Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example serializations for strategy orders #65

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 51 additions & 2 deletions lib/tests/examples/ex_order.ak
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use aiken/cbor
use types/order.{Destination, OrderDatum, Swap, Deposit, Withdrawal, Scoop, Cancel}
use aiken/transaction.{NoDatum}
use types/order.{Destination, OrderDatum, Swap, Deposit, Withdrawal, Strategy, StrategyExecution, SignedStrategyExecution, Scoop, Cancel}
use aiken/transaction.{NoDatum, OutputReference, TransactionId}
use aiken/interval
use aiken/transaction/credential.{VerificationKey, verify_signature}
use sundae/multisig
use tests/examples/ex_shared.{print_example, wallet_address}

Expand Down Expand Up @@ -87,6 +89,53 @@ test example_withdrawal() {
print_example(mk_withdrawal())
}


fn mk_strategy() {
let addr = wallet_address(#"6af53ff4f054348ad825c692dd9db8f1760a8e0eacf9af9f99306513")
let dest = Destination { address: addr, datum: NoDatum }
let strategy = Strategy(#"d441227553a0f1a965fee7d60a0f724b368dd1bddbc208730fccebcf")
OrderDatum {
pool_ident: Some(#"fc2c4a6ae8048b0b5affc169dfd496a7ace7d08288c476d9d7a5804e"),
owner: multisig.Signature(
#"c279a3fb3b4e62bbc78e288783b58045d4ae82a18867d8352d02775a",
),
max_protocol_fee: 1000000,
destination: dest,
details: strategy,
extension: Void,
}
}

test example_strategy() {
print_example(mk_strategy())
}

fn mk_strategy_execution() {
let tx_ref = OutputReference(TransactionId(#"797831ec63153a84ae1393bd5fea14196684f1dd12d6485e93cfe373d142e0d3"), 1)
let valid_range = interval.between(1000, 10000)
StrategyExecution {
tx_ref: tx_ref,
validity_range: valid_range,
details: mk_swap().details,
}
}

test example_strategy_execution() {
print_example(mk_strategy_execution())
}

fn mk_signed_strategy_execution() {
let sig = #"6af53ff4f054348ad825c692dd9db8f1760a8e0eacf9af9f99306513"
SignedStrategyExecution {
strategy: mk_strategy_execution(),
signature: sig,
}
}

test example_signed_strategy_execution() {
print_example(mk_signed_strategy_execution())
}

test example_cancel_redeemer() {
print_example(cbor.serialise(Cancel))
}
Expand Down
Loading