Hi Algorand community,
I am using pyteal to create a function to update a field of my smart contract.
If the new value is the same as the existing value i want the function to “pass”.
I currently created a function like this:
def noop_partial_shipment():
saved_partial_shipment = App.globalGet(Bytes(PARTIAL_SHIPMENT))
return Seq(
Assert(ASSERT SOMETHING),
Cond(
# if not set
[ saved_partial_shipment == Bytes(""), DO SOMETHING],
# if values are the same, skip
[saved_partial_shipment == Txn.application_args[1], Approve()], # DO NOTHING
# if currently set to something
[saved_partial_shipment != Txn.application_args[1], DO SOMETHING ]
),
)
The second condition i indicated Approve() hoping for the function to just pass, but in reality the call takes few seconds and it subtract the transaction fee.
I also noticed that if i remove the second condition and this is true:
saved_partial_shipment == Txn.application_args[1]
Then the application returns an error. I imagined initially if conditions do not trigger then nothing happens but i discovered it is not the case.
In short: how do I get a noop to do something or to avoid the error in case no conditions are triggered?
Thank you