[DRAFT] feat: Add MetaMask Promised Outcomes #88
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Promised Outcomes
Overview
This document will provide an overview of the
MetaMask Promised Outcomesfeature. We can extend an ERC-7715 permission response to enforce promises made by the dapp regarding the outcomes of the granted permissions without relying solely on the dapp's honesty.Providing Promised outcomes
When constructing a permission request for the wallet, the dApp can attach
promisedOutcomes. ThepromisedOutcomesfield is an array of objects, each representing a promised outcome. The type field specifies the kind of outcome being promised, and the data field contains type-specific details.Some potential types of promised outcomes:
exact-transfer: Promises an exact transfer of a specific asset amount to a recipient.event-emission: Promises that a specific event will be emitted with certain parameters.custom: Allows for open-ended custom promises with wallet-interpreted logic.Wallet Responsibilities
Upon receiving a
PermissionsRequestwithpromisedOutcomes, the wallet should:promisedOutcomesand generate corresponding enforcement caveats.PermissionsContextreturned to the dapp.The wallet should strive to enforce the promised outcomes as closely as possible, with a caveat enforcer with an
afterHook. Additionally, that wallet may run a runtime simulation to guarantee the promised outcomes further.POC e2e
For POC e2e, we will use the
exact-transfertype to enforce a promise that the dApp will transfer a specific asset(ie, mock GATOR token) amount to a recipient(ie, the account the user chooses that is granting the permission).Anytime the dApp redeems the permission, they are required to transfer X amount of GATOR tokens. This keeps the POC simple as we expand on the feature to make it more flexible.
Changes
MetaMask Promised Outcomesfeature.PromisedOutcomeson the permission request confirmationPromisedOutcomestype interface exposed to dApps attached to the permission request. This new field is optional.promisedOutcomes[]field to the correct promised outcomes types and throw an error if the type is not supported. For the POC, we will only allow theexact-transfertype.exact-transfercaveats and attach them to the delegation that will be signed.UI
Mental models
EVM UserOp State transition(UserOp submitted by dApp on behalf of the user
delegatoraccount)Native token stream permission with not
PromisedOutcomes