@turnkey/ethers
Advanced tools
Comparing version 0.5.0 to 0.6.0-beta.0
@@ -1,2 +0,2 @@ | ||
import { ethers } from "ethers"; | ||
import { ethers, type Bytes } from "ethers"; | ||
import { PublicApiService } from "@turnkey/http"; | ||
@@ -37,3 +37,3 @@ type TActivity = PublicApiService.TPostGetActivityResponse["activity"]; | ||
signTransaction(transaction: ethers.utils.Deferrable<ethers.providers.TransactionRequest>): Promise<string>; | ||
signMessage(message: string): Promise<string>; | ||
signMessage(message: string | Bytes): Promise<string>; | ||
_signMessageWithErrorWrapping(message: string): Promise<string>; | ||
@@ -40,0 +40,0 @@ _signMessageImpl(message: string): Promise<string>; |
@@ -97,5 +97,9 @@ "use strict"; | ||
} | ||
// Returns the signed prefixed-message. Per Ethers spec, this method treats: | ||
// - Bytes as a binary message | ||
// - string as a UTF8-message | ||
// i.e. "0x1234" is a SIX (6) byte string, NOT 2 bytes of data | ||
async signMessage(message) { | ||
const nonHexPrefixedSerializedMessage = message.replace(/^0x/, ""); | ||
const signedMessage = await this._signMessageWithErrorWrapping(nonHexPrefixedSerializedMessage); | ||
const hashedMessage = ethers_1.ethers.utils.hashMessage(message); | ||
const signedMessage = await this._signMessageWithErrorWrapping(hashedMessage); | ||
return `${signedMessage}`; | ||
@@ -127,4 +131,4 @@ } | ||
payload: message, | ||
encoding: "PAYLOAD_ENCODING_TEXT_UTF8", | ||
hashFunction: "HASH_FUNCTION_KECCAK256", | ||
encoding: "PAYLOAD_ENCODING_HEXADECIMAL", | ||
hashFunction: "HASH_FUNCTION_NO_OP", | ||
}, | ||
@@ -131,0 +135,0 @@ timestampMs: String(Date.now()), // millisecond timestamp |
{ | ||
"name": "@turnkey/ethers", | ||
"version": "0.5.0", | ||
"version": "0.6.0-beta.0", | ||
"main": "./dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "./dist/index.d.ts", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30620
209