@hashgraph/hedera-wallet-connect 2.0.1-canary.e271b17.0 → 2.0.1-canary.fc2f418.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 CHANGED
@@ -22,9 +22,9 @@ Hedera gRPC and REST API calls.
22
22
  ## Ethereum JSON-RPC vs. Hedera JSON-RPC vs. Hedera JSON-RPC Relay
23
23
 
24
24
  When integrating, app developers can choose to use the Hedera native approach and send
25
- transactions to wallets over the WalletConnect relays using the JSON-RPC spec defined for Hedera
26
- native transactions or use Ethereum JSON-RPC calls sent to a Hedera JSON-RPC Relay provider
27
- which then 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.
28
28
 
29
29
  On a high level, JSON-RPC is a type of API stucture, such as SOAP, gRPC, REST, GraphQL, etc. In
30
30
  the Hedera ecosystem, there are distinct concepts regarding JSON-RPC APIs to consider:
@@ -42,7 +42,9 @@ For more information see:
42
42
  - [Ethereum JSON-RPC Specification ](https://ethereum.github.io/execution-apis/api-documentation/)
43
43
  - [Hedera JSON-RPC relay](https://docs.hedera.com/hedera/core-concepts/smart-contracts/json-rpc-relay)
44
44
  - [Hedera Native JSON-RPC spec for WalletConnect](https://docs.reown.com/advanced/multichain/rpc-reference/hedera-rpc)
45
- - [@hashgraph/sdk](https://www.npmjs.com/package/@hashgraph/sdk)
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/)
46
48
 
47
49
  # Getting started
48
50
 
@@ -50,16 +52,14 @@ In addition to choosing between the Hedera native JSON-RPC spec and the Ethereum
50
52
  when building with javascript/typescript, there are 2 supported options to utilize the
51
53
  WalletConnect network to send information from apps to wallets and back.
52
54
 
53
- This README assumes a basic understanding of how to create transactions on Hedera as well as
54
- handling sessions, payloads, and other transport layer details on the WalletConnect network and
55
- focusses on how to send a payload to a wallet for processing and presentation to an end user
56
- that is a Hedera account holder. We recommend reviewing the
57
- [Hedera Docs](https://docs.hedera.com/) and first submitting transactions directly to the Hedera
58
- network without requiring interaction with a [Wallet](#hedera-wallets) when integrating Hedera
59
- for the first time. We also recommend reviewing the
60
- [Reown docs](https://docs.reown.com/overview).
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
61
 
62
- ## Using this library and WalletConnect libraries directly
62
+ ## Using this library and underlying WalletConnect libraries directly
63
63
 
64
64
  1. Add Hedera dependencies to your project:
65
65
 
@@ -233,6 +233,6 @@ While minimal, the main breaking changes are:
233
233
 
234
234
  - remove setting node id's within this library for transactions
235
235
 
236
- - initially, a transaction created by the Hedera javascript SDK needed to have a node id or
237
- set of node id's set to be able to serialize into bytes to be passed sent over a network and
238
- deserialized by the SDK.
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
@@ -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.
@@ -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;
@@ -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.caipNetworks || [],
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/universal-provider/node_modules/@walletconnect/sign-client';
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:
@@ -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, PrivateKey.fromStringECDSA(privateKey), provider);
25
+ const wallet = new HederaWallet(accountId, PrivateKey.fromString(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
  });
@@ -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,6 +1,6 @@
1
1
  {
2
2
  "name": "@hashgraph/hedera-wallet-connect",
3
- "version": "2.0.1-canary.e271b17.0",
3
+ "version": "2.0.1-canary.fc2f418.0",
4
4
  "description": "A library to facilitate integrating Hedera",
5
5
  "repository": {
6
6
  "type": "git",
@@ -25,19 +25,20 @@
25
25
  "build": "rimraf dist && tsc",
26
26
  "watch": "nodemon --watch src/ --ext ts --exec \"npm run build\"",
27
27
  "test": "jest",
28
- "prepublishOnly": "rm -Rf dist && npm run build",
28
+ "prepublishOnly": "rm -Rf dist && npm run test && npm run build",
29
29
  "prettier:check": "prettier --check ./src/",
30
30
  "prettier:fix": "prettier --write ./src/"
31
31
  },
32
32
  "peerDependencies": {
33
- "@hashgraph/sdk": "^2.61.0",
34
- "@reown/appkit": "^1.7.1",
35
- "@reown/walletkit": "^1.2.3",
33
+ "@hashgraph/sdk": "^2.63.0",
34
+ "@reown/appkit": "1.7.3",
35
+ "@reown/walletkit": "1.2.3",
36
36
  "@walletconnect/modal": "^2.7.0",
37
37
  "ethers": "^6.13.5"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@swc/jest": "^0.2.37",
41
+ "@types/jest": "^29.5.14",
41
42
  "jest": "^29.7.0",
42
43
  "prettier": "^3.5.3",
43
44
  "ts-node": "^10.9.2",