Skip to content

Commit e625a8e

Browse files
author
junkai121
authored
Merge pull request #12 from Pusher-Labs/update/asgardex-binance
finalize asgardex-binance
2 parents a66aeb0 + 739526a commit e625a8e

21 files changed

+82895
-24
lines changed

packages/asgardex-binance/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33
node_modules
44
npm-debug.log
55
.env
6-
lib
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import { BncClient } from '@binance-chain/javascript-sdk/lib/client';
2+
import { Address, AsgardexClient, AsgardexClientParams, Balances, Fees, Network, TxParams, TxHash, TxHistoryParams, TxsPage } from '@asgardex-clients/asgardex-client';
3+
import { Asset, BaseAmount } from '@thorchain/asgardex-util';
4+
export declare type FreezeParams = {
5+
asset: Asset;
6+
amount: BaseAmount;
7+
recipient?: Address;
8+
};
9+
export declare type Coin = {
10+
asset: Asset;
11+
amount: BaseAmount;
12+
};
13+
export declare type MultiTransfer = {
14+
to: Address;
15+
coins: Coin[];
16+
};
17+
export declare type MultiSendParams = {
18+
address?: Address;
19+
transactions: MultiTransfer[];
20+
memo?: string;
21+
};
22+
/**
23+
* Interface for custom Binance client
24+
*/
25+
export interface BinanceClient {
26+
purgeClient(): void;
27+
getBncClient(): BncClient;
28+
getAddress(): string;
29+
validateAddress(address: string): boolean;
30+
getMultiSendFees(): Promise<Fees>;
31+
getFreezeFees(): Promise<Fees>;
32+
freeze(params: FreezeParams): Promise<TxHash>;
33+
unfreeze(params: FreezeParams): Promise<TxHash>;
34+
multiSend(params: MultiSendParams): Promise<TxHash>;
35+
}
36+
/**
37+
* Custom Binance client
38+
*
39+
* @class Binance
40+
* @implements {BinanceClient}
41+
*/
42+
declare class Client implements BinanceClient, AsgardexClient {
43+
private network;
44+
private bncClient;
45+
private phrase;
46+
private address;
47+
private privateKey;
48+
/**
49+
* Client has to be initialised with network type and phrase
50+
* It will throw an error if an invalid phrase has been passed
51+
**/
52+
constructor({ network, phrase }: AsgardexClientParams);
53+
purgeClient(): void;
54+
getBncClient(): BncClient;
55+
setNetwork(network: Network): AsgardexClient;
56+
getNetwork(): Network;
57+
private getClientUrl;
58+
private getExplorerUrl;
59+
getExplorerAddressUrl: (address: Address) => string;
60+
getExplorerTxUrl: (txID: string) => string;
61+
private getPrefix;
62+
static generatePhrase: () => string;
63+
setPhrase: (phrase: string) => Address;
64+
/**
65+
* @private
66+
* Returns private key
67+
* Throws an error if phrase has not been set before
68+
* */
69+
private getPrivateKey;
70+
getAddress: () => string;
71+
validateAddress: (address: Address) => boolean;
72+
getBalance: (address?: string | undefined, asset?: Asset | undefined) => Promise<Balances>;
73+
getTransactions: (params?: TxHistoryParams | undefined) => Promise<TxsPage>;
74+
multiSend: ({ address, transactions, memo }: MultiSendParams) => Promise<TxHash>;
75+
deposit: ({ asset, amount, recipient, memo }: TxParams) => Promise<TxHash>;
76+
transfer: ({ asset, amount, recipient, memo }: TxParams) => Promise<TxHash>;
77+
freeze: ({ recipient, asset, amount }: FreezeParams) => Promise<TxHash>;
78+
unfreeze: ({ recipient, asset, amount }: FreezeParams) => Promise<TxHash>;
79+
getFees: () => Promise<Fees>;
80+
getMultiSendFees: () => Promise<Fees>;
81+
getFreezeFees: () => Promise<Fees>;
82+
}
83+
export { Client };

packages/asgardex-binance/lib/client.js

Lines changed: 458 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/asgardex-binance/lib/client.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export * from './client';
2+
export * from './util';
3+
export * from './types/binance';
4+
export * as WS from './types/binance-ws';

0 commit comments

Comments
 (0)