add arbitrum nova

master
cyhhao 2 years ago
parent baae3a0710
commit 6872268e76

@ -93,8 +93,31 @@ const evmNetworks: Record<number, any> = {
}, },
contracts: { factory: "0x96f7849C6D0EB09024e482Cc9c249096e3368a16" }, contracts: { factory: "0x96f7849C6D0EB09024e482Cc9c249096e3368a16" },
}, },
42170: {
name: "Arbitrum Nova",
nativeCurrency: {
name: "Ether",
symbol: "ETH",
decimals: 18,
},
rpc: ["https://nova.arbitrum.io/rpc"],
explorers: [
{
name: "Arbitrum Nova Chain Explorer",
url: "https://nova-explorer.arbitrum.io",
icon: "blockscout",
standard: "EIP3091",
},
],
txConst: {
blockTimeSec: 3,
rbfTimes: 5,
boardcastTimes: 10,
},
contracts: { factory: "0x6B7315a594263A886e8DecE2FfCB7b37cab0941b" },
},
421613: { 421613: {
name: "Arbitrum - Goerli", name: "Arbitrum Goerli",
nativeCurrency: { nativeCurrency: {
name: "Arbitrum Ether", name: "Arbitrum Ether",
symbol: "ETH", symbol: "ETH",

@ -39,6 +39,10 @@ function loadCache() {
start: 9623490, start: 9623490,
last: 9623490, last: 9623490,
}, },
42170: {
start: 2699199,
last: 2699199,
},
}, },
hubs: {}, hubs: {},
ns: { ns: {

@ -2,6 +2,7 @@ import { Ref, Status, Storage } from "./storage.js"
import { ethers } from "ethers" import { ethers } from "ethers"
import { TxManager } from "../common/tx-manager.js" import { TxManager } from "../common/tx-manager.js"
import { Git3Protocol } from "../common/git3-protocol.js" import { Git3Protocol } from "../common/git3-protocol.js"
import { Retrier } from "../common/queue-task.js"
export class ETHStorage implements Storage { export class ETHStorage implements Storage {
repoName: string repoName: string
@ -26,7 +27,10 @@ export class ETHStorage implements Storage {
} }
async download(path: string): Promise<[Status, Buffer]> { async download(path: string): Promise<[Status, Buffer]> {
const res = await this.contract.download(Buffer.from(this.repoName), Buffer.from(path)) const res = await Retrier(
async () => await this.contract.download(Buffer.from(this.repoName), Buffer.from(path)),
{ maxRetry: 10 }
)
const buffer = Buffer.from(res[0].slice(2), "hex") const buffer = Buffer.from(res[0].slice(2), "hex")
console.error(`=== download file ${path} succeed ===`) console.error(`=== download file ${path} succeed ===`)
return [Status.SUCCEED, buffer] return [Status.SUCCEED, buffer]
@ -111,7 +115,10 @@ export class ETHStorage implements Storage {
} }
async listRefs(): Promise<Ref[]> { async listRefs(): Promise<Ref[]> {
const res: string[][] = await this.contract.listRepoRefs(Buffer.from(this.repoName)) const res: string[][] = await Retrier(
async () => await this.contract.listRepoRefs(Buffer.from(this.repoName)),
{ maxRetry: 3 }
)
let refs = res.map((i) => ({ let refs = res.map((i) => ({
ref: Buffer.from(i[1].slice(2), "hex") ref: Buffer.from(i[1].slice(2), "hex")
.toString("utf8") .toString("utf8")

@ -51,7 +51,6 @@ export class SLIStorage implements Storage {
}) })
} }
async hasPermission(ref: string): Promise<boolean> { async hasPermission(ref: string): Promise<boolean> {
let sender = await this.wallet.getAddress() let sender = await this.wallet.getAddress()
let isMember = await this.contract.isRepoMembership(Buffer.from(this.repoName), sender) let isMember = await this.contract.isRepoMembership(Buffer.from(this.repoName), sender)
@ -173,7 +172,10 @@ export class SLIStorage implements Storage {
} }
async listRefs(): Promise<Ref[]> { async listRefs(): Promise<Ref[]> {
const res: string[][] = await this.contract.listRepoRefs(Buffer.from(this.repoName)) const res: string[][] = await Retrier(
async () => await this.contract.listRepoRefs(Buffer.from(this.repoName)),
{ maxRetry: 3 }
)
let refs = res.map((i) => ({ let refs = res.map((i) => ({
ref: Buffer.from(i[1].slice(2), "hex") ref: Buffer.from(i[1].slice(2), "hex")
.toString("utf8") .toString("utf8")

Loading…
Cancel
Save