@dvmkit/dvm-cli 0.0.0 → 0.1.4
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/LICENSE +67 -0
- package/NOTICE +2 -0
- package/README.md +28 -3
- package/dist/_esm-M2HUAA3B.js +883 -0
- package/dist/_esm-NRGECLJ7.js +35 -0
- package/dist/accounts-S747UW3A.js +73 -0
- package/dist/ccip-XZ5F5J6R.js +18 -0
- package/dist/chains-PINFXYUE.js +1460 -0
- package/dist/channel-store-GOV7TEDN.js +62 -0
- package/dist/chunk-3PPOU55E.js +312 -0
- package/dist/chunk-3TBULV3F.js +551 -0
- package/dist/chunk-4AQ4G7L5.js +1447 -0
- package/dist/chunk-5BUV73FO.js +2351 -0
- package/dist/chunk-6AJ7H2VX.js +4387 -0
- package/dist/chunk-6UGZAFIR.js +1485 -0
- package/dist/chunk-7UPZZGC5.js +30063 -0
- package/dist/chunk-ACNNU5RY.js +5485 -0
- package/dist/chunk-BZNZWRBB.js +189 -0
- package/dist/chunk-EY5K4BM3.js +1780 -0
- package/dist/chunk-G3RLVJF5.js +19 -0
- package/dist/chunk-GIDSTROG.js +16614 -0
- package/dist/chunk-HPRIQEJS.js +258 -0
- package/dist/chunk-IC6OXFYW.js +6484 -0
- package/dist/chunk-IYHTITNZ.js +45 -0
- package/dist/chunk-KC4UPK44.js +113 -0
- package/dist/chunk-MMJR6N3J.js +2426 -0
- package/dist/chunk-MTBCEXJ6.js +4602 -0
- package/dist/chunk-ONQMRWY3.js +83 -0
- package/dist/chunk-PHZHPRQE.js +1181 -0
- package/dist/chunk-RA24J4QM.js +3717 -0
- package/dist/chunk-RWBYCM47.js +339 -0
- package/dist/chunk-SLDVIXCS.js +21369 -0
- package/dist/chunk-TO47XRK7.js +24890 -0
- package/dist/chunk-U5TNSUYW.js +1757 -0
- package/dist/chunk-UU6QMSTQ.js +171 -0
- package/dist/chunk-UXQCP26E.js +2691 -0
- package/dist/chunk-XGABM4H5.js +3339 -0
- package/dist/chunk-YZUBKHHA.js +15436 -0
- package/dist/chunk-ZELLQI7F.js +248 -0
- package/dist/chunk-ZGXCK43G.js +9868 -0
- package/dist/client-D3XFLWOK.js +52 -0
- package/dist/dist-7MMV3EZA.js +46 -0
- package/dist/dvm.js +33650 -0
- package/dist/lifecycle-5RLM5JMN.js +29 -0
- package/dist/mine.wasm-DNBKYCTQ.js +12 -0
- package/dist/pocket-refill-GDYSTECR.js +133 -0
- package/dist/secp256k1-4YWQEMGF.js +19 -0
- package/dist/tempo-lifecycle-DHZPQTSB.js +31 -0
- package/dist/tempo-wallet-5FEOI4CF.js +35 -0
- package/dist/wallet-G3VOUCL4.js +30 -0
- package/dist/x402-VNFA3DBY.js +91 -0
- package/package.json +71 -6
- package/skills/dvm/SKILL.md +71 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __dvmCreateRequire } from "node:module";
|
|
3
|
+
const require = __dvmCreateRequire(import.meta.url);
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
11
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
12
|
+
}) : x)(function(x) {
|
|
13
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
14
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
15
|
+
});
|
|
16
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
17
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
18
|
+
};
|
|
19
|
+
var __export = (target, all) => {
|
|
20
|
+
for (var name in all)
|
|
21
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
22
|
+
};
|
|
23
|
+
var __copyProps = (to, from, except, desc) => {
|
|
24
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
25
|
+
for (let key of __getOwnPropNames(from))
|
|
26
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
27
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
28
|
+
}
|
|
29
|
+
return to;
|
|
30
|
+
};
|
|
31
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
32
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
33
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
34
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
35
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
36
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
37
|
+
mod
|
|
38
|
+
));
|
|
39
|
+
|
|
40
|
+
export {
|
|
41
|
+
__require,
|
|
42
|
+
__commonJS,
|
|
43
|
+
__export,
|
|
44
|
+
__toESM
|
|
45
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __dvmCreateRequire } from "node:module";
|
|
3
|
+
const require = __dvmCreateRequire(import.meta.url);
|
|
4
|
+
import {
|
|
5
|
+
usdcToMsats
|
|
6
|
+
} from "./chunk-ZELLQI7F.js";
|
|
7
|
+
import {
|
|
8
|
+
X402_DEFAULT_NETWORK,
|
|
9
|
+
buildPaymentRequirements,
|
|
10
|
+
callerLoggers,
|
|
11
|
+
createX402FacilitatorAuthHeaders,
|
|
12
|
+
decodePayment,
|
|
13
|
+
encodeSettleResponseHeader,
|
|
14
|
+
exactEvmAuthorization,
|
|
15
|
+
settleWithFacilitator,
|
|
16
|
+
verifyWithFacilitator
|
|
17
|
+
} from "./chunk-EY5K4BM3.js";
|
|
18
|
+
import {
|
|
19
|
+
x402NetworkByCaip2
|
|
20
|
+
} from "./chunk-MTBCEXJ6.js";
|
|
21
|
+
|
|
22
|
+
// src/lib/x402/asset.ts
|
|
23
|
+
function resolveX402Asset(network = X402_DEFAULT_NETWORK) {
|
|
24
|
+
const spec = x402NetworkByCaip2(network);
|
|
25
|
+
if (!spec) return null;
|
|
26
|
+
return {
|
|
27
|
+
address: spec.usdc,
|
|
28
|
+
symbol: "USDC",
|
|
29
|
+
// "native" is the load-bearing word: every contract in the table is
|
|
30
|
+
// Circle's own USDC, and the dollars that read as zero here are the
|
|
31
|
+
// bridged ones.
|
|
32
|
+
label: "native USDC",
|
|
33
|
+
unit: "USDC",
|
|
34
|
+
networkLabel: spec.label,
|
|
35
|
+
confusable: spec.confusable
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function x402WrongAssetHint(asset) {
|
|
39
|
+
const wrongToken = asset.confusable ? `Another dollar on ${asset.networkLabel} \u2014 ${asset.confusable}, the legacy bridged dollar, or any other stablecoin \u2014 is a different contract and will never show up here, however much of it your wallet says you hold.` : `Another dollar on ${asset.networkLabel} is a different contract and will never show up here, however much of it your wallet says you hold.`;
|
|
40
|
+
return `This rail reads only ${asset.label} (${asset.address}) on ${asset.networkLabel}. ${wrongToken} USDC on a different chain is invisible here too \u2014 this wallet reads ${asset.networkLabel} alone. If you funded the wrong one, swap it to ${asset.label} on ${asset.networkLabel}, or bridge the funds across to ${asset.networkLabel}; either way they land where this rail can spend them.`;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// src/lib/x402/verify.ts
|
|
44
|
+
async function verifyX402Payment(paymentHeader, config, requiredUsdcMicro, resource, btcUsdRate, exactVersions = { v1: true, v2: true }) {
|
|
45
|
+
return callerLoggers.x402.span(
|
|
46
|
+
"x402.verify_payment",
|
|
47
|
+
{
|
|
48
|
+
resource,
|
|
49
|
+
required_usdc_micro: Number(requiredUsdcMicro),
|
|
50
|
+
facilitator_url: config.facilitator
|
|
51
|
+
},
|
|
52
|
+
async () => {
|
|
53
|
+
let payload;
|
|
54
|
+
try {
|
|
55
|
+
payload = decodePayment(paymentHeader);
|
|
56
|
+
} catch {
|
|
57
|
+
return { verified: false, amountMsats: 0, invalidReason: "decode_failed" };
|
|
58
|
+
}
|
|
59
|
+
if (payload.x402Version === 1 && !exactVersions.v1 || payload.x402Version === 2 && !exactVersions.v2) {
|
|
60
|
+
return { verified: false, amountMsats: 0, invalidReason: "unsupported_version" };
|
|
61
|
+
}
|
|
62
|
+
const requirementOpts = { x402Config: config, requiredUsdcMicro, resource };
|
|
63
|
+
const requirements = payload.x402Version === 1 ? buildPaymentRequirements({ ...requirementOpts, version: 1 }) : buildPaymentRequirements({ ...requirementOpts, version: 2 });
|
|
64
|
+
const createAuthHeaders = createX402FacilitatorAuthHeaders(config);
|
|
65
|
+
const verifyRes = await verifyWithFacilitator(
|
|
66
|
+
payload,
|
|
67
|
+
requirements,
|
|
68
|
+
config,
|
|
69
|
+
createAuthHeaders
|
|
70
|
+
);
|
|
71
|
+
if (!verifyRes.isValid) {
|
|
72
|
+
return {
|
|
73
|
+
verified: false,
|
|
74
|
+
amountMsats: 0,
|
|
75
|
+
invalidReason: verifyRes.invalidReason ?? "verify_failed"
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
const settleRes = await settleWithFacilitator(
|
|
79
|
+
payload,
|
|
80
|
+
requirements,
|
|
81
|
+
config,
|
|
82
|
+
createAuthHeaders
|
|
83
|
+
);
|
|
84
|
+
if (!settleRes.success) {
|
|
85
|
+
return {
|
|
86
|
+
verified: false,
|
|
87
|
+
amountMsats: 0,
|
|
88
|
+
invalidReason: settleRes.errorReason ?? "settle_failed"
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
const amountUsdcMicro = Number.parseInt(exactEvmAuthorization(payload).value, 10);
|
|
92
|
+
const amountMsats = usdcToMsats(amountUsdcMicro / 1e6, btcUsdRate);
|
|
93
|
+
callerLoggers.x402.info("x402.verify_payment.result", {
|
|
94
|
+
verified: true,
|
|
95
|
+
tx_hash: settleRes.transaction,
|
|
96
|
+
amount_msats: amountMsats
|
|
97
|
+
});
|
|
98
|
+
return {
|
|
99
|
+
verified: true,
|
|
100
|
+
amountMsats,
|
|
101
|
+
amountUsdcMicro,
|
|
102
|
+
txHash: settleRes.transaction,
|
|
103
|
+
settleResponseHeader: encodeSettleResponseHeader(settleRes)
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export {
|
|
110
|
+
resolveX402Asset,
|
|
111
|
+
x402WrongAssetHint,
|
|
112
|
+
verifyX402Payment
|
|
113
|
+
};
|