@hashgraph/hedera-wallet-connect 2.0.1-canary.3eab33b.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.
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/lib/dapp/DAppSigner.d.ts +0 -2
- package/dist/lib/dapp/DAppSigner.js +2 -16
- package/dist/lib/dapp/index.d.ts +5 -7
- package/dist/lib/dapp/index.js +4 -36
- package/dist/lib/shared/index.d.ts +0 -2
- package/dist/lib/shared/index.js +0 -2
- package/dist/lib/shared/payloads.d.ts +1 -1
- package/dist/lib/shared/utils.d.ts +2 -1
- package/dist/lib/shared/utils.js +3 -2
- package/package.json +6 -8
- package/dist/lib/shared/accountInfo.d.ts +0 -30
- package/dist/lib/shared/accountInfo.js +0 -1
- package/dist/lib/shared/mirrorNode.d.ts +0 -3
- package/dist/lib/shared/mirrorNode.js +0 -17
- package/dist/reown/adapter.d.ts +0 -37
- package/dist/reown/adapter.js +0 -255
- package/dist/reown/connectors/HederaConnector.d.ts +0 -29
- package/dist/reown/connectors/HederaConnector.js +0 -35
- package/dist/reown/connectors/index.d.ts +0 -1
- package/dist/reown/connectors/index.js +0 -1
- package/dist/reown/index.d.ts +0 -4
- package/dist/reown/index.js +0 -4
- package/dist/reown/providers/EIP155Provider.d.ts +0 -33
- package/dist/reown/providers/EIP155Provider.js +0 -187
- package/dist/reown/providers/HIP820Provider.d.ts +0 -26
- package/dist/reown/providers/HIP820Provider.js +0 -69
- package/dist/reown/providers/HederaProvider.d.ts +0 -164
- package/dist/reown/providers/HederaProvider.js +0 -471
- package/dist/reown/providers/index.d.ts +0 -3
- package/dist/reown/providers/index.js +0 -3
- package/dist/reown/utils/chains.d.ts +0 -18
- package/dist/reown/utils/chains.js +0 -152
- package/dist/reown/utils/constants.d.ts +0 -16
- package/dist/reown/utils/constants.js +0 -18
- package/dist/reown/utils/helpers.d.ts +0 -12
- package/dist/reown/utils/helpers.js +0 -25
- package/dist/reown/utils/index.d.ts +0 -4
- package/dist/reown/utils/index.js +0 -4
- package/dist/reown/utils/types.d.ts +0 -9
- package/dist/reown/utils/types.js +0 -1
- package/dist/reown/wallets/EIP155Wallet.d.ts +0 -46
- package/dist/reown/wallets/EIP155Wallet.js +0 -124
- package/dist/reown/wallets/HIP820Wallet.d.ts +0 -53
- package/dist/reown/wallets/HIP820Wallet.js +0 -236
- package/dist/reown/wallets/index.d.ts +0 -2
- package/dist/reown/wallets/index.js +0 -2
@@ -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,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;
|
@@ -1,152 +0,0 @@
|
|
1
|
-
import { WcHelpersUtil } from '@reown/appkit';
|
2
|
-
import { defineChain } from '@reown/appkit/networks';
|
3
|
-
import { mergeArrays, normalizeNamespaces } from '@walletconnect/utils';
|
4
|
-
import { HederaJsonRpcMethod } from '../..';
|
5
|
-
export const hederaNamespace = 'hedera';
|
6
|
-
export const HederaChainDefinition = {
|
7
|
-
Native: {
|
8
|
-
Mainnet: defineChain({
|
9
|
-
id: 'mainnet',
|
10
|
-
chainNamespace: hederaNamespace,
|
11
|
-
caipNetworkId: 'hedera:mainnet',
|
12
|
-
name: 'Hedera Mainnet',
|
13
|
-
nativeCurrency: {
|
14
|
-
symbol: 'ℏ',
|
15
|
-
name: 'HBAR',
|
16
|
-
decimals: 8,
|
17
|
-
},
|
18
|
-
rpcUrls: {
|
19
|
-
default: {
|
20
|
-
http: ['https://mainnet.hashio.io/api'],
|
21
|
-
},
|
22
|
-
},
|
23
|
-
blockExplorers: {
|
24
|
-
default: {
|
25
|
-
name: 'Hashscan',
|
26
|
-
url: 'https://hashscan.io/mainnet',
|
27
|
-
},
|
28
|
-
},
|
29
|
-
testnet: false,
|
30
|
-
}),
|
31
|
-
Testnet: defineChain({
|
32
|
-
id: 'testnet',
|
33
|
-
chainNamespace: hederaNamespace,
|
34
|
-
caipNetworkId: 'hedera:testnet',
|
35
|
-
name: 'Hedera Testnet',
|
36
|
-
nativeCurrency: {
|
37
|
-
symbol: 'ℏ',
|
38
|
-
name: 'HBAR',
|
39
|
-
decimals: 8,
|
40
|
-
},
|
41
|
-
rpcUrls: {
|
42
|
-
default: {
|
43
|
-
http: ['https://testnet.hashio.io/api'],
|
44
|
-
},
|
45
|
-
},
|
46
|
-
blockExplorers: {
|
47
|
-
default: {
|
48
|
-
name: 'Hashscan',
|
49
|
-
url: 'https://hashscan.io/testnet',
|
50
|
-
},
|
51
|
-
},
|
52
|
-
testnet: true,
|
53
|
-
}),
|
54
|
-
},
|
55
|
-
EVM: {
|
56
|
-
Mainnet: defineChain({
|
57
|
-
id: 295,
|
58
|
-
name: 'Hedera Mainnet EVM',
|
59
|
-
chainNamespace: 'eip155',
|
60
|
-
caipNetworkId: 'eip155:295',
|
61
|
-
nativeCurrency: {
|
62
|
-
symbol: 'ℏ',
|
63
|
-
name: 'HBAR',
|
64
|
-
decimals: 18,
|
65
|
-
},
|
66
|
-
rpcUrls: {
|
67
|
-
default: {
|
68
|
-
http: ['https://mainnet.hashio.io/api'],
|
69
|
-
},
|
70
|
-
},
|
71
|
-
blockExplorers: {
|
72
|
-
default: {
|
73
|
-
name: 'Hashscan',
|
74
|
-
url: 'https://hashscan.io/testnet',
|
75
|
-
},
|
76
|
-
},
|
77
|
-
testnet: false,
|
78
|
-
}),
|
79
|
-
Testnet: defineChain({
|
80
|
-
id: 296,
|
81
|
-
name: 'Hedera Testnet EVM',
|
82
|
-
chainNamespace: 'eip155',
|
83
|
-
caipNetworkId: 'eip155:296',
|
84
|
-
nativeCurrency: {
|
85
|
-
symbol: 'ℏ',
|
86
|
-
name: 'HBAR',
|
87
|
-
decimals: 18,
|
88
|
-
},
|
89
|
-
rpcUrls: {
|
90
|
-
default: {
|
91
|
-
http: ['https://testnet.hashio.io/api'],
|
92
|
-
},
|
93
|
-
},
|
94
|
-
blockExplorers: {
|
95
|
-
default: {
|
96
|
-
name: 'Hashscan',
|
97
|
-
url: 'https://hashscan.io/testnet',
|
98
|
-
},
|
99
|
-
},
|
100
|
-
testnet: true,
|
101
|
-
}),
|
102
|
-
},
|
103
|
-
};
|
104
|
-
// Support Hedera Networks
|
105
|
-
export function createNamespaces(caipNetworks) {
|
106
|
-
return caipNetworks.reduce((acc, chain) => {
|
107
|
-
const { id, chainNamespace, rpcUrls } = chain;
|
108
|
-
const rpcUrl = rpcUrls.default.http[0];
|
109
|
-
const methods = chainNamespace == 'hedera'
|
110
|
-
? Object.values(HederaJsonRpcMethod)
|
111
|
-
: WcHelpersUtil.getMethodsByChainNamespace(chainNamespace);
|
112
|
-
if (!acc[chainNamespace]) {
|
113
|
-
acc[chainNamespace] = {
|
114
|
-
methods,
|
115
|
-
events: ['accountsChanged', 'chainChanged'],
|
116
|
-
chains: [],
|
117
|
-
rpcMap: {},
|
118
|
-
};
|
119
|
-
}
|
120
|
-
const caipNetworkId = `${chainNamespace}:${id}`;
|
121
|
-
const namespace = acc[chainNamespace];
|
122
|
-
namespace.chains.push(caipNetworkId);
|
123
|
-
if ((namespace === null || namespace === void 0 ? void 0 : namespace.rpcMap) && rpcUrl) {
|
124
|
-
namespace.rpcMap[id] = rpcUrl;
|
125
|
-
}
|
126
|
-
return acc;
|
127
|
-
}, {});
|
128
|
-
}
|
129
|
-
export function getChainsFromApprovedSession(accounts) {
|
130
|
-
return accounts.map((address) => `${address.split(':')[0]}:${address.split(':')[1]}`);
|
131
|
-
}
|
132
|
-
export function getChainId(chain) {
|
133
|
-
return chain.includes(':') ? chain.split(':')[1] : chain;
|
134
|
-
}
|
135
|
-
export function mergeRequiredOptionalNamespaces(required = {}, optional = {}) {
|
136
|
-
const requiredNamespaces = normalizeNamespaces(required);
|
137
|
-
const optionalNamespaces = normalizeNamespaces(optional);
|
138
|
-
return merge(requiredNamespaces, optionalNamespaces);
|
139
|
-
}
|
140
|
-
function merge(requiredNamespaces, optionalNamespaces) {
|
141
|
-
var _a, _b, _c;
|
142
|
-
const merged = Object.assign({}, requiredNamespaces);
|
143
|
-
for (const [namespace, values] of Object.entries(optionalNamespaces)) {
|
144
|
-
if (!merged[namespace]) {
|
145
|
-
merged[namespace] = values;
|
146
|
-
}
|
147
|
-
else {
|
148
|
-
merged[namespace] = Object.assign(Object.assign(Object.assign({}, merged[namespace]), values), { chains: mergeArrays(values.chains, (_a = merged[namespace]) === null || _a === void 0 ? void 0 : _a.chains), methods: mergeArrays(values.methods || [], ((_b = merged[namespace]) === null || _b === void 0 ? void 0 : _b.methods) || []), events: mergeArrays(values.events || [], ((_c = merged[namespace]) === null || _c === void 0 ? void 0 : _c.events) || []) });
|
149
|
-
}
|
150
|
-
}
|
151
|
-
return merged;
|
152
|
-
}
|
@@ -1,16 +0,0 @@
|
|
1
|
-
export declare const RPC_URL = "https://rpc.walletconnect.org/v1/";
|
2
|
-
export declare const GENERIC_SUBPROVIDER_NAME = "generic";
|
3
|
-
export declare const BUNDLER_URL = "https://rpc.walletconnect.org/v1/bundler";
|
4
|
-
export declare const PROVIDER_EVENTS: {
|
5
|
-
DEFAULT_CHAIN_CHANGED: string;
|
6
|
-
};
|
7
|
-
export declare enum Eip155JsonRpcMethod {
|
8
|
-
PersonalSign = "personal_sign",
|
9
|
-
Sign = "eth_sign",
|
10
|
-
SignTransaction = "eth_signTransaction",
|
11
|
-
SignTypedData = "eth_signTypedData",
|
12
|
-
SignTypedDataV3 = "eth_signTypedData_v3",
|
13
|
-
SignTypedDataV4 = "eth_signTypedData_v4",
|
14
|
-
SendRawTransaction = "eth_sendRawTransaction",
|
15
|
-
SendTransaction = "eth_sendTransaction"
|
16
|
-
}
|
@@ -1,18 +0,0 @@
|
|
1
|
-
export const RPC_URL = 'https://rpc.walletconnect.org/v1/';
|
2
|
-
export const GENERIC_SUBPROVIDER_NAME = 'generic';
|
3
|
-
export const BUNDLER_URL = `${RPC_URL}bundler`;
|
4
|
-
export const PROVIDER_EVENTS = {
|
5
|
-
DEFAULT_CHAIN_CHANGED: 'default_chain_changed',
|
6
|
-
};
|
7
|
-
// EIP-155 Wallet Methods
|
8
|
-
export var Eip155JsonRpcMethod;
|
9
|
-
(function (Eip155JsonRpcMethod) {
|
10
|
-
Eip155JsonRpcMethod["PersonalSign"] = "personal_sign";
|
11
|
-
Eip155JsonRpcMethod["Sign"] = "eth_sign";
|
12
|
-
Eip155JsonRpcMethod["SignTransaction"] = "eth_signTransaction";
|
13
|
-
Eip155JsonRpcMethod["SignTypedData"] = "eth_signTypedData";
|
14
|
-
Eip155JsonRpcMethod["SignTypedDataV3"] = "eth_signTypedData_v3";
|
15
|
-
Eip155JsonRpcMethod["SignTypedDataV4"] = "eth_signTypedData_v4";
|
16
|
-
Eip155JsonRpcMethod["SendRawTransaction"] = "eth_sendRawTransaction";
|
17
|
-
Eip155JsonRpcMethod["SendTransaction"] = "eth_sendTransaction";
|
18
|
-
})(Eip155JsonRpcMethod || (Eip155JsonRpcMethod = {}));
|