genlayer-js 0.19.2 → 0.19.4

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.cjs CHANGED
@@ -788,9 +788,13 @@ var _encodeSubmitAppealData = ({
788
788
  });
789
789
  };
790
790
  var isAddTransactionAbiMismatchError = (error) => {
791
- const errorMessage = String(
792
- _optionalChain([error, 'optionalAccess', _18 => _18.shortMessage]) || _optionalChain([error, 'optionalAccess', _19 => _19.details]) || _optionalChain([error, 'optionalAccess', _20 => _20.message]) || error || ""
793
- ).toLowerCase();
791
+ const errorObject = error;
792
+ const errorMessage = [
793
+ _optionalChain([errorObject, 'optionalAccess', _18 => _18.shortMessage]),
794
+ _optionalChain([errorObject, 'optionalAccess', _19 => _19.details]),
795
+ _optionalChain([errorObject, 'optionalAccess', _20 => _20.message]),
796
+ String(_nullishCoalesce(error, () => ( "")))
797
+ ].filter(Boolean).join(" ").toLowerCase();
794
798
  return errorMessage.includes("invalid pointer in tuple") || errorMessage.includes("could not decode") || errorMessage.includes("invalid arrayify value") || errorMessage.includes("types/value length mismatch");
795
799
  };
796
800
  var _sendTransaction = async ({
@@ -823,10 +827,10 @@ var _sendTransaction = async ({
823
827
  if (!_optionalChain([validatedSenderAccount, 'optionalAccess', _28 => _28.signTransaction])) {
824
828
  throw new Error("Account does not support signTransaction");
825
829
  }
826
- const gasPriceHex = await client.request({
830
+ const gasPriceHex2 = await client.request({
827
831
  method: "eth_gasPrice"
828
832
  });
829
- const transactionRequest2 = {
833
+ const transactionRequest = {
830
834
  account: validatedSenderAccount,
831
835
  to: _optionalChain([client, 'access', _29 => _29.chain, 'access', _30 => _30.consensusMainContract, 'optionalAccess', _31 => _31.address]),
832
836
  data: encodedDataForSend,
@@ -834,10 +838,10 @@ var _sendTransaction = async ({
834
838
  nonce: Number(nonce),
835
839
  value,
836
840
  gas: estimatedGas,
837
- gasPrice: BigInt(gasPriceHex),
841
+ gasPrice: BigInt(gasPriceHex2),
838
842
  chainId: client.chain.id
839
843
  };
840
- const serializedTransaction = await validatedSenderAccount.signTransaction(transactionRequest2);
844
+ const serializedTransaction = await validatedSenderAccount.signTransaction(transactionRequest);
841
845
  const txHash = await client.sendRawTransaction({ serializedTransaction });
842
846
  const receipt = await publicClient.waitForTransactionReceipt({ hash: txHash });
843
847
  if (receipt.status === "reverted") {
@@ -853,21 +857,29 @@ var _sendTransaction = async ({
853
857
  }
854
858
  return newTxEvents[0].args["txId"];
855
859
  }
856
- const transactionRequest = await client.prepareTransactionRequest({
857
- account: validatedSenderAccount,
858
- to: _optionalChain([client, 'access', _35 => _35.chain, 'access', _36 => _36.consensusMainContract, 'optionalAccess', _37 => _37.address]),
859
- data: encodedDataForSend,
860
- type: "legacy",
861
- nonce: Number(nonce),
862
- value,
863
- gas: estimatedGas
864
- });
860
+ let gasPriceHex;
861
+ try {
862
+ const gasPriceResult = await client.request({
863
+ method: "eth_gasPrice"
864
+ });
865
+ if (typeof gasPriceResult === "string") {
866
+ gasPriceHex = gasPriceResult;
867
+ }
868
+ } catch (error) {
869
+ console.warn("Failed to fetch gas price, delegating gas price selection to wallet:", error);
870
+ }
871
+ const nonceBigInt = typeof nonce === "bigint" ? nonce : typeof nonce === "string" ? BigInt(nonce) : BigInt(Number(nonce));
865
872
  const formattedRequest = {
866
- from: transactionRequest.from,
867
- to: transactionRequest.to,
873
+ from: validatedSenderAccount.address,
874
+ to: _optionalChain([client, 'access', _35 => _35.chain, 'access', _36 => _36.consensusMainContract, 'optionalAccess', _37 => _37.address]),
868
875
  data: encodedDataForSend,
869
- value: transactionRequest.value ? `0x${transactionRequest.value.toString(16)}` : "0x0",
870
- gas: transactionRequest.gas ? `0x${transactionRequest.gas.toString(16)}` : "0x5208"
876
+ value: `0x${value.toString(16)}`,
877
+ gas: `0x${estimatedGas.toString(16)}`,
878
+ nonce: `0x${nonceBigInt.toString(16)}`,
879
+ type: "0x0",
880
+ // legacy tx
881
+ chainId: `0x${client.chain.id.toString(16)}`,
882
+ ...gasPriceHex ? { gasPrice: gasPriceHex } : {}
871
883
  };
872
884
  return await client.request({
873
885
  method: "eth_sendTransaction",
package/dist/index.js CHANGED
@@ -788,9 +788,13 @@ var _encodeSubmitAppealData = ({
788
788
  });
789
789
  };
790
790
  var isAddTransactionAbiMismatchError = (error) => {
791
- const errorMessage = String(
792
- error?.shortMessage || error?.details || error?.message || error || ""
793
- ).toLowerCase();
791
+ const errorObject = error;
792
+ const errorMessage = [
793
+ errorObject?.shortMessage,
794
+ errorObject?.details,
795
+ errorObject?.message,
796
+ String(error ?? "")
797
+ ].filter(Boolean).join(" ").toLowerCase();
794
798
  return errorMessage.includes("invalid pointer in tuple") || errorMessage.includes("could not decode") || errorMessage.includes("invalid arrayify value") || errorMessage.includes("types/value length mismatch");
795
799
  };
796
800
  var _sendTransaction = async ({
@@ -823,10 +827,10 @@ var _sendTransaction = async ({
823
827
  if (!validatedSenderAccount?.signTransaction) {
824
828
  throw new Error("Account does not support signTransaction");
825
829
  }
826
- const gasPriceHex = await client.request({
830
+ const gasPriceHex2 = await client.request({
827
831
  method: "eth_gasPrice"
828
832
  });
829
- const transactionRequest2 = {
833
+ const transactionRequest = {
830
834
  account: validatedSenderAccount,
831
835
  to: client.chain.consensusMainContract?.address,
832
836
  data: encodedDataForSend,
@@ -834,10 +838,10 @@ var _sendTransaction = async ({
834
838
  nonce: Number(nonce),
835
839
  value,
836
840
  gas: estimatedGas,
837
- gasPrice: BigInt(gasPriceHex),
841
+ gasPrice: BigInt(gasPriceHex2),
838
842
  chainId: client.chain.id
839
843
  };
840
- const serializedTransaction = await validatedSenderAccount.signTransaction(transactionRequest2);
844
+ const serializedTransaction = await validatedSenderAccount.signTransaction(transactionRequest);
841
845
  const txHash = await client.sendRawTransaction({ serializedTransaction });
842
846
  const receipt = await publicClient.waitForTransactionReceipt({ hash: txHash });
843
847
  if (receipt.status === "reverted") {
@@ -853,21 +857,29 @@ var _sendTransaction = async ({
853
857
  }
854
858
  return newTxEvents[0].args["txId"];
855
859
  }
856
- const transactionRequest = await client.prepareTransactionRequest({
857
- account: validatedSenderAccount,
858
- to: client.chain.consensusMainContract?.address,
859
- data: encodedDataForSend,
860
- type: "legacy",
861
- nonce: Number(nonce),
862
- value,
863
- gas: estimatedGas
864
- });
860
+ let gasPriceHex;
861
+ try {
862
+ const gasPriceResult = await client.request({
863
+ method: "eth_gasPrice"
864
+ });
865
+ if (typeof gasPriceResult === "string") {
866
+ gasPriceHex = gasPriceResult;
867
+ }
868
+ } catch (error) {
869
+ console.warn("Failed to fetch gas price, delegating gas price selection to wallet:", error);
870
+ }
871
+ const nonceBigInt = typeof nonce === "bigint" ? nonce : typeof nonce === "string" ? BigInt(nonce) : BigInt(Number(nonce));
865
872
  const formattedRequest = {
866
- from: transactionRequest.from,
867
- to: transactionRequest.to,
873
+ from: validatedSenderAccount.address,
874
+ to: client.chain.consensusMainContract?.address,
868
875
  data: encodedDataForSend,
869
- value: transactionRequest.value ? `0x${transactionRequest.value.toString(16)}` : "0x0",
870
- gas: transactionRequest.gas ? `0x${transactionRequest.gas.toString(16)}` : "0x5208"
876
+ value: `0x${value.toString(16)}`,
877
+ gas: `0x${estimatedGas.toString(16)}`,
878
+ nonce: `0x${nonceBigInt.toString(16)}`,
879
+ type: "0x0",
880
+ // legacy tx
881
+ chainId: `0x${client.chain.id.toString(16)}`,
882
+ ...gasPriceHex ? { gasPrice: gasPriceHex } : {}
871
883
  };
872
884
  return await client.request({
873
885
  method: "eth_sendTransaction",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "genlayer-js",
3
3
  "type": "module",
4
- "version": "0.19.2",
4
+ "version": "0.19.4",
5
5
  "description": "GenLayer JavaScript SDK",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",