-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c23a6a8
commit e78a60f
Showing
6 changed files
with
338 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import baseConfig from "../../jest.config"; | ||
|
||
export default { | ||
...baseConfig, | ||
rootDir: __dirname, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "@ledgerhq/keyring-eth", | ||
"version": "0.0.1", | ||
"description": "Ledger keyring eth module", | ||
"files": [ | ||
"./lib" | ||
], | ||
"scripts": { | ||
"build": "rimraf lib && tsc", | ||
"test": "jest" | ||
}, | ||
"keywords": [], | ||
"license": "Apache-2.0", | ||
"devDependencies": { | ||
"@tsconfig/recommended": "^1.0.6", | ||
"@types/jest": "^29.5.12", | ||
"@types/node": "^20.12.7", | ||
"jest": "^29.7.0", | ||
"rimraf": "^5.0.5", | ||
"ts-jest": "^29.1.2", | ||
"ts-node": "^10.9.2", | ||
"typescript": "^5.4.5" | ||
}, | ||
"dependencies": { | ||
"@ledgerhq/context-module": "workspace:^", | ||
"@ledgerhq/hw-app-eth": "workspace:^", | ||
"@ledgerhq/hw-transport": "workspace:^", | ||
"ethers": "^5.7.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { Transaction } from "ethers"; | ||
import Transport from "@ledgerhq/hw-transport"; | ||
import AppBinding from "@ledgerhq/hw-app-eth"; | ||
import { ForwardDomainOptions } from "@ledgerhq/context-module/lib/models/LoaderOptions"; | ||
import { EIP712Message } from "../../types-live/lib"; | ||
|
||
type SignTransactionArgs = { | ||
derivationPath: string; | ||
transaction: Transaction; | ||
options?: { forwardDomainOptions?: ForwardDomainOptions }; // TODO: TBD | ||
}; | ||
|
||
type SignMessageArgs = { | ||
derivationPath: string; | ||
message: string | EIP712Message; // EIP-712/EIP-191 | ||
options: { | ||
type: "EIP-191" | "EIP-712"; | ||
context: any; // TODO: TBD | ||
}; | ||
}; | ||
|
||
type GetAddressArgs = { | ||
derivationPath: string; | ||
options: object; //TBD needVerify | ||
}; | ||
|
||
export interface EthKeyring { | ||
signTransaction(args: SignTransactionArgs): Promise<EcdsaSignature>; | ||
signMessage(args: SignMessageArgs): Promise<EcdsaSignature>; | ||
getAddress(args: GetAddressArgs): Promise<{ address: string; options: string }>; | ||
} | ||
|
||
export type EcdsaSignature = { r: `0x${string}`; s: `0x${string}`; v: number }; | ||
|
||
export class DefaultEthKeyring implements EthKeyring { | ||
private _appBinding: AppBinding; | ||
|
||
constructor(transport: Transport) { | ||
this._appBinding = new AppBinding(transport); | ||
} | ||
|
||
public async signTransaction({ | ||
derivationPath: _derivationPath, | ||
transaction: _transaction, | ||
options: _options, | ||
}: SignTransactionArgs) { | ||
return Promise.resolve({ r: "0x", s: "0x", v: 0 } as EcdsaSignature); | ||
} | ||
|
||
public async signMessage({ | ||
derivationPath: _derivationPath, | ||
message: _message, | ||
options: _options, | ||
}: SignMessageArgs) { | ||
return Promise.resolve({ r: "0x", s: "0x", v: 0 } as EcdsaSignature); | ||
} | ||
|
||
public async getAddress({ derivationPath: _derivationPath, options: _options }: GetAddressArgs) { | ||
return Promise.resolve({ address: "", options: "" }); | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "lib" | ||
}, | ||
"include": ["src/**/*"] | ||
} |
Oops, something went wrong.