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

Make compatible with multisig and Plutus based wallets #8

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
15 changes: 11 additions & 4 deletions validators/ask.ak
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Datum {
payouts: List<Payout>,
/// Flexible to allow discounts
/// The key that listed the NFT
owner: VerificationKeyHash,
owner: PaymentCredential,
}

/// A user can either buy a token
Expand All @@ -35,7 +35,7 @@ validator {
fn spend(datum: Datum, redeemer: Redeemer, ctx: ScriptContext) -> Bool {
let ScriptContext { transaction, purpose } = ctx

let Transaction { outputs, extra_signatories, .. } = transaction
let Transaction { outputs, extra_signatories, inputs, .. } = transaction

// Match on the action.
when redeemer is {
Expand Down Expand Up @@ -88,9 +88,16 @@ validator {
// There's not much to do here. An asset
// owner can cancel or update their listing
// at any time.
WithdrawOrUpdate ->
WithdrawOrUpdate -> {
// is signed by owner
list.has(extra_signatories, datum.owner)
let has_owner_signature = list.has(extra_signatories, datum.owner)
let has_owner_input =
list.any(
inputs,
fn(input) { input.output.address.payment_credential == datum.owner },
)
has_owner_signature || has_owner_input
}
}
}
}