@orderly.network/core 1.5.12 → 2.0.0-alpha.0
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 +229 -86
- package/dist/index.d.ts +229 -86
- 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 +20 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import EventEmitter from 'eventemitter3';
|
|
2
2
|
export { default as EventEmitter } from 'eventemitter3';
|
|
3
|
-
import { definedTypes, API, AccountStatusEnum } from '@orderly.network/types';
|
|
3
|
+
import { definedTypes, API, ChainNamespace, AccountStatusEnum } from '@orderly.network/types';
|
|
4
|
+
import { BigNumberish } from 'ethers/src.ts/utils';
|
|
4
5
|
import { parseUnits, TransactionResponse, ethers } from 'ethers';
|
|
5
6
|
|
|
6
7
|
interface OrderlyKeyPair {
|
|
@@ -24,6 +25,7 @@ interface OrderlyKeyStore {
|
|
|
24
25
|
setAccountId: (address: string, accountId: string) => void;
|
|
25
26
|
getAddress: () => string | undefined | null;
|
|
26
27
|
setAddress: (address: string) => void;
|
|
28
|
+
removeAddress: () => void;
|
|
27
29
|
generateKey: () => OrderlyKeyPair;
|
|
28
30
|
cleanKey: (address: string, key: string) => void;
|
|
29
31
|
cleanAllKey: (address: string) => void;
|
|
@@ -37,6 +39,7 @@ declare abstract class BaseKeyStore implements OrderlyKeyStore {
|
|
|
37
39
|
abstract setAccountId(address: string, accountId: string): void;
|
|
38
40
|
abstract getAddress(): string | undefined | null;
|
|
39
41
|
abstract setAddress(address: string): void;
|
|
42
|
+
abstract removeAddress(): void;
|
|
40
43
|
abstract generateKey(): OrderlyKeyPair;
|
|
41
44
|
abstract setKey(orderlyKey: string, secretKey: OrderlyKeyPair): void;
|
|
42
45
|
abstract cleanAllKey(address: string): void;
|
|
@@ -49,6 +52,7 @@ declare class LocalStorageStore extends BaseKeyStore {
|
|
|
49
52
|
setAccountId(address: string, accountId: string): void;
|
|
50
53
|
getAddress(): string | undefined | null;
|
|
51
54
|
setAddress(address: string): void;
|
|
55
|
+
removeAddress(): void;
|
|
52
56
|
generateKey(): OrderlyKeyPair;
|
|
53
57
|
setKey(address: string, orderlyKey: OrderlyKeyPair): void;
|
|
54
58
|
cleanAllKey(address: string): void;
|
|
@@ -65,6 +69,7 @@ declare class MockKeyStore implements OrderlyKeyStore {
|
|
|
65
69
|
setAccountId(accountId: string): void;
|
|
66
70
|
getAddress(): string;
|
|
67
71
|
setAddress(address: string): void;
|
|
72
|
+
removeAddress(): void;
|
|
68
73
|
setKey(orderlyKey: string, secretKey: OrderlyKeyPair): void;
|
|
69
74
|
cleanAllKey(): void;
|
|
70
75
|
cleanKey(key: string): void;
|
|
@@ -124,7 +129,7 @@ declare function parseBrokerHash(brokerId: string): string;
|
|
|
124
129
|
declare function parseAccountId(userAddress: string, brokerId: string): string;
|
|
125
130
|
declare function parseTokenHash(tokenSymbol: string): string;
|
|
126
131
|
declare function calculateStringHash(input: string): string;
|
|
127
|
-
declare function formatByUnits(amount:
|
|
132
|
+
declare function formatByUnits(amount: BigNumberish, unit?: number | "ether" | "gwei"): string;
|
|
128
133
|
declare function isHex(value: string): boolean;
|
|
129
134
|
declare function isHexString(value: string): boolean;
|
|
130
135
|
declare const getGlobalObject: () => typeof globalThis;
|
|
@@ -143,20 +148,7 @@ declare const utils_parseBrokerHash: typeof parseBrokerHash;
|
|
|
143
148
|
declare const utils_parseTokenHash: typeof parseTokenHash;
|
|
144
149
|
declare const utils_parseUnits: typeof parseUnits;
|
|
145
150
|
declare namespace utils {
|
|
146
|
-
export {
|
|
147
|
-
utils_SignatureDomain as SignatureDomain,
|
|
148
|
-
utils_base64url as base64url,
|
|
149
|
-
utils_calculateStringHash as calculateStringHash,
|
|
150
|
-
utils_formatByUnits as formatByUnits,
|
|
151
|
-
utils_getGlobalObject as getGlobalObject,
|
|
152
|
-
utils_getTimestamp as getTimestamp,
|
|
153
|
-
utils_isHex as isHex,
|
|
154
|
-
utils_isHexString as isHexString,
|
|
155
|
-
utils_parseAccountId as parseAccountId,
|
|
156
|
-
utils_parseBrokerHash as parseBrokerHash,
|
|
157
|
-
utils_parseTokenHash as parseTokenHash,
|
|
158
|
-
utils_parseUnits as parseUnits,
|
|
159
|
-
};
|
|
151
|
+
export { type utils_SignatureDomain as SignatureDomain, utils_base64url as base64url, utils_calculateStringHash as calculateStringHash, utils_formatByUnits as formatByUnits, utils_getGlobalObject as getGlobalObject, utils_getTimestamp as getTimestamp, utils_isHex as isHex, utils_isHexString as isHexString, utils_parseAccountId as parseAccountId, utils_parseBrokerHash as parseBrokerHash, utils_parseTokenHash as parseTokenHash, utils_parseUnits as parseUnits };
|
|
160
152
|
}
|
|
161
153
|
|
|
162
154
|
declare const getMockSigner: (secretKey?: string) => BaseSigner;
|
|
@@ -227,7 +219,10 @@ declare function generateAddOrderlyKeyMessage(inputs: {
|
|
|
227
219
|
primaryType: keyof typeof definedTypes;
|
|
228
220
|
expiration?: number;
|
|
229
221
|
timestamp?: number;
|
|
222
|
+
scope?: string;
|
|
223
|
+
tag?: string;
|
|
230
224
|
}): readonly [{
|
|
225
|
+
tag?: string | undefined;
|
|
231
226
|
brokerId: string;
|
|
232
227
|
orderlyKey: string;
|
|
233
228
|
scope: string;
|
|
@@ -242,6 +237,7 @@ declare function generateAddOrderlyKeyMessage(inputs: {
|
|
|
242
237
|
verifyingContract: string;
|
|
243
238
|
};
|
|
244
239
|
message: {
|
|
240
|
+
tag?: string | undefined;
|
|
245
241
|
brokerId: string;
|
|
246
242
|
orderlyKey: string;
|
|
247
243
|
scope: string;
|
|
@@ -249,7 +245,7 @@ declare function generateAddOrderlyKeyMessage(inputs: {
|
|
|
249
245
|
timestamp: number;
|
|
250
246
|
expiration: number;
|
|
251
247
|
};
|
|
252
|
-
primaryType: "
|
|
248
|
+
primaryType: "EIP712Domain" | "Registration" | "Withdraw" | "AddOrderlyKey" | "SettlePnl";
|
|
253
249
|
types: {
|
|
254
250
|
[x: string]: readonly [{
|
|
255
251
|
readonly name: "name";
|
|
@@ -412,6 +408,8 @@ type OrderlyContracts = {
|
|
|
412
408
|
vaultAddress: string;
|
|
413
409
|
vaultAbi: any;
|
|
414
410
|
verifyContractAddress: string;
|
|
411
|
+
solanaUSDCAddress: string;
|
|
412
|
+
solanaVaultAddress: string;
|
|
415
413
|
};
|
|
416
414
|
interface IContract {
|
|
417
415
|
getContractInfoByEnv(): OrderlyContracts;
|
|
@@ -462,6 +460,8 @@ declare class BaseContract implements IContract {
|
|
|
462
460
|
anonymous?: undefined;
|
|
463
461
|
})[];
|
|
464
462
|
vaultAddress: string;
|
|
463
|
+
solanaVaultAddress: string;
|
|
464
|
+
solanaUSDCAddress: string;
|
|
465
465
|
vaultAbi: ({
|
|
466
466
|
inputs: never[];
|
|
467
467
|
stateMutability: string;
|
|
@@ -575,46 +575,6 @@ declare class SimpleDI {
|
|
|
575
575
|
private constructor();
|
|
576
576
|
}
|
|
577
577
|
|
|
578
|
-
interface IWalletAdapter {
|
|
579
|
-
get chainId(): number;
|
|
580
|
-
get addresses(): string;
|
|
581
|
-
/**
|
|
582
|
-
* Set the chain id
|
|
583
|
-
*/
|
|
584
|
-
set chainId(chainId: number);
|
|
585
|
-
parseUnits: (amount: string) => string;
|
|
586
|
-
formatUnits: (amount: string) => string;
|
|
587
|
-
send: (method: string, params: Array<any> | Record<string, any>) => Promise<any>;
|
|
588
|
-
sendTransaction(contractAddress: string, method: string, payload: {
|
|
589
|
-
from: string;
|
|
590
|
-
to?: string;
|
|
591
|
-
data: any[];
|
|
592
|
-
value?: bigint;
|
|
593
|
-
}, options: {
|
|
594
|
-
abi: any;
|
|
595
|
-
}): Promise<TransactionResponse>;
|
|
596
|
-
getTransactionRecipect: (txHash: string) => Promise<any>;
|
|
597
|
-
signTypedData: (address: string, data: any) => Promise<string>;
|
|
598
|
-
pollTransactionReceiptWithBackoff: (txHash: string, baseInterval?: number, maxInterval?: number, maxRetries?: number) => Promise<any>;
|
|
599
|
-
getBalance: (userAddress: string) => Promise<any>;
|
|
600
|
-
call(address: string, method: string, params: any, options: {
|
|
601
|
-
abi: any;
|
|
602
|
-
}): Promise<any>;
|
|
603
|
-
callOnChain(chain: API.NetworkInfos, address: string, method: string, params: any, options: {
|
|
604
|
-
abi: any;
|
|
605
|
-
}): Promise<any>;
|
|
606
|
-
on(eventName: any, listener: any): void;
|
|
607
|
-
off(eventName: any, listener: any): void;
|
|
608
|
-
}
|
|
609
|
-
type WalletAdapterOptions = {
|
|
610
|
-
provider: any;
|
|
611
|
-
address: string;
|
|
612
|
-
chain: {
|
|
613
|
-
id: number;
|
|
614
|
-
};
|
|
615
|
-
};
|
|
616
|
-
type getWalletAdapterFunc = (options: WalletAdapterOptions) => IWalletAdapter;
|
|
617
|
-
|
|
618
578
|
declare class Assets {
|
|
619
579
|
private readonly configStore;
|
|
620
580
|
private readonly contractManger;
|
|
@@ -626,7 +586,6 @@ declare class Assets {
|
|
|
626
586
|
amount: string | number;
|
|
627
587
|
allowCrossChainWithdraw: boolean;
|
|
628
588
|
}): Promise<any>;
|
|
629
|
-
private _generateWithdrawMessage;
|
|
630
589
|
private getWithdrawalNonce;
|
|
631
590
|
getNativeBalance(options?: {
|
|
632
591
|
decimals?: number;
|
|
@@ -634,26 +593,119 @@ declare class Assets {
|
|
|
634
593
|
getBalance(address?: string, options?: {
|
|
635
594
|
decimals?: number;
|
|
636
595
|
}): Promise<string>;
|
|
637
|
-
getBalanceByAddress(address: string
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
596
|
+
getBalanceByAddress(address: string, options?: {
|
|
597
|
+
decimals?: number;
|
|
598
|
+
}): Promise<string>;
|
|
599
|
+
getAllowance(inputs?: string | {
|
|
600
|
+
address?: string;
|
|
601
|
+
vaultAddress?: string;
|
|
602
|
+
decimals?: number;
|
|
603
|
+
}, _vaultAddress?: string): Promise<string>;
|
|
604
|
+
approve(inputs?: string | {
|
|
605
|
+
address?: string;
|
|
641
606
|
amount?: string;
|
|
607
|
+
vaultAddress?: string;
|
|
608
|
+
decimals?: number;
|
|
609
|
+
}, _amount?: string, _vaultAddress?: string): Promise<any>;
|
|
610
|
+
approveByAddress(inputs: {
|
|
642
611
|
address: string;
|
|
612
|
+
amount?: string;
|
|
613
|
+
decimals?: number;
|
|
643
614
|
}): Promise<any>;
|
|
644
|
-
private _approve;
|
|
645
|
-
getDepositData(amount: string): {
|
|
646
|
-
accountId: string | undefined;
|
|
647
|
-
brokerHash: string;
|
|
648
|
-
tokenHash: string;
|
|
649
|
-
tokenAmount: string;
|
|
650
|
-
};
|
|
651
615
|
getDepositFee(amount: string, chain: API.NetworkInfos): Promise<any>;
|
|
652
|
-
deposit(amount: string, fee?: bigint): Promise<
|
|
616
|
+
deposit(amount: string, fee?: bigint): Promise<any>;
|
|
653
617
|
private _simpleFetch;
|
|
654
618
|
get usdcAddress(): string;
|
|
655
619
|
}
|
|
656
620
|
|
|
621
|
+
type ChainType = "EVM" | "SOL";
|
|
622
|
+
interface Message {
|
|
623
|
+
message: {
|
|
624
|
+
chainType: ChainType;
|
|
625
|
+
[key: string]: any;
|
|
626
|
+
};
|
|
627
|
+
signatured: string;
|
|
628
|
+
}
|
|
629
|
+
type RegisterAccountInputs = {
|
|
630
|
+
brokerId: string;
|
|
631
|
+
registrationNonce: number;
|
|
632
|
+
timestamp: number;
|
|
633
|
+
};
|
|
634
|
+
type WithdrawInputs = {
|
|
635
|
+
brokerId: string;
|
|
636
|
+
receiver: string;
|
|
637
|
+
token: string;
|
|
638
|
+
amount: string;
|
|
639
|
+
nonce: number;
|
|
640
|
+
timestamp: number;
|
|
641
|
+
verifyContract?: string;
|
|
642
|
+
};
|
|
643
|
+
type SettleInputs = {
|
|
644
|
+
brokerId: string;
|
|
645
|
+
settlePnlNonce: string;
|
|
646
|
+
timestamp: number;
|
|
647
|
+
verifyContract?: string;
|
|
648
|
+
};
|
|
649
|
+
type AddOrderlyKeyInputs = {
|
|
650
|
+
publicKey: string;
|
|
651
|
+
brokerId: string;
|
|
652
|
+
expiration: number;
|
|
653
|
+
timestamp: number;
|
|
654
|
+
scope?: string;
|
|
655
|
+
tag?: string;
|
|
656
|
+
};
|
|
657
|
+
interface WalletAdapter<Config = any> {
|
|
658
|
+
chainNamespace: ChainNamespace;
|
|
659
|
+
get chainId(): number;
|
|
660
|
+
get address(): string;
|
|
661
|
+
set chainId(chainId: number);
|
|
662
|
+
set address(addresses: string);
|
|
663
|
+
active(config: Config): void;
|
|
664
|
+
update(config: Config): void;
|
|
665
|
+
deactivate(): void;
|
|
666
|
+
generateSecretKey(): string;
|
|
667
|
+
/**
|
|
668
|
+
* business methods
|
|
669
|
+
*/
|
|
670
|
+
generateRegisterAccountMessage(inputs: RegisterAccountInputs): Promise<Message>;
|
|
671
|
+
generateWithdrawMessage(inputs: WithdrawInputs): Promise<Message & {
|
|
672
|
+
domain: SignatureDomain;
|
|
673
|
+
}>;
|
|
674
|
+
generateSettleMessage(inputs: SettleInputs): Promise<Message & {
|
|
675
|
+
domain: SignatureDomain;
|
|
676
|
+
}>;
|
|
677
|
+
generateAddOrderlyKeyMessage(inputs: AddOrderlyKeyInputs): Promise<Message>;
|
|
678
|
+
/**
|
|
679
|
+
* ===== general methods =====
|
|
680
|
+
*/
|
|
681
|
+
/**
|
|
682
|
+
* call contract
|
|
683
|
+
*/
|
|
684
|
+
call(address: string, method: string, params: any[], options?: {
|
|
685
|
+
abi: any;
|
|
686
|
+
}): Promise<any>;
|
|
687
|
+
/**
|
|
688
|
+
* send transaction
|
|
689
|
+
*/
|
|
690
|
+
sendTransaction(contractAddress: string, method: string, payload: {
|
|
691
|
+
from: string;
|
|
692
|
+
to?: string;
|
|
693
|
+
data: any[];
|
|
694
|
+
value?: bigint;
|
|
695
|
+
}, options: {
|
|
696
|
+
abi: any;
|
|
697
|
+
}): Promise<any>;
|
|
698
|
+
callOnChain(chain: API.NetworkInfos, address: string, method: string, params: any[], options: {
|
|
699
|
+
abi: any;
|
|
700
|
+
}): Promise<any>;
|
|
701
|
+
getBalance(): Promise<bigint>;
|
|
702
|
+
pollTransactionReceiptWithBackoff(txHash: string, baseInterval?: number, maxInterval?: number, maxRetries?: number): Promise<any>;
|
|
703
|
+
parseUnits: (amount: string, decimals?: number) => string;
|
|
704
|
+
formatUnits: (amount: BigNumberish, decimals?: number) => string;
|
|
705
|
+
on(eventName: string, listener: (...args: any[]) => void): void;
|
|
706
|
+
off(eventName: string, listener: (...args: any[]) => void): void;
|
|
707
|
+
}
|
|
708
|
+
|
|
657
709
|
interface AccountState {
|
|
658
710
|
status: AccountStatusEnum;
|
|
659
711
|
/**
|
|
@@ -663,10 +715,12 @@ interface AccountState {
|
|
|
663
715
|
accountId?: string;
|
|
664
716
|
userId?: string;
|
|
665
717
|
address?: string;
|
|
718
|
+
chainNamespace?: ChainNamespace;
|
|
666
719
|
/** new account */
|
|
667
720
|
isNew?: boolean;
|
|
668
721
|
connectWallet?: {
|
|
669
722
|
name: string;
|
|
723
|
+
chainId: number;
|
|
670
724
|
};
|
|
671
725
|
}
|
|
672
726
|
/**
|
|
@@ -680,16 +734,14 @@ interface AccountState {
|
|
|
680
734
|
declare class Account {
|
|
681
735
|
private readonly configStore;
|
|
682
736
|
readonly keyStore: OrderlyKeyStore;
|
|
683
|
-
private readonly getWalletAdapter;
|
|
684
737
|
static instanceName: string;
|
|
685
738
|
private _singer?;
|
|
686
739
|
private _ee;
|
|
740
|
+
private walletAdapterManager;
|
|
687
741
|
assetsManager: Assets;
|
|
688
742
|
private _state;
|
|
689
743
|
private readonly contractManger;
|
|
690
|
-
|
|
691
|
-
constructor(configStore: ConfigStore, keyStore: OrderlyKeyStore, getWalletAdapter: getWalletAdapterFunc, // private readonly walletAdapterClass: { new (options: any): WalletAdapter } // private walletClient?: WalletClient
|
|
692
|
-
options?: Partial<{
|
|
744
|
+
constructor(configStore: ConfigStore, keyStore: OrderlyKeyStore, walletAdapters: WalletAdapter[], options?: Partial<{
|
|
693
745
|
/**
|
|
694
746
|
* smart contract configuration class
|
|
695
747
|
* provide contract address and abi
|
|
@@ -697,12 +749,13 @@ declare class Account {
|
|
|
697
749
|
contracts: IContract;
|
|
698
750
|
}>);
|
|
699
751
|
logout(): void;
|
|
700
|
-
setAddress(address: string, wallet
|
|
752
|
+
setAddress(address: string, wallet: {
|
|
701
753
|
provider: any;
|
|
702
754
|
chain: {
|
|
703
755
|
id: string | number;
|
|
756
|
+
namespace: ChainNamespace;
|
|
704
757
|
};
|
|
705
|
-
wallet
|
|
758
|
+
wallet: {
|
|
706
759
|
name: string;
|
|
707
760
|
};
|
|
708
761
|
[key: string]: any;
|
|
@@ -712,28 +765,35 @@ declare class Account {
|
|
|
712
765
|
get accountIdHashStr(): string | undefined;
|
|
713
766
|
get address(): string | undefined;
|
|
714
767
|
get chainId(): number | string | undefined;
|
|
715
|
-
/**
|
|
716
|
-
* set user positions count
|
|
717
|
-
*/
|
|
718
768
|
private _bindEvents;
|
|
719
769
|
private _checkAccount;
|
|
720
770
|
private _checkAccountExist;
|
|
721
771
|
createAccount(): Promise<any>;
|
|
722
|
-
|
|
723
|
-
|
|
772
|
+
createApiKey(expiration?: number, options?: {
|
|
773
|
+
tag?: string;
|
|
774
|
+
scope?: string;
|
|
775
|
+
}): Promise<{
|
|
776
|
+
key: string;
|
|
777
|
+
secretKey: string;
|
|
778
|
+
}>;
|
|
779
|
+
createOrderlyKey(expiration?: number, options?: {
|
|
780
|
+
tag?: string;
|
|
781
|
+
scope?: string;
|
|
782
|
+
}): Promise<any>;
|
|
783
|
+
private generateAPiKey;
|
|
724
784
|
settle(): Promise<any>;
|
|
785
|
+
destoryOrderlyKey(): Promise<void>;
|
|
725
786
|
disconnect(): Promise<void>;
|
|
726
787
|
switchChainId(chainId: number | string): void;
|
|
727
788
|
private parseChainId;
|
|
728
789
|
private _checkOrderlyKeyState;
|
|
729
790
|
get signer(): Signer;
|
|
730
|
-
get
|
|
791
|
+
get walletAdapter(): WalletAdapter<any> | undefined;
|
|
731
792
|
private _getRegisterationNonce;
|
|
732
793
|
private _getTimestampFromServer;
|
|
733
794
|
private _getAccountInfo;
|
|
734
795
|
private _getSettleNonce;
|
|
735
796
|
private _simpleFetch;
|
|
736
|
-
getDomain(onChainDomain?: boolean): SignatureDomain;
|
|
737
797
|
get on(): <T extends string | symbol>(event: T, fn: (...args: any[]) => void, context?: any) => EventEmitter<string | symbol, any>;
|
|
738
798
|
get once(): <T extends string | symbol>(event: T, fn: (...args: any[]) => void, context?: any) => EventEmitter<string | symbol, any>;
|
|
739
799
|
get off(): <T extends string | symbol>(event: T, fn?: ((...args: any[]) => void) | undefined, context?: any, once?: boolean | undefined) => EventEmitter<string | symbol, any>;
|
|
@@ -748,13 +808,96 @@ declare class DefaultConfigStore implements ConfigStore {
|
|
|
748
808
|
clear(): void;
|
|
749
809
|
}
|
|
750
810
|
|
|
811
|
+
declare abstract class BaseWalletAdapter<Config> implements WalletAdapter<Config> {
|
|
812
|
+
abstract generateRegisterAccountMessage(inputs: RegisterAccountInputs): Promise<Message>;
|
|
813
|
+
abstract generateWithdrawMessage(inputs: WithdrawInputs): Promise<Message & {
|
|
814
|
+
domain: SignatureDomain;
|
|
815
|
+
}>;
|
|
816
|
+
abstract generateSettleMessage(inputs: SettleInputs): Promise<Message & {
|
|
817
|
+
domain: SignatureDomain;
|
|
818
|
+
}>;
|
|
819
|
+
abstract generateAddOrderlyKeyMessage(inputs: AddOrderlyKeyInputs): Promise<Message>;
|
|
820
|
+
abstract getBalance(): Promise<bigint>;
|
|
821
|
+
abstract chainNamespace: ChainNamespace;
|
|
822
|
+
abstract call(address: string, method: string, params: any[], options?: {
|
|
823
|
+
abi: any;
|
|
824
|
+
}): Promise<any>;
|
|
825
|
+
abstract sendTransaction(contractAddress: string, method: string, payload: {
|
|
826
|
+
from: string;
|
|
827
|
+
to?: string;
|
|
828
|
+
data: any[];
|
|
829
|
+
value?: bigint;
|
|
830
|
+
}, options: {
|
|
831
|
+
abi: any;
|
|
832
|
+
}): Promise<any>;
|
|
833
|
+
abstract callOnChain(chain: API.NetworkInfos, address: string, method: string, params: any[], options: {
|
|
834
|
+
abi: any;
|
|
835
|
+
}): Promise<any>;
|
|
836
|
+
get address(): string;
|
|
837
|
+
get chainId(): number;
|
|
838
|
+
active(config: Config): void;
|
|
839
|
+
abstract deactivate(): void;
|
|
840
|
+
update(config: Config): void;
|
|
841
|
+
generateSecretKey(): string;
|
|
842
|
+
parseUnits(amount: string, decimals?: number): string;
|
|
843
|
+
formatUnits(amount: BigNumberish, decimals?: number): string;
|
|
844
|
+
on(eventName: string, listener: (...args: any[]) => void): void;
|
|
845
|
+
off(eventName: string, listener: (...args: any[]) => void): void;
|
|
846
|
+
abstract pollTransactionReceiptWithBackoff(txHash: string, baseInterval?: number, maxInterval?: number, maxRetries?: number): Promise<any>;
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
interface Ed25519Keypair {
|
|
850
|
+
secretKey: string;
|
|
851
|
+
publicKey: string;
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
interface IWalletAdapter {
|
|
855
|
+
get chainId(): number;
|
|
856
|
+
get addresses(): string;
|
|
857
|
+
/**
|
|
858
|
+
* Set the chain id
|
|
859
|
+
*/
|
|
860
|
+
set chainId(chainId: number);
|
|
861
|
+
parseUnits: (amount: string, decimals?: number) => string;
|
|
862
|
+
formatUnits: (amount: string, decimals?: number) => string;
|
|
863
|
+
send: (method: string, params: Array<any> | Record<string, any>) => Promise<any>;
|
|
864
|
+
sendTransaction(contractAddress: string, method: string, payload: {
|
|
865
|
+
from: string;
|
|
866
|
+
to?: string;
|
|
867
|
+
data: any[];
|
|
868
|
+
value?: bigint;
|
|
869
|
+
}, options: {
|
|
870
|
+
abi: any;
|
|
871
|
+
}): Promise<TransactionResponse>;
|
|
872
|
+
getTransactionRecipect: (txHash: string) => Promise<any>;
|
|
873
|
+
signTypedData: (address: string, data: any) => Promise<string>;
|
|
874
|
+
pollTransactionReceiptWithBackoff: (txHash: string, baseInterval?: number, maxInterval?: number, maxRetries?: number) => Promise<any>;
|
|
875
|
+
getBalance: (userAddress: string) => Promise<any>;
|
|
876
|
+
call(address: string, method: string, params: any, options: {
|
|
877
|
+
abi: any;
|
|
878
|
+
}): Promise<any>;
|
|
879
|
+
callOnChain(chain: API.NetworkInfos, address: string, method: string, params: any, options: {
|
|
880
|
+
abi: any;
|
|
881
|
+
}): Promise<any>;
|
|
882
|
+
on(eventName: any, listener: any): void;
|
|
883
|
+
off(eventName: any, listener: any): void;
|
|
884
|
+
}
|
|
885
|
+
type WalletAdapterOptions = {
|
|
886
|
+
provider: any;
|
|
887
|
+
address: string;
|
|
888
|
+
chain: {
|
|
889
|
+
id: number;
|
|
890
|
+
};
|
|
891
|
+
};
|
|
892
|
+
type getWalletAdapterFunc = (options: WalletAdapterOptions) => IWalletAdapter;
|
|
893
|
+
|
|
751
894
|
declare class EtherAdapter implements IWalletAdapter {
|
|
752
895
|
private provider?;
|
|
753
896
|
private _chainId;
|
|
754
897
|
private _address;
|
|
755
898
|
constructor(options: WalletAdapterOptions);
|
|
756
|
-
parseUnits(amount: string): string;
|
|
757
|
-
formatUnits(amount: string): string;
|
|
899
|
+
parseUnits(amount: string, decimals?: number): string;
|
|
900
|
+
formatUnits(amount: string, decimals?: number): string;
|
|
758
901
|
getBalance(userAddress: string): Promise<any>;
|
|
759
902
|
deposit(from: string, to: string, amount: string): Promise<any>;
|
|
760
903
|
call(address: string, method: string, params: any[], options: {
|
|
@@ -789,4 +932,4 @@ declare class EtherAdapter implements IWalletAdapter {
|
|
|
789
932
|
getContract(address: string, abi: any): ethers.Contract;
|
|
790
933
|
}
|
|
791
934
|
|
|
792
|
-
export { Account, AccountState, BaseContract as BaseContractManager, BaseKeyStore, BaseOrderlyKeyPair, BaseSigner, ConfigKey, ConfigStore, DefaultConfigStore, EtherAdapter, IContract, LocalStorageStore, MessageFactor, MockKeyStore, OrderlyKeyPair, OrderlyKeyStore, SignedMessagePayload, Signer, SimpleDI,
|
|
935
|
+
export { Account, type AccountState, type AddOrderlyKeyInputs, BaseContract as BaseContractManager, BaseKeyStore, BaseOrderlyKeyPair, BaseSigner, BaseWalletAdapter, type ChainType, type ConfigKey, type ConfigStore, DefaultConfigStore, type Ed25519Keypair, EtherAdapter, type IContract, LocalStorageStore, type Message, type MessageFactor, MockKeyStore, type OrderlyKeyPair, type OrderlyKeyStore, type RegisterAccountInputs, type SettleInputs, type SignatureDomain, type SignedMessagePayload, type Signer, SimpleDI, type WalletAdapter, type WalletAdapterOptions, type WithdrawInputs, generateAddOrderlyKeyMessage, generateRegisterAccountMessage, generateSettleMessage, getDefaultSigner, getMockSigner, type getWalletAdapterFunc, utils };
|