Skip to content

Commit d96741d

Browse files
authored
fix: Address plutus data structure (#1121)
Signed-off-by: Aurora Gaffney <[email protected]>
1 parent fb70050 commit d96741d

File tree

4 files changed

+22
-45
lines changed

4 files changed

+22
-45
lines changed

ledger/alonzo/alonzo_test.go

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,10 @@ func TestAlonzoTransactionOutputToPlutusDataCoinOnly(t *testing.T) {
4242
0,
4343
data.NewConstr(
4444
0,
45-
data.NewConstr(
46-
0,
47-
data.NewByteString(
48-
[]byte{
49-
0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
50-
},
51-
),
45+
data.NewByteString(
46+
[]byte{
47+
0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
48+
},
5249
),
5350
),
5451
data.NewConstr(
@@ -109,13 +106,10 @@ func TestAlonzoTransactionOutputToPlutusDataCoinAssets(t *testing.T) {
109106
0,
110107
data.NewConstr(
111108
0,
112-
data.NewConstr(
113-
0,
114-
data.NewByteString(
115-
[]byte{
116-
0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
117-
},
118-
),
109+
data.NewByteString(
110+
[]byte{
111+
0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
112+
},
119113
),
120114
),
121115
data.NewConstr(

ledger/babbage/babbage_test.go

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2824,13 +2824,10 @@ func TestBabbageTransactionOutputToPlutusDataCoinOnly(t *testing.T) {
28242824
0,
28252825
data.NewConstr(
28262826
0,
2827-
data.NewConstr(
2828-
0,
2829-
data.NewByteString(
2830-
[]byte{
2831-
0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
2832-
},
2833-
),
2827+
data.NewByteString(
2828+
[]byte{
2829+
0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
2830+
},
28342831
),
28352832
),
28362833
data.NewConstr(
@@ -2891,13 +2888,10 @@ func TestBabbageTransactionOutputToPlutusDataCoinAssets(t *testing.T) {
28912888
0,
28922889
data.NewConstr(
28932890
0,
2894-
data.NewConstr(
2895-
0,
2896-
data.NewByteString(
2897-
[]byte{
2898-
0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
2899-
},
2900-
),
2891+
data.NewByteString(
2892+
[]byte{
2893+
0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
2894+
},
29012895
),
29022896
),
29032897
data.NewConstr(

ledger/common/address.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -295,22 +295,14 @@ func (a *Address) ToPlutusData() data.PlutusData {
295295
var paymentPd data.PlutusData
296296
switch a.addressType {
297297
case AddressTypeKeyKey, AddressTypeKeyScript, AddressTypeKeyPointer, AddressTypeKeyNone:
298-
tmpCred := &Credential{
299-
CredType: CredentialTypeAddrKeyHash,
300-
Credential: NewBlake2b224(a.paymentAddress),
301-
}
302298
paymentPd = data.NewConstr(
303299
0,
304-
tmpCred.ToPlutusData(),
300+
data.NewByteString(a.paymentAddress),
305301
)
306302
case AddressTypeScriptKey, AddressTypeScriptScript, AddressTypeScriptPointer, AddressTypeScriptNone:
307-
tmpCred := &Credential{
308-
CredType: CredentialTypeScriptHash,
309-
Credential: NewBlake2b224(a.paymentAddress),
310-
}
311303
paymentPd = data.NewConstr(
312304
1,
313-
tmpCred.ToPlutusData(),
305+
data.NewByteString(a.paymentAddress),
314306
)
315307
default:
316308
return nil

ledger/common/address_test.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -339,13 +339,10 @@ func TestAddressToPlutusData(t *testing.T) {
339339
0,
340340
data.NewConstr(
341341
0,
342-
data.NewConstr(
343-
0,
344-
data.NewByteString(
345-
[]byte{
346-
0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
347-
},
348-
),
342+
data.NewByteString(
343+
[]byte{
344+
0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
345+
},
349346
),
350347
),
351348
data.NewConstr(

0 commit comments

Comments
 (0)