Skip to content

Commit

Permalink
Merge pull request onflow#5024 from m-Peter/abi-encoding-decoding
Browse files Browse the repository at this point in the history
 Add `EVM` methods for `encodeABI` & `decodeABI`
  • Loading branch information
franklywatson authored Dec 13, 2023
2 parents 00b49e3 + 5b16ed6 commit ba6f0ff
Show file tree
Hide file tree
Showing 4 changed files with 2,292 additions and 10 deletions.
3 changes: 3 additions & 0 deletions fvm/environment/meter.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ const (
ComputationKindRLPEncoding = 2038
ComputationKindRLPDecoding = 2039
ComputationKindEncodeEvent = 2040
_ = 2041
ComputationKindEVMEncodeABI = 2042
ComputationKindEVMDecodeABI = 2042
)

type Meter interface {
Expand Down
10 changes: 10 additions & 0 deletions fvm/evm/stdlib/contract.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,14 @@ contract EVM {
fun run(tx: [UInt8], coinbase: EVMAddress) {
InternalEVM.run(tx: tx, coinbase: coinbase.bytes)
}

access(all)
fun encodeABI(_ values: [AnyStruct]): [UInt8] {
return InternalEVM.encodeABI(values)
}

access(all)
fun decodeABI(types: [Type], data: [UInt8]): [AnyStruct] {
return InternalEVM.decodeABI(types: types, data: data)
}
}
Loading

0 comments on commit ba6f0ff

Please sign in to comment.