thirdweb 5.117.0 → 5.117.1
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/cjs/transaction/actions/zksync/send-eip712-transaction.js +46 -14
- package/dist/cjs/transaction/actions/zksync/send-eip712-transaction.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/transaction/actions/zksync/send-eip712-transaction.js +46 -14
- package/dist/esm/transaction/actions/zksync/send-eip712-transaction.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/scripts/bridge-widget.js +99 -99
- package/dist/types/transaction/actions/zksync/send-eip712-transaction.d.ts +1 -1
- package/dist/types/transaction/actions/zksync/send-eip712-transaction.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/transaction/actions/zksync/send-eip712-transaction.test.ts +35 -1
- package/src/transaction/actions/zksync/send-eip712-transaction.ts +53 -19
- package/src/version.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"send-eip712-transaction.d.ts","sourceRoot":"","sources":["../../../../../src/transaction/actions/zksync/send-eip712-transaction.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,OAAO,EAAc,MAAM,2BAA2B,CAAC;AAGrE,OAAO,EAAE,KAAK,GAAG,EAAS,MAAM,gCAAgC,CAAC;AAEjE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uCAAuC,CAAC;AACrE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAGxE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EACL,KAAK,6BAA6B,EAGnC,MAAM,sBAAsB,CAAC;AAE9B,KAAK,4BAA4B,GAAG;IAClC,OAAO,EAAE,OAAO,CAAC;IAGjB,WAAW,EAAE,mBAAmB,CAAC,GAAG,CAAC,CAAC;CACvC,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,4BAA4B,GACpC,OAAO,CAAC,qBAAqB,CAAC,CAmBhC;AAED,wBAAsB,qBAAqB,CAAC,OAAO,EAAE;IACnD,OAAO,EAAE,OAAO,CAAC;IACjB,iBAAiB,EAAE,6BAA6B,CAAC;IACjD,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC,GAAG,CAAC,CAef;AAED;;;;GAIG;AACH,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,4BAA4B,GACpC,OAAO,CAAC,6BAA6B,CAAC,CAsBxC;AAgDD,wBAAsB,YAAY,CAAC,IAAI,EAAE;IACvC,WAAW,EAAE,mBAAmB,CAAC;IACjC,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;;;;;
|
|
1
|
+
{"version":3,"file":"send-eip712-transaction.d.ts","sourceRoot":"","sources":["../../../../../src/transaction/actions/zksync/send-eip712-transaction.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,OAAO,EAAc,MAAM,2BAA2B,CAAC;AAGrE,OAAO,EAAE,KAAK,GAAG,EAAS,MAAM,gCAAgC,CAAC;AAEjE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uCAAuC,CAAC;AACrE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAGxE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EACL,KAAK,6BAA6B,EAGnC,MAAM,sBAAsB,CAAC;AAE9B,KAAK,4BAA4B,GAAG;IAClC,OAAO,EAAE,OAAO,CAAC;IAGjB,WAAW,EAAE,mBAAmB,CAAC,GAAG,CAAC,CAAC;CACvC,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,4BAA4B,GACpC,OAAO,CAAC,qBAAqB,CAAC,CAmBhC;AAED,wBAAsB,qBAAqB,CAAC,OAAO,EAAE;IACnD,OAAO,EAAE,OAAO,CAAC;IACjB,iBAAiB,EAAE,6BAA6B,CAAC;IACjD,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC,GAAG,CAAC,CAef;AAED;;;;GAIG;AACH,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,4BAA4B,GACpC,OAAO,CAAC,6BAA6B,CAAC,CAsBxC;AAgDD,wBAAsB,YAAY,CAAC,IAAI,EAAE;IACvC,WAAW,EAAE,mBAAmB,CAAC;IACjC,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;;;;;GA6EA"}
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "5.117.
|
|
1
|
+
export declare const version = "5.117.1";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/package.json
CHANGED
|
@@ -5,9 +5,13 @@ import {
|
|
|
5
5
|
TEST_ACCOUNT_B,
|
|
6
6
|
} from "../../../../test/src/test-wallets.js";
|
|
7
7
|
import { zkSyncSepolia } from "../../../chains/chain-definitions/zksync-sepolia.js";
|
|
8
|
+
import { defineChain } from "../../../chains/utils.js";
|
|
8
9
|
import { deployPublishedContract } from "../../../extensions/prebuilts/deploy-published.js";
|
|
9
10
|
import { prepareTransaction } from "../../prepare-transaction.js";
|
|
10
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
getZkGasFees,
|
|
13
|
+
sendEip712Transaction,
|
|
14
|
+
} from "./send-eip712-transaction.js";
|
|
11
15
|
|
|
12
16
|
describe("sendEip712Transaction", () => {
|
|
13
17
|
// re-enable for testing, but disable for CI since it requires testnet funds
|
|
@@ -52,4 +56,34 @@ describe("sendEip712Transaction", () => {
|
|
|
52
56
|
expect(address).toBeDefined();
|
|
53
57
|
expect(address.length).toBe(42);
|
|
54
58
|
});
|
|
59
|
+
|
|
60
|
+
it("should fallback to standard EVM methods when zks_estimateFee is not available", async () => {
|
|
61
|
+
// Chain 278701 is a zkSync chain that doesn't support zks_estimateFee
|
|
62
|
+
const zkSyncChainWithoutZksSupport = defineChain(278701);
|
|
63
|
+
|
|
64
|
+
// Use a transaction with pre-defined gas to skip estimation (which requires balance)
|
|
65
|
+
// This tests that the fallback path is taken for fee estimation
|
|
66
|
+
const transaction = prepareTransaction({
|
|
67
|
+
chain: zkSyncChainWithoutZksSupport,
|
|
68
|
+
client: TEST_CLIENT,
|
|
69
|
+
gas: 21000n, // pre-define gas to skip eth_estimateGas
|
|
70
|
+
to: TEST_ACCOUNT_B.address,
|
|
71
|
+
value: 0n,
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const gasFees = await getZkGasFees({
|
|
75
|
+
transaction,
|
|
76
|
+
from: TEST_ACCOUNT_A.address as `0x${string}`,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// Verify fallback worked - should have valid gas values
|
|
80
|
+
expect(gasFees.gas).toBeDefined();
|
|
81
|
+
expect(gasFees.gas).toBeGreaterThan(0n);
|
|
82
|
+
expect(gasFees.maxFeePerGas).toBeDefined();
|
|
83
|
+
expect(gasFees.maxFeePerGas).toBeGreaterThan(0n);
|
|
84
|
+
expect(gasFees.maxPriorityFeePerGas).toBeDefined();
|
|
85
|
+
expect(gasFees.maxPriorityFeePerGas).toBeGreaterThan(0n);
|
|
86
|
+
// Fallback should use 100k for gasPerPubdata
|
|
87
|
+
expect(gasFees.gasPerPubdata).toBe(100000n);
|
|
88
|
+
});
|
|
55
89
|
});
|
|
@@ -180,25 +180,59 @@ export async function getZkGasFees(args: {
|
|
|
180
180
|
) {
|
|
181
181
|
const rpc = getRpcClient(transaction);
|
|
182
182
|
const params = await formatTransaction({ from, transaction });
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
gasPerPubdata =
|
|
183
|
+
|
|
184
|
+
// Try zkSync-specific fee estimation first, fallback to standard EVM methods
|
|
185
|
+
try {
|
|
186
|
+
const result = (await rpc({
|
|
187
|
+
// biome-ignore lint/suspicious/noExplicitAny: TODO add to RPC method types
|
|
188
|
+
method: "zks_estimateFee" as any,
|
|
189
|
+
// biome-ignore lint/suspicious/noExplicitAny: TODO add to RPC method types
|
|
190
|
+
params: [replaceBigInts(params, toHex)] as any,
|
|
191
|
+
})) as {
|
|
192
|
+
gas_limit: string;
|
|
193
|
+
max_fee_per_gas: string;
|
|
194
|
+
max_priority_fee_per_gas: string;
|
|
195
|
+
gas_per_pubdata_limit: string;
|
|
196
|
+
};
|
|
197
|
+
gas = toBigInt(result.gas_limit) * 2n; // overestimating to avoid issues when not accounting for paymaster extra gas ( we should really pass the paymaster input above for better accuracy )
|
|
198
|
+
const baseFee = toBigInt(result.max_fee_per_gas);
|
|
199
|
+
maxFeePerGas = baseFee * 2n; // bumping the base fee per gas to ensure fast inclusion
|
|
200
|
+
maxPriorityFeePerGas = toBigInt(result.max_priority_fee_per_gas) || 1n;
|
|
201
|
+
gasPerPubdata = toBigInt(result.gas_per_pubdata_limit) * 2n; // doubling for fast inclusion;
|
|
202
|
+
if (gasPerPubdata < 50000n) {
|
|
203
|
+
// enforce a minimum gas per pubdata limit
|
|
204
|
+
gasPerPubdata = 50000n;
|
|
205
|
+
}
|
|
206
|
+
} catch {
|
|
207
|
+
// Fallback to standard EVM methods if zks_estimateFee is not available
|
|
208
|
+
const [{ estimateGas }, { getDefaultGasOverrides }] = await Promise.all([
|
|
209
|
+
import("../estimate-gas.js"),
|
|
210
|
+
import("../../../gas/fee-data.js"),
|
|
211
|
+
]);
|
|
212
|
+
|
|
213
|
+
const [estimatedGas, gasOverrides] = await Promise.all([
|
|
214
|
+
gas === undefined
|
|
215
|
+
? estimateGas({ transaction, from })
|
|
216
|
+
: Promise.resolve(gas),
|
|
217
|
+
getDefaultGasOverrides(transaction.client, transaction.chain),
|
|
218
|
+
]);
|
|
219
|
+
|
|
220
|
+
gas = estimatedGas * 2n; // overestimating similar to zkSync estimation
|
|
221
|
+
if ("maxFeePerGas" in gasOverrides && gasOverrides.maxFeePerGas) {
|
|
222
|
+
maxFeePerGas = gasOverrides.maxFeePerGas * 2n; // bumping for fast inclusion
|
|
223
|
+
} else if ("gasPrice" in gasOverrides && gasOverrides.gasPrice) {
|
|
224
|
+
maxFeePerGas = gasOverrides.gasPrice * 2n;
|
|
225
|
+
}
|
|
226
|
+
if (
|
|
227
|
+
"maxPriorityFeePerGas" in gasOverrides &&
|
|
228
|
+
gasOverrides.maxPriorityFeePerGas
|
|
229
|
+
) {
|
|
230
|
+
maxPriorityFeePerGas = gasOverrides.maxPriorityFeePerGas;
|
|
231
|
+
} else {
|
|
232
|
+
maxPriorityFeePerGas = 1n;
|
|
233
|
+
}
|
|
234
|
+
// Use 100k as default gasPerPubdata for non-zkSync chains
|
|
235
|
+
gasPerPubdata = 100000n;
|
|
202
236
|
}
|
|
203
237
|
}
|
|
204
238
|
return {
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "5.117.
|
|
1
|
+
export const version = "5.117.1";
|