diff --git a/public/img/networks-logo/sgton.svg b/public/img/networks-logo/sgton.svg new file mode 100644 index 0000000..0fb04ad --- /dev/null +++ b/public/img/networks-logo/sgton.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/img/networks-logo/shard.svg b/public/img/networks-logo/shard.svg new file mode 100644 index 0000000..b8ad3ec --- /dev/null +++ b/public/img/networks-logo/shard.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/pages/csc/csc.xml b/src/pages/csc/csc.xml index 12175ad..459d975 100644 --- a/src/pages/csc/csc.xml +++ b/src/pages/csc/csc.xml @@ -1,4 +1,5 @@ +
diff --git a/src/pages/dashboard/dashboard.scss b/src/pages/dashboard/dashboard.scss new file mode 100644 index 0000000..1638a50 --- /dev/null +++ b/src/pages/dashboard/dashboard.scss @@ -0,0 +1,7 @@ + +.btn-nav{ + padding:10px; + border-radius: 3px; + background-color: blue; + color: white; +} \ No newline at end of file diff --git a/src/pages/dashboard/dashboard.xml b/src/pages/dashboard/dashboard.xml index c7a9cf6..5364f57 100644 --- a/src/pages/dashboard/dashboard.xml +++ b/src/pages/dashboard/dashboard.xml @@ -1,4 +1,5 @@ + @@ -32,6 +33,7 @@

@@ -42,5 +44,6 @@
+
-
\ No newline at end of file + diff --git a/src/pages/eth/abi-eth-eth.json b/src/pages/eth/abi-eth-eth.json new file mode 100644 index 0000000..6a988f7 --- /dev/null +++ b/src/pages/eth/abi-eth-eth.json @@ -0,0 +1,117 @@ +[ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes", + "name": "pubkey", + "type": "bytes" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "withdrawal_credentials", + "type": "bytes" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "amount", + "type": "bytes" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "signature", + "type": "bytes" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "index", + "type": "bytes" + } + ], + "name": "DepositEvent", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "pubkey", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "withdrawal_credentials", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + }, + { + "internalType": "bytes32", + "name": "deposit_data_root", + "type": "bytes32" + } + ], + "name": "deposit", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "get_deposit_count", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "get_deposit_root", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "interfaceId", + "type": "bytes4" + } + ], + "name": "supportsInterface", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "pure", + "type": "function" + } +] \ No newline at end of file diff --git a/src/pages/index.ts b/src/pages/index.ts index def1c40..0069dcc 100644 --- a/src/pages/index.ts +++ b/src/pages/index.ts @@ -12,4 +12,5 @@ them automatically. import "./csc"; import "./fantom"; import "./polygon"; -import "./sgton"; \ No newline at end of file +import "./sgton"; +import "./shardeum"; \ No newline at end of file diff --git a/src/pages/shardeum/abi-shardeum-shard.json b/src/pages/shardeum/abi-shardeum-shard.json new file mode 100644 index 0000000..fe8a770 --- /dev/null +++ b/src/pages/shardeum/abi-shardeum-shard.json @@ -0,0 +1,896 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "address", + "name": "minter_", + "type": "address" + }, + { + "internalType": "uint256", + "name": "mintingAllowedAfter_", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "delegator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "fromDelegate", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "toDelegate", + "type": "address" + } + ], + "name": "DelegateChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "delegate", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "previousBalance", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newBalance", + "type": "uint256" + } + ], + "name": "DelegateVotesChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "minter", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newMinter", + "type": "address" + } + ], + "name": "MinterChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [], + "name": "DELEGATION_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "DOMAIN_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "PERMIT_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRANSFER_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRANSFER_WITH_FEE_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "rawAmount", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "rawAmount", + "type": "uint256" + } + ], + "name": "burn", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "internalType": "uint256", + "name": "rawAmount", + "type": "uint256" + } + ], + "name": "burnFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "name": "checkpoints", + "outputs": [ + { + "internalType": "uint32", + "name": "fromBlock", + "type": "uint32" + }, + { + "internalType": "uint96", + "name": "votes", + "type": "uint96" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "rawAmount", + "type": "uint256" + } + ], + "name": "decreaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "delegatee", + "type": "address" + } + ], + "name": "delegate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "delegatee", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expiry", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "delegateBySig", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "delegates", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getCurrentVotes", + "outputs": [ + { + "internalType": "uint96", + "name": "", + "type": "uint96" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + } + ], + "name": "getPriorVotes", + "outputs": [ + { + "internalType": "uint96", + "name": "", + "type": "uint96" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "rawAmount", + "type": "uint256" + } + ], + "name": "increaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "maxSupply", + "outputs": [ + { + "internalType": "uint96", + "name": "", + "type": "uint96" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "minimumTimeBetweenMints", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "rawAmount", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "minter", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "mintingAllowedAfter", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "nonces", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "numCheckpoints", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "rawAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "permit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "minter_", + "type": "address" + } + ], + "name": "setMinter", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "rawAmount", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "dsts", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "rawAmounts", + "type": "uint256[]" + } + ], + "name": "transferBatch", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "rawAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expiry", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "transferBySig", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "rawAmount", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "rawAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rawFee", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expiry", + "type": "uint256" + }, + { + "internalType": "address", + "name": "feeTo", + "type": "address" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "transferWithFeeBySig", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] \ No newline at end of file diff --git a/src/pages/shardeum/index.ts b/src/pages/shardeum/index.ts new file mode 100644 index 0000000..9834734 --- /dev/null +++ b/src/pages/shardeum/index.ts @@ -0,0 +1,5 @@ + +import { ShardeumStaking } from "./shardeum"; +export { + ShardeumStaking +}; \ No newline at end of file diff --git a/src/pages/shardeum/shardeum.scss b/src/pages/shardeum/shardeum.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/pages/shardeum/shardeum.ts b/src/pages/shardeum/shardeum.ts new file mode 100644 index 0000000..ce17c9c --- /dev/null +++ b/src/pages/shardeum/shardeum.ts @@ -0,0 +1,147 @@ +/* + +Endpoint Information +Liberty 1.X +Field Alphanet +Network Name Shardeum Liberty 1.X +New RPC URL https://liberty10.shardeum.org/ +Chain ID 8080 +Currency symbol (optional) SHM +Block Explorer URL (optional) https://explorer-liberty10.shardeum.org/ + + +Liberty 2.X +Field Alphanet +Network Name Shardeum Liberty 2.X +New RPC URL https://liberty20.shardeum.org/ +Chain ID 8081 +Currency symbol (optional) SHM +Block Explorer URL (optional) https://explorer-liberty20.shardeum.org/ + +https://etherscan.io/token/0xbebdab6da046bc49ffbb61fbd7b33157eb270d05#writeContract + +*/ +import { Component, useState } from "@odoo/owl"; +import { enableStaking, logo, route, symbol, template, title } from "../../components/page"; +import { switchChain, useContract, useWallet } from "../../core/wallet"; + + +import shardeumABI from "./abi-shardeum-shard.json"; +import "./shardeum.scss"; +import "./shardeum.xml"; + + +const genzAdderss = "0x5a1b57f87b59e093d332c945c66b602843099f97"; //to be added +const testAddress = "0x42eAcf5b37540920914589a6B1b5e45d82D0C1ca"; +const shardeumContract = "0xBeBdab6DA046Bc49ffBb61fbD7b33157Eb270D05"; +const weiRate = 1000000000000000000; +const testnetChainId = "0x1F91"; +const mainnetChainId = "0x1F90"; + + +@route('/staking/shardeum') +@title('Shardeum (shard)') +@logo('./img/networks-logo/shard.svg') +@template('pages.shardeum') +@symbol('shardeum') +@enableStaking() +export class ShardeumStaking extends Component { + + wallet = useWallet(); + state = useState({ + staking: false, + unstaking: false, + value: 0, + }); + + testnetChainId: string; + mainnetChainId: string; + + /** + * Stake the amount value from the input + * + * @returns promise | undefinde + */ + async stakeit() { + this.testnetChainId = testnetChainId; + this.mainnetChainId = mainnetChainId; + if (this.state.staking || !this._checkChainId()) { + await switchChain(mainnetChainId, 'Shardeum', 'https://liberty10.shardeum.org/') + return; + } + this.state.staking = true; + let contract = useContract(this.wallet.chainId, shardeumContract, shardeumABI); + var amount = this.state.value*weiRate; + return contract.methods + .delegate(this.getVerifierAddress()) + .send({ + from: this.wallet.account, + // Minimum 1000m (1 m = 1000?) + value: "0x" + amount.toString(16) + + }).catch(ex => { + alert("Fail to performe the stake action"); + console.error(ex); + }).finally(() => this.state.staking = false); + } + + /** + * Unstake all m from the default Validator + * + * @returns promise to performe + */ + unstakeit() { + if (this.state.unstaking || !this._checkChainId()) { + // wait for end + return; + } + this.state.unstaking = true; + let contract = useContract(this.wallet.chainId, shardeumContract, shardeumABI); + contract.handleRevert = true + contract.methods + .unstake(this.getVerifierAddress()) + .send({ + from: this.wallet.account + }).catch(ex => { + alert("Fail to unstake!!"); + }).finally(async() => { + + this.state.unstaking = false; + }); + this.withdrawStaking() + } + withdrawStaking(){ + let contract = useContract(this.wallet.chainId, shardeumContract, shardeumABI); + return contract.methods + .withdrawStaking(this.getVerifierAddress()) + .send({ + from: this.wallet.account + }).catch(ex => { + alert("Fail to unstake!!",ex); + }); + } + + _checkChainId() { + if (this.wallet.chainId !== mainnetChainId && this.wallet.chainId !== testnetChainId) { + alert("Unsupported Chain ID :" + this.wallet.chainId); + return false; + } + return true; + } + + getVerifierAddress() { + if (this.wallet.chainId === mainnetChainId) { + return genzAdderss; + } + return testAddress; + } +} + + + + + + + + + diff --git a/src/pages/shardeum/shardeum.xml b/src/pages/shardeum/shardeum.xml new file mode 100644 index 0000000..90ac3c7 --- /dev/null +++ b/src/pages/shardeum/shardeum.xml @@ -0,0 +1,129 @@ + + + +
+
+ +
+ +
+
+
+ \ No newline at end of file