11import { Effect , Either , RequestResolver , Request , Array , pipe , Data , PrimaryKey , Schema , SchemaAST } from 'effect'
22import { ContractABI } from './abi-strategy/request-model.js'
33import { Abi } from 'viem'
4- import { AbiParams , AbiStore } from './abi-store.js'
4+ import * as AbiStore from './abi-store.js'
55
66interface LoadParameters {
77 readonly chainID : number
@@ -49,9 +49,9 @@ function makeRequestKey(key: AbiLoader) {
4949 return `abi::${ key . chainID } :${ key . address } :${ key . event } :${ key . signature } `
5050}
5151
52- const getMany = ( requests : Array < AbiParams > ) =>
52+ const getMany = ( requests : Array < AbiStore . AbiParams > ) =>
5353 Effect . gen ( function * ( ) {
54- const { getMany, get } = yield * AbiStore
54+ const { getMany, get } = yield * AbiStore . AbiStore
5555
5656 if ( getMany != null ) {
5757 return yield * getMany ( requests )
@@ -68,7 +68,7 @@ const getMany = (requests: Array<AbiParams>) =>
6868
6969const setValue = ( key : AbiLoader , abi : ContractABI | null ) =>
7070 Effect . gen ( function * ( ) {
71- const { set } = yield * AbiStore
71+ const { set } = yield * AbiStore . AbiStore
7272 yield * set (
7373 {
7474 chainID : key . chainID ,
@@ -128,12 +128,12 @@ const getBestMatch = (abi: ContractABI | null) => {
128128const AbiLoaderRequestResolver : Effect . Effect <
129129 RequestResolver . RequestResolver < AbiLoader , never > ,
130130 never ,
131- AbiStore
131+ AbiStore . AbiStore
132132> = RequestResolver . makeBatched ( ( requests : Array < AbiLoader > ) =>
133133 Effect . gen ( function * ( ) {
134134 if ( requests . length === 0 ) return
135135
136- const { strategies } = yield * AbiStore
136+ const { strategies } = yield * AbiStore . AbiStore
137137
138138 const requestGroups = Array . groupBy ( requests , makeRequestKey )
139139 const uniqueRequests = Object . values ( requestGroups ) . map ( ( group ) => group [ 0 ] )
@@ -239,15 +239,15 @@ const AbiLoaderRequestResolver: Effect.Effect<
239239 } ,
240240 )
241241 } ) ,
242- ) . pipe ( RequestResolver . contextFromServices ( AbiStore ) , Effect . withRequestCaching ( true ) )
242+ ) . pipe ( RequestResolver . contextFromServices ( AbiStore . AbiStore ) , Effect . withRequestCaching ( true ) )
243243
244244// TODO: When failing to decode with one ABI, we should retry with other resolved ABIs
245245// We can decode with Effect.validateFirst(abis, (abi) => decodeMethod(input as Hex, abi)) and to find the first ABIs
246246// that decodes successfully. We might enforce a sorted array to prioritize the address match. We will have to think
247247// how to handle the strategy resolver in this case. Currently, we stop at first successful strategy, which might result
248248// in a missing Fragment. We treat this issue as a minor one for now, as we epect it to occur rarely on contracts that
249249// are not verified and with a non standard events structure.
250- export const getAndCacheAbi = ( params : AbiParams ) =>
250+ export const getAndCacheAbi = ( params : AbiStore . AbiParams ) =>
251251 Effect . gen ( function * ( ) {
252252 if ( params . event === '0x' || params . signature === '0x' ) {
253253 return yield * Effect . fail ( new EmptyCalldataError ( params ) )
0 commit comments