Safari-Wallet / ui

https://safari-wallet-test-dapp.vercel.app
GNU General Public License v3.0
40 stars 11 forks source link

Early-stage JS messaging refactoring #9

Closed jamierumbelow closed 2 years ago

jamierumbelow commented 2 years ago

This PR starts to standardise the messaging format between the different JS files, with the goal of being able to validate and type messages from cradle to grave, from JS to Swift and back again.

The core idea is that all JS files communicate with the following object:

type Message = { destination: "background" | "content" | "popup";  method: string; params: any; sessionId: string; }

destination is used to multiplex the browser runtime events channel, and permit more generic method names. method is currently general-purpose, but will later be typed, ditto params. sessionId is currently unused.

It also:

My approach here has been to try to build in an 'invisible' way, so the extension should work mostly as it did before. Signing wasn't working for me before, so I've been unable to test it properly.

Explicitly not included in this PR:

The above list provides a pretty good roadmap for what I'll be working on this week :)

ronaldmannak commented 2 years ago

@natclark can you take a look at the commit since all changes are in the JS part?

jamierumbelow commented 2 years ago

Holding in draft state until #9 is merged, will update this branch then.

jamierumbelow commented 2 years ago

Superseded by #13.