Skip to content

Commit b503739

Browse files
authored
fixes attestation store (#3721)
1 parent ccb64e7 commit b503739

File tree

3 files changed

+30
-18
lines changed

3 files changed

+30
-18
lines changed

packages/grant-explorer/src/attestationStore.ts

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,45 @@ import { persist } from "zustand/middleware";
66
import { Hex } from "viem";
77

88
interface AttestationState {
9-
checkedOutTransactions: Hex[];
10-
addCheckedOutTransaction: (tx: Hex) => void;
11-
getCheckedOutTransactions: () => Hex[];
9+
checkedOutTransactions: Record<Hex, Hex[]>;
10+
addCheckedOutTransaction: (tx: Hex, address?: Hex) => void;
11+
getCheckedOutTransactions: (address?: Hex) => Hex[];
1212
cleanCheckedOutTransactions: () => void;
1313
}
1414

1515
export const useAttestationStore = create<AttestationState>()(
1616
persist(
1717
devtools((set, get) => ({
18-
checkedOutTransactions: [],
19-
addCheckedOutTransaction: (tx: Hex) => {
18+
checkedOutTransactions: {},
19+
addCheckedOutTransaction: (tx: Hex, address?: Hex) => {
20+
if (!address) {
21+
return;
22+
}
2023
set((oldState) => ({
21-
checkedOutTransactions: [...oldState.checkedOutTransactions, tx],
24+
checkedOutTransactions: {
25+
...oldState.checkedOutTransactions,
26+
[address]: [
27+
...(oldState.checkedOutTransactions[address] || []),
28+
tx,
29+
],
30+
},
2231
}));
2332
},
24-
getCheckedOutTransactions: () => {
25-
return get().checkedOutTransactions;
33+
getCheckedOutTransactions: (address?: Hex) => {
34+
if (!address) {
35+
return [];
36+
}
37+
return get().checkedOutTransactions[address] || [];
2638
},
2739
cleanCheckedOutTransactions: () => {
2840
set({
29-
checkedOutTransactions: [],
41+
checkedOutTransactions: {},
3042
});
3143
},
3244
})),
3345
{
3446
name: "attestation-store",
35-
version: 1,
47+
version: 1.01,
3648
}
3749
)
3850
);

packages/grant-explorer/src/checkoutStore.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ export const useCheckoutStore = create<CheckoutState>()(
111111
walletClient: WalletClient,
112112
connector: Connector
113113
) => {
114+
const userAddress = walletClient.account?.address;
114115
const chainIdsToCheckOut = chainsToCheckout.map((chain) => chain.chainId);
115116
get().setChainsToCheckout(
116117
uniq([...get().chainsToCheckout, ...chainIdsToCheckOut])
@@ -325,7 +326,7 @@ export const useCheckoutStore = create<CheckoutState>()(
325326
});
326327
useAttestationStore
327328
.getState()
328-
.addCheckedOutTransaction(receipt.transactionHash);
329+
.addCheckedOutTransaction(receipt.transactionHash, userAddress);
329330
} catch (error) {
330331
let context: Record<string, unknown> = {
331332
chainId,

packages/grant-explorer/src/features/round/ThankYou.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export default function ThankYou() {
104104
}, [minted]);
105105

106106
const transactions = useAttestationStore((state) =>
107-
state.getCheckedOutTransactions()
107+
state.getCheckedOutTransactions(address)
108108
);
109109

110110
const handleSelectBackground = (option: string) => {
@@ -169,7 +169,6 @@ export default function ThankYou() {
169169
? false
170170
: balance.value < attestationFee + (gasEstimation ?? 0n);
171171

172-
173172
return (
174173
<>
175174
<Navbar />
@@ -201,13 +200,13 @@ export default function ThankYou() {
201200
Mint your Impact
202201
</h1>
203202
<p className="mt-1 text-lg font-modern-era-regular">
204-
Capture your contribution onchain with an
205-
attestation and receive a unique visual that
206-
symbolizes your donation.
203+
Capture your contribution onchain with an attestation
204+
and receive a unique visual that symbolizes your
205+
donation.
207206
</p>
208207
<p className="my-2 text-lg font-modern-era-regular">
209-
This visual reflects your onchain attestation,
210-
marking your support in a meaningful way.
208+
This visual reflects your onchain attestation, marking
209+
your support in a meaningful way.
211210
</p>
212211
</div>
213212
<PreviewFrame

0 commit comments

Comments
 (0)