Skip to content

Commit

Permalink
Merge pull request #103 from onflow/bastian/improve-evm-addresses
Browse files Browse the repository at this point in the history
Improve conversion of EVM addresses
  • Loading branch information
nialexsan authored Dec 3, 2024
2 parents 205f1dc + f3309aa commit bbdb1c5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
10 changes: 2 additions & 8 deletions cadence/scripts/evm/get_balance.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ import "EVM"
/// Returns the Flow balance of of a given EVM address in FlowEVM
///
access(all) fun main(address: String): UFix64 {
let bytes = address.decodeHex()
let addressBytes: [UInt8; 20] = [
bytes[0], bytes[1], bytes[2], bytes[3], bytes[4],
bytes[5], bytes[6], bytes[7], bytes[8], bytes[9],
bytes[10], bytes[11], bytes[12], bytes[13], bytes[14],
bytes[15], bytes[16], bytes[17], bytes[18], bytes[19]
]
return EVM.EVMAddress(bytes: addressBytes).balance().inFLOW()
let bytes = address.decodeHex().toConstantSized<[UInt8; 20]>()!
return EVM.EVMAddress(bytes: bytes).balance().inFLOW()
}
10 changes: 2 additions & 8 deletions components/FundAccountSubmitted.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,8 @@ export default function FundAccountSubmitted({
/// Returns the Flow balance of a given EVM address in FlowEVM
///
access(all) fun main(address: String): UFix64 {
let bytes = address.decodeHex()
let addressBytes: [UInt8; 20] = [
bytes[0], bytes[1], bytes[2], bytes[3], bytes[4],
bytes[5], bytes[6], bytes[7], bytes[8], bytes[9],
bytes[10], bytes[11], bytes[12], bytes[13], bytes[14],
bytes[15], bytes[16], bytes[17], bytes[18], bytes[19]
]
return EVM.EVMAddress(bytes: addressBytes).balance().inFLOW()
let bytes = address.decodeHex().toConstantSized<[UInt8; 20]>()!
return EVM.EVMAddress(bytes: bytes).balance().inFLOW()
}`
: `import FungibleToken from ${publicConfig.contractFungibleToken}
import FlowToken from ${publicConfig.contractFlowToken}
Expand Down

0 comments on commit bbdb1c5

Please sign in to comment.