Skip to content

Commit

Permalink
Band-aid fix on gas station msg data
Browse files Browse the repository at this point in the history
  • Loading branch information
edmundnoble committed Sep 25, 2024
1 parent 4a0dff8 commit 537a305
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/Chainweb/Pact5/Templates.hs
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ mkFundTxTerm
-> MinerKeys
-> Text -- ^ Address of the sender from the command
-> GasSupply
-> (Expr (), PactValue)
-> (Expr (), Map.Map Field PactValue)
mkFundTxTerm (MinerId mid) (MinerKeys ks) sender total =
let
term = fundTxTemplate sender mid
buyGasData = PObject $ Map.fromList
buyGasData = Map.fromList
[ ("miner-keyset", convertKeySet ks)
, ("total", PDecimal $ _pact5GasSupply total)
]
Expand All @@ -103,10 +103,10 @@ convertKeySet =
mkBuyGasTerm
:: Text -- ^ Address of the sender from the command
-> GasSupply
-> (Expr (), PactValue)
-> (Expr (), Map.Map Field PactValue)
mkBuyGasTerm sender total = (buyGasTemplate sender, buyGasData)
where
buyGasData = PObject $ Map.fromList
buyGasData = Map.fromList
[ ("total", PDecimal $ _pact5GasSupply total) ]
{-# INLINABLE mkBuyGasTerm #-}

Expand Down
10 changes: 5 additions & 5 deletions src/Chainweb/Pact5/TransactionExec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -701,8 +701,8 @@ runUpgrade _logger db txContext cmd = case payload ^. pPayload of
publicMeta = payload ^. pMeta
chash = _cmdHash cmd

enrichedMsgBodyForGasPayer :: Command (Payload PublicMeta ParsedCode) -> PactValue
enrichedMsgBodyForGasPayer cmd = case (_pPayload $ _cmdPayload cmd) of
enrichedMsgBodyForGasPayer :: Map.Map Field PactValue -> Command (Payload PublicMeta ParsedCode) -> PactValue
enrichedMsgBodyForGasPayer dat cmd = case (_pPayload $ _cmdPayload cmd) of
Exec exec ->
PObject $ Map.fromList
[ ("tx-type", PString "exec")
Expand All @@ -712,7 +712,7 @@ enrichedMsgBodyForGasPayer cmd = case (_pPayload $ _cmdPayload cmd) of
-- then slice the section of code each `TopLevel` uses.
, ("exec-code", PList (Vector.fromList (fmap (PString . sliceSpan codeLines) (_pcExps (_pmCode exec)))))
, ("exec-user-data", _pmData exec)
]
] `Map.union` dat
where
codeLines = T.lines (_pcCode (_pmCode exec))
lispTLInfo = \case
Expand All @@ -738,7 +738,7 @@ enrichedMsgBodyForGasPayer cmd = case (_pPayload $ _cmdPayload cmd) of
, ("cont-is-rollback", PBool (_cmRollback cont))
, ("cont-user-data", _cmData cont)
, ("cont-has-proof", PBool (isJust (_cmProof cont)))
]
] `Map.union` dat

-- | Build and execute 'coin.buygas' command from miner info and user command
-- info (see 'TransactionExec.applyCmd' for more information).
Expand Down Expand Up @@ -786,7 +786,7 @@ buyGas logger db txCtx cmd = do
MsgData
-- Note: in the case of gaspayer, buyGas is given extra metadata that comes from
-- the Command
{ mdData = maybe buyGasData (const (enrichedMsgBodyForGasPayer cmd)) gasPayerCap
{ mdData = maybe (PObject buyGasData) (const $ enrichedMsgBodyForGasPayer buyGasData cmd) gasPayerCap
, mdHash = bgHash
, mdSigners = signersWithDebit
-- no verifiers are allowed in buy gas
Expand Down

0 comments on commit 537a305

Please sign in to comment.