Skip to content

Commit

Permalink
feat: ethers 5->6
Browse files Browse the repository at this point in the history
upgraded to newest hardhat, fixed up dependencies and tests
  • Loading branch information
jtakalai committed May 28, 2024
1 parent 6a9f0b2 commit 8990409
Show file tree
Hide file tree
Showing 16 changed files with 10,579 additions and 29,571 deletions.
40 changes: 40 additions & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { Provider, Signer } from "ethers";
import type { DATAv2 } from "./typechain/contracts/DATAv2";
export declare const abi: ({
inputs: never[];
stateMutability: string;
type: string;
anonymous?: undefined;
name?: undefined;
outputs?: undefined;
} | {
anonymous: boolean;
inputs: {
indexed: boolean;
internalType: string;
name: string;
type: string;
}[];
name: string;
type: string;
stateMutability?: undefined;
outputs?: undefined;
} | {
inputs: {
internalType: string;
name: string;
type: string;
}[];
name: string;
outputs: {
internalType: string;
name: string;
type: string;
}[];
stateMutability: string;
type: string;
anonymous?: undefined;
})[], bytecode: string;
export type { DATAv2 };
export declare function getTokenAt(address: string, signerOrProvider: Provider | Signer): DATAv2;
export declare function deployToken(signer: Signer): Promise<DATAv2>;
40 changes: 40 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.deployToken = exports.getTokenAt = exports.bytecode = exports.abi = void 0;
const ethers_1 = require("ethers");
const dataV2json = __importStar(require("./artifacts/contracts/DATAv2.sol/DATAv2.json"));
exports.abi = dataV2json.abi, exports.bytecode = dataV2json.bytecode;
function getTokenAt(address, signerOrProvider) {
return new ethers_1.Contract(address, exports.abi, signerOrProvider);
}
exports.getTokenAt = getTokenAt;
async function deployToken(signer) {
const factory = new ethers_1.ContractFactory(exports.abi, exports.bytecode, signer);
const contract = await factory.deploy();
await contract.waitForDeployment();
return contract;
}
exports.deployToken = deployToken;
9 changes: 5 additions & 4 deletions hardhat.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
require("@nomiclabs/hardhat-waffle")
require("solidity-coverage")
require("@nomicfoundation/hardhat-chai-matchers")
require("@nomicfoundation/hardhat-ethers")
require("@typechain/hardhat")
require("hardhat-gas-reporter")
require("hardhat-typechain")
require("solidity-coverage")

// You need to export an object to set up your config
// Go to https://hardhat.org/config/ to learn more
Expand All @@ -28,6 +29,6 @@ module.exports = {
},
typechain: {
outDir: "typechain",
target: "ethers-v5"
target: "ethers-v6"
}
}
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function deployToken(signer) {
return [4 /*yield*/, factory.deploy()];
case 1:
contract = _a.sent();
return [2 /*return*/, contract.deployed()];
return [2 /*return*/, contract.waitForDeployment()];
}
});
});
Expand Down
14 changes: 9 additions & 5 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { Signer } from "@ethersproject/abstract-signer"
import { Provider } from "@ethersproject/providers"
import { Contract, ContractFactory } from "@ethersproject/contracts"
import {
Contract,
ContractFactory,
Provider,
Signer,
} from "ethers"

import * as dataV2json from "./artifacts/contracts/DATAv2.sol/DATAv2.json"
import type { DATAv2 } from "./typechain/DATAv2"
import type { DATAv2 } from "./typechain/contracts/DATAv2"

export const { abi, bytecode } = dataV2json
export type { DATAv2 }
Expand All @@ -15,5 +18,6 @@ export function getTokenAt(address: string, signerOrProvider: Provider | Signer)
export async function deployToken(signer: Signer): Promise<DATAv2> {
const factory = new ContractFactory(abi, bytecode, signer)
const contract = await factory.deploy() as unknown as DATAv2
return contract.deployed()
await contract.waitForDeployment()
return contract
}
Loading

0 comments on commit 8990409

Please sign in to comment.