Lambda function with operations only in legacy version

I’m still using the legacy version of online editor.
The code I was using before had the function sp.utils.lambda_operations_only().
But now it says this function doesn’t exist anymore, should I use sp.build_lambda() to handle it?
If yes, how should I build it?

We revert it.
You can use it sp.utils.lambda_operations_only() in legacy.

Example:

import smartpy as sp

class MyContract(sp.Contract):
    def __init__(self):
        self.init(lambda_=sp.none)

    @sp.entry_point
    def set_lambda(self, lambda_):
        self.data.lambda_ = sp.some(lambda_)

    @sp.entry_point
    def exec_lambda(self):
        lambda_ = self.data.lambda_.open_some()
        ops = sp.compute(lambda_(sp.unit))
        sp.add_operations(ops)    

@sp.add_test(name = "Lambdas")
def test():
    scenario = sp.test_scenario()
    scenario.h1("Lambdas")
    c1 = MyContract()
    scenario += c1
    alice = sp.test_account("alice")

    def send_to_alice(params):
        sp.set_type(params, sp.TUnit)
        sp.send(alice.address, sp.tez(5))

    lambda_ = sp.utils.lambda_operations_only(send_to_alice)
    c1.set_lambda(lambda_)
    c1.exec_lambda().run(amount=sp.tez(5))
1 Like