Skip to content

Commit

Permalink
npm version bump (#53)
Browse files Browse the repository at this point in the history
* npm version bump

* verifreg_deserial. test added

* verifreg_deserial. test added
  • Loading branch information
wertikalk authored Mar 27, 2024
1 parent 4d2136e commit 2f032e4
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 9 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DEPLOYER_PK=""
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ yarn.lock
typechain-types

.openzeppelin/
.env
7 changes: 7 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import "hardhat-contract-sizer"

import { readFileSync } from "fs"

import "dotenv/config"

let extractedSolcVersion: string
try {
const tomlData = readFileSync("./foundry.toml", { encoding: "utf8", flag: "r" })
Expand Down Expand Up @@ -39,6 +41,11 @@ const config: HardhatUserConfig = {
gas: 1_000_000_000,
blockGasLimit: 1_000_000_000,
},
calibnet: {
url: "https://api.calibration.node.glif.io/rpc/v1",
chainId: 314159,
accounts: [process.env.DEPLOYER_PK],
},
},
mocha: {
timeout: 100000000,
Expand Down
69 changes: 69 additions & 0 deletions hh-test/verifreg_deserial.t.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { ethers, network } from "hardhat"
import * as utils from "./utils"

import { VerifRegApiTest, VerifRegApiTest__factory } from "../typechain-types"
import { assert } from "console"

const DBG_LOG_ON = false

//RUN using:
//npx hardhat --network calibnet run hh-test/verifreg_deserial.t.ts

const main = async () => {
const deployerPk = network.config.accounts[0]

const provider = new ethers.providers.JsonRpcProvider(network.config.url)

const deployer = new ethers.Wallet(deployerPk, provider)

console.log(`\nDeploying contracts... (verifreg)\n`)

const fact = new VerifRegApiTest__factory()

const verifreg = await fact.connect(deployer).deploy()

await utils.delay(15_000)

console.log(`\nCalling: get_claims(...)\n`)

//fil-sol issue#51 example values
const claimObject = { provider: 33601, claim_ids: [27133] }

const replicateFirstClaimId = (claimObject, n) => {
const claim_ids = [...new Array(10)].map(() => claimObject.claim_ids[0])
return { ...claimObject, claim_ids }
}

//fetch and compare all results with the initial request
const resOne = await verifreg.get_claims(claimObject)
dbgLogRes(`resOne:`, resOne)

for (let len = 2; len < 10; len += 1) {
const replicatedClaimObject = replicateFirstClaimId(claimObject, len)
const resReplicated = await verifreg.get_claims(replicatedClaimObject)
dbgLogRes(`resReplicated:::${len}:`, resReplicated)

//check correctness
const bigNumberKeys = ["provider", "client", "size", "term_min", "term_max", "term_start", "sector"]
for (const repClaim of resReplicated.claims) {
for (const bnk of bigNumberKeys) {
assert(repClaim[bnk].eq(resOne.claims[0][bnk]), `ERR: replicated(${len}).claim.${bnk} !== resOne.claim.${bnk}!`)
}
assert(repClaim.data === resOne.claims[0].data, `ERR: replicated(${len}).data !== resOne.data!`)
}
}

console.log(`----> Verifreg deserialize. test completed!\n`)
}
main().catch((error) => {
console.error(error)
process.exitCode = 1
})

const dbgLogRes = (name, res) => {
if (DBG_LOG_ON === false) return
console.log(`\n---------> `, name)
console.log("success_count", res.batch_info.success_count)
console.log("fail_codes", res.batch_info.fail_codes)
console.log("claims", res.claims)
}
19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "filecoin-solidity-api",
"version": "1.1.1",
"version": "1.1.2",
"description": "Filecoin EVM Solidity APIs",
"main": "",
"directories": {
Expand Down Expand Up @@ -33,28 +33,29 @@
"access": "public"
},
"devDependencies": {
"@glif/filecoin-address": "^2.0.43",
"@nomicfoundation/hardhat-ethers": "^3.0.4",
"@nomicfoundation/hardhat-foundry": "^1.0.3",
"@nomiclabs/hardhat-ethers": "npm:hardhat-deploy-ethers@^0.3.0-beta.13",
"@nomiclabs/hardhat-etherscan": "^3.1.7",
"@openzeppelin/hardhat-upgrades": "^1.28.0",
"@typechain/ethers-v5": "^11.1.1",
"@typechain/ethers-v6": "^0.5.0",
"@typechain/hardhat": "^6.1.2",
"ethers": "^5.5.1",
"hardhat": "^2.11.2",
"prettier": "^2.7.1",
"prettier-plugin-solidity": "^1.0.0",
"typechain": "^8.3.1",
"@glif/filecoin-address": "^2.0.43",
"@nomiclabs/hardhat-etherscan": "^3.1.7",
"@typechain/ethers-v5": "^11.1.1",
"@types/chai": "^4.3.5",
"@types/mocha": "^10.0.1",
"@types/node": "^20.5.0",
"chai": "^4.3.7",
"cids": "^1.1.9",
"dotenv": "^16.4.5",
"ethers": "^5.5.1",
"hardhat": "^2.11.2",
"hardhat-contract-sizer": "^2.10.0",
"hardhat-deploy-ethers": "^0.3.0-beta.13",
"prettier": "^2.7.1",
"prettier-plugin-solidity": "^1.0.0",
"ts-node": "^10.9.1",
"typechain": "^8.3.1",
"typescript": "^5.2.2"
},
"dependencies": {
Expand Down

0 comments on commit 2f032e4

Please sign in to comment.