Skip to content

Commit

Permalink
feat: building basic skeleton for oracle validator
Browse files Browse the repository at this point in the history
  • Loading branch information
HinsonSIDAN committed Nov 15, 2023
1 parent 9229aca commit a8bc120
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ build/
# Aiken's default documentation export
docs/

.vscode
test.json
13 changes: 6 additions & 7 deletions lib/aiken-content-ownership/diagnostic.ak
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use aiken/cbor.{serialise}
use aiken_content_ownership/placeholder.{mock_utxo_ref}

test diag() {
// serialise(mock_utxo_ref(0)) == #"d8799fd8799f58205a077cbcdffb88b104f292aacb9687ce93e2191e103a30a0cc5505c18b719f98ff00ff"
serialise(mock_utxo_ref(1)) == #"d8799fd8799f58205a077cbcdffb88b104f292aacb9687ce93e2191e103a30a0cc5505c18b719f98ff01ff"
}
// use aiken/cbor.{serialise}
// use aiken_content_ownership/placeholder.{mock_utxo_ref}
// test diag() {
// // serialise(mock_utxo_ref(0)) == #"d8799fd8799f58205a077cbcdffb88b104f292aacb9687ce93e2191e103a30a0cc5505c18b719f98ff00ff"
// serialise(mock_utxo_ref(1)) == #"d8799fd8799f58205a077cbcdffb88b104f292aacb9687ce93e2191e103a30a0cc5505c18b719f98ff01ff"
// }
Empty file added validators/content_registry.ak
Empty file.
Empty file.
48 changes: 48 additions & 0 deletions validators/oracle_validator.ak
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
use aiken/transaction.{ScriptContext, Spend}
use aiken/transaction/credential.{Address, Credential}
use aiken/transaction/value.{PolicyId}

type Datum {
content_registry_address: Address,
content_registry_ref_token: PolicyId,
ownership_registry_address: Address,
ownership_registry_ref_token: PolicyId,
content_registry_count: Int,
ownership_registry_count: Int,
operation_key: Credential,
stop_key: Credential,
}

type Redeemer {
CreateContentRegistry
CreateOwnershipRegistry
RotateKey { new_operation_key: Credential, new_stop_key: Credential }
StopApp
}

validator {
fn oracle_validator(datum: Datum, redeemer: Redeemer, context: ScriptContext) {
let ScriptContext { purpose, transaction } = context
when purpose is {
Spend(_) ->
when redeemer is {
CreateContentRegistry ->
// Ref token is minted to address
// count + 1
True
CreateOwnershipRegistry ->
// Ref token is minted to address
// count + 1
True
RotateKey { new_operation_key, new_stop_key } ->
// Sign by both ops and stop key
// datum update correctly (key rotated)
True
StopApp ->
// signed by stop key
True
}
_ -> False
}
}
}
Empty file.
Empty file.

0 comments on commit a8bc120

Please sign in to comment.