@orderly.network/hooks 0.0.25 → 0.0.27
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 +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +9 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import useSWR, { SWRConfiguration, SWRResponse } from 'swr';
|
|
2
2
|
export { SWRConfiguration, default as useSWR } from 'swr';
|
|
3
3
|
import { SWRMutationConfiguration } from 'swr/mutation';
|
|
4
|
-
import { Account, AccountState, ConfigStore, OrderlyKeyStore, WalletAdapter, EventEmitter, WSMessage } from '@orderly.network/core';
|
|
4
|
+
import { Account, AccountState, ConfigStore, OrderlyKeyStore, WalletAdapter, IContract, EventEmitter, WSMessage } from '@orderly.network/core';
|
|
5
5
|
import * as react from 'react';
|
|
6
6
|
import react__default, { FC, PropsWithChildren } from 'react';
|
|
7
7
|
export { default as useConstant } from 'use-constant';
|
|
@@ -74,6 +74,7 @@ interface OrderlyContextState extends OrderlyAppConfig {
|
|
|
74
74
|
walletAdapter: {
|
|
75
75
|
new (options: any): WalletAdapter;
|
|
76
76
|
};
|
|
77
|
+
contractManager: IContract;
|
|
77
78
|
networkId: string;
|
|
78
79
|
onWalletConnect?: () => Promise<any>;
|
|
79
80
|
onWalletDisconnect?: () => Promise<any>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import useSWR, { SWRConfiguration, SWRResponse } from 'swr';
|
|
2
2
|
export { SWRConfiguration, default as useSWR } from 'swr';
|
|
3
3
|
import { SWRMutationConfiguration } from 'swr/mutation';
|
|
4
|
-
import { Account, AccountState, ConfigStore, OrderlyKeyStore, WalletAdapter, EventEmitter, WSMessage } from '@orderly.network/core';
|
|
4
|
+
import { Account, AccountState, ConfigStore, OrderlyKeyStore, WalletAdapter, IContract, EventEmitter, WSMessage } from '@orderly.network/core';
|
|
5
5
|
import * as react from 'react';
|
|
6
6
|
import react__default, { FC, PropsWithChildren } from 'react';
|
|
7
7
|
export { default as useConstant } from 'use-constant';
|
|
@@ -74,6 +74,7 @@ interface OrderlyContextState extends OrderlyAppConfig {
|
|
|
74
74
|
walletAdapter: {
|
|
75
75
|
new (options: any): WalletAdapter;
|
|
76
76
|
};
|
|
77
|
+
contractManager: IContract;
|
|
77
78
|
networkId: string;
|
|
78
79
|
onWalletConnect?: () => Promise<any>;
|
|
79
80
|
onWalletDisconnect?: () => Promise<any>;
|
package/dist/index.js
CHANGED
|
@@ -98,7 +98,7 @@ var useQuery = (query, options) => {
|
|
|
98
98
|
);
|
|
99
99
|
};
|
|
100
100
|
var useAccountInstance = () => {
|
|
101
|
-
const { configStore, keyStore, walletAdapter } = React2.useContext(OrderlyContext);
|
|
101
|
+
const { configStore, keyStore, contractManager, walletAdapter } = React2.useContext(OrderlyContext);
|
|
102
102
|
if (!configStore)
|
|
103
103
|
throw new Error("configStore is not defined, please use OrderlyProvider");
|
|
104
104
|
if (!keyStore) {
|
|
@@ -109,7 +109,12 @@ var useAccountInstance = () => {
|
|
|
109
109
|
const account5 = useConstant__default.default(() => {
|
|
110
110
|
let account6 = core.SimpleDI.get("account");
|
|
111
111
|
if (!account6) {
|
|
112
|
-
account6 = new core.Account(
|
|
112
|
+
account6 = new core.Account(
|
|
113
|
+
configStore,
|
|
114
|
+
keyStore,
|
|
115
|
+
contractManager,
|
|
116
|
+
walletAdapter
|
|
117
|
+
);
|
|
113
118
|
core.SimpleDI.registerByName("account", account6);
|
|
114
119
|
}
|
|
115
120
|
return account6;
|
|
@@ -208,6 +213,7 @@ var useAccount = () => {
|
|
|
208
213
|
configStore,
|
|
209
214
|
keyStore,
|
|
210
215
|
walletAdapter,
|
|
216
|
+
contractManager,
|
|
211
217
|
onWalletConnect,
|
|
212
218
|
onWalletDisconnect,
|
|
213
219
|
onSetChain
|
|
@@ -219,14 +225,7 @@ var useAccount = () => {
|
|
|
219
225
|
"keyStore is not defined, please use OrderlyProvider and provide keyStore"
|
|
220
226
|
);
|
|
221
227
|
}
|
|
222
|
-
const account5 =
|
|
223
|
-
let account6 = core.SimpleDI.get("account");
|
|
224
|
-
if (!account6) {
|
|
225
|
-
account6 = new core.Account(configStore, keyStore, walletAdapter);
|
|
226
|
-
core.SimpleDI.registerByName("account", account6);
|
|
227
|
-
}
|
|
228
|
-
return account6;
|
|
229
|
-
});
|
|
228
|
+
const account5 = useAccountInstance();
|
|
230
229
|
const [state, setState] = React2.useState(account5.stateValue);
|
|
231
230
|
const statusChangeHandler = (nextState) => {
|
|
232
231
|
setState(() => nextState);
|