-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start to pull examples and tests into their own folder
- Loading branch information
1 parent
72af6e7
commit 8c9b264
Showing
5 changed files
with
106 additions
and
113 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
use aiken/bytearray | ||
use aiken/transaction/credential.{Address, VerificationKeyCredential} | ||
use aiken/cbor | ||
use sundae/multisig | ||
use aiken/transaction/value | ||
use types/settings.{SettingsDatum} | ||
use aiken/transaction.{Input, Output, InlineDatum} | ||
use tests/examples/ex_shared.{script_address, mk_output_reference} | ||
|
||
pub fn mk_valid_settings_datum( | ||
scoopers: List<ByteArray>, | ||
) -> SettingsDatum { | ||
SettingsDatum { | ||
settings_admin: multisig.Signature( | ||
#"725011d2c296eb3341e159b6c5c6991de11e81062b95108c9aa024ad", | ||
), | ||
metadata_admin: Address( | ||
VerificationKeyCredential( | ||
#"6af53ff4f054348ad825c692dd9db8f1760a8e0eacf9af9f99306513", | ||
), | ||
None, | ||
), | ||
treasury_admin: multisig.Signature( | ||
#"725011d2c296eb3341e159b6c5c6991de11e81062b95108c9aa024ad", | ||
), | ||
treasury_address: Address( | ||
VerificationKeyCredential( | ||
#"6af53ff4f054348ad825c692dd9db8f1760a8e0eacf9af9f99306513", | ||
), | ||
None, | ||
), | ||
treasury_allowance: (1, 10), | ||
authorized_scoopers: scoopers, | ||
authorized_staking_keys: [ | ||
#"725011d2c296eb3341e159b6c5c6991de11e81062b95108c9aa024ad", | ||
], | ||
base_fee: 0, | ||
simple_fee: 2_500_000, | ||
strategy_fee: 5_000_000, | ||
extensions: Void, | ||
} | ||
} | ||
|
||
pub fn mk_valid_settings_input( | ||
scoopers: List<ByteArray>, | ||
ix: Int, | ||
) -> Input { | ||
let hash_of_settings_script = | ||
#"00000000000000000000000000000000000000000000000000000000" | ||
let settings_nft_name = "settings" | ||
let settings_address = script_address(hash_of_settings_script) | ||
let settings_datum = mk_valid_settings_datum(scoopers) | ||
|
||
let settings_input = | ||
Input { | ||
output_reference: mk_output_reference(ix), | ||
output: Output { | ||
address: settings_address, | ||
value: value.from_lovelace(2_000_000) | ||
|> value.add(hash_of_settings_script, settings_nft_name, 1), | ||
datum: InlineDatum(settings_datum), | ||
reference_script: None, | ||
}, | ||
} | ||
settings_input | ||
} | ||
|
||
test example_settings_datum() { | ||
trace bytearray.to_hex( | ||
cbor.serialise(mk_valid_settings_datum([ | ||
#"725011d2c296eb3341e159b6c5c6991de11e81062b95108c9aa024ad", | ||
])), | ||
) | ||
True | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use aiken/bytearray | ||
use aiken/transaction.{OutputReference, TransactionId} | ||
use aiken/transaction/credential.{Address, ScriptCredential, VerificationKeyCredential} | ||
|
||
pub fn mk_tx_hash(n: Int) -> TransactionId { | ||
expect n < 256 | ||
let h = | ||
bytearray.push( | ||
#"00000000000000000000000000000000000000000000000000000000000000", | ||
n, | ||
) | ||
TransactionId { hash: h } | ||
} | ||
|
||
pub fn mk_output_reference(n: Int) -> OutputReference { | ||
OutputReference { transaction_id: mk_tx_hash(0), output_index: n } | ||
} | ||
|
||
pub fn script_address(hash: ByteArray) -> Address { | ||
Address { payment_credential: ScriptCredential(hash), stake_credential: None } | ||
} | ||
|
||
pub fn wallet_address(hash: ByteArray) -> Address { | ||
Address(VerificationKeyCredential(hash), None) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters