Skip to content

Commit

Permalink
abigen updated, fixed bug with structures
Browse files Browse the repository at this point in the history
  • Loading branch information
VolodymyrZolotukhin committed Nov 1, 2023
1 parent 1839118 commit 70b2376
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
Binary file modified bin/abigen.wasm
Binary file not shown.
6 changes: 3 additions & 3 deletions src/abigen/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ module.exports = class Generator {
const source = artifact.sourceName;

const abiPath = `${this.outDir}/${contract}.abi`;
const genDir = `${this.outDir}/${path.dirname(source)}`;
const packageName = path.basename(path.dirname(source)).replaceAll("-", "").replaceAll("_", "").toLowerCase();
const genPath = `${genDir}/${contract}.${this.lang}`;
const genDir = `${this.outDir}/${path.dirname(source)}/${contract}`.toLowerCase();
const packageName = path.basename(contract).replaceAll("-", "").replaceAll("_", "").toLowerCase();
const genPath = `${genDir}/${contract}.${this.lang}`.toLowerCase();

const argv = `abigen --abi ${abiPath} --pkg ${packageName} --type ${contract} --lang ${this.lang} --out ${genPath}`;

Expand Down
12 changes: 7 additions & 5 deletions test/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe("GoBind x Hardhat integration", function () {
const assertContractsGenerated = (outdir: string) => {
assertExists(outdir);
assertExists(`${outdir}/contracts`);
assertExists(`${outdir}/contracts/Lock.go`);
assertExists(`${outdir}/contracts/lock/lock.go`);
};

describe("Main logic with default config", function () {
Expand Down Expand Up @@ -55,9 +55,11 @@ describe("GoBind x Hardhat integration", function () {
assertNotExists(this.outdir);
});

const contractPaths = ["Mock1.go", "Mock2.go"].map((p) => "contracts/" + p);
const interfacePaths = ["IMock1.go", "IMock2.go"].map((p) => "contracts/interfaces/" + p);
const dependecyPaths = ["access/Ownable.go", "utils/Context.go"].map((p) => "@openzeppelin/contracts/" + p);
const contractPaths = ["mock1/mock1.go", "mock2/mock2.go"].map((p) => "contracts/" + p);
const interfacePaths = ["imock1/imock1.go", "imock2/imock2.go"].map((p) => "contracts/interfaces/" + p);
const dependecyPaths = ["access/ownable/ownable.go", "utils/context/context.go"].map(
(p) => "@openzeppelin/contracts/" + p
);
const allPaths = [...contractPaths, ...interfacePaths, ...dependecyPaths];

const testCases = [
Expand Down Expand Up @@ -101,7 +103,7 @@ describe("GoBind x Hardhat integration", function () {
});

it(`for ${caseToString(0)} generates only Ownable.go`, async function () {
const ownablePath = "@openzeppelin/contracts/access/Ownable.go";
const ownablePath = "@openzeppelin/contracts/access/ownable/ownable.go";
this.env.config.gobind.onlyFiles = testCases[0].only;
await this.env.run(TASK_GOBIND, abigenPath);

Expand Down

0 comments on commit 70b2376

Please sign in to comment.