@layerzerolabs/oft-v2-solana-sdk 3.0.52 → 3.0.54

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.mjs CHANGED
@@ -1,11 +1,12 @@
1
1
  import { hexlify } from '@ethersproject/bytes';
2
2
  import { deserializeAccount, publicKey as publicKey$1, assertAccountExists, gpaBuilder, ProgramError, isPda, isSigner, transactionBuilder, publicKeyBytes, createNullRpc, some, none, defaultPublicKey } from '@metaplex-foundation/umi';
3
3
  import { createDefaultProgramRepository } from '@metaplex-foundation/umi-program-repository';
4
- import { fromWeb3JsPublicKey, toWeb3JsPublicKey, fromWeb3JsInstruction, toWeb3JsInstruction } from '@metaplex-foundation/umi-web3js-adapters';
5
- import { PublicKey, Connection, ComputeBudgetProgram } from '@solana/web3.js';
6
- import { EndpointProgram, UlnProgram, LZ_RECEIVE_TYPES_SEED, EndpointPDADeriver, EventPDADeriver, SimpleMessageLibProgram, simulateTransaction, UlnPDADeriver } from '@layerzerolabs/lz-solana-sdk-v2';
4
+ import { fromWeb3JsPublicKey, toWeb3JsInstruction, toWeb3JsPublicKey } from '@metaplex-foundation/umi-web3js-adapters';
5
+ import { PublicKey, ComputeBudgetProgram } from '@solana/web3.js';
6
+ import { EndpointProgram, UlnProgram, SimpleMessageLibProgram, EventPDA, simulateWeb3JsTransaction, EndpointPDA, UlnPDA } from '@layerzerolabs/lz-solana-sdk-v2/umi';
7
7
  import { mapSerializer, struct, bytes, publicKey, u32, bool, u64, string, scalarEnum, dataEnum, tuple, option, u16, array, u8, Endian } from '@metaplex-foundation/umi/serializers';
8
8
  import { createWeb3JsEddsa } from '@metaplex-foundation/umi-eddsa-web3js';
9
+ import { LZ_RECEIVE_TYPES_SEED } from '@layerzerolabs/lz-solana-sdk-v2';
9
10
 
10
11
  var __defProp = Object.defineProperty;
11
12
  var __export = (target, all) => {
@@ -1488,8 +1489,8 @@ function getOftProgramId(context, clusterFilter) {
1488
1489
  }
1489
1490
 
1490
1491
  // src/oft302.ts
1491
- var ENDPOINT_PROGRAM_ID = fromWeb3JsPublicKey(EndpointProgram.PROGRAM_ID);
1492
- var ULN_PROGRAM_ID = fromWeb3JsPublicKey(UlnProgram.PROGRAM_ID);
1492
+ var ENDPOINT_PROGRAM_ID = EndpointProgram.ENDPOINT_PROGRAM_ID;
1493
+ var ULN_PROGRAM_ID = UlnProgram.ULN_PROGRAM_ID;
1493
1494
  function createOFTProgramRepo(oftProgram, rpc) {
1494
1495
  if (rpc === void 0) {
1495
1496
  rpc = createNullRpc();
@@ -1514,7 +1515,7 @@ function createOFTProgramRepo(oftProgram, rpc) {
1514
1515
  function initOft2(accounts, oftType, sharedDecimals = OFT_DECIMALS, programs) {
1515
1516
  const programsRepo = typeof programs.oft === "string" ? createOFTProgramRepo(programs.oft) : programs.oft;
1516
1517
  const deriver = new OftPDA(programsRepo.getPublicKey("oft"));
1517
- const endpoint = new EndpointProgram.Endpoint(toWeb3JsPublicKey(programs.endpoint ?? ENDPOINT_PROGRAM_ID));
1518
+ const endpoint = new EndpointProgram.Endpoint(programs.endpoint ?? ENDPOINT_PROGRAM_ID);
1518
1519
  const { payer, admin, mint, escrow } = accounts;
1519
1520
  const [oftStore] = deriver.oftStore(escrow.publicKey);
1520
1521
  const [lzReceiveTypes3] = deriver.lzReceiveTypesAccounts(oftStore);
@@ -1534,13 +1535,13 @@ function initOft2(accounts, oftType, sharedDecimals = OFT_DECIMALS, programs) {
1534
1535
  oftType,
1535
1536
  admin,
1536
1537
  sharedDecimals,
1537
- endpointProgram: fromWeb3JsPublicKey(endpoint.program)
1538
+ endpointProgram: endpoint.programId
1538
1539
  }
1539
1540
  );
1540
1541
  const retval = txBuilder.addRemainingAccounts(
1541
- endpoint.getRegisterOappIxAccountMetaForCPI(toWeb3JsPublicKey(payer.publicKey), toWeb3JsPublicKey(oftStore)).map((acc) => {
1542
+ endpoint.getRegisterOappIxAccountMetaForCPI(payer.publicKey, oftStore).map((acc) => {
1542
1543
  return {
1543
- pubkey: fromWeb3JsPublicKey(acc.pubkey),
1544
+ pubkey: acc.pubkey,
1544
1545
  isSigner: acc.isSigner,
1545
1546
  isWritable: acc.isWritable
1546
1547
  };
@@ -1552,7 +1553,6 @@ function initOft2(accounts, oftType, sharedDecimals = OFT_DECIMALS, programs) {
1552
1553
  function setOFTConfig(accounts, params, programs) {
1553
1554
  let actualParams;
1554
1555
  const { oftStore, admin } = accounts;
1555
- const oftStoreWeb3Js = toWeb3JsPublicKey(oftStore);
1556
1556
  const remainingAccounts = [];
1557
1557
  if (params.__kind === "Admin") {
1558
1558
  if (params.admin === void 0) {
@@ -1570,29 +1570,13 @@ function setOFTConfig(accounts, params, programs) {
1570
1570
  __kind: "Delegate",
1571
1571
  fields: [params.delegate]
1572
1572
  };
1573
- const endpointProgram = toWeb3JsPublicKey(programs.endpoint ?? ENDPOINT_PROGRAM_ID);
1574
- const [oAppRegistry] = new EndpointPDADeriver(endpointProgram).oappRegistry(oftStoreWeb3Js);
1575
- const [endpointEventAuthority] = new EventPDADeriver(endpointProgram).eventAuthority();
1576
- const keys = EndpointProgram.instructions.createSetDelegateInstructionAccounts(
1577
- {
1578
- oapp: oftStoreWeb3Js,
1579
- oappRegistry: oAppRegistry,
1580
- eventAuthority: endpointEventAuthority,
1581
- program: endpointProgram
1582
- },
1583
- endpointProgram
1584
- );
1573
+ const endpointProgram = programs.endpoint ?? ENDPOINT_PROGRAM_ID;
1574
+ const endpointSDK = new EndpointProgram.Endpoint(endpointProgram);
1575
+ const keys = endpointSDK.getSetDelegateIxAccountMetaForCPI(oftStore);
1585
1576
  for (const acc of keys) {
1586
1577
  acc.isSigner = false;
1587
1578
  }
1588
- remainingAccounts.push(
1589
- {
1590
- pubkey: endpointProgram,
1591
- isSigner: false,
1592
- isWritable: false
1593
- },
1594
- ...keys
1595
- );
1579
+ remainingAccounts.push(...keys);
1596
1580
  } else if (params.__kind === "DefaultFee") {
1597
1581
  if (params.defaultFee === void 0) {
1598
1582
  throw new Error("DefaultFee is required");
@@ -1631,7 +1615,7 @@ function setOFTConfig(accounts, params, programs) {
1631
1615
  return txBuilder.addRemainingAccounts(
1632
1616
  remainingAccounts.map((acc) => {
1633
1617
  return {
1634
- pubkey: fromWeb3JsPublicKey(acc.pubkey),
1618
+ pubkey: acc.pubkey,
1635
1619
  isSigner: acc.isSigner,
1636
1620
  isWritable: acc.isWritable
1637
1621
  };
@@ -1687,60 +1671,34 @@ function setPeerConfig2(accounts, param, oftProgramId) {
1687
1671
  }
1688
1672
  function initSendLibrary(accounts, remoteEid, endpointProgram = ENDPOINT_PROGRAM_ID) {
1689
1673
  const { admin, oftStore } = accounts;
1690
- const endpoint = new EndpointProgram.Endpoint(toWeb3JsPublicKey(endpointProgram));
1691
- return {
1692
- instruction: fromWeb3JsInstruction(
1693
- endpoint.initSendLibrary(toWeb3JsPublicKey(admin.publicKey), toWeb3JsPublicKey(oftStore), remoteEid)
1694
- ),
1695
- signers: [admin],
1696
- bytesCreatedOnChain: 0
1697
- };
1674
+ const endpoint = new EndpointProgram.Endpoint(endpointProgram);
1675
+ return endpoint.initOAppSendLibrary(admin, { sender: oftStore, remote: remoteEid });
1698
1676
  }
1699
1677
  function initReceiveLibrary(accounts, remoteEid, endpointProgram = ENDPOINT_PROGRAM_ID) {
1700
1678
  const { admin, oftStore } = accounts;
1701
- const endpoint = new EndpointProgram.Endpoint(toWeb3JsPublicKey(endpointProgram));
1702
- return {
1703
- instruction: fromWeb3JsInstruction(
1704
- endpoint.initReceiveLibrary(toWeb3JsPublicKey(admin.publicKey), toWeb3JsPublicKey(oftStore), remoteEid)
1705
- ),
1706
- signers: [admin],
1707
- bytesCreatedOnChain: 0
1708
- };
1679
+ const endpoint = new EndpointProgram.Endpoint(endpointProgram);
1680
+ return endpoint.initOAppReceiveLibrary(admin, { receiver: oftStore, remote: remoteEid });
1709
1681
  }
1710
1682
  function setSendLibrary(accounts, params, endpointProgram = ENDPOINT_PROGRAM_ID) {
1711
1683
  const { sendLibraryProgram, remoteEid } = params;
1712
1684
  const { admin, oftStore } = accounts;
1713
- const endpoint = new EndpointProgram.Endpoint(toWeb3JsPublicKey(endpointProgram));
1714
- return {
1715
- instruction: fromWeb3JsInstruction(
1716
- endpoint.setSendLibrary(
1717
- toWeb3JsPublicKey(admin.publicKey),
1718
- toWeb3JsPublicKey(oftStore),
1719
- toWeb3JsPublicKey(sendLibraryProgram),
1720
- remoteEid
1721
- )
1722
- ),
1723
- signers: [admin],
1724
- bytesCreatedOnChain: 0
1725
- };
1685
+ const endpoint = new EndpointProgram.Endpoint(endpointProgram);
1686
+ return endpoint.setOAppSendLibrary(admin, {
1687
+ sender: oftStore,
1688
+ remote: remoteEid,
1689
+ msgLibProgram: sendLibraryProgram
1690
+ });
1726
1691
  }
1727
1692
  function setReceiveLibrary(accounts, params, endpointProgram = ENDPOINT_PROGRAM_ID) {
1728
1693
  const { receiveLibraryProgram, remoteEid, gracePeriod } = params;
1729
1694
  const { admin, oftStore } = accounts;
1730
- const endpoint = new EndpointProgram.Endpoint(toWeb3JsPublicKey(endpointProgram));
1731
- return {
1732
- instruction: fromWeb3JsInstruction(
1733
- endpoint.setReceiveLibrary(
1734
- toWeb3JsPublicKey(admin.publicKey),
1735
- toWeb3JsPublicKey(oftStore),
1736
- toWeb3JsPublicKey(receiveLibraryProgram),
1737
- remoteEid,
1738
- gracePeriod
1739
- )
1740
- ),
1741
- signers: [admin],
1742
- bytesCreatedOnChain: 0
1743
- };
1695
+ const endpoint = new EndpointProgram.Endpoint(endpointProgram);
1696
+ return endpoint.setOAppReceiveLibrary(admin, {
1697
+ receiver: oftStore,
1698
+ remote: remoteEid,
1699
+ msgLibProgram: receiveLibraryProgram,
1700
+ gracePeriod
1701
+ });
1744
1702
  }
1745
1703
  function initConfig(accounts, remoteEid, programs) {
1746
1704
  const { admin, oftStore, payer } = accounts;
@@ -1752,28 +1710,26 @@ function initConfig(accounts, remoteEid, programs) {
1752
1710
  msgLibProgram = programs.msgLib ?? ULN_PROGRAM_ID;
1753
1711
  endpointProgram = programs.endpoint ?? ENDPOINT_PROGRAM_ID;
1754
1712
  }
1755
- const endpoint = new EndpointProgram.Endpoint(toWeb3JsPublicKey(endpointProgram));
1713
+ const endpoint = new EndpointProgram.Endpoint(endpointProgram);
1756
1714
  let msgLib;
1757
- if (msgLibProgram.toString() === SimpleMessageLibProgram.PROGRAM_ID.toBase58()) {
1758
- msgLib = new SimpleMessageLibProgram.SimpleMessageLib(SimpleMessageLibProgram.PROGRAM_ID);
1715
+ if (msgLibProgram === SimpleMessageLibProgram.SIMPLE_MESSAGELIB_PROGRAM_ID) {
1716
+ msgLib = new SimpleMessageLibProgram.SimpleMessageLib(SimpleMessageLibProgram.SIMPLE_MESSAGELIB_PROGRAM_ID);
1759
1717
  } else {
1760
- msgLib = new UlnProgram.Uln(toWeb3JsPublicKey(msgLibProgram));
1718
+ msgLib = new UlnProgram.Uln(msgLibProgram);
1761
1719
  }
1762
- return {
1763
- instruction: fromWeb3JsInstruction(
1764
- endpoint.initOAppConfig(
1765
- toWeb3JsPublicKey(admin.publicKey),
1766
- msgLib,
1767
- toWeb3JsPublicKey(payer.publicKey),
1768
- toWeb3JsPublicKey(oftStore),
1769
- remoteEid
1770
- )
1771
- ),
1772
- signers: [admin, payer],
1773
- bytesCreatedOnChain: 0
1774
- };
1720
+ return endpoint.initOAppConfig(
1721
+ {
1722
+ delegate: admin,
1723
+ payer: payer.publicKey
1724
+ },
1725
+ {
1726
+ msgLibSDK: msgLib,
1727
+ oapp: oftStore,
1728
+ remote: remoteEid
1729
+ }
1730
+ );
1775
1731
  }
1776
- async function setConfig(connection, accounts, params, programs) {
1732
+ async function setConfig(rpc, accounts, params, programs) {
1777
1733
  const { signer, oftStore } = accounts;
1778
1734
  const { remoteEid, configType, config } = params;
1779
1735
  let msgLibProgram, endpointProgram;
@@ -1784,20 +1740,16 @@ async function setConfig(connection, accounts, params, programs) {
1784
1740
  msgLibProgram = programs.msgLib ?? ULN_PROGRAM_ID;
1785
1741
  endpointProgram = programs.endpoint ?? ENDPOINT_PROGRAM_ID;
1786
1742
  }
1787
- const endpoint = new EndpointProgram.Endpoint(toWeb3JsPublicKey(endpointProgram));
1788
- return fromWeb3JsInstruction(
1789
- await endpoint.setOappConfig(
1790
- connection,
1791
- toWeb3JsPublicKey(signer),
1792
- toWeb3JsPublicKey(oftStore),
1793
- toWeb3JsPublicKey(msgLibProgram),
1794
- remoteEid,
1795
- {
1796
- configType,
1797
- value: config
1798
- }
1799
- )
1800
- );
1743
+ const endpoint = new EndpointProgram.Endpoint(endpointProgram);
1744
+ return endpoint.setOAppConfig(rpc, signer, {
1745
+ oapp: oftStore,
1746
+ eid: remoteEid,
1747
+ config: {
1748
+ configType,
1749
+ value: config
1750
+ },
1751
+ msgLibProgram
1752
+ });
1801
1753
  }
1802
1754
  function withdrawFee2(accounts, amount, programs) {
1803
1755
  const { admin, mint, escrow, dest } = accounts;
@@ -1823,25 +1775,21 @@ async function send2(rpc, accounts, sendParams, programs, remainingAccounts) {
1823
1775
  const deriver = new OftPDA(programs.oft);
1824
1776
  const [oftStore] = deriver.oftStore(tokenEscrow);
1825
1777
  const [peer] = deriver.peer(oftStore, dstEid);
1826
- const connection = new Connection(rpc.getEndpoint());
1827
1778
  if (remainingAccounts === void 0 || remainingAccounts.length === 0) {
1828
1779
  const peerAddr = accounts.peerAddr ?? await fetchPeerConfig({ rpc }, peer).then((peerInfo) => peerInfo.peerAddress);
1829
- const endpoint = new EndpointProgram.Endpoint(toWeb3JsPublicKey(programs.endpoint ?? ENDPOINT_PROGRAM_ID));
1830
- const msgLibProgram = await getSendLibraryProgram(connection, endpoint, payer.publicKey, oftStore, dstEid);
1780
+ const endpoint = new EndpointProgram.Endpoint(programs.endpoint ?? ENDPOINT_PROGRAM_ID);
1781
+ const msgLibProgram = await getSendLibraryProgram(rpc, endpoint, payer.publicKey, oftStore, dstEid);
1831
1782
  const packetPath = {
1832
- srcEid: 0,
1833
1783
  dstEid,
1834
- sender: hexlify(publicKeyBytes(oftStore)),
1835
- receiver: hexlify(peerAddr)
1784
+ sender: oftStore,
1785
+ receiver: peerAddr
1836
1786
  };
1837
- remainingAccounts = await endpoint.getSendIXAccountMetaForCPI(
1838
- connection,
1839
- toWeb3JsPublicKey(payer.publicKey),
1840
- packetPath,
1787
+ remainingAccounts = await endpoint.getSendIXAccountMetaForCPI(rpc, payer.publicKey, {
1788
+ path: packetPath,
1841
1789
  msgLibProgram
1842
- );
1790
+ });
1843
1791
  }
1844
- const [eventAuthorityPDA] = new EventPDADeriver(toWeb3JsPublicKey(programs.oft)).eventAuthority();
1792
+ const [eventAuthorityPDA] = new EventPDA(programs.oft).eventAuthority();
1845
1793
  const tokenProgram = programs.token ?? fromWeb3JsPublicKey(TOKEN_PROGRAM_ID);
1846
1794
  const txBuilder = send(
1847
1795
  { programs: createOFTProgramRepo(programs.oft) },
@@ -1853,7 +1801,7 @@ async function send2(rpc, accounts, sendParams, programs, remainingAccounts) {
1853
1801
  tokenEscrow,
1854
1802
  tokenMint,
1855
1803
  tokenProgram,
1856
- eventAuthority: fromWeb3JsPublicKey(eventAuthorityPDA),
1804
+ eventAuthority: eventAuthorityPDA,
1857
1805
  program: programs.oft,
1858
1806
  // params
1859
1807
  dstEid,
@@ -1869,7 +1817,7 @@ async function send2(rpc, accounts, sendParams, programs, remainingAccounts) {
1869
1817
  return txBuilder.addRemainingAccounts(
1870
1818
  remainingAccounts.map((acc) => {
1871
1819
  return {
1872
- pubkey: fromWeb3JsPublicKey(acc.pubkey),
1820
+ pubkey: acc.pubkey,
1873
1821
  isSigner: acc.isSigner,
1874
1822
  isWritable: acc.isWritable
1875
1823
  };
@@ -1882,21 +1830,14 @@ async function quote(rpc, accounts, quoteParams, programs, remainingAccounts, ad
1882
1830
  const deriver = new OftPDA(programs.oft);
1883
1831
  const [oftStore] = deriver.oftStore(tokenEscrow);
1884
1832
  const [peer] = deriver.peer(oftStore, dstEid);
1885
- const connection = new Connection(rpc.getEndpoint(), "confirmed");
1886
1833
  if (remainingAccounts === void 0 || remainingAccounts.length === 0) {
1887
1834
  const peerAddr = accounts.peerAddr ?? await fetchPeerConfig({ rpc }, peer).then((peerInfo) => peerInfo.peerAddress);
1888
- const endpoint = new EndpointProgram.Endpoint(toWeb3JsPublicKey(programs.endpoint ?? ENDPOINT_PROGRAM_ID));
1889
- const messageLib = await getSendLibraryProgram(connection, endpoint, payer, oftStore, dstEid);
1890
- remainingAccounts = await endpoint.getQuoteIXAccountMetaForCPI(
1891
- connection,
1892
- toWeb3JsPublicKey(payer),
1893
- {
1894
- sender: hexlify(publicKeyBytes(oftStore)),
1895
- dstEid,
1896
- receiver: hexlify(peerAddr)
1897
- },
1898
- messageLib
1899
- );
1835
+ const endpoint = new EndpointProgram.Endpoint(programs.endpoint ?? ENDPOINT_PROGRAM_ID);
1836
+ const messageLib = await getSendLibraryProgram(rpc, endpoint, payer, oftStore, dstEid);
1837
+ remainingAccounts = await endpoint.getQuoteIXAccountMetaForCPI(rpc, payer, {
1838
+ path: { sender: oftStore, dstEid, receiver: peerAddr },
1839
+ msgLibProgram: messageLib
1840
+ });
1900
1841
  }
1901
1842
  let txBuilder = quoteSend(
1902
1843
  { programs: createOFTProgramRepo(programs.oft) },
@@ -1918,7 +1859,7 @@ async function quote(rpc, accounts, quoteParams, programs, remainingAccounts, ad
1918
1859
  // Get remaining accounts from msgLib(simple_msgLib or uln)
1919
1860
  remainingAccounts.map((acc) => {
1920
1861
  return {
1921
- pubkey: fromWeb3JsPublicKey(acc.pubkey),
1862
+ pubkey: acc.pubkey,
1922
1863
  isSigner: acc.isSigner,
1923
1864
  isWritable: acc.isWritable
1924
1865
  };
@@ -1928,17 +1869,16 @@ async function quote(rpc, accounts, quoteParams, programs, remainingAccounts, ad
1928
1869
  const modifyComputeUnits = ComputeBudgetProgram.setComputeUnitLimit({
1929
1870
  units: 1e6
1930
1871
  });
1931
- const buffer = await simulateTransaction(
1932
- connection,
1872
+ return simulateWeb3JsTransaction(
1873
+ rpc,
1933
1874
  [modifyComputeUnits, web3Ix],
1934
1875
  web3Ix.programId,
1935
1876
  toWeb3JsPublicKey(payer),
1877
+ EndpointProgram.types.getMessagingFeeSerializer(),
1936
1878
  "confirmed",
1937
1879
  void 0,
1938
1880
  addressLookupTable === void 0 ? void 0 : toWeb3JsPublicKey(addressLookupTable)
1939
1881
  );
1940
- const fee = EndpointProgram.types.messagingFeeBeet.read(buffer, 0);
1941
- return { nativeFee: BigInt(fee.nativeFee.toString()), lzTokenFee: BigInt(fee.lzTokenFee.toString()) };
1942
1882
  }
1943
1883
  async function quoteOft2(rpc, accounts, quoteParams, oftProgram) {
1944
1884
  const { payer, tokenMint, tokenEscrow } = accounts;
@@ -1963,32 +1903,23 @@ async function quoteOft2(rpc, accounts, quoteParams, oftProgram) {
1963
1903
  }
1964
1904
  ).getInstructions()[0];
1965
1905
  const web3Ix = toWeb3JsInstruction(ix);
1966
- const connection = new Connection(rpc.getEndpoint());
1967
- const returnedValues = await simulateTransaction(
1968
- connection,
1906
+ return simulateWeb3JsTransaction(
1907
+ rpc.getEndpoint(),
1969
1908
  [web3Ix],
1970
1909
  web3Ix.programId,
1971
1910
  toWeb3JsPublicKey(payer),
1911
+ getQuoteOFTResultSerializer(),
1972
1912
  "confirmed"
1973
1913
  );
1974
- const [result] = getQuoteOFTResultSerializer().deserialize(returnedValues, 0);
1975
- return result;
1976
1914
  }
1977
1915
  function initOAppNonce(accounts, remoteEid, remoteOappAddr, endpointProgram = ENDPOINT_PROGRAM_ID) {
1978
1916
  const { admin, oftStore } = accounts;
1979
- const endpoint = new EndpointProgram.Endpoint(toWeb3JsPublicKey(endpointProgram));
1980
- return {
1981
- instruction: fromWeb3JsInstruction(
1982
- endpoint.initOAppNonce(
1983
- toWeb3JsPublicKey(admin.publicKey),
1984
- remoteEid,
1985
- toWeb3JsPublicKey(oftStore),
1986
- remoteOappAddr
1987
- )
1988
- ),
1989
- signers: [admin],
1990
- bytesCreatedOnChain: 0
1991
- };
1917
+ const endpoint = new EndpointProgram.Endpoint(endpointProgram);
1918
+ return endpoint.initOAppNonce(admin, {
1919
+ localOApp: oftStore,
1920
+ remote: remoteEid,
1921
+ remoteOApp: remoteOappAddr
1922
+ });
1992
1923
  }
1993
1924
  async function getEndpointConfig(rpc, oftStore, endpointId, programs) {
1994
1925
  let msgLibProgram, endpointProgram;
@@ -1999,38 +1930,33 @@ async function getEndpointConfig(rpc, oftStore, endpointId, programs) {
1999
1930
  msgLibProgram = programs.msgLib ?? ULN_PROGRAM_ID;
2000
1931
  endpointProgram = programs.endpoint ?? ENDPOINT_PROGRAM_ID;
2001
1932
  }
2002
- const endpointDeriver = new EndpointPDADeriver(toWeb3JsPublicKey(endpointProgram));
2003
- const ulnDeriver = new UlnPDADeriver(toWeb3JsPublicKey(msgLibProgram));
2004
- const web3OftStore = toWeb3JsPublicKey(oftStore);
2005
- const [sendLib] = endpointDeriver.sendLibraryConfig(web3OftStore, endpointId);
1933
+ const endpointDeriver = new EndpointPDA(endpointProgram);
1934
+ const ulnDeriver = new UlnPDA(msgLibProgram);
1935
+ const [sendLib] = endpointDeriver.sendLibraryConfig(oftStore, endpointId);
2006
1936
  const [defaultSendLib] = endpointDeriver.defaultSendLibraryConfig(endpointId);
2007
- const [receiveLib] = endpointDeriver.receiveLibraryConfig(web3OftStore, endpointId);
1937
+ const [receiveLib] = endpointDeriver.receiveLibraryConfig(oftStore, endpointId);
2008
1938
  const [defaultReceiveLib] = endpointDeriver.defaultReceiveLibraryConfig(endpointId);
2009
1939
  const [msgLib] = ulnDeriver.messageLib();
2010
- const connection = new Connection(rpc.getEndpoint());
2011
- let sendLibraryConfig = await EndpointProgram.accounts.SendLibraryConfig.fromAccountAddress(connection, sendLib);
2012
- let receiveLibraryConfig = await EndpointProgram.accounts.ReceiveLibraryConfig.fromAccountAddress(connection, receiveLib);
2013
- const defaultSendLibraryConfig = await EndpointProgram.accounts.SendLibraryConfig.fromAccountAddress(connection, defaultSendLib);
2014
- const defaultReceiveLibraryConfig = await EndpointProgram.accounts.ReceiveLibraryConfig.fromAccountAddress(connection, defaultReceiveLib);
2015
- const nil64 = "18446744073709551615";
1940
+ let sendLibraryConfig = await EndpointProgram.accounts.fetchSendLibraryConfig({ rpc }, sendLib);
1941
+ let receiveLibraryConfig = await EndpointProgram.accounts.fetchReceiveLibraryConfig({ rpc }, receiveLib);
1942
+ const defaultSendLibraryConfig = await EndpointProgram.accounts.fetchSendLibraryConfig({ rpc }, defaultSendLib);
1943
+ const defaultReceiveLibraryConfig = await EndpointProgram.accounts.fetchReceiveLibraryConfig({ rpc }, defaultReceiveLib);
1944
+ const nil64 = 18446744073709551615n;
2016
1945
  const nil8 = 255;
2017
- if (sendLibraryConfig.messageLib.toBase58() === defaultPublicKey().toString()) {
1946
+ if (sendLibraryConfig.messageLib === defaultPublicKey()) {
2018
1947
  sendLibraryConfig = defaultSendLibraryConfig;
2019
1948
  }
2020
- if (receiveLibraryConfig.messageLib.toBase58() === defaultPublicKey().toString()) {
1949
+ if (receiveLibraryConfig.messageLib === defaultPublicKey()) {
2021
1950
  receiveLibraryConfig = defaultReceiveLibraryConfig;
2022
1951
  }
2023
- if (sendLibraryConfig.messageLib.equals(msgLib)) {
1952
+ if (sendLibraryConfig.messageLib === msgLib) {
2024
1953
  const [ulnDefaultSendConfigPDA] = ulnDeriver.defaultSendConfig(endpointId);
2025
- const [ulnSendConfigPDA] = ulnDeriver.sendConfig(endpointId, web3OftStore);
2026
- const ulnSendConfig = await UlnProgram.accounts.SendConfig.fromAccountAddress(connection, ulnSendConfigPDA);
2027
- const ulnDefaultSendConfig = await UlnProgram.accounts.SendConfig.fromAccountAddress(
2028
- connection,
2029
- ulnDefaultSendConfigPDA
2030
- );
2031
- if (nil64 === ulnSendConfig.uln.confirmations.toString()) {
2032
- ulnSendConfig.uln.confirmations = 0;
2033
- } else if (ulnSendConfig.uln.confirmations == 0) {
1954
+ const [ulnSendConfigPDA] = ulnDeriver.sendConfig(endpointId, oftStore);
1955
+ const ulnSendConfig = await UlnProgram.accounts.fetchSendConfig({ rpc }, ulnSendConfigPDA);
1956
+ const ulnDefaultSendConfig = await UlnProgram.accounts.fetchSendConfig({ rpc }, ulnDefaultSendConfigPDA);
1957
+ if (nil64 === ulnSendConfig.uln.confirmations) {
1958
+ ulnSendConfig.uln.confirmations = 0n;
1959
+ } else if (ulnSendConfig.uln.confirmations == 0n) {
2034
1960
  ulnSendConfig.uln.confirmations = ulnDefaultSendConfig.uln.confirmations;
2035
1961
  }
2036
1962
  if (ulnSendConfig.uln.requiredDvnCount == nil8) {
@@ -2049,20 +1975,17 @@ async function getEndpointConfig(rpc, oftStore, endpointId, programs) {
2049
1975
  }
2050
1976
  sendLibraryConfig.ulnSendConfig = ulnSendConfig;
2051
1977
  }
2052
- if (receiveLibraryConfig.messageLib.equals(msgLib)) {
1978
+ if (receiveLibraryConfig.messageLib === msgLib) {
2053
1979
  const [ulnDefaultReceiveConfigPDA] = ulnDeriver.defaultReceiveConfig(endpointId);
2054
- const [ulnReceiveConfigPDA] = ulnDeriver.receiveConfig(endpointId, web3OftStore);
2055
- const ulnReceiveConfig = await UlnProgram.accounts.ReceiveConfig.fromAccountAddress(
2056
- connection,
2057
- ulnReceiveConfigPDA
2058
- );
2059
- const ulnDefaultReceiveConfig = await UlnProgram.accounts.ReceiveConfig.fromAccountAddress(
2060
- connection,
1980
+ const [ulnReceiveConfigPDA] = ulnDeriver.receiveConfig(endpointId, oftStore);
1981
+ const ulnReceiveConfig = await UlnProgram.accounts.fetchReceiveConfig({ rpc }, ulnReceiveConfigPDA);
1982
+ const ulnDefaultReceiveConfig = await UlnProgram.accounts.fetchReceiveConfig(
1983
+ { rpc },
2061
1984
  ulnDefaultReceiveConfigPDA
2062
1985
  );
2063
- if (nil64 === ulnReceiveConfig.uln.confirmations.toString()) {
2064
- ulnReceiveConfig.uln.confirmations = 0;
2065
- } else if (ulnReceiveConfig.uln.confirmations == 0) {
1986
+ if (nil64 === ulnReceiveConfig.uln.confirmations) {
1987
+ ulnReceiveConfig.uln.confirmations = 0n;
1988
+ } else if (ulnReceiveConfig.uln.confirmations == 0n) {
2066
1989
  ulnReceiveConfig.uln.confirmations = ulnDefaultReceiveConfig.uln.confirmations;
2067
1990
  }
2068
1991
  if (ulnReceiveConfig.uln.requiredDvnCount == nil8) {
@@ -2092,30 +2015,25 @@ async function getPeerAddress(rpc, oftInstance, remoteEid, oftProgramId) {
2092
2015
  return hexlify(peerInfo.peerAddress);
2093
2016
  }
2094
2017
  async function getDelegate(rpc, oftInstance, endpointProgram = ENDPOINT_PROGRAM_ID) {
2095
- const [oAppRegistry] = new EndpointPDADeriver(toWeb3JsPublicKey(endpointProgram)).oappRegistry(
2096
- toWeb3JsPublicKey(oftInstance)
2097
- );
2098
- const oAppRegistryInfo = await EndpointProgram.accounts.OAppRegistry.fromAccountAddress(
2099
- new Connection(rpc.getEndpoint()),
2100
- oAppRegistry
2101
- );
2102
- return fromWeb3JsPublicKey(oAppRegistryInfo.delegate);
2018
+ const [oAppRegistry] = new EndpointPDA(endpointProgram).oappRegistry(oftInstance);
2019
+ const oAppRegistryInfo = await EndpointProgram.accounts.fetchOAppRegistry({ rpc }, oAppRegistry);
2020
+ return oAppRegistryInfo.delegate;
2103
2021
  }
2104
2022
  async function getEnforcedOptions(rpc, oftInstance, remoteEid, oftProgramId) {
2105
2023
  const [peer] = new OftPDA(oftProgramId).peer(oftInstance, remoteEid);
2106
2024
  const peerInfo = await fetchPeerConfig({ rpc }, peer);
2107
2025
  return peerInfo.enforcedOptions;
2108
2026
  }
2109
- async function getSendLibraryProgram(connection, endpoint, payer, oftStore, remoteEid) {
2110
- const sendLibInfo = await endpoint.getSendLibrary(connection, toWeb3JsPublicKey(oftStore), remoteEid);
2111
- if (!sendLibInfo?.programId) {
2027
+ async function getSendLibraryProgram(rpc, endpoint, payer, oftStore, remoteEid) {
2028
+ const sendLibInfo = await endpoint.getSendLibrary(rpc, oftStore, remoteEid);
2029
+ if (!sendLibInfo.programId) {
2112
2030
  throw new Error("Send library not initialized or blocked message library");
2113
2031
  }
2114
2032
  const { programId: msgLibProgram } = sendLibInfo;
2115
- const msgLibVersion = await endpoint.getMessageLibVersion(connection, toWeb3JsPublicKey(payer), msgLibProgram);
2116
- if (msgLibVersion?.major.toString() === "0" && msgLibVersion.minor == 0 && msgLibVersion.endpointVersion == 2) {
2033
+ const msgLibVersion = await endpoint.getMessageLibVersion(rpc, payer, msgLibProgram);
2034
+ if (msgLibVersion.major.toString() === "0" && msgLibVersion.minor == 0 && msgLibVersion.endpointVersion == 2) {
2117
2035
  return new SimpleMessageLibProgram.SimpleMessageLib(msgLibProgram);
2118
- } else if (msgLibVersion?.major.toString() === "3" && msgLibVersion.minor == 0 && msgLibVersion.endpointVersion == 2) {
2036
+ } else if (msgLibVersion.major.toString() === "3" && msgLibVersion.minor == 0 && msgLibVersion.endpointVersion == 2) {
2119
2037
  return new UlnProgram.Uln(msgLibProgram);
2120
2038
  }
2121
2039
  throw new Error(`Unsupported message library version: ${JSON.stringify(msgLibVersion, null, 2)}`);
@@ -3541,7 +3459,7 @@ function getOftProgramId2(context, clusterFilter) {
3541
3459
  }
3542
3460
 
3543
3461
  // src/oft202.ts
3544
- var ENDPOINT_PROGRAM_ID2 = fromWeb3JsPublicKey(EndpointProgram.PROGRAM_ID);
3462
+ var { ENDPOINT_PROGRAM_ID: ENDPOINT_PROGRAM_ID2 } = EndpointProgram;
3545
3463
  var PROGRAM_NAME = "oft";
3546
3464
  function createOFTProgramRepo2(oftProgram, rpc) {
3547
3465
  if (rpc === void 0) {
@@ -3567,7 +3485,7 @@ function createOFTProgramRepo2(oftProgram, rpc) {
3567
3485
  function initOft4(accounts, oftType, sharedDecimals = OFT_DECIMALS, programs) {
3568
3486
  const programsRepo = createOFTProgramRepo2(programs.oft);
3569
3487
  const deriver = new OftPDA(programsRepo.getPublicKey(PROGRAM_NAME));
3570
- const endpoint = new EndpointProgram.Endpoint(toWeb3JsPublicKey(programs.endpoint ?? ENDPOINT_PROGRAM_ID2));
3488
+ const endpoint = new EndpointProgram.Endpoint(programs.endpoint ?? ENDPOINT_PROGRAM_ID2);
3571
3489
  const { payer, admin, mint, escrow } = accounts;
3572
3490
  const [oftStore] = deriver.oftStore(escrow.publicKey);
3573
3491
  const [lzReceiveTypes3] = deriver.lzReceiveTypesAccounts(oftStore);
@@ -3587,13 +3505,13 @@ function initOft4(accounts, oftType, sharedDecimals = OFT_DECIMALS, programs) {
3587
3505
  oftType,
3588
3506
  admin,
3589
3507
  sharedDecimals,
3590
- endpointProgram: fromWeb3JsPublicKey(endpoint.program)
3508
+ endpointProgram: endpoint.programId
3591
3509
  }
3592
3510
  );
3593
3511
  const retval = txBuilder.addRemainingAccounts(
3594
- endpoint.getRegisterOappIxAccountMetaForCPI(toWeb3JsPublicKey(payer.publicKey), toWeb3JsPublicKey(oftStore)).map((acc) => {
3512
+ endpoint.getRegisterOappIxAccountMetaForCPI(payer.publicKey, oftStore).map((acc) => {
3595
3513
  return {
3596
- pubkey: fromWeb3JsPublicKey(acc.pubkey),
3514
+ pubkey: acc.pubkey,
3597
3515
  isSigner: acc.isSigner,
3598
3516
  isWritable: acc.isWritable
3599
3517
  };
@@ -3605,7 +3523,6 @@ function initOft4(accounts, oftType, sharedDecimals = OFT_DECIMALS, programs) {
3605
3523
  function setOFTConfig2(accounts, params, programs) {
3606
3524
  let actualParams;
3607
3525
  const { oftStore, admin } = accounts;
3608
- const oftStoreWeb3Js = toWeb3JsPublicKey(oftStore);
3609
3526
  const remainingAccounts = [];
3610
3527
  if (params.__kind === "Admin") {
3611
3528
  if (params.admin === void 0) {
@@ -3623,18 +3540,9 @@ function setOFTConfig2(accounts, params, programs) {
3623
3540
  __kind: "Delegate",
3624
3541
  fields: [params.delegate]
3625
3542
  };
3626
- const endpointProgram = toWeb3JsPublicKey(programs.endpoint ?? ENDPOINT_PROGRAM_ID2);
3627
- const [oAppRegistry] = new EndpointPDADeriver(endpointProgram).oappRegistry(oftStoreWeb3Js);
3628
- const [endpointEventAuthority] = new EventPDADeriver(endpointProgram).eventAuthority();
3629
- const keys = EndpointProgram.instructions.createSetDelegateInstructionAccounts(
3630
- {
3631
- oapp: oftStoreWeb3Js,
3632
- oappRegistry: oAppRegistry,
3633
- eventAuthority: endpointEventAuthority,
3634
- program: endpointProgram
3635
- },
3636
- endpointProgram
3637
- );
3543
+ const endpointProgram = programs.endpoint ?? ENDPOINT_PROGRAM_ID2;
3544
+ const endpointSDK = new EndpointProgram.Endpoint(endpointProgram);
3545
+ const keys = endpointSDK.getSetDelegateIxAccountMetaForCPI(oftStore);
3638
3546
  for (const acc of keys) {
3639
3547
  acc.isSigner = false;
3640
3548
  }
@@ -3684,7 +3592,7 @@ function setOFTConfig2(accounts, params, programs) {
3684
3592
  return txBuilder.addRemainingAccounts(
3685
3593
  remainingAccounts.map((acc) => {
3686
3594
  return {
3687
- pubkey: fromWeb3JsPublicKey(acc.pubkey),
3595
+ pubkey: acc.pubkey,
3688
3596
  isSigner: acc.isSigner,
3689
3597
  isWritable: acc.isWritable
3690
3598
  };
@@ -3766,25 +3674,21 @@ async function send4(rpc, accounts, sendParams, programs, remainingAccounts) {
3766
3674
  const deriver = new OftPDA(oftProgramId);
3767
3675
  const [oftStore] = deriver.oftStore(tokenEscrow);
3768
3676
  const [peer] = deriver.peer(oftStore, dstEid);
3769
- const connection = new Connection(rpc.getEndpoint());
3770
3677
  if (remainingAccounts === void 0 || remainingAccounts.length === 0) {
3771
3678
  const peerAddr = accounts.peerAddr ?? await fetchPeerConfig2({ rpc }, peer).then((peerInfo) => peerInfo.peerAddress);
3772
- const endpoint = new EndpointProgram.Endpoint(toWeb3JsPublicKey(programs.endpoint ?? ENDPOINT_PROGRAM_ID2));
3773
- const msgLibProgram = await getSendLibraryProgram2(connection, endpoint, payer.publicKey, oftStore, dstEid);
3679
+ const endpoint = new EndpointProgram.Endpoint(programs.endpoint ?? ENDPOINT_PROGRAM_ID2);
3680
+ const msgLibProgram = await getSendLibraryProgram2(rpc, endpoint, payer.publicKey, oftStore, dstEid);
3774
3681
  const packetPath = {
3775
- srcEid: 0,
3776
3682
  dstEid,
3777
- sender: hexlify(publicKeyBytes(oftStore)),
3778
- receiver: hexlify(peerAddr)
3683
+ sender: oftStore,
3684
+ receiver: peerAddr
3779
3685
  };
3780
- remainingAccounts = await endpoint.getSendIXAccountMetaForCPI(
3781
- connection,
3782
- toWeb3JsPublicKey(payer.publicKey),
3783
- packetPath,
3686
+ remainingAccounts = await endpoint.getSendIXAccountMetaForCPI(rpc, payer.publicKey, {
3687
+ path: packetPath,
3784
3688
  msgLibProgram
3785
- );
3689
+ });
3786
3690
  }
3787
- const [eventAuthorityPDA] = new EventPDADeriver(toWeb3JsPublicKey(oftProgramId)).eventAuthority();
3691
+ const [eventAuthorityPDA] = new EventPDA(oftProgramId).eventAuthority();
3788
3692
  const tokenProgram = programs.token ?? fromWeb3JsPublicKey(TOKEN_PROGRAM_ID);
3789
3693
  const txBuilder = send3(
3790
3694
  { programs: programsRepo },
@@ -3796,7 +3700,7 @@ async function send4(rpc, accounts, sendParams, programs, remainingAccounts) {
3796
3700
  tokenEscrow,
3797
3701
  tokenMint,
3798
3702
  tokenProgram,
3799
- eventAuthority: fromWeb3JsPublicKey(eventAuthorityPDA),
3703
+ eventAuthority: eventAuthorityPDA,
3800
3704
  program: oftProgramId,
3801
3705
  // params
3802
3706
  dstEid,
@@ -3812,35 +3716,28 @@ async function send4(rpc, accounts, sendParams, programs, remainingAccounts) {
3812
3716
  return txBuilder.addRemainingAccounts(
3813
3717
  remainingAccounts.map((acc) => {
3814
3718
  return {
3815
- pubkey: fromWeb3JsPublicKey(acc.pubkey),
3719
+ pubkey: acc.pubkey,
3816
3720
  isSigner: acc.isSigner,
3817
3721
  isWritable: acc.isWritable
3818
3722
  };
3819
3723
  })
3820
3724
  ).items[0];
3821
3725
  }
3822
- async function quote2(rpc, accounts, quoteParams, programs, remainingAccounts) {
3726
+ async function quote2(rpc, accounts, quoteParams, programs, remainingAccounts, addressLookupTable) {
3823
3727
  const { dstEid, to, amountLd, minAmountLd, options, payInLzToken, composeParams } = quoteParams;
3824
3728
  const { payer, tokenMint, tokenEscrow } = accounts;
3825
3729
  const programsRepo = typeof programs.oft === "string" ? createOFTProgramRepo2(programs.oft) : programs.oft;
3826
3730
  const deriver = new OftPDA(programsRepo.getPublicKey(PROGRAM_NAME));
3827
3731
  const [oftStore] = deriver.oftStore(tokenEscrow);
3828
3732
  const [peer] = deriver.peer(oftStore, dstEid);
3829
- const connection = new Connection(rpc.getEndpoint(), "confirmed");
3830
3733
  if (remainingAccounts === void 0 || remainingAccounts.length === 0) {
3831
3734
  const peerAddr = accounts.peerAddr ?? await fetchPeerConfig2({ rpc }, peer).then((peerInfo) => peerInfo.peerAddress);
3832
- const endpoint = new EndpointProgram.Endpoint(toWeb3JsPublicKey(programs.endpoint ?? ENDPOINT_PROGRAM_ID2));
3833
- const messageLib = await getSendLibraryProgram2(connection, endpoint, payer, oftStore, dstEid);
3834
- remainingAccounts = await endpoint.getQuoteIXAccountMetaForCPI(
3835
- connection,
3836
- toWeb3JsPublicKey(payer),
3837
- {
3838
- sender: hexlify(publicKeyBytes(oftStore)),
3839
- dstEid,
3840
- receiver: hexlify(peerAddr)
3841
- },
3842
- messageLib
3843
- );
3735
+ const endpoint = new EndpointProgram.Endpoint(programs.endpoint ?? ENDPOINT_PROGRAM_ID2);
3736
+ const messageLib = await getSendLibraryProgram2(rpc, endpoint, payer, oftStore, dstEid);
3737
+ remainingAccounts = await endpoint.getQuoteIXAccountMetaForCPI(rpc, payer, {
3738
+ path: { sender: oftStore, dstEid, receiver: peerAddr },
3739
+ msgLibProgram: messageLib
3740
+ });
3844
3741
  }
3845
3742
  let txBuilder = quoteSend2(
3846
3743
  { programs: programsRepo },
@@ -3862,7 +3759,7 @@ async function quote2(rpc, accounts, quoteParams, programs, remainingAccounts) {
3862
3759
  // Get remaining accounts from msgLib(simple_msgLib or uln)
3863
3760
  remainingAccounts.map((acc) => {
3864
3761
  return {
3865
- pubkey: fromWeb3JsPublicKey(acc.pubkey),
3762
+ pubkey: acc.pubkey,
3866
3763
  isSigner: acc.isSigner,
3867
3764
  isWritable: acc.isWritable
3868
3765
  };
@@ -3872,15 +3769,16 @@ async function quote2(rpc, accounts, quoteParams, programs, remainingAccounts) {
3872
3769
  const modifyComputeUnits = ComputeBudgetProgram.setComputeUnitLimit({
3873
3770
  units: 1e6
3874
3771
  });
3875
- const buffer = await simulateTransaction(
3876
- connection,
3772
+ return simulateWeb3JsTransaction(
3773
+ rpc,
3877
3774
  [modifyComputeUnits, web3Ix],
3878
3775
  web3Ix.programId,
3879
3776
  toWeb3JsPublicKey(payer),
3880
- "confirmed"
3777
+ EndpointProgram.types.getMessagingFeeSerializer(),
3778
+ "confirmed",
3779
+ void 0,
3780
+ addressLookupTable === void 0 ? void 0 : toWeb3JsPublicKey(addressLookupTable)
3881
3781
  );
3882
- const fee = EndpointProgram.types.messagingFeeBeet.read(buffer, 0);
3883
- return { nativeFee: BigInt(fee.nativeFee.toString()), lzTokenFee: BigInt(fee.lzTokenFee.toString()) };
3884
3782
  }
3885
3783
  async function quoteOft4(rpc, accounts, quoteParams, oftProgram) {
3886
3784
  const { payer, tokenMint, tokenEscrow } = accounts;
@@ -3906,27 +3804,25 @@ async function quoteOft4(rpc, accounts, quoteParams, oftProgram) {
3906
3804
  }
3907
3805
  ).getInstructions()[0];
3908
3806
  const web3Ix = toWeb3JsInstruction(ix);
3909
- const connection = new Connection(rpc.getEndpoint());
3910
- const returnedValues = await simulateTransaction(
3911
- connection,
3807
+ return simulateWeb3JsTransaction(
3808
+ rpc.getEndpoint(),
3912
3809
  [web3Ix],
3913
3810
  web3Ix.programId,
3914
3811
  toWeb3JsPublicKey(payer),
3812
+ getQuoteOFTResultSerializer2(),
3915
3813
  "confirmed"
3916
3814
  );
3917
- const [result] = getQuoteOFTResultSerializer2().deserialize(returnedValues, 0);
3918
- return result;
3919
3815
  }
3920
- async function getSendLibraryProgram2(connection, endpoint, payer, oftStore, remoteEid) {
3921
- const sendLibInfo = await endpoint.getSendLibrary(connection, toWeb3JsPublicKey(oftStore), remoteEid);
3922
- if (!sendLibInfo?.programId) {
3816
+ async function getSendLibraryProgram2(rpc, endpoint, payer, oftStore, remoteEid) {
3817
+ const sendLibInfo = await endpoint.getSendLibrary(rpc, oftStore, remoteEid);
3818
+ if (!sendLibInfo.programId) {
3923
3819
  throw new Error("Send library not initialized or blocked message library");
3924
3820
  }
3925
3821
  const { programId: msgLibProgram } = sendLibInfo;
3926
- const msgLibVersion = await endpoint.getMessageLibVersion(connection, toWeb3JsPublicKey(payer), msgLibProgram);
3927
- if (msgLibVersion?.major.toString() === "0" && msgLibVersion.minor == 0 && msgLibVersion.endpointVersion == 2) {
3822
+ const msgLibVersion = await endpoint.getMessageLibVersion(rpc, payer, msgLibProgram);
3823
+ if (msgLibVersion.major.toString() === "0" && msgLibVersion.minor == 0 && msgLibVersion.endpointVersion == 2) {
3928
3824
  return new SimpleMessageLibProgram.SimpleMessageLib(msgLibProgram);
3929
- } else if (msgLibVersion?.major.toString() === "3" && msgLibVersion.minor == 0 && msgLibVersion.endpointVersion == 2) {
3825
+ } else if (msgLibVersion.major.toString() === "3" && msgLibVersion.minor == 0 && msgLibVersion.endpointVersion == 2) {
3930
3826
  return new UlnProgram.Uln(msgLibProgram);
3931
3827
  }
3932
3828
  throw new Error(`Unsupported message library version: ${JSON.stringify(msgLibVersion, null, 2)}`);