carbon-js-sdk 0.3.42 → 0.3.43-beta.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/lib/CarbonSDK.js +2 -2
- package/lib/clients/CarbonQueryClient.js +2 -2
- package/lib/clients/ETHClient.js +15 -15
- package/lib/clients/HydrogenClient.js +1 -1
- package/lib/clients/NEOClient.js +7 -7
- package/lib/clients/TokenClient.js +1 -1
- package/lib/clients/ZILClient.js +17 -17
- package/lib/codec/cosmos/gov/v1beta1/query.js +2 -2
- package/lib/codec/cosmos/gov/v1beta1/tx.js +2 -2
- package/lib/codec/cosmos/tx/v1beta1/tx.js +2 -2
- package/lib/codec/liquiditypool/legacy.d.ts +18 -0
- package/lib/codec/liquiditypool/legacy.js +64 -0
- package/lib/constant/generic.js +1 -1
- package/lib/modules/cdp.js +43 -43
- package/lib/modules/gov.js +14 -14
- package/lib/modules/liquiditypool.js +1 -1
- package/lib/provider/account/EthLedgerAccount/EthLedgerAccount.js +1 -1
- package/lib/provider/account/NeoLedgerAccount/N3Ledger/ErrorCode.js +1 -1
- package/lib/provider/account/NeoLedgerAccount/N3Ledger/main.js +8 -8
- package/lib/provider/account/NeoLedgerAccount/NeoLedgerAccount.js +3 -3
- package/lib/provider/account/NeoLedgerAccount/NeonLedger.js +1 -1
- package/lib/provider/amino/types/admin.js +30 -30
- package/lib/provider/amino/types/bank.js +1 -1
- package/lib/provider/amino/types/broker.js +1 -1
- package/lib/provider/amino/types/cdp.js +22 -22
- package/lib/provider/amino/types/coin.js +4 -4
- package/lib/provider/amino/types/gov.js +4 -4
- package/lib/provider/amino/types/ibc.js +1 -1
- package/lib/provider/amino/types/leverage.js +1 -1
- package/lib/provider/amino/types/liquidityPool.js +7 -7
- package/lib/provider/amino/types/market.js +1 -1
- package/lib/provider/amino/types/oracle.js +1 -1
- package/lib/provider/amino/types/order.js +4 -4
- package/lib/provider/amino/types/position.js +1 -1
- package/lib/provider/amino/types/profile.js +1 -1
- package/lib/provider/amino/types/staking.js +4 -4
- package/lib/provider/amino/types/subaccount.js +3 -3
- package/lib/provider/amino/utils.js +11 -11
- package/lib/provider/keplr/KeplrAccount.d.ts +2 -0
- package/lib/provider/keplr/KeplrAccount.js +37 -8
- package/lib/provider/ledger/ledger.js +2 -2
- package/lib/provider/metamask/MetaMask.js +1 -1
- package/lib/provider/o3/O3Wallet.js +2 -2
- package/lib/util/address.js +13 -13
- package/lib/util/api.js +4 -4
- package/lib/util/blockchain.js +10 -0
- package/lib/util/fetch.js +1 -1
- package/lib/util/generic.js +3 -3
- package/lib/util/number.js +5 -5
- package/lib/wallet/CarbonSigner.js +2 -2
- package/lib/wallet/CarbonSigningClient.js +8 -8
- package/lib/wallet/CarbonWallet.js +8 -8
- package/lib/websocket/connector.js +3 -3
- package/package.json +1 -1
package/lib/CarbonSDK.js
CHANGED
|
@@ -258,8 +258,8 @@ class CarbonSDK {
|
|
|
258
258
|
return __awaiter(this, void 0, void 0, function* () {
|
|
259
259
|
const chainInfo = yield provider_1.KeplrAccount.getChainInfo(this);
|
|
260
260
|
const chainId = chainInfo.chainId;
|
|
261
|
-
const keplrKey = yield keplr.getKey(chainId);
|
|
262
261
|
yield keplr.experimentalSuggestChain(chainInfo);
|
|
262
|
+
const keplrKey = yield keplr.getKey(chainId);
|
|
263
263
|
yield keplr.enable(chainId);
|
|
264
264
|
const wallet = wallet_1.CarbonWallet.withKeplr(keplr, chainInfo, keplrKey, Object.assign(Object.assign({}, opts), { network: this.network, config: this.configOverride }));
|
|
265
265
|
return this.connect(wallet);
|
|
@@ -269,8 +269,8 @@ class CarbonSDK {
|
|
|
269
269
|
return __awaiter(this, void 0, void 0, function* () {
|
|
270
270
|
const chainId = this.chainId;
|
|
271
271
|
const chainInfo = yield provider_1.LeapAccount.getChainInfo(this);
|
|
272
|
-
const leapKey = yield leap.getKey(chainId);
|
|
273
272
|
yield leap.experimentalSuggestChain(chainInfo);
|
|
273
|
+
const leapKey = yield leap.getKey(chainId);
|
|
274
274
|
yield leap.enable(chainId);
|
|
275
275
|
const wallet = wallet_1.CarbonWallet.withLeap(leap, chainId, leapKey, Object.assign(Object.assign({}, opts), { network: this.network, config: this.configOverride }));
|
|
276
276
|
return this.connect(wallet);
|
|
@@ -44,7 +44,7 @@ class CarbonQueryClient {
|
|
|
44
44
|
constructor(tmClient) {
|
|
45
45
|
this.tmClient = tmClient;
|
|
46
46
|
this.baseClient = new stargate_1.QueryClient(this.tmClient);
|
|
47
|
-
const rpcClient = stargate_1.createProtobufRpcClient(this.baseClient);
|
|
47
|
+
const rpcClient = (0, stargate_1.createProtobufRpcClient)(this.baseClient);
|
|
48
48
|
this.chain = BlockchainClient_1.default.connectWithTm(this.tmClient);
|
|
49
49
|
this.adl = new query_1.QueryClientImpl(rpcClient);
|
|
50
50
|
this.book = new query_2.QueryClientImpl(rpcClient);
|
|
@@ -85,7 +85,7 @@ class CarbonQueryClient {
|
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
87
|
getProtobufRpcClient() {
|
|
88
|
-
return stargate_1.createProtobufRpcClient(this.baseClient);
|
|
88
|
+
return (0, stargate_1.createProtobufRpcClient)(this.baseClient);
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
exports.default = CarbonQueryClient;
|
package/lib/clients/ETHClient.js
CHANGED
|
@@ -39,13 +39,13 @@ class ETHClient {
|
|
|
39
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40
40
|
const tokenQueryResults = yield api.token.getAllTokens();
|
|
41
41
|
const lockProxyAddress = this.getLockProxyAddress().toLowerCase();
|
|
42
|
-
const tokens = tokenQueryResults.filter((token) => blockchain_1.blockchainForChainId(token.chainId.toNumber()) == this.blockchain &&
|
|
42
|
+
const tokens = tokenQueryResults.filter((token) => (0, blockchain_1.blockchainForChainId)(token.chainId.toNumber(), api.network) == this.blockchain &&
|
|
43
43
|
token.tokenAddress.length == 40 &&
|
|
44
|
-
token.bridgeAddress.toLowerCase() == generic_1.stripHexPrefix(lockProxyAddress) &&
|
|
44
|
+
token.bridgeAddress.toLowerCase() == (0, generic_1.stripHexPrefix)(lockProxyAddress) &&
|
|
45
45
|
(!whitelistDenoms || whitelistDenoms.includes(token.denom)) &&
|
|
46
|
-
this.verifyChecksum(generic_1.appendHexPrefix(token.tokenAddress)));
|
|
46
|
+
this.verifyChecksum((0, generic_1.appendHexPrefix)(token.tokenAddress)));
|
|
47
47
|
const assetIds = tokens.map((token) => {
|
|
48
|
-
return this.verifyChecksum(generic_1.appendHexPrefix(token.tokenAddress));
|
|
48
|
+
return this.verifyChecksum((0, generic_1.appendHexPrefix)(token.tokenAddress));
|
|
49
49
|
});
|
|
50
50
|
const provider = this.getProvider();
|
|
51
51
|
const contractAddress = this.getBalanceReaderAddress();
|
|
@@ -96,14 +96,14 @@ class ETHClient {
|
|
|
96
96
|
}
|
|
97
97
|
const carbonNetwork = networkConfig.network;
|
|
98
98
|
const fromTokenId = fromToken.id;
|
|
99
|
-
const fromTokenAddress = generic_1.appendHexPrefix(fromToken.tokenAddress);
|
|
99
|
+
const fromTokenAddress = (0, generic_1.appendHexPrefix)(fromToken.tokenAddress);
|
|
100
100
|
const toTokenDenom = toToken.denom;
|
|
101
101
|
const recoveryAddressHex = ethers_1.ethers.utils.hexlify(util_1.AddressUtils.SWTHAddress.getAddressBytes(recoveryAddress, carbonNetwork));
|
|
102
102
|
const fromAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(fromTokenId));
|
|
103
103
|
const toAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(toTokenDenom));
|
|
104
104
|
const nonce = yield rpcProvider.getTransactionCount(fromAddress);
|
|
105
105
|
const contract = new ethers_1.ethers.Contract(this.getBridgeEntranceAddr(), eth_1.ABIs.bridgeEntrance, rpcProvider);
|
|
106
|
-
const feeAddress = generic_1.appendHexPrefix(networkConfig.feeAddress);
|
|
106
|
+
const feeAddress = (0, generic_1.appendHexPrefix)(networkConfig.feeAddress);
|
|
107
107
|
const tokenCreator = fromToken.creator;
|
|
108
108
|
const targetAddressBytes = util_1.AddressUtils.SWTHAddress.getAddressBytes(tokenCreator, carbonNetwork);
|
|
109
109
|
const targetProxyHash = ethers_1.ethers.utils.hexlify(targetAddressBytes);
|
|
@@ -138,9 +138,9 @@ class ETHClient {
|
|
|
138
138
|
throw new Error("Minimum gas required: 150,000");
|
|
139
139
|
}
|
|
140
140
|
const networkConfig = this.getNetworkConfig();
|
|
141
|
-
const assetId = generic_1.appendHexPrefix(token.tokenAddress);
|
|
142
|
-
const targetProxyHash = generic_1.appendHexPrefix(this.getTargetProxyHash(token));
|
|
143
|
-
const feeAddress = generic_1.appendHexPrefix(networkConfig.feeAddress);
|
|
141
|
+
const assetId = (0, generic_1.appendHexPrefix)(token.tokenAddress);
|
|
142
|
+
const targetProxyHash = (0, generic_1.appendHexPrefix)(this.getTargetProxyHash(token));
|
|
143
|
+
const feeAddress = (0, generic_1.appendHexPrefix)(networkConfig.feeAddress);
|
|
144
144
|
const toAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(token.id));
|
|
145
145
|
const swthAddress = ethers_1.ethers.utils.hexlify(address);
|
|
146
146
|
const contractAddress = this.getLockProxyAddress();
|
|
@@ -191,16 +191,16 @@ class ETHClient {
|
|
|
191
191
|
return "insufficient balance";
|
|
192
192
|
}
|
|
193
193
|
const networkConfig = this.getNetworkConfig();
|
|
194
|
-
const assetId = generic_1.appendHexPrefix(tokenWithExternalBalances.tokenAddress);
|
|
195
|
-
const targetProxyHash = generic_1.appendHexPrefix(this.getTargetProxyHash(tokenWithExternalBalances));
|
|
196
|
-
const feeAddress = generic_1.appendHexPrefix(networkConfig.feeAddress);
|
|
194
|
+
const assetId = (0, generic_1.appendHexPrefix)(tokenWithExternalBalances.tokenAddress);
|
|
195
|
+
const targetProxyHash = (0, generic_1.appendHexPrefix)(this.getTargetProxyHash(tokenWithExternalBalances));
|
|
196
|
+
const feeAddress = (0, generic_1.appendHexPrefix)(networkConfig.feeAddress);
|
|
197
197
|
const toAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(tokenWithExternalBalances.id));
|
|
198
198
|
const nonce = Math.floor(Math.random() * 1000000000); // random nonce to prevent replay attacks
|
|
199
199
|
const message = ethers_1.ethers.utils.solidityKeccak256(["string", "address", "bytes", "bytes", "bytes", "uint256", "uint256", "uint256"], ["sendTokens", assetId, targetProxyHash, toAssetHash, feeAddress, amount, feeAmount, nonce]);
|
|
200
200
|
// logger("sendDeposit message", message)
|
|
201
201
|
let signatureResult;
|
|
202
202
|
const { address, signature } = yield getSignatureCallback(message);
|
|
203
|
-
const signatureBytes = ethers_1.ethers.utils.arrayify(generic_1.appendHexPrefix(signature));
|
|
203
|
+
const signatureBytes = ethers_1.ethers.utils.arrayify((0, generic_1.appendHexPrefix)(signature));
|
|
204
204
|
const rsv = ethers_1.ethers.utils.splitSignature(signatureBytes);
|
|
205
205
|
// logger("sign result", address, signature)
|
|
206
206
|
signatureResult = {
|
|
@@ -239,7 +239,7 @@ class ETHClient {
|
|
|
239
239
|
if (!feeInfo.deposit_fee) {
|
|
240
240
|
throw new Error("unsupported token");
|
|
241
241
|
}
|
|
242
|
-
if (blockchain_1.blockchainForChainId(token.chainId.toNumber()) !== this.blockchain) {
|
|
242
|
+
if ((0, blockchain_1.blockchainForChainId)(token.chainId.toNumber(), this.configProvider.getConfig().network) !== this.blockchain) {
|
|
243
243
|
throw new Error("unsupported token");
|
|
244
244
|
}
|
|
245
245
|
let feeAmount = ethers_1.ethers.BigNumber.from(feeInfo.deposit_fee);
|
|
@@ -305,7 +305,7 @@ class ETHClient {
|
|
|
305
305
|
getTargetProxyHash(token) {
|
|
306
306
|
const networkConfig = this.getNetworkConfig();
|
|
307
307
|
const addressBytes = address_1.SWTHAddress.getAddressBytes(token.creator, networkConfig.network);
|
|
308
|
-
const addressHex = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(addressBytes));
|
|
308
|
+
const addressHex = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(addressBytes));
|
|
309
309
|
return addressHex;
|
|
310
310
|
}
|
|
311
311
|
getProvider() {
|
|
@@ -29,7 +29,7 @@ exports.HydrogenEndpoints = {
|
|
|
29
29
|
const formatDateField = (value) => {
|
|
30
30
|
if (typeof value !== "string")
|
|
31
31
|
return null;
|
|
32
|
-
return dayjs_1.default(value);
|
|
32
|
+
return (0, dayjs_1.default)(value);
|
|
33
33
|
};
|
|
34
34
|
const formatCrossChainTransfer = (value) => {
|
|
35
35
|
var _a, _b;
|
package/lib/clients/NEOClient.js
CHANGED
|
@@ -64,13 +64,13 @@ class NEOClient {
|
|
|
64
64
|
return __awaiter(this, void 0, void 0, function* () {
|
|
65
65
|
const tokenQueryResults = yield sdk.token.getAllTokens();
|
|
66
66
|
const account = new Neon.wallet.Account(address);
|
|
67
|
-
const tokens = tokenQueryResults.filter((token) => blockchain_1.blockchainForChainId(token.chainId.toNumber()) == this.blockchain &&
|
|
67
|
+
const tokens = tokenQueryResults.filter((token) => (0, blockchain_1.blockchainForChainId)(token.chainId.toNumber(), sdk.network) == this.blockchain &&
|
|
68
68
|
token.tokenAddress.length == 40 &&
|
|
69
69
|
token.bridgeAddress.length == 40);
|
|
70
70
|
const client = new Neon.rpc.RPCClient(url, "2.5.2"); // TODO: should we change the RPC version??
|
|
71
71
|
// NOTE: fetching of tokens is chunked in sets of 15 as we may hit
|
|
72
72
|
// the gas limit on the RPC node and error out otherwise
|
|
73
|
-
const promises = lodash_1.chunk(tokens, 75).map((partition) => __awaiter(this, void 0, void 0, function* () {
|
|
73
|
+
const promises = (0, lodash_1.chunk)(tokens, 75).map((partition) => __awaiter(this, void 0, void 0, function* () {
|
|
74
74
|
var _a, _b, _c;
|
|
75
75
|
let acc = {};
|
|
76
76
|
for (const token of partition) {
|
|
@@ -112,8 +112,8 @@ class NEOClient {
|
|
|
112
112
|
const targetProxyHash = this.getTargetProxyHash(token);
|
|
113
113
|
const toAssetHash = Neon.u.str2hexstring(token.id);
|
|
114
114
|
const addressBytes = address_1.SWTHAddress.getAddressBytes(swthAddress, networkConfig.network);
|
|
115
|
-
const toAddress = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(addressBytes));
|
|
116
|
-
const zeroAddressHex = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(constant_1.ZeroAddress));
|
|
115
|
+
const toAddress = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(addressBytes));
|
|
116
|
+
const zeroAddressHex = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(constant_1.ZeroAddress));
|
|
117
117
|
const amount = ethers_1.ethers.BigNumber.from(token.externalBalance);
|
|
118
118
|
const feeAmount = ethers_1.ethers.BigNumber.from(feeAmountInput !== null && feeAmountInput !== void 0 ? feeAmountInput : "100000000");
|
|
119
119
|
const feeAddress = feeAmount.isZero() ? zeroAddressHex : networkConfig.feeAddress;
|
|
@@ -160,7 +160,7 @@ class NEOClient {
|
|
|
160
160
|
const fromAddress = util_1.AddressUtils.NEOAddress.publicKeyToAddress(publicKeyOutput.publicKey);
|
|
161
161
|
const targetProxyHash = this.getTargetProxyHash(token);
|
|
162
162
|
const toAssetHash = Neon.u.str2hexstring(token.id);
|
|
163
|
-
const toAddress = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(address));
|
|
163
|
+
const toAddress = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(address));
|
|
164
164
|
const nonce = Math.floor(Math.random() * 1000000);
|
|
165
165
|
if (amount.lt(feeAmount)) {
|
|
166
166
|
throw new Error("Invalid amount");
|
|
@@ -196,7 +196,7 @@ class NEOClient {
|
|
|
196
196
|
const fromAddress = ledger.scriptHash;
|
|
197
197
|
const targetProxyHash = this.getTargetProxyHash(token);
|
|
198
198
|
const toAssetHash = Neon.u.str2hexstring(token.id);
|
|
199
|
-
const toAddress = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(address));
|
|
199
|
+
const toAddress = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(address));
|
|
200
200
|
const feeAddress = networkConfig.feeAddress;
|
|
201
201
|
const nonce = Math.floor(Math.random() * 1000000);
|
|
202
202
|
if (amount.lt(feeAmount)) {
|
|
@@ -316,7 +316,7 @@ class NEOClient {
|
|
|
316
316
|
getTargetProxyHash(token) {
|
|
317
317
|
const networkConfig = this.getNetworkConfig();
|
|
318
318
|
const addressBytes = address_1.SWTHAddress.getAddressBytes(token.creator, networkConfig.network);
|
|
319
|
-
const addressHex = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(addressBytes));
|
|
319
|
+
const addressHex = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(addressBytes));
|
|
320
320
|
return addressHex;
|
|
321
321
|
}
|
|
322
322
|
getNetworkConfig() {
|
|
@@ -456,7 +456,7 @@ class TokenClient {
|
|
|
456
456
|
processTokenPrices(tokenPrices) {
|
|
457
457
|
return tokenPrices.reduce((prevPrices, price) => {
|
|
458
458
|
const newPrev = prevPrices;
|
|
459
|
-
newPrev[price.denom] = number_1.bnOrZero(price.twap).shiftedBy(-constant_1.decTypeDecimals);
|
|
459
|
+
newPrev[price.denom] = (0, number_1.bnOrZero)(price.twap).shiftedBy(-constant_1.decTypeDecimals);
|
|
460
460
|
return newPrev;
|
|
461
461
|
}, {});
|
|
462
462
|
}
|
package/lib/clients/ZILClient.js
CHANGED
|
@@ -72,12 +72,12 @@ class ZILClient {
|
|
|
72
72
|
getExternalBalances(sdk, address, whitelistDenoms) {
|
|
73
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
74
74
|
const tokenQueryResults = yield sdk.token.getAllTokens();
|
|
75
|
-
const tokens = tokenQueryResults.filter((token) => blockchain_1.blockchainForChainId(token.chainId.toNumber()) == this.blockchain &&
|
|
75
|
+
const tokens = tokenQueryResults.filter((token) => (0, blockchain_1.blockchainForChainId)(token.chainId.toNumber(), sdk.network) == this.blockchain &&
|
|
76
76
|
token.tokenAddress.length == 40 &&
|
|
77
77
|
(!whitelistDenoms || whitelistDenoms.includes(token.denom)));
|
|
78
78
|
const requests = tokens.map((token) => token.tokenAddress === zeroAddress
|
|
79
|
-
? exports.balanceBatchRequest(address.replace(/^0x/i, ""))
|
|
80
|
-
: exports.tokenBalanceBatchRequest(token.tokenAddress, address));
|
|
79
|
+
? (0, exports.balanceBatchRequest)(address.replace(/^0x/i, ""))
|
|
80
|
+
: (0, exports.tokenBalanceBatchRequest)(token.tokenAddress, address));
|
|
81
81
|
const response = yield fetch(this.getProviderUrl(), {
|
|
82
82
|
method: "post",
|
|
83
83
|
headers: { "content-type": "application/json" },
|
|
@@ -102,7 +102,7 @@ class ZILClient {
|
|
|
102
102
|
// if (!isValidAddress) {
|
|
103
103
|
// throw new Error("invalid address")
|
|
104
104
|
// }
|
|
105
|
-
return zilliqa_1.fromBech32Address(bech32Address).toLowerCase().substr(2);
|
|
105
|
+
return (0, zilliqa_1.fromBech32Address)(bech32Address).toLowerCase().substr(2);
|
|
106
106
|
});
|
|
107
107
|
}
|
|
108
108
|
// see examplesV2/zil_client.ts on how to confirm the transactions
|
|
@@ -148,7 +148,7 @@ class ZILClient {
|
|
|
148
148
|
zilliqa = new zilliqa_1.Zilliqa(this.getProviderUrl());
|
|
149
149
|
}
|
|
150
150
|
const deployedContract = (this.walletProvider || zilliqa).contracts.at(contractAddress);
|
|
151
|
-
const balanceAndNonceResp = yield zilliqa.blockchain.getBalance(generic_1.stripHexPrefix(zilAddress));
|
|
151
|
+
const balanceAndNonceResp = yield zilliqa.blockchain.getBalance((0, generic_1.stripHexPrefix)(zilAddress));
|
|
152
152
|
if (balanceAndNonceResp.error !== undefined) {
|
|
153
153
|
throw new Error(balanceAndNonceResp.error.message);
|
|
154
154
|
}
|
|
@@ -166,7 +166,7 @@ class ZILClient {
|
|
|
166
166
|
vname: "spender",
|
|
167
167
|
type: "ByStr20",
|
|
168
168
|
// TODO: Check if bridgeAddress corresponds to carbon token lock_proxy_hash
|
|
169
|
-
value: spenderAddress !== null && spenderAddress !== void 0 ? spenderAddress : generic_1.appendHexPrefix(token.bridgeAddress),
|
|
169
|
+
value: spenderAddress !== null && spenderAddress !== void 0 ? spenderAddress : (0, generic_1.appendHexPrefix)(token.bridgeAddress),
|
|
170
170
|
},
|
|
171
171
|
{
|
|
172
172
|
vname: "amount",
|
|
@@ -184,7 +184,7 @@ class ZILClient {
|
|
|
184
184
|
}
|
|
185
185
|
checkAllowanceZRC2(token, owner, spender) {
|
|
186
186
|
return __awaiter(this, void 0, void 0, function* () {
|
|
187
|
-
const contractAddress = generic_1.appendHexPrefix(token.tokenAddress);
|
|
187
|
+
const contractAddress = (0, generic_1.appendHexPrefix)(token.tokenAddress);
|
|
188
188
|
const zilliqa = new zilliqa_1.Zilliqa(this.getProviderUrl());
|
|
189
189
|
const resp = yield zilliqa.blockchain.getSmartContractSubState(contractAddress, "allowances", [owner, spender]);
|
|
190
190
|
if (resp.error !== undefined) {
|
|
@@ -206,13 +206,13 @@ class ZILClient {
|
|
|
206
206
|
}
|
|
207
207
|
const carbonNetwork = networkConfig.network;
|
|
208
208
|
const fromTokenId = fromToken.id;
|
|
209
|
-
const fromTokenAddr = generic_1.appendHexPrefix(fromToken.tokenAddress);
|
|
209
|
+
const fromTokenAddr = (0, generic_1.appendHexPrefix)(fromToken.tokenAddress);
|
|
210
210
|
const toTokenDenom = toToken.denom;
|
|
211
|
-
const targetProxyHash = generic_1.appendHexPrefix(this.getTargetProxyHash(fromToken));
|
|
211
|
+
const targetProxyHash = (0, generic_1.appendHexPrefix)(this.getTargetProxyHash(fromToken));
|
|
212
212
|
const recoveryAddressHex = ethers_1.ethers.utils.hexlify(index_1.AddressUtils.SWTHAddress.getAddressBytes(recoveryAddress, carbonNetwork));
|
|
213
213
|
const fromAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(fromTokenId));
|
|
214
214
|
const toAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(toTokenDenom));
|
|
215
|
-
const feeAddress = generic_1.appendHexPrefix(networkConfig.feeAddress);
|
|
215
|
+
const feeAddress = (0, generic_1.appendHexPrefix)(networkConfig.feeAddress);
|
|
216
216
|
const contractAddress = this.getBridgeEntranceAddr();
|
|
217
217
|
let zilliqa;
|
|
218
218
|
if (typeof signer === "string") {
|
|
@@ -227,7 +227,7 @@ class ZILClient {
|
|
|
227
227
|
zilliqa = new zilliqa_1.Zilliqa(this.getProviderUrl());
|
|
228
228
|
}
|
|
229
229
|
const deployedContract = (this.walletProvider || zilliqa).contracts.at(contractAddress);
|
|
230
|
-
const balanceAndNonceResp = yield zilliqa.blockchain.getBalance(generic_1.stripHexPrefix(fromAddress));
|
|
230
|
+
const balanceAndNonceResp = yield zilliqa.blockchain.getBalance((0, generic_1.stripHexPrefix)(fromAddress));
|
|
231
231
|
if (balanceAndNonceResp.error !== undefined) {
|
|
232
232
|
throw new Error(balanceAndNonceResp.error.message);
|
|
233
233
|
}
|
|
@@ -304,13 +304,13 @@ class ZILClient {
|
|
|
304
304
|
return __awaiter(this, void 0, void 0, function* () {
|
|
305
305
|
const { address, amount, token, gasPrice, gasLimit, zilAddress, signer } = params;
|
|
306
306
|
const networkConfig = this.getNetworkConfig();
|
|
307
|
-
const assetId = generic_1.appendHexPrefix(token.tokenAddress);
|
|
308
|
-
const targetProxyHash = generic_1.appendHexPrefix(this.getTargetProxyHash(token));
|
|
309
|
-
const feeAddress = generic_1.appendHexPrefix(networkConfig.feeAddress);
|
|
307
|
+
const assetId = (0, generic_1.appendHexPrefix)(token.tokenAddress);
|
|
308
|
+
const targetProxyHash = (0, generic_1.appendHexPrefix)(this.getTargetProxyHash(token));
|
|
309
|
+
const feeAddress = (0, generic_1.appendHexPrefix)(networkConfig.feeAddress);
|
|
310
310
|
const toAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(token.id));
|
|
311
311
|
const swthAddress = ethers_1.ethers.utils.hexlify(address);
|
|
312
312
|
// TODO: Check if bridgeAddress corresponds to carbon token lock_proxy_hash
|
|
313
|
-
const contractAddress = generic_1.appendHexPrefix(token.bridgeAddress);
|
|
313
|
+
const contractAddress = (0, generic_1.appendHexPrefix)(token.bridgeAddress);
|
|
314
314
|
let zilliqa;
|
|
315
315
|
if (typeof signer === "string") {
|
|
316
316
|
zilliqa = new zilliqa_1.Zilliqa(this.getProviderUrl());
|
|
@@ -324,7 +324,7 @@ class ZILClient {
|
|
|
324
324
|
zilliqa = new zilliqa_1.Zilliqa(this.getProviderUrl());
|
|
325
325
|
}
|
|
326
326
|
const deployedContract = (this.walletProvider || zilliqa).contracts.at(contractAddress);
|
|
327
|
-
const balanceAndNonceResp = yield zilliqa.blockchain.getBalance(generic_1.stripHexPrefix(zilAddress));
|
|
327
|
+
const balanceAndNonceResp = yield zilliqa.blockchain.getBalance((0, generic_1.stripHexPrefix)(zilAddress));
|
|
328
328
|
if (balanceAndNonceResp.error !== undefined) {
|
|
329
329
|
throw new Error(balanceAndNonceResp.error.message);
|
|
330
330
|
}
|
|
@@ -409,7 +409,7 @@ class ZILClient {
|
|
|
409
409
|
getTargetProxyHash(token) {
|
|
410
410
|
const networkConfig = this.getNetworkConfig();
|
|
411
411
|
const addressBytes = address_1.SWTHAddress.getAddressBytes(token.creator, networkConfig.network);
|
|
412
|
-
const addressHex = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(addressBytes));
|
|
412
|
+
const addressHex = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(addressBytes));
|
|
413
413
|
return addressHex;
|
|
414
414
|
}
|
|
415
415
|
getNetworkConfig() {
|
|
@@ -159,7 +159,7 @@ exports.QueryProposalsRequest = {
|
|
|
159
159
|
const message = Object.assign({}, baseQueryProposalsRequest);
|
|
160
160
|
message.proposalStatus =
|
|
161
161
|
object.proposalStatus !== undefined && object.proposalStatus !== null
|
|
162
|
-
? gov_1.proposalStatusFromJSON(object.proposalStatus)
|
|
162
|
+
? (0, gov_1.proposalStatusFromJSON)(object.proposalStatus)
|
|
163
163
|
: 0;
|
|
164
164
|
message.voter =
|
|
165
165
|
object.voter !== undefined && object.voter !== null
|
|
@@ -178,7 +178,7 @@ exports.QueryProposalsRequest = {
|
|
|
178
178
|
toJSON(message) {
|
|
179
179
|
const obj = {};
|
|
180
180
|
message.proposalStatus !== undefined &&
|
|
181
|
-
(obj.proposalStatus = gov_1.proposalStatusToJSON(message.proposalStatus));
|
|
181
|
+
(obj.proposalStatus = (0, gov_1.proposalStatusToJSON)(message.proposalStatus));
|
|
182
182
|
message.voter !== undefined && (obj.voter = message.voter);
|
|
183
183
|
message.depositor !== undefined && (obj.depositor = message.depositor);
|
|
184
184
|
message.pagination !== undefined &&
|
|
@@ -185,7 +185,7 @@ exports.MsgVote = {
|
|
|
185
185
|
: "";
|
|
186
186
|
message.option =
|
|
187
187
|
object.option !== undefined && object.option !== null
|
|
188
|
-
? gov_1.voteOptionFromJSON(object.option)
|
|
188
|
+
? (0, gov_1.voteOptionFromJSON)(object.option)
|
|
189
189
|
: 0;
|
|
190
190
|
return message;
|
|
191
191
|
},
|
|
@@ -195,7 +195,7 @@ exports.MsgVote = {
|
|
|
195
195
|
(obj.proposalId = (message.proposalId || long_1.default.UZERO).toString());
|
|
196
196
|
message.voter !== undefined && (obj.voter = message.voter);
|
|
197
197
|
message.option !== undefined &&
|
|
198
|
-
(obj.option = gov_1.voteOptionToJSON(message.option));
|
|
198
|
+
(obj.option = (0, gov_1.voteOptionToJSON)(message.option));
|
|
199
199
|
return obj;
|
|
200
200
|
},
|
|
201
201
|
fromPartial(object) {
|
|
@@ -618,13 +618,13 @@ exports.ModeInfo_Single = {
|
|
|
618
618
|
const message = Object.assign({}, baseModeInfo_Single);
|
|
619
619
|
message.mode =
|
|
620
620
|
object.mode !== undefined && object.mode !== null
|
|
621
|
-
? signing_1.signModeFromJSON(object.mode)
|
|
621
|
+
? (0, signing_1.signModeFromJSON)(object.mode)
|
|
622
622
|
: 0;
|
|
623
623
|
return message;
|
|
624
624
|
},
|
|
625
625
|
toJSON(message) {
|
|
626
626
|
const obj = {};
|
|
627
|
-
message.mode !== undefined && (obj.mode = signing_1.signModeToJSON(message.mode));
|
|
627
|
+
message.mode !== undefined && (obj.mode = (0, signing_1.signModeToJSON)(message.mode));
|
|
628
628
|
return obj;
|
|
629
629
|
},
|
|
630
630
|
fromPartial(object) {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import Long from "long";
|
|
2
|
+
import _m0 from "protobufjs/minimal";
|
|
3
|
+
export declare const protobufPackage = "Switcheo.carbon.liquiditypool";
|
|
4
|
+
export interface ParamsV2170 {
|
|
5
|
+
rewardReductionThreshold: Long;
|
|
6
|
+
}
|
|
7
|
+
export declare const ParamsV2170: {
|
|
8
|
+
encode(message: ParamsV2170, writer?: _m0.Writer): _m0.Writer;
|
|
9
|
+
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): ParamsV2170;
|
|
10
|
+
fromJSON(object: any): ParamsV2170;
|
|
11
|
+
toJSON(message: ParamsV2170): unknown;
|
|
12
|
+
fromPartial(object: DeepPartial<ParamsV2170>): ParamsV2170;
|
|
13
|
+
};
|
|
14
|
+
declare type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
15
|
+
export declare type DeepPartial<T> = T extends Builtin ? T : T extends Long ? string | number | Long : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
|
|
16
|
+
[K in keyof T]?: DeepPartial<T[K]>;
|
|
17
|
+
} : Partial<T>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ParamsV2170 = exports.protobufPackage = void 0;
|
|
7
|
+
/* eslint-disable */
|
|
8
|
+
const long_1 = __importDefault(require("long"));
|
|
9
|
+
const minimal_1 = __importDefault(require("protobufjs/minimal"));
|
|
10
|
+
exports.protobufPackage = "Switcheo.carbon.liquiditypool";
|
|
11
|
+
const baseParamsV2170 = { rewardReductionThreshold: long_1.default.UZERO };
|
|
12
|
+
exports.ParamsV2170 = {
|
|
13
|
+
encode(message, writer = minimal_1.default.Writer.create()) {
|
|
14
|
+
if (!message.rewardReductionThreshold.isZero()) {
|
|
15
|
+
writer.uint32(8).uint64(message.rewardReductionThreshold);
|
|
16
|
+
}
|
|
17
|
+
return writer;
|
|
18
|
+
},
|
|
19
|
+
decode(input, length) {
|
|
20
|
+
const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
|
|
21
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
22
|
+
const message = Object.assign({}, baseParamsV2170);
|
|
23
|
+
while (reader.pos < end) {
|
|
24
|
+
const tag = reader.uint32();
|
|
25
|
+
switch (tag >>> 3) {
|
|
26
|
+
case 1:
|
|
27
|
+
message.rewardReductionThreshold = reader.uint64();
|
|
28
|
+
break;
|
|
29
|
+
default:
|
|
30
|
+
reader.skipType(tag & 7);
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return message;
|
|
35
|
+
},
|
|
36
|
+
fromJSON(object) {
|
|
37
|
+
const message = Object.assign({}, baseParamsV2170);
|
|
38
|
+
message.rewardReductionThreshold =
|
|
39
|
+
object.rewardReductionThreshold !== undefined &&
|
|
40
|
+
object.rewardReductionThreshold !== null
|
|
41
|
+
? long_1.default.fromString(object.rewardReductionThreshold)
|
|
42
|
+
: long_1.default.UZERO;
|
|
43
|
+
return message;
|
|
44
|
+
},
|
|
45
|
+
toJSON(message) {
|
|
46
|
+
const obj = {};
|
|
47
|
+
message.rewardReductionThreshold !== undefined &&
|
|
48
|
+
(obj.rewardReductionThreshold = (message.rewardReductionThreshold || long_1.default.UZERO).toString());
|
|
49
|
+
return obj;
|
|
50
|
+
},
|
|
51
|
+
fromPartial(object) {
|
|
52
|
+
const message = Object.assign({}, baseParamsV2170);
|
|
53
|
+
message.rewardReductionThreshold =
|
|
54
|
+
object.rewardReductionThreshold !== undefined &&
|
|
55
|
+
object.rewardReductionThreshold !== null
|
|
56
|
+
? long_1.default.fromValue(object.rewardReductionThreshold)
|
|
57
|
+
: long_1.default.UZERO;
|
|
58
|
+
return message;
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
if (minimal_1.default.util.Long !== long_1.default) {
|
|
62
|
+
minimal_1.default.util.Long = long_1.default;
|
|
63
|
+
minimal_1.default.configure();
|
|
64
|
+
}
|
package/lib/constant/generic.js
CHANGED
|
@@ -12,7 +12,7 @@ exports.DEFAULT_FEE_DENOM = "swth";
|
|
|
12
12
|
exports.DEFAULT_GAS_PRICE = new bignumber_js_1.default(10);
|
|
13
13
|
exports.DEFAULT_GAS = new bignumber_js_1.default(10000000);
|
|
14
14
|
exports.DEFAULT_FEE = {
|
|
15
|
-
amount: proto_signing_1.coins(exports.DEFAULT_GAS_PRICE.times(exports.DEFAULT_GAS).dp(0).toString(), "swth"),
|
|
15
|
+
amount: (0, proto_signing_1.coins)(exports.DEFAULT_GAS_PRICE.times(exports.DEFAULT_GAS).dp(0).toString(), "swth"),
|
|
16
16
|
gas: exports.DEFAULT_GAS.toString(10),
|
|
17
17
|
};
|
|
18
18
|
exports.CARBON_GAS_PRICE = {
|