Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AH] Ensure either the seller or the authority is passed as signer on the sell instruction #912

Merged
merged 3 commits into from
Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions auction-house/js/idl/auction_house.json
Original file line number Diff line number Diff line change
Expand Up @@ -3329,6 +3329,11 @@
"code": 6043,
"name": "InsufficientFunds",
"msg": "Insufficient funds in escrow account to purchase."
},
{
"code": 6044,
"name": "SaleRequiresExactlyOneSigner",
"msg": "This sale requires exactly one signer: either the seller or the authority."
}
],
"metadata": {
Expand Down
23 changes: 23 additions & 0 deletions auction-house/js/src/generated/errors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,29 @@ export class InsufficientFundsError extends Error {
createErrorFromCodeLookup.set(0x179b, () => new InsufficientFundsError());
createErrorFromNameLookup.set('InsufficientFunds', () => new InsufficientFundsError());

/**
* SaleRequiresExactlyOneSigner: 'This sale requires exactly one signer: either the seller or the authority.'
*
* @category Errors
* @category generated
*/
export class SaleRequiresExactlyOneSignerError extends Error {
readonly code: number = 0x179c;
readonly name: string = 'SaleRequiresExactlyOneSigner';
constructor() {
super('This sale requires exactly one signer: either the seller or the authority.');
if (typeof Error.captureStackTrace === 'function') {
Error.captureStackTrace(this, SaleRequiresExactlyOneSignerError);
}
}
}

createErrorFromCodeLookup.set(0x179c, () => new SaleRequiresExactlyOneSignerError());
createErrorFromNameLookup.set(
'SaleRequiresExactlyOneSigner',
() => new SaleRequiresExactlyOneSignerError(),
);

/**
* Attempts to resolve a custom program error from the provided error code.
* @category Errors
Expand Down
4 changes: 4 additions & 0 deletions auction-house/program/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,8 @@ pub enum AuctionHouseError {
// 6043
#[msg("Insufficient funds in escrow account to purchase.")]
InsufficientFunds,

// 6044
#[msg("This sale requires exactly one signer: either the seller or the authority.")]
SaleRequiresExactlyOneSigner,
}
3 changes: 3 additions & 0 deletions auction-house/program/src/sell/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,9 @@ fn sell_logic<'info>(
{
return Err(AuctionHouseError::SaleRequiresSigner.into());
}
if wallet.to_account_info().is_signer && authority.to_account_info().is_signer {
return Err(AuctionHouseError::SaleRequiresExactlyOneSigner.into());
}

let auction_house_key = auction_house.key();

Expand Down