@aromedia/contracts-sdk 1.0.0 → 1.0.1

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 (34) hide show
  1. package/dist/{chunk-EGUPIYHR.js → chunk-BVDE3GSN.js} +115 -362
  2. package/dist/chunk-BVDE3GSN.js.map +1 -0
  3. package/dist/{chunk-WUHQC3GY.js → chunk-RL7KGQGI.js} +10 -10
  4. package/dist/{chunk-WUHQC3GY.js.map → chunk-RL7KGQGI.js.map} +1 -1
  5. package/dist/{chunk-BENMJNYO.js → chunk-XYOUNFJU.js} +3 -3
  6. package/dist/{chunk-BENMJNYO.js.map → chunk-XYOUNFJU.js.map} +1 -1
  7. package/dist/generated/abis.cjs +114 -361
  8. package/dist/generated/abis.cjs.map +1 -1
  9. package/dist/generated/abis.d.cts +190 -568
  10. package/dist/generated/abis.d.ts +190 -568
  11. package/dist/generated/abis.js +1 -1
  12. package/dist/generated/addresses.cjs +9 -9
  13. package/dist/generated/addresses.cjs.map +1 -1
  14. package/dist/generated/addresses.js +1 -1
  15. package/dist/hooks/index.cjs +25 -290
  16. package/dist/hooks/index.cjs.map +1 -1
  17. package/dist/hooks/index.d.cts +1 -1
  18. package/dist/hooks/index.d.ts +1 -1
  19. package/dist/hooks/index.js +2 -2
  20. package/dist/hooks/index.js.map +1 -1
  21. package/dist/index.cjs +124 -371
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +2 -2
  24. package/dist/index.d.ts +2 -2
  25. package/dist/index.js +3 -3
  26. package/dist/{onboarding-DDKwXy8O.d.cts → onboarding-CC_y8QgN.d.cts} +8 -8
  27. package/dist/{onboarding-BD_g7Len.d.ts → onboarding-KnUSrGNx.d.ts} +8 -8
  28. package/dist/workflows/index.cjs +17 -282
  29. package/dist/workflows/index.cjs.map +1 -1
  30. package/dist/workflows/index.d.cts +1 -1
  31. package/dist/workflows/index.d.ts +1 -1
  32. package/dist/workflows/index.js +2 -2
  33. package/package.json +7 -7
  34. package/dist/chunk-EGUPIYHR.js.map +0 -1
@@ -2,7 +2,7 @@ import { addresses, AroChainId } from '../generated/addresses.cjs';
2
2
  import * as wagmi from 'wagmi';
3
3
  import { UseReadContractParameters } from 'wagmi';
4
4
  import * as abitype from 'abitype';
5
- import { O as OnboardingState } from '../onboarding-DDKwXy8O.cjs';
5
+ import { O as OnboardingState } from '../onboarding-CC_y8QgN.cjs';
6
6
  import '../generated/abis.cjs';
7
7
  import 'viem';
8
8
 
@@ -2,7 +2,7 @@ import { addresses, AroChainId } from '../generated/addresses.js';
2
2
  import * as wagmi from 'wagmi';
3
3
  import { UseReadContractParameters } from 'wagmi';
4
4
  import * as abitype from 'abitype';
5
- import { O as OnboardingState } from '../onboarding-BD_g7Len.js';
5
+ import { O as OnboardingState } from '../onboarding-KnUSrGNx.js';
6
6
  import '../generated/abis.js';
7
7
  import 'viem';
8
8
 
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  SUPPORTED_CHAIN_IDS,
3
3
  addresses
4
- } from "../chunk-WUHQC3GY.js";
4
+ } from "../chunk-RL7KGQGI.js";
5
5
  import "../chunk-VUYKYCOD.js";
6
6
  import {
7
7
  AroNomination_ABI,
8
8
  AroSBT_ABI
9
- } from "../chunk-EGUPIYHR.js";
9
+ } from "../chunk-BVDE3GSN.js";
10
10
 
11
11
  // src/hooks/useAroAddresses.ts
12
12
  import { useMemo } from "react";
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hooks/useAroAddresses.ts","../../src/hooks/useAroSBT.ts","../../src/hooks/useAroNomination.ts","../../src/hooks/useMembership.ts"],"sourcesContent":["import { useMemo } from \"react\";\nimport { useChainId } from \"wagmi\";\n\nimport { addresses, SUPPORTED_CHAIN_IDS, type AroChainId } from \"../generated/addresses.js\";\n\n/**\n * Returns the deployed contract addresses for the chain the user is\n * currently connected to. Returns `null` for chains the SDK does not\n * recognize so the dapp can render a \"switch network\" prompt.\n */\nexport function useAroAddresses(): Record<keyof typeof addresses[AroChainId], `0x${string}`> | null {\n const chainId = useChainId();\n return useMemo(() => {\n if (!isSupportedChain(chainId)) return null;\n return addresses[chainId];\n }, [chainId]);\n}\n\nexport function useAroChainId(): AroChainId | null {\n const chainId = useChainId();\n return isSupportedChain(chainId) ? chainId : null;\n}\n\nfunction isSupportedChain(id: number): id is AroChainId {\n return (SUPPORTED_CHAIN_IDS as readonly number[]).includes(id);\n}\n","import { useReadContract, useWriteContract, type UseReadContractParameters } from \"wagmi\";\n\nimport { AroSBT_ABI } from \"../generated/abis.js\";\nimport { useAroAddresses } from \"./useAroAddresses.js\";\n\n/**\n * Read whether an address holds an SBT. Returns `undefined` while loading\n * and `false` if the address has been confirmed as a non-member.\n */\nexport function useHasSBT(\n account: `0x${string}` | undefined,\n opts: Partial<UseReadContractParameters> = {},\n) {\n const addrs = useAroAddresses();\n return useReadContract({\n address: addrs?.AroSBT,\n abi: AroSBT_ABI,\n functionName: \"hasSBT\",\n args: account ? [account] : undefined,\n query: {\n enabled: Boolean(addrs?.AroSBT && account),\n ...((opts as { query?: unknown }).query as object | undefined),\n },\n ...opts,\n } as UseReadContractParameters);\n}\n\n/**\n * Decoded MemberData for an address. Throws on-chain if the address has\n * no SBT, so the dapp should only call this after `useHasSBT` returns true.\n */\nexport function useMemberData(\n account: `0x${string}` | undefined,\n opts: Partial<UseReadContractParameters> = {},\n) {\n const addrs = useAroAddresses();\n return useReadContract({\n address: addrs?.AroSBT,\n abi: AroSBT_ABI,\n functionName: \"getMemberData\",\n args: account ? [account] : undefined,\n query: {\n enabled: Boolean(addrs?.AroSBT && account),\n ...((opts as { query?: unknown }).query as object | undefined),\n },\n ...opts,\n } as UseReadContractParameters);\n}\n\n/**\n * Admin write hook for minting an SBT. The contract gates this behind\n * ROLE_MINTER, so the caller's wallet must be a holder of that role —\n * the dapp's UI should hide this control for non-admin users.\n */\nexport function useMintSBT() {\n return useWriteContract();\n}\n\n/**\n * Candidate-side write hook for AroSBT.mintWithApproval.\n *\n * The candidate submits an admin-issued EIP-712 voucher (see\n * `signMintApproval` in `../utils/mintApproval`) and its signature; the\n * contract recovers the approver, checks ROLE_MINTER, marks the voucher\n * nullified, and mints the SBT to msg.sender. The candidate's wallet\n * does NOT need any role — the gate is the signature.\n *\n * Usage:\n *\n * ```tsx\n * const addrs = useAroAddresses()\n * const { writeContractAsync } = useMintWithApproval()\n *\n * await writeContractAsync({\n * address: addrs!.AroSBT,\n * abi: AroSBT_ABI,\n * functionName: \"mintWithApproval\",\n * args: [approval, signature],\n * })\n * ```\n */\nexport function useMintWithApproval() {\n return useWriteContract();\n}\n","/**\n * @file Deprecated on-chain nomination hooks.\n *\n * The on-chain `AroNomination` contract is being retired because the\n * on-chain record of nominators and vouchers exposes the social graph of\n * prospective members publicly. The nomination and vouching flow has moved\n * to the admin portal backend (Next.js + Prisma + Postgres); consumers\n * should call its API instead of these hooks.\n *\n * These exports will be removed in a future major release.\n */\n\nimport { useReadContract, useWriteContract, type UseReadContractParameters } from \"wagmi\";\n\nimport { AroNomination_ABI } from \"../generated/abis.js\";\nimport { useAroAddresses } from \"./useAroAddresses.js\";\n\n/**\n * Read the full nomination record for a candidate.\n *\n * @deprecated Use the admin portal nomination API. The on-chain nomination\n * contract is being retired; see the file header for migration notes.\n */\nexport function useNomination(\n candidate: `0x${string}` | undefined,\n opts: Partial<UseReadContractParameters> = {},\n) {\n const addrs = useAroAddresses();\n return useReadContract({\n address: addrs?.AroNomination,\n abi: AroNomination_ABI,\n functionName: \"getNomination\",\n args: candidate ? [candidate] : undefined,\n query: {\n enabled: Boolean(addrs?.AroNomination && candidate),\n ...((opts as { query?: unknown }).query as object | undefined),\n },\n ...opts,\n } as UseReadContractParameters);\n}\n\n/**\n * Convenience read: just the status enum, when the dapp only needs to\n * branch on PENDING / APPROVED / CLEARED.\n *\n * @deprecated Use the admin portal nomination API. See file header.\n */\nexport function useNominationStatus(\n candidate: `0x${string}` | undefined,\n opts: Partial<UseReadContractParameters> = {},\n) {\n const addrs = useAroAddresses();\n return useReadContract({\n address: addrs?.AroNomination,\n abi: AroNomination_ABI,\n functionName: \"getNominationStatus\",\n args: candidate ? [candidate] : undefined,\n query: {\n enabled: Boolean(addrs?.AroNomination && candidate),\n ...((opts as { query?: unknown }).query as object | undefined),\n },\n ...opts,\n } as UseReadContractParameters);\n}\n\n/**\n * Current vouch threshold (typically 3 per KYC Policy §6.3).\n *\n * @deprecated Use the admin portal nomination API. See file header.\n */\nexport function useNominationThreshold(opts: Partial<UseReadContractParameters> = {}) {\n const addrs = useAroAddresses();\n return useReadContract({\n address: addrs?.AroNomination,\n abi: AroNomination_ABI,\n functionName: \"threshold\",\n query: {\n enabled: Boolean(addrs?.AroNomination),\n ...((opts as { query?: unknown }).query as object | undefined),\n },\n ...opts,\n } as UseReadContractParameters);\n}\n\n/**\n * Whether `voucher` has already vouched for `candidate`.\n *\n * @deprecated Use the admin portal nomination API. See file header.\n */\nexport function useHasVouched(\n voucher: `0x${string}` | undefined,\n candidate: `0x${string}` | undefined,\n opts: Partial<UseReadContractParameters> = {},\n) {\n const addrs = useAroAddresses();\n return useReadContract({\n address: addrs?.AroNomination,\n abi: AroNomination_ABI,\n functionName: \"hasVouched\",\n args: voucher && candidate ? [voucher, candidate] : undefined,\n query: {\n enabled: Boolean(addrs?.AroNomination && voucher && candidate),\n ...((opts as { query?: unknown }).query as object | undefined),\n },\n ...opts,\n } as UseReadContractParameters);\n}\n\n/**\n * Write hook returning `writeContractAsync` for nominate/vouch/clear.\n *\n * @deprecated Use the admin portal nomination API. See file header.\n */\nexport function useNominationWriter() {\n return useWriteContract();\n}\n","import { useMemo } from \"react\";\nimport { useReadContracts } from \"wagmi\";\n\nimport { AroNomination_ABI } from \"../generated/abis.js\";\nimport { AroSBT_ABI } from \"../generated/abis.js\";\nimport { AroTier, NominationStatus } from \"../generated/types.js\";\nimport type { OnboardingState, OnboardingStep } from \"../workflows/onboarding.js\";\nimport { useAroAddresses } from \"./useAroAddresses.js\";\n\n/**\n * The hook the access-gate page reaches for. Batches the three reads it\n * needs (hasSBT, nomination, threshold) into a single multicall and\n * returns a derived OnboardingState matching `describeOnboardingState`\n * from the workflows module — but reactive instead of a one-shot read.\n */\nexport function useMembership(wallet: `0x${string}` | undefined): {\n data?: OnboardingState;\n isLoading: boolean;\n isError: boolean;\n refetch: () => void;\n} {\n const addrs = useAroAddresses();\n\n const reads = useReadContracts({\n contracts:\n addrs && wallet\n ? [\n {\n address: addrs.AroSBT,\n abi: AroSBT_ABI,\n functionName: \"hasSBT\",\n args: [wallet],\n },\n {\n address: addrs.AroNomination,\n abi: AroNomination_ABI,\n functionName: \"getNomination\",\n args: [wallet],\n },\n {\n address: addrs.AroNomination,\n abi: AroNomination_ABI,\n functionName: \"threshold\",\n },\n {\n address: addrs.AroSBT,\n abi: AroSBT_ABI,\n functionName: \"getMemberData\",\n args: [wallet],\n },\n ]\n : [],\n query: { enabled: Boolean(addrs && wallet) },\n });\n\n const data = useMemo<OnboardingState | undefined>(() => {\n if (!wallet) return { step: \"needs-wallet\", membership: { hasSBT: false } };\n if (!reads.data) return undefined;\n\n const [hasSBTResult, nomResult, thresholdResult, memberDataResult] = reads.data;\n const hasSBT = (hasSBTResult?.result as boolean) ?? false;\n\n if (hasSBT) {\n const md = memberDataResult?.result as\n | {\n memberId: bigint;\n issuanceDate: bigint;\n tier: bigint; // uint256 since the Tier enum was retired\n kycHash: `0x${string}`;\n }\n | undefined;\n return {\n step: \"member\" as OnboardingStep,\n membership: {\n hasSBT: true,\n tier: md?.tier,\n memberId: md?.memberId,\n issuanceDate: md?.issuanceDate,\n kycHash: md?.kycHash,\n },\n };\n }\n\n const nomTuple = nomResult?.result as\n | [`0x${string}`, readonly `0x${string}`[], bigint, number]\n | undefined;\n const threshold = thresholdResult?.result as bigint | undefined;\n\n if (!nomTuple || threshold === undefined) {\n return { step: \"needs-nomination\", membership: { hasSBT: false } };\n }\n\n const [nominator, vouchers, nominatedAt, status] = nomTuple;\n const thresholdN = Number(threshold);\n const voucherCount = vouchers.length;\n const snapshot = {\n status: status as NominationStatus,\n nominator,\n vouchers,\n nominatedAt,\n voucherCount,\n threshold: thresholdN,\n remaining: Math.max(0, thresholdN - voucherCount),\n ready: status === NominationStatus.APPROVED,\n };\n\n let step: OnboardingStep = \"needs-nomination\";\n if (snapshot.status === NominationStatus.PENDING) step = \"needs-vouches\";\n else if (snapshot.status === NominationStatus.APPROVED) step = \"needs-kyc\";\n\n return { step, membership: { hasSBT: false }, nomination: snapshot };\n }, [reads.data, wallet]);\n\n return {\n data,\n isLoading: reads.isLoading,\n isError: reads.isError,\n refetch: reads.refetch,\n };\n}\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,eAAe;AACxB,SAAS,kBAAkB;AASpB,SAAS,kBAAoF;AAClG,QAAM,UAAU,WAAW;AAC3B,SAAO,QAAQ,MAAM;AACnB,QAAI,CAAC,iBAAiB,OAAO,EAAG,QAAO;AACvC,WAAO,UAAU,OAAO;AAAA,EAC1B,GAAG,CAAC,OAAO,CAAC;AACd;AAEO,SAAS,gBAAmC;AACjD,QAAM,UAAU,WAAW;AAC3B,SAAO,iBAAiB,OAAO,IAAI,UAAU;AAC/C;AAEA,SAAS,iBAAiB,IAA8B;AACtD,SAAQ,oBAA0C,SAAS,EAAE;AAC/D;;;ACzBA,SAAS,iBAAiB,wBAAwD;AAS3E,SAAS,UACd,SACA,OAA2C,CAAC,GAC5C;AACA,QAAM,QAAQ,gBAAgB;AAC9B,SAAO,gBAAgB;AAAA,IACrB,SAAS,OAAO;AAAA,IAChB,KAAK;AAAA,IACL,cAAc;AAAA,IACd,MAAM,UAAU,CAAC,OAAO,IAAI;AAAA,IAC5B,OAAO;AAAA,MACL,SAAS,QAAQ,OAAO,UAAU,OAAO;AAAA,MACzC,GAAK,KAA6B;AAAA,IACpC;AAAA,IACA,GAAG;AAAA,EACL,CAA8B;AAChC;AAMO,SAAS,cACd,SACA,OAA2C,CAAC,GAC5C;AACA,QAAM,QAAQ,gBAAgB;AAC9B,SAAO,gBAAgB;AAA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,gBAAgB,YAAY,EAAE,QAAQ,MAAM,EAAE;AAC1E,QAAI,CAAC,MAAM,KAAM,QAAO;AAExB,UAAM,CAAC,cAAc,WAAW,iBAAiB,gBAAgB,IAAI,MAAM;AAC3E,UAAM,SAAU,cAAc,UAAsB;AAEpD,QAAI,QAAQ;AACV,YAAM,KAAK,kBAAkB;AAQ7B,aAAO;AAAA,QACL,MAAM;AAAA,QACN,YAAY;AAAA,UACV,QAAQ;AAAA,UACR,MAAM,IAAI;AAAA,UACV,UAAU,IAAI;AAAA,UACd,cAAc,IAAI;AAAA,UAClB,SAAS,IAAI;AAAA,QACf;AAAA,MACF;AAAA,IACF;AAEA,UAAM,WAAW,WAAW;AAG5B,UAAM,YAAY,iBAAiB;AAEnC,QAAI,CAAC,YAAY,cAAc,QAAW;AACxC,aAAO,EAAE,MAAM,oBAAoB,YAAY,EAAE,QAAQ,MAAM,EAAE;AAAA,IACnE;AAEA,UAAM,CAAC,WAAW,UAAU,aAAa,MAAM,IAAI;AACnD,UAAM,aAAa,OAAO,SAAS;AACnC,UAAM,eAAe,SAAS;AAC9B,UAAM,WAAW;AAAA,MACf;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,WAAW;AAAA,MACX,WAAW,KAAK,IAAI,GAAG,aAAa,YAAY;AAAA,MAChD,OAAO;AAAA,IACT;AAEA,QAAI,OAAuB;AAC3B,QAAI,SAAS,2BAAqC,QAAO;AAAA,aAChD,SAAS,4BAAsC,QAAO;AAE/D,WAAO,EAAE,MAAM,YAAY,EAAE,QAAQ,MAAM,GAAG,YAAY,SAAS;AAAA,EACrE,GAAG,CAAC,MAAM,MAAM,MAAM,CAAC;AAEvB,SAAO;AAAA,IACL;AAAA,IACA,WAAW,MAAM;AAAA,IACjB,SAAS,MAAM;AAAA,IACf,SAAS,MAAM;AAAA,EACjB;AACF;","names":["useReadContract","useWriteContract","useReadContract","useWriteContract","useMemo","useMemo"]}
1
+ {"version":3,"sources":["../../src/hooks/useAroAddresses.ts","../../src/hooks/useAroSBT.ts","../../src/hooks/useAroNomination.ts","../../src/hooks/useMembership.ts"],"sourcesContent":["import { useMemo } from \"react\";\nimport { useChainId } from \"wagmi\";\n\nimport { addresses, SUPPORTED_CHAIN_IDS, type AroChainId } from \"../generated/addresses.js\";\n\n/**\n * Returns the deployed contract addresses for the chain the user is\n * currently connected to. Returns `null` for chains the SDK does not\n * recognize so the dapp can render a \"switch network\" prompt.\n */\nexport function useAroAddresses(): Record<keyof typeof addresses[AroChainId], `0x${string}`> | null {\n const chainId = useChainId();\n return useMemo(() => {\n if (!isSupportedChain(chainId)) return null;\n return addresses[chainId];\n }, [chainId]);\n}\n\nexport function useAroChainId(): AroChainId | null {\n const chainId = useChainId();\n return isSupportedChain(chainId) ? chainId : null;\n}\n\nfunction isSupportedChain(id: number): id is AroChainId {\n return (SUPPORTED_CHAIN_IDS as readonly number[]).includes(id);\n}\n","import { useReadContract, useWriteContract, type UseReadContractParameters } from \"wagmi\";\n\nimport { AroSBT_ABI } from \"../generated/abis.js\";\nimport { useAroAddresses } from \"./useAroAddresses.js\";\n\n/**\n * Read whether an address holds an SBT. Returns `undefined` while loading\n * and `false` if the address has been confirmed as a non-member.\n */\nexport function useHasSBT(\n account: `0x${string}` | undefined,\n opts: Partial<UseReadContractParameters> = {},\n) {\n const addrs = useAroAddresses();\n return useReadContract({\n address: addrs?.AroSBT,\n abi: AroSBT_ABI,\n functionName: \"hasSBT\",\n args: account ? [account] : undefined,\n query: {\n enabled: Boolean(addrs?.AroSBT && account),\n ...((opts as { query?: unknown }).query as object | undefined),\n },\n ...opts,\n } as UseReadContractParameters);\n}\n\n/**\n * Decoded MemberData for an address. Throws on-chain if the address has\n * no SBT, so the dapp should only call this after `useHasSBT` returns true.\n */\nexport function useMemberData(\n account: `0x${string}` | undefined,\n opts: Partial<UseReadContractParameters> = {},\n) {\n const addrs = useAroAddresses();\n return useReadContract({\n address: addrs?.AroSBT,\n abi: AroSBT_ABI,\n functionName: \"getMemberData\",\n args: account ? [account] : undefined,\n query: {\n enabled: Boolean(addrs?.AroSBT && account),\n ...((opts as { query?: unknown }).query as object | undefined),\n },\n ...opts,\n } as UseReadContractParameters);\n}\n\n/**\n * Admin write hook for minting an SBT. The contract gates this behind\n * ROLE_MINTER, so the caller's wallet must be a holder of that role —\n * the dapp's UI should hide this control for non-admin users.\n */\nexport function useMintSBT() {\n return useWriteContract();\n}\n\n/**\n * Candidate-side write hook for AroSBT.mintWithApproval.\n *\n * The candidate submits an admin-issued EIP-712 voucher (see\n * `signMintApproval` in `../utils/mintApproval`) and its signature; the\n * contract recovers the approver, checks ROLE_MINTER, marks the voucher\n * nullified, and mints the SBT to msg.sender. The candidate's wallet\n * does NOT need any role — the gate is the signature.\n *\n * Usage:\n *\n * ```tsx\n * const addrs = useAroAddresses()\n * const { writeContractAsync } = useMintWithApproval()\n *\n * await writeContractAsync({\n * address: addrs!.AroSBT,\n * abi: AroSBT_ABI,\n * functionName: \"mintWithApproval\",\n * args: [approval, signature],\n * })\n * ```\n */\nexport function useMintWithApproval() {\n return useWriteContract();\n}\n","/**\n * @file Deprecated on-chain nomination hooks.\n *\n * The on-chain `AroNomination` contract is being retired because the\n * on-chain record of nominators and vouchers exposes the social graph of\n * prospective members publicly. The nomination and vouching flow has moved\n * to the admin portal backend (Next.js + Prisma + Postgres); consumers\n * should call its API instead of these hooks.\n *\n * These exports will be removed in a future major release.\n */\n\nimport { useReadContract, useWriteContract, type UseReadContractParameters } from \"wagmi\";\n\nimport { AroNomination_ABI } from \"../generated/abis.js\";\nimport { useAroAddresses } from \"./useAroAddresses.js\";\n\n/**\n * Read the full nomination record for a candidate.\n *\n * @deprecated Use the admin portal nomination API. The on-chain nomination\n * contract is being retired; see the file header for migration notes.\n */\nexport function useNomination(\n candidate: `0x${string}` | undefined,\n opts: Partial<UseReadContractParameters> = {},\n) {\n const addrs = useAroAddresses();\n return useReadContract({\n address: addrs?.AroNomination,\n abi: AroNomination_ABI,\n functionName: \"getNomination\",\n args: candidate ? [candidate] : undefined,\n query: {\n enabled: Boolean(addrs?.AroNomination && candidate),\n ...((opts as { query?: unknown }).query as object | undefined),\n },\n ...opts,\n } as UseReadContractParameters);\n}\n\n/**\n * Convenience read: just the status enum, when the dapp only needs to\n * branch on PENDING / APPROVED / CLEARED.\n *\n * @deprecated Use the admin portal nomination API. See file header.\n */\nexport function useNominationStatus(\n candidate: `0x${string}` | undefined,\n opts: Partial<UseReadContractParameters> = {},\n) {\n const addrs = useAroAddresses();\n return useReadContract({\n address: addrs?.AroNomination,\n abi: AroNomination_ABI,\n functionName: \"getNominationStatus\",\n args: candidate ? [candidate] : undefined,\n query: {\n enabled: Boolean(addrs?.AroNomination && candidate),\n ...((opts as { query?: unknown }).query as object | undefined),\n },\n ...opts,\n } as UseReadContractParameters);\n}\n\n/**\n * Current vouch threshold (typically 3 per KYC Policy §6.3).\n *\n * @deprecated Use the admin portal nomination API. See file header.\n */\nexport function useNominationThreshold(opts: Partial<UseReadContractParameters> = {}) {\n const addrs = useAroAddresses();\n return useReadContract({\n address: addrs?.AroNomination,\n abi: AroNomination_ABI,\n functionName: \"threshold\",\n query: {\n enabled: Boolean(addrs?.AroNomination),\n ...((opts as { query?: unknown }).query as object | undefined),\n },\n ...opts,\n } as UseReadContractParameters);\n}\n\n/**\n * Whether `voucher` has already vouched for `candidate`.\n *\n * @deprecated Use the admin portal nomination API. See file header.\n */\nexport function useHasVouched(\n voucher: `0x${string}` | undefined,\n candidate: `0x${string}` | undefined,\n opts: Partial<UseReadContractParameters> = {},\n) {\n const addrs = useAroAddresses();\n return useReadContract({\n address: addrs?.AroNomination,\n abi: AroNomination_ABI,\n functionName: \"hasVouched\",\n args: voucher && candidate ? [voucher, candidate] : undefined,\n query: {\n enabled: Boolean(addrs?.AroNomination && voucher && candidate),\n ...((opts as { query?: unknown }).query as object | undefined),\n },\n ...opts,\n } as UseReadContractParameters);\n}\n\n/**\n * Write hook returning `writeContractAsync` for nominate/vouch/clear.\n *\n * @deprecated Use the admin portal nomination API. See file header.\n */\nexport function useNominationWriter() {\n return useWriteContract();\n}\n","import { AroTier, NominationStatus } from \"../generated/types.js\";\nimport type { OnboardingState, OnboardingStep } from \"../workflows/onboarding.js\";\n\nimport { AroNomination_ABI } from \"../generated/abis.js\";\nimport { AroSBT_ABI } from \"../generated/abis.js\";\nimport { useAroAddresses } from \"./useAroAddresses.js\";\nimport { useMemo } from \"react\";\nimport { useReadContracts } from \"wagmi\";\n\n/**\n * The hook the access-gate page reaches for. Batches the three reads it\n * needs (hasSBT, nomination, threshold) into a single multicall and\n * returns a derived OnboardingState matching `describeOnboardingState`\n * from the workflows module — but reactive instead of a one-shot read.\n */\nexport function useMembership(wallet: `0x${string}` | undefined): {\n data?: OnboardingState;\n isLoading: boolean;\n isError: boolean;\n refetch: () => void;\n} {\n const addrs = useAroAddresses();\n\n const reads = useReadContracts({\n contracts:\n addrs && wallet\n ? [\n {\n address: addrs.AroSBT,\n abi: AroSBT_ABI,\n functionName: \"hasSBT\",\n args: [wallet],\n },\n {\n address: addrs.AroNomination,\n abi: AroNomination_ABI,\n functionName: \"getNomination\",\n args: [wallet],\n },\n {\n address: addrs.AroNomination,\n abi: AroNomination_ABI,\n functionName: \"threshold\",\n },\n {\n address: addrs.AroSBT,\n abi: AroSBT_ABI,\n functionName: \"getMemberData\",\n args: [wallet],\n },\n ]\n : [],\n query: { enabled: Boolean(addrs && wallet) },\n });\n\n const data = useMemo<OnboardingState | undefined>(() => {\n if (!wallet) return { step: \"needs-wallet\", membership: { hasSBT: false } };\n if (!reads.data) return undefined;\n\n const [hasSBTResult, nomResult, thresholdResult, memberDataResult] = reads.data;\n const hasSBT = (hasSBTResult?.result as boolean) ?? false;\n\n if (hasSBT) {\n const md = memberDataResult?.result as\n | {\n memberId: bigint;\n issuanceDate: bigint;\n tier: number; // AroSBT.Tier enum (uint8)\n kycHash: `0x${string}`;\n }\n | undefined;\n return {\n step: \"member\" as OnboardingStep,\n membership: {\n hasSBT: true,\n tier: md?.tier,\n memberId: md?.memberId,\n issuanceDate: md?.issuanceDate,\n kycHash: md?.kycHash,\n },\n };\n }\n\n const nomTuple = nomResult?.result as\n | [`0x${string}`, readonly `0x${string}`[], bigint, number]\n | undefined;\n const threshold = thresholdResult?.result as bigint | undefined;\n\n if (!nomTuple || threshold === undefined) {\n return { step: \"needs-nomination\", membership: { hasSBT: false } };\n }\n\n const [nominator, vouchers, nominatedAt, status] = nomTuple;\n const thresholdN = Number(threshold);\n const voucherCount = vouchers.length;\n const snapshot = {\n status: status as NominationStatus,\n nominator,\n vouchers,\n nominatedAt,\n voucherCount,\n threshold: thresholdN,\n remaining: Math.max(0, thresholdN - voucherCount),\n ready: status === NominationStatus.APPROVED,\n };\n\n let step: OnboardingStep = \"needs-nomination\";\n if (snapshot.status === NominationStatus.PENDING) step = \"needs-vouches\";\n else if (snapshot.status === NominationStatus.APPROVED) step = \"needs-kyc\";\n\n return { step, membership: { hasSBT: false }, nomination: snapshot };\n }, [reads.data, wallet]);\n\n return {\n data,\n isLoading: reads.isLoading,\n isError: reads.isError,\n refetch: reads.refetch,\n };\n}\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,eAAe;AACxB,SAAS,kBAAkB;AASpB,SAAS,kBAAoF;AAClG,QAAM,UAAU,WAAW;AAC3B,SAAO,QAAQ,MAAM;AACnB,QAAI,CAAC,iBAAiB,OAAO,EAAG,QAAO;AACvC,WAAO,UAAU,OAAO;AAAA,EAC1B,GAAG,CAAC,OAAO,CAAC;AACd;AAEO,SAAS,gBAAmC;AACjD,QAAM,UAAU,WAAW;AAC3B,SAAO,iBAAiB,OAAO,IAAI,UAAU;AAC/C;AAEA,SAAS,iBAAiB,IAA8B;AACtD,SAAQ,oBAA0C,SAAS,EAAE;AAC/D;;;ACzBA,SAAS,iBAAiB,wBAAwD;AAS3E,SAAS,UACd,SACA,OAA2C,CAAC,GAC5C;AACA,QAAM,QAAQ,gBAAgB;AAC9B,SAAO,gBAAgB;AAAA,IACrB,SAA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