@solana-program/system 0.3.3 → 0.4.1

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 (50) hide show
  1. package/README.md +1 -2
  2. package/dist/src/index.js +51 -43
  3. package/dist/src/index.js.map +1 -1
  4. package/dist/src/index.mjs +52 -45
  5. package/dist/src/index.mjs.map +1 -1
  6. package/dist/types/generated/accounts/index.d.ts +1 -1
  7. package/dist/types/generated/accounts/nonce.d.ts +3 -3
  8. package/dist/types/generated/accounts/nonce.d.ts.map +1 -1
  9. package/dist/types/generated/errors/index.d.ts +1 -1
  10. package/dist/types/generated/errors/system.d.ts +11 -1
  11. package/dist/types/generated/errors/system.d.ts.map +1 -1
  12. package/dist/types/generated/index.d.ts +1 -1
  13. package/dist/types/generated/instructions/advanceNonceAccount.d.ts +2 -2
  14. package/dist/types/generated/instructions/advanceNonceAccount.d.ts.map +1 -1
  15. package/dist/types/generated/instructions/allocate.d.ts +2 -2
  16. package/dist/types/generated/instructions/allocate.d.ts.map +1 -1
  17. package/dist/types/generated/instructions/allocateWithSeed.d.ts +2 -2
  18. package/dist/types/generated/instructions/allocateWithSeed.d.ts.map +1 -1
  19. package/dist/types/generated/instructions/assign.d.ts +2 -2
  20. package/dist/types/generated/instructions/assign.d.ts.map +1 -1
  21. package/dist/types/generated/instructions/assignWithSeed.d.ts +2 -2
  22. package/dist/types/generated/instructions/assignWithSeed.d.ts.map +1 -1
  23. package/dist/types/generated/instructions/authorizeNonceAccount.d.ts +2 -2
  24. package/dist/types/generated/instructions/authorizeNonceAccount.d.ts.map +1 -1
  25. package/dist/types/generated/instructions/createAccount.d.ts +3 -3
  26. package/dist/types/generated/instructions/createAccount.d.ts.map +1 -1
  27. package/dist/types/generated/instructions/createAccountWithSeed.d.ts +2 -2
  28. package/dist/types/generated/instructions/createAccountWithSeed.d.ts.map +1 -1
  29. package/dist/types/generated/instructions/index.d.ts +1 -1
  30. package/dist/types/generated/instructions/initializeNonceAccount.d.ts +2 -2
  31. package/dist/types/generated/instructions/initializeNonceAccount.d.ts.map +1 -1
  32. package/dist/types/generated/instructions/transferSol.d.ts +2 -2
  33. package/dist/types/generated/instructions/transferSol.d.ts.map +1 -1
  34. package/dist/types/generated/instructions/transferSolWithSeed.d.ts +2 -2
  35. package/dist/types/generated/instructions/transferSolWithSeed.d.ts.map +1 -1
  36. package/dist/types/generated/instructions/upgradeNonceAccount.d.ts +2 -2
  37. package/dist/types/generated/instructions/upgradeNonceAccount.d.ts.map +1 -1
  38. package/dist/types/generated/instructions/withdrawNonceAccount.d.ts +2 -2
  39. package/dist/types/generated/instructions/withdrawNonceAccount.d.ts.map +1 -1
  40. package/dist/types/generated/programs/index.d.ts +1 -1
  41. package/dist/types/generated/programs/system.d.ts +5 -5
  42. package/dist/types/generated/programs/system.d.ts.map +1 -1
  43. package/dist/types/generated/shared/index.d.ts +2 -2
  44. package/dist/types/generated/shared/index.d.ts.map +1 -1
  45. package/dist/types/generated/types/index.d.ts +1 -1
  46. package/dist/types/generated/types/nonceState.d.ts +2 -2
  47. package/dist/types/generated/types/nonceState.d.ts.map +1 -1
  48. package/dist/types/generated/types/nonceVersion.d.ts +2 -2
  49. package/dist/types/generated/types/nonceVersion.d.ts.map +1 -1
  50. package/package.json +15 -11
package/README.md CHANGED
@@ -17,8 +17,7 @@ This will start a new local validator, if one is not already running, and run th
17
17
  Alternatively, you can go into the client directory and run the tests directly.
18
18
 
19
19
  ```sh
20
- # Build your programs and start the validator.
21
- pnpm programs:build
20
+ # Start the validator.
22
21
  pnpm validator:restart
23
22
 
24
23
  # Go into the client directory and run the tests.
package/dist/src/index.js CHANGED
@@ -2,12 +2,11 @@
2
2
 
3
3
  var web3_js = require('@solana/web3.js');
4
4
 
5
- // env-shim.ts
6
- var __DEV__ = /* @__PURE__ */ (() => process["env"].NODE_ENV === "development")();
7
- var NonceState = /* @__PURE__ */ ((NonceState3) => {
8
- NonceState3[NonceState3["Uninitialized"] = 0] = "Uninitialized";
9
- NonceState3[NonceState3["Initialized"] = 1] = "Initialized";
10
- return NonceState3;
5
+ // src/generated/accounts/nonce.ts
6
+ var NonceState = /* @__PURE__ */ ((NonceState2) => {
7
+ NonceState2[NonceState2["Uninitialized"] = 0] = "Uninitialized";
8
+ NonceState2[NonceState2["Initialized"] = 1] = "Initialized";
9
+ return NonceState2;
11
10
  })(NonceState || {});
12
11
  function getNonceStateEncoder() {
13
12
  return web3_js.getEnumEncoder(NonceState, { size: web3_js.getU32Encoder() });
@@ -18,10 +17,10 @@ function getNonceStateDecoder() {
18
17
  function getNonceStateCodec() {
19
18
  return web3_js.combineCodec(getNonceStateEncoder(), getNonceStateDecoder());
20
19
  }
21
- var NonceVersion = /* @__PURE__ */ ((NonceVersion3) => {
22
- NonceVersion3[NonceVersion3["Legacy"] = 0] = "Legacy";
23
- NonceVersion3[NonceVersion3["Current"] = 1] = "Current";
24
- return NonceVersion3;
20
+ var NonceVersion = /* @__PURE__ */ ((NonceVersion2) => {
21
+ NonceVersion2[NonceVersion2["Legacy"] = 0] = "Legacy";
22
+ NonceVersion2[NonceVersion2["Current"] = 1] = "Current";
23
+ return NonceVersion2;
25
24
  })(NonceVersion || {});
26
25
  function getNonceVersionEncoder() {
27
26
  return web3_js.getEnumEncoder(NonceVersion, { size: web3_js.getU32Encoder() });
@@ -82,37 +81,6 @@ async function fetchAllMaybeNonce(rpc, addresses, config) {
82
81
  function getNonceSize() {
83
82
  return 80;
84
83
  }
85
-
86
- // src/generated/errors/system.ts
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;
97
- if (__DEV__) {
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`
108
- };
109
- }
110
- function getSystemErrorMessage(code) {
111
- if (__DEV__) {
112
- return systemErrorMessages[code];
113
- }
114
- return "Error message not available in production bundles. Compile with `__DEV__` set to true to see more information.";
115
- }
116
84
  var SYSTEM_PROGRAM_ADDRESS = "11111111111111111111111111111111";
117
85
  var SystemAccount = /* @__PURE__ */ ((SystemAccount2) => {
118
86
  SystemAccount2[SystemAccount2["Nonce"] = 0] = "Nonce";
@@ -135,7 +103,7 @@ var SystemInstruction = /* @__PURE__ */ ((SystemInstruction2) => {
135
103
  return SystemInstruction2;
136
104
  })(SystemInstruction || {});
137
105
  function identifySystemInstruction(instruction) {
138
- const data = instruction instanceof Uint8Array ? instruction : instruction.data;
106
+ const data = "data" in instruction ? instruction.data : instruction;
139
107
  if (web3_js.containsBytes(data, web3_js.getU32Encoder().encode(0), 0)) {
140
108
  return 0 /* CreateAccount */;
141
109
  }
@@ -179,6 +147,45 @@ function identifySystemInstruction(instruction) {
179
147
  "The provided instruction could not be identified as a system instruction."
180
148
  );
181
149
  }
150
+
151
+ // src/generated/errors/system.ts
152
+ var SYSTEM_ERROR__ACCOUNT_ALREADY_IN_USE = 0;
153
+ var SYSTEM_ERROR__RESULT_WITH_NEGATIVE_LAMPORTS = 1;
154
+ var SYSTEM_ERROR__INVALID_PROGRAM_ID = 2;
155
+ var SYSTEM_ERROR__INVALID_ACCOUNT_DATA_LENGTH = 3;
156
+ var SYSTEM_ERROR__MAX_SEED_LENGTH_EXCEEDED = 4;
157
+ var SYSTEM_ERROR__ADDRESS_WITH_SEED_MISMATCH = 5;
158
+ var SYSTEM_ERROR__NONCE_NO_RECENT_BLOCKHASHES = 6;
159
+ var SYSTEM_ERROR__NONCE_BLOCKHASH_NOT_EXPIRED = 7;
160
+ var SYSTEM_ERROR__NONCE_UNEXPECTED_BLOCKHASH_VALUE = 8;
161
+ var systemErrorMessages;
162
+ if (process.env.NODE_ENV !== "production") {
163
+ systemErrorMessages = {
164
+ [SYSTEM_ERROR__ACCOUNT_ALREADY_IN_USE]: `an account with the same address already exists`,
165
+ [SYSTEM_ERROR__ADDRESS_WITH_SEED_MISMATCH]: `provided address does not match addressed derived from seed`,
166
+ [SYSTEM_ERROR__INVALID_ACCOUNT_DATA_LENGTH]: `cannot allocate account data of this length`,
167
+ [SYSTEM_ERROR__INVALID_PROGRAM_ID]: `cannot assign account to this program id`,
168
+ [SYSTEM_ERROR__MAX_SEED_LENGTH_EXCEEDED]: `length of requested seed is too long`,
169
+ [SYSTEM_ERROR__NONCE_BLOCKHASH_NOT_EXPIRED]: `stored nonce is still in recent_blockhashes`,
170
+ [SYSTEM_ERROR__NONCE_NO_RECENT_BLOCKHASHES]: `advancing stored nonce requires a populated RecentBlockhashes sysvar`,
171
+ [SYSTEM_ERROR__NONCE_UNEXPECTED_BLOCKHASH_VALUE]: `specified nonce does not match stored nonce`,
172
+ [SYSTEM_ERROR__RESULT_WITH_NEGATIVE_LAMPORTS]: `account does not have enough SOL to perform the operation`
173
+ };
174
+ }
175
+ function getSystemErrorMessage(code) {
176
+ if (process.env.NODE_ENV !== "production") {
177
+ return systemErrorMessages[code];
178
+ }
179
+ return "Error message not available in production bundles.";
180
+ }
181
+ function isSystemError(error, transactionMessage, code) {
182
+ return web3_js.isProgramError(
183
+ error,
184
+ transactionMessage,
185
+ SYSTEM_PROGRAM_ADDRESS,
186
+ code
187
+ );
188
+ }
182
189
  function expectAddress(value) {
183
190
  if (!value) {
184
191
  throw new Error("Expected a Address.");
@@ -1148,6 +1155,7 @@ exports.getWithdrawNonceAccountInstructionDataCodec = getWithdrawNonceAccountIns
1148
1155
  exports.getWithdrawNonceAccountInstructionDataDecoder = getWithdrawNonceAccountInstructionDataDecoder;
1149
1156
  exports.getWithdrawNonceAccountInstructionDataEncoder = getWithdrawNonceAccountInstructionDataEncoder;
1150
1157
  exports.identifySystemInstruction = identifySystemInstruction;
1158
+ exports.isSystemError = isSystemError;
1151
1159
  exports.parseAdvanceNonceAccountInstruction = parseAdvanceNonceAccountInstruction;
1152
1160
  exports.parseAllocateInstruction = parseAllocateInstruction;
1153
1161
  exports.parseAllocateWithSeedInstruction = parseAllocateWithSeedInstruction;
@@ -1161,5 +1169,5 @@ exports.parseTransferSolInstruction = parseTransferSolInstruction;
1161
1169
  exports.parseTransferSolWithSeedInstruction = parseTransferSolWithSeedInstruction;
1162
1170
  exports.parseUpgradeNonceAccountInstruction = parseUpgradeNonceAccountInstruction;
1163
1171
  exports.parseWithdrawNonceAccountInstruction = parseWithdrawNonceAccountInstruction;
1164
- //# sourceMappingURL=out.js.map
1172
+ //# sourceMappingURL=index.js.map
1165
1173
  //# sourceMappingURL=index.js.map