-
Notifications
You must be signed in to change notification settings - Fork 18
/
client.d.ts
197 lines (197 loc) · 5.87 KB
/
client.d.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
import * as consts from './types/constants';
import * as modules from './modules';
import { RpcClient } from './nets/rpc-client';
import { AxiosRequestConfig } from 'axios';
import * as types from './types';
import { Wallet } from "./types";
/** IRISHub Client */
export declare class Client {
/** IRISHub Client Config */
config: DefaultClientConfig;
/** Axios client for tendermint rpc requests */
private _rpcClient?;
get rpcClient(): RpcClient;
/** Auth module */
private _auth?;
get auth(): modules.Auth;
/** Token module */
private _token?;
get token(): modules.Token;
/** Bank module */
private _bank?;
get bank(): modules.Bank;
/** Key management module */
private _keys?;
get keys(): modules.Keys;
/** Protobuf module */
private _protobuf?;
get protobuf(): modules.Protobuf;
/** Staking module */
private _staking?;
get staking(): modules.Staking;
/** Tx module */
private _tx?;
get tx(): modules.Tx;
/** Gov module */
private _gov?;
get gov(): modules.Gov;
/** Slashing module */
private _slashing?;
get slashing(): modules.Slashing;
/** Distribution module */
private _distribution?;
get distribution(): modules.Distribution;
/** Service module */
/** Oracle module */
/** Random module */
/** Utils module */
private _utils?;
get utils(): modules.Utils;
/** Tendermint module */
private _tendermint?;
get tendermint(): modules.Tendermint;
/** Coinswap module */
private _coinswap?;
get coinswap(): modules.Coinswap;
/** Farm module */
private _farm?;
get farm(): modules.Farm;
/** NFT module */
private _nft?;
get nft(): modules.Nft;
/** Htlc module */
private _htlc?;
get htlc(): modules.Htlc;
/** Ibc module */
private _ibc?;
get ibc(): modules.Ibc;
/** Ibc nft transfer module */
private _ibcNftTransfer?;
get ibcNftTransfer(): modules.IbcNftTransfer;
/** IRISHub SDK Constructor */
constructor(config: DefaultClientConfig);
/**
* Set Key DAO Implemention
*
* @param keyDAO Key DAO Implemention
* @returns The SDK itself
*/
withKeyDAO(keyDAO: KeyDAO): this;
/**
* Set IRISHub network type
*
* @param network IRISHub network type, mainnet / testnet
* @returns The SDK itself
*/
withChainNetwork(chainNetwork: consts.ChainNetwork): this;
/**
* Set IRISHub chain-id
*
* @param chainId IRISHub chain-id
* @returns The SDK itself
*/
withChainId(chainId: string): this;
/**
* Set default gas limit
*
* @param gas Default gas limit
* @returns The SDK itself
*/
withGas(gas: string): this;
/**
* Set default fees
*
* @param fee Default fee amount
* @returns The SDK itself
*/
withFee(fee: types.Coin): this;
/**
* Set Axios config for tendermint rpc requests, refer to: https://github.com/axios/axios#request-config.
*
* Note the `baseURL` is set by `SdkConfig.node` and cannot be overwritten by this config
*
* @param rpcConfig Axios config for tendermint rpc requests
* @returns The SDK itself
*/
withRpcConfig(rpcConfig: AxiosRequestConfig): this;
}
/** IRISHub SDK Config */
export interface ClientConfig {
/** IRISHub node rpc address */
node: string;
/** IRISHUB = 0, Cosmos = 1, Akash = 2 */
chainNetwork?: consts.ChainNetwork;
/** IRISHub chain-id */
chainId?: string;
/** Default gas limit */
gas?: string;
/** Default fee amount */
fee?: types.Coin;
/** Key DAO Implemention */
keyDAO?: KeyDAO;
/** Bech32 prefix of the network, will be overwritten by network type */
bech32Prefix?: types.Bech32Prefix;
/** Axios request config for tendermint rpc requests */
rpcConfig?: AxiosRequestConfig;
}
/** Default IRISHub Client Config */
export declare class DefaultClientConfig implements ClientConfig {
node: string;
chainNetwork: consts.ChainNetwork;
chainId: string;
gas: string;
fee: types.Coin;
keyDAO: KeyDAO;
bech32Prefix: types.Bech32Prefix;
rpcConfig: AxiosRequestConfig;
constructor();
}
/**
* Key DAO Interface, to be implemented by apps if they need the key management.
*/
export interface KeyDAO {
/**
* Save the encrypted private key to app
*
* @param name Name of the key
* @param key The encrypted private key object
* @throws `SdkError` if the save fails.
*/
write(name: string, key: Wallet): void;
/**
* Get the encrypted private key by name
*
* @param name Name of the key
* @returns The encrypted private key object or undefined
*/
read(name: string): Wallet;
/**
* Delete the key by name
* @param name Name of the key
* @throws `SdkError` if the deletion fails.
*/
delete?(name: string): void;
/**
* Optional function to encrypt the private key by yourself. Default to AES Encryption
* @param privKey The plain private key
* @param password The password to encrypt the private key
* @returns The encrypted private key
* @throws `SdkError` if encrypt failed
*/
encrypt?(privKey: string, password: string): string;
/**
* Optional function to decrypt the private key by yourself. Default to AES Decryption
* @param encrptedPrivKey The encrpted private key
* @param password The password to decrypt the private key
* @returns The plain private key
* @throws `SdkError` if decrypt failed
*/
decrypt?(encrptedPrivKey: string, password: string): string;
}
export declare class DefaultKeyDAOImpl implements KeyDAO {
write(name: string, key: Wallet): void;
read(name: string): Wallet;
delete(name: string): void;
encrypt(privKey: string, password: string): string;
decrypt(encrptedPrivKey: string, password: string): string;
}