@layerzerolabs/oft-v2-solana-sdk 3.0.53 → 3.0.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,13 +1,14 @@
1
1
  'use strict';
2
2
 
3
3
  var bytes = require('@ethersproject/bytes');
4
- var umi = require('@metaplex-foundation/umi');
4
+ var umi$1 = require('@metaplex-foundation/umi');
5
5
  var umiProgramRepository = require('@metaplex-foundation/umi-program-repository');
6
6
  var umiWeb3jsAdapters = require('@metaplex-foundation/umi-web3js-adapters');
7
7
  var web3_js = require('@solana/web3.js');
8
- var lzSolanaSdkV2 = require('@layerzerolabs/lz-solana-sdk-v2');
8
+ var umi = require('@layerzerolabs/lz-solana-sdk-v2/umi');
9
9
  var serializers = require('@metaplex-foundation/umi/serializers');
10
10
  var umiEddsaWeb3js = require('@metaplex-foundation/umi-eddsa-web3js');
11
+ var lzSolanaSdkV2 = require('@layerzerolabs/lz-solana-sdk-v2');
11
12
 
12
13
  var __defProp = Object.defineProperty;
13
14
  var __export = (target, all) => {
@@ -98,39 +99,39 @@ function getLzReceiveTypesAccountsAccountDataSerializer() {
98
99
  );
99
100
  }
100
101
  function deserializeLzReceiveTypesAccounts(rawAccount) {
101
- return umi.deserializeAccount(
102
+ return umi$1.deserializeAccount(
102
103
  rawAccount,
103
104
  getLzReceiveTypesAccountsAccountDataSerializer()
104
105
  );
105
106
  }
106
107
  async function fetchLzReceiveTypesAccounts(context, publicKey3, options) {
107
108
  const maybeAccount = await context.rpc.getAccount(
108
- umi.publicKey(publicKey3, false),
109
+ umi$1.publicKey(publicKey3, false),
109
110
  options
110
111
  );
111
- umi.assertAccountExists(maybeAccount, "LzReceiveTypesAccounts");
112
+ umi$1.assertAccountExists(maybeAccount, "LzReceiveTypesAccounts");
112
113
  return deserializeLzReceiveTypesAccounts(maybeAccount);
113
114
  }
114
115
  async function safeFetchLzReceiveTypesAccounts(context, publicKey3, options) {
115
116
  const maybeAccount = await context.rpc.getAccount(
116
- umi.publicKey(publicKey3, false),
117
+ umi$1.publicKey(publicKey3, false),
117
118
  options
118
119
  );
119
120
  return maybeAccount.exists ? deserializeLzReceiveTypesAccounts(maybeAccount) : null;
120
121
  }
121
122
  async function fetchAllLzReceiveTypesAccounts(context, publicKeys, options) {
122
123
  const maybeAccounts = await context.rpc.getAccounts(
123
- publicKeys.map((key) => umi.publicKey(key, false)),
124
+ publicKeys.map((key) => umi$1.publicKey(key, false)),
124
125
  options
125
126
  );
126
127
  return maybeAccounts.map((maybeAccount) => {
127
- umi.assertAccountExists(maybeAccount, "LzReceiveTypesAccounts");
128
+ umi$1.assertAccountExists(maybeAccount, "LzReceiveTypesAccounts");
128
129
  return deserializeLzReceiveTypesAccounts(maybeAccount);
129
130
  });
130
131
  }
131
132
  async function safeFetchAllLzReceiveTypesAccounts(context, publicKeys, options) {
132
133
  const maybeAccounts = await context.rpc.getAccounts(
133
- publicKeys.map((key) => umi.publicKey(key, false)),
134
+ publicKeys.map((key) => umi$1.publicKey(key, false)),
134
135
  options
135
136
  );
136
137
  return maybeAccounts.filter((maybeAccount) => maybeAccount.exists).map(
@@ -139,7 +140,7 @@ async function safeFetchAllLzReceiveTypesAccounts(context, publicKeys, options)
139
140
  }
140
141
  function getLzReceiveTypesAccountsGpaBuilder(context) {
141
142
  const programId = context.programs.getPublicKey("oft", "");
142
- return umi.gpaBuilder(context, programId).registerFields({
143
+ return umi$1.gpaBuilder(context, programId).registerFields({
143
144
  discriminator: [0, serializers.bytes({ size: 8 })],
144
145
  oftStore: [8, serializers.publicKey()],
145
146
  tokenMint: [40, serializers.publicKey()]
@@ -414,43 +415,43 @@ function getOFTStoreAccountDataSerializer() {
414
415
  );
415
416
  }
416
417
  function deserializeOFTStore(rawAccount) {
417
- return umi.deserializeAccount(rawAccount, getOFTStoreAccountDataSerializer());
418
+ return umi$1.deserializeAccount(rawAccount, getOFTStoreAccountDataSerializer());
418
419
  }
419
420
  async function fetchOFTStore(context, publicKey3, options) {
420
421
  const maybeAccount = await context.rpc.getAccount(
421
- umi.publicKey(publicKey3, false),
422
+ umi$1.publicKey(publicKey3, false),
422
423
  options
423
424
  );
424
- umi.assertAccountExists(maybeAccount, "OFTStore");
425
+ umi$1.assertAccountExists(maybeAccount, "OFTStore");
425
426
  return deserializeOFTStore(maybeAccount);
426
427
  }
427
428
  async function safeFetchOFTStore(context, publicKey3, options) {
428
429
  const maybeAccount = await context.rpc.getAccount(
429
- umi.publicKey(publicKey3, false),
430
+ umi$1.publicKey(publicKey3, false),
430
431
  options
431
432
  );
432
433
  return maybeAccount.exists ? deserializeOFTStore(maybeAccount) : null;
433
434
  }
434
435
  async function fetchAllOFTStore(context, publicKeys, options) {
435
436
  const maybeAccounts = await context.rpc.getAccounts(
436
- publicKeys.map((key) => umi.publicKey(key, false)),
437
+ publicKeys.map((key) => umi$1.publicKey(key, false)),
437
438
  options
438
439
  );
439
440
  return maybeAccounts.map((maybeAccount) => {
440
- umi.assertAccountExists(maybeAccount, "OFTStore");
441
+ umi$1.assertAccountExists(maybeAccount, "OFTStore");
441
442
  return deserializeOFTStore(maybeAccount);
442
443
  });
443
444
  }
444
445
  async function safeFetchAllOFTStore(context, publicKeys, options) {
445
446
  const maybeAccounts = await context.rpc.getAccounts(
446
- publicKeys.map((key) => umi.publicKey(key, false)),
447
+ publicKeys.map((key) => umi$1.publicKey(key, false)),
447
448
  options
448
449
  );
449
450
  return maybeAccounts.filter((maybeAccount) => maybeAccount.exists).map((maybeAccount) => deserializeOFTStore(maybeAccount));
450
451
  }
451
452
  function getOFTStoreGpaBuilder(context) {
452
453
  const programId = context.programs.getPublicKey("oft", "");
453
- return umi.gpaBuilder(context, programId).registerFields({
454
+ return umi$1.gpaBuilder(context, programId).registerFields({
454
455
  discriminator: [0, serializers.bytes({ size: 8 })],
455
456
  oftType: [8, getOFTTypeSerializer()],
456
457
  ld2sdRate: [9, serializers.u64()],
@@ -490,43 +491,43 @@ function getPeerConfigAccountDataSerializer() {
490
491
  );
491
492
  }
492
493
  function deserializePeerConfig(rawAccount) {
493
- return umi.deserializeAccount(rawAccount, getPeerConfigAccountDataSerializer());
494
+ return umi$1.deserializeAccount(rawAccount, getPeerConfigAccountDataSerializer());
494
495
  }
495
496
  async function fetchPeerConfig(context, publicKey3, options) {
496
497
  const maybeAccount = await context.rpc.getAccount(
497
- umi.publicKey(publicKey3, false),
498
+ umi$1.publicKey(publicKey3, false),
498
499
  options
499
500
  );
500
- umi.assertAccountExists(maybeAccount, "PeerConfig");
501
+ umi$1.assertAccountExists(maybeAccount, "PeerConfig");
501
502
  return deserializePeerConfig(maybeAccount);
502
503
  }
503
504
  async function safeFetchPeerConfig(context, publicKey3, options) {
504
505
  const maybeAccount = await context.rpc.getAccount(
505
- umi.publicKey(publicKey3, false),
506
+ umi$1.publicKey(publicKey3, false),
506
507
  options
507
508
  );
508
509
  return maybeAccount.exists ? deserializePeerConfig(maybeAccount) : null;
509
510
  }
510
511
  async function fetchAllPeerConfig(context, publicKeys, options) {
511
512
  const maybeAccounts = await context.rpc.getAccounts(
512
- publicKeys.map((key) => umi.publicKey(key, false)),
513
+ publicKeys.map((key) => umi$1.publicKey(key, false)),
513
514
  options
514
515
  );
515
516
  return maybeAccounts.map((maybeAccount) => {
516
- umi.assertAccountExists(maybeAccount, "PeerConfig");
517
+ umi$1.assertAccountExists(maybeAccount, "PeerConfig");
517
518
  return deserializePeerConfig(maybeAccount);
518
519
  });
519
520
  }
520
521
  async function safeFetchAllPeerConfig(context, publicKeys, options) {
521
522
  const maybeAccounts = await context.rpc.getAccounts(
522
- publicKeys.map((key) => umi.publicKey(key, false)),
523
+ publicKeys.map((key) => umi$1.publicKey(key, false)),
523
524
  options
524
525
  );
525
526
  return maybeAccounts.filter((maybeAccount) => maybeAccount.exists).map((maybeAccount) => deserializePeerConfig(maybeAccount));
526
527
  }
527
528
  function getPeerConfigGpaBuilder(context) {
528
529
  const programId = context.programs.getPublicKey("oft", "");
529
- return umi.gpaBuilder(context, programId).registerFields({
530
+ return umi$1.gpaBuilder(context, programId).registerFields({
530
531
  discriminator: [0, serializers.bytes({ size: 8 })],
531
532
  peerAddress: [8, serializers.bytes({ size: 32 })],
532
533
  enforcedOptions: [40, getEnforcedOptionsSerializer()],
@@ -557,7 +558,7 @@ __export(errors_exports, {
557
558
  });
558
559
  var codeToErrorMap = /* @__PURE__ */ new Map();
559
560
  var nameToErrorMap = /* @__PURE__ */ new Map();
560
- var UnauthorizedError = class extends umi.ProgramError {
561
+ var UnauthorizedError = class extends umi$1.ProgramError {
561
562
  // 6000
562
563
  constructor(program, cause) {
563
564
  super("", program, cause);
@@ -567,7 +568,7 @@ var UnauthorizedError = class extends umi.ProgramError {
567
568
  };
568
569
  codeToErrorMap.set(6e3, UnauthorizedError);
569
570
  nameToErrorMap.set("Unauthorized", UnauthorizedError);
570
- var InvalidSenderError = class extends umi.ProgramError {
571
+ var InvalidSenderError = class extends umi$1.ProgramError {
571
572
  // 6001
572
573
  constructor(program, cause) {
573
574
  super("", program, cause);
@@ -577,7 +578,7 @@ var InvalidSenderError = class extends umi.ProgramError {
577
578
  };
578
579
  codeToErrorMap.set(6001, InvalidSenderError);
579
580
  nameToErrorMap.set("InvalidSender", InvalidSenderError);
580
- var InvalidDecimalsError = class extends umi.ProgramError {
581
+ var InvalidDecimalsError = class extends umi$1.ProgramError {
581
582
  // 6002
582
583
  constructor(program, cause) {
583
584
  super("", program, cause);
@@ -587,7 +588,7 @@ var InvalidDecimalsError = class extends umi.ProgramError {
587
588
  };
588
589
  codeToErrorMap.set(6002, InvalidDecimalsError);
589
590
  nameToErrorMap.set("InvalidDecimals", InvalidDecimalsError);
590
- var SlippageExceededError = class extends umi.ProgramError {
591
+ var SlippageExceededError = class extends umi$1.ProgramError {
591
592
  // 6003
592
593
  constructor(program, cause) {
593
594
  super("", program, cause);
@@ -597,7 +598,7 @@ var SlippageExceededError = class extends umi.ProgramError {
597
598
  };
598
599
  codeToErrorMap.set(6003, SlippageExceededError);
599
600
  nameToErrorMap.set("SlippageExceeded", SlippageExceededError);
600
- var InvalidTokenDestError = class extends umi.ProgramError {
601
+ var InvalidTokenDestError = class extends umi$1.ProgramError {
601
602
  // 6004
602
603
  constructor(program, cause) {
603
604
  super("", program, cause);
@@ -607,7 +608,7 @@ var InvalidTokenDestError = class extends umi.ProgramError {
607
608
  };
608
609
  codeToErrorMap.set(6004, InvalidTokenDestError);
609
610
  nameToErrorMap.set("InvalidTokenDest", InvalidTokenDestError);
610
- var RateLimitExceededError = class extends umi.ProgramError {
611
+ var RateLimitExceededError = class extends umi$1.ProgramError {
611
612
  // 6005
612
613
  constructor(program, cause) {
613
614
  super("", program, cause);
@@ -617,7 +618,7 @@ var RateLimitExceededError = class extends umi.ProgramError {
617
618
  };
618
619
  codeToErrorMap.set(6005, RateLimitExceededError);
619
620
  nameToErrorMap.set("RateLimitExceeded", RateLimitExceededError);
620
- var InvalidFeeError = class extends umi.ProgramError {
621
+ var InvalidFeeError = class extends umi$1.ProgramError {
621
622
  // 6006
622
623
  constructor(program, cause) {
623
624
  super("", program, cause);
@@ -627,7 +628,7 @@ var InvalidFeeError = class extends umi.ProgramError {
627
628
  };
628
629
  codeToErrorMap.set(6006, InvalidFeeError);
629
630
  nameToErrorMap.set("InvalidFee", InvalidFeeError);
630
- var InvalidMintAuthorityError = class extends umi.ProgramError {
631
+ var InvalidMintAuthorityError = class extends umi$1.ProgramError {
631
632
  // 6007
632
633
  constructor(program, cause) {
633
634
  super("", program, cause);
@@ -637,7 +638,7 @@ var InvalidMintAuthorityError = class extends umi.ProgramError {
637
638
  };
638
639
  codeToErrorMap.set(6007, InvalidMintAuthorityError);
639
640
  nameToErrorMap.set("InvalidMintAuthority", InvalidMintAuthorityError);
640
- var PausedError = class extends umi.ProgramError {
641
+ var PausedError = class extends umi$1.ProgramError {
641
642
  // 6008
642
643
  constructor(program, cause) {
643
644
  super("", program, cause);
@@ -701,10 +702,10 @@ function expectPublicKey(value) {
701
702
  if (!value) {
702
703
  throw new Error("Expected a PublicKey.");
703
704
  }
704
- return umi.publicKey(value, false);
705
+ return umi$1.publicKey(value, false);
705
706
  }
706
707
  function expectPda(value) {
707
- if (!value || !Array.isArray(value) || !umi.isPda(value)) {
708
+ if (!value || !Array.isArray(value) || !umi$1.isPda(value)) {
708
709
  throw new Error("Expected a PDA.");
709
710
  }
710
711
  return value;
@@ -718,12 +719,12 @@ function getAccountMetasAndSigners(accounts, optionalAccountStrategy, programId)
718
719
  keys.push({ pubkey: programId, isSigner: false, isWritable: false });
719
720
  return;
720
721
  }
721
- if (umi.isSigner(account.value)) {
722
+ if (umi$1.isSigner(account.value)) {
722
723
  signers.push(account.value);
723
724
  }
724
725
  keys.push({
725
- pubkey: umi.publicKey(account.value, false),
726
- isSigner: umi.isSigner(account.value),
726
+ pubkey: umi$1.publicKey(account.value, false),
727
+ isSigner: umi$1.isSigner(account.value),
727
728
  isWritable: account.isWritable
728
729
  });
729
730
  });
@@ -818,7 +819,7 @@ function initOft(context, input) {
818
819
  resolvedArgs
819
820
  );
820
821
  const bytesCreatedOnChain = 0;
821
- return umi.transactionBuilder([
822
+ return umi$1.transactionBuilder([
822
823
  { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }
823
824
  ]);
824
825
  }
@@ -932,7 +933,7 @@ function lzReceive(context, input) {
932
933
  resolvedArgs
933
934
  );
934
935
  const bytesCreatedOnChain = 0;
935
- return umi.transactionBuilder([
936
+ return umi$1.transactionBuilder([
936
937
  { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }
937
938
  ]);
938
939
  }
@@ -978,7 +979,7 @@ function lzReceiveTypes(context, input) {
978
979
  resolvedArgs
979
980
  );
980
981
  const bytesCreatedOnChain = 0;
981
- return umi.transactionBuilder([
982
+ return umi$1.transactionBuilder([
982
983
  { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }
983
984
  ]);
984
985
  }
@@ -1006,7 +1007,7 @@ function oftVersion(context) {
1006
1007
  );
1007
1008
  const data = getOftVersionInstructionDataSerializer().serialize({});
1008
1009
  const bytesCreatedOnChain = 0;
1009
- return umi.transactionBuilder([
1010
+ return umi$1.transactionBuilder([
1010
1011
  { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }
1011
1012
  ]);
1012
1013
  }
@@ -1059,7 +1060,7 @@ function quoteOft(context, input) {
1059
1060
  resolvedArgs
1060
1061
  );
1061
1062
  const bytesCreatedOnChain = 0;
1062
- return umi.transactionBuilder([
1063
+ return umi$1.transactionBuilder([
1063
1064
  { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }
1064
1065
  ]);
1065
1066
  }
@@ -1112,7 +1113,7 @@ function quoteSend(context, input) {
1112
1113
  resolvedArgs
1113
1114
  );
1114
1115
  const bytesCreatedOnChain = 0;
1115
- return umi.transactionBuilder([
1116
+ return umi$1.transactionBuilder([
1116
1117
  { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }
1117
1118
  ]);
1118
1119
  }
@@ -1203,7 +1204,7 @@ function send(context, input) {
1203
1204
  resolvedArgs
1204
1205
  );
1205
1206
  const bytesCreatedOnChain = 0;
1206
- return umi.transactionBuilder([
1207
+ return umi$1.transactionBuilder([
1207
1208
  { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }
1208
1209
  ]);
1209
1210
  }
@@ -1249,7 +1250,7 @@ function setOftConfig(context, input) {
1249
1250
  resolvedArgs
1250
1251
  );
1251
1252
  const bytesCreatedOnChain = 0;
1252
- return umi.transactionBuilder([
1253
+ return umi$1.transactionBuilder([
1253
1254
  { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }
1254
1255
  ]);
1255
1256
  }
@@ -1295,7 +1296,7 @@ function setPause(context, input) {
1295
1296
  resolvedArgs
1296
1297
  );
1297
1298
  const bytesCreatedOnChain = 0;
1298
- return umi.transactionBuilder([
1299
+ return umi$1.transactionBuilder([
1299
1300
  { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }
1300
1301
  ]);
1301
1302
  }
@@ -1355,7 +1356,7 @@ function setPeerConfig(context, input) {
1355
1356
  resolvedArgs
1356
1357
  );
1357
1358
  const bytesCreatedOnChain = 0;
1358
- return umi.transactionBuilder([
1359
+ return umi$1.transactionBuilder([
1359
1360
  { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }
1360
1361
  ]);
1361
1362
  }
@@ -1428,7 +1429,7 @@ function withdrawFee(context, input) {
1428
1429
  resolvedArgs
1429
1430
  );
1430
1431
  const bytesCreatedOnChain = 0;
1431
- return umi.transactionBuilder([
1432
+ return umi$1.transactionBuilder([
1432
1433
  { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }
1433
1434
  ]);
1434
1435
  }
@@ -1443,16 +1444,16 @@ var OftPDA = class {
1443
1444
  peer(oftStore, eid) {
1444
1445
  return eddsa.findPda(this.program, [
1445
1446
  Buffer.from(PEER_SEED, "utf8"),
1446
- umi.publicKeyBytes(oftStore),
1447
+ umi$1.publicKeyBytes(oftStore),
1447
1448
  serializers.u32({ endian: serializers.Endian.Big }).serialize(eid)
1448
1449
  // new BN(eid).toArrayLike(Buffer, 'be', 4),
1449
1450
  ]);
1450
1451
  }
1451
1452
  oftStore(escrow) {
1452
- return eddsa.findPda(this.program, [Buffer.from(OFT_SEED, "utf8"), umi.publicKeyBytes(escrow)]);
1453
+ return eddsa.findPda(this.program, [Buffer.from(OFT_SEED, "utf8"), umi$1.publicKeyBytes(escrow)]);
1453
1454
  }
1454
1455
  lzReceiveTypesAccounts(oftConfig) {
1455
- return eddsa.findPda(this.program, [Buffer.from(lzSolanaSdkV2.LZ_RECEIVE_TYPES_SEED, "utf8"), umi.publicKeyBytes(oftConfig)]);
1456
+ return eddsa.findPda(this.program, [Buffer.from(lzSolanaSdkV2.LZ_RECEIVE_TYPES_SEED, "utf8"), umi$1.publicKeyBytes(oftConfig)]);
1456
1457
  }
1457
1458
  };
1458
1459
 
@@ -1490,11 +1491,11 @@ function getOftProgramId(context, clusterFilter) {
1490
1491
  }
1491
1492
 
1492
1493
  // 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);
1494
+ var ENDPOINT_PROGRAM_ID = umi.EndpointProgram.ENDPOINT_PROGRAM_ID;
1495
+ var ULN_PROGRAM_ID = umi.UlnProgram.ULN_PROGRAM_ID;
1495
1496
  function createOFTProgramRepo(oftProgram, rpc) {
1496
1497
  if (rpc === void 0) {
1497
- rpc = umi.createNullRpc();
1498
+ rpc = umi$1.createNullRpc();
1498
1499
  rpc.getCluster = () => "custom";
1499
1500
  }
1500
1501
  return umiProgramRepository.createDefaultProgramRepository({ rpc }, [
@@ -1516,7 +1517,7 @@ function createOFTProgramRepo(oftProgram, rpc) {
1516
1517
  function initOft2(accounts, oftType, sharedDecimals = OFT_DECIMALS, programs) {
1517
1518
  const programsRepo = typeof programs.oft === "string" ? createOFTProgramRepo(programs.oft) : programs.oft;
1518
1519
  const deriver = new OftPDA(programsRepo.getPublicKey("oft"));
1519
- const endpoint = new lzSolanaSdkV2.EndpointProgram.Endpoint(umiWeb3jsAdapters.toWeb3JsPublicKey(programs.endpoint ?? ENDPOINT_PROGRAM_ID));
1520
+ const endpoint = new umi.EndpointProgram.Endpoint(programs.endpoint ?? ENDPOINT_PROGRAM_ID);
1520
1521
  const { payer, admin, mint, escrow } = accounts;
1521
1522
  const [oftStore] = deriver.oftStore(escrow.publicKey);
1522
1523
  const [lzReceiveTypes3] = deriver.lzReceiveTypesAccounts(oftStore);
@@ -1536,13 +1537,13 @@ function initOft2(accounts, oftType, sharedDecimals = OFT_DECIMALS, programs) {
1536
1537
  oftType,
1537
1538
  admin,
1538
1539
  sharedDecimals,
1539
- endpointProgram: umiWeb3jsAdapters.fromWeb3JsPublicKey(endpoint.program)
1540
+ endpointProgram: endpoint.programId
1540
1541
  }
1541
1542
  );
1542
1543
  const retval = txBuilder.addRemainingAccounts(
1543
- endpoint.getRegisterOappIxAccountMetaForCPI(umiWeb3jsAdapters.toWeb3JsPublicKey(payer.publicKey), umiWeb3jsAdapters.toWeb3JsPublicKey(oftStore)).map((acc) => {
1544
+ endpoint.getRegisterOappIxAccountMetaForCPI(payer.publicKey, oftStore).map((acc) => {
1544
1545
  return {
1545
- pubkey: umiWeb3jsAdapters.fromWeb3JsPublicKey(acc.pubkey),
1546
+ pubkey: acc.pubkey,
1546
1547
  isSigner: acc.isSigner,
1547
1548
  isWritable: acc.isWritable
1548
1549
  };
@@ -1554,7 +1555,6 @@ function initOft2(accounts, oftType, sharedDecimals = OFT_DECIMALS, programs) {
1554
1555
  function setOFTConfig(accounts, params, programs) {
1555
1556
  let actualParams;
1556
1557
  const { oftStore, admin } = accounts;
1557
- const oftStoreWeb3Js = umiWeb3jsAdapters.toWeb3JsPublicKey(oftStore);
1558
1558
  const remainingAccounts = [];
1559
1559
  if (params.__kind === "Admin") {
1560
1560
  if (params.admin === void 0) {
@@ -1572,29 +1572,13 @@ function setOFTConfig(accounts, params, programs) {
1572
1572
  __kind: "Delegate",
1573
1573
  fields: [params.delegate]
1574
1574
  };
1575
- const endpointProgram = umiWeb3jsAdapters.toWeb3JsPublicKey(programs.endpoint ?? ENDPOINT_PROGRAM_ID);
1576
- const [oAppRegistry] = new lzSolanaSdkV2.EndpointPDADeriver(endpointProgram).oappRegistry(oftStoreWeb3Js);
1577
- const [endpointEventAuthority] = new lzSolanaSdkV2.EventPDADeriver(endpointProgram).eventAuthority();
1578
- const keys = lzSolanaSdkV2.EndpointProgram.instructions.createSetDelegateInstructionAccounts(
1579
- {
1580
- oapp: oftStoreWeb3Js,
1581
- oappRegistry: oAppRegistry,
1582
- eventAuthority: endpointEventAuthority,
1583
- program: endpointProgram
1584
- },
1585
- endpointProgram
1586
- );
1575
+ const endpointProgram = programs.endpoint ?? ENDPOINT_PROGRAM_ID;
1576
+ const endpointSDK = new umi.EndpointProgram.Endpoint(endpointProgram);
1577
+ const keys = endpointSDK.getSetDelegateIxAccountMetaForCPI(oftStore);
1587
1578
  for (const acc of keys) {
1588
1579
  acc.isSigner = false;
1589
1580
  }
1590
- remainingAccounts.push(
1591
- {
1592
- pubkey: endpointProgram,
1593
- isSigner: false,
1594
- isWritable: false
1595
- },
1596
- ...keys
1597
- );
1581
+ remainingAccounts.push(...keys);
1598
1582
  } else if (params.__kind === "DefaultFee") {
1599
1583
  if (params.defaultFee === void 0) {
1600
1584
  throw new Error("DefaultFee is required");
@@ -1614,12 +1598,12 @@ function setOFTConfig(accounts, params, programs) {
1614
1598
  } else if (params.__kind === "Pauser") {
1615
1599
  actualParams = {
1616
1600
  __kind: "Pauser",
1617
- fields: [params.pauser ? umi.some(params.pauser) : umi.none()]
1601
+ fields: [params.pauser ? umi$1.some(params.pauser) : umi$1.none()]
1618
1602
  };
1619
1603
  } else {
1620
1604
  actualParams = {
1621
1605
  __kind: "Unpauser",
1622
- fields: [params.unpauser ? umi.some(params.unpauser) : umi.none()]
1606
+ fields: [params.unpauser ? umi$1.some(params.unpauser) : umi$1.none()]
1623
1607
  };
1624
1608
  }
1625
1609
  const txBuilder = setOftConfig(
@@ -1633,7 +1617,7 @@ function setOFTConfig(accounts, params, programs) {
1633
1617
  return txBuilder.addRemainingAccounts(
1634
1618
  remainingAccounts.map((acc) => {
1635
1619
  return {
1636
- pubkey: umiWeb3jsAdapters.fromWeb3JsPublicKey(acc.pubkey),
1620
+ pubkey: acc.pubkey,
1637
1621
  isSigner: acc.isSigner,
1638
1622
  isWritable: acc.isWritable
1639
1623
  };
@@ -1655,7 +1639,7 @@ function setPeerConfig2(accounts, param, oftProgramId) {
1655
1639
  }
1656
1640
  config = peerConfigParam("PeerAddress", [param.peer]);
1657
1641
  } else if (param.__kind === "FeeBps") {
1658
- config = { __kind: "FeeBps", fields: [umi.some(param.feeBps)] };
1642
+ config = { __kind: "FeeBps", fields: [umi$1.some(param.feeBps)] };
1659
1643
  } else if (param.__kind === "EnforcedOptions") {
1660
1644
  config = {
1661
1645
  __kind: "EnforcedOptions",
@@ -1666,9 +1650,9 @@ function setPeerConfig2(accounts, param, oftProgramId) {
1666
1650
  config = {
1667
1651
  __kind: param.__kind,
1668
1652
  fields: [
1669
- param.rateLimit ? umi.some({
1670
- refillPerSecond: umi.some(param.rateLimit.refillPerSecond),
1671
- capacity: umi.some(param.rateLimit.capacity)
1653
+ param.rateLimit ? umi$1.some({
1654
+ refillPerSecond: umi$1.some(param.rateLimit.refillPerSecond),
1655
+ capacity: umi$1.some(param.rateLimit.capacity)
1672
1656
  }) : null
1673
1657
  ]
1674
1658
  };
@@ -1689,60 +1673,34 @@ function setPeerConfig2(accounts, param, oftProgramId) {
1689
1673
  }
1690
1674
  function initSendLibrary(accounts, remoteEid, endpointProgram = ENDPOINT_PROGRAM_ID) {
1691
1675
  const { admin, oftStore } = accounts;
1692
- const endpoint = new lzSolanaSdkV2.EndpointProgram.Endpoint(umiWeb3jsAdapters.toWeb3JsPublicKey(endpointProgram));
1693
- return {
1694
- instruction: umiWeb3jsAdapters.fromWeb3JsInstruction(
1695
- endpoint.initSendLibrary(umiWeb3jsAdapters.toWeb3JsPublicKey(admin.publicKey), umiWeb3jsAdapters.toWeb3JsPublicKey(oftStore), remoteEid)
1696
- ),
1697
- signers: [admin],
1698
- bytesCreatedOnChain: 0
1699
- };
1676
+ const endpoint = new umi.EndpointProgram.Endpoint(endpointProgram);
1677
+ return endpoint.initOAppSendLibrary(admin, { sender: oftStore, remote: remoteEid });
1700
1678
  }
1701
1679
  function initReceiveLibrary(accounts, remoteEid, endpointProgram = ENDPOINT_PROGRAM_ID) {
1702
1680
  const { admin, oftStore } = accounts;
1703
- const endpoint = new lzSolanaSdkV2.EndpointProgram.Endpoint(umiWeb3jsAdapters.toWeb3JsPublicKey(endpointProgram));
1704
- return {
1705
- instruction: umiWeb3jsAdapters.fromWeb3JsInstruction(
1706
- endpoint.initReceiveLibrary(umiWeb3jsAdapters.toWeb3JsPublicKey(admin.publicKey), umiWeb3jsAdapters.toWeb3JsPublicKey(oftStore), remoteEid)
1707
- ),
1708
- signers: [admin],
1709
- bytesCreatedOnChain: 0
1710
- };
1681
+ const endpoint = new umi.EndpointProgram.Endpoint(endpointProgram);
1682
+ return endpoint.initOAppReceiveLibrary(admin, { receiver: oftStore, remote: remoteEid });
1711
1683
  }
1712
1684
  function setSendLibrary(accounts, params, endpointProgram = ENDPOINT_PROGRAM_ID) {
1713
1685
  const { sendLibraryProgram, remoteEid } = params;
1714
1686
  const { admin, oftStore } = accounts;
1715
- const endpoint = new lzSolanaSdkV2.EndpointProgram.Endpoint(umiWeb3jsAdapters.toWeb3JsPublicKey(endpointProgram));
1716
- return {
1717
- instruction: umiWeb3jsAdapters.fromWeb3JsInstruction(
1718
- endpoint.setSendLibrary(
1719
- umiWeb3jsAdapters.toWeb3JsPublicKey(admin.publicKey),
1720
- umiWeb3jsAdapters.toWeb3JsPublicKey(oftStore),
1721
- umiWeb3jsAdapters.toWeb3JsPublicKey(sendLibraryProgram),
1722
- remoteEid
1723
- )
1724
- ),
1725
- signers: [admin],
1726
- bytesCreatedOnChain: 0
1727
- };
1687
+ const endpoint = new umi.EndpointProgram.Endpoint(endpointProgram);
1688
+ return endpoint.setOAppSendLibrary(admin, {
1689
+ sender: oftStore,
1690
+ remote: remoteEid,
1691
+ msgLibProgram: sendLibraryProgram
1692
+ });
1728
1693
  }
1729
1694
  function setReceiveLibrary(accounts, params, endpointProgram = ENDPOINT_PROGRAM_ID) {
1730
1695
  const { receiveLibraryProgram, remoteEid, gracePeriod } = params;
1731
1696
  const { admin, oftStore } = accounts;
1732
- const endpoint = new lzSolanaSdkV2.EndpointProgram.Endpoint(umiWeb3jsAdapters.toWeb3JsPublicKey(endpointProgram));
1733
- return {
1734
- instruction: umiWeb3jsAdapters.fromWeb3JsInstruction(
1735
- endpoint.setReceiveLibrary(
1736
- umiWeb3jsAdapters.toWeb3JsPublicKey(admin.publicKey),
1737
- umiWeb3jsAdapters.toWeb3JsPublicKey(oftStore),
1738
- umiWeb3jsAdapters.toWeb3JsPublicKey(receiveLibraryProgram),
1739
- remoteEid,
1740
- gracePeriod
1741
- )
1742
- ),
1743
- signers: [admin],
1744
- bytesCreatedOnChain: 0
1745
- };
1697
+ const endpoint = new umi.EndpointProgram.Endpoint(endpointProgram);
1698
+ return endpoint.setOAppReceiveLibrary(admin, {
1699
+ receiver: oftStore,
1700
+ remote: remoteEid,
1701
+ msgLibProgram: receiveLibraryProgram,
1702
+ gracePeriod
1703
+ });
1746
1704
  }
1747
1705
  function initConfig(accounts, remoteEid, programs) {
1748
1706
  const { admin, oftStore, payer } = accounts;
@@ -1754,28 +1712,26 @@ function initConfig(accounts, remoteEid, programs) {
1754
1712
  msgLibProgram = programs.msgLib ?? ULN_PROGRAM_ID;
1755
1713
  endpointProgram = programs.endpoint ?? ENDPOINT_PROGRAM_ID;
1756
1714
  }
1757
- const endpoint = new lzSolanaSdkV2.EndpointProgram.Endpoint(umiWeb3jsAdapters.toWeb3JsPublicKey(endpointProgram));
1715
+ const endpoint = new umi.EndpointProgram.Endpoint(endpointProgram);
1758
1716
  let msgLib;
1759
- if (msgLibProgram.toString() === lzSolanaSdkV2.SimpleMessageLibProgram.PROGRAM_ID.toBase58()) {
1760
- msgLib = new lzSolanaSdkV2.SimpleMessageLibProgram.SimpleMessageLib(lzSolanaSdkV2.SimpleMessageLibProgram.PROGRAM_ID);
1717
+ if (msgLibProgram === umi.SimpleMessageLibProgram.SIMPLE_MESSAGELIB_PROGRAM_ID) {
1718
+ msgLib = new umi.SimpleMessageLibProgram.SimpleMessageLib(umi.SimpleMessageLibProgram.SIMPLE_MESSAGELIB_PROGRAM_ID);
1761
1719
  } else {
1762
- msgLib = new lzSolanaSdkV2.UlnProgram.Uln(umiWeb3jsAdapters.toWeb3JsPublicKey(msgLibProgram));
1720
+ msgLib = new umi.UlnProgram.Uln(msgLibProgram);
1763
1721
  }
1764
- return {
1765
- instruction: umiWeb3jsAdapters.fromWeb3JsInstruction(
1766
- endpoint.initOAppConfig(
1767
- umiWeb3jsAdapters.toWeb3JsPublicKey(admin.publicKey),
1768
- msgLib,
1769
- umiWeb3jsAdapters.toWeb3JsPublicKey(payer.publicKey),
1770
- umiWeb3jsAdapters.toWeb3JsPublicKey(oftStore),
1771
- remoteEid
1772
- )
1773
- ),
1774
- signers: [admin, payer],
1775
- bytesCreatedOnChain: 0
1776
- };
1722
+ return endpoint.initOAppConfig(
1723
+ {
1724
+ delegate: admin,
1725
+ payer: payer.publicKey
1726
+ },
1727
+ {
1728
+ msgLibSDK: msgLib,
1729
+ oapp: oftStore,
1730
+ remote: remoteEid
1731
+ }
1732
+ );
1777
1733
  }
1778
- async function setConfig(connection, accounts, params, programs) {
1734
+ async function setConfig(rpc, accounts, params, programs) {
1779
1735
  const { signer, oftStore } = accounts;
1780
1736
  const { remoteEid, configType, config } = params;
1781
1737
  let msgLibProgram, endpointProgram;
@@ -1786,20 +1742,16 @@ async function setConfig(connection, accounts, params, programs) {
1786
1742
  msgLibProgram = programs.msgLib ?? ULN_PROGRAM_ID;
1787
1743
  endpointProgram = programs.endpoint ?? ENDPOINT_PROGRAM_ID;
1788
1744
  }
1789
- const endpoint = new lzSolanaSdkV2.EndpointProgram.Endpoint(umiWeb3jsAdapters.toWeb3JsPublicKey(endpointProgram));
1790
- return umiWeb3jsAdapters.fromWeb3JsInstruction(
1791
- await endpoint.setOappConfig(
1792
- connection,
1793
- umiWeb3jsAdapters.toWeb3JsPublicKey(signer),
1794
- umiWeb3jsAdapters.toWeb3JsPublicKey(oftStore),
1795
- umiWeb3jsAdapters.toWeb3JsPublicKey(msgLibProgram),
1796
- remoteEid,
1797
- {
1798
- configType,
1799
- value: config
1800
- }
1801
- )
1802
- );
1745
+ const endpoint = new umi.EndpointProgram.Endpoint(endpointProgram);
1746
+ return endpoint.setOAppConfig(rpc, signer, {
1747
+ oapp: oftStore,
1748
+ eid: remoteEid,
1749
+ config: {
1750
+ configType,
1751
+ value: config
1752
+ },
1753
+ msgLibProgram
1754
+ });
1803
1755
  }
1804
1756
  function withdrawFee2(accounts, amount, programs) {
1805
1757
  const { admin, mint, escrow, dest } = accounts;
@@ -1825,25 +1777,21 @@ async function send2(rpc, accounts, sendParams, programs, remainingAccounts) {
1825
1777
  const deriver = new OftPDA(programs.oft);
1826
1778
  const [oftStore] = deriver.oftStore(tokenEscrow);
1827
1779
  const [peer] = deriver.peer(oftStore, dstEid);
1828
- const connection = new web3_js.Connection(rpc.getEndpoint());
1829
1780
  if (remainingAccounts === void 0 || remainingAccounts.length === 0) {
1830
1781
  const peerAddr = accounts.peerAddr ?? await fetchPeerConfig({ rpc }, peer).then((peerInfo) => peerInfo.peerAddress);
1831
- const endpoint = new lzSolanaSdkV2.EndpointProgram.Endpoint(umiWeb3jsAdapters.toWeb3JsPublicKey(programs.endpoint ?? ENDPOINT_PROGRAM_ID));
1832
- const msgLibProgram = await getSendLibraryProgram(connection, endpoint, payer.publicKey, oftStore, dstEid);
1782
+ const endpoint = new umi.EndpointProgram.Endpoint(programs.endpoint ?? ENDPOINT_PROGRAM_ID);
1783
+ const msgLibProgram = await getSendLibraryProgram(rpc, endpoint, payer.publicKey, oftStore, dstEid);
1833
1784
  const packetPath = {
1834
- srcEid: 0,
1835
1785
  dstEid,
1836
- sender: bytes.hexlify(umi.publicKeyBytes(oftStore)),
1837
- receiver: bytes.hexlify(peerAddr)
1786
+ sender: oftStore,
1787
+ receiver: peerAddr
1838
1788
  };
1839
- remainingAccounts = await endpoint.getSendIXAccountMetaForCPI(
1840
- connection,
1841
- umiWeb3jsAdapters.toWeb3JsPublicKey(payer.publicKey),
1842
- packetPath,
1789
+ remainingAccounts = await endpoint.getSendIXAccountMetaForCPI(rpc, payer.publicKey, {
1790
+ path: packetPath,
1843
1791
  msgLibProgram
1844
- );
1792
+ });
1845
1793
  }
1846
- const [eventAuthorityPDA] = new lzSolanaSdkV2.EventPDADeriver(umiWeb3jsAdapters.toWeb3JsPublicKey(programs.oft)).eventAuthority();
1794
+ const [eventAuthorityPDA] = new umi.EventPDA(programs.oft).eventAuthority();
1847
1795
  const tokenProgram = programs.token ?? umiWeb3jsAdapters.fromWeb3JsPublicKey(TOKEN_PROGRAM_ID);
1848
1796
  const txBuilder = send(
1849
1797
  { programs: createOFTProgramRepo(programs.oft) },
@@ -1855,7 +1803,7 @@ async function send2(rpc, accounts, sendParams, programs, remainingAccounts) {
1855
1803
  tokenEscrow,
1856
1804
  tokenMint,
1857
1805
  tokenProgram,
1858
- eventAuthority: umiWeb3jsAdapters.fromWeb3JsPublicKey(eventAuthorityPDA),
1806
+ eventAuthority: eventAuthorityPDA,
1859
1807
  program: programs.oft,
1860
1808
  // params
1861
1809
  dstEid,
@@ -1871,7 +1819,7 @@ async function send2(rpc, accounts, sendParams, programs, remainingAccounts) {
1871
1819
  return txBuilder.addRemainingAccounts(
1872
1820
  remainingAccounts.map((acc) => {
1873
1821
  return {
1874
- pubkey: umiWeb3jsAdapters.fromWeb3JsPublicKey(acc.pubkey),
1822
+ pubkey: acc.pubkey,
1875
1823
  isSigner: acc.isSigner,
1876
1824
  isWritable: acc.isWritable
1877
1825
  };
@@ -1884,21 +1832,14 @@ async function quote(rpc, accounts, quoteParams, programs, remainingAccounts, ad
1884
1832
  const deriver = new OftPDA(programs.oft);
1885
1833
  const [oftStore] = deriver.oftStore(tokenEscrow);
1886
1834
  const [peer] = deriver.peer(oftStore, dstEid);
1887
- const connection = new web3_js.Connection(rpc.getEndpoint(), "confirmed");
1888
1835
  if (remainingAccounts === void 0 || remainingAccounts.length === 0) {
1889
1836
  const peerAddr = accounts.peerAddr ?? await fetchPeerConfig({ rpc }, peer).then((peerInfo) => peerInfo.peerAddress);
1890
- const endpoint = new lzSolanaSdkV2.EndpointProgram.Endpoint(umiWeb3jsAdapters.toWeb3JsPublicKey(programs.endpoint ?? ENDPOINT_PROGRAM_ID));
1891
- const messageLib = await getSendLibraryProgram(connection, endpoint, payer, oftStore, dstEid);
1892
- remainingAccounts = await endpoint.getQuoteIXAccountMetaForCPI(
1893
- connection,
1894
- umiWeb3jsAdapters.toWeb3JsPublicKey(payer),
1895
- {
1896
- sender: bytes.hexlify(umi.publicKeyBytes(oftStore)),
1897
- dstEid,
1898
- receiver: bytes.hexlify(peerAddr)
1899
- },
1900
- messageLib
1901
- );
1837
+ const endpoint = new umi.EndpointProgram.Endpoint(programs.endpoint ?? ENDPOINT_PROGRAM_ID);
1838
+ const messageLib = await getSendLibraryProgram(rpc, endpoint, payer, oftStore, dstEid);
1839
+ remainingAccounts = await endpoint.getQuoteIXAccountMetaForCPI(rpc, payer, {
1840
+ path: { sender: oftStore, dstEid, receiver: peerAddr },
1841
+ msgLibProgram: messageLib
1842
+ });
1902
1843
  }
1903
1844
  let txBuilder = quoteSend(
1904
1845
  { programs: createOFTProgramRepo(programs.oft) },
@@ -1920,7 +1861,7 @@ async function quote(rpc, accounts, quoteParams, programs, remainingAccounts, ad
1920
1861
  // Get remaining accounts from msgLib(simple_msgLib or uln)
1921
1862
  remainingAccounts.map((acc) => {
1922
1863
  return {
1923
- pubkey: umiWeb3jsAdapters.fromWeb3JsPublicKey(acc.pubkey),
1864
+ pubkey: acc.pubkey,
1924
1865
  isSigner: acc.isSigner,
1925
1866
  isWritable: acc.isWritable
1926
1867
  };
@@ -1930,17 +1871,16 @@ async function quote(rpc, accounts, quoteParams, programs, remainingAccounts, ad
1930
1871
  const modifyComputeUnits = web3_js.ComputeBudgetProgram.setComputeUnitLimit({
1931
1872
  units: 1e6
1932
1873
  });
1933
- const buffer = await lzSolanaSdkV2.simulateTransaction(
1934
- connection,
1874
+ return umi.simulateWeb3JsTransaction(
1875
+ rpc,
1935
1876
  [modifyComputeUnits, web3Ix],
1936
1877
  web3Ix.programId,
1937
1878
  umiWeb3jsAdapters.toWeb3JsPublicKey(payer),
1879
+ umi.EndpointProgram.types.getMessagingFeeSerializer(),
1938
1880
  "confirmed",
1939
1881
  void 0,
1940
1882
  addressLookupTable === void 0 ? void 0 : umiWeb3jsAdapters.toWeb3JsPublicKey(addressLookupTable)
1941
1883
  );
1942
- const fee = lzSolanaSdkV2.EndpointProgram.types.messagingFeeBeet.read(buffer, 0);
1943
- return { nativeFee: BigInt(fee.nativeFee.toString()), lzTokenFee: BigInt(fee.lzTokenFee.toString()) };
1944
1884
  }
1945
1885
  async function quoteOft2(rpc, accounts, quoteParams, oftProgram) {
1946
1886
  const { payer, tokenMint, tokenEscrow } = accounts;
@@ -1965,32 +1905,23 @@ async function quoteOft2(rpc, accounts, quoteParams, oftProgram) {
1965
1905
  }
1966
1906
  ).getInstructions()[0];
1967
1907
  const web3Ix = umiWeb3jsAdapters.toWeb3JsInstruction(ix);
1968
- const connection = new web3_js.Connection(rpc.getEndpoint());
1969
- const returnedValues = await lzSolanaSdkV2.simulateTransaction(
1970
- connection,
1908
+ return umi.simulateWeb3JsTransaction(
1909
+ rpc.getEndpoint(),
1971
1910
  [web3Ix],
1972
1911
  web3Ix.programId,
1973
1912
  umiWeb3jsAdapters.toWeb3JsPublicKey(payer),
1913
+ getQuoteOFTResultSerializer(),
1974
1914
  "confirmed"
1975
1915
  );
1976
- const [result] = getQuoteOFTResultSerializer().deserialize(returnedValues, 0);
1977
- return result;
1978
1916
  }
1979
1917
  function initOAppNonce(accounts, remoteEid, remoteOappAddr, endpointProgram = ENDPOINT_PROGRAM_ID) {
1980
1918
  const { admin, oftStore } = accounts;
1981
- const endpoint = new lzSolanaSdkV2.EndpointProgram.Endpoint(umiWeb3jsAdapters.toWeb3JsPublicKey(endpointProgram));
1982
- return {
1983
- instruction: umiWeb3jsAdapters.fromWeb3JsInstruction(
1984
- endpoint.initOAppNonce(
1985
- umiWeb3jsAdapters.toWeb3JsPublicKey(admin.publicKey),
1986
- remoteEid,
1987
- umiWeb3jsAdapters.toWeb3JsPublicKey(oftStore),
1988
- remoteOappAddr
1989
- )
1990
- ),
1991
- signers: [admin],
1992
- bytesCreatedOnChain: 0
1993
- };
1919
+ const endpoint = new umi.EndpointProgram.Endpoint(endpointProgram);
1920
+ return endpoint.initOAppNonce(admin, {
1921
+ localOApp: oftStore,
1922
+ remote: remoteEid,
1923
+ remoteOApp: remoteOappAddr
1924
+ });
1994
1925
  }
1995
1926
  async function getEndpointConfig(rpc, oftStore, endpointId, programs) {
1996
1927
  let msgLibProgram, endpointProgram;
@@ -2001,38 +1932,33 @@ async function getEndpointConfig(rpc, oftStore, endpointId, programs) {
2001
1932
  msgLibProgram = programs.msgLib ?? ULN_PROGRAM_ID;
2002
1933
  endpointProgram = programs.endpoint ?? ENDPOINT_PROGRAM_ID;
2003
1934
  }
2004
- const endpointDeriver = new lzSolanaSdkV2.EndpointPDADeriver(umiWeb3jsAdapters.toWeb3JsPublicKey(endpointProgram));
2005
- const ulnDeriver = new lzSolanaSdkV2.UlnPDADeriver(umiWeb3jsAdapters.toWeb3JsPublicKey(msgLibProgram));
2006
- const web3OftStore = umiWeb3jsAdapters.toWeb3JsPublicKey(oftStore);
2007
- const [sendLib] = endpointDeriver.sendLibraryConfig(web3OftStore, endpointId);
1935
+ const endpointDeriver = new umi.EndpointPDA(endpointProgram);
1936
+ const ulnDeriver = new umi.UlnPDA(msgLibProgram);
1937
+ const [sendLib] = endpointDeriver.sendLibraryConfig(oftStore, endpointId);
2008
1938
  const [defaultSendLib] = endpointDeriver.defaultSendLibraryConfig(endpointId);
2009
- const [receiveLib] = endpointDeriver.receiveLibraryConfig(web3OftStore, endpointId);
1939
+ const [receiveLib] = endpointDeriver.receiveLibraryConfig(oftStore, endpointId);
2010
1940
  const [defaultReceiveLib] = endpointDeriver.defaultReceiveLibraryConfig(endpointId);
2011
1941
  const [msgLib] = ulnDeriver.messageLib();
2012
- const connection = new web3_js.Connection(rpc.getEndpoint());
2013
- let sendLibraryConfig = await lzSolanaSdkV2.EndpointProgram.accounts.SendLibraryConfig.fromAccountAddress(connection, sendLib);
2014
- let receiveLibraryConfig = await lzSolanaSdkV2.EndpointProgram.accounts.ReceiveLibraryConfig.fromAccountAddress(connection, receiveLib);
2015
- const defaultSendLibraryConfig = await lzSolanaSdkV2.EndpointProgram.accounts.SendLibraryConfig.fromAccountAddress(connection, defaultSendLib);
2016
- const defaultReceiveLibraryConfig = await lzSolanaSdkV2.EndpointProgram.accounts.ReceiveLibraryConfig.fromAccountAddress(connection, defaultReceiveLib);
2017
- const nil64 = "18446744073709551615";
1942
+ let sendLibraryConfig = await umi.EndpointProgram.accounts.fetchSendLibraryConfig({ rpc }, sendLib);
1943
+ let receiveLibraryConfig = await umi.EndpointProgram.accounts.fetchReceiveLibraryConfig({ rpc }, receiveLib);
1944
+ const defaultSendLibraryConfig = await umi.EndpointProgram.accounts.fetchSendLibraryConfig({ rpc }, defaultSendLib);
1945
+ const defaultReceiveLibraryConfig = await umi.EndpointProgram.accounts.fetchReceiveLibraryConfig({ rpc }, defaultReceiveLib);
1946
+ const nil64 = 18446744073709551615n;
2018
1947
  const nil8 = 255;
2019
- if (sendLibraryConfig.messageLib.toBase58() === umi.defaultPublicKey().toString()) {
1948
+ if (sendLibraryConfig.messageLib === umi$1.defaultPublicKey()) {
2020
1949
  sendLibraryConfig = defaultSendLibraryConfig;
2021
1950
  }
2022
- if (receiveLibraryConfig.messageLib.toBase58() === umi.defaultPublicKey().toString()) {
1951
+ if (receiveLibraryConfig.messageLib === umi$1.defaultPublicKey()) {
2023
1952
  receiveLibraryConfig = defaultReceiveLibraryConfig;
2024
1953
  }
2025
- if (sendLibraryConfig.messageLib.equals(msgLib)) {
1954
+ if (sendLibraryConfig.messageLib === msgLib) {
2026
1955
  const [ulnDefaultSendConfigPDA] = ulnDeriver.defaultSendConfig(endpointId);
2027
- const [ulnSendConfigPDA] = ulnDeriver.sendConfig(endpointId, web3OftStore);
2028
- const ulnSendConfig = await lzSolanaSdkV2.UlnProgram.accounts.SendConfig.fromAccountAddress(connection, ulnSendConfigPDA);
2029
- const ulnDefaultSendConfig = await lzSolanaSdkV2.UlnProgram.accounts.SendConfig.fromAccountAddress(
2030
- connection,
2031
- ulnDefaultSendConfigPDA
2032
- );
2033
- if (nil64 === ulnSendConfig.uln.confirmations.toString()) {
2034
- ulnSendConfig.uln.confirmations = 0;
2035
- } else if (ulnSendConfig.uln.confirmations == 0) {
1956
+ const [ulnSendConfigPDA] = ulnDeriver.sendConfig(endpointId, oftStore);
1957
+ const ulnSendConfig = await umi.UlnProgram.accounts.fetchSendConfig({ rpc }, ulnSendConfigPDA);
1958
+ const ulnDefaultSendConfig = await umi.UlnProgram.accounts.fetchSendConfig({ rpc }, ulnDefaultSendConfigPDA);
1959
+ if (nil64 === ulnSendConfig.uln.confirmations) {
1960
+ ulnSendConfig.uln.confirmations = 0n;
1961
+ } else if (ulnSendConfig.uln.confirmations == 0n) {
2036
1962
  ulnSendConfig.uln.confirmations = ulnDefaultSendConfig.uln.confirmations;
2037
1963
  }
2038
1964
  if (ulnSendConfig.uln.requiredDvnCount == nil8) {
@@ -2051,20 +1977,17 @@ async function getEndpointConfig(rpc, oftStore, endpointId, programs) {
2051
1977
  }
2052
1978
  sendLibraryConfig.ulnSendConfig = ulnSendConfig;
2053
1979
  }
2054
- if (receiveLibraryConfig.messageLib.equals(msgLib)) {
1980
+ if (receiveLibraryConfig.messageLib === msgLib) {
2055
1981
  const [ulnDefaultReceiveConfigPDA] = ulnDeriver.defaultReceiveConfig(endpointId);
2056
- const [ulnReceiveConfigPDA] = ulnDeriver.receiveConfig(endpointId, web3OftStore);
2057
- const ulnReceiveConfig = await lzSolanaSdkV2.UlnProgram.accounts.ReceiveConfig.fromAccountAddress(
2058
- connection,
2059
- ulnReceiveConfigPDA
2060
- );
2061
- const ulnDefaultReceiveConfig = await lzSolanaSdkV2.UlnProgram.accounts.ReceiveConfig.fromAccountAddress(
2062
- connection,
1982
+ const [ulnReceiveConfigPDA] = ulnDeriver.receiveConfig(endpointId, oftStore);
1983
+ const ulnReceiveConfig = await umi.UlnProgram.accounts.fetchReceiveConfig({ rpc }, ulnReceiveConfigPDA);
1984
+ const ulnDefaultReceiveConfig = await umi.UlnProgram.accounts.fetchReceiveConfig(
1985
+ { rpc },
2063
1986
  ulnDefaultReceiveConfigPDA
2064
1987
  );
2065
- if (nil64 === ulnReceiveConfig.uln.confirmations.toString()) {
2066
- ulnReceiveConfig.uln.confirmations = 0;
2067
- } else if (ulnReceiveConfig.uln.confirmations == 0) {
1988
+ if (nil64 === ulnReceiveConfig.uln.confirmations) {
1989
+ ulnReceiveConfig.uln.confirmations = 0n;
1990
+ } else if (ulnReceiveConfig.uln.confirmations == 0n) {
2068
1991
  ulnReceiveConfig.uln.confirmations = ulnDefaultReceiveConfig.uln.confirmations;
2069
1992
  }
2070
1993
  if (ulnReceiveConfig.uln.requiredDvnCount == nil8) {
@@ -2094,31 +2017,26 @@ async function getPeerAddress(rpc, oftInstance, remoteEid, oftProgramId) {
2094
2017
  return bytes.hexlify(peerInfo.peerAddress);
2095
2018
  }
2096
2019
  async function getDelegate(rpc, oftInstance, endpointProgram = ENDPOINT_PROGRAM_ID) {
2097
- const [oAppRegistry] = new lzSolanaSdkV2.EndpointPDADeriver(umiWeb3jsAdapters.toWeb3JsPublicKey(endpointProgram)).oappRegistry(
2098
- umiWeb3jsAdapters.toWeb3JsPublicKey(oftInstance)
2099
- );
2100
- const oAppRegistryInfo = await lzSolanaSdkV2.EndpointProgram.accounts.OAppRegistry.fromAccountAddress(
2101
- new web3_js.Connection(rpc.getEndpoint()),
2102
- oAppRegistry
2103
- );
2104
- return umiWeb3jsAdapters.fromWeb3JsPublicKey(oAppRegistryInfo.delegate);
2020
+ const [oAppRegistry] = new umi.EndpointPDA(endpointProgram).oappRegistry(oftInstance);
2021
+ const oAppRegistryInfo = await umi.EndpointProgram.accounts.fetchOAppRegistry({ rpc }, oAppRegistry);
2022
+ return oAppRegistryInfo.delegate;
2105
2023
  }
2106
2024
  async function getEnforcedOptions(rpc, oftInstance, remoteEid, oftProgramId) {
2107
2025
  const [peer] = new OftPDA(oftProgramId).peer(oftInstance, remoteEid);
2108
2026
  const peerInfo = await fetchPeerConfig({ rpc }, peer);
2109
2027
  return peerInfo.enforcedOptions;
2110
2028
  }
2111
- async function getSendLibraryProgram(connection, endpoint, payer, oftStore, remoteEid) {
2112
- const sendLibInfo = await endpoint.getSendLibrary(connection, umiWeb3jsAdapters.toWeb3JsPublicKey(oftStore), remoteEid);
2113
- if (!sendLibInfo?.programId) {
2029
+ async function getSendLibraryProgram(rpc, endpoint, payer, oftStore, remoteEid) {
2030
+ const sendLibInfo = await endpoint.getSendLibrary(rpc, oftStore, remoteEid);
2031
+ if (!sendLibInfo.programId) {
2114
2032
  throw new Error("Send library not initialized or blocked message library");
2115
2033
  }
2116
2034
  const { programId: msgLibProgram } = sendLibInfo;
2117
- const msgLibVersion = await endpoint.getMessageLibVersion(connection, umiWeb3jsAdapters.toWeb3JsPublicKey(payer), msgLibProgram);
2118
- if (msgLibVersion?.major.toString() === "0" && msgLibVersion.minor == 0 && msgLibVersion.endpointVersion == 2) {
2119
- return new lzSolanaSdkV2.SimpleMessageLibProgram.SimpleMessageLib(msgLibProgram);
2120
- } else if (msgLibVersion?.major.toString() === "3" && msgLibVersion.minor == 0 && msgLibVersion.endpointVersion == 2) {
2121
- return new lzSolanaSdkV2.UlnProgram.Uln(msgLibProgram);
2035
+ const msgLibVersion = await endpoint.getMessageLibVersion(rpc, payer, msgLibProgram);
2036
+ if (msgLibVersion.major.toString() === "0" && msgLibVersion.minor == 0 && msgLibVersion.endpointVersion == 2) {
2037
+ return new umi.SimpleMessageLibProgram.SimpleMessageLib(msgLibProgram);
2038
+ } else if (msgLibVersion.major.toString() === "3" && msgLibVersion.minor == 0 && msgLibVersion.endpointVersion == 2) {
2039
+ return new umi.UlnProgram.Uln(msgLibProgram);
2122
2040
  }
2123
2041
  throw new Error(`Unsupported message library version: ${JSON.stringify(msgLibVersion, null, 2)}`);
2124
2042
  }
@@ -2196,39 +2114,39 @@ function getLzReceiveTypesAccountsAccountDataSerializer2() {
2196
2114
  );
2197
2115
  }
2198
2116
  function deserializeLzReceiveTypesAccounts2(rawAccount) {
2199
- return umi.deserializeAccount(
2117
+ return umi$1.deserializeAccount(
2200
2118
  rawAccount,
2201
2119
  getLzReceiveTypesAccountsAccountDataSerializer2()
2202
2120
  );
2203
2121
  }
2204
2122
  async function fetchLzReceiveTypesAccounts2(context, publicKey3, options) {
2205
2123
  const maybeAccount = await context.rpc.getAccount(
2206
- umi.publicKey(publicKey3, false),
2124
+ umi$1.publicKey(publicKey3, false),
2207
2125
  options
2208
2126
  );
2209
- umi.assertAccountExists(maybeAccount, "LzReceiveTypesAccounts");
2127
+ umi$1.assertAccountExists(maybeAccount, "LzReceiveTypesAccounts");
2210
2128
  return deserializeLzReceiveTypesAccounts2(maybeAccount);
2211
2129
  }
2212
2130
  async function safeFetchLzReceiveTypesAccounts2(context, publicKey3, options) {
2213
2131
  const maybeAccount = await context.rpc.getAccount(
2214
- umi.publicKey(publicKey3, false),
2132
+ umi$1.publicKey(publicKey3, false),
2215
2133
  options
2216
2134
  );
2217
2135
  return maybeAccount.exists ? deserializeLzReceiveTypesAccounts2(maybeAccount) : null;
2218
2136
  }
2219
2137
  async function fetchAllLzReceiveTypesAccounts2(context, publicKeys, options) {
2220
2138
  const maybeAccounts = await context.rpc.getAccounts(
2221
- publicKeys.map((key) => umi.publicKey(key, false)),
2139
+ publicKeys.map((key) => umi$1.publicKey(key, false)),
2222
2140
  options
2223
2141
  );
2224
2142
  return maybeAccounts.map((maybeAccount) => {
2225
- umi.assertAccountExists(maybeAccount, "LzReceiveTypesAccounts");
2143
+ umi$1.assertAccountExists(maybeAccount, "LzReceiveTypesAccounts");
2226
2144
  return deserializeLzReceiveTypesAccounts2(maybeAccount);
2227
2145
  });
2228
2146
  }
2229
2147
  async function safeFetchAllLzReceiveTypesAccounts2(context, publicKeys, options) {
2230
2148
  const maybeAccounts = await context.rpc.getAccounts(
2231
- publicKeys.map((key) => umi.publicKey(key, false)),
2149
+ publicKeys.map((key) => umi$1.publicKey(key, false)),
2232
2150
  options
2233
2151
  );
2234
2152
  return maybeAccounts.filter((maybeAccount) => maybeAccount.exists).map(
@@ -2237,7 +2155,7 @@ async function safeFetchAllLzReceiveTypesAccounts2(context, publicKeys, options)
2237
2155
  }
2238
2156
  function getLzReceiveTypesAccountsGpaBuilder2(context) {
2239
2157
  const programId = context.programs.getPublicKey("oft", "");
2240
- return umi.gpaBuilder(context, programId).registerFields({
2158
+ return umi$1.gpaBuilder(context, programId).registerFields({
2241
2159
  discriminator: [0, serializers.bytes({ size: 8 })],
2242
2160
  oftStore: [8, serializers.publicKey()],
2243
2161
  tokenMint: [40, serializers.publicKey()]
@@ -2518,43 +2436,43 @@ function getOFTStoreAccountDataSerializer2() {
2518
2436
  );
2519
2437
  }
2520
2438
  function deserializeOFTStore2(rawAccount) {
2521
- return umi.deserializeAccount(rawAccount, getOFTStoreAccountDataSerializer2());
2439
+ return umi$1.deserializeAccount(rawAccount, getOFTStoreAccountDataSerializer2());
2522
2440
  }
2523
2441
  async function fetchOFTStore2(context, publicKey3, options) {
2524
2442
  const maybeAccount = await context.rpc.getAccount(
2525
- umi.publicKey(publicKey3, false),
2443
+ umi$1.publicKey(publicKey3, false),
2526
2444
  options
2527
2445
  );
2528
- umi.assertAccountExists(maybeAccount, "OFTStore");
2446
+ umi$1.assertAccountExists(maybeAccount, "OFTStore");
2529
2447
  return deserializeOFTStore2(maybeAccount);
2530
2448
  }
2531
2449
  async function safeFetchOFTStore2(context, publicKey3, options) {
2532
2450
  const maybeAccount = await context.rpc.getAccount(
2533
- umi.publicKey(publicKey3, false),
2451
+ umi$1.publicKey(publicKey3, false),
2534
2452
  options
2535
2453
  );
2536
2454
  return maybeAccount.exists ? deserializeOFTStore2(maybeAccount) : null;
2537
2455
  }
2538
2456
  async function fetchAllOFTStore2(context, publicKeys, options) {
2539
2457
  const maybeAccounts = await context.rpc.getAccounts(
2540
- publicKeys.map((key) => umi.publicKey(key, false)),
2458
+ publicKeys.map((key) => umi$1.publicKey(key, false)),
2541
2459
  options
2542
2460
  );
2543
2461
  return maybeAccounts.map((maybeAccount) => {
2544
- umi.assertAccountExists(maybeAccount, "OFTStore");
2462
+ umi$1.assertAccountExists(maybeAccount, "OFTStore");
2545
2463
  return deserializeOFTStore2(maybeAccount);
2546
2464
  });
2547
2465
  }
2548
2466
  async function safeFetchAllOFTStore2(context, publicKeys, options) {
2549
2467
  const maybeAccounts = await context.rpc.getAccounts(
2550
- publicKeys.map((key) => umi.publicKey(key, false)),
2468
+ publicKeys.map((key) => umi$1.publicKey(key, false)),
2551
2469
  options
2552
2470
  );
2553
2471
  return maybeAccounts.filter((maybeAccount) => maybeAccount.exists).map((maybeAccount) => deserializeOFTStore2(maybeAccount));
2554
2472
  }
2555
2473
  function getOFTStoreGpaBuilder2(context) {
2556
2474
  const programId = context.programs.getPublicKey("oft", "");
2557
- return umi.gpaBuilder(context, programId).registerFields({
2475
+ return umi$1.gpaBuilder(context, programId).registerFields({
2558
2476
  discriminator: [0, serializers.bytes({ size: 8 })],
2559
2477
  oftType: [8, getOFTTypeSerializer2()],
2560
2478
  ld2sdRate: [9, serializers.u64()],
@@ -2595,43 +2513,43 @@ function getPeerConfigAccountDataSerializer2() {
2595
2513
  );
2596
2514
  }
2597
2515
  function deserializePeerConfig2(rawAccount) {
2598
- return umi.deserializeAccount(rawAccount, getPeerConfigAccountDataSerializer2());
2516
+ return umi$1.deserializeAccount(rawAccount, getPeerConfigAccountDataSerializer2());
2599
2517
  }
2600
2518
  async function fetchPeerConfig2(context, publicKey3, options) {
2601
2519
  const maybeAccount = await context.rpc.getAccount(
2602
- umi.publicKey(publicKey3, false),
2520
+ umi$1.publicKey(publicKey3, false),
2603
2521
  options
2604
2522
  );
2605
- umi.assertAccountExists(maybeAccount, "PeerConfig");
2523
+ umi$1.assertAccountExists(maybeAccount, "PeerConfig");
2606
2524
  return deserializePeerConfig2(maybeAccount);
2607
2525
  }
2608
2526
  async function safeFetchPeerConfig2(context, publicKey3, options) {
2609
2527
  const maybeAccount = await context.rpc.getAccount(
2610
- umi.publicKey(publicKey3, false),
2528
+ umi$1.publicKey(publicKey3, false),
2611
2529
  options
2612
2530
  );
2613
2531
  return maybeAccount.exists ? deserializePeerConfig2(maybeAccount) : null;
2614
2532
  }
2615
2533
  async function fetchAllPeerConfig2(context, publicKeys, options) {
2616
2534
  const maybeAccounts = await context.rpc.getAccounts(
2617
- publicKeys.map((key) => umi.publicKey(key, false)),
2535
+ publicKeys.map((key) => umi$1.publicKey(key, false)),
2618
2536
  options
2619
2537
  );
2620
2538
  return maybeAccounts.map((maybeAccount) => {
2621
- umi.assertAccountExists(maybeAccount, "PeerConfig");
2539
+ umi$1.assertAccountExists(maybeAccount, "PeerConfig");
2622
2540
  return deserializePeerConfig2(maybeAccount);
2623
2541
  });
2624
2542
  }
2625
2543
  async function safeFetchAllPeerConfig2(context, publicKeys, options) {
2626
2544
  const maybeAccounts = await context.rpc.getAccounts(
2627
- publicKeys.map((key) => umi.publicKey(key, false)),
2545
+ publicKeys.map((key) => umi$1.publicKey(key, false)),
2628
2546
  options
2629
2547
  );
2630
2548
  return maybeAccounts.filter((maybeAccount) => maybeAccount.exists).map((maybeAccount) => deserializePeerConfig2(maybeAccount));
2631
2549
  }
2632
2550
  function getPeerConfigGpaBuilder2(context) {
2633
2551
  const programId = context.programs.getPublicKey("oft", "");
2634
- return umi.gpaBuilder(context, programId).registerFields({
2552
+ return umi$1.gpaBuilder(context, programId).registerFields({
2635
2553
  discriminator: [0, serializers.bytes({ size: 8 })],
2636
2554
  peerAddress: [8, serializers.bytes({ size: 32 })],
2637
2555
  enforcedOptions: [40, getEnforcedOptionsSerializer2()],
@@ -2663,7 +2581,7 @@ __export(errors_exports2, {
2663
2581
  });
2664
2582
  var codeToErrorMap2 = /* @__PURE__ */ new Map();
2665
2583
  var nameToErrorMap2 = /* @__PURE__ */ new Map();
2666
- var UnauthorizedError2 = class extends umi.ProgramError {
2584
+ var UnauthorizedError2 = class extends umi$1.ProgramError {
2667
2585
  // 6000
2668
2586
  constructor(program, cause) {
2669
2587
  super("", program, cause);
@@ -2673,7 +2591,7 @@ var UnauthorizedError2 = class extends umi.ProgramError {
2673
2591
  };
2674
2592
  codeToErrorMap2.set(6e3, UnauthorizedError2);
2675
2593
  nameToErrorMap2.set("Unauthorized", UnauthorizedError2);
2676
- var InvalidSenderError2 = class extends umi.ProgramError {
2594
+ var InvalidSenderError2 = class extends umi$1.ProgramError {
2677
2595
  // 6001
2678
2596
  constructor(program, cause) {
2679
2597
  super("", program, cause);
@@ -2683,7 +2601,7 @@ var InvalidSenderError2 = class extends umi.ProgramError {
2683
2601
  };
2684
2602
  codeToErrorMap2.set(6001, InvalidSenderError2);
2685
2603
  nameToErrorMap2.set("InvalidSender", InvalidSenderError2);
2686
- var InvalidDecimalsError2 = class extends umi.ProgramError {
2604
+ var InvalidDecimalsError2 = class extends umi$1.ProgramError {
2687
2605
  // 6002
2688
2606
  constructor(program, cause) {
2689
2607
  super("", program, cause);
@@ -2693,7 +2611,7 @@ var InvalidDecimalsError2 = class extends umi.ProgramError {
2693
2611
  };
2694
2612
  codeToErrorMap2.set(6002, InvalidDecimalsError2);
2695
2613
  nameToErrorMap2.set("InvalidDecimals", InvalidDecimalsError2);
2696
- var SlippageExceededError2 = class extends umi.ProgramError {
2614
+ var SlippageExceededError2 = class extends umi$1.ProgramError {
2697
2615
  // 6003
2698
2616
  constructor(program, cause) {
2699
2617
  super("", program, cause);
@@ -2703,7 +2621,7 @@ var SlippageExceededError2 = class extends umi.ProgramError {
2703
2621
  };
2704
2622
  codeToErrorMap2.set(6003, SlippageExceededError2);
2705
2623
  nameToErrorMap2.set("SlippageExceeded", SlippageExceededError2);
2706
- var InvalidTokenDestError2 = class extends umi.ProgramError {
2624
+ var InvalidTokenDestError2 = class extends umi$1.ProgramError {
2707
2625
  // 6004
2708
2626
  constructor(program, cause) {
2709
2627
  super("", program, cause);
@@ -2713,7 +2631,7 @@ var InvalidTokenDestError2 = class extends umi.ProgramError {
2713
2631
  };
2714
2632
  codeToErrorMap2.set(6004, InvalidTokenDestError2);
2715
2633
  nameToErrorMap2.set("InvalidTokenDest", InvalidTokenDestError2);
2716
- var RateLimitExceededError2 = class extends umi.ProgramError {
2634
+ var RateLimitExceededError2 = class extends umi$1.ProgramError {
2717
2635
  // 6005
2718
2636
  constructor(program, cause) {
2719
2637
  super("", program, cause);
@@ -2723,7 +2641,7 @@ var RateLimitExceededError2 = class extends umi.ProgramError {
2723
2641
  };
2724
2642
  codeToErrorMap2.set(6005, RateLimitExceededError2);
2725
2643
  nameToErrorMap2.set("RateLimitExceeded", RateLimitExceededError2);
2726
- var InvalidFeeError2 = class extends umi.ProgramError {
2644
+ var InvalidFeeError2 = class extends umi$1.ProgramError {
2727
2645
  // 6006
2728
2646
  constructor(program, cause) {
2729
2647
  super("", program, cause);
@@ -2733,7 +2651,7 @@ var InvalidFeeError2 = class extends umi.ProgramError {
2733
2651
  };
2734
2652
  codeToErrorMap2.set(6006, InvalidFeeError2);
2735
2653
  nameToErrorMap2.set("InvalidFee", InvalidFeeError2);
2736
- var InvalidMintAuthorityError2 = class extends umi.ProgramError {
2654
+ var InvalidMintAuthorityError2 = class extends umi$1.ProgramError {
2737
2655
  // 6007
2738
2656
  constructor(program, cause) {
2739
2657
  super("", program, cause);
@@ -2743,7 +2661,7 @@ var InvalidMintAuthorityError2 = class extends umi.ProgramError {
2743
2661
  };
2744
2662
  codeToErrorMap2.set(6007, InvalidMintAuthorityError2);
2745
2663
  nameToErrorMap2.set("InvalidMintAuthority", InvalidMintAuthorityError2);
2746
- var PausedError2 = class extends umi.ProgramError {
2664
+ var PausedError2 = class extends umi$1.ProgramError {
2747
2665
  // 6008
2748
2666
  constructor(program, cause) {
2749
2667
  super("", program, cause);
@@ -2805,10 +2723,10 @@ function expectPublicKey2(value) {
2805
2723
  if (!value) {
2806
2724
  throw new Error("Expected a PublicKey.");
2807
2725
  }
2808
- return umi.publicKey(value, false);
2726
+ return umi$1.publicKey(value, false);
2809
2727
  }
2810
2728
  function expectPda2(value) {
2811
- if (!value || !Array.isArray(value) || !umi.isPda(value)) {
2729
+ if (!value || !Array.isArray(value) || !umi$1.isPda(value)) {
2812
2730
  throw new Error("Expected a PDA.");
2813
2731
  }
2814
2732
  return value;
@@ -2822,12 +2740,12 @@ function getAccountMetasAndSigners2(accounts, optionalAccountStrategy, programId
2822
2740
  keys.push({ pubkey: programId, isSigner: false, isWritable: false });
2823
2741
  return;
2824
2742
  }
2825
- if (umi.isSigner(account.value)) {
2743
+ if (umi$1.isSigner(account.value)) {
2826
2744
  signers.push(account.value);
2827
2745
  }
2828
2746
  keys.push({
2829
- pubkey: umi.publicKey(account.value, false),
2830
- isSigner: umi.isSigner(account.value),
2747
+ pubkey: umi$1.publicKey(account.value, false),
2748
+ isSigner: umi$1.isSigner(account.value),
2831
2749
  isWritable: account.isWritable
2832
2750
  });
2833
2751
  });
@@ -2922,7 +2840,7 @@ function initOft3(context, input) {
2922
2840
  resolvedArgs
2923
2841
  );
2924
2842
  const bytesCreatedOnChain = 0;
2925
- return umi.transactionBuilder([
2843
+ return umi$1.transactionBuilder([
2926
2844
  { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }
2927
2845
  ]);
2928
2846
  }
@@ -3036,7 +2954,7 @@ function lzReceive2(context, input) {
3036
2954
  resolvedArgs
3037
2955
  );
3038
2956
  const bytesCreatedOnChain = 0;
3039
- return umi.transactionBuilder([
2957
+ return umi$1.transactionBuilder([
3040
2958
  { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }
3041
2959
  ]);
3042
2960
  }
@@ -3082,7 +3000,7 @@ function lzReceiveTypes2(context, input) {
3082
3000
  resolvedArgs
3083
3001
  );
3084
3002
  const bytesCreatedOnChain = 0;
3085
- return umi.transactionBuilder([
3003
+ return umi$1.transactionBuilder([
3086
3004
  { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }
3087
3005
  ]);
3088
3006
  }
@@ -3135,7 +3053,7 @@ function quoteOft3(context, input) {
3135
3053
  resolvedArgs
3136
3054
  );
3137
3055
  const bytesCreatedOnChain = 0;
3138
- return umi.transactionBuilder([
3056
+ return umi$1.transactionBuilder([
3139
3057
  { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }
3140
3058
  ]);
3141
3059
  }
@@ -3188,7 +3106,7 @@ function quoteSend2(context, input) {
3188
3106
  resolvedArgs
3189
3107
  );
3190
3108
  const bytesCreatedOnChain = 0;
3191
- return umi.transactionBuilder([
3109
+ return umi$1.transactionBuilder([
3192
3110
  { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }
3193
3111
  ]);
3194
3112
  }
@@ -3279,7 +3197,7 @@ function send3(context, input) {
3279
3197
  resolvedArgs
3280
3198
  );
3281
3199
  const bytesCreatedOnChain = 0;
3282
- return umi.transactionBuilder([
3200
+ return umi$1.transactionBuilder([
3283
3201
  { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }
3284
3202
  ]);
3285
3203
  }
@@ -3325,7 +3243,7 @@ function setOftConfig2(context, input) {
3325
3243
  resolvedArgs
3326
3244
  );
3327
3245
  const bytesCreatedOnChain = 0;
3328
- return umi.transactionBuilder([
3246
+ return umi$1.transactionBuilder([
3329
3247
  { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }
3330
3248
  ]);
3331
3249
  }
@@ -3371,7 +3289,7 @@ function setPause2(context, input) {
3371
3289
  resolvedArgs
3372
3290
  );
3373
3291
  const bytesCreatedOnChain = 0;
3374
- return umi.transactionBuilder([
3292
+ return umi$1.transactionBuilder([
3375
3293
  { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }
3376
3294
  ]);
3377
3295
  }
@@ -3431,7 +3349,7 @@ function setPeerConfig3(context, input) {
3431
3349
  resolvedArgs
3432
3350
  );
3433
3351
  const bytesCreatedOnChain = 0;
3434
- return umi.transactionBuilder([
3352
+ return umi$1.transactionBuilder([
3435
3353
  { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }
3436
3354
  ]);
3437
3355
  }
@@ -3504,7 +3422,7 @@ function withdrawFee3(context, input) {
3504
3422
  resolvedArgs
3505
3423
  );
3506
3424
  const bytesCreatedOnChain = 0;
3507
- return umi.transactionBuilder([
3425
+ return umi$1.transactionBuilder([
3508
3426
  { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }
3509
3427
  ]);
3510
3428
  }
@@ -3543,11 +3461,11 @@ function getOftProgramId2(context, clusterFilter) {
3543
3461
  }
3544
3462
 
3545
3463
  // src/oft202.ts
3546
- var ENDPOINT_PROGRAM_ID2 = umiWeb3jsAdapters.fromWeb3JsPublicKey(lzSolanaSdkV2.EndpointProgram.PROGRAM_ID);
3464
+ var { ENDPOINT_PROGRAM_ID: ENDPOINT_PROGRAM_ID2 } = umi.EndpointProgram;
3547
3465
  var PROGRAM_NAME = "oft";
3548
3466
  function createOFTProgramRepo2(oftProgram, rpc) {
3549
3467
  if (rpc === void 0) {
3550
- rpc = umi.createNullRpc();
3468
+ rpc = umi$1.createNullRpc();
3551
3469
  rpc.getCluster = () => "custom";
3552
3470
  }
3553
3471
  return umiProgramRepository.createDefaultProgramRepository({ rpc }, [
@@ -3569,7 +3487,7 @@ function createOFTProgramRepo2(oftProgram, rpc) {
3569
3487
  function initOft4(accounts, oftType, sharedDecimals = OFT_DECIMALS, programs) {
3570
3488
  const programsRepo = createOFTProgramRepo2(programs.oft);
3571
3489
  const deriver = new OftPDA(programsRepo.getPublicKey(PROGRAM_NAME));
3572
- const endpoint = new lzSolanaSdkV2.EndpointProgram.Endpoint(umiWeb3jsAdapters.toWeb3JsPublicKey(programs.endpoint ?? ENDPOINT_PROGRAM_ID2));
3490
+ const endpoint = new umi.EndpointProgram.Endpoint(programs.endpoint ?? ENDPOINT_PROGRAM_ID2);
3573
3491
  const { payer, admin, mint, escrow } = accounts;
3574
3492
  const [oftStore] = deriver.oftStore(escrow.publicKey);
3575
3493
  const [lzReceiveTypes3] = deriver.lzReceiveTypesAccounts(oftStore);
@@ -3589,13 +3507,13 @@ function initOft4(accounts, oftType, sharedDecimals = OFT_DECIMALS, programs) {
3589
3507
  oftType,
3590
3508
  admin,
3591
3509
  sharedDecimals,
3592
- endpointProgram: umiWeb3jsAdapters.fromWeb3JsPublicKey(endpoint.program)
3510
+ endpointProgram: endpoint.programId
3593
3511
  }
3594
3512
  );
3595
3513
  const retval = txBuilder.addRemainingAccounts(
3596
- endpoint.getRegisterOappIxAccountMetaForCPI(umiWeb3jsAdapters.toWeb3JsPublicKey(payer.publicKey), umiWeb3jsAdapters.toWeb3JsPublicKey(oftStore)).map((acc) => {
3514
+ endpoint.getRegisterOappIxAccountMetaForCPI(payer.publicKey, oftStore).map((acc) => {
3597
3515
  return {
3598
- pubkey: umiWeb3jsAdapters.fromWeb3JsPublicKey(acc.pubkey),
3516
+ pubkey: acc.pubkey,
3599
3517
  isSigner: acc.isSigner,
3600
3518
  isWritable: acc.isWritable
3601
3519
  };
@@ -3607,7 +3525,6 @@ function initOft4(accounts, oftType, sharedDecimals = OFT_DECIMALS, programs) {
3607
3525
  function setOFTConfig2(accounts, params, programs) {
3608
3526
  let actualParams;
3609
3527
  const { oftStore, admin } = accounts;
3610
- const oftStoreWeb3Js = umiWeb3jsAdapters.toWeb3JsPublicKey(oftStore);
3611
3528
  const remainingAccounts = [];
3612
3529
  if (params.__kind === "Admin") {
3613
3530
  if (params.admin === void 0) {
@@ -3625,18 +3542,9 @@ function setOFTConfig2(accounts, params, programs) {
3625
3542
  __kind: "Delegate",
3626
3543
  fields: [params.delegate]
3627
3544
  };
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
- );
3545
+ const endpointProgram = programs.endpoint ?? ENDPOINT_PROGRAM_ID2;
3546
+ const endpointSDK = new umi.EndpointProgram.Endpoint(endpointProgram);
3547
+ const keys = endpointSDK.getSetDelegateIxAccountMetaForCPI(oftStore);
3640
3548
  for (const acc of keys) {
3641
3549
  acc.isSigner = false;
3642
3550
  }
@@ -3667,12 +3575,12 @@ function setOFTConfig2(accounts, params, programs) {
3667
3575
  } else if (params.__kind === "Pauser") {
3668
3576
  actualParams = {
3669
3577
  __kind: "Pauser",
3670
- fields: [params.pauser ? umi.some(params.pauser) : umi.none()]
3578
+ fields: [params.pauser ? umi$1.some(params.pauser) : umi$1.none()]
3671
3579
  };
3672
3580
  } else {
3673
3581
  actualParams = {
3674
3582
  __kind: "Unpauser",
3675
- fields: [params.unpauser ? umi.some(params.unpauser) : umi.none()]
3583
+ fields: [params.unpauser ? umi$1.some(params.unpauser) : umi$1.none()]
3676
3584
  };
3677
3585
  }
3678
3586
  const txBuilder = setOftConfig2(
@@ -3686,7 +3594,7 @@ function setOFTConfig2(accounts, params, programs) {
3686
3594
  return txBuilder.addRemainingAccounts(
3687
3595
  remainingAccounts.map((acc) => {
3688
3596
  return {
3689
- pubkey: umiWeb3jsAdapters.fromWeb3JsPublicKey(acc.pubkey),
3597
+ pubkey: acc.pubkey,
3690
3598
  isSigner: acc.isSigner,
3691
3599
  isWritable: acc.isWritable
3692
3600
  };
@@ -3708,7 +3616,7 @@ function setPeerConfig4(accounts, param, oftProgramId) {
3708
3616
  }
3709
3617
  config = peerConfigParam2("PeerAddress", [param.peer]);
3710
3618
  } else if (param.__kind === "FeeBps") {
3711
- config = { __kind: "FeeBps", fields: [umi.some(param.feeBps)] };
3619
+ config = { __kind: "FeeBps", fields: [umi$1.some(param.feeBps)] };
3712
3620
  } else if (param.__kind === "EnforcedOptions") {
3713
3621
  config = {
3714
3622
  __kind: "EnforcedOptions",
@@ -3719,9 +3627,9 @@ function setPeerConfig4(accounts, param, oftProgramId) {
3719
3627
  config = {
3720
3628
  __kind: param.__kind,
3721
3629
  fields: [
3722
- param.rateLimit ? umi.some({
3723
- refillPerSecond: umi.some(param.rateLimit.refillPerSecond),
3724
- capacity: umi.some(param.rateLimit.capacity)
3630
+ param.rateLimit ? umi$1.some({
3631
+ refillPerSecond: umi$1.some(param.rateLimit.refillPerSecond),
3632
+ capacity: umi$1.some(param.rateLimit.capacity)
3725
3633
  }) : null
3726
3634
  ]
3727
3635
  };
@@ -3768,25 +3676,21 @@ async function send4(rpc, accounts, sendParams, programs, remainingAccounts) {
3768
3676
  const deriver = new OftPDA(oftProgramId);
3769
3677
  const [oftStore] = deriver.oftStore(tokenEscrow);
3770
3678
  const [peer] = deriver.peer(oftStore, dstEid);
3771
- const connection = new web3_js.Connection(rpc.getEndpoint());
3772
3679
  if (remainingAccounts === void 0 || remainingAccounts.length === 0) {
3773
3680
  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);
3681
+ const endpoint = new umi.EndpointProgram.Endpoint(programs.endpoint ?? ENDPOINT_PROGRAM_ID2);
3682
+ const msgLibProgram = await getSendLibraryProgram2(rpc, endpoint, payer.publicKey, oftStore, dstEid);
3776
3683
  const packetPath = {
3777
- srcEid: 0,
3778
3684
  dstEid,
3779
- sender: bytes.hexlify(umi.publicKeyBytes(oftStore)),
3780
- receiver: bytes.hexlify(peerAddr)
3685
+ sender: oftStore,
3686
+ receiver: peerAddr
3781
3687
  };
3782
- remainingAccounts = await endpoint.getSendIXAccountMetaForCPI(
3783
- connection,
3784
- umiWeb3jsAdapters.toWeb3JsPublicKey(payer.publicKey),
3785
- packetPath,
3688
+ remainingAccounts = await endpoint.getSendIXAccountMetaForCPI(rpc, payer.publicKey, {
3689
+ path: packetPath,
3786
3690
  msgLibProgram
3787
- );
3691
+ });
3788
3692
  }
3789
- const [eventAuthorityPDA] = new lzSolanaSdkV2.EventPDADeriver(umiWeb3jsAdapters.toWeb3JsPublicKey(oftProgramId)).eventAuthority();
3693
+ const [eventAuthorityPDA] = new umi.EventPDA(oftProgramId).eventAuthority();
3790
3694
  const tokenProgram = programs.token ?? umiWeb3jsAdapters.fromWeb3JsPublicKey(TOKEN_PROGRAM_ID);
3791
3695
  const txBuilder = send3(
3792
3696
  { programs: programsRepo },
@@ -3798,7 +3702,7 @@ async function send4(rpc, accounts, sendParams, programs, remainingAccounts) {
3798
3702
  tokenEscrow,
3799
3703
  tokenMint,
3800
3704
  tokenProgram,
3801
- eventAuthority: umiWeb3jsAdapters.fromWeb3JsPublicKey(eventAuthorityPDA),
3705
+ eventAuthority: eventAuthorityPDA,
3802
3706
  program: oftProgramId,
3803
3707
  // params
3804
3708
  dstEid,
@@ -3814,35 +3718,28 @@ async function send4(rpc, accounts, sendParams, programs, remainingAccounts) {
3814
3718
  return txBuilder.addRemainingAccounts(
3815
3719
  remainingAccounts.map((acc) => {
3816
3720
  return {
3817
- pubkey: umiWeb3jsAdapters.fromWeb3JsPublicKey(acc.pubkey),
3721
+ pubkey: acc.pubkey,
3818
3722
  isSigner: acc.isSigner,
3819
3723
  isWritable: acc.isWritable
3820
3724
  };
3821
3725
  })
3822
3726
  ).items[0];
3823
3727
  }
3824
- async function quote2(rpc, accounts, quoteParams, programs, remainingAccounts) {
3728
+ async function quote2(rpc, accounts, quoteParams, programs, remainingAccounts, addressLookupTable) {
3825
3729
  const { dstEid, to, amountLd, minAmountLd, options, payInLzToken, composeParams } = quoteParams;
3826
3730
  const { payer, tokenMint, tokenEscrow } = accounts;
3827
3731
  const programsRepo = typeof programs.oft === "string" ? createOFTProgramRepo2(programs.oft) : programs.oft;
3828
3732
  const deriver = new OftPDA(programsRepo.getPublicKey(PROGRAM_NAME));
3829
3733
  const [oftStore] = deriver.oftStore(tokenEscrow);
3830
3734
  const [peer] = deriver.peer(oftStore, dstEid);
3831
- const connection = new web3_js.Connection(rpc.getEndpoint(), "confirmed");
3832
3735
  if (remainingAccounts === void 0 || remainingAccounts.length === 0) {
3833
3736
  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
- );
3737
+ const endpoint = new umi.EndpointProgram.Endpoint(programs.endpoint ?? ENDPOINT_PROGRAM_ID2);
3738
+ const messageLib = await getSendLibraryProgram2(rpc, endpoint, payer, oftStore, dstEid);
3739
+ remainingAccounts = await endpoint.getQuoteIXAccountMetaForCPI(rpc, payer, {
3740
+ path: { sender: oftStore, dstEid, receiver: peerAddr },
3741
+ msgLibProgram: messageLib
3742
+ });
3846
3743
  }
3847
3744
  let txBuilder = quoteSend2(
3848
3745
  { programs: programsRepo },
@@ -3864,7 +3761,7 @@ async function quote2(rpc, accounts, quoteParams, programs, remainingAccounts) {
3864
3761
  // Get remaining accounts from msgLib(simple_msgLib or uln)
3865
3762
  remainingAccounts.map((acc) => {
3866
3763
  return {
3867
- pubkey: umiWeb3jsAdapters.fromWeb3JsPublicKey(acc.pubkey),
3764
+ pubkey: acc.pubkey,
3868
3765
  isSigner: acc.isSigner,
3869
3766
  isWritable: acc.isWritable
3870
3767
  };
@@ -3874,15 +3771,16 @@ async function quote2(rpc, accounts, quoteParams, programs, remainingAccounts) {
3874
3771
  const modifyComputeUnits = web3_js.ComputeBudgetProgram.setComputeUnitLimit({
3875
3772
  units: 1e6
3876
3773
  });
3877
- const buffer = await lzSolanaSdkV2.simulateTransaction(
3878
- connection,
3774
+ return umi.simulateWeb3JsTransaction(
3775
+ rpc,
3879
3776
  [modifyComputeUnits, web3Ix],
3880
3777
  web3Ix.programId,
3881
3778
  umiWeb3jsAdapters.toWeb3JsPublicKey(payer),
3882
- "confirmed"
3779
+ umi.EndpointProgram.types.getMessagingFeeSerializer(),
3780
+ "confirmed",
3781
+ void 0,
3782
+ addressLookupTable === void 0 ? void 0 : umiWeb3jsAdapters.toWeb3JsPublicKey(addressLookupTable)
3883
3783
  );
3884
- const fee = lzSolanaSdkV2.EndpointProgram.types.messagingFeeBeet.read(buffer, 0);
3885
- return { nativeFee: BigInt(fee.nativeFee.toString()), lzTokenFee: BigInt(fee.lzTokenFee.toString()) };
3886
3784
  }
3887
3785
  async function quoteOft4(rpc, accounts, quoteParams, oftProgram) {
3888
3786
  const { payer, tokenMint, tokenEscrow } = accounts;
@@ -3908,28 +3806,26 @@ async function quoteOft4(rpc, accounts, quoteParams, oftProgram) {
3908
3806
  }
3909
3807
  ).getInstructions()[0];
3910
3808
  const web3Ix = umiWeb3jsAdapters.toWeb3JsInstruction(ix);
3911
- const connection = new web3_js.Connection(rpc.getEndpoint());
3912
- const returnedValues = await lzSolanaSdkV2.simulateTransaction(
3913
- connection,
3809
+ return umi.simulateWeb3JsTransaction(
3810
+ rpc.getEndpoint(),
3914
3811
  [web3Ix],
3915
3812
  web3Ix.programId,
3916
3813
  umiWeb3jsAdapters.toWeb3JsPublicKey(payer),
3814
+ getQuoteOFTResultSerializer2(),
3917
3815
  "confirmed"
3918
3816
  );
3919
- const [result] = getQuoteOFTResultSerializer2().deserialize(returnedValues, 0);
3920
- return result;
3921
3817
  }
3922
- async function getSendLibraryProgram2(connection, endpoint, payer, oftStore, remoteEid) {
3923
- const sendLibInfo = await endpoint.getSendLibrary(connection, umiWeb3jsAdapters.toWeb3JsPublicKey(oftStore), remoteEid);
3924
- if (!sendLibInfo?.programId) {
3818
+ async function getSendLibraryProgram2(rpc, endpoint, payer, oftStore, remoteEid) {
3819
+ const sendLibInfo = await endpoint.getSendLibrary(rpc, oftStore, remoteEid);
3820
+ if (!sendLibInfo.programId) {
3925
3821
  throw new Error("Send library not initialized or blocked message library");
3926
3822
  }
3927
3823
  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);
3824
+ const msgLibVersion = await endpoint.getMessageLibVersion(rpc, payer, msgLibProgram);
3825
+ if (msgLibVersion.major.toString() === "0" && msgLibVersion.minor == 0 && msgLibVersion.endpointVersion == 2) {
3826
+ return new umi.SimpleMessageLibProgram.SimpleMessageLib(msgLibProgram);
3827
+ } else if (msgLibVersion.major.toString() === "3" && msgLibVersion.minor == 0 && msgLibVersion.endpointVersion == 2) {
3828
+ return new umi.UlnProgram.Uln(msgLibProgram);
3933
3829
  }
3934
3830
  throw new Error(`Unsupported message library version: ${JSON.stringify(msgLibVersion, null, 2)}`);
3935
3831
  }