@hashgraph/hedera-wallet-connect 1.0.5 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +59 -0
- package/dist/browser-cjs-metafile.json +1 -1
- package/dist/browser-cjs.js +11 -1
- package/dist/browser-esm-metafile.json +1 -1
- package/dist/browser-esm.js +11 -1
- package/dist/node-cjs-metafile.json +1 -1
- package/dist/node-cjs.js +142 -130
- package/dist/node-esm-metafile.json +1 -1
- package/dist/node-esm.js +142 -130
- package/dist/types/src/index.d.ts +2 -0
- package/dist/types/src/index.d.ts.map +1 -0
- package/dist/types/src/lib/dapp/DAppSigner.d.ts +35 -0
- package/dist/types/src/lib/dapp/DAppSigner.d.ts.map +1 -0
- package/dist/types/src/lib/dapp/index.d.ts +177 -0
- package/dist/types/src/lib/dapp/index.d.ts.map +1 -0
- package/dist/types/src/lib/index.d.ts +4 -0
- package/dist/types/src/lib/index.d.ts.map +1 -0
- package/dist/types/src/lib/shared/chainIds.d.ts +12 -0
- package/dist/types/src/lib/shared/chainIds.d.ts.map +1 -0
- package/dist/types/src/lib/shared/errors.d.ts +49 -0
- package/dist/types/src/lib/shared/errors.d.ts.map +1 -0
- package/dist/types/src/lib/shared/events.d.ts +8 -0
- package/dist/types/src/lib/shared/events.d.ts.map +1 -0
- package/dist/types/src/lib/shared/index.d.ts +7 -0
- package/dist/types/src/lib/shared/index.d.ts.map +1 -0
- package/dist/types/src/lib/shared/methods.d.ts +13 -0
- package/dist/types/src/lib/shared/methods.d.ts.map +1 -0
- package/dist/types/src/lib/shared/payloads.d.ts +102 -0
- package/dist/types/src/lib/shared/payloads.d.ts.map +1 -0
- package/dist/types/src/lib/shared/utils.d.ts +281 -0
- package/dist/types/src/lib/shared/utils.d.ts.map +1 -0
- package/dist/types/src/lib/wallet/index.d.ts +40 -0
- package/dist/types/src/lib/wallet/index.d.ts.map +1 -0
- package/dist/types/src/lib/wallet/provider.d.ts +18 -0
- package/dist/types/src/lib/wallet/provider.d.ts.map +1 -0
- package/dist/types/src/lib/wallet/types.d.ts +32 -0
- package/dist/types/src/lib/wallet/types.d.ts.map +1 -0
- package/dist/types/test/_helpers.d.ts +39 -0
- package/dist/types/test/_helpers.d.ts.map +1 -0
- package/dist/types/test/dapp/DAppConnector.test.d.ts +2 -0
- package/dist/types/test/dapp/DAppConnector.test.d.ts.map +1 -0
- package/dist/types/test/dapp/DAppSigner.test.d.ts +2 -0
- package/dist/types/test/dapp/DAppSigner.test.d.ts.map +1 -0
- package/dist/types/test/utils.test.d.ts +2 -0
- package/dist/types/test/utils.test.d.ts.map +1 -0
- package/dist/types/test/wallet/methods/wallet-executeTransaction.test.d.ts +2 -0
- package/dist/types/test/wallet/methods/wallet-executeTransaction.test.d.ts.map +1 -0
- package/dist/types/test/wallet/methods/wallet-getNodeAddresses.test.d.ts +2 -0
- package/dist/types/test/wallet/methods/wallet-getNodeAddresses.test.d.ts.map +1 -0
- package/dist/types/test/wallet/methods/wallet-signAndExecuteQuery.test.d.ts +2 -0
- package/dist/types/test/wallet/methods/wallet-signAndExecuteQuery.test.d.ts.map +1 -0
- package/dist/types/test/wallet/methods/wallet-signAndExecuteTransaction.test.d.ts +2 -0
- package/dist/types/test/wallet/methods/wallet-signAndExecuteTransaction.test.d.ts.map +1 -0
- package/dist/types/test/wallet/methods/wallet-signMessage.test.d.ts +2 -0
- package/dist/types/test/wallet/methods/wallet-signMessage.test.d.ts.map +1 -0
- package/dist/types/test/wallet/methods/wallet-signTransaction.test.d.ts +2 -0
- package/dist/types/test/wallet/methods/wallet-signTransaction.test.d.ts.map +1 -0
- package/dist/types/test/wallet/wallet-init.test.d.ts +2 -0
- package/dist/types/test/wallet/wallet-init.test.d.ts.map +1 -0
- package/package.json +5 -4
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -35
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -17
- package/.github/ISSUE_TEMPLATE/hip_820.md +0 -16
- package/.github/dependabot.yml +0 -17
- package/.github/workflows/prettier.yml +0 -28
- package/.github/workflows/publish.yml +0 -35
- package/.github/workflows/test.yml +0 -32
- package/.husky/pre-commit +0 -4
- package/.lintstagedrc.json +0 -5
- package/.prettierignore +0 -3
- package/jest.config.ts +0 -33
- package/scripts/examples/build.mjs +0 -54
- package/scripts/examples/dev.mjs +0 -54
- package/scripts/lib/build.mjs +0 -40
- package/scripts/lib/context.mjs +0 -71
- package/scripts/lib/watch.mjs +0 -28
- package/typedoc.json +0 -10
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAoBA,cAAc,OAAO,CAAA"}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import { Signer, AccountBalance, AccountId, AccountInfo, Executable, Key, LedgerId, SignerSignature, Transaction, TransactionRecord } from '@hashgraph/sdk';
|
2
|
+
import type { ISignClient } from '@walletconnect/types';
|
3
|
+
export declare class DAppSigner implements Signer {
|
4
|
+
private readonly accountId;
|
5
|
+
private readonly signClient;
|
6
|
+
readonly topic: string;
|
7
|
+
private readonly ledgerId;
|
8
|
+
constructor(accountId: AccountId, signClient: ISignClient, topic: string, ledgerId?: LedgerId);
|
9
|
+
private _getHederaClient;
|
10
|
+
private get _signerAccountId();
|
11
|
+
private _getRandomNodes;
|
12
|
+
request<T>(request: {
|
13
|
+
method: string;
|
14
|
+
params: any;
|
15
|
+
}): Promise<T>;
|
16
|
+
getAccountId(): AccountId;
|
17
|
+
getAccountKey(): Key;
|
18
|
+
getLedgerId(): LedgerId;
|
19
|
+
getNetwork(): {
|
20
|
+
[key: string]: string | AccountId;
|
21
|
+
};
|
22
|
+
getMirrorNetwork(): string[];
|
23
|
+
getAccountBalance(): Promise<AccountBalance>;
|
24
|
+
getAccountInfo(): Promise<AccountInfo>;
|
25
|
+
getAccountRecords(): Promise<TransactionRecord[]>;
|
26
|
+
sign(data: Uint8Array[], signOptions?: Record<string, any>): Promise<SignerSignature[]>;
|
27
|
+
checkTransaction<T extends Transaction>(transaction: T): Promise<T>;
|
28
|
+
populateTransaction<T extends Transaction>(transaction: T): Promise<T>;
|
29
|
+
signTransaction<T extends Transaction>(transaction: T): Promise<T>;
|
30
|
+
private _tryExecuteTransactionRequest;
|
31
|
+
private _parseQueryResponse;
|
32
|
+
private _tryExecuteQueryRequest;
|
33
|
+
call<RequestT, ResponseT, OutputT>(request: Executable<RequestT, ResponseT, OutputT>): Promise<OutputT>;
|
34
|
+
}
|
35
|
+
//# sourceMappingURL=DAppSigner.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"DAppSigner.d.ts","sourceRoot":"","sources":["../../../../../src/lib/dapp/DAppSigner.ts"],"names":[],"mappings":"AAoBA,OAAO,EACL,MAAM,EACN,cAAc,EACd,SAAS,EACT,WAAW,EACX,UAAU,EACV,GAAG,EACH,QAAQ,EACR,eAAe,EACf,WAAW,EACX,iBAAiB,EAWlB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAmBvD,qBAAa,UAAW,YAAW,MAAM;IAErC,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,UAAU;aACX,KAAK,EAAE,MAAM;IAC7B,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAHR,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,WAAW,EACxB,KAAK,EAAE,MAAM,EACZ,QAAQ,GAAE,QAA2B;IAGxD,OAAO,CAAC,gBAAgB;IASxB,OAAO,KAAK,gBAAgB,GAE3B;IAED,OAAO,CAAC,eAAe;IAcvB,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,GAAG,CAAA;KAAE,GAAG,OAAO,CAAC,CAAC,CAAC;IAQhE,YAAY,IAAI,SAAS;IAIzB,aAAa,IAAI,GAAG;IAIpB,WAAW,IAAI,QAAQ;IAIvB,UAAU,IAAI;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;KAAE;IAInD,gBAAgB,IAAI,MAAM,EAAE;IAI5B,iBAAiB,IAAI,OAAO,CAAC,cAAc,CAAC;IAI5C,cAAc,IAAI,OAAO,CAAC,WAAW,CAAC;IAItC,iBAAiB,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAI3C,IAAI,CACR,IAAI,EAAE,UAAU,EAAE,EAClB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAChC,OAAO,CAAC,eAAe,EAAE,CAAC;IAsBvB,gBAAgB,CAAC,CAAC,SAAS,WAAW,EAAE,WAAW,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAInE,mBAAmB,CAAC,CAAC,SAAS,WAAW,EAAE,WAAW,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAMtE,eAAe,CAAC,CAAC,SAAS,WAAW,EAAE,WAAW,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;YAqB1D,6BAA6B;YAsB7B,mBAAmB;YAsBnB,uBAAuB;IAuB/B,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,EACrC,OAAO,EAAE,UAAU,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,GAChD,OAAO,CAAC,OAAO,CAAC;CAgCpB"}
|
@@ -0,0 +1,177 @@
|
|
1
|
+
import { AccountId, LedgerId } from '@hashgraph/sdk';
|
2
|
+
import { SessionTypes, SignClientTypes } from '@walletconnect/types';
|
3
|
+
import { WalletConnectModal } from '@walletconnect/modal';
|
4
|
+
import SignClient from '@walletconnect/sign-client';
|
5
|
+
import { GetNodeAddressesResult, ExecuteTransactionParams, ExecuteTransactionResult, SignMessageParams, SignMessageResult, SignAndExecuteQueryResult, SignAndExecuteQueryParams, SignAndExecuteTransactionParams, SignAndExecuteTransactionResult, SignTransactionParams, SignTransactionResult } from '../shared';
|
6
|
+
import { DAppSigner } from './DAppSigner';
|
7
|
+
export * from './DAppSigner';
|
8
|
+
type BaseLogger = 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'fatal';
|
9
|
+
export declare class DAppConnector {
|
10
|
+
dAppMetadata: SignClientTypes.Metadata;
|
11
|
+
network: LedgerId;
|
12
|
+
projectId: string;
|
13
|
+
supportedMethods: string[];
|
14
|
+
supportedEvents: string[];
|
15
|
+
supportedChains: string[];
|
16
|
+
walletConnectClient: SignClient | undefined;
|
17
|
+
walletConnectModal: WalletConnectModal;
|
18
|
+
signers: DAppSigner[];
|
19
|
+
isInitializing: boolean;
|
20
|
+
/**
|
21
|
+
* Initializes the DAppConnector instance.
|
22
|
+
* @param metadata - SignClientTypes.Metadata object for the DApp metadata.
|
23
|
+
* @param network - LedgerId representing the network (default: LedgerId.TESTNET).
|
24
|
+
* @param projectId - Project ID for the WalletConnect client.
|
25
|
+
* @param methods - Array of supported methods for the DApp (optional).
|
26
|
+
* @param events - Array of supported events for the DApp (optional).
|
27
|
+
* @param events - Array of supported chains for the DApp (optional).
|
28
|
+
*/
|
29
|
+
constructor(metadata: SignClientTypes.Metadata, network: LedgerId, projectId: string, methods?: string[], events?: string[], chains?: string[]);
|
30
|
+
/**
|
31
|
+
* Initializes the DAppConnector instance.
|
32
|
+
* @param logger - `BaseLogger` for logging purposes (optional).
|
33
|
+
*/
|
34
|
+
init({ logger }?: {
|
35
|
+
logger?: BaseLogger;
|
36
|
+
}): Promise<void>;
|
37
|
+
getSigner(accountId: AccountId): DAppSigner;
|
38
|
+
/**
|
39
|
+
* Initiates the WalletConnect connection flow using a QR code.
|
40
|
+
* @param pairingTopic - The pairing topic for the connection (optional).
|
41
|
+
* @returns A Promise that resolves when the connection process is complete.
|
42
|
+
*/
|
43
|
+
connectQR(pairingTopic?: string): Promise<void>;
|
44
|
+
/**
|
45
|
+
* Initiates the WalletConnect connection flow using a QR code.
|
46
|
+
* @param pairingTopic - The pairing topic for the connection (optional).
|
47
|
+
* @returns {Promise<SessionTypes.Struct>} - A Promise that resolves when the connection process is complete.
|
48
|
+
*/
|
49
|
+
openModal(pairingTopic?: string): Promise<SessionTypes.Struct>;
|
50
|
+
/**
|
51
|
+
* Initiates the WallecConnect connection flow using URI.
|
52
|
+
* @param pairingTopic - The pairing topic for the connection (optional).
|
53
|
+
* @returns A Promise that resolves when the connection process is complete.
|
54
|
+
*/
|
55
|
+
connect(launchCallback: (uri: string) => void, pairingTopic?: string): Promise<void>;
|
56
|
+
private abortableConnect;
|
57
|
+
/**
|
58
|
+
* Disconnects the current session associated with the specified topic.
|
59
|
+
* @param topic - The topic of the session to disconnect.
|
60
|
+
* @returns A Promise that resolves when the session is disconnected.
|
61
|
+
*/
|
62
|
+
disconnect(topic: string): Promise<void>;
|
63
|
+
/**
|
64
|
+
* Disconnects all active sessions and pairings.
|
65
|
+
*
|
66
|
+
* Throws error when WalletConnect is not initialized or there are no active sessions/pairings.
|
67
|
+
* @returns A Promise that resolves when all active sessions and pairings are disconnected.
|
68
|
+
*/
|
69
|
+
disconnectAll(): Promise<void>;
|
70
|
+
private createSigners;
|
71
|
+
private onSessionConnected;
|
72
|
+
private connectURI;
|
73
|
+
private request;
|
74
|
+
/**
|
75
|
+
* Retrieves the node addresses associated with the current Hedera network.
|
76
|
+
*
|
77
|
+
* When there is no active session or an error occurs during the request.
|
78
|
+
* @returns Promise\<{@link GetNodeAddressesResult}\>
|
79
|
+
*/
|
80
|
+
getNodeAddresses(): Promise<GetNodeAddressesResult>;
|
81
|
+
/**
|
82
|
+
* Executes a transaction on the Hedera network.
|
83
|
+
*
|
84
|
+
* @param {ExecuteTransactionParams} params - The parameters of type {@link ExecuteTransactionParams | `ExecuteTransactionParams`} required for the transaction execution.
|
85
|
+
* @param {string[]} params.signedTransaction - Array of Base64-encoded `Transaction`'s
|
86
|
+
* @returns Promise\<{@link ExecuteTransactionResult}\>
|
87
|
+
* @example
|
88
|
+
* Use helper `transactionToBase64String` to encode `Transaction` to Base64 string
|
89
|
+
* ```ts
|
90
|
+
* const params = {
|
91
|
+
* signedTransaction: [transactionToBase64String(transaction)]
|
92
|
+
* }
|
93
|
+
*
|
94
|
+
* const result = await dAppConnector.executeTransaction(params)
|
95
|
+
* ```
|
96
|
+
*/
|
97
|
+
executeTransaction(params: ExecuteTransactionParams): Promise<ExecuteTransactionResult>;
|
98
|
+
/**
|
99
|
+
* Signs a provided `message` with provided `signerAccountId`.
|
100
|
+
*
|
101
|
+
* @param {SignMessageParams} params - The parameters of type {@link SignMessageParams | `SignMessageParams`} required for signing message.
|
102
|
+
* @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.
|
103
|
+
* @param {string} params.message - a plain UTF-8 string
|
104
|
+
* @returns Promise\<{@link SignMessageResult}\>
|
105
|
+
* @example
|
106
|
+
* ```ts
|
107
|
+
* const params = {
|
108
|
+
* signerAccountId: '0.0.12345',
|
109
|
+
* message: 'Hello World!'
|
110
|
+
* }
|
111
|
+
*
|
112
|
+
* const result = await dAppConnector.signMessage(params)
|
113
|
+
* ```
|
114
|
+
*/
|
115
|
+
signMessage(params: SignMessageParams): Promise<SignMessageResult>;
|
116
|
+
/**
|
117
|
+
* Signs and send `Query` on the Hedera network.
|
118
|
+
*
|
119
|
+
* @param {SignAndExecuteQueryParams} params - The parameters of type {@link SignAndExecuteQueryParams | `SignAndExecuteQueryParams`} required for the Query execution.
|
120
|
+
* @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.
|
121
|
+
* @param {string} params.query - `Query` object represented as Base64 string
|
122
|
+
* @returns Promise\<{@link SignAndExecuteQueryResult}\>
|
123
|
+
* @example
|
124
|
+
* Use helper `queryToBase64String` to encode `Query` to Base64 string
|
125
|
+
* ```ts
|
126
|
+
* const params = {
|
127
|
+
* signerAccountId: '0.0.12345',
|
128
|
+
* query: queryToBase64String(query),
|
129
|
+
* }
|
130
|
+
*
|
131
|
+
* const result = await dAppConnector.signAndExecuteQuery(params)
|
132
|
+
* ```
|
133
|
+
*/
|
134
|
+
signAndExecuteQuery(params: SignAndExecuteQueryParams): Promise<SignAndExecuteQueryResult>;
|
135
|
+
/**
|
136
|
+
* Signs and executes Transactions on the Hedera network.
|
137
|
+
*
|
138
|
+
* @param {SignAndExecuteTransactionParams} params - The parameters of type {@link SignAndExecuteTransactionParams | `SignAndExecuteTransactionParams`} required for `Transaction` signing and execution.
|
139
|
+
* @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.
|
140
|
+
* @param {string[]} params.transaction - Array of Base64-encoded `Transaction`'s
|
141
|
+
* @returns Promise\<{@link SignAndExecuteTransactionResult}\>
|
142
|
+
* @example
|
143
|
+
* Use helper `transactionToBase64String` to encode `Transaction` to Base64 string
|
144
|
+
* ```ts
|
145
|
+
* const params = {
|
146
|
+
* signerAccountId: '0.0.12345'
|
147
|
+
* transaction: [transactionToBase64String(transaction)]
|
148
|
+
* }
|
149
|
+
*
|
150
|
+
* const result = await dAppConnector.signAndExecuteTransaction(params)
|
151
|
+
* ```
|
152
|
+
*/
|
153
|
+
signAndExecuteTransaction(params: SignAndExecuteTransactionParams): Promise<SignAndExecuteTransactionResult>;
|
154
|
+
/**
|
155
|
+
* Signs and executes Transactions on the Hedera network.
|
156
|
+
*
|
157
|
+
* @param {SignTransactionParams} params - The parameters of type {@link SignTransactionParams | `SignTransactionParams`} required for `Transaction` signing.
|
158
|
+
* @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.
|
159
|
+
* @param {string[]} params.transaction - Array of Base64-encoded `Transaction`'s
|
160
|
+
* @returns Promise\<{@link SignTransactionResult}\>
|
161
|
+
* @example
|
162
|
+
* ```ts
|
163
|
+
* const transactionBodyObject = transactionToTransactionBody(transaction, AccountId.fromString('0.0.3'))
|
164
|
+
* const transactionBody = transactionBodyToBase64String(transactionBodyObject)
|
165
|
+
*
|
166
|
+
* const params = {
|
167
|
+
* signerAccountId: '0.0.12345',
|
168
|
+
* transactionBody
|
169
|
+
* }
|
170
|
+
*
|
171
|
+
* const result = await dAppConnector.signTransaction(params)
|
172
|
+
* ```
|
173
|
+
*/
|
174
|
+
signTransaction(params: SignTransactionParams): Promise<SignTransactionResult>;
|
175
|
+
}
|
176
|
+
export default DAppConnector;
|
177
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lib/dapp/index.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAe,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEjF,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAEzD,OAAO,UAAU,MAAM,4BAA4B,CAAA;AAEnD,OAAO,EAKL,sBAAsB,EACtB,wBAAwB,EAExB,wBAAwB,EACxB,iBAAiB,EAEjB,iBAAiB,EAEjB,yBAAyB,EACzB,yBAAyB,EACzB,+BAA+B,EAE/B,+BAA+B,EAC/B,qBAAqB,EAErB,qBAAqB,EACtB,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAGzC,cAAc,cAAc,CAAA;AAE5B,KAAK,UAAU,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAA;AAEzE,qBAAa,aAAa;IACxB,YAAY,EAAE,eAAe,CAAC,QAAQ,CAAA;IACtC,OAAO,EAAE,QAAQ,CAAmB;IACpC,SAAS,EAAE,MAAM,CAAA;IACjB,gBAAgB,EAAE,MAAM,EAAE,CAAK;IAC/B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E,wBAAwB;IAOhE;;;;;;;;;;;;;;;;OAgBG;IACU,WAAW,CAAC,MAAM,EAAE,iBAAiB;IAOlD;;;;;;;;;;;;;;;;;OAiBG;IACU,mBAAmB,CAAC,MAAM,EAAE,yBAAyB;IAOlE;;;;;;;;;;;;;;;;;OAiBG;IACU,yBAAyB,CAAC,MAAM,EAAE,+BAA+B;IAU9E;;;;;;;;;;;;;;;;;;;OAmBG;IACU,eAAe,CAAC,MAAM,EAAE,qBAAqB;CAM3D;AAED,eAAe,aAAa,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/index.ts"],"names":[],"mappings":"AAoBA,cAAc,UAAU,CAAA;AACxB,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAA;AAC5C,cAAc,QAAQ,CAAA"}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
/**
|
2
|
+
* Enum representing different Hedera network chain IDs.
|
3
|
+
*
|
4
|
+
* @see {@link https://github.com/hashgraph/hedera-improvement-proposal/blob/main/HIP/hip-820.md#specification | HIP-820 Specification}
|
5
|
+
*/
|
6
|
+
export declare enum HederaChainId {
|
7
|
+
Mainnet = "hedera:mainnet",
|
8
|
+
Testnet = "hedera:testnet",
|
9
|
+
Previewnet = "hedera:previewnet",
|
10
|
+
Devnet = "hedera:devnet"
|
11
|
+
}
|
12
|
+
//# sourceMappingURL=chainIds.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"chainIds.d.ts","sourceRoot":"","sources":["../../../../../src/lib/shared/chainIds.ts"],"names":[],"mappings":"AAoBA;;;;GAIG;AAEH,oBAAY,aAAa;IACvB,OAAO,mBAAmB;IAC1B,OAAO,mBAAmB;IAC1B,UAAU,sBAAsB;IAChC,MAAM,kBAAkB;CACzB"}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
/**
|
2
|
+
* This file defines error handling related to Hedera operations.
|
3
|
+
* @see {@link https://github.com/WalletConnect/walletconnect-monorepo/blob/v2.0/packages/utils/src/errors.ts | WalletConnect Errors}
|
4
|
+
*/
|
5
|
+
/**
|
6
|
+
* Represents keys of Hedera error types.
|
7
|
+
*/
|
8
|
+
export type HederaErrorKey = keyof typeof HEDERA_ERRORS;
|
9
|
+
/**
|
10
|
+
* Represents a JSON-RPC error for Hedera operations.
|
11
|
+
* @param T - Generic type for additional data in the error response.
|
12
|
+
*/
|
13
|
+
export interface HederaErrorResponse<T = string | number> {
|
14
|
+
code: number;
|
15
|
+
message: string;
|
16
|
+
data?: T;
|
17
|
+
}
|
18
|
+
/**
|
19
|
+
* WalletConnect has certain
|
20
|
+
* {@link https://github.com/WalletConnect/walletconnect-monorepo/blob/v2.0/packages/utils/src/errors.ts | error code ranges reserved}
|
21
|
+
* for WalletConnect use.
|
22
|
+
* The following schema uses negative codes to avoid conflicts.
|
23
|
+
*
|
24
|
+
* @see {@link https://github.com/WalletConnect/walletconnect-monorepo/blob/v2.0/packages/utils/src/errors.ts | WalletConnect Errors}
|
25
|
+
*/
|
26
|
+
/**
|
27
|
+
* Object containing specific Hedera errors with their respective codes and messages.
|
28
|
+
*/
|
29
|
+
export declare const HEDERA_ERRORS: {
|
30
|
+
[key: string]: Pick<HederaErrorResponse, 'code' | 'message'>;
|
31
|
+
};
|
32
|
+
/**
|
33
|
+
* Represents a JSON-RPC error for Hedera operations.
|
34
|
+
* @param T - Generic type for additional data in the error response.
|
35
|
+
*/
|
36
|
+
export interface HederaJsonRpcError<T = string | number> {
|
37
|
+
id: number;
|
38
|
+
jsonrpc: '2.0';
|
39
|
+
error: HederaErrorResponse<T>;
|
40
|
+
}
|
41
|
+
/**
|
42
|
+
* Generates a Hedera error response based on the provided key, context, and additional data.
|
43
|
+
* @param key - Key representing the specific error type.
|
44
|
+
* @param context - Contextual information for the error (optional).
|
45
|
+
* @param data - Additional data to include in the error response (optional).
|
46
|
+
* @returns A HederaErrorResponse object with the specified code, message, and additional data.
|
47
|
+
*/
|
48
|
+
export declare function getHederaError<T>(key: string, context?: string | number, data?: T): HederaErrorResponse<T>;
|
49
|
+
//# sourceMappingURL=errors.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../../src/lib/shared/errors.ts"],"names":[],"mappings":"AAoBA;;;GAGG;AAEH;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,aAAa,CAAA;AAEvD;;;GAGG;AACH,MAAM,WAAW,mBAAmB,CAAC,CAAC,GAAG,MAAM,GAAG,MAAM;IACtD,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,CAAC,CAAA;CACT;AAED;;;;;;;GAOG;AAEH;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC,mBAAmB,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;CAKzF,CAAA;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB,CAAC,CAAC,GAAG,MAAM,GAAG,MAAM;IACrD,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,KAAK,CAAA;IACd,KAAK,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAA;CAC9B;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAC9B,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EACzB,IAAI,CAAC,EAAE,CAAC,GACP,mBAAmB,CAAC,CAAC,CAAC,CAOxB"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../../../src/lib/shared/events.ts"],"names":[],"mappings":"AAoBA;;GAEG;AACH,oBAAY,kBAAkB;IAC5B,eAAe,oBAAoB;IACnC,YAAY,iBAAiB;CAC9B"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lib/shared/index.ts"],"names":[],"mappings":"AAoBA,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA"}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/**
|
2
|
+
* Enum representing different JSON-RPC methods related to Hedera.
|
3
|
+
* The methods are ordered alphabetically for ease of use and readability.
|
4
|
+
*/
|
5
|
+
export declare enum HederaJsonRpcMethod {
|
6
|
+
GetNodeAddresses = "hedera_getNodeAddresses",// 1
|
7
|
+
ExecuteTransaction = "hedera_executeTransaction",// 2
|
8
|
+
SignMessage = "hedera_signMessage",// 3
|
9
|
+
SignAndExecuteQuery = "hedera_signAndExecuteQuery",// 4
|
10
|
+
SignAndExecuteTransaction = "hedera_signAndExecuteTransaction",// 5
|
11
|
+
SignTransaction = "hedera_signTransaction"
|
12
|
+
}
|
13
|
+
//# sourceMappingURL=methods.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"methods.d.ts","sourceRoot":"","sources":["../../../../../src/lib/shared/methods.ts"],"names":[],"mappings":"AAoBA;;;GAGG;AACH,oBAAY,mBAAmB;IAC7B,gBAAgB,4BAA4B,CAAE,IAAI;IAClD,kBAAkB,8BAA8B,CAAE,IAAI;IACtD,WAAW,uBAAuB,CAAE,IAAI;IACxC,mBAAmB,+BAA+B,CAAE,IAAI;IACxD,yBAAyB,qCAAqC,CAAE,IAAI;IACpE,eAAe,2BAA2B;CAC3C"}
|
@@ -0,0 +1,102 @@
|
|
1
|
+
import { JsonRpcResult } from '@walletconnect/jsonrpc-types';
|
2
|
+
import { EngineTypes } from '@walletconnect/types';
|
3
|
+
import type { TransactionResponseJSON } from '@hashgraph/sdk';
|
4
|
+
import { HederaJsonRpcMethod } from './methods';
|
5
|
+
/**
|
6
|
+
* Defines various types and interfaces for Hedera JSON-RPC methods.
|
7
|
+
*/
|
8
|
+
export type GetNodeAddressesParams = undefined;
|
9
|
+
export interface GetNodeAddressesRequest extends EngineTypes.RequestParams {
|
10
|
+
request: {
|
11
|
+
method: HederaJsonRpcMethod.GetNodeAddresses;
|
12
|
+
params: GetNodeAddressesParams;
|
13
|
+
};
|
14
|
+
}
|
15
|
+
export interface GetNodeAddressesResult extends JsonRpcResult<{
|
16
|
+
nodes: string[];
|
17
|
+
}> {
|
18
|
+
}
|
19
|
+
export interface GetNodeAddresesResponse extends EngineTypes.RespondParams {
|
20
|
+
response: GetNodeAddressesResult;
|
21
|
+
}
|
22
|
+
export interface ExecuteTransactionParams {
|
23
|
+
transactionList: string;
|
24
|
+
}
|
25
|
+
export interface ExecuteTransactionRequest extends EngineTypes.RequestParams {
|
26
|
+
request: {
|
27
|
+
method: HederaJsonRpcMethod.ExecuteTransaction;
|
28
|
+
params: ExecuteTransactionParams;
|
29
|
+
};
|
30
|
+
}
|
31
|
+
export interface ExecuteTransactionResult extends JsonRpcResult<TransactionResponseJSON> {
|
32
|
+
}
|
33
|
+
export interface ExecuteTransactionResponse extends EngineTypes.RespondParams {
|
34
|
+
response: ExecuteTransactionResult;
|
35
|
+
}
|
36
|
+
export interface SignMessageParams {
|
37
|
+
signerAccountId: string;
|
38
|
+
message: string;
|
39
|
+
}
|
40
|
+
export interface SignMessageRequest extends EngineTypes.RequestParams {
|
41
|
+
request: {
|
42
|
+
method: HederaJsonRpcMethod.SignMessage;
|
43
|
+
params: SignMessageParams;
|
44
|
+
};
|
45
|
+
}
|
46
|
+
export interface SignMessageResult extends JsonRpcResult<{
|
47
|
+
signatureMap: string;
|
48
|
+
}> {
|
49
|
+
}
|
50
|
+
export interface SignMessageResponse extends EngineTypes.RespondParams {
|
51
|
+
response: SignMessageResult;
|
52
|
+
}
|
53
|
+
export interface SignAndExecuteQueryParams {
|
54
|
+
signerAccountId: string;
|
55
|
+
query: string;
|
56
|
+
}
|
57
|
+
export interface SignAndExecuteQueryRequest extends EngineTypes.RequestParams {
|
58
|
+
request: {
|
59
|
+
method: HederaJsonRpcMethod.SignAndExecuteQuery;
|
60
|
+
params: SignAndExecuteQueryParams;
|
61
|
+
};
|
62
|
+
}
|
63
|
+
export interface SignAndExecuteQueryResult extends JsonRpcResult<{
|
64
|
+
response: string;
|
65
|
+
}> {
|
66
|
+
}
|
67
|
+
export interface SignAndExecuteQueryResponse extends EngineTypes.RespondParams {
|
68
|
+
response: SignAndExecuteQueryResult;
|
69
|
+
}
|
70
|
+
export interface SignAndExecuteTransactionParams {
|
71
|
+
signerAccountId: string;
|
72
|
+
transactionList: string;
|
73
|
+
}
|
74
|
+
export interface SignAndExecuteTransactionRequest extends EngineTypes.RequestParams {
|
75
|
+
request: {
|
76
|
+
method: HederaJsonRpcMethod.SignAndExecuteTransaction;
|
77
|
+
params: SignAndExecuteTransactionParams;
|
78
|
+
};
|
79
|
+
}
|
80
|
+
export interface SignAndExecuteTransactionResult extends JsonRpcResult<TransactionResponseJSON> {
|
81
|
+
}
|
82
|
+
export interface SignAndExecuteTransactionResponse extends EngineTypes.RespondParams {
|
83
|
+
response: SignAndExecuteTransactionResult;
|
84
|
+
}
|
85
|
+
export interface SignTransactionParams {
|
86
|
+
signerAccountId: string;
|
87
|
+
transactionBody: string;
|
88
|
+
}
|
89
|
+
export interface SignTransactionRequest extends EngineTypes.RequestParams {
|
90
|
+
request: {
|
91
|
+
method: HederaJsonRpcMethod.SignTransaction;
|
92
|
+
params: SignTransactionParams;
|
93
|
+
};
|
94
|
+
}
|
95
|
+
export interface SignTransactionResult extends JsonRpcResult<{
|
96
|
+
signatureMap: string;
|
97
|
+
}> {
|
98
|
+
}
|
99
|
+
export interface SignTransactionResponse extends EngineTypes.RespondParams {
|
100
|
+
response: SignTransactionResult;
|
101
|
+
}
|
102
|
+
//# sourceMappingURL=payloads.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"payloads.d.ts","sourceRoot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