Skip to content

Commit

Permalink
adapt
Browse files Browse the repository at this point in the history
  • Loading branch information
rianhughes committed Aug 21, 2023
1 parent b8a1967 commit 08099b7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
6 changes: 4 additions & 2 deletions rpc/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -515,10 +515,12 @@ func TestCaptureUnsupportedBlockTxn(t *testing.T) {
_, okv1 := v.(InvokeTxnV1)
_, okv0 := v.(InvokeTxnV0)
_, okl1 := v.(L1HandlerTxn)
_, okdec := v.(DeclareTxnV1)
_, okdec0 := v.(DeclareTxnV0)
_, okdec1 := v.(DeclareTxnV1)
_, okdec2 := v.(DeclareTxnV2)
_, okdep := v.(DeployTxn)
_, okdepac := v.(DeployAccountTxn)
if !okv0 && !okv1 && !okl1 && !okdec && !okdep && !okdepac {
if !okv0 && !okv1 && !okl1 && !okdec0 && !okdec1 && !okdec2 && !okdep && !okdepac {
t.Fatalf("New Type Detected %T at Block(%d)/Txn(%d)", v, i, k)
}
}
Expand Down
21 changes: 18 additions & 3 deletions rpc/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,24 @@ func adaptTransaction(t TXN) (Transaction, error) {
json.Unmarshal(txMarshalled, &tx)
return tx, nil
case TransactionType_Declare:
var tx DeclareTxnV1
json.Unmarshal(txMarshalled, &tx)
return tx, nil

switch t.Version {
case &felt.Zero:
var tx DeclareTxnV0
json.Unmarshal(txMarshalled, &tx)
return tx, nil
case felt.Zero.SetUint64(1):
var tx DeclareTxnV1
json.Unmarshal(txMarshalled, &tx)
return tx, nil
case felt.Zero.SetUint64(2):
var tx DeclareTxnV2
json.Unmarshal(txMarshalled, &tx)
return tx, nil
default:
return nil, errors.New("Internal error with adaptTransaction()")
}

case TransactionType_DeployAccount:
var tx DeployAccountTxn
json.Unmarshal(txMarshalled, &tx)
Expand Down

0 comments on commit 08099b7

Please sign in to comment.