Repository navigation
Expand file tree
/
Copy pathminingRate.js
More file actions
146 lines (106 loc) · 4.71 KB
/
Copy pathminingRate.js
File metadata and controls
146 lines (106 loc) · 4.71 KB
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
async function fetchPoolsJSON() {
const response = await fetch('pools.json');
const pools = await response.json();
return pools;
}
async function fetchKeysJSON(walletAddress) {
const response = await fetch('https://wax.api.atomicassets.io/atomicmarket/v1/assets?collection_name=upliftworld&schema_name=keys&owner=' + walletAddress + '&page=1&limit=500&order=desc&sort=asset_id');
const keys = await response.json();
return keys;
}
async function fetchMinersJSON(walletAddress) {
const response = await fetch('https://wax.api.atomicassets.io/atomicmarket/v1/assets?collection_name=upliftworld&schema_name=miners&owner=' + walletAddress + '&page=1&limit=1000&order=desc&sort=asset_id');
const keys = await response.json();
return keys;
}
async function fetchYoshisJSON(walletAddress) {
const response = await fetch('https://wax.api.atomicassets.io/atomicassets/v1/assets?collection_name=yoshidrops&schema_name=memberships&owner='+walletAddress+'&page=1&limit=200&order=desc&sort=asset_id');
const yoshis = await response.json();
return yoshis;
}
async function fetchYoshiCoinsJSON(walletAddress) {
const response = await fetch('https://wax.api.atomicassets.io/atomicassets/v1/assets?collection_name=yoshidrops&schema_name=yoshicoins&owner='+walletAddress+'&page=1&limit=200&order=desc&sort=asset_id');
const yoshisCoins = await response.json();
return yoshisCoins;
}
async function fetchAlphaWingsJSON(walletAddress) {
const response = await fetch('https://wax.api.atomicassets.io/atomicassets/v1/assets?collection_name=upliftworld&schema_name=collectibles&template_id=133746&owner='+walletAddress+'&page=1&limit=200&order=desc&sort=asset_id');
const alphaWings = await response.json();
return alphaWings;
}
async function getMiningRate() {
const miners = {
name: "",
rate: 0,
id: 0
};
const outputMiningRate = document.querySelector('.miningRate');
outputMiningRate.innerHTML = "";
let minerArray = [];
let keysOwned = [];
let minersOwned = [];
let yoshisOwned = [];
let yoshiCoinsOwned = [];
let alphaWingsOwned = [];
let upliftiumPerHourKeys = 0;
let upliftiumPerHourMiners = 0;
let upliftiumPerHourYoshis = 0;
let upliftiumPerHourYoshiCoins = 0;
let upliftiumPerHourAlphaWings = 0;
let walletAddress = document.getElementById("wallet").value;
await fetchPoolsJSON().then(pools => {
pools.data.payload.forEach((element, index) => {
const miner = Object.create(miners);
miner.name = element.label;
miner.rate = parseFloat(element.size_per_tick_per_asset);
miner.id = element.template_id;
minerArray[index] = miner;
});
});
await fetchKeysJSON(walletAddress).then(keys => {
keys.data.forEach((element, i) => {
keysOwned[i] = element.template.template_id;
});
});
await fetchMinersJSON(walletAddress).then(miners => {
miners.data.forEach((element, index) => {
minersOwned[index] = element;
});
});
await fetchYoshisJSON(walletAddress).then(yoshis => {
yoshis.data.forEach((element, index) => {
yoshisOwned[index] = element;
});
});
await fetchYoshiCoinsJSON(walletAddress).then(yoshiCoins => {
yoshiCoins.data.forEach((element, index) => {
yoshiCoinsOwned[index] = element;
});
});
await fetchAlphaWingsJSON(walletAddress).then(alphaWings => {
alphaWings.data.forEach((element, index) => {
alphaWingsOwned[index] = element;
});
});
keysOwned.forEach(element => {
let key = minerArray.find(o => o.id === element);
upliftiumPerHourKeys += parseFloat(key.rate);
});
minersOwned.forEach(element => {
let m = minerArray.find(o => o.id === element.template.template_id);
upliftiumPerHourMiners += parseFloat(m.rate);
});
yoshisOwned.forEach(element => {
let m = minerArray.find(o => o.id === element.template.template_id);
upliftiumPerHourYoshis += parseFloat(m.rate);
});
yoshiCoinsOwned.forEach(element => {
let m = minerArray.find(o => o.id === element.template.template_id);
upliftiumPerHourYoshiCoins += parseFloat(m.rate);
});
alphaWingsOwned.forEach(element => {
let m = minerArray.find(o => o.id === element.template.template_id);
upliftiumPerHourAlphaWings += parseFloat(m.rate);
});
outputMiningRate.innerHTML += '<br><h1>Upliftium per Hour</h1><h2><span>' + (upliftiumPerHourAlphaWings+ upliftiumPerHourYoshiCoins+upliftiumPerHourKeys + upliftiumPerHourMiners + upliftiumPerHourYoshis).toFixed(2) + '</span></h2>';
}