@@ -32,7 +32,7 @@ export default async function createApiFacade({ web3, chainId }) {
3232 createApiInstance ( {
3333 web3,
3434 archon,
35- contracts : await getLinguoContracts ( { web3, chainId, address, deployment : Linguo } ) ,
35+ contracts : await getContracts ( { web3, chainId, address, deployment : Linguo } ) ,
3636 } )
3737 ) ,
3838 addressesByLanguageGroupPair
@@ -168,22 +168,28 @@ export default async function createApiFacade({ web3, chainId }) {
168168 ...rest ,
169169 ] ;
170170
171- const actualApi = apiInstancesByAddress [ address ] ;
172- if ( actualApi ) {
173- return actualApi [ target . name ] . apply ( actualApi , actualArgs ) ;
171+ const instance = apiInstancesByAddress [ address ] ;
172+ if ( instance ) {
173+ return instance [ target . name ] . apply ( instance , actualArgs ) ;
174174 }
175175
176+ /**
177+ * If a given task is from a contract that is no longer supported and therefore is
178+ * not wired up when the façade is created, users are still allowed to read from it.
179+ * To be able to do that, we need to create a new API instnace on the fly for the
180+ * unsupported contract, but only for the read-only methods.
181+ */
176182 if ( ! Object . keys ( readOnlyApiSkeleton ) . includes ( target . name ) ) {
177183 throw new Error ( `Task with ID ${ ID } is read-only.` ) ;
178184 }
179185
180186 const transientInstance = await createApiInstance ( {
181187 web3,
182188 archon,
183- contracts : await getLinguoContracts ( { web3, chainId, address, deployment : Linguo } ) ,
189+ contracts : await getContracts ( { web3, chainId, address, deployment : Linguo } ) ,
184190 } ) ;
185191
186- return transientInstance . api [ target . name ] . apply ( actualApi , actualArgs ) ;
192+ return transientInstance . api [ target . name ] . apply ( instance , actualArgs ) ;
187193 } ,
188194 } ;
189195
@@ -237,7 +243,7 @@ const readOnlyApiSkeleton = {
237243 getArbitrationCost ( ) { } ,
238244} ;
239245
240- async function getLinguoContracts ( { web3, chainId, address, deployment } ) {
246+ async function getContracts ( { web3, chainId, address, deployment } ) {
241247 // set the max listeners warning threshold
242248 web3 . eth . maxListenersWarningThreshold = 1000 ;
243249
0 commit comments