Skip to content

Commit

Permalink
make bounty retrieval action account for true decimals (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
moshmage authored Feb 26, 2024
1 parent 82f1108 commit 0552ac2
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/models/network-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,20 @@ export class Network_v2 extends Model<Network_v2Methods> implements Deployable {
}

async getBounty(id: number) {
return bounty(await this.callTx(this.contract.methods.getBounty(id)));
const chainInformation = await this.callTx(this.contract.methods.getBounty(id));

if (!chainInformation)
throw new Error(`No bounty with ${id}`);

const transactional = new ERC20(this.connection, chainInformation.transactional);
await transactional.start();

const reward = chainInformation.rewardToken !== nativeZeroAddress ?
new ERC20(this.connection, chainInformation.rewardToken) : null;

await reward?.start();

return bounty(chainInformation, this.networkToken.decimals, transactional.decimals, reward?.decimals);
}

/**
Expand Down

0 comments on commit 0552ac2

Please sign in to comment.