diff --git a/src/contract/abi/newbie-villa.ts b/src/contract/abi/newbie-villa.ts index ac840106..88e29788 100644 --- a/src/contract/abi/newbie-villa.ts +++ b/src/contract/abi/newbie-villa.ts @@ -133,6 +133,7 @@ export const newbieVilla = [ { name: 'xsyncOperator_', type: 'address' }, { name: 'token_', type: 'address' }, { name: 'admin_', type: 'address' }, + { name: 'tips_', type: 'address' }, ], name: 'initialize', outputs: [], @@ -178,6 +179,29 @@ export const newbieVilla = [ stateMutability: 'view', type: 'function', }, + { + inputs: [ + { name: 'fromCharacterId', type: 'uint256' }, + { name: 'toCharacterId', type: 'uint256' }, + { name: 'amount', type: 'uint256' }, + ], + name: 'tipCharacter', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { name: 'fromCharacterId', type: 'uint256' }, + { name: 'toCharacterId', type: 'uint256' }, + { name: 'toNoteId', type: 'uint256' }, + { name: 'amount', type: 'uint256' }, + ], + name: 'tipCharacterForNote', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, { inputs: [ { name: '', type: 'address' }, diff --git a/src/contract/subcontracts/tips.ts b/src/contract/subcontracts/tips.ts index 45854ced..da9b8e88 100644 --- a/src/contract/subcontracts/tips.ts +++ b/src/contract/subcontracts/tips.ts @@ -1,6 +1,6 @@ import { type Address, encodeAbiParameters, isAddressEqual } from 'viem' import { autoSwitchMainnet } from '../decorators' -import { type Entry, type Mira, type Tips } from '../abi' +import { type Entry, type Mira, type NewbieVilla, type Tips } from '../abi' import { type Numberish, type ReadOverrides, @@ -48,6 +48,56 @@ export class TipsContract { } } + @autoSwitchMainnet() + async tipCharacterFromNewbieVilla( + fromCharacterId: Numberish, + toCharacterId: Numberish, + amount: Numberish, + overrides: WriteOverrides = {}, + ) { + const hash = await this.base.newbieVillaContract.write.tipCharacter( + [BigInt(fromCharacterId), BigInt(toCharacterId), BigInt(amount)], + overrides, + ) + + const receipt = await this.base.publicClient.waitForTransactionReceipt({ + hash, + }) + + return { + data: undefined, + transactionHash: receipt.transactionHash, + } + } + + @autoSwitchMainnet() + async tipCharacterForNoteFromNewbieVilla( + fromCharacterId: Numberish, + toCharacterId: Numberish, + toNoteId: Numberish, + amount: Numberish, + overrides: WriteOverrides = {}, + ) { + const hash = await this.base.newbieVillaContract.write.tipCharacterForNote( + [ + BigInt(fromCharacterId), + BigInt(toCharacterId), + BigInt(toNoteId), + BigInt(amount), + ], + overrides, + ) + + const receipt = await this.base.publicClient.waitForTransactionReceipt({ + hash, + }) + + return { + data: undefined, + transactionHash: receipt.transactionHash, + } + } + /** * This tips a character for a note with $MIRA token. *