@vultisig/cli 4.4.0 → 4.5.0
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 +29 -0
- package/dist/index.js +131 -1180
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -24,11 +24,11 @@ var __export = (target, all) => {
|
|
|
24
24
|
for (var name in all)
|
|
25
25
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
26
26
|
};
|
|
27
|
-
var __copyProps = (to,
|
|
28
|
-
if (
|
|
29
|
-
for (let key of __getOwnPropNames(
|
|
27
|
+
var __copyProps = (to, from, except, desc) => {
|
|
28
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
29
|
+
for (let key of __getOwnPropNames(from))
|
|
30
30
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
31
|
-
__defProp(to, key, { get: () =>
|
|
31
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
32
32
|
}
|
|
33
33
|
return to;
|
|
34
34
|
};
|
|
@@ -1234,70 +1234,11 @@ var init_base = __esm({
|
|
|
1234
1234
|
}
|
|
1235
1235
|
});
|
|
1236
1236
|
|
|
1237
|
-
// ../../node_modules/viem/_esm/errors/abi.js
|
|
1238
|
-
var AbiEncodingArrayLengthMismatchError, AbiEncodingBytesSizeMismatchError, AbiEncodingLengthMismatchError, BytesSizeMismatchError, InvalidAbiEncodingTypeError, InvalidArrayError;
|
|
1239
|
-
var init_abi = __esm({
|
|
1240
|
-
"../../node_modules/viem/_esm/errors/abi.js"() {
|
|
1241
|
-
init_size();
|
|
1242
|
-
init_base();
|
|
1243
|
-
AbiEncodingArrayLengthMismatchError = class extends BaseError {
|
|
1244
|
-
constructor({ expectedLength, givenLength, type }) {
|
|
1245
|
-
super([
|
|
1246
|
-
`ABI encoding array length mismatch for type ${type}.`,
|
|
1247
|
-
`Expected length: ${expectedLength}`,
|
|
1248
|
-
`Given length: ${givenLength}`
|
|
1249
|
-
].join("\n"), { name: "AbiEncodingArrayLengthMismatchError" });
|
|
1250
|
-
}
|
|
1251
|
-
};
|
|
1252
|
-
AbiEncodingBytesSizeMismatchError = class extends BaseError {
|
|
1253
|
-
constructor({ expectedSize, value }) {
|
|
1254
|
-
super(`Size of bytes "${value}" (bytes${size(value)}) does not match expected size (bytes${expectedSize}).`, { name: "AbiEncodingBytesSizeMismatchError" });
|
|
1255
|
-
}
|
|
1256
|
-
};
|
|
1257
|
-
AbiEncodingLengthMismatchError = class extends BaseError {
|
|
1258
|
-
constructor({ expectedLength, givenLength }) {
|
|
1259
|
-
super([
|
|
1260
|
-
"ABI encoding params/values length mismatch.",
|
|
1261
|
-
`Expected length (params): ${expectedLength}`,
|
|
1262
|
-
`Given length (values): ${givenLength}`
|
|
1263
|
-
].join("\n"), { name: "AbiEncodingLengthMismatchError" });
|
|
1264
|
-
}
|
|
1265
|
-
};
|
|
1266
|
-
BytesSizeMismatchError = class extends BaseError {
|
|
1267
|
-
constructor({ expectedSize, givenSize }) {
|
|
1268
|
-
super(`Expected bytes${expectedSize}, got bytes${givenSize}.`, {
|
|
1269
|
-
name: "BytesSizeMismatchError"
|
|
1270
|
-
});
|
|
1271
|
-
}
|
|
1272
|
-
};
|
|
1273
|
-
InvalidAbiEncodingTypeError = class extends BaseError {
|
|
1274
|
-
constructor(type, { docsPath }) {
|
|
1275
|
-
super([
|
|
1276
|
-
`Type "${type}" is not a valid encoding type.`,
|
|
1277
|
-
"Please provide a valid ABI type."
|
|
1278
|
-
].join("\n"), { docsPath, name: "InvalidAbiEncodingType" });
|
|
1279
|
-
}
|
|
1280
|
-
};
|
|
1281
|
-
InvalidArrayError = class extends BaseError {
|
|
1282
|
-
constructor(value) {
|
|
1283
|
-
super([`Value "${value}" is not a valid array.`].join("\n"), {
|
|
1284
|
-
name: "InvalidArrayError"
|
|
1285
|
-
});
|
|
1286
|
-
}
|
|
1287
|
-
};
|
|
1288
|
-
}
|
|
1289
|
-
});
|
|
1290
|
-
|
|
1291
1237
|
// ../../node_modules/viem/_esm/errors/data.js
|
|
1292
|
-
var
|
|
1238
|
+
var SizeExceedsPaddingSizeError;
|
|
1293
1239
|
var init_data = __esm({
|
|
1294
1240
|
"../../node_modules/viem/_esm/errors/data.js"() {
|
|
1295
1241
|
init_base();
|
|
1296
|
-
SliceOffsetOutOfBoundsError = class extends BaseError {
|
|
1297
|
-
constructor({ offset, position, size: size2 }) {
|
|
1298
|
-
super(`Slice ${position === "start" ? "starting" : "ending"} at offset "${offset}" is out-of-bounds (size: ${size2}).`, { name: "SliceOffsetOutOfBoundsError" });
|
|
1299
|
-
}
|
|
1300
|
-
};
|
|
1301
1242
|
SizeExceedsPaddingSizeError = class extends BaseError {
|
|
1302
1243
|
constructor({ size: size2, targetSize, type }) {
|
|
1303
1244
|
super(`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} size (${size2}) exceeds padding size (${targetSize}).`, { name: "SizeExceedsPaddingSizeError" });
|
|
@@ -1912,25 +1853,6 @@ var init_keccak256 = __esm({
|
|
|
1912
1853
|
}
|
|
1913
1854
|
});
|
|
1914
1855
|
|
|
1915
|
-
// ../../node_modules/viem/_esm/errors/address.js
|
|
1916
|
-
var InvalidAddressError2;
|
|
1917
|
-
var init_address = __esm({
|
|
1918
|
-
"../../node_modules/viem/_esm/errors/address.js"() {
|
|
1919
|
-
init_base();
|
|
1920
|
-
InvalidAddressError2 = class extends BaseError {
|
|
1921
|
-
constructor({ address }) {
|
|
1922
|
-
super(`Address "${address}" is invalid.`, {
|
|
1923
|
-
metaMessages: [
|
|
1924
|
-
"- Address must be a hex value of 20 bytes (40 hex characters).",
|
|
1925
|
-
"- Address must match its checksum counterpart."
|
|
1926
|
-
],
|
|
1927
|
-
name: "InvalidAddressError"
|
|
1928
|
-
});
|
|
1929
|
-
}
|
|
1930
|
-
};
|
|
1931
|
-
}
|
|
1932
|
-
});
|
|
1933
|
-
|
|
1934
1856
|
// ../../node_modules/viem/_esm/utils/lru.js
|
|
1935
1857
|
var LruMap;
|
|
1936
1858
|
var init_lru = __esm({
|
|
@@ -1998,374 +1920,6 @@ var init_getAddress = __esm({
|
|
|
1998
1920
|
}
|
|
1999
1921
|
});
|
|
2000
1922
|
|
|
2001
|
-
// ../../node_modules/viem/_esm/utils/address/isAddress.js
|
|
2002
|
-
function isAddress(address, options) {
|
|
2003
|
-
const { strict = true } = options ?? {};
|
|
2004
|
-
const cacheKey = `${address}.${strict}`;
|
|
2005
|
-
if (isAddressCache.has(cacheKey))
|
|
2006
|
-
return isAddressCache.get(cacheKey);
|
|
2007
|
-
const result = (() => {
|
|
2008
|
-
if (!addressRegex.test(address))
|
|
2009
|
-
return false;
|
|
2010
|
-
if (address.toLowerCase() === address)
|
|
2011
|
-
return true;
|
|
2012
|
-
if (strict)
|
|
2013
|
-
return checksumAddress(address) === address;
|
|
2014
|
-
return true;
|
|
2015
|
-
})();
|
|
2016
|
-
isAddressCache.set(cacheKey, result);
|
|
2017
|
-
return result;
|
|
2018
|
-
}
|
|
2019
|
-
var addressRegex, isAddressCache;
|
|
2020
|
-
var init_isAddress = __esm({
|
|
2021
|
-
"../../node_modules/viem/_esm/utils/address/isAddress.js"() {
|
|
2022
|
-
init_lru();
|
|
2023
|
-
init_getAddress();
|
|
2024
|
-
addressRegex = /^0x[a-fA-F0-9]{40}$/;
|
|
2025
|
-
isAddressCache = /* @__PURE__ */ new LruMap(8192);
|
|
2026
|
-
}
|
|
2027
|
-
});
|
|
2028
|
-
|
|
2029
|
-
// ../../node_modules/viem/_esm/utils/data/concat.js
|
|
2030
|
-
function concat(values) {
|
|
2031
|
-
if (typeof values[0] === "string")
|
|
2032
|
-
return concatHex(values);
|
|
2033
|
-
return concatBytes2(values);
|
|
2034
|
-
}
|
|
2035
|
-
function concatBytes2(values) {
|
|
2036
|
-
let length = 0;
|
|
2037
|
-
for (const arr of values) {
|
|
2038
|
-
length += arr.length;
|
|
2039
|
-
}
|
|
2040
|
-
const result = new Uint8Array(length);
|
|
2041
|
-
let offset = 0;
|
|
2042
|
-
for (const arr of values) {
|
|
2043
|
-
result.set(arr, offset);
|
|
2044
|
-
offset += arr.length;
|
|
2045
|
-
}
|
|
2046
|
-
return result;
|
|
2047
|
-
}
|
|
2048
|
-
function concatHex(values) {
|
|
2049
|
-
return `0x${values.reduce((acc, x) => acc + x.replace("0x", ""), "")}`;
|
|
2050
|
-
}
|
|
2051
|
-
var init_concat = __esm({
|
|
2052
|
-
"../../node_modules/viem/_esm/utils/data/concat.js"() {
|
|
2053
|
-
}
|
|
2054
|
-
});
|
|
2055
|
-
|
|
2056
|
-
// ../../node_modules/viem/_esm/utils/data/slice.js
|
|
2057
|
-
function slice(value, start, end, { strict } = {}) {
|
|
2058
|
-
if (isHex(value, { strict: false }))
|
|
2059
|
-
return sliceHex(value, start, end, {
|
|
2060
|
-
strict
|
|
2061
|
-
});
|
|
2062
|
-
return sliceBytes(value, start, end, {
|
|
2063
|
-
strict
|
|
2064
|
-
});
|
|
2065
|
-
}
|
|
2066
|
-
function assertStartOffset(value, start) {
|
|
2067
|
-
if (typeof start === "number" && start > 0 && start > size(value) - 1)
|
|
2068
|
-
throw new SliceOffsetOutOfBoundsError({
|
|
2069
|
-
offset: start,
|
|
2070
|
-
position: "start",
|
|
2071
|
-
size: size(value)
|
|
2072
|
-
});
|
|
2073
|
-
}
|
|
2074
|
-
function assertEndOffset(value, start, end) {
|
|
2075
|
-
if (typeof start === "number" && typeof end === "number" && size(value) !== end - start) {
|
|
2076
|
-
throw new SliceOffsetOutOfBoundsError({
|
|
2077
|
-
offset: end,
|
|
2078
|
-
position: "end",
|
|
2079
|
-
size: size(value)
|
|
2080
|
-
});
|
|
2081
|
-
}
|
|
2082
|
-
}
|
|
2083
|
-
function sliceBytes(value_, start, end, { strict } = {}) {
|
|
2084
|
-
assertStartOffset(value_, start);
|
|
2085
|
-
const value = value_.slice(start, end);
|
|
2086
|
-
if (strict)
|
|
2087
|
-
assertEndOffset(value, start, end);
|
|
2088
|
-
return value;
|
|
2089
|
-
}
|
|
2090
|
-
function sliceHex(value_, start, end, { strict } = {}) {
|
|
2091
|
-
assertStartOffset(value_, start);
|
|
2092
|
-
const value = `0x${value_.replace("0x", "").slice((start ?? 0) * 2, (end ?? value_.length) * 2)}`;
|
|
2093
|
-
if (strict)
|
|
2094
|
-
assertEndOffset(value, start, end);
|
|
2095
|
-
return value;
|
|
2096
|
-
}
|
|
2097
|
-
var init_slice = __esm({
|
|
2098
|
-
"../../node_modules/viem/_esm/utils/data/slice.js"() {
|
|
2099
|
-
init_data();
|
|
2100
|
-
init_isHex();
|
|
2101
|
-
init_size();
|
|
2102
|
-
}
|
|
2103
|
-
});
|
|
2104
|
-
|
|
2105
|
-
// ../../node_modules/viem/_esm/utils/regex.js
|
|
2106
|
-
var bytesRegex, integerRegex;
|
|
2107
|
-
var init_regex = __esm({
|
|
2108
|
-
"../../node_modules/viem/_esm/utils/regex.js"() {
|
|
2109
|
-
bytesRegex = /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/;
|
|
2110
|
-
integerRegex = /^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;
|
|
2111
|
-
}
|
|
2112
|
-
});
|
|
2113
|
-
|
|
2114
|
-
// ../../node_modules/viem/_esm/utils/abi/encodeAbiParameters.js
|
|
2115
|
-
function encodeAbiParameters(params, values) {
|
|
2116
|
-
if (params.length !== values.length)
|
|
2117
|
-
throw new AbiEncodingLengthMismatchError({
|
|
2118
|
-
expectedLength: params.length,
|
|
2119
|
-
givenLength: values.length
|
|
2120
|
-
});
|
|
2121
|
-
const preparedParams = prepareParams({
|
|
2122
|
-
params,
|
|
2123
|
-
values
|
|
2124
|
-
});
|
|
2125
|
-
return encodeParams(preparedParams);
|
|
2126
|
-
}
|
|
2127
|
-
function prepareParams({ params, values }) {
|
|
2128
|
-
const preparedParams = [];
|
|
2129
|
-
for (let i = 0; i < params.length; i++) {
|
|
2130
|
-
preparedParams.push(prepareParam({ param: params[i], value: values[i] }));
|
|
2131
|
-
}
|
|
2132
|
-
return preparedParams;
|
|
2133
|
-
}
|
|
2134
|
-
function prepareParam({ param, value }) {
|
|
2135
|
-
const arrayComponents = getArrayComponents(param.type);
|
|
2136
|
-
if (arrayComponents) {
|
|
2137
|
-
const [length, type] = arrayComponents;
|
|
2138
|
-
return encodeArray(value, { length, param: { ...param, type } });
|
|
2139
|
-
}
|
|
2140
|
-
if (param.type === "tuple") {
|
|
2141
|
-
return encodeTuple(value, {
|
|
2142
|
-
param
|
|
2143
|
-
});
|
|
2144
|
-
}
|
|
2145
|
-
if (param.type === "address") {
|
|
2146
|
-
return encodeAddress(value);
|
|
2147
|
-
}
|
|
2148
|
-
if (param.type === "bool") {
|
|
2149
|
-
return encodeBool(value);
|
|
2150
|
-
}
|
|
2151
|
-
if (param.type.startsWith("uint") || param.type.startsWith("int")) {
|
|
2152
|
-
const signed = param.type.startsWith("int");
|
|
2153
|
-
const [, , size2 = "256"] = integerRegex.exec(param.type) ?? [];
|
|
2154
|
-
return encodeNumber(value, {
|
|
2155
|
-
signed,
|
|
2156
|
-
size: Number(size2)
|
|
2157
|
-
});
|
|
2158
|
-
}
|
|
2159
|
-
if (param.type.startsWith("bytes")) {
|
|
2160
|
-
return encodeBytes(value, { param });
|
|
2161
|
-
}
|
|
2162
|
-
if (param.type === "string") {
|
|
2163
|
-
return encodeString(value);
|
|
2164
|
-
}
|
|
2165
|
-
throw new InvalidAbiEncodingTypeError(param.type, {
|
|
2166
|
-
docsPath: "/docs/contract/encodeAbiParameters"
|
|
2167
|
-
});
|
|
2168
|
-
}
|
|
2169
|
-
function encodeParams(preparedParams) {
|
|
2170
|
-
let staticSize = 0;
|
|
2171
|
-
for (let i = 0; i < preparedParams.length; i++) {
|
|
2172
|
-
const { dynamic, encoded } = preparedParams[i];
|
|
2173
|
-
if (dynamic)
|
|
2174
|
-
staticSize += 32;
|
|
2175
|
-
else
|
|
2176
|
-
staticSize += size(encoded);
|
|
2177
|
-
}
|
|
2178
|
-
const staticParams = [];
|
|
2179
|
-
const dynamicParams = [];
|
|
2180
|
-
let dynamicSize = 0;
|
|
2181
|
-
for (let i = 0; i < preparedParams.length; i++) {
|
|
2182
|
-
const { dynamic, encoded } = preparedParams[i];
|
|
2183
|
-
if (dynamic) {
|
|
2184
|
-
staticParams.push(numberToHex(staticSize + dynamicSize, { size: 32 }));
|
|
2185
|
-
dynamicParams.push(encoded);
|
|
2186
|
-
dynamicSize += size(encoded);
|
|
2187
|
-
} else {
|
|
2188
|
-
staticParams.push(encoded);
|
|
2189
|
-
}
|
|
2190
|
-
}
|
|
2191
|
-
return concatHex([...staticParams, ...dynamicParams]);
|
|
2192
|
-
}
|
|
2193
|
-
function encodeAddress(value) {
|
|
2194
|
-
if (!isAddress(value))
|
|
2195
|
-
throw new InvalidAddressError2({ address: value });
|
|
2196
|
-
return { dynamic: false, encoded: padHex(value.toLowerCase()) };
|
|
2197
|
-
}
|
|
2198
|
-
function encodeArray(value, { length, param }) {
|
|
2199
|
-
const dynamic = length === null;
|
|
2200
|
-
if (!Array.isArray(value))
|
|
2201
|
-
throw new InvalidArrayError(value);
|
|
2202
|
-
if (!dynamic && value.length !== length)
|
|
2203
|
-
throw new AbiEncodingArrayLengthMismatchError({
|
|
2204
|
-
expectedLength: length,
|
|
2205
|
-
givenLength: value.length,
|
|
2206
|
-
type: `${param.type}[${length}]`
|
|
2207
|
-
});
|
|
2208
|
-
let dynamicChild = value.length === 0 && isDynamicType(param);
|
|
2209
|
-
const preparedParams = [];
|
|
2210
|
-
for (let i = 0; i < value.length; i++) {
|
|
2211
|
-
const preparedParam = prepareParam({ param, value: value[i] });
|
|
2212
|
-
if (preparedParam.dynamic)
|
|
2213
|
-
dynamicChild = true;
|
|
2214
|
-
preparedParams.push(preparedParam);
|
|
2215
|
-
}
|
|
2216
|
-
if (dynamic || dynamicChild) {
|
|
2217
|
-
const data = encodeParams(preparedParams);
|
|
2218
|
-
if (dynamic) {
|
|
2219
|
-
const length2 = numberToHex(preparedParams.length, { size: 32 });
|
|
2220
|
-
return {
|
|
2221
|
-
dynamic: true,
|
|
2222
|
-
encoded: concatHex([length2, data])
|
|
2223
|
-
};
|
|
2224
|
-
}
|
|
2225
|
-
if (dynamicChild)
|
|
2226
|
-
return { dynamic: true, encoded: data };
|
|
2227
|
-
}
|
|
2228
|
-
return {
|
|
2229
|
-
dynamic: false,
|
|
2230
|
-
encoded: concatHex(preparedParams.map(({ encoded }) => encoded))
|
|
2231
|
-
};
|
|
2232
|
-
}
|
|
2233
|
-
function encodeBytes(value, { param }) {
|
|
2234
|
-
const [, paramSize] = param.type.split("bytes");
|
|
2235
|
-
const bytesSize = size(value);
|
|
2236
|
-
if (!paramSize) {
|
|
2237
|
-
let value_ = value;
|
|
2238
|
-
if (bytesSize % 32 !== 0)
|
|
2239
|
-
value_ = padHex(value_, {
|
|
2240
|
-
dir: "right",
|
|
2241
|
-
size: Math.ceil((value.length - 2) / 2 / 32) * 32
|
|
2242
|
-
});
|
|
2243
|
-
return {
|
|
2244
|
-
dynamic: true,
|
|
2245
|
-
encoded: concatHex([
|
|
2246
|
-
padHex(numberToHex(bytesSize, { size: 32 })),
|
|
2247
|
-
value_
|
|
2248
|
-
])
|
|
2249
|
-
};
|
|
2250
|
-
}
|
|
2251
|
-
if (bytesSize !== Number.parseInt(paramSize, 10))
|
|
2252
|
-
throw new AbiEncodingBytesSizeMismatchError({
|
|
2253
|
-
expectedSize: Number.parseInt(paramSize, 10),
|
|
2254
|
-
value
|
|
2255
|
-
});
|
|
2256
|
-
return { dynamic: false, encoded: padHex(value, { dir: "right" }) };
|
|
2257
|
-
}
|
|
2258
|
-
function encodeBool(value) {
|
|
2259
|
-
if (typeof value !== "boolean")
|
|
2260
|
-
throw new BaseError(`Invalid boolean value: "${value}" (type: ${typeof value}). Expected: \`true\` or \`false\`.`);
|
|
2261
|
-
return { dynamic: false, encoded: padHex(boolToHex(value)) };
|
|
2262
|
-
}
|
|
2263
|
-
function encodeNumber(value, { signed, size: size2 = 256 }) {
|
|
2264
|
-
if (typeof size2 === "number") {
|
|
2265
|
-
const max = 2n ** (BigInt(size2) - (signed ? 1n : 0n)) - 1n;
|
|
2266
|
-
const min = signed ? -max - 1n : 0n;
|
|
2267
|
-
if (value > max || value < min)
|
|
2268
|
-
throw new IntegerOutOfRangeError({
|
|
2269
|
-
max: max.toString(),
|
|
2270
|
-
min: min.toString(),
|
|
2271
|
-
signed,
|
|
2272
|
-
size: size2 / 8,
|
|
2273
|
-
value: value.toString()
|
|
2274
|
-
});
|
|
2275
|
-
}
|
|
2276
|
-
return {
|
|
2277
|
-
dynamic: false,
|
|
2278
|
-
encoded: numberToHex(value, {
|
|
2279
|
-
size: 32,
|
|
2280
|
-
signed
|
|
2281
|
-
})
|
|
2282
|
-
};
|
|
2283
|
-
}
|
|
2284
|
-
function encodeString(value) {
|
|
2285
|
-
const hexValue = stringToHex(value);
|
|
2286
|
-
const partsLength = Math.ceil(size(hexValue) / 32);
|
|
2287
|
-
const parts = [];
|
|
2288
|
-
for (let i = 0; i < partsLength; i++) {
|
|
2289
|
-
parts.push(padHex(slice(hexValue, i * 32, (i + 1) * 32), {
|
|
2290
|
-
dir: "right"
|
|
2291
|
-
}));
|
|
2292
|
-
}
|
|
2293
|
-
return {
|
|
2294
|
-
dynamic: true,
|
|
2295
|
-
encoded: concatHex([
|
|
2296
|
-
padHex(numberToHex(size(hexValue), { size: 32 })),
|
|
2297
|
-
...parts
|
|
2298
|
-
])
|
|
2299
|
-
};
|
|
2300
|
-
}
|
|
2301
|
-
function encodeTuple(value, { param }) {
|
|
2302
|
-
let dynamic = false;
|
|
2303
|
-
const preparedParams = [];
|
|
2304
|
-
for (let i = 0; i < param.components.length; i++) {
|
|
2305
|
-
const param_ = param.components[i];
|
|
2306
|
-
const index = Array.isArray(value) ? i : param_.name;
|
|
2307
|
-
const preparedParam = prepareParam({
|
|
2308
|
-
param: param_,
|
|
2309
|
-
value: value[index]
|
|
2310
|
-
});
|
|
2311
|
-
preparedParams.push(preparedParam);
|
|
2312
|
-
if (preparedParam.dynamic)
|
|
2313
|
-
dynamic = true;
|
|
2314
|
-
}
|
|
2315
|
-
return {
|
|
2316
|
-
dynamic,
|
|
2317
|
-
encoded: dynamic ? encodeParams(preparedParams) : concatHex(preparedParams.map(({ encoded }) => encoded))
|
|
2318
|
-
};
|
|
2319
|
-
}
|
|
2320
|
-
function getArrayComponents(type) {
|
|
2321
|
-
const matches = type.match(/^(.*)\[(\d+)?\]$/);
|
|
2322
|
-
return matches ? (
|
|
2323
|
-
// Return `null` if the array is dynamic.
|
|
2324
|
-
[matches[2] ? Number(matches[2]) : null, matches[1]]
|
|
2325
|
-
) : void 0;
|
|
2326
|
-
}
|
|
2327
|
-
function isDynamicType(param) {
|
|
2328
|
-
const { type } = param;
|
|
2329
|
-
if (type === "string")
|
|
2330
|
-
return true;
|
|
2331
|
-
if (type === "bytes")
|
|
2332
|
-
return true;
|
|
2333
|
-
if (type.endsWith("[]"))
|
|
2334
|
-
return true;
|
|
2335
|
-
if (type === "tuple")
|
|
2336
|
-
return param.components.some(isDynamicType);
|
|
2337
|
-
const arrayComponents = getArrayComponents(type);
|
|
2338
|
-
if (arrayComponents)
|
|
2339
|
-
return isDynamicType({ ...param, type: arrayComponents[1] });
|
|
2340
|
-
return false;
|
|
2341
|
-
}
|
|
2342
|
-
var init_encodeAbiParameters = __esm({
|
|
2343
|
-
"../../node_modules/viem/_esm/utils/abi/encodeAbiParameters.js"() {
|
|
2344
|
-
init_abi();
|
|
2345
|
-
init_address();
|
|
2346
|
-
init_base();
|
|
2347
|
-
init_encoding();
|
|
2348
|
-
init_isAddress();
|
|
2349
|
-
init_concat();
|
|
2350
|
-
init_pad();
|
|
2351
|
-
init_size();
|
|
2352
|
-
init_slice();
|
|
2353
|
-
init_toHex();
|
|
2354
|
-
init_regex();
|
|
2355
|
-
}
|
|
2356
|
-
});
|
|
2357
|
-
|
|
2358
|
-
// ../../node_modules/viem/_esm/utils/stringify.js
|
|
2359
|
-
var stringify;
|
|
2360
|
-
var init_stringify = __esm({
|
|
2361
|
-
"../../node_modules/viem/_esm/utils/stringify.js"() {
|
|
2362
|
-
stringify = (value, replacer, space) => JSON.stringify(value, (key, value_) => {
|
|
2363
|
-
const value2 = typeof value_ === "bigint" ? value_.toString() : value_;
|
|
2364
|
-
return typeof replacer === "function" ? replacer(key, value2) : value2;
|
|
2365
|
-
}, space);
|
|
2366
|
-
}
|
|
2367
|
-
});
|
|
2368
|
-
|
|
2369
1923
|
// ../../node_modules/viem/_esm/utils/unit/Value.js
|
|
2370
1924
|
function format(value, decimals = 0) {
|
|
2371
1925
|
if (!Number.isInteger(decimals) || decimals < 0)
|
|
@@ -2382,69 +1936,9 @@ function format(value, decimals = 0) {
|
|
|
2382
1936
|
fraction = fraction.replace(/(0+)$/, "");
|
|
2383
1937
|
return `${negative ? "-" : ""}${integer || "0"}${fraction ? `.${fraction}` : ""}`;
|
|
2384
1938
|
}
|
|
2385
|
-
|
|
2386
|
-
if (!Number.isInteger(decimals) || decimals < 0)
|
|
2387
|
-
throw new InvalidDecimalsError({ decimals });
|
|
2388
|
-
if (!/^-?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)$/.test(value))
|
|
2389
|
-
throw new InvalidDecimalNumberError({ value });
|
|
2390
|
-
let [integer = "", fraction = "0"] = value.split(".");
|
|
2391
|
-
const negative = integer.startsWith("-");
|
|
2392
|
-
if (negative)
|
|
2393
|
-
integer = integer.slice(1);
|
|
2394
|
-
if (integer === "")
|
|
2395
|
-
integer = "0";
|
|
2396
|
-
fraction = fraction.replace(/(0+)$/, "");
|
|
2397
|
-
if (decimals === 0) {
|
|
2398
|
-
if (fraction.length > 0 && Number.parseInt(fraction[0], 10) >= 5)
|
|
2399
|
-
integer = `${BigInt(integer) + 1n}`;
|
|
2400
|
-
fraction = "";
|
|
2401
|
-
} else if (fraction.length > decimals) {
|
|
2402
|
-
const left = fraction.slice(0, decimals);
|
|
2403
|
-
const roundDigit = Number.parseInt(fraction.slice(decimals, decimals + 1), 10);
|
|
2404
|
-
if (roundDigit >= 5) {
|
|
2405
|
-
const carried = carry(left);
|
|
2406
|
-
if (carried.length > decimals) {
|
|
2407
|
-
fraction = carried.slice(1);
|
|
2408
|
-
integer = `${BigInt(integer) + 1n}`;
|
|
2409
|
-
} else {
|
|
2410
|
-
fraction = carried;
|
|
2411
|
-
}
|
|
2412
|
-
} else {
|
|
2413
|
-
fraction = left;
|
|
2414
|
-
}
|
|
2415
|
-
} else {
|
|
2416
|
-
fraction = fraction.padEnd(decimals, "0");
|
|
2417
|
-
}
|
|
2418
|
-
return BigInt(`${negative ? "-" : ""}${integer}${fraction}`);
|
|
2419
|
-
}
|
|
2420
|
-
function carry(digits) {
|
|
2421
|
-
const out = digits.split("");
|
|
2422
|
-
let i = out.length - 1;
|
|
2423
|
-
while (i >= 0) {
|
|
2424
|
-
const d = Number.parseInt(out[i], 10) + 1;
|
|
2425
|
-
if (d < 10) {
|
|
2426
|
-
out[i] = String(d);
|
|
2427
|
-
return out.join("");
|
|
2428
|
-
}
|
|
2429
|
-
out[i] = "0";
|
|
2430
|
-
i--;
|
|
2431
|
-
}
|
|
2432
|
-
return `1${out.join("")}`;
|
|
2433
|
-
}
|
|
2434
|
-
var InvalidDecimalNumberError, InvalidDecimalsError;
|
|
1939
|
+
var InvalidDecimalsError;
|
|
2435
1940
|
var init_Value = __esm({
|
|
2436
1941
|
"../../node_modules/viem/_esm/utils/unit/Value.js"() {
|
|
2437
|
-
InvalidDecimalNumberError = class extends Error {
|
|
2438
|
-
constructor({ value }) {
|
|
2439
|
-
super(`Value \`${value}\` is not a valid decimal number.`);
|
|
2440
|
-
Object.defineProperty(this, "name", {
|
|
2441
|
-
enumerable: true,
|
|
2442
|
-
configurable: true,
|
|
2443
|
-
writable: true,
|
|
2444
|
-
value: "Value.InvalidDecimalNumberError"
|
|
2445
|
-
});
|
|
2446
|
-
}
|
|
2447
|
-
};
|
|
2448
1942
|
InvalidDecimalsError = class extends Error {
|
|
2449
1943
|
constructor({ decimals }) {
|
|
2450
1944
|
super(`\`decimals\` must be a non-negative integer. Got \`${decimals}\`.`);
|
|
@@ -2898,7 +2392,7 @@ function ensureBytes(title, hex, expectedLength) {
|
|
|
2898
2392
|
throw new Error(title + " of length " + expectedLength + " expected, got " + len);
|
|
2899
2393
|
return res;
|
|
2900
2394
|
}
|
|
2901
|
-
function
|
|
2395
|
+
function concatBytes2(...arrays) {
|
|
2902
2396
|
let sum = 0;
|
|
2903
2397
|
for (let i = 0; i < arrays.length; i++) {
|
|
2904
2398
|
const a = arrays[i];
|
|
@@ -2966,7 +2460,7 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
|
2966
2460
|
out.push(sl);
|
|
2967
2461
|
len += v.length;
|
|
2968
2462
|
}
|
|
2969
|
-
return
|
|
2463
|
+
return concatBytes2(...out);
|
|
2970
2464
|
};
|
|
2971
2465
|
const genUntil = (seed, pred) => {
|
|
2972
2466
|
reset();
|
|
@@ -3598,7 +3092,7 @@ function weierstrassPoints(opts) {
|
|
|
3598
3092
|
const Fn = Field(CURVE.n, CURVE.nBitLength);
|
|
3599
3093
|
const toBytes3 = CURVE.toBytes || ((_c, point, _isCompressed) => {
|
|
3600
3094
|
const a = point.toAffine();
|
|
3601
|
-
return
|
|
3095
|
+
return concatBytes2(Uint8Array.from([4]), Fp.toBytes(a.x), Fp.toBytes(a.y));
|
|
3602
3096
|
});
|
|
3603
3097
|
const fromBytes = CURVE.fromBytes || ((bytes) => {
|
|
3604
3098
|
const tail = bytes.subarray(1);
|
|
@@ -4024,7 +3518,7 @@ function weierstrass(curveDef) {
|
|
|
4024
3518
|
toBytes(_c, point, isCompressed) {
|
|
4025
3519
|
const a = point.toAffine();
|
|
4026
3520
|
const x = Fp.toBytes(a.x);
|
|
4027
|
-
const cat =
|
|
3521
|
+
const cat = concatBytes2;
|
|
4028
3522
|
abool("isCompressed", isCompressed);
|
|
4029
3523
|
if (isCompressed) {
|
|
4030
3524
|
return cat(Uint8Array.from([point.hasEvenY() ? 2 : 3]), x);
|
|
@@ -4071,7 +3565,7 @@ function weierstrass(curveDef) {
|
|
|
4071
3565
|
function normalizeS(s) {
|
|
4072
3566
|
return isBiggerThanHalfOrder(s) ? modN2(-s) : s;
|
|
4073
3567
|
}
|
|
4074
|
-
const slcNum = (b,
|
|
3568
|
+
const slcNum = (b, from, to) => bytesToNumberBE(b.slice(from, to));
|
|
4075
3569
|
class Signature {
|
|
4076
3570
|
constructor(r, s, recovery) {
|
|
4077
3571
|
aInRange("r", r, _1n5, CURVE_ORDER);
|
|
@@ -4237,7 +3731,7 @@ function weierstrass(curveDef) {
|
|
|
4237
3731
|
const e = ent === true ? randomBytes4(Fp.BYTES) : ent;
|
|
4238
3732
|
seedArgs.push(ensureBytes("extraEntropy", e));
|
|
4239
3733
|
}
|
|
4240
|
-
const seed =
|
|
3734
|
+
const seed = concatBytes2(...seedArgs);
|
|
4241
3735
|
const m = h1int;
|
|
4242
3736
|
function k2sig(kBytes) {
|
|
4243
3737
|
const k = bits2int(kBytes);
|
|
@@ -4600,22 +4094,22 @@ function expand_message_xmd(msg, DST, lenInBytes, H) {
|
|
|
4600
4094
|
abytes2(DST);
|
|
4601
4095
|
anum(lenInBytes);
|
|
4602
4096
|
if (DST.length > 255)
|
|
4603
|
-
DST = H(
|
|
4097
|
+
DST = H(concatBytes2(utf8ToBytes2("H2C-OVERSIZE-DST-"), DST));
|
|
4604
4098
|
const { outputLen: b_in_bytes, blockLen: r_in_bytes } = H;
|
|
4605
4099
|
const ell = Math.ceil(lenInBytes / b_in_bytes);
|
|
4606
4100
|
if (lenInBytes > 65535 || ell > 255)
|
|
4607
4101
|
throw new Error("expand_message_xmd: invalid lenInBytes");
|
|
4608
|
-
const DST_prime =
|
|
4102
|
+
const DST_prime = concatBytes2(DST, i2osp(DST.length, 1));
|
|
4609
4103
|
const Z_pad = i2osp(0, r_in_bytes);
|
|
4610
4104
|
const l_i_b_str = i2osp(lenInBytes, 2);
|
|
4611
4105
|
const b = new Array(ell);
|
|
4612
|
-
const b_0 = H(
|
|
4613
|
-
b[0] = H(
|
|
4106
|
+
const b_0 = H(concatBytes2(Z_pad, msg, l_i_b_str, i2osp(0, 1), DST_prime));
|
|
4107
|
+
b[0] = H(concatBytes2(b_0, i2osp(1, 1), DST_prime));
|
|
4614
4108
|
for (let i = 1; i <= ell; i++) {
|
|
4615
4109
|
const args = [strxor(b_0, b[i - 1]), i2osp(i + 1, 1), DST_prime];
|
|
4616
|
-
b[i] = H(
|
|
4110
|
+
b[i] = H(concatBytes2(...args));
|
|
4617
4111
|
}
|
|
4618
|
-
const pseudo_random_bytes =
|
|
4112
|
+
const pseudo_random_bytes = concatBytes2(...b);
|
|
4619
4113
|
return pseudo_random_bytes.slice(0, lenInBytes);
|
|
4620
4114
|
}
|
|
4621
4115
|
function expand_message_xof(msg, DST, lenInBytes, k, H) {
|
|
@@ -4761,10 +4255,10 @@ function taggedHash(tag, ...messages) {
|
|
|
4761
4255
|
let tagP = TAGGED_HASH_PREFIXES[tag];
|
|
4762
4256
|
if (tagP === void 0) {
|
|
4763
4257
|
const tagH = sha256(Uint8Array.from(tag, (c) => c.charCodeAt(0)));
|
|
4764
|
-
tagP =
|
|
4258
|
+
tagP = concatBytes2(tagH, tagH);
|
|
4765
4259
|
TAGGED_HASH_PREFIXES[tag] = tagP;
|
|
4766
4260
|
}
|
|
4767
|
-
return sha256(
|
|
4261
|
+
return sha256(concatBytes2(tagP, ...messages));
|
|
4768
4262
|
}
|
|
4769
4263
|
function schnorrGetExtPubKey(priv) {
|
|
4770
4264
|
let d_ = secp256k1.utils.normPrivateKeyToScalar(priv);
|
|
@@ -4961,7 +4455,7 @@ var init_secp256k1 = __esm({
|
|
|
4961
4455
|
import "dotenv/config";
|
|
4962
4456
|
import { promises as fs4 } from "node:fs";
|
|
4963
4457
|
import { descriptions } from "@vultisig/client-shared";
|
|
4964
|
-
import { Chain as
|
|
4458
|
+
import { Chain as Chain13, parseKeygenQR, Vultisig as Vultisig6 } from "@vultisig/sdk";
|
|
4965
4459
|
import chalk16 from "chalk";
|
|
4966
4460
|
import { InvalidArgumentError, program as program2 } from "commander";
|
|
4967
4461
|
|
|
@@ -6016,7 +5510,7 @@ function displayVaultInfo(vault) {
|
|
|
6016
5510
|
printResult(` Chain Code: ${vault.hexChainCode.substring(0, 20)}...
|
|
6017
5511
|
`);
|
|
6018
5512
|
}
|
|
6019
|
-
function displayTransactionPreview(fromAddress, toAddress, amount, symbol, chain, memo, destinationTag, gas) {
|
|
5513
|
+
function displayTransactionPreview(fromAddress, toAddress, amount, symbol, chain, memo, destinationTag, gas, contractAddress) {
|
|
6020
5514
|
if (gas) {
|
|
6021
5515
|
const bigIntReplacer2 = (_k, v) => typeof v === "bigint" ? v.toString() : v;
|
|
6022
5516
|
info(chalk2.blue(`
|
|
@@ -6025,7 +5519,7 @@ Estimated gas: ${JSON.stringify(gas, bigIntReplacer2, 2)}`));
|
|
|
6025
5519
|
printResult(chalk2.cyan("\nTransaction Preview:"));
|
|
6026
5520
|
printResult(` From: ${fromAddress}`);
|
|
6027
5521
|
printResult(` To: ${toAddress}`);
|
|
6028
|
-
printResult(` Amount: ${amount} ${symbol}`);
|
|
5522
|
+
printResult(` Amount: ${amount} ${symbol}${contractAddress ? ` (${escapeTerminalControls(contractAddress)})` : ""}`);
|
|
6029
5523
|
printResult(` Chain: ${chain}`);
|
|
6030
5524
|
if (memo) {
|
|
6031
5525
|
printResult(` Memo: ${escapeTerminalControls(memo)}`);
|
|
@@ -6332,123 +5826,8 @@ function shouldAutoSelectActiveVault(hasActiveVault, corruptPointer, vaultCount)
|
|
|
6332
5826
|
return !hasActiveVault && !corruptPointer && vaultCount > 0;
|
|
6333
5827
|
}
|
|
6334
5828
|
|
|
6335
|
-
//
|
|
6336
|
-
|
|
6337
|
-
Arbitrum: "Arbitrum",
|
|
6338
|
-
Base: "Base",
|
|
6339
|
-
Blast: "Blast",
|
|
6340
|
-
Optimism: "Optimism",
|
|
6341
|
-
Zksync: "Zksync",
|
|
6342
|
-
Mantle: "Mantle",
|
|
6343
|
-
Robinhood: "Robinhood"
|
|
6344
|
-
};
|
|
6345
|
-
var EvmChain = {
|
|
6346
|
-
...EthereumL2Chain,
|
|
6347
|
-
Avalanche: "Avalanche",
|
|
6348
|
-
CronosChain: "CronosChain",
|
|
6349
|
-
BSC: "BSC",
|
|
6350
|
-
Ethereum: "Ethereum",
|
|
6351
|
-
Polygon: "Polygon",
|
|
6352
|
-
Hyperliquid: "Hyperliquid",
|
|
6353
|
-
Sei: "Sei"
|
|
6354
|
-
};
|
|
6355
|
-
var UtxoChain;
|
|
6356
|
-
(function(UtxoChain2) {
|
|
6357
|
-
UtxoChain2["Bitcoin"] = "Bitcoin";
|
|
6358
|
-
UtxoChain2["BitcoinCash"] = "Bitcoin-Cash";
|
|
6359
|
-
UtxoChain2["Litecoin"] = "Litecoin";
|
|
6360
|
-
UtxoChain2["Dogecoin"] = "Dogecoin";
|
|
6361
|
-
UtxoChain2["Dash"] = "Dash";
|
|
6362
|
-
UtxoChain2["Zcash"] = "Zcash";
|
|
6363
|
-
})(UtxoChain || (UtxoChain = {}));
|
|
6364
|
-
var cosmosChainsByKind = {
|
|
6365
|
-
ibcEnabled: {
|
|
6366
|
-
Cosmos: "Cosmos",
|
|
6367
|
-
Osmosis: "Osmosis",
|
|
6368
|
-
Dydx: "Dydx",
|
|
6369
|
-
Kujira: "Kujira",
|
|
6370
|
-
Terra: "Terra",
|
|
6371
|
-
TerraClassic: "TerraClassic",
|
|
6372
|
-
Noble: "Noble",
|
|
6373
|
-
Akash: "Akash"
|
|
6374
|
-
},
|
|
6375
|
-
vaultBased: {
|
|
6376
|
-
THORChain: "THORChain",
|
|
6377
|
-
MayaChain: "MayaChain"
|
|
6378
|
-
}
|
|
6379
|
-
};
|
|
6380
|
-
var IbcEnabledCosmosChain = cosmosChainsByKind.ibcEnabled;
|
|
6381
|
-
var VaultBasedCosmosChain = cosmosChainsByKind.vaultBased;
|
|
6382
|
-
var CosmosChain = {
|
|
6383
|
-
...IbcEnabledCosmosChain,
|
|
6384
|
-
...VaultBasedCosmosChain
|
|
6385
|
-
};
|
|
6386
|
-
var OtherChain;
|
|
6387
|
-
(function(OtherChain2) {
|
|
6388
|
-
OtherChain2["Sui"] = "Sui";
|
|
6389
|
-
OtherChain2["Solana"] = "Solana";
|
|
6390
|
-
OtherChain2["Polkadot"] = "Polkadot";
|
|
6391
|
-
OtherChain2["Bittensor"] = "Bittensor";
|
|
6392
|
-
OtherChain2["Ton"] = "Ton";
|
|
6393
|
-
OtherChain2["Ripple"] = "Ripple";
|
|
6394
|
-
OtherChain2["Tron"] = "Tron";
|
|
6395
|
-
OtherChain2["Cardano"] = "Cardano";
|
|
6396
|
-
OtherChain2["QBTC"] = "QBTC";
|
|
6397
|
-
})(OtherChain || (OtherChain = {}));
|
|
6398
|
-
var Chain2 = {
|
|
6399
|
-
...EvmChain,
|
|
6400
|
-
...UtxoChain,
|
|
6401
|
-
...CosmosChain,
|
|
6402
|
-
...OtherChain
|
|
6403
|
-
};
|
|
6404
|
-
var UtxoBasedChain = [...Object.values(UtxoChain), OtherChain.Cardano];
|
|
6405
|
-
var defaultChains = [Chain2.Bitcoin, Chain2.Ethereum, Chain2.THORChain, Chain2.Solana, Chain2.BSC];
|
|
6406
|
-
|
|
6407
|
-
// ../../packages/core/chain/dist/ChainKind.js
|
|
6408
|
-
var chainKindRecord = {
|
|
6409
|
-
[EvmChain.Arbitrum]: "evm",
|
|
6410
|
-
[EvmChain.Avalanche]: "evm",
|
|
6411
|
-
[EvmChain.Base]: "evm",
|
|
6412
|
-
[EvmChain.CronosChain]: "evm",
|
|
6413
|
-
[EvmChain.BSC]: "evm",
|
|
6414
|
-
[EvmChain.Blast]: "evm",
|
|
6415
|
-
[EvmChain.Ethereum]: "evm",
|
|
6416
|
-
[EvmChain.Optimism]: "evm",
|
|
6417
|
-
[EvmChain.Polygon]: "evm",
|
|
6418
|
-
[EvmChain.Zksync]: "evm",
|
|
6419
|
-
[EvmChain.Mantle]: "evm",
|
|
6420
|
-
[EvmChain.Hyperliquid]: "evm",
|
|
6421
|
-
[EvmChain.Sei]: "evm",
|
|
6422
|
-
[EvmChain.Robinhood]: "evm",
|
|
6423
|
-
[UtxoChain.Bitcoin]: "utxo",
|
|
6424
|
-
[UtxoChain.BitcoinCash]: "utxo",
|
|
6425
|
-
[UtxoChain.Litecoin]: "utxo",
|
|
6426
|
-
[UtxoChain.Dogecoin]: "utxo",
|
|
6427
|
-
[UtxoChain.Dash]: "utxo",
|
|
6428
|
-
[UtxoChain.Zcash]: "utxo",
|
|
6429
|
-
[CosmosChain.THORChain]: "cosmos",
|
|
6430
|
-
[CosmosChain.Cosmos]: "cosmos",
|
|
6431
|
-
[CosmosChain.Osmosis]: "cosmos",
|
|
6432
|
-
[CosmosChain.MayaChain]: "cosmos",
|
|
6433
|
-
[CosmosChain.Dydx]: "cosmos",
|
|
6434
|
-
[CosmosChain.Kujira]: "cosmos",
|
|
6435
|
-
[CosmosChain.Terra]: "cosmos",
|
|
6436
|
-
[CosmosChain.TerraClassic]: "cosmos",
|
|
6437
|
-
[CosmosChain.Noble]: "cosmos",
|
|
6438
|
-
[CosmosChain.Akash]: "cosmos",
|
|
6439
|
-
[OtherChain.Sui]: "sui",
|
|
6440
|
-
[OtherChain.Solana]: "solana",
|
|
6441
|
-
[OtherChain.Polkadot]: "polkadot",
|
|
6442
|
-
[OtherChain.Bittensor]: "bittensor",
|
|
6443
|
-
[OtherChain.Ton]: "ton",
|
|
6444
|
-
[OtherChain.Ripple]: "ripple",
|
|
6445
|
-
[OtherChain.Tron]: "tron",
|
|
6446
|
-
[OtherChain.Cardano]: "cardano",
|
|
6447
|
-
[OtherChain.QBTC]: "qbtc"
|
|
6448
|
-
};
|
|
6449
|
-
function getChainKind2(chain) {
|
|
6450
|
-
return chainKindRecord[chain];
|
|
6451
|
-
}
|
|
5829
|
+
// src/core/broadcastGuard.ts
|
|
5830
|
+
import { getChainKind as getChainKind2 } from "@vultisig/sdk";
|
|
6452
5831
|
|
|
6453
5832
|
// src/agent/broadcastJournal.ts
|
|
6454
5833
|
import { createHash } from "node:crypto";
|
|
@@ -7068,7 +6447,7 @@ async function guardedBroadcast(intent, force, broadcast) {
|
|
|
7068
6447
|
}
|
|
7069
6448
|
|
|
7070
6449
|
// src/interactive/completer.ts
|
|
7071
|
-
import { Chain as
|
|
6450
|
+
import { Chain as Chain2 } from "@vultisig/sdk";
|
|
7072
6451
|
import fs from "fs";
|
|
7073
6452
|
import path from "path";
|
|
7074
6453
|
var COMMANDS = [
|
|
@@ -7212,7 +6591,7 @@ function completeVaultName(ctx2, partial) {
|
|
|
7212
6591
|
return [show, partial];
|
|
7213
6592
|
}
|
|
7214
6593
|
function completeChainName(partial) {
|
|
7215
|
-
const allChains = Object.values(
|
|
6594
|
+
const allChains = Object.values(Chain2);
|
|
7216
6595
|
const partialLower = partial.toLowerCase();
|
|
7217
6596
|
const matches = allChains.filter((chain) => chain.toLowerCase().startsWith(partialLower));
|
|
7218
6597
|
matches.sort();
|
|
@@ -7220,7 +6599,7 @@ function completeChainName(partial) {
|
|
|
7220
6599
|
return [show, partial];
|
|
7221
6600
|
}
|
|
7222
6601
|
function findChainByName(name) {
|
|
7223
|
-
const allChains = Object.values(
|
|
6602
|
+
const allChains = Object.values(Chain2);
|
|
7224
6603
|
const nameLower = name.toLowerCase();
|
|
7225
6604
|
const found = allChains.find((chain) => chain.toLowerCase() === nameLower);
|
|
7226
6605
|
return found ? found : null;
|
|
@@ -7239,6 +6618,10 @@ function resolveChainOrThrow(input, label = "chain") {
|
|
|
7239
6618
|
}
|
|
7240
6619
|
return chain;
|
|
7241
6620
|
}
|
|
6621
|
+
function resolveOptionalChainOrThrow(input, label = "chain") {
|
|
6622
|
+
if (input === void 0 || input === null) return void 0;
|
|
6623
|
+
return resolveChainOrThrow(input, label);
|
|
6624
|
+
}
|
|
7242
6625
|
|
|
7243
6626
|
// src/core/config-store.ts
|
|
7244
6627
|
import { getConfigPath, loadConfig, saveConfig } from "@vultisig/client-shared";
|
|
@@ -7542,10 +6925,10 @@ var resolveDestinationTag = ({ destinationTag, memo }) => {
|
|
|
7542
6925
|
};
|
|
7543
6926
|
|
|
7544
6927
|
// src/commands/transaction.ts
|
|
7545
|
-
import { Chain as
|
|
6928
|
+
import { Chain as Chain3, Vultisig as Vultisig2 } from "@vultisig/sdk";
|
|
7546
6929
|
var getSendPreviewDetails = (chain, keysignPayload) => {
|
|
7547
6930
|
let memo = keysignPayload.memo || void 0;
|
|
7548
|
-
if (chain !==
|
|
6931
|
+
if (chain !== Chain3.Ripple) {
|
|
7549
6932
|
return { memo, destinationTag: void 0 };
|
|
7550
6933
|
}
|
|
7551
6934
|
const rippleSpecific = keysignPayload.blockchainSpecific;
|
|
@@ -7564,7 +6947,7 @@ var getSendPreviewDetails = (chain, keysignPayload) => {
|
|
|
7564
6947
|
};
|
|
7565
6948
|
async function executeSend(ctx2, params) {
|
|
7566
6949
|
const vault = await ctx2.ensureActiveVault();
|
|
7567
|
-
if (!Object.values(
|
|
6950
|
+
if (!Object.values(Chain3).includes(params.chain)) {
|
|
7568
6951
|
throw new Error(`Invalid chain: ${params.chain}`);
|
|
7569
6952
|
}
|
|
7570
6953
|
const isMax = params.amount === "max";
|
|
@@ -7581,12 +6964,13 @@ async function previewDryRun(vault, params, dryResult, to) {
|
|
|
7581
6964
|
dryResult.keysignPayload
|
|
7582
6965
|
);
|
|
7583
6966
|
const isTokenSend = balance.tokenId !== void 0;
|
|
7584
|
-
const
|
|
6967
|
+
const shouldCheckNativeFeeBalance = isTokenSend && params.amount !== "max";
|
|
6968
|
+
const feeBalance = shouldCheckNativeFeeBalance ? await vault.balance(params.chain).catch(() => void 0) : void 0;
|
|
7585
6969
|
const warnings = [];
|
|
7586
6970
|
if (hasInsufficientBalance) {
|
|
7587
6971
|
warnings.push(`Insufficient balance: you have ${balance.formattedAmount} ${balance.symbol}`);
|
|
7588
6972
|
}
|
|
7589
|
-
if (
|
|
6973
|
+
if (shouldCheckNativeFeeBalance && feeBalance === void 0) {
|
|
7590
6974
|
warnings.push(`Could not check your ${dryResult.feeSymbol} balance for the network fee`);
|
|
7591
6975
|
} else if (feeBalance && parseFloat(dryResult.fee) > parseFloat(feeBalance.formattedAmount)) {
|
|
7592
6976
|
warnings.push(
|
|
@@ -7599,6 +6983,7 @@ async function previewDryRun(vault, params, dryResult, to) {
|
|
|
7599
6983
|
to,
|
|
7600
6984
|
amount: params.amount,
|
|
7601
6985
|
symbol: balance.symbol,
|
|
6986
|
+
...dryResult.contractAddress ? { contractAddress: dryResult.contractAddress } : {},
|
|
7602
6987
|
fee: dryResult.fee,
|
|
7603
6988
|
feeSymbol: dryResult.feeSymbol,
|
|
7604
6989
|
total: dryResult.total,
|
|
@@ -7615,7 +7000,9 @@ async function previewDryRun(vault, params, dryResult, to) {
|
|
|
7615
7000
|
Dry-run preview:`);
|
|
7616
7001
|
info(` Chain: ${result.chain}`);
|
|
7617
7002
|
info(` To: ${result.to}`);
|
|
7618
|
-
info(
|
|
7003
|
+
info(
|
|
7004
|
+
` Amount: ${result.amount} ${result.symbol}${result.contractAddress ? ` (${escapeTerminalControls(result.contractAddress)})` : ""}`
|
|
7005
|
+
);
|
|
7619
7006
|
if (result.destinationTag !== void 0) info(` Destination tag: ${result.destinationTag}`);
|
|
7620
7007
|
if (result.memo) info(` Memo: ${escapeTerminalControls(result.memo)}`);
|
|
7621
7008
|
info(` Fee: ${result.fee} ${result.feeSymbol}`);
|
|
@@ -7631,7 +7018,7 @@ async function sendTransaction(vault, params) {
|
|
|
7631
7018
|
"Pass --yes to confirm, or --dry-run to preview without signing."
|
|
7632
7019
|
);
|
|
7633
7020
|
}
|
|
7634
|
-
const rippleDestination = params.chain ===
|
|
7021
|
+
const rippleDestination = params.chain === Chain3.Ripple ? normalizeRippleDestination(params.to) : { address: params.to };
|
|
7635
7022
|
const to = rippleDestination.address;
|
|
7636
7023
|
if (params.destinationTag !== void 0 && rippleDestination.destinationTag !== void 0 && params.destinationTag !== rippleDestination.destinationTag) {
|
|
7637
7024
|
throw new Error(
|
|
@@ -7672,7 +7059,8 @@ async function sendTransaction(vault, params) {
|
|
|
7672
7059
|
params.chain,
|
|
7673
7060
|
preview.memo,
|
|
7674
7061
|
preview.destinationTag,
|
|
7675
|
-
gas
|
|
7062
|
+
gas,
|
|
7063
|
+
dryResult.contractAddress
|
|
7676
7064
|
);
|
|
7677
7065
|
}
|
|
7678
7066
|
if (!params.yes) {
|
|
@@ -7727,23 +7115,32 @@ async function sendTransaction(vault, params) {
|
|
|
7727
7115
|
|
|
7728
7116
|
// src/commands/execute.ts
|
|
7729
7117
|
var import_qrcode_terminal = __toESM(require_main(), 1);
|
|
7730
|
-
import {
|
|
7731
|
-
|
|
7732
|
-
|
|
7733
|
-
|
|
7734
|
-
|
|
7735
|
-
|
|
7736
|
-
|
|
7737
|
-
|
|
7738
|
-
|
|
7739
|
-
|
|
7740
|
-
|
|
7741
|
-
|
|
7742
|
-
|
|
7743
|
-
|
|
7744
|
-
gasLimit: "500000"
|
|
7118
|
+
import {
|
|
7119
|
+
buildCosmosWasmExecuteMsg,
|
|
7120
|
+
Chain as Chain4,
|
|
7121
|
+
chainFeeCoin,
|
|
7122
|
+
cosmosFeeCoinDenom,
|
|
7123
|
+
getCosmosGasLimit,
|
|
7124
|
+
Vultisig as Vultisig3
|
|
7125
|
+
} from "@vultisig/sdk";
|
|
7126
|
+
var SUPPORTED_COSMWASM_CHAINS = [Chain4.THORChain, Chain4.MayaChain];
|
|
7127
|
+
function getCosmosChainConfig(chain) {
|
|
7128
|
+
if (!SUPPORTED_COSMWASM_CHAINS.includes(chain)) {
|
|
7129
|
+
throw new Error(
|
|
7130
|
+
`Chain ${chain} does not support CosmWasm execute. Supported chains: ${SUPPORTED_COSMWASM_CHAINS.join(", ")}`
|
|
7131
|
+
);
|
|
7745
7132
|
}
|
|
7746
|
-
|
|
7133
|
+
const supportedChain = chain;
|
|
7134
|
+
const feeCoin = chainFeeCoin[supportedChain];
|
|
7135
|
+
const denom = cosmosFeeCoinDenom[supportedChain];
|
|
7136
|
+
const gasLimit = getCosmosGasLimit({ chain: supportedChain, id: denom }).toString();
|
|
7137
|
+
return {
|
|
7138
|
+
denom,
|
|
7139
|
+
decimals: feeCoin.decimals,
|
|
7140
|
+
ticker: feeCoin.ticker,
|
|
7141
|
+
gasLimit
|
|
7142
|
+
};
|
|
7143
|
+
}
|
|
7747
7144
|
function parseFunds(fundsStr) {
|
|
7748
7145
|
if (!fundsStr) return [];
|
|
7749
7146
|
return fundsStr.split(",").map((fund) => {
|
|
@@ -7756,14 +7153,7 @@ function parseFunds(fundsStr) {
|
|
|
7756
7153
|
}
|
|
7757
7154
|
async function executeExecute(ctx2, params) {
|
|
7758
7155
|
const vault = await ctx2.ensureActiveVault();
|
|
7759
|
-
const chainConfig =
|
|
7760
|
-
if (!chainConfig) {
|
|
7761
|
-
throw new Error(
|
|
7762
|
-
`Chain ${params.chain} does not support CosmWasm execute. Supported chains: ${Object.keys(
|
|
7763
|
-
COSMOS_CHAIN_CONFIG
|
|
7764
|
-
).join(", ")}`
|
|
7765
|
-
);
|
|
7766
|
-
}
|
|
7156
|
+
const chainConfig = getCosmosChainConfig(params.chain);
|
|
7767
7157
|
let msg;
|
|
7768
7158
|
try {
|
|
7769
7159
|
msg = JSON.parse(params.msg);
|
|
@@ -7937,10 +7327,10 @@ Or use this URL: ${qrPayload}
|
|
|
7937
7327
|
|
|
7938
7328
|
// src/commands/sign.ts
|
|
7939
7329
|
var import_qrcode_terminal2 = __toESM(require_main(), 1);
|
|
7940
|
-
import { Chain as
|
|
7330
|
+
import { Chain as Chain5 } from "@vultisig/sdk";
|
|
7941
7331
|
async function executeSignBytes(ctx2, params) {
|
|
7942
7332
|
const vault = await ctx2.ensureActiveVault();
|
|
7943
|
-
if (!Object.values(
|
|
7333
|
+
if (!Object.values(Chain5).includes(params.chain)) {
|
|
7944
7334
|
throw new Error(`Invalid chain: ${params.chain}`);
|
|
7945
7335
|
}
|
|
7946
7336
|
return signBytes(vault, params);
|
|
@@ -8020,10 +7410,10 @@ Or use this URL: ${qrPayload}
|
|
|
8020
7410
|
}
|
|
8021
7411
|
|
|
8022
7412
|
// src/commands/broadcast.ts
|
|
8023
|
-
import { Chain as
|
|
7413
|
+
import { Chain as Chain6, Vultisig as Vultisig4 } from "@vultisig/sdk";
|
|
8024
7414
|
async function executeBroadcast(ctx2, params) {
|
|
8025
7415
|
const vault = await ctx2.ensureActiveVault();
|
|
8026
|
-
if (!Object.values(
|
|
7416
|
+
if (!Object.values(Chain6).includes(params.chain)) {
|
|
8027
7417
|
throw new Error(`Invalid chain: ${params.chain}`);
|
|
8028
7418
|
}
|
|
8029
7419
|
const broadcastSpinner = createSpinner("Broadcasting transaction...");
|
|
@@ -8052,9 +7442,9 @@ async function executeBroadcast(ctx2, params) {
|
|
|
8052
7442
|
}
|
|
8053
7443
|
|
|
8054
7444
|
// src/commands/tx-status.ts
|
|
8055
|
-
import { Chain as
|
|
7445
|
+
import { Chain as Chain7, isValidTxHash, Vultisig as Vultisig5 } from "@vultisig/sdk";
|
|
8056
7446
|
function resolveTxStatusParams(params) {
|
|
8057
|
-
if (!Object.values(
|
|
7447
|
+
if (!Object.values(Chain7).includes(params.chain)) {
|
|
8058
7448
|
throw new InvalidInputError(`Invalid chain: ${params.chain}`);
|
|
8059
7449
|
}
|
|
8060
7450
|
if (!isValidTxHash(params.chain, params.txHash)) {
|
|
@@ -9107,6 +8497,9 @@ Please specify more characters of the vault ID.`
|
|
|
9107
8497
|
throw new Error(`Vault not found: "${idOrName}"`);
|
|
9108
8498
|
}
|
|
9109
8499
|
|
|
8500
|
+
// src/commands/swap.ts
|
|
8501
|
+
import { toChainAmount } from "@vultisig/sdk";
|
|
8502
|
+
|
|
9110
8503
|
// ../../node_modules/viem/_esm/accounts/utils/publicKeyToAddress.js
|
|
9111
8504
|
init_getAddress();
|
|
9112
8505
|
init_keccak256();
|
|
@@ -9155,333 +8548,12 @@ async function recoverAddress({ hash, signature }) {
|
|
|
9155
8548
|
return publicKeyToAddress(await recoverPublicKey({ hash, signature }));
|
|
9156
8549
|
}
|
|
9157
8550
|
|
|
9158
|
-
// ../../node_modules/viem/_esm/utils/signature/hashTypedData.js
|
|
9159
|
-
init_encodeAbiParameters();
|
|
9160
|
-
init_concat();
|
|
9161
|
-
init_toHex();
|
|
9162
|
-
init_keccak256();
|
|
9163
|
-
|
|
9164
|
-
// ../../node_modules/viem/_esm/utils/typedData.js
|
|
9165
|
-
init_abi();
|
|
9166
|
-
init_address();
|
|
9167
|
-
|
|
9168
|
-
// ../../node_modules/viem/_esm/errors/typedData.js
|
|
9169
|
-
init_stringify();
|
|
9170
|
-
init_base();
|
|
9171
|
-
var InvalidDomainError = class extends BaseError {
|
|
9172
|
-
constructor({ domain }) {
|
|
9173
|
-
super(`Invalid domain "${stringify(domain)}".`, {
|
|
9174
|
-
metaMessages: ["Must be a valid EIP-712 domain."]
|
|
9175
|
-
});
|
|
9176
|
-
}
|
|
9177
|
-
};
|
|
9178
|
-
var InvalidPrimaryTypeError = class extends BaseError {
|
|
9179
|
-
constructor({ primaryType, types }) {
|
|
9180
|
-
super(`Invalid primary type \`${primaryType}\` must be one of \`${JSON.stringify(Object.keys(types))}\`.`, {
|
|
9181
|
-
docsPath: "/api/glossary/Errors#typeddatainvalidprimarytypeerror",
|
|
9182
|
-
metaMessages: ["Check that the primary type is a key in `types`."]
|
|
9183
|
-
});
|
|
9184
|
-
}
|
|
9185
|
-
};
|
|
9186
|
-
var InvalidStructTypeError = class extends BaseError {
|
|
9187
|
-
constructor({ type }) {
|
|
9188
|
-
super(`Struct type "${type}" is invalid.`, {
|
|
9189
|
-
metaMessages: ["Struct type must not be a Solidity type."],
|
|
9190
|
-
name: "InvalidStructTypeError"
|
|
9191
|
-
});
|
|
9192
|
-
}
|
|
9193
|
-
};
|
|
9194
|
-
|
|
9195
|
-
// ../../node_modules/viem/_esm/utils/typedData.js
|
|
9196
|
-
init_isAddress();
|
|
9197
|
-
init_size();
|
|
9198
|
-
init_toHex();
|
|
9199
|
-
init_regex();
|
|
9200
|
-
function validateTypedData(parameters) {
|
|
9201
|
-
const { domain, message, primaryType, types } = parameters;
|
|
9202
|
-
const validateData = (struct, data) => {
|
|
9203
|
-
for (const param of struct) {
|
|
9204
|
-
const { name, type } = param;
|
|
9205
|
-
const value = data[name];
|
|
9206
|
-
const integerMatch = type.match(integerRegex);
|
|
9207
|
-
if (integerMatch && (typeof value === "number" || typeof value === "bigint")) {
|
|
9208
|
-
const [_type, base, size_] = integerMatch;
|
|
9209
|
-
numberToHex(value, {
|
|
9210
|
-
signed: base === "int",
|
|
9211
|
-
size: Number.parseInt(size_, 10) / 8
|
|
9212
|
-
});
|
|
9213
|
-
}
|
|
9214
|
-
if (type === "address" && typeof value === "string" && !isAddress(value))
|
|
9215
|
-
throw new InvalidAddressError2({ address: value });
|
|
9216
|
-
const bytesMatch = type.match(bytesRegex);
|
|
9217
|
-
if (bytesMatch) {
|
|
9218
|
-
const [_type, size_] = bytesMatch;
|
|
9219
|
-
if (size_ && size(value) !== Number.parseInt(size_, 10))
|
|
9220
|
-
throw new BytesSizeMismatchError({
|
|
9221
|
-
expectedSize: Number.parseInt(size_, 10),
|
|
9222
|
-
givenSize: size(value)
|
|
9223
|
-
});
|
|
9224
|
-
}
|
|
9225
|
-
const struct2 = types[type];
|
|
9226
|
-
if (struct2) {
|
|
9227
|
-
validateReference(type);
|
|
9228
|
-
validateData(struct2, value);
|
|
9229
|
-
}
|
|
9230
|
-
}
|
|
9231
|
-
};
|
|
9232
|
-
if (types.EIP712Domain && domain) {
|
|
9233
|
-
if (typeof domain !== "object")
|
|
9234
|
-
throw new InvalidDomainError({ domain });
|
|
9235
|
-
validateData(types.EIP712Domain, domain);
|
|
9236
|
-
}
|
|
9237
|
-
if (primaryType !== "EIP712Domain") {
|
|
9238
|
-
if (types[primaryType])
|
|
9239
|
-
validateData(types[primaryType], message);
|
|
9240
|
-
else
|
|
9241
|
-
throw new InvalidPrimaryTypeError({ primaryType, types });
|
|
9242
|
-
}
|
|
9243
|
-
}
|
|
9244
|
-
function getTypesForEIP712Domain({ domain }) {
|
|
9245
|
-
return [
|
|
9246
|
-
typeof domain?.name === "string" && { name: "name", type: "string" },
|
|
9247
|
-
domain?.version && { name: "version", type: "string" },
|
|
9248
|
-
(typeof domain?.chainId === "number" || typeof domain?.chainId === "bigint") && {
|
|
9249
|
-
name: "chainId",
|
|
9250
|
-
type: "uint256"
|
|
9251
|
-
},
|
|
9252
|
-
domain?.verifyingContract && {
|
|
9253
|
-
name: "verifyingContract",
|
|
9254
|
-
type: "address"
|
|
9255
|
-
},
|
|
9256
|
-
domain?.salt && { name: "salt", type: "bytes32" }
|
|
9257
|
-
].filter(Boolean);
|
|
9258
|
-
}
|
|
9259
|
-
function validateReference(type) {
|
|
9260
|
-
if (type === "address" || type === "bool" || type === "string" || type.startsWith("bytes") || type.startsWith("uint") || type.startsWith("int"))
|
|
9261
|
-
throw new InvalidStructTypeError({ type });
|
|
9262
|
-
}
|
|
9263
|
-
|
|
9264
|
-
// ../../node_modules/viem/_esm/utils/signature/hashTypedData.js
|
|
9265
|
-
function hashTypedData(parameters) {
|
|
9266
|
-
const { domain = {}, message, primaryType } = parameters;
|
|
9267
|
-
const types = {
|
|
9268
|
-
EIP712Domain: getTypesForEIP712Domain({ domain }),
|
|
9269
|
-
...parameters.types
|
|
9270
|
-
};
|
|
9271
|
-
validateTypedData({
|
|
9272
|
-
domain,
|
|
9273
|
-
message,
|
|
9274
|
-
primaryType,
|
|
9275
|
-
types
|
|
9276
|
-
});
|
|
9277
|
-
const parts = ["0x1901"];
|
|
9278
|
-
if (domain)
|
|
9279
|
-
parts.push(hashDomain({
|
|
9280
|
-
domain,
|
|
9281
|
-
types
|
|
9282
|
-
}));
|
|
9283
|
-
if (primaryType !== "EIP712Domain")
|
|
9284
|
-
parts.push(hashStruct({
|
|
9285
|
-
data: message,
|
|
9286
|
-
primaryType,
|
|
9287
|
-
types
|
|
9288
|
-
}));
|
|
9289
|
-
return keccak256(concat(parts));
|
|
9290
|
-
}
|
|
9291
|
-
function hashDomain({ domain, types }) {
|
|
9292
|
-
return hashStruct({
|
|
9293
|
-
data: domain,
|
|
9294
|
-
primaryType: "EIP712Domain",
|
|
9295
|
-
types
|
|
9296
|
-
});
|
|
9297
|
-
}
|
|
9298
|
-
function hashStruct({ data, primaryType, types }) {
|
|
9299
|
-
const encoded = encodeData({
|
|
9300
|
-
data,
|
|
9301
|
-
primaryType,
|
|
9302
|
-
types
|
|
9303
|
-
});
|
|
9304
|
-
return keccak256(encoded);
|
|
9305
|
-
}
|
|
9306
|
-
function encodeData({ data, primaryType, types }) {
|
|
9307
|
-
const encodedTypes = [{ type: "bytes32" }];
|
|
9308
|
-
const encodedValues = [hashType({ primaryType, types })];
|
|
9309
|
-
for (const field of types[primaryType]) {
|
|
9310
|
-
const [type, value] = encodeField({
|
|
9311
|
-
types,
|
|
9312
|
-
name: field.name,
|
|
9313
|
-
type: field.type,
|
|
9314
|
-
value: data[field.name]
|
|
9315
|
-
});
|
|
9316
|
-
encodedTypes.push(type);
|
|
9317
|
-
encodedValues.push(value);
|
|
9318
|
-
}
|
|
9319
|
-
return encodeAbiParameters(encodedTypes, encodedValues);
|
|
9320
|
-
}
|
|
9321
|
-
function hashType({ primaryType, types }) {
|
|
9322
|
-
const encodedHashType = toHex(encodeType({ primaryType, types }));
|
|
9323
|
-
return keccak256(encodedHashType);
|
|
9324
|
-
}
|
|
9325
|
-
function encodeType({ primaryType, types }) {
|
|
9326
|
-
let result = "";
|
|
9327
|
-
const unsortedDeps = findTypeDependencies({ primaryType, types });
|
|
9328
|
-
unsortedDeps.delete(primaryType);
|
|
9329
|
-
const deps = [primaryType, ...Array.from(unsortedDeps).sort()];
|
|
9330
|
-
for (const type of deps) {
|
|
9331
|
-
result += `${type}(${types[type].map(({ name, type: t }) => `${t} ${name}`).join(",")})`;
|
|
9332
|
-
}
|
|
9333
|
-
return result;
|
|
9334
|
-
}
|
|
9335
|
-
function findTypeDependencies({ primaryType: primaryType_, types }, results = /* @__PURE__ */ new Set()) {
|
|
9336
|
-
const match = primaryType_.match(/^\w*/u);
|
|
9337
|
-
const primaryType = match?.[0];
|
|
9338
|
-
if (results.has(primaryType) || types[primaryType] === void 0) {
|
|
9339
|
-
return results;
|
|
9340
|
-
}
|
|
9341
|
-
results.add(primaryType);
|
|
9342
|
-
for (const field of types[primaryType]) {
|
|
9343
|
-
findTypeDependencies({ primaryType: field.type, types }, results);
|
|
9344
|
-
}
|
|
9345
|
-
return results;
|
|
9346
|
-
}
|
|
9347
|
-
function encodeField({ types, name, type, value }) {
|
|
9348
|
-
if (types[type] !== void 0) {
|
|
9349
|
-
return [
|
|
9350
|
-
{ type: "bytes32" },
|
|
9351
|
-
keccak256(encodeData({ data: value, primaryType: type, types }))
|
|
9352
|
-
];
|
|
9353
|
-
}
|
|
9354
|
-
if (type === "bytes")
|
|
9355
|
-
return [{ type: "bytes32" }, keccak256(value)];
|
|
9356
|
-
if (type === "string")
|
|
9357
|
-
return [{ type: "bytes32" }, keccak256(toHex(value))];
|
|
9358
|
-
if (type.lastIndexOf("]") === type.length - 1) {
|
|
9359
|
-
const parsedType = type.slice(0, type.lastIndexOf("["));
|
|
9360
|
-
const typeValuePairs = value.map((item) => encodeField({
|
|
9361
|
-
name,
|
|
9362
|
-
type: parsedType,
|
|
9363
|
-
types,
|
|
9364
|
-
value: item
|
|
9365
|
-
}));
|
|
9366
|
-
return [
|
|
9367
|
-
{ type: "bytes32" },
|
|
9368
|
-
keccak256(encodeAbiParameters(typeValuePairs.map(([t]) => t), typeValuePairs.map(([, v]) => v)))
|
|
9369
|
-
];
|
|
9370
|
-
}
|
|
9371
|
-
return [{ type }, value];
|
|
9372
|
-
}
|
|
9373
|
-
|
|
9374
8551
|
// ../../node_modules/viem/_esm/utils/unit/formatUnits.js
|
|
9375
8552
|
init_Value();
|
|
9376
8553
|
function formatUnits(value, decimals) {
|
|
9377
8554
|
return format(value, decimals);
|
|
9378
8555
|
}
|
|
9379
8556
|
|
|
9380
|
-
// ../../node_modules/viem/_esm/utils/unit/parseUnits.js
|
|
9381
|
-
init_Value();
|
|
9382
|
-
function parseUnits(value, decimals) {
|
|
9383
|
-
return from(value, decimals);
|
|
9384
|
-
}
|
|
9385
|
-
|
|
9386
|
-
// ../../packages/core/chain/dist/amount/toChainAmount.js
|
|
9387
|
-
var ChainAmountParseError = class extends Error {
|
|
9388
|
-
name = "ChainAmountParseError";
|
|
9389
|
-
constructor(message) {
|
|
9390
|
-
super(message);
|
|
9391
|
-
}
|
|
9392
|
-
};
|
|
9393
|
-
var SCIENTIFIC_DECIMAL = /^([+-]?)(?:(\d+)\.?(\d*)|\.(\d+))[eE]([+-]?\d+)$/i;
|
|
9394
|
-
var MAX_SCALE_ABS = 10000n;
|
|
9395
|
-
var padFractionDigits = (frac, totalLen) => {
|
|
9396
|
-
const need = totalLen - BigInt(frac.length);
|
|
9397
|
-
if (need <= 0n) {
|
|
9398
|
-
return frac;
|
|
9399
|
-
}
|
|
9400
|
-
if (need <= BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
9401
|
-
return `${"0".repeat(Number(need))}${frac}`;
|
|
9402
|
-
}
|
|
9403
|
-
let out = frac;
|
|
9404
|
-
while (BigInt(out.length) < totalLen) {
|
|
9405
|
-
out = `0${out}`;
|
|
9406
|
-
}
|
|
9407
|
-
return out;
|
|
9408
|
-
};
|
|
9409
|
-
var expandScientificNotationToDecimalString = (s) => {
|
|
9410
|
-
const m = SCIENTIFIC_DECIMAL.exec(s.trim());
|
|
9411
|
-
if (!m) {
|
|
9412
|
-
throw new ChainAmountParseError(`Invalid amount: "${s}"`);
|
|
9413
|
-
}
|
|
9414
|
-
const signNeg = m[1] === "-";
|
|
9415
|
-
let digitStr;
|
|
9416
|
-
let fracLen;
|
|
9417
|
-
if (m[4] !== void 0) {
|
|
9418
|
-
digitStr = m[4];
|
|
9419
|
-
fracLen = digitStr.length;
|
|
9420
|
-
} else {
|
|
9421
|
-
digitStr = `${m[2] ?? ""}${m[3] ?? ""}`;
|
|
9422
|
-
fracLen = (m[3] ?? "").length;
|
|
9423
|
-
}
|
|
9424
|
-
if (!/^\d+$/.test(digitStr)) {
|
|
9425
|
-
throw new ChainAmountParseError(`Invalid amount: "${s}"`);
|
|
9426
|
-
}
|
|
9427
|
-
const expStr = m[5] ?? "";
|
|
9428
|
-
if (expStr === "" || expStr === "+" || expStr === "-") {
|
|
9429
|
-
throw new ChainAmountParseError(`Invalid amount: "${s}"`);
|
|
9430
|
-
}
|
|
9431
|
-
const allDigits = BigInt(digitStr);
|
|
9432
|
-
const exp = BigInt(expStr);
|
|
9433
|
-
const scale = exp - BigInt(fracLen);
|
|
9434
|
-
const scaleAbs = scale < 0n ? -scale : scale;
|
|
9435
|
-
if (scaleAbs > MAX_SCALE_ABS) {
|
|
9436
|
-
throw new ChainAmountParseError(`Amount exponent out of supported range: "${s}"`);
|
|
9437
|
-
}
|
|
9438
|
-
let absResult;
|
|
9439
|
-
if (scale >= 0n) {
|
|
9440
|
-
const mult = 10n ** scale;
|
|
9441
|
-
absResult = (allDigits * mult).toString();
|
|
9442
|
-
} else {
|
|
9443
|
-
const k = -scale;
|
|
9444
|
-
const divisor = 10n ** k;
|
|
9445
|
-
const intPart = allDigits / divisor;
|
|
9446
|
-
const rem = allDigits % divisor;
|
|
9447
|
-
const frac = padFractionDigits(rem.toString(), k);
|
|
9448
|
-
absResult = intPart === 0n ? `0.${frac}` : `${intPart.toString()}.${frac}`;
|
|
9449
|
-
}
|
|
9450
|
-
if (signNeg && allDigits !== 0n) {
|
|
9451
|
-
return `-${absResult}`;
|
|
9452
|
-
}
|
|
9453
|
-
return absResult;
|
|
9454
|
-
};
|
|
9455
|
-
var formatNumberAmount = (amount) => {
|
|
9456
|
-
const str2 = amount.toString();
|
|
9457
|
-
return /[eE]/.test(str2) ? expandScientificNotationToDecimalString(str2) : str2;
|
|
9458
|
-
};
|
|
9459
|
-
var truncateToDecimals = (s, decimals) => {
|
|
9460
|
-
const dotIdx = s.indexOf(".");
|
|
9461
|
-
if (dotIdx === -1)
|
|
9462
|
-
return s;
|
|
9463
|
-
if (decimals === 0)
|
|
9464
|
-
return s.slice(0, dotIdx);
|
|
9465
|
-
const fracPart = s.slice(dotIdx + 1);
|
|
9466
|
-
if (fracPart.length <= decimals)
|
|
9467
|
-
return s;
|
|
9468
|
-
return `${s.slice(0, dotIdx + 1)}${fracPart.slice(0, decimals)}`;
|
|
9469
|
-
};
|
|
9470
|
-
var toChainAmount = (amount, decimals) => {
|
|
9471
|
-
if (typeof amount === "string") {
|
|
9472
|
-
const trimmed = amount.trim();
|
|
9473
|
-
if (!trimmed) {
|
|
9474
|
-
throw new ChainAmountParseError("Amount cannot be empty");
|
|
9475
|
-
}
|
|
9476
|
-
if (/[eE]/.test(trimmed)) {
|
|
9477
|
-
const expanded = expandScientificNotationToDecimalString(trimmed);
|
|
9478
|
-
return parseUnits(truncateToDecimals(expanded, decimals), decimals);
|
|
9479
|
-
}
|
|
9480
|
-
return parseUnits(truncateToDecimals(trimmed, decimals), decimals);
|
|
9481
|
-
}
|
|
9482
|
-
return parseUnits(truncateToDecimals(formatNumberAmount(amount), decimals), decimals);
|
|
9483
|
-
};
|
|
9484
|
-
|
|
9485
8557
|
// src/commands/swap.ts
|
|
9486
8558
|
async function executeSwapChains(ctx2) {
|
|
9487
8559
|
const vault = await ctx2.ensureActiveVault();
|
|
@@ -9676,7 +8748,7 @@ async function executeSwap(ctx2, options) {
|
|
|
9676
8748
|
}
|
|
9677
8749
|
|
|
9678
8750
|
// src/commands/settings.ts
|
|
9679
|
-
import { Chain as
|
|
8751
|
+
import { Chain as Chain8, fiatCurrencies as fiatCurrencies2, fiatCurrencyNameRecord as fiatCurrencyNameRecord3 } from "@vultisig/sdk";
|
|
9680
8752
|
import chalk6 from "chalk";
|
|
9681
8753
|
async function executeCurrency(ctx2, newCurrency) {
|
|
9682
8754
|
const vault = await ctx2.ensureActiveVault();
|
|
@@ -9747,7 +8819,7 @@ async function executeAddressBook(ctx2, options = {}) {
|
|
|
9747
8819
|
type: "select",
|
|
9748
8820
|
name: "chain",
|
|
9749
8821
|
message: "Select chain:",
|
|
9750
|
-
choices: Object.values(
|
|
8822
|
+
choices: Object.values(Chain8)
|
|
9751
8823
|
});
|
|
9752
8824
|
}
|
|
9753
8825
|
if (!address) {
|
|
@@ -10348,11 +9420,11 @@ var AskInterface = class {
|
|
|
10348
9420
|
|
|
10349
9421
|
// src/agent/auth.ts
|
|
10350
9422
|
import { randomBytes as randomBytes3 } from "node:crypto";
|
|
10351
|
-
import { Chain as
|
|
9423
|
+
import { Chain as Chain9, computePersonalSignHash, formatEcdsaSignature65 } from "@vultisig/sdk";
|
|
10352
9424
|
async function authenticateVault(client, vault, password, maxAttempts = 3) {
|
|
10353
9425
|
const publicKey = vault.publicKeys.ecdsa;
|
|
10354
9426
|
const chainCode = vault.hexChainCode;
|
|
10355
|
-
const ethAddress = await vault.address(
|
|
9427
|
+
const ethAddress = await vault.address(Chain9.Ethereum);
|
|
10356
9428
|
const nonce = "0x" + randomBytes3(16).toString("hex");
|
|
10357
9429
|
const expiresAt = new Date(Date.now() + 15 * 60 * 1e3).toISOString();
|
|
10358
9430
|
const authMessage = JSON.stringify({
|
|
@@ -10369,7 +9441,7 @@ async function authenticateVault(client, vault, password, maxAttempts = 3) {
|
|
|
10369
9441
|
process.stderr.write(` Retry ${attempt}/${maxAttempts}...
|
|
10370
9442
|
`);
|
|
10371
9443
|
}
|
|
10372
|
-
const signature = await vault.signBytes({ data: Buffer.from(messageHash), chain:
|
|
9444
|
+
const signature = await vault.signBytes({ data: Buffer.from(messageHash), chain: Chain9.Ethereum }, {});
|
|
10373
9445
|
if (signature.recovery === void 0) {
|
|
10374
9446
|
throw new Error("Agent authentication requires an ECDSA recovery id");
|
|
10375
9447
|
}
|
|
@@ -10701,11 +9773,13 @@ import { getChainKind as getChainKind4 } from "@vultisig/sdk";
|
|
|
10701
9773
|
|
|
10702
9774
|
// src/agent/executor.ts
|
|
10703
9775
|
import {
|
|
10704
|
-
Chain as
|
|
10705
|
-
chainFeeCoin,
|
|
9776
|
+
Chain as Chain10,
|
|
9777
|
+
chainFeeCoin as chainFeeCoin2,
|
|
9778
|
+
computeEip712Hash,
|
|
10706
9779
|
getChainKind as getChainKind3,
|
|
10707
9780
|
parseThorSwapMemo,
|
|
10708
9781
|
resolveChainReference,
|
|
9782
|
+
toCanonicalEvmSignature,
|
|
10709
9783
|
VaultError as VaultError3,
|
|
10710
9784
|
VaultErrorCode as VaultErrorCode3,
|
|
10711
9785
|
Vultisig as VultisigSdk
|
|
@@ -11061,7 +10135,7 @@ var AgentExecutor = class {
|
|
|
11061
10135
|
if (!nestedTx && txReadyData && typeof txReadyData === "object") {
|
|
11062
10136
|
const txArgs = txReadyData.txArgs;
|
|
11063
10137
|
if (txArgs && typeof txArgs === "object" && typeof txArgs.to === "string" && typeof txArgs.amount === "string") {
|
|
11064
|
-
const chain2 = resolveChainFromTxReady(txReadyData) ||
|
|
10138
|
+
const chain2 = resolveChainFromTxReady(txReadyData) || Chain10.Ethereum;
|
|
11065
10139
|
if (getChainKind3(chain2) !== "evm") {
|
|
11066
10140
|
this.pendingPayloads.clear();
|
|
11067
10141
|
this.pendingLegs = [];
|
|
@@ -11086,7 +10160,7 @@ var AgentExecutor = class {
|
|
|
11086
10160
|
`);
|
|
11087
10161
|
return false;
|
|
11088
10162
|
}
|
|
11089
|
-
const chain = resolveChainFromTxReady(txReadyData) ||
|
|
10163
|
+
const chain = resolveChainFromTxReady(txReadyData) || Chain10.Ethereum;
|
|
11090
10164
|
this.pendingPayloads.clear();
|
|
11091
10165
|
this.pendingLegs = [];
|
|
11092
10166
|
this.pendingPayloads.set("latest", {
|
|
@@ -11471,7 +10545,7 @@ var AgentExecutor = class {
|
|
|
11471
10545
|
`signNonEvmServerTx: dispatcher chain '${chain}' disagrees with envelope chain '${txArgs.chain}'`
|
|
11472
10546
|
);
|
|
11473
10547
|
}
|
|
11474
|
-
if (txArgs.msg_type === "deposit" && (chain ===
|
|
10548
|
+
if (txArgs.msg_type === "deposit" && (chain === Chain10.THORChain || chain === Chain10.MayaChain)) {
|
|
11475
10549
|
const memo = typeof txArgs.memo === "string" ? txArgs.memo : "";
|
|
11476
10550
|
if (memo.startsWith("=:")) {
|
|
11477
10551
|
return this.signThorMsgDepositSwap(serverTxData, chain);
|
|
@@ -11544,7 +10618,7 @@ var AgentExecutor = class {
|
|
|
11544
10618
|
);
|
|
11545
10619
|
}
|
|
11546
10620
|
const toChain = parsed.toChain;
|
|
11547
|
-
const fromSymbol = chain ===
|
|
10621
|
+
const fromSymbol = chain === Chain10.THORChain ? "RUNE" : "CACAO";
|
|
11548
10622
|
const amountRaw = typeof txArgs.amount === "string" ? txArgs.amount : void 0;
|
|
11549
10623
|
if (!amountRaw) {
|
|
11550
10624
|
throw new VaultError3(
|
|
@@ -12158,16 +11232,16 @@ var AgentExecutor = class {
|
|
|
12158
11232
|
}
|
|
12159
11233
|
if (this.verbose) process.stderr.write(`[sign_typed_data] primaryType=${primaryType} domain.name=${domain.name}
|
|
12160
11234
|
`);
|
|
12161
|
-
const eip712Hash =
|
|
11235
|
+
const eip712Hash = computeEip712Hash(domain, types, primaryType, message);
|
|
12162
11236
|
if (this.verbose) process.stderr.write(`[sign_typed_data] hash=${eip712Hash}
|
|
12163
11237
|
`);
|
|
12164
11238
|
const chainName = params.chain;
|
|
12165
11239
|
const chainId = domain.chainId;
|
|
12166
|
-
let chain =
|
|
11240
|
+
let chain = Chain10.Ethereum;
|
|
12167
11241
|
if (chainName) {
|
|
12168
|
-
chain = resolveChain(chainName) ||
|
|
11242
|
+
chain = resolveChain(chainName) || Chain10.Ethereum;
|
|
12169
11243
|
} else if (chainId) {
|
|
12170
|
-
chain = resolveChainId(chainId) ||
|
|
11244
|
+
chain = resolveChainId(chainId) || Chain10.Ethereum;
|
|
12171
11245
|
}
|
|
12172
11246
|
const sigResult = await this.vault.signBytes({
|
|
12173
11247
|
data: eip712Hash,
|
|
@@ -12322,7 +11396,7 @@ function convertBaseUnitsToDecimal(chain, amountRaw, context) {
|
|
|
12322
11396
|
`${context}: amount '${amountRaw}' for ${chain} exceeds ${MAX_AMOUNT_DIGITS}-digit safety bound. Likely a quote-side bug. Refusing to sign.`
|
|
12323
11397
|
);
|
|
12324
11398
|
}
|
|
12325
|
-
const decimals =
|
|
11399
|
+
const decimals = chainFeeCoin2[chain]?.decimals;
|
|
12326
11400
|
if (decimals === void 0) {
|
|
12327
11401
|
throw new VaultError3(VaultErrorCode3.UnsupportedChain, `${context}: no native decimals registered for ${chain}`);
|
|
12328
11402
|
}
|
|
@@ -12351,7 +11425,7 @@ function parseNonEvmEnvelope(serverTxData, chain) {
|
|
|
12351
11425
|
const amountDecimal = convertBaseUnitsToDecimal(chain, amountRaw, "parseNonEvmEnvelope");
|
|
12352
11426
|
let symbol;
|
|
12353
11427
|
const tokenResolved = serverTxData?.resolved?.labels?.token_resolved;
|
|
12354
|
-
const nativeTicker =
|
|
11428
|
+
const nativeTicker = chainFeeCoin2[chain]?.ticker;
|
|
12355
11429
|
if (typeof tokenResolved === "string" && tokenResolved !== nativeTicker) {
|
|
12356
11430
|
symbol = tokenResolved;
|
|
12357
11431
|
}
|
|
@@ -12361,74 +11435,6 @@ function parseNonEvmEnvelope(serverTxData, chain) {
|
|
|
12361
11435
|
function resolveChainId(chainId) {
|
|
12362
11436
|
return resolveChainReference(chainId) ?? null;
|
|
12363
11437
|
}
|
|
12364
|
-
function computeEIP712Hash(domain, types, primaryType, message) {
|
|
12365
|
-
const messageTypes = { ...types };
|
|
12366
|
-
delete messageTypes.EIP712Domain;
|
|
12367
|
-
const normalizedDomain = domain.chainId !== void 0 ? { ...domain, chainId: coerceChainId(domain.chainId) } : domain;
|
|
12368
|
-
return hashTypedData({
|
|
12369
|
-
domain: normalizedDomain,
|
|
12370
|
-
types: messageTypes,
|
|
12371
|
-
primaryType,
|
|
12372
|
-
message
|
|
12373
|
-
});
|
|
12374
|
-
}
|
|
12375
|
-
function coerceChainId(raw) {
|
|
12376
|
-
if (typeof raw === "number" || typeof raw === "bigint") return raw;
|
|
12377
|
-
const s = String(raw).trim();
|
|
12378
|
-
if (s === "") {
|
|
12379
|
-
throw new Error("EIP-712 domain.chainId is empty");
|
|
12380
|
-
}
|
|
12381
|
-
if (/^[0-9]+$/.test(s) || /^0x[0-9a-fA-F]+$/.test(s)) {
|
|
12382
|
-
const big = BigInt(s);
|
|
12383
|
-
return big <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(big) : big;
|
|
12384
|
-
}
|
|
12385
|
-
throw new Error(`EIP-712 domain.chainId not parseable: ${String(raw)}`);
|
|
12386
|
-
}
|
|
12387
|
-
var SECP256K1_N = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n;
|
|
12388
|
-
function toCanonicalEvmSignature(sigHex, recovery) {
|
|
12389
|
-
const { r, s } = parseDERSignature(sigHex);
|
|
12390
|
-
const sBig = BigInt("0x" + s);
|
|
12391
|
-
if (sBig > SECP256K1_N >> 1n) {
|
|
12392
|
-
const folded = SECP256K1_N - sBig;
|
|
12393
|
-
return { r, s: folded.toString(16).padStart(64, "0"), recovery: recovery ^ 1 };
|
|
12394
|
-
}
|
|
12395
|
-
return { r, s, recovery };
|
|
12396
|
-
}
|
|
12397
|
-
function parseDERSignature(sigHex) {
|
|
12398
|
-
const raw = sigHex.startsWith("0x") ? sigHex.slice(2) : sigHex;
|
|
12399
|
-
if (raw.length === 128) {
|
|
12400
|
-
return { r: raw.slice(0, 64), s: raw.slice(64) };
|
|
12401
|
-
}
|
|
12402
|
-
let offset = 0;
|
|
12403
|
-
if (raw.slice(offset, offset + 2) !== "30") {
|
|
12404
|
-
return {
|
|
12405
|
-
r: raw.slice(0, 64).padStart(64, "0"),
|
|
12406
|
-
s: raw.slice(64).padStart(64, "0")
|
|
12407
|
-
};
|
|
12408
|
-
}
|
|
12409
|
-
offset += 2;
|
|
12410
|
-
offset += 2;
|
|
12411
|
-
if (raw.slice(offset, offset + 2) !== "02") throw new Error("Invalid DER: expected 02 for R");
|
|
12412
|
-
offset += 2;
|
|
12413
|
-
const rLen = parseInt(raw.slice(offset, offset + 2), 16);
|
|
12414
|
-
offset += 2;
|
|
12415
|
-
let rHex = raw.slice(offset, offset + rLen * 2);
|
|
12416
|
-
offset += rLen * 2;
|
|
12417
|
-
if (rHex.length > 64 && rHex.startsWith("00")) {
|
|
12418
|
-
rHex = rHex.slice(rHex.length - 64);
|
|
12419
|
-
}
|
|
12420
|
-
rHex = rHex.padStart(64, "0");
|
|
12421
|
-
if (raw.slice(offset, offset + 2) !== "02") throw new Error("Invalid DER: expected 02 for S");
|
|
12422
|
-
offset += 2;
|
|
12423
|
-
const sLen = parseInt(raw.slice(offset, offset + 2), 16);
|
|
12424
|
-
offset += 2;
|
|
12425
|
-
let sHex = raw.slice(offset, offset + sLen * 2);
|
|
12426
|
-
if (sHex.length > 64 && sHex.startsWith("00")) {
|
|
12427
|
-
sHex = sHex.slice(sHex.length - 64);
|
|
12428
|
-
}
|
|
12429
|
-
sHex = sHex.padStart(64, "0");
|
|
12430
|
-
return { r: rHex, s: sHex };
|
|
12431
|
-
}
|
|
12432
11438
|
|
|
12433
11439
|
// src/agent/toolOutputSigning.ts
|
|
12434
11440
|
var POLYMARKET_DEPOSIT_TOOL = "polymarket_deposit";
|
|
@@ -12459,7 +11465,7 @@ function asRecord(value) {
|
|
|
12459
11465
|
}
|
|
12460
11466
|
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
12461
11467
|
}
|
|
12462
|
-
function
|
|
11468
|
+
function isAddress(value) {
|
|
12463
11469
|
return typeof value === "string" && /^0x[0-9a-fA-F]{40}$/.test(value);
|
|
12464
11470
|
}
|
|
12465
11471
|
function isCalldata(value) {
|
|
@@ -12479,7 +11485,7 @@ function normalizeGasLimit(value) {
|
|
|
12479
11485
|
return void 0;
|
|
12480
11486
|
}
|
|
12481
11487
|
function extractLeg(obj) {
|
|
12482
|
-
const to =
|
|
11488
|
+
const to = isAddress(obj.to) ? obj.to : isAddress(obj.to_address) ? obj.to_address : void 0;
|
|
12483
11489
|
const data = isCalldata(obj.data) ? obj.data : isCalldata(obj.calldata) ? obj.calldata : void 0;
|
|
12484
11490
|
if (!to || !data) return null;
|
|
12485
11491
|
const leg = { to, value: normalizeValue(obj.value), data };
|
|
@@ -12635,7 +11641,7 @@ function payloadLooksSignable(payload) {
|
|
|
12635
11641
|
}
|
|
12636
11642
|
function legSignable(legObj) {
|
|
12637
11643
|
const nested = asRecord(legObj.tx) || asRecord(legObj.swap_tx) || asRecord(legObj.send_tx) || asRecord(legObj.txArgs?.tx);
|
|
12638
|
-
if (nested &&
|
|
11644
|
+
if (nested && isAddress(nested.to)) return true;
|
|
12639
11645
|
const txArgs = asRecord(legObj.txArgs);
|
|
12640
11646
|
if (txArgs && typeof txArgs.to === "string" && typeof txArgs.amount === "string") return true;
|
|
12641
11647
|
return false;
|
|
@@ -13421,7 +12427,7 @@ var AgentClient = class {
|
|
|
13421
12427
|
};
|
|
13422
12428
|
|
|
13423
12429
|
// src/agent/context.ts
|
|
13424
|
-
import {
|
|
12430
|
+
import { chainFeeCoin as chainFeeCoin3 } from "@vultisig/sdk";
|
|
13425
12431
|
function applyChainPublicKeys(vault, context) {
|
|
13426
12432
|
const raw = vault.data.chainPublicKeys;
|
|
13427
12433
|
if (!raw) return;
|
|
@@ -13482,11 +12488,12 @@ async function buildMessageContext(vault) {
|
|
|
13482
12488
|
const coins = [];
|
|
13483
12489
|
const chains = vault.chains;
|
|
13484
12490
|
for (const chain of chains) {
|
|
12491
|
+
const nativeCoin = chainFeeCoin3[chain];
|
|
13485
12492
|
coins.push({
|
|
13486
12493
|
chain: chain.toString(),
|
|
13487
|
-
ticker:
|
|
12494
|
+
ticker: nativeCoin?.ticker ?? chain.toString(),
|
|
13488
12495
|
is_native_token: true,
|
|
13489
|
-
decimals:
|
|
12496
|
+
decimals: nativeCoin?.decimals ?? 18
|
|
13490
12497
|
});
|
|
13491
12498
|
const tokens = vault.tokens[chain] || [];
|
|
13492
12499
|
for (const token of tokens) {
|
|
@@ -13532,62 +12539,6 @@ async function buildMinimalContext(vault) {
|
|
|
13532
12539
|
}
|
|
13533
12540
|
return context;
|
|
13534
12541
|
}
|
|
13535
|
-
function getNativeTokenTicker(chain) {
|
|
13536
|
-
const tickers = {
|
|
13537
|
-
[Chain13.Ethereum]: "ETH",
|
|
13538
|
-
[Chain13.Bitcoin]: "BTC",
|
|
13539
|
-
[Chain13.Solana]: "SOL",
|
|
13540
|
-
[Chain13.THORChain]: "RUNE",
|
|
13541
|
-
[Chain13.Cosmos]: "ATOM",
|
|
13542
|
-
[Chain13.Avalanche]: "AVAX",
|
|
13543
|
-
[Chain13.BSC]: "BNB",
|
|
13544
|
-
[Chain13.Polygon]: "MATIC",
|
|
13545
|
-
[Chain13.Arbitrum]: "ETH",
|
|
13546
|
-
[Chain13.Optimism]: "ETH",
|
|
13547
|
-
[Chain13.Base]: "ETH",
|
|
13548
|
-
[Chain13.Blast]: "ETH",
|
|
13549
|
-
[Chain13.Litecoin]: "LTC",
|
|
13550
|
-
[Chain13.Dogecoin]: "DOGE",
|
|
13551
|
-
[Chain13.Dash]: "DASH",
|
|
13552
|
-
[Chain13.MayaChain]: "CACAO",
|
|
13553
|
-
[Chain13.Polkadot]: "DOT",
|
|
13554
|
-
[Chain13.Sui]: "SUI",
|
|
13555
|
-
[Chain13.Ton]: "TON",
|
|
13556
|
-
[Chain13.Tron]: "TRX",
|
|
13557
|
-
[Chain13.Ripple]: "XRP",
|
|
13558
|
-
[Chain13.Dydx]: "DYDX",
|
|
13559
|
-
[Chain13.Osmosis]: "OSMO",
|
|
13560
|
-
[Chain13.Terra]: "LUNA",
|
|
13561
|
-
[Chain13.Noble]: "USDC",
|
|
13562
|
-
[Chain13.Kujira]: "KUJI",
|
|
13563
|
-
[Chain13.Zksync]: "ETH",
|
|
13564
|
-
[Chain13.CronosChain]: "CRO"
|
|
13565
|
-
};
|
|
13566
|
-
return tickers[chain] || chain.toString();
|
|
13567
|
-
}
|
|
13568
|
-
function getNativeTokenDecimals(chain) {
|
|
13569
|
-
const decimals = {
|
|
13570
|
-
[Chain13.Bitcoin]: 8,
|
|
13571
|
-
[Chain13.Litecoin]: 8,
|
|
13572
|
-
[Chain13.Dogecoin]: 8,
|
|
13573
|
-
[Chain13.Dash]: 8,
|
|
13574
|
-
[Chain13.Solana]: 9,
|
|
13575
|
-
[Chain13.Sui]: 9,
|
|
13576
|
-
[Chain13.Ton]: 9,
|
|
13577
|
-
[Chain13.Polkadot]: 10,
|
|
13578
|
-
[Chain13.Cosmos]: 6,
|
|
13579
|
-
[Chain13.THORChain]: 8,
|
|
13580
|
-
[Chain13.MayaChain]: 10,
|
|
13581
|
-
[Chain13.Osmosis]: 6,
|
|
13582
|
-
[Chain13.Dydx]: 18,
|
|
13583
|
-
[Chain13.Tron]: 6,
|
|
13584
|
-
[Chain13.Ripple]: 6,
|
|
13585
|
-
[Chain13.Noble]: 6,
|
|
13586
|
-
[Chain13.Kujira]: 6,
|
|
13587
|
-
[Chain13.Terra]: 6
|
|
13588
|
-
};
|
|
13589
|
-
return decimals[chain] || 18;
|
|
13590
|
-
}
|
|
13591
12542
|
|
|
13592
12543
|
// src/agent/pipe.ts
|
|
13593
12544
|
import * as readline from "node:readline";
|
|
@@ -15077,7 +14028,7 @@ var ChatTUI = class {
|
|
|
15077
14028
|
},
|
|
15078
14029
|
onAssistantMessage: (content) => {
|
|
15079
14030
|
if (this.isStreaming) {
|
|
15080
|
-
process.stdout.write(renderMarkdown(this.currentStreamText) + "\n");
|
|
14031
|
+
process.stdout.write(renderMarkdown(content || this.currentStreamText) + "\n");
|
|
15081
14032
|
this.isStreaming = false;
|
|
15082
14033
|
} else if (content && content !== this.currentStreamText) {
|
|
15083
14034
|
const ts = this.timestamp();
|
|
@@ -15765,7 +14716,7 @@ var cachedVersion = null;
|
|
|
15765
14716
|
function getVersion() {
|
|
15766
14717
|
if (cachedVersion) return cachedVersion;
|
|
15767
14718
|
if (true) {
|
|
15768
|
-
cachedVersion = "4.
|
|
14719
|
+
cachedVersion = "4.5.0";
|
|
15769
14720
|
return cachedVersion;
|
|
15770
14721
|
}
|
|
15771
14722
|
try {
|
|
@@ -16225,7 +15176,7 @@ var EventBuffer = class {
|
|
|
16225
15176
|
};
|
|
16226
15177
|
|
|
16227
15178
|
// src/interactive/session.ts
|
|
16228
|
-
import { Chain as
|
|
15179
|
+
import { Chain as Chain12, fiatCurrencies as fiatCurrencies3 } from "@vultisig/sdk";
|
|
16229
15180
|
import chalk14 from "chalk";
|
|
16230
15181
|
import ora3 from "ora";
|
|
16231
15182
|
import * as readline3 from "readline";
|
|
@@ -17027,7 +15978,7 @@ Error: ${error2.message}`));
|
|
|
17027
15978
|
const raw = args.includes("--raw");
|
|
17028
15979
|
await this.withCancellation(
|
|
17029
15980
|
() => executeBalance(this.ctx, {
|
|
17030
|
-
chain:
|
|
15981
|
+
chain: resolveOptionalChainOrThrow(chainStr),
|
|
17031
15982
|
includeTokens,
|
|
17032
15983
|
raw
|
|
17033
15984
|
})
|
|
@@ -17057,7 +16008,7 @@ Error: ${error2.message}`));
|
|
|
17057
16008
|
return;
|
|
17058
16009
|
}
|
|
17059
16010
|
const [chainStr, to, amount, ...rest] = args;
|
|
17060
|
-
const chain =
|
|
16011
|
+
const chain = resolveChainOrThrow(chainStr);
|
|
17061
16012
|
let tokenId;
|
|
17062
16013
|
let memo;
|
|
17063
16014
|
let destinationTag;
|
|
@@ -17074,7 +16025,7 @@ Error: ${error2.message}`));
|
|
|
17074
16025
|
} else if (rest[i] === "--destination-tag") {
|
|
17075
16026
|
const tag = rest[i + 1];
|
|
17076
16027
|
const parsedTag = Number(tag);
|
|
17077
|
-
if (chain !==
|
|
16028
|
+
if (chain !== Chain12.Ripple || !/^(0|[1-9]\d*)$/.test(tag ?? "") || !Number.isSafeInteger(parsedTag) || parsedTag > 4294967295) {
|
|
17078
16029
|
throw new Error("Invalid XRP DestinationTag: expected an integer from 0 to 4294967295");
|
|
17079
16030
|
}
|
|
17080
16031
|
destinationTag = parsedTag;
|
|
@@ -17099,7 +16050,7 @@ Error: ${error2.message}`));
|
|
|
17099
16050
|
return;
|
|
17100
16051
|
}
|
|
17101
16052
|
const [chainStr, txHash, ...rest] = args;
|
|
17102
|
-
const chain =
|
|
16053
|
+
const chain = resolveChainOrThrow(chainStr);
|
|
17103
16054
|
const noWait = rest.includes("--no-wait");
|
|
17104
16055
|
await this.withCancellation(() => executeTxStatus(this.ctx, { chain, txHash, noWait }));
|
|
17105
16056
|
}
|
|
@@ -17138,7 +16089,7 @@ Error: ${error2.message}`));
|
|
|
17138
16089
|
return;
|
|
17139
16090
|
}
|
|
17140
16091
|
const chainStr = args[0];
|
|
17141
|
-
const chain =
|
|
16092
|
+
const chain = resolveChainOrThrow(chainStr);
|
|
17142
16093
|
let add;
|
|
17143
16094
|
let remove;
|
|
17144
16095
|
for (let i = 1; i < args.length; i++) {
|
|
@@ -17160,8 +16111,8 @@ Error: ${error2.message}`));
|
|
|
17160
16111
|
return;
|
|
17161
16112
|
}
|
|
17162
16113
|
const [fromChainStr, toChainStr, amountStr, ...rest] = args;
|
|
17163
|
-
const fromChain =
|
|
17164
|
-
const toChain =
|
|
16114
|
+
const fromChain = resolveChainOrThrow(fromChainStr, "source chain");
|
|
16115
|
+
const toChain = resolveChainOrThrow(toChainStr, "destination chain");
|
|
17165
16116
|
const amount = amountStr;
|
|
17166
16117
|
let fromToken;
|
|
17167
16118
|
let toToken;
|
|
@@ -17186,8 +16137,8 @@ Error: ${error2.message}`));
|
|
|
17186
16137
|
return;
|
|
17187
16138
|
}
|
|
17188
16139
|
const [fromChainStr, toChainStr, amountStr, ...rest] = args;
|
|
17189
|
-
const fromChain =
|
|
17190
|
-
const toChain =
|
|
16140
|
+
const fromChain = resolveChainOrThrow(fromChainStr, "source chain");
|
|
16141
|
+
const toChain = resolveChainOrThrow(toChainStr, "destination chain");
|
|
17191
16142
|
const amount = amountStr;
|
|
17192
16143
|
let fromToken;
|
|
17193
16144
|
let toToken;
|
|
@@ -17227,7 +16178,7 @@ Error: ${error2.message}`));
|
|
|
17227
16178
|
remove = args[i + 1];
|
|
17228
16179
|
i++;
|
|
17229
16180
|
} else if (args[i] === "--chain" && i + 1 < args.length) {
|
|
17230
|
-
chain =
|
|
16181
|
+
chain = resolveChainOrThrow(args[i + 1], "chain");
|
|
17231
16182
|
i++;
|
|
17232
16183
|
}
|
|
17233
16184
|
}
|
|
@@ -17896,7 +16847,7 @@ Examples:
|
|
|
17896
16847
|
withExit(async (chainStr, options) => {
|
|
17897
16848
|
const context = await init(program2.opts().vault);
|
|
17898
16849
|
await executeBalance(context, {
|
|
17899
|
-
chain:
|
|
16850
|
+
chain: resolveOptionalChainOrThrow(chainStr),
|
|
17900
16851
|
includeTokens: options.tokens,
|
|
17901
16852
|
raw: options.raw
|
|
17902
16853
|
});
|
|
@@ -17920,8 +16871,8 @@ See also: balance, tx-status`
|
|
|
17920
16871
|
async (chainStr, to, amount, options) => {
|
|
17921
16872
|
if (!amount && !options.max) throw new Error("Provide an amount or use --max");
|
|
17922
16873
|
if (amount && options.max) throw new Error("Cannot specify both amount and --max");
|
|
17923
|
-
const chain =
|
|
17924
|
-
if (options.destinationTag !== void 0 && chain !==
|
|
16874
|
+
const chain = resolveChainOrThrow(chainStr);
|
|
16875
|
+
if (options.destinationTag !== void 0 && chain !== Chain13.Ripple) {
|
|
17925
16876
|
throw new Error("--destination-tag is only supported for XRP");
|
|
17926
16877
|
}
|
|
17927
16878
|
const destinationTag = options.destinationTag === void 0 ? void 0 : Number(options.destinationTag);
|
|
@@ -17955,7 +16906,7 @@ Examples:
|
|
|
17955
16906
|
async (chainStr, contract, msg, options) => {
|
|
17956
16907
|
const context = await init(program2.opts().vault, options.password);
|
|
17957
16908
|
await executeExecute(context, {
|
|
17958
|
-
chain:
|
|
16909
|
+
chain: resolveChainOrThrow(chainStr),
|
|
17959
16910
|
contract,
|
|
17960
16911
|
msg,
|
|
17961
16912
|
funds: options.funds,
|
|
@@ -17971,7 +16922,7 @@ program2.command("sign").description("Sign pre-hashed bytes (for externally cons
|
|
|
17971
16922
|
withExit(async (options) => {
|
|
17972
16923
|
const context = await init(program2.opts().vault, options.password);
|
|
17973
16924
|
await executeSignBytes(context, {
|
|
17974
|
-
chain:
|
|
16925
|
+
chain: resolveChainOrThrow(options.chain),
|
|
17975
16926
|
bytes: options.bytes,
|
|
17976
16927
|
password: options.password
|
|
17977
16928
|
});
|
|
@@ -17981,7 +16932,7 @@ program2.command("broadcast").description("Broadcast a pre-signed raw transactio
|
|
|
17981
16932
|
withExit(async (options) => {
|
|
17982
16933
|
const context = await init(program2.opts().vault);
|
|
17983
16934
|
await executeBroadcast(context, {
|
|
17984
|
-
chain:
|
|
16935
|
+
chain: resolveChainOrThrow(options.chain),
|
|
17985
16936
|
rawTx: options.rawTx
|
|
17986
16937
|
});
|
|
17987
16938
|
})
|
|
@@ -18005,7 +16956,7 @@ Examples:
|
|
|
18005
16956
|
);
|
|
18006
16957
|
}
|
|
18007
16958
|
const params = resolveTxStatusParams({
|
|
18008
|
-
chain:
|
|
16959
|
+
chain: resolveChainOrThrow(options.chain),
|
|
18009
16960
|
txHash: options.txHash,
|
|
18010
16961
|
noWait: !options.wait,
|
|
18011
16962
|
timeoutSec
|
|
@@ -18081,7 +17032,7 @@ program2.command("address-book").description("Manage address book entries").opti
|
|
|
18081
17032
|
await executeAddressBook(context, {
|
|
18082
17033
|
add: options.add,
|
|
18083
17034
|
remove: options.remove,
|
|
18084
|
-
chain:
|
|
17035
|
+
chain: resolveOptionalChainOrThrow(options.chain),
|
|
18085
17036
|
address: options.address,
|
|
18086
17037
|
name: options.name
|
|
18087
17038
|
});
|
|
@@ -18098,9 +17049,9 @@ Examples:
|
|
|
18098
17049
|
withExit(async (options) => {
|
|
18099
17050
|
const context = await init(program2.opts().vault);
|
|
18100
17051
|
await executeChains(context, {
|
|
18101
|
-
add: options.add
|
|
17052
|
+
add: resolveOptionalChainOrThrow(options.add, "chain"),
|
|
18102
17053
|
addAll: options.addAll,
|
|
18103
|
-
remove: options.remove
|
|
17054
|
+
remove: resolveOptionalChainOrThrow(options.remove, "chain")
|
|
18104
17055
|
});
|
|
18105
17056
|
})
|
|
18106
17057
|
);
|
|
@@ -18217,8 +17168,8 @@ See also: swap-quote, swap-chains, balance`
|
|
|
18217
17168
|
if (amountStr && options.max) throw new Error("Cannot specify both amount and --max");
|
|
18218
17169
|
const context = await init(program2.opts().vault);
|
|
18219
17170
|
await executeSwap(context, {
|
|
18220
|
-
fromChain:
|
|
18221
|
-
toChain:
|
|
17171
|
+
fromChain: resolveChainOrThrow(fromChainStr, "source chain"),
|
|
17172
|
+
toChain: resolveChainOrThrow(toChainStr, "destination chain"),
|
|
18222
17173
|
amount: options.max ? "max" : amountStr,
|
|
18223
17174
|
fromToken: options.fromToken,
|
|
18224
17175
|
toToken: options.toToken,
|