@@ -655,6 +655,11 @@ yargs(hideBin(process.argv))
655
655
656
656
const missing = await missingConfigs ( deps , verbose ) ;
657
657
658
+ if ( checkConfigErrors ( deps ) ) {
659
+ console . error ( "There are errors in the config file. Please fix these before continuing." ) ;
660
+ process . exit ( 1 ) ;
661
+ }
662
+
658
663
for ( const [ chain , missingConfig ] of Object . entries ( missing ) ) {
659
664
assertChain ( chain ) ;
660
665
const ntt = deps [ chain ] ! . ntt ;
@@ -733,10 +738,15 @@ yargs(hideBin(process.argv))
733
738
734
739
let deps : Partial < { [ C in Chain ] : Deployment < Chain > } > = await pullDeployments ( deployments , network , verbose ) ;
735
740
736
- let errors = 0 ;
741
+ let fixable = 0 ;
737
742
738
743
const extraInfo : any = { } ;
739
744
745
+ if ( checkConfigErrors ( deps ) ) {
746
+ console . error ( "There are errors in the config file. Please fix these before continuing." ) ;
747
+ process . exit ( 1 ) ;
748
+ }
749
+
740
750
// diff remote and local configs
741
751
for ( const [ chain , deployment ] of Object . entries ( deps ) ) {
742
752
assertChain ( chain ) ;
@@ -748,7 +758,7 @@ yargs(hideBin(process.argv))
748
758
const diff = diffObjects ( a , b ) ;
749
759
if ( Object . keys ( diff ) . length !== 0 ) {
750
760
console . error ( chalk . reset ( colorizeDiff ( diff ) ) ) ;
751
- errors ++ ;
761
+ fixable ++ ;
752
762
}
753
763
754
764
if ( verbose ) {
@@ -771,7 +781,7 @@ yargs(hideBin(process.argv))
771
781
const missing = await missingConfigs ( deps , verbose ) ;
772
782
773
783
if ( Object . keys ( missing ) . length > 0 ) {
774
- errors ++ ;
784
+ fixable ++ ;
775
785
}
776
786
777
787
for ( const [ chain , missingConfig ] of Object . entries ( missing ) ) {
@@ -796,7 +806,7 @@ yargs(hideBin(process.argv))
796
806
}
797
807
}
798
808
799
- if ( errors > 0 ) {
809
+ if ( fixable > 0 ) {
800
810
console . error ( "Run `ntt pull` to pull the remote configuration (overwriting the local one)" ) ;
801
811
console . error ( "Run `ntt push` to push the local configuration (overwriting the remote one) by executing the necessary transactions" ) ;
802
812
process . exit ( 1 ) ;
@@ -834,6 +844,34 @@ yargs(hideBin(process.argv))
834
844
const tokenAuthority = NTT . pdas ( programId ) . tokenAuthority ( ) ;
835
845
console . log ( tokenAuthority . toBase58 ( ) ) ;
836
846
} )
847
+ . command ( "ata <mint> <owner> <tokenProgram>" ,
848
+ "print the token authority address for a given program ID" ,
849
+ ( yargs ) => yargs
850
+ . positional ( "mint" , {
851
+ describe : "Mint address" ,
852
+ type : "string" ,
853
+ demandOption : true ,
854
+ } )
855
+ . positional ( "owner" , {
856
+ describe : "Owner address" ,
857
+ type : "string" ,
858
+ demandOption : true ,
859
+ } )
860
+ . positional ( "tokenProgram" , {
861
+ describe : "Token program ID" ,
862
+ type : "string" ,
863
+ choices : [ "legacy" , "token22" ] ,
864
+ demandOption : true ,
865
+ } ) ,
866
+ ( argv ) => {
867
+ const mint = new PublicKey ( argv [ "mint" ] ) ;
868
+ const owner = new PublicKey ( argv [ "owner" ] ) ;
869
+ const tokenProgram = argv [ "tokenProgram" ] === "legacy"
870
+ ? spl . TOKEN_PROGRAM_ID
871
+ : spl . TOKEN_2022_PROGRAM_ID
872
+ const ata = spl . getAssociatedTokenAddressSync ( mint , owner , true , tokenProgram ) ;
873
+ console . log ( ata . toBase58 ( ) ) ;
874
+ } )
837
875
. demandCommand ( )
838
876
}
839
877
)
@@ -857,6 +895,31 @@ type MissingImplicitConfig = {
857
895
solanaUpdateLUT : boolean ;
858
896
}
859
897
898
+ function checkConfigErrors ( deps : Partial < { [ C in Chain ] : Deployment < Chain > } > ) : number {
899
+ let fatal = 0 ;
900
+ for ( const [ chain , deployment ] of Object . entries ( deps ) ) {
901
+ assertChain ( chain ) ;
902
+ const config = deployment . config . local ! ;
903
+ if ( ! checkNumberFormatting ( config . limits . outbound , deployment . decimals ) ) {
904
+ console . error ( `ERROR: ${ chain } has an outbound limit (${ config . limits . outbound } ) with the wrong number of decimals. The number should have ${ deployment . decimals } decimals.` ) ;
905
+ fatal ++ ;
906
+ }
907
+ if ( config . limits . outbound === formatNumber ( 0n , deployment . decimals ) ) {
908
+ console . warn ( chalk . yellow ( `${ chain } has an outbound limit of 0` ) ) ;
909
+ }
910
+ for ( const [ c , limit ] of Object . entries ( config . limits . inbound ) ) {
911
+ if ( ! checkNumberFormatting ( limit , deployment . decimals ) ) {
912
+ console . error ( `ERROR: ${ chain } has an inbound limit with the wrong number of decimals for ${ c } (${ limit } ). The number should have ${ deployment . decimals } decimals.` ) ;
913
+ fatal ++ ;
914
+ }
915
+ if ( limit === formatNumber ( 0n , deployment . decimals ) ) {
916
+ console . warn ( chalk . yellow ( `${ chain } has an inbound limit of 0 from ${ c } ` ) ) ;
917
+ }
918
+ }
919
+ }
920
+ return fatal ;
921
+ }
922
+
860
923
function createWorkTree ( platform : Platform , version : string ) : string {
861
924
const tag = getGitTagName ( platform , version ) ;
862
925
if ( ! tag ) {
@@ -1737,6 +1800,18 @@ function formatNumber(num: bigint, decimals: number) {
1737
1800
return formatted ;
1738
1801
}
1739
1802
1803
+ function checkNumberFormatting ( formatted : string , decimals : number ) : boolean {
1804
+ // check that the string has the correct number of decimals
1805
+ const parts = formatted . split ( "." ) ;
1806
+ if ( parts . length !== 2 ) {
1807
+ return false ;
1808
+ }
1809
+ if ( parts [ 1 ] . length !== decimals ) {
1810
+ return false ;
1811
+ }
1812
+ return true ;
1813
+ }
1814
+
1740
1815
function cargoNetworkFeature ( network : Network ) : string {
1741
1816
switch ( network ) {
1742
1817
case "Mainnet" :
0 commit comments