@cityofzion/blockchain-service 1.21.2 → 1.21.3

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,125 @@
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 type TTransactionNotificationTypedResponse = {
84
96
  type: string;
85
97
  value?: string;
86
98
  };
87
- export type TransactionNotificationStateResponse = {
99
+ export type TTransactionNotificationStateResponse = {
88
100
  type: string;
89
- value?: string | TransactionNotificationTypedResponse[];
101
+ value?: string | TTransactionNotificationTypedResponse[];
90
102
  };
91
- export type TransactionNotifications = {
103
+ export type TTransactionNotifications = {
92
104
  eventName: string;
93
- state?: TransactionNotificationStateResponse | TransactionNotificationStateResponse[];
105
+ state?: TTransactionNotificationStateResponse | TTransactionNotificationStateResponse[];
94
106
  };
95
- export type TransactionTransferAsset = {
107
+ export type TTransactionTransferAsset = {
96
108
  amount: string;
97
109
  to: string;
98
110
  from: string;
99
111
  type: 'token';
100
112
  contractHash: string;
101
- token?: Token;
113
+ token?: TBSToken;
102
114
  };
103
- export type TransactionTransferNft = {
115
+ export type TTransactionTransferNft = {
104
116
  tokenHash: string;
105
117
  to: string;
106
118
  from: string;
107
119
  type: 'nft';
108
120
  collectionHash: string;
109
121
  };
110
- type TransactionDefaultResponse = {
122
+ type TTransactionDefaultResponse = {
111
123
  type: 'default';
112
124
  };
113
125
  export type TransactionBridgeNeo3NeoXResponse = {
@@ -118,39 +130,39 @@ export type TransactionBridgeNeo3NeoXResponse = {
118
130
  receiverAddress: string;
119
131
  };
120
132
  };
121
- export type TransactionResponse = {
133
+ export type TTransactionResponse = {
122
134
  hash: string;
123
135
  block: number;
124
136
  time: number;
125
- transfers: (TransactionTransferAsset | TransactionTransferNft)[];
137
+ transfers: (TTransactionTransferAsset | TTransactionTransferNft)[];
126
138
  fee?: string;
127
- notifications: TransactionNotifications[];
128
- } & (TransactionDefaultResponse | TransactionBridgeNeo3NeoXResponse);
129
- export type ContractParameter = {
139
+ notifications: TTransactionNotifications[];
140
+ } & (TTransactionDefaultResponse | TransactionBridgeNeo3NeoXResponse);
141
+ export type TContractParameter = {
130
142
  name: string;
131
143
  type: string;
132
144
  };
133
- export type TransactionsByAddressResponse = {
134
- transactions: TransactionResponse[];
145
+ export type TTransactionsByAddressResponse = {
146
+ transactions: TTransactionResponse[];
135
147
  nextPageParams?: any;
136
148
  };
137
- export type TransactionsByAddressParams = {
149
+ export type TTransactionsByAddressParams = {
138
150
  address: string;
139
151
  nextPageParams?: any;
140
152
  };
141
- export type FullTransactionsByAddressParams = {
153
+ export type TFullTransactionsByAddressParams = {
142
154
  address: string;
143
155
  dateFrom: string;
144
156
  dateTo: string;
145
157
  pageSize?: number;
146
158
  nextCursor?: string;
147
159
  };
148
- export type ExportTransactionsByAddressParams = {
160
+ export type TExportTransactionsByAddressParams = {
149
161
  address: string;
150
162
  dateFrom: string;
151
163
  dateTo: string;
152
164
  };
153
- export type FullTransactionNftEvent = {
165
+ export type TFullTransactionNftEvent = {
154
166
  eventType: 'nft';
155
167
  amount?: string;
156
168
  methodName: string;
@@ -167,7 +179,7 @@ export type FullTransactionNftEvent = {
167
179
  name?: string;
168
180
  collectionName?: string;
169
181
  };
170
- export type FullTransactionAssetEvent = {
182
+ export type TFullTransactionAssetEvent = {
171
183
  eventType: 'token';
172
184
  amount?: string;
173
185
  methodName: string;
@@ -177,13 +189,13 @@ export type FullTransactionAssetEvent = {
177
189
  toUrl?: string;
178
190
  from?: string;
179
191
  fromUrl?: string;
180
- token?: Token;
192
+ token?: TBSToken;
181
193
  tokenType: 'generic' | (string & NonNullable<unknown>);
182
194
  };
183
- type FullTransactionsItemDefault = {
195
+ type TFullTransactionsItemDefault = {
184
196
  type: 'default';
185
197
  };
186
- export type FullTransactionsItemBridgeNeo3NeoX = {
198
+ export type TFullTransactionsItemBridgeNeo3NeoX = {
187
199
  type: 'bridgeNeo3NeoX';
188
200
  data: {
189
201
  amount: string;
@@ -191,7 +203,7 @@ export type FullTransactionsItemBridgeNeo3NeoX = {
191
203
  receiverAddress: string;
192
204
  };
193
205
  };
194
- export type FullTransactionsItem = {
206
+ export type TFullTransactionsItem = {
195
207
  txId: string;
196
208
  txIdUrl?: string;
197
209
  block: number;
@@ -200,68 +212,62 @@ export type FullTransactionsItem = {
200
212
  notificationCount: number;
201
213
  networkFeeAmount?: string;
202
214
  systemFeeAmount?: string;
203
- events: (FullTransactionAssetEvent | FullTransactionNftEvent)[];
204
- } & (FullTransactionsItemDefault | FullTransactionsItemBridgeNeo3NeoX);
205
- export type FullTransactionsByAddressResponse = {
215
+ events: (TFullTransactionAssetEvent | TFullTransactionNftEvent)[];
216
+ } & (TFullTransactionsItemDefault | TFullTransactionsItemBridgeNeo3NeoX);
217
+ export type TFullTransactionsByAddressResponse = {
206
218
  nextCursor?: string;
207
- data: FullTransactionsItem[];
219
+ data: TFullTransactionsItem[];
208
220
  };
209
- export type ContractMethod = {
221
+ export type TContractMethod = {
210
222
  name: string;
211
- parameters: ContractParameter[];
223
+ parameters: TContractParameter[];
212
224
  };
213
225
  export type ContractResponse = {
214
226
  hash: string;
215
227
  name: string;
216
- methods: ContractMethod[];
228
+ methods: TContractMethod[];
217
229
  };
218
- export type BalanceResponse = {
230
+ export type TBalanceResponse = {
219
231
  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>;
232
+ token: TBSToken;
233
+ };
234
+ export interface IBlockchainDataService {
235
+ readonly maxTimeToConfirmTransactionInMs: number;
236
+ getTransaction(txid: string): Promise<TTransactionResponse>;
237
+ getTransactionsByAddress(params: TTransactionsByAddressParams): Promise<TTransactionsByAddressResponse>;
238
+ getFullTransactionsByAddress(params: TFullTransactionsByAddressParams): Promise<TFullTransactionsByAddressResponse>;
239
+ exportFullTransactionsByAddress(params: TExportTransactionsByAddressParams): Promise<string>;
233
240
  getContract(contractHash: string): Promise<ContractResponse>;
234
- getTokenInfo(tokenHash: string): Promise<Token>;
235
- getBalance(address: string): Promise<BalanceResponse[]>;
241
+ getTokenInfo(tokenHash: string): Promise<TBSToken>;
242
+ getBalance(address: string): Promise<TBalanceResponse[]>;
236
243
  getBlockHeight(): Promise<number>;
237
- getRpcList(): Promise<RpcResponse[]>;
238
244
  }
239
- export interface BDSClaimable {
245
+ export interface IClaimDataService {
240
246
  getUnclaimed(address: string): Promise<string>;
241
247
  }
242
- export type TokenPricesResponse = {
248
+ export type TTokenPricesResponse = {
243
249
  usdPrice: number;
244
- token: Token;
250
+ token: TBSToken;
245
251
  };
246
- export type TokenPricesHistoryResponse = {
252
+ export type TTokenPricesHistoryResponse = {
247
253
  usdPrice: number;
248
254
  timestamp: number;
249
- token: Token;
255
+ token: TBSToken;
250
256
  };
251
- export type GetTokenPriceHistoryParams = {
252
- token: Token;
257
+ export type TGetTokenPriceHistoryParams = {
258
+ token: TBSToken;
253
259
  type: 'hour' | 'day';
254
260
  limit: number;
255
261
  };
256
- export type GetTokenPricesParams = {
257
- tokens: Token[];
262
+ export type TGetTokenPricesParams = {
263
+ tokens: TBSToken[];
258
264
  };
259
- export interface ExchangeDataService {
260
- getTokenPrices(params: GetTokenPricesParams): Promise<TokenPricesResponse[]>;
261
- getTokenPriceHistory(params: GetTokenPriceHistoryParams): Promise<TokenPricesHistoryResponse[]>;
265
+ export interface IExchangeDataService {
266
+ getTokenPrices(params: TGetTokenPricesParams): Promise<TTokenPricesResponse[]>;
267
+ getTokenPriceHistory(params: TGetTokenPriceHistoryParams): Promise<TTokenPricesHistoryResponse[]>;
262
268
  getCurrencyRatio(currency: string): Promise<number>;
263
269
  }
264
- export interface NftResponse {
270
+ export type TNftResponse = {
265
271
  hash: string;
266
272
  collection: {
267
273
  name?: string;
@@ -276,58 +282,58 @@ export interface NftResponse {
276
282
  image?: string;
277
283
  name?: string;
278
284
  isSVG?: boolean;
279
- }
280
- export interface NftsResponse {
281
- items: NftResponse[];
285
+ };
286
+ export type TNftsResponse = {
287
+ items: TNftResponse[];
282
288
  nextCursor?: string;
283
289
  total?: number;
284
- }
285
- export type GetNftsByAddressParams = {
290
+ };
291
+ export type TGetNftsByAddressParams = {
286
292
  address: string;
287
293
  page?: number;
288
294
  cursor?: string;
289
295
  size?: number;
290
296
  };
291
- export type GetNftParam = {
297
+ export type TGetNftParam = {
292
298
  tokenHash: string;
293
299
  collectionHash: string;
294
300
  };
295
- export type HasTokenParam = {
301
+ export type THasTokenParam = {
296
302
  address: string;
297
303
  collectionHash: string;
298
304
  };
299
- export interface NftDataService {
300
- getNftsByAddress(params: GetNftsByAddressParams): Promise<NftsResponse>;
301
- getNft(params: GetNftParam): Promise<NftResponse>;
302
- hasToken(params: HasTokenParam): Promise<boolean>;
305
+ export interface INftDataService {
306
+ getNftsByAddress(params: TGetNftsByAddressParams): Promise<TNftsResponse>;
307
+ getNft(params: TGetNftParam): Promise<TNftResponse>;
308
+ hasToken(params: THasTokenParam): Promise<boolean>;
303
309
  }
304
- export type BuildNftUrlParams = {
310
+ export type TBuildNftUrlParams = {
305
311
  collectionHash: string;
306
312
  tokenHash: string;
307
313
  };
308
- export interface ExplorerService {
314
+ export interface IExplorerService {
309
315
  buildTransactionUrl(hash: string): string;
310
316
  buildContractUrl(contractHash: string): string;
311
- buildNftUrl(params: BuildNftUrlParams): string;
317
+ buildNftUrl(params: TBuildNftUrlParams): string;
312
318
  getAddressTemplateUrl(): string | undefined;
313
319
  getTxTemplateUrl(): string | undefined;
314
320
  getNftTemplateUrl(): string | undefined;
315
321
  getContractTemplateUrl(): string | undefined;
316
322
  }
317
- export type LedgerServiceEmitter = TypedEmitter<{
323
+ export type TLedgerServiceEmitter = TypedEmitter<{
318
324
  getSignatureStart(): void | Promise<void>;
319
325
  getSignatureEnd(): void | Promise<void>;
320
326
  }>;
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>>;
327
+ export type TGetLedgerTransport<N extends string = string> = (account: TBSAccount<N>) => Promise<Transport>;
328
+ export interface ILedgerService<N extends string = string> {
329
+ emitter: TLedgerServiceEmitter;
330
+ getLedgerTransport?: TGetLedgerTransport<N>;
331
+ getAccounts(transport: Transport, getUntilIndex?: TUntilIndexRecord<N>): Promise<TBSAccount<N>[]>;
332
+ getAccount(transport: Transport, index: number): Promise<TBSAccount<N>>;
327
333
  }
328
- export type TSwapToken<BSName extends string = string> = {
334
+ export type TSwapToken<N extends string = string> = {
329
335
  id: string;
330
- blockchain?: BSName;
336
+ blockchain?: N;
331
337
  imageUrl?: string;
332
338
  symbol: string;
333
339
  name: string;
@@ -349,17 +355,17 @@ export type TSwapMinMaxAmount = {
349
355
  min: string;
350
356
  max: string | null;
351
357
  };
352
- export type TSwapOrchestratorEvents<BSName extends string = string> = {
353
- accountToUse: (account: TSwapValidateValue<Account<BSName>>) => void | Promise<void>;
358
+ export type TSwapOrchestratorEvents<N extends string = string> = {
359
+ accountToUse: (account: TSwapValidateValue<TBSAccount<N>>) => void | Promise<void>;
354
360
  amountToUse: (amount: TSwapLoadableValue<string>) => void | Promise<void>;
355
361
  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>;
362
+ tokenToUse: (token: TSwapLoadableValue<TSwapToken<N>>) => void | Promise<void>;
363
+ availableTokensToUse: (tokens: TSwapLoadableValue<TSwapToken<N>[]>) => void | Promise<void>;
358
364
  addressToReceive: (account: TSwapValidateValue<string>) => void | Promise<void>;
359
365
  extraIdToReceive: (extraIdToReceive: TSwapValidateValue<string>) => void;
360
366
  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>;
367
+ tokenToReceive: (token: TSwapLoadableValue<TSwapToken<N>>) => void | Promise<void>;
368
+ availableTokensToReceive: (tokens: TSwapLoadableValue<TSwapToken<N>[]>) => void | Promise<void>;
363
369
  error: (error: string) => void | Promise<void>;
364
370
  };
365
371
  export type TSwapResult = {
@@ -376,20 +382,20 @@ export type TSwapServiceStatusResponse = {
376
382
  export interface ISwapService {
377
383
  getStatus(id: string): Promise<TSwapServiceStatusResponse>;
378
384
  }
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>;
385
+ export interface ISwapOrchestrator<N extends string = string> {
386
+ eventEmitter: TypedEmitter<TSwapOrchestratorEvents<N>>;
387
+ setTokenToUse(token: TSwapToken<N> | null): Promise<void>;
388
+ setAccountToUse(account: TBSAccount<N> | null): Promise<void>;
383
389
  setAmountToUse(amount: string | null): Promise<void>;
384
- setTokenToReceive(token: TSwapToken<BSName> | null): Promise<void>;
390
+ setTokenToReceive(token: TSwapToken<N> | null): Promise<void>;
385
391
  setAddressToReceive(address: string | null): Promise<void>;
386
392
  setExtraIdToReceive(extraId: string | null): Promise<void>;
387
393
  swap(): Promise<TSwapResult>;
388
394
  calculateFee(): Promise<string>;
389
395
  }
390
- export type TBridgeToken<BSName extends string = string> = Token & {
396
+ export type TBridgeToken<N extends string = string> = TBSToken & {
397
+ blockchain: N;
391
398
  multichainId: string;
392
- blockchain: BSName;
393
399
  };
394
400
  export type TBridgeValue<T> = {
395
401
  value: T | null;
@@ -399,64 +405,65 @@ export type TBridgeValue<T> = {
399
405
  export type TBridgeValidateValue<T> = TBridgeValue<T> & {
400
406
  valid: boolean | null;
401
407
  };
402
- export type TBridgeOrchestratorEvents<BSName extends string = string> = {
403
- accountToUse: (account: TBridgeValue<Account<BSName>>) => void | Promise<void>;
408
+ export type TBridgeOrchestratorEvents<N extends string = string> = {
409
+ accountToUse: (account: TBridgeValue<TBSAccount<N>>) => void | Promise<void>;
404
410
  amountToUse: (amount: TBridgeValidateValue<string>) => void | Promise<void>;
405
411
  amountToUseMin: (max: TBridgeValue<string>) => void | Promise<void>;
406
412
  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>;
413
+ tokenToUse: (token: TBridgeValue<TBridgeToken<N>>) => void | Promise<void>;
414
+ availableTokensToUse: (tokens: TBridgeValue<TBridgeToken<N>[]>) => void | Promise<void>;
409
415
  addressToReceive: (account: TBridgeValidateValue<string>) => void | Promise<void>;
410
416
  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>;
417
+ tokenToReceive: (token: TBridgeValue<TBridgeToken<N>>) => void | Promise<void>;
418
+ tokenToUseBalance: (balance: TBridgeValue<TBalanceResponse | undefined>) => void | Promise<void>;
413
419
  bridgeFee: (fee: TBridgeValue<string>) => void | Promise<void>;
414
420
  };
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>;
421
+ export interface IBridgeOrchestrator<N extends string = string> {
422
+ eventEmitter: TypedEmitter<TBridgeOrchestratorEvents<N>>;
423
+ setTokenToUse(token: TBridgeToken<N> | null): Promise<void>;
424
+ setAccountToUse(account: TBSAccount<N> | null): Promise<void>;
419
425
  setAmountToUse(amount: string | null): Promise<void>;
420
426
  setAddressToReceive(address: string | null): Promise<void>;
421
- setBalances(balances: BalanceResponse[] | null): Promise<void>;
427
+ setBalances(balances: TBalanceResponse[] | null): Promise<void>;
422
428
  switchTokens(): Promise<void>;
423
429
  bridge(): Promise<string>;
424
430
  }
425
- export interface IBSWithNeo3NeoXBridge<BSName extends string = string> {
426
- neo3NeoXBridgeService: INeo3NeoXBridgeService<BSName>;
431
+ export interface IBSWithNeo3NeoXBridge<N extends string = string> {
432
+ neo3NeoXBridgeService: INeo3NeoXBridgeService<N>;
427
433
  }
428
434
  export type TNeo3NeoXBridgeServiceConstants = {
429
435
  bridgeFee: string;
430
436
  bridgeMaxAmount: string;
431
437
  bridgeMinAmount: string;
432
438
  };
433
- export type TNeo3NeoXBridgeServiceBridgeParam<BSName extends string = string> = {
434
- account: Account<BSName>;
439
+ export type TNeo3NeoXBridgeServiceBridgeParam<N extends string = string> = {
440
+ account: TBSAccount<N>;
435
441
  receiverAddress: string;
436
442
  amount: string;
437
- token: TBridgeToken<BSName>;
443
+ token: TBridgeToken<N>;
438
444
  bridgeFee: string;
439
445
  };
440
- export type TNeo3NeoXBridgeServiceGetApprovalParam<BSName extends string = string> = {
441
- account: Account<BSName>;
446
+ export type TNeo3NeoXBridgeServiceGetApprovalParam<N extends string = string> = {
447
+ account: TBSAccount<N>;
442
448
  amount: string;
443
- token: TBridgeToken<BSName>;
449
+ token: TBridgeToken<N>;
444
450
  };
445
- export type TNeo3NeoXBridgeServiceGetNonceParams<BSName extends string = string> = {
446
- token: TBridgeToken<BSName>;
451
+ export type TNeo3NeoXBridgeServiceGetNonceParams<N extends string = string> = {
452
+ token: TBridgeToken<N>;
447
453
  transactionHash: string;
448
454
  };
449
- export type TNeo3NeoXBridgeServiceGetTransactionHashByNonceParams<BSName extends string = string> = {
450
- token: TBridgeToken<BSName>;
455
+ export type TNeo3NeoXBridgeServiceGetTransactionHashByNonceParams<N extends string = string> = {
456
+ token: TBridgeToken<N>;
451
457
  nonce: string;
452
458
  };
453
- export interface INeo3NeoXBridgeService<BSName extends string = string> {
454
- tokens: TBridgeToken<BSName>[];
459
+ export interface INeo3NeoXBridgeService<N extends string = string> {
460
+ readonly gasToken: TBridgeToken<N>;
461
+ readonly neoToken: TBridgeToken<N>;
455
462
  getApprovalFee(params: TNeo3NeoXBridgeServiceGetApprovalParam): Promise<string>;
456
463
  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>;
464
+ bridge(params: TNeo3NeoXBridgeServiceBridgeParam<N>): Promise<string>;
465
+ getNonce(params: TNeo3NeoXBridgeServiceGetNonceParams<N>): Promise<string>;
466
+ getTransactionHashByNonce(params: TNeo3NeoXBridgeServiceGetTransactionHashByNonceParams<N>): Promise<string>;
460
467
  }
461
468
  export type TTokenServicePredicateParams = {
462
469
  hash: string;
@@ -472,7 +479,7 @@ export interface ITokenService {
472
479
  predicate(compareFrom: TTokenServicePredicateParams, compareTo: TTokenServicePredicateParams): boolean;
473
480
  predicateByHash(compareFrom: TTokenServicePredicateByHashParams, compareTo: TTokenServicePredicateByHashParams): boolean;
474
481
  predicateBySymbol(compareFrom: TTokenServicePredicateBySymbolParams, compareTo: TTokenServicePredicateBySymbolParams): boolean;
475
- normalizeToken<T extends Token | Token[]>(token: T): T;
482
+ normalizeToken<T extends TBSToken | TBSToken[]>(token: T): T;
476
483
  normalizeHash(hash: string): string;
477
484
  }
478
485
  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
  }