@zoguxprotocol/client-js 0.2.10 → 0.2.11

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 (110) hide show
  1. package/__native__/__ios__/v4-native-client.js +112 -9
  2. package/__native__/__ios__/v4-native-client.js.map +1 -1
  3. package/__tests__/modules/client/AccountEndpoints.test.ts +58 -0
  4. package/__tests__/modules/client/MarketsEndpoints.test.ts +47 -0
  5. package/build/cjs/__tests__/modules/client/AccountEndpoints.test.js +54 -1
  6. package/build/cjs/__tests__/modules/client/MarketsEndpoints.test.js +42 -1
  7. package/build/cjs/examples/account_endpoints.js +5 -5
  8. package/build/cjs/examples/batch_cancel_orders_example.js +11 -11
  9. package/build/cjs/examples/composite_example.js +11 -11
  10. package/build/cjs/examples/faucet_endpoint.js +5 -5
  11. package/build/cjs/examples/gov_add_new_market.js +5 -5
  12. package/build/cjs/examples/long_term_order_cancel_example.js +7 -7
  13. package/build/cjs/examples/native_examples.js +6 -6
  14. package/build/cjs/examples/noble_example.js +7 -7
  15. package/build/cjs/examples/permissioned_keys_example.js +9 -9
  16. package/build/cjs/examples/short_term_order_cancel_example.js +7 -7
  17. package/build/cjs/examples/short_term_order_composite_example.js +11 -11
  18. package/build/cjs/examples/test.js +11 -11
  19. package/build/cjs/examples/transfer_example_deposit.js +5 -5
  20. package/build/cjs/examples/transfer_example_send.js +5 -5
  21. package/build/cjs/examples/transfer_example_subaccount_transfer.js +5 -5
  22. package/build/cjs/examples/transfer_example_withdraw.js +5 -5
  23. package/build/cjs/examples/transfer_example_withdraw_other.js +5 -5
  24. package/build/cjs/examples/validator_get_example.js +14 -14
  25. package/build/cjs/examples/validator_post_example.js +7 -7
  26. package/build/cjs/examples/wallet_address.js +2 -2
  27. package/build/cjs/examples/websocket_example.js +5 -5
  28. package/build/cjs/src/clients/lib/axios/axiosRequest.js +1 -1
  29. package/build/cjs/src/clients/modules/account.js +66 -1
  30. package/build/cjs/src/clients/modules/composer.js +5 -3
  31. package/build/cjs/src/clients/modules/get.js +2 -2
  32. package/build/cjs/src/clients/modules/markets.js +37 -1
  33. package/build/cjs/src/clients/socket-client.js +1 -1
  34. package/build/cjs/src/lib/trading-key-utils.js +18 -18
  35. package/build/cjs/src/lib/validation.js +2 -2
  36. package/build/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  37. package/build/esm/__tests__/modules/client/AccountEndpoints.test.js +54 -1
  38. package/build/esm/__tests__/modules/client/MarketsEndpoints.test.js +42 -1
  39. package/build/esm/examples/account_endpoints.js +2 -2
  40. package/build/esm/examples/batch_cancel_orders_example.js +2 -2
  41. package/build/esm/examples/composite_example.js +3 -3
  42. package/build/esm/examples/faucet_endpoint.js +2 -2
  43. package/build/esm/examples/gov_add_new_market.js +2 -2
  44. package/build/esm/examples/long_term_order_cancel_example.js +2 -2
  45. package/build/esm/examples/native_examples.js +2 -2
  46. package/build/esm/examples/noble_example.js +2 -2
  47. package/build/esm/examples/permissioned_keys_example.js +2 -2
  48. package/build/esm/examples/short_term_order_cancel_example.js +2 -2
  49. package/build/esm/examples/short_term_order_composite_example.js +3 -3
  50. package/build/esm/examples/test.js +3 -3
  51. package/build/esm/examples/transfer_example_deposit.js +2 -2
  52. package/build/esm/examples/transfer_example_send.js +2 -2
  53. package/build/esm/examples/transfer_example_subaccount_transfer.js +2 -2
  54. package/build/esm/examples/transfer_example_withdraw.js +2 -2
  55. package/build/esm/examples/transfer_example_withdraw_other.js +2 -2
  56. package/build/esm/examples/validator_get_example.js +2 -2
  57. package/build/esm/examples/validator_post_example.js +3 -3
  58. package/build/esm/examples/wallet_address.js +2 -2
  59. package/build/esm/examples/websocket_example.js +2 -2
  60. package/build/esm/src/clients/lib/axios/axiosRequest.d.ts +1 -1
  61. package/build/esm/src/clients/lib/axios/axiosRequest.d.ts.map +1 -1
  62. package/build/esm/src/clients/lib/axios/axiosRequest.js +1 -1
  63. package/build/esm/src/clients/modules/account.d.ts +6 -0
  64. package/build/esm/src/clients/modules/account.d.ts.map +1 -1
  65. package/build/esm/src/clients/modules/account.js +66 -1
  66. package/build/esm/src/clients/modules/composer.d.ts.map +1 -1
  67. package/build/esm/src/clients/modules/composer.js +5 -3
  68. package/build/esm/src/clients/modules/get.d.ts.map +1 -1
  69. package/build/esm/src/clients/modules/get.js +2 -2
  70. package/build/esm/src/clients/modules/markets.d.ts +5 -0
  71. package/build/esm/src/clients/modules/markets.d.ts.map +1 -1
  72. package/build/esm/src/clients/modules/markets.js +37 -1
  73. package/build/esm/src/clients/socket-client.d.ts.map +1 -1
  74. package/build/esm/src/clients/socket-client.js +1 -1
  75. package/build/esm/src/lib/trading-key-utils.d.ts.map +1 -1
  76. package/build/esm/src/lib/trading-key-utils.js +3 -3
  77. package/build/esm/src/lib/validation.d.ts +1 -1
  78. package/build/esm/src/lib/validation.d.ts.map +1 -1
  79. package/build/esm/src/lib/validation.js +2 -2
  80. package/build/esm/tsconfig.esm.tsbuildinfo +1 -1
  81. package/examples/account_endpoints.ts +1 -1
  82. package/examples/batch_cancel_orders_example.ts +1 -1
  83. package/examples/composite_example.ts +2 -2
  84. package/examples/faucet_endpoint.ts +1 -1
  85. package/examples/gov_add_new_market.ts +1 -1
  86. package/examples/long_term_order_cancel_example.ts +1 -1
  87. package/examples/native_examples.ts +1 -1
  88. package/examples/noble_example.ts +1 -1
  89. package/examples/permissioned_keys_example.ts +1 -1
  90. package/examples/short_term_order_cancel_example.ts +1 -1
  91. package/examples/short_term_order_composite_example.ts +2 -2
  92. package/examples/test.ts +2 -2
  93. package/examples/transfer_example_deposit.ts +1 -1
  94. package/examples/transfer_example_send.ts +1 -1
  95. package/examples/transfer_example_subaccount_transfer.ts +1 -1
  96. package/examples/transfer_example_withdraw.ts +1 -1
  97. package/examples/transfer_example_withdraw_other.ts +1 -1
  98. package/examples/validator_get_example.ts +1 -1
  99. package/examples/validator_post_example.ts +2 -2
  100. package/examples/wallet_address.ts +1 -1
  101. package/examples/websocket_example.ts +1 -1
  102. package/package.json +1 -1
  103. package/src/clients/lib/axios/axiosRequest.ts +1 -1
  104. package/src/clients/modules/account.ts +112 -0
  105. package/src/clients/modules/composer.ts +2 -2
  106. package/src/clients/modules/get.ts +1 -1
  107. package/src/clients/modules/markets.ts +60 -0
  108. package/src/clients/socket-client.ts +1 -1
  109. package/src/lib/trading-key-utils.ts +2 -2
  110. package/src/lib/validation.ts +1 -1
@@ -2,9 +2,9 @@
2
2
  * Simple JS example demostrating accessing subaccount data with Indexer REST endpoints
3
3
  */
4
4
 
5
+ import { ZOGUX_TEST_ADDRESS } from './constants';
5
6
  import { Network } from '../src/clients/constants';
6
7
  import { IndexerClient } from '../src/clients/indexer-client';
7
- import { ZOGUX_TEST_ADDRESS } from './constants';
8
8
 
9
9
  async function test(): Promise<void> {
10
10
  const client = new IndexerClient(Network.testnet().indexerConfig);
@@ -1,12 +1,12 @@
1
1
  import _ from 'lodash';
2
2
 
3
3
  import { BECH32_PREFIX, Order_TimeInForce } from '../src';
4
+ import { ZOGUX_TEST_MNEMONIC, MAX_CLIENT_ID } from './constants';
4
5
  import { CompositeClient, OrderBatchWithMarketId } from '../src/clients/composite-client';
5
6
  import { Network, OrderSide } from '../src/clients/constants';
6
7
  import LocalWallet from '../src/clients/modules/local-wallet';
7
8
  import { SubaccountInfo } from '../src/clients/subaccount';
8
9
  import { randomInt, sleep } from '../src/lib/utils';
9
- import { ZOGUX_TEST_MNEMONIC, MAX_CLIENT_ID } from './constants';
10
10
 
11
11
  type OrderInfo = {
12
12
  marketId: string;
@@ -1,4 +1,6 @@
1
1
  import { BECH32_PREFIX } from '../src';
2
+ import { ZOGUX_TEST_MNEMONIC, MAX_CLIENT_ID } from './constants';
3
+ import ordersParams from './human_readable_orders.json';
2
4
  import { CompositeClient } from '../src/clients/composite-client';
3
5
  import {
4
6
  Network,
@@ -10,8 +12,6 @@ import {
10
12
  import LocalWallet from '../src/clients/modules/local-wallet';
11
13
  import { SubaccountInfo } from '../src/clients/subaccount';
12
14
  import { randomInt } from '../src/lib/utils';
13
- import { ZOGUX_TEST_MNEMONIC, MAX_CLIENT_ID } from './constants';
14
- import ordersParams from './human_readable_orders.json';
15
15
 
16
16
  async function sleep(ms: number): Promise<void> {
17
17
  return new Promise((resolve) => setTimeout(resolve, ms));
@@ -2,9 +2,9 @@
2
2
  * Simple JS example demostrating filling subaccount with Faucet API
3
3
  */
4
4
 
5
+ import { ZOGUX_TEST_ADDRESS } from './constants';
5
6
  import { FaucetApiHost } from '../src/clients/constants';
6
7
  import { FaucetClient } from '../src/clients/faucet-client';
7
- import { ZOGUX_TEST_ADDRESS } from './constants';
8
8
 
9
9
  async function test(): Promise<void> {
10
10
  const client = new FaucetClient(FaucetApiHost.TESTNET);
@@ -2,10 +2,10 @@ import { PerpetualMarketType } from '@zoguxprotocol/proto/src/codegen/zogux/perp
2
2
  import Long from 'long';
3
3
 
4
4
  import { GovAddNewMarketParams, LocalWallet, ProposalStatus } from '../src';
5
+ import { ZOGUX_LOCAL_MNEMONIC } from './constants';
5
6
  import { CompositeClient } from '../src/clients/composite-client';
6
7
  import { BECH32_PREFIX, Network } from '../src/clients/constants';
7
8
  import { getGovAddNewMarketSummary, getGovAddNewMarketTitle, sleep } from '../src/lib/utils';
8
- import { ZOGUX_LOCAL_MNEMONIC } from './constants';
9
9
 
10
10
  const INITIAL_DEPOSIT_AMOUNT = 10_000_000_000_000; // 10,000 whole native tokens.
11
11
  const MOCK_DATA: GovAddNewMarketParams = {
@@ -1,4 +1,5 @@
1
1
  import { BECH32_PREFIX, OrderFlags } from '../src';
2
+ import { ZOGUX_TEST_MNEMONIC, MAX_CLIENT_ID } from './constants';
2
3
  import { CompositeClient } from '../src/clients/composite-client';
3
4
  import {
4
5
  Network,
@@ -10,7 +11,6 @@ import {
10
11
  import LocalWallet from '../src/clients/modules/local-wallet';
11
12
  import { SubaccountInfo } from '../src/clients/subaccount';
12
13
  import { randomInt } from '../src/lib/utils';
13
- import { ZOGUX_TEST_MNEMONIC, MAX_CLIENT_ID } from './constants';
14
14
 
15
15
  async function sleep(ms: number): Promise<void> {
16
16
  return new Promise((resolve) => setTimeout(resolve, ms));
@@ -1,3 +1,4 @@
1
+ import { ZOGUX_TEST_ADDRESS, ZOGUX_TEST_MNEMONIC } from './constants';
1
2
  import { Network } from '../src/clients/constants';
2
3
  import { UserError } from '../src/clients/lib/errors';
3
4
  import {
@@ -19,7 +20,6 @@ import {
19
20
  depositToMegavault,
20
21
  withdrawFromMegavault,
21
22
  } from '../src/clients/native';
22
- import { ZOGUX_TEST_ADDRESS, ZOGUX_TEST_MNEMONIC } from './constants';
23
23
 
24
24
  async function test(): Promise<void> {
25
25
  try {
@@ -2,13 +2,13 @@ import { EncodeObject } from '@cosmjs/proto-signing';
2
2
  import Long from 'long';
3
3
 
4
4
  import { SubaccountInfo } from '../src';
5
+ import { ZOGUX_TEST_MNEMONIC } from './constants';
5
6
  import { Network } from '../src/clients/constants';
6
7
  import LocalWallet from '../src/clients/modules/local-wallet';
7
8
  import { NobleClient } from '../src/clients/noble-client';
8
9
  import { ValidatorClient } from '../src/clients/validator-client';
9
10
  import { BECH32_PREFIX, NOBLE_BECH32_PREFIX } from '../src/lib/constants';
10
11
  import { sleep } from '../src/lib/utils';
11
- import { ZOGUX_TEST_MNEMONIC } from './constants';
12
12
 
13
13
  async function test(): Promise<void> {
14
14
  const zoguxClient = await ValidatorClient.connect(Network.testnet().validatorConfig);
@@ -1,6 +1,7 @@
1
1
  import Long from 'long';
2
2
 
3
3
  import { BECH32_PREFIX } from '../src';
4
+ import { ZOGUX_TEST_MNEMONIC, ZOGUX_TEST_MNEMONIC_2 } from './constants';
4
5
  import { CompositeClient } from '../src/clients/composite-client';
5
6
  import {
6
7
  Network,
@@ -17,7 +18,6 @@ import {
17
18
  getAuthorizeNewTradingKeyArguments,
18
19
  getAuthorizedTradingKeysMetadata,
19
20
  } from '../src/lib/trading-key-utils';
20
- import { ZOGUX_TEST_MNEMONIC, ZOGUX_TEST_MNEMONIC_2 } from './constants';
21
21
 
22
22
  async function test(): Promise<void> {
23
23
  const wallet1 = await LocalWallet.fromMnemonic(ZOGUX_TEST_MNEMONIC, BECH32_PREFIX);
@@ -1,10 +1,10 @@
1
1
  import { BECH32_PREFIX, OrderFlags, Order_TimeInForce } from '../src';
2
+ import { ZOGUX_TEST_MNEMONIC, MAX_CLIENT_ID } from './constants';
2
3
  import { CompositeClient } from '../src/clients/composite-client';
3
4
  import { Network, OrderSide } from '../src/clients/constants';
4
5
  import LocalWallet from '../src/clients/modules/local-wallet';
5
6
  import { SubaccountInfo } from '../src/clients/subaccount';
6
7
  import { randomInt, sleep } from '../src/lib/utils';
7
- import { ZOGUX_TEST_MNEMONIC, MAX_CLIENT_ID } from './constants';
8
8
 
9
9
  async function test(): Promise<void> {
10
10
  const wallet = await LocalWallet.fromMnemonic(ZOGUX_TEST_MNEMONIC, BECH32_PREFIX);
@@ -1,13 +1,13 @@
1
1
  import { Order_TimeInForce } from '@zoguxprotocol/proto/src/codegen/zogux/clob/order';
2
2
 
3
3
  import { BECH32_PREFIX } from '../src';
4
+ import { ZOGUX_TEST_MNEMONIC } from './constants';
5
+ import ordersParams from './human_readable_short_term_orders.json';
4
6
  import { CompositeClient } from '../src/clients/composite-client';
5
7
  import { Network, OrderExecution, OrderSide } from '../src/clients/constants';
6
8
  import LocalWallet from '../src/clients/modules/local-wallet';
7
9
  import { SubaccountInfo } from '../src/clients/subaccount';
8
10
  import { randomInt } from '../src/lib/utils';
9
- import { ZOGUX_TEST_MNEMONIC } from './constants';
10
- import ordersParams from './human_readable_short_term_orders.json';
11
11
 
12
12
  async function sleep(ms: number): Promise<void> {
13
13
  return new Promise((resolve) => setTimeout(resolve, ms));
package/examples/test.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import { BECH32_PREFIX } from '../src';
2
+ import { ZOGUX_TEST_MNEMONIC, MAX_CLIENT_ID } from './constants';
3
+ import ordersParams from './human_readable_orders.json';
2
4
  import { CompositeClient } from '../src/clients/composite-client';
3
5
  import {
4
6
  Network,
@@ -10,8 +12,6 @@ import {
10
12
  import LocalWallet from '../src/clients/modules/local-wallet';
11
13
  import { SubaccountInfo } from '../src/clients/subaccount';
12
14
  import { randomInt } from '../src/lib/utils';
13
- import { ZOGUX_TEST_MNEMONIC, MAX_CLIENT_ID } from './constants';
14
- import ordersParams from './human_readable_orders.json';
15
15
 
16
16
  async function sleep(ms: number): Promise<void> {
17
17
  return new Promise((resolve) => setTimeout(resolve, ms));
@@ -1,11 +1,11 @@
1
1
  import Long from 'long';
2
2
 
3
3
  import { BECH32_PREFIX } from '../src';
4
+ import { ZOGUX_TEST_MNEMONIC } from './constants';
4
5
  import { Network } from '../src/clients/constants';
5
6
  import LocalWallet from '../src/clients/modules/local-wallet';
6
7
  import { SubaccountInfo } from '../src/clients/subaccount';
7
8
  import { ValidatorClient } from '../src/clients/validator-client';
8
- import { ZOGUX_TEST_MNEMONIC } from './constants';
9
9
 
10
10
  async function test(): Promise<void> {
11
11
  const wallet = await LocalWallet.fromMnemonic(ZOGUX_TEST_MNEMONIC, BECH32_PREFIX);
@@ -4,11 +4,11 @@ import Long from 'long';
4
4
 
5
5
  import { TEST_RECIPIENT_ADDRESS } from '../__tests__/helpers/constants';
6
6
  import { BECH32_PREFIX } from '../src';
7
+ import { ZOGUX_TEST_MNEMONIC } from './constants';
7
8
  import { Network } from '../src/clients/constants';
8
9
  import LocalWallet from '../src/clients/modules/local-wallet';
9
10
  import { SubaccountInfo } from '../src/clients/subaccount';
10
11
  import { ValidatorClient } from '../src/clients/validator-client';
11
- import { ZOGUX_TEST_MNEMONIC } from './constants';
12
12
 
13
13
  async function test(): Promise<void> {
14
14
  const wallet = await LocalWallet.fromMnemonic(ZOGUX_TEST_MNEMONIC, BECH32_PREFIX);
@@ -1,11 +1,11 @@
1
1
  import Long from 'long';
2
2
 
3
3
  import { BECH32_PREFIX } from '../src';
4
+ import { ZOGUX_TEST_MNEMONIC } from './constants';
4
5
  import { Network } from '../src/clients/constants';
5
6
  import LocalWallet from '../src/clients/modules/local-wallet';
6
7
  import { SubaccountInfo } from '../src/clients/subaccount';
7
8
  import { ValidatorClient } from '../src/clients/validator-client';
8
- import { ZOGUX_TEST_MNEMONIC } from './constants';
9
9
 
10
10
  async function test(): Promise<void> {
11
11
  const wallet = await LocalWallet.fromMnemonic(ZOGUX_TEST_MNEMONIC, BECH32_PREFIX);
@@ -1,11 +1,11 @@
1
1
  import Long from 'long';
2
2
 
3
3
  import { BECH32_PREFIX } from '../src';
4
+ import { ZOGUX_TEST_MNEMONIC } from './constants';
4
5
  import { Network } from '../src/clients/constants';
5
6
  import LocalWallet from '../src/clients/modules/local-wallet';
6
7
  import { SubaccountInfo } from '../src/clients/subaccount';
7
8
  import { ValidatorClient } from '../src/clients/validator-client';
8
- import { ZOGUX_TEST_MNEMONIC } from './constants';
9
9
 
10
10
  // TODO: Test after testnet deploy latest transfer contracts.
11
11
 
@@ -4,11 +4,11 @@ import Long from 'long';
4
4
 
5
5
  import { TEST_RECIPIENT_ADDRESS } from '../__tests__/helpers/constants';
6
6
  import { BECH32_PREFIX } from '../src';
7
+ import { ZOGUX_TEST_MNEMONIC } from './constants';
7
8
  import { Network } from '../src/clients/constants';
8
9
  import LocalWallet from '../src/clients/modules/local-wallet';
9
10
  import { SubaccountInfo } from '../src/clients/subaccount';
10
11
  import { ValidatorClient } from '../src/clients/validator-client';
11
- import { ZOGUX_TEST_MNEMONIC } from './constants';
12
12
 
13
13
  async function test(): Promise<void> {
14
14
  const wallet = await LocalWallet.fromMnemonic(ZOGUX_TEST_MNEMONIC, BECH32_PREFIX);
@@ -1,6 +1,6 @@
1
+ import { ZOGUX_TEST_ADDRESS } from './constants';
1
2
  import { Network } from '../src/clients/constants';
2
3
  import { ValidatorClient } from '../src/clients/validator-client';
3
- import { ZOGUX_TEST_ADDRESS } from './constants';
4
4
 
5
5
  async function test(): Promise<void> {
6
6
  const client = await ValidatorClient.connect(Network.testnet().validatorConfig);
@@ -2,14 +2,14 @@ import Long from 'long';
2
2
  import protobuf from 'protobufjs';
3
3
 
4
4
  import { BECH32_PREFIX } from '../src';
5
+ import { ZOGUX_TEST_MNEMONIC, defaultOrder } from './constants';
6
+ import ordersParams from './raw_orders.json';
5
7
  import { Network } from '../src/clients/constants';
6
8
  import LocalWallet from '../src/clients/modules/local-wallet';
7
9
  import { SubaccountInfo } from '../src/clients/subaccount';
8
10
  import { IPlaceOrder } from '../src/clients/types';
9
11
  import { ValidatorClient } from '../src/clients/validator-client';
10
12
  import { randomInt } from '../src/lib/utils';
11
- import { ZOGUX_TEST_MNEMONIC, defaultOrder } from './constants';
12
- import ordersParams from './raw_orders.json';
13
13
 
14
14
  // Required for encoding and decoding queries that are of type Long.
15
15
  // Must be done once but since the individal modules should be usable
@@ -1,6 +1,6 @@
1
1
  import { BECH32_PREFIX } from '../src';
2
- import LocalWallet from '../src/clients/modules/local-wallet';
3
2
  import { ZOGUX_TEST_ADDRESS, ZOGUX_TEST_MNEMONIC } from './constants';
3
+ import LocalWallet from '../src/clients/modules/local-wallet';
4
4
 
5
5
  async function test(): Promise<void> {
6
6
  const wallet = await LocalWallet.fromMnemonic(ZOGUX_TEST_MNEMONIC, BECH32_PREFIX);
@@ -1,10 +1,10 @@
1
+ import { ZOGUX_TEST_ADDRESS } from './constants';
1
2
  import { Network } from '../src/clients/constants';
2
3
  import {
3
4
  CandlesResolution,
4
5
  IncomingMessageTypes,
5
6
  SocketClient,
6
7
  } from '../src/clients/socket-client';
7
- import { ZOGUX_TEST_ADDRESS } from './constants';
8
8
 
9
9
  function test(): void {
10
10
  const mySocket = new SocketClient(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zoguxprotocol/client-js",
3
- "version": "0.2.10",
3
+ "version": "0.2.11",
4
4
  "description": "General client library for the new Zogux system (v4 decentralized)",
5
5
  "main": "build/cjs/src/index.js",
6
6
  "module": "build/esm/src/index.js",
@@ -1,8 +1,8 @@
1
1
  import axios, { AxiosRequestConfig } from 'axios';
2
2
 
3
- import { Data } from '../../types';
4
3
  import { AxiosServerError, AxiosError } from './errors';
5
4
  import { RequestMethod } from './types';
5
+ import { Data } from '../../types';
6
6
 
7
7
  export interface Response {
8
8
  status: number;
@@ -87,6 +87,11 @@ export default class AccountClient extends RestClient {
87
87
  });
88
88
  }
89
89
 
90
+ async getSpotBalances(address: string, subaccountNumber: number): Promise<Data> {
91
+ const uri = '/v4/spotAssetPositions/balances';
92
+ return this.get(uri, { address, subaccountNumber });
93
+ }
94
+
90
95
  // ------ Transfers ------ //
91
96
 
92
97
  async getTransfersBetween(
@@ -257,6 +262,113 @@ export default class AccountClient extends RestClient {
257
262
  });
258
263
  }
259
264
 
265
+ // ------ Spot Fills ------ //
266
+
267
+ async getSubaccountSpotFills(
268
+ address: string,
269
+ subaccountNumber: number,
270
+ market?: string | null,
271
+ limit?: number | null,
272
+ createdBeforeOrAtHeight?: number | null,
273
+ createdBeforeOrAt?: string | null,
274
+ page?: number | null,
275
+ ): Promise<Data> {
276
+ const uri = '/v4/spotFills';
277
+ return this.get(uri, {
278
+ address,
279
+ subaccountNumber,
280
+ market,
281
+ limit,
282
+ createdBeforeOrAtHeight,
283
+ createdBeforeOrAt,
284
+ page,
285
+ });
286
+ }
287
+
288
+ async getParentSubaccountNumberSpotFills(
289
+ address: string,
290
+ parentSubaccountNumber: number,
291
+ limit?: number | null,
292
+ page?: number | null,
293
+ ): Promise<Data> {
294
+ const uri = '/v4/spotFills/parentSubaccount';
295
+ return this.get(uri, {
296
+ address,
297
+ parentSubaccountNumber,
298
+ limit,
299
+ page,
300
+ });
301
+ }
302
+
303
+ // ------ Spot Orders ------ //
304
+
305
+ async getSubaccountSpotOrders(
306
+ address: string,
307
+ subaccountNumber: number,
308
+ limit?: number | null,
309
+ ticker?: string | null,
310
+ side?: OrderSide | null,
311
+ type?: OrderType | null,
312
+ status?: OrderStatus | null,
313
+ goodTilBlockBeforeOrAt?: number | null,
314
+ goodTilBlockAfter?: number | null,
315
+ goodTilBlockTimeBeforeOrAt?: string | null,
316
+ goodTilBlockTimeAfter?: string | null,
317
+ returnLatestOrders?: boolean | null,
318
+ ): Promise<Data> {
319
+ const uri = '/v4/spotOrders';
320
+ return this.get(uri, {
321
+ address,
322
+ subaccountNumber,
323
+ limit,
324
+ ticker,
325
+ side,
326
+ type,
327
+ status,
328
+ goodTilBlockBeforeOrAt,
329
+ goodTilBlockAfter,
330
+ goodTilBlockTimeBeforeOrAt,
331
+ goodTilBlockTimeAfter,
332
+ returnLatestOrders,
333
+ });
334
+ }
335
+
336
+ async getParentSubaccountNumberSpotOrders(
337
+ address: string,
338
+ parentSubaccountNumber: number,
339
+ limit?: number | null,
340
+ ticker?: string | null,
341
+ side?: OrderSide | null,
342
+ type?: OrderType | null,
343
+ status?: OrderStatus | null,
344
+ goodTilBlockBeforeOrAt?: number | null,
345
+ goodTilBlockAfter?: number | null,
346
+ goodTilBlockTimeBeforeOrAt?: string | null,
347
+ goodTilBlockTimeAfter?: string | null,
348
+ returnLatestOrders?: boolean | null,
349
+ ): Promise<Data> {
350
+ const uri = '/v4/spotOrders/parentSubaccountNumber';
351
+ return this.get(uri, {
352
+ address,
353
+ parentSubaccountNumber,
354
+ limit,
355
+ ticker,
356
+ side,
357
+ type,
358
+ status,
359
+ goodTilBlockBeforeOrAt,
360
+ goodTilBlockAfter,
361
+ goodTilBlockTimeBeforeOrAt,
362
+ goodTilBlockTimeAfter,
363
+ returnLatestOrders,
364
+ });
365
+ }
366
+
367
+ async getSpotOrder(orderId: string): Promise<Data> {
368
+ const uri = `/v4/spotOrders/${orderId}`;
369
+ return this.get(uri);
370
+ }
371
+
260
372
  // ------ Pnl ------ //
261
373
 
262
374
  async getSubaccountHistoricalPNLs(
@@ -1,5 +1,6 @@
1
1
  /* eslint-disable comma-dangle */
2
2
  /* eslint-disable @typescript-eslint/quotes */
3
+ import { fromBase64 } from '@cosmjs/encoding';
3
4
  import { EncodeObject, Registry } from '@cosmjs/proto-signing';
4
5
  import { MsgWithdrawDelegatorReward } from '@zoguxprotocol/proto/src/codegen/cosmos/distribution/v1beta1/tx';
5
6
  import { MsgSubmitProposal } from '@zoguxprotocol/proto/src/codegen/cosmos/gov/v1/tx';
@@ -24,13 +25,13 @@ import {
24
25
  MsgDepositToMegavault,
25
26
  MsgWithdrawFromMegavault,
26
27
  } from '@zoguxprotocol/proto/src/codegen/zogux/vault/tx';
27
- import { fromBase64, toBase64 } from '@cosmjs/encoding';
28
28
  import { MsgSend } from 'cosmjs-types/cosmos/bank/v1beta1/tx';
29
29
  import { Coin } from 'cosmjs-types/cosmos/base/v1beta1/coin';
30
30
  import { Any } from 'cosmjs-types/google/protobuf/any';
31
31
  import Long from 'long';
32
32
  import protobuf from 'protobufjs';
33
33
 
34
+ import { bigIntToBytes } from '../../lib/helpers';
34
35
  import {
35
36
  GOV_MODULE_ADDRESS,
36
37
  DELAYMSG_MODULE_ADDRESS,
@@ -68,7 +69,6 @@ import {
68
69
  TYPE_URL_MSG_REMOVE_AUTHENTICATOR,
69
70
  AuthenticatorType,
70
71
  } from '../constants';
71
- import { bigIntToBytes } from '../../lib/helpers';
72
72
  import { DenomConfig, ITwapParameters, IBuilderCodeParameters } from '../types';
73
73
  import {
74
74
  OrderId,
@@ -19,7 +19,6 @@ import protobuf from 'protobufjs';
19
19
 
20
20
  import { bigIntToBytes } from '../../lib/helpers';
21
21
  import { PAGE_REQUEST } from '../constants';
22
- import { UnexpectedClientError } from '../lib/errors';
23
22
  import {
24
23
  AffiliateModule,
25
24
  BridgeModule,
@@ -38,6 +37,7 @@ import {
38
37
  VaultModule,
39
38
  } from './proto-includes';
40
39
  import { TendermintClient } from './tendermintClient';
40
+ import { UnexpectedClientError } from '../lib/errors';
41
41
 
42
42
  // Required for encoding and decoding queries that are of type Long.
43
43
  // Must be done once but since the individal modules should be usable without
@@ -68,4 +68,64 @@ export default class MarketsClient extends RestClient {
68
68
  timePeriod: period,
69
69
  });
70
70
  }
71
+
72
+ // ------ Spot (public) ------ //
73
+
74
+ async getSpotMarkets(ticker?: string | null, limit?: number | null): Promise<Data> {
75
+ const uri = '/v4/spotMarkets';
76
+ return this.get(uri, { ticker, limit });
77
+ }
78
+
79
+ async getSpotMarketOrderbook(ticker: string): Promise<Data> {
80
+ const uri = `/v4/orderbooks/spotMarket/${ticker}`;
81
+ return this.get(uri);
82
+ }
83
+
84
+ async getSpotMarketCandles(
85
+ ticker: string,
86
+ resolution: string,
87
+ limit: number,
88
+ fromISO?: string | null,
89
+ toISO?: string | null,
90
+ ): Promise<Data> {
91
+ const uri = `/v4/candles/spotMarkets/${ticker}`;
92
+ return this.get(uri, {
93
+ resolution,
94
+ limit,
95
+ fromISO,
96
+ toISO,
97
+ });
98
+ }
99
+
100
+ async getSpotMarketTrades(
101
+ ticker: string,
102
+ startingBeforeOrAtHeight?: number | null,
103
+ startingBeforeOrAt?: string | null,
104
+ limit?: number | null,
105
+ page?: number | null,
106
+ ): Promise<Data> {
107
+ const uri = `/v4/trades/spotMarket/${ticker}`;
108
+ return this.get(uri, {
109
+ createdBeforeOrAtHeight: startingBeforeOrAtHeight,
110
+ createdBeforeOrAt: startingBeforeOrAt,
111
+ limit,
112
+ page,
113
+ });
114
+ }
115
+
116
+ async getSpotFillsByMarket(
117
+ ticker: string,
118
+ limit?: number | null,
119
+ createdBeforeOrAtHeight?: number | null,
120
+ createdBeforeOrAt?: string | null,
121
+ page?: number | null,
122
+ ): Promise<Data> {
123
+ const uri = `/v4/spotFills/market/${ticker}`;
124
+ return this.get(uri, {
125
+ limit,
126
+ createdBeforeOrAtHeight,
127
+ createdBeforeOrAt,
128
+ page,
129
+ });
130
+ }
71
131
  }
@@ -1,8 +1,8 @@
1
1
  import { HttpsProxyAgent } from 'https-proxy-agent';
2
2
  import WebSocket, { ErrorEvent, MessageEvent } from 'ws';
3
3
 
4
- import { getProxyAgent } from '../lib/utils';
5
4
  import { IndexerConfig } from './constants';
5
+ import { getProxyAgent } from '../lib/utils';
6
6
 
7
7
  enum OutgoingMessageTypes {
8
8
  SUBSCRIBE = 'subscribe',
@@ -3,6 +3,8 @@ import { rawSecp256k1PubkeyToRawAddress } from '@cosmjs/tendermint-rpc';
3
3
  import { generateMnemonic } from '@scure/bip39';
4
4
  import { wordlist } from '@scure/bip39/wordlists/english';
5
5
 
6
+ import { BECH32_PREFIX } from './constants';
7
+ import { deriveHDKeyFromMnemonic } from './onboarding';
6
8
  import {
7
9
  Authenticator,
8
10
  AuthenticatorType,
@@ -12,8 +14,6 @@ import {
12
14
  } from '../clients/constants';
13
15
  import { type Get } from '../clients/modules/get';
14
16
  import LocalWallet from '../clients/modules/local-wallet';
15
- import { BECH32_PREFIX } from './constants';
16
- import { deriveHDKeyFromMnemonic } from './onboarding';
17
17
 
18
18
  export const createNewRandomZoguxWallet = async (): Promise<
19
19
  { privateKeyHex: string; mnemonic: string; publicKey: string; address: string } | undefined
@@ -1,6 +1,7 @@
1
1
  import { decode } from 'bech32';
2
2
  import Long from 'long';
3
3
 
4
+ import { UserError } from './errors';
4
5
  import { MAX_SUBACCOUNT_NUMBER, MAX_UINT_32 } from '../clients/constants';
5
6
  import {
6
7
  Transfer,
@@ -10,7 +11,6 @@ import {
10
11
  IBatchCancelOrder,
11
12
  ISpotPerpTransferMessage,
12
13
  } from '../clients/types';
13
- import { UserError } from './errors';
14
14
 
15
15
  /**
16
16
  * @describe validatePlaceOrderMessage validates that an order to place has fields that would be