Skip to content

Commit

Permalink
feat: ignore gas param in abi (#123)
Browse files Browse the repository at this point in the history
* feat: ignore gas param in abi

* feat: lint json
  • Loading branch information
5h4z4mm authored Jun 20, 2022
1 parent 72aec14 commit 71ac4fc
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import { BaseContract, ContractFactory, ethers } from 'ethers';
import { EditableStorageLogic } from './logic/editable-storage-logic';
import { WatchableFunctionLogic } from './logic/watchable-function-logic';

type Abi = ReadonlyArray<Fragment | JsonFragment | string>;
type Abi = ReadonlyArray<
Fragment | Pick<JsonFragment, 'name' | 'type' | 'anonymous' | 'payable' | 'constant' | 'stateMutability' | 'inputs' | 'outputs'> | string
>;
export type FakeContractSpec = { abi?: Abi; interface?: Interface } | Abi | ethers.utils.Interface | string;

export interface FakeContractOptions {
Expand Down
6 changes: 6 additions & 0 deletions test/unit/fake/initialization.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Receiver, Receiver__factory, Returner } from '@typechained';
import receiverArtifact from 'artifacts/test/contracts/watchable-function-logic/Receiver.sol/Receiver.json';
import chai, { expect } from 'chai';
import { ethers, network } from 'hardhat';
import storageArtifact from 'test/unit/fake/testdata/Storage.json';

chai.use(smock.matchers);

Expand Down Expand Up @@ -84,4 +85,9 @@ describe('Fake: Initialization', () => {
const fake = await smock.fake('Receiver');
expect(fake.wallet._isSigner).to.be.true;
});

it('should work for abi with gas parameter', async () => {
const fake = await smock.fake(storageArtifact);
expect(fake.store._watchable).not.to.be.undefined;
});
});
29 changes: 29 additions & 0 deletions test/unit/fake/testdata/Storage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[
{
"inputs": [],
"name": "retrieve",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "num",
"type": "uint256"
}
],
"name": "store",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function",
"gas": 12345
}
]

0 comments on commit 71ac4fc

Please sign in to comment.