@@ -2,6 +2,7 @@ import { Context, Effect, RequestResolver, Request, Array, Either, pipe, Schema,
22import { ContractData } from './types.js'
33import { ContractMetaResolverStrategy , GetContractMetaStrategy } from './meta-strategy/request-model.js'
44import { Address } from 'viem'
5+ import { ZERO_ADDRESS } from './decoding/constants.js'
56
67export interface ContractMetaParams {
78 address : string
@@ -155,24 +156,28 @@ const ContractMetaLoaderRequestResolver = RequestResolver.makeBatched((requests:
155156 )
156157
157158 // Fetch ContractMeta from the strategies
158- const strategyResults = yield * Effect . forEach ( remaining , ( { chainID, address } ) => {
159- const allAvailableStrategies = Array . prependAll ( strategies . default , strategies [ chainID ] ?? [ ] )
160-
161- // TODO: Distinct the errors and missing data, so we can retry on errors
162- return Effect . validateFirst ( allAvailableStrategies , ( strategy ) =>
163- pipe (
164- Effect . request (
165- new GetContractMetaStrategy ( {
166- address,
167- chainId : chainID ,
168- strategyId : strategy . id ,
169- } ) ,
170- strategy . resolver ,
159+ const strategyResults = yield * Effect . forEach (
160+ remaining ,
161+ ( { chainID, address } ) => {
162+ const allAvailableStrategies = Array . prependAll ( strategies . default , strategies [ chainID ] ?? [ ] )
163+
164+ // TODO: Distinct the errors and missing data, so we can retry on errors
165+ return Effect . validateFirst ( allAvailableStrategies , ( strategy ) =>
166+ pipe (
167+ Effect . request (
168+ new GetContractMetaStrategy ( {
169+ address,
170+ chainId : chainID ,
171+ strategyId : strategy . id ,
172+ } ) ,
173+ strategy . resolver ,
174+ ) ,
175+ Effect . withRequestCaching ( true ) ,
171176 ) ,
172- Effect . withRequestCaching ( true ) ,
173- ) ,
174- ) . pipe ( Effect . orElseSucceed ( ( ) => null ) )
175- } )
177+ ) . pipe ( Effect . orElseSucceed ( ( ) => null ) )
178+ } ,
179+ { concurrency : 'unbounded' , batching : true } ,
180+ )
176181
177182 // Store results and resolve pending requests
178183 yield * Effect . forEach (
@@ -197,6 +202,8 @@ export const getAndCacheContractMeta = ({
197202 readonly chainID : number
198203 readonly address : Address
199204} ) => {
205+ if ( address === ZERO_ADDRESS ) return Effect . succeed ( null )
206+
200207 return Effect . withSpan (
201208 Effect . request ( new ContractMetaLoader ( { chainID, address } ) , ContractMetaLoaderRequestResolver ) ,
202209 'GetAndCacheContractMeta' ,
0 commit comments