carbon-js-sdk 0.3.35-beta.1 → 0.3.36
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/clients/ETHClient.js
CHANGED
|
@@ -13,6 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.ETHClient = exports.FEE_MULTIPLIER = void 0;
|
|
16
|
+
const CarbonSDK_1 = __importDefault(require("../CarbonSDK"));
|
|
16
17
|
const constant_1 = require("../constant");
|
|
17
18
|
const eth_1 = require("../eth");
|
|
18
19
|
const util_1 = require("../util");
|
|
@@ -90,22 +91,20 @@ class ETHClient {
|
|
|
90
91
|
const { fromToken, toToken, amount, toAddress, fromAddress, recoveryAddress, signer, gasPriceGwei, gasLimit, feeAmount, signCompleteCallback, } = params;
|
|
91
92
|
const networkConfig = this.getNetworkConfig();
|
|
92
93
|
const rpcProvider = this.getProvider();
|
|
93
|
-
|
|
94
|
-
if (!recoveryAddress.match(recoveryAddrRegex)) {
|
|
94
|
+
if (!recoveryAddress.match(/^swth[a-z0-9]{39}$/)) {
|
|
95
95
|
throw new Error("Invalid recovery address");
|
|
96
96
|
}
|
|
97
|
-
const carbonNetwork = networkConfig.network;
|
|
98
97
|
const fromTokenId = fromToken.id;
|
|
99
98
|
const fromTokenAddress = (0, generic_1.appendHexPrefix)(fromToken.tokenAddress);
|
|
100
99
|
const toTokenDenom = toToken.denom;
|
|
101
|
-
const recoveryAddressHex = ethers_1.ethers.utils.hexlify(util_1.AddressUtils.SWTHAddress.getAddressBytes(recoveryAddress,
|
|
100
|
+
const recoveryAddressHex = ethers_1.ethers.utils.hexlify(util_1.AddressUtils.SWTHAddress.getAddressBytes(recoveryAddress, CarbonSDK_1.default.Network.MainNet));
|
|
102
101
|
const fromAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(fromTokenId));
|
|
103
102
|
const toAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(toTokenDenom));
|
|
104
103
|
const nonce = yield rpcProvider.getTransactionCount(fromAddress);
|
|
105
104
|
const contract = new ethers_1.ethers.Contract(this.getBridgeEntranceAddr(), eth_1.ABIs.bridgeEntrance, rpcProvider);
|
|
106
105
|
const feeAddress = (0, generic_1.appendHexPrefix)(networkConfig.feeAddress);
|
|
107
106
|
const tokenCreator = fromToken.creator;
|
|
108
|
-
const targetAddressBytes = util_1.AddressUtils.SWTHAddress.getAddressBytes(tokenCreator,
|
|
107
|
+
const targetAddressBytes = util_1.AddressUtils.SWTHAddress.getAddressBytes(tokenCreator, CarbonSDK_1.default.Network.MainNet);
|
|
109
108
|
const targetProxyHash = ethers_1.ethers.utils.hexlify(targetAddressBytes);
|
|
110
109
|
const ethAmount = fromToken.tokenAddress === constant_1.NativeTokenHash ? amount : number_1.BN_ZERO;
|
|
111
110
|
const bridgeResultTx = yield contract.connect(signer).lock(fromTokenAddress, // the asset to deposit (from) (0x00 if eth)
|
package/lib/clients/ZILClient.js
CHANGED
|
@@ -13,6 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.ZILClient = exports.balanceBatchRequest = exports.tokenBalanceBatchRequest = exports.BatchRequestType = void 0;
|
|
16
|
+
const CarbonSDK_1 = __importDefault(require("../CarbonSDK"));
|
|
16
17
|
const index_1 = require("../index");
|
|
17
18
|
const address_1 = require("../util/address");
|
|
18
19
|
const blockchain_1 = require("../util/blockchain");
|
|
@@ -200,16 +201,14 @@ class ZILClient {
|
|
|
200
201
|
return __awaiter(this, void 0, void 0, function* () {
|
|
201
202
|
const { fromToken, toToken, amount, fromAddress, recoveryAddress, toAddress, signer, gasPrice, gasLimit, feeAmount, signCompleteCallback, } = params;
|
|
202
203
|
const networkConfig = this.getNetworkConfig();
|
|
203
|
-
|
|
204
|
-
if (!recoveryAddress.match(recoveryAddrRegex)) {
|
|
204
|
+
if (!recoveryAddress.match(/^swth[a-z0-9]{39}$/)) {
|
|
205
205
|
throw new Error("Invalid recovery address");
|
|
206
206
|
}
|
|
207
|
-
const carbonNetwork = networkConfig.network;
|
|
208
207
|
const fromTokenId = fromToken.id;
|
|
209
208
|
const fromTokenAddr = (0, generic_1.appendHexPrefix)(fromToken.tokenAddress);
|
|
210
209
|
const toTokenDenom = toToken.denom;
|
|
211
210
|
const targetProxyHash = (0, generic_1.appendHexPrefix)(this.getTargetProxyHash(fromToken));
|
|
212
|
-
const recoveryAddressHex = ethers_1.ethers.utils.hexlify(index_1.AddressUtils.SWTHAddress.getAddressBytes(recoveryAddress,
|
|
211
|
+
const recoveryAddressHex = ethers_1.ethers.utils.hexlify(index_1.AddressUtils.SWTHAddress.getAddressBytes(recoveryAddress, CarbonSDK_1.default.Network.MainNet));
|
|
213
212
|
const fromAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(fromTokenId));
|
|
214
213
|
const toAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(toTokenDenom));
|
|
215
214
|
const feeAddress = (0, generic_1.appendHexPrefix)(networkConfig.feeAddress);
|
package/lib/constant/ibc.js
CHANGED
package/lib/constant/network.js
CHANGED
|
@@ -125,7 +125,7 @@ exports.NetworkConfigs = {
|
|
|
125
125
|
networkMagic: neon_core_next_1.CONST.MAGIC_NUMBER.TestNet,
|
|
126
126
|
},
|
|
127
127
|
zil: {
|
|
128
|
-
rpcURL: "
|
|
128
|
+
rpcURL: "",
|
|
129
129
|
lockProxyAddr: "0xe7bef341044f1b8d5ab1a25172e2678a1e75479a",
|
|
130
130
|
bridgeEntranceAddr: "0xccf798e633d6fb6505b494fc010903f9be3bc99b",
|
|
131
131
|
chainId: 111,
|
package/lib/util/blockchain.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Network } from "../constant/network";
|
|
2
1
|
import { SimpleMap } from "./type";
|
|
3
2
|
export declare enum Blockchain {
|
|
4
3
|
Neo = "neo",
|
|
@@ -55,4 +54,4 @@ export declare const chainIdsByBlockchain: SimpleMap<ChainIds>;
|
|
|
55
54
|
export declare function parseBlockchain(value: string | null): Blockchain | null;
|
|
56
55
|
export declare function getChainFromID(id: number): string | undefined;
|
|
57
56
|
export declare const getBlockchainFromChain: (chainId?: number | undefined) => Blockchain.Ethereum | Blockchain.BinanceSmartChain | Blockchain.Zilliqa | Blockchain.Arbitrum | undefined;
|
|
58
|
-
export declare const blockchainForChainId: (chainId?: number | undefined
|
|
57
|
+
export declare const blockchainForChainId: (chainId?: number | undefined) => Blockchain | undefined;
|
package/lib/util/blockchain.js
CHANGED
|
@@ -127,101 +127,68 @@ const getBlockchainFromChain = (chainId) => {
|
|
|
127
127
|
return undefined;
|
|
128
128
|
};
|
|
129
129
|
exports.getBlockchainFromChain = getBlockchainFromChain;
|
|
130
|
-
const blockchainForChainId = (chainId
|
|
131
|
-
switch (
|
|
132
|
-
case
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
return Blockchain.Arbitrum;
|
|
193
|
-
default:
|
|
194
|
-
return undefined;
|
|
195
|
-
}
|
|
196
|
-
case network_1.Network.TestNet:
|
|
197
|
-
switch (chainId) {
|
|
198
|
-
case 1:
|
|
199
|
-
return Blockchain.Btc;
|
|
200
|
-
case 5:
|
|
201
|
-
return Blockchain.Carbon;
|
|
202
|
-
case 79:
|
|
203
|
-
return Blockchain.BinanceSmartChain;
|
|
204
|
-
case 88:
|
|
205
|
-
return Blockchain.Neo3;
|
|
206
|
-
case 111:
|
|
207
|
-
return Blockchain.Zilliqa;
|
|
208
|
-
case 2: /* FALLTHROUGH */
|
|
209
|
-
case 502:
|
|
210
|
-
return Blockchain.Ethereum;
|
|
211
|
-
default:
|
|
212
|
-
return undefined;
|
|
213
|
-
}
|
|
214
|
-
case network_1.Network.DevNet:
|
|
215
|
-
switch (chainId) {
|
|
216
|
-
case 350:
|
|
217
|
-
return Blockchain.Ethereum;
|
|
218
|
-
case 5:
|
|
219
|
-
return Blockchain.Neo;
|
|
220
|
-
case 79:
|
|
221
|
-
return Blockchain.BinanceSmartChain;
|
|
222
|
-
}
|
|
223
|
-
case network_1.Network.LocalHost:
|
|
224
|
-
return undefined;
|
|
130
|
+
const blockchainForChainId = (chainId) => {
|
|
131
|
+
switch (chainId) {
|
|
132
|
+
case 0:
|
|
133
|
+
return Blockchain.Native;
|
|
134
|
+
case 1:
|
|
135
|
+
return Blockchain.Btc;
|
|
136
|
+
case 2:
|
|
137
|
+
case 350: // devnet
|
|
138
|
+
return Blockchain.Ethereum;
|
|
139
|
+
case 4:
|
|
140
|
+
case 5: // devnet
|
|
141
|
+
return Blockchain.Neo;
|
|
142
|
+
case 6:
|
|
143
|
+
case 79: // devnet
|
|
144
|
+
return Blockchain.BinanceSmartChain;
|
|
145
|
+
case 9: // mainnet
|
|
146
|
+
case 10:
|
|
147
|
+
case 18:
|
|
148
|
+
case 110: // testnet
|
|
149
|
+
case 111:
|
|
150
|
+
return Blockchain.Zilliqa;
|
|
151
|
+
case 14: // mainnet
|
|
152
|
+
case 88: // testnet
|
|
153
|
+
return Blockchain.Neo3;
|
|
154
|
+
case 19: // mainnet
|
|
155
|
+
return Blockchain.Arbitrum;
|
|
156
|
+
case 244: // mainnet
|
|
157
|
+
return Blockchain.Osmosis;
|
|
158
|
+
case 245: // mainnet
|
|
159
|
+
return Blockchain.Terra;
|
|
160
|
+
case 246: // mainnet
|
|
161
|
+
return Blockchain.CosmosHub;
|
|
162
|
+
case 247: // mainnet
|
|
163
|
+
return Blockchain.Juno;
|
|
164
|
+
case 248: // mainnet
|
|
165
|
+
return Blockchain.Evmos;
|
|
166
|
+
case 249: // mainnet
|
|
167
|
+
return Blockchain.Axelar;
|
|
168
|
+
case 313: // mainnet
|
|
169
|
+
return Blockchain.Stride;
|
|
170
|
+
case 314: // mainnnet
|
|
171
|
+
return Blockchain.Kujira;
|
|
172
|
+
case 315: // mainnnet
|
|
173
|
+
return Blockchain.Terra2;
|
|
174
|
+
case 316: // mainnnet
|
|
175
|
+
return Blockchain.Quicksilver;
|
|
176
|
+
case 317: // mainnnet
|
|
177
|
+
return Blockchain.Comdex;
|
|
178
|
+
case 318: // mainnnet
|
|
179
|
+
return Blockchain.StafiHub;
|
|
180
|
+
case 319: // mainnnet
|
|
181
|
+
return Blockchain.Persistence;
|
|
182
|
+
case 320: // mainnnet
|
|
183
|
+
return Blockchain.Stargaze;
|
|
184
|
+
case 321: // mainnnet
|
|
185
|
+
return Blockchain.Canto;
|
|
186
|
+
case 322: // mainnnet
|
|
187
|
+
return Blockchain.OmniFlixHub;
|
|
188
|
+
case 323: // mainnnet
|
|
189
|
+
return Blockchain.Agoric;
|
|
190
|
+
case 42161: // mainnnet
|
|
191
|
+
return Blockchain.Arbitrum;
|
|
225
192
|
default:
|
|
226
193
|
return undefined;
|
|
227
194
|
}
|