Skip to content

Commit

Permalink
Update SIP-12 (#107)
Browse files Browse the repository at this point in the history
* update types

* added more language to specify return values
  • Loading branch information
hmalik88 authored Sep 22, 2023
1 parent e45f40b commit 24c1ce3
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions SIPS/sip-12.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ export const onNameLookup: OnNameLookupHandler = async ({
address
}) => {
if (domain) {
return { resolution: /* Get domain resolution */ }
return { resolvedAddress: /* Get domain resolution */ }
}

if (address) {
return { resolution: /* Get address resolution */ };
return { resolvedDomain: /* Get address resolution */ };
}

return null;
Expand All @@ -89,8 +89,8 @@ type OnNameLookupBaseArgs = {
chainId: ChainId
}

type DomainLookupArgs = OnNameLookUpBaseArgs & { domain: string, address: undefined };
type AddressLookupArgs = OnNameLookUpBaseArgs & { address: string, domain: undefined };
type DomainLookupArgs = OnNameLookUpBaseArgs & { domain: string; address?: never };
type AddressLookupArgs = OnNameLookUpBaseArgs & { address: string; domain?: never };

type OnNameLookupArgs = DomainLookupArgs | AddressLookupArgs;

Expand All @@ -107,12 +107,17 @@ the request is looking for resolution to a domain.
The interface for the return value of an `onNameLookup` export is:

```typescript
type Domain = string;

type OnNameLookupResponse = {
resolution: AccountAddress | Domain | null;
} | null;
type OnNameLookupResponse =
| {
resolvedAddress: AccountAddress;
resolvedDomain?: never;
}
| { resolvedDomain: string; resolvedAddress?: never }
| null;
```

**Note:** `resolvedDomain` and `resolvedAddress` MUST be the keys that the resolved address/domain being queried is indexed by in the protocol that the snap is resolving for. These returned values are un-opinionated at the API layer to allow the client to use them as they see fit.

## Copyright

Copyright and related rights waived via [CC0](../LICENSE).

0 comments on commit 24c1ce3

Please sign in to comment.