@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/dist/index.d.ts CHANGED
@@ -152,6 +152,8 @@ interface WriteError {
152
152
  code: WriteErrorCode;
153
153
  message: string;
154
154
  details?: unknown;
155
+ /** Raw 4-byte selector from the revert data, present when code is UNKNOWN or REVERT */
156
+ selector?: string;
155
157
  }
156
158
  type WriteResult = SimulateResult | ExecuteResult | WriteError;
157
159
  interface WriteCall {
@@ -170,6 +172,10 @@ declare class WriteExecutor {
170
172
  simulate(call: WriteCall): Promise<SimulateResult | WriteError>;
171
173
  /** Execute: sign and broadcast, wait for receipt. */
172
174
  execute(call: WriteCall, confirmations?: number): Promise<ExecuteResult | WriteError>;
175
+ /**
176
+ * Parse a revert error and extract { code, message, selector }.
177
+ * selector is always included for unknown errors so users can report it.
178
+ */
173
179
  private parseRevertError;
174
180
  }
175
181
  interface WriteOpts {
@@ -517,7 +523,7 @@ interface IsometryConfig {
517
523
  addresses?: ContractAddresses;
518
524
  privateKey?: string;
519
525
  }
520
- declare const SDK_VERSION = "0.4.0";
526
+ declare const SDK_VERSION = "0.4.2";
521
527
  declare class IsometryClient {
522
528
  readonly rpc: {
523
529
  platform: PlatformRpcService;
package/dist/index.js CHANGED
@@ -3956,7 +3956,8 @@ var WriteExecutor = class {
3956
3956
  ok: false,
3957
3957
  code: "SIMULATION_FAILED",
3958
3958
  message: `[simulate] ${decoded.message}`,
3959
- details: err
3959
+ details: err,
3960
+ ...decoded.selector ? { selector: decoded.selector } : {}
3960
3961
  };
3961
3962
  }
3962
3963
  }
@@ -4011,23 +4012,38 @@ var WriteExecutor = class {
4011
4012
  ok: false,
4012
4013
  code: decoded.code,
4013
4014
  message: decoded.message,
4014
- details: err
4015
+ details: err,
4016
+ ...decoded.selector ? { selector: decoded.selector } : {}
4015
4017
  };
4016
4018
  }
4017
4019
  }
4020
+ /**
4021
+ * Parse a revert error and extract { code, message, selector }.
4022
+ * selector is always included for unknown errors so users can report it.
4023
+ */
4018
4024
  parseRevertError(err) {
4025
+ let rawSelector;
4026
+ if (err && typeof err === "object") {
4027
+ const errObj = err;
4028
+ const data = errObj.data;
4029
+ if (data && data !== "0x" && data.length >= 10) {
4030
+ rawSelector = data.slice(0, 10).toLowerCase();
4031
+ }
4032
+ }
4019
4033
  if (err && typeof err === "object") {
4020
4034
  const decoded = decodeError(err);
4021
- if (decoded) return decoded;
4035
+ if (decoded) {
4036
+ return { code: decoded.code, message: decoded.message, selector: rawSelector };
4037
+ }
4022
4038
  }
4023
4039
  if (!(err instanceof Error)) {
4024
- return { code: "UNKNOWN", message: String(err) };
4040
+ return { code: "UNKNOWN", message: String(err), selector: rawSelector };
4025
4041
  }
4026
4042
  const msg = err.message;
4027
- if (msg.includes("insufficient funds")) return { code: "INSUFFICIENT_BALANCE", message: "insufficient funds for gas" };
4028
- if (msg.includes("nonce")) return { code: "RPC_ERROR", message: "nonce error (tx may already be mined)" };
4029
- if (msg.includes("read-only")) return { code: "NO_SIGNER", message: "wallet is read-only" };
4030
- return { code: "REVERT", message: msg.slice(0, 200) };
4043
+ if (msg.includes("insufficient funds")) return { code: "INSUFFICIENT_BALANCE", message: "insufficient funds for gas", selector: rawSelector };
4044
+ if (msg.includes("nonce")) return { code: "RPC_ERROR", message: "nonce error (tx may already be mined)", selector: rawSelector };
4045
+ if (msg.includes("read-only")) return { code: "NO_SIGNER", message: "wallet is read-only", selector: rawSelector };
4046
+ return { code: "REVERT", message: msg.slice(0, 200), selector: rawSelector };
4031
4047
  }
4032
4048
  };
4033
4049
  function makeWriteMeta(command) {
@@ -4725,7 +4741,7 @@ function resolveAddresses(env) {
4725
4741
  beacon: env.ISOMETRY_BEACON_ADDRESS ?? DEFAULT_ADDRESSES.beacon
4726
4742
  };
4727
4743
  }
4728
- var SDK_VERSION = "0.4.0";
4744
+ var SDK_VERSION = "0.4.2";
4729
4745
  var IsometryClient = class {
4730
4746
  rpc;
4731
4747
  graph;
@@ -4734,7 +4750,7 @@ var IsometryClient = class {
4734
4750
  _addresses;
4735
4751
  _chainId;
4736
4752
  constructor(config = {}) {
4737
- const rpcUrl = config.rpcUrl ?? process.env.ISOMETRY_RPC_URL ?? "";
4753
+ const rpcUrl = config.rpcUrl ?? process.env.ISOMETRY_RPC_URL ?? "https://ethereum-sepolia.publicnode.com";
4738
4754
  const graphUrl = config.graphUrl ?? process.env.ISOMETRY_GRAPH_URL ?? "https://console.isometry.network/graph/subgraphs/name/isometry";
4739
4755
  const privateKey = config.privateKey ?? process.env.ISOMETRY_PRIVATE_KEY;
4740
4756
  this._chainId = config.chainId ?? parseInt(process.env.ISOMETRY_CHAIN_ID ?? "11155111");