-
Notifications
You must be signed in to change notification settings - Fork 22
/
FeeGrantAPI.ts
86 lines (82 loc) 路 2.39 KB
/
FeeGrantAPI.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import { AccAddress } from '../../../core';
import { BaseAPI } from './BaseAPI';
import { Allowance } from '../../../core/feegrant/allowances';
import { Pagination, PaginationOptions } from '../APIRequester';
import { LCDClient } from '../LCDClient';
export class FeeGrantAPI extends BaseAPI {
constructor(public lcd: LCDClient) {
super(lcd.apiRequesters, lcd.config);
}
public async allowances(
grantee: AccAddress,
params: Partial<PaginationOptions> = {}
): Promise<{
allowances: {
granter: AccAddress;
grantee: AccAddress;
allowance: Allowance;
}[];
pagination: Pagination;
}> {
return this.getReqFromAddress(grantee)
.get<{
allowances: {
granter: AccAddress;
grantee: AccAddress;
allowance: Allowance.Data;
}[];
pagination: Pagination;
}>(`/cosmos/feegrant/v1beta1/allowances/${grantee}`, params)
.then(d => ({
allowances: d.allowances.map(allowance => ({
granter: allowance.granter,
grantee: allowance.grantee,
allowance: Allowance.fromData(allowance.allowance),
})),
pagination: d.pagination,
}));
}
public async allowance(
granter: AccAddress,
grantee: AccAddress
): Promise<Allowance> {
return this.getReqFromAddress(grantee)
.get<{
allowance: {
granter: AccAddress;
grantee: AccAddress;
allowance: Allowance.Data;
};
}>(`/cosmos/feegrant/v1beta1/allowance/${granter}/${grantee}`)
.then(d => Allowance.fromData(d.allowance.allowance));
}
public async allowancesByGranter(
granter: AccAddress,
params: Partial<PaginationOptions> = {}
): Promise<{
allowances: {
granter: AccAddress;
grantee: AccAddress;
allowance: Allowance;
}[];
pagination: Pagination;
}> {
return this.getReqFromAddress(granter)
.get<{
allowances: {
granter: AccAddress;
grantee: AccAddress;
allowance: Allowance.Data;
}[];
pagination: Pagination;
}>(`/cosmos/feegrant/v1beta1/issued/${granter}`, params)
.then(d => ({
allowances: d.allowances.map(allowance => ({
granter: allowance.granter,
grantee: allowance.grantee,
allowance: Allowance.fromData(allowance.allowance),
})),
pagination: d.pagination,
}));
}
}