@cityofzion/blockchain-service 3.1.2 → 3.1.4
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 +17 -16
- package/dist/functions.js +5 -5
- package/dist/helpers/BSUtilsHelper.d.ts +2 -2
- package/dist/interfaces.d.ts +68 -67
- package/dist/services/exchange-data/FlamingoForthewinEDS.d.ts +4 -4
- package/dist/services/nft-data/GhostMarketNDS.d.ts +2 -2
- package/dist/services/token/TokenService.d.ts +6 -2
- package/dist/services/token/TokenService.js +12 -0
- package/package.json +2 -2
package/dist/functions.d.ts
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import type { TBSAccount, IBlockchainService, IBSWithClaim, IBSWithEncryption, IBSWithExplorer, IBSWithFee, IBSWithLedger, IBSWithNameService, IBSWithNeo3NeoXBridge, IBSWithNft, TUntilIndexRecord, IBSWithWalletConnect, IBSWithFullTransactions } from './interfaces';
|
|
2
|
-
export declare function hasNameService<N extends string
|
|
3
|
-
export declare function isClaimable<N extends string
|
|
4
|
-
export declare function isCalculableFee<N extends string
|
|
5
|
-
export declare function hasNft<N extends string
|
|
6
|
-
export declare function hasExplorerService<N extends string
|
|
7
|
-
export declare function hasLedger<N extends string
|
|
8
|
-
export declare function hasNeo3NeoXBridge<N extends string
|
|
9
|
-
export declare function hasEncryption<N extends string
|
|
10
|
-
export declare function hasWalletConnect<N extends string
|
|
11
|
-
export declare function hasFullTransactions<N extends string
|
|
1
|
+
import type { TBSAccount, IBlockchainService, IBSWithClaim, IBSWithEncryption, IBSWithExplorer, IBSWithFee, IBSWithLedger, IBSWithNameService, IBSWithNeo3NeoXBridge, IBSWithNft, TUntilIndexRecord, IBSWithWalletConnect, IBSWithFullTransactions, TBSNetworkId, IBSWithFaucet, TBSBridgeName } from './interfaces';
|
|
2
|
+
export declare function hasNameService<N extends string, A extends TBSNetworkId>(service: IBlockchainService<N, A>): service is IBlockchainService<N, A> & IBSWithNameService;
|
|
3
|
+
export declare function isClaimable<N extends string, A extends TBSNetworkId>(service: IBlockchainService<N, A>): service is IBlockchainService<N, A> & IBSWithClaim<N>;
|
|
4
|
+
export declare function isCalculableFee<N extends string, A extends TBSNetworkId>(service: IBlockchainService<N, A>): service is IBlockchainService<N, A> & IBSWithFee<N>;
|
|
5
|
+
export declare function hasNft<N extends string, A extends TBSNetworkId>(service: IBlockchainService<N, A>): service is IBlockchainService<N, A> & IBSWithNft;
|
|
6
|
+
export declare function hasExplorerService<N extends string, A extends TBSNetworkId>(service: IBlockchainService<N, A>): service is IBlockchainService<N, A> & IBSWithExplorer;
|
|
7
|
+
export declare function hasLedger<N extends string, A extends TBSNetworkId>(service: IBlockchainService<N, A>): service is IBlockchainService<N, A> & IBSWithLedger<N>;
|
|
8
|
+
export declare function hasNeo3NeoXBridge<N extends string, A extends TBSNetworkId>(service: IBlockchainService<N, A>): service is N extends TBSBridgeName ? IBlockchainService<N, A> & IBSWithNeo3NeoXBridge<N> : never;
|
|
9
|
+
export declare function hasEncryption<N extends string, A extends TBSNetworkId>(service: IBlockchainService<N, A>): service is IBlockchainService<N, A> & IBSWithEncryption<N>;
|
|
10
|
+
export declare function hasWalletConnect<N extends string, A extends TBSNetworkId>(service: IBlockchainService<N, A>): service is IBlockchainService<N, A> & IBSWithWalletConnect<N>;
|
|
11
|
+
export declare function hasFullTransactions<N extends string, A extends TBSNetworkId>(service: IBlockchainService<N, A>): service is IBlockchainService<N, A> & IBSWithFullTransactions;
|
|
12
|
+
export declare function hasFaucet<N extends string, A extends TBSNetworkId>(service: IBlockchainService<N, A>): service is IBlockchainService<N, A> & IBSWithFaucet;
|
|
12
13
|
/**
|
|
13
14
|
* @deprecated use `waitForAccountTransaction` instead
|
|
14
15
|
*/
|
|
15
|
-
export declare function waitForTransaction<N extends string
|
|
16
|
-
export declare function waitForAccountTransaction<N extends string
|
|
16
|
+
export declare function waitForTransaction<N extends string, A extends TBSNetworkId>(service: IBlockchainService<N, A>, txId: string): Promise<boolean>;
|
|
17
|
+
export declare function waitForAccountTransaction<N extends string, A extends TBSNetworkId>(params: {
|
|
17
18
|
service: IBlockchainService<N, A>;
|
|
18
19
|
txId: string;
|
|
19
20
|
address: string;
|
|
20
21
|
maxAttempts?: number;
|
|
21
22
|
}): Promise<boolean>;
|
|
22
|
-
export declare function fetchAccounts<N extends string
|
|
23
|
-
export declare function generateAccount<N extends string
|
|
24
|
-
export declare function generateAccountForBlockchainService<N extends string
|
|
23
|
+
export declare function fetchAccounts<N extends string, A extends TBSNetworkId>(service: IBlockchainService<N, A>, initialIndex: number, getAccountCallback: (service: IBlockchainService<N, A>, index: number) => Promise<TBSAccount<N>>): Promise<TBSAccount<N>[]>;
|
|
24
|
+
export declare function generateAccount<N extends string, A extends TBSNetworkId>(service: IBlockchainService<N, A>, initialIndex: number, untilIndex: number, getAccountCallback: (service: IBlockchainService<N, A>, index: number) => Promise<TBSAccount<N>>): Promise<TBSAccount<N>[]>;
|
|
25
|
+
export declare function generateAccountForBlockchainService<N extends string, A extends TBSNetworkId>(services: IBlockchainService<N, A>[], getAccountCallback: (service: IBlockchainService<N, A>, index: number) => Promise<TBSAccount<N>>, untilIndexByBlockchainService?: TUntilIndexRecord<N>): Promise<Map<N, TBSAccount<N>[]>>;
|
package/dist/functions.js
CHANGED
|
@@ -10,6 +10,7 @@ exports.hasNeo3NeoXBridge = hasNeo3NeoXBridge;
|
|
|
10
10
|
exports.hasEncryption = hasEncryption;
|
|
11
11
|
exports.hasWalletConnect = hasWalletConnect;
|
|
12
12
|
exports.hasFullTransactions = hasFullTransactions;
|
|
13
|
+
exports.hasFaucet = hasFaucet;
|
|
13
14
|
exports.waitForTransaction = waitForTransaction;
|
|
14
15
|
exports.waitForAccountTransaction = waitForAccountTransaction;
|
|
15
16
|
exports.fetchAccounts = fetchAccounts;
|
|
@@ -20,11 +21,7 @@ function hasNameService(service) {
|
|
|
20
21
|
return 'resolveNameServiceDomain' in service && 'validateNameServiceDomainFormat' in service;
|
|
21
22
|
}
|
|
22
23
|
function isClaimable(service) {
|
|
23
|
-
return
|
|
24
|
-
'burnToken' in service &&
|
|
25
|
-
'claimDataService' in service &&
|
|
26
|
-
'calculateClaimFee' in service &&
|
|
27
|
-
'claim' in service);
|
|
24
|
+
return 'claimService' in service;
|
|
28
25
|
}
|
|
29
26
|
function isCalculableFee(service) {
|
|
30
27
|
return 'calculateTransferFee' in service;
|
|
@@ -50,6 +47,9 @@ function hasWalletConnect(service) {
|
|
|
50
47
|
function hasFullTransactions(service) {
|
|
51
48
|
return 'fullTransactionsDataService' in service;
|
|
52
49
|
}
|
|
50
|
+
function hasFaucet(service) {
|
|
51
|
+
return 'faucet' in service;
|
|
52
|
+
}
|
|
53
53
|
/**
|
|
54
54
|
* @deprecated use `waitForAccountTransaction` instead
|
|
55
55
|
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { TBSNetwork } from '../interfaces';
|
|
1
|
+
import type { TBSNetwork, TBSNetworkId } from '../interfaces';
|
|
2
2
|
import { TBSUtilsHelperRetryOptions } from '../types';
|
|
3
3
|
export declare class BSUtilsHelper {
|
|
4
4
|
static wait(ms: number): Promise<unknown>;
|
|
5
5
|
static retry<T = any>(callback: () => Promise<T>, options?: TBSUtilsHelperRetryOptions): Promise<T>;
|
|
6
|
-
static validateNetwork(network: TBSNetwork
|
|
6
|
+
static validateNetwork<A extends TBSNetworkId>(network: TBSNetwork<A>, availableNetworks: TBSNetwork<A>[], networkUrls: string[]): boolean;
|
|
7
7
|
static tryCatch<T>(callback: () => T): T extends Promise<infer R> ? Promise<[R, undefined] | [undefined, any]> : [T, undefined] | [undefined, any];
|
|
8
8
|
static isBase64(str: string): boolean;
|
|
9
9
|
}
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Transport from '@ledgerhq/hw-transport';
|
|
2
2
|
import TypedEmitter from 'typed-emitter';
|
|
3
|
-
import { BSError } from './error';
|
|
3
|
+
import type { BSError } from './error';
|
|
4
4
|
export type TUntilIndexRecord<N extends string> = Partial<Record<N, Record<string, number>>>;
|
|
5
5
|
export type TBSAccount<N extends string> = {
|
|
6
6
|
key: string;
|
|
@@ -43,6 +43,7 @@ export interface IBlockchainService<N extends string, A extends string = string>
|
|
|
43
43
|
readonly bipDerivationPath: string;
|
|
44
44
|
readonly feeToken: TBSToken;
|
|
45
45
|
readonly isMultiTransferSupported: boolean;
|
|
46
|
+
readonly amountToCreateAccount?: string;
|
|
46
47
|
tokens: TBSToken[];
|
|
47
48
|
readonly nativeTokens: TBSToken[];
|
|
48
49
|
networkUrls: string[];
|
|
@@ -51,7 +52,7 @@ export interface IBlockchainService<N extends string, A extends string = string>
|
|
|
51
52
|
readonly availableNetworks: TBSNetwork<A>[];
|
|
52
53
|
readonly isCustomNetworkSupported: boolean;
|
|
53
54
|
exchangeDataService: IExchangeDataService;
|
|
54
|
-
blockchainDataService: IBlockchainDataService
|
|
55
|
+
blockchainDataService: IBlockchainDataService;
|
|
55
56
|
tokenService: ITokenService;
|
|
56
57
|
setNetwork(network: TBSNetwork<A>): void;
|
|
57
58
|
pingNetwork(url?: string): Promise<TPingNetworkResponse>;
|
|
@@ -59,7 +60,7 @@ export interface IBlockchainService<N extends string, A extends string = string>
|
|
|
59
60
|
generateAccountFromKey(key: string): Promise<TBSAccount<N>>;
|
|
60
61
|
validateAddress(address: string): boolean;
|
|
61
62
|
validateKey(key: string): boolean;
|
|
62
|
-
transfer(params: TTransferParams<N>): Promise<TTransaction
|
|
63
|
+
transfer(params: TTransferParams<N>): Promise<TTransaction[]>;
|
|
63
64
|
}
|
|
64
65
|
export interface IBSWithEncryption<N extends string> {
|
|
65
66
|
decrypt(keyOrJson: string, password: string): Promise<TBSAccount<N>>;
|
|
@@ -70,11 +71,7 @@ export interface IBSWithFee<N extends string> {
|
|
|
70
71
|
calculateTransferFee(params: TTransferParams<N>): Promise<string>;
|
|
71
72
|
}
|
|
72
73
|
export interface IBSWithClaim<N extends string> {
|
|
73
|
-
|
|
74
|
-
readonly burnToken: TBSToken;
|
|
75
|
-
claimDataService: IClaimDataService;
|
|
76
|
-
calculateClaimFee(account: TBSAccount<N>): Promise<string>;
|
|
77
|
-
claim(account: TBSAccount<N>): Promise<TTransaction<N>>;
|
|
74
|
+
claimService: IClaimService<N>;
|
|
78
75
|
}
|
|
79
76
|
export interface IBSWithNameService {
|
|
80
77
|
resolveNameServiceDomain(domainName: string): Promise<string>;
|
|
@@ -93,8 +90,11 @@ export interface IBSWithLedger<N extends string> {
|
|
|
93
90
|
export interface IBSWithWalletConnect<N extends string> {
|
|
94
91
|
walletConnectService: IWalletConnectService<N>;
|
|
95
92
|
}
|
|
96
|
-
export interface IBSWithFullTransactions
|
|
97
|
-
fullTransactionsDataService: IFullTransactionsDataService
|
|
93
|
+
export interface IBSWithFullTransactions {
|
|
94
|
+
fullTransactionsDataService: IFullTransactionsDataService;
|
|
95
|
+
}
|
|
96
|
+
export interface IBSWithFaucet {
|
|
97
|
+
faucet(address: string): Promise<TTransaction>;
|
|
98
98
|
}
|
|
99
99
|
export type TContractParameter = {
|
|
100
100
|
name: string;
|
|
@@ -104,54 +104,34 @@ export type TGetTransactionsByAddressParams = {
|
|
|
104
104
|
address: string;
|
|
105
105
|
nextPageParams?: any;
|
|
106
106
|
};
|
|
107
|
-
type
|
|
108
|
-
export type TTransactionNftEvent = {
|
|
109
|
-
eventType: 'nft';
|
|
107
|
+
export type TTransactionBaseEvent = {
|
|
110
108
|
methodName?: string;
|
|
111
|
-
amount?: string;
|
|
112
109
|
from?: string;
|
|
113
110
|
fromUrl?: string;
|
|
114
111
|
to?: string;
|
|
115
112
|
toUrl?: string;
|
|
116
|
-
|
|
113
|
+
amount?: string;
|
|
114
|
+
};
|
|
115
|
+
export type TTransactionDefaultNftEvent = TTransactionBaseEvent & {
|
|
116
|
+
eventType: 'nft';
|
|
117
117
|
nft?: TNftResponse;
|
|
118
118
|
};
|
|
119
|
-
export type
|
|
119
|
+
export type TTransactionDefaultTokenEvent = TTransactionBaseEvent & {
|
|
120
120
|
eventType: 'token';
|
|
121
|
-
methodName?: string;
|
|
122
|
-
amount?: string;
|
|
123
|
-
from?: string;
|
|
124
|
-
fromUrl?: string;
|
|
125
|
-
to?: string;
|
|
126
|
-
toUrl?: string;
|
|
127
|
-
tokenType: TTransactionEventTokenType;
|
|
128
121
|
tokenUrl?: string;
|
|
129
122
|
token?: TBSToken;
|
|
130
123
|
};
|
|
131
|
-
export type
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
export type TTransactionVoteType = {
|
|
135
|
-
type: 'vote';
|
|
124
|
+
export type TTransactionDefaultGenericEvent = TTransactionBaseEvent & {
|
|
125
|
+
eventType: 'generic';
|
|
126
|
+
data?: Record<string, string | number | boolean | undefined | null>;
|
|
136
127
|
};
|
|
137
|
-
export type
|
|
138
|
-
type: 'claim';
|
|
139
|
-
};
|
|
140
|
-
export type TTransactionBridgeNeo3NeoXType<N extends string> = {
|
|
141
|
-
type: 'bridgeNeo3NeoX';
|
|
142
|
-
data: {
|
|
143
|
-
amount: string;
|
|
144
|
-
tokenToUse: TBridgeToken<N>;
|
|
145
|
-
receiverAddress: string;
|
|
146
|
-
};
|
|
147
|
-
};
|
|
148
|
-
export type TTransactionInputOutput = {
|
|
128
|
+
export type TTransactionUtxoInputOutput = {
|
|
149
129
|
address?: string;
|
|
150
130
|
addressUrl?: string;
|
|
151
131
|
amount: string;
|
|
152
132
|
token: TBSToken;
|
|
153
133
|
};
|
|
154
|
-
type TTransactionBase
|
|
134
|
+
type TTransactionBase = {
|
|
155
135
|
txId: string;
|
|
156
136
|
txIdUrl?: string;
|
|
157
137
|
block?: number;
|
|
@@ -160,20 +140,23 @@ type TTransactionBase<N extends string> = {
|
|
|
160
140
|
notificationCount?: number;
|
|
161
141
|
networkFeeAmount?: string;
|
|
162
142
|
systemFeeAmount?: string;
|
|
163
|
-
|
|
164
|
-
|
|
143
|
+
data?: any;
|
|
144
|
+
};
|
|
145
|
+
export type TTransactionDefaultEvent = TTransactionDefaultNftEvent | TTransactionDefaultTokenEvent | TTransactionDefaultGenericEvent;
|
|
146
|
+
export type TTransactionDefault = TTransactionBase & {
|
|
165
147
|
view: 'default';
|
|
166
|
-
events:
|
|
148
|
+
events: TTransactionDefaultEvent[];
|
|
167
149
|
};
|
|
168
|
-
export type TTransactionUtxo
|
|
150
|
+
export type TTransactionUtxo = TTransactionBase & {
|
|
169
151
|
view: 'utxo';
|
|
170
152
|
hex: string;
|
|
153
|
+
totalAmount: string;
|
|
171
154
|
nfts: TNftResponse[];
|
|
172
|
-
inputs:
|
|
173
|
-
outputs:
|
|
155
|
+
inputs: TTransactionUtxoInputOutput[];
|
|
156
|
+
outputs: TTransactionUtxoInputOutput[];
|
|
174
157
|
};
|
|
175
|
-
export type TTransaction
|
|
176
|
-
export type TGetTransactionsByAddressResponse<
|
|
158
|
+
export type TTransaction = TTransactionDefault | TTransactionUtxo;
|
|
159
|
+
export type TGetTransactionsByAddressResponse<T extends TTransaction = TTransaction> = {
|
|
177
160
|
nextPageParams?: any;
|
|
178
161
|
transactions: T[];
|
|
179
162
|
};
|
|
@@ -190,10 +173,10 @@ export type TBalanceResponse = {
|
|
|
190
173
|
amount: string;
|
|
191
174
|
token: TBSToken;
|
|
192
175
|
};
|
|
193
|
-
export interface IBlockchainDataService
|
|
176
|
+
export interface IBlockchainDataService {
|
|
194
177
|
readonly maxTimeToConfirmTransactionInMs: number;
|
|
195
|
-
getTransaction(transactionId: string): Promise<TTransaction
|
|
196
|
-
getTransactionsByAddress(params: TGetTransactionsByAddressParams): Promise<TGetTransactionsByAddressResponse
|
|
178
|
+
getTransaction(transactionId: string): Promise<TTransaction>;
|
|
179
|
+
getTransactionsByAddress(params: TGetTransactionsByAddressParams): Promise<TGetTransactionsByAddressResponse>;
|
|
197
180
|
getContract(contractHash: string): Promise<TContractResponse>;
|
|
198
181
|
getTokenInfo(tokenHash: string): Promise<TBSToken>;
|
|
199
182
|
getBalance(address: string): Promise<TBalanceResponse[]>;
|
|
@@ -211,12 +194,19 @@ export type TExportFullTransactionsByAddressParams = {
|
|
|
211
194
|
dateFrom: string;
|
|
212
195
|
dateTo: string;
|
|
213
196
|
};
|
|
214
|
-
export interface IFullTransactionsDataService
|
|
215
|
-
getFullTransactionsByAddress(params: TGetFullTransactionsByAddressParams): Promise<TGetTransactionsByAddressResponse
|
|
197
|
+
export interface IFullTransactionsDataService {
|
|
198
|
+
getFullTransactionsByAddress(params: TGetFullTransactionsByAddressParams): Promise<TGetTransactionsByAddressResponse>;
|
|
216
199
|
exportFullTransactionsByAddress(params: TExportFullTransactionsByAddressParams): Promise<string>;
|
|
217
200
|
}
|
|
218
|
-
export
|
|
201
|
+
export type TClaimServiceTransactionData = {
|
|
202
|
+
isClaim: boolean;
|
|
203
|
+
};
|
|
204
|
+
export interface IClaimService<N extends string> {
|
|
205
|
+
readonly claimToken: TBSToken;
|
|
219
206
|
getUnclaimed(address: string): Promise<string>;
|
|
207
|
+
calculateFee(account: TBSAccount<N>): Promise<string>;
|
|
208
|
+
claim(account: TBSAccount<N>): Promise<TTransactionDefault>;
|
|
209
|
+
getTransactionData(transaction: TTransaction): TClaimServiceTransactionData | undefined;
|
|
220
210
|
}
|
|
221
211
|
export type TTokenPricesResponse = {
|
|
222
212
|
usdPrice: number;
|
|
@@ -341,9 +331,9 @@ export type TSwapOrchestratorEvents<N extends string> = {
|
|
|
341
331
|
availableTokensToReceive: (tokens: TSwapLoadableValue<TSwapToken<N>[]>) => void | Promise<void>;
|
|
342
332
|
error: (error: string) => void | Promise<void>;
|
|
343
333
|
};
|
|
344
|
-
export type TSwapResponse
|
|
334
|
+
export type TSwapResponse = {
|
|
345
335
|
id: string;
|
|
346
|
-
transaction?: TTransaction
|
|
336
|
+
transaction?: TTransaction;
|
|
347
337
|
log?: string;
|
|
348
338
|
};
|
|
349
339
|
export type TSwapServiceStatusResponse = {
|
|
@@ -363,10 +353,11 @@ export interface ISwapOrchestrator<N extends string> {
|
|
|
363
353
|
setTokenToReceive(token: TSwapToken<N> | null): Promise<void>;
|
|
364
354
|
setAddressToReceive(address: string | null): Promise<void>;
|
|
365
355
|
setExtraIdToReceive(extraId: string | null): Promise<void>;
|
|
366
|
-
swap(): Promise<TSwapResponse
|
|
356
|
+
swap(): Promise<TSwapResponse>;
|
|
367
357
|
calculateFee(): Promise<string>;
|
|
368
358
|
}
|
|
369
|
-
export type
|
|
359
|
+
export type TBSBridgeName = 'neo3' | 'neox';
|
|
360
|
+
export type TBridgeToken<N extends TBSBridgeName> = TBSToken & {
|
|
370
361
|
blockchain: N;
|
|
371
362
|
multichainId: string;
|
|
372
363
|
};
|
|
@@ -378,7 +369,7 @@ export type TBridgeValue<T> = {
|
|
|
378
369
|
export type TBridgeValidateValue<T> = TBridgeValue<T> & {
|
|
379
370
|
valid: boolean | null;
|
|
380
371
|
};
|
|
381
|
-
export type TBridgeOrchestratorEvents<N extends
|
|
372
|
+
export type TBridgeOrchestratorEvents<N extends TBSBridgeName> = {
|
|
382
373
|
accountToUse: (account: TBridgeValue<TBSAccount<N>>) => void | Promise<void>;
|
|
383
374
|
amountToUse: (amount: TBridgeValidateValue<string>) => void | Promise<void>;
|
|
384
375
|
amountToUseMin: (max: TBridgeValue<string>) => void | Promise<void>;
|
|
@@ -391,7 +382,7 @@ export type TBridgeOrchestratorEvents<N extends string> = {
|
|
|
391
382
|
tokenToUseBalance: (balance: TBridgeValue<TBalanceResponse | undefined>) => void | Promise<void>;
|
|
392
383
|
bridgeFee: (fee: TBridgeValue<string>) => void | Promise<void>;
|
|
393
384
|
};
|
|
394
|
-
export interface IBridgeOrchestrator<N extends
|
|
385
|
+
export interface IBridgeOrchestrator<N extends TBSBridgeName> {
|
|
395
386
|
eventEmitter: TypedEmitter<TBridgeOrchestratorEvents<N>>;
|
|
396
387
|
setTokenToUse(token: TBridgeToken<N> | null): Promise<void>;
|
|
397
388
|
setAccountToUse(account: TBSAccount<N> | null): Promise<void>;
|
|
@@ -401,7 +392,7 @@ export interface IBridgeOrchestrator<N extends string> {
|
|
|
401
392
|
switchTokens(): Promise<void>;
|
|
402
393
|
bridge(): Promise<string>;
|
|
403
394
|
}
|
|
404
|
-
export interface IBSWithNeo3NeoXBridge<N extends
|
|
395
|
+
export interface IBSWithNeo3NeoXBridge<N extends TBSBridgeName> {
|
|
405
396
|
neo3NeoXBridgeService: INeo3NeoXBridgeService<N>;
|
|
406
397
|
}
|
|
407
398
|
export type TNeo3NeoXBridgeServiceConstants = {
|
|
@@ -409,27 +400,34 @@ export type TNeo3NeoXBridgeServiceConstants = {
|
|
|
409
400
|
bridgeMaxAmount: string;
|
|
410
401
|
bridgeMinAmount: string;
|
|
411
402
|
};
|
|
412
|
-
export type TNeo3NeoXBridgeServiceBridgeParam<N extends
|
|
403
|
+
export type TNeo3NeoXBridgeServiceBridgeParam<N extends TBSBridgeName> = {
|
|
413
404
|
account: TBSAccount<N>;
|
|
414
405
|
receiverAddress: string;
|
|
415
406
|
amount: string;
|
|
416
407
|
token: TBridgeToken<N>;
|
|
417
408
|
bridgeFee: string;
|
|
418
409
|
};
|
|
419
|
-
export type TNeo3NeoXBridgeServiceGetApprovalParam<N extends
|
|
410
|
+
export type TNeo3NeoXBridgeServiceGetApprovalParam<N extends TBSBridgeName> = {
|
|
420
411
|
account: TBSAccount<N>;
|
|
421
412
|
amount: string;
|
|
422
413
|
token: TBridgeToken<N>;
|
|
423
414
|
};
|
|
424
|
-
export type TNeo3NeoXBridgeServiceGetNonceParams<N extends
|
|
415
|
+
export type TNeo3NeoXBridgeServiceGetNonceParams<N extends TBSBridgeName> = {
|
|
425
416
|
token: TBridgeToken<N>;
|
|
426
417
|
transactionHash: string;
|
|
427
418
|
};
|
|
428
|
-
export type TNeo3NeoXBridgeServiceGetTransactionHashByNonceParams<N extends
|
|
419
|
+
export type TNeo3NeoXBridgeServiceGetTransactionHashByNonceParams<N extends TBSBridgeName> = {
|
|
429
420
|
token: TBridgeToken<N>;
|
|
430
421
|
nonce: string;
|
|
431
422
|
};
|
|
432
|
-
export
|
|
423
|
+
export type TNeo3NeoXBridgeTransactionData<N extends TBSBridgeName> = {
|
|
424
|
+
neo3NeoxBridge: {
|
|
425
|
+
tokenToUse: TBridgeToken<N>;
|
|
426
|
+
receiverAddress: string;
|
|
427
|
+
amount: string;
|
|
428
|
+
};
|
|
429
|
+
};
|
|
430
|
+
export interface INeo3NeoXBridgeService<N extends TBSBridgeName> {
|
|
433
431
|
readonly gasToken: TBridgeToken<N>;
|
|
434
432
|
readonly neoToken: TBridgeToken<N>;
|
|
435
433
|
getApprovalFee(params: TNeo3NeoXBridgeServiceGetApprovalParam<N>): Promise<string>;
|
|
@@ -438,6 +436,7 @@ export interface INeo3NeoXBridgeService<N extends string> {
|
|
|
438
436
|
getNonce(params: TNeo3NeoXBridgeServiceGetNonceParams<N>): Promise<string>;
|
|
439
437
|
getTransactionHashByNonce(params: TNeo3NeoXBridgeServiceGetTransactionHashByNonceParams<N>): Promise<string>;
|
|
440
438
|
getTokenByMultichainId(multichainId: string): TBridgeToken<N> | undefined;
|
|
439
|
+
getTransactionData(transaction: TTransaction): TNeo3NeoXBridgeTransactionData<N> | undefined;
|
|
441
440
|
}
|
|
442
441
|
export type TTokenServicePredicateParams = {
|
|
443
442
|
hash: string;
|
|
@@ -455,6 +454,8 @@ export interface ITokenService {
|
|
|
455
454
|
predicateBySymbol(compareFrom: TTokenServicePredicateBySymbolParams, compareTo: TTokenServicePredicateBySymbolParams): boolean;
|
|
456
455
|
normalizeToken<T extends TBSToken | TBSToken[]>(token: T): T;
|
|
457
456
|
normalizeHash(hash: string): string;
|
|
457
|
+
validateTokenHash(hash?: string): hash is string;
|
|
458
|
+
isNativeToken(hash: string): boolean;
|
|
458
459
|
}
|
|
459
460
|
export type TWalletConnectServiceRequestMethodParams<N extends string> = {
|
|
460
461
|
account: TBSAccount<N>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { TGetTokenPricesParams, IBlockchainService, IExchangeDataService, TTokenPricesResponse } from '../../interfaces';
|
|
1
|
+
import type { TGetTokenPricesParams, IBlockchainService, IExchangeDataService, TTokenPricesResponse, TBSNetworkId } from '../../interfaces';
|
|
2
2
|
import { CryptoCompareEDS } from './CryptoCompareEDS';
|
|
3
|
-
export declare class FlamingoForthewinEDS<N extends string> extends CryptoCompareEDS implements IExchangeDataService {
|
|
3
|
+
export declare class FlamingoForthewinEDS<N extends string, A extends TBSNetworkId> extends CryptoCompareEDS implements IExchangeDataService {
|
|
4
4
|
#private;
|
|
5
|
-
readonly _service: IBlockchainService<N>;
|
|
6
|
-
constructor(service: IBlockchainService<N>);
|
|
5
|
+
readonly _service: IBlockchainService<N, A>;
|
|
6
|
+
constructor(service: IBlockchainService<N, A>);
|
|
7
7
|
getTokenPrices({ tokens }: TGetTokenPricesParams): Promise<TTokenPricesResponse[]>;
|
|
8
8
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { IBlockchainService, INftDataService, TGetNftParams, TGetNftsByAddressParams, THasTokenParams, TNftResponse, TNftsResponse } from '../../interfaces';
|
|
2
|
-
export declare abstract class GhostMarketNDS<N extends string, A extends
|
|
1
|
+
import type { IBlockchainService, INftDataService, TBSNetworkId, TGetNftParams, TGetNftsByAddressParams, THasTokenParams, TNftResponse, TNftsResponse } from '../../interfaces';
|
|
2
|
+
export declare abstract class GhostMarketNDS<N extends string, A extends TBSNetworkId, S extends IBlockchainService<N, A>> implements INftDataService {
|
|
3
3
|
#private;
|
|
4
4
|
static readonly BASE_URL: string;
|
|
5
5
|
_service: S;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import type { ITokenService, TBSToken, TTokenServicePredicateByHashParams, TTokenServicePredicateBySymbolParams, TTokenServicePredicateParams } from '../../interfaces';
|
|
2
|
-
export declare abstract class TokenService implements ITokenService {
|
|
1
|
+
import type { IBlockchainService, ITokenService, TBSNetworkId, TBSToken, TTokenServicePredicateByHashParams, TTokenServicePredicateBySymbolParams, TTokenServicePredicateParams } from '../../interfaces';
|
|
2
|
+
export declare abstract class TokenService<N extends string, A extends TBSNetworkId> implements ITokenService {
|
|
3
|
+
protected _service: IBlockchainService<N, A>;
|
|
4
|
+
constructor(service: IBlockchainService<N, A>);
|
|
3
5
|
predicate(compareFrom: TTokenServicePredicateParams, compareTo: TTokenServicePredicateParams): boolean;
|
|
4
6
|
predicateByHash(compareFrom: TTokenServicePredicateByHashParams, compareTo: TTokenServicePredicateByHashParams): boolean;
|
|
5
7
|
predicateBySymbol(compareFrom: TTokenServicePredicateBySymbolParams, compareTo: TTokenServicePredicateBySymbolParams): boolean;
|
|
6
8
|
normalizeToken<T extends TBSToken | TBSToken[]>(token: T): T;
|
|
9
|
+
validateTokenHash(hash?: string): hash is string;
|
|
10
|
+
isNativeToken(hash: string): boolean;
|
|
7
11
|
abstract normalizeHash(hash: string): string;
|
|
8
12
|
}
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TokenService = void 0;
|
|
4
4
|
class TokenService {
|
|
5
|
+
constructor(service) {
|
|
6
|
+
this._service = service;
|
|
7
|
+
}
|
|
5
8
|
predicate(compareFrom, compareTo) {
|
|
6
9
|
if (this.normalizeHash(compareFrom.hash) === this.normalizeHash(compareTo.hash))
|
|
7
10
|
return true;
|
|
@@ -32,5 +35,14 @@ class TokenService {
|
|
|
32
35
|
hash: this.normalizeHash(token.hash),
|
|
33
36
|
};
|
|
34
37
|
}
|
|
38
|
+
validateTokenHash(hash) {
|
|
39
|
+
hash = hash?.trim();
|
|
40
|
+
if (!hash)
|
|
41
|
+
return false;
|
|
42
|
+
return !this.isNativeToken(hash);
|
|
43
|
+
}
|
|
44
|
+
isNativeToken(hash) {
|
|
45
|
+
return this._service.nativeTokens.some(token => this.predicateByHash(hash, token));
|
|
46
|
+
}
|
|
35
47
|
}
|
|
36
48
|
exports.TokenService = TokenService;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/blockchain-service",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.4",
|
|
4
4
|
"repository": "https://github.com/CityOfZion/blockchain-services",
|
|
5
5
|
"license": "GPL-3.0-only",
|
|
6
6
|
"author": "Coz",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"vitest": "~4.0.18"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
|
-
"build": "rm -rf ./dist && npm run typecheck && tsc --project tsconfig.build.json",
|
|
33
|
+
"build": "rm -rf ./dist && rm -f *.tgz && npm run typecheck && tsc --project tsconfig.build.json",
|
|
34
34
|
"format": "eslint --fix",
|
|
35
35
|
"lint": "eslint .",
|
|
36
36
|
"package": "npm run build && npm pack",
|