瀏覽代碼

scroll链接成功

skyfffire 2 年之前
父節點
當前提交
b0a92d2c2e
共有 4 個文件被更改,包括 19 次插入5 次删除
  1. 3 3
      model/chain.js
  2. 1 1
      package.json
  3. 1 1
      scripts/lib/chain-lib.js
  4. 14 0
      scripts/scroll/scroll-network.js

+ 3 - 3
model/chain.js

@@ -8,10 +8,10 @@ module.exports = class Chain {
     return rst.data
   }
 
-  static async findById(id) {
-    const url = '/chain/findById'
+  static async findByChainId(id) {
+    const url = '/chain/findByChainId'
     const rst = await http.post(url, {
-      id: id
+      chainId: id
     })
 
     return rst.data

+ 1 - 1
package.json

@@ -1,5 +1,5 @@
 {
-  "name": "hardhat-project",
+  "name": "scroll-project",
   "scripts": {
     "lp-generate": "node /scripts/generate/index.js"
   },

+ 1 - 1
scripts/lib/chain-lib.js

@@ -13,7 +13,7 @@ module.exports = class ChainLib {
   }
 
   static async parseChainById(chainId) {
-    const chainRst = await Chain.findById(chainId)
+    const chainRst = await Chain.findByChainId(chainId)
     if (!chainRst.state) {
       throw Error(chainRst.msg)
     }

+ 14 - 0
scripts/scroll/scroll-network.js

@@ -0,0 +1,14 @@
+const ChainLib = require("../lib/chain-lib");
+const Web3Utils = require("../../utils/web3-utils");
+
+async function main() {
+  const chain = await ChainLib.getChainFromCommand()
+  const web3 = Web3Utils.autoCreate(chain)
+
+  console.log(await web3.eth.getBlockNumber())
+}
+
+main().catch((error) => {
+  console.error(error);
+  process.exitCode = 1;
+})