@bigmaxwatermelon/sdk 0.4.0 → 0.4.2
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/README.md +91 -24
- package/dist/cli.js +79 -467
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +26 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -11,7 +11,7 @@ var __export = (target, all) => {
|
|
|
11
11
|
|
|
12
12
|
// src/sdk/rpc/wallet.ts
|
|
13
13
|
import { ethers } from "ethers";
|
|
14
|
-
function
|
|
14
|
+
function createWallet2(rpcUrl, privateKey) {
|
|
15
15
|
if (privateKey) return new PrivateKeyWallet(rpcUrl, privateKey);
|
|
16
16
|
return new ReadOnlyWallet(rpcUrl);
|
|
17
17
|
}
|
|
@@ -3721,7 +3721,7 @@ var init_StableCoinBeacon = __esm({
|
|
|
3721
3721
|
// src/sdk/rpc/contracts.ts
|
|
3722
3722
|
var contracts_exports = {};
|
|
3723
3723
|
__export(contracts_exports, {
|
|
3724
|
-
getContracts: () =>
|
|
3724
|
+
getContracts: () => getContracts2,
|
|
3725
3725
|
getPlatform: () => getPlatform,
|
|
3726
3726
|
getStableCoin: () => getStableCoin
|
|
3727
3727
|
});
|
|
@@ -3729,7 +3729,7 @@ import { Contract } from "ethers";
|
|
|
3729
3729
|
function abiOf(artifact) {
|
|
3730
3730
|
return artifact.abi;
|
|
3731
3731
|
}
|
|
3732
|
-
function
|
|
3732
|
+
function getContracts2(addresses, runner) {
|
|
3733
3733
|
if (!addresses.platform) throw new Error("ISOMETRY_PLATFORM_ADDRESS is required");
|
|
3734
3734
|
if (!addresses.factory) throw new Error("ISOMETRY_FACTORY_ADDRESS is required");
|
|
3735
3735
|
if (!addresses.beacon) throw new Error("ISOMETRY_BEACON_ADDRESS is required");
|
|
@@ -3766,7 +3766,7 @@ var init_platform = __esm({
|
|
|
3766
3766
|
contracts;
|
|
3767
3767
|
platform;
|
|
3768
3768
|
constructor(addresses, runner) {
|
|
3769
|
-
this.contracts =
|
|
3769
|
+
this.contracts = getContracts2(addresses, runner);
|
|
3770
3770
|
this.platform = this.contracts.platform;
|
|
3771
3771
|
}
|
|
3772
3772
|
async getPlatformInfo() {
|
|
@@ -3825,11 +3825,11 @@ var init_factory = __esm({
|
|
|
3825
3825
|
this.runner = runner;
|
|
3826
3826
|
}
|
|
3827
3827
|
async getBeaconAddress() {
|
|
3828
|
-
const { factory } =
|
|
3828
|
+
const { factory } = getContracts2(this.addresses, this.runner);
|
|
3829
3829
|
return factory.beacon();
|
|
3830
3830
|
}
|
|
3831
3831
|
async getPlatformAddress() {
|
|
3832
|
-
const { factory } =
|
|
3832
|
+
const { factory } = getContracts2(this.addresses, this.runner);
|
|
3833
3833
|
return factory.platform();
|
|
3834
3834
|
}
|
|
3835
3835
|
};
|
|
@@ -3915,258 +3915,17 @@ var init_stablecoin = __esm({
|
|
|
3915
3915
|
});
|
|
3916
3916
|
|
|
3917
3917
|
// 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
3918
|
var init_errorMap = __esm({
|
|
3945
3919
|
"src/sdk/rpc/errorMap.ts"() {
|
|
3946
3920
|
"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
3921
|
}
|
|
4004
3922
|
});
|
|
4005
3923
|
|
|
4006
3924
|
// 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
|
-
}
|
|
4030
|
-
if (meta) Object.assign(out, { meta });
|
|
4031
|
-
return JSON.stringify(
|
|
4032
|
-
out,
|
|
4033
|
-
(_key, value) => typeof value === "bigint" ? value.toString() : value,
|
|
4034
|
-
2
|
|
4035
|
-
);
|
|
4036
|
-
}
|
|
4037
|
-
if (!result.ok) {
|
|
4038
|
-
return `\u274C [${result.code}] ${result.message}`;
|
|
4039
|
-
}
|
|
4040
|
-
if (opts.simulate) {
|
|
4041
|
-
const sim = result;
|
|
4042
|
-
return `\u2705 Simulation passed
|
|
4043
|
-
Estimated gas: ${sim.estimatedGas.toLocaleString()}`;
|
|
4044
|
-
}
|
|
4045
|
-
const exec = result;
|
|
4046
|
-
const r = exec.receipt;
|
|
4047
|
-
const ok = r.status === 1;
|
|
4048
|
-
return [
|
|
4049
|
-
`${ok ? "\u2705" : "\u274C"} Transaction ${ok ? "confirmed" : "FAILED"}`,
|
|
4050
|
-
` Tx Hash ${r.txHash}`,
|
|
4051
|
-
` Block ${r.blockNumber ?? "pending"}`,
|
|
4052
|
-
` From ${r.from}`,
|
|
4053
|
-
` To ${r.to ?? "N/A"}`,
|
|
4054
|
-
` Gas Used ${r.gasUsed.toLocaleString()}`,
|
|
4055
|
-
` Status ${ok ? "success" : "reverted"}`
|
|
4056
|
-
].join("\n");
|
|
4057
|
-
}
|
|
4058
|
-
var WriteExecutor;
|
|
4059
3925
|
var init_writeExecutor = __esm({
|
|
4060
3926
|
"src/sdk/rpc/writeExecutor.ts"() {
|
|
4061
3927
|
"use strict";
|
|
4062
3928
|
init_errorMap();
|
|
4063
|
-
WriteExecutor = class {
|
|
4064
|
-
constructor(config2) {
|
|
4065
|
-
this.config = config2;
|
|
4066
|
-
}
|
|
4067
|
-
config;
|
|
4068
|
-
/** Dry-run: estimate gas without signing. Returns gas estimate or decoded error. */
|
|
4069
|
-
async simulate(call) {
|
|
4070
|
-
if (this.config.wallet.mode === "readonly") {
|
|
4071
|
-
return {
|
|
4072
|
-
ok: false,
|
|
4073
|
-
code: "NO_SIGNER",
|
|
4074
|
-
message: `Cannot simulate: wallet is read-only. Set ISOMETRY_PRIVATE_KEY to enable write operations.`
|
|
4075
|
-
};
|
|
4076
|
-
}
|
|
4077
|
-
try {
|
|
4078
|
-
const fn = this.config.contract.getFunction(call.method);
|
|
4079
|
-
const gasEstimate = await fn.estimateGas(...call.args, call.overrides ?? {});
|
|
4080
|
-
const params = {};
|
|
4081
|
-
fn.fragment.inputs.forEach((input, i) => {
|
|
4082
|
-
params[input.name || `arg${i}`] = call.args[i];
|
|
4083
|
-
});
|
|
4084
|
-
return {
|
|
4085
|
-
ok: true,
|
|
4086
|
-
estimatedGas: gasEstimate,
|
|
4087
|
-
functionFragment: `${call.method}(${fn.fragment.inputs.map((i) => i.type).join(",")})`,
|
|
4088
|
-
params
|
|
4089
|
-
};
|
|
4090
|
-
} catch (err) {
|
|
4091
|
-
const decoded = this.parseRevertError(err);
|
|
4092
|
-
return {
|
|
4093
|
-
ok: false,
|
|
4094
|
-
code: "SIMULATION_FAILED",
|
|
4095
|
-
message: `[simulate] ${decoded.message}`,
|
|
4096
|
-
details: err
|
|
4097
|
-
};
|
|
4098
|
-
}
|
|
4099
|
-
}
|
|
4100
|
-
/** Execute: sign and broadcast, wait for receipt. */
|
|
4101
|
-
async execute(call, confirmations = 1) {
|
|
4102
|
-
if (this.config.wallet.mode === "readonly") {
|
|
4103
|
-
return {
|
|
4104
|
-
ok: false,
|
|
4105
|
-
code: "NO_SIGNER",
|
|
4106
|
-
message: `Cannot execute: wallet is read-only. Set ISOMETRY_PRIVATE_KEY to enable write operations.`
|
|
4107
|
-
};
|
|
4108
|
-
}
|
|
4109
|
-
if (!this.config.wallet.signer) {
|
|
4110
|
-
return {
|
|
4111
|
-
ok: false,
|
|
4112
|
-
code: "NO_SIGNER",
|
|
4113
|
-
message: "Wallet has no signer."
|
|
4114
|
-
};
|
|
4115
|
-
}
|
|
4116
|
-
try {
|
|
4117
|
-
const contract = this.config.contract.connect(this.config.wallet.signer);
|
|
4118
|
-
const fn = contract.getFunction(call.method);
|
|
4119
|
-
const tx = await fn.populateTransaction(...call.args, call.overrides ?? {});
|
|
4120
|
-
const signedTx = await this.config.wallet.signer.sendTransaction(tx);
|
|
4121
|
-
const _receipt = await signedTx.wait(confirmations);
|
|
4122
|
-
if (!_receipt) {
|
|
4123
|
-
return { ok: false, code: "RPC_ERROR", message: "Transaction receipt is null" };
|
|
4124
|
-
}
|
|
4125
|
-
return {
|
|
4126
|
-
ok: true,
|
|
4127
|
-
receipt: {
|
|
4128
|
-
txHash: _receipt.hash,
|
|
4129
|
-
blockNumber: _receipt.blockNumber,
|
|
4130
|
-
blockHash: _receipt.blockHash ?? null,
|
|
4131
|
-
status: _receipt.status ?? null,
|
|
4132
|
-
gasUsed: _receipt.gasUsed,
|
|
4133
|
-
effectiveGasPrice: _receipt.effectiveGasPrice ?? 0n,
|
|
4134
|
-
from: _receipt.from,
|
|
4135
|
-
to: _receipt.to ?? null,
|
|
4136
|
-
nonce: _receipt.nonce,
|
|
4137
|
-
logs: _receipt.logs.map((log) => ({
|
|
4138
|
-
address: log.address,
|
|
4139
|
-
topics: [...log.topics],
|
|
4140
|
-
data: log.data,
|
|
4141
|
-
blockNumber: log.blockNumber
|
|
4142
|
-
}))
|
|
4143
|
-
}
|
|
4144
|
-
};
|
|
4145
|
-
} catch (err) {
|
|
4146
|
-
const decoded = this.parseRevertError(err);
|
|
4147
|
-
return {
|
|
4148
|
-
ok: false,
|
|
4149
|
-
code: decoded.code,
|
|
4150
|
-
message: decoded.message,
|
|
4151
|
-
details: err
|
|
4152
|
-
};
|
|
4153
|
-
}
|
|
4154
|
-
}
|
|
4155
|
-
parseRevertError(err) {
|
|
4156
|
-
if (err && typeof err === "object") {
|
|
4157
|
-
const decoded = decodeError(err);
|
|
4158
|
-
if (decoded) return decoded;
|
|
4159
|
-
}
|
|
4160
|
-
if (!(err instanceof Error)) {
|
|
4161
|
-
return { code: "UNKNOWN", message: String(err) };
|
|
4162
|
-
}
|
|
4163
|
-
const msg = err.message;
|
|
4164
|
-
if (msg.includes("insufficient funds")) return { code: "INSUFFICIENT_BALANCE", message: "insufficient funds for gas" };
|
|
4165
|
-
if (msg.includes("nonce")) return { code: "RPC_ERROR", message: "nonce error (tx may already be mined)" };
|
|
4166
|
-
if (msg.includes("read-only")) return { code: "NO_SIGNER", message: "wallet is read-only" };
|
|
4167
|
-
return { code: "REVERT", message: msg.slice(0, 200) };
|
|
4168
|
-
}
|
|
4169
|
-
};
|
|
4170
3929
|
}
|
|
4171
3930
|
});
|
|
4172
3931
|
|
|
@@ -4912,10 +4671,10 @@ function resolveAddresses(env) {
|
|
|
4912
4671
|
beacon: env.ISOMETRY_BEACON_ADDRESS ?? DEFAULT_ADDRESSES.beacon
|
|
4913
4672
|
};
|
|
4914
4673
|
}
|
|
4915
|
-
function
|
|
4674
|
+
function createClient2(config2) {
|
|
4916
4675
|
return new IsometryClient(config2);
|
|
4917
4676
|
}
|
|
4918
|
-
var DEFAULT_ADDRESSES,
|
|
4677
|
+
var DEFAULT_ADDRESSES, SDK_VERSION2, IsometryClient;
|
|
4919
4678
|
var init_client2 = __esm({
|
|
4920
4679
|
"src/sdk/client.ts"() {
|
|
4921
4680
|
"use strict";
|
|
@@ -4930,7 +4689,7 @@ var init_client2 = __esm({
|
|
|
4930
4689
|
factory: "0x73D6BC64f4f54F9dF05851216F70F42135d56864",
|
|
4931
4690
|
beacon: "0x99d6512B5483DFA003F73F737f87e7DAE9482F89"
|
|
4932
4691
|
};
|
|
4933
|
-
|
|
4692
|
+
SDK_VERSION2 = "0.4.2";
|
|
4934
4693
|
IsometryClient = class {
|
|
4935
4694
|
rpc;
|
|
4936
4695
|
graph;
|
|
@@ -4939,11 +4698,11 @@ var init_client2 = __esm({
|
|
|
4939
4698
|
_addresses;
|
|
4940
4699
|
_chainId;
|
|
4941
4700
|
constructor(config2 = {}) {
|
|
4942
|
-
const rpcUrl = config2.rpcUrl ?? process.env.ISOMETRY_RPC_URL ?? "";
|
|
4701
|
+
const rpcUrl = config2.rpcUrl ?? process.env.ISOMETRY_RPC_URL ?? "https://ethereum-sepolia.publicnode.com";
|
|
4943
4702
|
const graphUrl = config2.graphUrl ?? process.env.ISOMETRY_GRAPH_URL ?? "https://console.isometry.network/graph/subgraphs/name/isometry";
|
|
4944
4703
|
const privateKey = config2.privateKey ?? process.env.ISOMETRY_PRIVATE_KEY;
|
|
4945
4704
|
this._chainId = config2.chainId ?? parseInt(process.env.ISOMETRY_CHAIN_ID ?? "11155111");
|
|
4946
|
-
this._wallet =
|
|
4705
|
+
this._wallet = createWallet2(rpcUrl, privateKey);
|
|
4947
4706
|
this._addresses = config2.addresses ?? resolveAddresses(process.env);
|
|
4948
4707
|
this.config = {
|
|
4949
4708
|
chainId: this._chainId,
|
|
@@ -4997,13 +4756,13 @@ __export(sdk_exports, {
|
|
|
4997
4756
|
PlatformRpcService: () => PlatformRpcService,
|
|
4998
4757
|
PrivateKeyWallet: () => PrivateKeyWallet,
|
|
4999
4758
|
ReadOnlyWallet: () => ReadOnlyWallet,
|
|
5000
|
-
SDK_VERSION: () =>
|
|
4759
|
+
SDK_VERSION: () => SDK_VERSION2,
|
|
5001
4760
|
StableCoinRpcService: () => StableCoinRpcService,
|
|
5002
4761
|
TokenHistoryService: () => TokenHistoryService,
|
|
5003
|
-
createClient: () =>
|
|
4762
|
+
createClient: () => createClient2,
|
|
5004
4763
|
createGraphClient: () => createGraphClient,
|
|
5005
|
-
createWallet: () =>
|
|
5006
|
-
getContracts: () =>
|
|
4764
|
+
createWallet: () => createWallet2,
|
|
4765
|
+
getContracts: () => getContracts2,
|
|
5007
4766
|
getStableCoin: () => getStableCoin
|
|
5008
4767
|
});
|
|
5009
4768
|
var init_sdk = __esm({
|
|
@@ -5018,26 +4777,14 @@ var init_sdk = __esm({
|
|
|
5018
4777
|
}
|
|
5019
4778
|
});
|
|
5020
4779
|
|
|
5021
|
-
// src/env.ts
|
|
5022
|
-
import { config } from "dotenv";
|
|
5023
|
-
import { resolve, dirname } from "path";
|
|
5024
|
-
import { fileURLToPath } from "url";
|
|
5025
|
-
function loadEnv() {
|
|
5026
|
-
config({ path: resolve(__dirname, "../.env") });
|
|
5027
|
-
}
|
|
5028
|
-
var __dirname;
|
|
5029
|
-
var init_env = __esm({
|
|
5030
|
-
"src/env.ts"() {
|
|
5031
|
-
"use strict";
|
|
5032
|
-
__dirname = dirname(fileURLToPath(import.meta.url));
|
|
5033
|
-
}
|
|
5034
|
-
});
|
|
5035
|
-
|
|
5036
4780
|
// src/cli/commands/system.ts
|
|
5037
4781
|
var system_exports = {};
|
|
5038
4782
|
__export(system_exports, {
|
|
5039
4783
|
registerSystem: () => registerSystem
|
|
5040
4784
|
});
|
|
4785
|
+
function jsonReplacer(_key, value) {
|
|
4786
|
+
return typeof value === "bigint" ? value.toString() : value;
|
|
4787
|
+
}
|
|
5041
4788
|
async function version(json) {
|
|
5042
4789
|
const data = {
|
|
5043
4790
|
cli: SDK_VERSION,
|
|
@@ -5045,7 +4792,7 @@ async function version(json) {
|
|
|
5045
4792
|
graphUrl: process.env.ISOMETRY_GRAPH_URL ?? "https://console.isometry.network/graph/subgraphs/name/isometry"
|
|
5046
4793
|
};
|
|
5047
4794
|
if (json) {
|
|
5048
|
-
console.log(JSON.stringify({ ok: true, data },
|
|
4795
|
+
console.log(JSON.stringify({ ok: true, data }, jsonReplacer, 2));
|
|
5049
4796
|
} else {
|
|
5050
4797
|
console.log(`isometry CLI v${SDK_VERSION}`);
|
|
5051
4798
|
console.log(`SDK v${SDK_VERSION}`);
|
|
@@ -5065,7 +4812,7 @@ async function status(json) {
|
|
|
5065
4812
|
}
|
|
5066
4813
|
const data = { subgraph: meta ? "connected" : "unreachable", meta, metaError };
|
|
5067
4814
|
if (json) {
|
|
5068
|
-
console.log(JSON.stringify({ ok: true, data },
|
|
4815
|
+
console.log(JSON.stringify({ ok: true, data }, jsonReplacer, 2));
|
|
5069
4816
|
} else {
|
|
5070
4817
|
if (meta) {
|
|
5071
4818
|
console.log(`Subgraph \u2705 connected`);
|
|
@@ -5084,159 +4831,6 @@ function registerSystem(parent) {
|
|
|
5084
4831
|
var init_system = __esm({
|
|
5085
4832
|
"src/cli/commands/system.ts"() {
|
|
5086
4833
|
"use strict";
|
|
5087
|
-
init_sdk();
|
|
5088
|
-
init_env();
|
|
5089
|
-
loadEnv();
|
|
5090
|
-
}
|
|
5091
|
-
});
|
|
5092
|
-
|
|
5093
|
-
// src/cli/commands/platformWrite.ts
|
|
5094
|
-
async function getPlatformExecutor() {
|
|
5095
|
-
const client = createClient();
|
|
5096
|
-
if (!client.config.privateKey) {
|
|
5097
|
-
return {
|
|
5098
|
-
error: "ISOMETRY_PRIVATE_KEY is not set \u2014 cannot sign transactions",
|
|
5099
|
-
code: "NO_SIGNER"
|
|
5100
|
-
};
|
|
5101
|
-
}
|
|
5102
|
-
const pk = client.config.privateKey;
|
|
5103
|
-
if (!/^0x[0-9a-fA-F]{64}$/.test(pk)) {
|
|
5104
|
-
return { error: "ISOMETRY_PRIVATE_KEY format invalid \u2014 must be 0x-prefixed 64-char hex", code: "INVALID_KEY" };
|
|
5105
|
-
}
|
|
5106
|
-
const wallet = createWallet(client.config.rpcUrl, pk);
|
|
5107
|
-
if (!wallet.signer) {
|
|
5108
|
-
return { error: "Wallet has no signer", code: "NO_SIGNER" };
|
|
5109
|
-
}
|
|
5110
|
-
const { getPlatform: getPlatform2 } = await Promise.resolve().then(() => (init_contracts(), contracts_exports));
|
|
5111
|
-
const platform = getPlatform2(wallet.signer, client.config.addresses);
|
|
5112
|
-
return new WriteExecutor({ wallet, contract: platform });
|
|
5113
|
-
}
|
|
5114
|
-
function outputError(code, message, json) {
|
|
5115
|
-
if (json) {
|
|
5116
|
-
console.log(JSON.stringify({ ok: false, code, message }, null, 2));
|
|
5117
|
-
} else {
|
|
5118
|
-
console.log(`\u274C [${code}] ${message}`);
|
|
5119
|
-
}
|
|
5120
|
-
}
|
|
5121
|
-
async function addPlatformAdmin(account, opts) {
|
|
5122
|
-
const result = await getPlatformExecutor();
|
|
5123
|
-
if (typeof result === "object" && "error" in result) {
|
|
5124
|
-
outputError(result.code, result.error, opts.json);
|
|
5125
|
-
return;
|
|
5126
|
-
}
|
|
5127
|
-
const executor = result;
|
|
5128
|
-
const memo = opts.memo || `Add platform admin via isometry CLI at ${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
5129
|
-
const writeResult = opts.simulate ? await executor.simulate({ method: "addPlatformAdmin", args: [account, memo] }) : await executor.execute({ method: "addPlatformAdmin", args: [account, memo] });
|
|
5130
|
-
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5131
|
-
}
|
|
5132
|
-
async function removePlatformAdmin(account, opts) {
|
|
5133
|
-
const result = await getPlatformExecutor();
|
|
5134
|
-
if (typeof result === "object" && "error" in result) {
|
|
5135
|
-
outputError(result.code, result.error, opts.json);
|
|
5136
|
-
return;
|
|
5137
|
-
}
|
|
5138
|
-
const executor = result;
|
|
5139
|
-
const memo = opts.memo || `Remove platform admin via isometry CLI at ${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
5140
|
-
const writeResult = opts.simulate ? await executor.simulate({ method: "removePlatformAdmin", args: [account, memo] }) : await executor.execute({ method: "removePlatformAdmin", args: [account, memo] });
|
|
5141
|
-
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5142
|
-
}
|
|
5143
|
-
async function addApprovedIssuer(account, opts) {
|
|
5144
|
-
const result = await getPlatformExecutor();
|
|
5145
|
-
if (typeof result === "object" && "error" in result) {
|
|
5146
|
-
outputError(result.code, result.error, opts.json);
|
|
5147
|
-
return;
|
|
5148
|
-
}
|
|
5149
|
-
const executor = result;
|
|
5150
|
-
const memo = opts.memo || `Add approved issuer via isometry CLI at ${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
5151
|
-
const writeResult = opts.simulate ? await executor.simulate({ method: "addApprovedIssuer", args: [account, memo] }) : await executor.execute({ method: "addApprovedIssuer", args: [account, memo] });
|
|
5152
|
-
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5153
|
-
}
|
|
5154
|
-
async function removeApprovedIssuer(account, opts) {
|
|
5155
|
-
const result = await getPlatformExecutor();
|
|
5156
|
-
if (typeof result === "object" && "error" in result) {
|
|
5157
|
-
outputError(result.code, result.error, opts.json);
|
|
5158
|
-
return;
|
|
5159
|
-
}
|
|
5160
|
-
const executor = result;
|
|
5161
|
-
const memo = opts.memo || `Remove approved issuer via isometry CLI at ${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
5162
|
-
const writeResult = opts.simulate ? await executor.simulate({ method: "removeApprovedIssuer", args: [account, memo] }) : await executor.execute({ method: "removeApprovedIssuer", args: [account, memo] });
|
|
5163
|
-
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5164
|
-
}
|
|
5165
|
-
async function addAccessUser(account, opts) {
|
|
5166
|
-
const result = await getPlatformExecutor();
|
|
5167
|
-
if (typeof result === "object" && "error" in result) {
|
|
5168
|
-
outputError(result.code, result.error, opts.json);
|
|
5169
|
-
return;
|
|
5170
|
-
}
|
|
5171
|
-
const executor = result;
|
|
5172
|
-
const memo = opts.memo || `Add access user via isometry CLI at ${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
5173
|
-
const writeResult = opts.simulate ? await executor.simulate({ method: "addAccessUser", args: [account, memo] }) : await executor.execute({ method: "addAccessUser", args: [account, memo] });
|
|
5174
|
-
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5175
|
-
}
|
|
5176
|
-
async function removeAccessUser(account, opts) {
|
|
5177
|
-
const result = await getPlatformExecutor();
|
|
5178
|
-
if (typeof result === "object" && "error" in result) {
|
|
5179
|
-
outputError(result.code, result.error, opts.json);
|
|
5180
|
-
return;
|
|
5181
|
-
}
|
|
5182
|
-
const executor = result;
|
|
5183
|
-
const memo = opts.memo || `Remove access user via isometry CLI at ${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
5184
|
-
const writeResult = opts.simulate ? await executor.simulate({ method: "removeAccessUser", args: [account, memo] }) : await executor.execute({ method: "removeAccessUser", args: [account, memo] });
|
|
5185
|
-
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5186
|
-
}
|
|
5187
|
-
function registerPlatformWrite(platformCmd) {
|
|
5188
|
-
const admin = platformCmd.command("admin").description("Platform admin management");
|
|
5189
|
-
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(
|
|
5190
|
-
(account, opts) => addPlatformAdmin(account, {
|
|
5191
|
-
simulate: opts.simulate ?? false,
|
|
5192
|
-
json: opts.json ?? false,
|
|
5193
|
-
memo: opts.memo ?? ""
|
|
5194
|
-
})
|
|
5195
|
-
);
|
|
5196
|
-
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(
|
|
5197
|
-
(account, opts) => removePlatformAdmin(account, {
|
|
5198
|
-
simulate: opts.simulate ?? false,
|
|
5199
|
-
json: opts.json ?? false,
|
|
5200
|
-
memo: opts.memo ?? ""
|
|
5201
|
-
})
|
|
5202
|
-
);
|
|
5203
|
-
const issuer = platformCmd.command("issuer").description("Approved issuer management");
|
|
5204
|
-
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(
|
|
5205
|
-
(account, opts) => addApprovedIssuer(account, {
|
|
5206
|
-
simulate: opts.simulate ?? false,
|
|
5207
|
-
json: opts.json ?? false,
|
|
5208
|
-
memo: opts.memo ?? ""
|
|
5209
|
-
})
|
|
5210
|
-
);
|
|
5211
|
-
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(
|
|
5212
|
-
(account, opts) => removeApprovedIssuer(account, {
|
|
5213
|
-
simulate: opts.simulate ?? false,
|
|
5214
|
-
json: opts.json ?? false,
|
|
5215
|
-
memo: opts.memo ?? ""
|
|
5216
|
-
})
|
|
5217
|
-
);
|
|
5218
|
-
const access = platformCmd.command("access").description("Access user management");
|
|
5219
|
-
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(
|
|
5220
|
-
(account, opts) => addAccessUser(account, {
|
|
5221
|
-
simulate: opts.simulate ?? false,
|
|
5222
|
-
json: opts.json ?? false,
|
|
5223
|
-
memo: opts.memo ?? ""
|
|
5224
|
-
})
|
|
5225
|
-
);
|
|
5226
|
-
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(
|
|
5227
|
-
(account, opts) => removeAccessUser(account, {
|
|
5228
|
-
simulate: opts.simulate ?? false,
|
|
5229
|
-
json: opts.json ?? false,
|
|
5230
|
-
memo: opts.memo ?? ""
|
|
5231
|
-
})
|
|
5232
|
-
);
|
|
5233
|
-
}
|
|
5234
|
-
var init_platformWrite = __esm({
|
|
5235
|
-
"src/cli/commands/platformWrite.ts"() {
|
|
5236
|
-
"use strict";
|
|
5237
|
-
init_env();
|
|
5238
|
-
init_sdk();
|
|
5239
|
-
init_writeExecutor();
|
|
5240
4834
|
loadEnv();
|
|
5241
4835
|
}
|
|
5242
4836
|
});
|
|
@@ -5246,6 +4840,9 @@ var platform_exports = {};
|
|
|
5246
4840
|
__export(platform_exports, {
|
|
5247
4841
|
registerPlatform: () => registerPlatform
|
|
5248
4842
|
});
|
|
4843
|
+
function jsonReplacer2(_key, value) {
|
|
4844
|
+
return typeof value === "bigint" ? value.toString() : value;
|
|
4845
|
+
}
|
|
5249
4846
|
async function info(json) {
|
|
5250
4847
|
const client = createClient();
|
|
5251
4848
|
const [platformInfo, graphAdmins, graphIssuers, graphAccessUsers] = await Promise.all([
|
|
@@ -5276,7 +4873,7 @@ async function info(json) {
|
|
|
5276
4873
|
}))
|
|
5277
4874
|
};
|
|
5278
4875
|
if (json) {
|
|
5279
|
-
console.log(JSON.stringify({ ok: true, data },
|
|
4876
|
+
console.log(JSON.stringify({ ok: true, data }, jsonReplacer2, 2));
|
|
5280
4877
|
} else {
|
|
5281
4878
|
console.log(`Platform Paused ${data.paused ? "YES \u274C" : "No \u2705"}`);
|
|
5282
4879
|
console.log(`Token Count ${data.tokenCount}`);
|
|
@@ -5293,7 +4890,7 @@ async function tokens(json) {
|
|
|
5293
4890
|
const client = createClient();
|
|
5294
4891
|
const tokenAddrs = await client.rpc.platform.getAllTokens();
|
|
5295
4892
|
if (json) {
|
|
5296
|
-
console.log(JSON.stringify({ ok: true, data: { tokens: tokenAddrs } },
|
|
4893
|
+
console.log(JSON.stringify({ ok: true, data: { tokens: tokenAddrs } }, jsonReplacer2, 2));
|
|
5297
4894
|
} else {
|
|
5298
4895
|
console.log(`Registered tokens: ${tokenAddrs.length}`);
|
|
5299
4896
|
tokenAddrs.forEach((a) => console.log(` ${a}`));
|
|
@@ -5308,14 +4905,29 @@ function registerPlatform(parent) {
|
|
|
5308
4905
|
var init_platform2 = __esm({
|
|
5309
4906
|
"src/cli/commands/platform.ts"() {
|
|
5310
4907
|
"use strict";
|
|
5311
|
-
init_env();
|
|
5312
|
-
init_sdk();
|
|
5313
|
-
init_platformWrite();
|
|
5314
4908
|
loadEnv();
|
|
5315
4909
|
}
|
|
5316
4910
|
});
|
|
5317
4911
|
|
|
4912
|
+
// src/env.ts
|
|
4913
|
+
import { config } from "dotenv";
|
|
4914
|
+
import { resolve, dirname } from "path";
|
|
4915
|
+
import { fileURLToPath } from "url";
|
|
4916
|
+
function loadEnv2() {
|
|
4917
|
+
config({ path: resolve(__dirname, "../.env") });
|
|
4918
|
+
}
|
|
4919
|
+
var __dirname;
|
|
4920
|
+
var init_env = __esm({
|
|
4921
|
+
"src/env.ts"() {
|
|
4922
|
+
"use strict";
|
|
4923
|
+
__dirname = dirname(fileURLToPath(import.meta.url));
|
|
4924
|
+
}
|
|
4925
|
+
});
|
|
4926
|
+
|
|
5318
4927
|
// src/cli/commands/tokenWrite.ts
|
|
4928
|
+
function jsonReplacer3(_key, value) {
|
|
4929
|
+
return typeof value === "bigint" ? value.toString() : value;
|
|
4930
|
+
}
|
|
5319
4931
|
async function getTokenExecutor(tokenAddress) {
|
|
5320
4932
|
if (!tokenAddress) {
|
|
5321
4933
|
return { error: "Token address is required", code: "INVALID_ARGUMENT" };
|
|
@@ -5340,9 +4952,9 @@ async function getTokenExecutor(tokenAddress) {
|
|
|
5340
4952
|
const executor = new WriteExecutor({ wallet, contract: tokenContract });
|
|
5341
4953
|
return { executor };
|
|
5342
4954
|
}
|
|
5343
|
-
function
|
|
4955
|
+
function outputError(code, message, json) {
|
|
5344
4956
|
if (json) {
|
|
5345
|
-
console.log(JSON.stringify({ ok: false, code, message },
|
|
4957
|
+
console.log(JSON.stringify({ ok: false, code, message }, jsonReplacer3, 2));
|
|
5346
4958
|
} else {
|
|
5347
4959
|
console.log(`\u274C [${code}] ${message}`);
|
|
5348
4960
|
}
|
|
@@ -5355,7 +4967,7 @@ async function tokenMint(tokenAddress, to, amount, opts) {
|
|
|
5355
4967
|
const writeResult = opts.simulate ? await executor.simulate({ method: "mint", args: [to, BigInt(amount), memo] }) : await executor.execute({ method: "mint", args: [to, BigInt(amount), memo] });
|
|
5356
4968
|
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5357
4969
|
} else {
|
|
5358
|
-
|
|
4970
|
+
outputError(result.code, result.error, opts.json);
|
|
5359
4971
|
}
|
|
5360
4972
|
}
|
|
5361
4973
|
async function tokenBurn(tokenAddress, amount, opts) {
|
|
@@ -5366,7 +4978,7 @@ async function tokenBurn(tokenAddress, amount, opts) {
|
|
|
5366
4978
|
const writeResult = opts.simulate ? await executor.simulate({ method: "burn", args: [BigInt(amount), memo] }) : await executor.execute({ method: "burn", args: [BigInt(amount), memo] });
|
|
5367
4979
|
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5368
4980
|
} else {
|
|
5369
|
-
|
|
4981
|
+
outputError(result.code, result.error, opts.json);
|
|
5370
4982
|
}
|
|
5371
4983
|
}
|
|
5372
4984
|
async function tokenPause(tokenAddress, opts) {
|
|
@@ -5377,7 +4989,7 @@ async function tokenPause(tokenAddress, opts) {
|
|
|
5377
4989
|
const writeResult = opts.simulate ? await executor.simulate({ method: "pause", args: [memo] }) : await executor.execute({ method: "pause", args: [memo] });
|
|
5378
4990
|
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5379
4991
|
} else {
|
|
5380
|
-
|
|
4992
|
+
outputError(result.code, result.error, opts.json);
|
|
5381
4993
|
}
|
|
5382
4994
|
}
|
|
5383
4995
|
async function tokenUnpause(tokenAddress, opts) {
|
|
@@ -5388,7 +5000,7 @@ async function tokenUnpause(tokenAddress, opts) {
|
|
|
5388
5000
|
const writeResult = opts.simulate ? await executor.simulate({ method: "unpause", args: [memo] }) : await executor.execute({ method: "unpause", args: [memo] });
|
|
5389
5001
|
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5390
5002
|
} else {
|
|
5391
|
-
|
|
5003
|
+
outputError(result.code, result.error, opts.json);
|
|
5392
5004
|
}
|
|
5393
5005
|
}
|
|
5394
5006
|
async function blacklistAdd(tokenAddress, user, opts) {
|
|
@@ -5399,7 +5011,7 @@ async function blacklistAdd(tokenAddress, user, opts) {
|
|
|
5399
5011
|
const writeResult = opts.simulate ? await executor.simulate({ method: "blacklist", args: [user, memo] }) : await executor.execute({ method: "blacklist", args: [user, memo] });
|
|
5400
5012
|
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5401
5013
|
} else {
|
|
5402
|
-
|
|
5014
|
+
outputError(result.code, result.error, opts.json);
|
|
5403
5015
|
}
|
|
5404
5016
|
}
|
|
5405
5017
|
async function blacklistRemove(tokenAddress, user, opts) {
|
|
@@ -5410,7 +5022,7 @@ async function blacklistRemove(tokenAddress, user, opts) {
|
|
|
5410
5022
|
const writeResult = opts.simulate ? await executor.simulate({ method: "unBlacklist", args: [user, memo] }) : await executor.execute({ method: "unBlacklist", args: [user, memo] });
|
|
5411
5023
|
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5412
5024
|
} else {
|
|
5413
|
-
|
|
5025
|
+
outputError(result.code, result.error, opts.json);
|
|
5414
5026
|
}
|
|
5415
5027
|
}
|
|
5416
5028
|
async function addBlacklistManager(tokenAddress, account, opts) {
|
|
@@ -5421,7 +5033,7 @@ async function addBlacklistManager(tokenAddress, account, opts) {
|
|
|
5421
5033
|
const writeResult = opts.simulate ? await executor.simulate({ method: "addBlacklistManager", args: [account, memo] }) : await executor.execute({ method: "addBlacklistManager", args: [account, memo] });
|
|
5422
5034
|
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5423
5035
|
} else {
|
|
5424
|
-
|
|
5036
|
+
outputError(result.code, result.error, opts.json);
|
|
5425
5037
|
}
|
|
5426
5038
|
}
|
|
5427
5039
|
async function removeBlacklistManager(tokenAddress, account, opts) {
|
|
@@ -5432,7 +5044,7 @@ async function removeBlacklistManager(tokenAddress, account, opts) {
|
|
|
5432
5044
|
const writeResult = opts.simulate ? await executor.simulate({ method: "removeBlacklistManager", args: [account, memo] }) : await executor.execute({ method: "removeBlacklistManager", args: [account, memo] });
|
|
5433
5045
|
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5434
5046
|
} else {
|
|
5435
|
-
|
|
5047
|
+
outputError(result.code, result.error, opts.json);
|
|
5436
5048
|
}
|
|
5437
5049
|
}
|
|
5438
5050
|
async function addMinter(tokenAddress, minter, allowance, opts) {
|
|
@@ -5443,7 +5055,7 @@ async function addMinter(tokenAddress, minter, allowance, opts) {
|
|
|
5443
5055
|
const writeResult = opts.simulate ? await executor.simulate({ method: "addMinter", args: [minter, BigInt(allowance), memo] }) : await executor.execute({ method: "addMinter", args: [minter, BigInt(allowance), memo] });
|
|
5444
5056
|
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5445
5057
|
} else {
|
|
5446
|
-
|
|
5058
|
+
outputError(result.code, result.error, opts.json);
|
|
5447
5059
|
}
|
|
5448
5060
|
}
|
|
5449
5061
|
async function removeMinter(tokenAddress, minter, opts) {
|
|
@@ -5454,7 +5066,7 @@ async function removeMinter(tokenAddress, minter, opts) {
|
|
|
5454
5066
|
const writeResult = opts.simulate ? await executor.simulate({ method: "removeMinter", args: [minter, memo] }) : await executor.execute({ method: "removeMinter", args: [minter, memo] });
|
|
5455
5067
|
console.log(formatWriteResult(writeResult, { simulate: opts.simulate, json: opts.json }, makeWriteMeta()));
|
|
5456
5068
|
} else {
|
|
5457
|
-
|
|
5069
|
+
outputError(result.code, result.error, opts.json);
|
|
5458
5070
|
}
|
|
5459
5071
|
}
|
|
5460
5072
|
function registerTokenWrite(token) {
|
|
@@ -5535,9 +5147,6 @@ function registerTokenWrite(token) {
|
|
|
5535
5147
|
var init_tokenWrite = __esm({
|
|
5536
5148
|
"src/cli/commands/tokenWrite.ts"() {
|
|
5537
5149
|
"use strict";
|
|
5538
|
-
init_env();
|
|
5539
|
-
init_sdk();
|
|
5540
|
-
init_writeExecutor();
|
|
5541
5150
|
loadEnv();
|
|
5542
5151
|
}
|
|
5543
5152
|
});
|
|
@@ -5550,8 +5159,11 @@ __export(token_exports, {
|
|
|
5550
5159
|
function formatBigInt(v) {
|
|
5551
5160
|
return v.toString();
|
|
5552
5161
|
}
|
|
5162
|
+
function jsonReplacer4(_key, value) {
|
|
5163
|
+
return typeof value === "bigint" ? value.toString() : value;
|
|
5164
|
+
}
|
|
5553
5165
|
async function tokenInfo(addr, json) {
|
|
5554
|
-
const client =
|
|
5166
|
+
const client = createClient2();
|
|
5555
5167
|
const [info2, stats] = await Promise.all([
|
|
5556
5168
|
client.rpc.token.getTokenInfo(addr),
|
|
5557
5169
|
client.rpc.token.getTokenStats(addr)
|
|
@@ -5571,7 +5183,7 @@ async function tokenInfo(addr, json) {
|
|
|
5571
5183
|
blacklistCount: parseBigIntToNumber(stats.blacklistCount.toString())
|
|
5572
5184
|
};
|
|
5573
5185
|
if (json) {
|
|
5574
|
-
console.log(JSON.stringify({ ok: true, data },
|
|
5186
|
+
console.log(JSON.stringify({ ok: true, data }, jsonReplacer4, 2));
|
|
5575
5187
|
} else {
|
|
5576
5188
|
console.log(`Address ${data.address}`);
|
|
5577
5189
|
console.log(`Name ${data.name}`);
|
|
@@ -5587,7 +5199,7 @@ async function tokenInfo(addr, json) {
|
|
|
5587
5199
|
}
|
|
5588
5200
|
}
|
|
5589
5201
|
async function tokenStats(addr, json) {
|
|
5590
|
-
const client =
|
|
5202
|
+
const client = createClient2();
|
|
5591
5203
|
const stats = await client.rpc.token.getTokenStats(addr);
|
|
5592
5204
|
const net = BigInt(stats.totalMinted) - BigInt(stats.totalBurned);
|
|
5593
5205
|
const data = {
|
|
@@ -5601,7 +5213,7 @@ async function tokenStats(addr, json) {
|
|
|
5601
5213
|
blacklistCount: parseBigIntToNumber(stats.blacklistCount.toString())
|
|
5602
5214
|
};
|
|
5603
5215
|
if (json) {
|
|
5604
|
-
console.log(JSON.stringify({ ok: true, data },
|
|
5216
|
+
console.log(JSON.stringify({ ok: true, data }, jsonReplacer4, 2));
|
|
5605
5217
|
} else {
|
|
5606
5218
|
console.log(`Address ${data.address}`);
|
|
5607
5219
|
console.log(`Holders ${data.holdersTotal}`);
|
|
@@ -5614,7 +5226,7 @@ async function tokenStats(addr, json) {
|
|
|
5614
5226
|
}
|
|
5615
5227
|
}
|
|
5616
5228
|
async function tokenRoles(addr, account, json) {
|
|
5617
|
-
const client =
|
|
5229
|
+
const client = createClient2();
|
|
5618
5230
|
const roles = await client.rpc.token.getUserRoles(addr, account);
|
|
5619
5231
|
const data = {
|
|
5620
5232
|
token: roles.address,
|
|
@@ -5626,7 +5238,7 @@ async function tokenRoles(addr, account, json) {
|
|
|
5626
5238
|
isMasterStatus: roles.isMasterStatus
|
|
5627
5239
|
};
|
|
5628
5240
|
if (json) {
|
|
5629
|
-
console.log(JSON.stringify({ ok: true, data },
|
|
5241
|
+
console.log(JSON.stringify({ ok: true, data }, jsonReplacer4, 2));
|
|
5630
5242
|
} else {
|
|
5631
5243
|
console.log(`Token ${data.token}`);
|
|
5632
5244
|
console.log(`Account ${data.account}`);
|
|
@@ -5638,7 +5250,7 @@ async function tokenRoles(addr, account, json) {
|
|
|
5638
5250
|
}
|
|
5639
5251
|
}
|
|
5640
5252
|
async function tokenHistory(addr, first, json) {
|
|
5641
|
-
const client =
|
|
5253
|
+
const client = createClient2();
|
|
5642
5254
|
const [mints, burns] = await Promise.all([
|
|
5643
5255
|
client.graph.token.getMintHistory(addr, first, 0),
|
|
5644
5256
|
client.graph.token.getBurnHistory(addr, first, 0)
|
|
@@ -5661,7 +5273,7 @@ async function tokenHistory(addr, first, json) {
|
|
|
5661
5273
|
];
|
|
5662
5274
|
events.sort((a, b) => BigInt(a.block) > BigInt(b.block) ? -1 : 1);
|
|
5663
5275
|
if (json) {
|
|
5664
|
-
console.log(JSON.stringify({ ok: true, data: { events } },
|
|
5276
|
+
console.log(JSON.stringify({ ok: true, data: { events } }, jsonReplacer4, 2));
|
|
5665
5277
|
} else {
|
|
5666
5278
|
console.log(`Token ${addr}`);
|
|
5667
5279
|
console.log(`Mint events ${mints.length} Burn events ${burns.length}`);
|
|
@@ -5671,10 +5283,10 @@ async function tokenHistory(addr, first, json) {
|
|
|
5671
5283
|
}
|
|
5672
5284
|
}
|
|
5673
5285
|
async function tokenMintHistory(addr, first, json) {
|
|
5674
|
-
const client =
|
|
5286
|
+
const client = createClient2();
|
|
5675
5287
|
const events = await client.graph.token.getMintHistory(addr, first, 0);
|
|
5676
5288
|
if (json) {
|
|
5677
|
-
console.log(JSON.stringify({ ok: true, data: { events } },
|
|
5289
|
+
console.log(JSON.stringify({ ok: true, data: { events } }, jsonReplacer4, 2));
|
|
5678
5290
|
} else {
|
|
5679
5291
|
console.log(`Token ${addr} \u2014 Mint History (${events.length} events)`);
|
|
5680
5292
|
events.slice(0, 10).forEach((e) => {
|
|
@@ -5683,10 +5295,10 @@ async function tokenMintHistory(addr, first, json) {
|
|
|
5683
5295
|
}
|
|
5684
5296
|
}
|
|
5685
5297
|
async function tokenBurnHistory(addr, first, json) {
|
|
5686
|
-
const client =
|
|
5298
|
+
const client = createClient2();
|
|
5687
5299
|
const events = await client.graph.token.getBurnHistory(addr, first, 0);
|
|
5688
5300
|
if (json) {
|
|
5689
|
-
console.log(JSON.stringify({ ok: true, data: { events } },
|
|
5301
|
+
console.log(JSON.stringify({ ok: true, data: { events } }, jsonReplacer4, 2));
|
|
5690
5302
|
} else {
|
|
5691
5303
|
console.log(`Token ${addr} \u2014 Burn History (${events.length} events)`);
|
|
5692
5304
|
events.slice(0, 10).forEach((e) => {
|
|
@@ -5695,7 +5307,7 @@ async function tokenBurnHistory(addr, first, json) {
|
|
|
5695
5307
|
}
|
|
5696
5308
|
}
|
|
5697
5309
|
async function tokenPauseHistory(addr, first, json) {
|
|
5698
|
-
const client =
|
|
5310
|
+
const client = createClient2();
|
|
5699
5311
|
const [pauseEvts, pausedEvts, unpausedEvts] = await Promise.all([
|
|
5700
5312
|
client.graph.token.getPauseHistory(addr, first, 0),
|
|
5701
5313
|
client.graph.token.getPausedByOwnerHistory(addr, first, 0),
|
|
@@ -5739,7 +5351,7 @@ var init_token = __esm({
|
|
|
5739
5351
|
init_sdk();
|
|
5740
5352
|
init_analytics();
|
|
5741
5353
|
init_tokenWrite();
|
|
5742
|
-
|
|
5354
|
+
loadEnv2();
|
|
5743
5355
|
}
|
|
5744
5356
|
});
|
|
5745
5357
|
|
|
@@ -5748,6 +5360,9 @@ var factory_exports = {};
|
|
|
5748
5360
|
__export(factory_exports, {
|
|
5749
5361
|
registerFactory: () => registerFactory
|
|
5750
5362
|
});
|
|
5363
|
+
function jsonReplacer5(_key, value) {
|
|
5364
|
+
return typeof value === "bigint" ? value.toString() : value;
|
|
5365
|
+
}
|
|
5751
5366
|
async function factoryInfo(json) {
|
|
5752
5367
|
const client = createClient();
|
|
5753
5368
|
const [beacon, platformAddr] = await Promise.all([
|
|
@@ -5761,7 +5376,7 @@ async function factoryInfo(json) {
|
|
|
5761
5376
|
chainId: client.config.chainId
|
|
5762
5377
|
};
|
|
5763
5378
|
if (json) {
|
|
5764
|
-
console.log(JSON.stringify({ ok: true, data },
|
|
5379
|
+
console.log(JSON.stringify({ ok: true, data }, jsonReplacer5, 2));
|
|
5765
5380
|
} else {
|
|
5766
5381
|
console.log(`Beacon ${data.beacon}`);
|
|
5767
5382
|
console.log(`Platform ${data.platform}`);
|
|
@@ -5774,18 +5389,18 @@ async function factoryCreate(name, symbol, opts) {
|
|
|
5774
5389
|
const client = createClient();
|
|
5775
5390
|
if (!client.config.addresses.factory) {
|
|
5776
5391
|
const msg = "ISOMETRY_FACTORY_ADDRESS is not configured";
|
|
5777
|
-
console.log(opts.json ? JSON.stringify({ ok: false, code: "NOT_CONFIGURED", message: msg },
|
|
5392
|
+
console.log(opts.json ? JSON.stringify({ ok: false, code: "NOT_CONFIGURED", message: msg }, jsonReplacer5, 2) : `\u274C ${msg}`);
|
|
5778
5393
|
return;
|
|
5779
5394
|
}
|
|
5780
5395
|
if (!client.config.privateKey) {
|
|
5781
5396
|
const msg = "ISOMETRY_PRIVATE_KEY is not set \u2014 cannot sign transactions";
|
|
5782
|
-
console.log(opts.json ? JSON.stringify({ ok: false, code: "NO_SIGNER", message: msg },
|
|
5397
|
+
console.log(opts.json ? JSON.stringify({ ok: false, code: "NO_SIGNER", message: msg }, jsonReplacer5, 2) : `\u274C ${msg}`);
|
|
5783
5398
|
return;
|
|
5784
5399
|
}
|
|
5785
5400
|
const wallet = createWallet(client.config.rpcUrl, client.config.privateKey);
|
|
5786
5401
|
if (!wallet.signer) {
|
|
5787
5402
|
const msg = "Wallet has no signer \u2014 check ISOMETRY_PRIVATE_KEY";
|
|
5788
|
-
console.log(opts.json ? JSON.stringify({ ok: false, code: "NO_SIGNER", message: msg },
|
|
5403
|
+
console.log(opts.json ? JSON.stringify({ ok: false, code: "NO_SIGNER", message: msg }, jsonReplacer5, 2) : `\u274C ${msg}`);
|
|
5789
5404
|
return;
|
|
5790
5405
|
}
|
|
5791
5406
|
const contracts = getContracts(client.config.addresses, wallet.signer);
|
|
@@ -5815,9 +5430,6 @@ function registerFactory(parent) {
|
|
|
5815
5430
|
var init_factory2 = __esm({
|
|
5816
5431
|
"src/cli/commands/factory.ts"() {
|
|
5817
5432
|
"use strict";
|
|
5818
|
-
init_env();
|
|
5819
|
-
init_sdk();
|
|
5820
|
-
init_writeExecutor();
|
|
5821
5433
|
loadEnv();
|
|
5822
5434
|
}
|
|
5823
5435
|
});
|