@xelis/sdk 0.9.11 → 0.10.1

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.
Files changed (53) hide show
  1. package/dist/cjs/address/address.js +55 -0
  2. package/dist/cjs/address/bech32.js +167 -0
  3. package/dist/cjs/config.js +4 -2
  4. package/dist/cjs/daemon/rpc.js +122 -71
  5. package/dist/cjs/daemon/types.js +44 -24
  6. package/dist/cjs/daemon/websocket.js +129 -105
  7. package/dist/cjs/data/element.js +84 -0
  8. package/dist/cjs/data/value.js +327 -0
  9. package/dist/cjs/{lib/rpc.js → rpc/http.js} +68 -18
  10. package/dist/cjs/rpc/parse_json/parse_json.js +15 -0
  11. package/dist/cjs/{lib → rpc}/websocket.js +119 -79
  12. package/dist/cjs/wallet/rpc.js +81 -70
  13. package/dist/cjs/wallet/types.js +44 -1
  14. package/dist/cjs/wallet/websocket.js +77 -14
  15. package/dist/cjs/xswd/websocket.js +3 -3
  16. package/dist/esm/address/address.js +53 -0
  17. package/dist/esm/address/bech32.js +161 -0
  18. package/dist/esm/config.js +3 -1
  19. package/dist/esm/daemon/rpc.js +122 -71
  20. package/dist/esm/daemon/types.js +44 -24
  21. package/dist/esm/daemon/websocket.js +130 -106
  22. package/dist/esm/data/element.js +81 -0
  23. package/dist/esm/data/value.js +324 -0
  24. package/dist/esm/{lib/rpc.js → rpc/http.js} +67 -17
  25. package/dist/esm/rpc/parse_json/parse_json.js +8 -0
  26. package/dist/esm/{lib → rpc}/websocket.js +118 -78
  27. package/dist/esm/wallet/rpc.js +81 -70
  28. package/dist/esm/wallet/types.js +43 -0
  29. package/dist/esm/wallet/websocket.js +77 -14
  30. package/dist/esm/xswd/websocket.js +3 -3
  31. package/dist/types/address/address.d.ts +12 -0
  32. package/dist/types/address/bech32.d.ts +6 -0
  33. package/dist/types/config.d.ts +2 -0
  34. package/dist/types/daemon/rpc.d.ts +68 -51
  35. package/dist/types/daemon/types.d.ts +216 -44
  36. package/dist/types/daemon/websocket.d.ts +77 -56
  37. package/dist/types/data/element.d.ts +20 -0
  38. package/dist/types/data/value.d.ts +50 -0
  39. package/dist/types/rpc/http.d.ts +9 -0
  40. package/dist/types/rpc/parse_json/parse_json.d.ts +1 -0
  41. package/dist/types/{lib → rpc}/websocket.d.ts +14 -10
  42. package/dist/types/wallet/rpc.d.ts +45 -26
  43. package/dist/types/wallet/types.d.ts +244 -21
  44. package/dist/types/wallet/websocket.d.ts +47 -22
  45. package/dist/types/xswd/websocket.d.ts +3 -3
  46. package/package.json +5 -4
  47. package/dist/cjs/lib/parse_data.js +0 -15
  48. package/dist/esm/lib/parse_data.js +0 -11
  49. package/dist/types/lib/parse_data.d.ts +0 -1
  50. package/dist/types/lib/rpc.d.ts +0 -7
  51. /package/dist/cjs/{lib → rpc}/types.js +0 -0
  52. /package/dist/esm/{lib → rpc}/types.js +0 -0
  53. /package/dist/types/{lib → rpc}/types.d.ts +0 -0
@@ -1,29 +1,48 @@
1
- import { GetAssetParams, HasBalanceResult, SplitAddressParams, SplitAddressResult } from '../daemon/types';
2
- import { GetAddressParams, BuildTransactionParams, BuildTransactionResult, ListTransactionParams, Signature, TransactionEntry, RescanParams, SetOnlineModeParams, EstimateFeesParams } from './types';
3
- import { RPC as BaseRPC } from '../lib/rpc';
4
- import { RPCResponse } from '../lib/types';
5
- export declare class RPC extends BaseRPC {
6
- auth: string;
1
+ import * as daemonTypes from '../daemon/types';
2
+ import * as types from './types';
3
+ import { HttpRPC } from '../rpc/http';
4
+ import { Element } from '../data/element';
5
+ export declare class RPC extends HttpRPC {
7
6
  constructor(endpoint: string, username: string, password: string);
8
- post<T>(method: string, params?: any): Promise<RPCResponse<T>>;
9
- getVersion(): Promise<RPCResponse<string>>;
10
- getNetwork(): Promise<RPCResponse<string>>;
11
- getNonce(): Promise<RPCResponse<number>>;
12
- getTopoheight(): Promise<RPCResponse<number>>;
13
- getAddress(params?: GetAddressParams): Promise<RPCResponse<string>>;
14
- splitAddress(params: SplitAddressParams): Promise<RPCResponse<SplitAddressResult>>;
15
- rescan(params: RescanParams): Promise<RPCResponse<boolean>>;
16
- getBalance(asset?: string): Promise<RPCResponse<number>>;
17
- hasBalance(asset?: string): Promise<RPCResponse<HasBalanceResult>>;
18
- getTrackedAssets(): Promise<RPCResponse<string[]>>;
19
- getAssetPrecision(params: GetAssetParams): Promise<RPCResponse<number>>;
20
- getTransaction(hash: string): Promise<RPCResponse<TransactionEntry>>;
21
- buildTransaction(params: BuildTransactionParams): Promise<RPCResponse<BuildTransactionResult>>;
22
- listTransactions(params?: ListTransactionParams): Promise<RPCResponse<TransactionEntry[]>>;
23
- isOnline(): Promise<RPCResponse<boolean>>;
24
- signData(data: any): Promise<RPCResponse<Signature>>;
25
- estimateFees(params: EstimateFeesParams): Promise<RPCResponse<number>>;
26
- setOnlineMode(params: SetOnlineModeParams): Promise<RPCResponse<boolean>>;
27
- setOfflineMode(): Promise<RPCResponse<boolean>>;
7
+ getVersion(): Promise<string>;
8
+ getNetwork(): Promise<string>;
9
+ getNonce(): Promise<number>;
10
+ getTopoheight(): Promise<number>;
11
+ getAddress(params?: types.GetAddressParams): Promise<string>;
12
+ splitAddress(params: daemonTypes.SplitAddressParams): Promise<daemonTypes.SplitAddressResult>;
13
+ rescan(params: types.RescanParams): Promise<boolean>;
14
+ getBalance(asset?: string): Promise<number>;
15
+ hasBalance(asset?: string): Promise<daemonTypes.HasBalanceResult>;
16
+ getTrackedAssets(): Promise<string[]>;
17
+ getAssetPrecision(params: daemonTypes.GetAssetParams): Promise<number>;
18
+ getAssets(): Promise<{
19
+ [key: string]: types.Asset;
20
+ }>;
21
+ getAsset(params: daemonTypes.GetAssetParams): Promise<types.Asset>;
22
+ getTransaction(hash: string): Promise<types.TransactionEntry>;
23
+ buildTransaction(params: types.BuildTransactionParams): Promise<types.TransactionResponse>;
24
+ buildTransactionOffline(params: types.BuildTransactionOfflineParams): Promise<types.TransactionResponse>;
25
+ buildUnsignedTransaction(params: types.BuildTransactionParams): Promise<types.UnsignedTransactionResponse>;
26
+ signUnsignedTransaction(params: types.SignUnsignedTransactionParams): Promise<types.SignatureId>;
27
+ finalizeUnsignedTransaction(params: types.FinalizeUnsignedTransactionParams): Promise<types.TransactionResponse>;
28
+ clearTxCache(): Promise<boolean>;
29
+ listTransactions(params?: types.ListTransactionParams): Promise<types.TransactionEntry[]>;
30
+ isOnline(): Promise<boolean>;
31
+ setOnlineMode(params: types.SetOnlineModeParams): Promise<boolean>;
32
+ setOfflineMode(): Promise<boolean>;
33
+ signData(data: Element): Promise<string>;
34
+ estimateFees(params: types.EstimateFeesParams): Promise<number>;
35
+ estimateExtraDataSize(params: types.EstimateExtraDataSizeParams): Promise<types.EstimateExtraDataSizeResult>;
36
+ networkInfo(): Promise<types.NetworkInfoResult>;
37
+ decryptExtraData(params: types.DecryptExtraDataParams): Promise<types.PlaintextCiphertext>;
38
+ decryptCiphertext(params: types.DecryptCiphertextParams): Promise<number>;
39
+ getMatchingKeys(params: types.GetMatchingKeysParams): Promise<any>;
40
+ countMatchingEntries(params: types.CountMatchingKeysParams): Promise<number>;
41
+ getValueFromKey(params: types.GetValueFromKeyParams): Promise<any>;
42
+ store(params: types.StoreParams): Promise<boolean>;
43
+ delete(params: types.DeleteParams): Promise<boolean>;
44
+ deleteTreeEntries(tree: string): Promise<boolean>;
45
+ hasKey(params: types.HasKeyParams): Promise<boolean>;
46
+ queryDB(params: types.QueryDBParams): Promise<types.QueryResult>;
28
47
  }
29
48
  export default RPC;
@@ -1,4 +1,4 @@
1
- import { Transaction } from '../daemon/types';
1
+ import * as daemonTypes from '../daemon/types';
2
2
  export interface GetAddressParams {
3
3
  integrated_data?: string;
4
4
  }
@@ -6,16 +6,78 @@ export interface FeeBuilder {
6
6
  multiplier?: number;
7
7
  value?: number;
8
8
  }
9
+ export interface MultiSigBuilder {
10
+ participants: string[];
11
+ threshold: number;
12
+ }
13
+ export interface ContractDepositBuilder {
14
+ amount: number;
15
+ private: boolean;
16
+ }
17
+ export interface InvokeContractBuilder {
18
+ contract: string;
19
+ max_gas: number;
20
+ chunk_id: number;
21
+ parameters: any[];
22
+ deposits: {
23
+ [key: string]: ContractDepositBuilder;
24
+ };
25
+ }
26
+ export interface TransferBuilder {
27
+ destination: string;
28
+ asset: string;
29
+ amount: number;
30
+ extra_data?: any;
31
+ }
32
+ export interface SignerId {
33
+ id: number;
34
+ private_key: number[];
35
+ }
9
36
  export interface BuildTransactionParams {
10
- transfers: TransferOut[];
11
- burn?: TxBurn;
12
- broadcast: boolean;
37
+ transfers?: TransferBuilder[];
38
+ burn?: daemonTypes.Burn;
39
+ multi_sig?: MultiSigBuilder;
40
+ invoke_contract?: InvokeContractBuilder;
41
+ deploy_contract?: string;
13
42
  fee?: FeeBuilder;
43
+ nonce?: number;
44
+ tx_version?: number;
45
+ broadcast: boolean;
14
46
  tx_as_hex: boolean;
47
+ signers?: SignerId[];
48
+ }
49
+ export interface BuildTransactionOfflineParams extends BuildTransactionParams {
50
+ nonce: number;
51
+ reference: daemonTypes.Reference;
15
52
  }
16
- export interface BuildTransactionResult extends Transaction {
53
+ export interface TransactionResponse extends daemonTypes.Transaction {
17
54
  txt_as_hex?: string;
18
55
  }
56
+ export interface SignatureId {
57
+ id: number;
58
+ signature: string;
59
+ }
60
+ export interface MultiSig {
61
+ signatures: {
62
+ [id: number]: SignatureId;
63
+ };
64
+ }
65
+ export interface UnsignedTransaction {
66
+ version: number;
67
+ source: string;
68
+ data: daemonTypes.TransactionData;
69
+ fee: number;
70
+ nonce: number;
71
+ source_commitments: daemonTypes.SourceCommitment[];
72
+ reference: daemonTypes.Reference;
73
+ range_proof: number[];
74
+ multisig?: MultiSig;
75
+ }
76
+ export interface UnsignedTransactionResponse extends UnsignedTransaction {
77
+ hash: string;
78
+ threshold: number;
79
+ tx_as_hex?: string;
80
+ }
19
81
  export interface ListTransactionParams {
20
82
  min_topoheight?: number;
21
83
  max_topoheight?: number;
@@ -29,29 +91,29 @@ export interface Signature {
29
91
  s: number[];
30
92
  e: number[];
31
93
  }
32
- export interface TxCoinbase {
94
+ export interface Coinbase {
33
95
  reward: number;
34
96
  }
35
- export interface TxBurn {
36
- asset: string;
97
+ export interface PlaintextExtraData {
98
+ shared_key: string;
99
+ data: any;
100
+ }
101
+ export interface TransferOut {
37
102
  amount: number;
103
+ asset: string;
104
+ destination: string;
105
+ extra_data: PlaintextExtraData | null;
38
106
  }
39
107
  export interface TransferIn {
40
108
  asset: string;
41
109
  amount: number;
42
- extra_data?: any;
110
+ extra_data?: PlaintextExtraData | null;
43
111
  }
44
- export interface TxIncoming {
112
+ export interface Incoming {
45
113
  from: string;
46
114
  transfers: TransferIn[];
47
115
  }
48
- export interface TransferOut {
49
- destination: string;
50
- asset: string;
51
- amount: number;
52
- extra_data?: any;
53
- }
54
- export interface TxOutgoing {
116
+ export interface Outgoing {
55
117
  transfers: TransferOut;
56
118
  fees: number;
57
119
  nonce: number;
@@ -59,7 +121,10 @@ export interface TxOutgoing {
59
121
  export interface TransactionEntry {
60
122
  hash: string;
61
123
  topoheight: number;
62
- entry: TxCoinbase | TxBurn | TxIncoming | TxOutgoing;
124
+ outgoing: Outgoing | null;
125
+ incoming: Incoming | null;
126
+ burn: daemonTypes.Burn | null;
127
+ coinbase: Coinbase | null;
63
128
  }
64
129
  export interface RescanParams {
65
130
  until_topoheight?: number;
@@ -70,8 +135,11 @@ export interface SetOnlineModeParams {
70
135
  auto_reconnect: boolean;
71
136
  }
72
137
  export interface EstimateFeesParams {
73
- transfers: TransferOut[];
74
- burn?: TxBurn;
138
+ transfers?: TransferBuilder[];
139
+ burn?: daemonTypes.Burn;
140
+ multi_sig?: MultiSigBuilder;
141
+ invoke_contract?: InvokeContractBuilder;
142
+ deploy_contract?: string;
75
143
  }
76
144
  export interface BalanceChangedResult {
77
145
  asset: string;
@@ -83,6 +151,141 @@ export interface NewTopoheightResult {
83
151
  export interface RescanResult {
84
152
  start_topoheight: number;
85
153
  }
154
+ export interface Asset {
155
+ decimals: number;
156
+ name: string;
157
+ max_supply: number | null;
158
+ }
159
+ export interface EstimateExtraDataSizeParams {
160
+ destinations: string[];
161
+ }
162
+ export interface EstimateExtraDataSizeResult {
163
+ size: number;
164
+ }
165
+ export interface NetworkInfoResult extends daemonTypes.GetInfoResult {
166
+ connected_to: string;
167
+ }
168
+ export declare enum TxRole {
169
+ Sender = "sender",
170
+ Receiver = "receiver"
171
+ }
172
+ export interface DecryptExtraDataParams {
173
+ extra_data: number[];
174
+ role: TxRole;
175
+ }
176
+ export interface CompressedCiphertext {
177
+ commitment: number[];
178
+ handle: number[];
179
+ }
180
+ export interface PlaintextCiphertext {
181
+ shared_key: string;
182
+ data: any;
183
+ }
184
+ export interface DecryptCiphertextParams {
185
+ ciphertext: CompressedCiphertext;
186
+ }
187
+ export interface SignUnsignedTransactionParams {
188
+ hash: string;
189
+ signer_id: number;
190
+ }
191
+ export interface FinalizeUnsignedTransactionParams {
192
+ unsigned: string;
193
+ signatures: SignatureId[];
194
+ broadcast: boolean;
195
+ tx_as_hex: boolean;
196
+ }
197
+ export interface HistorySyncedResult {
198
+ topoheight: number;
199
+ }
200
+ export interface GetMatchingKeysParams {
201
+ tree: string;
202
+ query?: Query;
203
+ }
204
+ export interface CountMatchingKeysParams {
205
+ tree: string;
206
+ key?: Query;
207
+ value?: Query;
208
+ }
209
+ export interface GetValueFromKeyParams {
210
+ tree: string;
211
+ key: any;
212
+ }
213
+ export interface StoreParams {
214
+ tree: string;
215
+ key: any;
216
+ value: any;
217
+ }
218
+ export interface DeleteParams {
219
+ tree: string;
220
+ key: any;
221
+ }
222
+ export interface HasKeyParams {
223
+ tree: string;
224
+ key: any;
225
+ }
226
+ export interface QueryDBParams {
227
+ tree: string;
228
+ key?: Query;
229
+ value?: Query;
230
+ return_on_first: boolean;
231
+ }
232
+ export interface QueryResult {
233
+ entries: {
234
+ [key: string]: any;
235
+ };
236
+ next?: number;
237
+ }
238
+ export declare enum ValueType {
239
+ Bool = 0,
240
+ String = 1,
241
+ U8 = 2,
242
+ U16 = 3,
243
+ U32 = 4,
244
+ U64 = 5,
245
+ U128 = 6,
246
+ Hash = 7,
247
+ Blob = 8
248
+ }
249
+ export declare enum ElementType {
250
+ Value = 0,
251
+ Array = 1,
252
+ Fields = 2
253
+ }
254
+ export interface QueryAtKey {
255
+ key: any;
256
+ query?: Query;
257
+ }
258
+ export interface QueryNumber {
259
+ greater?: number;
260
+ greater_or_equal?: number;
261
+ lesser?: number;
262
+ lesser_or_equal?: number;
263
+ }
264
+ export interface QueryPosition {
265
+ position: number;
266
+ query?: Query;
267
+ }
268
+ export interface QueryElement {
269
+ has_key?: QueryAtKey;
270
+ at_key?: QueryAtKey;
271
+ len?: QueryNumber;
272
+ contains_element?: any;
273
+ at_position?: QueryPosition;
274
+ element_type?: ElementType;
275
+ }
276
+ export interface QueryValue extends QueryNumber {
277
+ equal?: any;
278
+ starts_with?: any;
279
+ ends_width?: any;
280
+ contains_value?: any;
281
+ is_of_type?: ValueType;
282
+ matches?: string;
283
+ }
284
+ export interface Query extends QueryValue, QueryElement {
285
+ not?: Query;
286
+ and?: Query[];
287
+ or?: Query[];
288
+ }
86
289
  export declare enum RPCMethod {
87
290
  GetVersion = "get_version",
88
291
  GetNetwork = "get_network",
@@ -95,14 +298,33 @@ export declare enum RPCMethod {
95
298
  HasBalance = "has_balance",
96
299
  GetTrackedAssets = "get_tracked_assets",
97
300
  GetAssetPrecision = "get_asset_precision",
301
+ GetAssets = "get_assets",
302
+ GetAsset = "get_asset",
98
303
  GetTransaction = "get_transaction",
99
304
  BuildTransaction = "build_transaction",
305
+ BuildTransactionOffline = "build_transaction_offline",
306
+ BuildUnsignedTransaction = "build_unsigned_transaction",
307
+ SignUnsignedTransaction = "sign_unsigned_transaction",
308
+ FinalizeUnsignedTransaction = "finalize_unsigned_transaction",
309
+ ClearTxCache = "clear_tx_cache",
100
310
  ListTransactions = "list_transactions",
101
311
  IsOnline = "is_online",
102
312
  SetOnlineMode = "set_online_mode",
103
313
  SetOfflineMode = "set_offline_mode",
104
314
  SignData = "sign_data",
105
- EstimateFees = "estimate_fees"
315
+ EstimateFees = "estimate_fees",
316
+ EstimateExtraDataSize = "estimate_extra_data_size",
317
+ NetworkInfo = "network_info",
318
+ DecryptExtraData = "decrypt_extra_data",
319
+ DecryptCiphertext = "decrypt_ciphertext",
320
+ GetMatchingKeys = "get_matching_keys",
321
+ CountMatchingEntries = "count_matching_entries",
322
+ GetValueFromKey = "get_value_from_key",
323
+ Store = "store",
324
+ Delete = "delete",
325
+ DeleteTreeEntries = "delete_tree_entries",
326
+ HasKey = "has_key",
327
+ QueryDB = "query_db"
106
328
  }
107
329
  export declare enum RPCEvent {
108
330
  NewTopoheight = "new_topoheight",
@@ -110,6 +332,7 @@ export declare enum RPCEvent {
110
332
  NewTransaction = "new_transaction",
111
333
  BalanceChanged = "balance_changed",
112
334
  Rescan = "rescan",
335
+ HistorySynced = "history_synced",
113
336
  Online = "online",
114
337
  Offline = "offline"
115
338
  }
@@ -1,39 +1,64 @@
1
- import { WS as BaseWS } from '../lib/websocket';
1
+ import { WSRPC } from '../rpc/websocket';
2
2
  import { MessageEvent } from 'ws';
3
- import { AssetWithData, GetAssetParams, RPCEventResult, SplitAddressParams, SplitAddressResult } from '../daemon/types';
4
- import { BuildTransactionParams, BuildTransactionResult, GetAddressParams, ListTransactionParams, Signature, RescanParams, SetOnlineModeParams, EstimateFeesParams, TransactionEntry, BalanceChangedResult, NewTopoheightResult, RescanResult } from './types';
3
+ import { RPCEventResult } from '../daemon/types';
4
+ import * as daemonTypes from '../daemon/types';
5
+ import * as types from './types';
6
+ import { Element } from '../data/element';
5
7
  export declare class WalletMethods {
6
- ws: BaseWS;
8
+ ws: WSRPC;
7
9
  prefix: string;
8
- constructor(ws: BaseWS, prefix?: string);
10
+ constructor(ws: WSRPC, prefix?: string);
9
11
  dataCall<T>(method: string, params?: any): Promise<T>;
10
- onNewTopoheight(onData: (msgEvent: MessageEvent, data?: NewTopoheightResult & RPCEventResult, err?: Error) => void): Promise<() => Promise<void>>;
11
- onNewAsset(onData: (msgEvent: MessageEvent, data?: AssetWithData & RPCEventResult, err?: Error) => void): Promise<() => Promise<void>>;
12
- onNewTransaction(onData: (msgEvent: MessageEvent, data?: TransactionEntry & RPCEventResult, err?: Error) => void): Promise<() => Promise<void>>;
13
- onBalanceChanged(onData: (msgEvent: MessageEvent, data?: BalanceChangedResult & RPCEventResult, err?: Error) => void): Promise<() => Promise<void>>;
14
- onRescan(onData: (msgEvent: MessageEvent, data?: RescanResult & RPCEventResult, err?: Error) => void): Promise<() => Promise<void>>;
12
+ onNewTopoheight(onData: (msgEvent: MessageEvent, data?: types.NewTopoheightResult & RPCEventResult, err?: Error) => void): Promise<() => Promise<void>>;
13
+ onNewAsset(onData: (msgEvent: MessageEvent, data?: daemonTypes.AssetWithData & RPCEventResult, err?: Error) => void): Promise<() => Promise<void>>;
14
+ onNewTransaction(onData: (msgEvent: MessageEvent, data?: types.TransactionEntry & RPCEventResult, err?: Error) => void): Promise<() => Promise<void>>;
15
+ onBalanceChanged(onData: (msgEvent: MessageEvent, data?: types.BalanceChangedResult & RPCEventResult, err?: Error) => void): Promise<() => Promise<void>>;
16
+ onRescan(onData: (msgEvent: MessageEvent, data?: types.RescanResult & RPCEventResult, err?: Error) => void): Promise<() => Promise<void>>;
17
+ onHistorySynced(onData: (msgEvent: MessageEvent, data?: types.HistorySyncedResult & RPCEventResult, err?: Error) => void): Promise<() => Promise<void>>;
15
18
  onOnline(onData: (msgEvent: MessageEvent, data?: RPCEventResult, err?: Error) => void): Promise<() => Promise<void>>;
16
19
  onOffline(onData: (msgEvent: MessageEvent, data?: RPCEventResult, err?: Error) => void): Promise<() => Promise<void>>;
17
20
  getVersion(): Promise<string>;
18
21
  getNetwork(): Promise<string>;
19
22
  getNonce(): Promise<number>;
20
23
  getTopoheight(): Promise<number>;
21
- getAddress(params?: GetAddressParams): Promise<string>;
22
- splitAddress(params: SplitAddressParams): Promise<SplitAddressResult>;
23
- rescan(params: RescanParams): Promise<boolean>;
24
- getBalance(asset?: string): Promise<number>;
24
+ getAddress(params?: types.GetAddressParams): Promise<string>;
25
+ splitAddress(params: daemonTypes.SplitAddressParams): Promise<daemonTypes.SplitAddressResult>;
26
+ rescan(params: types.RescanParams): Promise<boolean>;
27
+ getBalance(asset: string): Promise<number>;
28
+ hasBalance(asset: string): Promise<daemonTypes.HasBalanceResult>;
25
29
  getTrackedAssets(): Promise<string[]>;
26
- getAssetPrecision(params: GetAssetParams): Promise<number>;
27
- getTransaction(hash: string): Promise<TransactionEntry>;
28
- buildTransaction(params: BuildTransactionParams): Promise<BuildTransactionResult>;
29
- listTransactions(params?: ListTransactionParams): Promise<TransactionEntry[]>;
30
+ getAssetPrecision(params: daemonTypes.GetAssetParams): Promise<number>;
31
+ getAssets(): Promise<{
32
+ [key: string]: types.Asset;
33
+ }>;
34
+ getAsset(params: daemonTypes.GetAssetParams): Promise<types.Asset>;
35
+ getTransaction(hash: string): Promise<types.TransactionEntry>;
36
+ buildTransaction(params: types.BuildTransactionParams): Promise<types.TransactionResponse>;
37
+ buildTransactionOffline(params: types.BuildTransactionOfflineParams): Promise<types.TransactionResponse>;
38
+ buildUnsignedTransaction(params: types.BuildTransactionParams): Promise<types.UnsignedTransactionResponse>;
39
+ signUnsignedTransaction(params: types.SignUnsignedTransactionParams): Promise<types.SignatureId>;
40
+ finalizeUnsignedTransaction(params: types.FinalizeUnsignedTransactionParams): Promise<types.TransactionResponse>;
41
+ clearTxCache(): Promise<boolean>;
42
+ listTransactions(params?: types.ListTransactionParams): Promise<types.TransactionEntry[]>;
30
43
  isOnline(): Promise<boolean>;
31
- signData(data: any): Promise<Signature>;
32
- estimateFees(params: EstimateFeesParams): Promise<number>;
33
- setOnlineMode(params: SetOnlineModeParams): Promise<boolean>;
44
+ setOnlineMode(params: types.SetOnlineModeParams): Promise<boolean>;
34
45
  setOfflineMode(): Promise<boolean>;
46
+ signData(data: Element): Promise<string>;
47
+ estimateFees(params: types.EstimateFeesParams): Promise<number>;
48
+ estimateExtraDataSize(params: types.EstimateExtraDataSizeParams): Promise<types.EstimateExtraDataSizeResult>;
49
+ networkInfo(): Promise<types.NetworkInfoResult>;
50
+ decryptExtraData(params: types.DecryptExtraDataParams): Promise<types.PlaintextCiphertext>;
51
+ decryptCiphertext(params: types.DecryptCiphertextParams): Promise<number>;
52
+ getMatchingKeys(params: types.GetMatchingKeysParams): Promise<any>;
53
+ countMatchingEntries(params: types.CountMatchingKeysParams): Promise<number>;
54
+ getValueFromKey(params: types.GetValueFromKeyParams): Promise<any>;
55
+ store(params: types.StoreParams): Promise<boolean>;
56
+ delete(params: types.DeleteParams): Promise<boolean>;
57
+ deleteTreeEntries(tree: string): Promise<boolean>;
58
+ hasKey(params: types.HasKeyParams): Promise<boolean>;
59
+ queryDB(params: types.QueryDBParams): Promise<types.QueryResult>;
35
60
  }
36
- export declare class WS extends BaseWS {
61
+ export declare class WS extends WSRPC {
37
62
  methods: WalletMethods;
38
63
  constructor(username: string, password: string);
39
64
  }
@@ -1,11 +1,11 @@
1
- import { WS as BaseWS } from '../lib/websocket';
1
+ import { WSRPC } from '../rpc/websocket';
2
2
  import { ApplicationData } from '../wallet/types';
3
3
  import { DaemonMethods } from '../daemon/websocket';
4
4
  import { WalletMethods } from '../wallet/websocket';
5
- export declare class WS extends BaseWS {
5
+ export declare class WS extends WSRPC {
6
6
  daemon: DaemonMethods;
7
7
  wallet: WalletMethods;
8
8
  constructor();
9
- authorize(app: ApplicationData): Promise<import("../lib/types").RPCResponse<unknown>>;
9
+ authorize(app: ApplicationData): Promise<unknown>;
10
10
  }
11
11
  export default WS;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.9.11",
2
+ "version": "0.10.1",
3
3
  "name": "@xelis/sdk",
4
4
  "description": "Xelis software development kit for JS",
5
5
  "exports": {
@@ -29,9 +29,10 @@
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/jest": "^29.4.0",
32
+ "@types/json-bigint": "^1.0.4",
32
33
  "@types/react": "^18.2.23",
33
34
  "@types/ws": "^8.5.4",
34
- "fix-esm-import-path": "^1.5.0",
35
+ "fix-esm-import-path": "^1.10.1",
35
36
  "ts-jest": "^29.0.5",
36
37
  "typescript": "^4.9.5"
37
38
  },
@@ -39,8 +40,8 @@
39
40
  "await-to-js": "^3.0.0",
40
41
  "isomorphic-ws": "^5.0.0",
41
42
  "js-base64": "^3.7.6",
42
- "lossless-json": "^4.0.1",
43
+ "json-bigint": "^1.0.0",
43
44
  "react": "^18.2.0",
44
45
  "ws": "^8.12.1"
45
46
  }
46
- }
47
+ }
@@ -1,15 +0,0 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.parseData = void 0;
4
- var lossless_json_1 = require("lossless-json");
5
- // do not use JSON.parse() or we loose precision on big numbers
6
- // for ex: the API returns the nonce as a number instead of a string and JSON.parse() is rounding the number because of overflow
7
- // instead we will return any big number as a string and avoid precision loss
8
- var parseData = function (data) {
9
- return (0, lossless_json_1.parse)(data, null, function (value) {
10
- if ((0, lossless_json_1.isSafeNumber)(value))
11
- return parseFloat(value);
12
- return value;
13
- });
14
- };
15
- exports.parseData = parseData;
@@ -1,11 +0,0 @@
1
- import { parse, isSafeNumber } from 'lossless-json';
2
- // do not use JSON.parse() or we loose precision on big numbers
3
- // for ex: the API returns the nonce as a number instead of a string and JSON.parse() is rounding the number because of overflow
4
- // instead we will return any big number as a string and avoid precision loss
5
- export var parseData = function (data) {
6
- return parse(data, null, function (value) {
7
- if (isSafeNumber(value))
8
- return parseFloat(value);
9
- return value;
10
- });
11
- };
@@ -1 +0,0 @@
1
- export declare const parseData: (data: string) => unknown;
@@ -1,7 +0,0 @@
1
- import { RPCResponse } from './types';
2
- export declare class RPC {
3
- endpoint: string;
4
- timeout: number;
5
- constructor(endpoint: string);
6
- post<T>(method: string, params?: any, headers?: Headers): Promise<RPCResponse<T>>;
7
- }
File without changes
File without changes
File without changes