@allbridge/bridge-core-sdk 3.36.0-beta.1 → 3.36.0-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 +2 -2
- package/dist/browser/index.js.map +4 -4
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/index.js.map +4 -4
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +4 -4
- package/dist/src/client/core-api/api-client-caching.d.ts +6 -1
- package/dist/src/client/core-api/api-client-caching.js +11 -0
- package/dist/src/client/core-api/api-client-caching.js.map +1 -1
- package/dist/src/client/core-api/api-client.d.ts +27 -1
- package/dist/src/client/core-api/api-client.js +68 -2
- package/dist/src/client/core-api/api-client.js.map +1 -1
- package/dist/src/client/core-api/core-api-mapper.d.ts +3 -1
- package/dist/src/client/core-api/core-api-mapper.js +6 -3
- package/dist/src/client/core-api/core-api-mapper.js.map +1 -1
- package/dist/src/client/core-api/core-api.model.d.ts +100 -3
- package/dist/src/client/core-api/core-api.model.js +9 -0
- package/dist/src/client/core-api/core-api.model.js.map +1 -1
- package/dist/src/client/core-api/core-client-base.d.ts +7 -1
- package/dist/src/client/core-api/core-client-base.js +9 -0
- package/dist/src/client/core-api/core-client-base.js.map +1 -1
- package/dist/src/client/core-api/core-client-filtered.d.ts +4 -1
- package/dist/src/client/core-api/core-client-filtered.js +9 -0
- package/dist/src/client/core-api/core-client-filtered.js.map +1 -1
- package/dist/src/client/core-api/core-client-pool-info-caching.d.ts +4 -1
- package/dist/src/client/core-api/core-client-pool-info-caching.js +9 -0
- package/dist/src/client/core-api/core-client-pool-info-caching.js.map +1 -1
- package/dist/src/exceptions/exceptions.d.ts +41 -0
- package/dist/src/exceptions/exceptions.js +52 -0
- package/dist/src/exceptions/exceptions.js.map +1 -1
- package/dist/src/index.d.ts +19 -6
- package/dist/src/index.js +6 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/models/index.d.ts +4 -2
- package/dist/src/models/index.js.map +1 -1
- package/dist/src/services/bridge/alg/index.d.ts +5 -1
- package/dist/src/services/bridge/alg/index.js +7 -0
- package/dist/src/services/bridge/alg/index.js.map +1 -1
- package/dist/src/services/bridge/evm/index.d.ts +12 -2
- package/dist/src/services/bridge/evm/index.js +32 -0
- package/dist/src/services/bridge/evm/index.js.map +1 -1
- package/dist/src/services/bridge/index.d.ts +10 -3
- package/dist/src/services/bridge/index.js +27 -3
- package/dist/src/services/bridge/index.js.map +1 -1
- package/dist/src/services/bridge/models/bridge.d.ts +17 -1
- package/dist/src/services/bridge/models/bridge.js +6 -0
- package/dist/src/services/bridge/models/bridge.js.map +1 -1
- package/dist/src/services/bridge/models/bridge.model.d.ts +25 -0
- package/dist/src/services/bridge/models/bridge.model.js.map +1 -1
- package/dist/src/services/bridge/raw-bridge-transaction-builder.d.ts +8 -1
- package/dist/src/services/bridge/raw-bridge-transaction-builder.js +11 -1
- package/dist/src/services/bridge/raw-bridge-transaction-builder.js.map +1 -1
- package/dist/src/services/bridge/sol/bridge-tx-service.js +3 -0
- package/dist/src/services/bridge/sol/bridge-tx-service.js.map +1 -1
- package/dist/src/services/bridge/sol/index.d.ts +14 -1
- package/dist/src/services/bridge/sol/index.js +47 -2
- package/dist/src/services/bridge/sol/index.js.map +1 -1
- package/dist/src/services/bridge/sol/payer-with-token-service.js +3 -0
- package/dist/src/services/bridge/sol/payer-with-token-service.js.map +1 -1
- package/dist/src/services/bridge/spender.js +4 -0
- package/dist/src/services/bridge/spender.js.map +1 -1
- package/dist/src/services/bridge/srb/index.d.ts +9 -1
- package/dist/src/services/bridge/srb/index.js +45 -3
- package/dist/src/services/bridge/srb/index.js.map +1 -1
- package/dist/src/services/bridge/stx/index.d.ts +6 -2
- package/dist/src/services/bridge/stx/index.js +7 -0
- package/dist/src/services/bridge/stx/index.js.map +1 -1
- package/dist/src/services/bridge/sui/index.d.ts +8 -1
- package/dist/src/services/bridge/sui/index.js +24 -0
- package/dist/src/services/bridge/sui/index.js.map +1 -1
- package/dist/src/services/bridge/trx/index.d.ts +11 -1
- package/dist/src/services/bridge/trx/index.js +25 -0
- package/dist/src/services/bridge/trx/index.js.map +1 -1
- package/dist/src/services/bridge/utils.js +4 -1
- package/dist/src/services/bridge/utils.js.map +1 -1
- package/dist/src/services/index.d.ts +10 -0
- package/dist/src/services/index.js +36 -1
- package/dist/src/services/index.js.map +1 -1
- package/dist/src/services/near-intents/index.d.ts +62 -0
- package/dist/src/services/near-intents/index.js +115 -0
- package/dist/src/services/near-intents/index.js.map +1 -0
- package/dist/src/services/near-intents/models.d.ts +169 -0
- package/dist/src/services/near-intents/models.js +2 -0
- package/dist/src/services/near-intents/models.js.map +1 -0
- package/dist/src/services/near-intents/utils.d.ts +34 -0
- package/dist/src/services/near-intents/utils.js +53 -0
- package/dist/src/services/near-intents/utils.js.map +1 -0
- package/dist/src/services/token/evm/index.js +3 -0
- package/dist/src/services/token/evm/index.js.map +1 -1
- package/dist/src/services/token/sol/index.js +3 -0
- package/dist/src/services/token/sol/index.js.map +1 -1
- package/dist/src/services/token/srb/index.js +11 -0
- package/dist/src/services/token/srb/index.js.map +1 -1
- package/dist/src/services/token/sui/index.js +5 -0
- package/dist/src/services/token/sui/index.js.map +1 -1
- package/dist/src/services/token/trx/index.js +3 -0
- package/dist/src/services/token/trx/index.js.map +1 -1
- package/dist/src/tokens-info/tokens-info.model.d.ts +23 -1
- package/dist/src/tokens-info/tokens-info.model.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 +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PoolInfoMap, PoolKeyObject } from "../../tokens-info";
|
|
2
2
|
import { ApiClient, TokenInfo } from "./api-client";
|
|
3
|
-
import { GasBalanceResponse, PendingInfoResponse, ReceiveTransactionCostRequest, ReceiveTransactionCostResponse, TransferStatusResponse } from "./core-api.model";
|
|
3
|
+
import { GasBalanceResponse, NearIntentsDepositRequest, NearIntentsDepositResponse, NearIntentsQuoteRequest, NearIntentsQuoteResponse, NearIntentsSubmitDepositRequest, PendingInfoResponse, ReceiveTransactionCostRequest, ReceiveTransactionCostResponse, TransferStatusResponse } from "./core-api.model";
|
|
4
4
|
export declare class ApiClientCaching implements ApiClient {
|
|
5
5
|
private apiClient;
|
|
6
6
|
private tokenInfoCache;
|
|
@@ -16,4 +16,9 @@ export declare class ApiClientCaching implements ApiClient {
|
|
|
16
16
|
getTransferStatus(chainSymbol: string, txId: string): Promise<TransferStatusResponse>;
|
|
17
17
|
/** @deprecated Do not use. */
|
|
18
18
|
getPoolInfoMap(pools: PoolKeyObject[] | PoolKeyObject): Promise<PoolInfoMap>;
|
|
19
|
+
/** Not cached: every quote is a fresh market price. */
|
|
20
|
+
getNearIntentsQuote(args: NearIntentsQuoteRequest): Promise<NearIntentsQuoteResponse>;
|
|
21
|
+
/** Not cached: every call creates a new one-shot deposit address. */
|
|
22
|
+
createNearIntentsDeposit(args: NearIntentsDepositRequest): Promise<NearIntentsDepositResponse>;
|
|
23
|
+
submitNearIntentsDeposit(args: NearIntentsSubmitDepositRequest): Promise<void>;
|
|
19
24
|
}
|
|
@@ -62,5 +62,16 @@ export class ApiClientCaching {
|
|
|
62
62
|
async getPoolInfoMap(pools) {
|
|
63
63
|
return this.apiClient.getPoolInfoMap(pools);
|
|
64
64
|
}
|
|
65
|
+
/** Not cached: every quote is a fresh market price. */
|
|
66
|
+
async getNearIntentsQuote(args) {
|
|
67
|
+
return this.apiClient.getNearIntentsQuote(args);
|
|
68
|
+
}
|
|
69
|
+
/** Not cached: every call creates a new one-shot deposit address. */
|
|
70
|
+
async createNearIntentsDeposit(args) {
|
|
71
|
+
return this.apiClient.createNearIntentsDeposit(args);
|
|
72
|
+
}
|
|
73
|
+
async submitNearIntentsDeposit(args) {
|
|
74
|
+
return this.apiClient.submitNearIntentsDeposit(args);
|
|
75
|
+
}
|
|
65
76
|
}
|
|
66
77
|
//# sourceMappingURL=api-client-caching.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-client-caching.js","sourceRoot":"","sources":["../../../../src/client/core-api/api-client-caching.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"api-client-caching.js","sourceRoot":"","sources":["../../../../src/client/core-api/api-client-caching.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,aAAa,CAAC;AAgBhC,MAAM,eAAe,GAAG,EAAE,GAAG,IAAI,CAAC;AAClC,MAAM,eAAe,GAAG,EAAE,GAAG,IAAI,CAAC;AAElC,MAAM,OAAO,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,KAAK,CAAC,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC,CAAC;QACjE,IAAI,CAAC,wBAAwB,GAAG,IAAI,KAAK,CAAC,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC,CAAC;QAC3E,IAAI,CAAC,gBAAgB,GAAG,IAAI,KAAK,CAAC,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC,CAAC;QACnE,IAAI,CAAC,eAAe,GAAG,IAAI,KAAK,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,oB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I,CAAC,wBAAwB,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;QAC/E,IAAI,eAAe,EAAE,CAAC;YACpB,OAAO,eAAe,CAAC;QACzB,CAAC;QACD,MAAM,sBAAsB,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,yBAAyB,CAAC,IAAI,CAAC,CAAC;QACpF,IAAI,CAAC,wBAAwB,CAAC,GAAG,CAAC,mBAAmB,EAAE,sBAAsB,CAAC,CAAC;QAC/E,OAAO,sBAAsB,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,WAAmB,EAAE,IAAY;QACvD,OAAO,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;IAC7D,CAAC;IAED,8BAA8B;IAC9B,KAAK,CAAC,cAAc,CAAC,KAAsC;QACzD,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC;IAED,uDAAuD;IACvD,KAAK,CAAC,mBAAmB,CAAC,IAA6B;QACrD,OAAO,IAAI,CAAC,SAAS,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC;IAED,qEAAqE;IACrE,KAAK,CAAC,wBAAwB,CAAC,IAA+B;QAC5D,OAAO,IAAI,CAAC,SAAS,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,wBAAwB,CAAC,IAAqC;QAClE,OAAO,IAAI,CAAC,SAAS,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC;IACvD,CAAC;CACF","sourcesContent":["import Cache from \"timed-cache\";\nimport { PoolInfoMap, PoolKeyObject } from \"../../tokens-info\";\nimport { ApiClient, TokenInfo } from \"./api-client\";\nimport {\n GasBalanceResponse,\n NearIntentsDepositRequest,\n NearIntentsDepositResponse,\n NearIntentsQuoteRequest,\n NearIntentsQuoteResponse,\n NearIntentsSubmitDepositRequest,\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 /** @deprecated Do not use. */\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 /** @deprecated Do not use. */\n async getPoolInfoMap(pools: PoolKeyObject[] | PoolKeyObject): Promise<PoolInfoMap> {\n return this.apiClient.getPoolInfoMap(pools);\n }\n\n /** Not cached: every quote is a fresh market price. */\n async getNearIntentsQuote(args: NearIntentsQuoteRequest): Promise<NearIntentsQuoteResponse> {\n return this.apiClient.getNearIntentsQuote(args);\n }\n\n /** Not cached: every call creates a new one-shot deposit address. */\n async createNearIntentsDeposit(args: NearIntentsDepositRequest): Promise<NearIntentsDepositResponse> {\n return this.apiClient.createNearIntentsDeposit(args);\n }\n\n async submitNearIntentsDeposit(args: NearIntentsSubmitDepositRequest): Promise<void> {\n return this.apiClient.submitNearIntentsDeposit(args);\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ChainDetailsMapWithFlags, PoolInfoMap, PoolKeyObject } from "../../tokens-info";
|
|
2
|
-
import { GasBalanceResponse, PendingInfoResponse, ReceiveTransactionCostRequest, ReceiveTransactionCostResponse, TransferStatusResponse } from "./core-api.model";
|
|
2
|
+
import { GasBalanceResponse, NearIntentsDepositRequest, NearIntentsDepositResponse, NearIntentsQuoteRequest, NearIntentsQuoteResponse, NearIntentsSubmitDepositRequest, PendingInfoResponse, ReceiveTransactionCostRequest, ReceiveTransactionCostResponse, TransferStatusResponse } from "./core-api.model";
|
|
3
3
|
import { AllbridgeCoreClientParams } from "./core-client-base";
|
|
4
4
|
export interface TokenInfo {
|
|
5
5
|
chainDetailsMap: ChainDetailsMapWithFlags;
|
|
@@ -15,7 +15,30 @@ export interface ApiClient {
|
|
|
15
15
|
getReceiveTransactionCost(args: ReceiveTransactionCostRequest): Promise<ReceiveTransactionCostResponse>;
|
|
16
16
|
/** @deprecated Do not use. */
|
|
17
17
|
getPoolInfoMap(pools: PoolKeyObject[] | PoolKeyObject): Promise<PoolInfoMap>;
|
|
18
|
+
/**
|
|
19
|
+
* `POST /near-intents/quote`: a dry NEAR Intents quote, see {@link mapNearIntentsError} for the thrown errors.
|
|
20
|
+
*/
|
|
21
|
+
getNearIntentsQuote(args: NearIntentsQuoteRequest): Promise<NearIntentsQuoteResponse>;
|
|
22
|
+
/**
|
|
23
|
+
* `POST /near-intents/deposit`: a NEAR Intents quote with a one-shot deposit address.
|
|
24
|
+
*/
|
|
25
|
+
createNearIntentsDeposit(args: NearIntentsDepositRequest): Promise<NearIntentsDepositResponse>;
|
|
26
|
+
/**
|
|
27
|
+
* `POST /near-intents/deposit/submit`: notifies NEAR Intents about the deposit transaction.
|
|
28
|
+
*/
|
|
29
|
+
submitNearIntentsDeposit(args: NearIntentsSubmitDepositRequest): Promise<void>;
|
|
18
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Maps an error of a Core API `/near-intents/*` call to a typed SDK error:
|
|
33
|
+
* - HTTP 404 -> {@link NearIntentsDoesNotSupportedError}
|
|
34
|
+
* - `AMOUNT_TOO_LOW` -> {@link NearIntentsAmountTooLowError} (with `minAmount` / `minAmountUsd` when known)
|
|
35
|
+
* - `NO_LIQUIDITY` -> {@link NearIntentsNoLiquidityError}
|
|
36
|
+
* - `FAILED_TO_GET_QUOTE`, `UPSTREAM_ERROR` or HTTP 502 -> {@link NearIntentsQuoteError}
|
|
37
|
+
*
|
|
38
|
+
* Any other error is returned unchanged.
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
export declare function mapNearIntentsError(error: unknown): unknown;
|
|
19
42
|
export declare class ApiClientImpl implements ApiClient {
|
|
20
43
|
private api;
|
|
21
44
|
constructor(params: AllbridgeCoreClientParams);
|
|
@@ -35,4 +58,7 @@ export declare class ApiClientImpl implements ApiClient {
|
|
|
35
58
|
* always resolves to an empty map without calling the server.
|
|
36
59
|
*/
|
|
37
60
|
getPoolInfoMap(_pools: PoolKeyObject[] | PoolKeyObject): Promise<PoolInfoMap>;
|
|
61
|
+
getNearIntentsQuote(args: NearIntentsQuoteRequest): Promise<NearIntentsQuoteResponse>;
|
|
62
|
+
createNearIntentsDeposit(args: NearIntentsDepositRequest): Promise<NearIntentsDepositResponse>;
|
|
63
|
+
submitNearIntentsDeposit(args: NearIntentsSubmitDepositRequest): Promise<void>;
|
|
38
64
|
}
|
|
@@ -1,8 +1,42 @@
|
|
|
1
|
-
import { AxiosHeaders, create } from "axios";
|
|
2
|
-
import { InvalidMessengerOptionError } from "../../exceptions";
|
|
1
|
+
import { AxiosHeaders, create, isAxiosError } from "axios";
|
|
2
|
+
import { InvalidMessengerOptionError, NearIntentsAmountTooLowError, NearIntentsDoesNotSupportedError, NearIntentsNoLiquidityError, NearIntentsQuoteError, } from "../../exceptions";
|
|
3
3
|
import { VERSION } from "../../version";
|
|
4
4
|
import { mapChainDetailsResponseToChainDetailsMap, mapChainDetailsResponseToPoolInfoMap } from "./core-api-mapper";
|
|
5
5
|
import { Messenger, } from "./core-api.model";
|
|
6
|
+
/**
|
|
7
|
+
* Maps an error of a Core API `/near-intents/*` call to a typed SDK error:
|
|
8
|
+
* - HTTP 404 -> {@link NearIntentsDoesNotSupportedError}
|
|
9
|
+
* - `AMOUNT_TOO_LOW` -> {@link NearIntentsAmountTooLowError} (with `minAmount` / `minAmountUsd` when known)
|
|
10
|
+
* - `NO_LIQUIDITY` -> {@link NearIntentsNoLiquidityError}
|
|
11
|
+
* - `FAILED_TO_GET_QUOTE`, `UPSTREAM_ERROR` or HTTP 502 -> {@link NearIntentsQuoteError}
|
|
12
|
+
*
|
|
13
|
+
* Any other error is returned unchanged.
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export function mapNearIntentsError(error) {
|
|
17
|
+
if (!isAxiosError(error) || !error.response) {
|
|
18
|
+
return error;
|
|
19
|
+
}
|
|
20
|
+
const status = error.response.status;
|
|
21
|
+
const body = (error.response.data ?? {});
|
|
22
|
+
const message = typeof body.message === "string" ? body.message : undefined;
|
|
23
|
+
switch (body.code) {
|
|
24
|
+
case "AMOUNT_TOO_LOW":
|
|
25
|
+
return new NearIntentsAmountTooLowError(message ?? "Amount is too low for NEAR Intents route", body.minAmount, body.minAmountUsd);
|
|
26
|
+
case "NO_LIQUIDITY":
|
|
27
|
+
return new NearIntentsNoLiquidityError(message ?? "No liquidity available for NEAR Intents route");
|
|
28
|
+
case "FAILED_TO_GET_QUOTE":
|
|
29
|
+
case "UPSTREAM_ERROR":
|
|
30
|
+
return new NearIntentsQuoteError(message ?? "Failed to get NEAR Intents quote", body.code);
|
|
31
|
+
}
|
|
32
|
+
if (status === 404) {
|
|
33
|
+
return new NearIntentsDoesNotSupportedError(message ?? "Such route does not support NEAR Intents protocol");
|
|
34
|
+
}
|
|
35
|
+
if (status === 502) {
|
|
36
|
+
return new NearIntentsQuoteError(message ?? "NEAR Intents upstream error", "UPSTREAM_ERROR");
|
|
37
|
+
}
|
|
38
|
+
return error;
|
|
39
|
+
}
|
|
6
40
|
export class ApiClientImpl {
|
|
7
41
|
api;
|
|
8
42
|
constructor(params) {
|
|
@@ -81,5 +115,37 @@ export class ApiClientImpl {
|
|
|
81
115
|
getPoolInfoMap(_pools) {
|
|
82
116
|
return Promise.resolve({});
|
|
83
117
|
}
|
|
118
|
+
async getNearIntentsQuote(args) {
|
|
119
|
+
try {
|
|
120
|
+
const { data } = await this.api.post("/near-intents/quote", args, {
|
|
121
|
+
headers: { "Content-Type": "application/json" },
|
|
122
|
+
});
|
|
123
|
+
return data;
|
|
124
|
+
}
|
|
125
|
+
catch (e) {
|
|
126
|
+
throw mapNearIntentsError(e);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
async createNearIntentsDeposit(args) {
|
|
130
|
+
try {
|
|
131
|
+
const { data } = await this.api.post("/near-intents/deposit", args, {
|
|
132
|
+
headers: { "Content-Type": "application/json" },
|
|
133
|
+
});
|
|
134
|
+
return data;
|
|
135
|
+
}
|
|
136
|
+
catch (e) {
|
|
137
|
+
throw mapNearIntentsError(e);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
async submitNearIntentsDeposit(args) {
|
|
141
|
+
try {
|
|
142
|
+
await this.api.post("/near-intents/deposit/submit", args, {
|
|
143
|
+
headers: { "Content-Type": "application/json" },
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
catch (e) {
|
|
147
|
+
throw mapNearIntentsError(e);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
84
150
|
}
|
|
85
151
|
//# sourceMappingURL=api-client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-client.js","sourceRoot":"","sources":["../../../../src/client/core-api/api-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,YAAY,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAE/D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,wCAAwC,EAAE,oCAAoC,EAAE,MAAM,mBAAmB,CAAC;AACnH,OAAO,EAGL,SAAS,GAKV,MAAM,kBAAkB,CAAC;AAyB1B,MAAM,OAAO,aAAa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,eAAe;YACrC,uBAAuB,EAAE,IAAI,CAAC,uBAAuB;SACtD,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,cAAc,CAAC,MAAuC;QACpD,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC7B,CAAC;CACF","sourcesContent":["import { Axios, AxiosHeaders, create } from \"axios\";\nimport { InvalidMessengerOptionError } from \"../../exceptions\";\nimport { ChainDetailsMapWithFlags, PoolInfoMap, PoolKeyObject } from \"../../tokens-info\";\nimport { VERSION } from \"../../version\";\nimport { mapChainDetailsResponseToChainDetailsMap, mapChainDetailsResponseToPoolInfoMap } from \"./core-api-mapper\";\nimport {\n ChainDetailsResponse,\n GasBalanceResponse,\n Messenger,\n PendingInfoResponse,\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 /** @deprecated Do not use. */\n poolInfoMap: PoolInfoMap;\n}\n\nexport interface ApiClient {\n getTokenInfo(): Promise<TokenInfo>;\n\n /** @deprecated Do not use. */\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 /** @deprecated Do not use. */\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 = 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 if (params.coreApiHeadersProvider) {\n this.api.interceptors.request.use(async (config: { headers: any }) => {\n const dynamicHeaders = await params.coreApiHeadersProvider?.();\n if (!dynamicHeaders || Object.keys(dynamicHeaders).length === 0) {\n return config;\n }\n\n const headers = AxiosHeaders.from(config.headers);\n for (const [headerName, headerValue] of Object.entries(dynamicHeaders)) {\n if (!headerValue || headers.has(headerName)) {\n continue;\n }\n headers.set(headerName, headerValue);\n }\n\n config.headers = headers;\n return config;\n });\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 /**\n * @deprecated Do not use.\n * The `/pending-info` endpoint was removed from the Core API together with the liquidity pools;\n * always resolves to an empty object without calling the server.\n */\n getPendingInfo(): Promise<PendingInfoResponse> {\n return Promise.resolve({});\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 abrExchangeRate: data.abrExchangeRate,\n adminFeeShareWithExtras: data.adminFeeShareWithExtras,\n };\n }\n\n /**\n * @deprecated Do not use.\n * The `/pool-info` endpoint was removed from the Core API together with the liquidity pools;\n * always resolves to an empty map without calling the server.\n */\n getPoolInfoMap(_pools: PoolKeyObject[] | PoolKeyObject): Promise<PoolInfoMap> {\n return Promise.resolve({});\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"api-client.js","sourceRoot":"","sources":["../../../../src/client/core-api/api-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,EACL,2BAA2B,EAC3B,4BAA4B,EAC5B,gCAAgC,EAChC,2BAA2B,EAC3B,qBAAqB,GACtB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,wCAAwC,EAAE,oCAAoC,EAAE,MAAM,mBAAmB,CAAC;AACnH,OAAO,EAGL,SAAS,GAWV,MAAM,kBAAkB,CAAC;AAwC1B;;;;;;;;;GASG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAc;IAChD,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC5C,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;IACrC,MAAM,IAAI,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,IAAI,EAAE,CAAsC,CAAC;IAC9E,MAAM,OAAO,GAAG,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5E,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,gBAAgB;YACnB,OAAO,IAAI,4BAA4B,CACrC,OAAO,IAAI,0CAA0C,EACrD,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,YAAY,CAClB,CAAC;QACJ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I,EAAE;gBAC9F,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;aAChD,CAAC,CAAC;YACH,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,mBAAmB,CAAC,CAAC,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;IAED,KAAK,CAAC,wBAAwB,CAAC,IAAqC;QAClE,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,8BAA8B,EAAE,IAAI,EAAE;gBACxD,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;aAChD,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,mBAAmB,CAAC,CAAC,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;CACF","sourcesContent":["import { Axios, AxiosHeaders, create, isAxiosError } from \"axios\";\nimport {\n InvalidMessengerOptionError,\n NearIntentsAmountTooLowError,\n NearIntentsDoesNotSupportedError,\n NearIntentsNoLiquidityError,\n NearIntentsQuoteError,\n} from \"../../exceptions\";\nimport { ChainDetailsMapWithFlags, PoolInfoMap, PoolKeyObject } from \"../../tokens-info\";\nimport { VERSION } from \"../../version\";\nimport { mapChainDetailsResponseToChainDetailsMap, mapChainDetailsResponseToPoolInfoMap } from \"./core-api-mapper\";\nimport {\n ChainDetailsResponse,\n GasBalanceResponse,\n Messenger,\n NearIntentsDepositRequest,\n NearIntentsDepositResponse,\n NearIntentsErrorResponse,\n NearIntentsQuoteRequest,\n NearIntentsQuoteResponse,\n NearIntentsSubmitDepositRequest,\n PendingInfoResponse,\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 /** @deprecated Do not use. */\n poolInfoMap: PoolInfoMap;\n}\n\nexport interface ApiClient {\n getTokenInfo(): Promise<TokenInfo>;\n\n /** @deprecated Do not use. */\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 /** @deprecated Do not use. */\n getPoolInfoMap(pools: PoolKeyObject[] | PoolKeyObject): Promise<PoolInfoMap>;\n\n /**\n * `POST /near-intents/quote`: a dry NEAR Intents quote, see {@link mapNearIntentsError} for the thrown errors.\n */\n getNearIntentsQuote(args: NearIntentsQuoteRequest): Promise<NearIntentsQuoteResponse>;\n\n /**\n * `POST /near-intents/deposit`: a NEAR Intents quote with a one-shot deposit address.\n */\n createNearIntentsDeposit(args: NearIntentsDepositRequest): Promise<NearIntentsDepositResponse>;\n\n /**\n * `POST /near-intents/deposit/submit`: notifies NEAR Intents about the deposit transaction.\n */\n submitNearIntentsDeposit(args: NearIntentsSubmitDepositRequest): Promise<void>;\n}\n\n/**\n * Maps an error of a Core API `/near-intents/*` call to a typed SDK error:\n * - HTTP 404 -> {@link NearIntentsDoesNotSupportedError}\n * - `AMOUNT_TOO_LOW` -> {@link NearIntentsAmountTooLowError} (with `minAmount` / `minAmountUsd` when known)\n * - `NO_LIQUIDITY` -> {@link NearIntentsNoLiquidityError}\n * - `FAILED_TO_GET_QUOTE`, `UPSTREAM_ERROR` or HTTP 502 -> {@link NearIntentsQuoteError}\n *\n * Any other error is returned unchanged.\n * @internal\n */\nexport function mapNearIntentsError(error: unknown): unknown {\n if (!isAxiosError(error) || !error.response) {\n return error;\n }\n const status = error.response.status;\n const body = (error.response.data ?? {}) as Partial<NearIntentsErrorResponse>;\n const message = typeof body.message === \"string\" ? body.message : undefined;\n switch (body.code) {\n case \"AMOUNT_TOO_LOW\":\n return new NearIntentsAmountTooLowError(\n message ?? \"Amount is too low for NEAR Intents route\",\n body.minAmount,\n body.minAmountUsd\n );\n case \"NO_LIQUIDITY\":\n return new NearIntentsNoLiquidityError(message ?? \"No liquidity available for NEAR Intents route\");\n case \"FAILED_TO_GET_QUOTE\":\n case \"UPSTREAM_ERROR\":\n return new NearIntentsQuoteError(message ?? \"Failed to get NEAR Intents quote\", body.code);\n }\n if (status === 404) {\n return new NearIntentsDoesNotSupportedError(message ?? \"Such route does not support NEAR Intents protocol\");\n }\n if (status === 502) {\n return new NearIntentsQuoteError(message ?? \"NEAR Intents upstream error\", \"UPSTREAM_ERROR\");\n }\n return error;\n}\n\nexport class ApiClientImpl implements ApiClient {\n private api: Axios;\n\n constructor(params: AllbridgeCoreClientParams) {\n this.api = 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 if (params.coreApiHeadersProvider) {\n this.api.interceptors.request.use(async (config: { headers: any }) => {\n const dynamicHeaders = await params.coreApiHeadersProvider?.();\n if (!dynamicHeaders || Object.keys(dynamicHeaders).length === 0) {\n return config;\n }\n\n const headers = AxiosHeaders.from(config.headers);\n for (const [headerName, headerValue] of Object.entries(dynamicHeaders)) {\n if (!headerValue || headers.has(headerName)) {\n continue;\n }\n headers.set(headerName, headerValue);\n }\n\n config.headers = headers;\n return config;\n });\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 /**\n * @deprecated Do not use.\n * The `/pending-info` endpoint was removed from the Core API together with the liquidity pools;\n * always resolves to an empty object without calling the server.\n */\n getPendingInfo(): Promise<PendingInfoResponse> {\n return Promise.resolve({});\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 abrExchangeRate: data.abrExchangeRate,\n adminFeeShareWithExtras: data.adminFeeShareWithExtras,\n };\n }\n\n /**\n * @deprecated Do not use.\n * The `/pool-info` endpoint was removed from the Core API together with the liquidity pools;\n * always resolves to an empty map without calling the server.\n */\n getPoolInfoMap(_pools: PoolKeyObject[] | PoolKeyObject): Promise<PoolInfoMap> {\n return Promise.resolve({});\n }\n\n async getNearIntentsQuote(args: NearIntentsQuoteRequest): Promise<NearIntentsQuoteResponse> {\n try {\n const { data } = await this.api.post<NearIntentsQuoteResponse>(\"/near-intents/quote\", args, {\n headers: { \"Content-Type\": \"application/json\" },\n });\n return data;\n } catch (e) {\n throw mapNearIntentsError(e);\n }\n }\n\n async createNearIntentsDeposit(args: NearIntentsDepositRequest): Promise<NearIntentsDepositResponse> {\n try {\n const { data } = await this.api.post<NearIntentsDepositResponse>(\"/near-intents/deposit\", args, {\n headers: { \"Content-Type\": \"application/json\" },\n });\n return data;\n } catch (e) {\n throw mapNearIntentsError(e);\n }\n }\n\n async submitNearIntentsDeposit(args: NearIntentsSubmitDepositRequest): Promise<void> {\n try {\n await this.api.post(\"/near-intents/deposit/submit\", args, {\n headers: { \"Content-Type\": \"application/json\" },\n });\n } catch (e) {\n throw mapNearIntentsError(e);\n }\n }\n}\n"]}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { ChainDetailsMap, ChainDetailsMapWithFlags, PoolInfoMap, PoolKeyObject } from "../../tokens-info";
|
|
2
|
-
import { ChainDetailsResponse, PoolInfoResponse } from "./core-api.model";
|
|
2
|
+
import { AbrPayerAvailabilityKeyDTO, ChainDetailsResponse, Messenger, MessengerKeyDTO, PoolInfoResponse } from "./core-api.model";
|
|
3
3
|
export declare function mapChainDetailsResponseToChainDetailsMap(response: ChainDetailsResponse): ChainDetailsMapWithFlags;
|
|
4
4
|
/**
|
|
5
5
|
* @deprecated Do not use.
|
|
6
6
|
* The current Core API does not serve pool data, so the result is empty for it.
|
|
7
7
|
*/
|
|
8
8
|
export declare function mapChainDetailsResponseToPoolInfoMap(response: ChainDetailsResponse): PoolInfoMap;
|
|
9
|
+
export declare function mapMessengerKeyDtoToMessenger(dto: MessengerKeyDTO): Messenger | null;
|
|
10
|
+
export declare const dtoKeyToMessenger: Record<AbrPayerAvailabilityKeyDTO, Messenger>;
|
|
9
11
|
/**
|
|
10
12
|
* @deprecated Do not use.
|
|
11
13
|
*/
|
|
@@ -49,7 +49,7 @@ function mapTokenWithChainDetailsFromDto(chainDetails, dto) {
|
|
|
49
49
|
flags: flags ?? { ...DEFAULT_TOKEN_FLAGS },
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
|
-
function mapMessengerKeyDtoToMessenger(dto) {
|
|
52
|
+
export function mapMessengerKeyDtoToMessenger(dto) {
|
|
53
53
|
switch (dto) {
|
|
54
54
|
case MessengerKeyDTO.ALLBRIDGE:
|
|
55
55
|
return Messenger.ALLBRIDGE;
|
|
@@ -63,6 +63,8 @@ function mapMessengerKeyDtoToMessenger(dto) {
|
|
|
63
63
|
return Messenger.OFT;
|
|
64
64
|
case MessengerKeyDTO.X_RESERVE:
|
|
65
65
|
return Messenger.X_RESERVE;
|
|
66
|
+
case MessengerKeyDTO.NEAR_INTENTS:
|
|
67
|
+
return Messenger.NEAR_INTENTS;
|
|
66
68
|
}
|
|
67
69
|
}
|
|
68
70
|
function mapTransferTimeFromDto(dto) {
|
|
@@ -130,8 +132,9 @@ function mapAbrPayerAvailabilityFromDto(dto) {
|
|
|
130
132
|
}
|
|
131
133
|
return out;
|
|
132
134
|
}
|
|
133
|
-
// Build mapping from dto key ("allbridge") to Messenger enum value (1..
|
|
134
|
-
|
|
135
|
+
// Build mapping from dto key ("allbridge") to Messenger enum value (1..7).
|
|
136
|
+
// Pairs the enums by key name: every MessengerKeyDTO key must exist in Messenger with the same spelling.
|
|
137
|
+
export const dtoKeyToMessenger = Object.fromEntries(Object.entries(MessengerKeyDTO).map(([enumKey, dtoKey]) => {
|
|
135
138
|
// enumKey: "ALLBRIDGE"
|
|
136
139
|
// dtoKey: "allbridge"
|
|
137
140
|
return [dtoKey, Messenger[enumKey]];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-api-mapper.js","sourceRoot":"","sources":["../../../../src/client/core-api/core-api-mapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AActC,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAKL,SAAS,EACT,eAAe,GAKhB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,UAAU,wCAAwC,CAAC,QAA8B;IACrF,OAAO,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,CAA2B,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;QAC9E,MAAM,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QAC7B,MAAM,eAAe,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACjC,MAAM,YAAY,GAAG,sBAAsB,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;QAC1E,IAAI,YAAY,EAAE,CAAC;YACjB,GAAG,CAAC,WAAW,CAAC,GAA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UAAU,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;;GAEG;AACH,MAAM,UAAU,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,0BAA0B,CAAC,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 AbrPayerAvailability,\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 AbrPayerAvailabilityKeyDTO,\n AbrPayerAvailabilityTypeDTO,\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\n/**\n * @deprecated Do not use.\n * The current Core API does not serve pool data, so the result is empty for it.\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 { poolAddress, poolInfo } = token;\n if (!poolAddress || !poolInfo) {\n continue;\n }\n const poolKey = mapPoolKeyObjectToPoolKey({ chainSymbol, poolAddress });\n const imbalance = calculatePoolInfoImbalance(poolInfo);\n poolInfoMap[poolKey] = { ...poolInfo, imbalance };\n }\n }\n return poolInfoMap;\n}\n\n/**\n * Flags assumed for tokens served without them: the current Core API returns every token as a token to send\n * and has no liquidity pools.\n */\nconst DEFAULT_TOKEN_FLAGS: TokenWithChainDetailsWithFlags[\"flags\"] = { swap: true, pool: false };\n\nfunction mapTokenWithChainDetailsFromDto(chainDetails: ChainDetails, dto: TokenDTO): TokenWithChainDetailsWithFlags {\n const { name: chainName, ...chainDetailsWithoutName } = chainDetails;\n const { poolInfo: _poolInfo, flags, ...dtoWithoutPoolInfo } = dto;\n // The deprecated pool-era token fields (poolAddress, feeShare, apr, lpRate, ...) are kept on the public type\n // for backward compatibility but are undefined when served by the current Core API.\n return {\n ...dtoWithoutPoolInfo,\n ...chainDetailsWithoutName,\n chainName,\n flags: flags ?? { ...DEFAULT_TOKEN_FLAGS },\n } as TokenWithChainDetailsWithFlags;\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 case MessengerKeyDTO.X_RESERVE:\n return Messenger.X_RESERVE;\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 && value != null) {\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 // bridgeAddress is deprecated and undefined when served by the current Core API; the public type keeps it\n // for backward compatibility.\n const chainDetails = {\n ...basicChainProperties,\n allbridgeChainId: dto.chainId,\n bridgeId: dto.bridgeId,\n paddingUtilId: dto.paddingUtilId,\n bridgeAddress: dto.bridgeAddress,\n oftBridgeAddress: dto.oftBridgeAddress,\n yieldAddress: dto.yieldAddress,\n abrPayer: dto.abrPayer\n ? {\n payerAddress: dto.abrPayer.payerAddress,\n abrToken: {\n chainSymbol: chainSymbol as ChainSymbol,\n tokenAddress: dto.abrPayer.tokenAddress,\n decimals: dto.abrPayer.tokenDecimals,\n },\n payerAvailability: mapAbrPayerAvailabilityFromDto(dto.abrPayer.payerAvailability),\n }\n : undefined,\n transferTime: mapTransferTimeFromDto(dto.transferTime),\n txCostAmount: dto.txCostAmount,\n confirmations: dto.confirmations,\n suiAddresses: dto.suiAddresses,\n } as ChainDetails;\n return {\n ...chainDetails,\n tokens: dto.tokens.map((tokenDto) => mapTokenWithChainDetailsFromDto(chainDetails, tokenDto)),\n };\n}\n\nfunction mapAbrPayerAvailabilityFromDto(dto: AbrPayerAvailabilityTypeDTO): AbrPayerAvailability {\n if (!dto) return {};\n const out: AbrPayerAvailability = {};\n\n for (const [dtoKey, isAvailable] of Object.entries(dto) as [AbrPayerAvailabilityKeyDTO, boolean][]) {\n if (!isAvailable) continue;\n\n const messengerEnumValue = dtoKeyToMessenger[dtoKey];\n if (!messengerEnumValue) continue;\n\n out[messengerEnumValue] = true;\n }\n\n return out;\n}\n\n// Build mapping from dto key (\"allbridge\") to Messenger enum value (1..5)\nconst dtoKeyToMessenger: Record<AbrPayerAvailabilityKeyDTO, Messenger> = Object.fromEntries(\n Object.entries(MessengerKeyDTO).map(([enumKey, dtoKey]) => {\n // enumKey: \"ALLBRIDGE\"\n // dtoKey: \"allbridge\"\n return [dtoKey, Messenger[enumKey as keyof typeof Messenger]];\n })\n) as Record<AbrPayerAvailabilityKeyDTO, Messenger>;\n\n/**\n * @deprecated Do not use.\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\n/**\n * @deprecated Do not use.\n */\nexport function mapPoolKeyObjectToPoolKey(poolKeyObject: PoolKeyObject): string {\n return poolKeyObject.chainSymbol + \"_\" + poolKeyObject.poolAddress;\n}\n\n/**\n * @deprecated Do not use.\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\n/**\n * @deprecated Do not use.\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"]}
|
|
1
|
+
{"version":3,"file":"core-api-mapper.js","sourceRoot":"","sources":["../../../../src/client/core-api/core-api-mapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AActC,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAKL,SAAS,EACT,eAAe,GAKhB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,UAAU,wCAAwC,CAAC,QAA8B;IACrF,OAAO,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,CAA2B,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;QAC9E,MAAM,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QAC7B,MAAM,eAAe,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACjC,MAAM,YAAY,GAAG,sBAAsB,CAAC,W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ums\";\nimport {\n AbrPayerAvailability,\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 AbrPayerAvailabilityKeyDTO,\n AbrPayerAvailabilityTypeDTO,\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\n/**\n * @deprecated Do not use.\n * The current Core API does not serve pool data, so the result is empty for it.\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 { poolAddress, poolInfo } = token;\n if (!poolAddress || !poolInfo) {\n continue;\n }\n const poolKey = mapPoolKeyObjectToPoolKey({ chainSymbol, poolAddress });\n const imbalance = calculatePoolInfoImbalance(poolInfo);\n poolInfoMap[poolKey] = { ...poolInfo, imbalance };\n }\n }\n return poolInfoMap;\n}\n\n/**\n * Flags assumed for tokens served without them: the current Core API returns every token as a token to send\n * and has no liquidity pools.\n */\nconst DEFAULT_TOKEN_FLAGS: TokenWithChainDetailsWithFlags[\"flags\"] = { swap: true, pool: false };\n\nfunction mapTokenWithChainDetailsFromDto(chainDetails: ChainDetails, dto: TokenDTO): TokenWithChainDetailsWithFlags {\n const { name: chainName, ...chainDetailsWithoutName } = chainDetails;\n const { poolInfo: _poolInfo, flags, ...dtoWithoutPoolInfo } = dto;\n // The deprecated pool-era token fields (poolAddress, feeShare, apr, lpRate, ...) are kept on the public type\n // for backward compatibility but are undefined when served by the current Core API.\n return {\n ...dtoWithoutPoolInfo,\n ...chainDetailsWithoutName,\n chainName,\n flags: flags ?? { ...DEFAULT_TOKEN_FLAGS },\n } as TokenWithChainDetailsWithFlags;\n}\n\nexport function 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 case MessengerKeyDTO.X_RESERVE:\n return Messenger.X_RESERVE;\n case MessengerKeyDTO.NEAR_INTENTS:\n return Messenger.NEAR_INTENTS;\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 && value != null) {\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 // bridgeAddress is deprecated and undefined when served by the current Core API; the public type keeps it\n // for backward compatibility.\n const chainDetails = {\n ...basicChainProperties,\n allbridgeChainId: dto.chainId,\n bridgeId: dto.bridgeId,\n paddingUtilId: dto.paddingUtilId,\n bridgeAddress: dto.bridgeAddress,\n oftBridgeAddress: dto.oftBridgeAddress,\n yieldAddress: dto.yieldAddress,\n abrPayer: dto.abrPayer\n ? {\n payerAddress: dto.abrPayer.payerAddress,\n abrToken: {\n chainSymbol: chainSymbol as ChainSymbol,\n tokenAddress: dto.abrPayer.tokenAddress,\n decimals: dto.abrPayer.tokenDecimals,\n },\n payerAvailability: mapAbrPayerAvailabilityFromDto(dto.abrPayer.payerAvailability),\n }\n : undefined,\n transferTime: mapTransferTimeFromDto(dto.transferTime),\n txCostAmount: dto.txCostAmount,\n confirmations: dto.confirmations,\n suiAddresses: dto.suiAddresses,\n } as ChainDetails;\n return {\n ...chainDetails,\n tokens: dto.tokens.map((tokenDto) => mapTokenWithChainDetailsFromDto(chainDetails, tokenDto)),\n };\n}\n\nfunction mapAbrPayerAvailabilityFromDto(dto: AbrPayerAvailabilityTypeDTO): AbrPayerAvailability {\n if (!dto) return {};\n const out: AbrPayerAvailability = {};\n\n for (const [dtoKey, isAvailable] of Object.entries(dto) as [AbrPayerAvailabilityKeyDTO, boolean][]) {\n if (!isAvailable) continue;\n\n const messengerEnumValue = dtoKeyToMessenger[dtoKey];\n if (!messengerEnumValue) continue;\n\n out[messengerEnumValue] = true;\n }\n\n return out;\n}\n\n// Build mapping from dto key (\"allbridge\") to Messenger enum value (1..7).\n// Pairs the enums by key name: every MessengerKeyDTO key must exist in Messenger with the same spelling.\nexport const dtoKeyToMessenger: Record<AbrPayerAvailabilityKeyDTO, Messenger> = Object.fromEntries(\n Object.entries(MessengerKeyDTO).map(([enumKey, dtoKey]) => {\n // enumKey: \"ALLBRIDGE\"\n // dtoKey: \"allbridge\"\n return [dtoKey, Messenger[enumKey as keyof typeof Messenger]];\n })\n) as Record<AbrPayerAvailabilityKeyDTO, Messenger>;\n\n/**\n * @deprecated Do not use.\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\n/**\n * @deprecated Do not use.\n */\nexport function mapPoolKeyObjectToPoolKey(poolKeyObject: PoolKeyObject): string {\n return poolKeyObject.chainSymbol + \"_\" + poolKeyObject.poolAddress;\n}\n\n/**\n * @deprecated Do not use.\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\n/**\n * @deprecated Do not use.\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"]}
|
|
@@ -65,6 +65,14 @@ export interface TokenDTO {
|
|
|
65
65
|
*/
|
|
66
66
|
yieldId?: number;
|
|
67
67
|
xReserve?: XReserveDTO;
|
|
68
|
+
/**
|
|
69
|
+
* NEAR Intents (1Click) asset of the token. Defined when the token is listed by NEAR Intents.
|
|
70
|
+
*/
|
|
71
|
+
nearIntents?: NearIntentsDTO;
|
|
72
|
+
/**
|
|
73
|
+
* True when the token is the native gas token of the chain (listed under a sentinel address).
|
|
74
|
+
*/
|
|
75
|
+
isNative?: boolean;
|
|
68
76
|
/**
|
|
69
77
|
* Optional: the current Core API always returns all tokens and omits the flags,
|
|
70
78
|
* in which case every token is treated as `swap: true, pool: false`.
|
|
@@ -81,6 +89,9 @@ export interface XReserveDTO {
|
|
|
81
89
|
feeShare: string;
|
|
82
90
|
protocolAddress?: string;
|
|
83
91
|
}
|
|
92
|
+
export interface NearIntentsDTO {
|
|
93
|
+
assetId: string;
|
|
94
|
+
}
|
|
84
95
|
/**
|
|
85
96
|
* @deprecated Do not use.
|
|
86
97
|
*/
|
|
@@ -101,7 +112,8 @@ export declare enum MessengerKeyDTO {
|
|
|
101
112
|
CCTP = "cctp",
|
|
102
113
|
CCTP_V2 = "cctpV2",
|
|
103
114
|
OFT = "oft",
|
|
104
|
-
X_RESERVE = "xReserve"
|
|
115
|
+
X_RESERVE = "xReserve",
|
|
116
|
+
NEAR_INTENTS = "nearIntents"
|
|
105
117
|
}
|
|
106
118
|
export type AbrPayerAvailabilityKeyDTO = (typeof MessengerKeyDTO)[keyof typeof MessengerKeyDTO];
|
|
107
119
|
export type AbrPayerAvailabilityTypeDTO = Partial<Record<AbrPayerAvailabilityKeyDTO, boolean>>;
|
|
@@ -143,14 +155,22 @@ export declare enum Messenger {
|
|
|
143
155
|
* xReserve.
|
|
144
156
|
* Route is supported when `xReserve` is defined on both source and destination tokens.
|
|
145
157
|
*/
|
|
146
|
-
X_RESERVE = 6
|
|
158
|
+
X_RESERVE = 6,
|
|
159
|
+
/**
|
|
160
|
+
* NEAR Intents (1Click).
|
|
161
|
+
* Route is supported when `nearIntents` is defined on both source and destination tokens.
|
|
162
|
+
* The transfer is a plain token (or native currency) transfer to a one-shot deposit address,
|
|
163
|
+
* so no approval is needed. Amounts are market-priced quotes from the Core API, not a deterministic fee:
|
|
164
|
+
* see `AllbridgeCoreSdk.nearIntents`.
|
|
165
|
+
*/
|
|
166
|
+
NEAR_INTENTS = 7
|
|
147
167
|
}
|
|
148
168
|
/**
|
|
149
169
|
* @deprecated Do not use.
|
|
150
170
|
*/
|
|
151
171
|
export type LegacyMessenger = Messenger.ALLBRIDGE | Messenger.WORMHOLE;
|
|
152
172
|
/**
|
|
153
|
-
* Messengers supported for transfers: {@link Messenger.CCTP}, {@link Messenger.CCTP_V2}, {@link Messenger.OFT}, {@link Messenger.X_RESERVE}
|
|
173
|
+
* Messengers supported for transfers: {@link Messenger.CCTP}, {@link Messenger.CCTP_V2}, {@link Messenger.OFT}, {@link Messenger.X_RESERVE}, {@link Messenger.NEAR_INTENTS}
|
|
154
174
|
*/
|
|
155
175
|
export type ActiveMessenger = Exclude<Messenger, LegacyMessenger>;
|
|
156
176
|
export interface ReceiveTransactionCostRequest {
|
|
@@ -166,6 +186,77 @@ export interface ReceiveTransactionCostResponse {
|
|
|
166
186
|
abrExchangeRate?: string;
|
|
167
187
|
adminFeeShareWithExtras?: string;
|
|
168
188
|
}
|
|
189
|
+
/**
|
|
190
|
+
* NEAR Intents quote direction.
|
|
191
|
+
* - `EXACT_INPUT`: `amount` is what the user sends.
|
|
192
|
+
* - `EXACT_OUTPUT`: `amount` is what the user wants to receive.
|
|
193
|
+
*/
|
|
194
|
+
export type NearIntentsSwapType = "EXACT_INPUT" | "EXACT_OUTPUT";
|
|
195
|
+
export interface NearIntentsQuoteRequest {
|
|
196
|
+
sourceChainId: number;
|
|
197
|
+
sourceToken: string;
|
|
198
|
+
destinationChainId: number;
|
|
199
|
+
destinationToken: string;
|
|
200
|
+
/**
|
|
201
|
+
* Integer amount: in source token units for `EXACT_INPUT`, in destination token units for `EXACT_OUTPUT`.
|
|
202
|
+
*/
|
|
203
|
+
amount: string;
|
|
204
|
+
swapType: NearIntentsSwapType;
|
|
205
|
+
}
|
|
206
|
+
export interface NearIntentsQuoteResponse {
|
|
207
|
+
/** Integer amount in source token units */
|
|
208
|
+
amountIn: string;
|
|
209
|
+
/** Integer amount in destination token units */
|
|
210
|
+
amountOut: string;
|
|
211
|
+
/** Integer amount in destination token units, the slippage floor */
|
|
212
|
+
minAmountOut: string;
|
|
213
|
+
/** Estimated transfer time, seconds */
|
|
214
|
+
timeEstimate: number;
|
|
215
|
+
/**
|
|
216
|
+
* True when the server answered from its per-route quote model instead of a live 1Click quote.
|
|
217
|
+
* Deposits are never estimated. Older servers omit it.
|
|
218
|
+
*/
|
|
219
|
+
estimated: boolean;
|
|
220
|
+
/** Absent on an estimated answer for a token without a catalog price */
|
|
221
|
+
amountInUsd?: string;
|
|
222
|
+
/** Absent on an estimated answer for a token without a catalog price */
|
|
223
|
+
amountOutUsd?: string;
|
|
224
|
+
}
|
|
225
|
+
export interface NearIntentsDepositRequest extends NearIntentsQuoteRequest {
|
|
226
|
+
recipient: string;
|
|
227
|
+
refundTo: string;
|
|
228
|
+
}
|
|
229
|
+
export interface NearIntentsDepositResponse {
|
|
230
|
+
depositAddress: string;
|
|
231
|
+
depositMemo?: string;
|
|
232
|
+
/** Integer amount in source token units */
|
|
233
|
+
amountIn: string;
|
|
234
|
+
/** Integer amount in destination token units */
|
|
235
|
+
amountOut: string;
|
|
236
|
+
/** Integer amount in destination token units, the slippage floor */
|
|
237
|
+
minAmountOut: string;
|
|
238
|
+
/** ISO 8601 */
|
|
239
|
+
deadline: string;
|
|
240
|
+
/** ISO 8601 */
|
|
241
|
+
timeWhenInactive?: string;
|
|
242
|
+
/** Estimated transfer time, seconds */
|
|
243
|
+
timeEstimate: number;
|
|
244
|
+
}
|
|
245
|
+
export interface NearIntentsSubmitDepositRequest {
|
|
246
|
+
depositAddress: string;
|
|
247
|
+
depositMemo?: string;
|
|
248
|
+
txId: string;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Error codes of the Core API NEAR Intents endpoints (HTTP 400 and 502 bodies).
|
|
252
|
+
*/
|
|
253
|
+
export type NearIntentsErrorCode = "AMOUNT_TOO_LOW" | "NO_LIQUIDITY" | "FAILED_TO_GET_QUOTE" | "UPSTREAM_ERROR";
|
|
254
|
+
export interface NearIntentsErrorResponse {
|
|
255
|
+
code: NearIntentsErrorCode;
|
|
256
|
+
message: string;
|
|
257
|
+
minAmount?: string;
|
|
258
|
+
minAmountUsd?: string;
|
|
259
|
+
}
|
|
169
260
|
export interface GasBalanceResponse {
|
|
170
261
|
gasBalance: string | null;
|
|
171
262
|
status: AddressStatus;
|
|
@@ -192,6 +283,12 @@ export interface TransferStatusResponse {
|
|
|
192
283
|
signaturesNeeded: number;
|
|
193
284
|
send: BridgeTransaction;
|
|
194
285
|
receive?: BridgeTransaction;
|
|
286
|
+
/**
|
|
287
|
+
* True when the transfer was refunded to the sender on the source chain instead of being delivered
|
|
288
|
+
* (e.g. a {@link Messenger.NEAR_INTENTS} deposit refunded by NEAR Intents); `receive` stays absent.
|
|
289
|
+
* Optional: older Core API versions may omit it.
|
|
290
|
+
*/
|
|
291
|
+
refunded?: boolean;
|
|
195
292
|
responseTime?: number;
|
|
196
293
|
}
|
|
197
294
|
export interface BridgeTransaction {
|
|
@@ -17,6 +17,7 @@ export var MessengerKeyDTO;
|
|
|
17
17
|
MessengerKeyDTO["CCTP_V2"] = "cctpV2";
|
|
18
18
|
MessengerKeyDTO["OFT"] = "oft";
|
|
19
19
|
MessengerKeyDTO["X_RESERVE"] = "xReserve";
|
|
20
|
+
MessengerKeyDTO["NEAR_INTENTS"] = "nearIntents";
|
|
20
21
|
})(MessengerKeyDTO || (MessengerKeyDTO = {}));
|
|
21
22
|
/**
|
|
22
23
|
* Bridging protocol used for a transfer.
|
|
@@ -49,5 +50,13 @@ export var Messenger;
|
|
|
49
50
|
* Route is supported when `xReserve` is defined on both source and destination tokens.
|
|
50
51
|
*/
|
|
51
52
|
Messenger[Messenger["X_RESERVE"] = 6] = "X_RESERVE";
|
|
53
|
+
/**
|
|
54
|
+
* NEAR Intents (1Click).
|
|
55
|
+
* Route is supported when `nearIntents` is defined on both source and destination tokens.
|
|
56
|
+
* The transfer is a plain token (or native currency) transfer to a one-shot deposit address,
|
|
57
|
+
* so no approval is needed. Amounts are market-priced quotes from the Core API, not a deterministic fee:
|
|
58
|
+
* see `AllbridgeCoreSdk.nearIntents`.
|
|
59
|
+
*/
|
|
60
|
+
Messenger[Messenger["NEAR_INTENTS"] = 7] = "NEAR_INTENTS";
|
|
52
61
|
})(Messenger || (Messenger = {}));
|
|
53
62
|
//# 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":"AAiCA,MAAM,CAAN,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,KAAb,aAAa,QAOxB;AA+DD,MAAM,CAAN,IAAY,eASX;AATD,WAAY,eAAe;IACzB,8BAA8B;IAC9B,0CAAuB,CAAA;IACvB,8BAA8B;IAC9B,wCAAqB,CAAA;IACrB,gCAAa,CAAA;IACb,qCAAkB,CAAA;IAClB,8BAAW,CAAA;IACX,yCAAsB,CAAA;AACxB,CAAC,EATW,eAAe,KAAf,eAAe,QAS1B;AAkBD;;;GAGG;AACH,MAAM,CAAN,IAAY,SA0BX;AA1BD,WAAY,SAAS;IACnB,8BAA8B;IAC9B,mDAAa,CAAA;IACb,8BAA8B;IAC9B,iDAAY,CAAA;IACZ;;;OAGG;IACH,yCAAQ,CAAA;IACR;;;OAGG;IACH,+CAAW,CAAA;IACX;;;;OAIG;IACH,uCAAO,CAAA;IACP;;;OAGG;IACH,mDAAa,CAAA;AACf,CAAC,EA1BW,SAAS,KAAT,SAAS,QA0BpB","sourcesContent":["import { ChainSymbol } from \"../../chains/chain.enums\";\nimport { PoolInfo, SuiAddresses } from \"../../tokens-info\";\n\nexport type ChainDetailsResponse = Record<string, ChainDetailsDTO>;\n\nexport interface AbrPayerChainInfoDTO {\n payerAddress: string;\n tokenAddress: string;\n tokenDecimals: number;\n payerAvailability: AbrPayerAvailabilityTypeDTO;\n}\n\nexport interface ChainDetailsDTO {\n tokens: TokenDTO[];\n chainId: number;\n bridgeId?: string;\n paddingUtilId?: string;\n /** @deprecated Do not use. Not served by the current Core API. */\n bridgeAddress?: string;\n oftBridgeAddress?: string;\n abrPayer?: AbrPayerChainInfoDTO;\n /** @deprecated Do not use. Not served by the current Core API. */\n swapAddress?: string;\n /**\n * @deprecated Do not use.\n */\n yieldAddress?: 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 /** @deprecated Do not use. Not served by the current Core API. */\n poolAddress?: string;\n tokenAddress: string;\n originTokenAddress?: string;\n /** @deprecated Do not use. Not served by the current Core API. */\n poolInfo?: PoolInfoDTO;\n oftId?: string;\n /** @deprecated Do not use. Not served by the current Core API. */\n feeShare?: string;\n /** @deprecated Do not use. Not served by the current Core API. */\n apr?: string;\n /** @deprecated Do not use. Not served by the current Core API. */\n apr7d?: string;\n /** @deprecated Do not use. Not served by the current Core API. */\n apr30d?: string;\n /** @deprecated Do not use. Not served by the current Core API. */\n lpRate?: string;\n cctpAddress?: string;\n cctpV2Address?: string;\n cctpFeeShare?: string;\n cctpV2FeeShare?: string;\n /**\n * @deprecated Do not use.\n */\n yieldId?: number;\n xReserve?: XReserveDTO;\n /**\n * Optional: the current Core API always returns all tokens and omits the flags,\n * in which case every token is treated as `swap: true, pool: false`.\n */\n flags?: {\n swap: boolean;\n /** @deprecated Do not use. */\n pool: boolean;\n };\n}\n\nexport interface XReserveDTO {\n bridgeAddress: string;\n feeConst: string;\n feeShare: string;\n protocolAddress?: string;\n}\n\n/**\n * @deprecated Do not use.\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 /** @deprecated Do not use. */\n ALLBRIDGE = \"allbridge\",\n /** @deprecated Do not use. */\n WORMHOLE = \"wormhole\",\n CCTP = \"cctp\",\n CCTP_V2 = \"cctpV2\",\n OFT = \"oft\",\n X_RESERVE = \"xReserve\",\n}\n\nexport type AbrPayerAvailabilityKeyDTO = (typeof MessengerKeyDTO)[keyof typeof MessengerKeyDTO];\n\nexport type AbrPayerAvailabilityTypeDTO = Partial<Record<AbrPayerAvailabilityKeyDTO, boolean>>;\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 | null;\n};\n\n/**\n * Bridging protocol used for a transfer.\n * Only {@link ActiveMessenger} values are supported.\n */\nexport enum Messenger {\n /** @deprecated Do not use. */\n ALLBRIDGE = 1,\n /** @deprecated Do not use. */\n WORMHOLE = 2,\n /**\n * Circle CCTP.\n * Route is supported when `cctpAddress` is defined on both source and destination tokens.\n */\n CCTP = 3,\n /**\n * Circle CCTP V2.\n * Route is supported when `cctpV2Address` is defined on both source and destination tokens.\n */\n CCTP_V2 = 4,\n /**\n * LayerZero OFT.\n * Route is supported when source and destination tokens have the same `oftId`\n * and `oftBridgeAddress` is defined on both chains.\n */\n OFT = 5,\n /**\n * xReserve.\n * Route is supported when `xReserve` is defined on both source and destination tokens.\n */\n X_RESERVE = 6,\n}\n\n/**\n * @deprecated Do not use.\n */\nexport type LegacyMessenger = Messenger.ALLBRIDGE | Messenger.WORMHOLE;\n/**\n * Messengers supported for transfers: {@link Messenger.CCTP}, {@link Messenger.CCTP_V2}, {@link Messenger.OFT}, {@link Messenger.X_RESERVE}\n */\nexport type ActiveMessenger = Exclude<Messenger, LegacyMessenger>;\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 abrExchangeRate?: 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\n/**\n * @deprecated Do not use.\n */\nexport type PoolInfoResponse = Record<string, PoolInfo>;\n/**\n * @deprecated Do not use.\n */\nexport type PendingInfoResponse = Partial<Record<string, TokenPendingInfoDTO>>;\n/**\n * @deprecated Do not use.\n */\nexport type TokenPendingInfoDTO = Record<string, PendingInfoDTO>;\n\n/**\n * @deprecated Do not use.\n */\nexport interface PendingInfoDTO {\n pendingTxs: number;\n totalSentAmount: string;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"core-api.model.js","sourceRoot":"","sources":["../../../../src/client/core-api/core-api.model.ts"],"names":[],"mappings":"AAiCA,MAAM,CAAN,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,KAAb,aAAa,QAOxB;AA2ED,MAAM,CAAN,IAAY,eAUX;AAVD,WAAY,eAAe;IACzB,8BAA8B;IAC9B,0CAAuB,CAAA;IACvB,8BAA8B;IAC9B,wCAAqB,CAAA;IACrB,gCAAa,CAAA;IACb,qCAAkB,CAAA;IAClB,8BAAW,CAAA;IACX,yCAAsB,CAAA;IACtB,+CAA4B,CAAA;AAC9B,CAAC,EAVW,eAAe,KAAf,eAAe,QAU1B;AAkBD;;;GAGG;AACH,MAAM,CAAN,IAAY,SAkCX;AAlCD,WAAY,SAAS;IACnB,8BAA8B;IAC9B,mDAAa,CAAA;IACb,8BAA8B;IAC9B,iDAAY,CAAA;IACZ;;;OAGG;IACH,yCAAQ,CAAA;IACR;;;OAGG;IACH,+CAAW,CAAA;IACX;;;;OAIG;IACH,uCAAO,CAAA;IACP;;;OAGG;IACH,mDAAa,CAAA;IACb;;;;;;OAMG;IACH,yDAAgB,CAAA;AAClB,CAAC,EAlCW,SAAS,KAAT,SAAS,QAkCpB","sourcesContent":["import { ChainSymbol } from \"../../chains/chain.enums\";\nimport { PoolInfo, SuiAddresses } from \"../../tokens-info\";\n\nexport type ChainDetailsResponse = Record<string, ChainDetailsDTO>;\n\nexport interface AbrPayerChainInfoDTO {\n payerAddress: string;\n tokenAddress: string;\n tokenDecimals: number;\n payerAvailability: AbrPayerAvailabilityTypeDTO;\n}\n\nexport interface ChainDetailsDTO {\n tokens: TokenDTO[];\n chainId: number;\n bridgeId?: string;\n paddingUtilId?: string;\n /** @deprecated Do not use. Not served by the current Core API. */\n bridgeAddress?: string;\n oftBridgeAddress?: string;\n abrPayer?: AbrPayerChainInfoDTO;\n /** @deprecated Do not use. Not served by the current Core API. */\n swapAddress?: string;\n /**\n * @deprecated Do not use.\n */\n yieldAddress?: 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 /** @deprecated Do not use. Not served by the current Core API. */\n poolAddress?: string;\n tokenAddress: string;\n originTokenAddress?: string;\n /** @deprecated Do not use. Not served by the current Core API. */\n poolInfo?: PoolInfoDTO;\n oftId?: string;\n /** @deprecated Do not use. Not served by the current Core API. */\n feeShare?: string;\n /** @deprecated Do not use. Not served by the current Core API. */\n apr?: string;\n /** @deprecated Do not use. Not served by the current Core API. */\n apr7d?: string;\n /** @deprecated Do not use. Not served by the current Core API. */\n apr30d?: string;\n /** @deprecated Do not use. Not served by the current Core API. */\n lpRate?: string;\n cctpAddress?: string;\n cctpV2Address?: string;\n cctpFeeShare?: string;\n cctpV2FeeShare?: string;\n /**\n * @deprecated Do not use.\n */\n yieldId?: number;\n xReserve?: XReserveDTO;\n /**\n * NEAR Intents (1Click) asset of the token. Defined when the token is listed by NEAR Intents.\n */\n nearIntents?: NearIntentsDTO;\n /**\n * True when the token is the native gas token of the chain (listed under a sentinel address).\n */\n isNative?: boolean;\n /**\n * Optional: the current Core API always returns all tokens and omits the flags,\n * in which case every token is treated as `swap: true, pool: false`.\n */\n flags?: {\n swap: boolean;\n /** @deprecated Do not use. */\n pool: boolean;\n };\n}\n\nexport interface XReserveDTO {\n bridgeAddress: string;\n feeConst: string;\n feeShare: string;\n protocolAddress?: string;\n}\n\nexport interface NearIntentsDTO {\n assetId: string;\n}\n\n/**\n * @deprecated Do not use.\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 /** @deprecated Do not use. */\n ALLBRIDGE = \"allbridge\",\n /** @deprecated Do not use. */\n WORMHOLE = \"wormhole\",\n CCTP = \"cctp\",\n CCTP_V2 = \"cctpV2\",\n OFT = \"oft\",\n X_RESERVE = \"xReserve\",\n NEAR_INTENTS = \"nearIntents\",\n}\n\nexport type AbrPayerAvailabilityKeyDTO = (typeof MessengerKeyDTO)[keyof typeof MessengerKeyDTO];\n\nexport type AbrPayerAvailabilityTypeDTO = Partial<Record<AbrPayerAvailabilityKeyDTO, boolean>>;\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 | null;\n};\n\n/**\n * Bridging protocol used for a transfer.\n * Only {@link ActiveMessenger} values are supported.\n */\nexport enum Messenger {\n /** @deprecated Do not use. */\n ALLBRIDGE = 1,\n /** @deprecated Do not use. */\n WORMHOLE = 2,\n /**\n * Circle CCTP.\n * Route is supported when `cctpAddress` is defined on both source and destination tokens.\n */\n CCTP = 3,\n /**\n * Circle CCTP V2.\n * Route is supported when `cctpV2Address` is defined on both source and destination tokens.\n */\n CCTP_V2 = 4,\n /**\n * LayerZero OFT.\n * Route is supported when source and destination tokens have the same `oftId`\n * and `oftBridgeAddress` is defined on both chains.\n */\n OFT = 5,\n /**\n * xReserve.\n * Route is supported when `xReserve` is defined on both source and destination tokens.\n */\n X_RESERVE = 6,\n /**\n * NEAR Intents (1Click).\n * Route is supported when `nearIntents` is defined on both source and destination tokens.\n * The transfer is a plain token (or native currency) transfer to a one-shot deposit address,\n * so no approval is needed. Amounts are market-priced quotes from the Core API, not a deterministic fee:\n * see `AllbridgeCoreSdk.nearIntents`.\n */\n NEAR_INTENTS = 7,\n}\n\n/**\n * @deprecated Do not use.\n */\nexport type LegacyMessenger = Messenger.ALLBRIDGE | Messenger.WORMHOLE;\n/**\n * Messengers supported for transfers: {@link Messenger.CCTP}, {@link Messenger.CCTP_V2}, {@link Messenger.OFT}, {@link Messenger.X_RESERVE}, {@link Messenger.NEAR_INTENTS}\n */\nexport type ActiveMessenger = Exclude<Messenger, LegacyMessenger>;\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 abrExchangeRate?: string;\n adminFeeShareWithExtras?: string;\n}\n\n/**\n * NEAR Intents quote direction.\n * - `EXACT_INPUT`: `amount` is what the user sends.\n * - `EXACT_OUTPUT`: `amount` is what the user wants to receive.\n */\nexport type NearIntentsSwapType = \"EXACT_INPUT\" | \"EXACT_OUTPUT\";\n\nexport interface NearIntentsQuoteRequest {\n sourceChainId: number;\n sourceToken: string;\n destinationChainId: number;\n destinationToken: string;\n /**\n * Integer amount: in source token units for `EXACT_INPUT`, in destination token units for `EXACT_OUTPUT`.\n */\n amount: string;\n swapType: NearIntentsSwapType;\n}\n\nexport interface NearIntentsQuoteResponse {\n /** Integer amount in source token units */\n amountIn: string;\n /** Integer amount in destination token units */\n amountOut: string;\n /** Integer amount in destination token units, the slippage floor */\n minAmountOut: string;\n /** Estimated transfer time, seconds */\n timeEstimate: number;\n /**\n * True when the server answered from its per-route quote model instead of a live 1Click quote.\n * Deposits are never estimated. Older servers omit it.\n */\n estimated: boolean;\n /** Absent on an estimated answer for a token without a catalog price */\n amountInUsd?: string;\n /** Absent on an estimated answer for a token without a catalog price */\n amountOutUsd?: string;\n}\n\nexport interface NearIntentsDepositRequest extends NearIntentsQuoteRequest {\n recipient: string;\n refundTo: string;\n}\n\nexport interface NearIntentsDepositResponse {\n depositAddress: string;\n depositMemo?: string;\n /** Integer amount in source token units */\n amountIn: string;\n /** Integer amount in destination token units */\n amountOut: string;\n /** Integer amount in destination token units, the slippage floor */\n minAmountOut: string;\n /** ISO 8601 */\n deadline: string;\n /** ISO 8601 */\n timeWhenInactive?: string;\n /** Estimated transfer time, seconds */\n timeEstimate: number;\n}\n\nexport interface NearIntentsSubmitDepositRequest {\n depositAddress: string;\n depositMemo?: string;\n txId: string;\n}\n\n/**\n * Error codes of the Core API NEAR Intents endpoints (HTTP 400 and 502 bodies).\n */\nexport type NearIntentsErrorCode = \"AMOUNT_TOO_LOW\" | \"NO_LIQUIDITY\" | \"FAILED_TO_GET_QUOTE\" | \"UPSTREAM_ERROR\";\n\nexport interface NearIntentsErrorResponse {\n code: NearIntentsErrorCode;\n message: string;\n minAmount?: string;\n minAmountUsd?: 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 /**\n * True when the transfer was refunded to the sender on the source chain instead of being delivered\n * (e.g. a {@link Messenger.NEAR_INTENTS} deposit refunded by NEAR Intents); `receive` stays absent.\n * Optional: older Core API versions may omit it.\n */\n refunded?: boolean;\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\n/**\n * @deprecated Do not use.\n */\nexport type PoolInfoResponse = Record<string, PoolInfo>;\n/**\n * @deprecated Do not use.\n */\nexport type PendingInfoResponse = Partial<Record<string, TokenPendingInfoDTO>>;\n/**\n * @deprecated Do not use.\n */\nexport type TokenPendingInfoDTO = Record<string, PendingInfoDTO>;\n\n/**\n * @deprecated Do not use.\n */\nexport interface PendingInfoDTO {\n pendingTxs: number;\n totalSentAmount: string;\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ChainDetailsMapWithFlags, PoolInfoMap, PoolKeyObject, TokenWithChainDetailsWithFlags } from "../../tokens-info";
|
|
2
2
|
import { ApiClient } from "./api-client";
|
|
3
|
-
import { GasBalanceResponse, PendingInfoResponse, ReceiveTransactionCostRequest, ReceiveTransactionCostResponse, TransferStatusResponse } from "./core-api.model";
|
|
3
|
+
import { GasBalanceResponse, NearIntentsDepositRequest, NearIntentsDepositResponse, NearIntentsQuoteRequest, NearIntentsQuoteResponse, NearIntentsSubmitDepositRequest, PendingInfoResponse, ReceiveTransactionCostRequest, ReceiveTransactionCostResponse, TransferStatusResponse } from "./core-api.model";
|
|
4
4
|
export interface AllbridgeCoreClientParams {
|
|
5
5
|
coreApiUrl: string;
|
|
6
6
|
coreApiHeaders?: Record<string, string>;
|
|
@@ -13,6 +13,9 @@ export interface AllbridgeCoreClient {
|
|
|
13
13
|
getTransferStatus(chainSymbol: string, txId: string): Promise<TransferStatusResponse>;
|
|
14
14
|
getReceiveTransactionCost(args: ReceiveTransactionCostRequest): Promise<ReceiveTransactionCostResponse>;
|
|
15
15
|
getGasBalance(chainSymbol: string, address: string): Promise<GasBalanceResponse>;
|
|
16
|
+
getNearIntentsQuote(args: NearIntentsQuoteRequest): Promise<NearIntentsQuoteResponse>;
|
|
17
|
+
createNearIntentsDeposit(args: NearIntentsDepositRequest): Promise<NearIntentsDepositResponse>;
|
|
18
|
+
submitNearIntentsDeposit(args: NearIntentsSubmitDepositRequest): Promise<void>;
|
|
16
19
|
}
|
|
17
20
|
export interface AllbridgeCoreClientWithTokens extends AllbridgeCoreClient {
|
|
18
21
|
getChainDetailsMap(): Promise<ChainDetailsMapWithFlags>;
|
|
@@ -47,4 +50,7 @@ export declare class AllbridgeCoreClientImpl implements AllbridgeCoreClientWithP
|
|
|
47
50
|
getReceiveTransactionCost(args: ReceiveTransactionCostRequest): Promise<ReceiveTransactionCostResponse>;
|
|
48
51
|
/** @deprecated Do not use. */
|
|
49
52
|
getPoolInfoMap(pools: PoolKeyObject[] | PoolKeyObject): Promise<PoolInfoMap>;
|
|
53
|
+
getNearIntentsQuote(args: NearIntentsQuoteRequest): Promise<NearIntentsQuoteResponse>;
|
|
54
|
+
createNearIntentsDeposit(args: NearIntentsDepositRequest): Promise<NearIntentsDepositResponse>;
|
|
55
|
+
submitNearIntentsDeposit(args: NearIntentsSubmitDepositRequest): Promise<void>;
|
|
50
56
|
}
|
|
@@ -31,5 +31,14 @@ export class AllbridgeCoreClientImpl {
|
|
|
31
31
|
async getPoolInfoMap(pools) {
|
|
32
32
|
return await this.apiClient.getPoolInfoMap(pools);
|
|
33
33
|
}
|
|
34
|
+
async getNearIntentsQuote(args) {
|
|
35
|
+
return await this.apiClient.getNearIntentsQuote(args);
|
|
36
|
+
}
|
|
37
|
+
async createNearIntentsDeposit(args) {
|
|
38
|
+
return await this.apiClient.createNearIntentsDeposit(args);
|
|
39
|
+
}
|
|
40
|
+
async submitNearIntentsDeposit(args) {
|
|
41
|
+
return await this.apiClient.submitNearIntentsDeposit(args);
|
|
42
|
+
}
|
|
34
43
|
}
|
|
35
44
|
//# sourceMappingURL=core-client-base.js.map
|