UNPKG

@protonsale/sdk

Version:
641 lines 56.1 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.ProtonSaleClient = exports.NODE_URL_MAINNET = exports.NODE_URL_TESTNET = exports.NODE_URL_DEVNET = void 0; const aptos_1 = require("aptos"); const axios_1 = __importDefault(require("axios")); /** * Provides methods for retrieving data from Aptos node. * For more detailed API specification see {@link https://fullnode.devnet.aptoslabs.com/v1/spec} */ exports.NODE_URL_DEVNET = "https://fullnode.devnet.aptoslabs.com/v1"; exports.NODE_URL_TESTNET = "https://fullnode.testnet.aptoslabs.com/v1"; exports.NODE_URL_MAINNET = "https://fullnode.mainnet.aptoslabs.com/v1"; class ProtonSaleClient extends aptos_1.AptosClient { constructor(_networkType, _network, _saleAddress, _airdropAddress, config) { let network; let eventAddress; let airdropAddress; let globalStorageAddress; let saleAddress; let apiEndpoint; const apiEndpointCreateCoin = "https://dev2-api.protonsale.io"; if (_networkType === "MAINNET") { if (_network === undefined) { network = exports.NODE_URL_MAINNET; } else { network = _network; } globalStorageAddress = "0xbdda8aab9903e4485dc3893e32eb1d5084b1304e61eac85837fd1d0c09392704"; eventAddress = "0x1b392dc163c619021464efd08f6701e266860b9d71c6a13338ff205de002b2c1"; saleAddress = "0xf42220492c630f88c78b87b3d25bf45ede2798fa364b5152dd396e313cc64c1a"; airdropAddress = "0x8e836df4f0c5a2631c132673ee8190a4bbf3f30e99c873f9824d1237fff096ad"; apiEndpoint = "https://api.protonsale.io"; } else if (_networkType === "TESTNET") { if (_network === undefined) { network = exports.NODE_URL_TESTNET; } else { network = _network; } globalStorageAddress = "0xbdda8aab9903e4485dc3893e32eb1d5084b1304e61eac85837fd1d0c09392704"; eventAddress = "0x1b392dc163c619021464efd08f6701e266860b9d71c6a13338ff205de002b2c1"; airdropAddress = "0x8e836df4f0c5a2631c132673ee8190a4bbf3f30e99c873f9824d1237fff096ad"; saleAddress = "0xf42220492c630f88c78b87b3d25bf45ede2798fa364b5152dd396e313cc64c1a"; apiEndpoint = "https://stg-api.protonsale.io"; } else { if (_network === undefined) { network = exports.NODE_URL_DEVNET; } else { network = _network; } globalStorageAddress = ""; eventAddress = "0x80038fe1d86d69447323d0252937e3386b4b761dfcf1e461d7bfba0c665bc4d4"; saleAddress = "0xecfe5b1cacb7adf5f55095d0fbc58709b7efbf0a95f7cc7ffddacf30ef5b1aa0"; apiEndpoint = "https://dev-api.protonsale.io"; } // eslint-disable-next-line max-len super(network, config); this.genInitializeCoinPayload = async (account, moduleName, name, symbol, decimals) => { const token = new aptos_1.TxnBuilderTypes.TypeTagStruct(aptos_1.TxnBuilderTypes.StructTag.fromString(`${account.noPrefix()}::${moduleName}`)); const serializer = new aptos_1.BCS.Serializer(); serializer.serializeBool(false); const scriptFunctionPayload = new aptos_1.TxnBuilderTypes.TransactionPayloadEntryFunction(aptos_1.TxnBuilderTypes.EntryFunction.natural("0x1::managed_coin", "initialize", [token], [ aptos_1.BCS.bcsSerializeStr(name), aptos_1.BCS.bcsSerializeStr(symbol), aptos_1.BCS.bcsSerializeU8(decimals), serializer.getBytes(), ])); const [{ sequence_number: sequenceNumber }, chainId] = await Promise.all([ this.getAccount(account.hex()), this.getChainId(), ]); return new aptos_1.TxnBuilderTypes.RawTransaction(aptos_1.TxnBuilderTypes.AccountAddress.fromHex(account.hex()), BigInt(sequenceNumber), scriptFunctionPayload, BigInt(20000), BigInt(100), BigInt(Math.floor(Date.now() / 1000) + 10), new aptos_1.TxnBuilderTypes.ChainId(chainId)); }; this.initializeCoin = async (account, moduleName, name, symbol, decimals) => { const rawTxn = await this.genInitializeCoinPayload(account.address(), moduleName, name, symbol, decimals); const signedTxs = aptos_1.AptosClient.generateBCSTransaction(account, rawTxn); const pendingTxn = await this.submitSignedBCSTransaction(signedTxs); await this.waitForTransaction(pendingTxn.hash); return pendingTxn.hash; }; this.initAirdrop = async (account, moduleAddress) => { const scriptFunctionPayload = new aptos_1.TxnBuilderTypes.TransactionPayloadEntryFunction(aptos_1.TxnBuilderTypes.EntryFunction.natural(`${moduleAddress || this.airdropAddress}::airdrop`, "initialize", [], [])); const [{ sequence_number: sequenceNumber }, chainId] = await Promise.all([ this.getAccount(account.address().hex()), this.getChainId(), ]); const rawTxn = await new aptos_1.TxnBuilderTypes.RawTransaction(aptos_1.TxnBuilderTypes.AccountAddress.fromHex(account.address().hex()), BigInt(sequenceNumber), scriptFunctionPayload, BigInt(20000), BigInt(1000), BigInt(Math.floor(Date.now() / 1000) + 10), new aptos_1.TxnBuilderTypes.ChainId(chainId)); const signedTxs = aptos_1.AptosClient.generateBCSTransaction(account, rawTxn); const pendingTxn = await this.submitSignedBCSTransaction(signedTxs); await this.waitForTransaction(pendingTxn.hash); return pendingTxn.hash; }; this.genCreateAirdropHasWhitelistPayload = async (account, coinType, id, claimAmount, addresses, moduleAddress) => { const token = new aptos_1.TxnBuilderTypes.TypeTagStruct(aptos_1.TxnBuilderTypes.StructTag.fromString(coinType)); const array = addresses.map(aptos_1.TxnBuilderTypes.AccountAddress.fromHex); const serializer = new aptos_1.BCS.Serializer(); aptos_1.BCS.serializeVector(array, serializer); const scriptFunctionPayload = new aptos_1.TxnBuilderTypes.TransactionPayloadEntryFunction(aptos_1.TxnBuilderTypes.EntryFunction.natural(`${moduleAddress || this.airdropAddress}::airdrop`, "create_airdrop_has_whitelist", [token], [ aptos_1.BCS.bcsSerializeStr(id), aptos_1.BCS.bcsSerializeUint64(BigInt(claimAmount)), serializer.getBytes(), ])); const [{ sequence_number: sequenceNumber }, chainId] = await Promise.all([ this.getAccount(account.hex()), this.getChainId(), ]); return new aptos_1.TxnBuilderTypes.RawTransaction(aptos_1.TxnBuilderTypes.AccountAddress.fromHex(account.hex()), BigInt(sequenceNumber), scriptFunctionPayload, BigInt(20000), BigInt(150), BigInt(Math.floor(Date.now() / 1000) + 10), new aptos_1.TxnBuilderTypes.ChainId(chainId)); }; this.genCreateAirdropHasWhitelistEntryPayload = async (account, coinType, id, claimAmount, addresses, moduleAddress) => { const token = new aptos_1.TxnBuilderTypes.TypeTagStruct(aptos_1.TxnBuilderTypes.StructTag.fromString(coinType)); const array = addresses.map(aptos_1.TxnBuilderTypes.AccountAddress.fromHex); const serializer = new aptos_1.BCS.Serializer(); aptos_1.BCS.serializeVector(array, serializer); const entryFunction = aptos_1.TxnBuilderTypes.EntryFunction.natural(`${moduleAddress || this.airdropAddress}::airdrop`, "create_airdrop_has_whitelist", [token], [ aptos_1.BCS.bcsSerializeStr(id), aptos_1.BCS.bcsSerializeUint64(BigInt(claimAmount)), serializer.getBytes(), ]); return new aptos_1.TxnBuilderTypes.TransactionPayloadEntryFunction(entryFunction); }; this.createAirdropHasWhitelist = async (account, coinType, id, claimAmount, addresses, moduleAddress) => { const rawTxn = await this.genCreateAirdropHasWhitelistPayload(account.address(), coinType, id, claimAmount, addresses, moduleAddress); const signedTxs = aptos_1.AptosClient.generateBCSTransaction(account, rawTxn); const pendingTxn = await this.submitSignedBCSTransaction(signedTxs); await this.waitForTransaction(pendingTxn.hash); return pendingTxn.hash; }; this.genCreateAirdropNotWhitelistPayload = async (account, moduleName, id, claimAmount, numberReceiver, moduleAddress) => { const token = new aptos_1.TxnBuilderTypes.TypeTagStruct(aptos_1.TxnBuilderTypes.StructTag.fromString(`${account.noPrefix()}::${moduleName}`)); const scriptFunctionPayload = new aptos_1.TxnBuilderTypes.TransactionPayloadEntryFunction(aptos_1.TxnBuilderTypes.EntryFunction.natural(`${moduleAddress || this.airdropAddress}::airdrop`, "create_airdrop_not_whitelist", [token], [ aptos_1.BCS.bcsSerializeStr(id), aptos_1.BCS.bcsSerializeUint64(BigInt(claimAmount)), aptos_1.BCS.bcsSerializeUint64(BigInt(numberReceiver)), ])); const [{ sequence_number: sequenceNumber }, chainId] = await Promise.all([ this.getAccount(account.hex()), this.getChainId(), ]); return new aptos_1.TxnBuilderTypes.RawTransaction(aptos_1.TxnBuilderTypes.AccountAddress.fromHex(account.hex()), BigInt(sequenceNumber), scriptFunctionPayload, BigInt(20000), BigInt(1000), BigInt(Math.floor(Date.now() / 1000) + 10), new aptos_1.TxnBuilderTypes.ChainId(chainId)); }; this.createAirdropNotWhitelist = async (account, moduleName, id, claimAmount, numberReceiver, moduleAddress) => { const rawTxn = await this.genCreateAirdropNotWhitelistPayload(account.address(), moduleName, id, claimAmount, numberReceiver, moduleAddress); const signedTxs = aptos_1.AptosClient.generateBCSTransaction(account, rawTxn); const pendingTxn = await this.submitSignedBCSTransaction(signedTxs); await this.waitForTransaction(pendingTxn.hash); return pendingTxn.hash; }; this.genClaimAirdropNotWhitelistPayload = async (account, coinType, sourceAddress, id, moduleAddress) => { const token = new aptos_1.TxnBuilderTypes.TypeTagStruct(aptos_1.TxnBuilderTypes.StructTag.fromString(coinType)); const scriptFunctionPayload = new aptos_1.TxnBuilderTypes.TransactionPayloadEntryFunction(aptos_1.TxnBuilderTypes.EntryFunction.natural(`${moduleAddress || this.airdropAddress}::airdrop`, "claim_airdrop_not_whitelist", [token], [ aptos_1.BCS.bcsToBytes(aptos_1.TxnBuilderTypes.AccountAddress.fromHex(sourceAddress.hex())), aptos_1.BCS.bcsSerializeStr(id), ])); const [{ sequence_number: sequenceNumber }, chainId] = await Promise.all([ this.getAccount(account.hex()), this.getChainId(), ]); return new aptos_1.TxnBuilderTypes.RawTransaction(aptos_1.TxnBuilderTypes.AccountAddress.fromHex(account.hex()), BigInt(sequenceNumber), scriptFunctionPayload, BigInt(20000), BigInt(100), BigInt(Math.floor(Date.now() / 1000) + 10), new aptos_1.TxnBuilderTypes.ChainId(chainId)); }; this.claimAirdropNotWhitelist = async (account, coinType, sourceAddress, id, moduleAddress) => { const rawTxn = await this.genClaimAirdropNotWhitelistPayload(account.address(), coinType, sourceAddress, id, moduleAddress); const signedTxs = aptos_1.AptosClient.generateBCSTransaction(account, rawTxn); const pendingTxn = await this.submitSignedBCSTransaction(signedTxs); await this.waitForTransaction(pendingTxn.hash); return pendingTxn.hash; }; this.genClaimAirdropHasWhitelistPayload = async (account, coinType, sourceAddress, id, moduleAddress) => { const token = new aptos_1.TxnBuilderTypes.TypeTagStruct(aptos_1.TxnBuilderTypes.StructTag.fromString(coinType)); const scriptFunctionPayload = new aptos_1.TxnBuilderTypes.TransactionPayloadEntryFunction(aptos_1.TxnBuilderTypes.EntryFunction.natural(`${moduleAddress || this.airdropAddress}::airdrop`, "claim_airdrop_has_whitelist", [token], [ aptos_1.BCS.bcsToBytes(aptos_1.TxnBuilderTypes.AccountAddress.fromHex(sourceAddress.hex())), aptos_1.BCS.bcsSerializeStr(id), ])); const [{ sequence_number: sequenceNumber }, chainId] = await Promise.all([ this.getAccount(account.hex()), this.getChainId(), ]); return new aptos_1.TxnBuilderTypes.RawTransaction(aptos_1.TxnBuilderTypes.AccountAddress.fromHex(account.hex()), BigInt(sequenceNumber), scriptFunctionPayload, BigInt(20000), BigInt(100), BigInt(Math.floor(Date.now() / 1000) + 10), new aptos_1.TxnBuilderTypes.ChainId(chainId)); }; this.claimAirdropHasWhitelist = async (account, coinType, sourceAddress, id, moduleAddress) => { const rawTxn = await this.genClaimAirdropHasWhitelistPayload(account.address(), coinType, new aptos_1.HexString(sourceAddress), id, moduleAddress); const signedTxs = aptos_1.AptosClient.generateBCSTransaction(account, rawTxn); const pendingTxn = await this.submitSignedBCSTransaction(signedTxs); await this.waitForTransaction(pendingTxn.hash); return pendingTxn.hash; }; this.genCreateLockPayload = async (account, coinType, name, duration, amount, moduleAddress) => { const token = new aptos_1.TxnBuilderTypes.TypeTagStruct(aptos_1.TxnBuilderTypes.StructTag.fromString(coinType)); const scriptFunctionPayload = new aptos_1.TxnBuilderTypes.TransactionPayloadEntryFunction(aptos_1.TxnBuilderTypes.EntryFunction.natural(`${moduleAddress || this.saleAddress}::locker`, "create_lock", [token], [ aptos_1.BCS.bcsSerializeStr(name), aptos_1.BCS.bcsSerializeUint64(BigInt(duration)), aptos_1.BCS.bcsSerializeUint64(BigInt(amount)), ])); const [{ sequence_number: sequenceNumber }, chainId] = await Promise.all([ this.getAccount(account.hex()), this.getChainId(), ]); return new aptos_1.TxnBuilderTypes.RawTransaction(aptos_1.TxnBuilderTypes.AccountAddress.fromHex(account.hex()), BigInt(sequenceNumber), scriptFunctionPayload, BigInt(20000), BigInt(100), BigInt(Math.floor(Date.now() / 1000) + 10), new aptos_1.TxnBuilderTypes.ChainId(chainId)); }; this.createLock = async (account, coinType, name, duration, amount, moduleAddress) => { const rawTxn = await this.genCreateLockPayload(account.address(), coinType, name, duration, amount, moduleAddress); const signedTxs = aptos_1.AptosClient.generateBCSTransaction(account, rawTxn); const pendingTxn = await this.submitSignedBCSTransaction(signedTxs); await this.waitForTransaction(pendingTxn.hash); return pendingTxn.hash; }; this.genClaimLockPayload = async (account, coinType, name, moduleAddress) => { const token = new aptos_1.TxnBuilderTypes.TypeTagStruct(aptos_1.TxnBuilderTypes.StructTag.fromString(coinType)); const scriptFunctionPayload = new aptos_1.TxnBuilderTypes.TransactionPayloadEntryFunction(aptos_1.TxnBuilderTypes.EntryFunction.natural(`${moduleAddress || this.saleAddress}::locker`, "claim", [token], [ aptos_1.BCS.bcsSerializeStr(name), ])); const [{ sequence_number: sequenceNumber }, chainId] = await Promise.all([ this.getAccount(account.hex()), this.getChainId(), ]); return new aptos_1.TxnBuilderTypes.RawTransaction(aptos_1.TxnBuilderTypes.AccountAddress.fromHex(account.hex()), BigInt(sequenceNumber), scriptFunctionPayload, BigInt(20000), BigInt(100), BigInt(Math.floor(Date.now() / 1000) + 10), new aptos_1.TxnBuilderTypes.ChainId(chainId)); }; this.claimLock = async (account, coinType, name, moduleAddress) => { const rawTxn = await this.genClaimLockPayload(account.address(), coinType, name, moduleAddress); const signedTxs = aptos_1.AptosClient.generateBCSTransaction(account, rawTxn); const pendingTxn = await this.submitSignedBCSTransaction(signedTxs); await this.waitForTransaction(pendingTxn.hash); return pendingTxn.hash; }; this.genRegisterCoinPayload = async (coinReceiver, coinTypeAddress, moduleName) => { const token = new aptos_1.TxnBuilderTypes.TypeTagStruct(aptos_1.TxnBuilderTypes.StructTag.fromString(`${coinTypeAddress.hex()}::${moduleName}`)); const scriptFunctionPayload = new aptos_1.TxnBuilderTypes.TransactionPayloadEntryFunction(aptos_1.TxnBuilderTypes.EntryFunction.natural("0x1::managed_coin", "register", [token], [])); const [{ sequence_number: sequenceNumber }, chainId] = await Promise.all([ this.getAccount(coinReceiver), this.getChainId(), ]); return new aptos_1.TxnBuilderTypes.RawTransaction(aptos_1.TxnBuilderTypes.AccountAddress.fromHex(coinReceiver), BigInt(sequenceNumber), scriptFunctionPayload, BigInt(20000), BigInt(100), BigInt(Math.floor(Date.now() / 1000) + 10), new aptos_1.TxnBuilderTypes.ChainId(chainId)); }; this.registerCoin = async (coinReceiver, coinTypeAddress, moduleName) => { const rawTxn = await this.genRegisterCoinPayload(coinReceiver.address(), coinTypeAddress, moduleName); const payload = aptos_1.AptosClient.generateBCSTransaction(coinReceiver, rawTxn); const pendingTxn = await this.submitSignedBCSTransaction(payload); await this.waitForTransaction(pendingTxn.hash); return pendingTxn.hash; }; this.genMintCoinPayload = async (coinOwner, coinTypeAddress, moduleName, receiverAddress, amount) => { const token = new aptos_1.TxnBuilderTypes.TypeTagStruct(aptos_1.TxnBuilderTypes.StructTag.fromString(`${coinTypeAddress.hex()}::${moduleName}`)); const scriptFunctionPayload = new aptos_1.TxnBuilderTypes.TransactionPayloadEntryFunction(aptos_1.TxnBuilderTypes.EntryFunction.natural("0x1::managed_coin", "mint", [token], [ aptos_1.BCS.bcsToBytes(aptos_1.TxnBuilderTypes.AccountAddress.fromHex(receiverAddress.hex())), aptos_1.BCS.bcsSerializeUint64(amount), ])); const [{ sequence_number: sequenceNumber }, chainId] = await Promise.all([ this.getAccount(coinOwner), this.getChainId(), ]); return new aptos_1.TxnBuilderTypes.RawTransaction(aptos_1.TxnBuilderTypes.AccountAddress.fromHex(coinOwner), BigInt(sequenceNumber), scriptFunctionPayload, BigInt(20000), BigInt(100), BigInt(Math.floor(Date.now() / 1000) + 10), new aptos_1.TxnBuilderTypes.ChainId(chainId)); }; this.mintCoin = async (coinOwner, coinTypeAddress, moduleName, receiverAddress, amount) => { // eslint-disable-next-line max-len const rawTxn = await this.genMintCoinPayload(coinOwner.address(), coinTypeAddress, moduleName, receiverAddress, amount); const payload = aptos_1.AptosClient.generateBCSTransaction(coinOwner, rawTxn); const pendingTxn = await this.submitSignedBCSTransaction(payload); await this.waitForTransaction(pendingTxn.hash); return pendingTxn.hash; }; this.genCreateSalePayload = async (account, saleCoinTypeAddress, purchaseCoinTypeAddress, saleName, sale_coin_amount, sale_start_time, whitelist_duration, non_whitelist_duration, hardcap, tge_duration, tge_percent, vesting_cycle_duration, vesting_cycle_percent, liquidity_percent, liquidity_lock_duration, listing_price_increase_percent, max_contribute, module_address) => { const saleCoin = new aptos_1.TxnBuilderTypes.TypeTagStruct(aptos_1.TxnBuilderTypes.StructTag.fromString(`${saleCoinTypeAddress}`)); const purchaseCoin = new aptos_1.TxnBuilderTypes.TypeTagStruct(aptos_1.TxnBuilderTypes.StructTag.fromString(`${purchaseCoinTypeAddress}`)); const scriptFunctionPayload = new aptos_1.TxnBuilderTypes.TransactionPayloadEntryFunction(aptos_1.TxnBuilderTypes.EntryFunction.natural(`${module_address || this.saleAddress}::sale`, "create_sale", [saleCoin, purchaseCoin], [ aptos_1.BCS.bcsSerializeStr(saleName), aptos_1.BCS.bcsSerializeUint64(BigInt(sale_coin_amount)), aptos_1.BCS.bcsSerializeUint64(BigInt(sale_start_time)), aptos_1.BCS.bcsSerializeUint64(BigInt(whitelist_duration)), aptos_1.BCS.bcsSerializeUint64(BigInt(non_whitelist_duration)), aptos_1.BCS.bcsSerializeUint64(BigInt(hardcap)), aptos_1.BCS.bcsSerializeUint64(BigInt(tge_duration)), aptos_1.BCS.bcsSerializeU8(tge_percent), aptos_1.BCS.bcsSerializeUint64(BigInt(vesting_cycle_duration)), aptos_1.BCS.bcsSerializeU8(vesting_cycle_percent), aptos_1.BCS.bcsSerializeU8(liquidity_percent), aptos_1.BCS.bcsSerializeUint64(BigInt(liquidity_lock_duration)), aptos_1.BCS.bcsSerializeU8(listing_price_increase_percent), aptos_1.BCS.bcsSerializeUint64(BigInt(max_contribute)), ])); const [{ sequence_number: sequenceNumber }, chainId] = await Promise.all([ this.getAccount(account), this.getChainId(), ]); return new aptos_1.TxnBuilderTypes.RawTransaction(aptos_1.TxnBuilderTypes.AccountAddress.fromHex(account), BigInt(sequenceNumber), scriptFunctionPayload, BigInt(20000), BigInt(100), BigInt(Math.floor(Date.now() / 1000) + 10), new aptos_1.TxnBuilderTypes.ChainId(chainId)); }; this.createSale = async (account, saleCoinTypeAddress, purchaseCoinTypeAddress, saleName, sale_coin_amount, sale_start_time, whitelist_duration, non_whitelist_duration, hardcap, tge_duration, tge_percent, vesting_cycle_duration, vesting_cycle_percent, liquidity_percent, liquidity_lock_duration, listing_price_increase_percent, max_contribute, module_address) => { const rawTxn = await this.genCreateSalePayload(account.address(), saleCoinTypeAddress, purchaseCoinTypeAddress, saleName, sale_coin_amount, sale_start_time, whitelist_duration, non_whitelist_duration, hardcap, tge_duration, tge_percent, vesting_cycle_duration, vesting_cycle_percent, liquidity_percent, liquidity_lock_duration, listing_price_increase_percent, max_contribute, module_address); const payload = aptos_1.AptosClient.generateBCSTransaction(account, rawTxn); const pendingTxn = await this.submitSignedBCSTransaction(payload); await this.waitForTransaction(pendingTxn.hash); return pendingTxn.hash; }; this.genCreatePresalePayload = async (account, saleCoinTypeAddress, purchaseCoinTypeAddress, saleName, sale_coin_amount, sale_start_time, whitelist_duration, non_whitelist_duration, hardcap, tge_percent, vesting_cycle_duration, vesting_cycle_percent, max_contribute, module_address) => { const saleCoin = new aptos_1.TxnBuilderTypes.TypeTagStruct(aptos_1.TxnBuilderTypes.StructTag.fromString(`${saleCoinTypeAddress}`)); const purchaseCoin = new aptos_1.TxnBuilderTypes.TypeTagStruct(aptos_1.TxnBuilderTypes.StructTag.fromString(`${purchaseCoinTypeAddress}`)); const scriptFunctionPayload = new aptos_1.TxnBuilderTypes.TransactionPayloadEntryFunction(aptos_1.TxnBuilderTypes.EntryFunction.natural(`${module_address || this.saleAddress}::sale`, "create_presale", [saleCoin, purchaseCoin], [ aptos_1.BCS.bcsSerializeStr(saleName), aptos_1.BCS.bcsSerializeUint64(BigInt(sale_coin_amount)), aptos_1.BCS.bcsSerializeUint64(BigInt(sale_start_time)), aptos_1.BCS.bcsSerializeUint64(BigInt(whitelist_duration)), aptos_1.BCS.bcsSerializeUint64(BigInt(non_whitelist_duration)), aptos_1.BCS.bcsSerializeUint64(BigInt(hardcap)), aptos_1.BCS.bcsSerializeU8(tge_percent), aptos_1.BCS.bcsSerializeUint64(BigInt(vesting_cycle_duration)), aptos_1.BCS.bcsSerializeU8(vesting_cycle_percent), aptos_1.BCS.bcsSerializeUint64(BigInt(max_contribute)), ])); const [{ sequence_number: sequenceNumber }, chainId] = await Promise.all([ this.getAccount(account), this.getChainId(), ]); return new aptos_1.TxnBuilderTypes.RawTransaction(aptos_1.TxnBuilderTypes.AccountAddress.fromHex(account), BigInt(sequenceNumber), scriptFunctionPayload, BigInt(20000), BigInt(100), BigInt(Math.floor(Date.now() / 1000) + 10), new aptos_1.TxnBuilderTypes.ChainId(chainId)); }; this.createPresale = async (account, saleCoinTypeAddress, purchaseCoinTypeAddress, saleName, sale_coin_amount, sale_start_time, whitelist_duration, non_whitelist_duration, hardcap, tge_percent, vesting_cycle_duration, vesting_cycle_percent, max_contribute, module_address) => { const rawTxn = await this.genCreatePresalePayload(account.address(), saleCoinTypeAddress, purchaseCoinTypeAddress, saleName, sale_coin_amount, sale_start_time, whitelist_duration, non_whitelist_duration, hardcap, tge_percent, vesting_cycle_duration, vesting_cycle_percent, max_contribute, module_address); const payload = aptos_1.AptosClient.generateBCSTransaction(account, rawTxn); const pendingTxn = await this.submitSignedBCSTransaction(payload); await this.waitForTransaction(pendingTxn.hash); return pendingTxn.hash; }; this.genClaimPayload = async (account, saleCoinTypeAddress, purchaseCoinTypeAddress, creator, id, minter, counter, module_address) => { const saleCoin = new aptos_1.TxnBuilderTypes.TypeTagStruct(aptos_1.TxnBuilderTypes.StructTag.fromString(`${saleCoinTypeAddress}`)); const purchaseCoin = new aptos_1.TxnBuilderTypes.TypeTagStruct(aptos_1.TxnBuilderTypes.StructTag.fromString(`${purchaseCoinTypeAddress}`)); const scriptFunctionPayload = new aptos_1.TxnBuilderTypes.TransactionPayloadEntryFunction(aptos_1.TxnBuilderTypes.EntryFunction.natural(`${module_address || this.saleAddress}::sale`, "claim", [saleCoin, purchaseCoin], [ aptos_1.BCS.bcsToBytes(aptos_1.TxnBuilderTypes.AccountAddress.fromHex(creator)), aptos_1.BCS.bcsSerializeStr(id), aptos_1.BCS.bcsToBytes(aptos_1.TxnBuilderTypes.AccountAddress.fromHex(minter)), aptos_1.BCS.bcsSerializeUint64(BigInt(counter)), ])); const [{ sequence_number: sequenceNumber }, chainId] = await Promise.all([ this.getAccount(account), this.getChainId(), ]); return new aptos_1.TxnBuilderTypes.RawTransaction(aptos_1.TxnBuilderTypes.AccountAddress.fromHex(account), BigInt(sequenceNumber), scriptFunctionPayload, BigInt(20000), BigInt(100), BigInt(Math.floor(Date.now() / 1000) + 10), new aptos_1.TxnBuilderTypes.ChainId(chainId)); }; this.claim = async (account, saleCoinTypeAddress, purchaseCoinTypeAddress, creator, id, minter, counter, module_address) => { const rawTxn = await this.genClaimPayload(account.address(), saleCoinTypeAddress, purchaseCoinTypeAddress, creator, id, minter, counter, module_address); const payload = aptos_1.AptosClient.generateBCSTransaction(account, rawTxn); const pendingTxn = await this.submitSignedBCSTransaction(payload); await this.waitForTransaction(pendingTxn.hash); return pendingTxn.hash; }; this.genSetPresaleTgeTime = async (account, saleCoinTypeAddress, purchaseCoinTypeAddress, creator, id, tge, module_address) => { const saleCoin = new aptos_1.TxnBuilderTypes.TypeTagStruct(aptos_1.TxnBuilderTypes.StructTag.fromString(`${saleCoinTypeAddress}`)); const purchaseCoin = new aptos_1.TxnBuilderTypes.TypeTagStruct(aptos_1.TxnBuilderTypes.StructTag.fromString(`${purchaseCoinTypeAddress}`)); const scriptFunctionPayload = new aptos_1.TxnBuilderTypes.TransactionPayloadEntryFunction(aptos_1.TxnBuilderTypes.EntryFunction.natural(`${module_address || this.saleAddress}::sale`, "set_presale_tge_time", [saleCoin, purchaseCoin], [ aptos_1.BCS.bcsToBytes(aptos_1.TxnBuilderTypes.AccountAddress.fromHex(creator)), aptos_1.BCS.bcsSerializeStr(id), aptos_1.BCS.bcsSerializeUint64(BigInt(tge)), ])); const [{ sequence_number: sequenceNumber }, chainId] = await Promise.all([ this.getAccount(account), this.getChainId(), ]); return new aptos_1.TxnBuilderTypes.RawTransaction(aptos_1.TxnBuilderTypes.AccountAddress.fromHex(account), BigInt(sequenceNumber), scriptFunctionPayload, BigInt(20000), BigInt(100), BigInt(Math.floor(Date.now() / 1000) + 10), new aptos_1.TxnBuilderTypes.ChainId(chainId)); }; this.setPresaleTgeTime = async (account, saleCoinTypeAddress, purchaseCoinTypeAddress, creator, id, tge, module_address) => { const rawTxn = await this.genSetPresaleTgeTime(account.address(), saleCoinTypeAddress, purchaseCoinTypeAddress, creator, id, tge, module_address); const payload = aptos_1.AptosClient.generateBCSTransaction(account, rawTxn); const pendingTxn = await this.submitSignedBCSTransaction(payload); await this.waitForTransaction(pendingTxn.hash); return pendingTxn.hash; }; this.genSetBaseUri = async (account, uri, module_address) => { const scriptFunctionPayload = new aptos_1.TxnBuilderTypes.TransactionPayloadEntryFunction(aptos_1.TxnBuilderTypes.EntryFunction.natural(`${module_address || this.saleAddress}::sale`, "set_default_domain", [], [ aptos_1.BCS.bcsSerializeStr(uri), ])); const [{ sequence_number: sequenceNumber }, chainId] = await Promise.all([ this.getAccount(account), this.getChainId(), ]); return new aptos_1.TxnBuilderTypes.RawTransaction(aptos_1.TxnBuilderTypes.AccountAddress.fromHex(account), BigInt(sequenceNumber), scriptFunctionPayload, BigInt(20000), BigInt(100), BigInt(Math.floor(Date.now() / 1000) + 10), new aptos_1.TxnBuilderTypes.ChainId(chainId)); }; this.setBaseUri = async (account, uri, module_address) => { const rawTxn = await this.genSetBaseUri(account.address(), uri, module_address); const payload = aptos_1.AptosClient.generateBCSTransaction(account, rawTxn); const pendingTxn = await this.submitSignedBCSTransaction(payload); await this.waitForTransaction(pendingTxn.hash); return pendingTxn.hash; }; this.genProtonInitializePayload = async (account, default_domain, royalty_fee, creating_fee, commission_percent, receiver, min_softcap_percent, min_liquidity_percent, module_address) => { const scriptFunctionPayload = new aptos_1.TxnBuilderTypes.TransactionPayloadEntryFunction(aptos_1.TxnBuilderTypes.EntryFunction.natural(`${module_address || this.saleAddress}::sale`, "proton_initialize", [], [ aptos_1.BCS.bcsSerializeStr(default_domain), aptos_1.BCS.bcsSerializeUint64(royalty_fee), aptos_1.BCS.bcsSerializeUint64(creating_fee), aptos_1.BCS.bcsSerializeU8(commission_percent), aptos_1.BCS.bcsToBytes(aptos_1.TxnBuilderTypes.AccountAddress.fromHex(receiver)), aptos_1.BCS.bcsSerializeU8(min_softcap_percent), aptos_1.BCS.bcsSerializeU8(min_liquidity_percent), ])); const [{ sequence_number: sequenceNumber }, chainId] = await Promise.all([ this.getAccount(account), this.getChainId(), ]); return new aptos_1.TxnBuilderTypes.RawTransaction(aptos_1.TxnBuilderTypes.AccountAddress.fromHex(account), BigInt(sequenceNumber), scriptFunctionPayload, BigInt(20000), BigInt(100), BigInt(Math.floor(Date.now() / 1000) + 10), new aptos_1.TxnBuilderTypes.ChainId(chainId)); }; this.protonInitialize = async (account, default_domain, royalty_fee, creating_fee, commission_percent, receiver, min_softcap_percent, min_liquidity_percent, module_address) => { const rawTxn = await this.genProtonInitializePayload(account.address(), default_domain, royalty_fee, creating_fee, commission_percent, receiver, min_softcap_percent, min_liquidity_percent, module_address); const payload = aptos_1.AptosClient.generateBCSTransaction(account, rawTxn); const pendingTxn = await this.submitSignedBCSTransaction(payload); await this.waitForTransaction(pendingTxn.hash); return pendingTxn.hash; }; this.genSetCreatingFee = async (account, new_creating_fee, module_address) => { const scriptFunctionPayload = new aptos_1.TxnBuilderTypes.TransactionPayloadEntryFunction(aptos_1.TxnBuilderTypes.EntryFunction.natural(`${module_address || this.saleAddress}::global_state`, "set_creating_fee", [], [ aptos_1.BCS.bcsSerializeUint64(BigInt(new_creating_fee)), ])); const [{ sequence_number: sequenceNumber }, chainId] = await Promise.all([ this.getAccount(account), this.getChainId(), ]); return new aptos_1.TxnBuilderTypes.RawTransaction(aptos_1.TxnBuilderTypes.AccountAddress.fromHex(account), BigInt(sequenceNumber), scriptFunctionPayload, BigInt(20000), BigInt(100), BigInt(Math.floor(Date.now() / 1000) + 10), new aptos_1.TxnBuilderTypes.ChainId(chainId)); }; this.setCreatingFee = async (account, new_creating_fee, module_address) => { const rawTxn = await this.genSetCreatingFee(account.address(), new_creating_fee, module_address); const payload = aptos_1.AptosClient.generateBCSTransaction(account, rawTxn); const pendingTxn = await this.submitSignedBCSTransaction(payload); await this.waitForTransaction(pendingTxn.hash); return pendingTxn.hash; }; this.genContributePayload = async (account, saleCoinTypeAddress, purchaseCoinTypeAddress, creator, name, amount, module_address) => { const saleCoin = new aptos_1.TxnBuilderTypes.TypeTagStruct(aptos_1.TxnBuilderTypes.StructTag.fromString(`${saleCoinTypeAddress}`)); const purchaseCoin = new aptos_1.TxnBuilderTypes.TypeTagStruct(aptos_1.TxnBuilderTypes.StructTag.fromString(`${purchaseCoinTypeAddress}`)); const scriptFunctionPayload = new aptos_1.TxnBuilderTypes.TransactionPayloadEntryFunction(aptos_1.TxnBuilderTypes.EntryFunction.natural(`${module_address || this.saleAddress}::sale`, "contribute", [saleCoin, purchaseCoin], [ aptos_1.BCS.bcsToBytes(aptos_1.TxnBuilderTypes.AccountAddress.fromHex(creator)), aptos_1.BCS.bcsSerializeStr(name), aptos_1.BCS.bcsSerializeUint64(+amount), ])); const [{ sequence_number: sequenceNumber }, chainId] = await Promise.all([ this.getAccount(account), this.getChainId(), ]); return new aptos_1.TxnBuilderTypes.RawTransaction(aptos_1.TxnBuilderTypes.AccountAddress.fromHex(account), BigInt(sequenceNumber), scriptFunctionPayload, BigInt(20000), BigInt(100), BigInt(Math.floor(Date.now() / 1000) + 10), new aptos_1.TxnBuilderTypes.ChainId(chainId)); }; this.contribute = async (account, saleCoinTypeAddress, purchaseCoinTypeAddress, creator, name, amount, module_address) => { const rawTxn = await this.genContributePayload(account.address(), saleCoinTypeAddress, purchaseCoinTypeAddress, creator, name, amount, module_address); const payload = aptos_1.AptosClient.generateBCSTransaction(account, rawTxn); const pendingTxn = await this.submitSignedBCSTransaction(payload); await this.waitForTransaction(pendingTxn.hash); return pendingTxn.hash; }; this.genAddWhitelistPayload = async (account, saleCoinTypeAddress, purchaseCoinTypeAddress, creator, name, addresses, module_address) => { const saleCoin = new aptos_1.TxnBuilderTypes.TypeTagStruct(aptos_1.TxnBuilderTypes.StructTag.fromString(`${saleCoinTypeAddress}`)); const purchaseCoin = new aptos_1.TxnBuilderTypes.TypeTagStruct(aptos_1.TxnBuilderTypes.StructTag.fromString(`${purchaseCoinTypeAddress}`)); const array = addresses.map(aptos_1.TxnBuilderTypes.AccountAddress.fromHex); const serializer = new aptos_1.BCS.Serializer(); aptos_1.BCS.serializeVector(array, serializer); const scriptFunctionPayload = new aptos_1.TxnBuilderTypes.TransactionPayloadEntryFunction(aptos_1.TxnBuilderTypes.EntryFunction.natural(`${module_address || this.saleAddress}::sale`, "add_whitelist", [saleCoin, purchaseCoin], [ aptos_1.BCS.bcsSerializeStr(name), aptos_1.BCS.bcsToBytes(aptos_1.TxnBuilderTypes.AccountAddress.fromHex(creator)), serializer.getBytes(), ])); const [{ sequence_number: sequenceNumber }, chainId] = await Promise.all([ this.getAccount(account), this.getChainId(), ]); return new aptos_1.TxnBuilderTypes.RawTransaction(aptos_1.TxnBuilderTypes.AccountAddress.fromHex(account), BigInt(sequenceNumber), scriptFunctionPayload, BigInt(20000), BigInt(100), BigInt(Math.floor(Date.now() / 1000) + 10), new aptos_1.TxnBuilderTypes.ChainId(chainId)); }; this.genAddWhitelistEntryPayload = async (account, saleCoinTypeAddress, purchaseCoinTypeAddress, creator, name, addresses, module_address) => { const saleCoin = new aptos_1.TxnBuilderTypes.TypeTagStruct(aptos_1.TxnBuilderTypes.StructTag.fromString(`${saleCoinTypeAddress}`)); const purchaseCoin = new aptos_1.TxnBuilderTypes.TypeTagStruct(aptos_1.TxnBuilderTypes.StructTag.fromString(`${purchaseCoinTypeAddress}`)); const array = addresses.map(aptos_1.TxnBuilderTypes.AccountAddress.fromHex); // [TxnBuilderTypes.AccountAddress.fromHex(addresses[0]), TxnBuilderTypes.AccountAddress.fromHex(addresses[1])]; const serializer = new aptos_1.BCS.Serializer(); aptos_1.BCS.serializeVector(array, serializer); const entryFunction = aptos_1.TxnBuilderTypes.EntryFunction.natural(`${module_address || this.saleAddress}::sale`, "add_whitelist", [saleCoin, purchaseCoin], [ aptos_1.BCS.bcsSerializeStr(name), aptos_1.BCS.bcsToBytes(aptos_1.TxnBuilderTypes.AccountAddress.fromHex(creator)), serializer.getBytes(), ]); return new aptos_1.TxnBuilderTypes.TransactionPayloadEntryFunction(entryFunction); }; this.addWhitelist = async (account, saleCoinTypeAddress, purchaseCoinTypeAddress, creator, name, addresses, module_address) => { const rawTxn = await this.genAddWhitelistPayload(account.address(), saleCoinTypeAddress, purchaseCoinTypeAddress, creator, name, addresses, module_address); const payload = aptos_1.AptosClient.generateBCSTransaction(account, rawTxn); const pendingTxn = await this.submitSignedBCSTransaction(payload); await this.waitForTransaction(pendingTxn.hash); return pendingTxn.hash; }; this.genPublishCoinPayload = async (coinOwner, tokenName, tokenSym, decimals, moduleName, supply) => { const resp = await axios_1.default.post(`${this.apiEndpointCreateCoin}/coin/v2`, { coinOwner: coinOwner.toString(), tokenName, tokenSym, decimals, moduleName, supply }); const moduleDataStrHex = resp.data.data.h1; const packageMetadataStrHex = resp.data.data.h2; const createdModuleName = resp.data.data.module_name; const serializer = new aptos_1.BCS.Serializer(); const array = [ new aptos_1.TxnBuilderTypes.Module(new aptos_1.HexString(moduleDataStrHex).toUint8Array()), ]; aptos_1.BCS.serializeVector(array, serializer); const scriptFunctionPayload = new aptos_1.TxnBuilderTypes.TransactionPayloadEntryFunction(aptos_1.TxnBuilderTypes.EntryFunction.natural("0x1::code", "publish_package_txn", [], [ aptos_1.BCS.bcsSerializeBytes(new aptos_1.HexString(packageMetadataStrHex).toUint8Array()), serializer.getBytes(), ])); const [{ sequence_number: sequenceNumber }, chainId] = await Promise.all([ this.getAccount(coinOwner), this.getChainId(), ]); return { rawTxs: new aptos_1.TxnBuilderTypes.RawTransaction(aptos_1.TxnBuilderTypes.AccountAddress.fromHex(coinOwner), BigInt(sequenceNumber), scriptFunctionPayload, BigInt(20000), BigInt(1000), BigInt(Math.floor(Date.now() / 1000) + 10), new aptos_1.TxnBuilderTypes.ChainId(chainId)), createdModuleName }; }; this.genPublishCoinEntryPayload = async (coinOwner, tokenName, tokenSym, decimals, moduleName, supply) => { const resp = await axios_1.default.post(`${this.apiEndpointCreateCoin}/coin/v2`, { coinOwner: coinOwner.toString(), tokenName, tokenSym, decimals, moduleName, supply }); const moduleDataStrHex = resp.data.data.h1; const packageMetadataStrHex = resp.data.data.h2; const createdModuleName = resp.data.data.module_name; const serializer = new aptos_1.BCS.Serializer(); const array = [ new aptos_1.TxnBuilderTypes.Module(new aptos_1.HexString(moduleDataStrHex).toUint8Array()), ]; aptos_1.BCS.serializeVector(array, serializer); const entryFunction = aptos_1.TxnBuilderTypes.EntryFunction.natural("0x1::code", "publish_package_txn", [], [ aptos_1.BCS.bcsSerializeBytes(new aptos_1.HexString(packageMetadataStrHex).toUint8Array()), serializer.getBytes(), ]); const txn = new aptos_1.TxnBuilderTypes.TransactionPayloadEntryFunction(entryFunction); return { txn, createdModuleName }; }; this.genPublishCoinNormalPayload = async (coinOwner, tokenName, tokenSym, decimals, moduleName, supply, isCustomCointype) => { const pathUrl = isCustomCointype ? "/coin/v2" : "/coin"; try { const resp = await axios_1.default.post(`${this.apiEndpointCreateCoin}${pathUrl}`, { coinOwner: coinOwner.toString(), tokenName, tokenSym, decimals, moduleName, supply }); return resp.data.data; } catch (error) { return null; } }; this.genCreateCoinPayload = async (coinOwner, moduleName, amount, module_address) => { const token = new aptos_1.TxnBuilderTypes.TypeTagStruct(aptos_1.TxnBuilderTypes.StructTag.fromString(`${coinOwner}::${moduleName}`)); const scriptFunctionPayload = new aptos_1.TxnBuilderTypes.TransactionPayloadEntryFunction(aptos_1.TxnBuilderTypes.EntryFunction.natural(`${module_address || this.saleAddress}::utils`, "create_coin", [token], [aptos_1.BCS.bcsSerializeUint64(amount)])); const [{ sequence_number: sequenceNumber }, chainId] = await Promise.all([ this.getAccount(coinOwner), this.getChainId(), ]); return new aptos_1.TxnBuilderTypes.RawTransaction(aptos_1.TxnBuilderTypes.AccountAddress.fromHex(coinOwner), BigInt(sequenceNumber), scriptFunctionPayload, BigInt(20000), BigInt(100), BigInt(Math.floor(Date.now() / 1000) + 10), new aptos_1.TxnBuilderTypes.ChainId(chainId)); }; this.createCoin = async (coinOwner, moduleName, amount, module_address) => { // eslint-disable-next-line max-len const rawTxn = await this.genCreateCoinPayload(coinOwner.address(), moduleName, amount, module_address); const payload = aptos_1.AptosClient.generateBCSTransaction(coinOwner, rawTxn); const pendingTxn = await this.submitSignedBCSTransaction(payload); await this.waitForTransaction(pendingTxn.hash); return pendingTxn.hash; }; this.publishCoin = async (coinOwner, tokenName, tokenSym, decimals, moduleName, supply) => { // eslint-disable-next-line max-len const rawTxn = await this.genPublishCoinPayload(coinOwner.address(), tokenName, tokenSym, decimals, moduleName, supply); const payload = aptos_1.AptosClient.generateBCSTransaction(coinOwner, rawTxn); const pendingTxn = await this.submitSignedBCSTransaction(payload); await this.waitForTransaction(pendingTxn.hash, { checkSuccess: true }); return pendingTxn.hash; }; this.getAllPresale = async () => { const result = await axios_1.default.get(`${this.apiEndpoint}/sale?page=0&size=200&state=submited`); return result.data.data.map((sale) => ({ sale_start_time: BigInt(sale.sale_start_time), softcap: BigInt(sale.softcap), hardcap: BigInt(sale.hardcap), account_address: sale.account_address, description: sale.description, logo: sale.logo, telegram: sale.telegram, discord: sale.discord, twitter: sale.twitter, website: sale.website, })); }; this.createSaleMetadata = async (signatureResult, publicKey, data) => { const result = await (0, axios_1.default)({ method: "post", baseURL: this.apiEndpoint, url: "/sale", headers: { signature: signatureResult.signature.startsWith("0x") ? signatureResult.signature.substr(2) : signatureResult.signature, message: encodeURI(signatureResult.fullMessage), publicKey: publicKey.startsWith("0x") ? publicKey.substr(2) : publicKey, }, data, }); return result?.data?.data; }; this.getCreateSaleEvents = async () => { const events = await this.getEventsByEventHandle(this.eventAddress, `${this.saleAddress}::sale::ProtonEvent`, "create_sale_events"); return events; }; this.getContributeEvents = async () => { const events = await this.getEventsByEventHandle(this.eventAddress, `${this.saleAddress}::sale::ProtonEvent`, "contribute_events"); return events; }; this.genFinalizePayload = async (account, saleCoinTypeAddress, purchaseCoinTypeAddress, creator, id, dex_type, module_address) => { const saleCoin = new aptos_1.TxnBuilderTypes.TypeTagStruct(aptos_1.TxnBuilderTypes.StructTag.fromString(`${saleCoinTypeAddress}`)); const purchaseCoin = new aptos_1.TxnBuilderTypes.TypeTagStruct(aptos_1.TxnBuilderTypes.StructTag.fromString(`${purchaseCoinTypeAddress}`)); const scriptFunctionPayload = new aptos_1.TxnBuilderTypes.TransactionPayloadEntryFunction(aptos_1.TxnBuilderTypes.EntryFunction.natural(`${module_address || this.saleAddress}::sale`, "finalize_sale", [saleCoin, purchaseCoin], [ aptos_1.BCS.bcsToBytes(aptos_1.TxnBuilderTypes.AccountAddress.fromHex(creator)), aptos_1.BCS.bcsSerializeStr(id), aptos_1.BCS.bcsSerializeU8(dex_type), ])); const [{ sequence_number: sequenceNumber }, chainId] = await Promise.all([ this.getAccount(account), this.getChainId(), ]); return new aptos_1.TxnBuilderTypes.RawTransaction(aptos_1.TxnBuilderTypes.AccountAddress.fromHex(account), BigInt(sequenceNumber), scriptFunctionPayload, BigInt(20000), BigInt(200), BigInt(Math.floor(Date.now() / 1000) + 10), new aptos_1.TxnBuilderTypes.ChainId(chainId)); }; this.finalize = async (account, saleCoinTypeAddress, purchaseCoinTypeAddress, creator, id, dex_type, module_address) => { const rawTxn = await this.genFinalizePayload(account.address(), saleCoinTypeAddress, purchaseCoinTypeAddress, creator, id, dex_type, module_address); const payload = aptos_1.AptosClient.generateBCSTransaction(account, rawTxn); const pe