Skip to content

Commit

Permalink
Deposit/withdraw fee setting (#26)
Browse files Browse the repository at this point in the history
* deposit/withdraw with fees

* patch version

* remove zerofee
  • Loading branch information
rosepuppy authored Sep 8, 2023
1 parent cfdc9f2 commit 7dd1f9a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 24 deletions.
16 changes: 8 additions & 8 deletions v4-client-js/__native__/__ios__/v4-native-client.js

Large diffs are not rendered by default.

14 changes: 5 additions & 9 deletions v4-client-js/__tests__/modules/client/Transfers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@ describe('Validator Client', () => {
let subaccount: Subaccount;
let client: ValidatorClient;

describe('Transfers', async () => {
describe('Transfers', () => {
beforeEach(async () => {
wallet = await LocalWallet.fromMnemonic(DYDX_TEST_MNEMONIC, BECH32_PREFIX);
subaccount = new Subaccount(wallet, 0);
client = await ValidatorClient.connect(Network.staging().validatorConfig);
await sleep(5000); // wait for withdraw to complete
});

it('Withdraw', async () => {
const tx = await client.post.withdraw(
subaccount,
0,
new Long(1_00_000_000),
undefined,
);
console.log('**Withdraw Tx**');
console.log(tx);
});

await sleep(5000); // wait for withdraw to complete

it('Deposit', async () => {
const tx = await client.post.deposit(
subaccount,
Expand All @@ -42,10 +42,7 @@ describe('Validator Client', () => {
);
console.log('**Deposit Tx**');
console.log(tx);
},
);

await sleep(5000); // wait for withdraw to complete
});

it('Transfer', async () => {
const tx = await client.post.transfer(
Expand All @@ -57,7 +54,6 @@ describe('Validator Client', () => {
);
console.log('**Transfer Tx**');
console.log(tx);
},
);
});
});
});
1 change: 0 additions & 1 deletion v4-client-js/examples/transfer_example_withdraw_other.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ async function test(): Promise<void> {
0,
amountAfterFee,
TEST_RECIPIENT_ADDRESS,
false,
Method.BroadcastTxCommit,
);
console.log('**Withdraw and Send**');
Expand Down
4 changes: 2 additions & 2 deletions v4-client-js/src/clients/composite-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ export class CompositeClient {
});
return this.validatorClient.post.send(subaccount.wallet,
() => msgs,
true);
false);
}

/**
Expand Down Expand Up @@ -512,7 +512,7 @@ export class CompositeClient {
return this.send(
subaccount.wallet,
() => msgs,
true);
false);
}

/**
Expand Down
7 changes: 3 additions & 4 deletions v4-client-js/src/clients/modules/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ export class Post {
);
resolve([msg]);
});
return this.send(subaccount.wallet, () => msgs, true, undefined, undefined, broadcastMode);
return this.send(subaccount.wallet, () => msgs, false, undefined, undefined, broadcastMode);
}

async deposit(
Expand All @@ -433,15 +433,14 @@ export class Post {
);
resolve([msg]);
});
return this.send(subaccount.wallet, () => msgs, true, undefined, undefined, broadcastMode);
return this.send(subaccount.wallet, () => msgs, false, undefined, undefined, broadcastMode);
}

async withdraw(
subaccount: Subaccount,
assetId: number,
quantums: Long,
recipient?: string,
zeroFee: boolean = true,
broadcastMode?: BroadcastMode,
): Promise<BroadcastTxAsyncResponse | BroadcastTxSyncResponse | IndexedTx> {
const msgs: Promise<EncodeObject[]> = new Promise((resolve) => {
Expand All @@ -454,7 +453,7 @@ export class Post {
);
resolve([msg]);
});
return this.send(subaccount.wallet, () => msgs, zeroFee, undefined, undefined, broadcastMode);
return this.send(subaccount.wallet, () => msgs, false, undefined, undefined, broadcastMode);
}

async sendToken(
Expand Down

0 comments on commit 7dd1f9a

Please sign in to comment.