@everyprotocol/every-cli 0.1.1 → 0.1.3

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/abi.js CHANGED
@@ -31,6 +31,11 @@ export const abi = {
31
31
  "function mint(address to, address set, uint64 id, bytes memory data, bytes memory auth, uint32 policy) payable",
32
32
  ]),
33
33
  ...loadNonFuncAbiItems("ObjectMinter"),
34
+ ...loadNonFuncAbiItems("ISet"),
35
+ ],
36
+ create: [
37
+ ...parseAbi(["function create(address to, uint64 id0, bytes calldata data) payable"]),
38
+ ...loadNonFuncAbiItems("ISet"),
34
39
  ],
35
40
  relation: [
36
41
  ...parseAbi([
package/dist/cmdgen.js CHANGED
@@ -71,7 +71,7 @@ const setContractObjectCmdConfig = {
71
71
  const rawArgs = checkArguments(ctx.cmd.args, ctx.cmdAbi);
72
72
  const [set, id] = rawArgs[0].split(".");
73
73
  const args = [JSON5.parse(id), ...rawArgs.slice(1)];
74
- const publicClient = createPublicClient({ transport: http(ctx.conf.rpcUrl) });
74
+ const publicClient = createPublicClient({ transport: http(ctx.conf.rpc) });
75
75
  const address = (await publicClient.readContract({
76
76
  address: ctx.conf.contracts["SetRegistry"],
77
77
  abi: abi.setContract,
@@ -85,7 +85,7 @@ const objectUriTxnPrepare = async function (ctx) {
85
85
  const rawArgs = checkArguments(ctx.cmd.args, ctx.cmdAbi);
86
86
  // const [set, id] = rawArgs[0].split(".");
87
87
  const set = rawArgs[0].split(".")[0];
88
- const publicClient = createPublicClient({ transport: http(ctx.conf.rpcUrl) });
88
+ const publicClient = createPublicClient({ transport: http(ctx.conf.rpc) });
89
89
  const address = (await publicClient.readContract({
90
90
  address: ctx.conf.contracts["SetRegistry"],
91
91
  abi: abi.setContract,
package/dist/cmds.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import { Argument, Command, Option } from "commander";
2
2
  import { createPublicClient, http, parseEventLogs, stringify } from "viem";
3
3
  import { getUniverseConfig } from "./config.js";
4
- import { checkArguments, getClients } from "./utils.js";
4
+ import { checkArguments, getClientsEth } from "./utils.js";
5
5
  export function defaultReadFunctionOptions() {
6
6
  const options = [];
7
7
  options.push(new Option("-u, --universe <universe>", "universe name").default("local"));
8
- options.push(new Option("--dryrun", "dry run"));
8
+ options.push(new Option("--dry-run", "Simulate the command without sending a transaction"));
9
9
  return options;
10
10
  }
11
11
  export function defaultWriteFunctionOptions() {
@@ -14,9 +14,9 @@ export function defaultWriteFunctionOptions() {
14
14
  options.push(new Option("-k, --private-key <key>", "private key to sign the transaction"));
15
15
  options.push(new Option("-a, --account <account>", "name of the keystore to sign the transaction"));
16
16
  options.push(new Option("-p, --password [password]", "password to decrypt the keystore"));
17
- options.push(new Option("-f, --password-file <file>", "file containing the password to decrypt the keystore"));
18
- options.push(new Option("--foundry", "use keystore from Foundry directory (~/.foundry/keystores)"));
19
- options.push(new Option("--dryrun", "dry run"));
17
+ options.push(new Option("--password-file <file>", "file containing the password to decrypt the keystore"));
18
+ options.push(new Option("-f, --foundry", "use keystore from Foundry directory (~/.foundry/keystores)"));
19
+ options.push(new Option("--dry-run", "Simulate the command without sending a transaction"));
20
20
  return options;
21
21
  }
22
22
  const defaultConfig = {
@@ -40,12 +40,12 @@ const defaultConfig = {
40
40
  const abi = [ctx.txnAbi, ...ctx.nonFuncs];
41
41
  const functionName = ctx.txnAbi.name;
42
42
  if (isRead) {
43
- const publicClient = createPublicClient({ transport: http(ctx.conf.rpcUrl) });
43
+ const publicClient = createPublicClient({ transport: http(ctx.conf.rpc) });
44
44
  const result = await publicClient.readContract({ address, abi, functionName, args });
45
45
  console.log(`Result:`, result);
46
46
  }
47
47
  else {
48
- const { publicClient, walletClient } = await getClients(ctx.conf, opts);
48
+ const { publicClient, walletClient } = await getClientsEth(ctx.conf, opts);
49
49
  const account = walletClient.account;
50
50
  console.log({
51
51
  isRead,
package/dist/config.js CHANGED
@@ -2,7 +2,93 @@ import fs from "fs";
2
2
  import path from "path";
3
3
  import os from "os";
4
4
  import { parse as parseTOML } from "@iarna/toml";
5
+ import * as TOML from "@iarna/toml";
5
6
  import { __dirname } from "./utils.js";
7
+ // export interface Universe {
8
+ // name: string;
9
+ // id: number;
10
+ // rpc: string;
11
+ // explorer: string;
12
+ // observer: string;
13
+ // contracts: {
14
+ // setRegistry: string;
15
+ // omniRegistry: string;
16
+ // kindRegistry: string;
17
+ // elementRegistry: string;
18
+ // objectMinter: string;
19
+ // };
20
+ // }
21
+ // export interface Observer {
22
+ // name: string;
23
+ // rpc: string;
24
+ // explorer: string;
25
+ // gateway: string;
26
+ // }
27
+ // export interface Config {
28
+ // universes: Record<string, Universe>;
29
+ // observers: Record<string, Observer>;
30
+ // }
31
+ import { z } from "zod";
32
+ export const ContractsSchema = z.object({
33
+ SetRegistry: z.string().regex(/^0x[0-9a-fA-F]{40}$/, "Must be an Ethereum address"),
34
+ OmniRegistry: z.string().regex(/^0x[0-9a-fA-F]{40}$/),
35
+ KindRegistry: z.string().regex(/^0x[0-9a-fA-F]{40}$/),
36
+ ElementRegistry: z.string().regex(/^0x[0-9a-fA-F]{40}$/),
37
+ ObjectMinter: z.string().regex(/^0x[0-9a-fA-F]{40}$/),
38
+ });
39
+ export const UniverseSchema = z.object({
40
+ id: z.number().int().nonnegative(),
41
+ rpc: z.string().url(),
42
+ explorer: z.string().url(),
43
+ observer: z.string(), // reference to an Observer key
44
+ contracts: ContractsSchema,
45
+ });
46
+ export const ObserverSchema = z.object({
47
+ rpc: z.string().url(),
48
+ explorer: z.string().url(),
49
+ gateway: z.string().url(),
50
+ });
51
+ export const ConfigSchema = z.object({
52
+ universes: z.record(UniverseSchema),
53
+ observers: z.record(ObserverSchema),
54
+ });
55
+ export function loadConfig(file) {
56
+ const text = fs.readFileSync(file, "utf8");
57
+ const raw = TOML.parse(text);
58
+ return ConfigSchema.parse(raw);
59
+ }
60
+ const configPaths = [
61
+ path.resolve(__dirname, "../.every.toml"),
62
+ path.resolve(os.homedir(), ".every.toml"),
63
+ path.resolve(process.cwd(), ".every.toml"),
64
+ ];
65
+ export function loadMergedConfig() {
66
+ const merged = { universes: {}, observers: {} };
67
+ const existingFiles = configPaths.filter((f) => fs.existsSync(f));
68
+ if (existingFiles.length === 0) {
69
+ throw new Error(`No config file found. Searched in:\n ${configPaths.join("\n ")}`);
70
+ }
71
+ for (const file of existingFiles) {
72
+ const raw = loadConfig(file);
73
+ if (raw.universes) {
74
+ for (const [name, uni] of Object.entries(raw.universes)) {
75
+ merged.universes[name] = {
76
+ ...(merged.universes[name] ?? {}),
77
+ ...uni, // shallow merge here
78
+ };
79
+ }
80
+ }
81
+ if (raw.observers) {
82
+ for (const [name, obs] of Object.entries(raw.observers)) {
83
+ merged.observers[name] = {
84
+ ...(merged.observers[name] ?? {}),
85
+ ...obs,
86
+ };
87
+ }
88
+ }
89
+ }
90
+ return ConfigSchema.parse(merged);
91
+ }
6
92
  // Cache
7
93
  let CONFIG_CACHED = null;
8
94
  export function getUniverseConfig(opts) {
@@ -39,7 +125,10 @@ function loadProtocolConfig() {
39
125
  // console.log(name, uni);
40
126
  mergedConfig.universes[name] = {
41
127
  name: name,
42
- rpcUrl: uni.rpc_url,
128
+ id: uni.id,
129
+ rpc: uni.rpc,
130
+ explorer: uni.explorer,
131
+ observer: uni.observer,
43
132
  contracts: uni.contracts || {},
44
133
  };
45
134
  }
package/dist/index.js CHANGED
@@ -1,43 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { Command } from "commander";
3
- import { generateCommands } from "./cmdgen.js";
4
- import { RenamingCommand } from "./cmds.js";
5
- import { version } from "./utils.js";
6
- async function main() {
7
- const subCmds = generateCommands();
8
- const kindCmd = new RenamingCommand().name("kind").description("manage kinds").addCommands(subCmds.kind);
9
- const setCmd = new RenamingCommand().name("set").description("manage sets").addCommands(subCmds.set);
10
- const relationCmd = new RenamingCommand()
11
- .name("relation")
12
- .description("manage relations")
13
- .addCommands(subCmds.relation);
14
- const uniqueCmd = new RenamingCommand().name("unique").description("manage uniques").addCommands(subCmds.unique);
15
- const valueCmd = new RenamingCommand().name("value").description("manage values").addCommands(subCmds.value);
16
- const objectCmd = new RenamingCommand()
17
- .name("object")
18
- .description("create and interact with objects")
19
- .addCommands(subCmds.object);
20
- const mintPolicyCmd = new RenamingCommand()
21
- .name("mintpolicy")
22
- .description("manage mint policies")
23
- .addCommands(subCmds.mintpolicy);
24
- const program = new Command()
25
- .name("every")
26
- .description("CLI for interacting with Every Protocol")
27
- .version(version())
28
- .showHelpAfterError(true);
29
- program.addCommand(kindCmd);
30
- program.addCommand(setCmd);
31
- program.addCommand(relationCmd);
32
- program.addCommand(uniqueCmd);
33
- program.addCommand(valueCmd);
34
- program.addCommand(objectCmd);
35
- program.addCommand(mintPolicyCmd);
36
- try {
37
- await program.parseAsync();
38
- }
39
- catch (e) {
40
- console.error(e.message);
41
- }
2
+ import { program } from "./program.js";
3
+ try {
4
+ await program.parseAsync();
5
+ }
6
+ catch (e) {
7
+ console.error(e.message);
42
8
  }
43
- await main();
@@ -0,0 +1,120 @@
1
+ import { Keyring } from "@polkadot/keyring";
2
+ import { u8aToHex, hexToU8a, isHex } from "@polkadot/util";
3
+ import { base64Decode, cryptoWaitReady } from "@polkadot/util-crypto";
4
+ import { privateKeyToAccount } from "viem/accounts";
5
+ import { Wallet } from "ethers";
6
+ import { decodePair } from "@polkadot/keyring/pair/decode";
7
+ function isSubstrateJson(obj) {
8
+ return !!obj?.encoded && !!obj?.encoding && !!obj?.encoding?.content;
9
+ }
10
+ function isWeb3V3Json(obj) {
11
+ return Number(obj?.version) === 3 && !!obj?.crypto;
12
+ }
13
+ function inferSubstrateKeyType(obj) {
14
+ const content = Array.isArray(obj.encoding.content) ? obj.encoding.content : [obj.encoding.content];
15
+ // Typical values: ["pkcs8","sr25519"] | ["pkcs8","ed25519"] | ["pkcs8","ecdsa"] | ["pkcs8","ethereum"]
16
+ if (content.includes("sr25519"))
17
+ return "sr25519";
18
+ if (content.includes("ed25519"))
19
+ return "ed25519";
20
+ if (content.includes("ecdsa"))
21
+ return "ecdsa";
22
+ if (content.includes("ethereum"))
23
+ return "ethereum";
24
+ // Default to sr25519 if not specified (common in older exports)
25
+ return "sr25519";
26
+ }
27
+ function decryptSubstrate(keystore, password = "") {
28
+ const encodedRaw = keystore.encoded;
29
+ const types = keystore.encoding.type;
30
+ const encodingTypes = Array.isArray(types) ? types : [types];
31
+ const encoded = isHex(encodedRaw) ? hexToU8a(encodedRaw) : base64Decode(encodedRaw);
32
+ const decoded = decodePair(password, encoded, encodingTypes /*eslint-disable-line @typescript-eslint/no-explicit-any*/);
33
+ return decoded.secretKey;
34
+ }
35
+ async function decryptWeb3V3(keystore, password = "") {
36
+ const w = await Wallet.fromEncryptedJson(JSON.stringify(keystore), password);
37
+ return hexToU8a(w.privateKey);
38
+ }
39
+ export class UnifiedKeystore {
40
+ _keystore;
41
+ _type;
42
+ _keyType;
43
+ _password;
44
+ _pair; // cached for all key types
45
+ _account; // cached for ethereum keys (viem)
46
+ _privateKey; // cached decrypted private key
47
+ constructor(type, keyType, keystore, password) {
48
+ this._keystore = keystore;
49
+ this._type = type;
50
+ this._keyType = keyType;
51
+ this._password = password;
52
+ }
53
+ static async fromJSON(keystore, password) {
54
+ await cryptoWaitReady();
55
+ const obj = typeof keystore === "string" ? JSON.parse(keystore) : keystore;
56
+ if (isSubstrateJson(obj)) {
57
+ const keyType = inferSubstrateKeyType(obj);
58
+ return new UnifiedKeystore("substrate", keyType, obj, password);
59
+ }
60
+ if (isWeb3V3Json(obj)) {
61
+ return new UnifiedKeystore("web3_v3", "ethereum", obj, password);
62
+ }
63
+ throw new Error("Unsupported keystore JSON: expected Substrate (pkcs8) or Web3 v3 keystore");
64
+ }
65
+ type() {
66
+ return this._type;
67
+ }
68
+ keyType() {
69
+ return this._keyType;
70
+ }
71
+ async address() {
72
+ return (await this.pair()).address;
73
+ }
74
+ async publicKey() {
75
+ return (await this.pair()).publicKey;
76
+ }
77
+ async privateKey() {
78
+ if (this._privateKey)
79
+ return this._privateKey;
80
+ if (this._type === "substrate") {
81
+ this._privateKey = decryptSubstrate(this._keystore, this._password ?? "");
82
+ }
83
+ else {
84
+ this._privateKey = await decryptWeb3V3(this._keystore, this._password ?? "");
85
+ }
86
+ return this._privateKey;
87
+ }
88
+ async pair() {
89
+ if (this._pair)
90
+ return this._pair;
91
+ const keyring = new Keyring({ type: this._keyType });
92
+ if (this._type === "substrate") {
93
+ const pair = keyring.addFromJson(this._keystore);
94
+ if (this._password !== undefined) {
95
+ try {
96
+ pair.unlock(this._password);
97
+ }
98
+ catch {
99
+ // If password is wrong/empty, leave it locked; address/publicKey still work.
100
+ }
101
+ }
102
+ this._pair = pair;
103
+ }
104
+ else {
105
+ const sk = await this.privateKey();
106
+ this._pair = keyring.addFromUri(u8aToHex(sk));
107
+ }
108
+ return this._pair;
109
+ }
110
+ async account() {
111
+ if (this._keyType !== "ethereum") {
112
+ throw new Error("accounts() is only available for ethereum keys");
113
+ }
114
+ if (this._account)
115
+ return this._account;
116
+ const sk = await this.privateKey();
117
+ this._account = privateKeyToAccount(u8aToHex(sk));
118
+ return this._account;
119
+ }
120
+ }
package/dist/matter.js ADDED
@@ -0,0 +1,96 @@
1
+ import { Command } from "commander";
2
+ import { ApiPromise, WsProvider } from "@polkadot/api";
3
+ import "@polkadot/api-augment/substrate";
4
+ import * as fs from "fs";
5
+ import * as path from "path";
6
+ import { getObserverConfig, keystoreFromOptions } from "./utils.js";
7
+ import "./options.js";
8
+ import { findEvent, submitTransaction } from "./substrate.js";
9
+ import JSON5 from "json5";
10
+ function guessContentType(filePath) {
11
+ const ext = path.extname(filePath).toLowerCase();
12
+ switch (ext) {
13
+ case ".txt":
14
+ return "text/plain";
15
+ case ".json":
16
+ return "application/json";
17
+ case ".wasm":
18
+ return "application/wasm";
19
+ case ".jpg":
20
+ case ".jpeg":
21
+ return "image/jpeg";
22
+ case ".png":
23
+ return "image/png";
24
+ default:
25
+ return "application/octet-stream";
26
+ }
27
+ }
28
+ export function genMatterCommand() {
29
+ const cmd = new Command().name("matter").description("manage matters");
30
+ cmd
31
+ .command("register")
32
+ .description("Register matter on the Substrate chain")
33
+ .argument("<files...>", "Path to the file(s) containing the matter content")
34
+ .option("-c, --content-type <type>", "Default content type")
35
+ .option("-h, --hasher <number>", "Default hasher", "1")
36
+ .option("-u, --universe <name>", "Universe name")
37
+ .option("-o, --observer <name>", "Observer name")
38
+ .accountOptions()
39
+ .action(async (files, options) => {
40
+ const materials = [];
41
+ // Process each file argument
42
+ for (const file of files) {
43
+ const [filePath, hasher_, contentType_] = file.split(":");
44
+ const hasher = hasher_ ? Number(hasher_) : Number(options.hasher) || 1;
45
+ const contentType = contentType_ || options.contentType || guessContentType(filePath);
46
+ materials.push({ filePath, hasher, contentType });
47
+ }
48
+ const conf = getObserverConfig(options);
49
+ const keystore = await keystoreFromOptions(options);
50
+ const pair = await keystore.pair();
51
+ // Connect to the Substrate node
52
+ // console.log(`Connecting to ${conf.rpc}...`);
53
+ const provider = new WsProvider(conf.rpc);
54
+ const api = await ApiPromise.create({ provider });
55
+ await api.isReady;
56
+ // console.log("Connected to Substrate node");
57
+ const txns = [];
58
+ // Submit transactions for each material
59
+ for (const { filePath, hasher, contentType } of materials) {
60
+ console.log(`Processing ${filePath}: content-type=${contentType}, hasher=${hasher}`);
61
+ const content = fs.readFileSync(filePath);
62
+ const contentRaw = api.createType("Raw", content, content.length);
63
+ const call = api.tx.every.matterRegister(hasher, contentType, contentRaw);
64
+ console.log(`Submitting transaction for ${filePath}...`);
65
+ const txn = await submitTransaction(api, call, pair);
66
+ console.log(`Transaction submitted: ${txn.txHash}`);
67
+ txns.push({ txn, filePath });
68
+ }
69
+ // Wait for all transactions to be finalized
70
+ for (const { txn, filePath } of txns) {
71
+ console.log(`Waiting for ${filePath} to be finalized...`);
72
+ const receipt = await txn.receipt;
73
+ const event = findEvent(receipt.events, "MaterialAdded");
74
+ if (event) {
75
+ const hash = event.data[0].toString();
76
+ console.log(`${filePath} finalized in block ${receipt.blockHash}`);
77
+ console.log(` Matter hash: ${hash}`);
78
+ if (conf.gateway) {
79
+ console.log(` Preimage: ${conf.gateway}/m/${hash}`);
80
+ }
81
+ if (conf.explorer) {
82
+ // console.log(` Transaction: ${conf.explorer}/extrinsic/${receipt.blockNumber}-${receipt.txIndex}`);
83
+ }
84
+ }
85
+ else {
86
+ console.log(`${filePath} finalized, but no MaterialAdded event found`);
87
+ for (const { event } of receipt.events) {
88
+ console.log(`${event.method.padEnd(20)}`, JSON5.stringify(event.data.toHuman()));
89
+ }
90
+ }
91
+ }
92
+ await api.disconnect();
93
+ console.log("Disconnected from Substrate node");
94
+ });
95
+ return cmd;
96
+ }
package/dist/mint.js CHANGED
@@ -1,19 +1,20 @@
1
1
  import { Command } from "commander";
2
2
  import { defaultWriteFunctionOptions } from "./cmds.js";
3
- import { getClients, stringify } from "./utils.js";
3
+ import { getClientsEth, stringify } from "./utils.js";
4
4
  import { getUniverseConfig } from "./config.js";
5
5
  import { parseEventLogs, parseUnits } from "viem";
6
6
  import { abi } from "./abi.js";
7
7
  export function genMintCommand() {
8
8
  const cmd = new Command()
9
9
  .name("mint")
10
- .description("Mint an object via ObjectMinter")
11
- .option("--auth <data>", "authorization data, if needed for a permissioned mint", "0x")
12
- .option("--policy <index>", "the index number of the mint policy", "0")
10
+ .description("Mint an object via the object minter or directly from the set")
11
+ .option("--to <address>", "specify the recipient")
13
12
  .option("--value <amount>", "the amount of ETH to send together", "0")
13
+ .option("--auth <data>", "authorization data for a permissioned mint", "0x")
14
+ .option("--policy <index>", "the index number of the mint policy", "0")
15
+ .option("--no-minter", "mint directly from set contract instead of using ObjectMinter")
14
16
  .argument("<sid>", "scoped object ID, in form of set.id (e.g., 17.1)")
15
- .argument("<to>", "address of the recipient")
16
- .argument("[data]", "additional mint data", "0x")
17
+ .argument("[data]", "additional input data", "0x")
17
18
  .action(action);
18
19
  defaultWriteFunctionOptions().forEach((option) => cmd.addOption(option));
19
20
  return cmd;
@@ -22,9 +23,8 @@ async function action() {
22
23
  const opts = this.opts();
23
24
  const args0 = this.args;
24
25
  const conf = getUniverseConfig(opts);
25
- const objectMinter = conf.contracts["ObjectMinter"];
26
26
  const setRegistry = conf.contracts["SetRegistry"];
27
- const { publicClient, walletClient } = await getClients(conf, opts);
27
+ const { publicClient, walletClient } = await getClientsEth(conf, opts);
28
28
  const account = walletClient.account;
29
29
  const [set, id] = args0[0].split(".");
30
30
  const setContract = (await publicClient.readContract({
@@ -34,28 +34,42 @@ async function action() {
34
34
  args: [BigInt(set)],
35
35
  }));
36
36
  const value = parseUnits(opts.value || "0", 18);
37
- const { request } = await publicClient.simulateContract({
38
- address: objectMinter,
39
- abi: abi.mint,
40
- functionName: "mint",
41
- args: [
42
- args0[1],
43
- setContract,
44
- BigInt(id),
45
- (args0[2] || "0x"),
46
- opts.auth || "0x",
47
- Number(opts.policy || "0"),
48
- ],
49
- account,
50
- value,
51
- });
52
- const hash = await walletClient.writeContract(request);
37
+ // Use the provided recipient address or default to the sender's address
38
+ const recipientAddress = (opts.to || account.address);
39
+ const mintData = (args0[1] || "0x");
40
+ let hash;
41
+ if (opts.minter) {
42
+ // Mint via ObjectMinter
43
+ const objectMinter = conf.contracts["ObjectMinter"];
44
+ const { request } = await publicClient.simulateContract({
45
+ address: objectMinter,
46
+ abi: abi.mint,
47
+ functionName: "mint",
48
+ args: [recipientAddress, setContract, BigInt(id), mintData, opts.auth || "0x", Number(opts.policy || "0")],
49
+ account,
50
+ value,
51
+ });
52
+ hash = await walletClient.writeContract(request);
53
+ }
54
+ else {
55
+ // Mint directly from set contract
56
+ const { request } = await publicClient.simulateContract({
57
+ address: setContract,
58
+ abi: abi.create,
59
+ functionName: "create",
60
+ args: [recipientAddress, BigInt(id), mintData],
61
+ account,
62
+ value,
63
+ });
64
+ hash = await walletClient.writeContract(request);
65
+ }
53
66
  console.log(`Transaction sent: ${hash}`);
54
67
  console.log("Transaction mining...");
55
68
  const receipt = await publicClient.waitForTransactionReceipt({ hash });
56
69
  console.log("Transaction mined");
57
70
  if (receipt.logs && receipt.logs.length > 0) {
58
- const parsedLogs = parseEventLogs({ abi: abi.mint, logs: receipt.logs });
71
+ const abiToUse = opts.minter ? abi.mint : abi.create;
72
+ const parsedLogs = parseEventLogs({ abi: abiToUse, logs: receipt.logs });
59
73
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
60
74
  parsedLogs.forEach((log) => {
61
75
  console.log(" - Event", log.eventName, stringify(log.args));
@@ -0,0 +1,26 @@
1
+ import { Command, Option } from "commander";
2
+ export const optRpcUrl = new Option("--rpc-url <url>", "RPC endpoint URL");
3
+ export const optChainId = new Option("--chain-id <id>", "Chain ID").argParser(Number);
4
+ export const optPkey = new Option("--private-key <hex>", "Sender private key");
5
+ export const optFrom = new Option("--from <address>", "Sender address");
6
+ export const optDerivePath = new Option("--path <hd>", "Derivation path (HD)");
7
+ export const optVerbose = new Option("-v, --verbose", "Enable verbose logging");
8
+ export const optSilent = new Option("--silent", "Suppress output");
9
+ export const optAccount = new Option("-a, --account <account>", "Name of the keystore");
10
+ export const optPassword = new Option("-p, --password [password]", "Password to decrypt the keystore");
11
+ export const optPasswordFile = new Option("--password-file <file>", "File containing the keystore password");
12
+ export const optFoundry = new Option("-f, --foundry", "use foundry keystores (~/.foundry/keystores)");
13
+ export const accountOptions = [optAccount, optPassword, optPasswordFile, optFoundry];
14
+ Command.prototype.useOptions = function (options) {
15
+ options.forEach((o) => this.addOption(o));
16
+ return this;
17
+ };
18
+ // (Command.prototype as unknown as Command).networkOptions = function () {
19
+ // return (this as Command).useOptions(networkGroup);
20
+ // };
21
+ Command.prototype.accountOptions = function () {
22
+ return this.useOptions(accountOptions);
23
+ };
24
+ // (Command.prototype as unknown as Command).commonOptions = function () {
25
+ // return (this as Command).useOptions(commonGroup);
26
+ // };
@@ -0,0 +1,41 @@
1
+ import { Command } from "commander";
2
+ import { generateCommands } from "./cmdgen.js";
3
+ import { RenamingCommand } from "./cmds.js";
4
+ import { version } from "./utils.js";
5
+ import { walletCmd } from "./wallet.js";
6
+ import { genMatterCommand } from "./matter.js";
7
+ function buildProgram() {
8
+ const subCmds = generateCommands();
9
+ const kindCmd = new RenamingCommand().name("kind").description("manage kinds").addCommands(subCmds.kind);
10
+ const setCmd = new RenamingCommand().name("set").description("manage sets").addCommands(subCmds.set);
11
+ const relationCmd = new RenamingCommand()
12
+ .name("relation")
13
+ .description("manage relations")
14
+ .addCommands(subCmds.relation);
15
+ const uniqueCmd = new RenamingCommand().name("unique").description("manage uniques").addCommands(subCmds.unique);
16
+ const valueCmd = new RenamingCommand().name("value").description("manage values").addCommands(subCmds.value);
17
+ const objectCmd = new RenamingCommand()
18
+ .name("object")
19
+ .description("create and interact with objects")
20
+ .addCommands(subCmds.object);
21
+ const mintPolicyCmd = new RenamingCommand()
22
+ .name("minter")
23
+ .description("manage mint policies")
24
+ .addCommands(subCmds.mintpolicy);
25
+ const program = new Command()
26
+ .name("every")
27
+ .description("CLI for interacting with Every Protocol")
28
+ .version(version())
29
+ .showHelpAfterError(true);
30
+ program.addCommand(genMatterCommand());
31
+ program.addCommand(setCmd);
32
+ program.addCommand(kindCmd);
33
+ program.addCommand(relationCmd);
34
+ program.addCommand(valueCmd);
35
+ program.addCommand(uniqueCmd);
36
+ program.addCommand(objectCmd);
37
+ program.addCommand(mintPolicyCmd);
38
+ program.addCommand(walletCmd);
39
+ return program;
40
+ }
41
+ export const program = buildProgram();
package/dist/relate.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Command } from "commander";
2
2
  import { defaultWriteFunctionOptions } from "./cmds.js";
3
- import { getClients, stringify } from "./utils.js";
3
+ import { getClientsEth, stringify } from "./utils.js";
4
4
  import { getUniverseConfig } from "./config.js";
5
5
  import { parseEventLogs } from "viem";
6
6
  import { abi } from "./abi.js";
@@ -41,7 +41,7 @@ async function action(cmd, functionName) {
41
41
  await sendTransaction(conf, opts, address, abi.relation, functionName, [tail, rel, head]);
42
42
  }
43
43
  async function sendTransaction(conf, opts, address, abi /* eslint-disable-line @typescript-eslint/no-explicit-any*/, functionName, args /* eslint-disable-line @typescript-eslint/no-explicit-any*/) {
44
- const { publicClient, walletClient } = await getClients(conf, opts);
44
+ const { publicClient, walletClient } = await getClientsEth(conf, opts);
45
45
  const { request } = await publicClient.simulateContract({
46
46
  address,
47
47
  abi,