o1js
o1js copied to clipboard
Add caller field to the AccountUpdate
- In Ethereum, there is msg.sender that allows to get the information about the caller of the method. If contract A calls contract B, then B knows that the caller is A. We cannot get it in SmartContract, although there is an indirect way described in https://github.com/o1-labs/o1js/blob/main/src/examples/zkapps/joint-update.ts that require several AccountUpdates to be added to the tx and does not work with token accounts due to the limit of having max 5 AccountUpdates with proof authorization: https://discord.com/channels/484437221055922177/1282303057526263879
- In gsn.org, there is msgSender() that allows contract B also to get the address of the user who initiated and signed the transaction. We can get it in SmartContract by using
this.sender.getAndRequireSignatureV2()
Proposal:
- add to each AccountUpdate that is being created for SmartContract method call the field
caller
(this.self.caller
) that will contain the address and tokenId of the caller of a method - feePayer in case the method is called insideMina.transaction
and calling contract address in case it is called by another SmartContract - add the possibility to get inside the SmartContract the verification key hash of the account {publicKey, tokenId} to enable the SmartContract to do different actions depending on who called the method (
account.verificationKey.get()
).