-
Notifications
You must be signed in to change notification settings - Fork 65
/
inject.js
34 lines (31 loc) · 974 Bytes
/
inject.js
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
//window.mywax = new waxjs.WaxJS({rpcEndpoint: 'https://wax.dapplica.io'});
window.sleep = function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
window.wax_login = async function(){
try {
const auto_login = await window.mywax.isAutoLoginAvailable();
if (!auto_login)
window.mywax.login();
return [true,"ok"];
} catch (e){
return [false, e.message];
}
}
window.wax_transact = async function(transaction){
try {
const auto_login = await window.mywax.isAutoLoginAvailable();
if (!auto_login){
await window.mywax.login();
await window.sleep(3000);
}
console.log(transaction)
const result = await window.mywax.api.transact(transaction, {
blocksBehind: 3,
expireSeconds: 90,
});
return [true, result];
} catch (e){
return [false, e.message];
}
}