-
Notifications
You must be signed in to change notification settings - Fork 145
Description
Issue to be solved
Currently we can get account objects that are entitled to only access certain functionality like Storage, Capabilities, etc, and this is definitely nice, but it doesn't really allow the kind of restriction of functionality that would be the most useful. Even if the transaction is restricted to Storage, it can still access every storage path and modify any storage path.
Currently, it is an antipattern to pass account objects to utility functions to set up account storage, capabilities, etc, but this restriction is starting to get really out of hand. There is so much boilerplate in Cadence transactions for initializing storage and capabilities now, it makes transactions really complicated and error prone.
For example, just look at this transaction to schedule a COA transaction: https://github.com/onflow/flow-core-contracts/blob/josh/coa-handler/transactions/transactionScheduler/schedule_coa_transaction.cdc
90% of the transaction is just boilerplate to make sure the storage and capabilities are set up properly, which is so unnecessary.
It would be really nice if we were able to get authorized account objects that could only access certain paths so we can put this boilerplate in utility functions in the contract that defined them so we can really simplify these transactions.
Suggested Solution
Have functions on the account object to get an account object or reference that can only access the specified paths. If other paths are attempted to be accessed, then the transaction would fail checking or execution (not sure where this can be verified)
something like this:
account.getPathRestrictedAccount(storagePaths: [/storage/coa, /storage/coaScheduledTransactionHandler, /storage/flowTransactionSchedulerManager], publicPaths: [/public/coa, /public/coaScheduledTransactionHandler, /public/flowTransactionSchedulerManager])