@aromedia/contracts-sdk 0.2.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/LICENSE +21 -0
- package/README.md +121 -0
- package/dist/chains.cjs +67 -0
- package/dist/chains.cjs.map +1 -0
- package/dist/chains.d.cts +826 -0
- package/dist/chains.d.ts +826 -0
- package/dist/chains.js +23 -0
- package/dist/chains.js.map +1 -0
- package/dist/chunk-7I5N3BGV.js +271 -0
- package/dist/chunk-7I5N3BGV.js.map +1 -0
- package/dist/chunk-BYPGUFYV.js +50 -0
- package/dist/chunk-BYPGUFYV.js.map +1 -0
- package/dist/chunk-FWZ7XKFC.js +91 -0
- package/dist/chunk-FWZ7XKFC.js.map +1 -0
- package/dist/chunk-J6YVU3VA.js +35 -0
- package/dist/chunk-J6YVU3VA.js.map +1 -0
- package/dist/chunk-TZQHQLNY.js +7213 -0
- package/dist/chunk-TZQHQLNY.js.map +1 -0
- package/dist/generated/abis.cjs +7244 -0
- package/dist/generated/abis.cjs.map +1 -0
- package/dist/generated/abis.d.cts +11005 -0
- package/dist/generated/abis.d.ts +11005 -0
- package/dist/generated/abis.js +21 -0
- package/dist/generated/abis.js.map +1 -0
- package/dist/generated/addresses.cjs +119 -0
- package/dist/generated/addresses.cjs.map +1 -0
- package/dist/generated/addresses.d.cts +18 -0
- package/dist/generated/addresses.d.ts +18 -0
- package/dist/generated/addresses.js +15 -0
- package/dist/generated/addresses.js.map +1 -0
- package/dist/hooks/index.cjs +2005 -0
- package/dist/hooks/index.cjs.map +1 -0
- package/dist/hooks/index.d.cts +63 -0
- package/dist/hooks/index.d.ts +63 -0
- package/dist/hooks/index.js +218 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/index.cjs +7884 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +42 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.js +258 -0
- package/dist/index.js.map +1 -0
- package/dist/onboarding-BHpAJaNW.d.cts +302 -0
- package/dist/onboarding-DxL_LpM3.d.ts +302 -0
- package/dist/workflows/index.cjs +1988 -0
- package/dist/workflows/index.cjs.map +1 -0
- package/dist/workflows/index.d.cts +72 -0
- package/dist/workflows/index.d.ts +72 -0
- package/dist/workflows/index.js +25 -0
- package/dist/workflows/index.js.map +1 -0
- package/package.json +120 -0
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import { PublicClient, WalletClient, GetContractReturnType, Chain, Transport, Account, Hex } from 'viem';
|
|
2
|
+
import { AroChainId } from './generated/addresses.js';
|
|
3
|
+
import { AroMediaAccessManager_ABI, AroMediaAssetsRegistry_ABI, ForcedTransferManager_ABI, AroMediaIncMultiSig_ABI, AroNomination_ABI, AroMediaRWA_ABI, AroSBT_ABI } from './generated/abis.js';
|
|
4
|
+
|
|
5
|
+
/** Mirrors AroSBT.Tier. */
|
|
6
|
+
declare enum AroTier {
|
|
7
|
+
STANDARD = 0,
|
|
8
|
+
VERIFIED = 1,
|
|
9
|
+
TRUSTED = 2,
|
|
10
|
+
FOUNDING = 3
|
|
11
|
+
}
|
|
12
|
+
declare const AroTierLabels: Record<AroTier, string>;
|
|
13
|
+
/** Mirrors AroNomination.NominationStatus. */
|
|
14
|
+
declare enum NominationStatus {
|
|
15
|
+
NONE = 0,
|
|
16
|
+
PENDING = 1,
|
|
17
|
+
APPROVED = 2,
|
|
18
|
+
CLEARED = 3
|
|
19
|
+
}
|
|
20
|
+
declare const NominationStatusLabels: Record<NominationStatus, string>;
|
|
21
|
+
/** Mirrors ForcedTransferManager.ForcedTransferStatus. */
|
|
22
|
+
declare enum ForcedTransferStatus {
|
|
23
|
+
PENDING = 0,
|
|
24
|
+
APPROVED = 1,
|
|
25
|
+
EXECUTED = 2,
|
|
26
|
+
CANCELLED = 3
|
|
27
|
+
}
|
|
28
|
+
declare const ForcedTransferStatusLabels: Record<ForcedTransferStatus, string>;
|
|
29
|
+
|
|
30
|
+
type AroAccessManagerContract = GetContractReturnType<typeof AroMediaAccessManager_ABI, {
|
|
31
|
+
public: PublicClient;
|
|
32
|
+
wallet?: WalletClient;
|
|
33
|
+
}>;
|
|
34
|
+
interface AccessManagerClientOpts {
|
|
35
|
+
address: `0x${string}`;
|
|
36
|
+
publicClient: PublicClient;
|
|
37
|
+
walletClient?: WalletClient;
|
|
38
|
+
}
|
|
39
|
+
declare function createAccessManagerClient(opts: AccessManagerClientOpts): AroAccessManagerContract;
|
|
40
|
+
/**
|
|
41
|
+
* Role IDs as defined in AroMediaAccessManager.sol. Mirroring them here
|
|
42
|
+
* lets the dapp grant/revoke without re-reading the contract just to know
|
|
43
|
+
* which uint64 corresponds to which role.
|
|
44
|
+
*/
|
|
45
|
+
declare const AroRoles: {
|
|
46
|
+
readonly ORG_ADMIN: 0n;
|
|
47
|
+
readonly PROTOCOL_ADMIN: 1n;
|
|
48
|
+
readonly TREASURY_CONTROLLER: 2n;
|
|
49
|
+
readonly MARKET_MAKER: 3n;
|
|
50
|
+
readonly MINTER: 4n;
|
|
51
|
+
};
|
|
52
|
+
type AroRoleName = keyof typeof AroRoles;
|
|
53
|
+
|
|
54
|
+
type AroAssetsRegistryContract = GetContractReturnType<typeof AroMediaAssetsRegistry_ABI, {
|
|
55
|
+
public: PublicClient;
|
|
56
|
+
wallet?: WalletClient;
|
|
57
|
+
}>;
|
|
58
|
+
interface AssetsRegistryClientOpts {
|
|
59
|
+
address: `0x${string}`;
|
|
60
|
+
publicClient: PublicClient;
|
|
61
|
+
walletClient?: WalletClient;
|
|
62
|
+
}
|
|
63
|
+
declare function createAssetsRegistryClient(opts: AssetsRegistryClientOpts): AroAssetsRegistryContract;
|
|
64
|
+
|
|
65
|
+
type ForcedTransferManagerContract = GetContractReturnType<typeof ForcedTransferManager_ABI, {
|
|
66
|
+
public: PublicClient;
|
|
67
|
+
wallet?: WalletClient;
|
|
68
|
+
}>;
|
|
69
|
+
interface ForcedTransferClientOpts {
|
|
70
|
+
address: `0x${string}`;
|
|
71
|
+
publicClient: PublicClient;
|
|
72
|
+
walletClient?: WalletClient;
|
|
73
|
+
}
|
|
74
|
+
declare function createForcedTransferClient(opts: ForcedTransferClientOpts): ForcedTransferManagerContract;
|
|
75
|
+
|
|
76
|
+
type AroMultiSigContract = GetContractReturnType<typeof AroMediaIncMultiSig_ABI, {
|
|
77
|
+
public: PublicClient;
|
|
78
|
+
wallet?: WalletClient;
|
|
79
|
+
}>;
|
|
80
|
+
interface MultiSigClientOpts {
|
|
81
|
+
address: `0x${string}`;
|
|
82
|
+
publicClient: PublicClient;
|
|
83
|
+
walletClient?: WalletClient;
|
|
84
|
+
}
|
|
85
|
+
declare function createMultiSigClient(opts: MultiSigClientOpts): AroMultiSigContract;
|
|
86
|
+
|
|
87
|
+
type AroNominationContract = GetContractReturnType<typeof AroNomination_ABI, {
|
|
88
|
+
public: PublicClient;
|
|
89
|
+
wallet?: WalletClient;
|
|
90
|
+
}>;
|
|
91
|
+
interface NominationClientOpts {
|
|
92
|
+
address: `0x${string}`;
|
|
93
|
+
publicClient: PublicClient;
|
|
94
|
+
walletClient?: WalletClient;
|
|
95
|
+
}
|
|
96
|
+
declare function createNominationClient(opts: NominationClientOpts): AroNominationContract;
|
|
97
|
+
|
|
98
|
+
type AroRWAContract = GetContractReturnType<typeof AroMediaRWA_ABI, {
|
|
99
|
+
public: PublicClient;
|
|
100
|
+
wallet?: WalletClient;
|
|
101
|
+
}>;
|
|
102
|
+
interface RwaClientOpts {
|
|
103
|
+
address: `0x${string}`;
|
|
104
|
+
publicClient: PublicClient;
|
|
105
|
+
walletClient?: WalletClient;
|
|
106
|
+
}
|
|
107
|
+
declare function createRwaClient(opts: RwaClientOpts): AroRWAContract;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Typed viem contract handle for AroSBT.
|
|
111
|
+
*
|
|
112
|
+
* Use `read.hasSBT(address)`, `read.getMemberData(address)`, etc. for views;
|
|
113
|
+
* `write.mint(...)`, `write.revoke(...)`, etc. for state-changing calls when
|
|
114
|
+
* a wallet client is bound.
|
|
115
|
+
*/
|
|
116
|
+
type AroSBTContract = GetContractReturnType<typeof AroSBT_ABI, {
|
|
117
|
+
public: PublicClient;
|
|
118
|
+
wallet?: WalletClient;
|
|
119
|
+
}>;
|
|
120
|
+
interface SbtClientOpts {
|
|
121
|
+
address: `0x${string}`;
|
|
122
|
+
publicClient: PublicClient;
|
|
123
|
+
walletClient?: WalletClient;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Bind the AroSBT ABI to its deployed address and the caller's viem
|
|
127
|
+
* clients. The returned object is a thin proxy — calling `client.read.x`
|
|
128
|
+
* preserves full type inference from the ABI.
|
|
129
|
+
*/
|
|
130
|
+
declare function createSbtClient(opts: SbtClientOpts): AroSBTContract;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Per-contract address overrides. Useful for:
|
|
134
|
+
* • local Hardhat where ignition deployments aren't picked up at build time
|
|
135
|
+
* • staging deployments living outside of `ignition/deployments`
|
|
136
|
+
* • forked-network testing where contracts are at non-canonical addresses
|
|
137
|
+
*/
|
|
138
|
+
type AroAddressOverrides = Partial<Record<"AroSBT" | "AroNomination" | "AroMediaRWA" | "AroMediaAssetsRegistry" | "AroMediaAccessManager" | "AroMediaIncMultiSig" | "ForcedTransferManager", `0x${string}`>>;
|
|
139
|
+
interface CreateAroSdkOpts {
|
|
140
|
+
/** Target chain. Must be a chainId the SDK knows about. */
|
|
141
|
+
chain: Chain & {
|
|
142
|
+
id: AroChainId;
|
|
143
|
+
};
|
|
144
|
+
/** viem transport — defaults to `http()` against the chain's default RPC. */
|
|
145
|
+
transport?: Transport;
|
|
146
|
+
/** Optional wallet client for state-changing calls. */
|
|
147
|
+
walletClient?: WalletClient;
|
|
148
|
+
/** Override one or more contract addresses (local dev, staging, etc.). */
|
|
149
|
+
overrides?: AroAddressOverrides;
|
|
150
|
+
}
|
|
151
|
+
interface AroSdk {
|
|
152
|
+
chainId: AroChainId;
|
|
153
|
+
publicClient: PublicClient;
|
|
154
|
+
walletClient?: WalletClient;
|
|
155
|
+
/** Soulbound identity token. */
|
|
156
|
+
sbt: AroSBTContract;
|
|
157
|
+
/** Nomination + vouching workflow. */
|
|
158
|
+
nomination: AroNominationContract;
|
|
159
|
+
/** RWA security token (ARO). */
|
|
160
|
+
rwa: AroRWAContract;
|
|
161
|
+
/** ERC-721 assets registry. */
|
|
162
|
+
assetsRegistry: AroAssetsRegistryContract;
|
|
163
|
+
/** Centralized AccessManager (role grants/revokes). */
|
|
164
|
+
accessManager: AroAccessManagerContract;
|
|
165
|
+
/** ERC-7913 multi-sig smart-contract wallet. */
|
|
166
|
+
multiSig: AroMultiSigContract;
|
|
167
|
+
/** Regulator-driven forced transfer workflow. */
|
|
168
|
+
forcedTransfer: ForcedTransferManagerContract;
|
|
169
|
+
/** Resolve a contract address from the registry (with overrides applied). */
|
|
170
|
+
addressOf: (name: keyof AroAddressOverrides) => `0x${string}`;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* The single entry point most consumers reach for. Returns a bundle of
|
|
174
|
+
* typed contract handles bound to a viem PublicClient (and optionally a
|
|
175
|
+
* WalletClient for writes).
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* const sdk = createAroSdk({
|
|
179
|
+
* chain: sepolia as Chain & { id: 11155111 },
|
|
180
|
+
* walletClient,
|
|
181
|
+
* });
|
|
182
|
+
* const isMember = await sdk.sbt.read.hasSBT([userAddress]);
|
|
183
|
+
* if (!isMember) await sdk.nomination.write.nominate([userAddress]);
|
|
184
|
+
*/
|
|
185
|
+
declare function createAroSdk(opts: CreateAroSdkOpts): AroSdk;
|
|
186
|
+
/** Helper: peek at the address registry without instantiating an SDK. */
|
|
187
|
+
declare function addressesFor(chainId: AroChainId): Record<keyof AroAddressOverrides, `0x${string}`>;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Onboarding workflow helpers. These wrap multi-call sequences from the
|
|
191
|
+
* ARO KYC/AML/CFT Policy §6 so the dapp does not have to re-implement the
|
|
192
|
+
* choreography in three different places.
|
|
193
|
+
*
|
|
194
|
+
* Mental model (per Policy §6.3):
|
|
195
|
+
*
|
|
196
|
+
* 1. Existing member calls `nominateCandidate(candidate)`.
|
|
197
|
+
* The nominator's vouch counts as the first vouch automatically.
|
|
198
|
+
*
|
|
199
|
+
* 2. Other existing members call `vouchForCandidate(candidate)`. Each
|
|
200
|
+
* vouch increments the count; once `threshold` is reached (3 per
|
|
201
|
+
* policy), the nomination moves to APPROVED.
|
|
202
|
+
*
|
|
203
|
+
* 3. Off-chain: candidate completes Didit KYC (per MEMO-KYC-PROVIDER).
|
|
204
|
+
* Webhook posts back the verification result.
|
|
205
|
+
*
|
|
206
|
+
* 4. Compliance Officer reviews and either rejects (`clearNomination`)
|
|
207
|
+
* or mints the SBT (`mintSBTForApproved`) with the KYC hash.
|
|
208
|
+
*
|
|
209
|
+
* 5. SBT minted → AccessManager grants member roles → access unlocked.
|
|
210
|
+
*
|
|
211
|
+
* The write paths use `walletClient.writeContract` directly rather than
|
|
212
|
+
* the typed contract `.write` namespace. This is intentional: viem
|
|
213
|
+
* narrows the contract handle's write surface away when the SDK is
|
|
214
|
+
* instantiated without a walletClient, but workflows are run on demand
|
|
215
|
+
* after the dapp's wallet connects.
|
|
216
|
+
*/
|
|
217
|
+
interface MembershipStatus {
|
|
218
|
+
hasSBT: boolean;
|
|
219
|
+
tier?: AroTier;
|
|
220
|
+
tokenId?: bigint;
|
|
221
|
+
memberId?: bigint;
|
|
222
|
+
issuanceDate?: bigint;
|
|
223
|
+
kycHash?: `0x${string}`;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* One-call read for the dapp's access-gate page. Returns whether the
|
|
227
|
+
* connected wallet holds an SBT and, if so, decoded member data.
|
|
228
|
+
*
|
|
229
|
+
* Implementation note: reads are issued via `publicClient.readContract`
|
|
230
|
+
* with the ABI rather than the typed contract instance's `.read`
|
|
231
|
+
* namespace. viem ≥2.50 narrows `contract.read.*` based on whether a
|
|
232
|
+
* walletClient was bound at construction time; bypassing that gives us a
|
|
233
|
+
* stable, version-independent signature.
|
|
234
|
+
*/
|
|
235
|
+
declare function checkMembershipStatus(sdk: AroSdk, account: `0x${string}`): Promise<MembershipStatus>;
|
|
236
|
+
interface NominationSnapshot {
|
|
237
|
+
status: NominationStatus;
|
|
238
|
+
nominator: `0x${string}`;
|
|
239
|
+
vouchers: readonly `0x${string}`[];
|
|
240
|
+
nominatedAt: bigint;
|
|
241
|
+
voucherCount: number;
|
|
242
|
+
threshold: number;
|
|
243
|
+
remaining: number;
|
|
244
|
+
ready: boolean;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Snapshot of the candidate's progress through the vouch flow. The dapp
|
|
248
|
+
* shows this as "you need N more vouches" in the onboarding UI.
|
|
249
|
+
*/
|
|
250
|
+
declare function getNominationSnapshot(sdk: AroSdk, candidate: `0x${string}`): Promise<NominationSnapshot>;
|
|
251
|
+
/**
|
|
252
|
+
* Send `nominate(candidate)` from the connected wallet. The contract
|
|
253
|
+
* gates this behind "caller must already be an SBT holder"; we surface
|
|
254
|
+
* the right user-facing message via `AroContractError`.
|
|
255
|
+
*/
|
|
256
|
+
declare function nominateCandidate(sdk: AroSdk, candidate: `0x${string}`, opts?: {
|
|
257
|
+
account?: Account | `0x${string}`;
|
|
258
|
+
}): Promise<Hex>;
|
|
259
|
+
declare function vouchForCandidate(sdk: AroSdk, candidate: `0x${string}`, opts?: {
|
|
260
|
+
account?: Account | `0x${string}`;
|
|
261
|
+
}): Promise<Hex>;
|
|
262
|
+
/**
|
|
263
|
+
* Admin path: clear (reject) a nomination. Restricted to authorized roles
|
|
264
|
+
* via AccessManager; will revert with AccessManagedUnauthorized if the
|
|
265
|
+
* caller lacks the role.
|
|
266
|
+
*/
|
|
267
|
+
declare function clearNomination(sdk: AroSdk, candidate: `0x${string}`, opts?: {
|
|
268
|
+
account?: Account | `0x${string}`;
|
|
269
|
+
}): Promise<Hex>;
|
|
270
|
+
interface MintSBTOpts {
|
|
271
|
+
to: `0x${string}`;
|
|
272
|
+
/** keccak256 of the verified KYC payload — see utils/kycHash.ts. */
|
|
273
|
+
kycHash: `0x${string}`;
|
|
274
|
+
/** Off-chain profile metadata URI (ipfs://... or https://...). */
|
|
275
|
+
metadataURI: string;
|
|
276
|
+
/** Initial tier (defaults to STANDARD per Policy §6.1). */
|
|
277
|
+
tier?: AroTier;
|
|
278
|
+
account?: Account | `0x${string}`;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Admin-only: mint the SBT for an approved candidate. The contract gates
|
|
282
|
+
* this behind ROLE_MINTER via AccessManager (per AroMediaAccessManager).
|
|
283
|
+
*
|
|
284
|
+
* Calls the 4-arg mint overload explicitly so the tier is always
|
|
285
|
+
* specified — the 3-arg overload silently defaults to STANDARD, which
|
|
286
|
+
* we don't want callers to rely on implicitly.
|
|
287
|
+
*/
|
|
288
|
+
declare function mintSBTForApproved(sdk: AroSdk, opts: MintSBTOpts): Promise<Hex>;
|
|
289
|
+
/**
|
|
290
|
+
* Convenience: enumerate the policy-derived next action for a wallet so
|
|
291
|
+
* the onboarding UI can render the correct step (Connect → Nominate →
|
|
292
|
+
* Vouch → KYC → Mint).
|
|
293
|
+
*/
|
|
294
|
+
type OnboardingStep = "needs-wallet" | "needs-nomination" | "needs-vouches" | "needs-kyc" | "needs-admin-mint" | "member";
|
|
295
|
+
interface OnboardingState {
|
|
296
|
+
step: OnboardingStep;
|
|
297
|
+
membership: MembershipStatus;
|
|
298
|
+
nomination?: NominationSnapshot;
|
|
299
|
+
}
|
|
300
|
+
declare function describeOnboardingState(sdk: AroSdk, wallet: `0x${string}` | undefined): Promise<OnboardingState>;
|
|
301
|
+
|
|
302
|
+
export { type AccessManagerClientOpts as A, createAroSdk as B, type CreateAroSdkOpts as C, createAssetsRegistryClient as D, createForcedTransferClient as E, type ForcedTransferClientOpts as F, createMultiSigClient as G, createNominationClient as H, createRwaClient as I, createSbtClient as J, describeOnboardingState as K, getNominationSnapshot as L, type MembershipStatus as M, type NominationClientOpts as N, type OnboardingState as O, mintSBTForApproved as P, nominateCandidate as Q, type RwaClientOpts as R, type SbtClientOpts as S, vouchForCandidate as T, type AroAccessManagerContract as a, type AroAddressOverrides as b, type AroAssetsRegistryContract as c, type AroMultiSigContract as d, type AroNominationContract as e, type AroRWAContract as f, type AroRoleName as g, AroRoles as h, type AroSBTContract as i, type AroSdk as j, AroTier as k, AroTierLabels as l, type AssetsRegistryClientOpts as m, type ForcedTransferManagerContract as n, ForcedTransferStatus as o, ForcedTransferStatusLabels as p, type MintSBTOpts as q, type MultiSigClientOpts as r, type NominationSnapshot as s, NominationStatus as t, NominationStatusLabels as u, type OnboardingStep as v, addressesFor as w, checkMembershipStatus as x, clearNomination as y, createAccessManagerClient as z };
|