@solana-program/token-wrap 2.1.0 → 2.3.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 +264 -22
- package/dist/src/index.js.map +1 -1
- package/dist/src/index.mjs +246 -25
- package/dist/src/index.mjs.map +1 -1
- package/dist/types/create-mint.d.ts +2 -2
- package/dist/types/examples/sync-spl-to-token2022.d.ts +1 -0
- package/dist/types/examples/sync-token2022-to-spl.d.ts +1 -0
- package/dist/types/generated/accounts/backpointer.d.ts +6 -6
- package/dist/types/generated/accounts/index.d.ts +2 -2
- package/dist/types/generated/errors/index.d.ts +2 -2
- package/dist/types/generated/errors/tokenWrap.d.ts +10 -3
- package/dist/types/generated/index.d.ts +2 -2
- package/dist/types/generated/instructions/closeStuckEscrow.d.ts +10 -10
- package/dist/types/generated/instructions/createMint.d.ts +10 -10
- package/dist/types/generated/instructions/index.d.ts +4 -2
- package/dist/types/generated/instructions/syncMetadataToSplToken.d.ts +92 -0
- package/dist/types/generated/instructions/syncMetadataToToken2022.d.ts +75 -0
- package/dist/types/generated/instructions/unwrap.d.ts +11 -11
- package/dist/types/generated/instructions/wrap.d.ts +11 -11
- package/dist/types/generated/pdas/backpointer.d.ts +2 -2
- package/dist/types/generated/pdas/index.d.ts +2 -2
- package/dist/types/generated/pdas/wrappedMint.d.ts +2 -2
- package/dist/types/generated/pdas/wrappedMintAuthority.d.ts +2 -2
- package/dist/types/generated/programs/index.d.ts +2 -2
- package/dist/types/generated/programs/tokenWrap.d.ts +11 -5
- package/dist/types/generated/shared/index.d.ts +5 -5
- package/dist/types/unwrap.d.ts +3 -3
- package/dist/types/utilities.d.ts +4 -4
- package/dist/types/wrap.d.ts +3 -3
- package/package.json +18 -18
package/dist/src/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getProgramDerivedAddress, getUtf8Encoder, getAddressEncoder, getStructEncoder, getStructDecoder, getAddressDecoder, combineCodec, decodeAccount, assertAccountExists, fetchEncodedAccount, assertAccountsExist, fetchEncodedAccounts, containsBytes, getU8Encoder, isProgramError, transformEncoder, getU8Decoder, getBooleanEncoder, getBooleanDecoder, getU64Encoder, getU64Decoder, AccountRole,
|
|
2
|
-
import { getMintSize, findAssociatedTokenPda, fetchMaybeToken, getCreateAssociatedTokenInstruction, getTokenDecoder } from '@solana-program/token-2022';
|
|
1
|
+
import { getProgramDerivedAddress, getUtf8Encoder, getAddressEncoder, getStructEncoder, getStructDecoder, getAddressDecoder, combineCodec, decodeAccount, assertAccountExists, fetchEncodedAccount, assertAccountsExist, fetchEncodedAccounts, containsBytes, getU8Encoder, isProgramError, transformEncoder, getU8Decoder, getBooleanEncoder, getBooleanDecoder, getU64Encoder, getU64Decoder, AccountRole, assertIsFullySignedTransaction, assertIsSendableTransaction, pipe, createTransactionMessage, setTransactionMessageFeePayerSigner, setTransactionMessageLifetimeUsingBlockhash, appendTransactionMessageInstructions, upgradeRoleToSigner, isTransactionSigner as isTransactionSigner$1 } from '@solana/kit';
|
|
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';
|
|
5
5
|
|
|
@@ -99,6 +99,8 @@ var TokenWrapInstruction = /* @__PURE__ */ ((TokenWrapInstruction2) => {
|
|
|
99
99
|
TokenWrapInstruction2[TokenWrapInstruction2["Wrap"] = 1] = "Wrap";
|
|
100
100
|
TokenWrapInstruction2[TokenWrapInstruction2["Unwrap"] = 2] = "Unwrap";
|
|
101
101
|
TokenWrapInstruction2[TokenWrapInstruction2["CloseStuckEscrow"] = 3] = "CloseStuckEscrow";
|
|
102
|
+
TokenWrapInstruction2[TokenWrapInstruction2["SyncMetadataToToken2022"] = 4] = "SyncMetadataToToken2022";
|
|
103
|
+
TokenWrapInstruction2[TokenWrapInstruction2["SyncMetadataToSplToken"] = 5] = "SyncMetadataToSplToken";
|
|
102
104
|
return TokenWrapInstruction2;
|
|
103
105
|
})(TokenWrapInstruction || {});
|
|
104
106
|
function identifyTokenWrapInstruction(instruction) {
|
|
@@ -115,6 +117,12 @@ function identifyTokenWrapInstruction(instruction) {
|
|
|
115
117
|
if (containsBytes(data, getU8Encoder().encode(3), 0)) {
|
|
116
118
|
return 3 /* CloseStuckEscrow */;
|
|
117
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
|
+
}
|
|
118
126
|
throw new Error(
|
|
119
127
|
"The provided instruction could not be identified as a tokenWrap instruction."
|
|
120
128
|
);
|
|
@@ -130,6 +138,13 @@ var TOKEN_WRAP_ERROR__INVALID_WRAPPED_MINT_OWNER = 5;
|
|
|
130
138
|
var TOKEN_WRAP_ERROR__INVALID_BACKPOINTER_OWNER = 6;
|
|
131
139
|
var TOKEN_WRAP_ERROR__ESCROW_MISMATCH = 7;
|
|
132
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;
|
|
133
148
|
var tokenWrapErrorMessages;
|
|
134
149
|
if (process.env.NODE_ENV !== "production") {
|
|
135
150
|
tokenWrapErrorMessages = {
|
|
@@ -137,9 +152,16 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
137
152
|
[TOKEN_WRAP_ERROR__ESCROW_IN_GOOD_STATE]: `The escrow account is in a good state and cannot be recreated`,
|
|
138
153
|
[TOKEN_WRAP_ERROR__ESCROW_MISMATCH]: `Escrow account address does not match expected ATA`,
|
|
139
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`,
|
|
140
156
|
[TOKEN_WRAP_ERROR__INVALID_BACKPOINTER_OWNER]: `Wrapped backpointer account owner is not the expected token wrap program`,
|
|
141
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`,
|
|
142
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`,
|
|
143
165
|
[TOKEN_WRAP_ERROR__WRAPPED_MINT_MISMATCH]: `Wrapped mint account address does not match expected PDA`,
|
|
144
166
|
[TOKEN_WRAP_ERROR__ZERO_WRAP_AMOUNT]: `Wrap amount should be positive`
|
|
145
167
|
};
|
|
@@ -231,7 +253,7 @@ function getCloseStuckEscrowInstruction(input, config) {
|
|
|
231
253
|
accounts.token2022Program.value = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
|
|
232
254
|
}
|
|
233
255
|
const getAccountMeta = getAccountMetaFactory(programAddress);
|
|
234
|
-
|
|
256
|
+
return Object.freeze({
|
|
235
257
|
accounts: [
|
|
236
258
|
getAccountMeta(accounts.escrow),
|
|
237
259
|
getAccountMeta(accounts.destination),
|
|
@@ -240,10 +262,9 @@ function getCloseStuckEscrowInstruction(input, config) {
|
|
|
240
262
|
getAccountMeta(accounts.wrappedMintAuthority),
|
|
241
263
|
getAccountMeta(accounts.token2022Program)
|
|
242
264
|
],
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
};
|
|
246
|
-
return instruction;
|
|
265
|
+
data: getCloseStuckEscrowInstructionDataEncoder().encode({}),
|
|
266
|
+
programAddress
|
|
267
|
+
});
|
|
247
268
|
}
|
|
248
269
|
function parseCloseStuckEscrowInstruction(instruction) {
|
|
249
270
|
if (instruction.accounts.length < 6) {
|
|
@@ -319,7 +340,7 @@ function getCreateMintInstruction(input, config) {
|
|
|
319
340
|
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
320
341
|
}
|
|
321
342
|
const getAccountMeta = getAccountMetaFactory(programAddress);
|
|
322
|
-
|
|
343
|
+
return Object.freeze({
|
|
323
344
|
accounts: [
|
|
324
345
|
getAccountMeta(accounts.wrappedMint),
|
|
325
346
|
getAccountMeta(accounts.backpointer),
|
|
@@ -327,12 +348,11 @@ function getCreateMintInstruction(input, config) {
|
|
|
327
348
|
getAccountMeta(accounts.systemProgram),
|
|
328
349
|
getAccountMeta(accounts.wrappedTokenProgram)
|
|
329
350
|
],
|
|
330
|
-
programAddress,
|
|
331
351
|
data: getCreateMintInstructionDataEncoder().encode(
|
|
332
352
|
args
|
|
333
|
-
)
|
|
334
|
-
|
|
335
|
-
|
|
353
|
+
),
|
|
354
|
+
programAddress
|
|
355
|
+
});
|
|
336
356
|
}
|
|
337
357
|
function parseCreateMintInstruction(instruction) {
|
|
338
358
|
if (instruction.accounts.length < 5) {
|
|
@@ -360,6 +380,194 @@ function parseCreateMintInstruction(instruction) {
|
|
|
360
380
|
data: getCreateMintInstructionDataDecoder().decode(instruction.data)
|
|
361
381
|
};
|
|
362
382
|
}
|
|
383
|
+
var SYNC_METADATA_TO_SPL_TOKEN_DISCRIMINATOR = 5;
|
|
384
|
+
function getSyncMetadataToSplTokenDiscriminatorBytes() {
|
|
385
|
+
return getU8Encoder().encode(SYNC_METADATA_TO_SPL_TOKEN_DISCRIMINATOR);
|
|
386
|
+
}
|
|
387
|
+
function getSyncMetadataToSplTokenInstructionDataEncoder() {
|
|
388
|
+
return transformEncoder(
|
|
389
|
+
getStructEncoder([["discriminator", getU8Encoder()]]),
|
|
390
|
+
(value) => ({
|
|
391
|
+
...value,
|
|
392
|
+
discriminator: SYNC_METADATA_TO_SPL_TOKEN_DISCRIMINATOR
|
|
393
|
+
})
|
|
394
|
+
);
|
|
395
|
+
}
|
|
396
|
+
function getSyncMetadataToSplTokenInstructionDataDecoder() {
|
|
397
|
+
return getStructDecoder([["discriminator", getU8Decoder()]]);
|
|
398
|
+
}
|
|
399
|
+
function getSyncMetadataToSplTokenInstructionDataCodec() {
|
|
400
|
+
return combineCodec(
|
|
401
|
+
getSyncMetadataToSplTokenInstructionDataEncoder(),
|
|
402
|
+
getSyncMetadataToSplTokenInstructionDataDecoder()
|
|
403
|
+
);
|
|
404
|
+
}
|
|
405
|
+
function getSyncMetadataToSplTokenInstruction(input, config) {
|
|
406
|
+
const programAddress = config?.programAddress ?? TOKEN_WRAP_PROGRAM_ADDRESS;
|
|
407
|
+
const originalAccounts = {
|
|
408
|
+
metaplexMetadata: {
|
|
409
|
+
value: input.metaplexMetadata ?? null,
|
|
410
|
+
isWritable: true
|
|
411
|
+
},
|
|
412
|
+
wrappedMintAuthority: {
|
|
413
|
+
value: input.wrappedMintAuthority ?? null,
|
|
414
|
+
isWritable: true
|
|
415
|
+
},
|
|
416
|
+
wrappedMint: { value: input.wrappedMint ?? null, isWritable: false },
|
|
417
|
+
unwrappedMint: { value: input.unwrappedMint ?? null, isWritable: false },
|
|
418
|
+
metaplexProgram: {
|
|
419
|
+
value: input.metaplexProgram ?? null,
|
|
420
|
+
isWritable: false
|
|
421
|
+
},
|
|
422
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
423
|
+
rentSysvar: { value: input.rentSysvar ?? null, isWritable: false },
|
|
424
|
+
sourceMetadata: { value: input.sourceMetadata ?? null, isWritable: false },
|
|
425
|
+
ownerProgram: { value: input.ownerProgram ?? null, isWritable: false }
|
|
426
|
+
};
|
|
427
|
+
const accounts = originalAccounts;
|
|
428
|
+
if (!accounts.metaplexProgram.value) {
|
|
429
|
+
accounts.metaplexProgram.value = "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s";
|
|
430
|
+
}
|
|
431
|
+
if (!accounts.systemProgram.value) {
|
|
432
|
+
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
433
|
+
}
|
|
434
|
+
if (!accounts.rentSysvar.value) {
|
|
435
|
+
accounts.rentSysvar.value = "SysvarRent111111111111111111111111111111111";
|
|
436
|
+
}
|
|
437
|
+
const getAccountMeta = getAccountMetaFactory(programAddress);
|
|
438
|
+
return Object.freeze({
|
|
439
|
+
accounts: [
|
|
440
|
+
getAccountMeta(accounts.metaplexMetadata),
|
|
441
|
+
getAccountMeta(accounts.wrappedMintAuthority),
|
|
442
|
+
getAccountMeta(accounts.wrappedMint),
|
|
443
|
+
getAccountMeta(accounts.unwrappedMint),
|
|
444
|
+
getAccountMeta(accounts.metaplexProgram),
|
|
445
|
+
getAccountMeta(accounts.systemProgram),
|
|
446
|
+
getAccountMeta(accounts.rentSysvar),
|
|
447
|
+
getAccountMeta(accounts.sourceMetadata),
|
|
448
|
+
getAccountMeta(accounts.ownerProgram)
|
|
449
|
+
],
|
|
450
|
+
data: getSyncMetadataToSplTokenInstructionDataEncoder().encode({}),
|
|
451
|
+
programAddress
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
function parseSyncMetadataToSplTokenInstruction(instruction) {
|
|
455
|
+
if (instruction.accounts.length < 9) {
|
|
456
|
+
throw new Error("Not enough accounts");
|
|
457
|
+
}
|
|
458
|
+
let accountIndex = 0;
|
|
459
|
+
const getNextAccount = () => {
|
|
460
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
461
|
+
accountIndex += 1;
|
|
462
|
+
return accountMeta;
|
|
463
|
+
};
|
|
464
|
+
const getNextOptionalAccount = () => {
|
|
465
|
+
const accountMeta = getNextAccount();
|
|
466
|
+
return accountMeta.address === TOKEN_WRAP_PROGRAM_ADDRESS ? void 0 : accountMeta;
|
|
467
|
+
};
|
|
468
|
+
return {
|
|
469
|
+
programAddress: instruction.programAddress,
|
|
470
|
+
accounts: {
|
|
471
|
+
metaplexMetadata: getNextAccount(),
|
|
472
|
+
wrappedMintAuthority: getNextAccount(),
|
|
473
|
+
wrappedMint: getNextAccount(),
|
|
474
|
+
unwrappedMint: getNextAccount(),
|
|
475
|
+
metaplexProgram: getNextAccount(),
|
|
476
|
+
systemProgram: getNextAccount(),
|
|
477
|
+
rentSysvar: getNextAccount(),
|
|
478
|
+
sourceMetadata: getNextOptionalAccount(),
|
|
479
|
+
ownerProgram: getNextOptionalAccount()
|
|
480
|
+
},
|
|
481
|
+
data: getSyncMetadataToSplTokenInstructionDataDecoder().decode(
|
|
482
|
+
instruction.data
|
|
483
|
+
)
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
var SYNC_METADATA_TO_TOKEN2022_DISCRIMINATOR = 4;
|
|
487
|
+
function getSyncMetadataToToken2022DiscriminatorBytes() {
|
|
488
|
+
return getU8Encoder().encode(SYNC_METADATA_TO_TOKEN2022_DISCRIMINATOR);
|
|
489
|
+
}
|
|
490
|
+
function getSyncMetadataToToken2022InstructionDataEncoder() {
|
|
491
|
+
return transformEncoder(
|
|
492
|
+
getStructEncoder([["discriminator", getU8Encoder()]]),
|
|
493
|
+
(value) => ({
|
|
494
|
+
...value,
|
|
495
|
+
discriminator: SYNC_METADATA_TO_TOKEN2022_DISCRIMINATOR
|
|
496
|
+
})
|
|
497
|
+
);
|
|
498
|
+
}
|
|
499
|
+
function getSyncMetadataToToken2022InstructionDataDecoder() {
|
|
500
|
+
return getStructDecoder([["discriminator", getU8Decoder()]]);
|
|
501
|
+
}
|
|
502
|
+
function getSyncMetadataToToken2022InstructionDataCodec() {
|
|
503
|
+
return combineCodec(
|
|
504
|
+
getSyncMetadataToToken2022InstructionDataEncoder(),
|
|
505
|
+
getSyncMetadataToToken2022InstructionDataDecoder()
|
|
506
|
+
);
|
|
507
|
+
}
|
|
508
|
+
function getSyncMetadataToToken2022Instruction(input, config) {
|
|
509
|
+
const programAddress = config?.programAddress ?? TOKEN_WRAP_PROGRAM_ADDRESS;
|
|
510
|
+
const originalAccounts = {
|
|
511
|
+
wrappedMint: { value: input.wrappedMint ?? null, isWritable: true },
|
|
512
|
+
wrappedMintAuthority: {
|
|
513
|
+
value: input.wrappedMintAuthority ?? null,
|
|
514
|
+
isWritable: false
|
|
515
|
+
},
|
|
516
|
+
unwrappedMint: { value: input.unwrappedMint ?? null, isWritable: false },
|
|
517
|
+
token2022Program: {
|
|
518
|
+
value: input.token2022Program ?? null,
|
|
519
|
+
isWritable: false
|
|
520
|
+
},
|
|
521
|
+
sourceMetadata: { value: input.sourceMetadata ?? null, isWritable: false },
|
|
522
|
+
ownerProgram: { value: input.ownerProgram ?? null, isWritable: false }
|
|
523
|
+
};
|
|
524
|
+
const accounts = originalAccounts;
|
|
525
|
+
if (!accounts.token2022Program.value) {
|
|
526
|
+
accounts.token2022Program.value = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
|
|
527
|
+
}
|
|
528
|
+
const getAccountMeta = getAccountMetaFactory(programAddress);
|
|
529
|
+
return Object.freeze({
|
|
530
|
+
accounts: [
|
|
531
|
+
getAccountMeta(accounts.wrappedMint),
|
|
532
|
+
getAccountMeta(accounts.wrappedMintAuthority),
|
|
533
|
+
getAccountMeta(accounts.unwrappedMint),
|
|
534
|
+
getAccountMeta(accounts.token2022Program),
|
|
535
|
+
getAccountMeta(accounts.sourceMetadata),
|
|
536
|
+
getAccountMeta(accounts.ownerProgram)
|
|
537
|
+
],
|
|
538
|
+
data: getSyncMetadataToToken2022InstructionDataEncoder().encode({}),
|
|
539
|
+
programAddress
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
function parseSyncMetadataToToken2022Instruction(instruction) {
|
|
543
|
+
if (instruction.accounts.length < 6) {
|
|
544
|
+
throw new Error("Not enough accounts");
|
|
545
|
+
}
|
|
546
|
+
let accountIndex = 0;
|
|
547
|
+
const getNextAccount = () => {
|
|
548
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
549
|
+
accountIndex += 1;
|
|
550
|
+
return accountMeta;
|
|
551
|
+
};
|
|
552
|
+
const getNextOptionalAccount = () => {
|
|
553
|
+
const accountMeta = getNextAccount();
|
|
554
|
+
return accountMeta.address === TOKEN_WRAP_PROGRAM_ADDRESS ? void 0 : accountMeta;
|
|
555
|
+
};
|
|
556
|
+
return {
|
|
557
|
+
programAddress: instruction.programAddress,
|
|
558
|
+
accounts: {
|
|
559
|
+
wrappedMint: getNextAccount(),
|
|
560
|
+
wrappedMintAuthority: getNextAccount(),
|
|
561
|
+
unwrappedMint: getNextAccount(),
|
|
562
|
+
token2022Program: getNextAccount(),
|
|
563
|
+
sourceMetadata: getNextOptionalAccount(),
|
|
564
|
+
ownerProgram: getNextOptionalAccount()
|
|
565
|
+
},
|
|
566
|
+
data: getSyncMetadataToToken2022InstructionDataDecoder().decode(
|
|
567
|
+
instruction.data
|
|
568
|
+
)
|
|
569
|
+
};
|
|
570
|
+
}
|
|
363
571
|
var UNWRAP_DISCRIMINATOR = 2;
|
|
364
572
|
function getUnwrapDiscriminatorBytes() {
|
|
365
573
|
return getU8Encoder().encode(UNWRAP_DISCRIMINATOR);
|
|
@@ -426,7 +634,7 @@ function getUnwrapInstruction(input, config) {
|
|
|
426
634
|
})
|
|
427
635
|
);
|
|
428
636
|
const getAccountMeta = getAccountMetaFactory(programAddress);
|
|
429
|
-
|
|
637
|
+
return Object.freeze({
|
|
430
638
|
accounts: [
|
|
431
639
|
getAccountMeta(accounts.unwrappedEscrow),
|
|
432
640
|
getAccountMeta(accounts.recipientUnwrappedToken),
|
|
@@ -439,12 +647,11 @@ function getUnwrapInstruction(input, config) {
|
|
|
439
647
|
getAccountMeta(accounts.transferAuthority),
|
|
440
648
|
...remainingAccounts
|
|
441
649
|
],
|
|
442
|
-
programAddress,
|
|
443
650
|
data: getUnwrapInstructionDataEncoder().encode(
|
|
444
651
|
args
|
|
445
|
-
)
|
|
446
|
-
|
|
447
|
-
|
|
652
|
+
),
|
|
653
|
+
programAddress
|
|
654
|
+
});
|
|
448
655
|
}
|
|
449
656
|
function parseUnwrapInstruction(instruction) {
|
|
450
657
|
if (instruction.accounts.length < 9) {
|
|
@@ -538,7 +745,7 @@ function getWrapInstruction(input, config) {
|
|
|
538
745
|
})
|
|
539
746
|
);
|
|
540
747
|
const getAccountMeta = getAccountMetaFactory(programAddress);
|
|
541
|
-
|
|
748
|
+
return Object.freeze({
|
|
542
749
|
accounts: [
|
|
543
750
|
getAccountMeta(accounts.recipientWrappedTokenAccount),
|
|
544
751
|
getAccountMeta(accounts.wrappedMint),
|
|
@@ -551,12 +758,11 @@ function getWrapInstruction(input, config) {
|
|
|
551
758
|
getAccountMeta(accounts.transferAuthority),
|
|
552
759
|
...remainingAccounts
|
|
553
760
|
],
|
|
554
|
-
programAddress,
|
|
555
761
|
data: getWrapInstructionDataEncoder().encode(
|
|
556
762
|
args
|
|
557
|
-
)
|
|
558
|
-
|
|
559
|
-
|
|
763
|
+
),
|
|
764
|
+
programAddress
|
|
765
|
+
});
|
|
560
766
|
}
|
|
561
767
|
function parseWrapInstruction(instruction) {
|
|
562
768
|
if (instruction.accounts.length < 9) {
|
|
@@ -584,6 +790,17 @@ function parseWrapInstruction(instruction) {
|
|
|
584
790
|
data: getWrapInstructionDataDecoder().decode(instruction.data)
|
|
585
791
|
};
|
|
586
792
|
}
|
|
793
|
+
var DEFAULT_EXTENSIONS = [
|
|
794
|
+
extension("ConfidentialTransferMint", {
|
|
795
|
+
autoApproveNewAccounts: true,
|
|
796
|
+
authority: null,
|
|
797
|
+
auditorElgamalPubkey: null
|
|
798
|
+
}),
|
|
799
|
+
extension("MetadataPointer", {
|
|
800
|
+
authority: null,
|
|
801
|
+
metadataAddress: null
|
|
802
|
+
})
|
|
803
|
+
];
|
|
587
804
|
async function createMint({
|
|
588
805
|
rpc,
|
|
589
806
|
unwrappedMint,
|
|
@@ -598,7 +815,10 @@ async function createMint({
|
|
|
598
815
|
const [backpointer] = await findBackpointerPda({ wrappedMint });
|
|
599
816
|
const instructions = [];
|
|
600
817
|
let fundedWrappedMintLamports = 0n;
|
|
601
|
-
|
|
818
|
+
let mintSize = BigInt(getMintSize());
|
|
819
|
+
if (wrappedTokenProgram === TOKEN_2022_PROGRAM_ADDRESS) {
|
|
820
|
+
mintSize = BigInt(getMintSize(DEFAULT_EXTENSIONS));
|
|
821
|
+
}
|
|
602
822
|
const [wrappedMintAccount, wrappedMintRent] = await Promise.all([
|
|
603
823
|
fetchEncodedAccount(rpc, wrappedMint),
|
|
604
824
|
rpc.getMinimumBalanceForRentExemption(mintSize).send()
|
|
@@ -738,7 +958,8 @@ function combinedMultisigTx({
|
|
|
738
958
|
signatures: combineSignatures(signedTxs),
|
|
739
959
|
lifetimeConstraint: blockhash
|
|
740
960
|
};
|
|
741
|
-
|
|
961
|
+
assertIsFullySignedTransaction(tx);
|
|
962
|
+
assertIsSendableTransaction(tx);
|
|
742
963
|
return tx;
|
|
743
964
|
}
|
|
744
965
|
async function multisigOfflineSignWrap(args) {
|
|
@@ -980,6 +1201,6 @@ async function multisigOfflineSignUnwrap(args) {
|
|
|
980
1201
|
);
|
|
981
1202
|
}
|
|
982
1203
|
|
|
983
|
-
export { CLOSE_STUCK_ESCROW_DISCRIMINATOR, CREATE_MINT_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__INVALID_BACKPOINTER_OWNER, TOKEN_WRAP_ERROR__INVALID_WRAPPED_MINT_OWNER, TOKEN_WRAP_ERROR__MINT_AUTHORITY_MISMATCH, 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, getTokenWrapErrorMessage, getUnwrapDiscriminatorBytes, getUnwrapInstruction, getUnwrapInstructionDataCodec, getUnwrapInstructionDataDecoder, getUnwrapInstructionDataEncoder, getWrapDiscriminatorBytes, getWrapInstruction, getWrapInstructionDataCodec, getWrapInstructionDataDecoder, getWrapInstructionDataEncoder, identifyTokenWrapInstruction, isTokenWrapError, multisigOfflineSignUnwrap, multisigOfflineSignWrap, parseCloseStuckEscrowInstruction, parseCreateMintInstruction, parseUnwrapInstruction, parseWrapInstruction, singleSignerUnwrap, singleSignerWrap };
|
|
1204
|
+
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 };
|
|
984
1205
|
//# sourceMappingURL=index.mjs.map
|
|
985
1206
|
//# sourceMappingURL=index.mjs.map
|