Skip to content

Commit 71b05f1

Browse files
got further
1 parent 9070eab commit 71b05f1

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
@@ -16,7 +16,7 @@ import type { PreparedTransaction } from "../../../transaction/prepare-transacti
1616
import type { TransactionReceipt } from "../../../transaction/types.js";
1717
import { encodeAbiParameters } from "../../../utils/abi/encodeAbiParameters.js";
1818
import { isContractDeployed } from "../../../utils/bytecode/is-contract-deployed.js";
19-
import type { Hex } from "../../../utils/encoding/hex.js";
19+
import { type Hex, toHex } from "../../../utils/encoding/hex.js";
2020
import { hexToBytes } from "../../../utils/encoding/to-bytes.js";
2121
import { isThirdwebUrl } from "../../../utils/fetch.js";
2222
import { resolvePromisedValue } from "../../../utils/promise/resolve-promised-value.js";
@@ -662,7 +662,7 @@ async function getAccountNonce(options: {
662662
if (getNonceOverride) {
663663
return getNonceOverride(accountContract);
664664
}
665-
return getNonce({
665+
const nonce = await getNonce({
666666
contract: getContract({
667667
address: entrypointAddress || ENTRYPOINT_ADDRESS_v0_6,
668668
chain,
@@ -671,6 +671,11 @@ async function getAccountNonce(options: {
671671
key: generateRandomUint192(),
672672
sender: accountContract.address,
673673
});
674+
// FIXME - only for modular accounts to pass validator in
675+
const withValidator = `0x${"0".repeat(40)}${toHex(nonce).slice(42)}`;
676+
console.log("withValidator", withValidator);
677+
console.log("withValidator", withValidator.length);
678+
return withValidator;
674679
}
675680

676681
/**
@@ -680,6 +685,7 @@ async function getAccountNonce(options: {
680685
* @example
681686
* ```ts
682687
* import { createAndSignUserOp } from "thirdweb/wallets/smart";
688+
import { keccak256 } from "../../../utils/hashing/keccak256.js";
683689
*
684690
* const userOp = await createAndSignUserOp({
685691
* client,

0 commit comments

Comments
 (0)