diff --git a/src/contract/Contract.ts b/src/contract/Contract.ts index ebaf067282..443138b734 100644 --- a/src/contract/Contract.ts +++ b/src/contract/Contract.ts @@ -324,6 +324,7 @@ class Contract { const useFallbackAccount = callStatic === true && ( (error instanceof TypeError && error.message === 'Account should be an address (ak-prefixed string), or instance of AccountBase, got undefined instead') || (error instanceof NoWalletConnectedError) + || (error instanceof InternalError && error.message === 'Use fallback account') ); if (!useFallbackAccount) throw error; callerId = DRY_RUN_ACCOUNT.pub; diff --git a/test/integration/contract-aci.ts b/test/integration/contract-aci.ts index 2f1e7191b6..d71526037e 100644 --- a/test/integration/contract-aci.ts +++ b/test/integration/contract-aci.ts @@ -269,6 +269,14 @@ describe('Contract instance', () => { expect(res.tx.fee).to.be.equal('182000000000000'); }); + it('calls with fallback account if onAccount is not provided', async () => { + const account = testContract.$options.onAccount; + delete testContract.$options.onAccount; + const res = await testContract.intFn(2); + expect(res.decodedResult).to.be.equal(2n); + testContract.$options.onAccount = account; + }); + it('calls on chain', async () => { const res = await testContract.intFn(2, { callStatic: false }); expect(res.decodedResult).to.be.equal(2n);