Skip to content

Commit

Permalink
fix(contract): more specific error on calling without address
Browse files Browse the repository at this point in the history
  • Loading branch information
davidyuk committed Aug 12, 2022
1 parent 24699f1 commit 5c5a241
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/contract/aci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ export default async function getContractInstance({

if (fn == null) throw new MissingFunctionNameError();
if (fn === 'init' && opt.callStatic === false) throw new InvalidMethodInvocationError('"init" can be called only via dryRun');
if (contractId == null && fn !== 'init') throw new InvalidMethodInvocationError('You need to deploy contract before calling!');
if (contractId == null && fn !== 'init') throw new MissingContractAddressError('Can\'t call contract without address');
if (fn !== 'init' && opt.amount > 0 && fnACI.payable === false) throw new NotPayableFunctionError(opt.amount, fn);

let callerId;
Expand Down
3 changes: 1 addition & 2 deletions test/integration/contract-aci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
decode,
BytecodeMismatchError,
InvalidAensNameError,
InvalidMethodInvocationError,
MissingContractAddressError,
MissingContractDefError,
NotPayableFunctionError,
Expand Down Expand Up @@ -186,7 +185,7 @@ describe('Contract instance', () => {
});

it('fails on calling without deployment', () => expect(testContract.methods.intFn(2))
.to.be.rejectedWith(InvalidMethodInvocationError, 'You need to deploy contract before calling!'));
.to.be.rejectedWith(MissingContractAddressError, 'Can\'t call contract without address'));

it('deploys', async () => {
const deployInfo = await testContract.deploy(['test', 1, 'hahahaha'], {
Expand Down

0 comments on commit 5c5a241

Please sign in to comment.