@agirails/sdk 2.0.2 → 2.0.3
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 +22 -22
- package/dist/ACTPClient.d.ts +24 -24
- package/dist/ACTPClient.d.ts.map +1 -1
- package/dist/ACTPClient.js +18 -18
- package/dist/ACTPClient.js.map +1 -1
- package/dist/adapters/BasicAdapter.d.ts +152 -0
- package/dist/adapters/BasicAdapter.d.ts.map +1 -0
- package/dist/adapters/BasicAdapter.js +168 -0
- package/dist/adapters/BasicAdapter.js.map +1 -0
- package/dist/adapters/StandardAdapter.d.ts +211 -0
- package/dist/adapters/StandardAdapter.d.ts.map +1 -0
- package/dist/adapters/StandardAdapter.js +260 -0
- package/dist/adapters/StandardAdapter.js.map +1 -0
- package/dist/adapters/index.d.ts +4 -4
- package/dist/adapters/index.d.ts.map +1 -1
- package/dist/adapters/index.js +7 -7
- package/dist/adapters/index.js.map +1 -1
- package/dist/cli/commands/pay.d.ts +1 -1
- package/dist/cli/commands/pay.js +2 -2
- package/dist/cli/commands/pay.js.map +1 -1
- package/dist/cli/commands/tx.d.ts +1 -1
- package/dist/cli/commands/tx.js +13 -13
- package/dist/cli/commands/tx.js.map +1 -1
- package/dist/cli/commands/watch.js +2 -2
- package/dist/cli/commands/watch.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/protocol/ACTPKernel.d.ts +5 -5
- package/dist/protocol/ACTPKernel.js +5 -5
- package/dist/runtime/BlockchainRuntime.d.ts +1 -1
- package/dist/runtime/BlockchainRuntime.js +1 -1
- package/dist/runtime/IACTPRuntime.d.ts +1 -1
- package/dist/utils/ErrorRecoveryGuide.d.ts +2 -2
- package/dist/utils/ErrorRecoveryGuide.js +2 -2
- package/package.json +1 -1
- package/src/ACTPClient.ts +26 -26
- package/src/adapters/{BeginnerAdapter.ts → BasicAdapter.ts} +11 -11
- package/src/adapters/{IntermediateAdapter.ts → StandardAdapter.ts} +15 -15
- package/src/adapters/index.ts +4 -4
- package/src/cli/commands/pay.ts +2 -2
- package/src/cli/commands/tx.ts +13 -13
- package/src/cli/commands/watch.ts +2 -2
- package/src/index.ts +8 -8
- package/src/protocol/ACTPKernel.ts +5 -5
- package/src/runtime/BlockchainRuntime.ts +1 -1
- package/src/runtime/IACTPRuntime.ts +1 -1
- package/src/utils/ErrorRecoveryGuide.ts +2 -2
package/src/ACTPClient.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Provides the unified API for interacting with the ACTP protocol
|
|
5
5
|
* through three different abstraction levels:
|
|
6
|
-
* - `
|
|
7
|
-
* - `
|
|
6
|
+
* - `basic`: High-level, opinionated API for simple use cases
|
|
7
|
+
* - `standard`: Balanced API with more control
|
|
8
8
|
* - `advanced`: Direct protocol access for full control
|
|
9
9
|
*
|
|
10
10
|
* @module ACTPClient
|
|
@@ -17,18 +17,18 @@
|
|
|
17
17
|
* requesterAddress: '0x1234...',
|
|
18
18
|
* });
|
|
19
19
|
*
|
|
20
|
-
* //
|
|
21
|
-
* const result = await client.
|
|
20
|
+
* // Basic API - simplest approach
|
|
21
|
+
* const result = await client.basic.pay({
|
|
22
22
|
* to: '0xProvider...',
|
|
23
23
|
* amount: '100',
|
|
24
24
|
* });
|
|
25
25
|
*
|
|
26
|
-
* //
|
|
27
|
-
* const txId = await client.
|
|
26
|
+
* // Standard API - more control
|
|
27
|
+
* const txId = await client.standard.createTransaction({
|
|
28
28
|
* provider: '0xProvider...',
|
|
29
29
|
* amount: '100',
|
|
30
30
|
* });
|
|
31
|
-
* await client.
|
|
31
|
+
* await client.standard.linkEscrow(txId);
|
|
32
32
|
*
|
|
33
33
|
* // Advanced API - direct protocol access
|
|
34
34
|
* const tx = await client.advanced.getTransaction(txId);
|
|
@@ -43,8 +43,8 @@ import { MockRuntime } from './runtime/MockRuntime';
|
|
|
43
43
|
import { MockStateManager } from './runtime/MockStateManager';
|
|
44
44
|
import { BlockchainRuntime } from './runtime/BlockchainRuntime';
|
|
45
45
|
import { IACTPRuntime, IMockRuntime } from './runtime/IACTPRuntime';
|
|
46
|
-
import {
|
|
47
|
-
import {
|
|
46
|
+
import { BasicAdapter } from './adapters/BasicAdapter';
|
|
47
|
+
import { StandardAdapter } from './adapters/StandardAdapter';
|
|
48
48
|
import { EASHelper, EASConfig } from './protocol/EASHelper';
|
|
49
49
|
import { getNetwork } from './config/networks';
|
|
50
50
|
|
|
@@ -324,13 +324,13 @@ export interface ACTPClientInfo {
|
|
|
324
324
|
* This class provides a unified interface to the ACTP protocol through
|
|
325
325
|
* three abstraction levels, catering to developers with different needs:
|
|
326
326
|
*
|
|
327
|
-
* **
|
|
327
|
+
* **Basic API** (`client.basic`):
|
|
328
328
|
* - Simplest possible interface
|
|
329
329
|
* - Smart defaults (24h deadline, 2-day dispute window)
|
|
330
330
|
* - User-friendly inputs (strings, no BigInt)
|
|
331
331
|
* - Perfect for: Quick prototypes, simple integrations
|
|
332
332
|
*
|
|
333
|
-
* **
|
|
333
|
+
* **Standard API** (`client.standard`):
|
|
334
334
|
* - Explicit lifecycle methods
|
|
335
335
|
* - More control over transaction flow
|
|
336
336
|
* - Still with user-friendly input parsing
|
|
@@ -352,15 +352,15 @@ export interface ACTPClientInfo {
|
|
|
352
352
|
*
|
|
353
353
|
* // Three ways to create a transaction:
|
|
354
354
|
*
|
|
355
|
-
* // 1.
|
|
356
|
-
* await client.
|
|
355
|
+
* // 1. Basic: One call does everything
|
|
356
|
+
* await client.basic.pay({ to: '0xProvider', amount: '100' });
|
|
357
357
|
*
|
|
358
|
-
* // 2.
|
|
359
|
-
* const txId = await client.
|
|
358
|
+
* // 2. Standard: Explicit steps
|
|
359
|
+
* const txId = await client.standard.createTransaction({
|
|
360
360
|
* provider: '0xProvider',
|
|
361
361
|
* amount: '100',
|
|
362
362
|
* });
|
|
363
|
-
* await client.
|
|
363
|
+
* await client.standard.linkEscrow(txId);
|
|
364
364
|
*
|
|
365
365
|
* // 3. Advanced: Full control
|
|
366
366
|
* const txId = await client.advanced.createTransaction({
|
|
@@ -374,7 +374,7 @@ export interface ACTPClientInfo {
|
|
|
374
374
|
*/
|
|
375
375
|
export class ACTPClient {
|
|
376
376
|
/**
|
|
377
|
-
*
|
|
377
|
+
* Basic-level API.
|
|
378
378
|
*
|
|
379
379
|
* Provides the simplest interface for creating and checking transactions.
|
|
380
380
|
* Ideal for developers who want to "just make it work" without deep
|
|
@@ -382,7 +382,7 @@ export class ACTPClient {
|
|
|
382
382
|
*
|
|
383
383
|
* @example
|
|
384
384
|
* ```typescript
|
|
385
|
-
* const result = await client.
|
|
385
|
+
* const result = await client.basic.pay({
|
|
386
386
|
* to: '0xProvider...',
|
|
387
387
|
* amount: '100',
|
|
388
388
|
* });
|
|
@@ -390,10 +390,10 @@ export class ACTPClient {
|
|
|
390
390
|
* console.log('State:', result.state); // 'COMMITTED'
|
|
391
391
|
* ```
|
|
392
392
|
*/
|
|
393
|
-
public readonly
|
|
393
|
+
public readonly basic: BasicAdapter;
|
|
394
394
|
|
|
395
395
|
/**
|
|
396
|
-
*
|
|
396
|
+
* Standard-level API.
|
|
397
397
|
*
|
|
398
398
|
* Provides explicit lifecycle methods for more control over
|
|
399
399
|
* the transaction flow while still offering user-friendly inputs.
|
|
@@ -401,20 +401,20 @@ export class ACTPClient {
|
|
|
401
401
|
* @example
|
|
402
402
|
* ```typescript
|
|
403
403
|
* // Create transaction (INITIATED state)
|
|
404
|
-
* const txId = await client.
|
|
404
|
+
* const txId = await client.standard.createTransaction({
|
|
405
405
|
* provider: '0xProvider...',
|
|
406
406
|
* amount: '100',
|
|
407
407
|
* deadline: '+7d',
|
|
408
408
|
* });
|
|
409
409
|
*
|
|
410
410
|
* // Link escrow (auto-transitions to COMMITTED)
|
|
411
|
-
* await client.
|
|
411
|
+
* await client.standard.linkEscrow(txId);
|
|
412
412
|
*
|
|
413
413
|
* // Transition to DELIVERED
|
|
414
|
-
* await client.
|
|
414
|
+
* await client.standard.transitionState(txId, 'DELIVERED');
|
|
415
415
|
* ```
|
|
416
416
|
*/
|
|
417
|
-
public readonly
|
|
417
|
+
public readonly standard: StandardAdapter;
|
|
418
418
|
|
|
419
419
|
/**
|
|
420
420
|
* The underlying runtime implementation.
|
|
@@ -447,8 +447,8 @@ export class ACTPClient {
|
|
|
447
447
|
this.runtime = runtime;
|
|
448
448
|
this.info = info;
|
|
449
449
|
this.easHelper = easHelper;
|
|
450
|
-
this.
|
|
451
|
-
this.
|
|
450
|
+
this.basic = new BasicAdapter(runtime, requesterAddress, easHelper);
|
|
451
|
+
this.standard = new StandardAdapter(runtime, requesterAddress, easHelper);
|
|
452
452
|
}
|
|
453
453
|
|
|
454
454
|
// ==========================================================================
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* BasicAdapter - High-level, opinionated API for simple use cases
|
|
3
3
|
*
|
|
4
4
|
* Provides the simplest possible interface for creating and checking transactions.
|
|
5
5
|
* Designed for developers who want to "just make it work" without deep protocol knowledge.
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* - User-friendly input (strings, no BigInt)
|
|
11
11
|
* - User-friendly output (formatted amounts, ISO dates)
|
|
12
12
|
*
|
|
13
|
-
* @module adapters/
|
|
13
|
+
* @module adapters/BasicAdapter
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
import { BaseAdapter, ValidationError, DEFAULT_DISPUTE_WINDOW_SECONDS } from './BaseAdapter';
|
|
@@ -21,9 +21,9 @@ import { EASHelper } from '../protocol/EASHelper';
|
|
|
21
21
|
/**
|
|
22
22
|
* Parameters for creating a simple payment.
|
|
23
23
|
*
|
|
24
|
-
* This is the most
|
|
24
|
+
* This is the most user-friendly interface - minimal required fields.
|
|
25
25
|
*/
|
|
26
|
-
export interface
|
|
26
|
+
export interface BasicPayParams {
|
|
27
27
|
/** Recipient address (provider) */
|
|
28
28
|
to: string;
|
|
29
29
|
|
|
@@ -42,7 +42,7 @@ export interface BeginnerPayParams {
|
|
|
42
42
|
*
|
|
43
43
|
* Provides user-friendly formatted data (not raw protocol types).
|
|
44
44
|
*/
|
|
45
|
-
export interface
|
|
45
|
+
export interface BasicPayResult {
|
|
46
46
|
/** Transaction ID (bytes32 hex string) */
|
|
47
47
|
txId: string;
|
|
48
48
|
|
|
@@ -63,7 +63,7 @@ export interface BeginnerPayResult {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
|
-
*
|
|
66
|
+
* BasicAdapter - High-level API for simple payment flows.
|
|
67
67
|
*
|
|
68
68
|
* This adapter provides the simplest possible interface:
|
|
69
69
|
* - `pay()` - Create and fund a transaction in one call
|
|
@@ -76,7 +76,7 @@ export interface BeginnerPayResult {
|
|
|
76
76
|
* const client = await ACTPClient.create({ mode: 'mock' });
|
|
77
77
|
*
|
|
78
78
|
* // Simple payment (all defaults)
|
|
79
|
-
* const result = await client.
|
|
79
|
+
* const result = await client.basic.pay({
|
|
80
80
|
* to: '0xProvider123',
|
|
81
81
|
* amount: '100',
|
|
82
82
|
* });
|
|
@@ -84,15 +84,15 @@ export interface BeginnerPayResult {
|
|
|
84
84
|
* console.log('Amount:', result.amount); // "100.00 USDC"
|
|
85
85
|
*
|
|
86
86
|
* // Check status
|
|
87
|
-
* const status = await client.
|
|
87
|
+
* const status = await client.basic.checkStatus(result.txId);
|
|
88
88
|
* if (status.canAccept) {
|
|
89
89
|
* console.log('Provider can accept this transaction');
|
|
90
90
|
* }
|
|
91
91
|
* ```
|
|
92
92
|
*/
|
|
93
|
-
export class
|
|
93
|
+
export class BasicAdapter extends BaseAdapter {
|
|
94
94
|
/**
|
|
95
|
-
* Creates a new
|
|
95
|
+
* Creates a new BasicAdapter instance.
|
|
96
96
|
*
|
|
97
97
|
* @param runtime - ACTP runtime implementation (MockRuntime or BlockchainRuntime)
|
|
98
98
|
* @param requesterAddress - The requester's Ethereum address
|
|
@@ -136,7 +136,7 @@ export class BeginnerAdapter extends BaseAdapter {
|
|
|
136
136
|
* });
|
|
137
137
|
* ```
|
|
138
138
|
*/
|
|
139
|
-
async pay(params:
|
|
139
|
+
async pay(params: BasicPayParams): Promise<BasicPayResult> {
|
|
140
140
|
// Validate and parse inputs
|
|
141
141
|
const provider = this.validateAddress(params.to, 'to');
|
|
142
142
|
const amount = this.parseAmount(params.amount);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* StandardAdapter - Balanced API for developers with some protocol knowledge
|
|
3
3
|
*
|
|
4
|
-
* Provides more control than
|
|
4
|
+
* Provides more control than BasicAdapter while still offering convenience:
|
|
5
5
|
* - Explicit transaction lifecycle methods
|
|
6
6
|
* - Direct escrow operations
|
|
7
7
|
* - State transition control
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* Use this adapter when you need fine-grained control but still want
|
|
10
10
|
* user-friendly input parsing and validation.
|
|
11
11
|
*
|
|
12
|
-
* @module adapters/
|
|
12
|
+
* @module adapters/StandardAdapter
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import { BaseAdapter, ValidationError, DEFAULT_DISPUTE_WINDOW_SECONDS } from './BaseAdapter';
|
|
@@ -18,11 +18,11 @@ import { MockTransaction, TransactionState } from '../runtime/types/MockState';
|
|
|
18
18
|
import { EASHelper } from '../protocol/EASHelper';
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
* Parameters for creating a transaction (
|
|
21
|
+
* Parameters for creating a transaction (standard level).
|
|
22
22
|
*
|
|
23
|
-
* More explicit than
|
|
23
|
+
* More explicit than BasicPayParams but still with smart defaults.
|
|
24
24
|
*/
|
|
25
|
-
export interface
|
|
25
|
+
export interface StandardTransactionParams {
|
|
26
26
|
/** Provider's Ethereum address */
|
|
27
27
|
provider: string;
|
|
28
28
|
|
|
@@ -40,7 +40,7 @@ export interface IntermediateTransactionParams {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
|
-
*
|
|
43
|
+
* StandardAdapter - Balanced API for transaction lifecycle control.
|
|
44
44
|
*
|
|
45
45
|
* Provides explicit methods for each stage of the ACTP lifecycle:
|
|
46
46
|
* - `createTransaction()` - Create transaction without escrow
|
|
@@ -55,25 +55,25 @@ export interface IntermediateTransactionParams {
|
|
|
55
55
|
* const client = await ACTPClient.create({ mode: 'mock' });
|
|
56
56
|
*
|
|
57
57
|
* // Create transaction (INITIATED state)
|
|
58
|
-
* const txId = await client.
|
|
58
|
+
* const txId = await client.standard.createTransaction({
|
|
59
59
|
* provider: '0xProvider123',
|
|
60
60
|
* amount: '100',
|
|
61
61
|
* deadline: '+7d',
|
|
62
62
|
* });
|
|
63
63
|
*
|
|
64
64
|
* // Link escrow (auto-transitions to COMMITTED)
|
|
65
|
-
* await client.
|
|
65
|
+
* await client.standard.linkEscrow(txId, '100');
|
|
66
66
|
*
|
|
67
67
|
* // Provider delivers
|
|
68
|
-
* await client.
|
|
68
|
+
* await client.standard.transitionState(txId, 'DELIVERED');
|
|
69
69
|
*
|
|
70
70
|
* // Release funds after dispute window
|
|
71
|
-
* await client.
|
|
71
|
+
* await client.standard.releaseEscrow(escrowId);
|
|
72
72
|
* ```
|
|
73
73
|
*/
|
|
74
|
-
export class
|
|
74
|
+
export class StandardAdapter extends BaseAdapter {
|
|
75
75
|
/**
|
|
76
|
-
* Creates a new
|
|
76
|
+
* Creates a new StandardAdapter instance.
|
|
77
77
|
*
|
|
78
78
|
* @param runtime - ACTP runtime implementation (MockRuntime or BlockchainRuntime)
|
|
79
79
|
* @param requesterAddress - The requester's Ethereum address
|
|
@@ -90,7 +90,7 @@ export class IntermediateAdapter extends BaseAdapter {
|
|
|
90
90
|
/**
|
|
91
91
|
* Create a transaction (INITIATED state, no escrow yet).
|
|
92
92
|
*
|
|
93
|
-
* Unlike `
|
|
93
|
+
* Unlike `basic.pay()`, this only creates the transaction
|
|
94
94
|
* without linking escrow. You must call `linkEscrow()` separately.
|
|
95
95
|
*
|
|
96
96
|
* @param params - Transaction parameters
|
|
@@ -106,7 +106,7 @@ export class IntermediateAdapter extends BaseAdapter {
|
|
|
106
106
|
* });
|
|
107
107
|
* ```
|
|
108
108
|
*/
|
|
109
|
-
async createTransaction(params:
|
|
109
|
+
async createTransaction(params: StandardTransactionParams): Promise<string> {
|
|
110
110
|
const provider = this.validateAddress(params.provider, 'provider');
|
|
111
111
|
const amount = this.parseAmount(params.amount);
|
|
112
112
|
const currentTime = this.runtime.time.now();
|
package/src/adapters/index.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This module exports all adapter classes and types for the Three-Level API:
|
|
5
5
|
* - BaseAdapter: Abstract base with shared utilities
|
|
6
|
-
* -
|
|
7
|
-
* -
|
|
6
|
+
* - BasicAdapter: High-level, opinionated API
|
|
7
|
+
* - StandardAdapter: Balanced control API
|
|
8
8
|
*
|
|
9
9
|
* @module adapters
|
|
10
10
|
*/
|
|
@@ -18,8 +18,8 @@ export {
|
|
|
18
18
|
MAX_DEADLINE_HOURS,
|
|
19
19
|
MAX_DEADLINE_DAYS,
|
|
20
20
|
} from './BaseAdapter';
|
|
21
|
-
export {
|
|
22
|
-
export {
|
|
21
|
+
export { BasicAdapter, BasicPayParams, BasicPayResult } from './BasicAdapter';
|
|
22
|
+
export { StandardAdapter, StandardTransactionParams } from './StandardAdapter';
|
|
23
23
|
|
|
24
24
|
// Re-export runtime interface for convenience
|
|
25
25
|
export { IACTPRuntime, CreateTransactionParams } from '../runtime/IACTPRuntime';
|
package/src/cli/commands/pay.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Pay Command - One-liner payment command (
|
|
2
|
+
* Pay Command - One-liner payment command (basic API)
|
|
3
3
|
*
|
|
4
4
|
* The simplest way to create a payment transaction.
|
|
5
5
|
* Creates transaction, links escrow, and returns immediately.
|
|
@@ -76,7 +76,7 @@ async function runPay(
|
|
|
76
76
|
const disputeWindow = parseInt(options.disputeWindow, 10);
|
|
77
77
|
|
|
78
78
|
// Create payment
|
|
79
|
-
const result = await client.
|
|
79
|
+
const result = await client.basic.pay({
|
|
80
80
|
to,
|
|
81
81
|
amount,
|
|
82
82
|
deadline,
|
package/src/cli/commands/tx.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Transaction Commands - tx subcommand group
|
|
3
3
|
*
|
|
4
4
|
* Commands for managing ACTP transactions:
|
|
5
|
-
* - tx create: Create a new transaction (
|
|
5
|
+
* - tx create: Create a new transaction (standard API)
|
|
6
6
|
* - tx status: Check transaction status
|
|
7
7
|
* - tx list: List all transactions
|
|
8
8
|
* - tx deliver: Mark transaction as delivered
|
|
@@ -66,7 +66,7 @@ function createTxCreateCommand(): Command {
|
|
|
66
66
|
const disputeWindow = parseInt(options.disputeWindow, 10);
|
|
67
67
|
|
|
68
68
|
// Create transaction
|
|
69
|
-
const txId = await client.
|
|
69
|
+
const txId = await client.standard.createTransaction({
|
|
70
70
|
provider,
|
|
71
71
|
amount,
|
|
72
72
|
deadline,
|
|
@@ -77,10 +77,10 @@ function createTxCreateCommand(): Command {
|
|
|
77
77
|
// Optionally fund
|
|
78
78
|
let escrowId: string | undefined;
|
|
79
79
|
if (options.fund) {
|
|
80
|
-
escrowId = await client.
|
|
80
|
+
escrowId = await client.standard.linkEscrow(txId);
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
const tx = await client.
|
|
83
|
+
const tx = await client.standard.getTransaction(txId);
|
|
84
84
|
if (!tx) throw new Error('Transaction not found after creation');
|
|
85
85
|
|
|
86
86
|
output.result(
|
|
@@ -134,13 +134,13 @@ function createTxStatusCommand(): Command {
|
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
const client = await createClient();
|
|
137
|
-
const tx = await client.
|
|
137
|
+
const tx = await client.standard.getTransaction(txId);
|
|
138
138
|
|
|
139
139
|
if (!tx) {
|
|
140
140
|
throw new Error(`Transaction not found: ${txId}`);
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
const status = await client.
|
|
143
|
+
const status = await client.basic.checkStatus(txId);
|
|
144
144
|
|
|
145
145
|
if (options.quiet) {
|
|
146
146
|
output.raw(tx.state);
|
|
@@ -289,9 +289,9 @@ function createTxDeliverCommand(): Command {
|
|
|
289
289
|
const client = await createClient();
|
|
290
290
|
|
|
291
291
|
// Transition to DELIVERED
|
|
292
|
-
await client.
|
|
292
|
+
await client.standard.transitionState(txId, 'DELIVERED' as TransactionState);
|
|
293
293
|
|
|
294
|
-
const tx = await client.
|
|
294
|
+
const tx = await client.standard.getTransaction(txId);
|
|
295
295
|
if (!tx) throw new Error('Transaction not found');
|
|
296
296
|
|
|
297
297
|
output.result(
|
|
@@ -345,15 +345,15 @@ function createTxSettleCommand(): Command {
|
|
|
345
345
|
const client = await createClient();
|
|
346
346
|
|
|
347
347
|
// Get transaction to find escrow
|
|
348
|
-
const tx = await client.
|
|
348
|
+
const tx = await client.standard.getTransaction(txId);
|
|
349
349
|
if (!tx) throw new Error(`Transaction not found: ${txId}`);
|
|
350
350
|
if (!tx.escrowId) throw new Error('Transaction has no linked escrow');
|
|
351
351
|
|
|
352
352
|
// Release escrow
|
|
353
|
-
await client.
|
|
353
|
+
await client.standard.releaseEscrow(tx.escrowId);
|
|
354
354
|
|
|
355
355
|
// Get updated transaction
|
|
356
|
-
const updatedTx = await client.
|
|
356
|
+
const updatedTx = await client.standard.getTransaction(txId);
|
|
357
357
|
if (!updatedTx) throw new Error('Transaction not found');
|
|
358
358
|
|
|
359
359
|
output.result(
|
|
@@ -402,9 +402,9 @@ function createTxCancelCommand(): Command {
|
|
|
402
402
|
const client = await createClient();
|
|
403
403
|
|
|
404
404
|
// Transition to CANCELLED
|
|
405
|
-
await client.
|
|
405
|
+
await client.standard.transitionState(txId, 'CANCELLED' as TransactionState);
|
|
406
406
|
|
|
407
|
-
const tx = await client.
|
|
407
|
+
const tx = await client.standard.getTransaction(txId);
|
|
408
408
|
if (!tx) throw new Error('Transaction not found');
|
|
409
409
|
|
|
410
410
|
output.result(
|
|
@@ -85,7 +85,7 @@ async function runWatch(
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
// Get initial state
|
|
88
|
-
const tx = await client.
|
|
88
|
+
const tx = await client.standard.getTransaction(txId);
|
|
89
89
|
if (!tx) {
|
|
90
90
|
throw new Error(`Transaction not found: ${txId}`);
|
|
91
91
|
}
|
|
@@ -123,7 +123,7 @@ async function runWatch(
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
try {
|
|
126
|
-
const updatedTx = await client.
|
|
126
|
+
const updatedTx = await client.standard.getTransaction(txId);
|
|
127
127
|
if (!updatedTx) {
|
|
128
128
|
output.warning('Transaction no longer exists');
|
|
129
129
|
process.exit(ExitCode.ERROR);
|
package/src/index.ts
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* await client.mintTokens(client.getAddress(), '10000000000');
|
|
21
21
|
*
|
|
22
22
|
* // Create a payment
|
|
23
|
-
* const result = await client.
|
|
23
|
+
* const result = await client.basic.pay({
|
|
24
24
|
* to: '0xProvider...',
|
|
25
25
|
* amount: '100',
|
|
26
26
|
* });
|
|
@@ -54,15 +54,15 @@ export {
|
|
|
54
54
|
} from './adapters/BaseAdapter';
|
|
55
55
|
|
|
56
56
|
export {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
} from './adapters/
|
|
57
|
+
BasicAdapter,
|
|
58
|
+
BasicPayParams,
|
|
59
|
+
BasicPayResult,
|
|
60
|
+
} from './adapters/BasicAdapter';
|
|
61
61
|
|
|
62
62
|
export {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
} from './adapters/
|
|
63
|
+
StandardAdapter,
|
|
64
|
+
StandardTransactionParams,
|
|
65
|
+
} from './adapters/StandardAdapter';
|
|
66
66
|
|
|
67
67
|
// =============================================================================
|
|
68
68
|
// Runtime Layer - Protocol Implementation
|
|
@@ -455,13 +455,13 @@ export class ACTPKernel {
|
|
|
455
455
|
*
|
|
456
456
|
* **REQUIRED: Use secure wrapper methods instead:**
|
|
457
457
|
*
|
|
458
|
-
* 1. **
|
|
458
|
+
* 1. **BasicAdapter.completePayment()** (recommended for most users)
|
|
459
459
|
* - Automatically verifies attestation before release
|
|
460
460
|
* - Validates attestation belongs to this transaction
|
|
461
461
|
* - Checks attestation hasn't been used before
|
|
462
462
|
* - Handles all state transitions
|
|
463
463
|
*
|
|
464
|
-
* 2. **
|
|
464
|
+
* 2. **StandardAdapter.releaseEscrow()** (for more control)
|
|
465
465
|
* - Explicitly requires attestation verification
|
|
466
466
|
* - Throws error if attestation invalid or missing
|
|
467
467
|
* - Allows custom verification logic
|
|
@@ -493,15 +493,15 @@ export class ACTPKernel {
|
|
|
493
493
|
*
|
|
494
494
|
* **For testnet/mainnet deployments:**
|
|
495
495
|
* - MUST configure easConfig in ACTPClient
|
|
496
|
-
* - MUST use wrapper methods (
|
|
496
|
+
* - MUST use wrapper methods (Basic/Standard adapters)
|
|
497
497
|
* - NEVER call this method directly unless attestation verified
|
|
498
498
|
*
|
|
499
499
|
* @param txId - Transaction ID to settle
|
|
500
500
|
* @throws {ValidationError} If txId is invalid
|
|
501
501
|
* @throws {TransactionRevertedError} If contract reverts
|
|
502
502
|
*
|
|
503
|
-
* @see {@link
|
|
504
|
-
* @see {@link
|
|
503
|
+
* @see {@link BasicAdapter.completePayment} Recommended method with built-in verification
|
|
504
|
+
* @see {@link StandardAdapter.releaseEscrow} Explicit verification method
|
|
505
505
|
* @see {@link EASHelper.verifyDeliveryAttestation} Manual verification helper
|
|
506
506
|
*/
|
|
507
507
|
async releaseEscrow(txId: string): Promise<void> {
|
|
@@ -84,7 +84,7 @@ export interface BlockchainRuntimeConfig {
|
|
|
84
84
|
* });
|
|
85
85
|
*
|
|
86
86
|
* // Now use with adapters
|
|
87
|
-
* const adapter = new
|
|
87
|
+
* const adapter = new BasicAdapter(runtime, requesterAddress);
|
|
88
88
|
* await adapter.createJob({...});
|
|
89
89
|
* ```
|
|
90
90
|
*/
|
|
@@ -49,7 +49,7 @@ export interface CreateTransactionParams {
|
|
|
49
49
|
* });
|
|
50
50
|
*
|
|
51
51
|
* // Adapters work with either implementation
|
|
52
|
-
* const adapter = new
|
|
52
|
+
* const adapter = new BasicAdapter(runtime, requesterAddress);
|
|
53
53
|
* ```
|
|
54
54
|
*/
|
|
55
55
|
export interface IACTPRuntime {
|
|
@@ -465,7 +465,7 @@ const DEFAULT_RECOVERY: ErrorRecoveryInfo = {
|
|
|
465
465
|
* @example
|
|
466
466
|
* ```typescript
|
|
467
467
|
* try {
|
|
468
|
-
* await client.
|
|
468
|
+
* await client.basic.pay({ to: provider, amount: '100' });
|
|
469
469
|
* } catch (error) {
|
|
470
470
|
* const recovery = ErrorRecoveryGuide.analyze(error);
|
|
471
471
|
* console.log('Category:', recovery.category);
|
|
@@ -622,7 +622,7 @@ ${recovery.securityNotes.map((n) => ` ! ${n}`).join('\n')}`;
|
|
|
622
622
|
* @example
|
|
623
623
|
* ```typescript
|
|
624
624
|
* const result = await withRecoveryGuidance(
|
|
625
|
-
* () => client.
|
|
625
|
+
* () => client.basic.pay({ to: provider, amount: '100' }),
|
|
626
626
|
* { logGuidance: true, autoRetry: true }
|
|
627
627
|
* );
|
|
628
628
|
* ```
|