@bigmaxwatermelon/sdk 0.4.1 → 0.4.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/cli.js +82 -484
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -9,9 +9,24 @@ var __export = (target, all) => {
|
|
|
9
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
+
// src/env.ts
|
|
13
|
+
import { config } from "dotenv";
|
|
14
|
+
import { resolve, dirname } from "path";
|
|
15
|
+
import { fileURLToPath } from "url";
|
|
16
|
+
function loadEnv2() {
|
|
17
|
+
config({ path: resolve(__dirname, "../.env") });
|
|
18
|
+
}
|
|
19
|
+
var __dirname;
|
|
20
|
+
var init_env = __esm({
|
|
21
|
+
"src/env.ts"() {
|
|
22
|
+
"use strict";
|
|
23
|
+
__dirname = dirname(fileURLToPath(import.meta.url));
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
|
|
12
27
|
// src/sdk/rpc/wallet.ts
|
|
13
28
|
import { ethers } from "ethers";
|
|
14
|
-
function
|
|
29
|
+
function createWallet2(rpcUrl, privateKey) {
|
|
15
30
|
if (privateKey) return new PrivateKeyWallet(rpcUrl, privateKey);
|
|
16
31
|
return new ReadOnlyWallet(rpcUrl);
|
|
17
32
|
}
|
|
@@ -3721,7 +3736,7 @@ var init_StableCoinBeacon = __esm({
|
|
|
3721
3736
|
// src/sdk/rpc/contracts.ts
|
|
3722
3737
|
var contracts_exports = {};
|
|
3723
3738
|
__export(contracts_exports, {
|
|
3724
|
-
getContracts: () =>
|
|
3739
|
+
getContracts: () => getContracts2,
|
|
3725
3740
|
getPlatform: () => getPlatform,
|
|
3726
3741
|
getStableCoin: () => getStableCoin
|
|
3727
3742
|
});
|
|
@@ -3729,7 +3744,7 @@ import { Contract } from "ethers";
|
|
|
3729
3744
|
function abiOf(artifact) {
|
|
3730
3745
|
return artifact.abi;
|
|
3731
3746
|
}
|
|
3732
|
-
function
|
|
3747
|
+
function getContracts2(addresses, runner) {
|
|
3733
3748
|
if (!addresses.platform) throw new Error("ISOMETRY_PLATFORM_ADDRESS is required");
|
|
3734
3749
|
if (!addresses.factory) throw new Error("ISOMETRY_FACTORY_ADDRESS is required");
|
|
3735
3750
|
if (!addresses.beacon) throw new Error("ISOMETRY_BEACON_ADDRESS is required");
|
|
@@ -3766,7 +3781,7 @@ var init_platform = __esm({
|
|
|
3766
3781
|
contracts;
|
|
3767
3782
|
platform;
|
|
3768
3783
|
constructor(addresses, runner) {
|
|
3769
|
-
this.contracts =
|
|
3784
|
+
this.contracts = getContracts2(addresses, runner);
|
|
3770
3785
|
this.platform = this.contracts.platform;
|
|
3771
3786
|
}
|
|
3772
3787
|
async getPlatformInfo() {
|
|
@@ -3825,11 +3840,11 @@ var init_factory = __esm({
|
|
|
3825
3840
|
this.runner = runner;
|
|
3826
3841
|
}
|
|
3827
3842
|
async getBeaconAddress() {
|
|
3828
|
-
const { factory } =
|
|
3843
|
+
const { factory } = getContracts2(this.addresses, this.runner);
|
|
3829
3844
|
return factory.beacon();
|
|
3830
3845
|
}
|
|
3831
3846
|
async getPlatformAddress() {
|
|
3832
|
-
const { factory } =
|
|
3847
|
+
const { factory } = getContracts2(this.addresses, this.runner);
|
|
3833
3848
|
return factory.platform();
|
|
3834
3849
|
}
|
|
3835
3850
|
};
|
|
@@ -3915,275 +3930,17 @@ var init_stablecoin = __esm({
|
|
|
3915
3930
|
});
|
|
3916
3931
|
|
|
3917
3932
|
// src/sdk/rpc/errorMap.ts
|
|
3918
|
-
function decodeError(details) {
|
|
3919
|
-
if (details.data && details.data !== "0x") {
|
|
3920
|
-
const selector = details.data.slice(0, 10).toLowerCase();
|
|
3921
|
-
const mapped = ERROR_SELECTOR_MAP[selector];
|
|
3922
|
-
if (mapped) return mapped;
|
|
3923
|
-
}
|
|
3924
|
-
if (details.reason) {
|
|
3925
|
-
const reason = details.reason;
|
|
3926
|
-
if (reason === "Not authorized" || reason === "Not approved issuer") {
|
|
3927
|
-
return { code: "ACCESS_DENIED", message: reason };
|
|
3928
|
-
}
|
|
3929
|
-
return { code: "REVERT", message: reason };
|
|
3930
|
-
}
|
|
3931
|
-
if (details.revert?.args) {
|
|
3932
|
-
const name = details.revert.name ?? details.revert.signature ?? "";
|
|
3933
|
-
if (name.includes("AccessControl")) {
|
|
3934
|
-
const [account, role] = details.revert.args;
|
|
3935
|
-
return {
|
|
3936
|
-
code: "ACCESS_DENIED",
|
|
3937
|
-
message: `AccessControl: account ${account} missing role ${role}`
|
|
3938
|
-
};
|
|
3939
|
-
}
|
|
3940
|
-
}
|
|
3941
|
-
return null;
|
|
3942
|
-
}
|
|
3943
|
-
var ERROR_SELECTOR_MAP;
|
|
3944
3933
|
var init_errorMap = __esm({
|
|
3945
3934
|
"src/sdk/rpc/errorMap.ts"() {
|
|
3946
3935
|
"use strict";
|
|
3947
|
-
ERROR_SELECTOR_MAP = {
|
|
3948
|
-
// OpenZeppelin AccessControlUnauthorizedAccount(address account, bytes32 role)
|
|
3949
|
-
// keccak256("AccessControlUnauthorizedAccount(address,bytes32)") = 0x761f22a3
|
|
3950
|
-
// ethers v6 surfaces this as 0xe2517d3f in CALL_EXCEPTION details
|
|
3951
|
-
"0xe2517d3f": {
|
|
3952
|
-
code: "ACCESS_DENIED",
|
|
3953
|
-
message: "AccessControl: missing required role"
|
|
3954
|
-
},
|
|
3955
|
-
"0x761f22a3": {
|
|
3956
|
-
code: "ACCESS_DENIED",
|
|
3957
|
-
message: "AccessControl: missing required role"
|
|
3958
|
-
},
|
|
3959
|
-
// OpenZeppelin AccessControl: account is missing role
|
|
3960
|
-
"0x4e6f6c52": {
|
|
3961
|
-
code: "ACCESS_DENIED",
|
|
3962
|
-
message: "AccessControl: account is missing role"
|
|
3963
|
-
},
|
|
3964
|
-
// ERC20: insufficient balance
|
|
3965
|
-
"0x13be252b": {
|
|
3966
|
-
code: "INSUFFICIENT_BALANCE",
|
|
3967
|
-
message: "ERC20: transfer amount exceeds balance"
|
|
3968
|
-
},
|
|
3969
|
-
// ERC20: insufficient allowance
|
|
3970
|
-
"0xf4d708f0": {
|
|
3971
|
-
code: "INSUFFICIENT_ALLOWANCE",
|
|
3972
|
-
message: "ERC20: insufficient allowance"
|
|
3973
|
-
},
|
|
3974
|
-
// Pausable: paused
|
|
3975
|
-
"0x8d1c0a00": {
|
|
3976
|
-
code: "PAUSED",
|
|
3977
|
-
message: "Pausable: paused"
|
|
3978
|
-
},
|
|
3979
|
-
// ERC20: invalid sender
|
|
3980
|
-
"0xdf24fd05": {
|
|
3981
|
-
code: "INVALID_SENDER",
|
|
3982
|
-
message: "ERC20: invalid sender"
|
|
3983
|
-
},
|
|
3984
|
-
// ERC20: blacklisted
|
|
3985
|
-
"0x12d1b5d1": {
|
|
3986
|
-
code: "BLACKLISTED",
|
|
3987
|
-
message: "ERC20: sender is blacklisted"
|
|
3988
|
-
},
|
|
3989
|
-
// Isometry platform / factory custom errors (observed)
|
|
3990
|
-
"0x1e55aece": {
|
|
3991
|
-
code: "NOT_APPROVED_ISSUER",
|
|
3992
|
-
message: "Not an approved issuer"
|
|
3993
|
-
},
|
|
3994
|
-
"0xf2d4620b": {
|
|
3995
|
-
code: "FACTORY_SYMBOL_EXISTS",
|
|
3996
|
-
message: "Factory: symbol already exists"
|
|
3997
|
-
},
|
|
3998
|
-
"0x3b800a46": {
|
|
3999
|
-
code: "ZERO_ADDRESS",
|
|
4000
|
-
message: "Address cannot be zero"
|
|
4001
|
-
}
|
|
4002
|
-
};
|
|
4003
3936
|
}
|
|
4004
3937
|
});
|
|
4005
3938
|
|
|
4006
3939
|
// src/sdk/rpc/writeExecutor.ts
|
|
4007
|
-
function makeWriteMeta(command) {
|
|
4008
|
-
return {
|
|
4009
|
-
chainId: 11155111,
|
|
4010
|
-
source: "rpc",
|
|
4011
|
-
timestamp: Math.floor(Date.now() / 1e3),
|
|
4012
|
-
...command ? { command } : {}
|
|
4013
|
-
};
|
|
4014
|
-
}
|
|
4015
|
-
function formatWriteResult(result, opts, meta) {
|
|
4016
|
-
if (opts.json) {
|
|
4017
|
-
const out = { ok: result.ok };
|
|
4018
|
-
if (result.ok) {
|
|
4019
|
-
if (opts.simulate) {
|
|
4020
|
-
const r2 = result;
|
|
4021
|
-
Object.assign(out, { estimatedGas: r2.estimatedGas, functionFragment: r2.functionFragment, params: r2.params });
|
|
4022
|
-
} else {
|
|
4023
|
-
const r2 = result;
|
|
4024
|
-
Object.assign(out, { receipt: r2.receipt });
|
|
4025
|
-
}
|
|
4026
|
-
} else {
|
|
4027
|
-
const r2 = result;
|
|
4028
|
-
Object.assign(out, { code: r2.code, message: r2.message });
|
|
4029
|
-
if (r2.selector) Object.assign(out, { selector: r2.selector });
|
|
4030
|
-
}
|
|
4031
|
-
if (meta) Object.assign(out, { meta });
|
|
4032
|
-
return JSON.stringify(
|
|
4033
|
-
out,
|
|
4034
|
-
(_key, value) => typeof value === "bigint" ? value.toString() : value,
|
|
4035
|
-
2
|
|
4036
|
-
);
|
|
4037
|
-
}
|
|
4038
|
-
if (!result.ok) {
|
|
4039
|
-
return `\u274C [${result.code}] ${result.message}`;
|
|
4040
|
-
}
|
|
4041
|
-
if (opts.simulate) {
|
|
4042
|
-
const sim = result;
|
|
4043
|
-
return `\u2705 Simulation passed
|
|
4044
|
-
Estimated gas: ${sim.estimatedGas.toLocaleString()}`;
|
|
4045
|
-
}
|
|
4046
|
-
const exec = result;
|
|
4047
|
-
const r = exec.receipt;
|
|
4048
|
-
const ok = r.status === 1;
|
|
4049
|
-
return [
|
|
4050
|
-
`${ok ? "\u2705" : "\u274C"} Transaction ${ok ? "confirmed" : "FAILED"}`,
|
|
4051
|
-
` Tx Hash ${r.txHash}`,
|
|
4052
|
-
` Block ${r.blockNumber ?? "pending"}`,
|
|
4053
|
-
` From ${r.from}`,
|
|
4054
|
-
` To ${r.to ?? "N/A"}`,
|
|
4055
|
-
` Gas Used ${r.gasUsed.toLocaleString()}`,
|
|
4056
|
-
` Status ${ok ? "success" : "reverted"}`
|
|
4057
|
-
].join("\n");
|
|
4058
|
-
}
|
|
4059
|
-
var WriteExecutor;
|
|
4060
3940
|
var init_writeExecutor = __esm({
|
|
4061
3941
|
"src/sdk/rpc/writeExecutor.ts"() {
|
|
4062
3942
|
"use strict";
|
|
4063
3943
|
init_errorMap();
|
|
4064
|
-
WriteExecutor = class {
|
|
4065
|
-
constructor(config2) {
|
|
4066
|
-
this.config = config2;
|
|
4067
|
-
}
|
|
4068
|
-
config;
|
|
4069
|
-
/** Dry-run: estimate gas without signing. Returns gas estimate or decoded error. */
|
|
4070
|
-
async simulate(call) {
|
|
4071
|
-
if (this.config.wallet.mode === "readonly") {
|
|
4072
|
-
return {
|
|
4073
|
-
ok: false,
|
|
4074
|
-
code: "NO_SIGNER",
|
|
4075
|
-
message: `Cannot simulate: wallet is read-only. Set ISOMETRY_PRIVATE_KEY to enable write operations.`
|
|
4076
|
-
};
|
|
4077
|
-
}
|
|
4078
|
-
try {
|
|
4079
|
-
const fn = this.config.contract.getFunction(call.method);
|
|
4080
|
-
const gasEstimate = await fn.estimateGas(...call.args, call.overrides ?? {});
|
|
4081
|
-
const params = {};
|
|
4082
|
-
fn.fragment.inputs.forEach((input, i) => {
|
|
4083
|
-
params[input.name || `arg${i}`] = call.args[i];
|
|
4084
|
-
});
|
|
4085
|
-
return {
|
|
4086
|
-
ok: true,
|
|
4087
|
-
estimatedGas: gasEstimate,
|
|
4088
|
-
functionFragment: `${call.method}(${fn.fragment.inputs.map((i) => i.type).join(",")})`,
|
|
4089
|
-
params
|
|
4090
|
-
};
|
|
4091
|
-
} catch (err) {
|
|
4092
|
-
const decoded = this.parseRevertError(err);
|
|
4093
|
-
return {
|
|
4094
|
-
ok: false,
|
|
4095
|
-
code: "SIMULATION_FAILED",
|
|
4096
|
-
message: `[simulate] ${decoded.message}`,
|
|
4097
|
-
details: err,
|
|
4098
|
-
...decoded.selector ? { selector: decoded.selector } : {}
|
|
4099
|
-
};
|
|
4100
|
-
}
|
|
4101
|
-
}
|
|
4102
|
-
/** Execute: sign and broadcast, wait for receipt. */
|
|
4103
|
-
async execute(call, confirmations = 1) {
|
|
4104
|
-
if (this.config.wallet.mode === "readonly") {
|
|
4105
|
-
return {
|
|
4106
|
-
ok: false,
|
|
4107
|
-
code: "NO_SIGNER",
|
|
4108
|
-
message: `Cannot execute: wallet is read-only. Set ISOMETRY_PRIVATE_KEY to enable write operations.`
|
|
4109
|
-
};
|
|
4110
|
-
}
|
|
4111
|
-
if (!this.config.wallet.signer) {
|
|
4112
|
-
return {
|
|
4113
|
-
ok: false,
|
|
4114
|
-
code: "NO_SIGNER",
|
|
4115
|
-
message: "Wallet has no signer."
|
|
4116
|
-
};
|
|
4117
|
-
}
|
|
4118
|
-
try {
|
|
4119
|
-
const contract = this.config.contract.connect(this.config.wallet.signer);
|
|
4120
|
-
const fn = contract.getFunction(call.method);
|
|
4121
|
-
const tx = await fn.populateTransaction(...call.args, call.overrides ?? {});
|
|
4122
|
-
const signedTx = await this.config.wallet.signer.sendTransaction(tx);
|
|
4123
|
-
const _receipt = await signedTx.wait(confirmations);
|
|
4124
|
-
if (!_receipt) {
|
|
4125
|
-
return { ok: false, code: "RPC_ERROR", message: "Transaction receipt is null" };
|
|
4126
|
-
}
|
|
4127
|
-
return {
|
|
4128
|
-
ok: true,
|
|
4129
|
-
receipt: {
|
|
4130
|
-
txHash: _receipt.hash,
|
|
4131
|
-
blockNumber: _receipt.blockNumber,
|
|
4132
|
-
blockHash: _receipt.blockHash ?? null,
|
|
4133
|
-
status: _receipt.status ?? null,
|
|
4134
|
-
gasUsed: _receipt.gasUsed,
|
|
4135
|
-
effectiveGasPrice: _receipt.effectiveGasPrice ?? 0n,
|
|
4136
|
-
from: _receipt.from,
|
|
4137
|
-
to: _receipt.to ?? null,
|
|
4138
|
-
nonce: _receipt.nonce,
|
|
4139
|
-
logs: _receipt.logs.map((log) => ({
|
|
4140
|
-
address: log.address,
|
|
4141
|
-
topics: [...log.topics],
|
|
4142
|
-
data: log.data,
|
|
4143
|
-
blockNumber: log.blockNumber
|
|
4144
|
-
}))
|
|
4145
|
-
}
|
|
4146
|
-
};
|
|
4147
|
-
} catch (err) {
|
|
4148
|
-
const decoded = this.parseRevertError(err);
|
|
4149
|
-
return {
|
|
4150
|
-
ok: false,
|
|
4151
|
-
code: decoded.code,
|
|
4152
|
-
message: decoded.message,
|
|
4153
|
-
details: err,
|
|
4154
|
-
...decoded.selector ? { selector: decoded.selector } : {}
|
|
4155
|
-
};
|
|
4156
|
-
}
|
|
4157
|
-
}
|
|
4158
|
-
/**
|
|
4159
|
-
* Parse a revert error and extract { code, message, selector }.
|
|
4160
|
-
* selector is always included for unknown errors so users can report it.
|
|
4161
|
-
*/
|
|
4162
|
-
parseRevertError(err) {
|
|
4163
|
-
let rawSelector;
|
|
4164
|
-
if (err && typeof err === "object") {
|
|
4165
|
-
const errObj = err;
|
|
4166
|
-
const data = errObj.data;
|
|
4167
|
-
if (data && data !== "0x" && data.length >= 10) {
|
|
4168
|
-
rawSelector = data.slice(0, 10).toLowerCase();
|
|
4169
|
-
}
|
|
4170
|
-
}
|
|
4171
|
-
if (err && typeof err === "object") {
|
|
4172
|
-
const decoded = decodeError(err);
|
|
4173
|
-
if (decoded) {
|
|
4174
|
-
return { code: decoded.code, message: decoded.message, selector: rawSelector };
|
|
4175
|
-
}
|
|
4176
|
-
}
|
|
4177
|
-
if (!(err instanceof Error)) {
|
|
4178
|
-
return { code: "UNKNOWN", message: String(err), selector: rawSelector };
|
|
4179
|
-
}
|
|
4180
|
-
const msg = err.message;
|
|
4181
|
-
if (msg.includes("insufficient funds")) return { code: "INSUFFICIENT_BALANCE", message: "insufficient funds for gas", selector: rawSelector };
|
|
4182
|
-
if (msg.includes("nonce")) return { code: "RPC_ERROR", message: "nonce error (tx may already be mined)", selector: rawSelector };
|
|
4183
|
-
if (msg.includes("read-only")) return { code: "NO_SIGNER", message: "wallet is read-only", selector: rawSelector };
|
|
4184
|
-
return { code: "REVERT", message: msg.slice(0, 200), selector: rawSelector };
|
|
4185
|
-
}
|
|
4186
|
-
};
|
|
4187
3944
|
}
|
|
4188
3945
|
});
|
|
4189
3946
|
|
|
@@ -4929,10 +4686,10 @@ function resolveAddresses(env) {
|
|
|
4929
4686
|
beacon: env.ISOMETRY_BEACON_ADDRESS ?? DEFAULT_ADDRESSES.beacon
|
|
4930
4687
|
};
|
|
4931
4688
|
}
|
|
4932
|
-
function
|
|
4689
|
+
function createClient2(config2) {
|
|
4933
4690
|
return new IsometryClient(config2);
|
|
4934
4691
|
}
|
|
4935
|
-
var DEFAULT_ADDRESSES,
|
|
4692
|
+
var DEFAULT_ADDRESSES, SDK_VERSION2, IsometryClient;
|
|
4936
4693
|
var init_client2 = __esm({
|
|
4937
4694
|
"src/sdk/client.ts"() {
|
|
4938
4695
|
"use strict";
|
|
@@ -4947,7 +4704,7 @@ var init_client2 = __esm({
|
|
|
4947
4704
|
factory: "0x73D6BC64f4f54F9dF05851216F70F42135d56864",
|
|
4948
4705
|
beacon: "0x99d6512B5483DFA003F73F737f87e7DAE9482F89"
|
|
4949
4706
|
};
|
|
4950
|
-
|
|
4707
|
+
SDK_VERSION2 = "0.4.3";
|
|
4951
4708
|
IsometryClient = class {
|
|
4952
4709
|
rpc;
|
|
4953
4710
|
graph;
|
|
@@ -4956,11 +4713,11 @@ var init_client2 = __esm({
|
|
|
4956
4713
|
_addresses;
|
|
4957
4714
|
_chainId;
|
|
4958
4715
|
constructor(config2 = {}) {
|
|
4959
|
-
const rpcUrl = config2.rpcUrl ?? process.env.ISOMETRY_RPC_URL ?? "";
|
|
4716
|
+
const rpcUrl = config2.rpcUrl ?? process.env.ISOMETRY_RPC_URL ?? "https://ethereum-sepolia.publicnode.com";
|
|
4960
4717
|
const graphUrl = config2.graphUrl ?? process.env.ISOMETRY_GRAPH_URL ?? "https://console.isometry.network/graph/subgraphs/name/isometry";
|
|
4961
4718
|
const privateKey = config2.privateKey ?? process.env.ISOMETRY_PRIVATE_KEY;
|
|
4962
4719
|
this._chainId = config2.chainId ?? parseInt(process.env.ISOMETRY_CHAIN_ID ?? "11155111");
|
|
4963
|
-
this._wallet =
|
|
4720
|
+
this._wallet = createWallet2(rpcUrl, privateKey);
|
|
4964
4721
|
this._addresses = config2.addresses ?? resolveAddresses(process.env);
|
|
4965
4722
|
this.config = {
|
|
4966
4723
|
chainId: this._chainId,
|
|
@@ -5014,13 +4771,13 @@ __export(sdk_exports, {
|
|
|
5014
4771
|
PlatformRpcService: () => PlatformRpcService,
|
|
5015
4772
|
PrivateKeyWallet: () => PrivateKeyWallet,
|
|
5016
4773
|
ReadOnlyWallet: () => ReadOnlyWallet,
|
|
5017
|
-
SDK_VERSION: () =>
|
|
4774
|
+
SDK_VERSION: () => SDK_VERSION2,
|
|
5018
4775
|
StableCoinRpcService: () => StableCoinRpcService,
|
|
5019
4776
|
TokenHistoryService: () => TokenHistoryService,
|
|
5020
|
-
createClient: () =>
|
|
4777
|
+
createClient: () => createClient2,
|
|
5021
4778
|
createGraphClient: () => createGraphClient,
|
|
5022
|
-
createWallet: () =>
|
|
5023
|
-
getContracts: () =>
|
|
4779
|
+
createWallet: () => createWallet2,
|
|
4780
|
+
getContracts: () => getContracts2,
|
|
5024
4781
|
getStableCoin: () => getStableCoin
|
|
5025
4782
|
});
|
|
5026
4783
|
var init_sdk = __esm({
|
|
@@ -5035,26 +4792,14 @@ var init_sdk = __esm({
|
|
|
5035
4792
|
}
|
|
5036
4793
|
});
|
|
5037
4794
|
|
|
5038
|
-
// src/env.ts
|
|
5039
|
-
import { config } from "dotenv";
|
|
5040
|
-
import { resolve, dirname } from "path";
|
|
5041
|
-
import { fileURLToPath } from "url";
|
|
5042
|
-
function loadEnv() {
|
|
5043
|
-
config({ path: resolve(__dirname, "../.env") });
|
|
5044
|
-
}
|
|
5045
|
-
var __dirname;
|
|
5046
|
-
var init_env = __esm({
|
|
5047
|
-
"src/env.ts"() {
|
|
5048
|
-
"use strict";
|
|
5049
|
-
__dirname = dirname(fileURLToPath(import.meta.url));
|
|
5050
|
-
}
|
|
5051
|
-
});
|
|
5052
|
-
|
|
5053
4795
|
// src/cli/commands/system.ts
|
|
5054
4796
|
var system_exports = {};
|
|
5055
4797
|
__export(system_exports, {
|
|
5056
4798
|
registerSystem: () => registerSystem
|
|
5057
4799
|
});
|
|
4800
|
+
function jsonReplacer(_key, value) {
|
|
4801
|
+
return typeof value === "bigint" ? value.toString() : value;
|
|
4802
|
+
}
|
|
5058
4803
|
async function version(json) {
|
|
5059
4804
|
const data = {
|
|
5060
4805
|
cli: SDK_VERSION,
|
|
@@ -5062,7 +4807,7 @@ async function version(json) {
|
|
|
5062
4807
|
graphUrl: process.env.ISOMETRY_GRAPH_URL ?? "https://console.isometry.network/graph/subgraphs/name/isometry"
|
|
5063
4808
|
};
|
|
5064
4809
|
if (json) {
|
|
5065
|
-
console.log(JSON.stringify({ ok: true, data },
|
|
4810
|
+
console.log(JSON.stringify({ ok: true, data }, jsonReplacer, 2));
|
|
5066
4811
|
} else {
|
|
5067
4812
|
console.log(`isometry CLI v${SDK_VERSION}`);
|
|
5068
4813
|
console.log(`SDK v${SDK_VERSION}`);
|
|
@@ -5082,7 +4827,7 @@ async function status(json) {
|
|
|
5082
4827
|
}
|
|
5083
4828
|
const data = { subgraph: meta ? "connected" : "unreachable", meta, metaError };
|
|
5084
4829
|
if (json) {
|
|
5085
|
-
console.log(JSON.stringify({ ok: true, data },
|
|
4830
|
+
console.log(JSON.stringify({ ok: true, data }, jsonReplacer, 2));
|
|
5086
4831
|
} else {
|
|
5087
4832
|
if (meta) {
|
|
5088
4833
|
console.log(`Subgraph \u2705 connected`);
|
|
@@ -5101,160 +4846,8 @@ function registerSystem(parent) {
|
|
|
5101
4846
|
var init_system = __esm({
|
|
5102
4847
|
"src/cli/commands/system.ts"() {
|
|
5103
4848
|
"use strict";
|
|
5104
|
-
init_sdk();
|
|
5105
4849
|
init_env();
|
|
5106
|
-
|
|
5107
|
-
}
|
|
5108
|
-
});
|
|
5109
|
-
|
|
5110
|
-
// src/cli/commands/platformWrite.ts
|
|
5111
|
-
async function getPlatformExecutor() {
|
|
5112
|
-
const client = createClient();
|
|
5113
|
-
if (!client.config.privateKey) {
|
|
5114
|
-
return {
|
|
5115
|
-
error: "ISOMETRY_PRIVATE_KEY is not set \u2014 cannot sign transactions",
|
|
5116
|
-
code: "NO_SIGNER"
|
|
5117
|
-
};
|
|
5118
|
-
}
|
|
5119
|
-
const pk = client.config.privateKey;
|
|
5120
|
-
if (!/^0x[0-9a-fA-F]{64}$/.test(pk)) {
|
|
5121
|
-
return { error: "ISOMETRY_PRIVATE_KEY format invalid \u2014 must be 0x-prefixed 64-char hex", code: "INVALID_KEY" };
|
|
5122
|
-
}
|
|
5123
|
-
const wallet = createWallet(client.config.rpcUrl, pk);
|
|
5124
|
-
if (!wallet.signer) {
|
|
5125
|
-
return { error: "Wallet has no signer", code: "NO_SIGNER" };
|
|
5126
|
-
}
|
|
5127
|
-
const { getPlatform: getPlatform2 } = await Promise.resolve().then(() => (init_contracts(), contracts_exports));
|
|
5128
|
-
const platform = getPlatform2(wallet.signer, client.config.addresses);
|
|
5129
|
-
return new WriteExecutor({ wallet, contract: platform });
|
|
5130
|
-
}
|
|
5131
|
-
function outputError(code, message, json) {
|
|
5132
|
-
if (json) {
|
|
5133
|
-
console.log(JSON.stringify({ ok: false, code, message }, null, 2));
|
|
5134
|
-
} else {
|
|
5135
|
-
console.log(`\u274C [${code}] ${message}`);
|
|
5136
|
-
}
|
|
5137
|
-
}
|
|
5138
|
-
async function addPlatformAdmin(account, opts) {
|
|
5139
|
-
const result = await getPlatformExecutor();
|
|
5140
|
-
if (typeof result === "object" && "error" in result) {
|
|
5141
|
-
outputError(result.code, result.error, opts.json);
|
|
5142
|
-
return;
|
|
5143
|
-
}
|
|
5144
|
-
const executor = result;
|
|
5145
|
-
const memo = opts.memo || `Add platform admin via isometry CLI at ${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
5146
|
-
const writeResult = opts.simulate ? await executor.simulate({ method: "addPlatformAdmin", args: [account, memo] }) : await executor.execute({ method: "addPlatformAdmin", args: [account, memo] });
|
|
5147
|
-
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5148
|
-
}
|
|
5149
|
-
async function removePlatformAdmin(account, opts) {
|
|
5150
|
-
const result = await getPlatformExecutor();
|
|
5151
|
-
if (typeof result === "object" && "error" in result) {
|
|
5152
|
-
outputError(result.code, result.error, opts.json);
|
|
5153
|
-
return;
|
|
5154
|
-
}
|
|
5155
|
-
const executor = result;
|
|
5156
|
-
const memo = opts.memo || `Remove platform admin via isometry CLI at ${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
5157
|
-
const writeResult = opts.simulate ? await executor.simulate({ method: "removePlatformAdmin", args: [account, memo] }) : await executor.execute({ method: "removePlatformAdmin", args: [account, memo] });
|
|
5158
|
-
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5159
|
-
}
|
|
5160
|
-
async function addApprovedIssuer(account, opts) {
|
|
5161
|
-
const result = await getPlatformExecutor();
|
|
5162
|
-
if (typeof result === "object" && "error" in result) {
|
|
5163
|
-
outputError(result.code, result.error, opts.json);
|
|
5164
|
-
return;
|
|
5165
|
-
}
|
|
5166
|
-
const executor = result;
|
|
5167
|
-
const memo = opts.memo || `Add approved issuer via isometry CLI at ${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
5168
|
-
const writeResult = opts.simulate ? await executor.simulate({ method: "addApprovedIssuer", args: [account, memo] }) : await executor.execute({ method: "addApprovedIssuer", args: [account, memo] });
|
|
5169
|
-
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5170
|
-
}
|
|
5171
|
-
async function removeApprovedIssuer(account, opts) {
|
|
5172
|
-
const result = await getPlatformExecutor();
|
|
5173
|
-
if (typeof result === "object" && "error" in result) {
|
|
5174
|
-
outputError(result.code, result.error, opts.json);
|
|
5175
|
-
return;
|
|
5176
|
-
}
|
|
5177
|
-
const executor = result;
|
|
5178
|
-
const memo = opts.memo || `Remove approved issuer via isometry CLI at ${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
5179
|
-
const writeResult = opts.simulate ? await executor.simulate({ method: "removeApprovedIssuer", args: [account, memo] }) : await executor.execute({ method: "removeApprovedIssuer", args: [account, memo] });
|
|
5180
|
-
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5181
|
-
}
|
|
5182
|
-
async function addAccessUser(account, opts) {
|
|
5183
|
-
const result = await getPlatformExecutor();
|
|
5184
|
-
if (typeof result === "object" && "error" in result) {
|
|
5185
|
-
outputError(result.code, result.error, opts.json);
|
|
5186
|
-
return;
|
|
5187
|
-
}
|
|
5188
|
-
const executor = result;
|
|
5189
|
-
const memo = opts.memo || `Add access user via isometry CLI at ${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
5190
|
-
const writeResult = opts.simulate ? await executor.simulate({ method: "addAccessUser", args: [account, memo] }) : await executor.execute({ method: "addAccessUser", args: [account, memo] });
|
|
5191
|
-
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5192
|
-
}
|
|
5193
|
-
async function removeAccessUser(account, opts) {
|
|
5194
|
-
const result = await getPlatformExecutor();
|
|
5195
|
-
if (typeof result === "object" && "error" in result) {
|
|
5196
|
-
outputError(result.code, result.error, opts.json);
|
|
5197
|
-
return;
|
|
5198
|
-
}
|
|
5199
|
-
const executor = result;
|
|
5200
|
-
const memo = opts.memo || `Remove access user via isometry CLI at ${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
5201
|
-
const writeResult = opts.simulate ? await executor.simulate({ method: "removeAccessUser", args: [account, memo] }) : await executor.execute({ method: "removeAccessUser", args: [account, memo] });
|
|
5202
|
-
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5203
|
-
}
|
|
5204
|
-
function registerPlatformWrite(platformCmd) {
|
|
5205
|
-
const admin = platformCmd.command("admin").description("Platform admin management");
|
|
5206
|
-
admin.command("add <account>").description("Add platform admin (requires PLATFORM_ADMIN_ROLE)").option("--simulate", "Simulate without signing").option("--json", "Output as JSON").option("--memo <text>", "Transaction memo", "").action(
|
|
5207
|
-
(account, opts) => addPlatformAdmin(account, {
|
|
5208
|
-
simulate: opts.simulate ?? false,
|
|
5209
|
-
json: opts.json ?? false,
|
|
5210
|
-
memo: opts.memo ?? ""
|
|
5211
|
-
})
|
|
5212
|
-
);
|
|
5213
|
-
admin.command("remove <account>").description("Remove platform admin (requires PLATFORM_ADMIN_ROLE)").option("--simulate", "Simulate without signing").option("--json", "Output as JSON").option("--memo <text>", "Transaction memo", "").action(
|
|
5214
|
-
(account, opts) => removePlatformAdmin(account, {
|
|
5215
|
-
simulate: opts.simulate ?? false,
|
|
5216
|
-
json: opts.json ?? false,
|
|
5217
|
-
memo: opts.memo ?? ""
|
|
5218
|
-
})
|
|
5219
|
-
);
|
|
5220
|
-
const issuer = platformCmd.command("issuer").description("Approved issuer management");
|
|
5221
|
-
issuer.command("add <account>").description("Add approved issuer (requires PLATFORM_ADMIN_ROLE)").option("--simulate", "Simulate without signing").option("--json", "Output as JSON").option("--memo <text>", "Transaction memo", "").action(
|
|
5222
|
-
(account, opts) => addApprovedIssuer(account, {
|
|
5223
|
-
simulate: opts.simulate ?? false,
|
|
5224
|
-
json: opts.json ?? false,
|
|
5225
|
-
memo: opts.memo ?? ""
|
|
5226
|
-
})
|
|
5227
|
-
);
|
|
5228
|
-
issuer.command("remove <account>").description("Remove approved issuer (requires PLATFORM_ADMIN_ROLE)").option("--simulate", "Simulate without signing").option("--json", "Output as JSON").option("--memo <text>", "Transaction memo", "").action(
|
|
5229
|
-
(account, opts) => removeApprovedIssuer(account, {
|
|
5230
|
-
simulate: opts.simulate ?? false,
|
|
5231
|
-
json: opts.json ?? false,
|
|
5232
|
-
memo: opts.memo ?? ""
|
|
5233
|
-
})
|
|
5234
|
-
);
|
|
5235
|
-
const access = platformCmd.command("access").description("Access user management");
|
|
5236
|
-
access.command("add <account>").description("Add access user (requires PLATFORM_ADMIN_ROLE)").option("--simulate", "Simulate without signing").option("--json", "Output as JSON").option("--memo <text>", "Transaction memo", "").action(
|
|
5237
|
-
(account, opts) => addAccessUser(account, {
|
|
5238
|
-
simulate: opts.simulate ?? false,
|
|
5239
|
-
json: opts.json ?? false,
|
|
5240
|
-
memo: opts.memo ?? ""
|
|
5241
|
-
})
|
|
5242
|
-
);
|
|
5243
|
-
access.command("remove <account>").description("Remove access user (requires PLATFORM_ADMIN_ROLE)").option("--simulate", "Simulate without signing").option("--json", "Output as JSON").option("--memo <text>", "Transaction memo", "").action(
|
|
5244
|
-
(account, opts) => removeAccessUser(account, {
|
|
5245
|
-
simulate: opts.simulate ?? false,
|
|
5246
|
-
json: opts.json ?? false,
|
|
5247
|
-
memo: opts.memo ?? ""
|
|
5248
|
-
})
|
|
5249
|
-
);
|
|
5250
|
-
}
|
|
5251
|
-
var init_platformWrite = __esm({
|
|
5252
|
-
"src/cli/commands/platformWrite.ts"() {
|
|
5253
|
-
"use strict";
|
|
5254
|
-
init_env();
|
|
5255
|
-
init_sdk();
|
|
5256
|
-
init_writeExecutor();
|
|
5257
|
-
loadEnv();
|
|
4850
|
+
loadEnv2();
|
|
5258
4851
|
}
|
|
5259
4852
|
});
|
|
5260
4853
|
|
|
@@ -5263,6 +4856,9 @@ var platform_exports = {};
|
|
|
5263
4856
|
__export(platform_exports, {
|
|
5264
4857
|
registerPlatform: () => registerPlatform
|
|
5265
4858
|
});
|
|
4859
|
+
function jsonReplacer2(_key, value) {
|
|
4860
|
+
return typeof value === "bigint" ? value.toString() : value;
|
|
4861
|
+
}
|
|
5266
4862
|
async function info(json) {
|
|
5267
4863
|
const client = createClient();
|
|
5268
4864
|
const [platformInfo, graphAdmins, graphIssuers, graphAccessUsers] = await Promise.all([
|
|
@@ -5293,7 +4889,7 @@ async function info(json) {
|
|
|
5293
4889
|
}))
|
|
5294
4890
|
};
|
|
5295
4891
|
if (json) {
|
|
5296
|
-
console.log(JSON.stringify({ ok: true, data },
|
|
4892
|
+
console.log(JSON.stringify({ ok: true, data }, jsonReplacer2, 2));
|
|
5297
4893
|
} else {
|
|
5298
4894
|
console.log(`Platform Paused ${data.paused ? "YES \u274C" : "No \u2705"}`);
|
|
5299
4895
|
console.log(`Token Count ${data.tokenCount}`);
|
|
@@ -5310,7 +4906,7 @@ async function tokens(json) {
|
|
|
5310
4906
|
const client = createClient();
|
|
5311
4907
|
const tokenAddrs = await client.rpc.platform.getAllTokens();
|
|
5312
4908
|
if (json) {
|
|
5313
|
-
console.log(JSON.stringify({ ok: true, data: { tokens: tokenAddrs } },
|
|
4909
|
+
console.log(JSON.stringify({ ok: true, data: { tokens: tokenAddrs } }, jsonReplacer2, 2));
|
|
5314
4910
|
} else {
|
|
5315
4911
|
console.log(`Registered tokens: ${tokenAddrs.length}`);
|
|
5316
4912
|
tokenAddrs.forEach((a) => console.log(` ${a}`));
|
|
@@ -5326,13 +4922,14 @@ var init_platform2 = __esm({
|
|
|
5326
4922
|
"src/cli/commands/platform.ts"() {
|
|
5327
4923
|
"use strict";
|
|
5328
4924
|
init_env();
|
|
5329
|
-
|
|
5330
|
-
init_platformWrite();
|
|
5331
|
-
loadEnv();
|
|
4925
|
+
loadEnv2();
|
|
5332
4926
|
}
|
|
5333
4927
|
});
|
|
5334
4928
|
|
|
5335
4929
|
// src/cli/commands/tokenWrite.ts
|
|
4930
|
+
function jsonReplacer3(_key, value) {
|
|
4931
|
+
return typeof value === "bigint" ? value.toString() : value;
|
|
4932
|
+
}
|
|
5336
4933
|
async function getTokenExecutor(tokenAddress) {
|
|
5337
4934
|
if (!tokenAddress) {
|
|
5338
4935
|
return { error: "Token address is required", code: "INVALID_ARGUMENT" };
|
|
@@ -5357,9 +4954,9 @@ async function getTokenExecutor(tokenAddress) {
|
|
|
5357
4954
|
const executor = new WriteExecutor({ wallet, contract: tokenContract });
|
|
5358
4955
|
return { executor };
|
|
5359
4956
|
}
|
|
5360
|
-
function
|
|
4957
|
+
function outputError(code, message, json) {
|
|
5361
4958
|
if (json) {
|
|
5362
|
-
console.log(JSON.stringify({ ok: false, code, message },
|
|
4959
|
+
console.log(JSON.stringify({ ok: false, code, message }, jsonReplacer3, 2));
|
|
5363
4960
|
} else {
|
|
5364
4961
|
console.log(`\u274C [${code}] ${message}`);
|
|
5365
4962
|
}
|
|
@@ -5372,7 +4969,7 @@ async function tokenMint(tokenAddress, to, amount, opts) {
|
|
|
5372
4969
|
const writeResult = opts.simulate ? await executor.simulate({ method: "mint", args: [to, BigInt(amount), memo] }) : await executor.execute({ method: "mint", args: [to, BigInt(amount), memo] });
|
|
5373
4970
|
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5374
4971
|
} else {
|
|
5375
|
-
|
|
4972
|
+
outputError(result.code, result.error, opts.json);
|
|
5376
4973
|
}
|
|
5377
4974
|
}
|
|
5378
4975
|
async function tokenBurn(tokenAddress, amount, opts) {
|
|
@@ -5383,7 +4980,7 @@ async function tokenBurn(tokenAddress, amount, opts) {
|
|
|
5383
4980
|
const writeResult = opts.simulate ? await executor.simulate({ method: "burn", args: [BigInt(amount), memo] }) : await executor.execute({ method: "burn", args: [BigInt(amount), memo] });
|
|
5384
4981
|
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5385
4982
|
} else {
|
|
5386
|
-
|
|
4983
|
+
outputError(result.code, result.error, opts.json);
|
|
5387
4984
|
}
|
|
5388
4985
|
}
|
|
5389
4986
|
async function tokenPause(tokenAddress, opts) {
|
|
@@ -5394,7 +4991,7 @@ async function tokenPause(tokenAddress, opts) {
|
|
|
5394
4991
|
const writeResult = opts.simulate ? await executor.simulate({ method: "pause", args: [memo] }) : await executor.execute({ method: "pause", args: [memo] });
|
|
5395
4992
|
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5396
4993
|
} else {
|
|
5397
|
-
|
|
4994
|
+
outputError(result.code, result.error, opts.json);
|
|
5398
4995
|
}
|
|
5399
4996
|
}
|
|
5400
4997
|
async function tokenUnpause(tokenAddress, opts) {
|
|
@@ -5405,7 +5002,7 @@ async function tokenUnpause(tokenAddress, opts) {
|
|
|
5405
5002
|
const writeResult = opts.simulate ? await executor.simulate({ method: "unpause", args: [memo] }) : await executor.execute({ method: "unpause", args: [memo] });
|
|
5406
5003
|
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5407
5004
|
} else {
|
|
5408
|
-
|
|
5005
|
+
outputError(result.code, result.error, opts.json);
|
|
5409
5006
|
}
|
|
5410
5007
|
}
|
|
5411
5008
|
async function blacklistAdd(tokenAddress, user, opts) {
|
|
@@ -5416,7 +5013,7 @@ async function blacklistAdd(tokenAddress, user, opts) {
|
|
|
5416
5013
|
const writeResult = opts.simulate ? await executor.simulate({ method: "blacklist", args: [user, memo] }) : await executor.execute({ method: "blacklist", args: [user, memo] });
|
|
5417
5014
|
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5418
5015
|
} else {
|
|
5419
|
-
|
|
5016
|
+
outputError(result.code, result.error, opts.json);
|
|
5420
5017
|
}
|
|
5421
5018
|
}
|
|
5422
5019
|
async function blacklistRemove(tokenAddress, user, opts) {
|
|
@@ -5427,7 +5024,7 @@ async function blacklistRemove(tokenAddress, user, opts) {
|
|
|
5427
5024
|
const writeResult = opts.simulate ? await executor.simulate({ method: "unBlacklist", args: [user, memo] }) : await executor.execute({ method: "unBlacklist", args: [user, memo] });
|
|
5428
5025
|
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5429
5026
|
} else {
|
|
5430
|
-
|
|
5027
|
+
outputError(result.code, result.error, opts.json);
|
|
5431
5028
|
}
|
|
5432
5029
|
}
|
|
5433
5030
|
async function addBlacklistManager(tokenAddress, account, opts) {
|
|
@@ -5438,7 +5035,7 @@ async function addBlacklistManager(tokenAddress, account, opts) {
|
|
|
5438
5035
|
const writeResult = opts.simulate ? await executor.simulate({ method: "addBlacklistManager", args: [account, memo] }) : await executor.execute({ method: "addBlacklistManager", args: [account, memo] });
|
|
5439
5036
|
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5440
5037
|
} else {
|
|
5441
|
-
|
|
5038
|
+
outputError(result.code, result.error, opts.json);
|
|
5442
5039
|
}
|
|
5443
5040
|
}
|
|
5444
5041
|
async function removeBlacklistManager(tokenAddress, account, opts) {
|
|
@@ -5449,7 +5046,7 @@ async function removeBlacklistManager(tokenAddress, account, opts) {
|
|
|
5449
5046
|
const writeResult = opts.simulate ? await executor.simulate({ method: "removeBlacklistManager", args: [account, memo] }) : await executor.execute({ method: "removeBlacklistManager", args: [account, memo] });
|
|
5450
5047
|
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5451
5048
|
} else {
|
|
5452
|
-
|
|
5049
|
+
outputError(result.code, result.error, opts.json);
|
|
5453
5050
|
}
|
|
5454
5051
|
}
|
|
5455
5052
|
async function addMinter(tokenAddress, minter, allowance, opts) {
|
|
@@ -5460,7 +5057,7 @@ async function addMinter(tokenAddress, minter, allowance, opts) {
|
|
|
5460
5057
|
const writeResult = opts.simulate ? await executor.simulate({ method: "addMinter", args: [minter, BigInt(allowance), memo] }) : await executor.execute({ method: "addMinter", args: [minter, BigInt(allowance), memo] });
|
|
5461
5058
|
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5462
5059
|
} else {
|
|
5463
|
-
|
|
5060
|
+
outputError(result.code, result.error, opts.json);
|
|
5464
5061
|
}
|
|
5465
5062
|
}
|
|
5466
5063
|
async function removeMinter(tokenAddress, minter, opts) {
|
|
@@ -5471,7 +5068,7 @@ async function removeMinter(tokenAddress, minter, opts) {
|
|
|
5471
5068
|
const writeResult = opts.simulate ? await executor.simulate({ method: "removeMinter", args: [minter, memo] }) : await executor.execute({ method: "removeMinter", args: [minter, memo] });
|
|
5472
5069
|
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5473
5070
|
} else {
|
|
5474
|
-
|
|
5071
|
+
outputError(result.code, result.error, opts.json);
|
|
5475
5072
|
}
|
|
5476
5073
|
}
|
|
5477
5074
|
function registerTokenWrite(token) {
|
|
@@ -5552,9 +5149,6 @@ function registerTokenWrite(token) {
|
|
|
5552
5149
|
var init_tokenWrite = __esm({
|
|
5553
5150
|
"src/cli/commands/tokenWrite.ts"() {
|
|
5554
5151
|
"use strict";
|
|
5555
|
-
init_env();
|
|
5556
|
-
init_sdk();
|
|
5557
|
-
init_writeExecutor();
|
|
5558
5152
|
loadEnv();
|
|
5559
5153
|
}
|
|
5560
5154
|
});
|
|
@@ -5567,8 +5161,11 @@ __export(token_exports, {
|
|
|
5567
5161
|
function formatBigInt(v) {
|
|
5568
5162
|
return v.toString();
|
|
5569
5163
|
}
|
|
5164
|
+
function jsonReplacer4(_key, value) {
|
|
5165
|
+
return typeof value === "bigint" ? value.toString() : value;
|
|
5166
|
+
}
|
|
5570
5167
|
async function tokenInfo(addr, json) {
|
|
5571
|
-
const client =
|
|
5168
|
+
const client = createClient2();
|
|
5572
5169
|
const [info2, stats] = await Promise.all([
|
|
5573
5170
|
client.rpc.token.getTokenInfo(addr),
|
|
5574
5171
|
client.rpc.token.getTokenStats(addr)
|
|
@@ -5588,7 +5185,7 @@ async function tokenInfo(addr, json) {
|
|
|
5588
5185
|
blacklistCount: parseBigIntToNumber(stats.blacklistCount.toString())
|
|
5589
5186
|
};
|
|
5590
5187
|
if (json) {
|
|
5591
|
-
console.log(JSON.stringify({ ok: true, data },
|
|
5188
|
+
console.log(JSON.stringify({ ok: true, data }, jsonReplacer4, 2));
|
|
5592
5189
|
} else {
|
|
5593
5190
|
console.log(`Address ${data.address}`);
|
|
5594
5191
|
console.log(`Name ${data.name}`);
|
|
@@ -5604,7 +5201,7 @@ async function tokenInfo(addr, json) {
|
|
|
5604
5201
|
}
|
|
5605
5202
|
}
|
|
5606
5203
|
async function tokenStats(addr, json) {
|
|
5607
|
-
const client =
|
|
5204
|
+
const client = createClient2();
|
|
5608
5205
|
const stats = await client.rpc.token.getTokenStats(addr);
|
|
5609
5206
|
const net = BigInt(stats.totalMinted) - BigInt(stats.totalBurned);
|
|
5610
5207
|
const data = {
|
|
@@ -5618,7 +5215,7 @@ async function tokenStats(addr, json) {
|
|
|
5618
5215
|
blacklistCount: parseBigIntToNumber(stats.blacklistCount.toString())
|
|
5619
5216
|
};
|
|
5620
5217
|
if (json) {
|
|
5621
|
-
console.log(JSON.stringify({ ok: true, data },
|
|
5218
|
+
console.log(JSON.stringify({ ok: true, data }, jsonReplacer4, 2));
|
|
5622
5219
|
} else {
|
|
5623
5220
|
console.log(`Address ${data.address}`);
|
|
5624
5221
|
console.log(`Holders ${data.holdersTotal}`);
|
|
@@ -5631,7 +5228,7 @@ async function tokenStats(addr, json) {
|
|
|
5631
5228
|
}
|
|
5632
5229
|
}
|
|
5633
5230
|
async function tokenRoles(addr, account, json) {
|
|
5634
|
-
const client =
|
|
5231
|
+
const client = createClient2();
|
|
5635
5232
|
const roles = await client.rpc.token.getUserRoles(addr, account);
|
|
5636
5233
|
const data = {
|
|
5637
5234
|
token: roles.address,
|
|
@@ -5643,7 +5240,7 @@ async function tokenRoles(addr, account, json) {
|
|
|
5643
5240
|
isMasterStatus: roles.isMasterStatus
|
|
5644
5241
|
};
|
|
5645
5242
|
if (json) {
|
|
5646
|
-
console.log(JSON.stringify({ ok: true, data },
|
|
5243
|
+
console.log(JSON.stringify({ ok: true, data }, jsonReplacer4, 2));
|
|
5647
5244
|
} else {
|
|
5648
5245
|
console.log(`Token ${data.token}`);
|
|
5649
5246
|
console.log(`Account ${data.account}`);
|
|
@@ -5655,7 +5252,7 @@ async function tokenRoles(addr, account, json) {
|
|
|
5655
5252
|
}
|
|
5656
5253
|
}
|
|
5657
5254
|
async function tokenHistory(addr, first, json) {
|
|
5658
|
-
const client =
|
|
5255
|
+
const client = createClient2();
|
|
5659
5256
|
const [mints, burns] = await Promise.all([
|
|
5660
5257
|
client.graph.token.getMintHistory(addr, first, 0),
|
|
5661
5258
|
client.graph.token.getBurnHistory(addr, first, 0)
|
|
@@ -5678,7 +5275,7 @@ async function tokenHistory(addr, first, json) {
|
|
|
5678
5275
|
];
|
|
5679
5276
|
events.sort((a, b) => BigInt(a.block) > BigInt(b.block) ? -1 : 1);
|
|
5680
5277
|
if (json) {
|
|
5681
|
-
console.log(JSON.stringify({ ok: true, data: { events } },
|
|
5278
|
+
console.log(JSON.stringify({ ok: true, data: { events } }, jsonReplacer4, 2));
|
|
5682
5279
|
} else {
|
|
5683
5280
|
console.log(`Token ${addr}`);
|
|
5684
5281
|
console.log(`Mint events ${mints.length} Burn events ${burns.length}`);
|
|
@@ -5688,10 +5285,10 @@ async function tokenHistory(addr, first, json) {
|
|
|
5688
5285
|
}
|
|
5689
5286
|
}
|
|
5690
5287
|
async function tokenMintHistory(addr, first, json) {
|
|
5691
|
-
const client =
|
|
5288
|
+
const client = createClient2();
|
|
5692
5289
|
const events = await client.graph.token.getMintHistory(addr, first, 0);
|
|
5693
5290
|
if (json) {
|
|
5694
|
-
console.log(JSON.stringify({ ok: true, data: { events } },
|
|
5291
|
+
console.log(JSON.stringify({ ok: true, data: { events } }, jsonReplacer4, 2));
|
|
5695
5292
|
} else {
|
|
5696
5293
|
console.log(`Token ${addr} \u2014 Mint History (${events.length} events)`);
|
|
5697
5294
|
events.slice(0, 10).forEach((e) => {
|
|
@@ -5700,10 +5297,10 @@ async function tokenMintHistory(addr, first, json) {
|
|
|
5700
5297
|
}
|
|
5701
5298
|
}
|
|
5702
5299
|
async function tokenBurnHistory(addr, first, json) {
|
|
5703
|
-
const client =
|
|
5300
|
+
const client = createClient2();
|
|
5704
5301
|
const events = await client.graph.token.getBurnHistory(addr, first, 0);
|
|
5705
5302
|
if (json) {
|
|
5706
|
-
console.log(JSON.stringify({ ok: true, data: { events } },
|
|
5303
|
+
console.log(JSON.stringify({ ok: true, data: { events } }, jsonReplacer4, 2));
|
|
5707
5304
|
} else {
|
|
5708
5305
|
console.log(`Token ${addr} \u2014 Burn History (${events.length} events)`);
|
|
5709
5306
|
events.slice(0, 10).forEach((e) => {
|
|
@@ -5712,7 +5309,7 @@ async function tokenBurnHistory(addr, first, json) {
|
|
|
5712
5309
|
}
|
|
5713
5310
|
}
|
|
5714
5311
|
async function tokenPauseHistory(addr, first, json) {
|
|
5715
|
-
const client =
|
|
5312
|
+
const client = createClient2();
|
|
5716
5313
|
const [pauseEvts, pausedEvts, unpausedEvts] = await Promise.all([
|
|
5717
5314
|
client.graph.token.getPauseHistory(addr, first, 0),
|
|
5718
5315
|
client.graph.token.getPausedByOwnerHistory(addr, first, 0),
|
|
@@ -5756,7 +5353,7 @@ var init_token = __esm({
|
|
|
5756
5353
|
init_sdk();
|
|
5757
5354
|
init_analytics();
|
|
5758
5355
|
init_tokenWrite();
|
|
5759
|
-
|
|
5356
|
+
loadEnv2();
|
|
5760
5357
|
}
|
|
5761
5358
|
});
|
|
5762
5359
|
|
|
@@ -5765,6 +5362,9 @@ var factory_exports = {};
|
|
|
5765
5362
|
__export(factory_exports, {
|
|
5766
5363
|
registerFactory: () => registerFactory
|
|
5767
5364
|
});
|
|
5365
|
+
function jsonReplacer5(_key, value) {
|
|
5366
|
+
return typeof value === "bigint" ? value.toString() : value;
|
|
5367
|
+
}
|
|
5768
5368
|
async function factoryInfo(json) {
|
|
5769
5369
|
const client = createClient();
|
|
5770
5370
|
const [beacon, platformAddr] = await Promise.all([
|
|
@@ -5778,7 +5378,7 @@ async function factoryInfo(json) {
|
|
|
5778
5378
|
chainId: client.config.chainId
|
|
5779
5379
|
};
|
|
5780
5380
|
if (json) {
|
|
5781
|
-
console.log(JSON.stringify({ ok: true, data },
|
|
5381
|
+
console.log(JSON.stringify({ ok: true, data }, jsonReplacer5, 2));
|
|
5782
5382
|
} else {
|
|
5783
5383
|
console.log(`Beacon ${data.beacon}`);
|
|
5784
5384
|
console.log(`Platform ${data.platform}`);
|
|
@@ -5791,18 +5391,18 @@ async function factoryCreate(name, symbol, opts) {
|
|
|
5791
5391
|
const client = createClient();
|
|
5792
5392
|
if (!client.config.addresses.factory) {
|
|
5793
5393
|
const msg = "ISOMETRY_FACTORY_ADDRESS is not configured";
|
|
5794
|
-
console.log(opts.json ? JSON.stringify({ ok: false, code: "NOT_CONFIGURED", message: msg },
|
|
5394
|
+
console.log(opts.json ? JSON.stringify({ ok: false, code: "NOT_CONFIGURED", message: msg }, jsonReplacer5, 2) : `\u274C ${msg}`);
|
|
5795
5395
|
return;
|
|
5796
5396
|
}
|
|
5797
5397
|
if (!client.config.privateKey) {
|
|
5798
5398
|
const msg = "ISOMETRY_PRIVATE_KEY is not set \u2014 cannot sign transactions";
|
|
5799
|
-
console.log(opts.json ? JSON.stringify({ ok: false, code: "NO_SIGNER", message: msg },
|
|
5399
|
+
console.log(opts.json ? JSON.stringify({ ok: false, code: "NO_SIGNER", message: msg }, jsonReplacer5, 2) : `\u274C ${msg}`);
|
|
5800
5400
|
return;
|
|
5801
5401
|
}
|
|
5802
5402
|
const wallet = createWallet(client.config.rpcUrl, client.config.privateKey);
|
|
5803
5403
|
if (!wallet.signer) {
|
|
5804
5404
|
const msg = "Wallet has no signer \u2014 check ISOMETRY_PRIVATE_KEY";
|
|
5805
|
-
console.log(opts.json ? JSON.stringify({ ok: false, code: "NO_SIGNER", message: msg },
|
|
5405
|
+
console.log(opts.json ? JSON.stringify({ ok: false, code: "NO_SIGNER", message: msg }, jsonReplacer5, 2) : `\u274C ${msg}`);
|
|
5806
5406
|
return;
|
|
5807
5407
|
}
|
|
5808
5408
|
const contracts = getContracts(client.config.addresses, wallet.signer);
|
|
@@ -5833,9 +5433,7 @@ var init_factory2 = __esm({
|
|
|
5833
5433
|
"src/cli/commands/factory.ts"() {
|
|
5834
5434
|
"use strict";
|
|
5835
5435
|
init_env();
|
|
5836
|
-
|
|
5837
|
-
init_writeExecutor();
|
|
5838
|
-
loadEnv();
|
|
5436
|
+
loadEnv2();
|
|
5839
5437
|
}
|
|
5840
5438
|
});
|
|
5841
5439
|
|