@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.
Files changed (77) hide show
  1. package/README.md +59 -0
  2. package/dist/browser-cjs-metafile.json +1 -1
  3. package/dist/browser-cjs.js +11 -1
  4. package/dist/browser-esm-metafile.json +1 -1
  5. package/dist/browser-esm.js +11 -1
  6. package/dist/node-cjs-metafile.json +1 -1
  7. package/dist/node-cjs.js +142 -130
  8. package/dist/node-esm-metafile.json +1 -1
  9. package/dist/node-esm.js +142 -130
  10. package/dist/types/src/index.d.ts +2 -0
  11. package/dist/types/src/index.d.ts.map +1 -0
  12. package/dist/types/src/lib/dapp/DAppSigner.d.ts +35 -0
  13. package/dist/types/src/lib/dapp/DAppSigner.d.ts.map +1 -0
  14. package/dist/types/src/lib/dapp/index.d.ts +177 -0
  15. package/dist/types/src/lib/dapp/index.d.ts.map +1 -0
  16. package/dist/types/src/lib/index.d.ts +4 -0
  17. package/dist/types/src/lib/index.d.ts.map +1 -0
  18. package/dist/types/src/lib/shared/chainIds.d.ts +12 -0
  19. package/dist/types/src/lib/shared/chainIds.d.ts.map +1 -0
  20. package/dist/types/src/lib/shared/errors.d.ts +49 -0
  21. package/dist/types/src/lib/shared/errors.d.ts.map +1 -0
  22. package/dist/types/src/lib/shared/events.d.ts +8 -0
  23. package/dist/types/src/lib/shared/events.d.ts.map +1 -0
  24. package/dist/types/src/lib/shared/index.d.ts +7 -0
  25. package/dist/types/src/lib/shared/index.d.ts.map +1 -0
  26. package/dist/types/src/lib/shared/methods.d.ts +13 -0
  27. package/dist/types/src/lib/shared/methods.d.ts.map +1 -0
  28. package/dist/types/src/lib/shared/payloads.d.ts +102 -0
  29. package/dist/types/src/lib/shared/payloads.d.ts.map +1 -0
  30. package/dist/types/src/lib/shared/utils.d.ts +281 -0
  31. package/dist/types/src/lib/shared/utils.d.ts.map +1 -0
  32. package/dist/types/src/lib/wallet/index.d.ts +40 -0
  33. package/dist/types/src/lib/wallet/index.d.ts.map +1 -0
  34. package/dist/types/src/lib/wallet/provider.d.ts +18 -0
  35. package/dist/types/src/lib/wallet/provider.d.ts.map +1 -0
  36. package/dist/types/src/lib/wallet/types.d.ts +32 -0
  37. package/dist/types/src/lib/wallet/types.d.ts.map +1 -0
  38. package/dist/types/test/_helpers.d.ts +39 -0
  39. package/dist/types/test/_helpers.d.ts.map +1 -0
  40. package/dist/types/test/dapp/DAppConnector.test.d.ts +2 -0
  41. package/dist/types/test/dapp/DAppConnector.test.d.ts.map +1 -0
  42. package/dist/types/test/dapp/DAppSigner.test.d.ts +2 -0
  43. package/dist/types/test/dapp/DAppSigner.test.d.ts.map +1 -0
  44. package/dist/types/test/utils.test.d.ts +2 -0
  45. package/dist/types/test/utils.test.d.ts.map +1 -0
  46. package/dist/types/test/wallet/methods/wallet-executeTransaction.test.d.ts +2 -0
  47. package/dist/types/test/wallet/methods/wallet-executeTransaction.test.d.ts.map +1 -0
  48. package/dist/types/test/wallet/methods/wallet-getNodeAddresses.test.d.ts +2 -0
  49. package/dist/types/test/wallet/methods/wallet-getNodeAddresses.test.d.ts.map +1 -0
  50. package/dist/types/test/wallet/methods/wallet-signAndExecuteQuery.test.d.ts +2 -0
  51. package/dist/types/test/wallet/methods/wallet-signAndExecuteQuery.test.d.ts.map +1 -0
  52. package/dist/types/test/wallet/methods/wallet-signAndExecuteTransaction.test.d.ts +2 -0
  53. package/dist/types/test/wallet/methods/wallet-signAndExecuteTransaction.test.d.ts.map +1 -0
  54. package/dist/types/test/wallet/methods/wallet-signMessage.test.d.ts +2 -0
  55. package/dist/types/test/wallet/methods/wallet-signMessage.test.d.ts.map +1 -0
  56. package/dist/types/test/wallet/methods/wallet-signTransaction.test.d.ts +2 -0
  57. package/dist/types/test/wallet/methods/wallet-signTransaction.test.d.ts.map +1 -0
  58. package/dist/types/test/wallet/wallet-init.test.d.ts +2 -0
  59. package/dist/types/test/wallet/wallet-init.test.d.ts.map +1 -0
  60. package/package.json +5 -4
  61. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -35
  62. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -17
  63. package/.github/ISSUE_TEMPLATE/hip_820.md +0 -16
  64. package/.github/dependabot.yml +0 -17
  65. package/.github/workflows/prettier.yml +0 -28
  66. package/.github/workflows/publish.yml +0 -35
  67. package/.github/workflows/test.yml +0 -32
  68. package/.husky/pre-commit +0 -4
  69. package/.lintstagedrc.json +0 -5
  70. package/.prettierignore +0 -3
  71. package/jest.config.ts +0 -33
  72. package/scripts/examples/build.mjs +0 -54
  73. package/scripts/examples/dev.mjs +0 -54
  74. package/scripts/lib/build.mjs +0 -40
  75. package/scripts/lib/context.mjs +0 -71
  76. package/scripts/lib/watch.mjs +0 -28
  77. 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