Skip to content

Commit

Permalink
Fix hyperlane natives
Browse files Browse the repository at this point in the history
Signed-off-by: Evgenii Akentev <[email protected]>
Change-Id: I8f09e97090ae3fbe32bbe0339414ef175d987800
  • Loading branch information
chessai authored and Evgenii Akentev committed Jun 7, 2024
1 parent 61b6135 commit 583d721
Show file tree
Hide file tree
Showing 15 changed files with 569 additions and 341 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ cabal.project.local*
/golden/lcov/actual
.DS_Store
.ghci_history
.direnv/
.envrc
20 changes: 16 additions & 4 deletions docs/en/pact-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ Return ID if called during current pact execution, failing if not.
Obtain current pact build version.
```lisp
pact> (pact-version)
"4.11"
"4.12"
```

Top level only: this function will fail if used in module code.
Expand Down Expand Up @@ -1874,20 +1874,32 @@ pact> (poseidon-hash-hack-a-chain 1 2 3 4 5 6 7 8)

Decode a base-64-unpadded encoded Hyperlane Token Message into an object `{recipient:GUARD, amount:DECIMAL, chainId:STRING}`.
```lisp
pact> (hyperlane-decode-token-message "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAewAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGF7InByZWQiOiAia2V5cy1hbGwiLCAia2V5cyI6WyJkYTFhMzM5YmQ4MmQyYzJlOTE4MDYyNmEwMGRjMDQzMjc1ZGViM2FiYWJiMjdiNTczOGFiZjZiOWRjZWU4ZGI2Il19AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
pact> (hyperlane-decode-token-message "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHsABHsicHJlZCI6ICJrZXlzLWFsbCIsICJrZXlzIjpbImRhMWEzMzliZDgyZDJjMmU5MTgwNjI2YTAwZGMwNDMyNzVkZWIzYWJhYmIyN2I1NzM4YWJmNmI5ZGNlZThkYjYiXX0")
{"amount": 0.000000000000000123,"chainId": "4","recipient": KeySet {keys: [da1a339bd82d2c2e9180626a00dc043275deb3ababb27b5738abf6b9dcee8db6],pred: keys-all}}
```


### hyperlane-encode-token-message {#hyperlane-encode-token-message}

*x*&nbsp;`string` *&rarr;*&nbsp;`object:*`


Encode an object into a base-64-unpadded encoded Hyperlane Token Message `AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHsABHsicHJlZCI6ICJrZXlzLWFsbCIsICJrZXlzIjpbImRhMWEzMzliZDgyZDJjMmU5MTgwNjI2YTAwZGMwNDMyNzVkZWIzYWJhYmIyN2I1NzM4YWJmNmI5ZGNlZThkYjYiXX0`.
```lisp
pact> (hyperlane-encode-token-message {"recipient": "eyJwcmVkIjogImtleXMtYWxsIiwgImtleXMiOlsiZGExYTMzOWJkODJkMmMyZTkxODA2MjZhMDBkYzA0MzI3NWRlYjNhYmFiYjI3YjU3MzhhYmY2YjlkY2VlOGRiNiJdfQ", "amount":123000000000000000.0, "chainId":"4"})
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAbT72StfgAAABHsicHJlZCI6ICJrZXlzLWFsbCIsICJrZXlzIjpbImRhMWEzMzliZDgyZDJjMmU5MTgwNjI2YTAwZGMwNDMyNzVkZWIzYWJhYmIyN2I1NzM4YWJmNmI5ZGNlZThkYjYiXX0"
```


### hyperlane-message-id {#hyperlane-message-id}

*x*&nbsp;`object:*` *&rarr;*&nbsp;`string`


Get the Message Id of a Hyperlane Message object.
```lisp
pact> (hyperlane-message-id {"destinationDomain": 1,"nonce": 325,"originDomain": 626,"recipient": "0x71C7656EC7ab88b098defB751B7401B5f6d8976F","sender": "0x6b622d746f6b656e2d726f75746572","tokenMessage": {"amount": 10000000000000000000.0,"recipient": "0x71C7656EC7ab88b098defB751B7401B5f6d8976F"},"version": 1})
"0x97d98aa7fdb548f43c9be37aaea33fca79680247eb8396148f1df10e6e0adfb7"
pact> (hyperlane-message-id {"destinationDomain": 1,"nonce": 325,"originDomain": 626,"recipient": "AAAAAAAAAADpgrOqkM0BOY-FQnNzkDXuYlsVcf50GRU","sender": "AAAAAAAAAAAAAAAAf6k4W-ECrD6sKXSD3WIz1is-FJY","messageBody": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHsABHsicHJlZCI6ICJrZXlzLWFsbCIsICJrZXlzIjpbImRhMWEzMzliZDgyZDJjMmU5MTgwNjI2YTAwZGMwNDMyNzVkZWIzYWJhYmIyN2I1NzM4YWJmNmI5ZGNlZThkYjYiXX0","version": 1})
"9lxextceVw0b18kUdfwSze-3Iw7OE-Z5Kq9I8HTDKGE"
```

## REPL-only functions {#repl-lib}
Expand Down
5 changes: 2 additions & 3 deletions golden/gas-model/golden
Original file line number Diff line number Diff line change
Expand Up @@ -611,9 +611,8 @@
"77076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c2a")
- 29
- - |-
(hyperlane-message-id {"destinationDomain": 1,"nonce": 325,"originDomain": 626,"recipient": "0x71C7656EC7ab88b098defB751B7401B5f6d8976F","sender": "0x6b622d746f6b656e2d726f75746572","tokenMessage": {"amount": 10000000000000000000.0,"recipient": "0x71C7656EC7ab88b098defB751B7401B5f6d8976F"},"version": 1})
(hyperlane-message-id {"destinationDomain": 1,"nonce": 325,"originDomain": 626,"recipient": "0x71C7656EC7ab88b098defB751B7401B5f6d8976F","sender": "0x6b622d746f6b656e2d726f75746572","tokenMessage": {"amount": 10000000000000000000.0,"recipient": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"},"version": 1})
- 4
(hyperlane-message-id {"destinationDomain": 1,"nonce": 325,"originDomain": 626,"recipient": "AAAAAAAAAADpgrOqkM0BOY-FQnNzkDXuYlsVcf50GRU","sender": "AAAAAAAAAAAAAAAAf6k4W-ECrD6sKXSD3WIz1is-FJY","messageBody": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHsABHsicHJlZCI6ICJrZXlzLWFsbCIsICJrZXlzIjpbImRhMWEzMzliZDgyZDJjMmU5MTgwNjI2YTAwZGMwNDMyNzVkZWIzYWJhYmIyN2I1NzM4YWJmNmI5ZGNlZThkYjYiXX0","version": 1})
- 2
- - (^ 2 longNumber)
- 4
- - (^ 2 medNumber)
Expand Down
4 changes: 3 additions & 1 deletion pact.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ library
exposed-modules:
Crypto.Hash.Blake2Native
Crypto.Hash.Keccak256Native
Crypto.Hash.HyperlaneMessageId
Crypto.Hash.HyperlaneNatives
Crypto.Hash.PoseidonNative
Pact.Analyze.Remote.Types
Pact.ApiReq
Expand Down Expand Up @@ -424,6 +424,7 @@ test-suite hspec
, base
, base16-bytestring
, base64-bytestring
, binary
, bound
, bytestring
, containers
Expand All @@ -443,6 +444,7 @@ test-suite hspec
, trifecta
, unordered-containers
, vector
, wide-word >= 0.1

other-modules:
Blake2Spec
Expand Down
170 changes: 0 additions & 170 deletions src/Crypto/Hash/HyperlaneMessageId.hs

This file was deleted.

Loading

0 comments on commit 583d721

Please sign in to comment.