1
- // Copyright 2023 Blink Labs Software
1
+ // Copyright 2024 Blink Labs Software
2
2
//
3
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
4
// you may not use this file except in compliance with the License.
12
12
// See the License for the specific language governing permissions and
13
13
// limitations under the License.
14
14
15
- package ledger
15
+ package allegra
16
16
17
17
import (
18
18
"encoding/hex"
19
19
"fmt"
20
20
21
21
"github.com/blinklabs-io/gouroboros/cbor"
22
22
"github.com/blinklabs-io/gouroboros/ledger/common"
23
+ "github.com/blinklabs-io/gouroboros/ledger/shelley"
23
24
24
25
utxorpc "github.com/utxorpc/go-codegen/utxorpc/v1alpha/cardano"
25
26
)
@@ -51,7 +52,7 @@ type AllegraBlock struct {
51
52
cbor.DecodeStoreCbor
52
53
Header * AllegraBlockHeader
53
54
TransactionBodies []AllegraTransactionBody
54
- TransactionWitnessSets []ShelleyTransactionWitnessSet
55
+ TransactionWitnessSets []shelley. ShelleyTransactionWitnessSet
55
56
TransactionMetadataSet map [uint ]* cbor.LazyValue
56
57
}
57
58
@@ -71,20 +72,20 @@ func (b *AllegraBlock) SlotNumber() uint64 {
71
72
return b .Header .SlotNumber ()
72
73
}
73
74
74
- func (b * AllegraBlock ) IssuerVkey () IssuerVkey {
75
+ func (b * AllegraBlock ) IssuerVkey () common. IssuerVkey {
75
76
return b .Header .IssuerVkey ()
76
77
}
77
78
78
79
func (b * AllegraBlock ) BlockBodySize () uint64 {
79
80
return b .Header .BlockBodySize ()
80
81
}
81
82
82
- func (b * AllegraBlock ) Era () Era {
83
+ func (b * AllegraBlock ) Era () common. Era {
83
84
return EraAllegra
84
85
}
85
86
86
- func (b * AllegraBlock ) Transactions () []Transaction {
87
- ret := make ([]Transaction , len (b .TransactionBodies ))
87
+ func (b * AllegraBlock ) Transactions () []common. Transaction {
88
+ ret := make ([]common. Transaction , len (b .TransactionBodies ))
88
89
for idx := range b .TransactionBodies {
89
90
ret [idx ] = & AllegraTransaction {
90
91
Body : b .TransactionBodies [idx ],
@@ -118,18 +119,18 @@ func (b *AllegraBlock) Utxorpc() *utxorpc.Block {
118
119
}
119
120
120
121
type AllegraBlockHeader struct {
121
- ShelleyBlockHeader
122
+ shelley. ShelleyBlockHeader
122
123
}
123
124
124
- func (h * AllegraBlockHeader ) Era () Era {
125
+ func (h * AllegraBlockHeader ) Era () common. Era {
125
126
return EraAllegra
126
127
}
127
128
128
129
type AllegraTransactionBody struct {
129
- ShelleyTransactionBody
130
+ shelley. ShelleyTransactionBody
130
131
Update struct {
131
132
cbor.StructAsArray
132
- ProtocolParamUpdates map [Blake2b224 ]AllegraProtocolParameterUpdate
133
+ ProtocolParamUpdates map [common. Blake2b224 ]AllegraProtocolParameterUpdate
133
134
Epoch uint64
134
135
} `cbor:"6,keyasint,omitempty"`
135
136
TxValidityIntervalStart uint64 `cbor:"8,keyasint,omitempty"`
@@ -143,8 +144,8 @@ func (b *AllegraTransactionBody) ValidityIntervalStart() uint64 {
143
144
return b .TxValidityIntervalStart
144
145
}
145
146
146
- func (b * AllegraTransactionBody ) ProtocolParametersUpdate () map [Blake2b224 ]any {
147
- updateMap := make (map [Blake2b224 ]any )
147
+ func (b * AllegraTransactionBody ) ProtocolParametersUpdate () map [common. Blake2b224 ]any {
148
+ updateMap := make (map [common. Blake2b224 ]any )
148
149
for k , v := range b .Update .ProtocolParamUpdates {
149
150
updateMap [k ] = v
150
151
}
@@ -155,19 +156,19 @@ type AllegraTransaction struct {
155
156
cbor.StructAsArray
156
157
cbor.DecodeStoreCbor
157
158
Body AllegraTransactionBody
158
- WitnessSet ShelleyTransactionWitnessSet
159
+ WitnessSet shelley. ShelleyTransactionWitnessSet
159
160
TxMetadata * cbor.LazyValue
160
161
}
161
162
162
163
func (t AllegraTransaction ) Hash () string {
163
164
return t .Body .Hash ()
164
165
}
165
166
166
- func (t AllegraTransaction ) Inputs () []TransactionInput {
167
+ func (t AllegraTransaction ) Inputs () []common. TransactionInput {
167
168
return t .Body .Inputs ()
168
169
}
169
170
170
- func (t AllegraTransaction ) Outputs () []TransactionOutput {
171
+ func (t AllegraTransaction ) Outputs () []common. TransactionOutput {
171
172
return t .Body .Outputs ()
172
173
}
173
174
@@ -183,51 +184,51 @@ func (t AllegraTransaction) ValidityIntervalStart() uint64 {
183
184
return t .Body .ValidityIntervalStart ()
184
185
}
185
186
186
- func (t AllegraTransaction ) ReferenceInputs () []TransactionInput {
187
+ func (t AllegraTransaction ) ReferenceInputs () []common. TransactionInput {
187
188
return t .Body .ReferenceInputs ()
188
189
}
189
190
190
- func (t AllegraTransaction ) Collateral () []TransactionInput {
191
+ func (t AllegraTransaction ) Collateral () []common. TransactionInput {
191
192
return t .Body .Collateral ()
192
193
}
193
194
194
- func (t AllegraTransaction ) CollateralReturn () TransactionOutput {
195
+ func (t AllegraTransaction ) CollateralReturn () common. TransactionOutput {
195
196
return t .Body .CollateralReturn ()
196
197
}
197
198
198
199
func (t AllegraTransaction ) TotalCollateral () uint64 {
199
200
return t .Body .TotalCollateral ()
200
201
}
201
202
202
- func (t AllegraTransaction ) Certificates () []Certificate {
203
+ func (t AllegraTransaction ) Certificates () []common. Certificate {
203
204
return t .Body .Certificates ()
204
205
}
205
206
206
- func (t AllegraTransaction ) Withdrawals () map [* Address ]uint64 {
207
+ func (t AllegraTransaction ) Withdrawals () map [* common. Address ]uint64 {
207
208
return t .Body .Withdrawals ()
208
209
}
209
210
210
- func (t AllegraTransaction ) AuxDataHash () * Blake2b256 {
211
+ func (t AllegraTransaction ) AuxDataHash () * common. Blake2b256 {
211
212
return t .Body .AuxDataHash ()
212
213
}
213
214
214
- func (t AllegraTransaction ) RequiredSigners () []Blake2b224 {
215
+ func (t AllegraTransaction ) RequiredSigners () []common. Blake2b224 {
215
216
return t .Body .RequiredSigners ()
216
217
}
217
218
218
219
func (t AllegraTransaction ) AssetMint () * common.MultiAsset [common.MultiAssetTypeMint ] {
219
220
return t .Body .AssetMint ()
220
221
}
221
222
222
- func (t AllegraTransaction ) ScriptDataHash () * Blake2b256 {
223
+ func (t AllegraTransaction ) ScriptDataHash () * common. Blake2b256 {
223
224
return t .Body .ScriptDataHash ()
224
225
}
225
226
226
- func (t AllegraTransaction ) VotingProcedures () VotingProcedures {
227
+ func (t AllegraTransaction ) VotingProcedures () common. VotingProcedures {
227
228
return t .Body .VotingProcedures ()
228
229
}
229
230
230
- func (t AllegraTransaction ) ProposalProcedures () []ProposalProcedure {
231
+ func (t AllegraTransaction ) ProposalProcedures () []common. ProposalProcedure {
231
232
return t .Body .ProposalProcedures ()
232
233
}
233
234
@@ -251,25 +252,25 @@ func (t AllegraTransaction) IsValid() bool {
251
252
return true
252
253
}
253
254
254
- func (t AllegraTransaction ) Consumed () []TransactionInput {
255
+ func (t AllegraTransaction ) Consumed () []common. TransactionInput {
255
256
return t .Inputs ()
256
257
}
257
258
258
- func (t AllegraTransaction ) Produced () []Utxo {
259
- var ret []Utxo
259
+ func (t AllegraTransaction ) Produced () []common. Utxo {
260
+ var ret []common. Utxo
260
261
for idx , output := range t .Outputs () {
261
262
ret = append (
262
263
ret ,
263
- Utxo {
264
- Id : NewShelleyTransactionInput (t .Hash (), idx ),
264
+ common. Utxo {
265
+ Id : shelley . NewShelleyTransactionInput (t .Hash (), idx ),
265
266
Output : output ,
266
267
},
267
268
)
268
269
}
269
270
return ret
270
271
}
271
272
272
- func (t AllegraTransaction ) ProtocolParametersUpdate () map [Blake2b224 ]any {
273
+ func (t AllegraTransaction ) ProtocolParametersUpdate () map [common. Blake2b224 ]any {
273
274
return t .Body .ProtocolParametersUpdate ()
274
275
}
275
276
@@ -300,11 +301,11 @@ func (t *AllegraTransaction) Cbor() []byte {
300
301
}
301
302
302
303
type AllegraProtocolParameters struct {
303
- ShelleyProtocolParameters
304
+ shelley. ShelleyProtocolParameters
304
305
}
305
306
306
307
type AllegraProtocolParameterUpdate struct {
307
- ShelleyProtocolParameterUpdate
308
+ shelley. ShelleyProtocolParameterUpdate
308
309
}
309
310
310
311
func NewAllegraBlockFromCbor (data []byte ) (* AllegraBlock , error ) {
0 commit comments