Skip to content

Commit

Permalink
Add hyperlane-encode-token-message native
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgenii Akentev committed May 7, 2024
1 parent c6efe69 commit 8240f2e
Show file tree
Hide file tree
Showing 10 changed files with 131 additions and 45 deletions.
15 changes: 13 additions & 2 deletions docs/en/pact-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -1846,6 +1846,17 @@ pact> (hyperlane-decode-token-message "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
{"amount": 0.000000000000000123,"chainId": "4","recipient": KeySet {keys: [da1a339bd82d2c2e9180626a00dc043275deb3ababb27b5738abf6b9dcee8db6],pred: keys-all}}
```

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

*x* `object:*` *→* `string`


Encode an Hyperlane Token Message object `{recipient:GUARD, amount:DECIMAL, chainId:STRING}` into a base-64-unpadded string.
```lisp
pact> (hyperlane-encode-token-message {"amount": 599.0,"chainId": "1","recipient": "{\"pred\": \"keys-all\", \"keys\":[\"da1a339bd82d2c2e9180626a00dc043275deb3ababb27b5738abf6b9dcee8db6\"]}"})
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACB4y35cqvwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGF7InByZWQiOiAia2V5cy1hbGwiLCAia2V5cyI6WyJkYTFhMzM5YmQ4MmQyYzJlOTE4MDYyNmEwMGRjMDQzMjc1ZGViM2FiYWJiMjdiNTczOGFiZjZiOWRjZWU4ZGI2Il19AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
```


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

Expand All @@ -1854,8 +1865,8 @@ pact> (hyperlane-decode-token-message "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

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": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAewAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGF7InByZWQiOiAia2V5cy1hbGwiLCAia2V5cyI6WyJkYTFhMzM5YmQ4MmQyYzJlOTE4MDYyNmEwMGRjMDQzMjc1ZGViM2FiYWJiMjdiNTczOGFiZjZiOWRjZWU4ZGI2Il19AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA","version": 1})
"0x3cbd30e222a483f3ad52191674b2f6951adb88636553d10f69a4a002ffd6c8d4"
```

## REPL-only functions {#repl-lib}
Expand Down
4 changes: 2 additions & 2 deletions golden/gas-model/golden
Original file line number Diff line number Diff line change
Expand Up @@ -605,8 +605,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})
(hyperlane-message-id {"destinationDomain": 1,"nonce": 325,"originDomain": 626,"recipient": "AAAAAAAAAADpgrOqkM0BOY-FQnNzkDXuYlsVcf50GRU","sender": "AAAAAAAAAAAAAAAAf6k4W-ECrD6sKXSD3WIz1is-FJY","messageBody": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAewAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGF7InByZWQiOiAia2V5cy1hbGwiLCAia2V5cyI6WyJkYTFhMzM5YmQ4MmQyYzJlOTE4MDYyNmEwMGRjMDQzMjc1ZGViM2FiYWJiMjdiNTczOGFiZjZiOWRjZWU4ZGI2Il19AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA","version": 1})
(hyperlane-message-id {"destinationDomain": 1,"nonce": 325,"originDomain": 626,"recipient": "AAAAAAAAAADpgrOqkM0BOY-FQnNzkDXuYlsVcf50GRU","sender": "AAAAAAAAAAAAAAAAf6k4W-ECrD6sKXSD3WIz1is-FJY","messageBody": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAewAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGF7InByZWQiOiAia2V5cy1hbGwiLCAia2V5cyI6WyJkYTFhMzM5YmQ4MmQyYzJlOTE4MDYyNmEwMGRjMDQzMjc1ZGViM2FiYWJiMjdiNTczOGFiZjZiOWRjZWU4ZGI2Il19AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAewAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGF7InByZWQiOiAia2V5cy1hbGwiLCAia2V5cyI6WyJkYTFhMzM5YmQ4MmQyYzJlOTE4MDYyNmEwMGRjMDQzMjc1ZGViM2FiYWJiMjdiNTczOGFiZjZiOWRjZWU4ZGI2Il19AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAewAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGF7InByZWQiOiAia2V5cy1hbGwiLCAia2V5cyI6WyJkYTFhMzM5YmQ4MmQyYzJlOTE4MDYyNmEwMGRjMDQzMjc1ZGViM2FiYWJiMjdiNTczOGFiZjZiOWRjZWU4ZGI2Il19AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA","version": 1})
- 4
- - (^ 2 longNumber)
- 4
Expand Down
102 changes: 67 additions & 35 deletions src/Crypto/Hash/HyperlaneNatives.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module Crypto.Hash.HyperlaneNatives
-- Implementation of natives
, hyperlaneMessageId
, hyperlaneDecodeTokenMessage
, hyperlaneEncodeTokenMessage
) where

import Control.Lens ((^?), at, _Just, Prism', _1)
Expand All @@ -30,6 +31,7 @@ import Control.Monad.Except (throwError)
import Data.Bifunctor (first)
import Data.Binary.Get (Get)
import Data.Binary.Get qualified as Bin
import Data.Binary.Put qualified as Bin
import Data.ByteString (ByteString)
import Data.ByteString qualified as BS
import Data.ByteString.Base16 qualified as Base16

Check warning on line 37 in src/Crypto/Hash/HyperlaneNatives.hs

View workflow job for this annotation

GitHub Actions / build (9.6, 3.10, ubuntu-20.04, true, +build-tool)

The qualified import of ‘Data.ByteString.Base16’ is redundant

Check warning on line 37 in src/Crypto/Hash/HyperlaneNatives.hs

View workflow job for this annotation

GitHub Actions / build (9.6, 3.10, ubuntu-22.04, true, +build-tool)

The qualified import of ‘Data.ByteString.Base16’ is redundant

Check warning on line 37 in src/Crypto/Hash/HyperlaneNatives.hs

View workflow job for this annotation

GitHub Actions / build (9.6, 3.10, macOS-latest, true, +build-tool)

The qualified import of ‘Data.ByteString.Base16’ is redundant

Check warning on line 37 in src/Crypto/Hash/HyperlaneNatives.hs

View workflow job for this annotation

GitHub Actions / build (9.6, 3.10, macos-14, true, +build-tool)

The qualified import of ‘Data.ByteString.Base16’ is redundant

Check warning on line 37 in src/Crypto/Hash/HyperlaneNatives.hs

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04, 9.6, 3.10, true, -build-tool)

The qualified import of ‘Data.ByteString.Base16’ is redundant
Expand All @@ -45,24 +47,25 @@ import Data.Ratio ((%))
import Data.Text (Text)
import Data.Text qualified as Text
import Data.Text.Encoding qualified as Text
import Data.Text.Read qualified as Text
import Data.WideWord.Word256 (Word256(..))
import Data.Word (Word8, Word32)
import Ethereum.Misc (keccak256, _getKeccak256Hash, _getBytesN)
import Pact.JSON.Decode qualified as J
import Pact.Types.Exp (Literal(..))
import Pact.Types.PactValue (PactValue(PGuard), fromPactValue)
import Pact.Types.Pretty (Doc, pretty)
import Pact.Types.Runtime (Object(..), ObjectMap(..), FieldKey, Name, Type(TyAny), _TLiteral, _LInteger, _LString, toTObject, ChainId(..))
import Pact.Types.Runtime (Object(..), ObjectMap(..), FieldKey, Name, Type(TyAny), _TLiteral, _LInteger, _LString, toTObject, ChainId(..), _LDecimal)
import Pact.Types.Term (Term(..), toTerm)
import Pact.Types.Util (decodeBase64UrlUnpadded)
import Pact.Types.Util (decodeBase64UrlUnpadded, encodeBase64UrlUnpadded)

----------------------------------------------
-- Primitives --
----------------------------------------------

hyperlaneMessageId :: Object Name -> Either Doc Text
hyperlaneMessageId o = do
hm <- first displayHyperlaneMessageIdError $ decodeHyperlaneMessageObject o
hm <- first displayHyperlaneError $ decodeHyperlaneMessageObject o
pure $ getHyperlaneMessageId hm

-- | Decode a hyperlane 'TokenMessageERC20'
Expand All @@ -85,34 +88,42 @@ hyperlaneDecodeTokenMessage i = do
pure tm
tokenMessageToTerm tm

hyperlaneEncodeTokenMessage :: Object Name -> Either Doc Text
hyperlaneEncodeTokenMessage o = do
tm <- first displayHyperlaneError $ decodeHyperlaneTokenMessageObject o
let encoded = Text.decodeUtf8 $ encodeBase64UrlUnpadded $ BL.toStrict $ Bin.runPut $ Bin.putBuilder $ packTokenMessageERC20 tm
return encoded

----------------------------------------------
-- Error Types --
----------------------------------------------

data HyperlaneMessageIdError
= HyperlaneMessageIdErrorFailedToFindKey FieldKey
data HyperlaneError
= HyperlaneErrorFailedToFindKey FieldKey
-- ^ An expected key was not found.
| HyperlaneMessageIdErrorNumberOutOfBounds FieldKey
| HyperlaneErrorNumberOutOfBounds FieldKey
-- ^ The number at this field was outside of the expected bounds of its
-- type.
| HyperlaneMessageIdErrorBadHexPrefix FieldKey
| HyperlaneErrorBadHexPrefix FieldKey
-- ^ Hex textual fields (usually ETH addresses) must be prefixed with "0x"
| HyperlaneMessageIdErrorInvalidHex FieldKey
| HyperlaneErrorInvalidHex FieldKey
-- ^ Invalid Hex. We discard error messages from base16-bytestring to
| HyperlaneMessageIdInvalidBase64 FieldKey
| HyperlaneErrorInvalidBase64 FieldKey
-- ^ Invalid base64 text field.
| HyperlaneMessageIdIncorrectSize FieldKey Int Int
| HyperlaneErrorIncorrectSize FieldKey Int Int
-- ^ Invalid Hex. We discard error messages from base16-bytestring to

displayHyperlaneMessageIdError :: HyperlaneMessageIdError -> Doc
displayHyperlaneMessageIdError = \case
HyperlaneMessageIdErrorFailedToFindKey key -> "Failed to find key in object: " <> pretty key
HyperlaneMessageIdErrorNumberOutOfBounds key -> "Object key " <> pretty key <> " was out of bounds"
HyperlaneMessageIdErrorBadHexPrefix key -> "Missing 0x prefix on field " <> pretty key
HyperlaneMessageIdErrorInvalidHex key -> "Invalid hex encoding on field " <> pretty key
HyperlaneMessageIdInvalidBase64 key -> "Invalid base64 encoding on field " <> pretty key
HyperlaneMessageIdIncorrectSize key expected actual ->
| HyperlaneErrorInvalidChainId Text

displayHyperlaneError :: HyperlaneError -> Doc
displayHyperlaneError = \case
HyperlaneErrorFailedToFindKey key -> "Failed to find key in object: " <> pretty key
HyperlaneErrorNumberOutOfBounds key -> "Object key " <> pretty key <> " was out of bounds"
HyperlaneErrorBadHexPrefix key -> "Missing 0x prefix on field " <> pretty key
HyperlaneErrorInvalidHex key -> "Invalid hex encoding on field " <> pretty key
HyperlaneErrorInvalidBase64 key -> "Invalid base64 encoding on field " <> pretty key
HyperlaneErrorIncorrectSize key expected actual ->
"Incorrect binary data size " <> pretty key <> ". Expected: " <> pretty expected <> ", but got " <> pretty actual
HyperlaneErrorInvalidChainId msg -> "Failed to decode chainId: " <> pretty msg

data HyperlaneDecodeError
= HyperlaneDecodeErrorBase64
Expand Down Expand Up @@ -244,7 +255,8 @@ unpackTokenMessageERC20 = do

getHyperlaneMessageId :: HyperlaneMessage -> Text
getHyperlaneMessageId =
encodeHex
Text.decodeUtf8
. encodeBase64UrlUnpadded
. keccak256Hash
. BL.toStrict
. BB.toLazyByteString
Expand All @@ -253,27 +265,30 @@ getHyperlaneMessageId =
keccak256Hash :: ByteString -> ByteString
keccak256Hash = BSS.fromShort . _getBytesN . _getKeccak256Hash . keccak256

encodeHex :: ByteString -> Text
encodeHex b = "0x" <> Text.decodeUtf8 (Base16.encode b)

decodeBase64 :: FieldKey -> Text -> Either HyperlaneMessageIdError ByteString
decodeBase64 :: FieldKey -> Text -> Either HyperlaneError ByteString
decodeBase64 key s =
first (const $ HyperlaneMessageIdInvalidBase64 key) $ decodeBase64UrlUnpadded $ Text.encodeUtf8 s
first (const $ HyperlaneErrorInvalidBase64 key) $ decodeBase64UrlUnpadded $ Text.encodeUtf8 s

decodeBase64AndValidate :: FieldKey -> Int -> Text -> Either HyperlaneMessageIdError ByteString
decodeBase64AndValidate :: FieldKey -> Int -> Text -> Either HyperlaneError ByteString
decodeBase64AndValidate key expected s = do
decoded <- decodeBase64 key s

unless (BS.length decoded == expected) $
throwError $ HyperlaneMessageIdIncorrectSize key expected (BS.length decoded)
throwError $ HyperlaneErrorIncorrectSize key expected (BS.length decoded)

return decoded

----------------------------------------------
-- Hyperlane Pact Object Decoding --
----------------------------------------------
parseChainId :: Text -> Either HyperlaneError Word256
parseChainId s = do
cid <- first (HyperlaneErrorInvalidChainId . Text.pack) $ Text.decimal s
unless (fst cid >= 0) $ throwError $ HyperlaneErrorInvalidChainId "can't be negative"
return $ fst cid

------------------------------------------------------
-- Hyperlane Message Pact Object Decoding --
------------------------------------------------------

decodeHyperlaneMessageObject :: Object Name -> Either HyperlaneMessageIdError HyperlaneMessage
decodeHyperlaneMessageObject :: Object Name -> Either HyperlaneError HyperlaneMessage
decodeHyperlaneMessageObject o = do
let om = _objectMap (_oObject o)

Expand All @@ -287,32 +302,49 @@ decodeHyperlaneMessageObject o = do

pure HyperlaneMessage{..}

------------------------------------------------------------
-- Hyperlane Token Message Pact Object Decoding --
------------------------------------------------------------

decodeHyperlaneTokenMessageObject :: Object Name -> Either HyperlaneError TokenMessageERC20
decodeHyperlaneTokenMessageObject o = do
let om = _objectMap (_oObject o)

tmRecipient <- grabField om "recipient" _LString
tmAmount <- decimalToWord <$> grabField om "amount" _LDecimal
tmChainId <- parseChainId =<< grabField om "chainId" _LString

pure TokenMessageERC20{..}

----------------------------------------------
-- Utilities --
----------------------------------------------

wordToDecimal :: Word256 -> Decimal
wordToDecimal w = fromRational (toInteger w % ethInWei)

decimalToWord :: Decimal -> Word256
decimalToWord d = round $ d * ethInWei

ethInWei :: Num a => a
ethInWei = 1_000_000_000_000_000_000 -- 1e18
{-# inline ethInWei #-}

grabField :: Map FieldKey (Term Name) -> FieldKey -> Prism' Literal a -> Either HyperlaneMessageIdError a
grabField :: Map FieldKey (Term Name) -> FieldKey -> Prism' Literal a -> Either HyperlaneError a
grabField m key p = case m ^? at key . _Just . _TLiteral . _1 . p of
Nothing -> Left (HyperlaneMessageIdErrorFailedToFindKey key)
Nothing -> Left (HyperlaneErrorFailedToFindKey key)
Just a -> Right a

-- | Grab a bounded integral value out of the pact object, and make sure
-- the integer received is a valid element of that type
grabInt :: forall a. (Integral a, Bounded a) => Map FieldKey (Term Name) -> FieldKey -> Either HyperlaneMessageIdError a
grabInt :: forall a. (Integral a, Bounded a) => Map FieldKey (Term Name) -> FieldKey -> Either HyperlaneError a
grabInt m key = do
i <- grabField m key _LInteger
if i >= fromIntegral @a @Integer minBound && i <= fromIntegral @a @Integer maxBound
then do
pure (fromIntegral @Integer @a i)
else do
throwError (HyperlaneMessageIdErrorNumberOutOfBounds key)
throwError (HyperlaneErrorNumberOutOfBounds key)

eof :: Get ()
eof = do
Expand Down
6 changes: 6 additions & 0 deletions src/Pact/Gas/Table.hs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ data GasCostConfig = GasCostConfig
, _gasCostConfig_poseidonHashHackAChainLinearGasFactor :: Gas
, _gasCostConfig_hyperlaneMessageIdGasPerRecipientOneHundredBytes :: MilliGas
, _gasCostConfig_hyperlaneDecodeTokenMessageGasPerOneHundredBytes :: MilliGas
, _gasCostConfig_hyperlaneEncodeTokenMessageGasPerOneHundredBytes :: MilliGas
, _gasCostConfig_keccak256GasPerOneHundredBytes :: MilliGas
, _gasCostConfig_keccak256GasPerChunk :: MilliGas
}
Expand Down Expand Up @@ -88,6 +89,7 @@ defaultGasConfig = GasCostConfig
, _gasCostConfig_poseidonHashHackAChainQuadraticGasFactor = 38
, _gasCostConfig_hyperlaneMessageIdGasPerRecipientOneHundredBytes = MilliGas 47
, _gasCostConfig_hyperlaneDecodeTokenMessageGasPerOneHundredBytes = MilliGas 50
, _gasCostConfig_hyperlaneEncodeTokenMessageGasPerOneHundredBytes = MilliGas 50
, _gasCostConfig_keccak256GasPerOneHundredBytes = MilliGas 146
, _gasCostConfig_keccak256GasPerChunk = MilliGas 2_120
}
Expand Down Expand Up @@ -247,6 +249,7 @@ defaultGasTable =
,("poseidon-hash-hack-a-chain", 124)
,("hyperlane-message-id", 2)
,("hyperlane-decode-token-message", 2)
,("hyperlane-encode-token-message", 2)
,("hash-keccak256",1)
]

Expand Down Expand Up @@ -351,6 +354,9 @@ tableGasModel gasConfig =
GHyperlaneDecodeTokenMessage len ->
let MilliGas costPerOneHundredBytes = _gasCostConfig_hyperlaneDecodeTokenMessageGasPerOneHundredBytes gasConfig
in MilliGas (costPerOneHundredBytes * div (fromIntegral len) 100)
GHyperlaneEncodeTokenMessage len ->
let MilliGas costPerOneHundredBytes = _gasCostConfig_hyperlaneEncodeTokenMessageGasPerOneHundredBytes gasConfig
in MilliGas (costPerOneHundredBytes * div (fromIntegral len) 100)
GKeccak256 chunkBytes ->
let MilliGas costPerOneHundredBytes = _gasCostConfig_keccak256GasPerOneHundredBytes gasConfig
MilliGas costPerChunk = _gasCostConfig_keccak256GasPerChunk gasConfig
Expand Down
3 changes: 1 addition & 2 deletions src/Pact/GasModel/GasTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2042,8 +2042,7 @@ hyperlaneMessageIdTests :: NativeDefName -> GasUnitTests
hyperlaneMessageIdTests = defGasUnitTest $ PactExpression hyperlaneMessageIdExprText Nothing
where
hyperlaneMessageIdExprText = [text|
(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})
(hyperlane-message-id {"destinationDomain": 1,"nonce": 325,"originDomain": 626,"recipient": "AAAAAAAAAADpgrOqkM0BOY-FQnNzkDXuYlsVcf50GRU","sender": "AAAAAAAAAAAAAAAAf6k4W-ECrD6sKXSD3WIz1is-FJY","messageBody": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAewAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGF7InByZWQiOiAia2V5cy1hbGwiLCAia2V5cyI6WyJkYTFhMzM5YmQ4MmQyYzJlOTE4MDYyNmEwMGRjMDQzMjc1ZGViM2FiYWJiMjdiNTczOGFiZjZiOWRjZWU4ZGI2Il19AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA","version": 1})
|]

keccak256Tests :: NativeDefName -> GasUnitTests
Expand Down
2 changes: 1 addition & 1 deletion src/Pact/Interpreter.hs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ pact411Natives :: [Text]
pact411Natives = ["enforce-verifier", "hyperlane-message-id", "hyperlane-decode-token-message"]

pact412Natives :: [Text]
pact412Natives = ["hash-keccak256"]
pact412Natives = ["hash-keccak256", "hyperlane-encode-token-message"]

initRefStore :: RefStore
initRefStore = RefStore nativeDefs
Expand Down
Loading

0 comments on commit 8240f2e

Please sign in to comment.