Skip to content

Commit 076a08f

Browse files
committed
refactor: rename dataCallback to userInfo and update related logic
1 parent 3bb476b commit 076a08f

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

examples/testapp/src/pages/auto-sub-account/index.page.tsx

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ export default function AutoSubAccount() {
4848
const [walletConnectCapabilities, setWalletConnectCapabilities] = useState({
4949
siwe: false,
5050
addSubAccount: false,
51-
dataCallback: false,
51+
userInfo: false,
5252
});
53-
const [dataCallbackConfig, setDataCallbackConfig] = useState({
53+
const [userInfoConfig, setUserInfoConfig] = useState({
5454
email: true,
5555
name: true,
5656
phoneNumber: false,
@@ -204,7 +204,7 @@ export default function AutoSubAccount() {
204204
if (
205205
walletConnectCapabilities.siwe ||
206206
walletConnectCapabilities.addSubAccount ||
207-
walletConnectCapabilities.dataCallback
207+
walletConnectCapabilities.userInfo
208208
) {
209209
const capabilities: Record<string, unknown> = {};
210210

@@ -232,16 +232,16 @@ export default function AutoSubAccount() {
232232
};
233233
}
234234

235-
// Add dataCallback capability if selected
236-
if (walletConnectCapabilities.dataCallback) {
237-
const requests: Array<{ type: string; optional: boolean }> = [];
238-
if (dataCallbackConfig.email) requests.push({ type: 'email', optional: false });
239-
if (dataCallbackConfig.name) requests.push({ type: 'name', optional: false });
240-
if (dataCallbackConfig.phoneNumber) requests.push({ type: 'phoneNumber', optional: false });
235+
// Add userInfo capability if selected
236+
if (walletConnectCapabilities.userInfo) {
237+
const collect: string[] = [];
238+
if (userInfoConfig.email) collect.push('email');
239+
if (userInfoConfig.name) collect.push('name');
240+
if (userInfoConfig.phoneNumber) collect.push('phoneNumber');
241241

242-
if (requests.length > 0) {
243-
capabilities.dataCallback = {
244-
requests,
242+
if (collect.length > 0) {
243+
capabilities.userInfo = {
244+
collect,
245245
};
246246
}
247247
}
@@ -471,43 +471,43 @@ export default function AutoSubAccount() {
471471
Add Sub Account
472472
</Checkbox>
473473
<Checkbox
474-
isChecked={walletConnectCapabilities.dataCallback}
474+
isChecked={walletConnectCapabilities.userInfo}
475475
onChange={(e) =>
476476
setWalletConnectCapabilities((prev) => ({
477477
...prev,
478-
dataCallback: e.target.checked,
478+
userInfo: e.target.checked,
479479
}))
480480
}
481481
>
482-
Data Callback
482+
User Info
483483
</Checkbox>
484484

485-
{walletConnectCapabilities.dataCallback && (
485+
{walletConnectCapabilities.userInfo && (
486486
<VStack align="start" pl={2} spacing={2}>
487487
<Text fontSize="sm" color="gray.600" _dark={{ color: 'gray.300' }}>
488488
Select data to request (best-effort at connect time)
489489
</Text>
490490
<HStack wrap="wrap">
491491
<Checkbox
492-
isChecked={dataCallbackConfig.email}
492+
isChecked={userInfoConfig.email}
493493
onChange={(e) =>
494-
setDataCallbackConfig((prev) => ({ ...prev, email: e.target.checked }))
494+
setUserInfoConfig((prev) => ({ ...prev, email: e.target.checked }))
495495
}
496496
>
497497
email
498498
</Checkbox>
499499
<Checkbox
500-
isChecked={dataCallbackConfig.name}
500+
isChecked={userInfoConfig.name}
501501
onChange={(e) =>
502-
setDataCallbackConfig((prev) => ({ ...prev, name: e.target.checked }))
502+
setUserInfoConfig((prev) => ({ ...prev, name: e.target.checked }))
503503
}
504504
>
505505
name
506506
</Checkbox>
507507
<Checkbox
508-
isChecked={dataCallbackConfig.phoneNumber}
508+
isChecked={userInfoConfig.phoneNumber}
509509
onChange={(e) =>
510-
setDataCallbackConfig((prev) => ({
510+
setUserInfoConfig((prev) => ({
511511
...prev,
512512
phoneNumber: e.target.checked,
513513
}))

0 commit comments

Comments
 (0)