@allbridge/bridge-core-sdk 3.23.0-beta.1 → 3.23.0-beta.3
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/README.md +15 -8
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +4 -4
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +4 -4
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +4 -4
- package/dist/src/client/core-api/api-client-caching.js +1 -1
- package/dist/src/client/core-api/api-client-caching.js.map +1 -1
- package/dist/src/client/core-api/api-client.js +6 -0
- package/dist/src/client/core-api/api-client.js.map +1 -1
- package/dist/src/client/core-api/core-api-mapper.js +3 -0
- package/dist/src/client/core-api/core-api-mapper.js.map +1 -1
- package/dist/src/client/core-api/core-api.model.d.ts +8 -2
- package/dist/src/client/core-api/core-api.model.js +2 -0
- package/dist/src/client/core-api/core-api.model.js.map +1 -1
- package/dist/src/exceptions/exceptions.d.ts +4 -0
- package/dist/src/exceptions/exceptions.js +8 -1
- package/dist/src/exceptions/exceptions.js.map +1 -1
- package/dist/src/index.d.ts +10 -17
- package/dist/src/index.js +34 -26
- package/dist/src/index.js.map +1 -1
- package/dist/src/models/index.d.ts +1 -0
- package/dist/src/models/index.js.map +1 -1
- package/dist/src/services/bridge/evm/index.d.ts +3 -1
- package/dist/src/services/bridge/evm/index.js +46 -14
- package/dist/src/services/bridge/evm/index.js.map +1 -1
- package/dist/src/services/bridge/index.d.ts +1 -1
- package/dist/src/services/bridge/index.js +26 -19
- package/dist/src/services/bridge/index.js.map +1 -1
- package/dist/src/services/bridge/models/bridge.model.d.ts +4 -0
- package/dist/src/services/bridge/models/bridge.model.js.map +1 -1
- package/dist/src/services/bridge/sol/index.d.ts +2 -2
- package/dist/src/services/bridge/sol/index.js +7 -4
- package/dist/src/services/bridge/sol/index.js.map +1 -1
- package/dist/src/services/bridge/sui/index.js +2 -0
- package/dist/src/services/bridge/sui/index.js.map +1 -1
- package/dist/src/services/bridge/trx/index.d.ts +1 -1
- package/dist/src/services/bridge/trx/index.js +84 -53
- package/dist/src/services/bridge/trx/index.js.map +1 -1
- package/dist/src/services/bridge/utils.d.ts +2 -2
- package/dist/src/services/bridge/utils.js +64 -36
- package/dist/src/services/bridge/utils.js.map +1 -1
- package/dist/src/services/index.d.ts +13 -7
- package/dist/src/services/index.js +129 -48
- package/dist/src/services/index.js.map +1 -1
- package/dist/src/services/models/abi/OftBridge.d.ts +386 -0
- package/dist/src/services/models/abi/OftBridge.js +500 -0
- package/dist/src/services/models/abi/OftBridge.js.map +1 -0
- package/dist/src/tokens-info/tokens-info.model.d.ts +14 -0
- package/dist/src/tokens-info/tokens-info.model.js.map +1 -1
- package/dist/src/utils/evm/index.d.ts +40 -0
- package/dist/src/utils/evm/index.js +36 -0
- package/dist/src/utils/evm/index.js.map +1 -0
- package/dist/src/utils/index.d.ts +6 -0
- package/dist/src/utils/index.js +6 -0
- package/dist/src/utils/index.js.map +1 -1
- package/dist/src/utils/sui/index.d.ts +28 -0
- package/dist/src/utils/sui/index.js +57 -0
- package/dist/src/utils/sui/index.js.map +1 -0
- 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 +8 -8
|
@@ -51,7 +51,7 @@ class ApiClientCaching {
|
|
|
51
51
|
return pendingInfoPromise;
|
|
52
52
|
}
|
|
53
53
|
async getReceiveTransactionCost(args) {
|
|
54
|
-
const RECEIVE_TX_COST_KEY = `RECEIVE_TX_COST_${args.sourceChainId}_${args.destinationChainId}_${args.messenger}`;
|
|
54
|
+
const RECEIVE_TX_COST_KEY = `RECEIVE_TX_COST_${args.sourceChainId}_${args.destinationChainId}_${args.messenger}${args.sourceToken ? "_" + args.sourceToken : ""}`;
|
|
55
55
|
const transactionCost = this.receivedTransactionCache.get(RECEIVE_TX_COST_KEY);
|
|
56
56
|
if (transactionCost) {
|
|
57
57
|
return transactionCost;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-client-caching.js","sourceRoot":"","sources":["../../../../src/client/core-api/api-client-caching.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAgC;AAWhC,MAAM,eAAe,GAAG,EAAE,GAAG,IAAI,CAAC;AAClC,MAAM,eAAe,GAAG,EAAE,GAAG,IAAI,CAAC;AAElC,MAAa,gBAAgB;IAMP;IALZ,cAAc,CAA4B;IAC1C,gBAAgB,CAAsC;IACtD,eAAe,CAAqC;IACpD,wBAAwB,CAAwC;IAExE,YAAoB,SAAoB;QAApB,cAAS,GAAT,SAAS,CAAW;QACtC,IAAI,CAAC,cAAc,GAAG,IAAI,qBAAK,CAAC,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC,CAAC;QACjE,IAAI,CAAC,wBAAwB,GAAG,IAAI,qBAAK,CAAC,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC,CAAC;QAC3E,IAAI,CAAC,gBAAgB,GAAG,IAAI,qBAAK,CAAC,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC,CAAC;QACnE,IAAI,CAAC,eAAe,GAAG,IAAI,qBAAK,CAAC,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC,CAAC;IACpE,CAAC;IAED,YAAY;QACV,MAAM,oBAAoB,GAAG,sBAAsB,CAAC;QACpD,MAAM,SAAS,GAAG,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;QAChE,IAAI,SAAS,EAAE,CAAC;YACd,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,MAAM,gBAAgB,GAAG,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,CAAC;QACvD,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,oBAAoB,EAAE,gBAAgB,CAAC,CAAC;QAChE,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,WAAmB,EAAE,OAAe;QACtD,MAAM,qBAAqB,GAAG,eAAe,WAAW,IAAI,OAAO,EAAE,CAAC;QACtE,MAAM,UAAU,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;QACnE,IAAI,UAAU,EAAE,CAAC;YACf,OAAO,UAAU,CAAC;QACpB,CAAC;QACD,MAAM,iBAAiB,GAAG,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QAC7E,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,qBAAqB,EAAE,iBAAiB,CAAC,CAAC;QACnE,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,cAAc;QAClB,MAAM,sBAAsB,GAAG,wBAAwB,CAAC;QACxD,MAAM,WAAW,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;QACtE,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO,WAAW,CAAC;QACrB,CAAC;QACD,MAAM,kBAAkB,GAAG,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,CAAC;QAC3D,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,sBAAsB,EAAE,kBAAkB,CAAC,CAAC;QACtE,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,yBAAyB,CAAC,IAAmC;QACjE,MAAM,mBAAmB,GAAG,mBAAmB,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,kBAAkB,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"api-client-caching.js","sourceRoot":"","sources":["../../../../src/client/core-api/api-client-caching.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAgC;AAWhC,MAAM,eAAe,GAAG,EAAE,GAAG,IAAI,CAAC;AAClC,MAAM,eAAe,GAAG,EAAE,GAAG,IAAI,CAAC;AAElC,MAAa,gBAAgB;IAMP;IALZ,cAAc,CAA4B;IAC1C,gBAAgB,CAAsC;IACtD,eAAe,CAAqC;IACpD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C,cAAc,CAAC,KAAsC;QACzD,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC;CACF;AAhED,4CAgEC","sourcesContent":["import Cache from \"timed-cache\";\nimport { PoolInfoMap, PoolKeyObject } from \"../../tokens-info\";\nimport { ApiClient, TokenInfo } from \"./api-client\";\nimport {\n GasBalanceResponse,\n PendingInfoResponse,\n ReceiveTransactionCostRequest,\n ReceiveTransactionCostResponse,\n TransferStatusResponse,\n} from \"./core-api.model\";\n\nconst _20_SECONDS_TTL = 20 * 1000;\nconst _55_SECONDS_TTL = 55 * 1000;\n\nexport class ApiClientCaching implements ApiClient {\n private tokenInfoCache: Cache<Promise<TokenInfo>>;\n private pendingInfoCache: Cache<Promise<PendingInfoResponse>>;\n private gasBalanceCache: Cache<Promise<GasBalanceResponse>>;\n private receivedTransactionCache: Cache<ReceiveTransactionCostResponse>;\n\n constructor(private apiClient: ApiClient) {\n this.tokenInfoCache = new Cache({ defaultTtl: _55_SECONDS_TTL });\n this.receivedTransactionCache = new Cache({ defaultTtl: _20_SECONDS_TTL });\n this.pendingInfoCache = new Cache({ defaultTtl: _20_SECONDS_TTL });\n this.gasBalanceCache = new Cache({ defaultTtl: _20_SECONDS_TTL });\n }\n\n getTokenInfo(): Promise<TokenInfo> {\n const TOKEN_INFO_CACHE_KEY = \"TOKEN_INFO_CACHE_KEY\";\n const tokenInfo = this.tokenInfoCache.get(TOKEN_INFO_CACHE_KEY);\n if (tokenInfo) {\n return tokenInfo;\n }\n const tokenInfoPromise = this.apiClient.getTokenInfo();\n this.tokenInfoCache.put(TOKEN_INFO_CACHE_KEY, tokenInfoPromise);\n return tokenInfoPromise;\n }\n\n async getGasBalance(chainSymbol: string, address: string): Promise<GasBalanceResponse> {\n const GAS_BALANCE_CACHE_KEY = `GAS_BALANCE_${chainSymbol}_${address}`;\n const gasBalance = this.gasBalanceCache.get(GAS_BALANCE_CACHE_KEY);\n if (gasBalance) {\n return gasBalance;\n }\n const gasBalancePromise = this.apiClient.getGasBalance(chainSymbol, address);\n this.gasBalanceCache.put(GAS_BALANCE_CACHE_KEY, gasBalancePromise);\n return gasBalancePromise;\n }\n\n async getPendingInfo(): Promise<PendingInfoResponse> {\n const PENDING_INFO_CACHE_KEY = \"PENDING_INFO_CACHE_KEY\";\n const pendingInfo = this.pendingInfoCache.get(PENDING_INFO_CACHE_KEY);\n if (pendingInfo) {\n return pendingInfo;\n }\n const pendingInfoPromise = this.apiClient.getPendingInfo();\n this.pendingInfoCache.put(PENDING_INFO_CACHE_KEY, pendingInfoPromise);\n return pendingInfoPromise;\n }\n\n async getReceiveTransactionCost(args: ReceiveTransactionCostRequest): Promise<ReceiveTransactionCostResponse> {\n const RECEIVE_TX_COST_KEY = `RECEIVE_TX_COST_${args.sourceChainId}_${args.destinationChainId}_${args.messenger}${args.sourceToken ? \"_\" + args.sourceToken : \"\"}`;\n const transactionCost = this.receivedTransactionCache.get(RECEIVE_TX_COST_KEY);\n if (transactionCost) {\n return transactionCost;\n }\n const fetchedTransactionCost = await this.apiClient.getReceiveTransactionCost(args);\n this.receivedTransactionCache.put(RECEIVE_TX_COST_KEY, fetchedTransactionCost);\n return fetchedTransactionCost;\n }\n\n async getTransferStatus(chainSymbol: string, txId: string): Promise<TransferStatusResponse> {\n return this.apiClient.getTransferStatus(chainSymbol, txId);\n }\n\n async getPoolInfoMap(pools: PoolKeyObject[] | PoolKeyObject): Promise<PoolInfoMap> {\n return this.apiClient.getPoolInfoMap(pools);\n }\n}\n"]}
|
|
@@ -5,8 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ApiClientImpl = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const exceptions_1 = require("../../exceptions");
|
|
8
9
|
const version_1 = require("../../version");
|
|
9
10
|
const core_api_mapper_1 = require("./core-api-mapper");
|
|
11
|
+
const core_api_model_1 = require("./core-api.model");
|
|
10
12
|
class ApiClientImpl {
|
|
11
13
|
api;
|
|
12
14
|
constructor(params) {
|
|
@@ -40,6 +42,9 @@ class ApiClientImpl {
|
|
|
40
42
|
return data;
|
|
41
43
|
}
|
|
42
44
|
async getReceiveTransactionCost(args) {
|
|
45
|
+
if (args.messenger === core_api_model_1.Messenger.OFT && !args.sourceToken) {
|
|
46
|
+
throw new exceptions_1.InvalidMessengerOptionError("For OFT sourceToken required");
|
|
47
|
+
}
|
|
43
48
|
const { data } = await this.api.post("/receive-fee", args, {
|
|
44
49
|
headers: {
|
|
45
50
|
"Content-Type": "application/json",
|
|
@@ -49,6 +54,7 @@ class ApiClientImpl {
|
|
|
49
54
|
exchangeRate: data.exchangeRate,
|
|
50
55
|
fee: data.fee,
|
|
51
56
|
sourceNativeTokenPrice: data.sourceNativeTokenPrice,
|
|
57
|
+
adminFeeShareWithExtras: data.adminFeeShareWithExtras,
|
|
52
58
|
};
|
|
53
59
|
}
|
|
54
60
|
async getPoolInfoMap(pools) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-client.js","sourceRoot":"","sources":["../../../../src/client/core-api/api-client.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAqC;
|
|
1
|
+
{"version":3,"file":"api-client.js","sourceRoot":"","sources":["../../../../src/client/core-api/api-client.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAqC;AACrC,iDAA+D;AAE/D,2CAAwC;AACxC,uDAI2B;AAC3B,qDAS0B;AAsB1B,MAAa,aAAa;IAChB,GAAG,CAAQ;IAEnB,YAAY,MAAiC;QAC3C,IAAI,CAAC,GAAG,GAAG,eAAK,CAAC,MAAM,CAAC;YACtB,OAAO,EAAE,MAAM,CAAC,UAAU;YAC1B,OAAO,EAAE;gBACP,MAAM,EAAE,kBAAkB;gBAC1B,GAAG,MAAM,CAAC,cAAc;gBACxB,aAAa,EAAE,mBAAmB,GAAG,iBAAO;aAC7C;YACD,MAAM,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AE,IAAI,EAAE;YACzF,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;SACF,CAAC,CAAC;QACH,OAAO;YACL,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,sBAAsB,EAAE,IAAI,CAAC,sBAAsB;YACnD,uBAAuB,EAAE,IAAI,CAAC,uBAAuB;SACtD,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,KAAsC;QACzD,MAAM,QAAQ,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAC1D,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAClC,YAAY,EACZ,EAAE,KAAK,EAAE,QAAQ,EAAE,EACnB;YACE,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;SACF,CACF,CAAC;QACF,OAAO,IAAA,kDAAgC,EAAC,IAAI,CAAC,CAAC;IAChD,CAAC;CACF;AApED,sCAoEC","sourcesContent":["import axios, { Axios } from \"axios\";\nimport { InvalidMessengerOptionError } from \"../../exceptions\";\nimport { ChainDetailsMapWithFlags, PoolInfoMap, PoolKeyObject } from \"../../tokens-info\";\nimport { VERSION } from \"../../version\";\nimport {\n mapChainDetailsResponseToChainDetailsMap,\n mapChainDetailsResponseToPoolInfoMap,\n mapPoolInfoResponseToPoolInfoMap,\n} from \"./core-api-mapper\";\nimport {\n ChainDetailsResponse,\n GasBalanceResponse,\n Messenger,\n PendingInfoResponse,\n PoolInfoResponse,\n ReceiveTransactionCostRequest,\n ReceiveTransactionCostResponse,\n TransferStatusResponse,\n} from \"./core-api.model\";\nimport { AllbridgeCoreClientParams } from \"./core-client-base\";\n\nexport interface TokenInfo {\n chainDetailsMap: ChainDetailsMapWithFlags;\n poolInfoMap: PoolInfoMap;\n}\n\nexport interface ApiClient {\n getTokenInfo(): Promise<TokenInfo>;\n\n getPendingInfo(): Promise<PendingInfoResponse>;\n\n getGasBalance(chainSymbol: string, address: string): Promise<GasBalanceResponse>;\n\n getTransferStatus(chainSymbol: string, txId: string): Promise<TransferStatusResponse>;\n\n getReceiveTransactionCost(args: ReceiveTransactionCostRequest): Promise<ReceiveTransactionCostResponse>;\n\n getPoolInfoMap(pools: PoolKeyObject[] | PoolKeyObject): Promise<PoolInfoMap>;\n}\n\nexport class ApiClientImpl implements ApiClient {\n private api: Axios;\n\n constructor(params: AllbridgeCoreClientParams) {\n this.api = axios.create({\n baseURL: params.coreApiUrl,\n headers: {\n Accept: \"application/json\",\n ...params.coreApiHeaders,\n \"x-Sdk-Agent\": \"AllbridgeCoreSDK/\" + VERSION,\n },\n params: params.coreApiQueryParams,\n });\n }\n\n async getTokenInfo(): Promise<TokenInfo> {\n const { data } = await this.api.get<ChainDetailsResponse>(\"/token-info\", { params: { filter: \"all\" } });\n return {\n chainDetailsMap: mapChainDetailsResponseToChainDetailsMap(data),\n poolInfoMap: mapChainDetailsResponseToPoolInfoMap(data),\n };\n }\n\n async getPendingInfo(): Promise<PendingInfoResponse> {\n const { data } = await this.api.get<PendingInfoResponse>(\"/pending-info\");\n return data;\n }\n\n async getGasBalance(chainSymbol: string, address: string): Promise<GasBalanceResponse> {\n const { data } = await this.api.get<GasBalanceResponse>(`/check/${chainSymbol}/${address}`);\n return data;\n }\n\n async getTransferStatus(chainSymbol: string, txId: string): Promise<TransferStatusResponse> {\n const { data } = await this.api.get<TransferStatusResponse>(`/chain/${chainSymbol}/${txId}`);\n return data;\n }\n\n async getReceiveTransactionCost(args: ReceiveTransactionCostRequest): Promise<ReceiveTransactionCostResponse> {\n if (args.messenger === Messenger.OFT && !args.sourceToken) {\n throw new InvalidMessengerOptionError(\"For OFT sourceToken required\");\n }\n const { data } = await this.api.post<ReceiveTransactionCostResponse>(\"/receive-fee\", args, {\n headers: {\n \"Content-Type\": \"application/json\",\n },\n });\n return {\n exchangeRate: data.exchangeRate,\n fee: data.fee,\n sourceNativeTokenPrice: data.sourceNativeTokenPrice,\n adminFeeShareWithExtras: data.adminFeeShareWithExtras,\n };\n }\n\n async getPoolInfoMap(pools: PoolKeyObject[] | PoolKeyObject): Promise<PoolInfoMap> {\n const poolKeys = pools instanceof Array ? pools : [pools];\n const { data } = await this.api.post<PoolInfoResponse>(\n \"/pool-info\",\n { pools: poolKeys },\n {\n headers: {\n \"Content-Type\": \"application/json\",\n },\n }\n );\n return mapPoolInfoResponseToPoolInfoMap(data);\n }\n}\n"]}
|
|
@@ -54,6 +54,8 @@ function mapMessengerKeyDtoToMessenger(dto) {
|
|
|
54
54
|
return core_api_model_1.Messenger.CCTP;
|
|
55
55
|
case core_api_model_1.MessengerKeyDTO.CCTP_V2:
|
|
56
56
|
return core_api_model_1.Messenger.CCTP_V2;
|
|
57
|
+
case core_api_model_1.MessengerKeyDTO.OFT:
|
|
58
|
+
return core_api_model_1.Messenger.OFT;
|
|
57
59
|
}
|
|
58
60
|
}
|
|
59
61
|
function mapTransferTimeFromDto(dto) {
|
|
@@ -80,6 +82,7 @@ function mapChainDetailsFromDto(chainSymbol, dto) {
|
|
|
80
82
|
...basicChainProperties,
|
|
81
83
|
allbridgeChainId: dto.chainId,
|
|
82
84
|
bridgeAddress: dto.bridgeAddress,
|
|
85
|
+
oftBridgeAddress: dto.oftBridgeAddress,
|
|
83
86
|
transferTime: mapTransferTimeFromDto(dto.transferTime),
|
|
84
87
|
txCostAmount: dto.txCostAmount,
|
|
85
88
|
confirmations: dto.confirmations,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-api-mapper.js","sourceRoot":"","sources":["../../../../src/client/core-api/core-api-mapper.ts"],"names":[],"mappings":";;AAyBA,4FAUC;AAED,oFAcC;
|
|
1
|
+
{"version":3,"file":"core-api-mapper.js","sourceRoot":"","sources":["../../../../src/client/core-api/core-api-mapper.ts"],"names":[],"mappings":";;AAyBA,4FAUC;AAED,oFAcC;AAiED,8DA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,CAAC;AAED,SAAgB,kCAAkC,CAAC,eAAgC;IACjF,MAAM,MAAM,GAAG,EAAE,CAAC;IAClB,KAAK,MAAM,CAAC,gBAAgB,EAAE,YAAY,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC;QAC/E,MAAM,WAAW,GAAG,gBAAgB,CAAC;QACrC,KAAK,MAAM,KAAK,IAAI,YAAY,CAAC,MAAM,EAAE,CAAC;YACxC,MAAM,CAAC,IAAI,CAAC;gBACV,WAAW;gBACX,WAAW,EAAE,KAAK,CAAC,WAAW;aAC/B,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAgB,gCAAgC,CAAC,YAA8B;IAC7E,MAAM,WAAW,GAAgB,EAAE,CAAC;IACpC,KAAK,MAAM,CAAC,gBAAgB,EAAE,iBAAiB,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;QACjF,MAAM,WAAW,GAAG,gBAAgB,CAAC;QACrC,KAAK,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,EAAE,CAAC;YACxE,QAAQ,CAAC,SAAS,GAAG,IAAA,wCAA0B,EAAC,QAAQ,CAAC,CAAC;YAC1D,WAAW,CAAC,yBAAyB,CAAC,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC,CAAC,GAAG,QAAQ,CAAC;QAClF,CAAC;IACH,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import { Chains } from \"../../chains\";\nimport { ChainSymbol } from \"../../chains/chain.enums\";\nimport {\n ChainDetails,\n ChainDetailsMap,\n ChainDetailsMapWithFlags,\n ChainDetailsWithTokensWithFlags,\n MessengerTransferTime,\n PoolInfoMap,\n PoolKeyObject,\n TokenWithChainDetailsWithFlags,\n TransferTime,\n} from \"../../tokens-info\";\nimport { calculatePoolInfoImbalance } from \"../../utils/calculation\";\nimport {\n ChainDetailsDTO,\n ChainDetailsResponse,\n Messenger,\n MessengerKeyDTO,\n MessengerTransferTimeDTO,\n PoolInfoResponse,\n TokenDTO,\n TransferTimeDTO,\n} from \"./core-api.model\";\n\nexport function mapChainDetailsResponseToChainDetailsMap(response: ChainDetailsResponse): ChainDetailsMapWithFlags {\n return Object.entries(response).reduce<ChainDetailsMapWithFlags>((map, entry) => {\n const chainSymbol = entry[0];\n const chainDetailsDTO = entry[1];\n const chainDetails = mapChainDetailsFromDto(chainSymbol, chainDetailsDTO);\n if (chainDetails) {\n map[chainSymbol] = chainDetails;\n }\n return map;\n }, {});\n}\n\nexport function mapChainDetailsResponseToPoolInfoMap(response: ChainDetailsResponse): PoolInfoMap {\n const poolInfoMap: PoolInfoMap = {};\n for (const [chainSymbolValue, chainDetailsDTO] of Object.entries(response)) {\n const chainSymbol = chainSymbolValue;\n for (const token of chainDetailsDTO.tokens) {\n const poolKey = mapPoolKeyObjectToPoolKey({\n chainSymbol,\n poolAddress: token.poolAddress,\n });\n const imbalance = calculatePoolInfoImbalance(token.poolInfo);\n poolInfoMap[poolKey] = { ...token.poolInfo, imbalance };\n }\n }\n return poolInfoMap;\n}\n\nfunction mapTokenWithChainDetailsFromDto(chainDetails: ChainDetails, dto: TokenDTO): TokenWithChainDetailsWithFlags {\n const { name: chainName, ...chainDetailsWithoutName } = chainDetails;\n const { poolInfo: _poolInfo, ...dtoWithoutPoolInfo } = dto;\n return {\n ...dtoWithoutPoolInfo,\n ...chainDetailsWithoutName,\n chainName,\n };\n}\n\nfunction mapMessengerKeyDtoToMessenger(dto: MessengerKeyDTO): Messenger | null {\n switch (dto) {\n case MessengerKeyDTO.ALLBRIDGE:\n return Messenger.ALLBRIDGE;\n case MessengerKeyDTO.WORMHOLE:\n return Messenger.WORMHOLE;\n case MessengerKeyDTO.CCTP:\n return Messenger.CCTP;\n case MessengerKeyDTO.CCTP_V2:\n return Messenger.CCTP_V2;\n case MessengerKeyDTO.OFT:\n return Messenger.OFT;\n }\n}\n\nfunction mapTransferTimeFromDto(dto: TransferTimeDTO): TransferTime {\n return Object.entries(dto).reduce<TransferTime>((result, [key, value]) => {\n result[key as ChainSymbol] = mapMessengerTransferTimeFromDto(value);\n return result;\n }, {});\n}\n\nfunction mapMessengerTransferTimeFromDto(dto: MessengerTransferTimeDTO): MessengerTransferTime {\n return Object.entries(dto).reduce<MessengerTransferTime>((messengerTransferTime, [key, value]) => {\n const messenger = mapMessengerKeyDtoToMessenger(key as MessengerKeyDTO);\n if (messenger) {\n messengerTransferTime[messenger] = value;\n }\n return messengerTransferTime;\n }, {});\n}\n\nfunction mapChainDetailsFromDto(chainSymbol: string, dto: ChainDetailsDTO): ChainDetailsWithTokensWithFlags | null {\n const basicChainProperties = Chains.getChainsProperties()[chainSymbol];\n if (!basicChainProperties) {\n return null;\n }\n const chainDetails: ChainDetails = {\n ...basicChainProperties,\n allbridgeChainId: dto.chainId,\n bridgeAddress: dto.bridgeAddress,\n oftBridgeAddress: dto.oftBridgeAddress,\n transferTime: mapTransferTimeFromDto(dto.transferTime),\n txCostAmount: dto.txCostAmount,\n confirmations: dto.confirmations,\n suiAddresses: dto.suiAddresses,\n };\n return {\n ...chainDetails,\n tokens: dto.tokens.map((tokenDto) => mapTokenWithChainDetailsFromDto(chainDetails, tokenDto)),\n };\n}\n\nexport function mapPoolKeyToPoolKeyObject(poolKey: string): PoolKeyObject {\n const dividerPosition = poolKey.indexOf(\"_\");\n return {\n chainSymbol: poolKey.substring(0, dividerPosition),\n poolAddress: poolKey.substring(dividerPosition + 1),\n };\n}\n\nexport function mapPoolKeyObjectToPoolKey(poolKeyObject: PoolKeyObject): string {\n return poolKeyObject.chainSymbol + \"_\" + poolKeyObject.poolAddress;\n}\n\nexport function mapChainDetailsMapToPoolKeyObjects(chainDetailsMap: ChainDetailsMap): PoolKeyObject[] {\n const result = [];\n for (const [chainSymbolValue, chainDetails] of Object.entries(chainDetailsMap)) {\n const chainSymbol = chainSymbolValue;\n for (const token of chainDetails.tokens) {\n result.push({\n chainSymbol,\n poolAddress: token.poolAddress,\n });\n }\n }\n return result;\n}\n\nexport function mapPoolInfoResponseToPoolInfoMap(responseBody: PoolInfoResponse): PoolInfoMap {\n const poolInfoMap: PoolInfoMap = {};\n for (const [chainSymbolValue, poolInfoByAddress] of Object.entries(responseBody)) {\n const chainSymbol = chainSymbolValue;\n for (const [poolAddress, poolInfo] of Object.entries(poolInfoByAddress)) {\n poolInfo.imbalance = calculatePoolInfoImbalance(poolInfo);\n poolInfoMap[mapPoolKeyObjectToPoolKey({ chainSymbol, poolAddress })] = poolInfo;\n }\n }\n return poolInfoMap;\n}\n"]}
|
|
@@ -5,6 +5,7 @@ export interface ChainDetailsDTO {
|
|
|
5
5
|
tokens: TokenDTO[];
|
|
6
6
|
chainId: number;
|
|
7
7
|
bridgeAddress: string;
|
|
8
|
+
oftBridgeAddress?: string;
|
|
8
9
|
transferTime: TransferTimeDTO;
|
|
9
10
|
txCostAmount: TxCostAmountDTO;
|
|
10
11
|
confirmations: number;
|
|
@@ -25,6 +26,7 @@ export interface TokenDTO {
|
|
|
25
26
|
poolAddress: string;
|
|
26
27
|
tokenAddress: string;
|
|
27
28
|
poolInfo: PoolInfoDTO;
|
|
29
|
+
oftId?: string;
|
|
28
30
|
feeShare: string;
|
|
29
31
|
apr: string;
|
|
30
32
|
apr7d: string;
|
|
@@ -48,7 +50,8 @@ export declare enum MessengerKeyDTO {
|
|
|
48
50
|
ALLBRIDGE = "allbridge",
|
|
49
51
|
WORMHOLE = "wormhole",
|
|
50
52
|
CCTP = "cctp",
|
|
51
|
-
CCTP_V2 = "cctpV2"
|
|
53
|
+
CCTP_V2 = "cctpV2",
|
|
54
|
+
OFT = "oft"
|
|
52
55
|
}
|
|
53
56
|
export type TransferTimeDTO = Record<string, MessengerTransferTimeDTO>;
|
|
54
57
|
export interface TxCostAmountDTO {
|
|
@@ -63,17 +66,20 @@ export declare enum Messenger {
|
|
|
63
66
|
ALLBRIDGE = 1,
|
|
64
67
|
WORMHOLE = 2,
|
|
65
68
|
CCTP = 3,
|
|
66
|
-
CCTP_V2 = 4
|
|
69
|
+
CCTP_V2 = 4,
|
|
70
|
+
OFT = 5
|
|
67
71
|
}
|
|
68
72
|
export interface ReceiveTransactionCostRequest {
|
|
69
73
|
sourceChainId: number;
|
|
70
74
|
destinationChainId: number;
|
|
71
75
|
messenger: Messenger;
|
|
76
|
+
sourceToken?: string;
|
|
72
77
|
}
|
|
73
78
|
export interface ReceiveTransactionCostResponse {
|
|
74
79
|
exchangeRate: string;
|
|
75
80
|
fee: string;
|
|
76
81
|
sourceNativeTokenPrice: string;
|
|
82
|
+
adminFeeShareWithExtras?: string;
|
|
77
83
|
}
|
|
78
84
|
export interface GasBalanceResponse {
|
|
79
85
|
gasBalance: string | null;
|
|
@@ -16,6 +16,7 @@ var MessengerKeyDTO;
|
|
|
16
16
|
MessengerKeyDTO["WORMHOLE"] = "wormhole";
|
|
17
17
|
MessengerKeyDTO["CCTP"] = "cctp";
|
|
18
18
|
MessengerKeyDTO["CCTP_V2"] = "cctpV2";
|
|
19
|
+
MessengerKeyDTO["OFT"] = "oft";
|
|
19
20
|
})(MessengerKeyDTO || (exports.MessengerKeyDTO = MessengerKeyDTO = {}));
|
|
20
21
|
var Messenger;
|
|
21
22
|
(function (Messenger) {
|
|
@@ -23,5 +24,6 @@ var Messenger;
|
|
|
23
24
|
Messenger[Messenger["WORMHOLE"] = 2] = "WORMHOLE";
|
|
24
25
|
Messenger[Messenger["CCTP"] = 3] = "CCTP";
|
|
25
26
|
Messenger[Messenger["CCTP_V2"] = 4] = "CCTP_V2";
|
|
27
|
+
Messenger[Messenger["OFT"] = 5] = "OFT";
|
|
26
28
|
})(Messenger || (exports.Messenger = Messenger = {}));
|
|
27
29
|
//# sourceMappingURL=core-api.model.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-api.model.js","sourceRoot":"","sources":["../../../../src/client/core-api/core-api.model.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"core-api.model.js","sourceRoot":"","sources":["../../../../src/client/core-api/core-api.model.ts"],"names":[],"mappings":";;;AAgBA,IAAY,aAOX;AAPD,WAAY,aAAa;IACvB,0BAAS,CAAA;IACT,oCAAmB,CAAA;IACnB,wCAAuB,CAAA;IACvB,gDAA+B,CAAA;IAC/B,sDAAqC,CAAA;IACrC,kFAAiE,CAAA;AACnE,CAAC,EAPW,aAAa,6BAAb,aAAa,QAOxB;AA+BD,IAAY,eAMX;AAND,WAAY,eAAe;IACzB,0CAAuB,CAAA;IACvB,wCAAqB,CAAA;IACrB,gCAAa,CAAA;IACb,qCAAkB,CAAA;IAClB,8BAAW,CAAA;AACb,CAAC,EANW,eAAe,+BAAf,eAAe,QAM1B;AAcD,IAAY,SAMX;AAND,WAAY,SAAS;IACnB,mDAAa,CAAA;IACb,iDAAY,CAAA;IACZ,yCAAQ,CAAA;IACR,+CAAW,CAAA;IACX,uCAAO,CAAA;AACT,CAAC,EANW,SAAS,yBAAT,SAAS,QAMpB","sourcesContent":["import { ChainSymbol } from \"../../chains/chain.enums\";\nimport { PoolInfo, SuiAddresses } from \"../../tokens-info\";\n\nexport type ChainDetailsResponse = Record<string, ChainDetailsDTO>;\n\nexport interface ChainDetailsDTO {\n tokens: TokenDTO[];\n chainId: number;\n bridgeAddress: string;\n oftBridgeAddress?: string;\n transferTime: TransferTimeDTO;\n txCostAmount: TxCostAmountDTO;\n confirmations: number;\n suiAddresses?: SuiAddresses;\n}\n\nexport enum AddressStatus {\n OK = \"OK\",\n INVALID = \"INVALID\",\n FORBIDDEN = \"FORBIDDEN\",\n UNINITIALIZED = \"UNINITIALIZED\",\n CONTRACT_ADDRESS = \"CONTRACT_ADDRESS\",\n WRONG_ASSOCIATED_ACCOUNT_OWNER = \"WRONG_ASSOCIATED_ACCOUNT_OWNER\",\n}\n\nexport interface TokenDTO {\n symbol: string;\n name: string;\n decimals: number;\n poolAddress: string;\n tokenAddress: string;\n poolInfo: PoolInfoDTO;\n oftId?: string;\n feeShare: string;\n apr: string;\n apr7d: string;\n apr30d: string;\n lpRate: string;\n flags: {\n swap: boolean;\n pool: boolean;\n };\n}\n\nexport interface PoolInfoDTO {\n aValue: string;\n dValue: string;\n tokenBalance: string;\n vUsdBalance: string;\n totalLpAmount: string;\n accRewardPerShareP: string;\n p: number;\n}\n\nexport enum MessengerKeyDTO {\n ALLBRIDGE = \"allbridge\",\n WORMHOLE = \"wormhole\",\n CCTP = \"cctp\",\n CCTP_V2 = \"cctpV2\",\n OFT = \"oft\",\n}\n\nexport type TransferTimeDTO = Record<string, MessengerTransferTimeDTO>;\n\nexport interface TxCostAmountDTO {\n maxAmount: string;\n swap: string;\n transfer: string;\n}\n\nexport type MessengerTransferTimeDTO = {\n [messenger in MessengerKeyDTO]: number;\n};\n\nexport enum Messenger {\n ALLBRIDGE = 1,\n WORMHOLE = 2,\n CCTP = 3,\n CCTP_V2 = 4,\n OFT = 5,\n}\n\nexport interface ReceiveTransactionCostRequest {\n sourceChainId: number;\n destinationChainId: number;\n messenger: Messenger;\n sourceToken?: string;\n}\n\nexport interface ReceiveTransactionCostResponse {\n exchangeRate: string;\n fee: string;\n sourceNativeTokenPrice: string;\n adminFeeShareWithExtras?: string;\n}\n\nexport interface GasBalanceResponse {\n gasBalance: string | null;\n status: AddressStatus;\n}\n\nexport interface CheckAddressResponse {\n gasBalance: string | null;\n status: AddressStatus;\n}\n\nexport interface TransferStatusResponse {\n txId: string;\n\n sourceChainSymbol: ChainSymbol;\n destinationChainSymbol: ChainSymbol;\n\n sendAmount: string;\n sendAmountFormatted: number;\n\n stableFee: string;\n stableFeeFormatted: number;\n\n sourceTokenAddress: string;\n destinationTokenAddress: string;\n\n originSourceTokenAddress?: string;\n originDestinationTokenAddress?: string;\n\n senderAddress: string;\n recipientAddress: string;\n\n signaturesCount: number;\n signaturesNeeded: number;\n\n send: BridgeTransaction;\n receive?: BridgeTransaction;\n\n responseTime?: number;\n}\n\nexport interface BridgeTransaction {\n txId: string;\n\n sourceChainId: number;\n destinationChainId: number;\n\n fee: string;\n feeFormatted: number;\n\n stableFee: string;\n stableFeeFormatted: number;\n\n amount: string;\n amountFormatted: number;\n virtualAmount: string;\n\n bridgeContract: string;\n sender: string;\n recipient: string;\n\n sourceTokenAddress: string;\n destinationTokenAddress: string;\n\n originSourceTokenAddress?: string;\n originDestinationTokenAddress?: string;\n\n hash: string;\n\n messenger: Messenger;\n\n blockTime: number;\n blockId: string;\n\n confirmations: number;\n confirmationsNeeded: number;\n\n isClaimable?: boolean;\n}\n\nexport type PoolInfoResponse = Record<ChainSymbol, PoolInfo>;\nexport type PendingInfoResponse = Partial<Record<ChainSymbol, TokenPendingInfoDTO>>;\nexport type TokenPendingInfoDTO = Record<string, PendingInfoDTO>;\n\nexport interface PendingInfoDTO {\n pendingTxs: number;\n totalSentAmount: string;\n}\n"]}
|
|
@@ -47,6 +47,9 @@ export declare class NodeRpcUrlNotInitializedError extends SdkRootError {
|
|
|
47
47
|
export declare class CCTPDoesNotSupportedError extends SdkRootError {
|
|
48
48
|
constructor(message?: string);
|
|
49
49
|
}
|
|
50
|
+
export declare class OFTDoesNotSupportedError extends SdkRootError {
|
|
51
|
+
constructor(message?: string);
|
|
52
|
+
}
|
|
50
53
|
export declare class TxTooLargeError extends SdkRootError {
|
|
51
54
|
constructor();
|
|
52
55
|
}
|
|
@@ -66,5 +69,6 @@ export declare enum ErrorCode {
|
|
|
66
69
|
TIMEOUT_ERROR = "TimeoutError",
|
|
67
70
|
NODE_RPC_URL_NOT_INITIALIZED_ERROR = "NodeRpcUrlNotInitializedError",
|
|
68
71
|
CCTP_DOES_NOT_SUPPORTED_ERROR = "CCTPDoesNotSupportedError",
|
|
72
|
+
OFT_DOES_NOT_SUPPORTED_ERROR = "OFTDoesNotSupportedError",
|
|
69
73
|
TX_TOO_LARGE = "TxTooLargeError"
|
|
70
74
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ErrorCode = exports.TxTooLargeError = exports.CCTPDoesNotSupportedError = exports.NodeRpcUrlNotInitializedError = exports.TimeoutError = exports.ArgumentInvalidDecimalsError = exports.ExtraGasMaxLimitExceededError = exports.InvalidTxError = exports.VerifyTxError = exports.MethodNotSupportedError = exports.InvalidMessengerOptionError = exports.InvalidGasFeePaymentOptionError = exports.JupiterError = exports.InsufficientPoolLiquidityError = exports.AmountNotEnoughError = exports.InvalidAmountError = exports.SdkError = exports.SdkRootError = void 0;
|
|
3
|
+
exports.ErrorCode = exports.TxTooLargeError = exports.OFTDoesNotSupportedError = exports.CCTPDoesNotSupportedError = exports.NodeRpcUrlNotInitializedError = exports.TimeoutError = exports.ArgumentInvalidDecimalsError = exports.ExtraGasMaxLimitExceededError = exports.InvalidTxError = exports.VerifyTxError = exports.MethodNotSupportedError = exports.InvalidMessengerOptionError = exports.InvalidGasFeePaymentOptionError = exports.JupiterError = exports.InsufficientPoolLiquidityError = exports.AmountNotEnoughError = exports.InvalidAmountError = exports.SdkError = exports.SdkRootError = void 0;
|
|
4
4
|
class SdkRootError extends Error {
|
|
5
5
|
errorCode;
|
|
6
6
|
constructor(code, message) {
|
|
@@ -99,6 +99,12 @@ class CCTPDoesNotSupportedError extends SdkRootError {
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
exports.CCTPDoesNotSupportedError = CCTPDoesNotSupportedError;
|
|
102
|
+
class OFTDoesNotSupportedError extends SdkRootError {
|
|
103
|
+
constructor(message) {
|
|
104
|
+
super(ErrorCode.OFT_DOES_NOT_SUPPORTED_ERROR, message);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
exports.OFTDoesNotSupportedError = OFTDoesNotSupportedError;
|
|
102
108
|
class TxTooLargeError extends SdkRootError {
|
|
103
109
|
constructor() {
|
|
104
110
|
super(ErrorCode.TX_TOO_LARGE, "Transaction too large: try again later or switch to another messenger or pay relayer fee in native gas currency");
|
|
@@ -122,6 +128,7 @@ var ErrorCode;
|
|
|
122
128
|
ErrorCode["TIMEOUT_ERROR"] = "TimeoutError";
|
|
123
129
|
ErrorCode["NODE_RPC_URL_NOT_INITIALIZED_ERROR"] = "NodeRpcUrlNotInitializedError";
|
|
124
130
|
ErrorCode["CCTP_DOES_NOT_SUPPORTED_ERROR"] = "CCTPDoesNotSupportedError";
|
|
131
|
+
ErrorCode["OFT_DOES_NOT_SUPPORTED_ERROR"] = "OFTDoesNotSupportedError";
|
|
125
132
|
ErrorCode["TX_TOO_LARGE"] = "TxTooLargeError";
|
|
126
133
|
})(ErrorCode || (exports.ErrorCode = ErrorCode = {}));
|
|
127
134
|
//# sourceMappingURL=exceptions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exceptions.js","sourceRoot":"","sources":["../../../src/exceptions/exceptions.ts"],"names":[],"mappings":";;;AAAA,MAAsB,YAAa,SAAQ,KAAK;IACvC,SAAS,CAAY;IAE5B,YAAsB,IAAe,EAAE,OAAgB;QACrD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;CACF;AAPD,oCAOC;AAED,MAAa,QAAS,SAAQ,YAAY;IACxC,YAAY,OAAgB;QAC1B,KAAK,CAAC,SAAS,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC;CACF;AAJD,4BAIC;AAED,MAAa,kBAAmB,SAAQ,YAAY;IAClD,YAAY,OAAgB;QAC1B,KAAK,CAAC,SAAS,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC;IACjD,CAAC;CACF;AAJD,gDAIC;AAED,MAAa,oBAAqB,SAAQ,YAAY;IACpD,YAAY,OAAgB;QAC1B,KAAK,CAAC,SAAS,CAAC,uBAAuB,EAAE,OAAO,CAAC,CAAC;IACpD,CAAC;CACF;AAJD,oDAIC;AAED,MAAa,8BAA+B,SAAQ,YAAY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EAA8D,CAAA;IAC9D,mEAAsD,CAAA;IACtD,8CAAiC,CAAA;IACjC,gDAAmC,CAAA;IACnC,iFAAoE,CAAA;IACpE,6EAAgE,CAAA;IAChE,2CAA8B,CAAA;IAC9B,iFAAoE,CAAA;IACpE,wEAA2D,CAAA;IAC3D,sEAAyD,CAAA;IACzD,6CAAgC,CAAA;AAClC,CAAC,EAlBW,SAAS,yBAAT,SAAS,QAkBpB","sourcesContent":["export abstract class SdkRootError extends Error {\n public errorCode: ErrorCode;\n\n protected constructor(code: ErrorCode, message?: string) {\n super(message);\n this.errorCode = code;\n }\n}\n\nexport class SdkError extends SdkRootError {\n constructor(message?: string) {\n super(ErrorCode.SDK_ERROR, message);\n }\n}\n\nexport class InvalidAmountError extends SdkRootError {\n constructor(message?: string) {\n super(ErrorCode.INVALID_AMOUNT_ERROR, message);\n }\n}\n\nexport class AmountNotEnoughError extends SdkRootError {\n constructor(message?: string) {\n super(ErrorCode.AMOUNT_NOT_ENOUGH_ERROR, message);\n }\n}\n\nexport class InsufficientPoolLiquidityError extends SdkRootError {\n constructor(message?: string) {\n super(ErrorCode.INSUFFICIENT_POOL_LIQUIDITY_ERROR, message);\n }\n}\n\nexport class JupiterError extends SdkRootError {\n constructor(message?: string) {\n super(ErrorCode.JUPITER_ERROR, message);\n }\n}\n\nexport class InvalidGasFeePaymentOptionError extends SdkRootError {\n constructor(message?: string) {\n super(ErrorCode.INVALID_GAS_FEE_PAYMENT_OPTION_ERROR, message);\n }\n}\n\nexport class InvalidMessengerOptionError extends SdkRootError {\n constructor(message?: string) {\n super(ErrorCode.INVALID_MESSENGER_OPTION_ERROR, message);\n }\n}\n\nexport class MethodNotSupportedError extends SdkRootError {\n constructor(message?: string) {\n super(ErrorCode.METHOD_NOT_SUPPORTED_ERROR, message);\n }\n}\n\nexport class VerifyTxError extends SdkRootError {\n constructor(message?: string) {\n super(ErrorCode.VERIFY_TX_ERROR, message);\n }\n}\n\nexport class InvalidTxError extends SdkRootError {\n constructor(message?: string) {\n super(ErrorCode.INVALID_TX_ERROR, message);\n }\n}\n\nexport class ExtraGasMaxLimitExceededError extends SdkRootError {\n constructor(message?: string) {\n super(ErrorCode.EXTRA_GAS_MAX_LIMIT_EXCEEDED_ERROR, message);\n }\n}\n\nexport class ArgumentInvalidDecimalsError extends SdkRootError {\n constructor(argName: string, decimalsIs: number, decimalsRequired: number) {\n super(\n ErrorCode.ARGUMENT_INVALID_DECIMALS_ERROR,\n `Argument '${argName}' decimals '${decimalsIs}' cannot be greater than '${decimalsRequired}'`\n );\n }\n}\n\nexport class TimeoutError extends SdkRootError {\n constructor(message?: string) {\n super(ErrorCode.TIMEOUT_ERROR, message);\n }\n}\n\nexport class NodeRpcUrlNotInitializedError extends SdkRootError {\n constructor(chainSymbol: string) {\n super(ErrorCode.NODE_RPC_URL_NOT_INITIALIZED_ERROR, `For chain '${chainSymbol}' Node RPC URL not initialized`);\n }\n}\n\nexport class CCTPDoesNotSupportedError extends SdkRootError {\n constructor(message?: string) {\n super(ErrorCode.CCTP_DOES_NOT_SUPPORTED_ERROR, message);\n }\n}\n\nexport class OFTDoesNotSupportedError extends SdkRootError {\n constructor(message?: string) {\n super(ErrorCode.OFT_DOES_NOT_SUPPORTED_ERROR, message);\n }\n}\n\nexport class TxTooLargeError extends SdkRootError {\n constructor() {\n super(\n ErrorCode.TX_TOO_LARGE,\n \"Transaction too large: try again later or switch to another messenger or pay relayer fee in native gas currency\"\n );\n }\n}\n\nexport enum ErrorCode {\n SDK_ERROR = \"SdkError\",\n INVALID_AMOUNT_ERROR = \"InvalidAmountError\",\n AMOUNT_NOT_ENOUGH_ERROR = \"AmountNotEnoughError\",\n INSUFFICIENT_POOL_LIQUIDITY_ERROR = \"InsufficientPoolLiquidityError\",\n JUPITER_ERROR = \"JupiterError\",\n INVALID_GAS_FEE_PAYMENT_OPTION_ERROR = \"InvalidGasFeePaymentOptionError\",\n INVALID_MESSENGER_OPTION_ERROR = \"InvalidMessengerOptionError\",\n METHOD_NOT_SUPPORTED_ERROR = \"MethodNotSupportedError\",\n VERIFY_TX_ERROR = \"VerifyTxError\",\n INVALID_TX_ERROR = \"InvalidTxError\",\n EXTRA_GAS_MAX_LIMIT_EXCEEDED_ERROR = \"ExtraGasMaxLimitExceededError\",\n ARGUMENT_INVALID_DECIMALS_ERROR = \"ArgumentInvalidDecimalsError\",\n TIMEOUT_ERROR = \"TimeoutError\",\n NODE_RPC_URL_NOT_INITIALIZED_ERROR = \"NodeRpcUrlNotInitializedError\",\n CCTP_DOES_NOT_SUPPORTED_ERROR = \"CCTPDoesNotSupportedError\",\n OFT_DOES_NOT_SUPPORTED_ERROR = \"OFTDoesNotSupportedError\",\n TX_TOO_LARGE = \"TxTooLargeError\",\n}\n"]}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -196,13 +196,11 @@ export declare class AllbridgeCoreSdk {
|
|
|
196
196
|
* @param amountToSendFloat the amount of tokens that will be sent
|
|
197
197
|
* @param sourceChainToken selected token on the source chain
|
|
198
198
|
* @param destinationChainToken selected token on the destination chain
|
|
199
|
-
* @param messenger
|
|
199
|
+
* @param messenger selected messenger
|
|
200
200
|
*/
|
|
201
201
|
getAmountToBeReceived(amountToSendFloat: BigSource, sourceChainToken: TokenWithChainDetails, destinationChainToken: TokenWithChainDetails,
|
|
202
202
|
/**
|
|
203
203
|
* The Messengers for different routes.
|
|
204
|
-
* Optional.
|
|
205
|
-
* The {@link Messenger.ALLBRIDGE}, {@link Messenger.WORMHOLE} by default.
|
|
206
204
|
*/
|
|
207
205
|
messenger?: Messenger): Promise<string>;
|
|
208
206
|
/**
|
|
@@ -210,15 +208,13 @@ export declare class AllbridgeCoreSdk {
|
|
|
210
208
|
* @param amountToSendFloat the amount of tokens that will be sent
|
|
211
209
|
* @param sourceChainToken selected token on the source chain
|
|
212
210
|
* @param destinationChainToken selected token on the destination chain
|
|
213
|
-
* @param messenger
|
|
211
|
+
* @param messenger selected messenger
|
|
214
212
|
* @param sourceProvider Optional. source chain Provider
|
|
215
213
|
* @param destinationProvider Optional. destination chain Provider
|
|
216
214
|
*/
|
|
217
215
|
getAmountToBeReceivedFromChain(amountToSendFloat: BigSource, sourceChainToken: TokenWithChainDetails, destinationChainToken: TokenWithChainDetails,
|
|
218
216
|
/**
|
|
219
217
|
* The Messengers for different routes.
|
|
220
|
-
* Optional.
|
|
221
|
-
* The {@link Messenger.ALLBRIDGE}, {@link Messenger.WORMHOLE} by default.
|
|
222
218
|
*/
|
|
223
219
|
messenger?: Messenger, sourceProvider?: Provider, destinationProvider?: Provider): Promise<string>;
|
|
224
220
|
/**
|
|
@@ -228,21 +224,19 @@ export declare class AllbridgeCoreSdk {
|
|
|
228
224
|
* @param destinationChainToken selected token on the destination chain
|
|
229
225
|
* @param sourcePool source token pool state
|
|
230
226
|
* @param destinationPool destination token pool state
|
|
231
|
-
* @param messenger
|
|
227
|
+
* @param messenger selected messenger
|
|
232
228
|
*/
|
|
233
|
-
getAmountToBeReceivedFromPools(amountToSendFloat: BigSource, sourceChainToken: TokenWithChainDetails, destinationChainToken: TokenWithChainDetails, sourcePool: PoolInfo, destinationPool: PoolInfo, messenger?: Messenger): string;
|
|
229
|
+
getAmountToBeReceivedFromPools(amountToSendFloat: BigSource, sourceChainToken: TokenWithChainDetails, destinationChainToken: TokenWithChainDetails, sourcePool: PoolInfo, destinationPool: PoolInfo, messenger?: Exclude<Messenger, Messenger.OFT>): string;
|
|
234
230
|
/**
|
|
235
231
|
* Calculates the amount of tokens to send based on requested tokens amount be received as a result of transfer.
|
|
236
232
|
* @param amountToBeReceivedFloat the amount of tokens that should be received
|
|
237
233
|
* @param sourceChainToken selected token on the source chain
|
|
238
234
|
* @param destinationChainToken selected token on the destination chain
|
|
239
|
-
* @param messenger
|
|
235
|
+
* @param messenger selected messenger
|
|
240
236
|
*/
|
|
241
237
|
getAmountToSend(amountToBeReceivedFloat: BigSource, sourceChainToken: TokenWithChainDetails, destinationChainToken: TokenWithChainDetails,
|
|
242
238
|
/**
|
|
243
239
|
* The Messengers for different routes.
|
|
244
|
-
* Optional.
|
|
245
|
-
* The {@link Messenger.ALLBRIDGE}, {@link Messenger.WORMHOLE} by default.
|
|
246
240
|
*/
|
|
247
241
|
messenger?: Messenger): Promise<string>;
|
|
248
242
|
/**
|
|
@@ -250,15 +244,13 @@ export declare class AllbridgeCoreSdk {
|
|
|
250
244
|
* @param amountToBeReceivedFloat the amount of tokens that should be received
|
|
251
245
|
* @param sourceChainToken selected token on the source chain
|
|
252
246
|
* @param destinationChainToken selected token on the destination chain
|
|
253
|
-
* @param messenger
|
|
247
|
+
* @param messenger selected messenger
|
|
254
248
|
* @param sourceProvider Optional. source chain Provider
|
|
255
249
|
* @param destinationProvider Optional. destination chain Provider
|
|
256
250
|
*/
|
|
257
251
|
getAmountToSendFromChain(amountToBeReceivedFloat: BigSource, sourceChainToken: TokenWithChainDetails, destinationChainToken: TokenWithChainDetails,
|
|
258
252
|
/**
|
|
259
253
|
* The Messengers for different routes.
|
|
260
|
-
* Optional.
|
|
261
|
-
* The {@link Messenger.ALLBRIDGE}, {@link Messenger.WORMHOLE} by default.
|
|
262
254
|
*/
|
|
263
255
|
messenger?: Messenger, sourceProvider?: Provider, destinationProvider?: Provider): Promise<string>;
|
|
264
256
|
/**
|
|
@@ -268,9 +260,9 @@ export declare class AllbridgeCoreSdk {
|
|
|
268
260
|
* @param destinationChainToken selected token on the destination chain
|
|
269
261
|
* @param sourcePool source token pool state
|
|
270
262
|
* @param destinationPool destination token pool state
|
|
271
|
-
* @param messenger
|
|
263
|
+
* @param messenger selected messenger
|
|
272
264
|
*/
|
|
273
|
-
getAmountToSendFromPools(amountToBeReceivedFloat: BigSource, sourceChainToken: TokenWithChainDetails, destinationChainToken: TokenWithChainDetails, sourcePool: PoolInfo, destinationPool: PoolInfo, messenger?: Messenger): string;
|
|
265
|
+
getAmountToSendFromPools(amountToBeReceivedFloat: BigSource, sourceChainToken: TokenWithChainDetails, destinationChainToken: TokenWithChainDetails, sourcePool: PoolInfo, destinationPool: PoolInfo, messenger?: Exclude<Messenger, Messenger.OFT>): string;
|
|
274
266
|
/**
|
|
275
267
|
* Fetches possible ways to pay the transfer gas fee.
|
|
276
268
|
* @param sourceChainToken selected token on the source chain
|
|
@@ -311,9 +303,10 @@ export declare class AllbridgeCoreSdk {
|
|
|
311
303
|
* Get possible limit of extra gas amount.
|
|
312
304
|
* @param sourceChainToken selected token on the source chain
|
|
313
305
|
* @param destinationChainToken selected token on the destination chain
|
|
306
|
+
* @param messenger selected Messenger, Allbridge by default
|
|
314
307
|
* @returns {@link ExtraGasMaxLimitResponse}
|
|
315
308
|
*/
|
|
316
|
-
getExtraGasMaxLimits(sourceChainToken: TokenWithChainDetails, destinationChainToken: TokenWithChainDetails): Promise<ExtraGasMaxLimitResponse>;
|
|
309
|
+
getExtraGasMaxLimits(sourceChainToken: TokenWithChainDetails, destinationChainToken: TokenWithChainDetails, messenger?: Messenger): Promise<ExtraGasMaxLimitResponse>;
|
|
317
310
|
/**
|
|
318
311
|
* @param amount - amount
|
|
319
312
|
* @param amountFormat - AmountFormat
|
package/dist/src/index.js
CHANGED
|
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.AllbridgeCoreSdk = void 0;
|
|
18
18
|
const configs_1 = require("./configs");
|
|
19
|
+
const models_1 = require("./models");
|
|
19
20
|
const services_1 = require("./services");
|
|
20
21
|
const utils_1 = require("./utils");
|
|
21
22
|
__exportStar(require("./configs"), exports);
|
|
@@ -196,15 +197,13 @@ class AllbridgeCoreSdk {
|
|
|
196
197
|
* @param amountToSendFloat the amount of tokens that will be sent
|
|
197
198
|
* @param sourceChainToken selected token on the source chain
|
|
198
199
|
* @param destinationChainToken selected token on the destination chain
|
|
199
|
-
* @param messenger
|
|
200
|
+
* @param messenger selected messenger
|
|
200
201
|
*/
|
|
201
202
|
async getAmountToBeReceived(amountToSendFloat, sourceChainToken, destinationChainToken,
|
|
202
203
|
/**
|
|
203
204
|
* The Messengers for different routes.
|
|
204
|
-
* Optional.
|
|
205
|
-
* The {@link Messenger.ALLBRIDGE}, {@link Messenger.WORMHOLE} by default.
|
|
206
205
|
*/
|
|
207
|
-
messenger) {
|
|
206
|
+
messenger = models_1.Messenger.ALLBRIDGE) {
|
|
208
207
|
return this.service.getAmountToBeReceived(amountToSendFloat, sourceChainToken, destinationChainToken, messenger);
|
|
209
208
|
}
|
|
210
209
|
/**
|
|
@@ -212,17 +211,15 @@ class AllbridgeCoreSdk {
|
|
|
212
211
|
* @param amountToSendFloat the amount of tokens that will be sent
|
|
213
212
|
* @param sourceChainToken selected token on the source chain
|
|
214
213
|
* @param destinationChainToken selected token on the destination chain
|
|
215
|
-
* @param messenger
|
|
214
|
+
* @param messenger selected messenger
|
|
216
215
|
* @param sourceProvider Optional. source chain Provider
|
|
217
216
|
* @param destinationProvider Optional. destination chain Provider
|
|
218
217
|
*/
|
|
219
218
|
async getAmountToBeReceivedFromChain(amountToSendFloat, sourceChainToken, destinationChainToken,
|
|
220
219
|
/**
|
|
221
220
|
* The Messengers for different routes.
|
|
222
|
-
* Optional.
|
|
223
|
-
* The {@link Messenger.ALLBRIDGE}, {@link Messenger.WORMHOLE} by default.
|
|
224
221
|
*/
|
|
225
|
-
messenger, sourceProvider, destinationProvider) {
|
|
222
|
+
messenger = models_1.Messenger.ALLBRIDGE, sourceProvider, destinationProvider) {
|
|
226
223
|
return this.service.getAmountToBeReceivedFromChain(amountToSendFloat, sourceChainToken, destinationChainToken, messenger, sourceProvider, destinationProvider);
|
|
227
224
|
}
|
|
228
225
|
/**
|
|
@@ -232,25 +229,30 @@ class AllbridgeCoreSdk {
|
|
|
232
229
|
* @param destinationChainToken selected token on the destination chain
|
|
233
230
|
* @param sourcePool source token pool state
|
|
234
231
|
* @param destinationPool destination token pool state
|
|
235
|
-
* @param messenger
|
|
236
|
-
*/
|
|
237
|
-
getAmountToBeReceivedFromPools(amountToSendFloat, sourceChainToken, destinationChainToken, sourcePool, destinationPool, messenger) {
|
|
238
|
-
|
|
232
|
+
* @param messenger selected messenger
|
|
233
|
+
*/
|
|
234
|
+
getAmountToBeReceivedFromPools(amountToSendFloat, sourceChainToken, destinationChainToken, sourcePool, destinationPool, messenger = models_1.Messenger.ALLBRIDGE) {
|
|
235
|
+
switch (messenger) {
|
|
236
|
+
case models_1.Messenger.ALLBRIDGE:
|
|
237
|
+
case models_1.Messenger.WORMHOLE:
|
|
238
|
+
return this.service.getAmountToBeReceivedComputeWithPools(amountToSendFloat, sourceChainToken, destinationChainToken, sourcePool, destinationPool);
|
|
239
|
+
case models_1.Messenger.CCTP:
|
|
240
|
+
case models_1.Messenger.CCTP_V2:
|
|
241
|
+
return this.service.getAmountToBeReceivedComputeCctp(amountToSendFloat, sourceChainToken, destinationChainToken, messenger);
|
|
242
|
+
}
|
|
239
243
|
}
|
|
240
244
|
/**
|
|
241
245
|
* Calculates the amount of tokens to send based on requested tokens amount be received as a result of transfer.
|
|
242
246
|
* @param amountToBeReceivedFloat the amount of tokens that should be received
|
|
243
247
|
* @param sourceChainToken selected token on the source chain
|
|
244
248
|
* @param destinationChainToken selected token on the destination chain
|
|
245
|
-
* @param messenger
|
|
249
|
+
* @param messenger selected messenger
|
|
246
250
|
*/
|
|
247
251
|
async getAmountToSend(amountToBeReceivedFloat, sourceChainToken, destinationChainToken,
|
|
248
252
|
/**
|
|
249
253
|
* The Messengers for different routes.
|
|
250
|
-
* Optional.
|
|
251
|
-
* The {@link Messenger.ALLBRIDGE}, {@link Messenger.WORMHOLE} by default.
|
|
252
254
|
*/
|
|
253
|
-
messenger) {
|
|
255
|
+
messenger = models_1.Messenger.ALLBRIDGE) {
|
|
254
256
|
return this.service.getAmountToSend(amountToBeReceivedFloat, sourceChainToken, destinationChainToken, messenger);
|
|
255
257
|
}
|
|
256
258
|
/**
|
|
@@ -258,17 +260,15 @@ class AllbridgeCoreSdk {
|
|
|
258
260
|
* @param amountToBeReceivedFloat the amount of tokens that should be received
|
|
259
261
|
* @param sourceChainToken selected token on the source chain
|
|
260
262
|
* @param destinationChainToken selected token on the destination chain
|
|
261
|
-
* @param messenger
|
|
263
|
+
* @param messenger selected messenger
|
|
262
264
|
* @param sourceProvider Optional. source chain Provider
|
|
263
265
|
* @param destinationProvider Optional. destination chain Provider
|
|
264
266
|
*/
|
|
265
267
|
async getAmountToSendFromChain(amountToBeReceivedFloat, sourceChainToken, destinationChainToken,
|
|
266
268
|
/**
|
|
267
269
|
* The Messengers for different routes.
|
|
268
|
-
* Optional.
|
|
269
|
-
* The {@link Messenger.ALLBRIDGE}, {@link Messenger.WORMHOLE} by default.
|
|
270
270
|
*/
|
|
271
|
-
messenger, sourceProvider, destinationProvider) {
|
|
271
|
+
messenger = models_1.Messenger.ALLBRIDGE, sourceProvider, destinationProvider) {
|
|
272
272
|
return this.service.getAmountToSendFromChain(amountToBeReceivedFloat, sourceChainToken, destinationChainToken, messenger, sourceProvider, destinationProvider);
|
|
273
273
|
}
|
|
274
274
|
/**
|
|
@@ -278,10 +278,17 @@ class AllbridgeCoreSdk {
|
|
|
278
278
|
* @param destinationChainToken selected token on the destination chain
|
|
279
279
|
* @param sourcePool source token pool state
|
|
280
280
|
* @param destinationPool destination token pool state
|
|
281
|
-
* @param messenger
|
|
282
|
-
*/
|
|
283
|
-
getAmountToSendFromPools(amountToBeReceivedFloat, sourceChainToken, destinationChainToken, sourcePool, destinationPool, messenger) {
|
|
284
|
-
|
|
281
|
+
* @param messenger selected messenger
|
|
282
|
+
*/
|
|
283
|
+
getAmountToSendFromPools(amountToBeReceivedFloat, sourceChainToken, destinationChainToken, sourcePool, destinationPool, messenger = models_1.Messenger.ALLBRIDGE) {
|
|
284
|
+
switch (messenger) {
|
|
285
|
+
case models_1.Messenger.ALLBRIDGE:
|
|
286
|
+
case models_1.Messenger.WORMHOLE:
|
|
287
|
+
return this.service.getAmountToSendComputeWithPools(amountToBeReceivedFloat, sourceChainToken, destinationChainToken, sourcePool, destinationPool);
|
|
288
|
+
case models_1.Messenger.CCTP:
|
|
289
|
+
case models_1.Messenger.CCTP_V2:
|
|
290
|
+
return this.service.getAmountToSendComputeCctp(amountToBeReceivedFloat, sourceChainToken, destinationChainToken, messenger);
|
|
291
|
+
}
|
|
285
292
|
}
|
|
286
293
|
/**
|
|
287
294
|
* Fetches possible ways to pay the transfer gas fee.
|
|
@@ -333,10 +340,11 @@ class AllbridgeCoreSdk {
|
|
|
333
340
|
* Get possible limit of extra gas amount.
|
|
334
341
|
* @param sourceChainToken selected token on the source chain
|
|
335
342
|
* @param destinationChainToken selected token on the destination chain
|
|
343
|
+
* @param messenger selected Messenger, Allbridge by default
|
|
336
344
|
* @returns {@link ExtraGasMaxLimitResponse}
|
|
337
345
|
*/
|
|
338
|
-
async getExtraGasMaxLimits(sourceChainToken, destinationChainToken) {
|
|
339
|
-
return this.service.getExtraGasMaxLimits(sourceChainToken, destinationChainToken);
|
|
346
|
+
async getExtraGasMaxLimits(sourceChainToken, destinationChainToken, messenger = models_1.Messenger.ALLBRIDGE) {
|
|
347
|
+
return this.service.getExtraGasMaxLimits(sourceChainToken, destinationChainToken, messenger);
|
|
340
348
|
}
|
|
341
349
|
/**
|
|
342
350
|
* @param amount - amount
|