Skip to content

Commit

Permalink
Updated playground setup (not final)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Belets committed Nov 22, 2024
1 parent 0dc59e1 commit ec07031
Show file tree
Hide file tree
Showing 22 changed files with 147 additions and 202 deletions.
18 changes: 9 additions & 9 deletions playground/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
img_tag = "hayeah/qtumportal:testjanus"
container_name = "qtumportal-testjanus"
img_tag = "username/kaonportal:testethrpcgate"
container_name = "kaonportal-testethrpcgate"

.PHONY: image
image:
GOOS=linux GOARCH=amd64 go build -o ./docker/janus-linux-amd64 github.com/qtumproject/janus/cli/janus
GOOS=linux GOARCH=amd64 go build -o ./docker/eth-rpc-gate-linux-amd64 github.com/kaonone/eth-rpc-gate/cli/eth-rpc-gate
docker build ./docker -t $(img_tag)

.PHONY: run
run:
cd .. && make run-janus-https
cd .. && make run-ethrpcgate-https

.PHONY: stop
stop:
Expand All @@ -20,15 +20,15 @@ exec:

.PHONY: init-container
init-container:
docker exec -it qtumportal-testjanus sh init-container.sh
docker exec -it kaonportal-testethrpcgate sh init-container.sh

.PHONY: logs
logs:
docker logs --tail 1000 -f $(container_name)

.PHONY: clean-qtum-data
clean-qtum-data:
rm -rf ./docker/.qtum
.PHONY: clean-kaon-data
clean-kaon-data:
rm -rf ./docker/.kaon

.PHONY: deploy-contracts
deploy-contracts:
Expand All @@ -38,5 +38,5 @@ deploy-contracts:
.PHONY: serve-pet-shop
serve-pet-shop:
cd pet-shop-tutorial; yarn
echo "Two prefund accounts you can login with: \n 0x7926223070547d2d15b2ef5e7383e541c338ffe9 \n 0x2352be3db3177f0a07efbe6da5857615b8c9901d"
echo "Two prefund accounts you can login with: \n 0x1CE507204a6fC8fd6aA7e54D1481d30ACB0Dbead \n 0x3f501c368cb9ddb5f27ed72ac0d602724adfa175"
cd pet-shop-tutorial; yarn dev &> /dev/null
4 changes: 2 additions & 2 deletions playground/docker/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/janus-linux-amd64
/.qtum
/eth-rpc-gate-linux-amd64
/.kaon
/supervisord.*
/env.list
4 changes: 2 additions & 2 deletions playground/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM dcb9/qtumportal
FROM username/kaonportal

COPY janus-linux-amd64 /usr/local/bin/janus
COPY ethrpcgate-linux-amd64 /usr/local/bin/eth-rpc-gate
2 changes: 1 addition & 1 deletion playground/docker/env.list-example
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#QTUM_NETWORK=auto
#KAON_NETWORK=auto
23 changes: 13 additions & 10 deletions playground/docker/init-container.sh
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
#!/bin/sh
while
qcli help &> /dev/null
kaon-cli help &> /dev/null
rc=$?; if [[ $rc == 0 ]]; then break; fi
do :; done

balance=`qcli getbalance`
balance=`kaon-cli getbalance`
if [ "${balance:0:1}" == "0" ]
then
set -x
qcli generate 600 > /dev/null
kaon-cli generate 600 > /dev/null
set -
fi

WALLETFILE=test-wallet
LOCKFILE=${QTUM_DATADIR}/import-test-wallet.lock
LOCKFILE=${KAON_DATADIR}/import-test-wallet.lock

if [ ! -e $LOCKFILE ]; then
while
qcli getaddressesbyaccount "" &> /dev/null
kaon-cli getaddressesbyaccount "" &> /dev/null
rc=$?; if [[ $rc != 0 ]]; then continue; fi

set -x

kaon-cli importprivkey "YoBkvJXYcxihY3qYXZuh3ndN14hWmAPUU3qhFZw1Zbt9g85FjMCd" # addr=auASFMxv45WgjCW6wkpDuHWjxXhzNA9mjP

qcli importprivkey "cMbgxCJrTYUqgcmiC1berh5DFrtY1KeU4PXZ6NZxgenniF1mXCRk" # addr=qUbxboqjBRp96j3La8D1RYkyqx5uQbJPoW hdkeypath=m/88'/0'/1'
qcli importprivkey "cRcG1jizfBzHxfwu68aMjhy78CpnzD9gJYZ5ggDbzfYD3EQfGUDZ" # addr=qLn9vqbr2Gx3TsVR9QyTVB5mrMoh4x43Uf hdkeypath=m/88'/0'/2'

solar prefund qUbxboqjBRp96j3La8D1RYkyqx5uQbJPoW 500
solar prefund qLn9vqbr2Gx3TsVR9QyTVB5mrMoh4x43Uf 500
# MM private key for this addr is cbc9b23fc49066bbe19e599364035b9e8d11bb51e0f1fb56b14f50564bfd15e9
# there is no private key for this addr in KAON
solar prefund ar2SzdHghSgeacypPn7zfDe3qfKAEwimus 500
# KAON private key for this addr is YoBkvJXYcxihY3qYXZuh3ndN14hWmAPUU3qhFZw1Zbt9g85FjMCd
# there is no private key for this addr in Eth format
solar prefund auASFMxv45WgjCW6wkpDuHWjxXhzNA9mjP 500
touch $LOCKFILE

set -
Expand Down
13 changes: 6 additions & 7 deletions playground/docker/myaccounts.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
L42ijXgcx42jGGe8Ei2TazrMG3TWRBecBPUqqvE2qWgGVXFoFwZS
cMbgxCJrTYUqgcmiC1berh5DFrtY1KeU4PXZ6NZxgenniF1mXCRk
cRcG1jizfBzHxfwu68aMjhy78CpnzD9gJYZ5ggDbzfYD3EQfGUDZ
cV79qBoCSA2NDrJz8S3T7J8f3zgkGfg4ua4hRRXfhbnq5VhXkukT
cV93kaaV8hvNqZ711s2z9jVWLYEtwwsVpyFeEZCP6otiZgrCTiEW
cVPHpTvmv3UjQsZfsMRrW5RrGCyTSAZ3MWs1f8R1VeKJSYxy5uac
cTs5NqY4Ko9o6FESHGBDEG77qqz9me7cyYCoinHcWEiqMZgLC6XY
YoBkvJXYcxihY3qYXZuh3ndN14hWmAPUU3qhFZw1Zbt9g85FjMCd
Yn3MpyMQzQR7osXkNyQ3DVNP6kwZGpmXhXzuuPGXZwyouhxmWxh7
YhrMRdEunTgoz4vs9RYc7Ui5yAYp2UmBeZsVfWHjifzVWeDQGVt7
YiaCnmCToCPUGgSrLxEiGVa297WiFGc5jrsUpy68BJiCe7Cym716
YifXHT9WJeP53jor88a6FYgxj3CDFjtkbYGb6tRHJK3UhdLye6m2
Yjf1pkLANZcMQd81HyyqV4BHBMwMLoqZzZ9W4YfGxtqEbinL5kQq
2 changes: 1 addition & 1 deletion playground/migrations/3_deploy_myToken.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var MyToken = artifacts.require("./MyToken.sol");

module.exports = async function(deployer) {
await deployer.deploy(MyToken, 9999999999999, {from: "0x7926223070547d2d15b2ef5e7383e541c338ffe9"});
await deployer.deploy(MyToken, 9999999999999, {from: "0x1CE507204a6fC8fd6aA7e54D1481d30ACB0Dbead"});
};
8 changes: 4 additions & 4 deletions playground/myToken.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
const url = require('url');

const rpcURL = process.env.ETH_RPC;
const qtumAccount = url.parse(rpcURL).auth.split(":")[0]
const kaonAccount = url.parse(rpcURL).auth.split(":")[0]

// assume: node 8 or above
const ora = require("ora")
const parseArgs = require("minimist")

const qtum = require("qtumjs")
const rpc = new qtum.EthRPC(rpcURL, qtumAccount)
const kaon = require("qtumjs")
const rpc = new kaon.EthRPC(rpcURL, kaonAccount)
const repoData = require("./solar.development.json")
const {
sender,
...info
} = repoData.contracts['contracts/MyToken.sol']
const myToken = new qtum.Contract(rpc, info)
const myToken = new kaon.Contract(rpc, info)

const opts = {gasPrice: 100}

Expand Down
4 changes: 2 additions & 2 deletions playground/node-myToken-commands.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export ACC1="0x7926223070547d2d15b2ef5e7383e541c338ffe9"
export ACC2="0x3a895d2af552600f1f585425318c13a5aa25f01a"
export ACC1="0x1CE507204a6fC8fd6aA7e54D1481d30ACB0Dbead"
export ACC2="0x3f501c368cb9ddb5f27ed72ac0d602724adfa175"

node myToken.js mint ${ACC1} 100

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import './SafeMath.sol';


/**
QRC20Token Standard Token implementation
URC20Token Standard Token implementation
*/
contract QRC20Token is SafeMath {
contract URC20Token is SafeMath {
string public constant standard = 'Token 0.1';
uint8 public constant decimals = 8; // it's recommended to set decimals to 8 in QTUM
uint8 public constant decimals = 8; // it's recommended to set decimals to 8 in KAON

// you need change the following three values
string public constant name = 'QRC TEST';
string public constant symbol = 'QTC';
string public constant name = 'URC TEST';
string public constant symbol = 'UTC';
//Default assumes totalSupply can't be over max (2^256 - 1).
//you need multiply 10^decimals by your real total supply.
uint256 public totalSupply = 10**9 * 10**uint256(decimals);
Expand Down Expand Up @@ -71,8 +71,8 @@ contract QRC20Token is SafeMath {
return true;
}

// disable pay QTUM to this contract
// disable pay KAON to this contract
receive() external payable {
revert();
}
}
}
10 changes: 5 additions & 5 deletions playground/pet-shop-tutorial/js/SafeMath.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"type": "constructor"
}
],
"metadata": "{\"compiler\":{\"version\":\"0.8.6+commit.11564f7e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"/home/ripply/git/janus/playground/pet-shop-tutorial/contracts/SafeMath.sol\":\"SafeMath\"},\"evmVersion\":\"berlin\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":1},\"remappings\":[]},\"sources\":{\"/home/ripply/git/janus/playground/pet-shop-tutorial/contracts/SafeMath.sol\":{\"keccak256\":\"0x3c4f94ab343ae1a6c7f7a30cea559d7c95503b3afd6383813a5d40115cc03162\",\"urls\":[\"bzz-raw://0a9627dda4caae2de70b1c0d83e36082c8ac2175118e88724a6ba37ce612072c\",\"dweb:/ipfs/Qmd4W9Q3cxMYxoDwtDUnTY4xRxv8eQJVyJ1kRFpsg9TFED\"]}},\"version\":1}",
"metadata": "{\"compiler\":{\"version\":\"0.8.6+commit.11564f7e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"/home/kaonuser/git/eth-rpc-gate/playground/pet-shop-tutorial/contracts/SafeMath.sol\":\"SafeMath\"},\"evmVersion\":\"berlin\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":1},\"remappings\":[]},\"sources\":{\"/home/kaonuser/git/eth-rpc-gate/playground/pet-shop-tutorial/contracts/SafeMath.sol\":{\"keccak256\":\"0x3c4f94ab343ae1a6c7f7a30cea559d7c95503b3afd6383813a5d40115cc03162\",\"urls\":[\"bzz-raw://0a9627dda4caae2de70b1c0d83e36082c8ac2175118e88724a6ba37ce612072c\",\"dweb:/ipfs/Qmd4W9Q3cxMYxoDwtDUnTY4xRxv8eQJVyJ1kRFpsg9TFED\"]}},\"version\":1}",
"bytecode": "0x6080604052348015600f57600080fd5b50603f80601d6000396000f3fe6080604052600080fdfea264697066735822122035363a50c2e4bbaccaf11bd57be8b910f38ac30cf242d85eafdd010d88adffe864736f6c63430008060033",
"deployedBytecode": "0x6080604052600080fdfea264697066735822122035363a50c2e4bbaccaf11bd57be8b910f38ac30cf242d85eafdd010d88adffe864736f6c63430008060033",
"immutableReferences": {},
Expand All @@ -16,9 +16,9 @@
"sourceMap": "66:517:3:-:0;;;91:21;;;;;;;;;;66:517;;;;;;",
"deployedSourceMap": "66:517:3:-:0;;;;;",
"source": "pragma solidity ^0.8.0;\n\n/* taking ideas from FirstBlood token */\ncontract SafeMath {\n\n constructor() {\n }\n\n function safeAdd(uint256 _x, uint256 _y) pure internal returns (uint256) {\n uint256 z = _x + _y;\n assert(z >= _x);\n return z;\n }\n\n function safeSub(uint256 _x, uint256 _y) pure internal returns (uint256) {\n assert(_x >= _y);\n return _x - _y;\n }\n\n function safeMul(uint256 _x, uint256 _y) pure internal returns (uint256) {\n uint256 z = _x * _y;\n assert(_x == 0 || z / _x == _y);\n return z;\n }\n\n}\n",
"sourcePath": "/home/ripply/git/janus/playground/pet-shop-tutorial/contracts/SafeMath.sol",
"sourcePath": "/home/kaonuser/git/eth-rpc-gate/playground/pet-shop-tutorial/contracts/SafeMath.sol",
"ast": {
"absolutePath": "/home/ripply/git/janus/playground/pet-shop-tutorial/contracts/SafeMath.sol",
"absolutePath": "/home/kaonuser/git/eth-rpc-gate/playground/pet-shop-tutorial/contracts/SafeMath.sol",
"exportedSymbols": {
"SafeMath": [
431
Expand Down Expand Up @@ -1026,7 +1026,7 @@
"src": "0:584:3"
},
"legacyAST": {
"absolutePath": "/home/ripply/git/janus/playground/pet-shop-tutorial/contracts/SafeMath.sol",
"absolutePath": "/home/kaonuser/git/eth-rpc-gate/playground/pet-shop-tutorial/contracts/SafeMath.sol",
"exportedSymbols": {
"SafeMath": [
431
Expand Down Expand Up @@ -2050,4 +2050,4 @@
"methods": {},
"version": 1
}
}
}
Loading

0 comments on commit ec07031

Please sign in to comment.