From de0617959565e47a62239f76787c5802a350887c Mon Sep 17 00:00:00 2001 From: cyl19970726 <15258378443@163.com> Date: Mon, 27 Feb 2023 18:13:36 +0800 Subject: [PATCH 1/4] update src/config/evm-network.ts --- src/config/evm-network.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/evm-network.ts b/src/config/evm-network.ts index ad79bff..d9888c0 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: "0xF2CAd0c8997584D8DDe1c0726De0Fa9ECC3dDa04" }, + contracts: { factory: "0x9f0a56c4b11b6f65454C205b79C91424B5C6d590" }, }, 421613: { name: "Arbitrum - Goerli", From d0d3e8441536a552ab007cef1636200826eba8aa Mon Sep 17 00:00:00 2001 From: cyl19970726 <15258378443@163.com> Date: Mon, 27 Feb 2023 18:23:20 +0800 Subject: [PATCH 2/4] update hub contract_abi --- src/config/abis.ts | 858 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 857 insertions(+), 1 deletion(-) diff --git a/src/config/abis.ts b/src/config/abis.ts index 5484e6c..c7795b9 100644 --- a/src/config/abis.ts +++ b/src/config/abis.ts @@ -3,5 +3,861 @@ export default { '[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"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":"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":[{"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":"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"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","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":[{"internalType":"bool","name":"open","type":"bool"}],"name":"openPermissonlessJoin","outputs":[],"stateMutability":"nonpayable","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":[{"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":"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"}]', + 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": [ + { + "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" + } + ], + "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": "bytes32", + "name": "role", + "type": "bytes32" + } + ], + "name": "roleToMembers", + "outputs": [ + { + "internalType": "address[]", + "name": "members", + "type": "address[]" + } + ], + "stateMutability": "view", + "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" + } + ], + } From e2a3c743d5ff87d93fe29c14f10c336565fa52cc Mon Sep 17 00:00:00 2001 From: cyl19970726 <15258378443@163.com> Date: Mon, 27 Feb 2023 18:24:53 +0800 Subject: [PATCH 3/4] support uploadChunk on ETHStorage --- src/storage/ETHStorage.ts | 63 ++++++++++++++++++++++++++++++++++----- 1 file changed, 56 insertions(+), 7 deletions(-) diff --git a/src/storage/ETHStorage.ts b/src/storage/ETHStorage.ts index d9e01b3..925565b 100644 --- a/src/storage/ETHStorage.ts +++ b/src/storage/ETHStorage.ts @@ -2,7 +2,9 @@ import { Ref, Status, Storage } from "./storage.js" import { ethers } from "ethers" import { TxManager } from "../common/tx-manager.js" import { Git3Protocol } from "../common/git3-protocol.js" +import { buffer } from "stream/consumers" + export class ETHStorage implements Storage { repoName: string wallet: ethers.Signer @@ -39,14 +41,61 @@ export class ETHStorage implements Storage { async upload(path: string, file: Buffer): Promise { try { - console.error(`=== uploading file ${path} ===`) - await this.txManager.SendCall("upload", [ - Buffer.from(this.repoName), - Buffer.from(path), - file, - ]) - console.error(`=== upload ${path} succeed ===`) + let chunks: Buffer[] = []; + let costs:number[] = []; + const FileChunkSize = 475 * 1024 + const perEthPayStorageSize = 24 * 1024 + const initCodeLen = 280; + if (file.length > FileChunkSize) { + let uploadedSize = 0; + let nouploadfileSize = file.length; + for (uploadedSize = 0; uploadedSize < file.length; uploadedSize += FileChunkSize) { + let newchunk:Buffer; + let cost:number; + if (file.length != nouploadfileSize + uploadedSize){ + throw new Error(`file.length${file.length} != nouploadfileSize${nouploadfileSize} + uploadedSize${uploadedSize}`) + } + if (nouploadfileSize < FileChunkSize){ + newchunk = Buffer.alloc(nouploadfileSize) + file.copy(newchunk, 0,uploadedSize,file.length) + cost = Math.ceil((nouploadfileSize+ initCodeLen) / perEthPayStorageSize) + }else{ + newchunk = Buffer.alloc(FileChunkSize) + file.copy(newchunk, 0,uploadedSize,uploadedSize+FileChunkSize) + cost = Math.ceil((FileChunkSize+initCodeLen) / perEthPayStorageSize) + nouploadfileSize -= FileChunkSize; + } + chunks.push(newchunk); + costs.push(cost); + } + + chunks.forEach(async (context,index) => { + console.error(`=== uploading file chunk ${path} chunkId-${index} chunk_size:${context.length} storage_cost:${costs[index]}-token===`) + await this.txManager.SendCall("uploadChunk", [ + Buffer.from(this.repoName), + Buffer.from(path), + index, + context, + {value:ethers.utils.parseEther(costs[index].toString())}, + ]); + console.error(`=== upload file chunk ${path} chunkId-${index} chunk_size:${context.length} storage_cost:${costs[index]}-token Succeed===`) + }) + + } else { + let cost:number = 0; + if (file.length > perEthPayStorageSize){ + cost = Math.ceil(file.length / perEthPayStorageSize); + } + console.error(`=== uploading file ${path} file_size ${file.length} storage_cost:${cost}-token===`) + await this.txManager.SendCall("upload", [ + Buffer.from(this.repoName), + Buffer.from(path), + file, + {value:ethers.utils.parseEther(cost.toString())}, + ]) + console.error(`=== upload ${path} file_size ${file.length} storage_cost:${cost}-token succeed ===`) + } return Status.SUCCEED } catch (error: any) { this.txManager.CancelAll() From 3419e228f0db6038000524c2722c6d4ce0679fef Mon Sep 17 00:00:00 2001 From: cyl19970726 <15258378443@163.com> Date: Mon, 27 Feb 2023 20:50:44 +0800 Subject: [PATCH 4/4] update cli --- src/git3/actions.ts | 24 +++ src/git3/index.ts | 426 +++++++++++++++++++++++--------------------- 2 files changed, 242 insertions(+), 208 deletions(-) diff --git a/src/git3/actions.ts b/src/git3/actions.ts index 80f619b..8fde65e 100644 --- a/src/git3/actions.ts +++ b/src/git3/actions.ts @@ -41,4 +41,28 @@ export const importActions = [ return 'default' }, } +] + +export const createHubActions = [ + { + type: 'list', + name: 'permissionless', + message: 'can anyone join hub?', + choices: [ + 'yes', + 'no', + ], + }, +] + +export const HubMemberActions = [ + { + type: 'list', + name: 'role', + message: 'add contributor or manager into hub', + choices: [ + 'contribotor', + 'manager', + ], + }, ] \ No newline at end of file diff --git a/src/git3/index.ts b/src/git3/index.ts index 056a93f..225d0b9 100644 --- a/src/git3/index.ts +++ b/src/git3/index.ts @@ -3,7 +3,7 @@ import { ethers } from "ethers" import { Command } from "commander" import bip39 from "bip39" import inquirer from "inquirer" -import { importActions, generateActions } from "./actions.js" +import { importActions, generateActions,createHubActions,HubMemberActions } from "./actions.js" import network from "../config/evm-network.js" import { explorerTxUrl, getWallet, randomRPC, setupContract } from "../common/wallet.js" import { parseGit3URI } from "../common/git3-protocol.js" @@ -15,10 +15,20 @@ const program = new Command() program.name("git3").description("git3 mangement tool").version("0.1.0") -program - .command("generate") - .alias("gen") - .alias("new") +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]") + +wallet + .command("create") .description("generate a cryto wallet to use git3") .action(() => { inquirer.prompt(generateActions).then((answers) => { @@ -47,9 +57,8 @@ program }) }) -program - .command("list", { isDefault: true }) - .alias("ls") +wallet + .command("list") .description("list all wallets in user folder ~/.git3/keys") .option("-r, --raw", "output raw wallet data with pravate key / mnemonic") .action((params) => { @@ -83,7 +92,7 @@ program }) }) -program +wallet .command("import") .description("import a wallet from a private key or mnemonic") .action(() => { @@ -104,7 +113,7 @@ program }) }) -program +wallet .command("delete") .description("delete a wallet") .action(() => { @@ -132,16 +141,45 @@ program }) }) -let create = program - .command("create") - .description("create hub [is_permissionless] OR create repo ") +wallet + .command("info") + .argument("[wallet]", "wallet you want to get info", "default") + .description("get info of a wallet") + .action((wallet) => { + let etherWallet = getWallet(wallet) -create - .command("hub") + const address = etherWallet.address + + console.log(`wallet: ${wallet}`) + console.log(`address: ${address}`) + + for (let [_, net] of Object.entries(network)) { + const provider = new ethers.providers.JsonRpcProvider(randomRPC(net.rpc)) + const balance = provider.getBalance(address) + balance.then((res) => { + console.log( + `[${net.name}] balance: ${ethers.utils.formatUnits( + res, + net.nativeCurrency.decimals + )} ${net.nativeCurrency.symbol}` + ) + }) + } + }) + + +hub + .command("create") .argument("", "chain name or chain id") - .argument("[is_permissionless]", "true or false", false) .description("create a new hub") - .action(async (chain, isPermissionless) => { + .action(async (chain) => { + + + let answers = await inquirer.prompt(createHubActions) + const {permissionless} = answers + let isPermissionless = permissionless === "yes"? true:false + + console.log(`creating hub with permissionless:${isPermissionless} ...`) let netConfig, chainId chainId = parseInt(chain) if (chainId) { @@ -177,48 +215,26 @@ create console.log("hub owner:", events[0].args.creator) }) -create - .command("repo") - .argument("", "ex: git3.w3q/repo_name or hub_addr:chainid/repo_name") - .description("create a new repo") - .action(async (uri) => { - const protocol = await parseGit3URI(uri, { ignoreProtocolHeader: true }) - - let isMember = await protocol.hub.membership(protocol.wallet.address) - if (!isMember) { - let hubName = protocol.ns - ? `${protocol.nsName}.${protocol.nsDomain}` - : protocol.hubAddress - 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 can join it with: git3 join ${hubName}` - ) - } else { - console.error( - `this hub is not permissionless, you can ask the hub owner to add you as a member` - ) - } - return - } - - let owner = await protocol.hub.repoOwner(Buffer.from(protocol.repoName)) - - if (owner != "0x0000000000000000000000000000000000000000") { - console.error(`repo ${protocol.repoName} already exists`) - return +wallet + .command("clear") + .description("clear pending nonce") + .argument("", "ex: default@git3.w3q") + .argument("[num]", "number of pending nonce to clear", 1) + .action(async (uri, num) => { + if (!uri.startsWith("git3://")) { + uri = "git3://" + uri } - - console.log(`creating repo ${protocol.repoName} on ${protocol.netConfig.name}...`) + const protocol = await parseGit3URI(uri, { skipRepoName: true }) const txManager = new TxManager(protocol.hub, protocol.chainId, protocol.netConfig.txConst) - let receipt = await txManager.SendCall("createRepo", [Buffer.from(protocol.repoName)]) - - console.log(explorerTxUrl(receipt.transactionHash, protocol.netConfig.explorers)) - console.log(`repo ${protocol.repoName} created.`) + let nonce = await protocol.wallet.getTransactionCount() + console.log(`current nonce: ${nonce}`) + await txManager.clearPendingNonce(num) + nonce = await protocol.wallet.getTransactionCount() + console.log(`current nonce: ${nonce}`) }) -program +// =============================Hub Commands=================================== +hub .command("join") .argument("", "hub_name.NS or hub_address:chain_id") .description("join a permissionless hub") @@ -234,130 +250,169 @@ program console.log(explorerTxUrl(receipt.transactionHash, protocol.netConfig.explorers)) }) -program - .command("addManager") - .argument("", "hub_name.NS or hub_address:chain_id") - .argument("", "manager address") - .description("add a manager into hub") - .action(async (hub,managerAddr) => { - let protocol = await parseGit3URI(hub, { ignoreProtocolHeader: true, skipRepoName: true }) - 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}`) - return - } +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) => { + + let answers = await inquirer.prompt(HubMemberActions) + 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 (!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}`) + return + } - [isAdmin,isManager,isContributor] = await protocol.hub.memberRole(managerAddr) - if (isManager) { - let hubName = protocol.ns - ? `${protocol.nsName}.${protocol.nsDomain}` - : protocol.hubAddress - console.error(`${managerAddr} is already a manager to hub: ${hubName}`) - return - } + [isAdmin,isManager,isContributor] = await protocol.hub.memberRole(member) + if (isManager) { + let hubName = protocol.ns + ? `${protocol.nsName}.${protocol.nsDomain}` + : protocol.hubAddress + console.error(`${member} is already a manager to hub: ${hubName}`) + return + } - const txManager = new TxManager(protocol.hub, protocol.chainId, protocol.netConfig.txConst) - let receipt = await txManager.SendCall("addManager", [managerAddr]) - console.log(explorerTxUrl(receipt.transactionHash, protocol.netConfig.explorers)) + 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) + 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}`) + return + } + + [isAdmin,isManager,isContributor] = await protocol.hub.memberRole(member) + if (isContributor) { + let hubName = protocol.ns + ? `${protocol.nsName}.${protocol.nsDomain}` + : protocol.hubAddress + console.error(`${member} is already a contributor to hub: ${hubName}`) + return + } + 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)) + } + }) + + program .command("removeManager") - .argument("", "hub_name.NS or hub_address:chain_id") .argument("", "manager address") - .description("remove a manager from hub") - .action(async (hub,managerAddr) => { - let protocol = await parseGit3URI(hub, { ignoreProtocolHeader: true, skipRepoName: true }) - 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}`) - return - } - - [isAdmin,isManager,isContributor] = await protocol.hub.memberRole(managerAddr) - if (!isManager) { - let hubName = protocol.ns - ? `${protocol.nsName}.${protocol.nsDomain}` - : protocol.hubAddress - console.error(`${managerAddr} is not a manager to hub: ${hubName}`) - return - } + .option("-u, --uri ", "hub_name.NS or hub_address:chain_id") + .description("remove a manager/contributor from hub") + .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 }) + + 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}`) + return + } - const txManager = new TxManager(protocol.hub, protocol.chainId, protocol.netConfig.txConst) - let receipt = await txManager.SendCall("removeManager", [managerAddr]) - console.log(explorerTxUrl(receipt.transactionHash, protocol.netConfig.explorers)) - }) + [isAdmin,isManager,isContributor] = await protocol.hub.memberRole(member) + if (!isManager) { + let hubName = protocol.ns + ? `${protocol.nsName}.${protocol.nsDomain}` + : protocol.hubAddress + console.error(`${member} is not a manager to hub: ${hubName}`) + return + } -program - .command("addCon") - .argument("", "hub_name.NS or hub_address:chain_id") - .argument("", "contributor address") - .description("add a manager into hub") - .action(async (hub,contributorAddr) => { - let protocol = await parseGit3URI(hub, { ignoreProtocolHeader: true, skipRepoName: true }) - 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}`) - return - } + 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) + 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}`) + return + } - [isAdmin,isManager,isContributor] = await protocol.hub.memberRole(contributorAddr) - if (isContributor) { - let hubName = protocol.ns - ? `${protocol.nsName}.${protocol.nsDomain}` - : protocol.hubAddress - console.error(`${contributorAddr} is already a contributor to hub: ${hubName}`) - return + [isAdmin,isManager,isContributor] = await protocol.hub.memberRole(member) + if (!isContributor) { + let hubName = protocol.ns + ? `${protocol.nsName}.${protocol.nsDomain}` + : protocol.hubAddress + console.error(`${member} is not a contributor to hub: ${hubName}`) + return + } + 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)) } - const txManager = new TxManager(protocol.hub, protocol.chainId, protocol.netConfig.txConst) - let receipt = await txManager.SendCall("addContributor", [contributorAddr]) - console.log(explorerTxUrl(receipt.transactionHash, protocol.netConfig.explorers)) + }) -program - .command("removeCon") - .argument("", "hub_name.NS or hub_address:chain_id") - .argument("", "contributor address") - .description("add a manager into hub") - .action(async (hub,contributorAddr) => { - let protocol = await parseGit3URI(hub, { ignoreProtocolHeader: true, skipRepoName: true }) - let [isAdmin,isManager,isContributor] = await protocol.hub.memberRole(protocol.wallet.address) - if (!isManager) { +// =============================Repo Commands=================================== + +repo + .command("create") + .argument("", "ex: git3.w3q/repo_name or hub_addr:chainid/repo_name") + .description("create a new repo") + .action(async (uri) => { + const protocol = await parseGit3URI(uri, { ignoreProtocolHeader: true }) + + let isMember = await protocol.hub.membership(protocol.wallet.address) + if (!isMember) { 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(`you are not a member of this hub: ${hubName}`) + let isPermissionless = await protocol.hub.permissionless() + if (isPermissionless) { + console.error( + `this hub is permissionless, you can join it with: git3 join ${hubName}` + ) + } else { + console.error( + `this hub is not permissionless, you can ask the hub owner to add you as a member` + ) + } return } - [isAdmin,isManager,isContributor] = await protocol.hub.memberRole(contributorAddr) - if (!isContributor) { - let hubName = protocol.ns - ? `${protocol.nsName}.${protocol.nsDomain}` - : protocol.hubAddress - console.error(`${contributorAddr} is not a contributor to hub: ${hubName}`) + let owner = await protocol.hub.repoOwner(Buffer.from(protocol.repoName)) + + if (owner != "0x0000000000000000000000000000000000000000") { + console.error(`repo ${protocol.repoName} already exists`) return } + + console.log(`creating repo ${protocol.repoName} on ${protocol.netConfig.name}...`) const txManager = new TxManager(protocol.hub, protocol.chainId, protocol.netConfig.txConst) - let receipt = await txManager.SendCall("removeContributor", [contributorAddr]) + let receipt = await txManager.SendCall("createRepo", [Buffer.from(protocol.repoName)]) + console.log(explorerTxUrl(receipt.transactionHash, protocol.netConfig.explorers)) + console.log(`repo ${protocol.repoName} created.`) }) -// repo funcitons -let repository = program - .command("repository") - .description("repository related operations") -repository +repo .command("members") .argument("","ex: git3.w3q/repo_name or hub_addr:chainid/repo_name") .description("get all members information of the repository") @@ -369,13 +424,13 @@ repository console.log(`owner:${owner} \ncontributors:${contributors}`) }) -repository - .command("addCon") - .argument("","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 (uri,conAddr) => { - let protocol = await parseGit3URI(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 @@ -388,13 +443,13 @@ repository console.log(explorerTxUrl(receipt.transactionHash, protocol.netConfig.explorers)) }) -repository - .command("removeCon") - .argument("","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 (uri,conAddr) => { - let protocol = await parseGit3URI(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 @@ -407,51 +462,6 @@ repository console.log(explorerTxUrl(receipt.transactionHash, protocol.netConfig.explorers)) }) - -program - .command("info") - .argument("[wallet]", "wallet you want to get info", "default") - .description("get info of a wallet") - .action((wallet) => { - let etherWallet = getWallet(wallet) - - const address = etherWallet.address - - console.log(`wallet: ${wallet}`) - console.log(`address: ${address}`) - - for (let [_, net] of Object.entries(network)) { - const provider = new ethers.providers.JsonRpcProvider(randomRPC(net.rpc)) - const balance = provider.getBalance(address) - balance.then((res) => { - console.log( - `[${net.name}] balance: ${ethers.utils.formatUnits( - res, - net.nativeCurrency.decimals - )} ${net.nativeCurrency.symbol}` - ) - }) - } - }) - -program - .command("clear") - .description("clear pending nonce") - .argument("", "ex: default@git3.w3q") - .argument("[num]", "number of pending nonce to clear", 1) - .action(async (uri, num) => { - if (!uri.startsWith("git3://")) { - uri = "git3://" + uri - } - const protocol = await parseGit3URI(uri, { skipRepoName: true }) - const txManager = new TxManager(protocol.hub, protocol.chainId, protocol.netConfig.txConst) - let nonce = await protocol.wallet.getTransactionCount() - console.log(`current nonce: ${nonce}`) - await txManager.clearPendingNonce(num) - nonce = await protocol.wallet.getTransactionCount() - console.log(`current nonce: ${nonce}`) - }) - // Todo: set-wallet temporarily useless // program // .command("set-wallet")