diff --git a/messages-cosmos.proto b/messages-cosmos.proto new file mode 100644 index 0000000..df5f934 --- /dev/null +++ b/messages-cosmos.proto @@ -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' + 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]; +} + +/** + * 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 +} diff --git a/messages.proto b/messages.proto index f0ff527..2b85d0f 100644 --- a/messages.proto +++ b/messages.proto @@ -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]; } //////////////////// diff --git a/package.json b/package.json index 51b71f4..534823b 100644 --- a/package.json +++ b/package.json @@ -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" },