Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide interface to send multiple Msg per transaction [do not merge] #134

Closed
wants to merge 11 commits into from
983 changes: 691 additions & 292 deletions v4-client-js/__native__/__ios__/v4-native-client.js

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions v4-client-js/examples/composite_example.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { BECH32_PREFIX } from '../src';
import {
BECH32_PREFIX, OrderExecution, OrderSide, OrderTimeInForce, OrderType,
} from '../src';
import { CompositeClient } from '../src/clients/composite-client';
import {
Network, OrderExecution, OrderSide, OrderTimeInForce, OrderType,
Network,
} from '../src/clients/constants';
import LocalWallet from '../src/clients/modules/local-wallet';
import { SubaccountInfo } from '../src/clients/subaccount';
6 changes: 4 additions & 2 deletions v4-client-js/examples/long_term_order_cancel_example.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { BECH32_PREFIX, OrderFlags } from '../src';
import {
BECH32_PREFIX, OrderExecution, OrderFlags, OrderSide, OrderTimeInForce, OrderType,
} from '../src';
import { CompositeClient } from '../src/clients/composite-client';
import {
Network, OrderExecution, OrderSide, OrderTimeInForce, OrderType,
Network,
} from '../src/clients/constants';
import LocalWallet from '../src/clients/modules/local-wallet';
import { SubaccountInfo } from '../src/clients/subaccount';
6 changes: 4 additions & 2 deletions v4-client-js/examples/short_term_order_cancel_example.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { BECH32_PREFIX, OrderFlags, Order_TimeInForce } from '../src';
import {
BECH32_PREFIX, OrderFlags, OrderSide, Order_TimeInForce,
} from '../src';
import { CompositeClient } from '../src/clients/composite-client';
import {
Network, OrderSide,
Network,
} from '../src/clients/constants';
import LocalWallet from '../src/clients/modules/local-wallet';
import { SubaccountInfo } from '../src/clients/subaccount';
4 changes: 2 additions & 2 deletions v4-client-js/examples/short_term_order_composite_example.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Order_TimeInForce } from '@dydxprotocol/v4-proto/src/codegen/dydxprotocol/clob/order';

import { BECH32_PREFIX } from '../src';
import { BECH32_PREFIX, OrderExecution, OrderSide } from '../src';
import { CompositeClient } from '../src/clients/composite-client';
import {
Network, OrderExecution, OrderSide,
Network,
} from '../src/clients/constants';
import LocalWallet from '../src/clients/modules/local-wallet';
import { SubaccountInfo } from '../src/clients/subaccount';
6 changes: 4 additions & 2 deletions v4-client-js/examples/test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { BECH32_PREFIX } from '../src';
import {
BECH32_PREFIX, OrderExecution, OrderSide, OrderTimeInForce, OrderType,
} from '../src';
import { CompositeClient } from '../src/clients/composite-client';
import {
Network, OrderExecution, OrderSide, OrderTimeInForce, OrderType,
Network,
} from '../src/clients/constants';
import LocalWallet from '../src/clients/modules/local-wallet';
import { SubaccountInfo } from '../src/clients/subaccount';
18 changes: 17 additions & 1 deletion v4-client-js/examples/transfer_example_deposit.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import Long from 'long';

import { BECH32_PREFIX } from '../src';
import { BECH32_PREFIX, IDeposit } from '../src';
import { Network } from '../src/clients/constants';
import LocalWallet from '../src/clients/modules/local-wallet';
import { TransactionMsg, TransactionType } from '../src/clients/modules/post';
import { SubaccountInfo } from '../src/clients/subaccount';
import { ValidatorClient } from '../src/clients/validator-client';
import { DYDX_TEST_MNEMONIC } from './constants';
@@ -23,6 +24,21 @@ async function test(): Promise<void> {
);
console.log('**Deposit Tx**');
console.log(tx);

const params: IDeposit = {
quantums: new Long(10_000_000),
assetId: 0,
};
const tx2 = await client.post.sendMsg(
subaccount,
new TransactionMsg(
TransactionType.DEPOSIT,
params,
false,
),
);
console.log('**Deposit Tx**');
console.log(tx2);
}

test().then(() => {
20 changes: 19 additions & 1 deletion v4-client-js/examples/transfer_example_subaccount_transfer.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import Long from 'long';

import { BECH32_PREFIX } from '../src';
import { BECH32_PREFIX, ITransfer } from '../src';
import { Network } from '../src/clients/constants';
import LocalWallet from '../src/clients/modules/local-wallet';
import { TransactionMsg, TransactionType } from '../src/clients/modules/post';
import { SubaccountInfo } from '../src/clients/subaccount';
import { ValidatorClient } from '../src/clients/validator-client';
import { DYDX_TEST_MNEMONIC } from './constants';
@@ -26,6 +27,23 @@ async function test(): Promise<void> {
);
console.log('**Transfer Tx**');
console.log(tx);

const params: ITransfer = {
recipientAddress: wallet.address!!,
recipientSubaccountNumber: 0,
assetId: 0,
amount: new Long(10_000_000),
};
const tx2 = await client.post.sendMsg(
subaccount,
new TransactionMsg(
TransactionType.TRANSFER,
params,
false,
),
);
console.log('**Withdraw Tx**');
console.log(tx2);
}

test().then(() => {
19 changes: 18 additions & 1 deletion v4-client-js/examples/transfer_example_withdraw.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import Long from 'long';

import { BECH32_PREFIX } from '../src';
import { BECH32_PREFIX, IWithdraw } from '../src';
import { Network } from '../src/clients/constants';
import LocalWallet from '../src/clients/modules/local-wallet';
import { TransactionMsg, TransactionType } from '../src/clients/modules/post';
import { SubaccountInfo } from '../src/clients/subaccount';
import { ValidatorClient } from '../src/clients/validator-client';
import { DYDX_TEST_MNEMONIC } from './constants';
@@ -26,6 +27,22 @@ async function test(): Promise<void> {
);
console.log('**Withdraw Tx**');
console.log(tx);

const params: IWithdraw = {
quantums: new Long(10_000_000),
assetId: 0,
recipient: wallet.address,
};
const tx2 = await client.post.sendMsg(
subaccount,
new TransactionMsg(
TransactionType.WITHDRAW,
params,
false,
),
);
console.log('**Withdraw Tx**');
console.log(tx2);
}

test().then(() => {
2 changes: 1 addition & 1 deletion v4-client-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dydxprotocol/v4-client-js",
"version": "1.0.27",
"version": "1.0.28",
"description": "General client library for the new dYdX system (v4 decentralized)",
"main": "build/src/index.js",
"scripts": {
Loading