@hashgraph/hedera-wallet-connect 1.3.8-canary.afbe057.0 → 1.3.8-canary.e37de31.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. package/dist/index.d.ts +1 -3
  2. package/dist/index.js +1 -3
  3. package/dist/{dapp → lib/dapp}/DAppSigner.d.ts +3 -1
  4. package/dist/{dapp → lib/dapp}/DAppSigner.js +8 -4
  5. package/dist/lib/index.d.ts +3 -0
  6. package/dist/lib/index.js +22 -0
  7. package/dist/{shared → lib/shared}/utils.d.ts +6 -0
  8. package/dist/{shared → lib/shared}/utils.js +8 -0
  9. package/package.json +4 -3
  10. /package/dist/{dapp → lib/dapp}/index.d.ts +0 -0
  11. /package/dist/{dapp → lib/dapp}/index.js +0 -0
  12. /package/dist/{shared → lib/shared}/chainIds.d.ts +0 -0
  13. /package/dist/{shared → lib/shared}/chainIds.js +0 -0
  14. /package/dist/{shared → lib/shared}/errors.d.ts +0 -0
  15. /package/dist/{shared → lib/shared}/errors.js +0 -0
  16. /package/dist/{shared → lib/shared}/events.d.ts +0 -0
  17. /package/dist/{shared → lib/shared}/events.js +0 -0
  18. /package/dist/{shared → lib/shared}/extensionController.d.ts +0 -0
  19. /package/dist/{shared → lib/shared}/extensionController.js +0 -0
  20. /package/dist/{shared → lib/shared}/index.d.ts +0 -0
  21. /package/dist/{shared → lib/shared}/index.js +0 -0
  22. /package/dist/{shared → lib/shared}/logger.d.ts +0 -0
  23. /package/dist/{shared → lib/shared}/logger.js +0 -0
  24. /package/dist/{shared → lib/shared}/methods.d.ts +0 -0
  25. /package/dist/{shared → lib/shared}/methods.js +0 -0
  26. /package/dist/{shared → lib/shared}/payloads.d.ts +0 -0
  27. /package/dist/{shared → lib/shared}/payloads.js +0 -0
  28. /package/dist/{wallet → lib/wallet}/index.d.ts +0 -0
  29. /package/dist/{wallet → lib/wallet}/index.js +0 -0
  30. /package/dist/{wallet → lib/wallet}/provider.d.ts +0 -0
  31. /package/dist/{wallet → lib/wallet}/provider.js +0 -0
  32. /package/dist/{wallet → lib/wallet}/types.d.ts +0 -0
  33. /package/dist/{wallet → lib/wallet}/types.js +0 -0
package/dist/index.d.ts CHANGED
@@ -1,3 +1 @@
1
- export * from './shared';
2
- export { default as Wallet } from './wallet';
3
- export * from './dapp';
1
+ export * from './lib';
package/dist/index.js CHANGED
@@ -17,6 +17,4 @@
17
17
  * limitations under the License.
18
18
  *
19
19
  */
20
- export * from './shared';
21
- export { default as Wallet } from './wallet';
22
- export * from './dapp';
20
+ export * from './lib';
@@ -31,7 +31,9 @@ export declare class DAppSigner implements Signer {
31
31
  getAccountInfo(): Promise<AccountInfo>;
32
32
  getAccountRecords(): Promise<TransactionRecord[]>;
33
33
  getMetadata(): CoreTypes.Metadata;
34
- sign(data: Uint8Array[], signOptions?: Record<string, any>): Promise<SignerSignature[]>;
34
+ sign(data: Uint8Array[], signOptions?: {
35
+ encoding?: 'utf-8' | 'base64';
36
+ }): Promise<SignerSignature[]>;
35
37
  checkTransaction<T extends Transaction>(transaction: T): Promise<T>;
36
38
  populateTransaction<T extends Transaction>(transaction: T): Promise<T>;
37
39
  /**
@@ -19,7 +19,7 @@
19
19
  */
20
20
  import { AccountBalance, AccountId, AccountInfo, LedgerId, SignerSignature, Transaction, TransactionRecord, Client, PublicKey, TransactionId, TransactionResponse, Query, AccountRecordsQuery, AccountInfoQuery, AccountBalanceQuery, TransactionReceiptQuery, TransactionReceipt, TransactionRecordQuery, } from '@hashgraph/sdk';
21
21
  import { proto } from '@hashgraph/proto';
22
- import { HederaJsonRpcMethod, Uint8ArrayToBase64String, base64StringToSignatureMap, base64StringToUint8Array, ledgerIdToCAIPChainId, queryToBase64String, transactionBodyToBase64String, transactionToBase64String, transactionToTransactionBody, extensionOpen, } from '../shared';
22
+ import { HederaJsonRpcMethod, base64StringToSignatureMap, base64StringToUint8Array, ledgerIdToCAIPChainId, queryToBase64String, transactionBodyToBase64String, transactionToBase64String, transactionToTransactionBody, extensionOpen, Uint8ArrayToBase64String, Uint8ArrayToString, } from '../shared';
23
23
  import { DefaultLogger } from '../shared/logger';
24
24
  const clients = {};
25
25
  export class DAppSigner {
@@ -95,14 +95,18 @@ export class DAppSigner {
95
95
  getMetadata() {
96
96
  return this.signClient.metadata;
97
97
  }
98
- async sign(data, signOptions) {
99
- this.logger.debug('Signing data');
98
+ async sign(data, signOptions = {
99
+ encoding: 'utf-8',
100
+ }) {
100
101
  try {
102
+ const messageToSign = signOptions.encoding === 'base64'
103
+ ? Uint8ArrayToBase64String(data[0])
104
+ : Uint8ArrayToString(data[0]);
101
105
  const { signatureMap } = await this.request({
102
106
  method: HederaJsonRpcMethod.SignMessage,
103
107
  params: {
104
108
  signerAccountId: this._signerAccountId,
105
- message: Uint8ArrayToBase64String(data[0]),
109
+ message: messageToSign,
106
110
  },
107
111
  });
108
112
  const sigmap = base64StringToSignatureMap(signatureMap);
@@ -0,0 +1,3 @@
1
+ export * from './shared';
2
+ export { default as Wallet } from './wallet';
3
+ export * from './dapp';
@@ -0,0 +1,22 @@
1
+ /*
2
+ *
3
+ * Hedera Wallet Connect
4
+ *
5
+ * Copyright (C) 2023 Hedera Hashgraph, LLC
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ *
19
+ */
20
+ export * from './shared';
21
+ export { default as Wallet } from './wallet';
22
+ export * from './dapp';
@@ -85,6 +85,12 @@ export declare function base64StringToSignatureMap(base64string: string): proto.
85
85
  * @returns Base64-encoded string representation of the input `Uint8Array`
86
86
  */
87
87
  export declare function Uint8ArrayToBase64String(binary: Uint8Array): string;
88
+ /**
89
+ * Encodes the binary data represented by the `Uint8Array` to a UTF-8 string.
90
+ * @param binary - The `Uint8Array` containing binary data to be converted
91
+ * @returns UTF-8 string representation of the input `Uint8Array`
92
+ */
93
+ export declare function Uint8ArrayToString(binary: Uint8Array): string;
88
94
  /**
89
95
  * Converts a Base64-encoded string to a `Uint8Array`.
90
96
  * @param base64string - Base64-encoded string to be converted
@@ -139,6 +139,14 @@ export function base64StringToSignatureMap(base64string) {
139
139
  export function Uint8ArrayToBase64String(binary) {
140
140
  return Buffer.from(binary).toString('base64');
141
141
  }
142
+ /**
143
+ * Encodes the binary data represented by the `Uint8Array` to a UTF-8 string.
144
+ * @param binary - The `Uint8Array` containing binary data to be converted
145
+ * @returns UTF-8 string representation of the input `Uint8Array`
146
+ */
147
+ export function Uint8ArrayToString(binary) {
148
+ return Buffer.from(binary).toString('utf-8');
149
+ }
142
150
  /**
143
151
  * Converts a Base64-encoded string to a `Uint8Array`.
144
152
  * @param base64string - Base64-encoded string to be converted
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@hashgraph/hedera-wallet-connect",
3
- "version": "1.3.8-canary.afbe057.0",
3
+ "version": "1.3.8-canary.e37de31.0",
4
4
  "description": "A library to facilitate integrating Hedera with WalletConnect",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/hashgraph/hedera-wallet-connect.git"
8
8
  },
9
- "main": "./dist/src/index.js",
10
- "types": "./dist/src/index.d.ts",
9
+ "main": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
11
  "author": "Hgraph <support@hgraph.io>",
12
12
  "keywords": [
13
13
  "hedera",
@@ -55,6 +55,7 @@
55
55
  "dev:ts-demo": "rimraf dist && npm run build && concurrently --raw \"npm run watch\" \"node scripts/demos/typescript/dev.mjs\"",
56
56
  "dev:react-demo": "rimraf dist && npm run build && concurrently --raw \"npm run watch\" \"node scripts/demos/react/dev.mjs\"",
57
57
  "test": "jest",
58
+ "test:watch": "jest --watch",
58
59
  "test:connect": "jest --testMatch '**/DAppConnector.test.ts' --verbose",
59
60
  "test:signer": "jest --testMatch '**/DAppSigner.test.ts' --verbose",
60
61
  "prepublishOnly": "rm -Rf dist && npm run build",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes