Skip to content

Commit

Permalink
Add ResourceL1DataGas
Browse files Browse the repository at this point in the history
  • Loading branch information
AnkushinDaniil committed Jan 24, 2025
1 parent 61d810a commit f7494e1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rpc/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ type Resource uint32
const (
ResourceL1Gas Resource = iota + 1
ResourceL2Gas
ResourceL1DataGas
)

func (r Resource) MarshalText() ([]byte, error) {
Expand All @@ -172,6 +173,8 @@ func (r Resource) MarshalText() ([]byte, error) {
return []byte("l1_gas"), nil
case ResourceL2Gas:
return []byte("l2_gas"), nil
case ResourceL1DataGas:
return []byte("l1_data_gas"), nil

Check warning on line 177 in rpc/transaction.go

View check run for this annotation

Codecov / codecov/patch

rpc/transaction.go#L176-L177

Added lines #L176 - L177 were not covered by tests
default:
return nil, fmt.Errorf("unknown Resource %v", r)
}
Expand All @@ -183,6 +186,8 @@ func (r *Resource) UnmarshalJSON(data []byte) error {
*r = ResourceL1Gas
case `"l2_gas"`:
*r = ResourceL2Gas
case `"l1_data_gas"`:
*r = ResourceL1DataGas

Check warning on line 190 in rpc/transaction.go

View check run for this annotation

Codecov / codecov/patch

rpc/transaction.go#L189-L190

Added lines #L189 - L190 were not covered by tests
default:
return fmt.Errorf("unknown Resource: %q", string(data))
}
Expand Down
2 changes: 2 additions & 0 deletions starknet/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ func (r Resource) MarshalText() ([]byte, error) {
return []byte("L1_GAS"), nil
case ResourceL2Gas:
return []byte("L2_GAS"), nil
case ResourceL1DataGas:
return []byte("L1_DATA_GAS"), nil

Check warning on line 141 in starknet/transaction.go

View check run for this annotation

Codecov / codecov/patch

starknet/transaction.go#L140-L141

Added lines #L140 - L141 were not covered by tests
default:
return nil, errors.New("unknown resource")
}
Expand Down

0 comments on commit f7494e1

Please sign in to comment.