How to connect a dapplet to an adapter?
First you need to install the Dapplet Browser Extension package to your project. Use npm for this:
Then create the manifest /dapplet.json
:
Here set the title and icon and check if the other fields match your project.
As you can see "contextIds"
and "dependencies"
contain the name of our Twitter adapter: "twitter-config.dapplet-base.eth"
. The last field specifies which version should be used.
Implement the dapplet’s /src/index.ts
according to the example:
#
Using widgetsWidgets are taken from the adapter's exports
:
and then used in the attachConfig()
function:
attachConfig
receives an object with context names as keys. The values of the object are functions which return a widget or an array of widgets. attachConfig
returns the object with $(ctx, 'element_id')
function,
which returns the Proxy of the widget by its id.
Widgets have states. The DEFAULT (case sensitive) state is used as initial.
It's possible to implement many states.
If the DEFAULT state is not presented, the initial state has to be specified explicitly.
We pass parameters of the widget described in the adapter into states.