Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/cosmos #29

Merged
merged 11 commits into from
Nov 22, 2019
62 changes: 62 additions & 0 deletions messages-cosmos.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
syntax = "proto2";

// Sugar for easier handling in Java
option java_package = "com.keepkey.deviceprotocol";
option java_outer_classname = "KeepKeyMessageCosmos";

import "types.proto";

/**
* Request: Address at the specified index
* @start
* @next CosmosAddress
*/
message CosmosGetAddress {
repeated uint32 address_n = 1; // BIP-32 path. For compatibility with other wallets, must be m/44'/148'/index'
optional bool show_display = 2; // optionally show on display before sending the result
}

/**
* Response: Address for the given index
* @end
*/
message CosmosAddress {
optional string address = 1; // Address Bech32 encoded with 'cosmos' prefix
}

/**
* Request: ask device to sign Cosmos transaction
* @start
* @next CosmosSignedTx
*/
message CosmosSignTx {
repeated uint32 address_n = 1; // BIP-32 path. For compatibility with other wallets, must be m/44'/118'/index'
keepkeyjon marked this conversation as resolved.
Show resolved Hide resolved
optional uint64 account_number = 2 [jstype = JS_STRING];
optional string chain_id = 3;
optional uint32 fee_amount = 4;
optional uint32 gas = 5;
optional string memo = 6;
optional uint64 sequence = 7 [jstype = JS_STRING];
optional uint32 msg_count = 8;
}

message CosmosMsgRequest {}

message CosmosMsgAck {
optional CosmosMsgSend send = 1;
}

message CosmosMsgSend {
optional string from_address = 6;
optional string to_address = 7;
optional uint64 amount = 8 [jstype = JS_STRING];
}
keepkeyjon marked this conversation as resolved.
Show resolved Hide resolved

/**
* Response: signature for transaction
* @end
*/
message CosmosSignedTx {
optional bytes public_key = 1; // public key for the private key used to sign data
optional bytes signature = 2; // signature suitable for sending to the Cosmos network
}
7 changes: 7 additions & 0 deletions messages.proto
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ enum MessageType {
MessageType_NanoAddress = 701 [(wire_out) = true];
MessageType_NanoSignTx = 702 [(wire_in) = true];
MessageType_NanoSignedTx = 703 [(wire_out) = true];

MessageType_CosmosGetAddress = 900 [(wire_in) = true];
MessageType_CosmosAddress = 901 [(wire_out) = true];
MessageType_CosmosSignTx = 902 [(wire_in) = true];
MessageType_CosmosMsgRequest = 903 [(wire_out) = true];
MessageType_CosmosMsgAck = 904 [(wire_in) = true];
MessageType_CosmosSignedTx = 905 [(wire_out) = true];
}

////////////////////
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"scripts": {
"clean": "rm -rf ./lib/*.js ./lib/*.ts",
"build": "npm run build:js && npm run build:json && npm run build:postprocess",
"build:js": "protoc --plugin=protoc-gen-ts=./node_modules/.bin/protoc-gen-ts --js_out=import_style=commonjs,binary:./lib --ts_out=./lib exchange.proto types.proto messages.proto messages-eos.proto messages-nano.proto",
"build:json": "pbjs --keep-case -t json ./types.proto ./messages.proto ./messages-eos.proto ./messages-nano.proto ./exchange.proto > ./lib/proto.json",
"build:js": "protoc --plugin=protoc-gen-ts=./node_modules/.bin/protoc-gen-ts --js_out=import_style=commonjs,binary:./lib --ts_out=./lib exchange.proto types.proto messages.proto messages-eos.proto messages-nano.proto messages-cosmos.proto",
"build:json": "pbjs --keep-case -t json ./types.proto ./messages.proto ./messages-eos.proto ./messages-nano.proto ./messages-cosmos.proto ./exchange.proto > ./lib/proto.json",
"build:postprocess": "find ./lib -name \"*.js\" -exec sed -i '' -e \"s/var global = Function(\\'return this\\')();/var global = (function(){ return this }).call(null);/g\" {} \\;",
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand Down