Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
feat: Get tx filter type
Browse files Browse the repository at this point in the history
  • Loading branch information
riskers committed Oct 20, 2022
1 parent 041b3fa commit b1a013b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ export type API_NAME = keyof typeof API_MAP;
export type URL_INFO = typeof API_MAP[API_NAME];

export interface IReqParmsMap {
[API_MAP.GetTxsByAccount]: IReqBaseParam &
(
[API_MAP.GetTxsByAccount]: IReqBaseParam & {
type: Zk.TxType;
} & (
| {
value: Zk.PublicKey;
by: 'account_pk';
Expand Down
39 changes: 36 additions & 3 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,21 @@ export class Client {
/**
* returns txs by account public key
*/
async getTxsByAccountPk(accountPk: Zk.AccountPk, offset: number, limit: number) {
async getTxsByAccountPk({
accountPk,
type,
offset,
limit,
}: {
accountPk: Zk.AccountPk;
type: Zk.TxType;
offset: number;
limit: number;
}) {
return await this.http.req(API.API_MAP.GetTxsByAccount, {
value: accountPk,
by: 'account_pk',
type,
offset,
limit,
});
Expand All @@ -31,10 +42,21 @@ export class Client {
/**
* returns txs by account account name
*/
async getTxsByAccountName(accountName: string, offset: number, limit: number) {
async getTxsByAccountName({
accountName,
type,
offset,
limit,
}: {
accountName: string;
type: Zk.TxType;
offset: number;
limit: number;
}) {
return await this.http.req(API.API_MAP.GetTxsByAccount, {
value: accountName,
by: 'account_name',
type,
offset,
limit,
});
Expand All @@ -43,10 +65,21 @@ export class Client {
/**
* returns txs by account account index
*/
async getTxsByAccountIndex(accountIndex: Zk.AccountIndex, offset: number, limit: number) {
async getTxsByAccountIndex({
accountIndex,
type,
offset,
limit,
}: {
accountIndex: Zk.AccountIndex;
type: Zk.TxType;
offset: number;
limit: number;
}) {
return this.http.req(API.API_MAP.GetTxsByAccount, {
by: 'account_index',
value: accountIndex,
type,
offset,
limit,
});
Expand Down

0 comments on commit b1a013b

Please sign in to comment.