-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support contracts sending funds to a Moonlight Account #2284
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I only left a couple of minor comments.
Although I have a general comment about the tests: if it's not too much trouble, could we add a test that ensures that the code correctly captures scenarios where a transaction should fail? (e.g., attempting to send money from a contract to an account with insufficient funds).
a1440fe
to
30f4dc7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, nice test suite additions as well
This structure will be used as an argument to a transfer contract function allowing for a contract to send Dusk to a Moonlight account.
This will allow us to test that the contract successfully transfers funds to an account using the "transfer_to_account" function taking a `TransferToAccount` as argument.
The `transfer_to_account` can be called by contract using the `TransferToAccount` structure to move some of its funds to a Moonlight account.
30f4dc7
to
2971fbf
Compare
This PR enables the ability of contracts to send funds directly to a Moonlight account. This facilitates use-cases requiring sending Dusk through a contract to Moonlight accounts, including but not limited to bridging.
To achieve this we add a
transfer_to_account
function to the transfer contract, taking as argument aTransferToAccount
structure, that can be called by a contract to transfer funds to any Moonlight account they wish. Multiple calls may be chained to make contracts that effectively transfer Dusk to several accounts atomically. The function is the equivalent oftransfer_to_contract
but for accounts, and puts accounts and contracts on the same footing in terms of being able to receive funds directly.One important asymmetry between accounts and contracts, however, is the capability of contracts to reject the funds sent to them by a contract. With this implementation, accounts do not have this capability.