Skip to content

Commit ce2ecc6

Browse files
committed
chore: attempt debugging
1 parent 58a1494 commit ce2ecc6

File tree

7 files changed

+621
-445
lines changed

7 files changed

+621
-445
lines changed

.github/instructions/nx.instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ If the user wants to generate something, use the following flow:
2727
- wait for the user to finish the generator
2828
- read the generator log file using the 'nx_read_generator_log' tool
2929
- use the information provided in the log file to answer the user's question or continue with what they were doing
30-
undefined
30+
3131

3232

examples/nft-quest/composables/useMintNft.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,34 @@ import { waitForTransactionReceipt, writeContract } from "@wagmi/core";
22
import type { Address } from "viem";
33
import { getGeneralPaymasterInput } from "viem/zksync";
44

5+
export const useTradeNft = async (_address: MaybeRef<Address>) => {
6+
const address = toRef(_address);
7+
return await useAsyncData("tradeZeek", async () => {
8+
const runtimeConfig = useRuntimeConfig();
9+
const { wagmiConfig } = storeToRefs(useConnectorStore());
10+
11+
const mintingForAddress = address.value;
12+
const transactionHash = await writeContract(wagmiConfig.value, {
13+
address: runtimeConfig.public.contracts.nft as Address,
14+
abi: nftAbi,
15+
functionName: "mint",
16+
args: [mintingForAddress],
17+
paymaster: runtimeConfig.public.contracts.paymaster as Address,
18+
paymasterInput: getGeneralPaymasterInput({ innerInput: "0x" }),
19+
});
20+
21+
const transactionReceipt = await waitForTransactionReceipt(wagmiConfig.value, { hash: transactionHash });
22+
if (transactionReceipt.status === "reverted") {
23+
throw new Error("Transaction reverted");
24+
}
25+
26+
return transactionReceipt;
27+
}, {
28+
server: false,
29+
immediate: false,
30+
});
31+
};
32+
533
export const useMintNft = async (_address: MaybeRef<Address>) => {
634
const address = toRef(_address);
735

examples/nft-quest/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"@vueuse/motion": "^2.2.6",
2020
"@vueuse/nuxt": "^11.1.0",
2121
"@wagmi/core": "^2.16.4",
22+
"@wagmi/vue": "^0.1.14",
2223
"@web3modal/wagmi": "^5.1.11",
2324
"clsx": "^2.1.1",
2425
"dotenv": "16.4.5",

examples/nft-quest/pages/trade/index.vue

Lines changed: 26 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -166,20 +166,15 @@
166166
</template>
167167

168168
<script setup lang="ts">
169+
import { getAccount, signTypedData } from "@wagmi/core";
169170
import {
170171
type Address,
171-
createWalletClient,
172172
type Hex,
173-
http,
174-
parseEther,
175-
type TypedDataDefinition } from "viem";
176-
import { erc7739Actions } from "viem/experimental";
173+
isAddress,
174+
parseEther } from "viem";
177175
import { reactive, ref } from "vue";
178176
179-
const { account } = storeToRefs(useConnectorStore());
180-
181177
const runtimeConfig = useRuntimeConfig();
182-
const chain = runtimeConfig.public.chain;
183178
184179
const config = reactive({
185180
marketplaceName: "SimpleMarketplace",
@@ -216,59 +211,39 @@ const listRequestTypes = {
216211
],
217212
} as const;
218213
214+
const { account } = storeToRefs(useConnectorStore());
215+
219216
async function handleSignListRequest() {
220-
isLoading.value = true;
221217
errorMsg.value = null;
222218
signature.value = null;
223219
signedDomain.value = null;
224220
signedTypes.value = null;
225221
signedMessage.value = null;
222+
const connectedAccount = getAccount();
226223
227-
if (!config.marketplaceAddress) {
228-
errorMsg.value = "Marketplace address is required.";
229-
isLoading.value = false;
230-
console.error("Marketplace address is required.", runtimeConfig.public.contracts.marketplace);
224+
if (!connectedAccount.isConnected || !connectedAccount.address) {
225+
errorMsg.value = "Please connect your wallet first.";
231226
return;
232227
}
233-
if (!account.value.address) {
234-
errorMsg.value = "Smart Account address is required.";
235-
isLoading.value = false;
236-
return;
237-
}
238-
if (!config.nftContractAddress) {
239-
errorMsg.value = "nft address is required.";
240-
isLoading.value = false;
228+
229+
// --- Pre-flight Checks for Addresses and Critical Values ---
230+
if (!config.marketplaceAddress || !isAddress(config.marketplaceAddress)) {
231+
errorMsg.value = "Marketplace Contract Address (Verifying Contract) is missing or invalid.";
241232
return;
242233
}
243-
if (!chain) {
244-
errorMsg.value = "Chain not found in wagmiConfig.";
245-
isLoading.value = false;
234+
const smartAccount = account.value;
235+
if (!smartAccount.address || !isAddress(smartAccount.address)) {
236+
errorMsg.value = "Seller Smart Account Address is missing or invalid.";
246237
return;
247238
}
248-
if (!chain.id) {
249-
errorMsg.value = "Chain ID is required.";
250-
isLoading.value = false;
239+
if (!config.nftContractAddress || !isAddress(config.nftContractAddress)) {
240+
errorMsg.value = "NFT Contract Address is missing or invalid.";
251241
return;
252242
}
243+
// --- End Pre-flight Checks ---
244+
const chain = runtimeConfig.public.chain;
253245
254246
try {
255-
const accountValue = account.value;
256-
if (!accountValue || !accountValue.address) {
257-
errorMsg.value = "Smart Account address is required.";
258-
isLoading.value = false;
259-
return;
260-
}
261-
if (!config.marketplaceAddress || !config.nftContractAddress) {
262-
errorMsg.value = "Marketplace and NFT contract addresses are required.";
263-
isLoading.value = false;
264-
return;
265-
}
266-
// this needs to be a wagmi account, not a private key
267-
const client = createWalletClient({
268-
account: accountValue,
269-
chain: chain,
270-
transport: http(),
271-
}).extend(erc7739Actions());
272247
const domain = {
273248
name: config.marketplaceName,
274249
version: config.marketplaceVersion,
@@ -277,7 +252,7 @@ async function handleSignListRequest() {
277252
} as const;
278253
279254
const message = {
280-
seller: accountValue.address,
255+
seller: smartAccount.address as Address, // The smart account is the seller
281256
nftContract: config.nftContractAddress as Address,
282257
tokenId: BigInt(config.tokenId),
283258
price: parseEther(config.priceInEth),
@@ -289,22 +264,19 @@ async function handleSignListRequest() {
289264
signedTypes.value = listRequestTypes;
290265
signedMessage.value = message;
291266
292-
const typedData: TypedDataDefinition<typeof listRequestTypes, "ListRequest"> = {
267+
const typedDataArgs = {
293268
domain,
294269
types: listRequestTypes,
295270
primaryType: "ListRequest",
296271
message,
297-
};
272+
} as const;
298273
299-
const sig = await client.signTypedData(typedData);
274+
// Use wagmi/core's signTypedData
275+
const sig = await signTypedData(typedDataArgs);
300276
signature.value = sig;
301277
} catch (e) {
302-
errorMsg.value = e.message || "An unknown error occurred during signing.";
303-
if (e.shortMessage) { // Viem often has a shortMessage
304-
errorMsg.value = e.shortMessage;
305-
}
306-
} finally {
307-
isLoading.value = false;
278+
console.error("Error in handleSignListRequest:", e);
279+
errorMsg.value = e.message || "An unknown error occurred during the signing process preparation.";
308280
}
309281
}
310282
</script>

packages/auth-server/stores/client.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { useAppKitProvider } from "@reown/appkit/vue";
22
import { type Address, createPublicClient, createWalletClient, custom, http, publicActions, walletActions } from "viem";
33
import { generatePrivateKey, privateKeyToAccount } from "viem/accounts";
44
import { zksyncInMemoryNode, zksyncSepoliaTestnet } from "viem/chains";
5-
import { erc7739Actions } from "viem/experimental";
65
import { eip712WalletActions } from "viem/zksync";
76
import { createZksyncPasskeyClient, type PasskeyRequiredContracts } from "zksync-sso/client/passkey";
87
import { createZksyncRecoveryGuardianClient } from "zksync-sso/client/recovery";
@@ -155,8 +154,7 @@ export const useClientStore = defineStore("client", () => {
155154
})
156155
.extend(publicActions)
157156
.extend(walletActions)
158-
.extend(eip712WalletActions())
159-
.extend(erc7739Actions());
157+
.extend(eip712WalletActions());
160158
;
161159
};
162160

0 commit comments

Comments
 (0)