Skip to content

Commit

Permalink
feat(multisend): add builder pattern support (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
fubuloubu authored May 29, 2024
1 parent 36180b4 commit d5bd181
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ape_safe/multisend.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ class MultiSend(ManagerAccessMixin):
txn.add(contract.myMethod, *call_args)
... # Add as many calls as desired to execute
txn.add(contract.myMethod, *call_args)
# or, using a builder pattern:
txn = multisend.MultiSend()
.add(contract.myMethod, *call_args)
.add(contract.myMethod, *call_args)
... # Add as many calls as desired to execute
.add(contract.myMethod, *call_args)
# Stage the transaction to publish on-chain
# NOTE: if not enough signers are available, publish to Safe API instead
Expand Down Expand Up @@ -160,7 +166,7 @@ def add(
*args,
delegatecall=False,
value=0,
):
) -> "MultiSend":
"""
Adds a call to the Multicall session object.
Expand All @@ -181,6 +187,7 @@ def add(
"callData": call.encode_input(*args),
}
)
return self

def _validate_calls(self, **txn_kwargs) -> None:
required_value = sum(call["value"] for call in self.calls)
Expand Down

0 comments on commit d5bd181

Please sign in to comment.