BALANCE instruction returns balance sans AMOUNT
The BALANCE
instruction should, according to the docs:
Push the current amount of mutez held by the executing contract, including any mutez added by the calling transaction.
However, instead, the interpreter does not include any mutez added by the calling transaction
, i.e. AMOUNT
.
To recreate, I originated a contract that forwards its balance:
originateSpecializedAnyTezForwarder :: Mutez -> IntegrationalScenarioM (ForwarderAnyRef)
originateSpecializedAnyTezForwarder mutez' =
lOriginate fwd "FA1.2 Specialized Any Token and Tez Forwarder" () mutez'
where
fwd = FwdAnyTez.specializedAnyTezForwarderContract centralWallet
originateManagedLedger :: IntegrationalScenarioM (TAddress ML.Parameter)
originateManagedLedger =
lOriginate ML.managedLedgerContract "Managed ledger"
(ML.mkStorage masterAddress mempty) (toMutez 0)
spec_SpecializedForwarder :: Spec
spec_SpecializedForwarder = do
it "Successfully forwards Managed ledger tokens and Tez to centralWallet (FwdAnyTez)" $
integrationalTestExpectation $ do
let amount = 100500
heldTezAmount = toEnum @Mutez 1000
sentTezAmount = toEnum @Mutez 128
noTez = toEnum @Mutez 0
allTez = toEnum @Mutez . sum $ fromEnum <$>
[ heldTezAmount
, sentTezAmount
]
tokenAddr <- originateManagedLedger
fwd <- originateSpecializedAnyTezForwarder heldTezAmount
consumer <- lOriginateEmpty @Natural contractConsumer "consumer"
withSender masterAddress . lCallDef tokenAddr $
ML.Mint
( #to .! toAddress fwd
, #value .! amount
)
lTransfer (#from .! genesisAddress) (#to .! fwd) sentTezAmount CallDefault $
FwdAny.mkParameter amount $
toAddress tokenAddr
lCallEP tokenAddr (Call @"GetBalance") $
mkView (#owner .! centralWallet) consumer
validate . Right $
lExpectViewConsumerStorage consumer [amount]
validate . Right $
lExpectBalance tokenAddr noTez
validate . Right $
lExpectBalance consumer noTez
validate . Right $
lExpectBalance fwd noTez
The heldTezAmount
is forwarded, but the sentTezAmount
is not.