@orderly.network/core 0.0.52 → 0.0.54

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
@@ -135,12 +135,45 @@ declare class BaseConfigStore extends MemoryConfigStore {
135
135
  protected _restore(): void;
136
136
  }
137
137
 
138
+ type SignatureDomain = {
139
+ name: string;
140
+ version: string;
141
+ chainId: number;
142
+ verifyingContract: string;
143
+ };
144
+ declare const base64url: (aStr: string) => string;
145
+ declare function parseBrokerHash(brokerId: string): string;
146
+ declare function parseAccountId(userAddress: string, brokerId: string): string;
147
+ declare function parseTokenHash(tokenSymbol: string): string;
148
+ declare function calculateStringHash(input: string): string;
149
+ declare function formatByUnits(amount: string, unit?: number | "ether" | "gwei"): string;
150
+
151
+ type utils_SignatureDomain = SignatureDomain;
152
+ declare const utils_base64url: typeof base64url;
153
+ declare const utils_calculateStringHash: typeof calculateStringHash;
154
+ declare const utils_formatByUnits: typeof formatByUnits;
155
+ declare const utils_parseAccountId: typeof parseAccountId;
156
+ declare const utils_parseBrokerHash: typeof parseBrokerHash;
157
+ declare const utils_parseTokenHash: typeof parseTokenHash;
158
+ declare namespace utils {
159
+ export {
160
+ utils_SignatureDomain as SignatureDomain,
161
+ utils_base64url as base64url,
162
+ utils_calculateStringHash as calculateStringHash,
163
+ utils_formatByUnits as formatByUnits,
164
+ utils_parseAccountId as parseAccountId,
165
+ utils_parseBrokerHash as parseBrokerHash,
166
+ utils_parseTokenHash as parseTokenHash,
167
+ };
168
+ }
169
+
138
170
  declare const getMockSigner: (secretKey?: string) => BaseSigner;
139
171
  declare const getDefaultSigner: () => BaseSigner;
140
172
 
141
173
  type OrderlyContracts = {
142
174
  usdcAddress: string;
143
175
  usdcAbi: any;
176
+ erc20Abi: any;
144
177
  vaultAddress: string;
145
178
  vaultAbi: any;
146
179
  verifyContractAddress: string;
@@ -261,6 +294,45 @@ declare class BaseContract implements IContract {
261
294
  anonymous?: undefined;
262
295
  })[];
263
296
  verifyContractAddress: string;
297
+ erc20Abi: ({
298
+ inputs: {
299
+ internalType: string;
300
+ name: string;
301
+ type: string;
302
+ }[];
303
+ stateMutability: string;
304
+ type: string;
305
+ anonymous?: undefined;
306
+ name?: undefined;
307
+ outputs?: undefined;
308
+ } | {
309
+ anonymous: boolean;
310
+ inputs: {
311
+ indexed: boolean;
312
+ internalType: string;
313
+ name: string;
314
+ type: string;
315
+ }[];
316
+ name: string;
317
+ type: string;
318
+ stateMutability?: undefined;
319
+ outputs?: undefined;
320
+ } | {
321
+ inputs: {
322
+ internalType: string;
323
+ name: string;
324
+ type: string;
325
+ }[];
326
+ name: string;
327
+ outputs: {
328
+ internalType: string;
329
+ name: string;
330
+ type: string;
331
+ }[];
332
+ stateMutability: string;
333
+ type: string;
334
+ anonymous?: undefined;
335
+ })[];
264
336
  };
265
337
  }
266
338
 
@@ -280,15 +352,15 @@ interface WalletAdapter {
280
352
  get chainId(): number;
281
353
  get addresses(): string;
282
354
  parseUnits: (amount: string) => string;
283
- fromUnits: (amount: string) => string;
355
+ formatUnits: (amount: string) => string;
284
356
  send: (method: string, params: Array<any> | Record<string, any>) => Promise<any>;
285
357
  signTypedData: (address: string, data: any) => Promise<string>;
286
- getBalance: (address: string, userAddress: string, options: {
287
- abi: any;
288
- }) => Promise<any>;
358
+ getBalance: (userAddress: string) => Promise<any>;
289
359
  call(address: string, method: string, params: any, options: {
290
360
  abi: any;
291
361
  }): Promise<any>;
362
+ on(eventName: any, listener: any): void;
363
+ off(eventName: any, listener: any): void;
292
364
  }
293
365
  type WalletAdapterOptions = {
294
366
  provider: any;
@@ -299,13 +371,6 @@ type WalletAdapterOptions = {
299
371
  };
300
372
  type getWalletAdapterFunc = (options: WalletAdapterOptions) => WalletAdapter;
301
373
 
302
- type SignatureDomain = {
303
- name: string;
304
- version: string;
305
- chainId: number;
306
- verifyingContract: string;
307
- };
308
-
309
374
  declare class Assets {
310
375
  private readonly configStore;
311
376
  private readonly contractManger;
@@ -318,11 +383,21 @@ declare class Assets {
318
383
  }): Promise<any>;
319
384
  private _generateWithdrawMessage;
320
385
  private getWithdrawalNonce;
321
- getBalance(): Promise<string>;
322
- getAllowance(): Promise<string>;
323
- approve(amount?: string): Promise<any>;
386
+ getNativeBalance(options?: {
387
+ decimals?: number;
388
+ }): Promise<string>;
389
+ getBalance(address?: string): Promise<string>;
390
+ getBalanceByAddress(address: string): Promise<string>;
391
+ getAllowance(address?: string): Promise<string>;
392
+ approve(address?: string, amount?: string): Promise<any>;
393
+ approveByAddress(inputs: {
394
+ amount?: string;
395
+ address: string;
396
+ }): Promise<any>;
397
+ private _approve;
324
398
  deposit(amount: string): Promise<any>;
325
399
  private _simpleFetch;
400
+ get usdcAddress(): string;
326
401
  }
327
402
 
328
403
  interface AccountState {
@@ -378,6 +453,7 @@ declare class Account {
378
453
  }): Promise<AccountStatusEnum>;
379
454
  get stateValue(): AccountState;
380
455
  get accountId(): string | undefined;
456
+ get accountIdHashStr(): string | undefined;
381
457
  get address(): string | undefined;
382
458
  get chainId(): number | string | undefined;
383
459
  /**
@@ -411,10 +487,8 @@ declare class EtherAdapter implements WalletAdapter {
411
487
  private _address;
412
488
  constructor(options: WalletAdapterOptions);
413
489
  parseUnits(amount: string): string;
414
- fromUnits(amount: string): string;
415
- getBalance(contractId: string, userAddress: string, options: {
416
- abi: any;
417
- }): Promise<any>;
490
+ formatUnits(amount: string): string;
491
+ getBalance(userAddress: string): Promise<any>;
418
492
  deposit(from: string, to: string, amount: string): Promise<any>;
419
493
  call(address: string, method: string, params: any[], options: {
420
494
  abi: any;
@@ -428,6 +502,8 @@ declare class EtherAdapter implements WalletAdapter {
428
502
  message: any;
429
503
  types: any;
430
504
  }, signature: string): Promise<void>;
505
+ on(eventName: any, listener: any): void;
506
+ off(eventName: any, listener: any): void;
431
507
  }
432
508
 
433
- export { Account, AccountState, BaseConfigStore, BaseContract as BaseContractManager, BaseKeyStore, BaseOrderlyKeyPair, BaseSigner, ConfigKey, ConfigStore, EtherAdapter, IContract, LocalStorageStore, MemoryConfigStore, MessageFactor, MockKeyStore, OrderlyKeyPair, OrderlyKeyStore, SignedMessagePayload, Signer, SimpleDI, WalletAdapter, getDefaultSigner, getMockSigner, getWalletAdapterFunc };
509
+ export { Account, AccountState, BaseConfigStore, BaseContract as BaseContractManager, BaseKeyStore, BaseOrderlyKeyPair, BaseSigner, ConfigKey, ConfigStore, EtherAdapter, IContract, LocalStorageStore, MemoryConfigStore, MessageFactor, MockKeyStore, OrderlyKeyPair, OrderlyKeyStore, SignedMessagePayload, Signer, SimpleDI, WalletAdapter, getDefaultSigner, getMockSigner, getWalletAdapterFunc, utils };
package/dist/index.d.ts CHANGED
@@ -135,12 +135,45 @@ declare class BaseConfigStore extends MemoryConfigStore {
135
135
  protected _restore(): void;
136
136
  }
137
137
 
138
+ type SignatureDomain = {
139
+ name: string;
140
+ version: string;
141
+ chainId: number;
142
+ verifyingContract: string;
143
+ };
144
+ declare const base64url: (aStr: string) => string;
145
+ declare function parseBrokerHash(brokerId: string): string;
146
+ declare function parseAccountId(userAddress: string, brokerId: string): string;
147
+ declare function parseTokenHash(tokenSymbol: string): string;
148
+ declare function calculateStringHash(input: string): string;
149
+ declare function formatByUnits(amount: string, unit?: number | "ether" | "gwei"): string;
150
+
151
+ type utils_SignatureDomain = SignatureDomain;
152
+ declare const utils_base64url: typeof base64url;
153
+ declare const utils_calculateStringHash: typeof calculateStringHash;
154
+ declare const utils_formatByUnits: typeof formatByUnits;
155
+ declare const utils_parseAccountId: typeof parseAccountId;
156
+ declare const utils_parseBrokerHash: typeof parseBrokerHash;
157
+ declare const utils_parseTokenHash: typeof parseTokenHash;
158
+ declare namespace utils {
159
+ export {
160
+ utils_SignatureDomain as SignatureDomain,
161
+ utils_base64url as base64url,
162
+ utils_calculateStringHash as calculateStringHash,
163
+ utils_formatByUnits as formatByUnits,
164
+ utils_parseAccountId as parseAccountId,
165
+ utils_parseBrokerHash as parseBrokerHash,
166
+ utils_parseTokenHash as parseTokenHash,
167
+ };
168
+ }
169
+
138
170
  declare const getMockSigner: (secretKey?: string) => BaseSigner;
139
171
  declare const getDefaultSigner: () => BaseSigner;
140
172
 
141
173
  type OrderlyContracts = {
142
174
  usdcAddress: string;
143
175
  usdcAbi: any;
176
+ erc20Abi: any;
144
177
  vaultAddress: string;
145
178
  vaultAbi: any;
146
179
  verifyContractAddress: string;
@@ -261,6 +294,45 @@ declare class BaseContract implements IContract {
261
294
  anonymous?: undefined;
262
295
  })[];
263
296
  verifyContractAddress: string;
297
+ erc20Abi: ({
298
+ inputs: {
299
+ internalType: string;
300
+ name: string;
301
+ type: string;
302
+ }[];
303
+ stateMutability: string;
304
+ type: string;
305
+ anonymous?: undefined;
306
+ name?: undefined;
307
+ outputs?: undefined;
308
+ } | {
309
+ anonymous: boolean;
310
+ inputs: {
311
+ indexed: boolean;
312
+ internalType: string;
313
+ name: string;
314
+ type: string;
315
+ }[];
316
+ name: string;
317
+ type: string;
318
+ stateMutability?: undefined;
319
+ outputs?: undefined;
320
+ } | {
321
+ inputs: {
322
+ internalType: string;
323
+ name: string;
324
+ type: string;
325
+ }[];
326
+ name: string;
327
+ outputs: {
328
+ internalType: string;
329
+ name: string;
330
+ type: string;
331
+ }[];
332
+ stateMutability: string;
333
+ type: string;
334
+ anonymous?: undefined;
335
+ })[];
264
336
  };
265
337
  }
266
338
 
@@ -280,15 +352,15 @@ interface WalletAdapter {
280
352
  get chainId(): number;
281
353
  get addresses(): string;
282
354
  parseUnits: (amount: string) => string;
283
- fromUnits: (amount: string) => string;
355
+ formatUnits: (amount: string) => string;
284
356
  send: (method: string, params: Array<any> | Record<string, any>) => Promise<any>;
285
357
  signTypedData: (address: string, data: any) => Promise<string>;
286
- getBalance: (address: string, userAddress: string, options: {
287
- abi: any;
288
- }) => Promise<any>;
358
+ getBalance: (userAddress: string) => Promise<any>;
289
359
  call(address: string, method: string, params: any, options: {
290
360
  abi: any;
291
361
  }): Promise<any>;
362
+ on(eventName: any, listener: any): void;
363
+ off(eventName: any, listener: any): void;
292
364
  }
293
365
  type WalletAdapterOptions = {
294
366
  provider: any;
@@ -299,13 +371,6 @@ type WalletAdapterOptions = {
299
371
  };
300
372
  type getWalletAdapterFunc = (options: WalletAdapterOptions) => WalletAdapter;
301
373
 
302
- type SignatureDomain = {
303
- name: string;
304
- version: string;
305
- chainId: number;
306
- verifyingContract: string;
307
- };
308
-
309
374
  declare class Assets {
310
375
  private readonly configStore;
311
376
  private readonly contractManger;
@@ -318,11 +383,21 @@ declare class Assets {
318
383
  }): Promise<any>;
319
384
  private _generateWithdrawMessage;
320
385
  private getWithdrawalNonce;
321
- getBalance(): Promise<string>;
322
- getAllowance(): Promise<string>;
323
- approve(amount?: string): Promise<any>;
386
+ getNativeBalance(options?: {
387
+ decimals?: number;
388
+ }): Promise<string>;
389
+ getBalance(address?: string): Promise<string>;
390
+ getBalanceByAddress(address: string): Promise<string>;
391
+ getAllowance(address?: string): Promise<string>;
392
+ approve(address?: string, amount?: string): Promise<any>;
393
+ approveByAddress(inputs: {
394
+ amount?: string;
395
+ address: string;
396
+ }): Promise<any>;
397
+ private _approve;
324
398
  deposit(amount: string): Promise<any>;
325
399
  private _simpleFetch;
400
+ get usdcAddress(): string;
326
401
  }
327
402
 
328
403
  interface AccountState {
@@ -378,6 +453,7 @@ declare class Account {
378
453
  }): Promise<AccountStatusEnum>;
379
454
  get stateValue(): AccountState;
380
455
  get accountId(): string | undefined;
456
+ get accountIdHashStr(): string | undefined;
381
457
  get address(): string | undefined;
382
458
  get chainId(): number | string | undefined;
383
459
  /**
@@ -411,10 +487,8 @@ declare class EtherAdapter implements WalletAdapter {
411
487
  private _address;
412
488
  constructor(options: WalletAdapterOptions);
413
489
  parseUnits(amount: string): string;
414
- fromUnits(amount: string): string;
415
- getBalance(contractId: string, userAddress: string, options: {
416
- abi: any;
417
- }): Promise<any>;
490
+ formatUnits(amount: string): string;
491
+ getBalance(userAddress: string): Promise<any>;
418
492
  deposit(from: string, to: string, amount: string): Promise<any>;
419
493
  call(address: string, method: string, params: any[], options: {
420
494
  abi: any;
@@ -428,6 +502,8 @@ declare class EtherAdapter implements WalletAdapter {
428
502
  message: any;
429
503
  types: any;
430
504
  }, signature: string): Promise<void>;
505
+ on(eventName: any, listener: any): void;
506
+ off(eventName: any, listener: any): void;
431
507
  }
432
508
 
433
- export { Account, AccountState, BaseConfigStore, BaseContract as BaseContractManager, BaseKeyStore, BaseOrderlyKeyPair, BaseSigner, ConfigKey, ConfigStore, EtherAdapter, IContract, LocalStorageStore, MemoryConfigStore, MessageFactor, MockKeyStore, OrderlyKeyPair, OrderlyKeyStore, SignedMessagePayload, Signer, SimpleDI, WalletAdapter, getDefaultSigner, getMockSigner, getWalletAdapterFunc };
509
+ export { Account, AccountState, BaseConfigStore, BaseContract as BaseContractManager, BaseKeyStore, BaseOrderlyKeyPair, BaseSigner, ConfigKey, ConfigStore, EtherAdapter, IContract, LocalStorageStore, MemoryConfigStore, MessageFactor, MockKeyStore, OrderlyKeyPair, OrderlyKeyStore, SignedMessagePayload, Signer, SimpleDI, WalletAdapter, getDefaultSigner, getMockSigner, getWalletAdapterFunc, utils };