genlayer-js 0.19.3 → 0.19.5
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 +40 -18
- package/dist/index.js +40 -18
- package/package.json +1 -1
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,
|
|
@@ -827,10 +841,10 @@ var _sendTransaction = async ({
|
|
|
827
841
|
if (!_optionalChain([validatedSenderAccount, 'optionalAccess', _28 => _28.signTransaction])) {
|
|
828
842
|
throw new Error("Account does not support signTransaction");
|
|
829
843
|
}
|
|
830
|
-
const
|
|
844
|
+
const gasPriceHex2 = await client.request({
|
|
831
845
|
method: "eth_gasPrice"
|
|
832
846
|
});
|
|
833
|
-
const
|
|
847
|
+
const transactionRequest = {
|
|
834
848
|
account: validatedSenderAccount,
|
|
835
849
|
to: _optionalChain([client, 'access', _29 => _29.chain, 'access', _30 => _30.consensusMainContract, 'optionalAccess', _31 => _31.address]),
|
|
836
850
|
data: encodedDataForSend,
|
|
@@ -838,10 +852,10 @@ var _sendTransaction = async ({
|
|
|
838
852
|
nonce: Number(nonce),
|
|
839
853
|
value,
|
|
840
854
|
gas: estimatedGas,
|
|
841
|
-
gasPrice: BigInt(
|
|
855
|
+
gasPrice: BigInt(gasPriceHex2),
|
|
842
856
|
chainId: client.chain.id
|
|
843
857
|
};
|
|
844
|
-
const serializedTransaction = await validatedSenderAccount.signTransaction(
|
|
858
|
+
const serializedTransaction = await validatedSenderAccount.signTransaction(transactionRequest);
|
|
845
859
|
const txHash = await client.sendRawTransaction({ serializedTransaction });
|
|
846
860
|
const receipt = await publicClient.waitForTransactionReceipt({ hash: txHash });
|
|
847
861
|
if (receipt.status === "reverted") {
|
|
@@ -857,21 +871,29 @@ var _sendTransaction = async ({
|
|
|
857
871
|
}
|
|
858
872
|
return newTxEvents[0].args["txId"];
|
|
859
873
|
}
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
})
|
|
874
|
+
let gasPriceHex;
|
|
875
|
+
try {
|
|
876
|
+
const gasPriceResult = await client.request({
|
|
877
|
+
method: "eth_gasPrice"
|
|
878
|
+
});
|
|
879
|
+
if (typeof gasPriceResult === "string") {
|
|
880
|
+
gasPriceHex = gasPriceResult;
|
|
881
|
+
}
|
|
882
|
+
} catch (error) {
|
|
883
|
+
console.warn("Failed to fetch gas price, delegating gas price selection to wallet:", error);
|
|
884
|
+
}
|
|
885
|
+
const nonceBigInt = typeof nonce === "bigint" ? nonce : typeof nonce === "string" ? BigInt(nonce) : BigInt(Number(nonce));
|
|
869
886
|
const formattedRequest = {
|
|
870
|
-
from:
|
|
871
|
-
to:
|
|
887
|
+
from: validatedSenderAccount.address,
|
|
888
|
+
to: _optionalChain([client, 'access', _35 => _35.chain, 'access', _36 => _36.consensusMainContract, 'optionalAccess', _37 => _37.address]),
|
|
872
889
|
data: encodedDataForSend,
|
|
873
|
-
value:
|
|
874
|
-
gas:
|
|
890
|
+
value: `0x${value.toString(16)}`,
|
|
891
|
+
gas: `0x${estimatedGas.toString(16)}`,
|
|
892
|
+
nonce: `0x${nonceBigInt.toString(16)}`,
|
|
893
|
+
type: "0x0",
|
|
894
|
+
// legacy tx
|
|
895
|
+
chainId: `0x${client.chain.id.toString(16)}`,
|
|
896
|
+
...gasPriceHex ? { gasPrice: gasPriceHex } : {}
|
|
875
897
|
};
|
|
876
898
|
return await client.request({
|
|
877
899
|
method: "eth_sendTransaction",
|
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,
|
|
@@ -827,10 +841,10 @@ var _sendTransaction = async ({
|
|
|
827
841
|
if (!validatedSenderAccount?.signTransaction) {
|
|
828
842
|
throw new Error("Account does not support signTransaction");
|
|
829
843
|
}
|
|
830
|
-
const
|
|
844
|
+
const gasPriceHex2 = await client.request({
|
|
831
845
|
method: "eth_gasPrice"
|
|
832
846
|
});
|
|
833
|
-
const
|
|
847
|
+
const transactionRequest = {
|
|
834
848
|
account: validatedSenderAccount,
|
|
835
849
|
to: client.chain.consensusMainContract?.address,
|
|
836
850
|
data: encodedDataForSend,
|
|
@@ -838,10 +852,10 @@ var _sendTransaction = async ({
|
|
|
838
852
|
nonce: Number(nonce),
|
|
839
853
|
value,
|
|
840
854
|
gas: estimatedGas,
|
|
841
|
-
gasPrice: BigInt(
|
|
855
|
+
gasPrice: BigInt(gasPriceHex2),
|
|
842
856
|
chainId: client.chain.id
|
|
843
857
|
};
|
|
844
|
-
const serializedTransaction = await validatedSenderAccount.signTransaction(
|
|
858
|
+
const serializedTransaction = await validatedSenderAccount.signTransaction(transactionRequest);
|
|
845
859
|
const txHash = await client.sendRawTransaction({ serializedTransaction });
|
|
846
860
|
const receipt = await publicClient.waitForTransactionReceipt({ hash: txHash });
|
|
847
861
|
if (receipt.status === "reverted") {
|
|
@@ -857,21 +871,29 @@ var _sendTransaction = async ({
|
|
|
857
871
|
}
|
|
858
872
|
return newTxEvents[0].args["txId"];
|
|
859
873
|
}
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
})
|
|
874
|
+
let gasPriceHex;
|
|
875
|
+
try {
|
|
876
|
+
const gasPriceResult = await client.request({
|
|
877
|
+
method: "eth_gasPrice"
|
|
878
|
+
});
|
|
879
|
+
if (typeof gasPriceResult === "string") {
|
|
880
|
+
gasPriceHex = gasPriceResult;
|
|
881
|
+
}
|
|
882
|
+
} catch (error) {
|
|
883
|
+
console.warn("Failed to fetch gas price, delegating gas price selection to wallet:", error);
|
|
884
|
+
}
|
|
885
|
+
const nonceBigInt = typeof nonce === "bigint" ? nonce : typeof nonce === "string" ? BigInt(nonce) : BigInt(Number(nonce));
|
|
869
886
|
const formattedRequest = {
|
|
870
|
-
from:
|
|
871
|
-
to:
|
|
887
|
+
from: validatedSenderAccount.address,
|
|
888
|
+
to: client.chain.consensusMainContract?.address,
|
|
872
889
|
data: encodedDataForSend,
|
|
873
|
-
value:
|
|
874
|
-
gas:
|
|
890
|
+
value: `0x${value.toString(16)}`,
|
|
891
|
+
gas: `0x${estimatedGas.toString(16)}`,
|
|
892
|
+
nonce: `0x${nonceBigInt.toString(16)}`,
|
|
893
|
+
type: "0x0",
|
|
894
|
+
// legacy tx
|
|
895
|
+
chainId: `0x${client.chain.id.toString(16)}`,
|
|
896
|
+
...gasPriceHex ? { gasPrice: gasPriceHex } : {}
|
|
875
897
|
};
|
|
876
898
|
return await client.request({
|
|
877
899
|
method: "eth_sendTransaction",
|