@poa-box/core 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 +201 -0
- package/dist/abis/DirectDemocracyVotingNew.d.ts +749 -0
- package/dist/abis/DirectDemocracyVotingNew.js +961 -0
- package/dist/abis/ERC20.d.ts +90 -0
- package/dist/abis/ERC20.js +125 -0
- package/dist/abis/EducationHubNew.d.ts +590 -0
- package/dist/abis/EducationHubNew.js +762 -0
- package/dist/abis/EligibilityModuleNew.d.ts +1615 -0
- package/dist/abis/EligibilityModuleNew.js +2082 -0
- package/dist/abis/Executor.d.ts +619 -0
- package/dist/abis/Executor.js +796 -0
- package/dist/abis/HybridVotingNew.d.ts +898 -0
- package/dist/abis/HybridVotingNew.js +1149 -0
- package/dist/abis/ImplementationRegistry.d.ts +270 -0
- package/dist/abis/ImplementationRegistry.js +355 -0
- package/dist/abis/OrgDeployerNew.d.ts +1275 -0
- package/dist/abis/OrgDeployerNew.js +1630 -0
- package/dist/abis/OrgRegistry.d.ts +670 -0
- package/dist/abis/OrgRegistry.js +868 -0
- package/dist/abis/ParticipationToken.d.ts +1086 -0
- package/dist/abis/ParticipationToken.js +1415 -0
- package/dist/abis/PasskeyAccount.d.ts +788 -0
- package/dist/abis/PasskeyAccount.js +1019 -0
- package/dist/abis/PasskeyAccountFactory.d.ts +344 -0
- package/dist/abis/PasskeyAccountFactory.js +449 -0
- package/dist/abis/PaymasterHub.d.ts +1603 -0
- package/dist/abis/PaymasterHub.js +2048 -0
- package/dist/abis/PaymentManager.d.ts +520 -0
- package/dist/abis/PaymentManager.js +671 -0
- package/dist/abis/PoaManager.d.ts +344 -0
- package/dist/abis/PoaManager.js +449 -0
- package/dist/abis/QuickJoinNew.d.ts +855 -0
- package/dist/abis/QuickJoinNew.js +1098 -0
- package/dist/abis/TaskManagerNew.d.ts +1236 -0
- package/dist/abis/TaskManagerNew.js +1573 -0
- package/dist/abis/ToggleModule.d.ts +193 -0
- package/dist/abis/ToggleModule.js +255 -0
- package/dist/abis/UniversalAccountRegistry.d.ts +577 -0
- package/dist/abis/UniversalAccountRegistry.js +750 -0
- package/dist/abis/ZkEmailInvites.d.ts +823 -0
- package/dist/abis/ZkEmailInvites.js +1060 -0
- package/dist/abis/external/AaveGovernanceV2.d.ts +128 -0
- package/dist/abis/external/AaveGovernanceV2.js +177 -0
- package/dist/abis/external/AaveGovernanceV3.d.ts +160 -0
- package/dist/abis/external/AaveGovernanceV3.js +220 -0
- package/dist/abis/external/AragonVoting.d.ts +107 -0
- package/dist/abis/external/AragonVoting.js +150 -0
- package/dist/abis/external/CurveGaugeController.d.ts +95 -0
- package/dist/abis/external/CurveGaugeController.js +130 -0
- package/dist/abis/external/CurveVotingEscrow.d.ts +86 -0
- package/dist/abis/external/CurveVotingEscrow.js +116 -0
- package/dist/abis/external/GovernorAlpha.d.ts +172 -0
- package/dist/abis/external/GovernorAlpha.js +228 -0
- package/dist/abis/external/MakerDAOChief.d.ts +92 -0
- package/dist/abis/external/MakerDAOChief.js +129 -0
- package/dist/abis/external/OZGovernor.d.ts +227 -0
- package/dist/abis/external/OZGovernor.js +317 -0
- package/dist/abis/external/SolidlyVotingEscrow.d.ts +196 -0
- package/dist/abis/external/SolidlyVotingEscrow.js +260 -0
- package/dist/abis/index.d.ts +62 -0
- package/dist/abis/index.js +98 -0
- package/dist/chains.d.ts +150 -0
- package/dist/chains.js +320 -0
- package/dist/context.d.ts +48 -0
- package/dist/context.js +38 -0
- package/dist/contracts.d.ts +24 -0
- package/dist/contracts.js +41 -0
- package/dist/encoding.d.ts +58 -0
- package/dist/encoding.js +243 -0
- package/dist/env.d.ts +10 -0
- package/dist/env.js +4 -0
- package/dist/error-catalog.d.ts +41 -0
- package/dist/error-catalog.js +941 -0
- package/dist/errors.d.ts +27 -0
- package/dist/errors.js +60 -0
- package/dist/execute/ethers.d.ts +93 -0
- package/dist/execute/ethers.js +323 -0
- package/dist/execute/index.d.ts +7 -0
- package/dist/execute/index.js +23 -0
- package/dist/execute/sponsored.d.ts +68 -0
- package/dist/execute/sponsored.js +277 -0
- package/dist/exit-codes.d.ts +18 -0
- package/dist/exit-codes.js +21 -0
- package/dist/format.d.ts +21 -0
- package/dist/format.js +89 -0
- package/dist/graph/client.d.ts +298 -0
- package/dist/graph/client.js +702 -0
- package/dist/graph/documents/activity.d.ts +9 -0
- package/dist/graph/documents/activity.js +164 -0
- package/dist/graph/documents/beacons.d.ts +172 -0
- package/dist/graph/documents/beacons.js +345 -0
- package/dist/graph/documents/index.d.ts +21 -0
- package/dist/graph/documents/index.js +57 -0
- package/dist/graph/documents/infrastructure.d.ts +30 -0
- package/dist/graph/documents/infrastructure.js +34 -0
- package/dist/graph/documents/org.d.ts +15 -0
- package/dist/graph/documents/org.js +249 -0
- package/dist/graph/documents/paymaster.d.ts +95 -0
- package/dist/graph/documents/paymaster.js +101 -0
- package/dist/graph/documents/role.d.ts +6 -0
- package/dist/graph/documents/role.js +41 -0
- package/dist/graph/documents/roles.d.ts +50 -0
- package/dist/graph/documents/roles.js +112 -0
- package/dist/graph/documents/task.d.ts +84 -0
- package/dist/graph/documents/task.js +236 -0
- package/dist/graph/documents/token.d.ts +13 -0
- package/dist/graph/documents/token.js +126 -0
- package/dist/graph/documents/treasury.d.ts +39 -0
- package/dist/graph/documents/treasury.js +136 -0
- package/dist/graph/documents/user.d.ts +120 -0
- package/dist/graph/documents/user.js +302 -0
- package/dist/graph/documents/voting-classes.d.ts +69 -0
- package/dist/graph/documents/voting-classes.js +149 -0
- package/dist/graph/documents/voting.d.ts +28 -0
- package/dist/graph/documents/voting.js +163 -0
- package/dist/graph/documents/vouch.d.ts +79 -0
- package/dist/graph/documents/vouch.js +171 -0
- package/dist/graph/documents/zkemail.d.ts +63 -0
- package/dist/graph/documents/zkemail.js +188 -0
- package/dist/graph/index.d.ts +2 -0
- package/dist/graph/index.js +41 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.js +92 -0
- package/dist/ipfs.d.ts +39 -0
- package/dist/ipfs.js +214 -0
- package/dist/label-aliases.d.ts +31 -0
- package/dist/label-aliases.js +70 -0
- package/dist/metadata/education.d.ts +30 -0
- package/dist/metadata/education.js +31 -0
- package/dist/metadata/index.d.ts +12 -0
- package/dist/metadata/index.js +48 -0
- package/dist/metadata/org.d.ts +92 -0
- package/dist/metadata/org.js +93 -0
- package/dist/metadata/proposal.d.ts +44 -0
- package/dist/metadata/proposal.js +45 -0
- package/dist/metadata/role.d.ts +38 -0
- package/dist/metadata/role.js +35 -0
- package/dist/metadata/task.d.ts +108 -0
- package/dist/metadata/task.js +81 -0
- package/dist/metadata/token.d.ts +32 -0
- package/dist/metadata/token.js +36 -0
- package/dist/metadata/user.d.ts +63 -0
- package/dist/metadata/user.js +70 -0
- package/dist/multicall.d.ts +32 -0
- package/dist/multicall.js +96 -0
- package/dist/payout.d.ts +59 -0
- package/dist/payout.js +96 -0
- package/dist/perms.d.ts +47 -0
- package/dist/perms.js +120 -0
- package/dist/preflight.d.ts +72 -0
- package/dist/preflight.js +269 -0
- package/dist/reads/education.d.ts +79 -0
- package/dist/reads/education.js +122 -0
- package/dist/reads/eligibility.d.ts +377 -0
- package/dist/reads/eligibility.js +687 -0
- package/dist/reads/index.d.ts +16 -0
- package/dist/reads/index.js +55 -0
- package/dist/reads/org.d.ts +258 -0
- package/dist/reads/org.js +220 -0
- package/dist/reads/paymaster.d.ts +147 -0
- package/dist/reads/paymaster.js +235 -0
- package/dist/reads/project.d.ts +33 -0
- package/dist/reads/project.js +62 -0
- package/dist/reads/resolve.d.ts +34 -0
- package/dist/reads/resolve.js +64 -0
- package/dist/reads/task.d.ts +286 -0
- package/dist/reads/task.js +280 -0
- package/dist/reads/token.d.ts +94 -0
- package/dist/reads/token.js +75 -0
- package/dist/reads/treasury.d.ts +222 -0
- package/dist/reads/treasury.js +241 -0
- package/dist/reads/user.d.ts +229 -0
- package/dist/reads/user.js +155 -0
- package/dist/reads/vote.d.ts +296 -0
- package/dist/reads/vote.js +392 -0
- package/dist/reads/zkemail.d.ts +117 -0
- package/dist/reads/zkemail.js +217 -0
- package/dist/similarity.d.ts +36 -0
- package/dist/similarity.js +67 -0
- package/dist/sponsorship-config.d.ts +47 -0
- package/dist/sponsorship-config.js +41 -0
- package/dist/stats.d.ts +11 -0
- package/dist/stats.js +27 -0
- package/dist/task-lens.d.ts +113 -0
- package/dist/task-lens.js +210 -0
- package/dist/tx/education.d.ts +169 -0
- package/dist/tx/education.js +344 -0
- package/dist/tx/eligibility.d.ts +511 -0
- package/dist/tx/eligibility.js +818 -0
- package/dist/tx/governance.d.ts +85 -0
- package/dist/tx/governance.js +87 -0
- package/dist/tx/index.d.ts +17 -0
- package/dist/tx/index.js +56 -0
- package/dist/tx/intent.d.ts +67 -0
- package/dist/tx/intent.js +48 -0
- package/dist/tx/org.d.ts +321 -0
- package/dist/tx/org.js +544 -0
- package/dist/tx/paymaster.d.ts +140 -0
- package/dist/tx/paymaster.js +251 -0
- package/dist/tx/project.d.ts +146 -0
- package/dist/tx/project.js +217 -0
- package/dist/tx/task.d.ts +480 -0
- package/dist/tx/task.js +1149 -0
- package/dist/tx/token.d.ts +96 -0
- package/dist/tx/token.js +165 -0
- package/dist/tx/treasury.d.ts +474 -0
- package/dist/tx/treasury.js +911 -0
- package/dist/tx/user.d.ts +177 -0
- package/dist/tx/user.js +292 -0
- package/dist/tx/vote.d.ts +332 -0
- package/dist/tx/vote.js +762 -0
- package/dist/tx/zkemail.d.ts +90 -0
- package/dist/tx/zkemail.js +210 -0
- package/dist/validation.d.ts +8 -0
- package/dist/validation.js +39 -0
- package/dist/version.d.ts +142 -0
- package/dist/version.js +257 -0
- package/dist/zkemail.d.ts +161 -0
- package/dist/zkemail.js +299 -0
- package/package.json +130 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User write builders — UniversalAccountRegistry (registerAccount /
|
|
3
|
+
* changeUsername / setProfileMetadata) and QuickJoinNew (quickJoinWithUser /
|
|
4
|
+
* claimHatsWithUser).
|
|
5
|
+
*
|
|
6
|
+
* Level 1: pure, sync builders taking resolved addresses + prepared values.
|
|
7
|
+
* Level 2: async `<action>Intent(ctx, params)` builders that resolve the
|
|
8
|
+
* registry / QuickJoin address via the subgraph, merge + pin profile
|
|
9
|
+
* metadata, and delegate to Level 1.
|
|
10
|
+
*
|
|
11
|
+
* Chain semantics (preserved CLI behavior): usernames and profile metadata
|
|
12
|
+
* are HOME-CHAIN account-registry state, so the registry-scoped Level-2
|
|
13
|
+
* builders default to HOME_CHAIN_ID — deliberately IGNORING ctx.chainId (the
|
|
14
|
+
* CLI ignores POP_DEFAULT_CHAIN the same way; an explicit `chainId` param
|
|
15
|
+
* wins). The org-scoped QuickJoin builders use ctx.chainId as usual.
|
|
16
|
+
*
|
|
17
|
+
* NOT ported (CLI-side revert prediction / flow UX): checkUsernameFree,
|
|
18
|
+
* AccountUnknown prediction, the live re-read of quickJoin.accountRegistry()
|
|
19
|
+
* before a 2-tx join (a write-target pointer that updateAddresses can
|
|
20
|
+
* re-point — see src/commands/user/join.ts), and the claim-hats Multicall3
|
|
21
|
+
* probes (NoUsername / MAX_HATS_PER_MINT / HatOpenlyClaimable sentinel).
|
|
22
|
+
*/
|
|
23
|
+
import { ethers } from 'ethers';
|
|
24
|
+
import type { TxIntent } from './intent';
|
|
25
|
+
import type { PopContext } from '../context';
|
|
26
|
+
import { UserProfileUpdates } from '../metadata/user';
|
|
27
|
+
/**
|
|
28
|
+
* Parse a comma-separated hat-ID list into BigNumbers. Accepts decimal and
|
|
29
|
+
* 0x-hex forms. Hats Protocol IDs are uint256 — far beyond 2^53 — so
|
|
30
|
+
* parseInt/Number would silently corrupt them.
|
|
31
|
+
* Port of parseHatIds in `pop user claim-hats` —
|
|
32
|
+
* src/commands/user/claim-hats.ts (same messages and exit codes).
|
|
33
|
+
*/
|
|
34
|
+
export declare function parseHatIds(input: string): ethers.BigNumber[];
|
|
35
|
+
export interface RegisterAccountArgs {
|
|
36
|
+
/** UniversalAccountRegistry address (home chain unless overridden). */
|
|
37
|
+
registryAddress: string;
|
|
38
|
+
/** Validated username (3-32 alphanumeric+underscore — requireValidUsername). */
|
|
39
|
+
username: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Port of `pop user register` — src/commands/user/register.ts (also tx 1 of
|
|
43
|
+
* the 2-tx `pop user join` flow — src/commands/user/join.ts).
|
|
44
|
+
* UniversalAccountRegistry.registerAccount(string username); reverts
|
|
45
|
+
* UsernameTaken when the name is held. For the join flow, register on the
|
|
46
|
+
* SAME registry the org's QuickJoin consults (quickJoin.accountRegistry(),
|
|
47
|
+
* re-read live in the CLI) — registering anywhere else leaves
|
|
48
|
+
* quickJoinWithUser reverting NoUsername.
|
|
49
|
+
*/
|
|
50
|
+
export declare function buildRegisterAccount(a: RegisterAccountArgs): TxIntent;
|
|
51
|
+
export interface ChangeUsernameArgs {
|
|
52
|
+
registryAddress: string;
|
|
53
|
+
/** Validated new username. */
|
|
54
|
+
newUsername: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Port of `pop user update-profile --username` —
|
|
58
|
+
* src/commands/user/update-profile.ts.
|
|
59
|
+
* UniversalAccountRegistry.changeUsername(string newUsername) — DESTRUCTIVE:
|
|
60
|
+
* the old username is released for anyone to claim the moment the tx lands.
|
|
61
|
+
* Reverts AccountUnknown without an existing registration and UsernameTaken
|
|
62
|
+
* when the new name is held.
|
|
63
|
+
*/
|
|
64
|
+
export declare function buildChangeUsername(a: ChangeUsernameArgs): TxIntent;
|
|
65
|
+
export interface SetProfileMetadataArgs {
|
|
66
|
+
registryAddress: string;
|
|
67
|
+
/** bytes32 metadata hash — ipfsCidToBytes32 of the pinned profile document. */
|
|
68
|
+
metadataHash: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Port of the metadata tx of `pop user update-profile` —
|
|
72
|
+
* src/commands/user/update-profile.ts.
|
|
73
|
+
* UniversalAccountRegistry.setProfileMetadata(bytes32 metadataHash), where
|
|
74
|
+
* metadataHash = ipfsCidToBytes32(pinJson(serialized profile document)).
|
|
75
|
+
*/
|
|
76
|
+
export declare function buildSetProfileMetadata(a: SetProfileMetadataArgs): TxIntent;
|
|
77
|
+
export interface QuickJoinWithUserArgs {
|
|
78
|
+
quickJoinAddress: string;
|
|
79
|
+
orgId?: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Port of `pop user join` (the join tx) — src/commands/user/join.ts.
|
|
83
|
+
* QuickJoinNew.quickJoinWithUser() — NO arguments. The contract reads
|
|
84
|
+
* accountRegistry.getUsername(msg.sender) and reverts NoUsername when it is
|
|
85
|
+
* empty, so the sender must already hold a username on the registry this
|
|
86
|
+
* QuickJoin consults (register first via buildRegisterAccount when needed).
|
|
87
|
+
*/
|
|
88
|
+
export declare function buildQuickJoinWithUser(a: QuickJoinWithUserArgs): TxIntent;
|
|
89
|
+
export interface ClaimHatsWithUserArgs {
|
|
90
|
+
quickJoinAddress: string;
|
|
91
|
+
/** uint256 hat IDs — parse strings with parseHatIds, never parseInt. */
|
|
92
|
+
hatIds: ethers.BigNumber[];
|
|
93
|
+
orgId?: string;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Port of `pop user claim-hats` — src/commands/user/claim-hats.ts.
|
|
97
|
+
* QuickJoinNew.claimHatsWithUser(uint256[] claimHatIds). The caller must
|
|
98
|
+
* already have a username (reverts NoUsername); since audit H-03 QuickJoin
|
|
99
|
+
* refuses openly-claimable hats (reverts HatOpenlyClaimable), and the
|
|
100
|
+
* executor bounds the batch at MAX_HATS_PER_MINT.
|
|
101
|
+
*/
|
|
102
|
+
export declare function buildClaimHatsWithUser(a: ClaimHatsWithUserArgs): TxIntent;
|
|
103
|
+
export interface RegisterAccountParams {
|
|
104
|
+
username: string;
|
|
105
|
+
/** Registry chain. Defaults to HOME_CHAIN_ID (Arbitrum) — NOT ctx.chainId. */
|
|
106
|
+
chainId?: number;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Resolved builder for `pop user register` — src/commands/user/register.ts.
|
|
110
|
+
* Validates the username, resolves the UniversalAccountRegistry address from
|
|
111
|
+
* the infrastructure subgraph (universalAccountRegistries[0].id, falling back
|
|
112
|
+
* to poaManagerContracts[0].globalAccountRegistryProxy), then builds the
|
|
113
|
+
* registerAccount intent. Defaults to the HOME chain, deliberately ignoring
|
|
114
|
+
* ctx.chainId — usernames live on the home chain (the CLI ignores
|
|
115
|
+
* POP_DEFAULT_CHAIN the same way).
|
|
116
|
+
*/
|
|
117
|
+
export declare function registerAccountIntent(ctx: PopContext, params: RegisterAccountParams): Promise<TxIntent>;
|
|
118
|
+
export interface ChangeUsernameParams {
|
|
119
|
+
/** The account being renamed (the eventual tx sender). */
|
|
120
|
+
address: string;
|
|
121
|
+
newUsername: string;
|
|
122
|
+
/** Registry chain. Defaults to HOME_CHAIN_ID — NOT ctx.chainId. */
|
|
123
|
+
chainId?: number;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Resolved builder for the username tx of `pop user update-profile` —
|
|
127
|
+
* src/commands/user/update-profile.ts. DESTRUCTIVE: the old username is
|
|
128
|
+
* released on-chain for anyone to claim. Resolves the registry from the same
|
|
129
|
+
* one-round-trip document the CLI uses. The CLI's AccountUnknown /
|
|
130
|
+
* UsernameTaken / no-op-rename predictions are preflight and are not ported.
|
|
131
|
+
*/
|
|
132
|
+
export declare function changeUsernameIntent(ctx: PopContext, params: ChangeUsernameParams): Promise<TxIntent>;
|
|
133
|
+
export interface SetProfileMetadataParams extends UserProfileUpdates {
|
|
134
|
+
/** The account whose profile is being updated (the eventual tx sender). */
|
|
135
|
+
address: string;
|
|
136
|
+
/** Registry chain. Defaults to HOME_CHAIN_ID — NOT ctx.chainId. */
|
|
137
|
+
chainId?: number;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Resolved builder for the metadata tx of `pop user update-profile` —
|
|
141
|
+
* src/commands/user/update-profile.ts. Reads the existing indexed profile
|
|
142
|
+
* metadata (read-then-merge, so single-field edits preserve the others),
|
|
143
|
+
* builds the {bio, avatar, github, twitter, website} document with the CLI's
|
|
144
|
+
* exact conditional key order, pins it to IPFS, converts the CID to bytes32,
|
|
145
|
+
* and builds the setProfileMetadata intent.
|
|
146
|
+
*/
|
|
147
|
+
export declare function setProfileMetadataIntent(ctx: PopContext, params: SetProfileMetadataParams): Promise<TxIntent>;
|
|
148
|
+
export interface QuickJoinParams {
|
|
149
|
+
/** Org name or hex ID. */
|
|
150
|
+
org: string;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Resolved builder for `pop user join` (join tx only) —
|
|
154
|
+
* src/commands/user/join.ts. Resolves the org's QuickJoin via the subgraph
|
|
155
|
+
* and builds the quickJoinWithUser intent. The 1-tx vs 2-tx decision (does
|
|
156
|
+
* the sender already hold a username on the registry this QuickJoin
|
|
157
|
+
* consults?) is host orchestration: read state with
|
|
158
|
+
* reads/user.getQuickJoinAccount, re-verify the registry pointer LIVE
|
|
159
|
+
* (quickJoin.accountRegistry() — it is a write target updateAddresses can
|
|
160
|
+
* re-point), and when registration is needed send buildRegisterAccount
|
|
161
|
+
* against THAT registry first.
|
|
162
|
+
*/
|
|
163
|
+
export declare function quickJoinWithUserIntent(ctx: PopContext, params: QuickJoinParams): Promise<TxIntent>;
|
|
164
|
+
export interface ClaimHatsParams {
|
|
165
|
+
/** Org name or hex ID. */
|
|
166
|
+
org: string;
|
|
167
|
+
/** Comma-separated hat-ID string (as the CLI's --hats), or pre-parsed IDs. */
|
|
168
|
+
hats: string | Array<string | ethers.BigNumberish>;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Resolved builder for `pop user claim-hats` —
|
|
172
|
+
* src/commands/user/claim-hats.ts. Parses hat IDs with BigNumber (uint256 —
|
|
173
|
+
* never parseInt), resolves the org's QuickJoin via the subgraph, and builds
|
|
174
|
+
* the claimHatsWithUser intent. The CLI's Multicall3 preflight (NoUsername /
|
|
175
|
+
* batch cap / open-hat sentinel probes) stays in the CLI.
|
|
176
|
+
*/
|
|
177
|
+
export declare function claimHatsWithUserIntent(ctx: PopContext, params: ClaimHatsParams): Promise<TxIntent>;
|
package/dist/tx/user.js
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* User write builders — UniversalAccountRegistry (registerAccount /
|
|
4
|
+
* changeUsername / setProfileMetadata) and QuickJoinNew (quickJoinWithUser /
|
|
5
|
+
* claimHatsWithUser).
|
|
6
|
+
*
|
|
7
|
+
* Level 1: pure, sync builders taking resolved addresses + prepared values.
|
|
8
|
+
* Level 2: async `<action>Intent(ctx, params)` builders that resolve the
|
|
9
|
+
* registry / QuickJoin address via the subgraph, merge + pin profile
|
|
10
|
+
* metadata, and delegate to Level 1.
|
|
11
|
+
*
|
|
12
|
+
* Chain semantics (preserved CLI behavior): usernames and profile metadata
|
|
13
|
+
* are HOME-CHAIN account-registry state, so the registry-scoped Level-2
|
|
14
|
+
* builders default to HOME_CHAIN_ID — deliberately IGNORING ctx.chainId (the
|
|
15
|
+
* CLI ignores POP_DEFAULT_CHAIN the same way; an explicit `chainId` param
|
|
16
|
+
* wins). The org-scoped QuickJoin builders use ctx.chainId as usual.
|
|
17
|
+
*
|
|
18
|
+
* NOT ported (CLI-side revert prediction / flow UX): checkUsernameFree,
|
|
19
|
+
* AccountUnknown prediction, the live re-read of quickJoin.accountRegistry()
|
|
20
|
+
* before a 2-tx join (a write-target pointer that updateAddresses can
|
|
21
|
+
* re-point — see src/commands/user/join.ts), and the claim-hats Multicall3
|
|
22
|
+
* probes (NoUsername / MAX_HATS_PER_MINT / HatOpenlyClaimable sentinel).
|
|
23
|
+
*/
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.parseHatIds = parseHatIds;
|
|
26
|
+
exports.buildRegisterAccount = buildRegisterAccount;
|
|
27
|
+
exports.buildChangeUsername = buildChangeUsername;
|
|
28
|
+
exports.buildSetProfileMetadata = buildSetProfileMetadata;
|
|
29
|
+
exports.buildQuickJoinWithUser = buildQuickJoinWithUser;
|
|
30
|
+
exports.buildClaimHatsWithUser = buildClaimHatsWithUser;
|
|
31
|
+
exports.registerAccountIntent = registerAccountIntent;
|
|
32
|
+
exports.changeUsernameIntent = changeUsernameIntent;
|
|
33
|
+
exports.setProfileMetadataIntent = setProfileMetadataIntent;
|
|
34
|
+
exports.quickJoinWithUserIntent = quickJoinWithUserIntent;
|
|
35
|
+
exports.claimHatsWithUserIntent = claimHatsWithUserIntent;
|
|
36
|
+
const ethers_1 = require("ethers");
|
|
37
|
+
const contracts_1 = require("../contracts");
|
|
38
|
+
const ipfs_1 = require("../ipfs");
|
|
39
|
+
const encoding_1 = require("../encoding");
|
|
40
|
+
const validation_1 = require("../validation");
|
|
41
|
+
const chains_1 = require("../chains");
|
|
42
|
+
const errors_1 = require("../errors");
|
|
43
|
+
const exit_codes_1 = require("../exit-codes");
|
|
44
|
+
const infrastructure_1 = require("../graph/documents/infrastructure");
|
|
45
|
+
const user_1 = require("../metadata/user");
|
|
46
|
+
const resolve_1 = require("../reads/resolve");
|
|
47
|
+
const user_2 = require("../reads/user");
|
|
48
|
+
/**
|
|
49
|
+
* Parse a comma-separated hat-ID list into BigNumbers. Accepts decimal and
|
|
50
|
+
* 0x-hex forms. Hats Protocol IDs are uint256 — far beyond 2^53 — so
|
|
51
|
+
* parseInt/Number would silently corrupt them.
|
|
52
|
+
* Port of parseHatIds in `pop user claim-hats` —
|
|
53
|
+
* src/commands/user/claim-hats.ts (same messages and exit codes).
|
|
54
|
+
*/
|
|
55
|
+
function parseHatIds(input) {
|
|
56
|
+
const parts = String(input).split(',').map(part => part.trim()).filter(part => part.length > 0);
|
|
57
|
+
if (parts.length === 0) {
|
|
58
|
+
throw new errors_1.CliError('No hat IDs given.', exit_codes_1.EXIT.USAGE, 'Pass --hats <id>[,<id>...] (see pop org roles for hat IDs).');
|
|
59
|
+
}
|
|
60
|
+
return parts.map(part => {
|
|
61
|
+
try {
|
|
62
|
+
return ethers_1.ethers.BigNumber.from(part);
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
throw new errors_1.CliError(`Invalid hat ID "${part}".`, exit_codes_1.EXIT.USAGE, 'Hat IDs are uint256 integers — pass them as decimal or 0x-hex strings (see pop org roles).');
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Port of `pop user register` — src/commands/user/register.ts (also tx 1 of
|
|
71
|
+
* the 2-tx `pop user join` flow — src/commands/user/join.ts).
|
|
72
|
+
* UniversalAccountRegistry.registerAccount(string username); reverts
|
|
73
|
+
* UsernameTaken when the name is held. For the join flow, register on the
|
|
74
|
+
* SAME registry the org's QuickJoin consults (quickJoin.accountRegistry(),
|
|
75
|
+
* re-read live in the CLI) — registering anywhere else leaves
|
|
76
|
+
* quickJoinWithUser reverting NoUsername.
|
|
77
|
+
*/
|
|
78
|
+
function buildRegisterAccount(a) {
|
|
79
|
+
return {
|
|
80
|
+
to: a.registryAddress,
|
|
81
|
+
abi: (0, contracts_1.getAbi)('UniversalAccountRegistry'),
|
|
82
|
+
method: 'registerAccount',
|
|
83
|
+
args: [a.username],
|
|
84
|
+
meta: {
|
|
85
|
+
domain: 'user',
|
|
86
|
+
action: 'register',
|
|
87
|
+
summary: { username: a.username, registry: a.registryAddress },
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Port of `pop user update-profile --username` —
|
|
93
|
+
* src/commands/user/update-profile.ts.
|
|
94
|
+
* UniversalAccountRegistry.changeUsername(string newUsername) — DESTRUCTIVE:
|
|
95
|
+
* the old username is released for anyone to claim the moment the tx lands.
|
|
96
|
+
* Reverts AccountUnknown without an existing registration and UsernameTaken
|
|
97
|
+
* when the new name is held.
|
|
98
|
+
*/
|
|
99
|
+
function buildChangeUsername(a) {
|
|
100
|
+
return {
|
|
101
|
+
to: a.registryAddress,
|
|
102
|
+
abi: (0, contracts_1.getAbi)('UniversalAccountRegistry'),
|
|
103
|
+
method: 'changeUsername',
|
|
104
|
+
args: [a.newUsername],
|
|
105
|
+
meta: {
|
|
106
|
+
domain: 'user',
|
|
107
|
+
action: 'change-username',
|
|
108
|
+
summary: { username: a.newUsername, registry: a.registryAddress },
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Port of the metadata tx of `pop user update-profile` —
|
|
114
|
+
* src/commands/user/update-profile.ts.
|
|
115
|
+
* UniversalAccountRegistry.setProfileMetadata(bytes32 metadataHash), where
|
|
116
|
+
* metadataHash = ipfsCidToBytes32(pinJson(serialized profile document)).
|
|
117
|
+
*/
|
|
118
|
+
function buildSetProfileMetadata(a) {
|
|
119
|
+
return {
|
|
120
|
+
to: a.registryAddress,
|
|
121
|
+
abi: (0, contracts_1.getAbi)('UniversalAccountRegistry'),
|
|
122
|
+
method: 'setProfileMetadata',
|
|
123
|
+
args: [a.metadataHash],
|
|
124
|
+
meta: {
|
|
125
|
+
domain: 'user',
|
|
126
|
+
action: 'set-profile-metadata',
|
|
127
|
+
summary: { metadataHash: a.metadataHash, registry: a.registryAddress },
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Port of `pop user join` (the join tx) — src/commands/user/join.ts.
|
|
133
|
+
* QuickJoinNew.quickJoinWithUser() — NO arguments. The contract reads
|
|
134
|
+
* accountRegistry.getUsername(msg.sender) and reverts NoUsername when it is
|
|
135
|
+
* empty, so the sender must already hold a username on the registry this
|
|
136
|
+
* QuickJoin consults (register first via buildRegisterAccount when needed).
|
|
137
|
+
*/
|
|
138
|
+
function buildQuickJoinWithUser(a) {
|
|
139
|
+
return {
|
|
140
|
+
to: a.quickJoinAddress,
|
|
141
|
+
abi: (0, contracts_1.getAbi)('QuickJoinNew'),
|
|
142
|
+
method: 'quickJoinWithUser',
|
|
143
|
+
args: [],
|
|
144
|
+
meta: {
|
|
145
|
+
domain: 'user',
|
|
146
|
+
action: 'join',
|
|
147
|
+
orgId: a.orgId,
|
|
148
|
+
summary: {},
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Port of `pop user claim-hats` — src/commands/user/claim-hats.ts.
|
|
154
|
+
* QuickJoinNew.claimHatsWithUser(uint256[] claimHatIds). The caller must
|
|
155
|
+
* already have a username (reverts NoUsername); since audit H-03 QuickJoin
|
|
156
|
+
* refuses openly-claimable hats (reverts HatOpenlyClaimable), and the
|
|
157
|
+
* executor bounds the batch at MAX_HATS_PER_MINT.
|
|
158
|
+
*/
|
|
159
|
+
function buildClaimHatsWithUser(a) {
|
|
160
|
+
return {
|
|
161
|
+
to: a.quickJoinAddress,
|
|
162
|
+
abi: (0, contracts_1.getAbi)('QuickJoinNew'),
|
|
163
|
+
method: 'claimHatsWithUser',
|
|
164
|
+
args: [a.hatIds],
|
|
165
|
+
meta: {
|
|
166
|
+
domain: 'user',
|
|
167
|
+
action: 'claim-hats',
|
|
168
|
+
orgId: a.orgId,
|
|
169
|
+
summary: { hatIds: a.hatIds.map(id => id.toString()).join(',') },
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
// ──────────────────────────── Level 2 — resolved ───────────────────────────
|
|
174
|
+
/** Validate a username with the CLI's wrapping (usage error, not a bare throw). */
|
|
175
|
+
function requireUsernameArg(username) {
|
|
176
|
+
try {
|
|
177
|
+
return (0, validation_1.requireValidUsername)(username);
|
|
178
|
+
}
|
|
179
|
+
catch (err) {
|
|
180
|
+
throw new errors_1.CliError(err.message, exit_codes_1.EXIT.USAGE);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Resolved builder for `pop user register` — src/commands/user/register.ts.
|
|
185
|
+
* Validates the username, resolves the UniversalAccountRegistry address from
|
|
186
|
+
* the infrastructure subgraph (universalAccountRegistries[0].id, falling back
|
|
187
|
+
* to poaManagerContracts[0].globalAccountRegistryProxy), then builds the
|
|
188
|
+
* registerAccount intent. Defaults to the HOME chain, deliberately ignoring
|
|
189
|
+
* ctx.chainId — usernames live on the home chain (the CLI ignores
|
|
190
|
+
* POP_DEFAULT_CHAIN the same way).
|
|
191
|
+
*/
|
|
192
|
+
async function registerAccountIntent(ctx, params) {
|
|
193
|
+
const username = requireUsernameArg(params.username);
|
|
194
|
+
const chainId = params.chainId || chains_1.HOME_CHAIN_ID;
|
|
195
|
+
const infra = await ctx.client.query(infrastructure_1.FETCH_INFRASTRUCTURE_ADDRESSES, {}, chainId);
|
|
196
|
+
const registryAddr = infra.universalAccountRegistries?.[0]?.id
|
|
197
|
+
|| infra.poaManagerContracts?.[0]?.globalAccountRegistryProxy;
|
|
198
|
+
if (!registryAddr) {
|
|
199
|
+
throw new errors_1.CliError('Could not resolve the UniversalAccountRegistry address from the subgraph.', exit_codes_1.EXIT.INFRA, 'The subgraph may be syncing — retry shortly, or pass --chain for a chain with a deployed registry.');
|
|
200
|
+
}
|
|
201
|
+
return buildRegisterAccount({ registryAddress: registryAddr, username });
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Resolved builder for the username tx of `pop user update-profile` —
|
|
205
|
+
* src/commands/user/update-profile.ts. DESTRUCTIVE: the old username is
|
|
206
|
+
* released on-chain for anyone to claim. Resolves the registry from the same
|
|
207
|
+
* one-round-trip document the CLI uses. The CLI's AccountUnknown /
|
|
208
|
+
* UsernameTaken / no-op-rename predictions are preflight and are not ported.
|
|
209
|
+
*/
|
|
210
|
+
async function changeUsernameIntent(ctx, params) {
|
|
211
|
+
const newUsername = requireUsernameArg(params.newUsername);
|
|
212
|
+
const chainId = params.chainId ?? chains_1.HOME_CHAIN_ID;
|
|
213
|
+
const { registryAddress } = await (0, user_2.getRegistryAndAccount)(ctx.client, params.address, chainId);
|
|
214
|
+
if (!registryAddress) {
|
|
215
|
+
throw new errors_1.CliError('UniversalAccountRegistry not found on this chain.', exit_codes_1.EXIT.INFRA, 'The subgraph may be syncing — retry shortly.');
|
|
216
|
+
}
|
|
217
|
+
return buildChangeUsername({ registryAddress, newUsername });
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Resolved builder for the metadata tx of `pop user update-profile` —
|
|
221
|
+
* src/commands/user/update-profile.ts. Reads the existing indexed profile
|
|
222
|
+
* metadata (read-then-merge, so single-field edits preserve the others),
|
|
223
|
+
* builds the {bio, avatar, github, twitter, website} document with the CLI's
|
|
224
|
+
* exact conditional key order, pins it to IPFS, converts the CID to bytes32,
|
|
225
|
+
* and builds the setProfileMetadata intent.
|
|
226
|
+
*/
|
|
227
|
+
async function setProfileMetadataIntent(ctx, params) {
|
|
228
|
+
const updates = {
|
|
229
|
+
bio: params.bio,
|
|
230
|
+
avatar: params.avatar,
|
|
231
|
+
github: params.github,
|
|
232
|
+
twitter: params.twitter,
|
|
233
|
+
website: params.website,
|
|
234
|
+
};
|
|
235
|
+
if (!user_1.USER_PROFILE_FIELDS.some(field => updates[field] !== undefined)) {
|
|
236
|
+
throw new errors_1.CliError('Provide at least one field: --bio, --avatar, --github, --twitter, --website', exit_codes_1.EXIT.USAGE);
|
|
237
|
+
}
|
|
238
|
+
const chainId = params.chainId ?? chains_1.HOME_CHAIN_ID;
|
|
239
|
+
const { registryAddress, account } = await (0, user_2.getRegistryAndAccount)(ctx.client, params.address, chainId);
|
|
240
|
+
if (!registryAddress) {
|
|
241
|
+
throw new errors_1.CliError('UniversalAccountRegistry not found on this chain.', exit_codes_1.EXIT.INFRA, 'The subgraph may be syncing — retry shortly.');
|
|
242
|
+
}
|
|
243
|
+
// Merge over the indexed metadata exactly as the CLI does
|
|
244
|
+
// (indexed.account?.metadata || {} — no authority gating on the merge read).
|
|
245
|
+
const metadata = (0, user_1.buildUserProfileMetadata)(updates, account?.metadata ?? {});
|
|
246
|
+
const cid = await (0, ipfs_1.pinJson)((0, user_1.serializeUserProfileMetadata)(metadata), ctx.ipfs);
|
|
247
|
+
const metadataHash = (0, encoding_1.ipfsCidToBytes32)(cid);
|
|
248
|
+
const intent = buildSetProfileMetadata({ registryAddress, metadataHash });
|
|
249
|
+
intent.meta.ipfs = { cid, metadata };
|
|
250
|
+
return intent;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Resolved builder for `pop user join` (join tx only) —
|
|
254
|
+
* src/commands/user/join.ts. Resolves the org's QuickJoin via the subgraph
|
|
255
|
+
* and builds the quickJoinWithUser intent. The 1-tx vs 2-tx decision (does
|
|
256
|
+
* the sender already hold a username on the registry this QuickJoin
|
|
257
|
+
* consults?) is host orchestration: read state with
|
|
258
|
+
* reads/user.getQuickJoinAccount, re-verify the registry pointer LIVE
|
|
259
|
+
* (quickJoin.accountRegistry() — it is a write target updateAddresses can
|
|
260
|
+
* re-point), and when registration is needed send buildRegisterAccount
|
|
261
|
+
* against THAT registry first.
|
|
262
|
+
*/
|
|
263
|
+
async function quickJoinWithUserIntent(ctx, params) {
|
|
264
|
+
const modules = await (0, resolve_1.resolveOrgModules)(ctx.client, params.org, ctx.chainId);
|
|
265
|
+
const quickJoinAddress = (0, resolve_1.requireModule)(modules, 'quickJoinAddress');
|
|
266
|
+
return buildQuickJoinWithUser({ quickJoinAddress, orgId: modules.orgId });
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Resolved builder for `pop user claim-hats` —
|
|
270
|
+
* src/commands/user/claim-hats.ts. Parses hat IDs with BigNumber (uint256 —
|
|
271
|
+
* never parseInt), resolves the org's QuickJoin via the subgraph, and builds
|
|
272
|
+
* the claimHatsWithUser intent. The CLI's Multicall3 preflight (NoUsername /
|
|
273
|
+
* batch cap / open-hat sentinel probes) stays in the CLI.
|
|
274
|
+
*/
|
|
275
|
+
async function claimHatsWithUserIntent(ctx, params) {
|
|
276
|
+
const hatIds = typeof params.hats === 'string'
|
|
277
|
+
? parseHatIds(params.hats)
|
|
278
|
+
: params.hats.map(part => {
|
|
279
|
+
try {
|
|
280
|
+
return ethers_1.ethers.BigNumber.from(part);
|
|
281
|
+
}
|
|
282
|
+
catch {
|
|
283
|
+
throw new errors_1.CliError(`Invalid hat ID "${part}".`, exit_codes_1.EXIT.USAGE, 'Hat IDs are uint256 integers — pass them as decimal or 0x-hex strings (see pop org roles).');
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
if (hatIds.length === 0) {
|
|
287
|
+
throw new errors_1.CliError('No hat IDs given.', exit_codes_1.EXIT.USAGE, 'Pass --hats <id>[,<id>...] (see pop org roles for hat IDs).');
|
|
288
|
+
}
|
|
289
|
+
const modules = await (0, resolve_1.resolveOrgModules)(ctx.client, params.org, ctx.chainId);
|
|
290
|
+
const quickJoinAddress = (0, resolve_1.requireModule)(modules, 'quickJoinAddress');
|
|
291
|
+
return buildClaimHatsWithUser({ quickJoinAddress, hatIds, orgId: modules.orgId });
|
|
292
|
+
}
|