carbon-js-sdk 0.3.43-dev.1 → 0.3.43-dev.3

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.
Files changed (58) hide show
  1. package/lib/clients/CarbonQueryClient.js +2 -2
  2. package/lib/clients/ETHClient.js +15 -15
  3. package/lib/clients/HydrogenClient.js +1 -1
  4. package/lib/clients/NEOClient.js +7 -7
  5. package/lib/clients/TokenClient.js +1 -1
  6. package/lib/clients/ZILClient.js +17 -17
  7. package/lib/codec/cosmos/gov/v1beta1/query.js +2 -2
  8. package/lib/codec/cosmos/gov/v1beta1/tx.js +2 -2
  9. package/lib/codec/cosmos/tx/v1beta1/tx.js +2 -2
  10. package/lib/codec/index.d.ts +2 -2
  11. package/lib/codec/index.js +10 -6
  12. package/lib/codec/liquiditypool/event.d.ts +14 -0
  13. package/lib/codec/liquiditypool/event.js +107 -1
  14. package/lib/codec/liquiditypool/query.d.ts +71 -34
  15. package/lib/codec/liquiditypool/query.js +304 -112
  16. package/lib/codec/liquiditypool/tx.d.ts +0 -1
  17. package/lib/codec/liquiditypool/tx.js +1 -18
  18. package/lib/constant/generic.js +1 -1
  19. package/lib/modules/cdp.js +43 -43
  20. package/lib/modules/gov.js +12 -12
  21. package/lib/modules/liquiditypool.d.ts +0 -1
  22. package/lib/modules/liquiditypool.js +1 -2
  23. package/lib/provider/account/EthLedgerAccount/EthLedgerAccount.js +1 -1
  24. package/lib/provider/account/NeoLedgerAccount/N3Ledger/ErrorCode.js +1 -1
  25. package/lib/provider/account/NeoLedgerAccount/N3Ledger/main.js +8 -8
  26. package/lib/provider/account/NeoLedgerAccount/NeoLedgerAccount.js +3 -3
  27. package/lib/provider/account/NeoLedgerAccount/NeonLedger.js +1 -1
  28. package/lib/provider/amino/types/admin.js +28 -28
  29. package/lib/provider/amino/types/bank.js +1 -1
  30. package/lib/provider/amino/types/broker.js +1 -1
  31. package/lib/provider/amino/types/cdp.js +22 -22
  32. package/lib/provider/amino/types/coin.js +4 -4
  33. package/lib/provider/amino/types/gov.js +4 -12
  34. package/lib/provider/amino/types/ibc.js +1 -1
  35. package/lib/provider/amino/types/leverage.js +1 -1
  36. package/lib/provider/amino/types/liquidityPool.js +7 -9
  37. package/lib/provider/amino/types/market.js +1 -1
  38. package/lib/provider/amino/types/oracle.js +1 -1
  39. package/lib/provider/amino/types/order.js +4 -4
  40. package/lib/provider/amino/types/position.js +1 -1
  41. package/lib/provider/amino/types/profile.js +1 -1
  42. package/lib/provider/amino/types/staking.js +4 -4
  43. package/lib/provider/amino/types/subaccount.js +3 -3
  44. package/lib/provider/amino/utils.js +11 -11
  45. package/lib/provider/ledger/ledger.js +2 -2
  46. package/lib/provider/metamask/MetaMask.js +1 -1
  47. package/lib/provider/o3/O3Wallet.js +2 -2
  48. package/lib/util/address.js +13 -13
  49. package/lib/util/api.js +4 -4
  50. package/lib/util/fetch.js +1 -1
  51. package/lib/util/generic.js +3 -3
  52. package/lib/util/number.js +5 -5
  53. package/lib/wallet/CarbonSigner.js +2 -2
  54. package/lib/wallet/CarbonSigningClient.js +8 -8
  55. package/lib/wallet/CarbonWallet.js +6 -6
  56. package/lib/websocket/connector.js +3 -3
  57. package/lib/websocket/models.d.ts +7 -2
  58. package/package.json +1 -1
@@ -87,7 +87,7 @@ class CarbonSigningClient extends stargate_1.StargateClient {
87
87
  */
88
88
  sign(signerAddress, messages, fee, memo, signerData) {
89
89
  return __awaiter(this, void 0, void 0, function* () {
90
- return (0, proto_signing_1.isOfflineDirectSigner)(this.signer)
90
+ return proto_signing_1.isOfflineDirectSigner(this.signer)
91
91
  ? this.signDirect(signerAddress, messages, fee, memo, signerData)
92
92
  : this.signAmino(signerAddress, messages, fee, memo, signerData);
93
93
  });
@@ -99,7 +99,7 @@ class CarbonSigningClient extends stargate_1.StargateClient {
99
99
  if (!accountFromSigner) {
100
100
  throw new Error("Failed to retrieve account from signer");
101
101
  }
102
- const pubkey = (0, proto_signing_1.encodePubkey)((0, amino_1.encodeSecp256k1Pubkey)(accountFromSigner.pubkey));
102
+ const pubkey = proto_signing_1.encodePubkey(amino_1.encodeSecp256k1Pubkey(accountFromSigner.pubkey));
103
103
  const txBodyEncodeObject = {
104
104
  typeUrl: "/cosmos.tx.v1beta1.TxBody",
105
105
  value: Object.assign({ messages: messages, memo: memo }, (timeoutHeight && {
@@ -108,13 +108,13 @@ class CarbonSigningClient extends stargate_1.StargateClient {
108
108
  };
109
109
  const txBodyBytes = this.registry.encode(txBodyEncodeObject);
110
110
  const gasLimit = math_1.Int53.fromString(fee.gas).toNumber();
111
- const authInfoBytes = (0, proto_signing_1.makeAuthInfoBytes)([{ pubkey, sequence }], fee.amount, gasLimit);
112
- const signDoc = (0, proto_signing_1.makeSignDoc)(txBodyBytes, authInfoBytes, chainId, accountNumber);
111
+ const authInfoBytes = proto_signing_1.makeAuthInfoBytes([{ pubkey, sequence }], fee.amount, gasLimit);
112
+ const signDoc = proto_signing_1.makeSignDoc(txBodyBytes, authInfoBytes, chainId, accountNumber);
113
113
  const { signature, signed } = yield signer.signDirect(signerAddress, signDoc);
114
114
  return tx_1.TxRaw.fromPartial({
115
115
  bodyBytes: signed.bodyBytes,
116
116
  authInfoBytes: signed.authInfoBytes,
117
- signatures: [(0, encoding_1.fromBase64)(signature.signature)],
117
+ signatures: [encoding_1.fromBase64(signature.signature)],
118
118
  });
119
119
  });
120
120
  }
@@ -125,7 +125,7 @@ class CarbonSigningClient extends stargate_1.StargateClient {
125
125
  if (!accountFromSigner) {
126
126
  throw new Error("Failed to retrieve account from signer");
127
127
  }
128
- const pubkey = (0, proto_signing_1.encodePubkey)((0, amino_1.encodeSecp256k1Pubkey)(accountFromSigner.pubkey));
128
+ const pubkey = proto_signing_1.encodePubkey(amino_1.encodeSecp256k1Pubkey(accountFromSigner.pubkey));
129
129
  const signMode = SignMode.SIGN_MODE_LEGACY_AMINO_JSON;
130
130
  const msgs = messages.map((msg) => this.aminoTypes.toAmino(msg));
131
131
  const signDoc = makeSignDocAmino(msgs, fee, chainId, memo, accountNumber, sequence, timeoutHeight !== null && timeoutHeight !== void 0 ? timeoutHeight : 0);
@@ -140,11 +140,11 @@ class CarbonSigningClient extends stargate_1.StargateClient {
140
140
  const signedTxBodyBytes = this.registry.encode(signedTxBodyEncodeObject);
141
141
  const signedGasLimit = math_1.Int53.fromString(signed.fee.gas).toNumber();
142
142
  const signedSequence = math_1.Int53.fromString(signed.sequence).toNumber();
143
- const signedAuthInfoBytes = (0, proto_signing_1.makeAuthInfoBytes)([{ pubkey, sequence: signedSequence }], signed.fee.amount, signedGasLimit, signMode);
143
+ const signedAuthInfoBytes = proto_signing_1.makeAuthInfoBytes([{ pubkey, sequence: signedSequence }], signed.fee.amount, signedGasLimit, signMode);
144
144
  return tx_1.TxRaw.fromPartial({
145
145
  bodyBytes: signedTxBodyBytes,
146
146
  authInfoBytes: signedAuthInfoBytes,
147
- signatures: [(0, encoding_1.fromBase64)(signature.signature)],
147
+ signatures: [encoding_1.fromBase64(signature.signature)],
148
148
  });
149
149
  });
150
150
  }
@@ -150,7 +150,7 @@ class CarbonWallet {
150
150
  const signerData = Object.assign({ accountNumber: this.accountInfo.accountNumber, chainId: this.getChainId(), sequence }, explicitSignerData);
151
151
  const fee = (_a = opts === null || opts === void 0 ? void 0 : opts.fee) !== null && _a !== void 0 ? _a : this.estimateTxFee(messages, feeDenom);
152
152
  const txRaw = yield signingClient.sign(signerAddress, messages, fee, memo, signerData);
153
- signature = (0, amino_1.encodeSecp256k1Signature)(account.pubkey, txRaw.signatures[0]);
153
+ signature = amino_1.encodeSecp256k1Signature(account.pubkey, txRaw.signatures[0]);
154
154
  return txRaw;
155
155
  }
156
156
  finally {
@@ -168,7 +168,7 @@ class CarbonWallet {
168
168
  const tx = CarbonWallet.TxRaw.encode(txRaw).finish();
169
169
  const carbonClient = this.getSigningClient();
170
170
  const response = yield carbonClient.broadcastTx(tx, timeoutMs, pollIntervalMs);
171
- if ((0, stargate_1.isDeliverTxFailure)(response)) {
171
+ if (stargate_1.isDeliverTxFailure(response)) {
172
172
  // tx failed
173
173
  throw new tx_1.CarbonTxError(`[${response.code}] ${response.rawLog}`, response);
174
174
  }
@@ -207,9 +207,9 @@ class CarbonWallet {
207
207
  try {
208
208
  if (!this.accountInfo || this.sequenceInvalidated)
209
209
  yield this.reloadAccountSequence();
210
- const heightResponse = yield (0, fetch_1.fetch)(`${this.networkConfig.tmRpcUrl}/blockchain?cache=${new Date().getTime()}`);
210
+ const heightResponse = yield fetch_1.fetch(`${this.networkConfig.tmRpcUrl}/blockchain?cache=${new Date().getTime()}`);
211
211
  const heightRes = yield heightResponse.json();
212
- const height = (0, number_1.bnOrZero)((_a = heightRes.result) === null || _a === void 0 ? void 0 : _a.last_height);
212
+ const height = number_1.bnOrZero((_a = heightRes.result) === null || _a === void 0 ? void 0 : _a.last_height);
213
213
  const timeoutHeight = height.isZero() ? undefined : height.toNumber() + this.defaultTimeoutBlocks;
214
214
  const sequence = this.accountInfo.sequence;
215
215
  this.accountInfo = Object.assign(Object.assign({}, this.accountInfo), { sequence: sequence + 1 });
@@ -343,12 +343,12 @@ class CarbonWallet {
343
343
  const queryClient = this.getQueryClient();
344
344
  const { msgGasCosts } = yield queryClient.fee.MsgGasCostAll({});
345
345
  this.txGasCosts = msgGasCosts.reduce((result, item) => {
346
- result[item.msgType] = (0, number_1.bnOrZero)(item.gasCost);
346
+ result[item.msgType] = number_1.bnOrZero(item.gasCost);
347
347
  return result;
348
348
  }, {});
349
349
  const { minGasPrices } = yield queryClient.fee.MinGasPriceAll({});
350
350
  this.txGasPrices = minGasPrices.reduce((result, item) => {
351
- result[item.denom] = (0, number_1.bnOrZero)(item.gasPrice).shiftedBy(-18); // sdk.Dec shifting
351
+ result[item.denom] = number_1.bnOrZero(item.gasPrice).shiftedBy(-18); // sdk.Dec shifting
352
352
  return result;
353
353
  }, {});
354
354
  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 = (0, channel_1.generateChannelId)(param);
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 = (0, channel_1.generateChannelId)(param);
196
+ const channelId = channel_1.generateChannelId(param);
197
197
  const shouldUnsubscribe = this.channelHandlers[channelId] !== undefined;
198
198
  delete this.channelHandlers[channelId];
199
199
  if (shouldUnsubscribe) {
@@ -283,7 +283,7 @@ class WSConnector {
283
283
  if (!channelHandler) {
284
284
  this.debugLog(`handler not found for channel: ${message.channel}`);
285
285
  try {
286
- const params = (0, channel_1.parseChannelId)(message.channel);
286
+ const params = channel_1.parseChannelId(message.channel);
287
287
  this.unsubscribe({ channel: params.channel });
288
288
  }
289
289
  catch (error) {
@@ -139,12 +139,17 @@ export interface Pool {
139
139
  amount_b: string;
140
140
  weight_b: string;
141
141
  swap_fee: string;
142
- num_quotes: number;
143
142
  shares_amount: string;
144
- market: string;
145
143
  amp_bps: string;
146
144
  v_amount_a: string;
147
145
  v_amount_b: string;
146
+ /**
147
+ * @deprecated num_quotes and market fields have been removed in websocket data
148
+ * Use Pool Routes API to retrieve numQuotes value for market, as well as the attached pool ids
149
+ * i.e. sdk.query.liquiditypool.PoolRoutesAll({})
150
+ **/
151
+ num_quotes?: number;
152
+ market?: string;
148
153
  };
149
154
  rewards_weight: string;
150
155
  total_commitment: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-js-sdk",
3
- "version": "0.3.43-dev.1+e82d83211042",
3
+ "version": "0.3.43-dev.3+ca215dbc9f75",
4
4
  "description": "TypeScript SDK for Carbon blockchain",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",