Skip to content

Commit 3af3065

Browse files
got further
1 parent 6930deb commit 3af3065

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

packages/thirdweb/src/wallets/smart/lib/paymaster.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,23 @@ export async function getPaymasterAndData(args: {
5151
const entrypoint = entrypointAddress ?? ENTRYPOINT_ADDRESS_v0_6;
5252
const paymasterUrl = getDefaultBundlerUrl(chain);
5353

54+
const body = {
55+
jsonrpc: "2.0",
56+
id: 1,
57+
method: "pm_sponsorUserOperation",
58+
params: [hexlifyUserOp(userOp), entrypoint],
59+
};
60+
61+
if (DEBUG) {
62+
console.debug("Paymaster body:", body);
63+
}
64+
5465
// Ask the paymaster to sign the transaction and return a valid paymasterAndData value.
5566
const fetchWithHeaders = getClientFetch(client);
5667
const response = await fetchWithHeaders(paymasterUrl, {
5768
method: "POST",
5869
headers,
59-
body: stringify({
60-
jsonrpc: "2.0",
61-
id: 1,
62-
method: "pm_sponsorUserOperation",
63-
params: [hexlifyUserOp(userOp), entrypoint],
64-
}),
70+
body: stringify(body),
6571
});
6672
const res = await response.json();
6773

packages/thirdweb/src/wallets/smart/lib/userop.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { toSerializableTransaction } from "../../../transaction/actions/to-seria
1414
import type { PreparedTransaction } from "../../../transaction/prepare-transaction.js";
1515
import type { TransactionReceipt } from "../../../transaction/types.js";
1616
import { isContractDeployed } from "../../../utils/bytecode/is-contract-deployed.js";
17-
import type { Hex } from "../../../utils/encoding/hex.js";
17+
import { type Hex, toHex } from "../../../utils/encoding/hex.js";
1818
import { hexToBytes } from "../../../utils/encoding/to-bytes.js";
1919
import { isThirdwebUrl } from "../../../utils/fetch.js";
2020
import { resolvePromisedValue } from "../../../utils/promise/resolve-promised-value.js";
@@ -639,7 +639,7 @@ async function getAccountNonce(options: {
639639
if (getNonceOverride) {
640640
return getNonceOverride(accountContract);
641641
}
642-
return getNonce({
642+
const nonce = await getNonce({
643643
contract: getContract({
644644
address: entrypointAddress || ENTRYPOINT_ADDRESS_v0_6,
645645
chain,
@@ -648,6 +648,11 @@ async function getAccountNonce(options: {
648648
key: generateRandomUint192(),
649649
sender: accountContract.address,
650650
});
651+
// FIXME - only for modular accounts to pass validator in
652+
const withValidator = `0x${"0".repeat(40)}${toHex(nonce).slice(42)}`;
653+
console.log("withValidator", withValidator);
654+
console.log("withValidator", withValidator.length);
655+
return withValidator;
651656
}
652657

653658
/**
@@ -657,6 +662,7 @@ async function getAccountNonce(options: {
657662
* @example
658663
* ```ts
659664
* import { createAndSignUserOp } from "thirdweb/wallets/smart";
665+
import { keccak256 } from "../../../utils/hashing/keccak256.js";
660666
*
661667
* const userOp = await createAndSignUserOp({
662668
* client,

0 commit comments

Comments
 (0)