diff --git a/clients/js/package.json b/clients/js/package.json index b7b4d85..4515396 100644 --- a/clients/js/package.json +++ b/clients/js/package.json @@ -69,8 +69,7 @@ "rewritePaths": { "test/": "dist/test/" } - }, - "timeout": "60s" + } }, "packageManager": "pnpm@9.1.0" -} \ No newline at end of file +} diff --git a/clients/js/src/generated/instructions/createNativeMint.ts b/clients/js/src/generated/instructions/createNativeMint.ts index 646553a..f6cc756 100644 --- a/clients/js/src/generated/instructions/createNativeMint.ts +++ b/clients/js/src/generated/instructions/createNativeMint.ts @@ -7,6 +7,7 @@ */ import { + AccountRole, combineCodec, getStructDecoder, getStructEncoder, @@ -30,7 +31,7 @@ import { import { TOKEN_2022_PROGRAM_ADDRESS } from '../programs'; import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; -export const CREATE_NATIVE_MINT_DISCRIMINATOR = 27; +export const CREATE_NATIVE_MINT_DISCRIMINATOR = 31; export function getCreateNativeMintDiscriminatorBytes() { return getU8Encoder().encode(CREATE_NATIVE_MINT_DISCRIMINATOR); @@ -98,6 +99,7 @@ export type CreateNativeMintInput< nativeMint: Address; /** System program for mint account funding */ systemProgram?: Address; + multiSigners?: Array; }; export function getCreateNativeMintInstruction< @@ -132,18 +134,31 @@ export function getCreateNativeMintInstruction< ResolvedAccount >; + // Original args. + const args = { ...input }; + // Resolve default values. if (!accounts.systemProgram.value) { accounts.systemProgram.value = '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; } + // Remaining accounts. + const remainingAccounts: IAccountMeta[] = (args.multiSigners ?? []).map( + (signer) => ({ + address: signer.address, + role: AccountRole.READONLY_SIGNER, + signer, + }) + ); + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); const instruction = { accounts: [ getAccountMeta(accounts.payer), getAccountMeta(accounts.nativeMint), getAccountMeta(accounts.systemProgram), + ...remainingAccounts, ], programAddress, data: getCreateNativeMintInstructionDataEncoder().encode({}), diff --git a/clients/js/src/generated/programs/token2022.ts b/clients/js/src/generated/programs/token2022.ts index 6e52ff0..314f96d 100644 --- a/clients/js/src/generated/programs/token2022.ts +++ b/clients/js/src/generated/programs/token2022.ts @@ -114,7 +114,6 @@ export function identifyToken2022Account( export enum Token2022Instruction { InitializeMint, - CreateNativeMint, InitializeAccount, InitializeMultisig, Transfer, @@ -165,6 +164,7 @@ export enum Token2022Instruction { Reallocate, EnableMemoTransfers, DisableMemoTransfers, + CreateNativeMint, InitializeNonTransferableMint, EnableCpiGuard, DisableCpiGuard, @@ -192,9 +192,6 @@ export function identifyToken2022Instruction( if (containsBytes(data, getU8Encoder().encode(0), 0)) { return Token2022Instruction.InitializeMint; } - if (containsBytes(data, getU8Encoder().encode(27), 0)) { - return Token2022Instruction.CreateNativeMint; - } if (containsBytes(data, getU8Encoder().encode(1), 0)) { return Token2022Instruction.InitializeAccount; } @@ -417,6 +414,9 @@ export function identifyToken2022Instruction( ) { return Token2022Instruction.DisableMemoTransfers; } + if (containsBytes(data, getU8Encoder().encode(31), 0)) { + return Token2022Instruction.CreateNativeMint; + } if (containsBytes(data, getU8Encoder().encode(32), 0)) { return Token2022Instruction.InitializeNonTransferableMint; } @@ -552,9 +552,6 @@ export type ParsedToken2022Instruction< | ({ instructionType: Token2022Instruction.InitializeMint; } & ParsedInitializeMintInstruction) - | ({ - instructionType: Token2022Instruction.CreateNativeMint; - } & ParsedCreateNativeMintInstruction) | ({ instructionType: Token2022Instruction.InitializeAccount; } & ParsedInitializeAccountInstruction) @@ -705,6 +702,9 @@ export type ParsedToken2022Instruction< | ({ instructionType: Token2022Instruction.DisableMemoTransfers; } & ParsedDisableMemoTransfersInstruction) + | ({ + instructionType: Token2022Instruction.CreateNativeMint; + } & ParsedCreateNativeMintInstruction) | ({ instructionType: Token2022Instruction.InitializeNonTransferableMint; } & ParsedInitializeNonTransferableMintInstruction) diff --git a/clients/js/test/createNativeMint.test.ts b/clients/js/test/createNativeMint.test.ts index fd6df7e..c4cc7bf 100644 --- a/clients/js/test/createNativeMint.test.ts +++ b/clients/js/test/createNativeMint.test.ts @@ -21,7 +21,7 @@ test('it creates a native mint account', async (t) => { // When we create a native mint account. await sendAndConfirmInstructions(client, payer, [ - getCreateNativeMintInstruction({ + getCreateNativeMintInstruction({ payer: payer, nativeMint: NATIVE_MINT, }) diff --git a/program/idl.json b/program/idl.json index e2ce284..c756bac 100644 --- a/program/idl.json +++ b/program/idl.json @@ -461,78 +461,6 @@ } ] }, - { - "kind": "instructionNode", - "name": "createNativeMint", - "docs": [ - "Creates the native mint.", - "", - "This instruction only needs to be invoked once after deployment and is", - "permissionless. Wrapped SOL (`native_mint::id()`) will not be", - "available until this instruction is successfully executed." - ], - "optionalAccountStrategy": "programId", - "accounts": [ - { - "kind": "instructionAccountNode", - "name": "payer", - "isWritable": true, - "isSigner": true, - "isOptional": false, - "docs": [ - "Funding account (must be a system account)" - ] - }, - { - "kind": "instructionAccountNode", - "name": "nativeMint", - "isWritable": true, - "isSigner": false, - "isOptional": false, - "docs": [ - "The native mint address" - ] - }, - { - "kind": "instructionAccountNode", - "name": "systemProgram", - "isWritable": false, - "isSigner": false, - "isOptional": false, - "docs": [ - "System program for mint account funding" - ], - "defaultValue": { - "kind": "publicKeyValueNode", - "publicKey": "11111111111111111111111111111111" - } - } - ], - "arguments": [ - { - "kind": "instructionArgumentNode", - "name": "discriminator", - "defaultValueStrategy": "omitted", - "docs": [], - "type": { - "kind": "numberTypeNode", - "format": "u8", - "endian": "le" - }, - "defaultValue": { - "kind": "numberValueNode", - "number": 27 - } - } - ], - "discriminators": [ - { - "kind": "fieldDiscriminatorNode", - "name": "discriminator", - "offset": 0 - } - ] - }, { "kind": "instructionNode", "name": "initializeAccount", @@ -5417,6 +5345,84 @@ } ] }, + { + "kind": "instructionNode", + "name": "createNativeMint", + "docs": [ + "Creates the native mint.", + "", + "This instruction only needs to be invoked once after deployment and is", + "permissionless. Wrapped SOL (`native_mint::id()`) will not be", + "available until this instruction is successfully executed." + ], + "optionalAccountStrategy": "programId", + "accounts": [ + { + "kind": "instructionAccountNode", + "name": "payer", + "isWritable": true, + "isSigner": true, + "isOptional": false, + "docs": ["Funding account (must be a system account)"] + }, + { + "kind": "instructionAccountNode", + "name": "nativeMint", + "isWritable": true, + "isSigner": false, + "isOptional": false, + "docs": ["The native mint address"] + }, + { + "kind": "instructionAccountNode", + "name": "systemProgram", + "isWritable": false, + "isSigner": false, + "isOptional": false, + "docs": ["System program for mint account funding"], + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "11111111111111111111111111111111" + } + } + ], + "arguments": [ + { + "kind": "instructionArgumentNode", + "name": "discriminator", + "defaultValueStrategy": "omitted", + "docs": [], + "type": { + "kind": "numberTypeNode", + "format": "u8", + "endian": "le" + }, + "defaultValue": { + "kind": "numberValueNode", + "number": 31 + } + } + ], + "remainingAccounts": [ + { + "kind": "instructionRemainingAccountsNode", + "isOptional": true, + "isSigner": true, + "docs": [], + "value": { + "kind": "argumentValueNode", + "name": "multiSigners" + } + } + ], + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 + } + ] + }, { "kind": "instructionNode", "name": "initializeNonTransferableMint",