carbon-js-sdk 0.2.9 → 0.2.10
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/CarbonQueryClient.js +1 -1
- package/lib/clients/ETHClient.js +15 -15
- package/lib/clients/HydrogenClient.js +1 -1
- package/lib/clients/NEOClient.js +21 -21
- package/lib/clients/ZILClient.js +16 -16
- package/lib/codec/cdp/params.d.ts +1 -1
- package/lib/codec/cdp/params.js +11 -11
- package/lib/codec/cdp/stablecoin_debt_info.d.ts +23 -0
- package/lib/codec/cdp/stablecoin_debt_info.js +157 -0
- 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/constant/generic.js +1 -1
- 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 +20 -20
- 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 +4 -4
- package/lib/provider/amino/types/coin.js +2 -2
- 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/KeplrStore.js +1 -1
- 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/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 +6 -6
- package/lib/websocket/connector.js +3 -3
- package/package.json +2 -1
package/lib/util/address.js
CHANGED
|
@@ -96,13 +96,13 @@ const randomMnemonic = () => {
|
|
|
96
96
|
};
|
|
97
97
|
exports.randomMnemonic = randomMnemonic;
|
|
98
98
|
const wifEncodePrivateKey = (privateKey, iter = 128) => {
|
|
99
|
-
const privateKeyBuf =
|
|
99
|
+
const privateKeyBuf = exports.stringOrBufferToBuffer(privateKey);
|
|
100
100
|
return wif.encode(iter, privateKeyBuf, true);
|
|
101
101
|
};
|
|
102
102
|
exports.wifEncodePrivateKey = wifEncodePrivateKey;
|
|
103
103
|
exports.SWTHAddress = {
|
|
104
104
|
newMnemonic: () => {
|
|
105
|
-
return
|
|
105
|
+
return exports.randomMnemonic();
|
|
106
106
|
},
|
|
107
107
|
coinType: () => {
|
|
108
108
|
return SWTH_COIN_TYPE;
|
|
@@ -112,10 +112,10 @@ exports.SWTHAddress = {
|
|
|
112
112
|
return new BIP44Path(BIP44_PURPOSE, coinType).update(index, change, account).toArray();
|
|
113
113
|
},
|
|
114
114
|
publicKeyToScriptHash: (publicKey) => {
|
|
115
|
-
const pubKeyBuffer =
|
|
115
|
+
const pubKeyBuffer = exports.stringOrBufferToBuffer(publicKey);
|
|
116
116
|
const sha256Hash = ethers_1.ethers.utils.sha256(pubKeyBuffer);
|
|
117
117
|
const ripemdHash = ethers_1.ethers.utils.ripemd160(sha256Hash);
|
|
118
|
-
return
|
|
118
|
+
return generic_1.stripHexPrefix(ripemdHash);
|
|
119
119
|
},
|
|
120
120
|
publicKeyToAddress: (publicKey, opts) => {
|
|
121
121
|
const scriptHash = exports.SWTHAddress.publicKeyToScriptHash(publicKey);
|
|
@@ -137,7 +137,7 @@ exports.SWTHAddress = {
|
|
|
137
137
|
return privateKey;
|
|
138
138
|
},
|
|
139
139
|
privateToPublicKey: (privateKey) => {
|
|
140
|
-
const privateKeyBuff =
|
|
140
|
+
const privateKeyBuff = exports.stringOrBufferToBuffer(privateKey);
|
|
141
141
|
const publicKeyUint8Array = secp256k1.publicKeyCreate(privateKeyBuff, true);
|
|
142
142
|
const publicKey = Buffer.from(publicKeyUint8Array);
|
|
143
143
|
return publicKey;
|
|
@@ -148,7 +148,7 @@ exports.SWTHAddress = {
|
|
|
148
148
|
return address;
|
|
149
149
|
},
|
|
150
150
|
encode: (hash, opts) => {
|
|
151
|
-
const hashBuff =
|
|
151
|
+
const hashBuff = exports.stringOrBufferToBuffer(hash, 'hex');
|
|
152
152
|
const words = bech32.toWords(hashBuff.slice(0, 20));
|
|
153
153
|
const addressPrefix = exports.SWTHAddress.getBech32Prefix(opts === null || opts === void 0 ? void 0 : opts.network, opts === null || opts === void 0 ? void 0 : opts.bech32Prefix, opts === null || opts === void 0 ? void 0 : opts.type);
|
|
154
154
|
const address = bech32.encode(addressPrefix, words);
|
|
@@ -203,7 +203,7 @@ exports.NEOAddress = {
|
|
|
203
203
|
]);
|
|
204
204
|
const sha256Hash = ethers_1.ethers.utils.sha256(addressScript);
|
|
205
205
|
const ripemdHash = ethers_1.ethers.utils.ripemd160(sha256Hash);
|
|
206
|
-
return
|
|
206
|
+
return generic_1.stripHexPrefix(ripemdHash);
|
|
207
207
|
},
|
|
208
208
|
publicKeyToAddress: (publicKey) => {
|
|
209
209
|
const addressScript = exports.NEOAddress.publicKeyToScriptHash(publicKey);
|
|
@@ -211,7 +211,7 @@ exports.NEOAddress = {
|
|
|
211
211
|
return address;
|
|
212
212
|
},
|
|
213
213
|
encodePublicKey: (unencodedPublicKey) => {
|
|
214
|
-
const unencPubKeyBuf =
|
|
214
|
+
const unencPubKeyBuf = exports.stringOrBufferToBuffer(unencodedPublicKey);
|
|
215
215
|
if (unencPubKeyBuf.length <= 33) {
|
|
216
216
|
// length indicates already encoded
|
|
217
217
|
return unencPubKeyBuf;
|
|
@@ -236,7 +236,7 @@ exports.NEOAddress = {
|
|
|
236
236
|
return privateKey;
|
|
237
237
|
},
|
|
238
238
|
privateToPublicKey: (privateKey) => {
|
|
239
|
-
const privateKeyBuff =
|
|
239
|
+
const privateKeyBuff = exports.stringOrBufferToBuffer(privateKey);
|
|
240
240
|
const publicKeyUint8Array = secp256r1.publicKeyCreate(privateKeyBuff, true);
|
|
241
241
|
return Buffer.from(publicKeyUint8Array);
|
|
242
242
|
},
|
|
@@ -254,7 +254,7 @@ exports.NEOAddress = {
|
|
|
254
254
|
},
|
|
255
255
|
};
|
|
256
256
|
exports.N3Address = Object.assign(Object.assign({}, exports.NEOAddress), { publicKeyToScriptHash: (publicKey) => {
|
|
257
|
-
const publicKeyHex =
|
|
257
|
+
const publicKeyHex = exports.stringOrBufferToBuffer(publicKey).toString("hex");
|
|
258
258
|
return neon_core_next_1.wallet.getScriptHashFromPublicKey(publicKeyHex);
|
|
259
259
|
}, publicKeyToAddress: (publicKey) => {
|
|
260
260
|
const addressScript = exports.N3Address.publicKeyToScriptHash(publicKey);
|
|
@@ -280,11 +280,11 @@ exports.ETHAddress = {
|
|
|
280
280
|
return ethers_1.ethers.utils.keccak256(encodedPublicKey);
|
|
281
281
|
},
|
|
282
282
|
publicKeyToAddress: (publicKey) => {
|
|
283
|
-
const publicKeyBuff =
|
|
283
|
+
const publicKeyBuff = exports.stringOrBufferToBuffer(publicKey);
|
|
284
284
|
return ethers_1.ethers.utils.computeAddress(publicKeyBuff);
|
|
285
285
|
},
|
|
286
286
|
encodePublicKey: (unencodedPublicKey) => {
|
|
287
|
-
const unencodedPublicKeyBuff =
|
|
287
|
+
const unencodedPublicKeyBuff = exports.stringOrBufferToBuffer(unencodedPublicKey);
|
|
288
288
|
const publicKey = ethers_1.ethers.utils.computePublicKey(unencodedPublicKeyBuff, true);
|
|
289
289
|
return Buffer.from(publicKey, "hex");
|
|
290
290
|
},
|
|
@@ -296,7 +296,7 @@ exports.ETHAddress = {
|
|
|
296
296
|
return Buffer.from((_a = wallet.privateKey) === null || _a === void 0 ? void 0 : _a.replace(/^0x/, ""), "hex");
|
|
297
297
|
},
|
|
298
298
|
privateToPublicKey: (privateKey) => {
|
|
299
|
-
const privateKeyBuff =
|
|
299
|
+
const privateKeyBuff = exports.stringOrBufferToBuffer(privateKey);
|
|
300
300
|
return Buffer.from(ethers_1.ethers.utils.computePublicKey(privateKeyBuff).replace(/^0x/, ""), "hex");
|
|
301
301
|
},
|
|
302
302
|
privateKeyToAddress: (privateKey) => {
|
package/lib/util/api.js
CHANGED
|
@@ -84,7 +84,7 @@ class HTTP {
|
|
|
84
84
|
* Executes HTTP GET request with fetch
|
|
85
85
|
*/
|
|
86
86
|
this.get = ({ url, headers }) => {
|
|
87
|
-
return
|
|
87
|
+
return fetch_1.fetch(url, {
|
|
88
88
|
method: 'GET',
|
|
89
89
|
headers,
|
|
90
90
|
});
|
|
@@ -93,7 +93,7 @@ class HTTP {
|
|
|
93
93
|
* Executes HTTP POST request with fetch
|
|
94
94
|
*/
|
|
95
95
|
this.post = (options) => {
|
|
96
|
-
return
|
|
96
|
+
return fetch_1.fetch(options.url, {
|
|
97
97
|
method: 'POST',
|
|
98
98
|
headers: Object.assign({ 'Content-Type': options.content_type || 'application/json' }, options.headers),
|
|
99
99
|
body: JSON.stringify(options.body),
|
|
@@ -103,7 +103,7 @@ class HTTP {
|
|
|
103
103
|
* Executes HTTP DELETE request with fetch
|
|
104
104
|
*/
|
|
105
105
|
this.del = (options) => {
|
|
106
|
-
return
|
|
106
|
+
return fetch_1.fetch(options.url, {
|
|
107
107
|
method: 'DELETE',
|
|
108
108
|
headers: Object.assign({ 'Content-Type': options.content_type || 'application/json' }, options.headers),
|
|
109
109
|
body: JSON.stringify(options.body),
|
|
@@ -114,7 +114,7 @@ class HTTP {
|
|
|
114
114
|
*/
|
|
115
115
|
this.raw = (options) => {
|
|
116
116
|
const { url } = options, otherOpts = __rest(options, ["url"]);
|
|
117
|
-
return
|
|
117
|
+
return fetch_1.fetch(url, otherOpts);
|
|
118
118
|
};
|
|
119
119
|
this.apiPrefix = apiPrefix;
|
|
120
120
|
this.apiEndpoints = apiEndpoints;
|
package/lib/util/fetch.js
CHANGED
package/lib/util/generic.js
CHANGED
|
@@ -22,7 +22,7 @@ const overrideConfig = (defaults, override) => {
|
|
|
22
22
|
continue;
|
|
23
23
|
if (typeof member === "object") {
|
|
24
24
|
// @ts-ignore
|
|
25
|
-
result[key] =
|
|
25
|
+
result[key] = exports.overrideConfig(result[key], member);
|
|
26
26
|
}
|
|
27
27
|
else {
|
|
28
28
|
// @ts-ignore
|
|
@@ -41,7 +41,7 @@ const sortObject = (input) => {
|
|
|
41
41
|
Object.keys(input)
|
|
42
42
|
.sort()
|
|
43
43
|
// @ts-ignore noImplicitAny
|
|
44
|
-
.forEach((key) => (output[key] =
|
|
44
|
+
.forEach((key) => (output[key] = exports.sortObject(input[key])));
|
|
45
45
|
return output;
|
|
46
46
|
};
|
|
47
47
|
exports.sortObject = sortObject;
|
|
@@ -56,7 +56,7 @@ exports.appendHexPrefix = appendHexPrefix;
|
|
|
56
56
|
const computeTxHash = (bytes) => {
|
|
57
57
|
if (!bytes)
|
|
58
58
|
return bytes;
|
|
59
|
-
return
|
|
59
|
+
return exports.toTxHash(crypto_1.sha256(bytes));
|
|
60
60
|
};
|
|
61
61
|
exports.computeTxHash = computeTxHash;
|
|
62
62
|
const toTxHash = (bytes) => {
|
package/lib/util/number.js
CHANGED
|
@@ -17,26 +17,26 @@ const parseBN = (input, defaultValue) => {
|
|
|
17
17
|
};
|
|
18
18
|
exports.parseBN = parseBN;
|
|
19
19
|
const bnOrZero = (input, defaultValue = exports.BN_ZERO) => {
|
|
20
|
-
return
|
|
20
|
+
return exports.parseBN(input, defaultValue);
|
|
21
21
|
};
|
|
22
22
|
exports.bnOrZero = bnOrZero;
|
|
23
23
|
const toHuman = (value, decimals) => {
|
|
24
24
|
if (value === undefined || value === null)
|
|
25
25
|
return undefined;
|
|
26
|
-
const valueBN =
|
|
26
|
+
const valueBN = exports.bnOrZero(value);
|
|
27
27
|
if (!decimals)
|
|
28
28
|
return valueBN; // decimals = 0 or nullish
|
|
29
|
-
const decimalsBN =
|
|
29
|
+
const decimalsBN = exports.bnOrZero(decimals);
|
|
30
30
|
return valueBN.shiftedBy(decimalsBN.negated().toNumber());
|
|
31
31
|
};
|
|
32
32
|
exports.toHuman = toHuman;
|
|
33
33
|
const toUnitless = (value, decimals) => {
|
|
34
34
|
if (value === undefined || value === null)
|
|
35
35
|
return undefined;
|
|
36
|
-
const valueBN =
|
|
36
|
+
const valueBN = exports.bnOrZero(value);
|
|
37
37
|
if (!decimals)
|
|
38
38
|
return valueBN; // decimals = 0 or nullish
|
|
39
|
-
const decimalsBN =
|
|
39
|
+
const decimalsBN = exports.bnOrZero(decimals);
|
|
40
40
|
return valueBN.shiftedBy(decimalsBN.toNumber());
|
|
41
41
|
};
|
|
42
42
|
exports.toUnitless = toUnitless;
|
|
@@ -93,9 +93,9 @@ class CarbonLedgerSigner {
|
|
|
93
93
|
return __awaiter(this, void 0, void 0, function* () {
|
|
94
94
|
const account = yield this.retrieveAccount();
|
|
95
95
|
const { pubkey } = account;
|
|
96
|
-
const msg = JSON.stringify(
|
|
96
|
+
const msg = JSON.stringify(generic_1.sortObject(doc));
|
|
97
97
|
const signBytes = yield this.ledger.sign(msg);
|
|
98
|
-
const signature =
|
|
98
|
+
const signature = amino_1.encodeSecp256k1Signature(pubkey, signBytes);
|
|
99
99
|
return {
|
|
100
100
|
signed: doc,
|
|
101
101
|
signature,
|
|
@@ -62,7 +62,7 @@ class CarbonSigningClient extends stargate_1.StargateClient {
|
|
|
62
62
|
*/
|
|
63
63
|
sign(signerAddress, messages, fee, memo, signerData) {
|
|
64
64
|
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
-
return
|
|
65
|
+
return proto_signing_1.isOfflineDirectSigner(this.signer)
|
|
66
66
|
? this.signDirect(signerAddress, messages, fee, memo, signerData)
|
|
67
67
|
: this.signAmino(signerAddress, messages, fee, memo, signerData);
|
|
68
68
|
});
|
|
@@ -74,7 +74,7 @@ class CarbonSigningClient extends stargate_1.StargateClient {
|
|
|
74
74
|
if (!accountFromSigner) {
|
|
75
75
|
throw new Error("Failed to retrieve account from signer");
|
|
76
76
|
}
|
|
77
|
-
const pubkey =
|
|
77
|
+
const pubkey = proto_signing_1.encodePubkey(amino_1.encodeSecp256k1Pubkey(accountFromSigner.pubkey));
|
|
78
78
|
const txBodyEncodeObject = {
|
|
79
79
|
typeUrl: "/cosmos.tx.v1beta1.TxBody",
|
|
80
80
|
value: Object.assign({ messages: messages, memo: memo }, timeoutHeight && {
|
|
@@ -83,13 +83,13 @@ class CarbonSigningClient extends stargate_1.StargateClient {
|
|
|
83
83
|
};
|
|
84
84
|
const txBodyBytes = this.registry.encode(txBodyEncodeObject);
|
|
85
85
|
const gasLimit = math_1.Int53.fromString(fee.gas).toNumber();
|
|
86
|
-
const authInfoBytes =
|
|
87
|
-
const signDoc =
|
|
86
|
+
const authInfoBytes = proto_signing_1.makeAuthInfoBytes([{ pubkey, sequence }], fee.amount, gasLimit);
|
|
87
|
+
const signDoc = proto_signing_1.makeSignDoc(txBodyBytes, authInfoBytes, chainId, accountNumber);
|
|
88
88
|
const { signature, signed } = yield signer.signDirect(signerAddress, signDoc);
|
|
89
89
|
return tx_1.TxRaw.fromPartial({
|
|
90
90
|
bodyBytes: signed.bodyBytes,
|
|
91
91
|
authInfoBytes: signed.authInfoBytes,
|
|
92
|
-
signatures: [
|
|
92
|
+
signatures: [encoding_1.fromBase64(signature.signature)],
|
|
93
93
|
});
|
|
94
94
|
});
|
|
95
95
|
}
|
|
@@ -100,7 +100,7 @@ class CarbonSigningClient extends stargate_1.StargateClient {
|
|
|
100
100
|
if (!accountFromSigner) {
|
|
101
101
|
throw new Error("Failed to retrieve account from signer");
|
|
102
102
|
}
|
|
103
|
-
const pubkey =
|
|
103
|
+
const pubkey = proto_signing_1.encodePubkey(amino_1.encodeSecp256k1Pubkey(accountFromSigner.pubkey));
|
|
104
104
|
const signMode = signing_1.SignMode.SIGN_MODE_LEGACY_AMINO_JSON;
|
|
105
105
|
const msgs = messages.map((msg) => this.aminoTypes.toAmino(msg));
|
|
106
106
|
const signDoc = makeSignDocAmino(msgs, fee, chainId, memo, accountNumber, sequence, timeoutHeight !== null && timeoutHeight !== void 0 ? timeoutHeight : 0);
|
|
@@ -115,11 +115,11 @@ class CarbonSigningClient extends stargate_1.StargateClient {
|
|
|
115
115
|
const signedTxBodyBytes = this.registry.encode(signedTxBodyEncodeObject);
|
|
116
116
|
const signedGasLimit = math_1.Int53.fromString(signed.fee.gas).toNumber();
|
|
117
117
|
const signedSequence = math_1.Int53.fromString(signed.sequence).toNumber();
|
|
118
|
-
const signedAuthInfoBytes =
|
|
118
|
+
const signedAuthInfoBytes = proto_signing_1.makeAuthInfoBytes([{ pubkey, sequence: signedSequence }], signed.fee.amount, signedGasLimit, signMode);
|
|
119
119
|
return tx_1.TxRaw.fromPartial({
|
|
120
120
|
bodyBytes: signedTxBodyBytes,
|
|
121
121
|
authInfoBytes: signedAuthInfoBytes,
|
|
122
|
-
signatures: [
|
|
122
|
+
signatures: [encoding_1.fromBase64(signature.signature)],
|
|
123
123
|
});
|
|
124
124
|
});
|
|
125
125
|
}
|
|
@@ -148,7 +148,7 @@ class CarbonWallet {
|
|
|
148
148
|
const signerData = Object.assign({ accountNumber: this.accountInfo.accountNumber, chainId: this.getChainId(), sequence }, explicitSignerData);
|
|
149
149
|
const fee = (_a = opts === null || opts === void 0 ? void 0 : opts.fee) !== null && _a !== void 0 ? _a : this.estimateTxFee(messages, feeDenom);
|
|
150
150
|
const txRaw = yield signingClient.sign(signerAddress, messages, fee, memo, signerData);
|
|
151
|
-
signature =
|
|
151
|
+
signature = amino_1.encodeSecp256k1Signature(account.pubkey, txRaw.signatures[0]);
|
|
152
152
|
return txRaw;
|
|
153
153
|
}
|
|
154
154
|
finally {
|
|
@@ -166,7 +166,7 @@ class CarbonWallet {
|
|
|
166
166
|
const tx = CarbonWallet.TxRaw.encode(txRaw).finish();
|
|
167
167
|
const carbonClient = this.getSigningClient();
|
|
168
168
|
const response = yield carbonClient.broadcastTx(tx, timeoutMs, pollIntervalMs);
|
|
169
|
-
if (
|
|
169
|
+
if (stargate_1.isDeliverTxFailure(response)) {
|
|
170
170
|
// tx failed
|
|
171
171
|
console.error(response);
|
|
172
172
|
throw new Error(`[${response.code}] ${response.rawLog}`);
|
|
@@ -206,9 +206,9 @@ class CarbonWallet {
|
|
|
206
206
|
try {
|
|
207
207
|
if (!this.accountInfo || this.sequenceInvalidated)
|
|
208
208
|
yield this.reloadAccountSequence();
|
|
209
|
-
const heightResponse = yield
|
|
209
|
+
const heightResponse = yield fetch_1.fetch(`${this.networkConfig.tmRpcUrl}/blockchain?cache=${new Date().getTime()}`);
|
|
210
210
|
const heightRes = yield heightResponse.json();
|
|
211
|
-
const height =
|
|
211
|
+
const height = number_1.bnOrZero((_a = heightRes.result) === null || _a === void 0 ? void 0 : _a.last_height);
|
|
212
212
|
const timeoutHeight = height.isZero() ? undefined : height.toNumber() + this.defaultTimeoutBlocks;
|
|
213
213
|
const sequence = this.accountInfo.sequence;
|
|
214
214
|
this.accountInfo = Object.assign(Object.assign({}, this.accountInfo), { sequence: sequence + 1 });
|
|
@@ -342,12 +342,12 @@ class CarbonWallet {
|
|
|
342
342
|
const queryClient = this.getQueryClient();
|
|
343
343
|
const { msgGasCosts } = yield queryClient.fee.MsgGasCostAll({});
|
|
344
344
|
this.txGasCosts = msgGasCosts.reduce((result, item) => {
|
|
345
|
-
result[item.msgType] =
|
|
345
|
+
result[item.msgType] = number_1.bnOrZero(item.gasCost);
|
|
346
346
|
return result;
|
|
347
347
|
}, {});
|
|
348
348
|
const { minGasPrices } = yield queryClient.fee.MinGasPriceAll({});
|
|
349
349
|
this.txGasPrices = minGasPrices.reduce((result, item) => {
|
|
350
|
-
result[item.denom] =
|
|
350
|
+
result[item.denom] = number_1.bnOrZero(item.gasPrice).shiftedBy(-18); // sdk.Dec shifting
|
|
351
351
|
return result;
|
|
352
352
|
}, {});
|
|
353
353
|
if (!this.txGasPrices[this.defaultFeeDenom]) {
|
|
@@ -171,7 +171,7 @@ class WSConnector {
|
|
|
171
171
|
params = [params]; // eslint-disable-line no-param-reassign
|
|
172
172
|
}
|
|
173
173
|
for (const param of params) {
|
|
174
|
-
const channelId =
|
|
174
|
+
const channelId = channel_1.generateChannelId(param);
|
|
175
175
|
const shouldSubscribe = this.channelHandlers[channelId] === undefined;
|
|
176
176
|
this.channelHandlers[channelId] = handler;
|
|
177
177
|
if (shouldSubscribe) {
|
|
@@ -193,7 +193,7 @@ class WSConnector {
|
|
|
193
193
|
}
|
|
194
194
|
const channelIds = [];
|
|
195
195
|
for (const param of params) {
|
|
196
|
-
const channelId =
|
|
196
|
+
const channelId = channel_1.generateChannelId(param);
|
|
197
197
|
delete this.channelHandlers[channelId];
|
|
198
198
|
}
|
|
199
199
|
this.send('unsubscribe', {
|
|
@@ -279,7 +279,7 @@ class WSConnector {
|
|
|
279
279
|
if (!channelHandler) {
|
|
280
280
|
this.debugLog(`handler not found for channel: ${message.channel}`);
|
|
281
281
|
try {
|
|
282
|
-
const params =
|
|
282
|
+
const params = channel_1.parseChannelId(message.channel);
|
|
283
283
|
this.unsubscribe({ channel: params.channel });
|
|
284
284
|
}
|
|
285
285
|
catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "carbon-js-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.10",
|
|
4
4
|
"description": "TypeScript SDK for Carbon blockchain",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@cityofzion/neon-api": "^4.9.0",
|
|
40
40
|
"@cityofzion/neon-core": "^4.9.0",
|
|
41
|
+
"@cityofzion/neon-js": "^4.9.0",
|
|
41
42
|
"@cityofzion/neon-core-next": "npm:@cityofzion/neon-core@^5.0.0",
|
|
42
43
|
"@cosmjs/proto-signing": "^0.28.10",
|
|
43
44
|
"@cosmjs/stargate": "^0.28.10",
|