genlayer-js 0.19.4 → 0.20.0

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.
@@ -2753,6 +2753,9 @@ type GenLayerMethod = {
2753
2753
  } | {
2754
2754
  method: "gen_call";
2755
2755
  params: [requestParams: any];
2756
+ } | {
2757
+ method: "sim_cancelTransaction";
2758
+ params: [hash: TransactionHash, signature?: string, adminKey?: string];
2756
2759
  };
2757
2760
  type GenLayerClient<TGenLayerChain extends GenLayerChain> = Omit<Client<Transport, TGenLayerChain>, "getTransaction" | "readContract"> & Omit<WalletActions<TGenLayerChain>, "deployContract" | "writeContract"> & Omit<PublicActions<Transport, TGenLayerChain>, "readContract" | "getTransaction" | "waitForTransactionReceipt"> & {
2758
2761
  request: Client<Transport, TGenLayerChain>["request"] & {
@@ -2830,6 +2833,12 @@ type GenLayerClient<TGenLayerChain extends GenLayerChain> = Omit<Client<Transpor
2830
2833
  initializeConsensusSmartContract: (forceReset?: boolean) => Promise<void>;
2831
2834
  connect: (network?: Network, snapSource?: SnapSource) => Promise<void>;
2832
2835
  metamaskClient: (snapSource?: SnapSource) => Promise<MetaMaskClientResult>;
2836
+ cancelTransaction: (args: {
2837
+ hash: TransactionHash;
2838
+ }) => Promise<{
2839
+ transaction_hash: string;
2840
+ status: string;
2841
+ }>;
2833
2842
  appealTransaction: (args: {
2834
2843
  account?: Account;
2835
2844
  txId: `0x${string}`;
@@ -2753,6 +2753,9 @@ type GenLayerMethod = {
2753
2753
  } | {
2754
2754
  method: "gen_call";
2755
2755
  params: [requestParams: any];
2756
+ } | {
2757
+ method: "sim_cancelTransaction";
2758
+ params: [hash: TransactionHash, signature?: string, adminKey?: string];
2756
2759
  };
2757
2760
  type GenLayerClient<TGenLayerChain extends GenLayerChain> = Omit<Client<Transport, TGenLayerChain>, "getTransaction" | "readContract"> & Omit<WalletActions<TGenLayerChain>, "deployContract" | "writeContract"> & Omit<PublicActions<Transport, TGenLayerChain>, "readContract" | "getTransaction" | "waitForTransactionReceipt"> & {
2758
2761
  request: Client<Transport, TGenLayerChain>["request"] & {
@@ -2830,6 +2833,12 @@ type GenLayerClient<TGenLayerChain extends GenLayerChain> = Omit<Client<Transpor
2830
2833
  initializeConsensusSmartContract: (forceReset?: boolean) => Promise<void>;
2831
2834
  connect: (network?: Network, snapSource?: SnapSource) => Promise<void>;
2832
2835
  metamaskClient: (snapSource?: SnapSource) => Promise<MetaMaskClientResult>;
2836
+ cancelTransaction: (args: {
2837
+ hash: TransactionHash;
2838
+ }) => Promise<{
2839
+ transaction_hash: string;
2840
+ status: string;
2841
+ }>;
2833
2842
  appealTransaction: (args: {
2834
2843
  account?: Account;
2835
2844
  txId: `0x${string}`;
package/dist/index.cjs CHANGED
@@ -788,14 +788,28 @@ var _encodeSubmitAppealData = ({
788
788
  });
789
789
  };
790
790
  var isAddTransactionAbiMismatchError = (error) => {
791
+ const seen = /* @__PURE__ */ new WeakSet();
792
+ const serializedError = typeof error === "object" && error !== null ? JSON.stringify(error, (_key, value) => {
793
+ if (typeof value === "bigint") {
794
+ return value.toString();
795
+ }
796
+ if (typeof value === "object" && value !== null) {
797
+ if (seen.has(value)) {
798
+ return "[Circular]";
799
+ }
800
+ seen.add(value);
801
+ }
802
+ return value;
803
+ }) : "";
791
804
  const errorObject = error;
792
805
  const errorMessage = [
793
806
  _optionalChain([errorObject, 'optionalAccess', _18 => _18.shortMessage]),
794
807
  _optionalChain([errorObject, 'optionalAccess', _19 => _19.details]),
795
808
  _optionalChain([errorObject, 'optionalAccess', _20 => _20.message]),
809
+ serializedError,
796
810
  String(_nullishCoalesce(error, () => ( "")))
797
811
  ].filter(Boolean).join(" ").toLowerCase();
798
- return errorMessage.includes("invalid pointer in tuple") || errorMessage.includes("could not decode") || errorMessage.includes("invalid arrayify value") || errorMessage.includes("types/value length mismatch");
812
+ return errorMessage.includes("invalid pointer in tuple") || errorMessage.includes("invalid pointer") || errorMessage.includes("could not decode") || errorMessage.includes("invalid arrayify value") || errorMessage.includes("types/value length mismatch");
799
813
  };
800
814
  var _sendTransaction = async ({
801
815
  client,
@@ -907,6 +921,9 @@ async function sleep(ms) {
907
921
  return new Promise((resolve) => setTimeout(resolve, ms));
908
922
  }
909
923
 
924
+ // src/transactions/actions.ts
925
+
926
+
910
927
  // src/transactions/decoders.ts
911
928
 
912
929
  var FIELDS_TO_REMOVE = [
@@ -1204,6 +1221,33 @@ var transactionActions = (client, publicClient) => ({
1204
1221
  });
1205
1222
  return decodeTransaction(transaction);
1206
1223
  },
1224
+ cancelTransaction: async ({ hash }) => {
1225
+ if (!client.chain.isStudio) {
1226
+ throw new Error("cancelTransaction is only available on studio-based chains (localnet/studionet)");
1227
+ }
1228
+ if (!client.account) {
1229
+ throw new Error("No account set. Configure the client with an account to cancel transactions.");
1230
+ }
1231
+ const messageHash = _viem.keccak256.call(void 0, _viem.concat.call(void 0, [_viem.stringToBytes.call(void 0, "cancel_transaction"), _viem.toBytes.call(void 0, hash)]));
1232
+ let signature;
1233
+ if (typeof client.account === "object" && "signMessage" in client.account) {
1234
+ signature = await client.account.signMessage({ message: { raw: messageHash } });
1235
+ } else {
1236
+ const provider = typeof window !== "undefined" ? window.ethereum : void 0;
1237
+ if (!provider) {
1238
+ throw new Error("No provider available for signing. Use a private key account or ensure a wallet is connected.");
1239
+ }
1240
+ const address = typeof client.account === "string" ? client.account : client.account.address;
1241
+ signature = await provider.request({
1242
+ method: "personal_sign",
1243
+ params: [messageHash, address]
1244
+ });
1245
+ }
1246
+ return client.request({
1247
+ method: "sim_cancelTransaction",
1248
+ params: [hash, signature]
1249
+ });
1250
+ },
1207
1251
  estimateTransactionGas: async (transactionParams) => {
1208
1252
  const formattedParams = {
1209
1253
  from: transactionParams.from || _optionalChain([client, 'access', _48 => _48.account, 'optionalAccess', _49 => _49.address]),
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as viem from 'viem';
2
2
  import { Account, Address, Hex } from 'viem';
3
3
  import { G as GenLayerChain } from './chains-B7B7UXdn.cjs';
4
- import { G as GenLayerClient, D as DecodedDeployData, a as DecodedCallData, b as GenLayerRawTransaction, c as GenLayerTransaction, C as CalldataEncodable, T as TransactionDataElement, S as STAKING_ABI, V as VALIDATOR_WALLET_ABI, d as ContractSchema } from './index-CYszVbTS.cjs';
4
+ import { G as GenLayerClient, D as DecodedDeployData, a as DecodedCallData, b as GenLayerRawTransaction, c as GenLayerTransaction, C as CalldataEncodable, T as TransactionDataElement, S as STAKING_ABI, V as VALIDATOR_WALLET_ABI, d as ContractSchema } from './index-TroH9NJL.cjs';
5
5
  import * as abitype from 'abitype';
6
6
  import * as viem__types_types_authorization from 'viem/_types/types/authorization';
7
7
  import * as viem_accounts from 'viem/accounts';
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as viem from 'viem';
2
2
  import { Account, Address, Hex } from 'viem';
3
3
  import { G as GenLayerChain } from './chains-B7B7UXdn.js';
4
- import { G as GenLayerClient, D as DecodedDeployData, a as DecodedCallData, b as GenLayerRawTransaction, c as GenLayerTransaction, C as CalldataEncodable, T as TransactionDataElement, S as STAKING_ABI, V as VALIDATOR_WALLET_ABI, d as ContractSchema } from './index-CbVqYeWa.js';
4
+ import { G as GenLayerClient, D as DecodedDeployData, a as DecodedCallData, b as GenLayerRawTransaction, c as GenLayerTransaction, C as CalldataEncodable, T as TransactionDataElement, S as STAKING_ABI, V as VALIDATOR_WALLET_ABI, d as ContractSchema } from './index-DmoVRP1E.js';
5
5
  import * as abitype from 'abitype';
6
6
  import * as viem__types_types_authorization from 'viem/_types/types/authorization';
7
7
  import * as viem_accounts from 'viem/accounts';
package/dist/index.js CHANGED
@@ -788,14 +788,28 @@ var _encodeSubmitAppealData = ({
788
788
  });
789
789
  };
790
790
  var isAddTransactionAbiMismatchError = (error) => {
791
+ const seen = /* @__PURE__ */ new WeakSet();
792
+ const serializedError = typeof error === "object" && error !== null ? JSON.stringify(error, (_key, value) => {
793
+ if (typeof value === "bigint") {
794
+ return value.toString();
795
+ }
796
+ if (typeof value === "object" && value !== null) {
797
+ if (seen.has(value)) {
798
+ return "[Circular]";
799
+ }
800
+ seen.add(value);
801
+ }
802
+ return value;
803
+ }) : "";
791
804
  const errorObject = error;
792
805
  const errorMessage = [
793
806
  errorObject?.shortMessage,
794
807
  errorObject?.details,
795
808
  errorObject?.message,
809
+ serializedError,
796
810
  String(error ?? "")
797
811
  ].filter(Boolean).join(" ").toLowerCase();
798
- return errorMessage.includes("invalid pointer in tuple") || errorMessage.includes("could not decode") || errorMessage.includes("invalid arrayify value") || errorMessage.includes("types/value length mismatch");
812
+ return errorMessage.includes("invalid pointer in tuple") || errorMessage.includes("invalid pointer") || errorMessage.includes("could not decode") || errorMessage.includes("invalid arrayify value") || errorMessage.includes("types/value length mismatch");
799
813
  };
800
814
  var _sendTransaction = async ({
801
815
  client,
@@ -907,6 +921,9 @@ async function sleep(ms) {
907
921
  return new Promise((resolve) => setTimeout(resolve, ms));
908
922
  }
909
923
 
924
+ // src/transactions/actions.ts
925
+ import { keccak256, concat, stringToBytes, toBytes } from "viem";
926
+
910
927
  // src/transactions/decoders.ts
911
928
  import { fromRlp, fromHex as fromHex2 } from "viem";
912
929
  var FIELDS_TO_REMOVE = [
@@ -1204,6 +1221,33 @@ var transactionActions = (client, publicClient) => ({
1204
1221
  });
1205
1222
  return decodeTransaction(transaction);
1206
1223
  },
1224
+ cancelTransaction: async ({ hash }) => {
1225
+ if (!client.chain.isStudio) {
1226
+ throw new Error("cancelTransaction is only available on studio-based chains (localnet/studionet)");
1227
+ }
1228
+ if (!client.account) {
1229
+ throw new Error("No account set. Configure the client with an account to cancel transactions.");
1230
+ }
1231
+ const messageHash = keccak256(concat([stringToBytes("cancel_transaction"), toBytes(hash)]));
1232
+ let signature;
1233
+ if (typeof client.account === "object" && "signMessage" in client.account) {
1234
+ signature = await client.account.signMessage({ message: { raw: messageHash } });
1235
+ } else {
1236
+ const provider = typeof window !== "undefined" ? window.ethereum : void 0;
1237
+ if (!provider) {
1238
+ throw new Error("No provider available for signing. Use a private key account or ensure a wallet is connected.");
1239
+ }
1240
+ const address = typeof client.account === "string" ? client.account : client.account.address;
1241
+ signature = await provider.request({
1242
+ method: "personal_sign",
1243
+ params: [messageHash, address]
1244
+ });
1245
+ }
1246
+ return client.request({
1247
+ method: "sim_cancelTransaction",
1248
+ params: [hash, signature]
1249
+ });
1250
+ },
1207
1251
  estimateTransactionGas: async (transactionParams) => {
1208
1252
  const formattedParams = {
1209
1253
  from: transactionParams.from || client.account?.address,
@@ -1,3 +1,3 @@
1
1
  export { Account, Address } from 'viem';
2
- export { I as BannedValidatorInfo, e as CalldataAddress, C as CalldataEncodable, j as ContractMethod, i as ContractMethodBase, g as ContractParamsArraySchemaElement, h as ContractParamsSchema, d as ContractSchema, o as DECIDED_STATES, a as DecodedCallData, D as DecodedDeployData, a4 as DelegatorClaimOptions, a3 as DelegatorExitOptions, a2 as DelegatorJoinOptions, U as DelegatorJoinResult, K as EpochData, O as EpochInfo, G as GenLayerClient, f as GenLayerMethod, b as GenLayerRawTransaction, c as GenLayerTransaction, H as Hash, L as LeaderReceipt, M as MethodDescription, N as Network, P as PendingDeposit, F as PendingWithdrawal, a1 as SetIdentityOptions, a0 as SetOperatorOptions, y as SnapSource, J as StakeInfo, a5 as StakingActions, z as StakingContract, Q as StakingTransactionResult, k as TransactionHash, x as TransactionHashVariant, m as TransactionResult, r as TransactionResultNameToNumber, l as TransactionStatus, w as TransactionType, _ as ValidatorClaimOptions, Y as ValidatorDepositOptions, Z as ValidatorExitOptions, B as ValidatorIdentity, E as ValidatorInfo, X as ValidatorJoinOptions, R as ValidatorJoinResult, $ as ValidatorPrimeOptions, A as ValidatorView, s as VoteType, W as WithdrawalCommit, p as isDecidedState, q as transactionResultNumberToName, n as transactionsStatusNameToNumber, t as transactionsStatusNumberToName, u as voteTypeNameToNumber, v as voteTypeNumberToName } from '../index-CYszVbTS.cjs';
2
+ export { I as BannedValidatorInfo, e as CalldataAddress, C as CalldataEncodable, j as ContractMethod, i as ContractMethodBase, g as ContractParamsArraySchemaElement, h as ContractParamsSchema, d as ContractSchema, o as DECIDED_STATES, a as DecodedCallData, D as DecodedDeployData, a4 as DelegatorClaimOptions, a3 as DelegatorExitOptions, a2 as DelegatorJoinOptions, U as DelegatorJoinResult, K as EpochData, O as EpochInfo, G as GenLayerClient, f as GenLayerMethod, b as GenLayerRawTransaction, c as GenLayerTransaction, H as Hash, L as LeaderReceipt, M as MethodDescription, N as Network, P as PendingDeposit, F as PendingWithdrawal, a1 as SetIdentityOptions, a0 as SetOperatorOptions, y as SnapSource, J as StakeInfo, a5 as StakingActions, z as StakingContract, Q as StakingTransactionResult, k as TransactionHash, x as TransactionHashVariant, m as TransactionResult, r as TransactionResultNameToNumber, l as TransactionStatus, w as TransactionType, _ as ValidatorClaimOptions, Y as ValidatorDepositOptions, Z as ValidatorExitOptions, B as ValidatorIdentity, E as ValidatorInfo, X as ValidatorJoinOptions, R as ValidatorJoinResult, $ as ValidatorPrimeOptions, A as ValidatorView, s as VoteType, W as WithdrawalCommit, p as isDecidedState, q as transactionResultNumberToName, n as transactionsStatusNameToNumber, t as transactionsStatusNumberToName, u as voteTypeNameToNumber, v as voteTypeNumberToName } from '../index-TroH9NJL.cjs';
3
3
  export { G as GenLayerChain } from '../chains-B7B7UXdn.cjs';
@@ -1,3 +1,3 @@
1
1
  export { Account, Address } from 'viem';
2
- export { I as BannedValidatorInfo, e as CalldataAddress, C as CalldataEncodable, j as ContractMethod, i as ContractMethodBase, g as ContractParamsArraySchemaElement, h as ContractParamsSchema, d as ContractSchema, o as DECIDED_STATES, a as DecodedCallData, D as DecodedDeployData, a4 as DelegatorClaimOptions, a3 as DelegatorExitOptions, a2 as DelegatorJoinOptions, U as DelegatorJoinResult, K as EpochData, O as EpochInfo, G as GenLayerClient, f as GenLayerMethod, b as GenLayerRawTransaction, c as GenLayerTransaction, H as Hash, L as LeaderReceipt, M as MethodDescription, N as Network, P as PendingDeposit, F as PendingWithdrawal, a1 as SetIdentityOptions, a0 as SetOperatorOptions, y as SnapSource, J as StakeInfo, a5 as StakingActions, z as StakingContract, Q as StakingTransactionResult, k as TransactionHash, x as TransactionHashVariant, m as TransactionResult, r as TransactionResultNameToNumber, l as TransactionStatus, w as TransactionType, _ as ValidatorClaimOptions, Y as ValidatorDepositOptions, Z as ValidatorExitOptions, B as ValidatorIdentity, E as ValidatorInfo, X as ValidatorJoinOptions, R as ValidatorJoinResult, $ as ValidatorPrimeOptions, A as ValidatorView, s as VoteType, W as WithdrawalCommit, p as isDecidedState, q as transactionResultNumberToName, n as transactionsStatusNameToNumber, t as transactionsStatusNumberToName, u as voteTypeNameToNumber, v as voteTypeNumberToName } from '../index-CbVqYeWa.js';
2
+ export { I as BannedValidatorInfo, e as CalldataAddress, C as CalldataEncodable, j as ContractMethod, i as ContractMethodBase, g as ContractParamsArraySchemaElement, h as ContractParamsSchema, d as ContractSchema, o as DECIDED_STATES, a as DecodedCallData, D as DecodedDeployData, a4 as DelegatorClaimOptions, a3 as DelegatorExitOptions, a2 as DelegatorJoinOptions, U as DelegatorJoinResult, K as EpochData, O as EpochInfo, G as GenLayerClient, f as GenLayerMethod, b as GenLayerRawTransaction, c as GenLayerTransaction, H as Hash, L as LeaderReceipt, M as MethodDescription, N as Network, P as PendingDeposit, F as PendingWithdrawal, a1 as SetIdentityOptions, a0 as SetOperatorOptions, y as SnapSource, J as StakeInfo, a5 as StakingActions, z as StakingContract, Q as StakingTransactionResult, k as TransactionHash, x as TransactionHashVariant, m as TransactionResult, r as TransactionResultNameToNumber, l as TransactionStatus, w as TransactionType, _ as ValidatorClaimOptions, Y as ValidatorDepositOptions, Z as ValidatorExitOptions, B as ValidatorIdentity, E as ValidatorInfo, X as ValidatorJoinOptions, R as ValidatorJoinResult, $ as ValidatorPrimeOptions, A as ValidatorView, s as VoteType, W as WithdrawalCommit, p as isDecidedState, q as transactionResultNumberToName, n as transactionsStatusNameToNumber, t as transactionsStatusNumberToName, u as voteTypeNameToNumber, v as voteTypeNumberToName } from '../index-DmoVRP1E.js';
3
3
  export { G as GenLayerChain } from '../chains-B7B7UXdn.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "genlayer-js",
3
3
  "type": "module",
4
- "version": "0.19.4",
4
+ "version": "0.20.0",
5
5
  "description": "GenLayer JavaScript SDK",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",