genlayer-js 0.19.3 → 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
@@ -827,10 +827,10 @@ var _sendTransaction = async ({
827
827
  if (!_optionalChain([validatedSenderAccount, 'optionalAccess', _28 => _28.signTransaction])) {
828
828
  throw new Error("Account does not support signTransaction");
829
829
  }
830
- const gasPriceHex = await client.request({
830
+ const gasPriceHex2 = await client.request({
831
831
  method: "eth_gasPrice"
832
832
  });
833
- const transactionRequest2 = {
833
+ const transactionRequest = {
834
834
  account: validatedSenderAccount,
835
835
  to: _optionalChain([client, 'access', _29 => _29.chain, 'access', _30 => _30.consensusMainContract, 'optionalAccess', _31 => _31.address]),
836
836
  data: encodedDataForSend,
@@ -838,10 +838,10 @@ var _sendTransaction = async ({
838
838
  nonce: Number(nonce),
839
839
  value,
840
840
  gas: estimatedGas,
841
- gasPrice: BigInt(gasPriceHex),
841
+ gasPrice: BigInt(gasPriceHex2),
842
842
  chainId: client.chain.id
843
843
  };
844
- const serializedTransaction = await validatedSenderAccount.signTransaction(transactionRequest2);
844
+ const serializedTransaction = await validatedSenderAccount.signTransaction(transactionRequest);
845
845
  const txHash = await client.sendRawTransaction({ serializedTransaction });
846
846
  const receipt = await publicClient.waitForTransactionReceipt({ hash: txHash });
847
847
  if (receipt.status === "reverted") {
@@ -857,21 +857,29 @@ var _sendTransaction = async ({
857
857
  }
858
858
  return newTxEvents[0].args["txId"];
859
859
  }
860
- const transactionRequest = await client.prepareTransactionRequest({
861
- account: validatedSenderAccount,
862
- to: _optionalChain([client, 'access', _35 => _35.chain, 'access', _36 => _36.consensusMainContract, 'optionalAccess', _37 => _37.address]),
863
- data: encodedDataForSend,
864
- type: "legacy",
865
- nonce: Number(nonce),
866
- value,
867
- gas: estimatedGas
868
- });
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));
869
872
  const formattedRequest = {
870
- from: transactionRequest.from,
871
- to: transactionRequest.to,
873
+ from: validatedSenderAccount.address,
874
+ to: _optionalChain([client, 'access', _35 => _35.chain, 'access', _36 => _36.consensusMainContract, 'optionalAccess', _37 => _37.address]),
872
875
  data: encodedDataForSend,
873
- value: transactionRequest.value ? `0x${transactionRequest.value.toString(16)}` : "0x0",
874
- 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 } : {}
875
883
  };
876
884
  return await client.request({
877
885
  method: "eth_sendTransaction",
package/dist/index.js CHANGED
@@ -827,10 +827,10 @@ var _sendTransaction = async ({
827
827
  if (!validatedSenderAccount?.signTransaction) {
828
828
  throw new Error("Account does not support signTransaction");
829
829
  }
830
- const gasPriceHex = await client.request({
830
+ const gasPriceHex2 = await client.request({
831
831
  method: "eth_gasPrice"
832
832
  });
833
- const transactionRequest2 = {
833
+ const transactionRequest = {
834
834
  account: validatedSenderAccount,
835
835
  to: client.chain.consensusMainContract?.address,
836
836
  data: encodedDataForSend,
@@ -838,10 +838,10 @@ var _sendTransaction = async ({
838
838
  nonce: Number(nonce),
839
839
  value,
840
840
  gas: estimatedGas,
841
- gasPrice: BigInt(gasPriceHex),
841
+ gasPrice: BigInt(gasPriceHex2),
842
842
  chainId: client.chain.id
843
843
  };
844
- const serializedTransaction = await validatedSenderAccount.signTransaction(transactionRequest2);
844
+ const serializedTransaction = await validatedSenderAccount.signTransaction(transactionRequest);
845
845
  const txHash = await client.sendRawTransaction({ serializedTransaction });
846
846
  const receipt = await publicClient.waitForTransactionReceipt({ hash: txHash });
847
847
  if (receipt.status === "reverted") {
@@ -857,21 +857,29 @@ var _sendTransaction = async ({
857
857
  }
858
858
  return newTxEvents[0].args["txId"];
859
859
  }
860
- const transactionRequest = await client.prepareTransactionRequest({
861
- account: validatedSenderAccount,
862
- to: client.chain.consensusMainContract?.address,
863
- data: encodedDataForSend,
864
- type: "legacy",
865
- nonce: Number(nonce),
866
- value,
867
- gas: estimatedGas
868
- });
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));
869
872
  const formattedRequest = {
870
- from: transactionRequest.from,
871
- to: transactionRequest.to,
873
+ from: validatedSenderAccount.address,
874
+ to: client.chain.consensusMainContract?.address,
872
875
  data: encodedDataForSend,
873
- value: transactionRequest.value ? `0x${transactionRequest.value.toString(16)}` : "0x0",
874
- 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 } : {}
875
883
  };
876
884
  return await client.request({
877
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.3",
4
+ "version": "0.19.4",
5
5
  "description": "GenLayer JavaScript SDK",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",