Skip to content

Commit

Permalink
feat(oft-solana): if only oft store, set freeze authority immediately…
Browse files Browse the repository at this point in the history
… to none (#1141)
  • Loading branch information
nazreen authored Dec 31, 2024
1 parent d4850c3 commit 1585928
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion examples/oft-solana/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ sh -c "$(curl -sSfL https://release.solana.com/v1.17.31/install)"

: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\*.

: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. You will also not be able to renounce the Freeze Authority. The Mint Authority and Freeze Authority will be fixed to the Mint Authority Multisig address.
: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.

#### For OFT:

Expand Down
21 changes: 13 additions & 8 deletions examples/oft-solana/tasks/solana/createOFT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
createV1,
mintV1,
} from '@metaplex-foundation/mpl-token-metadata'
import { setAuthority } from '@metaplex-foundation/mpl-toolbox'
import { AuthorityType, setAuthority } from '@metaplex-foundation/mpl-toolbox'
import {
createNoopSigner,
createSignerFromKeypair,
Expand All @@ -20,6 +20,7 @@ import bs58 from 'bs58'
import { task } from 'hardhat/config'

import { types as devtoolsTypes } from '@layerzerolabs/devtools-evm-hardhat'
import { promptToContinue } from '@layerzerolabs/io-devtools'
import { EndpointId } from '@layerzerolabs/lz-definitions'
import { OFT_DECIMALS as DEFAULT_SHARED_DECIMALS, oft, types } from '@layerzerolabs/oft-v2-solana-sdk'

Expand Down Expand Up @@ -110,7 +111,7 @@ interface CreateOFTTaskArgs {
// * Create the SPL Multisig account for mint authority
// * Mint the new SPL Token
// * Initialize the OFT Store account
// * Set the mint/freeze authority to the multisig account
// * Set the mint authority to the multisig account. If not in only OFT Store mode, also set the freeze authority to the multisig account.
// Note: Only supports SPL Token Standard.
task('lz:oft:solana:create', 'Mints new SPL Token and creates new OFT Store account')
.addOptionalParam('amount', 'The initial supply to mint on solana', undefined, devtoolsTypes.int)
Expand Down Expand Up @@ -172,13 +173,17 @@ 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 OFTStore, please specify --only-oft-store true'
'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.'
)
}
console.log(
'No additional minters specified. This will result in only the OFTStore being able to mint new tokens.'
}

if (onlyOftStore) {
await promptToContinue(
'You have chosen `--only-oft-store true`. This means that only the OFT Store will be able to mint new tokens and that the Freeze Authority will be immediately renounced. Continue?'
)
}

const additionalMinters = additionalMintersAsStrings?.map((minter) => new PublicKey(minter)) ?? []
const mintAuthorityPublicKey = await createMintAuthorityMultisig(
connection,
Expand Down Expand Up @@ -273,15 +278,15 @@ task('lz:oft:solana:create', 'Mints new SPL Token and creates new OFT Store acco
owned: mint.publicKey,
owner: umiWalletSigner,
newAuthority: fromWeb3JsPublicKey(mintAuthorityPublicKey),
authorityType: 0,
authorityType: AuthorityType.MintTokens,
})
)
.add(
setAuthority(umi, {
owned: mint.publicKey,
owner: umiWalletSigner,
newAuthority: fromWeb3JsPublicKey(mintAuthorityPublicKey),
authorityType: 1,
newAuthority: onlyOftStore ? null : fromWeb3JsPublicKey(mintAuthorityPublicKey),
authorityType: AuthorityType.FreezeAccount,
})
)
txBuilder = await addComputeUnitInstructions(
Expand Down

0 comments on commit 1585928

Please sign in to comment.