@river-build/web3
Version:
Dapps for our Space and Registry contracts
46 lines • 1.85 kB
JavaScript
import { BaseContractShim } from './BaseContractShim';
import DevAbi from '@river-build/generated/dev/abis/ITipping.abi.json' assert { type: 'json' };
export class ITippingShim extends BaseContractShim {
constructor(address, provider) {
super(address, provider, DevAbi);
}
/**
* Get the total number of tips by currency
* @param currency - The currency to get the total tips for
* @returns The total number of tips by currency
*/
async totalTipsByCurrency(currency) {
const totalTips = await this.read.totalTipsByCurrency(currency);
return totalTips.toBigInt();
}
/**
* Get the tip amount by currency
* @param currency - The currency to get the tip amount for
* @returns The tip amount by currency
*/
async tipAmountByCurrency(currency) {
const tips = await this.read.tipAmountByCurrency(currency);
return tips.toBigInt();
}
getTipEvent(receipt, senderAddress) {
for (const log of receipt.logs) {
if (log.address === this.address) {
const parsedLog = this.interface.parseLog(log);
if (parsedLog.name === 'Tip' &&
parsedLog.args.sender.toLowerCase() === senderAddress.toLowerCase()) {
return {
tokenId: parsedLog.args.tokenId,
currency: parsedLog.args.currency,
sender: parsedLog.args.sender,
receiver: parsedLog.args.receiver,
amount: parsedLog.args.amount,
messageId: parsedLog.args.messageId,
channelId: parsedLog.args.channelId,
};
}
}
}
return undefined;
}
}
//# sourceMappingURL=ITippingShim.js.map