Skip to content
This repository has been archived by the owner on Aug 7, 2019. It is now read-only.

Bugfix/eth get address #11

Merged
merged 5 commits into from
Jan 17, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
},
"dependencies": {
"bytebuffer": "git+https://[email protected]/spiceboi/bytebuffer.js.git",
"device-protocol": "git+https://[email protected]/KeepKey/device-protocol.git#4ee29339fb8a9c916bcba9079aebd5254a16df08",
"device-protocol": "git+https://[email protected]/KeepKey/device-protocol.git#v6.0.1",
"eventemitter2": "^5.0.1",
"google-protobuf": "^3.6.1",
"p-queue": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default abstract class Device {
buffer: sentBuffer.toString('hex'),
interface: this.interface
}))
const [responseTypeEnum, responseMsg] = await this.fromMessageBuffer(responseBuffer)
const [responseTypeEnum, responseMsg] = this.fromMessageBuffer(responseBuffer)
this.events.emit(String(responseTypeEnum), makeEvent({
message_enum: responseTypeEnum,
message: responseMsg.toObject(),
Expand Down
7 changes: 3 additions & 4 deletions src/keepkey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ export default class KeepKey {
getAddr.setShowDisplay(a.showDisplay)
// send, receive ethereumaddress message
const [_, response] = await this.device.exchange(Messages.MessageType.MESSAGETYPE_ETHEREUMGETADDRESS, getAddr)
const { addressNList } = (response as Messages.EthereumGetAddress).toObject()
return addressNList.join('')
const { address, addressStr } = (response as Messages.EthereumAddress).toObject()
return addressStr || address as string
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return addressStr || address as string
return addressStr || ('0x' + (address as string))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... because addressStr has that in it, but address does not.

}

// Sign an ethereum transaction using a given node path
Expand Down Expand Up @@ -334,8 +334,7 @@ export default class KeepKey {
coinShortcut: symbol,
bip44AccountPath: coinType.bip44AccountPath,
curveName: coinType.curveName,
coinName: coinType.coinName,
gasLimit: coinType.gasLimit
coinName: coinType.coinName
}
})
}
Expand Down
89 changes: 24 additions & 65 deletions src/kkProto/messages_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,11 @@ export class EthereumAddress extends jspb.Message {
getAddress_asB64(): string;
setAddress(value: Uint8Array | string): void;

hasAddressStr(): boolean;
clearAddressStr(): void;
getAddressStr(): string | undefined;
setAddressStr(value: string): void;

serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): EthereumAddress.AsObject;
static toObject(includeInstance: boolean, msg: EthereumAddress): EthereumAddress.AsObject;
Expand All @@ -805,6 +810,7 @@ export class EthereumAddress extends jspb.Message {
export namespace EthereumAddress {
export type AsObject = {
address: Uint8Array | string,
addressStr?: string,
}
}

Expand Down Expand Up @@ -1033,6 +1039,16 @@ export class RecoveryDevice extends jspb.Message {
getAutoLockDelayMs(): number | undefined;
setAutoLockDelayMs(value: number): void;

hasU2fCounter(): boolean;
clearU2fCounter(): void;
getU2fCounter(): number | undefined;
setU2fCounter(value: number): void;

hasDryRun(): boolean;
clearDryRun(): void;
getDryRun(): boolean | undefined;
setDryRun(value: boolean): void;

serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): RecoveryDevice.AsObject;
static toObject(includeInstance: boolean, msg: RecoveryDevice): RecoveryDevice.AsObject;
Expand All @@ -1053,6 +1069,8 @@ export namespace RecoveryDevice {
enforceWordlist?: boolean,
useCharacterCipher?: boolean,
autoLockDelayMs?: number,
u2fCounter?: number,
dryRun?: boolean,
}
}

Expand Down Expand Up @@ -1644,70 +1662,6 @@ export namespace SignTx {
}
}

export class SimpleSignTx extends jspb.Message {
clearInputsList(): void;
getInputsList(): Array<types_pb.TxInputType>;
setInputsList(value: Array<types_pb.TxInputType>): void;
addInputs(value?: types_pb.TxInputType, index?: number): types_pb.TxInputType;

clearOutputsList(): void;
getOutputsList(): Array<types_pb.TxOutputType>;
setOutputsList(value: Array<types_pb.TxOutputType>): void;
addOutputs(value?: types_pb.TxOutputType, index?: number): types_pb.TxOutputType;

clearTransactionsList(): void;
getTransactionsList(): Array<types_pb.TransactionType>;
setTransactionsList(value: Array<types_pb.TransactionType>): void;
addTransactions(value?: types_pb.TransactionType, index?: number): types_pb.TransactionType;

hasCoinName(): boolean;
clearCoinName(): void;
getCoinName(): string | undefined;
setCoinName(value: string): void;

hasVersion(): boolean;
clearVersion(): void;
getVersion(): number | undefined;
setVersion(value: number): void;

hasLockTime(): boolean;
clearLockTime(): void;
getLockTime(): number | undefined;
setLockTime(value: number): void;

hasExpiry(): boolean;
clearExpiry(): void;
getExpiry(): number | undefined;
setExpiry(value: number): void;

hasOverwintered(): boolean;
clearOverwintered(): void;
getOverwintered(): boolean | undefined;
setOverwintered(value: boolean): void;

serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): SimpleSignTx.AsObject;
static toObject(includeInstance: boolean, msg: SimpleSignTx): SimpleSignTx.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: SimpleSignTx, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): SimpleSignTx;
static deserializeBinaryFromReader(message: SimpleSignTx, reader: jspb.BinaryReader): SimpleSignTx;
}

export namespace SimpleSignTx {
export type AsObject = {
inputsList: Array<types_pb.TxInputType.AsObject>,
outputsList: Array<types_pb.TxOutputType.AsObject>,
transactionsList: Array<types_pb.TransactionType.AsObject>,
coinName?: string,
version?: number,
lockTime?: number,
expiry?: number,
overwintered?: boolean,
}
}

export class TxRequest extends jspb.Message {
hasRequestType(): boolean;
clearRequestType(): void;
Expand Down Expand Up @@ -2642,7 +2596,6 @@ export enum MessageType {
MESSAGETYPE_LOADDEVICE = 13,
MESSAGETYPE_RESETDEVICE = 14,
MESSAGETYPE_SIGNTX = 15,
MESSAGETYPE_SIMPLESIGNTX = 16,
MESSAGETYPE_FEATURES = 17,
MESSAGETYPE_PINMATRIXREQUEST = 18,
MESSAGETYPE_PINMATRIXACK = 19,
Expand Down Expand Up @@ -2702,5 +2655,11 @@ export enum MessageType {
MESSAGETYPE_ETHEREUMSIGNMESSAGE = 108,
MESSAGETYPE_ETHEREUMVERIFYMESSAGE = 109,
MESSAGETYPE_ETHEREUMMESSAGESIGNATURE = 110,
MESSAGETYPE_EOSGETPUBLICKEY = 600,
MESSAGETYPE_EOSPUBLICKEY = 601,
MESSAGETYPE_EOSSIGNTX = 602,
MESSAGETYPE_EOSTXACTIONREQUEST = 603,
MESSAGETYPE_EOSTXACTIONACK = 604,
MESSAGETYPE_EOSSIGNEDTX = 605,
}

Loading