@hashgraph/hedera-wallet-connect 2.0.1-canary.3434618.0 → 2.0.1-canary.3659aea.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 (37) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +1 -0
  3. package/dist/reown/adapter.d.ts +53 -0
  4. package/dist/reown/adapter.js +258 -0
  5. package/dist/reown/connectors/HederaConnector.d.ts +29 -0
  6. package/dist/reown/connectors/HederaConnector.js +35 -0
  7. package/dist/reown/connectors/index.d.ts +1 -0
  8. package/dist/reown/connectors/index.js +1 -0
  9. package/dist/reown/index.d.ts +4 -0
  10. package/dist/reown/index.js +4 -0
  11. package/dist/reown/providers/EIP155Provider.d.ts +32 -0
  12. package/dist/reown/providers/EIP155Provider.js +187 -0
  13. package/dist/reown/providers/HIP820Provider.d.ts +26 -0
  14. package/dist/reown/providers/HIP820Provider.js +69 -0
  15. package/dist/reown/providers/HederaProvider.d.ts +164 -0
  16. package/dist/reown/providers/HederaProvider.js +471 -0
  17. package/dist/reown/providers/index.d.ts +3 -0
  18. package/dist/reown/providers/index.js +3 -0
  19. package/dist/reown/utils/account.d.ts +2 -0
  20. package/dist/reown/utils/account.js +20 -0
  21. package/dist/reown/utils/chains.d.ts +18 -0
  22. package/dist/reown/utils/chains.js +152 -0
  23. package/dist/reown/utils/constants.d.ts +16 -0
  24. package/dist/reown/utils/constants.js +18 -0
  25. package/dist/reown/utils/helpers.d.ts +12 -0
  26. package/dist/reown/utils/helpers.js +25 -0
  27. package/dist/reown/utils/index.d.ts +5 -0
  28. package/dist/reown/utils/index.js +5 -0
  29. package/dist/reown/utils/types.d.ts +9 -0
  30. package/dist/reown/utils/types.js +1 -0
  31. package/dist/reown/wallets/EIP155Wallet.d.ts +46 -0
  32. package/dist/reown/wallets/EIP155Wallet.js +124 -0
  33. package/dist/reown/wallets/HIP820Wallet.d.ts +53 -0
  34. package/dist/reown/wallets/HIP820Wallet.js +236 -0
  35. package/dist/reown/wallets/index.d.ts +2 -0
  36. package/dist/reown/wallets/index.js +2 -0
  37. package/package.json +3 -3
@@ -0,0 +1,69 @@
1
+ import { CAIPChainIdToLedgerId, DAppSigner } from '../..';
2
+ import { AccountId } from '@hashgraph/sdk';
3
+ class HIP820Provider {
4
+ constructor(opts) {
5
+ this.namespace = opts.namespace;
6
+ this.chainId = this.getDefaultChain();
7
+ this.events = opts.events;
8
+ this.client = opts.client;
9
+ }
10
+ get httpProviders() {
11
+ return {};
12
+ }
13
+ updateNamespace(namespace) {
14
+ this.namespace = Object.assign(this.namespace, namespace);
15
+ }
16
+ request(args) {
17
+ return this.getSigner(args.topic).request({
18
+ method: args.request.method,
19
+ params: args.request.params,
20
+ });
21
+ }
22
+ async signTransaction(transaction, topic) {
23
+ return this.getSigner(topic).signTransaction(transaction);
24
+ }
25
+ requestAccounts() {
26
+ const accounts = this.namespace.accounts;
27
+ if (!accounts) {
28
+ return [];
29
+ }
30
+ return Array.from(new Set(accounts
31
+ // get the accounts from the active chain
32
+ .filter((account) => account.split(':')[1] === this.chainId.toString())
33
+ // remove namespace & chainId from the string
34
+ .map((account) => account.split(':')[2])));
35
+ }
36
+ setDefaultChain(chainId) {
37
+ this.chainId = chainId;
38
+ this.namespace.defaultChain = chainId;
39
+ }
40
+ getDefaultChain() {
41
+ if (this.chainId)
42
+ return this.chainId;
43
+ if (this.namespace.defaultChain)
44
+ return this.namespace.defaultChain;
45
+ const chainId = this.namespace.chains[0];
46
+ if (!chainId)
47
+ throw new Error(`ChainId not found`);
48
+ return chainId.split(':')[1];
49
+ }
50
+ // create signer on demand
51
+ getSigner(topic) {
52
+ return this.getSigners(topic)[0];
53
+ }
54
+ getSigners(topic) {
55
+ var _a;
56
+ const accounts = (_a = this.namespace.accounts) === null || _a === void 0 ? void 0 : _a.map((account) => {
57
+ const [chain, network, acc] = account.split(':');
58
+ return {
59
+ ledgerId: CAIPChainIdToLedgerId(`${chain}:${network}`),
60
+ accountId: AccountId.fromString(acc),
61
+ };
62
+ });
63
+ if (!accounts) {
64
+ throw new Error('Accounts not found');
65
+ }
66
+ return accounts.map(({ accountId, ledgerId }) => new DAppSigner(accountId, this.client, topic, ledgerId));
67
+ }
68
+ }
69
+ export default HIP820Provider;
@@ -0,0 +1,164 @@
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
+ }