Skip to content

Commit

Permalink
fix unmarshalling
Browse files Browse the repository at this point in the history
  • Loading branch information
joshklop committed Nov 15, 2023
1 parent f0157bd commit 9934285
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 39 deletions.
72 changes: 53 additions & 19 deletions adapters/sn2core/sn2core.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,21 +141,25 @@ func AdaptTransaction(transaction *starknet.Transaction) (core.Transaction, erro
txType := transaction.Type
switch txType {
case starknet.TxnDeclare:
return AdaptDeclareTransaction(transaction), nil
return AdaptDeclareTransaction(transaction)
case starknet.TxnDeploy:
return AdaptDeployTransaction(transaction), nil
case starknet.TxnInvoke:
return AdaptInvokeTransaction(transaction), nil
return AdaptInvokeTransaction(transaction)
case starknet.TxnDeployAccount:
return AdaptDeployAccountTransaction(transaction), nil
return AdaptDeployAccountTransaction(transaction)
case starknet.TxnL1Handler:
return AdaptL1HandlerTransaction(transaction), nil
default:
return nil, fmt.Errorf("unknown transaction type %q", txType)
}
}

func AdaptDeclareTransaction(t *starknet.Transaction) *core.DeclareTransaction {
func AdaptDeclareTransaction(t *starknet.Transaction) (*core.DeclareTransaction, error) {
resourceBounds, err := adaptResourceBounds(t.ResourceBounds)
if err != nil {
return nil, err
}
return &core.DeclareTransaction{
TransactionHash: t.Hash,
SenderAddress: t.SenderAddress,
Expand All @@ -165,24 +169,39 @@ func AdaptDeclareTransaction(t *starknet.Transaction) *core.DeclareTransaction {
Version: (*core.TransactionVersion)(t.Version),
ClassHash: t.ClassHash,
CompiledClassHash: t.CompiledClassHash,
ResourceBounds: adaptResourceBounds(t.ResourceBounds),
Tip: t.Tip,
ResourceBounds: resourceBounds,
Tip: safeFeltToUint64(t.Tip),
PaymasterData: t.PaymasterData,
AccountDeploymentData: t.AccountDeploymentData,
NonceDAMode: core.DataAvailabilityMode(t.NonceDAMode),
FeeDAMode: core.DataAvailabilityMode(t.FeeDAMode),
}
}, nil
}

func adaptResourceBounds(rb map[starknet.Resource]*starknet.ResourceBounds) map[core.Resource]*core.ResourceBounds {
func adaptResourceBounds(rb map[starknet.Resource]*starknet.ResourceBounds) (map[core.Resource]*core.ResourceBounds, error) {
coreBounds := make(map[core.Resource]*core.ResourceBounds, len(rb))
for resource, bounds := range rb {
coreBounds[core.Resource(resource)] = &core.ResourceBounds{
MaxAmount: bounds.MaxAmount,
coreResource, err := adaptResource(resource)
if err != nil {
return nil, err
}
coreBounds[coreResource] = &core.ResourceBounds{
MaxAmount: bounds.MaxAmount.Uint64(),
MaxPricePerUnit: bounds.MaxPricePerUnit,
}
}
return coreBounds
return coreBounds, nil
}

func adaptResource(resource starknet.Resource) (core.Resource, error) {
switch resource {
case starknet.ResourceL1Gas:
return core.ResourceL1Gas, nil
case starknet.ResourceL2Gas:
return core.ResourceL2Gas, nil
default:
return 0, fmt.Errorf("unknown starknet.Resource %s", resource)
}
}

func AdaptDeployTransaction(t *starknet.Transaction) *core.DeployTransaction {
Expand All @@ -199,7 +218,11 @@ func AdaptDeployTransaction(t *starknet.Transaction) *core.DeployTransaction {
}
}

func AdaptInvokeTransaction(t *starknet.Transaction) *core.InvokeTransaction {
func AdaptInvokeTransaction(t *starknet.Transaction) (*core.InvokeTransaction, error) {
resourceBounds, err := adaptResourceBounds(t.ResourceBounds)
if err != nil {
return nil, err
}
return &core.InvokeTransaction{
TransactionHash: t.Hash,
ContractAddress: t.ContractAddress,
Expand All @@ -210,13 +233,13 @@ func AdaptInvokeTransaction(t *starknet.Transaction) *core.InvokeTransaction {
MaxFee: t.MaxFee,
Version: (*core.TransactionVersion)(t.Version),
SenderAddress: t.SenderAddress,
ResourceBounds: adaptResourceBounds(t.ResourceBounds),
Tip: t.Tip,
ResourceBounds: resourceBounds,
Tip: safeFeltToUint64(t.Tip),
PaymasterData: t.PaymasterData,
AccountDeploymentData: t.AccountDeploymentData,
NonceDAMode: core.DataAvailabilityMode(t.NonceDAMode),
FeeDAMode: core.DataAvailabilityMode(t.FeeDAMode),
}
}, nil
}

func AdaptL1HandlerTransaction(t *starknet.Transaction) *core.L1HandlerTransaction {
Expand All @@ -230,19 +253,23 @@ func AdaptL1HandlerTransaction(t *starknet.Transaction) *core.L1HandlerTransacti
}
}

func AdaptDeployAccountTransaction(t *starknet.Transaction) *core.DeployAccountTransaction {
func AdaptDeployAccountTransaction(t *starknet.Transaction) (*core.DeployAccountTransaction, error) {
resourceBounds, err := adaptResourceBounds(t.ResourceBounds)
if err != nil {
return nil, err
}
return &core.DeployAccountTransaction{
DeployTransaction: *AdaptDeployTransaction(t),
MaxFee: t.MaxFee,
TransactionSignature: *t.Signature,
Nonce: t.Nonce,
ResourceBounds: adaptResourceBounds(t.ResourceBounds),
Tip: t.Tip,
ResourceBounds: resourceBounds,
Tip: safeFeltToUint64(t.Tip),
PaymasterData: t.PaymasterData,
AccountDeploymentData: t.AccountDeploymentData,
NonceDAMode: core.DataAvailabilityMode(t.NonceDAMode),
FeeDAMode: core.DataAvailabilityMode(t.FeeDAMode),
}
}, nil
}

func AdaptCairo1Class(response *starknet.SierraDefinition, compiledClass json.RawMessage) (core.Class, error) {
Expand Down Expand Up @@ -368,3 +395,10 @@ func AdaptStateUpdate(response *starknet.StateUpdate) (*core.StateUpdate, error)
StateDiff: stateDiff,
}, nil
}

func safeFeltToUint64(f *felt.Felt) uint64 {
if f != nil {
return f.Uint64()
}
return 0
}
1 change: 1 addition & 0 deletions clients/feeder/testdata/integration/block/319132.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"block_hash": "0x50e864db6b81ce69fbeb70e6a7284ee2febbb9a2e707415de7adab83525e9cd", "parent_block_hash": "0x39dfc381180356734085e2d70b640e153c241c7f65936cacbdff9fad84bbc0c", "block_number": 319132, "state_root": "0x2a6b9a8b60e1de80dc50e6b704b415a38e8fd03d82244cec92cbff0821a8975", "status": "ACCEPTED_ON_L2", "eth_l1_gas_price": "0x3b9aca08", "strk_l1_gas_price": "0x2540be400", "transactions": [{"transaction_hash": "0x49728601e0bb2f48ce506b0cbd9c0e2a9e50d95858aa41463f46386dca489fd", "version": "0x3", "signature": ["0x71a9b2cd8a8a6a4ca284dcddcdefc6c4fd20b92c1b201bd9836e4ce376fad16", "0x6bef4745194c9447fdc8dd3aec4fc738ab0a560b0d2c7bf62fbf58aef3abfc5"], "nonce": "0xe97", "nonce_data_availability_mode": 0, "fee_data_availability_mode": 0, "resource_bounds": {"L1_GAS": {"max_amount": "0x186a0", "max_price_per_unit": "0x5af3107a4000"}, "L2_GAS": {"max_amount": "0x0", "max_price_per_unit": "0x0"}}, "tip": "0x0", "paymaster_data": [], "sender_address": "0x3f6f3bc663aedc5285d6013cc3ffcbc4341d86ab488b8b68d297f8258793c41", "calldata": ["0x2", "0x450703c32370cf7ffff540b9352e7ee4ad583af143a361155f2b485c0c39684", "0x27c3334165536f239cfd400ed956eabff55fc60de4fb56728b6a4f6b87db01c", "0x0", "0x4", "0x4c312760dfd17a954cdd09e76aa9f149f806d88ec3e402ffaf5c4926f568a42", "0x5df99ae77df976b4f0e5cf28c7dcfe09bd6e81aab787b19ac0c08e03d928cf", "0x4", "0x1", "0x5", "0x450703c32370cf7ffff540b9352e7ee4ad583af143a361155f2b485c0c39684", "0x5df99ae77df976b4f0e5cf28c7dcfe09bd6e81aab787b19ac0c08e03d928cf", "0x1", "0x7fe4fd616c7fece1244b3616bb516562e230be8c9f29668b46ce0369d5ca829", "0x287acddb27a2f9ba7f2612d72788dc96a5b30e401fc1e8072250940e024a587"], "account_deployment_data": [], "type": "INVOKE_FUNCTION"}, {"transaction_hash": "0x1ed0488e089f425c852b499b4fe5618db3b61d4f09e214c5b507df665093daa", "version": "0x3", "signature": ["0x1d6d8879d5b4f294fe3063915778c0b8c0612fadd212fbeeb4423fedd968c38", "0x7c091a97d36732ebb17b400545cda41131e9d1c08f1735585fe7de4002701ed"], "nonce": "0xe98", "nonce_data_availability_mode": 0, "fee_data_availability_mode": 0, "resource_bounds": {"L1_GAS": {"max_amount": "0x186a0", "max_price_per_unit": "0x5af3107a4000"}, "L2_GAS": {"max_amount": "0x0", "max_price_per_unit": "0x0"}}, "tip": "0x0", "paymaster_data": [], "sender_address": "0x3f6f3bc663aedc5285d6013cc3ffcbc4341d86ab488b8b68d297f8258793c41", "calldata": ["0x1", "0x6f42ff7606b801c5992636cf56ac4bffca73c4bebb5c8299331cbb8ec829eff", "0x3d7905601c217734671143d457f0db37f7f8883112abd34b92c4abfeafde0c3", "0x0", "0x2", "0x2", "0xc6d810831f3cc914995947b8324169ac15e9c462e614158f44117aaa9dcbf3", "0x524da13cb757a5b6f3df415b71bdf311dbdf7e933622d5bd050c6c3d92399c"], "account_deployment_data": [], "type": "INVOKE_FUNCTION"}, {"transaction_hash": "0xbd569e4ba3e87faf0e974ed8e852832aef749ce01b37cd738c59318cc8cc6c", "version": "0x1", "max_fee": "0x2386f26fc10000", "signature": ["0x4e2e7bcf3fd3ba954924fe9e8dcb82939bf73d4a39d39148c7354d46bd6d14b", "0x733b0a9d9a9cc3a5ca48aabcaad5446a0b46eefe2c19f0b5c13a368e4daa219"], "nonce": "0xe99", "sender_address": "0x3f6f3bc663aedc5285d6013cc3ffcbc4341d86ab488b8b68d297f8258793c41", "calldata": ["0x2", "0x450703c32370cf7ffff540b9352e7ee4ad583af143a361155f2b485c0c39684", "0x31aafc75f498fdfa7528880ad27246b4c15af4954f96228c9a132b328de1c92", "0x0", "0x6", "0x4c312760dfd17a954cdd09e76aa9f149f806d88ec3e402ffaf5c4926f568a42", "0x1072fa630c537b7c9577ccb2aacb2803600d02266543fab0cc18f238708e198", "0x6", "0x1", "0x7", "0x3e35591c079a109c6e6379b022ee894d5e21520a7f9cba1fcecc93c765f46f8", "0x3", "0x27511bb4f26888b54df6144419f47e4e231f2ad88f7a742f0850242e69f4fcb", "0x11b0e41cad19e4853c927261009f31f8864d678e0b5fc090389a226ad0cf4ca", "0x1862f5ecd223f7ba164b76a17c09d5e8836c186b99cb846bdd022cbe6bf58b4", "0x711537138b22bf083eebdc6913147aa868f36c10c9606fd8df12ea34d32c619", "0x1072fa630c537b7c9577ccb2aacb2803600d02266543fab0cc18f238708e198"], "type": "INVOKE_FUNCTION"}, {"transaction_hash": "0x392f68b1de3836ef99d55d155c2d4186c5bf15420b0ee07ff1fec61674a934", "version": "0x3", "signature": ["0x334fc1b5c3a1523ec257460320b2155d24cefa5e0dec6c859036b82619fbfce", "0xf5f6f721726844f37215e4cd33409d38bcb9e4fe340b23502b3b96236aee22"], "nonce": "0xe9a", "nonce_data_availability_mode": 0, "fee_data_availability_mode": 0, "resource_bounds": {"L1_GAS": {"max_amount": "0x186a0", "max_price_per_unit": "0x5af3107a4000"}, "L2_GAS": {"max_amount": "0x0", "max_price_per_unit": "0x0"}}, "tip": "0x0", "paymaster_data": [], "sender_address": "0x3f6f3bc663aedc5285d6013cc3ffcbc4341d86ab488b8b68d297f8258793c41", "calldata": ["0x2", "0x4c312760dfd17a954cdd09e76aa9f149f806d88ec3e402ffaf5c4926f568a42", "0x2468d193cd15b621b24c2a602b8dbcfa5eaa14f88416c40c09d7fd12592cb4b", "0x0", "0x0", "0x32f69988b7dbe2aef8cdcb34bff3e92a9404b6ec5082bb0e84c9dd3dc9747af", "0x169f135eddda5ab51886052d777a57f2ea9c162d713691b5e04a6d4ed71d47f", "0x0", "0x5", "0x5", "0x5b67559ce75456074bad84f9062da210de91650127d6a3a630afc880c753b45", "0x2036d88af19b1818d56a2ccb7b80a47e4d378f9107be75a6d8c61e9f209989b", "0x2", "0x4067eddfcdc5afc0a2b500fb2a4f6dbb5ca862daebc1e22a2c717e1f25b4b6e", "0x45ed06b10d0cc8527dc0cf013d13d538af502979431cec77ff16def4f1e3bb1"], "account_deployment_data": [], "type": "INVOKE_FUNCTION"}], "timestamp": 1700075354, "sequencer_address": "0x1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8", "transaction_receipts": [{"execution_status": "SUCCEEDED", "transaction_index": 0, "transaction_hash": "0x49728601e0bb2f48ce506b0cbd9c0e2a9e50d95858aa41463f46386dca489fd", "l2_to_l1_messages": [], "events": [{"from_address": "0x4718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d", "keys": ["0x99cd8bde557814842a3121e8ddfd433a539b8c9f14bf31ebf108d12e6196e9"], "data": ["0x3f6f3bc663aedc5285d6013cc3ffcbc4341d86ab488b8b68d297f8258793c41", "0x1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8", "0x16d8b4ad4000", "0x0"]}, {"from_address": "0x4718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d", "keys": ["0xa9fa878c35cd3d0191318f89033ca3e5501a3d90e21e3cc9256bdd5cd17fdd"], "data": ["0x1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8", "0x18ad8494375bc00", "0x0", "0x18aef21f822fc00", "0x0"]}], "execution_resources": {"n_steps": 615, "builtin_instance_counter": {"range_check_builtin": 19}, "n_memory_holes": 4}, "actual_fee": "0x16d8b4ad4000"}, {"execution_status": "SUCCEEDED", "transaction_index": 1, "transaction_hash": "0x1ed0488e089f425c852b499b4fe5618db3b61d4f09e214c5b507df665093daa", "l2_to_l1_messages": [], "events": [{"from_address": "0x4718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d", "keys": ["0x99cd8bde557814842a3121e8ddfd433a539b8c9f14bf31ebf108d12e6196e9"], "data": ["0x3f6f3bc663aedc5285d6013cc3ffcbc4341d86ab488b8b68d297f8258793c41", "0x1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8", "0x2cf27d8b7800", "0x0"]}, {"from_address": "0x4718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d", "keys": ["0xa9fa878c35cd3d0191318f89033ca3e5501a3d90e21e3cc9256bdd5cd17fdd"], "data": ["0x1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8", "0x18aef21f822fc00", "0x0", "0x18b1c1475ae7400", "0x0"]}], "execution_resources": {"n_steps": 167, "builtin_instance_counter": {"range_check_builtin": 2}, "n_memory_holes": 3}, "actual_fee": "0x2cf27d8b7800"}, {"execution_status": "SUCCEEDED", "transaction_index": 2, "transaction_hash": "0xbd569e4ba3e87faf0e974ed8e852832aef749ce01b37cd738c59318cc8cc6c", "l2_to_l1_messages": [], "events": [{"from_address": "0x450703c32370cf7ffff540b9352e7ee4ad583af143a361155f2b485c0c39684", "keys": ["0x15bd0500dc9d7e69ab9577f73a8d753e8761bed10f25ba0f124254dc4edb8b4"], "data": ["0x3e35591c079a109c6e6379b022ee894d5e21520a7f9cba1fcecc93c765f46f8", "0x3", "0x27511bb4f26888b54df6144419f47e4e231f2ad88f7a742f0850242e69f4fcb", "0x11b0e41cad19e4853c927261009f31f8864d678e0b5fc090389a226ad0cf4ca", "0x1862f5ecd223f7ba164b76a17c09d5e8836c186b99cb846bdd022cbe6bf58b4"]}], "execution_resources": {"n_steps": 835, "builtin_instance_counter": {"range_check_builtin": 14}, "n_memory_holes": 5}, "actual_fee": "0x247b4d87c58"}, {"execution_status": "SUCCEEDED", "transaction_index": 3, "transaction_hash": "0x392f68b1de3836ef99d55d155c2d4186c5bf15420b0ee07ff1fec61674a934", "l2_to_l1_messages": [], "events": [{"from_address": "0x4718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d", "keys": ["0x99cd8bde557814842a3121e8ddfd433a539b8c9f14bf31ebf108d12e6196e9"], "data": ["0x3f6f3bc663aedc5285d6013cc3ffcbc4341d86ab488b8b68d297f8258793c41", "0x1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8", "0x32ad52ce9000", "0x0"]}, {"from_address": "0x4718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d", "keys": ["0xa9fa878c35cd3d0191318f89033ca3e5501a3d90e21e3cc9256bdd5cd17fdd"], "data": ["0x1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8", "0x18b1c1475ae7400", "0x0", "0x18b4ec1c87d0400", "0x0"]}], "execution_resources": {"n_steps": 333, "builtin_instance_counter": {"poseidon_builtin": 1, "range_check_builtin": 5}, "n_memory_holes": 7}, "actual_fee": "0x32ad52ce9000"}], "starknet_version": "0.13.0"}
27 changes: 27 additions & 0 deletions starknet/block_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package starknet_test

import (
"context"
"testing"

"github.com/NethermindEth/juno/clients/feeder"
"github.com/NethermindEth/juno/utils"
"github.com/stretchr/testify/require"
)

func TestUnmarshalV013BlockHeader(t *testing.T) {
client := feeder.NewTestClient(t, utils.INTEGRATION)
block, err := client.Block(context.Background(), "319132")
require.NoError(t, err)

require.Equal(t, utils.HexToFelt(t, "0x50e864db6b81ce69fbeb70e6a7284ee2febbb9a2e707415de7adab83525e9cd"), block.Hash)
require.Equal(t, utils.HexToFelt(t, "0x39dfc381180356734085e2d70b640e153c241c7f65936cacbdff9fad84bbc0c"), block.ParentHash)
require.Equal(t, uint64(319132), block.Number)
require.Equal(t, utils.HexToFelt(t, "0x2a6b9a8b60e1de80dc50e6b704b415a38e8fd03d82244cec92cbff0821a8975"), block.StateRoot)
require.Equal(t, "ACCEPTED_ON_L2", block.Status)
require.Equal(t, utils.HexToFelt(t, "0x3b9aca08"), block.GasPrice())
require.Equal(t, utils.HexToFelt(t, "0x2540be400"), block.GasPriceSTRK)
require.Equal(t, uint64(1700075354), block.Timestamp)
require.Equal(t, utils.HexToFelt(t, "0x1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8"), block.SequencerAddress)
require.Equal(t, "0.13.0", block.Version)
}
22 changes: 5 additions & 17 deletions starknet/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,25 +104,13 @@ func (t *TransactionType) UnmarshalJSON(data []byte) error {
return nil
}

type Resource uint32
type Resource string

const (
ResourceL1Gas Resource = iota + 1
ResourceL2Gas
ResourceL1Gas Resource = "L1_GAS"
ResourceL2Gas Resource = "L2_GAS"
)

func (r *Resource) UnmarshalJSON(data []byte) error {
switch string(data) {
case `"L1_GAS"`:
*r = ResourceL1Gas
case `"L2_GAS"`:
*r = ResourceL2Gas
default:
return fmt.Errorf("unknown resource: %s", string(data))
}
return nil
}

type DataAvailabilityMode uint32

const (
Expand All @@ -131,7 +119,7 @@ const (
)

type ResourceBounds struct {
MaxAmount uint64 `json:"max_amount"`
MaxAmount *felt.Felt `json:"max_amount"`
MaxPricePerUnit *felt.Felt `json:"max_price_per_unit"`
}

Expand All @@ -152,7 +140,7 @@ type Transaction struct {
Nonce *felt.Felt `json:"nonce,omitempty"`
CompiledClassHash *felt.Felt `json:"compiled_class_hash,omitempty"`
ResourceBounds map[Resource]*ResourceBounds `json:"resource_bounds,omitempty"`
Tip uint64 `json:"tip,omitempty"`
Tip *felt.Felt `json:"tip,omitempty"`
NonceDAMode DataAvailabilityMode `json:"nonce_data_availability_mode,omitempty"`
FeeDAMode DataAvailabilityMode `json:"fee_data_availability_mode,omitempty"`
AccountDeploymentData []*felt.Felt `json:"account_deployment_data,omitempty"`
Expand Down
15 changes: 12 additions & 3 deletions starknetdata/feeder/feeder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ func TestTransaction(t *testing.T) {

ctx := context.Background()

//nolint:dupl
t.Run("invoke transaction", func(t *testing.T) {
hash := utils.HexToFelt(t, "0x7e3a229febf47c6edfd96582d9476dd91a58a5ba3df4553ae448a14a2f132d9")
response, err := clientGoerli.Transaction(ctx, hash)
Expand All @@ -119,7 +120,9 @@ func TestTransaction(t *testing.T) {
require.NoError(t, err)
invokeTx, ok := txn.(*core.InvokeTransaction)
require.True(t, ok)
assert.Equal(t, sn2core.AdaptInvokeTransaction(responseTx), invokeTx)
tx, err := sn2core.AdaptInvokeTransaction(responseTx)
require.NoError(t, err)
assert.Equal(t, tx, invokeTx)
})

t.Run("deploy transaction", func(t *testing.T) {
Expand All @@ -135,6 +138,7 @@ func TestTransaction(t *testing.T) {
assert.Equal(t, sn2core.AdaptDeployTransaction(responseTx), deployTx)
})

//nolint:dupl
t.Run("deploy account transaction", func(t *testing.T) {
hash := utils.HexToFelt(t, "0xd61fc89f4d1dc4dc90a014957d655d38abffd47ecea8e3fa762e3160f155f2")
response, err := clientMainnet.Transaction(ctx, hash)
Expand All @@ -145,9 +149,12 @@ func TestTransaction(t *testing.T) {
require.NoError(t, err)
deployAccountTx, ok := txn.(*core.DeployAccountTransaction)
require.True(t, ok)
assert.Equal(t, sn2core.AdaptDeployAccountTransaction(responseTx), deployAccountTx)
responseTxn, err := sn2core.AdaptDeployAccountTransaction(responseTx)
require.NoError(t, err)
assert.Equal(t, responseTxn, deployAccountTx)
})

//nolint:dupl
t.Run("declare transaction", func(t *testing.T) {
hash := utils.HexToFelt(t, "0x6eab8252abfc9bbfd72c8d592dde4018d07ce467c5ce922519d7142fcab203f")
response, err := clientGoerli.Transaction(ctx, hash)
Expand All @@ -158,7 +165,9 @@ func TestTransaction(t *testing.T) {
require.NoError(t, err)
declareTx, ok := txn.(*core.DeclareTransaction)
require.True(t, ok)
assert.Equal(t, sn2core.AdaptDeclareTransaction(responseTx), declareTx)
responseTxn, err := sn2core.AdaptDeclareTransaction(responseTx)
require.NoError(t, err)
assert.Equal(t, responseTxn, declareTx)
})

t.Run("l1handler transaction", func(t *testing.T) {
Expand Down

0 comments on commit 9934285

Please sign in to comment.