injectivejs 1.9.12 → 1.9.14

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 (41) hide show
  1. package/README.md +26 -22
  2. package/cosmos/base/v1beta1/coin.js +5 -4
  3. package/cosmos/distribution/v1beta1/distribution.js +11 -10
  4. package/cosmos/gov/v1beta1/gov.js +3 -2
  5. package/cosmos/staking/v1beta1/staking.js +15 -14
  6. package/cosmos/staking/v1beta1/tx.js +3 -2
  7. package/decimals.d.ts +20 -0
  8. package/decimals.js +102 -0
  9. package/esm/cosmos/base/v1beta1/coin.js +5 -4
  10. package/esm/cosmos/distribution/v1beta1/distribution.js +11 -10
  11. package/esm/cosmos/gov/v1beta1/gov.js +3 -2
  12. package/esm/cosmos/staking/v1beta1/staking.js +15 -14
  13. package/esm/cosmos/staking/v1beta1/tx.js +3 -2
  14. package/esm/decimals.js +98 -0
  15. package/esm/injective/auction/v1beta1/auction.js +3 -2
  16. package/esm/injective/exchange/v1beta1/events.js +13 -12
  17. package/esm/injective/exchange/v1beta1/exchange.js +183 -182
  18. package/esm/injective/exchange/v1beta1/genesis.js +5 -4
  19. package/esm/injective/exchange/v1beta1/proposal.js +99 -98
  20. package/esm/injective/exchange/v1beta1/query.js +89 -88
  21. package/esm/injective/exchange/v1beta1/tx.js +81 -80
  22. package/esm/injective/ocr/v1beta1/ocr.js +17 -16
  23. package/esm/injective/oracle/v1beta1/events.js +13 -12
  24. package/esm/injective/oracle/v1beta1/oracle.js +31 -30
  25. package/esm/injective/oracle/v1beta1/query.js +13 -12
  26. package/esm/injective/oracle/v1beta1/tx.js +5 -4
  27. package/esm/injective/stream/v1beta1/query.js +21 -20
  28. package/injective/auction/v1beta1/auction.js +3 -2
  29. package/injective/exchange/v1beta1/events.js +13 -12
  30. package/injective/exchange/v1beta1/exchange.js +183 -182
  31. package/injective/exchange/v1beta1/genesis.js +5 -4
  32. package/injective/exchange/v1beta1/proposal.js +99 -98
  33. package/injective/exchange/v1beta1/query.js +89 -88
  34. package/injective/exchange/v1beta1/tx.js +81 -80
  35. package/injective/ocr/v1beta1/ocr.js +17 -16
  36. package/injective/oracle/v1beta1/events.js +13 -12
  37. package/injective/oracle/v1beta1/oracle.js +31 -30
  38. package/injective/oracle/v1beta1/query.js +13 -12
  39. package/injective/oracle/v1beta1/tx.js +5 -4
  40. package/injective/stream/v1beta1/query.js +21 -20
  41. package/package.json +8 -8
@@ -12,6 +12,7 @@ import { BlacklistEthereumAddressesProposal, RevokeEthereumBlacklistProposal } f
12
12
  import { ContractRegistrationRequestProposal, BatchContractRegistrationRequestProposal, BatchContractDeregistrationProposal, ContractRegistrationRequest, BatchStoreCodeProposal } from "../../../injective/wasmx/v1/proposal";
13
13
  import { isSet, toTimestamp, fromTimestamp, bytesFromBase64, base64FromBytes } from "../../../helpers";
14
14
  import { BinaryReader, BinaryWriter } from "../../../binary";
15
+ import { Decimal } from "../../../decimals";
15
16
  import { GlobalDecoderRegistry } from "../../../registry";
16
17
  /** VoteOption enumerates the valid vote options for a given governance proposal. */
17
18
  export var VoteOption;
@@ -167,7 +168,7 @@ export const WeightedVoteOption = {
167
168
  writer.uint32(8).int32(message.option);
168
169
  }
169
170
  if (message.weight !== "") {
170
- writer.uint32(18).string(message.weight);
171
+ writer.uint32(18).string(Decimal.fromUserInput(message.weight, 18).atomics);
171
172
  }
172
173
  return writer;
173
174
  },
@@ -182,7 +183,7 @@ export const WeightedVoteOption = {
182
183
  message.option = reader.int32();
183
184
  break;
184
185
  case 2:
185
- message.weight = reader.string();
186
+ message.weight = Decimal.fromAtomics(reader.string(), 18).toString();
186
187
  break;
187
188
  default:
188
189
  reader.skipType(tag & 7);
@@ -7,6 +7,7 @@ import { ValidatorUpdate } from "../../../tendermint/abci/types";
7
7
  import { BinaryReader, BinaryWriter } from "../../../binary";
8
8
  import { GlobalDecoderRegistry } from "../../../registry";
9
9
  import { toTimestamp, fromTimestamp, isSet } from "../../../helpers";
10
+ import { Decimal } from "../../../decimals";
10
11
  import { encodePubkey, decodePubkey } from "@interchainjs/pubkey";
11
12
  /** BondStatus is the status of a validator. */
12
13
  export var BondStatus;
@@ -212,13 +213,13 @@ export const CommissionRates = {
212
213
  },
213
214
  encode(message, writer = BinaryWriter.create()) {
214
215
  if (message.rate !== "") {
215
- writer.uint32(10).string(message.rate);
216
+ writer.uint32(10).string(Decimal.fromUserInput(message.rate, 18).atomics);
216
217
  }
217
218
  if (message.maxRate !== "") {
218
- writer.uint32(18).string(message.maxRate);
219
+ writer.uint32(18).string(Decimal.fromUserInput(message.maxRate, 18).atomics);
219
220
  }
220
221
  if (message.maxChangeRate !== "") {
221
- writer.uint32(26).string(message.maxChangeRate);
222
+ writer.uint32(26).string(Decimal.fromUserInput(message.maxChangeRate, 18).atomics);
222
223
  }
223
224
  return writer;
224
225
  },
@@ -230,13 +231,13 @@ export const CommissionRates = {
230
231
  const tag = reader.uint32();
231
232
  switch (tag >>> 3) {
232
233
  case 1:
233
- message.rate = reader.string();
234
+ message.rate = Decimal.fromAtomics(reader.string(), 18).toString();
234
235
  break;
235
236
  case 2:
236
- message.maxRate = reader.string();
237
+ message.maxRate = Decimal.fromAtomics(reader.string(), 18).toString();
237
238
  break;
238
239
  case 3:
239
- message.maxChangeRate = reader.string();
240
+ message.maxChangeRate = Decimal.fromAtomics(reader.string(), 18).toString();
240
241
  break;
241
242
  default:
242
243
  reader.skipType(tag & 7);
@@ -554,7 +555,7 @@ export const Validator = {
554
555
  writer.uint32(42).string(message.tokens);
555
556
  }
556
557
  if (message.delegatorShares !== "") {
557
- writer.uint32(50).string(message.delegatorShares);
558
+ writer.uint32(50).string(Decimal.fromUserInput(message.delegatorShares, 18).atomics);
558
559
  }
559
560
  if (message.description !== undefined) {
560
561
  Description.encode(message.description, writer.uint32(58).fork()).ldelim();
@@ -604,7 +605,7 @@ export const Validator = {
604
605
  message.tokens = reader.string();
605
606
  break;
606
607
  case 6:
607
- message.delegatorShares = reader.string();
608
+ message.delegatorShares = Decimal.fromAtomics(reader.string(), 18).toString();
608
609
  break;
609
610
  case 7:
610
611
  message.description = Description.decode(reader, reader.uint32());
@@ -1206,7 +1207,7 @@ export const Delegation = {
1206
1207
  writer.uint32(18).string(message.validatorAddress);
1207
1208
  }
1208
1209
  if (message.shares !== "") {
1209
- writer.uint32(26).string(message.shares);
1210
+ writer.uint32(26).string(Decimal.fromUserInput(message.shares, 18).atomics);
1210
1211
  }
1211
1212
  return writer;
1212
1213
  },
@@ -1224,7 +1225,7 @@ export const Delegation = {
1224
1225
  message.validatorAddress = reader.string();
1225
1226
  break;
1226
1227
  case 3:
1227
- message.shares = reader.string();
1228
+ message.shares = Decimal.fromAtomics(reader.string(), 18).toString();
1228
1229
  break;
1229
1230
  default:
1230
1231
  reader.skipType(tag & 7);
@@ -1556,7 +1557,7 @@ export const RedelegationEntry = {
1556
1557
  writer.uint32(26).string(message.initialBalance);
1557
1558
  }
1558
1559
  if (message.sharesDst !== "") {
1559
- writer.uint32(34).string(message.sharesDst);
1560
+ writer.uint32(34).string(Decimal.fromUserInput(message.sharesDst, 18).atomics);
1560
1561
  }
1561
1562
  if (message.unbondingId !== BigInt(0)) {
1562
1563
  writer.uint32(40).uint64(message.unbondingId);
@@ -1583,7 +1584,7 @@ export const RedelegationEntry = {
1583
1584
  message.initialBalance = reader.string();
1584
1585
  break;
1585
1586
  case 4:
1586
- message.sharesDst = reader.string();
1587
+ message.sharesDst = Decimal.fromAtomics(reader.string(), 18).toString();
1587
1588
  break;
1588
1589
  case 5:
1589
1590
  message.unbondingId = reader.uint64();
@@ -1817,7 +1818,7 @@ export const Params = {
1817
1818
  writer.uint32(42).string(message.bondDenom);
1818
1819
  }
1819
1820
  if (message.minCommissionRate !== "") {
1820
- writer.uint32(50).string(message.minCommissionRate);
1821
+ writer.uint32(50).string(Decimal.fromUserInput(message.minCommissionRate, 18).atomics);
1821
1822
  }
1822
1823
  return writer;
1823
1824
  },
@@ -1844,7 +1845,7 @@ export const Params = {
1844
1845
  message.bondDenom = reader.string();
1845
1846
  break;
1846
1847
  case 6:
1847
- message.minCommissionRate = reader.string();
1848
+ message.minCommissionRate = Decimal.fromAtomics(reader.string(), 18).toString();
1848
1849
  break;
1849
1850
  default:
1850
1851
  reader.skipType(tag & 7);
@@ -6,6 +6,7 @@ import { BinaryReader, BinaryWriter } from "../../../binary";
6
6
  import { GlobalDecoderRegistry } from "../../../registry";
7
7
  import { toTimestamp, fromTimestamp } from "../../../helpers";
8
8
  import { encodePubkey, decodePubkey } from "@interchainjs/pubkey";
9
+ import { Decimal } from "../../../decimals";
9
10
  function createBaseMsgCreateValidator() {
10
11
  return {
11
12
  description: Description.fromPartial({}),
@@ -246,7 +247,7 @@ export const MsgEditValidator = {
246
247
  writer.uint32(18).string(message.validatorAddress);
247
248
  }
248
249
  if (message.commissionRate !== "") {
249
- writer.uint32(26).string(message.commissionRate);
250
+ writer.uint32(26).string(Decimal.fromUserInput(message.commissionRate, 18).atomics);
250
251
  }
251
252
  if (message.minSelfDelegation !== "") {
252
253
  writer.uint32(34).string(message.minSelfDelegation);
@@ -267,7 +268,7 @@ export const MsgEditValidator = {
267
268
  message.validatorAddress = reader.string();
268
269
  break;
269
270
  case 3:
270
- message.commissionRate = reader.string();
271
+ message.commissionRate = Decimal.fromAtomics(reader.string(), 18).toString();
271
272
  break;
272
273
  case 4:
273
274
  message.minSelfDelegation = reader.string();
@@ -0,0 +1,98 @@
1
+ /**
2
+ * This file and any referenced files were automatically generated by @cosmology/telescope@1.11.20
3
+ * DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
4
+ * and run the transpile command or npm scripts command that is used to regenerate this bundle.
5
+ */
6
+ // The largest value we need is 18 (Ether).
7
+ const maxFractionalDigits = 30;
8
+ /**
9
+ * A type for arbitrary precision, non-negative decimals.
10
+ *
11
+ * Instances of this class are immutable.
12
+ */
13
+ export class Decimal {
14
+ static fromUserInput(input, fractionalDigits) {
15
+ Decimal.verifyFractionalDigits(fractionalDigits);
16
+ const badCharacter = input.match(/[^0-9.]/);
17
+ if (badCharacter) {
18
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
19
+ throw new Error(`Invalid character at position ${badCharacter.index + 1}`);
20
+ }
21
+ let whole;
22
+ let fractional;
23
+ if (input === "") {
24
+ whole = "0";
25
+ fractional = "";
26
+ }
27
+ else if (input.search(/\./) === -1) {
28
+ // integer format, no separator
29
+ whole = input;
30
+ fractional = "";
31
+ }
32
+ else {
33
+ const parts = input.split(".");
34
+ switch (parts.length) {
35
+ case 0:
36
+ case 1:
37
+ throw new Error("Fewer than two elements in split result. This must not happen here.");
38
+ case 2:
39
+ if (!parts[1])
40
+ throw new Error("Fractional part missing");
41
+ whole = parts[0];
42
+ fractional = parts[1].replace(/0+$/, "");
43
+ break;
44
+ default:
45
+ throw new Error("More than one separator found");
46
+ }
47
+ }
48
+ if (fractional.length > fractionalDigits) {
49
+ throw new Error("Got more fractional digits than supported");
50
+ }
51
+ const quantity = `${whole}${fractional.padEnd(fractionalDigits, "0")}`;
52
+ return new Decimal(quantity, fractionalDigits);
53
+ }
54
+ static fromAtomics(atomics, fractionalDigits) {
55
+ Decimal.verifyFractionalDigits(fractionalDigits);
56
+ return new Decimal(atomics, fractionalDigits);
57
+ }
58
+ static verifyFractionalDigits(fractionalDigits) {
59
+ if (!Number.isInteger(fractionalDigits))
60
+ throw new Error("Fractional digits is not an integer");
61
+ if (fractionalDigits < 0)
62
+ throw new Error("Fractional digits must not be negative");
63
+ if (fractionalDigits > maxFractionalDigits) {
64
+ throw new Error(`Fractional digits must not exceed ${maxFractionalDigits}`);
65
+ }
66
+ }
67
+ get atomics() {
68
+ return this.data.atomics.toString();
69
+ }
70
+ get fractionalDigits() {
71
+ return this.data.fractionalDigits;
72
+ }
73
+ data;
74
+ constructor(atomics, fractionalDigits) {
75
+ if (!atomics.match(/^[0-9]+$/)) {
76
+ throw new Error("Invalid string format. Only non-negative integers in decimal representation supported.");
77
+ }
78
+ this.data = {
79
+ atomics: BigInt(atomics),
80
+ fractionalDigits: fractionalDigits,
81
+ };
82
+ }
83
+ toString() {
84
+ const factor = BigInt(10) ** BigInt(this.data.fractionalDigits);
85
+ const whole = this.data.atomics / factor;
86
+ const fractional = this.data.atomics % factor;
87
+ if (fractional === 0n) {
88
+ return whole.toString();
89
+ }
90
+ else {
91
+ const fullFractionalPart = fractional
92
+ .toString()
93
+ .padStart(this.data.fractionalDigits, "0");
94
+ const trimmedFractionalPart = fullFractionalPart.replace(/0+$/, "");
95
+ return `${whole.toString()}.${trimmedFractionalPart}`;
96
+ }
97
+ }
98
+ }
@@ -1,5 +1,6 @@
1
1
  import { Coin } from "../../../cosmos/base/v1beta1/coin";
2
2
  import { BinaryReader, BinaryWriter } from "../../../binary";
3
+ import { Decimal } from "../../../decimals";
3
4
  function createBaseParams() {
4
5
  return {
5
6
  auctionPeriod: BigInt(0),
@@ -20,7 +21,7 @@ export const Params = {
20
21
  writer.uint32(8).int64(message.auctionPeriod);
21
22
  }
22
23
  if (message.minNextBidIncrementRate !== "") {
23
- writer.uint32(18).string(message.minNextBidIncrementRate);
24
+ writer.uint32(18).string(Decimal.fromUserInput(message.minNextBidIncrementRate, 18).atomics);
24
25
  }
25
26
  return writer;
26
27
  },
@@ -35,7 +36,7 @@ export const Params = {
35
36
  message.auctionPeriod = reader.int64();
36
37
  break;
37
38
  case 2:
38
- message.minNextBidIncrementRate = reader.string();
39
+ message.minNextBidIncrementRate = Decimal.fromAtomics(reader.string(), 18).toString();
39
40
  break;
40
41
  default:
41
42
  reader.skipType(tag & 7);
@@ -2,6 +2,7 @@ import { TradeLog, DerivativeTradeLog, SubaccountPosition, BinaryOptionsMarket,
2
2
  import { Coin } from "../../../cosmos/base/v1beta1/coin";
3
3
  import { isSet, bytesFromBase64, base64FromBytes } from "../../../helpers";
4
4
  import { BinaryReader, BinaryWriter } from "../../../binary";
5
+ import { Decimal } from "../../../decimals";
5
6
  function createBaseEventBatchSpotExecution() {
6
7
  return {
7
8
  marketId: "",
@@ -142,7 +143,7 @@ export const EventBatchDerivativeExecution = {
142
143
  writer.uint32(24).bool(message.isLiquidation);
143
144
  }
144
145
  if (message.cumulativeFunding !== undefined) {
145
- writer.uint32(34).string(message.cumulativeFunding);
146
+ writer.uint32(34).string(Decimal.fromUserInput(message.cumulativeFunding, 18).atomics);
146
147
  }
147
148
  if (message.executionType !== 0) {
148
149
  writer.uint32(40).int32(message.executionType);
@@ -169,7 +170,7 @@ export const EventBatchDerivativeExecution = {
169
170
  message.isLiquidation = reader.bool();
170
171
  break;
171
172
  case 4:
172
- message.cumulativeFunding = reader.string();
173
+ message.cumulativeFunding = Decimal.fromAtomics(reader.string(), 18).toString();
173
174
  break;
174
175
  case 5:
175
176
  message.executionType = reader.int32();
@@ -272,10 +273,10 @@ export const EventLostFundsFromLiquidation = {
272
273
  writer.uint32(18).bytes(message.subaccountId);
273
274
  }
274
275
  if (message.lostFundsFromAvailableDuringPayout !== "") {
275
- writer.uint32(26).string(message.lostFundsFromAvailableDuringPayout);
276
+ writer.uint32(26).string(Decimal.fromUserInput(message.lostFundsFromAvailableDuringPayout, 18).atomics);
276
277
  }
277
278
  if (message.lostFundsFromOrderCancels !== "") {
278
- writer.uint32(34).string(message.lostFundsFromOrderCancels);
279
+ writer.uint32(34).string(Decimal.fromUserInput(message.lostFundsFromOrderCancels, 18).atomics);
279
280
  }
280
281
  return writer;
281
282
  },
@@ -293,10 +294,10 @@ export const EventLostFundsFromLiquidation = {
293
294
  message.subaccountId = reader.bytes();
294
295
  break;
295
296
  case 3:
296
- message.lostFundsFromAvailableDuringPayout = reader.string();
297
+ message.lostFundsFromAvailableDuringPayout = Decimal.fromAtomics(reader.string(), 18).toString();
297
298
  break;
298
299
  case 4:
299
- message.lostFundsFromOrderCancels = reader.string();
300
+ message.lostFundsFromOrderCancels = Decimal.fromAtomics(reader.string(), 18).toString();
300
301
  break;
301
302
  default:
302
303
  reader.skipType(tag & 7);
@@ -1378,10 +1379,10 @@ export const EventPerpetualMarketFundingUpdate = {
1378
1379
  writer.uint32(24).bool(message.isHourlyFunding);
1379
1380
  }
1380
1381
  if (message.fundingRate !== undefined) {
1381
- writer.uint32(34).string(message.fundingRate);
1382
+ writer.uint32(34).string(Decimal.fromUserInput(message.fundingRate, 18).atomics);
1382
1383
  }
1383
1384
  if (message.markPrice !== undefined) {
1384
- writer.uint32(42).string(message.markPrice);
1385
+ writer.uint32(42).string(Decimal.fromUserInput(message.markPrice, 18).atomics);
1385
1386
  }
1386
1387
  return writer;
1387
1388
  },
@@ -1402,10 +1403,10 @@ export const EventPerpetualMarketFundingUpdate = {
1402
1403
  message.isHourlyFunding = reader.bool();
1403
1404
  break;
1404
1405
  case 4:
1405
- message.fundingRate = reader.string();
1406
+ message.fundingRate = Decimal.fromAtomics(reader.string(), 18).toString();
1406
1407
  break;
1407
1408
  case 5:
1408
- message.markPrice = reader.string();
1409
+ message.markPrice = Decimal.fromAtomics(reader.string(), 18).toString();
1409
1410
  break;
1410
1411
  default:
1411
1412
  reader.skipType(tag & 7);
@@ -1852,7 +1853,7 @@ export const DerivativeMarketOrderCancel = {
1852
1853
  DerivativeMarketOrder.encode(message.marketOrder, writer.uint32(10).fork()).ldelim();
1853
1854
  }
1854
1855
  if (message.cancelQuantity !== "") {
1855
- writer.uint32(18).string(message.cancelQuantity);
1856
+ writer.uint32(18).string(Decimal.fromUserInput(message.cancelQuantity, 18).atomics);
1856
1857
  }
1857
1858
  return writer;
1858
1859
  },
@@ -1867,7 +1868,7 @@ export const DerivativeMarketOrderCancel = {
1867
1868
  message.marketOrder = DerivativeMarketOrder.decode(reader, reader.uint32());
1868
1869
  break;
1869
1870
  case 2:
1870
- message.cancelQuantity = reader.string();
1871
+ message.cancelQuantity = Decimal.fromAtomics(reader.string(), 18).toString();
1871
1872
  break;
1872
1873
  default:
1873
1874
  reader.skipType(tag & 7);