Skip to content

Commit

Permalink
latest changes
Browse files Browse the repository at this point in the history
  • Loading branch information
MicroProofs committed Mar 17, 2024
1 parent a83af56 commit f38cff1
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 3 deletions.
22 changes: 22 additions & 0 deletions lib/hardfork_tests.ak
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,28 @@ test calculate_emission_3() {
calculate_emission(210001) == 1050002500000000
}

test calculate_emission_4() {
calculate_emission(0) == 0
}

test calculate_emission_5() {
calculate_emission(2) == 10000000000
}

/// Final supply of Fortuna is 2099999999755520
test calculate_emission_6() {
calculate_emission(6_930_001) == 2099999999755520
}

test calculate_emission_7() {
calculate_emission(6_929_999) == 2099999999755519
}

/// Final supply of Fortuna is 2099999999755520
test calculate_emission_8() {
calculate_emission(6_930_000) == 2099999999755520
}

test check_block_signal_1() {
check_block_signal(0, 1000, 0, 1)
}
Expand Down
36 changes: 33 additions & 3 deletions validators/tunav2.ak
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ use aiken/transaction.{Mint,
use aiken/transaction/credential.{Address, ScriptCredential}
use aiken/transaction/value.{tokens}
use fortuna
use fortuna/utils.{list_at, quantity_of}
use fortuna/utils.{get_inline_datum, list_at, quantity_of}
use hardfork/hftypes.{ForkDatum, NftState}
use hardfork_validation.{hard_fork_state_token}

type TunaAction {
Expand Down Expand Up @@ -39,7 +40,7 @@ type TargetState {

validator(
init_utxo_ref: OutputReference,
_fortuna_v1_hash: ByteArray,
fortuna_v1_hash: ByteArray,
fork_script_hash: ByteArray,
) {
fn tuna(redeemer: TunaAction, ctx: ScriptContext) -> Bool {
Expand Down Expand Up @@ -77,8 +78,37 @@ validator(
genesis_input == genesis_input,
}
}
Redeem(locked_tokens_ref) -> {
let Transaction { reference_inputs, mint, .. } = tx

let mint = value.from_minted_value(mint)

// We reference the locked v1 tuan NFTState that we have the NFT key for.
let own_input =
utils.resolve_output_reference(reference_inputs, locked_tokens_ref)

let Output { address: in_address, value: in_value, datum: in_datum, .. } =
own_input

let locked_tokens =
quantity_of(in_value, fortuna_v1_hash, fortuna.token_name)

expect NftState { nft_key }: ForkDatum = get_inline_datum(in_datum)

expect [(token_name, quantity)] =
mint |> tokens(own_policy) |> dict.to_list

and {
quantity_of(mint, fork_script_hash, nft_key) == -1,
token_name == fortuna.token_name,
quantity == locked_tokens,
in_address == Address {
payment_credential: ScriptCredential(fork_script_hash),
stake_credential: None,
},
}
}
Mine -> todo
Redeem(_locked_tokens_ref) -> todo
NominateUpgradeContract -> todo
VoteContractToken -> todo
ApplyContractVote -> todo
Expand Down

0 comments on commit f38cff1

Please sign in to comment.