@@ -975,7 +975,7 @@ async function deploySolana<N extends Network, C extends SolanaChains>(
975
975
// grep example_native_token_transfers = ".*"
976
976
// in solana/Anchor.toml
977
977
// TODO: what if they rename the program?
978
- const existingProgramId = fs . readFileSync ( " solana/Anchor.toml" ) . toString ( ) . match ( / e x a m p l e _ n a t i v e _ t o k e n _ t r a n s f e r s = " ( .* ) " / ) ?. [ 1 ] ;
978
+ const existingProgramId = fs . readFileSync ( ` ${ pwd } / solana/Anchor.toml` ) . toString ( ) . match ( / e x a m p l e _ n a t i v e _ t o k e n _ t r a n s f e r s = " ( .* ) " / ) ?. [ 1 ] ;
979
979
if ( ! existingProgramId ) {
980
980
console . error ( "Program ID not found in Anchor.toml (looked for example_native_token_transfers = \"(.*)\")" ) ;
981
981
process . exit ( 1 ) ;
@@ -1011,11 +1011,16 @@ async function deploySolana<N extends Network, C extends SolanaChains>(
1011
1011
// to update the latter in the Anchor.toml file and the lib.rs file(s)
1012
1012
const providedProgramId = programKeypair . publicKey . toBase58 ( ) ;
1013
1013
if ( providedProgramId !== existingProgramId ) {
1014
- console . error ( `Program keypair does not match the existing program ID: ${ existingProgramId } ` ) ;
1015
- await askForConfirmation ( `Do you want to update the program ID in the Anchor.toml file and the lib.rs file to ${ providedProgramId } ?` ) ;
1014
+ // only ask for confirmation if the current directory is ".". if it's
1015
+ // something else (a worktree) then it's a fresh checkout and we just
1016
+ // override the address anyway.
1017
+ if ( pwd === "." ) {
1018
+ console . error ( `Program keypair does not match the existing program ID: ${ existingProgramId } ` ) ;
1019
+ await askForConfirmation ( `Do you want to update the program ID in the Anchor.toml file and the lib.rs file to ${ providedProgramId } ?` ) ;
1020
+ }
1016
1021
1017
- const anchorTomlPath = " solana/Anchor.toml" ;
1018
- const libRsPath = " solana/programs/example-native-token-transfers/src/lib.rs" ;
1022
+ const anchorTomlPath = ` ${ pwd } / solana/Anchor.toml` ;
1023
+ const libRsPath = ` ${ pwd } / solana/programs/example-native-token-transfers/src/lib.rs` ;
1019
1024
1020
1025
const anchorToml = fs . readFileSync ( anchorTomlPath ) . toString ( ) ;
1021
1026
const newAnchorToml = anchorToml . replace ( existingProgramId , providedProgramId ) ;
0 commit comments