@dydxprotocol/v4-client-js 1.2.0 → 1.3.1

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 (134) hide show
  1. package/__native__/__ios__/v4-native-client.js +5656 -5599
  2. package/__tests__/helpers/constants.ts +12 -0
  3. package/__tests__/lib/validation.test.ts +49 -1
  4. package/build/__tests__/helpers/constants.d.ts +2 -1
  5. package/build/__tests__/helpers/constants.js +12 -2
  6. package/build/__tests__/lib/validation.test.js +36 -1
  7. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/cosmos/bundle.d.ts +158 -158
  8. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/cosmos/bundle.js +126 -126
  9. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/accountplus/accountplus.d.ts +35 -0
  10. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/accountplus/accountplus.js +127 -0
  11. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/accountplus/genesis.d.ts +16 -0
  12. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/accountplus/genesis.js +65 -0
  13. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/bundle.d.ts +2762 -1461
  14. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/bundle.js +290 -249
  15. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/clob/order.d.ts +2 -3
  16. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/clob/order.js +3 -4
  17. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/clob/order_removals.d.ts +5 -0
  18. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/clob/order_removals.js +11 -1
  19. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/clob/process_proposer_matches_events.d.ts +6 -0
  20. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/clob/process_proposer_matches_events.js +1 -1
  21. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/clob/query.d.ts +130 -6
  22. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/clob/query.js +252 -5
  23. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/clob/query.rpc.Query.d.ts +9 -2
  24. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/clob/query.rpc.Query.js +10 -1
  25. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/indexer/events/events.d.ts +202 -4
  26. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/indexer/events/events.js +329 -6
  27. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/indexer/off_chain_updates/off_chain_updates.d.ts +28 -0
  28. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/indexer/off_chain_updates/off_chain_updates.js +92 -7
  29. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/indexer/shared/removal_reason.d.ts +5 -0
  30. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/indexer/shared/removal_reason.js +11 -1
  31. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/indexer/socks/messages.d.ts +20 -0
  32. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/indexer/socks/messages.js +54 -2
  33. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/lcd.d.ts +2 -0
  34. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/lcd.js +7 -1
  35. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/listing/genesis.d.ts +19 -0
  36. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/listing/genesis.js +64 -0
  37. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/listing/query.d.ts +27 -0
  38. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/listing/query.js +90 -0
  39. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/listing/query.rpc.Query.d.ts +16 -0
  40. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/listing/query.rpc.Query.js +52 -0
  41. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/listing/tx.d.ts +35 -0
  42. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/listing/tx.js +98 -0
  43. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/listing/tx.rpc.msg.d.ts +12 -0
  44. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/listing/tx.rpc.msg.js +41 -0
  45. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/ratelimit/pending_send_packet.d.ts +24 -0
  46. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/ratelimit/pending_send_packet.js +73 -0
  47. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/ratelimit/query.d.ts +37 -0
  48. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/ratelimit/query.js +65 -2
  49. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/ratelimit/query.lcd.d.ts +2 -1
  50. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/ratelimit/query.lcd.js +7 -1
  51. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/ratelimit/query.rpc.Query.d.ts +5 -1
  52. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/ratelimit/query.rpc.Query.js +10 -1
  53. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/revshare/genesis.d.ts +16 -0
  54. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/revshare/genesis.js +64 -0
  55. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/revshare/params.d.ts +29 -0
  56. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/revshare/params.js +80 -0
  57. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/revshare/query.d.ts +55 -0
  58. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/revshare/query.js +162 -0
  59. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/revshare/query.lcd.d.ts +10 -0
  60. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/revshare/query.lcd.js +23 -0
  61. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/revshare/query.rpc.Query.d.ts +23 -0
  62. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/revshare/query.rpc.Query.js +61 -0
  63. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/revshare/revshare.d.ts +23 -0
  64. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/revshare/revshare.js +64 -0
  65. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/revshare/tx.d.ts +69 -0
  66. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/revshare/tx.js +178 -0
  67. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/revshare/tx.rpc.msg.d.ts +21 -0
  68. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/revshare/tx.rpc.msg.js +47 -0
  69. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/rpc.query.d.ts +17 -2
  70. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/rpc.query.js +3 -1
  71. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/rpc.tx.d.ts +2 -0
  72. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/rpc.tx.js +3 -1
  73. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/subaccounts/perpetual_position.d.ts +3 -0
  74. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/subaccounts/perpetual_position.js +11 -3
  75. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/subaccounts/query.d.ts +55 -4
  76. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/subaccounts/query.js +87 -5
  77. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/subaccounts/query.lcd.d.ts +3 -2
  78. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/subaccounts/query.lcd.js +9 -3
  79. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/subaccounts/query.rpc.Query.d.ts +8 -4
  80. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/subaccounts/query.rpc.Query.js +11 -2
  81. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/vault/genesis.d.ts +37 -2
  82. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/vault/genesis.js +104 -5
  83. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/vault/params.d.ts +96 -0
  84. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/vault/params.js +196 -0
  85. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/vault/query.d.ts +134 -1
  86. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/vault/query.js +395 -1
  87. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/vault/query.lcd.d.ts +12 -0
  88. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/vault/query.lcd.js +49 -0
  89. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/vault/query.rpc.Query.d.ts +19 -1
  90. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/vault/query.rpc.Query.js +66 -2
  91. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/vault/share.d.ts +31 -0
  92. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/vault/share.js +108 -0
  93. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/vault/tx.d.ts +84 -2
  94. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/vault/tx.js +151 -2
  95. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/vault/tx.rpc.msg.d.ts +7 -1
  96. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/vault/tx.rpc.msg.js +13 -1
  97. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/vault/vault.d.ts +0 -14
  98. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/dydxprotocol/vault/vault.js +2 -38
  99. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/gogoproto/bundle.js +2 -2
  100. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/google/bundle.d.ts +174 -174
  101. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/google/bundle.js +12 -12
  102. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/helpers.d.ts +4 -4
  103. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/tendermint/bundle.d.ts +365 -365
  104. package/build/node_modules/@dydxprotocol/v4-proto/src/codegen/tendermint/bundle.js +22 -22
  105. package/build/src/clients/composite-client.d.ts +2 -2
  106. package/build/src/clients/composite-client.js +10 -10
  107. package/build/src/clients/lib/cctpProto.d.ts +4 -4
  108. package/build/src/clients/modules/get.d.ts +1 -1
  109. package/build/src/clients/modules/get.js +3 -3
  110. package/build/src/clients/native.d.ts +1 -1
  111. package/build/src/clients/native.js +3 -3
  112. package/build/src/clients/types.d.ts +14 -7
  113. package/build/src/clients/types.js +1 -1
  114. package/build/src/clients/validator-client.js +4 -4
  115. package/build/src/index.d.ts +1 -0
  116. package/build/src/index.js +3 -2
  117. package/build/src/lib/validation.d.ts +6 -1
  118. package/build/src/lib/validation.js +23 -2
  119. package/build/src/types.d.ts +3 -2
  120. package/build/src/types.js +2 -1
  121. package/build/tsconfig.tsbuildinfo +1 -0
  122. package/package.json +3 -4
  123. package/src/clients/composite-client.ts +4 -0
  124. package/src/clients/modules/get.ts +2 -2
  125. package/src/clients/native.ts +2 -2
  126. package/src/clients/types.ts +5 -0
  127. package/src/index.ts +1 -0
  128. package/src/lib/validation.ts +42 -3
  129. package/src/types.ts +1 -0
  130. package/tsconfig.json +0 -1
  131. package/webpack.config.js +1 -0
  132. package/.telescope.json +0 -15
  133. package/src/codegen/helpers.ts +0 -241
  134. package/src/codegen/index.ts +0 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dydxprotocol/v4-client-js",
3
- "version": "1.2.0",
3
+ "version": "1.3.1",
4
4
  "description": "General client library for the new dYdX system (v4 decentralized)",
5
5
  "main": "build/src/index.js",
6
6
  "scripts": {
@@ -12,7 +12,6 @@
12
12
  "lint": "eslint --ext .ts,.js .",
13
13
  "prepublishOnly": "npm run compile",
14
14
  "start": "node build/src/index.js",
15
- "transpile": "rm -rf src/codegen && telescope transpile --protoDirs ./proto --outPath ./src/codegen --no-includeAminos --includeLCDClients --includeRPCClients",
16
15
  "test": "NODE_ENV=test jest --testPathIgnorePatterns=__tests__/modules/client/*",
17
16
  "test:watch": "npm test -- --watch",
18
17
  "test-integration": "NODE_ENV=test jest",
@@ -37,7 +36,7 @@
37
36
  "@cosmjs/stargate": "^0.32.1",
38
37
  "@cosmjs/tendermint-rpc": "^0.32.1",
39
38
  "@cosmjs/utils": "^0.32.1",
40
- "@dydxprotocol/v4-proto": "5.0.0-dev.0",
39
+ "@dydxprotocol/v4-proto": "6.0.1",
41
40
  "@osmonauts/lcd": "^0.6.0",
42
41
  "@scure/bip32": "^1.1.5",
43
42
  "@scure/bip39": "^1.1.1",
@@ -53,7 +52,6 @@
53
52
  },
54
53
  "devDependencies": {
55
54
  "@dydxprotocol/node-service-base-dev": "^0.2.6",
56
- "@osmonauts/telescope": "0.80.0",
57
55
  "@protobufs/cosmos": "^0.0.11",
58
56
  "@protobufs/gogoproto": "^0.0.10",
59
57
  "@types/ffi-napi": "^4.0.4",
@@ -77,6 +75,7 @@
77
75
  "stream-http": "^3.2.0",
78
76
  "ts-loader": "^9.4.2",
79
77
  "ts-proto": "^1.165.1",
78
+ "util": "^0.12.5",
80
79
  "webpack": "^5.77.0",
81
80
  "webpack-cli": "^5.0.1"
82
81
  }
@@ -714,6 +714,7 @@ async batchCancelShortTermOrdersWithMarketId(
714
714
  subaccount: SubaccountInfo,
715
715
  shortTermOrders: OrderBatchWithMarketId[],
716
716
  goodTilBlock: number,
717
+ broadcastMode?: BroadcastMode,
717
718
  ): Promise<BroadcastTxAsyncResponse | BroadcastTxSyncResponse | IndexedTx> {
718
719
  const orderBatches = await Promise.all(
719
720
  shortTermOrders.map(async ({ marketId, clobPairId, clientIds }) => ({
@@ -728,6 +729,7 @@ async batchCancelShortTermOrdersWithMarketId(
728
729
  subaccount,
729
730
  orderBatches,
730
731
  goodTilBlock,
732
+ broadcastMode
731
733
  );
732
734
  }
733
735
 
@@ -743,11 +745,13 @@ async batchCancelShortTermOrdersWithMarketId(
743
745
  subaccount: SubaccountInfo,
744
746
  shortTermOrders: OrderBatch[],
745
747
  goodTilBlock: number,
748
+ broadcastMode?: BroadcastMode,
746
749
  ): Promise<BroadcastTxAsyncResponse | BroadcastTxSyncResponse | IndexedTx> {
747
750
  return this.validatorClient.post.batchCancelShortTermOrders(
748
751
  subaccount,
749
752
  shortTermOrders,
750
753
  goodTilBlock,
754
+ broadcastMode,
751
755
  );
752
756
  }
753
757
 
@@ -491,9 +491,9 @@ export class Get {
491
491
  return GovV1Module.QueryProposalsResponse.decode(data);
492
492
  }
493
493
 
494
- async getWithdrawalAndTransferGatingStatus(): Promise<SubaccountsModule.QueryGetWithdrawalAndTransfersBlockedInfoResponse> {
494
+ async getWithdrawalAndTransferGatingStatus(perpetualId: number): Promise<SubaccountsModule.QueryGetWithdrawalAndTransfersBlockedInfoResponse> {
495
495
  const requestData = Uint8Array.from(
496
- SubaccountsModule.QueryGetWithdrawalAndTransfersBlockedInfoRequest.encode({}).finish(),
496
+ SubaccountsModule.QueryGetWithdrawalAndTransfersBlockedInfoRequest.encode({ perpetualId }).finish(),
497
497
  );
498
498
 
499
499
  const data = await this.sendQuery(
@@ -1211,14 +1211,14 @@ export async function getWithdrawalCapacityByDenom(payload: string): Promise<str
1211
1211
  }
1212
1212
  }
1213
1213
 
1214
- export async function getWithdrawalAndTransferGatingStatus(): Promise<string> {
1214
+ export async function getWithdrawalAndTransferGatingStatus(perpetualId: number): Promise<string> {
1215
1215
  try {
1216
1216
  const client = globalThis.client;
1217
1217
  if (client === undefined) {
1218
1218
  throw new UserError('client is not connected. Call connectClient() first');
1219
1219
  }
1220
1220
 
1221
- const response = await client.validatorClient.get.getWithdrawalAndTransferGatingStatus();
1221
+ const response = await client.validatorClient.get.getWithdrawalAndTransferGatingStatus(perpetualId);
1222
1222
  return encodeJson(response);
1223
1223
  } catch (error) {
1224
1224
  return wrappedError(error);
@@ -59,6 +59,11 @@ export interface IPlaceOrder extends IBasicOrder {
59
59
 
60
60
  export interface ICancelOrder extends IBasicOrder {}
61
61
 
62
+ export interface IBatchCancelOrder {
63
+ shortTermOrders: { clobPairId: number; clientIds: number[] }[];
64
+ goodTilBlock: number;
65
+ }
66
+
62
67
  // How long to wait and how often to check when calling Broadcast with
63
68
  // Method.BroadcastTxCommit
64
69
  export interface BroadcastOptions {
package/src/index.ts CHANGED
@@ -2,6 +2,7 @@
2
2
  export * from './types';
3
3
 
4
4
  // Utility functions.
5
+ export * as helpers from './lib/helpers';
5
6
  export * as utils from './lib/utils';
6
7
  export * as validation from './lib/validation';
7
8
  export * as onboarding from './lib/onboarding';
@@ -2,7 +2,13 @@ import { decode } from 'bech32';
2
2
  import Long from 'long';
3
3
 
4
4
  import { MAX_SUBACCOUNT_NUMBER, MAX_UINT_32 } from '../clients/constants';
5
- import { Transfer, OrderFlags, ICancelOrder, IPlaceOrder } from '../clients/types';
5
+ import {
6
+ Transfer,
7
+ OrderFlags,
8
+ ICancelOrder,
9
+ IPlaceOrder,
10
+ IBatchCancelOrder,
11
+ } from '../clients/types';
6
12
  import { UserError } from './errors';
7
13
 
8
14
  /**
@@ -77,6 +83,35 @@ export function validateCancelOrderMessage(
77
83
  return undefined;
78
84
  }
79
85
 
86
+ /**
87
+ * @describe validateBatchCancelOrderMessage validates that orders to batch cancel have fields that would be
88
+ * valid on-chain.
89
+ */
90
+ export function validateBatchCancelOrderMessage(
91
+ subaccountNumber: number,
92
+ orders: IBatchCancelOrder,
93
+ ): UserError | undefined {
94
+ for (const orderBatch of orders.shortTermOrders) {
95
+ for (const clientId of orderBatch.clientIds) {
96
+ if (!verifyNumberIsUint32(clientId)) {
97
+ return new UserError(`clientId: ${clientId} is not a valid uint32`);
98
+ }
99
+ }
100
+ }
101
+
102
+ if (!verifyGoodTilBlock(orders.goodTilBlock)) {
103
+ return new UserError(`goodTilBlock: ${orders.goodTilBlock} is not a valid uint32 or is 0`);
104
+ }
105
+
106
+ if (!verifySubaccountNumber(subaccountNumber)) {
107
+ return new UserError(
108
+ `subaccountNumber: ${subaccountNumber} cannot be < 0 or > ${MAX_SUBACCOUNT_NUMBER}`,
109
+ );
110
+ }
111
+
112
+ return undefined;
113
+ }
114
+
80
115
  /**
81
116
  * @describe validateTransferMessage validates that a transfer to place has fields that would be
82
117
  * valid on-chain.
@@ -84,12 +119,16 @@ export function validateCancelOrderMessage(
84
119
  export function validateTransferMessage(transfer: Transfer): UserError | undefined {
85
120
  if (!verifySubaccountNumber(transfer.sender!!.number || 0)) {
86
121
  return new UserError(
87
- `senderSubaccountNumber: ${transfer.sender!!.number || 0} cannot be < 0 or > ${MAX_SUBACCOUNT_NUMBER}`,
122
+ `senderSubaccountNumber: ${
123
+ transfer.sender!!.number || 0
124
+ } cannot be < 0 or > ${MAX_SUBACCOUNT_NUMBER}`,
88
125
  );
89
126
  }
90
127
  if (!verifySubaccountNumber(transfer.recipient!!.number || 0)) {
91
128
  return new UserError(
92
- `recipientSubaccountNumber: ${transfer.recipient!!.number || 0} cannot be < 0 or > ${MAX_SUBACCOUNT_NUMBER}`,
129
+ `recipientSubaccountNumber: ${
130
+ transfer.recipient!!.number || 0
131
+ } cannot be < 0 or > ${MAX_SUBACCOUNT_NUMBER}`,
93
132
  );
94
133
  }
95
134
  if (transfer.assetId !== 0) {
package/src/types.ts CHANGED
@@ -40,4 +40,5 @@ export interface Options {
40
40
 
41
41
  export enum ClobPairId {
42
42
  PERPETUAL_PAIR_BTC_USD = 0,
43
+ PERPETUAL_PAIR_ETH_USD = 1,
43
44
  }
package/tsconfig.json CHANGED
@@ -6,7 +6,6 @@
6
6
  "examples",
7
7
  "scripts",
8
8
  "src",
9
- "codegen.js",
10
9
  "node_modules/@dydxprotocol/v4-proto/**/**.ts"
11
10
  ],
12
11
  "compilerOptions": {
package/webpack.config.js CHANGED
@@ -31,6 +31,7 @@ module.exports = {
31
31
  http: require.resolve('stream-http'),
32
32
  path: require.resolve('path-browserify'),
33
33
  crypto: require.resolve('crypto-browserify'),
34
+ util: require.resolve('util'),
34
35
  },
35
36
  },
36
37
  plugins: [
package/.telescope.json DELETED
@@ -1,15 +0,0 @@
1
- {
2
- "protoDirs": ["./proto"],
3
- "outPath": "./src/codegen",
4
- "options": {
5
- "aminoEncoding": {
6
- "enabled": false
7
- },
8
- "lcdClients": {
9
- "enabled": true
10
- },
11
- "rpcClients": {
12
- "enabled": true
13
- }
14
- }
15
- }
@@ -1,241 +0,0 @@
1
- /**
2
- * This file and any referenced files were automatically generated by @osmonauts/telescope@0.80.0
3
- * DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
4
- * and run the transpile command or yarn proto command to regenerate this bundle.
5
- */
6
-
7
- import * as _m0 from 'protobufjs/minimal';
8
- import Long from 'long';
9
-
10
- // @ts-ignore
11
- if (_m0.util.Long !== Long) {
12
- _m0.util.Long = Long as any;
13
-
14
- _m0.configure();
15
- }
16
-
17
- export { Long };
18
-
19
- declare var self: any | undefined;
20
- declare var window: any | undefined;
21
- declare var global: any | undefined;
22
- var globalThis: any = (() => {
23
- if (typeof globalThis !== 'undefined') return globalThis;
24
- if (typeof self !== 'undefined') return self;
25
- if (typeof window !== 'undefined') return window;
26
- if (typeof global !== 'undefined') return global;
27
- throw 'Unable to locate global object';
28
- })();
29
-
30
- const atob: (b64: string) => string =
31
- globalThis.atob || ((b64) => globalThis.Buffer.from(b64, 'base64').toString('binary'));
32
-
33
- export function bytesFromBase64(b64: string): Uint8Array {
34
- const bin = atob(b64);
35
- const arr = new Uint8Array(bin.length);
36
- for (let i = 0; i < bin.length; ++i) {
37
- arr[i] = bin.charCodeAt(i);
38
- }
39
- return arr;
40
- }
41
-
42
- const btoa: (bin: string) => string =
43
- globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
44
-
45
- export function base64FromBytes(arr: Uint8Array): string {
46
- const bin: string[] = [];
47
- arr.forEach((byte) => {
48
- bin.push(String.fromCharCode(byte));
49
- });
50
- return btoa(bin.join(''));
51
- }
52
-
53
- export interface AminoHeight {
54
- readonly revision_number?: string;
55
- readonly revision_height?: string;
56
- }
57
-
58
- export function omitDefault<T extends string | number | Long>(input: T): T | undefined {
59
- if (typeof input === 'string') {
60
- return input === '' ? undefined : input;
61
- }
62
-
63
- if (typeof input === 'number') {
64
- return input === 0 ? undefined : input;
65
- }
66
-
67
- if (Long.isLong(input)) {
68
- return input.isZero() ? undefined : input;
69
- }
70
-
71
- throw new Error(`Got unsupported type ${typeof input}`);
72
- }
73
-
74
- interface Duration {
75
- /**
76
- * Signed seconds of the span of time. Must be from -315,576,000,000
77
- * to +315,576,000,000 inclusive. Note: these bounds are computed from:
78
- * 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
79
- */
80
- seconds: Long;
81
- /**
82
- * Signed fractions of a second at nanosecond resolution of the span
83
- * of time. Durations less than one second are represented with a 0
84
- * `seconds` field and a positive or negative `nanos` field. For durations
85
- * of one second or more, a non-zero value for the `nanos` field must be
86
- * of the same sign as the `seconds` field. Must be from -999,999,999
87
- * to +999,999,999 inclusive.
88
- */
89
-
90
- nanos: number;
91
- }
92
-
93
- export function toDuration(duration: string): Duration {
94
- return {
95
- seconds: Long.fromNumber(Math.floor(parseInt(duration) / 1000000000)),
96
- nanos: parseInt(duration) % 1000000000,
97
- };
98
- }
99
-
100
- export function fromDuration(duration: Duration): string {
101
- return (parseInt(duration.seconds.toString()) * 1000000000 + duration.nanos).toString();
102
- }
103
-
104
- export function isSet(value: any): boolean {
105
- return value !== null && value !== undefined;
106
- }
107
-
108
- export function isObject(value: any): boolean {
109
- return typeof value === 'object' && value !== null;
110
- }
111
-
112
- export interface PageRequest {
113
- key: Uint8Array;
114
- offset: Long;
115
- limit: Long;
116
- countTotal: boolean;
117
- reverse: boolean;
118
- }
119
-
120
- export interface PageRequestParams {
121
- 'pagination.key'?: string;
122
- 'pagination.offset'?: string;
123
- 'pagination.limit'?: string;
124
- 'pagination.count_total'?: boolean;
125
- 'pagination.reverse'?: boolean;
126
- }
127
-
128
- export interface Params {
129
- params: PageRequestParams;
130
- }
131
-
132
- export const setPaginationParams = (options: Params, pagination?: PageRequest) => {
133
- if (!pagination) {
134
- return options;
135
- }
136
-
137
- if (typeof pagination?.countTotal !== 'undefined') {
138
- options.params['pagination.count_total'] = pagination.countTotal;
139
- }
140
- if (typeof pagination?.key !== 'undefined') {
141
- // String to Uint8Array
142
- // let uint8arr = new Uint8Array(Buffer.from(data,'base64'));
143
-
144
- // Uint8Array to String
145
- options.params['pagination.key'] = Buffer.from(pagination.key).toString('base64');
146
- }
147
- if (typeof pagination?.limit !== 'undefined') {
148
- options.params['pagination.limit'] = pagination.limit.toString();
149
- }
150
- if (typeof pagination?.offset !== 'undefined') {
151
- options.params['pagination.offset'] = pagination.offset.toString();
152
- }
153
- if (typeof pagination?.reverse !== 'undefined') {
154
- options.params['pagination.reverse'] = pagination.reverse;
155
- }
156
-
157
- return options;
158
- };
159
-
160
- type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
161
-
162
- export type DeepPartial<T> = T extends Builtin
163
- ? T
164
- : T extends Long
165
- ? string | number | Long
166
- : T extends Array<infer U>
167
- ? Array<DeepPartial<U>>
168
- : T extends ReadonlyArray<infer U>
169
- ? ReadonlyArray<DeepPartial<U>>
170
- : T extends {}
171
- ? { [K in keyof T]?: DeepPartial<T[K]> }
172
- : Partial<T>;
173
-
174
- type KeysOfUnion<T> = T extends T ? keyof T : never;
175
- export type Exact<P, I extends P> = P extends Builtin
176
- ? P
177
- : P & { [K in keyof P]: Exact<P[K], I[K]> } & Record<Exclude<keyof I, KeysOfUnion<P>>, never>;
178
-
179
- export interface Rpc {
180
- request(service: string, method: string, data: Uint8Array): Promise<Uint8Array>;
181
- }
182
-
183
- interface Timestamp {
184
- /**
185
- * Represents seconds of UTC time since Unix epoch
186
- * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
187
- * 9999-12-31T23:59:59Z inclusive.
188
- */
189
- seconds: Long;
190
- /**
191
- * Non-negative fractions of a second at nanosecond resolution. Negative
192
- * second values with fractions must still have non-negative nanos values
193
- * that count forward in time. Must be from 0 to 999,999,999
194
- * inclusive.
195
- */
196
-
197
- nanos: number;
198
- }
199
-
200
- export function toTimestamp(date: Date): Timestamp {
201
- const seconds = numberToLong(date.getTime() / 1_000);
202
- const nanos = (date.getTime() % 1000) * 1000000;
203
- return {
204
- seconds,
205
- nanos,
206
- };
207
- }
208
-
209
- export function fromTimestamp(t: Timestamp): Date {
210
- let millis = t.seconds.toNumber() * 1000;
211
- millis += t.nanos / 1000000;
212
- return new Date(millis);
213
- }
214
-
215
- const fromJSON = (object: any): Timestamp => {
216
- return {
217
- seconds: isSet(object.seconds) ? Long.fromString(object.seconds) : Long.ZERO,
218
- nanos: isSet(object.nanos) ? Number(object.nanos) : 0,
219
- };
220
- };
221
-
222
- const timestampFromJSON = (object: any): Timestamp => {
223
- return {
224
- seconds: isSet(object.seconds) ? Long.fromValue(object.seconds) : Long.ZERO,
225
- nanos: isSet(object.nanos) ? Number(object.nanos) : 0,
226
- };
227
- };
228
-
229
- export function fromJsonTimestamp(o: any): Timestamp {
230
- if (o instanceof Date) {
231
- return toTimestamp(o);
232
- } else if (typeof o === 'string') {
233
- return toTimestamp(new Date(o));
234
- } else {
235
- return timestampFromJSON(o);
236
- }
237
- }
238
-
239
- function numberToLong(number: number) {
240
- return Long.fromNumber(number);
241
- }
@@ -1,5 +0,0 @@
1
- /**
2
- * This file and any referenced files were automatically generated by @osmonauts/telescope@0.80.0
3
- * DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
4
- * and run the transpile command or yarn proto command to regenerate this bundle.
5
- */