@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.
- package/dist/functions.d.ts +14 -14
- package/dist/functions.js +20 -21
- package/dist/helpers/BSBigNumberHelper.d.ts +2 -1
- package/dist/helpers/BSBigNumberHelper.js +3 -3
- package/dist/helpers/BSFullTransactionsByAddressHelper.d.ts +8 -2
- package/dist/helpers/BSFullTransactionsByAddressHelper.js +9 -0
- package/dist/helpers/BSKeychainHelper.d.ts +8 -0
- package/dist/helpers/BSKeychainHelper.js +96 -0
- package/dist/helpers/BSUtilsHelper.d.ts +2 -0
- package/dist/helpers/BSUtilsHelper.js +12 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/interfaces.d.ts +176 -169
- package/dist/services/exchange-data/CryptoCompareEDS.d.ts +4 -5
- package/dist/services/exchange-data/CryptoCompareEDS.js +16 -11
- package/dist/services/exchange-data/FlamingoForthewinEDS.d.ts +5 -4
- package/dist/services/exchange-data/FlamingoForthewinEDS.js +30 -20
- package/dist/services/nft-data/GhostMarketNDS.d.ts +9 -0
- package/dist/services/nft-data/GhostMarketNDS.js +89 -0
- package/dist/services/token/TokenService.d.ts +3 -7
- package/dist/types.d.ts +57 -0
- package/dist/types.js +2 -0
- package/package.json +24 -19
package/dist/interfaces.d.ts
CHANGED
|
@@ -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
|
|
5
|
-
export type
|
|
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:
|
|
11
|
+
blockchain: N;
|
|
12
12
|
};
|
|
13
|
-
export type
|
|
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
|
|
20
|
-
export type
|
|
21
|
-
|
|
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
|
|
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
|
|
32
|
-
senderAccount:
|
|
33
|
-
intents:
|
|
34
|
-
tipIntent?:
|
|
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
|
|
38
|
-
|
|
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:
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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:
|
|
65
|
+
transfer(param: TTransferParam<N>): Promise<string[]>;
|
|
54
66
|
}
|
|
55
|
-
export interface
|
|
56
|
-
decrypt(keyOrJson: string, password: string): Promise<
|
|
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
|
|
61
|
-
calculateTransferFee(param:
|
|
72
|
+
export interface IBSWithFee<N extends string = string> {
|
|
73
|
+
calculateTransferFee(param: TTransferParam<N>): Promise<string>;
|
|
62
74
|
}
|
|
63
|
-
export interface
|
|
64
|
-
readonly claimToken:
|
|
65
|
-
readonly burnToken:
|
|
66
|
-
|
|
67
|
-
claim(account:
|
|
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
|
|
81
|
+
export interface IBSWithNameService {
|
|
70
82
|
resolveNameServiceDomain(domainName: string): Promise<string>;
|
|
71
83
|
validateNameServiceDomainFormat(domainName: string): boolean;
|
|
72
84
|
}
|
|
73
|
-
export interface
|
|
74
|
-
explorerService:
|
|
85
|
+
export interface IBSWithExplorer {
|
|
86
|
+
explorerService: IExplorerService;
|
|
75
87
|
}
|
|
76
|
-
export interface
|
|
77
|
-
nftDataService:
|
|
88
|
+
export interface IBSWithNft {
|
|
89
|
+
nftDataService: INftDataService;
|
|
78
90
|
}
|
|
79
|
-
export interface
|
|
80
|
-
ledgerService:
|
|
81
|
-
generateAccountFromPublicKey(publicKey: string):
|
|
91
|
+
export interface IBSWithLedger<N extends string = string> {
|
|
92
|
+
ledgerService: ILedgerService<N>;
|
|
93
|
+
generateAccountFromPublicKey(publicKey: string): TBSAccount<N>;
|
|
82
94
|
}
|
|
83
|
-
export type
|
|
95
|
+
export type TTransactionNotificationTypedResponse = {
|
|
84
96
|
type: string;
|
|
85
97
|
value?: string;
|
|
86
98
|
};
|
|
87
|
-
export type
|
|
99
|
+
export type TTransactionNotificationStateResponse = {
|
|
88
100
|
type: string;
|
|
89
|
-
value?: string |
|
|
101
|
+
value?: string | TTransactionNotificationTypedResponse[];
|
|
90
102
|
};
|
|
91
|
-
export type
|
|
103
|
+
export type TTransactionNotifications = {
|
|
92
104
|
eventName: string;
|
|
93
|
-
state?:
|
|
105
|
+
state?: TTransactionNotificationStateResponse | TTransactionNotificationStateResponse[];
|
|
94
106
|
};
|
|
95
|
-
export type
|
|
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?:
|
|
113
|
+
token?: TBSToken;
|
|
102
114
|
};
|
|
103
|
-
export type
|
|
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
|
|
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
|
|
133
|
+
export type TTransactionResponse = {
|
|
122
134
|
hash: string;
|
|
123
135
|
block: number;
|
|
124
136
|
time: number;
|
|
125
|
-
transfers: (
|
|
137
|
+
transfers: (TTransactionTransferAsset | TTransactionTransferNft)[];
|
|
126
138
|
fee?: string;
|
|
127
|
-
notifications:
|
|
128
|
-
} & (
|
|
129
|
-
export type
|
|
139
|
+
notifications: TTransactionNotifications[];
|
|
140
|
+
} & (TTransactionDefaultResponse | TransactionBridgeNeo3NeoXResponse);
|
|
141
|
+
export type TContractParameter = {
|
|
130
142
|
name: string;
|
|
131
143
|
type: string;
|
|
132
144
|
};
|
|
133
|
-
export type
|
|
134
|
-
transactions:
|
|
145
|
+
export type TTransactionsByAddressResponse = {
|
|
146
|
+
transactions: TTransactionResponse[];
|
|
135
147
|
nextPageParams?: any;
|
|
136
148
|
};
|
|
137
|
-
export type
|
|
149
|
+
export type TTransactionsByAddressParams = {
|
|
138
150
|
address: string;
|
|
139
151
|
nextPageParams?: any;
|
|
140
152
|
};
|
|
141
|
-
export type
|
|
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
|
|
160
|
+
export type TExportTransactionsByAddressParams = {
|
|
149
161
|
address: string;
|
|
150
162
|
dateFrom: string;
|
|
151
163
|
dateTo: string;
|
|
152
164
|
};
|
|
153
|
-
export type
|
|
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
|
|
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?:
|
|
192
|
+
token?: TBSToken;
|
|
181
193
|
tokenType: 'generic' | (string & NonNullable<unknown>);
|
|
182
194
|
};
|
|
183
|
-
type
|
|
195
|
+
type TFullTransactionsItemDefault = {
|
|
184
196
|
type: 'default';
|
|
185
197
|
};
|
|
186
|
-
export type
|
|
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
|
|
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: (
|
|
204
|
-
} & (
|
|
205
|
-
export type
|
|
215
|
+
events: (TFullTransactionAssetEvent | TFullTransactionNftEvent)[];
|
|
216
|
+
} & (TFullTransactionsItemDefault | TFullTransactionsItemBridgeNeo3NeoX);
|
|
217
|
+
export type TFullTransactionsByAddressResponse = {
|
|
206
218
|
nextCursor?: string;
|
|
207
|
-
data:
|
|
219
|
+
data: TFullTransactionsItem[];
|
|
208
220
|
};
|
|
209
|
-
export type
|
|
221
|
+
export type TContractMethod = {
|
|
210
222
|
name: string;
|
|
211
|
-
parameters:
|
|
223
|
+
parameters: TContractParameter[];
|
|
212
224
|
};
|
|
213
225
|
export type ContractResponse = {
|
|
214
226
|
hash: string;
|
|
215
227
|
name: string;
|
|
216
|
-
methods:
|
|
228
|
+
methods: TContractMethod[];
|
|
217
229
|
};
|
|
218
|
-
export type
|
|
230
|
+
export type TBalanceResponse = {
|
|
219
231
|
amount: string;
|
|
220
|
-
token:
|
|
221
|
-
};
|
|
222
|
-
export
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
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<
|
|
235
|
-
getBalance(address: string): Promise<
|
|
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
|
|
245
|
+
export interface IClaimDataService {
|
|
240
246
|
getUnclaimed(address: string): Promise<string>;
|
|
241
247
|
}
|
|
242
|
-
export type
|
|
248
|
+
export type TTokenPricesResponse = {
|
|
243
249
|
usdPrice: number;
|
|
244
|
-
token:
|
|
250
|
+
token: TBSToken;
|
|
245
251
|
};
|
|
246
|
-
export type
|
|
252
|
+
export type TTokenPricesHistoryResponse = {
|
|
247
253
|
usdPrice: number;
|
|
248
254
|
timestamp: number;
|
|
249
|
-
token:
|
|
255
|
+
token: TBSToken;
|
|
250
256
|
};
|
|
251
|
-
export type
|
|
252
|
-
token:
|
|
257
|
+
export type TGetTokenPriceHistoryParams = {
|
|
258
|
+
token: TBSToken;
|
|
253
259
|
type: 'hour' | 'day';
|
|
254
260
|
limit: number;
|
|
255
261
|
};
|
|
256
|
-
export type
|
|
257
|
-
tokens:
|
|
262
|
+
export type TGetTokenPricesParams = {
|
|
263
|
+
tokens: TBSToken[];
|
|
258
264
|
};
|
|
259
|
-
export interface
|
|
260
|
-
getTokenPrices(params:
|
|
261
|
-
getTokenPriceHistory(params:
|
|
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
|
|
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
|
|
281
|
-
items:
|
|
285
|
+
};
|
|
286
|
+
export type TNftsResponse = {
|
|
287
|
+
items: TNftResponse[];
|
|
282
288
|
nextCursor?: string;
|
|
283
289
|
total?: number;
|
|
284
|
-
}
|
|
285
|
-
export type
|
|
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
|
|
297
|
+
export type TGetNftParam = {
|
|
292
298
|
tokenHash: string;
|
|
293
299
|
collectionHash: string;
|
|
294
300
|
};
|
|
295
|
-
export type
|
|
301
|
+
export type THasTokenParam = {
|
|
296
302
|
address: string;
|
|
297
303
|
collectionHash: string;
|
|
298
304
|
};
|
|
299
|
-
export interface
|
|
300
|
-
getNftsByAddress(params:
|
|
301
|
-
getNft(params:
|
|
302
|
-
hasToken(params:
|
|
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
|
|
310
|
+
export type TBuildNftUrlParams = {
|
|
305
311
|
collectionHash: string;
|
|
306
312
|
tokenHash: string;
|
|
307
313
|
};
|
|
308
|
-
export interface
|
|
314
|
+
export interface IExplorerService {
|
|
309
315
|
buildTransactionUrl(hash: string): string;
|
|
310
316
|
buildContractUrl(contractHash: string): string;
|
|
311
|
-
buildNftUrl(params:
|
|
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
|
|
323
|
+
export type TLedgerServiceEmitter = TypedEmitter<{
|
|
318
324
|
getSignatureStart(): void | Promise<void>;
|
|
319
325
|
getSignatureEnd(): void | Promise<void>;
|
|
320
326
|
}>;
|
|
321
|
-
export type
|
|
322
|
-
export interface
|
|
323
|
-
emitter:
|
|
324
|
-
getLedgerTransport?:
|
|
325
|
-
getAccounts(transport: Transport, getUntilIndex?:
|
|
326
|
-
getAccount(transport: Transport, index: number): Promise<
|
|
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<
|
|
334
|
+
export type TSwapToken<N extends string = string> = {
|
|
329
335
|
id: string;
|
|
330
|
-
blockchain?:
|
|
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<
|
|
353
|
-
accountToUse: (account: TSwapValidateValue<
|
|
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<
|
|
357
|
-
availableTokensToUse: (tokens: TSwapLoadableValue<TSwapToken<
|
|
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<
|
|
362
|
-
availableTokensToReceive: (tokens: TSwapLoadableValue<TSwapToken<
|
|
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<
|
|
380
|
-
eventEmitter: TypedEmitter<TSwapOrchestratorEvents<
|
|
381
|
-
setTokenToUse(token: TSwapToken<
|
|
382
|
-
setAccountToUse(account:
|
|
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<
|
|
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<
|
|
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<
|
|
403
|
-
accountToUse: (account: TBridgeValue<
|
|
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<
|
|
408
|
-
availableTokensToUse: (tokens: TBridgeValue<TBridgeToken<
|
|
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<
|
|
412
|
-
tokenToUseBalance: (balance: TBridgeValue<
|
|
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<
|
|
416
|
-
eventEmitter: TypedEmitter<TBridgeOrchestratorEvents<
|
|
417
|
-
setTokenToUse(token: TBridgeToken<
|
|
418
|
-
setAccountToUse(account:
|
|
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:
|
|
427
|
+
setBalances(balances: TBalanceResponse[] | null): Promise<void>;
|
|
422
428
|
switchTokens(): Promise<void>;
|
|
423
429
|
bridge(): Promise<string>;
|
|
424
430
|
}
|
|
425
|
-
export interface IBSWithNeo3NeoXBridge<
|
|
426
|
-
neo3NeoXBridgeService: INeo3NeoXBridgeService<
|
|
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<
|
|
434
|
-
account:
|
|
439
|
+
export type TNeo3NeoXBridgeServiceBridgeParam<N extends string = string> = {
|
|
440
|
+
account: TBSAccount<N>;
|
|
435
441
|
receiverAddress: string;
|
|
436
442
|
amount: string;
|
|
437
|
-
token: TBridgeToken<
|
|
443
|
+
token: TBridgeToken<N>;
|
|
438
444
|
bridgeFee: string;
|
|
439
445
|
};
|
|
440
|
-
export type TNeo3NeoXBridgeServiceGetApprovalParam<
|
|
441
|
-
account:
|
|
446
|
+
export type TNeo3NeoXBridgeServiceGetApprovalParam<N extends string = string> = {
|
|
447
|
+
account: TBSAccount<N>;
|
|
442
448
|
amount: string;
|
|
443
|
-
token: TBridgeToken<
|
|
449
|
+
token: TBridgeToken<N>;
|
|
444
450
|
};
|
|
445
|
-
export type TNeo3NeoXBridgeServiceGetNonceParams<
|
|
446
|
-
token: TBridgeToken<
|
|
451
|
+
export type TNeo3NeoXBridgeServiceGetNonceParams<N extends string = string> = {
|
|
452
|
+
token: TBridgeToken<N>;
|
|
447
453
|
transactionHash: string;
|
|
448
454
|
};
|
|
449
|
-
export type TNeo3NeoXBridgeServiceGetTransactionHashByNonceParams<
|
|
450
|
-
token: TBridgeToken<
|
|
455
|
+
export type TNeo3NeoXBridgeServiceGetTransactionHashByNonceParams<N extends string = string> = {
|
|
456
|
+
token: TBridgeToken<N>;
|
|
451
457
|
nonce: string;
|
|
452
458
|
};
|
|
453
|
-
export interface INeo3NeoXBridgeService<
|
|
454
|
-
|
|
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<
|
|
458
|
-
getNonce(params: TNeo3NeoXBridgeServiceGetNonceParams<
|
|
459
|
-
getTransactionHashByNonce(params: TNeo3NeoXBridgeServiceGetTransactionHashByNonceParams<
|
|
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
|
|
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 {
|
|
2
|
-
export declare class CryptoCompareEDS implements
|
|
1
|
+
import { TGetTokenPriceHistoryParams, TGetTokenPricesParams, IExchangeDataService, TTokenPricesHistoryResponse, TTokenPricesResponse } from '../../interfaces';
|
|
2
|
+
export declare class CryptoCompareEDS implements IExchangeDataService {
|
|
3
3
|
#private;
|
|
4
|
-
|
|
5
|
-
|
|
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
|
}
|