@layerzerolabs/lz-aptos-sdk-v1 2.3.7 → 2.3.8
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 +8 -0
- package/dist/index.cjs +30 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -13
- package/dist/index.d.ts +13 -13
- package/dist/index.mjs +30 -30
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.d.cts
CHANGED
|
@@ -271,9 +271,7 @@ declare const ZERO_ADDRESS_BYTES: Uint8Array;
|
|
|
271
271
|
declare const GAS_LIMIT_SAFETY_BPS = 2000;
|
|
272
272
|
declare function encodePacket(packet: Packet): Buffer;
|
|
273
273
|
declare function computeGuid(packet: Packet): string;
|
|
274
|
-
|
|
275
|
-
(chainId: number): Promise<number>;
|
|
276
|
-
}
|
|
274
|
+
type GetAddressSizeOfChainFunc = (chainId: number) => Promise<number>;
|
|
277
275
|
/**
|
|
278
276
|
* decode the packet generated on the Aptos chain only, it assumes that the size of the source address is 32
|
|
279
277
|
* @param buf
|
|
@@ -823,7 +821,7 @@ declare class PreCrime {
|
|
|
823
821
|
* @param precrimePeers The precrime peers to set
|
|
824
822
|
* @returns The payload to be used in the transaction
|
|
825
823
|
*/
|
|
826
|
-
setPreCrimePeersPayload(oftType: string, eids:
|
|
824
|
+
setPreCrimePeersPayload(oftType: string, eids: aptos.BCS.Uint32[], precrimePeers: aptos.MaybeHexString[]): aptos.Types.EntryFunctionPayload;
|
|
827
825
|
/**
|
|
828
826
|
* Set the max batch size for a given OFT type
|
|
829
827
|
* @param oftType The OFT type, e.g. 0x1::BTCbOFT::BTCb
|
|
@@ -831,12 +829,12 @@ declare class PreCrime {
|
|
|
831
829
|
* @returns The payload to be used in the transaction
|
|
832
830
|
*/
|
|
833
831
|
setMaxBatchSizePayload(oftType: string, maxBatchSize: aptos.BCS.Uint64): aptos.Types.EntryFunctionPayload;
|
|
834
|
-
getConfig(packets:
|
|
835
|
-
simulate(packets:
|
|
836
|
-
precrime(packets:
|
|
837
|
-
getConfigTypes(packets:
|
|
838
|
-
getSimulateTypes(packets:
|
|
839
|
-
getPreCrimeTypes(packets:
|
|
832
|
+
getConfig(packets: aptos.MaybeHexString[], ledger_version?: string): Promise<aptos.MaybeHexString>;
|
|
833
|
+
simulate(packets: aptos.MaybeHexString[], ledger_version?: string): Promise<aptos.MaybeHexString>;
|
|
834
|
+
precrime(packets: aptos.MaybeHexString[], simulations: aptos.MaybeHexString[], ledger_version?: string): Promise<boolean>;
|
|
835
|
+
getConfigTypes(packets: aptos.MaybeHexString[], ledger_version?: string): Promise<string[]>;
|
|
836
|
+
getSimulateTypes(packets: aptos.MaybeHexString[], ledger_version?: string): Promise<string[]>;
|
|
837
|
+
getPreCrimeTypes(packets: aptos.MaybeHexString[], simulations: aptos.MaybeHexString[], ledger_version?: string): Promise<string[]>;
|
|
840
838
|
private formatTypes;
|
|
841
839
|
private assertType;
|
|
842
840
|
}
|
|
@@ -873,12 +871,14 @@ type AccountsOption = {
|
|
|
873
871
|
executor_v2?: aptos.MaybeHexString;
|
|
874
872
|
layerzero_apps?: aptos.MaybeHexString;
|
|
875
873
|
layerzero_apps_pubkey?: aptos.MaybeHexString;
|
|
876
|
-
} &
|
|
877
|
-
|
|
874
|
+
} & {
|
|
875
|
+
[key: string]: aptos.MaybeHexString;
|
|
876
|
+
};
|
|
877
|
+
interface SdkOptions {
|
|
878
878
|
provider: aptos.AptosClient;
|
|
879
879
|
stage?: Stage;
|
|
880
880
|
accounts?: AccountsOption;
|
|
881
|
-
}
|
|
881
|
+
}
|
|
882
882
|
declare class SDK {
|
|
883
883
|
stage: Stage;
|
|
884
884
|
client: aptos.AptosClient;
|
package/dist/index.d.ts
CHANGED
|
@@ -271,9 +271,7 @@ declare const ZERO_ADDRESS_BYTES: Uint8Array;
|
|
|
271
271
|
declare const GAS_LIMIT_SAFETY_BPS = 2000;
|
|
272
272
|
declare function encodePacket(packet: Packet): Buffer;
|
|
273
273
|
declare function computeGuid(packet: Packet): string;
|
|
274
|
-
|
|
275
|
-
(chainId: number): Promise<number>;
|
|
276
|
-
}
|
|
274
|
+
type GetAddressSizeOfChainFunc = (chainId: number) => Promise<number>;
|
|
277
275
|
/**
|
|
278
276
|
* decode the packet generated on the Aptos chain only, it assumes that the size of the source address is 32
|
|
279
277
|
* @param buf
|
|
@@ -823,7 +821,7 @@ declare class PreCrime {
|
|
|
823
821
|
* @param precrimePeers The precrime peers to set
|
|
824
822
|
* @returns The payload to be used in the transaction
|
|
825
823
|
*/
|
|
826
|
-
setPreCrimePeersPayload(oftType: string, eids:
|
|
824
|
+
setPreCrimePeersPayload(oftType: string, eids: aptos.BCS.Uint32[], precrimePeers: aptos.MaybeHexString[]): aptos.Types.EntryFunctionPayload;
|
|
827
825
|
/**
|
|
828
826
|
* Set the max batch size for a given OFT type
|
|
829
827
|
* @param oftType The OFT type, e.g. 0x1::BTCbOFT::BTCb
|
|
@@ -831,12 +829,12 @@ declare class PreCrime {
|
|
|
831
829
|
* @returns The payload to be used in the transaction
|
|
832
830
|
*/
|
|
833
831
|
setMaxBatchSizePayload(oftType: string, maxBatchSize: aptos.BCS.Uint64): aptos.Types.EntryFunctionPayload;
|
|
834
|
-
getConfig(packets:
|
|
835
|
-
simulate(packets:
|
|
836
|
-
precrime(packets:
|
|
837
|
-
getConfigTypes(packets:
|
|
838
|
-
getSimulateTypes(packets:
|
|
839
|
-
getPreCrimeTypes(packets:
|
|
832
|
+
getConfig(packets: aptos.MaybeHexString[], ledger_version?: string): Promise<aptos.MaybeHexString>;
|
|
833
|
+
simulate(packets: aptos.MaybeHexString[], ledger_version?: string): Promise<aptos.MaybeHexString>;
|
|
834
|
+
precrime(packets: aptos.MaybeHexString[], simulations: aptos.MaybeHexString[], ledger_version?: string): Promise<boolean>;
|
|
835
|
+
getConfigTypes(packets: aptos.MaybeHexString[], ledger_version?: string): Promise<string[]>;
|
|
836
|
+
getSimulateTypes(packets: aptos.MaybeHexString[], ledger_version?: string): Promise<string[]>;
|
|
837
|
+
getPreCrimeTypes(packets: aptos.MaybeHexString[], simulations: aptos.MaybeHexString[], ledger_version?: string): Promise<string[]>;
|
|
840
838
|
private formatTypes;
|
|
841
839
|
private assertType;
|
|
842
840
|
}
|
|
@@ -873,12 +871,14 @@ type AccountsOption = {
|
|
|
873
871
|
executor_v2?: aptos.MaybeHexString;
|
|
874
872
|
layerzero_apps?: aptos.MaybeHexString;
|
|
875
873
|
layerzero_apps_pubkey?: aptos.MaybeHexString;
|
|
876
|
-
} &
|
|
877
|
-
|
|
874
|
+
} & {
|
|
875
|
+
[key: string]: aptos.MaybeHexString;
|
|
876
|
+
};
|
|
877
|
+
interface SdkOptions {
|
|
878
878
|
provider: aptos.AptosClient;
|
|
879
879
|
stage?: Stage;
|
|
880
880
|
accounts?: AccountsOption;
|
|
881
|
-
}
|
|
881
|
+
}
|
|
882
882
|
declare class SDK {
|
|
883
883
|
stage: Stage;
|
|
884
884
|
client: aptos.AptosClient;
|
package/dist/index.mjs
CHANGED
|
@@ -362,7 +362,7 @@ function hexToAscii(hex) {
|
|
|
362
362
|
let str = "";
|
|
363
363
|
let i = 0;
|
|
364
364
|
const l = hex.length;
|
|
365
|
-
if (hex.
|
|
365
|
+
if (hex.startsWith("0x")) {
|
|
366
366
|
i = 2;
|
|
367
367
|
}
|
|
368
368
|
for (; i < l; i += 2) {
|
|
@@ -492,13 +492,13 @@ async function getLzReceiveTypeArguments(bytecode, sdk, publicKey, dstAddress, s
|
|
|
492
492
|
const address = getAddressFromPublicKey(publicKey);
|
|
493
493
|
const rawTransaction = await sdk.client.generateRawTransaction(address, transaction, {});
|
|
494
494
|
const txns = await sdk.client.simulateTransaction(publicKey, rawTransaction);
|
|
495
|
-
if (txns[0].success
|
|
495
|
+
if (!txns[0].success) {
|
|
496
496
|
throw new Error(txns[0].vm_status);
|
|
497
497
|
}
|
|
498
498
|
const result = txns.flatMap((txn) => txn.changes).filter(
|
|
499
499
|
(change) => change.type === "write_resource" && change.data.type.match(/::executor_ext::TypeArguments$/)
|
|
500
500
|
).map((change) => change.data.data).flatMap((r) => {
|
|
501
|
-
return r
|
|
501
|
+
return r.types;
|
|
502
502
|
}).map((t) => {
|
|
503
503
|
const account_address = fullAddress(t.account_address).toString();
|
|
504
504
|
const module_name = hexToAscii(t.module_name);
|
|
@@ -737,7 +737,7 @@ var Endpoint = class {
|
|
|
737
737
|
}
|
|
738
738
|
async registerExecutor(signer, executorType) {
|
|
739
739
|
const transaction = this.registerExecutorPayload(executorType);
|
|
740
|
-
return
|
|
740
|
+
return this.sdk.sendAndConfirmTransaction(signer, transaction);
|
|
741
741
|
}
|
|
742
742
|
};
|
|
743
743
|
|
|
@@ -1526,27 +1526,27 @@ var CompiledScriptRaw = class _CompiledScriptRaw {
|
|
|
1526
1526
|
}
|
|
1527
1527
|
};
|
|
1528
1528
|
var CompiledScript = class _CompiledScript {
|
|
1529
|
-
// @ts-
|
|
1529
|
+
// @ts-expect-error
|
|
1530
1530
|
header;
|
|
1531
|
-
// @ts-
|
|
1531
|
+
// @ts-expect-error
|
|
1532
1532
|
table;
|
|
1533
1533
|
moduleHandles = [];
|
|
1534
1534
|
structHandles = [];
|
|
1535
1535
|
functionHandles = [];
|
|
1536
1536
|
functionInstatiations = [];
|
|
1537
|
-
// @ts-
|
|
1537
|
+
// @ts-expect-error
|
|
1538
1538
|
signatures;
|
|
1539
|
-
// @ts-
|
|
1539
|
+
// @ts-expect-error
|
|
1540
1540
|
constantPool;
|
|
1541
|
-
// @ts-
|
|
1541
|
+
// @ts-expect-error
|
|
1542
1542
|
metadata;
|
|
1543
1543
|
identifiers = [];
|
|
1544
1544
|
addressIdentifiers = [];
|
|
1545
|
-
// @ts-
|
|
1545
|
+
// @ts-expect-error
|
|
1546
1546
|
typeParameters;
|
|
1547
|
-
// @ts-
|
|
1547
|
+
// @ts-expect-error
|
|
1548
1548
|
parameters;
|
|
1549
|
-
// @ts-
|
|
1549
|
+
// @ts-expect-error
|
|
1550
1550
|
code;
|
|
1551
1551
|
static from(raw) {
|
|
1552
1552
|
const script = new _CompiledScript();
|
|
@@ -2493,7 +2493,7 @@ var UlnReceive = class {
|
|
|
2493
2493
|
serializer.serializeBytes(Uint8Array.from(hash));
|
|
2494
2494
|
const payloadEntryFunction = new aptos2.TxnBuilderTypes.TransactionPayloadEntryFunction(
|
|
2495
2495
|
aptos2.TxnBuilderTypes.EntryFunction.natural(
|
|
2496
|
-
|
|
2496
|
+
this.module,
|
|
2497
2497
|
"oracle_propose",
|
|
2498
2498
|
[],
|
|
2499
2499
|
[serializer.getBytes(), aptos2.BCS.bcsSerializeUint64(confirmations)]
|
|
@@ -2522,7 +2522,7 @@ var UlnReceive = class {
|
|
|
2522
2522
|
}
|
|
2523
2523
|
async oracleProposeMS(multisigAccountAddress, multisigAccountPubkey, signFunc, hash, confirmations) {
|
|
2524
2524
|
const payload = await this.oracleProposePayloadMS(multisigAccountAddress, hash, confirmations);
|
|
2525
|
-
return
|
|
2525
|
+
return this.sdk.sendAndConfirmMultiSigTransaction(
|
|
2526
2526
|
this.sdk.client,
|
|
2527
2527
|
multisigAccountAddress,
|
|
2528
2528
|
multisigAccountPubkey,
|
|
@@ -2541,12 +2541,12 @@ var UlnSigner = class {
|
|
|
2541
2541
|
moduleName;
|
|
2542
2542
|
async register_TransactionPayload() {
|
|
2543
2543
|
return new aptos2.TxnBuilderTypes.TransactionPayloadEntryFunction(
|
|
2544
|
-
aptos2.TxnBuilderTypes.EntryFunction.natural(
|
|
2544
|
+
aptos2.TxnBuilderTypes.EntryFunction.natural(this.module, "register", [], [])
|
|
2545
2545
|
);
|
|
2546
2546
|
}
|
|
2547
2547
|
async registerMS(multisigAccountAddress, multisigAccountPubkey, signFunc) {
|
|
2548
2548
|
const payload = await this.register_TransactionPayload();
|
|
2549
|
-
return
|
|
2549
|
+
return this.sdk.sendAndConfirmMultiSigTransaction(
|
|
2550
2550
|
this.sdk.client,
|
|
2551
2551
|
multisigAccountAddress,
|
|
2552
2552
|
multisigAccountPubkey,
|
|
@@ -2579,7 +2579,7 @@ var UlnSigner = class {
|
|
|
2579
2579
|
async getSetFee_TransactionPayload(dstChainId, baseFee, feePerByte) {
|
|
2580
2580
|
return new aptos2.TxnBuilderTypes.TransactionPayloadEntryFunction(
|
|
2581
2581
|
aptos2.TxnBuilderTypes.EntryFunction.natural(
|
|
2582
|
-
|
|
2582
|
+
this.module,
|
|
2583
2583
|
"set_fee",
|
|
2584
2584
|
[],
|
|
2585
2585
|
[
|
|
@@ -2603,7 +2603,7 @@ var UlnSigner = class {
|
|
|
2603
2603
|
}
|
|
2604
2604
|
async setFeeMS(multisigAccountAddress, multisigAccountPubkey, signFunc, dstChainId, baseFee, feePerByte) {
|
|
2605
2605
|
const payload = await this.getSetFee_TransactionPayload(dstChainId, baseFee, feePerByte);
|
|
2606
|
-
return
|
|
2606
|
+
return this.sdk.sendAndConfirmMultiSigTransaction(
|
|
2607
2607
|
this.sdk.client,
|
|
2608
2608
|
multisigAccountAddress,
|
|
2609
2609
|
multisigAccountPubkey,
|
|
@@ -3033,7 +3033,7 @@ var Bridge = class {
|
|
|
3033
3033
|
Buffer.from(aptos2.HexString.ensure(remoteCoin.remote_address).noPrefix(), "hex")
|
|
3034
3034
|
);
|
|
3035
3035
|
const tvlSD = BigInt(remoteCoin.tvl_sd);
|
|
3036
|
-
const unwrappable = remoteCoin
|
|
3036
|
+
const { unwrappable } = remoteCoin;
|
|
3037
3037
|
return {
|
|
3038
3038
|
address,
|
|
3039
3039
|
tvlSD,
|
|
@@ -3041,7 +3041,7 @@ var Bridge = class {
|
|
|
3041
3041
|
};
|
|
3042
3042
|
}
|
|
3043
3043
|
async getCoinStore(coin) {
|
|
3044
|
-
return
|
|
3044
|
+
return this.sdk.client.getAccountResource(
|
|
3045
3045
|
this.address,
|
|
3046
3046
|
`${this.module}::CoinStore<${this.coin.getCoinType(coin)}>`
|
|
3047
3047
|
);
|
|
@@ -3125,7 +3125,7 @@ var Bridge = class {
|
|
|
3125
3125
|
return this.sdk.sendAndConfirmTransaction(signer, transaction);
|
|
3126
3126
|
}
|
|
3127
3127
|
async getCoinTypeStore() {
|
|
3128
|
-
return
|
|
3128
|
+
return this.sdk.client.getAccountResource(this.address, `${this.module}::CoinTypeStore`);
|
|
3129
3129
|
}
|
|
3130
3130
|
async getCoinTypes() {
|
|
3131
3131
|
const resource = await this.getCoinTypeStore();
|
|
@@ -3145,9 +3145,9 @@ var Bridge = class {
|
|
|
3145
3145
|
const typeInfo = `0x1::coin::CoinInfo<${coinStructTag}>`;
|
|
3146
3146
|
const resource = await this.sdk.client.getAccountResource(this.address, typeInfo);
|
|
3147
3147
|
const coinInfo = resource;
|
|
3148
|
-
const name = coinInfo.data
|
|
3149
|
-
const symbol = coinInfo.data
|
|
3150
|
-
const decimals = coinInfo.data
|
|
3148
|
+
const { name } = coinInfo.data;
|
|
3149
|
+
const { symbol } = coinInfo.data;
|
|
3150
|
+
const { decimals } = coinInfo.data;
|
|
3151
3151
|
const supply = coinInfo.data.supply.vec[0].integer.vec[0].value;
|
|
3152
3152
|
return {
|
|
3153
3153
|
name,
|
|
@@ -3536,7 +3536,7 @@ var MultisigOracle = class {
|
|
|
3536
3536
|
// View Functions
|
|
3537
3537
|
async isAdmin(account) {
|
|
3538
3538
|
const resource = await this.sdk.client.getAccountResource(this.address, `${this.module}::Config`);
|
|
3539
|
-
const admins = resource.data
|
|
3539
|
+
const { admins } = resource.data;
|
|
3540
3540
|
const acc = aptos2.HexString.ensure(account).toShortString();
|
|
3541
3541
|
return admins.includes(acc);
|
|
3542
3542
|
}
|
|
@@ -3551,7 +3551,7 @@ var MultisigOracle = class {
|
|
|
3551
3551
|
}
|
|
3552
3552
|
async getMultisigPubKeyAndAddress(validatorPubKeys) {
|
|
3553
3553
|
const pubKeys = Object.keys(validatorPubKeys).map((key) => stringToUint8Array(key));
|
|
3554
|
-
return
|
|
3554
|
+
return generateMultisig([...pubKeys], pubKeys.length);
|
|
3555
3555
|
}
|
|
3556
3556
|
async getResourceAddress() {
|
|
3557
3557
|
const resource = await this.sdk.client.getAccountResource(this.address, `${this.module}::Config`);
|
|
@@ -3992,16 +3992,16 @@ var OFT = class {
|
|
|
3992
3992
|
if (!match) {
|
|
3993
3993
|
throw new Error(`Invalid oft type: ${oftType}`);
|
|
3994
3994
|
}
|
|
3995
|
-
const address = match.groups
|
|
3995
|
+
const { address } = match.groups;
|
|
3996
3996
|
return address;
|
|
3997
3997
|
}
|
|
3998
3998
|
async getGlobalStore(oftType) {
|
|
3999
3999
|
const address = this.getTypeAddress(oftType);
|
|
4000
|
-
return
|
|
4000
|
+
return this.sdk.client.getAccountResource(address, `${this.module}::GlobalStore<${oftType}>`);
|
|
4001
4001
|
}
|
|
4002
4002
|
async getCoinStore(oftType) {
|
|
4003
4003
|
const address = this.getTypeAddress(oftType);
|
|
4004
|
-
return
|
|
4004
|
+
return this.sdk.client.getAccountResource(address, `${this.module}::CoinStore<${oftType}>`);
|
|
4005
4005
|
}
|
|
4006
4006
|
transferPayload(oftType, to, amount) {
|
|
4007
4007
|
return {
|
|
@@ -4086,7 +4086,7 @@ var Oracle = class {
|
|
|
4086
4086
|
}
|
|
4087
4087
|
async isValidator(validator) {
|
|
4088
4088
|
const resource = await this.sdk.client.getAccountResource(this.address, `${this.module}::Config`);
|
|
4089
|
-
const validators = resource.data
|
|
4089
|
+
const { validators } = resource.data;
|
|
4090
4090
|
const val = aptos2.HexString.ensure(validator).toShortString();
|
|
4091
4091
|
return validators.includes(val);
|
|
4092
4092
|
}
|