@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.
- package/build/abstraction/CoinFinder.d.ts +19 -11
- package/build/abstraction/CoinFinder.js +57 -22
- package/build/abstraction/CoinFinder.js.map +1 -1
- package/build/abstraction/EvmCoinFinder.d.ts +58 -12
- package/build/abstraction/EvmCoinFinder.js +154 -84
- package/build/abstraction/EvmCoinFinder.js.map +1 -1
- package/build/abstraction/Identities.d.ts +1 -30
- package/build/abstraction/Identities.js.map +1 -1
- package/build/abstraction/index.d.ts +4 -4
- package/build/abstraction/index.js +4 -4
- package/build/abstraction/index.js.map +1 -1
- package/build/abstraction/providers/AbstractionProviders.d.ts +2 -2
- package/build/abstraction/providers/AbstractionProviders.js +0 -2
- package/build/abstraction/providers/AbstractionProviders.js.map +1 -1
- package/build/abstraction/providers/CoinAddresses.d.ts +150 -1
- package/build/abstraction/providers/CoinAddresses.js +148 -2
- package/build/abstraction/providers/CoinAddresses.js.map +1 -1
- package/build/abstraction/providers/Providers.d.ts +2 -2
- package/build/abstraction/providers/Providers.js +12 -8
- package/build/abstraction/providers/Providers.js.map +1 -1
- package/build/abstraction/providers/{ankr.js → evm/ankr.js} +1 -1
- package/build/abstraction/providers/evm/ankr.js.map +1 -0
- package/build/abstraction/providers/{arbitrum.js → evm/arbitrum.js} +1 -1
- package/build/abstraction/providers/evm/arbitrum.js.map +1 -0
- package/build/abstraction/providers/{bsc.js → evm/bsc.js} +1 -1
- package/build/abstraction/providers/evm/bsc.js.map +1 -0
- package/build/abstraction/providers/{ethereum.js → evm/ethereum.js} +2 -2
- package/build/abstraction/providers/evm/ethereum.js.map +1 -0
- package/build/abstraction/providers/evm/index.d.ts +4 -0
- package/build/abstraction/providers/evm/index.js +15 -0
- package/build/abstraction/providers/evm/index.js.map +1 -0
- package/build/abstraction/providers/{optimism.js → evm/optimism.js} +1 -1
- package/build/abstraction/providers/evm/optimism.js.map +1 -0
- package/build/abstraction/providers/non-evm/bitcoin.d.ts +1 -0
- package/build/abstraction/providers/non-evm/bitcoin.js +23 -0
- package/build/abstraction/providers/non-evm/bitcoin.js.map +1 -0
- package/build/abstraction/providers/non-evm/index.d.ts +4 -0
- package/build/abstraction/providers/non-evm/index.js +15 -0
- package/build/abstraction/providers/non-evm/index.js.map +1 -0
- package/build/abstraction/providers/non-evm/multiversx.d.ts +1 -0
- package/build/abstraction/providers/non-evm/multiversx.js +23 -0
- package/build/abstraction/providers/non-evm/multiversx.js.map +1 -0
- package/build/abstraction/providers/non-evm/solana.d.ts +1 -0
- package/build/abstraction/providers/non-evm/solana.js +24 -0
- package/build/abstraction/providers/non-evm/solana.js.map +1 -0
- package/build/abstraction/providers/non-evm/xrp.d.ts +1 -0
- package/build/abstraction/providers/non-evm/xrp.js +23 -0
- package/build/abstraction/providers/non-evm/xrp.js.map +1 -0
- package/build/multichain/core/solana.js +3 -0
- package/build/multichain/core/solana.js.map +1 -1
- package/build/types/abstraction/index.d.ts +30 -0
- package/build/types/abstraction/index.js +3 -0
- package/build/types/abstraction/index.js.map +1 -0
- package/build/types/blockchain/GCREdit.d.ts +21 -0
- package/build/types/blockchain/GCREdit.js +5 -0
- package/build/types/blockchain/GCREdit.js.map +1 -0
- package/build/types/blockchain/Transaction.d.ts +2 -0
- package/build/types/index.d.ts +10 -9
- package/build/types/index.js.map +1 -1
- package/build/websdk/XMTransactions.d.ts +1 -1
- package/package.json +6 -5
- package/build/abstraction/providers/ankr.js.map +0 -1
- package/build/abstraction/providers/arbitrum.js.map +0 -1
- package/build/abstraction/providers/bsc.js.map +0 -1
- package/build/abstraction/providers/ethereum.js.map +0 -1
- package/build/abstraction/providers/optimism.js.map +0 -1
- /package/build/abstraction/providers/{ankr.d.ts → evm/ankr.d.ts} +0 -0
- /package/build/abstraction/providers/{arbitrum.d.ts → evm/arbitrum.d.ts} +0 -0
- /package/build/abstraction/providers/{bsc.d.ts → evm/bsc.d.ts} +0 -0
- /package/build/abstraction/providers/{ethereum.d.ts → evm/ethereum.d.ts} +0 -0
- /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
|
-
*
|
|
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
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
3
|
+
exports.CoinFinder = void 0;
|
|
4
|
+
const CoinAddresses_1 = require("./providers/CoinAddresses");
|
|
4
5
|
/**
|
|
5
|
-
*
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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.
|
|
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":"
|
|
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,0BAA0B,CAC7B,KAAqB,EACrB,gBAAwB,CAAC;QAEzB,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAG/C,CAAA;QAED,oBAAoB;QACpB,QAAQ,SAAS,EAAE,CAAC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|
|
2
|
-
|
|
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
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
60
|
-
|
|
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
|
-
|
|
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
|
|
85
|
-
weth = CoinAddresses_1.tokenAddresses.
|
|
138
|
+
case CoinAddresses_1.chainIds.eth.mainnet:
|
|
139
|
+
weth = CoinAddresses_1.tokenAddresses.ethereum.wrapped.ethereum.mainnet;
|
|
86
140
|
break;
|
|
87
|
-
case
|
|
88
|
-
weth = CoinAddresses_1.tokenAddresses.
|
|
141
|
+
case CoinAddresses_1.chainIds.bsc.mainnet:
|
|
142
|
+
weth = CoinAddresses_1.tokenAddresses.ethereum.wrapped.bsc.mainnet;
|
|
89
143
|
break;
|
|
90
|
-
case
|
|
91
|
-
weth = CoinAddresses_1.tokenAddresses.
|
|
144
|
+
case CoinAddresses_1.chainIds.arbitrum.mainnet:
|
|
145
|
+
weth = CoinAddresses_1.tokenAddresses.ethereum.wrapped.arbitrum.mainnet;
|
|
92
146
|
break;
|
|
93
|
-
case
|
|
94
|
-
weth = CoinAddresses_1.tokenAddresses.
|
|
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
|
-
|
|
100
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
127
|
-
|
|
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
|
|
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
|
-
//
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
|
|
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
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
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[
|
|
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
|
|
183
|
-
if (targetChainId !==
|
|
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
|
-
|
|
187
|
-
case
|
|
188
|
-
if (targetChainId !==
|
|
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
|
|
193
|
-
if (targetChainId !==
|
|
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
|
|
198
|
-
if (targetChainId !==
|
|
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.
|
|
276
|
+
return CoinAddresses_1.tokenAddresses.ethereum.mainnet;
|
|
207
277
|
}
|
|
208
278
|
}
|
|
209
|
-
exports.
|
|
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":"
|
|
1
|
+
{"version":3,"file":"EvmCoinFinder.js","sourceRoot":"","sources":["../../../src/abstraction/EvmCoinFinder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAAmC;AACnC,6DAA+E;AAC/E,+CAAgC;AAahC;;;;;;GAMG;AACH,MAAa,QAAS,SAAQ,KAAK;IAC/B,YACI,OAAe,EACC,IAAY,EACZ,OAAa;QAE7B,KAAK,CAAC,OAAO,CAAC,CAAA;QAHE,SAAI,GAAJ,IAAI,CAAQ;QACZ,YAAO,GAAP,OAAO,CAAM;IAGjC,CAAC;CACJ;AARD,4BAQC;AAED;;;;;GAKG;AACH,MAAa,aAAa;IACd,MAAM,CAAC,YAAY,CAA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,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
|
-
|
|
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;;
|
|
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 "
|
|
11
|
-
export { EvmCoinFinder, CoinFinder, Identities, InferFromWritePayload, InferFromSignaturePayload };
|
|
10
|
+
import { InferFromWritePayload, InferFromSignaturePayload } from "../types/abstraction";
|
|
11
|
+
export { EvmCoinFinder, CoinFinder, Identities, InferFromWritePayload, InferFromSignaturePayload, };
|