@kynesyslabs/demosdk 1.6.7 → 1.7.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.
Files changed (71) hide show
  1. package/build/abstraction/CoinFinder.d.ts +19 -11
  2. package/build/abstraction/CoinFinder.js +57 -22
  3. package/build/abstraction/CoinFinder.js.map +1 -1
  4. package/build/abstraction/EvmCoinFinder.d.ts +58 -12
  5. package/build/abstraction/EvmCoinFinder.js +154 -84
  6. package/build/abstraction/EvmCoinFinder.js.map +1 -1
  7. package/build/abstraction/Identities.d.ts +1 -30
  8. package/build/abstraction/Identities.js.map +1 -1
  9. package/build/abstraction/index.d.ts +4 -4
  10. package/build/abstraction/index.js +4 -4
  11. package/build/abstraction/index.js.map +1 -1
  12. package/build/abstraction/providers/AbstractionProviders.d.ts +2 -2
  13. package/build/abstraction/providers/AbstractionProviders.js +0 -2
  14. package/build/abstraction/providers/AbstractionProviders.js.map +1 -1
  15. package/build/abstraction/providers/CoinAddresses.d.ts +150 -1
  16. package/build/abstraction/providers/CoinAddresses.js +148 -2
  17. package/build/abstraction/providers/CoinAddresses.js.map +1 -1
  18. package/build/abstraction/providers/Providers.d.ts +2 -2
  19. package/build/abstraction/providers/Providers.js +12 -8
  20. package/build/abstraction/providers/Providers.js.map +1 -1
  21. package/build/abstraction/providers/{ankr.js → evm/ankr.js} +1 -1
  22. package/build/abstraction/providers/evm/ankr.js.map +1 -0
  23. package/build/abstraction/providers/{arbitrum.js → evm/arbitrum.js} +1 -1
  24. package/build/abstraction/providers/evm/arbitrum.js.map +1 -0
  25. package/build/abstraction/providers/{bsc.js → evm/bsc.js} +1 -1
  26. package/build/abstraction/providers/evm/bsc.js.map +1 -0
  27. package/build/abstraction/providers/{ethereum.js → evm/ethereum.js} +2 -2
  28. package/build/abstraction/providers/evm/ethereum.js.map +1 -0
  29. package/build/abstraction/providers/evm/index.d.ts +4 -0
  30. package/build/abstraction/providers/evm/index.js +15 -0
  31. package/build/abstraction/providers/evm/index.js.map +1 -0
  32. package/build/abstraction/providers/{optimism.js → evm/optimism.js} +1 -1
  33. package/build/abstraction/providers/evm/optimism.js.map +1 -0
  34. package/build/abstraction/providers/non-evm/bitcoin.d.ts +1 -0
  35. package/build/abstraction/providers/non-evm/bitcoin.js +23 -0
  36. package/build/abstraction/providers/non-evm/bitcoin.js.map +1 -0
  37. package/build/abstraction/providers/non-evm/index.d.ts +4 -0
  38. package/build/abstraction/providers/non-evm/index.js +15 -0
  39. package/build/abstraction/providers/non-evm/index.js.map +1 -0
  40. package/build/abstraction/providers/non-evm/multiversx.d.ts +1 -0
  41. package/build/abstraction/providers/non-evm/multiversx.js +23 -0
  42. package/build/abstraction/providers/non-evm/multiversx.js.map +1 -0
  43. package/build/abstraction/providers/non-evm/solana.d.ts +1 -0
  44. package/build/abstraction/providers/non-evm/solana.js +24 -0
  45. package/build/abstraction/providers/non-evm/solana.js.map +1 -0
  46. package/build/abstraction/providers/non-evm/xrp.d.ts +1 -0
  47. package/build/abstraction/providers/non-evm/xrp.js +23 -0
  48. package/build/abstraction/providers/non-evm/xrp.js.map +1 -0
  49. package/build/multichain/core/solana.js +3 -0
  50. package/build/multichain/core/solana.js.map +1 -1
  51. package/build/types/abstraction/index.d.ts +30 -0
  52. package/build/types/abstraction/index.js +3 -0
  53. package/build/types/abstraction/index.js.map +1 -0
  54. package/build/types/blockchain/GCREdit.d.ts +21 -0
  55. package/build/types/blockchain/GCREdit.js +5 -0
  56. package/build/types/blockchain/GCREdit.js.map +1 -0
  57. package/build/types/blockchain/Transaction.d.ts +2 -0
  58. package/build/types/index.d.ts +10 -9
  59. package/build/types/index.js.map +1 -1
  60. package/build/websdk/XMTransactions.d.ts +1 -1
  61. package/package.json +6 -5
  62. package/build/abstraction/providers/ankr.js.map +0 -1
  63. package/build/abstraction/providers/arbitrum.js.map +0 -1
  64. package/build/abstraction/providers/bsc.js.map +0 -1
  65. package/build/abstraction/providers/ethereum.js.map +0 -1
  66. package/build/abstraction/providers/optimism.js.map +0 -1
  67. /package/build/abstraction/providers/{ankr.d.ts → evm/ankr.d.ts} +0 -0
  68. /package/build/abstraction/providers/{arbitrum.d.ts → evm/arbitrum.d.ts} +0 -0
  69. /package/build/abstraction/providers/{bsc.d.ts → evm/bsc.d.ts} +0 -0
  70. /package/build/abstraction/providers/{ethereum.d.ts → evm/ethereum.d.ts} +0 -0
  71. /package/build/abstraction/providers/{optimism.d.ts → evm/optimism.d.ts} +0 -0
@@ -1,14 +1,22 @@
1
+ import { BaseChain, SupportedChain } from "./providers/CoinAddresses";
1
2
  /**
2
- * ? For each call, we should probably select a random RPC
3
- * ? from the Providers singleton and use that one in a for loop
4
- * ? that breaks when the call is successful.
5
- * ? This is to prevent any single RPC from being overloaded and
6
- * ? to be able to fail over to the next one in the list.
3
+ * Class for finding wrapped tokens on various chains
7
4
  */
8
- export default class CoinFinder {
9
- constructor();
10
- static findSol(targetChain: string): Promise<void>;
11
- static findMultiversx(targetChain: string): Promise<void>;
12
- static findXRP(targetChain: string): Promise<void>;
13
- static findBTC(targetChain: string): Promise<void>;
5
+ export declare class CoinFinder {
6
+ private static validateChain;
7
+ /**
8
+ * Finds the wrapped token address for a given source chain on a target chain
9
+ * @param {BaseChain} sourceChain The chain whose token we want to find (e.g., BITCOIN, SOLANA)
10
+ * @param {BaseChain} targetChain The chain where we want to find the wrapped token
11
+ * @returns {Promise<string | false>} The wrapped token address or false if not found
12
+ */
13
+ static findWrappedToken(sourceChain: BaseChain, targetChain: BaseChain): Promise<string | false>;
14
+ /**
15
+ * Gets the native token address for any supported chain
16
+ * @param {SupportedChain} chain The supported chain to find the native address for (e.g., "ethereum_mainnet")
17
+ * @param {number} targetChainId The chain ID to find the native address for (e.g., 1 for Ethereum mainnet)
18
+ * @returns {string} The native token address for the given chain ID
19
+ * @throws {Error} If chain ID doesn't match the chain or if chain is unsupported
20
+ */
21
+ static getNativeForSupportedChain(chain: SupportedChain, targetChainId?: number): string;
14
22
  }
@@ -1,32 +1,67 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // ! Use the Providers singleton with the methods of each chain RPC to find tokens
3
+ exports.CoinFinder = void 0;
4
+ const CoinAddresses_1 = require("./providers/CoinAddresses");
4
5
  /**
5
- * ? For each call, we should probably select a random RPC
6
- * ? from the Providers singleton and use that one in a for loop
7
- * ? that breaks when the call is successful.
8
- * ? This is to prevent any single RPC from being overloaded and
9
- * ? to be able to fail over to the next one in the list.
6
+ * Class for finding wrapped tokens on various chains
10
7
  */
11
8
  class CoinFinder {
12
- constructor() { }
13
- // TODO Implement supported chains (e.g. solana, multiversx, etc.) tokens cross search
14
- static async findSol(targetChain) {
15
- // TODO Validate the target chain id
16
- // TODO Get the wrapped sol address for the target chain
9
+ static validateChain(chain) {
10
+ if (!Object.values(CoinAddresses_1.BaseChain).includes(chain)) {
11
+ throw new Error(`Invalid chain: ${chain}`);
12
+ }
17
13
  }
18
- static async findMultiversx(targetChain) {
19
- // TODO Validate the target chain id
20
- // TODO Get the wrapped multiversx address for the target chain
14
+ /**
15
+ * Finds the wrapped token address for a given source chain on a target chain
16
+ * @param {BaseChain} sourceChain The chain whose token we want to find (e.g., BITCOIN, SOLANA)
17
+ * @param {BaseChain} targetChain The chain where we want to find the wrapped token
18
+ * @returns {Promise<string | false>} The wrapped token address or false if not found
19
+ */
20
+ static async findWrappedToken(sourceChain, targetChain) {
21
+ this.validateChain(sourceChain);
22
+ this.validateChain(targetChain);
23
+ return (CoinAddresses_1.tokenAddresses[sourceChain].wrapped?.[targetChain]?.mainnet || false);
21
24
  }
22
- static async findXRP(targetChain) {
23
- // TODO Validate the target chain id
24
- // TODO Get the wrapped xrp address for the target chain
25
- }
26
- static async findBTC(targetChain) {
27
- // TODO Validate the target chain id
28
- // TODO Get the wrapped btc address for the target chain
25
+ /**
26
+ * Gets the native token address for any supported chain
27
+ * @param {SupportedChain} chain The supported chain to find the native address for (e.g., "ethereum_mainnet")
28
+ * @param {number} targetChainId The chain ID to find the native address for (e.g., 1 for Ethereum mainnet)
29
+ * @returns {string} The native token address for the given chain ID
30
+ * @throws {Error} If chain ID doesn't match the chain or if chain is unsupported
31
+ */
32
+ static getNativeForSupportedChain(chain, targetChainId = 1) {
33
+ const [chainType, networkType] = chain.split("_");
34
+ // Handle EVM chains
35
+ switch (chainType) {
36
+ case CoinAddresses_1.BaseChain.ETHEREUM:
37
+ case CoinAddresses_1.BaseChain.BSC:
38
+ case CoinAddresses_1.BaseChain.ARBITRUM:
39
+ case CoinAddresses_1.BaseChain.OPTIMISM:
40
+ // Validate chain ID matches the chain
41
+ const chainIdMap = {
42
+ [CoinAddresses_1.BaseChain.ETHEREUM]: CoinAddresses_1.chainIds.eth.mainnet,
43
+ [CoinAddresses_1.BaseChain.BSC]: CoinAddresses_1.chainIds.bsc.mainnet,
44
+ [CoinAddresses_1.BaseChain.ARBITRUM]: CoinAddresses_1.chainIds.arbitrum.mainnet,
45
+ [CoinAddresses_1.BaseChain.OPTIMISM]: CoinAddresses_1.chainIds.optimism.mainnet,
46
+ };
47
+ if (targetChainId !== chainIdMap[chainType]) {
48
+ throw new Error(`Chain ID doesn't match ${chainType}`);
49
+ }
50
+ return CoinAddresses_1.tokenAddresses.ethereum[networkType];
51
+ // Handle non-EVM chains
52
+ case CoinAddresses_1.BaseChain.SOLANA:
53
+ case CoinAddresses_1.BaseChain.MULTIVERSX:
54
+ case CoinAddresses_1.BaseChain.XRP:
55
+ case CoinAddresses_1.BaseChain.BITCOIN:
56
+ case CoinAddresses_1.BaseChain.TON:
57
+ if (targetChainId !== 1) {
58
+ throw new Error("Non-EVM chains only support targetChainId 1");
59
+ }
60
+ return CoinAddresses_1.tokenAddresses[chainType][networkType];
61
+ default:
62
+ throw new Error(`Unsupported chain: ${chain}`);
63
+ }
29
64
  }
30
65
  }
31
- exports.default = CoinFinder;
66
+ exports.CoinFinder = CoinFinder;
32
67
  //# sourceMappingURL=CoinFinder.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CoinFinder.js","sourceRoot":"","sources":["../../../src/abstraction/CoinFinder.ts"],"names":[],"mappings":";;AAIA,kFAAkF;AAClF;;;;;;GAMG;AAEH,MAAqB,UAAU;IAC3B,gBAAe,CAAC;IAEhB,sFAAsF;IAEtF,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,WAAmB;QACpC,oCAAoC;QACpC,wDAAwD;IAC5D,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,WAAmB;QAC3C,oCAAoC;QACpC,+DAA+D;IACnE,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,WAAmB;QACpC,oCAAoC;QACpC,wDAAwD;IAC5D,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,WAAmB;QACpC,oCAAoC;QACpC,wDAAwD;IAC5D,CAAC;CACJ;AAxBD,6BAwBC"}
1
+ {"version":3,"file":"CoinFinder.js","sourceRoot":"","sources":["../../../src/abstraction/CoinFinder.ts"],"names":[],"mappings":";;;AAAA,6DAOkC;AAElC;;GAEG;AACH,MAAa,UAAU;IACX,MAAM,CAAC,aAAa,CAAC,KAAgB;QACzC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,yBAAS,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAC5C,MAAM,IAAI,KAAK,CAAC,kBAAkB,KAAK,EAAE,CAAC,CAAA;QAC9C,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,KAAK,CAAC,gBAAgB,CACzB,WAAsB,EACtB,WAAsB;QAEtB,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,CAAA;QAC/B,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,CAAA;QAC/B,OAAO,CACH,8BAAc,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,CAAC,WAAW,CAAC,EAAE,OAAO,IAAI,KAAK,CACvE,CAAA;IACL,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,0BA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C,WAAW,CAAC,CAAA;YAEjD;gBACI,MAAM,IAAI,KAAK,CAAC,sBAAsB,KAAK,EAAE,CAAC,CAAA;QACtD,CAAC;IACL,CAAC;CACJ;AA3ED,gCA2EC"}
@@ -1,15 +1,61 @@
1
- export type SupportedChain = "ethereum" | "bsc" | "arbitrum" | "optimism";
2
- export default class EvmCoinFinder {
1
+ import { chainIds } from "./providers/CoinAddresses";
2
+ type SupportedChainId = typeof chainIds.eth.mainnet | typeof chainIds.bsc.mainnet | typeof chainIds.arbitrum.mainnet | typeof chainIds.optimism.mainnet;
3
+ interface EvmTokenPair {
4
+ native: string;
5
+ wrapped: string | false;
6
+ }
7
+ /**
8
+ * Error class for EVM coin finder
9
+ * @extends Error
10
+ * @param {string} message - The error message
11
+ * @param {string} code - The error code
12
+ * @param {any} details - The error details
13
+ */
14
+ export declare class EvmError extends Error {
15
+ readonly code: string;
16
+ readonly details?: any;
17
+ constructor(message: string, code: string, details?: any);
18
+ }
19
+ /**
20
+ * Class for finding wrapped tokens on EVM chains
21
+ * @throws {EvmError} With code 'UNSUPPORTED_CHAIN_ID' if chain ID is not supported
22
+ * @throws {EvmError} With code 'INVALID_ADDRESS' if token address is invalid
23
+ * @throws {EvmError} With code 'CONTRACT_NOT_FOUND' if token contract doesn't exist
24
+ */
25
+ export declare class EvmCoinFinder {
26
+ private static getChainName;
3
27
  private static isValidAddress;
28
+ private static getChainNameFromId;
4
29
  private static getRandomProvider;
5
- static findNativeEth(targetChainIds: number[]): Promise<Record<number, {
6
- eth: string;
7
- weth: string;
8
- }>>;
9
- static findNativeAssets(targetChainIds: number[]): Promise<Record<number, {
10
- native: string;
11
- wrapped?: string;
12
- }>>;
13
- static findTokenPairs(tokenAddress: string, sourceChainId: number, targetChainIds: number[]): Promise<Record<number, string | false>>;
14
- static getNativeForSupportedChain(chain: SupportedChain, targetChainId: number): string;
30
+ static validateChainId(chainId: number): asserts chainId is SupportedChainId;
31
+ /**
32
+ * Finds native ETH and WETH addresses for given chain IDs
33
+ * @param {SupportedChainId[]} targetChainIds - Array of supported chain IDs
34
+ * @returns {Promise<Record<SupportedChainId, EvmTokenPair>>}
35
+ * @throws {EvmError} With code 'UNSUPPORTED_CHAIN_ID' if any chain ID is not supported
36
+ */
37
+ static findNativeEth(targetChainIds: SupportedChainId[]): Promise<Record<SupportedChainId, EvmTokenPair>>;
38
+ /**
39
+ * Finds the wrapped assets for the given chain IDs
40
+ * @param {SupportedChainId[]} targetChainIds The chain IDs to find wrapped assets for
41
+ * @returns {Promise<Record<number, EvmTokenPair>>} An object with the wrapped assets for each chain ID or false if not found
42
+ */
43
+ static findWrappedAssets(targetChainIds: SupportedChainId[]): Promise<Record<SupportedChainId, EvmTokenPair>>;
44
+ /**
45
+ * Finds wrapped token addresses across different chains
46
+ * @param {string} tokenAddress - Token address on source chain
47
+ * @param {SupportedChainId} sourceChainId - Chain ID where token exists
48
+ * @param {SupportedChainId[]} targetChainIds - Chain IDs to find wrapped versions
49
+ * @returns {Promise<Record<SupportedChainId, EvmTokenPair>>} Map of chain IDs to token addresses
50
+ * @throws {EvmError} With various error codes for different failure cases
51
+ */
52
+ static findTokenPairs(tokenAddress: string, sourceChainId: SupportedChainId, targetChainIds: SupportedChainId[]): Promise<Record<SupportedChainId, EvmTokenPair>>;
53
+ /**
54
+ * Finds the native address for the given chain ID
55
+ * @param {string} chain The chain to find the native address for
56
+ * @param {number} targetChainId The chain ID to find the native address for
57
+ * @returns {string} The native address for the given chain ID
58
+ */
59
+ static getNativeForSupportedChain(chain: string, targetChainId: number): string;
15
60
  }
61
+ export {};
@@ -36,16 +36,66 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.EvmCoinFinder = exports.EvmError = void 0;
39
40
  const providers_1 = __importDefault(require("./providers"));
40
41
  const CoinAddresses_1 = require("./providers/CoinAddresses");
41
42
  const ethers = __importStar(require("ethers"));
42
- const CoinAddresses_2 = require("./providers/CoinAddresses");
43
+ /**
44
+ * Error class for EVM coin finder
45
+ * @extends Error
46
+ * @param {string} message - The error message
47
+ * @param {string} code - The error code
48
+ * @param {any} details - The error details
49
+ */
50
+ class EvmError extends Error {
51
+ constructor(message, code, details) {
52
+ super(message);
53
+ this.code = code;
54
+ this.details = details;
55
+ }
56
+ }
57
+ exports.EvmError = EvmError;
58
+ /**
59
+ * Class for finding wrapped tokens on EVM chains
60
+ * @throws {EvmError} With code 'UNSUPPORTED_CHAIN_ID' if chain ID is not supported
61
+ * @throws {EvmError} With code 'INVALID_ADDRESS' if token address is invalid
62
+ * @throws {EvmError} With code 'CONTRACT_NOT_FOUND' if token contract doesn't exist
63
+ */
43
64
  class EvmCoinFinder {
65
+ static getChainName(chainId) {
66
+ switch (chainId) {
67
+ case CoinAddresses_1.chainIds.eth.mainnet:
68
+ return CoinAddresses_1.BaseChain.ETHEREUM;
69
+ case CoinAddresses_1.chainIds.bsc.mainnet:
70
+ return CoinAddresses_1.BaseChain.BSC;
71
+ case CoinAddresses_1.chainIds.arbitrum.mainnet:
72
+ return CoinAddresses_1.BaseChain.ARBITRUM;
73
+ case CoinAddresses_1.chainIds.optimism.mainnet:
74
+ return CoinAddresses_1.BaseChain.OPTIMISM;
75
+ default:
76
+ throw new Error(`Unsupported chain ID: ${chainId}`);
77
+ }
78
+ }
44
79
  static isValidAddress(address) {
45
80
  return ethers.isAddress(address);
46
81
  }
82
+ static getChainNameFromId(chainId) {
83
+ switch (chainId) {
84
+ case CoinAddresses_1.chainIds.eth.mainnet:
85
+ return CoinAddresses_1.BaseChain.ETHEREUM;
86
+ case CoinAddresses_1.chainIds.bsc.mainnet:
87
+ return CoinAddresses_1.BaseChain.BSC;
88
+ case CoinAddresses_1.chainIds.arbitrum.mainnet:
89
+ return CoinAddresses_1.BaseChain.ARBITRUM;
90
+ case CoinAddresses_1.chainIds.optimism.mainnet:
91
+ return CoinAddresses_1.BaseChain.OPTIMISM;
92
+ default:
93
+ return undefined;
94
+ }
95
+ }
47
96
  static async getRandomProvider(chainId) {
48
- const rpcUrls = providers_1.default.evm[chainId.toString()];
97
+ // Filter out Flashbots and Payload RPCs
98
+ const rpcUrls = providers_1.default.evm[chainId.toString()].filter(url => !url.includes("flashbots.net") && !url.includes("payload.de"));
49
99
  if (!rpcUrls || rpcUrls.length === 0) {
50
100
  throw new Error(`No providers found for chain ${chainId}`);
51
101
  }
@@ -55,9 +105,10 @@ class EvmCoinFinder {
55
105
  for (const rpcUrl of shuffledUrls) {
56
106
  try {
57
107
  // Create ethers provider
58
- const provider = new ethers.JsonRpcProvider(rpcUrl);
59
- // Test the connection
60
- await provider.getNetwork();
108
+ const provider = new ethers.JsonRpcProvider(rpcUrl, undefined, {
109
+ staticNetwork: true, // Prevent network detection
110
+ });
111
+ await provider.getNetwork(); // Test the connection
61
112
  return provider;
62
113
  }
63
114
  catch (error) {
@@ -67,71 +118,75 @@ class EvmCoinFinder {
67
118
  }
68
119
  throw new Error(`All RPC providers failed for chain ${chainId}`);
69
120
  }
121
+ static validateChainId(chainId) {
122
+ if (!Object.values(CoinAddresses_1.chainIds).some(chain => Object.values(chain).includes(chainId))) {
123
+ throw new EvmError(`Unsupported chain ID: ${chainId}`, "UNSUPPORTED_CHAIN_ID");
124
+ }
125
+ }
126
+ /**
127
+ * Finds native ETH and WETH addresses for given chain IDs
128
+ * @param {SupportedChainId[]} targetChainIds - Array of supported chain IDs
129
+ * @returns {Promise<Record<SupportedChainId, EvmTokenPair>>}
130
+ * @throws {EvmError} With code 'UNSUPPORTED_CHAIN_ID' if any chain ID is not supported
131
+ */
70
132
  static async findNativeEth(targetChainIds) {
71
133
  const result = {};
72
134
  for (const chainId of targetChainIds) {
73
- // First validate if chainId is supported
74
- if (![
75
- CoinAddresses_2.chainIds.eth.mainnet,
76
- CoinAddresses_2.chainIds.bsc.mainnet,
77
- CoinAddresses_2.chainIds.arbitrum.mainnet,
78
- CoinAddresses_2.chainIds.optimism.mainnet,
79
- ].includes(chainId)) {
80
- throw new Error(`Invalid chain ID: ${chainId}`);
81
- }
135
+ this.validateChainId(chainId);
82
136
  let weth;
83
137
  switch (chainId) {
84
- case CoinAddresses_2.chainIds.eth.mainnet:
85
- weth = CoinAddresses_1.tokenAddresses.eth.wrapped.ethereum.mainnet;
138
+ case CoinAddresses_1.chainIds.eth.mainnet:
139
+ weth = CoinAddresses_1.tokenAddresses.ethereum.wrapped.ethereum.mainnet;
86
140
  break;
87
- case CoinAddresses_2.chainIds.bsc.mainnet:
88
- weth = CoinAddresses_1.tokenAddresses.eth.wrapped.bsc.mainnet;
141
+ case CoinAddresses_1.chainIds.bsc.mainnet:
142
+ weth = CoinAddresses_1.tokenAddresses.ethereum.wrapped.bsc.mainnet;
89
143
  break;
90
- case CoinAddresses_2.chainIds.arbitrum.mainnet:
91
- weth = CoinAddresses_1.tokenAddresses.eth.wrapped.arbitrum.mainnet;
144
+ case CoinAddresses_1.chainIds.arbitrum.mainnet:
145
+ weth = CoinAddresses_1.tokenAddresses.ethereum.wrapped.arbitrum.mainnet;
92
146
  break;
93
- case CoinAddresses_2.chainIds.optimism.mainnet:
94
- weth = CoinAddresses_1.tokenAddresses.eth.wrapped.optimism.mainnet;
147
+ case CoinAddresses_1.chainIds.optimism.mainnet:
148
+ weth = CoinAddresses_1.tokenAddresses.ethereum.wrapped.optimism.mainnet;
95
149
  break;
96
150
  }
97
151
  if (weth) {
98
152
  result[chainId] = {
99
- eth: CoinAddresses_1.tokenAddresses.eth.mainnet, // native ETH
100
- weth: weth, // wrapped ETH
153
+ native: CoinAddresses_1.tokenAddresses.ethereum.mainnet, // native ETH
154
+ wrapped: weth, // wrapped ETH
101
155
  };
102
156
  }
103
157
  }
104
158
  return result;
105
159
  }
106
- static async findNativeAssets(targetChainIds) {
160
+ /**
161
+ * Finds the wrapped assets for the given chain IDs
162
+ * @param {SupportedChainId[]} targetChainIds The chain IDs to find wrapped assets for
163
+ * @returns {Promise<Record<number, EvmTokenPair>>} An object with the wrapped assets for each chain ID or false if not found
164
+ */
165
+ static async findWrappedAssets(targetChainIds) {
107
166
  const result = {};
108
167
  for (const chainId of targetChainIds) {
109
- let wrapped;
110
- switch (chainId) {
111
- case CoinAddresses_2.chainIds.eth.mainnet:
112
- wrapped = CoinAddresses_1.tokenAddresses.eth.wrapped.ethereum.mainnet;
113
- break;
114
- case CoinAddresses_2.chainIds.bsc.mainnet:
115
- wrapped = CoinAddresses_1.tokenAddresses.eth.wrapped.bsc.mainnet;
116
- break;
117
- case CoinAddresses_2.chainIds.arbitrum.mainnet:
118
- wrapped = CoinAddresses_1.tokenAddresses.eth.wrapped.arbitrum.mainnet;
119
- break;
120
- case CoinAddresses_2.chainIds.optimism.mainnet:
121
- wrapped = CoinAddresses_1.tokenAddresses.eth.wrapped.optimism.mainnet;
122
- break;
123
- }
124
- // Always include native, wrapped is optional
168
+ this.validateChainId(chainId);
125
169
  result[chainId] = {
126
- native: CoinAddresses_1.tokenAddresses.eth.mainnet,
127
- ...(wrapped && { wrapped }), // Only include wrapped if it exists
170
+ native: CoinAddresses_1.tokenAddresses.ethereum.mainnet,
171
+ wrapped: CoinAddresses_1.tokenAddresses.ethereum.wrapped[this.getChainName(chainId)]
172
+ ?.mainnet || false,
128
173
  };
129
174
  }
130
175
  return result;
131
176
  }
177
+ /**
178
+ * Finds wrapped token addresses across different chains
179
+ * @param {string} tokenAddress - Token address on source chain
180
+ * @param {SupportedChainId} sourceChainId - Chain ID where token exists
181
+ * @param {SupportedChainId[]} targetChainIds - Chain IDs to find wrapped versions
182
+ * @returns {Promise<Record<SupportedChainId, EvmTokenPair>>} Map of chain IDs to token addresses
183
+ * @throws {EvmError} With various error codes for different failure cases
184
+ */
132
185
  static async findTokenPairs(tokenAddress, sourceChainId, targetChainIds) {
133
186
  if (!this.isValidAddress(tokenAddress)) {
134
- throw new Error("Invalid token address");
187
+ throw new EvmError("Invalid token address", "INVALID_ADDRESS", {
188
+ address: tokenAddress,
189
+ });
135
190
  }
136
191
  const result = {};
137
192
  // Verify token exists on source chain
@@ -140,62 +195,77 @@ class EvmCoinFinder {
140
195
  if (code === "0x") {
141
196
  throw new Error("Token contract not found on source chain");
142
197
  }
143
- // Find corresponding tokens on target chains
144
- for (const chainId of targetChainIds) {
145
- // If source and target chains are the same, return the same address
146
- if (chainId === sourceChainId) {
147
- result[chainId] = tokenAddress;
198
+ // Get chain names for lookup
199
+ const sourceChain = this.getChainNameFromId(sourceChainId);
200
+ if (!sourceChain) {
201
+ throw new Error(`Unsupported chain ID: ${sourceChainId}`);
202
+ }
203
+ for (const targetChainId of targetChainIds) {
204
+ // Same chain = same address
205
+ if (targetChainId === sourceChainId) {
206
+ result[targetChainId] = {
207
+ native: tokenAddress,
208
+ wrapped: false,
209
+ };
148
210
  continue;
149
211
  }
150
- let mappedToken = false;
151
- // Check if it's USDC
152
- if (tokenAddress === CoinAddresses_1.tokenAddresses.usdc.ethereum.mainnet) {
153
- if (chainId === CoinAddresses_2.chainIds.bsc.mainnet) {
154
- mappedToken = CoinAddresses_1.tokenAddresses.usdc.bsc.mainnet;
155
- }
156
- else if (chainId === CoinAddresses_2.chainIds.arbitrum.mainnet) {
157
- mappedToken = CoinAddresses_1.tokenAddresses.usdc.arbitrum.mainnet;
158
- }
159
- else if (chainId === CoinAddresses_2.chainIds.optimism.mainnet) {
160
- mappedToken = CoinAddresses_1.tokenAddresses.usdc.optimism.mainnet;
161
- }
212
+ const targetChain = this.getChainNameFromId(targetChainId);
213
+ if (!targetChain) {
214
+ result[targetChainId] = {
215
+ native: tokenAddress,
216
+ wrapped: false,
217
+ };
218
+ continue;
162
219
  }
163
- // Check if it's USDT
164
- else if (tokenAddress === CoinAddresses_1.tokenAddresses.usdt.ethereum.mainnet) {
165
- if (chainId === CoinAddresses_2.chainIds.bsc.mainnet) {
166
- mappedToken = CoinAddresses_1.tokenAddresses.usdt.bsc.mainnet;
167
- }
168
- else if (chainId === CoinAddresses_2.chainIds.arbitrum.mainnet) {
169
- mappedToken = CoinAddresses_1.tokenAddresses.usdt.arbitrum.mainnet;
170
- }
171
- else if (chainId === CoinAddresses_2.chainIds.optimism.mainnet) {
172
- mappedToken = CoinAddresses_1.tokenAddresses.usdt.optimism.mainnet;
173
- }
220
+ // Check USDC mapping
221
+ if (tokenAddress === CoinAddresses_1.tokenAddresses.usdc[sourceChain]?.mainnet) {
222
+ result[targetChainId] = {
223
+ native: tokenAddress,
224
+ wrapped: CoinAddresses_1.tokenAddresses.usdc[targetChain]?.mainnet || false,
225
+ };
226
+ continue;
227
+ }
228
+ // Check USDT mapping
229
+ if (tokenAddress === CoinAddresses_1.tokenAddresses.usdt[sourceChain]?.mainnet) {
230
+ result[targetChainId] = {
231
+ native: tokenAddress,
232
+ wrapped: CoinAddresses_1.tokenAddresses.usdt[targetChain]?.mainnet || false,
233
+ };
234
+ continue;
174
235
  }
175
- result[chainId] = mappedToken;
236
+ result[targetChainId] = {
237
+ native: tokenAddress,
238
+ wrapped: false,
239
+ };
176
240
  }
177
241
  return result;
178
242
  }
243
+ /**
244
+ * Finds the native address for the given chain ID
245
+ * @param {string} chain The chain to find the native address for
246
+ * @param {number} targetChainId The chain ID to find the native address for
247
+ * @returns {string} The native address for the given chain ID
248
+ */
179
249
  static getNativeForSupportedChain(chain, targetChainId) {
180
250
  // Validate chain matches targetChainId
181
251
  switch (chain) {
182
- case "ethereum":
183
- if (targetChainId !== CoinAddresses_2.chainIds.eth.mainnet) {
252
+ case CoinAddresses_1.BaseChain.ETHEREUM:
253
+ if (targetChainId !== CoinAddresses_1.chainIds.eth.mainnet) {
184
254
  throw new Error("Chain ID doesn't match ethereum");
185
255
  }
186
- break;
187
- case "bsc":
188
- if (targetChainId !== CoinAddresses_2.chainIds.bsc.mainnet) {
256
+ return CoinAddresses_1.tokenAddresses.ethereum.mainnet;
257
+ case CoinAddresses_1.BaseChain.BSC:
258
+ if (targetChainId !== CoinAddresses_1.chainIds.bsc.mainnet) {
189
259
  throw new Error("Chain ID doesn't match bsc");
190
260
  }
191
261
  break;
192
- case "arbitrum":
193
- if (targetChainId !== CoinAddresses_2.chainIds.arbitrum.mainnet) {
262
+ case CoinAddresses_1.BaseChain.ARBITRUM:
263
+ if (targetChainId !== CoinAddresses_1.chainIds.arbitrum.mainnet) {
194
264
  throw new Error("Chain ID doesn't match arbitrum");
195
265
  }
196
266
  break;
197
- case "optimism":
198
- if (targetChainId !== CoinAddresses_2.chainIds.optimism.mainnet) {
267
+ case CoinAddresses_1.BaseChain.OPTIMISM:
268
+ if (targetChainId !== CoinAddresses_1.chainIds.optimism.mainnet) {
199
269
  throw new Error("Chain ID doesn't match optimism");
200
270
  }
201
271
  break;
@@ -203,8 +273,8 @@ class EvmCoinFinder {
203
273
  throw new Error(`Unsupported chain: ${chain}`);
204
274
  }
205
275
  // Return native address (0x0)
206
- return CoinAddresses_1.tokenAddresses.eth.mainnet;
276
+ return CoinAddresses_1.tokenAddresses.ethereum.mainnet;
207
277
  }
208
278
  }
209
- exports.default = EvmCoinFinder;
279
+ exports.EvmCoinFinder = EvmCoinFinder;
210
280
  //# sourceMappingURL=EvmCoinFinder.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EvmCoinFinder.js","sourceRoot":"","sources":["../../../src/abstraction/EvmCoinFinder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAAmC;AACnC,6DAA0D;AAC1D,+CAAgC;AAChC,6DAAoD;AAGpD,MAAqB,aAAa;IACtB,MAAM,CAAC,cAAc,CAAC,OAAe;QACzC,OAAO,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;IACpC,CAAC;IAEO,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,OAAe;QAClD,MAAM,OAAO,GAAG,mBAAS,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAA;QAEjD,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC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ACpB,OAAO,EAAE,KAAK;aACjB,CAAA;QACL,CAAC;QAED,OAAO,MAAM,CAAA;IACjB,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,0BAA0B,CAC7B,KAAa,EACb,aAAqB;QAErB,uCAAuC;QACvC,QAAQ,KAAK,EAAE,CAAC;YACZ,KAAK,yBAAS,CAAC,QAAQ;gBACnB,IAAI,aAAa,KAAK,wBAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;oBACzC,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAA;gBACtD,CAAC;gBACD,OAAO,8BAAc,CAAC,QAAQ,CAAC,OAAO,CAAA;YAC1C,KAAK,yBAAS,CAAC,GAAG;gBACd,IAAI,aAAa,KAAK,wBAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;oBACzC,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAA;gBACjD,CAAC;gBACD,MAAK;YACT,KAAK,yBAAS,CAAC,QAAQ;gBACnB,IAAI,aAAa,KAAK,wBAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;oBAC9C,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAA;gBACtD,CAAC;gBACD,MAAK;YACT,KAAK,yBAAS,CAAC,QAAQ;gBACnB,IAAI,aAAa,KAAK,wBAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;oBAC9C,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAA;gBACtD,CAAC;gBACD,MAAK;YACT;gBACI,MAAM,IAAI,KAAK,CAAC,sBAAsB,KAAK,EAAE,CAAC,CAAA;QACtD,CAAC;QAED,8BAA8B;QAC9B,OAAO,8BAAc,CAAC,QAAQ,CAAC,OAAO,CAAA;IAC1C,CAAC;CACJ;AAvQD,sCAuQC"}
@@ -1,33 +1,4 @@
1
- export interface InferFromWritePayload {
2
- method: "identity_assign_from_write";
3
- demos_identity: {
4
- address: string;
5
- signedData: string;
6
- signature: string;
7
- };
8
- target_identity: {
9
- txHash: string;
10
- targetAddress: string;
11
- isEVM: boolean;
12
- chainId: number | string;
13
- rpcUrl?: string;
14
- };
15
- }
16
- export interface InferFromSignaturePayload {
17
- method: "identity_assign_from_signature";
18
- demos_identity: {
19
- address: string;
20
- signedData: string;
21
- signature: string;
22
- };
23
- target_identity: {
24
- signature: string;
25
- signedData: string;
26
- targetAddress: string;
27
- isEVM: boolean;
28
- chainId: number | string;
29
- };
30
- }
1
+ import { InferFromWritePayload, InferFromSignaturePayload } from "../types/abstraction";
31
2
  export default class Identities {
32
3
  constructor();
33
4
  inferIdentity(payload: InferFromWritePayload | InferFromSignaturePayload): Promise<string | false>;
@@ -1 +1 @@
1
- {"version":3,"file":"Identities.js","sourceRoot":"","sources":["../../../src/abstraction/Identities.ts"],"names":[],"mappings":";AAAA,4CAA4C;AAC5C,8EAA8E;;AAoC9E,MAAqB,UAAU;IAC3B,gBAAe,CAAC;IAEhB,gEAAgE;IAChE,KAAK,CAAC,aAAa,CACf,OAA0D;QAE1D,MAAM,WAAW,GAAG;YAChB,MAAM,EAAE,aAAa;YACrB,MAAM,EAAE;gBACJ;oBACI,MAAM,EAAE,OAAO,CAAC,MAAM;oBACtB,MAAM,EAAE,CAAC,OAAO,CAAC;iBACpB;aACJ;SACJ,CAAA;QACD,8BAA8B;QAC9B,OAAO,KAAK,CAAA;IAChB,CAAC;CACJ;AAnBD,6BAmBC"}
1
+ {"version":3,"file":"Identities.js","sourceRoot":"","sources":["../../../src/abstraction/Identities.ts"],"names":[],"mappings":";AAAA,4CAA4C;AAC5C,8EAA8E;;AAO9E,MAAqB,UAAU;IAC3B,gBAAe,CAAC;IAEhB,gEAAgE;IAChE,KAAK,CAAC,aAAa,CACf,OAA0D;QAE1D,MAAM,WAAW,GAAG;YAChB,MAAM,EAAE,aAAa;YACrB,MAAM,EAAE;gBACJ;oBACI,MAAM,EAAE,OAAO,CAAC,MAAM;oBACtB,MAAM,EAAE,CAAC,OAAO,CAAC;iBACpB;aACJ;SACJ,CAAA;QACD,8BAA8B;QAC9B,OAAO,KAAK,CAAA;IAChB,CAAC;CACJ;AAnBD,6BAmBC"}
@@ -4,8 +4,8 @@
4
4
  * This is to ensure that the finders don't get rate limited or go offline.
5
5
  * This also means that the SDK calls should be made locally (using the ip address of the user).
6
6
  */
7
- import EvmCoinFinder from "./EvmCoinFinder";
8
- import CoinFinder from "./CoinFinder";
7
+ import { EvmCoinFinder } from "./EvmCoinFinder";
8
+ import { CoinFinder } from "./CoinFinder";
9
9
  import Identities from "./Identities";
10
- import { InferFromWritePayload, InferFromSignaturePayload } from "./Identities";
11
- export { EvmCoinFinder, CoinFinder, Identities, InferFromWritePayload, InferFromSignaturePayload };
10
+ import { InferFromWritePayload, InferFromSignaturePayload } from "../types/abstraction";
11
+ export { EvmCoinFinder, CoinFinder, Identities, InferFromWritePayload, InferFromSignaturePayload, };