Skip to content

Commit

Permalink
Add 0.13.0 fields to core.Block
Browse files Browse the repository at this point in the history
  • Loading branch information
joshklop authored and omerfirmak committed Nov 22, 2023
1 parent d293e8e commit 60a2257
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
1 change: 1 addition & 0 deletions adapters/sn2core/sn2core.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func AdaptBlock(response *starknet.Block, sig *starknet.Signature) (*core.Block,
EventCount: eventCount,
EventsBloom: core.EventsBloom(receipts),
GasPrice: response.GasPriceETH(),
GasPriceSTRK: response.GasPriceSTRK,
Signatures: sigs,
},
Transactions: txns,
Expand Down
25 changes: 23 additions & 2 deletions adapters/sn2core/sn2core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,19 @@ func TestAdaptBlock(t *testing.T) {
protocolVersion string
network utils.Network
sig *starknet.Signature
gasPriceWEI *felt.Felt
gasPriceSTRK *felt.Felt
}{
{
number: 147,
network: utils.Mainnet,
number: 147,
network: utils.Mainnet,
gasPriceWEI: &felt.Zero,
},
{
number: 11817,
protocolVersion: "0.10.1",
network: utils.Mainnet,
gasPriceWEI: utils.HexToFelt(t, "0x27ad16775"),
},
{
number: 304740,
Expand All @@ -38,6 +42,20 @@ func TestAdaptBlock(t *testing.T) {
sig: &starknet.Signature{
Signature: []*felt.Felt{utils.HexToFelt(t, "0x44"), utils.HexToFelt(t, "0x37")},
},
gasPriceWEI: utils.HexToFelt(t, "0x3bb2acbc"),
},
{
number: 319132,
network: utils.Integration,
protocolVersion: "0.13.0",
sig: &starknet.Signature{
Signature: []*felt.Felt{
utils.HexToFelt(t, "0x71a9b2cd8a8a6a4ca284dcddcdefc6c4fd20b92c1b201bd9836e4ce376fad16"),
utils.HexToFelt(t, "0x6bef4745194c9447fdc8dd3aec4fc738ab0a560b0d2c7bf62fbf58aef3abfc5"),
},
},
gasPriceWEI: utils.HexToFelt(t, "0x3b9aca08"),
gasPriceSTRK: utils.HexToFelt(t, "0x2540be400"),
},
}

Expand Down Expand Up @@ -81,6 +99,9 @@ func TestAdaptBlock(t *testing.T) {
} else {
assert.Empty(t, block.Signatures)
}

assert.Equal(t, test.gasPriceSTRK, block.GasPriceSTRK)
assert.Equal(t, test.gasPriceWEI, block.GasPrice)
})
}
}
Expand Down
4 changes: 3 additions & 1 deletion core/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ type Header struct {
ExtraData *felt.Felt
// Bloom filter on the events emitted this block
EventsBloom *bloom.BloomFilter
// Amount of ETH charged per Gas spent
// Amount of WEI charged per Gas spent
GasPrice *felt.Felt
// Sequencer signatures
Signatures [][]*felt.Felt
// Amount of STRK charged per Gas spent
GasPriceSTRK *felt.Felt
}

type Block struct {
Expand Down

0 comments on commit 60a2257

Please sign in to comment.