@cityofzion/blockchain-service 0.11.2 → 0.13.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/interfaces.d.ts +62 -0
- package/package.json +3 -2
package/dist/interfaces.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Transport from '@ledgerhq/hw-transport';
|
|
2
|
+
import TypedEmitter from 'typed-emitter';
|
|
2
3
|
export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
3
4
|
export type Account = {
|
|
4
5
|
key: string;
|
|
@@ -215,8 +216,69 @@ export interface ExplorerService {
|
|
|
215
216
|
buildTransactionUrl(hash: string): string;
|
|
216
217
|
buildNftUrl(params: BuildNftUrlParams): string;
|
|
217
218
|
}
|
|
219
|
+
export type LedgerServiceEmitter = TypedEmitter<{
|
|
220
|
+
getSignatureStart(): void | Promise<void>;
|
|
221
|
+
getSignatureEnd(): void | Promise<void>;
|
|
222
|
+
}>;
|
|
218
223
|
export interface LedgerService {
|
|
224
|
+
emitter: LedgerServiceEmitter;
|
|
219
225
|
getLedgerTransport?: (account: Account) => Promise<Transport>;
|
|
220
226
|
getAddress(transport: Transport): Promise<string>;
|
|
221
227
|
getPublicKey(transport: Transport): Promise<string>;
|
|
222
228
|
}
|
|
229
|
+
export type SwapRoute = {
|
|
230
|
+
assetToUseSymbol: string;
|
|
231
|
+
reservesToUse: string;
|
|
232
|
+
assetToReceiveSymbol: string;
|
|
233
|
+
reservesToReceive: string;
|
|
234
|
+
};
|
|
235
|
+
export type SwapControllerServiceEvents = {
|
|
236
|
+
accountToUse: (account: Account | null) => void | Promise<void>;
|
|
237
|
+
amountToUse: (amount: string | null) => void | Promise<void>;
|
|
238
|
+
tokenToUse: (token: Token | null) => void | Promise<void>;
|
|
239
|
+
reservesToUse: (reserves: string | null) => void | Promise<void>;
|
|
240
|
+
amountToReceive: (amount: string | null) => void | Promise<void>;
|
|
241
|
+
tokenToReceive: (token: Token | null) => void | Promise<void>;
|
|
242
|
+
reservesToReceive: (reserves: string | null) => void | Promise<void>;
|
|
243
|
+
minimumReceived: (minimumReceived: string | null) => void | Promise<void>;
|
|
244
|
+
maximumSelling: (maximumSelling: string | null) => void | Promise<void>;
|
|
245
|
+
deadline: (deadline: string) => void | Promise<void>;
|
|
246
|
+
slippage: (slippage: number) => void | Promise<void>;
|
|
247
|
+
liquidityProviderFee: (liquidityProviderFee: string | null) => void | Promise<void>;
|
|
248
|
+
priceImpact: (priceImpact: string | null) => void | Promise<void>;
|
|
249
|
+
priceInverse: (priceInverse: string | null) => void | Promise<void>;
|
|
250
|
+
routes: (routes: SwapRoute[] | null) => void | Promise<void>;
|
|
251
|
+
lastAmountChanged: (lastAmountChanged: 'amountToUse' | 'amountToReceive' | null) => void | Promise<void>;
|
|
252
|
+
};
|
|
253
|
+
export type SwapControllerServiceSwapArgs = {
|
|
254
|
+
amountToUse: string;
|
|
255
|
+
amountToReceive: string;
|
|
256
|
+
tokenToUse: Token;
|
|
257
|
+
tokenToReceive: Token;
|
|
258
|
+
address: string;
|
|
259
|
+
deadline: string;
|
|
260
|
+
network: Network;
|
|
261
|
+
};
|
|
262
|
+
export type SwapControllerServiceSwapToUseArgs = {
|
|
263
|
+
minimumReceived: string;
|
|
264
|
+
type: 'swapTokenToUse';
|
|
265
|
+
} & SwapControllerServiceSwapArgs;
|
|
266
|
+
export type SwapControllerServiceSwapToReceiveArgs = {
|
|
267
|
+
maximumSelling: string;
|
|
268
|
+
type: 'swapTokenToReceive';
|
|
269
|
+
} & SwapControllerServiceSwapArgs;
|
|
270
|
+
export interface SwapControllerService {
|
|
271
|
+
eventEmitter: TypedEmitter<SwapControllerServiceEvents>;
|
|
272
|
+
setAccountToUse(account: Account | null): void;
|
|
273
|
+
setAmountToUse(amount: string | null): void;
|
|
274
|
+
setTokenToUse(token: Token | null): void;
|
|
275
|
+
setAmountToReceive(amount: string | null): void;
|
|
276
|
+
setTokenToReceive(token: Token | null): void;
|
|
277
|
+
setDeadline(deadline: string): void;
|
|
278
|
+
setSlippage(slippage: number): void;
|
|
279
|
+
swap(isLedger?: boolean): void;
|
|
280
|
+
buildSwapArgs(): SwapControllerServiceSwapToUseArgs | SwapControllerServiceSwapToReceiveArgs;
|
|
281
|
+
setReserves(): void;
|
|
282
|
+
startListeningBlockGeneration(): void;
|
|
283
|
+
stopListeningBlockGeneration(): void;
|
|
284
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/blockchain-service",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"repository": "https://github.com/CityOfZion/blockchain-services",
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@ledgerhq/hw-transport": "~6.30.5",
|
|
22
|
-
"axios": "1.5.1"
|
|
22
|
+
"axios": "1.5.1",
|
|
23
|
+
"typed-emitter": "~2.1.0"
|
|
23
24
|
},
|
|
24
25
|
"scripts": {
|
|
25
26
|
"build": "tsc",
|