diff --git a/crates/lang/src/builtins.rs b/crates/lang/src/builtins.rs index e54e96c5..07b356a5 100644 --- a/crates/lang/src/builtins.rs +++ b/crates/lang/src/builtins.rs @@ -240,10 +240,7 @@ pub fn plutus(id_gen: &IdGenerator) -> TypeInfo { for builtin in DefaultFunction::iter() { if let Some(value) = from_default_function(builtin, id_gen) { - plutus.values.insert( - builtin.to_string().replace("ByteString", "ByteArray"), - value, - ); + plutus.values.insert(builtin.aiken_name(), value); } } @@ -403,7 +400,7 @@ pub fn from_default_function( ValueConstructor::public( tipo, ValueConstructorVariant::ModuleFn { - name: builtin.to_string().replace("ByteString", "ByteArray"), + name: builtin.aiken_name(), field_map: None, module: "".to_string(), arity, diff --git a/crates/uplc/src/builtins.rs b/crates/uplc/src/builtins.rs index 39eaf625..945f2cbd 100644 --- a/crates/uplc/src/builtins.rs +++ b/crates/uplc/src/builtins.rs @@ -325,3 +325,66 @@ impl Display for DefaultFunction { } } } + +impl DefaultFunction { + pub fn aiken_name(&self) -> String { + use DefaultFunction::*; + + match self { + AddInteger => "add_integer".to_string(), + SubtractInteger => "subtract_integer".to_string(), + MultiplyInteger => "multiply_integer".to_string(), + DivideInteger => "divide_integer".to_string(), + QuotientInteger => "quotient_integer".to_string(), + RemainderInteger => "remainder_integer".to_string(), + ModInteger => "mod_integer".to_string(), + EqualsInteger => "equals_integer".to_string(), + LessThanInteger => "less_than_integer".to_string(), + LessThanEqualsInteger => "less_than_equals_integer".to_string(), + AppendByteString => "append_bytearray".to_string(), + ConsByteString => "cons_bytearray".to_string(), + SliceByteString => "slice_bytearray".to_string(), + LengthOfByteString => "length_of_bytearray".to_string(), + IndexByteString => "index_bytearray".to_string(), + EqualsByteString => "equals_bytearray".to_string(), + LessThanByteString => "less_than_bytearray".to_string(), + LessThanEqualsByteString => "less_than_equals_bytearray".to_string(), + Sha2_256 => "sha2_256".to_string(), + Sha3_256 => "sha3_256".to_string(), + Blake2b_256 => "blake2b_256".to_string(), + VerifyEd25519Signature => "verify_signature".to_string(), + VerifyEcdsaSecp256k1Signature => "verify_ecdsa_secp256k1_signature".to_string(), + VerifySchnorrSecp256k1Signature => "verify_schnorr_secp256k1_signature".to_string(), + AppendString => "append_string".to_string(), + EqualsString => "equals_string".to_string(), + EncodeUtf8 => "encode_utf8".to_string(), + DecodeUtf8 => "decode_utf8".to_string(), + IfThenElse => "if_then_else".to_string(), + ChooseUnit => "choose_unit".to_string(), + Trace => "trace".to_string(), + FstPair => "fst_pair".to_string(), + SndPair => "snd_pair".to_string(), + ChooseList => "choose_list".to_string(), + MkCons => "mk_cons".to_string(), + HeadList => "head_list".to_string(), + TailList => "tail_list".to_string(), + NullList => "null_list".to_string(), + ChooseData => "choose_data".to_string(), + ConstrData => "constr_data".to_string(), + MapData => "map_data".to_string(), + ListData => "list_data".to_string(), + IData => "i_data".to_string(), + BData => "b_data".to_string(), + UnConstrData => "un_constr_data".to_string(), + UnMapData => "un_map_data".to_string(), + UnListData => "un_list_data".to_string(), + UnIData => "un_i_data".to_string(), + UnBData => "un_b_data".to_string(), + EqualsData => "equals_data".to_string(), + SerialiseData => "serialise_data".to_string(), + MkPairData => "mk_pair_data".to_string(), + MkNilData => "mk_nil_data".to_string(), + MkNilPairData => "mk_nil_pair_data".to_string(), + } + } +} diff --git a/examples/aiken_std/lib/aiken/bytearray.ak b/examples/aiken_std/lib/aiken/bytearray.ak index a5b26fbe..f74bfd9b 100644 --- a/examples/aiken_std/lib/aiken/bytearray.ak +++ b/examples/aiken_std/lib/aiken/bytearray.ak @@ -1,11 +1,11 @@ use aiken/builtin pub fn slice(bytes: ByteArray, start: Int, end: Int) -> ByteArray { - builtin.sliceByteArray(start, end, bytes) + builtin.slice_bytearray(start, end, bytes) } pub fn length(bytes: ByteArray) -> Int { - builtin.lengthOfByteArray(bytes) + builtin.length_of_bytearray(bytes) } pub fn is_empty(bytes: ByteArray) -> Bool { @@ -13,9 +13,9 @@ pub fn is_empty(bytes: ByteArray) -> Bool { } pub fn concat(left front: ByteArray, right back: ByteArray) -> ByteArray { - builtin.appendByteArray(front, back) + builtin.append_bytearray(front, back) } pub fn prepend(rest: ByteArray, byte: Int) -> ByteArray { - builtin.consByteArray(byte, rest) + builtin.cons_bytearray(byte, rest) } diff --git a/examples/aiken_std/lib/aiken/context.ak b/examples/aiken_std/lib/aiken/context.ak index 24cef8af..54d7b12a 100644 --- a/examples/aiken_std/lib/aiken/context.ak +++ b/examples/aiken_std/lib/aiken/context.ak @@ -13,7 +13,7 @@ pub type ScriptPurpose { Certify(Certificate) } -pub type Redeemer = +pub type Redeemer = Data pub type BoundValue(value) { @@ -47,8 +47,8 @@ pub type Transaction { id: TransactionId, } -pub type TransactionId = { - hash: Hash(Transaction) +pub type TransactionId { + hash: Hash(Transaction), } pub type Input { @@ -64,12 +64,12 @@ pub type OutputReference { pub type PolicyId = ByteArray -pub type StakeCredential = { +pub type StakeCredential { StakeHash(Credential) StakePointer(Int, Int, Int) } -pub type Credential = { +pub type Credential { PublicKeyCredential(PublicKeyHash) ScriptCredential(ScriptHash) } @@ -86,19 +86,19 @@ pub type PublicKeyHash = pub type PoolId = Hash(VerificationKey) -pub type Output = { +pub type Output { address: Address, value: Value, datum: DatumOption, reference_script: Option(ScriptHash), } -pub type Address = { +pub type Address { payment_credential: Credential, stake_credential: Option(StakeCredential), } -pub type DatumOption = { +pub type DatumOption { NoDatum DatumHash(Hash(Data)) Datum(Data) diff --git a/examples/aiken_std/lib/aiken/list.ak b/examples/aiken_std/lib/aiken/list.ak index 9a16650a..090010a8 100644 --- a/examples/aiken_std/lib/aiken/list.ak +++ b/examples/aiken_std/lib/aiken/list.ak @@ -63,7 +63,7 @@ pub fn range(from: Int, to: Int) -> List(Int) { pub fn head(xs: List(a)) -> Option(a) { when xs is { [] -> None - _ -> Some(builtin.headList(xs)) + _ -> Some(builtin.head_list(xs)) } }