@hashgraph/hedera-wallet-connect 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +61 -0
- package/dist/browser-cjs-metafile.json +1 -1
- package/dist/browser-cjs.js +1 -1
- package/dist/browser-esm-metafile.json +1 -1
- package/dist/browser-esm.js +1 -1
- package/dist/node-cjs-metafile.json +1 -1
- package/dist/node-cjs.js +96 -96
- package/dist/node-esm-metafile.json +1 -1
- package/dist/node-esm.js +89 -89
- package/dist/types/src/lib/dapp/DAppSigner.d.ts +2 -1
- package/dist/types/src/lib/dapp/DAppSigner.d.ts.map +1 -1
- package/dist/types/src/lib/dapp/index.d.ts +11 -2
- package/dist/types/src/lib/dapp/index.d.ts.map +1 -1
- package/dist/types/src/lib/shared/extensionController.d.ts +18 -0
- package/dist/types/src/lib/shared/extensionController.d.ts.map +1 -0
- package/dist/types/src/lib/shared/index.d.ts +1 -0
- package/dist/types/src/lib/shared/index.d.ts.map +1 -1
- package/package.json +7 -2
package/README.md
CHANGED
@@ -187,6 +187,67 @@ to approve or reject the session:
|
|
187
187
|
Upon receiving a `session_request` event, process the request. For instance, if the dApp
|
188
188
|
requests a transaction to be signed:
|
189
189
|
|
190
|
+
#### Extension popup
|
191
|
+
|
192
|
+
By default, it is not possible to directly pop up an extension with Wallet Connect. However, to
|
193
|
+
allow this possibility, the dAppConnector look for extensions. If you create the AppConnector,
|
194
|
+
it will automatically send a message to the extension to detect if it is installed. In case the
|
195
|
+
extension is installed, it will be added to the available extensions and its data can be found
|
196
|
+
at the extensions property of dAppConnector.
|
197
|
+
|
198
|
+
To connect an available extension, use the method `connectExtension(<extensionId>)`. This will
|
199
|
+
link the extension to the signer and session. Whenever you use the signer created for this
|
200
|
+
session, the extension will automatically open. You can find out if the extension is available
|
201
|
+
by checking the `extensions` property.
|
202
|
+
|
203
|
+
```javascript
|
204
|
+
const dAppConnector = new DAppConnector(
|
205
|
+
dAppMetadata,
|
206
|
+
LedgerId.TESTNET,
|
207
|
+
projectId,
|
208
|
+
Object.values(HederaJsonRpcMethod),
|
209
|
+
[HederaSessionEvent.ChainChanged, HederaSessionEvent.AccountsChanged],
|
210
|
+
[HederaChainId.Testnet]
|
211
|
+
)
|
212
|
+
|
213
|
+
[...]
|
214
|
+
|
215
|
+
dAppConnector?.extensions?.forEach((extension) => {
|
216
|
+
console.log(extension)
|
217
|
+
})
|
218
|
+
|
219
|
+
const extension = dAppConnector?.extensions?.find((extension) => extension.name === '<Extension name>')
|
220
|
+
if (extension.available) {
|
221
|
+
await dAppConnector!.connectExtension(extension.id);
|
222
|
+
const signer = dAppConnector.getSigner(AccountId.fromString('0.0.12345'))
|
223
|
+
|
224
|
+
// This request will open the extension
|
225
|
+
const response = await signer.signAndExecuteTransaction(transaction)
|
226
|
+
}
|
227
|
+
```
|
228
|
+
|
229
|
+
Wallets that are compatible should be able to receive and respond to the following messages:
|
230
|
+
|
231
|
+
- `"hedera-extension-query"`: The extension is required to respond with
|
232
|
+
`"hedera-extension-response"` and provide the next set of data in the metadata property.
|
233
|
+
```javascript
|
234
|
+
let metadata = {
|
235
|
+
id: '<extesnionId>',
|
236
|
+
name: '<Wallet name>',
|
237
|
+
url: '<Wallet url>',
|
238
|
+
icon: '<Wallet con>',
|
239
|
+
description: '<Wallet url>',
|
240
|
+
}
|
241
|
+
```
|
242
|
+
- `"hedera-extension-open-<extensionId>"`: The extension needs to listen to this message and
|
243
|
+
automatically open.
|
244
|
+
- `"hedera-extension-connect-<extensionId>"`: The extension must listen to this message and
|
245
|
+
utilize the `pairingString` property in order to establish a connection.
|
246
|
+
|
247
|
+
This communication protocol between the wallet and web dApps requires an intermediate script to
|
248
|
+
use the Chrome API. Refer to the
|
249
|
+
[Chrome Extensions documentation](https://developer.chrome.com/docs/extensions/develop/concepts/messaging)
|
250
|
+
|
190
251
|
## Demo & docs
|
191
252
|
|
192
253
|
This repository includes a vanilla html/css/javascript implementation with a dApp and wallet
|