chore: split example into lib and script
This commit is contained in:
@@ -1,17 +1,10 @@
|
|||||||
use aiken/context.{ScriptContext}
|
use aiken/builtins.{appendByteString}
|
||||||
|
|
||||||
pub type Datum {
|
pub type Bool {
|
||||||
something: String,
|
True
|
||||||
|
False
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type Redeemer {
|
pub fn append(a: ByteArray, b: ByteArray) -> ByteArray {
|
||||||
Buy
|
appendByteString(a, b)
|
||||||
Sell
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn validate(datum: Datum, rdmr: Redeemer, ctx: ScriptContext) -> Bool {
|
|
||||||
when rdmr is {
|
|
||||||
Buy -> True
|
|
||||||
Sell -> datum.something == "Aiken"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
17
examples/sample/scripts/swap.ak
Normal file
17
examples/sample/scripts/swap.ak
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
use sample/syntax.{append, Bool}
|
||||||
|
|
||||||
|
pub type Datum {
|
||||||
|
something: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type Redeemer {
|
||||||
|
Buy
|
||||||
|
Sell
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn validate(datum: Datum, rdmr: Redeemer, ctx: ScriptContext) -> Bool {
|
||||||
|
when rdmr is {
|
||||||
|
Buy -> True
|
||||||
|
Sell -> datum.something == "Aiken"
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user