diff --git a/public/deployments/contracts.json b/public/deployments/contracts.json index 2a1104a..70670a0 100644 --- a/public/deployments/contracts.json +++ b/public/deployments/contracts.json @@ -5715,6 +5715,11 @@ "name": "AirdropStillActive", "type": "error" }, + { + "inputs": [], + "name": "AirdropStillHasFunding", + "type": "error" + }, { "inputs": [], "name": "FailedInnerCall", @@ -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", @@ -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", diff --git a/public/js/pandasia.js b/public/js/pandasia.js index 62b1be5..9655e57 100644 --- a/public/js/pandasia.js +++ b/public/js/pandasia.js @@ -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) => {