diff --git a/ledger/allegra/rules_test.go b/ledger/allegra/rules_test.go index cf52cd20..0f23aa77 100644 --- a/ledger/allegra/rules_test.go +++ b/ledger/allegra/rules_test.go @@ -568,7 +568,7 @@ func TestUtxoValidateValueNotConservedUtxo(t *testing.T) { { Type: common.CertificateTypeStakeRegistration, Certificate: &common.StakeRegistrationCertificate{ - StakeRegistration: common.StakeCredential{}, + StakeRegistration: common.Credential{}, }, }, } @@ -595,7 +595,7 @@ func TestUtxoValidateValueNotConservedUtxo(t *testing.T) { { Type: common.CertificateTypeStakeRegistration, Certificate: &common.StakeDeregistrationCertificate{ - StakeDeregistration: common.StakeCredential{}, + StakeDeregistration: common.Credential{}, }, }, } diff --git a/ledger/alonzo/rules_test.go b/ledger/alonzo/rules_test.go index e52730b8..64da978a 100644 --- a/ledger/alonzo/rules_test.go +++ b/ledger/alonzo/rules_test.go @@ -602,7 +602,7 @@ func TestUtxoValidateValueNotConservedUtxo(t *testing.T) { { Type: common.CertificateTypeStakeRegistration, Certificate: &common.StakeRegistrationCertificate{ - StakeRegistration: common.StakeCredential{}, + StakeRegistration: common.Credential{}, }, }, } @@ -629,7 +629,7 @@ func TestUtxoValidateValueNotConservedUtxo(t *testing.T) { { Type: common.CertificateTypeStakeRegistration, Certificate: &common.StakeDeregistrationCertificate{ - StakeDeregistration: common.StakeCredential{}, + StakeDeregistration: common.Credential{}, }, }, } diff --git a/ledger/babbage/rules_test.go b/ledger/babbage/rules_test.go index 1c32dfd7..368cb0c5 100644 --- a/ledger/babbage/rules_test.go +++ b/ledger/babbage/rules_test.go @@ -601,7 +601,7 @@ func TestUtxoValidateValueNotConservedUtxo(t *testing.T) { { Type: common.CertificateTypeStakeRegistration, Certificate: &common.StakeRegistrationCertificate{ - StakeRegistration: common.StakeCredential{}, + StakeRegistration: common.Credential{}, }, }, } @@ -628,7 +628,7 @@ func TestUtxoValidateValueNotConservedUtxo(t *testing.T) { { Type: common.CertificateTypeStakeRegistration, Certificate: &common.StakeDeregistrationCertificate{ - StakeDeregistration: common.StakeCredential{}, + StakeDeregistration: common.Credential{}, }, }, } diff --git a/ledger/common/certs.go b/ledger/common/certs.go index 650e608b..43c7cf7a 100644 --- a/ledger/common/certs.go +++ b/ledger/common/certs.go @@ -160,7 +160,7 @@ type StakeRegistrationCertificate struct { cbor.StructAsArray cbor.DecodeStoreCbor CertType uint - StakeRegistration StakeCredential + StakeRegistration Credential } func (c StakeRegistrationCertificate) isCertificate() {} @@ -181,7 +181,7 @@ type StakeDeregistrationCertificate struct { cbor.StructAsArray cbor.DecodeStoreCbor CertType uint - StakeDeregistration StakeCredential + StakeDeregistration Credential } func (c StakeDeregistrationCertificate) isCertificate() {} @@ -202,7 +202,7 @@ type StakeDelegationCertificate struct { cbor.StructAsArray cbor.DecodeStoreCbor CertType uint - StakeCredential *StakeCredential + StakeCredential *Credential PoolKeyHash PoolKeyHash } @@ -435,7 +435,7 @@ const ( type MoveInstantaneousRewardsCertificateReward struct { Source uint - Rewards map[*StakeCredential]uint64 + Rewards map[*Credential]uint64 OtherPot uint64 } @@ -446,7 +446,7 @@ func (r *MoveInstantaneousRewardsCertificateReward) UnmarshalCBOR( tmpMapData := struct { cbor.StructAsArray Source uint - Rewards map[*StakeCredential]uint64 + Rewards map[*Credential]uint64 }{} if _, err := cbor.Decode(data, &tmpMapData); err == nil { r.Rewards = tmpMapData.Rewards @@ -512,7 +512,7 @@ type RegistrationCertificate struct { cbor.StructAsArray cbor.DecodeStoreCbor CertType uint - StakeCredential StakeCredential + StakeCredential Credential Amount int64 } @@ -533,7 +533,7 @@ type DeregistrationCertificate struct { cbor.StructAsArray cbor.DecodeStoreCbor CertType uint - StakeCredential StakeCredential + StakeCredential Credential Amount int64 } @@ -554,7 +554,7 @@ type VoteDelegationCertificate struct { cbor.StructAsArray cbor.DecodeStoreCbor CertType uint - StakeCredential StakeCredential + StakeCredential Credential Drep Drep } @@ -575,7 +575,7 @@ type StakeVoteDelegationCertificate struct { cbor.StructAsArray cbor.DecodeStoreCbor CertType uint - StakeCredential StakeCredential + StakeCredential Credential PoolKeyHash []byte Drep Drep } @@ -597,7 +597,7 @@ type StakeRegistrationDelegationCertificate struct { cbor.StructAsArray cbor.DecodeStoreCbor CertType uint - StakeCredential StakeCredential + StakeCredential Credential PoolKeyHash []byte Amount int64 } @@ -619,7 +619,7 @@ type VoteRegistrationDelegationCertificate struct { cbor.StructAsArray cbor.DecodeStoreCbor CertType uint - StakeCredential StakeCredential + StakeCredential Credential Drep Drep Amount int64 } @@ -641,7 +641,7 @@ type StakeVoteRegistrationDelegationCertificate struct { cbor.StructAsArray cbor.DecodeStoreCbor CertType uint - StakeCredential StakeCredential + StakeCredential Credential PoolKeyHash []byte Drep Drep Amount int64 @@ -664,8 +664,8 @@ type AuthCommitteeHotCertificate struct { cbor.StructAsArray cbor.DecodeStoreCbor CertType uint - ColdCredential StakeCredential - HostCredential StakeCredential + ColdCredential Credential + HostCredential Credential } func (c AuthCommitteeHotCertificate) isCertificate() {} @@ -685,7 +685,7 @@ type ResignCommitteeColdCertificate struct { cbor.StructAsArray cbor.DecodeStoreCbor CertType uint - ColdCredential StakeCredential + ColdCredential Credential Anchor *GovAnchor } @@ -706,7 +706,7 @@ type RegistrationDrepCertificate struct { cbor.StructAsArray cbor.DecodeStoreCbor CertType uint - DrepCredential StakeCredential + DrepCredential Credential Amount int64 Anchor *GovAnchor } @@ -728,7 +728,7 @@ type DeregistrationDrepCertificate struct { cbor.StructAsArray cbor.DecodeStoreCbor CertType uint - DrepCredential StakeCredential + DrepCredential Credential Amount int64 } @@ -749,7 +749,7 @@ type UpdateDrepCertificate struct { cbor.StructAsArray cbor.DecodeStoreCbor CertType uint - DrepCredential StakeCredential + DrepCredential Credential Anchor *GovAnchor } diff --git a/ledger/common/credentials.go b/ledger/common/credentials.go index 3e24772e..72425b4f 100644 --- a/ledger/common/credentials.go +++ b/ledger/common/credentials.go @@ -23,22 +23,22 @@ import ( ) const ( - StakeCredentialTypeAddrKeyHash = 0 - StakeCredentialTypeScriptHash = 1 + CredentialTypeAddrKeyHash = 0 + CredentialTypeScriptHash = 1 ) -type StakeCredential struct { +type Credential struct { cbor.StructAsArray cbor.DecodeStoreCbor CredType uint Credential []byte } -func (c *StakeCredential) UnmarshalCBOR(data []byte) error { +func (c *Credential) UnmarshalCBOR(data []byte) error { return c.UnmarshalCbor(data, c) } -func (c *StakeCredential) Hash() Blake2b224 { +func (c *Credential) Hash() Blake2b224 { hash, err := blake2b.New(28, nil) if err != nil { panic( @@ -54,14 +54,14 @@ func (c *StakeCredential) Hash() Blake2b224 { return Blake2b224(hash.Sum(nil)) } -func (c *StakeCredential) Utxorpc() *utxorpc.StakeCredential { +func (c *Credential) Utxorpc() *utxorpc.StakeCredential { ret := &utxorpc.StakeCredential{} switch c.CredType { - case StakeCredentialTypeAddrKeyHash: + case CredentialTypeAddrKeyHash: ret.StakeCredential = &utxorpc.StakeCredential_AddrKeyHash{ AddrKeyHash: c.Credential[:], } - case StakeCredentialTypeScriptHash: + case CredentialTypeScriptHash: ret.StakeCredential = &utxorpc.StakeCredential_ScriptHash{ ScriptHash: c.Credential[:], } diff --git a/ledger/common/gov.go b/ledger/common/gov.go index 63c7e200..527b36a4 100644 --- a/ledger/common/gov.go +++ b/ledger/common/gov.go @@ -171,8 +171,8 @@ type UpdateCommitteeGovAction struct { cbor.StructAsArray Type uint ActionId *GovActionId - Credentials []StakeCredential - CredEpochs map[*StakeCredential]uint + Credentials []Credential + CredEpochs map[*Credential]uint Unknown cbor.Rat } diff --git a/ledger/conway/rules_test.go b/ledger/conway/rules_test.go index 35be4607..a08be3e2 100644 --- a/ledger/conway/rules_test.go +++ b/ledger/conway/rules_test.go @@ -601,7 +601,7 @@ func TestUtxoValidateValueNotConservedUtxo(t *testing.T) { { Type: common.CertificateTypeStakeRegistration, Certificate: &common.StakeRegistrationCertificate{ - StakeRegistration: common.StakeCredential{}, + StakeRegistration: common.Credential{}, }, }, } @@ -628,7 +628,7 @@ func TestUtxoValidateValueNotConservedUtxo(t *testing.T) { { Type: common.CertificateTypeStakeRegistration, Certificate: &common.StakeDeregistrationCertificate{ - StakeDeregistration: common.StakeCredential{}, + StakeDeregistration: common.Credential{}, }, }, } diff --git a/ledger/mary/rules_test.go b/ledger/mary/rules_test.go index 68ac74cf..aed97af1 100644 --- a/ledger/mary/rules_test.go +++ b/ledger/mary/rules_test.go @@ -587,7 +587,7 @@ func TestUtxoValidateValueNotConservedUtxo(t *testing.T) { { Type: common.CertificateTypeStakeRegistration, Certificate: &common.StakeRegistrationCertificate{ - StakeRegistration: common.StakeCredential{}, + StakeRegistration: common.Credential{}, }, }, } @@ -614,7 +614,7 @@ func TestUtxoValidateValueNotConservedUtxo(t *testing.T) { { Type: common.CertificateTypeStakeRegistration, Certificate: &common.StakeDeregistrationCertificate{ - StakeDeregistration: common.StakeCredential{}, + StakeDeregistration: common.Credential{}, }, }, } diff --git a/ledger/shelley/rules_test.go b/ledger/shelley/rules_test.go index 2a2cb9cd..87d1b6b6 100644 --- a/ledger/shelley/rules_test.go +++ b/ledger/shelley/rules_test.go @@ -553,7 +553,7 @@ func TestUtxoValidateValueNotConservedUtxo(t *testing.T) { { Type: common.CertificateTypeStakeRegistration, Certificate: &common.StakeRegistrationCertificate{ - StakeRegistration: common.StakeCredential{}, + StakeRegistration: common.Credential{}, }, }, } @@ -580,7 +580,7 @@ func TestUtxoValidateValueNotConservedUtxo(t *testing.T) { { Type: common.CertificateTypeStakeRegistration, Certificate: &common.StakeDeregistrationCertificate{ - StakeDeregistration: common.StakeCredential{}, + StakeDeregistration: common.Credential{}, }, }, }