Skip to content

Commit

Permalink
add debugging to governance actions
Browse files Browse the repository at this point in the history
  • Loading branch information
MicroProofs committed Jul 2, 2024
1 parent 8864856 commit e41e650
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 23 deletions.
2 changes: 1 addition & 1 deletion aiken.lock
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ requirements = []
source = "github"

[etags]
"aiken-lang/fuzz@main" = [{ secs_since_epoch = 1719959323, nanos_since_epoch = 698487000 }, "a8294651f1577c671d580c99c9bc5445ef1fd44e4aa3dde550434a4cbc8d50b6"]
"aiken-lang/fuzz@main" = [{ secs_since_epoch = 1719964194, nanos_since_epoch = 538496000 }, "a8294651f1577c671d580c99c9bc5445ef1fd44e4aa3dde550434a4cbc8d50b6"]
8 changes: 4 additions & 4 deletions lib/fortunav2.ak
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ pub fn genesis_v2(tx, own_policy, fortuna_v1_hash: Data, fork_script_hash: Data)
)

and {
(mine_state == expected_mine_state)?,
(tunav2_output.value
mine_state == expected_mine_state,
tunav2_output.value
|> value.without_lovelace
|> builtin.equals_data(expected_value))?,
|> builtin.equals_data(expected_value),
}
}

Expand Down Expand Up @@ -266,7 +266,7 @@ pub fn count_votes(
[Pair(tuna_name, tuna_quantity), Pair(value_script_hash, 1)] ->
if
tuna_name == fortuna.token_name && value_script_hash == script_hash{

tuna_quantity + count_votes(
rest,
own_hash,
Expand Down
4 changes: 4 additions & 0 deletions miner/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1373,6 +1373,8 @@ app

const readUtxos = await lucid.utxosAt(forkValidatorAddress);

const realTimeNow = Number((Date.now() / 1000).toFixed(0)) * 1000 - 60000;

const nominateTx = await lucid
.newTx()
.readFrom(readUtxos)
Expand All @@ -1386,6 +1388,8 @@ app
{ inline: Data.to(spendOutputNominateDatum) },
{ [tunav2ValidatorHash + fromText('NOMA') + newSpendHash]: 1n },
)
.validFrom(realTimeNow)
.validTo(realTimeNow + 170000)
.complete();

console.log('here3');
Expand Down
8 changes: 4 additions & 4 deletions plutus.json

Large diffs are not rendered by default.

26 changes: 12 additions & 14 deletions validators/tunav2.ak
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ validator(fortuna_v1_hash: Data, fork_script_hash: Data) {

and {
// input value check
(in_token_name == expected_in_token_name)?,
in_token_name == expected_in_token_name,
// minted counter check
(minted_names == expected_mint)?,
minted_names == expected_mint,
}
}

Expand All @@ -161,12 +161,6 @@ validator(fortuna_v1_hash: Data, fork_script_hash: Data) {
let valid_cred = ScriptCredential(script_hash)

// Check contract is executable
expect Some(_) =
list.find(
inputs,
fn(input) { input.output.address.payment_credential == valid_cred },
)

// Mint nomination token
expect [Pair(nominated_contract_token, 1)] =
mint |> from_minted_value |> value.tokens(own_policy) |> dict.to_pairs
Expand Down Expand Up @@ -206,16 +200,20 @@ validator(fortuna_v1_hash: Data, fork_script_hash: Data) {
} = utils.list_at(outputs, output_index)

and {
nominated_contract_token == bytearray.concat(
(nominated_contract_token == bytearray.concat(
fortunav2.nominated_prefix,
script_hash,
),
address.payment_credential == ScriptCredential(own_policy),
expected_value == value.without_lovelace(nominated_value),
expected_datum == nominated_datum,
))?,
(address.payment_credential == ScriptCredential(own_policy))?,
(expected_value == value.without_lovelace(nominated_value))?,
(expected_datum == nominated_datum)?,
!upper_is_inclusive,
lower_is_inclusive,
upper_range - lower_range <= 180000,
(upper_range - lower_range <= 180000)?,
list.any(
inputs,
fn(input) { input.output.address.payment_credential == valid_cred },
)?,
}
}

Expand Down

0 comments on commit e41e650

Please sign in to comment.