carbon-js-sdk 0.11.30 → 0.11.31
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
|
@@ -77,7 +77,7 @@ class ETHClient {
|
|
|
77
77
|
const contract = new ethers_1.ethers.Contract(contractAddress, eth_1.ABIs.erc20, rpcProvider);
|
|
78
78
|
const approvalAmount = ethers_1.ethers.BigNumber.from((_a = amount === null || amount === void 0 ? void 0 : amount.toString(10)) !== null && _a !== void 0 ? _a : ethers_1.ethers.constants.MaxUint256);
|
|
79
79
|
const nonce = yield this.getTxNonce(ethAddress, params.nonce, rpcProvider);
|
|
80
|
-
const approveResultTx = yield contract.connect(signer).approve(spenderAddress !== null && spenderAddress !== void 0 ? spenderAddress : token.bridgeAddress, approvalAmount, Object.assign(Object.assign({ nonce }, gasPriceGwei && ({ gasPrice: gasPriceGwei.shiftedBy(9).toString(10) })), gasLimit && ({ gasLimit: gasLimit.toString(10) })));
|
|
80
|
+
const approveResultTx = yield contract.connect(signer).approve(spenderAddress !== null && spenderAddress !== void 0 ? spenderAddress : token.bridgeAddress, approvalAmount, Object.assign(Object.assign({ nonce }, gasPriceGwei && ({ gasPrice: gasPriceGwei.shiftedBy(9).dp(0, bignumber_js_1.default.ROUND_FLOOR).toString(10) })), gasLimit && ({ gasLimit: gasLimit.dp(0, bignumber_js_1.default.ROUND_FLOOR).toString(10) })));
|
|
81
81
|
return approveResultTx;
|
|
82
82
|
});
|
|
83
83
|
}
|
|
@@ -122,10 +122,10 @@ class ETHClient {
|
|
|
122
122
|
toAddress,
|
|
123
123
|
toAssetHash, // _toAssetHash
|
|
124
124
|
], [
|
|
125
|
-
amount.toString(10),
|
|
126
|
-
feeAmount.toString(10),
|
|
127
|
-
amount.toString(10),
|
|
128
|
-
], Object.assign(Object.assign(Object.assign({}, gasPriceGwei && ({ gasPrice: gasPriceGwei.shiftedBy(9).toString(10) })), gasLimit && ({ gasLimit: gasLimit.toString(10) })), { nonce, value: ethAmount.toString(10) }));
|
|
125
|
+
amount.dp(0, bignumber_js_1.default.ROUND_FLOOR).toString(10),
|
|
126
|
+
feeAmount.dp(0, bignumber_js_1.default.ROUND_FLOOR).toString(10),
|
|
127
|
+
amount.dp(0, bignumber_js_1.default.ROUND_FLOOR).toString(10),
|
|
128
|
+
], Object.assign(Object.assign(Object.assign({}, gasPriceGwei && ({ gasPrice: gasPriceGwei.shiftedBy(9).dp(0, bignumber_js_1.default.ROUND_FLOOR).toString(10) })), gasLimit && ({ gasLimit: gasLimit.dp(0, bignumber_js_1.default.ROUND_FLOOR).toString(10) })), { nonce, value: ethAmount.dp(0, bignumber_js_1.default.ROUND_FLOOR).toString(10) }));
|
|
129
129
|
signCompleteCallback === null || signCompleteCallback === void 0 ? void 0 : signCompleteCallback();
|
|
130
130
|
return bridgeResultTx;
|
|
131
131
|
});
|
|
@@ -153,11 +153,11 @@ class ETHClient {
|
|
|
153
153
|
feeAddress, // _feeAddress
|
|
154
154
|
[
|
|
155
155
|
// _values
|
|
156
|
-
amount.toString(),
|
|
156
|
+
amount.dp(0, bignumber_js_1.default.ROUND_FLOOR).toString(10),
|
|
157
157
|
"0",
|
|
158
|
-
amount.toString(), // callAmount
|
|
159
|
-
], Object.assign(Object.assign(Object.assign({ nonce, value: "0" }, gasPriceGwei && ({ gasPrice: gasPriceGwei.shiftedBy(9).toString(10) })), gasLimit && ({ gasLimit: gasLimit.toString(10) })), (token.tokenAddress === "0000000000000000000000000000000000000000" && {
|
|
160
|
-
value: amount.toString(),
|
|
158
|
+
amount.dp(0, bignumber_js_1.default.ROUND_FLOOR).toString(10), // callAmount
|
|
159
|
+
], Object.assign(Object.assign(Object.assign({ nonce, value: "0" }, gasPriceGwei && ({ gasPrice: gasPriceGwei.shiftedBy(9).dp(0, bignumber_js_1.default.ROUND_FLOOR).toString(10) })), gasLimit && ({ gasLimit: gasLimit.dp(0, bignumber_js_1.default.ROUND_FLOOR).toString(10) })), (token.tokenAddress === "0000000000000000000000000000000000000000" && {
|
|
160
|
+
value: amount.dp(0, bignumber_js_1.default.ROUND_FLOOR).toString(10),
|
|
161
161
|
})));
|
|
162
162
|
signCompleteCallback === null || signCompleteCallback === void 0 ? void 0 : signCompleteCallback();
|
|
163
163
|
return lockResultTx;
|
package/lib/clients/ZILClient.js
CHANGED
|
@@ -288,12 +288,12 @@ class ZILClient {
|
|
|
288
288
|
{
|
|
289
289
|
vname: "amount",
|
|
290
290
|
type: "Uint256",
|
|
291
|
-
value: amount.toString(10),
|
|
291
|
+
value: amount.dp(0, bignumber_js_1.default.ROUND_FLOOR).toString(10),
|
|
292
292
|
},
|
|
293
293
|
{
|
|
294
294
|
vname: "withdrawFeeAmount",
|
|
295
295
|
type: "Uint256",
|
|
296
|
-
value: feeAmount.toString(10),
|
|
296
|
+
value: feeAmount.dp(0, bignumber_js_1.default.ROUND_FLOOR).toString(10),
|
|
297
297
|
},
|
|
298
298
|
];
|
|
299
299
|
const data = {
|
|
@@ -375,7 +375,7 @@ class ZILClient {
|
|
|
375
375
|
{
|
|
376
376
|
vname: "amount",
|
|
377
377
|
type: "Uint256",
|
|
378
|
-
value: amount.toString(),
|
|
378
|
+
value: amount.dp(0, bignumber_js_1.default.ROUND_FLOOR).toString(10),
|
|
379
379
|
},
|
|
380
380
|
{
|
|
381
381
|
vname: "feeAmount",
|
package/lib/modules/coin.js
CHANGED
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.CoinModule = void 0;
|
|
16
16
|
const tx_1 = require("../codec/Switcheo/carbon/coin/tx");
|
|
17
17
|
const util_1 = require("../util");
|
|
18
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
18
19
|
const base_1 = __importDefault(require("./base"));
|
|
19
20
|
class CoinModule extends base_1.default {
|
|
20
21
|
createWithdrawal(params, opts) {
|
|
@@ -24,8 +25,8 @@ class CoinModule extends base_1.default {
|
|
|
24
25
|
creator: wallet.bech32Address,
|
|
25
26
|
toAddress: params.toAddress,
|
|
26
27
|
denom: params.denom,
|
|
27
|
-
amount: params.amount.toString(10),
|
|
28
|
-
feeAmount: params.feeAmount.toString(10),
|
|
28
|
+
amount: params.amount.dp(0, bignumber_js_1.default.ROUND_FLOOR).toString(10),
|
|
29
|
+
feeAmount: params.feeAmount.dp(0, bignumber_js_1.default.ROUND_FLOOR).toString(10),
|
|
29
30
|
feeAddress: params.feeAddress,
|
|
30
31
|
feeDenom: params.feeDenom,
|
|
31
32
|
});
|
package/lib/modules/grant.js
CHANGED
|
@@ -46,6 +46,8 @@ class GrantModule extends base_1.default {
|
|
|
46
46
|
};
|
|
47
47
|
});
|
|
48
48
|
let messages = encodedGrantMsgs;
|
|
49
|
+
// can only have one existing grant between granter and grantee
|
|
50
|
+
// to 'extend' have to revoke existing fee-grant and approve new fee-grant with new expiration
|
|
49
51
|
if (params.existingGrantee) {
|
|
50
52
|
const encodedRevokeAllowanceMsg = [{
|
|
51
53
|
typeUrl: util_1.CarbonTx.Types.MsgRevokeAllowance,
|
|
@@ -81,7 +83,7 @@ class GrantModule extends base_1.default {
|
|
|
81
83
|
});
|
|
82
84
|
}
|
|
83
85
|
revokeAuthAndAllowance(params, opts) {
|
|
84
|
-
var _a;
|
|
86
|
+
var _a, _b;
|
|
85
87
|
return __awaiter(this, void 0, void 0, function* () {
|
|
86
88
|
const wallet = this.getWallet();
|
|
87
89
|
const authorizedSignlessMsgs = (_a = wallet.authorizedMsgs) !== null && _a !== void 0 ? _a : [];
|
|
@@ -97,7 +99,16 @@ class GrantModule extends base_1.default {
|
|
|
97
99
|
value: revokeMsg,
|
|
98
100
|
};
|
|
99
101
|
});
|
|
100
|
-
|
|
102
|
+
let messages = encodedRevokeGrantMsgs;
|
|
103
|
+
const encodedRevokeAllowanceMsg = [{
|
|
104
|
+
typeUrl: util_1.CarbonTx.Types.MsgRevokeAllowance,
|
|
105
|
+
value: tx_2.MsgRevokeAllowance.fromPartial({
|
|
106
|
+
granter: (_b = params.granter) !== null && _b !== void 0 ? _b : wallet.bech32Address,
|
|
107
|
+
grantee: params.grantee,
|
|
108
|
+
}),
|
|
109
|
+
}];
|
|
110
|
+
messages = messages.concat(encodedRevokeAllowanceMsg);
|
|
111
|
+
const result = yield wallet.sendTxs(messages, opts);
|
|
101
112
|
return result;
|
|
102
113
|
});
|
|
103
114
|
}
|
|
@@ -246,10 +246,9 @@ class CarbonWallet {
|
|
|
246
246
|
isGranteeValid() {
|
|
247
247
|
if (!this.grantee)
|
|
248
248
|
return false;
|
|
249
|
-
const { expiry
|
|
249
|
+
const { expiry } = this.grantee;
|
|
250
250
|
const hasNotExpired = dayjs_1.default.utc(expiry).isAfter(dayjs_1.default.utc().add(grant_1.BUFFER_PERIOD, 'seconds'));
|
|
251
|
-
|
|
252
|
-
return hasNotExpired && versionUpToDate && !!this.grantee.signer;
|
|
251
|
+
return hasNotExpired && !!this.grantee.signer;
|
|
253
252
|
}
|
|
254
253
|
updateNetwork(network) {
|
|
255
254
|
this.network = network;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "carbon-js-sdk",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.31",
|
|
4
4
|
"description": "TypeScript SDK for Carbon blockchain",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -73,6 +73,7 @@
|
|
|
73
73
|
"wif": "^2.0.6"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
|
+
"@ledgerhq/hw-transport-node-hid": "^6.29.5",
|
|
76
77
|
"@types/lodash": "^4.14.174",
|
|
77
78
|
"@types/node": "^17.0.6",
|
|
78
79
|
"@types/node-fetch": "^2.5.12",
|