I'm still working on a token standard, and currently trying to design a versatile enough approval method for AUs.
So far i've came up with the following (not saying it works):
interface Approvable {
approveTransfer: (from: AccountUpdate, to: AccountUpdate) => void;
approveDeploy: (deploy: AccountUpdate) => void;
}
@method
public approveDeploy(deploy: AccountUpdate): void {
this.assertHasNoBalanceChange([deploy]);
this.approve(deploy, AccountUpdate.Layout.NoChildren);
}
@method
public approveTransfer(from: AccountUpdate, to: AccountUpdate): void {
this.assertHasNoBalanceChange([from, to]);
this.approve(from, AccountUpdate.Layout.NoChildren);
this.approve(to, AccountUpdate.Layout.NoChildren);
}
Depending on how the from / to account updates for balance change of the Token accounts are created, they might end up having various children.
In the case of a deployment as long as the self account update of the deployed contract stays simple => we can use NoChildren as a layout and things are just fine.
However i wonder in what cases would this break? I think adding an extra manual AU into init() could break it, since it will add another child AU with callDepth: 1 and then the approval method will run into trouble since it expects/asserts no children?
For the transfer approval, i've decided to go with the path of standalone from/to AUs, so that i can support arbitrarily proven AUs on both ends. Reasoning behind this was to support custom token accounts with permissions set to receive: proof, send: proof. However i also can't find an easy way to reason about the children layout of the from/to account updates.
Do you have any ideas how to generalise this? @primal plume @gritty crow @quiet rose @trim monolith 👀