@rhinestone/sdk 1.0.18 → 1.0.19
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.
|
@@ -7,7 +7,7 @@ const providers_1 = require("./providers");
|
|
|
7
7
|
(0, vitest_1.describe)('Alchemy', () => {
|
|
8
8
|
(0, vitest_1.test)('Network', () => {
|
|
9
9
|
const mockApiKey = '123';
|
|
10
|
-
(0, vitest_1.expect)((0, providers_1.getAlchemyUrl)(chains_1.
|
|
10
|
+
(0, vitest_1.expect)((0, providers_1.getAlchemyUrl)(chains_1.arbitrum.id, mockApiKey)).toBe('https://arb-mainnet.g.alchemy.com/v2/123');
|
|
11
11
|
(0, vitest_1.expect)((0, providers_1.getAlchemyUrl)(chains_1.sepolia.id, mockApiKey)).toBe('https://eth-sepolia.g.alchemy.com/v2/123');
|
|
12
12
|
(0, vitest_1.expect)((0, providers_1.getAlchemyUrl)(chains_1.polygon.id, mockApiKey)).toBe('https://polygon-mainnet.g.alchemy.com/v2/123');
|
|
13
13
|
});
|
|
@@ -15,29 +15,29 @@ const providers_1 = require("./providers");
|
|
|
15
15
|
(0, vitest_1.describe)('Custom', () => {
|
|
16
16
|
(0, vitest_1.test)('Returns URL for configured chain', () => {
|
|
17
17
|
const urls = {
|
|
18
|
-
[chains_1.
|
|
18
|
+
[chains_1.arbitrum.id]: 'https://my-rpc.example.com/mainnet',
|
|
19
19
|
[chains_1.sepolia.id]: 'https://my-rpc.example.com/sepolia',
|
|
20
20
|
};
|
|
21
|
-
(0, vitest_1.expect)((0, providers_1.getCustomUrl)(chains_1.
|
|
21
|
+
(0, vitest_1.expect)((0, providers_1.getCustomUrl)(chains_1.arbitrum.id, urls)).toBe('https://my-rpc.example.com/mainnet');
|
|
22
22
|
(0, vitest_1.expect)((0, providers_1.getCustomUrl)(chains_1.sepolia.id, urls)).toBe('https://my-rpc.example.com/sepolia');
|
|
23
23
|
});
|
|
24
24
|
(0, vitest_1.test)('Throws error when chain not configured', () => {
|
|
25
25
|
const urls = {
|
|
26
|
-
[chains_1.
|
|
26
|
+
[chains_1.arbitrum.id]: 'https://my-rpc.example.com/mainnet',
|
|
27
27
|
};
|
|
28
28
|
(0, vitest_1.expect)(() => (0, providers_1.getCustomUrl)(chains_1.sepolia.id, urls)).toThrow('No custom provider URL configured for chain 11155111');
|
|
29
29
|
});
|
|
30
30
|
(0, vitest_1.test)('Accepts HTTP URLs', () => {
|
|
31
31
|
const urls = {
|
|
32
|
-
[chains_1.
|
|
32
|
+
[chains_1.arbitrum.id]: 'http://localhost:8545',
|
|
33
33
|
};
|
|
34
|
-
(0, vitest_1.expect)((0, providers_1.getCustomUrl)(chains_1.
|
|
34
|
+
(0, vitest_1.expect)((0, providers_1.getCustomUrl)(chains_1.arbitrum.id, urls)).toBe('http://localhost:8545');
|
|
35
35
|
});
|
|
36
36
|
(0, vitest_1.test)('Accepts HTTPS URLs', () => {
|
|
37
37
|
const urls = {
|
|
38
|
-
[chains_1.
|
|
38
|
+
[chains_1.arbitrum.id]: 'https://my-rpc.example.com',
|
|
39
39
|
};
|
|
40
|
-
(0, vitest_1.expect)((0, providers_1.getCustomUrl)(chains_1.
|
|
40
|
+
(0, vitest_1.expect)((0, providers_1.getCustomUrl)(chains_1.arbitrum.id, urls)).toBe('https://my-rpc.example.com');
|
|
41
41
|
});
|
|
42
42
|
});
|
|
43
43
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../orchestrator/registry.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,KAAK,EAA0B,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../orchestrator/registry.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,KAAK,EAA0B,MAAM,MAAM,CAAA;AAEvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAE3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C,iBAAS,oBAAoB,IAAI,MAAM,EAAE,CAExC;AAMD,iBAAS,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAY7C;AAED,iBAAS,cAAc,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAetE;AAED,iBAAS,eAAe,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAsB3E;AAED,iBAAS,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,CAM5C;AAED,iBAAS,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAG3C;AAED,iBAAS,uBAAuB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAS3E;AAED,iBAAS,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,EAAE,CAO1D;AAED,iBAAS,2BAA2B,CAAC,UAAU,CAAC,EAAE,OAAO;;EAaxD;AAED,iBAAS,mBAAmB,CAC1B,KAAK,EAAE,WAAW,GAAG,OAAO,EAC5B,OAAO,EAAE,MAAM,GACd,OAAO,CAKT;AAED,iBAAS,8BAA8B,IAAI;IACzC,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,WAAW,EAAE,CAAA;CACtB,EAAE,CAMF;AAED,OAAO,EACL,cAAc,EACd,eAAe,EACf,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,oBAAoB,EACpB,SAAS,EACT,uBAAuB,EACvB,2BAA2B,EAC3B,mBAAmB,EACnB,8BAA8B,GAC/B,CAAA"}
|
|
@@ -63,28 +63,12 @@ function getTokenAddress(tokenSymbol, chainId) {
|
|
|
63
63
|
}
|
|
64
64
|
return token.address;
|
|
65
65
|
}
|
|
66
|
-
function isChainIdSupported(chainId) {
|
|
67
|
-
const chainIds = shared_configs_1.chains.map((chain) => chain.id);
|
|
68
|
-
return chainIds.includes(chainId);
|
|
69
|
-
}
|
|
70
66
|
function getChainById(chainId) {
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
[chains_1.sepolia.id]: chains_1.sepolia,
|
|
74
|
-
[chains_1.base.id]: chains_1.base,
|
|
75
|
-
[chains_1.baseSepolia.id]: chains_1.baseSepolia,
|
|
76
|
-
[chains_1.arbitrum.id]: chains_1.arbitrum,
|
|
77
|
-
[chains_1.arbitrumSepolia.id]: chains_1.arbitrumSepolia,
|
|
78
|
-
[chains_1.optimism.id]: chains_1.optimism,
|
|
79
|
-
[chains_1.optimismSepolia.id]: chains_1.optimismSepolia,
|
|
80
|
-
[chains_1.polygon.id]: chains_1.polygon,
|
|
81
|
-
[chains_1.soneium.id]: chains_1.soneium,
|
|
82
|
-
[chains_1.sonic.id]: chains_1.sonic,
|
|
83
|
-
};
|
|
84
|
-
if (!isChainIdSupported(chainId)) {
|
|
67
|
+
const chain = shared_configs_1.chains.find((chain) => chain.id === chainId);
|
|
68
|
+
if (!chain) {
|
|
85
69
|
throw new error_1.UnsupportedChainError(chainId);
|
|
86
70
|
}
|
|
87
|
-
return
|
|
71
|
+
return chain;
|
|
88
72
|
}
|
|
89
73
|
function isTestnet(chainId) {
|
|
90
74
|
const chain = getChainById(chainId);
|
|
@@ -13,7 +13,7 @@ const TOKEN_SYMBOLS = {
|
|
|
13
13
|
WETH: 'WETH',
|
|
14
14
|
};
|
|
15
15
|
const TOKEN_ADDRESSES = {
|
|
16
|
-
|
|
16
|
+
ARBTRUM_USDC: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
|
|
17
17
|
BASE_WETH: '0x4200000000000000000000000000000000000006',
|
|
18
18
|
};
|
|
19
19
|
const UNSUPPORTED_TOKEN_ADDRESS = '0x1234567890123456789012345678901234567890';
|
|
@@ -21,7 +21,7 @@ const UNSUPPORTED_TOKEN_ADDRESS = '0x1234567890123456789012345678901234567890';
|
|
|
21
21
|
(0, vitest_1.describe)('getSupportedChainIds', () => {
|
|
22
22
|
(0, vitest_1.test)('returns supported chain IDs', () => {
|
|
23
23
|
const chainIds = (0, registry_1.getSupportedChainIds)();
|
|
24
|
-
(0, vitest_1.expect)(chainIds).toContain(chains_1.
|
|
24
|
+
(0, vitest_1.expect)(chainIds).toContain(chains_1.arbitrum.id);
|
|
25
25
|
(0, vitest_1.expect)(chainIds).toContain(chains_1.base.id);
|
|
26
26
|
(0, vitest_1.expect)(chainIds).toContain(chains_1.sepolia.id);
|
|
27
27
|
});
|
|
@@ -33,21 +33,21 @@ const UNSUPPORTED_TOKEN_ADDRESS = '0x1234567890123456789012345678901234567890';
|
|
|
33
33
|
});
|
|
34
34
|
(0, vitest_1.describe)('getTokenSymbol', () => {
|
|
35
35
|
(0, vitest_1.test)('returns correct symbol for supported token', () => {
|
|
36
|
-
const symbol = (0, registry_1.getTokenSymbol)(TOKEN_ADDRESSES.
|
|
36
|
+
const symbol = (0, registry_1.getTokenSymbol)(TOKEN_ADDRESSES.ARBTRUM_USDC, chains_1.arbitrum.id);
|
|
37
37
|
(0, vitest_1.expect)(symbol).toBe(TOKEN_SYMBOLS.USDC);
|
|
38
38
|
});
|
|
39
39
|
(0, vitest_1.test)('throws error for unsupported chain', () => {
|
|
40
|
-
(0, vitest_1.expect)(() => (0, registry_1.getTokenSymbol)(TOKEN_ADDRESSES.
|
|
40
|
+
(0, vitest_1.expect)(() => (0, registry_1.getTokenSymbol)(TOKEN_ADDRESSES.ARBTRUM_USDC, UNSUPPORTED_CHAIN_ID)).toThrow(`Unsupported chain ${UNSUPPORTED_CHAIN_ID}`);
|
|
41
41
|
});
|
|
42
42
|
});
|
|
43
43
|
(0, vitest_1.describe)('getTokenAddress', () => {
|
|
44
44
|
(0, vitest_1.test)('returns zero address for ETH', () => {
|
|
45
|
-
const address = (0, registry_1.getTokenAddress)(TOKEN_SYMBOLS.ETH, chains_1.
|
|
45
|
+
const address = (0, registry_1.getTokenAddress)(TOKEN_SYMBOLS.ETH, chains_1.arbitrum.id);
|
|
46
46
|
(0, vitest_1.expect)(address).toBe(viem_1.zeroAddress);
|
|
47
47
|
});
|
|
48
48
|
(0, vitest_1.test)('returns correct address for token symbol', () => {
|
|
49
|
-
const address = (0, registry_1.getTokenAddress)(TOKEN_SYMBOLS.USDC, chains_1.
|
|
50
|
-
(0, vitest_1.expect)(address).toBe(TOKEN_ADDRESSES.
|
|
49
|
+
const address = (0, registry_1.getTokenAddress)(TOKEN_SYMBOLS.USDC, chains_1.arbitrum.id);
|
|
50
|
+
(0, vitest_1.expect)(address).toBe(TOKEN_ADDRESSES.ARBTRUM_USDC);
|
|
51
51
|
});
|
|
52
52
|
(0, vitest_1.test)('throws error for unsupported chain', () => {
|
|
53
53
|
(0, vitest_1.expect)(() => (0, registry_1.getTokenAddress)(TOKEN_SYMBOLS.USDC, UNSUPPORTED_CHAIN_ID)).toThrow(`Unsupported chain ${UNSUPPORTED_CHAIN_ID}`);
|
|
@@ -68,17 +68,17 @@ const UNSUPPORTED_TOKEN_ADDRESS = '0x1234567890123456789012345678901234567890';
|
|
|
68
68
|
});
|
|
69
69
|
(0, vitest_1.describe)('getChainById', () => {
|
|
70
70
|
(0, vitest_1.test)('returns correct chain for supported ID', () => {
|
|
71
|
-
const chain = (0, registry_1.getChainById)(chains_1.
|
|
72
|
-
(0, vitest_1.expect)(chain.id).toBe(chains_1.
|
|
73
|
-
(0, vitest_1.expect)(chain.name).toBe(chains_1.
|
|
71
|
+
const chain = (0, registry_1.getChainById)(chains_1.arbitrum.id);
|
|
72
|
+
(0, vitest_1.expect)(chain.id).toBe(chains_1.arbitrum.id);
|
|
73
|
+
(0, vitest_1.expect)(chain.name).toBe(chains_1.arbitrum.name);
|
|
74
74
|
});
|
|
75
75
|
(0, vitest_1.test)('throws error for unsupported chain', () => {
|
|
76
76
|
(0, vitest_1.expect)(() => (0, registry_1.getChainById)(UNSUPPORTED_CHAIN_ID)).toThrow(`Unsupported chain ${UNSUPPORTED_CHAIN_ID}`);
|
|
77
77
|
});
|
|
78
78
|
});
|
|
79
79
|
(0, vitest_1.describe)('isTestnet', () => {
|
|
80
|
-
(0, vitest_1.test)('returns false for
|
|
81
|
-
(0, vitest_1.expect)((0, registry_1.isTestnet)(chains_1.
|
|
80
|
+
(0, vitest_1.test)('returns false for arbitrum', () => {
|
|
81
|
+
(0, vitest_1.expect)((0, registry_1.isTestnet)(chains_1.arbitrum.id)).toBe(false);
|
|
82
82
|
});
|
|
83
83
|
(0, vitest_1.test)('returns true for testnet', () => {
|
|
84
84
|
(0, vitest_1.expect)((0, registry_1.isTestnet)(chains_1.sepolia.id)).toBe(true);
|
|
@@ -89,17 +89,17 @@ const UNSUPPORTED_TOKEN_ADDRESS = '0x1234567890123456789012345678901234567890';
|
|
|
89
89
|
});
|
|
90
90
|
(0, vitest_1.describe)('isTokenAddressSupported', () => {
|
|
91
91
|
(0, vitest_1.test)('returns true for supported token', () => {
|
|
92
|
-
const isSupported = (0, registry_1.isTokenAddressSupported)(TOKEN_ADDRESSES.
|
|
92
|
+
const isSupported = (0, registry_1.isTokenAddressSupported)(TOKEN_ADDRESSES.ARBTRUM_USDC, chains_1.arbitrum.id);
|
|
93
93
|
(0, vitest_1.expect)(isSupported).toBe(true);
|
|
94
94
|
});
|
|
95
95
|
(0, vitest_1.test)('returns false for unsupported token or chain', () => {
|
|
96
|
-
(0, vitest_1.expect)((0, registry_1.isTokenAddressSupported)(UNSUPPORTED_TOKEN_ADDRESS, chains_1.
|
|
97
|
-
(0, vitest_1.expect)((0, registry_1.isTokenAddressSupported)(TOKEN_ADDRESSES.
|
|
96
|
+
(0, vitest_1.expect)((0, registry_1.isTokenAddressSupported)(UNSUPPORTED_TOKEN_ADDRESS, chains_1.arbitrum.id)).toBe(false);
|
|
97
|
+
(0, vitest_1.expect)((0, registry_1.isTokenAddressSupported)(TOKEN_ADDRESSES.ARBTRUM_USDC, UNSUPPORTED_CHAIN_ID)).toBe(false);
|
|
98
98
|
});
|
|
99
99
|
});
|
|
100
100
|
(0, vitest_1.describe)('getSupportedTokens', () => {
|
|
101
101
|
(0, vitest_1.test)('returns tokens for supported chain', () => {
|
|
102
|
-
const tokens = (0, registry_1.getSupportedTokens)(chains_1.
|
|
102
|
+
const tokens = (0, registry_1.getSupportedTokens)(chains_1.arbitrum.id);
|
|
103
103
|
(0, vitest_1.expect)(tokens.length).toBeGreaterThan(0);
|
|
104
104
|
(0, vitest_1.expect)(tokens.find((t) => t.symbol === TOKEN_SYMBOLS.USDC)).toBeDefined();
|
|
105
105
|
});
|
|
@@ -109,23 +109,23 @@ const UNSUPPORTED_TOKEN_ADDRESS = '0x1234567890123456789012345678901234567890';
|
|
|
109
109
|
});
|
|
110
110
|
(0, vitest_1.describe)('getDefaultAccountAccessList', () => {
|
|
111
111
|
(0, vitest_1.test)('filters chains by testnet status', () => {
|
|
112
|
-
const
|
|
112
|
+
const arbitrumList = (0, registry_1.getDefaultAccountAccessList)(false);
|
|
113
113
|
const testnetList = (0, registry_1.getDefaultAccountAccessList)(true);
|
|
114
|
-
(0, vitest_1.expect)(
|
|
115
|
-
(0, vitest_1.expect)(
|
|
114
|
+
(0, vitest_1.expect)(arbitrumList.chainIds).toContain(chains_1.arbitrum.id);
|
|
115
|
+
(0, vitest_1.expect)(arbitrumList.chainIds).not.toContain(chains_1.sepolia.id);
|
|
116
116
|
(0, vitest_1.expect)(testnetList.chainIds).toContain(chains_1.sepolia.id);
|
|
117
|
-
(0, vitest_1.expect)(testnetList.chainIds).not.toContain(chains_1.
|
|
117
|
+
(0, vitest_1.expect)(testnetList.chainIds).not.toContain(chains_1.arbitrum.id);
|
|
118
118
|
});
|
|
119
119
|
});
|
|
120
120
|
(0, vitest_1.describe)('resolveTokenAddress', () => {
|
|
121
121
|
(0, vitest_1.test)('returns address as-is when given valid address', () => {
|
|
122
|
-
const address = TOKEN_ADDRESSES.
|
|
123
|
-
const result = (0, registry_1.resolveTokenAddress)(address, chains_1.
|
|
122
|
+
const address = TOKEN_ADDRESSES.ARBTRUM_USDC;
|
|
123
|
+
const result = (0, registry_1.resolveTokenAddress)(address, chains_1.arbitrum.id);
|
|
124
124
|
(0, vitest_1.expect)(result).toBe(address);
|
|
125
125
|
});
|
|
126
126
|
(0, vitest_1.test)('resolves token symbol to address', () => {
|
|
127
|
-
const result = (0, registry_1.resolveTokenAddress)(TOKEN_SYMBOLS.USDC, chains_1.
|
|
128
|
-
(0, vitest_1.expect)(result).toBe(TOKEN_ADDRESSES.
|
|
127
|
+
const result = (0, registry_1.resolveTokenAddress)(TOKEN_SYMBOLS.USDC, chains_1.arbitrum.id);
|
|
128
|
+
(0, vitest_1.expect)(result).toBe(TOKEN_ADDRESSES.ARBTRUM_USDC);
|
|
129
129
|
});
|
|
130
130
|
(0, vitest_1.test)('throw error for unsupported token', () => {
|
|
131
131
|
(0, vitest_1.expect)(() => (0, registry_1.resolveTokenAddress)(TOKEN_SYMBOLS.USDT, chains_1.baseSepolia.id)).toThrow(`Unsupported token ${TOKEN_SYMBOLS.USDT} for chain ${chains_1.baseSepolia.id}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rhinestone/sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.19",
|
|
4
4
|
"description": "End-to-end chain abstraction and modularity toolkit",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Rhinestone",
|
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
"access": "public"
|
|
127
127
|
},
|
|
128
128
|
"dependencies": {
|
|
129
|
-
"@rhinestone/shared-configs": "^1.4.
|
|
129
|
+
"@rhinestone/shared-configs": "^1.4.17",
|
|
130
130
|
"ox": "^0.9.11",
|
|
131
131
|
"solady": "^0.1.26"
|
|
132
132
|
},
|