@nullclear/shared 0.0.0-stage → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +8 -2
- package/dist/index.cjs +264 -0
- package/dist/index.d.cts +793 -0
- package/dist/index.d.mts +378 -0
- package/dist/index.d.ts +793 -0
- package/dist/index.js +216 -0
- package/dist/index.mjs +154 -0
- package/package.json +39 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nullclear-Protocol
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @nullclear/shared
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Core shared constants, CAIP-2 network configurations, ABIs, and cryptographic schemas for the NullClear protocol.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
- **Networks (`chains.ts`)**: Base Mainnet (8453) & Base Sepolia (84532) contract addresses.
|
|
7
|
+
- **ERC-8004 ABIs (`erc8004-abi.ts`)**: Official viem `parseAbi` definitions for Identity and Reputation Registries.
|
|
8
|
+
- **x402 V2 Types (`x402-types.ts`)**: Payment options, signatures, EIP-3009 typed data schemas, and Base64 helpers.
|
|
9
|
+
- **EIP-712 KYA Schemas (`eip712-kya.ts`)**: Corporate Mandate and Arbiter Clearing Attestation schemas.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
ARBITER_ATTESTATION_TYPES: () => ARBITER_ATTESTATION_TYPES,
|
|
24
|
+
ARBITER_DOMAIN: () => ARBITER_DOMAIN,
|
|
25
|
+
BASE_MAINNET: () => BASE_MAINNET,
|
|
26
|
+
BASE_SEPOLIA: () => BASE_SEPOLIA,
|
|
27
|
+
CAIP2_TO_CHAIN_ID: () => CAIP2_TO_CHAIN_ID,
|
|
28
|
+
ClearRequestSchema: () => ClearRequestSchema,
|
|
29
|
+
EIP3009_ABI: () => EIP3009_ABI,
|
|
30
|
+
EIP3009_TYPES: () => EIP3009_TYPES,
|
|
31
|
+
ERC8004_IDENTITY_ABI: () => ERC8004_IDENTITY_ABI,
|
|
32
|
+
ERC8004_REPUTATION_ABI: () => ERC8004_REPUTATION_ABI,
|
|
33
|
+
FallbackTargetSchema: () => FallbackTargetSchema,
|
|
34
|
+
InvariantRuleSchema: () => InvariantRuleSchema,
|
|
35
|
+
KYA_DOMAIN: () => KYA_DOMAIN,
|
|
36
|
+
KYA_MANDATE_TYPES: () => KYA_MANDATE_TYPES,
|
|
37
|
+
NULLCLEAR_ARBITER_ADDRESS: () => NULLCLEAR_ARBITER_ADDRESS,
|
|
38
|
+
NULLCLEAR_TREASURY_ADDRESS: () => NULLCLEAR_TREASURY_ADDRESS,
|
|
39
|
+
SUPPORTED_CHAINS: () => SUPPORTED_CHAINS,
|
|
40
|
+
SpendPolicySchema: () => SpendPolicySchema,
|
|
41
|
+
ValidationConfigSchema: () => ValidationConfigSchema,
|
|
42
|
+
decodeBase64Json: () => decodeBase64Json,
|
|
43
|
+
encodeBase64Json: () => encodeBase64Json,
|
|
44
|
+
getChainConfig: () => getChainConfig
|
|
45
|
+
});
|
|
46
|
+
module.exports = __toCommonJS(index_exports);
|
|
47
|
+
|
|
48
|
+
// src/chains.ts
|
|
49
|
+
var NULLCLEAR_TREASURY_ADDRESS = "0xB586eFcCa41dF27ad3873BEcA54da0c30bf04d5c";
|
|
50
|
+
var NULLCLEAR_ARBITER_ADDRESS = "0xfd74fF802EA0E735514C070AF04E0D6528deD145";
|
|
51
|
+
var BASE_MAINNET = {
|
|
52
|
+
name: "Base Mainnet",
|
|
53
|
+
chainId: 8453,
|
|
54
|
+
caip2: "eip155:8453",
|
|
55
|
+
erc8004Identity: "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432",
|
|
56
|
+
erc8004Reputation: "0x8004BAa17C55a88189AE136b182e5fdA19dE9b63",
|
|
57
|
+
usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
58
|
+
usdcDomain: {
|
|
59
|
+
name: "USD Coin",
|
|
60
|
+
version: "2",
|
|
61
|
+
chainId: 8453,
|
|
62
|
+
verifyingContract: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
|
|
63
|
+
},
|
|
64
|
+
rpcUrl: "https://mainnet.base.org",
|
|
65
|
+
blockExplorer: "https://basescan.org"
|
|
66
|
+
};
|
|
67
|
+
var BASE_SEPOLIA = {
|
|
68
|
+
name: "Base Sepolia",
|
|
69
|
+
chainId: 84532,
|
|
70
|
+
caip2: "eip155:84532",
|
|
71
|
+
erc8004Identity: "0x8004A818BFB912233c491871b3d84c89A494BD9e",
|
|
72
|
+
erc8004Reputation: "0x8004B663056A597Dffe9eCcC1965A193B7388713",
|
|
73
|
+
usdc: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
|
|
74
|
+
usdcDomain: {
|
|
75
|
+
name: "USDC",
|
|
76
|
+
version: "2",
|
|
77
|
+
chainId: 84532,
|
|
78
|
+
verifyingContract: "0x036CbD53842c5426634e7929541eC2318f3dCF7e"
|
|
79
|
+
},
|
|
80
|
+
rpcUrl: "https://sepolia.base.org",
|
|
81
|
+
blockExplorer: "https://sepolia.basescan.org"
|
|
82
|
+
};
|
|
83
|
+
var SUPPORTED_CHAINS = {
|
|
84
|
+
8453: BASE_MAINNET,
|
|
85
|
+
84532: BASE_SEPOLIA
|
|
86
|
+
};
|
|
87
|
+
var CAIP2_TO_CHAIN_ID = {
|
|
88
|
+
"eip155:8453": 8453,
|
|
89
|
+
"eip155:84532": 84532
|
|
90
|
+
};
|
|
91
|
+
function getChainConfig(chainIdOrCaip2) {
|
|
92
|
+
let chainId;
|
|
93
|
+
if (typeof chainIdOrCaip2 === "string") {
|
|
94
|
+
if (chainIdOrCaip2.startsWith("eip155:")) {
|
|
95
|
+
chainId = CAIP2_TO_CHAIN_ID[chainIdOrCaip2] ?? parseInt(chainIdOrCaip2.slice(7), 10);
|
|
96
|
+
} else {
|
|
97
|
+
chainId = parseInt(chainIdOrCaip2, 10);
|
|
98
|
+
}
|
|
99
|
+
} else {
|
|
100
|
+
chainId = chainIdOrCaip2;
|
|
101
|
+
}
|
|
102
|
+
const config = SUPPORTED_CHAINS[chainId];
|
|
103
|
+
if (!config) {
|
|
104
|
+
throw new Error(`Unsupported chain ID or CAIP-2 identifier: ${chainIdOrCaip2}`);
|
|
105
|
+
}
|
|
106
|
+
return config;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// src/erc8004-abi.ts
|
|
110
|
+
var import_viem = require("viem");
|
|
111
|
+
var ERC8004_IDENTITY_ABI = (0, import_viem.parseAbi)([
|
|
112
|
+
"function register(string agentURI) external returns (uint256 agentId)",
|
|
113
|
+
"function ownerOf(uint256 tokenId) external view returns (address)",
|
|
114
|
+
"function tokenURI(uint256 tokenId) external view returns (string)",
|
|
115
|
+
"function getAgentWallet(uint256 agentId) external view returns (address)",
|
|
116
|
+
"event Registered(uint256 indexed agentId, string agentURI, address indexed owner)"
|
|
117
|
+
]);
|
|
118
|
+
var ERC8004_REPUTATION_ABI = (0, import_viem.parseAbi)([
|
|
119
|
+
"function giveFeedback(uint256 agentId, int128 value, uint8 valueDecimals, string tag1, string tag2, string endpoint, string feedbackURI, bytes32 feedbackHash) external",
|
|
120
|
+
"function getSummary(uint256 agentId, address[] clientAddresses, string tag1, string tag2) external view returns (uint64 count, int128 summaryValue, uint8 summaryValueDecimals)",
|
|
121
|
+
"function readFeedback(uint256 agentId, address clientAddress, uint64 feedbackIndex) external view returns (int128 value, uint8 valueDecimals, string tag1, string tag2, bool isRevoked)",
|
|
122
|
+
"event NewFeedback(uint256 indexed agentId, address indexed clientAddress, uint64 feedbackIndex, int128 value, uint8 valueDecimals, string indexed indexedTag1, string tag1, string tag2, string endpoint, string feedbackURI, bytes32 feedbackHash)"
|
|
123
|
+
]);
|
|
124
|
+
|
|
125
|
+
// src/x402-types.ts
|
|
126
|
+
var import_viem2 = require("viem");
|
|
127
|
+
var EIP3009_ABI = (0, import_viem2.parseAbi)([
|
|
128
|
+
"function transferWithAuthorization(address from, address to, uint256 value, uint256 validAfter, uint256 validBefore, bytes32 nonce, uint8 v, bytes32 r, bytes32 s) external"
|
|
129
|
+
]);
|
|
130
|
+
var EIP3009_TYPES = {
|
|
131
|
+
TransferWithAuthorization: [
|
|
132
|
+
{ name: "from", type: "address" },
|
|
133
|
+
{ name: "to", type: "address" },
|
|
134
|
+
{ name: "value", type: "uint256" },
|
|
135
|
+
{ name: "validAfter", type: "uint256" },
|
|
136
|
+
{ name: "validBefore", type: "uint256" },
|
|
137
|
+
{ name: "nonce", type: "bytes32" }
|
|
138
|
+
]
|
|
139
|
+
};
|
|
140
|
+
function encodeBase64Json(obj) {
|
|
141
|
+
const json = JSON.stringify(obj);
|
|
142
|
+
if (typeof Buffer !== "undefined") {
|
|
143
|
+
return Buffer.from(json, "utf-8").toString("base64");
|
|
144
|
+
}
|
|
145
|
+
return btoa(unescape(encodeURIComponent(json)));
|
|
146
|
+
}
|
|
147
|
+
function decodeBase64Json(base64) {
|
|
148
|
+
let json;
|
|
149
|
+
if (typeof Buffer !== "undefined") {
|
|
150
|
+
json = Buffer.from(base64, "base64").toString("utf-8");
|
|
151
|
+
} else {
|
|
152
|
+
json = decodeURIComponent(escape(atob(base64)));
|
|
153
|
+
}
|
|
154
|
+
return JSON.parse(json);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// src/eip712-kya.ts
|
|
158
|
+
var KYA_MANDATE_TYPES = {
|
|
159
|
+
CorporateMandate: [
|
|
160
|
+
{ name: "corporateEntity", type: "string" },
|
|
161
|
+
{ name: "entityRegistrationNumber", type: "string" },
|
|
162
|
+
{ name: "agentId", type: "string" },
|
|
163
|
+
{ name: "agentWallet", type: "address" },
|
|
164
|
+
{ name: "maxTxLimitUsd", type: "uint256" },
|
|
165
|
+
{ name: "liabilityCoverageUsd", type: "uint256" },
|
|
166
|
+
{ name: "validUntil", type: "uint256" },
|
|
167
|
+
{ name: "jurisdiction", type: "string" }
|
|
168
|
+
]
|
|
169
|
+
};
|
|
170
|
+
var KYA_DOMAIN = {
|
|
171
|
+
name: "NullClear KYA Registry",
|
|
172
|
+
version: "1",
|
|
173
|
+
chainId: 8453
|
|
174
|
+
};
|
|
175
|
+
var ARBITER_ATTESTATION_TYPES = {
|
|
176
|
+
ClearingAttestation: [
|
|
177
|
+
{ name: "clearingId", type: "string" },
|
|
178
|
+
{ name: "buyer", type: "address" },
|
|
179
|
+
{ name: "sellerAgentId", type: "string" },
|
|
180
|
+
{ name: "amountAtomic", type: "uint256" },
|
|
181
|
+
{ name: "feeAtomic", type: "uint256" },
|
|
182
|
+
{ name: "responseHash", type: "bytes32" },
|
|
183
|
+
{ name: "timestamp", type: "uint256" },
|
|
184
|
+
{ name: "cleared", type: "bool" }
|
|
185
|
+
]
|
|
186
|
+
};
|
|
187
|
+
var ARBITER_DOMAIN = {
|
|
188
|
+
name: "NullClear Arbiter",
|
|
189
|
+
version: "1",
|
|
190
|
+
chainId: 8453
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
// src/schemas.ts
|
|
194
|
+
var import_zod = require("zod");
|
|
195
|
+
var InvariantRuleSchema = import_zod.z.object({
|
|
196
|
+
path: import_zod.z.string(),
|
|
197
|
+
gt: import_zod.z.number().optional(),
|
|
198
|
+
gte: import_zod.z.number().optional(),
|
|
199
|
+
lt: import_zod.z.number().optional(),
|
|
200
|
+
lte: import_zod.z.number().optional(),
|
|
201
|
+
eq: import_zod.z.union([import_zod.z.string(), import_zod.z.number(), import_zod.z.boolean()]).optional(),
|
|
202
|
+
neq: import_zod.z.union([import_zod.z.string(), import_zod.z.number(), import_zod.z.boolean()]).optional(),
|
|
203
|
+
minLength: import_zod.z.number().optional(),
|
|
204
|
+
maxLength: import_zod.z.number().optional(),
|
|
205
|
+
pattern: import_zod.z.string().optional(),
|
|
206
|
+
notContains: import_zod.z.array(import_zod.z.string()).optional(),
|
|
207
|
+
maxStalenessSeconds: import_zod.z.number().optional()
|
|
208
|
+
});
|
|
209
|
+
var ValidationConfigSchema = import_zod.z.object({
|
|
210
|
+
expectedStatus: import_zod.z.array(import_zod.z.number()).optional(),
|
|
211
|
+
jsonSchema: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional(),
|
|
212
|
+
requiredFields: import_zod.z.array(import_zod.z.string()).optional(),
|
|
213
|
+
sha256Match: import_zod.z.string().optional(),
|
|
214
|
+
rejectRefusals: import_zod.z.boolean().optional(),
|
|
215
|
+
invariants: import_zod.z.array(InvariantRuleSchema).optional()
|
|
216
|
+
});
|
|
217
|
+
var FallbackTargetSchema = import_zod.z.object({
|
|
218
|
+
targetUrl: import_zod.z.string(),
|
|
219
|
+
sellerAgentId: import_zod.z.string().optional(),
|
|
220
|
+
paymentSignatureHeader: import_zod.z.string(),
|
|
221
|
+
headers: import_zod.z.record(import_zod.z.string(), import_zod.z.string()).optional()
|
|
222
|
+
});
|
|
223
|
+
var SpendPolicySchema = import_zod.z.object({
|
|
224
|
+
maxPerCallAtomic: import_zod.z.string().optional(),
|
|
225
|
+
maxDailyWalletAtomic: import_zod.z.string().optional()
|
|
226
|
+
});
|
|
227
|
+
var ClearRequestSchema = import_zod.z.object({
|
|
228
|
+
targetUrl: import_zod.z.string(),
|
|
229
|
+
method: import_zod.z.enum(["GET", "POST", "PUT", "DELETE"]).optional().default("GET"),
|
|
230
|
+
headers: import_zod.z.record(import_zod.z.string(), import_zod.z.string()).optional(),
|
|
231
|
+
body: import_zod.z.unknown().optional(),
|
|
232
|
+
paymentSignatureHeader: import_zod.z.string(),
|
|
233
|
+
sellerAgentId: import_zod.z.string().optional(),
|
|
234
|
+
minTrustScore: import_zod.z.number().optional().default(50),
|
|
235
|
+
twoPhaseRelease: import_zod.z.boolean().optional().default(false),
|
|
236
|
+
validation: ValidationConfigSchema.optional(),
|
|
237
|
+
fallbacks: import_zod.z.array(FallbackTargetSchema).max(3).optional(),
|
|
238
|
+
spendPolicy: SpendPolicySchema.optional()
|
|
239
|
+
});
|
|
240
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
241
|
+
0 && (module.exports = {
|
|
242
|
+
ARBITER_ATTESTATION_TYPES,
|
|
243
|
+
ARBITER_DOMAIN,
|
|
244
|
+
BASE_MAINNET,
|
|
245
|
+
BASE_SEPOLIA,
|
|
246
|
+
CAIP2_TO_CHAIN_ID,
|
|
247
|
+
ClearRequestSchema,
|
|
248
|
+
EIP3009_ABI,
|
|
249
|
+
EIP3009_TYPES,
|
|
250
|
+
ERC8004_IDENTITY_ABI,
|
|
251
|
+
ERC8004_REPUTATION_ABI,
|
|
252
|
+
FallbackTargetSchema,
|
|
253
|
+
InvariantRuleSchema,
|
|
254
|
+
KYA_DOMAIN,
|
|
255
|
+
KYA_MANDATE_TYPES,
|
|
256
|
+
NULLCLEAR_ARBITER_ADDRESS,
|
|
257
|
+
NULLCLEAR_TREASURY_ADDRESS,
|
|
258
|
+
SUPPORTED_CHAINS,
|
|
259
|
+
SpendPolicySchema,
|
|
260
|
+
ValidationConfigSchema,
|
|
261
|
+
decodeBase64Json,
|
|
262
|
+
encodeBase64Json,
|
|
263
|
+
getChainConfig
|
|
264
|
+
});
|