signum-network / signum-mobile-wallet

The new 🚀 Signum Mobile Wallet - Better than ever before 🤘
Apache License 2.0
4 stars 0 forks source link

DApps Support #62

Open ipr0310 opened 3 months ago

ohager commented 2 months ago

That's actually relatively easy, but requires Deeplink support. We can rely here on SRC22, i.e. using the generic URL format

action: "sign" payload: "36b2444574328410c27..." (unsigned transaction bytes)

According to SRC22 the payload needs to be encoded in base64 (although knowing that unsignedBytes is already hex and compatible with network transport).

An url would look like this:

signum://v1?action=sign&payload=MDAyMDM1MWUzYTEyM2MwMDQ5N2Q1NTlkMThkOTg5YjhlMmQ3MjllYjZmNjliNzBjMWRkYzNlNTU0Zjc1YmVmM2VkMjcxNmE0YjIxMjE5MDIwODIyZWIwN2I3Nzc1NzIxMDBlMWY1MDUwMDAwMDAwMDQwNDIwZjAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMTAwMDAwMGMxMzIwYTAwMmY4YTMzZmQyOWI0N2Q5NDA0Y2ZlMTUzMWI1NDNjN2MwMTExMDAwMDgwNTM2ZjZkNjUyMDU0NjU3Mzc0MjA0ZDY1NzM3MzYxNjc2NQ==

SignumJS already supports this in Methods:

createDeeplink and parseDeeplink

https://signum-network.github.io/signumjs/modules/util.html#createdeeplink

So the flow is:

  1. Get unsigendTransactionBytes (generate Tx using the senders public key only)
  2. The dApp generates the deeplink for signing (createDeeplink)
  3. Using the deeplink would open the Mobile Wallet
  4. Mobile wallet needs to parse the incoming link -> support for two actions: pay (to be compatible with phoenix codes) and sign
  5. Mobile wallet navigates to Signing Screen (if action=sign)
  6. Gets the unsigned bytes and parses it using node function parseTransactionBytes
  7. Shows data and asks for confirmation

Bonus: the dApp can check the blockchain pending bytes for signed transaction.