Commit af412dbf authored by Kegan's avatar Kegan
Browse files

updated steamid linking to interact with existing testnet and mainnet contracts

parent 24f02458
......@@ -647,7 +647,6 @@ blockquote {
}
.cloneable-container-default {
min-height: 624px;
padding: 100px 40px;
border-radius: 20px;
background-color: #f7f7fb;
......@@ -1375,6 +1374,17 @@ blockquote {
text-align: left;
}
.grid-3 {
-ms-grid-columns: 1fr 0.5fr;
grid-template-columns: 1fr 0.5fr;
-ms-grid-rows: auto;
grid-template-rows: auto;
}
.div-block {
min-height: 72px;
}
@media screen and (min-width: 1440px) {
.text-uppercase.subtitle {
text-align: center;
......
<!DOCTYPE html><!-- This site was created in Webflow. http://www.webflow.com -->
<!-- Last Published: Mon Sep 06 2021 14:31:08 GMT+0000 (Coordinated Universal Time) -->
<!-- Last Published: Sun Sep 12 2021 19:11:10 GMT+0000 (Coordinated Universal Time) -->
<html data-wf-page="6134d5b7d6b22ccf9fd8df81" data-wf-site="6134d5b6d6b22c5832d8df7c">
<head>
<meta charset="utf-8">
......@@ -31,7 +31,7 @@
</head>
<body>
<div class="page-wrapper">
<div id="header-error-notification" style="display: none !important" class="section-2 wf-section">
<div id="header-error-notification" class="section-2 wf-section">
<div class="notification-header">
<p id="header-error-text" class="paragraph-2">You are not connected to the Arbitrum Network!</p>
</div>
......@@ -71,12 +71,12 @@
<a href="#" id="w-node-c054886d-07d1-a130-b374-a7e8d59be279-d59be275" target="_blank" class="button-secondary cloneable-header-button w-button">Why is this Necessary?</a>
</div>
</div>
<div class="cloneable-container-default account-link-container">
<div class="accordion-item-wrapper---brix">
<div class="accordion-item---brix accordion-1---brix">
<div data-w-id="bae2f787-303d-bffa-cdef-0d3047873f8a" style="opacity:0" class="cloneable-container-default">
<div class="accordion-item-wrapper---brix preview-page">
<div id="link-steam-id-div" class="accordion-item---brix accordion-1---brix">
<div class="text-uppercase subtitle">Link your steam account</div>
<div class="form-newsletter w-form">
<form id="wf-form-SteamID-Form" name="wf-form-SteamID-Form" data-name="SteamID-Form" method="get" action="#" class="form-newsletter-wrapper"><input type="number" class="input-relative newsletter footer w-input" maxlength="256" name="SteamID64" data-name="SteamID64" placeholder="SteamID64 Ex: &#x27;12345671234567890&#x27;" id="SteamID" required=""><input type="submit" value="Link Steam ID" data-wait="Please wait..." class="button-primary newsletter button-footer w-button"></form>
<div id="link-steam-id-form" class="form-newsletter w-form">
<form id="wf-form-SteamID-Form" name="wf-form-SteamID-Form" data-name="SteamID-Form" method="get" action="#" class="form-newsletter-wrapper"><input type="number" class="input-relative newsletter footer w-input" max="99999999999999999" min="10000000000000000" name="SteamID64" data-name="SteamID64" placeholder="SteamID64 Ex: &#x27;12345671234567890&#x27;" id="SteamID" required=""><input type="submit" value="Link Steam ID" data-wait="Please wait..." id="link-steam-id-btn" class="button-primary newsletter button-footer w-button"></form>
<div class="success-message-2 w-form-done">
<div class="text-uppercase subtitle">Steam Account linked successfully</div>
</div>
......@@ -85,20 +85,9 @@
</div>
</div>
</div>
</div>
<div class="accordion-item-wrapper---brix">
<div class="accordion-item---brix accordion-1---brix">
<div class="accordion-item-title---brix">Linked Steam Accounts</div>
<div class="w-layout-grid grid">
<div class="text-block-2">12345671234567890 <a href="#">unlink</a>
</div>
<div class="text-block-2">12345671234567890 <a href="#">unlink</a>
</div>
<div class="text-block-2">12345671234567890 <a href="#">unlink</a>
</div>
<div class="text-block-2">12345671234567890 <a href="#">unlink</a>
</div>
</div>
<div id="unlink-steam-id-div" class="accordion-item---brix accordion-1---brix">
<div class="text-uppercase subtitle">Unlink your Steam Account</div>
<a id="unlink-steam-id-btn" href="#" target="_blank" class="button-primary button-header button-unlink">Unlink Steam ID</a>
</div>
</div>
</div>
......
{
"_format": "hh-sol-artifact-1",
"contractName": "SteamIDToEthereum",
"sourceName": "contracts/SteamIDToEthereum.sol",
"abi": [
{
"stateMutability": "payable",
"type": "fallback"
},
{
"inputs": [
{
"internalType": "uint64",
"name": "steamid64",
"type": "uint64"
}
],
"name": "HashSteamID",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "hashed_steamid64",
"type": "uint256"
}
],
"name": "LinkSteamID",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "Unlink",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "account",
"type": "address"
}
],
"name": "getLink",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "hashed_steamid64",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "index",
"type": "uint256"
}
],
"name": "getLinkByIndex",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "hashed_steamid64",
"type": "uint256"
}
],
"name": "getNumberOfLinks",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "account",
"type": "address"
}
],
"name": "hasLink",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "hashed_steamid64",
"type": "uint256"
},
{
"internalType": "address",
"name": "account",
"type": "address"
}
],
"name": "isLinked",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"stateMutability": "payable",
"type": "receive"
}
],
"bytecode": "0x608060405234801561001057600080fd5b50610a39806100206000396000f3fe60806040526004361061007f5760003560e01c80636f7b16241161004e5780636f7b1624146101335780639d6abe4f14610148578063d238028314610168578063dc750cee1461018857600080fd5b80632ce427af1461008e5780632d3538fe146100c15780634e68c8ad146100f1578063642c13011461011357600080fd5b3661008957600080fd5b600080fd5b34801561009a57600080fd5b506100ae6100a9366004610928565b6101c0565b6040519081526020015b60405180910390f35b3480156100cd57600080fd5b506100e16100dc3660046108dc565b610251565b60405190151581526020016100b8565b3480156100fd57600080fd5b5061011161010c3660046108c4565b6102b5565b005b34801561011f57600080fd5b506100e161012e3660046108a3565b610351565b34801561013f57600080fd5b50610111610397565b34801561015457600080fd5b506100ae6101633660046108a3565b610453565b34801561017457600080fd5b506100ae6101833660046108c4565b610497565b34801561019457600080fd5b506101a86101a3366004610907565b6104cb565b6040516001600160a01b0390911681526020016100b8565b6000808267ffffffffffffffff16116101f45760405162461bcd60e51b81526004016101eb90610979565b60405180910390fd5b604080517f63726561746564206279206b6567616e20686f6c6c65726e000000000000000060208201526001600160c01b031960c085901b1660388201520160408051601f19818403018152919052805160209091012092915050565b60008083116102725760405162461bcd60e51b81526004016101eb90610979565b6001600160a01b0382166102985760405162461bcd60e51b81526004016101eb90610950565b506001600160a01b03166000908152600260205260409020541490565b600081116102d55760405162461bcd60e51b81526004016101eb90610979565b6102e9335b6001600160a01b03163b151590565b156103445760405162461bcd60e51b815260206004820152602560248201527f436f6e7472616374732063616e6e6f74206c696e6b20537465616d204163636f604482015264756e74732160d81b60648201526084016101eb565b61034e813361055e565b50565b60006001600160a01b0382166103795760405162461bcd60e51b81526004016101eb90610950565b506001600160a01b0316600090815260026020526040902054151590565b6103a0336102da565b156103fd5760405162461bcd60e51b815260206004820152602760248201527f436f6e7472616374732063616e6e6f7420756e6c696e6b20537465616d204163604482015266636f756e74732160c81b60648201526084016101eb565b61040633610351565b61043f5760405162461bcd60e51b815260206004820152600a602482015269139bdd081b1a5b9ad95960b21b60448201526064016101eb565b61045161044b33610453565b3361067a565b565b60006001600160a01b03821661047b5760405162461bcd60e51b81526004016101eb90610950565b506001600160a01b031660009081526002602052604090205490565b60008082116104b85760405162461bcd60e51b81526004016101eb90610979565b5060009081526001602052604090205490565b60008083116104ec5760405162461bcd60e51b81526004016101eb90610979565b6104f583610497565b82106105395760405162461bcd60e51b8152602060048201526013602482015272696e646578206f7574206f6620626f756e647360681b60448201526064016101eb565b506000918252602082815260408084209284529190529020546001600160a01b031690565b6000821161057e5760405162461bcd60e51b81526004016101eb90610979565b6001600160a01b0381166105a45760405162461bcd60e51b81526004016101eb90610950565b6105ad81610351565b156106065760405162461bcd60e51b8152602060048201526024808201527f4163636f756e7420616c7265616479206c696e6b656420746f206120537465616044820152636d49442160e01b60648201526084016101eb565b600061061183610497565b600084815260208181526040808320848452825280832080546001600160a01b0319166001600160a01b0388161790558683526001909152812080549293509061065a836109d2565b9091555050506001600160a01b0316600090815260026020526040902055565b6000821161069a5760405162461bcd60e51b81526004016101eb90610979565b6001600160a01b0381166106c05760405162461bcd60e51b81526004016101eb90610950565b6106ca8282610251565b61072a5760405162461bcd60e51b815260206004820152602b60248201527f4163636f756e74206e6f74206c696e6b656420746f207468652070726f76696460448201526a656420537465616d49442160a81b60648201526084016101eb565b600061073583610497565b90506000811161075557634e487b7160e01b600052600160045260246000fd5b60005b81811015610881576000848152602081815260408083208484529091529020546001600160a01b038481169116141561086f576107966001836109a4565b81146107fa576000848152602081905260408120906107b66001856109a4565b815260208082019290925260409081016000908120548782528184528282208583529093522080546001600160a01b0319166001600160a01b039092169190911790555b6000848152602081905260408120906108146001856109a4565b81526020808201929092526040908101600090812080546001600160a01b03191690558681526001909252812080549161084d836109bb565b909155505050506001600160a01b031660009081526002602052604081205550565b80610879816109d2565b915050610758565b50505050565b80356001600160a01b038116811461089e57600080fd5b919050565b6000602082840312156108b4578081fd5b6108bd82610887565b9392505050565b6000602082840312156108d5578081fd5b5035919050565b600080604083850312156108ee578081fd5b823591506108fe60208401610887565b90509250929050565b60008060408385031215610919578182fd5b50508035926020909101359150565b600060208284031215610939578081fd5b813567ffffffffffffffff811681146108bd578182fd5b6020808252600f908201526e1a5b9d985b1a59081858d8dbdd5b9d608a1b604082015260600190565b6020808252601190820152701a5b9d985b1a59081cdd19585b5a590d8d607a1b604082015260600190565b6000828210156109b6576109b66109ed565b500390565b6000816109ca576109ca6109ed565b506000190190565b60006000198214156109e6576109e66109ed565b5060010190565b634e487b7160e01b600052601160045260246000fdfea2646970667358221220fded517f319e83ae488e9d6349436f0586f61ca9426c02af5587a407641eca1b64736f6c63430008040033",
"deployedBytecode": "0x60806040526004361061007f5760003560e01c80636f7b16241161004e5780636f7b1624146101335780639d6abe4f14610148578063d238028314610168578063dc750cee1461018857600080fd5b80632ce427af1461008e5780632d3538fe146100c15780634e68c8ad146100f1578063642c13011461011357600080fd5b3661008957600080fd5b600080fd5b34801561009a57600080fd5b506100ae6100a9366004610928565b6101c0565b6040519081526020015b60405180910390f35b3480156100cd57600080fd5b506100e16100dc3660046108dc565b610251565b60405190151581526020016100b8565b3480156100fd57600080fd5b5061011161010c3660046108c4565b6102b5565b005b34801561011f57600080fd5b506100e161012e3660046108a3565b610351565b34801561013f57600080fd5b50610111610397565b34801561015457600080fd5b506100ae6101633660046108a3565b610453565b34801561017457600080fd5b506100ae6101833660046108c4565b610497565b34801561019457600080fd5b506101a86101a3366004610907565b6104cb565b6040516001600160a01b0390911681526020016100b8565b6000808267ffffffffffffffff16116101f45760405162461bcd60e51b81526004016101eb90610979565b60405180910390fd5b604080517f63726561746564206279206b6567616e20686f6c6c65726e000000000000000060208201526001600160c01b031960c085901b1660388201520160408051601f19818403018152919052805160209091012092915050565b60008083116102725760405162461bcd60e51b81526004016101eb90610979565b6001600160a01b0382166102985760405162461bcd60e51b81526004016101eb90610950565b506001600160a01b03166000908152600260205260409020541490565b600081116102d55760405162461bcd60e51b81526004016101eb90610979565b6102e9335b6001600160a01b03163b151590565b156103445760405162461bcd60e51b815260206004820152602560248201527f436f6e7472616374732063616e6e6f74206c696e6b20537465616d204163636f604482015264756e74732160d81b60648201526084016101eb565b61034e813361055e565b50565b60006001600160a01b0382166103795760405162461bcd60e51b81526004016101eb90610950565b506001600160a01b0316600090815260026020526040902054151590565b6103a0336102da565b156103fd5760405162461bcd60e51b815260206004820152602760248201527f436f6e7472616374732063616e6e6f7420756e6c696e6b20537465616d204163604482015266636f756e74732160c81b60648201526084016101eb565b61040633610351565b61043f5760405162461bcd60e51b815260206004820152600a602482015269139bdd081b1a5b9ad95960b21b60448201526064016101eb565b61045161044b33610453565b3361067a565b565b60006001600160a01b03821661047b5760405162461bcd60e51b81526004016101eb90610950565b506001600160a01b031660009081526002602052604090205490565b60008082116104b85760405162461bcd60e51b81526004016101eb90610979565b5060009081526001602052604090205490565b60008083116104ec5760405162461bcd60e51b81526004016101eb90610979565b6104f583610497565b82106105395760405162461bcd60e51b8152602060048201526013602482015272696e646578206f7574206f6620626f756e647360681b60448201526064016101eb565b506000918252602082815260408084209284529190529020546001600160a01b031690565b6000821161057e5760405162461bcd60e51b81526004016101eb90610979565b6001600160a01b0381166105a45760405162461bcd60e51b81526004016101eb90610950565b6105ad81610351565b156106065760405162461bcd60e51b8152602060048201526024808201527f4163636f756e7420616c7265616479206c696e6b656420746f206120537465616044820152636d49442160e01b60648201526084016101eb565b600061061183610497565b600084815260208181526040808320848452825280832080546001600160a01b0319166001600160a01b0388161790558683526001909152812080549293509061065a836109d2565b9091555050506001600160a01b0316600090815260026020526040902055565b6000821161069a5760405162461bcd60e51b81526004016101eb90610979565b6001600160a01b0381166106c05760405162461bcd60e51b81526004016101eb90610950565b6106ca8282610251565b61072a5760405162461bcd60e51b815260206004820152602b60248201527f4163636f756e74206e6f74206c696e6b656420746f207468652070726f76696460448201526a656420537465616d49442160a81b60648201526084016101eb565b600061073583610497565b90506000811161075557634e487b7160e01b600052600160045260246000fd5b60005b81811015610881576000848152602081815260408083208484529091529020546001600160a01b038481169116141561086f576107966001836109a4565b81146107fa576000848152602081905260408120906107b66001856109a4565b815260208082019290925260409081016000908120548782528184528282208583529093522080546001600160a01b0319166001600160a01b039092169190911790555b6000848152602081905260408120906108146001856109a4565b81526020808201929092526040908101600090812080546001600160a01b03191690558681526001909252812080549161084d836109bb565b909155505050506001600160a01b031660009081526002602052604081205550565b80610879816109d2565b915050610758565b50505050565b80356001600160a01b038116811461089e57600080fd5b919050565b6000602082840312156108b4578081fd5b6108bd82610887565b9392505050565b6000602082840312156108d5578081fd5b5035919050565b600080604083850312156108ee578081fd5b823591506108fe60208401610887565b90509250929050565b60008060408385031215610919578182fd5b50508035926020909101359150565b600060208284031215610939578081fd5b813567ffffffffffffffff811681146108bd578182fd5b6020808252600f908201526e1a5b9d985b1a59081858d8dbdd5b9d608a1b604082015260600190565b6020808252601190820152701a5b9d985b1a59081cdd19585b5a590d8d607a1b604082015260600190565b6000828210156109b6576109b66109ed565b500390565b6000816109ca576109ca6109ed565b506000190190565b60006000198214156109e6576109e66109ed565b5060010190565b634e487b7160e01b600052601160045260246000fdfea2646970667358221220fded517f319e83ae488e9d6349436f0586f61ca9426c02af5587a407641eca1b64736f6c63430008040033",
"linkReferences": {},
"deployedLinkReferences": {}
}
{
"421611": "0x6c54Db620d1D50E68EcC9ecb6009B26F386723F0",
"42161": "0xa3146718b0b9F2175e8a7F306b88B0c0DE5ABadE"
}
\ No newline at end of file
......@@ -5,6 +5,17 @@ import infura from "./infura.js";
const error_banner = document.getElementById('header-error-notification');
const error_text = document.getElementById('header-error-text');
const steamid_link_form = document.getElementById('link-steam-id-form');
const steamid_input = document.getElementById('SteamID');
steamid_input.min = "10000000000000000";
steamid_input.max = "99999999999999999";
const steamid_unlink_btn = document.getElementById('unlink-steam-id-btn');
const steamid_link_div = document.getElementById('link-steam-id-div');
const steamid_unlink_div = document.getElementById('unlink-steam-id-div');
const connect_txt = document.getElementById('connect-wallet-btn-text');
const connect_btn = document.getElementById('connect-wallet-btn');
......@@ -36,98 +47,13 @@ const OnWalletLinked = async () => {
let ens = await GetENSName(address);
connect_txt.innerHTML = (ens == null ? await signer.getAddress() : ens);
}
const GetABI = async () => {
if(!IsOnArbitrum()) return [];
let network = await provider.getNetwork();
if(network.chainId == 421611)
{
return [
{
"inputs": [],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "_wallet",
"type": "address"
},
{
"indexed": false,
"internalType": "uint64",
"name": "_steamId64",
"type": "uint64"
}
],
"name": "AccountLinked",
"type": "event"
},
{
"inputs": [
{
"internalType": "uint64",
"name": "_steamId",
"type": "uint64"
}
],
"name": "GetEthereumWallets",
"outputs": [
{
"internalType": "address[]",
"name": "",
"type": "address[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_addr",
"type": "address"
}
],
"name": "GetSteamAccount",
"outputs": [
{
"internalType": "uint64",
"name": "",
"type": "uint64"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint64",
"name": "_steamId64",
"type": "uint64"
}
],
"name": "LinkSteamAccount",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
];
}
if(network.chainId == 42161)
{
return []; //current mainnet contract abi
}
return [];
const GetABI = async (contract) => {
let response = (await fetch(`./js/abi/${contract}.json`)).json();
return response;
};
const GetContracts = async (contract) => {
let response = (await fetch(`./js/contracts/${contract}.json`)).json();
return response;
};
const IsOnArbitrum = async () => {
let network = await provider.getNetwork();
......@@ -142,13 +68,18 @@ const GetENSName = (address) => {
let temp_provider = new ethers.providers.JsonRpcProvider(infura.getEthMainnet());
return temp_provider.lookupAddress(address);
};
const Hide = (element) => {
element.style.display = "none";
}
const Show = (element) => {
element.style.display = "block";
}
const HideErrorBanner = () => {
error_banner.style.display = "none !important";
Hide(error_banner);
};
const ShowErrorBanner = (text) => {
error_text.innerHTML = text;
error_banner.style.display = "block";
Show(error_banner);
};
if(await IsWalletConnected()) OnWalletLinked();
......@@ -158,4 +89,72 @@ connect_btn.onclick = OnConnectClicked; //on btn click call onConnectClicked
if(!await IsOnArbitrum())
{
ShowErrorBanner("You are not connected to the <a href=\"https://arbitrum.io/\" target=\"_blank\">Arbitrum</a> Network!");
// handle displaying page when not on arbitrum
}
else
{
HideErrorBanner();
Hide(steamid_link_div);
Hide(steamid_unlink_div);
let network = await provider.getNetwork(); //get our network id
if(network.chainId == 421611)
{
ShowErrorBanner("You are connected to the <a href=\"https://arbitrum.io/\" target=\"_blank\">Arbitrum</a> Test Network!");
}
let address = await provider.getSigner().getAddress();
//--- steam to ethereum setup
let ste_artifact = await GetABI("SteamIDToEthereum");
let ste_contracts = await GetContracts("SteamIDToEthereum");
console.log(ste_artifact);
console.log(ste_contracts);
const ste = new ethers.Contract(ste_contracts[`${network.chainId}`], ste_artifact.abi, provider);
if(await ste.hasLink(address))
{
//show unlink
Show(steamid_unlink_div);
steamid_unlink_btn.onclick = () => {
alert('unlink clicked');
};
}
else
{
//show link
Show(steamid_link_div);
steamid_link_form.onsubmit = () => {
alert('form submission!');
return false;
};
}
// handle display page when on arbitrum
}
if(is_web3)
{
// setup event handlers for
// - Account changed
// - Network changed
// - Link/Unlink
// on one of these events, reload the page for simplicity!
}
console.log('main.js done!');
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment