x402-proxy 0.10.7 → 0.10.9
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 +23 -1
- package/README.md +7 -1
- package/dist/Credential-COZQnr1-.js +2055 -0
- package/dist/Mcp-CrCEqLqO.js +10 -0
- package/dist/Sse-ChldYgU7.js +9742 -0
- package/dist/Sse-kCB38G56.js +16482 -0
- package/dist/accounts-DsuvWwph.js +232 -0
- package/dist/accounts-DzvAlQRn.js +5 -0
- package/dist/accounts-IG-Cmrwy.js +229 -0
- package/dist/api-CUzmQvTQ.js +2802 -0
- package/dist/auth-DTzQmnZ_.js +1196 -0
- package/dist/bin/cli.js +585 -242
- package/dist/ccip-Bx-zoUCJ.js +240 -0
- package/dist/ccip-C2k1DD1T.js +153 -0
- package/dist/ccip-C6CQOJYv.js +152 -0
- package/dist/ccip-RZzsZ5Mv.js +156 -0
- package/dist/chain-CafcHffR.js +1997 -0
- package/dist/chain-DwfP5RGZ.js +1968 -0
- package/dist/chunk-DBEY4PJZ.js +16 -0
- package/dist/chunk-DjEMn6fM.js +36 -0
- package/dist/client-Blw2V7LF.js +657 -0
- package/dist/client-C37gWJOZ.js +102 -0
- package/dist/client-CEc4NYAA.js +6388 -0
- package/dist/client-CVDTUY0l.js +5152 -0
- package/dist/config-BUQsit4s.js +3 -0
- package/dist/config-DR1Fs_wL.js +6600 -0
- package/dist/{config-D9wIR3xc.js → config-rvKA3SYT.js} +10 -5
- package/dist/decodeFunctionData-DuFcwhC_.js +4510 -0
- package/dist/decodeFunctionData-JPOUdvil.js +4394 -0
- package/dist/derive-DNUl8LU9.js +9109 -0
- package/dist/dist-C2YO6HSQ.js +6581 -0
- package/dist/dist-DM5_F3r5.js +4 -0
- package/dist/dist-DxJCYyL5.js +1388 -0
- package/dist/hashTypedData-BHmP9dBd.js +859 -0
- package/dist/hashTypedData-CtEdfx4y.js +846 -0
- package/dist/helpers-CuUSw-tH.js +7125 -0
- package/dist/hmac-59IlS_by.js +648 -0
- package/dist/http-BAtucMbS.js +2060 -0
- package/dist/index.d.ts +1903 -9
- package/dist/index.js +18006 -50
- package/dist/index.node-CxkL0OFh.js +3592 -0
- package/dist/index.node-DvmeuZBj.js +3 -0
- package/dist/isAddressEqual-BLrd1Hg1.js +9 -0
- package/dist/isAddressEqual-DsAqfQOD.js +10 -0
- package/dist/localBatchGatewayRequest-C-RPJyDO.js +6260 -0
- package/dist/localBatchGatewayRequest-DOdQ9bR7.js +93 -0
- package/dist/localBatchGatewayRequest-DQkbZaSy.js +6261 -0
- package/dist/parseUnits-CApwcKSD.js +49 -0
- package/dist/parseUnits-cMO2udMe.js +48 -0
- package/dist/schemas-BxMFYNbH.js +1270 -0
- package/dist/secp256k1-BZpiyffY.js +2525 -0
- package/dist/secp256k1-BjenrLl5.js +1877 -0
- package/dist/secp256k1-CLPUX17u.js +3 -0
- package/dist/sendRawTransactionSync-DvSkhZtW.js +3612 -0
- package/dist/server-CSq0IuUq.js +565 -0
- package/dist/setup-BY4J49Lv.js +1110 -0
- package/dist/setup-wMOAgrsN.js +3 -0
- package/dist/sha256-FAs0qeni.js +17 -0
- package/dist/sha3-CYkWM8Xa.js +195 -0
- package/dist/sha3-DbMJRJ3C.js +194 -0
- package/dist/sse-B4LLqBQm.js +408 -0
- package/dist/status-Bu23RjW6.js +3 -0
- package/dist/{status-DihAcUSC.js → status-X21VnGUO.js} +16 -15
- package/dist/stdio-BADqxZdZ.js +85 -0
- package/dist/streamableHttp-BHkJypcI.js +358 -0
- package/dist/tempo-3nttrxgQ.js +17 -0
- package/dist/tempo-DER0P-ul.js +18 -0
- package/dist/types-BEKUz-Mf.js +1240 -0
- package/dist/types-DatK5vR5.js +3 -0
- package/dist/utils-BYjkXZDF.js +444 -0
- package/dist/utils-SeGHMW9O.js +445 -0
- package/dist/wallet-DKVlrR1S.js +3 -0
- package/dist/wallet-DSyht15_.js +17759 -0
- package/package.json +18 -71
- package/dist/config-B_upkJeK.js +0 -66
- package/dist/config-Be35NM5s.js +0 -3
- package/dist/config-J1m-CWXT.js +0 -27
- package/dist/derive-CL6e8K0Z.js +0 -81
- package/dist/openclaw/plugin.d.ts +0 -15
- package/dist/openclaw/plugin.js +0 -2067
- package/dist/openclaw.plugin.json +0 -93
- package/dist/setup-CNyMLnM-.js +0 -197
- package/dist/setup-DTIxPe58.js +0 -3
- package/dist/status-DZlJ4pS7.js +0 -3
- package/dist/wallet-B0S-rma9.js +0 -544
- package/dist/wallet-DBrVZJqe.js +0 -3
- package/openclaw.plugin.json +0 -93
- package/skills/SKILL.md +0 -183
- package/skills/references/library.md +0 -85
- package/skills/references/openclaw-plugin.md +0 -145
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { n as __exportAll } from "./chunk-DBEY4PJZ.js";
|
|
2
|
+
import { t as secp256k1 } from "./secp256k1-BZpiyffY.js";
|
|
3
|
+
import { _ as publicKeyToAddress, a as serializeTransaction, g as hashAuthorization, t as hashTypedData } from "./hashTypedData-BHmP9dBd.js";
|
|
4
|
+
import { $ as toHex, B as concat, H as isAddress, J as hexToBytes, K as InvalidAddressError, Ot as size, Q as stringToHex, X as bytesToHex, Z as numberToHex, kt as isHex, q as keccak256, tt as hexToBigInt } from "./chain-DwfP5RGZ.js";
|
|
5
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/constants/strings.js
|
|
6
|
+
const presignMessagePrefix = "Ethereum Signed Message:\n";
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/signature/toPrefixedMessage.js
|
|
9
|
+
function toPrefixedMessage(message_) {
|
|
10
|
+
const message = (() => {
|
|
11
|
+
if (typeof message_ === "string") return stringToHex(message_);
|
|
12
|
+
if (typeof message_.raw === "string") return message_.raw;
|
|
13
|
+
return bytesToHex(message_.raw);
|
|
14
|
+
})();
|
|
15
|
+
return concat([stringToHex(`${presignMessagePrefix}${size(message)}`), message]);
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/signature/hashMessage.js
|
|
19
|
+
function hashMessage(message, to_) {
|
|
20
|
+
return keccak256(toPrefixedMessage(message), to_);
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/signature/serializeSignature.js
|
|
24
|
+
/**
|
|
25
|
+
* @description Converts a signature into hex format.
|
|
26
|
+
*
|
|
27
|
+
* @param signature The signature to convert.
|
|
28
|
+
* @returns The signature in hex format.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* serializeSignature({
|
|
32
|
+
* r: '0x6e100a352ec6ad1b70802290e18aeed190704973570f3b8ed42cb9808e2ea6bf',
|
|
33
|
+
* s: '0x4a90a229a244495b41890987806fcbd2d5d23fc0dbe5f5256c2613c039d76db8',
|
|
34
|
+
* yParity: 1
|
|
35
|
+
* })
|
|
36
|
+
* // "0x6e100a352ec6ad1b70802290e18aeed190704973570f3b8ed42cb9808e2ea6bf4a90a229a244495b41890987806fcbd2d5d23fc0dbe5f5256c2613c039d76db81c"
|
|
37
|
+
*/
|
|
38
|
+
function serializeSignature({ r, s, to = "hex", v, yParity }) {
|
|
39
|
+
const yParity_ = (() => {
|
|
40
|
+
if (yParity === 0 || yParity === 1) return yParity;
|
|
41
|
+
if (v && (v === 27n || v === 28n || v >= 35n)) return v % 2n === 0n ? 1 : 0;
|
|
42
|
+
throw new Error("Invalid `v` or `yParity` value");
|
|
43
|
+
})();
|
|
44
|
+
const signature = `0x${new secp256k1.Signature(hexToBigInt(r), hexToBigInt(s)).toCompactHex()}${yParity_ === 0 ? "1b" : "1c"}`;
|
|
45
|
+
if (to === "hex") return signature;
|
|
46
|
+
return hexToBytes(signature);
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/accounts/toAccount.js
|
|
50
|
+
/**
|
|
51
|
+
* @description Creates an Account from a custom signing implementation.
|
|
52
|
+
*
|
|
53
|
+
* @returns A Local Account.
|
|
54
|
+
*/
|
|
55
|
+
function toAccount(source) {
|
|
56
|
+
if (typeof source === "string") {
|
|
57
|
+
if (!isAddress(source, { strict: false })) throw new InvalidAddressError({ address: source });
|
|
58
|
+
return {
|
|
59
|
+
address: source,
|
|
60
|
+
type: "json-rpc"
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
if (!isAddress(source.address, { strict: false })) throw new InvalidAddressError({ address: source.address });
|
|
64
|
+
return {
|
|
65
|
+
address: source.address,
|
|
66
|
+
nonceManager: source.nonceManager,
|
|
67
|
+
sign: source.sign,
|
|
68
|
+
signAuthorization: source.signAuthorization,
|
|
69
|
+
signMessage: source.signMessage,
|
|
70
|
+
signTransaction: source.signTransaction,
|
|
71
|
+
signTypedData: source.signTypedData,
|
|
72
|
+
source: "custom",
|
|
73
|
+
type: "local"
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/accounts/utils/sign.js
|
|
78
|
+
let extraEntropy = false;
|
|
79
|
+
/**
|
|
80
|
+
* @description Signs a hash with a given private key.
|
|
81
|
+
*
|
|
82
|
+
* @param hash The hash to sign.
|
|
83
|
+
* @param privateKey The private key to sign with.
|
|
84
|
+
*
|
|
85
|
+
* @returns The signature.
|
|
86
|
+
*/
|
|
87
|
+
async function sign({ hash, privateKey, to = "object" }) {
|
|
88
|
+
const { r, s, recovery } = secp256k1.sign(hash.slice(2), privateKey.slice(2), {
|
|
89
|
+
lowS: true,
|
|
90
|
+
extraEntropy: isHex(extraEntropy, { strict: false }) ? hexToBytes(extraEntropy) : extraEntropy
|
|
91
|
+
});
|
|
92
|
+
const signature = {
|
|
93
|
+
r: numberToHex(r, { size: 32 }),
|
|
94
|
+
s: numberToHex(s, { size: 32 }),
|
|
95
|
+
v: recovery ? 28n : 27n,
|
|
96
|
+
yParity: recovery
|
|
97
|
+
};
|
|
98
|
+
return (() => {
|
|
99
|
+
if (to === "bytes" || to === "hex") return serializeSignature({
|
|
100
|
+
...signature,
|
|
101
|
+
to
|
|
102
|
+
});
|
|
103
|
+
return signature;
|
|
104
|
+
})();
|
|
105
|
+
}
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/accounts/utils/signAuthorization.js
|
|
108
|
+
/**
|
|
109
|
+
* Signs an Authorization hash in [EIP-7702 format](https://eips.ethereum.org/EIPS/eip-7702): `keccak256('0x05' || rlp([chain_id, address, nonce]))`.
|
|
110
|
+
*/
|
|
111
|
+
async function signAuthorization(parameters) {
|
|
112
|
+
const { chainId, nonce, privateKey, to = "object" } = parameters;
|
|
113
|
+
const address = parameters.contractAddress ?? parameters.address;
|
|
114
|
+
const signature = await sign({
|
|
115
|
+
hash: hashAuthorization({
|
|
116
|
+
address,
|
|
117
|
+
chainId,
|
|
118
|
+
nonce
|
|
119
|
+
}),
|
|
120
|
+
privateKey,
|
|
121
|
+
to
|
|
122
|
+
});
|
|
123
|
+
if (to === "object") return {
|
|
124
|
+
address,
|
|
125
|
+
chainId,
|
|
126
|
+
nonce,
|
|
127
|
+
...signature
|
|
128
|
+
};
|
|
129
|
+
return signature;
|
|
130
|
+
}
|
|
131
|
+
//#endregion
|
|
132
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/accounts/utils/signMessage.js
|
|
133
|
+
/**
|
|
134
|
+
* @description Calculates an Ethereum-specific signature in [EIP-191 format](https://eips.ethereum.org/EIPS/eip-191):
|
|
135
|
+
* `keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))`.
|
|
136
|
+
*
|
|
137
|
+
* @returns The signature.
|
|
138
|
+
*/
|
|
139
|
+
async function signMessage({ message, privateKey }) {
|
|
140
|
+
return await sign({
|
|
141
|
+
hash: hashMessage(message),
|
|
142
|
+
privateKey,
|
|
143
|
+
to: "hex"
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
//#endregion
|
|
147
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/accounts/utils/signTransaction.js
|
|
148
|
+
async function signTransaction(parameters) {
|
|
149
|
+
const { privateKey, transaction, serializer = serializeTransaction } = parameters;
|
|
150
|
+
return await serializer(transaction, await sign({
|
|
151
|
+
hash: keccak256(await serializer((() => {
|
|
152
|
+
if (transaction.type === "eip4844") return {
|
|
153
|
+
...transaction,
|
|
154
|
+
sidecars: false
|
|
155
|
+
};
|
|
156
|
+
return transaction;
|
|
157
|
+
})())),
|
|
158
|
+
privateKey
|
|
159
|
+
}));
|
|
160
|
+
}
|
|
161
|
+
//#endregion
|
|
162
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/accounts/utils/signTypedData.js
|
|
163
|
+
/**
|
|
164
|
+
* @description Signs typed data and calculates an Ethereum-specific signature in [https://eips.ethereum.org/EIPS/eip-712](https://eips.ethereum.org/EIPS/eip-712):
|
|
165
|
+
* `sign(keccak256("\x19\x01" ‖ domainSeparator ‖ hashStruct(message)))`.
|
|
166
|
+
*
|
|
167
|
+
* @returns The signature.
|
|
168
|
+
*/
|
|
169
|
+
async function signTypedData(parameters) {
|
|
170
|
+
const { privateKey, ...typedData } = parameters;
|
|
171
|
+
return await sign({
|
|
172
|
+
hash: hashTypedData(typedData),
|
|
173
|
+
privateKey,
|
|
174
|
+
to: "hex"
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/accounts/privateKeyToAccount.js
|
|
179
|
+
/**
|
|
180
|
+
* @description Creates an Account from a private key.
|
|
181
|
+
*
|
|
182
|
+
* @returns A Private Key Account.
|
|
183
|
+
*/
|
|
184
|
+
function privateKeyToAccount(privateKey, options = {}) {
|
|
185
|
+
const { nonceManager } = options;
|
|
186
|
+
const publicKey = toHex(secp256k1.getPublicKey(privateKey.slice(2), false));
|
|
187
|
+
return {
|
|
188
|
+
...toAccount({
|
|
189
|
+
address: publicKeyToAddress(publicKey),
|
|
190
|
+
nonceManager,
|
|
191
|
+
async sign({ hash }) {
|
|
192
|
+
return sign({
|
|
193
|
+
hash,
|
|
194
|
+
privateKey,
|
|
195
|
+
to: "hex"
|
|
196
|
+
});
|
|
197
|
+
},
|
|
198
|
+
async signAuthorization(authorization) {
|
|
199
|
+
return signAuthorization({
|
|
200
|
+
...authorization,
|
|
201
|
+
privateKey
|
|
202
|
+
});
|
|
203
|
+
},
|
|
204
|
+
async signMessage({ message }) {
|
|
205
|
+
return signMessage({
|
|
206
|
+
message,
|
|
207
|
+
privateKey
|
|
208
|
+
});
|
|
209
|
+
},
|
|
210
|
+
async signTransaction(transaction, { serializer } = {}) {
|
|
211
|
+
return signTransaction({
|
|
212
|
+
privateKey,
|
|
213
|
+
transaction,
|
|
214
|
+
serializer
|
|
215
|
+
});
|
|
216
|
+
},
|
|
217
|
+
async signTypedData(typedData) {
|
|
218
|
+
return signTypedData({
|
|
219
|
+
...typedData,
|
|
220
|
+
privateKey
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
}),
|
|
224
|
+
publicKey,
|
|
225
|
+
source: "privateKey"
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
//#endregion
|
|
229
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/accounts/index.js
|
|
230
|
+
var accounts_exports = /* @__PURE__ */ __exportAll({ privateKeyToAccount: () => privateKeyToAccount });
|
|
231
|
+
//#endregion
|
|
232
|
+
export { privateKeyToAccount as n, serializeSignature as r, accounts_exports as t };
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { G as isAddress, Nt as size, Pt as isHex, U as concat, X as keccak256, Y as InvalidAddressError, Z as hexToBytes, at as hexToBigInt, et as bytesToHex, nt as stringToHex, rt as toHex, tt as numberToHex } from "./chain-CafcHffR.js";
|
|
3
|
+
import { a as serializeTransaction, g as hashAuthorization, t as hashTypedData, v as publicKeyToAddress } from "./hashTypedData-CtEdfx4y.js";
|
|
4
|
+
import { t as secp256k1 } from "./secp256k1-BjenrLl5.js";
|
|
5
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/constants/strings.js
|
|
6
|
+
const presignMessagePrefix = "Ethereum Signed Message:\n";
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/signature/toPrefixedMessage.js
|
|
9
|
+
function toPrefixedMessage(message_) {
|
|
10
|
+
const message = (() => {
|
|
11
|
+
if (typeof message_ === "string") return stringToHex(message_);
|
|
12
|
+
if (typeof message_.raw === "string") return message_.raw;
|
|
13
|
+
return bytesToHex(message_.raw);
|
|
14
|
+
})();
|
|
15
|
+
return concat([stringToHex(`${presignMessagePrefix}${size(message)}`), message]);
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/signature/hashMessage.js
|
|
19
|
+
function hashMessage(message, to_) {
|
|
20
|
+
return keccak256(toPrefixedMessage(message), to_);
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/signature/serializeSignature.js
|
|
24
|
+
/**
|
|
25
|
+
* @description Converts a signature into hex format.
|
|
26
|
+
*
|
|
27
|
+
* @param signature The signature to convert.
|
|
28
|
+
* @returns The signature in hex format.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* serializeSignature({
|
|
32
|
+
* r: '0x6e100a352ec6ad1b70802290e18aeed190704973570f3b8ed42cb9808e2ea6bf',
|
|
33
|
+
* s: '0x4a90a229a244495b41890987806fcbd2d5d23fc0dbe5f5256c2613c039d76db8',
|
|
34
|
+
* yParity: 1
|
|
35
|
+
* })
|
|
36
|
+
* // "0x6e100a352ec6ad1b70802290e18aeed190704973570f3b8ed42cb9808e2ea6bf4a90a229a244495b41890987806fcbd2d5d23fc0dbe5f5256c2613c039d76db81c"
|
|
37
|
+
*/
|
|
38
|
+
function serializeSignature({ r, s, to = "hex", v, yParity }) {
|
|
39
|
+
const yParity_ = (() => {
|
|
40
|
+
if (yParity === 0 || yParity === 1) return yParity;
|
|
41
|
+
if (v && (v === 27n || v === 28n || v >= 35n)) return v % 2n === 0n ? 1 : 0;
|
|
42
|
+
throw new Error("Invalid `v` or `yParity` value");
|
|
43
|
+
})();
|
|
44
|
+
const signature = `0x${new secp256k1.Signature(hexToBigInt(r), hexToBigInt(s)).toCompactHex()}${yParity_ === 0 ? "1b" : "1c"}`;
|
|
45
|
+
if (to === "hex") return signature;
|
|
46
|
+
return hexToBytes(signature);
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/accounts/toAccount.js
|
|
50
|
+
/**
|
|
51
|
+
* @description Creates an Account from a custom signing implementation.
|
|
52
|
+
*
|
|
53
|
+
* @returns A Local Account.
|
|
54
|
+
*/
|
|
55
|
+
function toAccount(source) {
|
|
56
|
+
if (typeof source === "string") {
|
|
57
|
+
if (!isAddress(source, { strict: false })) throw new InvalidAddressError({ address: source });
|
|
58
|
+
return {
|
|
59
|
+
address: source,
|
|
60
|
+
type: "json-rpc"
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
if (!isAddress(source.address, { strict: false })) throw new InvalidAddressError({ address: source.address });
|
|
64
|
+
return {
|
|
65
|
+
address: source.address,
|
|
66
|
+
nonceManager: source.nonceManager,
|
|
67
|
+
sign: source.sign,
|
|
68
|
+
signAuthorization: source.signAuthorization,
|
|
69
|
+
signMessage: source.signMessage,
|
|
70
|
+
signTransaction: source.signTransaction,
|
|
71
|
+
signTypedData: source.signTypedData,
|
|
72
|
+
source: "custom",
|
|
73
|
+
type: "local"
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/accounts/utils/sign.js
|
|
78
|
+
let extraEntropy = false;
|
|
79
|
+
/**
|
|
80
|
+
* @description Signs a hash with a given private key.
|
|
81
|
+
*
|
|
82
|
+
* @param hash The hash to sign.
|
|
83
|
+
* @param privateKey The private key to sign with.
|
|
84
|
+
*
|
|
85
|
+
* @returns The signature.
|
|
86
|
+
*/
|
|
87
|
+
async function sign({ hash, privateKey, to = "object" }) {
|
|
88
|
+
const { r, s, recovery } = secp256k1.sign(hash.slice(2), privateKey.slice(2), {
|
|
89
|
+
lowS: true,
|
|
90
|
+
extraEntropy: isHex(extraEntropy, { strict: false }) ? hexToBytes(extraEntropy) : extraEntropy
|
|
91
|
+
});
|
|
92
|
+
const signature = {
|
|
93
|
+
r: numberToHex(r, { size: 32 }),
|
|
94
|
+
s: numberToHex(s, { size: 32 }),
|
|
95
|
+
v: recovery ? 28n : 27n,
|
|
96
|
+
yParity: recovery
|
|
97
|
+
};
|
|
98
|
+
return (() => {
|
|
99
|
+
if (to === "bytes" || to === "hex") return serializeSignature({
|
|
100
|
+
...signature,
|
|
101
|
+
to
|
|
102
|
+
});
|
|
103
|
+
return signature;
|
|
104
|
+
})();
|
|
105
|
+
}
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/accounts/utils/signAuthorization.js
|
|
108
|
+
/**
|
|
109
|
+
* Signs an Authorization hash in [EIP-7702 format](https://eips.ethereum.org/EIPS/eip-7702): `keccak256('0x05' || rlp([chain_id, address, nonce]))`.
|
|
110
|
+
*/
|
|
111
|
+
async function signAuthorization(parameters) {
|
|
112
|
+
const { chainId, nonce, privateKey, to = "object" } = parameters;
|
|
113
|
+
const address = parameters.contractAddress ?? parameters.address;
|
|
114
|
+
const signature = await sign({
|
|
115
|
+
hash: hashAuthorization({
|
|
116
|
+
address,
|
|
117
|
+
chainId,
|
|
118
|
+
nonce
|
|
119
|
+
}),
|
|
120
|
+
privateKey,
|
|
121
|
+
to
|
|
122
|
+
});
|
|
123
|
+
if (to === "object") return {
|
|
124
|
+
address,
|
|
125
|
+
chainId,
|
|
126
|
+
nonce,
|
|
127
|
+
...signature
|
|
128
|
+
};
|
|
129
|
+
return signature;
|
|
130
|
+
}
|
|
131
|
+
//#endregion
|
|
132
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/accounts/utils/signMessage.js
|
|
133
|
+
/**
|
|
134
|
+
* @description Calculates an Ethereum-specific signature in [EIP-191 format](https://eips.ethereum.org/EIPS/eip-191):
|
|
135
|
+
* `keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))`.
|
|
136
|
+
*
|
|
137
|
+
* @returns The signature.
|
|
138
|
+
*/
|
|
139
|
+
async function signMessage({ message, privateKey }) {
|
|
140
|
+
return await sign({
|
|
141
|
+
hash: hashMessage(message),
|
|
142
|
+
privateKey,
|
|
143
|
+
to: "hex"
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
//#endregion
|
|
147
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/accounts/utils/signTransaction.js
|
|
148
|
+
async function signTransaction(parameters) {
|
|
149
|
+
const { privateKey, transaction, serializer = serializeTransaction } = parameters;
|
|
150
|
+
return await serializer(transaction, await sign({
|
|
151
|
+
hash: keccak256(await serializer((() => {
|
|
152
|
+
if (transaction.type === "eip4844") return {
|
|
153
|
+
...transaction,
|
|
154
|
+
sidecars: false
|
|
155
|
+
};
|
|
156
|
+
return transaction;
|
|
157
|
+
})())),
|
|
158
|
+
privateKey
|
|
159
|
+
}));
|
|
160
|
+
}
|
|
161
|
+
//#endregion
|
|
162
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/accounts/utils/signTypedData.js
|
|
163
|
+
/**
|
|
164
|
+
* @description Signs typed data and calculates an Ethereum-specific signature in [https://eips.ethereum.org/EIPS/eip-712](https://eips.ethereum.org/EIPS/eip-712):
|
|
165
|
+
* `sign(keccak256("\x19\x01" ‖ domainSeparator ‖ hashStruct(message)))`.
|
|
166
|
+
*
|
|
167
|
+
* @returns The signature.
|
|
168
|
+
*/
|
|
169
|
+
async function signTypedData(parameters) {
|
|
170
|
+
const { privateKey, ...typedData } = parameters;
|
|
171
|
+
return await sign({
|
|
172
|
+
hash: hashTypedData(typedData),
|
|
173
|
+
privateKey,
|
|
174
|
+
to: "hex"
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/accounts/privateKeyToAccount.js
|
|
179
|
+
/**
|
|
180
|
+
* @description Creates an Account from a private key.
|
|
181
|
+
*
|
|
182
|
+
* @returns A Private Key Account.
|
|
183
|
+
*/
|
|
184
|
+
function privateKeyToAccount(privateKey, options = {}) {
|
|
185
|
+
const { nonceManager } = options;
|
|
186
|
+
const publicKey = toHex(secp256k1.getPublicKey(privateKey.slice(2), false));
|
|
187
|
+
return {
|
|
188
|
+
...toAccount({
|
|
189
|
+
address: publicKeyToAddress(publicKey),
|
|
190
|
+
nonceManager,
|
|
191
|
+
async sign({ hash }) {
|
|
192
|
+
return sign({
|
|
193
|
+
hash,
|
|
194
|
+
privateKey,
|
|
195
|
+
to: "hex"
|
|
196
|
+
});
|
|
197
|
+
},
|
|
198
|
+
async signAuthorization(authorization) {
|
|
199
|
+
return signAuthorization({
|
|
200
|
+
...authorization,
|
|
201
|
+
privateKey
|
|
202
|
+
});
|
|
203
|
+
},
|
|
204
|
+
async signMessage({ message }) {
|
|
205
|
+
return signMessage({
|
|
206
|
+
message,
|
|
207
|
+
privateKey
|
|
208
|
+
});
|
|
209
|
+
},
|
|
210
|
+
async signTransaction(transaction, { serializer } = {}) {
|
|
211
|
+
return signTransaction({
|
|
212
|
+
privateKey,
|
|
213
|
+
transaction,
|
|
214
|
+
serializer
|
|
215
|
+
});
|
|
216
|
+
},
|
|
217
|
+
async signTypedData(typedData) {
|
|
218
|
+
return signTypedData({
|
|
219
|
+
...typedData,
|
|
220
|
+
privateKey
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
}),
|
|
224
|
+
publicKey,
|
|
225
|
+
source: "privateKey"
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
//#endregion
|
|
229
|
+
export { signAuthorization as a, serializeSignature as c, signMessage as i, hashMessage as l, signTypedData as n, sign as o, signTransaction as r, toAccount as s, privateKeyToAccount as t };
|