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

add get request for delayed complete bridge messages #45

Merged
merged 2 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6,407 changes: 2,418 additions & 3,989 deletions v4-client-js/__native__/__ios__/v4-native-client.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion v4-client-js/__native__/__ios__/v4-native-client.js.map

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions v4-client-js/examples/validator_get_example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,24 @@ async function test(): Promise<void> {
} catch (error) {
console.log(JSON.stringify(error.message));
}

try {
const delayedCompleteBridgeMessagesParams = await client
.get.getDelayedCompleteBridgeMessages();
console.log('All delayed complete bridge messages');
console.log(JSON.stringify(delayedCompleteBridgeMessagesParams));
} catch (error) {
console.log(JSON.stringify(error.message));
}

try {
const delayedCompleteBridgeMessagesParams = await client
.get.getDelayedCompleteBridgeMessages(DYDX_TEST_ADDRESS);
console.log('Filtered delayed complete bridge messages');
console.log(JSON.stringify(delayedCompleteBridgeMessagesParams));
} catch (error) {
console.log(JSON.stringify(error.message));
}
}

test().then(() => {
Expand Down
18 changes: 9 additions & 9 deletions v4-client-js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions 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": "0.37.3",
"version": "0.38.0",
"description": "General client library for the new dYdX system (v4 decentralized)",
"main": "build/src/index.js",
"scripts": {
Expand Down Expand Up @@ -36,7 +36,7 @@
"@cosmjs/stargate": "^0.30.1",
"@cosmjs/tendermint-rpc": "^0.30.1",
"@cosmjs/utils": "^0.31.1",
"@dydxprotocol/v4-proto": "^0.2.1",
"@dydxprotocol/v4-proto": "^0.3.0-dev.1",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only concern here is if we bump v4-proto again, the bridge feature would be lost.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

umm yea will resync and see we can actually publish a non dev version, otherwise doing it to unblock dev work for now

"@osmonauts/lcd": "^0.6.0",
"@scure/bip32": "^1.1.5",
"@scure/bip39": "^1.1.1",
Expand Down
20 changes: 20 additions & 0 deletions v4-client-js/src/clients/modules/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import protobuf from 'protobufjs';
import { PAGE_REQUEST } from '../constants';
import { UnexpectedClientError } from '../lib/errors';
import {
BridgeModule,
ClobModule,
FeeTierModule,
PerpetualsModule,
Expand Down Expand Up @@ -406,6 +407,25 @@ export class Get {
return StakingModule.QueryDelegatorUnbondingDelegationsResponse.decode(data);
}

/**
* @description Get all delayed complete bridge messages, optionally filtered by address.
*
* @returns Information on all delayed complete bridge messages.
*/
async getDelayedCompleteBridgeMessages(
address: string = '',
): Promise<BridgeModule.QueryDelayedCompleteBridgeMessagesResponse> {
const requestData: Uint8Array = Uint8Array.from(
BridgeModule.QueryDelayedCompleteBridgeMessagesRequest.encode({ address }).finish(),
);

const data: Uint8Array = await this.sendQuery(
'/dydxprotocol.bridge.Query/QueryDelayedCompleteBridgeMessages',
requestData,
);
return BridgeModule.QueryDelayedCompleteBridgeMessagesResponse.decode(data);
}

private async sendQuery(requestUrl: string, requestData: Uint8Array): Promise<Uint8Array> {
return this.stargateQueryClient.queryUnverified(requestUrl, requestData);
}
Expand Down
1 change: 1 addition & 0 deletions v4-client-js/src/clients/modules/proto-includes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export * as FeeTierModule from '@dydxprotocol/v4-proto/src/codegen/dydxprotocol/
export * as StatsModule from '@dydxprotocol/v4-proto/src/codegen/dydxprotocol/stats/query';
export * as RewardsModule from '@dydxprotocol/v4-proto/src/codegen/dydxprotocol/rewards/query';
export * as StakingModule from '@dydxprotocol/v4-proto/src/codegen/cosmos/staking/v1beta1/query';
export * as BridgeModule from '@dydxprotocol/v4-proto/src/codegen/dydxprotocol/bridge/query';

export * from '@dydxprotocol/v4-proto/src/codegen/cosmos/base/abci/v1beta1/abci';
export * from '@dydxprotocol/v4-proto/src/codegen/dydxprotocol/clob/order';
Expand Down