@hashgraph/hedera-wallet-connect 1.0.6 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -0
- package/dist/browser-cjs-metafile.json +1 -1
- package/dist/browser-cjs.js +11 -1
- package/dist/browser-esm-metafile.json +1 -1
- package/dist/browser-esm.js +11 -1
- package/dist/node-cjs-metafile.json +1 -1
- package/dist/node-cjs.js +142 -131
- package/dist/node-esm-metafile.json +1 -1
- package/dist/node-esm.js +142 -131
- package/dist/types/src/lib/dapp/DAppSigner.d.ts +6 -0
- package/dist/types/src/lib/dapp/DAppSigner.d.ts.map +1 -1
- package/dist/types/src/lib/dapp/index.d.ts +7 -7
- package/dist/types/src/lib/dapp/index.d.ts.map +1 -1
- package/dist/types/src/lib/shared/utils.d.ts +12 -0
- package/dist/types/src/lib/shared/utils.d.ts.map +1 -1
- package/dist/types/src/lib/wallet/index.d.ts.map +1 -1
- package/dist/types/src/lib/wallet/provider.d.ts +1 -1
- package/dist/types/test/_helpers.d.ts +7 -3
- package/dist/types/test/_helpers.d.ts.map +1 -1
- package/dist/types/test/dapp/DAppSigner.test.d.ts +2 -0
- package/dist/types/test/dapp/DAppSigner.test.d.ts.map +1 -0
- package/package.json +3 -2
package/README.md
CHANGED
@@ -65,6 +65,65 @@ reference the [WalletConnect documentation](https://docs.walletconnect.com/2.0/)
|
|
65
65
|
Upon successfully configuring your dApp and/or wallet to manage WalletConnect sessions, you can
|
66
66
|
use this library’s functions to easily create and handle requests for the Hedera network.
|
67
67
|
|
68
|
+
### DApps
|
69
|
+
|
70
|
+
#### Signer
|
71
|
+
|
72
|
+
This library provides a `DAppSigner` class that implements the `@hashgraph/sdk`'s `Signer`
|
73
|
+
interface. You may use the `DAppSigner` class to sign and execute transactions on the Hedera
|
74
|
+
network.
|
75
|
+
|
76
|
+
##### Get Signer
|
77
|
+
|
78
|
+
After you have paired your wallet with your dApp, you can get the signer from the
|
79
|
+
`DAppConnector` instance:
|
80
|
+
|
81
|
+
```javascript
|
82
|
+
const signer = dAppConnector.signers[0] // DAppSigner
|
83
|
+
```
|
84
|
+
|
85
|
+
Or, if multiple signers are available, you can find the signer by account ID:
|
86
|
+
|
87
|
+
```javascript
|
88
|
+
const signer = dAppConnector.signers.find(
|
89
|
+
(signer_) => signer_.getAccountId().toString() === '0.0.100',
|
90
|
+
) // DAppSigner
|
91
|
+
```
|
92
|
+
|
93
|
+
##### Sign Transactions
|
94
|
+
|
95
|
+
```javascript
|
96
|
+
const transaction = new TransferTransaction()
|
97
|
+
.addHbarTransfer('0.0.100', new Hbar(-1))
|
98
|
+
.addHbarTransfer('0.0.101', new Hbar(1))
|
99
|
+
|
100
|
+
await transaction.freezeWithSigner(signer)
|
101
|
+
const signedTransaction = await signer.signTransaction(transaction)
|
102
|
+
```
|
103
|
+
|
104
|
+
##### Sign and Execute Transactions
|
105
|
+
|
106
|
+
```javascript
|
107
|
+
const transaction = new TransferTransaction()
|
108
|
+
.addHbarTransfer('0.0.100', new Hbar(-1))
|
109
|
+
.addHbarTransfer('0.0.101', new Hbar(1))
|
110
|
+
|
111
|
+
await transaction.freezeWithSigner(signer)
|
112
|
+
const transactionResponse = await transaction.executeWithSigner(signer)
|
113
|
+
```
|
114
|
+
|
115
|
+
##### Sign and verify messages
|
116
|
+
|
117
|
+
```javascript
|
118
|
+
const text = 'Example message to sign'
|
119
|
+
const base64String = btoa(text)
|
120
|
+
|
121
|
+
const sigMaps = await signer.sign([base64StringToUint8Array(base64String)]) // import { base64StringToUint8Array } from '@hashgraph/hedera-wallet-connect'
|
122
|
+
|
123
|
+
// sigMaps[0].publicKey also contains the public key of the signer, but you should obtain a PublicKey you can trust from a mirror node.
|
124
|
+
const verifiedResult = verifySignerSignature(base64String, sigMaps[0], publicKey) // import { verifySignerSignature } from '@hashgraph/hedera-wallet-connect'
|
125
|
+
```
|
126
|
+
|
68
127
|
### Wallet
|
69
128
|
|
70
129
|
This library provides a Wallet class that extends the
|