carbon-js-sdk 0.3.27-beta.1 → 0.3.27
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 +0 -1
- package/lib/CarbonSDK.js +0 -10
- package/lib/clients/ETHClient.d.ts +0 -1
- package/lib/clients/ETHClient.js +1 -2
- package/lib/clients/HydrogenClient.d.ts +2 -2
- package/lib/clients/HydrogenClient.js +1 -7
- package/lib/constant/network.d.ts +0 -1
- package/lib/constant/network.js +0 -36
- package/lib/provider/metamask/MetaMask.d.ts +2 -2
- package/lib/provider/metamask/MetaMask.js +0 -43
- package/lib/util/blockchain.js +0 -2
- package/package.json +1 -1
package/lib/CarbonSDK.d.ts
CHANGED
package/lib/CarbonSDK.js
CHANGED
|
@@ -106,20 +106,10 @@ 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
|
-
});
|
|
114
109
|
this.zil = clients_1.ZILClient.instance({
|
|
115
110
|
configProvider: this,
|
|
116
111
|
blockchain: blockchain_1.Blockchain.Zilliqa,
|
|
117
112
|
});
|
|
118
|
-
this.arbitrum = clients_1.ETHClient.instance({
|
|
119
|
-
configProvider: this,
|
|
120
|
-
blockchain: blockchain_1.Blockchain.Arbitrum,
|
|
121
|
-
tokenClient: this.token,
|
|
122
|
-
});
|
|
123
113
|
}
|
|
124
114
|
static instance(opts = DEFAULT_SDK_INIT_OPTS) {
|
|
125
115
|
var _a, _b, _c, _d;
|
package/lib/clients/ETHClient.js
CHANGED
|
@@ -349,10 +349,9 @@ 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];
|
|
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",
|
|
357
356
|
};
|
|
358
357
|
exports.default = ETHClient;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NetworkConfig } from "../constant";
|
|
2
|
-
import { GetDetailedTransfersResponse, GetRelaysRequest,
|
|
2
|
+
import { GetDetailedTransfersResponse, GetRelaysRequest, 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<GetDetailedTransfersResponse>;
|
|
19
19
|
getFeeQuote(req: GetFeeQuoteRequest): Promise<GetFeeQuoteResponse>;
|
|
20
20
|
}
|
|
21
21
|
export default HydrogenClient;
|
|
@@ -42,12 +42,6 @@ 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
|
-
};
|
|
51
45
|
const formatChainEvent = (value) => {
|
|
52
46
|
var _a, _b, _c;
|
|
53
47
|
if (!value || typeof value !== "object")
|
|
@@ -106,7 +100,7 @@ class HydrogenClient {
|
|
|
106
100
|
const request = this.apiManager.path('relays', {}, Object.assign(Object.assign({}, req), { include_tx: true }));
|
|
107
101
|
const response = yield request.get();
|
|
108
102
|
const result = response.data;
|
|
109
|
-
return Object.assign(Object.assign({}, result), { data: result.data.map(
|
|
103
|
+
return Object.assign(Object.assign({}, result), { data: result.data.map(formatCrossChainTransferDetailed) });
|
|
110
104
|
});
|
|
111
105
|
}
|
|
112
106
|
getFeeQuote(req) {
|
package/lib/constant/network.js
CHANGED
|
@@ -50,15 +50,6 @@ 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
|
-
},
|
|
62
53
|
neo: {
|
|
63
54
|
rpcURL: "https://mainnet2.neo2.coz.io:443",
|
|
64
55
|
wrapperScriptHash: "f46719e2d16bf50cddcef9d4bbfece901f73cbb6",
|
|
@@ -107,15 +98,6 @@ exports.NetworkConfigs = {
|
|
|
107
98
|
balanceReader: "0x25c22f65cb820e787a13951f295d0b86db7b07b5",
|
|
108
99
|
byteCodeHash: "0x1b147c1cef546fcbcc1284df778073d65b90f80d5b649a69d5f8a01e186c0ec1",
|
|
109
100
|
},
|
|
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
|
-
},
|
|
119
101
|
neo: {
|
|
120
102
|
rpcURL: "https://g30trj885e.execute-api.ap-southeast-1.amazonaws.com",
|
|
121
103
|
wrapperScriptHash: "f46719e2d16bf50cddcef9d4bbfece901f73cbb6",
|
|
@@ -164,15 +146,6 @@ exports.NetworkConfigs = {
|
|
|
164
146
|
balanceReader: "0x25c22f65cb820e787a13951f295d0b86db7b07b5",
|
|
165
147
|
byteCodeHash: "0x1b147c1cef546fcbcc1284df778073d65b90f80d5b649a69d5f8a01e186c0ec1",
|
|
166
148
|
},
|
|
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
|
-
},
|
|
176
149
|
neo: {
|
|
177
150
|
rpcURL: "https://g30trj885e.execute-api.ap-southeast-1.amazonaws.com",
|
|
178
151
|
wrapperScriptHash: "f46719e2d16bf50cddcef9d4bbfece901f73cbb6",
|
|
@@ -221,15 +194,6 @@ exports.NetworkConfigs = {
|
|
|
221
194
|
balanceReader: "",
|
|
222
195
|
byteCodeHash: "",
|
|
223
196
|
},
|
|
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
|
-
},
|
|
233
197
|
neo: {
|
|
234
198
|
rpcURL: "https://g30trj885e.execute-api.ap-southeast-1.amazonaws.com",
|
|
235
199
|
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;
|
|
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;
|
|
42
42
|
constructor(network: Network);
|
|
43
43
|
private checkProvider;
|
|
44
44
|
getBlockchain(): Blockchain;
|
|
@@ -49,13 +49,6 @@ 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
|
-
},
|
|
59
52
|
};
|
|
60
53
|
const REGISTRY_CONTRACT_ABI = eth_1.ABIs.keyStorage;
|
|
61
54
|
const ENCRYPTION_VERSION = 'x25519-xsalsa20-poly1305';
|
|
@@ -119,28 +112,6 @@ const ETH_TESTNET = {
|
|
|
119
112
|
chainId: '0x4',
|
|
120
113
|
rpcUrls: ['https://rinkeby.infura.io/v3/'],
|
|
121
114
|
};
|
|
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
|
-
};
|
|
144
115
|
/**
|
|
145
116
|
* TODO: Add docs
|
|
146
117
|
*/
|
|
@@ -154,8 +125,6 @@ class MetaMask {
|
|
|
154
125
|
switch (blockchain) {
|
|
155
126
|
case blockchain_1.Blockchain.BinanceSmartChain:
|
|
156
127
|
return BSC_MAINNET;
|
|
157
|
-
case blockchain_1.Blockchain.Arbitrum:
|
|
158
|
-
return ARBITRUM_MAINNET;
|
|
159
128
|
default:
|
|
160
129
|
// metamask should come with Ethereum configs
|
|
161
130
|
return ETH_MAINNET;
|
|
@@ -164,8 +133,6 @@ class MetaMask {
|
|
|
164
133
|
switch (blockchain) {
|
|
165
134
|
case blockchain_1.Blockchain.BinanceSmartChain:
|
|
166
135
|
return BSC_TESTNET;
|
|
167
|
-
case blockchain_1.Blockchain.Arbitrum:
|
|
168
|
-
return ARBITRUM_TESTNET;
|
|
169
136
|
default:
|
|
170
137
|
// metamask should come with Ethereum configs
|
|
171
138
|
return ETH_TESTNET;
|
|
@@ -175,13 +142,11 @@ class MetaMask {
|
|
|
175
142
|
if (network === constant_1.Network.MainNet) {
|
|
176
143
|
switch (blockchain) {
|
|
177
144
|
case blockchain_1.Blockchain.BinanceSmartChain: return 56;
|
|
178
|
-
case blockchain_1.Blockchain.Arbitrum: return 42161;
|
|
179
145
|
default: return 1;
|
|
180
146
|
}
|
|
181
147
|
}
|
|
182
148
|
switch (blockchain) {
|
|
183
149
|
case blockchain_1.Blockchain.BinanceSmartChain: return 97;
|
|
184
|
-
case blockchain_1.Blockchain.Arbitrum: return 421611;
|
|
185
150
|
default: return 4;
|
|
186
151
|
}
|
|
187
152
|
}
|
|
@@ -354,10 +319,6 @@ class MetaMask {
|
|
|
354
319
|
this.blockchain = blockchain_1.Blockchain.BinanceSmartChain;
|
|
355
320
|
return currentChainId;
|
|
356
321
|
}
|
|
357
|
-
if (currentChainId === 42161) {
|
|
358
|
-
this.blockchain = blockchain_1.Blockchain.Arbitrum;
|
|
359
|
-
return currentChainId;
|
|
360
|
-
}
|
|
361
322
|
return 1;
|
|
362
323
|
}
|
|
363
324
|
if (currentChainId === 4) {
|
|
@@ -368,10 +329,6 @@ class MetaMask {
|
|
|
368
329
|
this.blockchain = blockchain_1.Blockchain.BinanceSmartChain;
|
|
369
330
|
return currentChainId;
|
|
370
331
|
}
|
|
371
|
-
if (currentChainId === 421611) {
|
|
372
|
-
this.blockchain = blockchain_1.Blockchain.Arbitrum;
|
|
373
|
-
return currentChainId;
|
|
374
|
-
}
|
|
375
332
|
// Deal with cases where users are logging in to devnet using mainnet chains
|
|
376
333
|
if (currentChainId === 56) {
|
|
377
334
|
return 97;
|
package/lib/util/blockchain.js
CHANGED