diff --git a/examples/lzapp-migration/README.md b/examples/lzapp-migration/README.md index 04d47e6775..2c3700dd6a 100644 --- a/examples/lzapp-migration/README.md +++ b/examples/lzapp-migration/README.md @@ -217,7 +217,7 @@ solana program deploy --program-id target/deploy/oft-keypair.json target/verifia :information_source: For **OFT** and **OFT Mint-and-Burn Adapter**, the SPL token's Mint Authority is set to the **Mint Authority Multisig**, which always has the **OFT Store** as a signer. The multisig is fixed to needing 1 of N signatures. -:information_source: For **OFT** and **OFT Mint-And-Burn Adapter**, you have the option to specify additional signers through the `--additional-minters` flag. If you choose not to, you must pass in `--only-oft-store true`, which means only the **OFT Store** will be a signer for the \_Mint Authority Multisig\*. +:information_source: For **OFT** and **OFT Mint-And-Burn Adapter**, you have the option to specify additional signers through the `--additional-minters` flag. If you choose not to, you must pass in `--only-oft-store`, which means only the **OFT Store** will be a signer for the \_Mint Authority Multisig\*. :warning: If you choose to go with `--only-oft-store`, you will not be able to add in other signers/minters or update the Mint Authority, and the Freeze Authority will be immediately renounced. The token Mint Authority will be fixed Mint Authority Multisig address while the Freeze Authority will be set to None. @@ -227,7 +227,7 @@ solana program deploy --program-id target/deploy/oft-keypair.json target/verifia pnpm hardhat lz:oft:solana:create --eid 40168 --program-id ``` -:warning: Use `--additional-minters` flag to add a CSV of additional minter addresses to the Mint Authority Multisig. If you do not want to, you must specify `--only-oft-store true`. +:warning: Use `--additional-minters` flag to add a CSV of additional minter addresses to the Mint Authority Multisig. If you do not want to, you must specify `--only-oft-store`. :information_source: You can also specify `--amount ` to have the OFT minted to your deployer address upon token creation. diff --git a/examples/lzapp-migration/tasks/solana/createOFT.ts b/examples/lzapp-migration/tasks/solana/createOFT.ts index 0b92938c31..186b56ba9c 100644 --- a/examples/lzapp-migration/tasks/solana/createOFT.ts +++ b/examples/lzapp-migration/tasks/solana/createOFT.ts @@ -143,11 +143,9 @@ task('lz:oft:solana:create', 'Mints new SPL Token and creates new OFT Store acco .addParam('symbol', 'Token Symbol', 'MOFT', devtoolsTypes.string) .addParam('tokenMetadataIsMutable', 'Token metadata is mutable', true, devtoolsTypes.boolean) .addParam('additionalMinters', 'Comma-separated list of additional minters', undefined, devtoolsTypes.csv, true) - .addOptionalParam( + .addFlag( 'onlyOftStore', - 'If you plan to have only the OFTStore and no additional minters. This is not reversible, and will result in losing the ability to mint new tokens by everything but the OFTStore.', - false, - devtoolsTypes.boolean + 'If you plan to have only the OFTStore and no additional minters. This is not reversible, and will result in losing the ability to mint new tokens by everything but the OFTStore.' ) .addParam( 'tokenProgram', @@ -205,13 +203,13 @@ task('lz:oft:solana:create', 'Mints new SPL Token and creates new OFT Store acco if (!additionalMintersAsStrings) { if (!onlyOftStore) { throw new Error( - 'If you want to proceed with only the OFT Store having the ability to mint, please specify --only-oft-store true. Note that this also means the Freeze Authority will be immediately renounced, unless --freeze-authority is specified.' + 'If you want to proceed with only the OFT Store having the ability to mint, please specify --only-oft-store. Note that this also means the Freeze Authority will be immediately renounced, unless --freeze-authority is specified.' ) } } if (freezeAuthorityStr && !onlyOftStore) { - throw new Error('`--freeze-authority` is only supported in `--only-oft-store true` mode') + throw new Error('`--freeze-authority` is only supported in `--only-oft-store` mode') } if (onlyOftStore && additionalMintersAsStrings && additionalMintersAsStrings?.length > 0) { @@ -222,7 +220,7 @@ task('lz:oft:solana:create', 'Mints new SPL Token and creates new OFT Store acco if (onlyOftStore && !ci) { const continueWithOnlyOftStore = await promptToContinue( - `You have chosen \`--only-oft-store true\`. This means that only the OFT Store will be able to mint new tokens${freezeAuthorityStr ? '' : ' and that the Freeze Authority will be immediately renounced'}. Continue?` + `You have chosen \`--only-oft-store\`. This means that only the OFT Store will be able to mint new tokens${freezeAuthorityStr ? '' : ' and that the Freeze Authority will be immediately renounced'}. Continue?` ) if (!continueWithOnlyOftStore) { return diff --git a/examples/lzapp-migration/tasks/solana/setAuthority.ts b/examples/lzapp-migration/tasks/solana/setAuthority.ts index 404a2f4be6..124e859a02 100644 --- a/examples/lzapp-migration/tasks/solana/setAuthority.ts +++ b/examples/lzapp-migration/tasks/solana/setAuthority.ts @@ -94,11 +94,9 @@ task('lz:oft:solana:setauthority', 'Create a new Mint Authority SPL multisig and .addParam('programId', 'The OFT Program id') .addParam('escrow', 'The OFT Escrow public key') .addParam('additionalMinters', 'Comma-separated list of additional minters', undefined, devtoolsTypes.csv, true) - .addOptionalParam( + .addFlag( 'onlyOftStore', - 'If you plan to have only the OFTStore and no additional minters. This is not reversible, and will result in losing the ability to mint new tokens by everything but the OFTStore.', - false, - devtoolsTypes.boolean + 'If you plan to have only the OFTStore and no additional minters. This is not reversible, and will result in losing the ability to mint new tokens by everything but the OFTStore.' ) .addParam( 'tokenProgram', @@ -123,9 +121,7 @@ task('lz:oft:solana:setauthority', 'Create a new Mint Authority SPL multisig and const tokenProgram = publicKey(tokenProgramStr) if (!additionalMintersAsStrings) { if (!onlyOftStore) { - throw new Error( - 'If you want to proceed with only the OFTStore, please specify --only-oft-store true' - ) + throw new Error('If you want to proceed with only the OFTStore, please specify --only-oft-store') } console.log( 'No additional minters specified. This will result in only the OFTStore being able to mint new tokens.' diff --git a/examples/oft-solana/README.md b/examples/oft-solana/README.md index ee250f32c1..f43d73a0bb 100644 --- a/examples/oft-solana/README.md +++ b/examples/oft-solana/README.md @@ -208,7 +208,7 @@ solana program deploy --program-id target/deploy/oft-keypair.json target/verifia ### Create the Solana OFT ```bash -pnpm hardhat lz:oft:solana:create --eid 40168 --program-id --only-oft-store true --amount 100000000000 +pnpm hardhat lz:oft:solana:create --eid 40168 --program-id --only-oft-store --amount 100000000000 ``` The above command will create a Solana OFT which will have only the OFT Store as the Mint Authority and will also mint 100 OFT (given the default 9 decimals on Solana, this would be `100_000_000_000` in raw amount). @@ -317,7 +317,7 @@ This section explains the three different options available for creating OFTs on - **Note**: Preferred option when you don't have an existing token ```bash -pnpm hardhat lz:oft:solana:create --eid 40168 --program-id --only-oft-store true --amount 100000000000 +pnpm hardhat lz:oft:solana:create --eid 40168 --program-id --only-oft-store --amount 100000000000 ``` ### OFT Adapter @@ -452,9 +452,8 @@ npx hardhat --help Comma-separated list of additional minters _Default: undefined_ -- **`--only-oft-store`** (boolean) - If you plan to have only the OFTStore and no additional minters. This is not reversible, and will result in losing the ability to mint new tokens by everything but the OFTStore. - _Default: false_ +- **`--only-oft-store`** (flag) + If you plan to have only the OFTStore and no additional minters. This is not reversible, and will result in losing the ability to mint new tokens by everything but the OFTStore. - **`--freeze-authority`** (string) The Freeze Authority address (only supported in onlyOftStore mode) @@ -476,13 +475,13 @@ The following parameters are only used for Mint-And-Burn Adapter (MABA) mode: :information_source: For **OFT**, the SPL token's Mint Authority is set to the **Mint Authority Multisig**, which always has the **OFT Store** as a signer. The multisig is fixed to needing 1 of N signatures. -:information_source: You have the option to specify additional signers through the `--additional-minters` flag. If you choose not to, you must pass in `--only-oft-store true`, which means only the **OFT Store** will be a signer for the **Mint Authority Multisig**. +:information_source: You have the option to specify additional signers through the `--additional-minters` flag. If you choose not to, you must pass in `--only-oft-store`, which means only the **OFT Store** will be a signer for the **Mint Authority Multisig**. :warning: If you choose to go with `--only-oft-store`, you will not be able to add in other signers/minters or update the Mint Authority, and the Freeze Authority will be immediately renounced. The token Mint Authority will be fixed Mint Authority Multisig address while the Freeze Authority will be set to None. ##### Important Notes -:warning: Use `--additional-minters` flag to add a CSV of additional minter addresses to the Mint Authority Multisig. If you do not want to, you must specify `--only-oft-store true`. +:warning: Use `--additional-minters` flag to add a CSV of additional minter addresses to the Mint Authority Multisig. If you do not want to, you must specify `--only-oft-store`.
pnpm hardhat lz:oft:solana:debug --eid @@ -512,7 +511,7 @@ const solanaContract: OmniPointHardhat = { This is only relevant for **OFT**. If you opted to include the `--amount` flag in the create step, that means you already have minted some Solana OFT and you can skip this section. -:information_source: This is only possible if you specified your deployer address as part of the `--additional-minters` flag when creating the Solana OFT. If you had chosen `--only-oft-store true`, you will not be able to mint your OFT on Solana. +:information_source: This is only possible if you specified your deployer address as part of the `--additional-minters` flag when creating the Solana OFT. If you had chosen `--only-oft-store`, you will not be able to mint your OFT on Solana. First, you need to create the Associated Token Account for your address. diff --git a/examples/oft-solana/tasks/solana/createOFT.ts b/examples/oft-solana/tasks/solana/createOFT.ts index a9c8f56319..1bd6660deb 100644 --- a/examples/oft-solana/tasks/solana/createOFT.ts +++ b/examples/oft-solana/tasks/solana/createOFT.ts @@ -143,11 +143,9 @@ task('lz:oft:solana:create', 'Mints new SPL Token and creates new OFT Store acco .addParam('symbol', 'Token Symbol', 'MOFT', devtoolsTypes.string) .addParam('tokenMetadataIsMutable', 'Token metadata is mutable', true, devtoolsTypes.boolean) .addParam('additionalMinters', 'Comma-separated list of additional minters', undefined, devtoolsTypes.csv, true) - .addOptionalParam( + .addFlag( 'onlyOftStore', - 'If you plan to have only the OFTStore and no additional minters. This is not reversible, and will result in losing the ability to mint new tokens by everything but the OFTStore.', - false, - devtoolsTypes.boolean + 'If you plan to have only the OFTStore and no additional minters. This is not reversible, and will result in losing the ability to mint new tokens by everything but the OFTStore.' ) .addParam( 'tokenProgram', @@ -205,13 +203,13 @@ task('lz:oft:solana:create', 'Mints new SPL Token and creates new OFT Store acco if (!additionalMintersAsStrings) { if (!onlyOftStore) { throw new Error( - 'If you want to proceed with only the OFT Store having the ability to mint, please specify --only-oft-store true. Note that this also means the Freeze Authority will be immediately renounced, unless --freeze-authority is specified.' + 'If you want to proceed with only the OFT Store having the ability to mint, please specify --only-oft-store. Note that this also means the Freeze Authority will be immediately renounced, unless --freeze-authority is specified.' ) } } if (freezeAuthorityStr && !onlyOftStore) { - throw new Error('`--freeze-authority` is only supported in `--only-oft-store true` mode') + throw new Error('`--freeze-authority` is only supported in `--only-oft-store` mode') } if (onlyOftStore && additionalMintersAsStrings && additionalMintersAsStrings?.length > 0) { @@ -222,7 +220,7 @@ task('lz:oft:solana:create', 'Mints new SPL Token and creates new OFT Store acco if (onlyOftStore && !ci) { const continueWithOnlyOftStore = await promptToContinue( - `You have chosen \`--only-oft-store true\`. This means that only the OFT Store will be able to mint new tokens${freezeAuthorityStr ? '' : ' and that the Freeze Authority will be immediately renounced'}. Continue?` + `You have chosen \`--only-oft-store\`. This means that only the OFT Store will be able to mint new tokens${freezeAuthorityStr ? '' : ' and that the Freeze Authority will be immediately renounced'}. Continue?` ) if (!continueWithOnlyOftStore) { return @@ -234,9 +232,11 @@ task('lz:oft:solana:create', 'Mints new SPL Token and creates new OFT Store acco const maxSupplyRaw = localDecimalsToMaxWholeTokens(decimals) const { full, compact } = formatTokenAmount(maxSupplyRaw) const maxSupplyStatement = `You have chosen ${decimals} local decimals. The maximum supply of your Solana OFT token will be ${full} (~${compact}).\n` - const confirmMaxSupply = await promptToContinue(maxSupplyStatement) - if (!confirmMaxSupply) { - return + if (!ci) { + const confirmMaxSupply = await promptToContinue(maxSupplyStatement) + if (!confirmMaxSupply) { + return + } } let mintAuthorityPublicKey: PublicKey = toWeb3JsPublicKey(oftStorePda) // we default to the OFT Store as the Mint Authority when there are no additional minters @@ -265,11 +265,13 @@ task('lz:oft:solana:create', 'Mints new SPL Token and creates new OFT Store acco let freezeAuthority: PublicKey | null = null if (freezeAuthorityStr && onlyOftStore) { freezeAuthority = new PublicKey(freezeAuthorityStr) // will error if invalid - const continueFreezeAuthority = await promptToContinue( - `Freeze Authority will be set to ${freezeAuthority.toBase58()}. Continue?` - ) - if (!continueFreezeAuthority) { - return + if (!ci) { + const continueFreezeAuthority = await promptToContinue( + `Freeze Authority will be set to ${freezeAuthority.toBase58()}. Continue?` + ) + if (!continueFreezeAuthority) { + return + } } } else { // onlyOftStore mode: if freezeAuthority is not provided, we set it to null diff --git a/examples/oft-solana/tasks/solana/createOFTAdapter.ts b/examples/oft-solana/tasks/solana/createOFTAdapter.ts index c6ec44ebe0..a5260a1500 100644 --- a/examples/oft-solana/tasks/solana/createOFTAdapter.ts +++ b/examples/oft-solana/tasks/solana/createOFTAdapter.ts @@ -42,6 +42,11 @@ interface CreateOFTAdapterTaskArgs { tokenProgram: string computeUnitPriceScaleFactor: number + + /** + * Whether to continue without confirmation. + */ + ci: boolean } // Define a Hardhat task for creating OFTAdapter on Solana @@ -51,6 +56,7 @@ task('lz:oft-adapter:solana:create', 'Creates new OFT Adapter (OFT Store PDA)') .addParam('eid', 'Solana mainnet (30168) or testnet (40168)', undefined, devtoolsTypes.eid) .addParam('tokenProgram', 'The Token Program public key', TOKEN_PROGRAM_ID.toBase58(), devtoolsTypes.string, true) .addParam('computeUnitPriceScaleFactor', 'The compute unit price scale factor', 4, devtoolsTypes.float, true) + .addFlag('ci', 'Continue without confirmation') .setAction( async ({ eid, @@ -58,6 +64,7 @@ task('lz:oft-adapter:solana:create', 'Creates new OFT Adapter (OFT Store PDA)') programId: programIdStr, tokenProgram: tokenProgramStr, computeUnitPriceScaleFactor, + ci, }: CreateOFTAdapterTaskArgs) => { const { connection, umi, umiWalletKeyPair, umiWalletSigner } = await deriveConnection(eid) const { programId, lockBox, escrowPK, oftStorePda, eddsa } = deriveKeys(programIdStr) @@ -71,9 +78,11 @@ task('lz:oft-adapter:solana:create', 'Creates new OFT Adapter (OFT Store PDA)') const maxSupplyRaw = localDecimalsToMaxWholeTokens(mintDecimals) const { full, compact } = formatTokenAmount(maxSupplyRaw) const maxSupplyStatement = `The underlying token has ${mintDecimals} local decimals. Its maximum supply is ${full} (~${compact}).\n` - const confirmMaxSupply = await promptToContinue(maxSupplyStatement) - if (!confirmMaxSupply) { - return + if (!ci) { + const confirmMaxSupply = await promptToContinue(maxSupplyStatement) + if (!confirmMaxSupply) { + return + } } const mintAuthority = mintPDA.mintAuthority diff --git a/examples/oft-solana/tasks/solana/setAuthority.ts b/examples/oft-solana/tasks/solana/setAuthority.ts index 56d8b84070..ad48bc78da 100644 --- a/examples/oft-solana/tasks/solana/setAuthority.ts +++ b/examples/oft-solana/tasks/solana/setAuthority.ts @@ -94,11 +94,9 @@ task('lz:oft:solana:setauthority', 'Create a new Mint Authority SPL multisig and .addParam('programId', 'The OFT Program id') .addParam('escrow', 'The OFT Escrow public key') .addParam('additionalMinters', 'Comma-separated list of additional minters', undefined, devtoolsTypes.csv, true) - .addOptionalParam( + .addFlag( 'onlyOftStore', - 'If you plan to have only the OFTStore and no additional minters. This is not reversible, and will result in losing the ability to mint new tokens by everything but the OFTStore.', - false, - devtoolsTypes.boolean + 'If you plan to have only the OFTStore and no additional minters. This is not reversible, and will result in losing the ability to mint new tokens by everything but the OFTStore.' ) .addParam( 'tokenProgram', @@ -123,9 +121,7 @@ task('lz:oft:solana:setauthority', 'Create a new Mint Authority SPL multisig and const tokenProgram = publicKey(tokenProgramStr) if (!additionalMintersAsStrings) { if (!onlyOftStore) { - throw new Error( - 'If you want to proceed with only the OFTStore, please specify --only-oft-store true' - ) + throw new Error('If you want to proceed with only the OFTStore, please specify --only-oft-store') } console.log( 'No additional minters specified. This will result in only the OFTStore being able to mint new tokens.' diff --git a/examples/oft-solana/tasks/solana/setUpdateAuthority.ts b/examples/oft-solana/tasks/solana/setUpdateAuthority.ts index 3658728487..57d8e6f525 100644 --- a/examples/oft-solana/tasks/solana/setUpdateAuthority.ts +++ b/examples/oft-solana/tasks/solana/setUpdateAuthority.ts @@ -15,6 +15,7 @@ interface Args { newUpdateAuthority?: string renounceUpdateAuthority?: boolean eid: EndpointId + ci: boolean } // sets the update authority via Metaplex @@ -27,8 +28,15 @@ task('lz:oft:solana:set-update-authority', 'Updates the metaplex update authorit .addParam('mint', 'The Token mint public key', undefined, devtoolsTypes.string) .addOptionalParam('newUpdateAuthority', 'The new update authority', undefined, devtoolsTypes.string) .addOptionalParam('renounceUpdateAuthority', 'Renounce update authority', false, devtoolsTypes.boolean) + .addFlag('ci', 'Continue without confirmation') .setAction( - async ({ eid, mint: mintStr, newUpdateAuthority: newUpdateAuthorityStr, renounceUpdateAuthority }: Args) => { + async ({ + eid, + mint: mintStr, + newUpdateAuthority: newUpdateAuthorityStr, + renounceUpdateAuthority, + ci, + }: Args) => { // if not renouncing, must provide new update authority if (!renounceUpdateAuthority && !newUpdateAuthorityStr) { throw new Error( @@ -73,7 +81,7 @@ task('lz:oft:solana:set-update-authority', 'Updates the metaplex update authorit console.log(`\nCurrent update authority: ${initialMetadata.updateAuthority}\n`) console.log(`\nNew update authority: ${updateAuthority.toString()}\n`) - if (renounceUpdateAuthority) { + if (renounceUpdateAuthority && !ci) { const doContinue = await promptToContinue( 'You have chosen `--renounce-update-authority true`. This means that the Update Authority will be immediately renounced. This is irreversible. Continue?' ) diff --git a/packages/verify-contract/src/index.ts b/packages/verify-contract/src/index.ts index 311683e1e6..caff802dc7 100644 --- a/packages/verify-contract/src/index.ts +++ b/packages/verify-contract/src/index.ts @@ -2,3 +2,5 @@ export { verifyTarget as verifyHardhatDeployTarget, verifyNonTarget as verifyHardhatDeployNonTarget, } from './hardhat-deploy/verify' + +export { getDefaultChainId } from './common/networks-loader'