Add script context translation for new Conway certificates
This commit is contained in:
@@ -23,7 +23,7 @@ for convenience.
|
||||
- [x] spend
|
||||
- [x] mint
|
||||
- [ ] withdraw
|
||||
- [ ] publish
|
||||
- [x] publish
|
||||
- [ ] voting
|
||||
- [x] proposing
|
||||
|
||||
@@ -41,20 +41,20 @@ for convenience.
|
||||
- [x] none
|
||||
- some
|
||||
- Register credential
|
||||
- [ ] no deposit
|
||||
- [ ] with deposit
|
||||
- [x] no deposit
|
||||
- [x] with deposit
|
||||
- Unregister credential
|
||||
- [ ] no deposit
|
||||
- [ ] with deposit
|
||||
- [ ] Delegate
|
||||
- [ ] Register & delegate credential
|
||||
- [ ] Register drep
|
||||
- [ ] Unregister drep
|
||||
- [ ] Update drep
|
||||
- [ ] Register pool
|
||||
- [ ] Retire pool
|
||||
- [ ] Delegate CC
|
||||
- [ ] Retire CC
|
||||
- [x] no deposit
|
||||
- [x] with deposit
|
||||
- [x] Delegate
|
||||
- [x] Register & delegate credential
|
||||
- [x] Register drep
|
||||
- [x] Unregister drep
|
||||
- [x] Update drep
|
||||
- [x] Register pool
|
||||
- [x] Retire pool
|
||||
- [x] Delegate CC
|
||||
- [x] Retire CC
|
||||
- withdrawals
|
||||
- [x] none
|
||||
- [ ] some
|
||||
@@ -71,10 +71,10 @@ for convenience.
|
||||
- [x] none
|
||||
- [x] some
|
||||
- current treasury
|
||||
- [ ] with
|
||||
- [x] with
|
||||
- [x] without
|
||||
- treasury donation
|
||||
- [ ] with
|
||||
- [x] with
|
||||
- [x] without
|
||||
|
||||
- Address
|
||||
@@ -102,8 +102,8 @@ for convenience.
|
||||
|
||||
- Governance Action
|
||||
- parameter change
|
||||
- [ ] with action id
|
||||
- [ ] without action id
|
||||
- [x] with action id
|
||||
- [x] without action id
|
||||
- hardfork initiation
|
||||
- [x] with action id
|
||||
- [x] without action id
|
||||
@@ -172,15 +172,15 @@ for convenience.
|
||||
- [x] script
|
||||
|
||||
- Delegatee
|
||||
- [ ] pool
|
||||
- [ ] drep
|
||||
- [ ] pool + drep
|
||||
- [x] pool
|
||||
- [x] drep
|
||||
- [x] pool + drep
|
||||
|
||||
- DRep
|
||||
- [ ] key
|
||||
- [ ] script
|
||||
- [ ] abstain
|
||||
- [ ] no confidence
|
||||
- [x] key
|
||||
- [x] script
|
||||
- [x] abstain
|
||||
- [x] no confidence
|
||||
|
||||
- Boundary
|
||||
- [ ] closed
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
[
|
||||
{ 0: h'6000000000000000000000000000000000000000000000000000000000'
|
||||
, 1: 1000000
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,118 @@
|
||||
[
|
||||
{ 0:
|
||||
[ [h'0000000000000000000000000000000000000000000000000000000000000000', 0]
|
||||
]
|
||||
|
||||
, 1:
|
||||
[]
|
||||
|
||||
, 4:
|
||||
[ [0, [1, h'22222222222222222222222222222222222222222222222222222222' ] ]
|
||||
, [0, [0, h'00000000000000000000000000000000000000000000000000000000' ] ]
|
||||
, [1, [0, h'00000000000000000000000000000000000000000000000000000000' ] ]
|
||||
, [ 3
|
||||
, h'11111111111111111111111111111111111111111111111111111111'
|
||||
, h'9999999999999999999999999999999999999999999999999999999999999999'
|
||||
, 1000000
|
||||
, 340
|
||||
, 30([1, 100])
|
||||
, h'E000000000000000000000000000000000000000000000000000000000'
|
||||
, 258([])
|
||||
, []
|
||||
, null
|
||||
]
|
||||
, [ 4
|
||||
, h'11111111111111111111111111111111111111111111111111111111'
|
||||
, 1337
|
||||
]
|
||||
, [ 7
|
||||
, [0, h'00000000000000000000000000000000000000000000000000000000' ]
|
||||
, 3000000
|
||||
]
|
||||
, [ 8
|
||||
, [0, h'00000000000000000000000000000000000000000000000000000000' ]
|
||||
, 3000000
|
||||
]
|
||||
, [ 9
|
||||
, [0, h'00000000000000000000000000000000000000000000000000000000' ]
|
||||
, [0, h'00000000000000000000000000000000000000000000000000000000' ]
|
||||
]
|
||||
, [ 9
|
||||
, [0, h'00000000000000000000000000000000000000000000000000000000' ]
|
||||
, [1, h'00000000000000000000000000000000000000000000000000000000' ]
|
||||
]
|
||||
, [ 9
|
||||
, [0, h'00000000000000000000000000000000000000000000000000000000' ]
|
||||
, [ 2 ]
|
||||
]
|
||||
, [ 9
|
||||
, [0, h'00000000000000000000000000000000000000000000000000000000' ]
|
||||
, [ 3 ]
|
||||
]
|
||||
, [ 10
|
||||
, [0, h'00000000000000000000000000000000000000000000000000000000' ]
|
||||
, h'11111111111111111111111111111111111111111111111111111111'
|
||||
, [ 3 ]
|
||||
]
|
||||
, [ 11
|
||||
, [0, h'00000000000000000000000000000000000000000000000000000000' ]
|
||||
, h'11111111111111111111111111111111111111111111111111111111'
|
||||
, 3000000
|
||||
]
|
||||
, [ 12
|
||||
, [0, h'00000000000000000000000000000000000000000000000000000000' ]
|
||||
, [ 3 ]
|
||||
, 3000000
|
||||
]
|
||||
, [ 13
|
||||
, [0, h'00000000000000000000000000000000000000000000000000000000' ]
|
||||
, h'11111111111111111111111111111111111111111111111111111111'
|
||||
, [ 3 ]
|
||||
, 3000000
|
||||
]
|
||||
, [ 14
|
||||
, [0, h'00000000000000000000000000000000000000000000000000000000' ]
|
||||
, [0, h'22222222222222222222222222222222222222222222222222222222' ]
|
||||
]
|
||||
, [ 15
|
||||
, [0, h'00000000000000000000000000000000000000000000000000000000' ]
|
||||
, null
|
||||
]
|
||||
, [ 16
|
||||
, [0, h'00000000000000000000000000000000000000000000000000000000' ]
|
||||
, 3000000
|
||||
, null
|
||||
]
|
||||
, [ 17
|
||||
, [0, h'00000000000000000000000000000000000000000000000000000000' ]
|
||||
, 3000000
|
||||
]
|
||||
, [ 18
|
||||
, [0, h'00000000000000000000000000000000000000000000000000000000' ]
|
||||
, null
|
||||
]
|
||||
, [ 2
|
||||
, [ 1
|
||||
, h'{{ certificates.script.hash }}'
|
||||
]
|
||||
, h'11111111111111111111111111111111111111111111111111111111'
|
||||
]
|
||||
]
|
||||
|
||||
, 2: 42
|
||||
|
||||
, 21: 10000000
|
||||
|
||||
, 22: 14
|
||||
|
||||
},
|
||||
|
||||
{ 5: [[2, 20, 121([]), [1000000, 100000000]]]
|
||||
|
||||
, 7: [h'{{ certificates.script.cbor }}']
|
||||
},
|
||||
|
||||
true,
|
||||
|
||||
null
|
||||
]
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,207 @@
|
||||
use aiken/collection/list
|
||||
use cardano/certificate.{
|
||||
AlwaysAbstain, AlwaysNoConfidence, AuthorizeConstitutionalCommitteeProxy,
|
||||
DelegateBlockProduction, DelegateBoth, DelegateCredential, DelegateVote,
|
||||
RegisterAndDelegateCredential, RegisterCredential,
|
||||
RegisterDelegateRepresentative, RegisterStakePool, Registered,
|
||||
RetireFromConstitutionalCommittee, RetireStakePool, UnregisterCredential,
|
||||
UnregisterDelegateRepresentative, UpdateDelegateRepresentative,
|
||||
}
|
||||
use cardano/credential.{Script, VerificationKey}
|
||||
use cardano/transaction.{Publishing, ScriptContext, ScriptInfo}
|
||||
|
||||
const only0s = #"00000000000000000000000000000000000000000000000000000000"
|
||||
|
||||
const only1s = #"11111111111111111111111111111111111111111111111111111111"
|
||||
|
||||
const only2s = #"22222222222222222222222222222222222222222222222222222222"
|
||||
|
||||
const only9s =
|
||||
#"9999999999999999999999999999999999999999999999999999999999999999"
|
||||
|
||||
validator {
|
||||
fn script(_tmp1: Void, ctx: ScriptContext) -> Bool {
|
||||
assert_script_info(ctx.info)
|
||||
|
||||
let certificates = ctx.transaction.certificates
|
||||
|
||||
expect Some(10_000_000) = ctx.transaction.current_treasury_amount
|
||||
|
||||
expect Some(14) = ctx.transaction.treasury_donation
|
||||
|
||||
expect
|
||||
Some(RegisterCredential { credential: Script(only2s), deposit: None }) == list.at(
|
||||
certificates,
|
||||
0,
|
||||
)
|
||||
|
||||
expect
|
||||
Some(
|
||||
RegisterCredential {
|
||||
credential: VerificationKey(only0s),
|
||||
deposit: None,
|
||||
},
|
||||
) == list.at(certificates, 1)
|
||||
|
||||
expect
|
||||
Some(
|
||||
UnregisterCredential {
|
||||
credential: VerificationKey(only0s),
|
||||
refund: None,
|
||||
},
|
||||
) == list.at(certificates, 2)
|
||||
|
||||
expect
|
||||
Some(RegisterStakePool { stake_pool: only1s, vrf: only9s }) == list.at(
|
||||
certificates,
|
||||
3,
|
||||
)
|
||||
|
||||
expect
|
||||
Some(RetireStakePool { stake_pool: only1s, at_epoch: 1337 }) == list.at(
|
||||
certificates,
|
||||
4,
|
||||
)
|
||||
|
||||
expect
|
||||
Some(
|
||||
RegisterCredential {
|
||||
credential: VerificationKey(only0s),
|
||||
deposit: Some(3_000_000),
|
||||
},
|
||||
) == list.at(certificates, 5)
|
||||
|
||||
expect
|
||||
Some(
|
||||
UnregisterCredential {
|
||||
credential: VerificationKey(only0s),
|
||||
refund: Some(3_000_000),
|
||||
},
|
||||
) == list.at(certificates, 6)
|
||||
|
||||
expect
|
||||
Some(
|
||||
DelegateCredential {
|
||||
credential: VerificationKey(only0s),
|
||||
delegate: DelegateVote(Registered(VerificationKey(only0s))),
|
||||
},
|
||||
) == list.at(certificates, 7)
|
||||
|
||||
expect
|
||||
Some(
|
||||
DelegateCredential {
|
||||
credential: VerificationKey(only0s),
|
||||
delegate: DelegateVote(Registered(Script(only0s))),
|
||||
},
|
||||
) == list.at(certificates, 8)
|
||||
|
||||
expect
|
||||
Some(
|
||||
DelegateCredential {
|
||||
credential: VerificationKey(only0s),
|
||||
delegate: DelegateVote(AlwaysAbstain),
|
||||
},
|
||||
) == list.at(certificates, 9)
|
||||
|
||||
expect
|
||||
Some(
|
||||
DelegateCredential {
|
||||
credential: VerificationKey(only0s),
|
||||
delegate: DelegateVote(AlwaysNoConfidence),
|
||||
},
|
||||
) == list.at(certificates, 10)
|
||||
|
||||
expect
|
||||
Some(
|
||||
DelegateCredential {
|
||||
credential: VerificationKey(only0s),
|
||||
delegate: DelegateBoth {
|
||||
stake_pool: only1s,
|
||||
delegate_representative: AlwaysNoConfidence,
|
||||
},
|
||||
},
|
||||
) == list.at(certificates, 11)
|
||||
|
||||
expect
|
||||
Some(
|
||||
RegisterAndDelegateCredential {
|
||||
credential: VerificationKey(only0s),
|
||||
delegate: DelegateBlockProduction(only1s),
|
||||
deposit: 3_000_000,
|
||||
},
|
||||
) == list.at(certificates, 12)
|
||||
|
||||
expect
|
||||
Some(
|
||||
RegisterAndDelegateCredential {
|
||||
credential: VerificationKey(only0s),
|
||||
delegate: DelegateVote(AlwaysNoConfidence),
|
||||
deposit: 3_000_000,
|
||||
},
|
||||
) == list.at(certificates, 13)
|
||||
|
||||
expect
|
||||
Some(
|
||||
RegisterAndDelegateCredential {
|
||||
credential: VerificationKey(only0s),
|
||||
delegate: DelegateBoth {
|
||||
stake_pool: only1s,
|
||||
delegate_representative: AlwaysNoConfidence,
|
||||
},
|
||||
deposit: 3_000_000,
|
||||
},
|
||||
) == list.at(certificates, 14)
|
||||
|
||||
expect
|
||||
Some(
|
||||
AuthorizeConstitutionalCommitteeProxy {
|
||||
constitutional_committee_member: VerificationKey(only0s),
|
||||
proxy: VerificationKey(only2s),
|
||||
},
|
||||
) == list.at(certificates, 15)
|
||||
|
||||
expect
|
||||
Some(
|
||||
RetireFromConstitutionalCommittee {
|
||||
constitutional_committee_member: VerificationKey(only0s),
|
||||
},
|
||||
) == list.at(certificates, 16)
|
||||
|
||||
expect
|
||||
Some(
|
||||
RegisterDelegateRepresentative {
|
||||
delegate_representative: VerificationKey(only0s),
|
||||
deposit: 3_000_000,
|
||||
},
|
||||
) == list.at(certificates, 17)
|
||||
|
||||
expect
|
||||
Some(
|
||||
UnregisterDelegateRepresentative {
|
||||
delegate_representative: VerificationKey(only0s),
|
||||
refund: 3_000_000,
|
||||
},
|
||||
) == list.at(certificates, 18)
|
||||
|
||||
expect
|
||||
Some(
|
||||
UpdateDelegateRepresentative {
|
||||
delegate_representative: VerificationKey(only0s),
|
||||
},
|
||||
) == list.at(certificates, 19)
|
||||
|
||||
expect Some(DelegateCredential {
|
||||
credential: Script(..),
|
||||
delegate: DelegateBlockProduction(..),
|
||||
}) = list.at(certificates, 20)
|
||||
|
||||
True
|
||||
}
|
||||
}
|
||||
|
||||
fn assert_script_info(info: ScriptInfo) {
|
||||
expect Publishing(20, DelegateCredential { credential, delegate }) = info
|
||||
expect DelegateBlockProduction { stake_pool: only1s } == delegate
|
||||
expect Script(..) = credential
|
||||
Void
|
||||
}
|
||||
Reference in New Issue
Block a user