fix: constr issue
- also fixed constant parsing - added new cbor flag to eval Co-authored-by: rvcas <x@rvcas.dev>
This commit is contained in:
parent
7875af7d35
commit
3f47a1f4b8
|
@ -14,12 +14,31 @@ pub struct Args {
|
||||||
#[clap(short, long)]
|
#[clap(short, long)]
|
||||||
flat: bool,
|
flat: bool,
|
||||||
|
|
||||||
|
#[clap(short, long)]
|
||||||
|
cbor: bool,
|
||||||
|
|
||||||
/// Arguments to pass to the uplc program
|
/// Arguments to pass to the uplc program
|
||||||
args: Vec<String>,
|
args: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(Args { script, flat, args }: Args) -> miette::Result<()> {
|
pub fn exec(
|
||||||
let mut program = if flat {
|
Args {
|
||||||
|
script,
|
||||||
|
flat,
|
||||||
|
args,
|
||||||
|
cbor,
|
||||||
|
}: Args,
|
||||||
|
) -> miette::Result<()> {
|
||||||
|
let mut program = if cbor {
|
||||||
|
let cbor_hex = std::fs::read_to_string(&script).into_diagnostic()?;
|
||||||
|
|
||||||
|
let raw_cbor = hex::decode(&cbor_hex).into_diagnostic()?;
|
||||||
|
|
||||||
|
let prog = Program::<FakeNamedDeBruijn>::from_cbor(&raw_cbor, &mut Vec::new())
|
||||||
|
.into_diagnostic()?;
|
||||||
|
|
||||||
|
prog.into()
|
||||||
|
} else if flat {
|
||||||
let bytes = std::fs::read(&script).into_diagnostic()?;
|
let bytes = std::fs::read(&script).into_diagnostic()?;
|
||||||
|
|
||||||
let prog = Program::<FakeNamedDeBruijn>::from_flat(&bytes).into_diagnostic()?;
|
let prog = Program::<FakeNamedDeBruijn>::from_flat(&bytes).into_diagnostic()?;
|
||||||
|
|
|
@ -33,6 +33,7 @@ where
|
||||||
miette::bail!("failed: {} error(s), {warning_count} warning(s)", err.len(),);
|
miette::bail!("failed: {} error(s), {warning_count} warning(s)", err.len(),);
|
||||||
};
|
};
|
||||||
|
|
||||||
println!("finished with {warning_count} warning(s)");
|
println!("\nfinished with {warning_count} warning(s)\n");
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -306,10 +306,12 @@ fn constant_value_parser() -> impl Parser<Token, ast::UntypedConstant, Error = P
|
||||||
});
|
});
|
||||||
|
|
||||||
let constant_tuple_parser = just(Token::Hash)
|
let constant_tuple_parser = just(Token::Hash)
|
||||||
.ignore_then(r.clone())
|
.ignore_then(
|
||||||
|
r.clone()
|
||||||
.separated_by(just(Token::Comma))
|
.separated_by(just(Token::Comma))
|
||||||
.allow_trailing()
|
.allow_trailing()
|
||||||
.delimited_by(just(Token::LeftParen), just(Token::RightParen))
|
.delimited_by(just(Token::LeftParen), just(Token::RightParen)),
|
||||||
|
)
|
||||||
.map_with_span(|elements, span| ast::UntypedConstant::Tuple {
|
.map_with_span(|elements, span| ast::UntypedConstant::Tuple {
|
||||||
location: span,
|
location: span,
|
||||||
elements,
|
elements,
|
||||||
|
@ -317,7 +319,8 @@ fn constant_value_parser() -> impl Parser<Token, ast::UntypedConstant, Error = P
|
||||||
|
|
||||||
let constant_bytearray_parser = just(Token::Hash)
|
let constant_bytearray_parser = just(Token::Hash)
|
||||||
.ignore_then(
|
.ignore_then(
|
||||||
select! {Token::Int {value} => value}.validate(|value, span, emit| {
|
select! {Token::Int {value} => value}
|
||||||
|
.validate(|value, span, emit| {
|
||||||
let byte: u8 = match value.parse() {
|
let byte: u8 = match value.parse() {
|
||||||
Ok(b) => b,
|
Ok(b) => b,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
|
@ -332,11 +335,11 @@ fn constant_value_parser() -> impl Parser<Token, ast::UntypedConstant, Error = P
|
||||||
};
|
};
|
||||||
|
|
||||||
byte
|
byte
|
||||||
}),
|
})
|
||||||
)
|
|
||||||
.separated_by(just(Token::Comma))
|
.separated_by(just(Token::Comma))
|
||||||
.allow_trailing()
|
.allow_trailing()
|
||||||
.delimited_by(just(Token::LeftSquare), just(Token::RightSquare))
|
.delimited_by(just(Token::LeftSquare), just(Token::RightSquare)),
|
||||||
|
)
|
||||||
.map_with_span(|bytes, span| ast::UntypedConstant::ByteArray {
|
.map_with_span(|bytes, span| ast::UntypedConstant::ByteArray {
|
||||||
location: span,
|
location: span,
|
||||||
bytes,
|
bytes,
|
||||||
|
@ -453,8 +456,8 @@ fn constant_value_parser() -> impl Parser<Token, ast::UntypedConstant, Error = P
|
||||||
choice((
|
choice((
|
||||||
constant_string_parser,
|
constant_string_parser,
|
||||||
constant_int_parser,
|
constant_int_parser,
|
||||||
constant_tuple_parser,
|
|
||||||
constant_bytearray_parser,
|
constant_bytearray_parser,
|
||||||
|
constant_tuple_parser,
|
||||||
constant_list_parser,
|
constant_list_parser,
|
||||||
constant_record_parser,
|
constant_record_parser,
|
||||||
constant_var_parser,
|
constant_var_parser,
|
||||||
|
@ -1271,6 +1274,7 @@ pub fn type_parser() -> impl Parser<Token, ast::Annotation, Error = ParseError>
|
||||||
.ignore_then(
|
.ignore_then(
|
||||||
r.clone()
|
r.clone()
|
||||||
.separated_by(just(Token::Comma))
|
.separated_by(just(Token::Comma))
|
||||||
|
.allow_trailing()
|
||||||
.delimited_by(just(Token::LeftParen), just(Token::RightParen)),
|
.delimited_by(just(Token::LeftParen), just(Token::RightParen)),
|
||||||
)
|
)
|
||||||
.map_with_span(|elems, span| ast::Annotation::Tuple {
|
.map_with_span(|elems, span| ast::Annotation::Tuple {
|
||||||
|
@ -1497,6 +1501,7 @@ pub fn pattern_parser() -> impl Parser<Token, ast::UntypedPattern, Error = Parse
|
||||||
.ignore_then(
|
.ignore_then(
|
||||||
r.clone()
|
r.clone()
|
||||||
.separated_by(just(Token::Comma))
|
.separated_by(just(Token::Comma))
|
||||||
|
.allow_trailing()
|
||||||
.delimited_by(just(Token::LeftParen), just(Token::RightParen)),
|
.delimited_by(just(Token::LeftParen), just(Token::RightParen)),
|
||||||
)
|
)
|
||||||
.map_with_span(|elems, span| ast::UntypedPattern::Tuple {
|
.map_with_span(|elems, span| ast::UntypedPattern::Tuple {
|
||||||
|
|
|
@ -30,8 +30,8 @@ pub fn lexer() -> impl Parser<char, Vec<(Token, Span)>, Error = ParseError> {
|
||||||
just("||").to(Token::VbarVbar),
|
just("||").to(Token::VbarVbar),
|
||||||
just('|').to(Token::Vbar),
|
just('|').to(Token::Vbar),
|
||||||
just("&&").to(Token::AmperAmper),
|
just("&&").to(Token::AmperAmper),
|
||||||
just("\n\n").to(Token::EmptyLine),
|
|
||||||
just('#').to(Token::Hash),
|
just('#').to(Token::Hash),
|
||||||
|
just("\n\n").to(Token::EmptyLine),
|
||||||
));
|
));
|
||||||
|
|
||||||
let grouping = choice((
|
let grouping = choice((
|
||||||
|
|
|
@ -215,7 +215,7 @@ pub enum Error {
|
||||||
types: Vec<String>,
|
types: Vec<String>,
|
||||||
},
|
},
|
||||||
|
|
||||||
#[error("Unknown variable\n\n{name}\n")]
|
#[error("Unknown variable\n\n {name}\n")]
|
||||||
UnknownVariable {
|
UnknownVariable {
|
||||||
#[label]
|
#[label]
|
||||||
location: Span,
|
location: Span,
|
||||||
|
|
|
@ -5,11 +5,10 @@ use itertools::Itertools;
|
||||||
use uplc::{
|
use uplc::{
|
||||||
ast::{
|
ast::{
|
||||||
builder::{self, constr_index_exposer, CONSTR_FIELDS_EXPOSER, CONSTR_GET_FIELD},
|
builder::{self, constr_index_exposer, CONSTR_FIELDS_EXPOSER, CONSTR_GET_FIELD},
|
||||||
Constant as UplcConstant, Name, Program, Term,
|
Constant as UplcConstant, Name, Program, Term, Type as UplcType,
|
||||||
},
|
},
|
||||||
builtins::DefaultFunction,
|
builtins::DefaultFunction,
|
||||||
parser::interner::Interner,
|
parser::interner::Interner,
|
||||||
BigInt, PlutusData,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -166,12 +165,18 @@ impl<'a> CodeGenerator<'a> {
|
||||||
TypedExpr::Var {
|
TypedExpr::Var {
|
||||||
constructor, name, ..
|
constructor, name, ..
|
||||||
} => {
|
} => {
|
||||||
|
if let ValueConstructorVariant::ModuleConstant { literal, .. } =
|
||||||
|
&constructor.variant
|
||||||
|
{
|
||||||
|
constants_ir(literal, ir_stack, scope);
|
||||||
|
} else {
|
||||||
ir_stack.push(Air::Var {
|
ir_stack.push(Air::Var {
|
||||||
scope,
|
scope,
|
||||||
constructor: constructor.clone(),
|
constructor: constructor.clone(),
|
||||||
name: name.clone(),
|
name: name.clone(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
TypedExpr::Fn { .. } => todo!(),
|
TypedExpr::Fn { .. } => todo!(),
|
||||||
TypedExpr::List {
|
TypedExpr::List {
|
||||||
elements,
|
elements,
|
||||||
|
@ -1371,7 +1376,9 @@ impl<'a> CodeGenerator<'a> {
|
||||||
text: name,
|
text: name,
|
||||||
unique: 0.into(),
|
unique: 0.into(),
|
||||||
})),
|
})),
|
||||||
ValueConstructorVariant::ModuleConstant { .. } => todo!(),
|
ValueConstructorVariant::ModuleConstant { .. } => {
|
||||||
|
unreachable!()
|
||||||
|
}
|
||||||
ValueConstructorVariant::ModuleFn {
|
ValueConstructorVariant::ModuleFn {
|
||||||
name: func_name,
|
name: func_name,
|
||||||
module,
|
module,
|
||||||
|
@ -1420,25 +1427,78 @@ impl<'a> CodeGenerator<'a> {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let mut fields =
|
let mut fields =
|
||||||
Term::Constant(UplcConstant::Data(PlutusData::Array(vec![])));
|
Term::Constant(UplcConstant::ProtoList(UplcType::Data, vec![]));
|
||||||
|
|
||||||
|
let tipo = constructor.tipo;
|
||||||
|
|
||||||
|
let args_type = match tipo.as_ref() {
|
||||||
|
Type::Fn { args, .. } => args,
|
||||||
|
|
||||||
|
_ => todo!(),
|
||||||
|
};
|
||||||
|
|
||||||
if let Some(field_map) = field_map.clone() {
|
if let Some(field_map) = field_map.clone() {
|
||||||
for field in field_map
|
for field in field_map
|
||||||
.fields
|
.fields
|
||||||
.iter()
|
.iter()
|
||||||
.sorted_by(|item1, item2| item1.1.cmp(item2.1))
|
.sorted_by(|item1, item2| item1.1.cmp(item2.1))
|
||||||
|
.zip(args_type)
|
||||||
.rev()
|
.rev()
|
||||||
{
|
{
|
||||||
|
let arg_to_data = if field.1.as_ref().is_bytearray() {
|
||||||
|
Term::Apply {
|
||||||
|
function: Term::Builtin(DefaultFunction::BData).into(),
|
||||||
|
argument: Term::Var(Name {
|
||||||
|
text: field.0 .0.clone(),
|
||||||
|
unique: 0.into(),
|
||||||
|
})
|
||||||
|
.into(),
|
||||||
|
}
|
||||||
|
} else if field.1.as_ref().is_int() {
|
||||||
|
Term::Apply {
|
||||||
|
function: Term::Builtin(DefaultFunction::IData).into(),
|
||||||
|
argument: Term::Var(Name {
|
||||||
|
text: field.0 .0.clone(),
|
||||||
|
unique: 0.into(),
|
||||||
|
})
|
||||||
|
.into(),
|
||||||
|
}
|
||||||
|
} else if field.1.as_ref().is_list() {
|
||||||
|
Term::Apply {
|
||||||
|
function: Term::Builtin(DefaultFunction::ListData).into(),
|
||||||
|
argument: Term::Var(Name {
|
||||||
|
text: field.0 .0.clone(),
|
||||||
|
unique: 0.into(),
|
||||||
|
})
|
||||||
|
.into(),
|
||||||
|
}
|
||||||
|
} else if field.1.as_ref().is_string() {
|
||||||
|
Term::Apply {
|
||||||
|
function: Term::Builtin(DefaultFunction::BData).into(),
|
||||||
|
argument: Term::Apply {
|
||||||
|
function: Term::Builtin(DefaultFunction::DecodeUtf8)
|
||||||
|
.into(),
|
||||||
|
argument: Term::Var(Name {
|
||||||
|
text: field.0 .0.clone(),
|
||||||
|
unique: 0.into(),
|
||||||
|
})
|
||||||
|
.into(),
|
||||||
|
}
|
||||||
|
.into(),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Term::Var(Name {
|
||||||
|
text: field.0 .0.clone(),
|
||||||
|
unique: 0.into(),
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
fields = Term::Apply {
|
fields = Term::Apply {
|
||||||
function: Term::Apply {
|
function: Term::Apply {
|
||||||
function: Term::Builtin(DefaultFunction::MkCons)
|
function: Term::Builtin(DefaultFunction::MkCons)
|
||||||
.force_wrap()
|
.force_wrap()
|
||||||
.into(),
|
.into(),
|
||||||
argument: Term::Var(Name {
|
argument: arg_to_data.into(),
|
||||||
text: field.0.clone(),
|
|
||||||
unique: 0.into(),
|
|
||||||
})
|
|
||||||
.into(),
|
|
||||||
}
|
}
|
||||||
.into(),
|
.into(),
|
||||||
argument: fields.into(),
|
argument: fields.into(),
|
||||||
|
@ -1447,25 +1507,15 @@ impl<'a> CodeGenerator<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut term = Term::Apply {
|
let mut term = Term::Apply {
|
||||||
function: Term::Builtin(DefaultFunction::ConstrData).into(),
|
|
||||||
argument: Term::Apply {
|
|
||||||
function: Term::Apply {
|
function: Term::Apply {
|
||||||
function: Term::Builtin(DefaultFunction::MkPairData).into(),
|
function: Term::Builtin(DefaultFunction::ConstrData).into(),
|
||||||
argument: Term::Constant(UplcConstant::Data(
|
argument: Term::Constant(UplcConstant::Integer(
|
||||||
PlutusData::BigInt(BigInt::Int(
|
constr_index.try_into().unwrap(),
|
||||||
(constr_index as i128).try_into().unwrap(),
|
|
||||||
)),
|
|
||||||
))
|
))
|
||||||
.into(),
|
.into(),
|
||||||
}
|
}
|
||||||
.into(),
|
.into(),
|
||||||
argument: Term::Apply {
|
|
||||||
function: Term::Builtin(DefaultFunction::ListData).into(),
|
|
||||||
argument: fields.into(),
|
argument: fields.into(),
|
||||||
}
|
|
||||||
.into(),
|
|
||||||
}
|
|
||||||
.into(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(field_map) = field_map {
|
if let Some(field_map) = field_map {
|
||||||
|
@ -2243,7 +2293,6 @@ impl<'a> CodeGenerator<'a> {
|
||||||
|
|
||||||
arg_stack.push(term);
|
arg_stack.push(term);
|
||||||
}
|
}
|
||||||
|
|
||||||
Air::ListClause {
|
Air::ListClause {
|
||||||
tail_name,
|
tail_name,
|
||||||
next_tail_name,
|
next_tail_name,
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
addr1wxdwvaptgf8kvxj3xuud67y6mnzgkvmkmz620nc77e9u65ghx46hl
|
addr1wyqlmv9mg7cc5gcrhkxsnund3640hrfmj7ynxpcpc5kux2c6u6ewl
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"type": "PlutusScriptV2",
|
"type": "PlutusScriptV2",
|
||||||
"description": "Generated by Aiken",
|
"description": "Generated by Aiken",
|
||||||
"cborHex": "58b258b0010000222533357346464646464a666ae68cdc3800a40002646466e3c0052201030303ff00375c6ae84004c01400854ccd5cd19b87001480084c8c8cdc7800a441030303ff00375c6ae84004c0140085281aab9d375400200266446e94cdd82601010000374e66ae80008cd5d0000a61029fff004881030404ff00483403c88c8ccc00400520000032223333573466e1c0100095d0919980200219b8000348008d5d100080091aab9e37540022930b01"
|
"cborHex": "5854585201000022253335734646466e3cdd7198009801002a40006eb8cc004c008011200022323330010014800000c888cccd5cd19b870040025742466600800866e0000d20023574400200246aae78dd50008a4c2d"
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@
|
||||||
(lam
|
(lam
|
||||||
datum
|
datum
|
||||||
(lam
|
(lam
|
||||||
_
|
rdmr
|
||||||
(lam
|
(lam
|
||||||
_
|
_
|
||||||
(force
|
(force
|
||||||
|
@ -17,157 +17,30 @@
|
||||||
[
|
[
|
||||||
(lam
|
(lam
|
||||||
__constr_get_field
|
__constr_get_field
|
||||||
[
|
|
||||||
(lam
|
|
||||||
x
|
|
||||||
[
|
|
||||||
(lam
|
|
||||||
__constr_name_8
|
|
||||||
[
|
|
||||||
(lam
|
|
||||||
__subject_name_7
|
|
||||||
(force
|
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
(force (builtin ifThenElse))
|
(force (builtin ifThenElse))
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
(builtin equalsInteger)
|
(builtin equalsByteString)
|
||||||
__subject_name_7
|
[
|
||||||
|
(builtin unBData)
|
||||||
|
[
|
||||||
|
[
|
||||||
|
__constr_get_field
|
||||||
|
[ __constr_fields_exposer datum ]
|
||||||
]
|
]
|
||||||
(con integer 0)
|
(con integer 0)
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
(delay
|
|
||||||
[
|
|
||||||
(lam
|
|
||||||
__constr_fields_18
|
|
||||||
[
|
|
||||||
(lam
|
|
||||||
signer
|
|
||||||
[
|
|
||||||
[
|
|
||||||
(builtin
|
|
||||||
equalsByteString
|
|
||||||
)
|
|
||||||
signer
|
|
||||||
]
|
]
|
||||||
(con bytestring #0303ff)
|
(con bytestring #0102)
|
||||||
]
|
|
||||||
)
|
|
||||||
[
|
|
||||||
(builtin unBData)
|
|
||||||
[
|
|
||||||
(force (builtin headList))
|
|
||||||
__constr_fields_18
|
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
(con bool False)
|
||||||
]
|
]
|
||||||
)
|
(con bool True)
|
||||||
[
|
|
||||||
__constr_fields_exposer
|
|
||||||
__constr_name_8
|
|
||||||
]
|
|
||||||
]
|
|
||||||
)
|
|
||||||
]
|
|
||||||
(delay
|
|
||||||
(force
|
|
||||||
[
|
|
||||||
[
|
|
||||||
[
|
|
||||||
(force (builtin ifThenElse))
|
|
||||||
[
|
|
||||||
[
|
|
||||||
(builtin equalsInteger)
|
|
||||||
__subject_name_7
|
|
||||||
]
|
|
||||||
(con integer 1)
|
|
||||||
]
|
|
||||||
]
|
|
||||||
(delay
|
|
||||||
[
|
|
||||||
(lam
|
|
||||||
__constr_fields_17
|
|
||||||
[
|
|
||||||
(lam
|
|
||||||
signer
|
|
||||||
[
|
|
||||||
[
|
|
||||||
(builtin
|
|
||||||
equalsByteString
|
|
||||||
)
|
|
||||||
signer
|
|
||||||
]
|
|
||||||
(con
|
|
||||||
bytestring
|
|
||||||
#0303ff
|
|
||||||
)
|
|
||||||
]
|
|
||||||
)
|
|
||||||
[
|
|
||||||
(builtin unBData)
|
|
||||||
[
|
|
||||||
(force
|
|
||||||
(builtin headList)
|
|
||||||
)
|
|
||||||
__constr_fields_17
|
|
||||||
]
|
|
||||||
]
|
|
||||||
]
|
|
||||||
)
|
|
||||||
[
|
|
||||||
__constr_fields_exposer
|
|
||||||
__constr_name_8
|
|
||||||
]
|
|
||||||
]
|
|
||||||
)
|
|
||||||
]
|
|
||||||
(delay (con bool False))
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
[
|
|
||||||
(force (force (builtin fstPair)))
|
|
||||||
[ (builtin unConstrData) __constr_name_8 ]
|
|
||||||
]
|
|
||||||
]
|
|
||||||
)
|
|
||||||
x
|
|
||||||
]
|
|
||||||
)
|
|
||||||
[
|
|
||||||
[
|
|
||||||
(lam
|
|
||||||
signer
|
|
||||||
(lam
|
|
||||||
amount
|
|
||||||
[
|
|
||||||
(builtin constrData)
|
|
||||||
[
|
|
||||||
[ (builtin mkPairData) (con data #00) ]
|
|
||||||
[
|
|
||||||
(builtin listData)
|
|
||||||
[
|
|
||||||
[ (force (builtin mkCons)) signer ]
|
|
||||||
[
|
|
||||||
[ (force (builtin mkCons)) amount ]
|
|
||||||
(con data #9fff)
|
|
||||||
]
|
|
||||||
]
|
|
||||||
]
|
|
||||||
]
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
(con bytestring #0404ff)
|
|
||||||
]
|
|
||||||
(con integer 1000)
|
|
||||||
]
|
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
(lam
|
(lam
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
58b0010000222533357346464646464a666ae68cdc3800a40002646466e3c0052201030303ff00375c6ae84004c01400854ccd5cd19b87001480084c8c8cdc7800a441030303ff00375c6ae84004c0140085281aab9d375400200266446e94cdd82601010000374e66ae80008cd5d0000a61029fff004881030404ff00483403c88c8ccc00400520000032223333573466e1c0100095d0919980200219b8000348008d5d100080091aab9e37540022930b01
|
585201000022253335734646466e3cdd7198009801002a40006eb8cc004c008011200022323330010014800000c888cccd5cd19b870040025742466600800866e0000d20023574400200246aae78dd50008a4c2d
|
|
@ -1 +1 @@
|
||||||
addr_test1wzdwvaptgf8kvxj3xuud67y6mnzgkvmkmz620nc77e9u65gvwpxc6
|
addr_test1wqqlmv9mg7cc5gcrhkxsnund3640hrfmj7ynxpcpc5kux2cp5w9p6
|
|
@ -1,49 +1,7 @@
|
||||||
pub type Signer {
|
pub type Redeemer {
|
||||||
hash: ByteArray,
|
signer: ByteArray,
|
||||||
}
|
|
||||||
|
|
||||||
pub type ScriptContext {
|
|
||||||
signer: Signer,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub type Redeem {
|
|
||||||
Buy { tipo: ByteArray, fin: Int }
|
|
||||||
Sell { twice: ByteArray, find: Int }
|
|
||||||
Hold(Int)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type Datum {
|
pub type Datum {
|
||||||
fin: Int,
|
random: ByteArray,
|
||||||
sc: ScriptContext,
|
|
||||||
rdmr: Redeem,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn eqIntPlusOne(a: Int, b: Int) {
|
|
||||||
a + 1 == b
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn eqString(a: ByteArray, b: ByteArray) {
|
|
||||||
a == b
|
|
||||||
}
|
|
||||||
|
|
||||||
pub type Thing {
|
|
||||||
Some
|
|
||||||
None
|
|
||||||
}
|
|
||||||
|
|
||||||
pub type Other {
|
|
||||||
Wow
|
|
||||||
Yes
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn incrementor(counter: Int, target: Int) -> Int {
|
|
||||||
if counter == target {
|
|
||||||
counter
|
|
||||||
} else if counter > target {
|
|
||||||
counter - target
|
|
||||||
} else {
|
|
||||||
incrementor(counter + 1, target)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub const big_a = 5
|
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
pub type ScriptContext(purpose) {
|
|
||||||
tx_info: TxInfo,
|
|
||||||
script_purpose: purpose,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub type TxInfo {
|
|
||||||
idk: Int,
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
use sample/context
|
|
||||||
|
|
||||||
pub type Mint {
|
|
||||||
currency_symbol: ByteArray,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub type ScriptContext =
|
|
||||||
context.ScriptContext(Mint)
|
|
|
@ -1,8 +0,0 @@
|
||||||
use sample/context
|
|
||||||
|
|
||||||
pub type Spend {
|
|
||||||
idk: Int,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub type ScriptContext =
|
|
||||||
context.ScriptContext(Spend)
|
|
|
@ -1,60 +1,5 @@
|
||||||
use sample
|
use sample
|
||||||
use sample/mint
|
|
||||||
use sample/spend
|
|
||||||
use aiken/builtin
|
|
||||||
|
|
||||||
const something = 5
|
pub fn spend(datum: sample.Datum, rdmr: sample.Redeemer, _ctx: Nil) -> Bool {
|
||||||
|
datum.random == rdmr.signer
|
||||||
pub type Redeemer {
|
|
||||||
signer: ByteArray,
|
|
||||||
amount: Int,
|
|
||||||
other_thing: Redeemer,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub type Reen {
|
|
||||||
Buy1 { signer: ByteArray, amount: Int }
|
|
||||||
Stuff(ByteArray, Int)
|
|
||||||
Sell1
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn twice(f: fn(Int) -> Int, initial: Int) -> Int {
|
|
||||||
f(f(initial))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn add_one(value: Int) -> Int {
|
|
||||||
value + 1
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn add_two(x: Int) -> Int {
|
|
||||||
twice(add_one, x)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn final_check(z: Int) {
|
|
||||||
z < 4
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn incrementor(counter: Int, target: Int) -> Int {
|
|
||||||
if counter == target {
|
|
||||||
counter
|
|
||||||
} else if counter > target {
|
|
||||||
counter - target
|
|
||||||
} else {
|
|
||||||
incrementor(counter + 1, target)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub type Datum {
|
|
||||||
Offer { prices: List(Int), asset_class: ByteArray, other_thing: Datum }
|
|
||||||
Sell
|
|
||||||
Hold(Int)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn spend(datum: Datum, _rdmr: Nil, _ctx: Nil) -> Bool {
|
|
||||||
let amount = 1000
|
|
||||||
let x = Buy1 { signer: #[4, 4, 255], amount }
|
|
||||||
when x is {
|
|
||||||
Buy1 { signer, .. } -> signer == #[3, 3, 255]
|
|
||||||
Stuff(signer, _) -> signer == #[3, 3, 255]
|
|
||||||
_ -> False
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue