@orderly.network/core 0.0.43 → 0.0.45

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.d.mts CHANGED
@@ -138,15 +138,128 @@ declare class BaseConfigStore extends MemoryConfigStore {
138
138
  declare const getMockSigner: (secretKey?: string) => BaseSigner;
139
139
  declare const getDefaultSigner: () => BaseSigner;
140
140
 
141
+ type OrderlyContracts = {
142
+ usdcAddress: string;
143
+ usdcAbi: any;
144
+ vaultAddress: string;
145
+ vaultAbi: any;
146
+ verifyContractAddress: string;
147
+ };
141
148
  interface IContract {
142
- getContractInfoByEnv(): any;
149
+ getContractInfoByEnv(): OrderlyContracts;
143
150
  }
144
151
  declare class BaseContract implements IContract {
145
152
  private readonly configStore;
146
153
  constructor(configStore: ConfigStore);
147
154
  getContractInfoByEnv(): {
148
155
  usdcAddress: string;
156
+ usdcAbi: ({
157
+ inputs: {
158
+ internalType: string;
159
+ name: string;
160
+ type: string;
161
+ }[];
162
+ stateMutability: string;
163
+ type: string;
164
+ anonymous?: undefined;
165
+ name?: undefined;
166
+ outputs?: undefined;
167
+ } | {
168
+ anonymous: boolean;
169
+ inputs: {
170
+ indexed: boolean;
171
+ internalType: string;
172
+ name: string;
173
+ type: string;
174
+ }[];
175
+ name: string;
176
+ type: string;
177
+ stateMutability?: undefined;
178
+ outputs?: undefined;
179
+ } | {
180
+ inputs: {
181
+ internalType: string;
182
+ name: string;
183
+ type: string;
184
+ }[];
185
+ name: string;
186
+ outputs: {
187
+ internalType: string;
188
+ name: string;
189
+ type: string;
190
+ }[];
191
+ stateMutability: string;
192
+ type: string;
193
+ anonymous?: undefined;
194
+ })[];
149
195
  vaultAddress: string;
196
+ vaultAbi: ({
197
+ inputs: never[];
198
+ stateMutability: string;
199
+ type: string;
200
+ name?: undefined;
201
+ anonymous?: undefined;
202
+ outputs?: undefined;
203
+ } | {
204
+ inputs: {
205
+ internalType: string;
206
+ name: string;
207
+ type: string;
208
+ }[];
209
+ name: string;
210
+ type: string;
211
+ stateMutability?: undefined;
212
+ anonymous?: undefined;
213
+ outputs?: undefined;
214
+ } | {
215
+ anonymous: boolean;
216
+ inputs: {
217
+ indexed: boolean;
218
+ internalType: string;
219
+ name: string;
220
+ type: string;
221
+ }[];
222
+ name: string;
223
+ type: string;
224
+ stateMutability?: undefined;
225
+ outputs?: undefined;
226
+ } | {
227
+ inputs: {
228
+ internalType: string;
229
+ name: string;
230
+ type: string;
231
+ }[];
232
+ name: string;
233
+ outputs: {
234
+ internalType: string;
235
+ name: string;
236
+ type: string;
237
+ }[];
238
+ stateMutability: string;
239
+ type: string;
240
+ anonymous?: undefined;
241
+ } | {
242
+ inputs: ({
243
+ internalType: string;
244
+ name: string;
245
+ type: string;
246
+ components?: undefined;
247
+ } | {
248
+ components: {
249
+ internalType: string;
250
+ name: string;
251
+ type: string;
252
+ }[];
253
+ internalType: string;
254
+ name: string;
255
+ type: string;
256
+ })[];
257
+ name: string;
258
+ outputs: never[];
259
+ stateMutability: string;
260
+ type: string;
261
+ anonymous?: undefined;
262
+ })[];
150
263
  verifyContractAddress: string;
151
264
  };
152
265
  }
@@ -166,10 +279,16 @@ declare class SimpleDI {
166
279
  interface WalletAdapter {
167
280
  get chainId(): number;
168
281
  get addresses(): string;
169
- getBalance: (address: string) => Promise<any>;
170
- deposit: (from: string, to: string, amount: string) => Promise<any>;
282
+ parseUnits: (amount: string) => string;
283
+ fromUnits: (amount: string) => string;
171
284
  send: (method: string, params: Array<any> | Record<string, any>) => Promise<any>;
172
285
  signTypedData: (address: string, data: any) => Promise<string>;
286
+ getBalance: (address: string, userAddress: string, options: {
287
+ abi: any;
288
+ }) => Promise<any>;
289
+ call(address: string, method: string, params: any, options: {
290
+ abi: any;
291
+ }): Promise<any>;
173
292
  }
174
293
  type WalletAdapterOptions = {
175
294
  provider: any;
@@ -180,6 +299,32 @@ type WalletAdapterOptions = {
180
299
  };
181
300
  type getWalletAdapterFunc = (options: WalletAdapterOptions) => WalletAdapter;
182
301
 
302
+ type SignatureDomain = {
303
+ name: string;
304
+ version: string;
305
+ chainId: number;
306
+ verifyingContract: string;
307
+ };
308
+
309
+ declare class Assets {
310
+ private readonly configStore;
311
+ private readonly contractManger;
312
+ private readonly account;
313
+ constructor(configStore: ConfigStore, contractManger: IContract, account: Account);
314
+ withdraw(inputs: {
315
+ chainId: number;
316
+ token: string;
317
+ amount: number;
318
+ }): Promise<any>;
319
+ private _generateWithdrawMessage;
320
+ private getWithdrawalNonce;
321
+ getBalance(): Promise<string>;
322
+ getAllowance(): Promise<string>;
323
+ approve(amount?: string): Promise<any>;
324
+ deposit(amount: string): Promise<any>;
325
+ private _simpleFetch;
326
+ }
327
+
183
328
  interface AccountState {
184
329
  status: AccountStatusEnum;
185
330
  checking: boolean;
@@ -208,8 +353,9 @@ declare class Account {
208
353
  static instanceName: string;
209
354
  private _singer?;
210
355
  private _ee;
356
+ assetsManager: Assets;
211
357
  private _state;
212
- private walletClient?;
358
+ walletClient?: WalletAdapter;
213
359
  constructor(configStore: ConfigStore, keyStore: OrderlyKeyStore, contractManger: IContract, getWalletAdapter: getWalletAdapterFunc);
214
360
  /**
215
361
  * 登录
@@ -233,7 +379,7 @@ declare class Account {
233
379
  get stateValue(): AccountState;
234
380
  get accountId(): string | undefined;
235
381
  get address(): string | undefined;
236
- get chainId(): string | undefined;
382
+ get chainId(): number | string | undefined;
237
383
  /**
238
384
  * set user positions count
239
385
  */
@@ -243,16 +389,17 @@ declare class Account {
243
389
  private _checkAccount;
244
390
  private _checkAccountExist;
245
391
  createAccount(): Promise<any>;
392
+ signTypedData(toSignatureMessage: Record<string, any>): Promise<string>;
246
393
  createOrderlyKey(expiration: number): Promise<any>;
247
- settlement(): Promise<any>;
394
+ settle(): Promise<any>;
248
395
  disconnect(): Promise<void>;
249
396
  private _checkOrderlyKeyState;
250
397
  get signer(): Signer;
251
- get wallet(): any;
398
+ get wallet(): WalletAdapter | undefined;
252
399
  private _getRegisterationNonce;
253
400
  private _getSettleNonce;
254
401
  private _simpleFetch;
255
- private getDomain;
402
+ getDomain(onChainDomain?: boolean): SignatureDomain;
256
403
  get on(): <T extends string | symbol>(event: T, fn: (...args: any[]) => void, context?: any) => EventEmitter<string | symbol, any>;
257
404
  get once(): <T extends string | symbol>(event: T, fn: (...args: any[]) => void, context?: any) => EventEmitter<string | symbol, any>;
258
405
  get off(): <T extends string | symbol>(event: T, fn?: ((...args: any[]) => void) | undefined, context?: any, once?: boolean | undefined) => EventEmitter<string | symbol, any>;
@@ -263,8 +410,15 @@ declare class EtherAdapter implements WalletAdapter {
263
410
  private _chainId;
264
411
  private _address;
265
412
  constructor(options: WalletAdapterOptions);
266
- getBalance(address: string): Promise<any>;
413
+ parseUnits(amount: string): string;
414
+ fromUnits(amount: string): string;
415
+ getBalance(contractId: string, userAddress: string, options: {
416
+ abi: any;
417
+ }): Promise<any>;
267
418
  deposit(from: string, to: string, amount: string): Promise<any>;
419
+ call(address: string, method: string, params: any[], options: {
420
+ abi: any;
421
+ }): Promise<any>;
268
422
  get chainId(): number;
269
423
  get addresses(): string;
270
424
  send(method: string, params: Array<any> | Record<string, any>): Promise<any>;
package/dist/index.d.ts CHANGED
@@ -138,15 +138,128 @@ declare class BaseConfigStore extends MemoryConfigStore {
138
138
  declare const getMockSigner: (secretKey?: string) => BaseSigner;
139
139
  declare const getDefaultSigner: () => BaseSigner;
140
140
 
141
+ type OrderlyContracts = {
142
+ usdcAddress: string;
143
+ usdcAbi: any;
144
+ vaultAddress: string;
145
+ vaultAbi: any;
146
+ verifyContractAddress: string;
147
+ };
141
148
  interface IContract {
142
- getContractInfoByEnv(): any;
149
+ getContractInfoByEnv(): OrderlyContracts;
143
150
  }
144
151
  declare class BaseContract implements IContract {
145
152
  private readonly configStore;
146
153
  constructor(configStore: ConfigStore);
147
154
  getContractInfoByEnv(): {
148
155
  usdcAddress: string;
156
+ usdcAbi: ({
157
+ inputs: {
158
+ internalType: string;
159
+ name: string;
160
+ type: string;
161
+ }[];
162
+ stateMutability: string;
163
+ type: string;
164
+ anonymous?: undefined;
165
+ name?: undefined;
166
+ outputs?: undefined;
167
+ } | {
168
+ anonymous: boolean;
169
+ inputs: {
170
+ indexed: boolean;
171
+ internalType: string;
172
+ name: string;
173
+ type: string;
174
+ }[];
175
+ name: string;
176
+ type: string;
177
+ stateMutability?: undefined;
178
+ outputs?: undefined;
179
+ } | {
180
+ inputs: {
181
+ internalType: string;
182
+ name: string;
183
+ type: string;
184
+ }[];
185
+ name: string;
186
+ outputs: {
187
+ internalType: string;
188
+ name: string;
189
+ type: string;
190
+ }[];
191
+ stateMutability: string;
192
+ type: string;
193
+ anonymous?: undefined;
194
+ })[];
149
195
  vaultAddress: string;
196
+ vaultAbi: ({
197
+ inputs: never[];
198
+ stateMutability: string;
199
+ type: string;
200
+ name?: undefined;
201
+ anonymous?: undefined;
202
+ outputs?: undefined;
203
+ } | {
204
+ inputs: {
205
+ internalType: string;
206
+ name: string;
207
+ type: string;
208
+ }[];
209
+ name: string;
210
+ type: string;
211
+ stateMutability?: undefined;
212
+ anonymous?: undefined;
213
+ outputs?: undefined;
214
+ } | {
215
+ anonymous: boolean;
216
+ inputs: {
217
+ indexed: boolean;
218
+ internalType: string;
219
+ name: string;
220
+ type: string;
221
+ }[];
222
+ name: string;
223
+ type: string;
224
+ stateMutability?: undefined;
225
+ outputs?: undefined;
226
+ } | {
227
+ inputs: {
228
+ internalType: string;
229
+ name: string;
230
+ type: string;
231
+ }[];
232
+ name: string;
233
+ outputs: {
234
+ internalType: string;
235
+ name: string;
236
+ type: string;
237
+ }[];
238
+ stateMutability: string;
239
+ type: string;
240
+ anonymous?: undefined;
241
+ } | {
242
+ inputs: ({
243
+ internalType: string;
244
+ name: string;
245
+ type: string;
246
+ components?: undefined;
247
+ } | {
248
+ components: {
249
+ internalType: string;
250
+ name: string;
251
+ type: string;
252
+ }[];
253
+ internalType: string;
254
+ name: string;
255
+ type: string;
256
+ })[];
257
+ name: string;
258
+ outputs: never[];
259
+ stateMutability: string;
260
+ type: string;
261
+ anonymous?: undefined;
262
+ })[];
150
263
  verifyContractAddress: string;
151
264
  };
152
265
  }
@@ -166,10 +279,16 @@ declare class SimpleDI {
166
279
  interface WalletAdapter {
167
280
  get chainId(): number;
168
281
  get addresses(): string;
169
- getBalance: (address: string) => Promise<any>;
170
- deposit: (from: string, to: string, amount: string) => Promise<any>;
282
+ parseUnits: (amount: string) => string;
283
+ fromUnits: (amount: string) => string;
171
284
  send: (method: string, params: Array<any> | Record<string, any>) => Promise<any>;
172
285
  signTypedData: (address: string, data: any) => Promise<string>;
286
+ getBalance: (address: string, userAddress: string, options: {
287
+ abi: any;
288
+ }) => Promise<any>;
289
+ call(address: string, method: string, params: any, options: {
290
+ abi: any;
291
+ }): Promise<any>;
173
292
  }
174
293
  type WalletAdapterOptions = {
175
294
  provider: any;
@@ -180,6 +299,32 @@ type WalletAdapterOptions = {
180
299
  };
181
300
  type getWalletAdapterFunc = (options: WalletAdapterOptions) => WalletAdapter;
182
301
 
302
+ type SignatureDomain = {
303
+ name: string;
304
+ version: string;
305
+ chainId: number;
306
+ verifyingContract: string;
307
+ };
308
+
309
+ declare class Assets {
310
+ private readonly configStore;
311
+ private readonly contractManger;
312
+ private readonly account;
313
+ constructor(configStore: ConfigStore, contractManger: IContract, account: Account);
314
+ withdraw(inputs: {
315
+ chainId: number;
316
+ token: string;
317
+ amount: number;
318
+ }): Promise<any>;
319
+ private _generateWithdrawMessage;
320
+ private getWithdrawalNonce;
321
+ getBalance(): Promise<string>;
322
+ getAllowance(): Promise<string>;
323
+ approve(amount?: string): Promise<any>;
324
+ deposit(amount: string): Promise<any>;
325
+ private _simpleFetch;
326
+ }
327
+
183
328
  interface AccountState {
184
329
  status: AccountStatusEnum;
185
330
  checking: boolean;
@@ -208,8 +353,9 @@ declare class Account {
208
353
  static instanceName: string;
209
354
  private _singer?;
210
355
  private _ee;
356
+ assetsManager: Assets;
211
357
  private _state;
212
- private walletClient?;
358
+ walletClient?: WalletAdapter;
213
359
  constructor(configStore: ConfigStore, keyStore: OrderlyKeyStore, contractManger: IContract, getWalletAdapter: getWalletAdapterFunc);
214
360
  /**
215
361
  * 登录
@@ -233,7 +379,7 @@ declare class Account {
233
379
  get stateValue(): AccountState;
234
380
  get accountId(): string | undefined;
235
381
  get address(): string | undefined;
236
- get chainId(): string | undefined;
382
+ get chainId(): number | string | undefined;
237
383
  /**
238
384
  * set user positions count
239
385
  */
@@ -243,16 +389,17 @@ declare class Account {
243
389
  private _checkAccount;
244
390
  private _checkAccountExist;
245
391
  createAccount(): Promise<any>;
392
+ signTypedData(toSignatureMessage: Record<string, any>): Promise<string>;
246
393
  createOrderlyKey(expiration: number): Promise<any>;
247
- settlement(): Promise<any>;
394
+ settle(): Promise<any>;
248
395
  disconnect(): Promise<void>;
249
396
  private _checkOrderlyKeyState;
250
397
  get signer(): Signer;
251
- get wallet(): any;
398
+ get wallet(): WalletAdapter | undefined;
252
399
  private _getRegisterationNonce;
253
400
  private _getSettleNonce;
254
401
  private _simpleFetch;
255
- private getDomain;
402
+ getDomain(onChainDomain?: boolean): SignatureDomain;
256
403
  get on(): <T extends string | symbol>(event: T, fn: (...args: any[]) => void, context?: any) => EventEmitter<string | symbol, any>;
257
404
  get once(): <T extends string | symbol>(event: T, fn: (...args: any[]) => void, context?: any) => EventEmitter<string | symbol, any>;
258
405
  get off(): <T extends string | symbol>(event: T, fn?: ((...args: any[]) => void) | undefined, context?: any, once?: boolean | undefined) => EventEmitter<string | symbol, any>;
@@ -263,8 +410,15 @@ declare class EtherAdapter implements WalletAdapter {
263
410
  private _chainId;
264
411
  private _address;
265
412
  constructor(options: WalletAdapterOptions);
266
- getBalance(address: string): Promise<any>;
413
+ parseUnits(amount: string): string;
414
+ fromUnits(amount: string): string;
415
+ getBalance(contractId: string, userAddress: string, options: {
416
+ abi: any;
417
+ }): Promise<any>;
267
418
  deposit(from: string, to: string, amount: string): Promise<any>;
419
+ call(address: string, method: string, params: any[], options: {
420
+ abi: any;
421
+ }): Promise<any>;
268
422
  get chainId(): number;
269
423
  get addresses(): string;
270
424
  send(method: string, params: Array<any> | Record<string, any>): Promise<any>;