@hashgraph/hedera-wallet-connect 2.0.0-canary.811af2f.0 → 2.0.1-canary.0769c48.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 +134 -25
- package/dist/lib/dapp/index.d.ts +4 -2
- package/dist/lib/dapp/index.js +4 -2
- package/dist/lib/shared/payloads.d.ts +1 -1
- package/dist/lib/shared/utils.d.ts +3 -2
- package/dist/lib/shared/utils.js +4 -3
- package/dist/reown/adapter.js +1 -1
- package/dist/reown/providers/EIP155Provider.d.ts +1 -1
- package/dist/reown/wallets/EIP155Wallet.js +0 -12
- package/dist/reown/wallets/HIP820Wallet.d.ts +2 -2
- package/dist/reown/wallets/HIP820Wallet.js +3 -6
- package/package.json +11 -12
package/README.md
CHANGED
@@ -1,36 +1,119 @@
|
|
1
|
-
#
|
1
|
+
# Background
|
2
2
|
|
3
|
-
|
4
|
-
|
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
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
13
|
-
native transactions or use Ethereum JSON-RPC calls sent to a Hedera JSON-RPC
|
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
|
-
|
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
|
22
|
-
transactions to wallets over the WalletConnect
|
23
|
-
|
24
|
-
network
|
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
|
30
|
-
- [Hedera Native
|
31
|
-
- [
|
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)
|
45
|
+
- [Hedera Javascript SDK](https://www.npmjs.com/package/@hashgraph/sdk)
|
46
|
+
- [Reown Docs](https://docs.reown.com/overview)
|
47
|
+
- [WalletConnect Network](https://walletconnect.network/)
|
48
|
+
|
49
|
+
# Getting started
|
50
|
+
|
51
|
+
In addition to choosing between the Hedera native JSON-RPC spec and the Ethereum JSON-RPC spec,
|
52
|
+
when building with javascript/typescript, there are 2 supported options to utilize the
|
53
|
+
WalletConnect network to send information from apps to wallets and back.
|
54
|
+
|
55
|
+
This README assumes an understanding of Hedera as well as the WalletConnect network and focusses
|
56
|
+
on how to send a payload to a wallet for processing and presentation to an end user that is a
|
57
|
+
Hedera account holder. We recommend reviewing the [Hedera Docs](https://docs.hedera.com/) and
|
58
|
+
first submitting transactions directly to the Hedera network without requiring interaction with
|
59
|
+
a [Wallet](#hedera-wallets) when integrating Hedera for the first time. We also recommend
|
60
|
+
reviewing the [Reown docs](https://docs.reown.com/overview).
|
61
|
+
|
62
|
+
## Using this library and underlying WalletConnect libraries directly
|
63
|
+
|
64
|
+
1. Add Hedera dependencies to your project:
|
65
|
+
|
66
|
+
```sh
|
67
|
+
npm install @hashgraph/hedera-wallet-connect@2.0.0-canary.811af2f.0 @hashgraph/sdk @walletconnect/modal
|
68
|
+
```
|
32
69
|
|
33
|
-
|
70
|
+
2. Initialize dApp Connector
|
71
|
+
|
72
|
+
```typescript
|
73
|
+
import {
|
74
|
+
HederaSessionEvent,
|
75
|
+
HederaJsonRpcMethod,
|
76
|
+
DAppConnector,
|
77
|
+
HederaChainId,
|
78
|
+
} from '@hashgraph/hedera-wallet-connect'
|
79
|
+
import { LedgerId } from '@hashgraph/sdk'
|
80
|
+
|
81
|
+
const metadata = {
|
82
|
+
name: 'Hedera Integration using Hedera DAppConnector - v1 approach',
|
83
|
+
description: 'Hedera dAppConnector Example',
|
84
|
+
url: 'https://example.com', // origin must match your domain & subdomain
|
85
|
+
icons: ['https://avatars.githubusercontent.com/u/31002956'],
|
86
|
+
}
|
87
|
+
|
88
|
+
const dAppConnector = new DAppConnector(
|
89
|
+
metadata,
|
90
|
+
LedgerId.Mainnet,
|
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
|
34
117
|
|
35
118
|
1. Follow one of the quickstart instructions at
|
36
119
|
https://docs.reown.com/appkit/overview#quickstart
|
@@ -38,7 +121,7 @@ For more information see:
|
|
38
121
|
2. Add Hedera dependencies to your project:
|
39
122
|
|
40
123
|
```sh
|
41
|
-
npm install
|
124
|
+
npm install @hashgraph/hedera-wallet-connect@2.0.1-canary.24fffa7.0 @hashgraph/sdk @walletconnect/universal-provider
|
42
125
|
```
|
43
126
|
|
44
127
|
3. Update `createAppKit` with adapters and a universal provider for Hedera. Note the
|
@@ -122,8 +205,34 @@ createAppKit({
|
|
122
205
|
})
|
123
206
|
```
|
124
207
|
|
125
|
-
|
208
|
+
### Examples, demos, and tools
|
126
209
|
|
127
|
-
- [
|
128
|
-
- [
|
129
|
-
- [
|
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
|
package/dist/lib/dapp/index.d.ts
CHANGED
@@ -11,6 +11,7 @@ export { SessionNotFoundError } from './SessionNotFoundError';
|
|
11
11
|
type BaseLogger = 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'fatal';
|
12
12
|
export declare class DAppConnector {
|
13
13
|
private logger;
|
14
|
+
readonly storagePrefix = "hedera-wc/dapp-connector/";
|
14
15
|
dAppMetadata: SignClientTypes.Metadata;
|
15
16
|
network: LedgerId;
|
16
17
|
projectId: string;
|
@@ -23,7 +24,6 @@ export declare class DAppConnector {
|
|
23
24
|
walletConnectModal: WalletConnectModal;
|
24
25
|
signers: DAppSigner[];
|
25
26
|
isInitializing: boolean;
|
26
|
-
private storagePrefix;
|
27
27
|
/**
|
28
28
|
* Initializes the DAppConnector instance.
|
29
29
|
* @param metadata - SignClientTypes.Metadata object for the DApp metadata.
|
@@ -194,7 +194,9 @@ export declare class DAppConnector {
|
|
194
194
|
*
|
195
195
|
* @param {SignTransactionParams} params - The parameters of type {@link SignTransactionParams | `SignTransactionParams`} required for `Transaction` signing.
|
196
196
|
* @param {string} params.signerAccountId - a signer Hedera Account identifier in {@link https://hips.hedera.com/hip/hip-30 | HIP-30} (`<nework>:<shard>.<realm>.<num>`) form.
|
197
|
-
* @param {Transaction} params.transactionBody - a Transaction object
|
197
|
+
* @param {Transaction | string} params.transactionBody - a built Transaction object, or a base64 string of a transaction body( HIP-820).
|
198
|
+
* HIP-820 calls for a base64 encoded proto.TransactionBody and many wallets support a serialized Transaction object generated by the Hedera Javascript SDK.
|
199
|
+
* Both options are supported here for backwards compatibility.
|
198
200
|
* @returns Promise\<{@link SignTransactionResult}\>
|
199
201
|
* @example
|
200
202
|
* ```ts
|
package/dist/lib/dapp/index.js
CHANGED
@@ -39,6 +39,7 @@ export class DAppConnector {
|
|
39
39
|
* @param logLevel - Logging level for the DAppConnector (optional).
|
40
40
|
*/
|
41
41
|
constructor(metadata, network, projectId, methods, events, chains, logLevel = 'debug') {
|
42
|
+
this.storagePrefix = 'hedera-wc/dapp-connector/';
|
42
43
|
this.network = LedgerId.TESTNET;
|
43
44
|
this.supportedMethods = [];
|
44
45
|
this.supportedEvents = [];
|
@@ -47,7 +48,6 @@ export class DAppConnector {
|
|
47
48
|
this.onSessionIframeCreated = null;
|
48
49
|
this.signers = [];
|
49
50
|
this.isInitializing = false;
|
50
|
-
this.storagePrefix = 'hedera-wc/dapp-connector/';
|
51
51
|
this.abortableConnect = async (callback) => {
|
52
52
|
return new Promise(async (resolve, reject) => {
|
53
53
|
const pairTimeoutMs = 480000;
|
@@ -501,7 +501,9 @@ export class DAppConnector {
|
|
501
501
|
*
|
502
502
|
* @param {SignTransactionParams} params - The parameters of type {@link SignTransactionParams | `SignTransactionParams`} required for `Transaction` signing.
|
503
503
|
* @param {string} params.signerAccountId - a signer Hedera Account identifier in {@link https://hips.hedera.com/hip/hip-30 | HIP-30} (`<nework>:<shard>.<realm>.<num>`) form.
|
504
|
-
* @param {Transaction} params.transactionBody - a Transaction object
|
504
|
+
* @param {Transaction | string} params.transactionBody - a built Transaction object, or a base64 string of a transaction body( HIP-820).
|
505
|
+
* HIP-820 calls for a base64 encoded proto.TransactionBody and many wallets support a serialized Transaction object generated by the Hedera Javascript SDK.
|
506
|
+
* Both options are supported here for backwards compatibility.
|
505
507
|
* @returns Promise\<{@link SignTransactionResult}\>
|
506
508
|
* @example
|
507
509
|
* ```ts
|
@@ -84,7 +84,7 @@ export interface SignAndExecuteTransactionResponse extends EngineTypes.RespondPa
|
|
84
84
|
}
|
85
85
|
export interface SignTransactionParams {
|
86
86
|
signerAccountId: string;
|
87
|
-
transactionBody: Transaction;
|
87
|
+
transactionBody: Transaction | string;
|
88
88
|
}
|
89
89
|
export interface SignTransactionRequest extends EngineTypes.RequestParams {
|
90
90
|
request: {
|
@@ -4,7 +4,7 @@ import { proto } from '@hashgraph/proto';
|
|
4
4
|
/**
|
5
5
|
* Converts `Transaction` to a Base64-string.
|
6
6
|
*
|
7
|
-
* Converts a transaction to bytes and then encodes it as a Base64-string. Allow
|
7
|
+
* Converts a transaction to bytes and then encodes it as a Base64-string. Allow incomplete transaction (HIP-745).
|
8
8
|
* @param transaction - Any instance of a class that extends `Transaction`
|
9
9
|
* @returns Base64 encoded representation of the input `Transaction` object
|
10
10
|
*/
|
@@ -29,9 +29,10 @@ export declare function transactionToBase64String<T extends Transaction>(transac
|
|
29
29
|
export declare function base64StringToTransaction<T extends Transaction>(transactionBytes: string): T;
|
30
30
|
/**
|
31
31
|
* @param transaction - a base64 encoded string of proto.TransactionBody.encode().finish()
|
32
|
+
* @param nodeAccountId - an optional `AccountId` to set the node account ID for the transaction
|
32
33
|
* @returns `string`
|
33
34
|
* */
|
34
|
-
export declare function transactionToTransactionBody<T extends Transaction>(transaction: T):
|
35
|
+
export declare function transactionToTransactionBody<T extends Transaction>(transaction: T, nodeAccountId?: AccountId | null): proto.ITransactionBody;
|
35
36
|
export declare function transactionBodyToBase64String(transactionBody: proto.ITransactionBody): string;
|
36
37
|
/**
|
37
38
|
* @param transactionList - a proto.TransactionList object
|
package/dist/lib/shared/utils.js
CHANGED
@@ -23,7 +23,7 @@ import { proto } from '@hashgraph/proto';
|
|
23
23
|
/**
|
24
24
|
* Converts `Transaction` to a Base64-string.
|
25
25
|
*
|
26
|
-
* Converts a transaction to bytes and then encodes it as a Base64-string. Allow
|
26
|
+
* Converts a transaction to bytes and then encodes it as a Base64-string. Allow incomplete transaction (HIP-745).
|
27
27
|
* @param transaction - Any instance of a class that extends `Transaction`
|
28
28
|
* @returns Base64 encoded representation of the input `Transaction` object
|
29
29
|
*/
|
@@ -54,12 +54,13 @@ export function base64StringToTransaction(transactionBytes) {
|
|
54
54
|
}
|
55
55
|
/**
|
56
56
|
* @param transaction - a base64 encoded string of proto.TransactionBody.encode().finish()
|
57
|
+
* @param nodeAccountId - an optional `AccountId` to set the node account ID for the transaction
|
57
58
|
* @returns `string`
|
58
59
|
* */
|
59
|
-
export function transactionToTransactionBody(transaction) {
|
60
|
+
export function transactionToTransactionBody(transaction, nodeAccountId = null) {
|
60
61
|
// This is a private function, though provides the capabilities to construct a proto.TransactionBody
|
61
62
|
//@ts-ignore
|
62
|
-
return transaction._makeTransactionBody(
|
63
|
+
return transaction._makeTransactionBody(nodeAccountId);
|
63
64
|
}
|
64
65
|
export function transactionBodyToBase64String(transactionBody) {
|
65
66
|
return Uint8ArrayToBase64String(proto.TransactionBody.encode(transactionBody).finish());
|
package/dist/reown/adapter.js
CHANGED
@@ -28,7 +28,7 @@ export class HederaAdapter extends AdapterBlueprint {
|
|
28
28
|
setUniversalProvider(universalProvider) {
|
29
29
|
this.addConnector(new HederaConnector({
|
30
30
|
provider: universalProvider,
|
31
|
-
caipNetworks: this.
|
31
|
+
caipNetworks: this.getCaipNetworks() || [],
|
32
32
|
namespace: this.namespace,
|
33
33
|
}));
|
34
34
|
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { EventEmitter } from 'events';
|
2
|
-
import Client from '@walletconnect/
|
2
|
+
import Client from '@walletconnect/sign-client';
|
3
3
|
import { SessionTypes } from '@walletconnect/types';
|
4
4
|
import { IProvider, SessionNamespace, RpcProvidersMap, RequestParams, Namespace } from '@walletconnect/universal-provider';
|
5
5
|
declare class EIP155Provider implements IProvider {
|
@@ -28,7 +28,6 @@ export class EIP155Wallet {
|
|
28
28
|
return this.eth_signTypedData(domain, types, data);
|
29
29
|
}
|
30
30
|
async eth_signTransaction(transaction, provider) {
|
31
|
-
console.log({ transaction });
|
32
31
|
// Populate transaction
|
33
32
|
const preparedTransaction = await this.connect(provider).populateTransaction(transaction);
|
34
33
|
delete preparedTransaction.from;
|
@@ -68,11 +67,9 @@ export class EIP155Wallet {
|
|
68
67
|
return formatJsonRpcResult(id, signedMessage);
|
69
68
|
}
|
70
69
|
catch (error) {
|
71
|
-
console.error(error);
|
72
70
|
if (!(error instanceof Error)) {
|
73
71
|
return formatJsonRpcError(id, 'Failed to sign message');
|
74
72
|
}
|
75
|
-
alert(error.message);
|
76
73
|
return formatJsonRpcError(id, error.message);
|
77
74
|
}
|
78
75
|
case Eip155JsonRpcMethod.SignTypedData:
|
@@ -86,11 +83,9 @@ export class EIP155Wallet {
|
|
86
83
|
return formatJsonRpcResult(id, signedData);
|
87
84
|
}
|
88
85
|
catch (error) {
|
89
|
-
console.error(error);
|
90
86
|
if (!(error instanceof Error)) {
|
91
87
|
return formatJsonRpcError(id, 'Failed to sign typed data');
|
92
88
|
}
|
93
|
-
alert(error.message);
|
94
89
|
return formatJsonRpcError(id, error.message);
|
95
90
|
}
|
96
91
|
case Eip155JsonRpcMethod.SendRawTransaction:
|
@@ -100,14 +95,9 @@ export class EIP155Wallet {
|
|
100
95
|
const sendTransaction = request.params[0];
|
101
96
|
const txResponse = await this[request.method](sendTransaction, provider);
|
102
97
|
const txHash = typeof txResponse === 'string' ? txResponse : txResponse === null || txResponse === void 0 ? void 0 : txResponse.hash;
|
103
|
-
const txReceipt = await txResponse.wait();
|
104
|
-
console.log(`Transaction broadcasted on chain ${chainId} , ${{
|
105
|
-
txHash,
|
106
|
-
}}, status: ${txReceipt === null || txReceipt === void 0 ? void 0 : txReceipt.status}`);
|
107
98
|
return formatJsonRpcResult(id, txHash);
|
108
99
|
}
|
109
100
|
catch (error) {
|
110
|
-
console.error(error);
|
111
101
|
return formatJsonRpcError(id, error instanceof Error ? error.message : 'Failed to send transaction');
|
112
102
|
}
|
113
103
|
case Eip155JsonRpcMethod.SignTransaction:
|
@@ -118,11 +108,9 @@ export class EIP155Wallet {
|
|
118
108
|
return formatJsonRpcResult(id, signature);
|
119
109
|
}
|
120
110
|
catch (error) {
|
121
|
-
console.error(error);
|
122
111
|
if (!(error instanceof Error)) {
|
123
112
|
return formatJsonRpcError(id, 'Failed to sign transaction');
|
124
113
|
}
|
125
|
-
alert(error.message);
|
126
114
|
return formatJsonRpcError(id, error.message);
|
127
115
|
}
|
128
116
|
default:
|
@@ -1,11 +1,11 @@
|
|
1
|
-
import { Wallet as HederaWallet, AccountId, Transaction, Query } from '@hashgraph/sdk';
|
1
|
+
import { Wallet as HederaWallet, AccountId, Transaction, Query, PrivateKey } from '@hashgraph/sdk';
|
2
2
|
import { JsonRpcError, JsonRpcResult } from '@walletconnect/jsonrpc-utils';
|
3
3
|
import { HederaChainId, HederaJsonRpcMethod, GetNodeAddressesResult, ExecuteTransactionResult, SignAndExecuteQueryResult, SignMessageResult, SignAndExecuteTransactionResult, SignTransactionResult, WalletRequestEventArgs } from '../..';
|
4
4
|
import Provider from '../../lib/wallet/provider';
|
5
5
|
interface IInitArgs {
|
6
6
|
chainId: HederaChainId;
|
7
7
|
accountId: AccountId | string;
|
8
|
-
privateKey:
|
8
|
+
privateKey: PrivateKey;
|
9
9
|
_provider?: Provider;
|
10
10
|
}
|
11
11
|
export interface HIP820WalletInterface {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { Buffer } from 'buffer';
|
2
2
|
import { getSdkError } from '@walletconnect/utils';
|
3
|
-
import { Wallet as HederaWallet, Client, AccountId, PrecheckStatusError,
|
3
|
+
import { Wallet as HederaWallet, Client, AccountId, PrecheckStatusError, } from '@hashgraph/sdk';
|
4
4
|
import { proto } from '@hashgraph/proto';
|
5
5
|
import { formatJsonRpcError, formatJsonRpcResult, } from '@walletconnect/jsonrpc-utils';
|
6
6
|
import { HederaJsonRpcMethod, base64StringToQuery, Uint8ArrayToBase64String, stringToSignerMessage, signerSignaturesToSignatureMap, getHederaError, base64StringToTransaction, signatureMapToBase64String, } from '../..';
|
@@ -22,7 +22,7 @@ export class HIP820Wallet {
|
|
22
22
|
const network = chainId.split(':')[1];
|
23
23
|
const client = Client.forName(network);
|
24
24
|
const provider = _provider !== null && _provider !== void 0 ? _provider : new Provider(client);
|
25
|
-
const wallet = new HederaWallet(accountId,
|
25
|
+
const wallet = new HederaWallet(accountId, privateKey, provider);
|
26
26
|
return new HIP820Wallet(wallet);
|
27
27
|
}
|
28
28
|
/*
|
@@ -118,7 +118,6 @@ export class HIP820Wallet {
|
|
118
118
|
async approveSessionRequest(event) {
|
119
119
|
const { method, id, body } = this.parseSessionRequest(event);
|
120
120
|
const response = await this[method](id, body);
|
121
|
-
console.log({ response });
|
122
121
|
return response;
|
123
122
|
}
|
124
123
|
rejectSessionRequest(requestEvent) {
|
@@ -134,7 +133,6 @@ export class HIP820Wallet {
|
|
134
133
|
_) {
|
135
134
|
const nodesAccountIds = this.wallet.getNetwork();
|
136
135
|
const nodes = Object.values(nodesAccountIds).map((nodeAccountId) => nodeAccountId.toString());
|
137
|
-
console.log(nodes);
|
138
136
|
return formatJsonRpcResult(id, {
|
139
137
|
nodes,
|
140
138
|
});
|
@@ -142,7 +140,7 @@ export class HIP820Wallet {
|
|
142
140
|
// 2. hedera_executeTransaction
|
143
141
|
async hedera_executeTransaction(id, signedTransaction) {
|
144
142
|
try {
|
145
|
-
const response = await
|
143
|
+
const response = await this.wallet.call(signedTransaction);
|
146
144
|
return formatJsonRpcResult(id, response.toJSON());
|
147
145
|
}
|
148
146
|
catch (e) {
|
@@ -203,7 +201,6 @@ export class HIP820Wallet {
|
|
203
201
|
}
|
204
202
|
// 5. hedera_signAndExecuteTransaction
|
205
203
|
async hedera_signAndExecuteTransaction(id, transaction) {
|
206
|
-
console.log({ inputTx: JSON.parse(JSON.stringify(transaction)) });
|
207
204
|
// check transaction is incomplete (HIP-745)
|
208
205
|
if (!transaction.isFrozen()) {
|
209
206
|
// set multiple nodeAccountIds and transactionId if not present
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@hashgraph/hedera-wallet-connect",
|
3
|
-
"version": "2.0.
|
4
|
-
"description": "A library to facilitate integrating Hedera",
|
3
|
+
"version": "2.0.1-canary.0769c48.0",
|
4
|
+
"description": "A library to facilitate integrating Hedera with WalletConnect",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
7
7
|
"url": "git+https://github.com/hashgraph/hedera-wallet-connect.git"
|
@@ -14,31 +14,30 @@
|
|
14
14
|
"walletconnect",
|
15
15
|
"reown",
|
16
16
|
"hashgraph",
|
17
|
-
"evm",
|
18
|
-
"ethereum",
|
19
|
-
"smart contracts",
|
20
17
|
"hbar",
|
21
|
-
"
|
18
|
+
"evm",
|
19
|
+
"smart contracts"
|
22
20
|
],
|
23
21
|
"license": "Apache-2.0",
|
24
22
|
"scripts": {
|
25
23
|
"build": "rimraf dist && tsc",
|
26
24
|
"watch": "nodemon --watch src/ --ext ts --exec \"npm run build\"",
|
27
|
-
"test": "jest",
|
28
|
-
"prepublishOnly": "rm -Rf dist && npm run build",
|
25
|
+
"test": "jest --coverage",
|
26
|
+
"prepublishOnly": "rm -Rf dist && npm run test && npm run build",
|
29
27
|
"prettier:check": "prettier --check ./src/",
|
30
28
|
"prettier:fix": "prettier --write ./src/"
|
31
29
|
},
|
32
30
|
"peerDependencies": {
|
33
|
-
"@hashgraph/sdk": "^2.
|
34
|
-
"@reown/appkit": "
|
35
|
-
"@reown/walletkit": "
|
31
|
+
"@hashgraph/sdk": "^2.63.0",
|
32
|
+
"@reown/appkit": "1.7.3",
|
33
|
+
"@reown/walletkit": "1.2.3",
|
36
34
|
"@walletconnect/modal": "^2.7.0",
|
37
35
|
"ethers": "^6.13.5"
|
38
36
|
},
|
39
37
|
"devDependencies": {
|
40
38
|
"@swc/jest": "^0.2.37",
|
41
|
-
"jest": "^
|
39
|
+
"@types/jest": "^30.0.0",
|
40
|
+
"jest": "^30.0.3",
|
42
41
|
"prettier": "^3.5.3",
|
43
42
|
"ts-node": "^10.9.2",
|
44
43
|
"typescript": "^5.8.2"
|