aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRahiel Kasim <rahielkasim@gmail.com>2018-11-16 16:16:09 +0100
committerRahiel Kasim <rahielkasim@gmail.com>2018-11-16 16:16:09 +0100
commit1739acf5c7aae53cb8ed8732357bf8cae50a691c (patch)
tree7544727f2c42cad41f653f426940317ba051ac3a
Bismillah
-rw-r--r--.gitignore3
-rw-r--r--COSSToken.json1
-rw-r--r--index.html105
-rw-r--r--main.ts74
-rw-r--r--package.json14
-rw-r--r--style.css12
-rw-r--r--tsconfig.json23
7 files changed, 232 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..0784e61
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+node_modules
+dist
+.cache
diff --git a/COSSToken.json b/COSSToken.json
new file mode 100644
index 0000000..c25ecea
--- /dev/null
+++ b/COSSToken.json
@@ -0,0 +1 @@
+[{"constant": true, "inputs": [], "name": "name", "outputs": [{"name": "", "type": "string"}], "payable": false, "stateMutability": "view", "type": "function"}, {"constant": false, "inputs": [{"name": "_spender", "type": "address"}, {"name": "_value", "type": "uint256"}], "name": "approve", "outputs": [{"name": "", "type": "bool"}], "payable": false, "stateMutability": "nonpayable", "type": "function"}, {"constant": false, "inputs": [{"name": "_addresses", "type": "address[]"}], "name": "replaceToken", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function"}, {"constant": true, "inputs": [], "name": "totalSupply", "outputs": [{"name": "", "type": "uint256"}], "payable": false, "stateMutability": "view", "type": "function"}, {"constant": false, "inputs": [{"name": "_from", "type": "address"}, {"name": "_to", "type": "address"}, {"name": "_value", "type": "uint256"}], "name": "transferFrom", "outputs": [{"name": "", "type": "bool"}], "payable": false, "stateMutability": "nonpayable", "type": "function"}, {"constant": true, "inputs": [], "name": "decimals", "outputs": [{"name": "", "type": "uint256"}], "payable": false, "stateMutability": "view", "type": "function"}, {"constant": false, "inputs": [], "name": "setTransfersEnabled", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function"}, {"constant": false, "inputs": [{"name": "_spender", "type": "address"}, {"name": "_subtractedValue", "type": "uint256"}], "name": "decreaseApproval", "outputs": [{"name": "success", "type": "bool"}], "payable": false, "stateMutability": "nonpayable", "type": "function"}, {"constant": true, "inputs": [{"name": "_owner", "type": "address"}], "name": "balanceOf", "outputs": [{"name": "balance", "type": "uint256"}], "payable": false, "stateMutability": "view", "type": "function"}, {"constant": false, "inputs": [{"name": "_distributor", "type": "address"}], "name": "setDistributor", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function"}, {"constant": true, "inputs": [], "name": "owner", "outputs": [{"name": "", "type": "address"}], "payable": false, "stateMutability": "view", "type": "function"}, {"constant": false, "inputs": [{"name": "_revenueShareIdentifier", "type": "string"}], "name": "activateRevenueShareIdentifier", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function"}, {"constant": true, "inputs": [], "name": "symbol", "outputs": [{"name": "", "type": "string"}], "payable": false, "stateMutability": "view", "type": "function"}, {"constant": false, "inputs": [{"name": "_addresses", "type": "address[]"}, {"name": "_balances", "type": "uint256[]"}], "name": "replaceTokenFix", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function"}, {"constant": false, "inputs": [{"name": "_to", "type": "address"}, {"name": "_value", "type": "uint256"}], "name": "transfer", "outputs": [{"name": "", "type": "bool"}], "payable": false, "stateMutability": "nonpayable", "type": "function"}, {"constant": false, "inputs": [{"name": "_to", "type": "address"}, {"name": "_value", "type": "uint256"}, {"name": "_data", "type": "bytes"}], "name": "transfer", "outputs": [{"name": "", "type": "bool"}], "payable": false, "stateMutability": "nonpayable", "type": "function"}, {"constant": true, "inputs": [], "name": "transfersEnabled", "outputs": [{"name": "", "type": "bool"}], "payable": false, "stateMutability": "view", "type": "function"}, {"constant": true, "inputs": [], "name": "distributor", "outputs": [{"name": "", "type": "address"}], "payable": false, "stateMutability": "view", "type": "function"}, {"constant": false, "inputs": [{"name": "_destination", "type": "address"}, {"name": "_amount", "type": "uint256"}], "name": "sendEther", "outputs": [], "payable": true, "stateMutability": "payable", "type": "function"}, {"constant": false, "inputs": [{"name": "_oldTokenAddress", "type": "address"}], "name": "setOldTokenAddress", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function"}, {"constant": true, "inputs": [{"name": "", "type": "address"}], "name": "revenueShareIdentifierList", "outputs": [{"name": "", "type": "string"}], "payable": false, "stateMutability": "view", "type": "function"}, {"constant": false, "inputs": [{"name": "_spender", "type": "address"}, {"name": "_addedValue", "type": "uint256"}], "name": "increaseApproval", "outputs": [{"name": "success", "type": "bool"}], "payable": false, "stateMutability": "nonpayable", "type": "function"}, {"constant": true, "inputs": [], "name": "oldTokenAddress", "outputs": [{"name": "", "type": "address"}], "payable": false, "stateMutability": "view", "type": "function"}, {"constant": true, "inputs": [{"name": "_owner", "type": "address"}, {"name": "_spender", "type": "address"}], "name": "allowance", "outputs": [{"name": "", "type": "uint256"}], "payable": false, "stateMutability": "view", "type": "function"}, {"constant": false, "inputs": [{"name": "_destination", "type": "address"}, {"name": "_token", "type": "address"}, {"name": "_amount", "type": "uint256"}], "name": "sendTokens", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function"}, {"constant": false, "inputs": [{"name": "newOwner", "type": "address"}], "name": "transferOwnership", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function"}, {"inputs": [], "payable": false, "stateMutability": "nonpayable", "type": "constructor"}, {"payable": true, "stateMutability": "payable", "type": "fallback"}, {"anonymous": false, "inputs": [{"indexed": true, "name": "_address", "type": "address"}, {"indexed": false, "name": "_identifier", "type": "string"}], "name": "RevenueShareIdentifierCreated", "type": "event"}, {"anonymous": false, "inputs": [{"indexed": true, "name": "previousOwner", "type": "address"}, {"indexed": true, "name": "newOwner", "type": "address"}], "name": "OwnershipTransferred", "type": "event"}, {"anonymous": false, "inputs": [{"indexed": true, "name": "owner", "type": "address"}, {"indexed": true, "name": "spender", "type": "address"}, {"indexed": false, "name": "value", "type": "uint256"}], "name": "Approval", "type": "event"}, {"anonymous": false, "inputs": [{"indexed": true, "name": "from", "type": "address"}, {"indexed": true, "name": "to", "type": "address"}, {"indexed": false, "name": "value", "type": "uint256"}], "name": "Transfer", "type": "event"}] \ No newline at end of file
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..dcdf959
--- /dev/null
+++ b/index.html
@@ -0,0 +1,105 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
+
+ <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
+
+ <meta name="description" content="Interface for the COSS token contract. Easily set your fee split allocation identifier.">
+ <title>COSS Token Contract</title>
+ <link rel="stylesheet" href="style.css">
+ </head>
+ <body>
+ <div class="container">
+ <div class="row">
+ <h1>COSS Token Contract</h1>
+
+ <div class="alert alert-warning" id="noweb3" style="display:none">
+ Non-Ethereum browser detected. You can't interact with the contract.
+ You should consider trying <a href="https://metamask.io/">MetaMask</a>!
+ </div>
+
+ <div class="alert alert-danger" id="deny" style="display:none">
+ Can't read your public address. Please connect again to interact with
+ the contract.
+ </div>
+
+ <p>
+ On this page you can interact with the COSS token contract at <a id="contractURL"><span class="text-monospace" id="contract"></span></a>.
+ </p>
+ <p>
+ The COSS token is an ERC223 token issued on the Ethereum blockchain by
+ the Singapore based <a href="https://www.coss.io/">COSS</a> cryptocurrency
+ exchange. COSS shares 50% of their exchange fees with the COSS token
+ holders. The more COSS you hold, the bigger your part of the fees and
+ the higher your payouts.
+ </p>
+ <p>
+ To receive the payouts you hold your COSS tokens in your wallet on the
+ exchange, or you keep them safe in your own private Ethereum wallet.
+ For this second option you need to link your Ethereum address with
+ your COSS account on the exchange by setting your fee split allocation
+ identifier in the smart contract. You can do this below.
+ </p>
+ </div>
+
+ <div class="row">
+ <h2>Set Fee Split Allocation Identifier</h2>
+
+ <p>
+ Here you can set your fee split allocation identifier to receive
+ payouts for your COSS on an external wallet. Make sure you are logged
+ in with your wallet (with MetaMask or your preferred Ethereum browser)
+ containing COSS and click the "Connect" button to start. After
+ connecting, the box below will show your address, COSS balance and
+ identifier if it is already set.
+ </p>
+ <button id="connect" type="button" class="btn btn-primary">Connect</button>
+ </div>
+
+ <br>
+
+ <div id="wallet">
+ <span class="text-monospace">Address: &nbsp;&nbsp;&nbsp;</span><span class="text-monospace" id="address">&lt;address&gt;</span>
+ <br>
+ <span class="text-monospace">Balance: &nbsp;&nbsp;&nbsp;</span><span class="text-monospace" id="balance">0</span> <span class="text-monospace">COSS</span>
+ <br>
+ <span class="text-monospace">Identifier: </span><span class="text-monospace" id="active-identifier">None</span>
+ </div>
+
+ <div class="row">
+ <p>
+ Now login to your COSS account and visit your <a href="https://profile.coss.io/fee-split">Fee Split Allocation page</a>.
+ Copy your "Token Based Fee Split Allocation identifier" and paste it
+ below. An example identifier looks like:<br> <code>df45ee1d-d323-425e-b87f-85e570609fb8</code>.
+ </p>
+
+ <label for="identifier">Identifier</label>
+ <input id="identifier" class="form-control" type="text" placeholder="Your identifier...">
+ <br><br>
+
+ <p>
+ Finally, after double-checking your identifier and address, click on
+ the "Set Identifier" button to make the transaction.
+ </p>
+ <button id="set" type="button" class="btn btn-primary">Set Identifier</button>
+ </div>
+
+ <br>
+
+ <div class="row">
+ <h2 class="text-muted">Old ERC20 Contract</h2>
+
+ <p>
+ The COSS token was first issued as an ERC20 token at address <a href="https://etherscan.io/address/0x65292eeadf1426cd2df1c4793a3d7519f253913b"><span class="text-monospace">0x65292EeadF1426Cd2dF1C4793a3d7519f253913b</span></a>.
+ It was later forked to become an ERC223 token at the contract
+ address at the top of this page. Make sure you don't buy these old
+ tokens or interact with the old contract, as they have been abandoned.
+ </p>
+ </div>
+ </div>
+
+ <script src="dist/main.js"></script>
+ </body>
+</html>
diff --git a/main.ts b/main.ts
new file mode 100644
index 0000000..8a497f0
--- /dev/null
+++ b/main.ts
@@ -0,0 +1,74 @@
+let Web3 = require("web3");
+
+
+declare let ethereum: any;
+let web3, contractInterface;
+
+fetch("COSSToken.json")
+ .then(response => response.json())
+ .then(j => contractInterface = j);
+
+const COSSAddress = "0x9e96604445Ec19fFed9a5e8dd7B50a29C899A10C";
+document.getElementById("contract").textContent = COSSAddress;
+(<HTMLAnchorElement>document.getElementById("contractURL")).href = `https://etherscan.io/address/${COSSAddress}`;
+
+window.addEventListener("load", () => {
+ if ((<any>window).ethereum) {
+ web3 = new Web3(ethereum);
+ document.getElementById("connect").onclick = main;
+ } else {
+ document.getElementById("noweb3").style.display = "block";
+ }
+});
+
+async function main() {
+ try {
+ await ethereum.enable();
+ document.getElementById("deny").style.display = "none";
+ } catch (error) {
+ document.getElementById("deny").style.display = "block";
+ }
+
+ let decimals, address;
+ const contract = new web3.eth.Contract(contractInterface, COSSAddress);
+
+ contract.methods.decimals().call()
+ .then(function (result) {
+ decimals = result;
+ getAddress();
+ })
+
+ document.getElementById("set").onclick = setIdentifier;
+
+ function getAddress() {
+ web3.eth.getAccounts()
+ .then(function (addresses) {
+ address = addresses[0];
+ document.getElementById("address").textContent = address;
+ getBalance();
+ });
+ }
+
+ function getBalance() {
+ contract.methods.balanceOf(address).call()
+ .then(function (result) {
+ let tokens = result / Math.pow(10, decimals);
+ document.getElementById("balance").textContent = tokens.toString();
+ getIdentifier();
+ });
+ }
+
+ function getIdentifier() {
+ contract.methods.revenueShareIdentifierList(address).call()
+ .then(function (identifier) {
+ if (identifier) {
+ document.getElementById("active-identifier").textContent = identifier;
+ }
+ })
+ }
+
+ function setIdentifier() {
+ const identifier = (<HTMLInputElement>document.getElementById("identifier")).value.trim();
+ contract.methods.activateRevenueShareIdentifier(identifier).send({from: address});
+ }
+}
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..8f2cbcf
--- /dev/null
+++ b/package.json
@@ -0,0 +1,14 @@
+{
+ "scripts": {
+ "start": "parcel watch main.ts",
+ "build": "parcel build main.ts"
+ },
+ "devDependencies": {
+ "@types/web3": "^1.0.12",
+ "parcel-bundler": "^1.10.3",
+ "typescript": "^3.1.6"
+ },
+ "dependencies": {
+ "web3": "^1.0.0-beta.36"
+ }
+}
diff --git a/style.css b/style.css
new file mode 100644
index 0000000..5a4fca6
--- /dev/null
+++ b/style.css
@@ -0,0 +1,12 @@
+body {
+ margin: 0 auto;
+ max-width: 50em;
+ padding: 4em 1em;
+}
+
+#wallet {
+ padding: 10px;
+ border: 2px solid #174a9b;
+ border-radius: 5px;
+ margin-bottom: 10px;
+}
diff --git a/tsconfig.json b/tsconfig.json
new file mode 100644
index 0000000..27dabdd
--- /dev/null
+++ b/tsconfig.json
@@ -0,0 +1,23 @@
+{
+ "compilerOptions": {
+ "downlevelIteration": true,
+ "sourceMap": true,
+ "noImplicitAny": false,
+ "module": "commonjs",
+ "target": "es5",
+ "lib": [
+ "DOM",
+ "ES2015",
+ "ES7",
+ "DOM.Iterable",
+ "ScriptHost"
+ ]
+ },
+ "include": [
+ "*.ts"
+ ],
+ "exclude": [
+ "node_modules",
+ "**/*.spec.ts"
+ ]
+}