@libid/contracts 0.1.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/README.md +96 -0
- package/dist/abis/adminFacet.d.ts +339 -0
- package/dist/abis/adminFacet.d.ts.map +1 -0
- package/dist/abis/adminFacet.js +442 -0
- package/dist/abis/adminFacet.js.map +1 -0
- package/dist/abis/bank.d.ts +916 -0
- package/dist/abis/bank.d.ts.map +1 -0
- package/dist/abis/bank.js +1184 -0
- package/dist/abis/bank.js.map +1 -0
- package/dist/abis/diamondLoupeFacet.d.ts +73 -0
- package/dist/abis/diamondLoupeFacet.d.ts.map +1 -0
- package/dist/abis/diamondLoupeFacet.js +100 -0
- package/dist/abis/diamondLoupeFacet.js.map +1 -0
- package/dist/abis/gitHubIdentityVerifier.d.ts +451 -0
- package/dist/abis/gitHubIdentityVerifier.d.ts.map +1 -0
- package/dist/abis/gitHubIdentityVerifier.js +586 -0
- package/dist/abis/gitHubIdentityVerifier.js.map +1 -0
- package/dist/abis/googleIdentityVerifier.d.ts +373 -0
- package/dist/abis/googleIdentityVerifier.d.ts.map +1 -0
- package/dist/abis/googleIdentityVerifier.js +485 -0
- package/dist/abis/googleIdentityVerifier.js.map +1 -0
- package/dist/abis/googleOidcVerifier.d.ts +743 -0
- package/dist/abis/googleOidcVerifier.d.ts.map +1 -0
- package/dist/abis/googleOidcVerifier.js +962 -0
- package/dist/abis/googleOidcVerifier.js.map +1 -0
- package/dist/abis/identityJwksRoots.d.ts +515 -0
- package/dist/abis/identityJwksRoots.d.ts.map +1 -0
- package/dist/abis/identityJwksRoots.js +669 -0
- package/dist/abis/identityJwksRoots.js.map +1 -0
- package/dist/abis/identityNames.d.ts +614 -0
- package/dist/abis/identityNames.d.ts.map +1 -0
- package/dist/abis/identityNames.js +798 -0
- package/dist/abis/identityNames.js.map +1 -0
- package/dist/abis/index.d.ts +19 -0
- package/dist/abis/index.d.ts.map +1 -0
- package/dist/abis/index.js +21 -0
- package/dist/abis/index.js.map +1 -0
- package/dist/abis/mockErc20.d.ts +262 -0
- package/dist/abis/mockErc20.d.ts.map +1 -0
- package/dist/abis/mockErc20.js +347 -0
- package/dist/abis/mockErc20.js.map +1 -0
- package/dist/abis/notaryRegistry.d.ts +272 -0
- package/dist/abis/notaryRegistry.d.ts.map +1 -0
- package/dist/abis/notaryRegistry.js +355 -0
- package/dist/abis/notaryRegistry.js.map +1 -0
- package/dist/abis/registry.d.ts +1166 -0
- package/dist/abis/registry.d.ts.map +1 -0
- package/dist/abis/registry.js +1506 -0
- package/dist/abis/registry.js.map +1 -0
- package/dist/abis/transferFacet.d.ts +814 -0
- package/dist/abis/transferFacet.d.ts.map +1 -0
- package/dist/abis/transferFacet.js +1035 -0
- package/dist/abis/transferFacet.js.map +1 -0
- package/dist/abis/vaultFacet.d.ts +306 -0
- package/dist/abis/vaultFacet.d.ts.map +1 -0
- package/dist/abis/vaultFacet.js +398 -0
- package/dist/abis/vaultFacet.js.map +1 -0
- package/dist/abis/walletFactory.d.ts +325 -0
- package/dist/abis/walletFactory.d.ts.map +1 -0
- package/dist/abis/walletFactory.js +424 -0
- package/dist/abis/walletFactory.js.map +1 -0
- package/dist/abis/webWallet.d.ts +523 -0
- package/dist/abis/webWallet.d.ts.map +1 -0
- package/dist/abis/webWallet.js +680 -0
- package/dist/abis/webWallet.js.map +1 -0
- package/dist/abis/wtia9.d.ts +233 -0
- package/dist/abis/wtia9.d.ts.map +1 -0
- package/dist/abis/wtia9.js +304 -0
- package/dist/abis/wtia9.js.map +1 -0
- package/dist/abis/xIdentityVerifier.d.ts +487 -0
- package/dist/abis/xIdentityVerifier.d.ts.map +1 -0
- package/dist/abis/xIdentityVerifier.js +631 -0
- package/dist/abis/xIdentityVerifier.js.map +1 -0
- package/dist/abis/xZkVerifier.d.ts +586 -0
- package/dist/abis/xZkVerifier.d.ts.map +1 -0
- package/dist/abis/xZkVerifier.js +760 -0
- package/dist/abis/xZkVerifier.js.map +1 -0
- package/dist/identity/bind.d.ts +60 -0
- package/dist/identity/bind.d.ts.map +1 -0
- package/dist/identity/bind.fixtures.d.ts +8 -0
- package/dist/identity/bind.fixtures.d.ts.map +1 -0
- package/dist/identity/bind.fixtures.js +57 -0
- package/dist/identity/bind.fixtures.js.map +1 -0
- package/dist/identity/bind.js +119 -0
- package/dist/identity/bind.js.map +1 -0
- package/dist/identity/handle.d.ts +22 -0
- package/dist/identity/handle.d.ts.map +1 -0
- package/dist/identity/handle.js +137 -0
- package/dist/identity/handle.js.map +1 -0
- package/dist/identity/handleVectors.d.ts +53 -0
- package/dist/identity/handleVectors.d.ts.map +1 -0
- package/dist/identity/handleVectors.js +99 -0
- package/dist/identity/handleVectors.js.map +1 -0
- package/dist/identity/index.d.ts +5 -0
- package/dist/identity/index.d.ts.map +1 -0
- package/dist/identity/index.js +12 -0
- package/dist/identity/index.js.map +1 -0
- package/dist/identity/resolve.d.ts +16 -0
- package/dist/identity/resolve.d.ts.map +1 -0
- package/dist/identity/resolve.js +90 -0
- package/dist/identity/resolve.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/package.json +53 -0
- package/src/abis/adminFacet.ts +444 -0
- package/src/abis/bank.ts +1186 -0
- package/src/abis/diamondLoupeFacet.ts +102 -0
- package/src/abis/gitHubIdentityVerifier.ts +588 -0
- package/src/abis/googleIdentityVerifier.ts +487 -0
- package/src/abis/googleOidcVerifier.ts +964 -0
- package/src/abis/identityJwksRoots.ts +671 -0
- package/src/abis/identityNames.ts +800 -0
- package/src/abis/index.ts +20 -0
- package/src/abis/mockErc20.ts +349 -0
- package/src/abis/notaryRegistry.ts +357 -0
- package/src/abis/registry.ts +1508 -0
- package/src/abis/transferFacet.ts +1037 -0
- package/src/abis/vaultFacet.ts +400 -0
- package/src/abis/walletFactory.ts +426 -0
- package/src/abis/webWallet.ts +682 -0
- package/src/abis/wtia9.ts +306 -0
- package/src/abis/xIdentityVerifier.ts +633 -0
- package/src/abis/xZkVerifier.ts +762 -0
- package/src/identity/bind.fixtures.ts +65 -0
- package/src/identity/bind.ts +209 -0
- package/src/identity/handle.ts +170 -0
- package/src/identity/handleVectors.ts +115 -0
- package/src/identity/index.ts +12 -0
- package/src/identity/resolve.ts +141 -0
- package/src/index.ts +6 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/// Reading names from the chain.
|
|
2
|
+
///
|
|
3
|
+
/// Everything here is a view call. Binding a name needs a proof and a wallet;
|
|
4
|
+
/// reading one needs neither, which is the point — any product can resolve a
|
|
5
|
+
/// name without touching the login that created it.
|
|
6
|
+
///
|
|
7
|
+
/// The client and the contract address are arguments rather than imports. This
|
|
8
|
+
/// package ships separately from the repository it currently lives in, so it
|
|
9
|
+
/// carries no configuration of its own and reaches for nothing outside itself.
|
|
10
|
+
|
|
11
|
+
import { type Address, keccak256, type PublicClient, toHex, zeroAddress } from 'viem'
|
|
12
|
+
|
|
13
|
+
import { identityNamesAbi } from '../abis/identityNames.js'
|
|
14
|
+
|
|
15
|
+
/// A platform id is `keccak256` of its domain string. The domains are generated
|
|
16
|
+
/// from `handles.json`, so this and the contract agree by construction.
|
|
17
|
+
export function platformId(domain: string): `0x${string}` {
|
|
18
|
+
return keccak256(toHex(domain))
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface NamesReader {
|
|
22
|
+
client: PublicClient
|
|
23
|
+
/// The deployed `IdentityNames` contract.
|
|
24
|
+
address: Address
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/// One view call.
|
|
28
|
+
///
|
|
29
|
+
/// Routed through a narrow cast for the same reason the wallet package does it:
|
|
30
|
+
/// viem's `PublicClient`, without its chain type parameters, types
|
|
31
|
+
/// `authorizationList` as required even for a read. The alternative is to
|
|
32
|
+
/// spread that noise across every call site here.
|
|
33
|
+
function read<T>(reader: NamesReader, functionName: string, args: readonly unknown[]): Promise<T> {
|
|
34
|
+
return (
|
|
35
|
+
reader.client as unknown as {
|
|
36
|
+
readContract: (request: Record<string, unknown>) => Promise<T>
|
|
37
|
+
}
|
|
38
|
+
).readContract({
|
|
39
|
+
authorizationList: undefined,
|
|
40
|
+
address: reader.address,
|
|
41
|
+
abi: identityNamesAbi,
|
|
42
|
+
functionName,
|
|
43
|
+
args,
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/// The wallet that proved this account id, or `null`.
|
|
48
|
+
export async function resolveId(
|
|
49
|
+
reader: NamesReader,
|
|
50
|
+
platform: `0x${string}`,
|
|
51
|
+
userId: string,
|
|
52
|
+
): Promise<Address | null> {
|
|
53
|
+
const owner = await read<Address>(reader, 'resolveId', [platform, userId])
|
|
54
|
+
return owner === zeroAddress ? null : owner
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/// The wallet that last proved this handle, or `null`.
|
|
58
|
+
///
|
|
59
|
+
/// The handle is normalized on chain before it is looked up, so a caller may
|
|
60
|
+
/// pass what a user typed — including something that is not a handle at all.
|
|
61
|
+
/// The contract is total in the handle: a string no platform could hold answers
|
|
62
|
+
/// the zero address, which is the same answer as a handle nobody has proved,
|
|
63
|
+
/// and the one a search box wants.
|
|
64
|
+
///
|
|
65
|
+
/// A revert propagates. `UnknownPlatform` in particular means the platform is
|
|
66
|
+
/// not configured, and answering "unowned" would bury a deployment mistake
|
|
67
|
+
/// under a plausible result.
|
|
68
|
+
export async function resolveHandle(
|
|
69
|
+
reader: NamesReader,
|
|
70
|
+
platform: `0x${string}`,
|
|
71
|
+
handle: string,
|
|
72
|
+
): Promise<Address | null> {
|
|
73
|
+
const owner = await read<Address>(reader, 'resolveHandle', [platform, handle])
|
|
74
|
+
return owner === zeroAddress ? null : owner
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/// The handle a wallet published, exactly as stored.
|
|
78
|
+
///
|
|
79
|
+
/// It may be stale: it says what the wallet proved once, not what the handle
|
|
80
|
+
/// resolves to now. Use `primaryName` to display one.
|
|
81
|
+
export async function reverseOf(
|
|
82
|
+
reader: NamesReader,
|
|
83
|
+
wallet: Address,
|
|
84
|
+
platform: `0x${string}`,
|
|
85
|
+
): Promise<string | null> {
|
|
86
|
+
const name = await read<string>(reader, 'reverseOf', [wallet, platform])
|
|
87
|
+
return name.length === 0 ? null : name
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/// The handle to show for a wallet, or `null`.
|
|
91
|
+
///
|
|
92
|
+
/// Forward-checked on chain: empty once the stored handle resolves somewhere
|
|
93
|
+
/// else. ENS asks integrators to perform that check themselves and warns that
|
|
94
|
+
/// skipping it displays a name its holder no longer owns; here it cannot be
|
|
95
|
+
/// skipped, because the contract does it.
|
|
96
|
+
export async function primaryName(
|
|
97
|
+
reader: NamesReader,
|
|
98
|
+
wallet: Address,
|
|
99
|
+
platform: `0x${string}`,
|
|
100
|
+
): Promise<string | null> {
|
|
101
|
+
const name = await read<string>(reader, 'primaryOf', [wallet, platform])
|
|
102
|
+
return name.length === 0 ? null : name
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface PairResolution {
|
|
106
|
+
/// The current owner of the handle, or `null`.
|
|
107
|
+
wallet: Address | null
|
|
108
|
+
/// True only when the account id resolves to that same wallet.
|
|
109
|
+
///
|
|
110
|
+
/// False means the caller's `(handle, id)` pair comes from two moments:
|
|
111
|
+
/// somebody proved the handle after the caller learned who held it. That is
|
|
112
|
+
/// staleness, not corruption.
|
|
113
|
+
idAgrees: boolean
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/// Resolve a handle and report whether an account id still agrees with it.
|
|
117
|
+
///
|
|
118
|
+
/// **Read this before signing, and do not let it block a transfer.** A name
|
|
119
|
+
/// that will not route is not a name: sending to a handle means sending to
|
|
120
|
+
/// whoever proved it last, which is what the handle now means. What the flag is
|
|
121
|
+
/// for is telling a user that the account they think they are paying is not the
|
|
122
|
+
/// one that holds the name today — a decision they can only make beforehand.
|
|
123
|
+
///
|
|
124
|
+
/// Both halves are needed. A handle on its own has nothing to disagree with.
|
|
125
|
+
///
|
|
126
|
+
/// A handle the platform's rules reject resolves to `{wallet: null, idAgrees:
|
|
127
|
+
/// false}`, the same as one nobody has proved — see `resolveHandle`.
|
|
128
|
+
export async function resolvePair(
|
|
129
|
+
reader: NamesReader,
|
|
130
|
+
platform: `0x${string}`,
|
|
131
|
+
handle: string,
|
|
132
|
+
userId: string,
|
|
133
|
+
): Promise<PairResolution> {
|
|
134
|
+
const [wallet, idAgrees] = await read<[Address, boolean]>(reader, 'resolvePair', [
|
|
135
|
+
platform,
|
|
136
|
+
handle,
|
|
137
|
+
userId,
|
|
138
|
+
])
|
|
139
|
+
|
|
140
|
+
return { wallet: wallet === zeroAddress ? null : wallet, idAgrees }
|
|
141
|
+
}
|
package/src/index.ts
ADDED