Skip to content

Commit 8f26fc6

Browse files
committed
cli: update solana addresses in worktree
1 parent d2b8884 commit 8f26fc6

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

cli/src/index.ts

+10-5
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,7 @@ async function deploySolana<N extends Network, C extends SolanaChains>(
975975
// grep example_native_token_transfers = ".*"
976976
// in solana/Anchor.toml
977977
// TODO: what if they rename the program?
978-
const existingProgramId = fs.readFileSync("solana/Anchor.toml").toString().match(/example_native_token_transfers = "(.*)"/)?.[1];
978+
const existingProgramId = fs.readFileSync(`${pwd}/solana/Anchor.toml`).toString().match(/example_native_token_transfers = "(.*)"/)?.[1];
979979
if (!existingProgramId) {
980980
console.error("Program ID not found in Anchor.toml (looked for example_native_token_transfers = \"(.*)\")");
981981
process.exit(1);
@@ -1011,11 +1011,16 @@ async function deploySolana<N extends Network, C extends SolanaChains>(
10111011
// to update the latter in the Anchor.toml file and the lib.rs file(s)
10121012
const providedProgramId = programKeypair.publicKey.toBase58();
10131013
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+
}
10161021

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`;
10191024

10201025
const anchorToml = fs.readFileSync(anchorTomlPath).toString();
10211026
const newAnchorToml = anchorToml.replace(existingProgramId, providedProgramId);

0 commit comments

Comments
 (0)