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