@layerzerolabs/lz-solana-sdk-v2 2.3.27 → 2.3.28
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/CHANGELOG.md +16 -0
- package/dist/index.cjs +51 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +15 -2
- package/dist/index.d.ts +15 -2
- package/dist/index.mjs +51 -29
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -15890,7 +15890,7 @@ declare const SOLANA_EID = 1;
|
|
|
15890
15890
|
declare function createInitAdapterOftIx(payer: PublicKey, admin: PublicKey, mint: PublicKey, escrow: PublicKey, sharedDecimals?: number, tokenProgram?: PublicKey, oftProgramId?: PublicKey, endpointProgram?: PublicKey): Promise<TransactionInstruction>;
|
|
15891
15891
|
declare function createNonceTx(connection: Connection, nonceAccount: PublicKey, nonceAuthority: PublicKey, instructions: TransactionInstruction[], commitmentOrConfig?: Commitment | GetNonceConfig): Promise<Transaction>;
|
|
15892
15892
|
declare function createInitNativeOftIx(payer: PublicKey, admin: PublicKey, mint: PublicKey, oftMintAuthority: PublicKey, sharedDecimals?: number, tokenProgram?: PublicKey, oftProgramId?: PublicKey, endpointProgram?: PublicKey): Promise<TransactionInstruction>;
|
|
15893
|
-
declare function createSetPeerIx(admin: PublicKey, oftConfig: PublicKey, dstEid: number, peer:
|
|
15893
|
+
declare function createSetPeerIx(admin: PublicKey, oftConfig: PublicKey, dstEid: number, peer: Uint8Array, oftProgramId?: PublicKey): Promise<TransactionInstruction>;
|
|
15894
15894
|
declare function createSetDelegateIx(admin: PublicKey, oftConfig: PublicKey, delegate: PublicKey, oftProgramId?: PublicKey, endpointProgram?: PublicKey): Promise<TransactionInstruction>;
|
|
15895
15895
|
declare function createInitSendLibraryIx(signer: PublicKey, oftConfig: PublicKey, dstEid: number, endpointProgram?: PublicKey): Promise<TransactionInstruction>;
|
|
15896
15896
|
declare function createInitReceiveLibraryIx(signer: PublicKey, oftConfig: PublicKey, remoteEid: number, endpointProgram?: PublicKey): Promise<TransactionInstruction>;
|
|
@@ -15905,7 +15905,20 @@ declare function createTransferAdminIx(signer: PublicKey, oftConfig: PublicKey,
|
|
|
15905
15905
|
declare function sendWithUln(connection: Connection, payer: PublicKey, tokenMint: PublicKey, tokenSource: PublicKey, dstEid: number, amountLd: bigint, minAmountLd: bigint, options: Uint8Array, to: number[], nativeFee: bigint, lzTokenFee?: bigint, tokenEscrow?: PublicKey, composeMsg?: Uint8Array, peerAddr?: number[], remainingAccounts?: AccountMeta[], tokenProgram?: PublicKey, oftProgramId?: PublicKey, endpointProgram?: PublicKey): Promise<TransactionInstruction>;
|
|
15906
15906
|
declare function createInitNonceIx(delegate: PublicKey, // payer
|
|
15907
15907
|
dstEid: number, oftInstance: PublicKey, remoteOappAddr: Uint8Array, endpointProgram?: PublicKey): Promise<TransactionInstruction>;
|
|
15908
|
-
declare function quoteOft(connection: Connection, payer: PublicKey, tokenMint: PublicKey, dstEid: number, amountLd: bigint, minAmountLd: bigint, options: Uint8Array, to: number[], payInLzToken?: boolean, tokenEscrow?: PublicKey, composeMsg?: Uint8Array, tokenProgram?: PublicKey, oftProgramId?: PublicKey, endpointProgram?: PublicKey): Promise<
|
|
15908
|
+
declare function quoteOft(connection: Connection, payer: PublicKey, tokenMint: PublicKey, dstEid: number, amountLd: bigint, minAmountLd: bigint, options: Uint8Array, to: number[], payInLzToken?: boolean, tokenEscrow?: PublicKey, composeMsg?: Uint8Array, tokenProgram?: PublicKey, oftProgramId?: PublicKey, endpointProgram?: PublicKey): Promise<{
|
|
15909
|
+
oftLimits: {
|
|
15910
|
+
minAmountLd: bigint;
|
|
15911
|
+
maxAmountLd: bigint;
|
|
15912
|
+
};
|
|
15913
|
+
oftFeeDetails: {
|
|
15914
|
+
feeAmountLd: bigint;
|
|
15915
|
+
description: string;
|
|
15916
|
+
}[];
|
|
15917
|
+
oftReceipt: {
|
|
15918
|
+
amountSentLd: bigint;
|
|
15919
|
+
amountReceivedLd: bigint;
|
|
15920
|
+
};
|
|
15921
|
+
}>;
|
|
15909
15922
|
declare function quoteWithUln(connection: Connection, payer: PublicKey, tokenMint: PublicKey, dstEid: number, amountLd: bigint, minAmountLd: bigint, options: Uint8Array, to: number[], payInLzToken?: boolean, tokenEscrow?: PublicKey, composeMsg?: Uint8Array, peerAddr?: number[], remainingAccounts?: AccountMeta[], tokenProgram?: PublicKey, oftProgramId?: PublicKey, msgLibProgram?: PublicKey, endpointProgram?: PublicKey): Promise<{
|
|
15910
15923
|
nativeFee: bigint;
|
|
15911
15924
|
lzTokenFee: bigint;
|
package/dist/index.d.ts
CHANGED
|
@@ -15890,7 +15890,7 @@ declare const SOLANA_EID = 1;
|
|
|
15890
15890
|
declare function createInitAdapterOftIx(payer: PublicKey, admin: PublicKey, mint: PublicKey, escrow: PublicKey, sharedDecimals?: number, tokenProgram?: PublicKey, oftProgramId?: PublicKey, endpointProgram?: PublicKey): Promise<TransactionInstruction>;
|
|
15891
15891
|
declare function createNonceTx(connection: Connection, nonceAccount: PublicKey, nonceAuthority: PublicKey, instructions: TransactionInstruction[], commitmentOrConfig?: Commitment | GetNonceConfig): Promise<Transaction>;
|
|
15892
15892
|
declare function createInitNativeOftIx(payer: PublicKey, admin: PublicKey, mint: PublicKey, oftMintAuthority: PublicKey, sharedDecimals?: number, tokenProgram?: PublicKey, oftProgramId?: PublicKey, endpointProgram?: PublicKey): Promise<TransactionInstruction>;
|
|
15893
|
-
declare function createSetPeerIx(admin: PublicKey, oftConfig: PublicKey, dstEid: number, peer:
|
|
15893
|
+
declare function createSetPeerIx(admin: PublicKey, oftConfig: PublicKey, dstEid: number, peer: Uint8Array, oftProgramId?: PublicKey): Promise<TransactionInstruction>;
|
|
15894
15894
|
declare function createSetDelegateIx(admin: PublicKey, oftConfig: PublicKey, delegate: PublicKey, oftProgramId?: PublicKey, endpointProgram?: PublicKey): Promise<TransactionInstruction>;
|
|
15895
15895
|
declare function createInitSendLibraryIx(signer: PublicKey, oftConfig: PublicKey, dstEid: number, endpointProgram?: PublicKey): Promise<TransactionInstruction>;
|
|
15896
15896
|
declare function createInitReceiveLibraryIx(signer: PublicKey, oftConfig: PublicKey, remoteEid: number, endpointProgram?: PublicKey): Promise<TransactionInstruction>;
|
|
@@ -15905,7 +15905,20 @@ declare function createTransferAdminIx(signer: PublicKey, oftConfig: PublicKey,
|
|
|
15905
15905
|
declare function sendWithUln(connection: Connection, payer: PublicKey, tokenMint: PublicKey, tokenSource: PublicKey, dstEid: number, amountLd: bigint, minAmountLd: bigint, options: Uint8Array, to: number[], nativeFee: bigint, lzTokenFee?: bigint, tokenEscrow?: PublicKey, composeMsg?: Uint8Array, peerAddr?: number[], remainingAccounts?: AccountMeta[], tokenProgram?: PublicKey, oftProgramId?: PublicKey, endpointProgram?: PublicKey): Promise<TransactionInstruction>;
|
|
15906
15906
|
declare function createInitNonceIx(delegate: PublicKey, // payer
|
|
15907
15907
|
dstEid: number, oftInstance: PublicKey, remoteOappAddr: Uint8Array, endpointProgram?: PublicKey): Promise<TransactionInstruction>;
|
|
15908
|
-
declare function quoteOft(connection: Connection, payer: PublicKey, tokenMint: PublicKey, dstEid: number, amountLd: bigint, minAmountLd: bigint, options: Uint8Array, to: number[], payInLzToken?: boolean, tokenEscrow?: PublicKey, composeMsg?: Uint8Array, tokenProgram?: PublicKey, oftProgramId?: PublicKey, endpointProgram?: PublicKey): Promise<
|
|
15908
|
+
declare function quoteOft(connection: Connection, payer: PublicKey, tokenMint: PublicKey, dstEid: number, amountLd: bigint, minAmountLd: bigint, options: Uint8Array, to: number[], payInLzToken?: boolean, tokenEscrow?: PublicKey, composeMsg?: Uint8Array, tokenProgram?: PublicKey, oftProgramId?: PublicKey, endpointProgram?: PublicKey): Promise<{
|
|
15909
|
+
oftLimits: {
|
|
15910
|
+
minAmountLd: bigint;
|
|
15911
|
+
maxAmountLd: bigint;
|
|
15912
|
+
};
|
|
15913
|
+
oftFeeDetails: {
|
|
15914
|
+
feeAmountLd: bigint;
|
|
15915
|
+
description: string;
|
|
15916
|
+
}[];
|
|
15917
|
+
oftReceipt: {
|
|
15918
|
+
amountSentLd: bigint;
|
|
15919
|
+
amountReceivedLd: bigint;
|
|
15920
|
+
};
|
|
15921
|
+
}>;
|
|
15909
15922
|
declare function quoteWithUln(connection: Connection, payer: PublicKey, tokenMint: PublicKey, dstEid: number, amountLd: bigint, minAmountLd: bigint, options: Uint8Array, to: number[], payInLzToken?: boolean, tokenEscrow?: PublicKey, composeMsg?: Uint8Array, peerAddr?: number[], remainingAccounts?: AccountMeta[], tokenProgram?: PublicKey, oftProgramId?: PublicKey, msgLibProgram?: PublicKey, endpointProgram?: PublicKey): Promise<{
|
|
15910
15923
|
nativeFee: bigint;
|
|
15911
15924
|
lzTokenFee: bigint;
|
package/dist/index.mjs
CHANGED
|
@@ -20498,25 +20498,40 @@ var Oft = class {
|
|
|
20498
20498
|
const peerInfo = await Peer.fromAccountAddress(connection, peer);
|
|
20499
20499
|
peerAddr = peerInfo.address;
|
|
20500
20500
|
}
|
|
20501
|
-
|
|
20502
|
-
|
|
20503
|
-
|
|
20504
|
-
|
|
20505
|
-
|
|
20506
|
-
|
|
20507
|
-
|
|
20508
|
-
|
|
20509
|
-
|
|
20510
|
-
|
|
20511
|
-
|
|
20512
|
-
|
|
20513
|
-
|
|
20514
|
-
await isAccountInitialized(
|
|
20501
|
+
if (remainingAccounts === void 0 || remainingAccounts.length === 0) {
|
|
20502
|
+
const msgLibProgram = await this.getSendLibraryProgram(connection, payer, dstEid);
|
|
20503
|
+
const [endpointSettings] = this.endpoint.deriver.setting();
|
|
20504
|
+
const packetPath = {
|
|
20505
|
+
srcEid: 0,
|
|
20506
|
+
dstEid,
|
|
20507
|
+
sender: hexlify(oftConfig.toBytes()),
|
|
20508
|
+
receiver: hexlify(peerAddr)
|
|
20509
|
+
};
|
|
20510
|
+
invariant5(
|
|
20511
|
+
await isAccountInitialized(connection, endpointSettings),
|
|
20512
|
+
"endpointSettings account not initialized"
|
|
20513
|
+
);
|
|
20514
|
+
invariant5(await isAccountInitialized(connection, peer), "peer account not initialized");
|
|
20515
|
+
invariant5(
|
|
20516
|
+
await isAccountInitialized(connection, enforcedOptions),
|
|
20517
|
+
"enforcedOptions account not initialized"
|
|
20518
|
+
);
|
|
20519
|
+
invariant5(await isAccountInitialized(connection, payer), "payer account not initialized");
|
|
20520
|
+
invariant5(
|
|
20521
|
+
await isAccountInitialized(
|
|
20522
|
+
connection,
|
|
20523
|
+
this.endpoint.deriver.nonce(oftConfig, dstEid, Uint8Array.from(peerAddr))[0]
|
|
20524
|
+
),
|
|
20525
|
+
"nonce account not initialized"
|
|
20526
|
+
);
|
|
20527
|
+
remainingAccounts = await this.endpoint.getSendIXAccountMetaForCPI(
|
|
20515
20528
|
connection,
|
|
20516
|
-
|
|
20517
|
-
|
|
20518
|
-
|
|
20519
|
-
|
|
20529
|
+
payer,
|
|
20530
|
+
packetPath,
|
|
20531
|
+
msgLibProgram,
|
|
20532
|
+
commitmentOrConfig
|
|
20533
|
+
);
|
|
20534
|
+
}
|
|
20520
20535
|
return createSendInstruction(
|
|
20521
20536
|
{
|
|
20522
20537
|
signer: payer,
|
|
@@ -20530,13 +20545,7 @@ var Oft = class {
|
|
|
20530
20545
|
eventAuthority: this.eventAuthorityPDA,
|
|
20531
20546
|
program: this.program,
|
|
20532
20547
|
// Get remaining accounts from msgLib(simple_msgLib or uln)
|
|
20533
|
-
anchorRemainingAccounts: remainingAccounts
|
|
20534
|
-
connection,
|
|
20535
|
-
payer,
|
|
20536
|
-
packetPath,
|
|
20537
|
-
msgLibProgram,
|
|
20538
|
-
commitmentOrConfig
|
|
20539
|
-
)
|
|
20548
|
+
anchorRemainingAccounts: remainingAccounts
|
|
20540
20549
|
},
|
|
20541
20550
|
{
|
|
20542
20551
|
params: {
|
|
@@ -20681,7 +20690,7 @@ async function createSetPeerIx(admin, oftConfig, dstEid, peer, oftProgramId = PR
|
|
|
20681
20690
|
{
|
|
20682
20691
|
params: {
|
|
20683
20692
|
dstEid,
|
|
20684
|
-
peer
|
|
20693
|
+
peer: Array.from(peer)
|
|
20685
20694
|
}
|
|
20686
20695
|
},
|
|
20687
20696
|
oftProgramId
|
|
@@ -20877,15 +20886,28 @@ async function quoteOft(connection, payer, tokenMint, dstEid, amountLd, minAmoun
|
|
|
20877
20886
|
oftProgramId
|
|
20878
20887
|
);
|
|
20879
20888
|
const returnedValues = await simulateTransaction(connection, [ix], ix.programId, payer, "confirmed");
|
|
20880
|
-
const [
|
|
20881
|
-
return
|
|
20889
|
+
const [resultInBeet] = types_exports.quoteOftResultBeet.deserialize(returnedValues, 0);
|
|
20890
|
+
return {
|
|
20891
|
+
oftLimits: {
|
|
20892
|
+
minAmountLd: BigInt(resultInBeet.oftLimits.minAmountLd.toString()),
|
|
20893
|
+
maxAmountLd: BigInt(resultInBeet.oftLimits.maxAmountLd.toString())
|
|
20894
|
+
},
|
|
20895
|
+
oftFeeDetails: resultInBeet.oftFeeDetails.map((fee) => ({
|
|
20896
|
+
feeAmountLd: BigInt(fee.feeAmountLd.toString()),
|
|
20897
|
+
description: fee.description
|
|
20898
|
+
})),
|
|
20899
|
+
oftReceipt: {
|
|
20900
|
+
amountSentLd: BigInt(resultInBeet.oftReceipt.amountSentLd.toString()),
|
|
20901
|
+
amountReceivedLd: BigInt(resultInBeet.oftReceipt.amountReceivedLd.toString())
|
|
20902
|
+
}
|
|
20903
|
+
};
|
|
20882
20904
|
}
|
|
20883
20905
|
async function quoteWithUln(connection, payer, tokenMint, dstEid, amountLd, minAmountLd, options, to, payInLzToken = false, tokenEscrow, composeMsg, peerAddr, remainingAccounts, tokenProgram = TOKEN_PROGRAM_ID, oftProgramId = PROGRAM_ID, msgLibProgram = PROGRAM_ID6, endpointProgram = PROGRAM_ID2) {
|
|
20884
20906
|
const oft = new Oft(oftProgramId, endpointProgram, tokenProgram, tokenMint, tokenEscrow);
|
|
20885
20907
|
const oftInstance = oft.getOftConfig();
|
|
20886
20908
|
const [enforcedOptions] = oft.deriver.enforcedOptions(oftInstance, dstEid);
|
|
20887
20909
|
const [peer] = oft.deriver.peer(oftInstance, dstEid);
|
|
20888
|
-
if (peerAddr
|
|
20910
|
+
if (peerAddr === void 0) {
|
|
20889
20911
|
const peerInfo = await accounts_exports.Peer.fromAccountAddress(connection, peer);
|
|
20890
20912
|
peerAddr = peerInfo.address;
|
|
20891
20913
|
}
|