@whitewall-os/sdk 0.1.0 → 0.3.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 +137 -6
- package/dist/abis.js +94 -7
- package/dist/addresses.d.ts +8 -4
- package/dist/addresses.js +5 -2
- package/dist/client.d.ts +6 -5
- package/dist/client.js +100 -42
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/types.d.ts +5 -5
- package/package.json +1 -1
- package/src/abis.ts +99 -7
- package/src/addresses.ts +13 -6
- package/src/client.ts +104 -45
- package/src/index.ts +4 -2
- package/src/types.ts +6 -6
package/dist/abis.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const tieredPolicyAbi: readonly [{
|
|
2
2
|
readonly inputs: readonly [];
|
|
3
|
-
readonly name: "
|
|
3
|
+
readonly name: "getIdentityRegistry";
|
|
4
4
|
readonly outputs: readonly [{
|
|
5
5
|
readonly name: "";
|
|
6
|
-
readonly type: "
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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,128 @@ 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";
|
|
388
|
+
}, {
|
|
389
|
+
readonly anonymous: false;
|
|
390
|
+
readonly inputs: readonly [{
|
|
391
|
+
readonly indexed: true;
|
|
392
|
+
readonly name: "agentId";
|
|
393
|
+
readonly type: "uint256";
|
|
394
|
+
}, {
|
|
395
|
+
readonly indexed: false;
|
|
396
|
+
readonly name: "score";
|
|
397
|
+
readonly type: "uint8";
|
|
398
|
+
}, {
|
|
399
|
+
readonly indexed: false;
|
|
400
|
+
readonly name: "dataHash";
|
|
401
|
+
readonly type: "bytes32";
|
|
402
|
+
}, {
|
|
403
|
+
readonly indexed: false;
|
|
404
|
+
readonly name: "timestamp";
|
|
405
|
+
readonly type: "uint256";
|
|
406
|
+
}];
|
|
407
|
+
readonly name: "CreditScoreSet";
|
|
408
|
+
readonly type: "event";
|
|
409
|
+
}, {
|
|
410
|
+
readonly inputs: readonly [];
|
|
411
|
+
readonly name: "getSgxConfig";
|
|
412
|
+
readonly outputs: readonly [{
|
|
413
|
+
readonly name: "verifier";
|
|
414
|
+
readonly type: "address";
|
|
415
|
+
}, {
|
|
416
|
+
readonly name: "mrEnclave";
|
|
417
|
+
readonly type: "bytes32";
|
|
418
|
+
}];
|
|
419
|
+
readonly stateMutability: "view";
|
|
420
|
+
readonly type: "function";
|
|
290
421
|
}];
|
|
291
422
|
export declare const whitewallConsumerAbi: readonly [{
|
|
292
423
|
readonly anonymous: false;
|
package/dist/abis.js
CHANGED
|
@@ -1,33 +1,40 @@
|
|
|
1
|
-
// ──
|
|
2
|
-
export const
|
|
1
|
+
// ── TieredPolicy — unified policy, SDK reads all config from here ──
|
|
2
|
+
export const tieredPolicyAbi = [
|
|
3
3
|
{
|
|
4
4
|
inputs: [],
|
|
5
|
-
name: "
|
|
6
|
-
outputs: [{ name: "", type: "
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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,87 @@ 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
|
+
},
|
|
251
|
+
{
|
|
252
|
+
anonymous: false,
|
|
253
|
+
inputs: [
|
|
254
|
+
{ indexed: true, name: "agentId", type: "uint256" },
|
|
255
|
+
{ indexed: false, name: "score", type: "uint8" },
|
|
256
|
+
{ indexed: false, name: "dataHash", type: "bytes32" },
|
|
257
|
+
{ indexed: false, name: "timestamp", type: "uint256" },
|
|
258
|
+
],
|
|
259
|
+
name: "CreditScoreSet",
|
|
260
|
+
type: "event",
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
inputs: [],
|
|
264
|
+
name: "getSgxConfig",
|
|
265
|
+
outputs: [
|
|
266
|
+
{ name: "verifier", type: "address" },
|
|
267
|
+
{ name: "mrEnclave", type: "bytes32" },
|
|
268
|
+
],
|
|
269
|
+
stateMutability: "view",
|
|
270
|
+
type: "function",
|
|
271
|
+
},
|
|
187
272
|
];
|
|
273
|
+
// ── Legacy policy ABIs removed ──
|
|
274
|
+
// KYCPolicy and CreditPolicy replaced by unified TieredPolicy
|
|
188
275
|
// ── WhitewallConsumer ──
|
|
189
276
|
export const whitewallConsumerAbi = [
|
|
190
277
|
{
|
package/dist/addresses.d.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
2
|
export type ChainName = "baseSepolia";
|
|
3
3
|
export interface WhitewallOSAddresses {
|
|
4
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
4
|
-
|
|
3
|
+
policyEngine: "0xc7afccc4b97786e34c07e4444496256d2f2b0b9a",
|
|
4
|
+
tieredPolicy: "0xdb20a5d22cc7eb2a43628527667021121e80e30d",
|
|
5
|
+
whitewallConsumer: "0x9670cc85a97c07a1bb6353fb968c6a2c153db99f",
|
|
6
|
+
stripeKYCValidator: "0xebba79075ad00a22c5ff9a1f36a379f577265936",
|
|
7
|
+
plaidCreditValidator: "0x07e8653b55a3cd703106c9726a140755204c1ad5",
|
|
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,
|
|
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
|
|
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
|
|
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
|
-
|
|
30
|
-
|
|
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 {
|
|
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
|
|
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
|
|
31
|
+
/** Read policy configuration from the on-chain TieredPolicy contract */
|
|
33
32
|
async loadPolicyConfig() {
|
|
34
|
-
const [identityRegistry,
|
|
33
|
+
const [identityRegistry, worldIdValidator, stripeKYCValidator, plaidCreditValidator, minCreditScore] = await Promise.all([
|
|
35
34
|
this.client.readContract({
|
|
36
|
-
address: this.addrs.
|
|
37
|
-
abi:
|
|
35
|
+
address: this.addrs.tieredPolicy,
|
|
36
|
+
abi: tieredPolicyAbi,
|
|
38
37
|
functionName: "getIdentityRegistry",
|
|
39
38
|
}),
|
|
40
39
|
this.client.readContract({
|
|
41
|
-
address: this.addrs.
|
|
42
|
-
abi:
|
|
43
|
-
functionName: "
|
|
40
|
+
address: this.addrs.tieredPolicy,
|
|
41
|
+
abi: tieredPolicyAbi,
|
|
42
|
+
functionName: "getWorldIdValidator",
|
|
44
43
|
}),
|
|
45
44
|
this.client.readContract({
|
|
46
|
-
address: this.addrs.
|
|
47
|
-
abi:
|
|
48
|
-
functionName: "
|
|
45
|
+
address: this.addrs.tieredPolicy,
|
|
46
|
+
abi: tieredPolicyAbi,
|
|
47
|
+
functionName: "getStripeKYCValidator",
|
|
49
48
|
}),
|
|
50
49
|
this.client.readContract({
|
|
51
|
-
address: this.addrs.
|
|
52
|
-
abi:
|
|
53
|
-
functionName: "
|
|
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 = {
|
|
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
|
-
|
|
80
|
-
|
|
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
|
-
// ───
|
|
115
|
-
async
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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,
|
|
173
|
+
const [owner, agentWallet, humanVerified] = await Promise.all([
|
|
146
174
|
this.getOwner(agentId),
|
|
147
175
|
this.getAgentWallet(agentId),
|
|
148
|
-
this.
|
|
176
|
+
this.isHumanVerified(agentId),
|
|
149
177
|
]);
|
|
150
|
-
const
|
|
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
|
-
|
|
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,
|
|
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 {
|
|
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 {
|
|
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
|
-
|
|
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
package/src/abis.ts
CHANGED
|
@@ -1,34 +1,41 @@
|
|
|
1
|
-
// ──
|
|
1
|
+
// ── TieredPolicy — unified policy, SDK reads all config from here ──
|
|
2
2
|
|
|
3
|
-
export const
|
|
3
|
+
export const tieredPolicyAbi = [
|
|
4
4
|
{
|
|
5
5
|
inputs: [],
|
|
6
|
-
name: "
|
|
7
|
-
outputs: [{ name: "", type: "
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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,93 @@ 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
|
+
},
|
|
231
|
+
] as const;
|
|
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
|
+
{
|
|
263
|
+
anonymous: false,
|
|
264
|
+
inputs: [
|
|
265
|
+
{ indexed: true, name: "agentId", type: "uint256" },
|
|
266
|
+
{ indexed: false, name: "score", type: "uint8" },
|
|
267
|
+
{ indexed: false, name: "dataHash", type: "bytes32" },
|
|
268
|
+
{ indexed: false, name: "timestamp", type: "uint256" },
|
|
269
|
+
],
|
|
270
|
+
name: "CreditScoreSet",
|
|
271
|
+
type: "event",
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
inputs: [],
|
|
275
|
+
name: "getSgxConfig",
|
|
276
|
+
outputs: [
|
|
277
|
+
{ name: "verifier", type: "address" },
|
|
278
|
+
{ name: "mrEnclave", type: "bytes32" },
|
|
279
|
+
],
|
|
280
|
+
stateMutability: "view",
|
|
281
|
+
type: "function",
|
|
282
|
+
},
|
|
194
283
|
] as const;
|
|
195
284
|
|
|
285
|
+
// ── Legacy policy ABIs removed ──
|
|
286
|
+
// KYCPolicy and CreditPolicy replaced by unified TieredPolicy
|
|
287
|
+
|
|
196
288
|
// ── WhitewallConsumer ──
|
|
197
289
|
|
|
198
290
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
21
|
-
|
|
24
|
+
policyEngine: "0xc7afccc4b97786e34c07e4444496256d2f2b0b9a",
|
|
25
|
+
tieredPolicy: "0xdb20a5d22cc7eb2a43628527667021121e80e30d",
|
|
26
|
+
whitewallConsumer: "0x9670cc85a97c07a1bb6353fb968c6a2c153db99f",
|
|
27
|
+
stripeKYCValidator: "0xebba79075ad00a22c5ff9a1f36a379f577265936",
|
|
28
|
+
plaidCreditValidator: "0x07e8653b55a3cd703106c9726a140755204c1ad5",
|
|
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
|
-
|
|
13
|
+
tieredPolicyAbi,
|
|
14
14
|
identityRegistryAbi,
|
|
15
|
-
|
|
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,
|
|
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
|
|
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
|
|
62
|
+
/** Read policy configuration from the on-chain TieredPolicy contract */
|
|
63
63
|
private async loadPolicyConfig(): Promise<void> {
|
|
64
|
-
const [identityRegistry,
|
|
64
|
+
const [identityRegistry, worldIdValidator, stripeKYCValidator, plaidCreditValidator, minCreditScore] =
|
|
65
65
|
await Promise.all([
|
|
66
66
|
this.client.readContract({
|
|
67
|
-
address: this.addrs.
|
|
68
|
-
abi:
|
|
67
|
+
address: this.addrs.tieredPolicy,
|
|
68
|
+
abi: tieredPolicyAbi,
|
|
69
69
|
functionName: "getIdentityRegistry",
|
|
70
70
|
}),
|
|
71
71
|
this.client.readContract({
|
|
72
|
-
address: this.addrs.
|
|
73
|
-
abi:
|
|
74
|
-
functionName: "
|
|
72
|
+
address: this.addrs.tieredPolicy,
|
|
73
|
+
abi: tieredPolicyAbi,
|
|
74
|
+
functionName: "getWorldIdValidator",
|
|
75
75
|
}),
|
|
76
76
|
this.client.readContract({
|
|
77
|
-
address: this.addrs.
|
|
78
|
-
abi:
|
|
79
|
-
functionName: "
|
|
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.
|
|
83
|
-
abi:
|
|
84
|
-
functionName: "
|
|
87
|
+
address: this.addrs.tieredPolicy,
|
|
88
|
+
abi: tieredPolicyAbi,
|
|
89
|
+
functionName: "getMinCreditScore",
|
|
85
90
|
}),
|
|
86
91
|
]);
|
|
87
92
|
|
|
88
|
-
this.policy = {
|
|
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
|
-
|
|
114
|
-
|
|
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
|
-
// ───
|
|
168
|
+
// ─── KYC & Credit Read Methods ───
|
|
154
169
|
|
|
155
|
-
async
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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,
|
|
214
|
+
const [owner, agentWallet, humanVerified] = await Promise.all([
|
|
190
215
|
this.getOwner(agentId),
|
|
191
216
|
this.getAgentWallet(agentId),
|
|
192
|
-
this.
|
|
217
|
+
this.isHumanVerified(agentId),
|
|
193
218
|
]);
|
|
194
219
|
|
|
195
|
-
const
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
}
|