@allbridge/bridge-core-sdk 3.23.1-alpha.1 → 3.23.1-beta.2
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/browser/index.js +1 -1
- package/dist/browser/index.js.map +3 -3
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +3 -3
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +3 -3
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/services/bridge/sui/index.d.ts +5 -3
- package/dist/src/services/bridge/sui/index.js +52 -18
- package/dist/src/services/bridge/sui/index.js.map +1 -1
- package/dist/src/services/index.d.ts +3 -1
- package/dist/src/services/index.js +2 -0
- package/dist/src/services/index.js.map +1 -1
- package/dist/src/utils/index.d.ts +3 -4
- package/dist/src/utils/index.js +7 -7
- package/dist/src/utils/index.js.map +1 -1
- package/dist/src/utils/sui/index.d.ts +10 -20
- package/dist/src/utils/sui/index.js +11 -44
- package/dist/src/utils/sui/index.js.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/package.json +2 -2
package/dist/src/index.js
CHANGED
|
@@ -51,7 +51,7 @@ class AllbridgeCoreSdk {
|
|
|
51
51
|
this.service = new services_1.AllbridgeCoreSdkService(nodeRpcUrlsConfig, params);
|
|
52
52
|
this.bridge = this.service.bridge;
|
|
53
53
|
this.pool = this.service.pool;
|
|
54
|
-
this.utils = new utils_1.DefaultUtils(
|
|
54
|
+
this.utils = new utils_1.DefaultUtils(this.service);
|
|
55
55
|
this.params = params;
|
|
56
56
|
}
|
|
57
57
|
/**
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAEA,uCAAoC;AACpC,qCAqBkB;AAClB,yCAAwE;AAExE,m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AAM,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;IACzF,CAAC;CACF;AA5gBD,4CA4gBC","sourcesContent":["import { BigSource } from \"big.js\";\nimport { AdditionalBasicChainProperties } from \"./chains/models\";\nimport { mainnet } from \"./configs\";\nimport {\n AmountFormat,\n AmountFormatted,\n AmountsAndGasFeeOptions,\n BridgeService,\n ChainDetailsMap,\n CheckAddressResponse,\n ExtraGasMaxLimitResponse,\n GasBalanceResponse,\n GasFeeOptions,\n GetNativeTokenBalanceParams,\n GetTokenBalanceParams,\n LiquidityPoolService,\n Messenger,\n PendingStatusInfoResponse,\n PoolInfo,\n Provider,\n SendAmountDetails,\n SwapAndBridgeCalculationData,\n TokenWithChainDetails,\n TransferStatusResponse,\n} from \"./models\";\nimport { AllbridgeCoreSdkService, NodeRpcUrlsConfig } from \"./services\";\nimport { CctpParams } from \"./services/bridge/sol\";\nimport { DefaultUtils, Utils } from \"./utils\";\n\nexport * from \"./configs\";\nexport * from \"./models\";\n\nexport interface AllbridgeCoreSdkOptions {\n coreApiUrl: string;\n /**\n * A set of query parameters to be added to all requests to the Core API.\n */\n coreApiQueryParams?: Record<string, string>;\n /**\n * A set of headers to be added to all requests to the Core API.\n */\n coreApiHeaders?: Record<string, string>;\n /**\n * Jupiter Swap Api</br>\n * Default: https://lite-api.jup.ag/swap/v1</br>\n * {@link https://dev.jup.ag/docs/swap-api/}\n */\n jupiterUrl: string;\n /**\n * Jupiter Api Key Header</br>\n * {@link https://dev.jup.ag/docs/api-setup}\n */\n jupiterApiKeyHeader?: string;\n /**\n * Jupiter v6 'maxAccounts' parameter</br>\n * Rough estimate of the max accounts to be used for the quote, so that you can compose with your own accounts</br>\n * {@link https://station.jup.ag/docs/apis/swap-api#using-maxaccounts}\n */\n jupiterMaxAccounts?: number;\n wormholeMessengerProgramId: string;\n solanaLookUpTable: string;\n sorobanNetworkPassphrase: string;\n /**\n * Optional. Will be used in methods</br>\n * {@link LiquidityPoolService.getPoolInfoFromChain} and {@link LiquidityPoolService.getAmountToBeWithdrawn}</br>\n * to fetch information from the blockchain with fewer HTTP requests using JSON-RPC API\n */\n tronJsonRpc?: string;\n cctpParams: CctpParams;\n /**\n * The number of seconds that pool information taken from the chain will be cached.\n *\n * @type {number}\n */\n cachePoolInfoChainSec: number;\n\n /**\n * @internal\n * Optional additional properties to merge with the default properties.\n */\n additionalChainsProperties?: Record<string, AdditionalBasicChainProperties>;\n}\n\n/**\n * Type representing RPC node URLs for different blockchain chains.</br>\n * Provide node RPC URL for chain connection you intend to communicate with</br>\n * - required for SOL, TRX chains</br>\n * - optional for EVM chains -- you can interact by passing a {@link Provider} that will be used to communicate with the chain</br>\n * @typedef {Record<string, string>} NodeRpcUrls\n * @property {string} chainSymbol - The symbol of the chain representing one of the supported blockchain networks (e.g., \"ETH\" for Ethereum). For more details, see: {@link ChainSymbol}.\n * @property {string} rpcUrl - The RPC node URL for the specified chain.\n */\nexport type NodeRpcUrls = Record<string, string>;\n\n/**\n * @deprecated Use {@link NodeRpcUrls}\n */\nexport interface NodeUrlsConfig {\n solanaRpcUrl: string;\n tronRpcUrl: string;\n}\n\n/**\n * @deprecated Use {@link NodeRpcUrls}\n */\nfunction isNodeUrlsConfig(nodeUrls: NodeUrlsConfig | NodeRpcUrls): nodeUrls is NodeUrlsConfig {\n return \"solanaRpcUrl\" in nodeUrls;\n}\n\nexport class AllbridgeCoreSdk {\n readonly params: AllbridgeCoreSdkOptions;\n\n bridge: BridgeService;\n pool: LiquidityPoolService;\n utils: Utils;\n\n private service: AllbridgeCoreSdkService;\n\n /**\n * Initializes the SDK object.\n * @param nodeUrls node rpc urls for full functionality\n * @param params\n * Optional.\n * If not defined, the default {@link mainnet} parameters are used.\n */\n constructor(nodeUrls: NodeUrlsConfig | NodeRpcUrls, params: AllbridgeCoreSdkOptions = mainnet) {\n let nodeRpcUrlsConfig: NodeRpcUrlsConfig;\n if (isNodeUrlsConfig(nodeUrls)) {\n nodeRpcUrlsConfig = new NodeRpcUrlsConfig({ SOL: nodeUrls.solanaRpcUrl, TRX: nodeUrls.tronRpcUrl });\n } else {\n nodeRpcUrlsConfig = new NodeRpcUrlsConfig(nodeUrls);\n }\n this.service = new AllbridgeCoreSdkService(nodeRpcUrlsConfig, params);\n this.bridge = this.service.bridge;\n this.pool = this.service.pool;\n this.utils = new DefaultUtils(nodeRpcUrlsConfig, params);\n this.params = params;\n }\n\n /**\n * Returns {@link ChainDetailsMap} containing a list of supported tokens groped by chain.\n *\n * @param type - A string value which specifies ChainDetailsMap to retrieve.\n * Can be either 'swap' for send or 'pool' for liquidity pools setup.\n * Defaults to 'swap'.\n */\n async chainDetailsMap(type: \"swap\" | \"pool\" = \"swap\"): Promise<ChainDetailsMap> {\n return this.service.chainDetailsMap(type);\n }\n\n /**\n * Returns a list of supported {@link TokenWithChainDetails | tokens}.\n *\n * @param type - A string value which specifies a set of tokens to retrieve.\n * Can be either 'swap' for tokens to send or 'pool' for liquidity pools operations.\n * Defaults to 'swap'.\n * @returns A promise that resolves to an array of {@link TokenWithChainDetails}.\n */\n async tokens(type: \"swap\" | \"pool\" = \"swap\"): Promise<TokenWithChainDetails[]> {\n return this.service.tokens(type);\n }\n\n /**\n * Returns a list of supported {@link TokenWithChainDetails | tokens} on the selected chain.\n * @param chainSymbol - The symbol of the chain representing one of the supported blockchain networks (e.g., \"ETH\" for Ethereum). For more details, see: {@link ChainSymbol}.\n * @param type - A string value which specifies a set of tokens to retrieve.\n * Can be either 'swap' for tokens to send or 'pool' for liquidity pools operations.\n * Defaults to 'swap'.\n */\n async tokensByChain(chainSymbol: string, type: \"swap\" | \"pool\" = \"swap\"): Promise<TokenWithChainDetails[]> {\n return this.service.tokensByChain(chainSymbol, type);\n }\n\n /**\n * Fetches information about tokens transfer by chosen chainSymbol and transaction Id from the Allbridge Core API.\n * @param chainSymbol - The symbol of the chain representing one of the supported blockchain networks (e.g., \"ETH\" for Ethereum). For more details, see: {@link ChainSymbol}.\n * @param txId\n */\n async getTransferStatus(chainSymbol: string, txId: string): Promise<TransferStatusResponse> {\n return this.service.getTransferStatus(chainSymbol, txId);\n }\n\n /**\n * Get gas balance\n * @param chainSymbol - The symbol of the chain representing one of the supported blockchain networks (e.g., \"ETH\" for Ethereum). For more details, see: {@link ChainSymbol}.\n * @param address\n */\n async getGasBalance(chainSymbol: string, address: string): Promise<GasBalanceResponse> {\n return this.service.getGasBalance(chainSymbol, address);\n }\n\n /**\n * Check address and show gas balance\n * @deprecated\n * @param chainSymbol - The symbol of the chain representing one of the supported blockchain networks (e.g., \"ETH\" for Ethereum). For more details, see: {@link ChainSymbol}.\n * @param recipientAddress\n * @param tokenAddress\n */\n async checkAddress(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n chainSymbol: string,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n recipientAddress: string,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n tokenAddress?: string\n ): Promise<CheckAddressResponse> {\n return await this.service.checkAddress();\n }\n\n /**\n * Returns information about pending transactions for the same destination chain and the amount of tokens can be received as a result of transfer considering pending transactions.\n * @param amount the amount of tokens that will be sent\n * @param amountFormat amount format\n * @param sourceToken selected token transfer from\n * @param destToken selected token transfer to\n * @returns range of possible amount based on already pending transactions\n */\n async getPendingStatusInfo(\n amount: string,\n amountFormat: AmountFormat,\n sourceToken: TokenWithChainDetails,\n destToken: TokenWithChainDetails\n ): Promise<PendingStatusInfoResponse> {\n return this.service.getPendingStatusInfo(amount, amountFormat, sourceToken, destToken);\n }\n\n /**\n * Get token balance\n * @param params\n * @param provider\n * @returns Token balance\n */\n async getTokenBalance(params: GetTokenBalanceParams, provider?: Provider): Promise<string> {\n return this.service.getTokenBalance(params, provider);\n }\n\n /**\n * Get native (gas) token balance\n * @param params\n * @param provider\n * @returns Token balance\n */\n async getNativeTokenBalance(params: GetNativeTokenBalanceParams, provider?: Provider): Promise<AmountFormatted> {\n return this.service.getNativeTokenBalance(params, provider);\n }\n\n /**\n * @deprecated\n * Calculates the percentage of fee from the initial amount that is charged when swapping from the selected source chain.\n * (Does not include fee related to the destination chain. Does not include gas fee)\n * @param amountFloat initial amount of tokens to swap\n * @param sourceChainToken selected token on the source chain\n * @returns fee percent\n */\n async calculateFeePercentOnSourceChain(\n amountFloat: BigSource,\n sourceChainToken: TokenWithChainDetails\n ): Promise<number> {\n return this.service.calculateFeePercentOnSourceChain(amountFloat, sourceChainToken);\n }\n\n /**\n * @deprecated\n * Calculates the percentage of fee that is charged when swapping to the selected destination chain. The destination chain fee percent applies to the amount after the source chain fee.\n * (Does not include fee related to the source chain. Does not include gas fee)\n * @see {@link calculateFeePercentOnSourceChain}\n * @param amountFloat initial amount of tokens to swap\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @returns fee percent\n */\n async calculateFeePercentOnDestinationChain(\n amountFloat: BigSource,\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails\n ): Promise<number> {\n return this.service.calculateFeePercentOnDestinationChain(amountFloat, sourceChainToken, destinationChainToken);\n }\n\n /**\n * Calculates the amount of tokens to be received as a result of transfer\n * and fetches {@link GasFeeOptions} which contains available ways to pay the gas fee.\n * @param amountToSendFloat the amount of tokens that will be sent\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @param messenger\n */\n async getAmountToBeReceivedAndGasFeeOptions(\n amountToSendFloat: BigSource,\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n messenger: Messenger\n ): Promise<AmountsAndGasFeeOptions> {\n return this.service.getAmountToBeReceivedAndGasFeeOptions(\n amountToSendFloat,\n sourceChainToken,\n destinationChainToken,\n messenger\n );\n }\n\n /**\n * Calculates the amount of tokens to send based on requested tokens amount be received as a result of transfer.\n * and fetches {@link GasFeeOptions} which contains available ways to pay the gas fee.\n * @param amountToBeReceivedFloat the amount of tokens that should be received\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @param messenger\n */\n async getAmountToSendAndGasFeeOptions(\n amountToBeReceivedFloat: BigSource,\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n messenger: Messenger\n ): Promise<AmountsAndGasFeeOptions> {\n return this.service.getAmountToSendAndGasFeeOptions(\n amountToBeReceivedFloat,\n sourceChainToken,\n destinationChainToken,\n messenger\n );\n }\n\n /**\n * Calculates the amount of tokens to be received as a result of transfer.\n * @param amountToSendFloat the amount of tokens that will be sent\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @param messenger selected messenger\n */\n async getAmountToBeReceived(\n amountToSendFloat: BigSource,\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n /**\n * The Messengers for different routes.\n */\n messenger: Messenger = Messenger.ALLBRIDGE\n ): Promise<string> {\n return this.service.getAmountToBeReceived(amountToSendFloat, sourceChainToken, destinationChainToken, messenger);\n }\n\n /**\n * Calculates the amount of tokens to be received as a result of transfer based on actual blockchain pool state.\n * @param amountToSendFloat the amount of tokens that will be sent\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @param messenger selected messenger\n * @param sourceProvider Optional. source chain Provider\n * @param destinationProvider Optional. destination chain Provider\n */\n async getAmountToBeReceivedFromChain(\n amountToSendFloat: BigSource,\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n /**\n * The Messengers for different routes.\n */\n messenger: Messenger = Messenger.ALLBRIDGE,\n sourceProvider?: Provider,\n destinationProvider?: Provider\n ): Promise<string> {\n return this.service.getAmountToBeReceivedFromChain(\n amountToSendFloat,\n sourceChainToken,\n destinationChainToken,\n messenger,\n sourceProvider,\n destinationProvider\n );\n }\n\n /**\n * Calculates the amount of tokens to be received as a result of transfer based on passed pool state.\n * @param amountToSendFloat the amount of tokens that will be sent\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @param sourcePool source token pool state\n * @param destinationPool destination token pool state\n * @param messenger selected messenger\n */\n getAmountToBeReceivedFromPools(\n amountToSendFloat: BigSource,\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n sourcePool: PoolInfo,\n destinationPool: PoolInfo,\n messenger: Exclude<Messenger, Messenger.OFT> = Messenger.ALLBRIDGE\n ): string {\n switch (messenger) {\n case Messenger.ALLBRIDGE:\n case Messenger.WORMHOLE:\n return this.service.getAmountToBeReceivedComputeWithPools(\n amountToSendFloat,\n sourceChainToken,\n destinationChainToken,\n sourcePool,\n destinationPool\n );\n case Messenger.CCTP:\n case Messenger.CCTP_V2:\n return this.service.getAmountToBeReceivedComputeCctp(\n amountToSendFloat,\n sourceChainToken,\n destinationChainToken,\n messenger\n );\n }\n }\n\n /**\n * Calculates the amount of tokens to send based on requested tokens amount be received as a result of transfer.\n * @param amountToBeReceivedFloat the amount of tokens that should be received\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @param messenger selected messenger\n */\n async getAmountToSend(\n amountToBeReceivedFloat: BigSource,\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n /**\n * The Messengers for different routes.\n */\n messenger: Messenger = Messenger.ALLBRIDGE\n ): Promise<string> {\n return this.service.getAmountToSend(amountToBeReceivedFloat, sourceChainToken, destinationChainToken, messenger);\n }\n\n /**\n * Calculates the amount of tokens to send based on requested tokens amount be received as a result of transfer based on actual blockchain pool state.\n * @param amountToBeReceivedFloat the amount of tokens that should be received\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @param messenger selected messenger\n * @param sourceProvider Optional. source chain Provider\n * @param destinationProvider Optional. destination chain Provider\n */\n async getAmountToSendFromChain(\n amountToBeReceivedFloat: BigSource,\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n /**\n * The Messengers for different routes.\n */\n messenger: Messenger = Messenger.ALLBRIDGE,\n sourceProvider?: Provider,\n destinationProvider?: Provider\n ): Promise<string> {\n return this.service.getAmountToSendFromChain(\n amountToBeReceivedFloat,\n sourceChainToken,\n destinationChainToken,\n messenger,\n sourceProvider,\n destinationProvider\n );\n }\n\n /**\n * Calculates the amount of tokens to send based on requested tokens amount be received as a result of transfer based on passed pool state.\n * @param amountToBeReceivedFloat the amount of tokens that should be received\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @param sourcePool source token pool state\n * @param destinationPool destination token pool state\n * @param messenger selected messenger\n */\n getAmountToSendFromPools(\n amountToBeReceivedFloat: BigSource,\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n sourcePool: PoolInfo,\n destinationPool: PoolInfo,\n messenger: Exclude<Messenger, Messenger.OFT> = Messenger.ALLBRIDGE\n ): string {\n switch (messenger) {\n case Messenger.ALLBRIDGE:\n case Messenger.WORMHOLE:\n return this.service.getAmountToSendComputeWithPools(\n amountToBeReceivedFloat,\n sourceChainToken,\n destinationChainToken,\n sourcePool,\n destinationPool\n );\n case Messenger.CCTP:\n case Messenger.CCTP_V2:\n return this.service.getAmountToSendComputeCctp(\n amountToBeReceivedFloat,\n sourceChainToken,\n destinationChainToken,\n messenger\n );\n }\n }\n\n /**\n * Fetches possible ways to pay the transfer gas fee.\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @param messenger\n * @returns {@link GasFeeOptions}\n */\n async getGasFeeOptions(\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n messenger: Messenger\n ): Promise<GasFeeOptions> {\n return this.service.getGasFeeOptions(sourceChainToken, destinationChainToken, messenger);\n }\n\n /**\n * Gets the average time in ms to complete a transfer for given tokens and messenger.\n * @param sourceChainToken selected token on the source chain.\n * @param destinationChainToken selected token on the destination chain.\n * @param messenger\n * @returns Average transfer time in milliseconds or null if a given combination of tokens and messenger is not supported.\n */\n getAverageTransferTime(\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n messenger: Messenger\n ): number | null {\n return this.service.getAverageTransferTime(sourceChainToken, destinationChainToken, messenger);\n }\n\n /**\n * Gets information about the poolInfo by token\n * @param token\n * @returns poolInfo\n */\n async getPoolInfoByToken(token: TokenWithChainDetails): Promise<PoolInfo> {\n return this.service.getPoolInfoByToken(token);\n }\n\n /**\n * Forces refresh of cached information about the state of liquidity pools.\n * Outdated cache leads to calculated amounts being less accurate.\n * The cache is invalidated at regular intervals, but it can be forced to be refreshed by calling this method.+\n *\n * @param tokens if present, the corresponding liquidity pools will be updated\n */\n async refreshPoolInfo(tokens?: TokenWithChainDetails | TokenWithChainDetails[]): Promise<void> {\n return this.service.refreshPoolInfo(tokens);\n }\n\n /**\n * Convert APR to percentage view\n * @param apr\n * @returns aprPercentageView\n */\n aprInPercents(apr: string): string {\n return this.service.aprInPercents(apr);\n }\n\n /**\n * Get possible limit of extra gas amount.\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @param messenger selected Messenger, Allbridge by default\n * @returns {@link ExtraGasMaxLimitResponse}\n */\n async getExtraGasMaxLimits(\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n messenger: Messenger = Messenger.ALLBRIDGE\n ): Promise<ExtraGasMaxLimitResponse> {\n return this.service.getExtraGasMaxLimits(sourceChainToken, destinationChainToken, messenger);\n }\n\n /**\n * @param amount - amount\n * @param amountFormat - AmountFormat\n * @param sourceToken - selected token on the source chain\n * @return virtual amount\n */\n async getVUsdFromAmount(\n amount: string,\n amountFormat: AmountFormat,\n sourceToken: TokenWithChainDetails\n ): Promise<AmountFormatted> {\n return this.service.getVUsdFromAmount(amount, amountFormat, sourceToken);\n }\n\n /**\n * @param vUsdAmount - amount of vUsd, int format\n * @param destToken selected token on the destination chain\n * @return amount of destToken\n */\n async getAmountFromVUsd(vUsdAmount: string, destToken: TokenWithChainDetails): Promise<AmountFormatted> {\n return this.service.getAmountFromVUsd(vUsdAmount, destToken);\n }\n\n /**\n * @deprecated Use {@link getSendAmountDetails}\n * @param amountInTokenPrecision\n * @param sourceToken\n * @param destToken\n */\n async swapAndBridgeFeeCalculation(\n amountInTokenPrecision: string,\n sourceToken: TokenWithChainDetails,\n destToken: TokenWithChainDetails\n ): Promise<SwapAndBridgeCalculationData> {\n return this.service.swapAndBridgeFeeCalculation(amountInTokenPrecision, sourceToken, destToken);\n }\n\n /**\n * @deprecated Use {@link getAmountToBeReceived} and then {@link getSendAmountDetails}\n * @param amountInTokenPrecision\n * @param sourceToken\n * @param destToken\n */\n async swapAndBridgeFeeCalculationReverse(\n amountInTokenPrecision: string,\n sourceToken: TokenWithChainDetails,\n destToken: TokenWithChainDetails\n ): Promise<SwapAndBridgeCalculationData> {\n return this.service.swapAndBridgeFeeCalculationReverse(amountInTokenPrecision, sourceToken, destToken);\n }\n\n /**\n * Show amount changes (fee and amount adjustment) during send through pools on source and destination chains\n */\n async getSendAmountDetails(\n amount: string,\n amountFormat: AmountFormat,\n sourceToken: TokenWithChainDetails,\n destToken: TokenWithChainDetails\n ): Promise<SendAmountDetails> {\n return this.service.getSendAmountDetails(amount, amountFormat, sourceToken, destToken);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAEA,uCAAoC;AACpC,qCAqBkB;AAClB,yCAAwE;AAExE,mCAA8C;AAE9C,4CAA0B;AAC1B,2CAAyB;AAwEzB;;GAEG;AACH,SAAS,gBAAgB,CAAC,QAAsC;IAC9D,OAAO,cAAc,IAAI,QAAQ,CAAC;AACpC,CAAC;AAED,MAAa,gBAAgB;IAClB,MAAM,CAA0B;IAEzC,MAAM,CAAgB;IACtB,IAAI,CAAuB;IAC3B,KAAK,CAAQ;IAEL,OAAO,CAA0B;IAEzC;;;;;;OAMG;IACH,YAAY,QAAsC,EAAE,SAAkC,iBAAO;QAC3F,IAAI,iBAAoC,CAAC;QACzC,IAAI,gBAAgB,CAA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;;;OAKG;IACH,KAAK,CAAC,iBAAiB,CACrB,MAAc,EACd,YAA0B,EAC1B,WAAkC;QAElC,OAAO,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,MAAM,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC;IAC3E,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,iBAAiB,CAAC,UAAkB,EAAE,SAAgC;QAC1E,OAAO,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;IAC/D,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,2BAA2B,CAC/B,sBAA8B,EAC9B,WAAkC,EAClC,SAAgC;QAEhC,OAAO,IAAI,CAAC,OAAO,CAAC,2BAA2B,CAAC,sBAAsB,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;IAClG,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,kCAAkC,CACtC,sBAA8B,EAC9B,WAAkC,EAClC,SAAgC;QAEhC,OAAO,IAAI,CAAC,OAAO,CAAC,kCAAkC,CAAC,sBAAsB,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;IACzG,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,oBAAoB,CACxB,MAAc,EACd,YAA0B,EAC1B,WAAkC,EAClC,SAAgC;QAEhC,OAAO,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;IACzF,CAAC;CACF;AA5gBD,4CA4gBC","sourcesContent":["import { BigSource } from \"big.js\";\nimport { AdditionalBasicChainProperties } from \"./chains/models\";\nimport { mainnet } from \"./configs\";\nimport {\n AmountFormat,\n AmountFormatted,\n AmountsAndGasFeeOptions,\n BridgeService,\n ChainDetailsMap,\n CheckAddressResponse,\n ExtraGasMaxLimitResponse,\n GasBalanceResponse,\n GasFeeOptions,\n GetNativeTokenBalanceParams,\n GetTokenBalanceParams,\n LiquidityPoolService,\n Messenger,\n PendingStatusInfoResponse,\n PoolInfo,\n Provider,\n SendAmountDetails,\n SwapAndBridgeCalculationData,\n TokenWithChainDetails,\n TransferStatusResponse,\n} from \"./models\";\nimport { AllbridgeCoreSdkService, NodeRpcUrlsConfig } from \"./services\";\nimport { CctpParams } from \"./services/bridge/sol\";\nimport { DefaultUtils, Utils } from \"./utils\";\n\nexport * from \"./configs\";\nexport * from \"./models\";\n\nexport interface AllbridgeCoreSdkOptions {\n coreApiUrl: string;\n /**\n * A set of query parameters to be added to all requests to the Core API.\n */\n coreApiQueryParams?: Record<string, string>;\n /**\n * A set of headers to be added to all requests to the Core API.\n */\n coreApiHeaders?: Record<string, string>;\n /**\n * Jupiter Swap Api</br>\n * Default: https://lite-api.jup.ag/swap/v1</br>\n * {@link https://dev.jup.ag/docs/swap-api/}\n */\n jupiterUrl: string;\n /**\n * Jupiter Api Key Header</br>\n * {@link https://dev.jup.ag/docs/api-setup}\n */\n jupiterApiKeyHeader?: string;\n /**\n * Jupiter v6 'maxAccounts' parameter</br>\n * Rough estimate of the max accounts to be used for the quote, so that you can compose with your own accounts</br>\n * {@link https://station.jup.ag/docs/apis/swap-api#using-maxaccounts}\n */\n jupiterMaxAccounts?: number;\n wormholeMessengerProgramId: string;\n solanaLookUpTable: string;\n sorobanNetworkPassphrase: string;\n /**\n * Optional. Will be used in methods</br>\n * {@link LiquidityPoolService.getPoolInfoFromChain} and {@link LiquidityPoolService.getAmountToBeWithdrawn}</br>\n * to fetch information from the blockchain with fewer HTTP requests using JSON-RPC API\n */\n tronJsonRpc?: string;\n cctpParams: CctpParams;\n /**\n * The number of seconds that pool information taken from the chain will be cached.\n *\n * @type {number}\n */\n cachePoolInfoChainSec: number;\n\n /**\n * @internal\n * Optional additional properties to merge with the default properties.\n */\n additionalChainsProperties?: Record<string, AdditionalBasicChainProperties>;\n}\n\n/**\n * Type representing RPC node URLs for different blockchain chains.</br>\n * Provide node RPC URL for chain connection you intend to communicate with</br>\n * - required for SOL, TRX chains</br>\n * - optional for EVM chains -- you can interact by passing a {@link Provider} that will be used to communicate with the chain</br>\n * @typedef {Record<string, string>} NodeRpcUrls\n * @property {string} chainSymbol - The symbol of the chain representing one of the supported blockchain networks (e.g., \"ETH\" for Ethereum). For more details, see: {@link ChainSymbol}.\n * @property {string} rpcUrl - The RPC node URL for the specified chain.\n */\nexport type NodeRpcUrls = Record<string, string>;\n\n/**\n * @deprecated Use {@link NodeRpcUrls}\n */\nexport interface NodeUrlsConfig {\n solanaRpcUrl: string;\n tronRpcUrl: string;\n}\n\n/**\n * @deprecated Use {@link NodeRpcUrls}\n */\nfunction isNodeUrlsConfig(nodeUrls: NodeUrlsConfig | NodeRpcUrls): nodeUrls is NodeUrlsConfig {\n return \"solanaRpcUrl\" in nodeUrls;\n}\n\nexport class AllbridgeCoreSdk {\n readonly params: AllbridgeCoreSdkOptions;\n\n bridge: BridgeService;\n pool: LiquidityPoolService;\n utils: Utils;\n\n private service: AllbridgeCoreSdkService;\n\n /**\n * Initializes the SDK object.\n * @param nodeUrls node rpc urls for full functionality\n * @param params\n * Optional.\n * If not defined, the default {@link mainnet} parameters are used.\n */\n constructor(nodeUrls: NodeUrlsConfig | NodeRpcUrls, params: AllbridgeCoreSdkOptions = mainnet) {\n let nodeRpcUrlsConfig: NodeRpcUrlsConfig;\n if (isNodeUrlsConfig(nodeUrls)) {\n nodeRpcUrlsConfig = new NodeRpcUrlsConfig({ SOL: nodeUrls.solanaRpcUrl, TRX: nodeUrls.tronRpcUrl });\n } else {\n nodeRpcUrlsConfig = new NodeRpcUrlsConfig(nodeUrls);\n }\n this.service = new AllbridgeCoreSdkService(nodeRpcUrlsConfig, params);\n this.bridge = this.service.bridge;\n this.pool = this.service.pool;\n this.utils = new DefaultUtils(this.service);\n this.params = params;\n }\n\n /**\n * Returns {@link ChainDetailsMap} containing a list of supported tokens groped by chain.\n *\n * @param type - A string value which specifies ChainDetailsMap to retrieve.\n * Can be either 'swap' for send or 'pool' for liquidity pools setup.\n * Defaults to 'swap'.\n */\n async chainDetailsMap(type: \"swap\" | \"pool\" = \"swap\"): Promise<ChainDetailsMap> {\n return this.service.chainDetailsMap(type);\n }\n\n /**\n * Returns a list of supported {@link TokenWithChainDetails | tokens}.\n *\n * @param type - A string value which specifies a set of tokens to retrieve.\n * Can be either 'swap' for tokens to send or 'pool' for liquidity pools operations.\n * Defaults to 'swap'.\n * @returns A promise that resolves to an array of {@link TokenWithChainDetails}.\n */\n async tokens(type: \"swap\" | \"pool\" = \"swap\"): Promise<TokenWithChainDetails[]> {\n return this.service.tokens(type);\n }\n\n /**\n * Returns a list of supported {@link TokenWithChainDetails | tokens} on the selected chain.\n * @param chainSymbol - The symbol of the chain representing one of the supported blockchain networks (e.g., \"ETH\" for Ethereum). For more details, see: {@link ChainSymbol}.\n * @param type - A string value which specifies a set of tokens to retrieve.\n * Can be either 'swap' for tokens to send or 'pool' for liquidity pools operations.\n * Defaults to 'swap'.\n */\n async tokensByChain(chainSymbol: string, type: \"swap\" | \"pool\" = \"swap\"): Promise<TokenWithChainDetails[]> {\n return this.service.tokensByChain(chainSymbol, type);\n }\n\n /**\n * Fetches information about tokens transfer by chosen chainSymbol and transaction Id from the Allbridge Core API.\n * @param chainSymbol - The symbol of the chain representing one of the supported blockchain networks (e.g., \"ETH\" for Ethereum). For more details, see: {@link ChainSymbol}.\n * @param txId\n */\n async getTransferStatus(chainSymbol: string, txId: string): Promise<TransferStatusResponse> {\n return this.service.getTransferStatus(chainSymbol, txId);\n }\n\n /**\n * Get gas balance\n * @param chainSymbol - The symbol of the chain representing one of the supported blockchain networks (e.g., \"ETH\" for Ethereum). For more details, see: {@link ChainSymbol}.\n * @param address\n */\n async getGasBalance(chainSymbol: string, address: string): Promise<GasBalanceResponse> {\n return this.service.getGasBalance(chainSymbol, address);\n }\n\n /**\n * Check address and show gas balance\n * @deprecated\n * @param chainSymbol - The symbol of the chain representing one of the supported blockchain networks (e.g., \"ETH\" for Ethereum). For more details, see: {@link ChainSymbol}.\n * @param recipientAddress\n * @param tokenAddress\n */\n async checkAddress(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n chainSymbol: string,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n recipientAddress: string,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n tokenAddress?: string\n ): Promise<CheckAddressResponse> {\n return await this.service.checkAddress();\n }\n\n /**\n * Returns information about pending transactions for the same destination chain and the amount of tokens can be received as a result of transfer considering pending transactions.\n * @param amount the amount of tokens that will be sent\n * @param amountFormat amount format\n * @param sourceToken selected token transfer from\n * @param destToken selected token transfer to\n * @returns range of possible amount based on already pending transactions\n */\n async getPendingStatusInfo(\n amount: string,\n amountFormat: AmountFormat,\n sourceToken: TokenWithChainDetails,\n destToken: TokenWithChainDetails\n ): Promise<PendingStatusInfoResponse> {\n return this.service.getPendingStatusInfo(amount, amountFormat, sourceToken, destToken);\n }\n\n /**\n * Get token balance\n * @param params\n * @param provider\n * @returns Token balance\n */\n async getTokenBalance(params: GetTokenBalanceParams, provider?: Provider): Promise<string> {\n return this.service.getTokenBalance(params, provider);\n }\n\n /**\n * Get native (gas) token balance\n * @param params\n * @param provider\n * @returns Token balance\n */\n async getNativeTokenBalance(params: GetNativeTokenBalanceParams, provider?: Provider): Promise<AmountFormatted> {\n return this.service.getNativeTokenBalance(params, provider);\n }\n\n /**\n * @deprecated\n * Calculates the percentage of fee from the initial amount that is charged when swapping from the selected source chain.\n * (Does not include fee related to the destination chain. Does not include gas fee)\n * @param amountFloat initial amount of tokens to swap\n * @param sourceChainToken selected token on the source chain\n * @returns fee percent\n */\n async calculateFeePercentOnSourceChain(\n amountFloat: BigSource,\n sourceChainToken: TokenWithChainDetails\n ): Promise<number> {\n return this.service.calculateFeePercentOnSourceChain(amountFloat, sourceChainToken);\n }\n\n /**\n * @deprecated\n * Calculates the percentage of fee that is charged when swapping to the selected destination chain. The destination chain fee percent applies to the amount after the source chain fee.\n * (Does not include fee related to the source chain. Does not include gas fee)\n * @see {@link calculateFeePercentOnSourceChain}\n * @param amountFloat initial amount of tokens to swap\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @returns fee percent\n */\n async calculateFeePercentOnDestinationChain(\n amountFloat: BigSource,\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails\n ): Promise<number> {\n return this.service.calculateFeePercentOnDestinationChain(amountFloat, sourceChainToken, destinationChainToken);\n }\n\n /**\n * Calculates the amount of tokens to be received as a result of transfer\n * and fetches {@link GasFeeOptions} which contains available ways to pay the gas fee.\n * @param amountToSendFloat the amount of tokens that will be sent\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @param messenger\n */\n async getAmountToBeReceivedAndGasFeeOptions(\n amountToSendFloat: BigSource,\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n messenger: Messenger\n ): Promise<AmountsAndGasFeeOptions> {\n return this.service.getAmountToBeReceivedAndGasFeeOptions(\n amountToSendFloat,\n sourceChainToken,\n destinationChainToken,\n messenger\n );\n }\n\n /**\n * Calculates the amount of tokens to send based on requested tokens amount be received as a result of transfer.\n * and fetches {@link GasFeeOptions} which contains available ways to pay the gas fee.\n * @param amountToBeReceivedFloat the amount of tokens that should be received\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @param messenger\n */\n async getAmountToSendAndGasFeeOptions(\n amountToBeReceivedFloat: BigSource,\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n messenger: Messenger\n ): Promise<AmountsAndGasFeeOptions> {\n return this.service.getAmountToSendAndGasFeeOptions(\n amountToBeReceivedFloat,\n sourceChainToken,\n destinationChainToken,\n messenger\n );\n }\n\n /**\n * Calculates the amount of tokens to be received as a result of transfer.\n * @param amountToSendFloat the amount of tokens that will be sent\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @param messenger selected messenger\n */\n async getAmountToBeReceived(\n amountToSendFloat: BigSource,\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n /**\n * The Messengers for different routes.\n */\n messenger: Messenger = Messenger.ALLBRIDGE\n ): Promise<string> {\n return this.service.getAmountToBeReceived(amountToSendFloat, sourceChainToken, destinationChainToken, messenger);\n }\n\n /**\n * Calculates the amount of tokens to be received as a result of transfer based on actual blockchain pool state.\n * @param amountToSendFloat the amount of tokens that will be sent\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @param messenger selected messenger\n * @param sourceProvider Optional. source chain Provider\n * @param destinationProvider Optional. destination chain Provider\n */\n async getAmountToBeReceivedFromChain(\n amountToSendFloat: BigSource,\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n /**\n * The Messengers for different routes.\n */\n messenger: Messenger = Messenger.ALLBRIDGE,\n sourceProvider?: Provider,\n destinationProvider?: Provider\n ): Promise<string> {\n return this.service.getAmountToBeReceivedFromChain(\n amountToSendFloat,\n sourceChainToken,\n destinationChainToken,\n messenger,\n sourceProvider,\n destinationProvider\n );\n }\n\n /**\n * Calculates the amount of tokens to be received as a result of transfer based on passed pool state.\n * @param amountToSendFloat the amount of tokens that will be sent\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @param sourcePool source token pool state\n * @param destinationPool destination token pool state\n * @param messenger selected messenger\n */\n getAmountToBeReceivedFromPools(\n amountToSendFloat: BigSource,\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n sourcePool: PoolInfo,\n destinationPool: PoolInfo,\n messenger: Exclude<Messenger, Messenger.OFT> = Messenger.ALLBRIDGE\n ): string {\n switch (messenger) {\n case Messenger.ALLBRIDGE:\n case Messenger.WORMHOLE:\n return this.service.getAmountToBeReceivedComputeWithPools(\n amountToSendFloat,\n sourceChainToken,\n destinationChainToken,\n sourcePool,\n destinationPool\n );\n case Messenger.CCTP:\n case Messenger.CCTP_V2:\n return this.service.getAmountToBeReceivedComputeCctp(\n amountToSendFloat,\n sourceChainToken,\n destinationChainToken,\n messenger\n );\n }\n }\n\n /**\n * Calculates the amount of tokens to send based on requested tokens amount be received as a result of transfer.\n * @param amountToBeReceivedFloat the amount of tokens that should be received\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @param messenger selected messenger\n */\n async getAmountToSend(\n amountToBeReceivedFloat: BigSource,\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n /**\n * The Messengers for different routes.\n */\n messenger: Messenger = Messenger.ALLBRIDGE\n ): Promise<string> {\n return this.service.getAmountToSend(amountToBeReceivedFloat, sourceChainToken, destinationChainToken, messenger);\n }\n\n /**\n * Calculates the amount of tokens to send based on requested tokens amount be received as a result of transfer based on actual blockchain pool state.\n * @param amountToBeReceivedFloat the amount of tokens that should be received\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @param messenger selected messenger\n * @param sourceProvider Optional. source chain Provider\n * @param destinationProvider Optional. destination chain Provider\n */\n async getAmountToSendFromChain(\n amountToBeReceivedFloat: BigSource,\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n /**\n * The Messengers for different routes.\n */\n messenger: Messenger = Messenger.ALLBRIDGE,\n sourceProvider?: Provider,\n destinationProvider?: Provider\n ): Promise<string> {\n return this.service.getAmountToSendFromChain(\n amountToBeReceivedFloat,\n sourceChainToken,\n destinationChainToken,\n messenger,\n sourceProvider,\n destinationProvider\n );\n }\n\n /**\n * Calculates the amount of tokens to send based on requested tokens amount be received as a result of transfer based on passed pool state.\n * @param amountToBeReceivedFloat the amount of tokens that should be received\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @param sourcePool source token pool state\n * @param destinationPool destination token pool state\n * @param messenger selected messenger\n */\n getAmountToSendFromPools(\n amountToBeReceivedFloat: BigSource,\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n sourcePool: PoolInfo,\n destinationPool: PoolInfo,\n messenger: Exclude<Messenger, Messenger.OFT> = Messenger.ALLBRIDGE\n ): string {\n switch (messenger) {\n case Messenger.ALLBRIDGE:\n case Messenger.WORMHOLE:\n return this.service.getAmountToSendComputeWithPools(\n amountToBeReceivedFloat,\n sourceChainToken,\n destinationChainToken,\n sourcePool,\n destinationPool\n );\n case Messenger.CCTP:\n case Messenger.CCTP_V2:\n return this.service.getAmountToSendComputeCctp(\n amountToBeReceivedFloat,\n sourceChainToken,\n destinationChainToken,\n messenger\n );\n }\n }\n\n /**\n * Fetches possible ways to pay the transfer gas fee.\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @param messenger\n * @returns {@link GasFeeOptions}\n */\n async getGasFeeOptions(\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n messenger: Messenger\n ): Promise<GasFeeOptions> {\n return this.service.getGasFeeOptions(sourceChainToken, destinationChainToken, messenger);\n }\n\n /**\n * Gets the average time in ms to complete a transfer for given tokens and messenger.\n * @param sourceChainToken selected token on the source chain.\n * @param destinationChainToken selected token on the destination chain.\n * @param messenger\n * @returns Average transfer time in milliseconds or null if a given combination of tokens and messenger is not supported.\n */\n getAverageTransferTime(\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n messenger: Messenger\n ): number | null {\n return this.service.getAverageTransferTime(sourceChainToken, destinationChainToken, messenger);\n }\n\n /**\n * Gets information about the poolInfo by token\n * @param token\n * @returns poolInfo\n */\n async getPoolInfoByToken(token: TokenWithChainDetails): Promise<PoolInfo> {\n return this.service.getPoolInfoByToken(token);\n }\n\n /**\n * Forces refresh of cached information about the state of liquidity pools.\n * Outdated cache leads to calculated amounts being less accurate.\n * The cache is invalidated at regular intervals, but it can be forced to be refreshed by calling this method.+\n *\n * @param tokens if present, the corresponding liquidity pools will be updated\n */\n async refreshPoolInfo(tokens?: TokenWithChainDetails | TokenWithChainDetails[]): Promise<void> {\n return this.service.refreshPoolInfo(tokens);\n }\n\n /**\n * Convert APR to percentage view\n * @param apr\n * @returns aprPercentageView\n */\n aprInPercents(apr: string): string {\n return this.service.aprInPercents(apr);\n }\n\n /**\n * Get possible limit of extra gas amount.\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @param messenger selected Messenger, Allbridge by default\n * @returns {@link ExtraGasMaxLimitResponse}\n */\n async getExtraGasMaxLimits(\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n messenger: Messenger = Messenger.ALLBRIDGE\n ): Promise<ExtraGasMaxLimitResponse> {\n return this.service.getExtraGasMaxLimits(sourceChainToken, destinationChainToken, messenger);\n }\n\n /**\n * @param amount - amount\n * @param amountFormat - AmountFormat\n * @param sourceToken - selected token on the source chain\n * @return virtual amount\n */\n async getVUsdFromAmount(\n amount: string,\n amountFormat: AmountFormat,\n sourceToken: TokenWithChainDetails\n ): Promise<AmountFormatted> {\n return this.service.getVUsdFromAmount(amount, amountFormat, sourceToken);\n }\n\n /**\n * @param vUsdAmount - amount of vUsd, int format\n * @param destToken selected token on the destination chain\n * @return amount of destToken\n */\n async getAmountFromVUsd(vUsdAmount: string, destToken: TokenWithChainDetails): Promise<AmountFormatted> {\n return this.service.getAmountFromVUsd(vUsdAmount, destToken);\n }\n\n /**\n * @deprecated Use {@link getSendAmountDetails}\n * @param amountInTokenPrecision\n * @param sourceToken\n * @param destToken\n */\n async swapAndBridgeFeeCalculation(\n amountInTokenPrecision: string,\n sourceToken: TokenWithChainDetails,\n destToken: TokenWithChainDetails\n ): Promise<SwapAndBridgeCalculationData> {\n return this.service.swapAndBridgeFeeCalculation(amountInTokenPrecision, sourceToken, destToken);\n }\n\n /**\n * @deprecated Use {@link getAmountToBeReceived} and then {@link getSendAmountDetails}\n * @param amountInTokenPrecision\n * @param sourceToken\n * @param destToken\n */\n async swapAndBridgeFeeCalculationReverse(\n amountInTokenPrecision: string,\n sourceToken: TokenWithChainDetails,\n destToken: TokenWithChainDetails\n ): Promise<SwapAndBridgeCalculationData> {\n return this.service.swapAndBridgeFeeCalculationReverse(amountInTokenPrecision, sourceToken, destToken);\n }\n\n /**\n * Show amount changes (fee and amount adjustment) during send through pools on source and destination chains\n */\n async getSendAmountDetails(\n amount: string,\n amountFormat: AmountFormat,\n sourceToken: TokenWithChainDetails,\n destToken: TokenWithChainDetails\n ): Promise<SendAmountDetails> {\n return this.service.getSendAmountDetails(amount, amountFormat, sourceToken, destToken);\n }\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { Transaction, TransactionResult } from "@mysten/sui/transactions";
|
|
1
2
|
import { AllbridgeCoreClient } from "../../../client/core-api/core-client-base";
|
|
2
3
|
import { ChainSymbol, ChainType, RawSuiTransaction, SwapParams, TransactionResponse } from "../../../models";
|
|
3
|
-
import { SuiAddresses } from "../../../tokens-info";
|
|
4
4
|
import { NodeRpcUrlsConfig } from "../../index";
|
|
5
|
-
import { ChainBridgeService, SendParams
|
|
5
|
+
import { ChainBridgeService, SendParams } from "../models";
|
|
6
6
|
export declare class SuiBridgeService extends ChainBridgeService {
|
|
7
7
|
private nodeRpcUrlsConfig;
|
|
8
8
|
api: AllbridgeCoreClient;
|
|
@@ -12,8 +12,10 @@ export declare class SuiBridgeService extends ChainBridgeService {
|
|
|
12
12
|
constructor(nodeRpcUrlsConfig: NodeRpcUrlsConfig, api: AllbridgeCoreClient);
|
|
13
13
|
send(): Promise<TransactionResponse>;
|
|
14
14
|
buildRawTransactionSwap(params: SwapParams): Promise<RawSuiTransaction>;
|
|
15
|
-
buildRawTransactionSwapFromParams
|
|
15
|
+
private buildRawTransactionSwapFromParams;
|
|
16
|
+
buildRawTransactionSendFromCustomTx(baseTx: string | Uint8Array | Transaction, inputCoin: TransactionResult, params: SendParams): Promise<RawSuiTransaction>;
|
|
16
17
|
buildRawTransactionSend(params: SendParams): Promise<RawSuiTransaction>;
|
|
18
|
+
private buildRawTransactionSendFromTx;
|
|
17
19
|
private buildRawTransactionAllbridgeSend;
|
|
18
20
|
private buildRawTransactionWormholeSend;
|
|
19
21
|
private buildRawTransactionCctpSend;
|
|
@@ -65,7 +65,14 @@ class SuiBridgeService extends models_2.ChainBridgeService {
|
|
|
65
65
|
}
|
|
66
66
|
return await tx.toJSON({ client: this.client });
|
|
67
67
|
}
|
|
68
|
+
async buildRawTransactionSendFromCustomTx(baseTx, inputCoin, params) {
|
|
69
|
+
const transaction = transactions_1.Transaction.from(baseTx);
|
|
70
|
+
return this.buildRawTransactionSendFromTx(params, transaction, inputCoin);
|
|
71
|
+
}
|
|
68
72
|
async buildRawTransactionSend(params) {
|
|
73
|
+
return this.buildRawTransactionSendFromTx(params, new transactions_1.Transaction());
|
|
74
|
+
}
|
|
75
|
+
async buildRawTransactionSendFromTx(params, tx, inputCoin) {
|
|
69
76
|
const txSendParams = await (0, utils_3.prepareTxSendParams)(this.chainType, params, this.api);
|
|
70
77
|
const { messenger } = txSendParams;
|
|
71
78
|
const suiAddresses = params.sourceToken.suiAddresses;
|
|
@@ -76,36 +83,45 @@ class SuiBridgeService extends models_2.ChainBridgeService {
|
|
|
76
83
|
(0, utils_2.setAddress)(suiAddresses.utilsAddress);
|
|
77
84
|
switch (messenger) {
|
|
78
85
|
case models_1.Messenger.ALLBRIDGE:
|
|
79
|
-
return this.buildRawTransactionAllbridgeSend(txSendParams, suiAddresses);
|
|
86
|
+
return this.buildRawTransactionAllbridgeSend(txSendParams, suiAddresses, tx, inputCoin);
|
|
80
87
|
case models_1.Messenger.WORMHOLE:
|
|
81
|
-
return this.buildRawTransactionWormholeSend(txSendParams, suiAddresses);
|
|
88
|
+
return this.buildRawTransactionWormholeSend(txSendParams, suiAddresses, tx, inputCoin);
|
|
82
89
|
case models_1.Messenger.CCTP:
|
|
83
90
|
case models_1.Messenger.CCTP_V2:
|
|
84
|
-
return this.buildRawTransactionCctpSend(params, txSendParams, suiAddresses);
|
|
91
|
+
return this.buildRawTransactionCctpSend(params, txSendParams, suiAddresses, tx, inputCoin);
|
|
85
92
|
case models_1.Messenger.OFT:
|
|
86
93
|
throw new models_1.OFTDoesNotSupportedError("Messenger OFT is not supported yet.");
|
|
87
94
|
}
|
|
88
95
|
}
|
|
89
|
-
async buildRawTransactionAllbridgeSend(txSendParams, suiAddresses) {
|
|
96
|
+
async buildRawTransactionAllbridgeSend(txSendParams, suiAddresses, tx, inputCoin) {
|
|
90
97
|
const { amount, fromAccountAddress, fromTokenAddress, toChainId, toAccountAddress, toTokenAddress, fee, gasFeePaymentMethod, extraGas, } = txSendParams;
|
|
91
98
|
let totalFee = fee;
|
|
92
99
|
if (extraGas) {
|
|
93
100
|
totalFee = (0, big_js_1.Big)(totalFee).plus(extraGas).toFixed();
|
|
94
101
|
}
|
|
95
|
-
const tx = new transactions_1.Transaction();
|
|
96
102
|
tx.setSender(fromAccountAddress);
|
|
97
103
|
if (gasFeePaymentMethod === models_1.FeePaymentMethod.WITH_STABLECOIN) {
|
|
98
104
|
const amountWithoutFee = BigInt(amount) - BigInt(totalFee);
|
|
105
|
+
let amountCoin, feeTokenCoin;
|
|
106
|
+
if (inputCoin) {
|
|
107
|
+
const [amountCoinS, feeTokenCoinS] = tx.splitCoins(inputCoin, [amount, totalFee]);
|
|
108
|
+
amountCoin = amountCoinS;
|
|
109
|
+
feeTokenCoin = feeTokenCoinS;
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
amountCoin = (0, transactions_1.coinWithBalance)({ balance: amountWithoutFee, type: fromTokenAddress });
|
|
113
|
+
feeTokenCoin = (0, transactions_1.coinWithBalance)({ balance: BigInt(totalFee), type: fromTokenAddress });
|
|
114
|
+
}
|
|
99
115
|
const args = {
|
|
100
116
|
bridge: suiAddresses.bridgeObjectAddress,
|
|
101
117
|
messenger: suiAddresses.allbridgeMessengerObjectAddress,
|
|
102
|
-
amount:
|
|
118
|
+
amount: amountCoin,
|
|
103
119
|
destinationChainId: toChainId,
|
|
104
120
|
nonce: (0, utils_3.getNonceBigInt)(),
|
|
105
121
|
recipient: (0, functions_3.fromHex)(tx, (0, utils_3.normalizeSuiHex)(toAccountAddress)),
|
|
106
122
|
receiveToken: (0, functions_3.fromHex)(tx, (0, utils_3.normalizeSuiHex)(toTokenAddress)),
|
|
107
123
|
gasOracle: suiAddresses.gasOracleObjectAddress,
|
|
108
|
-
feeTokenCoin:
|
|
124
|
+
feeTokenCoin: feeTokenCoin,
|
|
109
125
|
feeSuiCoin: (0, transactions_1.coinWithBalance)({ balance: BigInt(0), useGasCoin: false }),
|
|
110
126
|
};
|
|
111
127
|
(0, functions_1.swapAndBridge)(tx, fromTokenAddress, args);
|
|
@@ -117,7 +133,7 @@ class SuiBridgeService extends models_2.ChainBridgeService {
|
|
|
117
133
|
const args = {
|
|
118
134
|
bridge: suiAddresses.bridgeObjectAddress,
|
|
119
135
|
messenger: suiAddresses.allbridgeMessengerObjectAddress,
|
|
120
|
-
amount: (0, transactions_1.coinWithBalance)({ balance: BigInt(amount), type: fromTokenAddress }),
|
|
136
|
+
amount: inputCoin ?? (0, transactions_1.coinWithBalance)({ balance: BigInt(amount), type: fromTokenAddress }),
|
|
121
137
|
destinationChainId: toChainId,
|
|
122
138
|
nonce: (0, utils_3.getNonceBigInt)(),
|
|
123
139
|
recipient: (0, functions_3.fromHex)(tx, (0, utils_3.normalizeSuiHex)(toAccountAddress)),
|
|
@@ -130,28 +146,37 @@ class SuiBridgeService extends models_2.ChainBridgeService {
|
|
|
130
146
|
}
|
|
131
147
|
return await tx.toJSON({ client: this.client });
|
|
132
148
|
}
|
|
133
|
-
async buildRawTransactionWormholeSend(txSendParams, suiAddresses) {
|
|
149
|
+
async buildRawTransactionWormholeSend(txSendParams, suiAddresses, tx, inputCoin) {
|
|
134
150
|
const { amount, fromAccountAddress, fromTokenAddress, toChainId, toAccountAddress, toTokenAddress, fee, gasFeePaymentMethod, extraGas, } = txSendParams;
|
|
135
151
|
let totalFee = fee;
|
|
136
152
|
if (extraGas) {
|
|
137
153
|
totalFee = (0, big_js_1.Big)(totalFee).plus(extraGas).toFixed();
|
|
138
154
|
}
|
|
139
|
-
const tx = new transactions_1.Transaction();
|
|
140
155
|
tx.setSender(fromAccountAddress);
|
|
141
156
|
if (gasFeePaymentMethod === models_1.FeePaymentMethod.WITH_STABLECOIN) {
|
|
142
157
|
const amountWithoutFee = BigInt(amount) - BigInt(totalFee);
|
|
158
|
+
let amountCoin, feeTokenCoin;
|
|
159
|
+
if (inputCoin) {
|
|
160
|
+
const [amountCoinS, feeTokenCoinS] = tx.splitCoins(inputCoin, [amount, totalFee]);
|
|
161
|
+
amountCoin = amountCoinS;
|
|
162
|
+
feeTokenCoin = feeTokenCoinS;
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
amountCoin = (0, transactions_1.coinWithBalance)({ balance: amountWithoutFee, type: fromTokenAddress });
|
|
166
|
+
feeTokenCoin = (0, transactions_1.coinWithBalance)({ balance: BigInt(totalFee), type: fromTokenAddress });
|
|
167
|
+
}
|
|
143
168
|
const args = {
|
|
144
169
|
bridge: suiAddresses.bridgeObjectAddress,
|
|
145
170
|
messenger: suiAddresses.wormholeMessengerObjectAddress,
|
|
146
171
|
wormholeState: suiAddresses.wormholeStateObjectAddress,
|
|
147
172
|
theClock: utils_1.SUI_CLOCK_OBJECT_ID,
|
|
148
|
-
amount:
|
|
173
|
+
amount: amountCoin,
|
|
149
174
|
destinationChainId: toChainId,
|
|
150
175
|
nonce: (0, utils_3.getNonceBigInt)(),
|
|
151
176
|
recipient: (0, functions_3.fromHex)(tx, (0, utils_3.normalizeSuiHex)(toAccountAddress)),
|
|
152
177
|
receiveToken: (0, functions_3.fromHex)(tx, (0, utils_3.normalizeSuiHex)(toTokenAddress)),
|
|
153
178
|
gasOracle: suiAddresses.gasOracleObjectAddress,
|
|
154
|
-
feeTokenCoin:
|
|
179
|
+
feeTokenCoin: feeTokenCoin,
|
|
155
180
|
feeSuiCoin: (0, transactions_1.coinWithBalance)({ balance: BigInt(0), useGasCoin: false }),
|
|
156
181
|
};
|
|
157
182
|
(0, functions_1.swapAndBridgeWormhole)(tx, fromTokenAddress, args);
|
|
@@ -165,7 +190,7 @@ class SuiBridgeService extends models_2.ChainBridgeService {
|
|
|
165
190
|
messenger: suiAddresses.wormholeMessengerObjectAddress,
|
|
166
191
|
wormholeState: suiAddresses.wormholeStateObjectAddress,
|
|
167
192
|
theClock: utils_1.SUI_CLOCK_OBJECT_ID,
|
|
168
|
-
amount: (0, transactions_1.coinWithBalance)({ balance: BigInt(amount), type: fromTokenAddress }),
|
|
193
|
+
amount: inputCoin ?? (0, transactions_1.coinWithBalance)({ balance: BigInt(amount), type: fromTokenAddress }),
|
|
169
194
|
destinationChainId: toChainId,
|
|
170
195
|
nonce: (0, utils_3.getNonceBigInt)(),
|
|
171
196
|
recipient: (0, functions_3.fromHex)(tx, (0, utils_3.normalizeSuiHex)(toAccountAddress)),
|
|
@@ -178,14 +203,13 @@ class SuiBridgeService extends models_2.ChainBridgeService {
|
|
|
178
203
|
}
|
|
179
204
|
return await tx.toJSON({ client: this.client });
|
|
180
205
|
}
|
|
181
|
-
async buildRawTransactionCctpSend(params, txSendParams, suiAddresses) {
|
|
206
|
+
async buildRawTransactionCctpSend(params, txSendParams, suiAddresses, tx, inputCoin) {
|
|
182
207
|
const { amount, fromAccountAddress, fromTokenAddress, toChainId, toAccountAddress, fee, gasFeePaymentMethod, extraGas, } = txSendParams;
|
|
183
208
|
(0, cctp_bridge_1.setAddress)(suiAddresses.cctpAddress, suiAddresses.cctpAddressOrigin);
|
|
184
209
|
let totalFee = fee;
|
|
185
210
|
if (extraGas) {
|
|
186
211
|
totalFee = (0, big_js_1.Big)(totalFee).plus(extraGas).toFixed();
|
|
187
212
|
}
|
|
188
|
-
const tx = new transactions_1.Transaction();
|
|
189
213
|
tx.setSender(fromAccountAddress);
|
|
190
214
|
const recipientWalletAddress = (0, functions_3.fromHex)(tx, (0, utils_3.normalizeSuiHex)(toAccountAddress));
|
|
191
215
|
let recipient;
|
|
@@ -198,18 +222,28 @@ class SuiBridgeService extends models_2.ChainBridgeService {
|
|
|
198
222
|
}
|
|
199
223
|
if (gasFeePaymentMethod === models_1.FeePaymentMethod.WITH_STABLECOIN) {
|
|
200
224
|
const amountWithoutFee = BigInt(amount) - BigInt(totalFee);
|
|
225
|
+
let amountCoin, feeTokenCoin;
|
|
226
|
+
if (inputCoin) {
|
|
227
|
+
const [amountCoinS, feeTokenCoinS] = tx.splitCoins(inputCoin, [amount, totalFee]);
|
|
228
|
+
amountCoin = amountCoinS;
|
|
229
|
+
feeTokenCoin = feeTokenCoinS;
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
amountCoin = (0, transactions_1.coinWithBalance)({ balance: amountWithoutFee, type: fromTokenAddress });
|
|
233
|
+
feeTokenCoin = (0, transactions_1.coinWithBalance)({ balance: BigInt(totalFee), type: fromTokenAddress });
|
|
234
|
+
}
|
|
201
235
|
const args = {
|
|
202
236
|
cctpBridge: suiAddresses.cctpObjectAddress,
|
|
203
237
|
tokenMessengerMinterState: suiAddresses.cctpTokenMessengerMinterStateObjectAddress,
|
|
204
238
|
messageTransmitterState: suiAddresses.cctpMessageTransmitterStateObjectAddress,
|
|
205
239
|
treasury: suiAddresses.cctpTreasuryObjectAddress,
|
|
206
240
|
denyList: suiAddresses.cctpDenyListObjectAddress,
|
|
207
|
-
amount:
|
|
241
|
+
amount: amountCoin,
|
|
208
242
|
destinationChainId: toChainId,
|
|
209
243
|
recipient: recipient,
|
|
210
244
|
recipientWalletAddress: recipientWalletAddress,
|
|
211
245
|
gasOracle: suiAddresses.gasOracleObjectAddress,
|
|
212
|
-
feeTokenCoin:
|
|
246
|
+
feeTokenCoin: feeTokenCoin,
|
|
213
247
|
feeSuiCoin: (0, transactions_1.coinWithBalance)({ balance: BigInt(0), useGasCoin: false }),
|
|
214
248
|
};
|
|
215
249
|
(0, functions_2.bridge)(tx, fromTokenAddress, args);
|
|
@@ -224,7 +258,7 @@ class SuiBridgeService extends models_2.ChainBridgeService {
|
|
|
224
258
|
messageTransmitterState: suiAddresses.cctpMessageTransmitterStateObjectAddress,
|
|
225
259
|
treasury: suiAddresses.cctpTreasuryObjectAddress,
|
|
226
260
|
denyList: suiAddresses.cctpDenyListObjectAddress,
|
|
227
|
-
amount: (0, transactions_1.coinWithBalance)({ balance: BigInt(amount), type: fromTokenAddress }),
|
|
261
|
+
amount: inputCoin ?? (0, transactions_1.coinWithBalance)({ balance: BigInt(amount), type: fromTokenAddress }),
|
|
228
262
|
destinationChainId: toChainId,
|
|
229
263
|
recipient: recipient,
|
|
230
264
|
recipientWalletAddress: recipientWalletAddress,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/services/bridge/sui/index.ts"],"names":[],"mappings":";;;AAAA,+CAA+C;AAE/C,2DAA2F;AAC3F,6CAAwD;AACxD,mCAA6B;AAE7B,4CAUyB;AAGzB,oDAAqD;AACrD,kFAAgH;AAChH,8DAA4E;AAC5E,4FAAsF;AACtF,kDAAuE;AACvE,wEAAmE;AACnE,yDAAmE;AACnE,kGAA0F;AAC1F,sCAA6F;AAC7F,oCAAqG;AAErG,MAAa,gBAAiB,SAAQ,2BAAkB;IAO5C;IACD;IAPT,SAAS,GAAkB,kBAAS,CAAC,GAAG,CAAC;IACzC,WAAW,GAAoB,oBAAW,CAAC,GAAG,CAAC;IAE9B,MAAM,CAAY;IAEnC,YACU,iBAAoC,EACrC,GAAwB;QAE/B,KAAK,EAAE,CAAC;QAHA,sBAAiB,GAAjB,iBAAiB,CAAmB;QACrC,QAAG,GAAH,GAAG,CAAqB;QAG/B,IAAI,CAAC,MAAM,GAAG,IAAI,kBAAS,CAAC;YAC1B,GAAG,EAAE,iBAAiB,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC;SACvD,CAAC,CAAC;IACL,CAAC;IAED,IAAI;QACF,MAAM,IAAI,iBAAQ,CAAC,8BAA8B,CAAC,CA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EAAE,EAAE,gBAAgB,EAAE,IAAI,CAAC,CAAC;QACrC,CAAC;QACD,OAAO,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IAClD,CAAC;CACF;AAhSD,4CAgSC","sourcesContent":["import { SuiClient } from \"@mysten/sui/client\";\nimport { CoinStruct } from \"@mysten/sui/src/client/types/generated\";\nimport { coinWithBalance, Transaction, TransactionResult } from \"@mysten/sui/transactions\";\nimport { SUI_CLOCK_OBJECT_ID } from \"@mysten/sui/utils\";\nimport { Big } from \"big.js\";\nimport { AllbridgeCoreClient } from \"../../../client/core-api/core-client-base\";\nimport {\n ChainSymbol,\n ChainType,\n FeePaymentMethod,\n Messenger,\n OFTDoesNotSupportedError,\n RawSuiTransaction,\n SdkError,\n SwapParams,\n TransactionResponse,\n} from \"../../../models\";\nimport { SuiAddresses } from \"../../../tokens-info\";\nimport { NodeRpcUrlsConfig } from \"../../index\";\nimport { setAddress } from \"../../models/sui/bridge\";\nimport { swap, swapAndBridge, swapAndBridgeWormhole } from \"../../models/sui/bridge/bridge-interface/functions\";\nimport { setAddress as setCctpAddress } from \"../../models/sui/cctp-bridge\";\nimport { bridge } from \"../../models/sui/cctp-bridge/cctp-bridge-interface/functions\";\nimport { setAddress as setUtilsAddress } from \"../../models/sui/utils\";\nimport { fromHex } from \"../../models/sui/utils/bytes32/functions\";\nimport { fetchAllPagesRecursive } from \"../../utils/sui/paginated\";\nimport { getCctpSolTokenRecipientAddress } from \"../get-cctp-sol-token-recipient-address\";\nimport { ChainBridgeService, SendParams, TxSendParamsSui, TxSwapParamsSui } from \"../models\";\nimport { getNonceBigInt, normalizeSuiHex, prepareTxSendParams, prepareTxSwapParams } from \"../utils\";\n\nexport class SuiBridgeService extends ChainBridgeService {\n chainType: ChainType.SUI = ChainType.SUI;\n chainSymbol: ChainSymbol.SUI = ChainSymbol.SUI;\n\n private readonly client: SuiClient;\n\n constructor(\n private nodeRpcUrlsConfig: NodeRpcUrlsConfig,\n public api: AllbridgeCoreClient\n ) {\n super();\n this.client = new SuiClient({\n url: nodeRpcUrlsConfig.getNodeRpcUrl(this.chainSymbol),\n });\n }\n\n send(): Promise<TransactionResponse> {\n throw new SdkError(\"Method send not implemented.\");\n }\n\n async buildRawTransactionSwap(params: SwapParams): Promise<RawSuiTransaction> {\n const suiAddresses = params.sourceToken.suiAddresses;\n if (!suiAddresses) {\n throw new SdkError(\"SUI token must contain 'suiAddresses'\");\n }\n setAddress(suiAddresses.bridgeAddress, suiAddresses.bridgeAddressOrigin);\n\n const txSwapParams = prepareTxSwapParams(this.chainType, params);\n return await this.buildRawTransactionSwapFromParams(txSwapParams, suiAddresses);\n }\n\n async buildRawTransactionSwapFromParams(\n params: TxSwapParamsSui,\n suiAddresses: SuiAddresses\n ): Promise<RawSuiTransaction> {\n const { amount, fromAccountAddress, fromTokenAddress, toTokenAddress, minimumReceiveAmount } = params;\n\n const tx = new Transaction();\n tx.setSender(fromAccountAddress);\n\n const args = {\n bridge: suiAddresses.bridgeObjectAddress,\n coin: coinWithBalance({ balance: BigInt(amount), type: fromTokenAddress }),\n receiveAmountMin: BigInt(minimumReceiveAmount),\n };\n const swapResult = swap(tx, [fromTokenAddress, toTokenAddress], args);\n\n const coins: CoinStruct[] = await fetchAllPagesRecursive((cursor: string | null | undefined) =>\n this.client.getCoins({\n owner: params.toAccountAddress,\n coinType: toTokenAddress,\n cursor,\n })\n );\n if (coins.length === 0 || !coins[0]) {\n tx.transferObjects([swapResult], params.toAccountAddress);\n } else {\n tx.mergeCoins(coins[0].coinObjectId, [swapResult]);\n }\n return await tx.toJSON({ client: this.client });\n }\n\n async buildRawTransactionSend(params: SendParams): Promise<RawSuiTransaction> {\n const txSendParams = await prepareTxSendParams(this.chainType, params, this.api);\n const { messenger } = txSendParams;\n\n const suiAddresses = params.sourceToken.suiAddresses;\n if (!suiAddresses) {\n throw new SdkError(\"SUI token must contain 'suiAddresses'\");\n }\n setAddress(suiAddresses.bridgeAddress, suiAddresses.bridgeAddressOrigin);\n setUtilsAddress(suiAddresses.utilsAddress);\n\n switch (messenger) {\n case Messenger.ALLBRIDGE:\n return this.buildRawTransactionAllbridgeSend(txSendParams, suiAddresses);\n case Messenger.WORMHOLE:\n return this.buildRawTransactionWormholeSend(txSendParams, suiAddresses);\n case Messenger.CCTP:\n case Messenger.CCTP_V2:\n return this.buildRawTransactionCctpSend(params, txSendParams, suiAddresses);\n case Messenger.OFT:\n throw new OFTDoesNotSupportedError(\"Messenger OFT is not supported yet.\");\n }\n }\n\n private async buildRawTransactionAllbridgeSend(\n txSendParams: TxSendParamsSui,\n suiAddresses: SuiAddresses\n ): Promise<RawSuiTransaction> {\n const {\n amount,\n fromAccountAddress,\n fromTokenAddress,\n toChainId,\n toAccountAddress,\n toTokenAddress,\n fee,\n gasFeePaymentMethod,\n extraGas,\n } = txSendParams;\n let totalFee = fee;\n if (extraGas) {\n totalFee = Big(totalFee).plus(extraGas).toFixed();\n }\n\n const tx = new Transaction();\n tx.setSender(fromAccountAddress);\n if (gasFeePaymentMethod === FeePaymentMethod.WITH_STABLECOIN) {\n const amountWithoutFee = BigInt(amount) - BigInt(totalFee);\n const args = {\n bridge: suiAddresses.bridgeObjectAddress,\n messenger: suiAddresses.allbridgeMessengerObjectAddress,\n amount: coinWithBalance({ balance: amountWithoutFee, type: fromTokenAddress }),\n destinationChainId: toChainId,\n nonce: getNonceBigInt(),\n recipient: fromHex(tx, normalizeSuiHex(toAccountAddress)),\n receiveToken: fromHex(tx, normalizeSuiHex(toTokenAddress)),\n gasOracle: suiAddresses.gasOracleObjectAddress,\n feeTokenCoin: coinWithBalance({ balance: BigInt(totalFee), type: fromTokenAddress }),\n feeSuiCoin: coinWithBalance({ balance: BigInt(0), useGasCoin: false }),\n };\n swapAndBridge(tx, fromTokenAddress, args);\n } else {\n const totalFeeCoin =\n totalFee === \"0\"\n ? coinWithBalance({ balance: BigInt(totalFee), useGasCoin: false })\n : coinWithBalance({ balance: BigInt(totalFee) });\n const args = {\n bridge: suiAddresses.bridgeObjectAddress,\n messenger: suiAddresses.allbridgeMessengerObjectAddress,\n amount: coinWithBalance({ balance: BigInt(amount), type: fromTokenAddress }),\n destinationChainId: toChainId,\n nonce: getNonceBigInt(),\n recipient: fromHex(tx, normalizeSuiHex(toAccountAddress)),\n receiveToken: fromHex(tx, normalizeSuiHex(toTokenAddress)),\n gasOracle: suiAddresses.gasOracleObjectAddress,\n feeTokenCoin: coinWithBalance({ balance: BigInt(0), type: fromTokenAddress }),\n feeSuiCoin: totalFeeCoin,\n };\n swapAndBridge(tx, fromTokenAddress, args);\n }\n return await tx.toJSON({ client: this.client });\n }\n\n private async buildRawTransactionWormholeSend(\n txSendParams: TxSendParamsSui,\n suiAddresses: SuiAddresses\n ): Promise<RawSuiTransaction> {\n const {\n amount,\n fromAccountAddress,\n fromTokenAddress,\n toChainId,\n toAccountAddress,\n toTokenAddress,\n fee,\n gasFeePaymentMethod,\n extraGas,\n } = txSendParams;\n let totalFee = fee;\n if (extraGas) {\n totalFee = Big(totalFee).plus(extraGas).toFixed();\n }\n\n const tx = new Transaction();\n tx.setSender(fromAccountAddress);\n if (gasFeePaymentMethod === FeePaymentMethod.WITH_STABLECOIN) {\n const amountWithoutFee = BigInt(amount) - BigInt(totalFee);\n const args = {\n bridge: suiAddresses.bridgeObjectAddress,\n messenger: suiAddresses.wormholeMessengerObjectAddress,\n wormholeState: suiAddresses.wormholeStateObjectAddress,\n theClock: SUI_CLOCK_OBJECT_ID,\n amount: coinWithBalance({ balance: amountWithoutFee, type: fromTokenAddress }),\n destinationChainId: toChainId,\n nonce: getNonceBigInt(),\n recipient: fromHex(tx, normalizeSuiHex(toAccountAddress)),\n receiveToken: fromHex(tx, normalizeSuiHex(toTokenAddress)),\n gasOracle: suiAddresses.gasOracleObjectAddress,\n feeTokenCoin: coinWithBalance({ balance: BigInt(totalFee), type: fromTokenAddress }),\n feeSuiCoin: coinWithBalance({ balance: BigInt(0), useGasCoin: false }),\n };\n swapAndBridgeWormhole(tx, fromTokenAddress, args);\n } else {\n const totalFeeCoin =\n totalFee === \"0\"\n ? coinWithBalance({ balance: BigInt(totalFee), useGasCoin: false })\n : coinWithBalance({ balance: BigInt(totalFee) });\n const args = {\n bridge: suiAddresses.bridgeObjectAddress,\n messenger: suiAddresses.wormholeMessengerObjectAddress,\n wormholeState: suiAddresses.wormholeStateObjectAddress,\n theClock: SUI_CLOCK_OBJECT_ID,\n amount: coinWithBalance({ balance: BigInt(amount), type: fromTokenAddress }),\n destinationChainId: toChainId,\n nonce: getNonceBigInt(),\n recipient: fromHex(tx, normalizeSuiHex(toAccountAddress)),\n receiveToken: fromHex(tx, normalizeSuiHex(toTokenAddress)),\n gasOracle: suiAddresses.gasOracleObjectAddress,\n feeTokenCoin: coinWithBalance({ balance: BigInt(0), type: fromTokenAddress }),\n feeSuiCoin: totalFeeCoin,\n };\n swapAndBridgeWormhole(tx, fromTokenAddress, args);\n }\n return await tx.toJSON({ client: this.client });\n }\n\n private async buildRawTransactionCctpSend(\n params: SendParams,\n txSendParams: TxSendParamsSui,\n suiAddresses: SuiAddresses\n ): Promise<RawSuiTransaction> {\n const {\n amount,\n fromAccountAddress,\n fromTokenAddress,\n toChainId,\n toAccountAddress,\n fee,\n gasFeePaymentMethod,\n extraGas,\n } = txSendParams;\n\n setCctpAddress(suiAddresses.cctpAddress, suiAddresses.cctpAddressOrigin);\n\n let totalFee = fee;\n if (extraGas) {\n totalFee = Big(totalFee).plus(extraGas).toFixed();\n }\n\n const tx = new Transaction();\n tx.setSender(fromAccountAddress);\n\n const recipientWalletAddress = fromHex(tx, normalizeSuiHex(toAccountAddress));\n let recipient: TransactionResult;\n if (params.destinationToken.chainType === ChainType.SOLANA) {\n const recipientStr = await getCctpSolTokenRecipientAddress(\n this.chainType,\n params.toAccountAddress,\n params.destinationToken.tokenAddress,\n this.nodeRpcUrlsConfig.getNodeRpcUrl(ChainSymbol.SOL)\n );\n recipient = fromHex(tx, normalizeSuiHex(recipientStr));\n } else {\n recipient = recipientWalletAddress;\n }\n\n if (gasFeePaymentMethod === FeePaymentMethod.WITH_STABLECOIN) {\n const amountWithoutFee = BigInt(amount) - BigInt(totalFee);\n const args = {\n cctpBridge: suiAddresses.cctpObjectAddress,\n tokenMessengerMinterState: suiAddresses.cctpTokenMessengerMinterStateObjectAddress,\n messageTransmitterState: suiAddresses.cctpMessageTransmitterStateObjectAddress,\n treasury: suiAddresses.cctpTreasuryObjectAddress,\n denyList: suiAddresses.cctpDenyListObjectAddress,\n amount: coinWithBalance({ balance: amountWithoutFee, type: fromTokenAddress }),\n destinationChainId: toChainId,\n recipient: recipient,\n recipientWalletAddress: recipientWalletAddress,\n gasOracle: suiAddresses.gasOracleObjectAddress,\n feeTokenCoin: coinWithBalance({ balance: BigInt(totalFee), type: fromTokenAddress }),\n feeSuiCoin: coinWithBalance({ balance: BigInt(0), useGasCoin: false }),\n };\n bridge(tx, fromTokenAddress, args);\n } else {\n const totalFeeCoin =\n totalFee === \"0\"\n ? coinWithBalance({ balance: BigInt(totalFee), useGasCoin: false })\n : coinWithBalance({ balance: BigInt(totalFee) });\n const args = {\n cctpBridge: suiAddresses.cctpObjectAddress,\n tokenMessengerMinterState: suiAddresses.cctpTokenMessengerMinterStateObjectAddress,\n messageTransmitterState: suiAddresses.cctpMessageTransmitterStateObjectAddress,\n treasury: suiAddresses.cctpTreasuryObjectAddress,\n denyList: suiAddresses.cctpDenyListObjectAddress,\n amount: coinWithBalance({ balance: BigInt(amount), type: fromTokenAddress }),\n destinationChainId: toChainId,\n recipient: recipient,\n recipientWalletAddress: recipientWalletAddress,\n gasOracle: suiAddresses.gasOracleObjectAddress,\n feeTokenCoin: coinWithBalance({ balance: BigInt(0), type: fromTokenAddress }),\n feeSuiCoin: totalFeeCoin,\n };\n bridge(tx, fromTokenAddress, args);\n }\n return await tx.toJSON({ client: this.client });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../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port { CoinStruct } from \"@mysten/sui/src/client/types/generated\";\nimport { coinWithBalance, Transaction, TransactionResult } from \"@mysten/sui/transactions\";\nimport { SUI_CLOCK_OBJECT_ID } from \"@mysten/sui/utils\";\nimport { Big } from \"big.js\";\nimport { AllbridgeCoreClient } from \"../../../client/core-api/core-client-base\";\nimport {\n ChainSymbol,\n ChainType,\n FeePaymentMethod,\n Messenger,\n OFTDoesNotSupportedError,\n RawSuiTransaction,\n SdkError,\n SwapParams,\n TransactionResponse,\n} from \"../../../models\";\nimport { SuiAddresses } from \"../../../tokens-info\";\nimport { NodeRpcUrlsConfig } from \"../../index\";\nimport { setAddress } from \"../../models/sui/bridge\";\nimport { swap, swapAndBridge, swapAndBridgeWormhole } from \"../../models/sui/bridge/bridge-interface/functions\";\nimport { setAddress as setCctpAddress } from \"../../models/sui/cctp-bridge\";\nimport { bridge } from \"../../models/sui/cctp-bridge/cctp-bridge-interface/functions\";\nimport { setAddress as setUtilsAddress } from \"../../models/sui/utils\";\nimport { fromHex } from \"../../models/sui/utils/bytes32/functions\";\nimport { fetchAllPagesRecursive } from \"../../utils/sui/paginated\";\nimport { getCctpSolTokenRecipientAddress } from \"../get-cctp-sol-token-recipient-address\";\nimport { ChainBridgeService, SendParams, TxSendParamsSui, TxSwapParamsSui } from \"../models\";\nimport { getNonceBigInt, normalizeSuiHex, prepareTxSendParams, prepareTxSwapParams } from \"../utils\";\n\nexport class SuiBridgeService extends ChainBridgeService {\n chainType: ChainType.SUI = ChainType.SUI;\n chainSymbol: ChainSymbol.SUI = ChainSymbol.SUI;\n\n private readonly client: SuiClient;\n\n constructor(\n private nodeRpcUrlsConfig: NodeRpcUrlsConfig,\n public api: AllbridgeCoreClient\n ) {\n super();\n this.client = new SuiClient({\n url: nodeRpcUrlsConfig.getNodeRpcUrl(this.chainSymbol),\n });\n }\n\n send(): Promise<TransactionResponse> {\n throw new SdkError(\"Method send not implemented.\");\n }\n\n async buildRawTransactionSwap(params: SwapParams): Promise<RawSuiTransaction> {\n const suiAddresses = params.sourceToken.suiAddresses;\n if (!suiAddresses) {\n throw new SdkError(\"SUI token must contain 'suiAddresses'\");\n }\n setAddress(suiAddresses.bridgeAddress, suiAddresses.bridgeAddressOrigin);\n\n const txSwapParams = prepareTxSwapParams(this.chainType, params);\n return await this.buildRawTransactionSwapFromParams(txSwapParams, suiAddresses);\n }\n\n private async buildRawTransactionSwapFromParams(\n params: TxSwapParamsSui,\n suiAddresses: SuiAddresses\n ): Promise<RawSuiTransaction> {\n const { amount, fromAccountAddress, fromTokenAddress, toTokenAddress, minimumReceiveAmount } = params;\n\n const tx = new Transaction();\n tx.setSender(fromAccountAddress);\n\n const args = {\n bridge: suiAddresses.bridgeObjectAddress,\n coin: coinWithBalance({ balance: BigInt(amount), type: fromTokenAddress }),\n receiveAmountMin: BigInt(minimumReceiveAmount),\n };\n const swapResult = swap(tx, [fromTokenAddress, toTokenAddress], args);\n\n const coins: CoinStruct[] = await fetchAllPagesRecursive((cursor: string | null | undefined) =>\n this.client.getCoins({\n owner: params.toAccountAddress,\n coinType: toTokenAddress,\n cursor,\n })\n );\n if (coins.length === 0 || !coins[0]) {\n tx.transferObjects([swapResult], params.toAccountAddress);\n } else {\n tx.mergeCoins(coins[0].coinObjectId, [swapResult]);\n }\n return await tx.toJSON({ client: this.client });\n }\n\n async buildRawTransactionSendFromCustomTx(\n baseTx: string | Uint8Array | Transaction,\n inputCoin: TransactionResult,\n params: SendParams\n ): Promise<RawSuiTransaction> {\n const transaction = Transaction.from(baseTx);\n return this.buildRawTransactionSendFromTx(params, transaction, inputCoin);\n }\n\n async buildRawTransactionSend(params: SendParams): Promise<RawSuiTransaction> {\n return this.buildRawTransactionSendFromTx(params, new Transaction());\n }\n\n private async buildRawTransactionSendFromTx(\n params: SendParams,\n tx: Transaction,\n inputCoin?: TransactionResult\n ): Promise<RawSuiTransaction> {\n const txSendParams = await prepareTxSendParams(this.chainType, params, this.api);\n const { messenger } = txSendParams;\n\n const suiAddresses = params.sourceToken.suiAddresses;\n if (!suiAddresses) {\n throw new SdkError(\"SUI token must contain 'suiAddresses'\");\n }\n setAddress(suiAddresses.bridgeAddress, suiAddresses.bridgeAddressOrigin);\n setUtilsAddress(suiAddresses.utilsAddress);\n\n switch (messenger) {\n case Messenger.ALLBRIDGE:\n return this.buildRawTransactionAllbridgeSend(txSendParams, suiAddresses, tx, inputCoin);\n case Messenger.WORMHOLE:\n return this.buildRawTransactionWormholeSend(txSendParams, suiAddresses, tx, inputCoin);\n case Messenger.CCTP:\n case Messenger.CCTP_V2:\n return this.buildRawTransactionCctpSend(params, txSendParams, suiAddresses, tx, inputCoin);\n case Messenger.OFT:\n throw new OFTDoesNotSupportedError(\"Messenger OFT is not supported yet.\");\n }\n }\n\n private async buildRawTransactionAllbridgeSend(\n txSendParams: TxSendParamsSui,\n suiAddresses: SuiAddresses,\n tx: Transaction,\n inputCoin?: TransactionResult\n ): Promise<RawSuiTransaction> {\n const {\n amount,\n fromAccountAddress,\n fromTokenAddress,\n toChainId,\n toAccountAddress,\n toTokenAddress,\n fee,\n gasFeePaymentMethod,\n extraGas,\n } = txSendParams;\n let totalFee = fee;\n if (extraGas) {\n totalFee = Big(totalFee).plus(extraGas).toFixed();\n }\n\n tx.setSender(fromAccountAddress);\n if (gasFeePaymentMethod === FeePaymentMethod.WITH_STABLECOIN) {\n const amountWithoutFee = BigInt(amount) - BigInt(totalFee);\n\n let amountCoin, feeTokenCoin;\n if (inputCoin) {\n const [amountCoinS, feeTokenCoinS] = tx.splitCoins(inputCoin, [amount, totalFee]);\n amountCoin = amountCoinS;\n feeTokenCoin = feeTokenCoinS;\n } else {\n amountCoin = coinWithBalance({ balance: amountWithoutFee, type: fromTokenAddress });\n feeTokenCoin = coinWithBalance({ balance: BigInt(totalFee), type: fromTokenAddress });\n }\n\n const args = {\n bridge: suiAddresses.bridgeObjectAddress,\n messenger: suiAddresses.allbridgeMessengerObjectAddress,\n amount: amountCoin,\n destinationChainId: toChainId,\n nonce: getNonceBigInt(),\n recipient: fromHex(tx, normalizeSuiHex(toAccountAddress)),\n receiveToken: fromHex(tx, normalizeSuiHex(toTokenAddress)),\n gasOracle: suiAddresses.gasOracleObjectAddress,\n feeTokenCoin: feeTokenCoin,\n feeSuiCoin: coinWithBalance({ balance: BigInt(0), useGasCoin: false }),\n };\n swapAndBridge(tx, fromTokenAddress, args);\n } else {\n const totalFeeCoin =\n totalFee === \"0\"\n ? coinWithBalance({ balance: BigInt(totalFee), useGasCoin: false })\n : coinWithBalance({ balance: BigInt(totalFee) });\n const args = {\n bridge: suiAddresses.bridgeObjectAddress,\n messenger: suiAddresses.allbridgeMessengerObjectAddress,\n amount: inputCoin ?? coinWithBalance({ balance: BigInt(amount), type: fromTokenAddress }),\n destinationChainId: toChainId,\n nonce: getNonceBigInt(),\n recipient: fromHex(tx, normalizeSuiHex(toAccountAddress)),\n receiveToken: fromHex(tx, normalizeSuiHex(toTokenAddress)),\n gasOracle: suiAddresses.gasOracleObjectAddress,\n feeTokenCoin: coinWithBalance({ balance: BigInt(0), type: fromTokenAddress }),\n feeSuiCoin: totalFeeCoin,\n };\n swapAndBridge(tx, fromTokenAddress, args);\n }\n return await tx.toJSON({ client: this.client });\n }\n\n private async buildRawTransactionWormholeSend(\n txSendParams: TxSendParamsSui,\n suiAddresses: SuiAddresses,\n tx: Transaction,\n inputCoin?: TransactionResult\n ): Promise<RawSuiTransaction> {\n const {\n amount,\n fromAccountAddress,\n fromTokenAddress,\n toChainId,\n toAccountAddress,\n toTokenAddress,\n fee,\n gasFeePaymentMethod,\n extraGas,\n } = txSendParams;\n let totalFee = fee;\n if (extraGas) {\n totalFee = Big(totalFee).plus(extraGas).toFixed();\n }\n\n tx.setSender(fromAccountAddress);\n if (gasFeePaymentMethod === FeePaymentMethod.WITH_STABLECOIN) {\n const amountWithoutFee = BigInt(amount) - BigInt(totalFee);\n\n let amountCoin, feeTokenCoin;\n if (inputCoin) {\n const [amountCoinS, feeTokenCoinS] = tx.splitCoins(inputCoin, [amount, totalFee]);\n amountCoin = amountCoinS;\n feeTokenCoin = feeTokenCoinS;\n } else {\n amountCoin = coinWithBalance({ balance: amountWithoutFee, type: fromTokenAddress });\n feeTokenCoin = coinWithBalance({ balance: BigInt(totalFee), type: fromTokenAddress });\n }\n\n const args = {\n bridge: suiAddresses.bridgeObjectAddress,\n messenger: suiAddresses.wormholeMessengerObjectAddress,\n wormholeState: suiAddresses.wormholeStateObjectAddress,\n theClock: SUI_CLOCK_OBJECT_ID,\n amount: amountCoin,\n destinationChainId: toChainId,\n nonce: getNonceBigInt(),\n recipient: fromHex(tx, normalizeSuiHex(toAccountAddress)),\n receiveToken: fromHex(tx, normalizeSuiHex(toTokenAddress)),\n gasOracle: suiAddresses.gasOracleObjectAddress,\n feeTokenCoin: feeTokenCoin,\n feeSuiCoin: coinWithBalance({ balance: BigInt(0), useGasCoin: false }),\n };\n swapAndBridgeWormhole(tx, fromTokenAddress, args);\n } else {\n const totalFeeCoin =\n totalFee === \"0\"\n ? coinWithBalance({ balance: BigInt(totalFee), useGasCoin: false })\n : coinWithBalance({ balance: BigInt(totalFee) });\n const args = {\n bridge: suiAddresses.bridgeObjectAddress,\n messenger: suiAddresses.wormholeMessengerObjectAddress,\n wormholeState: suiAddresses.wormholeStateObjectAddress,\n theClock: SUI_CLOCK_OBJECT_ID,\n amount: inputCoin ?? coinWithBalance({ balance: BigInt(amount), type: fromTokenAddress }),\n destinationChainId: toChainId,\n nonce: getNonceBigInt(),\n recipient: fromHex(tx, normalizeSuiHex(toAccountAddress)),\n receiveToken: fromHex(tx, normalizeSuiHex(toTokenAddress)),\n gasOracle: suiAddresses.gasOracleObjectAddress,\n feeTokenCoin: coinWithBalance({ balance: BigInt(0), type: fromTokenAddress }),\n feeSuiCoin: totalFeeCoin,\n };\n swapAndBridgeWormhole(tx, fromTokenAddress, args);\n }\n return await tx.toJSON({ client: this.client });\n }\n\n private async buildRawTransactionCctpSend(\n params: SendParams,\n txSendParams: TxSendParamsSui,\n suiAddresses: SuiAddresses,\n tx: Transaction,\n inputCoin?: TransactionResult\n ): Promise<RawSuiTransaction> {\n const {\n amount,\n fromAccountAddress,\n fromTokenAddress,\n toChainId,\n toAccountAddress,\n fee,\n gasFeePaymentMethod,\n extraGas,\n } = txSendParams;\n\n setCctpAddress(suiAddresses.cctpAddress, suiAddresses.cctpAddressOrigin);\n\n let totalFee = fee;\n if (extraGas) {\n totalFee = Big(totalFee).plus(extraGas).toFixed();\n }\n\n tx.setSender(fromAccountAddress);\n\n const recipientWalletAddress = fromHex(tx, normalizeSuiHex(toAccountAddress));\n let recipient: TransactionResult;\n if (params.destinationToken.chainType === ChainType.SOLANA) {\n const recipientStr = await getCctpSolTokenRecipientAddress(\n this.chainType,\n params.toAccountAddress,\n params.destinationToken.tokenAddress,\n this.nodeRpcUrlsConfig.getNodeRpcUrl(ChainSymbol.SOL)\n );\n recipient = fromHex(tx, normalizeSuiHex(recipientStr));\n } else {\n recipient = recipientWalletAddress;\n }\n\n if (gasFeePaymentMethod === FeePaymentMethod.WITH_STABLECOIN) {\n const amountWithoutFee = BigInt(amount) - BigInt(totalFee);\n\n let amountCoin, feeTokenCoin;\n if (inputCoin) {\n const [amountCoinS, feeTokenCoinS] = tx.splitCoins(inputCoin, [amount, totalFee]);\n amountCoin = amountCoinS;\n feeTokenCoin = feeTokenCoinS;\n } else {\n amountCoin = coinWithBalance({ balance: amountWithoutFee, type: fromTokenAddress });\n feeTokenCoin = coinWithBalance({ balance: BigInt(totalFee), type: fromTokenAddress });\n }\n\n const args = {\n cctpBridge: suiAddresses.cctpObjectAddress,\n tokenMessengerMinterState: suiAddresses.cctpTokenMessengerMinterStateObjectAddress,\n messageTransmitterState: suiAddresses.cctpMessageTransmitterStateObjectAddress,\n treasury: suiAddresses.cctpTreasuryObjectAddress,\n denyList: suiAddresses.cctpDenyListObjectAddress,\n amount: amountCoin,\n destinationChainId: toChainId,\n recipient: recipient,\n recipientWalletAddress: recipientWalletAddress,\n gasOracle: suiAddresses.gasOracleObjectAddress,\n feeTokenCoin: feeTokenCoin,\n feeSuiCoin: coinWithBalance({ balance: BigInt(0), useGasCoin: false }),\n };\n bridge(tx, fromTokenAddress, args);\n } else {\n const totalFeeCoin =\n totalFee === \"0\"\n ? coinWithBalance({ balance: BigInt(totalFee), useGasCoin: false })\n : coinWithBalance({ balance: BigInt(totalFee) });\n const args = {\n cctpBridge: suiAddresses.cctpObjectAddress,\n tokenMessengerMinterState: suiAddresses.cctpTokenMessengerMinterStateObjectAddress,\n messageTransmitterState: suiAddresses.cctpMessageTransmitterStateObjectAddress,\n treasury: suiAddresses.cctpTreasuryObjectAddress,\n denyList: suiAddresses.cctpDenyListObjectAddress,\n amount: inputCoin ?? coinWithBalance({ balance: BigInt(amount), type: fromTokenAddress }),\n destinationChainId: toChainId,\n recipient: recipient,\n recipientWalletAddress: recipientWalletAddress,\n gasOracle: suiAddresses.gasOracleObjectAddress,\n feeTokenCoin: coinWithBalance({ balance: BigInt(0), type: fromTokenAddress }),\n feeSuiCoin: totalFeeCoin,\n };\n bridge(tx, fromTokenAddress, args);\n }\n return await tx.toJSON({ client: this.client });\n }\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Big } from "big.js";
|
|
2
2
|
import { CheckAddressResponse, GasBalanceResponse, Messenger, TransferStatusResponse } from "../client/core-api/core-api.model";
|
|
3
|
+
import { AllbridgeCoreClientFiltered } from "../client/core-api/core-client-filtered";
|
|
3
4
|
import { AllbridgeCoreSdkOptions, NodeRpcUrls } from "../index";
|
|
4
5
|
import { AmountFormat, AmountFormatted, AmountsAndGasFeeOptions, ExtraGasMaxLimitResponse, GasFeeOptions, GetTokenBalanceParams, PendingStatusInfoResponse, Provider, SendAmountDetails, SwapAndBridgeCalculationData } from "../models";
|
|
5
6
|
import { ChainDetailsMap, PoolInfo, TokenWithChainDetails } from "../tokens-info";
|
|
@@ -12,7 +13,8 @@ export declare class NodeRpcUrlsConfig {
|
|
|
12
13
|
getNodeRpcUrl(chainSymbol: string): string;
|
|
13
14
|
}
|
|
14
15
|
export declare class AllbridgeCoreSdkService {
|
|
15
|
-
|
|
16
|
+
readonly nodeRpcUrlsConfig: NodeRpcUrlsConfig;
|
|
17
|
+
readonly api: AllbridgeCoreClientFiltered;
|
|
16
18
|
private readonly tokenService;
|
|
17
19
|
readonly params: AllbridgeCoreSdkOptions;
|
|
18
20
|
bridge: BridgeService;
|
|
@@ -38,12 +38,14 @@ class NodeRpcUrlsConfig {
|
|
|
38
38
|
}
|
|
39
39
|
exports.NodeRpcUrlsConfig = NodeRpcUrlsConfig;
|
|
40
40
|
class AllbridgeCoreSdkService {
|
|
41
|
+
nodeRpcUrlsConfig;
|
|
41
42
|
api;
|
|
42
43
|
tokenService;
|
|
43
44
|
params;
|
|
44
45
|
bridge;
|
|
45
46
|
pool;
|
|
46
47
|
constructor(nodeRpcUrlsConfig, params = configs_1.mainnet) {
|
|
48
|
+
this.nodeRpcUrlsConfig = nodeRpcUrlsConfig;
|
|
47
49
|
chains_1.Chains.addChainsProperties(params.additionalChainsProperties);
|
|
48
50
|
const apiClient = new api_client_1.ApiClientImpl(params);
|
|
49
51
|
const apiClientCaching = new api_client_caching_1.ApiClientCaching(apiClient);
|