@orderly.network/core 0.0.36 → 0.0.38
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/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/dist/index.d.mts +0 -279
- package/dist/index.d.ts +0 -279
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orderly.network/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.38",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"eventemitter3": "^5.0.1",
|
|
16
16
|
"lodash.merge": "^4.6.2",
|
|
17
17
|
"typescript": "^5.1.6",
|
|
18
|
-
"@orderly.network/types": "0.0.
|
|
18
|
+
"@orderly.network/types": "0.0.38"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@babel/core": "^7.22.9",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"jest": "^29.6.1",
|
|
31
31
|
"tsup": "^7.1.0",
|
|
32
32
|
"typedoc": "^0.24.8",
|
|
33
|
-
"tsconfig": "0.0.
|
|
33
|
+
"tsconfig": "0.0.36"
|
|
34
34
|
},
|
|
35
35
|
"jest": {
|
|
36
36
|
"transformIgnorePatterns": []
|
package/dist/index.d.mts
DELETED
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
import EventEmitter from 'eventemitter3';
|
|
2
|
-
export { default as EventEmitter } from 'eventemitter3';
|
|
3
|
-
import { AccountStatusEnum } from '@orderly.network/types';
|
|
4
|
-
|
|
5
|
-
interface OrderlyKeyPair {
|
|
6
|
-
getPublicKey(): Promise<string>;
|
|
7
|
-
secretKey: string;
|
|
8
|
-
sign: (data: Uint8Array) => Promise<Uint8Array>;
|
|
9
|
-
}
|
|
10
|
-
declare class BaseOrderlyKeyPair implements OrderlyKeyPair {
|
|
11
|
-
secretKey: string;
|
|
12
|
-
private privateKey;
|
|
13
|
-
static generateKey(): OrderlyKeyPair;
|
|
14
|
-
constructor(secretKey: string);
|
|
15
|
-
sign(message: Uint8Array): Promise<Uint8Array>;
|
|
16
|
-
getPublicKey(): Promise<string>;
|
|
17
|
-
toString(): string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface OrderlyKeyStore {
|
|
21
|
-
getOrderlyKey: (address?: string) => OrderlyKeyPair | null;
|
|
22
|
-
getAccountId: (address: string) => string | undefined | null;
|
|
23
|
-
setAccountId: (address: string, accountId: string) => void;
|
|
24
|
-
getAddress: () => string | undefined | null;
|
|
25
|
-
setAddress: (address: string) => void;
|
|
26
|
-
generateKey: () => OrderlyKeyPair;
|
|
27
|
-
cleanKey: (address: string, key: string) => void;
|
|
28
|
-
cleanAllKey: (address: string) => void;
|
|
29
|
-
setKey: (orderlyKey: string, secretKey: OrderlyKeyPair) => void;
|
|
30
|
-
}
|
|
31
|
-
declare abstract class BaseKeyStore implements OrderlyKeyStore {
|
|
32
|
-
private readonly networkId;
|
|
33
|
-
constructor(networkId?: string);
|
|
34
|
-
abstract getOrderlyKey(address?: string): OrderlyKeyPair | null;
|
|
35
|
-
abstract getAccountId(address: string): string | undefined | null;
|
|
36
|
-
abstract setAccountId(address: string, accountId: string): void;
|
|
37
|
-
abstract getAddress(): string | undefined | null;
|
|
38
|
-
abstract setAddress(address: string): void;
|
|
39
|
-
abstract generateKey(): OrderlyKeyPair;
|
|
40
|
-
abstract setKey(orderlyKey: string, secretKey: OrderlyKeyPair): void;
|
|
41
|
-
abstract cleanAllKey(address: string): void;
|
|
42
|
-
abstract cleanKey(address: string, key: string): void;
|
|
43
|
-
protected get keyPrefix(): string;
|
|
44
|
-
}
|
|
45
|
-
declare class LocalStorageStore extends BaseKeyStore {
|
|
46
|
-
getOrderlyKey(address?: string): OrderlyKeyPair | null;
|
|
47
|
-
getAccountId(address: string): string | undefined | null;
|
|
48
|
-
setAccountId(address: string, accountId: string): void;
|
|
49
|
-
getAddress(): string | undefined | null;
|
|
50
|
-
setAddress(address: string): void;
|
|
51
|
-
generateKey(): OrderlyKeyPair;
|
|
52
|
-
setKey(address: string, orderlyKey: OrderlyKeyPair): void;
|
|
53
|
-
cleanAllKey(address: string): void;
|
|
54
|
-
cleanKey(address: string, key: string): void;
|
|
55
|
-
private setItem;
|
|
56
|
-
private getItem;
|
|
57
|
-
}
|
|
58
|
-
declare class MockKeyStore implements OrderlyKeyStore {
|
|
59
|
-
private readonly secretKey;
|
|
60
|
-
constructor(secretKey: string);
|
|
61
|
-
generateKey(): BaseOrderlyKeyPair;
|
|
62
|
-
getOrderlyKey(): BaseOrderlyKeyPair;
|
|
63
|
-
getAccountId(): string;
|
|
64
|
-
setAccountId(accountId: string): void;
|
|
65
|
-
getAddress(): string;
|
|
66
|
-
setAddress(address: string): void;
|
|
67
|
-
setKey(orderlyKey: string, secretKey: OrderlyKeyPair): void;
|
|
68
|
-
cleanAllKey(): void;
|
|
69
|
-
cleanKey(key: string): void;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
type MessageFactor = {
|
|
73
|
-
url: string;
|
|
74
|
-
method: "GET" | "POST" | "PUT" | "DELETE";
|
|
75
|
-
data?: any;
|
|
76
|
-
};
|
|
77
|
-
type SignedMessagePayload = {
|
|
78
|
-
"orderly-key": string;
|
|
79
|
-
"orderly-timestamp": string;
|
|
80
|
-
"orderly-signature": string;
|
|
81
|
-
"orderly-account-id"?: string;
|
|
82
|
-
};
|
|
83
|
-
/**
|
|
84
|
-
* 签名
|
|
85
|
-
* @example
|
|
86
|
-
* ```ts
|
|
87
|
-
* const signer = new BaseSigner(keyStore);
|
|
88
|
-
* const payload = await signer.sign({
|
|
89
|
-
* url: "https://api.orderly.io/get_account?address=0x1234567890&brokerId=woofi_dex",
|
|
90
|
-
* method: "GET",
|
|
91
|
-
* data: {
|
|
92
|
-
* address: "0x1234567890",
|
|
93
|
-
* brokerId: "woofi_dex",
|
|
94
|
-
* },
|
|
95
|
-
* });
|
|
96
|
-
* ```
|
|
97
|
-
*/
|
|
98
|
-
interface Signer {
|
|
99
|
-
sign: (data: MessageFactor) => Promise<SignedMessagePayload>;
|
|
100
|
-
signText: (text: string) => Promise<{
|
|
101
|
-
signature: string;
|
|
102
|
-
publicKey: string;
|
|
103
|
-
}>;
|
|
104
|
-
}
|
|
105
|
-
declare class BaseSigner implements Signer {
|
|
106
|
-
private readonly keyStore;
|
|
107
|
-
constructor(keyStore: OrderlyKeyStore);
|
|
108
|
-
sign(message: MessageFactor): Promise<SignedMessagePayload>;
|
|
109
|
-
signText(text: string): Promise<{
|
|
110
|
-
signature: string;
|
|
111
|
-
publicKey: string;
|
|
112
|
-
}>;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
interface ConfigStore {
|
|
116
|
-
get<T>(key: string): T;
|
|
117
|
-
set<T>(key: string, value: T): void;
|
|
118
|
-
clear(): void;
|
|
119
|
-
}
|
|
120
|
-
declare class MemoryConfigStore implements ConfigStore {
|
|
121
|
-
protected map: Map<string, any>;
|
|
122
|
-
constructor();
|
|
123
|
-
protected _restore(): void;
|
|
124
|
-
get<T>(key: string): T;
|
|
125
|
-
set<T>(key: string, value: T): void;
|
|
126
|
-
clear(): void;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
*
|
|
130
|
-
*/
|
|
131
|
-
declare class BaseConfigStore extends MemoryConfigStore {
|
|
132
|
-
private readonly configMap;
|
|
133
|
-
constructor(configMap: Record<string, any>);
|
|
134
|
-
protected _restore(): void;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
declare const getMockSigner: (secretKey?: string) => BaseSigner;
|
|
138
|
-
declare const getDefaultSigner: () => BaseSigner;
|
|
139
|
-
|
|
140
|
-
interface IContract {
|
|
141
|
-
getContractInfoByEnv(): any;
|
|
142
|
-
}
|
|
143
|
-
declare class BaseContract implements IContract {
|
|
144
|
-
private readonly configStore;
|
|
145
|
-
constructor(configStore: ConfigStore);
|
|
146
|
-
getContractInfoByEnv(): {
|
|
147
|
-
usdcAddress: string;
|
|
148
|
-
vaultAddress: string;
|
|
149
|
-
verifyContractAddress: string;
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
declare class SimpleDI {
|
|
154
|
-
private static container;
|
|
155
|
-
private static getContainer;
|
|
156
|
-
static register(...serviceClasses: any[]): void;
|
|
157
|
-
static registerByName(name: string, serviceClass: any): void;
|
|
158
|
-
static get<T = any>(name: string): T;
|
|
159
|
-
static getAll(): {
|
|
160
|
-
[name: string]: any;
|
|
161
|
-
};
|
|
162
|
-
private constructor();
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
interface WalletAdapter {
|
|
166
|
-
getBalance: (address: string) => Promise<any>;
|
|
167
|
-
deposit: (from: string, to: string, amount: string) => Promise<any>;
|
|
168
|
-
send: (method: string, params: Array<any> | Record<string, any>) => Promise<any>;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
interface AccountState {
|
|
172
|
-
status: AccountStatusEnum;
|
|
173
|
-
checking: boolean;
|
|
174
|
-
accountId?: string;
|
|
175
|
-
userId?: string;
|
|
176
|
-
address?: string;
|
|
177
|
-
balance: string;
|
|
178
|
-
leverage: number;
|
|
179
|
-
positon?: string[];
|
|
180
|
-
orders?: string[];
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* 账户
|
|
184
|
-
* @example
|
|
185
|
-
* ```ts
|
|
186
|
-
* const account = new Account();
|
|
187
|
-
* account.login("0x1234567890");
|
|
188
|
-
* ```
|
|
189
|
-
*/
|
|
190
|
-
declare class Account {
|
|
191
|
-
private readonly configStore;
|
|
192
|
-
private readonly keyStore;
|
|
193
|
-
private readonly contractManger;
|
|
194
|
-
private readonly walletAdapterClass;
|
|
195
|
-
static instanceName: string;
|
|
196
|
-
private _singer?;
|
|
197
|
-
private _ee;
|
|
198
|
-
private _state;
|
|
199
|
-
private walletClient?;
|
|
200
|
-
constructor(configStore: ConfigStore, keyStore: OrderlyKeyStore, contractManger: IContract, walletAdapterClass: {
|
|
201
|
-
new (options: any): WalletAdapter;
|
|
202
|
-
});
|
|
203
|
-
/**
|
|
204
|
-
* 登录
|
|
205
|
-
* @param address 钱包地址
|
|
206
|
-
*/
|
|
207
|
-
login(address: string): void;
|
|
208
|
-
logout(): void;
|
|
209
|
-
/**
|
|
210
|
-
* 连接钱包先用第三方的React版本,不用自己实现
|
|
211
|
-
*/
|
|
212
|
-
setAddress(address: string, wallet?: {
|
|
213
|
-
provider: any;
|
|
214
|
-
chain: {
|
|
215
|
-
id: string;
|
|
216
|
-
};
|
|
217
|
-
[key: string]: any;
|
|
218
|
-
}): Promise<AccountStatusEnum>;
|
|
219
|
-
get stateValue(): AccountState;
|
|
220
|
-
get accountId(): string | undefined;
|
|
221
|
-
get address(): string | undefined;
|
|
222
|
-
get chainId(): string | undefined;
|
|
223
|
-
/**
|
|
224
|
-
* set user positions count
|
|
225
|
-
*/
|
|
226
|
-
set position(position: string[]);
|
|
227
|
-
set orders(orders: string[]);
|
|
228
|
-
private _bindEvents;
|
|
229
|
-
private _checkAccount;
|
|
230
|
-
private _checkAccountExist;
|
|
231
|
-
createAccount(): Promise<any>;
|
|
232
|
-
createOrderlyKey(expiration: number): Promise<any>;
|
|
233
|
-
settlement(): Promise<any>;
|
|
234
|
-
disconnect(): Promise<void>;
|
|
235
|
-
private _checkOrderlyKeyState;
|
|
236
|
-
get signer(): Signer;
|
|
237
|
-
get wallet(): any;
|
|
238
|
-
private _getRegisterationNonce;
|
|
239
|
-
private _getSettleNonce;
|
|
240
|
-
private _simpleFetch;
|
|
241
|
-
private getDomain;
|
|
242
|
-
get on(): <T extends string | symbol>(event: T, fn: (...args: any[]) => void, context?: any) => EventEmitter<string | symbol, any>;
|
|
243
|
-
get once(): <T extends string | symbol>(event: T, fn: (...args: any[]) => void, context?: any) => EventEmitter<string | symbol, any>;
|
|
244
|
-
get off(): <T extends string | symbol>(event: T, fn?: ((...args: any[]) => void) | undefined, context?: any, once?: boolean | undefined) => EventEmitter<string | symbol, any>;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
declare class Web3WalletAdapter implements WalletAdapter {
|
|
248
|
-
private readonly web3;
|
|
249
|
-
constructor(web3: any);
|
|
250
|
-
getBalance(address: string): Promise<any>;
|
|
251
|
-
deposit(from: string, to: string, amount: string): Promise<any>;
|
|
252
|
-
send(method: string, params: Array<any> | Record<string, any>): Promise<any>;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
interface EtherAdapterOptions {
|
|
256
|
-
provider: any;
|
|
257
|
-
label?: string;
|
|
258
|
-
getAddresses?: (address: string) => string;
|
|
259
|
-
chain: {
|
|
260
|
-
id: string;
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
declare class EtherAdapter implements WalletAdapter {
|
|
264
|
-
private provider?;
|
|
265
|
-
private _chainId;
|
|
266
|
-
constructor(options: EtherAdapterOptions);
|
|
267
|
-
getBalance(address: string): Promise<any>;
|
|
268
|
-
deposit(from: string, to: string, amount: string): Promise<any>;
|
|
269
|
-
getAddresses(address: string): string;
|
|
270
|
-
get chainId(): number;
|
|
271
|
-
send(method: string, params: Array<any> | Record<string, any>): Promise<any>;
|
|
272
|
-
verify(data: {
|
|
273
|
-
domain: any;
|
|
274
|
-
message: any;
|
|
275
|
-
types: any;
|
|
276
|
-
}, signature: string): Promise<void>;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
export { Account, AccountState, BaseConfigStore, BaseContract as BaseContractManager, BaseKeyStore, BaseOrderlyKeyPair, BaseSigner, ConfigStore, EtherAdapter, IContract, LocalStorageStore, MemoryConfigStore, MessageFactor, MockKeyStore, OrderlyKeyPair, OrderlyKeyStore, SignedMessagePayload, Signer, SimpleDI, WalletAdapter, Web3WalletAdapter, getDefaultSigner, getMockSigner };
|
package/dist/index.d.ts
DELETED
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
import EventEmitter from 'eventemitter3';
|
|
2
|
-
export { default as EventEmitter } from 'eventemitter3';
|
|
3
|
-
import { AccountStatusEnum } from '@orderly.network/types';
|
|
4
|
-
|
|
5
|
-
interface OrderlyKeyPair {
|
|
6
|
-
getPublicKey(): Promise<string>;
|
|
7
|
-
secretKey: string;
|
|
8
|
-
sign: (data: Uint8Array) => Promise<Uint8Array>;
|
|
9
|
-
}
|
|
10
|
-
declare class BaseOrderlyKeyPair implements OrderlyKeyPair {
|
|
11
|
-
secretKey: string;
|
|
12
|
-
private privateKey;
|
|
13
|
-
static generateKey(): OrderlyKeyPair;
|
|
14
|
-
constructor(secretKey: string);
|
|
15
|
-
sign(message: Uint8Array): Promise<Uint8Array>;
|
|
16
|
-
getPublicKey(): Promise<string>;
|
|
17
|
-
toString(): string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface OrderlyKeyStore {
|
|
21
|
-
getOrderlyKey: (address?: string) => OrderlyKeyPair | null;
|
|
22
|
-
getAccountId: (address: string) => string | undefined | null;
|
|
23
|
-
setAccountId: (address: string, accountId: string) => void;
|
|
24
|
-
getAddress: () => string | undefined | null;
|
|
25
|
-
setAddress: (address: string) => void;
|
|
26
|
-
generateKey: () => OrderlyKeyPair;
|
|
27
|
-
cleanKey: (address: string, key: string) => void;
|
|
28
|
-
cleanAllKey: (address: string) => void;
|
|
29
|
-
setKey: (orderlyKey: string, secretKey: OrderlyKeyPair) => void;
|
|
30
|
-
}
|
|
31
|
-
declare abstract class BaseKeyStore implements OrderlyKeyStore {
|
|
32
|
-
private readonly networkId;
|
|
33
|
-
constructor(networkId?: string);
|
|
34
|
-
abstract getOrderlyKey(address?: string): OrderlyKeyPair | null;
|
|
35
|
-
abstract getAccountId(address: string): string | undefined | null;
|
|
36
|
-
abstract setAccountId(address: string, accountId: string): void;
|
|
37
|
-
abstract getAddress(): string | undefined | null;
|
|
38
|
-
abstract setAddress(address: string): void;
|
|
39
|
-
abstract generateKey(): OrderlyKeyPair;
|
|
40
|
-
abstract setKey(orderlyKey: string, secretKey: OrderlyKeyPair): void;
|
|
41
|
-
abstract cleanAllKey(address: string): void;
|
|
42
|
-
abstract cleanKey(address: string, key: string): void;
|
|
43
|
-
protected get keyPrefix(): string;
|
|
44
|
-
}
|
|
45
|
-
declare class LocalStorageStore extends BaseKeyStore {
|
|
46
|
-
getOrderlyKey(address?: string): OrderlyKeyPair | null;
|
|
47
|
-
getAccountId(address: string): string | undefined | null;
|
|
48
|
-
setAccountId(address: string, accountId: string): void;
|
|
49
|
-
getAddress(): string | undefined | null;
|
|
50
|
-
setAddress(address: string): void;
|
|
51
|
-
generateKey(): OrderlyKeyPair;
|
|
52
|
-
setKey(address: string, orderlyKey: OrderlyKeyPair): void;
|
|
53
|
-
cleanAllKey(address: string): void;
|
|
54
|
-
cleanKey(address: string, key: string): void;
|
|
55
|
-
private setItem;
|
|
56
|
-
private getItem;
|
|
57
|
-
}
|
|
58
|
-
declare class MockKeyStore implements OrderlyKeyStore {
|
|
59
|
-
private readonly secretKey;
|
|
60
|
-
constructor(secretKey: string);
|
|
61
|
-
generateKey(): BaseOrderlyKeyPair;
|
|
62
|
-
getOrderlyKey(): BaseOrderlyKeyPair;
|
|
63
|
-
getAccountId(): string;
|
|
64
|
-
setAccountId(accountId: string): void;
|
|
65
|
-
getAddress(): string;
|
|
66
|
-
setAddress(address: string): void;
|
|
67
|
-
setKey(orderlyKey: string, secretKey: OrderlyKeyPair): void;
|
|
68
|
-
cleanAllKey(): void;
|
|
69
|
-
cleanKey(key: string): void;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
type MessageFactor = {
|
|
73
|
-
url: string;
|
|
74
|
-
method: "GET" | "POST" | "PUT" | "DELETE";
|
|
75
|
-
data?: any;
|
|
76
|
-
};
|
|
77
|
-
type SignedMessagePayload = {
|
|
78
|
-
"orderly-key": string;
|
|
79
|
-
"orderly-timestamp": string;
|
|
80
|
-
"orderly-signature": string;
|
|
81
|
-
"orderly-account-id"?: string;
|
|
82
|
-
};
|
|
83
|
-
/**
|
|
84
|
-
* 签名
|
|
85
|
-
* @example
|
|
86
|
-
* ```ts
|
|
87
|
-
* const signer = new BaseSigner(keyStore);
|
|
88
|
-
* const payload = await signer.sign({
|
|
89
|
-
* url: "https://api.orderly.io/get_account?address=0x1234567890&brokerId=woofi_dex",
|
|
90
|
-
* method: "GET",
|
|
91
|
-
* data: {
|
|
92
|
-
* address: "0x1234567890",
|
|
93
|
-
* brokerId: "woofi_dex",
|
|
94
|
-
* },
|
|
95
|
-
* });
|
|
96
|
-
* ```
|
|
97
|
-
*/
|
|
98
|
-
interface Signer {
|
|
99
|
-
sign: (data: MessageFactor) => Promise<SignedMessagePayload>;
|
|
100
|
-
signText: (text: string) => Promise<{
|
|
101
|
-
signature: string;
|
|
102
|
-
publicKey: string;
|
|
103
|
-
}>;
|
|
104
|
-
}
|
|
105
|
-
declare class BaseSigner implements Signer {
|
|
106
|
-
private readonly keyStore;
|
|
107
|
-
constructor(keyStore: OrderlyKeyStore);
|
|
108
|
-
sign(message: MessageFactor): Promise<SignedMessagePayload>;
|
|
109
|
-
signText(text: string): Promise<{
|
|
110
|
-
signature: string;
|
|
111
|
-
publicKey: string;
|
|
112
|
-
}>;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
interface ConfigStore {
|
|
116
|
-
get<T>(key: string): T;
|
|
117
|
-
set<T>(key: string, value: T): void;
|
|
118
|
-
clear(): void;
|
|
119
|
-
}
|
|
120
|
-
declare class MemoryConfigStore implements ConfigStore {
|
|
121
|
-
protected map: Map<string, any>;
|
|
122
|
-
constructor();
|
|
123
|
-
protected _restore(): void;
|
|
124
|
-
get<T>(key: string): T;
|
|
125
|
-
set<T>(key: string, value: T): void;
|
|
126
|
-
clear(): void;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
*
|
|
130
|
-
*/
|
|
131
|
-
declare class BaseConfigStore extends MemoryConfigStore {
|
|
132
|
-
private readonly configMap;
|
|
133
|
-
constructor(configMap: Record<string, any>);
|
|
134
|
-
protected _restore(): void;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
declare const getMockSigner: (secretKey?: string) => BaseSigner;
|
|
138
|
-
declare const getDefaultSigner: () => BaseSigner;
|
|
139
|
-
|
|
140
|
-
interface IContract {
|
|
141
|
-
getContractInfoByEnv(): any;
|
|
142
|
-
}
|
|
143
|
-
declare class BaseContract implements IContract {
|
|
144
|
-
private readonly configStore;
|
|
145
|
-
constructor(configStore: ConfigStore);
|
|
146
|
-
getContractInfoByEnv(): {
|
|
147
|
-
usdcAddress: string;
|
|
148
|
-
vaultAddress: string;
|
|
149
|
-
verifyContractAddress: string;
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
declare class SimpleDI {
|
|
154
|
-
private static container;
|
|
155
|
-
private static getContainer;
|
|
156
|
-
static register(...serviceClasses: any[]): void;
|
|
157
|
-
static registerByName(name: string, serviceClass: any): void;
|
|
158
|
-
static get<T = any>(name: string): T;
|
|
159
|
-
static getAll(): {
|
|
160
|
-
[name: string]: any;
|
|
161
|
-
};
|
|
162
|
-
private constructor();
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
interface WalletAdapter {
|
|
166
|
-
getBalance: (address: string) => Promise<any>;
|
|
167
|
-
deposit: (from: string, to: string, amount: string) => Promise<any>;
|
|
168
|
-
send: (method: string, params: Array<any> | Record<string, any>) => Promise<any>;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
interface AccountState {
|
|
172
|
-
status: AccountStatusEnum;
|
|
173
|
-
checking: boolean;
|
|
174
|
-
accountId?: string;
|
|
175
|
-
userId?: string;
|
|
176
|
-
address?: string;
|
|
177
|
-
balance: string;
|
|
178
|
-
leverage: number;
|
|
179
|
-
positon?: string[];
|
|
180
|
-
orders?: string[];
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* 账户
|
|
184
|
-
* @example
|
|
185
|
-
* ```ts
|
|
186
|
-
* const account = new Account();
|
|
187
|
-
* account.login("0x1234567890");
|
|
188
|
-
* ```
|
|
189
|
-
*/
|
|
190
|
-
declare class Account {
|
|
191
|
-
private readonly configStore;
|
|
192
|
-
private readonly keyStore;
|
|
193
|
-
private readonly contractManger;
|
|
194
|
-
private readonly walletAdapterClass;
|
|
195
|
-
static instanceName: string;
|
|
196
|
-
private _singer?;
|
|
197
|
-
private _ee;
|
|
198
|
-
private _state;
|
|
199
|
-
private walletClient?;
|
|
200
|
-
constructor(configStore: ConfigStore, keyStore: OrderlyKeyStore, contractManger: IContract, walletAdapterClass: {
|
|
201
|
-
new (options: any): WalletAdapter;
|
|
202
|
-
});
|
|
203
|
-
/**
|
|
204
|
-
* 登录
|
|
205
|
-
* @param address 钱包地址
|
|
206
|
-
*/
|
|
207
|
-
login(address: string): void;
|
|
208
|
-
logout(): void;
|
|
209
|
-
/**
|
|
210
|
-
* 连接钱包先用第三方的React版本,不用自己实现
|
|
211
|
-
*/
|
|
212
|
-
setAddress(address: string, wallet?: {
|
|
213
|
-
provider: any;
|
|
214
|
-
chain: {
|
|
215
|
-
id: string;
|
|
216
|
-
};
|
|
217
|
-
[key: string]: any;
|
|
218
|
-
}): Promise<AccountStatusEnum>;
|
|
219
|
-
get stateValue(): AccountState;
|
|
220
|
-
get accountId(): string | undefined;
|
|
221
|
-
get address(): string | undefined;
|
|
222
|
-
get chainId(): string | undefined;
|
|
223
|
-
/**
|
|
224
|
-
* set user positions count
|
|
225
|
-
*/
|
|
226
|
-
set position(position: string[]);
|
|
227
|
-
set orders(orders: string[]);
|
|
228
|
-
private _bindEvents;
|
|
229
|
-
private _checkAccount;
|
|
230
|
-
private _checkAccountExist;
|
|
231
|
-
createAccount(): Promise<any>;
|
|
232
|
-
createOrderlyKey(expiration: number): Promise<any>;
|
|
233
|
-
settlement(): Promise<any>;
|
|
234
|
-
disconnect(): Promise<void>;
|
|
235
|
-
private _checkOrderlyKeyState;
|
|
236
|
-
get signer(): Signer;
|
|
237
|
-
get wallet(): any;
|
|
238
|
-
private _getRegisterationNonce;
|
|
239
|
-
private _getSettleNonce;
|
|
240
|
-
private _simpleFetch;
|
|
241
|
-
private getDomain;
|
|
242
|
-
get on(): <T extends string | symbol>(event: T, fn: (...args: any[]) => void, context?: any) => EventEmitter<string | symbol, any>;
|
|
243
|
-
get once(): <T extends string | symbol>(event: T, fn: (...args: any[]) => void, context?: any) => EventEmitter<string | symbol, any>;
|
|
244
|
-
get off(): <T extends string | symbol>(event: T, fn?: ((...args: any[]) => void) | undefined, context?: any, once?: boolean | undefined) => EventEmitter<string | symbol, any>;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
declare class Web3WalletAdapter implements WalletAdapter {
|
|
248
|
-
private readonly web3;
|
|
249
|
-
constructor(web3: any);
|
|
250
|
-
getBalance(address: string): Promise<any>;
|
|
251
|
-
deposit(from: string, to: string, amount: string): Promise<any>;
|
|
252
|
-
send(method: string, params: Array<any> | Record<string, any>): Promise<any>;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
interface EtherAdapterOptions {
|
|
256
|
-
provider: any;
|
|
257
|
-
label?: string;
|
|
258
|
-
getAddresses?: (address: string) => string;
|
|
259
|
-
chain: {
|
|
260
|
-
id: string;
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
declare class EtherAdapter implements WalletAdapter {
|
|
264
|
-
private provider?;
|
|
265
|
-
private _chainId;
|
|
266
|
-
constructor(options: EtherAdapterOptions);
|
|
267
|
-
getBalance(address: string): Promise<any>;
|
|
268
|
-
deposit(from: string, to: string, amount: string): Promise<any>;
|
|
269
|
-
getAddresses(address: string): string;
|
|
270
|
-
get chainId(): number;
|
|
271
|
-
send(method: string, params: Array<any> | Record<string, any>): Promise<any>;
|
|
272
|
-
verify(data: {
|
|
273
|
-
domain: any;
|
|
274
|
-
message: any;
|
|
275
|
-
types: any;
|
|
276
|
-
}, signature: string): Promise<void>;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
export { Account, AccountState, BaseConfigStore, BaseContract as BaseContractManager, BaseKeyStore, BaseOrderlyKeyPair, BaseSigner, ConfigStore, EtherAdapter, IContract, LocalStorageStore, MemoryConfigStore, MessageFactor, MockKeyStore, OrderlyKeyPair, OrderlyKeyStore, SignedMessagePayload, Signer, SimpleDI, WalletAdapter, Web3WalletAdapter, getDefaultSigner, getMockSigner };
|