-
Notifications
You must be signed in to change notification settings - Fork 4
/
index_contract.html
152 lines (136 loc) · 4.61 KB
/
index_contract.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
<!DOCTYPE html>
<html class="no-js" lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="initial-scale=1.0, width=device-width, maximum-scale=1.0">
<title>Free City invitation by</title>
<link rel="preload" href="files/Site.min.css" as="style">
<link rel="reload" href="files/style.min.css" as="style">
<link rel="preload" href="files/sso-theme.min.css" as="style">
<link href="files/Site.min.css" rel="stylesheet" type="text/css">
<link href="files/style.min.css" rel="stylesheet" type="text/css">
<link href="files/sso-theme.min.css" rel="stylesheet" type="text/css">
<script src='waxjs.js'></script>
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XTEM2SY6EK"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XTEM2SY6EK');
</script>
<script src="https://cdn.onesignal.com/sdks/OneSignalSDK.js" async=""></script>
<script>
window.OneSignal = window.OneSignal || [];
OneSignal.push(function() {
OneSignal.init({
appId: "224c931b-c7a6-4969-997d-5d047c89460d",
});
});
</script>
</head>
<body style="background-image: url('files/bg.jpg');" align="center">
<center>
<div id="container">
<header>
<img src="files/wax.svg" alt="WAX" width="75px" height="75px">
<br>
<p>Wax Affiliation</p>
</header>
<section id="main" align="center">
<img src="files/new-logo-freecity.png" alt="FreeCityGame" width="100%">
<p>Affiliation For Game Interacting With Wax NFT Standard Assets.
<br><br>
<p>
1- Click this buttons to login with your wax wallet.
<br><br>
<button id="login" onclick=login() >WAX Login</button>
<input hidden="hidden" id="wallet">
<br><br>
<hr><br>
2- Click this buttons to register the game.
<br><br>
<button id="sign" onclick=sign() >Register to FreeCityGame</button><br><br>
<hr>
<label>Response</label>
<h1 id="response"></h1>
<hr>
</p>
<script>
const wax = new waxjs.WaxJS({
rpcEndpoint: 'https://wax.greymass.com'
});
// const wax = new waxjs.WaxJS({
// rpcEndpoint: 'http://wax-all.test:8888',
// tryAutoLogin: true,
// waxSigningURL: 'http://all-access.wax.test:8113',
// waxAutoSigningURL: 'http://idm.wax.test:8113/v1/accounts/auto-accept/'
// });
async function login() {
try {
const userAccount = await wax.login();
document.getElementById('wallet').value = userAccount;
document.getElementById('response').append('* You are Login *');
await getCurrentMessage();
} catch(e) {
document.getElementById('response').append(e.message);
}
}
async function sign() {
if(!wax.api) {
return document.getElementById('response').append('* Login first *');
}
const wallet = document.getElementById('wallet').value;
try {
const result = await wax.api.transact({
actions: [{
account: 'freecitygamx',
name: 'adduseraff',
authorization: [{
actor: wax.userAccount,
permission: 'active',
}],
data: {
wallet,
affiliate_wallet: 'kkere.wam',
},
}]
}, {
blocksBehind: 3,
expireSeconds: 30
});
document.getElementById('response').append('* You are Register *');
await new Promise(resolve => setTimeout(resolve, 1000));
await getCurrentMessage();
} catch(e) {
document.getElementById('response').append('* Expired Transaction *');
}
}
async function getCurrentMessage() {
const res = await wax.rpc.get_table_rows({
json: true,
code: 'freecitygamx',
scope: 'freecitygamx',
table: 'users',
lower_bound: wax.userAccount,
upper_bound: wax.userAccount,
});
const message = res.rows[0] ? res.rows[0].message : `<No message is set for ${wax.userAccount}>`;
}
// set a random value to the initial message value
document.getElementById('message').value = Math.random().toString(36).substring(2);
</script>
<br>
3- After you register, you can go to the gaming dapp.<br>
<a href="https://play.remixworlds.com/">https://play.remixworlds.com/</a>
<br><br>
<img src="files/wax.svg" alt="WAX" width="75px" height="75px">
</p>
<br>
</section>
<footer align="center">
<br><br>
© WaxAffiliation.io
</footer>
</div>
</center>
</body></html>