@echoxyz/sonar-react 0.3.1 → 0.4.1
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/CHANGELOG.md +13 -0
- package/README.md +0 -3
- package/dist/index.cjs +7 -8
- package/dist/index.d.cts +2 -6
- package/dist/index.d.ts +2 -6
- package/dist/index.js +7 -8
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @echoxyz/sonar-react
|
|
2
2
|
|
|
3
|
+
## 0.4.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [c032c29]
|
|
8
|
+
- @echoxyz/sonar-core@0.3.0
|
|
9
|
+
|
|
10
|
+
## 0.4.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- 2571855: useSonarEntity now just takes walletAddress, and not isConnected
|
|
15
|
+
|
|
3
16
|
## 0.3.1
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -124,7 +124,6 @@ const ExampleEntityPanel = () => {
|
|
|
124
124
|
import { useEffect } from "react";
|
|
125
125
|
import { useSonarEntity } from "./hooks/useSonarEntity";
|
|
126
126
|
import { useAccount } from "wagmi";
|
|
127
|
-
import { EntityType } from "@echoxyz/sonar-core";
|
|
128
127
|
|
|
129
128
|
export function Example() {
|
|
130
129
|
const { address, isConnected } = useAccount();
|
|
@@ -144,7 +143,6 @@ export function Example() {
|
|
|
144
143
|
const pre = await client.prePurchaseCheck({
|
|
145
144
|
saleUUID: "<your-sale-uuid>",
|
|
146
145
|
entityUUID: entity.EntityUUID,
|
|
147
|
-
entityType: EntityType.USER,
|
|
148
146
|
walletAddress: "0x1234...abcd" as `0x${string}`,
|
|
149
147
|
});
|
|
150
148
|
|
|
@@ -152,7 +150,6 @@ export function Example() {
|
|
|
152
150
|
const permit = await client.generatePurchasePermit({
|
|
153
151
|
saleUUID: "<your-sale-uuid>",
|
|
154
152
|
entityUUID: entity.EntityUUID,
|
|
155
|
-
entityType: EntityType.USER,
|
|
156
153
|
walletAddress: "0x1234...abcd" as `0x${string}`,
|
|
157
154
|
});
|
|
158
155
|
console.log(permit.Signature, permit.Permit);
|
package/dist/index.cjs
CHANGED
|
@@ -128,22 +128,21 @@ function useSonarEntity(args) {
|
|
|
128
128
|
throw new Error("saleUUID is required");
|
|
129
129
|
}
|
|
130
130
|
const saleUUID = args.saleUUID;
|
|
131
|
-
const
|
|
132
|
-
const walletConnected = args.wallet.isConnected;
|
|
131
|
+
const walletAddress = args.walletAddress;
|
|
133
132
|
const [state, setState] = (0, import_react2.useState)({
|
|
134
133
|
loading: false,
|
|
135
134
|
hasFetched: false
|
|
136
135
|
});
|
|
137
|
-
const fullyConnected = ready && authenticated && Boolean(
|
|
136
|
+
const fullyConnected = ready && authenticated && Boolean(walletAddress);
|
|
138
137
|
const refetch = (0, import_react2.useCallback)(async () => {
|
|
139
|
-
if (!
|
|
138
|
+
if (!walletAddress || !fullyConnected) {
|
|
140
139
|
return;
|
|
141
140
|
}
|
|
142
141
|
setState((s) => ({ ...s, loading: true }));
|
|
143
142
|
try {
|
|
144
143
|
const resp = await client.readEntity({
|
|
145
144
|
saleUUID,
|
|
146
|
-
walletAddress
|
|
145
|
+
walletAddress
|
|
147
146
|
});
|
|
148
147
|
setState({
|
|
149
148
|
loading: false,
|
|
@@ -164,7 +163,7 @@ function useSonarEntity(args) {
|
|
|
164
163
|
const error = err instanceof Error ? err : new Error(String(err));
|
|
165
164
|
setState({ loading: false, entity: void 0, error, hasFetched: true });
|
|
166
165
|
}
|
|
167
|
-
}, [client, saleUUID,
|
|
166
|
+
}, [client, saleUUID, walletAddress, fullyConnected]);
|
|
168
167
|
const reset = (0, import_react2.useCallback)(() => {
|
|
169
168
|
setState({
|
|
170
169
|
loading: false,
|
|
@@ -181,10 +180,10 @@ function useSonarEntity(args) {
|
|
|
181
180
|
}
|
|
182
181
|
}, [fullyConnected, state.hasFetched, state.loading, refetch]);
|
|
183
182
|
(0, import_react2.useEffect)(() => {
|
|
184
|
-
if (ready && (!authenticated || !
|
|
183
|
+
if (ready && (!authenticated || !walletAddress)) {
|
|
185
184
|
reset();
|
|
186
185
|
}
|
|
187
|
-
}, [ready, authenticated,
|
|
186
|
+
}, [ready, authenticated, walletAddress, reset]);
|
|
188
187
|
return {
|
|
189
188
|
authenticated,
|
|
190
189
|
loading: state.loading,
|
package/dist/index.d.cts
CHANGED
|
@@ -29,10 +29,6 @@ declare function SonarProvider({ children, config }: SonarProviderProps): react_
|
|
|
29
29
|
|
|
30
30
|
declare function useSonarAuth(): AuthContextValue;
|
|
31
31
|
declare function useSonarClient(): SonarClient;
|
|
32
|
-
type WalletConnection = {
|
|
33
|
-
address?: string;
|
|
34
|
-
isConnected: boolean;
|
|
35
|
-
};
|
|
36
32
|
type UseSonarEntityResult = {
|
|
37
33
|
authenticated: boolean;
|
|
38
34
|
loading: boolean;
|
|
@@ -41,7 +37,7 @@ type UseSonarEntityResult = {
|
|
|
41
37
|
};
|
|
42
38
|
declare function useSonarEntity(args: {
|
|
43
39
|
saleUUID: string;
|
|
44
|
-
|
|
40
|
+
walletAddress?: string;
|
|
45
41
|
}): UseSonarEntityResult;
|
|
46
42
|
|
|
47
|
-
export { SonarProvider, type SonarProviderConfig, type UseSonarEntityResult,
|
|
43
|
+
export { SonarProvider, type SonarProviderConfig, type UseSonarEntityResult, useSonarAuth, useSonarClient, useSonarEntity };
|
package/dist/index.d.ts
CHANGED
|
@@ -29,10 +29,6 @@ declare function SonarProvider({ children, config }: SonarProviderProps): react_
|
|
|
29
29
|
|
|
30
30
|
declare function useSonarAuth(): AuthContextValue;
|
|
31
31
|
declare function useSonarClient(): SonarClient;
|
|
32
|
-
type WalletConnection = {
|
|
33
|
-
address?: string;
|
|
34
|
-
isConnected: boolean;
|
|
35
|
-
};
|
|
36
32
|
type UseSonarEntityResult = {
|
|
37
33
|
authenticated: boolean;
|
|
38
34
|
loading: boolean;
|
|
@@ -41,7 +37,7 @@ type UseSonarEntityResult = {
|
|
|
41
37
|
};
|
|
42
38
|
declare function useSonarEntity(args: {
|
|
43
39
|
saleUUID: string;
|
|
44
|
-
|
|
40
|
+
walletAddress?: string;
|
|
45
41
|
}): UseSonarEntityResult;
|
|
46
42
|
|
|
47
|
-
export { SonarProvider, type SonarProviderConfig, type UseSonarEntityResult,
|
|
43
|
+
export { SonarProvider, type SonarProviderConfig, type UseSonarEntityResult, useSonarAuth, useSonarClient, useSonarEntity };
|
package/dist/index.js
CHANGED
|
@@ -99,22 +99,21 @@ function useSonarEntity(args) {
|
|
|
99
99
|
throw new Error("saleUUID is required");
|
|
100
100
|
}
|
|
101
101
|
const saleUUID = args.saleUUID;
|
|
102
|
-
const
|
|
103
|
-
const walletConnected = args.wallet.isConnected;
|
|
102
|
+
const walletAddress = args.walletAddress;
|
|
104
103
|
const [state, setState] = useState2({
|
|
105
104
|
loading: false,
|
|
106
105
|
hasFetched: false
|
|
107
106
|
});
|
|
108
|
-
const fullyConnected = ready && authenticated && Boolean(
|
|
107
|
+
const fullyConnected = ready && authenticated && Boolean(walletAddress);
|
|
109
108
|
const refetch = useCallback2(async () => {
|
|
110
|
-
if (!
|
|
109
|
+
if (!walletAddress || !fullyConnected) {
|
|
111
110
|
return;
|
|
112
111
|
}
|
|
113
112
|
setState((s) => ({ ...s, loading: true }));
|
|
114
113
|
try {
|
|
115
114
|
const resp = await client.readEntity({
|
|
116
115
|
saleUUID,
|
|
117
|
-
walletAddress
|
|
116
|
+
walletAddress
|
|
118
117
|
});
|
|
119
118
|
setState({
|
|
120
119
|
loading: false,
|
|
@@ -135,7 +134,7 @@ function useSonarEntity(args) {
|
|
|
135
134
|
const error = err instanceof Error ? err : new Error(String(err));
|
|
136
135
|
setState({ loading: false, entity: void 0, error, hasFetched: true });
|
|
137
136
|
}
|
|
138
|
-
}, [client, saleUUID,
|
|
137
|
+
}, [client, saleUUID, walletAddress, fullyConnected]);
|
|
139
138
|
const reset = useCallback2(() => {
|
|
140
139
|
setState({
|
|
141
140
|
loading: false,
|
|
@@ -152,10 +151,10 @@ function useSonarEntity(args) {
|
|
|
152
151
|
}
|
|
153
152
|
}, [fullyConnected, state.hasFetched, state.loading, refetch]);
|
|
154
153
|
useEffect2(() => {
|
|
155
|
-
if (ready && (!authenticated || !
|
|
154
|
+
if (ready && (!authenticated || !walletAddress)) {
|
|
156
155
|
reset();
|
|
157
156
|
}
|
|
158
|
-
}, [ready, authenticated,
|
|
157
|
+
}, [ready, authenticated, walletAddress, reset]);
|
|
159
158
|
return {
|
|
160
159
|
authenticated,
|
|
161
160
|
loading: state.loading,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@echoxyz/sonar-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"react": ">=18"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@echoxyz/sonar-core": "0.
|
|
19
|
+
"@echoxyz/sonar-core": "0.3.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@testing-library/react": "^16.0.0",
|