@hashgraph/hedera-wallet-connect 1.5.2-canary.90511fb.0 → 1.5.2-canary.93d61f2.0
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 +64 -232
- package/package.json +1 -1
package/README.md
CHANGED
@@ -1,238 +1,70 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
This library provides tools and recommendations on how to integrate Hedera into an application
|
4
|
-
that requires communication with a wallet that supports Hedera. There are 2 different paths to
|
5
|
-
integrate Hedera in this context. Both approaches use the
|
6
|
-
[WalletConnect](https://walletconnect.network/) network to send messages from apps to wallets
|
7
|
-
and back.
|
8
|
-
|
9
|
-
## Hedera APIs
|
10
|
-
|
11
|
-
Hedera natively operates using a gRPC API for write transactions and by default, a REST API for
|
12
|
-
read transactions. Hedera implements EVM compatible smart contracts using
|
13
|
-
[Hyperledger Besu](https://besu.hyperledger.org/) under the hood.
|
14
|
-
|
15
|
-
Ethereum developers and toolsets often expect to interact with Ethereum compatible chains using
|
16
|
-
the [Ethereum JSON-RPC](https://ethereum.org/en/developers/docs/apis/json-rpc/). To acheive
|
17
|
-
compatibility with this API,
|
18
|
-
[Hedera JSON-RPC Providers](https://docs.hedera.com/hedera/core-concepts/smart-contracts/json-rpc-relay#community-hosted-json-rpc-relays)
|
19
|
-
operate a software middlelayer that translates Ethereum JSON-RPC compatible API calls into
|
20
|
-
Hedera gRPC and REST API calls.
|
1
|
+
# Overview
|
21
2
|
|
22
|
-
|
3
|
+
This library is the result of Hedera community collaboration to bring Hedera into the
|
4
|
+
WalletConnect ecosystem and vice versa.
|
23
5
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
6
|
+
The goal of this repository is to be a reference for wallets and dApps integrating the
|
7
|
+
WalletConnect <> Hedera JSON-RPC reference. Additionally, this library is meant to be included
|
8
|
+
in projects supporting WalletConnect and Hedera, providing utility functions useful to
|
9
|
+
validating requests and resposes in both the WalletConnect JSON-RPC context as well as the
|
10
|
+
Hedera context.
|
28
11
|
|
29
|
-
|
30
|
-
the Hedera ecosystem, there are distinct concepts regarding JSON-RPC APIs to consider:
|
12
|
+
A few useful resources include:
|
31
13
|
|
32
|
-
-
|
33
|
-
-
|
34
|
-
- Wallets in the Hedera ecosystem also support a separate specification that defines how to send
|
35
|
-
transactions and messages to wallets over the WalletConnect network without relying on a
|
36
|
-
Hedera JSON-RPC Relay provider. This is a Hedera specific specification defined for utilizing
|
37
|
-
the WalletConnect network distict from other JSON-RPC specs such as the one defined by the
|
38
|
-
Ethereum network.
|
14
|
+
- [HIP-820](https://hips.hedera.com/hip/hip-820)
|
15
|
+
- [WalletConnect <> Hedera JSON-RPC spec](https://specs.walletconnect.com/2.0/blockchain-rpc/hedera-rpc).
|
39
16
|
|
40
|
-
|
17
|
+
> WalletConnect brings the ecosystem together by enabling wallets and apps to securely connect
|
18
|
+
> and interact.
|
19
|
+
>
|
20
|
+
> -- <cite> https://walletconnect.com
|
41
21
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
projectId,
|
92
|
-
Object.values(HederaJsonRpcMethod),
|
93
|
-
[HederaSessionEvent.ChainChanged, HederaSessionEvent.AccountsChanged],
|
94
|
-
[HederaChainId.Mainnet, HederaChainId.Testnet],
|
95
|
-
)
|
96
|
-
|
97
|
-
await dAppConnector.init({ logger: 'error' })
|
98
|
-
```
|
99
|
-
|
100
|
-
3. Connect to a wallet
|
101
|
-
|
102
|
-
```typescript
|
103
|
-
await dAppConnector.openModal()
|
104
|
-
```
|
105
|
-
|
106
|
-
4. Handle sessions, events, and payloads.
|
107
|
-
|
108
|
-
- See: [DAppConnector](./src/lib/dapp/index.ts)
|
109
|
-
|
110
|
-
### Examples, demos, and tools
|
111
|
-
|
112
|
-
- [Hashgraph React Wallets by Buidler Labs](https://github.com/buidler-labs/hashgraph-react-wallets)
|
113
|
-
- [Hashgraph Online's WalletConnect SDK](https://github.com/hashgraph-online/hashinal-wc)
|
114
|
-
- <em>[Add an example, demo, or tool here](https://github.com/hashgraph/hedera-wallet-connect/pulls)</em>
|
115
|
-
|
116
|
-
## Using Reown's AppKit
|
117
|
-
|
118
|
-
1. Follow one of the quickstart instructions at
|
119
|
-
https://docs.reown.com/appkit/overview#quickstart
|
120
|
-
|
121
|
-
2. Add Hedera dependencies to your project:
|
122
|
-
|
123
|
-
```sh
|
124
|
-
npm install @hashgraph/hedera-wallet-connect@2.0.1-canary.24fffa7.0 @hashgraph/sdk @walletconnect/universal-provider
|
125
|
-
```
|
126
|
-
|
127
|
-
3. Update `createAppKit` with adapters and a universal provider for Hedera. Note the
|
128
|
-
HederaAdapter will need to come before the WagmiAdapter in the adapters array.
|
129
|
-
|
130
|
-
```typescript
|
131
|
-
import type UniversalProvider from '@walletconnect/universal-provider'
|
132
|
-
|
133
|
-
import {
|
134
|
-
HederaProvider,
|
135
|
-
HederaAdapter,
|
136
|
-
HederaChainDefinition,
|
137
|
-
hederaNamespace,
|
138
|
-
} from '@hashgraph/hedera-wallet-connect'
|
139
|
-
|
140
|
-
const metadata = {
|
141
|
-
name: 'AppKit w/ Hedera',
|
142
|
-
description: 'Hedera AppKit Example',
|
143
|
-
url: 'https://example.com', // origin must match your domain & subdomain
|
144
|
-
icons: ['https://avatars.githubusercontent.com/u/179229932']
|
145
|
-
}
|
146
|
-
|
147
|
-
const hederaEVMAdapter = new HederaAdapter({
|
148
|
-
projectId,
|
149
|
-
networks: [
|
150
|
-
HederaChainDefinition.EVM.Mainnet,
|
151
|
-
HederaChainDefinition.EVM.Testnet,
|
152
|
-
],
|
153
|
-
namespace: 'eip155',
|
154
|
-
})
|
155
|
-
|
156
|
-
const universalProvider = (await HederaProvider.init({
|
157
|
-
projectId: "YOUR_PROJECT_ID"
|
158
|
-
metadata,
|
159
|
-
})) as unknown as UniversalProvider, // avoid type mismatch error due to missing of private properties in HederaProvider
|
160
|
-
|
161
|
-
// ...
|
162
|
-
createAppKit({
|
163
|
-
adapters: [ hederaEVMAdapter ],
|
164
|
-
//@ts-expect-error expected type error
|
165
|
-
universalProvider,
|
166
|
-
projectId,
|
167
|
-
metadata,
|
168
|
-
networks: [
|
169
|
-
// EVM
|
170
|
-
HederaChainDefinition.EVM.Mainnet,
|
171
|
-
HederaChainDefinition.EVM.Testnet,
|
172
|
-
],
|
173
|
-
})
|
174
|
-
|
175
|
-
// ...
|
176
|
-
```
|
177
|
-
|
178
|
-
4. Recommended: Add Hedera Native WalletConnect Adapter
|
179
|
-
|
180
|
-
```typescript
|
181
|
-
import { HederaChainDefinition, hederaNamespace } from '@hashgraph/hedera-wallet-connect'
|
182
|
-
|
183
|
-
// ...
|
184
|
-
|
185
|
-
const hederaNativeAdapter = new HederaAdapter({
|
186
|
-
projectId,
|
187
|
-
networks: [HederaChainDefinition.Native.Mainnet, HederaChainDefinition.Native.Testnet],
|
188
|
-
namespace: hederaNamespace, // 'hedera' as CaipNamespace,
|
189
|
-
})
|
190
|
-
|
191
|
-
// ...
|
192
|
-
|
193
|
-
createAppKit({
|
194
|
-
adapters: [hederaEVMAdapter, hederaNativeAdapter],
|
195
|
-
projectId,
|
196
|
-
metadata,
|
197
|
-
networks: [
|
198
|
-
// EVM
|
199
|
-
HederaChainDefinition.EVM.Mainnet,
|
200
|
-
HederaChainDefinition.EVM.Testnet,
|
201
|
-
// Native
|
202
|
-
HederaChainDefinition.Native.Mainnet,
|
203
|
-
HederaChainDefinition.Native.Testnet,
|
204
|
-
],
|
205
|
-
})
|
206
|
-
```
|
207
|
-
|
208
|
-
### Examples, demos, and tools
|
209
|
-
|
210
|
-
- [Hedera App Example by Hgraph](https://github.com/hgraph-io/hedera-app)
|
211
|
-
- [Hedera Wallet Example by Hgraph](https://github.com/hgraph-io/hedera-wallet)
|
212
|
-
- <em>[Add an example, demo, or tool here](https://github.com/hashgraph/hedera-wallet-connect/pulls)</em>
|
213
|
-
|
214
|
-
# Hedera Wallets
|
215
|
-
|
216
|
-
- [Hashpack](https://hashpack.app/)
|
217
|
-
- [Kabila](https://wallet.kabila.app/)
|
218
|
-
- [Blade](https://bladewallet.io/)
|
219
|
-
- [Dropp](https://dropp.cc/)
|
220
|
-
|
221
|
-
# Upgrading from v1 to v2
|
222
|
-
|
223
|
-
Upgrading from v1 to v2 should be fairly straightforward. We have maintained compatibility with
|
224
|
-
the v1 structure, while deprecating a few methods marked as deprecated. The v1 library did not
|
225
|
-
explicitly offer support for Ethereum JSON-RPC function calls, so the only breaking changes
|
226
|
-
refer to how to send transactions to wallets using the `hedera:(mainnet|testnet)` namespace.
|
227
|
-
While minimal, the main breaking changes are:
|
228
|
-
|
229
|
-
- remove WalletConnect v1 modals
|
230
|
-
|
231
|
-
- these are very old, though in the spirit of semver, we kept the dependency until this
|
232
|
-
library's v2 release
|
233
|
-
|
234
|
-
- remove setting node id's within this library for transactions
|
235
|
-
|
236
|
-
- initially, a transaction created by the Hedera Javascript SDK needed to have one or more
|
237
|
-
consensus node ids set to be able to serialize into bytes, sent over a network, and
|
238
|
-
deserialized by the SDK
|
22
|
+
Hedera aims to be:
|
23
|
+
|
24
|
+
> The open source public ledger for everyone
|
25
|
+
>
|
26
|
+
> -- <cite> https://hedera.com
|
27
|
+
|
28
|
+
---
|
29
|
+
|
30
|
+
This package managed by the Hedera community and is intended to be a standard for ecosystem
|
31
|
+
wallets and dApp providers utilizing [WalletConnect](https://walletconnect.com) as a their
|
32
|
+
communications protocol. It utilizes the
|
33
|
+
[`@hashgraph/sdk`](https://www.npmjs.com/package/@hashgraph/sdk) and provides functions to
|
34
|
+
facilitate implementing the
|
35
|
+
[WalletConnect <> Hedera JSON-RPC spec](https://specs.walletconnect.com/2.0/blockchain-rpc/hedera-rpc)
|
36
|
+
which has been defined through the collaborative HIP process in
|
37
|
+
[HIP-820](https://hips.hedera.com/hip/hip-820).
|
38
|
+
|
39
|
+
This library facilitates the implementation of the **WalletConnect <> Hedera Spec** which allows
|
40
|
+
wallets and dApps to natively integrate with Hedera. It provides additional, out of network
|
41
|
+
functionality with the `hedera_signMessage` function.
|
42
|
+
|
43
|
+
In short, it uses the Hedera javascript SDK to build transactions, serialize them, send to
|
44
|
+
wallets for processing and return responses back to dApps.
|
45
|
+
|
46
|
+
_Please note, this is distinct from the
|
47
|
+
[Implementation of Ethereum JSON-RPC APIs for Hedera](https://github.com/hashgraph/hedera-json-rpc-relay).
|
48
|
+
At the time of this writing, "the Hedera JSON-RPC relay implementation is in beta, offers
|
49
|
+
limited functionality today, and is only available to developers."_
|
50
|
+
|
51
|
+
_The relay and this library have different intentions and serve different purposes - namely
|
52
|
+
native Hedera integration vs. Ethereum compatability layers to ease developer onboarding for
|
53
|
+
those more familiar with the Ethereum ecosystem._
|
54
|
+
|
55
|
+
# Documentation
|
56
|
+
|
57
|
+
WalletConnect <> Hedera docs are fully hosted on [https://hwc-docs.hgraph.app/](https://hwc-docs.hgraph.app/)
|
58
|
+
|
59
|
+
- [Installation](/docs/docs/installation.md)
|
60
|
+
- [dApp Guide](/docs/docs/dapp-guide.md)
|
61
|
+
- [Wallet Guide](/docs/docs/wallet-guide.md)
|
62
|
+
- [Signing Messages](/docs/docs/sign-messages.md)
|
63
|
+
- [Demos](/docs/docs/demos.md)
|
64
|
+
|
65
|
+
# Accessing the docs locally
|
66
|
+
|
67
|
+
- `cd docs`
|
68
|
+
- `npm install`
|
69
|
+
- `npm run docs`
|
70
|
+
- Navigating to `localhost:3000`
|
package/package.json
CHANGED