-
Notifications
You must be signed in to change notification settings - Fork 1
/
getDeposits.ts
38 lines (31 loc) · 903 Bytes
/
getDeposits.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
import {invariant} from '@spinfi/shared';
import {nearErrorMessage, contractIdErrorMessage} from './messages';
import {createView} from '../../utils/createView';
/**
* @category getDeposits
*/
export type GetDepositsResponse = Record<string, string>;
/**
* @category getDeposits
*/
export interface GetDepositsRequest {
/**
* Account ID
*/
accountId: string;
}
const METHOD_NAME = 'get_deposits';
export const getDeposits = createView<GetDepositsRequest, GetDepositsResponse>(({methodify}) => {
const createMethod = methodify((config) => {
return async (request) => {
invariant(config.near, nearErrorMessage('getDeposits'));
invariant(config.contractId, contractIdErrorMessage('getDeposits'));
return await config.near.view(config.contractId, METHOD_NAME, {
account_id: request.accountId,
});
};
});
return {
createMethod,
};
});