UNPKG

@galliun/sofi-sdk

Version:

SDK for interacting with the Galliun SocialFi protocol

207 lines (198 loc) 5.53 kB
import type { Transaction, TransactionResult } from '@mysten/sui/transactions'; import type { ObjectInput } from '../util'; import { objectArg } from '../util'; /** * Build transactions for the tip module. * Handles tip creation, claiming, and management. */ export const TipModule = { /** * Creates a new tip with initial payment * @param tx Transaction to build on * @param packageId Package ID of the protocol contract * @param coin_type The coin type to use for the tip * @param config Global config object * @param payment_coin Initial payment coin for the tip * @param profile Recipient's profile object * @param sender Optional sender's profile object * @param sender_points Optional sender's points object * @param message Optional message for the tip * @returns Transaction result */ new_tip_with_sender: ( tx: Transaction, packageId: string, coin_type: string, config: ObjectInput, payment_coin: ObjectInput, profile: ObjectInput, sender: ObjectInput, sender_points: ObjectInput, message: string | null, ): TransactionResult => { return tx.moveCall({ target: `${packageId}::tip::new_tip_with_sender`, typeArguments: [coin_type], arguments: [ objectArg(tx, config), objectArg(tx, payment_coin), objectArg(tx, profile), objectArg(tx, sender), objectArg(tx, sender_points), tx.pure.string(message || ''), tx.object.clock(), ], }) }, /** * Creates a new tip with initial payment * @param tx Transaction to build on * @param packageId Package ID of the protocol contract * @param coin_type The coin type to use for the tip * @param config Global config object * @param payment_coin Initial payment coin for the tip * @param profile Recipient's profile object * @param sender Optional sender's profile object * @param message Optional message for the tip * @returns Transaction result */ new_tip_without_sender: ( tx: Transaction, packageId: string, coin_type: string, config: ObjectInput, payment_coin: ObjectInput, profile: ObjectInput, message: string | null, ): TransactionResult => { return tx.moveCall({ target: `${packageId}::tip::new_tip_without_sender`, typeArguments: [coin_type], arguments: [ objectArg(tx, config), objectArg(tx, payment_coin), objectArg(tx, profile), tx.pure.string(message || ''), tx.object.clock(), ], }) }, /** * Claims a tip * @param tx Transaction to build on * @param packageId Package ID of the protocol contract * @param coin_type The coin type to claim * @param config Global config object * @param profile Recipient's profile object * @param tip Tip object to claim * @returns Transaction result with claimed coin */ claim_tip: ( tx: Transaction, packageId: string, coin_type: string, config: ObjectInput, profile: ObjectInput, profile_points: ObjectInput, tip: ObjectInput, ): TransactionResult => tx.moveCall({ target: `${packageId}::tip::claim_tip`, typeArguments: [coin_type], arguments: [ objectArg(tx, config), objectArg(tx, profile), objectArg(tx, profile_points), objectArg(tx, tip), ], }), /** * Cancels a tip * @param tx Transaction to build on * @param packageId Package ID of the protocol contract * @param coin_type The coin type of the tip * @param config Global config object * @param profile Profile object of the recipient * @param tip Tip object to cancel * @returns Transaction result */ cancel_tip: ( tx: Transaction, packageId: string, coin_type: string, config: ObjectInput, profile: ObjectInput, tip: ObjectInput, ): TransactionResult => tx.moveCall({ target: `${packageId}::tip::cancel_tip`, typeArguments: [coin_type], arguments: [ objectArg(tx, config), objectArg(tx, profile), objectArg(tx, tip), ], }), /** * Gets the balance amount of a tip * @param tx Transaction to build on * @param packageId Package ID of the protocol contract * @param coin_type The coin type of the tip * @param tip Tip object to check * @returns Transaction result with balance amount */ balance_amount: ( tx: Transaction, packageId: string, coin_type: string, tip: ObjectInput, ): TransactionResult => tx.moveCall({ target: `${packageId}::tip::balance_amount`, typeArguments: [coin_type], arguments: [objectArg(tx, tip)], }), /** * Share a tip object * @param tx Transaction to build on * @param packageId Package ID of the protocol contract * @param coin_type The coin type of the tip * @param tip Tip object to share * @returns Transaction result */ share: ( tx: Transaction, packageId: string, coin_type: string, tip: ObjectInput ): TransactionResult => tx.moveCall({ target: `${packageId}::tip::share`, typeArguments: [coin_type], arguments: [objectArg(tx, tip)], }), /** * Toggles the display status of a tip * @param tx Transaction to build on * @param packageId Package ID of the protocol contract * @param coin_type The coin type of the tip * @param profile Profile object of the recipient * @param tip Tip object to toggle display * @returns Transaction result */ display: ( tx: Transaction, packageId: string, coin_type: string, profile: ObjectInput, tip: ObjectInput, ): TransactionResult => tx.moveCall({ target: `${packageId}::tip::display`, typeArguments: [coin_type], arguments: [ objectArg(tx, profile), objectArg(tx, tip), ], }), };