@solana-program/system 0.1.3 → 0.3.0

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.
Files changed (47) hide show
  1. package/dist/src/index.cjs +414 -678
  2. package/dist/src/index.cjs.map +1 -1
  3. package/dist/src/index.js +281 -530
  4. package/dist/src/index.js.map +1 -1
  5. package/dist/types/src/generated/accounts/nonce.d.ts +12 -16
  6. package/dist/types/src/generated/accounts/nonce.d.ts.map +1 -1
  7. package/dist/types/src/generated/errors/system.d.ts +20 -27
  8. package/dist/types/src/generated/errors/system.d.ts.map +1 -1
  9. package/dist/types/src/generated/index.d.ts +0 -1
  10. package/dist/types/src/generated/index.d.ts.map +1 -1
  11. package/dist/types/src/generated/instructions/advanceNonceAccount.d.ts +6 -25
  12. package/dist/types/src/generated/instructions/advanceNonceAccount.d.ts.map +1 -1
  13. package/dist/types/src/generated/instructions/allocate.d.ts +6 -20
  14. package/dist/types/src/generated/instructions/allocate.d.ts.map +1 -1
  15. package/dist/types/src/generated/instructions/allocateWithSeed.d.ts +6 -26
  16. package/dist/types/src/generated/instructions/allocateWithSeed.d.ts.map +1 -1
  17. package/dist/types/src/generated/instructions/assign.d.ts +6 -20
  18. package/dist/types/src/generated/instructions/assign.d.ts.map +1 -1
  19. package/dist/types/src/generated/instructions/assignWithSeed.d.ts +6 -25
  20. package/dist/types/src/generated/instructions/assignWithSeed.d.ts.map +1 -1
  21. package/dist/types/src/generated/instructions/authorizeNonceAccount.d.ts +6 -23
  22. package/dist/types/src/generated/instructions/authorizeNonceAccount.d.ts.map +1 -1
  23. package/dist/types/src/generated/instructions/createAccount.d.ts +6 -25
  24. package/dist/types/src/generated/instructions/createAccount.d.ts.map +1 -1
  25. package/dist/types/src/generated/instructions/createAccountWithSeed.d.ts +6 -30
  26. package/dist/types/src/generated/instructions/createAccountWithSeed.d.ts.map +1 -1
  27. package/dist/types/src/generated/instructions/initializeNonceAccount.d.ts +6 -25
  28. package/dist/types/src/generated/instructions/initializeNonceAccount.d.ts.map +1 -1
  29. package/dist/types/src/generated/instructions/transferSol.d.ts +6 -23
  30. package/dist/types/src/generated/instructions/transferSol.d.ts.map +1 -1
  31. package/dist/types/src/generated/instructions/transferSolWithSeed.d.ts +6 -28
  32. package/dist/types/src/generated/instructions/transferSolWithSeed.d.ts.map +1 -1
  33. package/dist/types/src/generated/instructions/upgradeNonceAccount.d.ts +6 -18
  34. package/dist/types/src/generated/instructions/upgradeNonceAccount.d.ts.map +1 -1
  35. package/dist/types/src/generated/instructions/withdrawNonceAccount.d.ts +6 -32
  36. package/dist/types/src/generated/instructions/withdrawNonceAccount.d.ts.map +1 -1
  37. package/dist/types/src/generated/programs/system.d.ts +1 -5
  38. package/dist/types/src/generated/programs/system.d.ts.map +1 -1
  39. package/dist/types/src/generated/shared/index.d.ts +2 -13
  40. package/dist/types/src/generated/shared/index.d.ts.map +1 -1
  41. package/dist/types/src/generated/types/nonceState.d.ts +1 -1
  42. package/dist/types/src/generated/types/nonceState.d.ts.map +1 -1
  43. package/dist/types/src/generated/types/nonceVersion.d.ts +1 -1
  44. package/dist/types/src/generated/types/nonceVersion.d.ts.map +1 -1
  45. package/dist/types/test/_setup.d.ts +5 -5
  46. package/dist/types/test/_setup.d.ts.map +1 -1
  47. package/package.json +13 -22
@@ -1,10 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var accounts = require('@solana/accounts');
4
- var addresses = require('@solana/addresses');
5
- var codecs = require('@solana/codecs');
6
- var instructions = require('@solana/instructions');
7
- var signers = require('@solana/signers');
3
+ var web3_js = require('@solana/web3.js');
8
4
 
9
5
  // env-shim.ts
10
6
  var __DEV__ = /* @__PURE__ */ (() => process["env"].NODE_ENV === "development")();
@@ -14,13 +10,13 @@ var NonceState = /* @__PURE__ */ ((NonceState3) => {
14
10
  return NonceState3;
15
11
  })(NonceState || {});
16
12
  function getNonceStateEncoder() {
17
- return codecs.getScalarEnumEncoder(NonceState, { size: codecs.getU32Encoder() });
13
+ return web3_js.getEnumEncoder(NonceState, { size: web3_js.getU32Encoder() });
18
14
  }
19
15
  function getNonceStateDecoder() {
20
- return codecs.getScalarEnumDecoder(NonceState, { size: codecs.getU32Decoder() });
16
+ return web3_js.getEnumDecoder(NonceState, { size: web3_js.getU32Decoder() });
21
17
  }
22
18
  function getNonceStateCodec() {
23
- return codecs.combineCodec(getNonceStateEncoder(), getNonceStateDecoder());
19
+ return web3_js.combineCodec(getNonceStateEncoder(), getNonceStateDecoder());
24
20
  }
25
21
  var NonceVersion = /* @__PURE__ */ ((NonceVersion3) => {
26
22
  NonceVersion3[NonceVersion3["Legacy"] = 0] = "Legacy";
@@ -28,62 +24,59 @@ var NonceVersion = /* @__PURE__ */ ((NonceVersion3) => {
28
24
  return NonceVersion3;
29
25
  })(NonceVersion || {});
30
26
  function getNonceVersionEncoder() {
31
- return codecs.getScalarEnumEncoder(NonceVersion, { size: codecs.getU32Encoder() });
27
+ return web3_js.getEnumEncoder(NonceVersion, { size: web3_js.getU32Encoder() });
32
28
  }
33
29
  function getNonceVersionDecoder() {
34
- return codecs.getScalarEnumDecoder(NonceVersion, { size: codecs.getU32Decoder() });
30
+ return web3_js.getEnumDecoder(NonceVersion, { size: web3_js.getU32Decoder() });
35
31
  }
36
32
  function getNonceVersionCodec() {
37
- return codecs.combineCodec(getNonceVersionEncoder(), getNonceVersionDecoder());
33
+ return web3_js.combineCodec(getNonceVersionEncoder(), getNonceVersionDecoder());
38
34
  }
39
35
 
40
36
  // src/generated/accounts/nonce.ts
41
- function getNonceAccountDataEncoder() {
42
- return codecs.getStructEncoder([
37
+ function getNonceEncoder() {
38
+ return web3_js.getStructEncoder([
43
39
  ["version", getNonceVersionEncoder()],
44
40
  ["state", getNonceStateEncoder()],
45
- ["authority", addresses.getAddressEncoder()],
46
- ["blockhash", addresses.getAddressEncoder()],
47
- ["lamportsPerSignature", codecs.getU64Encoder()]
41
+ ["authority", web3_js.getAddressEncoder()],
42
+ ["blockhash", web3_js.getAddressEncoder()],
43
+ ["lamportsPerSignature", web3_js.getU64Encoder()]
48
44
  ]);
49
45
  }
50
- function getNonceAccountDataDecoder() {
51
- return codecs.getStructDecoder([
46
+ function getNonceDecoder() {
47
+ return web3_js.getStructDecoder([
52
48
  ["version", getNonceVersionDecoder()],
53
49
  ["state", getNonceStateDecoder()],
54
- ["authority", addresses.getAddressDecoder()],
55
- ["blockhash", addresses.getAddressDecoder()],
56
- ["lamportsPerSignature", codecs.getU64Decoder()]
50
+ ["authority", web3_js.getAddressDecoder()],
51
+ ["blockhash", web3_js.getAddressDecoder()],
52
+ ["lamportsPerSignature", web3_js.getU64Decoder()]
57
53
  ]);
58
54
  }
59
- function getNonceAccountDataCodec() {
60
- return codecs.combineCodec(
61
- getNonceAccountDataEncoder(),
62
- getNonceAccountDataDecoder()
63
- );
55
+ function getNonceCodec() {
56
+ return web3_js.combineCodec(getNonceEncoder(), getNonceDecoder());
64
57
  }
65
58
  function decodeNonce(encodedAccount) {
66
- return accounts.decodeAccount(
59
+ return web3_js.decodeAccount(
67
60
  encodedAccount,
68
- getNonceAccountDataDecoder()
61
+ getNonceDecoder()
69
62
  );
70
63
  }
71
64
  async function fetchNonce(rpc, address, config) {
72
65
  const maybeAccount = await fetchMaybeNonce(rpc, address, config);
73
- accounts.assertAccountExists(maybeAccount);
66
+ web3_js.assertAccountExists(maybeAccount);
74
67
  return maybeAccount;
75
68
  }
76
69
  async function fetchMaybeNonce(rpc, address, config) {
77
- const maybeAccount = await accounts.fetchEncodedAccount(rpc, address, config);
70
+ const maybeAccount = await web3_js.fetchEncodedAccount(rpc, address, config);
78
71
  return decodeNonce(maybeAccount);
79
72
  }
80
73
  async function fetchAllNonce(rpc, addresses, config) {
81
74
  const maybeAccounts = await fetchAllMaybeNonce(rpc, addresses, config);
82
- accounts.assertAccountsExist(maybeAccounts);
75
+ web3_js.assertAccountsExist(maybeAccounts);
83
76
  return maybeAccounts;
84
77
  }
85
78
  async function fetchAllMaybeNonce(rpc, addresses, config) {
86
- const maybeAccounts = await accounts.fetchEncodedAccounts(rpc, addresses, config);
79
+ const maybeAccounts = await web3_js.fetchEncodedAccounts(rpc, addresses, config);
87
80
  return maybeAccounts.map((maybeAccount) => decodeNonce(maybeAccount));
88
81
  }
89
82
  function getNonceSize() {
@@ -91,89 +84,100 @@ function getNonceSize() {
91
84
  }
92
85
 
93
86
  // src/generated/errors/system.ts
94
- var SystemProgramErrorCode = /* @__PURE__ */ ((SystemProgramErrorCode3) => {
95
- SystemProgramErrorCode3[SystemProgramErrorCode3["ACCOUNT_ALREADY_IN_USE"] = 0] = "ACCOUNT_ALREADY_IN_USE";
96
- SystemProgramErrorCode3[SystemProgramErrorCode3["RESULT_WITH_NEGATIVE_LAMPORTS"] = 1] = "RESULT_WITH_NEGATIVE_LAMPORTS";
97
- SystemProgramErrorCode3[SystemProgramErrorCode3["INVALID_PROGRAM_ID"] = 2] = "INVALID_PROGRAM_ID";
98
- SystemProgramErrorCode3[SystemProgramErrorCode3["INVALID_ACCOUNT_DATA_LENGTH"] = 3] = "INVALID_ACCOUNT_DATA_LENGTH";
99
- SystemProgramErrorCode3[SystemProgramErrorCode3["MAX_SEED_LENGTH_EXCEEDED"] = 4] = "MAX_SEED_LENGTH_EXCEEDED";
100
- SystemProgramErrorCode3[SystemProgramErrorCode3["ADDRESS_WITH_SEED_MISMATCH"] = 5] = "ADDRESS_WITH_SEED_MISMATCH";
101
- SystemProgramErrorCode3[SystemProgramErrorCode3["NONCE_NO_RECENT_BLOCKHASHES"] = 6] = "NONCE_NO_RECENT_BLOCKHASHES";
102
- SystemProgramErrorCode3[SystemProgramErrorCode3["NONCE_BLOCKHASH_NOT_EXPIRED"] = 7] = "NONCE_BLOCKHASH_NOT_EXPIRED";
103
- SystemProgramErrorCode3[SystemProgramErrorCode3["NONCE_UNEXPECTED_BLOCKHASH_VALUE"] = 8] = "NONCE_UNEXPECTED_BLOCKHASH_VALUE";
104
- return SystemProgramErrorCode3;
105
- })(SystemProgramErrorCode || {});
106
- var SystemProgramError = class extends Error {
107
- name = "SystemProgramError";
108
- code;
109
- cause;
110
- constructor(code, name, message, cause) {
111
- super(`${name} (${code}): ${message}`);
112
- this.code = code;
113
- this.cause = cause;
114
- }
115
- };
116
- var systemProgramErrorCodeMap;
87
+ var SYSTEM_ERROR__ACCOUNT_ALREADY_IN_USE = 0;
88
+ var SYSTEM_ERROR__RESULT_WITH_NEGATIVE_LAMPORTS = 1;
89
+ var SYSTEM_ERROR__INVALID_PROGRAM_ID = 2;
90
+ var SYSTEM_ERROR__INVALID_ACCOUNT_DATA_LENGTH = 3;
91
+ var SYSTEM_ERROR__MAX_SEED_LENGTH_EXCEEDED = 4;
92
+ var SYSTEM_ERROR__ADDRESS_WITH_SEED_MISMATCH = 5;
93
+ var SYSTEM_ERROR__NONCE_NO_RECENT_BLOCKHASHES = 6;
94
+ var SYSTEM_ERROR__NONCE_BLOCKHASH_NOT_EXPIRED = 7;
95
+ var SYSTEM_ERROR__NONCE_UNEXPECTED_BLOCKHASH_VALUE = 8;
96
+ var systemErrorMessages;
117
97
  if (__DEV__) {
118
- systemProgramErrorCodeMap = {
119
- [0 /* ACCOUNT_ALREADY_IN_USE */]: [
120
- "AccountAlreadyInUse",
121
- `an account with the same address already exists`
122
- ],
123
- [1 /* RESULT_WITH_NEGATIVE_LAMPORTS */]: [
124
- "ResultWithNegativeLamports",
125
- `account does not have enough SOL to perform the operation`
126
- ],
127
- [2 /* INVALID_PROGRAM_ID */]: [
128
- "InvalidProgramId",
129
- `cannot assign account to this program id`
130
- ],
131
- [3 /* INVALID_ACCOUNT_DATA_LENGTH */]: [
132
- "InvalidAccountDataLength",
133
- `cannot allocate account data of this length`
134
- ],
135
- [4 /* MAX_SEED_LENGTH_EXCEEDED */]: [
136
- "MaxSeedLengthExceeded",
137
- `length of requested seed is too long`
138
- ],
139
- [5 /* ADDRESS_WITH_SEED_MISMATCH */]: [
140
- "AddressWithSeedMismatch",
141
- `provided address does not match addressed derived from seed`
142
- ],
143
- [6 /* NONCE_NO_RECENT_BLOCKHASHES */]: [
144
- "NonceNoRecentBlockhashes",
145
- `advancing stored nonce requires a populated RecentBlockhashes sysvar`
146
- ],
147
- [7 /* NONCE_BLOCKHASH_NOT_EXPIRED */]: [
148
- "NonceBlockhashNotExpired",
149
- `stored nonce is still in recent_blockhashes`
150
- ],
151
- [8 /* NONCE_UNEXPECTED_BLOCKHASH_VALUE */]: [
152
- "NonceUnexpectedBlockhashValue",
153
- `specified nonce does not match stored nonce`
154
- ]
98
+ systemErrorMessages = {
99
+ [SYSTEM_ERROR__ACCOUNT_ALREADY_IN_USE]: `an account with the same address already exists`,
100
+ [SYSTEM_ERROR__ADDRESS_WITH_SEED_MISMATCH]: `provided address does not match addressed derived from seed`,
101
+ [SYSTEM_ERROR__INVALID_ACCOUNT_DATA_LENGTH]: `cannot allocate account data of this length`,
102
+ [SYSTEM_ERROR__INVALID_PROGRAM_ID]: `cannot assign account to this program id`,
103
+ [SYSTEM_ERROR__MAX_SEED_LENGTH_EXCEEDED]: `length of requested seed is too long`,
104
+ [SYSTEM_ERROR__NONCE_BLOCKHASH_NOT_EXPIRED]: `stored nonce is still in recent_blockhashes`,
105
+ [SYSTEM_ERROR__NONCE_NO_RECENT_BLOCKHASHES]: `advancing stored nonce requires a populated RecentBlockhashes sysvar`,
106
+ [SYSTEM_ERROR__NONCE_UNEXPECTED_BLOCKHASH_VALUE]: `specified nonce does not match stored nonce`,
107
+ [SYSTEM_ERROR__RESULT_WITH_NEGATIVE_LAMPORTS]: `account does not have enough SOL to perform the operation`
155
108
  };
156
109
  }
157
- function getSystemProgramErrorFromCode(code, cause) {
110
+ function getSystemErrorMessage(code) {
158
111
  if (__DEV__) {
159
- return new SystemProgramError(
160
- code,
161
- ...systemProgramErrorCodeMap[code],
162
- cause
163
- );
112
+ return systemErrorMessages[code];
164
113
  }
165
- return new SystemProgramError(
166
- code,
167
- "Unknown",
168
- "Error message not available in production bundles. Compile with __DEV__ set to true to see more information.",
169
- cause
170
- );
114
+ return "Error message not available in production bundles. Compile with `__DEV__` set to true to see more information.";
171
115
  }
172
- function expectSome(value) {
173
- if (value == null) {
174
- throw new Error("Expected a value but received null or undefined.");
116
+ var SYSTEM_PROGRAM_ADDRESS = "11111111111111111111111111111111";
117
+ var SystemAccount = /* @__PURE__ */ ((SystemAccount2) => {
118
+ SystemAccount2[SystemAccount2["Nonce"] = 0] = "Nonce";
119
+ return SystemAccount2;
120
+ })(SystemAccount || {});
121
+ var SystemInstruction = /* @__PURE__ */ ((SystemInstruction2) => {
122
+ SystemInstruction2[SystemInstruction2["CreateAccount"] = 0] = "CreateAccount";
123
+ SystemInstruction2[SystemInstruction2["Assign"] = 1] = "Assign";
124
+ SystemInstruction2[SystemInstruction2["TransferSol"] = 2] = "TransferSol";
125
+ SystemInstruction2[SystemInstruction2["CreateAccountWithSeed"] = 3] = "CreateAccountWithSeed";
126
+ SystemInstruction2[SystemInstruction2["AdvanceNonceAccount"] = 4] = "AdvanceNonceAccount";
127
+ SystemInstruction2[SystemInstruction2["WithdrawNonceAccount"] = 5] = "WithdrawNonceAccount";
128
+ SystemInstruction2[SystemInstruction2["InitializeNonceAccount"] = 6] = "InitializeNonceAccount";
129
+ SystemInstruction2[SystemInstruction2["AuthorizeNonceAccount"] = 7] = "AuthorizeNonceAccount";
130
+ SystemInstruction2[SystemInstruction2["Allocate"] = 8] = "Allocate";
131
+ SystemInstruction2[SystemInstruction2["AllocateWithSeed"] = 9] = "AllocateWithSeed";
132
+ SystemInstruction2[SystemInstruction2["AssignWithSeed"] = 10] = "AssignWithSeed";
133
+ SystemInstruction2[SystemInstruction2["TransferSolWithSeed"] = 11] = "TransferSolWithSeed";
134
+ SystemInstruction2[SystemInstruction2["UpgradeNonceAccount"] = 12] = "UpgradeNonceAccount";
135
+ return SystemInstruction2;
136
+ })(SystemInstruction || {});
137
+ function identifySystemInstruction(instruction) {
138
+ const data = instruction instanceof Uint8Array ? instruction : instruction.data;
139
+ if (web3_js.containsBytes(data, web3_js.getU32Encoder().encode(0), 0)) {
140
+ return 0 /* CreateAccount */;
175
141
  }
176
- return value;
142
+ if (web3_js.containsBytes(data, web3_js.getU32Encoder().encode(1), 0)) {
143
+ return 1 /* Assign */;
144
+ }
145
+ if (web3_js.containsBytes(data, web3_js.getU32Encoder().encode(2), 0)) {
146
+ return 2 /* TransferSol */;
147
+ }
148
+ if (web3_js.containsBytes(data, web3_js.getU32Encoder().encode(3), 0)) {
149
+ return 3 /* CreateAccountWithSeed */;
150
+ }
151
+ if (web3_js.containsBytes(data, web3_js.getU32Encoder().encode(4), 0)) {
152
+ return 4 /* AdvanceNonceAccount */;
153
+ }
154
+ if (web3_js.containsBytes(data, web3_js.getU32Encoder().encode(5), 0)) {
155
+ return 5 /* WithdrawNonceAccount */;
156
+ }
157
+ if (web3_js.containsBytes(data, web3_js.getU32Encoder().encode(6), 0)) {
158
+ return 6 /* InitializeNonceAccount */;
159
+ }
160
+ if (web3_js.containsBytes(data, web3_js.getU32Encoder().encode(7), 0)) {
161
+ return 7 /* AuthorizeNonceAccount */;
162
+ }
163
+ if (web3_js.containsBytes(data, web3_js.getU32Encoder().encode(8), 0)) {
164
+ return 8 /* Allocate */;
165
+ }
166
+ if (web3_js.containsBytes(data, web3_js.getU32Encoder().encode(9), 0)) {
167
+ return 9 /* AllocateWithSeed */;
168
+ }
169
+ if (web3_js.containsBytes(data, web3_js.getU32Encoder().encode(10), 0)) {
170
+ return 10 /* AssignWithSeed */;
171
+ }
172
+ if (web3_js.containsBytes(data, web3_js.getU32Encoder().encode(11), 0)) {
173
+ return 11 /* TransferSolWithSeed */;
174
+ }
175
+ if (web3_js.containsBytes(data, web3_js.getU32Encoder().encode(12), 0)) {
176
+ return 12 /* UpgradeNonceAccount */;
177
+ }
178
+ throw new Error(
179
+ "The provided instruction could not be identified as a system instruction."
180
+ );
177
181
  }
178
182
  function expectAddress(value) {
179
183
  if (!value) {
@@ -187,74 +191,45 @@ function expectAddress(value) {
187
191
  }
188
192
  return value;
189
193
  }
190
- function expectProgramDerivedAddress(value) {
191
- if (!value || !Array.isArray(value) || !addresses.isProgramDerivedAddress(value)) {
192
- throw new Error("Expected a ProgramDerivedAddress.");
193
- }
194
- return value;
195
- }
196
- function expectTransactionSigner(value) {
197
- if (!value || !isTransactionSigner(value)) {
198
- throw new Error("Expected a TransactionSigner.");
199
- }
200
- return value;
201
- }
202
- function accountMetaWithDefault(account, role) {
203
- if (account === void 0)
204
- return void 0;
205
- return typeof account === "string" ? { address: account, role } : account;
206
- }
207
- function getAccountMetasWithSigners(accounts, optionalAccountStrategy, programAddress) {
208
- const accountMetas = {};
209
- Object.keys(accounts).forEach((key) => {
210
- const account = accounts[key];
194
+ function getAccountMetaFactory(programAddress, optionalAccountStrategy) {
195
+ return (account) => {
211
196
  if (!account.value) {
212
- if (optionalAccountStrategy === "omitted")
213
- return;
214
- accountMetas[key] = {
197
+ return Object.freeze({
215
198
  address: programAddress,
216
- role: instructions.AccountRole.READONLY
217
- };
218
- return;
199
+ role: web3_js.AccountRole.READONLY
200
+ });
219
201
  }
220
- const writableRole = account.isWritable ? instructions.AccountRole.WRITABLE : instructions.AccountRole.READONLY;
221
- accountMetas[key] = Object.freeze({
202
+ const writableRole = account.isWritable ? web3_js.AccountRole.WRITABLE : web3_js.AccountRole.READONLY;
203
+ return Object.freeze({
222
204
  address: expectAddress(account.value),
223
- role: isTransactionSigner(account.value) ? instructions.upgradeRoleToSigner(writableRole) : writableRole,
205
+ role: isTransactionSigner(account.value) ? web3_js.upgradeRoleToSigner(writableRole) : writableRole,
224
206
  ...isTransactionSigner(account.value) ? { signer: account.value } : {}
225
207
  });
226
- });
227
- return accountMetas;
208
+ };
228
209
  }
229
210
  function isTransactionSigner(value) {
230
- return !!value && typeof value === "object" && "address" in value && signers.isTransactionSigner(value);
231
- }
232
- function memcmp(data, bytes, offset) {
233
- const slice = data.slice(offset, offset + bytes.length);
234
- if (slice.length !== bytes.length)
235
- return false;
236
- return bytes.every((b, i) => b === slice[i]);
211
+ return !!value && typeof value === "object" && "address" in value && web3_js.isTransactionSigner(value);
237
212
  }
238
213
 
239
214
  // src/generated/instructions/advanceNonceAccount.ts
240
215
  function getAdvanceNonceAccountInstructionDataEncoder() {
241
- return codecs.mapEncoder(
242
- codecs.getStructEncoder([["discriminator", codecs.getU32Encoder()]]),
216
+ return web3_js.transformEncoder(
217
+ web3_js.getStructEncoder([["discriminator", web3_js.getU32Encoder()]]),
243
218
  (value) => ({ ...value, discriminator: 4 })
244
219
  );
245
220
  }
246
221
  function getAdvanceNonceAccountInstructionDataDecoder() {
247
- return codecs.getStructDecoder([["discriminator", codecs.getU32Decoder()]]);
222
+ return web3_js.getStructDecoder([["discriminator", web3_js.getU32Decoder()]]);
248
223
  }
249
224
  function getAdvanceNonceAccountInstructionDataCodec() {
250
- return codecs.combineCodec(
225
+ return web3_js.combineCodec(
251
226
  getAdvanceNonceAccountInstructionDataEncoder(),
252
227
  getAdvanceNonceAccountInstructionDataDecoder()
253
228
  );
254
229
  }
255
230
  function getAdvanceNonceAccountInstruction(input) {
256
- const programAddress = "11111111111111111111111111111111";
257
- const accounts = {
231
+ const programAddress = SYSTEM_PROGRAM_ADDRESS;
232
+ const originalAccounts = {
258
233
  nonceAccount: { value: input.nonceAccount ?? null, isWritable: true },
259
234
  recentBlockhashesSysvar: {
260
235
  value: input.recentBlockhashesSysvar ?? null,
@@ -262,37 +237,21 @@ function getAdvanceNonceAccountInstruction(input) {
262
237
  },
263
238
  nonceAuthority: { value: input.nonceAuthority ?? null, isWritable: false }
264
239
  };
240
+ const accounts = originalAccounts;
265
241
  if (!accounts.recentBlockhashesSysvar.value) {
266
242
  accounts.recentBlockhashesSysvar.value = "SysvarRecentB1ockHashes11111111111111111111";
267
243
  }
268
- const accountMetas = getAccountMetasWithSigners(
269
- accounts,
270
- "programId",
271
- programAddress
272
- );
273
- const instruction = getAdvanceNonceAccountInstructionRaw(
274
- accountMetas,
275
- programAddress
276
- );
277
- return instruction;
278
- }
279
- function getAdvanceNonceAccountInstructionRaw(accounts, programAddress = "11111111111111111111111111111111", remainingAccounts) {
280
- return {
244
+ const getAccountMeta = getAccountMetaFactory(programAddress);
245
+ const instruction = {
281
246
  accounts: [
282
- accountMetaWithDefault(accounts.nonceAccount, instructions.AccountRole.WRITABLE),
283
- accountMetaWithDefault(
284
- accounts.recentBlockhashesSysvar ?? "SysvarRecentB1ockHashes11111111111111111111",
285
- instructions.AccountRole.READONLY
286
- ),
287
- accountMetaWithDefault(
288
- accounts.nonceAuthority,
289
- instructions.AccountRole.READONLY_SIGNER
290
- ),
291
- ...remainingAccounts ?? []
247
+ getAccountMeta(accounts.nonceAccount),
248
+ getAccountMeta(accounts.recentBlockhashesSysvar),
249
+ getAccountMeta(accounts.nonceAuthority)
292
250
  ],
293
- data: getAdvanceNonceAccountInstructionDataEncoder().encode({}),
294
- programAddress
251
+ programAddress,
252
+ data: getAdvanceNonceAccountInstructionDataEncoder().encode({})
295
253
  };
254
+ return instruction;
296
255
  }
297
256
  function parseAdvanceNonceAccountInstruction(instruction) {
298
257
  if (instruction.accounts.length < 3) {
@@ -317,53 +276,42 @@ function parseAdvanceNonceAccountInstruction(instruction) {
317
276
  };
318
277
  }
319
278
  function getAllocateInstructionDataEncoder() {
320
- return codecs.mapEncoder(
321
- codecs.getStructEncoder([
322
- ["discriminator", codecs.getU32Encoder()],
323
- ["space", codecs.getU64Encoder()]
279
+ return web3_js.transformEncoder(
280
+ web3_js.getStructEncoder([
281
+ ["discriminator", web3_js.getU32Encoder()],
282
+ ["space", web3_js.getU64Encoder()]
324
283
  ]),
325
284
  (value) => ({ ...value, discriminator: 8 })
326
285
  );
327
286
  }
328
287
  function getAllocateInstructionDataDecoder() {
329
- return codecs.getStructDecoder([
330
- ["discriminator", codecs.getU32Decoder()],
331
- ["space", codecs.getU64Decoder()]
288
+ return web3_js.getStructDecoder([
289
+ ["discriminator", web3_js.getU32Decoder()],
290
+ ["space", web3_js.getU64Decoder()]
332
291
  ]);
333
292
  }
334
293
  function getAllocateInstructionDataCodec() {
335
- return codecs.combineCodec(
294
+ return web3_js.combineCodec(
336
295
  getAllocateInstructionDataEncoder(),
337
296
  getAllocateInstructionDataDecoder()
338
297
  );
339
298
  }
340
299
  function getAllocateInstruction(input) {
341
- const programAddress = "11111111111111111111111111111111";
342
- const accounts = {
300
+ const programAddress = SYSTEM_PROGRAM_ADDRESS;
301
+ const originalAccounts = {
343
302
  newAccount: { value: input.newAccount ?? null, isWritable: true }
344
303
  };
304
+ const accounts = originalAccounts;
345
305
  const args = { ...input };
346
- const accountMetas = getAccountMetasWithSigners(
347
- accounts,
348
- "programId",
349
- programAddress
350
- );
351
- const instruction = getAllocateInstructionRaw(
352
- accountMetas,
353
- args,
354
- programAddress
355
- );
356
- return instruction;
357
- }
358
- function getAllocateInstructionRaw(accounts, args, programAddress = "11111111111111111111111111111111", remainingAccounts) {
359
- return {
360
- accounts: [
361
- accountMetaWithDefault(accounts.newAccount, instructions.AccountRole.WRITABLE_SIGNER),
362
- ...remainingAccounts ?? []
363
- ],
364
- data: getAllocateInstructionDataEncoder().encode(args),
365
- programAddress
306
+ const getAccountMeta = getAccountMetaFactory(programAddress);
307
+ const instruction = {
308
+ accounts: [getAccountMeta(accounts.newAccount)],
309
+ programAddress,
310
+ data: getAllocateInstructionDataEncoder().encode(
311
+ args
312
+ )
366
313
  };
314
+ return instruction;
367
315
  }
368
316
  function parseAllocateInstruction(instruction) {
369
317
  if (instruction.accounts.length < 1) {
@@ -384,61 +332,52 @@ function parseAllocateInstruction(instruction) {
384
332
  };
385
333
  }
386
334
  function getAllocateWithSeedInstructionDataEncoder() {
387
- return codecs.mapEncoder(
388
- codecs.getStructEncoder([
389
- ["discriminator", codecs.getU32Encoder()],
390
- ["base", addresses.getAddressEncoder()],
391
- ["seed", codecs.getStringEncoder()],
392
- ["space", codecs.getU64Encoder()],
393
- ["programAddress", addresses.getAddressEncoder()]
335
+ return web3_js.transformEncoder(
336
+ web3_js.getStructEncoder([
337
+ ["discriminator", web3_js.getU32Encoder()],
338
+ ["base", web3_js.getAddressEncoder()],
339
+ ["seed", web3_js.addEncoderSizePrefix(web3_js.getUtf8Encoder(), web3_js.getU32Encoder())],
340
+ ["space", web3_js.getU64Encoder()],
341
+ ["programAddress", web3_js.getAddressEncoder()]
394
342
  ]),
395
343
  (value) => ({ ...value, discriminator: 9 })
396
344
  );
397
345
  }
398
346
  function getAllocateWithSeedInstructionDataDecoder() {
399
- return codecs.getStructDecoder([
400
- ["discriminator", codecs.getU32Decoder()],
401
- ["base", addresses.getAddressDecoder()],
402
- ["seed", codecs.getStringDecoder()],
403
- ["space", codecs.getU64Decoder()],
404
- ["programAddress", addresses.getAddressDecoder()]
347
+ return web3_js.getStructDecoder([
348
+ ["discriminator", web3_js.getU32Decoder()],
349
+ ["base", web3_js.getAddressDecoder()],
350
+ ["seed", web3_js.addDecoderSizePrefix(web3_js.getUtf8Decoder(), web3_js.getU32Decoder())],
351
+ ["space", web3_js.getU64Decoder()],
352
+ ["programAddress", web3_js.getAddressDecoder()]
405
353
  ]);
406
354
  }
407
355
  function getAllocateWithSeedInstructionDataCodec() {
408
- return codecs.combineCodec(
356
+ return web3_js.combineCodec(
409
357
  getAllocateWithSeedInstructionDataEncoder(),
410
358
  getAllocateWithSeedInstructionDataDecoder()
411
359
  );
412
360
  }
413
361
  function getAllocateWithSeedInstruction(input) {
414
- const programAddress = "11111111111111111111111111111111";
415
- const accounts = {
362
+ const programAddress = SYSTEM_PROGRAM_ADDRESS;
363
+ const originalAccounts = {
416
364
  newAccount: { value: input.newAccount ?? null, isWritable: true },
417
365
  baseAccount: { value: input.baseAccount ?? null, isWritable: false }
418
366
  };
367
+ const accounts = originalAccounts;
419
368
  const args = { ...input };
420
- const accountMetas = getAccountMetasWithSigners(
421
- accounts,
422
- "programId",
423
- programAddress
424
- );
425
- const instruction = getAllocateWithSeedInstructionRaw(
426
- accountMetas,
427
- args,
428
- programAddress
429
- );
430
- return instruction;
431
- }
432
- function getAllocateWithSeedInstructionRaw(accounts, args, programAddress = "11111111111111111111111111111111", remainingAccounts) {
433
- return {
369
+ const getAccountMeta = getAccountMetaFactory(programAddress);
370
+ const instruction = {
434
371
  accounts: [
435
- accountMetaWithDefault(accounts.newAccount, instructions.AccountRole.WRITABLE),
436
- accountMetaWithDefault(accounts.baseAccount, instructions.AccountRole.READONLY_SIGNER),
437
- ...remainingAccounts ?? []
372
+ getAccountMeta(accounts.newAccount),
373
+ getAccountMeta(accounts.baseAccount)
438
374
  ],
439
- data: getAllocateWithSeedInstructionDataEncoder().encode(args),
440
- programAddress
375
+ programAddress,
376
+ data: getAllocateWithSeedInstructionDataEncoder().encode(
377
+ args
378
+ )
441
379
  };
380
+ return instruction;
442
381
  }
443
382
  function parseAllocateWithSeedInstruction(instruction) {
444
383
  if (instruction.accounts.length < 2) {
@@ -460,53 +399,42 @@ function parseAllocateWithSeedInstruction(instruction) {
460
399
  };
461
400
  }
462
401
  function getAssignInstructionDataEncoder() {
463
- return codecs.mapEncoder(
464
- codecs.getStructEncoder([
465
- ["discriminator", codecs.getU32Encoder()],
466
- ["programAddress", addresses.getAddressEncoder()]
402
+ return web3_js.transformEncoder(
403
+ web3_js.getStructEncoder([
404
+ ["discriminator", web3_js.getU32Encoder()],
405
+ ["programAddress", web3_js.getAddressEncoder()]
467
406
  ]),
468
407
  (value) => ({ ...value, discriminator: 1 })
469
408
  );
470
409
  }
471
410
  function getAssignInstructionDataDecoder() {
472
- return codecs.getStructDecoder([
473
- ["discriminator", codecs.getU32Decoder()],
474
- ["programAddress", addresses.getAddressDecoder()]
411
+ return web3_js.getStructDecoder([
412
+ ["discriminator", web3_js.getU32Decoder()],
413
+ ["programAddress", web3_js.getAddressDecoder()]
475
414
  ]);
476
415
  }
477
416
  function getAssignInstructionDataCodec() {
478
- return codecs.combineCodec(
417
+ return web3_js.combineCodec(
479
418
  getAssignInstructionDataEncoder(),
480
419
  getAssignInstructionDataDecoder()
481
420
  );
482
421
  }
483
422
  function getAssignInstruction(input) {
484
- const programAddress = "11111111111111111111111111111111";
485
- const accounts = {
423
+ const programAddress = SYSTEM_PROGRAM_ADDRESS;
424
+ const originalAccounts = {
486
425
  account: { value: input.account ?? null, isWritable: true }
487
426
  };
427
+ const accounts = originalAccounts;
488
428
  const args = { ...input };
489
- const accountMetas = getAccountMetasWithSigners(
490
- accounts,
491
- "programId",
492
- programAddress
493
- );
494
- const instruction = getAssignInstructionRaw(
495
- accountMetas,
496
- args,
497
- programAddress
498
- );
499
- return instruction;
500
- }
501
- function getAssignInstructionRaw(accounts, args, programAddress = "11111111111111111111111111111111", remainingAccounts) {
502
- return {
503
- accounts: [
504
- accountMetaWithDefault(accounts.account, instructions.AccountRole.WRITABLE_SIGNER),
505
- ...remainingAccounts ?? []
506
- ],
507
- data: getAssignInstructionDataEncoder().encode(args),
508
- programAddress
429
+ const getAccountMeta = getAccountMetaFactory(programAddress);
430
+ const instruction = {
431
+ accounts: [getAccountMeta(accounts.account)],
432
+ programAddress,
433
+ data: getAssignInstructionDataEncoder().encode(
434
+ args
435
+ )
509
436
  };
437
+ return instruction;
510
438
  }
511
439
  function parseAssignInstruction(instruction) {
512
440
  if (instruction.accounts.length < 1) {
@@ -527,59 +455,50 @@ function parseAssignInstruction(instruction) {
527
455
  };
528
456
  }
529
457
  function getAssignWithSeedInstructionDataEncoder() {
530
- return codecs.mapEncoder(
531
- codecs.getStructEncoder([
532
- ["discriminator", codecs.getU32Encoder()],
533
- ["base", addresses.getAddressEncoder()],
534
- ["seed", codecs.getStringEncoder()],
535
- ["programAddress", addresses.getAddressEncoder()]
458
+ return web3_js.transformEncoder(
459
+ web3_js.getStructEncoder([
460
+ ["discriminator", web3_js.getU32Encoder()],
461
+ ["base", web3_js.getAddressEncoder()],
462
+ ["seed", web3_js.addEncoderSizePrefix(web3_js.getUtf8Encoder(), web3_js.getU32Encoder())],
463
+ ["programAddress", web3_js.getAddressEncoder()]
536
464
  ]),
537
465
  (value) => ({ ...value, discriminator: 10 })
538
466
  );
539
467
  }
540
468
  function getAssignWithSeedInstructionDataDecoder() {
541
- return codecs.getStructDecoder([
542
- ["discriminator", codecs.getU32Decoder()],
543
- ["base", addresses.getAddressDecoder()],
544
- ["seed", codecs.getStringDecoder()],
545
- ["programAddress", addresses.getAddressDecoder()]
469
+ return web3_js.getStructDecoder([
470
+ ["discriminator", web3_js.getU32Decoder()],
471
+ ["base", web3_js.getAddressDecoder()],
472
+ ["seed", web3_js.addDecoderSizePrefix(web3_js.getUtf8Decoder(), web3_js.getU32Decoder())],
473
+ ["programAddress", web3_js.getAddressDecoder()]
546
474
  ]);
547
475
  }
548
476
  function getAssignWithSeedInstructionDataCodec() {
549
- return codecs.combineCodec(
477
+ return web3_js.combineCodec(
550
478
  getAssignWithSeedInstructionDataEncoder(),
551
479
  getAssignWithSeedInstructionDataDecoder()
552
480
  );
553
481
  }
554
482
  function getAssignWithSeedInstruction(input) {
555
- const programAddress = "11111111111111111111111111111111";
556
- const accounts = {
483
+ const programAddress = SYSTEM_PROGRAM_ADDRESS;
484
+ const originalAccounts = {
557
485
  account: { value: input.account ?? null, isWritable: true },
558
486
  baseAccount: { value: input.baseAccount ?? null, isWritable: false }
559
487
  };
488
+ const accounts = originalAccounts;
560
489
  const args = { ...input };
561
- const accountMetas = getAccountMetasWithSigners(
562
- accounts,
563
- "programId",
564
- programAddress
565
- );
566
- const instruction = getAssignWithSeedInstructionRaw(
567
- accountMetas,
568
- args,
569
- programAddress
570
- );
571
- return instruction;
572
- }
573
- function getAssignWithSeedInstructionRaw(accounts, args, programAddress = "11111111111111111111111111111111", remainingAccounts) {
574
- return {
490
+ const getAccountMeta = getAccountMetaFactory(programAddress);
491
+ const instruction = {
575
492
  accounts: [
576
- accountMetaWithDefault(accounts.account, instructions.AccountRole.WRITABLE),
577
- accountMetaWithDefault(accounts.baseAccount, instructions.AccountRole.READONLY_SIGNER),
578
- ...remainingAccounts ?? []
493
+ getAccountMeta(accounts.account),
494
+ getAccountMeta(accounts.baseAccount)
579
495
  ],
580
- data: getAssignWithSeedInstructionDataEncoder().encode(args),
581
- programAddress
496
+ programAddress,
497
+ data: getAssignWithSeedInstructionDataEncoder().encode(
498
+ args
499
+ )
582
500
  };
501
+ return instruction;
583
502
  }
584
503
  function parseAssignWithSeedInstruction(instruction) {
585
504
  if (instruction.accounts.length < 2) {
@@ -601,58 +520,46 @@ function parseAssignWithSeedInstruction(instruction) {
601
520
  };
602
521
  }
603
522
  function getAuthorizeNonceAccountInstructionDataEncoder() {
604
- return codecs.mapEncoder(
605
- codecs.getStructEncoder([
606
- ["discriminator", codecs.getU32Encoder()],
607
- ["newNonceAuthority", addresses.getAddressEncoder()]
523
+ return web3_js.transformEncoder(
524
+ web3_js.getStructEncoder([
525
+ ["discriminator", web3_js.getU32Encoder()],
526
+ ["newNonceAuthority", web3_js.getAddressEncoder()]
608
527
  ]),
609
528
  (value) => ({ ...value, discriminator: 7 })
610
529
  );
611
530
  }
612
531
  function getAuthorizeNonceAccountInstructionDataDecoder() {
613
- return codecs.getStructDecoder([
614
- ["discriminator", codecs.getU32Decoder()],
615
- ["newNonceAuthority", addresses.getAddressDecoder()]
532
+ return web3_js.getStructDecoder([
533
+ ["discriminator", web3_js.getU32Decoder()],
534
+ ["newNonceAuthority", web3_js.getAddressDecoder()]
616
535
  ]);
617
536
  }
618
537
  function getAuthorizeNonceAccountInstructionDataCodec() {
619
- return codecs.combineCodec(
538
+ return web3_js.combineCodec(
620
539
  getAuthorizeNonceAccountInstructionDataEncoder(),
621
540
  getAuthorizeNonceAccountInstructionDataDecoder()
622
541
  );
623
542
  }
624
543
  function getAuthorizeNonceAccountInstruction(input) {
625
- const programAddress = "11111111111111111111111111111111";
626
- const accounts = {
544
+ const programAddress = SYSTEM_PROGRAM_ADDRESS;
545
+ const originalAccounts = {
627
546
  nonceAccount: { value: input.nonceAccount ?? null, isWritable: true },
628
547
  nonceAuthority: { value: input.nonceAuthority ?? null, isWritable: false }
629
548
  };
549
+ const accounts = originalAccounts;
630
550
  const args = { ...input };
631
- const accountMetas = getAccountMetasWithSigners(
632
- accounts,
633
- "programId",
634
- programAddress
635
- );
636
- const instruction = getAuthorizeNonceAccountInstructionRaw(
637
- accountMetas,
638
- args,
639
- programAddress
640
- );
641
- return instruction;
642
- }
643
- function getAuthorizeNonceAccountInstructionRaw(accounts, args, programAddress = "11111111111111111111111111111111", remainingAccounts) {
644
- return {
551
+ const getAccountMeta = getAccountMetaFactory(programAddress);
552
+ const instruction = {
645
553
  accounts: [
646
- accountMetaWithDefault(accounts.nonceAccount, instructions.AccountRole.WRITABLE),
647
- accountMetaWithDefault(
648
- accounts.nonceAuthority,
649
- instructions.AccountRole.READONLY_SIGNER
650
- ),
651
- ...remainingAccounts ?? []
554
+ getAccountMeta(accounts.nonceAccount),
555
+ getAccountMeta(accounts.nonceAuthority)
652
556
  ],
653
- data: getAuthorizeNonceAccountInstructionDataEncoder().encode(args),
654
- programAddress
557
+ programAddress,
558
+ data: getAuthorizeNonceAccountInstructionDataEncoder().encode(
559
+ args
560
+ )
655
561
  };
562
+ return instruction;
656
563
  }
657
564
  function parseAuthorizeNonceAccountInstruction(instruction) {
658
565
  if (instruction.accounts.length < 2) {
@@ -676,63 +583,54 @@ function parseAuthorizeNonceAccountInstruction(instruction) {
676
583
  };
677
584
  }
678
585
  function getCreateAccountInstructionDataEncoder() {
679
- return codecs.mapEncoder(
680
- codecs.getStructEncoder([
681
- ["discriminator", codecs.getU32Encoder()],
682
- ["lamports", codecs.getU64Encoder()],
683
- ["space", codecs.getU64Encoder()],
684
- ["programAddress", addresses.getAddressEncoder()]
586
+ return web3_js.transformEncoder(
587
+ web3_js.getStructEncoder([
588
+ ["discriminator", web3_js.getU32Encoder()],
589
+ ["lamports", web3_js.getU64Encoder()],
590
+ ["space", web3_js.getU64Encoder()],
591
+ ["programAddress", web3_js.getAddressEncoder()]
685
592
  ]),
686
593
  (value) => ({ ...value, discriminator: 0 })
687
594
  );
688
595
  }
689
596
  function getCreateAccountInstructionDataDecoder() {
690
- return codecs.getStructDecoder([
691
- ["discriminator", codecs.getU32Decoder()],
692
- ["lamports", codecs.getU64Decoder()],
693
- ["space", codecs.getU64Decoder()],
694
- ["programAddress", addresses.getAddressDecoder()]
597
+ return web3_js.getStructDecoder([
598
+ ["discriminator", web3_js.getU32Decoder()],
599
+ ["lamports", web3_js.getU64Decoder()],
600
+ ["space", web3_js.getU64Decoder()],
601
+ ["programAddress", web3_js.getAddressDecoder()]
695
602
  ]);
696
603
  }
697
604
  function getCreateAccountInstructionDataCodec() {
698
- return codecs.combineCodec(
605
+ return web3_js.combineCodec(
699
606
  getCreateAccountInstructionDataEncoder(),
700
607
  getCreateAccountInstructionDataDecoder()
701
608
  );
702
609
  }
703
610
  function getCreateAccountInstruction(input) {
704
- const programAddress = "11111111111111111111111111111111";
705
- const accounts$1 = {
611
+ const programAddress = SYSTEM_PROGRAM_ADDRESS;
612
+ const originalAccounts = {
706
613
  payer: { value: input.payer ?? null, isWritable: true },
707
614
  newAccount: { value: input.newAccount ?? null, isWritable: true }
708
615
  };
616
+ const accounts = originalAccounts;
709
617
  const args = { ...input };
710
- const byteDelta = [Number(args.space) + accounts.BASE_ACCOUNT_SIZE].reduce(
618
+ const byteDelta = [Number(args.space) + web3_js.BASE_ACCOUNT_SIZE].reduce(
711
619
  (a, b) => a + b,
712
620
  0
713
621
  );
714
- const accountMetas = getAccountMetasWithSigners(
715
- accounts$1,
716
- "programId",
717
- programAddress
718
- );
719
- const instruction = getCreateAccountInstructionRaw(
720
- accountMetas,
721
- args,
722
- programAddress
723
- );
724
- return Object.freeze({ ...instruction, byteDelta });
725
- }
726
- function getCreateAccountInstructionRaw(accounts, args, programAddress = "11111111111111111111111111111111", remainingAccounts) {
727
- return {
622
+ const getAccountMeta = getAccountMetaFactory(programAddress);
623
+ const instruction = {
728
624
  accounts: [
729
- accountMetaWithDefault(accounts.payer, instructions.AccountRole.WRITABLE_SIGNER),
730
- accountMetaWithDefault(accounts.newAccount, instructions.AccountRole.WRITABLE_SIGNER),
731
- ...remainingAccounts ?? []
625
+ getAccountMeta(accounts.payer),
626
+ getAccountMeta(accounts.newAccount)
732
627
  ],
733
- data: getCreateAccountInstructionDataEncoder().encode(args),
734
- programAddress
628
+ programAddress,
629
+ data: getCreateAccountInstructionDataEncoder().encode(
630
+ args
631
+ )
735
632
  };
633
+ return Object.freeze({ ...instruction, byteDelta });
736
634
  }
737
635
  function parseCreateAccountInstruction(instruction) {
738
636
  if (instruction.accounts.length < 2) {
@@ -754,65 +652,56 @@ function parseCreateAccountInstruction(instruction) {
754
652
  };
755
653
  }
756
654
  function getCreateAccountWithSeedInstructionDataEncoder() {
757
- return codecs.mapEncoder(
758
- codecs.getStructEncoder([
759
- ["discriminator", codecs.getU32Encoder()],
760
- ["base", addresses.getAddressEncoder()],
761
- ["seed", codecs.getStringEncoder()],
762
- ["amount", codecs.getU64Encoder()],
763
- ["space", codecs.getU64Encoder()],
764
- ["programAddress", addresses.getAddressEncoder()]
655
+ return web3_js.transformEncoder(
656
+ web3_js.getStructEncoder([
657
+ ["discriminator", web3_js.getU32Encoder()],
658
+ ["base", web3_js.getAddressEncoder()],
659
+ ["seed", web3_js.addEncoderSizePrefix(web3_js.getUtf8Encoder(), web3_js.getU32Encoder())],
660
+ ["amount", web3_js.getU64Encoder()],
661
+ ["space", web3_js.getU64Encoder()],
662
+ ["programAddress", web3_js.getAddressEncoder()]
765
663
  ]),
766
664
  (value) => ({ ...value, discriminator: 3 })
767
665
  );
768
666
  }
769
667
  function getCreateAccountWithSeedInstructionDataDecoder() {
770
- return codecs.getStructDecoder([
771
- ["discriminator", codecs.getU32Decoder()],
772
- ["base", addresses.getAddressDecoder()],
773
- ["seed", codecs.getStringDecoder()],
774
- ["amount", codecs.getU64Decoder()],
775
- ["space", codecs.getU64Decoder()],
776
- ["programAddress", addresses.getAddressDecoder()]
668
+ return web3_js.getStructDecoder([
669
+ ["discriminator", web3_js.getU32Decoder()],
670
+ ["base", web3_js.getAddressDecoder()],
671
+ ["seed", web3_js.addDecoderSizePrefix(web3_js.getUtf8Decoder(), web3_js.getU32Decoder())],
672
+ ["amount", web3_js.getU64Decoder()],
673
+ ["space", web3_js.getU64Decoder()],
674
+ ["programAddress", web3_js.getAddressDecoder()]
777
675
  ]);
778
676
  }
779
677
  function getCreateAccountWithSeedInstructionDataCodec() {
780
- return codecs.combineCodec(
678
+ return web3_js.combineCodec(
781
679
  getCreateAccountWithSeedInstructionDataEncoder(),
782
680
  getCreateAccountWithSeedInstructionDataDecoder()
783
681
  );
784
682
  }
785
683
  function getCreateAccountWithSeedInstruction(input) {
786
- const programAddress = "11111111111111111111111111111111";
787
- const accounts = {
684
+ const programAddress = SYSTEM_PROGRAM_ADDRESS;
685
+ const originalAccounts = {
788
686
  payer: { value: input.payer ?? null, isWritable: true },
789
687
  newAccount: { value: input.newAccount ?? null, isWritable: true },
790
688
  baseAccount: { value: input.baseAccount ?? null, isWritable: false }
791
689
  };
690
+ const accounts = originalAccounts;
792
691
  const args = { ...input };
793
- const accountMetas = getAccountMetasWithSigners(
794
- accounts,
795
- "programId",
796
- programAddress
797
- );
798
- const instruction = getCreateAccountWithSeedInstructionRaw(
799
- accountMetas,
800
- args,
801
- programAddress
802
- );
803
- return instruction;
804
- }
805
- function getCreateAccountWithSeedInstructionRaw(accounts, args, programAddress = "11111111111111111111111111111111", remainingAccounts) {
806
- return {
692
+ const getAccountMeta = getAccountMetaFactory(programAddress);
693
+ const instruction = {
807
694
  accounts: [
808
- accountMetaWithDefault(accounts.payer, instructions.AccountRole.WRITABLE_SIGNER),
809
- accountMetaWithDefault(accounts.newAccount, instructions.AccountRole.WRITABLE),
810
- accountMetaWithDefault(accounts.baseAccount, instructions.AccountRole.READONLY_SIGNER),
811
- ...remainingAccounts ?? []
695
+ getAccountMeta(accounts.payer),
696
+ getAccountMeta(accounts.newAccount),
697
+ getAccountMeta(accounts.baseAccount)
812
698
  ],
813
- data: getCreateAccountWithSeedInstructionDataEncoder().encode(args),
814
- programAddress
699
+ programAddress,
700
+ data: getCreateAccountWithSeedInstructionDataEncoder().encode(
701
+ args
702
+ )
815
703
  };
704
+ return instruction;
816
705
  }
817
706
  function parseCreateAccountWithSeedInstruction(instruction) {
818
707
  if (instruction.accounts.length < 3) {
@@ -837,29 +726,29 @@ function parseCreateAccountWithSeedInstruction(instruction) {
837
726
  };
838
727
  }
839
728
  function getInitializeNonceAccountInstructionDataEncoder() {
840
- return codecs.mapEncoder(
841
- codecs.getStructEncoder([
842
- ["discriminator", codecs.getU32Encoder()],
843
- ["nonceAuthority", addresses.getAddressEncoder()]
729
+ return web3_js.transformEncoder(
730
+ web3_js.getStructEncoder([
731
+ ["discriminator", web3_js.getU32Encoder()],
732
+ ["nonceAuthority", web3_js.getAddressEncoder()]
844
733
  ]),
845
734
  (value) => ({ ...value, discriminator: 6 })
846
735
  );
847
736
  }
848
737
  function getInitializeNonceAccountInstructionDataDecoder() {
849
- return codecs.getStructDecoder([
850
- ["discriminator", codecs.getU32Decoder()],
851
- ["nonceAuthority", addresses.getAddressDecoder()]
738
+ return web3_js.getStructDecoder([
739
+ ["discriminator", web3_js.getU32Decoder()],
740
+ ["nonceAuthority", web3_js.getAddressDecoder()]
852
741
  ]);
853
742
  }
854
743
  function getInitializeNonceAccountInstructionDataCodec() {
855
- return codecs.combineCodec(
744
+ return web3_js.combineCodec(
856
745
  getInitializeNonceAccountInstructionDataEncoder(),
857
746
  getInitializeNonceAccountInstructionDataDecoder()
858
747
  );
859
748
  }
860
749
  function getInitializeNonceAccountInstruction(input) {
861
- const programAddress = "11111111111111111111111111111111";
862
- const accounts = {
750
+ const programAddress = SYSTEM_PROGRAM_ADDRESS;
751
+ const originalAccounts = {
863
752
  nonceAccount: { value: input.nonceAccount ?? null, isWritable: true },
864
753
  recentBlockhashesSysvar: {
865
754
  value: input.recentBlockhashesSysvar ?? null,
@@ -867,6 +756,7 @@ function getInitializeNonceAccountInstruction(input) {
867
756
  },
868
757
  rentSysvar: { value: input.rentSysvar ?? null, isWritable: false }
869
758
  };
759
+ const accounts = originalAccounts;
870
760
  const args = { ...input };
871
761
  if (!accounts.recentBlockhashesSysvar.value) {
872
762
  accounts.recentBlockhashesSysvar.value = "SysvarRecentB1ockHashes11111111111111111111";
@@ -874,35 +764,19 @@ function getInitializeNonceAccountInstruction(input) {
874
764
  if (!accounts.rentSysvar.value) {
875
765
  accounts.rentSysvar.value = "SysvarRent111111111111111111111111111111111";
876
766
  }
877
- const accountMetas = getAccountMetasWithSigners(
878
- accounts,
879
- "programId",
880
- programAddress
881
- );
882
- const instruction = getInitializeNonceAccountInstructionRaw(
883
- accountMetas,
884
- args,
885
- programAddress
886
- );
887
- return instruction;
888
- }
889
- function getInitializeNonceAccountInstructionRaw(accounts, args, programAddress = "11111111111111111111111111111111", remainingAccounts) {
890
- return {
767
+ const getAccountMeta = getAccountMetaFactory(programAddress);
768
+ const instruction = {
891
769
  accounts: [
892
- accountMetaWithDefault(accounts.nonceAccount, instructions.AccountRole.WRITABLE),
893
- accountMetaWithDefault(
894
- accounts.recentBlockhashesSysvar ?? "SysvarRecentB1ockHashes11111111111111111111",
895
- instructions.AccountRole.READONLY
896
- ),
897
- accountMetaWithDefault(
898
- accounts.rentSysvar ?? "SysvarRent111111111111111111111111111111111",
899
- instructions.AccountRole.READONLY
900
- ),
901
- ...remainingAccounts ?? []
770
+ getAccountMeta(accounts.nonceAccount),
771
+ getAccountMeta(accounts.recentBlockhashesSysvar),
772
+ getAccountMeta(accounts.rentSysvar)
902
773
  ],
903
- data: getInitializeNonceAccountInstructionDataEncoder().encode(args),
904
- programAddress
774
+ programAddress,
775
+ data: getInitializeNonceAccountInstructionDataEncoder().encode(
776
+ args
777
+ )
905
778
  };
779
+ return instruction;
906
780
  }
907
781
  function parseInitializeNonceAccountInstruction(instruction) {
908
782
  if (instruction.accounts.length < 3) {
@@ -927,55 +801,46 @@ function parseInitializeNonceAccountInstruction(instruction) {
927
801
  };
928
802
  }
929
803
  function getTransferSolInstructionDataEncoder() {
930
- return codecs.mapEncoder(
931
- codecs.getStructEncoder([
932
- ["discriminator", codecs.getU32Encoder()],
933
- ["amount", codecs.getU64Encoder()]
804
+ return web3_js.transformEncoder(
805
+ web3_js.getStructEncoder([
806
+ ["discriminator", web3_js.getU32Encoder()],
807
+ ["amount", web3_js.getU64Encoder()]
934
808
  ]),
935
809
  (value) => ({ ...value, discriminator: 2 })
936
810
  );
937
811
  }
938
812
  function getTransferSolInstructionDataDecoder() {
939
- return codecs.getStructDecoder([
940
- ["discriminator", codecs.getU32Decoder()],
941
- ["amount", codecs.getU64Decoder()]
813
+ return web3_js.getStructDecoder([
814
+ ["discriminator", web3_js.getU32Decoder()],
815
+ ["amount", web3_js.getU64Decoder()]
942
816
  ]);
943
817
  }
944
818
  function getTransferSolInstructionDataCodec() {
945
- return codecs.combineCodec(
819
+ return web3_js.combineCodec(
946
820
  getTransferSolInstructionDataEncoder(),
947
821
  getTransferSolInstructionDataDecoder()
948
822
  );
949
823
  }
950
824
  function getTransferSolInstruction(input) {
951
- const programAddress = "11111111111111111111111111111111";
952
- const accounts = {
825
+ const programAddress = SYSTEM_PROGRAM_ADDRESS;
826
+ const originalAccounts = {
953
827
  source: { value: input.source ?? null, isWritable: true },
954
828
  destination: { value: input.destination ?? null, isWritable: true }
955
829
  };
830
+ const accounts = originalAccounts;
956
831
  const args = { ...input };
957
- const accountMetas = getAccountMetasWithSigners(
958
- accounts,
959
- "programId",
960
- programAddress
961
- );
962
- const instruction = getTransferSolInstructionRaw(
963
- accountMetas,
964
- args,
965
- programAddress
966
- );
967
- return instruction;
968
- }
969
- function getTransferSolInstructionRaw(accounts, args, programAddress = "11111111111111111111111111111111", remainingAccounts) {
970
- return {
832
+ const getAccountMeta = getAccountMetaFactory(programAddress);
833
+ const instruction = {
971
834
  accounts: [
972
- accountMetaWithDefault(accounts.source, instructions.AccountRole.WRITABLE_SIGNER),
973
- accountMetaWithDefault(accounts.destination, instructions.AccountRole.WRITABLE),
974
- ...remainingAccounts ?? []
835
+ getAccountMeta(accounts.source),
836
+ getAccountMeta(accounts.destination)
975
837
  ],
976
- data: getTransferSolInstructionDataEncoder().encode(args),
977
- programAddress
838
+ programAddress,
839
+ data: getTransferSolInstructionDataEncoder().encode(
840
+ args
841
+ )
978
842
  };
843
+ return instruction;
979
844
  }
980
845
  function parseTransferSolInstruction(instruction) {
981
846
  if (instruction.accounts.length < 2) {
@@ -997,61 +862,52 @@ function parseTransferSolInstruction(instruction) {
997
862
  };
998
863
  }
999
864
  function getTransferSolWithSeedInstructionDataEncoder() {
1000
- return codecs.mapEncoder(
1001
- codecs.getStructEncoder([
1002
- ["discriminator", codecs.getU32Encoder()],
1003
- ["amount", codecs.getU64Encoder()],
1004
- ["fromSeed", codecs.getStringEncoder()],
1005
- ["fromOwner", addresses.getAddressEncoder()]
865
+ return web3_js.transformEncoder(
866
+ web3_js.getStructEncoder([
867
+ ["discriminator", web3_js.getU32Encoder()],
868
+ ["amount", web3_js.getU64Encoder()],
869
+ ["fromSeed", web3_js.addEncoderSizePrefix(web3_js.getUtf8Encoder(), web3_js.getU32Encoder())],
870
+ ["fromOwner", web3_js.getAddressEncoder()]
1006
871
  ]),
1007
872
  (value) => ({ ...value, discriminator: 11 })
1008
873
  );
1009
874
  }
1010
875
  function getTransferSolWithSeedInstructionDataDecoder() {
1011
- return codecs.getStructDecoder([
1012
- ["discriminator", codecs.getU32Decoder()],
1013
- ["amount", codecs.getU64Decoder()],
1014
- ["fromSeed", codecs.getStringDecoder()],
1015
- ["fromOwner", addresses.getAddressDecoder()]
876
+ return web3_js.getStructDecoder([
877
+ ["discriminator", web3_js.getU32Decoder()],
878
+ ["amount", web3_js.getU64Decoder()],
879
+ ["fromSeed", web3_js.addDecoderSizePrefix(web3_js.getUtf8Decoder(), web3_js.getU32Decoder())],
880
+ ["fromOwner", web3_js.getAddressDecoder()]
1016
881
  ]);
1017
882
  }
1018
883
  function getTransferSolWithSeedInstructionDataCodec() {
1019
- return codecs.combineCodec(
884
+ return web3_js.combineCodec(
1020
885
  getTransferSolWithSeedInstructionDataEncoder(),
1021
886
  getTransferSolWithSeedInstructionDataDecoder()
1022
887
  );
1023
888
  }
1024
889
  function getTransferSolWithSeedInstruction(input) {
1025
- const programAddress = "11111111111111111111111111111111";
1026
- const accounts = {
890
+ const programAddress = SYSTEM_PROGRAM_ADDRESS;
891
+ const originalAccounts = {
1027
892
  source: { value: input.source ?? null, isWritable: true },
1028
893
  baseAccount: { value: input.baseAccount ?? null, isWritable: false },
1029
894
  destination: { value: input.destination ?? null, isWritable: true }
1030
895
  };
896
+ const accounts = originalAccounts;
1031
897
  const args = { ...input };
1032
- const accountMetas = getAccountMetasWithSigners(
1033
- accounts,
1034
- "programId",
1035
- programAddress
1036
- );
1037
- const instruction = getTransferSolWithSeedInstructionRaw(
1038
- accountMetas,
1039
- args,
1040
- programAddress
1041
- );
1042
- return instruction;
1043
- }
1044
- function getTransferSolWithSeedInstructionRaw(accounts, args, programAddress = "11111111111111111111111111111111", remainingAccounts) {
1045
- return {
898
+ const getAccountMeta = getAccountMetaFactory(programAddress);
899
+ const instruction = {
1046
900
  accounts: [
1047
- accountMetaWithDefault(accounts.source, instructions.AccountRole.WRITABLE),
1048
- accountMetaWithDefault(accounts.baseAccount, instructions.AccountRole.READONLY_SIGNER),
1049
- accountMetaWithDefault(accounts.destination, instructions.AccountRole.WRITABLE),
1050
- ...remainingAccounts ?? []
901
+ getAccountMeta(accounts.source),
902
+ getAccountMeta(accounts.baseAccount),
903
+ getAccountMeta(accounts.destination)
1051
904
  ],
1052
- data: getTransferSolWithSeedInstructionDataEncoder().encode(args),
1053
- programAddress
905
+ programAddress,
906
+ data: getTransferSolWithSeedInstructionDataEncoder().encode(
907
+ args
908
+ )
1054
909
  };
910
+ return instruction;
1055
911
  }
1056
912
  function parseTransferSolWithSeedInstruction(instruction) {
1057
913
  if (instruction.accounts.length < 3) {
@@ -1076,45 +932,33 @@ function parseTransferSolWithSeedInstruction(instruction) {
1076
932
  };
1077
933
  }
1078
934
  function getUpgradeNonceAccountInstructionDataEncoder() {
1079
- return codecs.mapEncoder(
1080
- codecs.getStructEncoder([["discriminator", codecs.getU32Encoder()]]),
935
+ return web3_js.transformEncoder(
936
+ web3_js.getStructEncoder([["discriminator", web3_js.getU32Encoder()]]),
1081
937
  (value) => ({ ...value, discriminator: 12 })
1082
938
  );
1083
939
  }
1084
940
  function getUpgradeNonceAccountInstructionDataDecoder() {
1085
- return codecs.getStructDecoder([["discriminator", codecs.getU32Decoder()]]);
941
+ return web3_js.getStructDecoder([["discriminator", web3_js.getU32Decoder()]]);
1086
942
  }
1087
943
  function getUpgradeNonceAccountInstructionDataCodec() {
1088
- return codecs.combineCodec(
944
+ return web3_js.combineCodec(
1089
945
  getUpgradeNonceAccountInstructionDataEncoder(),
1090
946
  getUpgradeNonceAccountInstructionDataDecoder()
1091
947
  );
1092
948
  }
1093
949
  function getUpgradeNonceAccountInstruction(input) {
1094
- const programAddress = "11111111111111111111111111111111";
1095
- const accounts = {
950
+ const programAddress = SYSTEM_PROGRAM_ADDRESS;
951
+ const originalAccounts = {
1096
952
  nonceAccount: { value: input.nonceAccount ?? null, isWritable: true }
1097
953
  };
1098
- const accountMetas = getAccountMetasWithSigners(
1099
- accounts,
1100
- "programId",
1101
- programAddress
1102
- );
1103
- const instruction = getUpgradeNonceAccountInstructionRaw(
1104
- accountMetas,
1105
- programAddress
1106
- );
1107
- return instruction;
1108
- }
1109
- function getUpgradeNonceAccountInstructionRaw(accounts, programAddress = "11111111111111111111111111111111", remainingAccounts) {
1110
- return {
1111
- accounts: [
1112
- accountMetaWithDefault(accounts.nonceAccount, instructions.AccountRole.WRITABLE),
1113
- ...remainingAccounts ?? []
1114
- ],
1115
- data: getUpgradeNonceAccountInstructionDataEncoder().encode({}),
1116
- programAddress
954
+ const accounts = originalAccounts;
955
+ const getAccountMeta = getAccountMetaFactory(programAddress);
956
+ const instruction = {
957
+ accounts: [getAccountMeta(accounts.nonceAccount)],
958
+ programAddress,
959
+ data: getUpgradeNonceAccountInstructionDataEncoder().encode({})
1117
960
  };
961
+ return instruction;
1118
962
  }
1119
963
  function parseUpgradeNonceAccountInstruction(instruction) {
1120
964
  if (instruction.accounts.length < 1) {
@@ -1137,29 +981,29 @@ function parseUpgradeNonceAccountInstruction(instruction) {
1137
981
  };
1138
982
  }
1139
983
  function getWithdrawNonceAccountInstructionDataEncoder() {
1140
- return codecs.mapEncoder(
1141
- codecs.getStructEncoder([
1142
- ["discriminator", codecs.getU32Encoder()],
1143
- ["withdrawAmount", codecs.getU64Encoder()]
984
+ return web3_js.transformEncoder(
985
+ web3_js.getStructEncoder([
986
+ ["discriminator", web3_js.getU32Encoder()],
987
+ ["withdrawAmount", web3_js.getU64Encoder()]
1144
988
  ]),
1145
989
  (value) => ({ ...value, discriminator: 5 })
1146
990
  );
1147
991
  }
1148
992
  function getWithdrawNonceAccountInstructionDataDecoder() {
1149
- return codecs.getStructDecoder([
1150
- ["discriminator", codecs.getU32Decoder()],
1151
- ["withdrawAmount", codecs.getU64Decoder()]
993
+ return web3_js.getStructDecoder([
994
+ ["discriminator", web3_js.getU32Decoder()],
995
+ ["withdrawAmount", web3_js.getU64Decoder()]
1152
996
  ]);
1153
997
  }
1154
998
  function getWithdrawNonceAccountInstructionDataCodec() {
1155
- return codecs.combineCodec(
999
+ return web3_js.combineCodec(
1156
1000
  getWithdrawNonceAccountInstructionDataEncoder(),
1157
1001
  getWithdrawNonceAccountInstructionDataDecoder()
1158
1002
  );
1159
1003
  }
1160
1004
  function getWithdrawNonceAccountInstruction(input) {
1161
- const programAddress = "11111111111111111111111111111111";
1162
- const accounts = {
1005
+ const programAddress = SYSTEM_PROGRAM_ADDRESS;
1006
+ const originalAccounts = {
1163
1007
  nonceAccount: { value: input.nonceAccount ?? null, isWritable: true },
1164
1008
  recipientAccount: {
1165
1009
  value: input.recipientAccount ?? null,
@@ -1172,6 +1016,7 @@ function getWithdrawNonceAccountInstruction(input) {
1172
1016
  rentSysvar: { value: input.rentSysvar ?? null, isWritable: false },
1173
1017
  nonceAuthority: { value: input.nonceAuthority ?? null, isWritable: false }
1174
1018
  };
1019
+ const accounts = originalAccounts;
1175
1020
  const args = { ...input };
1176
1021
  if (!accounts.recentBlockhashesSysvar.value) {
1177
1022
  accounts.recentBlockhashesSysvar.value = "SysvarRecentB1ockHashes11111111111111111111";
@@ -1179,40 +1024,21 @@ function getWithdrawNonceAccountInstruction(input) {
1179
1024
  if (!accounts.rentSysvar.value) {
1180
1025
  accounts.rentSysvar.value = "SysvarRent111111111111111111111111111111111";
1181
1026
  }
1182
- const accountMetas = getAccountMetasWithSigners(
1183
- accounts,
1184
- "programId",
1185
- programAddress
1186
- );
1187
- const instruction = getWithdrawNonceAccountInstructionRaw(
1188
- accountMetas,
1189
- args,
1190
- programAddress
1191
- );
1192
- return instruction;
1193
- }
1194
- function getWithdrawNonceAccountInstructionRaw(accounts, args, programAddress = "11111111111111111111111111111111", remainingAccounts) {
1195
- return {
1027
+ const getAccountMeta = getAccountMetaFactory(programAddress);
1028
+ const instruction = {
1196
1029
  accounts: [
1197
- accountMetaWithDefault(accounts.nonceAccount, instructions.AccountRole.WRITABLE),
1198
- accountMetaWithDefault(accounts.recipientAccount, instructions.AccountRole.WRITABLE),
1199
- accountMetaWithDefault(
1200
- accounts.recentBlockhashesSysvar ?? "SysvarRecentB1ockHashes11111111111111111111",
1201
- instructions.AccountRole.READONLY
1202
- ),
1203
- accountMetaWithDefault(
1204
- accounts.rentSysvar ?? "SysvarRent111111111111111111111111111111111",
1205
- instructions.AccountRole.READONLY
1206
- ),
1207
- accountMetaWithDefault(
1208
- accounts.nonceAuthority,
1209
- instructions.AccountRole.READONLY_SIGNER
1210
- ),
1211
- ...remainingAccounts ?? []
1030
+ getAccountMeta(accounts.nonceAccount),
1031
+ getAccountMeta(accounts.recipientAccount),
1032
+ getAccountMeta(accounts.recentBlockhashesSysvar),
1033
+ getAccountMeta(accounts.rentSysvar),
1034
+ getAccountMeta(accounts.nonceAuthority)
1212
1035
  ],
1213
- data: getWithdrawNonceAccountInstructionDataEncoder().encode(args),
1214
- programAddress
1036
+ programAddress,
1037
+ data: getWithdrawNonceAccountInstructionDataEncoder().encode(
1038
+ args
1039
+ )
1215
1040
  };
1041
+ return instruction;
1216
1042
  }
1217
1043
  function parseWithdrawNonceAccountInstruction(instruction) {
1218
1044
  if (instruction.accounts.length < 5) {
@@ -1238,148 +1064,65 @@ function parseWithdrawNonceAccountInstruction(instruction) {
1238
1064
  )
1239
1065
  };
1240
1066
  }
1241
- var SYSTEM_PROGRAM_ADDRESS = "11111111111111111111111111111111";
1242
- function getSystemProgram() {
1243
- return {
1244
- name: "system",
1245
- address: SYSTEM_PROGRAM_ADDRESS,
1246
- getErrorFromCode(code, cause) {
1247
- return getSystemProgramErrorFromCode(code, cause);
1248
- }
1249
- };
1250
- }
1251
- var SystemAccount = /* @__PURE__ */ ((SystemAccount2) => {
1252
- SystemAccount2[SystemAccount2["Nonce"] = 0] = "Nonce";
1253
- return SystemAccount2;
1254
- })(SystemAccount || {});
1255
- var SystemInstruction = /* @__PURE__ */ ((SystemInstruction2) => {
1256
- SystemInstruction2[SystemInstruction2["CreateAccount"] = 0] = "CreateAccount";
1257
- SystemInstruction2[SystemInstruction2["Assign"] = 1] = "Assign";
1258
- SystemInstruction2[SystemInstruction2["TransferSol"] = 2] = "TransferSol";
1259
- SystemInstruction2[SystemInstruction2["CreateAccountWithSeed"] = 3] = "CreateAccountWithSeed";
1260
- SystemInstruction2[SystemInstruction2["AdvanceNonceAccount"] = 4] = "AdvanceNonceAccount";
1261
- SystemInstruction2[SystemInstruction2["WithdrawNonceAccount"] = 5] = "WithdrawNonceAccount";
1262
- SystemInstruction2[SystemInstruction2["InitializeNonceAccount"] = 6] = "InitializeNonceAccount";
1263
- SystemInstruction2[SystemInstruction2["AuthorizeNonceAccount"] = 7] = "AuthorizeNonceAccount";
1264
- SystemInstruction2[SystemInstruction2["Allocate"] = 8] = "Allocate";
1265
- SystemInstruction2[SystemInstruction2["AllocateWithSeed"] = 9] = "AllocateWithSeed";
1266
- SystemInstruction2[SystemInstruction2["AssignWithSeed"] = 10] = "AssignWithSeed";
1267
- SystemInstruction2[SystemInstruction2["TransferSolWithSeed"] = 11] = "TransferSolWithSeed";
1268
- SystemInstruction2[SystemInstruction2["UpgradeNonceAccount"] = 12] = "UpgradeNonceAccount";
1269
- return SystemInstruction2;
1270
- })(SystemInstruction || {});
1271
- function identifySystemInstruction(instruction) {
1272
- const data = instruction instanceof Uint8Array ? instruction : instruction.data;
1273
- if (memcmp(data, codecs.getU32Encoder().encode(0), 0)) {
1274
- return 0 /* CreateAccount */;
1275
- }
1276
- if (memcmp(data, codecs.getU32Encoder().encode(1), 0)) {
1277
- return 1 /* Assign */;
1278
- }
1279
- if (memcmp(data, codecs.getU32Encoder().encode(2), 0)) {
1280
- return 2 /* TransferSol */;
1281
- }
1282
- if (memcmp(data, codecs.getU32Encoder().encode(3), 0)) {
1283
- return 3 /* CreateAccountWithSeed */;
1284
- }
1285
- if (memcmp(data, codecs.getU32Encoder().encode(4), 0)) {
1286
- return 4 /* AdvanceNonceAccount */;
1287
- }
1288
- if (memcmp(data, codecs.getU32Encoder().encode(5), 0)) {
1289
- return 5 /* WithdrawNonceAccount */;
1290
- }
1291
- if (memcmp(data, codecs.getU32Encoder().encode(6), 0)) {
1292
- return 6 /* InitializeNonceAccount */;
1293
- }
1294
- if (memcmp(data, codecs.getU32Encoder().encode(7), 0)) {
1295
- return 7 /* AuthorizeNonceAccount */;
1296
- }
1297
- if (memcmp(data, codecs.getU32Encoder().encode(8), 0)) {
1298
- return 8 /* Allocate */;
1299
- }
1300
- if (memcmp(data, codecs.getU32Encoder().encode(9), 0)) {
1301
- return 9 /* AllocateWithSeed */;
1302
- }
1303
- if (memcmp(data, codecs.getU32Encoder().encode(10), 0)) {
1304
- return 10 /* AssignWithSeed */;
1305
- }
1306
- if (memcmp(data, codecs.getU32Encoder().encode(11), 0)) {
1307
- return 11 /* TransferSolWithSeed */;
1308
- }
1309
- if (memcmp(data, codecs.getU32Encoder().encode(12), 0)) {
1310
- return 12 /* UpgradeNonceAccount */;
1311
- }
1312
- throw new Error(
1313
- "The provided instruction could not be identified as a system instruction."
1314
- );
1315
- }
1316
1067
 
1317
1068
  exports.NonceState = NonceState;
1318
1069
  exports.NonceVersion = NonceVersion;
1070
+ exports.SYSTEM_ERROR__ACCOUNT_ALREADY_IN_USE = SYSTEM_ERROR__ACCOUNT_ALREADY_IN_USE;
1071
+ exports.SYSTEM_ERROR__ADDRESS_WITH_SEED_MISMATCH = SYSTEM_ERROR__ADDRESS_WITH_SEED_MISMATCH;
1072
+ exports.SYSTEM_ERROR__INVALID_ACCOUNT_DATA_LENGTH = SYSTEM_ERROR__INVALID_ACCOUNT_DATA_LENGTH;
1073
+ exports.SYSTEM_ERROR__INVALID_PROGRAM_ID = SYSTEM_ERROR__INVALID_PROGRAM_ID;
1074
+ exports.SYSTEM_ERROR__MAX_SEED_LENGTH_EXCEEDED = SYSTEM_ERROR__MAX_SEED_LENGTH_EXCEEDED;
1075
+ exports.SYSTEM_ERROR__NONCE_BLOCKHASH_NOT_EXPIRED = SYSTEM_ERROR__NONCE_BLOCKHASH_NOT_EXPIRED;
1076
+ exports.SYSTEM_ERROR__NONCE_NO_RECENT_BLOCKHASHES = SYSTEM_ERROR__NONCE_NO_RECENT_BLOCKHASHES;
1077
+ exports.SYSTEM_ERROR__NONCE_UNEXPECTED_BLOCKHASH_VALUE = SYSTEM_ERROR__NONCE_UNEXPECTED_BLOCKHASH_VALUE;
1078
+ exports.SYSTEM_ERROR__RESULT_WITH_NEGATIVE_LAMPORTS = SYSTEM_ERROR__RESULT_WITH_NEGATIVE_LAMPORTS;
1319
1079
  exports.SYSTEM_PROGRAM_ADDRESS = SYSTEM_PROGRAM_ADDRESS;
1320
1080
  exports.SystemAccount = SystemAccount;
1321
1081
  exports.SystemInstruction = SystemInstruction;
1322
- exports.SystemProgramError = SystemProgramError;
1323
- exports.SystemProgramErrorCode = SystemProgramErrorCode;
1324
- exports.accountMetaWithDefault = accountMetaWithDefault;
1325
1082
  exports.decodeNonce = decodeNonce;
1326
- exports.expectAddress = expectAddress;
1327
- exports.expectProgramDerivedAddress = expectProgramDerivedAddress;
1328
- exports.expectSome = expectSome;
1329
- exports.expectTransactionSigner = expectTransactionSigner;
1330
1083
  exports.fetchAllMaybeNonce = fetchAllMaybeNonce;
1331
1084
  exports.fetchAllNonce = fetchAllNonce;
1332
1085
  exports.fetchMaybeNonce = fetchMaybeNonce;
1333
1086
  exports.fetchNonce = fetchNonce;
1334
- exports.getAccountMetasWithSigners = getAccountMetasWithSigners;
1335
1087
  exports.getAdvanceNonceAccountInstruction = getAdvanceNonceAccountInstruction;
1336
1088
  exports.getAdvanceNonceAccountInstructionDataCodec = getAdvanceNonceAccountInstructionDataCodec;
1337
1089
  exports.getAdvanceNonceAccountInstructionDataDecoder = getAdvanceNonceAccountInstructionDataDecoder;
1338
1090
  exports.getAdvanceNonceAccountInstructionDataEncoder = getAdvanceNonceAccountInstructionDataEncoder;
1339
- exports.getAdvanceNonceAccountInstructionRaw = getAdvanceNonceAccountInstructionRaw;
1340
1091
  exports.getAllocateInstruction = getAllocateInstruction;
1341
1092
  exports.getAllocateInstructionDataCodec = getAllocateInstructionDataCodec;
1342
1093
  exports.getAllocateInstructionDataDecoder = getAllocateInstructionDataDecoder;
1343
1094
  exports.getAllocateInstructionDataEncoder = getAllocateInstructionDataEncoder;
1344
- exports.getAllocateInstructionRaw = getAllocateInstructionRaw;
1345
1095
  exports.getAllocateWithSeedInstruction = getAllocateWithSeedInstruction;
1346
1096
  exports.getAllocateWithSeedInstructionDataCodec = getAllocateWithSeedInstructionDataCodec;
1347
1097
  exports.getAllocateWithSeedInstructionDataDecoder = getAllocateWithSeedInstructionDataDecoder;
1348
1098
  exports.getAllocateWithSeedInstructionDataEncoder = getAllocateWithSeedInstructionDataEncoder;
1349
- exports.getAllocateWithSeedInstructionRaw = getAllocateWithSeedInstructionRaw;
1350
1099
  exports.getAssignInstruction = getAssignInstruction;
1351
1100
  exports.getAssignInstructionDataCodec = getAssignInstructionDataCodec;
1352
1101
  exports.getAssignInstructionDataDecoder = getAssignInstructionDataDecoder;
1353
1102
  exports.getAssignInstructionDataEncoder = getAssignInstructionDataEncoder;
1354
- exports.getAssignInstructionRaw = getAssignInstructionRaw;
1355
1103
  exports.getAssignWithSeedInstruction = getAssignWithSeedInstruction;
1356
1104
  exports.getAssignWithSeedInstructionDataCodec = getAssignWithSeedInstructionDataCodec;
1357
1105
  exports.getAssignWithSeedInstructionDataDecoder = getAssignWithSeedInstructionDataDecoder;
1358
1106
  exports.getAssignWithSeedInstructionDataEncoder = getAssignWithSeedInstructionDataEncoder;
1359
- exports.getAssignWithSeedInstructionRaw = getAssignWithSeedInstructionRaw;
1360
1107
  exports.getAuthorizeNonceAccountInstruction = getAuthorizeNonceAccountInstruction;
1361
1108
  exports.getAuthorizeNonceAccountInstructionDataCodec = getAuthorizeNonceAccountInstructionDataCodec;
1362
1109
  exports.getAuthorizeNonceAccountInstructionDataDecoder = getAuthorizeNonceAccountInstructionDataDecoder;
1363
1110
  exports.getAuthorizeNonceAccountInstructionDataEncoder = getAuthorizeNonceAccountInstructionDataEncoder;
1364
- exports.getAuthorizeNonceAccountInstructionRaw = getAuthorizeNonceAccountInstructionRaw;
1365
1111
  exports.getCreateAccountInstruction = getCreateAccountInstruction;
1366
1112
  exports.getCreateAccountInstructionDataCodec = getCreateAccountInstructionDataCodec;
1367
1113
  exports.getCreateAccountInstructionDataDecoder = getCreateAccountInstructionDataDecoder;
1368
1114
  exports.getCreateAccountInstructionDataEncoder = getCreateAccountInstructionDataEncoder;
1369
- exports.getCreateAccountInstructionRaw = getCreateAccountInstructionRaw;
1370
1115
  exports.getCreateAccountWithSeedInstruction = getCreateAccountWithSeedInstruction;
1371
1116
  exports.getCreateAccountWithSeedInstructionDataCodec = getCreateAccountWithSeedInstructionDataCodec;
1372
1117
  exports.getCreateAccountWithSeedInstructionDataDecoder = getCreateAccountWithSeedInstructionDataDecoder;
1373
1118
  exports.getCreateAccountWithSeedInstructionDataEncoder = getCreateAccountWithSeedInstructionDataEncoder;
1374
- exports.getCreateAccountWithSeedInstructionRaw = getCreateAccountWithSeedInstructionRaw;
1375
1119
  exports.getInitializeNonceAccountInstruction = getInitializeNonceAccountInstruction;
1376
1120
  exports.getInitializeNonceAccountInstructionDataCodec = getInitializeNonceAccountInstructionDataCodec;
1377
1121
  exports.getInitializeNonceAccountInstructionDataDecoder = getInitializeNonceAccountInstructionDataDecoder;
1378
1122
  exports.getInitializeNonceAccountInstructionDataEncoder = getInitializeNonceAccountInstructionDataEncoder;
1379
- exports.getInitializeNonceAccountInstructionRaw = getInitializeNonceAccountInstructionRaw;
1380
- exports.getNonceAccountDataCodec = getNonceAccountDataCodec;
1381
- exports.getNonceAccountDataDecoder = getNonceAccountDataDecoder;
1382
- exports.getNonceAccountDataEncoder = getNonceAccountDataEncoder;
1123
+ exports.getNonceCodec = getNonceCodec;
1124
+ exports.getNonceDecoder = getNonceDecoder;
1125
+ exports.getNonceEncoder = getNonceEncoder;
1383
1126
  exports.getNonceSize = getNonceSize;
1384
1127
  exports.getNonceStateCodec = getNonceStateCodec;
1385
1128
  exports.getNonceStateDecoder = getNonceStateDecoder;
@@ -1387,31 +1130,24 @@ exports.getNonceStateEncoder = getNonceStateEncoder;
1387
1130
  exports.getNonceVersionCodec = getNonceVersionCodec;
1388
1131
  exports.getNonceVersionDecoder = getNonceVersionDecoder;
1389
1132
  exports.getNonceVersionEncoder = getNonceVersionEncoder;
1390
- exports.getSystemProgram = getSystemProgram;
1391
- exports.getSystemProgramErrorFromCode = getSystemProgramErrorFromCode;
1133
+ exports.getSystemErrorMessage = getSystemErrorMessage;
1392
1134
  exports.getTransferSolInstruction = getTransferSolInstruction;
1393
1135
  exports.getTransferSolInstructionDataCodec = getTransferSolInstructionDataCodec;
1394
1136
  exports.getTransferSolInstructionDataDecoder = getTransferSolInstructionDataDecoder;
1395
1137
  exports.getTransferSolInstructionDataEncoder = getTransferSolInstructionDataEncoder;
1396
- exports.getTransferSolInstructionRaw = getTransferSolInstructionRaw;
1397
1138
  exports.getTransferSolWithSeedInstruction = getTransferSolWithSeedInstruction;
1398
1139
  exports.getTransferSolWithSeedInstructionDataCodec = getTransferSolWithSeedInstructionDataCodec;
1399
1140
  exports.getTransferSolWithSeedInstructionDataDecoder = getTransferSolWithSeedInstructionDataDecoder;
1400
1141
  exports.getTransferSolWithSeedInstructionDataEncoder = getTransferSolWithSeedInstructionDataEncoder;
1401
- exports.getTransferSolWithSeedInstructionRaw = getTransferSolWithSeedInstructionRaw;
1402
1142
  exports.getUpgradeNonceAccountInstruction = getUpgradeNonceAccountInstruction;
1403
1143
  exports.getUpgradeNonceAccountInstructionDataCodec = getUpgradeNonceAccountInstructionDataCodec;
1404
1144
  exports.getUpgradeNonceAccountInstructionDataDecoder = getUpgradeNonceAccountInstructionDataDecoder;
1405
1145
  exports.getUpgradeNonceAccountInstructionDataEncoder = getUpgradeNonceAccountInstructionDataEncoder;
1406
- exports.getUpgradeNonceAccountInstructionRaw = getUpgradeNonceAccountInstructionRaw;
1407
1146
  exports.getWithdrawNonceAccountInstruction = getWithdrawNonceAccountInstruction;
1408
1147
  exports.getWithdrawNonceAccountInstructionDataCodec = getWithdrawNonceAccountInstructionDataCodec;
1409
1148
  exports.getWithdrawNonceAccountInstructionDataDecoder = getWithdrawNonceAccountInstructionDataDecoder;
1410
1149
  exports.getWithdrawNonceAccountInstructionDataEncoder = getWithdrawNonceAccountInstructionDataEncoder;
1411
- exports.getWithdrawNonceAccountInstructionRaw = getWithdrawNonceAccountInstructionRaw;
1412
1150
  exports.identifySystemInstruction = identifySystemInstruction;
1413
- exports.isTransactionSigner = isTransactionSigner;
1414
- exports.memcmp = memcmp;
1415
1151
  exports.parseAdvanceNonceAccountInstruction = parseAdvanceNonceAccountInstruction;
1416
1152
  exports.parseAllocateInstruction = parseAllocateInstruction;
1417
1153
  exports.parseAllocateWithSeedInstruction = parseAllocateWithSeedInstruction;