@4mica/x402 1.0.1 → 1.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 +16 -0
- package/package.json +1 -1
- package/src/client/scheme.ts +1 -0
- package/src/index.ts +2 -0
- package/src/server/scheme.ts +7 -1
- package/src/types.ts +24 -0
- package/tests/client-scheme.test.ts +2 -0
package/README.md
CHANGED
|
@@ -156,6 +156,22 @@ The recommended middleware factory for most use cases. Automatically configures
|
|
|
156
156
|
6. **`paywall`** (optional): Custom paywall provider
|
|
157
157
|
7. **`syncFacilitatorOnStart`** (optional): Whether to sync with facilitator on startup (defaults to true)
|
|
158
158
|
|
|
159
|
+
#### V2 Requirements Extra
|
|
160
|
+
|
|
161
|
+
When using x402 V2, `paymentRequirements.extra` must include the validation policy fields expected by the 4mica SDKs and facilitator:
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
const extra = {
|
|
165
|
+
validationRegistryAddress: '0x3333333333333333333333333333333333333333',
|
|
166
|
+
validatorAddress: '0x4444444444444444444444444444444444444444',
|
|
167
|
+
validatorAgentId: '7',
|
|
168
|
+
minValidationScore: 80,
|
|
169
|
+
jobHash: '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
|
|
170
|
+
requiredValidationTag: 'hard-finality', // optional
|
|
171
|
+
tabEndpoint: 'https://api.example.com/tabs/open',
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
159
175
|
#### Supported Networks
|
|
160
176
|
|
|
161
177
|
- `eip155:11155111` - Ethereum Sepolia
|
package/package.json
CHANGED
package/src/client/scheme.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { SUPPORTED_NETWORKS } from '../server/scheme.js'
|
|
|
12
12
|
|
|
13
13
|
const NETWORK_RPC_URLS: Record<Network, string> = {
|
|
14
14
|
'eip155:11155111': 'https://ethereum.sepolia.api.4mica.xyz',
|
|
15
|
+
'eip155:84532': 'https://base.sepolia.api.4mica.xyz',
|
|
15
16
|
'eip155:80002': 'https://api.4mica.xyz',
|
|
16
17
|
}
|
|
17
18
|
|
package/src/index.ts
CHANGED
package/src/server/scheme.ts
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
MoneyParser,
|
|
8
8
|
} from '@x402/core/types'
|
|
9
9
|
|
|
10
|
-
export const SUPPORTED_NETWORKS: Network[] = ['eip155:11155111', 'eip155:80002']
|
|
10
|
+
export const SUPPORTED_NETWORKS: Network[] = ['eip155:11155111', 'eip155:84532', 'eip155:80002']
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* EVM server implementation for the 4mica payment scheme.
|
|
@@ -205,6 +205,12 @@ export class FourMicaEvmScheme implements SchemeNetworkServer {
|
|
|
205
205
|
version: '2',
|
|
206
206
|
decimals: 6,
|
|
207
207
|
}, // Ethereum Sepolia USDC
|
|
208
|
+
'eip155:84532': {
|
|
209
|
+
address: '0x036CbD53842c5426634e7929541eC2318f3dCF7e',
|
|
210
|
+
name: 'USDC',
|
|
211
|
+
version: '2',
|
|
212
|
+
decimals: 6,
|
|
213
|
+
}, // Base Sepolia USDC
|
|
208
214
|
'eip155:80002': {
|
|
209
215
|
address: '0x41E94Eb019C0762f9Bfcf9Fb1E58725BfB0e7582',
|
|
210
216
|
name: 'USDC',
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { PaymentRequirements } from '@x402/core/types'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Extra fields required by the 4mica V2 validation policy.
|
|
5
|
+
*/
|
|
6
|
+
export type FourMicaV2RequirementsExtra = {
|
|
7
|
+
validationRegistryAddress: string
|
|
8
|
+
validatorAddress: string
|
|
9
|
+
validatorAgentId: string | number
|
|
10
|
+
minValidationScore: number
|
|
11
|
+
jobHash: string
|
|
12
|
+
requiredValidationTag?: string
|
|
13
|
+
tabEndpoint?: string
|
|
14
|
+
rpcUrl?: string
|
|
15
|
+
resource?: {
|
|
16
|
+
url?: string
|
|
17
|
+
description?: string
|
|
18
|
+
mimeType?: string
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type FourMicaPaymentRequirementsV2 = PaymentRequirements & {
|
|
23
|
+
extra: FourMicaV2RequirementsExtra
|
|
24
|
+
}
|
|
@@ -39,6 +39,7 @@ describe('FourMicaEvmScheme', () => {
|
|
|
39
39
|
validatorAgentId: '7',
|
|
40
40
|
minValidationScore: 80,
|
|
41
41
|
requiredValidationTag: 'hard-finality',
|
|
42
|
+
jobHash: '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
|
|
42
43
|
resource: {
|
|
43
44
|
url: 'https://api.example.com/premium',
|
|
44
45
|
description: 'Premium dataset',
|
|
@@ -73,6 +74,7 @@ describe('FourMicaEvmScheme', () => {
|
|
|
73
74
|
validatorAgentId: '7',
|
|
74
75
|
minValidationScore: 80,
|
|
75
76
|
requiredValidationTag: 'hard-finality',
|
|
77
|
+
jobHash: '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
|
|
76
78
|
})
|
|
77
79
|
})
|
|
78
80
|
|