Skip to content

Commit 254adf8

Browse files
committed
fix: update hardcoded signatures for passkey view
This was super tough to find and would have been a compile error had we imported the abi directly from the contracts! This is something I'm going to look into so we don't lose our minds
1 parent 99114da commit 254adf8

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

examples/nft-quest-contracts/deploy/deploy.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ export default async function (hre: HardhatRuntimeEnvironment) {
2020
const nftQuestAddress = await nftContract.getAddress();
2121
const paymasterContractAddress = await paymasterContract.getAddress();
2222

23-
const configPath = path.join(__dirname, "../../../packages/auth-server/local-node.json");
24-
fs.writeFileSync(configPath, JSON.stringify({ nftQuestAddress, paymasterContractAddress }), { encoding: "utf8" });
2523
// Update the .env.local file with the contract addresses for NFT Quest app
2624
const envFilePath = path.join(__dirname, "../../nft-quest/.env.local");
2725

packages/sdk/src/client/passkey/actions/account.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { getGeneralPaymasterInput } from "viem/zksync";
55
import { FactoryAbi } from "../../../abi/Factory.js";
66
import { encodeModuleData, encodePasskeyModuleParameters, encodeSession } from "../../../utils/encoding.js";
77
import { noThrow } from "../../../utils/helpers.js";
8-
import { getPasskeySignatureFromPublicKeyBytes, getPublicKeyBytesFromPasskeySignature } from "../../../utils/passkey.js";
8+
import { base64UrlToUint8Array, getPasskeySignatureFromPublicKeyBytes, getPublicKeyBytesFromPasskeySignature } from "../../../utils/passkey.js";
99
import type { SessionConfig } from "../../../utils/session.js";
1010

1111
/* TODO: try to get rid of most of the contract params like passkey, session */
@@ -174,17 +174,18 @@ export const fetchAccount = async <
174174

175175
if (!accountAddress || accountAddress == NULL_ADDRESS) throw new Error(`No account found for username: ${username}`);
176176

177+
const credentialId = toHex(base64UrlToUint8Array(username));
177178
const lowerKeyHalfBytes = await readContract(client, {
178-
abi: parseAbi(["function lowerKeyHalf(string,address) view returns (bytes32)"]),
179+
abi: parseAbi(["function lowerKeyHalf(string,bytes,address) view returns (bytes32)"]),
179180
address: args.contracts.passkey,
180181
functionName: "lowerKeyHalf",
181-
args: [origin, accountAddress],
182+
args: [origin, credentialId, accountAddress],
182183
});
183184
const upperKeyHalfBytes = await readContract(client, {
184-
abi: parseAbi(["function upperKeyHalf(string,address) view returns (bytes32)"]),
185+
abi: parseAbi(["function upperKeyHalf(string,bytes,address) view returns (bytes32)"]),
185186
address: args.contracts.passkey,
186187
functionName: "upperKeyHalf",
187-
args: [origin, accountAddress],
188+
args: [origin, credentialId, accountAddress],
188189
});
189190

190191
if (!lowerKeyHalfBytes || !upperKeyHalfBytes) throw new Error(`Passkey credentials not found in on-chain module for passkey ${username}`);

0 commit comments

Comments
 (0)