Skip to content

Commit

Permalink
Add getDelegationTotalRewards call for mobile (#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruixhuang authored Jul 25, 2024
1 parent 06f9c28 commit 8996a3a
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 5 deletions.
24 changes: 22 additions & 2 deletions v4-client-js/__native__/__ios__/v4-native-client.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions v4-client-js/package-lock.json

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

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.1.29",
"version": "1.1.30",
"description": "General client library for the new dYdX system (v4 decentralized)",
"main": "build/src/index.js",
"scripts": {
Expand Down
19 changes: 19 additions & 0 deletions v4-client-js/src/clients/native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,25 @@ export async function getDelegatorDelegations(payload: string): Promise<string>
}
}

export async function getStakingRewards(payload: string): Promise<string> {
try {
const client = globalThis.client;
if (client === undefined) {
throw new UserError('client is not connected. Call connectClient() first');
}
const json = JSON.parse(payload);
const address = json.address;
if (address === undefined) {
throw new UserError('address is not set');
}
const delegations =
await globalThis.client?.validatorClient.get.getDelegationTotalRewards(address);
return encodeJson(delegations);
} catch (e) {
return wrappedError(e);
}
}

export async function getCurrentUnstaking(payload: string): Promise<string> {
try {
const client = globalThis.client;
Expand Down

0 comments on commit 8996a3a

Please sign in to comment.