@hashgraph/hedera-wallet-connect 1.0.5 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- 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 -130
- package/dist/node-esm-metafile.json +1 -1
- package/dist/node-esm.js +142 -130
- package/dist/types/src/index.d.ts +2 -0
- package/dist/types/src/index.d.ts.map +1 -0
- package/dist/types/src/lib/dapp/DAppSigner.d.ts +35 -0
- package/dist/types/src/lib/dapp/DAppSigner.d.ts.map +1 -0
- package/dist/types/src/lib/dapp/index.d.ts +177 -0
- package/dist/types/src/lib/dapp/index.d.ts.map +1 -0
- package/dist/types/src/lib/index.d.ts +4 -0
- package/dist/types/src/lib/index.d.ts.map +1 -0
- package/dist/types/src/lib/shared/chainIds.d.ts +12 -0
- package/dist/types/src/lib/shared/chainIds.d.ts.map +1 -0
- package/dist/types/src/lib/shared/errors.d.ts +49 -0
- package/dist/types/src/lib/shared/errors.d.ts.map +1 -0
- package/dist/types/src/lib/shared/events.d.ts +8 -0
- package/dist/types/src/lib/shared/events.d.ts.map +1 -0
- package/dist/types/src/lib/shared/index.d.ts +7 -0
- package/dist/types/src/lib/shared/index.d.ts.map +1 -0
- package/dist/types/src/lib/shared/methods.d.ts +13 -0
- package/dist/types/src/lib/shared/methods.d.ts.map +1 -0
- package/dist/types/src/lib/shared/payloads.d.ts +102 -0
- package/dist/types/src/lib/shared/payloads.d.ts.map +1 -0
- package/dist/types/src/lib/shared/utils.d.ts +281 -0
- package/dist/types/src/lib/shared/utils.d.ts.map +1 -0
- package/dist/types/src/lib/wallet/index.d.ts +40 -0
- package/dist/types/src/lib/wallet/index.d.ts.map +1 -0
- package/dist/types/src/lib/wallet/provider.d.ts +18 -0
- package/dist/types/src/lib/wallet/provider.d.ts.map +1 -0
- package/dist/types/src/lib/wallet/types.d.ts +32 -0
- package/dist/types/src/lib/wallet/types.d.ts.map +1 -0
- package/dist/types/test/_helpers.d.ts +39 -0
- package/dist/types/test/_helpers.d.ts.map +1 -0
- package/dist/types/test/dapp/DAppConnector.test.d.ts +2 -0
- package/dist/types/test/dapp/DAppConnector.test.d.ts.map +1 -0
- package/dist/types/test/dapp/DAppSigner.test.d.ts +2 -0
- package/dist/types/test/dapp/DAppSigner.test.d.ts.map +1 -0
- package/dist/types/test/utils.test.d.ts +2 -0
- package/dist/types/test/utils.test.d.ts.map +1 -0
- package/dist/types/test/wallet/methods/wallet-executeTransaction.test.d.ts +2 -0
- package/dist/types/test/wallet/methods/wallet-executeTransaction.test.d.ts.map +1 -0
- package/dist/types/test/wallet/methods/wallet-getNodeAddresses.test.d.ts +2 -0
- package/dist/types/test/wallet/methods/wallet-getNodeAddresses.test.d.ts.map +1 -0
- package/dist/types/test/wallet/methods/wallet-signAndExecuteQuery.test.d.ts +2 -0
- package/dist/types/test/wallet/methods/wallet-signAndExecuteQuery.test.d.ts.map +1 -0
- package/dist/types/test/wallet/methods/wallet-signAndExecuteTransaction.test.d.ts +2 -0
- package/dist/types/test/wallet/methods/wallet-signAndExecuteTransaction.test.d.ts.map +1 -0
- package/dist/types/test/wallet/methods/wallet-signMessage.test.d.ts +2 -0
- package/dist/types/test/wallet/methods/wallet-signMessage.test.d.ts.map +1 -0
- package/dist/types/test/wallet/methods/wallet-signTransaction.test.d.ts +2 -0
- package/dist/types/test/wallet/methods/wallet-signTransaction.test.d.ts.map +1 -0
- package/dist/types/test/wallet/wallet-init.test.d.ts +2 -0
- package/dist/types/test/wallet/wallet-init.test.d.ts.map +1 -0
- package/package.json +5 -4
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -35
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -17
- package/.github/ISSUE_TEMPLATE/hip_820.md +0 -16
- package/.github/dependabot.yml +0 -17
- package/.github/workflows/prettier.yml +0 -28
- package/.github/workflows/publish.yml +0 -35
- package/.github/workflows/test.yml +0 -32
- package/.husky/pre-commit +0 -4
- package/.lintstagedrc.json +0 -5
- package/.prettierignore +0 -3
- package/jest.config.ts +0 -33
- package/scripts/examples/build.mjs +0 -54
- package/scripts/examples/dev.mjs +0 -54
- package/scripts/lib/build.mjs +0 -40
- package/scripts/lib/context.mjs +0 -71
- package/scripts/lib/watch.mjs +0 -28
- package/typedoc.json +0 -10
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
|