polkadot-cli 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +18 -3
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -1060,6 +1060,7 @@ async function accountRemove(name) {
|
|
|
1060
1060
|
}
|
|
1061
1061
|
|
|
1062
1062
|
// src/commands/tx.ts
|
|
1063
|
+
import { Binary } from "polkadot-api";
|
|
1063
1064
|
function registerTxCommand(cli) {
|
|
1064
1065
|
cli.command("tx [target] [...args]", "Submit an extrinsic (e.g. Balances.transferKeepAlive <dest> <amount>)").option("--from <name>", "Account to sign with (required)").option("--dry-run", "Estimate fees without submitting").action(async (target, args, opts) => {
|
|
1065
1066
|
if (!target || !opts.from) {
|
|
@@ -1224,6 +1225,13 @@ function parseTypedArg(lookup, entry, arg) {
|
|
|
1224
1225
|
} catch {}
|
|
1225
1226
|
}
|
|
1226
1227
|
const variants = Object.keys(entry.value);
|
|
1228
|
+
if (variants.includes("Id")) {
|
|
1229
|
+
const idVariant = entry.value["Id"];
|
|
1230
|
+
const innerType = idVariant.type === "lookupEntry" ? idVariant.value : idVariant;
|
|
1231
|
+
if (innerType.type === "AccountId32" && !arg.startsWith("{")) {
|
|
1232
|
+
return { type: "Id", value: arg };
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1227
1235
|
const matched = variants.find((v) => v.toLowerCase() === arg.toLowerCase());
|
|
1228
1236
|
if (matched) {
|
|
1229
1237
|
const variant = entry.value[matched];
|
|
@@ -1234,15 +1242,22 @@ function parseTypedArg(lookup, entry, arg) {
|
|
|
1234
1242
|
return parseValue(arg);
|
|
1235
1243
|
}
|
|
1236
1244
|
case "sequence":
|
|
1237
|
-
case "array":
|
|
1245
|
+
case "array": {
|
|
1246
|
+
const inner = entry.value;
|
|
1247
|
+
if (inner.type === "primitive" && inner.value === "u8") {
|
|
1248
|
+
if (/^0x[0-9a-fA-F]*$/.test(arg))
|
|
1249
|
+
return Binary.fromHex(arg);
|
|
1250
|
+
return Binary.fromText(arg);
|
|
1251
|
+
}
|
|
1238
1252
|
if (arg.startsWith("[")) {
|
|
1239
1253
|
try {
|
|
1240
1254
|
return JSON.parse(arg);
|
|
1241
1255
|
} catch {}
|
|
1242
1256
|
}
|
|
1243
1257
|
if (/^0x[0-9a-fA-F]*$/.test(arg))
|
|
1244
|
-
return arg;
|
|
1258
|
+
return Binary.fromHex(arg);
|
|
1245
1259
|
return parseValue(arg);
|
|
1260
|
+
}
|
|
1246
1261
|
case "struct":
|
|
1247
1262
|
if (arg.startsWith("{")) {
|
|
1248
1263
|
try {
|
|
@@ -1310,7 +1325,7 @@ registerConstCommand(cli);
|
|
|
1310
1325
|
registerAccountCommands(cli);
|
|
1311
1326
|
registerTxCommand(cli);
|
|
1312
1327
|
cli.help();
|
|
1313
|
-
cli.version("0.2.
|
|
1328
|
+
cli.version("0.2.1");
|
|
1314
1329
|
function handleError(err) {
|
|
1315
1330
|
if (err instanceof CliError2) {
|
|
1316
1331
|
console.error(`Error: ${err.message}`);
|