Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@turnkey/ethers

Package Overview
Dependencies
Maintainers
2
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turnkey/ethers - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

11

CHANGELOG.md
# @turnkey/ethers
## 0.5.0
### Minor Changes
- Arbitrary message signing
### Patch Changes
- Updated dependencies
- @turnkey/http@0.5.0
## 0.4.0

@@ -4,0 +15,0 @@

4

dist/index.d.ts

@@ -36,4 +36,6 @@ import { ethers } from "ethers";

private _signTransactionWithErrorWrapping;
signMessage(_message: string | ethers.utils.Bytes): Promise<string>;
signTransaction(transaction: ethers.utils.Deferrable<ethers.providers.TransactionRequest>): Promise<string>;
signMessage(message: string): Promise<string>;
_signMessageWithErrorWrapping(message: string): Promise<string>;
_signMessageImpl(message: string): Promise<string>;
}

@@ -40,0 +42,0 @@ export declare function assertNonNull<T>(input: T | null | undefined): T;

@@ -90,5 +90,2 @@ "use strict";

}
async signMessage(_message) {
throw new Error("Not implemented yet");
}
async signTransaction(transaction) {

@@ -101,2 +98,55 @@ const unsignedTx = await ethers_1.ethers.utils.resolveProperties(transaction);

}
async signMessage(message) {
const nonHexPrefixedSerializedMessage = message.replace(/^0x/, "");
const signedMessage = await this._signMessageWithErrorWrapping(nonHexPrefixedSerializedMessage);
return `${signedMessage}`;
}
async _signMessageWithErrorWrapping(message) {
let signedMessage;
try {
signedMessage = await this._signMessageImpl(message);
}
catch (error) {
if (error instanceof TurnkeyActivityError) {
throw error;
}
throw new TurnkeyActivityError({
message: `Failed to sign`,
cause: error,
});
}
return signedMessage;
}
async _signMessageImpl(message) {
const { activity } = await http_1.PublicApiService.postSignRawPayload({
body: {
type: "ACTIVITY_TYPE_SIGN_RAW_PAYLOAD",
organizationId: this.config.organizationId,
parameters: {
privateKeyId: this.config.privateKeyId,
payload: message,
encoding: "PAYLOAD_ENCODING_TEXT_UTF8",
hashFunction: "HASH_FUNCTION_KECCAK256",
},
timestampMs: String(Date.now()), // millisecond timestamp
},
});
const { id, status, type } = activity;
if (activity.status === "ACTIVITY_STATUS_COMPLETED") {
let result = assertNonNull(activity?.result?.signRawPayloadResult);
let assembled = ethers_1.ethers.utils.joinSignature({
r: `0x${result.r}`,
s: `0x${result.s}`,
v: parseInt(result.v) + 27,
});
// assemble the hex
return assertNonNull(assembled);
}
throw new TurnkeyActivityError({
message: `Invalid activity status: ${activity.status}`,
activityId: id,
activityStatus: status,
activityType: type,
});
}
}

@@ -103,0 +153,0 @@ exports.TurnkeySigner = TurnkeySigner;

{
"name": "@turnkey/ethers",
"version": "0.4.0",
"version": "0.5.0",
"main": "./dist/index.js",

@@ -37,3 +37,3 @@ "types": "./dist/index.d.ts",

"dependencies": {
"@turnkey/http": "0.4.0"
"@turnkey/http": "0.5.0"
},

@@ -40,0 +40,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc