@solana-program/system 0.12.1 → 0.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -493,6 +493,85 @@ function parseCreateAccountInstruction(instruction) {
493
493
  data: getCreateAccountInstructionDataDecoder().decode(instruction.data)
494
494
  };
495
495
  }
496
+ var CREATE_ACCOUNT_ALLOW_PREFUND_DISCRIMINATOR = 13;
497
+ function getCreateAccountAllowPrefundDiscriminatorBytes() {
498
+ return getU32Encoder().encode(CREATE_ACCOUNT_ALLOW_PREFUND_DISCRIMINATOR);
499
+ }
500
+ function getCreateAccountAllowPrefundInstructionDataEncoder() {
501
+ return transformEncoder(
502
+ getStructEncoder([
503
+ ["discriminator", getU32Encoder()],
504
+ ["lamports", getU64Encoder()],
505
+ ["space", getU64Encoder()],
506
+ ["programAddress", getAddressEncoder()]
507
+ ]),
508
+ (value) => ({
509
+ ...value,
510
+ discriminator: CREATE_ACCOUNT_ALLOW_PREFUND_DISCRIMINATOR,
511
+ lamports: value.lamports ?? 0
512
+ })
513
+ );
514
+ }
515
+ function getCreateAccountAllowPrefundInstructionDataDecoder() {
516
+ return getStructDecoder([
517
+ ["discriminator", getU32Decoder()],
518
+ ["lamports", getU64Decoder()],
519
+ ["space", getU64Decoder()],
520
+ ["programAddress", getAddressDecoder()]
521
+ ]);
522
+ }
523
+ function getCreateAccountAllowPrefundInstructionDataCodec() {
524
+ return combineCodec(
525
+ getCreateAccountAllowPrefundInstructionDataEncoder(),
526
+ getCreateAccountAllowPrefundInstructionDataDecoder()
527
+ );
528
+ }
529
+ function getCreateAccountAllowPrefundInstruction(input, config) {
530
+ const programAddress = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
531
+ const originalAccounts = {
532
+ newAccount: { value: input.newAccount ?? null, isWritable: true },
533
+ payer: { value: input.payer ?? null, isWritable: true }
534
+ };
535
+ const accounts = originalAccounts;
536
+ const args = { ...input };
537
+ const byteDelta = [Number(args.space) + BASE_ACCOUNT_SIZE].reduce((a, b) => a + b, 0);
538
+ const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
539
+ return Object.freeze({
540
+ accounts: [getAccountMeta("newAccount", accounts.newAccount), getAccountMeta("payer", accounts.payer)].filter(
541
+ (x) => x !== void 0
542
+ ),
543
+ byteDelta,
544
+ data: getCreateAccountAllowPrefundInstructionDataEncoder().encode(
545
+ args
546
+ ),
547
+ programAddress
548
+ });
549
+ }
550
+ function parseCreateAccountAllowPrefundInstruction(instruction) {
551
+ if (instruction.accounts.length < 1) {
552
+ throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
553
+ actualAccountMetas: instruction.accounts.length,
554
+ expectedAccountMetas: 1
555
+ });
556
+ }
557
+ let accountIndex = 0;
558
+ const getNextAccount = () => {
559
+ const accountMeta = instruction.accounts[accountIndex];
560
+ accountIndex += 1;
561
+ return accountMeta;
562
+ };
563
+ let optionalAccountsRemaining = instruction.accounts.length - 1;
564
+ const getNextOptionalAccount = () => {
565
+ if (optionalAccountsRemaining === 0) return void 0;
566
+ optionalAccountsRemaining -= 1;
567
+ return getNextAccount();
568
+ };
569
+ return {
570
+ programAddress: instruction.programAddress,
571
+ accounts: { newAccount: getNextAccount(), payer: getNextOptionalAccount() },
572
+ data: getCreateAccountAllowPrefundInstructionDataDecoder().decode(instruction.data)
573
+ };
574
+ }
496
575
  var CREATE_ACCOUNT_WITH_SEED_DISCRIMINATOR = 3;
497
576
  function getCreateAccountWithSeedDiscriminatorBytes() {
498
577
  return getU32Encoder().encode(CREATE_ACCOUNT_WITH_SEED_DISCRIMINATOR);
@@ -915,6 +994,7 @@ var SystemInstruction = /* @__PURE__ */ ((SystemInstruction2) => {
915
994
  SystemInstruction2[SystemInstruction2["AssignWithSeed"] = 10] = "AssignWithSeed";
916
995
  SystemInstruction2[SystemInstruction2["TransferSolWithSeed"] = 11] = "TransferSolWithSeed";
917
996
  SystemInstruction2[SystemInstruction2["UpgradeNonceAccount"] = 12] = "UpgradeNonceAccount";
997
+ SystemInstruction2[SystemInstruction2["CreateAccountAllowPrefund"] = 13] = "CreateAccountAllowPrefund";
918
998
  return SystemInstruction2;
919
999
  })(SystemInstruction || {});
920
1000
  function identifySystemInstruction(instruction) {
@@ -958,6 +1038,9 @@ function identifySystemInstruction(instruction) {
958
1038
  if (containsBytes(data, getU32Encoder().encode(12), 0)) {
959
1039
  return 12 /* UpgradeNonceAccount */;
960
1040
  }
1041
+ if (containsBytes(data, getU32Encoder().encode(13), 0)) {
1042
+ return 13 /* CreateAccountAllowPrefund */;
1043
+ }
961
1044
  throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION, {
962
1045
  instructionData: data,
963
1046
  programName: "system"
@@ -1045,6 +1128,13 @@ function parseSystemInstruction(instruction) {
1045
1128
  ...parseUpgradeNonceAccountInstruction(instruction)
1046
1129
  };
1047
1130
  }
1131
+ case 13 /* CreateAccountAllowPrefund */: {
1132
+ assertIsInstructionWithAccounts(instruction);
1133
+ return {
1134
+ instructionType: 13 /* CreateAccountAllowPrefund */,
1135
+ ...parseCreateAccountAllowPrefundInstruction(instruction)
1136
+ };
1137
+ }
1048
1138
  default:
1049
1139
  throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE, {
1050
1140
  instructionType,
@@ -1076,7 +1166,8 @@ function systemProgram() {
1076
1166
  allocateWithSeed: (input) => addSelfPlanAndSendFunctions(client, getAllocateWithSeedInstruction(input)),
1077
1167
  assignWithSeed: (input) => addSelfPlanAndSendFunctions(client, getAssignWithSeedInstruction(input)),
1078
1168
  transferSolWithSeed: (input) => addSelfPlanAndSendFunctions(client, getTransferSolWithSeedInstruction(input)),
1079
- upgradeNonceAccount: (input) => addSelfPlanAndSendFunctions(client, getUpgradeNonceAccountInstruction(input))
1169
+ upgradeNonceAccount: (input) => addSelfPlanAndSendFunctions(client, getUpgradeNonceAccountInstruction(input)),
1170
+ createAccountAllowPrefund: (input) => addSelfPlanAndSendFunctions(client, getCreateAccountAllowPrefundInstruction(input))
1080
1171
  }
1081
1172
  }
1082
1173
  });
@@ -1117,6 +1208,6 @@ function isSystemError(error, transactionMessage, code) {
1117
1208
  return isProgramError(error, transactionMessage, SYSTEM_PROGRAM_ADDRESS, code);
1118
1209
  }
1119
1210
 
1120
- export { ADVANCE_NONCE_ACCOUNT_DISCRIMINATOR, ALLOCATE_DISCRIMINATOR, ALLOCATE_WITH_SEED_DISCRIMINATOR, ASSIGN_DISCRIMINATOR, ASSIGN_WITH_SEED_DISCRIMINATOR, AUTHORIZE_NONCE_ACCOUNT_DISCRIMINATOR, CREATE_ACCOUNT_DISCRIMINATOR, CREATE_ACCOUNT_WITH_SEED_DISCRIMINATOR, INITIALIZE_NONCE_ACCOUNT_DISCRIMINATOR, NonceState, NonceVersion, SYSTEM_ERROR__ACCOUNT_ALREADY_IN_USE, SYSTEM_ERROR__ADDRESS_WITH_SEED_MISMATCH, SYSTEM_ERROR__INVALID_ACCOUNT_DATA_LENGTH, SYSTEM_ERROR__INVALID_PROGRAM_ID, SYSTEM_ERROR__MAX_SEED_LENGTH_EXCEEDED, SYSTEM_ERROR__NONCE_BLOCKHASH_NOT_EXPIRED, SYSTEM_ERROR__NONCE_NO_RECENT_BLOCKHASHES, SYSTEM_ERROR__NONCE_UNEXPECTED_BLOCKHASH_VALUE, SYSTEM_ERROR__RESULT_WITH_NEGATIVE_LAMPORTS, SYSTEM_PROGRAM_ADDRESS, SystemAccount, SystemInstruction, TRANSFER_SOL_DISCRIMINATOR, TRANSFER_SOL_WITH_SEED_DISCRIMINATOR, UPGRADE_NONCE_ACCOUNT_DISCRIMINATOR, WITHDRAW_NONCE_ACCOUNT_DISCRIMINATOR, decodeNonce, fetchAllMaybeNonce, fetchAllNonce, fetchMaybeNonce, fetchNonce, getAdvanceNonceAccountDiscriminatorBytes, getAdvanceNonceAccountInstruction, getAdvanceNonceAccountInstructionDataCodec, getAdvanceNonceAccountInstructionDataDecoder, getAdvanceNonceAccountInstructionDataEncoder, getAllocateDiscriminatorBytes, getAllocateInstruction, getAllocateInstructionDataCodec, getAllocateInstructionDataDecoder, getAllocateInstructionDataEncoder, getAllocateWithSeedDiscriminatorBytes, getAllocateWithSeedInstruction, getAllocateWithSeedInstructionDataCodec, getAllocateWithSeedInstructionDataDecoder, getAllocateWithSeedInstructionDataEncoder, getAssignDiscriminatorBytes, getAssignInstruction, getAssignInstructionDataCodec, getAssignInstructionDataDecoder, getAssignInstructionDataEncoder, getAssignWithSeedDiscriminatorBytes, getAssignWithSeedInstruction, getAssignWithSeedInstructionDataCodec, getAssignWithSeedInstructionDataDecoder, getAssignWithSeedInstructionDataEncoder, getAuthorizeNonceAccountDiscriminatorBytes, getAuthorizeNonceAccountInstruction, getAuthorizeNonceAccountInstructionDataCodec, getAuthorizeNonceAccountInstructionDataDecoder, getAuthorizeNonceAccountInstructionDataEncoder, getCreateAccountDiscriminatorBytes, getCreateAccountInstruction, getCreateAccountInstructionDataCodec, getCreateAccountInstructionDataDecoder, getCreateAccountInstructionDataEncoder, getCreateAccountWithSeedDiscriminatorBytes, getCreateAccountWithSeedInstruction, getCreateAccountWithSeedInstructionDataCodec, getCreateAccountWithSeedInstructionDataDecoder, getCreateAccountWithSeedInstructionDataEncoder, getInitializeNonceAccountDiscriminatorBytes, getInitializeNonceAccountInstruction, getInitializeNonceAccountInstructionDataCodec, getInitializeNonceAccountInstructionDataDecoder, getInitializeNonceAccountInstructionDataEncoder, getNonceCodec, getNonceDecoder, getNonceEncoder, getNonceSize, getNonceStateCodec, getNonceStateDecoder, getNonceStateEncoder, getNonceVersionCodec, getNonceVersionDecoder, getNonceVersionEncoder, getSystemErrorMessage, getTransferSolDiscriminatorBytes, getTransferSolInstruction, getTransferSolInstructionDataCodec, getTransferSolInstructionDataDecoder, getTransferSolInstructionDataEncoder, getTransferSolWithSeedDiscriminatorBytes, getTransferSolWithSeedInstruction, getTransferSolWithSeedInstructionDataCodec, getTransferSolWithSeedInstructionDataDecoder, getTransferSolWithSeedInstructionDataEncoder, getUpgradeNonceAccountDiscriminatorBytes, getUpgradeNonceAccountInstruction, getUpgradeNonceAccountInstructionDataCodec, getUpgradeNonceAccountInstructionDataDecoder, getUpgradeNonceAccountInstructionDataEncoder, getWithdrawNonceAccountDiscriminatorBytes, getWithdrawNonceAccountInstruction, getWithdrawNonceAccountInstructionDataCodec, getWithdrawNonceAccountInstructionDataDecoder, getWithdrawNonceAccountInstructionDataEncoder, identifySystemInstruction, isSystemError, parseAdvanceNonceAccountInstruction, parseAllocateInstruction, parseAllocateWithSeedInstruction, parseAssignInstruction, parseAssignWithSeedInstruction, parseAuthorizeNonceAccountInstruction, parseCreateAccountInstruction, parseCreateAccountWithSeedInstruction, parseInitializeNonceAccountInstruction, parseSystemInstruction, parseTransferSolInstruction, parseTransferSolWithSeedInstruction, parseUpgradeNonceAccountInstruction, parseWithdrawNonceAccountInstruction, systemProgram };
1211
+ export { ADVANCE_NONCE_ACCOUNT_DISCRIMINATOR, ALLOCATE_DISCRIMINATOR, ALLOCATE_WITH_SEED_DISCRIMINATOR, ASSIGN_DISCRIMINATOR, ASSIGN_WITH_SEED_DISCRIMINATOR, AUTHORIZE_NONCE_ACCOUNT_DISCRIMINATOR, CREATE_ACCOUNT_ALLOW_PREFUND_DISCRIMINATOR, CREATE_ACCOUNT_DISCRIMINATOR, CREATE_ACCOUNT_WITH_SEED_DISCRIMINATOR, INITIALIZE_NONCE_ACCOUNT_DISCRIMINATOR, NonceState, NonceVersion, SYSTEM_ERROR__ACCOUNT_ALREADY_IN_USE, SYSTEM_ERROR__ADDRESS_WITH_SEED_MISMATCH, SYSTEM_ERROR__INVALID_ACCOUNT_DATA_LENGTH, SYSTEM_ERROR__INVALID_PROGRAM_ID, SYSTEM_ERROR__MAX_SEED_LENGTH_EXCEEDED, SYSTEM_ERROR__NONCE_BLOCKHASH_NOT_EXPIRED, SYSTEM_ERROR__NONCE_NO_RECENT_BLOCKHASHES, SYSTEM_ERROR__NONCE_UNEXPECTED_BLOCKHASH_VALUE, SYSTEM_ERROR__RESULT_WITH_NEGATIVE_LAMPORTS, SYSTEM_PROGRAM_ADDRESS, SystemAccount, SystemInstruction, TRANSFER_SOL_DISCRIMINATOR, TRANSFER_SOL_WITH_SEED_DISCRIMINATOR, UPGRADE_NONCE_ACCOUNT_DISCRIMINATOR, WITHDRAW_NONCE_ACCOUNT_DISCRIMINATOR, decodeNonce, fetchAllMaybeNonce, fetchAllNonce, fetchMaybeNonce, fetchNonce, getAdvanceNonceAccountDiscriminatorBytes, getAdvanceNonceAccountInstruction, getAdvanceNonceAccountInstructionDataCodec, getAdvanceNonceAccountInstructionDataDecoder, getAdvanceNonceAccountInstructionDataEncoder, getAllocateDiscriminatorBytes, getAllocateInstruction, getAllocateInstructionDataCodec, getAllocateInstructionDataDecoder, getAllocateInstructionDataEncoder, getAllocateWithSeedDiscriminatorBytes, getAllocateWithSeedInstruction, getAllocateWithSeedInstructionDataCodec, getAllocateWithSeedInstructionDataDecoder, getAllocateWithSeedInstructionDataEncoder, getAssignDiscriminatorBytes, getAssignInstruction, getAssignInstructionDataCodec, getAssignInstructionDataDecoder, getAssignInstructionDataEncoder, getAssignWithSeedDiscriminatorBytes, getAssignWithSeedInstruction, getAssignWithSeedInstructionDataCodec, getAssignWithSeedInstructionDataDecoder, getAssignWithSeedInstructionDataEncoder, getAuthorizeNonceAccountDiscriminatorBytes, getAuthorizeNonceAccountInstruction, getAuthorizeNonceAccountInstructionDataCodec, getAuthorizeNonceAccountInstructionDataDecoder, getAuthorizeNonceAccountInstructionDataEncoder, getCreateAccountAllowPrefundDiscriminatorBytes, getCreateAccountAllowPrefundInstruction, getCreateAccountAllowPrefundInstructionDataCodec, getCreateAccountAllowPrefundInstructionDataDecoder, getCreateAccountAllowPrefundInstructionDataEncoder, getCreateAccountDiscriminatorBytes, getCreateAccountInstruction, getCreateAccountInstructionDataCodec, getCreateAccountInstructionDataDecoder, getCreateAccountInstructionDataEncoder, getCreateAccountWithSeedDiscriminatorBytes, getCreateAccountWithSeedInstruction, getCreateAccountWithSeedInstructionDataCodec, getCreateAccountWithSeedInstructionDataDecoder, getCreateAccountWithSeedInstructionDataEncoder, getInitializeNonceAccountDiscriminatorBytes, getInitializeNonceAccountInstruction, getInitializeNonceAccountInstructionDataCodec, getInitializeNonceAccountInstructionDataDecoder, getInitializeNonceAccountInstructionDataEncoder, getNonceCodec, getNonceDecoder, getNonceEncoder, getNonceSize, getNonceStateCodec, getNonceStateDecoder, getNonceStateEncoder, getNonceVersionCodec, getNonceVersionDecoder, getNonceVersionEncoder, getSystemErrorMessage, getTransferSolDiscriminatorBytes, getTransferSolInstruction, getTransferSolInstructionDataCodec, getTransferSolInstructionDataDecoder, getTransferSolInstructionDataEncoder, getTransferSolWithSeedDiscriminatorBytes, getTransferSolWithSeedInstruction, getTransferSolWithSeedInstructionDataCodec, getTransferSolWithSeedInstructionDataDecoder, getTransferSolWithSeedInstructionDataEncoder, getUpgradeNonceAccountDiscriminatorBytes, getUpgradeNonceAccountInstruction, getUpgradeNonceAccountInstructionDataCodec, getUpgradeNonceAccountInstructionDataDecoder, getUpgradeNonceAccountInstructionDataEncoder, getWithdrawNonceAccountDiscriminatorBytes, getWithdrawNonceAccountInstruction, getWithdrawNonceAccountInstructionDataCodec, getWithdrawNonceAccountInstructionDataDecoder, getWithdrawNonceAccountInstructionDataEncoder, identifySystemInstruction, isSystemError, parseAdvanceNonceAccountInstruction, parseAllocateInstruction, parseAllocateWithSeedInstruction, parseAssignInstruction, parseAssignWithSeedInstruction, parseAuthorizeNonceAccountInstruction, parseCreateAccountAllowPrefundInstruction, parseCreateAccountInstruction, parseCreateAccountWithSeedInstruction, parseInitializeNonceAccountInstruction, parseSystemInstruction, parseTransferSolInstruction, parseTransferSolWithSeedInstruction, parseUpgradeNonceAccountInstruction, parseWithdrawNonceAccountInstruction, systemProgram };
1121
1212
  //# sourceMappingURL=index.mjs.map
1122
1213
  //# sourceMappingURL=index.mjs.map