Skip to content

Commit

Permalink
Fix pandasia page
Browse files Browse the repository at this point in the history
  • Loading branch information
chand1012 committed Dec 12, 2023
1 parent 83b8d6c commit ad0bda5
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 22 deletions.
34 changes: 30 additions & 4 deletions public/deployments/contracts.json
Original file line number Diff line number Diff line change
Expand Up @@ -5715,6 +5715,11 @@
"name": "AirdropStillActive",
"type": "error"
},
{
"inputs": [],
"name": "AirdropStillHasFunding",
"type": "error"
},
{
"inputs": [],
"name": "FailedInnerCall",
Expand Down Expand Up @@ -5937,6 +5942,19 @@
"name": "RoleRevoked",
"type": "event"
},
{
"inputs": [],
"name": "AIRDROP_ADMIN",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "DEFAULT_ADMIN_ROLE",
Expand Down Expand Up @@ -6195,11 +6213,19 @@
"internalType": "uint64",
"name": "airdropId",
"type": "uint64"
},
}
],
"name": "deleteAirdrop",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "withdrawAmt",
"type": "uint256"
"internalType": "uint64",
"name": "airdropId",
"type": "uint64"
}
],
"name": "emergencyWithdraw",
Expand Down
37 changes: 19 additions & 18 deletions public/js/pandasia.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,25 +74,26 @@ class Pandasia {
const addressCount = await this.contract.cChainAddrsCount();
// convert from a BigNumber to a number
const count = addressCount.toNumber();
// getRegisteredUsers takes an offset and a limit
let offset = 0;
let limit = 10;
let users = [];
while (users.length < count) {
// make a request to the contract
const resp = await this.contract.getRegisteredUsers(offset, limit);
// if the response is empty, break out of the loop
if (resp.length === 0) {
break;
}
// otherwise, add the response to the local addresses
users.push(...resp);
if (resp.length < limit) {
break;
}
// increment the offset
offset += limit;
let addresses = [];
// get the entire registered addresses array
for (let i = 0; i < count; i++) {
addresses.push(this.contract.cChainAddrs(i));
}
// wait for all the addresses to resolve
addresses = await Promise.all(addresses);

let pChainAddresses = addresses.map((address) => {
return this.contract.c2p(address);
});
// wait for all the addresses to resolve
pChainAddresses = await Promise.all(pChainAddresses);
// zip them together
const users = addresses.map((address, i) => {
return {
cChainAddr: address,
pChainAddr: pChainAddresses[i],
};
});

// users are an object with two keys: cChainAddr and pChainAddr
this.users = users.map((user, i) => {
Expand Down

0 comments on commit ad0bda5

Please sign in to comment.