@@ -5,6 +5,7 @@ import type {
55 WithOverrides ,
66} from "../../../../transaction/types.js" ;
77import { getClaimParams } from "../../../../utils/extensions/drops/get-claim-params.js" ;
8+ import { resolvePromisedValue } from "../../../../utils/promise/resolve-promised-value.js" ;
89import { encodeClaim } from "../../__generated__/IDrop/write/claim.js" ;
910
1011/**
@@ -49,7 +50,10 @@ export function claimToBatch(
4950 return multicall ( {
5051 contract : options . contract ,
5152 asyncParams : ( ) => getClaimToBatchParams ( options ) ,
52- overrides : options . overrides ,
53+ overrides : {
54+ erc20Value : getERC20Value ( options ) ,
55+ ...options . overrides ,
56+ } ,
5357 } ) ;
5458}
5559
@@ -96,6 +100,53 @@ async function getClaimToBatchParams(
96100 return { data } ;
97101}
98102
103+ /**
104+ * @internal
105+ */
106+ async function getERC20Value (
107+ options : BaseTransactionOptions < ClaimToBatchParams > ,
108+ ) : Promise <
109+ | {
110+ amountWei : bigint ;
111+ tokenAddress : string ;
112+ }
113+ | undefined
114+ > {
115+ const data = await Promise . all (
116+ options . content . map ( async ( item ) => {
117+ const claimParams = await getClaimParams ( {
118+ type : "erc721" ,
119+ contract : options . contract ,
120+ to : item . to ,
121+ from : options . from ,
122+ quantity : item . quantity ,
123+ } ) ;
124+ const erc20Value = await resolvePromisedValue (
125+ claimParams . overrides . erc20Value ,
126+ ) ;
127+ return erc20Value ;
128+ } ) ,
129+ ) ;
130+
131+ const filteredData = data . filter ( ( item ) => item !== undefined ) ;
132+
133+ if ( ! filteredData . length || ! filteredData [ 0 ] ) {
134+ return undefined ;
135+ }
136+
137+ const totalAmountWei = filteredData
138+ . filter ( ( item ) => item !== undefined )
139+ . reduce (
140+ ( accumulator , currentValue ) => accumulator + currentValue . amountWei ,
141+ BigInt ( 0 ) ,
142+ ) ;
143+
144+ return {
145+ amountWei : totalAmountWei ,
146+ tokenAddress : filteredData [ 0 ] . tokenAddress ,
147+ } ;
148+ }
149+
99150/**
100151 * Optimization
101152 * For identical addresses that stays next to each other in the array,
0 commit comments