@@ -4,6 +4,7 @@ import { devtools } from "zustand/middleware";
44import { CartProject , ProgressStatus } from "./features/api/types" ;
55import {
66 AlloV2 ,
7+ DirectAllocation ,
78 createEthersTransactionSender ,
89 createPinataIpfsUploader ,
910 createWaitForIndexerSyncTo ,
@@ -32,13 +33,13 @@ import { groupBy, uniq } from "lodash-es";
3233import { getEnabledChains } from "./app/chainConfig" ;
3334import { getPermitType } from "common/dist/allo/voting" ;
3435import { getConfig } from "common/src/config" ;
35- import { DataLayer } from "data-layer" ;
3636import { getEthersProvider , getEthersSigner } from "./app/wagmi" ;
3737import { Connector } from "wagmi" ;
3838
3939type ChainMap < T > = Record < number , T > ;
4040
4141const isV2 = getConfig ( ) . allo . version === "allo-v2" ;
42+
4243interface CheckoutState {
4344 permitStatus : ChainMap < ProgressStatus > ;
4445 setPermitStatusForChain : (
@@ -62,7 +63,7 @@ interface CheckoutState {
6263 chainsToCheckout : { chainId : number ; permitDeadline : number } [ ] ,
6364 walletClient : WalletClient ,
6465 connector : Connector ,
65- dataLayer : DataLayer
66+ directAllocation ?: DirectAllocation
6667 ) => Promise < void > ;
6768 getCheckedOutProjects : ( ) => CartProject [ ] ;
6869 checkedOutProjects : CartProject [ ] ;
@@ -109,10 +110,12 @@ export const useCheckoutStore = create<CheckoutState>()(
109110 checkout : async (
110111 chainsToCheckout : { chainId : number ; permitDeadline : number } [ ] ,
111112 walletClient : WalletClient ,
112- connector : Connector
113+ connector : Connector ,
114+ directAllocation ?: DirectAllocation
113115 ) => {
114116 const userAddress = walletClient . account ?. address ;
115117 const chainIdsToCheckOut = chainsToCheckout . map ( ( chain ) => chain . chainId ) ;
118+ const hasDirectAllocation = ! ! directAllocation ;
116119 get ( ) . setChainsToCheckout (
117120 uniq ( [ ...get ( ) . chainsToCheckout , ...chainIdsToCheckOut ] )
118121 ) ;
@@ -151,6 +154,8 @@ export const useCheckoutStore = create<CheckoutState>()(
151154 const chainId = currentChain . chainId ;
152155 const deadline = currentChain . permitDeadline ;
153156 const donations = projectsByChain [ chainId ] ;
157+ const isDirectAllocation =
158+ hasDirectAllocation && directAllocation . chainId === chainId ;
154159
155160 set ( {
156161 currentChainBeingCheckedOut : chainId ,
@@ -205,7 +210,9 @@ export const useCheckoutStore = create<CheckoutState>()(
205210 tokenName = "cUSD" ;
206211 sig = await signPermit2612 ( {
207212 walletClient : walletClient ,
208- value : totalDonationPerChain [ chainId ] ,
213+ value : isDirectAllocation
214+ ? totalDonationPerChain [ chainId ] + directAllocation . amount
215+ : totalDonationPerChain [ chainId ] ,
209216 spenderAddress : chain . contracts . multiRoundCheckout ,
210217 nonce,
211218 chainId,
@@ -302,7 +309,8 @@ export const useCheckoutStore = create<CheckoutState>()(
302309 deadline,
303310 nonce : nonce ! ,
304311 }
305- : undefined
312+ : undefined ,
313+ isDirectAllocation ? directAllocation : undefined
306314 ) ;
307315
308316 if ( receipt . status === "reverted" ) {
0 commit comments