Skip to content

Commit 10a0e90

Browse files
committed
fix(docs): update getXrplAccountForAddress function to return a default address for non-existent accounts
1 parent 699d078 commit 10a0e90

1 file changed

Lines changed: 12 additions & 15 deletions

File tree

docs/smart-accounts/guides/typescript-viem/01-state-lookup.mdx

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -141,24 +141,21 @@ If the call succeeds and returns a non-empty and valid XRPL address, the address
141141
```typescript
142142
export async function getXrplAccountForAddress(
143143
evmAddress: Address,
144-
): Promise<string | null> {
145-
try {
146-
const xrplOwner = await publicClient.readContract({
147-
address: evmAddress,
148-
// Use the IPersonalAccount interface
149-
abi: coston2.iPersonalAccountAbi,
150-
functionName: "xrplOwner",
151-
args: [],
152-
});
153-
return xrplOwner && xrplOwner.length > 0 ? xrplOwner : null;
154-
} catch {
155-
return null;
156-
}
144+
): Promise<`0x${string}`> {
145+
const xrplOwner = await publicClient.readContract({
146+
address: evmAddress,
147+
abi: coston2.iPersonalAccountAbi,
148+
functionName: "xrplOwner",
149+
args: [],
150+
});
151+
return xrplOwner && xrplOwner.length > 0
152+
? evmAddress
153+
: "0x0000000000000000000000000000000000000000";
157154
}
158155
159156
export async function isSmartAccount(evmAddress: Address): Promise<boolean> {
160-
const xrplAccount = await getXrplAccountForAddress(evmAddress);
161-
return xrplAccount !== null;
157+
const smartAccountAddress = await getXrplAccountForAddress(evmAddress);
158+
return smartAccountAddress !== "0x0000000000000000000000000000000000000000";
162159
}
163160
```
164161

0 commit comments

Comments
 (0)