-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browser support (with dist files) for Ledger.
- Loading branch information
Showing
5 changed files
with
143 additions
and
55 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 |
---|---|---|
@@ -1,17 +1,15 @@ | ||
{ | ||
"author": "Richard Moore <[email protected]>", | ||
"browser": { | ||
"./lib.esm/ledger-transport.js": "./lib.esm/browser-ledger-transport.js", | ||
"ethers": "./lib.esm/browser-ethers.js" | ||
}, | ||
"dependencies": { | ||
"@ethersproject/abstract-provider": ">=5.0.0-beta.136", | ||
"@ethersproject/abstract-signer": ">=5.0.0-beta.137", | ||
"@ethersproject/address": ">=5.0.0-beta.134", | ||
"@ethersproject/bytes": ">=5.0.0-beta.134", | ||
"@ethersproject/properties": ">=5.0.0-beta.136", | ||
"@ethersproject/strings": ">=5.0.0-beta.135", | ||
"@ethersproject/transactions": ">=5.0.0-beta.133", | ||
"@ledgerhq/hw-app-eth": "5.3.0", | ||
"@ledgerhq/hw-transport": "5.3.0", | ||
"@ledgerhq/hw-transport-node-hid": "5.3.0", | ||
"@ledgerhq/hw-transport-u2f": "5.3.0" | ||
"@ledgerhq/hw-transport-u2f": "5.3.0", | ||
"ethers": "5.0.0-beta.166" | ||
}, | ||
"description": "Hardware Wallet support for ethers.", | ||
"devDependencies": { | ||
|
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,12 @@ | ||
"use strict"; | ||
|
||
let ethers: any = { }; | ||
|
||
const w = (window as any); | ||
if (w._ethers == null) { | ||
console.log("WARNING: @ethersproject/hardware-wallet requires ethers loaded first"); | ||
} else { | ||
ethers = w._ethers; | ||
} | ||
|
||
export { ethers } |
12 changes: 12 additions & 0 deletions
12
packages/hardware-wallets/src.ts/browser-ledger-transport.ts
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,12 @@ | ||
"use strict"; | ||
|
||
import u2f from "@ledgerhq/hw-transport-u2f"; | ||
|
||
export type TransportCreator = { | ||
create: () => Promise<Transport>; | ||
}; | ||
|
||
export const transports: { [ name: string ]: TransportCreator } = { | ||
"u2f": u2f, | ||
"default": u2f | ||
}; |
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
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,53 @@ | ||
"use strict"; | ||
|
||
import resolve from 'rollup-plugin-node-resolve'; | ||
import commonjs from 'rollup-plugin-commonjs'; | ||
import _globals from 'rollup-plugin-node-globals'; | ||
|
||
import { terser } from "rollup-plugin-terser"; | ||
|
||
function getConfig(project, minify) { | ||
|
||
const suffix = [ "esm" ]; | ||
|
||
const plugins = [ | ||
resolve({ | ||
mainFields: [ "browser", "module", "main" ], | ||
preferBuiltins: false | ||
}), | ||
commonjs({ | ||
namedExports: { | ||
"bn.js": [ "BN" ], | ||
"elliptic": [ "ec" ], | ||
"scrypt-js": [ "scrypt" ], | ||
"u2f-api": [ "isSupported", "sign" ], | ||
"js-sha3": [ null ] | ||
}, | ||
}), | ||
_globals(), | ||
]; | ||
|
||
if (minify) { | ||
suffix.push("min"); | ||
plugins.push(terser()); | ||
} | ||
|
||
return { | ||
input: `packages/${ project }/lib.esm/index.js`, | ||
output: { | ||
file: `packages/${ project }/dist/hardware-wallets.${ suffix.join(".") }.js`, | ||
format: "esm", | ||
name: "_ethersAncillary", | ||
exports: "named" | ||
}, | ||
context: "window", | ||
treeshake: false, | ||
plugins: plugins | ||
}; | ||
} | ||
|
||
export default [ | ||
getConfig("hardware-wallets", false), | ||
getConfig("hardware-wallets", true), | ||
] | ||
|