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

chore: split ledger era compat types to separate files #696

Merged
merged 1 commit into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
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
42 changes: 42 additions & 0 deletions ledger/allegra.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright 2024 Blink Labs Software
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package ledger

import "github.com/blinklabs-io/gouroboros/ledger/allegra"

// The below are compatability types, constants, and functions for the Allegra era
// to keep existing code working after a refactor of the ledger package

// Allegra types
type AllegraBlock = allegra.AllegraBlock
type AllegraTransaction = allegra.AllegraTransaction
type AllegraTransactionBody = allegra.AllegraTransactionBody
type AllegraProtocolParameters = allegra.AllegraProtocolParameters
type AllegraProtocolParameterUpdate = allegra.AllegraProtocolParameterUpdate

// Allegra constants
const (
EraIdAllegra = allegra.EraIdAllegra
BlockTypeAllegra = allegra.BlockTypeAllegra
BlockHeaderTypeAllegra = allegra.BlockHeaderTypeAllegra
TxTypeAllegra = allegra.TxTypeAllegra
)

// Allegra functions
var (
NewAllegraBlockFromCbor = allegra.NewAllegraBlockFromCbor
NewAllegraTransactionFromCbor = allegra.NewAllegraTransactionFromCbor
NewAllegraTransactionBodyFromCbor = allegra.NewAllegraTransactionBodyFromCbor
)
46 changes: 46 additions & 0 deletions ledger/alonzo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright 2024 Blink Labs Software
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package ledger

import "github.com/blinklabs-io/gouroboros/ledger/alonzo"

// The below are compatability types, constants, and functions for the Alonzo era
// to keep existing code working after a refactor of the ledger package

// Alonzo types
type AlonzoBlock = alonzo.AlonzoBlock
type AlonzoBlockHeader = alonzo.AlonzoBlockHeader
type AlonzoTransaction = alonzo.AlonzoTransaction
type AlonzoTransactionBody = alonzo.AlonzoTransactionBody
type AlonzoTransactionOutput = alonzo.AlonzoTransactionOutput
type AlonzoTransactionWitnessSet = alonzo.AlonzoTransactionWitnessSet
type AlonzoProtocolParameters = alonzo.AlonzoProtocolParameters
type AlonzoProtocolParameterUpdate = alonzo.AlonzoProtocolParameterUpdate

// Alonzo constants
const (
EraIdAlonzo = alonzo.EraIdAlonzo
BlockTypeAlonzo = alonzo.BlockTypeAlonzo
BlockHeaderTypeAlonzo = alonzo.BlockHeaderTypeAlonzo
TxTypeAlonzo = alonzo.TxTypeAlonzo
)

// Alonzo functions
var (
NewAlonzoBlockFromCbor = alonzo.NewAlonzoBlockFromCbor
NewAlonzoTransactionFromCbor = alonzo.NewAlonzoTransactionFromCbor
NewAlonzoTransactionBodyFromCbor = alonzo.NewAlonzoTransactionBodyFromCbor
NewAlonzoTransactionOutputFromCbor = alonzo.NewAlonzoTransactionOutputFromCbor
)
47 changes: 47 additions & 0 deletions ledger/babbage.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright 2024 Blink Labs Software
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package ledger

import "github.com/blinklabs-io/gouroboros/ledger/babbage"

// The below are compatability types, constants, and functions for the Babbage era
// to keep existing code working after a refactor of the ledger package

// Babbage types
type BabbageBlock = babbage.BabbageBlock
type BabbageBlockHeader = babbage.BabbageBlockHeader
type BabbageTransaction = babbage.BabbageTransaction
type BabbageTransactionBody = babbage.BabbageTransactionBody
type BabbageTransactionOutput = babbage.BabbageTransactionOutput
type BabbageTransactionWitnessSet = babbage.BabbageTransactionWitnessSet
type BabbageProtocolParameters = babbage.BabbageProtocolParameters
type BabbageProtocolParameterUpdate = babbage.BabbageProtocolParameterUpdate

// Babbage constants
const (
EraIdBabbage = babbage.EraIdBabbage
BlockTypeBabbage = babbage.BlockTypeBabbage
BlockHeaderTypeBabbage = babbage.BlockHeaderTypeBabbage
TxTypeBabbage = babbage.TxTypeBabbage
)

// Babbage functions
var (
NewBabbageBlockFromCbor = babbage.NewBabbageBlockFromCbor
NewBabbageBlockHeaderFromCbor = babbage.NewBabbageBlockHeaderFromCbor
NewBabbageTransactionFromCbor = babbage.NewBabbageTransactionFromCbor
NewBabbageTransactionBodyFromCbor = babbage.NewBabbageTransactionBodyFromCbor
NewBabbageTransactionOutputFromCbor = babbage.NewBabbageTransactionOutputFromCbor
)
48 changes: 48 additions & 0 deletions ledger/byron.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright 2024 Blink Labs Software
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package ledger

import "github.com/blinklabs-io/gouroboros/ledger/byron"

// The below are compatability types, constants, and functions for the Byron era
// to keep existing code working after a refactor of the ledger package

// Byron types
type ByronEpochBoundaryBlock = byron.ByronEpochBoundaryBlock
type ByronMainBlock = byron.ByronMainBlock
type ByronEpochBounaryBlockHeader = byron.ByronEpochBoundaryBlockHeader
type ByronMainBlockHeader = byron.ByronMainBlockHeader
type ByronTransaction = byron.ByronTransaction
type ByronTransactionInput = byron.ByronTransactionInput
type ByronTransactionOutput = byron.ByronTransactionOutput

// Byron constants
const (
EraIdByron = byron.EraIdByron
BlockTypeByronEbb = byron.BlockTypeByronEbb
BlockTypeByronMain = byron.BlockTypeByronMain
BlockHeaderTypeByron = byron.BlockHeaderTypeByron
TxTypeByron = byron.TxTypeByron
)

// Byron functions
var (
NewByronEpochBoundaryBlockFromCbor = byron.NewByronEpochBoundaryBlockFromCbor
NewByronMainBlockFromCbor = byron.NewByronMainBlockFromCbor
NewByronEpochBoundaryBlockHeaderFromCbor = byron.NewByronEpochBoundaryBlockHeaderFromCbor
NewByronMainBlockHeaderFromCbor = byron.NewByronMainBlockHeaderFromCbor
NewByronTransactionInput = byron.NewByronTransactionInput
NewByronTransactionFromCbor = byron.NewByronTransactionFromCbor
)
191 changes: 0 additions & 191 deletions ledger/compat.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,7 @@
package ledger

import (
"github.com/blinklabs-io/gouroboros/ledger/allegra"
"github.com/blinklabs-io/gouroboros/ledger/alonzo"
"github.com/blinklabs-io/gouroboros/ledger/babbage"
"github.com/blinklabs-io/gouroboros/ledger/byron"
"github.com/blinklabs-io/gouroboros/ledger/common"
"github.com/blinklabs-io/gouroboros/ledger/conway"
"github.com/blinklabs-io/gouroboros/ledger/mary"
"github.com/blinklabs-io/gouroboros/ledger/shelley"
)

// The below are compatability types and functions to keep existing code working
Expand Down Expand Up @@ -79,187 +72,3 @@ type AssetFingerprint = common.AssetFingerprint
func NewAssetFingerprint(policyId []byte, assetName []byte) AssetFingerprint {
return common.NewAssetFingerprint(policyId, assetName)
}

// Byron types
type ByronEpochBoundaryBlock = byron.ByronEpochBoundaryBlock
type ByronMainBlock = byron.ByronMainBlock
type ByronEpochBounaryBlockHeader = byron.ByronEpochBoundaryBlockHeader
type ByronMainBlockHeader = byron.ByronMainBlockHeader
type ByronTransaction = byron.ByronTransaction
type ByronTransactionInput = byron.ByronTransactionInput
type ByronTransactionOutput = byron.ByronTransactionOutput

// Byron constants
const (
EraIdByron = byron.EraIdByron
BlockTypeByronEbb = byron.BlockTypeByronEbb
BlockTypeByronMain = byron.BlockTypeByronMain
BlockHeaderTypeByron = byron.BlockHeaderTypeByron
TxTypeByron = byron.TxTypeByron
)

// Byron functions
var (
NewByronEpochBoundaryBlockFromCbor = byron.NewByronEpochBoundaryBlockFromCbor
NewByronMainBlockFromCbor = byron.NewByronMainBlockFromCbor
NewByronEpochBoundaryBlockHeaderFromCbor = byron.NewByronEpochBoundaryBlockHeaderFromCbor
NewByronMainBlockHeaderFromCbor = byron.NewByronMainBlockHeaderFromCbor
NewByronTransactionInput = byron.NewByronTransactionInput
NewByronTransactionFromCbor = byron.NewByronTransactionFromCbor
)

// Shelley types
type ShelleyBlock = shelley.ShelleyBlock
type ShelleyBlockHeader = shelley.ShelleyBlockHeader
type ShelleyTransaction = shelley.ShelleyTransaction
type ShelleyTransactionBody = shelley.ShelleyTransactionBody
type ShelleyTransactionInput = shelley.ShelleyTransactionInput
type ShelleyTransactionOutput = shelley.ShelleyTransactionOutput
type ShelleyTransactionWitnessSet = shelley.ShelleyTransactionWitnessSet
type ShelleyProtocolParameters = shelley.ShelleyProtocolParameters
type ShelleyProtocolParameterUpdate = shelley.ShelleyProtocolParameterUpdate

// Shelley constants
const (
EraIdShelley = shelley.EraIdShelley
BlockTypeShelley = shelley.BlockTypeShelley
BlockHeaderTypeShelley = shelley.BlockHeaderTypeShelley
TxTypeShelley = shelley.TxTypeShelley
)

// Shelley functions
var (
NewShelleyBlockFromCbor = shelley.NewShelleyBlockFromCbor
NewShelleyBlockHeaderFromCbor = shelley.NewShelleyBlockHeaderFromCbor
NewShelleyTransactionInput = shelley.NewShelleyTransactionInput
NewShelleyTransactionFromCbor = shelley.NewShelleyTransactionFromCbor
NewShelleyTransactionBodyFromCbor = shelley.NewShelleyTransactionBodyFromCbor
NewShelleyTransactionOutputFromCbor = shelley.NewShelleyTransactionOutputFromCbor
)

// Allegra types
type AllegraBlock = allegra.AllegraBlock
type AllegraTransaction = allegra.AllegraTransaction
type AllegraTransactionBody = allegra.AllegraTransactionBody
type AllegraProtocolParameters = allegra.AllegraProtocolParameters
type AllegraProtocolParameterUpdate = allegra.AllegraProtocolParameterUpdate

// Allegra constants
const (
EraIdAllegra = allegra.EraIdAllegra
BlockTypeAllegra = allegra.BlockTypeAllegra
BlockHeaderTypeAllegra = allegra.BlockHeaderTypeAllegra
TxTypeAllegra = allegra.TxTypeAllegra
)

// Allegra functions
var (
NewAllegraBlockFromCbor = allegra.NewAllegraBlockFromCbor
NewAllegraTransactionFromCbor = allegra.NewAllegraTransactionFromCbor
NewAllegraTransactionBodyFromCbor = allegra.NewAllegraTransactionBodyFromCbor
)

// Mary types
type MaryBlock = mary.MaryBlock
type MaryBlockHeader = mary.MaryBlockHeader
type MaryTransaction = mary.MaryTransaction
type MaryTransactionBody = mary.MaryTransactionBody
type MaryTransactionOutput = mary.MaryTransactionOutput
type MaryTransactionOutputValue = mary.MaryTransactionOutputValue
type MaryTransactionWitnessSet = mary.MaryTransactionWitnessSet
type MaryProtocolParameters = mary.MaryProtocolParameters
type MaryProtocolParameterUpdate = mary.MaryProtocolParameterUpdate

// Mary constants
const (
EraIdMary = mary.EraIdMary
BlockTypeMary = mary.BlockTypeMary
BlockHeaderTypeMary = mary.BlockHeaderTypeMary
TxTypeMary = mary.TxTypeMary
)

// Mary functions
var (
NewMaryBlockFromCbor = mary.NewMaryBlockFromCbor
NewMaryTransactionFromCbor = mary.NewMaryTransactionFromCbor
NewMaryTransactionBodyFromCbor = mary.NewMaryTransactionBodyFromCbor
NewMaryTransactionOutputFromCbor = mary.NewMaryTransactionOutputFromCbor
)

// Alonzo types
type AlonzoBlock = alonzo.AlonzoBlock
type AlonzoBlockHeader = alonzo.AlonzoBlockHeader
type AlonzoTransaction = alonzo.AlonzoTransaction
type AlonzoTransactionBody = alonzo.AlonzoTransactionBody
type AlonzoTransactionOutput = alonzo.AlonzoTransactionOutput
type AlonzoTransactionWitnessSet = alonzo.AlonzoTransactionWitnessSet
type AlonzoProtocolParameters = alonzo.AlonzoProtocolParameters
type AlonzoProtocolParameterUpdate = alonzo.AlonzoProtocolParameterUpdate

// Alonzo constants
const (
EraIdAlonzo = alonzo.EraIdAlonzo
BlockTypeAlonzo = alonzo.BlockTypeAlonzo
BlockHeaderTypeAlonzo = alonzo.BlockHeaderTypeAlonzo
TxTypeAlonzo = alonzo.TxTypeAlonzo
)

// Alonzo functions
var (
NewAlonzoBlockFromCbor = alonzo.NewAlonzoBlockFromCbor
NewAlonzoTransactionFromCbor = alonzo.NewAlonzoTransactionFromCbor
NewAlonzoTransactionBodyFromCbor = alonzo.NewAlonzoTransactionBodyFromCbor
NewAlonzoTransactionOutputFromCbor = alonzo.NewAlonzoTransactionOutputFromCbor
)

// Babbage types
type BabbageBlock = babbage.BabbageBlock
type BabbageBlockHeader = babbage.BabbageBlockHeader
type BabbageTransaction = babbage.BabbageTransaction
type BabbageTransactionBody = babbage.BabbageTransactionBody
type BabbageTransactionOutput = babbage.BabbageTransactionOutput
type BabbageTransactionWitnessSet = babbage.BabbageTransactionWitnessSet
type BabbageProtocolParameters = babbage.BabbageProtocolParameters
type BabbageProtocolParameterUpdate = babbage.BabbageProtocolParameterUpdate

// Babbage constants
const (
EraIdBabbage = babbage.EraIdBabbage
BlockTypeBabbage = babbage.BlockTypeBabbage
BlockHeaderTypeBabbage = babbage.BlockHeaderTypeBabbage
TxTypeBabbage = babbage.TxTypeBabbage
)

// Babbage functions
var (
NewBabbageBlockFromCbor = babbage.NewBabbageBlockFromCbor
NewBabbageBlockHeaderFromCbor = babbage.NewBabbageBlockHeaderFromCbor
NewBabbageTransactionFromCbor = babbage.NewBabbageTransactionFromCbor
NewBabbageTransactionBodyFromCbor = babbage.NewBabbageTransactionBodyFromCbor
NewBabbageTransactionOutputFromCbor = babbage.NewBabbageTransactionOutputFromCbor
)

// Conway types
type ConwayBlock = conway.ConwayBlock
type ConwayBlockHeader = conway.ConwayBlockHeader
type ConwayTransaction = conway.ConwayTransaction
type ConwayTransactionBody = conway.ConwayTransactionBody
type ConwayTransactionWitnessSet = conway.ConwayTransactionWitnessSet
type ConwayProtocolParameters = conway.ConwayProtocolParameters
type ConwayProtocolParameterUpdate = conway.ConwayProtocolParameterUpdate

// Conway constants
const (
EraIdConway = conway.EraIdConway
BlockTypeConway = conway.BlockTypeConway
BlockHeaderTypeConway = conway.BlockHeaderTypeConway
TxTypeConway = conway.TxTypeConway
)

// Conway functions
var (
NewConwayBlockFromCbor = conway.NewConwayBlockFromCbor
NewConwayBlockHeaderFromCbor = conway.NewConwayBlockHeaderFromCbor
NewConwayTransactionFromCbor = conway.NewConwayTransactionFromCbor
NewConwayTransactionBodyFromCbor = conway.NewConwayTransactionBodyFromCbor
)
Loading