@hashgraph/hedera-wallet-connect 1.3.8-canary.25ba652.0 → 1.3.8-canary.5466394.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -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?:
|
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,
|
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
|
-
|
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:
|
109
|
+
message: messageToSign,
|
106
110
|
},
|
107
111
|
});
|
108
112
|
const sigmap = base64StringToSignatureMap(signatureMap);
|
@@ -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
|
package/dist/lib/shared/utils.js
CHANGED
@@ -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,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@hashgraph/hedera-wallet-connect",
|
3
|
-
"version": "1.3.8-canary.
|
3
|
+
"version": "1.3.8-canary.5466394.0",
|
4
4
|
"description": "A library to facilitate integrating Hedera with WalletConnect",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -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",
|