@orderly.network/core 0.0.58 → 0.0.60
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 +30 -15
- package/dist/index.d.ts +30 -15
- 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 +4 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import EventEmitter from 'eventemitter3';
|
|
2
2
|
export { default as EventEmitter } from 'eventemitter3';
|
|
3
|
+
import { TransactionResponse, ethers } from 'ethers';
|
|
3
4
|
import { AccountStatusEnum } from '@orderly.network/types';
|
|
4
5
|
|
|
5
6
|
interface OrderlyKeyPair {
|
|
@@ -90,7 +91,7 @@ type SignedMessagePayload = {
|
|
|
90
91
|
* method: "GET",
|
|
91
92
|
* data: {
|
|
92
93
|
* address: "0x1234567890",
|
|
93
|
-
* brokerId: "
|
|
94
|
+
* brokerId: "woofi_pro",
|
|
94
95
|
* },
|
|
95
96
|
* });
|
|
96
97
|
* ```
|
|
@@ -115,6 +116,7 @@ declare class BaseSigner implements Signer {
|
|
|
115
116
|
type ConfigKey = "apiBaseUrl" | "klineDataUrl";
|
|
116
117
|
interface ConfigStore {
|
|
117
118
|
get<T>(key: string): T;
|
|
119
|
+
getOr<T>(key: string, defaultValue: T): T;
|
|
118
120
|
set<T>(key: string, value: T): void;
|
|
119
121
|
clear(): void;
|
|
120
122
|
}
|
|
@@ -123,6 +125,7 @@ declare class MemoryConfigStore implements ConfigStore {
|
|
|
123
125
|
constructor();
|
|
124
126
|
protected _restore(): void;
|
|
125
127
|
get<T>(key: string): T;
|
|
128
|
+
getOr<T>(key: string, defaultValue: T): T;
|
|
126
129
|
set<T>(key: string, value: T): void;
|
|
127
130
|
clear(): void;
|
|
128
131
|
}
|
|
@@ -348,12 +351,20 @@ declare class SimpleDI {
|
|
|
348
351
|
private constructor();
|
|
349
352
|
}
|
|
350
353
|
|
|
351
|
-
interface
|
|
354
|
+
interface IWalletAdapter {
|
|
352
355
|
get chainId(): number;
|
|
353
356
|
get addresses(): string;
|
|
354
357
|
parseUnits: (amount: string) => string;
|
|
355
358
|
formatUnits: (amount: string) => string;
|
|
356
359
|
send: (method: string, params: Array<any> | Record<string, any>) => Promise<any>;
|
|
360
|
+
sendTransaction(contractAddress: string, method: string, payload: {
|
|
361
|
+
from: string;
|
|
362
|
+
to?: string;
|
|
363
|
+
data: any[];
|
|
364
|
+
value?: bigint;
|
|
365
|
+
}, options: {
|
|
366
|
+
abi: any;
|
|
367
|
+
}): Promise<TransactionResponse>;
|
|
357
368
|
signTypedData: (address: string, data: any) => Promise<string>;
|
|
358
369
|
getBalance: (userAddress: string) => Promise<any>;
|
|
359
370
|
call(address: string, method: string, params: any, options: {
|
|
@@ -369,7 +380,7 @@ type WalletAdapterOptions = {
|
|
|
369
380
|
id: string;
|
|
370
381
|
};
|
|
371
382
|
};
|
|
372
|
-
type getWalletAdapterFunc = (options: WalletAdapterOptions) =>
|
|
383
|
+
type getWalletAdapterFunc = (options: WalletAdapterOptions) => IWalletAdapter;
|
|
373
384
|
|
|
374
385
|
declare class Assets {
|
|
375
386
|
private readonly configStore;
|
|
@@ -388,8 +399,8 @@ declare class Assets {
|
|
|
388
399
|
}): Promise<string>;
|
|
389
400
|
getBalance(address?: string): Promise<string>;
|
|
390
401
|
getBalanceByAddress(address: string): Promise<string>;
|
|
391
|
-
getAllowance(address?: string): Promise<string>;
|
|
392
|
-
approve(address?: string, amount?: string): Promise<any>;
|
|
402
|
+
getAllowance(address?: string, vaultAddress?: string): Promise<string>;
|
|
403
|
+
approve(address?: string, amount?: string, vaultAddress?: string): Promise<any>;
|
|
393
404
|
approveByAddress(inputs: {
|
|
394
405
|
amount?: string;
|
|
395
406
|
address: string;
|
|
@@ -413,7 +424,7 @@ interface AccountState {
|
|
|
413
424
|
leverage: number;
|
|
414
425
|
}
|
|
415
426
|
/**
|
|
416
|
-
*
|
|
427
|
+
* Account
|
|
417
428
|
* @example
|
|
418
429
|
* ```ts
|
|
419
430
|
* const account = new Account();
|
|
@@ -430,13 +441,8 @@ declare class Account {
|
|
|
430
441
|
private _ee;
|
|
431
442
|
assetsManager: Assets;
|
|
432
443
|
private _state;
|
|
433
|
-
walletClient?:
|
|
444
|
+
walletClient?: IWalletAdapter;
|
|
434
445
|
constructor(configStore: ConfigStore, keyStore: OrderlyKeyStore, contractManger: IContract, getWalletAdapter: getWalletAdapterFunc);
|
|
435
|
-
/**
|
|
436
|
-
* 登录
|
|
437
|
-
* @param address 钱包地址
|
|
438
|
-
*/
|
|
439
|
-
login(address: string): void;
|
|
440
446
|
logout(): void;
|
|
441
447
|
/**
|
|
442
448
|
* 连接钱包先用第三方的React版本,不用自己实现
|
|
@@ -471,7 +477,7 @@ declare class Account {
|
|
|
471
477
|
disconnect(): Promise<void>;
|
|
472
478
|
private _checkOrderlyKeyState;
|
|
473
479
|
get signer(): Signer;
|
|
474
|
-
get wallet():
|
|
480
|
+
get wallet(): IWalletAdapter | undefined;
|
|
475
481
|
private _getRegisterationNonce;
|
|
476
482
|
private _getSettleNonce;
|
|
477
483
|
private _simpleFetch;
|
|
@@ -481,7 +487,7 @@ declare class Account {
|
|
|
481
487
|
get off(): <T extends string | symbol>(event: T, fn?: ((...args: any[]) => void) | undefined, context?: any, once?: boolean | undefined) => EventEmitter<string | symbol, any>;
|
|
482
488
|
}
|
|
483
489
|
|
|
484
|
-
declare class EtherAdapter implements
|
|
490
|
+
declare class EtherAdapter implements IWalletAdapter {
|
|
485
491
|
private provider?;
|
|
486
492
|
private _chainId;
|
|
487
493
|
private _address;
|
|
@@ -496,6 +502,15 @@ declare class EtherAdapter implements WalletAdapter {
|
|
|
496
502
|
get chainId(): number;
|
|
497
503
|
get addresses(): string;
|
|
498
504
|
send(method: string, params: Array<any> | Record<string, any>): Promise<any>;
|
|
505
|
+
sendTransaction(contractAddress: string, method: string, payload: {
|
|
506
|
+
from: string;
|
|
507
|
+
to?: string;
|
|
508
|
+
data: any[];
|
|
509
|
+
value?: bigint;
|
|
510
|
+
}, options: {
|
|
511
|
+
abi: any;
|
|
512
|
+
}): Promise<ethers.TransactionResponse>;
|
|
513
|
+
private estimateGas;
|
|
499
514
|
signTypedData(address: string, data: any): Promise<any>;
|
|
500
515
|
verify(data: {
|
|
501
516
|
domain: any;
|
|
@@ -506,4 +521,4 @@ declare class EtherAdapter implements WalletAdapter {
|
|
|
506
521
|
off(eventName: any, listener: any): void;
|
|
507
522
|
}
|
|
508
523
|
|
|
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 };
|
|
524
|
+
export { Account, AccountState, BaseConfigStore, BaseContract as BaseContractManager, BaseKeyStore, BaseOrderlyKeyPair, BaseSigner, ConfigKey, ConfigStore, EtherAdapter, IContract, LocalStorageStore, MemoryConfigStore, MessageFactor, MockKeyStore, OrderlyKeyPair, OrderlyKeyStore, SignedMessagePayload, Signer, SimpleDI, IWalletAdapter as WalletAdapter, getDefaultSigner, getMockSigner, getWalletAdapterFunc, utils };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import EventEmitter from 'eventemitter3';
|
|
2
2
|
export { default as EventEmitter } from 'eventemitter3';
|
|
3
|
+
import { TransactionResponse, ethers } from 'ethers';
|
|
3
4
|
import { AccountStatusEnum } from '@orderly.network/types';
|
|
4
5
|
|
|
5
6
|
interface OrderlyKeyPair {
|
|
@@ -90,7 +91,7 @@ type SignedMessagePayload = {
|
|
|
90
91
|
* method: "GET",
|
|
91
92
|
* data: {
|
|
92
93
|
* address: "0x1234567890",
|
|
93
|
-
* brokerId: "
|
|
94
|
+
* brokerId: "woofi_pro",
|
|
94
95
|
* },
|
|
95
96
|
* });
|
|
96
97
|
* ```
|
|
@@ -115,6 +116,7 @@ declare class BaseSigner implements Signer {
|
|
|
115
116
|
type ConfigKey = "apiBaseUrl" | "klineDataUrl";
|
|
116
117
|
interface ConfigStore {
|
|
117
118
|
get<T>(key: string): T;
|
|
119
|
+
getOr<T>(key: string, defaultValue: T): T;
|
|
118
120
|
set<T>(key: string, value: T): void;
|
|
119
121
|
clear(): void;
|
|
120
122
|
}
|
|
@@ -123,6 +125,7 @@ declare class MemoryConfigStore implements ConfigStore {
|
|
|
123
125
|
constructor();
|
|
124
126
|
protected _restore(): void;
|
|
125
127
|
get<T>(key: string): T;
|
|
128
|
+
getOr<T>(key: string, defaultValue: T): T;
|
|
126
129
|
set<T>(key: string, value: T): void;
|
|
127
130
|
clear(): void;
|
|
128
131
|
}
|
|
@@ -348,12 +351,20 @@ declare class SimpleDI {
|
|
|
348
351
|
private constructor();
|
|
349
352
|
}
|
|
350
353
|
|
|
351
|
-
interface
|
|
354
|
+
interface IWalletAdapter {
|
|
352
355
|
get chainId(): number;
|
|
353
356
|
get addresses(): string;
|
|
354
357
|
parseUnits: (amount: string) => string;
|
|
355
358
|
formatUnits: (amount: string) => string;
|
|
356
359
|
send: (method: string, params: Array<any> | Record<string, any>) => Promise<any>;
|
|
360
|
+
sendTransaction(contractAddress: string, method: string, payload: {
|
|
361
|
+
from: string;
|
|
362
|
+
to?: string;
|
|
363
|
+
data: any[];
|
|
364
|
+
value?: bigint;
|
|
365
|
+
}, options: {
|
|
366
|
+
abi: any;
|
|
367
|
+
}): Promise<TransactionResponse>;
|
|
357
368
|
signTypedData: (address: string, data: any) => Promise<string>;
|
|
358
369
|
getBalance: (userAddress: string) => Promise<any>;
|
|
359
370
|
call(address: string, method: string, params: any, options: {
|
|
@@ -369,7 +380,7 @@ type WalletAdapterOptions = {
|
|
|
369
380
|
id: string;
|
|
370
381
|
};
|
|
371
382
|
};
|
|
372
|
-
type getWalletAdapterFunc = (options: WalletAdapterOptions) =>
|
|
383
|
+
type getWalletAdapterFunc = (options: WalletAdapterOptions) => IWalletAdapter;
|
|
373
384
|
|
|
374
385
|
declare class Assets {
|
|
375
386
|
private readonly configStore;
|
|
@@ -388,8 +399,8 @@ declare class Assets {
|
|
|
388
399
|
}): Promise<string>;
|
|
389
400
|
getBalance(address?: string): Promise<string>;
|
|
390
401
|
getBalanceByAddress(address: string): Promise<string>;
|
|
391
|
-
getAllowance(address?: string): Promise<string>;
|
|
392
|
-
approve(address?: string, amount?: string): Promise<any>;
|
|
402
|
+
getAllowance(address?: string, vaultAddress?: string): Promise<string>;
|
|
403
|
+
approve(address?: string, amount?: string, vaultAddress?: string): Promise<any>;
|
|
393
404
|
approveByAddress(inputs: {
|
|
394
405
|
amount?: string;
|
|
395
406
|
address: string;
|
|
@@ -413,7 +424,7 @@ interface AccountState {
|
|
|
413
424
|
leverage: number;
|
|
414
425
|
}
|
|
415
426
|
/**
|
|
416
|
-
*
|
|
427
|
+
* Account
|
|
417
428
|
* @example
|
|
418
429
|
* ```ts
|
|
419
430
|
* const account = new Account();
|
|
@@ -430,13 +441,8 @@ declare class Account {
|
|
|
430
441
|
private _ee;
|
|
431
442
|
assetsManager: Assets;
|
|
432
443
|
private _state;
|
|
433
|
-
walletClient?:
|
|
444
|
+
walletClient?: IWalletAdapter;
|
|
434
445
|
constructor(configStore: ConfigStore, keyStore: OrderlyKeyStore, contractManger: IContract, getWalletAdapter: getWalletAdapterFunc);
|
|
435
|
-
/**
|
|
436
|
-
* 登录
|
|
437
|
-
* @param address 钱包地址
|
|
438
|
-
*/
|
|
439
|
-
login(address: string): void;
|
|
440
446
|
logout(): void;
|
|
441
447
|
/**
|
|
442
448
|
* 连接钱包先用第三方的React版本,不用自己实现
|
|
@@ -471,7 +477,7 @@ declare class Account {
|
|
|
471
477
|
disconnect(): Promise<void>;
|
|
472
478
|
private _checkOrderlyKeyState;
|
|
473
479
|
get signer(): Signer;
|
|
474
|
-
get wallet():
|
|
480
|
+
get wallet(): IWalletAdapter | undefined;
|
|
475
481
|
private _getRegisterationNonce;
|
|
476
482
|
private _getSettleNonce;
|
|
477
483
|
private _simpleFetch;
|
|
@@ -481,7 +487,7 @@ declare class Account {
|
|
|
481
487
|
get off(): <T extends string | symbol>(event: T, fn?: ((...args: any[]) => void) | undefined, context?: any, once?: boolean | undefined) => EventEmitter<string | symbol, any>;
|
|
482
488
|
}
|
|
483
489
|
|
|
484
|
-
declare class EtherAdapter implements
|
|
490
|
+
declare class EtherAdapter implements IWalletAdapter {
|
|
485
491
|
private provider?;
|
|
486
492
|
private _chainId;
|
|
487
493
|
private _address;
|
|
@@ -496,6 +502,15 @@ declare class EtherAdapter implements WalletAdapter {
|
|
|
496
502
|
get chainId(): number;
|
|
497
503
|
get addresses(): string;
|
|
498
504
|
send(method: string, params: Array<any> | Record<string, any>): Promise<any>;
|
|
505
|
+
sendTransaction(contractAddress: string, method: string, payload: {
|
|
506
|
+
from: string;
|
|
507
|
+
to?: string;
|
|
508
|
+
data: any[];
|
|
509
|
+
value?: bigint;
|
|
510
|
+
}, options: {
|
|
511
|
+
abi: any;
|
|
512
|
+
}): Promise<ethers.TransactionResponse>;
|
|
513
|
+
private estimateGas;
|
|
499
514
|
signTypedData(address: string, data: any): Promise<any>;
|
|
500
515
|
verify(data: {
|
|
501
516
|
domain: any;
|
|
@@ -506,4 +521,4 @@ declare class EtherAdapter implements WalletAdapter {
|
|
|
506
521
|
off(eventName: any, listener: any): void;
|
|
507
522
|
}
|
|
508
523
|
|
|
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 };
|
|
524
|
+
export { Account, AccountState, BaseConfigStore, BaseContract as BaseContractManager, BaseKeyStore, BaseOrderlyKeyPair, BaseSigner, ConfigKey, ConfigStore, EtherAdapter, IContract, LocalStorageStore, MemoryConfigStore, MessageFactor, MockKeyStore, OrderlyKeyPair, OrderlyKeyStore, SignedMessagePayload, Signer, SimpleDI, IWalletAdapter as WalletAdapter, getDefaultSigner, getMockSigner, getWalletAdapterFunc, utils };
|