-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
153 lines (134 loc) · 4.34 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="application/wasm; charset=utf-8">
<title>Claim Link</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<script src="waxjs.js"></script>
<script src="sha256.js"></script>
<script src="https://unpkg.com/anchor-link@3"></script>
<script src="https://unpkg.com/anchor-link-browser-transport@3"></script>
<script>
window.dataLayer = window.dataLayer || [];
</script>
<script language="javascript">
$(document).ready(function() {
$("#divlists_table").html("");
});
const dapp = "claimlink";
let login_use = "";
let wallet_userAccount="none";
let wallet_session=null;
const wax = new waxjs.WaxJS({
rpcEndpoint: 'https://wax.greymass.com'
});
const transport = new AnchorLinkBrowserTransport();
const anchorLink = new AnchorLink({
transport,
chains: [{
chainId: '1064487b3cd1a897ce03ae5b6a865651747e2e152090f99c1d19d44e01aea5a4',
nodeUrl: 'https://wax.greymass.com',
}]
});
function loginWax(anchor){
login_use=anchor;
if (anchor) {
login_anchor();
}else{
login_waxjs().then(function(retorno){
wallet_userAccount=retorno;
$("#autologin").html(wallet_userAccount);
hideLoginButton();
wallet_session=wax.api;
});
}
}
function login_anchor(){
anchorLink.login(dapp).then((result) => {
console.log(result);
wallet_session = result.session;
console.log(result.session);
wallet_userAccount=wallet_session.auth.actor;
console.log(wallet_session.auth.actor);
$("#autologin").html(String(wallet_userAccount).split("@")[0]);
hideLoginButton();
});
}
async function login_waxjs(){
try {
let userAccount = await wax.login();
return userAccount;
} catch (e) {
$("#autologin").html(e.message);
}
return false;
}
function logout(){
wallet_userAccount="none";
if(login_use){
//anchorLink.logout();
session.remove();
$("#autologin").html("logout");
}else{
wax.logout();
$("#autologin").html("logout");
}
$("#divlogin").show();
$("#divlogout").hide();
}
function hideLoginButton() {
$("#divlogin").hide();
$("#divlogout").show();
checkToken();
}
function checkToken(){
$("#divlists_table").html("Checking Token...");
waxApiUrl ="https://wax.eosphere.io/";
//Modify this to the TOKEN contract
const TokenContract = "alien.worlds";
const TokenSymbol = "TLM";
jsonData=JSON.stringify({"json":true,"code":TokenContract,"scope":wallet_userAccount,"table":"accounts","limit":10});
$.ajax({
type: "POST",
url: waxApiUrl+"v1/chain/get_table_rows",
data: jsonData,
dataType: "json",
success: function (data) {
TokenFound =false;
console.log(data.rows);
$.each(data.rows, function (index, value) {
console.log(value);
if(value.balance){
//$("#divlists_table").html("You have "+value.balance+" "+TokenSymbol);
$("#divlists_table").html("The Link is : HTTP ");
TokenFound =true;
}
});
if(!TokenFound){
$("#divlists_table").html("You have to have at least 1 "+TokenSymbol+" to claim the link");
}
},
error: function (data) {
//console.log(data);
},
complete: function (data) {
//console.log("complete");
}
});
}
</script>
</head>
<body>
<p id="autologin"></p>
<div id="divlogin">
<button id="login" onclick="loginWax(false)">WAX Login</button>
<button id="login" onclick="loginWax(true)">Anchor Login</button>
</div>
<div id="divlogout" style="display:none"><button id="loginout" onclick=logout()>Logout</button></div>
<div id="divlists">
<div id="divlists_table"></div>
</div>
</body>
</html>