Skip to content

Commit

Permalink
Add nightly to CI
Browse files Browse the repository at this point in the history
  • Loading branch information
MitchTurner committed Mar 30, 2024
1 parent 01e82ca commit c4fe884
Show file tree
Hide file tree
Showing 64 changed files with 1,551 additions and 555 deletions.
20 changes: 18 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,25 @@ jobs:
run: cargo build --verbose --workspace
- name: Run tests
run: cargo test --verbose --workspace
- name: Lint
run: cargo +nightly fmt --all -- --check
- name: Clippy
run: cargo clippy --all-targets --all-features -- -D warnings

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install latest nightly
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.NIGHTLY_RUST_VERSION }}
components: rustfmt
- name: Rustfmt check
run: cargo +${{ env.NIGHTLY_RUST_VERSION }} fmt --all -- --check


audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Audit
run: cargo audit
6 changes: 4 additions & 2 deletions nau-scripts/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use aiken_lang::ast::Tracing;
use aiken_project::telemetry::Terminal;
use aiken_project::Project;
use aiken_project::{
telemetry::Terminal,
Project,
};

const MINT_NFT_PROJECT: &str = "./aiken/mint_nft";

Expand Down
41 changes: 26 additions & 15 deletions nau-scripts/src/one_shot.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
use naumachia::scripts::raw_script::BlueprintFile;
use naumachia::{
output::Output as NauOutput,
scripts::{
plutus_minting_policy::OneParamPlutusPolicy,
plutus_validator::plutus_data::{Constr, PlutusData},
ScriptError, ScriptResult,
plutus_validator::plutus_data::{
Constr,
PlutusData,
},
raw_script::BlueprintFile,
ScriptError,
ScriptResult,
},
};

Expand Down Expand Up @@ -53,16 +57,16 @@ impl From<OutputReference> for PlutusData {
}
}

pub fn get_parameterized_script() -> ScriptResult<OneParamPlutusPolicy<OutputReference, ()>> {
pub fn get_parameterized_script(
) -> ScriptResult<OneParamPlutusPolicy<OutputReference, ()>> {
let script_file: BlueprintFile = serde_json::from_str(BLUEPRINT)
.map_err(|e| ScriptError::FailedToConstruct(e.to_string()))?;
let validator_blueprint =
script_file
.get_validator(VALIDATOR_NAME)
.ok_or(ScriptError::FailedToConstruct(format!(
"Validator not listed in Blueprint: {:?}",
VALIDATOR_NAME
)))?;
let validator_blueprint = script_file.get_validator(VALIDATOR_NAME).ok_or(
ScriptError::FailedToConstruct(format!(
"Validator not listed in Blueprint: {:?}",
VALIDATOR_NAME
)),
)?;
let raw_script_validator = OneParamPlutusPolicy::from_blueprint(validator_blueprint)
.map_err(|e| ScriptError::FailedToConstruct(e.to_string()))?;
Ok(raw_script_validator)
Expand All @@ -72,10 +76,17 @@ pub fn get_parameterized_script() -> ScriptResult<OneParamPlutusPolicy<OutputRef
#[cfg(test)]
mod tests {
use super::*;
use naumachia::output::Output;
use naumachia::scripts::context::{pub_key_hash_from_address_if_available, ContextBuilder};
use naumachia::scripts::MintingPolicy;
use naumachia::Address;
use naumachia::{
output::Output,
scripts::{
context::{
pub_key_hash_from_address_if_available,
ContextBuilder,
},
MintingPolicy,
},
Address,
};

#[test]
fn execute__succeeds_when_output_included() {
Expand Down
6 changes: 4 additions & 2 deletions sample-dApps/always-succeeds-contract/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use aiken_lang::ast::Tracing;
use aiken_project::telemetry::Terminal;
use aiken_project::Project;
use aiken_project::{
telemetry::Terminal,
Project,
};

const PROJECT: &str = "./always_succeeds";

Expand Down
18 changes: 14 additions & 4 deletions sample-dApps/always-succeeds-contract/src/logic.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
use crate::logic::script::get_script;
use async_trait::async_trait;
use naumachia::logic::error::{SCLogicError, SCLogicResult};
use naumachia::{
ledger_client::LedgerClient,
logic::SCLogic,
output::{Output, OutputId},
logic::{
error::{
SCLogicError,
SCLogicResult,
},
SCLogic,
},
output::{
Output,
OutputId,
},
policy_id::PolicyId,
scripts::Validator,
transaction::TxActions,
Expand Down Expand Up @@ -54,7 +62,9 @@ impl SCLogic for AlwaysSucceedsLogic {
ledger_client: &LC,
) -> SCLogicResult<TxActions<Self::Datums, Self::Redeemers>> {
match endpoint {
AlwaysSucceedsEndpoints::Lock { amount } => impl_lock(ledger_client, amount).await,
AlwaysSucceedsEndpoints::Lock { amount } => {
impl_lock(ledger_client, amount).await
}
AlwaysSucceedsEndpoints::Claim { output_id } => {
impl_claim(ledger_client, output_id).await
}
Expand Down
35 changes: 22 additions & 13 deletions sample-dApps/always-succeeds-contract/src/logic/script.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
use naumachia::scripts::plutus_validator::PlutusValidator;
use naumachia::scripts::raw_script::BlueprintFile;
use naumachia::scripts::{ScriptError, ScriptResult};
use naumachia::scripts::{
plutus_validator::PlutusValidator,
raw_script::BlueprintFile,
ScriptError,
ScriptResult,
};

const BLUEPRINT: &str = include_str!("../../always_succeeds/plutus.json");
const VALIDATOR_NAME: &str = "always_true.spend";

pub fn get_script() -> ScriptResult<PlutusValidator<(), ()>> {
let script_file: BlueprintFile = serde_json::from_str(BLUEPRINT)
.map_err(|e| ScriptError::FailedToConstruct(e.to_string()))?;
let validator_blueprint =
script_file
.get_validator(VALIDATOR_NAME)
.ok_or(ScriptError::FailedToConstruct(format!(
"Validator not listed in Blueprint: {:?}",
VALIDATOR_NAME
)))?;
let validator_blueprint = script_file.get_validator(VALIDATOR_NAME).ok_or(
ScriptError::FailedToConstruct(format!(
"Validator not listed in Blueprint: {:?}",
VALIDATOR_NAME
)),
)?;
let raw_script_validator = PlutusValidator::from_blueprint(validator_blueprint)
.map_err(|e| ScriptError::FailedToConstruct(e.to_string()))?;
Ok(raw_script_validator)
Expand All @@ -23,9 +25,16 @@ pub fn get_script() -> ScriptResult<PlutusValidator<(), ()>> {
#[cfg(test)]
mod tests {
use super::*;
use naumachia::scripts::context::{pub_key_hash_from_address_if_available, ContextBuilder};
use naumachia::scripts::Validator;
use naumachia::Address;
use naumachia::{
scripts::{
context::{
pub_key_hash_from_address_if_available,
ContextBuilder,
},
Validator,
},
Address,
};

#[test]
fn test() {
Expand Down
12 changes: 9 additions & 3 deletions sample-dApps/always-succeeds-contract/src/logic/tests.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
use super::*;
use naumachia::ledger_client::test_ledger_client::TestLedgerClientBuilder;
use naumachia::smart_contract::{SmartContract, SmartContractTrait};
use naumachia::{Address, Network};
use naumachia::{
ledger_client::test_ledger_client::TestLedgerClientBuilder,
smart_contract::{
SmartContract,
SmartContractTrait,
},
Address,
Network,
};

#[tokio::test]
async fn lock_and_claim() {
Expand Down
9 changes: 7 additions & 2 deletions sample-dApps/always-succeeds-contract/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
use always_succeeds_contract::logic::{
AlwaysSucceedsEndpoints, AlwaysSucceedsLogic, AlwaysSucceedsLookupResponses,
AlwaysSucceedsEndpoints,
AlwaysSucceedsLogic,
AlwaysSucceedsLookupResponses,
AlwaysSucceedsLookups,
};
use clap::Parser;
use naumachia::{
output::OutputId,
smart_contract::{SmartContract, SmartContractTrait},
smart_contract::{
SmartContract,
SmartContractTrait,
},
trireme_ledger_client::get_trireme_ledger_client_from_file,
};

Expand Down
2 changes: 1 addition & 1 deletion sample-dApps/checking_account/checking/aiken.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ requirements = []
source = "github"

[etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1708887379, nanos_since_epoch = 415727333 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1711836891, nanos_since_epoch = 667346334 }, "2a710731e0127ec3e21c6c3962a0254c98602e7428b33fc4fcaa67ab368ce1b1"]
21 changes: 17 additions & 4 deletions sample-dApps/free-minting-contract/src/logic.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
use crate::logic::script::get_policy;
use async_trait::async_trait;
use naumachia::logic::error::{SCLogicError, SCLogicResult};
use naumachia::{ledger_client::LedgerClient, logic::SCLogic, transaction::TxActions};
use naumachia::{
ledger_client::LedgerClient,
logic::{
error::{
SCLogicError,
SCLogicResult,
},
SCLogic,
},
transaction::TxActions,
};

pub mod script;

Expand Down Expand Up @@ -29,8 +38,12 @@ impl SCLogic for FreeMintingLogic {
FreeMintingEndpoints::Mint { amount } => {
let inner_policy = get_policy().map_err(SCLogicError::PolicyScript)?;
let policy = Box::new(inner_policy);
let actions =
TxActions::v1().with_mint(amount, Some("FREEEEEE".to_string()), (), policy);
let actions = TxActions::v1().with_mint(
amount,
Some("FREEEEEE".to_string()),
(),
policy,
);
Ok(actions)
}
}
Expand Down
22 changes: 16 additions & 6 deletions sample-dApps/free-minting-contract/src/logic/script.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use naumachia::scripts::plutus_minting_policy::PlutusMintingPolicy;
use naumachia::scripts::raw_script::PlutusScriptFile;
use naumachia::scripts::{ScriptError, ScriptResult};
use naumachia::scripts::{
plutus_minting_policy::PlutusMintingPolicy,
raw_script::PlutusScriptFile,
ScriptError,
ScriptResult,
};

// const SCRIPT_RAW: &str = include_str!("../../plutus/anyone-can-mint.plutus");
// const SCRIPT_RAW: &str = include_str!("../../plutus/free-minting.plutus");
Expand All @@ -17,9 +20,16 @@ pub fn get_policy<R>() -> ScriptResult<PlutusMintingPolicy<R>> {
#[cfg(test)]
mod tests {
use super::*;
use naumachia::scripts::context::{pub_key_hash_from_address_if_available, ContextBuilder};
use naumachia::scripts::MintingPolicy;
use naumachia::Address;
use naumachia::{
scripts::{
context::{
pub_key_hash_from_address_if_available,
ContextBuilder,
},
MintingPolicy,
},
Address,
};

#[test]
fn can_execute_policy() {
Expand Down
13 changes: 9 additions & 4 deletions sample-dApps/free-minting-contract/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
use clap::Parser;
use free_minting_contract::logic::FreeMintingEndpoints;
use free_minting_contract::logic::FreeMintingLogic;
use naumachia::smart_contract::SmartContractTrait;
use free_minting_contract::logic::{
FreeMintingEndpoints,
FreeMintingLogic,
};
use naumachia::{
smart_contract::SmartContract, trireme_ledger_client::get_trireme_ledger_client_from_file,
smart_contract::{
SmartContract,
SmartContractTrait,
},
trireme_ledger_client::get_trireme_ledger_client_from_file,
};

#[derive(Parser, Debug)]
Expand Down
20 changes: 16 additions & 4 deletions sample-dApps/game-contract/src/logic.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
use crate::logic::script::{get_script, ClearString, HashedString};
use crate::logic::script::{
get_script,
ClearString,
HashedString,
};
use async_trait::async_trait;
use naumachia::logic::error::{SCLogicError, SCLogicResult};
use naumachia::{
ledger_client::LedgerClient,
logic::SCLogic,
output::{Output, OutputId},
logic::{
error::{
SCLogicError,
SCLogicResult,
},
SCLogic,
},
output::{
Output,
OutputId,
},
policy_id::PolicyId,
scripts::Validator,
transaction::TxActions,
Expand Down
Loading

0 comments on commit c4fe884

Please sign in to comment.