@whitewall-os/sdk 0.1.0 → 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/dist/abis.d.ts CHANGED
@@ -1,15 +1,15 @@
1
- export declare const humanVerifiedPolicyAbi: readonly [{
1
+ export declare const tieredPolicyAbi: readonly [{
2
2
  readonly inputs: readonly [];
3
- readonly name: "getRequiredTier";
3
+ readonly name: "getIdentityRegistry";
4
4
  readonly outputs: readonly [{
5
5
  readonly name: "";
6
- readonly type: "uint8";
6
+ readonly type: "address";
7
7
  }];
8
8
  readonly stateMutability: "view";
9
9
  readonly type: "function";
10
10
  }, {
11
11
  readonly inputs: readonly [];
12
- readonly name: "getIdentityRegistry";
12
+ readonly name: "getWorldIdValidator";
13
13
  readonly outputs: readonly [{
14
14
  readonly name: "";
15
15
  readonly type: "address";
@@ -18,7 +18,7 @@ export declare const humanVerifiedPolicyAbi: readonly [{
18
18
  readonly type: "function";
19
19
  }, {
20
20
  readonly inputs: readonly [];
21
- readonly name: "getValidationRegistry";
21
+ readonly name: "getStripeKYCValidator";
22
22
  readonly outputs: readonly [{
23
23
  readonly name: "";
24
24
  readonly type: "address";
@@ -27,13 +27,22 @@ export declare const humanVerifiedPolicyAbi: readonly [{
27
27
  readonly type: "function";
28
28
  }, {
29
29
  readonly inputs: readonly [];
30
- readonly name: "getWorldIdValidator";
30
+ readonly name: "getPlaidCreditValidator";
31
31
  readonly outputs: readonly [{
32
32
  readonly name: "";
33
33
  readonly type: "address";
34
34
  }];
35
35
  readonly stateMutability: "view";
36
36
  readonly type: "function";
37
+ }, {
38
+ readonly inputs: readonly [];
39
+ readonly name: "getMinCreditScore";
40
+ readonly outputs: readonly [{
41
+ readonly name: "";
42
+ readonly type: "uint8";
43
+ }];
44
+ readonly stateMutability: "view";
45
+ readonly type: "function";
37
46
  }];
38
47
  export declare const identityRegistryAbi: readonly [{
39
48
  readonly inputs: readonly [{
@@ -287,6 +296,95 @@ export declare const worldIdValidatorAbi: readonly [{
287
296
  readonly outputs: readonly [];
288
297
  readonly stateMutability: "nonpayable";
289
298
  readonly type: "function";
299
+ }, {
300
+ readonly inputs: readonly [{
301
+ readonly name: "agentId";
302
+ readonly type: "uint256";
303
+ }];
304
+ readonly name: "isHumanVerified";
305
+ readonly outputs: readonly [{
306
+ readonly name: "";
307
+ readonly type: "bool";
308
+ }];
309
+ readonly stateMutability: "view";
310
+ readonly type: "function";
311
+ }];
312
+ export declare const stripeKYCValidatorAbi: readonly [{
313
+ readonly inputs: readonly [{
314
+ readonly name: "agentId";
315
+ readonly type: "uint256";
316
+ }];
317
+ readonly name: "isKYCVerified";
318
+ readonly outputs: readonly [{
319
+ readonly name: "";
320
+ readonly type: "bool";
321
+ }];
322
+ readonly stateMutability: "view";
323
+ readonly type: "function";
324
+ }, {
325
+ readonly inputs: readonly [{
326
+ readonly name: "agentId";
327
+ readonly type: "uint256";
328
+ }];
329
+ readonly name: "getKYCData";
330
+ readonly outputs: readonly [{
331
+ readonly name: "verified";
332
+ readonly type: "bool";
333
+ }, {
334
+ readonly name: "sessionHash";
335
+ readonly type: "bytes32";
336
+ }, {
337
+ readonly name: "verifiedAt";
338
+ readonly type: "uint256";
339
+ }];
340
+ readonly stateMutability: "view";
341
+ readonly type: "function";
342
+ }];
343
+ export declare const plaidCreditValidatorAbi: readonly [{
344
+ readonly inputs: readonly [{
345
+ readonly name: "agentId";
346
+ readonly type: "uint256";
347
+ }];
348
+ readonly name: "getCreditScore";
349
+ readonly outputs: readonly [{
350
+ readonly name: "";
351
+ readonly type: "uint8";
352
+ }];
353
+ readonly stateMutability: "view";
354
+ readonly type: "function";
355
+ }, {
356
+ readonly inputs: readonly [{
357
+ readonly name: "agentId";
358
+ readonly type: "uint256";
359
+ }];
360
+ readonly name: "hasCreditScore";
361
+ readonly outputs: readonly [{
362
+ readonly name: "";
363
+ readonly type: "bool";
364
+ }];
365
+ readonly stateMutability: "view";
366
+ readonly type: "function";
367
+ }, {
368
+ readonly inputs: readonly [{
369
+ readonly name: "agentId";
370
+ readonly type: "uint256";
371
+ }];
372
+ readonly name: "getCreditData";
373
+ readonly outputs: readonly [{
374
+ readonly name: "score";
375
+ readonly type: "uint8";
376
+ }, {
377
+ readonly name: "dataHash";
378
+ readonly type: "bytes32";
379
+ }, {
380
+ readonly name: "verifiedAt";
381
+ readonly type: "uint256";
382
+ }, {
383
+ readonly name: "hasScore";
384
+ readonly type: "bool";
385
+ }];
386
+ readonly stateMutability: "view";
387
+ readonly type: "function";
290
388
  }];
291
389
  export declare const whitewallConsumerAbi: readonly [{
292
390
  readonly anonymous: false;
package/dist/abis.js CHANGED
@@ -1,33 +1,40 @@
1
- // ── HumanVerifiedPolicyentry point, SDK reads config from here ──
2
- export const humanVerifiedPolicyAbi = [
1
+ // ── TieredPolicyunified policy, SDK reads all config from here ──
2
+ export const tieredPolicyAbi = [
3
3
  {
4
4
  inputs: [],
5
- name: "getRequiredTier",
6
- outputs: [{ name: "", type: "uint8" }],
5
+ name: "getIdentityRegistry",
6
+ outputs: [{ name: "", type: "address" }],
7
7
  stateMutability: "view",
8
8
  type: "function",
9
9
  },
10
10
  {
11
11
  inputs: [],
12
- name: "getIdentityRegistry",
12
+ name: "getWorldIdValidator",
13
13
  outputs: [{ name: "", type: "address" }],
14
14
  stateMutability: "view",
15
15
  type: "function",
16
16
  },
17
17
  {
18
18
  inputs: [],
19
- name: "getValidationRegistry",
19
+ name: "getStripeKYCValidator",
20
20
  outputs: [{ name: "", type: "address" }],
21
21
  stateMutability: "view",
22
22
  type: "function",
23
23
  },
24
24
  {
25
25
  inputs: [],
26
- name: "getWorldIdValidator",
26
+ name: "getPlaidCreditValidator",
27
27
  outputs: [{ name: "", type: "address" }],
28
28
  stateMutability: "view",
29
29
  type: "function",
30
30
  },
31
+ {
32
+ inputs: [],
33
+ name: "getMinCreditScore",
34
+ outputs: [{ name: "", type: "uint8" }],
35
+ stateMutability: "view",
36
+ type: "function",
37
+ },
31
38
  ];
32
39
  // ── IdentityRegistry ──
33
40
  export const identityRegistryAbi = [
@@ -184,7 +191,66 @@ export const worldIdValidatorAbi = [
184
191
  stateMutability: "nonpayable",
185
192
  type: "function",
186
193
  },
194
+ {
195
+ inputs: [{ name: "agentId", type: "uint256" }],
196
+ name: "isHumanVerified",
197
+ outputs: [{ name: "", type: "bool" }],
198
+ stateMutability: "view",
199
+ type: "function",
200
+ },
201
+ ];
202
+ // ── StripeKYCValidator ──
203
+ export const stripeKYCValidatorAbi = [
204
+ {
205
+ inputs: [{ name: "agentId", type: "uint256" }],
206
+ name: "isKYCVerified",
207
+ outputs: [{ name: "", type: "bool" }],
208
+ stateMutability: "view",
209
+ type: "function",
210
+ },
211
+ {
212
+ inputs: [{ name: "agentId", type: "uint256" }],
213
+ name: "getKYCData",
214
+ outputs: [
215
+ { name: "verified", type: "bool" },
216
+ { name: "sessionHash", type: "bytes32" },
217
+ { name: "verifiedAt", type: "uint256" },
218
+ ],
219
+ stateMutability: "view",
220
+ type: "function",
221
+ },
222
+ ];
223
+ // ── PlaidCreditValidator ──
224
+ export const plaidCreditValidatorAbi = [
225
+ {
226
+ inputs: [{ name: "agentId", type: "uint256" }],
227
+ name: "getCreditScore",
228
+ outputs: [{ name: "", type: "uint8" }],
229
+ stateMutability: "view",
230
+ type: "function",
231
+ },
232
+ {
233
+ inputs: [{ name: "agentId", type: "uint256" }],
234
+ name: "hasCreditScore",
235
+ outputs: [{ name: "", type: "bool" }],
236
+ stateMutability: "view",
237
+ type: "function",
238
+ },
239
+ {
240
+ inputs: [{ name: "agentId", type: "uint256" }],
241
+ name: "getCreditData",
242
+ outputs: [
243
+ { name: "score", type: "uint8" },
244
+ { name: "dataHash", type: "bytes32" },
245
+ { name: "verifiedAt", type: "uint256" },
246
+ { name: "hasScore", type: "bool" },
247
+ ],
248
+ stateMutability: "view",
249
+ type: "function",
250
+ },
187
251
  ];
252
+ // ── Legacy policy ABIs removed ──
253
+ // KYCPolicy and CreditPolicy replaced by unified TieredPolicy
188
254
  // ── WhitewallConsumer ──
189
255
  export const whitewallConsumerAbi = [
190
256
  {
@@ -1,14 +1,18 @@
1
1
  import type { Address } from "viem";
2
2
  export type ChainName = "baseSepolia";
3
3
  export interface WhitewallOSAddresses {
4
- humanVerifiedPolicy: Address;
4
+ policyEngine: Address;
5
+ tieredPolicy: Address;
5
6
  whitewallConsumer: Address;
7
+ stripeKYCValidator: Address;
8
+ plaidCreditValidator: Address;
6
9
  }
7
- /** Protocol-level policy config, read from on-chain HumanVerifiedPolicy */
10
+ /** Protocol-level policy config, read from on-chain TieredPolicy */
8
11
  export interface PolicyConfig {
9
12
  identityRegistry: Address;
10
- validationRegistry: Address;
11
13
  worldIdValidator: Address;
12
- requiredTier: number;
14
+ stripeKYCValidator: Address;
15
+ plaidCreditValidator: Address;
16
+ minCreditScore: number;
13
17
  }
14
18
  export declare const addresses: Record<ChainName, WhitewallOSAddresses>;
package/dist/addresses.js CHANGED
@@ -1,6 +1,9 @@
1
1
  export const addresses = {
2
2
  baseSepolia: {
3
- humanVerifiedPolicy: "0x8f66f55f4ade4e64b105820972d444a56449e8b3",
4
- whitewallConsumer: "0xec3114ea6bb29f77b63cd1223533870b663120bb",
3
+ policyEngine: "0x12816c0c79981726627a550b73e9627b81be95be",
4
+ tieredPolicy: "0x63b4d2e051180c3c0313eb71a9bdda8554432e23",
5
+ whitewallConsumer: "0xb5845901c590f06ffa480c31b96aca7eff4dfb3e",
6
+ stripeKYCValidator: "0x12b456dcc0e669eeb1d96806c8ef87b713d39cc8",
7
+ plaidCreditValidator: "0x9a0ed706f1714961bf607404521a58decddc2636",
5
8
  },
6
9
  };
package/dist/client.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { type Address, type PublicClient, type Transport, type Chain, type WatchEventReturnType } from "viem";
2
2
  import { type ChainName, type WhitewallOSAddresses, type PolicyConfig } from "./addresses.js";
3
- import type { AgentStatus, AccessGrantedEvent, ValidationSummary } from "./types.js";
3
+ import type { AgentStatus, FullAgentStatus, AccessGrantedEvent } from "./types.js";
4
4
  export interface WhitewallOSConfig {
5
5
  chain: ChainName;
6
6
  rpcUrl?: string;
@@ -14,10 +14,10 @@ export declare class WhitewallOS {
14
14
  private constructor();
15
15
  /**
16
16
  * Create and connect a WhitewallOS instance.
17
- * Reads policy config from on-chain HumanVerifiedPolicy contract.
17
+ * Reads policy config from on-chain TieredPolicy contract.
18
18
  */
19
19
  static connect(config: WhitewallOSConfig): Promise<WhitewallOS>;
20
- /** Read policy configuration from the on-chain HumanVerifiedPolicy contract */
20
+ /** Read policy configuration from the on-chain TieredPolicy contract */
21
21
  private loadPolicyConfig;
22
22
  private get policyConfig();
23
23
  isRegistered(agentId: bigint): Promise<boolean>;
@@ -26,9 +26,10 @@ export declare class WhitewallOS {
26
26
  getAgentWallet(agentId: bigint): Promise<Address>;
27
27
  getTokenURI(agentId: bigint): Promise<string>;
28
28
  getMetadata(agentId: bigint, key: string): Promise<`0x${string}`>;
29
- getValidationSummary(agentId: bigint): Promise<ValidationSummary>;
30
- getAgentValidations(agentId: bigint): Promise<readonly `0x${string}`[]>;
29
+ isKYCVerified(agentId: bigint): Promise<boolean>;
30
+ getCreditScore(agentId: bigint): Promise<number>;
31
31
  getAgentStatus(agentId: bigint): Promise<AgentStatus>;
32
+ getFullStatus(agentId: bigint): Promise<FullAgentStatus>;
32
33
  onAccessGranted(callback: (event: AccessGrantedEvent) => void): WatchEventReturnType;
33
34
  onRegistered(callback: (agentId: bigint, owner: Address) => void): WatchEventReturnType;
34
35
  getAddresses(): WhitewallOSAddresses;
package/dist/client.js CHANGED
@@ -1,8 +1,7 @@
1
1
  import { createPublicClient, http, zeroAddress, } from "viem";
2
2
  import { baseSepolia } from "viem/chains";
3
- import { humanVerifiedPolicyAbi, identityRegistryAbi, validationRegistryAbi, whitewallConsumerAbi, } from "./abis.js";
3
+ import { tieredPolicyAbi, identityRegistryAbi, worldIdValidatorAbi, whitewallConsumerAbi, stripeKYCValidatorAbi, plaidCreditValidatorAbi, } from "./abis.js";
4
4
  import { addresses } from "./addresses.js";
5
- const HUMAN_VERIFIED_TAG = "HUMAN_VERIFIED";
6
5
  const chainMap = {
7
6
  baseSepolia,
8
7
  };
@@ -16,7 +15,7 @@ export class WhitewallOS {
16
15
  }
17
16
  /**
18
17
  * Create and connect a WhitewallOS instance.
19
- * Reads policy config from on-chain HumanVerifiedPolicy contract.
18
+ * Reads policy config from on-chain TieredPolicy contract.
20
19
  */
21
20
  static async connect(config) {
22
21
  const addrs = addresses[config.chain];
@@ -29,31 +28,42 @@ export class WhitewallOS {
29
28
  await instance.loadPolicyConfig();
30
29
  return instance;
31
30
  }
32
- /** Read policy configuration from the on-chain HumanVerifiedPolicy contract */
31
+ /** Read policy configuration from the on-chain TieredPolicy contract */
33
32
  async loadPolicyConfig() {
34
- const [identityRegistry, validationRegistry, worldIdValidator, requiredTier] = await Promise.all([
33
+ const [identityRegistry, worldIdValidator, stripeKYCValidator, plaidCreditValidator, minCreditScore] = await Promise.all([
35
34
  this.client.readContract({
36
- address: this.addrs.humanVerifiedPolicy,
37
- abi: humanVerifiedPolicyAbi,
35
+ address: this.addrs.tieredPolicy,
36
+ abi: tieredPolicyAbi,
38
37
  functionName: "getIdentityRegistry",
39
38
  }),
40
39
  this.client.readContract({
41
- address: this.addrs.humanVerifiedPolicy,
42
- abi: humanVerifiedPolicyAbi,
43
- functionName: "getValidationRegistry",
40
+ address: this.addrs.tieredPolicy,
41
+ abi: tieredPolicyAbi,
42
+ functionName: "getWorldIdValidator",
44
43
  }),
45
44
  this.client.readContract({
46
- address: this.addrs.humanVerifiedPolicy,
47
- abi: humanVerifiedPolicyAbi,
48
- functionName: "getWorldIdValidator",
45
+ address: this.addrs.tieredPolicy,
46
+ abi: tieredPolicyAbi,
47
+ functionName: "getStripeKYCValidator",
49
48
  }),
50
49
  this.client.readContract({
51
- address: this.addrs.humanVerifiedPolicy,
52
- abi: humanVerifiedPolicyAbi,
53
- functionName: "getRequiredTier",
50
+ address: this.addrs.tieredPolicy,
51
+ abi: tieredPolicyAbi,
52
+ functionName: "getPlaidCreditValidator",
53
+ }),
54
+ this.client.readContract({
55
+ address: this.addrs.tieredPolicy,
56
+ abi: tieredPolicyAbi,
57
+ functionName: "getMinCreditScore",
54
58
  }),
55
59
  ]);
56
- this.policy = { identityRegistry, validationRegistry, worldIdValidator, requiredTier };
60
+ this.policy = {
61
+ identityRegistry,
62
+ worldIdValidator,
63
+ stripeKYCValidator,
64
+ plaidCreditValidator,
65
+ minCreditScore,
66
+ };
57
67
  }
58
68
  get policyConfig() {
59
69
  if (!this.policy)
@@ -76,8 +86,12 @@ export class WhitewallOS {
76
86
  }
77
87
  }
78
88
  async isHumanVerified(agentId) {
79
- const summary = await this.getValidationSummary(agentId);
80
- return summary.count > 0n && summary.avgScore >= this.policyConfig.requiredTier;
89
+ return this.client.readContract({
90
+ address: this.policyConfig.worldIdValidator,
91
+ abi: worldIdValidatorAbi,
92
+ functionName: "isHumanVerified",
93
+ args: [agentId],
94
+ });
81
95
  }
82
96
  async getOwner(agentId) {
83
97
  return this.client.readContract({
@@ -111,23 +125,38 @@ export class WhitewallOS {
111
125
  args: [agentId, key],
112
126
  });
113
127
  }
114
- // ─── Validation ───
115
- async getValidationSummary(agentId) {
116
- const [count, avgResponse] = await this.client.readContract({
117
- address: this.policyConfig.validationRegistry,
118
- abi: validationRegistryAbi,
119
- functionName: "getSummary",
120
- args: [agentId, [this.policyConfig.worldIdValidator], HUMAN_VERIFIED_TAG],
121
- });
122
- return { count: BigInt(count), avgScore: avgResponse };
128
+ // ─── KYC & Credit Read Methods ───
129
+ async isKYCVerified(agentId) {
130
+ const addr = this.policyConfig.stripeKYCValidator ?? this.addrs.stripeKYCValidator;
131
+ if (!addr)
132
+ return false;
133
+ try {
134
+ return await this.client.readContract({
135
+ address: addr,
136
+ abi: stripeKYCValidatorAbi,
137
+ functionName: "isKYCVerified",
138
+ args: [agentId],
139
+ });
140
+ }
141
+ catch {
142
+ return false;
143
+ }
123
144
  }
124
- async getAgentValidations(agentId) {
125
- return this.client.readContract({
126
- address: this.policyConfig.validationRegistry,
127
- abi: validationRegistryAbi,
128
- functionName: "getAgentValidations",
129
- args: [agentId],
130
- });
145
+ async getCreditScore(agentId) {
146
+ const addr = this.policyConfig.plaidCreditValidator ?? this.addrs.plaidCreditValidator;
147
+ if (!addr)
148
+ return 0;
149
+ try {
150
+ return await this.client.readContract({
151
+ address: addr,
152
+ abi: plaidCreditValidatorAbi,
153
+ functionName: "getCreditScore",
154
+ args: [agentId],
155
+ });
156
+ }
157
+ catch {
158
+ return 0;
159
+ }
131
160
  }
132
161
  // ─── Composite: Full Status ───
133
162
  async getAgentStatus(agentId) {
@@ -139,23 +168,52 @@ export class WhitewallOS {
139
168
  tier: 0,
140
169
  owner: zeroAddress,
141
170
  agentWallet: zeroAddress,
142
- validationCount: 0n,
143
171
  };
144
172
  }
145
- const [owner, agentWallet, summary] = await Promise.all([
173
+ const [owner, agentWallet, humanVerified] = await Promise.all([
146
174
  this.getOwner(agentId),
147
175
  this.getAgentWallet(agentId),
148
- this.getValidationSummary(agentId),
176
+ this.isHumanVerified(agentId),
149
177
  ]);
150
- const isHumanVerified = summary.count > 0n && summary.avgScore >= this.policyConfig.requiredTier;
151
- const tier = isHumanVerified ? this.policyConfig.requiredTier : 1;
178
+ const tier = humanVerified ? 2 : 1;
152
179
  return {
153
180
  isRegistered: true,
154
- isHumanVerified,
181
+ isHumanVerified: humanVerified,
155
182
  tier,
156
183
  owner,
157
184
  agentWallet,
158
- validationCount: summary.count,
185
+ };
186
+ }
187
+ async getFullStatus(agentId) {
188
+ const base = await this.getAgentStatus(agentId);
189
+ if (!base.isRegistered) {
190
+ return {
191
+ ...base,
192
+ isKYCVerified: false,
193
+ creditScore: 0,
194
+ effectiveTier: 0,
195
+ };
196
+ }
197
+ const [kycVerified, creditScore] = await Promise.all([
198
+ this.isKYCVerified(agentId),
199
+ this.getCreditScore(agentId),
200
+ ]);
201
+ // Compute effective tier (cumulative):
202
+ // 0 = not registered, 1 = registered, 2 = human verified,
203
+ // 3 = + KYC, 4 = + credit score
204
+ let effectiveTier = base.tier; // 1 or 2
205
+ if (base.isHumanVerified && kycVerified) {
206
+ effectiveTier = 3;
207
+ const minScore = this.policyConfig.minCreditScore ?? 50;
208
+ if (creditScore >= minScore) {
209
+ effectiveTier = 4;
210
+ }
211
+ }
212
+ return {
213
+ ...base,
214
+ isKYCVerified: kycVerified,
215
+ creditScore,
216
+ effectiveTier,
159
217
  };
160
218
  }
161
219
  // ─── Event Watching ───
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { WhitewallOS } from "./client.js";
2
2
  export type { WhitewallOSConfig } from "./client.js";
3
- export type { AgentStatus, AccessGrantedEvent, ValidationSummary } from "./types.js";
3
+ export type { AgentStatus, FullAgentStatus, AccessGrantedEvent } from "./types.js";
4
4
  export type { ChainName, WhitewallOSAddresses, PolicyConfig } from "./addresses.js";
5
5
  export { addresses } from "./addresses.js";
6
- export { humanVerifiedPolicyAbi, identityRegistryAbi, validationRegistryAbi, whitewallConsumerAbi, worldIdValidatorAbi, } from "./abis.js";
6
+ export { tieredPolicyAbi, identityRegistryAbi, validationRegistryAbi, whitewallConsumerAbi, worldIdValidatorAbi, stripeKYCValidatorAbi, plaidCreditValidatorAbi, } from "./abis.js";
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  export { WhitewallOS } from "./client.js";
2
2
  export { addresses } from "./addresses.js";
3
- export { humanVerifiedPolicyAbi, identityRegistryAbi, validationRegistryAbi, whitewallConsumerAbi, worldIdValidatorAbi, } from "./abis.js";
3
+ export { tieredPolicyAbi, identityRegistryAbi, validationRegistryAbi, whitewallConsumerAbi, worldIdValidatorAbi, stripeKYCValidatorAbi, plaidCreditValidatorAbi, } from "./abis.js";
package/dist/types.d.ts CHANGED
@@ -5,7 +5,11 @@ export interface AgentStatus {
5
5
  tier: number;
6
6
  owner: Address;
7
7
  agentWallet: Address;
8
- validationCount: bigint;
8
+ }
9
+ export interface FullAgentStatus extends AgentStatus {
10
+ isKYCVerified: boolean;
11
+ creditScore: number;
12
+ effectiveTier: number;
9
13
  }
10
14
  export interface AccessGrantedEvent {
11
15
  agentId: bigint;
@@ -14,7 +18,3 @@ export interface AccessGrantedEvent {
14
18
  blockNumber: bigint;
15
19
  transactionHash: `0x${string}`;
16
20
  }
17
- export interface ValidationSummary {
18
- count: bigint;
19
- avgScore: number;
20
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whitewall-os/sdk",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "TypeScript SDK for Whitewall OS — AI agent accountability protocol",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/src/abis.ts CHANGED
@@ -1,34 +1,41 @@
1
- // ── HumanVerifiedPolicyentry point, SDK reads config from here ──
1
+ // ── TieredPolicyunified policy, SDK reads all config from here ──
2
2
 
3
- export const humanVerifiedPolicyAbi = [
3
+ export const tieredPolicyAbi = [
4
4
  {
5
5
  inputs: [],
6
- name: "getRequiredTier",
7
- outputs: [{ name: "", type: "uint8" }],
6
+ name: "getIdentityRegistry",
7
+ outputs: [{ name: "", type: "address" }],
8
8
  stateMutability: "view",
9
9
  type: "function",
10
10
  },
11
11
  {
12
12
  inputs: [],
13
- name: "getIdentityRegistry",
13
+ name: "getWorldIdValidator",
14
14
  outputs: [{ name: "", type: "address" }],
15
15
  stateMutability: "view",
16
16
  type: "function",
17
17
  },
18
18
  {
19
19
  inputs: [],
20
- name: "getValidationRegistry",
20
+ name: "getStripeKYCValidator",
21
21
  outputs: [{ name: "", type: "address" }],
22
22
  stateMutability: "view",
23
23
  type: "function",
24
24
  },
25
25
  {
26
26
  inputs: [],
27
- name: "getWorldIdValidator",
27
+ name: "getPlaidCreditValidator",
28
28
  outputs: [{ name: "", type: "address" }],
29
29
  stateMutability: "view",
30
30
  type: "function",
31
31
  },
32
+ {
33
+ inputs: [],
34
+ name: "getMinCreditScore",
35
+ outputs: [{ name: "", type: "uint8" }],
36
+ stateMutability: "view",
37
+ type: "function",
38
+ },
32
39
  ] as const;
33
40
 
34
41
  // ── IdentityRegistry ──
@@ -191,8 +198,72 @@ export const worldIdValidatorAbi = [
191
198
  stateMutability: "nonpayable",
192
199
  type: "function",
193
200
  },
201
+ {
202
+ inputs: [{ name: "agentId", type: "uint256" }],
203
+ name: "isHumanVerified",
204
+ outputs: [{ name: "", type: "bool" }],
205
+ stateMutability: "view",
206
+ type: "function",
207
+ },
208
+ ] as const;
209
+
210
+ // ── StripeKYCValidator ──
211
+
212
+ export const stripeKYCValidatorAbi = [
213
+ {
214
+ inputs: [{ name: "agentId", type: "uint256" }],
215
+ name: "isKYCVerified",
216
+ outputs: [{ name: "", type: "bool" }],
217
+ stateMutability: "view",
218
+ type: "function",
219
+ },
220
+ {
221
+ inputs: [{ name: "agentId", type: "uint256" }],
222
+ name: "getKYCData",
223
+ outputs: [
224
+ { name: "verified", type: "bool" },
225
+ { name: "sessionHash", type: "bytes32" },
226
+ { name: "verifiedAt", type: "uint256" },
227
+ ],
228
+ stateMutability: "view",
229
+ type: "function",
230
+ },
194
231
  ] as const;
195
232
 
233
+ // ── PlaidCreditValidator ──
234
+
235
+ export const plaidCreditValidatorAbi = [
236
+ {
237
+ inputs: [{ name: "agentId", type: "uint256" }],
238
+ name: "getCreditScore",
239
+ outputs: [{ name: "", type: "uint8" }],
240
+ stateMutability: "view",
241
+ type: "function",
242
+ },
243
+ {
244
+ inputs: [{ name: "agentId", type: "uint256" }],
245
+ name: "hasCreditScore",
246
+ outputs: [{ name: "", type: "bool" }],
247
+ stateMutability: "view",
248
+ type: "function",
249
+ },
250
+ {
251
+ inputs: [{ name: "agentId", type: "uint256" }],
252
+ name: "getCreditData",
253
+ outputs: [
254
+ { name: "score", type: "uint8" },
255
+ { name: "dataHash", type: "bytes32" },
256
+ { name: "verifiedAt", type: "uint256" },
257
+ { name: "hasScore", type: "bool" },
258
+ ],
259
+ stateMutability: "view",
260
+ type: "function",
261
+ },
262
+ ] as const;
263
+
264
+ // ── Legacy policy ABIs removed ──
265
+ // KYCPolicy and CreditPolicy replaced by unified TieredPolicy
266
+
196
267
  // ── WhitewallConsumer ──
197
268
 
198
269
  export const whitewallConsumerAbi = [
package/src/addresses.ts CHANGED
@@ -3,21 +3,28 @@ import type { Address } from "viem";
3
3
  export type ChainName = "baseSepolia";
4
4
 
5
5
  export interface WhitewallOSAddresses {
6
- humanVerifiedPolicy: Address;
6
+ policyEngine: Address;
7
+ tieredPolicy: Address;
7
8
  whitewallConsumer: Address;
9
+ stripeKYCValidator: Address;
10
+ plaidCreditValidator: Address;
8
11
  }
9
12
 
10
- /** Protocol-level policy config, read from on-chain HumanVerifiedPolicy */
13
+ /** Protocol-level policy config, read from on-chain TieredPolicy */
11
14
  export interface PolicyConfig {
12
15
  identityRegistry: Address;
13
- validationRegistry: Address;
14
16
  worldIdValidator: Address;
15
- requiredTier: number;
17
+ stripeKYCValidator: Address;
18
+ plaidCreditValidator: Address;
19
+ minCreditScore: number;
16
20
  }
17
21
 
18
22
  export const addresses: Record<ChainName, WhitewallOSAddresses> = {
19
23
  baseSepolia: {
20
- humanVerifiedPolicy: "0x8f66f55f4ade4e64b105820972d444a56449e8b3",
21
- whitewallConsumer: "0xec3114ea6bb29f77b63cd1223533870b663120bb",
24
+ policyEngine: "0x12816c0c79981726627a550b73e9627b81be95be",
25
+ tieredPolicy: "0x63b4d2e051180c3c0313eb71a9bdda8554432e23",
26
+ whitewallConsumer: "0xb5845901c590f06ffa480c31b96aca7eff4dfb3e",
27
+ stripeKYCValidator: "0x12b456dcc0e669eeb1d96806c8ef87b713d39cc8",
28
+ plaidCreditValidator: "0x9a0ed706f1714961bf607404521a58decddc2636",
22
29
  },
23
30
  } as const;
package/src/client.ts CHANGED
@@ -10,15 +10,15 @@ import {
10
10
  } from "viem";
11
11
  import { baseSepolia } from "viem/chains";
12
12
  import {
13
- humanVerifiedPolicyAbi,
13
+ tieredPolicyAbi,
14
14
  identityRegistryAbi,
15
- validationRegistryAbi,
15
+ worldIdValidatorAbi,
16
16
  whitewallConsumerAbi,
17
+ stripeKYCValidatorAbi,
18
+ plaidCreditValidatorAbi,
17
19
  } from "./abis.js";
18
20
  import { addresses, type ChainName, type WhitewallOSAddresses, type PolicyConfig } from "./addresses.js";
19
- import type { AgentStatus, AccessGrantedEvent, ValidationSummary } from "./types.js";
20
-
21
- const HUMAN_VERIFIED_TAG = "HUMAN_VERIFIED";
21
+ import type { AgentStatus, FullAgentStatus, AccessGrantedEvent } from "./types.js";
22
22
 
23
23
  const chainMap: Record<ChainName, Chain> = {
24
24
  baseSepolia,
@@ -43,7 +43,7 @@ export class WhitewallOS {
43
43
 
44
44
  /**
45
45
  * Create and connect a WhitewallOS instance.
46
- * Reads policy config from on-chain HumanVerifiedPolicy contract.
46
+ * Reads policy config from on-chain TieredPolicy contract.
47
47
  */
48
48
  static async connect(config: WhitewallOSConfig): Promise<WhitewallOS> {
49
49
  const addrs = addresses[config.chain];
@@ -59,33 +59,44 @@ export class WhitewallOS {
59
59
  return instance;
60
60
  }
61
61
 
62
- /** Read policy configuration from the on-chain HumanVerifiedPolicy contract */
62
+ /** Read policy configuration from the on-chain TieredPolicy contract */
63
63
  private async loadPolicyConfig(): Promise<void> {
64
- const [identityRegistry, validationRegistry, worldIdValidator, requiredTier] =
64
+ const [identityRegistry, worldIdValidator, stripeKYCValidator, plaidCreditValidator, minCreditScore] =
65
65
  await Promise.all([
66
66
  this.client.readContract({
67
- address: this.addrs.humanVerifiedPolicy,
68
- abi: humanVerifiedPolicyAbi,
67
+ address: this.addrs.tieredPolicy,
68
+ abi: tieredPolicyAbi,
69
69
  functionName: "getIdentityRegistry",
70
70
  }),
71
71
  this.client.readContract({
72
- address: this.addrs.humanVerifiedPolicy,
73
- abi: humanVerifiedPolicyAbi,
74
- functionName: "getValidationRegistry",
72
+ address: this.addrs.tieredPolicy,
73
+ abi: tieredPolicyAbi,
74
+ functionName: "getWorldIdValidator",
75
75
  }),
76
76
  this.client.readContract({
77
- address: this.addrs.humanVerifiedPolicy,
78
- abi: humanVerifiedPolicyAbi,
79
- functionName: "getWorldIdValidator",
77
+ address: this.addrs.tieredPolicy,
78
+ abi: tieredPolicyAbi,
79
+ functionName: "getStripeKYCValidator",
80
+ }),
81
+ this.client.readContract({
82
+ address: this.addrs.tieredPolicy,
83
+ abi: tieredPolicyAbi,
84
+ functionName: "getPlaidCreditValidator",
80
85
  }),
81
86
  this.client.readContract({
82
- address: this.addrs.humanVerifiedPolicy,
83
- abi: humanVerifiedPolicyAbi,
84
- functionName: "getRequiredTier",
87
+ address: this.addrs.tieredPolicy,
88
+ abi: tieredPolicyAbi,
89
+ functionName: "getMinCreditScore",
85
90
  }),
86
91
  ]);
87
92
 
88
- this.policy = { identityRegistry, validationRegistry, worldIdValidator, requiredTier };
93
+ this.policy = {
94
+ identityRegistry,
95
+ worldIdValidator,
96
+ stripeKYCValidator,
97
+ plaidCreditValidator,
98
+ minCreditScore,
99
+ };
89
100
  }
90
101
 
91
102
  private get policyConfig(): PolicyConfig {
@@ -110,8 +121,12 @@ export class WhitewallOS {
110
121
  }
111
122
 
112
123
  async isHumanVerified(agentId: bigint): Promise<boolean> {
113
- const summary = await this.getValidationSummary(agentId);
114
- return summary.count > 0n && summary.avgScore >= this.policyConfig.requiredTier;
124
+ return this.client.readContract({
125
+ address: this.policyConfig.worldIdValidator,
126
+ abi: worldIdValidatorAbi,
127
+ functionName: "isHumanVerified",
128
+ args: [agentId],
129
+ });
115
130
  }
116
131
 
117
132
  async getOwner(agentId: bigint): Promise<Address> {
@@ -150,25 +165,36 @@ export class WhitewallOS {
150
165
  });
151
166
  }
152
167
 
153
- // ─── Validation ───
168
+ // ─── KYC & Credit Read Methods ───
154
169
 
155
- async getValidationSummary(agentId: bigint): Promise<ValidationSummary> {
156
- const [count, avgResponse] = await this.client.readContract({
157
- address: this.policyConfig.validationRegistry,
158
- abi: validationRegistryAbi,
159
- functionName: "getSummary",
160
- args: [agentId, [this.policyConfig.worldIdValidator], HUMAN_VERIFIED_TAG],
161
- });
162
- return { count: BigInt(count), avgScore: avgResponse };
170
+ async isKYCVerified(agentId: bigint): Promise<boolean> {
171
+ const addr = this.policyConfig.stripeKYCValidator ?? this.addrs.stripeKYCValidator;
172
+ if (!addr) return false;
173
+ try {
174
+ return await this.client.readContract({
175
+ address: addr,
176
+ abi: stripeKYCValidatorAbi,
177
+ functionName: "isKYCVerified",
178
+ args: [agentId],
179
+ });
180
+ } catch {
181
+ return false;
182
+ }
163
183
  }
164
184
 
165
- async getAgentValidations(agentId: bigint): Promise<readonly `0x${string}`[]> {
166
- return this.client.readContract({
167
- address: this.policyConfig.validationRegistry,
168
- abi: validationRegistryAbi,
169
- functionName: "getAgentValidations",
170
- args: [agentId],
171
- });
185
+ async getCreditScore(agentId: bigint): Promise<number> {
186
+ const addr = this.policyConfig.plaidCreditValidator ?? this.addrs.plaidCreditValidator;
187
+ if (!addr) return 0;
188
+ try {
189
+ return await this.client.readContract({
190
+ address: addr,
191
+ abi: plaidCreditValidatorAbi,
192
+ functionName: "getCreditScore",
193
+ args: [agentId],
194
+ });
195
+ } catch {
196
+ return 0;
197
+ }
172
198
  }
173
199
 
174
200
  // ─── Composite: Full Status ───
@@ -182,26 +208,59 @@ export class WhitewallOS {
182
208
  tier: 0,
183
209
  owner: zeroAddress,
184
210
  agentWallet: zeroAddress,
185
- validationCount: 0n,
186
211
  };
187
212
  }
188
213
 
189
- const [owner, agentWallet, summary] = await Promise.all([
214
+ const [owner, agentWallet, humanVerified] = await Promise.all([
190
215
  this.getOwner(agentId),
191
216
  this.getAgentWallet(agentId),
192
- this.getValidationSummary(agentId),
217
+ this.isHumanVerified(agentId),
193
218
  ]);
194
219
 
195
- const isHumanVerified = summary.count > 0n && summary.avgScore >= this.policyConfig.requiredTier;
196
- const tier = isHumanVerified ? this.policyConfig.requiredTier : 1;
220
+ const tier = humanVerified ? 2 : 1;
197
221
 
198
222
  return {
199
223
  isRegistered: true,
200
- isHumanVerified,
224
+ isHumanVerified: humanVerified,
201
225
  tier,
202
226
  owner,
203
227
  agentWallet,
204
- validationCount: summary.count,
228
+ };
229
+ }
230
+
231
+ async getFullStatus(agentId: bigint): Promise<FullAgentStatus> {
232
+ const base = await this.getAgentStatus(agentId);
233
+ if (!base.isRegistered) {
234
+ return {
235
+ ...base,
236
+ isKYCVerified: false,
237
+ creditScore: 0,
238
+ effectiveTier: 0,
239
+ };
240
+ }
241
+
242
+ const [kycVerified, creditScore] = await Promise.all([
243
+ this.isKYCVerified(agentId),
244
+ this.getCreditScore(agentId),
245
+ ]);
246
+
247
+ // Compute effective tier (cumulative):
248
+ // 0 = not registered, 1 = registered, 2 = human verified,
249
+ // 3 = + KYC, 4 = + credit score
250
+ let effectiveTier = base.tier; // 1 or 2
251
+ if (base.isHumanVerified && kycVerified) {
252
+ effectiveTier = 3;
253
+ const minScore = this.policyConfig.minCreditScore ?? 50;
254
+ if (creditScore >= minScore) {
255
+ effectiveTier = 4;
256
+ }
257
+ }
258
+
259
+ return {
260
+ ...base,
261
+ isKYCVerified: kycVerified,
262
+ creditScore,
263
+ effectiveTier,
205
264
  };
206
265
  }
207
266
 
package/src/index.ts CHANGED
@@ -1,12 +1,14 @@
1
1
  export { WhitewallOS } from "./client.js";
2
2
  export type { WhitewallOSConfig } from "./client.js";
3
- export type { AgentStatus, AccessGrantedEvent, ValidationSummary } from "./types.js";
3
+ export type { AgentStatus, FullAgentStatus, AccessGrantedEvent } from "./types.js";
4
4
  export type { ChainName, WhitewallOSAddresses, PolicyConfig } from "./addresses.js";
5
5
  export { addresses } from "./addresses.js";
6
6
  export {
7
- humanVerifiedPolicyAbi,
7
+ tieredPolicyAbi,
8
8
  identityRegistryAbi,
9
9
  validationRegistryAbi,
10
10
  whitewallConsumerAbi,
11
11
  worldIdValidatorAbi,
12
+ stripeKYCValidatorAbi,
13
+ plaidCreditValidatorAbi,
12
14
  } from "./abis.js";
package/src/types.ts CHANGED
@@ -6,7 +6,12 @@ export interface AgentStatus {
6
6
  tier: number;
7
7
  owner: Address;
8
8
  agentWallet: Address;
9
- validationCount: bigint;
9
+ }
10
+
11
+ export interface FullAgentStatus extends AgentStatus {
12
+ isKYCVerified: boolean;
13
+ creditScore: number;
14
+ effectiveTier: number; // 0-4 computed from all verification states
10
15
  }
11
16
 
12
17
  export interface AccessGrantedEvent {
@@ -16,8 +21,3 @@ export interface AccessGrantedEvent {
16
21
  blockNumber: bigint;
17
22
  transactionHash: `0x${string}`;
18
23
  }
19
-
20
- export interface ValidationSummary {
21
- count: bigint;
22
- avgScore: number;
23
- }