tryethernal / hardhat-ethernal

Hardhat plugin for Ethernal
MIT License
102 stars 17 forks source link

I can't push my contract #31

Closed olivmath closed 2 years ago

olivmath commented 2 years ago

This is my deploy script

import { ethernal, ethers } from "hardhat"

async function main() {
    const [owner] = await ethers.getSigners()

    const Contract = await ethers.getContractFactory("Contract")
    const Deployed = await Contract.deploy()

    await ethernal.push({
        name: "Contract",
        address: Deployed.address
    })

    console.log("Contract address:", Deployed.address)
    console.log("Owner address:", owner.address)
}

main()
    .then(() => process.exit(0))
    .catch((error) => {
        console.error(error)
        process.exit(1)
    })

This is my error log

yarn run v1.22.19
$ npx hardhat run scripts/deploy.ts --network localhost
[Ethernal]  Logged in with olivmath@protonmail.com
[Ethernal]  Using default workspace "LOCAL"
HttpsErrorImpl: [syncContractData] Missing parameter.
    at new HttpsErrorImpl (/Users/olivmath/work/olivmath/payments-auto/node_modules/@firebase/functions/src/api/error.ts:66:5)
    at _errorForResponse (/Users/olivmath/work/olivmath/payments-auto/node_modules/@firebase/functions/src/api/error.ts:175:10)
    at Service.<anonymous> (/Users/olivmath/work/olivmath/payments-auto/node_modules/@firebase/functions/src/api/service.ts:276:19)
    at step (/Users/olivmath/work/olivmath/payments-auto/node_modules/tslib/tslib.js:141:27)
    at Object.next (/Users/olivmath/work/olivmath/payments-auto/node_modules/tslib/tslib.js:122:57)
    at fulfilled (/Users/olivmath/work/olivmath/payments-auto/node_modules/tslib/tslib.js:112:62)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  code: 'invalid-argument',
  details: undefined
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
antoinedc commented 2 years ago

Hey, You need to make sure that the "name" parameter of the push function is exactly the same name than the contract name.

olivmath commented 2 years ago

I improved the file for this, now it works

my deploy script

import { ethernal, ethers } from "hardhat"

async function main() {
    const [owner] = await ethers.getSigners()

    const Lib = await ethers.getContractFactory("Array")
    const Array = await Lib.deploy()

    const AutoPay = await ethers.getContractFactory("AutoPay", {
        libraries: { Array: Array.address }
    })
    const Pay = await AutoPay.deploy()

    console.log("Library address:", Array.address)
    console.log("Contract address:", Pay.address)
    console.log("Owner address:", owner.address)

    await ethernal.push({
        name: "AutoPay",
        address: Pay.address
    })
}

main()
    .then(() => process.exit(0))
    .catch((error) => {
        console.error(error)
        process.exit(1)
    })