Skip to content

Commit f1dd2b6

Browse files
fix: regenerate pb2 files with protoc 3.5.1 + add mayachain client methods
fix: regenerate pb2 files with protoc 3.5.1 for protobuf 3.17 compat
2 parents dfe331b + a4e1fb3 commit f1dd2b6

16 files changed

Lines changed: 13069 additions & 992 deletions

.circleci/config.yml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ jobs:
66
- image: circleci/python:3.7 # upgrade to cimg/python:3.12 if you like
77
steps:
88
# ────────────────────────────────────────────────────────────────
9-
# 1) Pull python-keepkey via HTTPS so no SSH key is required
9+
# 1) Clone the current branch of python-keepkey via HTTPS
1010
# ────────────────────────────────────────────────────────────────
1111
- run:
12-
name: Clone python-keepkey
13-
command: git clone --depth 1 https://github.com/keepkey/python-keepkey.git .pykk
12+
name: Clone python-keepkey (current branch)
13+
command: |
14+
git clone --depth 1 -b "$CIRCLE_BRANCH" https://github.com/keepkey/python-keepkey.git .pykk
15+
cd .pykk && git submodule update --init --recursive
1416
1517
# ────────────────────────────────────────────────────────────────
1618
# 2) Grab firmware repo and inject our fresh python-keepkey copy
@@ -22,7 +24,7 @@ jobs:
2224
git config --global url."https://github.com/".insteadOf git@github.com:
2325
git config --global url."https://".insteadOf git://
2426
25-
# Move python-keepkey out of the way for the moment
27+
# Move python-keepkey out of the way
2628
mv .pykk ../
2729
2830
# Clone firmware repository (expects $FIRMWARE_REPO env var)
@@ -31,15 +33,10 @@ jobs:
3133
# Initialise firmware submodules
3234
git submodule update --init --recursive
3335
34-
# Replace the vendor copy with our freshly–cloned python-keepkey
36+
# Replace the vendor copy with our PR branch python-keepkey
3537
rm -rf deps/python-keepkey
3638
mv ../.pykk deps/python-keepkey
3739
38-
# Pull python-keepkey submodules too
39-
cd deps/python-keepkey
40-
git submodule update --init --recursive
41-
cd ../../..
42-
4340
# ────────────────────────────────────────────────────────────────
4441
# 3) Build the Docker-based emulator tests
4542
# ────────────────────────────────────────────────────────────────

keepkeylib/client.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,91 @@ def thorchain_sign_tx(
10521052

10531053
return resp
10541054

1055+
@field('address')
1056+
@expect(mayachain_proto.MayachainAddress)
1057+
def mayachain_get_address(self, address_n, show_display=False, testnet=False):
1058+
return self.call(
1059+
mayachain_proto.MayachainGetAddress(address_n=address_n, show_display=show_display, testnet=testnet)
1060+
)
1061+
1062+
@session
1063+
def mayachain_sign_tx(
1064+
self,
1065+
address_n,
1066+
account_number,
1067+
chain_id,
1068+
fee,
1069+
gas,
1070+
msgs,
1071+
memo,
1072+
sequence,
1073+
testnet=None
1074+
):
1075+
resp = self.call(mayachain_proto.MayachainSignTx(
1076+
address_n=address_n,
1077+
account_number=account_number,
1078+
chain_id=chain_id,
1079+
fee_amount=fee,
1080+
gas=gas,
1081+
memo=memo,
1082+
sequence=sequence,
1083+
msg_count=len(msgs),
1084+
testnet=testnet
1085+
))
1086+
1087+
for msg in msgs:
1088+
if not isinstance(resp, mayachain_proto.MayachainMsgRequest):
1089+
raise CallException(
1090+
"Mayachain.ExpectedMsgRequest",
1091+
"Message request expected but not received.",
1092+
)
1093+
1094+
if msg['type'] == "mayachain/MsgSend":
1095+
if len(msg['value']['amount']) != 1:
1096+
raise CallException("Mayachain.MsgSend", "Multiple amounts per send msg not supported")
1097+
1098+
denom = msg['value']['amount'][0]['denom']
1099+
1100+
resp = self.call(mayachain_proto.MayachainMsgAck(
1101+
send=mayachain_proto.MayachainMsgSend(
1102+
from_address=msg['value']['from_address'],
1103+
to_address=msg['value']['to_address'],
1104+
amount=int(msg['value']['amount'][0]['amount']),
1105+
denom=denom,
1106+
address_type=types.SPEND,
1107+
)
1108+
))
1109+
1110+
elif msg['type'] == "mayachain/MsgDeposit":
1111+
if len(msg['value']['coins']) != 1:
1112+
raise CallException("Mayachain.MsgDeposit", "Multiple coins per deposit msg not supported")
1113+
1114+
asset = msg['value']['coins'][0]['asset']
1115+
if asset != 'MAYA.CACAO':
1116+
raise CallException("Mayachain.MsgDeposit", "Unsupported asset: " + asset)
1117+
1118+
resp = self.call(mayachain_proto.MayachainMsgAck(
1119+
deposit=mayachain_proto.MayachainMsgDeposit(
1120+
asset=asset,
1121+
amount=int(msg['value']['coins'][0]['amount']),
1122+
memo=msg['value']['memo'],
1123+
signer=msg['value']['signer']
1124+
)
1125+
))
1126+
1127+
else:
1128+
raise CallException(
1129+
"Mayachain.UnknownMsg",
1130+
"Mayachain message %s is not yet supported" % (msg['type'],)
1131+
)
1132+
1133+
if not isinstance(resp, mayachain_proto.MayachainSignedTx):
1134+
raise CallException(
1135+
"Mayachain.UnexpectedEndOfOperations",
1136+
"Reached end of operations without a signature.",
1137+
)
1138+
1139+
return resp
10551140

10561141
@field('address')
10571142
@expect(ripple_proto.RippleAddress)

0 commit comments

Comments
 (0)