@hashgraph/hedera-wallet-connect 1.4.1-canary.b18a552.0 → 1.4.2-canary.541ffd1.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.
@@ -1,8 +1,8 @@
1
- import { AccountId, LedgerId } from '@hashgraph/sdk';
1
+ import { AccountId, LedgerId, Transaction } 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, ExtensionData } from '../shared';
5
+ import { GetNodeAddressesResult, ExecuteTransactionParams, ExecuteTransactionResult, SignMessageParams, SignMessageResult, SignAndExecuteQueryResult, SignAndExecuteQueryParams, SignAndExecuteTransactionParams, SignAndExecuteTransactionResult, SignTransactionParams, SignTransactionResult, 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,20 +195,21 @@ 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 {Transaction} params.transaction - a built Transaction.
198
+ * @param {Transaction | string} params.transactionBody - a built Transaction object, or a base64 string of a transaction body (deprecated).
199
+ * @deprecated Using string for params.transactionBody is deprecated and will be removed in a future version. Please migrate to using Transaction objects directly.
199
200
  * @returns Promise\<{@link SignTransactionResult}\>
200
201
  * @example
201
202
  * ```ts
202
203
  *
203
204
  * const params = {
204
205
  * signerAccountId: '0.0.12345',
205
- * transaction
206
+ * transactionBody
206
207
  * }
207
208
  *
208
209
  * const result = await dAppConnector.signTransaction(params)
209
210
  * ```
210
211
  */
211
- signTransaction(params: SignTransactionParams): Promise<import("@hashgraph/sdk").Transaction>;
212
+ signTransaction(params: SignTransactionParams): Promise<Transaction | SignTransactionResult>;
212
213
  private handleSessionEvent;
213
214
  private handleSessionUpdate;
214
215
  private handleSessionDelete;
@@ -17,7 +17,7 @@
17
17
  * limitations under the License.
18
18
  *
19
19
  */
20
- import { LedgerId } from '@hashgraph/sdk';
20
+ import { LedgerId, Transaction } from '@hashgraph/sdk';
21
21
  import QRCodeModal from '@walletconnect/qrcode-modal';
22
22
  import { WalletConnectModal } from '@walletconnect/modal';
23
23
  import SignClient from '@walletconnect/sign-client';
@@ -486,14 +486,15 @@ 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 {Transaction} params.transaction - a built Transaction.
489
+ * @param {Transaction | string} params.transactionBody - a built Transaction object, or a base64 string of a transaction body (deprecated).
490
+ * @deprecated Using string for params.transactionBody is deprecated and will be removed in a future version. Please migrate to using Transaction objects directly.
490
491
  * @returns Promise\<{@link SignTransactionResult}\>
491
492
  * @example
492
493
  * ```ts
493
494
  *
494
495
  * const params = {
495
496
  * signerAccountId: '0.0.12345',
496
- * transaction
497
+ * transactionBody
497
498
  * }
498
499
  *
499
500
  * const result = await dAppConnector.signTransaction(params)
@@ -501,15 +502,25 @@ export class DAppConnector {
501
502
  */
502
503
  async signTransaction(params) {
503
504
  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}`);
505
+ if (typeof (params === null || params === void 0 ? void 0 : params.transactionBody) === 'string') {
506
+ this.logger.warn('Transaction body is a string. This is not recommended, please migrate to passing a transaction object directly.');
507
+ return await this.request({
508
+ method: HederaJsonRpcMethod.SignTransaction,
509
+ params,
510
+ });
508
511
  }
509
- if (!(params === null || params === void 0 ? void 0 : params.transaction)) {
510
- throw new Error('No transaction provided');
512
+ if ((params === null || params === void 0 ? void 0 : params.transactionBody) instanceof Transaction) {
513
+ 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();
514
+ 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; });
515
+ if (!accountSigner) {
516
+ throw new Error(`No signer found for account ${signerAccountId}`);
517
+ }
518
+ if (!(params === null || params === void 0 ? void 0 : params.transactionBody)) {
519
+ throw new Error('No transaction provided');
520
+ }
521
+ return await accountSigner.signTransaction(params.transactionBody);
511
522
  }
512
- return await accountSigner.signTransaction(params.transaction);
523
+ throw new Error('Transaction sent in incorrect format. Ensure transaction body is either a base64 transaction body or Transaction object.');
513
524
  }
514
525
  handleSessionEvent(args) {
515
526
  this.logger.debug('Session event received:', args);
@@ -84,7 +84,11 @@ export interface SignAndExecuteTransactionResponse extends EngineTypes.RespondPa
84
84
  }
85
85
  export interface SignTransactionParams {
86
86
  signerAccountId: string;
87
- transaction: Transaction;
87
+ /**
88
+ * @deprecated Using string for transactionBody is deprecated and will be removed in a future version.
89
+ * Please migrate to using Transaction objects directly.
90
+ */
91
+ transactionBody: Transaction | string;
88
92
  }
89
93
  export interface SignTransactionRequest extends EngineTypes.RequestParams {
90
94
  request: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hashgraph/hedera-wallet-connect",
3
- "version": "1.4.1-canary.b18a552.0",
3
+ "version": "1.4.2-canary.541ffd1.0",
4
4
  "description": "A library to facilitate integrating Hedera with WalletConnect",
5
5
  "repository": {
6
6
  "type": "git",