Skip to content

Commit

Permalink
chore: artifacts type & export (#499)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjlevesque committed May 6, 2021
1 parent 96e9486 commit d4e8b12
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/smart-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"generate-types": "typechain --target=ethers-v5 --outDir=src/types 'build/contracts/*.json'"
},
"devDependencies": {
"@ethersproject/abi": "5.0.13",
"@openzeppelin/contracts": "2.5.1",
"@openzeppelin/test-helpers": "0.5.6",
"@requestnetwork/currency": "0.6.0",
Expand Down
11 changes: 8 additions & 3 deletions packages/smart-contracts/src/lib/ContractArtifact.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Contract, ContractInterface, providers, Signer } from 'ethers';
import { Contract, providers, Signer } from 'ethers';
import { JsonFragment } from '@ethersproject/abi';

/**
* Contract information specific to a network
Expand All @@ -12,7 +13,7 @@ export type ArtifactNetworkInfo = {

/** Deployment information and ABI per network */
export type ArtifactDeploymentInfo<TNetwork extends string = string> = {
abi: ContractInterface;
abi: JsonFragment[];
deployment: Record<TNetwork, ArtifactNetworkInfo>;
};

Expand Down Expand Up @@ -44,11 +45,15 @@ export class ContractArtifact<TContract extends Contract> {
) as TContract;
}

getInterface(): TContract['interface'] {
return Contract.getInterface(this.getContractAbi());
}

/**
* Retrieve the abi from the artifact of the used version
* @returns the abi of the artifact as a json object
*/
getContractAbi(version = this.lastVersion): ContractInterface {
getContractAbi(version = this.lastVersion): JsonFragment[] {
return this.info[version].abi;
}

Expand Down
1 change: 1 addition & 0 deletions packages/smart-contracts/src/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './artifacts';
export * from './ContractArtifact';

0 comments on commit d4e8b12

Please sign in to comment.