// JSON descriptor //提示词: 通过这个json 结构给我生成一个 protobufjs使用的 JSON descriptors //通用返回值结构。 const common = { 'nested': { 'Response': { 'fields': { 'code': { 'type': 'int32', 'id': 1, }, 'msg': { 'type': 'string', 'id': 2, }, 'status': { 'type': 'string', 'id': 3, }, 'ts': { 'type': 'int64', 'id': 4, }, 'ch': { 'type': 'string', 'id': 5, }, }, }, }, } //market.v2.trade.recommend.pair const market_v2_trade_recommend_pair = { 'nested': { 'Response': { // 把 Response 放在最外层 'fields': { 'code': { 'type': 'int32', 'id': 1 }, 'msg': { 'type': 'string', 'id': 2 }, 'status': { 'type': 'string', 'id': 3 }, 'ts': { 'type': 'int64', 'id': 4 }, 'ch': { 'type': 'string', 'id': 5 }, 'recommendpair': { 'type': 'RecommendPair', 'id': 6 } } }, 'RecommendPair': { // 定义内部消息类型 'nested': { // 新增 nested 层 'TradePair': { // 把 TradePair 定义移到 RecommendPair 内部 'fields': { 'tradeId': { 'type': 'int64', 'id': 1 }, 'cny': { 'type': 'string', 'id': 2 }, 'totalamount': { 'type': 'string', 'id': 3 }, 'last': { 'type': 'string', 'id': 4 }, 'volume': { 'type': 'string', 'id': 5 }, 'change': { 'type': 'string', 'id': 6 } } } }, 'fields': { 'listList': { 'rule': 'repeated', 'type': 'TradePair', 'id': 1 } } } } }; const market_v2_trade_area_tickers = { 'nested': { 'TradeAreaPair': { 'fields': { 'listList': { 'rule': 'repeated', 'type': 'TradePair', 'id': 1, 'default': [], // 添加默认值 }, }, }, 'TradePair': { 'fields': { 'tradeid': { 'type': 'int64', 'id': 1, }, 'cny': { 'type': 'double', 'id': 2, }, 'buy': { 'type': 'double', 'id': 3, }, 'lever': { 'type': 'int64', 'id': 4, }, 'sell': { 'type': 'double', 'id': 5, }, 'last': { 'type': 'double', 'id': 6, }, 'volume': { 'type': 'double', 'id': 7, }, 'change': { 'type': 'double', 'id': 8, }, 'high': { 'type': 'double', 'id': 9, }, 'low': { 'type': 'double', 'id': 10, }, 'isopen': { 'type': 'int64', 'id': 11, }, 'open': { 'type': 'int64', 'id': 12, }, 'amount': { 'type': 'double', 'id': 13, }, 'isfiatconvert': { 'type': 'bool', 'id': 14, }, }, }, 'Response': { 'fields': { 'code': { 'type': 'int32', 'id': 1, }, 'msg': { 'type': 'string', 'id': 2, }, 'status': { 'type': 'string', 'id': 3, }, 'ts': { 'type': 'int64', 'id': 4, }, 'ch': { 'type': 'string', 'id': 5, }, 'tradeareapair': { 'type': 'TradeAreaPair', 'id': 6, }, }, }, }, } const market_v2_trade_main_pair = { 'nested': { 'MainPair': { 'fields': { 'listList': { 'rule': 'repeated', 'type': 'Trade', 'id': 1, 'default': [], // 添加默认值 }, }, }, 'Trade': { 'fields': { 'tradeId': { 'type': 'int64', 'id': 1, }, 'cny': { 'type': 'double', 'id': 2, }, 'totalamount': { 'type': 'double', 'id': 3, }, 'last': { 'type': 'double', 'id': 4, }, 'volume': { 'type': 'double', 'id': 5, }, 'change': { 'type': 'double', 'id': 6, }, }, }, 'Response': { 'fields': { 'code': { 'type': 'int32', 'id': 1, }, 'msg': { 'type': 'string', 'id': 2, }, 'status': { 'type': 'string', 'id': 3, }, 'ts': { 'type': 'int64', 'id': 4, }, 'ch': { 'type': 'string', 'id': 5, }, 'mainpair': { 'type': 'MainPair', 'id': 6, }, }, }, }, } module.exports = { common, market_v2_trade_recommend_pair, market_v2_trade_area_tickers, market_v2_trade_main_pair, }