@hashgraph/hedera-wallet-connect 1.3.8-canary.5466394.0 → 1.3.8-canary.5c326ed.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.
@@ -234,9 +234,7 @@ export class DAppSigner {
234
234
  if (!(result === null || result === void 0 ? void 0 : result.error)) {
235
235
  return { result: result.result };
236
236
  }
237
- else {
238
- this.logger.error('Error executing free receipt query. Sending to wallet.', result.error);
239
- }
237
+ this.logger.error('Error executing free receipt query. Sending to wallet.', result.error);
240
238
  }
241
239
  /**
242
240
  * Note, should we be converting these to specific query types?
@@ -2,7 +2,7 @@ import { AccountId, LedgerId } from '@hashgraph/sdk';
2
2
  import { SessionTypes, SignClientTypes } from '@walletconnect/types';
3
3
  import { WalletConnectModal } from '@walletconnect/modal';
4
4
  import SignClient from '@walletconnect/sign-client';
5
- import { GetNodeAddressesResult, ExecuteTransactionParams, ExecuteTransactionResult, SignMessageParams, SignMessageResult, SignAndExecuteQueryResult, SignAndExecuteQueryParams, SignAndExecuteTransactionParams, SignAndExecuteTransactionResult, SignTransactionParams, SignTransactionResult, ExtensionData } from '../shared';
5
+ import { GetNodeAddressesResult, ExecuteTransactionParams, ExecuteTransactionResult, SignMessageParams, SignMessageResult, SignAndExecuteQueryResult, SignAndExecuteQueryParams, SignAndExecuteTransactionParams, SignAndExecuteTransactionResult, SignTransactionParams, ExtensionData } from '../shared';
6
6
  import { DAppSigner } from './DAppSigner';
7
7
  export * from './DAppSigner';
8
8
  type BaseLogger = 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'fatal';
@@ -195,22 +195,20 @@ export declare class DAppConnector {
195
195
  *
196
196
  * @param {SignTransactionParams} params - The parameters of type {@link SignTransactionParams | `SignTransactionParams`} required for `Transaction` signing.
197
197
  * @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.
198
- * @param {string[]} params.transaction - Array of Base64-encoded `Transaction`'s
198
+ * @param {Transaction} params.transaction - a built Transaction.
199
199
  * @returns Promise\<{@link SignTransactionResult}\>
200
200
  * @example
201
201
  * ```ts
202
- * const transactionBodyObject = transactionToTransactionBody(transaction, AccountId.fromString('0.0.3'))
203
- * const transactionBody = transactionBodyToBase64String(transactionBodyObject)
204
202
  *
205
203
  * const params = {
206
204
  * signerAccountId: '0.0.12345',
207
- * transactionBody
205
+ * transaction
208
206
  * }
209
207
  *
210
208
  * const result = await dAppConnector.signTransaction(params)
211
209
  * ```
212
210
  */
213
- signTransaction(params: SignTransactionParams): Promise<SignTransactionResult>;
211
+ signTransaction(params: SignTransactionParams): Promise<import("@hashgraph/sdk").Transaction>;
214
212
  private handleSessionEvent;
215
213
  private handleSessionUpdate;
216
214
  private handleSessionDelete;
@@ -486,26 +486,30 @@ export class DAppConnector {
486
486
  *
487
487
  * @param {SignTransactionParams} params - The parameters of type {@link SignTransactionParams | `SignTransactionParams`} required for `Transaction` signing.
488
488
  * @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.
489
- * @param {string[]} params.transaction - Array of Base64-encoded `Transaction`'s
489
+ * @param {Transaction} params.transaction - a built Transaction.
490
490
  * @returns Promise\<{@link SignTransactionResult}\>
491
491
  * @example
492
492
  * ```ts
493
- * const transactionBodyObject = transactionToTransactionBody(transaction, AccountId.fromString('0.0.3'))
494
- * const transactionBody = transactionBodyToBase64String(transactionBodyObject)
495
493
  *
496
494
  * const params = {
497
495
  * signerAccountId: '0.0.12345',
498
- * transactionBody
496
+ * transaction
499
497
  * }
500
498
  *
501
499
  * const result = await dAppConnector.signTransaction(params)
502
500
  * ```
503
501
  */
504
502
  async signTransaction(params) {
505
- return await this.request({
506
- method: HederaJsonRpcMethod.SignTransaction,
507
- params,
508
- });
503
+ var _a, _b;
504
+ 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();
505
+ const accountSigner = this.signers.find((signer) => { var _a; return ((_a = signer === null || signer === void 0 ? void 0 : signer.getAccountId()) === null || _a === void 0 ? void 0 : _a.toString()) === signerAccountId; });
506
+ if (!accountSigner) {
507
+ throw new Error(`No signer found for account ${signerAccountId}`);
508
+ }
509
+ if (!(params === null || params === void 0 ? void 0 : params.transaction)) {
510
+ throw new Error('No transaction provided');
511
+ }
512
+ return await accountSigner.signTransaction(params.transaction);
509
513
  }
510
514
  handleSessionEvent(args) {
511
515
  this.logger.debug('Session event received:', args);
@@ -1,6 +1,6 @@
1
1
  import { JsonRpcResult } from '@walletconnect/jsonrpc-types';
2
2
  import { EngineTypes } from '@walletconnect/types';
3
- import type { TransactionResponseJSON } from '@hashgraph/sdk';
3
+ import type { Transaction, TransactionResponseJSON } from '@hashgraph/sdk';
4
4
  import { HederaJsonRpcMethod } from './methods';
5
5
  /**
6
6
  * Defines various types and interfaces for Hedera JSON-RPC methods.
@@ -84,7 +84,7 @@ export interface SignAndExecuteTransactionResponse extends EngineTypes.RespondPa
84
84
  }
85
85
  export interface SignTransactionParams {
86
86
  signerAccountId: string;
87
- transactionBody: string;
87
+ transaction: Transaction;
88
88
  }
89
89
  export interface SignTransactionRequest extends EngineTypes.RequestParams {
90
90
  request: {
@@ -56,6 +56,12 @@ export declare function transactionBodyToBase64String(transactionBody: proto.ITr
56
56
  * @returns `string`
57
57
  * */
58
58
  export declare function transactionListToBase64String(transactionList: proto.TransactionList): string;
59
+ /**
60
+ * Extracts the first signature from a proto.SignatureMap object.
61
+ * @param signatureMap - a proto.SignatureMap object
62
+ * @returns `Uint8Array`
63
+ * */
64
+ export declare const extractFirstSignature: (signatureMap: proto.ISignatureMap) => Uint8Array;
59
65
  /**
60
66
  * Decodes base64 encoded proto.TransactionBody bytes to a `proto.TransactionBody` object.
61
67
  *
@@ -99,6 +99,20 @@ export function transactionListToBase64String(transactionList) {
99
99
  const encoded = proto.TransactionList.encode(transactionList).finish();
100
100
  return Uint8ArrayToBase64String(encoded);
101
101
  }
102
+ /**
103
+ * Extracts the first signature from a proto.SignatureMap object.
104
+ * @param signatureMap - a proto.SignatureMap object
105
+ * @returns `Uint8Array`
106
+ * */
107
+ export const extractFirstSignature = (signatureMap) => {
108
+ var _a;
109
+ const firstPair = (_a = signatureMap === null || signatureMap === void 0 ? void 0 : signatureMap.sigPair) === null || _a === void 0 ? void 0 : _a[0];
110
+ const firstSignature = (firstPair === null || firstPair === void 0 ? void 0 : firstPair.ed25519) || (firstPair === null || firstPair === void 0 ? void 0 : firstPair.ECDSASecp256k1) || (firstPair === null || firstPair === void 0 ? void 0 : firstPair.ECDSA_384);
111
+ if (!firstSignature) {
112
+ throw new Error('No signatures found in response');
113
+ }
114
+ return firstSignature;
115
+ };
102
116
  /**
103
117
  * Decodes base64 encoded proto.TransactionBody bytes to a `proto.TransactionBody` object.
104
118
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hashgraph/hedera-wallet-connect",
3
- "version": "1.3.8-canary.5466394.0",
3
+ "version": "1.3.8-canary.5c326ed.0",
4
4
  "description": "A library to facilitate integrating Hedera with WalletConnect",
5
5
  "repository": {
6
6
  "type": "git",
@@ -28,12 +28,12 @@
28
28
  "concurrently": "^9.0.1",
29
29
  "esbuild": "^0.24.0",
30
30
  "esbuild-plugin-copy": "^2.1.1",
31
- "eslint-plugin-tsdoc": "^0.3.0",
31
+ "eslint-plugin-tsdoc": "^0.4.0",
32
32
  "husky": "^9.0.6",
33
33
  "jest": "^29.7.0",
34
34
  "lint-staged": "^15.1.0",
35
- "long": "^5.2.3",
36
35
  "lokijs": "^1.5.12",
36
+ "long": "^5.2.3",
37
37
  "nodemon": "^3.0.3",
38
38
  "prettier": "^3.2.4",
39
39
  "react": "^18.2.0",
@@ -42,7 +42,8 @@
42
42
  "ts-node": "^10.9.2",
43
43
  "typedoc": "^0.26.3",
44
44
  "typedoc-theme-hierarchy": "^4.1.2",
45
- "typescript": "^5.2.2"
45
+ "typescript": "^5.2.2",
46
+ "tweetnacl": "^1.0.3"
46
47
  },
47
48
  "scripts": {
48
49
  "build": "rimraf dist && tsc",