@dvmkit/dvm-cli 0.6.0 → 0.7.0-rc.2
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/{_esm-MN4BUYV6.js → _esm-KJAA4KAJ.js} +7 -7
- package/dist/{actions-LR65XILR.js → actions-J7VGYDBF.js} +4 -4
- package/dist/{ccip-JXYJSXTW.js → ccip-CJFG4PLA.js} +1 -1
- package/dist/{chains-LJ7XK6H3.js → chains-J6VIUNUB.js} +4 -4
- package/dist/{chunk-MJ4X4BEW.js → chunk-6LP4EGKA.js} +61 -61
- package/dist/chunk-6QHVPJNX.js +122 -0
- package/dist/chunk-7UAQTHNP.js +77 -0
- package/dist/{chunk-BECPI5H5.js → chunk-B4WHUMZM.js} +36 -36
- package/dist/{chunk-CJTE5TS3.js → chunk-ESOJUXVY.js} +5 -5
- package/dist/{chunk-F55NNH2F.js → chunk-FOWQ7R7S.js} +16 -16
- package/dist/{chunk-ID5G54HJ.js → chunk-FPWP4S5S.js} +5 -3
- package/dist/{chunk-EE2MREOM.js → chunk-IQV4KG63.js} +5 -3
- package/dist/{chunk-R55XNXAR.js → chunk-IUTVV6N5.js} +3 -3
- package/dist/{chunk-Z4CZUMUT.js → chunk-JBU7RKQ3.js} +15 -15
- package/dist/{chunk-SHZMNEXE.js → chunk-JTMBSEZO.js} +2770 -926
- package/dist/{chunk-ERJFRCJO.js → chunk-KDNFUDOG.js} +5 -5
- package/dist/chunk-PG7MEKJI.js +43 -0
- package/dist/{chunk-WTM2EICO.js → chunk-PUOXBKY2.js} +3 -3
- package/dist/{chunk-GZWKCIYN.js → chunk-QXMKABL7.js} +3 -3
- package/dist/chunk-R2DSAZBO.js +87 -0
- package/dist/chunk-RQYMWLX4.js +409 -0
- package/dist/{chunk-FL2ICZW5.js → chunk-SYFKO6BA.js} +3 -3
- package/dist/{chunk-LH3QPVN6.js → chunk-TAZWRWM4.js} +8060 -8058
- package/dist/chunk-U3YRNLZ5.js +262 -0
- package/dist/{chunk-QICJRKB7.js → chunk-VIYUB3XT.js} +11035 -12471
- package/dist/chunk-VLZ2K7JL.js +5460 -0
- package/dist/{chunk-TZWZTS37.js → chunk-WN5R367B.js} +57 -83
- package/dist/{chunk-EZHT2RLJ.js → chunk-X7SEGALJ.js} +3 -3
- package/dist/{chunk-XHOFQ3OS.js → chunk-Y3SQD37C.js} +9 -9
- package/dist/chunk-ZXVOMXT4.js +765 -0
- package/dist/{client-RYDA62DU.js → client-6IHIUB6J.js} +10 -10
- package/dist/client-IDO4IAXG.js +36 -0
- package/dist/{dist-GKCEIY2A.js → dist-23E7OOCA.js} +9 -9
- package/dist/dvm.js +2428 -568
- package/dist/{internal-INUTGTXQ.js → internal-7FXJTFBU.js} +325 -508
- package/dist/lifecycle-LRS3IBQL.js +36 -0
- package/dist/{payout-reporter-3Y2U55ZX-CMKACKA3.js → payout-reporter-WT7XYW42-U2QPDIYC.js} +3 -2
- package/dist/{pocket-refill-K5T4LZF6.js → pocket-refill-J5OWRBXH.js} +33 -30
- package/dist/{revenue-reporter-MAERPYGK-CCPZXGFA.js → revenue-reporter-7UR3W2SD-C5OMRGK3.js} +3 -2
- package/dist/{tempo-AXTE4ZEA.js → tempo-ORFVGUKP.js} +10 -10
- package/dist/tempo-lifecycle-HS2NIFKT.js +38 -0
- package/dist/tempo-wallet-BA2LKR45.js +43 -0
- package/dist/wallet-RPPUCQUR.js +45 -0
- package/dist/{x402-R6HPBY5D-VMSW7Z32.js → x402-ZU4GML7Z-RYEACIIT.js} +4 -19
- package/package.json +4 -2
- package/dist/chunk-3YE43JJR.js +0 -215
- package/dist/chunk-4KINCBHL.js +0 -5153
- package/dist/chunk-FSYEZERJ.js +0 -1667
- package/dist/chunk-VOO5IAK7.js +0 -2318
- package/dist/tempo-lifecycle-ZBBLFBMH-HWI4PLYP.js +0 -32
- package/dist/tempo-wallet-B5XXV3YH-SRQBMYFV.js +0 -41
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
walletActions,
|
|
36
36
|
webSocket,
|
|
37
37
|
weiUnits
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-ESOJUXVY.js";
|
|
39
39
|
import {
|
|
40
40
|
BundleFailedError,
|
|
41
41
|
EnsAvatarInvalidNftUriError,
|
|
@@ -47,7 +47,7 @@ import {
|
|
|
47
47
|
labelhash,
|
|
48
48
|
namehash,
|
|
49
49
|
zeroAddress
|
|
50
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-QXMKABL7.js";
|
|
51
51
|
import {
|
|
52
52
|
BaseFeeScalarError,
|
|
53
53
|
BlockNotFoundError,
|
|
@@ -88,22 +88,22 @@ import {
|
|
|
88
88
|
parseGwei,
|
|
89
89
|
parseTransaction,
|
|
90
90
|
parseUnits,
|
|
91
|
-
recoverAddress,
|
|
91
|
+
recoverAddress2 as recoverAddress,
|
|
92
92
|
recoverMessageAddress,
|
|
93
|
-
recoverPublicKey,
|
|
93
|
+
recoverPublicKey2 as recoverPublicKey,
|
|
94
94
|
recoverTypedDataAddress,
|
|
95
95
|
ripemd160,
|
|
96
96
|
serializeErc6492Signature,
|
|
97
97
|
serializeErc8010Signature,
|
|
98
98
|
transactionType,
|
|
99
|
-
verifyHash,
|
|
99
|
+
verifyHash2 as verifyHash,
|
|
100
100
|
verifyMessage,
|
|
101
101
|
verifyTypedData,
|
|
102
102
|
withCache,
|
|
103
103
|
withRetry,
|
|
104
104
|
withTimeout,
|
|
105
105
|
zeroHash
|
|
106
|
-
} from "./chunk-
|
|
106
|
+
} from "./chunk-TAZWRWM4.js";
|
|
107
107
|
import {
|
|
108
108
|
InvalidDomainError,
|
|
109
109
|
InvalidPrimaryTypeError,
|
|
@@ -240,7 +240,7 @@ import {
|
|
|
240
240
|
toFunctionSelector,
|
|
241
241
|
toSignature,
|
|
242
242
|
toSignatureHash
|
|
243
|
-
} from "./chunk-
|
|
243
|
+
} from "./chunk-FOWQ7R7S.js";
|
|
244
244
|
import {
|
|
245
245
|
AbiConstructorNotFoundError,
|
|
246
246
|
AbiConstructorParamsNotFoundError,
|
|
@@ -84,7 +84,7 @@ import {
|
|
|
84
84
|
watchBlocks,
|
|
85
85
|
watchEvent,
|
|
86
86
|
watchPendingTransactions
|
|
87
|
-
} from "./chunk-
|
|
87
|
+
} from "./chunk-QXMKABL7.js";
|
|
88
88
|
import {
|
|
89
89
|
createContractEventFilter,
|
|
90
90
|
defaultParameters,
|
|
@@ -109,20 +109,20 @@ import {
|
|
|
109
109
|
sendTransaction,
|
|
110
110
|
sendTransactionSync,
|
|
111
111
|
uninstallFilter,
|
|
112
|
-
|
|
112
|
+
verifyHash,
|
|
113
113
|
waitForTransactionReceipt,
|
|
114
114
|
watchBlockNumber,
|
|
115
115
|
watchContractEvent,
|
|
116
116
|
writeContract,
|
|
117
117
|
writeContractSync
|
|
118
|
-
} from "./chunk-
|
|
118
|
+
} from "./chunk-TAZWRWM4.js";
|
|
119
119
|
import {
|
|
120
120
|
getTransactionCount
|
|
121
121
|
} from "./chunk-6O27TEXD.js";
|
|
122
122
|
import "./chunk-65EY7CT4.js";
|
|
123
123
|
import {
|
|
124
124
|
call
|
|
125
|
-
} from "./chunk-
|
|
125
|
+
} from "./chunk-FOWQ7R7S.js";
|
|
126
126
|
import "./chunk-MLDUKBU3.js";
|
|
127
127
|
import "./chunk-7OK7MBT6.js";
|
|
128
128
|
import "./chunk-IYHTITNZ.js";
|
|
@@ -720,12 +720,12 @@ import {
|
|
|
720
720
|
zora,
|
|
721
721
|
zoraSepolia,
|
|
722
722
|
zoraTestnet
|
|
723
|
-
} from "./chunk-
|
|
724
|
-
import "./chunk-
|
|
725
|
-
import "./chunk-
|
|
723
|
+
} from "./chunk-B4WHUMZM.js";
|
|
724
|
+
import "./chunk-X7SEGALJ.js";
|
|
725
|
+
import "./chunk-TAZWRWM4.js";
|
|
726
726
|
import "./chunk-6O27TEXD.js";
|
|
727
727
|
import "./chunk-65EY7CT4.js";
|
|
728
|
-
import "./chunk-
|
|
728
|
+
import "./chunk-FOWQ7R7S.js";
|
|
729
729
|
import "./chunk-MLDUKBU3.js";
|
|
730
730
|
import "./chunk-7OK7MBT6.js";
|
|
731
731
|
import "./chunk-IYHTITNZ.js";
|
|
@@ -1,6 +1,61 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __dvmCreateRequire } from "node:module";
|
|
3
3
|
const require = __dvmCreateRequire(import.meta.url);
|
|
4
|
+
import {
|
|
5
|
+
BadRequestError,
|
|
6
|
+
ChannelClosedError,
|
|
7
|
+
Headers as Headers2,
|
|
8
|
+
Intents,
|
|
9
|
+
MethodDetailKeys,
|
|
10
|
+
Methods,
|
|
11
|
+
PaymentRequirementsSchema,
|
|
12
|
+
Schema,
|
|
13
|
+
SessionProtocols,
|
|
14
|
+
VerificationFailedError,
|
|
15
|
+
_enum,
|
|
16
|
+
_maxLength,
|
|
17
|
+
_minLength,
|
|
18
|
+
_regex,
|
|
19
|
+
address,
|
|
20
|
+
amount,
|
|
21
|
+
array,
|
|
22
|
+
assert as assert2,
|
|
23
|
+
bigint,
|
|
24
|
+
boolean,
|
|
25
|
+
createJson,
|
|
26
|
+
credentialMetaKey,
|
|
27
|
+
custom as custom2,
|
|
28
|
+
datetimeInput,
|
|
29
|
+
decodePaymentRequiredEnvelope,
|
|
30
|
+
deserialize as deserialize2,
|
|
31
|
+
discriminatedUnion,
|
|
32
|
+
exactIntent,
|
|
33
|
+
from as from4,
|
|
34
|
+
from3 as from5,
|
|
35
|
+
fromResponseList,
|
|
36
|
+
getMethodDetail,
|
|
37
|
+
hash,
|
|
38
|
+
literal,
|
|
39
|
+
number,
|
|
40
|
+
object,
|
|
41
|
+
optional,
|
|
42
|
+
paymentMethod,
|
|
43
|
+
paymentRequiredCode,
|
|
44
|
+
paymentRequiredHeader,
|
|
45
|
+
paymentRequiredMetaKey,
|
|
46
|
+
paymentResponseHeader,
|
|
47
|
+
paymentSignatureHeader,
|
|
48
|
+
pipe,
|
|
49
|
+
refine,
|
|
50
|
+
serialize2 as serialize,
|
|
51
|
+
serialize3 as serialize2,
|
|
52
|
+
signature,
|
|
53
|
+
string,
|
|
54
|
+
syntheticChallengeIdPrefix,
|
|
55
|
+
toClient,
|
|
56
|
+
transform,
|
|
57
|
+
union
|
|
58
|
+
} from "./chunk-PUOXBKY2.js";
|
|
4
59
|
import {
|
|
5
60
|
Abis_exports,
|
|
6
61
|
Account_exports,
|
|
@@ -60,71 +115,16 @@ import {
|
|
|
60
115
|
validator,
|
|
61
116
|
validatorConfig,
|
|
62
117
|
zoneOutbox
|
|
63
|
-
} from "./chunk-
|
|
64
|
-
import {
|
|
65
|
-
BadRequestError,
|
|
66
|
-
ChannelClosedError,
|
|
67
|
-
Headers as Headers2,
|
|
68
|
-
Intents,
|
|
69
|
-
MethodDetailKeys,
|
|
70
|
-
Methods,
|
|
71
|
-
PaymentRequirementsSchema,
|
|
72
|
-
Schema,
|
|
73
|
-
SessionProtocols,
|
|
74
|
-
VerificationFailedError,
|
|
75
|
-
_enum,
|
|
76
|
-
_maxLength,
|
|
77
|
-
_minLength,
|
|
78
|
-
_regex,
|
|
79
|
-
address,
|
|
80
|
-
amount,
|
|
81
|
-
array,
|
|
82
|
-
assert as assert2,
|
|
83
|
-
bigint,
|
|
84
|
-
boolean,
|
|
85
|
-
createJson,
|
|
86
|
-
credentialMetaKey,
|
|
87
|
-
custom as custom2,
|
|
88
|
-
datetimeInput,
|
|
89
|
-
decodePaymentRequiredEnvelope,
|
|
90
|
-
deserialize as deserialize2,
|
|
91
|
-
discriminatedUnion,
|
|
92
|
-
exactIntent,
|
|
93
|
-
from as from4,
|
|
94
|
-
from3 as from5,
|
|
95
|
-
fromResponseList,
|
|
96
|
-
getMethodDetail,
|
|
97
|
-
hash,
|
|
98
|
-
literal,
|
|
99
|
-
number,
|
|
100
|
-
object,
|
|
101
|
-
optional,
|
|
102
|
-
paymentMethod,
|
|
103
|
-
paymentRequiredCode,
|
|
104
|
-
paymentRequiredHeader,
|
|
105
|
-
paymentRequiredMetaKey,
|
|
106
|
-
paymentResponseHeader,
|
|
107
|
-
paymentSignatureHeader,
|
|
108
|
-
pipe,
|
|
109
|
-
refine,
|
|
110
|
-
serialize2 as serialize,
|
|
111
|
-
serialize3 as serialize2,
|
|
112
|
-
signature,
|
|
113
|
-
string,
|
|
114
|
-
syntheticChallengeIdPrefix,
|
|
115
|
-
toClient,
|
|
116
|
-
transform,
|
|
117
|
-
union
|
|
118
|
-
} from "./chunk-WTM2EICO.js";
|
|
118
|
+
} from "./chunk-B4WHUMZM.js";
|
|
119
119
|
import {
|
|
120
120
|
Base64_exports
|
|
121
|
-
} from "./chunk-
|
|
121
|
+
} from "./chunk-X7SEGALJ.js";
|
|
122
122
|
import {
|
|
123
123
|
createClient,
|
|
124
124
|
createTransport,
|
|
125
125
|
custom,
|
|
126
126
|
http
|
|
127
|
-
} from "./chunk-
|
|
127
|
+
} from "./chunk-ESOJUXVY.js";
|
|
128
128
|
import {
|
|
129
129
|
estimateContractGas,
|
|
130
130
|
multicall,
|
|
@@ -136,7 +136,7 @@ import {
|
|
|
136
136
|
toAmount,
|
|
137
137
|
toBaseUnits,
|
|
138
138
|
zeroAddress
|
|
139
|
-
} from "./chunk-
|
|
139
|
+
} from "./chunk-QXMKABL7.js";
|
|
140
140
|
import {
|
|
141
141
|
AbiItem_exports,
|
|
142
142
|
AbiParameters_exports,
|
|
@@ -173,7 +173,7 @@ import {
|
|
|
173
173
|
writeContract,
|
|
174
174
|
writeContractSync,
|
|
175
175
|
zeroHash
|
|
176
|
-
} from "./chunk-
|
|
176
|
+
} from "./chunk-TAZWRWM4.js";
|
|
177
177
|
import {
|
|
178
178
|
hashTypedData
|
|
179
179
|
} from "./chunk-6O27TEXD.js";
|
|
@@ -207,7 +207,7 @@ import {
|
|
|
207
207
|
toNumber2 as toNumber,
|
|
208
208
|
toRpc,
|
|
209
209
|
withResolvers
|
|
210
|
-
} from "./chunk-
|
|
210
|
+
} from "./chunk-FOWQ7R7S.js";
|
|
211
211
|
import {
|
|
212
212
|
AbiDecodingZeroDataError,
|
|
213
213
|
BaseError,
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __dvmCreateRequire } from "node:module";
|
|
3
|
+
const require = __dvmCreateRequire(import.meta.url);
|
|
4
|
+
import {
|
|
5
|
+
authorizeProtectedRemoval,
|
|
6
|
+
loadConfig,
|
|
7
|
+
updateConfig
|
|
8
|
+
} from "./chunk-ZXVOMXT4.js";
|
|
9
|
+
import {
|
|
10
|
+
withX402ChannelLock,
|
|
11
|
+
x402WalletFromConfig
|
|
12
|
+
} from "./chunk-VIYUB3XT.js";
|
|
13
|
+
import {
|
|
14
|
+
DvmError,
|
|
15
|
+
X402_DEFAULT_NETWORK,
|
|
16
|
+
X402_NETWORKS,
|
|
17
|
+
ensureAddress,
|
|
18
|
+
isValidEvmPrivateKey,
|
|
19
|
+
x402NetworkByCaip2
|
|
20
|
+
} from "./chunk-JTMBSEZO.js";
|
|
21
|
+
|
|
22
|
+
// src/lib/x402/networks.ts
|
|
23
|
+
function x402NetworkLabel(network) {
|
|
24
|
+
const spec = x402NetworkByCaip2(network);
|
|
25
|
+
return spec ? `${spec.label} (${network})` : network;
|
|
26
|
+
}
|
|
27
|
+
function x402NetworkListForCopy() {
|
|
28
|
+
return X402_NETWORKS.map((n) => `${n.caip2} (${n.label})`).join(", ");
|
|
29
|
+
}
|
|
30
|
+
function assertSupportedX402Network(network) {
|
|
31
|
+
if (x402NetworkByCaip2(network)) return;
|
|
32
|
+
throw new DvmError(
|
|
33
|
+
"unsupported_network",
|
|
34
|
+
`Unsupported x402 network: ${network}.`,
|
|
35
|
+
`${x402SupportedNetworksHint()} If a wallet is connected, run 'dvm wallet x402-network <caip2>'. For a first connection, pass --network to 'dvm wallet x402-connect'.`
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
function x402SupportedNetworksHint() {
|
|
39
|
+
return `This rail settles native USDC on: ${x402NetworkListForCopy()}.`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// src/lib/x402/wallet.ts
|
|
43
|
+
function loadX402Wallet() {
|
|
44
|
+
return x402WalletFromConfig(loadConfig());
|
|
45
|
+
}
|
|
46
|
+
async function connectedX402Payer() {
|
|
47
|
+
const wallet = loadX402Wallet();
|
|
48
|
+
if (!wallet) return null;
|
|
49
|
+
return (await ensureAddress(wallet)).address;
|
|
50
|
+
}
|
|
51
|
+
async function repinX402WalletNetwork(network) {
|
|
52
|
+
assertSupportedX402Network(network);
|
|
53
|
+
return withX402ChannelLock(async () => {
|
|
54
|
+
const { previous } = await updateConfig({
|
|
55
|
+
reason: "x402_wallet_repin",
|
|
56
|
+
patch: (current) => {
|
|
57
|
+
if (!current) throw new DvmError("no_config", "No config found.", "Run: dvm init");
|
|
58
|
+
const privateKey = current.x402?.privateKey;
|
|
59
|
+
if (privateKey === void 0) throw x402WalletMissingError();
|
|
60
|
+
if (!isValidEvmPrivateKey(privateKey)) throw invalidX402PrivateKey();
|
|
61
|
+
return { set: { x402: { privateKey, network } } };
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
const stored = previous?.x402;
|
|
65
|
+
if (stored === void 0) throw x402WalletMissingError();
|
|
66
|
+
if (!isValidEvmPrivateKey(stored.privateKey)) throw invalidX402PrivateKey();
|
|
67
|
+
const { privateKeyToAccount } = await import("./accounts-2WZE4N5F.js");
|
|
68
|
+
return {
|
|
69
|
+
address: privateKeyToAccount(stored.privateKey).address,
|
|
70
|
+
previousNetwork: stored.network ?? X402_DEFAULT_NETWORK,
|
|
71
|
+
network
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
async function saveX402Wallet(privateKey, network) {
|
|
76
|
+
if (network !== void 0) assertSupportedX402Network(network);
|
|
77
|
+
if (!isValidEvmPrivateKey(privateKey)) throw invalidX402PrivateKey();
|
|
78
|
+
const { privateKeyToAccount } = await import("./accounts-2WZE4N5F.js");
|
|
79
|
+
const account = privateKeyToAccount(privateKey);
|
|
80
|
+
let resolved;
|
|
81
|
+
await updateConfig({
|
|
82
|
+
reason: "x402_wallet_connect",
|
|
83
|
+
patch: (current) => {
|
|
84
|
+
resolved = network ?? current?.x402?.network;
|
|
85
|
+
return {
|
|
86
|
+
set: { x402: resolved === void 0 ? { privateKey } : { privateKey, network: resolved } }
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
return { address: account.address, network: resolved ?? X402_DEFAULT_NETWORK };
|
|
91
|
+
}
|
|
92
|
+
async function removeX402Wallet() {
|
|
93
|
+
await updateConfig({
|
|
94
|
+
reason: "x402_wallet_disconnect",
|
|
95
|
+
authorize: authorizeProtectedRemoval("x402"),
|
|
96
|
+
patch: () => ({ unset: ["x402"] })
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
function invalidX402PrivateKey() {
|
|
100
|
+
return new DvmError(
|
|
101
|
+
"invalid_key",
|
|
102
|
+
"Invalid secp256k1 private key.",
|
|
103
|
+
"Reconnect with `dvm wallet x402-connect --key-file <path>`, set DVM_X402_KEY, or pipe a valid 0x-prefixed 32-byte secp256k1 private key through stdin."
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
function x402WalletMissingError() {
|
|
107
|
+
return new DvmError(
|
|
108
|
+
"x402_wallet_missing",
|
|
109
|
+
"No x402 wallet is connected.",
|
|
110
|
+
"Run 'dvm wallet x402-connect' to create one, or add --key-file <path> to import a key you already hold."
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export {
|
|
115
|
+
x402NetworkLabel,
|
|
116
|
+
assertSupportedX402Network,
|
|
117
|
+
loadX402Wallet,
|
|
118
|
+
connectedX402Payer,
|
|
119
|
+
repinX402WalletNetwork,
|
|
120
|
+
saveX402Wallet,
|
|
121
|
+
removeX402Wallet
|
|
122
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __dvmCreateRequire } from "node:module";
|
|
3
|
+
const require = __dvmCreateRequire(import.meta.url);
|
|
4
|
+
import {
|
|
5
|
+
loadConfig,
|
|
6
|
+
updateConfig
|
|
7
|
+
} from "./chunk-ZXVOMXT4.js";
|
|
8
|
+
import {
|
|
9
|
+
tempoAccountFromConfig,
|
|
10
|
+
tryResolveTempoAsset
|
|
11
|
+
} from "./chunk-VIYUB3XT.js";
|
|
12
|
+
import {
|
|
13
|
+
DvmError
|
|
14
|
+
} from "./chunk-JTMBSEZO.js";
|
|
15
|
+
|
|
16
|
+
// src/lib/payment-rails/tempo-wallet.ts
|
|
17
|
+
function tempoBalanceCheckHint(token) {
|
|
18
|
+
const configured = tryResolveTempoAsset();
|
|
19
|
+
if (configured?.address.toLowerCase() === token.toLowerCase()) {
|
|
20
|
+
return "This channel's token is the rail's configured settlement asset, so 'dvm wallet balance' reads it.";
|
|
21
|
+
}
|
|
22
|
+
return `'dvm wallet balance' reads the rail's configured settlement asset (${configured?.address ?? "unresolvable in this environment"}) rather than this channel's token (${token}), so query that contract directly for the balance that matters here.`;
|
|
23
|
+
}
|
|
24
|
+
function tempoWrongAssetHint(asset) {
|
|
25
|
+
return `This rail settles only in ${asset.label} (${asset.address}) on Tempo. Another Tempo dollar \u2014 USDT0 or any other stablecoin \u2014 is a different contract and will never show up here, however much of it your wallet says you hold. If you funded with the wrong one, swap it to ${asset.label} on Tempo (an on-chain swap, fees are sub-cent) or send ${asset.label} to this address.`;
|
|
26
|
+
}
|
|
27
|
+
async function connectedTempoAccount() {
|
|
28
|
+
const config = loadConfig();
|
|
29
|
+
return tempoAccountFromConfig(config);
|
|
30
|
+
}
|
|
31
|
+
async function generateTempoKey(opts = {}) {
|
|
32
|
+
const config = loadConfig();
|
|
33
|
+
if (!config) {
|
|
34
|
+
throw new DvmError(
|
|
35
|
+
"no_config",
|
|
36
|
+
"No config found.",
|
|
37
|
+
"Run `dvm init` before generating a Tempo wallet."
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
const existing = await tempoAccountFromConfig(config);
|
|
41
|
+
if (existing && !opts.force) {
|
|
42
|
+
throw new DvmError(
|
|
43
|
+
"tempo_wallet_exists",
|
|
44
|
+
`Tempo wallet already configured (address ${existing.address}).`,
|
|
45
|
+
"Pass `--force` to replace, or run `dvm wallet tempo-disconnect` to clear it first."
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
if (existing && opts.force) {
|
|
49
|
+
const { assertTempoWalletIdle } = await import("./tempo-lifecycle-HS2NIFKT.js");
|
|
50
|
+
await assertTempoWalletIdle("replace");
|
|
51
|
+
}
|
|
52
|
+
const { privateKeyToAccount, generatePrivateKey } = await import("./accounts-2WZE4N5F.js");
|
|
53
|
+
const privateKey = generatePrivateKey();
|
|
54
|
+
const account = privateKeyToAccount(privateKey);
|
|
55
|
+
const generated = {
|
|
56
|
+
privateKey,
|
|
57
|
+
address: account.address.toLowerCase(),
|
|
58
|
+
network: opts.network ?? "mainnet"
|
|
59
|
+
};
|
|
60
|
+
await opts.beforePersist?.(generated);
|
|
61
|
+
await updateConfig({
|
|
62
|
+
reason: "tempo_wallet_generate",
|
|
63
|
+
patch: () => ({
|
|
64
|
+
set: {
|
|
65
|
+
tempo: { method: "tempo", apiKey: privateKey, network: generated.network }
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
});
|
|
69
|
+
return generated;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export {
|
|
73
|
+
tempoBalanceCheckHint,
|
|
74
|
+
tempoWrongAssetHint,
|
|
75
|
+
connectedTempoAccount,
|
|
76
|
+
generateTempoKey
|
|
77
|
+
};
|