@solana-program/system 0.4.0 → 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.
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
@@ -81,37 +81,6 @@ async function fetchAllMaybeNonce(rpc, addresses, config) {
81
81
  function getNonceSize() {
82
82
  return 80;
83
83
  }
84
-
85
- // src/generated/errors/system.ts
86
- var SYSTEM_ERROR__ACCOUNT_ALREADY_IN_USE = 0;
87
- var SYSTEM_ERROR__RESULT_WITH_NEGATIVE_LAMPORTS = 1;
88
- var SYSTEM_ERROR__INVALID_PROGRAM_ID = 2;
89
- var SYSTEM_ERROR__INVALID_ACCOUNT_DATA_LENGTH = 3;
90
- var SYSTEM_ERROR__MAX_SEED_LENGTH_EXCEEDED = 4;
91
- var SYSTEM_ERROR__ADDRESS_WITH_SEED_MISMATCH = 5;
92
- var SYSTEM_ERROR__NONCE_NO_RECENT_BLOCKHASHES = 6;
93
- var SYSTEM_ERROR__NONCE_BLOCKHASH_NOT_EXPIRED = 7;
94
- var SYSTEM_ERROR__NONCE_UNEXPECTED_BLOCKHASH_VALUE = 8;
95
- var systemErrorMessages;
96
- if (process.env.NODE_ENV !== "production") {
97
- systemErrorMessages = {
98
- [SYSTEM_ERROR__ACCOUNT_ALREADY_IN_USE]: `an account with the same address already exists`,
99
- [SYSTEM_ERROR__ADDRESS_WITH_SEED_MISMATCH]: `provided address does not match addressed derived from seed`,
100
- [SYSTEM_ERROR__INVALID_ACCOUNT_DATA_LENGTH]: `cannot allocate account data of this length`,
101
- [SYSTEM_ERROR__INVALID_PROGRAM_ID]: `cannot assign account to this program id`,
102
- [SYSTEM_ERROR__MAX_SEED_LENGTH_EXCEEDED]: `length of requested seed is too long`,
103
- [SYSTEM_ERROR__NONCE_BLOCKHASH_NOT_EXPIRED]: `stored nonce is still in recent_blockhashes`,
104
- [SYSTEM_ERROR__NONCE_NO_RECENT_BLOCKHASHES]: `advancing stored nonce requires a populated RecentBlockhashes sysvar`,
105
- [SYSTEM_ERROR__NONCE_UNEXPECTED_BLOCKHASH_VALUE]: `specified nonce does not match stored nonce`,
106
- [SYSTEM_ERROR__RESULT_WITH_NEGATIVE_LAMPORTS]: `account does not have enough SOL to perform the operation`
107
- };
108
- }
109
- function getSystemErrorMessage(code) {
110
- if (process.env.NODE_ENV !== "production") {
111
- return systemErrorMessages[code];
112
- }
113
- return "Error message not available in production bundles.";
114
- }
115
84
  var SYSTEM_PROGRAM_ADDRESS = "11111111111111111111111111111111";
116
85
  var SystemAccount = /* @__PURE__ */ ((SystemAccount2) => {
117
86
  SystemAccount2[SystemAccount2["Nonce"] = 0] = "Nonce";
@@ -134,7 +103,7 @@ var SystemInstruction = /* @__PURE__ */ ((SystemInstruction2) => {
134
103
  return SystemInstruction2;
135
104
  })(SystemInstruction || {});
136
105
  function identifySystemInstruction(instruction) {
137
- const data = instruction instanceof Uint8Array ? instruction : instruction.data;
106
+ const data = "data" in instruction ? instruction.data : instruction;
138
107
  if (web3_js.containsBytes(data, web3_js.getU32Encoder().encode(0), 0)) {
139
108
  return 0 /* CreateAccount */;
140
109
  }
@@ -178,6 +147,45 @@ function identifySystemInstruction(instruction) {
178
147
  "The provided instruction could not be identified as a system instruction."
179
148
  );
180
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
+ }
181
189
  function expectAddress(value) {
182
190
  if (!value) {
183
191
  throw new Error("Expected a Address.");
@@ -1147,6 +1155,7 @@ exports.getWithdrawNonceAccountInstructionDataCodec = getWithdrawNonceAccountIns
1147
1155
  exports.getWithdrawNonceAccountInstructionDataDecoder = getWithdrawNonceAccountInstructionDataDecoder;
1148
1156
  exports.getWithdrawNonceAccountInstructionDataEncoder = getWithdrawNonceAccountInstructionDataEncoder;
1149
1157
  exports.identifySystemInstruction = identifySystemInstruction;
1158
+ exports.isSystemError = isSystemError;
1150
1159
  exports.parseAdvanceNonceAccountInstruction = parseAdvanceNonceAccountInstruction;
1151
1160
  exports.parseAllocateInstruction = parseAllocateInstruction;
1152
1161
  exports.parseAllocateWithSeedInstruction = parseAllocateWithSeedInstruction;
@@ -1160,5 +1169,5 @@ exports.parseTransferSolInstruction = parseTransferSolInstruction;
1160
1169
  exports.parseTransferSolWithSeedInstruction = parseTransferSolWithSeedInstruction;
1161
1170
  exports.parseUpgradeNonceAccountInstruction = parseUpgradeNonceAccountInstruction;
1162
1171
  exports.parseWithdrawNonceAccountInstruction = parseWithdrawNonceAccountInstruction;
1163
- //# sourceMappingURL=out.js.map
1172
+ //# sourceMappingURL=index.js.map
1164
1173
  //# sourceMappingURL=index.js.map