@zoguxprotocol/client-js 0.2.9 → 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.
- package/__native__/__ios__/v4-native-client.js +979 -18
- package/__native__/__ios__/v4-native-client.js.map +1 -1
- package/__tests__/lib/composer-bridge.test.ts +133 -0
- package/__tests__/modules/client/AccountEndpoints.test.ts +58 -0
- package/__tests__/modules/client/MarketsEndpoints.test.ts +47 -0
- package/build/cjs/__tests__/lib/composer-bridge.test.js +88 -0
- package/build/cjs/__tests__/modules/client/AccountEndpoints.test.js +54 -1
- package/build/cjs/__tests__/modules/client/MarketsEndpoints.test.js +42 -1
- package/build/cjs/examples/account_endpoints.js +5 -5
- package/build/cjs/examples/batch_cancel_orders_example.js +11 -11
- package/build/cjs/examples/composite_example.js +11 -11
- package/build/cjs/examples/faucet_endpoint.js +5 -5
- package/build/cjs/examples/gov_add_new_market.js +5 -5
- package/build/cjs/examples/long_term_order_cancel_example.js +7 -7
- package/build/cjs/examples/native_examples.js +6 -6
- package/build/cjs/examples/noble_example.js +7 -7
- package/build/cjs/examples/permissioned_keys_example.js +9 -9
- package/build/cjs/examples/short_term_order_cancel_example.js +7 -7
- package/build/cjs/examples/short_term_order_composite_example.js +11 -11
- package/build/cjs/examples/test.js +11 -11
- package/build/cjs/examples/transfer_example_deposit.js +5 -5
- package/build/cjs/examples/transfer_example_send.js +5 -5
- package/build/cjs/examples/transfer_example_subaccount_transfer.js +5 -5
- package/build/cjs/examples/transfer_example_withdraw.js +5 -5
- package/build/cjs/examples/transfer_example_withdraw_other.js +5 -5
- package/build/cjs/examples/validator_get_example.js +14 -14
- package/build/cjs/examples/validator_post_example.js +7 -7
- package/build/cjs/examples/wallet_address.js +2 -2
- package/build/cjs/examples/websocket_example.js +5 -5
- package/build/cjs/node_modules/@zoguxprotocol/proto/src/codegen/zogux/bridge/events.js +1 -1
- package/build/cjs/node_modules/@zoguxprotocol/proto/src/codegen/zogux/bridge/params.js +1 -1
- package/build/cjs/node_modules/@zoguxprotocol/proto/src/codegen/zogux/indexer/protocol/v1/subaccount.js +1 -1
- package/build/cjs/node_modules/@zoguxprotocol/proto/src/codegen/zogux/sending/transfer.js +1 -1
- package/build/cjs/node_modules/@zoguxprotocol/proto/src/codegen/zogux/sending/tx.rpc.msg.js +1 -1
- package/build/cjs/node_modules/@zoguxprotocol/proto/src/codegen/zogux/spots/tx.js +73 -2
- package/build/cjs/node_modules/@zoguxprotocol/proto/src/codegen/zogux/spots/tx.rpc.msg.js +7 -1
- package/build/cjs/node_modules/@zoguxprotocol/proto/src/codegen/zogux/subaccounts/spot_position.js +1 -1
- package/build/cjs/node_modules/@zoguxprotocol/proto/src/codegen/zogux/subaccounts/tx.js +1 -1
- package/build/cjs/node_modules/@zoguxprotocol/proto/src/codegen/zogux/subaccounts/tx.rpc.msg.js +1 -1
- package/build/cjs/src/clients/constants.js +11 -3
- package/build/cjs/src/clients/lib/axios/axiosRequest.js +1 -1
- package/build/cjs/src/clients/lib/registry.js +9 -1
- package/build/cjs/src/clients/modules/account.js +66 -1
- package/build/cjs/src/clients/modules/composer.js +43 -3
- package/build/cjs/src/clients/modules/get.js +2 -2
- package/build/cjs/src/clients/modules/markets.js +37 -1
- package/build/cjs/src/clients/modules/post.js +37 -1
- package/build/cjs/src/clients/socket-client.js +1 -1
- package/build/cjs/src/lib/trading-key-utils.js +18 -18
- package/build/cjs/src/lib/validation.js +2 -2
- package/build/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/build/esm/__tests__/lib/composer-bridge.test.d.ts +2 -0
- package/build/esm/__tests__/lib/composer-bridge.test.d.ts.map +1 -0
- package/build/esm/__tests__/lib/composer-bridge.test.js +83 -0
- package/build/esm/__tests__/modules/client/AccountEndpoints.test.js +54 -1
- package/build/esm/__tests__/modules/client/MarketsEndpoints.test.js +42 -1
- package/build/esm/examples/account_endpoints.js +2 -2
- package/build/esm/examples/batch_cancel_orders_example.js +2 -2
- package/build/esm/examples/composite_example.js +3 -3
- package/build/esm/examples/faucet_endpoint.js +2 -2
- package/build/esm/examples/gov_add_new_market.js +2 -2
- package/build/esm/examples/long_term_order_cancel_example.js +2 -2
- package/build/esm/examples/native_examples.js +2 -2
- package/build/esm/examples/noble_example.js +2 -2
- package/build/esm/examples/permissioned_keys_example.js +2 -2
- package/build/esm/examples/short_term_order_cancel_example.js +2 -2
- package/build/esm/examples/short_term_order_composite_example.js +3 -3
- package/build/esm/examples/test.js +3 -3
- package/build/esm/examples/transfer_example_deposit.js +2 -2
- package/build/esm/examples/transfer_example_send.js +2 -2
- package/build/esm/examples/transfer_example_subaccount_transfer.js +2 -2
- package/build/esm/examples/transfer_example_withdraw.js +2 -2
- package/build/esm/examples/transfer_example_withdraw_other.js +2 -2
- package/build/esm/examples/validator_get_example.js +2 -2
- package/build/esm/examples/validator_post_example.js +3 -3
- package/build/esm/examples/wallet_address.js +2 -2
- package/build/esm/examples/websocket_example.js +2 -2
- package/build/esm/node_modules/@zoguxprotocol/proto/src/codegen/zogux/bridge/events.d.ts +12 -6
- package/build/esm/node_modules/@zoguxprotocol/proto/src/codegen/zogux/bridge/events.d.ts.map +1 -1
- package/build/esm/node_modules/@zoguxprotocol/proto/src/codegen/zogux/bridge/events.js +1 -1
- package/build/esm/node_modules/@zoguxprotocol/proto/src/codegen/zogux/bridge/params.d.ts +6 -4
- package/build/esm/node_modules/@zoguxprotocol/proto/src/codegen/zogux/bridge/params.d.ts.map +1 -1
- package/build/esm/node_modules/@zoguxprotocol/proto/src/codegen/zogux/bridge/params.js +1 -1
- package/build/esm/node_modules/@zoguxprotocol/proto/src/codegen/zogux/bundle.d.ts +10 -0
- package/build/esm/node_modules/@zoguxprotocol/proto/src/codegen/zogux/bundle.d.ts.map +1 -1
- package/build/esm/node_modules/@zoguxprotocol/proto/src/codegen/zogux/indexer/protocol/v1/subaccount.d.ts +6 -4
- package/build/esm/node_modules/@zoguxprotocol/proto/src/codegen/zogux/indexer/protocol/v1/subaccount.d.ts.map +1 -1
- package/build/esm/node_modules/@zoguxprotocol/proto/src/codegen/zogux/indexer/protocol/v1/subaccount.js +1 -1
- package/build/esm/node_modules/@zoguxprotocol/proto/src/codegen/zogux/sending/transfer.d.ts +8 -2
- package/build/esm/node_modules/@zoguxprotocol/proto/src/codegen/zogux/sending/transfer.d.ts.map +1 -1
- package/build/esm/node_modules/@zoguxprotocol/proto/src/codegen/zogux/sending/transfer.js +1 -1
- package/build/esm/node_modules/@zoguxprotocol/proto/src/codegen/zogux/sending/tx.rpc.msg.d.ts +6 -2
- package/build/esm/node_modules/@zoguxprotocol/proto/src/codegen/zogux/sending/tx.rpc.msg.d.ts.map +1 -1
- package/build/esm/node_modules/@zoguxprotocol/proto/src/codegen/zogux/sending/tx.rpc.msg.js +1 -1
- package/build/esm/node_modules/@zoguxprotocol/proto/src/codegen/zogux/spots/tx.d.ts +28 -0
- package/build/esm/node_modules/@zoguxprotocol/proto/src/codegen/zogux/spots/tx.d.ts.map +1 -1
- package/build/esm/node_modules/@zoguxprotocol/proto/src/codegen/zogux/spots/tx.js +72 -1
- package/build/esm/node_modules/@zoguxprotocol/proto/src/codegen/zogux/spots/tx.rpc.msg.d.ts +4 -1
- package/build/esm/node_modules/@zoguxprotocol/proto/src/codegen/zogux/spots/tx.rpc.msg.d.ts.map +1 -1
- package/build/esm/node_modules/@zoguxprotocol/proto/src/codegen/zogux/spots/tx.rpc.msg.js +8 -2
- package/build/esm/node_modules/@zoguxprotocol/proto/src/codegen/zogux/subaccounts/spot_position.d.ts +6 -4
- package/build/esm/node_modules/@zoguxprotocol/proto/src/codegen/zogux/subaccounts/spot_position.d.ts.map +1 -1
- package/build/esm/node_modules/@zoguxprotocol/proto/src/codegen/zogux/subaccounts/spot_position.js +1 -1
- package/build/esm/node_modules/@zoguxprotocol/proto/src/codegen/zogux/subaccounts/tx.d.ts +22 -7
- package/build/esm/node_modules/@zoguxprotocol/proto/src/codegen/zogux/subaccounts/tx.d.ts.map +1 -1
- package/build/esm/node_modules/@zoguxprotocol/proto/src/codegen/zogux/subaccounts/tx.js +1 -1
- package/build/esm/node_modules/@zoguxprotocol/proto/src/codegen/zogux/subaccounts/tx.rpc.msg.d.ts +3 -2
- package/build/esm/node_modules/@zoguxprotocol/proto/src/codegen/zogux/subaccounts/tx.rpc.msg.d.ts.map +1 -1
- package/build/esm/node_modules/@zoguxprotocol/proto/src/codegen/zogux/subaccounts/tx.rpc.msg.js +1 -1
- package/build/esm/src/clients/constants.d.ts +7 -0
- package/build/esm/src/clients/constants.d.ts.map +1 -1
- package/build/esm/src/clients/constants.js +9 -1
- package/build/esm/src/clients/lib/axios/axiosRequest.d.ts +1 -1
- package/build/esm/src/clients/lib/axios/axiosRequest.d.ts.map +1 -1
- package/build/esm/src/clients/lib/axios/axiosRequest.js +1 -1
- package/build/esm/src/clients/lib/registry.d.ts.map +1 -1
- package/build/esm/src/clients/lib/registry.js +10 -2
- package/build/esm/src/clients/modules/account.d.ts +6 -0
- package/build/esm/src/clients/modules/account.d.ts.map +1 -1
- package/build/esm/src/clients/modules/account.js +66 -1
- package/build/esm/src/clients/modules/composer.d.ts +6 -1
- package/build/esm/src/clients/modules/composer.d.ts.map +1 -1
- package/build/esm/src/clients/modules/composer.js +44 -4
- package/build/esm/src/clients/modules/get.d.ts.map +1 -1
- package/build/esm/src/clients/modules/get.js +2 -2
- package/build/esm/src/clients/modules/markets.d.ts +5 -0
- package/build/esm/src/clients/modules/markets.d.ts.map +1 -1
- package/build/esm/src/clients/modules/markets.js +37 -1
- package/build/esm/src/clients/modules/post.d.ts +10 -0
- package/build/esm/src/clients/modules/post.d.ts.map +1 -1
- package/build/esm/src/clients/modules/post.js +37 -1
- package/build/esm/src/clients/socket-client.d.ts.map +1 -1
- package/build/esm/src/clients/socket-client.js +1 -1
- package/build/esm/src/lib/trading-key-utils.d.ts.map +1 -1
- package/build/esm/src/lib/trading-key-utils.js +3 -3
- package/build/esm/src/lib/validation.d.ts +1 -1
- package/build/esm/src/lib/validation.d.ts.map +1 -1
- package/build/esm/src/lib/validation.js +2 -2
- package/build/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/examples/account_endpoints.ts +1 -1
- package/examples/batch_cancel_orders_example.ts +1 -1
- package/examples/composite_example.ts +2 -2
- package/examples/faucet_endpoint.ts +1 -1
- package/examples/gov_add_new_market.ts +1 -1
- package/examples/long_term_order_cancel_example.ts +1 -1
- package/examples/native_examples.ts +1 -1
- package/examples/noble_example.ts +1 -1
- package/examples/permissioned_keys_example.ts +1 -1
- package/examples/short_term_order_cancel_example.ts +1 -1
- package/examples/short_term_order_composite_example.ts +2 -2
- package/examples/test.ts +2 -2
- package/examples/transfer_example_deposit.ts +1 -1
- package/examples/transfer_example_send.ts +1 -1
- package/examples/transfer_example_subaccount_transfer.ts +1 -1
- package/examples/transfer_example_withdraw.ts +1 -1
- package/examples/transfer_example_withdraw_other.ts +1 -1
- package/examples/validator_get_example.ts +1 -1
- package/examples/validator_post_example.ts +2 -2
- package/examples/wallet_address.ts +1 -1
- package/examples/websocket_example.ts +1 -1
- package/package.json +2 -2
- package/src/clients/constants.ts +9 -0
- package/src/clients/lib/axios/axiosRequest.ts +1 -1
- package/src/clients/lib/registry.ts +21 -0
- package/src/clients/modules/account.ts +112 -0
- package/src/clients/modules/composer.ts +78 -4
- package/src/clients/modules/get.ts +1 -1
- package/src/clients/modules/markets.ts +60 -0
- package/src/clients/modules/post.ts +167 -0
- package/src/clients/socket-client.ts +1 -1
- package/src/lib/trading-key-utils.ts +2 -2
- package/src/lib/validation.ts +1 -1
- package/tsconfig.base.json +7 -2
|
@@ -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.
|
|
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",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@osmonauts/lcd": "^0.6.0",
|
|
56
56
|
"@scure/bip32": "^1.1.5",
|
|
57
57
|
"@scure/bip39": "^1.1.1",
|
|
58
|
-
"@zoguxprotocol/proto": "0.1.
|
|
58
|
+
"@zoguxprotocol/proto": "0.1.8",
|
|
59
59
|
"axios": "1.1.3",
|
|
60
60
|
"bech32": "^1.1.4",
|
|
61
61
|
"bignumber.js": "^9.1.1",
|
package/src/clients/constants.ts
CHANGED
|
@@ -110,6 +110,15 @@ export const TYPE_URL_MSG_WITHDRAW_FROM_SPOT = '/zogux.sending.MsgWithdrawFromSp
|
|
|
110
110
|
// x/affiliates
|
|
111
111
|
export const TYPE_URL_MSG_REGISTER_AFFILIATE = '/zogux.affiliates.MsgRegisterAffiliate';
|
|
112
112
|
|
|
113
|
+
// x/bridge
|
|
114
|
+
export const TYPE_URL_MSG_REQUEST_WITHDRAWAL = '/zogux.bridge.MsgRequestWithdrawal';
|
|
115
|
+
export const TYPE_URL_MSG_SUBMIT_WITHDRAWAL_SIGNATURE = '/zogux.bridge.MsgSubmitWithdrawalSignature';
|
|
116
|
+
export const TYPE_URL_MSG_MARK_WITHDRAWAL_SUBMITTED = '/zogux.bridge.MsgMarkWithdrawalSubmitted';
|
|
117
|
+
export const TYPE_URL_MSG_CONFIRM_WITHDRAWAL = '/zogux.bridge.MsgConfirmWithdrawal';
|
|
118
|
+
/** @deprecated Use MsgConfirmWithdrawal instead. */
|
|
119
|
+
export const TYPE_URL_MSG_COMPLETE_WITHDRAWAL = '/zogux.bridge.MsgCompleteWithdrawal';
|
|
120
|
+
export const TYPE_URL_MSG_CANCEL_WITHDRAWAL = '/zogux.bridge.MsgCancelWithdrawal';
|
|
121
|
+
|
|
113
122
|
// x/vault
|
|
114
123
|
export const TYPE_URL_MSG_DEPOSIT_TO_MEGAVAULT = '/zogux.vault.MsgDepositToMegavault';
|
|
115
124
|
export const TYPE_URL_MSG_WITHDRAW_FROM_MEGAVAULT = '/zogux.vault.MsgWithdrawFromMegavault';
|
|
@@ -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;
|
|
@@ -2,6 +2,14 @@ import { GeneratedType, Registry } from '@cosmjs/proto-signing';
|
|
|
2
2
|
import { defaultRegistryTypes } from '@cosmjs/stargate';
|
|
3
3
|
import { MsgAddAuthenticator, MsgRemoveAuthenticator } from '@zoguxprotocol/proto/src/codegen/zogux/accountplus/tx';
|
|
4
4
|
import { MsgRegisterAffiliate } from '@zoguxprotocol/proto/src/codegen/zogux/affiliates/tx';
|
|
5
|
+
import {
|
|
6
|
+
MsgRequestWithdrawal,
|
|
7
|
+
MsgSubmitWithdrawalSignature,
|
|
8
|
+
MsgMarkWithdrawalSubmitted,
|
|
9
|
+
MsgConfirmWithdrawal,
|
|
10
|
+
MsgCompleteWithdrawal,
|
|
11
|
+
MsgCancelWithdrawal,
|
|
12
|
+
} from '@zoguxprotocol/proto/src/codegen/zogux/bridge/tss';
|
|
5
13
|
import {
|
|
6
14
|
MsgPlaceOrder,
|
|
7
15
|
MsgCancelOrder,
|
|
@@ -50,6 +58,12 @@ import {
|
|
|
50
58
|
TYPE_URL_MSG_CREATE_MARKET_PERMISSIONLESS,
|
|
51
59
|
TYPE_URL_MSG_ADD_AUTHENTICATOR,
|
|
52
60
|
TYPE_URL_MSG_REMOVE_AUTHENTICATOR,
|
|
61
|
+
TYPE_URL_MSG_REQUEST_WITHDRAWAL,
|
|
62
|
+
TYPE_URL_MSG_SUBMIT_WITHDRAWAL_SIGNATURE,
|
|
63
|
+
TYPE_URL_MSG_MARK_WITHDRAWAL_SUBMITTED,
|
|
64
|
+
TYPE_URL_MSG_CONFIRM_WITHDRAWAL,
|
|
65
|
+
TYPE_URL_MSG_COMPLETE_WITHDRAWAL,
|
|
66
|
+
TYPE_URL_MSG_CANCEL_WITHDRAWAL,
|
|
53
67
|
} from '../constants';
|
|
54
68
|
import { MsgCreateTransfer } from '../types';
|
|
55
69
|
|
|
@@ -92,6 +106,13 @@ export function generateRegistry(): Registry {
|
|
|
92
106
|
// affiliates
|
|
93
107
|
[TYPE_URL_MSG_REGISTER_AFFILIATE, MsgRegisterAffiliate as GeneratedType],
|
|
94
108
|
|
|
109
|
+
// bridge (withdrawal)
|
|
110
|
+
[TYPE_URL_MSG_REQUEST_WITHDRAWAL, MsgRequestWithdrawal as GeneratedType],
|
|
111
|
+
[TYPE_URL_MSG_SUBMIT_WITHDRAWAL_SIGNATURE, MsgSubmitWithdrawalSignature as GeneratedType],
|
|
112
|
+
[TYPE_URL_MSG_MARK_WITHDRAWAL_SUBMITTED, MsgMarkWithdrawalSubmitted as GeneratedType],
|
|
113
|
+
[TYPE_URL_MSG_CONFIRM_WITHDRAWAL, MsgConfirmWithdrawal as GeneratedType],
|
|
114
|
+
[TYPE_URL_MSG_COMPLETE_WITHDRAWAL, MsgCompleteWithdrawal as GeneratedType],
|
|
115
|
+
[TYPE_URL_MSG_CANCEL_WITHDRAWAL, MsgCancelWithdrawal as GeneratedType],
|
|
95
116
|
|
|
96
117
|
// authentication
|
|
97
118
|
[TYPE_URL_MSG_ADD_AUTHENTICATOR, MsgAddAuthenticator as GeneratedType],
|
|
@@ -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';
|
|
@@ -30,6 +31,7 @@ import { Any } from 'cosmjs-types/google/protobuf/any';
|
|
|
30
31
|
import Long from 'long';
|
|
31
32
|
import protobuf from 'protobufjs';
|
|
32
33
|
|
|
34
|
+
import { bigIntToBytes } from '../../lib/helpers';
|
|
33
35
|
import {
|
|
34
36
|
GOV_MODULE_ADDRESS,
|
|
35
37
|
DELAYMSG_MODULE_ADDRESS,
|
|
@@ -55,6 +57,11 @@ import {
|
|
|
55
57
|
TYPE_URL_MSG_WITHDRAW_DELEGATOR_REWARD,
|
|
56
58
|
TYPE_URL_BATCH_CANCEL,
|
|
57
59
|
TYPE_URL_MSG_REGISTER_AFFILIATE,
|
|
60
|
+
TYPE_URL_MSG_REQUEST_WITHDRAWAL,
|
|
61
|
+
TYPE_URL_MSG_SUBMIT_WITHDRAWAL_SIGNATURE,
|
|
62
|
+
TYPE_URL_MSG_MARK_WITHDRAWAL_SUBMITTED,
|
|
63
|
+
TYPE_URL_MSG_CONFIRM_WITHDRAWAL,
|
|
64
|
+
TYPE_URL_MSG_CANCEL_WITHDRAWAL,
|
|
58
65
|
TYPE_URL_MSG_DEPOSIT_TO_MEGAVAULT,
|
|
59
66
|
TYPE_URL_MSG_WITHDRAW_FROM_MEGAVAULT,
|
|
60
67
|
TYPE_URL_MSG_CREATE_MARKET_PERMISSIONLESS,
|
|
@@ -421,6 +428,69 @@ export class Composer {
|
|
|
421
428
|
return { typeUrl: TYPE_URL_MSG_WITHDRAW_FROM_SPOT, value: { sender, recipient, assetId, quantums } };
|
|
422
429
|
}
|
|
423
430
|
|
|
431
|
+
// ------------ x/bridge ------------
|
|
432
|
+
public composeMsgRequestWithdrawal(
|
|
433
|
+
fromAddress: string,
|
|
434
|
+
toAddress: string,
|
|
435
|
+
amount: string,
|
|
436
|
+
chainId: number | Long,
|
|
437
|
+
denom: string,
|
|
438
|
+
nonce: number | Long,
|
|
439
|
+
): EncodeObject {
|
|
440
|
+
const chainIdLong = typeof chainId === 'number' ? Long.fromNumber(chainId) : chainId;
|
|
441
|
+
const nonceLong = typeof nonce === 'number' ? Long.fromNumber(nonce) : nonce;
|
|
442
|
+
return {
|
|
443
|
+
typeUrl: TYPE_URL_MSG_REQUEST_WITHDRAWAL,
|
|
444
|
+
value: { fromAddress, toAddress, amount, chainId: chainIdLong, denom, nonce: nonceLong },
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
public composeMsgSubmitWithdrawalSignature(
|
|
449
|
+
validator: string,
|
|
450
|
+
withdrawalId: string,
|
|
451
|
+
signature: Uint8Array | string,
|
|
452
|
+
): EncodeObject {
|
|
453
|
+
const signatureBytes =
|
|
454
|
+
typeof signature === 'string' ? fromBase64(signature) : signature;
|
|
455
|
+
return {
|
|
456
|
+
typeUrl: TYPE_URL_MSG_SUBMIT_WITHDRAWAL_SIGNATURE,
|
|
457
|
+
value: { validator, withdrawalId, signature: signatureBytes },
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
public composeMsgMarkWithdrawalSubmitted(
|
|
462
|
+
signer: string,
|
|
463
|
+
withdrawalId: string,
|
|
464
|
+
evmTxHash: string,
|
|
465
|
+
): EncodeObject {
|
|
466
|
+
return {
|
|
467
|
+
typeUrl: TYPE_URL_MSG_MARK_WITHDRAWAL_SUBMITTED,
|
|
468
|
+
value: { signer, withdrawalId, evmTxHash },
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
public composeMsgConfirmWithdrawal(
|
|
473
|
+
signer: string,
|
|
474
|
+
withdrawalId: string,
|
|
475
|
+
evmTxHash: string,
|
|
476
|
+
): EncodeObject {
|
|
477
|
+
return {
|
|
478
|
+
typeUrl: TYPE_URL_MSG_CONFIRM_WITHDRAWAL,
|
|
479
|
+
value: { signer, withdrawalId, evmTxHash },
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
public composeMsgCancelWithdrawal(
|
|
484
|
+
authority: string,
|
|
485
|
+
withdrawalId: string,
|
|
486
|
+
reason: string,
|
|
487
|
+
): EncodeObject {
|
|
488
|
+
return {
|
|
489
|
+
typeUrl: TYPE_URL_MSG_CANCEL_WITHDRAWAL,
|
|
490
|
+
value: { authority, withdrawalId, reason },
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
|
|
424
494
|
// ------------ x/bank ------------
|
|
425
495
|
public composeMsgSendToken(
|
|
426
496
|
address: string,
|
|
@@ -576,17 +646,21 @@ export class Composer {
|
|
|
576
646
|
public composeMsgWithdrawFromMegavault(
|
|
577
647
|
address: string,
|
|
578
648
|
subaccountNumber: number,
|
|
579
|
-
shares: Uint8Array,
|
|
580
|
-
minQuoteQuantums: Uint8Array,
|
|
649
|
+
shares: string | Uint8Array,
|
|
650
|
+
minQuoteQuantums: string | Uint8Array,
|
|
581
651
|
): EncodeObject {
|
|
582
652
|
const subaccountId: SubaccountId = {
|
|
583
653
|
owner: address,
|
|
584
654
|
number: subaccountNumber,
|
|
585
655
|
};
|
|
586
656
|
|
|
657
|
+
const sharesBytes = typeof shares === 'string' ? bigIntToBytes(BigInt(shares)) : shares;
|
|
658
|
+
const minQuoteQuantumsBytes =
|
|
659
|
+
typeof minQuoteQuantums === 'string' ? bigIntToBytes(BigInt(minQuoteQuantums)) : minQuoteQuantums;
|
|
660
|
+
|
|
587
661
|
const msg: MsgWithdrawFromMegavault = {
|
|
588
|
-
minQuoteQuantums,
|
|
589
|
-
shares: { numShares:
|
|
662
|
+
minQuoteQuantums: minQuoteQuantumsBytes,
|
|
663
|
+
shares: { numShares: sharesBytes },
|
|
590
664
|
subaccountId,
|
|
591
665
|
};
|
|
592
666
|
|
|
@@ -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
|