aavegotchi-cli 0.2.2 → 0.2.5
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/CHANGELOG.md +40 -0
- package/README.md +28 -3
- package/dist/command-catalog.js +7 -5
- package/dist/command-runner.js +13 -0
- package/dist/commands/auction-bid.js +815 -0
- package/dist/commands/bootstrap.js +5 -0
- package/dist/commands/mapped-defaults.js +242 -0
- package/dist/commands/mapped.js +14 -1
- package/dist/commands/onchain.js +33 -4
- package/dist/commands/profile.js +1 -0
- package/dist/commands/signer.js +3 -0
- package/dist/commands/tx.js +3 -0
- package/dist/output.js +86 -11
- package/dist/profile-env.js +172 -0
- package/dist/schemas.js +1 -0
- package/dist/signer.js +1 -6
- package/dist/subgraph/sources.js +4 -1
- package/dist/tx-engine.js +56 -1
- package/package.json +1 -1
|
@@ -0,0 +1,172 @@
|
|
|
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
|
+
exports.applySignerEnvironment = applySignerEnvironment;
|
|
37
|
+
exports.applyProfileEnvironment = applyProfileEnvironment;
|
|
38
|
+
const fs = __importStar(require("fs"));
|
|
39
|
+
const os = __importStar(require("os"));
|
|
40
|
+
const path = __importStar(require("path"));
|
|
41
|
+
const config_1 = require("./config");
|
|
42
|
+
const errors_1 = require("./errors");
|
|
43
|
+
function parseAssignment(rawLine, lineNumber, filePath) {
|
|
44
|
+
const trimmed = rawLine.trim();
|
|
45
|
+
if (!trimmed || trimmed.startsWith("#")) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
const withoutExport = trimmed.startsWith("export ") ? trimmed.slice("export ".length).trim() : trimmed;
|
|
49
|
+
const equalsIndex = withoutExport.indexOf("=");
|
|
50
|
+
if (equalsIndex <= 0) {
|
|
51
|
+
throw new errors_1.CliError("INVALID_ENV_FILE", `Invalid env assignment at ${filePath}:${lineNumber}.`, 2, {
|
|
52
|
+
line: rawLine,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
const key = withoutExport.slice(0, equalsIndex).trim();
|
|
56
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(key)) {
|
|
57
|
+
throw new errors_1.CliError("INVALID_ENV_FILE", `Invalid env key '${key}' at ${filePath}:${lineNumber}.`, 2);
|
|
58
|
+
}
|
|
59
|
+
let value = withoutExport.slice(equalsIndex + 1).trim();
|
|
60
|
+
if ((value.startsWith("\"") && value.endsWith("\"") && value.length >= 2) ||
|
|
61
|
+
(value.startsWith("'") && value.endsWith("'") && value.length >= 2)) {
|
|
62
|
+
value = value.slice(1, -1);
|
|
63
|
+
}
|
|
64
|
+
return [key, value];
|
|
65
|
+
}
|
|
66
|
+
function loadEnvAssignments(filePath) {
|
|
67
|
+
const raw = fs.readFileSync(filePath, "utf8");
|
|
68
|
+
const lines = raw.split(/\r?\n/);
|
|
69
|
+
const assignments = [];
|
|
70
|
+
for (let index = 0; index < lines.length; index++) {
|
|
71
|
+
const parsed = parseAssignment(lines[index], index + 1, filePath);
|
|
72
|
+
if (parsed) {
|
|
73
|
+
assignments.push(parsed);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return assignments;
|
|
77
|
+
}
|
|
78
|
+
function resolveEnvPath(envFile, customHome) {
|
|
79
|
+
if (envFile.startsWith("~/")) {
|
|
80
|
+
return path.join(os.homedir(), envFile.slice(2));
|
|
81
|
+
}
|
|
82
|
+
if (path.isAbsolute(envFile)) {
|
|
83
|
+
return envFile;
|
|
84
|
+
}
|
|
85
|
+
return path.resolve((0, config_1.resolveAgcliHome)(customHome), envFile);
|
|
86
|
+
}
|
|
87
|
+
function applyEnvFromPath(source, envPath, searched) {
|
|
88
|
+
const loaded = [];
|
|
89
|
+
const skippedExisting = [];
|
|
90
|
+
const assignments = loadEnvAssignments(envPath);
|
|
91
|
+
for (const [key, value] of assignments) {
|
|
92
|
+
if (process.env[key] === undefined) {
|
|
93
|
+
process.env[key] = value;
|
|
94
|
+
loaded.push(key);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
skippedExisting.push(key);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
source,
|
|
102
|
+
path: envPath,
|
|
103
|
+
loaded,
|
|
104
|
+
skippedExisting,
|
|
105
|
+
...(searched ? { searched } : {}),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function uniquePaths(values) {
|
|
109
|
+
const seen = new Set();
|
|
110
|
+
const result = [];
|
|
111
|
+
for (const value of values) {
|
|
112
|
+
const normalized = path.resolve(value);
|
|
113
|
+
if (!seen.has(normalized)) {
|
|
114
|
+
seen.add(normalized);
|
|
115
|
+
result.push(normalized);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
120
|
+
function buildBankrAutoCandidates(customHome) {
|
|
121
|
+
const home = (0, config_1.resolveAgcliHome)(customHome);
|
|
122
|
+
const configured = process.env.AGCLI_BANKR_ENV_FILE;
|
|
123
|
+
const cwd = process.cwd();
|
|
124
|
+
return uniquePaths([
|
|
125
|
+
configured || "",
|
|
126
|
+
path.join(home, "bankr.env"),
|
|
127
|
+
path.join(home, ".env.bankr"),
|
|
128
|
+
path.join(os.homedir(), ".config/openclaw/bankr.env"),
|
|
129
|
+
path.join(cwd, ".env.bankr"),
|
|
130
|
+
path.join(cwd, "bankr.env"),
|
|
131
|
+
].filter(Boolean));
|
|
132
|
+
}
|
|
133
|
+
function applySignerEnvironment(signer, options) {
|
|
134
|
+
const explicitEnvFile = options?.envFile?.trim();
|
|
135
|
+
if (explicitEnvFile) {
|
|
136
|
+
const resolvedPath = resolveEnvPath(explicitEnvFile, options?.customHome);
|
|
137
|
+
if (!fs.existsSync(resolvedPath)) {
|
|
138
|
+
throw new errors_1.CliError("ENV_FILE_NOT_FOUND", `Environment file not found: ${resolvedPath}`, 2, {
|
|
139
|
+
envFile: explicitEnvFile,
|
|
140
|
+
resolvedPath,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
return applyEnvFromPath("profile", resolvedPath);
|
|
144
|
+
}
|
|
145
|
+
if (signer.type !== "bankr") {
|
|
146
|
+
return {
|
|
147
|
+
source: "none",
|
|
148
|
+
path: null,
|
|
149
|
+
loaded: [],
|
|
150
|
+
skippedExisting: [],
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
const searched = buildBankrAutoCandidates(options?.customHome);
|
|
154
|
+
for (const candidate of searched) {
|
|
155
|
+
if (fs.existsSync(candidate)) {
|
|
156
|
+
return applyEnvFromPath("auto", candidate, searched);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return {
|
|
160
|
+
source: "none",
|
|
161
|
+
path: null,
|
|
162
|
+
loaded: [],
|
|
163
|
+
skippedExisting: [],
|
|
164
|
+
searched,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
function applyProfileEnvironment(profile, customHome) {
|
|
168
|
+
return applySignerEnvironment(profile.signer, {
|
|
169
|
+
envFile: profile.envFile,
|
|
170
|
+
customHome,
|
|
171
|
+
});
|
|
172
|
+
}
|
package/dist/schemas.js
CHANGED
|
@@ -45,6 +45,7 @@ exports.profileSchema = zod_1.z.object({
|
|
|
45
45
|
chainId: zod_1.z.number().int().positive(),
|
|
46
46
|
rpcUrl: zod_1.z.string().url(),
|
|
47
47
|
signer: exports.signerSchema,
|
|
48
|
+
envFile: zod_1.z.string().min(1).optional(),
|
|
48
49
|
policy: zod_1.z.string().min(1),
|
|
49
50
|
createdAt: zod_1.z.string().datetime(),
|
|
50
51
|
updatedAt: zod_1.z.string().datetime(),
|
package/dist/signer.js
CHANGED
|
@@ -467,20 +467,15 @@ async function resolveSignerRuntime(signer, publicClient, rpcUrl, chain, customH
|
|
|
467
467
|
return {
|
|
468
468
|
summary,
|
|
469
469
|
sendTransaction: async (request) => {
|
|
470
|
+
// Bankr expects a minimal transaction schema for /agent/submit.
|
|
470
471
|
const payload = {
|
|
471
472
|
transaction: {
|
|
472
473
|
chainId: request.chain.id,
|
|
473
|
-
from: address,
|
|
474
474
|
to: request.to,
|
|
475
475
|
data: request.data,
|
|
476
476
|
value: request.value?.toString() || "0",
|
|
477
|
-
gas: request.gas.toString(),
|
|
478
|
-
nonce: request.nonce,
|
|
479
|
-
maxFeePerGas: request.maxFeePerGas?.toString(),
|
|
480
|
-
maxPriorityFeePerGas: request.maxPriorityFeePerGas?.toString(),
|
|
481
477
|
},
|
|
482
478
|
waitForConfirmation: false,
|
|
483
|
-
description: "Submitted via aavegotchi-cli",
|
|
484
479
|
};
|
|
485
480
|
const response = await fetchBankrJson(addDefaultPaths(apiUrl, BANKR_AGENT_SUBMIT_PATH), {
|
|
486
481
|
method: "POST",
|
package/dist/subgraph/sources.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BASE_GBM_DIAMOND = exports.BASE_AAVEGOTCHI_DIAMOND = exports.GBM_BASE_ENDPOINT = exports.CORE_BASE_ENDPOINT = void 0;
|
|
3
|
+
exports.BASE_MERKLE_DISTRIBUTOR = exports.BASE_GLTR_STAKING = exports.BASE_FORGE_DIAMOND = exports.BASE_GBM_DIAMOND = exports.BASE_AAVEGOTCHI_DIAMOND = exports.GBM_BASE_ENDPOINT = exports.CORE_BASE_ENDPOINT = void 0;
|
|
4
4
|
exports.listSubgraphSources = listSubgraphSources;
|
|
5
5
|
exports.parseSubgraphSourceAlias = parseSubgraphSourceAlias;
|
|
6
6
|
exports.resolveSubgraphEndpoint = resolveSubgraphEndpoint;
|
|
@@ -9,6 +9,9 @@ exports.CORE_BASE_ENDPOINT = "https://api.goldsky.com/api/public/project_cmh3fla
|
|
|
9
9
|
exports.GBM_BASE_ENDPOINT = "https://api.goldsky.com/api/public/project_cmh3flagm0001r4p25foufjtt/subgraphs/aavegotchi-gbm-baazaar-base/prod/gn";
|
|
10
10
|
exports.BASE_AAVEGOTCHI_DIAMOND = "0xa99c4b08201f2913db8d28e71d020c4298f29dbf";
|
|
11
11
|
exports.BASE_GBM_DIAMOND = "0x80320a0000c7a6a34086e2acad6915ff57ffda31";
|
|
12
|
+
exports.BASE_FORGE_DIAMOND = "0x50af2d63b839aa32b4166fd1cb247129b715186c";
|
|
13
|
+
exports.BASE_GLTR_STAKING = "0xab449dca14413a6ae0bcea9ea210b57ace280d2c";
|
|
14
|
+
exports.BASE_MERKLE_DISTRIBUTOR = "0xf50326e1a6c6949cc390c4efe8ea538e29a4fa11";
|
|
12
15
|
const SOURCE_MAP = {
|
|
13
16
|
"core-base": {
|
|
14
17
|
alias: "core-base",
|
package/dist/tx-engine.js
CHANGED
|
@@ -39,6 +39,57 @@ function mapJournalToResult(entry) {
|
|
|
39
39
|
receipt,
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
|
+
function extractErrorMessage(error) {
|
|
43
|
+
if (typeof error === "string") {
|
|
44
|
+
return error;
|
|
45
|
+
}
|
|
46
|
+
if (error instanceof Error) {
|
|
47
|
+
const typed = error;
|
|
48
|
+
return typed.shortMessage || typed.details || typed.message;
|
|
49
|
+
}
|
|
50
|
+
if (typeof error === "object" && error !== null) {
|
|
51
|
+
const maybe = error;
|
|
52
|
+
if (typeof maybe.shortMessage === "string") {
|
|
53
|
+
return maybe.shortMessage;
|
|
54
|
+
}
|
|
55
|
+
if (typeof maybe.message === "string") {
|
|
56
|
+
return maybe.message;
|
|
57
|
+
}
|
|
58
|
+
if (typeof maybe.details === "string") {
|
|
59
|
+
return maybe.details;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return String(error);
|
|
63
|
+
}
|
|
64
|
+
function classifySimulationRevert(message) {
|
|
65
|
+
const normalized = message.toLowerCase();
|
|
66
|
+
if (normalized.includes("allowance")) {
|
|
67
|
+
return {
|
|
68
|
+
reasonCode: "INSUFFICIENT_ALLOWANCE",
|
|
69
|
+
reason: "Allowance is below required token spend.",
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
if ((normalized.includes("bid") && normalized.includes("low")) || normalized.includes("start bid")) {
|
|
73
|
+
return {
|
|
74
|
+
reasonCode: "BID_BELOW_START",
|
|
75
|
+
reason: "Bid amount is below minimum threshold.",
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
if (normalized.includes("auction") &&
|
|
79
|
+
(normalized.includes("ended") ||
|
|
80
|
+
normalized.includes("state") ||
|
|
81
|
+
normalized.includes("not active") ||
|
|
82
|
+
normalized.includes("already"))) {
|
|
83
|
+
return {
|
|
84
|
+
reasonCode: "AUCTION_STATE_CHANGED",
|
|
85
|
+
reason: "Auction state changed before execution.",
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
reasonCode: "UNKNOWN_REVERT",
|
|
90
|
+
reason: "Revert reason could not be classified.",
|
|
91
|
+
};
|
|
92
|
+
}
|
|
42
93
|
async function resolveNonce(intent, ctx, address) {
|
|
43
94
|
if (intent.noncePolicy === "manual") {
|
|
44
95
|
if (intent.nonce === undefined) {
|
|
@@ -117,8 +168,12 @@ async function executeTxIntent(intent, chain, customHome) {
|
|
|
117
168
|
});
|
|
118
169
|
}
|
|
119
170
|
catch (error) {
|
|
171
|
+
const message = extractErrorMessage(error);
|
|
172
|
+
const classified = classifySimulationRevert(message);
|
|
120
173
|
throw new errors_1.CliError("SIMULATION_REVERT", "Transaction simulation reverted.", 2, {
|
|
121
|
-
message
|
|
174
|
+
message,
|
|
175
|
+
reasonCode: classified.reasonCode,
|
|
176
|
+
reason: classified.reason,
|
|
122
177
|
});
|
|
123
178
|
}
|
|
124
179
|
const gasLimit = await preflight.client.estimateGas({
|