@bigmaxwatermelon/sdk 0.4.5 → 0.4.6
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 +497 -63
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- 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 loadEnv() {
|
|
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 createWallet(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: () => getContracts,
|
|
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 getContracts(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 = getContracts(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 } = getContracts(this.addresses, this.runner);
|
|
3829
3844
|
return factory.beacon();
|
|
3830
3845
|
}
|
|
3831
3846
|
async getPlatformAddress() {
|
|
3832
|
-
const { factory } =
|
|
3847
|
+
const { factory } = getContracts(this.addresses, this.runner);
|
|
3833
3848
|
return factory.platform();
|
|
3834
3849
|
}
|
|
3835
3850
|
};
|
|
@@ -3915,17 +3930,275 @@ var init_stablecoin = __esm({
|
|
|
3915
3930
|
});
|
|
3916
3931
|
|
|
3917
3932
|
// src/sdk/rpc/errorMap.ts
|
|
3933
|
+
function decodeError(details) {
|
|
3934
|
+
if (details.data && details.data !== "0x") {
|
|
3935
|
+
const selector = details.data.slice(0, 10).toLowerCase();
|
|
3936
|
+
const mapped = ERROR_SELECTOR_MAP[selector];
|
|
3937
|
+
if (mapped) return mapped;
|
|
3938
|
+
}
|
|
3939
|
+
if (details.reason) {
|
|
3940
|
+
const reason = details.reason;
|
|
3941
|
+
if (reason === "Not authorized" || reason === "Not approved issuer") {
|
|
3942
|
+
return { code: "ACCESS_DENIED", message: reason };
|
|
3943
|
+
}
|
|
3944
|
+
return { code: "REVERT", message: reason };
|
|
3945
|
+
}
|
|
3946
|
+
if (details.revert?.args) {
|
|
3947
|
+
const name = details.revert.name ?? details.revert.signature ?? "";
|
|
3948
|
+
if (name.includes("AccessControl")) {
|
|
3949
|
+
const [account, role] = details.revert.args;
|
|
3950
|
+
return {
|
|
3951
|
+
code: "ACCESS_DENIED",
|
|
3952
|
+
message: `AccessControl: account ${account} missing role ${role}`
|
|
3953
|
+
};
|
|
3954
|
+
}
|
|
3955
|
+
}
|
|
3956
|
+
return null;
|
|
3957
|
+
}
|
|
3958
|
+
var ERROR_SELECTOR_MAP;
|
|
3918
3959
|
var init_errorMap = __esm({
|
|
3919
3960
|
"src/sdk/rpc/errorMap.ts"() {
|
|
3920
3961
|
"use strict";
|
|
3962
|
+
ERROR_SELECTOR_MAP = {
|
|
3963
|
+
// OpenZeppelin AccessControlUnauthorizedAccount(address account, bytes32 role)
|
|
3964
|
+
// keccak256("AccessControlUnauthorizedAccount(address,bytes32)") = 0x761f22a3
|
|
3965
|
+
// ethers v6 surfaces this as 0xe2517d3f in CALL_EXCEPTION details
|
|
3966
|
+
"0xe2517d3f": {
|
|
3967
|
+
code: "ACCESS_DENIED",
|
|
3968
|
+
message: "AccessControl: missing required role"
|
|
3969
|
+
},
|
|
3970
|
+
"0x761f22a3": {
|
|
3971
|
+
code: "ACCESS_DENIED",
|
|
3972
|
+
message: "AccessControl: missing required role"
|
|
3973
|
+
},
|
|
3974
|
+
// OpenZeppelin AccessControl: account is missing role
|
|
3975
|
+
"0x4e6f6c52": {
|
|
3976
|
+
code: "ACCESS_DENIED",
|
|
3977
|
+
message: "AccessControl: account is missing role"
|
|
3978
|
+
},
|
|
3979
|
+
// ERC20: insufficient balance
|
|
3980
|
+
"0x13be252b": {
|
|
3981
|
+
code: "INSUFFICIENT_BALANCE",
|
|
3982
|
+
message: "ERC20: transfer amount exceeds balance"
|
|
3983
|
+
},
|
|
3984
|
+
// ERC20: insufficient allowance
|
|
3985
|
+
"0xf4d708f0": {
|
|
3986
|
+
code: "INSUFFICIENT_ALLOWANCE",
|
|
3987
|
+
message: "ERC20: insufficient allowance"
|
|
3988
|
+
},
|
|
3989
|
+
// Pausable: paused
|
|
3990
|
+
"0x8d1c0a00": {
|
|
3991
|
+
code: "PAUSED",
|
|
3992
|
+
message: "Pausable: paused"
|
|
3993
|
+
},
|
|
3994
|
+
// ERC20: invalid sender
|
|
3995
|
+
"0xdf24fd05": {
|
|
3996
|
+
code: "INVALID_SENDER",
|
|
3997
|
+
message: "ERC20: invalid sender"
|
|
3998
|
+
},
|
|
3999
|
+
// ERC20: blacklisted
|
|
4000
|
+
"0x12d1b5d1": {
|
|
4001
|
+
code: "BLACKLISTED",
|
|
4002
|
+
message: "ERC20: sender is blacklisted"
|
|
4003
|
+
},
|
|
4004
|
+
// Isometry platform / factory custom errors (observed)
|
|
4005
|
+
"0x1e55aece": {
|
|
4006
|
+
code: "NOT_APPROVED_ISSUER",
|
|
4007
|
+
message: "Not an approved issuer"
|
|
4008
|
+
},
|
|
4009
|
+
"0xf2d4620b": {
|
|
4010
|
+
code: "FACTORY_SYMBOL_EXISTS",
|
|
4011
|
+
message: "Factory: symbol already exists"
|
|
4012
|
+
},
|
|
4013
|
+
"0x3b800a46": {
|
|
4014
|
+
code: "ZERO_ADDRESS",
|
|
4015
|
+
message: "Address cannot be zero"
|
|
4016
|
+
}
|
|
4017
|
+
};
|
|
3921
4018
|
}
|
|
3922
4019
|
});
|
|
3923
4020
|
|
|
3924
4021
|
// src/sdk/rpc/writeExecutor.ts
|
|
4022
|
+
function makeWriteMeta(command) {
|
|
4023
|
+
return {
|
|
4024
|
+
chainId: 11155111,
|
|
4025
|
+
source: "rpc",
|
|
4026
|
+
timestamp: Math.floor(Date.now() / 1e3),
|
|
4027
|
+
...command ? { command } : {}
|
|
4028
|
+
};
|
|
4029
|
+
}
|
|
4030
|
+
function formatWriteResult(result, opts, meta) {
|
|
4031
|
+
if (opts.json) {
|
|
4032
|
+
const out = { ok: result.ok };
|
|
4033
|
+
if (result.ok) {
|
|
4034
|
+
if (opts.simulate) {
|
|
4035
|
+
const r2 = result;
|
|
4036
|
+
Object.assign(out, { estimatedGas: r2.estimatedGas, functionFragment: r2.functionFragment, params: r2.params });
|
|
4037
|
+
} else {
|
|
4038
|
+
const r2 = result;
|
|
4039
|
+
Object.assign(out, { receipt: r2.receipt });
|
|
4040
|
+
}
|
|
4041
|
+
} else {
|
|
4042
|
+
const r2 = result;
|
|
4043
|
+
Object.assign(out, { code: r2.code, message: r2.message });
|
|
4044
|
+
if (r2.selector) Object.assign(out, { selector: r2.selector });
|
|
4045
|
+
}
|
|
4046
|
+
if (meta) Object.assign(out, { meta });
|
|
4047
|
+
return JSON.stringify(
|
|
4048
|
+
out,
|
|
4049
|
+
(_key, value) => typeof value === "bigint" ? value.toString() : value,
|
|
4050
|
+
2
|
|
4051
|
+
);
|
|
4052
|
+
}
|
|
4053
|
+
if (!result.ok) {
|
|
4054
|
+
return `\u274C [${result.code}] ${result.message}`;
|
|
4055
|
+
}
|
|
4056
|
+
if (opts.simulate) {
|
|
4057
|
+
const sim = result;
|
|
4058
|
+
return `\u2705 Simulation passed
|
|
4059
|
+
Estimated gas: ${sim.estimatedGas.toLocaleString()}`;
|
|
4060
|
+
}
|
|
4061
|
+
const exec = result;
|
|
4062
|
+
const r = exec.receipt;
|
|
4063
|
+
const ok = r.status === 1;
|
|
4064
|
+
return [
|
|
4065
|
+
`${ok ? "\u2705" : "\u274C"} Transaction ${ok ? "confirmed" : "FAILED"}`,
|
|
4066
|
+
` Tx Hash ${r.txHash}`,
|
|
4067
|
+
` Block ${r.blockNumber ?? "pending"}`,
|
|
4068
|
+
` From ${r.from}`,
|
|
4069
|
+
` To ${r.to ?? "N/A"}`,
|
|
4070
|
+
` Gas Used ${r.gasUsed.toLocaleString()}`,
|
|
4071
|
+
` Status ${ok ? "success" : "reverted"}`
|
|
4072
|
+
].join("\n");
|
|
4073
|
+
}
|
|
4074
|
+
var WriteExecutor;
|
|
3925
4075
|
var init_writeExecutor = __esm({
|
|
3926
4076
|
"src/sdk/rpc/writeExecutor.ts"() {
|
|
3927
4077
|
"use strict";
|
|
3928
4078
|
init_errorMap();
|
|
4079
|
+
WriteExecutor = class {
|
|
4080
|
+
constructor(config2) {
|
|
4081
|
+
this.config = config2;
|
|
4082
|
+
}
|
|
4083
|
+
config;
|
|
4084
|
+
/** Dry-run: estimate gas without signing. Returns gas estimate or decoded error. */
|
|
4085
|
+
async simulate(call) {
|
|
4086
|
+
if (this.config.wallet.mode === "readonly") {
|
|
4087
|
+
return {
|
|
4088
|
+
ok: false,
|
|
4089
|
+
code: "NO_SIGNER",
|
|
4090
|
+
message: `Cannot simulate: wallet is read-only. Set ISOMETRY_PRIVATE_KEY to enable write operations.`
|
|
4091
|
+
};
|
|
4092
|
+
}
|
|
4093
|
+
try {
|
|
4094
|
+
const fn = this.config.contract.getFunction(call.method);
|
|
4095
|
+
const gasEstimate = await fn.estimateGas(...call.args, call.overrides ?? {});
|
|
4096
|
+
const params = {};
|
|
4097
|
+
fn.fragment.inputs.forEach((input, i) => {
|
|
4098
|
+
params[input.name || `arg${i}`] = call.args[i];
|
|
4099
|
+
});
|
|
4100
|
+
return {
|
|
4101
|
+
ok: true,
|
|
4102
|
+
estimatedGas: gasEstimate,
|
|
4103
|
+
functionFragment: `${call.method}(${fn.fragment.inputs.map((i) => i.type).join(",")})`,
|
|
4104
|
+
params
|
|
4105
|
+
};
|
|
4106
|
+
} catch (err) {
|
|
4107
|
+
const decoded = this.parseRevertError(err);
|
|
4108
|
+
return {
|
|
4109
|
+
ok: false,
|
|
4110
|
+
code: "SIMULATION_FAILED",
|
|
4111
|
+
message: `[simulate] ${decoded.message}`,
|
|
4112
|
+
details: err,
|
|
4113
|
+
...decoded.selector ? { selector: decoded.selector } : {}
|
|
4114
|
+
};
|
|
4115
|
+
}
|
|
4116
|
+
}
|
|
4117
|
+
/** Execute: sign and broadcast, wait for receipt. */
|
|
4118
|
+
async execute(call, confirmations = 1) {
|
|
4119
|
+
if (this.config.wallet.mode === "readonly") {
|
|
4120
|
+
return {
|
|
4121
|
+
ok: false,
|
|
4122
|
+
code: "NO_SIGNER",
|
|
4123
|
+
message: `Cannot execute: wallet is read-only. Set ISOMETRY_PRIVATE_KEY to enable write operations.`
|
|
4124
|
+
};
|
|
4125
|
+
}
|
|
4126
|
+
if (!this.config.wallet.signer) {
|
|
4127
|
+
return {
|
|
4128
|
+
ok: false,
|
|
4129
|
+
code: "NO_SIGNER",
|
|
4130
|
+
message: "Wallet has no signer."
|
|
4131
|
+
};
|
|
4132
|
+
}
|
|
4133
|
+
try {
|
|
4134
|
+
const contract = this.config.contract.connect(this.config.wallet.signer);
|
|
4135
|
+
const fn = contract.getFunction(call.method);
|
|
4136
|
+
const tx = await fn.populateTransaction(...call.args, call.overrides ?? {});
|
|
4137
|
+
const signedTx = await this.config.wallet.signer.sendTransaction(tx);
|
|
4138
|
+
const _receipt = await signedTx.wait(confirmations);
|
|
4139
|
+
if (!_receipt) {
|
|
4140
|
+
return { ok: false, code: "RPC_ERROR", message: "Transaction receipt is null" };
|
|
4141
|
+
}
|
|
4142
|
+
return {
|
|
4143
|
+
ok: true,
|
|
4144
|
+
receipt: {
|
|
4145
|
+
txHash: _receipt.hash,
|
|
4146
|
+
blockNumber: _receipt.blockNumber,
|
|
4147
|
+
blockHash: _receipt.blockHash ?? null,
|
|
4148
|
+
status: _receipt.status ?? null,
|
|
4149
|
+
gasUsed: _receipt.gasUsed,
|
|
4150
|
+
effectiveGasPrice: _receipt.effectiveGasPrice ?? 0n,
|
|
4151
|
+
from: _receipt.from,
|
|
4152
|
+
to: _receipt.to ?? null,
|
|
4153
|
+
nonce: _receipt.nonce,
|
|
4154
|
+
logs: _receipt.logs.map((log) => ({
|
|
4155
|
+
address: log.address,
|
|
4156
|
+
topics: [...log.topics],
|
|
4157
|
+
data: log.data,
|
|
4158
|
+
blockNumber: log.blockNumber
|
|
4159
|
+
}))
|
|
4160
|
+
}
|
|
4161
|
+
};
|
|
4162
|
+
} catch (err) {
|
|
4163
|
+
const decoded = this.parseRevertError(err);
|
|
4164
|
+
return {
|
|
4165
|
+
ok: false,
|
|
4166
|
+
code: decoded.code,
|
|
4167
|
+
message: decoded.message,
|
|
4168
|
+
details: err,
|
|
4169
|
+
...decoded.selector ? { selector: decoded.selector } : {}
|
|
4170
|
+
};
|
|
4171
|
+
}
|
|
4172
|
+
}
|
|
4173
|
+
/**
|
|
4174
|
+
* Parse a revert error and extract { code, message, selector }.
|
|
4175
|
+
* selector is always included for unknown errors so users can report it.
|
|
4176
|
+
*/
|
|
4177
|
+
parseRevertError(err) {
|
|
4178
|
+
let rawSelector;
|
|
4179
|
+
if (err && typeof err === "object") {
|
|
4180
|
+
const errObj = err;
|
|
4181
|
+
const data = errObj.data;
|
|
4182
|
+
if (data && data !== "0x" && data.length >= 10) {
|
|
4183
|
+
rawSelector = data.slice(0, 10).toLowerCase();
|
|
4184
|
+
}
|
|
4185
|
+
}
|
|
4186
|
+
if (err && typeof err === "object") {
|
|
4187
|
+
const decoded = decodeError(err);
|
|
4188
|
+
if (decoded) {
|
|
4189
|
+
return { code: decoded.code, message: decoded.message, selector: rawSelector };
|
|
4190
|
+
}
|
|
4191
|
+
}
|
|
4192
|
+
if (!(err instanceof Error)) {
|
|
4193
|
+
return { code: "UNKNOWN", message: String(err), selector: rawSelector };
|
|
4194
|
+
}
|
|
4195
|
+
const msg = err.message;
|
|
4196
|
+
if (msg.includes("insufficient funds")) return { code: "INSUFFICIENT_BALANCE", message: "insufficient funds for gas", selector: rawSelector };
|
|
4197
|
+
if (msg.includes("nonce")) return { code: "RPC_ERROR", message: "nonce error (tx may already be mined)", selector: rawSelector };
|
|
4198
|
+
if (msg.includes("read-only")) return { code: "NO_SIGNER", message: "wallet is read-only", selector: rawSelector };
|
|
4199
|
+
return { code: "REVERT", message: msg.slice(0, 200), selector: rawSelector };
|
|
4200
|
+
}
|
|
4201
|
+
};
|
|
3929
4202
|
}
|
|
3930
4203
|
});
|
|
3931
4204
|
|
|
@@ -4671,10 +4944,10 @@ function resolveAddresses(env) {
|
|
|
4671
4944
|
beacon: env.ISOMETRY_BEACON_ADDRESS ?? DEFAULT_ADDRESSES.beacon
|
|
4672
4945
|
};
|
|
4673
4946
|
}
|
|
4674
|
-
function
|
|
4947
|
+
function createClient(config2) {
|
|
4675
4948
|
return new IsometryClient(config2);
|
|
4676
4949
|
}
|
|
4677
|
-
var DEFAULT_ADDRESSES,
|
|
4950
|
+
var DEFAULT_ADDRESSES, SDK_VERSION, IsometryClient;
|
|
4678
4951
|
var init_client2 = __esm({
|
|
4679
4952
|
"src/sdk/client.ts"() {
|
|
4680
4953
|
"use strict";
|
|
@@ -4689,7 +4962,7 @@ var init_client2 = __esm({
|
|
|
4689
4962
|
factory: "0x73D6BC64f4f54F9dF05851216F70F42135d56864",
|
|
4690
4963
|
beacon: "0x99d6512B5483DFA003F73F737f87e7DAE9482F89"
|
|
4691
4964
|
};
|
|
4692
|
-
|
|
4965
|
+
SDK_VERSION = "0.4.6";
|
|
4693
4966
|
IsometryClient = class {
|
|
4694
4967
|
rpc;
|
|
4695
4968
|
graph;
|
|
@@ -4702,7 +4975,7 @@ var init_client2 = __esm({
|
|
|
4702
4975
|
const graphUrl = config2.graphUrl ?? process.env.ISOMETRY_GRAPH_URL ?? "https://console.isometry.network/graph/subgraphs/name/isometry";
|
|
4703
4976
|
const privateKey = config2.privateKey ?? process.env.ISOMETRY_PRIVATE_KEY;
|
|
4704
4977
|
this._chainId = config2.chainId ?? parseInt(process.env.ISOMETRY_CHAIN_ID ?? "11155111");
|
|
4705
|
-
this._wallet =
|
|
4978
|
+
this._wallet = createWallet(rpcUrl, privateKey);
|
|
4706
4979
|
this._addresses = config2.addresses ?? resolveAddresses(process.env);
|
|
4707
4980
|
this.config = {
|
|
4708
4981
|
chainId: this._chainId,
|
|
@@ -4756,13 +5029,13 @@ __export(sdk_exports, {
|
|
|
4756
5029
|
PlatformRpcService: () => PlatformRpcService,
|
|
4757
5030
|
PrivateKeyWallet: () => PrivateKeyWallet,
|
|
4758
5031
|
ReadOnlyWallet: () => ReadOnlyWallet,
|
|
4759
|
-
SDK_VERSION: () =>
|
|
5032
|
+
SDK_VERSION: () => SDK_VERSION,
|
|
4760
5033
|
StableCoinRpcService: () => StableCoinRpcService,
|
|
4761
5034
|
TokenHistoryService: () => TokenHistoryService,
|
|
4762
|
-
createClient: () =>
|
|
5035
|
+
createClient: () => createClient,
|
|
4763
5036
|
createGraphClient: () => createGraphClient,
|
|
4764
|
-
createWallet: () =>
|
|
4765
|
-
getContracts: () =>
|
|
5037
|
+
createWallet: () => createWallet,
|
|
5038
|
+
getContracts: () => getContracts,
|
|
4766
5039
|
getStableCoin: () => getStableCoin
|
|
4767
5040
|
});
|
|
4768
5041
|
var init_sdk = __esm({
|
|
@@ -4831,6 +5104,163 @@ function registerSystem(parent) {
|
|
|
4831
5104
|
var init_system = __esm({
|
|
4832
5105
|
"src/cli/commands/system.ts"() {
|
|
4833
5106
|
"use strict";
|
|
5107
|
+
init_sdk();
|
|
5108
|
+
init_env();
|
|
5109
|
+
loadEnv();
|
|
5110
|
+
}
|
|
5111
|
+
});
|
|
5112
|
+
|
|
5113
|
+
// src/cli/commands/platformWrite.ts
|
|
5114
|
+
function jsonReplacer2(_key, value) {
|
|
5115
|
+
return typeof value === "bigint" ? value.toString() : value;
|
|
5116
|
+
}
|
|
5117
|
+
async function getPlatformExecutor() {
|
|
5118
|
+
const client = createClient();
|
|
5119
|
+
if (!client.config.privateKey) {
|
|
5120
|
+
return {
|
|
5121
|
+
error: "ISOMETRY_PRIVATE_KEY is not set \u2014 cannot sign transactions",
|
|
5122
|
+
code: "NO_SIGNER"
|
|
5123
|
+
};
|
|
5124
|
+
}
|
|
5125
|
+
const pk = client.config.privateKey;
|
|
5126
|
+
if (!/^0x[0-9a-fA-F]{64}$/.test(pk)) {
|
|
5127
|
+
return { error: "ISOMETRY_PRIVATE_KEY format invalid \u2014 must be 0x-prefixed 64-char hex", code: "INVALID_KEY" };
|
|
5128
|
+
}
|
|
5129
|
+
const wallet = createWallet(client.config.rpcUrl, pk);
|
|
5130
|
+
if (!wallet.signer) {
|
|
5131
|
+
return { error: "Wallet has no signer", code: "NO_SIGNER" };
|
|
5132
|
+
}
|
|
5133
|
+
const { getPlatform: getPlatform2 } = await Promise.resolve().then(() => (init_contracts(), contracts_exports));
|
|
5134
|
+
const platform = getPlatform2(wallet.signer, client.config.addresses);
|
|
5135
|
+
return new WriteExecutor({ wallet, contract: platform });
|
|
5136
|
+
}
|
|
5137
|
+
function outputError(code, message, json) {
|
|
5138
|
+
if (json) {
|
|
5139
|
+
console.log(JSON.stringify({ ok: false, code, message }, jsonReplacer2, 2));
|
|
5140
|
+
} else {
|
|
5141
|
+
console.log(`\u274C [${code}] ${message}`);
|
|
5142
|
+
}
|
|
5143
|
+
}
|
|
5144
|
+
async function addPlatformAdmin(account, opts) {
|
|
5145
|
+
const result = await getPlatformExecutor();
|
|
5146
|
+
if (typeof result === "object" && "error" in result) {
|
|
5147
|
+
outputError(result.code, result.error, opts.json);
|
|
5148
|
+
return;
|
|
5149
|
+
}
|
|
5150
|
+
const executor = result;
|
|
5151
|
+
const memo = opts.memo || `Add platform admin via isometry CLI at ${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
5152
|
+
const writeResult = opts.simulate ? await executor.simulate({ method: "addPlatformAdmin", args: [account, memo] }) : await executor.execute({ method: "addPlatformAdmin", args: [account, memo] });
|
|
5153
|
+
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5154
|
+
}
|
|
5155
|
+
async function removePlatformAdmin(account, opts) {
|
|
5156
|
+
const result = await getPlatformExecutor();
|
|
5157
|
+
if (typeof result === "object" && "error" in result) {
|
|
5158
|
+
outputError(result.code, result.error, opts.json);
|
|
5159
|
+
return;
|
|
5160
|
+
}
|
|
5161
|
+
const executor = result;
|
|
5162
|
+
const memo = opts.memo || `Remove platform admin via isometry CLI at ${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
5163
|
+
const writeResult = opts.simulate ? await executor.simulate({ method: "removePlatformAdmin", args: [account, memo] }) : await executor.execute({ method: "removePlatformAdmin", args: [account, memo] });
|
|
5164
|
+
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5165
|
+
}
|
|
5166
|
+
async function addApprovedIssuer(account, opts) {
|
|
5167
|
+
const result = await getPlatformExecutor();
|
|
5168
|
+
if (typeof result === "object" && "error" in result) {
|
|
5169
|
+
outputError(result.code, result.error, opts.json);
|
|
5170
|
+
return;
|
|
5171
|
+
}
|
|
5172
|
+
const executor = result;
|
|
5173
|
+
const memo = opts.memo || `Add approved issuer via isometry CLI at ${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
5174
|
+
const writeResult = opts.simulate ? await executor.simulate({ method: "addApprovedIssuer", args: [account, memo] }) : await executor.execute({ method: "addApprovedIssuer", args: [account, memo] });
|
|
5175
|
+
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5176
|
+
}
|
|
5177
|
+
async function removeApprovedIssuer(account, opts) {
|
|
5178
|
+
const result = await getPlatformExecutor();
|
|
5179
|
+
if (typeof result === "object" && "error" in result) {
|
|
5180
|
+
outputError(result.code, result.error, opts.json);
|
|
5181
|
+
return;
|
|
5182
|
+
}
|
|
5183
|
+
const executor = result;
|
|
5184
|
+
const memo = opts.memo || `Remove approved issuer via isometry CLI at ${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
5185
|
+
const writeResult = opts.simulate ? await executor.simulate({ method: "removeApprovedIssuer", args: [account, memo] }) : await executor.execute({ method: "removeApprovedIssuer", args: [account, memo] });
|
|
5186
|
+
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5187
|
+
}
|
|
5188
|
+
async function addAccessUser(account, opts) {
|
|
5189
|
+
const result = await getPlatformExecutor();
|
|
5190
|
+
if (typeof result === "object" && "error" in result) {
|
|
5191
|
+
outputError(result.code, result.error, opts.json);
|
|
5192
|
+
return;
|
|
5193
|
+
}
|
|
5194
|
+
const executor = result;
|
|
5195
|
+
const memo = opts.memo || `Add access user via isometry CLI at ${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
5196
|
+
const writeResult = opts.simulate ? await executor.simulate({ method: "addAccessUser", args: [account, memo] }) : await executor.execute({ method: "addAccessUser", args: [account, memo] });
|
|
5197
|
+
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5198
|
+
}
|
|
5199
|
+
async function removeAccessUser(account, opts) {
|
|
5200
|
+
const result = await getPlatformExecutor();
|
|
5201
|
+
if (typeof result === "object" && "error" in result) {
|
|
5202
|
+
outputError(result.code, result.error, opts.json);
|
|
5203
|
+
return;
|
|
5204
|
+
}
|
|
5205
|
+
const executor = result;
|
|
5206
|
+
const memo = opts.memo || `Remove access user via isometry CLI at ${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
5207
|
+
const writeResult = opts.simulate ? await executor.simulate({ method: "removeAccessUser", args: [account, memo] }) : await executor.execute({ method: "removeAccessUser", args: [account, memo] });
|
|
5208
|
+
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5209
|
+
}
|
|
5210
|
+
function registerPlatformWrite(platformCmd) {
|
|
5211
|
+
const admin = platformCmd.command("admin").description("Platform admin management");
|
|
5212
|
+
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(
|
|
5213
|
+
(account, opts) => addPlatformAdmin(account, {
|
|
5214
|
+
simulate: opts.simulate ?? false,
|
|
5215
|
+
json: opts.json ?? false,
|
|
5216
|
+
memo: opts.memo ?? ""
|
|
5217
|
+
})
|
|
5218
|
+
);
|
|
5219
|
+
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(
|
|
5220
|
+
(account, opts) => removePlatformAdmin(account, {
|
|
5221
|
+
simulate: opts.simulate ?? false,
|
|
5222
|
+
json: opts.json ?? false,
|
|
5223
|
+
memo: opts.memo ?? ""
|
|
5224
|
+
})
|
|
5225
|
+
);
|
|
5226
|
+
const issuer = platformCmd.command("issuer").description("Approved issuer management");
|
|
5227
|
+
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(
|
|
5228
|
+
(account, opts) => addApprovedIssuer(account, {
|
|
5229
|
+
simulate: opts.simulate ?? false,
|
|
5230
|
+
json: opts.json ?? false,
|
|
5231
|
+
memo: opts.memo ?? ""
|
|
5232
|
+
})
|
|
5233
|
+
);
|
|
5234
|
+
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(
|
|
5235
|
+
(account, opts) => removeApprovedIssuer(account, {
|
|
5236
|
+
simulate: opts.simulate ?? false,
|
|
5237
|
+
json: opts.json ?? false,
|
|
5238
|
+
memo: opts.memo ?? ""
|
|
5239
|
+
})
|
|
5240
|
+
);
|
|
5241
|
+
const access = platformCmd.command("access").description("Access user management");
|
|
5242
|
+
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(
|
|
5243
|
+
(account, opts) => addAccessUser(account, {
|
|
5244
|
+
simulate: opts.simulate ?? false,
|
|
5245
|
+
json: opts.json ?? false,
|
|
5246
|
+
memo: opts.memo ?? ""
|
|
5247
|
+
})
|
|
5248
|
+
);
|
|
5249
|
+
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(
|
|
5250
|
+
(account, opts) => removeAccessUser(account, {
|
|
5251
|
+
simulate: opts.simulate ?? false,
|
|
5252
|
+
json: opts.json ?? false,
|
|
5253
|
+
memo: opts.memo ?? ""
|
|
5254
|
+
})
|
|
5255
|
+
);
|
|
5256
|
+
}
|
|
5257
|
+
var init_platformWrite = __esm({
|
|
5258
|
+
"src/cli/commands/platformWrite.ts"() {
|
|
5259
|
+
"use strict";
|
|
5260
|
+
init_env();
|
|
5261
|
+
init_sdk();
|
|
5262
|
+
init_writeExecutor();
|
|
5263
|
+
loadEnv();
|
|
4834
5264
|
}
|
|
4835
5265
|
});
|
|
4836
5266
|
|
|
@@ -4839,7 +5269,7 @@ var platform_exports = {};
|
|
|
4839
5269
|
__export(platform_exports, {
|
|
4840
5270
|
registerPlatform: () => registerPlatform
|
|
4841
5271
|
});
|
|
4842
|
-
function
|
|
5272
|
+
function jsonReplacer3(_key, value) {
|
|
4843
5273
|
return typeof value === "bigint" ? value.toString() : value;
|
|
4844
5274
|
}
|
|
4845
5275
|
async function info(json) {
|
|
@@ -4872,7 +5302,7 @@ async function info(json) {
|
|
|
4872
5302
|
}))
|
|
4873
5303
|
};
|
|
4874
5304
|
if (json) {
|
|
4875
|
-
console.log(JSON.stringify({ ok: true, data },
|
|
5305
|
+
console.log(JSON.stringify({ ok: true, data }, jsonReplacer3, 2));
|
|
4876
5306
|
} else {
|
|
4877
5307
|
console.log(`Platform Paused ${data.paused ? "YES \u274C" : "No \u2705"}`);
|
|
4878
5308
|
console.log(`Token Count ${data.tokenCount}`);
|
|
@@ -4889,7 +5319,7 @@ async function tokens(json) {
|
|
|
4889
5319
|
const client = createClient();
|
|
4890
5320
|
const tokenAddrs = await client.rpc.platform.getAllTokens();
|
|
4891
5321
|
if (json) {
|
|
4892
|
-
console.log(JSON.stringify({ ok: true, data: { tokens: tokenAddrs } },
|
|
5322
|
+
console.log(JSON.stringify({ ok: true, data: { tokens: tokenAddrs } }, jsonReplacer3, 2));
|
|
4893
5323
|
} else {
|
|
4894
5324
|
console.log(`Registered tokens: ${tokenAddrs.length}`);
|
|
4895
5325
|
tokenAddrs.forEach((a) => console.log(` ${a}`));
|
|
@@ -4904,11 +5334,15 @@ function registerPlatform(parent) {
|
|
|
4904
5334
|
var init_platform2 = __esm({
|
|
4905
5335
|
"src/cli/commands/platform.ts"() {
|
|
4906
5336
|
"use strict";
|
|
5337
|
+
init_env();
|
|
5338
|
+
init_sdk();
|
|
5339
|
+
init_platformWrite();
|
|
5340
|
+
loadEnv();
|
|
4907
5341
|
}
|
|
4908
5342
|
});
|
|
4909
5343
|
|
|
4910
5344
|
// src/cli/commands/tokenWrite.ts
|
|
4911
|
-
function
|
|
5345
|
+
function jsonReplacer4(_key, value) {
|
|
4912
5346
|
return typeof value === "bigint" ? value.toString() : value;
|
|
4913
5347
|
}
|
|
4914
5348
|
async function getTokenExecutor(tokenAddress) {
|
|
@@ -4935,9 +5369,9 @@ async function getTokenExecutor(tokenAddress) {
|
|
|
4935
5369
|
const executor = new WriteExecutor({ wallet, contract: tokenContract });
|
|
4936
5370
|
return { executor };
|
|
4937
5371
|
}
|
|
4938
|
-
function
|
|
5372
|
+
function outputError2(code, message, json) {
|
|
4939
5373
|
if (json) {
|
|
4940
|
-
console.log(JSON.stringify({ ok: false, code, message },
|
|
5374
|
+
console.log(JSON.stringify({ ok: false, code, message }, jsonReplacer4, 2));
|
|
4941
5375
|
} else {
|
|
4942
5376
|
console.log(`\u274C [${code}] ${message}`);
|
|
4943
5377
|
}
|
|
@@ -4950,7 +5384,7 @@ async function tokenMint(tokenAddress, to, amount, opts) {
|
|
|
4950
5384
|
const writeResult = opts.simulate ? await executor.simulate({ method: "mint", args: [to, BigInt(amount), memo] }) : await executor.execute({ method: "mint", args: [to, BigInt(amount), memo] });
|
|
4951
5385
|
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
4952
5386
|
} else {
|
|
4953
|
-
|
|
5387
|
+
outputError2(result.code, result.error, opts.json);
|
|
4954
5388
|
}
|
|
4955
5389
|
}
|
|
4956
5390
|
async function tokenBurn(tokenAddress, amount, opts) {
|
|
@@ -4961,7 +5395,7 @@ async function tokenBurn(tokenAddress, amount, opts) {
|
|
|
4961
5395
|
const writeResult = opts.simulate ? await executor.simulate({ method: "burn", args: [BigInt(amount), memo] }) : await executor.execute({ method: "burn", args: [BigInt(amount), memo] });
|
|
4962
5396
|
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
4963
5397
|
} else {
|
|
4964
|
-
|
|
5398
|
+
outputError2(result.code, result.error, opts.json);
|
|
4965
5399
|
}
|
|
4966
5400
|
}
|
|
4967
5401
|
async function tokenPause(tokenAddress, opts) {
|
|
@@ -4972,7 +5406,7 @@ async function tokenPause(tokenAddress, opts) {
|
|
|
4972
5406
|
const writeResult = opts.simulate ? await executor.simulate({ method: "pause", args: [memo] }) : await executor.execute({ method: "pause", args: [memo] });
|
|
4973
5407
|
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
4974
5408
|
} else {
|
|
4975
|
-
|
|
5409
|
+
outputError2(result.code, result.error, opts.json);
|
|
4976
5410
|
}
|
|
4977
5411
|
}
|
|
4978
5412
|
async function tokenUnpause(tokenAddress, opts) {
|
|
@@ -4983,7 +5417,7 @@ async function tokenUnpause(tokenAddress, opts) {
|
|
|
4983
5417
|
const writeResult = opts.simulate ? await executor.simulate({ method: "unpause", args: [memo] }) : await executor.execute({ method: "unpause", args: [memo] });
|
|
4984
5418
|
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
4985
5419
|
} else {
|
|
4986
|
-
|
|
5420
|
+
outputError2(result.code, result.error, opts.json);
|
|
4987
5421
|
}
|
|
4988
5422
|
}
|
|
4989
5423
|
async function blacklistAdd(tokenAddress, user, opts) {
|
|
@@ -4994,7 +5428,7 @@ async function blacklistAdd(tokenAddress, user, opts) {
|
|
|
4994
5428
|
const writeResult = opts.simulate ? await executor.simulate({ method: "blacklist", args: [user, memo] }) : await executor.execute({ method: "blacklist", args: [user, memo] });
|
|
4995
5429
|
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
4996
5430
|
} else {
|
|
4997
|
-
|
|
5431
|
+
outputError2(result.code, result.error, opts.json);
|
|
4998
5432
|
}
|
|
4999
5433
|
}
|
|
5000
5434
|
async function blacklistRemove(tokenAddress, user, opts) {
|
|
@@ -5005,7 +5439,7 @@ async function blacklistRemove(tokenAddress, user, opts) {
|
|
|
5005
5439
|
const writeResult = opts.simulate ? await executor.simulate({ method: "unBlacklist", args: [user, memo] }) : await executor.execute({ method: "unBlacklist", args: [user, memo] });
|
|
5006
5440
|
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5007
5441
|
} else {
|
|
5008
|
-
|
|
5442
|
+
outputError2(result.code, result.error, opts.json);
|
|
5009
5443
|
}
|
|
5010
5444
|
}
|
|
5011
5445
|
async function addBlacklistManager(tokenAddress, account, opts) {
|
|
@@ -5016,7 +5450,7 @@ async function addBlacklistManager(tokenAddress, account, opts) {
|
|
|
5016
5450
|
const writeResult = opts.simulate ? await executor.simulate({ method: "addBlacklistManager", args: [account, memo] }) : await executor.execute({ method: "addBlacklistManager", args: [account, memo] });
|
|
5017
5451
|
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5018
5452
|
} else {
|
|
5019
|
-
|
|
5453
|
+
outputError2(result.code, result.error, opts.json);
|
|
5020
5454
|
}
|
|
5021
5455
|
}
|
|
5022
5456
|
async function removeBlacklistManager(tokenAddress, account, opts) {
|
|
@@ -5027,7 +5461,7 @@ async function removeBlacklistManager(tokenAddress, account, opts) {
|
|
|
5027
5461
|
const writeResult = opts.simulate ? await executor.simulate({ method: "removeBlacklistManager", args: [account, memo] }) : await executor.execute({ method: "removeBlacklistManager", args: [account, memo] });
|
|
5028
5462
|
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5029
5463
|
} else {
|
|
5030
|
-
|
|
5464
|
+
outputError2(result.code, result.error, opts.json);
|
|
5031
5465
|
}
|
|
5032
5466
|
}
|
|
5033
5467
|
async function addMinter(tokenAddress, minter, allowance, opts) {
|
|
@@ -5038,7 +5472,7 @@ async function addMinter(tokenAddress, minter, allowance, opts) {
|
|
|
5038
5472
|
const writeResult = opts.simulate ? await executor.simulate({ method: "addMinter", args: [minter, BigInt(allowance), memo] }) : await executor.execute({ method: "addMinter", args: [minter, BigInt(allowance), memo] });
|
|
5039
5473
|
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5040
5474
|
} else {
|
|
5041
|
-
|
|
5475
|
+
outputError2(result.code, result.error, opts.json);
|
|
5042
5476
|
}
|
|
5043
5477
|
}
|
|
5044
5478
|
async function removeMinter(tokenAddress, minter, opts) {
|
|
@@ -5049,7 +5483,7 @@ async function removeMinter(tokenAddress, minter, opts) {
|
|
|
5049
5483
|
const writeResult = opts.simulate ? await executor.simulate({ method: "removeMinter", args: [minter, memo] }) : await executor.execute({ method: "removeMinter", args: [minter, memo] });
|
|
5050
5484
|
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5051
5485
|
} else {
|
|
5052
|
-
|
|
5486
|
+
outputError2(result.code, result.error, opts.json);
|
|
5053
5487
|
}
|
|
5054
5488
|
}
|
|
5055
5489
|
function registerTokenWrite(token) {
|
|
@@ -5130,6 +5564,10 @@ function registerTokenWrite(token) {
|
|
|
5130
5564
|
var init_tokenWrite = __esm({
|
|
5131
5565
|
"src/cli/commands/tokenWrite.ts"() {
|
|
5132
5566
|
"use strict";
|
|
5567
|
+
init_env();
|
|
5568
|
+
init_sdk();
|
|
5569
|
+
init_writeExecutor();
|
|
5570
|
+
loadEnv();
|
|
5133
5571
|
}
|
|
5134
5572
|
});
|
|
5135
5573
|
|
|
@@ -5138,14 +5576,14 @@ var token_exports = {};
|
|
|
5138
5576
|
__export(token_exports, {
|
|
5139
5577
|
registerToken: () => registerToken
|
|
5140
5578
|
});
|
|
5579
|
+
function jsonReplacer5(_key, value) {
|
|
5580
|
+
return typeof value === "bigint" ? value.toString() : value;
|
|
5581
|
+
}
|
|
5141
5582
|
function formatBigInt(v) {
|
|
5142
5583
|
return v.toString();
|
|
5143
5584
|
}
|
|
5144
|
-
function jsonReplacer4(_key, value) {
|
|
5145
|
-
return typeof value === "bigint" ? value.toString() : value;
|
|
5146
|
-
}
|
|
5147
5585
|
async function tokenInfo(addr, json) {
|
|
5148
|
-
const client =
|
|
5586
|
+
const client = createClient();
|
|
5149
5587
|
const [info2, stats] = await Promise.all([
|
|
5150
5588
|
client.rpc.token.getTokenInfo(addr),
|
|
5151
5589
|
client.rpc.token.getTokenStats(addr)
|
|
@@ -5165,7 +5603,7 @@ async function tokenInfo(addr, json) {
|
|
|
5165
5603
|
blacklistCount: parseBigIntToNumber(stats.blacklistCount.toString())
|
|
5166
5604
|
};
|
|
5167
5605
|
if (json) {
|
|
5168
|
-
console.log(JSON.stringify({ ok: true, data },
|
|
5606
|
+
console.log(JSON.stringify({ ok: true, data }, jsonReplacer5, 2));
|
|
5169
5607
|
} else {
|
|
5170
5608
|
console.log(`Address ${data.address}`);
|
|
5171
5609
|
console.log(`Name ${data.name}`);
|
|
@@ -5181,7 +5619,7 @@ async function tokenInfo(addr, json) {
|
|
|
5181
5619
|
}
|
|
5182
5620
|
}
|
|
5183
5621
|
async function tokenStats(addr, json) {
|
|
5184
|
-
const client =
|
|
5622
|
+
const client = createClient();
|
|
5185
5623
|
const stats = await client.rpc.token.getTokenStats(addr);
|
|
5186
5624
|
const net = BigInt(stats.totalMinted) - BigInt(stats.totalBurned);
|
|
5187
5625
|
const data = {
|
|
@@ -5195,7 +5633,7 @@ async function tokenStats(addr, json) {
|
|
|
5195
5633
|
blacklistCount: parseBigIntToNumber(stats.blacklistCount.toString())
|
|
5196
5634
|
};
|
|
5197
5635
|
if (json) {
|
|
5198
|
-
console.log(JSON.stringify({ ok: true, data },
|
|
5636
|
+
console.log(JSON.stringify({ ok: true, data }, jsonReplacer5, 2));
|
|
5199
5637
|
} else {
|
|
5200
5638
|
console.log(`Address ${data.address}`);
|
|
5201
5639
|
console.log(`Holders ${data.holdersTotal}`);
|
|
@@ -5208,7 +5646,7 @@ async function tokenStats(addr, json) {
|
|
|
5208
5646
|
}
|
|
5209
5647
|
}
|
|
5210
5648
|
async function tokenRoles(addr, account, json) {
|
|
5211
|
-
const client =
|
|
5649
|
+
const client = createClient();
|
|
5212
5650
|
const roles = await client.rpc.token.getUserRoles(addr, account);
|
|
5213
5651
|
const data = {
|
|
5214
5652
|
token: roles.address,
|
|
@@ -5220,7 +5658,7 @@ async function tokenRoles(addr, account, json) {
|
|
|
5220
5658
|
isMasterStatus: roles.isMasterStatus
|
|
5221
5659
|
};
|
|
5222
5660
|
if (json) {
|
|
5223
|
-
console.log(JSON.stringify({ ok: true, data },
|
|
5661
|
+
console.log(JSON.stringify({ ok: true, data }, jsonReplacer5, 2));
|
|
5224
5662
|
} else {
|
|
5225
5663
|
console.log(`Token ${data.token}`);
|
|
5226
5664
|
console.log(`Account ${data.account}`);
|
|
@@ -5232,7 +5670,7 @@ async function tokenRoles(addr, account, json) {
|
|
|
5232
5670
|
}
|
|
5233
5671
|
}
|
|
5234
5672
|
async function tokenHistory(addr, first, json) {
|
|
5235
|
-
const client =
|
|
5673
|
+
const client = createClient();
|
|
5236
5674
|
const [mints, burns] = await Promise.all([
|
|
5237
5675
|
client.graph.token.getMintHistory(addr, first, 0),
|
|
5238
5676
|
client.graph.token.getBurnHistory(addr, first, 0)
|
|
@@ -5255,7 +5693,7 @@ async function tokenHistory(addr, first, json) {
|
|
|
5255
5693
|
];
|
|
5256
5694
|
events.sort((a, b) => BigInt(a.block) > BigInt(b.block) ? -1 : 1);
|
|
5257
5695
|
if (json) {
|
|
5258
|
-
console.log(JSON.stringify({ ok: true, data: { events } },
|
|
5696
|
+
console.log(JSON.stringify({ ok: true, data: { events } }, jsonReplacer5, 2));
|
|
5259
5697
|
} else {
|
|
5260
5698
|
console.log(`Token ${addr}`);
|
|
5261
5699
|
console.log(`Mint events ${mints.length} Burn events ${burns.length}`);
|
|
@@ -5265,10 +5703,10 @@ async function tokenHistory(addr, first, json) {
|
|
|
5265
5703
|
}
|
|
5266
5704
|
}
|
|
5267
5705
|
async function tokenMintHistory(addr, first, json) {
|
|
5268
|
-
const client =
|
|
5706
|
+
const client = createClient();
|
|
5269
5707
|
const events = await client.graph.token.getMintHistory(addr, first, 0);
|
|
5270
5708
|
if (json) {
|
|
5271
|
-
console.log(JSON.stringify({ ok: true, data: { events } },
|
|
5709
|
+
console.log(JSON.stringify({ ok: true, data: { events } }, jsonReplacer5, 2));
|
|
5272
5710
|
} else {
|
|
5273
5711
|
console.log(`Token ${addr} \u2014 Mint History (${events.length} events)`);
|
|
5274
5712
|
events.slice(0, 10).forEach((e) => {
|
|
@@ -5277,10 +5715,10 @@ async function tokenMintHistory(addr, first, json) {
|
|
|
5277
5715
|
}
|
|
5278
5716
|
}
|
|
5279
5717
|
async function tokenBurnHistory(addr, first, json) {
|
|
5280
|
-
const client =
|
|
5718
|
+
const client = createClient();
|
|
5281
5719
|
const events = await client.graph.token.getBurnHistory(addr, first, 0);
|
|
5282
5720
|
if (json) {
|
|
5283
|
-
console.log(JSON.stringify({ ok: true, data: { events } },
|
|
5721
|
+
console.log(JSON.stringify({ ok: true, data: { events } }, jsonReplacer5, 2));
|
|
5284
5722
|
} else {
|
|
5285
5723
|
console.log(`Token ${addr} \u2014 Burn History (${events.length} events)`);
|
|
5286
5724
|
events.slice(0, 10).forEach((e) => {
|
|
@@ -5289,7 +5727,7 @@ async function tokenBurnHistory(addr, first, json) {
|
|
|
5289
5727
|
}
|
|
5290
5728
|
}
|
|
5291
5729
|
async function tokenPauseHistory(addr, first, json) {
|
|
5292
|
-
const client =
|
|
5730
|
+
const client = createClient();
|
|
5293
5731
|
const [pauseEvts, pausedEvts, unpausedEvts] = await Promise.all([
|
|
5294
5732
|
client.graph.token.getPauseHistory(addr, first, 0),
|
|
5295
5733
|
client.graph.token.getPausedByOwnerHistory(addr, first, 0),
|
|
@@ -5299,7 +5737,7 @@ async function tokenPauseHistory(addr, first, json) {
|
|
|
5299
5737
|
console.log(JSON.stringify({
|
|
5300
5738
|
ok: true,
|
|
5301
5739
|
data: { pauseEvents: pauseEvts, pausedByOwnerEvents: pausedEvts, unpausedByOwnerEvents: unpausedEvts }
|
|
5302
|
-
},
|
|
5740
|
+
}, jsonReplacer5, 2));
|
|
5303
5741
|
} else {
|
|
5304
5742
|
console.log(`Token ${addr} \u2014 Pause History`);
|
|
5305
5743
|
console.log(`Pause events ${pauseEvts.length}`);
|
|
@@ -5329,9 +5767,11 @@ function registerToken(parent) {
|
|
|
5329
5767
|
var init_token = __esm({
|
|
5330
5768
|
"src/cli/commands/token.ts"() {
|
|
5331
5769
|
"use strict";
|
|
5770
|
+
init_env();
|
|
5332
5771
|
init_sdk();
|
|
5333
5772
|
init_analytics();
|
|
5334
5773
|
init_tokenWrite();
|
|
5774
|
+
loadEnv();
|
|
5335
5775
|
}
|
|
5336
5776
|
});
|
|
5337
5777
|
|
|
@@ -5340,7 +5780,7 @@ var factory_exports = {};
|
|
|
5340
5780
|
__export(factory_exports, {
|
|
5341
5781
|
registerFactory: () => registerFactory
|
|
5342
5782
|
});
|
|
5343
|
-
function
|
|
5783
|
+
function jsonReplacer6(_key, value) {
|
|
5344
5784
|
return typeof value === "bigint" ? value.toString() : value;
|
|
5345
5785
|
}
|
|
5346
5786
|
async function factoryInfo(json) {
|
|
@@ -5356,7 +5796,7 @@ async function factoryInfo(json) {
|
|
|
5356
5796
|
chainId: client.config.chainId
|
|
5357
5797
|
};
|
|
5358
5798
|
if (json) {
|
|
5359
|
-
console.log(JSON.stringify({ ok: true, data },
|
|
5799
|
+
console.log(JSON.stringify({ ok: true, data }, jsonReplacer6, 2));
|
|
5360
5800
|
} else {
|
|
5361
5801
|
console.log(`Beacon ${data.beacon}`);
|
|
5362
5802
|
console.log(`Platform ${data.platform}`);
|
|
@@ -5369,18 +5809,18 @@ async function factoryCreate(name, symbol, opts) {
|
|
|
5369
5809
|
const client = createClient();
|
|
5370
5810
|
if (!client.config.addresses.factory) {
|
|
5371
5811
|
const msg = "ISOMETRY_FACTORY_ADDRESS is not configured";
|
|
5372
|
-
console.log(opts.json ? JSON.stringify({ ok: false, code: "NOT_CONFIGURED", message: msg },
|
|
5812
|
+
console.log(opts.json ? JSON.stringify({ ok: false, code: "NOT_CONFIGURED", message: msg }, jsonReplacer6, 2) : `\u274C ${msg}`);
|
|
5373
5813
|
return;
|
|
5374
5814
|
}
|
|
5375
5815
|
if (!client.config.privateKey) {
|
|
5376
5816
|
const msg = "ISOMETRY_PRIVATE_KEY is not set \u2014 cannot sign transactions";
|
|
5377
|
-
console.log(opts.json ? JSON.stringify({ ok: false, code: "NO_SIGNER", message: msg },
|
|
5817
|
+
console.log(opts.json ? JSON.stringify({ ok: false, code: "NO_SIGNER", message: msg }, jsonReplacer6, 2) : `\u274C ${msg}`);
|
|
5378
5818
|
return;
|
|
5379
5819
|
}
|
|
5380
5820
|
const wallet = createWallet(client.config.rpcUrl, client.config.privateKey);
|
|
5381
5821
|
if (!wallet.signer) {
|
|
5382
5822
|
const msg = "Wallet has no signer \u2014 check ISOMETRY_PRIVATE_KEY";
|
|
5383
|
-
console.log(opts.json ? JSON.stringify({ ok: false, code: "NO_SIGNER", message: msg },
|
|
5823
|
+
console.log(opts.json ? JSON.stringify({ ok: false, code: "NO_SIGNER", message: msg }, jsonReplacer6, 2) : `\u274C ${msg}`);
|
|
5384
5824
|
return;
|
|
5385
5825
|
}
|
|
5386
5826
|
const contracts = getContracts(client.config.addresses, wallet.signer);
|
|
@@ -5410,25 +5850,19 @@ function registerFactory(parent) {
|
|
|
5410
5850
|
var init_factory2 = __esm({
|
|
5411
5851
|
"src/cli/commands/factory.ts"() {
|
|
5412
5852
|
"use strict";
|
|
5853
|
+
init_env();
|
|
5854
|
+
init_sdk();
|
|
5855
|
+
init_writeExecutor();
|
|
5856
|
+
loadEnv();
|
|
5413
5857
|
}
|
|
5414
5858
|
});
|
|
5415
5859
|
|
|
5416
5860
|
// src/cli/index.ts
|
|
5861
|
+
init_env();
|
|
5417
5862
|
import { Command } from "commander";
|
|
5418
5863
|
import { readFileSync } from "fs";
|
|
5419
5864
|
import { resolve as resolve2 } from "path";
|
|
5420
5865
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
5421
|
-
|
|
5422
|
-
// src/env.ts
|
|
5423
|
-
import { config } from "dotenv";
|
|
5424
|
-
import { resolve, dirname } from "path";
|
|
5425
|
-
import { fileURLToPath } from "url";
|
|
5426
|
-
var __dirname = dirname(fileURLToPath(import.meta.url));
|
|
5427
|
-
function loadEnv() {
|
|
5428
|
-
config({ path: resolve(__dirname, "../.env") });
|
|
5429
|
-
}
|
|
5430
|
-
|
|
5431
|
-
// src/cli/index.ts
|
|
5432
5866
|
var __dirname2 = fileURLToPath2(new URL(".", import.meta.url));
|
|
5433
5867
|
loadEnv();
|
|
5434
5868
|
var pkg = JSON.parse(
|