vana-cli 0.15.1 → 0.23.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 +73 -15
- package/dist/cli/app/ask.d.ts +38 -0
- package/dist/cli/app/ask.d.ts.map +1 -0
- package/dist/cli/app/ask.js +110 -0
- package/dist/cli/app/ask.js.map +1 -0
- package/dist/cli/app/derivatives.d.ts +41 -0
- package/dist/cli/app/derivatives.d.ts.map +1 -0
- package/dist/cli/app/derivatives.js +227 -0
- package/dist/cli/app/derivatives.js.map +1 -0
- package/dist/cli/app/escrow.d.ts +44 -0
- package/dist/cli/app/escrow.d.ts.map +1 -0
- package/dist/cli/app/escrow.js +275 -0
- package/dist/cli/app/escrow.js.map +1 -0
- package/dist/cli/app/index.d.ts +11 -0
- package/dist/cli/app/index.d.ts.map +1 -0
- package/dist/cli/app/index.js +151 -0
- package/dist/cli/app/index.js.map +1 -0
- package/dist/cli/app/onchain.d.ts +14 -0
- package/dist/cli/app/onchain.d.ts.map +1 -0
- package/dist/cli/app/onchain.js +84 -0
- package/dist/cli/app/onchain.js.map +1 -0
- package/dist/cli/app/outcome.d.ts +45 -0
- package/dist/cli/app/outcome.d.ts.map +1 -0
- package/dist/cli/app/outcome.js +55 -0
- package/dist/cli/app/outcome.js.map +1 -0
- package/dist/cli/app/read.d.ts +43 -0
- package/dist/cli/app/read.d.ts.map +1 -0
- package/dist/cli/app/read.js +429 -0
- package/dist/cli/app/read.js.map +1 -0
- package/dist/cli/app/register.d.ts +34 -0
- package/dist/cli/app/register.d.ts.map +1 -0
- package/dist/cli/app/register.js +113 -0
- package/dist/cli/app/register.js.map +1 -0
- package/dist/cli/app/request.d.ts +50 -0
- package/dist/cli/app/request.d.ts.map +1 -0
- package/dist/cli/app/request.js +252 -0
- package/dist/cli/app/request.js.map +1 -0
- package/dist/cli/app/requests.d.ts +21 -0
- package/dist/cli/app/requests.d.ts.map +1 -0
- package/dist/cli/app/requests.js +163 -0
- package/dist/cli/app/requests.js.map +1 -0
- package/dist/cli/app/whoami.d.ts +13 -0
- package/dist/cli/app/whoami.d.ts.map +1 -0
- package/dist/cli/app/whoami.js +71 -0
- package/dist/cli/app/whoami.js.map +1 -0
- package/dist/cli/auth.d.ts +18 -0
- package/dist/cli/auth.d.ts.map +1 -1
- package/dist/cli/auth.js +82 -4
- package/dist/cli/auth.js.map +1 -1
- package/dist/cli/index.d.ts +2 -2
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +304 -54
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/mcp-server.d.ts.map +1 -1
- package/dist/cli/mcp-server.js +32 -3
- package/dist/cli/mcp-server.js.map +1 -1
- package/dist/core/app-key.d.ts +50 -0
- package/dist/core/app-key.d.ts.map +1 -0
- package/dist/core/app-key.js +171 -0
- package/dist/core/app-key.js.map +1 -0
- package/dist/core/assets.d.ts +33 -0
- package/dist/core/assets.d.ts.map +1 -0
- package/dist/core/assets.js +87 -0
- package/dist/core/assets.js.map +1 -0
- package/dist/core/cli-types.d.ts +30 -0
- package/dist/core/cli-types.d.ts.map +1 -1
- package/dist/core/cli-types.js +16 -0
- package/dist/core/cli-types.js.map +1 -1
- package/dist/core/exit-codes.d.ts +48 -0
- package/dist/core/exit-codes.d.ts.map +1 -0
- package/dist/core/exit-codes.js +96 -0
- package/dist/core/exit-codes.js.map +1 -0
- package/dist/core/network.d.ts +52 -0
- package/dist/core/network.d.ts.map +1 -0
- package/dist/core/network.js +83 -0
- package/dist/core/network.js.map +1 -0
- package/dist/core/paths.d.ts +4 -2
- package/dist/core/paths.d.ts.map +1 -1
- package/dist/core/paths.js +8 -6
- package/dist/core/paths.js.map +1 -1
- package/dist/core/receipts.d.ts +37 -0
- package/dist/core/receipts.d.ts.map +1 -0
- package/dist/core/receipts.js +72 -0
- package/dist/core/receipts.js.map +1 -0
- package/dist/core/requests-store.d.ts +54 -0
- package/dist/core/requests-store.d.ts.map +1 -0
- package/dist/core/requests-store.js +83 -0
- package/dist/core/requests-store.js.map +1 -0
- package/dist/personal-server/registered.d.ts +25 -0
- package/dist/personal-server/registered.d.ts.map +1 -0
- package/dist/personal-server/registered.js +49 -0
- package/dist/personal-server/registered.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `vana app escrow balance|fund` - what the app can spend, and funding it.
|
|
3
|
+
*
|
|
4
|
+
* Funding is deliberately one command for both halves: the on-chain
|
|
5
|
+
* `depositNative(account)` transaction and the gateway deposit
|
|
6
|
+
* registration. Either half alone produces a contract that looks funded
|
|
7
|
+
* while every read still answers 402.
|
|
8
|
+
*/
|
|
9
|
+
import { CONTRACTS, createGatewayClient, encodeDepositNativeData, encodeDepositTokenData, } from "@opendatalabs/vana-sdk";
|
|
10
|
+
import { getChainConfig } from "@opendatalabs/vana-sdk/chains";
|
|
11
|
+
import { createPublicClient, createWalletClient, erc20Abi, formatEther, http, } from "viem";
|
|
12
|
+
import { NATIVE_ASSET, formatAssetAmount, parseAssetAmount, resolveAsset, } from "../../core/assets.js";
|
|
13
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
14
|
+
import { AppKeyMissingError, resolveAppKey, } from "../../core/app-key.js";
|
|
15
|
+
import { UnknownNetworkError, resolveNetwork, } from "../../core/network.js";
|
|
16
|
+
import { emitAppOutcome } from "./outcome.js";
|
|
17
|
+
function resolveContext(options, deps) {
|
|
18
|
+
let network;
|
|
19
|
+
try {
|
|
20
|
+
network = resolveNetwork(options.network);
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
if (error instanceof UnknownNetworkError) {
|
|
24
|
+
return {
|
|
25
|
+
ok: false,
|
|
26
|
+
exitCode: emitAppOutcome(options, {
|
|
27
|
+
status: "failed",
|
|
28
|
+
code: "bad_usage",
|
|
29
|
+
message: error.message,
|
|
30
|
+
}),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
const key = (deps.resolveKey ?? resolveAppKey)({});
|
|
37
|
+
return { ok: true, network, key };
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
if (error instanceof AppKeyMissingError) {
|
|
41
|
+
return {
|
|
42
|
+
ok: false,
|
|
43
|
+
exitCode: emitAppOutcome(options, {
|
|
44
|
+
status: "failed",
|
|
45
|
+
code: "bad_usage",
|
|
46
|
+
message: "No app key on this machine yet.",
|
|
47
|
+
remedy: "vana app register",
|
|
48
|
+
network: network.name,
|
|
49
|
+
}),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
throw error;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export async function runAppEscrowBalance(options, deps = {}) {
|
|
56
|
+
const context = resolveContext(options, deps);
|
|
57
|
+
if (!context.ok) {
|
|
58
|
+
return context.exitCode;
|
|
59
|
+
}
|
|
60
|
+
const { network, key } = context;
|
|
61
|
+
const client = (deps.createClient ?? createGatewayClient)(network.gatewayUrl);
|
|
62
|
+
try {
|
|
63
|
+
const balance = await client.getEscrowBalance(key.address);
|
|
64
|
+
// Each entry carries its own asset, and they do not share decimals:
|
|
65
|
+
// native VANA has 18, USDC.e has 6.
|
|
66
|
+
const lines = await Promise.all(balance.balances.map(async (entry) => {
|
|
67
|
+
const info = await resolveAsset(entry.asset, network.rpcUrl);
|
|
68
|
+
return `${formatAssetAmount(entry.availableAmount ?? "0", info)} available`;
|
|
69
|
+
}));
|
|
70
|
+
return emitAppOutcome(options, {
|
|
71
|
+
status: "done",
|
|
72
|
+
code: "ok",
|
|
73
|
+
message: lines.length === 0 ? "Escrow is empty." : lines.join(", "),
|
|
74
|
+
network: network.name,
|
|
75
|
+
data: {
|
|
76
|
+
address: key.address,
|
|
77
|
+
balances: balance.balances,
|
|
78
|
+
deposits: {
|
|
79
|
+
submitted: balance.deposits.submitted.length,
|
|
80
|
+
finalized: balance.deposits.finalized.length,
|
|
81
|
+
failed: balance.deposits.failed.length,
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
return emitAppOutcome(options, {
|
|
88
|
+
status: "failed",
|
|
89
|
+
code: "gateway_unreachable",
|
|
90
|
+
message: `Escrow balance lookup failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
91
|
+
network: network.name,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async function defaultSendDeposit(params) {
|
|
96
|
+
const chain = getChainConfig(params.network.chainId);
|
|
97
|
+
const account = privateKeyToAccount(params.key.privateKey);
|
|
98
|
+
const transport = http(params.network.rpcUrl);
|
|
99
|
+
const publicClient = createPublicClient({ chain, transport });
|
|
100
|
+
const walletClient = createWalletClient({ account, chain, transport });
|
|
101
|
+
const isToken = Boolean(params.asset && params.asset.toLowerCase() !== NATIVE_ASSET);
|
|
102
|
+
if (!isToken) {
|
|
103
|
+
const balance = await publicClient.getBalance({
|
|
104
|
+
address: params.key.address,
|
|
105
|
+
});
|
|
106
|
+
if (balance < params.amountWei) {
|
|
107
|
+
throw new InsufficientFundsError(balance, params.amountWei);
|
|
108
|
+
}
|
|
109
|
+
const txHash = await walletClient.sendTransaction({
|
|
110
|
+
to: params.escrowContract,
|
|
111
|
+
data: encodeDepositNativeData({ account: params.key.address }),
|
|
112
|
+
value: params.amountWei,
|
|
113
|
+
});
|
|
114
|
+
await publicClient.waitForTransactionReceipt({ hash: txHash });
|
|
115
|
+
return { txHash };
|
|
116
|
+
}
|
|
117
|
+
// ERC20 path: the escrow pulls the tokens, so it needs an allowance
|
|
118
|
+
// first. Two transactions, and the approve is skipped when the existing
|
|
119
|
+
// allowance already covers the deposit.
|
|
120
|
+
const token = params.asset;
|
|
121
|
+
const held = (await publicClient.readContract({
|
|
122
|
+
address: token,
|
|
123
|
+
abi: erc20Abi,
|
|
124
|
+
functionName: "balanceOf",
|
|
125
|
+
args: [params.key.address],
|
|
126
|
+
}));
|
|
127
|
+
if (held < params.amountWei) {
|
|
128
|
+
throw new InsufficientFundsError(held, params.amountWei, token);
|
|
129
|
+
}
|
|
130
|
+
const allowance = (await publicClient.readContract({
|
|
131
|
+
address: token,
|
|
132
|
+
abi: erc20Abi,
|
|
133
|
+
functionName: "allowance",
|
|
134
|
+
args: [params.key.address, params.escrowContract],
|
|
135
|
+
}));
|
|
136
|
+
if (allowance < params.amountWei) {
|
|
137
|
+
const approveHash = await walletClient.writeContract({
|
|
138
|
+
address: token,
|
|
139
|
+
abi: erc20Abi,
|
|
140
|
+
functionName: "approve",
|
|
141
|
+
args: [params.escrowContract, params.amountWei],
|
|
142
|
+
});
|
|
143
|
+
await publicClient.waitForTransactionReceipt({ hash: approveHash });
|
|
144
|
+
}
|
|
145
|
+
const txHash = await walletClient.sendTransaction({
|
|
146
|
+
to: params.escrowContract,
|
|
147
|
+
data: encodeDepositTokenData({
|
|
148
|
+
account: params.key.address,
|
|
149
|
+
token,
|
|
150
|
+
amount: params.amountWei,
|
|
151
|
+
}),
|
|
152
|
+
});
|
|
153
|
+
await publicClient.waitForTransactionReceipt({ hash: txHash });
|
|
154
|
+
return { txHash };
|
|
155
|
+
}
|
|
156
|
+
export class InsufficientFundsError extends Error {
|
|
157
|
+
balanceWei;
|
|
158
|
+
neededWei;
|
|
159
|
+
asset;
|
|
160
|
+
constructor(balanceWei, neededWei, asset) {
|
|
161
|
+
super(asset
|
|
162
|
+
? `Wallet holds ${balanceWei} base units of ${asset}, needs ${neededWei}`
|
|
163
|
+
: `Wallet holds ${formatEther(balanceWei)} VANA, needs ${formatEther(neededWei)} plus gas`);
|
|
164
|
+
this.balanceWei = balanceWei;
|
|
165
|
+
this.neededWei = neededWei;
|
|
166
|
+
this.asset = asset;
|
|
167
|
+
this.name = "InsufficientFundsError";
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
export async function runAppEscrowFund(options, deps = {}) {
|
|
171
|
+
const context = resolveContext(options, deps);
|
|
172
|
+
if (!context.ok) {
|
|
173
|
+
return context.exitCode;
|
|
174
|
+
}
|
|
175
|
+
const { network, key } = context;
|
|
176
|
+
// The amount is denominated in the chosen asset, not always in VANA.
|
|
177
|
+
const asset = await resolveAsset(options.asset, network.rpcUrl);
|
|
178
|
+
if (options.asset && !asset) {
|
|
179
|
+
return emitAppOutcome(options, {
|
|
180
|
+
status: "failed",
|
|
181
|
+
code: "bad_usage",
|
|
182
|
+
message: `Cannot read decimals for asset ${options.asset} on ${network.name}.`,
|
|
183
|
+
network: network.name,
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
const parsedAmount = parseAssetAmount(options.amount ?? "", asset);
|
|
187
|
+
if (parsedAmount === null || parsedAmount <= 0n) {
|
|
188
|
+
return emitAppOutcome(options, {
|
|
189
|
+
status: "failed",
|
|
190
|
+
code: "bad_usage",
|
|
191
|
+
message: `A positive --amount in ${asset?.symbol ?? "VANA"} is required.`,
|
|
192
|
+
remedy: "vana app escrow fund --amount 0.5",
|
|
193
|
+
network: network.name,
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
const amountWei = parsedAmount;
|
|
197
|
+
if (network.name === "mainnet" && !options.yes) {
|
|
198
|
+
return emitAppOutcome(options, {
|
|
199
|
+
status: "failed",
|
|
200
|
+
code: "confirmation_required",
|
|
201
|
+
message: `This deposits ${options.amount} real ${asset?.symbol ?? "VANA"} on mainnet.`,
|
|
202
|
+
remedy: `re-run with --yes to confirm`,
|
|
203
|
+
network: network.name,
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
const escrowContract = CONTRACTS.DataPortabilityEscrow.addresses[network.chainId];
|
|
207
|
+
if (!escrowContract) {
|
|
208
|
+
return emitAppOutcome(options, {
|
|
209
|
+
status: "failed",
|
|
210
|
+
code: "internal",
|
|
211
|
+
message: `No escrow contract known for chain ${network.chainId}.`,
|
|
212
|
+
network: network.name,
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
let txHash;
|
|
216
|
+
try {
|
|
217
|
+
({ txHash } = await (deps.sendDeposit ?? defaultSendDeposit)({
|
|
218
|
+
network,
|
|
219
|
+
key,
|
|
220
|
+
escrowContract,
|
|
221
|
+
amountWei,
|
|
222
|
+
asset: options.asset,
|
|
223
|
+
}));
|
|
224
|
+
}
|
|
225
|
+
catch (error) {
|
|
226
|
+
if (error instanceof InsufficientFundsError) {
|
|
227
|
+
return emitAppOutcome(options, {
|
|
228
|
+
status: "failed",
|
|
229
|
+
code: "payment_required",
|
|
230
|
+
message: error.message,
|
|
231
|
+
remedy: network.name === "moksha"
|
|
232
|
+
? "fund the app wallet from the Moksha faucet: https://faucet.vana.org"
|
|
233
|
+
: `send VANA to ${key.address}`,
|
|
234
|
+
network: network.name,
|
|
235
|
+
data: { address: key.address },
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
return emitAppOutcome(options, {
|
|
239
|
+
status: "failed",
|
|
240
|
+
code: "internal",
|
|
241
|
+
message: `On-chain deposit failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
242
|
+
network: network.name,
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
// Second half: tell the gateway about the deposit. Idempotent to re-run;
|
|
246
|
+
// a crash between halves is recoverable by re-running fund (the on-chain
|
|
247
|
+
// half will fail on balance, but submit can be redone via the txHash we
|
|
248
|
+
// print).
|
|
249
|
+
const client = (deps.createClient ?? createGatewayClient)(network.gatewayUrl);
|
|
250
|
+
try {
|
|
251
|
+
const state = await client.submitEscrowDeposit({ txHash });
|
|
252
|
+
return emitAppOutcome(options, {
|
|
253
|
+
status: "done",
|
|
254
|
+
code: "ok",
|
|
255
|
+
message: `Deposited ${options.amount} ${asset?.symbol ?? "VANA"} into escrow.`,
|
|
256
|
+
network: network.name,
|
|
257
|
+
data: {
|
|
258
|
+
txHash,
|
|
259
|
+
gatewayStatus: state.status,
|
|
260
|
+
explorer: `${network.explorerUrl}/tx/${txHash}`,
|
|
261
|
+
},
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
catch (error) {
|
|
265
|
+
return emitAppOutcome(options, {
|
|
266
|
+
status: "failed",
|
|
267
|
+
code: "gateway_unreachable",
|
|
268
|
+
message: `On-chain deposit ${txHash} confirmed, but the gateway registration failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
269
|
+
remedy: `re-run: the deposit is on chain, only the gateway half is missing (tx ${txHash})`,
|
|
270
|
+
network: network.name,
|
|
271
|
+
data: { txHash },
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
//# sourceMappingURL=escrow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"escrow.js","sourceRoot":"","sources":["../../../src/cli/app/escrow.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,uBAAuB,EACvB,sBAAsB,GAEvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,QAAQ,EACR,WAAW,EACX,IAAI,GACL,MAAM,MAAM,CAAC;AACd,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,GACb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EACL,kBAAkB,EAClB,aAAa,GAEd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,mBAAmB,EACnB,cAAc,GAEf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,cAAc,EAA0B,MAAM,cAAc,CAAC;AAyBtE,SAAS,cAAc,CACrB,OAA0B,EAC1B,IAAgB;IAIhB,IAAI,OAAwB,CAAC;IAC7B,IAAI,CAAC;QACH,OAAO,GAAG,cAAc,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IA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M,MAAM,GAAG,CAAC,IAAI,CAAC,YAAY,IAAI,mBAAmB,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC9E,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;QAC3D,OAAO,cAAc,CAAC,OAAO,EAAE;YAC7B,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI;YACV,OAAO,EAAE,aAAa,OAAO,CAAC,MAAM,IAAI,KAAK,EAAE,MAAM,IAAI,MAAM,eAAe;YAC9E,OAAO,EAAE,OAAO,CAAC,IAAI;YACrB,IAAI,EAAE;gBACJ,MAAM;gBACN,aAAa,EAAE,KAAK,CAAC,MAAM;gBAC3B,QAAQ,EAAE,GAAG,OAAO,CAAC,WAAW,OAAO,MAAM,EAAE;aAChD;SACF,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,cAAc,CAAC,OAAO,EAAE;YAC7B,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,qBAAqB;YAC3B,OAAO,EAAE,oBAAoB,MAAM,oDACjC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CACvD,EAAE;YACF,MAAM,EAAE,yEAAyE,MAAM,GAAG;YAC1F,OAAO,EAAE,OAAO,CAAC,IAAI;YACrB,IAAI,EAAE,EAAE,MAAM,EAAE;SACjB,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registration of the `vana app` builder command group.
|
|
3
|
+
*
|
|
4
|
+
* Only the commands that need no pending protocol decision are here:
|
|
5
|
+
* `register` and `whoami`. The consent flow (`request`, `requests`), the
|
|
6
|
+
* read loop, derivatives and write land as their milestones clear.
|
|
7
|
+
*/
|
|
8
|
+
import type { Command } from "commander";
|
|
9
|
+
import type { AppCommandOptions } from "./outcome.js";
|
|
10
|
+
export declare function registerAppCommands(program: Command, getOptions: () => AppCommandOptions): void;
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/app/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUzC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtD,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,iBAAiB,GAClC,IAAI,CA2KN"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registration of the `vana app` builder command group.
|
|
3
|
+
*
|
|
4
|
+
* Only the commands that need no pending protocol decision are here:
|
|
5
|
+
* `register` and `whoami`. The consent flow (`request`, `requests`), the
|
|
6
|
+
* read loop, derivatives and write land as their milestones clear.
|
|
7
|
+
*/
|
|
8
|
+
import { runAppEscrowBalance, runAppEscrowFund } from "./escrow.js";
|
|
9
|
+
import { runAppOnchain } from "./onchain.js";
|
|
10
|
+
import { runAppRead } from "./read.js";
|
|
11
|
+
import { runAppAsk } from "./ask.js";
|
|
12
|
+
import { runAppLineage, runAppStatus } from "./derivatives.js";
|
|
13
|
+
import { runAppRegister } from "./register.js";
|
|
14
|
+
import { runAppRequest } from "./request.js";
|
|
15
|
+
import { runAppRequestsList, runAppRequestsShow } from "./requests.js";
|
|
16
|
+
import { runAppWhoami } from "./whoami.js";
|
|
17
|
+
export function registerAppCommands(program, getOptions) {
|
|
18
|
+
const app = program
|
|
19
|
+
.command("app")
|
|
20
|
+
.description("Builder-side protocol operations");
|
|
21
|
+
app
|
|
22
|
+
.command("register")
|
|
23
|
+
.description("Register this app as a builder at the gateway (idempotent)")
|
|
24
|
+
.option("--app-url <url>", "Public URL stored on the builder record")
|
|
25
|
+
.action(async (commandOptions) => {
|
|
26
|
+
process.exitCode = await runAppRegister({
|
|
27
|
+
...getOptions(),
|
|
28
|
+
appUrl: commandOptions.appUrl,
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
app
|
|
32
|
+
.command("request")
|
|
33
|
+
.description("Ask a person for access and wait for the grant")
|
|
34
|
+
.option("--scopes <list>", "Comma-separated scopes to request")
|
|
35
|
+
.option("--question <text>", "Derivative question to carry on the request")
|
|
36
|
+
.option("--derived <scope>", "Scope the answer is written to")
|
|
37
|
+
.option("--sources <list>", "Comma-separated scopes the answer is computed from")
|
|
38
|
+
.option("--return-url <url>", "Where approval returns the person")
|
|
39
|
+
.option("--timeout <seconds>", "How long to wait for approval (default 600)")
|
|
40
|
+
.option("--app-id <id>", "App id shown during approval")
|
|
41
|
+
.option("--app-name <name>", "App name shown during approval")
|
|
42
|
+
.option("--app-url <url>", "App homepage shown during approval")
|
|
43
|
+
.action(async (commandOptions) => {
|
|
44
|
+
process.exitCode = await runAppRequest({
|
|
45
|
+
...getOptions(),
|
|
46
|
+
...commandOptions,
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
const requests = app
|
|
50
|
+
.command("requests")
|
|
51
|
+
.description("Access requests created from this machine");
|
|
52
|
+
requests
|
|
53
|
+
.command("list")
|
|
54
|
+
.description("List access requests this machine created")
|
|
55
|
+
.action(async () => {
|
|
56
|
+
process.exitCode = await runAppRequestsList(getOptions());
|
|
57
|
+
});
|
|
58
|
+
requests
|
|
59
|
+
.command("show <requestId>")
|
|
60
|
+
.description("Show one access request, refreshed from the service")
|
|
61
|
+
.action(async (requestId) => {
|
|
62
|
+
process.exitCode = await runAppRequestsShow(requestId, getOptions());
|
|
63
|
+
});
|
|
64
|
+
app
|
|
65
|
+
.command("read <scope>")
|
|
66
|
+
.description("Read granted data from the owner's Personal Server")
|
|
67
|
+
.option("--grant <id>", "Grant id covering the scope")
|
|
68
|
+
.option("--pay", "Settle a 402 payment from escrow")
|
|
69
|
+
.option("--max-fee <vana>", "Refuse fees above this amount, in VANA")
|
|
70
|
+
.option("--server <url>", "Explicit Personal Server URL")
|
|
71
|
+
.action(async (scope, commandOptions) => {
|
|
72
|
+
process.exitCode = await runAppRead(scope, {
|
|
73
|
+
...getOptions(),
|
|
74
|
+
...commandOptions,
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
const escrow = app
|
|
78
|
+
.command("escrow")
|
|
79
|
+
.description("Escrow balance and funding for paid reads");
|
|
80
|
+
escrow
|
|
81
|
+
.command("balance")
|
|
82
|
+
.description("What the app can spend from escrow")
|
|
83
|
+
.action(async () => {
|
|
84
|
+
process.exitCode = await runAppEscrowBalance(getOptions());
|
|
85
|
+
});
|
|
86
|
+
escrow
|
|
87
|
+
.command("fund")
|
|
88
|
+
.description("Deposit VANA into escrow (on-chain tx + gateway registration)")
|
|
89
|
+
.option("--amount <amount>", "Amount to deposit, in the asset's units")
|
|
90
|
+
.option("--asset <address>", "ERC20 to deposit instead of native VANA")
|
|
91
|
+
.action(async (commandOptions) => {
|
|
92
|
+
process.exitCode = await runAppEscrowFund({
|
|
93
|
+
...getOptions(),
|
|
94
|
+
...commandOptions,
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
app
|
|
98
|
+
.command("onchain <scope>")
|
|
99
|
+
.description("On-chain trace of a data point (version, hashes, deletion)")
|
|
100
|
+
.option("--owner <address>", "Data owner address")
|
|
101
|
+
.action(async (scope, commandOptions) => {
|
|
102
|
+
process.exitCode = await runAppOnchain(scope, {
|
|
103
|
+
...getOptions(),
|
|
104
|
+
...commandOptions,
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
app
|
|
108
|
+
.command("ask <question>")
|
|
109
|
+
.description("Ask a question about a person's data, through consent")
|
|
110
|
+
.option("--sources <list>", "Comma-separated scopes the answer is computed from")
|
|
111
|
+
.option("--derived <scope>", "Scope the answer is written to")
|
|
112
|
+
.option("--pay", "Settle the derived-scope read from escrow")
|
|
113
|
+
.option("--max-fee <amount>", "Refuse fees above this, in the fee's asset")
|
|
114
|
+
.option("--timeout <seconds>", "How long to wait for approval")
|
|
115
|
+
.option("--registered", "Use the builder-registered path instead of consent")
|
|
116
|
+
.action(async (question, commandOptions) => {
|
|
117
|
+
process.exitCode = await runAppAsk(question, {
|
|
118
|
+
...getOptions(),
|
|
119
|
+
...commandOptions,
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
app
|
|
123
|
+
.command("status <derivedScope>")
|
|
124
|
+
.description("Is the answer coming, and when")
|
|
125
|
+
.option("--grant <id>", "Grant covering the derived scope")
|
|
126
|
+
.option("--server <url>", "Personal Server URL")
|
|
127
|
+
.action(async (derivedScope, commandOptions) => {
|
|
128
|
+
process.exitCode = await runAppStatus(derivedScope, {
|
|
129
|
+
...getOptions(),
|
|
130
|
+
...commandOptions,
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
app
|
|
134
|
+
.command("lineage <scope>")
|
|
135
|
+
.description("Where an answer came from, redacted where it must be")
|
|
136
|
+
.option("--grant <id>", "Grant covering the scope")
|
|
137
|
+
.option("--server <url>", "Personal Server URL")
|
|
138
|
+
.action(async (scope, commandOptions) => {
|
|
139
|
+
process.exitCode = await runAppLineage(scope, {
|
|
140
|
+
...getOptions(),
|
|
141
|
+
...commandOptions,
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
app
|
|
145
|
+
.command("whoami")
|
|
146
|
+
.description("Show the app identity, key source and registration state")
|
|
147
|
+
.action(async () => {
|
|
148
|
+
process.exitCode = await runAppWhoami(getOptions());
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cli/app/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAA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AAC;SACjB,WAAW,CAAC,0DAA0D,CAAC;SACvE,MAAM,CAAC,KAAK,IAAI,EAAE;QACjB,OAAO,CAAC,QAAQ,GAAG,MAAM,YAAY,CAAC,UAAU,EAAE,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `vana app onchain <scope> --owner <address>` - the on-chain trace of a
|
|
3
|
+
* data point: id, version, hashes, when it landed, whether it was deleted.
|
|
4
|
+
*/
|
|
5
|
+
import { type GatewayClient } from "@opendatalabs/vana-sdk";
|
|
6
|
+
import { type AppCommandOptions } from "./outcome.js";
|
|
7
|
+
export interface OnchainCommandOptions extends AppCommandOptions {
|
|
8
|
+
owner?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface OnchainDeps {
|
|
11
|
+
createClient?: (gatewayUrl: string) => GatewayClient;
|
|
12
|
+
}
|
|
13
|
+
export declare function runAppOnchain(scope: string, options: OnchainCommandOptions, deps?: OnchainDeps): Promise<number>;
|
|
14
|
+
//# sourceMappingURL=onchain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onchain.d.ts","sourceRoot":"","sources":["../../../src/cli/app/onchain.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,wBAAwB,CAAC;AAOhC,OAAO,EAAkB,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtE,MAAM,WAAW,qBAAsB,SAAQ,iBAAiB;IAC9D,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,WAAW;IAC1B,YAAY,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,aAAa,CAAC;CACtD;AAED,wBAAsB,aAAa,CACjC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,qBAAqB,EAC9B,IAAI,GAAE,WAAgB,GACrB,OAAO,CAAC,MAAM,CAAC,CA8EjB"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `vana app onchain <scope> --owner <address>` - the on-chain trace of a
|
|
3
|
+
* data point: id, version, hashes, when it landed, whether it was deleted.
|
|
4
|
+
*/
|
|
5
|
+
import { DataPointDeletedError, createGatewayClient, deriveDataPointId, } from "@opendatalabs/vana-sdk";
|
|
6
|
+
import { isAddress } from "viem";
|
|
7
|
+
import { UnknownNetworkError, resolveNetwork, } from "../../core/network.js";
|
|
8
|
+
import { emitAppOutcome } from "./outcome.js";
|
|
9
|
+
export async function runAppOnchain(scope, options, deps = {}) {
|
|
10
|
+
let network;
|
|
11
|
+
try {
|
|
12
|
+
network = resolveNetwork(options.network);
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
if (error instanceof UnknownNetworkError) {
|
|
16
|
+
return emitAppOutcome(options, {
|
|
17
|
+
status: "failed",
|
|
18
|
+
code: "bad_usage",
|
|
19
|
+
message: error.message,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
throw error;
|
|
23
|
+
}
|
|
24
|
+
if (!options.owner || !isAddress(options.owner)) {
|
|
25
|
+
return emitAppOutcome(options, {
|
|
26
|
+
status: "failed",
|
|
27
|
+
code: "bad_usage",
|
|
28
|
+
message: "An --owner address is required (the data point id derives from owner + scope).",
|
|
29
|
+
remedy: `vana app onchain ${scope} --owner 0x...`,
|
|
30
|
+
network: network.name,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
const dataPointId = deriveDataPointId(options.owner, scope);
|
|
34
|
+
const client = (deps.createClient ?? createGatewayClient)(network.gatewayUrl);
|
|
35
|
+
try {
|
|
36
|
+
const record = await client.getDataPoint(dataPointId, {
|
|
37
|
+
includeDeleted: true,
|
|
38
|
+
});
|
|
39
|
+
if (!record) {
|
|
40
|
+
return emitAppOutcome(options, {
|
|
41
|
+
status: "failed",
|
|
42
|
+
code: "scope_not_found",
|
|
43
|
+
message: `No data point for ${scope} under ${options.owner} on ${network.name}.`,
|
|
44
|
+
network: network.name,
|
|
45
|
+
data: { dataPointId },
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return emitAppOutcome(options, {
|
|
49
|
+
status: "done",
|
|
50
|
+
code: "ok",
|
|
51
|
+
message: record.deletedAt
|
|
52
|
+
? `Data point exists but was deleted at ${record.deletedAt}.`
|
|
53
|
+
: `Version ${record.expectedVersion}, registered ${record.addedAt}.`,
|
|
54
|
+
network: network.name,
|
|
55
|
+
data: {
|
|
56
|
+
dataPointId,
|
|
57
|
+
owner: record.ownerAddress,
|
|
58
|
+
scope: record.scope,
|
|
59
|
+
version: record.expectedVersion,
|
|
60
|
+
dataHash: record.dataHash,
|
|
61
|
+
addedAt: record.addedAt,
|
|
62
|
+
deletedAt: record.deletedAt ?? null,
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
if (error instanceof DataPointDeletedError) {
|
|
68
|
+
return emitAppOutcome(options, {
|
|
69
|
+
status: "done",
|
|
70
|
+
code: "ok",
|
|
71
|
+
message: "Data point exists but was deleted (tombstoned).",
|
|
72
|
+
network: network.name,
|
|
73
|
+
data: { dataPointId, deleted: true },
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
return emitAppOutcome(options, {
|
|
77
|
+
status: "failed",
|
|
78
|
+
code: "gateway_unreachable",
|
|
79
|
+
message: `Data point lookup failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
80
|
+
network: network.name,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=onchain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onchain.js","sourceRoot":"","sources":["../../../src/cli/app/onchain.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,iBAAiB,GAElB,MAAM,wBAAwB,CAAC;AAChC,OA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QACD,OAAO,cAAc,CAAC,OAAO,EAAE;YAC7B,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,qBAAqB;YAC3B,OAAO,EAAE,6BACP,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CACvD,EAAE;YACF,OAAO,EAAE,OAAO,CAAC,IAAI;SACtB,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outcome contract for the builder (`vana app`) command group.
|
|
3
|
+
*
|
|
4
|
+
* Every app command ends by emitting exactly one outcome through
|
|
5
|
+
* {@link emitAppOutcome}: a single JSON line in `--json` mode, readable
|
|
6
|
+
* lines otherwise. The exit code always comes from the protocol `code`
|
|
7
|
+
* through the binary-wide table in `src/core/exit-codes.ts`.
|
|
8
|
+
*/
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
import { type CliExitCode } from "../../core/exit-codes.js";
|
|
11
|
+
import type { VanaNetworkName } from "../../core/network.js";
|
|
12
|
+
export declare const APP_OUTCOME_STATUSES: readonly ["done", "failed"];
|
|
13
|
+
export type AppOutcomeStatus = (typeof APP_OUTCOME_STATUSES)[number];
|
|
14
|
+
export interface AppOutcomeInput {
|
|
15
|
+
status: AppOutcomeStatus;
|
|
16
|
+
/** Stable protocol code; drives the exit code. `ok` for success. */
|
|
17
|
+
code: string;
|
|
18
|
+
message: string;
|
|
19
|
+
remedy?: string;
|
|
20
|
+
network?: VanaNetworkName;
|
|
21
|
+
data?: Record<string, unknown>;
|
|
22
|
+
}
|
|
23
|
+
export declare const appOutcomeSchema: z.ZodObject<{
|
|
24
|
+
type: z.ZodLiteral<"outcome">;
|
|
25
|
+
status: z.ZodEnum<{
|
|
26
|
+
failed: "failed";
|
|
27
|
+
done: "done";
|
|
28
|
+
}>;
|
|
29
|
+
code: z.ZodString;
|
|
30
|
+
exitCode: z.ZodNumber;
|
|
31
|
+
message: z.ZodString;
|
|
32
|
+
remedy: z.ZodOptional<z.ZodString>;
|
|
33
|
+
network: z.ZodOptional<z.ZodString>;
|
|
34
|
+
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
35
|
+
}, z.core.$catchall<z.ZodUnknown>>;
|
|
36
|
+
export interface AppCommandOptions {
|
|
37
|
+
json?: boolean;
|
|
38
|
+
noInput?: boolean;
|
|
39
|
+
quiet?: boolean;
|
|
40
|
+
yes?: boolean;
|
|
41
|
+
network?: VanaNetworkName;
|
|
42
|
+
}
|
|
43
|
+
/** Emit the terminal outcome and return the exit code for the command. */
|
|
44
|
+
export declare function emitAppOutcome(options: AppCommandOptions, outcome: AppOutcomeInput): CliExitCode;
|
|
45
|
+
//# sourceMappingURL=outcome.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outcome.d.ts","sourceRoot":"","sources":["../../../src/cli/app/outcome.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAEL,KAAK,WAAW,EACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,eAAO,MAAM,oBAAoB,6BAA8B,CAAC;AAChE,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAErE,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,gBAAgB,CAAC;IACzB,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED,eAAO,MAAM,gBAAgB;;;;;;;;;;;;kCAWL,CAAC;AAEzB,MAAM,WAAW,iBAAiB;IAChC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE,eAAe,CAAC;CAC3B;AAED,0EAA0E;AAC1E,wBAAgB,cAAc,CAC5B,OAAO,EAAE,iBAAiB,EAC1B,OAAO,EAAE,eAAe,GACvB,WAAW,CA8Bb"}
|