Skip to content

Commit

Permalink
chore: update package versions and dependencies to improve compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Charon-Fan committed Feb 25, 2025
1 parent b0b7ef7 commit 4443a0f
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 194 deletions.
5 changes: 3 additions & 2 deletions packages/base-eth-keyring/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@keystonehq/base-eth-keyring",
"version": "0.14.1",
"version": "0.15.0",
"description": "base eth keyring",
"author": "aaronisme <[email protected]>",
"homepage": "https://github.com/KeystoneHQ/keystone-airgaped-base#readme",
Expand All @@ -26,8 +26,9 @@
"build": "tsdx build"
},
"dependencies": {
"@ethereumjs/tx": "^4.0.2",
"@ethereumjs/tx": "5.1.0",
"@ethereumjs/util": "^8.0.0",
"@ethereumjs/rlp": "^4.0.1",
"@keystonehq/bc-ur-registry-eth": "^0.19.1",
"hdkey": "^2.0.1",
"rlp": "^3.0.0",
Expand Down
28 changes: 21 additions & 7 deletions packages/base-eth-keyring/src/BaseKeyring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import {
publicToAddress,
stripHexPrefix,
} from "@ethereumjs/util";
import rlp from "rlp";
import { RLP } from "@ethereumjs/rlp";
import {
Transaction,
LegacyTransaction as Transaction,
FeeMarketEIP1559Transaction,
TransactionFactory,
TypedTransaction,
Expand Down Expand Up @@ -436,11 +436,11 @@ export class BaseKeyring {
let messageToSign: Buffer;
if (tx.type === 0) {
messageToSign = Buffer.from(
rlp.encode((tx as Transaction).getMessageToSign(false))
RLP.encode((tx as Transaction).getMessageToSign())
);
} else {
messageToSign = (tx as FeeMarketEIP1559Transaction).getMessageToSign(
false
messageToSign = Buffer.from(
(tx as FeeMarketEIP1559Transaction).serialize()
);
}
const hdPath = await this._pathFromAddress(address);
Expand Down Expand Up @@ -500,7 +500,14 @@ export class BaseKeyring {
"Scan with your Keystone",
'After your Keystone has signed this message, click on "Scan Keystone" to receive the signature'
);
return "0x" + Buffer.concat([r, s, v]).toString("hex");
return (
"0x" +
Buffer.concat([
Uint8Array.from(r),
Uint8Array.from(s),
Uint8Array.from(v),
]).toString("hex")
);
}

async signTypedData(withAccount: string, typedData: any): Promise<string> {
Expand All @@ -521,7 +528,14 @@ export class BaseKeyring {
"Scan with your Keystone",
'After your Keystone has signed this data, click on "Scan Keystone" to receive the signature'
);
return "0x" + Buffer.concat([r, s, v]).toString("hex");
return (
"0x" +
Buffer.concat([
Uint8Array.from(r),
Uint8Array.from(s),
Uint8Array.from(v),
]).toString("hex")
);
}

__addressFromIndex = async (pb: string, i: number): Promise<string> => {
Expand Down
8 changes: 5 additions & 3 deletions packages/metamask-airgapped-keyring/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@keystonehq/metamask-airgapped-keyring",
"version": "0.14.1",
"version": "0.15.0",
"description": "airgapped eth keyring for metamask",
"author": "aaronisme <[email protected]>",
"homepage": "https://github.com/KeystoneHQ/keystone-airgaped-base#readme",
Expand All @@ -26,8 +26,10 @@
"build": "tsdx build"
},
"dependencies": {
"@ethereumjs/tx": "^4.0.2",
"@keystonehq/base-eth-keyring": "^0.14.1",
"@ethereumjs/rlp": "^4.0.1",
"@ethereumjs/tx": "5.1.0",
"@ethereumjs/util": "9.1.0",
"@keystonehq/base-eth-keyring": "workspace:^",
"@keystonehq/bc-ur-registry-eth": "^0.19.1",
"@metamask/obs-store": "^9.0.0",
"rlp": "^2.2.6",
Expand Down
12 changes: 7 additions & 5 deletions packages/metamask-airgapped-keyring/src/MetaMaskKeyring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { BaseKeyring, StoredKeyring } from "@keystonehq/base-eth-keyring";
import { MetamaskInteractionProvider } from "./MetaMaskInteractionProvider";
import {
TransactionFactory,
Transaction,
LegacyTransaction as Transaction,
FeeMarketEIP1559Transaction,
} from "@ethereumjs/tx";
import { DataType, EthSignRequest } from "@keystonehq/bc-ur-registry-eth";
import * as uuid from "uuid";
import rlp from "rlp";
import { RLP } from "@ethereumjs/rlp";

export class MetaMaskKeyring extends BaseKeyring {
static type = BaseKeyring.type;
Expand Down Expand Up @@ -38,10 +38,12 @@ export class MetaMaskKeyring extends BaseKeyring {
tx.type === 0 ? DataType.transaction : DataType.typedTransaction;
let messageToSign;
if (tx.type === 0) {
messageToSign = rlp.encode((tx as Transaction).getMessageToSign(false));
messageToSign = Buffer.from(
RLP.encode((tx as Transaction).getMessageToSign())
);
} else {
messageToSign = (tx as FeeMarketEIP1559Transaction).getMessageToSign(
false
messageToSign = Buffer.from(
(tx as FeeMarketEIP1559Transaction).serialize()
);
}
const hdPath = await this._pathFromAddress(address);
Expand Down
Loading

0 comments on commit 4443a0f

Please sign in to comment.