@solana-program/system 0.2.0 → 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 +244 -338
  2. package/dist/src/index.cjs.map +1 -1
  3. package/dist/src/index.js +112 -205
  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 +1 -4
  12. package/dist/types/src/generated/instructions/advanceNonceAccount.d.ts.map +1 -1
  13. package/dist/types/src/generated/instructions/allocate.d.ts +1 -4
  14. package/dist/types/src/generated/instructions/allocate.d.ts.map +1 -1
  15. package/dist/types/src/generated/instructions/allocateWithSeed.d.ts +1 -4
  16. package/dist/types/src/generated/instructions/allocateWithSeed.d.ts.map +1 -1
  17. package/dist/types/src/generated/instructions/assign.d.ts +1 -4
  18. package/dist/types/src/generated/instructions/assign.d.ts.map +1 -1
  19. package/dist/types/src/generated/instructions/assignWithSeed.d.ts +1 -4
  20. package/dist/types/src/generated/instructions/assignWithSeed.d.ts.map +1 -1
  21. package/dist/types/src/generated/instructions/authorizeNonceAccount.d.ts +1 -4
  22. package/dist/types/src/generated/instructions/authorizeNonceAccount.d.ts.map +1 -1
  23. package/dist/types/src/generated/instructions/createAccount.d.ts +1 -4
  24. package/dist/types/src/generated/instructions/createAccount.d.ts.map +1 -1
  25. package/dist/types/src/generated/instructions/createAccountWithSeed.d.ts +1 -4
  26. package/dist/types/src/generated/instructions/createAccountWithSeed.d.ts.map +1 -1
  27. package/dist/types/src/generated/instructions/initializeNonceAccount.d.ts +1 -3
  28. package/dist/types/src/generated/instructions/initializeNonceAccount.d.ts.map +1 -1
  29. package/dist/types/src/generated/instructions/transferSol.d.ts +1 -4
  30. package/dist/types/src/generated/instructions/transferSol.d.ts.map +1 -1
  31. package/dist/types/src/generated/instructions/transferSolWithSeed.d.ts +1 -4
  32. package/dist/types/src/generated/instructions/transferSolWithSeed.d.ts.map +1 -1
  33. package/dist/types/src/generated/instructions/upgradeNonceAccount.d.ts +1 -3
  34. package/dist/types/src/generated/instructions/upgradeNonceAccount.d.ts.map +1 -1
  35. package/dist/types/src/generated/instructions/withdrawNonceAccount.d.ts +1 -4
  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 +1 -4
  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 +5 -10
package/dist/src/index.js CHANGED
@@ -1,8 +1,4 @@
1
- import { decodeAccount, assertAccountExists, fetchEncodedAccount, assertAccountsExist, fetchEncodedAccounts, BASE_ACCOUNT_SIZE } from '@solana/accounts';
2
- import { getAddressEncoder, getAddressDecoder, isProgramDerivedAddress } from '@solana/addresses';
3
- import { getScalarEnumEncoder, getU32Encoder, getScalarEnumDecoder, getU32Decoder, combineCodec, getStructEncoder, getU64Encoder, getStructDecoder, getU64Decoder, mapEncoder, getStringEncoder, getStringDecoder } from '@solana/codecs';
4
- import { AccountRole, upgradeRoleToSigner } from '@solana/instructions';
5
- import { isTransactionSigner as isTransactionSigner$1 } from '@solana/signers';
1
+ import { getEnumEncoder, getU32Encoder, getEnumDecoder, getU32Decoder, combineCodec, getStructEncoder, getAddressEncoder, getU64Encoder, getStructDecoder, getAddressDecoder, getU64Decoder, decodeAccount, assertAccountExists, fetchEncodedAccount, assertAccountsExist, fetchEncodedAccounts, containsBytes, transformEncoder, addEncoderSizePrefix, getUtf8Encoder, addDecoderSizePrefix, getUtf8Decoder, BASE_ACCOUNT_SIZE, AccountRole, upgradeRoleToSigner, isTransactionSigner as isTransactionSigner$1 } from '@solana/web3.js';
6
2
 
7
3
  // env-shim.ts
8
4
  var __DEV__ = /* @__PURE__ */ (() => process["env"].NODE_ENV === "development")();
@@ -12,10 +8,10 @@ var NonceState = /* @__PURE__ */ ((NonceState3) => {
12
8
  return NonceState3;
13
9
  })(NonceState || {});
14
10
  function getNonceStateEncoder() {
15
- return getScalarEnumEncoder(NonceState, { size: getU32Encoder() });
11
+ return getEnumEncoder(NonceState, { size: getU32Encoder() });
16
12
  }
17
13
  function getNonceStateDecoder() {
18
- return getScalarEnumDecoder(NonceState, { size: getU32Decoder() });
14
+ return getEnumDecoder(NonceState, { size: getU32Decoder() });
19
15
  }
20
16
  function getNonceStateCodec() {
21
17
  return combineCodec(getNonceStateEncoder(), getNonceStateDecoder());
@@ -26,17 +22,17 @@ var NonceVersion = /* @__PURE__ */ ((NonceVersion3) => {
26
22
  return NonceVersion3;
27
23
  })(NonceVersion || {});
28
24
  function getNonceVersionEncoder() {
29
- return getScalarEnumEncoder(NonceVersion, { size: getU32Encoder() });
25
+ return getEnumEncoder(NonceVersion, { size: getU32Encoder() });
30
26
  }
31
27
  function getNonceVersionDecoder() {
32
- return getScalarEnumDecoder(NonceVersion, { size: getU32Decoder() });
28
+ return getEnumDecoder(NonceVersion, { size: getU32Decoder() });
33
29
  }
34
30
  function getNonceVersionCodec() {
35
31
  return combineCodec(getNonceVersionEncoder(), getNonceVersionDecoder());
36
32
  }
37
33
 
38
34
  // src/generated/accounts/nonce.ts
39
- function getNonceAccountDataEncoder() {
35
+ function getNonceEncoder() {
40
36
  return getStructEncoder([
41
37
  ["version", getNonceVersionEncoder()],
42
38
  ["state", getNonceStateEncoder()],
@@ -45,7 +41,7 @@ function getNonceAccountDataEncoder() {
45
41
  ["lamportsPerSignature", getU64Encoder()]
46
42
  ]);
47
43
  }
48
- function getNonceAccountDataDecoder() {
44
+ function getNonceDecoder() {
49
45
  return getStructDecoder([
50
46
  ["version", getNonceVersionDecoder()],
51
47
  ["state", getNonceStateDecoder()],
@@ -54,16 +50,13 @@ function getNonceAccountDataDecoder() {
54
50
  ["lamportsPerSignature", getU64Decoder()]
55
51
  ]);
56
52
  }
57
- function getNonceAccountDataCodec() {
58
- return combineCodec(
59
- getNonceAccountDataEncoder(),
60
- getNonceAccountDataDecoder()
61
- );
53
+ function getNonceCodec() {
54
+ return combineCodec(getNonceEncoder(), getNonceDecoder());
62
55
  }
63
56
  function decodeNonce(encodedAccount) {
64
57
  return decodeAccount(
65
58
  encodedAccount,
66
- getNonceAccountDataDecoder()
59
+ getNonceDecoder()
67
60
  );
68
61
  }
69
62
  async function fetchNonce(rpc, address, config) {
@@ -89,153 +82,36 @@ function getNonceSize() {
89
82
  }
90
83
 
91
84
  // src/generated/errors/system.ts
92
- var SystemProgramErrorCode = /* @__PURE__ */ ((SystemProgramErrorCode3) => {
93
- SystemProgramErrorCode3[SystemProgramErrorCode3["ACCOUNT_ALREADY_IN_USE"] = 0] = "ACCOUNT_ALREADY_IN_USE";
94
- SystemProgramErrorCode3[SystemProgramErrorCode3["RESULT_WITH_NEGATIVE_LAMPORTS"] = 1] = "RESULT_WITH_NEGATIVE_LAMPORTS";
95
- SystemProgramErrorCode3[SystemProgramErrorCode3["INVALID_PROGRAM_ID"] = 2] = "INVALID_PROGRAM_ID";
96
- SystemProgramErrorCode3[SystemProgramErrorCode3["INVALID_ACCOUNT_DATA_LENGTH"] = 3] = "INVALID_ACCOUNT_DATA_LENGTH";
97
- SystemProgramErrorCode3[SystemProgramErrorCode3["MAX_SEED_LENGTH_EXCEEDED"] = 4] = "MAX_SEED_LENGTH_EXCEEDED";
98
- SystemProgramErrorCode3[SystemProgramErrorCode3["ADDRESS_WITH_SEED_MISMATCH"] = 5] = "ADDRESS_WITH_SEED_MISMATCH";
99
- SystemProgramErrorCode3[SystemProgramErrorCode3["NONCE_NO_RECENT_BLOCKHASHES"] = 6] = "NONCE_NO_RECENT_BLOCKHASHES";
100
- SystemProgramErrorCode3[SystemProgramErrorCode3["NONCE_BLOCKHASH_NOT_EXPIRED"] = 7] = "NONCE_BLOCKHASH_NOT_EXPIRED";
101
- SystemProgramErrorCode3[SystemProgramErrorCode3["NONCE_UNEXPECTED_BLOCKHASH_VALUE"] = 8] = "NONCE_UNEXPECTED_BLOCKHASH_VALUE";
102
- return SystemProgramErrorCode3;
103
- })(SystemProgramErrorCode || {});
104
- var SystemProgramError = class extends Error {
105
- name = "SystemProgramError";
106
- code;
107
- cause;
108
- constructor(code, name, message, cause) {
109
- super(`${name} (${code}): ${message}`);
110
- this.code = code;
111
- this.cause = cause;
112
- }
113
- };
114
- var systemProgramErrorCodeMap;
85
+ var SYSTEM_ERROR__ACCOUNT_ALREADY_IN_USE = 0;
86
+ var SYSTEM_ERROR__RESULT_WITH_NEGATIVE_LAMPORTS = 1;
87
+ var SYSTEM_ERROR__INVALID_PROGRAM_ID = 2;
88
+ var SYSTEM_ERROR__INVALID_ACCOUNT_DATA_LENGTH = 3;
89
+ var SYSTEM_ERROR__MAX_SEED_LENGTH_EXCEEDED = 4;
90
+ var SYSTEM_ERROR__ADDRESS_WITH_SEED_MISMATCH = 5;
91
+ var SYSTEM_ERROR__NONCE_NO_RECENT_BLOCKHASHES = 6;
92
+ var SYSTEM_ERROR__NONCE_BLOCKHASH_NOT_EXPIRED = 7;
93
+ var SYSTEM_ERROR__NONCE_UNEXPECTED_BLOCKHASH_VALUE = 8;
94
+ var systemErrorMessages;
115
95
  if (__DEV__) {
116
- systemProgramErrorCodeMap = {
117
- [0 /* ACCOUNT_ALREADY_IN_USE */]: [
118
- "AccountAlreadyInUse",
119
- `an account with the same address already exists`
120
- ],
121
- [1 /* RESULT_WITH_NEGATIVE_LAMPORTS */]: [
122
- "ResultWithNegativeLamports",
123
- `account does not have enough SOL to perform the operation`
124
- ],
125
- [2 /* INVALID_PROGRAM_ID */]: [
126
- "InvalidProgramId",
127
- `cannot assign account to this program id`
128
- ],
129
- [3 /* INVALID_ACCOUNT_DATA_LENGTH */]: [
130
- "InvalidAccountDataLength",
131
- `cannot allocate account data of this length`
132
- ],
133
- [4 /* MAX_SEED_LENGTH_EXCEEDED */]: [
134
- "MaxSeedLengthExceeded",
135
- `length of requested seed is too long`
136
- ],
137
- [5 /* ADDRESS_WITH_SEED_MISMATCH */]: [
138
- "AddressWithSeedMismatch",
139
- `provided address does not match addressed derived from seed`
140
- ],
141
- [6 /* NONCE_NO_RECENT_BLOCKHASHES */]: [
142
- "NonceNoRecentBlockhashes",
143
- `advancing stored nonce requires a populated RecentBlockhashes sysvar`
144
- ],
145
- [7 /* NONCE_BLOCKHASH_NOT_EXPIRED */]: [
146
- "NonceBlockhashNotExpired",
147
- `stored nonce is still in recent_blockhashes`
148
- ],
149
- [8 /* NONCE_UNEXPECTED_BLOCKHASH_VALUE */]: [
150
- "NonceUnexpectedBlockhashValue",
151
- `specified nonce does not match stored nonce`
152
- ]
96
+ systemErrorMessages = {
97
+ [SYSTEM_ERROR__ACCOUNT_ALREADY_IN_USE]: `an account with the same address already exists`,
98
+ [SYSTEM_ERROR__ADDRESS_WITH_SEED_MISMATCH]: `provided address does not match addressed derived from seed`,
99
+ [SYSTEM_ERROR__INVALID_ACCOUNT_DATA_LENGTH]: `cannot allocate account data of this length`,
100
+ [SYSTEM_ERROR__INVALID_PROGRAM_ID]: `cannot assign account to this program id`,
101
+ [SYSTEM_ERROR__MAX_SEED_LENGTH_EXCEEDED]: `length of requested seed is too long`,
102
+ [SYSTEM_ERROR__NONCE_BLOCKHASH_NOT_EXPIRED]: `stored nonce is still in recent_blockhashes`,
103
+ [SYSTEM_ERROR__NONCE_NO_RECENT_BLOCKHASHES]: `advancing stored nonce requires a populated RecentBlockhashes sysvar`,
104
+ [SYSTEM_ERROR__NONCE_UNEXPECTED_BLOCKHASH_VALUE]: `specified nonce does not match stored nonce`,
105
+ [SYSTEM_ERROR__RESULT_WITH_NEGATIVE_LAMPORTS]: `account does not have enough SOL to perform the operation`
153
106
  };
154
107
  }
155
- function getSystemProgramErrorFromCode(code, cause) {
108
+ function getSystemErrorMessage(code) {
156
109
  if (__DEV__) {
157
- return new SystemProgramError(
158
- code,
159
- ...systemProgramErrorCodeMap[code],
160
- cause
161
- );
110
+ return systemErrorMessages[code];
162
111
  }
163
- return new SystemProgramError(
164
- code,
165
- "Unknown",
166
- "Error message not available in production bundles. Compile with __DEV__ set to true to see more information.",
167
- cause
168
- );
112
+ return "Error message not available in production bundles. Compile with `__DEV__` set to true to see more information.";
169
113
  }
170
- function expectSome(value) {
171
- if (value == null) {
172
- throw new Error("Expected a value but received null or undefined.");
173
- }
174
- return value;
175
- }
176
- function expectAddress(value) {
177
- if (!value) {
178
- throw new Error("Expected a Address.");
179
- }
180
- if (typeof value === "object" && "address" in value) {
181
- return value.address;
182
- }
183
- if (Array.isArray(value)) {
184
- return value[0];
185
- }
186
- return value;
187
- }
188
- function expectProgramDerivedAddress(value) {
189
- if (!value || !Array.isArray(value) || !isProgramDerivedAddress(value)) {
190
- throw new Error("Expected a ProgramDerivedAddress.");
191
- }
192
- return value;
193
- }
194
- function expectTransactionSigner(value) {
195
- if (!value || !isTransactionSigner(value)) {
196
- throw new Error("Expected a TransactionSigner.");
197
- }
198
- return value;
199
- }
200
- function getAccountMetaFactory(programAddress, optionalAccountStrategy) {
201
- return (account) => {
202
- if (!account.value) {
203
- if (optionalAccountStrategy === "omitted")
204
- return;
205
- return Object.freeze({
206
- address: programAddress,
207
- role: AccountRole.READONLY
208
- });
209
- }
210
- const writableRole = account.isWritable ? AccountRole.WRITABLE : AccountRole.READONLY;
211
- return Object.freeze({
212
- address: expectAddress(account.value),
213
- role: isTransactionSigner(account.value) ? upgradeRoleToSigner(writableRole) : writableRole,
214
- ...isTransactionSigner(account.value) ? { signer: account.value } : {}
215
- });
216
- };
217
- }
218
- function isTransactionSigner(value) {
219
- return !!value && typeof value === "object" && "address" in value && isTransactionSigner$1(value);
220
- }
221
- function memcmp(data, bytes, offset) {
222
- const slice = data.slice(offset, offset + bytes.length);
223
- if (slice.length !== bytes.length)
224
- return false;
225
- return bytes.every((b, i) => b === slice[i]);
226
- }
227
-
228
- // src/generated/programs/system.ts
229
114
  var SYSTEM_PROGRAM_ADDRESS = "11111111111111111111111111111111";
230
- function getSystemProgram() {
231
- return {
232
- name: "system",
233
- address: SYSTEM_PROGRAM_ADDRESS,
234
- getErrorFromCode(code, cause) {
235
- return getSystemProgramErrorFromCode(code, cause);
236
- }
237
- };
238
- }
239
115
  var SystemAccount = /* @__PURE__ */ ((SystemAccount2) => {
240
116
  SystemAccount2[SystemAccount2["Nonce"] = 0] = "Nonce";
241
117
  return SystemAccount2;
@@ -258,53 +134,84 @@ var SystemInstruction = /* @__PURE__ */ ((SystemInstruction2) => {
258
134
  })(SystemInstruction || {});
259
135
  function identifySystemInstruction(instruction) {
260
136
  const data = instruction instanceof Uint8Array ? instruction : instruction.data;
261
- if (memcmp(data, getU32Encoder().encode(0), 0)) {
137
+ if (containsBytes(data, getU32Encoder().encode(0), 0)) {
262
138
  return 0 /* CreateAccount */;
263
139
  }
264
- if (memcmp(data, getU32Encoder().encode(1), 0)) {
140
+ if (containsBytes(data, getU32Encoder().encode(1), 0)) {
265
141
  return 1 /* Assign */;
266
142
  }
267
- if (memcmp(data, getU32Encoder().encode(2), 0)) {
143
+ if (containsBytes(data, getU32Encoder().encode(2), 0)) {
268
144
  return 2 /* TransferSol */;
269
145
  }
270
- if (memcmp(data, getU32Encoder().encode(3), 0)) {
146
+ if (containsBytes(data, getU32Encoder().encode(3), 0)) {
271
147
  return 3 /* CreateAccountWithSeed */;
272
148
  }
273
- if (memcmp(data, getU32Encoder().encode(4), 0)) {
149
+ if (containsBytes(data, getU32Encoder().encode(4), 0)) {
274
150
  return 4 /* AdvanceNonceAccount */;
275
151
  }
276
- if (memcmp(data, getU32Encoder().encode(5), 0)) {
152
+ if (containsBytes(data, getU32Encoder().encode(5), 0)) {
277
153
  return 5 /* WithdrawNonceAccount */;
278
154
  }
279
- if (memcmp(data, getU32Encoder().encode(6), 0)) {
155
+ if (containsBytes(data, getU32Encoder().encode(6), 0)) {
280
156
  return 6 /* InitializeNonceAccount */;
281
157
  }
282
- if (memcmp(data, getU32Encoder().encode(7), 0)) {
158
+ if (containsBytes(data, getU32Encoder().encode(7), 0)) {
283
159
  return 7 /* AuthorizeNonceAccount */;
284
160
  }
285
- if (memcmp(data, getU32Encoder().encode(8), 0)) {
161
+ if (containsBytes(data, getU32Encoder().encode(8), 0)) {
286
162
  return 8 /* Allocate */;
287
163
  }
288
- if (memcmp(data, getU32Encoder().encode(9), 0)) {
164
+ if (containsBytes(data, getU32Encoder().encode(9), 0)) {
289
165
  return 9 /* AllocateWithSeed */;
290
166
  }
291
- if (memcmp(data, getU32Encoder().encode(10), 0)) {
167
+ if (containsBytes(data, getU32Encoder().encode(10), 0)) {
292
168
  return 10 /* AssignWithSeed */;
293
169
  }
294
- if (memcmp(data, getU32Encoder().encode(11), 0)) {
170
+ if (containsBytes(data, getU32Encoder().encode(11), 0)) {
295
171
  return 11 /* TransferSolWithSeed */;
296
172
  }
297
- if (memcmp(data, getU32Encoder().encode(12), 0)) {
173
+ if (containsBytes(data, getU32Encoder().encode(12), 0)) {
298
174
  return 12 /* UpgradeNonceAccount */;
299
175
  }
300
176
  throw new Error(
301
177
  "The provided instruction could not be identified as a system instruction."
302
178
  );
303
179
  }
180
+ function expectAddress(value) {
181
+ if (!value) {
182
+ throw new Error("Expected a Address.");
183
+ }
184
+ if (typeof value === "object" && "address" in value) {
185
+ return value.address;
186
+ }
187
+ if (Array.isArray(value)) {
188
+ return value[0];
189
+ }
190
+ return value;
191
+ }
192
+ function getAccountMetaFactory(programAddress, optionalAccountStrategy) {
193
+ return (account) => {
194
+ if (!account.value) {
195
+ return Object.freeze({
196
+ address: programAddress,
197
+ role: AccountRole.READONLY
198
+ });
199
+ }
200
+ const writableRole = account.isWritable ? AccountRole.WRITABLE : AccountRole.READONLY;
201
+ return Object.freeze({
202
+ address: expectAddress(account.value),
203
+ role: isTransactionSigner(account.value) ? upgradeRoleToSigner(writableRole) : writableRole,
204
+ ...isTransactionSigner(account.value) ? { signer: account.value } : {}
205
+ });
206
+ };
207
+ }
208
+ function isTransactionSigner(value) {
209
+ return !!value && typeof value === "object" && "address" in value && isTransactionSigner$1(value);
210
+ }
304
211
 
305
212
  // src/generated/instructions/advanceNonceAccount.ts
306
213
  function getAdvanceNonceAccountInstructionDataEncoder() {
307
- return mapEncoder(
214
+ return transformEncoder(
308
215
  getStructEncoder([["discriminator", getU32Encoder()]]),
309
216
  (value) => ({ ...value, discriminator: 4 })
310
217
  );
@@ -332,7 +239,7 @@ function getAdvanceNonceAccountInstruction(input) {
332
239
  if (!accounts.recentBlockhashesSysvar.value) {
333
240
  accounts.recentBlockhashesSysvar.value = "SysvarRecentB1ockHashes11111111111111111111";
334
241
  }
335
- const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
242
+ const getAccountMeta = getAccountMetaFactory(programAddress);
336
243
  const instruction = {
337
244
  accounts: [
338
245
  getAccountMeta(accounts.nonceAccount),
@@ -367,7 +274,7 @@ function parseAdvanceNonceAccountInstruction(instruction) {
367
274
  };
368
275
  }
369
276
  function getAllocateInstructionDataEncoder() {
370
- return mapEncoder(
277
+ return transformEncoder(
371
278
  getStructEncoder([
372
279
  ["discriminator", getU32Encoder()],
373
280
  ["space", getU64Encoder()]
@@ -394,7 +301,7 @@ function getAllocateInstruction(input) {
394
301
  };
395
302
  const accounts = originalAccounts;
396
303
  const args = { ...input };
397
- const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
304
+ const getAccountMeta = getAccountMetaFactory(programAddress);
398
305
  const instruction = {
399
306
  accounts: [getAccountMeta(accounts.newAccount)],
400
307
  programAddress,
@@ -423,11 +330,11 @@ function parseAllocateInstruction(instruction) {
423
330
  };
424
331
  }
425
332
  function getAllocateWithSeedInstructionDataEncoder() {
426
- return mapEncoder(
333
+ return transformEncoder(
427
334
  getStructEncoder([
428
335
  ["discriminator", getU32Encoder()],
429
336
  ["base", getAddressEncoder()],
430
- ["seed", getStringEncoder()],
337
+ ["seed", addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())],
431
338
  ["space", getU64Encoder()],
432
339
  ["programAddress", getAddressEncoder()]
433
340
  ]),
@@ -438,7 +345,7 @@ function getAllocateWithSeedInstructionDataDecoder() {
438
345
  return getStructDecoder([
439
346
  ["discriminator", getU32Decoder()],
440
347
  ["base", getAddressDecoder()],
441
- ["seed", getStringDecoder()],
348
+ ["seed", addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
442
349
  ["space", getU64Decoder()],
443
350
  ["programAddress", getAddressDecoder()]
444
351
  ]);
@@ -457,7 +364,7 @@ function getAllocateWithSeedInstruction(input) {
457
364
  };
458
365
  const accounts = originalAccounts;
459
366
  const args = { ...input };
460
- const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
367
+ const getAccountMeta = getAccountMetaFactory(programAddress);
461
368
  const instruction = {
462
369
  accounts: [
463
370
  getAccountMeta(accounts.newAccount),
@@ -490,7 +397,7 @@ function parseAllocateWithSeedInstruction(instruction) {
490
397
  };
491
398
  }
492
399
  function getAssignInstructionDataEncoder() {
493
- return mapEncoder(
400
+ return transformEncoder(
494
401
  getStructEncoder([
495
402
  ["discriminator", getU32Encoder()],
496
403
  ["programAddress", getAddressEncoder()]
@@ -517,7 +424,7 @@ function getAssignInstruction(input) {
517
424
  };
518
425
  const accounts = originalAccounts;
519
426
  const args = { ...input };
520
- const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
427
+ const getAccountMeta = getAccountMetaFactory(programAddress);
521
428
  const instruction = {
522
429
  accounts: [getAccountMeta(accounts.account)],
523
430
  programAddress,
@@ -546,11 +453,11 @@ function parseAssignInstruction(instruction) {
546
453
  };
547
454
  }
548
455
  function getAssignWithSeedInstructionDataEncoder() {
549
- return mapEncoder(
456
+ return transformEncoder(
550
457
  getStructEncoder([
551
458
  ["discriminator", getU32Encoder()],
552
459
  ["base", getAddressEncoder()],
553
- ["seed", getStringEncoder()],
460
+ ["seed", addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())],
554
461
  ["programAddress", getAddressEncoder()]
555
462
  ]),
556
463
  (value) => ({ ...value, discriminator: 10 })
@@ -560,7 +467,7 @@ function getAssignWithSeedInstructionDataDecoder() {
560
467
  return getStructDecoder([
561
468
  ["discriminator", getU32Decoder()],
562
469
  ["base", getAddressDecoder()],
563
- ["seed", getStringDecoder()],
470
+ ["seed", addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
564
471
  ["programAddress", getAddressDecoder()]
565
472
  ]);
566
473
  }
@@ -578,7 +485,7 @@ function getAssignWithSeedInstruction(input) {
578
485
  };
579
486
  const accounts = originalAccounts;
580
487
  const args = { ...input };
581
- const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
488
+ const getAccountMeta = getAccountMetaFactory(programAddress);
582
489
  const instruction = {
583
490
  accounts: [
584
491
  getAccountMeta(accounts.account),
@@ -611,7 +518,7 @@ function parseAssignWithSeedInstruction(instruction) {
611
518
  };
612
519
  }
613
520
  function getAuthorizeNonceAccountInstructionDataEncoder() {
614
- return mapEncoder(
521
+ return transformEncoder(
615
522
  getStructEncoder([
616
523
  ["discriminator", getU32Encoder()],
617
524
  ["newNonceAuthority", getAddressEncoder()]
@@ -639,7 +546,7 @@ function getAuthorizeNonceAccountInstruction(input) {
639
546
  };
640
547
  const accounts = originalAccounts;
641
548
  const args = { ...input };
642
- const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
549
+ const getAccountMeta = getAccountMetaFactory(programAddress);
643
550
  const instruction = {
644
551
  accounts: [
645
552
  getAccountMeta(accounts.nonceAccount),
@@ -674,7 +581,7 @@ function parseAuthorizeNonceAccountInstruction(instruction) {
674
581
  };
675
582
  }
676
583
  function getCreateAccountInstructionDataEncoder() {
677
- return mapEncoder(
584
+ return transformEncoder(
678
585
  getStructEncoder([
679
586
  ["discriminator", getU32Encoder()],
680
587
  ["lamports", getU64Encoder()],
@@ -710,7 +617,7 @@ function getCreateAccountInstruction(input) {
710
617
  (a, b) => a + b,
711
618
  0
712
619
  );
713
- const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
620
+ const getAccountMeta = getAccountMetaFactory(programAddress);
714
621
  const instruction = {
715
622
  accounts: [
716
623
  getAccountMeta(accounts.payer),
@@ -743,11 +650,11 @@ function parseCreateAccountInstruction(instruction) {
743
650
  };
744
651
  }
745
652
  function getCreateAccountWithSeedInstructionDataEncoder() {
746
- return mapEncoder(
653
+ return transformEncoder(
747
654
  getStructEncoder([
748
655
  ["discriminator", getU32Encoder()],
749
656
  ["base", getAddressEncoder()],
750
- ["seed", getStringEncoder()],
657
+ ["seed", addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())],
751
658
  ["amount", getU64Encoder()],
752
659
  ["space", getU64Encoder()],
753
660
  ["programAddress", getAddressEncoder()]
@@ -759,7 +666,7 @@ function getCreateAccountWithSeedInstructionDataDecoder() {
759
666
  return getStructDecoder([
760
667
  ["discriminator", getU32Decoder()],
761
668
  ["base", getAddressDecoder()],
762
- ["seed", getStringDecoder()],
669
+ ["seed", addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
763
670
  ["amount", getU64Decoder()],
764
671
  ["space", getU64Decoder()],
765
672
  ["programAddress", getAddressDecoder()]
@@ -780,7 +687,7 @@ function getCreateAccountWithSeedInstruction(input) {
780
687
  };
781
688
  const accounts = originalAccounts;
782
689
  const args = { ...input };
783
- const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
690
+ const getAccountMeta = getAccountMetaFactory(programAddress);
784
691
  const instruction = {
785
692
  accounts: [
786
693
  getAccountMeta(accounts.payer),
@@ -817,7 +724,7 @@ function parseCreateAccountWithSeedInstruction(instruction) {
817
724
  };
818
725
  }
819
726
  function getInitializeNonceAccountInstructionDataEncoder() {
820
- return mapEncoder(
727
+ return transformEncoder(
821
728
  getStructEncoder([
822
729
  ["discriminator", getU32Encoder()],
823
730
  ["nonceAuthority", getAddressEncoder()]
@@ -855,7 +762,7 @@ function getInitializeNonceAccountInstruction(input) {
855
762
  if (!accounts.rentSysvar.value) {
856
763
  accounts.rentSysvar.value = "SysvarRent111111111111111111111111111111111";
857
764
  }
858
- const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
765
+ const getAccountMeta = getAccountMetaFactory(programAddress);
859
766
  const instruction = {
860
767
  accounts: [
861
768
  getAccountMeta(accounts.nonceAccount),
@@ -892,7 +799,7 @@ function parseInitializeNonceAccountInstruction(instruction) {
892
799
  };
893
800
  }
894
801
  function getTransferSolInstructionDataEncoder() {
895
- return mapEncoder(
802
+ return transformEncoder(
896
803
  getStructEncoder([
897
804
  ["discriminator", getU32Encoder()],
898
805
  ["amount", getU64Encoder()]
@@ -920,7 +827,7 @@ function getTransferSolInstruction(input) {
920
827
  };
921
828
  const accounts = originalAccounts;
922
829
  const args = { ...input };
923
- const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
830
+ const getAccountMeta = getAccountMetaFactory(programAddress);
924
831
  const instruction = {
925
832
  accounts: [
926
833
  getAccountMeta(accounts.source),
@@ -953,11 +860,11 @@ function parseTransferSolInstruction(instruction) {
953
860
  };
954
861
  }
955
862
  function getTransferSolWithSeedInstructionDataEncoder() {
956
- return mapEncoder(
863
+ return transformEncoder(
957
864
  getStructEncoder([
958
865
  ["discriminator", getU32Encoder()],
959
866
  ["amount", getU64Encoder()],
960
- ["fromSeed", getStringEncoder()],
867
+ ["fromSeed", addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())],
961
868
  ["fromOwner", getAddressEncoder()]
962
869
  ]),
963
870
  (value) => ({ ...value, discriminator: 11 })
@@ -967,7 +874,7 @@ function getTransferSolWithSeedInstructionDataDecoder() {
967
874
  return getStructDecoder([
968
875
  ["discriminator", getU32Decoder()],
969
876
  ["amount", getU64Decoder()],
970
- ["fromSeed", getStringDecoder()],
877
+ ["fromSeed", addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
971
878
  ["fromOwner", getAddressDecoder()]
972
879
  ]);
973
880
  }
@@ -986,7 +893,7 @@ function getTransferSolWithSeedInstruction(input) {
986
893
  };
987
894
  const accounts = originalAccounts;
988
895
  const args = { ...input };
989
- const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
896
+ const getAccountMeta = getAccountMetaFactory(programAddress);
990
897
  const instruction = {
991
898
  accounts: [
992
899
  getAccountMeta(accounts.source),
@@ -1023,7 +930,7 @@ function parseTransferSolWithSeedInstruction(instruction) {
1023
930
  };
1024
931
  }
1025
932
  function getUpgradeNonceAccountInstructionDataEncoder() {
1026
- return mapEncoder(
933
+ return transformEncoder(
1027
934
  getStructEncoder([["discriminator", getU32Encoder()]]),
1028
935
  (value) => ({ ...value, discriminator: 12 })
1029
936
  );
@@ -1043,7 +950,7 @@ function getUpgradeNonceAccountInstruction(input) {
1043
950
  nonceAccount: { value: input.nonceAccount ?? null, isWritable: true }
1044
951
  };
1045
952
  const accounts = originalAccounts;
1046
- const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
953
+ const getAccountMeta = getAccountMetaFactory(programAddress);
1047
954
  const instruction = {
1048
955
  accounts: [getAccountMeta(accounts.nonceAccount)],
1049
956
  programAddress,
@@ -1072,7 +979,7 @@ function parseUpgradeNonceAccountInstruction(instruction) {
1072
979
  };
1073
980
  }
1074
981
  function getWithdrawNonceAccountInstructionDataEncoder() {
1075
- return mapEncoder(
982
+ return transformEncoder(
1076
983
  getStructEncoder([
1077
984
  ["discriminator", getU32Encoder()],
1078
985
  ["withdrawAmount", getU64Encoder()]
@@ -1115,7 +1022,7 @@ function getWithdrawNonceAccountInstruction(input) {
1115
1022
  if (!accounts.rentSysvar.value) {
1116
1023
  accounts.rentSysvar.value = "SysvarRent111111111111111111111111111111111";
1117
1024
  }
1118
- const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
1025
+ const getAccountMeta = getAccountMetaFactory(programAddress);
1119
1026
  const instruction = {
1120
1027
  accounts: [
1121
1028
  getAccountMeta(accounts.nonceAccount),
@@ -1156,6 +1063,6 @@ function parseWithdrawNonceAccountInstruction(instruction) {
1156
1063
  };
1157
1064
  }
1158
1065
 
1159
- export { NonceState, NonceVersion, SYSTEM_PROGRAM_ADDRESS, SystemAccount, SystemInstruction, SystemProgramError, SystemProgramErrorCode, decodeNonce, expectAddress, expectProgramDerivedAddress, expectSome, expectTransactionSigner, fetchAllMaybeNonce, fetchAllNonce, fetchMaybeNonce, fetchNonce, getAccountMetaFactory, getAdvanceNonceAccountInstruction, getAdvanceNonceAccountInstructionDataCodec, getAdvanceNonceAccountInstructionDataDecoder, getAdvanceNonceAccountInstructionDataEncoder, getAllocateInstruction, getAllocateInstructionDataCodec, getAllocateInstructionDataDecoder, getAllocateInstructionDataEncoder, getAllocateWithSeedInstruction, getAllocateWithSeedInstructionDataCodec, getAllocateWithSeedInstructionDataDecoder, getAllocateWithSeedInstructionDataEncoder, getAssignInstruction, getAssignInstructionDataCodec, getAssignInstructionDataDecoder, getAssignInstructionDataEncoder, getAssignWithSeedInstruction, getAssignWithSeedInstructionDataCodec, getAssignWithSeedInstructionDataDecoder, getAssignWithSeedInstructionDataEncoder, getAuthorizeNonceAccountInstruction, getAuthorizeNonceAccountInstructionDataCodec, getAuthorizeNonceAccountInstructionDataDecoder, getAuthorizeNonceAccountInstructionDataEncoder, getCreateAccountInstruction, getCreateAccountInstructionDataCodec, getCreateAccountInstructionDataDecoder, getCreateAccountInstructionDataEncoder, getCreateAccountWithSeedInstruction, getCreateAccountWithSeedInstructionDataCodec, getCreateAccountWithSeedInstructionDataDecoder, getCreateAccountWithSeedInstructionDataEncoder, getInitializeNonceAccountInstruction, getInitializeNonceAccountInstructionDataCodec, getInitializeNonceAccountInstructionDataDecoder, getInitializeNonceAccountInstructionDataEncoder, getNonceAccountDataCodec, getNonceAccountDataDecoder, getNonceAccountDataEncoder, getNonceSize, getNonceStateCodec, getNonceStateDecoder, getNonceStateEncoder, getNonceVersionCodec, getNonceVersionDecoder, getNonceVersionEncoder, getSystemProgram, getSystemProgramErrorFromCode, getTransferSolInstruction, getTransferSolInstructionDataCodec, getTransferSolInstructionDataDecoder, getTransferSolInstructionDataEncoder, getTransferSolWithSeedInstruction, getTransferSolWithSeedInstructionDataCodec, getTransferSolWithSeedInstructionDataDecoder, getTransferSolWithSeedInstructionDataEncoder, getUpgradeNonceAccountInstruction, getUpgradeNonceAccountInstructionDataCodec, getUpgradeNonceAccountInstructionDataDecoder, getUpgradeNonceAccountInstructionDataEncoder, getWithdrawNonceAccountInstruction, getWithdrawNonceAccountInstructionDataCodec, getWithdrawNonceAccountInstructionDataDecoder, getWithdrawNonceAccountInstructionDataEncoder, identifySystemInstruction, isTransactionSigner, memcmp, parseAdvanceNonceAccountInstruction, parseAllocateInstruction, parseAllocateWithSeedInstruction, parseAssignInstruction, parseAssignWithSeedInstruction, parseAuthorizeNonceAccountInstruction, parseCreateAccountInstruction, parseCreateAccountWithSeedInstruction, parseInitializeNonceAccountInstruction, parseTransferSolInstruction, parseTransferSolWithSeedInstruction, parseUpgradeNonceAccountInstruction, parseWithdrawNonceAccountInstruction };
1066
+ export { 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, decodeNonce, fetchAllMaybeNonce, fetchAllNonce, fetchMaybeNonce, fetchNonce, getAdvanceNonceAccountInstruction, getAdvanceNonceAccountInstructionDataCodec, getAdvanceNonceAccountInstructionDataDecoder, getAdvanceNonceAccountInstructionDataEncoder, getAllocateInstruction, getAllocateInstructionDataCodec, getAllocateInstructionDataDecoder, getAllocateInstructionDataEncoder, getAllocateWithSeedInstruction, getAllocateWithSeedInstructionDataCodec, getAllocateWithSeedInstructionDataDecoder, getAllocateWithSeedInstructionDataEncoder, getAssignInstruction, getAssignInstructionDataCodec, getAssignInstructionDataDecoder, getAssignInstructionDataEncoder, getAssignWithSeedInstruction, getAssignWithSeedInstructionDataCodec, getAssignWithSeedInstructionDataDecoder, getAssignWithSeedInstructionDataEncoder, getAuthorizeNonceAccountInstruction, getAuthorizeNonceAccountInstructionDataCodec, getAuthorizeNonceAccountInstructionDataDecoder, getAuthorizeNonceAccountInstructionDataEncoder, getCreateAccountInstruction, getCreateAccountInstructionDataCodec, getCreateAccountInstructionDataDecoder, getCreateAccountInstructionDataEncoder, getCreateAccountWithSeedInstruction, getCreateAccountWithSeedInstructionDataCodec, getCreateAccountWithSeedInstructionDataDecoder, getCreateAccountWithSeedInstructionDataEncoder, getInitializeNonceAccountInstruction, getInitializeNonceAccountInstructionDataCodec, getInitializeNonceAccountInstructionDataDecoder, getInitializeNonceAccountInstructionDataEncoder, getNonceCodec, getNonceDecoder, getNonceEncoder, getNonceSize, getNonceStateCodec, getNonceStateDecoder, getNonceStateEncoder, getNonceVersionCodec, getNonceVersionDecoder, getNonceVersionEncoder, getSystemErrorMessage, getTransferSolInstruction, getTransferSolInstructionDataCodec, getTransferSolInstructionDataDecoder, getTransferSolInstructionDataEncoder, getTransferSolWithSeedInstruction, getTransferSolWithSeedInstructionDataCodec, getTransferSolWithSeedInstructionDataDecoder, getTransferSolWithSeedInstructionDataEncoder, getUpgradeNonceAccountInstruction, getUpgradeNonceAccountInstructionDataCodec, getUpgradeNonceAccountInstructionDataDecoder, getUpgradeNonceAccountInstructionDataEncoder, getWithdrawNonceAccountInstruction, getWithdrawNonceAccountInstructionDataCodec, getWithdrawNonceAccountInstructionDataDecoder, getWithdrawNonceAccountInstructionDataEncoder, identifySystemInstruction, parseAdvanceNonceAccountInstruction, parseAllocateInstruction, parseAllocateWithSeedInstruction, parseAssignInstruction, parseAssignWithSeedInstruction, parseAuthorizeNonceAccountInstruction, parseCreateAccountInstruction, parseCreateAccountWithSeedInstruction, parseInitializeNonceAccountInstruction, parseTransferSolInstruction, parseTransferSolWithSeedInstruction, parseUpgradeNonceAccountInstruction, parseWithdrawNonceAccountInstruction };
1160
1067
  //# sourceMappingURL=out.js.map
1161
1068
  //# sourceMappingURL=index.js.map