Skip to content

Commit ff4b3c9

Browse files
got further
1 parent 369fcac commit ff4b3c9

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
@@ -55,17 +55,23 @@ export async function getPaymasterAndData(args: {
5555
const entrypoint = entrypointAddress ?? ENTRYPOINT_ADDRESS_v0_6;
5656
const paymasterUrl = getDefaultBundlerUrl(chain);
5757

58+
const body = {
59+
jsonrpc: "2.0",
60+
id: 1,
61+
method: "pm_sponsorUserOperation",
62+
params: [hexlifyUserOp(userOp), entrypoint],
63+
};
64+
65+
if (DEBUG) {
66+
console.debug("Paymaster body:", body);
67+
}
68+
5869
// Ask the paymaster to sign the transaction and return a valid paymasterAndData value.
5970
const fetchWithHeaders = getClientFetch(client);
6071
const response = await fetchWithHeaders(paymasterUrl, {
6172
method: "POST",
6273
headers,
63-
body: stringify({
64-
jsonrpc: "2.0",
65-
id: 1,
66-
method: "pm_sponsorUserOperation",
67-
params: [hexlifyUserOp(userOp), entrypoint],
68-
}),
74+
body: stringify(body),
6975
});
7076
const res = await response.json();
7177

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)