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