@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.
Files changed (220) hide show
  1. package/README.md +201 -0
  2. package/dist/abis/DirectDemocracyVotingNew.d.ts +749 -0
  3. package/dist/abis/DirectDemocracyVotingNew.js +961 -0
  4. package/dist/abis/ERC20.d.ts +90 -0
  5. package/dist/abis/ERC20.js +125 -0
  6. package/dist/abis/EducationHubNew.d.ts +590 -0
  7. package/dist/abis/EducationHubNew.js +762 -0
  8. package/dist/abis/EligibilityModuleNew.d.ts +1615 -0
  9. package/dist/abis/EligibilityModuleNew.js +2082 -0
  10. package/dist/abis/Executor.d.ts +619 -0
  11. package/dist/abis/Executor.js +796 -0
  12. package/dist/abis/HybridVotingNew.d.ts +898 -0
  13. package/dist/abis/HybridVotingNew.js +1149 -0
  14. package/dist/abis/ImplementationRegistry.d.ts +270 -0
  15. package/dist/abis/ImplementationRegistry.js +355 -0
  16. package/dist/abis/OrgDeployerNew.d.ts +1275 -0
  17. package/dist/abis/OrgDeployerNew.js +1630 -0
  18. package/dist/abis/OrgRegistry.d.ts +670 -0
  19. package/dist/abis/OrgRegistry.js +868 -0
  20. package/dist/abis/ParticipationToken.d.ts +1086 -0
  21. package/dist/abis/ParticipationToken.js +1415 -0
  22. package/dist/abis/PasskeyAccount.d.ts +788 -0
  23. package/dist/abis/PasskeyAccount.js +1019 -0
  24. package/dist/abis/PasskeyAccountFactory.d.ts +344 -0
  25. package/dist/abis/PasskeyAccountFactory.js +449 -0
  26. package/dist/abis/PaymasterHub.d.ts +1603 -0
  27. package/dist/abis/PaymasterHub.js +2048 -0
  28. package/dist/abis/PaymentManager.d.ts +520 -0
  29. package/dist/abis/PaymentManager.js +671 -0
  30. package/dist/abis/PoaManager.d.ts +344 -0
  31. package/dist/abis/PoaManager.js +449 -0
  32. package/dist/abis/QuickJoinNew.d.ts +855 -0
  33. package/dist/abis/QuickJoinNew.js +1098 -0
  34. package/dist/abis/TaskManagerNew.d.ts +1236 -0
  35. package/dist/abis/TaskManagerNew.js +1573 -0
  36. package/dist/abis/ToggleModule.d.ts +193 -0
  37. package/dist/abis/ToggleModule.js +255 -0
  38. package/dist/abis/UniversalAccountRegistry.d.ts +577 -0
  39. package/dist/abis/UniversalAccountRegistry.js +750 -0
  40. package/dist/abis/ZkEmailInvites.d.ts +823 -0
  41. package/dist/abis/ZkEmailInvites.js +1060 -0
  42. package/dist/abis/external/AaveGovernanceV2.d.ts +128 -0
  43. package/dist/abis/external/AaveGovernanceV2.js +177 -0
  44. package/dist/abis/external/AaveGovernanceV3.d.ts +160 -0
  45. package/dist/abis/external/AaveGovernanceV3.js +220 -0
  46. package/dist/abis/external/AragonVoting.d.ts +107 -0
  47. package/dist/abis/external/AragonVoting.js +150 -0
  48. package/dist/abis/external/CurveGaugeController.d.ts +95 -0
  49. package/dist/abis/external/CurveGaugeController.js +130 -0
  50. package/dist/abis/external/CurveVotingEscrow.d.ts +86 -0
  51. package/dist/abis/external/CurveVotingEscrow.js +116 -0
  52. package/dist/abis/external/GovernorAlpha.d.ts +172 -0
  53. package/dist/abis/external/GovernorAlpha.js +228 -0
  54. package/dist/abis/external/MakerDAOChief.d.ts +92 -0
  55. package/dist/abis/external/MakerDAOChief.js +129 -0
  56. package/dist/abis/external/OZGovernor.d.ts +227 -0
  57. package/dist/abis/external/OZGovernor.js +317 -0
  58. package/dist/abis/external/SolidlyVotingEscrow.d.ts +196 -0
  59. package/dist/abis/external/SolidlyVotingEscrow.js +260 -0
  60. package/dist/abis/index.d.ts +62 -0
  61. package/dist/abis/index.js +98 -0
  62. package/dist/chains.d.ts +150 -0
  63. package/dist/chains.js +320 -0
  64. package/dist/context.d.ts +48 -0
  65. package/dist/context.js +38 -0
  66. package/dist/contracts.d.ts +24 -0
  67. package/dist/contracts.js +41 -0
  68. package/dist/encoding.d.ts +58 -0
  69. package/dist/encoding.js +243 -0
  70. package/dist/env.d.ts +10 -0
  71. package/dist/env.js +4 -0
  72. package/dist/error-catalog.d.ts +41 -0
  73. package/dist/error-catalog.js +941 -0
  74. package/dist/errors.d.ts +27 -0
  75. package/dist/errors.js +60 -0
  76. package/dist/execute/ethers.d.ts +93 -0
  77. package/dist/execute/ethers.js +323 -0
  78. package/dist/execute/index.d.ts +7 -0
  79. package/dist/execute/index.js +23 -0
  80. package/dist/execute/sponsored.d.ts +68 -0
  81. package/dist/execute/sponsored.js +277 -0
  82. package/dist/exit-codes.d.ts +18 -0
  83. package/dist/exit-codes.js +21 -0
  84. package/dist/format.d.ts +21 -0
  85. package/dist/format.js +89 -0
  86. package/dist/graph/client.d.ts +298 -0
  87. package/dist/graph/client.js +702 -0
  88. package/dist/graph/documents/activity.d.ts +9 -0
  89. package/dist/graph/documents/activity.js +164 -0
  90. package/dist/graph/documents/beacons.d.ts +172 -0
  91. package/dist/graph/documents/beacons.js +345 -0
  92. package/dist/graph/documents/index.d.ts +21 -0
  93. package/dist/graph/documents/index.js +57 -0
  94. package/dist/graph/documents/infrastructure.d.ts +30 -0
  95. package/dist/graph/documents/infrastructure.js +34 -0
  96. package/dist/graph/documents/org.d.ts +15 -0
  97. package/dist/graph/documents/org.js +249 -0
  98. package/dist/graph/documents/paymaster.d.ts +95 -0
  99. package/dist/graph/documents/paymaster.js +101 -0
  100. package/dist/graph/documents/role.d.ts +6 -0
  101. package/dist/graph/documents/role.js +41 -0
  102. package/dist/graph/documents/roles.d.ts +50 -0
  103. package/dist/graph/documents/roles.js +112 -0
  104. package/dist/graph/documents/task.d.ts +84 -0
  105. package/dist/graph/documents/task.js +236 -0
  106. package/dist/graph/documents/token.d.ts +13 -0
  107. package/dist/graph/documents/token.js +126 -0
  108. package/dist/graph/documents/treasury.d.ts +39 -0
  109. package/dist/graph/documents/treasury.js +136 -0
  110. package/dist/graph/documents/user.d.ts +120 -0
  111. package/dist/graph/documents/user.js +302 -0
  112. package/dist/graph/documents/voting-classes.d.ts +69 -0
  113. package/dist/graph/documents/voting-classes.js +149 -0
  114. package/dist/graph/documents/voting.d.ts +28 -0
  115. package/dist/graph/documents/voting.js +163 -0
  116. package/dist/graph/documents/vouch.d.ts +79 -0
  117. package/dist/graph/documents/vouch.js +171 -0
  118. package/dist/graph/documents/zkemail.d.ts +63 -0
  119. package/dist/graph/documents/zkemail.js +188 -0
  120. package/dist/graph/index.d.ts +2 -0
  121. package/dist/graph/index.js +41 -0
  122. package/dist/index.d.ts +49 -0
  123. package/dist/index.js +92 -0
  124. package/dist/ipfs.d.ts +39 -0
  125. package/dist/ipfs.js +214 -0
  126. package/dist/label-aliases.d.ts +31 -0
  127. package/dist/label-aliases.js +70 -0
  128. package/dist/metadata/education.d.ts +30 -0
  129. package/dist/metadata/education.js +31 -0
  130. package/dist/metadata/index.d.ts +12 -0
  131. package/dist/metadata/index.js +48 -0
  132. package/dist/metadata/org.d.ts +92 -0
  133. package/dist/metadata/org.js +93 -0
  134. package/dist/metadata/proposal.d.ts +44 -0
  135. package/dist/metadata/proposal.js +45 -0
  136. package/dist/metadata/role.d.ts +38 -0
  137. package/dist/metadata/role.js +35 -0
  138. package/dist/metadata/task.d.ts +108 -0
  139. package/dist/metadata/task.js +81 -0
  140. package/dist/metadata/token.d.ts +32 -0
  141. package/dist/metadata/token.js +36 -0
  142. package/dist/metadata/user.d.ts +63 -0
  143. package/dist/metadata/user.js +70 -0
  144. package/dist/multicall.d.ts +32 -0
  145. package/dist/multicall.js +96 -0
  146. package/dist/payout.d.ts +59 -0
  147. package/dist/payout.js +96 -0
  148. package/dist/perms.d.ts +47 -0
  149. package/dist/perms.js +120 -0
  150. package/dist/preflight.d.ts +72 -0
  151. package/dist/preflight.js +269 -0
  152. package/dist/reads/education.d.ts +79 -0
  153. package/dist/reads/education.js +122 -0
  154. package/dist/reads/eligibility.d.ts +377 -0
  155. package/dist/reads/eligibility.js +687 -0
  156. package/dist/reads/index.d.ts +16 -0
  157. package/dist/reads/index.js +55 -0
  158. package/dist/reads/org.d.ts +258 -0
  159. package/dist/reads/org.js +220 -0
  160. package/dist/reads/paymaster.d.ts +147 -0
  161. package/dist/reads/paymaster.js +235 -0
  162. package/dist/reads/project.d.ts +33 -0
  163. package/dist/reads/project.js +62 -0
  164. package/dist/reads/resolve.d.ts +34 -0
  165. package/dist/reads/resolve.js +64 -0
  166. package/dist/reads/task.d.ts +286 -0
  167. package/dist/reads/task.js +280 -0
  168. package/dist/reads/token.d.ts +94 -0
  169. package/dist/reads/token.js +75 -0
  170. package/dist/reads/treasury.d.ts +222 -0
  171. package/dist/reads/treasury.js +241 -0
  172. package/dist/reads/user.d.ts +229 -0
  173. package/dist/reads/user.js +155 -0
  174. package/dist/reads/vote.d.ts +296 -0
  175. package/dist/reads/vote.js +392 -0
  176. package/dist/reads/zkemail.d.ts +117 -0
  177. package/dist/reads/zkemail.js +217 -0
  178. package/dist/similarity.d.ts +36 -0
  179. package/dist/similarity.js +67 -0
  180. package/dist/sponsorship-config.d.ts +47 -0
  181. package/dist/sponsorship-config.js +41 -0
  182. package/dist/stats.d.ts +11 -0
  183. package/dist/stats.js +27 -0
  184. package/dist/task-lens.d.ts +113 -0
  185. package/dist/task-lens.js +210 -0
  186. package/dist/tx/education.d.ts +169 -0
  187. package/dist/tx/education.js +344 -0
  188. package/dist/tx/eligibility.d.ts +511 -0
  189. package/dist/tx/eligibility.js +818 -0
  190. package/dist/tx/governance.d.ts +85 -0
  191. package/dist/tx/governance.js +87 -0
  192. package/dist/tx/index.d.ts +17 -0
  193. package/dist/tx/index.js +56 -0
  194. package/dist/tx/intent.d.ts +67 -0
  195. package/dist/tx/intent.js +48 -0
  196. package/dist/tx/org.d.ts +321 -0
  197. package/dist/tx/org.js +544 -0
  198. package/dist/tx/paymaster.d.ts +140 -0
  199. package/dist/tx/paymaster.js +251 -0
  200. package/dist/tx/project.d.ts +146 -0
  201. package/dist/tx/project.js +217 -0
  202. package/dist/tx/task.d.ts +480 -0
  203. package/dist/tx/task.js +1149 -0
  204. package/dist/tx/token.d.ts +96 -0
  205. package/dist/tx/token.js +165 -0
  206. package/dist/tx/treasury.d.ts +474 -0
  207. package/dist/tx/treasury.js +911 -0
  208. package/dist/tx/user.d.ts +177 -0
  209. package/dist/tx/user.js +292 -0
  210. package/dist/tx/vote.d.ts +332 -0
  211. package/dist/tx/vote.js +762 -0
  212. package/dist/tx/zkemail.d.ts +90 -0
  213. package/dist/tx/zkemail.js +210 -0
  214. package/dist/validation.d.ts +8 -0
  215. package/dist/validation.js +39 -0
  216. package/dist/version.d.ts +142 -0
  217. package/dist/version.js +257 -0
  218. package/dist/zkemail.d.ts +161 -0
  219. package/dist/zkemail.js +299 -0
  220. package/package.json +130 -0
@@ -0,0 +1,96 @@
1
+ /**
2
+ * ParticipationToken write builders — token request / approve / cancel.
3
+ *
4
+ * Level 1: pure, sync builders that take resolved addresses + fully-prepared
5
+ * values and return a TxIntent. Level 2: async `<action>Intent(ctx, params)`
6
+ * builders that resolve the org's token address via the subgraph and pin the
7
+ * request metadata to IPFS, then delegate to Level 1 — replicating exactly
8
+ * what the CLI commands do before executeTx.
9
+ *
10
+ * Preflight (hat gates, requests(id) existence/state probes) is NOT ported:
11
+ * those are provider-bound revert predictors that stay in the CLI
12
+ * (src/commands/token/helpers.ts documents why they must stay on RPC).
13
+ */
14
+ import { ethers } from 'ethers';
15
+ import type { TxIntent } from './intent';
16
+ import type { PopContext } from '../context';
17
+ /**
18
+ * Parse a PT amount to 18-decimal wei, enforcing the contract's uint96 bound.
19
+ * Port of parseRequestAmount in `pop token request` —
20
+ * src/commands/token/request.ts (same messages and exit codes).
21
+ */
22
+ export declare function parseRequestAmount(amount: number | string): ethers.BigNumber;
23
+ export interface RequestTokensArgs {
24
+ participationTokenAddress: string;
25
+ /** 18-decimal wei, bounded to uint96 (see parseRequestAmount). */
26
+ amountWei: ethers.BigNumberish;
27
+ /** IPFS CID of the pinned {reason, submittedAt} document — the CID STRING, not bytes32. */
28
+ ipfsHash: string;
29
+ orgId?: string;
30
+ }
31
+ /**
32
+ * Port of `pop token request` — src/commands/token/request.ts.
33
+ * ParticipationToken.requestTokens(uint96 amount, string ipfsHash): amount in
34
+ * 18 decimals, ipfsHash as the CID string (not bytes32). isMember-gated
35
+ * on-chain (executor or any allowed member hat); reverts ZeroAmount on a zero
36
+ * amount or empty ipfsHash. Emits Requested(id) — parse receipt logs for the
37
+ * request id.
38
+ */
39
+ export declare function buildRequestTokens(a: RequestTokensArgs): TxIntent;
40
+ export interface ApproveTokenRequestArgs {
41
+ participationTokenAddress: string;
42
+ /** Numeric request id (`pop token requests`). */
43
+ requestId: ethers.BigNumberish;
44
+ orgId?: string;
45
+ }
46
+ /**
47
+ * Port of `pop token approve` — src/commands/token/approve.ts.
48
+ * ParticipationToken.approveRequest(uint256 id) — DESTRUCTIVE: mints the
49
+ * requested PT straight to the requester, irreversibly. onlyApprover
50
+ * (executor or any allowed approver hat); reverts RequestUnknown /
51
+ * AlreadyApproved, and NotRequester when the approver IS the requester.
52
+ */
53
+ export declare function buildApproveRequest(a: ApproveTokenRequestArgs): TxIntent;
54
+ /**
55
+ * Port of `pop token cancel` — src/commands/token/cancel.ts.
56
+ * ParticipationToken.cancelRequest(uint256 id) — callable by the REQUESTER or
57
+ * any APPROVER; reverts RequestUnknown for missing ids, AlreadyApproved once
58
+ * minted, NotApprover for everyone else.
59
+ */
60
+ export declare function buildCancelRequest(a: ApproveTokenRequestArgs): TxIntent;
61
+ export interface RequestTokensParams {
62
+ /** Org name or hex ID. */
63
+ org: string;
64
+ /** Decimal PT amount, e.g. 12.5 (parsed with parseRequestAmount). */
65
+ amount: number | string;
66
+ /** Reason pinned to IPFS as {reason, submittedAt}. */
67
+ reason: string;
68
+ /** Override the metadata timestamp (defaults to Date.now(), as the CLI). */
69
+ submittedAt?: number;
70
+ }
71
+ /**
72
+ * Resolved builder for `pop token request` — src/commands/token/request.ts.
73
+ * Validates amount/reason with the CLI's exact errors, resolves the org's
74
+ * ParticipationToken via the subgraph, pins {reason, submittedAt} to IPFS
75
+ * (exact key order), then builds the requestTokens intent.
76
+ */
77
+ export declare function requestTokensIntent(ctx: PopContext, params: RequestTokensParams): Promise<TxIntent>;
78
+ export interface TokenRequestIdParams {
79
+ /** Org name or hex ID. */
80
+ org: string;
81
+ /** Numeric request id (`pop token requests`). */
82
+ requestId: number;
83
+ }
84
+ /**
85
+ * Resolved builder for `pop token approve` — src/commands/token/approve.ts.
86
+ * DESTRUCTIVE: approval mints PT irreversibly to the requester. The CLI's
87
+ * on-chain request/approver-hat preflight is not ported (revert predictors
88
+ * stay on RPC in the CLI).
89
+ */
90
+ export declare function approveRequestIntent(ctx: PopContext, params: TokenRequestIdParams): Promise<TxIntent>;
91
+ /**
92
+ * Resolved builder for `pop token cancel` — src/commands/token/cancel.ts.
93
+ * Callable by the requester or any approver; the CLI's on-chain
94
+ * existence/not-yet-approved preflight is not ported.
95
+ */
96
+ export declare function cancelRequestIntent(ctx: PopContext, params: TokenRequestIdParams): Promise<TxIntent>;
@@ -0,0 +1,165 @@
1
+ "use strict";
2
+ /**
3
+ * ParticipationToken write builders — token request / approve / cancel.
4
+ *
5
+ * Level 1: pure, sync builders that take resolved addresses + fully-prepared
6
+ * values and return a TxIntent. Level 2: async `<action>Intent(ctx, params)`
7
+ * builders that resolve the org's token address via the subgraph and pin the
8
+ * request metadata to IPFS, then delegate to Level 1 — replicating exactly
9
+ * what the CLI commands do before executeTx.
10
+ *
11
+ * Preflight (hat gates, requests(id) existence/state probes) is NOT ported:
12
+ * those are provider-bound revert predictors that stay in the CLI
13
+ * (src/commands/token/helpers.ts documents why they must stay on RPC).
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.parseRequestAmount = parseRequestAmount;
17
+ exports.buildRequestTokens = buildRequestTokens;
18
+ exports.buildApproveRequest = buildApproveRequest;
19
+ exports.buildCancelRequest = buildCancelRequest;
20
+ exports.requestTokensIntent = requestTokensIntent;
21
+ exports.approveRequestIntent = approveRequestIntent;
22
+ exports.cancelRequestIntent = cancelRequestIntent;
23
+ const ethers_1 = require("ethers");
24
+ const contracts_1 = require("../contracts");
25
+ const ipfs_1 = require("../ipfs");
26
+ const errors_1 = require("../errors");
27
+ const exit_codes_1 = require("../exit-codes");
28
+ const token_1 = require("../metadata/token");
29
+ const token_2 = require("../reads/token");
30
+ const UINT96_MAX = ethers_1.ethers.BigNumber.from(2).pow(96).sub(1);
31
+ /**
32
+ * Parse a PT amount to 18-decimal wei, enforcing the contract's uint96 bound.
33
+ * Port of parseRequestAmount in `pop token request` —
34
+ * src/commands/token/request.ts (same messages and exit codes).
35
+ */
36
+ function parseRequestAmount(amount) {
37
+ let wei;
38
+ try {
39
+ wei = ethers_1.ethers.utils.parseUnits(String(amount), 18);
40
+ }
41
+ catch {
42
+ throw new errors_1.CliError(`Invalid --amount "${amount}".`, exit_codes_1.EXIT.USAGE, 'Pass a decimal PT amount, e.g. --amount 12.5');
43
+ }
44
+ if (wei.lte(0)) {
45
+ throw new errors_1.CliError('--amount must be greater than zero (the contract reverts ZeroAmount).', exit_codes_1.EXIT.USAGE);
46
+ }
47
+ if (wei.gt(UINT96_MAX)) {
48
+ throw new errors_1.CliError(`--amount overflows the contract's uint96 amount field.`, exit_codes_1.EXIT.USAGE, 'Request a smaller amount.');
49
+ }
50
+ return wei;
51
+ }
52
+ /**
53
+ * Port of `pop token request` — src/commands/token/request.ts.
54
+ * ParticipationToken.requestTokens(uint96 amount, string ipfsHash): amount in
55
+ * 18 decimals, ipfsHash as the CID string (not bytes32). isMember-gated
56
+ * on-chain (executor or any allowed member hat); reverts ZeroAmount on a zero
57
+ * amount or empty ipfsHash. Emits Requested(id) — parse receipt logs for the
58
+ * request id.
59
+ */
60
+ function buildRequestTokens(a) {
61
+ return {
62
+ to: a.participationTokenAddress,
63
+ abi: (0, contracts_1.getAbi)('ParticipationToken'),
64
+ method: 'requestTokens',
65
+ args: [a.amountWei, a.ipfsHash],
66
+ meta: {
67
+ domain: 'token',
68
+ action: 'request',
69
+ orgId: a.orgId,
70
+ summary: { amountWei: String(a.amountWei), ipfsHash: a.ipfsHash },
71
+ },
72
+ };
73
+ }
74
+ /**
75
+ * Port of `pop token approve` — src/commands/token/approve.ts.
76
+ * ParticipationToken.approveRequest(uint256 id) — DESTRUCTIVE: mints the
77
+ * requested PT straight to the requester, irreversibly. onlyApprover
78
+ * (executor or any allowed approver hat); reverts RequestUnknown /
79
+ * AlreadyApproved, and NotRequester when the approver IS the requester.
80
+ */
81
+ function buildApproveRequest(a) {
82
+ return {
83
+ to: a.participationTokenAddress,
84
+ abi: (0, contracts_1.getAbi)('ParticipationToken'),
85
+ method: 'approveRequest',
86
+ args: [a.requestId],
87
+ meta: {
88
+ domain: 'token',
89
+ action: 'approve',
90
+ orgId: a.orgId,
91
+ summary: { requestId: String(a.requestId) },
92
+ },
93
+ };
94
+ }
95
+ /**
96
+ * Port of `pop token cancel` — src/commands/token/cancel.ts.
97
+ * ParticipationToken.cancelRequest(uint256 id) — callable by the REQUESTER or
98
+ * any APPROVER; reverts RequestUnknown for missing ids, AlreadyApproved once
99
+ * minted, NotApprover for everyone else.
100
+ */
101
+ function buildCancelRequest(a) {
102
+ return {
103
+ to: a.participationTokenAddress,
104
+ abi: (0, contracts_1.getAbi)('ParticipationToken'),
105
+ method: 'cancelRequest',
106
+ args: [a.requestId],
107
+ meta: {
108
+ domain: 'token',
109
+ action: 'cancel',
110
+ orgId: a.orgId,
111
+ summary: { requestId: String(a.requestId) },
112
+ },
113
+ };
114
+ }
115
+ /**
116
+ * Resolved builder for `pop token request` — src/commands/token/request.ts.
117
+ * Validates amount/reason with the CLI's exact errors, resolves the org's
118
+ * ParticipationToken via the subgraph, pins {reason, submittedAt} to IPFS
119
+ * (exact key order), then builds the requestTokens intent.
120
+ */
121
+ async function requestTokensIntent(ctx, params) {
122
+ const amountWei = parseRequestAmount(params.amount);
123
+ if (!params.reason || !String(params.reason).trim()) {
124
+ throw new errors_1.CliError('--reason cannot be empty (the contract requires a non-empty ipfsHash).', exit_codes_1.EXIT.USAGE);
125
+ }
126
+ const { orgId, tokenAddress } = await (0, token_2.resolveParticipationToken)(ctx.client, params.org, ctx.chainId);
127
+ const metadata = (0, token_1.buildTokenRequestMetadata)(params.reason, params.submittedAt);
128
+ const cid = await (0, ipfs_1.pinJson)((0, token_1.serializeTokenRequestMetadata)(metadata), ctx.ipfs);
129
+ const intent = buildRequestTokens({
130
+ participationTokenAddress: tokenAddress,
131
+ amountWei,
132
+ ipfsHash: cid,
133
+ orgId,
134
+ });
135
+ intent.meta.ipfs = { cid, metadata };
136
+ return intent;
137
+ }
138
+ /** Shared id validation — same message/exit code as the approve/cancel commands. */
139
+ function requireRequestId(requestId) {
140
+ if (!Number.isInteger(requestId) || requestId <= 0) {
141
+ throw new errors_1.CliError(`Invalid --request "${requestId}".`, exit_codes_1.EXIT.USAGE, 'Pass the numeric request ID (pop token requests).');
142
+ }
143
+ return requestId;
144
+ }
145
+ /**
146
+ * Resolved builder for `pop token approve` — src/commands/token/approve.ts.
147
+ * DESTRUCTIVE: approval mints PT irreversibly to the requester. The CLI's
148
+ * on-chain request/approver-hat preflight is not ported (revert predictors
149
+ * stay on RPC in the CLI).
150
+ */
151
+ async function approveRequestIntent(ctx, params) {
152
+ const requestId = requireRequestId(params.requestId);
153
+ const { orgId, tokenAddress } = await (0, token_2.resolveParticipationToken)(ctx.client, params.org, ctx.chainId);
154
+ return buildApproveRequest({ participationTokenAddress: tokenAddress, requestId, orgId });
155
+ }
156
+ /**
157
+ * Resolved builder for `pop token cancel` — src/commands/token/cancel.ts.
158
+ * Callable by the requester or any approver; the CLI's on-chain
159
+ * existence/not-yet-approved preflight is not ported.
160
+ */
161
+ async function cancelRequestIntent(ctx, params) {
162
+ const requestId = requireRequestId(params.requestId);
163
+ const { orgId, tokenAddress } = await (0, token_2.resolveParticipationToken)(ctx.client, params.org, ctx.chainId);
164
+ return buildCancelRequest({ participationTokenAddress: tokenAddress, requestId, orgId });
165
+ }