@wangwuww/neo-market-cli 0.1.0-alpha.1
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 +52 -0
- package/SKILL.md +81 -0
- package/artifacts/contracts/AgentRegistry.sol/AgentRegistry.dbg.json +4 -0
- package/artifacts/contracts/AgentRegistry.sol/AgentRegistry.json +400 -0
- package/artifacts/contracts/ArbitrationMultisig.sol/ArbitrationMultisig.dbg.json +4 -0
- package/artifacts/contracts/ArbitrationMultisig.sol/ArbitrationMultisig.json +243 -0
- package/artifacts/contracts/ArbitrationMultisig.sol/ITokenEscrowExecute.dbg.json +4 -0
- package/artifacts/contracts/ArbitrationMultisig.sol/ITokenEscrowExecute.json +24 -0
- package/artifacts/contracts/FeeManager.sol/FeeManager.dbg.json +4 -0
- package/artifacts/contracts/FeeManager.sol/FeeManager.json +53 -0
- package/artifacts/contracts/Marketplace.sol/IModuleRegistry.dbg.json +4 -0
- package/artifacts/contracts/Marketplace.sol/IModuleRegistry.json +30 -0
- package/artifacts/contracts/Marketplace.sol/ITokenEscrowMinimal.dbg.json +4 -0
- package/artifacts/contracts/Marketplace.sol/ITokenEscrowMinimal.json +120 -0
- package/artifacts/contracts/Marketplace.sol/Marketplace.dbg.json +4 -0
- package/artifacts/contracts/Marketplace.sol/Marketplace.json +746 -0
- package/artifacts/contracts/ModuleKeys.sol/ModuleKeys.dbg.json +4 -0
- package/artifacts/contracts/ModuleKeys.sol/ModuleKeys.json +10 -0
- package/artifacts/contracts/ModuleRegistry.sol/ModuleRegistry.dbg.json +4 -0
- package/artifacts/contracts/ModuleRegistry.sol/ModuleRegistry.json +169 -0
- package/artifacts/contracts/Reputation.sol/Reputation.dbg.json +4 -0
- package/artifacts/contracts/Reputation.sol/Reputation.json +265 -0
- package/artifacts/contracts/TokenEscrow.sol/IArbitration.dbg.json +4 -0
- package/artifacts/contracts/TokenEscrow.sol/IArbitration.json +59 -0
- package/artifacts/contracts/TokenEscrow.sol/IERC20Minimal.dbg.json +4 -0
- package/artifacts/contracts/TokenEscrow.sol/IERC20Minimal.json +64 -0
- package/artifacts/contracts/TokenEscrow.sol/IFeeManager.dbg.json +4 -0
- package/artifacts/contracts/TokenEscrow.sol/IFeeManager.json +37 -0
- package/artifacts/contracts/TokenEscrow.sol/IModuleRegistry.dbg.json +4 -0
- package/artifacts/contracts/TokenEscrow.sol/IModuleRegistry.json +30 -0
- package/artifacts/contracts/TokenEscrow.sol/TokenEscrow.dbg.json +4 -0
- package/artifacts/contracts/TokenEscrow.sol/TokenEscrow.json +1091 -0
- package/artifacts/contracts/USDCMock.sol/USDCMock.dbg.json +4 -0
- package/artifacts/contracts/USDCMock.sol/USDCMock.json +251 -0
- package/artifacts/contracts/interfaces/IAgentRegistry.sol/IAgentRegistry.dbg.json +4 -0
- package/artifacts/contracts/interfaces/IAgentRegistry.sol/IAgentRegistry.json +203 -0
- package/artifacts/contracts/interfaces/IArbitration.sol/IArbitration.dbg.json +4 -0
- package/artifacts/contracts/interfaces/IArbitration.sol/IArbitration.json +127 -0
- package/artifacts/contracts/interfaces/IEscrow.sol/IEscrow.dbg.json +4 -0
- package/artifacts/contracts/interfaces/IEscrow.sol/IEscrow.json +431 -0
- package/artifacts/contracts/interfaces/IFeeManager.sol/IFeeManager.dbg.json +4 -0
- package/artifacts/contracts/interfaces/IFeeManager.sol/IFeeManager.json +87 -0
- package/artifacts/contracts/interfaces/IMarketplace.sol/IMarketplace.dbg.json +4 -0
- package/artifacts/contracts/interfaces/IMarketplace.sol/IMarketplace.json +427 -0
- package/artifacts/contracts/interfaces/IReputation.sol/IReputation.dbg.json +4 -0
- package/artifacts/contracts/interfaces/IReputation.sol/IReputation.json +151 -0
- package/artifacts/contracts/interfaces/ISignatures.sol/ISignatures.dbg.json +4 -0
- package/artifacts/contracts/interfaces/ISignatures.sol/ISignatures.json +414 -0
- package/artifacts/contracts/interfaces/ITokenEscrow.sol/ITokenEscrow.dbg.json +4 -0
- package/artifacts/contracts/interfaces/ITokenEscrow.sol/ITokenEscrow.json +245 -0
- package/deployed_addresses.json +11 -0
- package/dist/artifacts/build-info/263a967f7f3cd59c812a49b3d7012981.json +1 -0
- package/dist/artifacts/build-info/4a4ba527b0f3c1846c84e3e500a6db58.json +1 -0
- package/dist/artifacts/build-info/4e7053f3332c81b7a9916619c1b87388.json +1 -0
- package/dist/artifacts/build-info/50367a8838c4b3b556df951a374f59c7.json +1 -0
- package/dist/artifacts/build-info/61ca0f28829f90b00df26748203acea3.json +1 -0
- package/dist/artifacts/build-info/63fca17ade81ae3db2e066ca74f790d1.json +1 -0
- package/dist/artifacts/build-info/85f6bdb1a79bcf0154bb1562fa8e221e.json +1 -0
- package/dist/artifacts/contracts/AgentRegistry.sol/AgentRegistry.dbg.json +4 -0
- package/dist/artifacts/contracts/AgentRegistry.sol/AgentRegistry.json +400 -0
- package/dist/artifacts/contracts/ArbitrationMultisig.sol/ArbitrationMultisig.dbg.json +4 -0
- package/dist/artifacts/contracts/ArbitrationMultisig.sol/ArbitrationMultisig.json +243 -0
- package/dist/artifacts/contracts/ArbitrationMultisig.sol/ITokenEscrowExecute.dbg.json +4 -0
- package/dist/artifacts/contracts/ArbitrationMultisig.sol/ITokenEscrowExecute.json +24 -0
- package/dist/artifacts/contracts/FeeManager.sol/FeeManager.dbg.json +4 -0
- package/dist/artifacts/contracts/FeeManager.sol/FeeManager.json +53 -0
- package/dist/artifacts/contracts/Marketplace.sol/IModuleRegistry.dbg.json +4 -0
- package/dist/artifacts/contracts/Marketplace.sol/IModuleRegistry.json +30 -0
- package/dist/artifacts/contracts/Marketplace.sol/ITokenEscrowMinimal.dbg.json +4 -0
- package/dist/artifacts/contracts/Marketplace.sol/ITokenEscrowMinimal.json +120 -0
- package/dist/artifacts/contracts/Marketplace.sol/Marketplace.dbg.json +4 -0
- package/dist/artifacts/contracts/Marketplace.sol/Marketplace.json +746 -0
- package/dist/artifacts/contracts/ModuleKeys.sol/ModuleKeys.dbg.json +4 -0
- package/dist/artifacts/contracts/ModuleKeys.sol/ModuleKeys.json +10 -0
- package/dist/artifacts/contracts/ModuleRegistry.sol/ModuleRegistry.dbg.json +4 -0
- package/dist/artifacts/contracts/ModuleRegistry.sol/ModuleRegistry.json +169 -0
- package/dist/artifacts/contracts/Reputation.sol/Reputation.dbg.json +4 -0
- package/dist/artifacts/contracts/Reputation.sol/Reputation.json +265 -0
- package/dist/artifacts/contracts/TokenEscrow.sol/IArbitration.dbg.json +4 -0
- package/dist/artifacts/contracts/TokenEscrow.sol/IArbitration.json +59 -0
- package/dist/artifacts/contracts/TokenEscrow.sol/IERC20Minimal.dbg.json +4 -0
- package/dist/artifacts/contracts/TokenEscrow.sol/IERC20Minimal.json +64 -0
- package/dist/artifacts/contracts/TokenEscrow.sol/IFeeManager.dbg.json +4 -0
- package/dist/artifacts/contracts/TokenEscrow.sol/IFeeManager.json +37 -0
- package/dist/artifacts/contracts/TokenEscrow.sol/IModuleRegistry.dbg.json +4 -0
- package/dist/artifacts/contracts/TokenEscrow.sol/IModuleRegistry.json +30 -0
- package/dist/artifacts/contracts/TokenEscrow.sol/TokenEscrow.dbg.json +4 -0
- package/dist/artifacts/contracts/TokenEscrow.sol/TokenEscrow.json +1091 -0
- package/dist/artifacts/contracts/USDCMock.sol/USDCMock.dbg.json +4 -0
- package/dist/artifacts/contracts/USDCMock.sol/USDCMock.json +251 -0
- package/dist/artifacts/contracts/interfaces/IAgentRegistry.sol/IAgentRegistry.dbg.json +4 -0
- package/dist/artifacts/contracts/interfaces/IAgentRegistry.sol/IAgentRegistry.json +203 -0
- package/dist/artifacts/contracts/interfaces/IArbitration.sol/IArbitration.dbg.json +4 -0
- package/dist/artifacts/contracts/interfaces/IArbitration.sol/IArbitration.json +127 -0
- package/dist/artifacts/contracts/interfaces/IEscrow.sol/IEscrow.dbg.json +4 -0
- package/dist/artifacts/contracts/interfaces/IEscrow.sol/IEscrow.json +431 -0
- package/dist/artifacts/contracts/interfaces/IFeeManager.sol/IFeeManager.dbg.json +4 -0
- package/dist/artifacts/contracts/interfaces/IFeeManager.sol/IFeeManager.json +87 -0
- package/dist/artifacts/contracts/interfaces/IMarketplace.sol/IMarketplace.dbg.json +4 -0
- package/dist/artifacts/contracts/interfaces/IMarketplace.sol/IMarketplace.json +427 -0
- package/dist/artifacts/contracts/interfaces/IReputation.sol/IReputation.dbg.json +4 -0
- package/dist/artifacts/contracts/interfaces/IReputation.sol/IReputation.json +151 -0
- package/dist/artifacts/contracts/interfaces/ISignatures.sol/ISignatures.dbg.json +4 -0
- package/dist/artifacts/contracts/interfaces/ISignatures.sol/ISignatures.json +414 -0
- package/dist/artifacts/contracts/interfaces/ITokenEscrow.sol/ITokenEscrow.dbg.json +4 -0
- package/dist/artifacts/contracts/interfaces/ITokenEscrow.sol/ITokenEscrow.json +245 -0
- package/dist/cli.js +306 -0
- package/dist/deployed_addresses.json +11 -0
- package/dist/scripts/bridge_to_base.js +67 -0
- package/dist/scripts/check_balance.js +46 -0
- package/dist/scripts/count_agents.js +62 -0
- package/dist/scripts/demo_e2e.js +256 -0
- package/dist/scripts/deploy_prod.js +190 -0
- package/dist/scripts/deploy_sepolia.js +196 -0
- package/dist/scripts/issue_usdc.js +97 -0
- package/dist/scripts/issue_usdc_retry.js +92 -0
- package/dist/scripts/run_genesis_tx.js +127 -0
- package/dist/scripts/show_address.js +52 -0
- package/dist/scripts/test_encryption.js +65 -0
- package/dist/scripts/utils/encryption.js +80 -0
- package/dist/scripts/verify_and_run.js +130 -0
- package/dist/scripts/wire_and_verify.js +120 -0
- package/package.json +39 -0
package/dist/cli.js
ADDED
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
const commander_1 = require("commander");
|
|
38
|
+
const ethers_1 = require("ethers");
|
|
39
|
+
const path = __importStar(require("path"));
|
|
40
|
+
const fs = __importStar(require("fs"));
|
|
41
|
+
const dotenv = __importStar(require("dotenv"));
|
|
42
|
+
dotenv.config();
|
|
43
|
+
// Load addresses
|
|
44
|
+
const ADDR_PATH = path.join(__dirname, "deployed_addresses.json");
|
|
45
|
+
if (!fs.existsSync(ADDR_PATH)) {
|
|
46
|
+
console.error("ā Error: deployed_addresses.json not found.");
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
const ADDRS = JSON.parse(fs.readFileSync(ADDR_PATH, "utf-8"));
|
|
50
|
+
// Contracts are on Sepolia L1
|
|
51
|
+
const DEFAULT_RPC = "https://ethereum-sepolia-rpc.publicnode.com";
|
|
52
|
+
const CURRENT_CHAIN_ID = 11155111;
|
|
53
|
+
const program = new commander_1.Command();
|
|
54
|
+
program
|
|
55
|
+
.name("agent-market")
|
|
56
|
+
.description("CLI for Autonomous Agents")
|
|
57
|
+
.version("0.1.0")
|
|
58
|
+
.option("--rpc <url>", "Override RPC URL", DEFAULT_RPC)
|
|
59
|
+
.option("--key <private_key>", "Override Private Key");
|
|
60
|
+
function getProvider(options) {
|
|
61
|
+
const rpc = options.rpc || process.env.BASE_RPC_URL || DEFAULT_RPC;
|
|
62
|
+
return new ethers_1.ethers.JsonRpcProvider(rpc);
|
|
63
|
+
}
|
|
64
|
+
function getWallet(options, provider) {
|
|
65
|
+
const key = options.key || process.env.PRIVATE_KEY;
|
|
66
|
+
if (key)
|
|
67
|
+
return new ethers_1.ethers.Wallet(key, provider);
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
function getContract(name, address, runner) {
|
|
71
|
+
try {
|
|
72
|
+
// Try to find artifact in artifacts/contracts
|
|
73
|
+
// Support both ts-node (src) and dist (build) paths
|
|
74
|
+
let artifactPath = path.join(__dirname, `artifacts/contracts/${name}.sol/${name}.json`);
|
|
75
|
+
if (!fs.existsSync(artifactPath)) {
|
|
76
|
+
// Fallback for dist structure
|
|
77
|
+
artifactPath = path.join(__dirname, `../artifacts/contracts/${name}.sol/${name}.json`);
|
|
78
|
+
}
|
|
79
|
+
const artifact = JSON.parse(fs.readFileSync(artifactPath, "utf-8"));
|
|
80
|
+
return new ethers_1.ethers.Contract(address, artifact.abi, runner);
|
|
81
|
+
}
|
|
82
|
+
catch (e) {
|
|
83
|
+
console.error(`ā ABI for ${name} not found at ${path.join(__dirname, `artifacts/contracts/${name}.sol/${name}.json`)}`);
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// --- Command: Register ---
|
|
88
|
+
program
|
|
89
|
+
.command("register")
|
|
90
|
+
.description("Register as a Supplier Agent")
|
|
91
|
+
.requiredOption("-m, --manifest <ipfs_cid>", "IPFS CID")
|
|
92
|
+
.action(async (options) => {
|
|
93
|
+
const provider = getProvider(program.opts());
|
|
94
|
+
const wallet = getWallet(program.opts(), provider);
|
|
95
|
+
if (!wallet) {
|
|
96
|
+
console.error("ā Private Key required");
|
|
97
|
+
process.exit(1);
|
|
98
|
+
}
|
|
99
|
+
console.log(`š RPC: ${provider._getConnection().url}`);
|
|
100
|
+
console.log(`š¤ Address: ${wallet.address}`);
|
|
101
|
+
const bal = await provider.getBalance(wallet.address);
|
|
102
|
+
console.log(`š° Balance: ${ethers_1.ethers.formatEther(bal)} ETH`);
|
|
103
|
+
if (bal === 0n) {
|
|
104
|
+
console.error("ā Balance is 0. Cannot send tx.");
|
|
105
|
+
process.exit(1);
|
|
106
|
+
}
|
|
107
|
+
console.log(`\nš¦ Registering agent...`);
|
|
108
|
+
const registry = getContract("AgentRegistry", ADDRS.AgentRegistry, wallet);
|
|
109
|
+
try {
|
|
110
|
+
const tx = await registry.register(options.manifest);
|
|
111
|
+
console.log(`ā
Tx sent: ${tx.hash}`);
|
|
112
|
+
await tx.wait();
|
|
113
|
+
console.log(`š Registered!`);
|
|
114
|
+
}
|
|
115
|
+
catch (e) {
|
|
116
|
+
console.error("ā Tx Failed:", e.shortMessage || e.message);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
// --- Command: Publish Job ---
|
|
120
|
+
program
|
|
121
|
+
.command("publish")
|
|
122
|
+
.description("Publish a new Job request")
|
|
123
|
+
.requiredOption("-t, --title <string>", "Job Title")
|
|
124
|
+
.requiredOption("-d, --description <string>", "Job Description")
|
|
125
|
+
.requiredOption("-b, --budget <amount>", "Budget in USDC")
|
|
126
|
+
.action(async (options) => {
|
|
127
|
+
const provider = getProvider(program.opts());
|
|
128
|
+
const wallet = getWallet(program.opts(), provider);
|
|
129
|
+
if (!wallet) {
|
|
130
|
+
console.error("ā Key required");
|
|
131
|
+
process.exit(1);
|
|
132
|
+
}
|
|
133
|
+
console.log(`š Publishing Job: ${options.title}...`);
|
|
134
|
+
// 1. Upload Spec (Mock)
|
|
135
|
+
// In real CLI, we would use IPFS. For demo, we assume a CID or generate a mock one.
|
|
136
|
+
// Since we removed local IPFS mocking code to slim down, we'll just use a placeholder CID for now
|
|
137
|
+
// or restore the mock function if needed. Let's use a placeholder.
|
|
138
|
+
const cid = "Qm" + ethers_1.ethers.keccak256(ethers_1.ethers.toUtf8Bytes(options.title + Date.now())).substring(2, 44);
|
|
139
|
+
console.log(`š¦ Spec CID: ${cid}`);
|
|
140
|
+
const market = getContract("Marketplace", ADDRS.Marketplace, wallet);
|
|
141
|
+
const token = getContract("USDCMock", ADDRS.usdc, wallet);
|
|
142
|
+
const budgetWei = ethers_1.ethers.parseUnits(options.budget, 6);
|
|
143
|
+
const deadline = Math.floor(Date.now() / 1000) + 7 * 24 * 3600; // 1 week
|
|
144
|
+
// 2. Approve
|
|
145
|
+
console.log("š° Approving USDC...");
|
|
146
|
+
try {
|
|
147
|
+
const txApprove = await token.approve(ADDRS.Marketplace, budgetWei);
|
|
148
|
+
await txApprove.wait();
|
|
149
|
+
console.log("ā
Approved.");
|
|
150
|
+
}
|
|
151
|
+
catch (e) {
|
|
152
|
+
console.error("ā Approve Failed:", e.shortMessage || e.message);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
// 3. Post
|
|
156
|
+
console.log("š Posting Job...");
|
|
157
|
+
try {
|
|
158
|
+
const tx = await market.publishJob(cid, 0, budgetWei, ADDRS.usdc, deadline);
|
|
159
|
+
console.log(`ā
Tx: ${tx.hash}`);
|
|
160
|
+
await tx.wait();
|
|
161
|
+
console.log("š Job Published!");
|
|
162
|
+
}
|
|
163
|
+
catch (e) {
|
|
164
|
+
console.error("ā Post Failed:", e.shortMessage || e.message);
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
// --- Command: Select Bid ---
|
|
168
|
+
program
|
|
169
|
+
.command("select-bid")
|
|
170
|
+
.description("Select a bid for your job")
|
|
171
|
+
.requiredOption("-j, --job <id>", "Job ID")
|
|
172
|
+
.requiredOption("-b, --bid <id>", "Bid ID")
|
|
173
|
+
.action(async (options) => {
|
|
174
|
+
const provider = getProvider(program.opts());
|
|
175
|
+
const wallet = getWallet(program.opts(), provider);
|
|
176
|
+
if (!wallet) {
|
|
177
|
+
console.error("ā Key required");
|
|
178
|
+
process.exit(1);
|
|
179
|
+
}
|
|
180
|
+
console.log(`__ Selecting Bid #${options.bid} for Job #${options.job}...`);
|
|
181
|
+
const market = getContract("Marketplace", ADDRS.Marketplace, wallet);
|
|
182
|
+
try {
|
|
183
|
+
const tx = await market.selectBid(options.job, options.bid);
|
|
184
|
+
console.log(`ā
Tx: ${tx.hash}`);
|
|
185
|
+
await tx.wait();
|
|
186
|
+
console.log("š Bid Selected!");
|
|
187
|
+
}
|
|
188
|
+
catch (e) {
|
|
189
|
+
console.error("ā Select Failed:", e.shortMessage || e.message);
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
// --- Command: Jobs ---
|
|
193
|
+
program
|
|
194
|
+
.command("jobs")
|
|
195
|
+
.description("List jobs")
|
|
196
|
+
.option("-l, --limit <number>", "Limit results", "10")
|
|
197
|
+
.action(async (options) => {
|
|
198
|
+
const provider = getProvider(program.opts());
|
|
199
|
+
const market = getContract("Marketplace", ADDRS.Marketplace, provider);
|
|
200
|
+
try {
|
|
201
|
+
const count = await market.jobCount();
|
|
202
|
+
console.log(`š Total Jobs: ${count}`);
|
|
203
|
+
const limit = Math.min(Number(count), parseInt(options.limit));
|
|
204
|
+
for (let i = Number(count); i > Number(count) - limit; i--) {
|
|
205
|
+
if (i <= 0)
|
|
206
|
+
break;
|
|
207
|
+
const job = await market.getJob(i);
|
|
208
|
+
console.log(`\nš Job #${job.jobId}`);
|
|
209
|
+
console.log(` Spec: ${job.jobSpecCID}`);
|
|
210
|
+
console.log(` Budget: ${ethers_1.ethers.formatUnits(job.budget, 6)} USDC`);
|
|
211
|
+
const status = ["Init", "Open", "Selected", "Cancelled", "Closed", "Expired"][Number(job.status)];
|
|
212
|
+
console.log(` Status: ${status}`);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
catch (e) {
|
|
216
|
+
console.error("Error fetching jobs:", e);
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
// --- Command: Bid ---
|
|
220
|
+
program
|
|
221
|
+
.command("bid")
|
|
222
|
+
.requiredOption("-j, --job <id>", "Job ID")
|
|
223
|
+
.requiredOption("-p, --price <amount>", "Price USDC")
|
|
224
|
+
.requiredOption("-e, --eta <seconds>", "ETA")
|
|
225
|
+
.requiredOption("-c, --cid <ipfs_cid>", "CID")
|
|
226
|
+
.action(async (options) => {
|
|
227
|
+
const provider = getProvider(program.opts());
|
|
228
|
+
const wallet = getWallet(program.opts(), provider);
|
|
229
|
+
if (!wallet) {
|
|
230
|
+
console.error("ā Key required");
|
|
231
|
+
process.exit(1);
|
|
232
|
+
}
|
|
233
|
+
const market = getContract("Marketplace", ADDRS.Marketplace, wallet);
|
|
234
|
+
const price = ethers_1.ethers.parseUnits(options.price, 6);
|
|
235
|
+
console.log(`š¦ Bidding on Job #${options.job}...`);
|
|
236
|
+
try {
|
|
237
|
+
const tx = await market.placeBid(options.job, options.cid, price, options.eta);
|
|
238
|
+
console.log(`ā
Tx: ${tx.hash}`);
|
|
239
|
+
await tx.wait();
|
|
240
|
+
console.log("š Bid Placed!");
|
|
241
|
+
}
|
|
242
|
+
catch (e) {
|
|
243
|
+
console.error("ā Bid Failed:", e.shortMessage || e.message);
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
// --- Command: Deliver ---
|
|
247
|
+
program
|
|
248
|
+
.command("deliver")
|
|
249
|
+
.requiredOption("-e, --escrow <id>", "Escrow ID")
|
|
250
|
+
.requiredOption("-j, --job <id>", "Job ID")
|
|
251
|
+
.requiredOption("-c, --cid <ipfs_cid>", "CID")
|
|
252
|
+
.action(async (options) => {
|
|
253
|
+
const provider = getProvider(program.opts());
|
|
254
|
+
const wallet = getWallet(program.opts(), provider);
|
|
255
|
+
if (!wallet) {
|
|
256
|
+
console.error("ā Key required");
|
|
257
|
+
process.exit(1);
|
|
258
|
+
}
|
|
259
|
+
const escrow = getContract("TokenEscrow", ADDRS.TokenEscrow, wallet);
|
|
260
|
+
// Receipt Signature
|
|
261
|
+
const deliveryHash = ethers_1.ethers.keccak256(ethers_1.ethers.toUtf8Bytes(options.cid));
|
|
262
|
+
const nonce = await escrow.nonces(wallet.address);
|
|
263
|
+
const ts = Math.floor(Date.now() / 1000);
|
|
264
|
+
const deadline = ts + 3600;
|
|
265
|
+
const receipt = {
|
|
266
|
+
escrowId: options.escrow,
|
|
267
|
+
jobId: options.job,
|
|
268
|
+
agent: wallet.address,
|
|
269
|
+
deliveryCID: options.cid,
|
|
270
|
+
deliveryHash: deliveryHash,
|
|
271
|
+
timestamp: ts,
|
|
272
|
+
nonce: nonce,
|
|
273
|
+
deadline: deadline
|
|
274
|
+
};
|
|
275
|
+
const domain = {
|
|
276
|
+
name: "AgentMarket",
|
|
277
|
+
version: "1",
|
|
278
|
+
chainId: CURRENT_CHAIN_ID,
|
|
279
|
+
verifyingContract: ADDRS.TokenEscrow
|
|
280
|
+
};
|
|
281
|
+
const types = {
|
|
282
|
+
DeliveryReceiptSignature: [
|
|
283
|
+
{ name: "escrowId", type: "uint256" },
|
|
284
|
+
{ name: "jobId", type: "uint256" },
|
|
285
|
+
{ name: "agent", type: "address" },
|
|
286
|
+
{ name: "deliveryCID", type: "string" },
|
|
287
|
+
{ name: "deliveryHash", type: "bytes32" },
|
|
288
|
+
{ name: "timestamp", type: "uint64" },
|
|
289
|
+
{ name: "nonce", type: "uint256" },
|
|
290
|
+
{ name: "deadline", type: "uint64" }
|
|
291
|
+
]
|
|
292
|
+
};
|
|
293
|
+
console.log("āļø Signing receipt...");
|
|
294
|
+
const signature = await wallet.signTypedData(domain, types, receipt);
|
|
295
|
+
console.log("š Submitting...");
|
|
296
|
+
try {
|
|
297
|
+
const tx = await escrow.submitDelivery(receipt, signature);
|
|
298
|
+
console.log(`ā
Tx: ${tx.hash}`);
|
|
299
|
+
await tx.wait();
|
|
300
|
+
console.log("š Delivered!");
|
|
301
|
+
}
|
|
302
|
+
catch (e) {
|
|
303
|
+
console.error("ā Deliver Failed:", e.shortMessage || e.message);
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
program.parse(process.argv);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"ModuleRegistry": "0xF15d928954F9Ac529CF706027e5E1829B1aBed34",
|
|
3
|
+
"AgentRegistry": "0xF040bE18dfb1f0ac50c599fb187668a0B428481C",
|
|
4
|
+
"FeeManager": "0x2F6fB6bE3F176B2e424405C27E02fE0414237B83",
|
|
5
|
+
"TokenEscrow": "0xFec348d13419C58c1a638f3a6E6097f4FDF7591C",
|
|
6
|
+
"Marketplace": "0x339f142deE647aD8518db6b7e2045B5F3d5aEeFc",
|
|
7
|
+
"Reputation": "0xf9a166CaF953F6D50af3a63BC0D02084C832a791",
|
|
8
|
+
"network": "sepolia",
|
|
9
|
+
"chainId": 11155111,
|
|
10
|
+
"usdc": "0x1723FDdEaaB893D6d4d841BeBD80099cB47cB82e"
|
|
11
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const ethers_1 = require("ethers");
|
|
37
|
+
const dotenv = __importStar(require("dotenv"));
|
|
38
|
+
dotenv.config();
|
|
39
|
+
const L1_RPC = "https://ethereum-sepolia-rpc.publicnode.com"; // Sepolia L1
|
|
40
|
+
const BRIDGE_ADDRESS = "0x3154Cf16ccdb4C6d922629664174b904d80F2C35"; // L1StandardBridgeProxy on Sepolia
|
|
41
|
+
async function bridge() {
|
|
42
|
+
const pk = process.env.PRIVATE_KEY;
|
|
43
|
+
if (!pk)
|
|
44
|
+
throw new Error("Missing PRIVATE_KEY");
|
|
45
|
+
const provider = new ethers_1.ethers.JsonRpcProvider(L1_RPC);
|
|
46
|
+
const wallet = new ethers_1.ethers.Wallet(pk, provider);
|
|
47
|
+
const balance = await provider.getBalance(wallet.address);
|
|
48
|
+
console.log(`L1 Balance: ${ethers_1.ethers.formatEther(balance)} ETH`);
|
|
49
|
+
if (balance < ethers_1.ethers.parseEther("0.05")) {
|
|
50
|
+
console.log("ā Balance too low for bridging");
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
// Deposit 0.08 ETH to Base Sepolia
|
|
54
|
+
const amount = ethers_1.ethers.parseEther("0.08");
|
|
55
|
+
// ABI for depositETHTo
|
|
56
|
+
const abi = ["function depositETHTo(address _to, uint32 _minGasLimit, bytes _extraData) payable"];
|
|
57
|
+
const contract = new ethers_1.ethers.Contract(BRIDGE_ADDRESS, abi, wallet);
|
|
58
|
+
console.log(`Bridging 0.08 ETH to Base Sepolia...`);
|
|
59
|
+
const tx = await contract.depositETHTo(wallet.address, // to self
|
|
60
|
+
200000, // minGasLimit
|
|
61
|
+
"0x", // extraData
|
|
62
|
+
{ value: amount });
|
|
63
|
+
console.log(`Tx Sent: https://sepolia.etherscan.io/tx/${tx.hash}`);
|
|
64
|
+
await tx.wait();
|
|
65
|
+
console.log("ā
Bridging initiated! Wait ~2 mins for funds to arrive on Base Sepolia.");
|
|
66
|
+
}
|
|
67
|
+
bridge().catch(console.error);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const ethers_1 = require("ethers");
|
|
37
|
+
const dotenv = __importStar(require("dotenv"));
|
|
38
|
+
dotenv.config();
|
|
39
|
+
const RPC = "https://ethereum-sepolia-rpc.publicnode.com";
|
|
40
|
+
async function check() {
|
|
41
|
+
const provider = new ethers_1.ethers.JsonRpcProvider(RPC);
|
|
42
|
+
const address = "0xfc33a39d546CB88e82beBF0b246E4C458E562A56";
|
|
43
|
+
const balance = await provider.getBalance(address);
|
|
44
|
+
console.log(`Base Sepolia Balance: ${ethers_1.ethers.formatEther(balance)} ETH`);
|
|
45
|
+
}
|
|
46
|
+
check().catch(console.error);
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const hardhat_1 = require("hardhat");
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
async function main() {
|
|
40
|
+
const addrPath = path.join(process.cwd(), "deployed_addresses.json");
|
|
41
|
+
const addrs = JSON.parse(fs.readFileSync(addrPath, "utf-8"));
|
|
42
|
+
const registry = await hardhat_1.ethers.getContractAt("AgentRegistry", addrs.AgentRegistry);
|
|
43
|
+
console.log(`Querying AgentRegistry at ${addrs.AgentRegistry}...`);
|
|
44
|
+
// Scan last 10000 blocks (deployment was recent)
|
|
45
|
+
const currentBlock = await hardhat_1.ethers.provider.getBlockNumber();
|
|
46
|
+
const fromBlock = currentBlock - 10000;
|
|
47
|
+
const filter = registry.filters.AgentRegistered();
|
|
48
|
+
const events = await registry.queryFilter(filter, fromBlock);
|
|
49
|
+
console.log(`\nš Total Registered Agents: ${events.length}`);
|
|
50
|
+
if (events.length > 0) {
|
|
51
|
+
console.log("\nRecent Registrations:");
|
|
52
|
+
// Show last 5
|
|
53
|
+
for (const ev of events.slice(-5)) {
|
|
54
|
+
const args = ev.args;
|
|
55
|
+
console.log(`- Agent: ${args.agent}`);
|
|
56
|
+
console.log(` CID: ${args.manifestCID}`);
|
|
57
|
+
console.log(` Stake: ${hardhat_1.ethers.formatEther(args.stake)} ETH`);
|
|
58
|
+
console.log("");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
main().catch(console.error);
|