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:
Kasey White
2022-12-05 22:46:33 -05:00
committed by Lucas
parent 7875af7d35
commit 3f47a1f4b8
16 changed files with 155 additions and 329 deletions

View File

@@ -1 +1 @@
addr1wxdwvaptgf8kvxj3xuud67y6mnzgkvmkmz620nc77e9u65ghx46hl
addr1wyqlmv9mg7cc5gcrhkxsnund3640hrfmj7ynxpcpc5kux2c6u6ewl

View File

@@ -1,5 +1,5 @@
{
"type": "PlutusScriptV2",
"description": "Generated by Aiken",
"cborHex": "58b258b0010000222533357346464646464a666ae68cdc3800a40002646466e3c0052201030303ff00375c6ae84004c01400854ccd5cd19b87001480084c8c8cdc7800a441030303ff00375c6ae84004c0140085281aab9d375400200266446e94cdd82601010000374e66ae80008cd5d0000a61029fff004881030404ff00483403c88c8ccc00400520000032223333573466e1c0100095d0919980200219b8000348008d5d100080091aab9e37540022930b01"
"cborHex": "5854585201000022253335734646466e3cdd7198009801002a40006eb8cc004c008011200022323330010014800000c888cccd5cd19b870040025742466600800866e0000d20023574400200246aae78dd50008a4c2d"
}

View File

@@ -3,7 +3,7 @@
(lam
datum
(lam
_
rdmr
(lam
_
(force
@@ -18,156 +18,29 @@
(lam
__constr_get_field
[
(lam
x
[
(lam
__constr_name_8
[
(lam
__subject_name_7
(force
[
[
[
(force (builtin ifThenElse))
[
[
(builtin equalsInteger)
__subject_name_7
]
(con integer 0)
]
]
(delay
[
(lam
__constr_fields_18
[
(lam
signer
[
[
(builtin
equalsByteString
)
signer
]
(con bytestring #0303ff)
]
)
[
(builtin unBData)
[
(force (builtin headList))
__constr_fields_18
]
]
]
)
[
__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
(force (builtin ifThenElse))
[
[
(builtin equalsByteString)
[
(builtin constrData)
(builtin unBData)
[
[ (builtin mkPairData) (con data #00) ]
[
(builtin listData)
[
[ (force (builtin mkCons)) signer ]
[
[ (force (builtin mkCons)) amount ]
(con data #9fff)
]
]
__constr_get_field
[ __constr_fields_exposer datum ]
]
(con integer 0)
]
]
)
)
(con bytestring #0404ff)
]
(con bytestring #0102)
]
]
(con integer 1000)
(con bool False)
]
(con bool True)
]
)
(lam

View File

@@ -1 +1 @@
58b0010000222533357346464646464a666ae68cdc3800a40002646466e3c0052201030303ff00375c6ae84004c01400854ccd5cd19b87001480084c8c8cdc7800a441030303ff00375c6ae84004c0140085281aab9d375400200266446e94cdd82601010000374e66ae80008cd5d0000a61029fff004881030404ff00483403c88c8ccc00400520000032223333573466e1c0100095d0919980200219b8000348008d5d100080091aab9e37540022930b01
585201000022253335734646466e3cdd7198009801002a40006eb8cc004c008011200022323330010014800000c888cccd5cd19b870040025742466600800866e0000d20023574400200246aae78dd50008a4c2d

View File

@@ -1 +1 @@
addr_test1wzdwvaptgf8kvxj3xuud67y6mnzgkvmkmz620nc77e9u65gvwpxc6
addr_test1wqqlmv9mg7cc5gcrhkxsnund3640hrfmj7ynxpcpc5kux2cp5w9p6

View File

@@ -1,49 +1,7 @@
pub type Signer {
hash: ByteArray,
}
pub type ScriptContext {
signer: Signer,
}
pub type Redeem {
Buy { tipo: ByteArray, fin: Int }
Sell { twice: ByteArray, find: Int }
Hold(Int)
pub type Redeemer {
signer: ByteArray,
}
pub type Datum {
fin: Int,
sc: ScriptContext,
rdmr: Redeem,
random: ByteArray,
}
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

View File

@@ -1,8 +0,0 @@
pub type ScriptContext(purpose) {
tx_info: TxInfo,
script_purpose: purpose,
}
pub type TxInfo {
idk: Int,
}

View File

@@ -1,8 +0,0 @@
use sample/context
pub type Mint {
currency_symbol: ByteArray,
}
pub type ScriptContext =
context.ScriptContext(Mint)

View File

@@ -1,8 +0,0 @@
use sample/context
pub type Spend {
idk: Int,
}
pub type ScriptContext =
context.ScriptContext(Spend)

View File

@@ -1,60 +1,5 @@
use sample
use sample/mint
use sample/spend
use aiken/builtin
const something = 5
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
}
pub fn spend(datum: sample.Datum, rdmr: sample.Redeemer, _ctx: Nil) -> Bool {
datum.random == rdmr.signer
}