on master help sign in
Merge pull request #244 from urbit/trezor-hdpath

Actually set Trezor HD path on login

commit58b9f253fb3bd4f55f7d8a3acf7ec8a8cc221bd2 authorFang <Fang-@users.noreply.github.com> dateFri 23 Aug 2019, 11:24 (7 years ago) parent5ca110dba09d4e
2 files changed+9−5
src/lib/trezor.js+4 src/views/Login/Trezor.js+5−5
src/lib/trezor.js+4
@@ -21,6 +21,10 @@ const trezorSignTransaction = async (txn, hdpath) => {
2121 transaction: trezorFormattedTxn,
2222 });
2323
24+ if (!sig.success) {
25+ throw new Error(sig.payload.error);
26+ }
27+
2428 const payload = sig.payload;
2529
2630 txn.v = Buffer.from(payload.v.slice(2), 'hex');
src/views/Login/Trezor.js+5−5
@@ -42,7 +42,7 @@ export default function Trezor({ className, goHome }) {
4242 composeValidator({
4343 useCustomPath: buildCheckboxValidator(),
4444 account: buildSelectValidator(ACCOUNT_OPTIONS),
45− hdpath: buildHdPathValidator(),
45+ hdPath: buildHdPathValidator(),
4646 }),
4747 []
4848 );
@@ -55,7 +55,7 @@ export default function Trezor({ className, goHome }) {
5555 });
5656
5757 const { success, payload } = await TrezorConnect.getPublicKey({
58− path: values.hdpath,
58+ path: values.hdPath,
5959 });
6060
6161 if (!success) {
@@ -79,14 +79,14 @@ export default function Trezor({ className, goHome }) {
7979 }
8080
8181 if (!values.useCustomPath) {
82− form.change('hdpath', TREZOR_PATH.replace(/x/g, values.account));
82+ form.change('hdPath', TREZOR_PATH.replace(/x/g, values.account));
8383 }
8484 }, []);
8585
8686 const initialValues = useMemo(
8787 () => ({
8888 useCustomPath: false,
89− hdpath: TREZOR_PATH.replace(/x/g, ACCOUNT_OPTIONS[0].value),
89+ hdPath: TREZOR_PATH.replace(/x/g, ACCOUNT_OPTIONS[0].value),
9090 account: ACCOUNT_OPTIONS[0].value,
9191 }),
9292 []
@@ -112,7 +112,7 @@ export default function Trezor({ className, goHome }) {
112112 {({ handleSubmit }) => (
113113 <>
114114 <Condition when="useCustomPath" is={true}>
115− <Grid.Item full as={HdPathInput} name="hdpath" label="HD Path" />
115+ <Grid.Item full as={HdPathInput} name="hdPath" label="HD Path" />
116116 </Condition>
117117
118118 <Condition when="useCustomPath" is={false}>