@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.js
CHANGED
|
@@ -101,6 +101,8 @@ var TokenWrapInstruction = /* @__PURE__ */ ((TokenWrapInstruction2) => {
|
|
|
101
101
|
TokenWrapInstruction2[TokenWrapInstruction2["Wrap"] = 1] = "Wrap";
|
|
102
102
|
TokenWrapInstruction2[TokenWrapInstruction2["Unwrap"] = 2] = "Unwrap";
|
|
103
103
|
TokenWrapInstruction2[TokenWrapInstruction2["CloseStuckEscrow"] = 3] = "CloseStuckEscrow";
|
|
104
|
+
TokenWrapInstruction2[TokenWrapInstruction2["SyncMetadataToToken2022"] = 4] = "SyncMetadataToToken2022";
|
|
105
|
+
TokenWrapInstruction2[TokenWrapInstruction2["SyncMetadataToSplToken"] = 5] = "SyncMetadataToSplToken";
|
|
104
106
|
return TokenWrapInstruction2;
|
|
105
107
|
})(TokenWrapInstruction || {});
|
|
106
108
|
function identifyTokenWrapInstruction(instruction) {
|
|
@@ -117,6 +119,12 @@ function identifyTokenWrapInstruction(instruction) {
|
|
|
117
119
|
if (kit.containsBytes(data, kit.getU8Encoder().encode(3), 0)) {
|
|
118
120
|
return 3 /* CloseStuckEscrow */;
|
|
119
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
|
+
}
|
|
120
128
|
throw new Error(
|
|
121
129
|
"The provided instruction could not be identified as a tokenWrap instruction."
|
|
122
130
|
);
|
|
@@ -132,6 +140,13 @@ var TOKEN_WRAP_ERROR__INVALID_WRAPPED_MINT_OWNER = 5;
|
|
|
132
140
|
var TOKEN_WRAP_ERROR__INVALID_BACKPOINTER_OWNER = 6;
|
|
133
141
|
var TOKEN_WRAP_ERROR__ESCROW_MISMATCH = 7;
|
|
134
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;
|
|
135
150
|
var tokenWrapErrorMessages;
|
|
136
151
|
if (process.env.NODE_ENV !== "production") {
|
|
137
152
|
tokenWrapErrorMessages = {
|
|
@@ -139,9 +154,16 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
139
154
|
[TOKEN_WRAP_ERROR__ESCROW_IN_GOOD_STATE]: `The escrow account is in a good state and cannot be recreated`,
|
|
140
155
|
[TOKEN_WRAP_ERROR__ESCROW_MISMATCH]: `Escrow account address does not match expected ATA`,
|
|
141
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`,
|
|
142
158
|
[TOKEN_WRAP_ERROR__INVALID_BACKPOINTER_OWNER]: `Wrapped backpointer account owner is not the expected token wrap program`,
|
|
143
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`,
|
|
144
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`,
|
|
145
167
|
[TOKEN_WRAP_ERROR__WRAPPED_MINT_MISMATCH]: `Wrapped mint account address does not match expected PDA`,
|
|
146
168
|
[TOKEN_WRAP_ERROR__ZERO_WRAP_AMOUNT]: `Wrap amount should be positive`
|
|
147
169
|
};
|
|
@@ -233,7 +255,7 @@ function getCloseStuckEscrowInstruction(input, config) {
|
|
|
233
255
|
accounts.token2022Program.value = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
|
|
234
256
|
}
|
|
235
257
|
const getAccountMeta = getAccountMetaFactory(programAddress);
|
|
236
|
-
|
|
258
|
+
return Object.freeze({
|
|
237
259
|
accounts: [
|
|
238
260
|
getAccountMeta(accounts.escrow),
|
|
239
261
|
getAccountMeta(accounts.destination),
|
|
@@ -242,10 +264,9 @@ function getCloseStuckEscrowInstruction(input, config) {
|
|
|
242
264
|
getAccountMeta(accounts.wrappedMintAuthority),
|
|
243
265
|
getAccountMeta(accounts.token2022Program)
|
|
244
266
|
],
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
};
|
|
248
|
-
return instruction;
|
|
267
|
+
data: getCloseStuckEscrowInstructionDataEncoder().encode({}),
|
|
268
|
+
programAddress
|
|
269
|
+
});
|
|
249
270
|
}
|
|
250
271
|
function parseCloseStuckEscrowInstruction(instruction) {
|
|
251
272
|
if (instruction.accounts.length < 6) {
|
|
@@ -321,7 +342,7 @@ function getCreateMintInstruction(input, config) {
|
|
|
321
342
|
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
322
343
|
}
|
|
323
344
|
const getAccountMeta = getAccountMetaFactory(programAddress);
|
|
324
|
-
|
|
345
|
+
return Object.freeze({
|
|
325
346
|
accounts: [
|
|
326
347
|
getAccountMeta(accounts.wrappedMint),
|
|
327
348
|
getAccountMeta(accounts.backpointer),
|
|
@@ -329,12 +350,11 @@ function getCreateMintInstruction(input, config) {
|
|
|
329
350
|
getAccountMeta(accounts.systemProgram),
|
|
330
351
|
getAccountMeta(accounts.wrappedTokenProgram)
|
|
331
352
|
],
|
|
332
|
-
programAddress,
|
|
333
353
|
data: getCreateMintInstructionDataEncoder().encode(
|
|
334
354
|
args
|
|
335
|
-
)
|
|
336
|
-
|
|
337
|
-
|
|
355
|
+
),
|
|
356
|
+
programAddress
|
|
357
|
+
});
|
|
338
358
|
}
|
|
339
359
|
function parseCreateMintInstruction(instruction) {
|
|
340
360
|
if (instruction.accounts.length < 5) {
|
|
@@ -362,6 +382,194 @@ function parseCreateMintInstruction(instruction) {
|
|
|
362
382
|
data: getCreateMintInstructionDataDecoder().decode(instruction.data)
|
|
363
383
|
};
|
|
364
384
|
}
|
|
385
|
+
var SYNC_METADATA_TO_SPL_TOKEN_DISCRIMINATOR = 5;
|
|
386
|
+
function getSyncMetadataToSplTokenDiscriminatorBytes() {
|
|
387
|
+
return kit.getU8Encoder().encode(SYNC_METADATA_TO_SPL_TOKEN_DISCRIMINATOR);
|
|
388
|
+
}
|
|
389
|
+
function getSyncMetadataToSplTokenInstructionDataEncoder() {
|
|
390
|
+
return kit.transformEncoder(
|
|
391
|
+
kit.getStructEncoder([["discriminator", kit.getU8Encoder()]]),
|
|
392
|
+
(value) => ({
|
|
393
|
+
...value,
|
|
394
|
+
discriminator: SYNC_METADATA_TO_SPL_TOKEN_DISCRIMINATOR
|
|
395
|
+
})
|
|
396
|
+
);
|
|
397
|
+
}
|
|
398
|
+
function getSyncMetadataToSplTokenInstructionDataDecoder() {
|
|
399
|
+
return kit.getStructDecoder([["discriminator", kit.getU8Decoder()]]);
|
|
400
|
+
}
|
|
401
|
+
function getSyncMetadataToSplTokenInstructionDataCodec() {
|
|
402
|
+
return kit.combineCodec(
|
|
403
|
+
getSyncMetadataToSplTokenInstructionDataEncoder(),
|
|
404
|
+
getSyncMetadataToSplTokenInstructionDataDecoder()
|
|
405
|
+
);
|
|
406
|
+
}
|
|
407
|
+
function getSyncMetadataToSplTokenInstruction(input, config) {
|
|
408
|
+
const programAddress = config?.programAddress ?? TOKEN_WRAP_PROGRAM_ADDRESS;
|
|
409
|
+
const originalAccounts = {
|
|
410
|
+
metaplexMetadata: {
|
|
411
|
+
value: input.metaplexMetadata ?? null,
|
|
412
|
+
isWritable: true
|
|
413
|
+
},
|
|
414
|
+
wrappedMintAuthority: {
|
|
415
|
+
value: input.wrappedMintAuthority ?? null,
|
|
416
|
+
isWritable: true
|
|
417
|
+
},
|
|
418
|
+
wrappedMint: { value: input.wrappedMint ?? null, isWritable: false },
|
|
419
|
+
unwrappedMint: { value: input.unwrappedMint ?? null, isWritable: false },
|
|
420
|
+
metaplexProgram: {
|
|
421
|
+
value: input.metaplexProgram ?? null,
|
|
422
|
+
isWritable: false
|
|
423
|
+
},
|
|
424
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
425
|
+
rentSysvar: { value: input.rentSysvar ?? null, isWritable: false },
|
|
426
|
+
sourceMetadata: { value: input.sourceMetadata ?? null, isWritable: false },
|
|
427
|
+
ownerProgram: { value: input.ownerProgram ?? null, isWritable: false }
|
|
428
|
+
};
|
|
429
|
+
const accounts = originalAccounts;
|
|
430
|
+
if (!accounts.metaplexProgram.value) {
|
|
431
|
+
accounts.metaplexProgram.value = "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s";
|
|
432
|
+
}
|
|
433
|
+
if (!accounts.systemProgram.value) {
|
|
434
|
+
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
435
|
+
}
|
|
436
|
+
if (!accounts.rentSysvar.value) {
|
|
437
|
+
accounts.rentSysvar.value = "SysvarRent111111111111111111111111111111111";
|
|
438
|
+
}
|
|
439
|
+
const getAccountMeta = getAccountMetaFactory(programAddress);
|
|
440
|
+
return Object.freeze({
|
|
441
|
+
accounts: [
|
|
442
|
+
getAccountMeta(accounts.metaplexMetadata),
|
|
443
|
+
getAccountMeta(accounts.wrappedMintAuthority),
|
|
444
|
+
getAccountMeta(accounts.wrappedMint),
|
|
445
|
+
getAccountMeta(accounts.unwrappedMint),
|
|
446
|
+
getAccountMeta(accounts.metaplexProgram),
|
|
447
|
+
getAccountMeta(accounts.systemProgram),
|
|
448
|
+
getAccountMeta(accounts.rentSysvar),
|
|
449
|
+
getAccountMeta(accounts.sourceMetadata),
|
|
450
|
+
getAccountMeta(accounts.ownerProgram)
|
|
451
|
+
],
|
|
452
|
+
data: getSyncMetadataToSplTokenInstructionDataEncoder().encode({}),
|
|
453
|
+
programAddress
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
function parseSyncMetadataToSplTokenInstruction(instruction) {
|
|
457
|
+
if (instruction.accounts.length < 9) {
|
|
458
|
+
throw new Error("Not enough accounts");
|
|
459
|
+
}
|
|
460
|
+
let accountIndex = 0;
|
|
461
|
+
const getNextAccount = () => {
|
|
462
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
463
|
+
accountIndex += 1;
|
|
464
|
+
return accountMeta;
|
|
465
|
+
};
|
|
466
|
+
const getNextOptionalAccount = () => {
|
|
467
|
+
const accountMeta = getNextAccount();
|
|
468
|
+
return accountMeta.address === TOKEN_WRAP_PROGRAM_ADDRESS ? void 0 : accountMeta;
|
|
469
|
+
};
|
|
470
|
+
return {
|
|
471
|
+
programAddress: instruction.programAddress,
|
|
472
|
+
accounts: {
|
|
473
|
+
metaplexMetadata: getNextAccount(),
|
|
474
|
+
wrappedMintAuthority: getNextAccount(),
|
|
475
|
+
wrappedMint: getNextAccount(),
|
|
476
|
+
unwrappedMint: getNextAccount(),
|
|
477
|
+
metaplexProgram: getNextAccount(),
|
|
478
|
+
systemProgram: getNextAccount(),
|
|
479
|
+
rentSysvar: getNextAccount(),
|
|
480
|
+
sourceMetadata: getNextOptionalAccount(),
|
|
481
|
+
ownerProgram: getNextOptionalAccount()
|
|
482
|
+
},
|
|
483
|
+
data: getSyncMetadataToSplTokenInstructionDataDecoder().decode(
|
|
484
|
+
instruction.data
|
|
485
|
+
)
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
var SYNC_METADATA_TO_TOKEN2022_DISCRIMINATOR = 4;
|
|
489
|
+
function getSyncMetadataToToken2022DiscriminatorBytes() {
|
|
490
|
+
return kit.getU8Encoder().encode(SYNC_METADATA_TO_TOKEN2022_DISCRIMINATOR);
|
|
491
|
+
}
|
|
492
|
+
function getSyncMetadataToToken2022InstructionDataEncoder() {
|
|
493
|
+
return kit.transformEncoder(
|
|
494
|
+
kit.getStructEncoder([["discriminator", kit.getU8Encoder()]]),
|
|
495
|
+
(value) => ({
|
|
496
|
+
...value,
|
|
497
|
+
discriminator: SYNC_METADATA_TO_TOKEN2022_DISCRIMINATOR
|
|
498
|
+
})
|
|
499
|
+
);
|
|
500
|
+
}
|
|
501
|
+
function getSyncMetadataToToken2022InstructionDataDecoder() {
|
|
502
|
+
return kit.getStructDecoder([["discriminator", kit.getU8Decoder()]]);
|
|
503
|
+
}
|
|
504
|
+
function getSyncMetadataToToken2022InstructionDataCodec() {
|
|
505
|
+
return kit.combineCodec(
|
|
506
|
+
getSyncMetadataToToken2022InstructionDataEncoder(),
|
|
507
|
+
getSyncMetadataToToken2022InstructionDataDecoder()
|
|
508
|
+
);
|
|
509
|
+
}
|
|
510
|
+
function getSyncMetadataToToken2022Instruction(input, config) {
|
|
511
|
+
const programAddress = config?.programAddress ?? TOKEN_WRAP_PROGRAM_ADDRESS;
|
|
512
|
+
const originalAccounts = {
|
|
513
|
+
wrappedMint: { value: input.wrappedMint ?? null, isWritable: true },
|
|
514
|
+
wrappedMintAuthority: {
|
|
515
|
+
value: input.wrappedMintAuthority ?? null,
|
|
516
|
+
isWritable: false
|
|
517
|
+
},
|
|
518
|
+
unwrappedMint: { value: input.unwrappedMint ?? null, isWritable: false },
|
|
519
|
+
token2022Program: {
|
|
520
|
+
value: input.token2022Program ?? null,
|
|
521
|
+
isWritable: false
|
|
522
|
+
},
|
|
523
|
+
sourceMetadata: { value: input.sourceMetadata ?? null, isWritable: false },
|
|
524
|
+
ownerProgram: { value: input.ownerProgram ?? null, isWritable: false }
|
|
525
|
+
};
|
|
526
|
+
const accounts = originalAccounts;
|
|
527
|
+
if (!accounts.token2022Program.value) {
|
|
528
|
+
accounts.token2022Program.value = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
|
|
529
|
+
}
|
|
530
|
+
const getAccountMeta = getAccountMetaFactory(programAddress);
|
|
531
|
+
return Object.freeze({
|
|
532
|
+
accounts: [
|
|
533
|
+
getAccountMeta(accounts.wrappedMint),
|
|
534
|
+
getAccountMeta(accounts.wrappedMintAuthority),
|
|
535
|
+
getAccountMeta(accounts.unwrappedMint),
|
|
536
|
+
getAccountMeta(accounts.token2022Program),
|
|
537
|
+
getAccountMeta(accounts.sourceMetadata),
|
|
538
|
+
getAccountMeta(accounts.ownerProgram)
|
|
539
|
+
],
|
|
540
|
+
data: getSyncMetadataToToken2022InstructionDataEncoder().encode({}),
|
|
541
|
+
programAddress
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
function parseSyncMetadataToToken2022Instruction(instruction) {
|
|
545
|
+
if (instruction.accounts.length < 6) {
|
|
546
|
+
throw new Error("Not enough accounts");
|
|
547
|
+
}
|
|
548
|
+
let accountIndex = 0;
|
|
549
|
+
const getNextAccount = () => {
|
|
550
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
551
|
+
accountIndex += 1;
|
|
552
|
+
return accountMeta;
|
|
553
|
+
};
|
|
554
|
+
const getNextOptionalAccount = () => {
|
|
555
|
+
const accountMeta = getNextAccount();
|
|
556
|
+
return accountMeta.address === TOKEN_WRAP_PROGRAM_ADDRESS ? void 0 : accountMeta;
|
|
557
|
+
};
|
|
558
|
+
return {
|
|
559
|
+
programAddress: instruction.programAddress,
|
|
560
|
+
accounts: {
|
|
561
|
+
wrappedMint: getNextAccount(),
|
|
562
|
+
wrappedMintAuthority: getNextAccount(),
|
|
563
|
+
unwrappedMint: getNextAccount(),
|
|
564
|
+
token2022Program: getNextAccount(),
|
|
565
|
+
sourceMetadata: getNextOptionalAccount(),
|
|
566
|
+
ownerProgram: getNextOptionalAccount()
|
|
567
|
+
},
|
|
568
|
+
data: getSyncMetadataToToken2022InstructionDataDecoder().decode(
|
|
569
|
+
instruction.data
|
|
570
|
+
)
|
|
571
|
+
};
|
|
572
|
+
}
|
|
365
573
|
var UNWRAP_DISCRIMINATOR = 2;
|
|
366
574
|
function getUnwrapDiscriminatorBytes() {
|
|
367
575
|
return kit.getU8Encoder().encode(UNWRAP_DISCRIMINATOR);
|
|
@@ -428,7 +636,7 @@ function getUnwrapInstruction(input, config) {
|
|
|
428
636
|
})
|
|
429
637
|
);
|
|
430
638
|
const getAccountMeta = getAccountMetaFactory(programAddress);
|
|
431
|
-
|
|
639
|
+
return Object.freeze({
|
|
432
640
|
accounts: [
|
|
433
641
|
getAccountMeta(accounts.unwrappedEscrow),
|
|
434
642
|
getAccountMeta(accounts.recipientUnwrappedToken),
|
|
@@ -441,12 +649,11 @@ function getUnwrapInstruction(input, config) {
|
|
|
441
649
|
getAccountMeta(accounts.transferAuthority),
|
|
442
650
|
...remainingAccounts
|
|
443
651
|
],
|
|
444
|
-
programAddress,
|
|
445
652
|
data: getUnwrapInstructionDataEncoder().encode(
|
|
446
653
|
args
|
|
447
|
-
)
|
|
448
|
-
|
|
449
|
-
|
|
654
|
+
),
|
|
655
|
+
programAddress
|
|
656
|
+
});
|
|
450
657
|
}
|
|
451
658
|
function parseUnwrapInstruction(instruction) {
|
|
452
659
|
if (instruction.accounts.length < 9) {
|
|
@@ -540,7 +747,7 @@ function getWrapInstruction(input, config) {
|
|
|
540
747
|
})
|
|
541
748
|
);
|
|
542
749
|
const getAccountMeta = getAccountMetaFactory(programAddress);
|
|
543
|
-
|
|
750
|
+
return Object.freeze({
|
|
544
751
|
accounts: [
|
|
545
752
|
getAccountMeta(accounts.recipientWrappedTokenAccount),
|
|
546
753
|
getAccountMeta(accounts.wrappedMint),
|
|
@@ -553,12 +760,11 @@ function getWrapInstruction(input, config) {
|
|
|
553
760
|
getAccountMeta(accounts.transferAuthority),
|
|
554
761
|
...remainingAccounts
|
|
555
762
|
],
|
|
556
|
-
programAddress,
|
|
557
763
|
data: getWrapInstructionDataEncoder().encode(
|
|
558
764
|
args
|
|
559
|
-
)
|
|
560
|
-
|
|
561
|
-
|
|
765
|
+
),
|
|
766
|
+
programAddress
|
|
767
|
+
});
|
|
562
768
|
}
|
|
563
769
|
function parseWrapInstruction(instruction) {
|
|
564
770
|
if (instruction.accounts.length < 9) {
|
|
@@ -586,6 +792,17 @@ function parseWrapInstruction(instruction) {
|
|
|
586
792
|
data: getWrapInstructionDataDecoder().decode(instruction.data)
|
|
587
793
|
};
|
|
588
794
|
}
|
|
795
|
+
var DEFAULT_EXTENSIONS = [
|
|
796
|
+
token2022.extension("ConfidentialTransferMint", {
|
|
797
|
+
autoApproveNewAccounts: true,
|
|
798
|
+
authority: null,
|
|
799
|
+
auditorElgamalPubkey: null
|
|
800
|
+
}),
|
|
801
|
+
token2022.extension("MetadataPointer", {
|
|
802
|
+
authority: null,
|
|
803
|
+
metadataAddress: null
|
|
804
|
+
})
|
|
805
|
+
];
|
|
589
806
|
async function createMint({
|
|
590
807
|
rpc,
|
|
591
808
|
unwrappedMint,
|
|
@@ -600,7 +817,10 @@ async function createMint({
|
|
|
600
817
|
const [backpointer] = await findBackpointerPda({ wrappedMint });
|
|
601
818
|
const instructions = [];
|
|
602
819
|
let fundedWrappedMintLamports = 0n;
|
|
603
|
-
|
|
820
|
+
let mintSize = BigInt(token2022.getMintSize());
|
|
821
|
+
if (wrappedTokenProgram === token2022.TOKEN_2022_PROGRAM_ADDRESS) {
|
|
822
|
+
mintSize = BigInt(token2022.getMintSize(DEFAULT_EXTENSIONS));
|
|
823
|
+
}
|
|
604
824
|
const [wrappedMintAccount, wrappedMintRent] = await Promise.all([
|
|
605
825
|
kit.fetchEncodedAccount(rpc, wrappedMint),
|
|
606
826
|
rpc.getMinimumBalanceForRentExemption(mintSize).send()
|
|
@@ -740,7 +960,8 @@ function combinedMultisigTx({
|
|
|
740
960
|
signatures: combineSignatures(signedTxs),
|
|
741
961
|
lifetimeConstraint: blockhash
|
|
742
962
|
};
|
|
743
|
-
kit.
|
|
963
|
+
kit.assertIsFullySignedTransaction(tx);
|
|
964
|
+
kit.assertIsSendableTransaction(tx);
|
|
744
965
|
return tx;
|
|
745
966
|
}
|
|
746
967
|
async function multisigOfflineSignWrap(args) {
|
|
@@ -984,13 +1205,22 @@ async function multisigOfflineSignUnwrap(args) {
|
|
|
984
1205
|
|
|
985
1206
|
exports.CLOSE_STUCK_ESCROW_DISCRIMINATOR = CLOSE_STUCK_ESCROW_DISCRIMINATOR;
|
|
986
1207
|
exports.CREATE_MINT_DISCRIMINATOR = CREATE_MINT_DISCRIMINATOR;
|
|
1208
|
+
exports.SYNC_METADATA_TO_SPL_TOKEN_DISCRIMINATOR = SYNC_METADATA_TO_SPL_TOKEN_DISCRIMINATOR;
|
|
1209
|
+
exports.SYNC_METADATA_TO_TOKEN2022_DISCRIMINATOR = SYNC_METADATA_TO_TOKEN2022_DISCRIMINATOR;
|
|
987
1210
|
exports.TOKEN_WRAP_ERROR__BACKPOINTER_MISMATCH = TOKEN_WRAP_ERROR__BACKPOINTER_MISMATCH;
|
|
988
1211
|
exports.TOKEN_WRAP_ERROR__ESCROW_IN_GOOD_STATE = TOKEN_WRAP_ERROR__ESCROW_IN_GOOD_STATE;
|
|
989
1212
|
exports.TOKEN_WRAP_ERROR__ESCROW_MISMATCH = TOKEN_WRAP_ERROR__ESCROW_MISMATCH;
|
|
990
1213
|
exports.TOKEN_WRAP_ERROR__ESCROW_OWNER_MISMATCH = TOKEN_WRAP_ERROR__ESCROW_OWNER_MISMATCH;
|
|
1214
|
+
exports.TOKEN_WRAP_ERROR__EXTERNAL_PROGRAM_RETURNED_NO_DATA = TOKEN_WRAP_ERROR__EXTERNAL_PROGRAM_RETURNED_NO_DATA;
|
|
991
1215
|
exports.TOKEN_WRAP_ERROR__INVALID_BACKPOINTER_OWNER = TOKEN_WRAP_ERROR__INVALID_BACKPOINTER_OWNER;
|
|
992
1216
|
exports.TOKEN_WRAP_ERROR__INVALID_WRAPPED_MINT_OWNER = TOKEN_WRAP_ERROR__INVALID_WRAPPED_MINT_OWNER;
|
|
1217
|
+
exports.TOKEN_WRAP_ERROR__METADATA_POINTER_MISMATCH = TOKEN_WRAP_ERROR__METADATA_POINTER_MISMATCH;
|
|
1218
|
+
exports.TOKEN_WRAP_ERROR__METADATA_POINTER_MISSING = TOKEN_WRAP_ERROR__METADATA_POINTER_MISSING;
|
|
1219
|
+
exports.TOKEN_WRAP_ERROR__METADATA_POINTER_UNSET = TOKEN_WRAP_ERROR__METADATA_POINTER_UNSET;
|
|
1220
|
+
exports.TOKEN_WRAP_ERROR__METAPLEX_METADATA_MISMATCH = TOKEN_WRAP_ERROR__METAPLEX_METADATA_MISMATCH;
|
|
993
1221
|
exports.TOKEN_WRAP_ERROR__MINT_AUTHORITY_MISMATCH = TOKEN_WRAP_ERROR__MINT_AUTHORITY_MISMATCH;
|
|
1222
|
+
exports.TOKEN_WRAP_ERROR__NO_SYNCING_TO_TOKEN2022 = TOKEN_WRAP_ERROR__NO_SYNCING_TO_TOKEN2022;
|
|
1223
|
+
exports.TOKEN_WRAP_ERROR__UNWRAPPED_MINT_HAS_NO_METADATA = TOKEN_WRAP_ERROR__UNWRAPPED_MINT_HAS_NO_METADATA;
|
|
994
1224
|
exports.TOKEN_WRAP_ERROR__WRAPPED_MINT_MISMATCH = TOKEN_WRAP_ERROR__WRAPPED_MINT_MISMATCH;
|
|
995
1225
|
exports.TOKEN_WRAP_ERROR__ZERO_WRAP_AMOUNT = TOKEN_WRAP_ERROR__ZERO_WRAP_AMOUNT;
|
|
996
1226
|
exports.TOKEN_WRAP_PROGRAM_ADDRESS = TOKEN_WRAP_PROGRAM_ADDRESS;
|
|
@@ -1025,6 +1255,16 @@ exports.getCreateMintInstruction = getCreateMintInstruction;
|
|
|
1025
1255
|
exports.getCreateMintInstructionDataCodec = getCreateMintInstructionDataCodec;
|
|
1026
1256
|
exports.getCreateMintInstructionDataDecoder = getCreateMintInstructionDataDecoder;
|
|
1027
1257
|
exports.getCreateMintInstructionDataEncoder = getCreateMintInstructionDataEncoder;
|
|
1258
|
+
exports.getSyncMetadataToSplTokenDiscriminatorBytes = getSyncMetadataToSplTokenDiscriminatorBytes;
|
|
1259
|
+
exports.getSyncMetadataToSplTokenInstruction = getSyncMetadataToSplTokenInstruction;
|
|
1260
|
+
exports.getSyncMetadataToSplTokenInstructionDataCodec = getSyncMetadataToSplTokenInstructionDataCodec;
|
|
1261
|
+
exports.getSyncMetadataToSplTokenInstructionDataDecoder = getSyncMetadataToSplTokenInstructionDataDecoder;
|
|
1262
|
+
exports.getSyncMetadataToSplTokenInstructionDataEncoder = getSyncMetadataToSplTokenInstructionDataEncoder;
|
|
1263
|
+
exports.getSyncMetadataToToken2022DiscriminatorBytes = getSyncMetadataToToken2022DiscriminatorBytes;
|
|
1264
|
+
exports.getSyncMetadataToToken2022Instruction = getSyncMetadataToToken2022Instruction;
|
|
1265
|
+
exports.getSyncMetadataToToken2022InstructionDataCodec = getSyncMetadataToToken2022InstructionDataCodec;
|
|
1266
|
+
exports.getSyncMetadataToToken2022InstructionDataDecoder = getSyncMetadataToToken2022InstructionDataDecoder;
|
|
1267
|
+
exports.getSyncMetadataToToken2022InstructionDataEncoder = getSyncMetadataToToken2022InstructionDataEncoder;
|
|
1028
1268
|
exports.getTokenWrapErrorMessage = getTokenWrapErrorMessage;
|
|
1029
1269
|
exports.getUnwrapDiscriminatorBytes = getUnwrapDiscriminatorBytes;
|
|
1030
1270
|
exports.getUnwrapInstruction = getUnwrapInstruction;
|
|
@@ -1042,6 +1282,8 @@ exports.multisigOfflineSignUnwrap = multisigOfflineSignUnwrap;
|
|
|
1042
1282
|
exports.multisigOfflineSignWrap = multisigOfflineSignWrap;
|
|
1043
1283
|
exports.parseCloseStuckEscrowInstruction = parseCloseStuckEscrowInstruction;
|
|
1044
1284
|
exports.parseCreateMintInstruction = parseCreateMintInstruction;
|
|
1285
|
+
exports.parseSyncMetadataToSplTokenInstruction = parseSyncMetadataToSplTokenInstruction;
|
|
1286
|
+
exports.parseSyncMetadataToToken2022Instruction = parseSyncMetadataToToken2022Instruction;
|
|
1045
1287
|
exports.parseUnwrapInstruction = parseUnwrapInstruction;
|
|
1046
1288
|
exports.parseWrapInstruction = parseWrapInstruction;
|
|
1047
1289
|
exports.singleSignerUnwrap = singleSignerUnwrap;
|