@agentbadge/circle-payments 0.1.17 → 0.1.18
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/chain/chain.d.ts +32 -0
- package/dist/chain/chain.js +44 -0
- package/dist/chain/index.d.ts +1 -0
- package/dist/chain/index.js +1 -0
- package/dist/chains.d.ts +8 -0
- package/dist/chains.js +27 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type Hex = `0x${string}`;
|
|
2
|
+
export declare const GENESIS_HASH: Hex;
|
|
3
|
+
export interface ChainEntry {
|
|
4
|
+
seq: number;
|
|
5
|
+
domain: string;
|
|
6
|
+
verdictId: Hex;
|
|
7
|
+
prevHash: Hex;
|
|
8
|
+
entryHash: Hex;
|
|
9
|
+
artifactHash: Hex;
|
|
10
|
+
appendedAt: number;
|
|
11
|
+
}
|
|
12
|
+
export interface ChainHead {
|
|
13
|
+
domain: string;
|
|
14
|
+
headHash: Hex;
|
|
15
|
+
count: number;
|
|
16
|
+
lastFlushAt?: number;
|
|
17
|
+
anchor?: {
|
|
18
|
+
epochSeq: number;
|
|
19
|
+
txHash: Hex;
|
|
20
|
+
blockNumber: string;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export declare function computeEntryHash(prevHash: Hex, artifactHash: Hex): Hex;
|
|
24
|
+
export declare function appendEntry(domain: string, verdictId: Hex, artifactHash: Hex, entries: readonly ChainEntry[], appendedAt?: number): ChainEntry;
|
|
25
|
+
export interface ChainVerifyResult {
|
|
26
|
+
ok: boolean;
|
|
27
|
+
firstBrokenSeq: number | null;
|
|
28
|
+
headHash: Hex;
|
|
29
|
+
}
|
|
30
|
+
export declare function verifyChain(entries: readonly ChainEntry[]): ChainVerifyResult;
|
|
31
|
+
export declare function inclusionPath(entries: readonly ChainEntry[], seq: number): ChainEntry[];
|
|
32
|
+
export declare function chainHeadOf(domain: string, entries: readonly ChainEntry[]): ChainHead;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { concatHex, keccak256 } from "viem";
|
|
2
|
+
export const GENESIS_HASH = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
3
|
+
export function computeEntryHash(prevHash, artifactHash) {
|
|
4
|
+
return keccak256(concatHex([prevHash, artifactHash]));
|
|
5
|
+
}
|
|
6
|
+
function headHashOf(entries) {
|
|
7
|
+
return entries.length === 0
|
|
8
|
+
? GENESIS_HASH
|
|
9
|
+
: entries[entries.length - 1].entryHash;
|
|
10
|
+
}
|
|
11
|
+
export function appendEntry(domain, verdictId, artifactHash, entries, appendedAt = Date.now()) {
|
|
12
|
+
const prevHash = headHashOf(entries);
|
|
13
|
+
return {
|
|
14
|
+
seq: entries.length,
|
|
15
|
+
domain,
|
|
16
|
+
verdictId,
|
|
17
|
+
prevHash,
|
|
18
|
+
entryHash: computeEntryHash(prevHash, artifactHash),
|
|
19
|
+
artifactHash,
|
|
20
|
+
appendedAt,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export function verifyChain(entries) {
|
|
24
|
+
let prevHash = GENESIS_HASH;
|
|
25
|
+
for (let i = 0; i < entries.length; i++) {
|
|
26
|
+
const e = entries[i];
|
|
27
|
+
const broken = e.seq !== i ||
|
|
28
|
+
e.prevHash !== prevHash ||
|
|
29
|
+
e.entryHash !== computeEntryHash(prevHash, e.artifactHash);
|
|
30
|
+
if (broken) {
|
|
31
|
+
return { ok: false, firstBrokenSeq: e.seq, headHash: prevHash };
|
|
32
|
+
}
|
|
33
|
+
prevHash = e.entryHash;
|
|
34
|
+
}
|
|
35
|
+
return { ok: true, firstBrokenSeq: null, headHash: prevHash };
|
|
36
|
+
}
|
|
37
|
+
export function inclusionPath(entries, seq) {
|
|
38
|
+
if (seq < 0 || seq >= entries.length)
|
|
39
|
+
return [];
|
|
40
|
+
return entries.slice(seq);
|
|
41
|
+
}
|
|
42
|
+
export function chainHeadOf(domain, entries) {
|
|
43
|
+
return { domain, headHash: headHashOf(entries), count: entries.length };
|
|
44
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./chain.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./chain.js";
|
package/dist/chains.d.ts
CHANGED
|
@@ -35,10 +35,18 @@ export declare const ARC_MAINNET_AGENTBADGE_CONTRACTS: {
|
|
|
35
35
|
readonly accessPassNFT: "0x68ca4d1a9ff24f86328f2fb3a30d81e503d367f5";
|
|
36
36
|
readonly marketplacePassNFT: "0xf8756ce4400c76f1c31b72216c391e1c46cc2c03";
|
|
37
37
|
};
|
|
38
|
+
export declare const CELO_MAINNET: SupportedChain;
|
|
39
|
+
export declare const CELO_SEPOLIA: SupportedChain;
|
|
40
|
+
export declare const CELO_ERC8004_CONTRACTS: {
|
|
41
|
+
readonly celo: "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432";
|
|
42
|
+
readonly celoSepolia: "0x8004A818BFB912233c491871b3d84c89A494BD9e";
|
|
43
|
+
};
|
|
38
44
|
export declare const CHAINS: {
|
|
39
45
|
readonly [BASE_SEPOLIA.caip2]: SupportedChain;
|
|
40
46
|
readonly [ARC_TESTNET.caip2]: SupportedChain;
|
|
41
47
|
readonly [ARC_MAINNET.caip2]: SupportedChain;
|
|
48
|
+
readonly [CELO_MAINNET.caip2]: SupportedChain;
|
|
49
|
+
readonly [CELO_SEPOLIA.caip2]: SupportedChain;
|
|
42
50
|
};
|
|
43
51
|
export declare function getChain(id: string | number): SupportedChain | undefined;
|
|
44
52
|
export type PaymentSchemeId = "gateway-batch" | "exact" | "eip3009-client-broadcast";
|
package/dist/chains.js
CHANGED
|
@@ -56,10 +56,37 @@ export const ARC_MAINNET_AGENTBADGE_CONTRACTS = {
|
|
|
56
56
|
accessPassNFT: "0x68ca4d1a9ff24f86328f2fb3a30d81e503d367f5",
|
|
57
57
|
marketplacePassNFT: "0xf8756ce4400c76f1c31b72216c391e1c46cc2c03",
|
|
58
58
|
};
|
|
59
|
+
export const CELO_MAINNET = {
|
|
60
|
+
caip2: "eip155:42220",
|
|
61
|
+
chainId: 42220,
|
|
62
|
+
name: "Celo",
|
|
63
|
+
usdc: "0xcebA9300f2b948710d2653dD7B07f33A8B32118C",
|
|
64
|
+
usdcDecimals: 6,
|
|
65
|
+
rpcUrl: process.env.CELO_RPC_URL ?? "https://forno.celo.org",
|
|
66
|
+
facilitatorUrl: "https://api.x402.celo.org",
|
|
67
|
+
explorerUrl: "https://celoscan.io",
|
|
68
|
+
};
|
|
69
|
+
export const CELO_SEPOLIA = {
|
|
70
|
+
caip2: "eip155:11142220",
|
|
71
|
+
chainId: 11142220,
|
|
72
|
+
name: "Celo Sepolia",
|
|
73
|
+
usdc: "0x01C5C0122039549AD1493B8220cABEdD739BC44E",
|
|
74
|
+
usdcDecimals: 6,
|
|
75
|
+
rpcUrl: process.env.CELO_SEPOLIA_RPC_URL ??
|
|
76
|
+
"https://forno.celo-sepolia.celo-testnet.org",
|
|
77
|
+
explorerUrl: "https://sepolia.celoscan.io",
|
|
78
|
+
faucetUrl: "https://faucet.celo.org/celo-sepolia",
|
|
79
|
+
};
|
|
80
|
+
export const CELO_ERC8004_CONTRACTS = {
|
|
81
|
+
celo: "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432",
|
|
82
|
+
celoSepolia: "0x8004A818BFB912233c491871b3d84c89A494BD9e",
|
|
83
|
+
};
|
|
59
84
|
export const CHAINS = {
|
|
60
85
|
[BASE_SEPOLIA.caip2]: BASE_SEPOLIA,
|
|
61
86
|
[ARC_TESTNET.caip2]: ARC_TESTNET,
|
|
62
87
|
[ARC_MAINNET.caip2]: ARC_MAINNET,
|
|
88
|
+
[CELO_MAINNET.caip2]: CELO_MAINNET,
|
|
89
|
+
[CELO_SEPOLIA.caip2]: CELO_SEPOLIA,
|
|
63
90
|
};
|
|
64
91
|
export function getChain(id) {
|
|
65
92
|
const key = typeof id === "number" ? `eip155:${id}` : id;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentbadge/circle-payments",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.18",
|
|
4
4
|
"description": "Circle Gateway nanopayments + x402 payment rails (Base Sepolia, Arc) for AgentBadge \u2014 trusted agent payments",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|