@hashgraph/hedera-wallet-connect 2.0.0-canary.811af2f.0 → 2.0.1-canary.1c9f580.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.
Files changed (2) hide show
  1. package/README.md +131 -24
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,36 +1,117 @@
1
- # Overview
1
+ # Background
2
2
 
3
- Hedera is a public distributed ledger that is EVM compatible. This library provides tools to
4
- integrate Hedera using Reown's AppKit and WalletKit.
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.
5
8
 
6
- There are 2 distict paths to integrate Hedera. Hedera natively operates using a gRPC based API
7
- for write transactions and a REST API for read transactions. To acheive EVM compatibility, there
8
- is a software middlelayer called the Hedera JSON-RPC Relay that translates Ethereum JSON-RPC
9
- compatible API calls into the Hedera gRPC and REST API calls.
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.
21
+
22
+ ## Ethereum JSON-RPC vs. Hedera JSON-RPC vs. Hedera JSON-RPC Relay
10
23
 
11
24
  When integrating, app developers can choose to use the Hedera native approach and send
12
- transactions to wallets over the WalletConnect relays using the JSON-RPC spec defined for Hedera
13
- native transactions or use Ethereum JSON-RPC calls sent to a Hedera JSON-RPC provider which then
14
- communicates with Hedera consensus and mirror nodes.
25
+ transactions to wallets over the WalletConnect network using the JSON-RPC spec defined for
26
+ Hedera native transactions or use Ethereum JSON-RPC calls sent to a Hedera JSON-RPC Relay
27
+ provider which then communicates with Hedera consensus and mirror nodes.
15
28
 
16
- In short, JSON-RPC is a type of API stucture, such as SOAP, gRPC, REST, GraphQL, etc. In the
17
- Hedera ecosystem, there are distinct concepts regarding JSON-RPC APIs to consider:
29
+ On a high level, JSON-RPC is a type of API stucture, such as SOAP, gRPC, REST, GraphQL, etc. In
30
+ the Hedera ecosystem, there are distinct concepts regarding JSON-RPC APIs to consider:
18
31
 
19
32
  - Ethereum JSON-RPC spec defines how to interact with Ethereum compatible networks
20
33
  - Hedera JSON-RPC Relay implements the Ethereum JSON-RPC spec for Hedera
21
- - Wallets in the Hedera ecosystem support a separate JSON-RPC spec that defines how to send
22
- transactions to wallets over the WalletConnect relays. This is a Hedera specific spec that is
23
- not compatible with the Ethereum JSON-RPC spec, rather is used to interact with the Hedera
24
- network without the JSON-RPC Relay.
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.
25
39
 
26
40
  For more information see:
27
41
 
28
42
  - [Ethereum JSON-RPC Specification ](https://ethereum.github.io/execution-apis/api-documentation/)
29
- - [Hedera EVM: JSON-RPC relay](https://docs.hedera.com/hedera/core-concepts/smart-contracts/json-rpc-relay)
30
- - [Hedera Native: JSON-RPC spec](https://docs.reown.com/advanced/multichain/rpc-reference/hedera-rpc).
43
+ - [Hedera JSON-RPC relay](https://docs.hedera.com/hedera/core-concepts/smart-contracts/json-rpc-relay)
44
+ - [Hedera Native JSON-RPC spec for WalletConnect](https://docs.reown.com/advanced/multichain/rpc-reference/hedera-rpc)
31
45
  - [@hashgraph/sdk](https://www.npmjs.com/package/@hashgraph/sdk)
32
46
 
33
- ## Getting started
47
+ # Getting started
48
+
49
+ In addition to choosing between the Hedera native JSON-RPC spec and the Ethereum JSON-RPC spec,
50
+ when building with javascript/typescript, there are 2 supported options to utilize the
51
+ WalletConnect network to send information from apps to wallets and back.
52
+
53
+ This README assumes an understanding of Hedera as well as the WalletConnect network and focusses
54
+ on how to send a payload to a wallet for processing and presentation to an end user that is a
55
+ Hedera account holder. We recommend reviewing the [Hedera Docs](https://docs.hedera.com/) and
56
+ first submitting transactions directly to the Hedera network without requiring interaction with
57
+ a [Wallet](#hedera-wallets) when integrating Hedera for the first time. We also recommend
58
+ reviewing the [Reown docs](https://docs.reown.com/overview).
59
+
60
+ ## Using this library and underlying WalletConnect libraries directly
61
+
62
+ 1. Add Hedera dependencies to your project:
63
+
64
+ ```sh
65
+ npm install @hashgraph/hedera-wallet-connect@2.0.0-canary.811af2f.0 @hashgraph/sdk @walletconnect/modal
66
+ ```
67
+
68
+ 2. Initialize dApp Connector
69
+
70
+ ```typescript
71
+ import {
72
+ HederaSessionEvent,
73
+ HederaJsonRpcMethod,
74
+ DAppConnector,
75
+ HederaChainId,
76
+ } from '@hashgraph/hedera-wallet-connect'
77
+ import { LedgerId } from '@hashgraph/sdk'
78
+
79
+ const metadata = {
80
+ name: 'Hedera Integration using Hedera DAppConnector - v1 approach',
81
+ description: 'Hedera dAppConnector Example',
82
+ url: 'https://example.com', // origin must match your domain & subdomain
83
+ icons: ['https://avatars.githubusercontent.com/u/31002956'],
84
+ }
85
+
86
+ const dAppConnector = new DAppConnector(
87
+ metadata,
88
+ LedgerId.Mainnet,
89
+ projectId,
90
+ Object.values(HederaJsonRpcMethod),
91
+ [HederaSessionEvent.ChainChanged, HederaSessionEvent.AccountsChanged],
92
+ [HederaChainId.Mainnet, HederaChainId.Testnet],
93
+ )
94
+
95
+ await dAppConnector.init({ logger: 'error' })
96
+ ```
97
+
98
+ 3. Connect to a wallet
99
+
100
+ ```typescript
101
+ await dAppConnector.openModal()
102
+ ```
103
+
104
+ 4. Handle sessions, events, and payloads.
105
+
106
+ - See: [DAppConnector](./src/lib/dapp/index.ts)
107
+
108
+ ### Examples, demos, and tools
109
+
110
+ - [Hashgraph React Wallets by Buidler Labs](https://github.com/buidler-labs/hashgraph-react-wallets)
111
+ - [Hashgraph Online's WalletConnect SDK](https://github.com/hashgraph-online/hashinal-wc)
112
+ - <em>[Add an example, demo, or tool here](https://github.com/hashgraph/hedera-wallet-connect/pulls)</em>
113
+
114
+ ## Using Reown's AppKit
34
115
 
35
116
  1. Follow one of the quickstart instructions at
36
117
  https://docs.reown.com/appkit/overview#quickstart
@@ -38,7 +119,7 @@ For more information see:
38
119
  2. Add Hedera dependencies to your project:
39
120
 
40
121
  ```sh
41
- npm install file:../../hedera-wallet-connect @hashgraph/sdk @walletconnect/universal-provider
122
+ npm install @hashgraph/hedera-wallet-connect@2.0.0-canary.811af2f.0 @hashgraph/sdk @walletconnect/universal-provider
42
123
  ```
43
124
 
44
125
  3. Update `createAppKit` with adapters and a universal provider for Hedera. Note the
@@ -122,8 +203,34 @@ createAppKit({
122
203
  })
123
204
  ```
124
205
 
125
- ## Examples and Demos
206
+ ### Examples, demos, and tools
126
207
 
127
- - [Example App by Hgraph](https://github.com/hgraph-io/hedera-app)
128
- - [Example Wallet by Hgraph](https://github.com/hgraph-io/hedera-wallet)
129
- - [Hashgraph React Wallets by Buidler Labs](https://github.com/buidler-labs/hashgraph-react-wallets)
208
+ - [Hedera App Example by Hgraph](https://github.com/hgraph-io/hedera-app)
209
+ - [Hedera Wallet Example by Hgraph](https://github.com/hgraph-io/hedera-wallet)
210
+ - <em>[Add an example, demo, or tool here](https://github.com/hashgraph/hedera-wallet-connect/pulls)</em>
211
+
212
+ # Hedera Wallets
213
+
214
+ - [Hashpack](https://hashpack.app/)
215
+ - [Kabila](https://wallet.kabila.app/)
216
+ - [Blade](https://bladewallet.io/)
217
+ - [Dropp](https://dropp.cc/)
218
+
219
+ # Upgrading from v1 to v2
220
+
221
+ Upgrading from v1 to v2 should be fairly straightforward. We have maintained compatibility with
222
+ the v1 structure, while deprecating a few methods marked as deprecated. The v1 library did not
223
+ explicitly offer support for Ethereum JSON-RPC function calls, so the only breaking changes
224
+ refer to how to send transactions to wallets using the `hedera:(mainnet|testnet)` namespace.
225
+ While minimal, the main breaking changes are:
226
+
227
+ - remove WalletConnect v1 modals
228
+
229
+ - these are very old, though in the spirit of semver, we kept the dependency until this
230
+ library's v2 release
231
+
232
+ - remove setting node id's within this library for transactions
233
+
234
+ - initially, a transaction created by the Hedera javascript SDK needed to have a node id or
235
+ set of node ids set to be able to serialize into bytes to be passed sent over a network and
236
+ deserialized by the SDK.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hashgraph/hedera-wallet-connect",
3
- "version": "2.0.0-canary.811af2f.0",
3
+ "version": "2.0.1-canary.1c9f580.0",
4
4
  "description": "A library to facilitate integrating Hedera",
5
5
  "repository": {
6
6
  "type": "git",