warp-contracts / warp

An implementation of the Arweave SmartWeave smart contracts protocol.
MIT License
159 stars 44 forks source link

fix: reading owner of tx in strict mode #306

Closed koonopek closed 1 year ago

koonopek commented 1 year ago

This MR solve problem where in strict mode, customSignature is not resolving to proper address.

It fails here: https://github.com/warp-contracts/warp/blob/main/src/contract/HandlerBasedContract.ts#L581 (thanks @asiaziola) When we try to decode address from signature and we strictly assume that it is arweave signature. It only happens when {stricit : true}.

To solve this issue I extract owner assigned by signature.signer function and it solves the issues.

However, I also wanted to remove this code https://github.com/warp-contracts/warp/blob/main/src/contract/HandlerBasedContract.ts#L581, because of it - we are signing twice per one interaction (one dummy interaction just to get address and second real one). If interaction is signed by metaMask for example it will break the ux (two pop ups). However, when i removed this logic, it broke internal writes integration tests, so I left it there.

I have also tested it with - https://github.com/warp-contracts/warp-contracts-plugins/blob/main/warp-contracts-plugin-signature/src/server/evm/evmSignature.ts I didnt want to bring plugin as dependency so it is not in tests