Skip to content

Commit 03e7cc4

Browse files
feat: view wallet rewards
1 parent 7ac03ec commit 03e7cc4

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

src/client/client.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,18 @@ export abstract class BaseTNClient<T extends EnvironmentType> {
285285
return bridgeResult.data.tx_hash;
286286
}
287287

288+
/**
289+
* Lists wallet rewards for a specific wallet address on a blockchain network
290+
* @param chain The chain identifier (e.g., "sepolia", "mainnet", "polygon", etc.)
291+
* @param wallet The wallet address to list rewards for
292+
* @param withPending Whether to include pending rewards
293+
* @returns Promise that resolves to an array of rewards data
294+
*/
295+
async listWalletRewards(chain: string, wallet: string, withPending: boolean): Promise<any[]> {
296+
const action = this.loadAction();
297+
return action.listWalletRewards(chain, wallet, withPending);
298+
}
299+
288300
/**
289301
* Gets taxonomies for specific streams in batch.
290302
* High-level wrapper for ComposedAction.getTaxonomiesForStreams()

src/contracts-api/action.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,4 +1030,35 @@ export class Action {
10301030
$amount: amount
10311031
}]);
10321032
}
1033+
1034+
/**
1035+
* Lists wallet rewards on a blockchain network
1036+
* @param chain The chain identifier (e.g., "sepolia", "mainnet", "polygon", etc.)
1037+
* @param wallet The wallet address to list rewards for
1038+
* @param withPending Whether to include pending rewards
1039+
* @returns Promise that resolves to the rewards data
1040+
*/
1041+
public async listWalletRewards(
1042+
chain: string,
1043+
wallet: string,
1044+
withPending: boolean
1045+
): Promise<any[]> {
1046+
const result = await this.kwilClient.call(
1047+
{
1048+
namespace: `${chain}_bridge`,
1049+
name: "list_wallet_rewards",
1050+
inputs: {
1051+
$wallet: wallet,
1052+
$with_pending: withPending,
1053+
},
1054+
},
1055+
this.kwilSigner,
1056+
);
1057+
1058+
if (result.status !== 200) {
1059+
throw new Error(`Failed to list wallet rewards: ${result.status}`);
1060+
}
1061+
1062+
return result.data?.result || [];
1063+
}
10331064
}

0 commit comments

Comments
 (0)