carbon-js-sdk 0.3.26 → 0.3.27-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.
- package/lib/CarbonSDK.d.ts +1 -0
- package/lib/CarbonSDK.js +10 -0
- package/lib/clients/ETHClient.d.ts +1 -0
- package/lib/clients/ETHClient.js +2 -1
- package/lib/clients/HydrogenClient.d.ts +2 -2
- package/lib/clients/HydrogenClient.js +7 -1
- package/lib/constant/network.d.ts +1 -0
- package/lib/constant/network.js +36 -0
- package/lib/provider/metamask/MetaMask.d.ts +2 -2
- package/lib/provider/metamask/MetaMask.js +43 -0
- package/lib/util/blockchain.d.ts +1 -1
- package/lib/util/blockchain.js +3 -1
- package/package.json +1 -1
package/lib/CarbonSDK.d.ts
CHANGED
package/lib/CarbonSDK.js
CHANGED
|
@@ -106,10 +106,20 @@ class CarbonSDK {
|
|
|
106
106
|
blockchain: blockchain_1.Blockchain.BinanceSmartChain,
|
|
107
107
|
tokenClient: this.token,
|
|
108
108
|
});
|
|
109
|
+
this.arbitrum = clients_1.ETHClient.instance({
|
|
110
|
+
configProvider: this,
|
|
111
|
+
blockchain: blockchain_1.Blockchain.Arbitrum,
|
|
112
|
+
tokenClient: this.token,
|
|
113
|
+
});
|
|
109
114
|
this.zil = clients_1.ZILClient.instance({
|
|
110
115
|
configProvider: this,
|
|
111
116
|
blockchain: blockchain_1.Blockchain.Zilliqa,
|
|
112
117
|
});
|
|
118
|
+
this.arbitrum = clients_1.ETHClient.instance({
|
|
119
|
+
configProvider: this,
|
|
120
|
+
blockchain: blockchain_1.Blockchain.Arbitrum,
|
|
121
|
+
tokenClient: this.token,
|
|
122
|
+
});
|
|
113
123
|
}
|
|
114
124
|
static instance(opts = DEFAULT_SDK_INIT_OPTS) {
|
|
115
125
|
var _a, _b, _c, _d;
|
package/lib/clients/ETHClient.js
CHANGED
|
@@ -349,9 +349,10 @@ class ETHClient {
|
|
|
349
349
|
}
|
|
350
350
|
}
|
|
351
351
|
exports.ETHClient = ETHClient;
|
|
352
|
-
ETHClient.SUPPORTED_BLOCKCHAINS = [blockchain_1.Blockchain.BinanceSmartChain, blockchain_1.Blockchain.Ethereum];
|
|
352
|
+
ETHClient.SUPPORTED_BLOCKCHAINS = [blockchain_1.Blockchain.BinanceSmartChain, blockchain_1.Blockchain.Ethereum, blockchain_1.Blockchain.Arbitrum];
|
|
353
353
|
ETHClient.BLOCKCHAIN_KEY = {
|
|
354
354
|
[blockchain_1.Blockchain.BinanceSmartChain]: "bsc",
|
|
355
355
|
[blockchain_1.Blockchain.Ethereum]: "eth",
|
|
356
|
+
[blockchain_1.Blockchain.Arbitrum]: "arbitrum",
|
|
356
357
|
};
|
|
357
358
|
exports.default = ETHClient;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NetworkConfig } from "../constant";
|
|
2
|
-
import { GetDetailedTransfersResponse, GetRelaysRequest, GetStatsResponse, GetTransfersRequest, GetTransfersResponse } from "../hydrogen";
|
|
2
|
+
import { GetDetailedTransfersResponse, GetRelaysRequest, GetRelaysResponse, GetStatsResponse, GetTransfersRequest, GetTransfersResponse } from "../hydrogen";
|
|
3
3
|
import { GetFeeQuoteRequest, GetFeeQuoteResponse } from "../hydrogen/feeQuote";
|
|
4
4
|
export declare const HydrogenEndpoints: {
|
|
5
5
|
stats: string;
|
|
@@ -15,7 +15,7 @@ declare class HydrogenClient {
|
|
|
15
15
|
getStats(): Promise<GetStatsResponse>;
|
|
16
16
|
getTransfers(req: GetTransfersRequest): Promise<GetTransfersResponse>;
|
|
17
17
|
getDetailedTransfers(req: GetTransfersRequest): Promise<GetDetailedTransfersResponse>;
|
|
18
|
-
getRelaysTransfers(req: GetRelaysRequest): Promise<
|
|
18
|
+
getRelaysTransfers(req: GetRelaysRequest): Promise<GetRelaysResponse>;
|
|
19
19
|
getFeeQuote(req: GetFeeQuoteRequest): Promise<GetFeeQuoteResponse>;
|
|
20
20
|
}
|
|
21
21
|
export default HydrogenClient;
|
|
@@ -42,6 +42,12 @@ const formatCrossChainTransferDetailed = (value) => {
|
|
|
42
42
|
return value;
|
|
43
43
|
return Object.assign(Object.assign({}, formatCrossChainTransfer(value)), { source_event: formatChainEvent(value.source_event), bridging_event: formatChainEvent(value.bridging_event), destination_event: formatChainEvent(value.destination_event) });
|
|
44
44
|
};
|
|
45
|
+
const formatRelaysTransfers = (value) => {
|
|
46
|
+
var _a, _b;
|
|
47
|
+
if (!value || typeof value !== "object")
|
|
48
|
+
return value;
|
|
49
|
+
return Object.assign(Object.assign({}, value), { created_at: formatDateField((_a = value.created_at) === null || _a === void 0 ? void 0 : _a.toString()), updated_at: formatDateField((_b = value.updated_at) === null || _b === void 0 ? void 0 : _b.toString()), source_blockchain: util_1.BlockchainUtils.parseBlockchain(value.source_blockchain), bridging_blockchain: util_1.BlockchainUtils.parseBlockchain(value.bridging_blockchain), destination_blockchain: util_1.BlockchainUtils.parseBlockchain(value.destination_blockchain) });
|
|
50
|
+
};
|
|
45
51
|
const formatChainEvent = (value) => {
|
|
46
52
|
var _a, _b, _c;
|
|
47
53
|
if (!value || typeof value !== "object")
|
|
@@ -100,7 +106,7 @@ class HydrogenClient {
|
|
|
100
106
|
const request = this.apiManager.path('relays', {}, Object.assign(Object.assign({}, req), { include_tx: true }));
|
|
101
107
|
const response = yield request.get();
|
|
102
108
|
const result = response.data;
|
|
103
|
-
return Object.assign(Object.assign({}, result), { data: result.data.map(
|
|
109
|
+
return Object.assign(Object.assign({}, result), { data: result.data.map(formatRelaysTransfers) });
|
|
104
110
|
});
|
|
105
111
|
}
|
|
106
112
|
getFeeQuote(req) {
|
package/lib/constant/network.js
CHANGED
|
@@ -50,6 +50,15 @@ exports.NetworkConfigs = {
|
|
|
50
50
|
balanceReader: "0x2b18c5e1edaa7e27d40fec8d0b7d96c5eefa35df",
|
|
51
51
|
byteCodeHash: "0x1b147c1cef546fcbcc1284df778073d65b90f80d5b649a69d5f8a01e186c0ec1",
|
|
52
52
|
},
|
|
53
|
+
arbitrum: {
|
|
54
|
+
rpcURL: "https://arb1.arbitrum.io/rpc",
|
|
55
|
+
wsURL: "",
|
|
56
|
+
payerURL: "https://payer.carbon.network",
|
|
57
|
+
bridgeEntranceAddr: "0x7b1c7216c117cc62d875e3086518b238392cf04d",
|
|
58
|
+
lockProxyAddr: "0xb1e6f8820826491fcc5519f84ff4e2bdbb6e3cad",
|
|
59
|
+
balanceReader: "0x7e8d8c98a016877cb3103e837fc71d41b155af70",
|
|
60
|
+
byteCodeHash: "", // TODO: update when byteCodeHash is added
|
|
61
|
+
},
|
|
53
62
|
neo: {
|
|
54
63
|
rpcURL: "https://mainnet2.neo2.coz.io:443",
|
|
55
64
|
wrapperScriptHash: "f46719e2d16bf50cddcef9d4bbfece901f73cbb6",
|
|
@@ -98,6 +107,15 @@ exports.NetworkConfigs = {
|
|
|
98
107
|
balanceReader: "0x25c22f65cb820e787a13951f295d0b86db7b07b5",
|
|
99
108
|
byteCodeHash: "0x1b147c1cef546fcbcc1284df778073d65b90f80d5b649a69d5f8a01e186c0ec1",
|
|
100
109
|
},
|
|
110
|
+
arbitrum: {
|
|
111
|
+
rpcURL: "https://rinkeby.arbitrum.io/rpc",
|
|
112
|
+
wsURL: "",
|
|
113
|
+
payerURL: "https://test-payer.carbon.network",
|
|
114
|
+
bridgeEntranceAddr: "",
|
|
115
|
+
lockProxyAddr: "",
|
|
116
|
+
balanceReader: "",
|
|
117
|
+
byteCodeHash: "",
|
|
118
|
+
},
|
|
101
119
|
neo: {
|
|
102
120
|
rpcURL: "https://g30trj885e.execute-api.ap-southeast-1.amazonaws.com",
|
|
103
121
|
wrapperScriptHash: "f46719e2d16bf50cddcef9d4bbfece901f73cbb6",
|
|
@@ -146,6 +164,15 @@ exports.NetworkConfigs = {
|
|
|
146
164
|
balanceReader: "0x25c22f65cb820e787a13951f295d0b86db7b07b5",
|
|
147
165
|
byteCodeHash: "0x1b147c1cef546fcbcc1284df778073d65b90f80d5b649a69d5f8a01e186c0ec1",
|
|
148
166
|
},
|
|
167
|
+
arbitrum: {
|
|
168
|
+
rpcURL: "https://rinkeby.arbitrum.io/rpc",
|
|
169
|
+
wsURL: "",
|
|
170
|
+
payerURL: "https://test-payer.carbon.network",
|
|
171
|
+
bridgeEntranceAddr: "",
|
|
172
|
+
lockProxyAddr: "",
|
|
173
|
+
balanceReader: "",
|
|
174
|
+
byteCodeHash: "",
|
|
175
|
+
},
|
|
149
176
|
neo: {
|
|
150
177
|
rpcURL: "https://g30trj885e.execute-api.ap-southeast-1.amazonaws.com",
|
|
151
178
|
wrapperScriptHash: "f46719e2d16bf50cddcef9d4bbfece901f73cbb6",
|
|
@@ -194,6 +221,15 @@ exports.NetworkConfigs = {
|
|
|
194
221
|
balanceReader: "",
|
|
195
222
|
byteCodeHash: "",
|
|
196
223
|
},
|
|
224
|
+
arbitrum: {
|
|
225
|
+
rpcURL: "https://rinkeby.arbitrum.io/rpc",
|
|
226
|
+
wsURL: "",
|
|
227
|
+
payerURL: "https://test-payer.carbon.network",
|
|
228
|
+
bridgeEntranceAddr: "",
|
|
229
|
+
lockProxyAddr: "",
|
|
230
|
+
balanceReader: "",
|
|
231
|
+
byteCodeHash: "",
|
|
232
|
+
},
|
|
197
233
|
neo: {
|
|
198
234
|
rpcURL: "https://g30trj885e.execute-api.ap-southeast-1.amazonaws.com",
|
|
199
235
|
wrapperScriptHash: "f46719e2d16bf50cddcef9d4bbfece901f73cbb6",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Network } from '../../constant';
|
|
2
2
|
import { Blockchain } from '../../util/blockchain';
|
|
3
3
|
import { ethers } from 'ethers';
|
|
4
|
-
export declare type EVMChain = Blockchain.Ethereum | Blockchain.BinanceSmartChain;
|
|
4
|
+
export declare type EVMChain = Blockchain.Ethereum | Blockchain.BinanceSmartChain | Blockchain.Arbitrum;
|
|
5
5
|
interface RequestArguments {
|
|
6
6
|
method: string;
|
|
7
7
|
params?: unknown[] | object;
|
|
@@ -38,7 +38,7 @@ export declare class MetaMask {
|
|
|
38
38
|
readonly network: Network;
|
|
39
39
|
private blockchain;
|
|
40
40
|
static getNetworkParams(network: Network, blockchain?: EVMChain): MetaMaskChangeNetworkParam;
|
|
41
|
-
static getRequiredChainId(network: Network, blockchain?: Blockchain): 1 | 4 | 56 | 97;
|
|
41
|
+
static getRequiredChainId(network: Network, blockchain?: Blockchain): 1 | 4 | 56 | 97 | 42161 | 421611;
|
|
42
42
|
constructor(network: Network);
|
|
43
43
|
private checkProvider;
|
|
44
44
|
getBlockchain(): Blockchain;
|
|
@@ -49,6 +49,13 @@ const CONTRACT_HASH = {
|
|
|
49
49
|
[constant_1.Network.LocalHost]: '0x06E949ec2d6737ff57859CdcE426C5b5CA2Fc085',
|
|
50
50
|
[constant_1.Network.MainNet]: '0x3786d94AC6B15FE2eaC72c3CA78cB82578Fc66f4',
|
|
51
51
|
},
|
|
52
|
+
[blockchain_1.Blockchain.Arbitrum]: {
|
|
53
|
+
// use same testnet contract for all non-mainnet uses
|
|
54
|
+
[constant_1.Network.TestNet]: '',
|
|
55
|
+
[constant_1.Network.DevNet]: '',
|
|
56
|
+
[constant_1.Network.LocalHost]: '',
|
|
57
|
+
[constant_1.Network.MainNet]: '0x43138036d1283413035b8eca403559737e8f7980',
|
|
58
|
+
},
|
|
52
59
|
};
|
|
53
60
|
const REGISTRY_CONTRACT_ABI = eth_1.ABIs.keyStorage;
|
|
54
61
|
const ENCRYPTION_VERSION = 'x25519-xsalsa20-poly1305';
|
|
@@ -112,6 +119,28 @@ const ETH_TESTNET = {
|
|
|
112
119
|
chainId: '0x4',
|
|
113
120
|
rpcUrls: ['https://rinkeby.infura.io/v3/'],
|
|
114
121
|
};
|
|
122
|
+
const ARBITRUM_MAINNET = {
|
|
123
|
+
chainId: '0xA4B1',
|
|
124
|
+
blockExplorerUrls: ['https://explorer.arbitrum.io'],
|
|
125
|
+
chainName: 'Arbitrum One',
|
|
126
|
+
rpcUrls: ['https://arb1.arbitrum.io/rpc'],
|
|
127
|
+
nativeCurrency: {
|
|
128
|
+
decimals: 18,
|
|
129
|
+
name: 'Ethereum',
|
|
130
|
+
symbol: 'ETH',
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
const ARBITRUM_TESTNET = {
|
|
134
|
+
chainId: '0x66EEB',
|
|
135
|
+
blockExplorerUrls: [''],
|
|
136
|
+
chainName: 'Arbitrum Testnet',
|
|
137
|
+
rpcUrls: ['https://rinkeby.arbitrum.io/rpc'],
|
|
138
|
+
nativeCurrency: {
|
|
139
|
+
decimals: 18,
|
|
140
|
+
name: 'Ethereum',
|
|
141
|
+
symbol: 'ETH',
|
|
142
|
+
},
|
|
143
|
+
};
|
|
115
144
|
/**
|
|
116
145
|
* TODO: Add docs
|
|
117
146
|
*/
|
|
@@ -125,6 +154,8 @@ class MetaMask {
|
|
|
125
154
|
switch (blockchain) {
|
|
126
155
|
case blockchain_1.Blockchain.BinanceSmartChain:
|
|
127
156
|
return BSC_MAINNET;
|
|
157
|
+
case blockchain_1.Blockchain.Arbitrum:
|
|
158
|
+
return ARBITRUM_MAINNET;
|
|
128
159
|
default:
|
|
129
160
|
// metamask should come with Ethereum configs
|
|
130
161
|
return ETH_MAINNET;
|
|
@@ -133,6 +164,8 @@ class MetaMask {
|
|
|
133
164
|
switch (blockchain) {
|
|
134
165
|
case blockchain_1.Blockchain.BinanceSmartChain:
|
|
135
166
|
return BSC_TESTNET;
|
|
167
|
+
case blockchain_1.Blockchain.Arbitrum:
|
|
168
|
+
return ARBITRUM_TESTNET;
|
|
136
169
|
default:
|
|
137
170
|
// metamask should come with Ethereum configs
|
|
138
171
|
return ETH_TESTNET;
|
|
@@ -142,11 +175,13 @@ class MetaMask {
|
|
|
142
175
|
if (network === constant_1.Network.MainNet) {
|
|
143
176
|
switch (blockchain) {
|
|
144
177
|
case blockchain_1.Blockchain.BinanceSmartChain: return 56;
|
|
178
|
+
case blockchain_1.Blockchain.Arbitrum: return 42161;
|
|
145
179
|
default: return 1;
|
|
146
180
|
}
|
|
147
181
|
}
|
|
148
182
|
switch (blockchain) {
|
|
149
183
|
case blockchain_1.Blockchain.BinanceSmartChain: return 97;
|
|
184
|
+
case blockchain_1.Blockchain.Arbitrum: return 421611;
|
|
150
185
|
default: return 4;
|
|
151
186
|
}
|
|
152
187
|
}
|
|
@@ -319,6 +354,10 @@ class MetaMask {
|
|
|
319
354
|
this.blockchain = blockchain_1.Blockchain.BinanceSmartChain;
|
|
320
355
|
return currentChainId;
|
|
321
356
|
}
|
|
357
|
+
if (currentChainId === 42161) {
|
|
358
|
+
this.blockchain = blockchain_1.Blockchain.Arbitrum;
|
|
359
|
+
return currentChainId;
|
|
360
|
+
}
|
|
322
361
|
return 1;
|
|
323
362
|
}
|
|
324
363
|
if (currentChainId === 4) {
|
|
@@ -329,6 +368,10 @@ class MetaMask {
|
|
|
329
368
|
this.blockchain = blockchain_1.Blockchain.BinanceSmartChain;
|
|
330
369
|
return currentChainId;
|
|
331
370
|
}
|
|
371
|
+
if (currentChainId === 421611) {
|
|
372
|
+
this.blockchain = blockchain_1.Blockchain.Arbitrum;
|
|
373
|
+
return currentChainId;
|
|
374
|
+
}
|
|
332
375
|
// Deal with cases where users are logging in to devnet using mainnet chains
|
|
333
376
|
if (currentChainId === 56) {
|
|
334
377
|
return 97;
|
package/lib/util/blockchain.d.ts
CHANGED
package/lib/util/blockchain.js
CHANGED
|
@@ -28,7 +28,7 @@ var Blockchain;
|
|
|
28
28
|
Blockchain["Terra2"] = "terra2";
|
|
29
29
|
Blockchain["Quicksilver"] = "quicksilver";
|
|
30
30
|
Blockchain["Comdex"] = "comdex";
|
|
31
|
-
Blockchain["StafiHub"] = "
|
|
31
|
+
Blockchain["StafiHub"] = "stafi";
|
|
32
32
|
Blockchain["Persistence"] = "persistence";
|
|
33
33
|
Blockchain["Stargaze"] = "stargaze";
|
|
34
34
|
})(Blockchain = exports.Blockchain || (exports.Blockchain = {}));
|
|
@@ -176,6 +176,8 @@ const blockchainForChainId = (chainId) => {
|
|
|
176
176
|
return Blockchain.Persistence;
|
|
177
177
|
case 320: // mainnnet
|
|
178
178
|
return Blockchain.Stargaze;
|
|
179
|
+
case 42161: // mainnnet
|
|
180
|
+
return Blockchain.Arbitrum;
|
|
179
181
|
default:
|
|
180
182
|
return undefined;
|
|
181
183
|
}
|