@allbridge/bridge-core-sdk 3.35.1 → 3.36.0-beta.1

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.
@@ -20,11 +20,19 @@ export declare class ApiClientImpl implements ApiClient {
20
20
  private api;
21
21
  constructor(params: AllbridgeCoreClientParams);
22
22
  getTokenInfo(): Promise<TokenInfo>;
23
- /** @deprecated Do not use. */
23
+ /**
24
+ * @deprecated Do not use.
25
+ * The `/pending-info` endpoint was removed from the Core API together with the liquidity pools;
26
+ * always resolves to an empty object without calling the server.
27
+ */
24
28
  getPendingInfo(): Promise<PendingInfoResponse>;
25
29
  getGasBalance(chainSymbol: string, address: string): Promise<GasBalanceResponse>;
26
30
  getTransferStatus(chainSymbol: string, txId: string): Promise<TransferStatusResponse>;
27
31
  getReceiveTransactionCost(args: ReceiveTransactionCostRequest): Promise<ReceiveTransactionCostResponse>;
28
- /** @deprecated Do not use. */
29
- getPoolInfoMap(pools: PoolKeyObject[] | PoolKeyObject): Promise<PoolInfoMap>;
32
+ /**
33
+ * @deprecated Do not use.
34
+ * The `/pool-info` endpoint was removed from the Core API together with the liquidity pools;
35
+ * always resolves to an empty map without calling the server.
36
+ */
37
+ getPoolInfoMap(_pools: PoolKeyObject[] | PoolKeyObject): Promise<PoolInfoMap>;
30
38
  }
@@ -1,7 +1,7 @@
1
1
  import { AxiosHeaders, create } from "axios";
2
2
  import { InvalidMessengerOptionError } from "../../exceptions";
3
3
  import { VERSION } from "../../version";
4
- import { mapChainDetailsResponseToChainDetailsMap, mapChainDetailsResponseToPoolInfoMap, mapPoolInfoResponseToPoolInfoMap, } from "./core-api-mapper";
4
+ import { mapChainDetailsResponseToChainDetailsMap, mapChainDetailsResponseToPoolInfoMap } from "./core-api-mapper";
5
5
  import { Messenger, } from "./core-api.model";
6
6
  export class ApiClientImpl {
7
7
  api;
@@ -40,10 +40,13 @@ export class ApiClientImpl {
40
40
  poolInfoMap: mapChainDetailsResponseToPoolInfoMap(data),
41
41
  };
42
42
  }
43
- /** @deprecated Do not use. */
44
- async getPendingInfo() {
45
- const { data } = await this.api.get("/pending-info");
46
- return data;
43
+ /**
44
+ * @deprecated Do not use.
45
+ * The `/pending-info` endpoint was removed from the Core API together with the liquidity pools;
46
+ * always resolves to an empty object without calling the server.
47
+ */
48
+ getPendingInfo() {
49
+ return Promise.resolve({});
47
50
  }
48
51
  async getGasBalance(chainSymbol, address) {
49
52
  const { data } = await this.api.get(`/check/${chainSymbol}/${address}`);
@@ -70,15 +73,13 @@ export class ApiClientImpl {
70
73
  adminFeeShareWithExtras: data.adminFeeShareWithExtras,
71
74
  };
72
75
  }
73
- /** @deprecated Do not use. */
74
- async getPoolInfoMap(pools) {
75
- const poolKeys = pools instanceof Array ? pools : [pools];
76
- const { data } = await this.api.post("/pool-info", { pools: poolKeys }, {
77
- headers: {
78
- "Content-Type": "application/json",
79
- },
80
- });
81
- return mapPoolInfoResponseToPoolInfoMap(data);
76
+ /**
77
+ * @deprecated Do not use.
78
+ * The `/pool-info` endpoint was removed from the Core API together with the liquidity pools;
79
+ * always resolves to an empty map without calling the server.
80
+ */
81
+ getPoolInfoMap(_pools) {
82
+ return Promise.resolve({});
82
83
  }
83
84
  }
84
85
  //# 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,EACL,wCAAwC,EACxC,oCAAoC,EACpC,gCAAgC,GACjC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAGL,SAAS,GAMV,MAAM,kBAAkB,CAAC;AAyB1B,MAAM,OAAO,aAAa;IAChB,GAAG,CAAQ;IAEnB,Y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,IAAI,CAAC,sBAAsB;YACnD,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,uBAAuB,EAAE,IAAI,CAAC,uBAAuB;SACtD,CAAC;IACJ,CAAC;IAED,8BAA8B;IAC9B,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,gCAAgC,CAAC,IAAI,CAAC,CAAC;IAChD,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 {\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 /** @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 /** @deprecated Do not use. */\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 abrExchangeRate: data.abrExchangeRate,\n adminFeeShareWithExtras: data.adminFeeShareWithExtras,\n };\n }\n\n /** @deprecated Do not use. */\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"]}
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;IAChB,GAAG,CAAQ;IAEnB,YAAY,MAAiC;QAC3C,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC;YAChB,OAAO,EAAE,MAAM,CAAC,UAAU;YAC1B,OAAO,EAAE;gBACP,MAAM,EAAE,kBAAkB;gBAC1B,GAAG,MAAM,CAAC,cAAc;gBACxB,aAAa,EAAE,mBAAmB,GAAG,OAAO;a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ionError } 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"]}
@@ -3,6 +3,7 @@ import { ChainDetailsResponse, PoolInfoResponse } from "./core-api.model";
3
3
  export declare function mapChainDetailsResponseToChainDetailsMap(response: ChainDetailsResponse): ChainDetailsMapWithFlags;
4
4
  /**
5
5
  * @deprecated Do not use.
6
+ * The current Core API does not serve pool data, so the result is empty for it.
6
7
  */
7
8
  export declare function mapChainDetailsResponseToPoolInfoMap(response: ChainDetailsResponse): PoolInfoMap;
8
9
  /**
@@ -14,29 +14,39 @@ export function mapChainDetailsResponseToChainDetailsMap(response) {
14
14
  }
15
15
  /**
16
16
  * @deprecated Do not use.
17
+ * The current Core API does not serve pool data, so the result is empty for it.
17
18
  */
18
19
  export function mapChainDetailsResponseToPoolInfoMap(response) {
19
20
  const poolInfoMap = {};
20
21
  for (const [chainSymbolValue, chainDetailsDTO] of Object.entries(response)) {
21
22
  const chainSymbol = chainSymbolValue;
22
23
  for (const token of chainDetailsDTO.tokens) {
23
- const poolKey = mapPoolKeyObjectToPoolKey({
24
- chainSymbol,
25
- poolAddress: token.poolAddress,
26
- });
27
- const imbalance = calculatePoolInfoImbalance(token.poolInfo);
28
- poolInfoMap[poolKey] = { ...token.poolInfo, imbalance };
24
+ const { poolAddress, poolInfo } = token;
25
+ if (!poolAddress || !poolInfo) {
26
+ continue;
27
+ }
28
+ const poolKey = mapPoolKeyObjectToPoolKey({ chainSymbol, poolAddress });
29
+ const imbalance = calculatePoolInfoImbalance(poolInfo);
30
+ poolInfoMap[poolKey] = { ...poolInfo, imbalance };
29
31
  }
30
32
  }
31
33
  return poolInfoMap;
32
34
  }
35
+ /**
36
+ * Flags assumed for tokens served without them: the current Core API returns every token as a token to send
37
+ * and has no liquidity pools.
38
+ */
39
+ const DEFAULT_TOKEN_FLAGS = { swap: true, pool: false };
33
40
  function mapTokenWithChainDetailsFromDto(chainDetails, dto) {
34
41
  const { name: chainName, ...chainDetailsWithoutName } = chainDetails;
35
- const { poolInfo: _poolInfo, ...dtoWithoutPoolInfo } = dto;
42
+ const { poolInfo: _poolInfo, flags, ...dtoWithoutPoolInfo } = dto;
43
+ // The deprecated pool-era token fields (poolAddress, feeShare, apr, lpRate, ...) are kept on the public type
44
+ // for backward compatibility but are undefined when served by the current Core API.
36
45
  return {
37
46
  ...dtoWithoutPoolInfo,
38
47
  ...chainDetailsWithoutName,
39
48
  chainName,
49
+ flags: flags ?? { ...DEFAULT_TOKEN_FLAGS },
40
50
  };
41
51
  }
42
52
  function mapMessengerKeyDtoToMessenger(dto) {
@@ -75,6 +85,8 @@ function mapChainDetailsFromDto(chainSymbol, dto) {
75
85
  if (!basicChainProperties) {
76
86
  return null;
77
87
  }
88
+ // bridgeAddress is deprecated and undefined when served by the current Core API; the public type keeps it
89
+ // for backward compatibility.
78
90
  const chainDetails = {
79
91
  ...basicChainProperties,
80
92
  allbridgeChainId: dto.chainId,
@@ -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,GAAG,YAAY,CAAC;QAClC,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oCAAoC,CAAC,QAA8B;IACjF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A8B;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 */\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 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 const chainDetails: 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 };\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;AACr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AAS,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"]}
@@ -12,11 +12,12 @@ export interface ChainDetailsDTO {
12
12
  chainId: number;
13
13
  bridgeId?: string;
14
14
  paddingUtilId?: string;
15
- /** @deprecated Do not use. */
16
- bridgeAddress: string;
15
+ /** @deprecated Do not use. Not served by the current Core API. */
16
+ bridgeAddress?: string;
17
17
  oftBridgeAddress?: string;
18
18
  abrPayer?: AbrPayerChainInfoDTO;
19
- swapAddress: string;
19
+ /** @deprecated Do not use. Not served by the current Core API. */
20
+ swapAddress?: string;
20
21
  /**
21
22
  * @deprecated Do not use.
22
23
  */
@@ -38,22 +39,23 @@ export interface TokenDTO {
38
39
  symbol: string;
39
40
  name: string;
40
41
  decimals: number;
41
- /** @deprecated Do not use. */
42
- poolAddress: string;
42
+ /** @deprecated Do not use. Not served by the current Core API. */
43
+ poolAddress?: string;
43
44
  tokenAddress: string;
44
- /** @deprecated Do not use. */
45
- poolInfo: PoolInfoDTO;
45
+ originTokenAddress?: string;
46
+ /** @deprecated Do not use. Not served by the current Core API. */
47
+ poolInfo?: PoolInfoDTO;
46
48
  oftId?: string;
47
- /** @deprecated Do not use. */
48
- feeShare: string;
49
- /** @deprecated Do not use. */
50
- apr: string;
51
- /** @deprecated Do not use. */
52
- apr7d: string;
53
- /** @deprecated Do not use. */
54
- apr30d: string;
55
- /** @deprecated Do not use. */
56
- lpRate: string;
49
+ /** @deprecated Do not use. Not served by the current Core API. */
50
+ feeShare?: string;
51
+ /** @deprecated Do not use. Not served by the current Core API. */
52
+ apr?: string;
53
+ /** @deprecated Do not use. Not served by the current Core API. */
54
+ apr7d?: string;
55
+ /** @deprecated Do not use. Not served by the current Core API. */
56
+ apr30d?: string;
57
+ /** @deprecated Do not use. Not served by the current Core API. */
58
+ lpRate?: string;
57
59
  cctpAddress?: string;
58
60
  cctpV2Address?: string;
59
61
  cctpFeeShare?: string;
@@ -63,7 +65,11 @@ export interface TokenDTO {
63
65
  */
64
66
  yieldId?: number;
65
67
  xReserve?: XReserveDTO;
66
- flags: {
68
+ /**
69
+ * Optional: the current Core API always returns all tokens and omits the flags,
70
+ * in which case every token is treated as `swap: true, pool: false`.
71
+ */
72
+ flags?: {
67
73
  swap: boolean;
68
74
  /** @deprecated Do not use. */
69
75
  pool: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"core-api.model.js","sourceRoot":"","sources":["../../../../src/client/core-api/core-api.model.ts"],"names":[],"mappings":"AAgCA,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;AA0DD,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. */\n bridgeAddress: string;\n oftBridgeAddress?: string;\n abrPayer?: AbrPayerChainInfoDTO;\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. */\n poolAddress: string;\n tokenAddress: string;\n /** @deprecated Do not use. */\n poolInfo: PoolInfoDTO;\n oftId?: string;\n /** @deprecated Do not use. */\n feeShare: string;\n /** @deprecated Do not use. */\n apr: string;\n /** @deprecated Do not use. */\n apr7d: string;\n /** @deprecated Do not use. */\n apr30d: string;\n /** @deprecated Do not use. */\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 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;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 +1 @@
1
- export declare const VERSION = "3.35.1";
1
+ export declare const VERSION = "3.36.0-beta.1";
@@ -1,2 +1,2 @@
1
- export const VERSION = "3.35.1";
1
+ export const VERSION = "3.36.0-beta.1";
2
2
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["export const VERSION = \"3.35.1\";\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,eAAe,CAAC","sourcesContent":["export const VERSION = \"3.36.0-beta.1\";\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allbridge/bridge-core-sdk",
3
- "version": "3.35.1",
3
+ "version": "3.36.0-beta.1",
4
4
  "main": "./dist/cjs/index.js",
5
5
  "module": "./dist/esm/index.js",
6
6
  "types": "./dist/src/index.d.ts",