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