@orderly.network/core 2.2.0-alpha.0 → 2.3.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 +148 -18
- package/dist/index.d.ts +148 -18
- 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
CHANGED
|
@@ -221,7 +221,9 @@ declare function generateAddOrderlyKeyMessage(inputs: {
|
|
|
221
221
|
timestamp?: number;
|
|
222
222
|
scope?: string;
|
|
223
223
|
tag?: string;
|
|
224
|
+
subAccountId?: string;
|
|
224
225
|
}): readonly [{
|
|
226
|
+
subAccountId?: string | undefined;
|
|
225
227
|
tag?: string | undefined;
|
|
226
228
|
brokerId: string;
|
|
227
229
|
orderlyKey: string;
|
|
@@ -237,6 +239,7 @@ declare function generateAddOrderlyKeyMessage(inputs: {
|
|
|
237
239
|
verifyingContract: string;
|
|
238
240
|
};
|
|
239
241
|
message: {
|
|
242
|
+
subAccountId?: string | undefined;
|
|
240
243
|
tag?: string | undefined;
|
|
241
244
|
brokerId: string;
|
|
242
245
|
orderlyKey: string;
|
|
@@ -415,6 +418,8 @@ type OrderlyContracts = {
|
|
|
415
418
|
monadTestnetUSDCAddress?: string;
|
|
416
419
|
abstractVaultAddress?: string;
|
|
417
420
|
abstractUSDCAddress?: string;
|
|
421
|
+
bscVaultAddress?: string;
|
|
422
|
+
bscUSDCAddress?: string;
|
|
418
423
|
};
|
|
419
424
|
interface IContract {
|
|
420
425
|
getContractInfoByEnv(): OrderlyContracts;
|
|
@@ -543,6 +548,8 @@ declare class BaseContract implements IContract {
|
|
|
543
548
|
solanaVaultAddress: string;
|
|
544
549
|
abstractVaultAddress: string;
|
|
545
550
|
abstractUSDCAddress: string;
|
|
551
|
+
bscVaultAddress: string;
|
|
552
|
+
bscUSDCAddress: string;
|
|
546
553
|
storyTestnetVaultAddress?: undefined;
|
|
547
554
|
monadTestnetVaultAddress?: undefined;
|
|
548
555
|
monadTestnetUSDCAddress?: undefined;
|
|
@@ -691,6 +698,8 @@ declare class BaseContract implements IContract {
|
|
|
691
698
|
monadTestnetUSDCAddress: string;
|
|
692
699
|
abstractUSDCAddress: string;
|
|
693
700
|
abstractVaultAddress: string;
|
|
701
|
+
bscVaultAddress: string;
|
|
702
|
+
bscUSDCAddress: string;
|
|
694
703
|
};
|
|
695
704
|
}
|
|
696
705
|
|
|
@@ -699,6 +708,8 @@ declare const EVENT_NAMES: {
|
|
|
699
708
|
validateStart: string;
|
|
700
709
|
validateEnd: string;
|
|
701
710
|
switchAccount: string;
|
|
711
|
+
subAccountCreated: string;
|
|
712
|
+
subAccountUpdated: string;
|
|
702
713
|
};
|
|
703
714
|
|
|
704
715
|
declare class SimpleDI {
|
|
@@ -725,6 +736,8 @@ declare class Assets {
|
|
|
725
736
|
token: string;
|
|
726
737
|
amount: string | number;
|
|
727
738
|
allowCrossChainWithdraw: boolean;
|
|
739
|
+
/** orderly withdraw decimals */
|
|
740
|
+
decimals: number;
|
|
728
741
|
}): Promise<any>;
|
|
729
742
|
private getWithdrawalNonce;
|
|
730
743
|
getNativeBalance(options?: {
|
|
@@ -736,28 +749,60 @@ declare class Assets {
|
|
|
736
749
|
getBalanceByAddress(address: string, options?: {
|
|
737
750
|
decimals?: number;
|
|
738
751
|
}): Promise<string>;
|
|
739
|
-
getAllowance(
|
|
752
|
+
getAllowance(
|
|
753
|
+
/** please use object inputs instead, string inputs will be removed in the future */
|
|
754
|
+
inputs?: string | {
|
|
740
755
|
address?: string;
|
|
741
756
|
vaultAddress?: string;
|
|
742
757
|
decimals?: number;
|
|
743
|
-
},
|
|
744
|
-
|
|
758
|
+
},
|
|
759
|
+
/** @deprecated use inputs.vaultAddress instead, will be removed in the future */
|
|
760
|
+
_vaultAddress?: string): Promise<string>;
|
|
761
|
+
approve(
|
|
762
|
+
/** please use object inputs instead, string inputs will be removed in the future */
|
|
763
|
+
inputs: string | {
|
|
745
764
|
address?: string;
|
|
746
765
|
amount?: string;
|
|
747
766
|
vaultAddress?: string;
|
|
748
|
-
decimals
|
|
749
|
-
},
|
|
767
|
+
decimals: number;
|
|
768
|
+
},
|
|
769
|
+
/** @deprecated use inputs.amount instead, will be removed in the future */
|
|
770
|
+
_amount?: string,
|
|
771
|
+
/** @deprecated use inputs.vaultAddress instead, will be removed in the future */
|
|
772
|
+
_vaultAddress?: string): Promise<any>;
|
|
750
773
|
approveByAddress(inputs: {
|
|
751
774
|
address: string;
|
|
752
775
|
amount?: string;
|
|
753
|
-
decimals
|
|
776
|
+
decimals: number;
|
|
754
777
|
}): Promise<any>;
|
|
755
|
-
getDepositFee(
|
|
756
|
-
|
|
778
|
+
getDepositFee(
|
|
779
|
+
/** please use object inputs instead, string inputs will be removed in the future */
|
|
780
|
+
inputs: string | {
|
|
781
|
+
amount: string;
|
|
782
|
+
chain: API.NetworkInfos;
|
|
783
|
+
decimals: number;
|
|
784
|
+
},
|
|
785
|
+
/** @deprecated use inputs.chain instead, will be removed in the future */
|
|
786
|
+
_chain?: API.NetworkInfos): Promise<any>;
|
|
787
|
+
deposit(
|
|
788
|
+
/** please use object inputs instead */
|
|
789
|
+
inputs: string | {
|
|
790
|
+
amount: string;
|
|
791
|
+
fee: bigint;
|
|
792
|
+
decimals: number;
|
|
793
|
+
},
|
|
794
|
+
/** @deprecated use inputs.fee instead, will be removed in the future */
|
|
795
|
+
_fee?: bigint): Promise<any>;
|
|
757
796
|
private _simpleFetch;
|
|
758
797
|
get usdcAddress(): string;
|
|
759
798
|
}
|
|
760
799
|
|
|
800
|
+
type SubAccount = {
|
|
801
|
+
id: string;
|
|
802
|
+
description: string;
|
|
803
|
+
holding: API.Holding[];
|
|
804
|
+
};
|
|
805
|
+
|
|
761
806
|
type ChainType = "EVM" | "SOL";
|
|
762
807
|
interface Message {
|
|
763
808
|
message: {
|
|
@@ -793,6 +838,8 @@ type AddOrderlyKeyInputs = {
|
|
|
793
838
|
timestamp: number;
|
|
794
839
|
scope?: string;
|
|
795
840
|
tag?: string;
|
|
841
|
+
/** @since 2.3.0, when create orderly key for sub account, it's required */
|
|
842
|
+
subAccountId?: string;
|
|
796
843
|
};
|
|
797
844
|
interface WalletAdapter<Config = any> {
|
|
798
845
|
chainNamespace: ChainNamespace;
|
|
@@ -840,8 +887,8 @@ interface WalletAdapter<Config = any> {
|
|
|
840
887
|
}): Promise<any>;
|
|
841
888
|
getBalance(): Promise<bigint>;
|
|
842
889
|
pollTransactionReceiptWithBackoff(txHash: string, baseInterval?: number, maxInterval?: number, maxRetries?: number): Promise<any>;
|
|
843
|
-
parseUnits: (amount: string, decimals
|
|
844
|
-
formatUnits: (amount: BigNumberish, decimals
|
|
890
|
+
parseUnits: (amount: string, decimals: number) => string;
|
|
891
|
+
formatUnits: (amount: BigNumberish, decimals: number) => string;
|
|
845
892
|
on(eventName: string, listener: (...args: any[]) => void): void;
|
|
846
893
|
off(eventName: string, listener: (...args: any[]) => void): void;
|
|
847
894
|
}
|
|
@@ -855,7 +902,22 @@ interface AccountState {
|
|
|
855
902
|
/**
|
|
856
903
|
* whether the account is revalidating
|
|
857
904
|
*/
|
|
905
|
+
/**
|
|
906
|
+
* The current active account ID
|
|
907
|
+
* Can be either a root account ID or sub-account ID
|
|
908
|
+
* @since 2.3.0
|
|
909
|
+
*/
|
|
858
910
|
accountId?: string;
|
|
911
|
+
/**
|
|
912
|
+
* root account id
|
|
913
|
+
* @since 2.3.0
|
|
914
|
+
*/
|
|
915
|
+
mainAccountId?: string;
|
|
916
|
+
/**
|
|
917
|
+
* sub account id
|
|
918
|
+
* @since 2.3.0
|
|
919
|
+
*/
|
|
920
|
+
subAccountId?: string | undefined;
|
|
859
921
|
userId?: string;
|
|
860
922
|
address?: string;
|
|
861
923
|
chainNamespace?: ChainNamespace;
|
|
@@ -865,6 +927,11 @@ interface AccountState {
|
|
|
865
927
|
name: string;
|
|
866
928
|
chainId: number;
|
|
867
929
|
};
|
|
930
|
+
/**
|
|
931
|
+
* sub accounts
|
|
932
|
+
* @since 2.3.0
|
|
933
|
+
*/
|
|
934
|
+
subAccounts?: SubAccount[];
|
|
868
935
|
}
|
|
869
936
|
/**
|
|
870
937
|
* Account
|
|
@@ -879,6 +946,7 @@ declare class Account {
|
|
|
879
946
|
readonly keyStore: OrderlyKeyStore;
|
|
880
947
|
static instanceName: string;
|
|
881
948
|
static additionalInfoRepositoryName: string;
|
|
949
|
+
static ACTIVE_SUB_ACCOUNT_ID_KEY: string;
|
|
882
950
|
private _singer?;
|
|
883
951
|
private _ee;
|
|
884
952
|
private walletAdapterManager;
|
|
@@ -908,15 +976,59 @@ declare class Account {
|
|
|
908
976
|
private saveAdditionalInfo;
|
|
909
977
|
get stateValue(): AccountState;
|
|
910
978
|
get accountId(): string | undefined;
|
|
979
|
+
get mainAccountId(): string | undefined;
|
|
980
|
+
get subAccountId(): string | undefined;
|
|
981
|
+
get isSubAccount(): boolean;
|
|
911
982
|
get accountIdHashStr(): string | undefined;
|
|
912
983
|
get address(): string | undefined;
|
|
913
984
|
get chainId(): number | string | undefined;
|
|
914
985
|
get apiBaseUrl(): string | undefined;
|
|
986
|
+
private updateState;
|
|
915
987
|
private _bindEvents;
|
|
916
988
|
private _checkAccount;
|
|
917
989
|
private _checkAccountExist;
|
|
990
|
+
private _restoreSubAccount;
|
|
991
|
+
restoreSubAccount(): Promise<AccountState>;
|
|
918
992
|
createAccount(): Promise<any>;
|
|
919
|
-
|
|
993
|
+
createSubAccount(description?: string): Promise<any>;
|
|
994
|
+
updateSubAccount({ subAccountId, description, }: {
|
|
995
|
+
subAccountId: string;
|
|
996
|
+
description?: string;
|
|
997
|
+
}): Promise<any>;
|
|
998
|
+
switchAccount(accountId: string): void;
|
|
999
|
+
getSubAccounts(): Promise<({
|
|
1000
|
+
sub_account_id: string;
|
|
1001
|
+
description: string;
|
|
1002
|
+
} & {
|
|
1003
|
+
holding: API.Holding[];
|
|
1004
|
+
})[]>;
|
|
1005
|
+
getSubAccountBalances(): Promise<Record<string, API.Holding[]>>;
|
|
1006
|
+
/**
|
|
1007
|
+
* refresh sub account balances
|
|
1008
|
+
* @since 2.3.0
|
|
1009
|
+
*/
|
|
1010
|
+
refreshSubAccountBalances(): Promise<Record<string, API.Holding[]>>;
|
|
1011
|
+
/**
|
|
1012
|
+
* @since 2.3.0
|
|
1013
|
+
* if you are using main account orderly key, you can create api key for sub account
|
|
1014
|
+
*/
|
|
1015
|
+
createSubAccountApiKey(
|
|
1016
|
+
/**
|
|
1017
|
+
* expiration days
|
|
1018
|
+
*/
|
|
1019
|
+
expiration: number, options: {
|
|
1020
|
+
tag?: string;
|
|
1021
|
+
scope?: string;
|
|
1022
|
+
subAccountId: string;
|
|
1023
|
+
}): Promise<{
|
|
1024
|
+
key: string;
|
|
1025
|
+
secretKey: string;
|
|
1026
|
+
}>;
|
|
1027
|
+
createApiKey(
|
|
1028
|
+
/**
|
|
1029
|
+
* expiration days
|
|
1030
|
+
*/
|
|
1031
|
+
expiration: number, options?: {
|
|
920
1032
|
tag?: string;
|
|
921
1033
|
scope?: string;
|
|
922
1034
|
}): Promise<{
|
|
@@ -934,7 +1046,19 @@ declare class Account {
|
|
|
934
1046
|
chainNamespace: ChainNamespace;
|
|
935
1047
|
}): Promise<true | undefined>;
|
|
936
1048
|
checkOrderlyKey(address: string, orderlyKey: OrderlyKeyPair, accountId: string): Promise<true | undefined>;
|
|
1049
|
+
/**
|
|
1050
|
+
* @since 2.3.0
|
|
1051
|
+
* settle sub account pnl
|
|
1052
|
+
*/
|
|
1053
|
+
settleSubAccount(options?: {
|
|
1054
|
+
/**
|
|
1055
|
+
* if you are main account and want to settle the sub account, you need to pass the subAccountId
|
|
1056
|
+
* if you are sub account, not need to pass the subAccountId
|
|
1057
|
+
* */
|
|
1058
|
+
subAccountId?: string;
|
|
1059
|
+
}): Promise<any>;
|
|
937
1060
|
settle(): Promise<any>;
|
|
1061
|
+
private signData;
|
|
938
1062
|
destroyOrderlyKey(): Promise<void>;
|
|
939
1063
|
disconnect(): Promise<void>;
|
|
940
1064
|
switchChainId(chainId: number | string): void;
|
|
@@ -951,6 +1075,12 @@ declare class Account {
|
|
|
951
1075
|
get on(): <T extends string | symbol>(event: T, fn: (...args: any[]) => void, context?: any) => EventEmitter<string | symbol, any>;
|
|
952
1076
|
get once(): <T extends string | symbol>(event: T, fn: (...args: any[]) => void, context?: any) => EventEmitter<string | symbol, any>;
|
|
953
1077
|
get off(): <T extends string | symbol>(event: T, fn?: ((...args: any[]) => void) | undefined, context?: any, once?: boolean) => EventEmitter<string | symbol, any>;
|
|
1078
|
+
/**
|
|
1079
|
+
* Signs a GET MessageFactor payload with the current timestamp.
|
|
1080
|
+
* @param url The URL for the GET request
|
|
1081
|
+
* @returns The signature
|
|
1082
|
+
*/
|
|
1083
|
+
private signGetMessageFactor;
|
|
954
1084
|
}
|
|
955
1085
|
|
|
956
1086
|
type ChainNamespaceType = typeof ChainNamespace[keyof typeof ChainNamespace];
|
|
@@ -1002,8 +1132,8 @@ declare abstract class BaseWalletAdapter<Config> implements WalletAdapter<Config
|
|
|
1002
1132
|
abstract deactivate(): void;
|
|
1003
1133
|
update(config: Config): void;
|
|
1004
1134
|
generateSecretKey(): string;
|
|
1005
|
-
parseUnits(amount: string, decimals
|
|
1006
|
-
formatUnits(amount: BigNumberish, decimals
|
|
1135
|
+
parseUnits(amount: string, decimals: number): string;
|
|
1136
|
+
formatUnits(amount: BigNumberish, decimals: number): string;
|
|
1007
1137
|
on(eventName: string, listener: (...args: any[]) => void): void;
|
|
1008
1138
|
off(eventName: string, listener: (...args: any[]) => void): void;
|
|
1009
1139
|
abstract pollTransactionReceiptWithBackoff(txHash: string, baseInterval?: number, maxInterval?: number, maxRetries?: number): Promise<any>;
|
|
@@ -1021,8 +1151,8 @@ interface IWalletAdapter {
|
|
|
1021
1151
|
* Set the chain id
|
|
1022
1152
|
*/
|
|
1023
1153
|
set chainId(chainId: number);
|
|
1024
|
-
parseUnits: (amount: string, decimals
|
|
1025
|
-
formatUnits: (amount: string, decimals
|
|
1154
|
+
parseUnits: (amount: string, decimals: number) => string;
|
|
1155
|
+
formatUnits: (amount: string, decimals: number) => string;
|
|
1026
1156
|
send: (method: string, params: Array<any> | Record<string, any>) => Promise<any>;
|
|
1027
1157
|
sendTransaction(contractAddress: string, method: string, payload: {
|
|
1028
1158
|
from: string;
|
|
@@ -1059,8 +1189,8 @@ declare class EtherAdapter implements IWalletAdapter {
|
|
|
1059
1189
|
private _chainId;
|
|
1060
1190
|
private _address;
|
|
1061
1191
|
constructor(options: WalletAdapterOptions);
|
|
1062
|
-
parseUnits(amount: string, decimals
|
|
1063
|
-
formatUnits(amount: string, decimals
|
|
1192
|
+
parseUnits(amount: string, decimals: number): string;
|
|
1193
|
+
formatUnits(amount: string, decimals: number): string;
|
|
1064
1194
|
getBalance(userAddress: string): Promise<any>;
|
|
1065
1195
|
deposit(from: string, to: string, amount: string): Promise<any>;
|
|
1066
1196
|
call(address: string, method: string, params: any[], options: {
|
|
@@ -1095,4 +1225,4 @@ declare class EtherAdapter implements IWalletAdapter {
|
|
|
1095
1225
|
getContract(address: string, abi: any): ethers.Contract;
|
|
1096
1226
|
}
|
|
1097
1227
|
|
|
1098
|
-
export { API_URLS, Account, type AccountState, type AddOrderlyKeyInputs, BaseContract as BaseContractManager, BaseKeyStore, BaseOrderlyKeyPair, BaseSigner, BaseWalletAdapter, type ChainType, type ConfigKey, type ConfigStore, DefaultConfigStore, EVENT_NAMES, 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 URLS, type WalletAdapter, type WalletAdapterOptions, type WithdrawInputs, generateAddOrderlyKeyMessage, generateRegisterAccountMessage, generateSettleMessage, getDefaultSigner, getMockSigner, type getWalletAdapterFunc, utils };
|
|
1228
|
+
export { API_URLS, Account, type AccountState, type AddOrderlyKeyInputs, BaseContract as BaseContractManager, BaseKeyStore, BaseOrderlyKeyPair, BaseSigner, BaseWalletAdapter, type ChainType, type ConfigKey, type ConfigStore, DefaultConfigStore, EVENT_NAMES, 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 SubAccount, type URLS, type WalletAdapter, type WalletAdapterOptions, type WithdrawInputs, generateAddOrderlyKeyMessage, generateRegisterAccountMessage, generateSettleMessage, getDefaultSigner, getMockSigner, type getWalletAdapterFunc, utils };
|
package/dist/index.d.ts
CHANGED
|
@@ -221,7 +221,9 @@ declare function generateAddOrderlyKeyMessage(inputs: {
|
|
|
221
221
|
timestamp?: number;
|
|
222
222
|
scope?: string;
|
|
223
223
|
tag?: string;
|
|
224
|
+
subAccountId?: string;
|
|
224
225
|
}): readonly [{
|
|
226
|
+
subAccountId?: string | undefined;
|
|
225
227
|
tag?: string | undefined;
|
|
226
228
|
brokerId: string;
|
|
227
229
|
orderlyKey: string;
|
|
@@ -237,6 +239,7 @@ declare function generateAddOrderlyKeyMessage(inputs: {
|
|
|
237
239
|
verifyingContract: string;
|
|
238
240
|
};
|
|
239
241
|
message: {
|
|
242
|
+
subAccountId?: string | undefined;
|
|
240
243
|
tag?: string | undefined;
|
|
241
244
|
brokerId: string;
|
|
242
245
|
orderlyKey: string;
|
|
@@ -415,6 +418,8 @@ type OrderlyContracts = {
|
|
|
415
418
|
monadTestnetUSDCAddress?: string;
|
|
416
419
|
abstractVaultAddress?: string;
|
|
417
420
|
abstractUSDCAddress?: string;
|
|
421
|
+
bscVaultAddress?: string;
|
|
422
|
+
bscUSDCAddress?: string;
|
|
418
423
|
};
|
|
419
424
|
interface IContract {
|
|
420
425
|
getContractInfoByEnv(): OrderlyContracts;
|
|
@@ -543,6 +548,8 @@ declare class BaseContract implements IContract {
|
|
|
543
548
|
solanaVaultAddress: string;
|
|
544
549
|
abstractVaultAddress: string;
|
|
545
550
|
abstractUSDCAddress: string;
|
|
551
|
+
bscVaultAddress: string;
|
|
552
|
+
bscUSDCAddress: string;
|
|
546
553
|
storyTestnetVaultAddress?: undefined;
|
|
547
554
|
monadTestnetVaultAddress?: undefined;
|
|
548
555
|
monadTestnetUSDCAddress?: undefined;
|
|
@@ -691,6 +698,8 @@ declare class BaseContract implements IContract {
|
|
|
691
698
|
monadTestnetUSDCAddress: string;
|
|
692
699
|
abstractUSDCAddress: string;
|
|
693
700
|
abstractVaultAddress: string;
|
|
701
|
+
bscVaultAddress: string;
|
|
702
|
+
bscUSDCAddress: string;
|
|
694
703
|
};
|
|
695
704
|
}
|
|
696
705
|
|
|
@@ -699,6 +708,8 @@ declare const EVENT_NAMES: {
|
|
|
699
708
|
validateStart: string;
|
|
700
709
|
validateEnd: string;
|
|
701
710
|
switchAccount: string;
|
|
711
|
+
subAccountCreated: string;
|
|
712
|
+
subAccountUpdated: string;
|
|
702
713
|
};
|
|
703
714
|
|
|
704
715
|
declare class SimpleDI {
|
|
@@ -725,6 +736,8 @@ declare class Assets {
|
|
|
725
736
|
token: string;
|
|
726
737
|
amount: string | number;
|
|
727
738
|
allowCrossChainWithdraw: boolean;
|
|
739
|
+
/** orderly withdraw decimals */
|
|
740
|
+
decimals: number;
|
|
728
741
|
}): Promise<any>;
|
|
729
742
|
private getWithdrawalNonce;
|
|
730
743
|
getNativeBalance(options?: {
|
|
@@ -736,28 +749,60 @@ declare class Assets {
|
|
|
736
749
|
getBalanceByAddress(address: string, options?: {
|
|
737
750
|
decimals?: number;
|
|
738
751
|
}): Promise<string>;
|
|
739
|
-
getAllowance(
|
|
752
|
+
getAllowance(
|
|
753
|
+
/** please use object inputs instead, string inputs will be removed in the future */
|
|
754
|
+
inputs?: string | {
|
|
740
755
|
address?: string;
|
|
741
756
|
vaultAddress?: string;
|
|
742
757
|
decimals?: number;
|
|
743
|
-
},
|
|
744
|
-
|
|
758
|
+
},
|
|
759
|
+
/** @deprecated use inputs.vaultAddress instead, will be removed in the future */
|
|
760
|
+
_vaultAddress?: string): Promise<string>;
|
|
761
|
+
approve(
|
|
762
|
+
/** please use object inputs instead, string inputs will be removed in the future */
|
|
763
|
+
inputs: string | {
|
|
745
764
|
address?: string;
|
|
746
765
|
amount?: string;
|
|
747
766
|
vaultAddress?: string;
|
|
748
|
-
decimals
|
|
749
|
-
},
|
|
767
|
+
decimals: number;
|
|
768
|
+
},
|
|
769
|
+
/** @deprecated use inputs.amount instead, will be removed in the future */
|
|
770
|
+
_amount?: string,
|
|
771
|
+
/** @deprecated use inputs.vaultAddress instead, will be removed in the future */
|
|
772
|
+
_vaultAddress?: string): Promise<any>;
|
|
750
773
|
approveByAddress(inputs: {
|
|
751
774
|
address: string;
|
|
752
775
|
amount?: string;
|
|
753
|
-
decimals
|
|
776
|
+
decimals: number;
|
|
754
777
|
}): Promise<any>;
|
|
755
|
-
getDepositFee(
|
|
756
|
-
|
|
778
|
+
getDepositFee(
|
|
779
|
+
/** please use object inputs instead, string inputs will be removed in the future */
|
|
780
|
+
inputs: string | {
|
|
781
|
+
amount: string;
|
|
782
|
+
chain: API.NetworkInfos;
|
|
783
|
+
decimals: number;
|
|
784
|
+
},
|
|
785
|
+
/** @deprecated use inputs.chain instead, will be removed in the future */
|
|
786
|
+
_chain?: API.NetworkInfos): Promise<any>;
|
|
787
|
+
deposit(
|
|
788
|
+
/** please use object inputs instead */
|
|
789
|
+
inputs: string | {
|
|
790
|
+
amount: string;
|
|
791
|
+
fee: bigint;
|
|
792
|
+
decimals: number;
|
|
793
|
+
},
|
|
794
|
+
/** @deprecated use inputs.fee instead, will be removed in the future */
|
|
795
|
+
_fee?: bigint): Promise<any>;
|
|
757
796
|
private _simpleFetch;
|
|
758
797
|
get usdcAddress(): string;
|
|
759
798
|
}
|
|
760
799
|
|
|
800
|
+
type SubAccount = {
|
|
801
|
+
id: string;
|
|
802
|
+
description: string;
|
|
803
|
+
holding: API.Holding[];
|
|
804
|
+
};
|
|
805
|
+
|
|
761
806
|
type ChainType = "EVM" | "SOL";
|
|
762
807
|
interface Message {
|
|
763
808
|
message: {
|
|
@@ -793,6 +838,8 @@ type AddOrderlyKeyInputs = {
|
|
|
793
838
|
timestamp: number;
|
|
794
839
|
scope?: string;
|
|
795
840
|
tag?: string;
|
|
841
|
+
/** @since 2.3.0, when create orderly key for sub account, it's required */
|
|
842
|
+
subAccountId?: string;
|
|
796
843
|
};
|
|
797
844
|
interface WalletAdapter<Config = any> {
|
|
798
845
|
chainNamespace: ChainNamespace;
|
|
@@ -840,8 +887,8 @@ interface WalletAdapter<Config = any> {
|
|
|
840
887
|
}): Promise<any>;
|
|
841
888
|
getBalance(): Promise<bigint>;
|
|
842
889
|
pollTransactionReceiptWithBackoff(txHash: string, baseInterval?: number, maxInterval?: number, maxRetries?: number): Promise<any>;
|
|
843
|
-
parseUnits: (amount: string, decimals
|
|
844
|
-
formatUnits: (amount: BigNumberish, decimals
|
|
890
|
+
parseUnits: (amount: string, decimals: number) => string;
|
|
891
|
+
formatUnits: (amount: BigNumberish, decimals: number) => string;
|
|
845
892
|
on(eventName: string, listener: (...args: any[]) => void): void;
|
|
846
893
|
off(eventName: string, listener: (...args: any[]) => void): void;
|
|
847
894
|
}
|
|
@@ -855,7 +902,22 @@ interface AccountState {
|
|
|
855
902
|
/**
|
|
856
903
|
* whether the account is revalidating
|
|
857
904
|
*/
|
|
905
|
+
/**
|
|
906
|
+
* The current active account ID
|
|
907
|
+
* Can be either a root account ID or sub-account ID
|
|
908
|
+
* @since 2.3.0
|
|
909
|
+
*/
|
|
858
910
|
accountId?: string;
|
|
911
|
+
/**
|
|
912
|
+
* root account id
|
|
913
|
+
* @since 2.3.0
|
|
914
|
+
*/
|
|
915
|
+
mainAccountId?: string;
|
|
916
|
+
/**
|
|
917
|
+
* sub account id
|
|
918
|
+
* @since 2.3.0
|
|
919
|
+
*/
|
|
920
|
+
subAccountId?: string | undefined;
|
|
859
921
|
userId?: string;
|
|
860
922
|
address?: string;
|
|
861
923
|
chainNamespace?: ChainNamespace;
|
|
@@ -865,6 +927,11 @@ interface AccountState {
|
|
|
865
927
|
name: string;
|
|
866
928
|
chainId: number;
|
|
867
929
|
};
|
|
930
|
+
/**
|
|
931
|
+
* sub accounts
|
|
932
|
+
* @since 2.3.0
|
|
933
|
+
*/
|
|
934
|
+
subAccounts?: SubAccount[];
|
|
868
935
|
}
|
|
869
936
|
/**
|
|
870
937
|
* Account
|
|
@@ -879,6 +946,7 @@ declare class Account {
|
|
|
879
946
|
readonly keyStore: OrderlyKeyStore;
|
|
880
947
|
static instanceName: string;
|
|
881
948
|
static additionalInfoRepositoryName: string;
|
|
949
|
+
static ACTIVE_SUB_ACCOUNT_ID_KEY: string;
|
|
882
950
|
private _singer?;
|
|
883
951
|
private _ee;
|
|
884
952
|
private walletAdapterManager;
|
|
@@ -908,15 +976,59 @@ declare class Account {
|
|
|
908
976
|
private saveAdditionalInfo;
|
|
909
977
|
get stateValue(): AccountState;
|
|
910
978
|
get accountId(): string | undefined;
|
|
979
|
+
get mainAccountId(): string | undefined;
|
|
980
|
+
get subAccountId(): string | undefined;
|
|
981
|
+
get isSubAccount(): boolean;
|
|
911
982
|
get accountIdHashStr(): string | undefined;
|
|
912
983
|
get address(): string | undefined;
|
|
913
984
|
get chainId(): number | string | undefined;
|
|
914
985
|
get apiBaseUrl(): string | undefined;
|
|
986
|
+
private updateState;
|
|
915
987
|
private _bindEvents;
|
|
916
988
|
private _checkAccount;
|
|
917
989
|
private _checkAccountExist;
|
|
990
|
+
private _restoreSubAccount;
|
|
991
|
+
restoreSubAccount(): Promise<AccountState>;
|
|
918
992
|
createAccount(): Promise<any>;
|
|
919
|
-
|
|
993
|
+
createSubAccount(description?: string): Promise<any>;
|
|
994
|
+
updateSubAccount({ subAccountId, description, }: {
|
|
995
|
+
subAccountId: string;
|
|
996
|
+
description?: string;
|
|
997
|
+
}): Promise<any>;
|
|
998
|
+
switchAccount(accountId: string): void;
|
|
999
|
+
getSubAccounts(): Promise<({
|
|
1000
|
+
sub_account_id: string;
|
|
1001
|
+
description: string;
|
|
1002
|
+
} & {
|
|
1003
|
+
holding: API.Holding[];
|
|
1004
|
+
})[]>;
|
|
1005
|
+
getSubAccountBalances(): Promise<Record<string, API.Holding[]>>;
|
|
1006
|
+
/**
|
|
1007
|
+
* refresh sub account balances
|
|
1008
|
+
* @since 2.3.0
|
|
1009
|
+
*/
|
|
1010
|
+
refreshSubAccountBalances(): Promise<Record<string, API.Holding[]>>;
|
|
1011
|
+
/**
|
|
1012
|
+
* @since 2.3.0
|
|
1013
|
+
* if you are using main account orderly key, you can create api key for sub account
|
|
1014
|
+
*/
|
|
1015
|
+
createSubAccountApiKey(
|
|
1016
|
+
/**
|
|
1017
|
+
* expiration days
|
|
1018
|
+
*/
|
|
1019
|
+
expiration: number, options: {
|
|
1020
|
+
tag?: string;
|
|
1021
|
+
scope?: string;
|
|
1022
|
+
subAccountId: string;
|
|
1023
|
+
}): Promise<{
|
|
1024
|
+
key: string;
|
|
1025
|
+
secretKey: string;
|
|
1026
|
+
}>;
|
|
1027
|
+
createApiKey(
|
|
1028
|
+
/**
|
|
1029
|
+
* expiration days
|
|
1030
|
+
*/
|
|
1031
|
+
expiration: number, options?: {
|
|
920
1032
|
tag?: string;
|
|
921
1033
|
scope?: string;
|
|
922
1034
|
}): Promise<{
|
|
@@ -934,7 +1046,19 @@ declare class Account {
|
|
|
934
1046
|
chainNamespace: ChainNamespace;
|
|
935
1047
|
}): Promise<true | undefined>;
|
|
936
1048
|
checkOrderlyKey(address: string, orderlyKey: OrderlyKeyPair, accountId: string): Promise<true | undefined>;
|
|
1049
|
+
/**
|
|
1050
|
+
* @since 2.3.0
|
|
1051
|
+
* settle sub account pnl
|
|
1052
|
+
*/
|
|
1053
|
+
settleSubAccount(options?: {
|
|
1054
|
+
/**
|
|
1055
|
+
* if you are main account and want to settle the sub account, you need to pass the subAccountId
|
|
1056
|
+
* if you are sub account, not need to pass the subAccountId
|
|
1057
|
+
* */
|
|
1058
|
+
subAccountId?: string;
|
|
1059
|
+
}): Promise<any>;
|
|
937
1060
|
settle(): Promise<any>;
|
|
1061
|
+
private signData;
|
|
938
1062
|
destroyOrderlyKey(): Promise<void>;
|
|
939
1063
|
disconnect(): Promise<void>;
|
|
940
1064
|
switchChainId(chainId: number | string): void;
|
|
@@ -951,6 +1075,12 @@ declare class Account {
|
|
|
951
1075
|
get on(): <T extends string | symbol>(event: T, fn: (...args: any[]) => void, context?: any) => EventEmitter<string | symbol, any>;
|
|
952
1076
|
get once(): <T extends string | symbol>(event: T, fn: (...args: any[]) => void, context?: any) => EventEmitter<string | symbol, any>;
|
|
953
1077
|
get off(): <T extends string | symbol>(event: T, fn?: ((...args: any[]) => void) | undefined, context?: any, once?: boolean) => EventEmitter<string | symbol, any>;
|
|
1078
|
+
/**
|
|
1079
|
+
* Signs a GET MessageFactor payload with the current timestamp.
|
|
1080
|
+
* @param url The URL for the GET request
|
|
1081
|
+
* @returns The signature
|
|
1082
|
+
*/
|
|
1083
|
+
private signGetMessageFactor;
|
|
954
1084
|
}
|
|
955
1085
|
|
|
956
1086
|
type ChainNamespaceType = typeof ChainNamespace[keyof typeof ChainNamespace];
|
|
@@ -1002,8 +1132,8 @@ declare abstract class BaseWalletAdapter<Config> implements WalletAdapter<Config
|
|
|
1002
1132
|
abstract deactivate(): void;
|
|
1003
1133
|
update(config: Config): void;
|
|
1004
1134
|
generateSecretKey(): string;
|
|
1005
|
-
parseUnits(amount: string, decimals
|
|
1006
|
-
formatUnits(amount: BigNumberish, decimals
|
|
1135
|
+
parseUnits(amount: string, decimals: number): string;
|
|
1136
|
+
formatUnits(amount: BigNumberish, decimals: number): string;
|
|
1007
1137
|
on(eventName: string, listener: (...args: any[]) => void): void;
|
|
1008
1138
|
off(eventName: string, listener: (...args: any[]) => void): void;
|
|
1009
1139
|
abstract pollTransactionReceiptWithBackoff(txHash: string, baseInterval?: number, maxInterval?: number, maxRetries?: number): Promise<any>;
|
|
@@ -1021,8 +1151,8 @@ interface IWalletAdapter {
|
|
|
1021
1151
|
* Set the chain id
|
|
1022
1152
|
*/
|
|
1023
1153
|
set chainId(chainId: number);
|
|
1024
|
-
parseUnits: (amount: string, decimals
|
|
1025
|
-
formatUnits: (amount: string, decimals
|
|
1154
|
+
parseUnits: (amount: string, decimals: number) => string;
|
|
1155
|
+
formatUnits: (amount: string, decimals: number) => string;
|
|
1026
1156
|
send: (method: string, params: Array<any> | Record<string, any>) => Promise<any>;
|
|
1027
1157
|
sendTransaction(contractAddress: string, method: string, payload: {
|
|
1028
1158
|
from: string;
|
|
@@ -1059,8 +1189,8 @@ declare class EtherAdapter implements IWalletAdapter {
|
|
|
1059
1189
|
private _chainId;
|
|
1060
1190
|
private _address;
|
|
1061
1191
|
constructor(options: WalletAdapterOptions);
|
|
1062
|
-
parseUnits(amount: string, decimals
|
|
1063
|
-
formatUnits(amount: string, decimals
|
|
1192
|
+
parseUnits(amount: string, decimals: number): string;
|
|
1193
|
+
formatUnits(amount: string, decimals: number): string;
|
|
1064
1194
|
getBalance(userAddress: string): Promise<any>;
|
|
1065
1195
|
deposit(from: string, to: string, amount: string): Promise<any>;
|
|
1066
1196
|
call(address: string, method: string, params: any[], options: {
|
|
@@ -1095,4 +1225,4 @@ declare class EtherAdapter implements IWalletAdapter {
|
|
|
1095
1225
|
getContract(address: string, abi: any): ethers.Contract;
|
|
1096
1226
|
}
|
|
1097
1227
|
|
|
1098
|
-
export { API_URLS, Account, type AccountState, type AddOrderlyKeyInputs, BaseContract as BaseContractManager, BaseKeyStore, BaseOrderlyKeyPair, BaseSigner, BaseWalletAdapter, type ChainType, type ConfigKey, type ConfigStore, DefaultConfigStore, EVENT_NAMES, 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 URLS, type WalletAdapter, type WalletAdapterOptions, type WithdrawInputs, generateAddOrderlyKeyMessage, generateRegisterAccountMessage, generateSettleMessage, getDefaultSigner, getMockSigner, type getWalletAdapterFunc, utils };
|
|
1228
|
+
export { API_URLS, Account, type AccountState, type AddOrderlyKeyInputs, BaseContract as BaseContractManager, BaseKeyStore, BaseOrderlyKeyPair, BaseSigner, BaseWalletAdapter, type ChainType, type ConfigKey, type ConfigStore, DefaultConfigStore, EVENT_NAMES, 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 SubAccount, type URLS, type WalletAdapter, type WalletAdapterOptions, type WithdrawInputs, generateAddOrderlyKeyMessage, generateRegisterAccountMessage, generateSettleMessage, getDefaultSigner, getMockSigner, type getWalletAdapterFunc, utils };
|