-
-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Add the ability to enable "Zippers" which implement pre-/post- transaction checks on the execution of certain callbacks (reminiscent of Safe's Guards)
Sketch: (update Purse.vy)
interface Zipper:
def unzip(accessory: address, indata: Bytes[65535]): view
def rezip(accessory: address, indata: Bytes[65535], outdata: Bytes[65535]): view
zippers: public(HashMap[bytes4, Zipper])
event ZipperUpdated:
method: indexed(bytes4)
old_zipper: indexed(Zipper)
new_zipper: indexed(Zipper)
...
struct ZipperUpdate:
method: bytes4
zipper: Zipper
@external
# NOTE: Reentrancy guard ensures that `__default__` module calls can't call this
def update_zippers(updates: DynArray[ZipperUpdate, 100]):
# NOTE: Can only work in a EIP-7702 context
assert tx.origin == self and tx.origin == msg.sender, "Purse:!authorized"
for update: ZipperUpdate in updates:
old_zipper: Zipper = self.zippers[update.method]
self.zippers[update.method] = update.zipper
log ZipperUpdated(
method=update.method,
old_zipper=old_zipper,
new_zipper=update.zipper,
)
...
def __default__():
... # Load accessory by `method`
zipper: Zipper = self.zippers[method]
if zipper.address != empty(address):
staticcall zipper.unzip(accessory, msg.data)
data: Bytes[65535] = ... # Call accessory w/ `msg.data`
if zipper.address != empty(address):
staticcall zipper.rezip(accessory, msg.data, data)
return data # NOTE: Need to temporarily store return dataMetadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request