Skip to content

Commit

Permalink
isAddressEqual returns boolean and not a set, getDestination fails wh…
Browse files Browse the repository at this point in the history
…en no account and no addressbook entry
  • Loading branch information
Ptroger committed Sep 9, 2024
1 parent eed77ac commit acf0672
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,39 @@ test_checkDestinationClassification_on_managed_Account {
"assignees": [],
}}}
}

test_checkDestinationClassification_on_no_addressbook_or_account {
req = {
"action": "signTransaction",
"principal": {
"userId": "test-antoine-user-uid",
"id": "0x6af10b6d5024963972ba832486ea1ae29f1b99cb1191abe444b52e98c69f7487",
"key": {
"kty": "EC",
"alg": "ES256K",
"kid": "0x6af10b6d5024963972ba832486ea1ae29f1b99cb1191abe444b52e98c69f7487",
"crv": "secp256k1",
"x": "QwUuAC2s22VKwoS5uPTZgcTN_ztkwt9VWKRae3bikEQ",
"y": "lZgwfE7ZDz9af9_PZxq9B7pVwAarfIaFESATYp-Q7Uk"
}
},
"intent": {
"to": "eip155:1:0x1afe44aca4abee6867385dcc7eb36ce4335b59c1",
"from": "eip155:1:0x0301e2724a40e934cce3345928b88956901aa127",
"type": "transferNative",
"amount": "1000000000000000000",
"token": "eip155:1/slip44:60"
},
"transactionRequest": {
"chainId": 1,
"from": "0x0301e2724a40e934cce3345928b88956901aa127",
"to": "0x1afe44aca4abee6867385dcc7eb36ce4335b59c1",
"value": "0xde0b6b3a7640000"
},
"resource": {
"uid": "eip155:eoa:0x0301e2724a40e934cce3345928b88956901aa127"
}
}

not checkDestinationClassification({"managed"}) with input as req with data.entities as entities
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ getDestination(intent) = entry {
not data.entities.addressBook[intent.to]

chainAccount = parseChainAccount(intent.to)
account = data.entities.accounts[_]
isAddressEqual(account.address, chainAccount.address)

chainId = _getChainId(account, chainAccount)
account = data.entities.accounts[_]
isAddressEqual(account.address, chainAccount.address) == true
chainId = _getChainId(account, chainAccount)

# INVARIANT: Every EOA Account is an implicity AddressBook on every chain
# which `classification` is always `managed`.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
package armory.util.eth

isAddressEqual(a, b) = {lower(a) == lower(b)}
isAddressEqual(a, b) = result {
lower_a := lower(a)
lower_b := lower(b)
result := (lower_a == lower_b)
}

0 comments on commit acf0672

Please sign in to comment.