@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.
- package/dist/functions.d.ts +15 -14
- package/dist/functions.js +24 -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 +194 -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,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
|
|
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
|
|
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
|
|
102
|
+
export type TTransactionNotificationStateResponse = {
|
|
88
103
|
type: string;
|
|
89
|
-
value?: string |
|
|
104
|
+
value?: string | TTransactionNotificationTypedResponse[];
|
|
90
105
|
};
|
|
91
|
-
export type
|
|
106
|
+
export type TTransactionNotifications = {
|
|
92
107
|
eventName: string;
|
|
93
|
-
state?:
|
|
108
|
+
state?: TTransactionNotificationStateResponse | TTransactionNotificationStateResponse[];
|
|
94
109
|
};
|
|
95
|
-
export type
|
|
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?:
|
|
116
|
+
token?: TBSToken;
|
|
102
117
|
};
|
|
103
|
-
export type
|
|
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
|
|
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
|
|
136
|
+
export type TTransactionResponse = {
|
|
122
137
|
hash: string;
|
|
123
138
|
block: number;
|
|
124
139
|
time: number;
|
|
125
|
-
transfers: (
|
|
140
|
+
transfers: (TTransactionTransferAsset | TTransactionTransferNft)[];
|
|
126
141
|
fee?: string;
|
|
127
|
-
notifications:
|
|
128
|
-
} & (
|
|
129
|
-
export type
|
|
142
|
+
notifications: TTransactionNotifications[];
|
|
143
|
+
} & (TTransactionDefaultResponse | TransactionBridgeNeo3NeoXResponse);
|
|
144
|
+
export type TContractParameter = {
|
|
130
145
|
name: string;
|
|
131
146
|
type: string;
|
|
132
147
|
};
|
|
133
|
-
export type
|
|
134
|
-
transactions:
|
|
148
|
+
export type TTransactionsByAddressResponse = {
|
|
149
|
+
transactions: TTransactionResponse[];
|
|
135
150
|
nextPageParams?: any;
|
|
136
151
|
};
|
|
137
|
-
export type
|
|
152
|
+
export type TTransactionsByAddressParams = {
|
|
138
153
|
address: string;
|
|
139
154
|
nextPageParams?: any;
|
|
140
155
|
};
|
|
141
|
-
export type
|
|
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
|
|
163
|
+
export type TExportTransactionsByAddressParams = {
|
|
149
164
|
address: string;
|
|
150
165
|
dateFrom: string;
|
|
151
166
|
dateTo: string;
|
|
152
167
|
};
|
|
153
|
-
export type
|
|
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
|
|
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?:
|
|
195
|
+
token?: TBSToken;
|
|
181
196
|
tokenType: 'generic' | (string & NonNullable<unknown>);
|
|
182
197
|
};
|
|
183
|
-
type
|
|
198
|
+
type TFullTransactionsItemDefault = {
|
|
184
199
|
type: 'default';
|
|
185
200
|
};
|
|
186
|
-
export type
|
|
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
|
|
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: (
|
|
204
|
-
} & (
|
|
205
|
-
export type
|
|
218
|
+
events: (TFullTransactionAssetEvent | TFullTransactionNftEvent)[];
|
|
219
|
+
} & (TFullTransactionsItemDefault | TFullTransactionsItemBridgeNeo3NeoX);
|
|
220
|
+
export type TFullTransactionsByAddressResponse = {
|
|
206
221
|
nextCursor?: string;
|
|
207
|
-
data:
|
|
222
|
+
data: TFullTransactionsItem[];
|
|
208
223
|
};
|
|
209
|
-
export type
|
|
224
|
+
export type TContractMethod = {
|
|
210
225
|
name: string;
|
|
211
|
-
parameters:
|
|
226
|
+
parameters: TContractParameter[];
|
|
212
227
|
};
|
|
213
228
|
export type ContractResponse = {
|
|
214
229
|
hash: string;
|
|
215
230
|
name: string;
|
|
216
|
-
methods:
|
|
231
|
+
methods: TContractMethod[];
|
|
217
232
|
};
|
|
218
|
-
export type
|
|
233
|
+
export type TBalanceResponse = {
|
|
219
234
|
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>;
|
|
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<
|
|
235
|
-
getBalance(address: string): Promise<
|
|
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
|
|
248
|
+
export interface IClaimDataService {
|
|
240
249
|
getUnclaimed(address: string): Promise<string>;
|
|
241
250
|
}
|
|
242
|
-
export type
|
|
251
|
+
export type TTokenPricesResponse = {
|
|
243
252
|
usdPrice: number;
|
|
244
|
-
token:
|
|
253
|
+
token: TBSToken;
|
|
245
254
|
};
|
|
246
|
-
export type
|
|
255
|
+
export type TTokenPricesHistoryResponse = {
|
|
247
256
|
usdPrice: number;
|
|
248
257
|
timestamp: number;
|
|
249
|
-
token:
|
|
258
|
+
token: TBSToken;
|
|
250
259
|
};
|
|
251
|
-
export type
|
|
252
|
-
token:
|
|
260
|
+
export type TGetTokenPriceHistoryParams = {
|
|
261
|
+
token: TBSToken;
|
|
253
262
|
type: 'hour' | 'day';
|
|
254
263
|
limit: number;
|
|
255
264
|
};
|
|
256
|
-
export type
|
|
257
|
-
tokens:
|
|
265
|
+
export type TGetTokenPricesParams = {
|
|
266
|
+
tokens: TBSToken[];
|
|
258
267
|
};
|
|
259
|
-
export interface
|
|
260
|
-
getTokenPrices(params:
|
|
261
|
-
getTokenPriceHistory(params:
|
|
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
|
|
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
|
|
281
|
-
items:
|
|
288
|
+
};
|
|
289
|
+
export type TNftsResponse = {
|
|
290
|
+
items: TNftResponse[];
|
|
282
291
|
nextCursor?: string;
|
|
283
292
|
total?: number;
|
|
284
|
-
}
|
|
285
|
-
export type
|
|
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
|
|
300
|
+
export type TGetNftParam = {
|
|
292
301
|
tokenHash: string;
|
|
293
302
|
collectionHash: string;
|
|
294
303
|
};
|
|
295
|
-
export type
|
|
304
|
+
export type THasTokenParam = {
|
|
296
305
|
address: string;
|
|
297
306
|
collectionHash: string;
|
|
298
307
|
};
|
|
299
|
-
export interface
|
|
300
|
-
getNftsByAddress(params:
|
|
301
|
-
getNft(params:
|
|
302
|
-
hasToken(params:
|
|
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
|
|
313
|
+
export type TBuildNftUrlParams = {
|
|
305
314
|
collectionHash: string;
|
|
306
315
|
tokenHash: string;
|
|
307
316
|
};
|
|
308
|
-
export interface
|
|
317
|
+
export interface IExplorerService {
|
|
309
318
|
buildTransactionUrl(hash: string): string;
|
|
310
319
|
buildContractUrl(contractHash: string): string;
|
|
311
|
-
buildNftUrl(params:
|
|
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
|
|
326
|
+
export type TLedgerServiceEmitter = TypedEmitter<{
|
|
318
327
|
getSignatureStart(): void | Promise<void>;
|
|
319
328
|
getSignatureEnd(): void | Promise<void>;
|
|
320
329
|
}>;
|
|
321
|
-
export type
|
|
322
|
-
export interface
|
|
323
|
-
emitter:
|
|
324
|
-
getLedgerTransport?:
|
|
325
|
-
getAccounts(transport: Transport, getUntilIndex?:
|
|
326
|
-
getAccount(transport: Transport, index: number): Promise<
|
|
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<
|
|
337
|
+
export type TSwapToken<N extends string = string> = {
|
|
329
338
|
id: string;
|
|
330
|
-
blockchain?:
|
|
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<
|
|
353
|
-
accountToUse: (account: TSwapValidateValue<
|
|
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<
|
|
357
|
-
availableTokensToUse: (tokens: TSwapLoadableValue<TSwapToken<
|
|
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<
|
|
362
|
-
availableTokensToReceive: (tokens: TSwapLoadableValue<TSwapToken<
|
|
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<
|
|
380
|
-
eventEmitter: TypedEmitter<TSwapOrchestratorEvents<
|
|
381
|
-
setTokenToUse(token: TSwapToken<
|
|
382
|
-
setAccountToUse(account:
|
|
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<
|
|
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<
|
|
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<
|
|
403
|
-
accountToUse: (account: TBridgeValue<
|
|
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<
|
|
408
|
-
availableTokensToUse: (tokens: TBridgeValue<TBridgeToken<
|
|
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<
|
|
412
|
-
tokenToUseBalance: (balance: TBridgeValue<
|
|
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<
|
|
416
|
-
eventEmitter: TypedEmitter<TBridgeOrchestratorEvents<
|
|
417
|
-
setTokenToUse(token: TBridgeToken<
|
|
418
|
-
setAccountToUse(account:
|
|
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:
|
|
430
|
+
setBalances(balances: TBalanceResponse[] | null): Promise<void>;
|
|
422
431
|
switchTokens(): Promise<void>;
|
|
423
432
|
bridge(): Promise<string>;
|
|
424
433
|
}
|
|
425
|
-
export interface IBSWithNeo3NeoXBridge<
|
|
426
|
-
neo3NeoXBridgeService: INeo3NeoXBridgeService<
|
|
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<
|
|
434
|
-
account:
|
|
442
|
+
export type TNeo3NeoXBridgeServiceBridgeParam<N extends string = string> = {
|
|
443
|
+
account: TBSAccount<N>;
|
|
435
444
|
receiverAddress: string;
|
|
436
445
|
amount: string;
|
|
437
|
-
token: TBridgeToken<
|
|
446
|
+
token: TBridgeToken<N>;
|
|
438
447
|
bridgeFee: string;
|
|
439
448
|
};
|
|
440
|
-
export type TNeo3NeoXBridgeServiceGetApprovalParam<
|
|
441
|
-
account:
|
|
449
|
+
export type TNeo3NeoXBridgeServiceGetApprovalParam<N extends string = string> = {
|
|
450
|
+
account: TBSAccount<N>;
|
|
442
451
|
amount: string;
|
|
443
|
-
token: TBridgeToken<
|
|
452
|
+
token: TBridgeToken<N>;
|
|
444
453
|
};
|
|
445
|
-
export type TNeo3NeoXBridgeServiceGetNonceParams<
|
|
446
|
-
token: TBridgeToken<
|
|
454
|
+
export type TNeo3NeoXBridgeServiceGetNonceParams<N extends string = string> = {
|
|
455
|
+
token: TBridgeToken<N>;
|
|
447
456
|
transactionHash: string;
|
|
448
457
|
};
|
|
449
|
-
export type TNeo3NeoXBridgeServiceGetTransactionHashByNonceParams<
|
|
450
|
-
token: TBridgeToken<
|
|
458
|
+
export type TNeo3NeoXBridgeServiceGetTransactionHashByNonceParams<N extends string = string> = {
|
|
459
|
+
token: TBridgeToken<N>;
|
|
451
460
|
nonce: string;
|
|
452
461
|
};
|
|
453
|
-
export interface INeo3NeoXBridgeService<
|
|
454
|
-
|
|
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<
|
|
458
|
-
getNonce(params: TNeo3NeoXBridgeServiceGetNonceParams<
|
|
459
|
-
getTransactionHashByNonce(params: TNeo3NeoXBridgeServiceGetTransactionHashByNonceParams<
|
|
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
|
|
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 {
|
|
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
|
}
|