@xchainjs/xchain-thorchain 1.0.11 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.d.ts CHANGED
@@ -5,7 +5,6 @@ import { StdFee } from '@cosmjs/amino';
5
5
  import { AssetInfo, Network, PreparedTx, TxHash, TxParams } from '@xchainjs/xchain-client';
6
6
  import { Client as CosmosSDKClient, CosmosSdkClientParams, MsgTypes } from '@xchainjs/xchain-cosmos-sdk';
7
7
  import { Address, Asset } from '@xchainjs/xchain-util';
8
- import { BigNumber } from 'bignumber.js';
9
8
  import { DepositParam, DepositTx, TxOfflineParams } from './types';
10
9
  /**
11
10
  * Interface for custom Thorchain client
@@ -20,28 +19,15 @@ export interface ThorchainClient {
20
19
  */
21
20
  export type ThorchainClientParams = Partial<CosmosSdkClientParams>;
22
21
  /**
23
- * Thorchain client
22
+ * Thorchain base client
24
23
  */
25
- export declare class Client extends CosmosSDKClient implements ThorchainClient {
24
+ export declare abstract class Client extends CosmosSDKClient implements ThorchainClient {
26
25
  /**
27
26
  * Thorchain client constructor
28
27
  *
29
28
  * @param {ThorchainClientParams} config Optional - Client configuration. If it is not set, default values will be used
30
29
  */
31
30
  constructor(config?: ThorchainClientParams);
32
- /**
33
- * Asynchronous version of getAddress method.
34
- * @param {number} index Derivation path index of the address to be generated.
35
- * @returns {string} A promise that resolves to the generated address.
36
- */
37
- getAddressAsync(index?: number): Promise<string>;
38
- /**
39
- * Get the address derived from the provided phrase.
40
- * @param {number | undefined} walletIndex The index of the address derivation path. Default is 0.
41
- * @returns {string} The user address at the specified walletIndex.
42
- */
43
- getAddress(walletIndex?: number | undefined): string;
44
- transfer(params: TxParams): Promise<string>;
45
31
  /**
46
32
  * Get address prefix by network
47
33
  * @param {Network} network The network of which return the prefix
@@ -104,44 +90,6 @@ export declare class Client extends CosmosSDKClient implements ThorchainClient {
104
90
  prepareTx({ sender, recipient, asset, amount, memo, }: TxParams & {
105
91
  sender: Address;
106
92
  }): Promise<PreparedTx>;
107
- /**
108
- * Make a deposit
109
- *
110
- * @param {number} param.walletIndex Optional - The index to use to generate the address from the transaction will be done.
111
- * If it is not set, address associated with index 0 will be used
112
- * @param {Asset} param.asset Optional - The asset that will be deposit. If it is not set, Thorchain native asset will be
113
- * used
114
- * @param {BaseAmount} param.amount The amount that will be deposit
115
- * @param {string} param.memo Optional - The memo associated with the deposit
116
- * @param {BigNumber} param.gasLimit Optional - The limit amount of gas allowed to spend in the deposit. If not set, default
117
- * value of 600000000 will be used
118
- * @returns {string} The deposit hash
119
- */
120
- deposit({ walletIndex, asset, amount, memo, gasLimit, }: DepositParam): Promise<string>;
121
- /**
122
- * Create and sign transaction without broadcasting it
123
- *
124
- * @deprecated Use prepare Tx instead
125
- */
126
- transferOffline({ walletIndex, recipient, asset, amount, memo, gasLimit, }: TxOfflineParams & {
127
- gasLimit?: BigNumber;
128
- }): Promise<string>;
129
- /**
130
- * Returns the private key associated with an index
131
- *
132
- * @param {number} index Optional - The index to use to generate the private key. If it is not set, address associated with
133
- * index 0 will be used
134
- * @returns {Uint8Array} The private key
135
- */
136
- getPrivateKey(index?: number): Promise<Uint8Array>;
137
- /**
138
- * Returns the compressed public key associated with an index
139
- *
140
- * @param {number} index Optional - The index to use to generate the private key. If it is not set, address associated with
141
- * index 0 will be used
142
- * @returns {Uint8Array} The public key
143
- */
144
- getPubKey(index?: number): Promise<Uint8Array>;
145
93
  /**
146
94
  * Get deposit transaction
147
95
  *
@@ -162,41 +110,6 @@ export declare class Client extends CosmosSDKClient implements ThorchainClient {
162
110
  * @returns {StdFee} the standard fee
163
111
  */
164
112
  protected getStandardFee(): StdFee;
165
- /**
166
- * Hashes a buffer using SHA256 followed by RIPEMD160 or RMD160.
167
- * @param {Uint8Array} buffer The buffer to hash
168
- * @returns {Uint8Array} The hashed buffer
169
- */
170
- private hash160;
171
- /**
172
- * Sign a transaction making a round robin over the clients urls provided to the client
173
- *
174
- * @param {string} sender Sender address
175
- * @param {DecodedTxRaw} unsignedTx Unsigned transaction
176
- * @param {DirectSecp256k1HdWallet} signer Signer
177
- * @param {BigNumber} gasLimit Transaction gas limit
178
- * @returns {TxRaw} The raw signed transaction
179
- */
180
- private roundRobinSign;
181
- /**
182
- * Sign and broadcast a transaction making a round robin over the clients urls provided to the client
183
- *
184
- * @param {string} sender Sender address
185
- * @param {DecodedTxRaw} unsignedTx Unsigned transaction
186
- * @param {DirectSecp256k1HdWallet} signer Signer
187
- * @returns {DeliverTxResponse} The transaction broadcasted
188
- */
189
- private roundRobinSignAndBroadcastTx;
190
- /**
191
- * Sign and broadcast a transaction making a round robin over the clients urls provided to the client
192
- *
193
- * @param {string} sender Sender address
194
- * @param {DirectSecp256k1HdWallet} signer Signer
195
- * @param {BigNumber} gasLimit Gas limit for the transaction
196
- * @param {BaseAmount} amount Amount to deposit
197
- * @param {string} memo Deposit memo
198
- * @param {Asset} asset Asset to deposit
199
- * @returns {DeliverTxResponse} The transaction broadcasted
200
- */
201
- private roundRobinSignAndBroadcastDeposit;
113
+ abstract deposit(params: DepositParam): Promise<string>;
114
+ abstract transferOffline(params: TxOfflineParams): Promise<string>;
202
115
  }
@@ -0,0 +1,97 @@
1
+ import { TxParams } from '@xchainjs/xchain-client';
2
+ import { BigNumber } from 'bignumber.js';
3
+ import { Client } from './client';
4
+ import { DepositParam, TxOfflineParams } from './types';
5
+ /**
6
+ * Thorchain Keystore client
7
+ */
8
+ export declare class ClientKeystore extends Client {
9
+ /**
10
+ * Asynchronous version of getAddress method.
11
+ * @param {number} index Derivation path index of the address to be generated.
12
+ * @returns {string} A promise that resolves to the generated address.
13
+ */
14
+ getAddressAsync(index?: number): Promise<string>;
15
+ /**
16
+ * Get the address derived from the provided phrase.
17
+ * @param {number | undefined} walletIndex The index of the address derivation path. Default is 0.
18
+ * @returns {string} The user address at the specified walletIndex.
19
+ */
20
+ getAddress(walletIndex?: number): string;
21
+ /**
22
+ * Returns the private key associated with an index
23
+ *
24
+ * @param {number} index Optional - The index to use to generate the private key. If it is not set, address associated with
25
+ * index 0 will be used
26
+ * @returns {Uint8Array} The private key
27
+ */
28
+ getPrivateKey(index?: number): Promise<Uint8Array>;
29
+ /**
30
+ * Returns the compressed public key associated with an index
31
+ *
32
+ * @param {number} index Optional - The index to use to generate the private key. If it is not set, address associated with
33
+ * index 0 will be used
34
+ * @returns {Uint8Array} The public key
35
+ */
36
+ getPubKey(index?: number): Promise<Uint8Array>;
37
+ transfer(params: TxParams): Promise<string>;
38
+ /**
39
+ * Make a deposit
40
+ *
41
+ * @param {number} param.walletIndex Optional - The index to use to generate the address from the transaction will be done.
42
+ * If it is not set, address associated with index 0 will be used
43
+ * @param {Asset} param.asset Optional - The asset that will be deposit. If it is not set, Thorchain native asset will be
44
+ * used
45
+ * @param {BaseAmount} param.amount The amount that will be deposit
46
+ * @param {string} param.memo Optional - The memo associated with the deposit
47
+ * @param {BigNumber} param.gasLimit Optional - The limit amount of gas allowed to spend in the deposit. If not set, default
48
+ * value of 600000000 will be used
49
+ * @returns {string} The deposit hash
50
+ */
51
+ deposit({ walletIndex, asset, amount, memo, gasLimit, }: DepositParam): Promise<string>;
52
+ /**
53
+ * Create and sign transaction without broadcasting it
54
+ *
55
+ * @deprecated Use prepare Tx instead
56
+ */
57
+ transferOffline({ walletIndex, recipient, asset, amount, memo, gasLimit, }: TxOfflineParams & {
58
+ gasLimit?: BigNumber;
59
+ }): Promise<string>;
60
+ /**
61
+ * Hashes a buffer using SHA256 followed by RIPEMD160 or RMD160.
62
+ * @param {Uint8Array} buffer The buffer to hash
63
+ * @returns {Uint8Array} The hashed buffer
64
+ */
65
+ private hash160;
66
+ /**
67
+ * Sign a transaction making a round robin over the clients urls provided to the client
68
+ *
69
+ * @param {string} sender Sender address
70
+ * @param {DecodedTxRaw} unsignedTx Unsigned transaction
71
+ * @param {DirectSecp256k1HdWallet} signer Signer
72
+ * @param {BigNumber} gasLimit Transaction gas limit
73
+ * @returns {TxRaw} The raw signed transaction
74
+ */
75
+ private roundRobinSign;
76
+ /**
77
+ * Sign and broadcast a transaction making a round robin over the clients urls provided to the client
78
+ *
79
+ * @param {string} sender Sender address
80
+ * @param {DecodedTxRaw} unsignedTx Unsigned transaction
81
+ * @param {DirectSecp256k1HdWallet} signer Signer
82
+ * @returns {DeliverTxResponse} The transaction broadcasted
83
+ */
84
+ private roundRobinSignAndBroadcastTx;
85
+ /**
86
+ * Sign and broadcast a transaction making a round robin over the clients urls provided to the client
87
+ *
88
+ * @param {string} sender Sender address
89
+ * @param {DirectSecp256k1HdWallet} signer Signer
90
+ * @param {BigNumber} gasLimit Gas limit for the transaction
91
+ * @param {BaseAmount} amount Amount to deposit
92
+ * @param {string} memo Deposit memo
93
+ * @param {Asset} asset Asset to deposit
94
+ * @returns {DeliverTxResponse} The transaction broadcasted
95
+ */
96
+ private roundRobinSignAndBroadcastDeposit;
97
+ }
@@ -0,0 +1,70 @@
1
+ import Transport from '@ledgerhq/hw-transport';
2
+ import { TxParams } from '@xchainjs/xchain-client';
3
+ import { Client, ThorchainClientParams } from './client';
4
+ import { DepositParam } from './types';
5
+ /**
6
+ * Thorchain Ledger client
7
+ */
8
+ export declare class ClientLedger extends Client {
9
+ private app;
10
+ constructor(params: ThorchainClientParams & {
11
+ transport: Transport;
12
+ });
13
+ /**
14
+ * Asynchronous version of getAddress method.
15
+ * @param {number} index Derivation path index of the address to be generated.
16
+ * @param {boolean} verify True to check the address against the Ledger device, otherwise false
17
+ * @returns {string} A promise that resolves to the generated address.
18
+ */
19
+ getAddressAsync(index?: number, verify?: boolean): Promise<string>;
20
+ /**
21
+ * @deprecated
22
+ * Asynchronous version of getAddress method. Not supported for ledger client
23
+ * @throws {Error} Not supported method
24
+ */
25
+ getAddress(): string;
26
+ /**
27
+ * Transfers RUNE or synth token
28
+ *
29
+ * @param {TxParams} params The transfer options.
30
+ * @param {number} params.walletIndex Optional - The index to use to generate the address from the transaction will be done.
31
+ * If it is not set, address associated with index 0 will be used
32
+ * @param {asset} params.asset Optional - The asset that will be deposit. If it is not set, Thorchain native asset will be
33
+ * used
34
+ * @param {BaseAmount} params.amount The amount that will be transfer
35
+ * @param {string} params.recipient Recipient of the transfer
36
+ * @param {string} params.memo Optional - The memo associated with the transfer
37
+ * @returns {TxHash} The transaction hash.
38
+ */
39
+ transfer(params: TxParams): Promise<string>;
40
+ /**
41
+ * Make a deposit
42
+ *
43
+ * @param {number} param.walletIndex Optional - The index to use to generate the address from the transaction will be done.
44
+ * If it is not set, address associated with index 0 will be used
45
+ * @param {Asset} param.asset Optional - The asset that will be deposit. If it is not set, Thorchain native asset will be
46
+ * used
47
+ * @param {BaseAmount} param.amount The amount that will be deposit
48
+ * @param {string} param.memo Optional - The memo associated with the deposit
49
+ * @param {BigNumber} param.gasLimit Optional - The limit amount of gas allowed to spend in the deposit. If not set, default
50
+ * value of 600000000 will be used
51
+ * @returns {string} The deposit hash
52
+ */
53
+ deposit({ walletIndex, asset, amount, memo, gasLimit, }: DepositParam): Promise<string>;
54
+ /**
55
+ * @deprecated
56
+ * Create a transaction and sign it without broadcasting it
57
+ *
58
+ * @param {TxParams} params The transfer options.
59
+ * @param {number} params.walletIndex Optional - The index to use to generate the address from the transaction will be done.
60
+ * If it is not set, address associated with index 0 will be used
61
+ * @param {asset} params.asset Optional - The asset that will be deposit. If it is not set, Thorchain native asset will be
62
+ * used
63
+ * @param {BaseAmount} params.amount The amount that will be transfer
64
+ * @param {string} params.recipient Recipient of the transfer
65
+ * @param {string} params.memo Optional - The memo associated with the transfer
66
+ * @returns {TxHash} The transaction hash.
67
+ */
68
+ transferOffline(params: TxParams): Promise<string>;
69
+ private getProtocolAminoMessages;
70
+ }
package/lib/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- export * from './client';
1
+ export { ClientKeystore, ClientKeystore as Client } from './clientKeystore';
2
+ export { ClientLedger } from './clientLedger';
2
3
  export * from './types';
3
4
  export * from './utils';
4
5
  export * from './const';