@agirails/sdk 3.3.0 → 3.5.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/dist/api/agirailsApp.d.ts +21 -1
- package/dist/api/agirailsApp.d.ts.map +1 -1
- package/dist/api/agirailsApp.js.map +1 -1
- package/dist/builders/CounterAcceptBuilder.d.ts +96 -0
- package/dist/builders/CounterAcceptBuilder.d.ts.map +1 -0
- package/dist/builders/CounterAcceptBuilder.js +226 -0
- package/dist/builders/CounterAcceptBuilder.js.map +1 -0
- package/dist/builders/CounterOfferBuilder.d.ts +143 -0
- package/dist/builders/CounterOfferBuilder.d.ts.map +1 -0
- package/dist/builders/CounterOfferBuilder.js +329 -0
- package/dist/builders/CounterOfferBuilder.js.map +1 -0
- package/dist/builders/QuoteBuilder.d.ts +9 -3
- package/dist/builders/QuoteBuilder.d.ts.map +1 -1
- package/dist/builders/QuoteBuilder.js +22 -6
- package/dist/builders/QuoteBuilder.js.map +1 -1
- package/dist/builders/index.d.ts +2 -0
- package/dist/builders/index.d.ts.map +1 -1
- package/dist/builders/index.js +7 -1
- package/dist/builders/index.js.map +1 -1
- package/dist/cli/agirails.js +22 -2
- package/dist/cli/agirails.js.map +1 -1
- package/dist/cli/commands/agent.d.ts +22 -0
- package/dist/cli/commands/agent.d.ts.map +1 -0
- package/dist/cli/commands/agent.js +209 -0
- package/dist/cli/commands/agent.js.map +1 -0
- package/dist/cli/commands/health.js +21 -5
- package/dist/cli/commands/health.js.map +1 -1
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +25 -5
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/publish.d.ts +34 -0
- package/dist/cli/commands/publish.d.ts.map +1 -1
- package/dist/cli/commands/publish.js +256 -80
- package/dist/cli/commands/publish.js.map +1 -1
- package/dist/cli/commands/repair.d.ts +23 -0
- package/dist/cli/commands/repair.d.ts.map +1 -0
- package/dist/cli/commands/repair.js +210 -0
- package/dist/cli/commands/repair.js.map +1 -0
- package/dist/cli/commands/serve.d.ts +38 -0
- package/dist/cli/commands/serve.d.ts.map +1 -0
- package/dist/cli/commands/serve.js +308 -0
- package/dist/cli/commands/serve.js.map +1 -0
- package/dist/cli/commands/test.js +2 -2
- package/dist/cli/commands/test.js.map +1 -1
- package/dist/cli/index.js +10 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/config/agirailsmdV4.d.ts +46 -1
- package/dist/config/agirailsmdV4.d.ts.map +1 -1
- package/dist/config/agirailsmdV4.js +65 -8
- package/dist/config/agirailsmdV4.js.map +1 -1
- package/dist/config/defaults.d.ts +10 -0
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +10 -0
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/networks.d.ts.map +1 -1
- package/dist/config/networks.js +7 -1
- package/dist/config/networks.js.map +1 -1
- package/dist/config/publishPipeline.d.ts +23 -1
- package/dist/config/publishPipeline.d.ts.map +1 -1
- package/dist/config/publishPipeline.js +70 -15
- package/dist/config/publishPipeline.js.map +1 -1
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +39 -3
- package/dist/index.js.map +1 -1
- package/dist/level1/Agent.d.ts +27 -0
- package/dist/level1/Agent.d.ts.map +1 -1
- package/dist/level1/Agent.js +77 -6
- package/dist/level1/Agent.js.map +1 -1
- package/dist/negotiation/BuyerOrchestrator.d.ts +115 -1
- package/dist/negotiation/BuyerOrchestrator.d.ts.map +1 -1
- package/dist/negotiation/BuyerOrchestrator.js +530 -4
- package/dist/negotiation/BuyerOrchestrator.js.map +1 -1
- package/dist/negotiation/DecisionEngine.d.ts +69 -1
- package/dist/negotiation/DecisionEngine.d.ts.map +1 -1
- package/dist/negotiation/DecisionEngine.js +140 -1
- package/dist/negotiation/DecisionEngine.js.map +1 -1
- package/dist/negotiation/MockChannel.d.ts +63 -0
- package/dist/negotiation/MockChannel.d.ts.map +1 -0
- package/dist/negotiation/MockChannel.js +175 -0
- package/dist/negotiation/MockChannel.js.map +1 -0
- package/dist/negotiation/NegotiationChannel.d.ts +142 -0
- package/dist/negotiation/NegotiationChannel.d.ts.map +1 -0
- package/dist/negotiation/NegotiationChannel.js +59 -0
- package/dist/negotiation/NegotiationChannel.js.map +1 -0
- package/dist/negotiation/PolicyEngine.d.ts +32 -0
- package/dist/negotiation/PolicyEngine.d.ts.map +1 -1
- package/dist/negotiation/PolicyEngine.js.map +1 -1
- package/dist/negotiation/ProviderOrchestrator.d.ts +158 -0
- package/dist/negotiation/ProviderOrchestrator.d.ts.map +1 -0
- package/dist/negotiation/ProviderOrchestrator.js +286 -0
- package/dist/negotiation/ProviderOrchestrator.js.map +1 -0
- package/dist/negotiation/ProviderPolicy.d.ts +188 -0
- package/dist/negotiation/ProviderPolicy.d.ts.map +1 -0
- package/dist/negotiation/ProviderPolicy.js +259 -0
- package/dist/negotiation/ProviderPolicy.js.map +1 -0
- package/dist/negotiation/RelayChannel.d.ts +59 -0
- package/dist/negotiation/RelayChannel.d.ts.map +1 -0
- package/dist/negotiation/RelayChannel.js +208 -0
- package/dist/negotiation/RelayChannel.js.map +1 -0
- package/dist/negotiation/index.d.ts +8 -1
- package/dist/negotiation/index.d.ts.map +1 -1
- package/dist/negotiation/index.js +8 -1
- package/dist/negotiation/index.js.map +1 -1
- package/dist/negotiation/verifyQuoteOnChain.d.ts +58 -0
- package/dist/negotiation/verifyQuoteOnChain.d.ts.map +1 -0
- package/dist/negotiation/verifyQuoteOnChain.js +83 -0
- package/dist/negotiation/verifyQuoteOnChain.js.map +1 -0
- package/dist/protocol/ACTPKernel.d.ts.map +1 -1
- package/dist/protocol/ACTPKernel.js +51 -1
- package/dist/protocol/ACTPKernel.js.map +1 -1
- package/dist/runtime/BlockchainRuntime.d.ts +13 -0
- package/dist/runtime/BlockchainRuntime.d.ts.map +1 -1
- package/dist/runtime/BlockchainRuntime.js +33 -2
- package/dist/runtime/BlockchainRuntime.js.map +1 -1
- package/dist/runtime/IACTPRuntime.d.ts +35 -0
- package/dist/runtime/IACTPRuntime.d.ts.map +1 -1
- package/dist/runtime/MockRuntime.d.ts +11 -0
- package/dist/runtime/MockRuntime.d.ts.map +1 -1
- package/dist/runtime/MockRuntime.js +39 -0
- package/dist/runtime/MockRuntime.js.map +1 -1
- package/dist/runtime/types/MockState.d.ts +10 -0
- package/dist/runtime/types/MockState.d.ts.map +1 -1
- package/dist/runtime/types/MockState.js.map +1 -1
- package/dist/transport/QuoteChannel.d.ts +201 -0
- package/dist/transport/QuoteChannel.d.ts.map +1 -0
- package/dist/transport/QuoteChannel.js +358 -0
- package/dist/transport/QuoteChannel.js.map +1 -0
- package/dist/types/adapter.d.ts +24 -24
- package/package.json +16 -1
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Repair Command — reshape an already-on-chain agent without redeploying.
|
|
4
|
+
*
|
|
5
|
+
* Use cases:
|
|
6
|
+
* - Drop a phantom service registered by an earlier misshape (e.g. a
|
|
7
|
+
* pay-only agent that was registered as `code-review` provider before
|
|
8
|
+
* the intent-aware publish flow existed).
|
|
9
|
+
* - Update the on-chain endpoint to a real HTTPS URL after wiring a
|
|
10
|
+
* webhook for x402 / off-protocol intake.
|
|
11
|
+
* - Toggle isActive / listed flags to hide from public discovery.
|
|
12
|
+
*
|
|
13
|
+
* Wraps existing AgentRegistry SDK methods; this command is the user-
|
|
14
|
+
* facing surface that explains what's about to change and asks for
|
|
15
|
+
* confirmation before sending the tx.
|
|
16
|
+
*
|
|
17
|
+
* Deliberately does NOT expose `deregisterAgent` — destructive ops that
|
|
18
|
+
* forfeit reputation belong in a separate command with bigger guards.
|
|
19
|
+
*
|
|
20
|
+
* @module cli/commands/repair
|
|
21
|
+
*/
|
|
22
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
23
|
+
if (k2 === undefined) k2 = k;
|
|
24
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
25
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
26
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
27
|
+
}
|
|
28
|
+
Object.defineProperty(o, k2, desc);
|
|
29
|
+
}) : (function(o, m, k, k2) {
|
|
30
|
+
if (k2 === undefined) k2 = k;
|
|
31
|
+
o[k2] = m[k];
|
|
32
|
+
}));
|
|
33
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
34
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
35
|
+
}) : function(o, v) {
|
|
36
|
+
o["default"] = v;
|
|
37
|
+
});
|
|
38
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
39
|
+
if (mod && mod.__esModule) return mod;
|
|
40
|
+
var result = {};
|
|
41
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
42
|
+
__setModuleDefault(result, mod);
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.createRepairCommand = void 0;
|
|
47
|
+
const commander_1 = require("commander");
|
|
48
|
+
const ethers_1 = require("ethers");
|
|
49
|
+
const readline = __importStar(require("readline"));
|
|
50
|
+
const output_1 = require("../utils/output");
|
|
51
|
+
const client_1 = require("../utils/client");
|
|
52
|
+
const config_1 = require("../utils/config");
|
|
53
|
+
const networks_1 = require("../../config/networks");
|
|
54
|
+
const AgentRegistry_1 = require("../../protocol/AgentRegistry");
|
|
55
|
+
const AgentRegistryClient_1 = require("../../registry/AgentRegistryClient");
|
|
56
|
+
// ============================================================================
|
|
57
|
+
// Command
|
|
58
|
+
// ============================================================================
|
|
59
|
+
function createRepairCommand() {
|
|
60
|
+
const cmd = new commander_1.Command('repair')
|
|
61
|
+
.description('Reshape on-chain agent (drop phantom services, update endpoint, toggle active/listed)')
|
|
62
|
+
.option('--remove-service <name>', 'Remove a service type from your on-chain provider role')
|
|
63
|
+
.option('--endpoint <url>', 'Update on-chain endpoint URL (must be HTTPS)')
|
|
64
|
+
.option('--active <bool>', 'Set on-chain isActive (true|false)')
|
|
65
|
+
.option('--listed <bool>', 'Set on-chain listed flag (true|false)')
|
|
66
|
+
.option('--network <name>', 'Network to repair on', 'base-sepolia')
|
|
67
|
+
.option('-y, --yes', 'Skip confirmation prompts (required for non-TTY)')
|
|
68
|
+
.option('--json', 'Output as JSON')
|
|
69
|
+
.action(async (options) => {
|
|
70
|
+
const output = new output_1.Output(options.json ? 'json' : 'human');
|
|
71
|
+
try {
|
|
72
|
+
await runRepair(options, output);
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
const structured = (0, client_1.mapError)(error);
|
|
76
|
+
output.errorResult({
|
|
77
|
+
code: structured.code,
|
|
78
|
+
message: structured.message,
|
|
79
|
+
details: structured.details,
|
|
80
|
+
});
|
|
81
|
+
process.exit(output_1.ExitCode.ERROR);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
return cmd;
|
|
85
|
+
}
|
|
86
|
+
exports.createRepairCommand = createRepairCommand;
|
|
87
|
+
async function runRepair(options, output) {
|
|
88
|
+
// At least one repair action must be specified.
|
|
89
|
+
const actions = [
|
|
90
|
+
options.removeService && `remove-service ${options.removeService}`,
|
|
91
|
+
options.endpoint && `endpoint → ${options.endpoint}`,
|
|
92
|
+
options.active !== undefined && `active → ${options.active}`,
|
|
93
|
+
options.listed !== undefined && `listed → ${options.listed}`,
|
|
94
|
+
].filter(Boolean);
|
|
95
|
+
if (actions.length === 0) {
|
|
96
|
+
throw new Error('No repair action specified. Use one of:\n' +
|
|
97
|
+
' --remove-service <name>\n' +
|
|
98
|
+
' --endpoint <url>\n' +
|
|
99
|
+
' --active <true|false>\n' +
|
|
100
|
+
' --listed <true|false>');
|
|
101
|
+
}
|
|
102
|
+
// Validate inputs early — fail before touching the network.
|
|
103
|
+
if (options.endpoint !== undefined && !options.endpoint.startsWith('https://')) {
|
|
104
|
+
throw new Error(`--endpoint must be HTTPS (got: ${options.endpoint})`);
|
|
105
|
+
}
|
|
106
|
+
const activeBool = options.active !== undefined ? parseBool(options.active, '--active') : undefined;
|
|
107
|
+
const listedBool = options.listed !== undefined ? parseBool(options.listed, '--listed') : undefined;
|
|
108
|
+
// Load signer.
|
|
109
|
+
const config = (0, config_1.loadConfig)();
|
|
110
|
+
const { resolvePrivateKey } = await Promise.resolve().then(() => __importStar(require('../../wallet/keystore')));
|
|
111
|
+
const network = options.network;
|
|
112
|
+
const tier = network.includes('mainnet') ? 'mainnet' : network.includes('sepolia') ? 'testnet' : 'mock';
|
|
113
|
+
const privateKey = await resolvePrivateKey(process.cwd(), { network: tier });
|
|
114
|
+
if (!privateKey) {
|
|
115
|
+
throw new Error('No wallet found. Set ACTP_KEYSTORE_BASE64 or run `actp init` first.');
|
|
116
|
+
}
|
|
117
|
+
const networkConfig = (0, networks_1.getNetwork)(network);
|
|
118
|
+
if (!networkConfig.contracts.agentRegistry) {
|
|
119
|
+
throw new Error(`AgentRegistry not configured for network: ${network}`);
|
|
120
|
+
}
|
|
121
|
+
const provider = new ethers_1.ethers.JsonRpcProvider(networkConfig.rpcUrl);
|
|
122
|
+
const signer = new ethers_1.ethers.Wallet(privateKey, provider);
|
|
123
|
+
const signerAddress = await signer.getAddress();
|
|
124
|
+
void config;
|
|
125
|
+
// Confirm before sending.
|
|
126
|
+
output.info(`About to repair on-chain agent for wallet: ${signerAddress}`);
|
|
127
|
+
output.print(' Network: ' + network);
|
|
128
|
+
output.print(' Actions:');
|
|
129
|
+
for (const a of actions)
|
|
130
|
+
output.print(` - ${a}`);
|
|
131
|
+
const confirmed = await confirm(options, output);
|
|
132
|
+
if (!confirmed) {
|
|
133
|
+
output.info('Cancelled — no on-chain transactions sent.');
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const registry = new AgentRegistry_1.AgentRegistry(networkConfig.contracts.agentRegistry, signer, networkConfig.gasSettings);
|
|
137
|
+
const txHashes = [];
|
|
138
|
+
// Sequential execution — each call is its own tx; if one fails the
|
|
139
|
+
// earlier ones already landed and the user can retry the rest.
|
|
140
|
+
if (options.removeService) {
|
|
141
|
+
const hash = ethers_1.ethers.keccak256(ethers_1.ethers.toUtf8Bytes(options.removeService));
|
|
142
|
+
output.print('');
|
|
143
|
+
output.print(`Removing service "${options.removeService}" (hash ${hash.slice(0, 10)}...)`);
|
|
144
|
+
const txHash = await registry.removeServiceType(hash);
|
|
145
|
+
txHashes.push({ action: `remove-service:${options.removeService}`, txHash });
|
|
146
|
+
output.success(`Removed. tx: ${txHash}`);
|
|
147
|
+
}
|
|
148
|
+
if (options.endpoint !== undefined) {
|
|
149
|
+
output.print('');
|
|
150
|
+
output.print(`Updating endpoint → ${options.endpoint}`);
|
|
151
|
+
const txHash = await registry.updateEndpoint(options.endpoint);
|
|
152
|
+
txHashes.push({ action: `update-endpoint`, txHash });
|
|
153
|
+
output.success(`Updated. tx: ${txHash}`);
|
|
154
|
+
}
|
|
155
|
+
if (activeBool !== undefined) {
|
|
156
|
+
output.print('');
|
|
157
|
+
output.print(`Setting active → ${activeBool}`);
|
|
158
|
+
const txHash = await registry.setActiveStatus(activeBool);
|
|
159
|
+
txHashes.push({ action: `set-active:${activeBool}`, txHash });
|
|
160
|
+
output.success(`Set. tx: ${txHash}`);
|
|
161
|
+
}
|
|
162
|
+
if (listedBool !== undefined) {
|
|
163
|
+
// setListed lives on AgentRegistryClient (the v2 listing surface),
|
|
164
|
+
// not on the legacy AgentRegistry wrapper used for the other repair
|
|
165
|
+
// ops. Cheap to instantiate; both share the same contract address.
|
|
166
|
+
const listingClient = new AgentRegistryClient_1.AgentRegistryClient(networkConfig.contracts.agentRegistry, signer, networkConfig.gasSettings);
|
|
167
|
+
output.print('');
|
|
168
|
+
output.print(`Setting listed → ${listedBool}`);
|
|
169
|
+
const txHash = await listingClient.setListed(listedBool);
|
|
170
|
+
txHashes.push({ action: `set-listed:${listedBool}`, txHash });
|
|
171
|
+
output.success(`Set. tx: ${txHash}`);
|
|
172
|
+
}
|
|
173
|
+
output.print('');
|
|
174
|
+
output.success(`Repair complete (${txHashes.length} tx).`);
|
|
175
|
+
if (output.mode === 'json') {
|
|
176
|
+
output.result({
|
|
177
|
+
wallet: signerAddress,
|
|
178
|
+
network,
|
|
179
|
+
txHashes,
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
// ============================================================================
|
|
184
|
+
// Helpers
|
|
185
|
+
// ============================================================================
|
|
186
|
+
function parseBool(value, flag) {
|
|
187
|
+
const v = value.toLowerCase().trim();
|
|
188
|
+
if (v === 'true' || v === '1' || v === 'yes' || v === 'y')
|
|
189
|
+
return true;
|
|
190
|
+
if (v === 'false' || v === '0' || v === 'no' || v === 'n')
|
|
191
|
+
return false;
|
|
192
|
+
throw new Error(`${flag} must be true|false (got: ${value})`);
|
|
193
|
+
}
|
|
194
|
+
async function confirm(options, output) {
|
|
195
|
+
if (options.yes)
|
|
196
|
+
return true;
|
|
197
|
+
if (!process.stdin.isTTY) {
|
|
198
|
+
throw new Error('Non-TTY environment requires explicit confirmation. Re-run with --yes to acknowledge.');
|
|
199
|
+
}
|
|
200
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
201
|
+
const answer = await new Promise((resolve) => {
|
|
202
|
+
rl.question(output_1.fmt.cyan('? ') + 'Send these on-chain transactions? [y/N] ', (a) => {
|
|
203
|
+
rl.close();
|
|
204
|
+
resolve(a.trim().toLowerCase());
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
void output;
|
|
208
|
+
return answer === 'y' || answer === 'yes';
|
|
209
|
+
}
|
|
210
|
+
//# sourceMappingURL=repair.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repair.js","sourceRoot":"","sources":["../../../src/cli/commands/repair.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;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AAI,CAAC,IAAI,CAAC,GAAG,0CAA0C,EAAE,CAAC,CAAC,EAAE,EAAE;YAC7E,EAAE,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,KAAK,MAAM,CAAC;IACZ,OAAO,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,KAAK,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `actp serve` — long-running provider daemon.
|
|
3
|
+
*
|
|
4
|
+
* Loads a ProviderPolicy JSON, constructs a ProviderOrchestrator, opens
|
|
5
|
+
* an HTTP server on the configured port that exposes the AIP-2.1 quote
|
|
6
|
+
* channel surface (`POST /quote-channel/{chainId}/{txId}` per §8.2),
|
|
7
|
+
* and routes incoming buyer counter-offers through
|
|
8
|
+
* orchestrator.evaluateCounter().
|
|
9
|
+
*
|
|
10
|
+
* Scope (v1):
|
|
11
|
+
* - accept + verify incoming counter-offers via QuoteChannelHandler
|
|
12
|
+
* - log the policy verdict (accept / reject) per round
|
|
13
|
+
* - emit a one-line health response on `GET /`
|
|
14
|
+
*
|
|
15
|
+
* Out of scope for v1 (Phase 5):
|
|
16
|
+
* - on-chain event listening (no automatic submitQuote on incoming
|
|
17
|
+
* INITIATED txs — caller still drives via Agent.ts or manual code)
|
|
18
|
+
* - sending CounterAcceptMessage back to buyer (no reverse-endpoint
|
|
19
|
+
* discovery yet — print the verdict, operator handles delivery)
|
|
20
|
+
*
|
|
21
|
+
* @module cli/commands/serve
|
|
22
|
+
*/
|
|
23
|
+
/// <reference types="node" />
|
|
24
|
+
import { Command } from 'commander';
|
|
25
|
+
import { IncomingMessage } from 'http';
|
|
26
|
+
export declare function createServeCommand(): Command;
|
|
27
|
+
/**
|
|
28
|
+
* Read a request body with two hard limits — defense in depth alongside
|
|
29
|
+
* the server-level `headersTimeout` / `requestTimeout`:
|
|
30
|
+
* - byte cap (64 KiB) to bound memory
|
|
31
|
+
* - wall-clock deadline (10s) to bound time
|
|
32
|
+
*
|
|
33
|
+
* Both must be enforced here too because a caller could construct the
|
|
34
|
+
* server without our timeouts (e.g. testing with a raw http.Server) and
|
|
35
|
+
* the body cap alone won't shed a peer that sends 1 byte/sec forever.
|
|
36
|
+
*/
|
|
37
|
+
export declare function readBody(req: IncomingMessage): Promise<string>;
|
|
38
|
+
//# sourceMappingURL=serve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/serve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAgB,eAAe,EAAkB,MAAM,MAAM,CAAC;AAoBrE,wBAAgB,kBAAkB,IAAI,OAAO,CAuB5C;AA6ND;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAmC9D"}
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `actp serve` — long-running provider daemon.
|
|
4
|
+
*
|
|
5
|
+
* Loads a ProviderPolicy JSON, constructs a ProviderOrchestrator, opens
|
|
6
|
+
* an HTTP server on the configured port that exposes the AIP-2.1 quote
|
|
7
|
+
* channel surface (`POST /quote-channel/{chainId}/{txId}` per §8.2),
|
|
8
|
+
* and routes incoming buyer counter-offers through
|
|
9
|
+
* orchestrator.evaluateCounter().
|
|
10
|
+
*
|
|
11
|
+
* Scope (v1):
|
|
12
|
+
* - accept + verify incoming counter-offers via QuoteChannelHandler
|
|
13
|
+
* - log the policy verdict (accept / reject) per round
|
|
14
|
+
* - emit a one-line health response on `GET /`
|
|
15
|
+
*
|
|
16
|
+
* Out of scope for v1 (Phase 5):
|
|
17
|
+
* - on-chain event listening (no automatic submitQuote on incoming
|
|
18
|
+
* INITIATED txs — caller still drives via Agent.ts or manual code)
|
|
19
|
+
* - sending CounterAcceptMessage back to buyer (no reverse-endpoint
|
|
20
|
+
* discovery yet — print the verdict, operator handles delivery)
|
|
21
|
+
*
|
|
22
|
+
* @module cli/commands/serve
|
|
23
|
+
*/
|
|
24
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
25
|
+
if (k2 === undefined) k2 = k;
|
|
26
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
27
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
28
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
29
|
+
}
|
|
30
|
+
Object.defineProperty(o, k2, desc);
|
|
31
|
+
}) : (function(o, m, k, k2) {
|
|
32
|
+
if (k2 === undefined) k2 = k;
|
|
33
|
+
o[k2] = m[k];
|
|
34
|
+
}));
|
|
35
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
36
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
37
|
+
}) : function(o, v) {
|
|
38
|
+
o["default"] = v;
|
|
39
|
+
});
|
|
40
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
41
|
+
if (mod && mod.__esModule) return mod;
|
|
42
|
+
var result = {};
|
|
43
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
44
|
+
__setModuleDefault(result, mod);
|
|
45
|
+
return result;
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.readBody = exports.createServeCommand = void 0;
|
|
49
|
+
const commander_1 = require("commander");
|
|
50
|
+
const http_1 = require("http");
|
|
51
|
+
const fs_1 = require("fs");
|
|
52
|
+
const ethers_1 = require("ethers");
|
|
53
|
+
const output_1 = require("../utils/output");
|
|
54
|
+
const client_1 = require("../utils/client");
|
|
55
|
+
const networks_1 = require("../../config/networks");
|
|
56
|
+
const BlockchainRuntime_1 = require("../../runtime/BlockchainRuntime");
|
|
57
|
+
const MockRuntime_1 = require("../../runtime/MockRuntime");
|
|
58
|
+
const MockStateManager_1 = require("../../runtime/MockStateManager");
|
|
59
|
+
const ProviderOrchestrator_1 = require("../../negotiation/ProviderOrchestrator");
|
|
60
|
+
const QuoteChannel_1 = require("../../transport/QuoteChannel");
|
|
61
|
+
// ============================================================================
|
|
62
|
+
// Command
|
|
63
|
+
// ============================================================================
|
|
64
|
+
function createServeCommand() {
|
|
65
|
+
const cmd = new commander_1.Command('serve')
|
|
66
|
+
.description('Run a long-running provider daemon (AIP-2.1 quote channel)')
|
|
67
|
+
.requiredOption('--policy <path>', 'Path to ProviderPolicy JSON file')
|
|
68
|
+
.option('--port <num>', 'HTTP port to listen on', '8787')
|
|
69
|
+
.option('--network <name>', 'Network — base-sepolia | base-mainnet | mock', 'base-sepolia')
|
|
70
|
+
.option('--rpc <url>', 'Custom RPC URL override (testnet/mainnet only)')
|
|
71
|
+
.option('--mock', 'Run with MockRuntime instead of BlockchainRuntime (for local testing)')
|
|
72
|
+
.action(async (options) => {
|
|
73
|
+
const output = new output_1.Output('human');
|
|
74
|
+
try {
|
|
75
|
+
await runServe(options, output);
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
const structured = (0, client_1.mapError)(error);
|
|
79
|
+
output.errorResult({
|
|
80
|
+
code: structured.code,
|
|
81
|
+
message: structured.message,
|
|
82
|
+
details: structured.details,
|
|
83
|
+
});
|
|
84
|
+
process.exit(output_1.ExitCode.ERROR);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
return cmd;
|
|
88
|
+
}
|
|
89
|
+
exports.createServeCommand = createServeCommand;
|
|
90
|
+
async function runServe(options, output) {
|
|
91
|
+
// 1. Load + validate policy.
|
|
92
|
+
if (!(0, fs_1.existsSync)(options.policy)) {
|
|
93
|
+
throw new Error(`Policy file not found: ${options.policy}`);
|
|
94
|
+
}
|
|
95
|
+
const policy = JSON.parse((0, fs_1.readFileSync)(options.policy, 'utf-8'));
|
|
96
|
+
// 2. Build runtime AND keep a direct signer reference for the
|
|
97
|
+
// orchestrator. BlockchainRuntime makes its signer private, so we
|
|
98
|
+
// hold ours alongside.
|
|
99
|
+
let runtime;
|
|
100
|
+
let kernelAddress;
|
|
101
|
+
let chainId;
|
|
102
|
+
let signerAddress;
|
|
103
|
+
let orchestratorSigner;
|
|
104
|
+
if (options.mock) {
|
|
105
|
+
const stateMgr = new MockStateManager_1.MockStateManager(process.cwd() + '/.actp-serve');
|
|
106
|
+
runtime = new MockRuntime_1.MockRuntime(stateMgr);
|
|
107
|
+
kernelAddress = '0x' + '0'.repeat(40);
|
|
108
|
+
chainId = 84532;
|
|
109
|
+
const mockWallet = ethers_1.Wallet.createRandom();
|
|
110
|
+
orchestratorSigner = mockWallet;
|
|
111
|
+
signerAddress = mockWallet.address;
|
|
112
|
+
output.info('Running in MOCK mode — no real on-chain interaction.');
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
const networkCfg = (0, networks_1.getNetwork)(options.network);
|
|
116
|
+
if (options.rpc)
|
|
117
|
+
networkCfg.rpcUrl = options.rpc;
|
|
118
|
+
const { resolvePrivateKey } = await Promise.resolve().then(() => __importStar(require('../../wallet/keystore')));
|
|
119
|
+
const tier = options.network.includes('mainnet') ? 'mainnet'
|
|
120
|
+
: options.network.includes('sepolia') ? 'testnet' : 'mock';
|
|
121
|
+
const privateKey = await resolvePrivateKey(process.cwd(), {
|
|
122
|
+
network: tier,
|
|
123
|
+
});
|
|
124
|
+
if (!privateKey) {
|
|
125
|
+
throw new Error('No wallet found. Run `actp init` or set ACTP_KEYSTORE_BASE64.');
|
|
126
|
+
}
|
|
127
|
+
const provider = new ethers_1.JsonRpcProvider(networkCfg.rpcUrl);
|
|
128
|
+
const signer = new ethers_1.Wallet(privateKey, provider);
|
|
129
|
+
orchestratorSigner = signer;
|
|
130
|
+
runtime = new BlockchainRuntime_1.BlockchainRuntime({
|
|
131
|
+
network: options.network,
|
|
132
|
+
signer,
|
|
133
|
+
provider,
|
|
134
|
+
});
|
|
135
|
+
await runtime.initialize();
|
|
136
|
+
kernelAddress = networkCfg.contracts.actpKernel;
|
|
137
|
+
chainId = networkCfg.chainId;
|
|
138
|
+
signerAddress = await signer.getAddress();
|
|
139
|
+
}
|
|
140
|
+
const orchestrator = new ProviderOrchestrator_1.ProviderOrchestrator({
|
|
141
|
+
policy,
|
|
142
|
+
runtime,
|
|
143
|
+
signer: orchestratorSigner,
|
|
144
|
+
kernelAddress,
|
|
145
|
+
chainId,
|
|
146
|
+
});
|
|
147
|
+
// 4. Build channel handler with kernel address per chain.
|
|
148
|
+
const channelHandler = new QuoteChannel_1.QuoteChannelHandler({
|
|
149
|
+
kernelAddressByChainId: {
|
|
150
|
+
[chainId]: kernelAddress,
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
// 5. Start HTTP server.
|
|
154
|
+
const port = Number(options.port);
|
|
155
|
+
if (!Number.isFinite(port) || port < 1 || port > 65535) {
|
|
156
|
+
throw new Error(`Invalid port: ${options.port}`);
|
|
157
|
+
}
|
|
158
|
+
const server = (0, http_1.createServer)(async (req, res) => {
|
|
159
|
+
try {
|
|
160
|
+
await routeRequest(req, res, {
|
|
161
|
+
channelHandler,
|
|
162
|
+
orchestrator,
|
|
163
|
+
chainId,
|
|
164
|
+
signerAddress,
|
|
165
|
+
output,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
catch (err) {
|
|
169
|
+
output.error(`Request handler crashed: ${err instanceof Error ? err.message : String(err)}`);
|
|
170
|
+
res.statusCode = 500;
|
|
171
|
+
res.end('{"error":"internal"}');
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
// Slow-loris hardening: bound the time a client can hold a socket open
|
|
175
|
+
// dribbling out a request body. Without this, `readBody` will sit in
|
|
176
|
+
// its `data` listener until the OS-level keepalive ages out.
|
|
177
|
+
// 10s for headers, 15s for the full request — generous for normal
|
|
178
|
+
// peers (a counter-offer body is well under 4 KiB), tight enough to
|
|
179
|
+
// shed slow-trickle attackers in seconds.
|
|
180
|
+
server.headersTimeout = 10000;
|
|
181
|
+
server.requestTimeout = 15000;
|
|
182
|
+
server.listen(port, () => {
|
|
183
|
+
output.success(`actp serve listening on http://0.0.0.0:${port}`);
|
|
184
|
+
output.print(` Network: ${options.network}${options.mock ? ' (mock)' : ''}`);
|
|
185
|
+
output.print(` Provider: ${signerAddress}`);
|
|
186
|
+
output.print(` Channel base: ${(0, QuoteChannel_1.buildChannelPath)(chainId, '<txId>')}`);
|
|
187
|
+
output.print(` Health: GET /`);
|
|
188
|
+
output.print('');
|
|
189
|
+
output.print('Counter-offers POSTed to /quote-channel/{chainId}/{txId} are verified + evaluated.');
|
|
190
|
+
output.print('Verdicts are logged here; v1 does NOT auto-deliver CounterAcceptMessage back to');
|
|
191
|
+
output.print('the buyer — operator handles that out-of-band (see AIP-2.1 §5.3).');
|
|
192
|
+
output.print('');
|
|
193
|
+
});
|
|
194
|
+
// Graceful shutdown.
|
|
195
|
+
const shutdown = (signal) => {
|
|
196
|
+
output.info(`\n${signal} received — shutting down…`);
|
|
197
|
+
server.close(() => {
|
|
198
|
+
output.success('Stopped.');
|
|
199
|
+
process.exit(0);
|
|
200
|
+
});
|
|
201
|
+
// Force-exit after 5s if connections hang.
|
|
202
|
+
setTimeout(() => process.exit(0), 5000).unref();
|
|
203
|
+
};
|
|
204
|
+
process.once('SIGINT', () => shutdown('SIGINT'));
|
|
205
|
+
process.once('SIGTERM', () => shutdown('SIGTERM'));
|
|
206
|
+
}
|
|
207
|
+
async function routeRequest(req, res, ctx) {
|
|
208
|
+
const url = req.url ?? '/';
|
|
209
|
+
// Health check.
|
|
210
|
+
if (req.method === 'GET' && url === '/') {
|
|
211
|
+
res.statusCode = 200;
|
|
212
|
+
res.setHeader('Content-Type', 'application/json');
|
|
213
|
+
res.end(JSON.stringify({
|
|
214
|
+
status: 'ok',
|
|
215
|
+
provider: ctx.signerAddress,
|
|
216
|
+
chainId: ctx.chainId,
|
|
217
|
+
service: 'actp-serve',
|
|
218
|
+
}));
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
// /quote-channel/{chainId}/{txId}.
|
|
222
|
+
const channelMatch = url.match(/^\/quote-channel\/(\d+)\/(0x[a-fA-F0-9]{64})\/?$/);
|
|
223
|
+
if (req.method === 'POST' && channelMatch) {
|
|
224
|
+
const [, chainIdStr, txId] = channelMatch;
|
|
225
|
+
const pathChainId = Number(chainIdStr);
|
|
226
|
+
const body = await readBody(req);
|
|
227
|
+
let payload;
|
|
228
|
+
try {
|
|
229
|
+
payload = JSON.parse(body);
|
|
230
|
+
}
|
|
231
|
+
catch {
|
|
232
|
+
res.statusCode = 400;
|
|
233
|
+
res.end(JSON.stringify({ accepted: false, reason: 'Invalid JSON' }));
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
const result = await ctx.channelHandler.handle(payload, { pathChainId, pathTxId: txId });
|
|
237
|
+
// For counter-offers that pass the channel handler, run the
|
|
238
|
+
// orchestrator's policy verdict and log it.
|
|
239
|
+
if (result.status === 201 || result.status === 200) {
|
|
240
|
+
const p = payload;
|
|
241
|
+
if (p?.type === 'agirails.counteroffer.v1' && p.message) {
|
|
242
|
+
try {
|
|
243
|
+
const verdict = await ctx.orchestrator.evaluateCounter(p.message);
|
|
244
|
+
ctx.output.info(`[counter] tx=${txId.slice(0, 12)}… counter=${p.message.counterAmount} → ${verdict.action}: ${verdict.reason}`);
|
|
245
|
+
}
|
|
246
|
+
catch (err) {
|
|
247
|
+
ctx.output.warning(`[counter] tx=${txId.slice(0, 12)}… verification failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
res.statusCode = result.status;
|
|
252
|
+
res.setHeader('Content-Type', 'application/json');
|
|
253
|
+
res.end(JSON.stringify(result.body));
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
res.statusCode = 404;
|
|
257
|
+
res.end(JSON.stringify({ error: 'Not found' }));
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Read a request body with two hard limits — defense in depth alongside
|
|
261
|
+
* the server-level `headersTimeout` / `requestTimeout`:
|
|
262
|
+
* - byte cap (64 KiB) to bound memory
|
|
263
|
+
* - wall-clock deadline (10s) to bound time
|
|
264
|
+
*
|
|
265
|
+
* Both must be enforced here too because a caller could construct the
|
|
266
|
+
* server without our timeouts (e.g. testing with a raw http.Server) and
|
|
267
|
+
* the body cap alone won't shed a peer that sends 1 byte/sec forever.
|
|
268
|
+
*/
|
|
269
|
+
function readBody(req) {
|
|
270
|
+
return new Promise((resolve, reject) => {
|
|
271
|
+
const chunks = [];
|
|
272
|
+
let total = 0;
|
|
273
|
+
let settled = false;
|
|
274
|
+
const MAX_BYTES = 64 * 1024;
|
|
275
|
+
const MAX_MS = 10000;
|
|
276
|
+
const finish = (err, body) => {
|
|
277
|
+
if (settled)
|
|
278
|
+
return;
|
|
279
|
+
settled = true;
|
|
280
|
+
clearTimeout(deadline);
|
|
281
|
+
if (err) {
|
|
282
|
+
try {
|
|
283
|
+
req.destroy();
|
|
284
|
+
}
|
|
285
|
+
catch { /* */ }
|
|
286
|
+
reject(err);
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
resolve(body ?? '');
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
const deadline = setTimeout(() => {
|
|
293
|
+
finish(new Error('Body read timeout'));
|
|
294
|
+
}, MAX_MS);
|
|
295
|
+
req.on('data', (chunk) => {
|
|
296
|
+
total += chunk.length;
|
|
297
|
+
if (total > MAX_BYTES) {
|
|
298
|
+
finish(new Error('Body too large'));
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
chunks.push(chunk);
|
|
302
|
+
});
|
|
303
|
+
req.on('end', () => finish(null, Buffer.concat(chunks).toString('utf-8')));
|
|
304
|
+
req.on('error', (err) => finish(err));
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
exports.readBody = readBody;
|
|
308
|
+
//# sourceMappingURL=serve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serve.js","sourceRoot":"","sources":["../../../src/cli/commands/serve.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,yCAAoC;AACpC,+BAAqE;AACrE,2BAA8C;AAC9C,mCAA8D;AAC9D,4CAAmD;AACnD,4CAA2C;AAC3C,oDAAmD;AACnD,uEAAoE;AACpE,2DAAwD;AACxD,qEAAkE;AAClE,iFAA8E;AAE9E,+DAGsC;AAEtC,+EAA+E;AAC/E,UAAU;AACV,+EAA+E;AAE/E,SAAgB,kBAAkB;IAChC,MAAM,GAAG,GAAG,IAAI,mBAAO,CAAC,OAAO,CAAC;SAC7B,WAAW,CAAC,4DAA4D,CAAC;SACzE,cAAc,CAAC,iBAAiB,EAAE,kCAAkC,CAAC;SACrE,MAAM,CAAC,cAAc,EAAE,wBAAwB,EAAE,MAAM,CAAC;SACxD,MAAM,CAAC,kBAAkB,EAAE,8CAA8C,EAAE,cAAc,CAAC;SAC1F,MAAM,CAAC,aAAa,EAAE,gDAAgD,CAAC;SACvE,MAAM,CAAC,QAAQ,EAAE,uEAAuE,CAAC;SACzF,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QACxB,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC,OAAO,CAAC,CAAC;QACnC,IAAI,CAAC;YACH,MAAM,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAClC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,UAAU,GAAG,IAAA,iBAAQ,EAAC,KAAK,CAAC,C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C,CAAC;QACzC,CAAC,EAAE,MAAM,CAAC,CAAC;QAEX,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE;YAC/B,KAAK,IAAI,KAAK,CAAC,MAAM,CAAC;YACtB,IAAI,KAAK,GAAG,SAAS,EAAE,CAAC;gBACtB,MAAM,CAAC,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC;gBACpC,OAAO;YACT,CAAC;YACD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC,CAAC,CAAC;QACH,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAC3E,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;AACL,CAAC;AAnCD,4BAmCC"}
|
|
@@ -140,7 +140,7 @@ async function runTest(output) {
|
|
|
140
140
|
// Parse identity
|
|
141
141
|
const content = fs.readFileSync(identityPath, 'utf-8');
|
|
142
142
|
const config = (0, agirailsmdV4_1.parseAgirailsMdV4)(content);
|
|
143
|
-
const testJob = (0, testjobs_1.selectTestJob)(config.services);
|
|
143
|
+
const testJob = (0, testjobs_1.selectTestJob)(config.services.map(s => s.type));
|
|
144
144
|
// Render banner + section header (human mode only)
|
|
145
145
|
if (output.mode === 'human') {
|
|
146
146
|
output.print('');
|
|
@@ -217,7 +217,7 @@ async function runTest(output) {
|
|
|
217
217
|
// Receipt
|
|
218
218
|
(0, receipt_1.renderReceipt)({
|
|
219
219
|
agent: config.name,
|
|
220
|
-
service: config.services[0],
|
|
220
|
+
service: config.services[0].type,
|
|
221
221
|
amountWei,
|
|
222
222
|
network: 'mock',
|
|
223
223
|
txId,
|