@layerzerolabs/oft-v2-solana-sdk 3.0.46 → 3.0.48

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.
Files changed (91) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/deployments/solana-sandbox-local/{TokenOneOFT.json → 302/TokenOneOFT.json} +5 -4
  3. package/deployments/solana-sandbox-local/{TokenThreeOFT.json → 302/TokenThreeOFT.json} +5 -4
  4. package/deployments/solana-sandbox-local/{TokenTwoOFTAdapter.json → 302/TokenTwoOFTAdapter.json} +5 -4
  5. package/deployments/solana-testnet/202/TokenOneOFT.json +16 -0
  6. package/dist/index.cjs +2101 -266
  7. package/dist/index.cjs.map +1 -1
  8. package/dist/index.d.mts +1349 -269
  9. package/dist/index.d.ts +1349 -269
  10. package/dist/index.mjs +2099 -260
  11. package/dist/index.mjs.map +1 -1
  12. package/package.json +11 -9
  13. package/src/consts.ts +5 -0
  14. package/src/generated/{accounts → oft202/accounts}/lzReceiveTypesAccounts.ts +1 -2
  15. package/src/generated/{accounts → oft202/accounts}/oFTStore.ts +1 -2
  16. package/src/generated/oft202/accounts/peerConfig.ts +178 -0
  17. package/src/generated/oft202/instructions/index.ts +18 -0
  18. package/src/generated/{instructions → oft202/instructions}/initOft.ts +1 -2
  19. package/src/generated/{instructions → oft202/instructions}/lzReceive.ts +1 -2
  20. package/src/generated/{instructions → oft202/instructions}/lzReceiveTypes.ts +1 -2
  21. package/src/generated/{instructions → oft202/instructions}/quoteOft.ts +1 -2
  22. package/src/generated/oft202/instructions/quoteSend.ts +149 -0
  23. package/src/generated/oft202/instructions/send.ts +193 -0
  24. package/src/generated/{instructions → oft202/instructions}/setOftConfig.ts +1 -2
  25. package/src/generated/{instructions → oft202/instructions}/setPause.ts +1 -2
  26. package/src/generated/{instructions → oft202/instructions}/setPeerConfig.ts +1 -2
  27. package/src/generated/{instructions → oft202/instructions}/withdrawFee.ts +1 -2
  28. package/src/generated/{programs → oft202/programs}/oft.ts +2 -2
  29. package/src/generated/oft202/types/composeParams.ts +35 -0
  30. package/src/generated/oft202/types/index.ts +22 -0
  31. package/src/generated/oft202/types/peerConfigParam.ts +143 -0
  32. package/src/generated/oft302/accounts/index.ts +11 -0
  33. package/src/generated/oft302/accounts/lzReceiveTypesAccounts.ts +167 -0
  34. package/src/generated/oft302/accounts/oFTStore.ts +198 -0
  35. package/src/generated/{accounts → oft302/accounts}/peerConfig.ts +1 -2
  36. package/src/generated/oft302/errors/index.ts +9 -0
  37. package/src/generated/oft302/errors/oft.ts +159 -0
  38. package/src/generated/oft302/index.ts +14 -0
  39. package/src/generated/oft302/instructions/initOft.ts +179 -0
  40. package/src/generated/oft302/instructions/lzReceive.ts +203 -0
  41. package/src/generated/oft302/instructions/lzReceiveTypes.ts +124 -0
  42. package/src/generated/{instructions → oft302/instructions}/oftVersion.ts +1 -2
  43. package/src/generated/oft302/instructions/quoteOft.ts +144 -0
  44. package/src/generated/{instructions → oft302/instructions}/quoteSend.ts +1 -2
  45. package/src/generated/{instructions → oft302/instructions}/send.ts +1 -2
  46. package/src/generated/oft302/instructions/setOftConfig.ts +124 -0
  47. package/src/generated/oft302/instructions/setPause.ts +119 -0
  48. package/src/generated/oft302/instructions/setPeerConfig.ts +148 -0
  49. package/src/generated/oft302/instructions/withdrawFee.ts +151 -0
  50. package/src/generated/oft302/programs/index.ts +9 -0
  51. package/src/generated/oft302/programs/oft.ts +47 -0
  52. package/src/generated/oft302/shared/index.ts +117 -0
  53. package/src/generated/oft302/types/enforcedOptions.ts +31 -0
  54. package/src/generated/oft302/types/lzAccount.ts +35 -0
  55. package/src/generated/oft302/types/lzReceiveParams.ts +50 -0
  56. package/src/generated/oft302/types/messagingFee.ts +29 -0
  57. package/src/generated/oft302/types/oFTFeeDetail.ts +34 -0
  58. package/src/generated/oft302/types/oFTLimits.ts +26 -0
  59. package/src/generated/oft302/types/oFTReceipt.ts +29 -0
  60. package/src/generated/oft302/types/oFTType.ts +23 -0
  61. package/src/generated/oft302/types/quoteOFTResult.ts +50 -0
  62. package/src/generated/oft302/types/rateLimitParams.ts +38 -0
  63. package/src/generated/oft302/types/rateLimiter.ts +38 -0
  64. package/src/generated/oft302/types/setOFTConfigParams.ts +124 -0
  65. package/src/index.ts +5 -46
  66. package/src/oft202.ts +618 -0
  67. package/src/{oft.ts → oft302.ts} +54 -55
  68. package/src/pda.ts +34 -0
  69. package/src/types.ts +40 -0
  70. /package/src/generated/{accounts → oft202/accounts}/index.ts +0 -0
  71. /package/src/generated/{errors → oft202/errors}/index.ts +0 -0
  72. /package/src/generated/{errors → oft202/errors}/oft.ts +0 -0
  73. /package/src/generated/{index.ts → oft202/index.ts} +0 -0
  74. /package/src/generated/{programs → oft202/programs}/index.ts +0 -0
  75. /package/src/generated/{shared → oft202/shared}/index.ts +0 -0
  76. /package/src/generated/{types → oft202/types}/enforcedOptions.ts +0 -0
  77. /package/src/generated/{types → oft202/types}/lzAccount.ts +0 -0
  78. /package/src/generated/{types → oft202/types}/lzReceiveParams.ts +0 -0
  79. /package/src/generated/{types → oft202/types}/messagingFee.ts +0 -0
  80. /package/src/generated/{types → oft202/types}/oFTFeeDetail.ts +0 -0
  81. /package/src/generated/{types → oft202/types}/oFTLimits.ts +0 -0
  82. /package/src/generated/{types → oft202/types}/oFTReceipt.ts +0 -0
  83. /package/src/generated/{types → oft202/types}/oFTType.ts +0 -0
  84. /package/src/generated/{types → oft202/types}/quoteOFTResult.ts +0 -0
  85. /package/src/generated/{types → oft202/types}/rateLimitParams.ts +0 -0
  86. /package/src/generated/{types → oft202/types}/rateLimiter.ts +0 -0
  87. /package/src/generated/{types → oft202/types}/setOFTConfigParams.ts +0 -0
  88. /package/src/generated/{instructions → oft302/instructions}/index.ts +0 -0
  89. /package/src/generated/{types → oft302/types}/index.ts +0 -0
  90. /package/src/generated/{types → oft302/types}/peerConfigParam.ts +0 -0
  91. /package/src/generated/{types → oft302/types}/version.ts +0 -0
package/dist/index.cjs CHANGED
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var umi = require('@metaplex-foundation/umi');
4
- var serializers = require('@metaplex-foundation/umi/serializers');
5
- var umiEddsaWeb3js = require('@metaplex-foundation/umi-eddsa-web3js');
6
- var lzSolanaSdkV2 = require('@layerzerolabs/lz-solana-sdk-v2');
7
3
  var bytes = require('@ethersproject/bytes');
4
+ var umi = require('@metaplex-foundation/umi');
8
5
  var umiProgramRepository = require('@metaplex-foundation/umi-program-repository');
9
6
  var umiWeb3jsAdapters = require('@metaplex-foundation/umi-web3js-adapters');
10
7
  var web3_js = require('@solana/web3.js');
8
+ var lzSolanaSdkV2 = require('@layerzerolabs/lz-solana-sdk-v2');
9
+ var serializers = require('@metaplex-foundation/umi/serializers');
10
+ var umiEddsaWeb3js = require('@metaplex-foundation/umi-eddsa-web3js');
11
11
 
12
12
  var __defProp = Object.defineProperty;
13
13
  var __export = (target, all) => {
@@ -15,7 +15,47 @@ var __export = (target, all) => {
15
15
  __defProp(target, name, { get: all[name], enumerable: true });
16
16
  };
17
17
 
18
- // src/generated/accounts/index.ts
18
+ // src/oft302.ts
19
+ var oft302_exports = {};
20
+ __export(oft302_exports, {
21
+ accounts: () => accounts_exports,
22
+ createOFTProgramRepo: () => createOFTProgramRepo,
23
+ errors: () => errors_exports,
24
+ getDelegate: () => getDelegate,
25
+ getEndpointConfig: () => getEndpointConfig,
26
+ getEnforcedOptions: () => getEnforcedOptions,
27
+ getPeerAddress: () => getPeerAddress,
28
+ initConfig: () => initConfig,
29
+ initOAppNonce: () => initOAppNonce,
30
+ initOft: () => initOft2,
31
+ initReceiveLibrary: () => initReceiveLibrary,
32
+ initSendLibrary: () => initSendLibrary,
33
+ instructions: () => instructions_exports,
34
+ programs: () => programs_exports,
35
+ quote: () => quote,
36
+ quoteOft: () => quoteOft2,
37
+ send: () => send2,
38
+ setConfig: () => setConfig,
39
+ setOFTConfig: () => setOFTConfig,
40
+ setPeerConfig: () => setPeerConfig2,
41
+ setReceiveLibrary: () => setReceiveLibrary,
42
+ setSendLibrary: () => setSendLibrary,
43
+ shared: () => shared_exports,
44
+ types: () => types_exports,
45
+ withdrawFee: () => withdrawFee2
46
+ });
47
+ var TOKEN_PROGRAM_ID = new web3_js.PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
48
+ new web3_js.PublicKey("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb");
49
+ new web3_js.PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");
50
+ new web3_js.PublicKey("So11111111111111111111111111111111111111112");
51
+ new web3_js.PublicKey("9pan9bMn5HatX4EJdBwg9VgCa7Uz5HL8N1m5D3NdXejP");
52
+
53
+ // src/consts.ts
54
+ var OFT_DECIMALS = 6;
55
+ var OFT_SEED = "OFT";
56
+ var PEER_SEED = "Peer";
57
+
58
+ // src/generated/oft302/accounts/index.ts
19
59
  var accounts_exports = {};
20
60
  __export(accounts_exports, {
21
61
  deserializeLzReceiveTypesAccounts: () => deserializeLzReceiveTypesAccounts,
@@ -63,17 +103,17 @@ function deserializeLzReceiveTypesAccounts(rawAccount) {
63
103
  getLzReceiveTypesAccountsAccountDataSerializer()
64
104
  );
65
105
  }
66
- async function fetchLzReceiveTypesAccounts(context, publicKey2, options) {
106
+ async function fetchLzReceiveTypesAccounts(context, publicKey3, options) {
67
107
  const maybeAccount = await context.rpc.getAccount(
68
- umi.publicKey(publicKey2, false),
108
+ umi.publicKey(publicKey3, false),
69
109
  options
70
110
  );
71
111
  umi.assertAccountExists(maybeAccount, "LzReceiveTypesAccounts");
72
112
  return deserializeLzReceiveTypesAccounts(maybeAccount);
73
113
  }
74
- async function safeFetchLzReceiveTypesAccounts(context, publicKey2, options) {
114
+ async function safeFetchLzReceiveTypesAccounts(context, publicKey3, options) {
75
115
  const maybeAccount = await context.rpc.getAccount(
76
- umi.publicKey(publicKey2, false),
116
+ umi.publicKey(publicKey3, false),
77
117
  options
78
118
  );
79
119
  return maybeAccount.exists ? deserializeLzReceiveTypesAccounts(maybeAccount) : null;
@@ -98,7 +138,7 @@ async function safeFetchAllLzReceiveTypesAccounts(context, publicKeys, options)
98
138
  );
99
139
  }
100
140
  function getLzReceiveTypesAccountsGpaBuilder(context) {
101
- const programId = context.programs.getPublicKey("oft", umi.defaultPublicKey(), "custom");
141
+ const programId = context.programs.getPublicKey("oft", "");
102
142
  return umi.gpaBuilder(context, programId).registerFields({
103
143
  discriminator: [0, serializers.bytes({ size: 8 })],
104
144
  oftStore: [8, serializers.publicKey()],
@@ -114,7 +154,7 @@ function getLzReceiveTypesAccountsSize() {
114
154
  return 72;
115
155
  }
116
156
 
117
- // src/generated/types/index.ts
157
+ // src/generated/oft302/types/index.ts
118
158
  var types_exports = {};
119
159
  __export(types_exports, {
120
160
  OFTType: () => OFTType,
@@ -205,10 +245,10 @@ function getOFTReceiptSerializer() {
205
245
  { description: "OFTReceipt" }
206
246
  );
207
247
  }
208
- var OFTType = /* @__PURE__ */ ((OFTType4) => {
209
- OFTType4[OFTType4["Native"] = 0] = "Native";
210
- OFTType4[OFTType4["Adapter"] = 1] = "Adapter";
211
- return OFTType4;
248
+ var OFTType = /* @__PURE__ */ ((OFTType7) => {
249
+ OFTType7[OFTType7["Native"] = 0] = "Native";
250
+ OFTType7[OFTType7["Adapter"] = 1] = "Adapter";
251
+ return OFTType7;
212
252
  })(OFTType || {});
213
253
  function getOFTTypeSerializer() {
214
254
  return serializers.scalarEnum(OFTType, { description: "OFTType" });
@@ -346,7 +386,7 @@ function getVersionSerializer() {
346
386
  );
347
387
  }
348
388
 
349
- // src/generated/accounts/oFTStore.ts
389
+ // src/generated/oft302/accounts/oFTStore.ts
350
390
  function getOFTStoreAccountDataSerializer() {
351
391
  return serializers.mapSerializer(
352
392
  serializers.struct(
@@ -376,17 +416,17 @@ function getOFTStoreAccountDataSerializer() {
376
416
  function deserializeOFTStore(rawAccount) {
377
417
  return umi.deserializeAccount(rawAccount, getOFTStoreAccountDataSerializer());
378
418
  }
379
- async function fetchOFTStore(context, publicKey2, options) {
419
+ async function fetchOFTStore(context, publicKey3, options) {
380
420
  const maybeAccount = await context.rpc.getAccount(
381
- umi.publicKey(publicKey2, false),
421
+ umi.publicKey(publicKey3, false),
382
422
  options
383
423
  );
384
424
  umi.assertAccountExists(maybeAccount, "OFTStore");
385
425
  return deserializeOFTStore(maybeAccount);
386
426
  }
387
- async function safeFetchOFTStore(context, publicKey2, options) {
427
+ async function safeFetchOFTStore(context, publicKey3, options) {
388
428
  const maybeAccount = await context.rpc.getAccount(
389
- umi.publicKey(publicKey2, false),
429
+ umi.publicKey(publicKey3, false),
390
430
  options
391
431
  );
392
432
  return maybeAccount.exists ? deserializeOFTStore(maybeAccount) : null;
@@ -409,7 +449,7 @@ async function safeFetchAllOFTStore(context, publicKeys, options) {
409
449
  return maybeAccounts.filter((maybeAccount) => maybeAccount.exists).map((maybeAccount) => deserializeOFTStore(maybeAccount));
410
450
  }
411
451
  function getOFTStoreGpaBuilder(context) {
412
- const programId = context.programs.getPublicKey("oft", umi.defaultPublicKey(), "custom");
452
+ const programId = context.programs.getPublicKey("oft", "");
413
453
  return umi.gpaBuilder(context, programId).registerFields({
414
454
  discriminator: [0, serializers.bytes({ size: 8 })],
415
455
  oftType: [8, getOFTTypeSerializer()],
@@ -452,17 +492,17 @@ function getPeerConfigAccountDataSerializer() {
452
492
  function deserializePeerConfig(rawAccount) {
453
493
  return umi.deserializeAccount(rawAccount, getPeerConfigAccountDataSerializer());
454
494
  }
455
- async function fetchPeerConfig(context, publicKey2, options) {
495
+ async function fetchPeerConfig(context, publicKey3, options) {
456
496
  const maybeAccount = await context.rpc.getAccount(
457
- umi.publicKey(publicKey2, false),
497
+ umi.publicKey(publicKey3, false),
458
498
  options
459
499
  );
460
500
  umi.assertAccountExists(maybeAccount, "PeerConfig");
461
501
  return deserializePeerConfig(maybeAccount);
462
502
  }
463
- async function safeFetchPeerConfig(context, publicKey2, options) {
503
+ async function safeFetchPeerConfig(context, publicKey3, options) {
464
504
  const maybeAccount = await context.rpc.getAccount(
465
- umi.publicKey(publicKey2, false),
505
+ umi.publicKey(publicKey3, false),
466
506
  options
467
507
  );
468
508
  return maybeAccount.exists ? deserializePeerConfig(maybeAccount) : null;
@@ -485,7 +525,7 @@ async function safeFetchAllPeerConfig(context, publicKeys, options) {
485
525
  return maybeAccounts.filter((maybeAccount) => maybeAccount.exists).map((maybeAccount) => deserializePeerConfig(maybeAccount));
486
526
  }
487
527
  function getPeerConfigGpaBuilder(context) {
488
- const programId = context.programs.getPublicKey("oft", umi.defaultPublicKey(), "custom");
528
+ const programId = context.programs.getPublicKey("oft", "");
489
529
  return umi.gpaBuilder(context, programId).registerFields({
490
530
  discriminator: [0, serializers.bytes({ size: 8 })],
491
531
  peerAddress: [8, serializers.bytes({ size: 32 })],
@@ -500,7 +540,123 @@ function getPeerConfigGpaBuilder(context) {
500
540
  );
501
541
  }
502
542
 
503
- // src/generated/instructions/index.ts
543
+ // src/generated/oft302/errors/index.ts
544
+ var errors_exports = {};
545
+ __export(errors_exports, {
546
+ InvalidDecimalsError: () => InvalidDecimalsError,
547
+ InvalidFeeError: () => InvalidFeeError,
548
+ InvalidMintAuthorityError: () => InvalidMintAuthorityError,
549
+ InvalidSenderError: () => InvalidSenderError,
550
+ InvalidTokenDestError: () => InvalidTokenDestError,
551
+ PausedError: () => PausedError,
552
+ RateLimitExceededError: () => RateLimitExceededError,
553
+ SlippageExceededError: () => SlippageExceededError,
554
+ UnauthorizedError: () => UnauthorizedError,
555
+ getOftErrorFromCode: () => getOftErrorFromCode,
556
+ getOftErrorFromName: () => getOftErrorFromName
557
+ });
558
+ var codeToErrorMap = /* @__PURE__ */ new Map();
559
+ var nameToErrorMap = /* @__PURE__ */ new Map();
560
+ var UnauthorizedError = class extends umi.ProgramError {
561
+ // 6000
562
+ constructor(program, cause) {
563
+ super("", program, cause);
564
+ this.name = "Unauthorized";
565
+ this.code = 6e3;
566
+ }
567
+ };
568
+ codeToErrorMap.set(6e3, UnauthorizedError);
569
+ nameToErrorMap.set("Unauthorized", UnauthorizedError);
570
+ var InvalidSenderError = class extends umi.ProgramError {
571
+ // 6001
572
+ constructor(program, cause) {
573
+ super("", program, cause);
574
+ this.name = "InvalidSender";
575
+ this.code = 6001;
576
+ }
577
+ };
578
+ codeToErrorMap.set(6001, InvalidSenderError);
579
+ nameToErrorMap.set("InvalidSender", InvalidSenderError);
580
+ var InvalidDecimalsError = class extends umi.ProgramError {
581
+ // 6002
582
+ constructor(program, cause) {
583
+ super("", program, cause);
584
+ this.name = "InvalidDecimals";
585
+ this.code = 6002;
586
+ }
587
+ };
588
+ codeToErrorMap.set(6002, InvalidDecimalsError);
589
+ nameToErrorMap.set("InvalidDecimals", InvalidDecimalsError);
590
+ var SlippageExceededError = class extends umi.ProgramError {
591
+ // 6003
592
+ constructor(program, cause) {
593
+ super("", program, cause);
594
+ this.name = "SlippageExceeded";
595
+ this.code = 6003;
596
+ }
597
+ };
598
+ codeToErrorMap.set(6003, SlippageExceededError);
599
+ nameToErrorMap.set("SlippageExceeded", SlippageExceededError);
600
+ var InvalidTokenDestError = class extends umi.ProgramError {
601
+ // 6004
602
+ constructor(program, cause) {
603
+ super("", program, cause);
604
+ this.name = "InvalidTokenDest";
605
+ this.code = 6004;
606
+ }
607
+ };
608
+ codeToErrorMap.set(6004, InvalidTokenDestError);
609
+ nameToErrorMap.set("InvalidTokenDest", InvalidTokenDestError);
610
+ var RateLimitExceededError = class extends umi.ProgramError {
611
+ // 6005
612
+ constructor(program, cause) {
613
+ super("", program, cause);
614
+ this.name = "RateLimitExceeded";
615
+ this.code = 6005;
616
+ }
617
+ };
618
+ codeToErrorMap.set(6005, RateLimitExceededError);
619
+ nameToErrorMap.set("RateLimitExceeded", RateLimitExceededError);
620
+ var InvalidFeeError = class extends umi.ProgramError {
621
+ // 6006
622
+ constructor(program, cause) {
623
+ super("", program, cause);
624
+ this.name = "InvalidFee";
625
+ this.code = 6006;
626
+ }
627
+ };
628
+ codeToErrorMap.set(6006, InvalidFeeError);
629
+ nameToErrorMap.set("InvalidFee", InvalidFeeError);
630
+ var InvalidMintAuthorityError = class extends umi.ProgramError {
631
+ // 6007
632
+ constructor(program, cause) {
633
+ super("", program, cause);
634
+ this.name = "InvalidMintAuthority";
635
+ this.code = 6007;
636
+ }
637
+ };
638
+ codeToErrorMap.set(6007, InvalidMintAuthorityError);
639
+ nameToErrorMap.set("InvalidMintAuthority", InvalidMintAuthorityError);
640
+ var PausedError = class extends umi.ProgramError {
641
+ // 6008
642
+ constructor(program, cause) {
643
+ super("", program, cause);
644
+ this.name = "Paused";
645
+ this.code = 6008;
646
+ }
647
+ };
648
+ codeToErrorMap.set(6008, PausedError);
649
+ nameToErrorMap.set("Paused", PausedError);
650
+ function getOftErrorFromCode(code, program, cause) {
651
+ const constructor = codeToErrorMap.get(code);
652
+ return constructor ? new constructor(program, cause) : null;
653
+ }
654
+ function getOftErrorFromName(name, program, cause) {
655
+ const constructor = nameToErrorMap.get(name);
656
+ return constructor ? new constructor(program, cause) : null;
657
+ }
658
+
659
+ // src/generated/oft302/instructions/index.ts
504
660
  var instructions_exports = {};
505
661
  __export(instructions_exports, {
506
662
  getInitOftInstructionDataSerializer: () => getInitOftInstructionDataSerializer,
@@ -527,7 +683,7 @@ __export(instructions_exports, {
527
683
  withdrawFee: () => withdrawFee
528
684
  });
529
685
 
530
- // src/generated/shared/index.ts
686
+ // src/generated/oft302/shared/index.ts
531
687
  var shared_exports = {};
532
688
  __export(shared_exports, {
533
689
  expectPda: () => expectPda,
@@ -574,7 +730,7 @@ function getAccountMetasAndSigners(accounts, optionalAccountStrategy, programId)
574
730
  return [keys, signers];
575
731
  }
576
732
 
577
- // src/generated/instructions/initOft.ts
733
+ // src/generated/oft302/instructions/initOft.ts
578
734
  function getInitOftInstructionDataSerializer() {
579
735
  return serializers.mapSerializer(
580
736
  serializers.struct(
@@ -594,7 +750,7 @@ function getInitOftInstructionDataSerializer() {
594
750
  );
595
751
  }
596
752
  function initOft(context, input) {
597
- const programId = context.programs.getPublicKey("oft", umi.defaultPublicKey(), "custom");
753
+ const programId = context.programs.getPublicKey("oft", "");
598
754
  const resolvedAccounts = {
599
755
  payer: {
600
756
  index: 0,
@@ -682,7 +838,7 @@ function getLzReceiveInstructionDataSerializer() {
682
838
  );
683
839
  }
684
840
  function lzReceive(context, input) {
685
- const programId = context.programs.getPublicKey("oft", umi.defaultPublicKey(), "custom");
841
+ const programId = context.programs.getPublicKey("oft", "");
686
842
  const resolvedAccounts = {
687
843
  payer: {
688
844
  index: 0,
@@ -796,7 +952,7 @@ function getLzReceiveTypesInstructionDataSerializer() {
796
952
  );
797
953
  }
798
954
  function lzReceiveTypes(context, input) {
799
- const programId = context.programs.getPublicKey("oft", umi.defaultPublicKey(), "custom");
955
+ const programId = context.programs.getPublicKey("oft", "");
800
956
  const resolvedAccounts = {
801
957
  oftStore: {
802
958
  index: 0,
@@ -838,7 +994,7 @@ function getOftVersionInstructionDataSerializer() {
838
994
  );
839
995
  }
840
996
  function oftVersion(context) {
841
- const programId = context.programs.getPublicKey("oft", umi.defaultPublicKey(), "custom");
997
+ const programId = context.programs.getPublicKey("oft", "");
842
998
  const resolvedAccounts = {};
843
999
  const orderedAccounts = Object.values(
844
1000
  resolvedAccounts
@@ -876,7 +1032,7 @@ function getQuoteOftInstructionDataSerializer() {
876
1032
  );
877
1033
  }
878
1034
  function quoteOft(context, input) {
879
- const programId = context.programs.getPublicKey("oft", umi.defaultPublicKey(), "custom");
1035
+ const programId = context.programs.getPublicKey("oft", "");
880
1036
  const resolvedAccounts = {
881
1037
  oftStore: {
882
1038
  index: 0,
@@ -929,7 +1085,7 @@ function getQuoteSendInstructionDataSerializer() {
929
1085
  );
930
1086
  }
931
1087
  function quoteSend(context, input) {
932
- const programId = context.programs.getPublicKey("oft", umi.defaultPublicKey(), "custom");
1088
+ const programId = context.programs.getPublicKey("oft", "");
933
1089
  const resolvedAccounts = {
934
1090
  oftStore: {
935
1091
  index: 0,
@@ -983,7 +1139,7 @@ function getSendInstructionDataSerializer() {
983
1139
  );
984
1140
  }
985
1141
  function send(context, input) {
986
- const programId = context.programs.getPublicKey("oft", umi.defaultPublicKey(), "custom");
1142
+ const programId = context.programs.getPublicKey("oft", "");
987
1143
  const resolvedAccounts = {
988
1144
  signer: {
989
1145
  index: 0,
@@ -1067,7 +1223,7 @@ function getSetOftConfigInstructionDataSerializer() {
1067
1223
  );
1068
1224
  }
1069
1225
  function setOftConfig(context, input) {
1070
- const programId = context.programs.getPublicKey("oft", umi.defaultPublicKey(), "custom");
1226
+ const programId = context.programs.getPublicKey("oft", "");
1071
1227
  const resolvedAccounts = {
1072
1228
  admin: {
1073
1229
  index: 0,
@@ -1113,7 +1269,7 @@ function getSetPauseInstructionDataSerializer() {
1113
1269
  );
1114
1270
  }
1115
1271
  function setPause(context, input) {
1116
- const programId = context.programs.getPublicKey("oft", umi.defaultPublicKey(), "custom");
1272
+ const programId = context.programs.getPublicKey("oft", "");
1117
1273
  const resolvedAccounts = {
1118
1274
  signer: {
1119
1275
  index: 0,
@@ -1160,7 +1316,7 @@ function getSetPeerConfigInstructionDataSerializer() {
1160
1316
  );
1161
1317
  }
1162
1318
  function setPeerConfig(context, input) {
1163
- const programId = context.programs.getPublicKey("oft", umi.defaultPublicKey(), "custom");
1319
+ const programId = context.programs.getPublicKey("oft", "");
1164
1320
  const resolvedAccounts = {
1165
1321
  admin: {
1166
1322
  index: 0,
@@ -1219,7 +1375,7 @@ function getWithdrawFeeInstructionDataSerializer() {
1219
1375
  );
1220
1376
  }
1221
1377
  function withdrawFee(context, input) {
1222
- const programId = context.programs.getPublicKey("oft", umi.defaultPublicKey(), "custom");
1378
+ const programId = context.programs.getPublicKey("oft", "");
1223
1379
  const resolvedAccounts = {
1224
1380
  admin: {
1225
1381
  index: 0,
@@ -1276,8 +1432,31 @@ function withdrawFee(context, input) {
1276
1432
  { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }
1277
1433
  ]);
1278
1434
  }
1435
+ var eddsa = umiEddsaWeb3js.createWeb3JsEddsa();
1436
+ var OftPDA = class {
1437
+ constructor(program) {
1438
+ this.program = program;
1439
+ }
1440
+ config() {
1441
+ return eddsa.findPda(this.program, [Buffer.from("OftConfig", "utf8")]);
1442
+ }
1443
+ peer(oftStore, eid) {
1444
+ return eddsa.findPda(this.program, [
1445
+ Buffer.from(PEER_SEED, "utf8"),
1446
+ umi.publicKeyBytes(oftStore),
1447
+ serializers.u32({ endian: serializers.Endian.Big }).serialize(eid)
1448
+ // new BN(eid).toArrayLike(Buffer, 'be', 4),
1449
+ ]);
1450
+ }
1451
+ oftStore(escrow) {
1452
+ return eddsa.findPda(this.program, [Buffer.from(OFT_SEED, "utf8"), umi.publicKeyBytes(escrow)]);
1453
+ }
1454
+ lzReceiveTypesAccounts(oftConfig) {
1455
+ return eddsa.findPda(this.program, [Buffer.from(lzSolanaSdkV2.LZ_RECEIVE_TYPES_SEED, "utf8"), umi.publicKeyBytes(oftConfig)]);
1456
+ }
1457
+ };
1279
1458
 
1280
- // src/generated/programs/index.ts
1459
+ // src/generated/oft302/programs/index.ts
1281
1460
  var programs_exports = {};
1282
1461
  __export(programs_exports, {
1283
1462
  OFT_PROGRAM_ID: () => OFT_PROGRAM_ID,
@@ -1286,187 +1465,62 @@ __export(programs_exports, {
1286
1465
  getOftProgramId: () => getOftProgramId
1287
1466
  });
1288
1467
 
1289
- // src/generated/errors/index.ts
1290
- var errors_exports = {};
1291
- __export(errors_exports, {
1292
- InvalidDecimalsError: () => InvalidDecimalsError,
1293
- InvalidFeeError: () => InvalidFeeError,
1294
- InvalidMintAuthorityError: () => InvalidMintAuthorityError,
1295
- InvalidSenderError: () => InvalidSenderError,
1296
- InvalidTokenDestError: () => InvalidTokenDestError,
1297
- PausedError: () => PausedError,
1298
- RateLimitExceededError: () => RateLimitExceededError,
1299
- SlippageExceededError: () => SlippageExceededError,
1300
- UnauthorizedError: () => UnauthorizedError,
1301
- getOftErrorFromCode: () => getOftErrorFromCode,
1302
- getOftErrorFromName: () => getOftErrorFromName
1303
- });
1304
- var codeToErrorMap = /* @__PURE__ */ new Map();
1305
- var nameToErrorMap = /* @__PURE__ */ new Map();
1306
- var UnauthorizedError = class extends umi.ProgramError {
1307
- // 6000
1308
- constructor(program, cause) {
1309
- super("", program, cause);
1310
- this.name = "Unauthorized";
1311
- this.code = 6e3;
1312
- }
1313
- };
1314
- codeToErrorMap.set(6e3, UnauthorizedError);
1315
- nameToErrorMap.set("Unauthorized", UnauthorizedError);
1316
- var InvalidSenderError = class extends umi.ProgramError {
1317
- // 6001
1318
- constructor(program, cause) {
1319
- super("", program, cause);
1320
- this.name = "InvalidSender";
1321
- this.code = 6001;
1322
- }
1323
- };
1324
- codeToErrorMap.set(6001, InvalidSenderError);
1325
- nameToErrorMap.set("InvalidSender", InvalidSenderError);
1326
- var InvalidDecimalsError = class extends umi.ProgramError {
1327
- // 6002
1328
- constructor(program, cause) {
1329
- super("", program, cause);
1330
- this.name = "InvalidDecimals";
1331
- this.code = 6002;
1332
- }
1333
- };
1334
- codeToErrorMap.set(6002, InvalidDecimalsError);
1335
- nameToErrorMap.set("InvalidDecimals", InvalidDecimalsError);
1336
- var SlippageExceededError = class extends umi.ProgramError {
1337
- // 6003
1338
- constructor(program, cause) {
1339
- super("", program, cause);
1340
- this.name = "SlippageExceeded";
1341
- this.code = 6003;
1468
+ // src/generated/oft302/programs/oft.ts
1469
+ var OFT_PROGRAM_ID = "";
1470
+ function createOftProgram() {
1471
+ return {
1472
+ name: "oft",
1473
+ publicKey: OFT_PROGRAM_ID,
1474
+ getErrorFromCode(code, cause) {
1475
+ return getOftErrorFromCode(code, this, cause);
1476
+ },
1477
+ getErrorFromName(name, cause) {
1478
+ return getOftErrorFromName(name, this, cause);
1479
+ },
1480
+ isOnCluster() {
1481
+ return true;
1482
+ }
1483
+ };
1484
+ }
1485
+ function getOftProgram(context, clusterFilter) {
1486
+ return context.programs.get("oft", clusterFilter);
1487
+ }
1488
+ function getOftProgramId(context, clusterFilter) {
1489
+ return context.programs.getPublicKey("oft", OFT_PROGRAM_ID, clusterFilter);
1490
+ }
1491
+
1492
+ // src/oft302.ts
1493
+ var ENDPOINT_PROGRAM_ID = umiWeb3jsAdapters.fromWeb3JsPublicKey(lzSolanaSdkV2.EndpointProgram.PROGRAM_ID);
1494
+ var ULN_PROGRAM_ID = umiWeb3jsAdapters.fromWeb3JsPublicKey(lzSolanaSdkV2.UlnProgram.PROGRAM_ID);
1495
+ function createOFTProgramRepo(oftProgram, rpc) {
1496
+ if (rpc === void 0) {
1497
+ rpc = umi.createNullRpc();
1498
+ rpc.getCluster = () => "custom";
1342
1499
  }
1343
- };
1344
- codeToErrorMap.set(6003, SlippageExceededError);
1345
- nameToErrorMap.set("SlippageExceeded", SlippageExceededError);
1346
- var InvalidTokenDestError = class extends umi.ProgramError {
1347
- // 6004
1348
- constructor(program, cause) {
1349
- super("", program, cause);
1350
- this.name = "InvalidTokenDest";
1351
- this.code = 6004;
1352
- }
1353
- };
1354
- codeToErrorMap.set(6004, InvalidTokenDestError);
1355
- nameToErrorMap.set("InvalidTokenDest", InvalidTokenDestError);
1356
- var RateLimitExceededError = class extends umi.ProgramError {
1357
- // 6005
1358
- constructor(program, cause) {
1359
- super("", program, cause);
1360
- this.name = "RateLimitExceeded";
1361
- this.code = 6005;
1362
- }
1363
- };
1364
- codeToErrorMap.set(6005, RateLimitExceededError);
1365
- nameToErrorMap.set("RateLimitExceeded", RateLimitExceededError);
1366
- var InvalidFeeError = class extends umi.ProgramError {
1367
- // 6006
1368
- constructor(program, cause) {
1369
- super("", program, cause);
1370
- this.name = "InvalidFee";
1371
- this.code = 6006;
1372
- }
1373
- };
1374
- codeToErrorMap.set(6006, InvalidFeeError);
1375
- nameToErrorMap.set("InvalidFee", InvalidFeeError);
1376
- var InvalidMintAuthorityError = class extends umi.ProgramError {
1377
- // 6007
1378
- constructor(program, cause) {
1379
- super("", program, cause);
1380
- this.name = "InvalidMintAuthority";
1381
- this.code = 6007;
1382
- }
1383
- };
1384
- codeToErrorMap.set(6007, InvalidMintAuthorityError);
1385
- nameToErrorMap.set("InvalidMintAuthority", InvalidMintAuthorityError);
1386
- var PausedError = class extends umi.ProgramError {
1387
- // 6008
1388
- constructor(program, cause) {
1389
- super("", program, cause);
1390
- this.name = "Paused";
1391
- this.code = 6008;
1392
- }
1393
- };
1394
- codeToErrorMap.set(6008, PausedError);
1395
- nameToErrorMap.set("Paused", PausedError);
1396
- function getOftErrorFromCode(code, program, cause) {
1397
- const constructor = codeToErrorMap.get(code);
1398
- return constructor ? new constructor(program, cause) : null;
1399
- }
1400
- function getOftErrorFromName(name, program, cause) {
1401
- const constructor = nameToErrorMap.get(name);
1402
- return constructor ? new constructor(program, cause) : null;
1403
- }
1404
-
1405
- // src/generated/programs/oft.ts
1406
- var OFT_PROGRAM_ID = "";
1407
- function createOftProgram(programId) {
1408
- return {
1409
- name: "oft",
1410
- publicKey: programId,
1411
- getErrorFromCode(code, cause) {
1412
- return getOftErrorFromCode(code, this, cause);
1413
- },
1414
- getErrorFromName(name, cause) {
1415
- return getOftErrorFromName(name, this, cause);
1416
- },
1417
- isOnCluster() {
1418
- return true;
1500
+ return umiProgramRepository.createDefaultProgramRepository({ rpc }, [
1501
+ {
1502
+ name: "oft",
1503
+ publicKey: oftProgram,
1504
+ getErrorFromCode(code, cause) {
1505
+ return getOftErrorFromCode(code, this, cause);
1506
+ },
1507
+ getErrorFromName(name, cause) {
1508
+ return getOftErrorFromName(name, this, cause);
1509
+ },
1510
+ isOnCluster() {
1511
+ return true;
1512
+ }
1419
1513
  }
1420
- };
1421
- }
1422
- function getOftProgram(context, clusterFilter) {
1423
- return context.programs.get("oft", clusterFilter);
1424
- }
1425
- function getOftProgramId(context, clusterFilter) {
1426
- return context.programs.getPublicKey("oft", OFT_PROGRAM_ID, clusterFilter);
1427
- }
1428
-
1429
- // src/oft.ts
1430
- var oft_exports = {};
1431
- __export(oft_exports, {
1432
- createOFTProgramRepo: () => createOFTProgramRepo,
1433
- getDelegate: () => getDelegate,
1434
- getEndpointConfig: () => getEndpointConfig,
1435
- getEnforcedOptions: () => getEnforcedOptions,
1436
- getPeerAddress: () => getPeerAddress,
1437
- initConfig: () => initConfig,
1438
- initOAppNonce: () => initOAppNonce,
1439
- initOft: () => initOft2,
1440
- initReceiveLibrary: () => initReceiveLibrary,
1441
- initSendLibrary: () => initSendLibrary,
1442
- quote: () => quote,
1443
- quoteOft: () => quoteOft2,
1444
- send: () => send2,
1445
- setConfig: () => setConfig,
1446
- setOFTConfig: () => setOFTConfig,
1447
- setPeerConfig: () => setPeerConfig2,
1448
- setReceiveLibrary: () => setReceiveLibrary,
1449
- setSendLibrary: () => setSendLibrary,
1450
- withdrawFee: () => withdrawFee2
1451
- });
1452
- var TOKEN_PROGRAM_ID = new web3_js.PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
1453
- new web3_js.PublicKey("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb");
1454
- new web3_js.PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");
1455
- new web3_js.PublicKey("So11111111111111111111111111111111111111112");
1456
- new web3_js.PublicKey("9pan9bMn5HatX4EJdBwg9VgCa7Uz5HL8N1m5D3NdXejP");
1457
- var ENDPOINT_PROGRAM_ID = umiWeb3jsAdapters.fromWeb3JsPublicKey(lzSolanaSdkV2.EndpointProgram.PROGRAM_ID);
1458
- var ULN_PROGRAM_ID = umiWeb3jsAdapters.fromWeb3JsPublicKey(lzSolanaSdkV2.UlnProgram.PROGRAM_ID);
1459
- function createOFTProgramRepo(oftProgram) {
1460
- return umiProgramRepository.createDefaultProgramRepository({ rpc: umi.createNullRpc() }, [programs_exports.createOftProgram(oftProgram)]);
1514
+ ]);
1461
1515
  }
1462
1516
  function initOft2(accounts, oftType, sharedDecimals = OFT_DECIMALS, programs) {
1463
- const deriver = new OftPDA(programs.oft);
1517
+ const programsRepo = typeof programs.oft === "string" ? createOFTProgramRepo(programs.oft) : programs.oft;
1518
+ const deriver = new OftPDA(programsRepo.getPublicKey("oft"));
1464
1519
  const endpoint = new lzSolanaSdkV2.EndpointProgram.Endpoint(umiWeb3jsAdapters.toWeb3JsPublicKey(programs.endpoint ?? ENDPOINT_PROGRAM_ID));
1465
1520
  const { payer, admin, mint, escrow } = accounts;
1466
- const programsRepo = createOFTProgramRepo(programs.oft);
1467
1521
  const [oftStore] = deriver.oftStore(escrow.publicKey);
1468
- const [lzReceiveTypes2] = deriver.lzReceiveTypesAccounts(oftStore);
1469
- const txBuilder = instructions_exports.initOft(
1522
+ const [lzReceiveTypes3] = deriver.lzReceiveTypesAccounts(oftStore);
1523
+ const txBuilder = initOft(
1470
1524
  {
1471
1525
  payer,
1472
1526
  programs: programsRepo
@@ -1474,7 +1528,7 @@ function initOft2(accounts, oftType, sharedDecimals = OFT_DECIMALS, programs) {
1474
1528
  {
1475
1529
  // accounts
1476
1530
  oftStore,
1477
- lzReceiveTypesAccounts: lzReceiveTypes2,
1531
+ lzReceiveTypesAccounts: lzReceiveTypes3,
1478
1532
  tokenMint: mint,
1479
1533
  tokenEscrow: escrow,
1480
1534
  tokenProgram: programs.token ?? umiWeb3jsAdapters.fromWeb3JsPublicKey(TOKEN_PROGRAM_ID),
@@ -1568,7 +1622,7 @@ function setOFTConfig(accounts, params, programs) {
1568
1622
  fields: [params.unpauser ? umi.some(params.unpauser) : umi.none()]
1569
1623
  };
1570
1624
  }
1571
- const txBuilder = instructions_exports.setOftConfig(
1625
+ const txBuilder = setOftConfig(
1572
1626
  { programs: createOFTProgramRepo(programs.oft) },
1573
1627
  {
1574
1628
  admin,
@@ -1587,18 +1641,19 @@ function setOFTConfig(accounts, params, programs) {
1587
1641
  ).items[0];
1588
1642
  }
1589
1643
  function setPeerConfig2(accounts, param, oftProgramId) {
1644
+ const programsRepo = typeof oftProgramId === "string" ? createOFTProgramRepo(oftProgramId) : oftProgramId;
1590
1645
  const { remote: remoteId } = param;
1591
1646
  if (remoteId % 3e4 == 0) {
1592
1647
  throw new Error("Invalid remote ID");
1593
1648
  }
1594
1649
  const { admin, oftStore } = accounts;
1595
- const [peerPda] = new OftPDA(oftProgramId).peer(oftStore, remoteId);
1650
+ const [peerPda] = new OftPDA(programsRepo.getPublicKey("oft")).peer(oftStore, remoteId);
1596
1651
  let config;
1597
1652
  if (param.__kind === "PeerAddress") {
1598
1653
  if (param.peer.length !== 32) {
1599
1654
  throw new Error("Peer must be 32 bytes (left-padded with zeroes)");
1600
1655
  }
1601
- config = types_exports.peerConfigParam("PeerAddress", [param.peer]);
1656
+ config = peerConfigParam("PeerAddress", [param.peer]);
1602
1657
  } else if (param.__kind === "FeeBps") {
1603
1658
  config = { __kind: "FeeBps", fields: [umi.some(param.feeBps)] };
1604
1659
  } else if (param.__kind === "EnforcedOptions") {
@@ -1620,8 +1675,8 @@ function setPeerConfig2(accounts, param, oftProgramId) {
1620
1675
  } else {
1621
1676
  throw new Error("Invalid peer config");
1622
1677
  }
1623
- return instructions_exports.setPeerConfig(
1624
- { programs: createOFTProgramRepo(oftProgramId) },
1678
+ return setPeerConfig(
1679
+ { programs: programsRepo },
1625
1680
  {
1626
1681
  admin,
1627
1682
  peer: peerPda,
@@ -1748,9 +1803,10 @@ async function setConfig(connection, accounts, params, programs) {
1748
1803
  }
1749
1804
  function withdrawFee2(accounts, amount, programs) {
1750
1805
  const { admin, mint, escrow, dest } = accounts;
1751
- const [oftStore] = new OftPDA(programs.oft).oftStore(escrow);
1752
- return instructions_exports.withdrawFee(
1753
- { programs: createOFTProgramRepo(programs.oft) },
1806
+ const programsRepo = typeof programs.oft === "string" ? createOFTProgramRepo(programs.oft) : programs.oft;
1807
+ const [oftStore] = new OftPDA(programsRepo.getPublicKey("oft")).oftStore(escrow);
1808
+ return withdrawFee(
1809
+ { programs: programsRepo },
1754
1810
  {
1755
1811
  admin,
1756
1812
  tokenEscrow: escrow,
@@ -1771,7 +1827,7 @@ async function send2(rpc, accounts, sendParams, programs, remainingAccounts) {
1771
1827
  const [peer] = deriver.peer(oftStore, dstEid);
1772
1828
  const connection = new web3_js.Connection(rpc.getEndpoint());
1773
1829
  if (remainingAccounts === void 0 || remainingAccounts.length === 0) {
1774
- const peerAddr = accounts.peerAddr ?? await accounts_exports.fetchPeerConfig({ rpc }, peer).then((peerInfo) => peerInfo.peerAddress);
1830
+ const peerAddr = accounts.peerAddr ?? await fetchPeerConfig({ rpc }, peer).then((peerInfo) => peerInfo.peerAddress);
1775
1831
  const endpoint = new lzSolanaSdkV2.EndpointProgram.Endpoint(umiWeb3jsAdapters.toWeb3JsPublicKey(programs.endpoint ?? ENDPOINT_PROGRAM_ID));
1776
1832
  const msgLibProgram = await getSendLibraryProgram(connection, endpoint, payer.publicKey, oftStore, dstEid);
1777
1833
  const packetPath = {
@@ -1789,7 +1845,7 @@ async function send2(rpc, accounts, sendParams, programs, remainingAccounts) {
1789
1845
  }
1790
1846
  const [eventAuthorityPDA] = new lzSolanaSdkV2.EventPDADeriver(umiWeb3jsAdapters.toWeb3JsPublicKey(programs.oft)).eventAuthority();
1791
1847
  const tokenProgram = programs.token ?? umiWeb3jsAdapters.fromWeb3JsPublicKey(TOKEN_PROGRAM_ID);
1792
- const txBuilder = instructions_exports.send(
1848
+ const txBuilder = send(
1793
1849
  { programs: createOFTProgramRepo(programs.oft) },
1794
1850
  {
1795
1851
  signer: payer,
@@ -1830,7 +1886,7 @@ async function quote(rpc, accounts, quoteParams, programs, remainingAccounts, ad
1830
1886
  const [peer] = deriver.peer(oftStore, dstEid);
1831
1887
  const connection = new web3_js.Connection(rpc.getEndpoint(), "confirmed");
1832
1888
  if (remainingAccounts === void 0 || remainingAccounts.length === 0) {
1833
- const peerAddr = accounts.peerAddr ?? await accounts_exports.fetchPeerConfig({ rpc }, peer).then((peerInfo) => peerInfo.peerAddress);
1889
+ const peerAddr = accounts.peerAddr ?? await fetchPeerConfig({ rpc }, peer).then((peerInfo) => peerInfo.peerAddress);
1834
1890
  const endpoint = new lzSolanaSdkV2.EndpointProgram.Endpoint(umiWeb3jsAdapters.toWeb3JsPublicKey(programs.endpoint ?? ENDPOINT_PROGRAM_ID));
1835
1891
  const messageLib = await getSendLibraryProgram(connection, endpoint, payer, oftStore, dstEid);
1836
1892
  remainingAccounts = await endpoint.getQuoteIXAccountMetaForCPI(
@@ -1844,7 +1900,7 @@ async function quote(rpc, accounts, quoteParams, programs, remainingAccounts, ad
1844
1900
  messageLib
1845
1901
  );
1846
1902
  }
1847
- let txBuilder = instructions_exports.quoteSend(
1903
+ let txBuilder = quoteSend(
1848
1904
  { programs: createOFTProgramRepo(programs.oft) },
1849
1905
  {
1850
1906
  oftStore,
@@ -1892,7 +1948,7 @@ async function quoteOft2(rpc, accounts, quoteParams, oftProgram) {
1892
1948
  const deriver = new OftPDA(oftProgram);
1893
1949
  const [oftStore] = deriver.oftStore(tokenEscrow);
1894
1950
  const [peer] = deriver.peer(oftStore, dstEid);
1895
- const ix = instructions_exports.quoteOft(
1951
+ const ix = quoteOft(
1896
1952
  { programs: createOFTProgramRepo(oftProgram) },
1897
1953
  {
1898
1954
  oftStore,
@@ -1917,7 +1973,7 @@ async function quoteOft2(rpc, accounts, quoteParams, oftProgram) {
1917
1973
  umiWeb3jsAdapters.toWeb3JsPublicKey(payer),
1918
1974
  "confirmed"
1919
1975
  );
1920
- const [result] = types_exports.getQuoteOFTResultSerializer().deserialize(returnedValues, 0);
1976
+ const [result] = getQuoteOFTResultSerializer().deserialize(returnedValues, 0);
1921
1977
  return result;
1922
1978
  }
1923
1979
  function initOAppNonce(accounts, remoteEid, remoteOappAddr, endpointProgram = ENDPOINT_PROGRAM_ID) {
@@ -2034,7 +2090,7 @@ async function getEndpointConfig(rpc, oftStore, endpointId, programs) {
2034
2090
  }
2035
2091
  async function getPeerAddress(rpc, oftInstance, remoteEid, oftProgramId) {
2036
2092
  const [peer] = new OftPDA(oftProgramId).peer(oftInstance, remoteEid);
2037
- const peerInfo = await accounts_exports.fetchPeerConfig({ rpc }, peer);
2093
+ const peerInfo = await fetchPeerConfig({ rpc }, peer);
2038
2094
  return bytes.hexlify(peerInfo.peerAddress);
2039
2095
  }
2040
2096
  async function getDelegate(rpc, oftInstance, endpointProgram = ENDPOINT_PROGRAM_ID) {
@@ -2049,7 +2105,7 @@ async function getDelegate(rpc, oftInstance, endpointProgram = ENDPOINT_PROGRAM_
2049
2105
  }
2050
2106
  async function getEnforcedOptions(rpc, oftInstance, remoteEid, oftProgramId) {
2051
2107
  const [peer] = new OftPDA(oftProgramId).peer(oftInstance, remoteEid);
2052
- const peerInfo = await accounts_exports.fetchPeerConfig({ rpc }, peer);
2108
+ const peerInfo = await fetchPeerConfig({ rpc }, peer);
2053
2109
  return peerInfo.enforcedOptions;
2054
2110
  }
2055
2111
  async function getSendLibraryProgram(connection, endpoint, payer, oftStore, remoteEid) {
@@ -2067,44 +2123,1823 @@ async function getSendLibraryProgram(connection, endpoint, payer, oftStore, remo
2067
2123
  throw new Error(`Unsupported message library version: ${JSON.stringify(msgLibVersion, null, 2)}`);
2068
2124
  }
2069
2125
 
2070
- // src/index.ts
2071
- var OFT_DECIMALS = 6;
2072
- var OFT_SEED = "OFT";
2073
- var PEER_SEED = "Peer";
2074
- var eddsa = umiEddsaWeb3js.createWeb3JsEddsa();
2075
- var OftPDA = class {
2076
- constructor(program) {
2077
- this.program = program;
2078
- }
2079
- config() {
2080
- return eddsa.findPda(this.program, [Buffer.from("OftConfig", "utf8")]);
2081
- }
2082
- peer(oftStore, eid) {
2083
- return eddsa.findPda(this.program, [
2084
- Buffer.from(PEER_SEED, "utf8"),
2085
- umi.publicKeyBytes(oftStore),
2086
- serializers.u32({ endian: serializers.Endian.Big }).serialize(eid)
2087
- // new BN(eid).toArrayLike(Buffer, 'be', 4),
2088
- ]);
2089
- }
2090
- oftStore(escrow) {
2091
- return eddsa.findPda(this.program, [Buffer.from(OFT_SEED, "utf8"), umi.publicKeyBytes(escrow)]);
2092
- }
2093
- lzReceiveTypesAccounts(oftConfig) {
2094
- return eddsa.findPda(this.program, [Buffer.from(lzSolanaSdkV2.LZ_RECEIVE_TYPES_SEED, "utf8"), umi.publicKeyBytes(oftConfig)]);
2095
- }
2096
- };
2126
+ // src/oft202.ts
2127
+ var oft202_exports = {};
2128
+ __export(oft202_exports, {
2129
+ accounts: () => accounts_exports2,
2130
+ createOFTProgramRepo: () => createOFTProgramRepo2,
2131
+ errors: () => errors_exports2,
2132
+ getDelegate: () => getDelegate,
2133
+ getEndpointConfig: () => getEndpointConfig,
2134
+ getEnforcedOptions: () => getEnforcedOptions,
2135
+ getPeerAddress: () => getPeerAddress,
2136
+ initConfig: () => initConfig,
2137
+ initOAppNonce: () => initOAppNonce,
2138
+ initOft: () => initOft4,
2139
+ initReceiveLibrary: () => initReceiveLibrary,
2140
+ initSendLibrary: () => initSendLibrary,
2141
+ instructions: () => instructions_exports2,
2142
+ programs: () => programs_exports2,
2143
+ quote: () => quote2,
2144
+ quoteOft: () => quoteOft4,
2145
+ send: () => send4,
2146
+ setConfig: () => setConfig,
2147
+ setOFTConfig: () => setOFTConfig2,
2148
+ setPeerConfig: () => setPeerConfig4,
2149
+ setReceiveLibrary: () => setReceiveLibrary,
2150
+ setSendLibrary: () => setSendLibrary,
2151
+ shared: () => shared_exports2,
2152
+ types: () => types_exports2,
2153
+ withdrawFee: () => withdrawFee4
2154
+ });
2155
+
2156
+ // src/generated/oft202/accounts/index.ts
2157
+ var accounts_exports2 = {};
2158
+ __export(accounts_exports2, {
2159
+ deserializeLzReceiveTypesAccounts: () => deserializeLzReceiveTypesAccounts2,
2160
+ deserializeOFTStore: () => deserializeOFTStore2,
2161
+ deserializePeerConfig: () => deserializePeerConfig2,
2162
+ fetchAllLzReceiveTypesAccounts: () => fetchAllLzReceiveTypesAccounts2,
2163
+ fetchAllOFTStore: () => fetchAllOFTStore2,
2164
+ fetchAllPeerConfig: () => fetchAllPeerConfig2,
2165
+ fetchLzReceiveTypesAccounts: () => fetchLzReceiveTypesAccounts2,
2166
+ fetchOFTStore: () => fetchOFTStore2,
2167
+ fetchPeerConfig: () => fetchPeerConfig2,
2168
+ getLzReceiveTypesAccountsAccountDataSerializer: () => getLzReceiveTypesAccountsAccountDataSerializer2,
2169
+ getLzReceiveTypesAccountsGpaBuilder: () => getLzReceiveTypesAccountsGpaBuilder2,
2170
+ getLzReceiveTypesAccountsSize: () => getLzReceiveTypesAccountsSize2,
2171
+ getOFTStoreAccountDataSerializer: () => getOFTStoreAccountDataSerializer2,
2172
+ getOFTStoreGpaBuilder: () => getOFTStoreGpaBuilder2,
2173
+ getPeerConfigAccountDataSerializer: () => getPeerConfigAccountDataSerializer2,
2174
+ getPeerConfigGpaBuilder: () => getPeerConfigGpaBuilder2,
2175
+ safeFetchAllLzReceiveTypesAccounts: () => safeFetchAllLzReceiveTypesAccounts2,
2176
+ safeFetchAllOFTStore: () => safeFetchAllOFTStore2,
2177
+ safeFetchAllPeerConfig: () => safeFetchAllPeerConfig2,
2178
+ safeFetchLzReceiveTypesAccounts: () => safeFetchLzReceiveTypesAccounts2,
2179
+ safeFetchOFTStore: () => safeFetchOFTStore2,
2180
+ safeFetchPeerConfig: () => safeFetchPeerConfig2
2181
+ });
2182
+ function getLzReceiveTypesAccountsAccountDataSerializer2() {
2183
+ return serializers.mapSerializer(
2184
+ serializers.struct(
2185
+ [
2186
+ ["discriminator", serializers.bytes({ size: 8 })],
2187
+ ["oftStore", serializers.publicKey()],
2188
+ ["tokenMint", serializers.publicKey()]
2189
+ ],
2190
+ { description: "LzReceiveTypesAccountsAccountData" }
2191
+ ),
2192
+ (value) => ({
2193
+ ...value,
2194
+ discriminator: new Uint8Array([248, 87, 167, 117, 5, 251, 21, 126])
2195
+ })
2196
+ );
2197
+ }
2198
+ function deserializeLzReceiveTypesAccounts2(rawAccount) {
2199
+ return umi.deserializeAccount(
2200
+ rawAccount,
2201
+ getLzReceiveTypesAccountsAccountDataSerializer2()
2202
+ );
2203
+ }
2204
+ async function fetchLzReceiveTypesAccounts2(context, publicKey3, options) {
2205
+ const maybeAccount = await context.rpc.getAccount(
2206
+ umi.publicKey(publicKey3, false),
2207
+ options
2208
+ );
2209
+ umi.assertAccountExists(maybeAccount, "LzReceiveTypesAccounts");
2210
+ return deserializeLzReceiveTypesAccounts2(maybeAccount);
2211
+ }
2212
+ async function safeFetchLzReceiveTypesAccounts2(context, publicKey3, options) {
2213
+ const maybeAccount = await context.rpc.getAccount(
2214
+ umi.publicKey(publicKey3, false),
2215
+ options
2216
+ );
2217
+ return maybeAccount.exists ? deserializeLzReceiveTypesAccounts2(maybeAccount) : null;
2218
+ }
2219
+ async function fetchAllLzReceiveTypesAccounts2(context, publicKeys, options) {
2220
+ const maybeAccounts = await context.rpc.getAccounts(
2221
+ publicKeys.map((key) => umi.publicKey(key, false)),
2222
+ options
2223
+ );
2224
+ return maybeAccounts.map((maybeAccount) => {
2225
+ umi.assertAccountExists(maybeAccount, "LzReceiveTypesAccounts");
2226
+ return deserializeLzReceiveTypesAccounts2(maybeAccount);
2227
+ });
2228
+ }
2229
+ async function safeFetchAllLzReceiveTypesAccounts2(context, publicKeys, options) {
2230
+ const maybeAccounts = await context.rpc.getAccounts(
2231
+ publicKeys.map((key) => umi.publicKey(key, false)),
2232
+ options
2233
+ );
2234
+ return maybeAccounts.filter((maybeAccount) => maybeAccount.exists).map(
2235
+ (maybeAccount) => deserializeLzReceiveTypesAccounts2(maybeAccount)
2236
+ );
2237
+ }
2238
+ function getLzReceiveTypesAccountsGpaBuilder2(context) {
2239
+ const programId = context.programs.getPublicKey("oft", "");
2240
+ return umi.gpaBuilder(context, programId).registerFields({
2241
+ discriminator: [0, serializers.bytes({ size: 8 })],
2242
+ oftStore: [8, serializers.publicKey()],
2243
+ tokenMint: [40, serializers.publicKey()]
2244
+ }).deserializeUsing(
2245
+ (account) => deserializeLzReceiveTypesAccounts2(account)
2246
+ ).whereField(
2247
+ "discriminator",
2248
+ new Uint8Array([248, 87, 167, 117, 5, 251, 21, 126])
2249
+ );
2250
+ }
2251
+ function getLzReceiveTypesAccountsSize2() {
2252
+ return 72;
2253
+ }
2254
+
2255
+ // src/generated/oft202/types/index.ts
2256
+ var types_exports2 = {};
2257
+ __export(types_exports2, {
2258
+ OFTType: () => OFTType4,
2259
+ getComposeParamsSerializer: () => getComposeParamsSerializer,
2260
+ getEnforcedOptionsSerializer: () => getEnforcedOptionsSerializer2,
2261
+ getLzAccountSerializer: () => getLzAccountSerializer2,
2262
+ getLzReceiveParamsSerializer: () => getLzReceiveParamsSerializer2,
2263
+ getMessagingFeeSerializer: () => getMessagingFeeSerializer2,
2264
+ getOFTFeeDetailSerializer: () => getOFTFeeDetailSerializer2,
2265
+ getOFTLimitsSerializer: () => getOFTLimitsSerializer2,
2266
+ getOFTReceiptSerializer: () => getOFTReceiptSerializer2,
2267
+ getOFTTypeSerializer: () => getOFTTypeSerializer2,
2268
+ getPeerConfigParamSerializer: () => getPeerConfigParamSerializer2,
2269
+ getQuoteOFTResultSerializer: () => getQuoteOFTResultSerializer2,
2270
+ getRateLimitParamsSerializer: () => getRateLimitParamsSerializer2,
2271
+ getRateLimiterSerializer: () => getRateLimiterSerializer2,
2272
+ getSetOFTConfigParamsSerializer: () => getSetOFTConfigParamsSerializer2,
2273
+ isPeerConfigParam: () => isPeerConfigParam2,
2274
+ isSetOFTConfigParams: () => isSetOFTConfigParams2,
2275
+ peerConfigParam: () => peerConfigParam2,
2276
+ setOFTConfigParams: () => setOFTConfigParams2
2277
+ });
2278
+ function getComposeParamsSerializer() {
2279
+ return serializers.struct(
2280
+ [
2281
+ ["composeGas", serializers.u64()],
2282
+ ["composeMsg", serializers.bytes({ size: serializers.u32() })]
2283
+ ],
2284
+ { description: "ComposeParams" }
2285
+ );
2286
+ }
2287
+ function getEnforcedOptionsSerializer2() {
2288
+ return serializers.struct(
2289
+ [
2290
+ ["send", serializers.bytes({ size: serializers.u32() })],
2291
+ ["sendAndCall", serializers.bytes({ size: serializers.u32() })]
2292
+ ],
2293
+ { description: "EnforcedOptions" }
2294
+ );
2295
+ }
2296
+ function getLzAccountSerializer2() {
2297
+ return serializers.struct(
2298
+ [
2299
+ ["pubkey", serializers.publicKey()],
2300
+ ["isSigner", serializers.bool()],
2301
+ ["isWritable", serializers.bool()]
2302
+ ],
2303
+ { description: "LzAccount" }
2304
+ );
2305
+ }
2306
+ function getLzReceiveParamsSerializer2() {
2307
+ return serializers.struct(
2308
+ [
2309
+ ["srcEid", serializers.u32()],
2310
+ ["sender", serializers.bytes({ size: 32 })],
2311
+ ["nonce", serializers.u64()],
2312
+ ["guid", serializers.bytes({ size: 32 })],
2313
+ ["message", serializers.bytes({ size: serializers.u32() })],
2314
+ ["extraData", serializers.bytes({ size: serializers.u32() })]
2315
+ ],
2316
+ { description: "LzReceiveParams" }
2317
+ );
2318
+ }
2319
+ function getMessagingFeeSerializer2() {
2320
+ return serializers.struct(
2321
+ [
2322
+ ["nativeFee", serializers.u64()],
2323
+ ["lzTokenFee", serializers.u64()]
2324
+ ],
2325
+ { description: "MessagingFee" }
2326
+ );
2327
+ }
2328
+ function getOFTFeeDetailSerializer2() {
2329
+ return serializers.struct(
2330
+ [
2331
+ ["feeAmountLd", serializers.u64()],
2332
+ ["description", serializers.string()]
2333
+ ],
2334
+ { description: "OFTFeeDetail" }
2335
+ );
2336
+ }
2337
+ function getOFTLimitsSerializer2() {
2338
+ return serializers.struct(
2339
+ [
2340
+ ["minAmountLd", serializers.u64()],
2341
+ ["maxAmountLd", serializers.u64()]
2342
+ ],
2343
+ { description: "OFTLimits" }
2344
+ );
2345
+ }
2346
+ function getOFTReceiptSerializer2() {
2347
+ return serializers.struct(
2348
+ [
2349
+ ["amountSentLd", serializers.u64()],
2350
+ ["amountReceivedLd", serializers.u64()]
2351
+ ],
2352
+ { description: "OFTReceipt" }
2353
+ );
2354
+ }
2355
+ var OFTType4 = /* @__PURE__ */ ((OFTType7) => {
2356
+ OFTType7[OFTType7["Native"] = 0] = "Native";
2357
+ OFTType7[OFTType7["Adapter"] = 1] = "Adapter";
2358
+ return OFTType7;
2359
+ })(OFTType4 || {});
2360
+ function getOFTTypeSerializer2() {
2361
+ return serializers.scalarEnum(OFTType4, { description: "OFTType" });
2362
+ }
2363
+ function getPeerConfigParamSerializer2() {
2364
+ return serializers.dataEnum(
2365
+ [
2366
+ [
2367
+ "PeerAddress",
2368
+ serializers.struct([
2369
+ ["fields", serializers.tuple([serializers.bytes({ size: 32 })])]
2370
+ ])
2371
+ ],
2372
+ [
2373
+ "FeeBps",
2374
+ serializers.struct([
2375
+ ["fields", serializers.tuple([serializers.option(serializers.u16())])]
2376
+ ])
2377
+ ],
2378
+ [
2379
+ "EnforcedOptions",
2380
+ serializers.struct([
2381
+ ["send", serializers.bytes({ size: serializers.u32() })],
2382
+ ["sendAndCall", serializers.bytes({ size: serializers.u32() })]
2383
+ ])
2384
+ ],
2385
+ [
2386
+ "OutboundRateLimit",
2387
+ serializers.struct([
2388
+ ["fields", serializers.tuple([serializers.option(getRateLimitParamsSerializer2())])]
2389
+ ])
2390
+ ],
2391
+ [
2392
+ "InboundRateLimit",
2393
+ serializers.struct([
2394
+ ["fields", serializers.tuple([serializers.option(getRateLimitParamsSerializer2())])]
2395
+ ])
2396
+ ],
2397
+ [
2398
+ "IsEndpointV1",
2399
+ serializers.struct([
2400
+ ["fields", serializers.tuple([serializers.bool()])]
2401
+ ])
2402
+ ]
2403
+ ],
2404
+ { description: "PeerConfigParam" }
2405
+ );
2406
+ }
2407
+ function peerConfigParam2(kind, data) {
2408
+ return Array.isArray(data) ? { __kind: kind, fields: data } : { __kind: kind, ...data ?? {} };
2409
+ }
2410
+ function isPeerConfigParam2(kind, value) {
2411
+ return value.__kind === kind;
2412
+ }
2413
+ function getQuoteOFTResultSerializer2() {
2414
+ return serializers.struct(
2415
+ [
2416
+ ["oftLimits", getOFTLimitsSerializer2()],
2417
+ ["oftFeeDetails", serializers.array(getOFTFeeDetailSerializer2())],
2418
+ ["oftReceipt", getOFTReceiptSerializer2()]
2419
+ ],
2420
+ { description: "QuoteOFTResult" }
2421
+ );
2422
+ }
2423
+ function getRateLimiterSerializer2() {
2424
+ return serializers.struct(
2425
+ [
2426
+ ["capacity", serializers.u64()],
2427
+ ["tokens", serializers.u64()],
2428
+ ["refillPerSecond", serializers.u64()],
2429
+ ["lastRefillTime", serializers.u64()]
2430
+ ],
2431
+ { description: "RateLimiter" }
2432
+ );
2433
+ }
2434
+ function getRateLimitParamsSerializer2() {
2435
+ return serializers.struct(
2436
+ [
2437
+ ["refillPerSecond", serializers.option(serializers.u64())],
2438
+ ["capacity", serializers.option(serializers.u64())]
2439
+ ],
2440
+ { description: "RateLimitParams" }
2441
+ );
2442
+ }
2443
+ function getSetOFTConfigParamsSerializer2() {
2444
+ return serializers.dataEnum(
2445
+ [
2446
+ [
2447
+ "Admin",
2448
+ serializers.struct([
2449
+ ["fields", serializers.tuple([serializers.publicKey()])]
2450
+ ])
2451
+ ],
2452
+ [
2453
+ "Delegate",
2454
+ serializers.struct([
2455
+ ["fields", serializers.tuple([serializers.publicKey()])]
2456
+ ])
2457
+ ],
2458
+ [
2459
+ "DefaultFee",
2460
+ serializers.struct([
2461
+ ["fields", serializers.tuple([serializers.u16()])]
2462
+ ])
2463
+ ],
2464
+ [
2465
+ "Paused",
2466
+ serializers.struct([
2467
+ ["fields", serializers.tuple([serializers.bool()])]
2468
+ ])
2469
+ ],
2470
+ [
2471
+ "Pauser",
2472
+ serializers.struct([
2473
+ ["fields", serializers.tuple([serializers.option(serializers.publicKey())])]
2474
+ ])
2475
+ ],
2476
+ [
2477
+ "Unpauser",
2478
+ serializers.struct([
2479
+ ["fields", serializers.tuple([serializers.option(serializers.publicKey())])]
2480
+ ])
2481
+ ]
2482
+ ],
2483
+ { description: "SetOFTConfigParams" }
2484
+ );
2485
+ }
2486
+ function setOFTConfigParams2(kind, data) {
2487
+ return Array.isArray(data) ? { __kind: kind, fields: data } : { __kind: kind, ...data ?? {} };
2488
+ }
2489
+ function isSetOFTConfigParams2(kind, value) {
2490
+ return value.__kind === kind;
2491
+ }
2492
+
2493
+ // src/generated/oft202/accounts/oFTStore.ts
2494
+ function getOFTStoreAccountDataSerializer2() {
2495
+ return serializers.mapSerializer(
2496
+ serializers.struct(
2497
+ [
2498
+ ["discriminator", serializers.bytes({ size: 8 })],
2499
+ ["oftType", getOFTTypeSerializer2()],
2500
+ ["ld2sdRate", serializers.u64()],
2501
+ ["tokenMint", serializers.publicKey()],
2502
+ ["tokenEscrow", serializers.publicKey()],
2503
+ ["endpointProgram", serializers.publicKey()],
2504
+ ["bump", serializers.u8()],
2505
+ ["tvlLd", serializers.u64()],
2506
+ ["admin", serializers.publicKey()],
2507
+ ["defaultFeeBps", serializers.u16()],
2508
+ ["paused", serializers.bool()],
2509
+ ["pauser", serializers.option(serializers.publicKey())],
2510
+ ["unpauser", serializers.option(serializers.publicKey())]
2511
+ ],
2512
+ { description: "OFTStoreAccountData" }
2513
+ ),
2514
+ (value) => ({
2515
+ ...value,
2516
+ discriminator: new Uint8Array([195, 215, 104, 134, 185, 195, 240, 114])
2517
+ })
2518
+ );
2519
+ }
2520
+ function deserializeOFTStore2(rawAccount) {
2521
+ return umi.deserializeAccount(rawAccount, getOFTStoreAccountDataSerializer2());
2522
+ }
2523
+ async function fetchOFTStore2(context, publicKey3, options) {
2524
+ const maybeAccount = await context.rpc.getAccount(
2525
+ umi.publicKey(publicKey3, false),
2526
+ options
2527
+ );
2528
+ umi.assertAccountExists(maybeAccount, "OFTStore");
2529
+ return deserializeOFTStore2(maybeAccount);
2530
+ }
2531
+ async function safeFetchOFTStore2(context, publicKey3, options) {
2532
+ const maybeAccount = await context.rpc.getAccount(
2533
+ umi.publicKey(publicKey3, false),
2534
+ options
2535
+ );
2536
+ return maybeAccount.exists ? deserializeOFTStore2(maybeAccount) : null;
2537
+ }
2538
+ async function fetchAllOFTStore2(context, publicKeys, options) {
2539
+ const maybeAccounts = await context.rpc.getAccounts(
2540
+ publicKeys.map((key) => umi.publicKey(key, false)),
2541
+ options
2542
+ );
2543
+ return maybeAccounts.map((maybeAccount) => {
2544
+ umi.assertAccountExists(maybeAccount, "OFTStore");
2545
+ return deserializeOFTStore2(maybeAccount);
2546
+ });
2547
+ }
2548
+ async function safeFetchAllOFTStore2(context, publicKeys, options) {
2549
+ const maybeAccounts = await context.rpc.getAccounts(
2550
+ publicKeys.map((key) => umi.publicKey(key, false)),
2551
+ options
2552
+ );
2553
+ return maybeAccounts.filter((maybeAccount) => maybeAccount.exists).map((maybeAccount) => deserializeOFTStore2(maybeAccount));
2554
+ }
2555
+ function getOFTStoreGpaBuilder2(context) {
2556
+ const programId = context.programs.getPublicKey("oft", "");
2557
+ return umi.gpaBuilder(context, programId).registerFields({
2558
+ discriminator: [0, serializers.bytes({ size: 8 })],
2559
+ oftType: [8, getOFTTypeSerializer2()],
2560
+ ld2sdRate: [9, serializers.u64()],
2561
+ tokenMint: [17, serializers.publicKey()],
2562
+ tokenEscrow: [49, serializers.publicKey()],
2563
+ endpointProgram: [81, serializers.publicKey()],
2564
+ bump: [113, serializers.u8()],
2565
+ tvlLd: [114, serializers.u64()],
2566
+ admin: [122, serializers.publicKey()],
2567
+ defaultFeeBps: [154, serializers.u16()],
2568
+ paused: [156, serializers.bool()],
2569
+ pauser: [157, serializers.option(serializers.publicKey())],
2570
+ unpauser: [null, serializers.option(serializers.publicKey())]
2571
+ }).deserializeUsing((account) => deserializeOFTStore2(account)).whereField(
2572
+ "discriminator",
2573
+ new Uint8Array([195, 215, 104, 134, 185, 195, 240, 114])
2574
+ );
2575
+ }
2576
+ function getPeerConfigAccountDataSerializer2() {
2577
+ return serializers.mapSerializer(
2578
+ serializers.struct(
2579
+ [
2580
+ ["discriminator", serializers.bytes({ size: 8 })],
2581
+ ["peerAddress", serializers.bytes({ size: 32 })],
2582
+ ["enforcedOptions", getEnforcedOptionsSerializer2()],
2583
+ ["outboundRateLimiter", serializers.option(getRateLimiterSerializer2())],
2584
+ ["inboundRateLimiter", serializers.option(getRateLimiterSerializer2())],
2585
+ ["feeBps", serializers.option(serializers.u16())],
2586
+ ["bump", serializers.u8()],
2587
+ ["isEndpointV1", serializers.bool()]
2588
+ ],
2589
+ { description: "PeerConfigAccountData" }
2590
+ ),
2591
+ (value) => ({
2592
+ ...value,
2593
+ discriminator: new Uint8Array([181, 157, 86, 198, 33, 193, 94, 203])
2594
+ })
2595
+ );
2596
+ }
2597
+ function deserializePeerConfig2(rawAccount) {
2598
+ return umi.deserializeAccount(rawAccount, getPeerConfigAccountDataSerializer2());
2599
+ }
2600
+ async function fetchPeerConfig2(context, publicKey3, options) {
2601
+ const maybeAccount = await context.rpc.getAccount(
2602
+ umi.publicKey(publicKey3, false),
2603
+ options
2604
+ );
2605
+ umi.assertAccountExists(maybeAccount, "PeerConfig");
2606
+ return deserializePeerConfig2(maybeAccount);
2607
+ }
2608
+ async function safeFetchPeerConfig2(context, publicKey3, options) {
2609
+ const maybeAccount = await context.rpc.getAccount(
2610
+ umi.publicKey(publicKey3, false),
2611
+ options
2612
+ );
2613
+ return maybeAccount.exists ? deserializePeerConfig2(maybeAccount) : null;
2614
+ }
2615
+ async function fetchAllPeerConfig2(context, publicKeys, options) {
2616
+ const maybeAccounts = await context.rpc.getAccounts(
2617
+ publicKeys.map((key) => umi.publicKey(key, false)),
2618
+ options
2619
+ );
2620
+ return maybeAccounts.map((maybeAccount) => {
2621
+ umi.assertAccountExists(maybeAccount, "PeerConfig");
2622
+ return deserializePeerConfig2(maybeAccount);
2623
+ });
2624
+ }
2625
+ async function safeFetchAllPeerConfig2(context, publicKeys, options) {
2626
+ const maybeAccounts = await context.rpc.getAccounts(
2627
+ publicKeys.map((key) => umi.publicKey(key, false)),
2628
+ options
2629
+ );
2630
+ return maybeAccounts.filter((maybeAccount) => maybeAccount.exists).map((maybeAccount) => deserializePeerConfig2(maybeAccount));
2631
+ }
2632
+ function getPeerConfigGpaBuilder2(context) {
2633
+ const programId = context.programs.getPublicKey("oft", "");
2634
+ return umi.gpaBuilder(context, programId).registerFields({
2635
+ discriminator: [0, serializers.bytes({ size: 8 })],
2636
+ peerAddress: [8, serializers.bytes({ size: 32 })],
2637
+ enforcedOptions: [40, getEnforcedOptionsSerializer2()],
2638
+ outboundRateLimiter: [null, serializers.option(getRateLimiterSerializer2())],
2639
+ inboundRateLimiter: [null, serializers.option(getRateLimiterSerializer2())],
2640
+ feeBps: [null, serializers.option(serializers.u16())],
2641
+ bump: [null, serializers.u8()],
2642
+ isEndpointV1: [null, serializers.bool()]
2643
+ }).deserializeUsing((account) => deserializePeerConfig2(account)).whereField(
2644
+ "discriminator",
2645
+ new Uint8Array([181, 157, 86, 198, 33, 193, 94, 203])
2646
+ );
2647
+ }
2648
+
2649
+ // src/generated/oft202/errors/index.ts
2650
+ var errors_exports2 = {};
2651
+ __export(errors_exports2, {
2652
+ InvalidDecimalsError: () => InvalidDecimalsError2,
2653
+ InvalidFeeError: () => InvalidFeeError2,
2654
+ InvalidMintAuthorityError: () => InvalidMintAuthorityError2,
2655
+ InvalidSenderError: () => InvalidSenderError2,
2656
+ InvalidTokenDestError: () => InvalidTokenDestError2,
2657
+ PausedError: () => PausedError2,
2658
+ RateLimitExceededError: () => RateLimitExceededError2,
2659
+ SlippageExceededError: () => SlippageExceededError2,
2660
+ UnauthorizedError: () => UnauthorizedError2,
2661
+ getOftErrorFromCode: () => getOftErrorFromCode2,
2662
+ getOftErrorFromName: () => getOftErrorFromName2
2663
+ });
2664
+ var codeToErrorMap2 = /* @__PURE__ */ new Map();
2665
+ var nameToErrorMap2 = /* @__PURE__ */ new Map();
2666
+ var UnauthorizedError2 = class extends umi.ProgramError {
2667
+ // 6000
2668
+ constructor(program, cause) {
2669
+ super("", program, cause);
2670
+ this.name = "Unauthorized";
2671
+ this.code = 6e3;
2672
+ }
2673
+ };
2674
+ codeToErrorMap2.set(6e3, UnauthorizedError2);
2675
+ nameToErrorMap2.set("Unauthorized", UnauthorizedError2);
2676
+ var InvalidSenderError2 = class extends umi.ProgramError {
2677
+ // 6001
2678
+ constructor(program, cause) {
2679
+ super("", program, cause);
2680
+ this.name = "InvalidSender";
2681
+ this.code = 6001;
2682
+ }
2683
+ };
2684
+ codeToErrorMap2.set(6001, InvalidSenderError2);
2685
+ nameToErrorMap2.set("InvalidSender", InvalidSenderError2);
2686
+ var InvalidDecimalsError2 = class extends umi.ProgramError {
2687
+ // 6002
2688
+ constructor(program, cause) {
2689
+ super("", program, cause);
2690
+ this.name = "InvalidDecimals";
2691
+ this.code = 6002;
2692
+ }
2693
+ };
2694
+ codeToErrorMap2.set(6002, InvalidDecimalsError2);
2695
+ nameToErrorMap2.set("InvalidDecimals", InvalidDecimalsError2);
2696
+ var SlippageExceededError2 = class extends umi.ProgramError {
2697
+ // 6003
2698
+ constructor(program, cause) {
2699
+ super("", program, cause);
2700
+ this.name = "SlippageExceeded";
2701
+ this.code = 6003;
2702
+ }
2703
+ };
2704
+ codeToErrorMap2.set(6003, SlippageExceededError2);
2705
+ nameToErrorMap2.set("SlippageExceeded", SlippageExceededError2);
2706
+ var InvalidTokenDestError2 = class extends umi.ProgramError {
2707
+ // 6004
2708
+ constructor(program, cause) {
2709
+ super("", program, cause);
2710
+ this.name = "InvalidTokenDest";
2711
+ this.code = 6004;
2712
+ }
2713
+ };
2714
+ codeToErrorMap2.set(6004, InvalidTokenDestError2);
2715
+ nameToErrorMap2.set("InvalidTokenDest", InvalidTokenDestError2);
2716
+ var RateLimitExceededError2 = class extends umi.ProgramError {
2717
+ // 6005
2718
+ constructor(program, cause) {
2719
+ super("", program, cause);
2720
+ this.name = "RateLimitExceeded";
2721
+ this.code = 6005;
2722
+ }
2723
+ };
2724
+ codeToErrorMap2.set(6005, RateLimitExceededError2);
2725
+ nameToErrorMap2.set("RateLimitExceeded", RateLimitExceededError2);
2726
+ var InvalidFeeError2 = class extends umi.ProgramError {
2727
+ // 6006
2728
+ constructor(program, cause) {
2729
+ super("", program, cause);
2730
+ this.name = "InvalidFee";
2731
+ this.code = 6006;
2732
+ }
2733
+ };
2734
+ codeToErrorMap2.set(6006, InvalidFeeError2);
2735
+ nameToErrorMap2.set("InvalidFee", InvalidFeeError2);
2736
+ var InvalidMintAuthorityError2 = class extends umi.ProgramError {
2737
+ // 6007
2738
+ constructor(program, cause) {
2739
+ super("", program, cause);
2740
+ this.name = "InvalidMintAuthority";
2741
+ this.code = 6007;
2742
+ }
2743
+ };
2744
+ codeToErrorMap2.set(6007, InvalidMintAuthorityError2);
2745
+ nameToErrorMap2.set("InvalidMintAuthority", InvalidMintAuthorityError2);
2746
+ var PausedError2 = class extends umi.ProgramError {
2747
+ // 6008
2748
+ constructor(program, cause) {
2749
+ super("", program, cause);
2750
+ this.name = "Paused";
2751
+ this.code = 6008;
2752
+ }
2753
+ };
2754
+ codeToErrorMap2.set(6008, PausedError2);
2755
+ nameToErrorMap2.set("Paused", PausedError2);
2756
+ function getOftErrorFromCode2(code, program, cause) {
2757
+ const constructor = codeToErrorMap2.get(code);
2758
+ return constructor ? new constructor(program, cause) : null;
2759
+ }
2760
+ function getOftErrorFromName2(name, program, cause) {
2761
+ const constructor = nameToErrorMap2.get(name);
2762
+ return constructor ? new constructor(program, cause) : null;
2763
+ }
2764
+
2765
+ // src/generated/oft202/instructions/index.ts
2766
+ var instructions_exports2 = {};
2767
+ __export(instructions_exports2, {
2768
+ getInitOftInstructionDataSerializer: () => getInitOftInstructionDataSerializer2,
2769
+ getLzReceiveInstructionDataSerializer: () => getLzReceiveInstructionDataSerializer2,
2770
+ getLzReceiveTypesInstructionDataSerializer: () => getLzReceiveTypesInstructionDataSerializer2,
2771
+ getQuoteOftInstructionDataSerializer: () => getQuoteOftInstructionDataSerializer2,
2772
+ getQuoteSendInstructionDataSerializer: () => getQuoteSendInstructionDataSerializer2,
2773
+ getSendInstructionDataSerializer: () => getSendInstructionDataSerializer2,
2774
+ getSetOftConfigInstructionDataSerializer: () => getSetOftConfigInstructionDataSerializer2,
2775
+ getSetPauseInstructionDataSerializer: () => getSetPauseInstructionDataSerializer2,
2776
+ getSetPeerConfigInstructionDataSerializer: () => getSetPeerConfigInstructionDataSerializer2,
2777
+ getWithdrawFeeInstructionDataSerializer: () => getWithdrawFeeInstructionDataSerializer2,
2778
+ initOft: () => initOft3,
2779
+ lzReceive: () => lzReceive2,
2780
+ lzReceiveTypes: () => lzReceiveTypes2,
2781
+ quoteOft: () => quoteOft3,
2782
+ quoteSend: () => quoteSend2,
2783
+ send: () => send3,
2784
+ setOftConfig: () => setOftConfig2,
2785
+ setPause: () => setPause2,
2786
+ setPeerConfig: () => setPeerConfig3,
2787
+ withdrawFee: () => withdrawFee3
2788
+ });
2789
+
2790
+ // src/generated/oft202/shared/index.ts
2791
+ var shared_exports2 = {};
2792
+ __export(shared_exports2, {
2793
+ expectPda: () => expectPda2,
2794
+ expectPublicKey: () => expectPublicKey2,
2795
+ expectSome: () => expectSome2,
2796
+ getAccountMetasAndSigners: () => getAccountMetasAndSigners2
2797
+ });
2798
+ function expectSome2(value) {
2799
+ if (value == null) {
2800
+ throw new Error("Expected a value but received null or undefined.");
2801
+ }
2802
+ return value;
2803
+ }
2804
+ function expectPublicKey2(value) {
2805
+ if (!value) {
2806
+ throw new Error("Expected a PublicKey.");
2807
+ }
2808
+ return umi.publicKey(value, false);
2809
+ }
2810
+ function expectPda2(value) {
2811
+ if (!value || !Array.isArray(value) || !umi.isPda(value)) {
2812
+ throw new Error("Expected a PDA.");
2813
+ }
2814
+ return value;
2815
+ }
2816
+ function getAccountMetasAndSigners2(accounts, optionalAccountStrategy, programId) {
2817
+ const keys = [];
2818
+ const signers = [];
2819
+ accounts.forEach((account) => {
2820
+ if (!account.value) {
2821
+ if (optionalAccountStrategy === "omitted") return;
2822
+ keys.push({ pubkey: programId, isSigner: false, isWritable: false });
2823
+ return;
2824
+ }
2825
+ if (umi.isSigner(account.value)) {
2826
+ signers.push(account.value);
2827
+ }
2828
+ keys.push({
2829
+ pubkey: umi.publicKey(account.value, false),
2830
+ isSigner: umi.isSigner(account.value),
2831
+ isWritable: account.isWritable
2832
+ });
2833
+ });
2834
+ return [keys, signers];
2835
+ }
2836
+
2837
+ // src/generated/oft202/instructions/initOft.ts
2838
+ function getInitOftInstructionDataSerializer2() {
2839
+ return serializers.mapSerializer(
2840
+ serializers.struct(
2841
+ [
2842
+ ["discriminator", serializers.bytes({ size: 8 })],
2843
+ ["oftType", getOFTTypeSerializer2()],
2844
+ ["admin", serializers.publicKey()],
2845
+ ["sharedDecimals", serializers.u8()],
2846
+ ["endpointProgram", serializers.option(serializers.publicKey())]
2847
+ ],
2848
+ { description: "InitOftInstructionData" }
2849
+ ),
2850
+ (value) => ({
2851
+ ...value,
2852
+ discriminator: new Uint8Array([182, 169, 147, 16, 201, 45, 76, 23])
2853
+ })
2854
+ );
2855
+ }
2856
+ function initOft3(context, input) {
2857
+ const programId = context.programs.getPublicKey("oft", "");
2858
+ const resolvedAccounts = {
2859
+ payer: {
2860
+ index: 0,
2861
+ isWritable: true,
2862
+ value: input.payer ?? null
2863
+ },
2864
+ oftStore: {
2865
+ index: 1,
2866
+ isWritable: true,
2867
+ value: input.oftStore ?? null
2868
+ },
2869
+ lzReceiveTypesAccounts: {
2870
+ index: 2,
2871
+ isWritable: true,
2872
+ value: input.lzReceiveTypesAccounts ?? null
2873
+ },
2874
+ tokenMint: {
2875
+ index: 3,
2876
+ isWritable: false,
2877
+ value: input.tokenMint ?? null
2878
+ },
2879
+ tokenEscrow: {
2880
+ index: 4,
2881
+ isWritable: true,
2882
+ value: input.tokenEscrow ?? null
2883
+ },
2884
+ tokenProgram: {
2885
+ index: 5,
2886
+ isWritable: false,
2887
+ value: input.tokenProgram ?? null
2888
+ },
2889
+ systemProgram: {
2890
+ index: 6,
2891
+ isWritable: false,
2892
+ value: input.systemProgram ?? null
2893
+ }
2894
+ };
2895
+ const resolvedArgs = { ...input };
2896
+ if (!resolvedAccounts.payer.value) {
2897
+ resolvedAccounts.payer.value = context.payer;
2898
+ }
2899
+ if (!resolvedAccounts.tokenProgram.value) {
2900
+ resolvedAccounts.tokenProgram.value = context.programs.getPublicKey(
2901
+ "splToken",
2902
+ "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
2903
+ );
2904
+ resolvedAccounts.tokenProgram.isWritable = false;
2905
+ }
2906
+ if (!resolvedAccounts.systemProgram.value) {
2907
+ resolvedAccounts.systemProgram.value = context.programs.getPublicKey(
2908
+ "splSystem",
2909
+ "11111111111111111111111111111111"
2910
+ );
2911
+ resolvedAccounts.systemProgram.isWritable = false;
2912
+ }
2913
+ const orderedAccounts = Object.values(
2914
+ resolvedAccounts
2915
+ ).sort((a, b) => a.index - b.index);
2916
+ const [keys, signers] = getAccountMetasAndSigners2(
2917
+ orderedAccounts,
2918
+ "programId",
2919
+ programId
2920
+ );
2921
+ const data = getInitOftInstructionDataSerializer2().serialize(
2922
+ resolvedArgs
2923
+ );
2924
+ const bytesCreatedOnChain = 0;
2925
+ return umi.transactionBuilder([
2926
+ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }
2927
+ ]);
2928
+ }
2929
+ function getLzReceiveInstructionDataSerializer2() {
2930
+ return serializers.mapSerializer(
2931
+ serializers.struct(
2932
+ [
2933
+ ["discriminator", serializers.bytes({ size: 8 })],
2934
+ ["params", getLzReceiveParamsSerializer2()]
2935
+ ],
2936
+ { description: "LzReceiveInstructionData" }
2937
+ ),
2938
+ (value) => ({
2939
+ ...value,
2940
+ discriminator: new Uint8Array([8, 179, 120, 109, 33, 118, 189, 80])
2941
+ })
2942
+ );
2943
+ }
2944
+ function lzReceive2(context, input) {
2945
+ const programId = context.programs.getPublicKey("oft", "");
2946
+ const resolvedAccounts = {
2947
+ payer: {
2948
+ index: 0,
2949
+ isWritable: true,
2950
+ value: input.payer ?? null
2951
+ },
2952
+ peer: { index: 1, isWritable: true, value: input.peer ?? null },
2953
+ oftStore: {
2954
+ index: 2,
2955
+ isWritable: true,
2956
+ value: input.oftStore ?? null
2957
+ },
2958
+ tokenEscrow: {
2959
+ index: 3,
2960
+ isWritable: true,
2961
+ value: input.tokenEscrow ?? null
2962
+ },
2963
+ toAddress: {
2964
+ index: 4,
2965
+ isWritable: false,
2966
+ value: input.toAddress ?? null
2967
+ },
2968
+ tokenDest: {
2969
+ index: 5,
2970
+ isWritable: true,
2971
+ value: input.tokenDest ?? null
2972
+ },
2973
+ tokenMint: {
2974
+ index: 6,
2975
+ isWritable: true,
2976
+ value: input.tokenMint ?? null
2977
+ },
2978
+ mintAuthority: {
2979
+ index: 7,
2980
+ isWritable: false,
2981
+ value: input.mintAuthority ?? null
2982
+ },
2983
+ tokenProgram: {
2984
+ index: 8,
2985
+ isWritable: false,
2986
+ value: input.tokenProgram ?? null
2987
+ },
2988
+ associatedTokenProgram: {
2989
+ index: 9,
2990
+ isWritable: false,
2991
+ value: input.associatedTokenProgram ?? null
2992
+ },
2993
+ systemProgram: {
2994
+ index: 10,
2995
+ isWritable: false,
2996
+ value: input.systemProgram ?? null
2997
+ },
2998
+ eventAuthority: {
2999
+ index: 11,
3000
+ isWritable: false,
3001
+ value: input.eventAuthority ?? null
3002
+ },
3003
+ program: {
3004
+ index: 12,
3005
+ isWritable: false,
3006
+ value: input.program ?? null
3007
+ }
3008
+ };
3009
+ const resolvedArgs = { ...input };
3010
+ if (!resolvedAccounts.payer.value) {
3011
+ resolvedAccounts.payer.value = context.payer;
3012
+ }
3013
+ if (!resolvedAccounts.tokenProgram.value) {
3014
+ resolvedAccounts.tokenProgram.value = context.programs.getPublicKey(
3015
+ "splToken",
3016
+ "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
3017
+ );
3018
+ resolvedAccounts.tokenProgram.isWritable = false;
3019
+ }
3020
+ if (!resolvedAccounts.systemProgram.value) {
3021
+ resolvedAccounts.systemProgram.value = context.programs.getPublicKey(
3022
+ "splSystem",
3023
+ "11111111111111111111111111111111"
3024
+ );
3025
+ resolvedAccounts.systemProgram.isWritable = false;
3026
+ }
3027
+ const orderedAccounts = Object.values(
3028
+ resolvedAccounts
3029
+ ).sort((a, b) => a.index - b.index);
3030
+ const [keys, signers] = getAccountMetasAndSigners2(
3031
+ orderedAccounts,
3032
+ "programId",
3033
+ programId
3034
+ );
3035
+ const data = getLzReceiveInstructionDataSerializer2().serialize(
3036
+ resolvedArgs
3037
+ );
3038
+ const bytesCreatedOnChain = 0;
3039
+ return umi.transactionBuilder([
3040
+ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }
3041
+ ]);
3042
+ }
3043
+ function getLzReceiveTypesInstructionDataSerializer2() {
3044
+ return serializers.mapSerializer(
3045
+ serializers.struct(
3046
+ [
3047
+ ["discriminator", serializers.bytes({ size: 8 })],
3048
+ ["params", getLzReceiveParamsSerializer2()]
3049
+ ],
3050
+ { description: "LzReceiveTypesInstructionData" }
3051
+ ),
3052
+ (value) => ({
3053
+ ...value,
3054
+ discriminator: new Uint8Array([221, 17, 246, 159, 248, 128, 31, 96])
3055
+ })
3056
+ );
3057
+ }
3058
+ function lzReceiveTypes2(context, input) {
3059
+ const programId = context.programs.getPublicKey("oft", "");
3060
+ const resolvedAccounts = {
3061
+ oftStore: {
3062
+ index: 0,
3063
+ isWritable: false,
3064
+ value: input.oftStore ?? null
3065
+ },
3066
+ tokenMint: {
3067
+ index: 1,
3068
+ isWritable: false,
3069
+ value: input.tokenMint ?? null
3070
+ }
3071
+ };
3072
+ const resolvedArgs = { ...input };
3073
+ const orderedAccounts = Object.values(
3074
+ resolvedAccounts
3075
+ ).sort((a, b) => a.index - b.index);
3076
+ const [keys, signers] = getAccountMetasAndSigners2(
3077
+ orderedAccounts,
3078
+ "programId",
3079
+ programId
3080
+ );
3081
+ const data = getLzReceiveTypesInstructionDataSerializer2().serialize(
3082
+ resolvedArgs
3083
+ );
3084
+ const bytesCreatedOnChain = 0;
3085
+ return umi.transactionBuilder([
3086
+ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }
3087
+ ]);
3088
+ }
3089
+ function getQuoteOftInstructionDataSerializer2() {
3090
+ return serializers.mapSerializer(
3091
+ serializers.struct(
3092
+ [
3093
+ ["discriminator", serializers.bytes({ size: 8 })],
3094
+ ["dstEid", serializers.u32()],
3095
+ ["to", serializers.bytes({ size: 32 })],
3096
+ ["amountLd", serializers.u64()],
3097
+ ["minAmountLd", serializers.u64()],
3098
+ ["options", serializers.bytes({ size: serializers.u32() })],
3099
+ ["composeMsg", serializers.option(serializers.bytes({ size: serializers.u32() }))],
3100
+ ["payInLzToken", serializers.bool()]
3101
+ ],
3102
+ { description: "QuoteOftInstructionData" }
3103
+ ),
3104
+ (value) => ({
3105
+ ...value,
3106
+ discriminator: new Uint8Array([179, 255, 92, 202, 251, 82, 82, 118])
3107
+ })
3108
+ );
3109
+ }
3110
+ function quoteOft3(context, input) {
3111
+ const programId = context.programs.getPublicKey("oft", "");
3112
+ const resolvedAccounts = {
3113
+ oftStore: {
3114
+ index: 0,
3115
+ isWritable: false,
3116
+ value: input.oftStore ?? null
3117
+ },
3118
+ peer: { index: 1, isWritable: false, value: input.peer ?? null },
3119
+ tokenMint: {
3120
+ index: 2,
3121
+ isWritable: false,
3122
+ value: input.tokenMint ?? null
3123
+ }
3124
+ };
3125
+ const resolvedArgs = { ...input };
3126
+ const orderedAccounts = Object.values(
3127
+ resolvedAccounts
3128
+ ).sort((a, b) => a.index - b.index);
3129
+ const [keys, signers] = getAccountMetasAndSigners2(
3130
+ orderedAccounts,
3131
+ "programId",
3132
+ programId
3133
+ );
3134
+ const data = getQuoteOftInstructionDataSerializer2().serialize(
3135
+ resolvedArgs
3136
+ );
3137
+ const bytesCreatedOnChain = 0;
3138
+ return umi.transactionBuilder([
3139
+ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }
3140
+ ]);
3141
+ }
3142
+ function getQuoteSendInstructionDataSerializer2() {
3143
+ return serializers.mapSerializer(
3144
+ serializers.struct(
3145
+ [
3146
+ ["discriminator", serializers.bytes({ size: 8 })],
3147
+ ["dstEid", serializers.u32()],
3148
+ ["to", serializers.bytes({ size: 32 })],
3149
+ ["amountLd", serializers.u64()],
3150
+ ["minAmountLd", serializers.u64()],
3151
+ ["options", serializers.bytes({ size: serializers.u32() })],
3152
+ ["payInLzToken", serializers.bool()],
3153
+ ["composeParams", serializers.option(getComposeParamsSerializer())]
3154
+ ],
3155
+ { description: "QuoteSendInstructionData" }
3156
+ ),
3157
+ (value) => ({
3158
+ ...value,
3159
+ discriminator: new Uint8Array([207, 0, 49, 214, 160, 211, 76, 211])
3160
+ })
3161
+ );
3162
+ }
3163
+ function quoteSend2(context, input) {
3164
+ const programId = context.programs.getPublicKey("oft", "");
3165
+ const resolvedAccounts = {
3166
+ oftStore: {
3167
+ index: 0,
3168
+ isWritable: false,
3169
+ value: input.oftStore ?? null
3170
+ },
3171
+ peer: { index: 1, isWritable: false, value: input.peer ?? null },
3172
+ tokenMint: {
3173
+ index: 2,
3174
+ isWritable: false,
3175
+ value: input.tokenMint ?? null
3176
+ }
3177
+ };
3178
+ const resolvedArgs = { ...input };
3179
+ const orderedAccounts = Object.values(
3180
+ resolvedAccounts
3181
+ ).sort((a, b) => a.index - b.index);
3182
+ const [keys, signers] = getAccountMetasAndSigners2(
3183
+ orderedAccounts,
3184
+ "programId",
3185
+ programId
3186
+ );
3187
+ const data = getQuoteSendInstructionDataSerializer2().serialize(
3188
+ resolvedArgs
3189
+ );
3190
+ const bytesCreatedOnChain = 0;
3191
+ return umi.transactionBuilder([
3192
+ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }
3193
+ ]);
3194
+ }
3195
+ function getSendInstructionDataSerializer2() {
3196
+ return serializers.mapSerializer(
3197
+ serializers.struct(
3198
+ [
3199
+ ["discriminator", serializers.bytes({ size: 8 })],
3200
+ ["dstEid", serializers.u32()],
3201
+ ["to", serializers.bytes({ size: 32 })],
3202
+ ["amountLd", serializers.u64()],
3203
+ ["minAmountLd", serializers.u64()],
3204
+ ["options", serializers.bytes({ size: serializers.u32() })],
3205
+ ["nativeFee", serializers.u64()],
3206
+ ["lzTokenFee", serializers.u64()],
3207
+ ["composeParams", serializers.option(getComposeParamsSerializer())]
3208
+ ],
3209
+ { description: "SendInstructionData" }
3210
+ ),
3211
+ (value) => ({
3212
+ ...value,
3213
+ discriminator: new Uint8Array([102, 251, 20, 187, 65, 75, 12, 69])
3214
+ })
3215
+ );
3216
+ }
3217
+ function send3(context, input) {
3218
+ const programId = context.programs.getPublicKey("oft", "");
3219
+ const resolvedAccounts = {
3220
+ signer: {
3221
+ index: 0,
3222
+ isWritable: false,
3223
+ value: input.signer ?? null
3224
+ },
3225
+ peer: { index: 1, isWritable: true, value: input.peer ?? null },
3226
+ oftStore: {
3227
+ index: 2,
3228
+ isWritable: true,
3229
+ value: input.oftStore ?? null
3230
+ },
3231
+ tokenSource: {
3232
+ index: 3,
3233
+ isWritable: true,
3234
+ value: input.tokenSource ?? null
3235
+ },
3236
+ tokenEscrow: {
3237
+ index: 4,
3238
+ isWritable: true,
3239
+ value: input.tokenEscrow ?? null
3240
+ },
3241
+ tokenMint: {
3242
+ index: 5,
3243
+ isWritable: true,
3244
+ value: input.tokenMint ?? null
3245
+ },
3246
+ tokenProgram: {
3247
+ index: 6,
3248
+ isWritable: false,
3249
+ value: input.tokenProgram ?? null
3250
+ },
3251
+ eventAuthority: {
3252
+ index: 7,
3253
+ isWritable: false,
3254
+ value: input.eventAuthority ?? null
3255
+ },
3256
+ program: {
3257
+ index: 8,
3258
+ isWritable: false,
3259
+ value: input.program ?? null
3260
+ }
3261
+ };
3262
+ const resolvedArgs = { ...input };
3263
+ if (!resolvedAccounts.tokenProgram.value) {
3264
+ resolvedAccounts.tokenProgram.value = context.programs.getPublicKey(
3265
+ "splToken",
3266
+ "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
3267
+ );
3268
+ resolvedAccounts.tokenProgram.isWritable = false;
3269
+ }
3270
+ const orderedAccounts = Object.values(
3271
+ resolvedAccounts
3272
+ ).sort((a, b) => a.index - b.index);
3273
+ const [keys, signers] = getAccountMetasAndSigners2(
3274
+ orderedAccounts,
3275
+ "programId",
3276
+ programId
3277
+ );
3278
+ const data = getSendInstructionDataSerializer2().serialize(
3279
+ resolvedArgs
3280
+ );
3281
+ const bytesCreatedOnChain = 0;
3282
+ return umi.transactionBuilder([
3283
+ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }
3284
+ ]);
3285
+ }
3286
+ function getSetOftConfigInstructionDataSerializer2() {
3287
+ return serializers.mapSerializer(
3288
+ serializers.struct(
3289
+ [
3290
+ ["discriminator", serializers.bytes({ size: 8 })],
3291
+ ["params", getSetOFTConfigParamsSerializer2()]
3292
+ ],
3293
+ { description: "SetOftConfigInstructionData" }
3294
+ ),
3295
+ (value) => ({
3296
+ ...value,
3297
+ discriminator: new Uint8Array([55, 126, 87, 217, 159, 66, 24, 194])
3298
+ })
3299
+ );
3300
+ }
3301
+ function setOftConfig2(context, input) {
3302
+ const programId = context.programs.getPublicKey("oft", "");
3303
+ const resolvedAccounts = {
3304
+ admin: {
3305
+ index: 0,
3306
+ isWritable: false,
3307
+ value: input.admin ?? null
3308
+ },
3309
+ oftStore: {
3310
+ index: 1,
3311
+ isWritable: true,
3312
+ value: input.oftStore ?? null
3313
+ }
3314
+ };
3315
+ const resolvedArgs = { ...input };
3316
+ const orderedAccounts = Object.values(
3317
+ resolvedAccounts
3318
+ ).sort((a, b) => a.index - b.index);
3319
+ const [keys, signers] = getAccountMetasAndSigners2(
3320
+ orderedAccounts,
3321
+ "programId",
3322
+ programId
3323
+ );
3324
+ const data = getSetOftConfigInstructionDataSerializer2().serialize(
3325
+ resolvedArgs
3326
+ );
3327
+ const bytesCreatedOnChain = 0;
3328
+ return umi.transactionBuilder([
3329
+ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }
3330
+ ]);
3331
+ }
3332
+ function getSetPauseInstructionDataSerializer2() {
3333
+ return serializers.mapSerializer(
3334
+ serializers.struct(
3335
+ [
3336
+ ["discriminator", serializers.bytes({ size: 8 })],
3337
+ ["paused", serializers.bool()]
3338
+ ],
3339
+ { description: "SetPauseInstructionData" }
3340
+ ),
3341
+ (value) => ({
3342
+ ...value,
3343
+ discriminator: new Uint8Array([63, 32, 154, 2, 56, 103, 79, 45])
3344
+ })
3345
+ );
3346
+ }
3347
+ function setPause2(context, input) {
3348
+ const programId = context.programs.getPublicKey("oft", "");
3349
+ const resolvedAccounts = {
3350
+ signer: {
3351
+ index: 0,
3352
+ isWritable: false,
3353
+ value: input.signer ?? null
3354
+ },
3355
+ oftStore: {
3356
+ index: 1,
3357
+ isWritable: true,
3358
+ value: input.oftStore ?? null
3359
+ }
3360
+ };
3361
+ const resolvedArgs = { ...input };
3362
+ const orderedAccounts = Object.values(
3363
+ resolvedAccounts
3364
+ ).sort((a, b) => a.index - b.index);
3365
+ const [keys, signers] = getAccountMetasAndSigners2(
3366
+ orderedAccounts,
3367
+ "programId",
3368
+ programId
3369
+ );
3370
+ const data = getSetPauseInstructionDataSerializer2().serialize(
3371
+ resolvedArgs
3372
+ );
3373
+ const bytesCreatedOnChain = 0;
3374
+ return umi.transactionBuilder([
3375
+ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }
3376
+ ]);
3377
+ }
3378
+ function getSetPeerConfigInstructionDataSerializer2() {
3379
+ return serializers.mapSerializer(
3380
+ serializers.struct(
3381
+ [
3382
+ ["discriminator", serializers.bytes({ size: 8 })],
3383
+ ["remoteEid", serializers.u32()],
3384
+ ["config", getPeerConfigParamSerializer2()]
3385
+ ],
3386
+ { description: "SetPeerConfigInstructionData" }
3387
+ ),
3388
+ (value) => ({
3389
+ ...value,
3390
+ discriminator: new Uint8Array([79, 187, 168, 57, 139, 140, 93, 47])
3391
+ })
3392
+ );
3393
+ }
3394
+ function setPeerConfig3(context, input) {
3395
+ const programId = context.programs.getPublicKey("oft", "");
3396
+ const resolvedAccounts = {
3397
+ admin: {
3398
+ index: 0,
3399
+ isWritable: true,
3400
+ value: input.admin ?? null
3401
+ },
3402
+ peer: { index: 1, isWritable: true, value: input.peer ?? null },
3403
+ oftStore: {
3404
+ index: 2,
3405
+ isWritable: false,
3406
+ value: input.oftStore ?? null
3407
+ },
3408
+ systemProgram: {
3409
+ index: 3,
3410
+ isWritable: false,
3411
+ value: input.systemProgram ?? null
3412
+ }
3413
+ };
3414
+ const resolvedArgs = { ...input };
3415
+ if (!resolvedAccounts.systemProgram.value) {
3416
+ resolvedAccounts.systemProgram.value = context.programs.getPublicKey(
3417
+ "splSystem",
3418
+ "11111111111111111111111111111111"
3419
+ );
3420
+ resolvedAccounts.systemProgram.isWritable = false;
3421
+ }
3422
+ const orderedAccounts = Object.values(
3423
+ resolvedAccounts
3424
+ ).sort((a, b) => a.index - b.index);
3425
+ const [keys, signers] = getAccountMetasAndSigners2(
3426
+ orderedAccounts,
3427
+ "programId",
3428
+ programId
3429
+ );
3430
+ const data = getSetPeerConfigInstructionDataSerializer2().serialize(
3431
+ resolvedArgs
3432
+ );
3433
+ const bytesCreatedOnChain = 0;
3434
+ return umi.transactionBuilder([
3435
+ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }
3436
+ ]);
3437
+ }
3438
+ function getWithdrawFeeInstructionDataSerializer2() {
3439
+ return serializers.mapSerializer(
3440
+ serializers.struct(
3441
+ [
3442
+ ["discriminator", serializers.bytes({ size: 8 })],
3443
+ ["feeLd", serializers.u64()]
3444
+ ],
3445
+ { description: "WithdrawFeeInstructionData" }
3446
+ ),
3447
+ (value) => ({
3448
+ ...value,
3449
+ discriminator: new Uint8Array([14, 122, 231, 218, 31, 238, 223, 150])
3450
+ })
3451
+ );
3452
+ }
3453
+ function withdrawFee3(context, input) {
3454
+ const programId = context.programs.getPublicKey("oft", "");
3455
+ const resolvedAccounts = {
3456
+ admin: {
3457
+ index: 0,
3458
+ isWritable: false,
3459
+ value: input.admin ?? null
3460
+ },
3461
+ oftStore: {
3462
+ index: 1,
3463
+ isWritable: false,
3464
+ value: input.oftStore ?? null
3465
+ },
3466
+ tokenMint: {
3467
+ index: 2,
3468
+ isWritable: false,
3469
+ value: input.tokenMint ?? null
3470
+ },
3471
+ tokenEscrow: {
3472
+ index: 3,
3473
+ isWritable: true,
3474
+ value: input.tokenEscrow ?? null
3475
+ },
3476
+ tokenDest: {
3477
+ index: 4,
3478
+ isWritable: true,
3479
+ value: input.tokenDest ?? null
3480
+ },
3481
+ tokenProgram: {
3482
+ index: 5,
3483
+ isWritable: false,
3484
+ value: input.tokenProgram ?? null
3485
+ }
3486
+ };
3487
+ const resolvedArgs = { ...input };
3488
+ if (!resolvedAccounts.tokenProgram.value) {
3489
+ resolvedAccounts.tokenProgram.value = context.programs.getPublicKey(
3490
+ "splToken",
3491
+ "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
3492
+ );
3493
+ resolvedAccounts.tokenProgram.isWritable = false;
3494
+ }
3495
+ const orderedAccounts = Object.values(
3496
+ resolvedAccounts
3497
+ ).sort((a, b) => a.index - b.index);
3498
+ const [keys, signers] = getAccountMetasAndSigners2(
3499
+ orderedAccounts,
3500
+ "programId",
3501
+ programId
3502
+ );
3503
+ const data = getWithdrawFeeInstructionDataSerializer2().serialize(
3504
+ resolvedArgs
3505
+ );
3506
+ const bytesCreatedOnChain = 0;
3507
+ return umi.transactionBuilder([
3508
+ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }
3509
+ ]);
3510
+ }
3511
+
3512
+ // src/generated/oft202/programs/index.ts
3513
+ var programs_exports2 = {};
3514
+ __export(programs_exports2, {
3515
+ OFT_PROGRAM_ID: () => OFT_PROGRAM_ID2,
3516
+ createOftProgram: () => createOftProgram2,
3517
+ getOftProgram: () => getOftProgram2,
3518
+ getOftProgramId: () => getOftProgramId2
3519
+ });
3520
+
3521
+ // src/generated/oft202/programs/oft.ts
3522
+ var OFT_PROGRAM_ID2 = "";
3523
+ function createOftProgram2() {
3524
+ return {
3525
+ name: "oft",
3526
+ publicKey: OFT_PROGRAM_ID2,
3527
+ getErrorFromCode(code, cause) {
3528
+ return getOftErrorFromCode2(code, this, cause);
3529
+ },
3530
+ getErrorFromName(name, cause) {
3531
+ return getOftErrorFromName2(name, this, cause);
3532
+ },
3533
+ isOnCluster() {
3534
+ return true;
3535
+ }
3536
+ };
3537
+ }
3538
+ function getOftProgram2(context, clusterFilter) {
3539
+ return context.programs.get("oft", clusterFilter);
3540
+ }
3541
+ function getOftProgramId2(context, clusterFilter) {
3542
+ return context.programs.getPublicKey("oft", OFT_PROGRAM_ID2, clusterFilter);
3543
+ }
3544
+
3545
+ // src/oft202.ts
3546
+ var ENDPOINT_PROGRAM_ID2 = umiWeb3jsAdapters.fromWeb3JsPublicKey(lzSolanaSdkV2.EndpointProgram.PROGRAM_ID);
3547
+ var PROGRAM_NAME = "oft";
3548
+ function createOFTProgramRepo2(oftProgram, rpc) {
3549
+ if (rpc === void 0) {
3550
+ rpc = umi.createNullRpc();
3551
+ rpc.getCluster = () => "custom";
3552
+ }
3553
+ return umiProgramRepository.createDefaultProgramRepository({ rpc }, [
3554
+ {
3555
+ name: PROGRAM_NAME,
3556
+ publicKey: oftProgram,
3557
+ getErrorFromCode(code, cause) {
3558
+ return getOftErrorFromCode2(code, this, cause);
3559
+ },
3560
+ getErrorFromName(name, cause) {
3561
+ return getOftErrorFromName2(name, this, cause);
3562
+ },
3563
+ isOnCluster() {
3564
+ return true;
3565
+ }
3566
+ }
3567
+ ]);
3568
+ }
3569
+ function initOft4(accounts, oftType, sharedDecimals = OFT_DECIMALS, programs) {
3570
+ const programsRepo = createOFTProgramRepo2(programs.oft);
3571
+ const deriver = new OftPDA(programsRepo.getPublicKey(PROGRAM_NAME));
3572
+ const endpoint = new lzSolanaSdkV2.EndpointProgram.Endpoint(umiWeb3jsAdapters.toWeb3JsPublicKey(programs.endpoint ?? ENDPOINT_PROGRAM_ID2));
3573
+ const { payer, admin, mint, escrow } = accounts;
3574
+ const [oftStore] = deriver.oftStore(escrow.publicKey);
3575
+ const [lzReceiveTypes3] = deriver.lzReceiveTypesAccounts(oftStore);
3576
+ const txBuilder = initOft3(
3577
+ {
3578
+ payer,
3579
+ programs: programsRepo
3580
+ },
3581
+ {
3582
+ // accounts
3583
+ oftStore,
3584
+ lzReceiveTypesAccounts: lzReceiveTypes3,
3585
+ tokenMint: mint,
3586
+ tokenEscrow: escrow,
3587
+ tokenProgram: programs.token ?? umiWeb3jsAdapters.fromWeb3JsPublicKey(TOKEN_PROGRAM_ID),
3588
+ // params
3589
+ oftType,
3590
+ admin,
3591
+ sharedDecimals,
3592
+ endpointProgram: umiWeb3jsAdapters.fromWeb3JsPublicKey(endpoint.program)
3593
+ }
3594
+ );
3595
+ const retval = txBuilder.addRemainingAccounts(
3596
+ endpoint.getRegisterOappIxAccountMetaForCPI(umiWeb3jsAdapters.toWeb3JsPublicKey(payer.publicKey), umiWeb3jsAdapters.toWeb3JsPublicKey(oftStore)).map((acc) => {
3597
+ return {
3598
+ pubkey: umiWeb3jsAdapters.fromWeb3JsPublicKey(acc.pubkey),
3599
+ isSigner: acc.isSigner,
3600
+ isWritable: acc.isWritable
3601
+ };
3602
+ })
3603
+ ).items[0];
3604
+ retval.signers = [payer, escrow];
3605
+ return retval;
3606
+ }
3607
+ function setOFTConfig2(accounts, params, programs) {
3608
+ let actualParams;
3609
+ const { oftStore, admin } = accounts;
3610
+ const oftStoreWeb3Js = umiWeb3jsAdapters.toWeb3JsPublicKey(oftStore);
3611
+ const remainingAccounts = [];
3612
+ if (params.__kind === "Admin") {
3613
+ if (params.admin === void 0) {
3614
+ throw new Error("Admin is required");
3615
+ }
3616
+ actualParams = {
3617
+ __kind: "Admin",
3618
+ fields: [params.admin]
3619
+ };
3620
+ } else if (params.__kind === "Delegate") {
3621
+ if (params.delegate === void 0) {
3622
+ throw new Error("Delegate is required");
3623
+ }
3624
+ actualParams = {
3625
+ __kind: "Delegate",
3626
+ fields: [params.delegate]
3627
+ };
3628
+ const endpointProgram = umiWeb3jsAdapters.toWeb3JsPublicKey(programs.endpoint ?? ENDPOINT_PROGRAM_ID2);
3629
+ const [oAppRegistry] = new lzSolanaSdkV2.EndpointPDADeriver(endpointProgram).oappRegistry(oftStoreWeb3Js);
3630
+ const [endpointEventAuthority] = new lzSolanaSdkV2.EventPDADeriver(endpointProgram).eventAuthority();
3631
+ const keys = lzSolanaSdkV2.EndpointProgram.instructions.createSetDelegateInstructionAccounts(
3632
+ {
3633
+ oapp: oftStoreWeb3Js,
3634
+ oappRegistry: oAppRegistry,
3635
+ eventAuthority: endpointEventAuthority,
3636
+ program: endpointProgram
3637
+ },
3638
+ endpointProgram
3639
+ );
3640
+ for (const acc of keys) {
3641
+ acc.isSigner = false;
3642
+ }
3643
+ remainingAccounts.push(
3644
+ {
3645
+ pubkey: endpointProgram,
3646
+ isSigner: false,
3647
+ isWritable: false
3648
+ },
3649
+ ...keys
3650
+ );
3651
+ } else if (params.__kind === "DefaultFee") {
3652
+ if (params.defaultFee === void 0) {
3653
+ throw new Error("DefaultFee is required");
3654
+ }
3655
+ actualParams = {
3656
+ __kind: "DefaultFee",
3657
+ fields: [params.defaultFee]
3658
+ };
3659
+ } else if (params.__kind === "Paused") {
3660
+ if (params.paused === void 0) {
3661
+ throw new Error("Paused is required");
3662
+ }
3663
+ actualParams = {
3664
+ __kind: "Paused",
3665
+ fields: [params.paused]
3666
+ };
3667
+ } else if (params.__kind === "Pauser") {
3668
+ actualParams = {
3669
+ __kind: "Pauser",
3670
+ fields: [params.pauser ? umi.some(params.pauser) : umi.none()]
3671
+ };
3672
+ } else {
3673
+ actualParams = {
3674
+ __kind: "Unpauser",
3675
+ fields: [params.unpauser ? umi.some(params.unpauser) : umi.none()]
3676
+ };
3677
+ }
3678
+ const txBuilder = setOftConfig2(
3679
+ { programs: createOFTProgramRepo2(programs.oft) },
3680
+ {
3681
+ admin,
3682
+ oftStore,
3683
+ params: actualParams
3684
+ }
3685
+ );
3686
+ return txBuilder.addRemainingAccounts(
3687
+ remainingAccounts.map((acc) => {
3688
+ return {
3689
+ pubkey: umiWeb3jsAdapters.fromWeb3JsPublicKey(acc.pubkey),
3690
+ isSigner: acc.isSigner,
3691
+ isWritable: acc.isWritable
3692
+ };
3693
+ })
3694
+ ).items[0];
3695
+ }
3696
+ function setPeerConfig4(accounts, param, oftProgramId) {
3697
+ const programsRepo = typeof oftProgramId === "string" ? createOFTProgramRepo2(oftProgramId) : oftProgramId;
3698
+ const { remote: remoteId } = param;
3699
+ if (remoteId % 3e4 == 0) {
3700
+ throw new Error("Invalid remote ID");
3701
+ }
3702
+ const { admin, oftStore } = accounts;
3703
+ const [peerPda] = new OftPDA(programsRepo.getPublicKey(PROGRAM_NAME)).peer(oftStore, remoteId);
3704
+ let config;
3705
+ if (param.__kind === "PeerAddress") {
3706
+ if (param.peer.length !== 32) {
3707
+ throw new Error("Peer must be 32 bytes (left-padded with zeroes)");
3708
+ }
3709
+ config = peerConfigParam2("PeerAddress", [param.peer]);
3710
+ } else if (param.__kind === "FeeBps") {
3711
+ config = { __kind: "FeeBps", fields: [umi.some(param.feeBps)] };
3712
+ } else if (param.__kind === "EnforcedOptions") {
3713
+ config = {
3714
+ __kind: "EnforcedOptions",
3715
+ send: param.send,
3716
+ sendAndCall: param.sendAndCall
3717
+ };
3718
+ } else if (param.__kind === "OutboundRateLimit" || param.__kind === "InboundRateLimit") {
3719
+ config = {
3720
+ __kind: param.__kind,
3721
+ fields: [
3722
+ param.rateLimit ? umi.some({
3723
+ refillPerSecond: umi.some(param.rateLimit.refillPerSecond),
3724
+ capacity: umi.some(param.rateLimit.capacity)
3725
+ }) : null
3726
+ ]
3727
+ };
3728
+ } else if (param.__kind === "IsEndpointV1") {
3729
+ config = { __kind: "IsEndpointV1", fields: [param.isEndpointV1] };
3730
+ } else {
3731
+ throw new Error("Invalid peer config");
3732
+ }
3733
+ return setPeerConfig3(
3734
+ { programs: programsRepo },
3735
+ {
3736
+ admin,
3737
+ peer: peerPda,
3738
+ oftStore,
3739
+ // params
3740
+ remoteEid: remoteId,
3741
+ config
3742
+ }
3743
+ ).items[0];
3744
+ }
3745
+ function withdrawFee4(accounts, amount, programs) {
3746
+ const { admin, mint, escrow, dest } = accounts;
3747
+ const programsRepo = typeof programs.oft === "string" ? createOFTProgramRepo2(programs.oft) : programs.oft;
3748
+ const [oftStore] = new OftPDA(programsRepo.getPublicKey("oft")).oftStore(escrow);
3749
+ return withdrawFee3(
3750
+ { programs: programsRepo },
3751
+ {
3752
+ admin,
3753
+ tokenEscrow: escrow,
3754
+ tokenDest: dest,
3755
+ tokenProgram: programs.token ?? umiWeb3jsAdapters.fromWeb3JsPublicKey(TOKEN_PROGRAM_ID),
3756
+ oftStore,
3757
+ tokenMint: mint,
3758
+ // params
3759
+ feeLd: amount
3760
+ }
3761
+ ).items[0];
3762
+ }
3763
+ async function send4(rpc, accounts, sendParams, programs, remainingAccounts) {
3764
+ const { payer, tokenMint, tokenEscrow, tokenSource } = accounts;
3765
+ const { dstEid, to, amountLd, minAmountLd, options, composeParams, nativeFee, lzTokenFee } = sendParams;
3766
+ const programsRepo = typeof programs.oft === "string" ? createOFTProgramRepo2(programs.oft) : programs.oft;
3767
+ const oftProgramId = programsRepo.getPublicKey(PROGRAM_NAME);
3768
+ const deriver = new OftPDA(oftProgramId);
3769
+ const [oftStore] = deriver.oftStore(tokenEscrow);
3770
+ const [peer] = deriver.peer(oftStore, dstEid);
3771
+ const connection = new web3_js.Connection(rpc.getEndpoint());
3772
+ if (remainingAccounts === void 0 || remainingAccounts.length === 0) {
3773
+ const peerAddr = accounts.peerAddr ?? await fetchPeerConfig2({ rpc }, peer).then((peerInfo) => peerInfo.peerAddress);
3774
+ const endpoint = new lzSolanaSdkV2.EndpointProgram.Endpoint(umiWeb3jsAdapters.toWeb3JsPublicKey(programs.endpoint ?? ENDPOINT_PROGRAM_ID2));
3775
+ const msgLibProgram = await getSendLibraryProgram2(connection, endpoint, payer.publicKey, oftStore, dstEid);
3776
+ const packetPath = {
3777
+ srcEid: 0,
3778
+ dstEid,
3779
+ sender: bytes.hexlify(umi.publicKeyBytes(oftStore)),
3780
+ receiver: bytes.hexlify(peerAddr)
3781
+ };
3782
+ remainingAccounts = await endpoint.getSendIXAccountMetaForCPI(
3783
+ connection,
3784
+ umiWeb3jsAdapters.toWeb3JsPublicKey(payer.publicKey),
3785
+ packetPath,
3786
+ msgLibProgram
3787
+ );
3788
+ }
3789
+ const [eventAuthorityPDA] = new lzSolanaSdkV2.EventPDADeriver(umiWeb3jsAdapters.toWeb3JsPublicKey(oftProgramId)).eventAuthority();
3790
+ const tokenProgram = programs.token ?? umiWeb3jsAdapters.fromWeb3JsPublicKey(TOKEN_PROGRAM_ID);
3791
+ const txBuilder = send3(
3792
+ { programs: programsRepo },
3793
+ {
3794
+ signer: payer,
3795
+ peer,
3796
+ oftStore,
3797
+ tokenSource,
3798
+ tokenEscrow,
3799
+ tokenMint,
3800
+ tokenProgram,
3801
+ eventAuthority: umiWeb3jsAdapters.fromWeb3JsPublicKey(eventAuthorityPDA),
3802
+ program: oftProgramId,
3803
+ // params
3804
+ dstEid,
3805
+ to,
3806
+ amountLd,
3807
+ minAmountLd,
3808
+ options: options ?? new Uint8Array(),
3809
+ nativeFee,
3810
+ lzTokenFee: lzTokenFee ?? 0,
3811
+ composeParams: composeParams ?? null
3812
+ }
3813
+ );
3814
+ return txBuilder.addRemainingAccounts(
3815
+ remainingAccounts.map((acc) => {
3816
+ return {
3817
+ pubkey: umiWeb3jsAdapters.fromWeb3JsPublicKey(acc.pubkey),
3818
+ isSigner: acc.isSigner,
3819
+ isWritable: acc.isWritable
3820
+ };
3821
+ })
3822
+ ).items[0];
3823
+ }
3824
+ async function quote2(rpc, accounts, quoteParams, programs, remainingAccounts) {
3825
+ const { dstEid, to, amountLd, minAmountLd, options, payInLzToken, composeParams } = quoteParams;
3826
+ const { payer, tokenMint, tokenEscrow } = accounts;
3827
+ const programsRepo = typeof programs.oft === "string" ? createOFTProgramRepo2(programs.oft) : programs.oft;
3828
+ const deriver = new OftPDA(programsRepo.getPublicKey(PROGRAM_NAME));
3829
+ const [oftStore] = deriver.oftStore(tokenEscrow);
3830
+ const [peer] = deriver.peer(oftStore, dstEid);
3831
+ const connection = new web3_js.Connection(rpc.getEndpoint(), "confirmed");
3832
+ if (remainingAccounts === void 0 || remainingAccounts.length === 0) {
3833
+ const peerAddr = accounts.peerAddr ?? await fetchPeerConfig2({ rpc }, peer).then((peerInfo) => peerInfo.peerAddress);
3834
+ const endpoint = new lzSolanaSdkV2.EndpointProgram.Endpoint(umiWeb3jsAdapters.toWeb3JsPublicKey(programs.endpoint ?? ENDPOINT_PROGRAM_ID2));
3835
+ const messageLib = await getSendLibraryProgram2(connection, endpoint, payer, oftStore, dstEid);
3836
+ remainingAccounts = await endpoint.getQuoteIXAccountMetaForCPI(
3837
+ connection,
3838
+ umiWeb3jsAdapters.toWeb3JsPublicKey(payer),
3839
+ {
3840
+ sender: bytes.hexlify(umi.publicKeyBytes(oftStore)),
3841
+ dstEid,
3842
+ receiver: bytes.hexlify(peerAddr)
3843
+ },
3844
+ messageLib
3845
+ );
3846
+ }
3847
+ let txBuilder = quoteSend2(
3848
+ { programs: programsRepo },
3849
+ {
3850
+ oftStore,
3851
+ peer,
3852
+ tokenMint,
3853
+ // params
3854
+ dstEid,
3855
+ to,
3856
+ amountLd,
3857
+ minAmountLd,
3858
+ options: options ?? new Uint8Array(),
3859
+ payInLzToken: payInLzToken ?? false,
3860
+ composeParams: composeParams ?? null
3861
+ }
3862
+ );
3863
+ txBuilder = txBuilder.addRemainingAccounts(
3864
+ // Get remaining accounts from msgLib(simple_msgLib or uln)
3865
+ remainingAccounts.map((acc) => {
3866
+ return {
3867
+ pubkey: umiWeb3jsAdapters.fromWeb3JsPublicKey(acc.pubkey),
3868
+ isSigner: acc.isSigner,
3869
+ isWritable: acc.isWritable
3870
+ };
3871
+ })
3872
+ );
3873
+ const web3Ix = umiWeb3jsAdapters.toWeb3JsInstruction(txBuilder.getInstructions()[0]);
3874
+ const modifyComputeUnits = web3_js.ComputeBudgetProgram.setComputeUnitLimit({
3875
+ units: 1e6
3876
+ });
3877
+ const buffer = await lzSolanaSdkV2.simulateTransaction(
3878
+ connection,
3879
+ [modifyComputeUnits, web3Ix],
3880
+ web3Ix.programId,
3881
+ umiWeb3jsAdapters.toWeb3JsPublicKey(payer),
3882
+ "confirmed"
3883
+ );
3884
+ const fee = lzSolanaSdkV2.EndpointProgram.types.messagingFeeBeet.read(buffer, 0);
3885
+ return { nativeFee: BigInt(fee.nativeFee.toString()), lzTokenFee: BigInt(fee.lzTokenFee.toString()) };
3886
+ }
3887
+ async function quoteOft4(rpc, accounts, quoteParams, oftProgram) {
3888
+ const { payer, tokenMint, tokenEscrow } = accounts;
3889
+ const { dstEid, to, amountLd, minAmountLd, options, payInLzToken, composeMsg } = quoteParams;
3890
+ const programsRepo = typeof oftProgram === "string" ? createOFTProgramRepo2(oftProgram) : oftProgram;
3891
+ const deriver = new OftPDA(programsRepo.getPublicKey(PROGRAM_NAME));
3892
+ const [oftStore] = deriver.oftStore(tokenEscrow);
3893
+ const [peer] = deriver.peer(oftStore, dstEid);
3894
+ const ix = quoteOft3(
3895
+ { programs: programsRepo },
3896
+ {
3897
+ oftStore,
3898
+ peer,
3899
+ tokenMint,
3900
+ // params
3901
+ dstEid,
3902
+ to,
3903
+ amountLd,
3904
+ minAmountLd,
3905
+ options: options ?? new Uint8Array(),
3906
+ payInLzToken: payInLzToken ?? false,
3907
+ composeMsg: composeMsg ?? null
3908
+ }
3909
+ ).getInstructions()[0];
3910
+ const web3Ix = umiWeb3jsAdapters.toWeb3JsInstruction(ix);
3911
+ const connection = new web3_js.Connection(rpc.getEndpoint());
3912
+ const returnedValues = await lzSolanaSdkV2.simulateTransaction(
3913
+ connection,
3914
+ [web3Ix],
3915
+ web3Ix.programId,
3916
+ umiWeb3jsAdapters.toWeb3JsPublicKey(payer),
3917
+ "confirmed"
3918
+ );
3919
+ const [result] = getQuoteOFTResultSerializer2().deserialize(returnedValues, 0);
3920
+ return result;
3921
+ }
3922
+ async function getSendLibraryProgram2(connection, endpoint, payer, oftStore, remoteEid) {
3923
+ const sendLibInfo = await endpoint.getSendLibrary(connection, umiWeb3jsAdapters.toWeb3JsPublicKey(oftStore), remoteEid);
3924
+ if (!sendLibInfo?.programId) {
3925
+ throw new Error("Send library not initialized or blocked message library");
3926
+ }
3927
+ const { programId: msgLibProgram } = sendLibInfo;
3928
+ const msgLibVersion = await endpoint.getMessageLibVersion(connection, umiWeb3jsAdapters.toWeb3JsPublicKey(payer), msgLibProgram);
3929
+ if (msgLibVersion?.major.toString() === "0" && msgLibVersion.minor == 0 && msgLibVersion.endpointVersion == 2) {
3930
+ return new lzSolanaSdkV2.SimpleMessageLibProgram.SimpleMessageLib(msgLibProgram);
3931
+ } else if (msgLibVersion?.major.toString() === "3" && msgLibVersion.minor == 0 && msgLibVersion.endpointVersion == 2) {
3932
+ return new lzSolanaSdkV2.UlnProgram.Uln(msgLibProgram);
3933
+ }
3934
+ throw new Error(`Unsupported message library version: ${JSON.stringify(msgLibVersion, null, 2)}`);
3935
+ }
2097
3936
 
2098
3937
  exports.OFT_DECIMALS = OFT_DECIMALS;
2099
3938
  exports.OFT_SEED = OFT_SEED;
2100
3939
  exports.OftPDA = OftPDA;
2101
3940
  exports.PEER_SEED = PEER_SEED;
2102
- exports.accounts = accounts_exports;
2103
- exports.errors = errors_exports;
2104
- exports.instructions = instructions_exports;
2105
- exports.oft = oft_exports;
2106
- exports.programs = programs_exports;
2107
- exports.shared = shared_exports;
2108
- exports.types = types_exports;
3941
+ exports.oft = oft302_exports;
3942
+ exports.oft202 = oft202_exports;
3943
+ exports.oft302 = oft302_exports;
2109
3944
  //# sourceMappingURL=index.cjs.map
2110
3945
  //# sourceMappingURL=index.cjs.map