@abbababa/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/README.md +47 -9
- package/dist/buyer.d.ts +26 -11
- package/dist/buyer.d.ts.map +1 -1
- package/dist/buyer.js +48 -15
- package/dist/buyer.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/seller.d.ts +30 -2
- package/dist/seller.d.ts.map +1 -1
- package/dist/seller.js +66 -1
- package/dist/seller.js.map +1 -1
- package/dist/types.d.ts +34 -9
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +21 -1
- package/dist/types.js.map +1 -1
- package/dist/wallet/abi.d.ts +87 -81
- package/dist/wallet/abi.d.ts.map +1 -1
- package/dist/wallet/abi.js +59 -59
- package/dist/wallet/abi.js.map +1 -1
- package/dist/wallet/constants.d.ts +4 -8
- package/dist/wallet/constants.d.ts.map +1 -1
- package/dist/wallet/constants.js +7 -20
- package/dist/wallet/constants.js.map +1 -1
- package/dist/wallet/escrow.d.ts +62 -15
- package/dist/wallet/escrow.d.ts.map +1 -1
- package/dist/wallet/escrow.js +219 -85
- package/dist/wallet/escrow.js.map +1 -1
- package/dist/wallet/index.d.ts +2 -2
- package/dist/wallet/index.d.ts.map +1 -1
- package/dist/wallet/index.js +4 -8
- package/dist/wallet/index.js.map +1 -1
- package/dist/wallet/session-keys.d.ts +9 -6
- package/dist/wallet/session-keys.d.ts.map +1 -1
- package/dist/wallet/session-keys.js +53 -54
- package/dist/wallet/session-keys.js.map +1 -1
- package/dist/wallet/smart-account.d.ts.map +1 -1
- package/dist/wallet/smart-account.js +5 -4
- package/dist/wallet/smart-account.js.map +1 -1
- package/package.json +2 -1
package/dist/wallet/escrow.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { type TokenInfo } from './constants.js';
|
|
2
|
-
import type { EscrowDetails } from '../types.js';
|
|
2
|
+
import type { EscrowDetails, AgentStats } from '../types.js';
|
|
3
3
|
/**
|
|
4
|
-
* Client for interacting with the
|
|
5
|
-
* Supports
|
|
4
|
+
* Client for interacting with the AbbababaEscrow V4 smart contract.
|
|
5
|
+
* Supports self-executing escrow with delivery proofs, 24h dispute window,
|
|
6
|
+
* auto-release, and abandonment detection.
|
|
6
7
|
* Uses a ZeroDev Kernel account client for sending UserOperations.
|
|
7
8
|
*/
|
|
8
9
|
export declare class EscrowClient {
|
|
9
10
|
private kernelClient;
|
|
10
11
|
private chainId;
|
|
11
12
|
private escrowAddress;
|
|
12
|
-
private escrowVersion;
|
|
13
13
|
private tokenAddress;
|
|
14
14
|
private tokenDecimals;
|
|
15
15
|
constructor(kernelClient: unknown, token?: TokenInfo, chainId?: number);
|
|
16
16
|
/**
|
|
17
17
|
* Convert a platform transaction ID (CUID string) to a bytes32 escrow ID.
|
|
18
|
-
* Uses keccak256, matching the existing backend pattern
|
|
18
|
+
* Uses keccak256, matching the existing backend pattern.
|
|
19
19
|
*/
|
|
20
20
|
static toEscrowId(transactionId: string): `0x${string}`;
|
|
21
21
|
/**
|
|
@@ -23,23 +23,70 @@ export declare class EscrowClient {
|
|
|
23
23
|
* Must be called before fundEscrow.
|
|
24
24
|
*/
|
|
25
25
|
approveToken(amount: bigint): Promise<string>;
|
|
26
|
-
/** @deprecated Use approveToken() instead. */
|
|
27
|
-
approveUSDC(amount: bigint): Promise<string>;
|
|
28
26
|
/**
|
|
29
|
-
* Fund an escrow. Calls createEscrow
|
|
30
|
-
* V3: passes token address as 4th argument.
|
|
31
|
-
* V2 fallback: USDC only (3 arguments).
|
|
27
|
+
* Fund an escrow. Calls V4 createEscrow with 5 args including deadline.
|
|
32
28
|
* The contract will safeTransferFrom the token (amount + 1% buyer fee) from the caller.
|
|
33
29
|
*/
|
|
34
|
-
fundEscrow(transactionId: string, sellerAddress: string, amount: bigint): Promise<string>;
|
|
30
|
+
fundEscrow(transactionId: string, sellerAddress: string, amount: bigint, deadline: bigint): Promise<string>;
|
|
35
31
|
/**
|
|
36
|
-
*
|
|
37
|
-
* Callable by the buyer or an arbitrator.
|
|
32
|
+
* Submit delivery proof on-chain. Called by the seller after completing work.
|
|
38
33
|
*/
|
|
39
|
-
|
|
34
|
+
submitDelivery(transactionId: string, proofHash: `0x${string}`): Promise<string>;
|
|
40
35
|
/**
|
|
41
|
-
*
|
|
36
|
+
* Accept delivery and release funds immediately. Called by the buyer.
|
|
37
|
+
*/
|
|
38
|
+
acceptDelivery(transactionId: string): Promise<string>;
|
|
39
|
+
/**
|
|
40
|
+
* Finalize release after the 24h dispute window has passed without a dispute.
|
|
41
|
+
* Can be called by anyone.
|
|
42
|
+
*/
|
|
43
|
+
finalizeRelease(transactionId: string): Promise<string>;
|
|
44
|
+
/**
|
|
45
|
+
* Dispute a delivery within the 24h dispute window. Called by the buyer.
|
|
46
|
+
*/
|
|
47
|
+
disputeEscrow(transactionId: string): Promise<string>;
|
|
48
|
+
/**
|
|
49
|
+
* Claim funds for an abandoned escrow (deadline + 7 days passed with no delivery).
|
|
50
|
+
* Called by the buyer to reclaim funds.
|
|
51
|
+
*/
|
|
52
|
+
claimAbandoned(transactionId: string): Promise<string>;
|
|
53
|
+
/**
|
|
54
|
+
* Read escrow details from the V4 contract (view function, no gas needed).
|
|
42
55
|
*/
|
|
43
56
|
getEscrow(transactionId: string): Promise<EscrowDetails | null>;
|
|
57
|
+
/**
|
|
58
|
+
* Check if the 24h dispute window is currently active for an escrow.
|
|
59
|
+
*/
|
|
60
|
+
isDisputeWindowActive(transactionId: string): Promise<boolean>;
|
|
61
|
+
/**
|
|
62
|
+
* Check if an escrow can be finalized (dispute window passed, no dispute filed).
|
|
63
|
+
*/
|
|
64
|
+
canFinalize(transactionId: string): Promise<boolean>;
|
|
65
|
+
/**
|
|
66
|
+
* Check if an escrow can be claimed as abandoned (deadline + 7 days passed).
|
|
67
|
+
*/
|
|
68
|
+
canClaimAbandoned(transactionId: string): Promise<boolean>;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Read-only client for the AbbababaScore on-chain reputation system.
|
|
72
|
+
* No wallet needed — all methods are view functions.
|
|
73
|
+
*/
|
|
74
|
+
export declare class ScoreClient {
|
|
75
|
+
private chainId;
|
|
76
|
+
private scoreAddress;
|
|
77
|
+
constructor(chainId?: number);
|
|
78
|
+
private getPublicClient;
|
|
79
|
+
/**
|
|
80
|
+
* Get an agent's trust score (int256 — can be negative).
|
|
81
|
+
*/
|
|
82
|
+
getScore(agentAddress: string): Promise<bigint>;
|
|
83
|
+
/**
|
|
84
|
+
* Check if an agent requires a bond (low trust score).
|
|
85
|
+
*/
|
|
86
|
+
requiresBond(agentAddress: string): Promise<boolean>;
|
|
87
|
+
/**
|
|
88
|
+
* Get full agent stats from the reputation contract.
|
|
89
|
+
*/
|
|
90
|
+
getAgentStats(agentAddress: string): Promise<AgentStats>;
|
|
44
91
|
}
|
|
45
92
|
//# sourceMappingURL=escrow.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"escrow.d.ts","sourceRoot":"","sources":["../../src/wallet/escrow.ts"],"names":[],"mappings":"AAWA,OAAO,
|
|
1
|
+
{"version":3,"file":"escrow.d.ts","sourceRoot":"","sources":["../../src/wallet/escrow.ts"],"names":[],"mappings":"AAWA,OAAO,EAML,KAAK,SAAS,EACf,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAU5D;;;;;GAKG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,aAAa,CAAQ;gBAEjB,YAAY,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,SAAS,EAAE,OAAO,SAAwB;IAoBrF;;;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,eAAe;IAQvB;;OAEG;IACG,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAarD;;OAEG;IACG,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAa1D;;OAEG;IACG,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CAgB/D"}
|
package/dist/wallet/escrow.js
CHANGED
|
@@ -1,58 +1,48 @@
|
|
|
1
1
|
import { encodeFunctionData, keccak256, toBytes, createPublicClient, http, } from 'viem';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { baseSepolia, base } from 'viem/chains';
|
|
3
|
+
import { ABBABABA_ESCROW_ABI, ABBABABA_SCORE_ABI, ERC20_ABI } from './abi.js';
|
|
4
|
+
import { ESCROW_V4_ADDRESSES, SCORE_ADDRESSES, BASE_SEPOLIA_CHAIN_ID, BASE_MAINNET_CHAIN_ID, getToken, } from './constants.js';
|
|
5
5
|
const CHAINS = {
|
|
6
|
-
[POLYGON_AMOY_CHAIN_ID]: polygonAmoy,
|
|
7
|
-
[POLYGON_MAINNET_CHAIN_ID]: polygon,
|
|
8
6
|
[BASE_SEPOLIA_CHAIN_ID]: baseSepolia,
|
|
9
7
|
[BASE_MAINNET_CHAIN_ID]: base,
|
|
10
8
|
};
|
|
9
|
+
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
|
|
10
|
+
const ZERO_BYTES32 = '0x0000000000000000000000000000000000000000000000000000000000000000';
|
|
11
11
|
/**
|
|
12
|
-
* Client for interacting with the
|
|
13
|
-
* Supports
|
|
12
|
+
* Client for interacting with the AbbababaEscrow V4 smart contract.
|
|
13
|
+
* Supports self-executing escrow with delivery proofs, 24h dispute window,
|
|
14
|
+
* auto-release, and abandonment detection.
|
|
14
15
|
* Uses a ZeroDev Kernel account client for sending UserOperations.
|
|
15
16
|
*/
|
|
16
17
|
export class EscrowClient {
|
|
17
18
|
kernelClient;
|
|
18
19
|
chainId;
|
|
19
20
|
escrowAddress;
|
|
20
|
-
escrowVersion;
|
|
21
21
|
tokenAddress;
|
|
22
22
|
tokenDecimals;
|
|
23
23
|
constructor(kernelClient, token, chainId = BASE_SEPOLIA_CHAIN_ID) {
|
|
24
24
|
this.kernelClient = kernelClient;
|
|
25
25
|
this.chainId = chainId;
|
|
26
|
-
// Resolve token (default USDC
|
|
26
|
+
// Resolve token (default USDC)
|
|
27
27
|
if (token) {
|
|
28
28
|
this.tokenAddress = token.address;
|
|
29
29
|
this.tokenDecimals = token.decimals;
|
|
30
30
|
}
|
|
31
31
|
else {
|
|
32
|
-
const usdc =
|
|
32
|
+
const usdc = getToken(chainId, 'USDC');
|
|
33
33
|
if (!usdc)
|
|
34
34
|
throw new Error(`No USDC address for chain ${chainId}`);
|
|
35
|
-
this.tokenAddress = usdc;
|
|
36
|
-
this.tokenDecimals =
|
|
37
|
-
}
|
|
38
|
-
// Try V3 first, fall back to V2
|
|
39
|
-
const v3 = ESCROW_ADDRESSES[chainId];
|
|
40
|
-
const v2 = ESCROW_V2_ADDRESSES[chainId];
|
|
41
|
-
if (v3) {
|
|
42
|
-
this.escrowAddress = v3;
|
|
43
|
-
this.escrowVersion = 3;
|
|
44
|
-
}
|
|
45
|
-
else if (v2) {
|
|
46
|
-
this.escrowAddress = v2;
|
|
47
|
-
this.escrowVersion = 2;
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
throw new Error(`No escrow contract for chain ${chainId}`);
|
|
35
|
+
this.tokenAddress = usdc.address;
|
|
36
|
+
this.tokenDecimals = usdc.decimals;
|
|
51
37
|
}
|
|
38
|
+
const v4 = ESCROW_V4_ADDRESSES[chainId];
|
|
39
|
+
if (!v4)
|
|
40
|
+
throw new Error(`No V4 escrow contract for chain ${chainId}`);
|
|
41
|
+
this.escrowAddress = v4;
|
|
52
42
|
}
|
|
53
43
|
/**
|
|
54
44
|
* Convert a platform transaction ID (CUID string) to a bytes32 escrow ID.
|
|
55
|
-
* Uses keccak256, matching the existing backend pattern
|
|
45
|
+
* Uses keccak256, matching the existing backend pattern.
|
|
56
46
|
*/
|
|
57
47
|
static toEscrowId(transactionId) {
|
|
58
48
|
return keccak256(toBytes(transactionId));
|
|
@@ -76,33 +66,66 @@ export class EscrowClient {
|
|
|
76
66
|
});
|
|
77
67
|
return txHash;
|
|
78
68
|
}
|
|
79
|
-
/** @deprecated Use approveToken() instead. */
|
|
80
|
-
async approveUSDC(amount) {
|
|
81
|
-
return this.approveToken(amount);
|
|
82
|
-
}
|
|
83
69
|
/**
|
|
84
|
-
* Fund an escrow. Calls createEscrow
|
|
85
|
-
* V3: passes token address as 4th argument.
|
|
86
|
-
* V2 fallback: USDC only (3 arguments).
|
|
70
|
+
* Fund an escrow. Calls V4 createEscrow with 5 args including deadline.
|
|
87
71
|
* The contract will safeTransferFrom the token (amount + 1% buyer fee) from the caller.
|
|
88
72
|
*/
|
|
89
|
-
async fundEscrow(transactionId, sellerAddress, amount) {
|
|
73
|
+
async fundEscrow(transactionId, sellerAddress, amount, deadline) {
|
|
90
74
|
const escrowId = EscrowClient.toEscrowId(transactionId);
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
75
|
+
const data = encodeFunctionData({
|
|
76
|
+
abi: ABBABABA_ESCROW_ABI,
|
|
77
|
+
functionName: 'createEscrow',
|
|
78
|
+
args: [escrowId, sellerAddress, amount, this.tokenAddress, deadline],
|
|
79
|
+
});
|
|
80
|
+
const txHash = await this.kernelClient.sendTransaction({
|
|
81
|
+
to: this.escrowAddress,
|
|
82
|
+
data,
|
|
83
|
+
});
|
|
84
|
+
return txHash;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Submit delivery proof on-chain. Called by the seller after completing work.
|
|
88
|
+
*/
|
|
89
|
+
async submitDelivery(transactionId, proofHash) {
|
|
90
|
+
const escrowId = EscrowClient.toEscrowId(transactionId);
|
|
91
|
+
const data = encodeFunctionData({
|
|
92
|
+
abi: ABBABABA_ESCROW_ABI,
|
|
93
|
+
functionName: 'submitDelivery',
|
|
94
|
+
args: [escrowId, proofHash],
|
|
95
|
+
});
|
|
96
|
+
const txHash = await this.kernelClient.sendTransaction({
|
|
97
|
+
to: this.escrowAddress,
|
|
98
|
+
data,
|
|
99
|
+
});
|
|
100
|
+
return txHash;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Accept delivery and release funds immediately. Called by the buyer.
|
|
104
|
+
*/
|
|
105
|
+
async acceptDelivery(transactionId) {
|
|
106
|
+
const escrowId = EscrowClient.toEscrowId(transactionId);
|
|
107
|
+
const data = encodeFunctionData({
|
|
108
|
+
abi: ABBABABA_ESCROW_ABI,
|
|
109
|
+
functionName: 'accept',
|
|
110
|
+
args: [escrowId],
|
|
111
|
+
});
|
|
112
|
+
const txHash = await this.kernelClient.sendTransaction({
|
|
113
|
+
to: this.escrowAddress,
|
|
114
|
+
data,
|
|
115
|
+
});
|
|
116
|
+
return txHash;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Finalize release after the 24h dispute window has passed without a dispute.
|
|
120
|
+
* Can be called by anyone.
|
|
121
|
+
*/
|
|
122
|
+
async finalizeRelease(transactionId) {
|
|
123
|
+
const escrowId = EscrowClient.toEscrowId(transactionId);
|
|
124
|
+
const data = encodeFunctionData({
|
|
125
|
+
abi: ABBABABA_ESCROW_ABI,
|
|
126
|
+
functionName: 'finalizeRelease',
|
|
127
|
+
args: [escrowId],
|
|
128
|
+
});
|
|
106
129
|
const txHash = await this.kernelClient.sendTransaction({
|
|
107
130
|
to: this.escrowAddress,
|
|
108
131
|
data,
|
|
@@ -110,15 +133,13 @@ export class EscrowClient {
|
|
|
110
133
|
return txHash;
|
|
111
134
|
}
|
|
112
135
|
/**
|
|
113
|
-
*
|
|
114
|
-
* Callable by the buyer or an arbitrator.
|
|
136
|
+
* Dispute a delivery within the 24h dispute window. Called by the buyer.
|
|
115
137
|
*/
|
|
116
|
-
async
|
|
138
|
+
async disputeEscrow(transactionId) {
|
|
117
139
|
const escrowId = EscrowClient.toEscrowId(transactionId);
|
|
118
|
-
const abi = this.escrowVersion === 3 ? SERVICE_ESCROW_V3_ABI : SERVICE_ESCROW_V2_ABI;
|
|
119
140
|
const data = encodeFunctionData({
|
|
120
|
-
abi,
|
|
121
|
-
functionName: '
|
|
141
|
+
abi: ABBABABA_ESCROW_ABI,
|
|
142
|
+
functionName: 'dispute',
|
|
122
143
|
args: [escrowId],
|
|
123
144
|
});
|
|
124
145
|
const txHash = await this.kernelClient.sendTransaction({
|
|
@@ -128,57 +149,170 @@ export class EscrowClient {
|
|
|
128
149
|
return txHash;
|
|
129
150
|
}
|
|
130
151
|
/**
|
|
131
|
-
*
|
|
152
|
+
* Claim funds for an abandoned escrow (deadline + 7 days passed with no delivery).
|
|
153
|
+
* Called by the buyer to reclaim funds.
|
|
154
|
+
*/
|
|
155
|
+
async claimAbandoned(transactionId) {
|
|
156
|
+
const escrowId = EscrowClient.toEscrowId(transactionId);
|
|
157
|
+
const data = encodeFunctionData({
|
|
158
|
+
abi: ABBABABA_ESCROW_ABI,
|
|
159
|
+
functionName: 'claimAbandoned',
|
|
160
|
+
args: [escrowId],
|
|
161
|
+
});
|
|
162
|
+
const txHash = await this.kernelClient.sendTransaction({
|
|
163
|
+
to: this.escrowAddress,
|
|
164
|
+
data,
|
|
165
|
+
});
|
|
166
|
+
return txHash;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Read escrow details from the V4 contract (view function, no gas needed).
|
|
132
170
|
*/
|
|
133
171
|
async getEscrow(transactionId) {
|
|
134
172
|
const escrowId = EscrowClient.toEscrowId(transactionId);
|
|
135
|
-
const viemChain = CHAINS[this.chainId] ??
|
|
173
|
+
const viemChain = CHAINS[this.chainId] ?? baseSepolia;
|
|
136
174
|
const publicClient = createPublicClient({
|
|
137
175
|
chain: viemChain,
|
|
138
176
|
transport: http(),
|
|
139
177
|
});
|
|
140
|
-
if (this.escrowVersion === 3) {
|
|
141
|
-
const result = await publicClient.readContract({
|
|
142
|
-
address: this.escrowAddress,
|
|
143
|
-
abi: SERVICE_ESCROW_V3_ABI,
|
|
144
|
-
functionName: 'getEscrow',
|
|
145
|
-
args: [escrowId],
|
|
146
|
-
});
|
|
147
|
-
const [token, buyer, seller, amount, buyerFee, status, createdAt, expiresAt] = result;
|
|
148
|
-
if (buyer === '0x0000000000000000000000000000000000000000') {
|
|
149
|
-
return null;
|
|
150
|
-
}
|
|
151
|
-
return {
|
|
152
|
-
token,
|
|
153
|
-
buyer,
|
|
154
|
-
seller,
|
|
155
|
-
amount,
|
|
156
|
-
buyerFee,
|
|
157
|
-
status,
|
|
158
|
-
createdAt: Number(createdAt),
|
|
159
|
-
expiresAt: Number(expiresAt),
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
// V2 fallback
|
|
163
178
|
const result = await publicClient.readContract({
|
|
164
179
|
address: this.escrowAddress,
|
|
165
|
-
abi:
|
|
180
|
+
abi: ABBABABA_ESCROW_ABI,
|
|
166
181
|
functionName: 'getEscrow',
|
|
167
182
|
args: [escrowId],
|
|
168
183
|
});
|
|
169
|
-
const [buyer, seller, amount, buyerFee, status, createdAt,
|
|
170
|
-
if (buyer ===
|
|
184
|
+
const [token, buyer, seller, amount, buyerFee, status, createdAt, deadline, deliveredAt, proofHash] = result;
|
|
185
|
+
if (buyer === ZERO_ADDRESS) {
|
|
171
186
|
return null;
|
|
172
187
|
}
|
|
173
188
|
return {
|
|
189
|
+
token,
|
|
174
190
|
buyer,
|
|
175
191
|
seller,
|
|
176
192
|
amount,
|
|
177
193
|
buyerFee,
|
|
178
194
|
status,
|
|
179
195
|
createdAt: Number(createdAt),
|
|
180
|
-
|
|
196
|
+
deadline: Number(deadline),
|
|
197
|
+
deliveredAt: Number(deliveredAt),
|
|
198
|
+
proofHash: proofHash === ZERO_BYTES32 ? null : proofHash,
|
|
181
199
|
};
|
|
182
200
|
}
|
|
201
|
+
/**
|
|
202
|
+
* Check if the 24h dispute window is currently active for an escrow.
|
|
203
|
+
*/
|
|
204
|
+
async isDisputeWindowActive(transactionId) {
|
|
205
|
+
const escrowId = EscrowClient.toEscrowId(transactionId);
|
|
206
|
+
const viemChain = CHAINS[this.chainId] ?? baseSepolia;
|
|
207
|
+
const publicClient = createPublicClient({
|
|
208
|
+
chain: viemChain,
|
|
209
|
+
transport: http(),
|
|
210
|
+
});
|
|
211
|
+
const result = await publicClient.readContract({
|
|
212
|
+
address: this.escrowAddress,
|
|
213
|
+
abi: ABBABABA_ESCROW_ABI,
|
|
214
|
+
functionName: 'isDisputeWindowActive',
|
|
215
|
+
args: [escrowId],
|
|
216
|
+
});
|
|
217
|
+
return result;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Check if an escrow can be finalized (dispute window passed, no dispute filed).
|
|
221
|
+
*/
|
|
222
|
+
async canFinalize(transactionId) {
|
|
223
|
+
const escrowId = EscrowClient.toEscrowId(transactionId);
|
|
224
|
+
const viemChain = CHAINS[this.chainId] ?? baseSepolia;
|
|
225
|
+
const publicClient = createPublicClient({
|
|
226
|
+
chain: viemChain,
|
|
227
|
+
transport: http(),
|
|
228
|
+
});
|
|
229
|
+
const result = await publicClient.readContract({
|
|
230
|
+
address: this.escrowAddress,
|
|
231
|
+
abi: ABBABABA_ESCROW_ABI,
|
|
232
|
+
functionName: 'canFinalize',
|
|
233
|
+
args: [escrowId],
|
|
234
|
+
});
|
|
235
|
+
return result;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Check if an escrow can be claimed as abandoned (deadline + 7 days passed).
|
|
239
|
+
*/
|
|
240
|
+
async canClaimAbandoned(transactionId) {
|
|
241
|
+
const escrowId = EscrowClient.toEscrowId(transactionId);
|
|
242
|
+
const viemChain = CHAINS[this.chainId] ?? baseSepolia;
|
|
243
|
+
const publicClient = createPublicClient({
|
|
244
|
+
chain: viemChain,
|
|
245
|
+
transport: http(),
|
|
246
|
+
});
|
|
247
|
+
const result = await publicClient.readContract({
|
|
248
|
+
address: this.escrowAddress,
|
|
249
|
+
abi: ABBABABA_ESCROW_ABI,
|
|
250
|
+
functionName: 'canClaimAbandoned',
|
|
251
|
+
args: [escrowId],
|
|
252
|
+
});
|
|
253
|
+
return result;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Read-only client for the AbbababaScore on-chain reputation system.
|
|
258
|
+
* No wallet needed — all methods are view functions.
|
|
259
|
+
*/
|
|
260
|
+
export class ScoreClient {
|
|
261
|
+
chainId;
|
|
262
|
+
scoreAddress;
|
|
263
|
+
constructor(chainId = BASE_SEPOLIA_CHAIN_ID) {
|
|
264
|
+
this.chainId = chainId;
|
|
265
|
+
const addr = SCORE_ADDRESSES[chainId];
|
|
266
|
+
if (!addr)
|
|
267
|
+
throw new Error(`No Score contract for chain ${chainId}`);
|
|
268
|
+
this.scoreAddress = addr;
|
|
269
|
+
}
|
|
270
|
+
getPublicClient() {
|
|
271
|
+
const viemChain = CHAINS[this.chainId] ?? baseSepolia;
|
|
272
|
+
return createPublicClient({
|
|
273
|
+
chain: viemChain,
|
|
274
|
+
transport: http(),
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Get an agent's trust score (int256 — can be negative).
|
|
279
|
+
*/
|
|
280
|
+
async getScore(agentAddress) {
|
|
281
|
+
const publicClient = this.getPublicClient();
|
|
282
|
+
const result = await publicClient.readContract({
|
|
283
|
+
address: this.scoreAddress,
|
|
284
|
+
abi: ABBABABA_SCORE_ABI,
|
|
285
|
+
functionName: 'getScore',
|
|
286
|
+
args: [agentAddress],
|
|
287
|
+
});
|
|
288
|
+
return result;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Check if an agent requires a bond (low trust score).
|
|
292
|
+
*/
|
|
293
|
+
async requiresBond(agentAddress) {
|
|
294
|
+
const publicClient = this.getPublicClient();
|
|
295
|
+
const result = await publicClient.readContract({
|
|
296
|
+
address: this.scoreAddress,
|
|
297
|
+
abi: ABBABABA_SCORE_ABI,
|
|
298
|
+
functionName: 'requiresBond',
|
|
299
|
+
args: [agentAddress],
|
|
300
|
+
});
|
|
301
|
+
return result;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Get full agent stats from the reputation contract.
|
|
305
|
+
*/
|
|
306
|
+
async getAgentStats(agentAddress) {
|
|
307
|
+
const publicClient = this.getPublicClient();
|
|
308
|
+
const result = await publicClient.readContract({
|
|
309
|
+
address: this.scoreAddress,
|
|
310
|
+
abi: ABBABABA_SCORE_ABI,
|
|
311
|
+
functionName: 'getAgentStats',
|
|
312
|
+
args: [agentAddress],
|
|
313
|
+
});
|
|
314
|
+
const [score, totalJobs, disputesLost, jobsAbandoned, needsBond] = result;
|
|
315
|
+
return { score, totalJobs, disputesLost, jobsAbandoned, needsBond };
|
|
316
|
+
}
|
|
183
317
|
}
|
|
184
318
|
//# sourceMappingURL=escrow.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"escrow.js","sourceRoot":"","sources":["../../src/wallet/escrow.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,OAAO,EAGP,kBAAkB,EAClB,IAAI,GACL,MAAM,MAAM,CAAA;AACb,OAAO,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"escrow.js","sourceRoot":"","sources":["../../src/wallet/escrow.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,OAAO,EAGP,kBAAkB,EAClB,IAAI,GACL,MAAM,MAAM,CAAA;AACb,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,mBAAmB,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AG,IAAI,CAAC,eAAe,EAAE,CAAA;QAE3C,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,YAAY,CAAC;YAC7C,OAAO,EAAE,IAAI,CAAC,YAAY;YAC1B,GAAG,EAAE,kBAAkB;YACvB,YAAY,EAAE,eAAe;YAC7B,IAAI,EAAE,CAAC,YAAuB,CAAC;SAChC,CAAC,CAAA;QAEF,MAAM,CAAC,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,CAAC,GAAG,MAElE,CAAA;QAED,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,CAAA;IACrE,CAAC;CACF"}
|
package/dist/wallet/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { createSmartAccount, buildKernelClient } from './smart-account.js';
|
|
2
|
-
export { EscrowClient } from './escrow.js';
|
|
2
|
+
export { EscrowClient, ScoreClient } from './escrow.js';
|
|
3
3
|
export { generateSessionKey, useSessionKey, revokeSessionKey, buildEscrowPolicies, } from './session-keys.js';
|
|
4
|
-
export {
|
|
4
|
+
export { ESCROW_V4_ADDRESSES, SCORE_ADDRESSES, TOKEN_REGISTRY, getToken, getTokensByTier, isTokenSupported, POLYGON_AMOY_CHAIN_ID, POLYGON_MAINNET_CHAIN_ID, BASE_SEPOLIA_CHAIN_ID, BASE_MAINNET_CHAIN_ID, MIN_GAS_BALANCE, } from './constants.js';
|
|
5
5
|
export type { TokenInfo } from './constants.js';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/wallet/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/wallet/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAC1E,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACvD,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAEL,mBAAmB,EACnB,eAAe,EAEf,cAAc,EACd,QAAQ,EACR,eAAe,EACf,gBAAgB,EAEhB,qBAAqB,EACrB,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,EAErB,eAAe,GAChB,MAAM,gBAAgB,CAAA;AACvB,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA"}
|
package/dist/wallet/index.js
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
export { createSmartAccount, buildKernelClient } from './smart-account.js';
|
|
2
|
-
export { EscrowClient } from './escrow.js';
|
|
2
|
+
export { EscrowClient, ScoreClient } from './escrow.js';
|
|
3
3
|
export { generateSessionKey, useSessionKey, revokeSessionKey, buildEscrowPolicies, } from './session-keys.js';
|
|
4
4
|
export {
|
|
5
|
-
//
|
|
6
|
-
|
|
7
|
-
// V2 legacy (single-token USDC)
|
|
8
|
-
ESCROW_V2_ADDRESSES,
|
|
5
|
+
// V4 contract addresses
|
|
6
|
+
ESCROW_V4_ADDRESSES, SCORE_ADDRESSES,
|
|
9
7
|
// Token registry
|
|
10
8
|
TOKEN_REGISTRY, getToken, getTokensByTier, isTokenSupported,
|
|
11
|
-
// Legacy compat (deprecated)
|
|
12
|
-
USDC_ADDRESSES, USDC_DECIMALS,
|
|
13
9
|
// Chain IDs
|
|
14
|
-
POLYGON_AMOY_CHAIN_ID, POLYGON_MAINNET_CHAIN_ID,
|
|
10
|
+
POLYGON_AMOY_CHAIN_ID, POLYGON_MAINNET_CHAIN_ID, BASE_SEPOLIA_CHAIN_ID, BASE_MAINNET_CHAIN_ID,
|
|
15
11
|
// Gas
|
|
16
12
|
MIN_GAS_BALANCE, } from './constants.js';
|
|
17
13
|
//# sourceMappingURL=index.js.map
|
package/dist/wallet/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/wallet/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/wallet/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAC1E,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACvD,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,mBAAmB,CAAA;AAC1B,OAAO;AACL,wBAAwB;AACxB,mBAAmB,EACnB,eAAe;AACf,iBAAiB;AACjB,cAAc,EACd,QAAQ,EACR,eAAe,EACf,gBAAgB;AAChB,YAAY;AACZ,qBAAqB,EACrB,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB;AACrB,MAAM;AACN,eAAe,GAChB,MAAM,gBAAgB,CAAA"}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type { SessionKeyConfig, SessionKeyResult, UseSessionKeyConfig, RevokeSessionKeyConfig, SmartAccountResult } from '../types.js';
|
|
2
2
|
/**
|
|
3
|
-
* Build escrow-scoped policies for a session key.
|
|
3
|
+
* Build escrow-scoped policies for a session key (V4).
|
|
4
4
|
*
|
|
5
|
-
* Creates a CallPolicy restricted to escrow operations:
|
|
6
|
-
* 1. ERC20.approve for each allowed token (spender must equal escrow contract)
|
|
7
|
-
* 2. Escrow.createEscrow (
|
|
8
|
-
* 3. Escrow.
|
|
5
|
+
* Creates a CallPolicy restricted to V4 escrow operations:
|
|
6
|
+
* 1. ERC20.approve for each allowed token (spender must equal V4 escrow contract)
|
|
7
|
+
* 2. Escrow.createEscrow (5 args: escrowId, seller, amount, token, deadline)
|
|
8
|
+
* 3. Escrow.submitDelivery
|
|
9
|
+
* 4. Escrow.accept
|
|
10
|
+
* 5. Escrow.finalizeRelease
|
|
11
|
+
* 6. Escrow.dispute
|
|
9
12
|
*
|
|
10
13
|
* Plus a TimestampPolicy for time-bound expiration.
|
|
11
14
|
*
|
|
@@ -22,7 +25,7 @@ export declare function buildEscrowPolicies(config: {
|
|
|
22
25
|
* Generate a scoped session key for an agent (owner operation).
|
|
23
26
|
*
|
|
24
27
|
* The owner calls this with their private key. A random session key is generated,
|
|
25
|
-
* scoped to escrow operations via CallPolicy + TimestampPolicy, and serialized
|
|
28
|
+
* scoped to V4 escrow operations via CallPolicy + TimestampPolicy, and serialized
|
|
26
29
|
* into a single string that can be passed to the agent.
|
|
27
30
|
*
|
|
28
31
|
* Requires peer dependencies:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-keys.d.ts","sourceRoot":"","sources":["../../src/wallet/session-keys.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,sBAAsB,EACtB,kBAAkB,EAEnB,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"session-keys.d.ts","sourceRoot":"","sources":["../../src/wallet/session-keys.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,sBAAsB,EACtB,kBAAkB,EAEnB,MAAM,aAAa,CAAA;AAWpB;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,mBAAmB,CAAC,MAAM,EAAE;IAChD,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;CAClB,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAwFrB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,gBAAgB,CAAC,CA2F3B;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,kBAAkB,CAAC,CA0D7B;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,sBAAsB,GAC7B,OAAO,CAAC,MAAM,CAAC,CAgFjB"}
|