Skip to content

Commit

Permalink
fix: query revert on stratosphere contract
Browse files Browse the repository at this point in the history
  • Loading branch information
royvardhan committed Mar 20, 2024
1 parent a47db38 commit d9e7b72
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/config/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const deployedBlockTimestamps = {
*/
export const addresses: AddressMap = {
Stratosphere: {
[Chains.AVALANCHE]: "0x08e287adcf9bf6773a87e1a278aa9042bef44b60",
[Chains.AVALANCHE]: "0x08e287adCf9BF6773a87e1a278aa9042BEF44b60",
},

DexAggregator: {
Expand Down
22 changes: 16 additions & 6 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,23 @@ export async function getTokenId(
): Promise<bigint> {
const { client, network } = context;

const tokenId = await client.readContract({
abi: StratosphereAbi,
address: addresses.Stratosphere![network.name] as `0x${string}`,
functionName: "tokenIdOf",
args: [address],
});
let tokenId = 0n;
let revertedAddresses = [];

try {
tokenId = await client.readContract({
abi: StratosphereAbi,
address: addresses.Stratosphere![network.name] as `0x${string}`,
functionName: "tokenIdOf",
args: [address],
});
} catch (e) {
revertedAddresses.push(address);
}

if (revertedAddresses.length > 0) {
console.log(revertedAddresses);
}
return tokenId;
}

Expand Down
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ ponder.on("LiquidMining:Deposit", async ({ event, context }) => {
const { seasonId, user: userAddress, amount } = event.args;
const tokenId = await getTokenId(userAddress, context);

if (tokenId === 0n) {
return;
}

let liquidMiningData = await LiquidMining.findUnique({
id: seasonId,
});
Expand Down

0 comments on commit d9e7b72

Please sign in to comment.