Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Ethereum
Skin Z
Commits
716b9609
Commit
716b9609
authored
Sep 12, 2021
by
Kegan
Browse files
steam account linking contract completed
parent
590d363c
Changes
2
Hide whitespace changes
Inline
Side-by-side
test/tests.js
View file @
716b9609
...
...
@@ -65,7 +65,7 @@ describe("SteamIDToEthereum", function () {
expect
(
await
ste
.
hasLink
(
"
0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
"
)).
to
.
equal
(
false
);
console
.
log
(
'
linking account
'
);
await
ste
.
LinkSteamID
(
steamid_hash
);
console
.
log
(
await
ste
.
LinkSteamID
(
steamid_hash
)
)
;
console
.
log
(
'
testing accessors
'
);
expect
(
await
ste
.
getNumberOfLinks
(
steamid_hash
)).
to
.
equal
(
1
);
...
...
website/js/main.js
View file @
716b9609
...
...
@@ -10,7 +10,7 @@ const steamid_input = document.getElementById('SteamID');
steamid_input
.
min
=
"
10000000000000000
"
;
steamid_input
.
max
=
"
99999999999999999
"
;
const
steamid_link_btn
=
document
.
getElementById
(
'
link-steam-id-btn
'
);
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
'
);
...
...
@@ -117,11 +117,10 @@ else
ShowErrorBanner
(
"
You are connected to the <a href=
\"
https://arbitrum.io/
\"
target=
\"
_blank
\"
>Arbitrum</a> Test Network!
"
);
}
if
(
is_web3
)
if
(
signer
!=
null
)
{
//--- handle connected via Metamask/Web3
let
address
=
await
provider
.
getSigner
().
getAddress
();
let
address
=
await
signer
.
getAddress
();
//--- steam to ethereum setup
let
ste_artifact
=
await
GetABI
(
"
SteamIDToEthereum
"
);
...
...
@@ -129,13 +128,22 @@ else
console
.
log
(
ste_artifact
);
console
.
log
(
ste_contracts
);
const
ste
=
new
ethers
.
Contract
(
ste_contracts
[
`
${
network
.
chainId
}
`
],
ste_artifact
.
abi
,
provider
);
let
provider_ste
=
new
ethers
.
Contract
(
ste_contracts
[
`
${
network
.
chainId
}
`
],
ste_artifact
.
abi
,
provider
);
const
ste
=
provider_ste
.
connect
(
signer
);
if
(
await
ste
.
hasLink
(
address
))
{
//show unlink
Show
(
steamid_unlink_div
);
steamid_unlink_btn
.
onclick
=
()
=>
{
alert
(
'
unlink clicked
'
);
ste
.
Unlink
().
then
(
async
(
tx
)
=>
{
console
.
log
(
tx
);
//alert('unlinking steamid...');
await
tx
.
wait
();
//steamid unlinked, reload page
location
.
reload
();
});
};
}
else
...
...
@@ -143,9 +151,19 @@ else
//show link
Show
(
steamid_link_div
);
steamid_link_form
.
onsubmit
=
()
=>
{
alert
(
'
form submission!
'
);
steamid_link_btn
.
disabled
=
true
;
let
steamid64
=
steamid_input
.
value
;
let
hashed_steamid
=
ethers
.
utils
.
solidityKeccak256
([
"
string
"
,
"
uint64
"
],
[
"
created by kegan hollern
"
,
steamid64
]);
ste
.
LinkSteamID
(
hashed_steamid
).
then
(
async
(
tx
)
=>
{
console
.
log
(
tx
);
//alert('linking steamid...');
await
tx
.
wait
();
steamid_link_btn
.
disabled
=
false
;
//steamid linked, reload page
location
.
reload
();
});
return
false
;
};
...
...
@@ -156,7 +174,7 @@ else
}
else
{
//--- handle connected via Infura (no web3)
//--- handle connected via Infura (no web3)
OR no account link (no signer)
Show
(
steamid_link_div
);
steamid_link_form
.
onsubmit
=
()
=>
{
...
...
@@ -170,12 +188,18 @@ else
if
(
is_web3
)
{
// setup event handlers for
// - Account changed
// - Network changed
// - Link/Unlink
// on one of these events, reload the page for simplicity!
window
.
ethereum
.
on
(
'
accountsChanged
'
,
function
(
accounts
)
{
location
.
reload
();
});
window
.
ethereum
.
on
(
'
chainChanged
'
,
function
(
accounts
)
{
location
.
reload
();
});
if
(
!
window
.
ethereum
.
isConnected
())
{
window
.
ethereum
.
on
(
'
connect
'
,
function
(
accounts
)
{
location
.
reload
();
});
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment