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 +25 -17
- package/dist/index.js +25 -17
- package/package.json +1 -1
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
|
|
830
|
+
const gasPriceHex2 = await client.request({
|
|
831
831
|
method: "eth_gasPrice"
|
|
832
832
|
});
|
|
833
|
-
const
|
|
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(
|
|
841
|
+
gasPrice: BigInt(gasPriceHex2),
|
|
842
842
|
chainId: client.chain.id
|
|
843
843
|
};
|
|
844
|
-
const serializedTransaction = await validatedSenderAccount.signTransaction(
|
|
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
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
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:
|
|
871
|
-
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:
|
|
874
|
-
gas:
|
|
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
|
|
830
|
+
const gasPriceHex2 = await client.request({
|
|
831
831
|
method: "eth_gasPrice"
|
|
832
832
|
});
|
|
833
|
-
const
|
|
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(
|
|
841
|
+
gasPrice: BigInt(gasPriceHex2),
|
|
842
842
|
chainId: client.chain.id
|
|
843
843
|
};
|
|
844
|
-
const serializedTransaction = await validatedSenderAccount.signTransaction(
|
|
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
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
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:
|
|
871
|
-
to:
|
|
873
|
+
from: validatedSenderAccount.address,
|
|
874
|
+
to: client.chain.consensusMainContract?.address,
|
|
872
875
|
data: encodedDataForSend,
|
|
873
|
-
value:
|
|
874
|
-
gas:
|
|
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",
|