From 5d7421b626847ea0e0b5b3ca2b13b8c37e50cdd3 Mon Sep 17 00:00:00 2001 From: cyhhao Date: Thu, 2 Mar 2023 11:45:34 +0800 Subject: [PATCH] change latest contract --- src/config/abis.ts | 904 +----------------------------------- src/config/evm-network.ts | 4 +- src/config/name-services.ts | 2 +- src/git3/index.ts | 207 +++++---- src/scripts/sync.ts | 12 +- 5 files changed, 124 insertions(+), 1005 deletions(-) diff --git a/src/config/abis.ts b/src/config/abis.ts index 81f2f65..feb4f18 100644 --- a/src/config/abis.ts +++ b/src/config/abis.ts @@ -3,907 +3,5 @@ export default { '[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"address","name":"hub","type":"address"}],"name":"RegisterHub","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"}],"name":"HubRecords","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"hubName","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"}],"name":"nameHub","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"nameList","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nameListLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"}],"name":"nameOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"address","name":"hub","type":"address"}],"name":"rebindHubAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"address","name":"hub","type":"address"}],"name":"registerHub","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferNameOwner","outputs":[],"stateMutability":"nonpayable","type":"function"}]', Factory: '[{"inputs":[{"internalType":"bool","name":"_dbSelector","type":"bool"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"hub","type":"address"},{"indexed":true,"internalType":"address","name":"creator","type":"address"}],"name":"CreateHub","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[{"internalType":"bool","name":"isPermissionless","type":"bool"}],"name":"createHub","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"dbSelector","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"hubImp","outputs":[{"internalType":"contract Hubv3","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"hubs","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"newHubImp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"setHubImp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]', - Hub: [ - { - "inputs": [], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint8", - "name": "version", - "type": "uint8" - } - ], - "name": "Initialized", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "bytes32", - "name": "previousAdminRole", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "bytes32", - "name": "newAdminRole", - "type": "bytes32" - } - ], - "name": "RoleAdminChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "sender", - "type": "address" - } - ], - "name": "RoleGranted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "sender", - "type": "address" - } - ], - "name": "RoleRevoked", - "type": "event" - }, - { - "inputs": [], - "name": "CONTRIBUTOR", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "DEFAULT_ADMIN_ROLE", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "MANAGER", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "NOTFOUND", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "RoleList", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "member", - "type": "address" - } - ], - "name": "addContributor", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "member", - "type": "address" - } - ], - "name": "addManager", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "repoName", - "type": "bytes" - }, - { - "internalType": "address", - "name": "con", - "type": "address" - } - ], - "name": "addRepoContributor", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "repoName", - "type": "bytes" - }, - { - "internalType": "bytes[]", - "name": "path", - "type": "bytes[]" - }, - { - "internalType": "bytes[]", - "name": "data", - "type": "bytes[]" - } - ], - "name": "batchUpload", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "repoName", - "type": "bytes" - } - ], - "name": "createRepo", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "db", - "outputs": [ - { - "internalType": "contract database", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "repoName", - "type": "bytes" - }, - { - "internalType": "bytes", - "name": "branchPath", - "type": "bytes" - } - ], - "name": "delRepoRef", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "repoName", - "type": "bytes" - } - ], - "name": "deleteRepo", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "repoName", - "type": "bytes" - }, - { - "internalType": "bytes", - "name": "path", - "type": "bytes" - } - ], - "name": "download", - "outputs": [ - { - "internalType": "bytes", - "name": "", - "type": "bytes" - }, - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getAllMembers", - "outputs": [ - { - "internalType": "address[]", - "name": "admins", - "type": "address[]" - }, - { - "internalType": "address[]", - "name": "managers", - "type": "address[]" - }, - { - "internalType": "address[]", - "name": "cons", - "type": "address[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - } - ], - "name": "getMembersByRole", - "outputs": [ - { - "internalType": "address[]", - "name": "members", - "type": "address[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "repoName", - "type": "bytes" - }, - { - "internalType": "bytes", - "name": "branchPath", - "type": "bytes" - } - ], - "name": "getRepoRef", - "outputs": [ - { - "internalType": "bytes20", - "name": "", - "type": "bytes20" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - } - ], - "name": "getRoleAdmin", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "index", - "type": "uint256" - } - ], - "name": "getRoleMember", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - } - ], - "name": "getRoleMemberCount", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "grantRole", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "hasRole", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bool", - "name": "dbSelector", - "type": "bool" - }, - { - "internalType": "address", - "name": "user", - "type": "address" - }, - { - "internalType": "bool", - "name": "isPermissionless", - "type": "bool" - } - ], - "name": "initialize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "repoName", - "type": "bytes" - }, - { - "internalType": "address", - "name": "member", - "type": "address" - } - ], - "name": "isRepoMembership", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "repoName", - "type": "bytes" - } - ], - "name": "listRepoRefs", - "outputs": [ - { - "components": [ - { - "internalType": "bytes20", - "name": "hash", - "type": "bytes20" - }, - { - "internalType": "bytes", - "name": "name", - "type": "bytes" - } - ], - "internalType": "struct Repolib.refData[]", - "name": "list", - "type": "tuple[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "member", - "type": "address" - } - ], - "name": "memberRole", - "outputs": [ - { - "internalType": "bool", - "name": "IsAdmin", - "type": "bool" - }, - { - "internalType": "bool", - "name": "IsManager", - "type": "bool" - }, - { - "internalType": "bool", - "name": "IsContributor", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "member", - "type": "address" - } - ], - "name": "membership", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "permissionless", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "permissionlessJoin", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "member", - "type": "address" - } - ], - "name": "removeContributor", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "member", - "type": "address" - } - ], - "name": "removeManager", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "repoName", - "type": "bytes" - }, - { - "internalType": "address", - "name": "con", - "type": "address" - } - ], - "name": "removeRepoContributor", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "renounceRole", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "repoName", - "type": "bytes" - } - ], - "name": "repoContributors", - "outputs": [ - { - "internalType": "address[]", - "name": "", - "type": "address[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "repoList", - "outputs": [ - { - "internalType": "bytes[]", - "name": "rn", - "type": "bytes[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "repoNames", - "outputs": [ - { - "internalType": "bytes", - "name": "", - "type": "bytes" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "repoName", - "type": "bytes" - } - ], - "name": "repoOwner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "revokeRole", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bool", - "name": "open", - "type": "bool" - } - ], - "name": "setPermissonlessJoin", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "repoName", - "type": "bytes" - }, - { - "internalType": "bytes", - "name": "branchPath", - "type": "bytes" - }, - { - "internalType": "bytes20", - "name": "refHash", - "type": "bytes20" - } - ], - "name": "setRepoRef", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes4", - "name": "interfaceId", - "type": "bytes4" - } - ], - "name": "supportsInterface", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "repoName", - "type": "bytes" - }, - { - "internalType": "bytes", - "name": "path", - "type": "bytes" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "name": "upload", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "repoName", - "type": "bytes" - }, - { - "internalType": "bytes", - "name": "path", - "type": "bytes" - }, - { - "internalType": "uint256", - "name": "chunkId", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "name": "uploadChunk", - "outputs": [], - "stateMutability": "payable", - "type": "function" - } - ], + Hub: '[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"repoName","type":"bytes"},{"indexed":false,"internalType":"address","name":"owner","type":"address"}],"name":"RepoCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"repoName","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"branchPath","type":"bytes"},{"indexed":false,"internalType":"bytes20","name":"refHash","type":"bytes20"}],"name":"SetRepoRef","type":"event"},{"inputs":[],"name":"CONTRIBUTOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MANAGER","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"NOTFOUND","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"RoleList","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"member","type":"address"}],"name":"addContributor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"member","type":"address"}],"name":"addManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"repoName","type":"bytes"},{"internalType":"address","name":"con","type":"address"}],"name":"addRepoContributor","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"repoName","type":"bytes"},{"internalType":"bytes[]","name":"path","type":"bytes[]"},{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"batchUpload","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes","name":"repoName","type":"bytes"}],"name":"createRepo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"db","outputs":[{"internalType":"contract database","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"repoName","type":"bytes"},{"internalType":"bytes","name":"branchPath","type":"bytes"}],"name":"delRepoRef","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"repoName","type":"bytes"}],"name":"deleteRepo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"repoName","type":"bytes"},{"internalType":"bytes","name":"path","type":"bytes"}],"name":"download","outputs":[{"internalType":"bytes","name":"","type":"bytes"},{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAllMembers","outputs":[{"internalType":"address[]","name":"admins","type":"address[]"},{"internalType":"address[]","name":"managers","type":"address[]"},{"internalType":"address[]","name":"cons","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getMembersByRole","outputs":[{"internalType":"address[]","name":"members","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"repoName","type":"bytes"},{"internalType":"bytes","name":"branchPath","type":"bytes"}],"name":"getRepoRef","outputs":[{"internalType":"bytes20","name":"","type":"bytes20"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"dbSelector","type":"bool"},{"internalType":"address","name":"user","type":"address"},{"internalType":"bool","name":"isPermissionless","type":"bool"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"repoName","type":"bytes"},{"internalType":"address","name":"member","type":"address"}],"name":"isRepoMembership","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"repoName","type":"bytes"}],"name":"listRepoRefs","outputs":[{"components":[{"internalType":"bytes20","name":"hash","type":"bytes20"},{"internalType":"bytes","name":"name","type":"bytes"}],"internalType":"struct Repolib.refData[]","name":"list","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"member","type":"address"}],"name":"memberRole","outputs":[{"internalType":"bool","name":"IsAdmin","type":"bool"},{"internalType":"bool","name":"IsManager","type":"bool"},{"internalType":"bool","name":"IsContributor","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"member","type":"address"}],"name":"membership","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"permissionless","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"permissionlessJoin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"member","type":"address"}],"name":"removeContributor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"member","type":"address"}],"name":"removeManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"repoName","type":"bytes"},{"internalType":"address","name":"con","type":"address"}],"name":"removeRepoContributor","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"repoName","type":"bytes"}],"name":"repoContributors","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"repoList","outputs":[{"internalType":"bytes[]","name":"rn","type":"bytes[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"repoNames","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"repoName","type":"bytes"}],"name":"repoOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"open","type":"bool"}],"name":"setPermissonlessJoin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"repoName","type":"bytes"},{"internalType":"bytes","name":"branchPath","type":"bytes"},{"internalType":"bytes20","name":"refHash","type":"bytes20"}],"name":"setRepoRef","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"repoName","type":"bytes"},{"internalType":"bytes","name":"path","type":"bytes"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upload","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes","name":"repoName","type":"bytes"},{"internalType":"bytes","name":"path","type":"bytes"},{"internalType":"uint256","name":"chunkId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"uploadChunk","outputs":[],"stateMutability":"payable","type":"function"}]', } diff --git a/src/config/evm-network.ts b/src/config/evm-network.ts index f021474..909af4e 100644 --- a/src/config/evm-network.ts +++ b/src/config/evm-network.ts @@ -89,7 +89,7 @@ const evmNetworks: Record = { txConst: { blockTimeSec: 7, }, - contracts: { factory: "0x719854f2B4767F3D1fE4FBD9Db9cA7c65d9B60c5" }, + contracts: { factory: "0x96f7849C6D0EB09024e482Cc9c249096e3368a16" }, }, 421613: { name: "Arbitrum - Goerli", @@ -114,7 +114,7 @@ const evmNetworks: Record = { rbfTimes: 5, boardcastTimes: 10, }, - contracts: { factory: "0xa709975Bc01e745432f8898499E7b9a60f420117" }, + contracts: { factory: "0x6b7f49b32131288D1833929FBa35bb29d384c3D3" }, }, } diff --git a/src/config/name-services.ts b/src/config/name-services.ts index d3bad57..ccf418c 100644 --- a/src/config/name-services.ts +++ b/src/config/name-services.ts @@ -1,5 +1,5 @@ const ns: Record = { - resolver_: "0xd684DBf9124d6B1f74f37558dD11fdcE0103AF15", + resolver_: "0xE7273B5fd932B525e80Ca1c72381fA6e352C7262", w3q: { chainId: 3334, }, diff --git a/src/git3/index.ts b/src/git3/index.ts index 8c5997f..b10d1ca 100644 --- a/src/git3/index.ts +++ b/src/git3/index.ts @@ -3,7 +3,13 @@ import { ethers } from "ethers" import { Command } from "commander" import bip39 from "bip39" import inquirer from "inquirer" -import { importActions, generateActions,createHubActions,HubMemberActions,HubGetMemberActions } from "./actions.js" +import { + importActions, + generateActions, + createHubActions, + HubMemberActions, + HubGetMemberActions, +} from "./actions.js" import network from "../config/evm-network.js" import { explorerTxUrl, getWallet, randomRPC } from "../common/wallet.js" import { initFactoryByChainID, parseGit3URI } from "../common/git3-protocol.js" @@ -13,17 +19,13 @@ const program = new Command() program.name("git3").description("git3 mangement tool").version("0.1.0") -let wallet = program - .command("wallet") - .description("wallet [create/import/delete/list]") +let wallet = program.command("wallet").description("wallet [create/import/delete/list]") let hub = program .command("hub") .description("hub [create/join/list/members/add-member/remove-member]") -let repo = program - .command("repo") - .description("repo [create/members/add-member/remove-member]") +let repo = program.command("repo").description("repo [create/members/add-member/remove-member]") wallet .command("create") @@ -184,16 +186,13 @@ wallet }) // =============================Hub Commands=================================== -hub - .command("create") +hub.command("create") .argument("", "chain name or chain id") .description("create a new hub") .action(async (chain) => { - - let answers = await inquirer.prompt(createHubActions) - const {permissionless} = answers - let isPermissionless = permissionless === "yes"? true:false + const { permissionless } = answers + let isPermissionless = permissionless === "yes" ? true : false console.log(`creating hub with permissionless:${isPermissionless} ...`) @@ -213,13 +212,13 @@ hub } }) .filter((item: any) => item !== null && item.name === "CreateHub") - - console.log("hub address:", events[0].args.hub) + let hubAddr = events[0].args.hub + console.log("hub address:", hubAddr) console.log("hub owner:", events[0].args.creator) + console.log(`You can use ${hubAddr}:${protocol.chainId} to represent this hub`) }) -hub - .command("join") +hub.command("join") .argument("", "hub_name.NS or hub_address:chain_id") .description("join a permissionless hub") .action(async (hub) => { @@ -234,66 +233,68 @@ hub console.log(explorerTxUrl(receipt.transactionHash, protocol.netConfig.explorers)) }) -hub - .command("members") +hub.command("members") .argument("", "hub_name.NS or hub_address:chain_id") .description("get members corresponding to the role from hub") .action(async (hub) => { let protocol = await parseGit3URI(hub, { ignoreProtocolHeader: true, skipRepoName: true }) let answers = await inquirer.prompt(HubGetMemberActions) - let role:string = "0x0000000000000000000000000000000000000000000000000000000000000000"; - + let role: string = "0x0000000000000000000000000000000000000000000000000000000000000000" + if (answers.role == "admin") { role = "0x0000000000000000000000000000000000000000000000000000000000000000" - }else if (answers.role == "manager") { + } else if (answers.role == "manager") { role = "0x0000000000000000000000000000000000000000000000000000000000000001" - }else if (answers.role == "contributor") { + } else if (answers.role == "contributor") { role = "0x0000000000000000000000000000000000000000000000000000000000000002" - }else { + } else { throw new Error(`Invalid role ${answers.role}`) } - + console.error(`role:${role}`) let members = await protocol.hub.getMembersByRole(role) console.error(`${answers.role} : ${members}`) }) -hub - .command("allMembers") +hub.command("allMembers") .argument("", "hub_name.NS or hub_address:chain_id") .description("get all members from hub") .action(async (hub) => { let protocol = await parseGit3URI(hub, { ignoreProtocolHeader: true, skipRepoName: true }) - let [admins, managers ,cons] = await protocol.hub.getAllMembers() + let [admins, managers, cons] = await protocol.hub.getAllMembers() console.error(`admins : ${admins}`) console.error(`managers : ${managers}`) console.error(`contributors : ${cons}`) }) - -hub - .command("add-member") +hub.command("add-member") .argument("", "member address which will be added to the hub") .option("-u, --uri ", "hub_name.NS or hub_address:chain_id") .description("add a manager/contributor into hub") - .action(async (member,options) => { - + .action(async (member, options) => { let answers = await inquirer.prompt(HubMemberActions) - let memberIsManager = answers.role === 'manager' ? true: false - let protocol = await parseGit3URI(options.uri, { ignoreProtocolHeader: true, skipRepoName: true }) + let memberIsManager = answers.role === "manager" ? true : false + let protocol = await parseGit3URI(options.uri, { + ignoreProtocolHeader: true, + skipRepoName: true, + }) - if (memberIsManager){ - let [isAdmin,isManager,isContributor] = await protocol.hub.memberRole(protocol.wallet.address) + if (memberIsManager) { + let [isAdmin, isManager, isContributor] = await protocol.hub.memberRole( + protocol.wallet.address + ) if (!isAdmin) { let hubName = protocol.ns ? `${protocol.nsName}.${protocol.nsDomain}` : protocol.hubAddress - console.error(`[addManager] can only be executed with the admin authority of this hub: ${hubName}`) + console.error( + `[addManager] can only be executed with the admin authority of this hub: ${hubName}` + ) return } - [isAdmin,isManager,isContributor] = await protocol.hub.memberRole(member) + ;[isAdmin, isManager, isContributor] = await protocol.hub.memberRole(member) if (isManager) { let hubName = protocol.ns ? `${protocol.nsName}.${protocol.nsDomain}` @@ -302,20 +303,28 @@ hub return } - const txManager = new TxManager(protocol.hub, protocol.chainId, protocol.netConfig.txConst) + const txManager = new TxManager( + protocol.hub, + protocol.chainId, + protocol.netConfig.txConst + ) let receipt = await txManager.SendCall("addManager", [member]) console.log(explorerTxUrl(receipt.transactionHash, protocol.netConfig.explorers)) - }else{ - let [isAdmin,isManager,isContributor] = await protocol.hub.memberRole(protocol.wallet.address) + } else { + let [isAdmin, isManager, isContributor] = await protocol.hub.memberRole( + protocol.wallet.address + ) if (!isManager) { let hubName = protocol.ns ? `${protocol.nsName}.${protocol.nsDomain}` : protocol.hubAddress - console.error(`[addContributor] can only be executed with the manager authority of this hub: ${hubName}`) + console.error( + `[addContributor] can only be executed with the manager authority of this hub: ${hubName}` + ) return } - - [isAdmin,isManager,isContributor] = await protocol.hub.memberRole(member) + + ;[isAdmin, isManager, isContributor] = await protocol.hub.memberRole(member) if (isContributor) { let hubName = protocol.ns ? `${protocol.nsName}.${protocol.nsDomain}` @@ -323,37 +332,43 @@ hub console.error(`${member} is already a contributor to hub: ${hubName}`) return } - const txManager = new TxManager(protocol.hub, protocol.chainId, protocol.netConfig.txConst) + const txManager = new TxManager( + protocol.hub, + protocol.chainId, + protocol.netConfig.txConst + ) let receipt = await txManager.SendCall("addContributor", [member]) console.log(explorerTxUrl(receipt.transactionHash, protocol.netConfig.explorers)) } - }) - - -hub - .command("remove-member") +hub.command("remove-member") .argument("", "manager address") .option("-u, --uri ", "hub_name.NS or hub_address:chain_id") .description("remove a manager/contributor from hub") - .action(async (member,options) => { - + .action(async (member, options) => { let answers = await inquirer.prompt(HubMemberActions) - let memberIsManager = answers.role === 'manager' ? true: false - let protocol = await parseGit3URI(options.uri, { ignoreProtocolHeader: true, skipRepoName: true }) + let memberIsManager = answers.role === "manager" ? true : false + let protocol = await parseGit3URI(options.uri, { + ignoreProtocolHeader: true, + skipRepoName: true, + }) - if (memberIsManager){ - let [isAdmin,isManager,isContributor] = await protocol.hub.memberRole(protocol.wallet.address) + if (memberIsManager) { + let [isAdmin, isManager, isContributor] = await protocol.hub.memberRole( + protocol.wallet.address + ) if (!isAdmin) { let hubName = protocol.ns ? `${protocol.nsName}.${protocol.nsDomain}` : protocol.hubAddress - console.error(`[removeManager] can only be executed with the admin authority of this hub: ${hubName}`) + console.error( + `[removeManager] can only be executed with the admin authority of this hub: ${hubName}` + ) return } - [isAdmin,isManager,isContributor] = await protocol.hub.memberRole(member) + ;[isAdmin, isManager, isContributor] = await protocol.hub.memberRole(member) if (!isManager) { let hubName = protocol.ns ? `${protocol.nsName}.${protocol.nsDomain}` @@ -362,20 +377,28 @@ hub return } - const txManager = new TxManager(protocol.hub, protocol.chainId, protocol.netConfig.txConst) + const txManager = new TxManager( + protocol.hub, + protocol.chainId, + protocol.netConfig.txConst + ) let receipt = await txManager.SendCall("removeManager", [member]) console.log(explorerTxUrl(receipt.transactionHash, protocol.netConfig.explorers)) - }else{ - let [isAdmin,isManager,isContributor] = await protocol.hub.memberRole(protocol.wallet.address) + } else { + let [isAdmin, isManager, isContributor] = await protocol.hub.memberRole( + protocol.wallet.address + ) if (!isManager) { let hubName = protocol.ns ? `${protocol.nsName}.${protocol.nsDomain}` : protocol.hubAddress - console.error(`[removeContributor] can only be executed with the manager authority of this hub: ${hubName}`) + console.error( + `[removeContributor] can only be executed with the manager authority of this hub: ${hubName}` + ) return } - [isAdmin,isManager,isContributor] = await protocol.hub.memberRole(member) + ;[isAdmin, isManager, isContributor] = await protocol.hub.memberRole(member) if (!isContributor) { let hubName = protocol.ns ? `${protocol.nsName}.${protocol.nsDomain}` @@ -383,17 +406,19 @@ hub console.error(`${member} is not a contributor to hub: ${hubName}`) return } - const txManager = new TxManager(protocol.hub, protocol.chainId, protocol.netConfig.txConst) + const txManager = new TxManager( + protocol.hub, + protocol.chainId, + protocol.netConfig.txConst + ) let receipt = await txManager.SendCall("removeContributor", [member]) console.log(explorerTxUrl(receipt.transactionHash, protocol.netConfig.explorers)) } - }) // =============================Repo Commands=================================== -repo - .command("list") +repo.command("list") .argument("", "hub_name.NS or hub_address:chain_id") .description("get all members from hub") .action(async (hub) => { @@ -402,8 +427,7 @@ repo console.error(`repos : ${repos}`) }) -repo - .command("create") +repo.command("create") .argument("", "ex: git3.w3q/repo_name or hub_addr:chainid/repo_name") .description("create a new repo") .action(async (uri) => { @@ -418,12 +442,9 @@ repo console.error(`you are not a member of this hub: ${hubName}`) let isPermissionless = await protocol.hub.permissionless() if (isPermissionless) { - - console.error( - `this hub is permissionless, you are joining this hub ${hubName}` - ) - - let rec = await txManager.SendCall("permissionlessJoin",[]) + console.error(`this hub is permissionless, you are joining this hub ${hubName}`) + + let rec = await txManager.SendCall("permissionlessJoin", []) console.log(explorerTxUrl(rec.transactionHash, protocol.netConfig.explorers)) console.log(`already joined hub: ${hubName}`) @@ -449,9 +470,7 @@ repo console.log(`repo ${protocol.repoName} created.`) }) - -repo - .command("members") +repo.command("members") .argument("", "ex: git3.w3q/repo_name or hub_addr:chainid/repo_name") .description("get all members information of the repository") .action(async (uri) => { @@ -462,13 +481,15 @@ repo console.log(`owner:${owner} \ncontributors:${contributors}`) }) -repo - .command("add-member") - .argument("","contributor address") - .option("-u, --uri ","ex: git3.w3q/repo_name or hub_addr:chainid/repo_name") +repo.command("add-member") + .argument("", "contributor address") + .option("-u, --uri ", "ex: git3.w3q/repo_name or hub_addr:chainid/repo_name") .description("add a contributor into the specified repository") - .action(async (conAddr,options) => { - let protocol = await parseGit3URI(options.uri, { ignoreProtocolHeader: true, skipRepoName: true }) + .action(async (conAddr, options) => { + let protocol = await parseGit3URI(options.uri, { + ignoreProtocolHeader: true, + skipRepoName: true, + }) let owner = await protocol.hub.repoOwner(Buffer.from(protocol.repoName)) if (owner != protocol.wallet.address) { let hubName = protocol.ns @@ -486,14 +507,15 @@ repo console.log(explorerTxUrl(receipt.transactionHash, protocol.netConfig.explorers)) }) - -repo - .command("remove-member") - .argument("","contributor address") - .option("-u, --uri ","ex: git3.w3q/repo_name or hub_addr:chainid/repo_name") +repo.command("remove-member") + .argument("", "contributor address") + .option("-u, --uri ", "ex: git3.w3q/repo_name or hub_addr:chainid/repo_name") .description("remove a contributor from the specified repository") - .action(async (conAddr,options) => { - let protocol = await parseGit3URI(options.uri, { ignoreProtocolHeader: true, skipRepoName: true }) + .action(async (conAddr, options) => { + let protocol = await parseGit3URI(options.uri, { + ignoreProtocolHeader: true, + skipRepoName: true, + }) let owner = await protocol.hub.repoOwner(Buffer.from(protocol.repoName)) if (owner != protocol.wallet.address) { let hubName = protocol.ns @@ -511,7 +533,6 @@ repo console.log(explorerTxUrl(receipt.transactionHash, protocol.netConfig.explorers)) }) - // Todo: set-wallet temporarily useless // program // .command("set-wallet") diff --git a/src/scripts/sync.ts b/src/scripts/sync.ts index c651676..2aff3eb 100644 --- a/src/scripts/sync.ts +++ b/src/scripts/sync.ts @@ -32,18 +32,18 @@ function loadCache() { return { factory: { 3334: { - start: 5375112, - last: 5375112, + start: 5413325, + last: 5413325, }, 421613: { - start: 9341366, - last: 9341366, + start: 9623490, + last: 9623490, }, }, hubs: {}, ns: { - start: 9340900, - last: 9340900, + start: 9622844, + last: 9622844, nameHub: {}, hubName: {}, },