@cityofzion/blockchain-service 1.21.2 → 1.22.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.
@@ -1,113 +1,128 @@
1
1
  import Transport from '@ledgerhq/hw-transport';
2
2
  import TypedEmitter from 'typed-emitter';
3
3
  import { BSError } from './error';
4
- export type UntilIndexRecord<BSName extends string = string> = Partial<Record<BSName, Record<string, number>>>;
5
- export type Account<BSName extends string = string> = {
4
+ export type TUntilIndexRecord<N extends string = string> = Partial<Record<N, Record<string, number>>>;
5
+ export type TBSAccount<N extends string = string> = {
6
6
  key: string;
7
7
  type: 'wif' | 'privateKey' | 'publicKey';
8
8
  address: string;
9
9
  bip44Path?: string;
10
10
  isHardware?: boolean;
11
- blockchain: BSName;
11
+ blockchain: N;
12
12
  };
13
- export type Token = {
13
+ export type TBSToken = {
14
14
  symbol: string;
15
15
  name: string;
16
16
  hash: string;
17
17
  decimals: number;
18
18
  };
19
- export type NetworkId<T extends string = string> = T | (string & {});
20
- export type Network<T extends string = string> = {
21
- id: NetworkId<T>;
19
+ export type TBSNetworkId<T extends string = string> = T | (string & {});
20
+ export type TBSNetworkType = 'mainnet' | 'testnet' | 'custom';
21
+ export type TBSNetwork<T extends string = string> = {
22
+ id: TBSNetworkId<T>;
22
23
  name: string;
23
24
  url: string;
25
+ type: TBSNetworkType;
24
26
  };
25
- export type IntentTransferParam = {
27
+ export type TIntentTransferParam = {
26
28
  receiverAddress: string;
27
29
  tokenHash: string;
28
30
  amount: string;
29
31
  tokenDecimals?: number;
30
32
  };
31
- export type TransferParam<BSName extends string = string> = {
32
- senderAccount: Account<BSName>;
33
- intents: IntentTransferParam[];
34
- tipIntent?: IntentTransferParam;
33
+ export type TTransferParam<N extends string = string> = {
34
+ senderAccount: TBSAccount<N>;
35
+ intents: TIntentTransferParam[];
36
+ tipIntent?: TIntentTransferParam;
35
37
  priorityFee?: string;
36
38
  };
37
- export interface BlockchainService<BSName extends string = string, BSAvailableNetworks extends string = string> {
38
- readonly name: BSName;
39
+ export type TPingNetworkResponse = {
40
+ latency: number;
41
+ url: string;
42
+ height: number;
43
+ };
44
+ export interface IBlockchainService<N extends string = string, A extends string = string> {
45
+ readonly name: N;
39
46
  readonly bip44DerivationPath: string;
40
- readonly feeToken: Token;
41
- exchangeDataService: ExchangeDataService;
42
- blockchainDataService: BlockchainDataService;
47
+ readonly feeToken: TBSToken;
48
+ readonly isMultiTransferSupported: boolean;
49
+ readonly isCustomNetworkSupported: boolean;
50
+ tokens: TBSToken[];
51
+ readonly nativeTokens: TBSToken[];
52
+ network: TBSNetwork<A>;
53
+ availableNetworkURLs: string[];
54
+ readonly defaultNetwork: TBSNetwork<A>;
55
+ readonly availableNetworks: TBSNetwork<A>[];
56
+ exchangeDataService: IExchangeDataService;
57
+ blockchainDataService: IBlockchainDataService;
43
58
  tokenService: ITokenService;
44
- tokens: Token[];
45
- nativeTokens: Token[];
46
- network: Network<BSAvailableNetworks>;
47
- testNetwork: (network: Network<BSAvailableNetworks>) => Promise<void>;
48
- setNetwork: (partialNetwork: Network<BSAvailableNetworks>) => void;
49
- generateAccountFromMnemonic(mnemonic: string, index: number): Account<BSName>;
50
- generateAccountFromKey(key: string): Account<BSName>;
59
+ pingNetwork: (network: TBSNetwork<A>) => Promise<TPingNetworkResponse>;
60
+ setNetwork: (network: TBSNetwork<A>) => void;
61
+ generateAccountFromMnemonic(mnemonic: string, index: number): TBSAccount<N>;
62
+ generateAccountFromKey(key: string): TBSAccount<N>;
51
63
  validateAddress(address: string): boolean;
52
64
  validateKey(key: string): boolean;
53
- transfer(param: TransferParam<BSName>): Promise<string[]>;
65
+ transfer(param: TTransferParam<N>): Promise<string[]>;
54
66
  }
55
- export interface BSWithEncryption<BSName extends string = string> {
56
- decrypt(keyOrJson: string, password: string): Promise<Account<BSName>>;
67
+ export interface IBSWithEncryption<N extends string = string> {
68
+ decrypt(keyOrJson: string, password: string): Promise<TBSAccount<N>>;
57
69
  encrypt(key: string, password: string): Promise<string>;
58
70
  validateEncrypted(keyOrJson: string): boolean;
59
71
  }
60
- export interface BSCalculableFee<BSName extends string = string> {
61
- calculateTransferFee(param: TransferParam<BSName>): Promise<string>;
72
+ export interface IBSWithFee<N extends string = string> {
73
+ calculateTransferFee(param: TTransferParam<N>): Promise<string>;
62
74
  }
63
- export interface BSClaimable<BSName extends string = string> {
64
- readonly claimToken: Token;
65
- readonly burnToken: Token;
66
- blockchainDataService: BlockchainDataService & BDSClaimable;
67
- claim(account: Account<BSName>): Promise<string>;
75
+ export interface IBSWithClaim<N extends string = string> {
76
+ readonly claimToken: TBSToken;
77
+ readonly burnToken: TBSToken;
78
+ claimDataService: IClaimDataService;
79
+ claim(account: TBSAccount<N>): Promise<string>;
68
80
  }
69
- export interface BSWithNameService {
81
+ export interface IBSWithNameService {
70
82
  resolveNameServiceDomain(domainName: string): Promise<string>;
71
83
  validateNameServiceDomainFormat(domainName: string): boolean;
72
84
  }
73
- export interface BSWithExplorerService {
74
- explorerService: ExplorerService;
85
+ export interface IBSWithExplorer {
86
+ explorerService: IExplorerService;
75
87
  }
76
- export interface BSWithNft {
77
- nftDataService: NftDataService;
88
+ export interface IBSWithNft {
89
+ nftDataService: INftDataService;
78
90
  }
79
- export interface BSWithLedger<BSName extends string = string> {
80
- ledgerService: LedgerService<BSName>;
81
- generateAccountFromPublicKey(publicKey: string): Account<BSName>;
91
+ export interface IBSWithLedger<N extends string = string> {
92
+ ledgerService: ILedgerService<N>;
93
+ generateAccountFromPublicKey(publicKey: string): TBSAccount<N>;
82
94
  }
83
- export type TransactionNotificationTypedResponse = {
95
+ export interface IBSWithWalletConnect {
96
+ walletConnectService: IWalletConnectService;
97
+ }
98
+ export type TTransactionNotificationTypedResponse = {
84
99
  type: string;
85
100
  value?: string;
86
101
  };
87
- export type TransactionNotificationStateResponse = {
102
+ export type TTransactionNotificationStateResponse = {
88
103
  type: string;
89
- value?: string | TransactionNotificationTypedResponse[];
104
+ value?: string | TTransactionNotificationTypedResponse[];
90
105
  };
91
- export type TransactionNotifications = {
106
+ export type TTransactionNotifications = {
92
107
  eventName: string;
93
- state?: TransactionNotificationStateResponse | TransactionNotificationStateResponse[];
108
+ state?: TTransactionNotificationStateResponse | TTransactionNotificationStateResponse[];
94
109
  };
95
- export type TransactionTransferAsset = {
110
+ export type TTransactionTransferAsset = {
96
111
  amount: string;
97
112
  to: string;
98
113
  from: string;
99
114
  type: 'token';
100
115
  contractHash: string;
101
- token?: Token;
116
+ token?: TBSToken;
102
117
  };
103
- export type TransactionTransferNft = {
118
+ export type TTransactionTransferNft = {
104
119
  tokenHash: string;
105
120
  to: string;
106
121
  from: string;
107
122
  type: 'nft';
108
123
  collectionHash: string;
109
124
  };
110
- type TransactionDefaultResponse = {
125
+ type TTransactionDefaultResponse = {
111
126
  type: 'default';
112
127
  };
113
128
  export type TransactionBridgeNeo3NeoXResponse = {
@@ -118,39 +133,39 @@ export type TransactionBridgeNeo3NeoXResponse = {
118
133
  receiverAddress: string;
119
134
  };
120
135
  };
121
- export type TransactionResponse = {
136
+ export type TTransactionResponse = {
122
137
  hash: string;
123
138
  block: number;
124
139
  time: number;
125
- transfers: (TransactionTransferAsset | TransactionTransferNft)[];
140
+ transfers: (TTransactionTransferAsset | TTransactionTransferNft)[];
126
141
  fee?: string;
127
- notifications: TransactionNotifications[];
128
- } & (TransactionDefaultResponse | TransactionBridgeNeo3NeoXResponse);
129
- export type ContractParameter = {
142
+ notifications: TTransactionNotifications[];
143
+ } & (TTransactionDefaultResponse | TransactionBridgeNeo3NeoXResponse);
144
+ export type TContractParameter = {
130
145
  name: string;
131
146
  type: string;
132
147
  };
133
- export type TransactionsByAddressResponse = {
134
- transactions: TransactionResponse[];
148
+ export type TTransactionsByAddressResponse = {
149
+ transactions: TTransactionResponse[];
135
150
  nextPageParams?: any;
136
151
  };
137
- export type TransactionsByAddressParams = {
152
+ export type TTransactionsByAddressParams = {
138
153
  address: string;
139
154
  nextPageParams?: any;
140
155
  };
141
- export type FullTransactionsByAddressParams = {
156
+ export type TFullTransactionsByAddressParams = {
142
157
  address: string;
143
158
  dateFrom: string;
144
159
  dateTo: string;
145
160
  pageSize?: number;
146
161
  nextCursor?: string;
147
162
  };
148
- export type ExportTransactionsByAddressParams = {
163
+ export type TExportTransactionsByAddressParams = {
149
164
  address: string;
150
165
  dateFrom: string;
151
166
  dateTo: string;
152
167
  };
153
- export type FullTransactionNftEvent = {
168
+ export type TFullTransactionNftEvent = {
154
169
  eventType: 'nft';
155
170
  amount?: string;
156
171
  methodName: string;
@@ -167,7 +182,7 @@ export type FullTransactionNftEvent = {
167
182
  name?: string;
168
183
  collectionName?: string;
169
184
  };
170
- export type FullTransactionAssetEvent = {
185
+ export type TFullTransactionAssetEvent = {
171
186
  eventType: 'token';
172
187
  amount?: string;
173
188
  methodName: string;
@@ -177,13 +192,13 @@ export type FullTransactionAssetEvent = {
177
192
  toUrl?: string;
178
193
  from?: string;
179
194
  fromUrl?: string;
180
- token?: Token;
195
+ token?: TBSToken;
181
196
  tokenType: 'generic' | (string & NonNullable<unknown>);
182
197
  };
183
- type FullTransactionsItemDefault = {
198
+ type TFullTransactionsItemDefault = {
184
199
  type: 'default';
185
200
  };
186
- export type FullTransactionsItemBridgeNeo3NeoX = {
201
+ export type TFullTransactionsItemBridgeNeo3NeoX = {
187
202
  type: 'bridgeNeo3NeoX';
188
203
  data: {
189
204
  amount: string;
@@ -191,7 +206,7 @@ export type FullTransactionsItemBridgeNeo3NeoX = {
191
206
  receiverAddress: string;
192
207
  };
193
208
  };
194
- export type FullTransactionsItem = {
209
+ export type TFullTransactionsItem = {
195
210
  txId: string;
196
211
  txIdUrl?: string;
197
212
  block: number;
@@ -200,68 +215,62 @@ export type FullTransactionsItem = {
200
215
  notificationCount: number;
201
216
  networkFeeAmount?: string;
202
217
  systemFeeAmount?: string;
203
- events: (FullTransactionAssetEvent | FullTransactionNftEvent)[];
204
- } & (FullTransactionsItemDefault | FullTransactionsItemBridgeNeo3NeoX);
205
- export type FullTransactionsByAddressResponse = {
218
+ events: (TFullTransactionAssetEvent | TFullTransactionNftEvent)[];
219
+ } & (TFullTransactionsItemDefault | TFullTransactionsItemBridgeNeo3NeoX);
220
+ export type TFullTransactionsByAddressResponse = {
206
221
  nextCursor?: string;
207
- data: FullTransactionsItem[];
222
+ data: TFullTransactionsItem[];
208
223
  };
209
- export type ContractMethod = {
224
+ export type TContractMethod = {
210
225
  name: string;
211
- parameters: ContractParameter[];
226
+ parameters: TContractParameter[];
212
227
  };
213
228
  export type ContractResponse = {
214
229
  hash: string;
215
230
  name: string;
216
- methods: ContractMethod[];
231
+ methods: TContractMethod[];
217
232
  };
218
- export type BalanceResponse = {
233
+ export type TBalanceResponse = {
219
234
  amount: string;
220
- token: Token;
221
- };
222
- export type RpcResponse = {
223
- latency: number;
224
- url: string;
225
- height: number;
226
- };
227
- export interface BlockchainDataService {
228
- maxTimeToConfirmTransactionInMs: number;
229
- getTransaction(txid: string): Promise<TransactionResponse>;
230
- getTransactionsByAddress(params: TransactionsByAddressParams): Promise<TransactionsByAddressResponse>;
231
- getFullTransactionsByAddress(params: FullTransactionsByAddressParams): Promise<FullTransactionsByAddressResponse>;
232
- exportFullTransactionsByAddress(params: ExportTransactionsByAddressParams): Promise<string>;
235
+ token: TBSToken;
236
+ };
237
+ export interface IBlockchainDataService {
238
+ readonly maxTimeToConfirmTransactionInMs: number;
239
+ getTransaction(txid: string): Promise<TTransactionResponse>;
240
+ getTransactionsByAddress(params: TTransactionsByAddressParams): Promise<TTransactionsByAddressResponse>;
241
+ getFullTransactionsByAddress(params: TFullTransactionsByAddressParams): Promise<TFullTransactionsByAddressResponse>;
242
+ exportFullTransactionsByAddress(params: TExportTransactionsByAddressParams): Promise<string>;
233
243
  getContract(contractHash: string): Promise<ContractResponse>;
234
- getTokenInfo(tokenHash: string): Promise<Token>;
235
- getBalance(address: string): Promise<BalanceResponse[]>;
244
+ getTokenInfo(tokenHash: string): Promise<TBSToken>;
245
+ getBalance(address: string): Promise<TBalanceResponse[]>;
236
246
  getBlockHeight(): Promise<number>;
237
- getRpcList(): Promise<RpcResponse[]>;
238
247
  }
239
- export interface BDSClaimable {
248
+ export interface IClaimDataService {
240
249
  getUnclaimed(address: string): Promise<string>;
241
250
  }
242
- export type TokenPricesResponse = {
251
+ export type TTokenPricesResponse = {
243
252
  usdPrice: number;
244
- token: Token;
253
+ token: TBSToken;
245
254
  };
246
- export type TokenPricesHistoryResponse = {
255
+ export type TTokenPricesHistoryResponse = {
247
256
  usdPrice: number;
248
257
  timestamp: number;
249
- token: Token;
258
+ token: TBSToken;
250
259
  };
251
- export type GetTokenPriceHistoryParams = {
252
- token: Token;
260
+ export type TGetTokenPriceHistoryParams = {
261
+ token: TBSToken;
253
262
  type: 'hour' | 'day';
254
263
  limit: number;
255
264
  };
256
- export type GetTokenPricesParams = {
257
- tokens: Token[];
265
+ export type TGetTokenPricesParams = {
266
+ tokens: TBSToken[];
258
267
  };
259
- export interface ExchangeDataService {
260
- getTokenPrices(params: GetTokenPricesParams): Promise<TokenPricesResponse[]>;
261
- getTokenPriceHistory(params: GetTokenPriceHistoryParams): Promise<TokenPricesHistoryResponse[]>;
268
+ export interface IExchangeDataService {
269
+ getTokenPrices(params: TGetTokenPricesParams): Promise<TTokenPricesResponse[]>;
270
+ getTokenPriceHistory(params: TGetTokenPriceHistoryParams): Promise<TTokenPricesHistoryResponse[]>;
262
271
  getCurrencyRatio(currency: string): Promise<number>;
263
272
  }
264
- export interface NftResponse {
273
+ export type TNftResponse = {
265
274
  hash: string;
266
275
  collection: {
267
276
  name?: string;
@@ -276,58 +285,58 @@ export interface NftResponse {
276
285
  image?: string;
277
286
  name?: string;
278
287
  isSVG?: boolean;
279
- }
280
- export interface NftsResponse {
281
- items: NftResponse[];
288
+ };
289
+ export type TNftsResponse = {
290
+ items: TNftResponse[];
282
291
  nextCursor?: string;
283
292
  total?: number;
284
- }
285
- export type GetNftsByAddressParams = {
293
+ };
294
+ export type TGetNftsByAddressParams = {
286
295
  address: string;
287
296
  page?: number;
288
297
  cursor?: string;
289
298
  size?: number;
290
299
  };
291
- export type GetNftParam = {
300
+ export type TGetNftParam = {
292
301
  tokenHash: string;
293
302
  collectionHash: string;
294
303
  };
295
- export type HasTokenParam = {
304
+ export type THasTokenParam = {
296
305
  address: string;
297
306
  collectionHash: string;
298
307
  };
299
- export interface NftDataService {
300
- getNftsByAddress(params: GetNftsByAddressParams): Promise<NftsResponse>;
301
- getNft(params: GetNftParam): Promise<NftResponse>;
302
- hasToken(params: HasTokenParam): Promise<boolean>;
308
+ export interface INftDataService {
309
+ getNftsByAddress(params: TGetNftsByAddressParams): Promise<TNftsResponse>;
310
+ getNft(params: TGetNftParam): Promise<TNftResponse>;
311
+ hasToken(params: THasTokenParam): Promise<boolean>;
303
312
  }
304
- export type BuildNftUrlParams = {
313
+ export type TBuildNftUrlParams = {
305
314
  collectionHash: string;
306
315
  tokenHash: string;
307
316
  };
308
- export interface ExplorerService {
317
+ export interface IExplorerService {
309
318
  buildTransactionUrl(hash: string): string;
310
319
  buildContractUrl(contractHash: string): string;
311
- buildNftUrl(params: BuildNftUrlParams): string;
320
+ buildNftUrl(params: TBuildNftUrlParams): string;
312
321
  getAddressTemplateUrl(): string | undefined;
313
322
  getTxTemplateUrl(): string | undefined;
314
323
  getNftTemplateUrl(): string | undefined;
315
324
  getContractTemplateUrl(): string | undefined;
316
325
  }
317
- export type LedgerServiceEmitter = TypedEmitter<{
326
+ export type TLedgerServiceEmitter = TypedEmitter<{
318
327
  getSignatureStart(): void | Promise<void>;
319
328
  getSignatureEnd(): void | Promise<void>;
320
329
  }>;
321
- export type GetLedgerTransport<BSName extends string = string> = (account: Account<BSName>) => Promise<Transport>;
322
- export interface LedgerService<BSName extends string = string> {
323
- emitter: LedgerServiceEmitter;
324
- getLedgerTransport?: GetLedgerTransport<BSName>;
325
- getAccounts(transport: Transport, getUntilIndex?: UntilIndexRecord<BSName>): Promise<Account<BSName>[]>;
326
- getAccount(transport: Transport, index: number): Promise<Account<BSName>>;
330
+ export type TGetLedgerTransport<N extends string = string> = (account: TBSAccount<N>) => Promise<Transport>;
331
+ export interface ILedgerService<N extends string = string> {
332
+ emitter: TLedgerServiceEmitter;
333
+ getLedgerTransport?: TGetLedgerTransport<N>;
334
+ getAccounts(transport: Transport, getUntilIndex?: TUntilIndexRecord<N>): Promise<TBSAccount<N>[]>;
335
+ getAccount(transport: Transport, index: number): Promise<TBSAccount<N>>;
327
336
  }
328
- export type TSwapToken<BSName extends string = string> = {
337
+ export type TSwapToken<N extends string = string> = {
329
338
  id: string;
330
- blockchain?: BSName;
339
+ blockchain?: N;
331
340
  imageUrl?: string;
332
341
  symbol: string;
333
342
  name: string;
@@ -349,17 +358,17 @@ export type TSwapMinMaxAmount = {
349
358
  min: string;
350
359
  max: string | null;
351
360
  };
352
- export type TSwapOrchestratorEvents<BSName extends string = string> = {
353
- accountToUse: (account: TSwapValidateValue<Account<BSName>>) => void | Promise<void>;
361
+ export type TSwapOrchestratorEvents<N extends string = string> = {
362
+ accountToUse: (account: TSwapValidateValue<TBSAccount<N>>) => void | Promise<void>;
354
363
  amountToUse: (amount: TSwapLoadableValue<string>) => void | Promise<void>;
355
364
  amountToUseMinMax: (minMax: TSwapLoadableValue<TSwapMinMaxAmount>) => void | Promise<void>;
356
- tokenToUse: (token: TSwapLoadableValue<TSwapToken<BSName>>) => void | Promise<void>;
357
- availableTokensToUse: (tokens: TSwapLoadableValue<TSwapToken<BSName>[]>) => void | Promise<void>;
365
+ tokenToUse: (token: TSwapLoadableValue<TSwapToken<N>>) => void | Promise<void>;
366
+ availableTokensToUse: (tokens: TSwapLoadableValue<TSwapToken<N>[]>) => void | Promise<void>;
358
367
  addressToReceive: (account: TSwapValidateValue<string>) => void | Promise<void>;
359
368
  extraIdToReceive: (extraIdToReceive: TSwapValidateValue<string>) => void;
360
369
  amountToReceive: (amount: TSwapLoadableValue<string>) => void | Promise<void>;
361
- tokenToReceive: (token: TSwapLoadableValue<TSwapToken<BSName>>) => void | Promise<void>;
362
- availableTokensToReceive: (tokens: TSwapLoadableValue<TSwapToken<BSName>[]>) => void | Promise<void>;
370
+ tokenToReceive: (token: TSwapLoadableValue<TSwapToken<N>>) => void | Promise<void>;
371
+ availableTokensToReceive: (tokens: TSwapLoadableValue<TSwapToken<N>[]>) => void | Promise<void>;
363
372
  error: (error: string) => void | Promise<void>;
364
373
  };
365
374
  export type TSwapResult = {
@@ -376,20 +385,20 @@ export type TSwapServiceStatusResponse = {
376
385
  export interface ISwapService {
377
386
  getStatus(id: string): Promise<TSwapServiceStatusResponse>;
378
387
  }
379
- export interface ISwapOrchestrator<BSName extends string = string> {
380
- eventEmitter: TypedEmitter<TSwapOrchestratorEvents<BSName>>;
381
- setTokenToUse(token: TSwapToken<BSName> | null): Promise<void>;
382
- setAccountToUse(account: Account<BSName> | null): Promise<void>;
388
+ export interface ISwapOrchestrator<N extends string = string> {
389
+ eventEmitter: TypedEmitter<TSwapOrchestratorEvents<N>>;
390
+ setTokenToUse(token: TSwapToken<N> | null): Promise<void>;
391
+ setAccountToUse(account: TBSAccount<N> | null): Promise<void>;
383
392
  setAmountToUse(amount: string | null): Promise<void>;
384
- setTokenToReceive(token: TSwapToken<BSName> | null): Promise<void>;
393
+ setTokenToReceive(token: TSwapToken<N> | null): Promise<void>;
385
394
  setAddressToReceive(address: string | null): Promise<void>;
386
395
  setExtraIdToReceive(extraId: string | null): Promise<void>;
387
396
  swap(): Promise<TSwapResult>;
388
397
  calculateFee(): Promise<string>;
389
398
  }
390
- export type TBridgeToken<BSName extends string = string> = Token & {
399
+ export type TBridgeToken<N extends string = string> = TBSToken & {
400
+ blockchain: N;
391
401
  multichainId: string;
392
- blockchain: BSName;
393
402
  };
394
403
  export type TBridgeValue<T> = {
395
404
  value: T | null;
@@ -399,64 +408,65 @@ export type TBridgeValue<T> = {
399
408
  export type TBridgeValidateValue<T> = TBridgeValue<T> & {
400
409
  valid: boolean | null;
401
410
  };
402
- export type TBridgeOrchestratorEvents<BSName extends string = string> = {
403
- accountToUse: (account: TBridgeValue<Account<BSName>>) => void | Promise<void>;
411
+ export type TBridgeOrchestratorEvents<N extends string = string> = {
412
+ accountToUse: (account: TBridgeValue<TBSAccount<N>>) => void | Promise<void>;
404
413
  amountToUse: (amount: TBridgeValidateValue<string>) => void | Promise<void>;
405
414
  amountToUseMin: (max: TBridgeValue<string>) => void | Promise<void>;
406
415
  amountToUseMax: (max: TBridgeValue<string>) => void | Promise<void>;
407
- tokenToUse: (token: TBridgeValue<TBridgeToken<BSName>>) => void | Promise<void>;
408
- availableTokensToUse: (tokens: TBridgeValue<TBridgeToken<BSName>[]>) => void | Promise<void>;
416
+ tokenToUse: (token: TBridgeValue<TBridgeToken<N>>) => void | Promise<void>;
417
+ availableTokensToUse: (tokens: TBridgeValue<TBridgeToken<N>[]>) => void | Promise<void>;
409
418
  addressToReceive: (account: TBridgeValidateValue<string>) => void | Promise<void>;
410
419
  amountToReceive: (amount: TBridgeValue<string>) => void | Promise<void>;
411
- tokenToReceive: (token: TBridgeValue<TBridgeToken<BSName>>) => void | Promise<void>;
412
- tokenToUseBalance: (balance: TBridgeValue<BalanceResponse | undefined>) => void | Promise<void>;
420
+ tokenToReceive: (token: TBridgeValue<TBridgeToken<N>>) => void | Promise<void>;
421
+ tokenToUseBalance: (balance: TBridgeValue<TBalanceResponse | undefined>) => void | Promise<void>;
413
422
  bridgeFee: (fee: TBridgeValue<string>) => void | Promise<void>;
414
423
  };
415
- export interface IBridgeOrchestrator<BSName extends string = string> {
416
- eventEmitter: TypedEmitter<TBridgeOrchestratorEvents<BSName>>;
417
- setTokenToUse(token: TBridgeToken<BSName> | null): Promise<void>;
418
- setAccountToUse(account: Account<BSName> | null): Promise<void>;
424
+ export interface IBridgeOrchestrator<N extends string = string> {
425
+ eventEmitter: TypedEmitter<TBridgeOrchestratorEvents<N>>;
426
+ setTokenToUse(token: TBridgeToken<N> | null): Promise<void>;
427
+ setAccountToUse(account: TBSAccount<N> | null): Promise<void>;
419
428
  setAmountToUse(amount: string | null): Promise<void>;
420
429
  setAddressToReceive(address: string | null): Promise<void>;
421
- setBalances(balances: BalanceResponse[] | null): Promise<void>;
430
+ setBalances(balances: TBalanceResponse[] | null): Promise<void>;
422
431
  switchTokens(): Promise<void>;
423
432
  bridge(): Promise<string>;
424
433
  }
425
- export interface IBSWithNeo3NeoXBridge<BSName extends string = string> {
426
- neo3NeoXBridgeService: INeo3NeoXBridgeService<BSName>;
434
+ export interface IBSWithNeo3NeoXBridge<N extends string = string> {
435
+ neo3NeoXBridgeService: INeo3NeoXBridgeService<N>;
427
436
  }
428
437
  export type TNeo3NeoXBridgeServiceConstants = {
429
438
  bridgeFee: string;
430
439
  bridgeMaxAmount: string;
431
440
  bridgeMinAmount: string;
432
441
  };
433
- export type TNeo3NeoXBridgeServiceBridgeParam<BSName extends string = string> = {
434
- account: Account<BSName>;
442
+ export type TNeo3NeoXBridgeServiceBridgeParam<N extends string = string> = {
443
+ account: TBSAccount<N>;
435
444
  receiverAddress: string;
436
445
  amount: string;
437
- token: TBridgeToken<BSName>;
446
+ token: TBridgeToken<N>;
438
447
  bridgeFee: string;
439
448
  };
440
- export type TNeo3NeoXBridgeServiceGetApprovalParam<BSName extends string = string> = {
441
- account: Account<BSName>;
449
+ export type TNeo3NeoXBridgeServiceGetApprovalParam<N extends string = string> = {
450
+ account: TBSAccount<N>;
442
451
  amount: string;
443
- token: TBridgeToken<BSName>;
452
+ token: TBridgeToken<N>;
444
453
  };
445
- export type TNeo3NeoXBridgeServiceGetNonceParams<BSName extends string = string> = {
446
- token: TBridgeToken<BSName>;
454
+ export type TNeo3NeoXBridgeServiceGetNonceParams<N extends string = string> = {
455
+ token: TBridgeToken<N>;
447
456
  transactionHash: string;
448
457
  };
449
- export type TNeo3NeoXBridgeServiceGetTransactionHashByNonceParams<BSName extends string = string> = {
450
- token: TBridgeToken<BSName>;
458
+ export type TNeo3NeoXBridgeServiceGetTransactionHashByNonceParams<N extends string = string> = {
459
+ token: TBridgeToken<N>;
451
460
  nonce: string;
452
461
  };
453
- export interface INeo3NeoXBridgeService<BSName extends string = string> {
454
- tokens: TBridgeToken<BSName>[];
462
+ export interface INeo3NeoXBridgeService<N extends string = string> {
463
+ readonly gasToken: TBridgeToken<N>;
464
+ readonly neoToken: TBridgeToken<N>;
455
465
  getApprovalFee(params: TNeo3NeoXBridgeServiceGetApprovalParam): Promise<string>;
456
466
  getBridgeConstants(token: TBridgeToken): Promise<TNeo3NeoXBridgeServiceConstants>;
457
- bridge(params: TNeo3NeoXBridgeServiceBridgeParam<BSName>): Promise<string>;
458
- getNonce(params: TNeo3NeoXBridgeServiceGetNonceParams<BSName>): Promise<string>;
459
- getTransactionHashByNonce(params: TNeo3NeoXBridgeServiceGetTransactionHashByNonceParams<BSName>): Promise<string>;
467
+ bridge(params: TNeo3NeoXBridgeServiceBridgeParam<N>): Promise<string>;
468
+ getNonce(params: TNeo3NeoXBridgeServiceGetNonceParams<N>): Promise<string>;
469
+ getTransactionHashByNonce(params: TNeo3NeoXBridgeServiceGetTransactionHashByNonceParams<N>): Promise<string>;
460
470
  }
461
471
  export type TTokenServicePredicateParams = {
462
472
  hash: string;
@@ -472,7 +482,22 @@ export interface ITokenService {
472
482
  predicate(compareFrom: TTokenServicePredicateParams, compareTo: TTokenServicePredicateParams): boolean;
473
483
  predicateByHash(compareFrom: TTokenServicePredicateByHashParams, compareTo: TTokenServicePredicateByHashParams): boolean;
474
484
  predicateBySymbol(compareFrom: TTokenServicePredicateBySymbolParams, compareTo: TTokenServicePredicateBySymbolParams): boolean;
475
- normalizeToken<T extends Token | Token[]>(token: T): T;
485
+ normalizeToken<T extends TBSToken | TBSToken[]>(token: T): T;
476
486
  normalizeHash(hash: string): string;
477
487
  }
488
+ export type TWalletConnectServiceRequestMethodParams<N extends string = string> = {
489
+ account: TBSAccount<N>;
490
+ params: any;
491
+ };
492
+ export type TWalletConnectServiceRequestMethod = (params: TWalletConnectServiceRequestMethodParams) => Promise<any>;
493
+ export interface IWalletConnectService {
494
+ readonly namespace: string;
495
+ readonly chain: string;
496
+ readonly supportedMethods: string[];
497
+ readonly supportedEvents: string[];
498
+ readonly calculableMethods: string[];
499
+ readonly autoApproveMethods: string[];
500
+ calculateRequestFee(args: TWalletConnectServiceRequestMethodParams): Promise<string>;
501
+ [methodName: string]: any | TWalletConnectServiceRequestMethod;
502
+ }
478
503
  export {};
@@ -1,8 +1,7 @@
1
- import { ExchangeDataService, GetTokenPriceHistoryParams, GetTokenPricesParams, TokenPricesHistoryResponse, TokenPricesResponse } from '../../interfaces';
2
- export declare class CryptoCompareEDS implements ExchangeDataService {
1
+ import { TGetTokenPriceHistoryParams, TGetTokenPricesParams, IExchangeDataService, TTokenPricesHistoryResponse, TTokenPricesResponse } from '../../interfaces';
2
+ export declare class CryptoCompareEDS implements IExchangeDataService {
3
3
  #private;
4
- constructor();
5
- getTokenPrices(params: GetTokenPricesParams): Promise<TokenPricesResponse[]>;
6
- getTokenPriceHistory(params: GetTokenPriceHistoryParams): Promise<TokenPricesHistoryResponse[]>;
4
+ getTokenPrices(params: TGetTokenPricesParams): Promise<TTokenPricesResponse[]>;
5
+ getTokenPriceHistory(params: TGetTokenPriceHistoryParams): Promise<TTokenPricesHistoryResponse[]>;
7
6
  getCurrencyRatio(currency: string): Promise<number>;
8
7
  }