diff --git a/lib/src/main/java/com/metaplex/lib/Metaplex.kt b/lib/src/main/java/com/metaplex/lib/Metaplex.kt index 3ac81ff..6a1e43f 100644 --- a/lib/src/main/java/com/metaplex/lib/Metaplex.kt +++ b/lib/src/main/java/com/metaplex/lib/Metaplex.kt @@ -18,7 +18,7 @@ class Metaplex(val connection: Connection, val nft: NftClient by lazy { NftClient(connection, identityDriver) } val tokens: TokenClient by lazy { TokenClient(connection) } - val auctions: AuctionsClient by lazy { AuctionsClient(connection) } + val auctions: AuctionsClient by lazy { AuctionsClient(connection, identityDriver) } val candyMachinesV2: CandyMachineV2Client by lazy { CandyMachineV2Client(connection, identityDriver) } val candyMachines: CandyMachineClient by lazy { CandyMachineClient(connection, identityDriver) } diff --git a/lib/src/main/java/com/metaplex/lib/experimental/jen/Idl.kt b/lib/src/main/java/com/metaplex/lib/experimental/jen/Idl.kt index 13d264f..cf5fd3c 100644 --- a/lib/src/main/java/com/metaplex/lib/experimental/jen/Idl.kt +++ b/lib/src/main/java/com/metaplex/lib/experimental/jen/Idl.kt @@ -26,7 +26,7 @@ data class Instruction(val name: String, val accounts: List, @Serializable data class AccountInput(val name: String, val isMut: Boolean, val isSigner: Boolean, - val desc: String? = null, val optional: Boolean = false) + val desc: String? = null, val optional: Boolean = false, val docs: List? = null) @Serializable data class Argument(val name: String, @Serializable(with = FTSerializer::class) val type: FieldType) diff --git a/lib/src/main/java/com/metaplex/lib/experimental/jen/auctionhouse/Accounts.kt b/lib/src/main/java/com/metaplex/lib/experimental/jen/auctionhouse/Accounts.kt index 7b5372d..d146c41 100644 --- a/lib/src/main/java/com/metaplex/lib/experimental/jen/auctionhouse/Accounts.kt +++ b/lib/src/main/java/com/metaplex/lib/experimental/jen/auctionhouse/Accounts.kt @@ -2,7 +2,7 @@ // Accounts // Metaplex // -// This code was generated locally by Funkatronics on 2022-08-11 +// This code was generated locally by Funkatronics on 2022-10-20 // @file:UseSerializers(PublicKeyAs32ByteSerializer::class) @@ -10,6 +10,12 @@ package com.metaplex.lib.experimental.jen.auctionhouse import com.metaplex.lib.serialization.serializers.solana.PublicKeyAs32ByteSerializer import com.solana.core.PublicKey +import kotlin.Boolean +import kotlin.Long +import kotlin.UByte +import kotlin.ULong +import kotlin.UShort +import kotlin.collections.List import kotlinx.serialization.Serializable import kotlinx.serialization.UseSerializers diff --git a/lib/src/main/java/com/metaplex/lib/experimental/jen/auctionhouse/Errors.kt b/lib/src/main/java/com/metaplex/lib/experimental/jen/auctionhouse/Errors.kt index be78486..99018d2 100644 --- a/lib/src/main/java/com/metaplex/lib/experimental/jen/auctionhouse/Errors.kt +++ b/lib/src/main/java/com/metaplex/lib/experimental/jen/auctionhouse/Errors.kt @@ -2,10 +2,13 @@ // Errors // Metaplex // -// This code was generated locally by Funkatronics on 2022-08-11 +// This code was generated locally by Funkatronics on 2022-10-20 // package com.metaplex.lib.experimental.jen.auctionhouse +import kotlin.Int +import kotlin.String + sealed interface AuctionHouseError { val code: Int @@ -118,7 +121,7 @@ class CannotMatchFreeSalesWithoutAuctionHouseOrSellerSignoff : AuctionHouseError override val code: Int = 6017 override val message: String = - "Cannot match free sales unless the auction house or seller signs off" + "Cannot match free sales unless the auction house or seller signs off" } class SaleRequiresSigner : AuctionHouseError { @@ -227,7 +230,7 @@ class EscrowUnderRentExemption : AuctionHouseError { override val code: Int = 6035 override val message: String = - "The instruction would drain the escrow below rent exemption threshold" + "The instruction would drain the escrow below rent exemption threshold" } class InvalidSeedsOrAuctionHouseNotDelegated : AuctionHouseError { @@ -246,21 +249,21 @@ class MissingElementForPartialOrder : AuctionHouseError { override val code: Int = 6038 override val message: String = - "Partial order size and price must both be provided in a partial buy." + "Partial order size and price must both be provided in a partial buy." } class NotEnoughTokensAvailableForPurchase : AuctionHouseError { override val code: Int = 6039 override val message: String = - "Amount of tokens available for purchase is less than the partial order amount." + "Amount of tokens available for purchase is less than the partial order amount." } class PartialPriceMismatch : AuctionHouseError { override val code: Int = 6040 override val message: String = - "Calculated partial price does not not partial price that was provided." + "Calculated partial price does not not partial price that was provided." } class AuctionHouseAlreadyDelegated : AuctionHouseError { diff --git a/lib/src/main/java/com/metaplex/lib/experimental/jen/auctionhouse/Instructions.kt b/lib/src/main/java/com/metaplex/lib/experimental/jen/auctionhouse/Instructions.kt index bb7eaa4..5281c73 100644 --- a/lib/src/main/java/com/metaplex/lib/experimental/jen/auctionhouse/Instructions.kt +++ b/lib/src/main/java/com/metaplex/lib/experimental/jen/auctionhouse/Instructions.kt @@ -2,14 +2,20 @@ // Instructions // Metaplex // -// This code was generated locally by Funkatronics on 2022-08-11 +// This code was generated locally by Funkatronics on 2022-10-20 // package com.metaplex.lib.experimental.jen.auctionhouse import com.metaplex.lib.serialization.format.Borsh +import com.metaplex.lib.serialization.serializers.solana.AnchorInstructionSerializer import com.solana.core.AccountMeta import com.solana.core.PublicKey import com.solana.core.TransactionInstruction +import kotlin.Boolean +import kotlin.UByte +import kotlin.ULong +import kotlin.UShort +import kotlin.collections.List import kotlinx.serialization.Serializable object AuctionHouseInstructions { @@ -21,22 +27,12 @@ object AuctionHouseInstructions { systemProgram: PublicKey, amount: ULong ): TransactionInstruction = - TransactionInstruction( - PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), - listOf( - AccountMeta(authority, true, false), AccountMeta( - feeWithdrawalDestination, false, - true - ), AccountMeta(auctionHouseFeeAccount, false, true), AccountMeta( - auctionHouse, - false, true - ), AccountMeta(systemProgram, false, false) - ), - Borsh.encodeToByteArray( - Args_withdrawFromFee.serializer(), - Args_withdrawFromFee(amount) - ) - ) + TransactionInstruction(PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), + listOf(AccountMeta(authority, true, false), AccountMeta(feeWithdrawalDestination, false, + true), AccountMeta(auctionHouseFeeAccount, false, true), AccountMeta(auctionHouse, + false, true), AccountMeta(systemProgram, false, false)), + Borsh.encodeToByteArray(AnchorInstructionSerializer("withdraw_from_fee"), + Args_withdrawFromFee(amount))) fun withdrawFromTreasury( treasuryMint: PublicKey, @@ -48,22 +44,13 @@ object AuctionHouseInstructions { systemProgram: PublicKey, amount: ULong ): TransactionInstruction = - TransactionInstruction( - PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), - listOf( - AccountMeta(treasuryMint, false, false), - AccountMeta(authority, true, false), - AccountMeta(treasuryWithdrawalDestination, false, true), - AccountMeta(auctionHouseTreasury, false, true), - AccountMeta(auctionHouse, false, true), - AccountMeta(tokenProgram, false, false), - AccountMeta(systemProgram, false, false) - ), - Borsh.encodeToByteArray( - Args_withdrawFromTreasury.serializer(), - Args_withdrawFromTreasury(amount) - ) - ) + TransactionInstruction(PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), + listOf(AccountMeta(treasuryMint, false, false), AccountMeta(authority, true, false), + AccountMeta(treasuryWithdrawalDestination, false, true), + AccountMeta(auctionHouseTreasury, false, true), AccountMeta(auctionHouse, false, true), + AccountMeta(tokenProgram, false, false), AccountMeta(systemProgram, false, false)), + Borsh.encodeToByteArray(AnchorInstructionSerializer("withdraw_from_treasury"), + Args_withdrawFromTreasury(amount))) fun updateAuctionHouse( treasuryMint: PublicKey, @@ -82,26 +69,16 @@ object AuctionHouseInstructions { requiresSignOff: Boolean?, canChangeSalePrice: Boolean? ): TransactionInstruction = - TransactionInstruction( - PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), - listOf( - AccountMeta(treasuryMint, false, false), AccountMeta(payer, true, false), - AccountMeta(authority, true, false), AccountMeta(newAuthority, false, false), - AccountMeta(feeWithdrawalDestination, false, true), - AccountMeta(treasuryWithdrawalDestination, false, true), - AccountMeta(treasuryWithdrawalDestinationOwner, false, false), AccountMeta( - auctionHouse, - false, true - ), AccountMeta(tokenProgram, false, false), AccountMeta( - systemProgram, false, - false - ), AccountMeta(ataProgram, false, false), AccountMeta(rent, false, false) - ), - Borsh.encodeToByteArray( - Args_updateAuctionHouse.serializer(), - Args_updateAuctionHouse(sellerFeeBasisPoints, requiresSignOff, canChangeSalePrice) - ) - ) + TransactionInstruction(PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), + listOf(AccountMeta(treasuryMint, false, false), AccountMeta(payer, true, false), + AccountMeta(authority, true, false), AccountMeta(newAuthority, false, false), + AccountMeta(feeWithdrawalDestination, false, true), + AccountMeta(treasuryWithdrawalDestination, false, true), + AccountMeta(treasuryWithdrawalDestinationOwner, false, false), AccountMeta(auctionHouse, + false, true), AccountMeta(tokenProgram, false, false), AccountMeta(systemProgram, false, + false), AccountMeta(ataProgram, false, false), AccountMeta(rent, false, false)), + Borsh.encodeToByteArray(AnchorInstructionSerializer("update_auction_house"), + Args_updateAuctionHouse(sellerFeeBasisPoints, requiresSignOff, canChangeSalePrice))) fun createAuctionHouse( treasuryMint: PublicKey, @@ -124,37 +101,18 @@ object AuctionHouseInstructions { requiresSignOff: Boolean, canChangeSalePrice: Boolean ): TransactionInstruction = - TransactionInstruction( - PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), - listOf( - AccountMeta(treasuryMint, false, false), - AccountMeta(payer, true, true), - AccountMeta(authority, false, false), - AccountMeta( - feeWithdrawalDestination, false, - true - ), - AccountMeta(treasuryWithdrawalDestination, false, true), - AccountMeta(treasuryWithdrawalDestinationOwner, false, false), - AccountMeta( - auctionHouse, - false, true - ), - AccountMeta(auctionHouseFeeAccount, false, true), - AccountMeta(auctionHouseTreasury, false, true), - AccountMeta(tokenProgram, false, false), - AccountMeta(systemProgram, false, false), - AccountMeta(ataProgram, false, false), - AccountMeta(rent, false, false) - ), - Borsh.encodeToByteArray( - Args_createAuctionHouse.serializer(), - Args_createAuctionHouse( - bump, feePayerBump, treasuryBump, sellerFeeBasisPoints, - requiresSignOff, canChangeSalePrice - ) - ) - ) + TransactionInstruction(PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), + listOf(AccountMeta(treasuryMint, false, false), AccountMeta(payer, true, true), + AccountMeta(authority, false, false), AccountMeta(feeWithdrawalDestination, false, + true), AccountMeta(treasuryWithdrawalDestination, false, true), + AccountMeta(treasuryWithdrawalDestinationOwner, false, false), AccountMeta(auctionHouse, + false, true), AccountMeta(auctionHouseFeeAccount, false, true), + AccountMeta(auctionHouseTreasury, false, true), AccountMeta(tokenProgram, false, false), + AccountMeta(systemProgram, false, false), AccountMeta(ataProgram, false, false), + AccountMeta(rent, false, false)), + Borsh.encodeToByteArray(AnchorInstructionSerializer("create_auction_house"), + Args_createAuctionHouse(bump, feePayerBump, treasuryBump, sellerFeeBasisPoints, + requiresSignOff, canChangeSalePrice))) fun buy( wallet: PublicKey, @@ -176,37 +134,16 @@ object AuctionHouseInstructions { buyerPrice: ULong, tokenSize: ULong ): TransactionInstruction = - TransactionInstruction( - PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), - listOf( - AccountMeta(wallet, true, false), - AccountMeta(paymentAccount, false, true), - AccountMeta(transferAuthority, false, false), - AccountMeta(treasuryMint, false, false), - AccountMeta(tokenAccount, false, false), - AccountMeta(metadata, false, false), - AccountMeta(escrowPaymentAccount, false, true), - AccountMeta(authority, false, false), - AccountMeta(auctionHouse, false, false), - AccountMeta( - auctionHouseFeeAccount, false, - true - ), - AccountMeta(buyerTradeState, false, true), - AccountMeta( - tokenProgram, false, - false - ), - AccountMeta(systemProgram, false, false), - AccountMeta(rent, false, false) - ), - Borsh.encodeToByteArray( - Args_buy.serializer(), Args_buy( - tradeStateBump, - escrowPaymentBump, buyerPrice, tokenSize - ) - ) - ) + TransactionInstruction(PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), + listOf(AccountMeta(wallet, true, false), AccountMeta(paymentAccount, false, true), + AccountMeta(transferAuthority, false, false), AccountMeta(treasuryMint, false, false), + AccountMeta(tokenAccount, false, false), AccountMeta(metadata, false, false), + AccountMeta(escrowPaymentAccount, false, true), AccountMeta(authority, false, false), + AccountMeta(auctionHouse, false, false), AccountMeta(auctionHouseFeeAccount, false, + true), AccountMeta(buyerTradeState, false, true), AccountMeta(tokenProgram, false, + false), AccountMeta(systemProgram, false, false), AccountMeta(rent, false, false)), + Borsh.encodeToByteArray(AnchorInstructionSerializer("buy"), Args_buy(tradeStateBump, + escrowPaymentBump, buyerPrice, tokenSize))) fun auctioneerBuy( wallet: PublicKey, @@ -230,37 +167,17 @@ object AuctionHouseInstructions { buyerPrice: ULong, tokenSize: ULong ): TransactionInstruction = - TransactionInstruction( - PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), - listOf( - AccountMeta(wallet, true, false), - AccountMeta(paymentAccount, false, true), - AccountMeta(transferAuthority, false, false), - AccountMeta(treasuryMint, false, false), - AccountMeta(tokenAccount, false, false), - AccountMeta(metadata, false, false), - AccountMeta(escrowPaymentAccount, false, true), - AccountMeta(authority, false, false), - AccountMeta(auctioneerAuthority, true, false), - AccountMeta(auctionHouse, false, false), - AccountMeta(auctionHouseFeeAccount, false, true), - AccountMeta( - buyerTradeState, false, - true - ), - AccountMeta(ahAuctioneerPda, false, false), - AccountMeta( - tokenProgram, false, - false - ), - AccountMeta(systemProgram, false, false), - AccountMeta(rent, false, false) - ), - Borsh.encodeToByteArray( - Args_auctioneerBuy.serializer(), - Args_auctioneerBuy(tradeStateBump, escrowPaymentBump, buyerPrice, tokenSize) - ) - ) + TransactionInstruction(PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), + listOf(AccountMeta(wallet, true, false), AccountMeta(paymentAccount, false, true), + AccountMeta(transferAuthority, false, false), AccountMeta(treasuryMint, false, false), + AccountMeta(tokenAccount, false, false), AccountMeta(metadata, false, false), + AccountMeta(escrowPaymentAccount, false, true), AccountMeta(authority, false, false), + AccountMeta(auctioneerAuthority, true, false), AccountMeta(auctionHouse, false, false), + AccountMeta(auctionHouseFeeAccount, false, true), AccountMeta(buyerTradeState, false, + true), AccountMeta(ahAuctioneerPda, false, false), AccountMeta(tokenProgram, false, + false), AccountMeta(systemProgram, false, false), AccountMeta(rent, false, false)), + Borsh.encodeToByteArray(AnchorInstructionSerializer("auctioneer_buy"), + Args_auctioneerBuy(tradeStateBump, escrowPaymentBump, buyerPrice, tokenSize))) fun publicBuy( wallet: PublicKey, @@ -282,37 +199,16 @@ object AuctionHouseInstructions { buyerPrice: ULong, tokenSize: ULong ): TransactionInstruction = - TransactionInstruction( - PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), - listOf( - AccountMeta(wallet, true, false), - AccountMeta(paymentAccount, false, true), - AccountMeta(transferAuthority, false, false), - AccountMeta(treasuryMint, false, false), - AccountMeta(tokenAccount, false, false), - AccountMeta(metadata, false, false), - AccountMeta(escrowPaymentAccount, false, true), - AccountMeta(authority, false, false), - AccountMeta(auctionHouse, false, false), - AccountMeta( - auctionHouseFeeAccount, false, - true - ), - AccountMeta(buyerTradeState, false, true), - AccountMeta( - tokenProgram, false, - false - ), - AccountMeta(systemProgram, false, false), - AccountMeta(rent, false, false) - ), - Borsh.encodeToByteArray( - Args_publicBuy.serializer(), Args_publicBuy( - tradeStateBump, - escrowPaymentBump, buyerPrice, tokenSize - ) - ) - ) + TransactionInstruction(PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), + listOf(AccountMeta(wallet, true, false), AccountMeta(paymentAccount, false, true), + AccountMeta(transferAuthority, false, false), AccountMeta(treasuryMint, false, false), + AccountMeta(tokenAccount, false, false), AccountMeta(metadata, false, false), + AccountMeta(escrowPaymentAccount, false, true), AccountMeta(authority, false, false), + AccountMeta(auctionHouse, false, false), AccountMeta(auctionHouseFeeAccount, false, + true), AccountMeta(buyerTradeState, false, true), AccountMeta(tokenProgram, false, + false), AccountMeta(systemProgram, false, false), AccountMeta(rent, false, false)), + Borsh.encodeToByteArray(AnchorInstructionSerializer("public_buy"), + Args_publicBuy(tradeStateBump, escrowPaymentBump, buyerPrice, tokenSize))) fun auctioneerPublicBuy( wallet: PublicKey, @@ -336,37 +232,17 @@ object AuctionHouseInstructions { buyerPrice: ULong, tokenSize: ULong ): TransactionInstruction = - TransactionInstruction( - PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), - listOf( - AccountMeta(wallet, true, false), - AccountMeta(paymentAccount, false, true), - AccountMeta(transferAuthority, false, false), - AccountMeta(treasuryMint, false, false), - AccountMeta(tokenAccount, false, false), - AccountMeta(metadata, false, false), - AccountMeta(escrowPaymentAccount, false, true), - AccountMeta(authority, false, false), - AccountMeta(auctioneerAuthority, true, false), - AccountMeta(auctionHouse, false, false), - AccountMeta(auctionHouseFeeAccount, false, true), - AccountMeta( - buyerTradeState, false, - true - ), - AccountMeta(ahAuctioneerPda, false, false), - AccountMeta( - tokenProgram, false, - false - ), - AccountMeta(systemProgram, false, false), - AccountMeta(rent, false, false) - ), - Borsh.encodeToByteArray( - Args_auctioneerPublicBuy.serializer(), - Args_auctioneerPublicBuy(tradeStateBump, escrowPaymentBump, buyerPrice, tokenSize) - ) - ) + TransactionInstruction(PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), + listOf(AccountMeta(wallet, true, false), AccountMeta(paymentAccount, false, true), + AccountMeta(transferAuthority, false, false), AccountMeta(treasuryMint, false, false), + AccountMeta(tokenAccount, false, false), AccountMeta(metadata, false, false), + AccountMeta(escrowPaymentAccount, false, true), AccountMeta(authority, false, false), + AccountMeta(auctioneerAuthority, true, false), AccountMeta(auctionHouse, false, false), + AccountMeta(auctionHouseFeeAccount, false, true), AccountMeta(buyerTradeState, false, + true), AccountMeta(ahAuctioneerPda, false, false), AccountMeta(tokenProgram, false, + false), AccountMeta(systemProgram, false, false), AccountMeta(rent, false, false)), + Borsh.encodeToByteArray(AnchorInstructionSerializer("auctioneer_public_buy"), + Args_auctioneerPublicBuy(tradeStateBump, escrowPaymentBump, buyerPrice, tokenSize))) fun cancel( wallet: PublicKey, @@ -380,18 +256,13 @@ object AuctionHouseInstructions { buyerPrice: ULong, tokenSize: ULong ): TransactionInstruction = - TransactionInstruction( - PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), - listOf( - AccountMeta(wallet, false, true), AccountMeta(tokenAccount, false, true), - AccountMeta(tokenMint, false, false), AccountMeta(authority, false, false), - AccountMeta(auctionHouse, false, false), AccountMeta( - auctionHouseFeeAccount, false, - true - ), AccountMeta(tradeState, false, true), AccountMeta(tokenProgram, false, false) - ), - Borsh.encodeToByteArray(Args_cancel.serializer(), Args_cancel(buyerPrice, tokenSize)) - ) + TransactionInstruction(PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), + listOf(AccountMeta(wallet, false, true), AccountMeta(tokenAccount, false, true), + AccountMeta(tokenMint, false, false), AccountMeta(authority, false, false), + AccountMeta(auctionHouse, false, false), AccountMeta(auctionHouseFeeAccount, false, + true), AccountMeta(tradeState, false, true), AccountMeta(tokenProgram, false, false)), + Borsh.encodeToByteArray(AnchorInstructionSerializer("cancel"), Args_cancel(buyerPrice, + tokenSize))) fun auctioneerCancel( wallet: PublicKey, @@ -407,25 +278,14 @@ object AuctionHouseInstructions { buyerPrice: ULong, tokenSize: ULong ): TransactionInstruction = - TransactionInstruction( - PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), - listOf( - AccountMeta(wallet, false, true), - AccountMeta(tokenAccount, false, true), - AccountMeta(tokenMint, false, false), - AccountMeta(authority, false, false), - AccountMeta(auctioneerAuthority, true, false), - AccountMeta(auctionHouse, false, false), - AccountMeta(auctionHouseFeeAccount, false, true), - AccountMeta(tradeState, false, true), - AccountMeta(ahAuctioneerPda, false, false), - AccountMeta(tokenProgram, false, false) - ), - Borsh.encodeToByteArray( - Args_auctioneerCancel.serializer(), - Args_auctioneerCancel(buyerPrice, tokenSize) - ) - ) + TransactionInstruction(PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), + listOf(AccountMeta(wallet, false, true), AccountMeta(tokenAccount, false, true), + AccountMeta(tokenMint, false, false), AccountMeta(authority, false, false), + AccountMeta(auctioneerAuthority, true, false), AccountMeta(auctionHouse, false, false), + AccountMeta(auctionHouseFeeAccount, false, true), AccountMeta(tradeState, false, true), + AccountMeta(ahAuctioneerPda, false, false), AccountMeta(tokenProgram, false, false)), + Borsh.encodeToByteArray(AnchorInstructionSerializer("auctioneer_cancel"), + Args_auctioneerCancel(buyerPrice, tokenSize))) fun deposit( wallet: PublicKey, @@ -442,29 +302,15 @@ object AuctionHouseInstructions { escrowPaymentBump: UByte, amount: ULong ): TransactionInstruction = - TransactionInstruction( - PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), - listOf( - AccountMeta(wallet, true, false), AccountMeta(paymentAccount, false, true), - AccountMeta(transferAuthority, false, false), AccountMeta( - escrowPaymentAccount, false, - true - ), AccountMeta(treasuryMint, false, false), AccountMeta(authority, false, false), - AccountMeta(auctionHouse, false, false), AccountMeta( - auctionHouseFeeAccount, false, - true - ), AccountMeta(tokenProgram, false, false), AccountMeta( - systemProgram, false, - false - ), AccountMeta(rent, false, false) - ), - Borsh.encodeToByteArray( - Args_deposit.serializer(), Args_deposit( - escrowPaymentBump, - amount - ) - ) - ) + TransactionInstruction(PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), + listOf(AccountMeta(wallet, true, false), AccountMeta(paymentAccount, false, true), + AccountMeta(transferAuthority, false, false), AccountMeta(escrowPaymentAccount, false, + true), AccountMeta(treasuryMint, false, false), AccountMeta(authority, false, false), + AccountMeta(auctionHouse, false, false), AccountMeta(auctionHouseFeeAccount, false, + true), AccountMeta(tokenProgram, false, false), AccountMeta(systemProgram, false, + false), AccountMeta(rent, false, false)), + Borsh.encodeToByteArray(AnchorInstructionSerializer("deposit"), + Args_deposit(escrowPaymentBump, amount))) fun auctioneerDeposit( wallet: PublicKey, @@ -483,37 +329,16 @@ object AuctionHouseInstructions { escrowPaymentBump: UByte, amount: ULong ): TransactionInstruction = - TransactionInstruction( - PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), - listOf( - AccountMeta(wallet, true, false), - AccountMeta(paymentAccount, false, true), - AccountMeta(transferAuthority, false, false), - AccountMeta( - escrowPaymentAccount, false, - true - ), - AccountMeta(treasuryMint, false, false), - AccountMeta(authority, false, false), - AccountMeta(auctioneerAuthority, true, false), - AccountMeta(auctionHouse, false, false), - AccountMeta(auctionHouseFeeAccount, false, true), - AccountMeta( - ahAuctioneerPda, false, - false - ), - AccountMeta(tokenProgram, false, false), - AccountMeta( - systemProgram, false, - false - ), - AccountMeta(rent, false, false) - ), - Borsh.encodeToByteArray( - Args_auctioneerDeposit.serializer(), - Args_auctioneerDeposit(escrowPaymentBump, amount) - ) - ) + TransactionInstruction(PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), + listOf(AccountMeta(wallet, true, false), AccountMeta(paymentAccount, false, true), + AccountMeta(transferAuthority, false, false), AccountMeta(escrowPaymentAccount, false, + true), AccountMeta(treasuryMint, false, false), AccountMeta(authority, false, false), + AccountMeta(auctioneerAuthority, true, false), AccountMeta(auctionHouse, false, false), + AccountMeta(auctionHouseFeeAccount, false, true), AccountMeta(ahAuctioneerPda, false, + false), AccountMeta(tokenProgram, false, false), AccountMeta(systemProgram, false, + false), AccountMeta(rent, false, false)), + Borsh.encodeToByteArray(AnchorInstructionSerializer("auctioneer_deposit"), + Args_auctioneerDeposit(escrowPaymentBump, amount))) fun executeSale( buyer: PublicKey, @@ -543,39 +368,21 @@ object AuctionHouseInstructions { buyerPrice: ULong, tokenSize: ULong ): TransactionInstruction = - TransactionInstruction( - PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), - listOf( - AccountMeta(buyer, false, true), AccountMeta(seller, false, true), - AccountMeta(tokenAccount, false, true), AccountMeta(tokenMint, false, false), - AccountMeta(metadata, false, false), AccountMeta(treasuryMint, false, false), - AccountMeta(escrowPaymentAccount, false, true), AccountMeta( - sellerPaymentReceiptAccount, - false, true - ), AccountMeta(buyerReceiptTokenAccount, false, true), AccountMeta( - authority, - false, false - ), AccountMeta(auctionHouse, false, false), - AccountMeta(auctionHouseFeeAccount, false, true), AccountMeta( - auctionHouseTreasury, - false, true - ), AccountMeta(buyerTradeState, false, true), AccountMeta( - sellerTradeState, - false, true - ), AccountMeta(freeTradeState, false, true), AccountMeta( - tokenProgram, false, - false - ), AccountMeta(systemProgram, false, false), AccountMeta(ataProgram, false, false), - AccountMeta(programAsSigner, false, false), AccountMeta(rent, false, false) - ), - Borsh.encodeToByteArray( - Args_executeSale.serializer(), - Args_executeSale( - escrowPaymentBump, freeTradeStateBump, programAsSignerBump, buyerPrice, - tokenSize - ) - ) - ) + TransactionInstruction(PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), + listOf(AccountMeta(buyer, false, true), AccountMeta(seller, false, true), + AccountMeta(tokenAccount, false, true), AccountMeta(tokenMint, false, false), + AccountMeta(metadata, false, false), AccountMeta(treasuryMint, false, false), + AccountMeta(escrowPaymentAccount, false, true), AccountMeta(sellerPaymentReceiptAccount, + false, true), AccountMeta(buyerReceiptTokenAccount, false, true), AccountMeta(authority, + false, false), AccountMeta(auctionHouse, false, false), + AccountMeta(auctionHouseFeeAccount, false, true), AccountMeta(auctionHouseTreasury, + false, true), AccountMeta(buyerTradeState, false, true), AccountMeta(sellerTradeState, + false, true), AccountMeta(freeTradeState, false, true), AccountMeta(tokenProgram, false, + false), AccountMeta(systemProgram, false, false), AccountMeta(ataProgram, false, false), + AccountMeta(programAsSigner, false, false), AccountMeta(rent, false, false)), + Borsh.encodeToByteArray(AnchorInstructionSerializer("execute_sale"), + Args_executeSale(escrowPaymentBump, freeTradeStateBump, programAsSignerBump, buyerPrice, + tokenSize))) fun executePartialSale( buyer: PublicKey, @@ -607,39 +414,21 @@ object AuctionHouseInstructions { partialOrderSize: ULong?, partialOrderPrice: ULong? ): TransactionInstruction = - TransactionInstruction( - PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), - listOf( - AccountMeta(buyer, false, true), AccountMeta(seller, false, true), - AccountMeta(tokenAccount, false, true), AccountMeta(tokenMint, false, false), - AccountMeta(metadata, false, false), AccountMeta(treasuryMint, false, false), - AccountMeta(escrowPaymentAccount, false, true), AccountMeta( - sellerPaymentReceiptAccount, - false, true - ), AccountMeta(buyerReceiptTokenAccount, false, true), AccountMeta( - authority, - false, false - ), AccountMeta(auctionHouse, false, false), - AccountMeta(auctionHouseFeeAccount, false, true), AccountMeta( - auctionHouseTreasury, - false, true - ), AccountMeta(buyerTradeState, false, true), AccountMeta( - sellerTradeState, - false, true - ), AccountMeta(freeTradeState, false, true), AccountMeta( - tokenProgram, false, - false - ), AccountMeta(systemProgram, false, false), AccountMeta(ataProgram, false, false), - AccountMeta(programAsSigner, false, false), AccountMeta(rent, false, false) - ), - Borsh.encodeToByteArray( - Args_executePartialSale.serializer(), - Args_executePartialSale( - escrowPaymentBump, freeTradeStateBump, programAsSignerBump, - buyerPrice, tokenSize, partialOrderSize, partialOrderPrice - ) - ) - ) + TransactionInstruction(PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), + listOf(AccountMeta(buyer, false, true), AccountMeta(seller, false, true), + AccountMeta(tokenAccount, false, true), AccountMeta(tokenMint, false, false), + AccountMeta(metadata, false, false), AccountMeta(treasuryMint, false, false), + AccountMeta(escrowPaymentAccount, false, true), AccountMeta(sellerPaymentReceiptAccount, + false, true), AccountMeta(buyerReceiptTokenAccount, false, true), AccountMeta(authority, + false, false), AccountMeta(auctionHouse, false, false), + AccountMeta(auctionHouseFeeAccount, false, true), AccountMeta(auctionHouseTreasury, + false, true), AccountMeta(buyerTradeState, false, true), AccountMeta(sellerTradeState, + false, true), AccountMeta(freeTradeState, false, true), AccountMeta(tokenProgram, false, + false), AccountMeta(systemProgram, false, false), AccountMeta(ataProgram, false, false), + AccountMeta(programAsSigner, false, false), AccountMeta(rent, false, false)), + Borsh.encodeToByteArray(AnchorInstructionSerializer("execute_partial_sale"), + Args_executePartialSale(escrowPaymentBump, freeTradeStateBump, programAsSignerBump, + buyerPrice, tokenSize, partialOrderSize, partialOrderPrice))) fun auctioneerExecuteSale( buyer: PublicKey, @@ -671,42 +460,22 @@ object AuctionHouseInstructions { buyerPrice: ULong, tokenSize: ULong ): TransactionInstruction = - TransactionInstruction( - PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), - listOf( - AccountMeta(buyer, false, true), AccountMeta(seller, false, true), - AccountMeta(tokenAccount, false, true), AccountMeta(tokenMint, false, false), - AccountMeta(metadata, false, false), AccountMeta(treasuryMint, false, false), - AccountMeta(escrowPaymentAccount, false, true), AccountMeta( - sellerPaymentReceiptAccount, - false, true - ), AccountMeta(buyerReceiptTokenAccount, false, true), AccountMeta( - authority, - false, false - ), AccountMeta(auctioneerAuthority, true, false), AccountMeta( - auctionHouse, - false, false - ), AccountMeta(auctionHouseFeeAccount, false, true), - AccountMeta(auctionHouseTreasury, false, true), AccountMeta( - buyerTradeState, false, - true - ), AccountMeta(sellerTradeState, false, true), AccountMeta( - freeTradeState, false, - true - ), AccountMeta(ahAuctioneerPda, false, false), AccountMeta( - tokenProgram, false, - false - ), AccountMeta(systemProgram, false, false), AccountMeta(ataProgram, false, false), - AccountMeta(programAsSigner, false, false), AccountMeta(rent, false, false) - ), - Borsh.encodeToByteArray( - Args_auctioneerExecuteSale.serializer(), - Args_auctioneerExecuteSale( - escrowPaymentBump, freeTradeStateBump, programAsSignerBump, - buyerPrice, tokenSize - ) - ) - ) + TransactionInstruction(PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), + listOf(AccountMeta(buyer, false, true), AccountMeta(seller, false, true), + AccountMeta(tokenAccount, false, true), AccountMeta(tokenMint, false, false), + AccountMeta(metadata, false, false), AccountMeta(treasuryMint, false, false), + AccountMeta(escrowPaymentAccount, false, true), AccountMeta(sellerPaymentReceiptAccount, + false, true), AccountMeta(buyerReceiptTokenAccount, false, true), AccountMeta(authority, + false, false), AccountMeta(auctioneerAuthority, true, false), AccountMeta(auctionHouse, + false, false), AccountMeta(auctionHouseFeeAccount, false, true), + AccountMeta(auctionHouseTreasury, false, true), AccountMeta(buyerTradeState, false, + true), AccountMeta(sellerTradeState, false, true), AccountMeta(freeTradeState, false, + true), AccountMeta(ahAuctioneerPda, false, false), AccountMeta(tokenProgram, false, + false), AccountMeta(systemProgram, false, false), AccountMeta(ataProgram, false, false), + AccountMeta(programAsSigner, false, false), AccountMeta(rent, false, false)), + Borsh.encodeToByteArray(AnchorInstructionSerializer("auctioneer_execute_sale"), + Args_auctioneerExecuteSale(escrowPaymentBump, freeTradeStateBump, programAsSignerBump, + buyerPrice, tokenSize))) fun auctioneerExecutePartialSale( buyer: PublicKey, @@ -740,42 +509,22 @@ object AuctionHouseInstructions { partialOrderSize: ULong?, partialOrderPrice: ULong? ): TransactionInstruction = - TransactionInstruction( - PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), - listOf( - AccountMeta(buyer, false, true), AccountMeta(seller, false, true), - AccountMeta(tokenAccount, false, true), AccountMeta(tokenMint, false, false), - AccountMeta(metadata, false, false), AccountMeta(treasuryMint, false, false), - AccountMeta(escrowPaymentAccount, false, true), AccountMeta( - sellerPaymentReceiptAccount, - false, true - ), AccountMeta(buyerReceiptTokenAccount, false, true), AccountMeta( - authority, - false, false - ), AccountMeta(auctioneerAuthority, true, false), AccountMeta( - auctionHouse, - false, false - ), AccountMeta(auctionHouseFeeAccount, false, true), - AccountMeta(auctionHouseTreasury, false, true), AccountMeta( - buyerTradeState, false, - true - ), AccountMeta(sellerTradeState, false, true), AccountMeta( - freeTradeState, false, - true - ), AccountMeta(ahAuctioneerPda, false, false), AccountMeta( - tokenProgram, false, - false - ), AccountMeta(systemProgram, false, false), AccountMeta(ataProgram, false, false), - AccountMeta(programAsSigner, false, false), AccountMeta(rent, false, false) - ), - Borsh.encodeToByteArray( - Args_auctioneerExecutePartialSale.serializer(), - Args_auctioneerExecutePartialSale( - escrowPaymentBump, freeTradeStateBump, - programAsSignerBump, buyerPrice, tokenSize, partialOrderSize, partialOrderPrice - ) - ) - ) + TransactionInstruction(PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), + listOf(AccountMeta(buyer, false, true), AccountMeta(seller, false, true), + AccountMeta(tokenAccount, false, true), AccountMeta(tokenMint, false, false), + AccountMeta(metadata, false, false), AccountMeta(treasuryMint, false, false), + AccountMeta(escrowPaymentAccount, false, true), AccountMeta(sellerPaymentReceiptAccount, + false, true), AccountMeta(buyerReceiptTokenAccount, false, true), AccountMeta(authority, + false, false), AccountMeta(auctioneerAuthority, true, false), AccountMeta(auctionHouse, + false, false), AccountMeta(auctionHouseFeeAccount, false, true), + AccountMeta(auctionHouseTreasury, false, true), AccountMeta(buyerTradeState, false, + true), AccountMeta(sellerTradeState, false, true), AccountMeta(freeTradeState, false, + true), AccountMeta(ahAuctioneerPda, false, false), AccountMeta(tokenProgram, false, + false), AccountMeta(systemProgram, false, false), AccountMeta(ataProgram, false, false), + AccountMeta(programAsSigner, false, false), AccountMeta(rent, false, false)), + Borsh.encodeToByteArray(AnchorInstructionSerializer("auctioneer_execute_partial_sale"), + Args_auctioneerExecutePartialSale(escrowPaymentBump, freeTradeStateBump, + programAsSignerBump, buyerPrice, tokenSize, partialOrderSize, partialOrderPrice))) fun sell( wallet: PublicKey, @@ -796,29 +545,15 @@ object AuctionHouseInstructions { buyerPrice: ULong, tokenSize: ULong ): TransactionInstruction = - TransactionInstruction( - PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), - listOf( - AccountMeta(wallet, false, false), AccountMeta(tokenAccount, false, true), - AccountMeta(metadata, false, false), AccountMeta(authority, false, false), - AccountMeta(auctionHouse, false, false), AccountMeta( - auctionHouseFeeAccount, false, - true - ), AccountMeta(sellerTradeState, false, true), AccountMeta( - freeSellerTradeState, - false, true - ), AccountMeta(tokenProgram, false, false), AccountMeta( - systemProgram, false, - false - ), AccountMeta(programAsSigner, false, false), AccountMeta(rent, false, false) - ), - Borsh.encodeToByteArray( - Args_sell.serializer(), Args_sell( - tradeStateBump, - freeTradeStateBump, programAsSignerBump, buyerPrice, tokenSize - ) - ) - ) + TransactionInstruction(PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), + listOf(AccountMeta(wallet, false, false), AccountMeta(tokenAccount, false, true), + AccountMeta(metadata, false, false), AccountMeta(authority, false, false), + AccountMeta(auctionHouse, false, false), AccountMeta(auctionHouseFeeAccount, false, + true), AccountMeta(sellerTradeState, false, true), AccountMeta(freeSellerTradeState, + false, true), AccountMeta(tokenProgram, false, false), AccountMeta(systemProgram, false, + false), AccountMeta(programAsSigner, false, false), AccountMeta(rent, false, false)), + Borsh.encodeToByteArray(AnchorInstructionSerializer("sell"), Args_sell(tradeStateBump, + freeTradeStateBump, programAsSignerBump, buyerPrice, tokenSize))) fun auctioneerSell( wallet: PublicKey, @@ -840,43 +575,17 @@ object AuctionHouseInstructions { programAsSignerBump: UByte, tokenSize: ULong ): TransactionInstruction = - TransactionInstruction( - PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), - listOf( - AccountMeta(wallet, false, true), - AccountMeta(tokenAccount, false, true), - AccountMeta(metadata, false, false), - AccountMeta(authority, false, false), - AccountMeta(auctioneerAuthority, true, false), - AccountMeta(auctionHouse, false, false), - AccountMeta(auctionHouseFeeAccount, false, true), - AccountMeta( - sellerTradeState, false, - true - ), - AccountMeta(freeSellerTradeState, false, true), - AccountMeta( - ahAuctioneerPda, - false, false - ), - AccountMeta(programAsSigner, false, false), - AccountMeta( - tokenProgram, - false, false - ), - AccountMeta(systemProgram, false, false), - AccountMeta( - rent, false, - false - ) - ), Borsh.encodeToByteArray( - Args_auctioneerSell.serializer(), - Args_auctioneerSell( - tradeStateBump, freeTradeStateBump, programAsSignerBump, - tokenSize - ) - ) - ) + TransactionInstruction(PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), + listOf(AccountMeta(wallet, false, true), AccountMeta(tokenAccount, false, true), + AccountMeta(metadata, false, false), AccountMeta(authority, false, false), + AccountMeta(auctioneerAuthority, true, false), AccountMeta(auctionHouse, false, false), + AccountMeta(auctionHouseFeeAccount, false, true), AccountMeta(sellerTradeState, false, + true), AccountMeta(freeSellerTradeState, false, true), AccountMeta(ahAuctioneerPda, + false, false), AccountMeta(programAsSigner, false, false), AccountMeta(tokenProgram, + false, false), AccountMeta(systemProgram, false, false), AccountMeta(rent, false, + false)), Borsh.encodeToByteArray(AnchorInstructionSerializer("auctioneer_sell"), + Args_auctioneerSell(tradeStateBump, freeTradeStateBump, programAsSignerBump, + tokenSize))) fun withdraw( wallet: PublicKey, @@ -893,28 +602,15 @@ object AuctionHouseInstructions { escrowPaymentBump: UByte, amount: ULong ): TransactionInstruction = - TransactionInstruction( - PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), - listOf( - AccountMeta(wallet, false, false), - AccountMeta(receiptAccount, false, true), - AccountMeta(escrowPaymentAccount, false, true), - AccountMeta(treasuryMint, false, false), - AccountMeta(authority, false, false), - AccountMeta(auctionHouse, false, false), - AccountMeta(auctionHouseFeeAccount, false, true), - AccountMeta( - tokenProgram, false, - false - ), - AccountMeta(systemProgram, false, false), - AccountMeta(ataProgram, false, false), - AccountMeta(rent, false, false) - ), Borsh.encodeToByteArray( - Args_withdraw.serializer(), - Args_withdraw(escrowPaymentBump, amount) - ) - ) + TransactionInstruction(PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), + listOf(AccountMeta(wallet, false, false), AccountMeta(receiptAccount, false, true), + AccountMeta(escrowPaymentAccount, false, true), AccountMeta(treasuryMint, false, false), + AccountMeta(authority, false, false), AccountMeta(auctionHouse, false, false), + AccountMeta(auctionHouseFeeAccount, false, true), AccountMeta(tokenProgram, false, + false), AccountMeta(systemProgram, false, false), AccountMeta(ataProgram, false, false), + AccountMeta(rent, false, false)), + Borsh.encodeToByteArray(AnchorInstructionSerializer("withdraw"), + Args_withdraw(escrowPaymentBump, amount))) fun auctioneerWithdraw( wallet: PublicKey, @@ -933,34 +629,16 @@ object AuctionHouseInstructions { escrowPaymentBump: UByte, amount: ULong ): TransactionInstruction = - TransactionInstruction( - PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), - listOf( - AccountMeta(wallet, false, false), - AccountMeta(receiptAccount, false, true), - AccountMeta(escrowPaymentAccount, false, true), - AccountMeta(treasuryMint, false, false), - AccountMeta(authority, false, false), - AccountMeta(auctioneerAuthority, true, false), - AccountMeta(auctionHouse, false, false), - AccountMeta( - auctionHouseFeeAccount, false, - true - ), - AccountMeta(ahAuctioneerPda, false, false), - AccountMeta( - tokenProgram, false, - false - ), - AccountMeta(systemProgram, false, false), - AccountMeta(ataProgram, false, false), - AccountMeta(rent, false, false) - ), - Borsh.encodeToByteArray( - Args_auctioneerWithdraw.serializer(), - Args_auctioneerWithdraw(escrowPaymentBump, amount) - ) - ) + TransactionInstruction(PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), + listOf(AccountMeta(wallet, false, false), AccountMeta(receiptAccount, false, true), + AccountMeta(escrowPaymentAccount, false, true), AccountMeta(treasuryMint, false, false), + AccountMeta(authority, false, false), AccountMeta(auctioneerAuthority, true, false), + AccountMeta(auctionHouse, false, false), AccountMeta(auctionHouseFeeAccount, false, + true), AccountMeta(ahAuctioneerPda, false, false), AccountMeta(tokenProgram, false, + false), AccountMeta(systemProgram, false, false), AccountMeta(ataProgram, false, false), + AccountMeta(rent, false, false)), + Borsh.encodeToByteArray(AnchorInstructionSerializer("auctioneer_withdraw"), + Args_auctioneerWithdraw(escrowPaymentBump, amount))) fun closeEscrowAccount( wallet: PublicKey, @@ -969,17 +647,11 @@ object AuctionHouseInstructions { systemProgram: PublicKey, escrowPaymentBump: UByte ): TransactionInstruction = - TransactionInstruction( - PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), - listOf( - AccountMeta(wallet, true, false), AccountMeta(escrowPaymentAccount, false, true), - AccountMeta(auctionHouse, false, false), AccountMeta(systemProgram, false, false) - ), - Borsh.encodeToByteArray( - Args_closeEscrowAccount.serializer(), - Args_closeEscrowAccount(escrowPaymentBump) - ) - ) + TransactionInstruction(PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), + listOf(AccountMeta(wallet, true, false), AccountMeta(escrowPaymentAccount, false, true), + AccountMeta(auctionHouse, false, false), AccountMeta(systemProgram, false, false)), + Borsh.encodeToByteArray(AnchorInstructionSerializer("close_escrow_account"), + Args_closeEscrowAccount(escrowPaymentBump))) fun delegateAuctioneer( auctionHouse: PublicKey, @@ -989,20 +661,12 @@ object AuctionHouseInstructions { systemProgram: PublicKey, scopes: List ): TransactionInstruction = - TransactionInstruction( - PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), - listOf( - AccountMeta(auctionHouse, false, true), AccountMeta(authority, true, true), - AccountMeta(auctioneerAuthority, false, false), AccountMeta( - ahAuctioneerPda, false, - true - ), AccountMeta(systemProgram, false, false) - ), - Borsh.encodeToByteArray( - Args_delegateAuctioneer.serializer(), - Args_delegateAuctioneer(scopes) - ) - ) + TransactionInstruction(PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), + listOf(AccountMeta(auctionHouse, false, true), AccountMeta(authority, true, true), + AccountMeta(auctioneerAuthority, false, false), AccountMeta(ahAuctioneerPda, false, + true), AccountMeta(systemProgram, false, false)), + Borsh.encodeToByteArray(AnchorInstructionSerializer("delegate_auctioneer"), + Args_delegateAuctioneer(scopes))) fun updateAuctioneer( auctionHouse: PublicKey, @@ -1012,20 +676,12 @@ object AuctionHouseInstructions { systemProgram: PublicKey, scopes: List ): TransactionInstruction = - TransactionInstruction( - PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), - listOf( - AccountMeta(auctionHouse, false, true), AccountMeta(authority, true, true), - AccountMeta(auctioneerAuthority, false, false), AccountMeta( - ahAuctioneerPda, false, - true - ), AccountMeta(systemProgram, false, false) - ), - Borsh.encodeToByteArray( - Args_updateAuctioneer.serializer(), - Args_updateAuctioneer(scopes) - ) - ) + TransactionInstruction(PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), + listOf(AccountMeta(auctionHouse, false, true), AccountMeta(authority, true, true), + AccountMeta(auctioneerAuthority, false, false), AccountMeta(ahAuctioneerPda, false, + true), AccountMeta(systemProgram, false, false)), + Borsh.encodeToByteArray(AnchorInstructionSerializer("update_auctioneer"), + Args_updateAuctioneer(scopes))) fun printListingReceipt( receipt: PublicKey, @@ -1035,35 +691,23 @@ object AuctionHouseInstructions { instruction: PublicKey, receiptBump: UByte ): TransactionInstruction = - TransactionInstruction( - PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), - listOf( - AccountMeta(receipt, false, true), AccountMeta(bookkeeper, true, true), - AccountMeta(systemProgram, false, false), AccountMeta(rent, false, false), - AccountMeta(instruction, false, false) - ), - Borsh.encodeToByteArray( - Args_printListingReceipt.serializer(), - Args_printListingReceipt(receiptBump) - ) - ) + TransactionInstruction(PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), + listOf(AccountMeta(receipt, false, true), AccountMeta(bookkeeper, true, true), + AccountMeta(systemProgram, false, false), AccountMeta(rent, false, false), + AccountMeta(instruction, false, false)), + Borsh.encodeToByteArray(AnchorInstructionSerializer("print_listing_receipt"), + Args_printListingReceipt(receiptBump))) fun cancelListingReceipt( receipt: PublicKey, systemProgram: PublicKey, instruction: PublicKey ): TransactionInstruction = - TransactionInstruction( - PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), - listOf( - AccountMeta(receipt, false, true), AccountMeta(systemProgram, false, false), - AccountMeta(instruction, false, false) - ), - Borsh.encodeToByteArray( - Args_cancelListingReceipt.serializer(), - Args_cancelListingReceipt() - ) - ) + TransactionInstruction(PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), + listOf(AccountMeta(receipt, false, true), AccountMeta(systemProgram, false, false), + AccountMeta(instruction, false, false)), + Borsh.encodeToByteArray(AnchorInstructionSerializer("cancel_listing_receipt"), + Args_cancelListingReceipt())) fun printBidReceipt( receipt: PublicKey, @@ -1073,32 +717,23 @@ object AuctionHouseInstructions { instruction: PublicKey, receiptBump: UByte ): TransactionInstruction = - TransactionInstruction( - PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), - listOf( - AccountMeta(receipt, false, true), AccountMeta(bookkeeper, true, true), - AccountMeta(systemProgram, false, false), AccountMeta(rent, false, false), - AccountMeta(instruction, false, false) - ), - Borsh.encodeToByteArray( - Args_printBidReceipt.serializer(), - Args_printBidReceipt(receiptBump) - ) - ) + TransactionInstruction(PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), + listOf(AccountMeta(receipt, false, true), AccountMeta(bookkeeper, true, true), + AccountMeta(systemProgram, false, false), AccountMeta(rent, false, false), + AccountMeta(instruction, false, false)), + Borsh.encodeToByteArray(AnchorInstructionSerializer("print_bid_receipt"), + Args_printBidReceipt(receiptBump))) fun cancelBidReceipt( receipt: PublicKey, systemProgram: PublicKey, instruction: PublicKey ): TransactionInstruction = - TransactionInstruction( - PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), - listOf( - AccountMeta(receipt, false, true), AccountMeta(systemProgram, false, false), - AccountMeta(instruction, false, false) - ), - Borsh.encodeToByteArray(Args_cancelBidReceipt.serializer(), Args_cancelBidReceipt()) - ) + TransactionInstruction(PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), + listOf(AccountMeta(receipt, false, true), AccountMeta(systemProgram, false, false), + AccountMeta(instruction, false, false)), + Borsh.encodeToByteArray(AnchorInstructionSerializer("cancel_bid_receipt"), + Args_cancelBidReceipt())) fun printPurchaseReceipt( purchaseReceipt: PublicKey, @@ -1110,21 +745,13 @@ object AuctionHouseInstructions { instruction: PublicKey, purchaseReceiptBump: UByte ): TransactionInstruction = - TransactionInstruction( - PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), - listOf( - AccountMeta(purchaseReceipt, false, true), AccountMeta( - listingReceipt, false, - true - ), AccountMeta(bidReceipt, false, true), AccountMeta(bookkeeper, true, true), - AccountMeta(systemProgram, false, false), AccountMeta(rent, false, false), - AccountMeta(instruction, false, false) - ), - Borsh.encodeToByteArray( - Args_printPurchaseReceipt.serializer(), - Args_printPurchaseReceipt(purchaseReceiptBump) - ) - ) + TransactionInstruction(PublicKey("hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk"), + listOf(AccountMeta(purchaseReceipt, false, true), AccountMeta(listingReceipt, false, + true), AccountMeta(bidReceipt, false, true), AccountMeta(bookkeeper, true, true), + AccountMeta(systemProgram, false, false), AccountMeta(rent, false, false), + AccountMeta(instruction, false, false)), + Borsh.encodeToByteArray(AnchorInstructionSerializer("print_purchase_receipt"), + Args_printPurchaseReceipt(purchaseReceiptBump))) @Serializable class Args_withdrawFromFee(val amount: ULong) @@ -1269,13 +896,13 @@ object AuctionHouseInstructions { class Args_printListingReceipt(val receiptBump: UByte) @Serializable - class Args_cancelListingReceipt + class Args_cancelListingReceipt() @Serializable class Args_printBidReceipt(val receiptBump: UByte) @Serializable - class Args_cancelBidReceipt + class Args_cancelBidReceipt() @Serializable class Args_printPurchaseReceipt(val purchaseReceiptBump: UByte) diff --git a/lib/src/main/java/com/metaplex/lib/experimental/jen/auctionhouse/Types.kt b/lib/src/main/java/com/metaplex/lib/experimental/jen/auctionhouse/Types.kt index 201ddf5..87571a6 100644 --- a/lib/src/main/java/com/metaplex/lib/experimental/jen/auctionhouse/Types.kt +++ b/lib/src/main/java/com/metaplex/lib/experimental/jen/auctionhouse/Types.kt @@ -2,10 +2,15 @@ // Types // Metaplex // -// This code was generated locally by Funkatronics on 2022-08-11 +// This code was generated locally by Funkatronics on 2022-10-20 // +@file:UseSerializers(PublicKeyAs32ByteSerializer::class) + package com.metaplex.lib.experimental.jen.auctionhouse +import com.metaplex.lib.serialization.serializers.solana.PublicKeyAs32ByteSerializer +import kotlinx.serialization.UseSerializers + enum class AuthorityScope { Deposit, diff --git a/lib/src/main/java/com/metaplex/lib/experimental/jen/auctionhouse/idl.kt b/lib/src/main/java/com/metaplex/lib/experimental/jen/auctionhouse/idl.kt index be77e1a..d6461cd 100644 --- a/lib/src/main/java/com/metaplex/lib/experimental/jen/auctionhouse/idl.kt +++ b/lib/src/main/java/com/metaplex/lib/experimental/jen/auctionhouse/idl.kt @@ -12,2696 +12,6039 @@ import org.intellij.lang.annotations.Language // holding the json here for now becasue lazy @Language("json") val auctionHouseJson = """ + { + "version": "1.3.1", + "name": "auction_house", + "instructions": [ { - "version": "1.2.4", - "name": "auction_house", - "instructions": [ - { - "name": "withdrawFromFee", - "accounts": [ - { - "name": "authority", - "isMut": false, - "isSigner": true - }, - { - "name": "feeWithdrawalDestination", - "isMut": true, - "isSigner": false - }, - { - "name": "auctionHouseFeeAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "auctionHouse", - "isMut": true, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "withdrawFromTreasury", - "accounts": [ - { - "name": "treasuryMint", - "isMut": false, - "isSigner": false - }, - { - "name": "authority", - "isMut": false, - "isSigner": true - }, - { - "name": "treasuryWithdrawalDestination", - "isMut": true, - "isSigner": false - }, - { - "name": "auctionHouseTreasury", - "isMut": true, - "isSigner": false - }, - { - "name": "auctionHouse", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "updateAuctionHouse", - "accounts": [ - { - "name": "treasuryMint", - "isMut": false, - "isSigner": false - }, - { - "name": "payer", - "isMut": false, - "isSigner": true - }, - { - "name": "authority", - "isMut": false, - "isSigner": true - }, - { - "name": "newAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "feeWithdrawalDestination", - "isMut": true, - "isSigner": false - }, - { - "name": "treasuryWithdrawalDestination", - "isMut": true, - "isSigner": false - }, - { - "name": "treasuryWithdrawalDestinationOwner", - "isMut": false, - "isSigner": false - }, - { - "name": "auctionHouse", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "ataProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "sellerFeeBasisPoints", - "type": { - "option": "u16" + "name": "withdrawFromFee", + "docs": [ + "Withdraw `amount` from the Auction House Fee Account to a provided destination account." + ], + "accounts": [ + { + "name": "authority", + "isMut": false, + "isSigner": true, + "docs": [ + "Authority key for the Auction House." + ] + }, + { + "name": "feeWithdrawalDestination", + "isMut": true, + "isSigner": false, + "docs": [ + "Account that pays for fees if the marketplace executes sales." + ] + }, + { + "name": "auctionHouseFeeAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "Auction House instance fee account." + ] + }, + { + "name": "auctionHouse", + "isMut": true, + "isSigner": false, + "docs": [ + "Auction House instance PDA account." + ] + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false } - }, - { - "name": "requiresSignOff", - "type": { - "option": "bool" + ], + "args": [ + { + "name": "amount", + "type": "u64" } - }, - { - "name": "canChangeSalePrice", - "type": { - "option": "bool" + ] + }, + { + "name": "withdrawFromTreasury", + "docs": [ + "Withdraw `amount` from the Auction House Treasury Account to a provided destination account." + ], + "accounts": [ + { + "name": "treasuryMint", + "isMut": false, + "isSigner": false, + "docs": [ + "Treasury mint account, either native SOL mint or a SPL token mint." + ] + }, + { + "name": "authority", + "isMut": false, + "isSigner": true, + "docs": [ + "Authority key for the Auction House." + ] + }, + { + "name": "treasuryWithdrawalDestination", + "isMut": true, + "isSigner": false, + "docs": [ + "SOL or SPL token account to receive Auction House fees. If treasury mint is native this will be the same as the `treasury_withdrawl_destination_owner`." + ] + }, + { + "name": "auctionHouseTreasury", + "isMut": true, + "isSigner": false, + "docs": [ + "Auction House treasury PDA account." + ] + }, + { + "name": "auctionHouse", + "isMut": true, + "isSigner": false, + "docs": [ + "Auction House instance PDA account." + ] + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false } - } - ] - }, - { - "name": "createAuctionHouse", - "accounts": [ - { - "name": "treasuryMint", - "isMut": false, - "isSigner": false - }, - { - "name": "payer", - "isMut": true, - "isSigner": true - }, - { - "name": "authority", - "isMut": false, - "isSigner": false - }, - { - "name": "feeWithdrawalDestination", - "isMut": true, - "isSigner": false - }, - { - "name": "treasuryWithdrawalDestination", - "isMut": true, - "isSigner": false - }, - { - "name": "treasuryWithdrawalDestinationOwner", - "isMut": false, - "isSigner": false - }, - { - "name": "auctionHouse", - "isMut": true, - "isSigner": false - }, - { - "name": "auctionHouseFeeAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "auctionHouseTreasury", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "ataProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "bump", - "type": "u8" - }, - { - "name": "feePayerBump", - "type": "u8" - }, - { - "name": "treasuryBump", - "type": "u8" - }, - { - "name": "sellerFeeBasisPoints", - "type": "u16" - }, - { - "name": "requiresSignOff", - "type": "bool" - }, - { - "name": "canChangeSalePrice", - "type": "bool" - } - ] - }, - { - "name": "buy", - "accounts": [ - { - "name": "wallet", - "isMut": false, - "isSigner": true - }, - { - "name": "paymentAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "transferAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "treasuryMint", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenAccount", - "isMut": false, - "isSigner": false - }, - { - "name": "metadata", - "isMut": false, - "isSigner": false - }, - { - "name": "escrowPaymentAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "authority", - "isMut": false, - "isSigner": false - }, - { - "name": "auctionHouse", - "isMut": false, - "isSigner": false - }, - { - "name": "auctionHouseFeeAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "buyerTradeState", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "tradeStateBump", - "type": "u8" - }, - { - "name": "escrowPaymentBump", - "type": "u8" - }, - { - "name": "buyerPrice", - "type": "u64" - }, - { - "name": "tokenSize", - "type": "u64" - } - ] - }, - { - "name": "auctioneerBuy", - "accounts": [ - { - "name": "wallet", - "isMut": false, - "isSigner": true - }, - { - "name": "paymentAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "transferAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "treasuryMint", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenAccount", - "isMut": false, - "isSigner": false - }, - { - "name": "metadata", - "isMut": false, - "isSigner": false - }, - { - "name": "escrowPaymentAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "authority", - "isMut": false, - "isSigner": false - }, - { - "name": "auctioneerAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "auctionHouse", - "isMut": false, - "isSigner": false - }, - { - "name": "auctionHouseFeeAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "buyerTradeState", - "isMut": true, - "isSigner": false - }, - { - "name": "ahAuctioneerPda", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "tradeStateBump", - "type": "u8" - }, - { - "name": "escrowPaymentBump", - "type": "u8" - }, - { - "name": "buyerPrice", - "type": "u64" - }, - { - "name": "tokenSize", - "type": "u64" - } - ] - }, - { - "name": "publicBuy", - "accounts": [ - { - "name": "wallet", - "isMut": false, - "isSigner": true - }, - { - "name": "paymentAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "transferAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "treasuryMint", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenAccount", - "isMut": false, - "isSigner": false - }, - { - "name": "metadata", - "isMut": false, - "isSigner": false - }, - { - "name": "escrowPaymentAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "authority", - "isMut": false, - "isSigner": false - }, - { - "name": "auctionHouse", - "isMut": false, - "isSigner": false - }, - { - "name": "auctionHouseFeeAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "buyerTradeState", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "tradeStateBump", - "type": "u8" - }, - { - "name": "escrowPaymentBump", - "type": "u8" - }, - { - "name": "buyerPrice", - "type": "u64" - }, - { - "name": "tokenSize", - "type": "u64" - } - ] - }, - { - "name": "auctioneerPublicBuy", - "accounts": [ - { - "name": "wallet", - "isMut": false, - "isSigner": true - }, - { - "name": "paymentAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "transferAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "treasuryMint", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenAccount", - "isMut": false, - "isSigner": false - }, - { - "name": "metadata", - "isMut": false, - "isSigner": false - }, - { - "name": "escrowPaymentAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "authority", - "isMut": false, - "isSigner": false - }, - { - "name": "auctioneerAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "auctionHouse", - "isMut": false, - "isSigner": false - }, - { - "name": "auctionHouseFeeAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "buyerTradeState", - "isMut": true, - "isSigner": false - }, - { - "name": "ahAuctioneerPda", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "tradeStateBump", - "type": "u8" - }, - { - "name": "escrowPaymentBump", - "type": "u8" - }, - { - "name": "buyerPrice", - "type": "u64" - }, - { - "name": "tokenSize", - "type": "u64" - } - ] - }, - { - "name": "cancel", - "accounts": [ - { - "name": "wallet", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenMint", - "isMut": false, - "isSigner": false - }, - { - "name": "authority", - "isMut": false, - "isSigner": false - }, - { - "name": "auctionHouse", - "isMut": false, - "isSigner": false - }, - { - "name": "auctionHouseFeeAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "tradeState", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "buyerPrice", - "type": "u64" - }, - { - "name": "tokenSize", - "type": "u64" - } - ] - }, - { - "name": "auctioneerCancel", - "accounts": [ - { - "name": "wallet", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenMint", - "isMut": false, - "isSigner": false - }, - { - "name": "authority", - "isMut": false, - "isSigner": false - }, - { - "name": "auctioneerAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "auctionHouse", - "isMut": false, - "isSigner": false - }, - { - "name": "auctionHouseFeeAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "tradeState", - "isMut": true, - "isSigner": false - }, - { - "name": "ahAuctioneerPda", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "buyerPrice", - "type": "u64" - }, - { - "name": "tokenSize", - "type": "u64" - } - ] - }, - { - "name": "deposit", - "accounts": [ - { - "name": "wallet", - "isMut": false, - "isSigner": true - }, - { - "name": "paymentAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "transferAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "escrowPaymentAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "treasuryMint", - "isMut": false, - "isSigner": false - }, - { - "name": "authority", - "isMut": false, - "isSigner": false - }, - { - "name": "auctionHouse", - "isMut": false, - "isSigner": false - }, - { - "name": "auctionHouseFeeAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "escrowPaymentBump", - "type": "u8" - }, - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "auctioneerDeposit", - "accounts": [ - { - "name": "wallet", - "isMut": false, - "isSigner": true - }, - { - "name": "paymentAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "transferAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "escrowPaymentAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "treasuryMint", - "isMut": false, - "isSigner": false - }, - { - "name": "authority", - "isMut": false, - "isSigner": false - }, - { - "name": "auctioneerAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "auctionHouse", - "isMut": false, - "isSigner": false - }, - { - "name": "auctionHouseFeeAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "ahAuctioneerPda", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "escrowPaymentBump", - "type": "u8" - }, - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "executeSale", - "accounts": [ - { - "name": "buyer", - "isMut": true, - "isSigner": false - }, - { - "name": "seller", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenMint", - "isMut": false, - "isSigner": false - }, - { - "name": "metadata", - "isMut": false, - "isSigner": false - }, - { - "name": "treasuryMint", - "isMut": false, - "isSigner": false - }, - { - "name": "escrowPaymentAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "sellerPaymentReceiptAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "buyerReceiptTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "authority", - "isMut": false, - "isSigner": false - }, - { - "name": "auctionHouse", - "isMut": false, - "isSigner": false - }, - { - "name": "auctionHouseFeeAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "auctionHouseTreasury", - "isMut": true, - "isSigner": false - }, - { - "name": "buyerTradeState", - "isMut": true, - "isSigner": false - }, - { - "name": "sellerTradeState", - "isMut": true, - "isSigner": false - }, - { - "name": "freeTradeState", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "ataProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "programAsSigner", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "escrowPaymentBump", - "type": "u8" - }, - { - "name": "freeTradeStateBump", - "type": "u8" - }, - { - "name": "programAsSignerBump", - "type": "u8" - }, - { - "name": "buyerPrice", - "type": "u64" - }, - { - "name": "tokenSize", - "type": "u64" - } - ] - }, - { - "name": "executePartialSale", - "accounts": [ - { - "name": "buyer", - "isMut": true, - "isSigner": false - }, - { - "name": "seller", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenMint", - "isMut": false, - "isSigner": false - }, - { - "name": "metadata", - "isMut": false, - "isSigner": false - }, - { - "name": "treasuryMint", - "isMut": false, - "isSigner": false - }, - { - "name": "escrowPaymentAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "sellerPaymentReceiptAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "buyerReceiptTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "authority", - "isMut": false, - "isSigner": false - }, - { - "name": "auctionHouse", - "isMut": false, - "isSigner": false - }, - { - "name": "auctionHouseFeeAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "auctionHouseTreasury", - "isMut": true, - "isSigner": false - }, - { - "name": "buyerTradeState", - "isMut": true, - "isSigner": false - }, - { - "name": "sellerTradeState", - "isMut": true, - "isSigner": false - }, - { - "name": "freeTradeState", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "ataProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "programAsSigner", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "escrowPaymentBump", - "type": "u8" - }, - { - "name": "freeTradeStateBump", - "type": "u8" - }, - { - "name": "programAsSignerBump", - "type": "u8" - }, - { - "name": "buyerPrice", - "type": "u64" - }, - { - "name": "tokenSize", - "type": "u64" - }, - { - "name": "partialOrderSize", - "type": { - "option": "u64" + ], + "args": [ + { + "name": "amount", + "type": "u64" } - }, - { - "name": "partialOrderPrice", - "type": { - "option": "u64" + ] + }, + { + "name": "updateAuctionHouse", + "docs": [ + "Update Auction House values such as seller fee basis points, update authority, treasury account, etc." + ], + "accounts": [ + { + "name": "treasuryMint", + "isMut": false, + "isSigner": false, + "docs": [ + "Treasury mint account, either native SOL mint or a SPL token mint." + ] + }, + { + "name": "payer", + "isMut": false, + "isSigner": true, + "docs": [ + "Key paying SOL fees for setting up the Auction House." + ] + }, + { + "name": "authority", + "isMut": false, + "isSigner": true, + "docs": [ + "Authority key for the Auction House." + ] + }, + { + "name": "newAuthority", + "isMut": false, + "isSigner": false, + "docs": [ + "New authority key for the Auction House." + ] + }, + { + "name": "feeWithdrawalDestination", + "isMut": true, + "isSigner": false, + "docs": [ + "Account that pays for fees if the marketplace executes sales." + ] + }, + { + "name": "treasuryWithdrawalDestination", + "isMut": true, + "isSigner": false, + "docs": [ + "SOL or SPL token account to receive Auction House fees. If treasury mint is native this will be the same as the `treasury_withdrawl_destination_owner`." + ] + }, + { + "name": "treasuryWithdrawalDestinationOwner", + "isMut": false, + "isSigner": false, + "docs": [ + "Owner of the `treasury_withdrawal_destination` account or the same address if the `treasury_mint` is native." + ] + }, + { + "name": "auctionHouse", + "isMut": true, + "isSigner": false, + "docs": [ + "Auction House instance PDA account." + ] + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "ataProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "rent", + "isMut": false, + "isSigner": false } - } - ] - }, - { - "name": "auctioneerExecuteSale", - "accounts": [ - { - "name": "buyer", - "isMut": true, - "isSigner": false - }, - { - "name": "seller", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenMint", - "isMut": false, - "isSigner": false - }, - { - "name": "metadata", - "isMut": false, - "isSigner": false - }, - { - "name": "treasuryMint", - "isMut": false, - "isSigner": false - }, - { - "name": "escrowPaymentAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "sellerPaymentReceiptAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "buyerReceiptTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "authority", - "isMut": false, - "isSigner": false - }, - { - "name": "auctioneerAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "auctionHouse", - "isMut": false, - "isSigner": false - }, - { - "name": "auctionHouseFeeAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "auctionHouseTreasury", - "isMut": true, - "isSigner": false - }, - { - "name": "buyerTradeState", - "isMut": true, - "isSigner": false - }, - { - "name": "sellerTradeState", - "isMut": true, - "isSigner": false - }, - { - "name": "freeTradeState", - "isMut": true, - "isSigner": false - }, - { - "name": "ahAuctioneerPda", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "ataProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "programAsSigner", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "escrowPaymentBump", - "type": "u8" - }, - { - "name": "freeTradeStateBump", - "type": "u8" - }, - { - "name": "programAsSignerBump", - "type": "u8" - }, - { - "name": "buyerPrice", - "type": "u64" - }, - { - "name": "tokenSize", - "type": "u64" - } - ] - }, - { - "name": "auctioneerExecutePartialSale", - "accounts": [ - { - "name": "buyer", - "isMut": true, - "isSigner": false - }, - { - "name": "seller", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenMint", - "isMut": false, - "isSigner": false - }, - { - "name": "metadata", - "isMut": false, - "isSigner": false - }, - { - "name": "treasuryMint", - "isMut": false, - "isSigner": false - }, - { - "name": "escrowPaymentAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "sellerPaymentReceiptAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "buyerReceiptTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "authority", - "isMut": false, - "isSigner": false - }, - { - "name": "auctioneerAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "auctionHouse", - "isMut": false, - "isSigner": false - }, - { - "name": "auctionHouseFeeAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "auctionHouseTreasury", - "isMut": true, - "isSigner": false - }, - { - "name": "buyerTradeState", - "isMut": true, - "isSigner": false - }, - { - "name": "sellerTradeState", - "isMut": true, - "isSigner": false - }, - { - "name": "freeTradeState", - "isMut": true, - "isSigner": false - }, - { - "name": "ahAuctioneerPda", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "ataProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "programAsSigner", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "escrowPaymentBump", - "type": "u8" - }, - { - "name": "freeTradeStateBump", - "type": "u8" - }, - { - "name": "programAsSignerBump", - "type": "u8" - }, - { - "name": "buyerPrice", - "type": "u64" - }, - { - "name": "tokenSize", - "type": "u64" - }, - { - "name": "partialOrderSize", - "type": { - "option": "u64" + ], + "args": [ + { + "name": "sellerFeeBasisPoints", + "type": { + "option": "u16" + } + }, + { + "name": "requiresSignOff", + "type": { + "option": "bool" + } + }, + { + "name": "canChangeSalePrice", + "type": { + "option": "bool" + } + } + ] + }, + { + "name": "createAuctionHouse", + "docs": [ + "Create a new Auction House instance." + ], + "accounts": [ + { + "name": "treasuryMint", + "isMut": false, + "isSigner": false, + "docs": [ + "Treasury mint account, either native SOL mint or a SPL token mint." + ] + }, + { + "name": "payer", + "isMut": true, + "isSigner": true, + "docs": [ + "Key paying SOL fees for setting up the Auction House." + ] + }, + { + "name": "authority", + "isMut": false, + "isSigner": false + }, + { + "name": "feeWithdrawalDestination", + "isMut": true, + "isSigner": false, + "docs": [ + "Account that pays for fees if the marketplace executes sales." + ] + }, + { + "name": "treasuryWithdrawalDestination", + "isMut": true, + "isSigner": false, + "docs": [ + "SOL or SPL token account to receive Auction House fees. If treasury mint is native this will be the same as the `treasury_withdrawl_destination_owner`." + ] + }, + { + "name": "treasuryWithdrawalDestinationOwner", + "isMut": false, + "isSigner": false, + "docs": [ + "Owner of the `treasury_withdrawal_destination` account or the same address if the `treasury_mint` is native." + ] + }, + { + "name": "auctionHouse", + "isMut": true, + "isSigner": false, + "docs": [ + "Auction House instance PDA account." + ] + }, + { + "name": "auctionHouseFeeAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "Auction House instance fee account." + ] + }, + { + "name": "auctionHouseTreasury", + "isMut": true, + "isSigner": false, + "docs": [ + "Auction House instance treasury PDA account." + ] + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "ataProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "rent", + "isMut": false, + "isSigner": false } - }, - { - "name": "partialOrderPrice", - "type": { - "option": "u64" + ], + "args": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "feePayerBump", + "type": "u8" + }, + { + "name": "treasuryBump", + "type": "u8" + }, + { + "name": "sellerFeeBasisPoints", + "type": "u16" + }, + { + "name": "requiresSignOff", + "type": "bool" + }, + { + "name": "canChangeSalePrice", + "type": "bool" } - } - ] - }, - { - "name": "sell", - "accounts": [ - { - "name": "wallet", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "metadata", - "isMut": false, - "isSigner": false - }, - { - "name": "authority", - "isMut": false, - "isSigner": false - }, - { - "name": "auctionHouse", - "isMut": false, - "isSigner": false - }, - { - "name": "auctionHouseFeeAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "sellerTradeState", - "isMut": true, - "isSigner": false - }, - { - "name": "freeSellerTradeState", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "programAsSigner", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "tradeStateBump", - "type": "u8" - }, - { - "name": "freeTradeStateBump", - "type": "u8" - }, - { - "name": "programAsSignerBump", - "type": "u8" - }, - { - "name": "buyerPrice", - "type": "u64" - }, - { - "name": "tokenSize", - "type": "u64" - } - ] - }, - { - "name": "auctioneerSell", - "accounts": [ - { - "name": "wallet", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "metadata", - "isMut": false, - "isSigner": false - }, - { - "name": "authority", - "isMut": false, - "isSigner": false - }, - { - "name": "auctioneerAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "auctionHouse", - "isMut": false, - "isSigner": false - }, - { - "name": "auctionHouseFeeAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "sellerTradeState", - "isMut": true, - "isSigner": false - }, - { - "name": "freeSellerTradeState", - "isMut": true, - "isSigner": false - }, - { - "name": "ahAuctioneerPda", - "isMut": false, - "isSigner": false - }, - { - "name": "programAsSigner", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "tradeStateBump", - "type": "u8" - }, - { - "name": "freeTradeStateBump", - "type": "u8" - }, - { - "name": "programAsSignerBump", - "type": "u8" - }, - { - "name": "tokenSize", - "type": "u64" - } - ] - }, - { - "name": "withdraw", - "accounts": [ - { - "name": "wallet", - "isMut": false, - "isSigner": false - }, - { - "name": "receiptAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "escrowPaymentAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "treasuryMint", - "isMut": false, - "isSigner": false - }, - { - "name": "authority", - "isMut": false, - "isSigner": false - }, - { - "name": "auctionHouse", - "isMut": false, - "isSigner": false - }, - { - "name": "auctionHouseFeeAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "ataProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "escrowPaymentBump", - "type": "u8" - }, - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "auctioneerWithdraw", - "accounts": [ - { - "name": "wallet", - "isMut": false, - "isSigner": false - }, - { - "name": "receiptAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "escrowPaymentAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "treasuryMint", - "isMut": false, - "isSigner": false - }, - { - "name": "authority", - "isMut": false, - "isSigner": false - }, - { - "name": "auctioneerAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "auctionHouse", - "isMut": false, - "isSigner": false - }, - { - "name": "auctionHouseFeeAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "ahAuctioneerPda", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "ataProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "escrowPaymentBump", - "type": "u8" - }, - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "closeEscrowAccount", - "accounts": [ - { - "name": "wallet", - "isMut": false, - "isSigner": true - }, - { - "name": "escrowPaymentAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "auctionHouse", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "escrowPaymentBump", - "type": "u8" - } - ] - }, - { - "name": "delegateAuctioneer", - "accounts": [ - { - "name": "auctionHouse", - "isMut": true, - "isSigner": false - }, - { - "name": "authority", - "isMut": true, - "isSigner": true - }, - { - "name": "auctioneerAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "ahAuctioneerPda", - "isMut": true, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "scopes", - "type": { - "vec": { - "defined": "AuthorityScope" - } + ] + }, + { + "name": "buy", + "docs": [ + "Create a private buy bid by creating a `buyer_trade_state` account and an `escrow_payment` account and funding the escrow with the necessary SOL or SPL token amount." + ], + "accounts": [ + { + "name": "wallet", + "isMut": false, + "isSigner": true, + "docs": [ + "User wallet account." + ] + }, + { + "name": "paymentAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "User SOL or SPL account to transfer funds from." + ] + }, + { + "name": "transferAuthority", + "isMut": false, + "isSigner": false, + "docs": [ + "SPL token account transfer authority." + ] + }, + { + "name": "treasuryMint", + "isMut": false, + "isSigner": false, + "docs": [ + "Auction House instance treasury mint account." + ] + }, + { + "name": "tokenAccount", + "isMut": false, + "isSigner": false, + "docs": [ + "SPL token account." + ] + }, + { + "name": "metadata", + "isMut": false, + "isSigner": false, + "docs": [ + "SPL token account metadata." + ] + }, + { + "name": "escrowPaymentAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "Buyer escrow payment account PDA." + ] + }, + { + "name": "authority", + "isMut": false, + "isSigner": false, + "docs": [ + "Auction House instance authority account." + ] + }, + { + "name": "auctionHouse", + "isMut": false, + "isSigner": false, + "docs": [ + "Auction House instance PDA account." + ] + }, + { + "name": "auctionHouseFeeAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "Auction House instance fee account." + ] + }, + { + "name": "buyerTradeState", + "isMut": true, + "isSigner": false, + "docs": [ + "Buyer trade state PDA." + ] + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "rent", + "isMut": false, + "isSigner": false } - } - ] - }, - { - "name": "updateAuctioneer", - "accounts": [ - { - "name": "auctionHouse", - "isMut": true, - "isSigner": false - }, - { - "name": "authority", - "isMut": true, - "isSigner": true - }, - { - "name": "auctioneerAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "ahAuctioneerPda", - "isMut": true, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "scopes", - "type": { - "vec": { - "defined": "AuthorityScope" - } + ], + "args": [ + { + "name": "tradeStateBump", + "type": "u8" + }, + { + "name": "escrowPaymentBump", + "type": "u8" + }, + { + "name": "buyerPrice", + "type": "u64" + }, + { + "name": "tokenSize", + "type": "u64" } - } - ] - }, - { - "name": "printListingReceipt", - "accounts": [ - { - "name": "receipt", - "isMut": true, - "isSigner": false - }, - { - "name": "bookkeeper", - "isMut": true, - "isSigner": true - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - }, - { - "name": "instruction", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "receiptBump", - "type": "u8" - } - ] - }, - { - "name": "cancelListingReceipt", - "accounts": [ - { - "name": "receipt", - "isMut": true, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "instruction", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "printBidReceipt", - "accounts": [ - { - "name": "receipt", - "isMut": true, - "isSigner": false - }, - { - "name": "bookkeeper", - "isMut": true, - "isSigner": true - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - }, - { - "name": "instruction", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "receiptBump", - "type": "u8" - } - ] - }, - { - "name": "cancelBidReceipt", - "accounts": [ - { - "name": "receipt", - "isMut": true, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "instruction", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "printPurchaseReceipt", - "accounts": [ - { - "name": "purchaseReceipt", - "isMut": true, - "isSigner": false - }, - { - "name": "listingReceipt", - "isMut": true, - "isSigner": false - }, - { - "name": "bidReceipt", - "isMut": true, - "isSigner": false - }, - { - "name": "bookkeeper", - "isMut": true, - "isSigner": true - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - }, - { - "name": "instruction", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "purchaseReceiptBump", - "type": "u8" - } - ] - } - ], - "accounts": [ - { - "name": "BidReceipt", - "type": { - "kind": "struct", - "fields": [ + ] + }, + { + "name": "auctioneerBuy", + "accounts": [ + { + "name": "wallet", + "isMut": false, + "isSigner": true, + "docs": [ + "User wallet account." + ] + }, + { + "name": "paymentAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "User SOL or SPL account to transfer funds from." + ] + }, + { + "name": "transferAuthority", + "isMut": false, + "isSigner": false, + "docs": [ + "SPL token account transfer authority." + ] + }, + { + "name": "treasuryMint", + "isMut": false, + "isSigner": false, + "docs": [ + "Auction House instance treasury mint account." + ] + }, + { + "name": "tokenAccount", + "isMut": false, + "isSigner": false, + "docs": [ + "SPL token account." + ] + }, + { + "name": "metadata", + "isMut": false, + "isSigner": false, + "docs": [ + "SPL token account metadata." + ] + }, + { + "name": "escrowPaymentAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "Buyer escrow payment account PDA." + ] + }, + { + "name": "authority", + "isMut": false, + "isSigner": false + }, + { + "name": "auctioneerAuthority", + "isMut": false, + "isSigner": true, + "docs": [ + "The auctioneer authority - typically a PDA of the Auctioneer program running this action." + ] + }, + { + "name": "auctionHouse", + "isMut": false, + "isSigner": false, + "docs": [ + "Auction House instance PDA account." + ] + }, + { + "name": "auctionHouseFeeAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "Auction House instance fee account." + ] + }, + { + "name": "buyerTradeState", + "isMut": true, + "isSigner": false, + "docs": [ + "Buyer trade state PDA." + ] + }, + { + "name": "ahAuctioneerPda", + "isMut": false, + "isSigner": false + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "rent", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "tradeStateBump", + "type": "u8" + }, + { + "name": "escrowPaymentBump", + "type": "u8" + }, + { + "name": "buyerPrice", + "type": "u64" + }, + { + "name": "tokenSize", + "type": "u64" + } + ] + }, + { + "name": "publicBuy", + "docs": [ + "Create a public buy bid by creating a `public_buyer_trade_state` account and an `escrow_payment` account and funding the escrow with the necessary SOL or SPL token amount." + ], + "accounts": [ + { + "name": "wallet", + "isMut": false, + "isSigner": true + }, + { + "name": "paymentAccount", + "isMut": true, + "isSigner": false + }, + { + "name": "transferAuthority", + "isMut": false, + "isSigner": false + }, + { + "name": "treasuryMint", + "isMut": false, + "isSigner": false + }, + { + "name": "tokenAccount", + "isMut": false, + "isSigner": false + }, + { + "name": "metadata", + "isMut": false, + "isSigner": false + }, + { + "name": "escrowPaymentAccount", + "isMut": true, + "isSigner": false + }, + { + "name": "authority", + "isMut": false, + "isSigner": false + }, + { + "name": "auctionHouse", + "isMut": false, + "isSigner": false + }, + { + "name": "auctionHouseFeeAccount", + "isMut": true, + "isSigner": false + }, + { + "name": "buyerTradeState", + "isMut": true, + "isSigner": false + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "rent", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "tradeStateBump", + "type": "u8" + }, + { + "name": "escrowPaymentBump", + "type": "u8" + }, + { + "name": "buyerPrice", + "type": "u64" + }, + { + "name": "tokenSize", + "type": "u64" + } + ] + }, + { + "name": "auctioneerPublicBuy", + "docs": [ + "Create a public buy bid by creating a `public_buyer_trade_state` account and an `escrow_payment` account and funding the escrow with the necessary SOL or SPL token amount." + ], + "accounts": [ + { + "name": "wallet", + "isMut": false, + "isSigner": true + }, + { + "name": "paymentAccount", + "isMut": true, + "isSigner": false + }, + { + "name": "transferAuthority", + "isMut": false, + "isSigner": false + }, + { + "name": "treasuryMint", + "isMut": false, + "isSigner": false + }, + { + "name": "tokenAccount", + "isMut": false, + "isSigner": false + }, + { + "name": "metadata", + "isMut": false, + "isSigner": false + }, + { + "name": "escrowPaymentAccount", + "isMut": true, + "isSigner": false + }, + { + "name": "authority", + "isMut": false, + "isSigner": false + }, + { + "name": "auctioneerAuthority", + "isMut": false, + "isSigner": true, + "docs": [ + "The auctioneer authority - typically a PDA of the Auctioneer program running this action." + ] + }, + { + "name": "auctionHouse", + "isMut": false, + "isSigner": false + }, + { + "name": "auctionHouseFeeAccount", + "isMut": true, + "isSigner": false + }, + { + "name": "buyerTradeState", + "isMut": true, + "isSigner": false + }, + { + "name": "ahAuctioneerPda", + "isMut": false, + "isSigner": false, + "docs": [ + "The auctioneer PDA owned by Auction House storing scopes." + ] + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "rent", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "tradeStateBump", + "type": "u8" + }, + { + "name": "escrowPaymentBump", + "type": "u8" + }, + { + "name": "buyerPrice", + "type": "u64" + }, + { + "name": "tokenSize", + "type": "u64" + } + ] + }, + { + "name": "cancel", + "docs": [ + "Cancel a bid or ask by revoking the token delegate, transferring all lamports from the trade state account to the fee payer, and setting the trade state account data to zero so it can be garbage collected." + ], + "accounts": [ + { + "name": "wallet", + "isMut": true, + "isSigner": false, + "docs": [ + "User wallet account." + ] + }, + { + "name": "tokenAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "SPL token account containing the token of the sale to be canceled." + ] + }, + { + "name": "tokenMint", + "isMut": false, + "isSigner": false, + "docs": [ + "Token mint account of SPL token." + ] + }, + { + "name": "authority", + "isMut": false, + "isSigner": false, + "docs": [ + "Auction House instance authority account." + ] + }, + { + "name": "auctionHouse", + "isMut": false, + "isSigner": false, + "docs": [ + "Auction House instance PDA account." + ] + }, + { + "name": "auctionHouseFeeAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "Auction House instance fee account." + ] + }, + { + "name": "tradeState", + "isMut": true, + "isSigner": false, + "docs": [ + "Trade state PDA account representing the bid or ask to be canceled." + ] + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "buyerPrice", + "type": "u64" + }, + { + "name": "tokenSize", + "type": "u64" + } + ] + }, + { + "name": "auctioneerCancel", + "docs": [ + "Cancel, but with an auctioneer" + ], + "accounts": [ + { + "name": "wallet", + "isMut": true, + "isSigner": false, + "docs": [ + "User wallet account." + ] + }, + { + "name": "tokenAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "SPL token account containing the token of the sale to be canceled." + ] + }, + { + "name": "tokenMint", + "isMut": false, + "isSigner": false, + "docs": [ + "Token mint account of SPL token." + ] + }, + { + "name": "authority", + "isMut": false, + "isSigner": false, + "docs": [ + "Auction House instance authority account." + ] + }, + { + "name": "auctioneerAuthority", + "isMut": false, + "isSigner": true, + "docs": [ + "The auctioneer authority - typically a PDA of the Auctioneer program running this action." + ] + }, + { + "name": "auctionHouse", + "isMut": false, + "isSigner": false, + "docs": [ + "Auction House instance PDA account." + ] + }, + { + "name": "auctionHouseFeeAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "Auction House instance fee account." + ] + }, + { + "name": "tradeState", + "isMut": true, + "isSigner": false, + "docs": [ + "Trade state PDA account representing the bid or ask to be canceled." + ] + }, + { + "name": "ahAuctioneerPda", + "isMut": false, + "isSigner": false, + "docs": [ + "The auctioneer PDA owned by Auction House storing scopes." + ] + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "buyerPrice", + "type": "u64" + }, + { + "name": "tokenSize", + "type": "u64" + } + ] + }, + { + "name": "deposit", + "docs": [ + "Deposit `amount` into the escrow payment account for your specific wallet." + ], + "accounts": [ + { + "name": "wallet", + "isMut": false, + "isSigner": true, + "docs": [ + "User wallet account." + ] + }, + { + "name": "paymentAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "User SOL or SPL account to transfer funds from." + ] + }, + { + "name": "transferAuthority", + "isMut": false, + "isSigner": false, + "docs": [ + "SPL token account transfer authority." + ] + }, + { + "name": "escrowPaymentAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "Buyer escrow payment account PDA." + ] + }, + { + "name": "treasuryMint", + "isMut": false, + "isSigner": false, + "docs": [ + "Auction House instance treasury mint account." + ] + }, + { + "name": "authority", + "isMut": false, + "isSigner": false, + "docs": [ + "Auction House instance authority account." + ] + }, + { + "name": "auctionHouse", + "isMut": false, + "isSigner": false, + "docs": [ + "Auction House instance PDA account." + ] + }, + { + "name": "auctionHouseFeeAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "Auction House instance fee account." + ] + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "rent", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "escrowPaymentBump", + "type": "u8" + }, + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "auctioneerDeposit", + "docs": [ + "Deposit `amount` into the escrow payment account for your specific wallet." + ], + "accounts": [ + { + "name": "wallet", + "isMut": false, + "isSigner": true, + "docs": [ + "User wallet account." + ] + }, + { + "name": "paymentAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "User SOL or SPL account to transfer funds from." + ] + }, + { + "name": "transferAuthority", + "isMut": false, + "isSigner": false, + "docs": [ + "SPL token account transfer authority." + ] + }, + { + "name": "escrowPaymentAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "Buyer escrow payment account PDA." + ] + }, + { + "name": "treasuryMint", + "isMut": false, + "isSigner": false, + "docs": [ + "Auction House instance treasury mint account." + ] + }, + { + "name": "authority", + "isMut": false, + "isSigner": false, + "docs": [ + "Auction House instance authority account." + ] + }, + { + "name": "auctioneerAuthority", + "isMut": false, + "isSigner": true, + "docs": [ + "The auctioneer authority - typically a PDA of the Auctioneer program running this action." + ] + }, + { + "name": "auctionHouse", + "isMut": false, + "isSigner": false, + "docs": [ + "Auction House instance PDA account." + ] + }, + { + "name": "auctionHouseFeeAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "Auction House instance fee account." + ] + }, + { + "name": "ahAuctioneerPda", + "isMut": false, + "isSigner": false, + "docs": [ + "The auctioneer PDA owned by Auction House storing scopes." + ] + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "rent", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "escrowPaymentBump", + "type": "u8" + }, + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "executeSale", + "accounts": [ + { + "name": "buyer", + "isMut": true, + "isSigner": false, + "docs": [ + "Buyer user wallet account." + ] + }, + { + "name": "seller", + "isMut": true, + "isSigner": false, + "docs": [ + "Seller user wallet account." + ] + }, + { + "name": "tokenAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "Token account where the SPL token is stored." + ] + }, + { + "name": "tokenMint", + "isMut": false, + "isSigner": false, + "docs": [ + "Token mint account for the SPL token." + ] + }, + { + "name": "metadata", + "isMut": false, + "isSigner": false, + "docs": [ + "Metaplex metadata account decorating SPL mint account." + ] + }, + { + "name": "treasuryMint", + "isMut": false, + "isSigner": false, + "docs": [ + "Auction House treasury mint account." + ] + }, + { + "name": "escrowPaymentAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "Buyer escrow payment account." + ] + }, + { + "name": "sellerPaymentReceiptAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "Seller SOL or SPL account to receive payment at." + ] + }, + { + "name": "buyerReceiptTokenAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "Buyer SPL token account to receive purchased item at." + ] + }, + { + "name": "authority", + "isMut": false, + "isSigner": false, + "docs": [ + "Auction House instance authority." + ] + }, + { + "name": "auctionHouse", + "isMut": false, + "isSigner": false, + "docs": [ + "Auction House instance PDA account." + ] + }, + { + "name": "auctionHouseFeeAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "Auction House instance fee account." + ] + }, + { + "name": "auctionHouseTreasury", + "isMut": true, + "isSigner": false, + "docs": [ + "Auction House instance treasury account." + ] + }, + { + "name": "buyerTradeState", + "isMut": true, + "isSigner": false, + "docs": [ + "Buyer trade state PDA account encoding the buy order." + ] + }, + { + "name": "sellerTradeState", + "isMut": true, + "isSigner": false, + "docs": [ + "Seller trade state PDA account encoding the sell order." + ] + }, + { + "name": "freeTradeState", + "isMut": true, + "isSigner": false, + "docs": [ + "Free seller trade state PDA account encoding a free sell order." + ] + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "ataProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "programAsSigner", + "isMut": false, + "isSigner": false + }, + { + "name": "rent", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "escrowPaymentBump", + "type": "u8" + }, + { + "name": "freeTradeStateBump", + "type": "u8" + }, + { + "name": "programAsSignerBump", + "type": "u8" + }, + { + "name": "buyerPrice", + "type": "u64" + }, + { + "name": "tokenSize", + "type": "u64" + } + ] + }, + { + "name": "executePartialSale", + "accounts": [ + { + "name": "buyer", + "isMut": true, + "isSigner": false, + "docs": [ + "Buyer user wallet account." + ] + }, + { + "name": "seller", + "isMut": true, + "isSigner": false, + "docs": [ + "Seller user wallet account." + ] + }, + { + "name": "tokenAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "Token account where the SPL token is stored." + ] + }, + { + "name": "tokenMint", + "isMut": false, + "isSigner": false, + "docs": [ + "Token mint account for the SPL token." + ] + }, + { + "name": "metadata", + "isMut": false, + "isSigner": false, + "docs": [ + "Metaplex metadata account decorating SPL mint account." + ] + }, + { + "name": "treasuryMint", + "isMut": false, + "isSigner": false, + "docs": [ + "Auction House treasury mint account." + ] + }, + { + "name": "escrowPaymentAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "Buyer escrow payment account." + ] + }, + { + "name": "sellerPaymentReceiptAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "Seller SOL or SPL account to receive payment at." + ] + }, + { + "name": "buyerReceiptTokenAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "Buyer SPL token account to receive purchased item at." + ] + }, + { + "name": "authority", + "isMut": false, + "isSigner": false, + "docs": [ + "Auction House instance authority." + ] + }, + { + "name": "auctionHouse", + "isMut": false, + "isSigner": false, + "docs": [ + "Auction House instance PDA account." + ] + }, + { + "name": "auctionHouseFeeAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "Auction House instance fee account." + ] + }, + { + "name": "auctionHouseTreasury", + "isMut": true, + "isSigner": false, + "docs": [ + "Auction House instance treasury account." + ] + }, + { + "name": "buyerTradeState", + "isMut": true, + "isSigner": false, + "docs": [ + "Buyer trade state PDA account encoding the buy order." + ] + }, + { + "name": "sellerTradeState", + "isMut": true, + "isSigner": false, + "docs": [ + "Seller trade state PDA account encoding the sell order." + ] + }, + { + "name": "freeTradeState", + "isMut": true, + "isSigner": false, + "docs": [ + "Free seller trade state PDA account encoding a free sell order." + ] + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "ataProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "programAsSigner", + "isMut": false, + "isSigner": false + }, + { + "name": "rent", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "escrowPaymentBump", + "type": "u8" + }, + { + "name": "freeTradeStateBump", + "type": "u8" + }, + { + "name": "programAsSignerBump", + "type": "u8" + }, + { + "name": "buyerPrice", + "type": "u64" + }, + { + "name": "tokenSize", + "type": "u64" + }, + { + "name": "partialOrderSize", + "type": { + "option": "u64" + } + }, + { + "name": "partialOrderPrice", + "type": { + "option": "u64" + } + } + ] + }, + { + "name": "auctioneerExecuteSale", + "accounts": [ + { + "name": "buyer", + "isMut": true, + "isSigner": false, + "docs": [ + "Buyer user wallet account." + ] + }, + { + "name": "seller", + "isMut": true, + "isSigner": false, + "docs": [ + "Seller user wallet account." + ] + }, + { + "name": "tokenAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "Token account where the SPL token is stored." + ] + }, + { + "name": "tokenMint", + "isMut": false, + "isSigner": false, + "docs": [ + "Token mint account for the SPL token." + ] + }, + { + "name": "metadata", + "isMut": false, + "isSigner": false, + "docs": [ + "Metaplex metadata account decorating SPL mint account." + ] + }, + { + "name": "treasuryMint", + "isMut": false, + "isSigner": false, + "docs": [ + "Auction House treasury mint account." + ] + }, + { + "name": "escrowPaymentAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "Buyer escrow payment account." + ] + }, + { + "name": "sellerPaymentReceiptAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "Seller SOL or SPL account to receive payment at." + ] + }, + { + "name": "buyerReceiptTokenAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "Buyer SPL token account to receive purchased item at." + ] + }, + { + "name": "authority", + "isMut": false, + "isSigner": false, + "docs": [ + "Auction House instance authority." + ] + }, + { + "name": "auctioneerAuthority", + "isMut": false, + "isSigner": true, + "docs": [ + "The auctioneer authority - typically a PDA of the Auctioneer program running this action." + ] + }, + { + "name": "auctionHouse", + "isMut": false, + "isSigner": false, + "docs": [ + "Auction House instance PDA account." + ] + }, + { + "name": "auctionHouseFeeAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "Auction House instance fee account." + ] + }, + { + "name": "auctionHouseTreasury", + "isMut": true, + "isSigner": false, + "docs": [ + "Auction House instance treasury account." + ] + }, + { + "name": "buyerTradeState", + "isMut": true, + "isSigner": false, + "docs": [ + "Buyer trade state PDA account encoding the buy order." + ] + }, + { + "name": "sellerTradeState", + "isMut": true, + "isSigner": false, + "docs": [ + "Seller trade state PDA account encoding the sell order." + ] + }, + { + "name": "freeTradeState", + "isMut": true, + "isSigner": false, + "docs": [ + "Free seller trade state PDA account encoding a free sell order." + ] + }, + { + "name": "ahAuctioneerPda", + "isMut": false, + "isSigner": false, + "docs": [ + "The auctioneer PDA owned by Auction House storing scopes." + ] + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "ataProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "programAsSigner", + "isMut": false, + "isSigner": false + }, + { + "name": "rent", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "escrowPaymentBump", + "type": "u8" + }, + { + "name": "freeTradeStateBump", + "type": "u8" + }, + { + "name": "programAsSignerBump", + "type": "u8" + }, + { + "name": "buyerPrice", + "type": "u64" + }, + { + "name": "tokenSize", + "type": "u64" + } + ] + }, + { + "name": "auctioneerExecutePartialSale", + "accounts": [ + { + "name": "buyer", + "isMut": true, + "isSigner": false, + "docs": [ + "Buyer user wallet account." + ] + }, + { + "name": "seller", + "isMut": true, + "isSigner": false, + "docs": [ + "Seller user wallet account." + ] + }, + { + "name": "tokenAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "Token account where the SPL token is stored." + ] + }, + { + "name": "tokenMint", + "isMut": false, + "isSigner": false, + "docs": [ + "Token mint account for the SPL token." + ] + }, + { + "name": "metadata", + "isMut": false, + "isSigner": false, + "docs": [ + "Metaplex metadata account decorating SPL mint account." + ] + }, + { + "name": "treasuryMint", + "isMut": false, + "isSigner": false, + "docs": [ + "Auction House treasury mint account." + ] + }, + { + "name": "escrowPaymentAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "Buyer escrow payment account." + ] + }, + { + "name": "sellerPaymentReceiptAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "Seller SOL or SPL account to receive payment at." + ] + }, + { + "name": "buyerReceiptTokenAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "Buyer SPL token account to receive purchased item at." + ] + }, + { + "name": "authority", + "isMut": false, + "isSigner": false, + "docs": [ + "Auction House instance authority." + ] + }, + { + "name": "auctioneerAuthority", + "isMut": false, + "isSigner": true, + "docs": [ + "The auctioneer authority - typically a PDA of the Auctioneer program running this action." + ] + }, + { + "name": "auctionHouse", + "isMut": false, + "isSigner": false, + "docs": [ + "Auction House instance PDA account." + ] + }, + { + "name": "auctionHouseFeeAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "Auction House instance fee account." + ] + }, + { + "name": "auctionHouseTreasury", + "isMut": true, + "isSigner": false, + "docs": [ + "Auction House instance treasury account." + ] + }, + { + "name": "buyerTradeState", + "isMut": true, + "isSigner": false, + "docs": [ + "Buyer trade state PDA account encoding the buy order." + ] + }, + { + "name": "sellerTradeState", + "isMut": true, + "isSigner": false, + "docs": [ + "Seller trade state PDA account encoding the sell order." + ] + }, + { + "name": "freeTradeState", + "isMut": true, + "isSigner": false, + "docs": [ + "Free seller trade state PDA account encoding a free sell order." + ] + }, + { + "name": "ahAuctioneerPda", + "isMut": false, + "isSigner": false, + "docs": [ + "The auctioneer PDA owned by Auction House storing scopes." + ] + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "ataProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "programAsSigner", + "isMut": false, + "isSigner": false + }, + { + "name": "rent", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "escrowPaymentBump", + "type": "u8" + }, + { + "name": "freeTradeStateBump", + "type": "u8" + }, + { + "name": "programAsSignerBump", + "type": "u8" + }, + { + "name": "buyerPrice", + "type": "u64" + }, + { + "name": "tokenSize", + "type": "u64" + }, + { + "name": "partialOrderSize", + "type": { + "option": "u64" + } + }, + { + "name": "partialOrderPrice", + "type": { + "option": "u64" + } + } + ] + }, + { + "name": "sell", + "accounts": [ + { + "name": "wallet", + "isMut": false, + "isSigner": false, + "docs": [ + "User wallet account." + ] + }, + { + "name": "tokenAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "SPL token account containing token for sale." + ] + }, + { + "name": "metadata", + "isMut": false, + "isSigner": false, + "docs": [ + "Metaplex metadata account decorating SPL mint account." + ] + }, + { + "name": "authority", + "isMut": false, + "isSigner": false, + "docs": [ + "Auction House authority account." + ] + }, + { + "name": "auctionHouse", + "isMut": false, + "isSigner": false, + "docs": [ + "Auction House instance PDA account." + ] + }, + { + "name": "auctionHouseFeeAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "Auction House instance fee account." + ] + }, + { + "name": "sellerTradeState", + "isMut": true, + "isSigner": false, + "docs": [ + "Seller trade state PDA account encoding the sell order." + ] + }, + { + "name": "freeSellerTradeState", + "isMut": true, + "isSigner": false, + "docs": [ + "Free seller trade state PDA account encoding a free sell order." + ] + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "programAsSigner", + "isMut": false, + "isSigner": false + }, + { + "name": "rent", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "tradeStateBump", + "type": "u8" + }, + { + "name": "freeTradeStateBump", + "type": "u8" + }, + { + "name": "programAsSignerBump", + "type": "u8" + }, + { + "name": "buyerPrice", + "type": "u64" + }, + { + "name": "tokenSize", + "type": "u64" + } + ] + }, + { + "name": "auctioneerSell", + "accounts": [ + { + "name": "wallet", + "isMut": true, + "isSigner": false, + "docs": [ + "User wallet account." + ] + }, + { + "name": "tokenAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "SPL token account containing token for sale." + ] + }, { - "name": "tradeState", - "type": "publicKey" + "name": "metadata", + "isMut": false, + "isSigner": false, + "docs": [ + "Metaplex metadata account decorating SPL mint account." + ] }, { - "name": "bookkeeper", - "type": "publicKey" + "name": "authority", + "isMut": false, + "isSigner": false, + "docs": [ + "Auction House authority account." + ] + }, + { + "name": "auctioneerAuthority", + "isMut": false, + "isSigner": true, + "docs": [ + "The auctioneer authority - typically a PDA of the Auctioneer program running this action." + ] }, { "name": "auctionHouse", - "type": "publicKey" + "isMut": false, + "isSigner": false, + "docs": [ + "Auction House instance PDA account." + ] }, { - "name": "buyer", - "type": "publicKey" + "name": "auctionHouseFeeAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "Auction House instance fee account." + ] }, { - "name": "metadata", - "type": "publicKey" + "name": "sellerTradeState", + "isMut": true, + "isSigner": false, + "docs": [ + "Seller trade state PDA account encoding the sell order." + ] }, { - "name": "tokenAccount", - "type": { - "option": "publicKey" - } + "name": "freeSellerTradeState", + "isMut": true, + "isSigner": false, + "docs": [ + "Free seller trade state PDA account encoding a free sell order." + ] }, { - "name": "purchaseReceipt", - "type": { - "option": "publicKey" - } + "name": "ahAuctioneerPda", + "isMut": false, + "isSigner": false, + "docs": [ + "The auctioneer PDA owned by Auction House storing scopes." + ] }, { - "name": "price", - "type": "u64" + "name": "programAsSigner", + "isMut": false, + "isSigner": false }, { - "name": "tokenSize", - "type": "u64" + "name": "tokenProgram", + "isMut": false, + "isSigner": false }, { - "name": "bump", - "type": "u8" + "name": "systemProgram", + "isMut": false, + "isSigner": false }, + { + "name": "rent", + "isMut": false, + "isSigner": false + } + ], + "args": [ { "name": "tradeStateBump", "type": "u8" }, { - "name": "createdAt", - "type": "i64" + "name": "freeTradeStateBump", + "type": "u8" + }, + { + "name": "programAsSignerBump", + "type": "u8" }, { - "name": "canceledAt", - "type": { - "option": "i64" - } + "name": "tokenSize", + "type": "u64" } ] - } - }, - { - "name": "ListingReceipt", - "type": { - "kind": "struct", - "fields": [ + }, + { + "name": "withdraw", + "docs": [ + "Withdraw `amount` from the escrow payment account for your specific wallet." + ], + "accounts": [ { - "name": "tradeState", - "type": "publicKey" + "name": "wallet", + "isMut": false, + "isSigner": false, + "docs": [ + "User wallet account." + ] }, { - "name": "bookkeeper", - "type": "publicKey" + "name": "receiptAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "SPL token account or native SOL account to transfer funds to. If the account is a native SOL account, this is the same as the wallet address." + ] }, { - "name": "auctionHouse", - "type": "publicKey" + "name": "escrowPaymentAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "Buyer escrow payment account PDA." + ] }, { - "name": "seller", - "type": "publicKey" + "name": "treasuryMint", + "isMut": false, + "isSigner": false, + "docs": [ + "Auction House instance treasury mint account." + ] }, { - "name": "metadata", - "type": "publicKey" + "name": "authority", + "isMut": false, + "isSigner": false, + "docs": [ + "Auction House instance authority account." + ] }, { - "name": "purchaseReceipt", - "type": { - "option": "publicKey" - } + "name": "auctionHouse", + "isMut": false, + "isSigner": false, + "docs": [ + "Auction House instance PDA account." + ] }, { - "name": "price", - "type": "u64" + "name": "auctionHouseFeeAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "Auction House instance fee account." + ] }, { - "name": "tokenSize", - "type": "u64" + "name": "tokenProgram", + "isMut": false, + "isSigner": false }, { - "name": "bump", - "type": "u8" + "name": "systemProgram", + "isMut": false, + "isSigner": false }, { - "name": "tradeStateBump", - "type": "u8" + "name": "ataProgram", + "isMut": false, + "isSigner": false }, { - "name": "createdAt", - "type": "i64" + "name": "rent", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "escrowPaymentBump", + "type": "u8" }, { - "name": "canceledAt", - "type": { - "option": "i64" - } + "name": "amount", + "type": "u64" } ] - } - }, - { - "name": "PurchaseReceipt", - "type": { - "kind": "struct", - "fields": [ + }, + { + "name": "auctioneerWithdraw", + "docs": [ + "Withdraw `amount` from the escrow payment account for your specific wallet." + ], + "accounts": [ { - "name": "bookkeeper", - "type": "publicKey" + "name": "wallet", + "isMut": false, + "isSigner": false, + "docs": [ + "User wallet account." + ] }, { - "name": "buyer", - "type": "publicKey" + "name": "receiptAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "SPL token account or native SOL account to transfer funds to. If the account is a native SOL account, this is the same as the wallet address." + ] }, { - "name": "seller", - "type": "publicKey" + "name": "escrowPaymentAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "Buyer escrow payment account PDA." + ] }, { - "name": "auctionHouse", - "type": "publicKey" + "name": "treasuryMint", + "isMut": false, + "isSigner": false, + "docs": [ + "Auction House instance treasury mint account." + ] }, { - "name": "metadata", - "type": "publicKey" + "name": "authority", + "isMut": false, + "isSigner": false, + "docs": [ + "Auction House instance authority account." + ] }, { - "name": "tokenSize", - "type": "u64" + "name": "auctioneerAuthority", + "isMut": false, + "isSigner": true, + "docs": [ + "The auctioneer authority - typically a PDA of the Auctioneer program running this action." + ] }, { - "name": "price", - "type": "u64" + "name": "auctionHouse", + "isMut": false, + "isSigner": false, + "docs": [ + "Auction House instance PDA account." + ] }, { - "name": "bump", - "type": "u8" + "name": "auctionHouseFeeAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "Auction House instance fee account." + ] }, { - "name": "createdAt", - "type": "i64" - } - ] - } - }, - { - "name": "AuctionHouse", - "type": { - "kind": "struct", - "fields": [ - { - "name": "auctionHouseFeeAccount", - "type": "publicKey" + "name": "ahAuctioneerPda", + "isMut": false, + "isSigner": false, + "docs": [ + "The auctioneer PDA owned by Auction House storing scopes." + ] }, { - "name": "auctionHouseTreasury", - "type": "publicKey" + "name": "tokenProgram", + "isMut": false, + "isSigner": false }, { - "name": "treasuryWithdrawalDestination", - "type": "publicKey" + "name": "systemProgram", + "isMut": false, + "isSigner": false }, { - "name": "feeWithdrawalDestination", - "type": "publicKey" + "name": "ataProgram", + "isMut": false, + "isSigner": false }, { - "name": "treasuryMint", - "type": "publicKey" + "name": "rent", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "escrowPaymentBump", + "type": "u8" }, { - "name": "authority", - "type": "publicKey" + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "closeEscrowAccount", + "docs": [ + "Close the escrow account of the user." + ], + "accounts": [ + { + "name": "wallet", + "isMut": false, + "isSigner": true, + "docs": [ + "User wallet account." + ] }, { - "name": "creator", - "type": "publicKey" + "name": "escrowPaymentAccount", + "isMut": true, + "isSigner": false, + "docs": [ + "Buyer escrow payment account PDA." + ] }, { - "name": "bump", - "type": "u8" + "name": "auctionHouse", + "isMut": false, + "isSigner": false, + "docs": [ + "Auction House instance PDA account." + ] }, { - "name": "treasuryBump", + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "escrowPaymentBump", "type": "u8" + } + ] + }, + { + "name": "delegateAuctioneer", + "accounts": [ + { + "name": "auctionHouse", + "isMut": true, + "isSigner": false }, { - "name": "feePayerBump", - "type": "u8" + "name": "authority", + "isMut": true, + "isSigner": true }, { - "name": "sellerFeeBasisPoints", - "type": "u16" + "name": "auctioneerAuthority", + "isMut": false, + "isSigner": false, + "docs": [ + "The auctioneer authority - the program PDA running this auction." + ] }, { - "name": "requiresSignOff", - "type": "bool" + "name": "ahAuctioneerPda", + "isMut": true, + "isSigner": false, + "docs": [ + "The auctioneer PDA owned by Auction House storing scopes." + ] }, { - "name": "canChangeSalePrice", - "type": "bool" + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "scopes", + "type": { + "vec": { + "defined": "AuthorityScope" + } + } + } + ] + }, + { + "name": "updateAuctioneer", + "accounts": [ + { + "name": "auctionHouse", + "isMut": true, + "isSigner": false }, { - "name": "escrowPaymentBump", - "type": "u8" + "name": "authority", + "isMut": true, + "isSigner": true }, { - "name": "hasAuctioneer", - "type": "bool" + "name": "auctioneerAuthority", + "isMut": false, + "isSigner": false, + "docs": [ + "The auctioneer authority - typically a PDA of the Auctioneer program running this action." + ] }, { - "name": "auctioneerAddress", - "type": "publicKey" + "name": "ahAuctioneerPda", + "isMut": true, + "isSigner": false, + "docs": [ + "The auctioneer PDA owned by Auction House storing scopes." + ] }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ { "name": "scopes", "type": { - "array": [ - "bool", - 7 - ] + "vec": { + "defined": "AuthorityScope" + } } } ] - } - }, - { - "name": "Auctioneer", - "type": { - "kind": "struct", - "fields": [ + }, + { + "name": "printListingReceipt", + "docs": [ + "Create a listing receipt by creating a `listing_receipt` account." + ], + "accounts": [ { - "name": "auctioneerAuthority", - "type": "publicKey" + "name": "receipt", + "isMut": true, + "isSigner": false }, { - "name": "auctionHouse", - "type": "publicKey" + "name": "bookkeeper", + "isMut": true, + "isSigner": true }, { - "name": "bump", + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "rent", + "isMut": false, + "isSigner": false + }, + { + "name": "instruction", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "receiptBump", "type": "u8" } ] - } - } - ], - "types": [ - { - "name": "AuthorityScope", - "type": { - "kind": "enum", - "variants": [ + }, + { + "name": "cancelListingReceipt", + "docs": [ + "Cancel an active listing receipt by setting the `canceled_at` field to the current time." + ], + "accounts": [ { - "name": "Deposit" + "name": "receipt", + "isMut": true, + "isSigner": false }, { - "name": "Buy" + "name": "systemProgram", + "isMut": false, + "isSigner": false }, { - "name": "PublicBuy" + "name": "instruction", + "isMut": false, + "isSigner": false + } + ], + "args": [] + }, + { + "name": "printBidReceipt", + "docs": [ + "Create a bid receipt by creating a `bid_receipt` account." + ], + "accounts": [ + { + "name": "receipt", + "isMut": true, + "isSigner": false }, { - "name": "ExecuteSale" + "name": "bookkeeper", + "isMut": true, + "isSigner": true }, { - "name": "Sell" + "name": "systemProgram", + "isMut": false, + "isSigner": false }, { - "name": "Cancel" + "name": "rent", + "isMut": false, + "isSigner": false }, { - "name": "Withdraw" + "name": "instruction", + "isMut": false, + "isSigner": false } - ] - } - }, - { - "name": "BidType", - "type": { - "kind": "enum", - "variants": [ + ], + "args": [ { - "name": "PublicSale" - }, + "name": "receiptBump", + "type": "u8" + } + ] + }, + { + "name": "cancelBidReceipt", + "docs": [ + "Cancel an active bid receipt by setting the `canceled_at` field to the current time." + ], + "accounts": [ { - "name": "PrivateSale" + "name": "receipt", + "isMut": true, + "isSigner": false }, { - "name": "AuctioneerPublicSale" + "name": "systemProgram", + "isMut": false, + "isSigner": false }, { - "name": "AuctioneerPrivateSale" + "name": "instruction", + "isMut": false, + "isSigner": false } - ] - } - }, - { - "name": "ListingType", - "type": { - "kind": "enum", - "variants": [ + ], + "args": [] + }, + { + "name": "printPurchaseReceipt", + "docs": [ + "Create a purchase receipt by creating a `purchase_receipt` account." + ], + "accounts": [ { - "name": "Sell" + "name": "purchaseReceipt", + "isMut": true, + "isSigner": false }, { - "name": "AuctioneerSell" - } - ] - } - }, - { - "name": "PurchaseType", - "type": { - "kind": "enum", - "variants": [ + "name": "listingReceipt", + "isMut": true, + "isSigner": false + }, { - "name": "ExecuteSale" + "name": "bidReceipt", + "isMut": true, + "isSigner": false }, { - "name": "AuctioneerExecuteSale" - } - ] - } - }, - { - "name": "CancelType", - "type": { - "kind": "enum", - "variants": [ + "name": "bookkeeper", + "isMut": true, + "isSigner": true + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, { - "name": "Cancel" + "name": "rent", + "isMut": false, + "isSigner": false }, { - "name": "AuctioneerCancel" + "name": "instruction", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "purchaseReceiptBump", + "type": "u8" } ] } + ], + "accounts": [ + { + "name": "BidReceipt", + "docs": [ + "Receipt for a bid transaction." + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "tradeState", + "type": "publicKey" + }, + { + "name": "bookkeeper", + "type": "publicKey" + }, + { + "name": "auctionHouse", + "type": "publicKey" + }, + { + "name": "buyer", + "type": "publicKey" + }, + { + "name": "metadata", + "type": "publicKey" + }, + { + "name": "tokenAccount", + "type": { + "option": "publicKey" + } + }, + { + "name": "purchaseReceipt", + "type": { + "option": "publicKey" + } + }, + { + "name": "price", + "type": "u64" + }, + { + "name": "tokenSize", + "type": "u64" + }, + { + "name": "bump", + "type": "u8" + }, + { + "name": "tradeStateBump", + "type": "u8" + }, + { + "name": "createdAt", + "type": "i64" + }, + { + "name": "canceledAt", + "type": { + "option": "i64" + } + } + ] + } + }, + { + "name": "ListingReceipt", + "docs": [ + "Receipt for a listing transaction." + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "tradeState", + "type": "publicKey" + }, + { + "name": "bookkeeper", + "type": "publicKey" + }, + { + "name": "auctionHouse", + "type": "publicKey" + }, + { + "name": "seller", + "type": "publicKey" + }, + { + "name": "metadata", + "type": "publicKey" + }, + { + "name": "purchaseReceipt", + "type": { + "option": "publicKey" + } + }, + { + "name": "price", + "type": "u64" + }, + { + "name": "tokenSize", + "type": "u64" + }, + { + "name": "bump", + "type": "u8" + }, + { + "name": "tradeStateBump", + "type": "u8" + }, + { + "name": "createdAt", + "type": "i64" + }, + { + "name": "canceledAt", + "type": { + "option": "i64" + } + } + ] + } + }, + { + "name": "PurchaseReceipt", + "docs": [ + "Receipt for a purchase transaction." + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "bookkeeper", + "type": "publicKey" + }, + { + "name": "buyer", + "type": "publicKey" + }, + { + "name": "seller", + "type": "publicKey" + }, + { + "name": "auctionHouse", + "type": "publicKey" + }, + { + "name": "metadata", + "type": "publicKey" + }, + { + "name": "tokenSize", + "type": "u64" + }, + { + "name": "price", + "type": "u64" + }, + { + "name": "bump", + "type": "u8" + }, + { + "name": "createdAt", + "type": "i64" + } + ] + } + }, + { + "name": "AuctionHouse", + "type": { + "kind": "struct", + "fields": [ + { + "name": "auctionHouseFeeAccount", + "type": "publicKey" + }, + { + "name": "auctionHouseTreasury", + "type": "publicKey" + }, + { + "name": "treasuryWithdrawalDestination", + "type": "publicKey" + }, + { + "name": "feeWithdrawalDestination", + "type": "publicKey" + }, + { + "name": "treasuryMint", + "type": "publicKey" + }, + { + "name": "authority", + "type": "publicKey" + }, + { + "name": "creator", + "type": "publicKey" + }, + { + "name": "bump", + "type": "u8" + }, + { + "name": "treasuryBump", + "type": "u8" + }, + { + "name": "feePayerBump", + "type": "u8" + }, + { + "name": "sellerFeeBasisPoints", + "type": "u16" + }, + { + "name": "requiresSignOff", + "type": "bool" + }, + { + "name": "canChangeSalePrice", + "type": "bool" + }, + { + "name": "escrowPaymentBump", + "type": "u8" + }, + { + "name": "hasAuctioneer", + "type": "bool" + }, + { + "name": "auctioneerAddress", + "type": "publicKey" + }, + { + "name": "scopes", + "type": { + "array": [ + "bool", + 7 + ] + } + } + ] + } + }, + { + "name": "Auctioneer", + "type": { + "kind": "struct", + "fields": [ + { + "name": "auctioneerAuthority", + "type": "publicKey" + }, + { + "name": "auctionHouse", + "type": "publicKey" + }, + { + "name": "bump", + "type": "u8" + } + ] + } + } + ], + "types": [ + { + "name": "AuthorityScope", + "type": { + "kind": "enum", + "variants": [ + { + "name": "Deposit" + }, + { + "name": "Buy" + }, + { + "name": "PublicBuy" + }, + { + "name": "ExecuteSale" + }, + { + "name": "Sell" + }, + { + "name": "Cancel" + }, + { + "name": "Withdraw" + } + ] + } + }, + { + "name": "BidType", + "type": { + "kind": "enum", + "variants": [ + { + "name": "PublicSale" + }, + { + "name": "PrivateSale" + }, + { + "name": "AuctioneerPublicSale" + }, + { + "name": "AuctioneerPrivateSale" + } + ] + } + }, + { + "name": "ListingType", + "type": { + "kind": "enum", + "variants": [ + { + "name": "Sell" + }, + { + "name": "AuctioneerSell" + } + ] + } + }, + { + "name": "PurchaseType", + "type": { + "kind": "enum", + "variants": [ + { + "name": "ExecuteSale" + }, + { + "name": "AuctioneerExecuteSale" + } + ] + } + }, + { + "name": "CancelType", + "type": { + "kind": "enum", + "variants": [ + { + "name": "Cancel" + }, + { + "name": "AuctioneerCancel" + } + ] + } + } + ], + "errors": [ + { + "code": 6000, + "name": "PublicKeyMismatch", + "msg": "PublicKeyMismatch" + }, + { + "code": 6001, + "name": "InvalidMintAuthority", + "msg": "InvalidMintAuthority" + }, + { + "code": 6002, + "name": "UninitializedAccount", + "msg": "UninitializedAccount" + }, + { + "code": 6003, + "name": "IncorrectOwner", + "msg": "IncorrectOwner" + }, + { + "code": 6004, + "name": "PublicKeysShouldBeUnique", + "msg": "PublicKeysShouldBeUnique" + }, + { + "code": 6005, + "name": "StatementFalse", + "msg": "StatementFalse" + }, + { + "code": 6006, + "name": "NotRentExempt", + "msg": "NotRentExempt" + }, + { + "code": 6007, + "name": "NumericalOverflow", + "msg": "NumericalOverflow" + }, + { + "code": 6008, + "name": "ExpectedSolAccount", + "msg": "Expected a sol account but got an spl token account instead" + }, + { + "code": 6009, + "name": "CannotExchangeSOLForSol", + "msg": "Cannot exchange sol for sol" + }, + { + "code": 6010, + "name": "SOLWalletMustSign", + "msg": "If paying with sol, sol wallet must be signer" + }, + { + "code": 6011, + "name": "CannotTakeThisActionWithoutAuctionHouseSignOff", + "msg": "Cannot take this action without auction house signing too" + }, + { + "code": 6012, + "name": "NoPayerPresent", + "msg": "No payer present on this txn" + }, + { + "code": 6013, + "name": "DerivedKeyInvalid", + "msg": "Derived key invalid" + }, + { + "code": 6014, + "name": "MetadataDoesntExist", + "msg": "Metadata doesn't exist" + }, + { + "code": 6015, + "name": "InvalidTokenAmount", + "msg": "Invalid token amount" + }, + { + "code": 6016, + "name": "BothPartiesNeedToAgreeToSale", + "msg": "Both parties need to agree to this sale" + }, + { + "code": 6017, + "name": "CannotMatchFreeSalesWithoutAuctionHouseOrSellerSignoff", + "msg": "Cannot match free sales unless the auction house or seller signs off" + }, + { + "code": 6018, + "name": "SaleRequiresSigner", + "msg": "This sale requires a signer" + }, + { + "code": 6019, + "name": "OldSellerNotInitialized", + "msg": "Old seller not initialized" + }, + { + "code": 6020, + "name": "SellerATACannotHaveDelegate", + "msg": "Seller ata cannot have a delegate set" + }, + { + "code": 6021, + "name": "BuyerATACannotHaveDelegate", + "msg": "Buyer ata cannot have a delegate set" + }, + { + "code": 6022, + "name": "NoValidSignerPresent", + "msg": "No valid signer present" + }, + { + "code": 6023, + "name": "InvalidBasisPoints", + "msg": "BP must be less than or equal to 10000" + }, + { + "code": 6024, + "name": "TradeStateDoesntExist", + "msg": "The trade state account does not exist" + }, + { + "code": 6025, + "name": "TradeStateIsNotEmpty", + "msg": "The trade state is not empty" + }, + { + "code": 6026, + "name": "ReceiptIsEmpty", + "msg": "The receipt is empty" + }, + { + "code": 6027, + "name": "InstructionMismatch", + "msg": "The instruction does not match" + }, + { + "code": 6028, + "name": "InvalidAuctioneer", + "msg": "Invalid Auctioneer for this Auction House instance." + }, + { + "code": 6029, + "name": "MissingAuctioneerScope", + "msg": "The Auctioneer does not have the correct scope for this action." + }, + { + "code": 6030, + "name": "MustUseAuctioneerHandler", + "msg": "Must use auctioneer handler." + }, + { + "code": 6031, + "name": "NoAuctioneerProgramSet", + "msg": "No Auctioneer program set." + }, + { + "code": 6032, + "name": "TooManyScopes", + "msg": "Too many scopes." + }, + { + "code": 6033, + "name": "AuctionHouseNotDelegated", + "msg": "Auction House not delegated." + }, + { + "code": 6034, + "name": "BumpSeedNotInHashMap", + "msg": "Bump seed not in hash map." + }, + { + "code": 6035, + "name": "EscrowUnderRentExemption", + "msg": "The instruction would drain the escrow below rent exemption threshold" + }, + { + "code": 6036, + "name": "InvalidSeedsOrAuctionHouseNotDelegated", + "msg": "Invalid seeds or Auction House not delegated" + }, + { + "code": 6037, + "name": "BuyerTradeStateNotValid", + "msg": "The buyer trade state was unable to be initialized." + }, + { + "code": 6038, + "name": "MissingElementForPartialOrder", + "msg": "Partial order size and price must both be provided in a partial buy." + }, + { + "code": 6039, + "name": "NotEnoughTokensAvailableForPurchase", + "msg": "Amount of tokens available for purchase is less than the partial order amount." + }, + { + "code": 6040, + "name": "PartialPriceMismatch", + "msg": "Calculated partial price does not not partial price that was provided." + }, + { + "code": 6041, + "name": "AuctionHouseAlreadyDelegated", + "msg": "Auction House already delegated." + }, + { + "code": 6042, + "name": "AuctioneerAuthorityMismatch", + "msg": "Auctioneer Authority Mismatch" + }, + { + "code": 6043, + "name": "InsufficientFunds", + "msg": "Insufficient funds in escrow account to purchase." + } + ], + "metadata": { + "address": "hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk", + "origin": "anchor", + "binaryVersion": "0.25.0", + "libVersion": "0.25.0" } - ], - "errors": [ - { - "code": 6000, - "name": "PublicKeyMismatch", - "msg": "PublicKeyMismatch" - }, - { - "code": 6001, - "name": "InvalidMintAuthority", - "msg": "InvalidMintAuthority" - }, - { - "code": 6002, - "name": "UninitializedAccount", - "msg": "UninitializedAccount" - }, - { - "code": 6003, - "name": "IncorrectOwner", - "msg": "IncorrectOwner" - }, - { - "code": 6004, - "name": "PublicKeysShouldBeUnique", - "msg": "PublicKeysShouldBeUnique" - }, - { - "code": 6005, - "name": "StatementFalse", - "msg": "StatementFalse" - }, - { - "code": 6006, - "name": "NotRentExempt", - "msg": "NotRentExempt" - }, - { - "code": 6007, - "name": "NumericalOverflow", - "msg": "NumericalOverflow" - }, - { - "code": 6008, - "name": "ExpectedSolAccount", - "msg": "Expected a sol account but got an spl token account instead" - }, - { - "code": 6009, - "name": "CannotExchangeSOLForSol", - "msg": "Cannot exchange sol for sol" - }, - { - "code": 6010, - "name": "SOLWalletMustSign", - "msg": "If paying with sol, sol wallet must be signer" - }, - { - "code": 6011, - "name": "CannotTakeThisActionWithoutAuctionHouseSignOff", - "msg": "Cannot take this action without auction house signing too" - }, - { - "code": 6012, - "name": "NoPayerPresent", - "msg": "No payer present on this txn" - }, - { - "code": 6013, - "name": "DerivedKeyInvalid", - "msg": "Derived key invalid" - }, - { - "code": 6014, - "name": "MetadataDoesntExist", - "msg": "Metadata doesn't exist" - }, - { - "code": 6015, - "name": "InvalidTokenAmount", - "msg": "Invalid token amount" - }, - { - "code": 6016, - "name": "BothPartiesNeedToAgreeToSale", - "msg": "Both parties need to agree to this sale" - }, - { - "code": 6017, - "name": "CannotMatchFreeSalesWithoutAuctionHouseOrSellerSignoff", - "msg": "Cannot match free sales unless the auction house or seller signs off" - }, - { - "code": 6018, - "name": "SaleRequiresSigner", - "msg": "This sale requires a signer" - }, - { - "code": 6019, - "name": "OldSellerNotInitialized", - "msg": "Old seller not initialized" - }, - { - "code": 6020, - "name": "SellerATACannotHaveDelegate", - "msg": "Seller ata cannot have a delegate set" - }, - { - "code": 6021, - "name": "BuyerATACannotHaveDelegate", - "msg": "Buyer ata cannot have a delegate set" - }, - { - "code": 6022, - "name": "NoValidSignerPresent", - "msg": "No valid signer present" - }, - { - "code": 6023, - "name": "InvalidBasisPoints", - "msg": "BP must be less than or equal to 10000" - }, - { - "code": 6024, - "name": "TradeStateDoesntExist", - "msg": "The trade state account does not exist" - }, - { - "code": 6025, - "name": "TradeStateIsNotEmpty", - "msg": "The trade state is not empty" - }, - { - "code": 6026, - "name": "ReceiptIsEmpty", - "msg": "The receipt is empty" - }, - { - "code": 6027, - "name": "InstructionMismatch", - "msg": "The instruction does not match" - }, - { - "code": 6028, - "name": "InvalidAuctioneer", - "msg": "Invalid Auctioneer for this Auction House instance." - }, - { - "code": 6029, - "name": "MissingAuctioneerScope", - "msg": "The Auctioneer does not have the correct scope for this action." - }, - { - "code": 6030, - "name": "MustUseAuctioneerHandler", - "msg": "Must use auctioneer handler." - }, - { - "code": 6031, - "name": "NoAuctioneerProgramSet", - "msg": "No Auctioneer program set." - }, - { - "code": 6032, - "name": "TooManyScopes", - "msg": "Too many scopes." - }, - { - "code": 6033, - "name": "AuctionHouseNotDelegated", - "msg": "Auction House not delegated." - }, - { - "code": 6034, - "name": "BumpSeedNotInHashMap", - "msg": "Bump seed not in hash map." - }, - { - "code": 6035, - "name": "EscrowUnderRentExemption", - "msg": "The instruction would drain the escrow below rent exemption threshold" - }, - { - "code": 6036, - "name": "InvalidSeedsOrAuctionHouseNotDelegated", - "msg": "Invalid seeds or Auction House not delegated" - }, - { - "code": 6037, - "name": "BuyerTradeStateNotValid", - "msg": "The buyer trade state was unable to be initialized." - }, - { - "code": 6038, - "name": "MissingElementForPartialOrder", - "msg": "Partial order size and price must both be provided in a partial buy." - }, - { - "code": 6039, - "name": "NotEnoughTokensAvailableForPurchase", - "msg": "Amount of tokens available for purchase is less than the partial order amount." - }, - { - "code": 6040, - "name": "PartialPriceMismatch", - "msg": "Calculated partial price does not not partial price that was provided." - }, - { - "code": 6041, - "name": "AuctionHouseAlreadyDelegated", - "msg": "Auction House already delegated." - }, - { - "code": 6042, - "name": "AuctioneerAuthorityMismatch", - "msg": "Auctioneer Authority Mismatch" - }, - { - "code": 6043, - "name": "InsufficientFunds", - "msg": "Insufficient funds in escrow account to purchase." - } - ] - } - """.trimIndent() \ No newline at end of file + } +""".trimIndent() +//@Language("json") +//val auctionHouseJson = """ +// { +// "version": "1.2.4", +// "name": "auction_house", +// "instructions": [ +// { +// "name": "withdrawFromFee", +// "accounts": [ +// { +// "name": "authority", +// "isMut": false, +// "isSigner": true +// }, +// { +// "name": "feeWithdrawalDestination", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "auctionHouseFeeAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "auctionHouse", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "systemProgram", +// "isMut": false, +// "isSigner": false +// } +// ], +// "args": [ +// { +// "name": "amount", +// "type": "u64" +// } +// ] +// }, +// { +// "name": "withdrawFromTreasury", +// "accounts": [ +// { +// "name": "treasuryMint", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "authority", +// "isMut": false, +// "isSigner": true +// }, +// { +// "name": "treasuryWithdrawalDestination", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "auctionHouseTreasury", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "auctionHouse", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "tokenProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "systemProgram", +// "isMut": false, +// "isSigner": false +// } +// ], +// "args": [ +// { +// "name": "amount", +// "type": "u64" +// } +// ] +// }, +// { +// "name": "updateAuctionHouse", +// "accounts": [ +// { +// "name": "treasuryMint", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "payer", +// "isMut": false, +// "isSigner": true +// }, +// { +// "name": "authority", +// "isMut": false, +// "isSigner": true +// }, +// { +// "name": "newAuthority", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "feeWithdrawalDestination", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "treasuryWithdrawalDestination", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "treasuryWithdrawalDestinationOwner", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "auctionHouse", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "tokenProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "systemProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "ataProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "rent", +// "isMut": false, +// "isSigner": false +// } +// ], +// "args": [ +// { +// "name": "sellerFeeBasisPoints", +// "type": { +// "option": "u16" +// } +// }, +// { +// "name": "requiresSignOff", +// "type": { +// "option": "bool" +// } +// }, +// { +// "name": "canChangeSalePrice", +// "type": { +// "option": "bool" +// } +// } +// ] +// }, +// { +// "name": "createAuctionHouse", +// "accounts": [ +// { +// "name": "treasuryMint", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "payer", +// "isMut": true, +// "isSigner": true +// }, +// { +// "name": "authority", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "feeWithdrawalDestination", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "treasuryWithdrawalDestination", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "treasuryWithdrawalDestinationOwner", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "auctionHouse", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "auctionHouseFeeAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "auctionHouseTreasury", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "tokenProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "systemProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "ataProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "rent", +// "isMut": false, +// "isSigner": false +// } +// ], +// "args": [ +// { +// "name": "bump", +// "type": "u8" +// }, +// { +// "name": "feePayerBump", +// "type": "u8" +// }, +// { +// "name": "treasuryBump", +// "type": "u8" +// }, +// { +// "name": "sellerFeeBasisPoints", +// "type": "u16" +// }, +// { +// "name": "requiresSignOff", +// "type": "bool" +// }, +// { +// "name": "canChangeSalePrice", +// "type": "bool" +// } +// ] +// }, +// { +// "name": "buy", +// "accounts": [ +// { +// "name": "wallet", +// "isMut": false, +// "isSigner": true +// }, +// { +// "name": "paymentAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "transferAuthority", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "treasuryMint", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "tokenAccount", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "metadata", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "escrowPaymentAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "authority", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "auctionHouse", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "auctionHouseFeeAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "buyerTradeState", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "tokenProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "systemProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "rent", +// "isMut": false, +// "isSigner": false +// } +// ], +// "args": [ +// { +// "name": "tradeStateBump", +// "type": "u8" +// }, +// { +// "name": "escrowPaymentBump", +// "type": "u8" +// }, +// { +// "name": "buyerPrice", +// "type": "u64" +// }, +// { +// "name": "tokenSize", +// "type": "u64" +// } +// ] +// }, +// { +// "name": "auctioneerBuy", +// "accounts": [ +// { +// "name": "wallet", +// "isMut": false, +// "isSigner": true +// }, +// { +// "name": "paymentAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "transferAuthority", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "treasuryMint", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "tokenAccount", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "metadata", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "escrowPaymentAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "authority", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "auctioneerAuthority", +// "isMut": false, +// "isSigner": true +// }, +// { +// "name": "auctionHouse", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "auctionHouseFeeAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "buyerTradeState", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "ahAuctioneerPda", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "tokenProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "systemProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "rent", +// "isMut": false, +// "isSigner": false +// } +// ], +// "args": [ +// { +// "name": "tradeStateBump", +// "type": "u8" +// }, +// { +// "name": "escrowPaymentBump", +// "type": "u8" +// }, +// { +// "name": "buyerPrice", +// "type": "u64" +// }, +// { +// "name": "tokenSize", +// "type": "u64" +// } +// ] +// }, +// { +// "name": "publicBuy", +// "accounts": [ +// { +// "name": "wallet", +// "isMut": false, +// "isSigner": true +// }, +// { +// "name": "paymentAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "transferAuthority", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "treasuryMint", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "tokenAccount", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "metadata", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "escrowPaymentAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "authority", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "auctionHouse", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "auctionHouseFeeAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "buyerTradeState", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "tokenProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "systemProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "rent", +// "isMut": false, +// "isSigner": false +// } +// ], +// "args": [ +// { +// "name": "tradeStateBump", +// "type": "u8" +// }, +// { +// "name": "escrowPaymentBump", +// "type": "u8" +// }, +// { +// "name": "buyerPrice", +// "type": "u64" +// }, +// { +// "name": "tokenSize", +// "type": "u64" +// } +// ] +// }, +// { +// "name": "auctioneerPublicBuy", +// "accounts": [ +// { +// "name": "wallet", +// "isMut": false, +// "isSigner": true +// }, +// { +// "name": "paymentAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "transferAuthority", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "treasuryMint", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "tokenAccount", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "metadata", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "escrowPaymentAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "authority", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "auctioneerAuthority", +// "isMut": false, +// "isSigner": true +// }, +// { +// "name": "auctionHouse", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "auctionHouseFeeAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "buyerTradeState", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "ahAuctioneerPda", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "tokenProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "systemProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "rent", +// "isMut": false, +// "isSigner": false +// } +// ], +// "args": [ +// { +// "name": "tradeStateBump", +// "type": "u8" +// }, +// { +// "name": "escrowPaymentBump", +// "type": "u8" +// }, +// { +// "name": "buyerPrice", +// "type": "u64" +// }, +// { +// "name": "tokenSize", +// "type": "u64" +// } +// ] +// }, +// { +// "name": "cancel", +// "accounts": [ +// { +// "name": "wallet", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "tokenAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "tokenMint", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "authority", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "auctionHouse", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "auctionHouseFeeAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "tradeState", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "tokenProgram", +// "isMut": false, +// "isSigner": false +// } +// ], +// "args": [ +// { +// "name": "buyerPrice", +// "type": "u64" +// }, +// { +// "name": "tokenSize", +// "type": "u64" +// } +// ] +// }, +// { +// "name": "auctioneerCancel", +// "accounts": [ +// { +// "name": "wallet", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "tokenAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "tokenMint", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "authority", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "auctioneerAuthority", +// "isMut": false, +// "isSigner": true +// }, +// { +// "name": "auctionHouse", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "auctionHouseFeeAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "tradeState", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "ahAuctioneerPda", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "tokenProgram", +// "isMut": false, +// "isSigner": false +// } +// ], +// "args": [ +// { +// "name": "buyerPrice", +// "type": "u64" +// }, +// { +// "name": "tokenSize", +// "type": "u64" +// } +// ] +// }, +// { +// "name": "deposit", +// "accounts": [ +// { +// "name": "wallet", +// "isMut": false, +// "isSigner": true +// }, +// { +// "name": "paymentAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "transferAuthority", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "escrowPaymentAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "treasuryMint", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "authority", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "auctionHouse", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "auctionHouseFeeAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "tokenProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "systemProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "rent", +// "isMut": false, +// "isSigner": false +// } +// ], +// "args": [ +// { +// "name": "escrowPaymentBump", +// "type": "u8" +// }, +// { +// "name": "amount", +// "type": "u64" +// } +// ] +// }, +// { +// "name": "auctioneerDeposit", +// "accounts": [ +// { +// "name": "wallet", +// "isMut": false, +// "isSigner": true +// }, +// { +// "name": "paymentAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "transferAuthority", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "escrowPaymentAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "treasuryMint", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "authority", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "auctioneerAuthority", +// "isMut": false, +// "isSigner": true +// }, +// { +// "name": "auctionHouse", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "auctionHouseFeeAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "ahAuctioneerPda", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "tokenProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "systemProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "rent", +// "isMut": false, +// "isSigner": false +// } +// ], +// "args": [ +// { +// "name": "escrowPaymentBump", +// "type": "u8" +// }, +// { +// "name": "amount", +// "type": "u64" +// } +// ] +// }, +// { +// "name": "executeSale", +// "accounts": [ +// { +// "name": "buyer", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "seller", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "tokenAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "tokenMint", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "metadata", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "treasuryMint", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "escrowPaymentAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "sellerPaymentReceiptAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "buyerReceiptTokenAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "authority", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "auctionHouse", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "auctionHouseFeeAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "auctionHouseTreasury", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "buyerTradeState", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "sellerTradeState", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "freeTradeState", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "tokenProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "systemProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "ataProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "programAsSigner", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "rent", +// "isMut": false, +// "isSigner": false +// } +// ], +// "args": [ +// { +// "name": "escrowPaymentBump", +// "type": "u8" +// }, +// { +// "name": "freeTradeStateBump", +// "type": "u8" +// }, +// { +// "name": "programAsSignerBump", +// "type": "u8" +// }, +// { +// "name": "buyerPrice", +// "type": "u64" +// }, +// { +// "name": "tokenSize", +// "type": "u64" +// } +// ] +// }, +// { +// "name": "executePartialSale", +// "accounts": [ +// { +// "name": "buyer", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "seller", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "tokenAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "tokenMint", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "metadata", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "treasuryMint", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "escrowPaymentAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "sellerPaymentReceiptAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "buyerReceiptTokenAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "authority", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "auctionHouse", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "auctionHouseFeeAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "auctionHouseTreasury", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "buyerTradeState", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "sellerTradeState", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "freeTradeState", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "tokenProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "systemProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "ataProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "programAsSigner", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "rent", +// "isMut": false, +// "isSigner": false +// } +// ], +// "args": [ +// { +// "name": "escrowPaymentBump", +// "type": "u8" +// }, +// { +// "name": "freeTradeStateBump", +// "type": "u8" +// }, +// { +// "name": "programAsSignerBump", +// "type": "u8" +// }, +// { +// "name": "buyerPrice", +// "type": "u64" +// }, +// { +// "name": "tokenSize", +// "type": "u64" +// }, +// { +// "name": "partialOrderSize", +// "type": { +// "option": "u64" +// } +// }, +// { +// "name": "partialOrderPrice", +// "type": { +// "option": "u64" +// } +// } +// ] +// }, +// { +// "name": "auctioneerExecuteSale", +// "accounts": [ +// { +// "name": "buyer", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "seller", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "tokenAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "tokenMint", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "metadata", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "treasuryMint", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "escrowPaymentAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "sellerPaymentReceiptAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "buyerReceiptTokenAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "authority", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "auctioneerAuthority", +// "isMut": false, +// "isSigner": true +// }, +// { +// "name": "auctionHouse", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "auctionHouseFeeAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "auctionHouseTreasury", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "buyerTradeState", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "sellerTradeState", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "freeTradeState", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "ahAuctioneerPda", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "tokenProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "systemProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "ataProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "programAsSigner", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "rent", +// "isMut": false, +// "isSigner": false +// } +// ], +// "args": [ +// { +// "name": "escrowPaymentBump", +// "type": "u8" +// }, +// { +// "name": "freeTradeStateBump", +// "type": "u8" +// }, +// { +// "name": "programAsSignerBump", +// "type": "u8" +// }, +// { +// "name": "buyerPrice", +// "type": "u64" +// }, +// { +// "name": "tokenSize", +// "type": "u64" +// } +// ] +// }, +// { +// "name": "auctioneerExecutePartialSale", +// "accounts": [ +// { +// "name": "buyer", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "seller", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "tokenAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "tokenMint", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "metadata", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "treasuryMint", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "escrowPaymentAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "sellerPaymentReceiptAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "buyerReceiptTokenAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "authority", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "auctioneerAuthority", +// "isMut": false, +// "isSigner": true +// }, +// { +// "name": "auctionHouse", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "auctionHouseFeeAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "auctionHouseTreasury", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "buyerTradeState", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "sellerTradeState", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "freeTradeState", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "ahAuctioneerPda", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "tokenProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "systemProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "ataProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "programAsSigner", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "rent", +// "isMut": false, +// "isSigner": false +// } +// ], +// "args": [ +// { +// "name": "escrowPaymentBump", +// "type": "u8" +// }, +// { +// "name": "freeTradeStateBump", +// "type": "u8" +// }, +// { +// "name": "programAsSignerBump", +// "type": "u8" +// }, +// { +// "name": "buyerPrice", +// "type": "u64" +// }, +// { +// "name": "tokenSize", +// "type": "u64" +// }, +// { +// "name": "partialOrderSize", +// "type": { +// "option": "u64" +// } +// }, +// { +// "name": "partialOrderPrice", +// "type": { +// "option": "u64" +// } +// } +// ] +// }, +// { +// "name": "sell", +// "accounts": [ +// { +// "name": "wallet", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "tokenAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "metadata", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "authority", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "auctionHouse", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "auctionHouseFeeAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "sellerTradeState", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "freeSellerTradeState", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "tokenProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "systemProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "programAsSigner", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "rent", +// "isMut": false, +// "isSigner": false +// } +// ], +// "args": [ +// { +// "name": "tradeStateBump", +// "type": "u8" +// }, +// { +// "name": "freeTradeStateBump", +// "type": "u8" +// }, +// { +// "name": "programAsSignerBump", +// "type": "u8" +// }, +// { +// "name": "buyerPrice", +// "type": "u64" +// }, +// { +// "name": "tokenSize", +// "type": "u64" +// } +// ] +// }, +// { +// "name": "auctioneerSell", +// "accounts": [ +// { +// "name": "wallet", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "tokenAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "metadata", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "authority", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "auctioneerAuthority", +// "isMut": false, +// "isSigner": true +// }, +// { +// "name": "auctionHouse", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "auctionHouseFeeAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "sellerTradeState", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "freeSellerTradeState", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "ahAuctioneerPda", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "programAsSigner", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "tokenProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "systemProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "rent", +// "isMut": false, +// "isSigner": false +// } +// ], +// "args": [ +// { +// "name": "tradeStateBump", +// "type": "u8" +// }, +// { +// "name": "freeTradeStateBump", +// "type": "u8" +// }, +// { +// "name": "programAsSignerBump", +// "type": "u8" +// }, +// { +// "name": "tokenSize", +// "type": "u64" +// } +// ] +// }, +// { +// "name": "withdraw", +// "accounts": [ +// { +// "name": "wallet", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "receiptAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "escrowPaymentAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "treasuryMint", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "authority", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "auctionHouse", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "auctionHouseFeeAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "tokenProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "systemProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "ataProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "rent", +// "isMut": false, +// "isSigner": false +// } +// ], +// "args": [ +// { +// "name": "escrowPaymentBump", +// "type": "u8" +// }, +// { +// "name": "amount", +// "type": "u64" +// } +// ] +// }, +// { +// "name": "auctioneerWithdraw", +// "accounts": [ +// { +// "name": "wallet", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "receiptAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "escrowPaymentAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "treasuryMint", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "authority", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "auctioneerAuthority", +// "isMut": false, +// "isSigner": true +// }, +// { +// "name": "auctionHouse", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "auctionHouseFeeAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "ahAuctioneerPda", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "tokenProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "systemProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "ataProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "rent", +// "isMut": false, +// "isSigner": false +// } +// ], +// "args": [ +// { +// "name": "escrowPaymentBump", +// "type": "u8" +// }, +// { +// "name": "amount", +// "type": "u64" +// } +// ] +// }, +// { +// "name": "closeEscrowAccount", +// "accounts": [ +// { +// "name": "wallet", +// "isMut": false, +// "isSigner": true +// }, +// { +// "name": "escrowPaymentAccount", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "auctionHouse", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "systemProgram", +// "isMut": false, +// "isSigner": false +// } +// ], +// "args": [ +// { +// "name": "escrowPaymentBump", +// "type": "u8" +// } +// ] +// }, +// { +// "name": "delegateAuctioneer", +// "accounts": [ +// { +// "name": "auctionHouse", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "authority", +// "isMut": true, +// "isSigner": true +// }, +// { +// "name": "auctioneerAuthority", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "ahAuctioneerPda", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "systemProgram", +// "isMut": false, +// "isSigner": false +// } +// ], +// "args": [ +// { +// "name": "scopes", +// "type": { +// "vec": { +// "defined": "AuthorityScope" +// } +// } +// } +// ] +// }, +// { +// "name": "updateAuctioneer", +// "accounts": [ +// { +// "name": "auctionHouse", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "authority", +// "isMut": true, +// "isSigner": true +// }, +// { +// "name": "auctioneerAuthority", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "ahAuctioneerPda", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "systemProgram", +// "isMut": false, +// "isSigner": false +// } +// ], +// "args": [ +// { +// "name": "scopes", +// "type": { +// "vec": { +// "defined": "AuthorityScope" +// } +// } +// } +// ] +// }, +// { +// "name": "printListingReceipt", +// "accounts": [ +// { +// "name": "receipt", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "bookkeeper", +// "isMut": true, +// "isSigner": true +// }, +// { +// "name": "systemProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "rent", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "instruction", +// "isMut": false, +// "isSigner": false +// } +// ], +// "args": [ +// { +// "name": "receiptBump", +// "type": "u8" +// } +// ] +// }, +// { +// "name": "cancelListingReceipt", +// "accounts": [ +// { +// "name": "receipt", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "systemProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "instruction", +// "isMut": false, +// "isSigner": false +// } +// ], +// "args": [] +// }, +// { +// "name": "printBidReceipt", +// "accounts": [ +// { +// "name": "receipt", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "bookkeeper", +// "isMut": true, +// "isSigner": true +// }, +// { +// "name": "systemProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "rent", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "instruction", +// "isMut": false, +// "isSigner": false +// } +// ], +// "args": [ +// { +// "name": "receiptBump", +// "type": "u8" +// } +// ] +// }, +// { +// "name": "cancelBidReceipt", +// "accounts": [ +// { +// "name": "receipt", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "systemProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "instruction", +// "isMut": false, +// "isSigner": false +// } +// ], +// "args": [] +// }, +// { +// "name": "printPurchaseReceipt", +// "accounts": [ +// { +// "name": "purchaseReceipt", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "listingReceipt", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "bidReceipt", +// "isMut": true, +// "isSigner": false +// }, +// { +// "name": "bookkeeper", +// "isMut": true, +// "isSigner": true +// }, +// { +// "name": "systemProgram", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "rent", +// "isMut": false, +// "isSigner": false +// }, +// { +// "name": "instruction", +// "isMut": false, +// "isSigner": false +// } +// ], +// "args": [ +// { +// "name": "purchaseReceiptBump", +// "type": "u8" +// } +// ] +// } +// ], +// "accounts": [ +// { +// "name": "BidReceipt", +// "type": { +// "kind": "struct", +// "fields": [ +// { +// "name": "tradeState", +// "type": "publicKey" +// }, +// { +// "name": "bookkeeper", +// "type": "publicKey" +// }, +// { +// "name": "auctionHouse", +// "type": "publicKey" +// }, +// { +// "name": "buyer", +// "type": "publicKey" +// }, +// { +// "name": "metadata", +// "type": "publicKey" +// }, +// { +// "name": "tokenAccount", +// "type": { +// "option": "publicKey" +// } +// }, +// { +// "name": "purchaseReceipt", +// "type": { +// "option": "publicKey" +// } +// }, +// { +// "name": "price", +// "type": "u64" +// }, +// { +// "name": "tokenSize", +// "type": "u64" +// }, +// { +// "name": "bump", +// "type": "u8" +// }, +// { +// "name": "tradeStateBump", +// "type": "u8" +// }, +// { +// "name": "createdAt", +// "type": "i64" +// }, +// { +// "name": "canceledAt", +// "type": { +// "option": "i64" +// } +// } +// ] +// } +// }, +// { +// "name": "ListingReceipt", +// "type": { +// "kind": "struct", +// "fields": [ +// { +// "name": "tradeState", +// "type": "publicKey" +// }, +// { +// "name": "bookkeeper", +// "type": "publicKey" +// }, +// { +// "name": "auctionHouse", +// "type": "publicKey" +// }, +// { +// "name": "seller", +// "type": "publicKey" +// }, +// { +// "name": "metadata", +// "type": "publicKey" +// }, +// { +// "name": "purchaseReceipt", +// "type": { +// "option": "publicKey" +// } +// }, +// { +// "name": "price", +// "type": "u64" +// }, +// { +// "name": "tokenSize", +// "type": "u64" +// }, +// { +// "name": "bump", +// "type": "u8" +// }, +// { +// "name": "tradeStateBump", +// "type": "u8" +// }, +// { +// "name": "createdAt", +// "type": "i64" +// }, +// { +// "name": "canceledAt", +// "type": { +// "option": "i64" +// } +// } +// ] +// } +// }, +// { +// "name": "PurchaseReceipt", +// "type": { +// "kind": "struct", +// "fields": [ +// { +// "name": "bookkeeper", +// "type": "publicKey" +// }, +// { +// "name": "buyer", +// "type": "publicKey" +// }, +// { +// "name": "seller", +// "type": "publicKey" +// }, +// { +// "name": "auctionHouse", +// "type": "publicKey" +// }, +// { +// "name": "metadata", +// "type": "publicKey" +// }, +// { +// "name": "tokenSize", +// "type": "u64" +// }, +// { +// "name": "price", +// "type": "u64" +// }, +// { +// "name": "bump", +// "type": "u8" +// }, +// { +// "name": "createdAt", +// "type": "i64" +// } +// ] +// } +// }, +// { +// "name": "AuctionHouse", +// "type": { +// "kind": "struct", +// "fields": [ +// { +// "name": "auctionHouseFeeAccount", +// "type": "publicKey" +// }, +// { +// "name": "auctionHouseTreasury", +// "type": "publicKey" +// }, +// { +// "name": "treasuryWithdrawalDestination", +// "type": "publicKey" +// }, +// { +// "name": "feeWithdrawalDestination", +// "type": "publicKey" +// }, +// { +// "name": "treasuryMint", +// "type": "publicKey" +// }, +// { +// "name": "authority", +// "type": "publicKey" +// }, +// { +// "name": "creator", +// "type": "publicKey" +// }, +// { +// "name": "bump", +// "type": "u8" +// }, +// { +// "name": "treasuryBump", +// "type": "u8" +// }, +// { +// "name": "feePayerBump", +// "type": "u8" +// }, +// { +// "name": "sellerFeeBasisPoints", +// "type": "u16" +// }, +// { +// "name": "requiresSignOff", +// "type": "bool" +// }, +// { +// "name": "canChangeSalePrice", +// "type": "bool" +// }, +// { +// "name": "escrowPaymentBump", +// "type": "u8" +// }, +// { +// "name": "hasAuctioneer", +// "type": "bool" +// }, +// { +// "name": "auctioneerAddress", +// "type": "publicKey" +// }, +// { +// "name": "scopes", +// "type": { +// "array": [ +// "bool", +// 7 +// ] +// } +// } +// ] +// } +// }, +// { +// "name": "Auctioneer", +// "type": { +// "kind": "struct", +// "fields": [ +// { +// "name": "auctioneerAuthority", +// "type": "publicKey" +// }, +// { +// "name": "auctionHouse", +// "type": "publicKey" +// }, +// { +// "name": "bump", +// "type": "u8" +// } +// ] +// } +// } +// ], +// "types": [ +// { +// "name": "AuthorityScope", +// "type": { +// "kind": "enum", +// "variants": [ +// { +// "name": "Deposit" +// }, +// { +// "name": "Buy" +// }, +// { +// "name": "PublicBuy" +// }, +// { +// "name": "ExecuteSale" +// }, +// { +// "name": "Sell" +// }, +// { +// "name": "Cancel" +// }, +// { +// "name": "Withdraw" +// } +// ] +// } +// }, +// { +// "name": "BidType", +// "type": { +// "kind": "enum", +// "variants": [ +// { +// "name": "PublicSale" +// }, +// { +// "name": "PrivateSale" +// }, +// { +// "name": "AuctioneerPublicSale" +// }, +// { +// "name": "AuctioneerPrivateSale" +// } +// ] +// } +// }, +// { +// "name": "ListingType", +// "type": { +// "kind": "enum", +// "variants": [ +// { +// "name": "Sell" +// }, +// { +// "name": "AuctioneerSell" +// } +// ] +// } +// }, +// { +// "name": "PurchaseType", +// "type": { +// "kind": "enum", +// "variants": [ +// { +// "name": "ExecuteSale" +// }, +// { +// "name": "AuctioneerExecuteSale" +// } +// ] +// } +// }, +// { +// "name": "CancelType", +// "type": { +// "kind": "enum", +// "variants": [ +// { +// "name": "Cancel" +// }, +// { +// "name": "AuctioneerCancel" +// } +// ] +// } +// } +// ], +// "errors": [ +// { +// "code": 6000, +// "name": "PublicKeyMismatch", +// "msg": "PublicKeyMismatch" +// }, +// { +// "code": 6001, +// "name": "InvalidMintAuthority", +// "msg": "InvalidMintAuthority" +// }, +// { +// "code": 6002, +// "name": "UninitializedAccount", +// "msg": "UninitializedAccount" +// }, +// { +// "code": 6003, +// "name": "IncorrectOwner", +// "msg": "IncorrectOwner" +// }, +// { +// "code": 6004, +// "name": "PublicKeysShouldBeUnique", +// "msg": "PublicKeysShouldBeUnique" +// }, +// { +// "code": 6005, +// "name": "StatementFalse", +// "msg": "StatementFalse" +// }, +// { +// "code": 6006, +// "name": "NotRentExempt", +// "msg": "NotRentExempt" +// }, +// { +// "code": 6007, +// "name": "NumericalOverflow", +// "msg": "NumericalOverflow" +// }, +// { +// "code": 6008, +// "name": "ExpectedSolAccount", +// "msg": "Expected a sol account but got an spl token account instead" +// }, +// { +// "code": 6009, +// "name": "CannotExchangeSOLForSol", +// "msg": "Cannot exchange sol for sol" +// }, +// { +// "code": 6010, +// "name": "SOLWalletMustSign", +// "msg": "If paying with sol, sol wallet must be signer" +// }, +// { +// "code": 6011, +// "name": "CannotTakeThisActionWithoutAuctionHouseSignOff", +// "msg": "Cannot take this action without auction house signing too" +// }, +// { +// "code": 6012, +// "name": "NoPayerPresent", +// "msg": "No payer present on this txn" +// }, +// { +// "code": 6013, +// "name": "DerivedKeyInvalid", +// "msg": "Derived key invalid" +// }, +// { +// "code": 6014, +// "name": "MetadataDoesntExist", +// "msg": "Metadata doesn't exist" +// }, +// { +// "code": 6015, +// "name": "InvalidTokenAmount", +// "msg": "Invalid token amount" +// }, +// { +// "code": 6016, +// "name": "BothPartiesNeedToAgreeToSale", +// "msg": "Both parties need to agree to this sale" +// }, +// { +// "code": 6017, +// "name": "CannotMatchFreeSalesWithoutAuctionHouseOrSellerSignoff", +// "msg": "Cannot match free sales unless the auction house or seller signs off" +// }, +// { +// "code": 6018, +// "name": "SaleRequiresSigner", +// "msg": "This sale requires a signer" +// }, +// { +// "code": 6019, +// "name": "OldSellerNotInitialized", +// "msg": "Old seller not initialized" +// }, +// { +// "code": 6020, +// "name": "SellerATACannotHaveDelegate", +// "msg": "Seller ata cannot have a delegate set" +// }, +// { +// "code": 6021, +// "name": "BuyerATACannotHaveDelegate", +// "msg": "Buyer ata cannot have a delegate set" +// }, +// { +// "code": 6022, +// "name": "NoValidSignerPresent", +// "msg": "No valid signer present" +// }, +// { +// "code": 6023, +// "name": "InvalidBasisPoints", +// "msg": "BP must be less than or equal to 10000" +// }, +// { +// "code": 6024, +// "name": "TradeStateDoesntExist", +// "msg": "The trade state account does not exist" +// }, +// { +// "code": 6025, +// "name": "TradeStateIsNotEmpty", +// "msg": "The trade state is not empty" +// }, +// { +// "code": 6026, +// "name": "ReceiptIsEmpty", +// "msg": "The receipt is empty" +// }, +// { +// "code": 6027, +// "name": "InstructionMismatch", +// "msg": "The instruction does not match" +// }, +// { +// "code": 6028, +// "name": "InvalidAuctioneer", +// "msg": "Invalid Auctioneer for this Auction House instance." +// }, +// { +// "code": 6029, +// "name": "MissingAuctioneerScope", +// "msg": "The Auctioneer does not have the correct scope for this action." +// }, +// { +// "code": 6030, +// "name": "MustUseAuctioneerHandler", +// "msg": "Must use auctioneer handler." +// }, +// { +// "code": 6031, +// "name": "NoAuctioneerProgramSet", +// "msg": "No Auctioneer program set." +// }, +// { +// "code": 6032, +// "name": "TooManyScopes", +// "msg": "Too many scopes." +// }, +// { +// "code": 6033, +// "name": "AuctionHouseNotDelegated", +// "msg": "Auction House not delegated." +// }, +// { +// "code": 6034, +// "name": "BumpSeedNotInHashMap", +// "msg": "Bump seed not in hash map." +// }, +// { +// "code": 6035, +// "name": "EscrowUnderRentExemption", +// "msg": "The instruction would drain the escrow below rent exemption threshold" +// }, +// { +// "code": 6036, +// "name": "InvalidSeedsOrAuctionHouseNotDelegated", +// "msg": "Invalid seeds or Auction House not delegated" +// }, +// { +// "code": 6037, +// "name": "BuyerTradeStateNotValid", +// "msg": "The buyer trade state was unable to be initialized." +// }, +// { +// "code": 6038, +// "name": "MissingElementForPartialOrder", +// "msg": "Partial order size and price must both be provided in a partial buy." +// }, +// { +// "code": 6039, +// "name": "NotEnoughTokensAvailableForPurchase", +// "msg": "Amount of tokens available for purchase is less than the partial order amount." +// }, +// { +// "code": 6040, +// "name": "PartialPriceMismatch", +// "msg": "Calculated partial price does not not partial price that was provided." +// }, +// { +// "code": 6041, +// "name": "AuctionHouseAlreadyDelegated", +// "msg": "Auction House already delegated." +// }, +// { +// "code": 6042, +// "name": "AuctioneerAuthorityMismatch", +// "msg": "Auctioneer Authority Mismatch" +// }, +// { +// "code": 6043, +// "name": "InsufficientFunds", +// "msg": "Insufficient funds in escrow account to purchase." +// } +// ] +// } +// """.trimIndent() \ No newline at end of file diff --git a/lib/src/main/java/com/metaplex/lib/modules/auctions/AuctionHouseClient.kt b/lib/src/main/java/com/metaplex/lib/modules/auctions/AuctionHouseClient.kt index 1555392..c55cdf7 100644 --- a/lib/src/main/java/com/metaplex/lib/modules/auctions/AuctionHouseClient.kt +++ b/lib/src/main/java/com/metaplex/lib/modules/auctions/AuctionHouseClient.kt @@ -11,11 +11,21 @@ import com.metaplex.lib.Metaplex import com.metaplex.lib.drivers.indenty.IdentityDriver import com.metaplex.lib.drivers.solana.Connection import com.metaplex.lib.drivers.solana.getRecentBlockhash +import com.metaplex.lib.extensions.signSendAndConfirm +import com.metaplex.lib.modules.auctions.builders.AuctionHouseBuyTransactionBuilder +import com.metaplex.lib.modules.auctions.builders.AuctionHouseCancelTransactionBuilder import com.metaplex.lib.modules.auctions.models.* +import com.metaplex.lib.modules.nfts.operations.FindNftByMintOnChainOperationHandler +import com.metaplex.lib.modules.token.operations.FindFungibleTokenByMintOnChainOperationHandler +import com.metaplex.lib.modules.token.operations.FindTokenMetadataAccountOperation +import com.metaplex.lib.programs.token_metadata.accounts.MetadataAccount import com.solana.core.PublicKey import com.solana.core.Transaction import com.solana.programs.AssociatedTokenProgram import com.solana.programs.TokenProgram +import kotlinx.coroutines.CoroutineDispatcher +import kotlinx.coroutines.Dispatchers +import kotlinx.serialization.builtins.ByteArraySerializer import kotlin.coroutines.suspendCoroutine /** @@ -25,10 +35,10 @@ import kotlin.coroutines.suspendCoroutine * * @author Funkatronics */ -class AuctionHouseClient(val auctionHouse: AuctionHouse, val connectionDriver: Connection, - // dog_using_computer.jpg - // let the caller figure out signing, or pass in all signer accounts explicitly? - val signer: IdentityDriver) { +class AuctionHouseClient( + val auctionHouse: AuctionHouse, val connection: Connection, val signer: IdentityDriver, + val dispatcher: CoroutineDispatcher = Dispatchers.IO +) { constructor(metaplex: Metaplex, auctionHouse: AuctionHouse) : this(auctionHouse, metaplex.connection, metaplex.identity()) @@ -47,9 +57,10 @@ class AuctionHouseClient(val auctionHouse: AuctionHouse, val connectionDriver: C Listing(auctionHouse, seller, authority, mintAccount = mint, price = price, tokens = tokens).apply { - buildTransaction(printReceipt).signAndSend().getOrElse { - return Result.failure(it) // we cant proceed further, return the error - } + buildTransaction(printReceipt).signSendAndConfirm(connection, signer, listOf()) + .getOrElse { + return Result.failure(it) // we cant proceed further, return the error + } return Result.success(this) } @@ -68,10 +79,28 @@ class AuctionHouseClient(val auctionHouse: AuctionHouse, val connectionDriver: C Bid(auctionHouse, mint, buyer, authority, price = price, tokens = tokens).apply { - buildTransaction(printReceipt).signAndSend().getOrElse { - return Result.failure(it) // we cant proceed further, return the error + if (tokenAccount == null) { + connection.getAccountInfo(ByteArraySerializer(), buyerTokenAccount).getOrElse { + val associatedTokenAddress = PublicKey.associatedTokenAddress(buyer, mint).address + Transaction().addInstruction( + AssociatedTokenProgram.createAssociatedTokenAccountInstruction( + mint = mint, + associatedAccount = associatedTokenAddress, + owner = buyer, + payer = signer.publicKey + ) + ).signSendAndConfirm(connection, signer, listOf()) + .getOrElse { + return Result.failure(it) // we cant proceed further, return the error + } + } } + buildTransaction(printReceipt).signSendAndConfirm(connection, signer, listOf()) + .getOrElse { + return Result.failure(it) // we cant proceed further, return the error + } + return Result.success(this) } } @@ -94,45 +123,35 @@ class AuctionHouseClient(val auctionHouse: AuctionHouse, val connectionDriver: C auctioneerAuthority, bid.buyerTradeState.address, listing.sellerTradeState.address, bid.price, bid.tokens).apply { - buildTransaction(printReceipt).signAndSend().getOrElse { - return Result.failure(it) // we cant proceed further, return the error - } + val assetMetadata = FindTokenMetadataAccountOperation(connection) + .run(MetadataAccount.pda(listing.mintAccount).getOrThrows()).getOrThrow().data + + val creators = assetMetadata?.data?.creators?.map { it.address } ?: listOf() + + AuctionHouseBuyTransactionBuilder(auctionHouse, this, printReceipt, connection, dispatcher) + .addCreators(creators) + .build() + .getOrThrow() + .signSendAndConfirm(connection, signer) + .getOrElse { + return Result.failure(it) // we cant proceed further, return the error + } return Result.success(this) } } suspend fun cancelListing(listing: Listing, mint: PublicKey, - authority: PublicKey? = null): Result = - buildAuctionCancelInstruction(auctionHouse, - listing.seller, mint, listing.sellerTradeState.address, - listing.price, listing.tokens, listing.receiptAddress.address, authority - ).signAndSend() - - suspend fun cancelBid(mint: PublicKey, bid: Bid, authority: PublicKey? = null): Result = - buildAuctionCancelInstruction(auctionHouse, - bid.buyer, mint, bid.buyerTradeState.address, - bid.price, bid.tokens, bid.receiptAddress.address, authority - ).signAndSend() - - private suspend fun Transaction.signAndSend(): Result { - - setRecentBlockHash(connectionDriver.getRecentBlockhash().getOrElse { - return Result.failure(it) // we cant proceed further, return the error - }) - - // TODO: refactor identity driver to use coroutines? - return Result.success( - suspendCoroutine { continuation -> - signer.signTransaction(this) { result -> - result.onSuccess { signedTx -> - - // TODO: I think I would prefer to handle the send here rather than - // delegating to the identity driver, but #we'llgetthere - signer.sendTransaction(signedTx) { continuation.resumeWith(it) } - }.onFailure { continuation.resumeWith(Result.failure(it)) } - } - }) + auctioneerAuthority: PublicKey? = null): Result = runCatching { + return AuctionHouseCancelTransactionBuilder(auctionHouse, listing, mint, auctioneerAuthority, + connection, dispatcher) + .build().getOrThrow().signSendAndConfirm(connection, signer) + } + + suspend fun cancelBid(mint: PublicKey, bid: Bid, authority: PublicKey? = null): Result = runCatching { + return AuctionHouseCancelTransactionBuilder(auctionHouse, bid, mint, authority, + connection, dispatcher) + .build().getOrThrow().signSendAndConfirm(connection, signer) } } diff --git a/lib/src/main/java/com/metaplex/lib/modules/auctions/AuctionsClient.kt b/lib/src/main/java/com/metaplex/lib/modules/auctions/AuctionsClient.kt index 1d46a43..a6bfa22 100644 --- a/lib/src/main/java/com/metaplex/lib/modules/auctions/AuctionsClient.kt +++ b/lib/src/main/java/com/metaplex/lib/modules/auctions/AuctionsClient.kt @@ -7,9 +7,20 @@ package com.metaplex.lib.modules.auctions +import com.metaplex.lib.drivers.indenty.IdentityDriver import com.metaplex.lib.drivers.solana.getAccountInfo import com.metaplex.lib.modules.auctions.models.AuctionHouse import com.metaplex.lib.drivers.solana.Connection +import com.metaplex.lib.drivers.solana.TransactionOptions +import com.metaplex.lib.experimental.jen.auctionhouse.BidReceipt +import com.metaplex.lib.experimental.jen.auctionhouse.ListingReceipt +import com.metaplex.lib.extensions.signSendAndConfirm +import com.metaplex.lib.modules.auctions.builders.CreateAuctionHouseTransactionBuilder +import com.metaplex.lib.modules.auctions.models.Bid +import com.metaplex.lib.modules.auctions.models.Listing +import com.metaplex.lib.modules.auctions.operations.FindAuctionHouseByAddressOperation +import com.metaplex.lib.modules.token.WRAPPED_SOL_MINT_ADDRESS +import com.metaplex.lib.modules.token.operations.FindTokenMetadataAccountOperation import com.solana.core.PublicKey import kotlinx.coroutines.* @@ -18,19 +29,17 @@ import kotlinx.coroutines.* * * @author Funkatronics */ -class AuctionsClient(val connectionDriver: Connection) { +class AuctionsClient(val connection: Connection, val signer: IdentityDriver, + private val dispatcher: CoroutineDispatcher = Dispatchers.IO, + private val txOptions: TransactionOptions = connection.transactionOptions) { /** * Attempts to find an AuctionHouse account on chain via its [address] */ - suspend fun findAuctionHouseByAddress(address: PublicKey): Result { - // temporary cast to ConnectionKt until suspend funs are merged into Connection - connectionDriver.apply { - return getAccountInfo(address).map { - it.data!! // safe unwrap, successful result will not have null - } + suspend fun findAuctionHouseByAddress(address: PublicKey): Result = + withContext(dispatcher) { + FindAuctionHouseByAddressOperation(connection).run(address) } - } /** * Attempts to find an AuctionHouse account on chain via its [creator] address and @@ -38,7 +47,61 @@ class AuctionsClient(val connectionDriver: Connection) { */ suspend fun findAuctionHouseByCreatorAndMint(creator: PublicKey, treasuryMint: PublicKey): Result = - findAuctionHouseByAddress(AuctionHouse.pda(creator, treasuryMint)) + findAuctionHouseByAddress(AuctionHouse.pda(creator, treasuryMint).address) + + /** + * Attempts to find a Listing account on chain via its receipt [address] + */ + suspend fun findListingByReceipt(address: PublicKey): Result { + connection.apply { + return getAccountInfo(address).map { + it.data!!.let { receipt ->// safe unwrap, successful result will not have null + val auctionHouse = findAuctionHouseByAddress(receipt.auctionHouse).getOrThrow() + val metadata = FindTokenMetadataAccountOperation(connection) + .run(receipt.metadata).getOrThrow().data!! + + Listing(auctionHouse, + receipt.seller, + auctionHouse.authority, + null, + metadata.mint, + PublicKey.associatedTokenAddress(receipt.seller, metadata.mint).address, + receipt.price.toLong(), + receipt.tokenSize.toLong(), + receipt.bookkeeper, + receipt.canceledAt + ) + } + } + } + } + + /** + * Attempts to find a Listing account on chain via its receipt [address] + */ + suspend fun findBidByReceipt(address: PublicKey): Result { + connection.apply { + return getAccountInfo(address).map { + it.data!!.let { receipt ->// safe unwrap, successful result will not have null + val auctionHouse = findAuctionHouseByAddress(receipt.auctionHouse).getOrThrow() + val metadata = FindTokenMetadataAccountOperation(connection) + .run(receipt.metadata).getOrThrow().data!! + + Bid(auctionHouse, + metadata.mint, + receipt.buyer, + auctionHouse.authority, + null, + null, + receipt.price.toLong(), + receipt.tokenSize.toLong(), + receipt.bookkeeper, + receipt.canceledAt + ) + } + } + } + } /** * Async-callback version of [findAuctionHouseByAddress] @@ -56,4 +119,32 @@ class AuctionsClient(val connectionDriver: Connection) { CoroutineScope(Dispatchers.IO).launch { onComplete(findAuctionHouseByCreatorAndMint(creator, mint)) } + + suspend fun createAuctionHouse( + sellerFeeBasisPoints: Int, + canChangeSalePrice: Boolean = false, + requireSignOff: Boolean = canChangeSalePrice, + treasuryMint: PublicKey = PublicKey(WRAPPED_SOL_MINT_ADDRESS), + authority: PublicKey = signer.publicKey, + transactionOptions: TransactionOptions = txOptions + ): Result { + + AuctionHouse( + treasuryWithdrawalDestinationOwner = signer.publicKey, + feeWithdrawalDestination = signer.publicKey, + treasuryMint = treasuryMint, + authority = authority, + creator = signer.publicKey, + sellerFeeBasisPoints = sellerFeeBasisPoints.toUShort(), + requiresSignOff = requireSignOff, + canChangeSalePrice = canChangeSalePrice + ).apply { + CreateAuctionHouseTransactionBuilder(this, signer.publicKey, connection, dispatcher) + .build() + .getOrThrow() + .signSendAndConfirm(connection, signer, listOf(), transactionOptions) + + return Result.success(this) + } + } } \ No newline at end of file diff --git a/lib/src/main/java/com/metaplex/lib/modules/auctions/builders/AuctionHouseBuyTransactionBuilder.kt b/lib/src/main/java/com/metaplex/lib/modules/auctions/builders/AuctionHouseBuyTransactionBuilder.kt new file mode 100644 index 0000000..d08b4a3 --- /dev/null +++ b/lib/src/main/java/com/metaplex/lib/modules/auctions/builders/AuctionHouseBuyTransactionBuilder.kt @@ -0,0 +1,133 @@ +/* + * AuctionHouseBuyTransactionBuilder + * Metaplex + * + * Created by Funkatronics on 10/21/2022 + */ + +package com.metaplex.lib.modules.auctions.builders + +import com.metaplex.lib.drivers.solana.Connection +import com.metaplex.lib.experimental.jen.auctionhouse.AuctionHouseInstructions +import com.metaplex.lib.modules.auctions.SYSVAR_INSTRUCTIONS_PUBKEY +import com.metaplex.lib.modules.auctions.associatedTokenAddress +import com.metaplex.lib.modules.auctions.models.* +import com.metaplex.lib.shared.builders.TransactionBuilder +import com.solana.core.* +import com.solana.programs.AssociatedTokenProgram +import com.solana.programs.SystemProgram +import com.solana.programs.TokenProgram +import kotlinx.coroutines.CoroutineDispatcher +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.withContext + +class AuctionHouseBuyTransactionBuilder( + val auctionHouse: AuctionHouse, val purchase: Purchase, val printReceipt: Boolean = true, + connection: Connection, dispatcher: CoroutineDispatcher = Dispatchers.IO +) : TransactionBuilder(purchase.buyer, connection, dispatcher) { + + var creators = listOf(purchase.seller) + + fun addCreators(creators: List): AuctionHouseBuyTransactionBuilder { + this.creators = creators + return this + } + + override suspend fun build(): Result = withContext(dispatcher) { + Result.success(Transaction().apply { + purchase.apply { + + val programAsSigner = AuctionHouse.programAsSignerPda() + + val saleInstruction = auctioneerAuthority?.let { + AuctionHouseInstructions.auctioneerExecuteSale( + buyer = buyer, seller = seller, + tokenAccount = assetTokenAccount, + tokenMint = mintAccount, + metadata = assetMetadata, + treasuryMint = auctionHouse.treasuryMint, + escrowPaymentAccount = escrowPayment.address, + sellerPaymentReceiptAccount = sellerPaymentReceiptAccount, + buyerReceiptTokenAccount = buyerReceiptTokenAccount, + authority = auctionHouse.authority, + auctioneerAuthority = auctioneerAuthority, + auctionHouse = auctionHouse.address, + auctionHouseFeeAccount = auctionHouse.auctionHouseFeeAccount, + auctionHouseTreasury = auctionHouse.auctionHouseTreasury, + buyerTradeState = buyerTradeState, + sellerTradeState = sellerTradeState, + freeTradeState = freeTradeState.address, + ahAuctioneerPda = auctionHouse.auctioneerPda(auctioneerAuthority), + tokenProgram = TokenProgram.PROGRAM_ID, + systemProgram = SystemProgram.PROGRAM_ID, + ataProgram = AssociatedTokenProgram.SPL_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID, + programAsSigner = programAsSigner.address, + rent = Sysvar.SYSVAR_RENT_ADDRESS, + freeTradeStateBump = freeTradeState.nonce.toUByte(), + escrowPaymentBump = escrowPayment.nonce.toUByte(), + programAsSignerBump = programAsSigner.nonce.toUByte(), + buyerPrice = price.toULong(), + tokenSize = tokens.toULong() + ) + } ?: AuctionHouseInstructions.executeSale( + buyer = buyer, seller = seller, + tokenAccount = assetTokenAccount, + tokenMint = mintAccount, + metadata = assetMetadata, + treasuryMint = auctionHouse.treasuryMint, + escrowPaymentAccount = escrowPayment.address, + sellerPaymentReceiptAccount = sellerPaymentReceiptAccount, + buyerReceiptTokenAccount = buyerReceiptTokenAccount, + authority = auctionHouse.authority, + auctionHouse = auctionHouse.address, + auctionHouseFeeAccount = auctionHouse.auctionHouseFeeAccount, + auctionHouseTreasury = auctionHouse.auctionHouseTreasury, + buyerTradeState = buyerTradeState, + sellerTradeState = sellerTradeState, + freeTradeState = freeTradeState.address, + tokenProgram = TokenProgram.PROGRAM_ID, + systemProgram = SystemProgram.PROGRAM_ID, + ataProgram = AssociatedTokenProgram.SPL_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID, + programAsSigner = programAsSigner.address, + rent = Sysvar.SYSVAR_RENT_ADDRESS, + freeTradeStateBump = freeTradeState.nonce.toUByte(), + escrowPaymentBump = escrowPayment.nonce.toUByte(), + programAsSignerBump = programAsSigner.nonce.toUByte(), + buyerPrice = price.toULong(), + tokenSize = tokens.toULong() + ) + + val additionalAccounts = mutableListOf() + + creators.forEach { address -> + additionalAccounts.add(AccountMeta(address, false, true)) + + if (!auctionHouse.isNative) + additionalAccounts.add(AccountMeta(PublicKey.associatedTokenAddress(address, mintAccount).address, false, true)) + } + + addInstruction(TransactionInstruction(saleInstruction.programId, saleInstruction.keys + additionalAccounts, saleInstruction.data)) + + if (printReceipt) { + + val listingReceipt = AuctionHouse.listingReceiptPda(sellerTradeState) + val bidReceipt = AuctionHouse.bidReceiptPda(buyerTradeState) + val purchaseReceipt = AuctionHouse.purchaseReceiptPda(sellerTradeState, buyerTradeState) + + addInstruction( + AuctionHouseInstructions.printPurchaseReceipt( + purchaseReceipt = purchaseReceipt.address, + listingReceipt = listingReceipt.address, + bidReceipt = bidReceipt.address, + bookkeeper = bookkeeper, + systemProgram = SystemProgram.PROGRAM_ID, + rent = Sysvar.SYSVAR_RENT_ADDRESS, + instruction = PublicKey(SYSVAR_INSTRUCTIONS_PUBKEY), + purchaseReceiptBump = purchaseReceipt.nonce.toUByte() + ) + ) + } + } + }) + } +} \ No newline at end of file diff --git a/lib/src/main/java/com/metaplex/lib/modules/auctions/builders/AuctionHouseCancelTransactionBuilder.kt b/lib/src/main/java/com/metaplex/lib/modules/auctions/builders/AuctionHouseCancelTransactionBuilder.kt new file mode 100644 index 0000000..24af5db --- /dev/null +++ b/lib/src/main/java/com/metaplex/lib/modules/auctions/builders/AuctionHouseCancelTransactionBuilder.kt @@ -0,0 +1,101 @@ +/* + * AuctionHouseCancelTransactionBuilder + * Metaplex + * + * Created by Funkatronics on 10/21/2022 + */ + +package com.metaplex.lib.modules.auctions.builders + +import com.metaplex.lib.drivers.solana.Connection +import com.metaplex.lib.experimental.jen.auctionhouse.AuctionHouseInstructions +import com.metaplex.lib.modules.auctions.SYSVAR_INSTRUCTIONS_PUBKEY +import com.metaplex.lib.modules.auctions.associatedTokenAddress +import com.metaplex.lib.modules.auctions.models.* +import com.metaplex.lib.shared.builders.TransactionBuilder +import com.solana.core.PublicKey +import com.solana.core.Transaction +import com.solana.programs.SystemProgram +import com.solana.programs.TokenProgram +import kotlinx.coroutines.CoroutineDispatcher +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.withContext + +class AuctionHouseCancelTransactionBuilder( + val auctionHouse: AuctionHouse, val wallet: PublicKey, val mint: PublicKey, + val tradeState: PublicKey, val price: Long, val tokenSize: Long, + val purchaseReceipt: PublicKey? = null, val authority: PublicKey? = null, + val mode: Mode = Mode.LISTING, + connection: Connection, dispatcher: CoroutineDispatcher = Dispatchers.IO +) : TransactionBuilder(wallet, connection, dispatcher) { + + enum class Mode { + LISTING, BID + } + + constructor(auctionHouse: AuctionHouse, listing: Listing, mint: PublicKey, + auctioneerAuthority: PublicKey? = null, connection: Connection, + dispatcher: CoroutineDispatcher = Dispatchers.IO) : this(auctionHouse, + listing.seller, mint, listing.sellerTradeState.address, listing.price, listing.tokens, + listing.receiptAddress.address, auctioneerAuthority, Mode.LISTING, connection, dispatcher + ) + + constructor(auctionHouse: AuctionHouse, bid: Bid, mint: PublicKey, + auctioneerAuthority: PublicKey? = null, connection: Connection, + dispatcher: CoroutineDispatcher = Dispatchers.IO) : this(auctionHouse, + bid.buyer, mint, bid.buyerTradeState.address, bid.price, bid.tokens, + bid.receiptAddress.address, auctioneerAuthority, Mode.BID, connection, dispatcher + ) + + override suspend fun build(): Result = withContext(dispatcher) { + + val tokenAccount = PublicKey.associatedTokenAddress(wallet, mint).address + + Result.success(Transaction().apply { + addInstruction( + authority?.let { + AuctionHouseInstructions.auctioneerCancel( + wallet = wallet, + tokenAccount = tokenAccount, + tokenMint = mint, + authority = auctionHouse.authority, + auctioneerAuthority = authority, + auctionHouse = auctionHouse.address, + auctionHouseFeeAccount = auctionHouse.feeAccountPda().address, + tradeState = tradeState, + ahAuctioneerPda = auctionHouse.auctioneerPda(authority), + tokenProgram = TokenProgram.PROGRAM_ID, + buyerPrice = price.toULong(), + tokenSize = tokenSize.toULong() + ) + } ?: AuctionHouseInstructions.cancel( + wallet = wallet, + tokenAccount = tokenAccount, + tokenMint = mint, + authority = auctionHouse.authority, + auctionHouse = auctionHouse.address, + auctionHouseFeeAccount = auctionHouse.feeAccountPda().address, + tokenProgram = TokenProgram.PROGRAM_ID, + tradeState = tradeState, + buyerPrice = price.toULong(), + tokenSize = tokenSize.toULong() + ) + ) + + purchaseReceipt?.let { + addInstruction( when (mode) { + Mode.LISTING -> AuctionHouseInstructions.cancelListingReceipt( + receipt = purchaseReceipt, + instruction = PublicKey(SYSVAR_INSTRUCTIONS_PUBKEY), + systemProgram = SystemProgram.PROGRAM_ID + ) + Mode.BID -> AuctionHouseInstructions.cancelBidReceipt( + receipt = purchaseReceipt, + instruction = PublicKey(SYSVAR_INSTRUCTIONS_PUBKEY), + systemProgram = SystemProgram.PROGRAM_ID + ) + }) + } + }) + } +} \ No newline at end of file diff --git a/lib/src/main/java/com/metaplex/lib/modules/auctions/builders/CreateAuctionHouseTransactionBuilder.kt b/lib/src/main/java/com/metaplex/lib/modules/auctions/builders/CreateAuctionHouseTransactionBuilder.kt new file mode 100644 index 0000000..fbd3780 --- /dev/null +++ b/lib/src/main/java/com/metaplex/lib/modules/auctions/builders/CreateAuctionHouseTransactionBuilder.kt @@ -0,0 +1,74 @@ +/* + * CreateAuctionHouseTransactionBuilder + * Metaplex + * + * Created by Funkatronics on 10/20/2022 + */ + +package com.metaplex.lib.modules.auctions.builders + +import com.metaplex.lib.drivers.solana.Connection +import com.metaplex.lib.experimental.jen.auctionhouse.AuctionHouseInstructions +import com.metaplex.lib.modules.auctions.associatedTokenAddress +import com.metaplex.lib.modules.auctions.models.AuctionHouse +import com.metaplex.lib.modules.auctions.models.feeAccountPda +import com.metaplex.lib.modules.auctions.models.treasuryAccountPda +import com.metaplex.lib.modules.token.WRAPPED_SOL_MINT_ADDRESS +import com.metaplex.lib.shared.builders.TransactionBuilder +import com.solana.core.PublicKey +import com.solana.core.Sysvar +import com.solana.core.Transaction +import com.solana.programs.AssociatedTokenProgram +import com.solana.programs.SystemProgram +import com.solana.programs.TokenProgram +import kotlinx.coroutines.CoroutineDispatcher +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.withContext + +class CreateAuctionHouseTransactionBuilder(val auctionHouse: AuctionHouse, + payer: PublicKey, connection: Connection, + dispatcher: CoroutineDispatcher = Dispatchers.IO) + : TransactionBuilder(payer, connection, dispatcher) { + + override suspend fun build(): Result = withContext(dispatcher) { + Result.success(Transaction().apply { + auctionHouse.apply { + + val auctionHousePda = AuctionHouse.pda(authority, treasuryMint) + val feeAccountPda = feeAccountPda() + val treasuryAccountPda = treasuryAccountPda() + val treasuryWithdrawalDestination = + if (treasuryMint == PublicKey(WRAPPED_SOL_MINT_ADDRESS)) + treasuryWithdrawalDestinationOwner + else + PublicKey.associatedTokenAddress( + treasuryMint, treasuryWithdrawalDestinationOwner + ).address + + // Initialize the candy machine account. + addInstruction( + AuctionHouseInstructions.createAuctionHouse( + treasuryMint, + payer, + authority, + feeWithdrawalDestination, + treasuryWithdrawalDestination, + treasuryWithdrawalDestinationOwner, + auctionHouse = auctionHousePda.address, + auctionHouseFeeAccount = feeAccountPda.address, + auctionHouseTreasury = treasuryAccountPda.address, + tokenProgram = TokenProgram.PROGRAM_ID, + systemProgram = SystemProgram.PROGRAM_ID, + ataProgram = AssociatedTokenProgram.SPL_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID, + rent = Sysvar.SYSVAR_RENT_ADDRESS, + bump = auctionHousePda.nonce.toUByte(), + feePayerBump = feeAccountPda.nonce.toUByte(), + treasuryBump = treasuryAccountPda.nonce.toUByte(), + sellerFeeBasisPoints = sellerFeeBasisPoints, + requiresSignOff = requiresSignOff, + canChangeSalePrice = canChangeSalePrice + )) + } + }) + } +} \ No newline at end of file diff --git a/lib/src/main/java/com/metaplex/lib/modules/auctions/models/AuctionHouse.kt b/lib/src/main/java/com/metaplex/lib/modules/auctions/models/AuctionHouse.kt index 929e25e..b6c4bc1 100644 --- a/lib/src/main/java/com/metaplex/lib/modules/auctions/models/AuctionHouse.kt +++ b/lib/src/main/java/com/metaplex/lib/modules/auctions/models/AuctionHouse.kt @@ -8,30 +8,25 @@ package com.metaplex.lib.modules.auctions.models +import com.metaplex.lib.modules.token.WRAPPED_SOL_MINT_ADDRESS import com.metaplex.lib.serialization.serializers.solana.PublicKeyAs32ByteSerializer import com.solana.core.PublicKey import kotlinx.serialization.* import java.nio.ByteBuffer +import java.nio.ByteOrder import java.nio.charset.StandardCharsets @Serializable data class AuctionHouse( - val auctionHouseFeeAccount: PublicKey, - val auctionHouseTreasury: PublicKey, - val treasuryWithdrawalDestination: PublicKey, + val treasuryWithdrawalDestinationOwner: PublicKey, val feeWithdrawalDestination: PublicKey, - val treasuryMint: PublicKey, + val treasuryMint: PublicKey = PublicKey(WRAPPED_SOL_MINT_ADDRESS), val authority: PublicKey, val creator: PublicKey, - val bump: UByte, - val treasuryBump: UByte, - val feePayerBump: UByte, val sellerFeeBasisPoints: UShort, - val requiresSignOff: Boolean, - val canChangeSalePrice: Boolean, - val escrowPaymentBump: UByte, - val hasAuctioneer: Boolean, - val auctioneerPdaBump: UByte + val requiresSignOff: Boolean = false, + val canChangeSalePrice: Boolean = false, + val hasAuctioneer: Boolean = false ) { companion object { const val PROGRAM_NAME = "auction_house" @@ -42,59 +37,75 @@ data class AuctionHouse( PROGRAM_NAME.toByteArray(StandardCharsets.UTF_8), creator.toByteArray(), treasuryMint.toByteArray() - ), PublicKey(PROGRAM_ADDRESS)).address + ), PublicKey(PROGRAM_ADDRESS)) } } -val AuctionHouse.address get() = AuctionHouse.pda(creator, treasuryMint) +val AuctionHouse.address get() = AuctionHouse.pda(creator, treasuryMint).address +val AuctionHouse.auctionHouseFeeAccount get() = feeAccountPda().address +val AuctionHouse.auctionHouseTreasury get() = treasuryAccountPda().address // TODO: is this correct? is there a better way to check this? val AuctionHouse.isNative get() = - treasuryMint == PublicKey("So11111111111111111111111111111111111111112") + treasuryMint == PublicKey(WRAPPED_SOL_MINT_ADDRESS) //region PDAs +fun AuctionHouse.feeAccountPda() = + PublicKey.findProgramAddress(listOf( + AuctionHouse.PROGRAM_NAME.toByteArray(Charsets.UTF_8), + address.toByteArray(), + "fee_payer".toByteArray(Charsets.UTF_8) + ), PublicKey(AuctionHouse.PROGRAM_ADDRESS)) + +fun AuctionHouse.treasuryAccountPda() = + PublicKey.findProgramAddress(listOf( + AuctionHouse.PROGRAM_NAME.toByteArray(Charsets.UTF_8), + address.toByteArray(), + "treasury".toByteArray(Charsets.UTF_8) + ), PublicKey(AuctionHouse.PROGRAM_ADDRESS)) + fun AuctionHouse.Companion.programAsSignerPda() = PublicKey.findProgramAddress(listOf( - PROGRAM_NAME.toByteArray(), - "signer".toByteArray() + PROGRAM_NAME.toByteArray(Charsets.UTF_8), + "signer".toByteArray(Charsets.UTF_8) ), PublicKey(PROGRAM_ADDRESS)) fun AuctionHouse.Companion.listingReceiptPda(tradeState: PublicKey) = PublicKey.findProgramAddress(listOf( - "listing_receipt".toByteArray(), + "listing_receipt".toByteArray(Charsets.UTF_8), tradeState.toByteArray() ), PublicKey(PROGRAM_ADDRESS)) fun AuctionHouse.Companion.bidReceiptPda(tradeState: PublicKey) = PublicKey.findProgramAddress(listOf( - "bid_receipt".toByteArray(), + "bid_receipt".toByteArray(Charsets.UTF_8), tradeState.toByteArray() ), PublicKey(PROGRAM_ADDRESS)) fun AuctionHouse.Companion.purchaseReceiptPda(sellerTradeState: PublicKey, buyerTradeState: PublicKey) = PublicKey.findProgramAddress(listOf( - "purchase_receipt".toByteArray(), + "purchase_receipt".toByteArray(Charsets.UTF_8), sellerTradeState.toByteArray(), buyerTradeState.toByteArray(), ), PublicKey(PROGRAM_ADDRESS)) fun AuctionHouse.tokenAccountPda(auctioneerAuthority: PublicKey) = PublicKey.findProgramAddress(listOf( - "auctioneer".toByteArray(), + "auctioneer".toByteArray(Charsets.UTF_8), address.toByteArray(), auctioneerAuthority.toByteArray() ), PublicKey(AuctionHouse.PROGRAM_ADDRESS)).address fun AuctionHouse.auctioneerPda(auctioneerAuthority: PublicKey) = PublicKey.findProgramAddress(listOf( - "auctioneer".toByteArray(), + "auctioneer".toByteArray(Charsets.UTF_8), address.toByteArray(), auctioneerAuthority.toByteArray() ), PublicKey(AuctionHouse.PROGRAM_ADDRESS)).address fun AuctionHouse.buyerEscrowPda(buyer: PublicKey) = PublicKey.findProgramAddress(listOf( - AuctionHouse.PROGRAM_NAME.toByteArray(), + AuctionHouse.PROGRAM_NAME.toByteArray(Charsets.UTF_8), address.toByteArray(), buyer.toByteArray() ), PublicKey(AuctionHouse.PROGRAM_ADDRESS)) @@ -102,13 +113,15 @@ fun AuctionHouse.buyerEscrowPda(buyer: PublicKey) = fun AuctionHouse.tradeStatePda(wallet: PublicKey, mintAccount: PublicKey, price: Long, tokens: Long, tokenAccount: PublicKey?) = PublicKey.findProgramAddress(listOf( - AuctionHouse.PROGRAM_NAME.toByteArray(), // program name + AuctionHouse.PROGRAM_NAME.toByteArray(Charsets.UTF_8), // program name wallet.toByteArray(), // wallet address.toByteArray(), // auction house tokenAccount?.toByteArray() ?: byteArrayOf(), // optional token account treasuryMint.toByteArray(), // treasury mint mintAccount.toByteArray(), // token mint - ByteBuffer.allocate(Long.SIZE_BYTES).putLong(price).array(), // price as long - ByteBuffer.allocate(Long.SIZE_BYTES).putLong(tokens).array(), // token size (?) + ByteBuffer.allocate(Long.SIZE_BYTES) + .order(ByteOrder.LITTLE_ENDIAN).putLong(price).array(), // price as long + ByteBuffer.allocate(Long.SIZE_BYTES) + .order(ByteOrder.LITTLE_ENDIAN).putLong(tokens).array(), // token size (?) ), PublicKey(AuctionHouse.PROGRAM_ADDRESS)) //endregion \ No newline at end of file diff --git a/lib/src/main/java/com/metaplex/lib/modules/auctions/models/Bid.kt b/lib/src/main/java/com/metaplex/lib/modules/auctions/models/Bid.kt index 71d75ee..8c7e4e7 100644 --- a/lib/src/main/java/com/metaplex/lib/modules/auctions/models/Bid.kt +++ b/lib/src/main/java/com/metaplex/lib/modules/auctions/models/Bid.kt @@ -8,7 +8,6 @@ package com.metaplex.lib.modules.auctions.models import com.metaplex.lib.experimental.jen.auctionhouse.AuctionHouseInstructions -import com.metaplex.lib.experimental.jen.auctionhouse.BidReceipt import com.metaplex.lib.modules.auctions.SYSVAR_INSTRUCTIONS_PUBKEY import com.metaplex.lib.modules.auctions.associatedTokenAddress import com.metaplex.lib.programs.token_metadata.accounts.MetadataAccount @@ -28,6 +27,7 @@ data class Bid( val price: Long = 0, // Default: 0 SOLs or tokens. val tokens: Long = 1, // Default: token(1) val bookkeeper: PublicKey = buyer, // Default: identity + val canceledAt: Long? = null ) // TODO: handle Result @@ -100,7 +100,7 @@ fun Bid.buildTransaction(printReceipt: Boolean = true) = Transaction().apply { metadata = metadata, escrowPaymentAccount = escrowPayment.address, authority = authority, - auctionHouse = AuctionHouse.pda(auctionHouse.creator, auctionHouse.treasuryMint), + auctionHouse = auctionHouse.address, auctionHouseFeeAccount = auctionHouse.auctionHouseFeeAccount, buyerTradeState = buyerTradeState.address, tokenAccount = tokenAccount, diff --git a/lib/src/main/java/com/metaplex/lib/modules/auctions/models/Cancel.kt b/lib/src/main/java/com/metaplex/lib/modules/auctions/models/Cancel.kt deleted file mode 100644 index ec96358..0000000 --- a/lib/src/main/java/com/metaplex/lib/modules/auctions/models/Cancel.kt +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Cancel - * Metaplex - * - * Created by Funkatronics on 8/26/2022 - */ - -package com.metaplex.lib.modules.auctions.models - -import com.metaplex.lib.experimental.jen.auctionhouse.AuctionHouseInstructions -import com.metaplex.lib.modules.auctions.SYSVAR_INSTRUCTIONS_PUBKEY -import com.metaplex.lib.modules.auctions.associatedTokenAddress -import com.solana.core.PublicKey -import com.solana.core.Transaction -import com.solana.programs.SystemProgram -import com.solana.programs.TokenProgram - -fun buildAuctionCancelInstruction(auctionHouse: AuctionHouse, wallet: PublicKey, mint: PublicKey, - tradeState: PublicKey, price: Long, tokenSize: Long, - purchaseReceipt: PublicKey? = null, authority: PublicKey? = null) -: Transaction { - - val tokenAccount = PublicKey.associatedTokenAddress(wallet, mint).address - - return Transaction().apply { - addInstruction( - authority?.let { - AuctionHouseInstructions.auctioneerCancel( - wallet = wallet, - tokenAccount = tokenAccount, - tokenMint = mint, - authority = auctionHouse.authority, - auctioneerAuthority = authority, - auctionHouse = auctionHouse.address, - auctionHouseFeeAccount = auctionHouse.auctionHouseFeeAccount, - tradeState = tradeState, - ahAuctioneerPda = auctionHouse.auctioneerPda(authority), - tokenProgram = TokenProgram.PROGRAM_ID, - buyerPrice = price.toULong(), - tokenSize = tokenSize.toULong() - ) - } ?: AuctionHouseInstructions.cancel( - wallet = wallet, - tokenAccount = tokenAccount, - tokenMint = mint, - authority = auctionHouse.authority, - auctionHouse = auctionHouse.address, - auctionHouseFeeAccount = auctionHouse.auctionHouseFeeAccount, - tokenProgram = TokenProgram.PROGRAM_ID, - tradeState = tradeState, - buyerPrice = price.toULong(), - tokenSize = tokenSize.toULong() - ) - ) - - purchaseReceipt?.let { - addInstruction( - AuctionHouseInstructions.cancelBidReceipt( - receipt = purchaseReceipt, - instruction = PublicKey(SYSVAR_INSTRUCTIONS_PUBKEY), - systemProgram = SystemProgram.PROGRAM_ID - ) - ) - } - } -} \ No newline at end of file diff --git a/lib/src/main/java/com/metaplex/lib/modules/auctions/models/Listing.kt b/lib/src/main/java/com/metaplex/lib/modules/auctions/models/Listing.kt index dd5665d..01dc7d9 100644 --- a/lib/src/main/java/com/metaplex/lib/modules/auctions/models/Listing.kt +++ b/lib/src/main/java/com/metaplex/lib/modules/auctions/models/Listing.kt @@ -8,7 +8,6 @@ package com.metaplex.lib.modules.auctions.models import com.metaplex.lib.experimental.jen.auctionhouse.AuctionHouseInstructions -import com.metaplex.lib.experimental.jen.auctionhouse.ListingReceipt import com.metaplex.lib.modules.auctions.SYSVAR_INSTRUCTIONS_PUBKEY import com.metaplex.lib.modules.auctions.associatedTokenAddress import com.metaplex.lib.programs.token_metadata.accounts.MetadataAccount @@ -31,6 +30,7 @@ data class Listing( val price: Long = auctioneerAuthority?.let { AUCTIONEER_PRICE } ?: 0, // Default: 0 SOLs or tokens, ignored in Auctioneer. val tokens: Long = 1, // Default: token(1) val bookkeeper: PublicKey = seller, // Default: identity + val canceledAt: Long? = null ) // TODO: handle Result diff --git a/lib/src/main/java/com/metaplex/lib/modules/auctions/models/Purchase.kt b/lib/src/main/java/com/metaplex/lib/modules/auctions/models/Purchase.kt index 12149e0..e3be812 100644 --- a/lib/src/main/java/com/metaplex/lib/modules/auctions/models/Purchase.kt +++ b/lib/src/main/java/com/metaplex/lib/modules/auctions/models/Purchase.kt @@ -10,10 +10,9 @@ package com.metaplex.lib.modules.auctions.models import com.metaplex.lib.experimental.jen.auctionhouse.AuctionHouseInstructions import com.metaplex.lib.modules.auctions.SYSVAR_INSTRUCTIONS_PUBKEY import com.metaplex.lib.modules.auctions.associatedTokenAddress +import com.metaplex.lib.modules.nfts.operations.FindNftByMintOperation import com.metaplex.lib.programs.token_metadata.accounts.MetadataAccount -import com.solana.core.PublicKey -import com.solana.core.Sysvar -import com.solana.core.Transaction +import com.solana.core.* import com.solana.programs.AssociatedTokenProgram import com.solana.programs.SystemProgram import com.solana.programs.TokenProgram @@ -52,7 +51,7 @@ fun Purchase.buildTransaction(printReceipt: Boolean = true) = Transaction().appl val programAsSigner = AuctionHouse.programAsSignerPda() - addInstruction(auctioneerAuthority?.let { + val saleInstruction = auctioneerAuthority?.let { AuctionHouseInstructions.auctioneerExecuteSale( buyer = buyer, seller = seller, tokenAccount = assetTokenAccount, @@ -108,7 +107,18 @@ fun Purchase.buildTransaction(printReceipt: Boolean = true) = Transaction().appl programAsSignerBump = programAsSigner.nonce.toUByte(), buyerPrice = price.toULong(), tokenSize = tokens.toULong() - )) + ) + + val additionalAccounts = mutableListOf() + + // for each creator: (need to get asset creators list) + additionalAccounts.add(AccountMeta(seller, false, true)) + + if (!auctionHouse.isNative) + additionalAccounts.add(AccountMeta(PublicKey.associatedTokenAddress(seller, mintAccount).address, false, true)) + // end for each + + addInstruction(TransactionInstruction(saleInstruction.programId, saleInstruction.keys + additionalAccounts, saleInstruction.data)) if (printReceipt) { diff --git a/lib/src/main/java/com/metaplex/lib/modules/auctions/operations/FindAuctionHouseByAddressOperationHandler.kt b/lib/src/main/java/com/metaplex/lib/modules/auctions/operations/FindAuctionHouseByAddressOperationHandler.kt new file mode 100644 index 0000000..f056585 --- /dev/null +++ b/lib/src/main/java/com/metaplex/lib/modules/auctions/operations/FindAuctionHouseByAddressOperationHandler.kt @@ -0,0 +1,77 @@ +/* + * FindAuctionHouseByAddressOperationHandler + * Metaplex + * + * Created by Funkatronics on 10/21/2022 + */ + +package com.metaplex.lib.modules.auctions.operations + +import com.metaplex.lib.ASYNC_CALLBACK_DEPRECATION_MESSAGE +import com.metaplex.lib.Metaplex +import com.metaplex.lib.drivers.solana.Connection +import com.metaplex.lib.drivers.solana.getAccountInfo +import com.metaplex.lib.modules.auctions.models.AuctionHouse +import com.metaplex.lib.shared.* +import com.solana.core.PublicKey +import kotlinx.coroutines.* + +class FindAuctionHouseByAddressOperation(override val connection: Connection) + : SuspendOperation { + override suspend fun run(input: PublicKey): Result = + connection.getAccountInfo(input) + .map { + it.data!!.let { // safe unwrap, successful result will not have null + AuctionHouse( + it.treasuryWithdrawalDestination, + it.feeWithdrawalDestination, + it.treasuryMint, + it.authority, + it.creator, + it.sellerFeeBasisPoints, + it.requiresSignOff, + it.canChangeSalePrice, + it.hasAuctioneer + ) + } + } +} + +class FindAuctionHouseByAddressOperationHandler(override val connection: Connection, + override val dispatcher: CoroutineDispatcher = Dispatchers.IO) + : OperationHandler { + + override var metaplex: Metaplex + get() = maybeMetaplex ?: throw IllegalStateException( + "Metaplex object was not injected, and dependency forwarding is obsolete and has been " + + "replaced with direct dependency injection") + set(value) { + maybeMetaplex = value + } + + private var maybeMetaplex: Metaplex? = null + + constructor(metaplex: Metaplex) : this(metaplex.connection) { this.maybeMetaplex = metaplex} + + override suspend fun handle(input: PublicKey): Result = withContext(dispatcher) { + FindAuctionHouseByAddressOperation(connection).run(input) + } + + @Deprecated(ASYNC_CALLBACK_DEPRECATION_MESSAGE, ReplaceWith("handle(input)")) + override fun handle(operation: OperationResult) + : OperationResult = + operation.flatMap { mintKey -> + OperationResult { cb -> + CoroutineScope(dispatcher).launch { + handle(mintKey) + .onSuccess { buffer -> + cb(ResultWithCustomError.success(buffer)) + }.onFailure { + cb( + ResultWithCustomError.failure( + OperationError.GetMetadataAccountInfoError(java.lang.RuntimeException(it)))) + } + } + } + } +} \ No newline at end of file diff --git a/lib/src/main/java/com/metaplex/lib/modules/nfts/operations/FindNftByMintOnChainOperationHandler.kt b/lib/src/main/java/com/metaplex/lib/modules/nfts/operations/FindNftByMintOnChainOperationHandler.kt index e3129b7..d2296b8 100644 --- a/lib/src/main/java/com/metaplex/lib/modules/nfts/operations/FindNftByMintOnChainOperationHandler.kt +++ b/lib/src/main/java/com/metaplex/lib/modules/nfts/operations/FindNftByMintOnChainOperationHandler.kt @@ -6,6 +6,7 @@ import com.metaplex.lib.drivers.solana.Connection import com.metaplex.lib.modules.nfts.models.NFT import com.metaplex.lib.modules.token.operations.FindTokenMasterEditionAccountOperation import com.metaplex.lib.modules.token.operations.FindTokenMetadataAccountOperation +import com.metaplex.lib.programs.token_metadata.accounts.MetadataAccount import com.metaplex.lib.shared.* import com.solana.core.PublicKey import kotlinx.coroutines.* @@ -34,7 +35,7 @@ class FindNftByMintOnChainOperationHandler(override val connection: Connection, // Launch the metadata job asynchronously val metadataJob = async { FindTokenMetadataAccountOperation(connection) - .run(input).getOrElse { + .run(MetadataAccount.pda(input).getOrThrows()).getOrElse { throw OperationError.GetMetadataAccountInfoError(it) }.data } diff --git a/lib/src/main/java/com/metaplex/lib/modules/token/Constants.kt b/lib/src/main/java/com/metaplex/lib/modules/token/Constants.kt index bdf78ba..154fdc1 100644 --- a/lib/src/main/java/com/metaplex/lib/modules/token/Constants.kt +++ b/lib/src/main/java/com/metaplex/lib/modules/token/Constants.kt @@ -8,4 +8,6 @@ package com.metaplex.lib.modules.token const val MINT_SIZE = 82L -const val MIN_RENT_FOR_MINT = 1461600L \ No newline at end of file +const val MIN_RENT_FOR_MINT = 1461600L + +const val WRAPPED_SOL_MINT_ADDRESS = "So11111111111111111111111111111111111111112" \ No newline at end of file diff --git a/lib/src/main/java/com/metaplex/lib/modules/token/operations/FindFungibleTokenByMintOnChainOperationHandler.kt b/lib/src/main/java/com/metaplex/lib/modules/token/operations/FindFungibleTokenByMintOnChainOperationHandler.kt index ca3eb01..81149e1 100644 --- a/lib/src/main/java/com/metaplex/lib/modules/token/operations/FindFungibleTokenByMintOnChainOperationHandler.kt +++ b/lib/src/main/java/com/metaplex/lib/modules/token/operations/FindFungibleTokenByMintOnChainOperationHandler.kt @@ -4,6 +4,7 @@ import com.metaplex.lib.ASYNC_CALLBACK_DEPRECATION_MESSAGE import com.metaplex.lib.Metaplex import com.metaplex.lib.drivers.solana.Connection import com.metaplex.lib.modules.token.models.FungibleToken +import com.metaplex.lib.programs.token_metadata.accounts.MetadataAccount import com.metaplex.lib.shared.* import com.solana.core.PublicKey import kotlinx.coroutines.* @@ -28,9 +29,10 @@ class FindFungibleTokenByMintOnChainOperationHandler(override val connection: Co constructor(metaplex: Metaplex) : this(metaplex.connection) { this.maybeMetaplex = metaplex} override suspend fun handle(input: PublicKey): Result = withContext(dispatcher) { - FindTokenMetadataAccountOperation(connection).run(input).mapCatching { - it.data?.let { FungibleToken(it) } ?: throw OperationError.NilDataOnAccount - } + FindTokenMetadataAccountOperation(connection).run(MetadataAccount.pda(input).getOrThrows()) + .mapCatching { + it.data?.let { FungibleToken(it) } ?: throw OperationError.NilDataOnAccount + } } @Deprecated(ASYNC_CALLBACK_DEPRECATION_MESSAGE, ReplaceWith("handle(input)")) diff --git a/lib/src/main/java/com/metaplex/lib/modules/token/operations/FindTokenMetadataAccountOperation.kt b/lib/src/main/java/com/metaplex/lib/modules/token/operations/FindTokenMetadataAccountOperation.kt index a38bd18..80fb061 100644 --- a/lib/src/main/java/com/metaplex/lib/modules/token/operations/FindTokenMetadataAccountOperation.kt +++ b/lib/src/main/java/com/metaplex/lib/modules/token/operations/FindTokenMetadataAccountOperation.kt @@ -18,8 +18,7 @@ class FindTokenMetadataAccountOperation(override val connection: Connection) : SuspendOperation> { override suspend fun run(input: PublicKey): Result> = @Suppress("UNCHECKED_CAST") - connection.getAccountInfo(BorshCodeableSerializer(MetadataAccount::class.java), - MetadataAccount.pda(input).getOrThrows()).map { + connection.getAccountInfo(BorshCodeableSerializer(MetadataAccount::class.java), input).map { it as AccountInfo // safe cast, we know the returned type } } \ No newline at end of file diff --git a/lib/src/test/java/com/metaplex/data/TestDataProvider.kt b/lib/src/test/java/com/metaplex/data/TestDataProvider.kt index 13c74d4..5f2d086 100644 --- a/lib/src/test/java/com/metaplex/data/TestDataProvider.kt +++ b/lib/src/test/java/com/metaplex/data/TestDataProvider.kt @@ -7,10 +7,12 @@ package com.metaplex.data import com.metaplex.data.model.TestAuctionHouse +import com.metaplex.data.model.TestAuctionHouseAccount object TestDataProvider { val auctionHouse get() = TestAuctionHouse() + val auctionHouseAccount get() = TestAuctionHouseAccount() val auctionHouseWithAuctioneer get() = TestAuctionHouse(true) val badAddress = "So11111111111111111111111111111111111111113" diff --git a/lib/src/test/java/com/metaplex/data/model/TestAuctionHouse.kt b/lib/src/test/java/com/metaplex/data/model/TestAuctionHouse.kt index 910a6d2..1b5dcd0 100644 --- a/lib/src/test/java/com/metaplex/data/model/TestAuctionHouse.kt +++ b/lib/src/test/java/com/metaplex/data/model/TestAuctionHouse.kt @@ -8,12 +8,13 @@ package com.metaplex.data.model import com.metaplex.lib.modules.auctions.models.AuctionHouse +import com.metaplex.lib.experimental.jen.auctionhouse.AuctionHouse as AuctionHouseAccount import com.solana.core.PublicKey import java.util.Base64 internal typealias TestAuctionHouse = AuctionHouse -internal val TestAuctionHouse.address get() = "5xN42RZCk7wA4GjQU2VVDhda8LBL8fAnrKZK921sybLF" +internal val TestAuctionHouse.publicKey get() = "5xN42RZCk7wA4GjQU2VVDhda8LBL8fAnrKZK921sybLF" internal val TestAuctionHouse.borsh get() = Base64.getDecoder().decode( "KGzXa9VV9TC9WuTFjCbG0RR7CXM/o6Jb3sLJjqqmeNyI+uBYcn8mGLvtruiZlJOUc5O5XrLpZ+PbnWq5BpAKKCT" + "7T9RhxMiSeA6Gza4qx8mdg9W+r6hT4lSELlTjkLzxG/JeSifEZqx4DobNrirHyZ2D1b6vqFPiVIQuVOOQvPEb8l" + @@ -22,6 +23,18 @@ internal val TestAuctionHouse.borsh get() = Base64.getDecoder().decode( ) internal fun TestAuctionHouse(hasAuctioneer: Boolean = false) = AuctionHouse( + treasuryWithdrawalDestinationOwner = PublicKey("95emj1a33Ei7B6ciu7gbPm7zRMRpFGs86g5nK5NiSdEK"), + feeWithdrawalDestination = PublicKey("95emj1a33Ei7B6ciu7gbPm7zRMRpFGs86g5nK5NiSdEK"), + treasuryMint = PublicKey("So11111111111111111111111111111111111111112"), + authority = PublicKey("95emj1a33Ei7B6ciu7gbPm7zRMRpFGs86g5nK5NiSdEK"), + creator = PublicKey("95emj1a33Ei7B6ciu7gbPm7zRMRpFGs86g5nK5NiSdEK"), + sellerFeeBasisPoints = 200u, + requiresSignOff = false, + canChangeSalePrice = false, + hasAuctioneer = hasAuctioneer, +) + +internal fun TestAuctionHouseAccount(hasAuctioneer: Boolean = false) = AuctionHouseAccount( auctionHouseFeeAccount = PublicKey("DkAScnZa6GqjXkPYPAU4kediZmR2EESHXutFzR4U6TGs"), auctionHouseTreasury = PublicKey("DebSyCbsnzMppVLt1umD4tUcJV6bSQW4z3nQVXQpWhCV"), treasuryWithdrawalDestination = PublicKey("95emj1a33Ei7B6ciu7gbPm7zRMRpFGs86g5nK5NiSdEK"), @@ -37,5 +50,6 @@ internal fun TestAuctionHouse(hasAuctioneer: Boolean = false) = AuctionHouse( canChangeSalePrice = false, escrowPaymentBump = 0u, hasAuctioneer = hasAuctioneer, - auctioneerPdaBump = 0u + auctioneerAddress = PublicKey(ByteArray(PublicKey.PUBLIC_KEY_LENGTH)), + scopes = listOf() ) \ No newline at end of file diff --git a/lib/src/test/java/com/metaplex/lib/drivers/solana/RecentBlockhashTests.kt b/lib/src/test/java/com/metaplex/lib/drivers/solana/RecentBlockhashTests.kt index 7c554ab..18addc2 100644 --- a/lib/src/test/java/com/metaplex/lib/drivers/solana/RecentBlockhashTests.kt +++ b/lib/src/test/java/com/metaplex/lib/drivers/solana/RecentBlockhashTests.kt @@ -48,7 +48,7 @@ class RecentBlockhashTests { @Test fun testRecentBlockhashRequest() = runTest { // given - val rpcService = MockRpcDriver() + val rpcService = MockRpcDriver(autoHandleBlockhashRequest = false) val blockhashRequest = RecentBlockhashRequest() val expectedBlockhash = BlockhashResponse("wooweeLookAtThisBlockhash", buildJsonObject {}) diff --git a/lib/src/test/java/com/metaplex/lib/drivers/solana/SolanaConnectionDriverTests.kt b/lib/src/test/java/com/metaplex/lib/drivers/solana/SolanaConnectionDriverTests.kt index 7585d2f..114093a 100644 --- a/lib/src/test/java/com/metaplex/lib/drivers/solana/SolanaConnectionDriverTests.kt +++ b/lib/src/test/java/com/metaplex/lib/drivers/solana/SolanaConnectionDriverTests.kt @@ -10,7 +10,7 @@ package com.metaplex.lib.drivers.solana import com.metaplex.data.TestDataProvider -import com.metaplex.data.model.address +import com.metaplex.data.model.publicKey import com.metaplex.lib.drivers.rpc.RpcError import com.metaplex.mock.driver.rpc.MockRpcDriver import com.solana.core.Account @@ -31,7 +31,7 @@ class SolanaConnectionDriverTests { @Test fun testGetAccountInfoReturnsValidAccountInfo() = runTest { // given - val address = TestDataProvider.auctionHouse.address + val address = TestDataProvider.auctionHouse.publicKey val accountRequest = AccountRequest(address) val expectedAccountInfo = AccountInfo("testAccount", false, 0, "", 0) val solanaDriver = SolanaConnectionDriver(MockRpcDriver().apply { @@ -48,7 +48,7 @@ class SolanaConnectionDriverTests { @Test fun testGetAccountInfoReturnsErrorForNullAccount() = runTest { // given - val address = TestDataProvider.auctionHouse.address + val address = TestDataProvider.auctionHouse.publicKey val expectedResult = Result.failure(Error("Account return Null")) val solanaDriver = SolanaConnectionDriver(MockRpcDriver()) diff --git a/lib/src/test/java/com/metaplex/lib/modules/auctions/AuctionHouseClientTests.kt b/lib/src/test/java/com/metaplex/lib/modules/auctions/AuctionHouseClientTests.kt index bb85ee3..92cf035 100644 --- a/lib/src/test/java/com/metaplex/lib/modules/auctions/AuctionHouseClientTests.kt +++ b/lib/src/test/java/com/metaplex/lib/modules/auctions/AuctionHouseClientTests.kt @@ -10,68 +10,45 @@ package com.metaplex.lib.modules.auctions import com.metaplex.data.TestDataProvider +import com.metaplex.lib.MetaplexTestUtils import com.metaplex.lib.drivers.indenty.IdentityDriver -import com.metaplex.lib.drivers.solana.BlockhashResponse -import com.metaplex.lib.drivers.solana.RecentBlockhashRequest -import com.metaplex.lib.drivers.solana.SolanaConnectionDriver +import com.metaplex.lib.drivers.indenty.KeypairIdentityDriver +import com.metaplex.lib.drivers.solana.* +import com.metaplex.lib.experimental.jen.jenerateAuctionHouse +import com.metaplex.lib.generateConnectionDriver import com.metaplex.lib.modules.auctions.models.* +import com.metaplex.lib.modules.nfts.NftClient +import com.metaplex.lib.modules.nfts.models.Metadata +import com.metaplex.lib.programs.token_metadata.MetadataKey import com.metaplex.lib.programs.token_metadata.accounts.MetadataAccount +import com.metaplex.lib.programs.token_metadata.accounts.MetaplexData import com.metaplex.mock.driver.rpc.MockRpcDriver import com.solana.core.Account -import com.solana.core.PublicKey -import com.solana.core.Transaction +import com.util.airdrop import kotlinx.coroutines.* import kotlinx.coroutines.test.runTest -import kotlinx.serialization.json.buildJsonObject -import org.junit.Assert.assertEquals +import org.junit.Assert +import org.junit.Before import org.junit.Test +import java.net.URL class AuctionHouseClientTests { // @Before // fun prepare() { -// jenerate() +// jenerateAuctionHouse() // } + //region UNIT @Test fun testListingReturnsExpectedListing() = runTest { // given val seller = Account() val auctionHouse = TestDataProvider.auctionHouse - val rpcDriver = MockRpcDriver().apply { - willReturn( - RecentBlockhashRequest(), - BlockhashResponse(seller.publicKey.toBase58(), buildJsonObject { }) - ) - } - - val mockIdentityDriver = object : IdentityDriver { - override val publicKey: PublicKey = seller.publicKey - - override fun sendTransaction( - transaction: Transaction, - recentBlockHash: String?, - onComplete: (Result) -> Unit - ) { - onComplete(Result.success("transaction result")) - } - - override fun signTransaction( - transaction: Transaction, - onComplete: (Result) -> Unit - ) { - transaction.sign(seller) - onComplete(Result.success(transaction)) - } - - override fun signAllTransactions( - transactions: List, - onComplete: (Result>) -> Unit - ) = TODO("Not yet implemented") - } - + val rpcDriver = MockRpcDriver(autoConfirmTransactions = true) + val connection = SolanaConnectionDriver(rpcDriver) val client = - AuctionHouseClient(auctionHouse, SolanaConnectionDriver(rpcDriver), mockIdentityDriver) + AuctionHouseClient(auctionHouse, connection, KeypairIdentityDriver(seller, connection)) val expectedListing = Listing(auctionHouse, mintAccount = auctionHouse.treasuryMint, @@ -84,7 +61,7 @@ class AuctionHouseClientTests { val actualListing: Listing? = client.list(auctionHouse.treasuryMint, 1).getOrNull() // then - assertEquals(expectedListing, actualListing) + Assert.assertEquals(expectedListing, actualListing) } @Test @@ -92,40 +69,10 @@ class AuctionHouseClientTests { // given val buyer = Account() val auctionHouse = TestDataProvider.auctionHouse - val rpcDriver = MockRpcDriver().apply { - willReturn( - RecentBlockhashRequest(), - BlockhashResponse(buyer.publicKey.toBase58(), buildJsonObject { }) - ) - } - - val mockIdentityDriver = object : IdentityDriver { - override val publicKey: PublicKey = buyer.publicKey - - override fun sendTransaction( - transaction: Transaction, - recentBlockHash: String?, - onComplete: (Result) -> Unit - ) { - onComplete(Result.success("transaction result")) - } - - override fun signTransaction( - transaction: Transaction, - onComplete: (Result) -> Unit - ) { - transaction.sign(buyer) - onComplete(Result.success(transaction)) - } - - override fun signAllTransactions( - transactions: List, - onComplete: (Result>) -> Unit - ) = TODO("Not yet implemented") - } - + val rpcDriver = MockRpcDriver(autoConfirmTransactions = true) + val connection = SolanaConnectionDriver(rpcDriver) val client = - AuctionHouseClient(auctionHouse, SolanaConnectionDriver(rpcDriver), mockIdentityDriver) + AuctionHouseClient(auctionHouse, connection, KeypairIdentityDriver(buyer, connection)) val expectedBid = Bid(auctionHouse, mintAccount = auctionHouse.treasuryMint, @@ -138,7 +85,7 @@ class AuctionHouseClientTests { val actualBid: Bid? = client.bid(auctionHouse.treasuryMint, 1).getOrNull() // then - assertEquals(expectedBid, actualBid) + Assert.assertEquals(expectedBid, actualBid) } @Test @@ -146,101 +93,56 @@ class AuctionHouseClientTests { // given val buyer = Account() val seller = Account() + val asset = Account() val auctionHouse = TestDataProvider.auctionHouse - val rpcDriver = MockRpcDriver().apply { - willReturn( - RecentBlockhashRequest(), - BlockhashResponse(buyer.publicKey.toBase58(), buildJsonObject { }) - ) - } - - val mockIdentityDriver = object : IdentityDriver { - override val publicKey: PublicKey = buyer.publicKey - - override fun sendTransaction( - transaction: Transaction, - recentBlockHash: String?, - onComplete: (Result) -> Unit - ) { - onComplete(Result.success("transaction result")) - } - - override fun signTransaction( - transaction: Transaction, - onComplete: (Result) -> Unit - ) { - transaction.sign(buyer) - onComplete(Result.success(transaction)) - } - - override fun signAllTransactions( - transactions: List, - onComplete: (Result>) -> Unit - ) = TODO("Not yet implemented") + val rpcDriver = MockRpcDriver(autoConfirmTransactions = true).apply { + // this mocking is annoying, need to find a cleaner way to set this up + willReturn(AccountRequest(MetadataAccount.pda(asset.publicKey).getOrThrows().toBase58()), + AccountInfo(MetadataAccount(MetadataKey.MetadataV1.ordinal, + seller.publicKey, asset.publicKey, + MetaplexData("", "", "", 250, false, 0, arrayOf()), + true, false, null, null, null) + , false, 0, null, 0)) } + val connection = SolanaConnectionDriver(rpcDriver) val client = - AuctionHouseClient(auctionHouse, SolanaConnectionDriver(rpcDriver), mockIdentityDriver) + AuctionHouseClient(auctionHouse, connection, KeypairIdentityDriver(buyer, connection)) val listing = Listing(auctionHouse, - mintAccount = auctionHouse.treasuryMint, + mintAccount = asset.publicKey, seller = seller.publicKey, bookkeeper = seller.publicKey, price=1, ) val bid = Bid(auctionHouse, - mintAccount = auctionHouse.treasuryMint, + mintAccount = asset.publicKey, buyer = buyer.publicKey, bookkeeper = buyer.publicKey, price=1, ) val expectedPurchase = Purchase(auctionHouse, bid.bookkeeper, buyer.publicKey, - seller.publicKey, auctionHouse.treasuryMint, null, + seller.publicKey, asset.publicKey, null, bid.buyerTradeState.address, listing.sellerTradeState.address, bid.price, bid.tokens) // when val actualPurchase: Purchase? = client.executeSale(listing, bid).getOrNull() // then - assertEquals(expectedPurchase, actualPurchase) + Assert.assertEquals(expectedPurchase, actualPurchase) } @Test fun testAuctioneerListingWithoutAuctioneerReturnsError() = runTest { // given val seller = Account() - val rpcDriver = MockRpcDriver() val auctionHouse = TestDataProvider.auctionHouseWithAuctioneer - - val mockIdentityDriver = object : IdentityDriver { - override val publicKey: PublicKey = seller.publicKey - - override fun sendTransaction( - transaction: Transaction, - recentBlockHash: String?, - onComplete: (Result) -> Unit - ) { - onComplete(Result.success("transaction result")) - } - - override fun signTransaction( - transaction: Transaction, - onComplete: (Result) -> Unit - ) { - transaction.sign(seller) - onComplete(Result.success(transaction)) - } - - override fun signAllTransactions( - transactions: List, - onComplete: (Result>) -> Unit - ) = TODO("Not yet implemented") - } - + val rpcDriver = MockRpcDriver(autoConfirmTransactions = true) + val connection = SolanaConnectionDriver(rpcDriver) val client = - AuctionHouseClient(auctionHouse, SolanaConnectionDriver(rpcDriver), mockIdentityDriver) + AuctionHouseClient(auctionHouse, connection, KeypairIdentityDriver(seller, connection)) val expectedError = Error("Auctioneer Authority Required") @@ -248,51 +150,26 @@ class AuctionHouseClientTests { val actualError = client.list(auctionHouse.treasuryMint, 1).exceptionOrNull() // then - assertEquals(expectedError.message, actualError?.message) + Assert.assertEquals(expectedError.message, actualError?.message) } @Test fun testAuctioneerBidWithoutAuctioneerReturnsError() = runTest { // given val buyer = Account() - val rpcDriver = MockRpcDriver() val auctionHouse = TestDataProvider.auctionHouseWithAuctioneer - - val mockIdentityDriver = object : IdentityDriver { - override val publicKey: PublicKey = buyer.publicKey - - override fun sendTransaction( - transaction: Transaction, - recentBlockHash: String?, - onComplete: (Result) -> Unit - ) { - onComplete(Result.success("transaction result")) - } - - override fun signTransaction( - transaction: Transaction, - onComplete: (Result) -> Unit - ) { - transaction.sign(buyer) - onComplete(Result.success(transaction)) - } - - override fun signAllTransactions( - transactions: List, - onComplete: (Result>) -> Unit - ) = TODO("Not yet implemented") - } - + val rpcDriver = MockRpcDriver(autoConfirmTransactions = true) + val connection = SolanaConnectionDriver(rpcDriver) val client = - AuctionHouseClient(auctionHouse, SolanaConnectionDriver(rpcDriver), mockIdentityDriver) + AuctionHouseClient(auctionHouse, connection, KeypairIdentityDriver(buyer, connection)) val expectedError = Error("Auctioneer Authority Required") // when - val actualError = client.list(auctionHouse.treasuryMint, 1).exceptionOrNull() + val actualError = client.bid(auctionHouse.treasuryMint, 1).exceptionOrNull() // then - assertEquals(expectedError.message, actualError?.message) + Assert.assertEquals(expectedError.message, actualError?.message) } @Test @@ -300,36 +177,11 @@ class AuctionHouseClientTests { // given val buyer = Account() val seller = Account() - val rpcDriver = MockRpcDriver() val auctionHouse = TestDataProvider.auctionHouseWithAuctioneer - - val mockIdentityDriver = object : IdentityDriver { - override val publicKey: PublicKey = seller.publicKey - - override fun sendTransaction( - transaction: Transaction, - recentBlockHash: String?, - onComplete: (Result) -> Unit - ) { - onComplete(Result.success("transaction result")) - } - - override fun signTransaction( - transaction: Transaction, - onComplete: (Result) -> Unit - ) { - transaction.sign(seller) - onComplete(Result.success(transaction)) - } - - override fun signAllTransactions( - transactions: List, - onComplete: (Result>) -> Unit - ) = TODO("Not yet implemented") - } - + val rpcDriver = MockRpcDriver(autoConfirmTransactions = true) + val connection = SolanaConnectionDriver(rpcDriver) val client = - AuctionHouseClient(auctionHouse, SolanaConnectionDriver(rpcDriver), mockIdentityDriver) + AuctionHouseClient(auctionHouse, connection, KeypairIdentityDriver(buyer, connection)) val listing = Listing(auctionHouse, mintAccount = auctionHouse.treasuryMint, @@ -348,10 +200,10 @@ class AuctionHouseClientTests { val expectedError = Error("Auctioneer Authority Required") // when - val actualError = client.list(auctionHouse.treasuryMint, 1).exceptionOrNull() + val actualError = client.executeSale(listing, bid).exceptionOrNull() // then - assertEquals(expectedError.message, actualError?.message) + Assert.assertEquals(expectedError.message, actualError?.message) } @Test @@ -359,36 +211,11 @@ class AuctionHouseClientTests { // given val buyer = Account() val seller = Account() - val rpcDriver = MockRpcDriver() val auctionHouse = TestDataProvider.auctionHouse - - val mockIdentityDriver = object : IdentityDriver { - override val publicKey: PublicKey = seller.publicKey - - override fun sendTransaction( - transaction: Transaction, - recentBlockHash: String?, - onComplete: (Result) -> Unit - ) { - onComplete(Result.success("transaction result")) - } - - override fun signTransaction( - transaction: Transaction, - onComplete: (Result) -> Unit - ) { - transaction.sign(seller) - onComplete(Result.success(transaction)) - } - - override fun signAllTransactions( - transactions: List, - onComplete: (Result>) -> Unit - ) = TODO("Not yet implemented") - } - + val rpcDriver = MockRpcDriver(autoConfirmTransactions = true) + val connection = SolanaConnectionDriver(rpcDriver) val client = - AuctionHouseClient(auctionHouse, SolanaConnectionDriver(rpcDriver), mockIdentityDriver) + AuctionHouseClient(auctionHouse, connection, KeypairIdentityDriver(seller, connection)) val listing = Listing(auctionHouse, mintAccount = auctionHouse.treasuryMint, @@ -410,7 +237,7 @@ class AuctionHouseClientTests { val actualError = client.executeSale(listing, bid).exceptionOrNull() // then - assertEquals(expectedError.message, actualError?.message) + Assert.assertEquals(expectedError.message, actualError?.message) } @Test @@ -418,55 +245,31 @@ class AuctionHouseClientTests { // given val buyer = Account() val seller = Account() - val rpcDriver = MockRpcDriver() val auctionHouse1 = TestDataProvider.auctionHouse + val rpcDriver = MockRpcDriver(autoConfirmTransactions = true) + val connection = SolanaConnectionDriver(rpcDriver) + val client = + AuctionHouseClient(auctionHouse1, connection, KeypairIdentityDriver(seller, connection)) + val auctionHouse2 = AuctionHouse( - auctionHouseFeeAccount = Account().publicKey, - auctionHouseTreasury = Account().publicKey, - treasuryWithdrawalDestination = Account().publicKey, - feeWithdrawalDestination = Account().publicKey, - treasuryMint = PublicKey("So11111111111111111111111111111111111111112"), - authority = buyer.publicKey, - creator = buyer.publicKey, - bump = 253u, - treasuryBump = 254u, - feePayerBump = 252u, +// auctionHouseFeeAccount = Account().publicKey, +// auctionHouseTreasury = Account().publicKey, + treasuryWithdrawalDestinationOwner = seller.publicKey, + feeWithdrawalDestination = seller.publicKey, +// treasuryMint = PublicKey(WRAPPED_SOL_MINT_ADDRESS), + authority = seller.publicKey, + creator = seller.publicKey, +// bump = 253u, +// treasuryBump = 254u, +// feePayerBump = 252u, sellerFeeBasisPoints = 200u, - requiresSignOff = false, - canChangeSalePrice = false, - escrowPaymentBump = 0u, - hasAuctioneer = false, - auctioneerPdaBump = 0u +// requiresSignOff = false, +// canChangeSalePrice = false, +// escrowPaymentBump = 0u, +// hasAuctioneer = false, +// auctioneerPdaBump = 0u ) - val mockIdentityDriver = object : IdentityDriver { - override val publicKey: PublicKey = seller.publicKey - - override fun sendTransaction( - transaction: Transaction, - recentBlockHash: String?, - onComplete: (Result) -> Unit - ) { - onComplete(Result.success("transaction result")) - } - - override fun signTransaction( - transaction: Transaction, - onComplete: (Result) -> Unit - ) { - transaction.sign(seller) - onComplete(Result.success(transaction)) - } - - override fun signAllTransactions( - transactions: List, - onComplete: (Result>) -> Unit - ) = TODO("Not yet implemented") - } - - val client = - AuctionHouseClient(auctionHouse1, SolanaConnectionDriver(rpcDriver), mockIdentityDriver) - val listing = Listing(auctionHouse1, mintAccount = auctionHouse1.treasuryMint, seller = seller.publicKey, @@ -487,7 +290,196 @@ class AuctionHouseClientTests { val actualError = client.executeSale(listing, bid).exceptionOrNull() // then - assertEquals(expectedError.message, actualError?.message) + Assert.assertEquals(expectedError.message, actualError?.message) + } + //endregion + + //region INTEGRATION + @Test + fun testCreatePublicListingOnAuctionHouse() = runTest { + // given + val seller = Account() + val connection = MetaplexTestUtils.generateConnectionDriver() + val identityDriver = KeypairIdentityDriver(seller, connection) + val auctionsClient = AuctionsClient(connection, identityDriver) + + // when + connection.airdrop(seller.publicKey, 1f) + + // create nft to list + val nft = createNft(connection, identityDriver).getOrThrow() + + // create auction house + val auctionHouse = auctionsClient.createAuctionHouse(250).getOrThrow() + + // fund AH fee account (should this be added to the create auction house client operation?) + connection.airdrop(auctionHouse.auctionHouseFeeAccount, 1f) + + val createdListing = AuctionHouseClient(auctionHouse, connection, identityDriver) + .list(nft.mint, 100000L).getOrThrow() + + val onChainListing = + auctionsClient.findListingByReceipt(createdListing.receiptAddress.address).getOrThrow() + + // then + Assert.assertEquals(createdListing, onChainListing) + } + + @Test + fun testCancelPublicListingOnAuctionHouse() = runTest { + // given + val seller = Account() + val connection = MetaplexTestUtils.generateConnectionDriver() + val identityDriver = KeypairIdentityDriver(seller, connection) + val auctionsClient = AuctionsClient(connection, identityDriver) + + // when + connection.airdrop(seller.publicKey, 1f) + + // create nft to list + val nft = createNft(connection, identityDriver).getOrThrow() + + // create auction house + val auctionHouse = auctionsClient.createAuctionHouse(250).getOrThrow() + + // fund AH fee account (should this be added to the create auction house client operation?) + connection.airdrop(auctionHouse.auctionHouseFeeAccount, 1f) + + val client = AuctionHouseClient(auctionHouse, connection, identityDriver) + val createdListing = client.list(nft.mint, 100000L).getOrThrow() + + client.cancelListing(createdListing, createdListing.mintAccount).getOrThrow() + + val cancelledListing = + auctionsClient.findListingByReceipt(createdListing.receiptAddress.address).getOrThrow() + + // then + Assert.assertNotNull(createdListing) + Assert.assertTrue(cancelledListing.canceledAt!! > 0) + Assert.assertEquals(createdListing.auctionHouse, cancelledListing.auctionHouse) + Assert.assertEquals(createdListing.mintAccount, cancelledListing.mintAccount) + Assert.assertEquals(createdListing.tokenAccount, cancelledListing.tokenAccount) + Assert.assertEquals(createdListing.price, cancelledListing.price) + Assert.assertEquals(createdListing.tokens, cancelledListing.tokens) + } + + @Test + fun testCreatePublicBidOnAuctionHouse() = runTest { + // given + val buyer = Account() + val seller = Account() +// val connection = MetaplexTestUtils.generateConnectionDriver() + val connection = MetaplexTestUtils.generateConnectionDriver(URL("http://127.0.0.1:8899")) + val buyerIdentityDriver = KeypairIdentityDriver(buyer, connection) + val sellerIdentityDriver = KeypairIdentityDriver(seller, connection) + val auctionsClient = AuctionsClient(connection, buyerIdentityDriver) + + // when + connection.airdrop(buyer.publicKey, 1f) + connection.airdrop(seller.publicKey, 1f) + + // create nft to bid on + val nft = createNft(connection, sellerIdentityDriver).getOrThrow() + + // create auction house + val auctionHouse = auctionsClient.createAuctionHouse(250).getOrThrow() + + // fund AH fee account (should this be added to the create auction house client operation?) + connection.airdrop(auctionHouse.auctionHouseFeeAccount, 1f) + + val createdBid = AuctionHouseClient(auctionHouse, connection, buyerIdentityDriver) + .bid(nft.mint, 100000L).getOrThrow() + + val onChainBid = + auctionsClient.findBidByReceipt(createdBid.receiptAddress.address).getOrThrow() + + // then + Assert.assertNotNull(createdBid) + Assert.assertEquals(createdBid, onChainBid) } + @Test + fun testCancelPublicBidOnAuctionHouse() = runTest { + // given + val buyer = Account() + val seller = Account() +// val connection = MetaplexTestUtils.generateConnectionDriver() + val connection = MetaplexTestUtils.generateConnectionDriver(URL("http://127.0.0.1:8899")) + val buyerIdentityDriver = KeypairIdentityDriver(buyer, connection) + val sellerIdentityDriver = KeypairIdentityDriver(seller, connection) + val auctionsClient = AuctionsClient(connection, buyerIdentityDriver) + + // when + connection.airdrop(buyer.publicKey, 1f) + connection.airdrop(seller.publicKey, 1f) + + // create nft to bid on + val nft = createNft(connection, sellerIdentityDriver).getOrThrow() + + // create auction house + val auctionHouse = auctionsClient.createAuctionHouse(250).getOrThrow() + + // fund AH fee account (should this be added to the create auction house client operation?) + connection.airdrop(auctionHouse.auctionHouseFeeAccount, 1f) + + val client = AuctionHouseClient(auctionHouse, connection, buyerIdentityDriver) + val createdBid = client.bid(nft.mint, 100000L).getOrThrow() + + client.cancelBid(createdBid.mintAccount, createdBid).getOrThrow() + + val canceledBid = + auctionsClient.findBidByReceipt(createdBid.receiptAddress.address).getOrThrow() + + // then + Assert.assertNotNull(createdBid) + Assert.assertTrue(canceledBid.canceledAt!! > 0) + Assert.assertEquals(createdBid.auctionHouse, canceledBid.auctionHouse) + Assert.assertEquals(createdBid.mintAccount, canceledBid.mintAccount) + Assert.assertEquals(createdBid.tokenAccount, canceledBid.tokenAccount) + Assert.assertEquals(createdBid.price, canceledBid.price) + Assert.assertEquals(createdBid.tokens, canceledBid.tokens) + } + + @Test + fun testExecuteSaleOnPublicListingBidPair() = runTest { + // given + val buyer = Account() + val seller = Account() + val connection = MetaplexTestUtils.generateConnectionDriver(URL("http://127.0.0.1:8899")) + val buyerIdentityDriver = KeypairIdentityDriver(buyer, connection) + val sellerIdentityDriver = KeypairIdentityDriver(seller, connection) + val auctionsClient = AuctionsClient(connection, buyerIdentityDriver) + + // when + connection.airdrop(buyer.publicKey, 1f) + connection.airdrop(seller.publicKey, 1f) + + // create nft to bid on + val nft = createNft(connection, sellerIdentityDriver).getOrThrow() + + // create auction house + val auctionHouse = auctionsClient.createAuctionHouse(250).getOrThrow() + + // fund AH fee account (should this be added to the create auction house client operation?) + connection.airdrop(auctionHouse.auctionHouseFeeAccount, 1f) + + val listing = AuctionHouseClient(auctionHouse, connection, sellerIdentityDriver) + .list(nft.mint, 1L).getOrThrow() + + val bid = AuctionHouseClient(auctionHouse, connection, buyerIdentityDriver) + .bid(nft.mint, 1L).getOrThrow() + + val purchase = AuctionHouseClient(auctionHouse, connection, sellerIdentityDriver) + .executeSale(listing, bid).getOrThrow() + + // then + Assert.assertNotNull(purchase) + } + //endregion + + private suspend fun createNft(connection: Connection, identityDriver: IdentityDriver) = + NftClient(connection, identityDriver).create( + Metadata("My NFT", uri = "http://example.com/sd8756fsuyvvbf37684", + sellerFeeBasisPoints = 250) + ) } \ No newline at end of file diff --git a/lib/src/test/java/com/metaplex/lib/modules/auctions/AuctionsTests.kt b/lib/src/test/java/com/metaplex/lib/modules/auctions/AuctionsTests.kt index 9c66042..e5fdab4 100644 --- a/lib/src/test/java/com/metaplex/lib/modules/auctions/AuctionsTests.kt +++ b/lib/src/test/java/com/metaplex/lib/modules/auctions/AuctionsTests.kt @@ -11,12 +11,19 @@ package com.metaplex.lib.modules.auctions import com.metaplex.data.TestDataProvider import com.metaplex.data.model.TestAccountResponse -import com.metaplex.data.model.address +import com.metaplex.data.model.publicKey +import com.metaplex.lib.MetaplexTestUtils +import com.metaplex.lib.drivers.indenty.KeypairIdentityDriver +import com.metaplex.lib.drivers.indenty.ReadOnlyIdentityDriver import com.metaplex.lib.drivers.solana.AccountRequest import com.metaplex.lib.drivers.solana.SolanaConnectionDriver +import com.metaplex.lib.generateConnectionDriver import com.metaplex.lib.modules.auctions.models.AuctionHouse +import com.metaplex.lib.modules.auctions.models.address import com.metaplex.mock.driver.rpc.MockRpcDriver +import com.solana.core.Account import com.solana.core.PublicKey +import com.util.airdrop import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest import org.junit.Assert @@ -24,15 +31,19 @@ import org.junit.Test class AuctionsTests { + //region UNIT @Test fun testfindAuctionHouseByAddressReturnsKnownAuctionHouse() = runTest { // given - val address = TestDataProvider.auctionHouse.address + val address = TestDataProvider.auctionHouse.publicKey + val auctionHouseAccount = TestDataProvider.auctionHouseAccount val expectedAuctionHouse = TestDataProvider.auctionHouse + val connection = SolanaConnectionDriver(MockRpcDriver().apply { + willReturn(AccountRequest(address), TestAccountResponse(auctionHouseAccount)) + }) - val client = AuctionsClient(SolanaConnectionDriver(MockRpcDriver().apply { - willReturn(AccountRequest(address), TestAccountResponse(expectedAuctionHouse)) - })) + val client = AuctionsClient(connection, + ReadOnlyIdentityDriver(Account().publicKey, connection)) // when var result = client.findAuctionHouseByAddress(PublicKey(address)).getOrNull() @@ -45,7 +56,9 @@ class AuctionsTests { fun testfindAuctionHouseByAddressReturnsNullForBadAddress() = runTest { // given val address = TestDataProvider.badAddress - val client = AuctionsClient(SolanaConnectionDriver(MockRpcDriver())) + val connection = SolanaConnectionDriver(MockRpcDriver()) + val client = AuctionsClient(connection, + ReadOnlyIdentityDriver(Account().publicKey, connection)) // when var result = client.findAuctionHouseByAddress(PublicKey(address)).getOrNull() @@ -59,12 +72,15 @@ class AuctionsTests { // given val creator = TestDataProvider.auctionHouse.creator val treasuryMint = TestDataProvider.auctionHouse.treasuryMint - val pda = AuctionHouse.pda(creator, treasuryMint).toBase58() + val pda = AuctionHouse.pda(creator, treasuryMint).address.toBase58() + val auctionHouseAccount = TestDataProvider.auctionHouseAccount val expectedAuctionHouse = TestDataProvider.auctionHouse + val connection = SolanaConnectionDriver(MockRpcDriver().apply { + willReturn(AccountRequest(pda), TestAccountResponse(auctionHouseAccount)) + }) - val client = AuctionsClient(SolanaConnectionDriver(MockRpcDriver().apply { - willReturn(AccountRequest(pda), TestAccountResponse(expectedAuctionHouse)) - })) + val client = AuctionsClient(connection, + ReadOnlyIdentityDriver(Account().publicKey, connection)) // when var result = client.findAuctionHouseByCreatorAndMint(creator, treasuryMint).getOrNull() @@ -78,8 +94,9 @@ class AuctionsTests { // given val creator = PublicKey(TestDataProvider.badAddress) val treasuryMint = PublicKey(TestDataProvider.badAddress) - - val client = AuctionsClient(SolanaConnectionDriver(MockRpcDriver())) + val connection = SolanaConnectionDriver(MockRpcDriver()) + val client = AuctionsClient(connection, + ReadOnlyIdentityDriver(Account().publicKey, connection)) // when var result = client.findAuctionHouseByCreatorAndMint(creator, treasuryMint).getOrNull() @@ -87,4 +104,25 @@ class AuctionsTests { // then Assert.assertNull(result) } + //endregion + + //region INTEGRATION + @Test + fun testCreateNewAuctionHouseMinimumConfiguration() = runTest { + // given + val signer = Account() + val connection = MetaplexTestUtils.generateConnectionDriver() + val identityDriver = KeypairIdentityDriver(signer, connection) + val client = AuctionsClient(connection, identityDriver) + + // when + connection.airdrop(signer.publicKey, 1f) + val auctionHouse = client.createAuctionHouse(250).map { + client.findAuctionHouseByAddress(it.address) + } + + // then + Assert.assertNotNull(auctionHouse) + } + //endregion } \ No newline at end of file diff --git a/lib/src/test/java/com/metaplex/lib/modules/auctions/models/AuctionHouseTests.kt b/lib/src/test/java/com/metaplex/lib/modules/auctions/models/AuctionHouseTests.kt deleted file mode 100644 index bc74190..0000000 --- a/lib/src/test/java/com/metaplex/lib/modules/auctions/models/AuctionHouseTests.kt +++ /dev/null @@ -1,48 +0,0 @@ -/* - * AuctionHouseTests - * Metaplex - * - * Created by Funkatronics on 7/19/2022 - */ - -package com.metaplex.lib.modules.auctions.models - -import com.metaplex.data.TestDataProvider -import com.metaplex.data.model.borsh -import com.metaplex.lib.serialization.format.Borsh -import com.metaplex.lib.serialization.serializers.solana.AnchorAccountSerializer -import org.junit.Assert -import org.junit.Test - -class AuctionHouseTests { - - @Test - fun testAuctionHouseDecodeFromBorsh() { - // given - val serializedAH = TestDataProvider.auctionHouse.borsh - val expectedAH = TestDataProvider.auctionHouse - - // when - val deserializedAH = - Borsh.decodeFromByteArray(AnchorAccountSerializer(), serializedAH) - - // then - Assert.assertEquals(expectedAH, deserializedAH) - } - - @Test - fun testAuctionHouseEncode() { - // given - val expectedSerializedBorsh = TestDataProvider.auctionHouse.borsh - val auctionHouse = TestDataProvider.auctionHouse - - // when - val serializedAH = Borsh.encodeToByteArray(AnchorAccountSerializer(), auctionHouse) - val deserializedAH = - Borsh.decodeFromByteArray(AnchorAccountSerializer(), serializedAH) - - // then - Assert.assertArrayEquals(expectedSerializedBorsh, serializedAH) - Assert.assertEquals(auctionHouse, deserializedAH) - } -} \ No newline at end of file diff --git a/lib/src/test/java/com/metaplex/lib/modules/auctions/operations/FindAuctionHouseByAddressOperationTests.kt b/lib/src/test/java/com/metaplex/lib/modules/auctions/operations/FindAuctionHouseByAddressOperationTests.kt new file mode 100644 index 0000000..8d2b1ea --- /dev/null +++ b/lib/src/test/java/com/metaplex/lib/modules/auctions/operations/FindAuctionHouseByAddressOperationTests.kt @@ -0,0 +1,62 @@ +/* + * FindAuctionHouseByAddressOperationTests + * Metaplex + * + * Created by Funkatronics on 10/21/2022 + */ + +@file:OptIn(ExperimentalCoroutinesApi::class) + +package com.metaplex.lib.modules.auctions.operations + +import com.metaplex.data.TestDataProvider +import com.metaplex.lib.drivers.solana.AccountInfo +import com.metaplex.lib.drivers.solana.AccountRequest +import com.metaplex.lib.drivers.solana.SolanaConnectionDriver +import com.metaplex.mock.driver.rpc.MockErrorRpcDriver +import com.metaplex.mock.driver.rpc.MockRpcDriver +import com.solana.core.Account +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.test.runTest +import org.junit.Assert +import org.junit.Test + +class FindAuctionHouseByAddressOperationTests { + + @Test + fun testFindAuctionHouseByAddressOperationReturnsAuctionHouseModel() = runTest { + // given + val expectedAH = TestDataProvider.auctionHouse + val auctionHouseAddress = Account().publicKey + val rpcDriver = MockRpcDriver().apply { + willReturn(AccountRequest(auctionHouseAddress.toBase58()), + AccountInfo(TestDataProvider.auctionHouseAccount, false, 0, null, 0)) + } + + val connection = SolanaConnectionDriver(rpcDriver) + + // when + val actualAH = FindAuctionHouseByAddressOperation(connection) + .run(auctionHouseAddress).getOrThrow() + + // then + Assert.assertEquals(expectedAH, actualAH) + } + + @Test + fun testFindAuctionHouseByAddressOperationHandlesError() = runTest { + // given + val auctionHouseAddress = Account().publicKey + val expectedErrorMessage = "An error occurred" + val rpcDriver = MockErrorRpcDriver(expectedErrorMessage) + val connection = SolanaConnectionDriver(rpcDriver) + + // when + val actualResult = FindAuctionHouseByAddressOperation(connection) + .run(auctionHouseAddress).exceptionOrNull() + + // then + Assert.assertNotNull(actualResult) + Assert.assertEquals(expectedErrorMessage, actualResult?.message) + } +} \ No newline at end of file diff --git a/lib/src/test/java/com/metaplex/mock/driver/rpc/MockRpcDriver.kt b/lib/src/test/java/com/metaplex/mock/driver/rpc/MockRpcDriver.kt index 37d6878..824b409 100644 --- a/lib/src/test/java/com/metaplex/mock/driver/rpc/MockRpcDriver.kt +++ b/lib/src/test/java/com/metaplex/mock/driver/rpc/MockRpcDriver.kt @@ -8,7 +8,10 @@ package com.metaplex.mock.driver.rpc import com.metaplex.lib.drivers.rpc.* +import com.metaplex.lib.drivers.solana.* +import com.solana.core.PublicKey import kotlinx.serialization.KSerializer +import kotlinx.serialization.json.buildJsonObject import kotlinx.serialization.json.jsonArray class MockErrorRpcDriver(val errorMessage: String) : JsonRpcDriver { @@ -18,7 +21,8 @@ class MockErrorRpcDriver(val errorMessage: String) : JsonRpcDriver { ): RpcResponse = RpcResponse(error = RpcError(1234, errorMessage), id = request.id) } -class MockRpcDriver : JsonRpcDriver { +class MockRpcDriver(val autoConfirmTransactions: Boolean = false, + val autoHandleBlockhashRequest: Boolean = true) : JsonRpcDriver { val willReturn = mutableMapOf() val willError = mutableMapOf() @@ -35,6 +39,20 @@ class MockRpcDriver : JsonRpcDriver { request: RpcRequest, resultSerializer: KSerializer ): RpcResponse { + + if (autoConfirmTransactions) when (request) { + is SendTransactionRequest -> return RpcResponse("transaction signature" as R) + is SignatureStatusRequest -> return RpcResponse(listOf( + SignatureStatus(1, 30, null, "finalized") + ) as R) + } + + if (autoHandleBlockhashRequest && request is RecentBlockhashRequest) + return RpcResponse(BlockhashResponse( + PublicKey(ByteArray(PublicKey.PUBLIC_KEY_LENGTH)).toString(), + buildJsonObject { } + ) as R) + findErrorForRequest(request)?.let { error -> return RpcResponse(error = RpcError(error.code, error.message)) }