@solana-program/token-wrap 2.2.0 → 2.4.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/dist/src/index.js +206 -282
- package/dist/src/index.js.map +1 -1
- package/dist/src/index.mjs +207 -284
- package/dist/src/index.mjs.map +1 -1
- package/dist/types/{generated → src/generated}/accounts/backpointer.d.ts +6 -2
- package/dist/types/{generated → src/generated}/accounts/index.d.ts +2 -2
- package/dist/types/{generated → src/generated}/errors/index.d.ts +2 -2
- package/dist/types/{generated → src/generated}/errors/tokenWrap.d.ts +2 -2
- package/dist/types/{generated → src/generated}/index.d.ts +2 -2
- package/dist/types/{generated → src/generated}/instructions/closeStuckEscrow.d.ts +3 -3
- package/dist/types/{generated → src/generated}/instructions/createMint.d.ts +3 -3
- package/dist/types/{generated → src/generated}/instructions/index.d.ts +2 -2
- package/dist/types/{generated → src/generated}/instructions/syncMetadataToSplToken.d.ts +3 -3
- package/dist/types/{generated → src/generated}/instructions/syncMetadataToToken2022.d.ts +3 -3
- package/dist/types/{generated → src/generated}/instructions/unwrap.d.ts +3 -3
- package/dist/types/{generated → src/generated}/instructions/wrap.d.ts +3 -3
- package/dist/types/{generated → src/generated}/pdas/backpointer.d.ts +2 -2
- package/dist/types/{generated → src/generated}/pdas/index.d.ts +2 -2
- package/dist/types/{generated → src/generated}/pdas/wrappedMint.d.ts +2 -2
- package/dist/types/{generated → src/generated}/pdas/wrappedMintAuthority.d.ts +2 -2
- package/dist/types/{generated → src/generated}/programs/index.d.ts +2 -2
- package/dist/types/{generated → src/generated}/programs/tokenWrap.d.ts +4 -3
- package/dist/types/{generated → src/generated}/shared/index.d.ts +2 -2
- package/dist/types/{unwrap.d.ts → src/unwrap.d.ts} +1 -2
- package/dist/types/{utilities.d.ts → src/utilities.d.ts} +1 -3
- package/dist/types/{wrap.d.ts → src/wrap.d.ts} +1 -2
- package/dist/types/tsup.config.d.ts +3 -0
- package/package.json +16 -18
- /package/dist/types/{create-mint.d.ts → src/create-mint.d.ts} +0 -0
- /package/dist/types/{examples → src/examples}/multisig.d.ts +0 -0
- /package/dist/types/{examples → src/examples}/single-signer.d.ts +0 -0
- /package/dist/types/{examples → src/examples}/sync-spl-to-token2022.d.ts +0 -0
- /package/dist/types/{examples → src/examples}/sync-token2022-to-spl.d.ts +0 -0
- /package/dist/types/{index.d.ts → src/index.d.ts} +0 -0
package/dist/src/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getProgramDerivedAddress, getUtf8Encoder, getAddressEncoder, getStructEncoder, getStructDecoder, getAddressDecoder, combineCodec, decodeAccount, assertAccountExists, fetchEncodedAccount, assertAccountsExist, fetchEncodedAccounts,
|
|
1
|
+
import { getProgramDerivedAddress, getUtf8Encoder, getAddressEncoder, getStructEncoder, getStructDecoder, getAddressDecoder, combineCodec, decodeAccount, assertAccountExists, fetchEncodedAccount, assertAccountsExist, fetchEncodedAccounts, getU8Encoder, transformEncoder, getU8Decoder, getBooleanEncoder, getBooleanDecoder, getU64Encoder, getU64Decoder, AccountRole, containsBytes, assertIsInstructionWithAccounts, isProgramError, assertIsFullySignedTransaction, assertIsSendableTransaction, pipe, createTransactionMessage, setTransactionMessageFeePayerSigner, setTransactionMessageLifetimeUsingBlockhash, appendTransactionMessageInstructions, upgradeRoleToSigner, isTransactionSigner as isTransactionSigner$1 } from '@solana/kit';
|
|
2
2
|
import { extension, getMintSize, TOKEN_2022_PROGRAM_ADDRESS, findAssociatedTokenPda, fetchMaybeToken, getCreateAssociatedTokenInstruction, getTokenDecoder } from '@solana-program/token-2022';
|
|
3
3
|
import { getTransferSolInstruction } from '@solana-program/system';
|
|
4
4
|
import '@solana-program/token';
|
|
@@ -10,10 +10,7 @@ async function findBackpointerPda(seeds, config = {}) {
|
|
|
10
10
|
} = config;
|
|
11
11
|
return await getProgramDerivedAddress({
|
|
12
12
|
programAddress,
|
|
13
|
-
seeds: [
|
|
14
|
-
getUtf8Encoder().encode("backpointer"),
|
|
15
|
-
getAddressEncoder().encode(seeds.wrappedMint)
|
|
16
|
-
]
|
|
13
|
+
seeds: [getUtf8Encoder().encode("backpointer"), getAddressEncoder().encode(seeds.wrappedMint)]
|
|
17
14
|
});
|
|
18
15
|
}
|
|
19
16
|
async function findWrappedMintPda(seeds, config = {}) {
|
|
@@ -35,10 +32,7 @@ async function findWrappedMintAuthorityPda(seeds, config = {}) {
|
|
|
35
32
|
} = config;
|
|
36
33
|
return await getProgramDerivedAddress({
|
|
37
34
|
programAddress,
|
|
38
|
-
seeds: [
|
|
39
|
-
getUtf8Encoder().encode("authority"),
|
|
40
|
-
getAddressEncoder().encode(seeds.wrappedMint)
|
|
41
|
-
]
|
|
35
|
+
seeds: [getUtf8Encoder().encode("authority"), getAddressEncoder().encode(seeds.wrappedMint)]
|
|
42
36
|
});
|
|
43
37
|
}
|
|
44
38
|
|
|
@@ -53,10 +47,7 @@ function getBackpointerCodec() {
|
|
|
53
47
|
return combineCodec(getBackpointerEncoder(), getBackpointerDecoder());
|
|
54
48
|
}
|
|
55
49
|
function decodeBackpointer(encodedAccount) {
|
|
56
|
-
return decodeAccount(
|
|
57
|
-
encodedAccount,
|
|
58
|
-
getBackpointerDecoder()
|
|
59
|
-
);
|
|
50
|
+
return decodeAccount(encodedAccount, getBackpointerDecoder());
|
|
60
51
|
}
|
|
61
52
|
async function fetchBackpointer(rpc, address, config) {
|
|
62
53
|
const maybeAccount = await fetchMaybeBackpointer(rpc, address, config);
|
|
@@ -89,97 +80,6 @@ async function fetchMaybeBackpointerFromSeeds(rpc, seeds, config = {}) {
|
|
|
89
80
|
const [address] = await findBackpointerPda(seeds, { programAddress });
|
|
90
81
|
return await fetchMaybeBackpointer(rpc, address, fetchConfig);
|
|
91
82
|
}
|
|
92
|
-
var TOKEN_WRAP_PROGRAM_ADDRESS = "TwRapQCDhWkZRrDaHfZGuHxkZ91gHDRkyuzNqeU5MgR";
|
|
93
|
-
var TokenWrapAccount = /* @__PURE__ */ ((TokenWrapAccount2) => {
|
|
94
|
-
TokenWrapAccount2[TokenWrapAccount2["Backpointer"] = 0] = "Backpointer";
|
|
95
|
-
return TokenWrapAccount2;
|
|
96
|
-
})(TokenWrapAccount || {});
|
|
97
|
-
var TokenWrapInstruction = /* @__PURE__ */ ((TokenWrapInstruction2) => {
|
|
98
|
-
TokenWrapInstruction2[TokenWrapInstruction2["CreateMint"] = 0] = "CreateMint";
|
|
99
|
-
TokenWrapInstruction2[TokenWrapInstruction2["Wrap"] = 1] = "Wrap";
|
|
100
|
-
TokenWrapInstruction2[TokenWrapInstruction2["Unwrap"] = 2] = "Unwrap";
|
|
101
|
-
TokenWrapInstruction2[TokenWrapInstruction2["CloseStuckEscrow"] = 3] = "CloseStuckEscrow";
|
|
102
|
-
TokenWrapInstruction2[TokenWrapInstruction2["SyncMetadataToToken2022"] = 4] = "SyncMetadataToToken2022";
|
|
103
|
-
TokenWrapInstruction2[TokenWrapInstruction2["SyncMetadataToSplToken"] = 5] = "SyncMetadataToSplToken";
|
|
104
|
-
return TokenWrapInstruction2;
|
|
105
|
-
})(TokenWrapInstruction || {});
|
|
106
|
-
function identifyTokenWrapInstruction(instruction) {
|
|
107
|
-
const data = "data" in instruction ? instruction.data : instruction;
|
|
108
|
-
if (containsBytes(data, getU8Encoder().encode(0), 0)) {
|
|
109
|
-
return 0 /* CreateMint */;
|
|
110
|
-
}
|
|
111
|
-
if (containsBytes(data, getU8Encoder().encode(1), 0)) {
|
|
112
|
-
return 1 /* Wrap */;
|
|
113
|
-
}
|
|
114
|
-
if (containsBytes(data, getU8Encoder().encode(2), 0)) {
|
|
115
|
-
return 2 /* Unwrap */;
|
|
116
|
-
}
|
|
117
|
-
if (containsBytes(data, getU8Encoder().encode(3), 0)) {
|
|
118
|
-
return 3 /* CloseStuckEscrow */;
|
|
119
|
-
}
|
|
120
|
-
if (containsBytes(data, getU8Encoder().encode(4), 0)) {
|
|
121
|
-
return 4 /* SyncMetadataToToken2022 */;
|
|
122
|
-
}
|
|
123
|
-
if (containsBytes(data, getU8Encoder().encode(5), 0)) {
|
|
124
|
-
return 5 /* SyncMetadataToSplToken */;
|
|
125
|
-
}
|
|
126
|
-
throw new Error(
|
|
127
|
-
"The provided instruction could not be identified as a tokenWrap instruction."
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// src/generated/errors/tokenWrap.ts
|
|
132
|
-
var TOKEN_WRAP_ERROR__WRAPPED_MINT_MISMATCH = 0;
|
|
133
|
-
var TOKEN_WRAP_ERROR__BACKPOINTER_MISMATCH = 1;
|
|
134
|
-
var TOKEN_WRAP_ERROR__ZERO_WRAP_AMOUNT = 2;
|
|
135
|
-
var TOKEN_WRAP_ERROR__MINT_AUTHORITY_MISMATCH = 3;
|
|
136
|
-
var TOKEN_WRAP_ERROR__ESCROW_OWNER_MISMATCH = 4;
|
|
137
|
-
var TOKEN_WRAP_ERROR__INVALID_WRAPPED_MINT_OWNER = 5;
|
|
138
|
-
var TOKEN_WRAP_ERROR__INVALID_BACKPOINTER_OWNER = 6;
|
|
139
|
-
var TOKEN_WRAP_ERROR__ESCROW_MISMATCH = 7;
|
|
140
|
-
var TOKEN_WRAP_ERROR__ESCROW_IN_GOOD_STATE = 8;
|
|
141
|
-
var TOKEN_WRAP_ERROR__UNWRAPPED_MINT_HAS_NO_METADATA = 9;
|
|
142
|
-
var TOKEN_WRAP_ERROR__METAPLEX_METADATA_MISMATCH = 10;
|
|
143
|
-
var TOKEN_WRAP_ERROR__METADATA_POINTER_MISSING = 11;
|
|
144
|
-
var TOKEN_WRAP_ERROR__METADATA_POINTER_UNSET = 12;
|
|
145
|
-
var TOKEN_WRAP_ERROR__METADATA_POINTER_MISMATCH = 13;
|
|
146
|
-
var TOKEN_WRAP_ERROR__EXTERNAL_PROGRAM_RETURNED_NO_DATA = 14;
|
|
147
|
-
var TOKEN_WRAP_ERROR__NO_SYNCING_TO_TOKEN2022 = 15;
|
|
148
|
-
var tokenWrapErrorMessages;
|
|
149
|
-
if (process.env.NODE_ENV !== "production") {
|
|
150
|
-
tokenWrapErrorMessages = {
|
|
151
|
-
[TOKEN_WRAP_ERROR__BACKPOINTER_MISMATCH]: `Wrapped backpointer account address does not match expected PDA`,
|
|
152
|
-
[TOKEN_WRAP_ERROR__ESCROW_IN_GOOD_STATE]: `The escrow account is in a good state and cannot be recreated`,
|
|
153
|
-
[TOKEN_WRAP_ERROR__ESCROW_MISMATCH]: `Escrow account address does not match expected ATA`,
|
|
154
|
-
[TOKEN_WRAP_ERROR__ESCROW_OWNER_MISMATCH]: `Unwrapped escrow token owner is not set to expected PDA`,
|
|
155
|
-
[TOKEN_WRAP_ERROR__EXTERNAL_PROGRAM_RETURNED_NO_DATA]: `External metadata program returned no data`,
|
|
156
|
-
[TOKEN_WRAP_ERROR__INVALID_BACKPOINTER_OWNER]: `Wrapped backpointer account owner is not the expected token wrap program`,
|
|
157
|
-
[TOKEN_WRAP_ERROR__INVALID_WRAPPED_MINT_OWNER]: `Wrapped mint account owner is not the expected token program`,
|
|
158
|
-
[TOKEN_WRAP_ERROR__METADATA_POINTER_MISMATCH]: `Provided source metadata account does not match pointer`,
|
|
159
|
-
[TOKEN_WRAP_ERROR__METADATA_POINTER_MISSING]: `Metadata pointer extension missing on mint`,
|
|
160
|
-
[TOKEN_WRAP_ERROR__METADATA_POINTER_UNSET]: `Metadata pointer is unset (None)`,
|
|
161
|
-
[TOKEN_WRAP_ERROR__METAPLEX_METADATA_MISMATCH]: `Metaplex metadata account address does not match expected PDA`,
|
|
162
|
-
[TOKEN_WRAP_ERROR__MINT_AUTHORITY_MISMATCH]: `Wrapped mint authority does not match expected PDA`,
|
|
163
|
-
[TOKEN_WRAP_ERROR__NO_SYNCING_TO_TOKEN2022]: `Instruction can only be used with spl-token wrapped mints`,
|
|
164
|
-
[TOKEN_WRAP_ERROR__UNWRAPPED_MINT_HAS_NO_METADATA]: `Unwrapped mint does not have the TokenMetadata extension`,
|
|
165
|
-
[TOKEN_WRAP_ERROR__WRAPPED_MINT_MISMATCH]: `Wrapped mint account address does not match expected PDA`,
|
|
166
|
-
[TOKEN_WRAP_ERROR__ZERO_WRAP_AMOUNT]: `Wrap amount should be positive`
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
function getTokenWrapErrorMessage(code) {
|
|
170
|
-
if (process.env.NODE_ENV !== "production") {
|
|
171
|
-
return tokenWrapErrorMessages[code];
|
|
172
|
-
}
|
|
173
|
-
return "Error message not available in production bundles.";
|
|
174
|
-
}
|
|
175
|
-
function isTokenWrapError(error, transactionMessage, code) {
|
|
176
|
-
return isProgramError(
|
|
177
|
-
error,
|
|
178
|
-
transactionMessage,
|
|
179
|
-
TOKEN_WRAP_PROGRAM_ADDRESS,
|
|
180
|
-
code
|
|
181
|
-
);
|
|
182
|
-
}
|
|
183
83
|
function expectAddress(value) {
|
|
184
84
|
if (!value) {
|
|
185
85
|
throw new Error("Expected a Address.");
|
|
@@ -195,10 +95,7 @@ function expectAddress(value) {
|
|
|
195
95
|
function getAccountMetaFactory(programAddress, optionalAccountStrategy) {
|
|
196
96
|
return (account) => {
|
|
197
97
|
if (!account.value) {
|
|
198
|
-
return Object.freeze({
|
|
199
|
-
address: programAddress,
|
|
200
|
-
role: AccountRole.READONLY
|
|
201
|
-
});
|
|
98
|
+
return Object.freeze({ address: programAddress, role: AccountRole.READONLY });
|
|
202
99
|
}
|
|
203
100
|
const writableRole = account.isWritable ? AccountRole.WRITABLE : AccountRole.READONLY;
|
|
204
101
|
return Object.freeze({
|
|
@@ -218,19 +115,16 @@ function getCloseStuckEscrowDiscriminatorBytes() {
|
|
|
218
115
|
return getU8Encoder().encode(CLOSE_STUCK_ESCROW_DISCRIMINATOR);
|
|
219
116
|
}
|
|
220
117
|
function getCloseStuckEscrowInstructionDataEncoder() {
|
|
221
|
-
return transformEncoder(
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
);
|
|
118
|
+
return transformEncoder(getStructEncoder([["discriminator", getU8Encoder()]]), (value) => ({
|
|
119
|
+
...value,
|
|
120
|
+
discriminator: CLOSE_STUCK_ESCROW_DISCRIMINATOR
|
|
121
|
+
}));
|
|
225
122
|
}
|
|
226
123
|
function getCloseStuckEscrowInstructionDataDecoder() {
|
|
227
124
|
return getStructDecoder([["discriminator", getU8Decoder()]]);
|
|
228
125
|
}
|
|
229
126
|
function getCloseStuckEscrowInstructionDataCodec() {
|
|
230
|
-
return combineCodec(
|
|
231
|
-
getCloseStuckEscrowInstructionDataEncoder(),
|
|
232
|
-
getCloseStuckEscrowInstructionDataDecoder()
|
|
233
|
-
);
|
|
127
|
+
return combineCodec(getCloseStuckEscrowInstructionDataEncoder(), getCloseStuckEscrowInstructionDataDecoder());
|
|
234
128
|
}
|
|
235
129
|
function getCloseStuckEscrowInstruction(input, config) {
|
|
236
130
|
const programAddress = config?.programAddress ?? TOKEN_WRAP_PROGRAM_ADDRESS;
|
|
@@ -239,21 +133,15 @@ function getCloseStuckEscrowInstruction(input, config) {
|
|
|
239
133
|
destination: { value: input.destination ?? null, isWritable: true },
|
|
240
134
|
unwrappedMint: { value: input.unwrappedMint ?? null, isWritable: false },
|
|
241
135
|
wrappedMint: { value: input.wrappedMint ?? null, isWritable: false },
|
|
242
|
-
wrappedMintAuthority: {
|
|
243
|
-
|
|
244
|
-
isWritable: false
|
|
245
|
-
},
|
|
246
|
-
token2022Program: {
|
|
247
|
-
value: input.token2022Program ?? null,
|
|
248
|
-
isWritable: false
|
|
249
|
-
}
|
|
136
|
+
wrappedMintAuthority: { value: input.wrappedMintAuthority ?? null, isWritable: false },
|
|
137
|
+
token2022Program: { value: input.token2022Program ?? null, isWritable: false }
|
|
250
138
|
};
|
|
251
139
|
const accounts = originalAccounts;
|
|
252
140
|
if (!accounts.token2022Program.value) {
|
|
253
141
|
accounts.token2022Program.value = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
|
|
254
142
|
}
|
|
255
143
|
const getAccountMeta = getAccountMetaFactory(programAddress);
|
|
256
|
-
|
|
144
|
+
return Object.freeze({
|
|
257
145
|
accounts: [
|
|
258
146
|
getAccountMeta(accounts.escrow),
|
|
259
147
|
getAccountMeta(accounts.destination),
|
|
@@ -262,10 +150,9 @@ function getCloseStuckEscrowInstruction(input, config) {
|
|
|
262
150
|
getAccountMeta(accounts.wrappedMintAuthority),
|
|
263
151
|
getAccountMeta(accounts.token2022Program)
|
|
264
152
|
],
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
};
|
|
268
|
-
return instruction;
|
|
153
|
+
data: getCloseStuckEscrowInstructionDataEncoder().encode({}),
|
|
154
|
+
programAddress
|
|
155
|
+
});
|
|
269
156
|
}
|
|
270
157
|
function parseCloseStuckEscrowInstruction(instruction) {
|
|
271
158
|
if (instruction.accounts.length < 6) {
|
|
@@ -304,11 +191,7 @@ function getCreateMintInstructionDataEncoder() {
|
|
|
304
191
|
["discriminator", getU8Encoder()],
|
|
305
192
|
["idempotent", getBooleanEncoder()]
|
|
306
193
|
]),
|
|
307
|
-
(value) => ({
|
|
308
|
-
...value,
|
|
309
|
-
discriminator: CREATE_MINT_DISCRIMINATOR,
|
|
310
|
-
idempotent: value.idempotent ?? false
|
|
311
|
-
})
|
|
194
|
+
(value) => ({ ...value, discriminator: CREATE_MINT_DISCRIMINATOR, idempotent: value.idempotent ?? false })
|
|
312
195
|
);
|
|
313
196
|
}
|
|
314
197
|
function getCreateMintInstructionDataDecoder() {
|
|
@@ -318,10 +201,7 @@ function getCreateMintInstructionDataDecoder() {
|
|
|
318
201
|
]);
|
|
319
202
|
}
|
|
320
203
|
function getCreateMintInstructionDataCodec() {
|
|
321
|
-
return combineCodec(
|
|
322
|
-
getCreateMintInstructionDataEncoder(),
|
|
323
|
-
getCreateMintInstructionDataDecoder()
|
|
324
|
-
);
|
|
204
|
+
return combineCodec(getCreateMintInstructionDataEncoder(), getCreateMintInstructionDataDecoder());
|
|
325
205
|
}
|
|
326
206
|
function getCreateMintInstruction(input, config) {
|
|
327
207
|
const programAddress = config?.programAddress ?? TOKEN_WRAP_PROGRAM_ADDRESS;
|
|
@@ -330,10 +210,7 @@ function getCreateMintInstruction(input, config) {
|
|
|
330
210
|
backpointer: { value: input.backpointer ?? null, isWritable: true },
|
|
331
211
|
unwrappedMint: { value: input.unwrappedMint ?? null, isWritable: false },
|
|
332
212
|
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
333
|
-
wrappedTokenProgram: {
|
|
334
|
-
value: input.wrappedTokenProgram ?? null,
|
|
335
|
-
isWritable: false
|
|
336
|
-
}
|
|
213
|
+
wrappedTokenProgram: { value: input.wrappedTokenProgram ?? null, isWritable: false }
|
|
337
214
|
};
|
|
338
215
|
const accounts = originalAccounts;
|
|
339
216
|
const args = { ...input };
|
|
@@ -341,7 +218,7 @@ function getCreateMintInstruction(input, config) {
|
|
|
341
218
|
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
342
219
|
}
|
|
343
220
|
const getAccountMeta = getAccountMetaFactory(programAddress);
|
|
344
|
-
|
|
221
|
+
return Object.freeze({
|
|
345
222
|
accounts: [
|
|
346
223
|
getAccountMeta(accounts.wrappedMint),
|
|
347
224
|
getAccountMeta(accounts.backpointer),
|
|
@@ -349,12 +226,9 @@ function getCreateMintInstruction(input, config) {
|
|
|
349
226
|
getAccountMeta(accounts.systemProgram),
|
|
350
227
|
getAccountMeta(accounts.wrappedTokenProgram)
|
|
351
228
|
],
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
)
|
|
356
|
-
};
|
|
357
|
-
return instruction;
|
|
229
|
+
data: getCreateMintInstructionDataEncoder().encode(args),
|
|
230
|
+
programAddress
|
|
231
|
+
});
|
|
358
232
|
}
|
|
359
233
|
function parseCreateMintInstruction(instruction) {
|
|
360
234
|
if (instruction.accounts.length < 5) {
|
|
@@ -387,13 +261,10 @@ function getSyncMetadataToSplTokenDiscriminatorBytes() {
|
|
|
387
261
|
return getU8Encoder().encode(SYNC_METADATA_TO_SPL_TOKEN_DISCRIMINATOR);
|
|
388
262
|
}
|
|
389
263
|
function getSyncMetadataToSplTokenInstructionDataEncoder() {
|
|
390
|
-
return transformEncoder(
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
discriminator: SYNC_METADATA_TO_SPL_TOKEN_DISCRIMINATOR
|
|
395
|
-
})
|
|
396
|
-
);
|
|
264
|
+
return transformEncoder(getStructEncoder([["discriminator", getU8Encoder()]]), (value) => ({
|
|
265
|
+
...value,
|
|
266
|
+
discriminator: SYNC_METADATA_TO_SPL_TOKEN_DISCRIMINATOR
|
|
267
|
+
}));
|
|
397
268
|
}
|
|
398
269
|
function getSyncMetadataToSplTokenInstructionDataDecoder() {
|
|
399
270
|
return getStructDecoder([["discriminator", getU8Decoder()]]);
|
|
@@ -407,20 +278,11 @@ function getSyncMetadataToSplTokenInstructionDataCodec() {
|
|
|
407
278
|
function getSyncMetadataToSplTokenInstruction(input, config) {
|
|
408
279
|
const programAddress = config?.programAddress ?? TOKEN_WRAP_PROGRAM_ADDRESS;
|
|
409
280
|
const originalAccounts = {
|
|
410
|
-
metaplexMetadata: {
|
|
411
|
-
|
|
412
|
-
isWritable: true
|
|
413
|
-
},
|
|
414
|
-
wrappedMintAuthority: {
|
|
415
|
-
value: input.wrappedMintAuthority ?? null,
|
|
416
|
-
isWritable: true
|
|
417
|
-
},
|
|
281
|
+
metaplexMetadata: { value: input.metaplexMetadata ?? null, isWritable: true },
|
|
282
|
+
wrappedMintAuthority: { value: input.wrappedMintAuthority ?? null, isWritable: true },
|
|
418
283
|
wrappedMint: { value: input.wrappedMint ?? null, isWritable: false },
|
|
419
284
|
unwrappedMint: { value: input.unwrappedMint ?? null, isWritable: false },
|
|
420
|
-
metaplexProgram: {
|
|
421
|
-
value: input.metaplexProgram ?? null,
|
|
422
|
-
isWritable: false
|
|
423
|
-
},
|
|
285
|
+
metaplexProgram: { value: input.metaplexProgram ?? null, isWritable: false },
|
|
424
286
|
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
425
287
|
rentSysvar: { value: input.rentSysvar ?? null, isWritable: false },
|
|
426
288
|
sourceMetadata: { value: input.sourceMetadata ?? null, isWritable: false },
|
|
@@ -437,7 +299,7 @@ function getSyncMetadataToSplTokenInstruction(input, config) {
|
|
|
437
299
|
accounts.rentSysvar.value = "SysvarRent111111111111111111111111111111111";
|
|
438
300
|
}
|
|
439
301
|
const getAccountMeta = getAccountMetaFactory(programAddress);
|
|
440
|
-
|
|
302
|
+
return Object.freeze({
|
|
441
303
|
accounts: [
|
|
442
304
|
getAccountMeta(accounts.metaplexMetadata),
|
|
443
305
|
getAccountMeta(accounts.wrappedMintAuthority),
|
|
@@ -449,10 +311,9 @@ function getSyncMetadataToSplTokenInstruction(input, config) {
|
|
|
449
311
|
getAccountMeta(accounts.sourceMetadata),
|
|
450
312
|
getAccountMeta(accounts.ownerProgram)
|
|
451
313
|
],
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
};
|
|
455
|
-
return instruction;
|
|
314
|
+
data: getSyncMetadataToSplTokenInstructionDataEncoder().encode({}),
|
|
315
|
+
programAddress
|
|
316
|
+
});
|
|
456
317
|
}
|
|
457
318
|
function parseSyncMetadataToSplTokenInstruction(instruction) {
|
|
458
319
|
if (instruction.accounts.length < 9) {
|
|
@@ -481,9 +342,7 @@ function parseSyncMetadataToSplTokenInstruction(instruction) {
|
|
|
481
342
|
sourceMetadata: getNextOptionalAccount(),
|
|
482
343
|
ownerProgram: getNextOptionalAccount()
|
|
483
344
|
},
|
|
484
|
-
data: getSyncMetadataToSplTokenInstructionDataDecoder().decode(
|
|
485
|
-
instruction.data
|
|
486
|
-
)
|
|
345
|
+
data: getSyncMetadataToSplTokenInstructionDataDecoder().decode(instruction.data)
|
|
487
346
|
};
|
|
488
347
|
}
|
|
489
348
|
var SYNC_METADATA_TO_TOKEN2022_DISCRIMINATOR = 4;
|
|
@@ -491,13 +350,10 @@ function getSyncMetadataToToken2022DiscriminatorBytes() {
|
|
|
491
350
|
return getU8Encoder().encode(SYNC_METADATA_TO_TOKEN2022_DISCRIMINATOR);
|
|
492
351
|
}
|
|
493
352
|
function getSyncMetadataToToken2022InstructionDataEncoder() {
|
|
494
|
-
return transformEncoder(
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
discriminator: SYNC_METADATA_TO_TOKEN2022_DISCRIMINATOR
|
|
499
|
-
})
|
|
500
|
-
);
|
|
353
|
+
return transformEncoder(getStructEncoder([["discriminator", getU8Encoder()]]), (value) => ({
|
|
354
|
+
...value,
|
|
355
|
+
discriminator: SYNC_METADATA_TO_TOKEN2022_DISCRIMINATOR
|
|
356
|
+
}));
|
|
501
357
|
}
|
|
502
358
|
function getSyncMetadataToToken2022InstructionDataDecoder() {
|
|
503
359
|
return getStructDecoder([["discriminator", getU8Decoder()]]);
|
|
@@ -512,15 +368,9 @@ function getSyncMetadataToToken2022Instruction(input, config) {
|
|
|
512
368
|
const programAddress = config?.programAddress ?? TOKEN_WRAP_PROGRAM_ADDRESS;
|
|
513
369
|
const originalAccounts = {
|
|
514
370
|
wrappedMint: { value: input.wrappedMint ?? null, isWritable: true },
|
|
515
|
-
wrappedMintAuthority: {
|
|
516
|
-
value: input.wrappedMintAuthority ?? null,
|
|
517
|
-
isWritable: false
|
|
518
|
-
},
|
|
371
|
+
wrappedMintAuthority: { value: input.wrappedMintAuthority ?? null, isWritable: false },
|
|
519
372
|
unwrappedMint: { value: input.unwrappedMint ?? null, isWritable: false },
|
|
520
|
-
token2022Program: {
|
|
521
|
-
value: input.token2022Program ?? null,
|
|
522
|
-
isWritable: false
|
|
523
|
-
},
|
|
373
|
+
token2022Program: { value: input.token2022Program ?? null, isWritable: false },
|
|
524
374
|
sourceMetadata: { value: input.sourceMetadata ?? null, isWritable: false },
|
|
525
375
|
ownerProgram: { value: input.ownerProgram ?? null, isWritable: false }
|
|
526
376
|
};
|
|
@@ -529,7 +379,7 @@ function getSyncMetadataToToken2022Instruction(input, config) {
|
|
|
529
379
|
accounts.token2022Program.value = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
|
|
530
380
|
}
|
|
531
381
|
const getAccountMeta = getAccountMetaFactory(programAddress);
|
|
532
|
-
|
|
382
|
+
return Object.freeze({
|
|
533
383
|
accounts: [
|
|
534
384
|
getAccountMeta(accounts.wrappedMint),
|
|
535
385
|
getAccountMeta(accounts.wrappedMintAuthority),
|
|
@@ -538,10 +388,9 @@ function getSyncMetadataToToken2022Instruction(input, config) {
|
|
|
538
388
|
getAccountMeta(accounts.sourceMetadata),
|
|
539
389
|
getAccountMeta(accounts.ownerProgram)
|
|
540
390
|
],
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
};
|
|
544
|
-
return instruction;
|
|
391
|
+
data: getSyncMetadataToToken2022InstructionDataEncoder().encode({}),
|
|
392
|
+
programAddress
|
|
393
|
+
});
|
|
545
394
|
}
|
|
546
395
|
function parseSyncMetadataToToken2022Instruction(instruction) {
|
|
547
396
|
if (instruction.accounts.length < 6) {
|
|
@@ -567,9 +416,7 @@ function parseSyncMetadataToToken2022Instruction(instruction) {
|
|
|
567
416
|
sourceMetadata: getNextOptionalAccount(),
|
|
568
417
|
ownerProgram: getNextOptionalAccount()
|
|
569
418
|
},
|
|
570
|
-
data: getSyncMetadataToToken2022InstructionDataDecoder().decode(
|
|
571
|
-
instruction.data
|
|
572
|
-
)
|
|
419
|
+
data: getSyncMetadataToToken2022InstructionDataDecoder().decode(instruction.data)
|
|
573
420
|
};
|
|
574
421
|
}
|
|
575
422
|
var UNWRAP_DISCRIMINATOR = 2;
|
|
@@ -592,53 +439,30 @@ function getUnwrapInstructionDataDecoder() {
|
|
|
592
439
|
]);
|
|
593
440
|
}
|
|
594
441
|
function getUnwrapInstructionDataCodec() {
|
|
595
|
-
return combineCodec(
|
|
596
|
-
getUnwrapInstructionDataEncoder(),
|
|
597
|
-
getUnwrapInstructionDataDecoder()
|
|
598
|
-
);
|
|
442
|
+
return combineCodec(getUnwrapInstructionDataEncoder(), getUnwrapInstructionDataDecoder());
|
|
599
443
|
}
|
|
600
444
|
function getUnwrapInstruction(input, config) {
|
|
601
445
|
const programAddress = config?.programAddress ?? TOKEN_WRAP_PROGRAM_ADDRESS;
|
|
602
446
|
const originalAccounts = {
|
|
603
447
|
unwrappedEscrow: { value: input.unwrappedEscrow ?? null, isWritable: true },
|
|
604
|
-
recipientUnwrappedToken: {
|
|
605
|
-
|
|
606
|
-
isWritable: true
|
|
607
|
-
},
|
|
608
|
-
wrappedMintAuthority: {
|
|
609
|
-
value: input.wrappedMintAuthority ?? null,
|
|
610
|
-
isWritable: false
|
|
611
|
-
},
|
|
448
|
+
recipientUnwrappedToken: { value: input.recipientUnwrappedToken ?? null, isWritable: true },
|
|
449
|
+
wrappedMintAuthority: { value: input.wrappedMintAuthority ?? null, isWritable: false },
|
|
612
450
|
unwrappedMint: { value: input.unwrappedMint ?? null, isWritable: false },
|
|
613
|
-
wrappedTokenProgram: {
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
},
|
|
617
|
-
unwrappedTokenProgram: {
|
|
618
|
-
value: input.unwrappedTokenProgram ?? null,
|
|
619
|
-
isWritable: false
|
|
620
|
-
},
|
|
621
|
-
wrappedTokenAccount: {
|
|
622
|
-
value: input.wrappedTokenAccount ?? null,
|
|
623
|
-
isWritable: true
|
|
624
|
-
},
|
|
451
|
+
wrappedTokenProgram: { value: input.wrappedTokenProgram ?? null, isWritable: false },
|
|
452
|
+
unwrappedTokenProgram: { value: input.unwrappedTokenProgram ?? null, isWritable: false },
|
|
453
|
+
wrappedTokenAccount: { value: input.wrappedTokenAccount ?? null, isWritable: true },
|
|
625
454
|
wrappedMint: { value: input.wrappedMint ?? null, isWritable: true },
|
|
626
|
-
transferAuthority: {
|
|
627
|
-
value: input.transferAuthority ?? null,
|
|
628
|
-
isWritable: false
|
|
629
|
-
}
|
|
455
|
+
transferAuthority: { value: input.transferAuthority ?? null, isWritable: false }
|
|
630
456
|
};
|
|
631
457
|
const accounts = originalAccounts;
|
|
632
458
|
const args = { ...input };
|
|
633
|
-
const remainingAccounts = (args.multiSigners ?? []).map(
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
})
|
|
639
|
-
);
|
|
459
|
+
const remainingAccounts = (args.multiSigners ?? []).map((signer) => ({
|
|
460
|
+
address: signer.address,
|
|
461
|
+
role: AccountRole.READONLY_SIGNER,
|
|
462
|
+
signer
|
|
463
|
+
}));
|
|
640
464
|
const getAccountMeta = getAccountMetaFactory(programAddress);
|
|
641
|
-
|
|
465
|
+
return Object.freeze({
|
|
642
466
|
accounts: [
|
|
643
467
|
getAccountMeta(accounts.unwrappedEscrow),
|
|
644
468
|
getAccountMeta(accounts.recipientUnwrappedToken),
|
|
@@ -651,12 +475,9 @@ function getUnwrapInstruction(input, config) {
|
|
|
651
475
|
getAccountMeta(accounts.transferAuthority),
|
|
652
476
|
...remainingAccounts
|
|
653
477
|
],
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
)
|
|
658
|
-
};
|
|
659
|
-
return instruction;
|
|
478
|
+
data: getUnwrapInstructionDataEncoder().encode(args),
|
|
479
|
+
programAddress
|
|
480
|
+
});
|
|
660
481
|
}
|
|
661
482
|
function parseUnwrapInstruction(instruction) {
|
|
662
483
|
if (instruction.accounts.length < 9) {
|
|
@@ -704,53 +525,30 @@ function getWrapInstructionDataDecoder() {
|
|
|
704
525
|
]);
|
|
705
526
|
}
|
|
706
527
|
function getWrapInstructionDataCodec() {
|
|
707
|
-
return combineCodec(
|
|
708
|
-
getWrapInstructionDataEncoder(),
|
|
709
|
-
getWrapInstructionDataDecoder()
|
|
710
|
-
);
|
|
528
|
+
return combineCodec(getWrapInstructionDataEncoder(), getWrapInstructionDataDecoder());
|
|
711
529
|
}
|
|
712
530
|
function getWrapInstruction(input, config) {
|
|
713
531
|
const programAddress = config?.programAddress ?? TOKEN_WRAP_PROGRAM_ADDRESS;
|
|
714
532
|
const originalAccounts = {
|
|
715
|
-
recipientWrappedTokenAccount: {
|
|
716
|
-
value: input.recipientWrappedTokenAccount ?? null,
|
|
717
|
-
isWritable: true
|
|
718
|
-
},
|
|
533
|
+
recipientWrappedTokenAccount: { value: input.recipientWrappedTokenAccount ?? null, isWritable: true },
|
|
719
534
|
wrappedMint: { value: input.wrappedMint ?? null, isWritable: true },
|
|
720
|
-
wrappedMintAuthority: {
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
},
|
|
724
|
-
unwrappedTokenProgram: {
|
|
725
|
-
value: input.unwrappedTokenProgram ?? null,
|
|
726
|
-
isWritable: false
|
|
727
|
-
},
|
|
728
|
-
wrappedTokenProgram: {
|
|
729
|
-
value: input.wrappedTokenProgram ?? null,
|
|
730
|
-
isWritable: false
|
|
731
|
-
},
|
|
732
|
-
unwrappedTokenAccount: {
|
|
733
|
-
value: input.unwrappedTokenAccount ?? null,
|
|
734
|
-
isWritable: true
|
|
735
|
-
},
|
|
535
|
+
wrappedMintAuthority: { value: input.wrappedMintAuthority ?? null, isWritable: false },
|
|
536
|
+
unwrappedTokenProgram: { value: input.unwrappedTokenProgram ?? null, isWritable: false },
|
|
537
|
+
wrappedTokenProgram: { value: input.wrappedTokenProgram ?? null, isWritable: false },
|
|
538
|
+
unwrappedTokenAccount: { value: input.unwrappedTokenAccount ?? null, isWritable: true },
|
|
736
539
|
unwrappedMint: { value: input.unwrappedMint ?? null, isWritable: false },
|
|
737
540
|
unwrappedEscrow: { value: input.unwrappedEscrow ?? null, isWritable: true },
|
|
738
|
-
transferAuthority: {
|
|
739
|
-
value: input.transferAuthority ?? null,
|
|
740
|
-
isWritable: false
|
|
741
|
-
}
|
|
541
|
+
transferAuthority: { value: input.transferAuthority ?? null, isWritable: false }
|
|
742
542
|
};
|
|
743
543
|
const accounts = originalAccounts;
|
|
744
544
|
const args = { ...input };
|
|
745
|
-
const remainingAccounts = (args.multiSigners ?? []).map(
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
})
|
|
751
|
-
);
|
|
545
|
+
const remainingAccounts = (args.multiSigners ?? []).map((signer) => ({
|
|
546
|
+
address: signer.address,
|
|
547
|
+
role: AccountRole.READONLY_SIGNER,
|
|
548
|
+
signer
|
|
549
|
+
}));
|
|
752
550
|
const getAccountMeta = getAccountMetaFactory(programAddress);
|
|
753
|
-
|
|
551
|
+
return Object.freeze({
|
|
754
552
|
accounts: [
|
|
755
553
|
getAccountMeta(accounts.recipientWrappedTokenAccount),
|
|
756
554
|
getAccountMeta(accounts.wrappedMint),
|
|
@@ -763,12 +561,9 @@ function getWrapInstruction(input, config) {
|
|
|
763
561
|
getAccountMeta(accounts.transferAuthority),
|
|
764
562
|
...remainingAccounts
|
|
765
563
|
],
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
)
|
|
770
|
-
};
|
|
771
|
-
return instruction;
|
|
564
|
+
data: getWrapInstructionDataEncoder().encode(args),
|
|
565
|
+
programAddress
|
|
566
|
+
});
|
|
772
567
|
}
|
|
773
568
|
function parseWrapInstruction(instruction) {
|
|
774
569
|
if (instruction.accounts.length < 9) {
|
|
@@ -796,6 +591,132 @@ function parseWrapInstruction(instruction) {
|
|
|
796
591
|
data: getWrapInstructionDataDecoder().decode(instruction.data)
|
|
797
592
|
};
|
|
798
593
|
}
|
|
594
|
+
|
|
595
|
+
// src/generated/programs/tokenWrap.ts
|
|
596
|
+
var TOKEN_WRAP_PROGRAM_ADDRESS = "TwRapQCDhWkZRrDaHfZGuHxkZ91gHDRkyuzNqeU5MgR";
|
|
597
|
+
var TokenWrapAccount = /* @__PURE__ */ ((TokenWrapAccount2) => {
|
|
598
|
+
TokenWrapAccount2[TokenWrapAccount2["Backpointer"] = 0] = "Backpointer";
|
|
599
|
+
return TokenWrapAccount2;
|
|
600
|
+
})(TokenWrapAccount || {});
|
|
601
|
+
var TokenWrapInstruction = /* @__PURE__ */ ((TokenWrapInstruction2) => {
|
|
602
|
+
TokenWrapInstruction2[TokenWrapInstruction2["CreateMint"] = 0] = "CreateMint";
|
|
603
|
+
TokenWrapInstruction2[TokenWrapInstruction2["Wrap"] = 1] = "Wrap";
|
|
604
|
+
TokenWrapInstruction2[TokenWrapInstruction2["Unwrap"] = 2] = "Unwrap";
|
|
605
|
+
TokenWrapInstruction2[TokenWrapInstruction2["CloseStuckEscrow"] = 3] = "CloseStuckEscrow";
|
|
606
|
+
TokenWrapInstruction2[TokenWrapInstruction2["SyncMetadataToToken2022"] = 4] = "SyncMetadataToToken2022";
|
|
607
|
+
TokenWrapInstruction2[TokenWrapInstruction2["SyncMetadataToSplToken"] = 5] = "SyncMetadataToSplToken";
|
|
608
|
+
return TokenWrapInstruction2;
|
|
609
|
+
})(TokenWrapInstruction || {});
|
|
610
|
+
function identifyTokenWrapInstruction(instruction) {
|
|
611
|
+
const data = "data" in instruction ? instruction.data : instruction;
|
|
612
|
+
if (containsBytes(data, getU8Encoder().encode(0), 0)) {
|
|
613
|
+
return 0 /* CreateMint */;
|
|
614
|
+
}
|
|
615
|
+
if (containsBytes(data, getU8Encoder().encode(1), 0)) {
|
|
616
|
+
return 1 /* Wrap */;
|
|
617
|
+
}
|
|
618
|
+
if (containsBytes(data, getU8Encoder().encode(2), 0)) {
|
|
619
|
+
return 2 /* Unwrap */;
|
|
620
|
+
}
|
|
621
|
+
if (containsBytes(data, getU8Encoder().encode(3), 0)) {
|
|
622
|
+
return 3 /* CloseStuckEscrow */;
|
|
623
|
+
}
|
|
624
|
+
if (containsBytes(data, getU8Encoder().encode(4), 0)) {
|
|
625
|
+
return 4 /* SyncMetadataToToken2022 */;
|
|
626
|
+
}
|
|
627
|
+
if (containsBytes(data, getU8Encoder().encode(5), 0)) {
|
|
628
|
+
return 5 /* SyncMetadataToSplToken */;
|
|
629
|
+
}
|
|
630
|
+
throw new Error("The provided instruction could not be identified as a tokenWrap instruction.");
|
|
631
|
+
}
|
|
632
|
+
function parseTokenWrapInstruction(instruction) {
|
|
633
|
+
const instructionType = identifyTokenWrapInstruction(instruction);
|
|
634
|
+
switch (instructionType) {
|
|
635
|
+
case 0 /* CreateMint */: {
|
|
636
|
+
assertIsInstructionWithAccounts(instruction);
|
|
637
|
+
return { instructionType: 0 /* CreateMint */, ...parseCreateMintInstruction(instruction) };
|
|
638
|
+
}
|
|
639
|
+
case 1 /* Wrap */: {
|
|
640
|
+
assertIsInstructionWithAccounts(instruction);
|
|
641
|
+
return { instructionType: 1 /* Wrap */, ...parseWrapInstruction(instruction) };
|
|
642
|
+
}
|
|
643
|
+
case 2 /* Unwrap */: {
|
|
644
|
+
assertIsInstructionWithAccounts(instruction);
|
|
645
|
+
return { instructionType: 2 /* Unwrap */, ...parseUnwrapInstruction(instruction) };
|
|
646
|
+
}
|
|
647
|
+
case 3 /* CloseStuckEscrow */: {
|
|
648
|
+
assertIsInstructionWithAccounts(instruction);
|
|
649
|
+
return {
|
|
650
|
+
instructionType: 3 /* CloseStuckEscrow */,
|
|
651
|
+
...parseCloseStuckEscrowInstruction(instruction)
|
|
652
|
+
};
|
|
653
|
+
}
|
|
654
|
+
case 4 /* SyncMetadataToToken2022 */: {
|
|
655
|
+
assertIsInstructionWithAccounts(instruction);
|
|
656
|
+
return {
|
|
657
|
+
instructionType: 4 /* SyncMetadataToToken2022 */,
|
|
658
|
+
...parseSyncMetadataToToken2022Instruction(instruction)
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
case 5 /* SyncMetadataToSplToken */: {
|
|
662
|
+
assertIsInstructionWithAccounts(instruction);
|
|
663
|
+
return {
|
|
664
|
+
instructionType: 5 /* SyncMetadataToSplToken */,
|
|
665
|
+
...parseSyncMetadataToSplTokenInstruction(instruction)
|
|
666
|
+
};
|
|
667
|
+
}
|
|
668
|
+
default:
|
|
669
|
+
throw new Error(`Unrecognized instruction type: ${instructionType}`);
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
// src/generated/errors/tokenWrap.ts
|
|
674
|
+
var TOKEN_WRAP_ERROR__WRAPPED_MINT_MISMATCH = 0;
|
|
675
|
+
var TOKEN_WRAP_ERROR__BACKPOINTER_MISMATCH = 1;
|
|
676
|
+
var TOKEN_WRAP_ERROR__ZERO_WRAP_AMOUNT = 2;
|
|
677
|
+
var TOKEN_WRAP_ERROR__MINT_AUTHORITY_MISMATCH = 3;
|
|
678
|
+
var TOKEN_WRAP_ERROR__ESCROW_OWNER_MISMATCH = 4;
|
|
679
|
+
var TOKEN_WRAP_ERROR__INVALID_WRAPPED_MINT_OWNER = 5;
|
|
680
|
+
var TOKEN_WRAP_ERROR__INVALID_BACKPOINTER_OWNER = 6;
|
|
681
|
+
var TOKEN_WRAP_ERROR__ESCROW_MISMATCH = 7;
|
|
682
|
+
var TOKEN_WRAP_ERROR__ESCROW_IN_GOOD_STATE = 8;
|
|
683
|
+
var TOKEN_WRAP_ERROR__UNWRAPPED_MINT_HAS_NO_METADATA = 9;
|
|
684
|
+
var TOKEN_WRAP_ERROR__METAPLEX_METADATA_MISMATCH = 10;
|
|
685
|
+
var TOKEN_WRAP_ERROR__METADATA_POINTER_MISSING = 11;
|
|
686
|
+
var TOKEN_WRAP_ERROR__METADATA_POINTER_UNSET = 12;
|
|
687
|
+
var TOKEN_WRAP_ERROR__METADATA_POINTER_MISMATCH = 13;
|
|
688
|
+
var TOKEN_WRAP_ERROR__EXTERNAL_PROGRAM_RETURNED_NO_DATA = 14;
|
|
689
|
+
var TOKEN_WRAP_ERROR__NO_SYNCING_TO_TOKEN2022 = 15;
|
|
690
|
+
var tokenWrapErrorMessages;
|
|
691
|
+
if (process.env.NODE_ENV !== "production") {
|
|
692
|
+
tokenWrapErrorMessages = {
|
|
693
|
+
[TOKEN_WRAP_ERROR__BACKPOINTER_MISMATCH]: `Wrapped backpointer account address does not match expected PDA`,
|
|
694
|
+
[TOKEN_WRAP_ERROR__ESCROW_IN_GOOD_STATE]: `The escrow account is in a good state and cannot be recreated`,
|
|
695
|
+
[TOKEN_WRAP_ERROR__ESCROW_MISMATCH]: `Escrow account address does not match expected ATA`,
|
|
696
|
+
[TOKEN_WRAP_ERROR__ESCROW_OWNER_MISMATCH]: `Unwrapped escrow token owner is not set to expected PDA`,
|
|
697
|
+
[TOKEN_WRAP_ERROR__EXTERNAL_PROGRAM_RETURNED_NO_DATA]: `External metadata program returned no data`,
|
|
698
|
+
[TOKEN_WRAP_ERROR__INVALID_BACKPOINTER_OWNER]: `Wrapped backpointer account owner is not the expected token wrap program`,
|
|
699
|
+
[TOKEN_WRAP_ERROR__INVALID_WRAPPED_MINT_OWNER]: `Wrapped mint account owner is not the expected token program`,
|
|
700
|
+
[TOKEN_WRAP_ERROR__METADATA_POINTER_MISMATCH]: `Provided source metadata account does not match pointer`,
|
|
701
|
+
[TOKEN_WRAP_ERROR__METADATA_POINTER_MISSING]: `Metadata pointer extension missing on mint`,
|
|
702
|
+
[TOKEN_WRAP_ERROR__METADATA_POINTER_UNSET]: `Metadata pointer is unset (None)`,
|
|
703
|
+
[TOKEN_WRAP_ERROR__METAPLEX_METADATA_MISMATCH]: `Metaplex metadata account address does not match expected PDA`,
|
|
704
|
+
[TOKEN_WRAP_ERROR__MINT_AUTHORITY_MISMATCH]: `Wrapped mint authority does not match expected PDA`,
|
|
705
|
+
[TOKEN_WRAP_ERROR__NO_SYNCING_TO_TOKEN2022]: `Instruction can only be used with spl-token wrapped mints`,
|
|
706
|
+
[TOKEN_WRAP_ERROR__UNWRAPPED_MINT_HAS_NO_METADATA]: `Unwrapped mint does not have the TokenMetadata extension`,
|
|
707
|
+
[TOKEN_WRAP_ERROR__WRAPPED_MINT_MISMATCH]: `Wrapped mint account address does not match expected PDA`,
|
|
708
|
+
[TOKEN_WRAP_ERROR__ZERO_WRAP_AMOUNT]: `Wrap amount should be positive`
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
function getTokenWrapErrorMessage(code) {
|
|
712
|
+
if (process.env.NODE_ENV !== "production") {
|
|
713
|
+
return tokenWrapErrorMessages[code];
|
|
714
|
+
}
|
|
715
|
+
return "Error message not available in production bundles.";
|
|
716
|
+
}
|
|
717
|
+
function isTokenWrapError(error, transactionMessage, code) {
|
|
718
|
+
return isProgramError(error, transactionMessage, TOKEN_WRAP_PROGRAM_ADDRESS, code);
|
|
719
|
+
}
|
|
799
720
|
var DEFAULT_EXTENSIONS = [
|
|
800
721
|
extension("ConfidentialTransferMint", {
|
|
801
722
|
autoApproveNewAccounts: true,
|
|
@@ -968,6 +889,8 @@ function combinedMultisigTx({
|
|
|
968
889
|
assertIsSendableTransaction(tx);
|
|
969
890
|
return tx;
|
|
970
891
|
}
|
|
892
|
+
|
|
893
|
+
// src/wrap.ts
|
|
971
894
|
async function multisigOfflineSignWrap(args) {
|
|
972
895
|
const wrapIx = await buildWrapIx(args);
|
|
973
896
|
return pipe(
|
|
@@ -1207,6 +1130,6 @@ async function multisigOfflineSignUnwrap(args) {
|
|
|
1207
1130
|
);
|
|
1208
1131
|
}
|
|
1209
1132
|
|
|
1210
|
-
export { CLOSE_STUCK_ESCROW_DISCRIMINATOR, CREATE_MINT_DISCRIMINATOR, SYNC_METADATA_TO_SPL_TOKEN_DISCRIMINATOR, SYNC_METADATA_TO_TOKEN2022_DISCRIMINATOR, TOKEN_WRAP_ERROR__BACKPOINTER_MISMATCH, TOKEN_WRAP_ERROR__ESCROW_IN_GOOD_STATE, TOKEN_WRAP_ERROR__ESCROW_MISMATCH, TOKEN_WRAP_ERROR__ESCROW_OWNER_MISMATCH, TOKEN_WRAP_ERROR__EXTERNAL_PROGRAM_RETURNED_NO_DATA, TOKEN_WRAP_ERROR__INVALID_BACKPOINTER_OWNER, TOKEN_WRAP_ERROR__INVALID_WRAPPED_MINT_OWNER, TOKEN_WRAP_ERROR__METADATA_POINTER_MISMATCH, TOKEN_WRAP_ERROR__METADATA_POINTER_MISSING, TOKEN_WRAP_ERROR__METADATA_POINTER_UNSET, TOKEN_WRAP_ERROR__METAPLEX_METADATA_MISMATCH, TOKEN_WRAP_ERROR__MINT_AUTHORITY_MISMATCH, TOKEN_WRAP_ERROR__NO_SYNCING_TO_TOKEN2022, TOKEN_WRAP_ERROR__UNWRAPPED_MINT_HAS_NO_METADATA, TOKEN_WRAP_ERROR__WRAPPED_MINT_MISMATCH, TOKEN_WRAP_ERROR__ZERO_WRAP_AMOUNT, TOKEN_WRAP_PROGRAM_ADDRESS, TokenWrapAccount, TokenWrapInstruction, UNWRAP_DISCRIMINATOR, WRAP_DISCRIMINATOR, combinedMultisigTx, createEscrowAccount, createMint, decodeBackpointer, fetchAllBackpointer, fetchAllMaybeBackpointer, fetchBackpointer, fetchBackpointerFromSeeds, fetchMaybeBackpointer, fetchMaybeBackpointerFromSeeds, findBackpointerPda, findWrappedMintAuthorityPda, findWrappedMintPda, getBackpointerCodec, getBackpointerDecoder, getBackpointerEncoder, getBackpointerSize, getCloseStuckEscrowDiscriminatorBytes, getCloseStuckEscrowInstruction, getCloseStuckEscrowInstructionDataCodec, getCloseStuckEscrowInstructionDataDecoder, getCloseStuckEscrowInstructionDataEncoder, getCreateMintDiscriminatorBytes, getCreateMintInstruction, getCreateMintInstructionDataCodec, getCreateMintInstructionDataDecoder, getCreateMintInstructionDataEncoder, getSyncMetadataToSplTokenDiscriminatorBytes, getSyncMetadataToSplTokenInstruction, getSyncMetadataToSplTokenInstructionDataCodec, getSyncMetadataToSplTokenInstructionDataDecoder, getSyncMetadataToSplTokenInstructionDataEncoder, getSyncMetadataToToken2022DiscriminatorBytes, getSyncMetadataToToken2022Instruction, getSyncMetadataToToken2022InstructionDataCodec, getSyncMetadataToToken2022InstructionDataDecoder, getSyncMetadataToToken2022InstructionDataEncoder, getTokenWrapErrorMessage, getUnwrapDiscriminatorBytes, getUnwrapInstruction, getUnwrapInstructionDataCodec, getUnwrapInstructionDataDecoder, getUnwrapInstructionDataEncoder, getWrapDiscriminatorBytes, getWrapInstruction, getWrapInstructionDataCodec, getWrapInstructionDataDecoder, getWrapInstructionDataEncoder, identifyTokenWrapInstruction, isTokenWrapError, multisigOfflineSignUnwrap, multisigOfflineSignWrap, parseCloseStuckEscrowInstruction, parseCreateMintInstruction, parseSyncMetadataToSplTokenInstruction, parseSyncMetadataToToken2022Instruction, parseUnwrapInstruction, parseWrapInstruction, singleSignerUnwrap, singleSignerWrap };
|
|
1133
|
+
export { CLOSE_STUCK_ESCROW_DISCRIMINATOR, CREATE_MINT_DISCRIMINATOR, SYNC_METADATA_TO_SPL_TOKEN_DISCRIMINATOR, SYNC_METADATA_TO_TOKEN2022_DISCRIMINATOR, TOKEN_WRAP_ERROR__BACKPOINTER_MISMATCH, TOKEN_WRAP_ERROR__ESCROW_IN_GOOD_STATE, TOKEN_WRAP_ERROR__ESCROW_MISMATCH, TOKEN_WRAP_ERROR__ESCROW_OWNER_MISMATCH, TOKEN_WRAP_ERROR__EXTERNAL_PROGRAM_RETURNED_NO_DATA, TOKEN_WRAP_ERROR__INVALID_BACKPOINTER_OWNER, TOKEN_WRAP_ERROR__INVALID_WRAPPED_MINT_OWNER, TOKEN_WRAP_ERROR__METADATA_POINTER_MISMATCH, TOKEN_WRAP_ERROR__METADATA_POINTER_MISSING, TOKEN_WRAP_ERROR__METADATA_POINTER_UNSET, TOKEN_WRAP_ERROR__METAPLEX_METADATA_MISMATCH, TOKEN_WRAP_ERROR__MINT_AUTHORITY_MISMATCH, TOKEN_WRAP_ERROR__NO_SYNCING_TO_TOKEN2022, TOKEN_WRAP_ERROR__UNWRAPPED_MINT_HAS_NO_METADATA, TOKEN_WRAP_ERROR__WRAPPED_MINT_MISMATCH, TOKEN_WRAP_ERROR__ZERO_WRAP_AMOUNT, TOKEN_WRAP_PROGRAM_ADDRESS, TokenWrapAccount, TokenWrapInstruction, UNWRAP_DISCRIMINATOR, WRAP_DISCRIMINATOR, combinedMultisigTx, createEscrowAccount, createMint, decodeBackpointer, fetchAllBackpointer, fetchAllMaybeBackpointer, fetchBackpointer, fetchBackpointerFromSeeds, fetchMaybeBackpointer, fetchMaybeBackpointerFromSeeds, findBackpointerPda, findWrappedMintAuthorityPda, findWrappedMintPda, getBackpointerCodec, getBackpointerDecoder, getBackpointerEncoder, getBackpointerSize, getCloseStuckEscrowDiscriminatorBytes, getCloseStuckEscrowInstruction, getCloseStuckEscrowInstructionDataCodec, getCloseStuckEscrowInstructionDataDecoder, getCloseStuckEscrowInstructionDataEncoder, getCreateMintDiscriminatorBytes, getCreateMintInstruction, getCreateMintInstructionDataCodec, getCreateMintInstructionDataDecoder, getCreateMintInstructionDataEncoder, getSyncMetadataToSplTokenDiscriminatorBytes, getSyncMetadataToSplTokenInstruction, getSyncMetadataToSplTokenInstructionDataCodec, getSyncMetadataToSplTokenInstructionDataDecoder, getSyncMetadataToSplTokenInstructionDataEncoder, getSyncMetadataToToken2022DiscriminatorBytes, getSyncMetadataToToken2022Instruction, getSyncMetadataToToken2022InstructionDataCodec, getSyncMetadataToToken2022InstructionDataDecoder, getSyncMetadataToToken2022InstructionDataEncoder, getTokenWrapErrorMessage, getUnwrapDiscriminatorBytes, getUnwrapInstruction, getUnwrapInstructionDataCodec, getUnwrapInstructionDataDecoder, getUnwrapInstructionDataEncoder, getWrapDiscriminatorBytes, getWrapInstruction, getWrapInstructionDataCodec, getWrapInstructionDataDecoder, getWrapInstructionDataEncoder, identifyTokenWrapInstruction, isTokenWrapError, multisigOfflineSignUnwrap, multisigOfflineSignWrap, parseCloseStuckEscrowInstruction, parseCreateMintInstruction, parseSyncMetadataToSplTokenInstruction, parseSyncMetadataToToken2022Instruction, parseTokenWrapInstruction, parseUnwrapInstruction, parseWrapInstruction, singleSignerUnwrap, singleSignerWrap };
|
|
1211
1134
|
//# sourceMappingURL=index.mjs.map
|
|
1212
1135
|
//# sourceMappingURL=index.mjs.map
|