{"version":3,"file":"royalty_rule.mjs","names":[],"sources":["../../../src/contracts/kiosk/royalty_rule.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\n\n/**\n * Description: This module defines a Rule which requires a payment on a purchase.\n * The payment amount can be either a fixed amount (min_amount) or a percentage of\n * the purchase price (amount_bp). Or both: the higher of the two is used.\n *\n * Configuration:\n *\n * - amount_bp - the percentage of the purchase price to be paid as a fee,\n *   denominated in basis points (100_00 = 100%, 1 = 0.01%).\n * - min_amount - the minimum amount to be paid as a fee if the relative amount is\n *   lower than this setting.\n *\n * Use cases:\n *\n * - Percentage-based Royalty fee for the creator of the NFT.\n * - Fixed commission fee on a trade.\n * - A mix of both: the higher of the two is used.\n *\n * Notes:\n *\n * - To use it as a fixed commission set the `amount_bp` to 0 and use the\n *   `min_amount` to set the fixed amount.\n * - To use it as a percentage-based fee set the `min_amount` to 0 and use the\n *   `amount_bp` to set the percentage.\n * - To use it as a mix of both set the `min_amount` to the min amount acceptable\n *   and the `amount_bp` to the percentage of the purchase price. The higher of the\n *   two will be used.\n */\n\nimport { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js';\nimport { bcs } from '@mysten/sui/bcs';\nimport { type Transaction, type TransactionArgument } from '@mysten/sui/transactions';\nconst $moduleName = '@local-pkg/kiosk::royalty_rule';\nexport const Rule = new MoveStruct({\n\tname: `${$moduleName}::Rule`,\n\tfields: {\n\t\tdummy_field: bcs.bool(),\n\t},\n});\nexport const Config = new MoveStruct({\n\tname: `${$moduleName}::Config`,\n\tfields: {\n\t\tamount_bp: bcs.u16(),\n\t\tmin_amount: bcs.u64(),\n\t},\n});\nexport interface AddArguments {\n\tpolicy: RawTransactionArgument<string>;\n\tcap: RawTransactionArgument<string>;\n\tamountBp: RawTransactionArgument<number>;\n\tminAmount: RawTransactionArgument<number | bigint>;\n}\nexport interface AddOptions {\n\tpackage?: string;\n\targuments:\n\t\t| AddArguments\n\t\t| [\n\t\t\t\tpolicy: RawTransactionArgument<string>,\n\t\t\t\tcap: RawTransactionArgument<string>,\n\t\t\t\tamountBp: RawTransactionArgument<number>,\n\t\t\t\tminAmount: RawTransactionArgument<number | bigint>,\n\t\t  ];\n\ttypeArguments: [string];\n}\n/**\n * Creator action: Add the Royalty Rule for the `T`. Pass in the `TransferPolicy`,\n * `TransferPolicyCap` and the configuration for the policy: `amount_bp` and\n * `min_amount`.\n */\nexport function add(options: AddOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/kiosk';\n\tconst argumentsTypes = [null, null, 'u16', 'u64'] satisfies (string | null)[];\n\tconst parameterNames = ['policy', 'cap', 'amountBp', 'minAmount'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'royalty_rule',\n\t\t\tfunction: 'add',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface PayArguments {\n\tpolicy: RawTransactionArgument<string>;\n\trequest: TransactionArgument;\n\tpayment: RawTransactionArgument<string>;\n}\nexport interface PayOptions {\n\tpackage?: string;\n\targuments:\n\t\t| PayArguments\n\t\t| [\n\t\t\t\tpolicy: RawTransactionArgument<string>,\n\t\t\t\trequest: TransactionArgument,\n\t\t\t\tpayment: RawTransactionArgument<string>,\n\t\t  ];\n\ttypeArguments: [string];\n}\n/** Buyer action: Pay the royalty fee for the transfer. */\nexport function pay(options: PayOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/kiosk';\n\tconst argumentsTypes = [null, null, null] satisfies (string | null)[];\n\tconst parameterNames = ['policy', 'request', 'payment'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'royalty_rule',\n\t\t\tfunction: 'pay',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface FeeAmountArguments {\n\tpolicy: RawTransactionArgument<string>;\n\tpaid: RawTransactionArgument<number | bigint>;\n}\nexport interface FeeAmountOptions {\n\tpackage?: string;\n\targuments:\n\t\t| FeeAmountArguments\n\t\t| [policy: RawTransactionArgument<string>, paid: RawTransactionArgument<number | bigint>];\n\ttypeArguments: [string];\n}\n/**\n * Helper function to calculate the amount to be paid for the transfer. Can be used\n * dry-runned to estimate the fee amount based on the Kiosk listing price.\n */\nexport function feeAmount(options: FeeAmountOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/kiosk';\n\tconst argumentsTypes = [null, 'u64'] satisfies (string | null)[];\n\tconst parameterNames = ['policy', 'paid'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'royalty_rule',\n\t\t\tfunction: 'fee_amount',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAM,cAAc;AACpB,MAAa,OAAO,IAAI,WAAW;CAClC,MAAM,GAAG,YAAY;CACrB,QAAQ,EACP,aAAa,IAAI,MAAM,EACvB;CACD,CAAC;AACF,MAAa,SAAS,IAAI,WAAW;CACpC,MAAM,GAAG,YAAY;CACrB,QAAQ;EACP,WAAW,IAAI,KAAK;EACpB,YAAY,IAAI,KAAK;EACrB;CACD,CAAC;;;;;;AAwBF,SAAgB,IAAI,SAAqB;CACxC,MAAM,iBAAiB,QAAQ,WAAW;CAC1C,MAAM,iBAAiB;EAAC;EAAM;EAAM;EAAO;EAAM;CACjD,MAAM,iBAAiB;EAAC;EAAU;EAAO;EAAY;EAAY;AACjE,SAAQ,OACP,GAAG,SAAS;EACX,SAAS;EACT,QAAQ;EACR,UAAU;EACV,WAAW,uBAAuB,QAAQ,WAAW,gBAAgB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