@hashgraph/hedera-wallet-connect 2.0.1-canary.3ca89d4.0 → 2.0.1-canary.45f4fe0.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 (49) hide show
  1. package/README.md +16 -16
  2. package/dist/index.d.ts +0 -1
  3. package/dist/index.js +0 -1
  4. package/dist/lib/dapp/DAppSigner.d.ts +0 -2
  5. package/dist/lib/dapp/DAppSigner.js +2 -16
  6. package/dist/lib/dapp/index.d.ts +5 -7
  7. package/dist/lib/dapp/index.js +4 -36
  8. package/dist/lib/shared/index.d.ts +0 -2
  9. package/dist/lib/shared/index.js +0 -2
  10. package/dist/lib/shared/payloads.d.ts +1 -1
  11. package/dist/lib/shared/utils.d.ts +3 -2
  12. package/dist/lib/shared/utils.js +4 -3
  13. package/package.json +10 -11
  14. package/dist/lib/shared/accountInfo.d.ts +0 -30
  15. package/dist/lib/shared/accountInfo.js +0 -1
  16. package/dist/lib/shared/mirrorNode.d.ts +0 -3
  17. package/dist/lib/shared/mirrorNode.js +0 -17
  18. package/dist/reown/adapter.d.ts +0 -37
  19. package/dist/reown/adapter.js +0 -255
  20. package/dist/reown/connectors/HederaConnector.d.ts +0 -29
  21. package/dist/reown/connectors/HederaConnector.js +0 -35
  22. package/dist/reown/connectors/index.d.ts +0 -1
  23. package/dist/reown/connectors/index.js +0 -1
  24. package/dist/reown/index.d.ts +0 -4
  25. package/dist/reown/index.js +0 -4
  26. package/dist/reown/providers/EIP155Provider.d.ts +0 -33
  27. package/dist/reown/providers/EIP155Provider.js +0 -187
  28. package/dist/reown/providers/HIP820Provider.d.ts +0 -26
  29. package/dist/reown/providers/HIP820Provider.js +0 -69
  30. package/dist/reown/providers/HederaProvider.d.ts +0 -164
  31. package/dist/reown/providers/HederaProvider.js +0 -471
  32. package/dist/reown/providers/index.d.ts +0 -3
  33. package/dist/reown/providers/index.js +0 -3
  34. package/dist/reown/utils/chains.d.ts +0 -18
  35. package/dist/reown/utils/chains.js +0 -152
  36. package/dist/reown/utils/constants.d.ts +0 -16
  37. package/dist/reown/utils/constants.js +0 -18
  38. package/dist/reown/utils/helpers.d.ts +0 -12
  39. package/dist/reown/utils/helpers.js +0 -25
  40. package/dist/reown/utils/index.d.ts +0 -4
  41. package/dist/reown/utils/index.js +0 -4
  42. package/dist/reown/utils/types.d.ts +0 -9
  43. package/dist/reown/utils/types.js +0 -1
  44. package/dist/reown/wallets/EIP155Wallet.d.ts +0 -46
  45. package/dist/reown/wallets/EIP155Wallet.js +0 -136
  46. package/dist/reown/wallets/HIP820Wallet.d.ts +0 -53
  47. package/dist/reown/wallets/HIP820Wallet.js +0 -239
  48. package/dist/reown/wallets/index.d.ts +0 -2
  49. package/dist/reown/wallets/index.js +0 -2
@@ -1,164 +0,0 @@
1
- import { TransactionRequest } from 'ethers';
2
- import { CaipNetwork, RequestArguments } from '@reown/appkit';
3
- import type { EstimateGasTransactionArgs, SendTransactionArgs, WriteContractArgs } from '@reown/appkit';
4
- import UniversalProvider, { RpcProviderMap, UniversalProviderOpts } from '@walletconnect/universal-provider';
5
- import { Transaction } from '@hashgraph/sdk';
6
- import { ExecuteTransactionParams, SignMessageParams, SignAndExecuteQueryParams, SignAndExecuteTransactionParams, SignTransactionParams } from '../..';
7
- import { EthFilter } from '../utils';
8
- import HIP820Provider from './HIP820Provider';
9
- import EIP155Provider from './EIP155Provider';
10
- export type HederaWalletConnectProviderConfig = {
11
- chains: CaipNetwork[];
12
- } & UniversalProviderOpts;
13
- export declare class HederaProvider extends UniversalProvider {
14
- nativeProvider?: HIP820Provider;
15
- eip155Provider?: EIP155Provider;
16
- constructor(opts: UniversalProviderOpts);
17
- static init(opts: UniversalProviderOpts): Promise<HederaProvider>;
18
- emit(event: string, data?: unknown): void;
19
- getAccountAddresses(): string[];
20
- request<T = unknown>(args: RequestArguments, chain?: string | undefined, expiry?: number | undefined): Promise<T>;
21
- /**
22
- * Retrieves the node addresses associated with the current Hedera network.
23
- *
24
- * When there is no active session or an error occurs during the request.
25
- * @returns Promise\<{@link GetNodeAddressesResult}\>
26
- */
27
- hedera_getNodeAddresses(): Promise<{
28
- nodes: string[];
29
- }>;
30
- /**
31
- * Executes a transaction on the Hedera network.
32
- *
33
- * @param {ExecuteTransactionParams} params - The parameters of type {@link ExecuteTransactionParams | `ExecuteTransactionParams`} required for the transaction execution.
34
- * @param {string[]} params.signedTransaction - Array of Base64-encoded `Transaction`'s
35
- * @returns Promise\<{@link ExecuteTransactionResult}\>
36
- * @example
37
- * Use helper `transactionToBase64String` to encode `Transaction` to Base64 string
38
- * ```ts
39
- * const params = {
40
- * signedTransaction: [transactionToBase64String(transaction)]
41
- * }
42
- *
43
- * const result = await dAppConnector.executeTransaction(params)
44
- * ```
45
- */
46
- hedera_executeTransaction(params: ExecuteTransactionParams): Promise<import("@hashgraph/sdk/lib/transaction/TransactionResponse").TransactionResponseJSON>;
47
- /**
48
- * Signs a provided `message` with provided `signerAccountId`.
49
- *
50
- * @param {SignMessageParams} params - The parameters of type {@link SignMessageParams | `SignMessageParams`} required for signing message.
51
- * @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.
52
- * @param {string} params.message - a plain UTF-8 string
53
- * @returns Promise\<{@link SignMessageResult}\>
54
- * @example
55
- * ```ts
56
- * const params = {
57
- * signerAccountId: 'hedera:testnet:0.0.12345',
58
- * message: 'Hello World!'
59
- * }
60
- *
61
- * const result = await dAppConnector.signMessage(params)
62
- * ```
63
- */
64
- hedera_signMessage(params: SignMessageParams): Promise<{
65
- signatureMap: string;
66
- }>;
67
- /**
68
- * Signs and send `Query` on the Hedera network.
69
- *
70
- * @param {SignAndExecuteQueryParams} params - The parameters of type {@link SignAndExecuteQueryParams | `SignAndExecuteQueryParams`} required for the Query execution.
71
- * @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.
72
- * @param {string} params.query - `Query` object represented as Base64 string
73
- * @returns Promise\<{@link SignAndExecuteQueryResult}\>
74
- * @example
75
- * Use helper `queryToBase64String` to encode `Query` to Base64 string
76
- * ```ts
77
- * const params = {
78
- * signerAccountId: '0.0.12345',
79
- * query: queryToBase64String(query),
80
- * }
81
- *
82
- * const result = await dAppConnector.signAndExecuteQuery(params)
83
- * ```
84
- */
85
- hedera_signAndExecuteQuery(params: SignAndExecuteQueryParams): Promise<{
86
- response: string;
87
- }>;
88
- /**
89
- * Signs and executes Transactions on the Hedera network.
90
- *
91
- * @param {SignAndExecuteTransactionParams} params - The parameters of type {@link SignAndExecuteTransactionParams | `SignAndExecuteTransactionParams`} required for `Transaction` signing and execution.
92
- * @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.
93
- * @param {string[]} params.transaction - Array of Base64-encoded `Transaction`'s
94
- * @returns Promise\<{@link SignAndExecuteTransactionResult}\>
95
- * @example
96
- * Use helper `transactionToBase64String` to encode `Transaction` to Base64 string
97
- * ```ts
98
- * const params = {
99
- * signerAccountId: '0.0.12345'
100
- * transaction: [transactionToBase64String(transaction)]
101
- * }
102
- *
103
- * const result = await dAppConnector.signAndExecuteTransaction(params)
104
- * ```
105
- */
106
- hedera_signAndExecuteTransaction(params: SignAndExecuteTransactionParams): Promise<import("@hashgraph/sdk/lib/transaction/TransactionResponse").TransactionResponseJSON>;
107
- /**
108
- * Signs and executes Transactions on the Hedera network.
109
- *
110
- * @param {SignTransactionParams} params - The parameters of type {@link SignTransactionParams | `SignTransactionParams`} required for `Transaction` signing.
111
- * @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.
112
- * @param {Transaction} params.transactionBody - a Transaction object built with the @hgraph/sdk
113
- * @returns Promise\<{@link SignTransactionResult}\>
114
- * @example
115
- * ```ts
116
- *
117
- * const params = {
118
- * signerAccountId: '0.0.12345',
119
- * transactionBody
120
- * }
121
- *
122
- * const result = await dAppConnector.signTransaction(params)
123
- * ```
124
- */
125
- hedera_signTransaction(params: SignTransactionParams): Promise<Transaction>;
126
- eth_signMessage(message: string, address: string): Promise<`0x${string}`>;
127
- eth_estimateGas(data: EstimateGasTransactionArgs, address: string, networkId: number): Promise<bigint>;
128
- eth_sendTransaction(data: SendTransactionArgs, address: string, networkId: number): Promise<`0x${string}`>;
129
- eth_writeContract(data: WriteContractArgs, address: string, chainId: number): Promise<string>;
130
- eth_blockNumber(): Promise<string>;
131
- eth_call(tx: TransactionRequest, block?: string): Promise<string>;
132
- eth_feeHistory(blockCount: number, newestBlock: string, rewardPercentiles: number[]): Promise<string>;
133
- eth_gasPrice(): Promise<string>;
134
- eth_getBlockByHash(hash: string, fullTx?: boolean): Promise<string>;
135
- eth_getBlockByNumber(block: string, fullTx?: boolean): Promise<unknown>;
136
- eth_getBlockTransactionCountByHash(hash: string): Promise<string>;
137
- eth_getBlockTransactionCountByNumber(block: string): Promise<string>;
138
- eth_getCode(address: string, block?: string): Promise<string>;
139
- eth_getFilterLogs(filterId: string): Promise<string>;
140
- eth_getFilterChanges(filterId: string): Promise<string>;
141
- eth_getLogs(filter: EthFilter): Promise<string>;
142
- eth_getStorageAt(address: string, position: string, block?: string): Promise<string>;
143
- eth_getTransactionByBlockHashAndIndex(hash: string, index: string): Promise<string>;
144
- eth_getTransactionByBlockNumberAndIndex(block: string, index: string): Promise<string>;
145
- eth_getTransactionByHash(hash: string): Promise<string>;
146
- eth_getTransactionCount(address: string, block?: string): Promise<string>;
147
- eth_getTransactionReceipt(hash: string): Promise<string>;
148
- eth_hashrate(): Promise<string>;
149
- eth_maxPriorityFeePerGas(): Promise<string>;
150
- eth_mining(): Promise<string>;
151
- eth_newBlockFilter(): Promise<string>;
152
- eth_newFilter(filter: EthFilter): Promise<string>;
153
- eth_submitWork(params: string[]): Promise<string>;
154
- eth_syncing(): Promise<string>;
155
- eth_uninstallFilter(filterId: string): Promise<string>;
156
- net_listening(): Promise<string>;
157
- net_version(): Promise<string>;
158
- web3_clientVersion(): Promise<string>;
159
- eth_chainId(): Promise<string>;
160
- pair(pairingTopic: string | undefined): ReturnType<UniversalProvider['pair']>;
161
- private initProviders;
162
- get rpcProviders(): RpcProviderMap;
163
- set rpcProviders(_: RpcProviderMap);
164
- }
@@ -1,471 +0,0 @@
1
- import { BrowserProvider, Contract, JsonRpcSigner, hexlify, isHexString, toQuantity, toUtf8Bytes, } from 'ethers';
2
- import UniversalProvider from '@walletconnect/universal-provider';
3
- import { Transaction } from '@hashgraph/sdk';
4
- import { HederaJsonRpcMethod, } from '../..';
5
- import { getChainsFromApprovedSession, mergeRequiredOptionalNamespaces, } from '../utils';
6
- import HIP820Provider from './HIP820Provider';
7
- import EIP155Provider from './EIP155Provider';
8
- // Reown AppKit UniversalProvider for HIP-820 & EIP-155 version implementation of the @hashgraph/hedera-wallet-connect DAppConnector
9
- export class HederaProvider extends UniversalProvider {
10
- constructor(opts) {
11
- super(opts);
12
- }
13
- static async init(opts) {
14
- var _a, _b, _c, _d, _e, _f;
15
- const provider = new HederaProvider(opts);
16
- //@ts-expect-error - private base method
17
- await provider.initialize();
18
- provider.namespaces = Object.assign(Object.assign({}, (((_a = provider.namespaces) === null || _a === void 0 ? void 0 : _a.eip155)
19
- ? {
20
- eip155: Object.assign(Object.assign({}, (_b = provider.namespaces) === null || _b === void 0 ? void 0 : _b.eip155), { rpcMap: (_c = provider.optionalNamespaces) === null || _c === void 0 ? void 0 : _c.eip155.rpcMap }),
21
- }
22
- : {})), (((_d = provider.namespaces) === null || _d === void 0 ? void 0 : _d.hedera)
23
- ? {
24
- hedera: Object.assign(Object.assign({}, (_e = provider.namespaces) === null || _e === void 0 ? void 0 : _e.hedera), { rpcMap: (_f = provider.optionalNamespaces) === null || _f === void 0 ? void 0 : _f.hedera.rpcMap }),
25
- }
26
- : {}));
27
- if (provider.session)
28
- provider.initProviders();
29
- return provider;
30
- }
31
- emit(event, data) {
32
- this.events.emit(event, data);
33
- }
34
- getAccountAddresses() {
35
- if (!this.session || !this.namespaces) {
36
- throw new Error('Not initialized. Please call connect()');
37
- }
38
- return Object.values(this.session.namespaces).flatMap((namespace) => { var _a; return (_a = namespace.accounts.map((account) => account.split(':')[2])) !== null && _a !== void 0 ? _a : []; });
39
- }
40
- async request(args, chain, expiry) {
41
- var _a, _b, _c, _d;
42
- if (!this.session || !this.namespaces) {
43
- throw new Error('Please call connect() before request()');
44
- }
45
- let chainId = chain;
46
- if (Object.values(HederaJsonRpcMethod).includes(args.method)) {
47
- if (!this.nativeProvider) {
48
- throw new Error('nativeProvider not initialized. Please call connect()');
49
- }
50
- chainId = chainId !== null && chainId !== void 0 ? chainId : (_a = this.namespaces.hedera) === null || _a === void 0 ? void 0 : _a.chains[0];
51
- return (_b = this.nativeProvider) === null || _b === void 0 ? void 0 : _b.request({
52
- request: Object.assign({}, args),
53
- chainId: chainId,
54
- topic: this.session.topic,
55
- expiry,
56
- });
57
- }
58
- else {
59
- if (!this.eip155Provider) {
60
- throw new Error('eip155Provider not initialized');
61
- }
62
- chainId = chainId !== null && chainId !== void 0 ? chainId : (_c = this.namespaces.eip155) === null || _c === void 0 ? void 0 : _c.chains[0];
63
- return (_d = this.eip155Provider) === null || _d === void 0 ? void 0 : _d.request({
64
- request: Object.assign({}, args),
65
- chainId: chainId,
66
- topic: this.session.topic,
67
- expiry,
68
- });
69
- }
70
- }
71
- /**
72
- * Retrieves the node addresses associated with the current Hedera network.
73
- *
74
- * When there is no active session or an error occurs during the request.
75
- * @returns Promise\<{@link GetNodeAddressesResult}\>
76
- */
77
- async hedera_getNodeAddresses() {
78
- return await this.request({
79
- method: HederaJsonRpcMethod.GetNodeAddresses,
80
- params: undefined,
81
- });
82
- }
83
- /**
84
- * Executes a transaction on the Hedera network.
85
- *
86
- * @param {ExecuteTransactionParams} params - The parameters of type {@link ExecuteTransactionParams | `ExecuteTransactionParams`} required for the transaction execution.
87
- * @param {string[]} params.signedTransaction - Array of Base64-encoded `Transaction`'s
88
- * @returns Promise\<{@link ExecuteTransactionResult}\>
89
- * @example
90
- * Use helper `transactionToBase64String` to encode `Transaction` to Base64 string
91
- * ```ts
92
- * const params = {
93
- * signedTransaction: [transactionToBase64String(transaction)]
94
- * }
95
- *
96
- * const result = await dAppConnector.executeTransaction(params)
97
- * ```
98
- */
99
- async hedera_executeTransaction(params) {
100
- return await this.request({
101
- method: HederaJsonRpcMethod.ExecuteTransaction,
102
- params,
103
- });
104
- }
105
- /**
106
- * Signs a provided `message` with provided `signerAccountId`.
107
- *
108
- * @param {SignMessageParams} params - The parameters of type {@link SignMessageParams | `SignMessageParams`} required for signing message.
109
- * @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.
110
- * @param {string} params.message - a plain UTF-8 string
111
- * @returns Promise\<{@link SignMessageResult}\>
112
- * @example
113
- * ```ts
114
- * const params = {
115
- * signerAccountId: 'hedera:testnet:0.0.12345',
116
- * message: 'Hello World!'
117
- * }
118
- *
119
- * const result = await dAppConnector.signMessage(params)
120
- * ```
121
- */
122
- async hedera_signMessage(params) {
123
- return await this.request({
124
- method: HederaJsonRpcMethod.SignMessage,
125
- params,
126
- });
127
- }
128
- /**
129
- * Signs and send `Query` on the Hedera network.
130
- *
131
- * @param {SignAndExecuteQueryParams} params - The parameters of type {@link SignAndExecuteQueryParams | `SignAndExecuteQueryParams`} required for the Query execution.
132
- * @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.
133
- * @param {string} params.query - `Query` object represented as Base64 string
134
- * @returns Promise\<{@link SignAndExecuteQueryResult}\>
135
- * @example
136
- * Use helper `queryToBase64String` to encode `Query` to Base64 string
137
- * ```ts
138
- * const params = {
139
- * signerAccountId: '0.0.12345',
140
- * query: queryToBase64String(query),
141
- * }
142
- *
143
- * const result = await dAppConnector.signAndExecuteQuery(params)
144
- * ```
145
- */
146
- async hedera_signAndExecuteQuery(params) {
147
- return await this.request({
148
- method: HederaJsonRpcMethod.SignAndExecuteQuery,
149
- params,
150
- });
151
- }
152
- /**
153
- * Signs and executes Transactions on the Hedera network.
154
- *
155
- * @param {SignAndExecuteTransactionParams} params - The parameters of type {@link SignAndExecuteTransactionParams | `SignAndExecuteTransactionParams`} required for `Transaction` signing and execution.
156
- * @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.
157
- * @param {string[]} params.transaction - Array of Base64-encoded `Transaction`'s
158
- * @returns Promise\<{@link SignAndExecuteTransactionResult}\>
159
- * @example
160
- * Use helper `transactionToBase64String` to encode `Transaction` to Base64 string
161
- * ```ts
162
- * const params = {
163
- * signerAccountId: '0.0.12345'
164
- * transaction: [transactionToBase64String(transaction)]
165
- * }
166
- *
167
- * const result = await dAppConnector.signAndExecuteTransaction(params)
168
- * ```
169
- */
170
- async hedera_signAndExecuteTransaction(params) {
171
- return await this.request({
172
- method: HederaJsonRpcMethod.SignAndExecuteTransaction,
173
- params,
174
- });
175
- }
176
- /**
177
- * Signs and executes Transactions on the Hedera network.
178
- *
179
- * @param {SignTransactionParams} params - The parameters of type {@link SignTransactionParams | `SignTransactionParams`} required for `Transaction` signing.
180
- * @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.
181
- * @param {Transaction} params.transactionBody - a Transaction object built with the @hgraph/sdk
182
- * @returns Promise\<{@link SignTransactionResult}\>
183
- * @example
184
- * ```ts
185
- *
186
- * const params = {
187
- * signerAccountId: '0.0.12345',
188
- * transactionBody
189
- * }
190
- *
191
- * const result = await dAppConnector.signTransaction(params)
192
- * ```
193
- */
194
- async hedera_signTransaction(params) {
195
- var _a, _b, _c;
196
- if (!this.session) {
197
- throw new Error('Session not initialized. Please call connect()');
198
- }
199
- if (!this.nativeProvider) {
200
- throw new Error('nativeProvider not initialized. Please call connect()');
201
- }
202
- if (!((params === null || params === void 0 ? void 0 : params.transactionBody) instanceof Transaction)) {
203
- throw new Error('Transaction sent in incorrect format. Ensure transaction body is a Transaction object.');
204
- }
205
- const signerAccountId = (_b = (_a = params === null || params === void 0 ? void 0 : params.signerAccountId) === null || _a === void 0 ? void 0 : _a.split(':')) === null || _b === void 0 ? void 0 : _b.pop();
206
- const isValidSigner = (_c = this.nativeProvider) === null || _c === void 0 ? void 0 : _c.requestAccounts().includes(signerAccountId !== null && signerAccountId !== void 0 ? signerAccountId : '');
207
- if (!isValidSigner) {
208
- throw new Error(`Signer not found for account ${signerAccountId}`);
209
- }
210
- return (await this.nativeProvider.signTransaction(params.transactionBody, this.session.topic));
211
- }
212
- async eth_signMessage(message, address) {
213
- const hexMessage = isHexString(message) ? message : hexlify(toUtf8Bytes(message));
214
- const signature = await this.request({
215
- method: 'personal_sign',
216
- params: [hexMessage, address],
217
- });
218
- return signature;
219
- }
220
- async eth_estimateGas(data, address, networkId) {
221
- if (!address) {
222
- throw new Error('estimateGas - address is undefined');
223
- }
224
- if (data.chainNamespace !== 'eip155') {
225
- throw new Error('estimateGas - chainNamespace is not eip155');
226
- }
227
- const txParams = {
228
- from: data.address,
229
- to: data.to,
230
- data: data.data,
231
- type: 0,
232
- };
233
- const browserProvider = new BrowserProvider(this, networkId);
234
- const signer = new JsonRpcSigner(browserProvider, address);
235
- return await signer.estimateGas(txParams);
236
- }
237
- async eth_sendTransaction(data, address, networkId) {
238
- if (!address) {
239
- throw new Error('sendTransaction - address is undefined');
240
- }
241
- if (data.chainNamespace !== 'eip155') {
242
- throw new Error('sendTransaction - chainNamespace is not eip155');
243
- }
244
- const txParams = {
245
- to: data.to,
246
- value: data.value,
247
- gasLimit: data.gas,
248
- gasPrice: data.gasPrice,
249
- data: data.data,
250
- type: 0,
251
- };
252
- const browserProvider = new BrowserProvider(this, networkId);
253
- const signer = new JsonRpcSigner(browserProvider, address);
254
- const txResponse = await signer.sendTransaction(txParams);
255
- const txReceipt = await txResponse.wait();
256
- return (txReceipt === null || txReceipt === void 0 ? void 0 : txReceipt.hash) || null;
257
- }
258
- async eth_writeContract(data, address, chainId) {
259
- if (!address) {
260
- throw new Error('writeContract - address is undefined');
261
- }
262
- const browserProvider = new BrowserProvider(this, chainId);
263
- const signer = new JsonRpcSigner(browserProvider, address);
264
- const contract = new Contract(data.tokenAddress, data.abi, signer);
265
- if (!contract || !data.method) {
266
- throw new Error('Contract method is undefined');
267
- }
268
- const method = contract[data.method];
269
- if (method) {
270
- return (await method(...data.args));
271
- }
272
- throw new Error('Contract method is undefined');
273
- }
274
- // Returns the latest block number
275
- async eth_blockNumber() {
276
- return this.request({ method: 'eth_blockNumber', params: [] });
277
- }
278
- // Executes a call with the given transaction request and block identifier
279
- async eth_call(tx, block = 'latest') {
280
- return this.request({ method: 'eth_call', params: [tx, block] });
281
- }
282
- // Returns fee history data for the given parameters
283
- async eth_feeHistory(blockCount, newestBlock, rewardPercentiles) {
284
- return this.request({
285
- method: 'eth_feeHistory',
286
- params: [toQuantity(blockCount), newestBlock, rewardPercentiles],
287
- });
288
- }
289
- // Returns the current gas price
290
- async eth_gasPrice() {
291
- return this.request({ method: 'eth_gasPrice', params: [] });
292
- }
293
- // Returns block details by hash, optionally including full transactions
294
- async eth_getBlockByHash(hash, fullTx = false) {
295
- return this.request({ method: 'eth_getBlockByHash', params: [hash, fullTx] });
296
- }
297
- // Returns block details by block number, optionally including full transactions
298
- async eth_getBlockByNumber(block, fullTx = false) {
299
- return this.request({ method: 'eth_getBlockByNumber', params: [block, fullTx] });
300
- }
301
- // Returns the number of transactions in a block identified by its hash
302
- async eth_getBlockTransactionCountByHash(hash) {
303
- return this.request({
304
- method: 'eth_getBlockTransactionCountByHash',
305
- params: [hash],
306
- });
307
- }
308
- // Returns the number of transactions in a block identified by its number
309
- async eth_getBlockTransactionCountByNumber(block) {
310
- return this.request({
311
- method: 'eth_getBlockTransactionCountByNumber',
312
- params: [block],
313
- });
314
- }
315
- // Returns the contract code at the specified address and block
316
- async eth_getCode(address, block = 'latest') {
317
- return this.request({ method: 'eth_getCode', params: [address, block] });
318
- }
319
- // Returns filter logs based on the provided filter object
320
- async eth_getFilterLogs(filterId) {
321
- return this.request({ method: 'eth_getFilterLogs', params: [filterId] });
322
- }
323
- // Returns filter changes for the given filter ID
324
- async eth_getFilterChanges(filterId) {
325
- return this.request({ method: 'eth_getFilterChanges', params: [filterId] });
326
- }
327
- // Returns logs based on the provided filter object
328
- async eth_getLogs(filter) {
329
- return this.request({ method: 'eth_getLogs', params: [filter] });
330
- }
331
- // Returns storage data at a specific address and position for a given block
332
- async eth_getStorageAt(address, position, block = 'latest') {
333
- return this.request({
334
- method: 'eth_getStorageAt',
335
- params: [address, position, block],
336
- });
337
- }
338
- // Returns a transaction from a block by its hash and index
339
- async eth_getTransactionByBlockHashAndIndex(hash, index) {
340
- return await this.request({
341
- method: 'eth_getTransactionByBlockHashAndIndex',
342
- params: [hash, index],
343
- });
344
- }
345
- // Returns a transaction from a block by its number and index
346
- async eth_getTransactionByBlockNumberAndIndex(block, index) {
347
- return this.request({
348
- method: 'eth_getTransactionByBlockNumberAndIndex',
349
- params: [block, index],
350
- });
351
- }
352
- // Returns transaction details by its hash
353
- async eth_getTransactionByHash(hash) {
354
- return this.request({ method: 'eth_getTransactionByHash', params: [hash] });
355
- }
356
- // Returns the transaction count for a given address and block
357
- async eth_getTransactionCount(address, block = 'latest') {
358
- return this.request({
359
- method: 'eth_getTransactionCount',
360
- params: [address, block],
361
- });
362
- }
363
- // Returns the transaction receipt for a given transaction hash
364
- async eth_getTransactionReceipt(hash) {
365
- return this.request({ method: 'eth_getTransactionReceipt', params: [hash] });
366
- }
367
- // Returns the current hashrate
368
- async eth_hashrate() {
369
- return this.request({ method: 'eth_hashrate', params: [] });
370
- }
371
- // Returns the max priority fee per gas
372
- async eth_maxPriorityFeePerGas() {
373
- return this.request({ method: 'eth_maxPriorityFeePerGas', params: [] });
374
- }
375
- // Returns the mining status
376
- async eth_mining() {
377
- return this.request({ method: 'eth_mining', params: [] });
378
- }
379
- // Creates a new block filter and returns its ID
380
- async eth_newBlockFilter() {
381
- return this.request({ method: 'eth_newBlockFilter', params: [] });
382
- }
383
- // Creates a new filter based on the provided filter object and returns its ID
384
- async eth_newFilter(filter) {
385
- return this.request({ method: 'eth_newFilter', params: [filter] });
386
- }
387
- // Submits work for mining (dummy parameters) and returns the result
388
- async eth_submitWork(params) {
389
- return this.request({ method: 'eth_submitWork', params });
390
- }
391
- // Returns the syncing status
392
- async eth_syncing() {
393
- return this.request({ method: 'eth_syncing', params: [] });
394
- }
395
- // Uninstalls the filter with the given ID
396
- async eth_uninstallFilter(filterId) {
397
- return this.request({ method: 'eth_uninstallFilter', params: [filterId] });
398
- }
399
- // Returns the network listening status
400
- async net_listening() {
401
- return this.request({ method: 'net_listening', params: [] });
402
- }
403
- // Returns the current network version
404
- async net_version() {
405
- return this.request({ method: 'net_version', params: [] });
406
- }
407
- // Returns the client version string
408
- async web3_clientVersion() {
409
- return this.request({ method: 'web3_clientVersion', params: [] });
410
- }
411
- async eth_chainId() {
412
- return this.request({ method: 'eth_chainId', params: [] });
413
- }
414
- async pair(pairingTopic) {
415
- const session = await super.pair(pairingTopic);
416
- this.initProviders();
417
- return session;
418
- }
419
- initProviders() {
420
- if (!this.client) {
421
- throw new Error('Sign Client not initialized');
422
- }
423
- if (!this.session || !this.namespaces) {
424
- return {};
425
- }
426
- const namespaces = Object.keys(this.namespaces);
427
- const providers = {};
428
- namespaces.forEach((namespace) => {
429
- const accounts = this.session.namespaces[namespace].accounts;
430
- const approvedChains = getChainsFromApprovedSession(accounts);
431
- const mergedNamespaces = mergeRequiredOptionalNamespaces(this.namespaces, this.optionalNamespaces);
432
- const combinedNamespace = Object.assign(Object.assign({}, mergedNamespaces[namespace]), { accounts, chains: approvedChains });
433
- switch (namespace) {
434
- case 'hedera': {
435
- const provider = new HIP820Provider({
436
- namespace: combinedNamespace,
437
- events: this.events,
438
- client: this.client,
439
- });
440
- this.nativeProvider = provider;
441
- providers[namespace] = provider;
442
- break;
443
- }
444
- case 'eip155': {
445
- const provider = new EIP155Provider({
446
- namespace: combinedNamespace,
447
- events: this.events,
448
- client: this.client,
449
- });
450
- this.eip155Provider = provider;
451
- providers[namespace] = provider;
452
- break;
453
- }
454
- default:
455
- throw new Error(`Unsupported namespace: ${namespace}`);
456
- }
457
- });
458
- return providers;
459
- }
460
- // @ts-expect-error - override base rpcProviders logic
461
- get rpcProviders() {
462
- if (!this.nativeProvider && !this.eip155Provider) {
463
- return this.initProviders();
464
- }
465
- return {
466
- hedera: this.nativeProvider,
467
- eip155: this.eip155Provider,
468
- };
469
- }
470
- set rpcProviders(_) { }
471
- }
@@ -1,3 +0,0 @@
1
- export * from './HIP820Provider';
2
- export * from './EIP155Provider';
3
- export * from './HederaProvider';
@@ -1,3 +0,0 @@
1
- export * from './HIP820Provider';
2
- export * from './EIP155Provider';
3
- export * from './HederaProvider';
@@ -1,18 +0,0 @@
1
- import { CaipNetwork, ChainNamespace } from '@reown/appkit-common';
2
- import { NamespaceConfig } from '@walletconnect/universal-provider';
3
- import { ProposalTypes } from '@walletconnect/types';
4
- export declare const hederaNamespace: ChainNamespace;
5
- export declare const HederaChainDefinition: {
6
- Native: {
7
- Mainnet: CaipNetwork;
8
- Testnet: CaipNetwork;
9
- };
10
- EVM: {
11
- Mainnet: CaipNetwork;
12
- Testnet: CaipNetwork;
13
- };
14
- };
15
- export declare function createNamespaces(caipNetworks: CaipNetwork[]): NamespaceConfig;
16
- export declare function getChainsFromApprovedSession(accounts: string[]): string[];
17
- export declare function getChainId(chain: string): string;
18
- export declare function mergeRequiredOptionalNamespaces(required?: ProposalTypes.RequiredNamespaces, optional?: ProposalTypes.RequiredNamespaces): ProposalTypes.RequiredNamespaces;