SecretNetwork icon indicating copy to clipboard operation
SecretNetwork copied to clipboard

CosmWasm v1: Pass `is_caller_a_contract` in `Env`

Open assafmo opened this issue 4 years ago • 2 comments

@baedrik:

Will there be a way for a contract to create/sign its own permit to, for example, view its own snip20 balance, or will contracts always have to use viewing keys to view its own balances, histories, etc...?

Assaf:

That's a good question that I didn't think of. Contracts don't have wallets like users. Their account is created publicly on chain before they're instantiated, I think even without a private key... so they cannot sign anything. However, in future upgrades we could pass in env whether the caller is a contract. This can also be available to queries and authenticated inside the enclave.

assafmo avatar Oct 05 '21 06:10 assafmo

I think there are cleaner ways to handle this specific issue, but it could be useful to pass this parameter (if it's verified by the enclave) in other scenarios (e.g. an application that doesn't want contracts interacting with it, only "real" users)

reuvenpo avatar Oct 05 '21 07:10 reuvenpo

This issue is actually easy to do, we just have to extend the Env sturct and populate it somewhere in the vicinity of this.

assafmo avatar Oct 05 '21 10:10 assafmo