Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .changeset/olive-dogs-rush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"agentcommercekit": patch
"@agentcommercekit/ack-pay": patch
"@agentcommercekit/ack-id": patch
"@agentcommercekit/keys": patch
"@agentcommercekit/did": patch
"@agentcommercekit/jwt": patch
"@agentcommercekit/vc": patch
---

Add did:pkh support for more chains, including solana
11 changes: 11 additions & 0 deletions .changeset/poor-tips-judge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"agentcommercekit": patch
"@agentcommercekit/ack-pay": patch
"@agentcommercekit/ack-id": patch
"@agentcommercekit/keys": patch
"@agentcommercekit/did": patch
"@agentcommercekit/jwt": patch
"@agentcommercekit/vc": patch
---

Add schemas for CAIP-2, CAIP-10, CAIP-19 which are used by did:pkh
2 changes: 1 addition & 1 deletion demos/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@
"eslint": "^9.27.0",
"tsx": "^4.19.4",
"typescript": "^5",
"vitest": "^3.1.4"
"vitest": "^3.2.4"
}
}
9 changes: 4 additions & 5 deletions demos/e2e/src/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import { verifyAgentIdentityWithCredential } from "./verification"
import type { CredentialVerifier } from "./credential-verifier"
import type { ReceiptVerifier } from "./receipt-verifier"
import type {
Caip2ChainId,
DidDocument,
DidPkhChainId,
DidResolver,
DidUri,
JwtSigner,
Expand All @@ -32,7 +32,7 @@ interface AgentConstructorParams {
receiptVerifier: ReceiptVerifier
credentialVerifier: CredentialVerifier
wallet: Keypair
preferredChainId: DidPkhChainId
preferredChainId: Caip2ChainId
}

export class Agent {
Expand All @@ -48,7 +48,7 @@ export class Agent {
private readonly resolver: DidResolver
private readonly receiptVerifier: ReceiptVerifier
private readonly credentialVerifier: CredentialVerifier
private readonly preferredChainId: DidPkhChainId
private readonly preferredChainId: Caip2ChainId
// An optional map of id to the request itself (e.g. product, message, etc)
private pendingRequests: Record<string, PaymentRequest> = {}

Expand Down Expand Up @@ -79,7 +79,6 @@ export class Agent {
this.preferredChainId = preferredChainId
const { did: walletDid, didDocument: walletDidDocument } =
createDidPkhDocument({
keypair: this.wallet,
address: this.walletAddress,
chainId: this.preferredChainId
})
Expand All @@ -105,7 +104,7 @@ export class Agent {
credentialVerifier
}: {
ownerDid: DidUri
preferredChainId: DidPkhChainId
preferredChainId: Caip2ChainId
resolver: DidResolver
receiptVerifier: ReceiptVerifier
credentialVerifier: CredentialVerifier
Expand Down
4 changes: 2 additions & 2 deletions demos/e2e/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
waitForEnter
} from "@repo/cli-tools"
import {
caip2ChainIds,
createJwt,
didPkhChainIds,
getDidResolver,
parseJwtCredential
} from "agentcommercekit"
Expand All @@ -30,7 +30,7 @@ import type { Keypair, PaymentRequest } from "agentcommercekit"
*
* @see {@link https://namespaces.chainagnostic.org}
*/
const CHAIN_ID = didPkhChainIds.evm.baseSepolia
const CHAIN_ID = caip2ChainIds.baseSepolia

/**
* These are defined outside the `main` function because they are
Expand Down
11 changes: 5 additions & 6 deletions demos/e2e/src/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
} from "agentcommercekit"
import { publicKeyToAddress } from "./utils/evm-address"
import type {
Caip2ChainId,
DidDocument,
DidPkhChainId,
DidResolver,
DidUri,
JwtSigner,
Expand All @@ -15,15 +15,15 @@ import type {

interface ConstructorParams {
wallet: Keypair
preferredChainId: DidPkhChainId
preferredChainId: Caip2ChainId
did: DidUri
didDocument: DidDocument
resolver: DidResolver
}

export class User {
readonly wallet: Keypair
readonly preferredChainId: DidPkhChainId
readonly preferredChainId: Caip2ChainId
readonly did: DidUri
readonly didDocument: DidDocument
readonly signer: JwtSigner
Expand All @@ -48,14 +48,13 @@ export class User {

static async create(
resolver: DidResolver,
chainId: DidPkhChainId
chainId: Caip2ChainId
): Promise<User> {
const wallet = await generateKeypair("secp256k1")
const address = publicKeyToAddress(wallet.publicKey)
const { did, didDocument } = createDidPkhDocument({
address,
chainId,
keypair: wallet
chainId
})

return new User({
Expand Down
2 changes: 1 addition & 1 deletion demos/identity-a2a/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@
"eslint": "^9.27.0",
"tsx": "^4.19.4",
"typescript": "^5",
"vitest": "^3.1.4"
"vitest": "^3.2.4"
}
}
2 changes: 1 addition & 1 deletion demos/identity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@
"eslint": "^9.27.0",
"tsx": "^4.19.4",
"typescript": "^5",
"vitest": "^3.1.4"
"vitest": "^3.2.4"
}
}
2 changes: 1 addition & 1 deletion demos/payments/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@
"eslint": "^9.27.0",
"tsx": "^4.19.4",
"typescript": "^5",
"vitest": "^3.1.4"
"vitest": "^3.2.4"
}
}
4 changes: 2 additions & 2 deletions demos/payments/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from "node:path"
import { didPkhChainIds } from "agentcommercekit"
import { caip2ChainIds } from "agentcommercekit"
import { createPublicClient, http } from "viem"
import { baseSepolia } from "viem/chains"

Expand All @@ -20,7 +20,7 @@ export const envFilePath = path.resolve(currentDir, "..", ".env")
* Configure the EVM chain you'd like to use:
*/
export const chain = baseSepolia
export const chainId = didPkhChainIds.evm.baseSepolia
export const chainId = caip2ChainIds.baseSepolia
export const usdcAddress = "0x036CbD53842c5426634e7929541eC2318f3dCF7e"
export const publicClient = createPublicClient({
chain,
Expand Down
4 changes: 2 additions & 2 deletions demos/payments/src/receipt-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
verifyJwt,
verifyPaymentToken
} from "agentcommercekit"
import { didPkhChainIdSchema } from "agentcommercekit/schemas/valibot"
import { caip2ChainIdSchema } from "agentcommercekit/schemas/valibot"
import { Hono } from "hono"
import { env } from "hono/adapter"
import { HTTPException } from "hono/http-exception"
Expand All @@ -38,7 +38,7 @@ const bodySchema = v.object({
const paymentDetailsSchema = v.object({
metadata: v.union([
v.object({
network: didPkhChainIdSchema,
network: caip2ChainIdSchema,
txHash: v.string()
}),
v.object({
Expand Down
2 changes: 1 addition & 1 deletion demos/payments/src/utils/keypair-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export async function getKeypairInfo(
const account = privateKeyToAccount(
`0x${bytesToHexString(keypair.privateKey)}`
)
const did = createDidPkhUri(address, chainId)
const did = createDidPkhUri(chainId, address)
const jwtSigner = createJwtSigner(keypair)

return {
Expand Down
2 changes: 1 addition & 1 deletion demos/skyfire-kya/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@
"eslint": "^9.27.0",
"tsx": "^4.19.4",
"typescript": "^5",
"vitest": "^3.1.4"
"vitest": "^3.2.4"
}
}
2 changes: 1 addition & 1 deletion examples/issuer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@
"eslint": "^9.27.0",
"tsx": "^4.19.4",
"vite-tsconfig-paths": "^5.1.4",
"vitest": "^3.1.4"
"vitest": "^3.2.4"
}
}
2 changes: 1 addition & 1 deletion examples/local-did-host/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@
"dotenv-cli": "^8.0.0",
"eslint": "^9.27.0",
"tsx": "^4.19.4",
"vitest": "^3.1.4"
"vitest": "^3.2.4"
}
}
2 changes: 1 addition & 1 deletion examples/verifier/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@
"dotenv-cli": "^8.0.0",
"eslint": "^9.27.0",
"tsx": "^4.19.4",
"vitest": "^3.1.4"
"vitest": "^3.2.4"
}
}
2 changes: 1 addition & 1 deletion packages/ack-id/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"eslint": "^9.27.0",
"tsdown": "^0.11.12",
"typescript": "^5",
"vitest": "^3.1.4",
"vitest": "^3.2.4",
"zod": "^3.25.0"
},
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/ack-id/src/a2a/schemas/zod/v3.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { z } from "zod"
import { z } from "zod/v3"

const roleSchema = z.enum(["agent", "user"])

Expand Down
2 changes: 1 addition & 1 deletion packages/ack-id/src/schemas/zod/v3.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { z } from "zod"
import { z } from "zod/v3"

export const controllerClaimSchema = z.object({
id: z.string(),
Expand Down
2 changes: 1 addition & 1 deletion packages/ack-pay/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"eslint": "^9.27.0",
"tsdown": "^0.11.12",
"typescript": "^5",
"vitest": "^3.1.4",
"vitest": "^3.2.4",
"zod": "^3.25.0"
},
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/ack-pay/src/schemas/zod/v3.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { didUriSchema } from "@agentcommercekit/did/schemas/zod/v3"
import { z } from "zod"
import { z } from "zod/v3"

const urlOrDidUri = z.union([z.string().url(), didUriSchema])

Expand Down
4 changes: 2 additions & 2 deletions packages/ack-pay/src/verify-payment-receipt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ describe("verifyPaymentReceipt()", () => {
paymentOptionId: paymentRequest.paymentOptions[0].id,
issuer: receiptIssuerDid,
payerDid: createDidPkhUri(
"0x7B3D8F2E1C9A4B5D6E7F8A9B0C1D2E3F4A5B6C",
"eip155:84532"
"eip155:84532",
"0x7B3D8F2E1C9A4B5D6E7F8A9B0C1D2E3F4A5B6C"
)
})

Expand Down
3 changes: 2 additions & 1 deletion packages/agentcommercekit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"dependencies": {
"@agentcommercekit/ack-id": "workspace:*",
"@agentcommercekit/ack-pay": "workspace:*",
"@agentcommercekit/caip": "workspace:*",
"@agentcommercekit/did": "workspace:*",
"@agentcommercekit/jwt": "workspace:*",
"@agentcommercekit/keys": "workspace:*",
Expand All @@ -90,7 +91,7 @@
"tsdown": "^0.11.12",
"typescript": "^5",
"valibot": "^1.1.0",
"vitest": "^3.1.4",
"vitest": "^3.2.4",
"zod": "^3.25.0"
},
"peerDependencies": {
Expand Down
1 change: 1 addition & 0 deletions packages/agentcommercekit/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from "@agentcommercekit/ack-pay"
export * from "@agentcommercekit/ack-id"
export * from "@agentcommercekit/caip"
export * from "@agentcommercekit/did"
export * from "@agentcommercekit/jwt"
export * from "@agentcommercekit/keys"
Expand Down
1 change: 1 addition & 0 deletions packages/agentcommercekit/src/schemas/valibot.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from "@agentcommercekit/ack-pay/schemas/valibot"
export * from "@agentcommercekit/ack-id/schemas/valibot"
export * from "@agentcommercekit/caip/schemas/valibot"
export * from "@agentcommercekit/did/schemas/valibot"
export * from "@agentcommercekit/jwt/schemas/valibot"
export * from "@agentcommercekit/vc/schemas/valibot"
1 change: 1 addition & 0 deletions packages/agentcommercekit/src/schemas/zod/v3.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from "@agentcommercekit/ack-pay/schemas/zod/v3"
export * from "@agentcommercekit/ack-id/schemas/zod/v3"
export * from "@agentcommercekit/caip/schemas/zod/v3"
export * from "@agentcommercekit/did/schemas/zod/v3"
export * from "@agentcommercekit/jwt/schemas/zod/v3"
export * from "@agentcommercekit/vc/schemas/zod/v3"
1 change: 1 addition & 0 deletions packages/agentcommercekit/src/schemas/zod/v4.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from "@agentcommercekit/ack-pay/schemas/zod/v4"
export * from "@agentcommercekit/ack-id/schemas/zod/v4"
export * from "@agentcommercekit/caip/schemas/zod/v4"
export * from "@agentcommercekit/did/schemas/zod/v4"
export * from "@agentcommercekit/jwt/schemas/zod/v4"
export * from "@agentcommercekit/vc/schemas/zod/v4"
17 changes: 17 additions & 0 deletions packages/caip/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# @agentcommercekit/caip

CAIP (Chain Agnostic Improvement Proposal) utilities with support for CAIP-2, CAIP-10, and CAIP-19.

This package is part of the [Agent Commerce Kit](https://www.agentcommercekit.com).

## Installation

```sh
npm i @agentcommercekit/caip
# or
pnpm add @agentcommercekit/caip
```

## License (MIT)

Copyright (c) 2025 [Catena Labs, Inc](https://catenalabs.com).
7 changes: 7 additions & 0 deletions packages/caip/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// @ts-check

import { config } from "@repo/eslint-config/base"

export default config({
root: import.meta.dirname
})
Loading
Loading