Skip to content

Commit 2f032e4

Browse files
authored
npm version bump (#53)
* npm version bump * verifreg_deserial. test added * verifreg_deserial. test added
1 parent 4d2136e commit 2f032e4

File tree

5 files changed

+88
-9
lines changed

5 files changed

+88
-9
lines changed

.env.example

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DEPLOYER_PK=""

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ yarn.lock
1919
typechain-types
2020

2121
.openzeppelin/
22+
.env

hardhat.config.ts

+7
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import "hardhat-contract-sizer"
99

1010
import { readFileSync } from "fs"
1111

12+
import "dotenv/config"
13+
1214
let extractedSolcVersion: string
1315
try {
1416
const tomlData = readFileSync("./foundry.toml", { encoding: "utf8", flag: "r" })
@@ -39,6 +41,11 @@ const config: HardhatUserConfig = {
3941
gas: 1_000_000_000,
4042
blockGasLimit: 1_000_000_000,
4143
},
44+
calibnet: {
45+
url: "https://api.calibration.node.glif.io/rpc/v1",
46+
chainId: 314159,
47+
accounts: [process.env.DEPLOYER_PK],
48+
},
4249
},
4350
mocha: {
4451
timeout: 100000000,

hh-test/verifreg_deserial.t.ts

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import { ethers, network } from "hardhat"
2+
import * as utils from "./utils"
3+
4+
import { VerifRegApiTest, VerifRegApiTest__factory } from "../typechain-types"
5+
import { assert } from "console"
6+
7+
const DBG_LOG_ON = false
8+
9+
//RUN using:
10+
//npx hardhat --network calibnet run hh-test/verifreg_deserial.t.ts
11+
12+
const main = async () => {
13+
const deployerPk = network.config.accounts[0]
14+
15+
const provider = new ethers.providers.JsonRpcProvider(network.config.url)
16+
17+
const deployer = new ethers.Wallet(deployerPk, provider)
18+
19+
console.log(`\nDeploying contracts... (verifreg)\n`)
20+
21+
const fact = new VerifRegApiTest__factory()
22+
23+
const verifreg = await fact.connect(deployer).deploy()
24+
25+
await utils.delay(15_000)
26+
27+
console.log(`\nCalling: get_claims(...)\n`)
28+
29+
//fil-sol issue#51 example values
30+
const claimObject = { provider: 33601, claim_ids: [27133] }
31+
32+
const replicateFirstClaimId = (claimObject, n) => {
33+
const claim_ids = [...new Array(10)].map(() => claimObject.claim_ids[0])
34+
return { ...claimObject, claim_ids }
35+
}
36+
37+
//fetch and compare all results with the initial request
38+
const resOne = await verifreg.get_claims(claimObject)
39+
dbgLogRes(`resOne:`, resOne)
40+
41+
for (let len = 2; len < 10; len += 1) {
42+
const replicatedClaimObject = replicateFirstClaimId(claimObject, len)
43+
const resReplicated = await verifreg.get_claims(replicatedClaimObject)
44+
dbgLogRes(`resReplicated:::${len}:`, resReplicated)
45+
46+
//check correctness
47+
const bigNumberKeys = ["provider", "client", "size", "term_min", "term_max", "term_start", "sector"]
48+
for (const repClaim of resReplicated.claims) {
49+
for (const bnk of bigNumberKeys) {
50+
assert(repClaim[bnk].eq(resOne.claims[0][bnk]), `ERR: replicated(${len}).claim.${bnk} !== resOne.claim.${bnk}!`)
51+
}
52+
assert(repClaim.data === resOne.claims[0].data, `ERR: replicated(${len}).data !== resOne.data!`)
53+
}
54+
}
55+
56+
console.log(`----> Verifreg deserialize. test completed!\n`)
57+
}
58+
main().catch((error) => {
59+
console.error(error)
60+
process.exitCode = 1
61+
})
62+
63+
const dbgLogRes = (name, res) => {
64+
if (DBG_LOG_ON === false) return
65+
console.log(`\n---------> `, name)
66+
console.log("success_count", res.batch_info.success_count)
67+
console.log("fail_codes", res.batch_info.fail_codes)
68+
console.log("claims", res.claims)
69+
}

package.json

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "filecoin-solidity-api",
3-
"version": "1.1.1",
3+
"version": "1.1.2",
44
"description": "Filecoin EVM Solidity APIs",
55
"main": "",
66
"directories": {
@@ -33,28 +33,29 @@
3333
"access": "public"
3434
},
3535
"devDependencies": {
36+
"@glif/filecoin-address": "^2.0.43",
3637
"@nomicfoundation/hardhat-ethers": "^3.0.4",
3738
"@nomicfoundation/hardhat-foundry": "^1.0.3",
3839
"@nomiclabs/hardhat-ethers": "npm:hardhat-deploy-ethers@^0.3.0-beta.13",
40+
"@nomiclabs/hardhat-etherscan": "^3.1.7",
3941
"@openzeppelin/hardhat-upgrades": "^1.28.0",
42+
"@typechain/ethers-v5": "^11.1.1",
4043
"@typechain/ethers-v6": "^0.5.0",
4144
"@typechain/hardhat": "^6.1.2",
42-
"ethers": "^5.5.1",
43-
"hardhat": "^2.11.2",
44-
"prettier": "^2.7.1",
45-
"prettier-plugin-solidity": "^1.0.0",
46-
"typechain": "^8.3.1",
47-
"@glif/filecoin-address": "^2.0.43",
48-
"@nomiclabs/hardhat-etherscan": "^3.1.7",
49-
"@typechain/ethers-v5": "^11.1.1",
5045
"@types/chai": "^4.3.5",
5146
"@types/mocha": "^10.0.1",
5247
"@types/node": "^20.5.0",
5348
"chai": "^4.3.7",
5449
"cids": "^1.1.9",
50+
"dotenv": "^16.4.5",
51+
"ethers": "^5.5.1",
52+
"hardhat": "^2.11.2",
5553
"hardhat-contract-sizer": "^2.10.0",
5654
"hardhat-deploy-ethers": "^0.3.0-beta.13",
55+
"prettier": "^2.7.1",
56+
"prettier-plugin-solidity": "^1.0.0",
5757
"ts-node": "^10.9.1",
58+
"typechain": "^8.3.1",
5859
"typescript": "^5.2.2"
5960
},
6061
"dependencies": {

0 commit comments

Comments
 (0)