@echoxyz/sonar-react 0.13.3 → 0.14.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/CHANGELOG.md +11 -0
- package/dist/index.cjs +20 -8
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +20 -8
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -131,25 +131,28 @@ function useSonarEntity(args) {
|
|
|
131
131
|
throw new Error("saleUUID is required");
|
|
132
132
|
}
|
|
133
133
|
const saleUUID = args.saleUUID;
|
|
134
|
+
const entityID = args.entityID;
|
|
134
135
|
const walletAddress = args.walletAddress;
|
|
135
136
|
const [state, setState] = (0, import_react2.useState)({
|
|
136
137
|
loading: false,
|
|
137
138
|
hasFetched: false
|
|
138
139
|
});
|
|
139
|
-
const fullyConnected = ready && authenticated && Boolean(walletAddress);
|
|
140
|
+
const fullyConnected = ready && authenticated && (Boolean(entityID) || Boolean(walletAddress));
|
|
140
141
|
const refetch = (0, import_react2.useCallback)(async () => {
|
|
141
|
-
if (!walletAddress || !fullyConnected) {
|
|
142
|
+
if (!entityID && !walletAddress || !fullyConnected) {
|
|
142
143
|
return;
|
|
143
144
|
}
|
|
144
145
|
setState((s) => ({ ...s, loading: true }));
|
|
145
146
|
try {
|
|
146
147
|
const resp = await client.readEntity({
|
|
147
148
|
saleUUID,
|
|
149
|
+
entityID,
|
|
148
150
|
walletAddress
|
|
149
151
|
});
|
|
150
152
|
setState({
|
|
151
153
|
loading: false,
|
|
152
154
|
entity: resp.Entity,
|
|
155
|
+
entityID,
|
|
153
156
|
walletAddress,
|
|
154
157
|
error: void 0,
|
|
155
158
|
hasFetched: true
|
|
@@ -159,6 +162,7 @@ function useSonarEntity(args) {
|
|
|
159
162
|
setState({
|
|
160
163
|
loading: false,
|
|
161
164
|
entity: void 0,
|
|
165
|
+
entityID: void 0,
|
|
162
166
|
walletAddress: void 0,
|
|
163
167
|
error: void 0,
|
|
164
168
|
hasFetched: true
|
|
@@ -166,28 +170,36 @@ function useSonarEntity(args) {
|
|
|
166
170
|
return;
|
|
167
171
|
}
|
|
168
172
|
const error = err instanceof Error ? err : new Error(String(err));
|
|
169
|
-
setState({
|
|
173
|
+
setState({
|
|
174
|
+
loading: false,
|
|
175
|
+
entity: void 0,
|
|
176
|
+
entityID: void 0,
|
|
177
|
+
walletAddress: void 0,
|
|
178
|
+
error,
|
|
179
|
+
hasFetched: true
|
|
180
|
+
});
|
|
170
181
|
}
|
|
171
|
-
}, [client, saleUUID, walletAddress, fullyConnected]);
|
|
182
|
+
}, [client, saleUUID, entityID, walletAddress, fullyConnected]);
|
|
172
183
|
const reset = (0, import_react2.useCallback)(() => {
|
|
173
184
|
setState({
|
|
174
185
|
loading: false,
|
|
175
186
|
hasFetched: false,
|
|
176
187
|
entity: void 0,
|
|
188
|
+
entityID: void 0,
|
|
177
189
|
walletAddress: void 0,
|
|
178
190
|
error: void 0
|
|
179
191
|
});
|
|
180
192
|
}, []);
|
|
181
193
|
(0, import_react2.useEffect)(() => {
|
|
182
|
-
if (fullyConnected && state.walletAddress !== walletAddress) {
|
|
194
|
+
if (fullyConnected && (state.entityID !== entityID || state.walletAddress !== walletAddress)) {
|
|
183
195
|
refetch();
|
|
184
196
|
}
|
|
185
|
-
}, [fullyConnected, state.walletAddress, walletAddress, refetch]);
|
|
197
|
+
}, [fullyConnected, state.entityID, entityID, state.walletAddress, walletAddress, refetch]);
|
|
186
198
|
(0, import_react2.useEffect)(() => {
|
|
187
|
-
if (ready && (!authenticated || !walletAddress)) {
|
|
199
|
+
if (ready && (!authenticated || !entityID && !walletAddress)) {
|
|
188
200
|
reset();
|
|
189
201
|
}
|
|
190
|
-
}, [ready, authenticated, walletAddress, reset]);
|
|
202
|
+
}, [ready, authenticated, entityID, walletAddress, reset]);
|
|
191
203
|
return {
|
|
192
204
|
authenticated,
|
|
193
205
|
loading: state.loading,
|
package/dist/index.d.cts
CHANGED
|
@@ -36,6 +36,8 @@ type UseSonarEntityResult = {
|
|
|
36
36
|
};
|
|
37
37
|
declare function useSonarEntity(args: {
|
|
38
38
|
saleUUID: string;
|
|
39
|
+
entityID?: string;
|
|
40
|
+
/** Only used for a wallet linking feature, enabled for niche use-cases on request. */
|
|
39
41
|
walletAddress?: string;
|
|
40
42
|
}): UseSonarEntityResult;
|
|
41
43
|
type UseSonarEntitiesResult = {
|
package/dist/index.d.ts
CHANGED
|
@@ -36,6 +36,8 @@ type UseSonarEntityResult = {
|
|
|
36
36
|
};
|
|
37
37
|
declare function useSonarEntity(args: {
|
|
38
38
|
saleUUID: string;
|
|
39
|
+
entityID?: string;
|
|
40
|
+
/** Only used for a wallet linking feature, enabled for niche use-cases on request. */
|
|
39
41
|
walletAddress?: string;
|
|
40
42
|
}): UseSonarEntityResult;
|
|
41
43
|
type UseSonarEntitiesResult = {
|
package/dist/index.js
CHANGED
|
@@ -99,25 +99,28 @@ function useSonarEntity(args) {
|
|
|
99
99
|
throw new Error("saleUUID is required");
|
|
100
100
|
}
|
|
101
101
|
const saleUUID = args.saleUUID;
|
|
102
|
+
const entityID = args.entityID;
|
|
102
103
|
const walletAddress = args.walletAddress;
|
|
103
104
|
const [state, setState] = useState2({
|
|
104
105
|
loading: false,
|
|
105
106
|
hasFetched: false
|
|
106
107
|
});
|
|
107
|
-
const fullyConnected = ready && authenticated && Boolean(walletAddress);
|
|
108
|
+
const fullyConnected = ready && authenticated && (Boolean(entityID) || Boolean(walletAddress));
|
|
108
109
|
const refetch = useCallback2(async () => {
|
|
109
|
-
if (!walletAddress || !fullyConnected) {
|
|
110
|
+
if (!entityID && !walletAddress || !fullyConnected) {
|
|
110
111
|
return;
|
|
111
112
|
}
|
|
112
113
|
setState((s) => ({ ...s, loading: true }));
|
|
113
114
|
try {
|
|
114
115
|
const resp = await client.readEntity({
|
|
115
116
|
saleUUID,
|
|
117
|
+
entityID,
|
|
116
118
|
walletAddress
|
|
117
119
|
});
|
|
118
120
|
setState({
|
|
119
121
|
loading: false,
|
|
120
122
|
entity: resp.Entity,
|
|
123
|
+
entityID,
|
|
121
124
|
walletAddress,
|
|
122
125
|
error: void 0,
|
|
123
126
|
hasFetched: true
|
|
@@ -127,6 +130,7 @@ function useSonarEntity(args) {
|
|
|
127
130
|
setState({
|
|
128
131
|
loading: false,
|
|
129
132
|
entity: void 0,
|
|
133
|
+
entityID: void 0,
|
|
130
134
|
walletAddress: void 0,
|
|
131
135
|
error: void 0,
|
|
132
136
|
hasFetched: true
|
|
@@ -134,28 +138,36 @@ function useSonarEntity(args) {
|
|
|
134
138
|
return;
|
|
135
139
|
}
|
|
136
140
|
const error = err instanceof Error ? err : new Error(String(err));
|
|
137
|
-
setState({
|
|
141
|
+
setState({
|
|
142
|
+
loading: false,
|
|
143
|
+
entity: void 0,
|
|
144
|
+
entityID: void 0,
|
|
145
|
+
walletAddress: void 0,
|
|
146
|
+
error,
|
|
147
|
+
hasFetched: true
|
|
148
|
+
});
|
|
138
149
|
}
|
|
139
|
-
}, [client, saleUUID, walletAddress, fullyConnected]);
|
|
150
|
+
}, [client, saleUUID, entityID, walletAddress, fullyConnected]);
|
|
140
151
|
const reset = useCallback2(() => {
|
|
141
152
|
setState({
|
|
142
153
|
loading: false,
|
|
143
154
|
hasFetched: false,
|
|
144
155
|
entity: void 0,
|
|
156
|
+
entityID: void 0,
|
|
145
157
|
walletAddress: void 0,
|
|
146
158
|
error: void 0
|
|
147
159
|
});
|
|
148
160
|
}, []);
|
|
149
161
|
useEffect2(() => {
|
|
150
|
-
if (fullyConnected && state.walletAddress !== walletAddress) {
|
|
162
|
+
if (fullyConnected && (state.entityID !== entityID || state.walletAddress !== walletAddress)) {
|
|
151
163
|
refetch();
|
|
152
164
|
}
|
|
153
|
-
}, [fullyConnected, state.walletAddress, walletAddress, refetch]);
|
|
165
|
+
}, [fullyConnected, state.entityID, entityID, state.walletAddress, walletAddress, refetch]);
|
|
154
166
|
useEffect2(() => {
|
|
155
|
-
if (ready && (!authenticated || !walletAddress)) {
|
|
167
|
+
if (ready && (!authenticated || !entityID && !walletAddress)) {
|
|
156
168
|
reset();
|
|
157
169
|
}
|
|
158
|
-
}, [ready, authenticated, walletAddress, reset]);
|
|
170
|
+
}, [ready, authenticated, entityID, walletAddress, reset]);
|
|
159
171
|
return {
|
|
160
172
|
authenticated,
|
|
161
173
|
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.14.0",
|
|
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.15.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@testing-library/react": "^16.0.0",
|