1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-17 21:22:10 +00:00

refactor(common & core & legacy): Stellar, rename StellarCreatePassiveOfferOp to StellarCreatePassiveSellOfferOp.

This commit is contained in:
Jun Luo 2021-10-08 07:33:09 +08:00 committed by matejcik
parent d064aae3f9
commit 62b649ef5d
22 changed files with 43 additions and 40 deletions

View File

@ -78,7 +78,7 @@ message StellarSignTx {
* @next StellarPathPaymentStrictSendOp
* @next StellarManageSellOfferOp
* @next StellarManageBuyOfferOp
* @next StellarCreatePassiveOfferOp
* @next StellarCreatePassiveSellOfferOp
* @next StellarSetOptionsOp
* @next StellarChangeTrustOp
* @next StellarAllowTrustOp
@ -177,7 +177,7 @@ message StellarManageBuyOfferOp {
* @next StellarTxOpRequest
* @next StellarSignedTx
*/
message StellarCreatePassiveOfferOp {
message StellarCreatePassiveSellOfferOp {
optional string source_account = 1; // (optional) source account address
required StellarAsset selling_asset = 2;
required StellarAsset buying_asset = 3;

View File

@ -231,7 +231,7 @@ enum MessageType {
MessageType_StellarPaymentOp = 211 [(wire_in) = true];
MessageType_StellarPathPaymentStrictReceiveOp = 212 [(wire_in) = true];
MessageType_StellarManageSellOfferOp = 213 [(wire_in) = true];
MessageType_StellarCreatePassiveOfferOp = 214 [(wire_in) = true];
MessageType_StellarCreatePassiveSellOfferOp = 214 [(wire_in) = true];
MessageType_StellarSetOptionsOp = 215 [(wire_in) = true];
MessageType_StellarChangeTrustOp = 216 [(wire_in) = true];
MessageType_StellarAllowTrustOp = 217 [(wire_in) = true];

View File

@ -298,7 +298,7 @@
}
},
{
"name": "StellarCreatePassiveOfferOp",
"name": "StellarCreatePassiveSellOfferOp",
"parameters": {
"xdr": "AAAAAgAAAAAvIrnGLwi3dPPr5t1ufbk8PsLL3gJ5Vho9nFIluMMikgAAAGQAAAAAAAAD6AAAAAEAAAAAG4J3zQAAAABd5CqEAAAAAAAAAAEAAAAAAAAABAAAAAJBQkNERUZHSElKS0wAAAAAKYSWAsIOWDZfEjwS2HocpFUNEM0hsK4OGNROPlb9ahUAAAABWAAAAAAAAAAphJYCwg5YNl8SPBLYehykVQ0QzSGwrg4Y1E4+Vv1qFQAAAAAdzxaYAAAAAwAAAAQAAAAAAAAAAA==",
"address_n": "m/44'/148'/0'",
@ -313,7 +313,7 @@
},
"operations": [
{
"_message_type": "StellarCreatePassiveOfferOp",
"_message_type": "StellarCreatePassiveSellOfferOp",
"selling_asset": {
"type": "ALPHANUM12",
"code": "ABCDEFGHIJKL",
@ -888,7 +888,7 @@
"starting_balance": 100000000
},
{
"_message_type": "StellarCreatePassiveOfferOp",
"_message_type": "StellarCreatePassiveSellOfferOp",
"selling_asset": {
"type": "ALPHANUM12",
"code": "ABCDEFGHIJKL",

View File

@ -1 +1 @@
Stellar: rename StellarManageOfferOp to StellarManageSellOfferOp and StellarPathPaymentOp to StellarPathPaymentStrictReceiveOp.
Stellar: rename StellarManageOfferOp to StellarManageSellOfferOp, StellarPathPaymentOp to StellarPathPaymentStrictReceiveOp and StellarCreatePassiveOfferOp to StellarCreatePassiveSellOfferOp.

View File

@ -23,7 +23,7 @@ Stellar transaction is composed of one or more operations. We support all [opera
- Bump Sequence
- Change Trust
- Create Account
- Create Passive Offer
- Create Passive Sell Offer
- Manage Data
- Manage Buy Offer
- Manage Sell Offer

View File

@ -12,7 +12,7 @@ if False:
StellarBumpSequenceOp,
StellarChangeTrustOp,
StellarCreateAccountOp,
StellarCreatePassiveOfferOp,
StellarCreatePassiveSellOfferOp,
StellarManageDataOp,
StellarManageBuyOfferOp,
StellarManageSellOfferOp,
@ -28,7 +28,7 @@ if False:
StellarBumpSequenceOp,
StellarChangeTrustOp,
StellarCreateAccountOp,
StellarCreatePassiveOfferOp,
StellarCreatePassiveSellOfferOp,
StellarManageDataOp,
StellarManageBuyOfferOp,
StellarManageSellOfferOp,
@ -49,7 +49,7 @@ op_codes: dict[int, int] = {
MessageType.StellarBumpSequenceOp: 11,
MessageType.StellarChangeTrustOp: 6,
MessageType.StellarCreateAccountOp: 0,
MessageType.StellarCreatePassiveOfferOp: 4,
MessageType.StellarCreatePassiveSellOfferOp: 4,
MessageType.StellarManageDataOp: 10,
MessageType.StellarManageBuyOfferOp: 12,
MessageType.StellarManageSellOfferOp: 3,
@ -65,7 +65,7 @@ op_wire_types = [
MessageType.StellarBumpSequenceOp,
MessageType.StellarChangeTrustOp,
MessageType.StellarCreateAccountOp,
MessageType.StellarCreatePassiveOfferOp,
MessageType.StellarCreatePassiveSellOfferOp,
MessageType.StellarManageDataOp,
MessageType.StellarManageBuyOfferOp,
MessageType.StellarManageSellOfferOp,

View File

@ -28,9 +28,9 @@ async def process_operation(
elif serialize.StellarCreateAccountOp.is_type_of(op):
await layout.confirm_create_account_op(ctx, op)
serialize.write_create_account_op(w, op)
elif serialize.StellarCreatePassiveOfferOp.is_type_of(op):
await layout.confirm_create_passive_offer_op(ctx, op)
serialize.write_create_passive_offer_op(w, op)
elif serialize.StellarCreatePassiveSellOfferOp.is_type_of(op):
await layout.confirm_create_passive_sell_offer_op(ctx, op)
serialize.write_create_passive_sell_offer_op(w, op)
elif serialize.StellarManageDataOp.is_type_of(op):
await layout.confirm_manage_data_op(ctx, op)
serialize.write_manage_data_op(w, op)

View File

@ -6,7 +6,7 @@ from trezor.messages import (
StellarBumpSequenceOp,
StellarChangeTrustOp,
StellarCreateAccountOp,
StellarCreatePassiveOfferOp,
StellarCreatePassiveSellOfferOp,
StellarManageBuyOfferOp,
StellarManageDataOp,
StellarManageSellOfferOp,
@ -98,8 +98,8 @@ async def confirm_create_account_op(ctx: Context, op: StellarCreateAccountOp) ->
)
async def confirm_create_passive_offer_op(
ctx: Context, op: StellarCreatePassiveOfferOp
async def confirm_create_passive_sell_offer_op(
ctx: Context, op: StellarCreatePassiveSellOfferOp
) -> None:
if op.amount == 0:
text = "Delete Passive Offer"
@ -137,7 +137,7 @@ async def _confirm_manage_offer_op_common(
async def _confirm_offer(
ctx: Context,
title: str,
op: StellarCreatePassiveOfferOp
op: StellarCreatePassiveSellOfferOp
| StellarManageSellOfferOp
| StellarManageBuyOfferOp,
) -> None:

View File

@ -6,7 +6,7 @@ from trezor.messages import (
StellarBumpSequenceOp,
StellarChangeTrustOp,
StellarCreateAccountOp,
StellarCreatePassiveOfferOp,
StellarCreatePassiveSellOfferOp,
StellarManageBuyOfferOp,
StellarManageDataOp,
StellarManageSellOfferOp,
@ -50,7 +50,9 @@ def write_create_account_op(w: Writer, msg: StellarCreateAccountOp) -> None:
writers.write_uint64(w, msg.starting_balance)
def write_create_passive_offer_op(w: Writer, msg: StellarCreatePassiveOfferOp) -> None:
def write_create_passive_sell_offer_op(
w: Writer, msg: StellarCreatePassiveSellOfferOp
) -> None:
_write_asset(w, msg.selling_asset)
_write_asset(w, msg.buying_asset)
writers.write_uint64(w, msg.amount)

View File

@ -123,7 +123,7 @@ if not utils.BITCOIN_ONLY:
StellarPaymentOp = 211
StellarPathPaymentStrictReceiveOp = 212
StellarManageSellOfferOp = 213
StellarCreatePassiveOfferOp = 214
StellarCreatePassiveSellOfferOp = 214
StellarSetOptionsOp = 215
StellarChangeTrustOp = 216
StellarAllowTrustOp = 217

View File

@ -128,7 +128,7 @@ if TYPE_CHECKING:
StellarPaymentOp = 211
StellarPathPaymentStrictReceiveOp = 212
StellarManageSellOfferOp = 213
StellarCreatePassiveOfferOp = 214
StellarCreatePassiveSellOfferOp = 214
StellarSetOptionsOp = 215
StellarChangeTrustOp = 216
StellarAllowTrustOp = 217

View File

@ -4876,7 +4876,7 @@ if TYPE_CHECKING:
def is_type_of(cls, msg: protobuf.MessageType) -> TypeGuard["StellarManageBuyOfferOp"]:
return isinstance(msg, cls)
class StellarCreatePassiveOfferOp(protobuf.MessageType):
class StellarCreatePassiveSellOfferOp(protobuf.MessageType):
source_account: "str | None"
selling_asset: "StellarAsset"
buying_asset: "StellarAsset"
@ -4897,7 +4897,7 @@ if TYPE_CHECKING:
pass
@classmethod
def is_type_of(cls, msg: protobuf.MessageType) -> TypeGuard["StellarCreatePassiveOfferOp"]:
def is_type_of(cls, msg: protobuf.MessageType) -> TypeGuard["StellarCreatePassiveSellOfferOp"]:
return isinstance(msg, cls)
class StellarSetOptionsOp(protobuf.MessageType):

View File

@ -1 +1 @@
Stellar: rename StellarManageOfferOp to StellarManageSellOfferOp and StellarPathPaymentOp to StellarPathPaymentStrictReceiveOp.
Stellar: rename StellarManageOfferOp to StellarManageSellOfferOp, StellarPathPaymentOp to StellarPathPaymentStrictReceiveOp and StellarCreatePassiveOfferOp to StellarCreatePassiveSellOfferOp.

View File

@ -124,7 +124,8 @@ void fsm_msgStellarPathPaymentStrictSendOp(
const StellarPathPaymentStrictSendOp *msg);
void fsm_msgStellarManageBuyOfferOp(const StellarManageBuyOfferOp *msg);
void fsm_msgStellarManageSellOfferOp(const StellarManageSellOfferOp *msg);
void fsm_msgStellarCreatePassiveOfferOp(const StellarCreatePassiveOfferOp *msg);
void fsm_msgStellarCreatePassiveSellOfferOp(
const StellarCreatePassiveSellOfferOp *msg);
void fsm_msgStellarSetOptionsOp(const StellarSetOptionsOp *msg);
void fsm_msgStellarChangeTrustOp(const StellarChangeTrustOp *msg);
void fsm_msgStellarAllowTrustOp(const StellarAllowTrustOp *msg);

View File

@ -183,9 +183,9 @@ void fsm_msgStellarManageSellOfferOp(const StellarManageSellOfferOp *msg) {
}
}
void fsm_msgStellarCreatePassiveOfferOp(
const StellarCreatePassiveOfferOp *msg) {
if (!stellar_confirmCreatePassiveOfferOp(msg)) return;
void fsm_msgStellarCreatePassiveSellOfferOp(
const StellarCreatePassiveSellOfferOp *msg) {
if (!stellar_confirmCreatePassiveSellOfferOp(msg)) return;
if (stellar_allOperationsConfirmed()) {
RESP_INIT(StellarSignedTx);

View File

@ -29,7 +29,7 @@ StellarManageBuyOfferOp.source_account max_size:57
StellarManageSellOfferOp.source_account max_size:57
StellarCreatePassiveOfferOp.source_account max_size:57
StellarCreatePassiveSellOfferOp.source_account max_size:57
StellarSetOptionsOp.source_account max_size:57
StellarSetOptionsOp.inflation_destination_account max_size:57

View File

@ -659,8 +659,8 @@ bool stellar_confirmManageSellOfferOp(const StellarManageSellOfferOp *msg) {
return true;
}
bool stellar_confirmCreatePassiveOfferOp(
const StellarCreatePassiveOfferOp *msg) {
bool stellar_confirmCreatePassiveSellOfferOp(
const StellarCreatePassiveSellOfferOp *msg) {
if (!stellar_signing) return false;
if (!stellar_confirmSourceAccount(msg->has_source_account,

View File

@ -65,8 +65,8 @@ bool stellar_confirmPathPaymentStrictSendOp(
const StellarPathPaymentStrictSendOp *msg);
bool stellar_confirmManageBuyOfferOp(const StellarManageBuyOfferOp *msg);
bool stellar_confirmManageSellOfferOp(const StellarManageSellOfferOp *msg);
bool stellar_confirmCreatePassiveOfferOp(
const StellarCreatePassiveOfferOp *msg);
bool stellar_confirmCreatePassiveSellOfferOp(
const StellarCreatePassiveSellOfferOp *msg);
bool stellar_confirmSetOptionsOp(const StellarSetOptionsOp *msg);
bool stellar_confirmChangeTrustOp(const StellarChangeTrustOp *msg);
bool stellar_confirmAllowTrustOp(const StellarAllowTrustOp *msg);

View File

@ -149,7 +149,7 @@ class MessageType(IntEnum):
StellarPaymentOp = 211
StellarPathPaymentStrictReceiveOp = 212
StellarManageSellOfferOp = 213
StellarCreatePassiveOfferOp = 214
StellarCreatePassiveSellOfferOp = 214
StellarSetOptionsOp = 215
StellarChangeTrustOp = 216
StellarAllowTrustOp = 217
@ -6454,7 +6454,7 @@ class StellarManageBuyOfferOp(protobuf.MessageType):
self.source_account = source_account
class StellarCreatePassiveOfferOp(protobuf.MessageType):
class StellarCreatePassiveSellOfferOp(protobuf.MessageType):
MESSAGE_WIRE_TYPE = 214
FIELDS = {
1: protobuf.Field("source_account", "string", repeated=False, required=False),

View File

@ -153,7 +153,7 @@ def _read_operation(op: "Operation"):
)
if isinstance(op, CreatePassiveSellOffer):
price = _read_price(op.price)
return messages.StellarCreatePassiveOfferOp(
return messages.StellarCreatePassiveSellOfferOp(
source_account=source_account,
selling_asset=_read_asset(op.selling),
buying_asset=_read_asset(op.buying),

View File

@ -447,7 +447,7 @@ def test_create_passive_sell_offer():
tx, operations = stellar.from_envelope(envelope)
assert len(operations) == 1
assert isinstance(operations[0], messages.StellarCreatePassiveOfferOp)
assert isinstance(operations[0], messages.StellarCreatePassiveSellOfferOp)
assert operations[0].source_account == operation_source
assert operations[0].selling_asset.type == messages.StellarAssetType.NATIVE
assert operations[0].buying_asset.type == messages.StellarAssetType.ALPHANUM4

View File

@ -844,7 +844,7 @@
"test_stellar.py::test_sign_tx[StellarChangeTrustOp-add]": "7a8d420121a13e34f6ca7ad224e01a3b189ceb8e8d104cf9ec9b329222670936",
"test_stellar.py::test_sign_tx[StellarChangeTrustOp-delete]": "ec26e6883ba9405412674431e0ec07504b3f25682ce7d76ebd445b809194198a",
"test_stellar.py::test_sign_tx[StellarCreateAccountOp]": "2582717c25974d2b3ee156624b00375148ff7fd12eeea73625a7c367fa610373",
"test_stellar.py::test_sign_tx[StellarCreatePassiveOfferOp]": "6b0f0d2b746f98e2c85006ea7e2d5c49cd9277662e47f223138ff418066791e3",
"test_stellar.py::test_sign_tx[StellarCreatePassiveSellOfferOp]": "6b0f0d2b746f98e2c85006ea7e2d5c49cd9277662e47f223138ff418066791e3",
"test_stellar.py::test_sign_tx[StellarManageDataOp]": "8fbec6547a8f9d1f002181db0cbe57fe86abef8d365b1c06fd14292cd0b068a7",
"test_stellar.py::test_sign_tx[StellarManageBuyOfferOp]": "fc57e1ca8b65588aa16cc3524d6dc0f01e094ad5d16a6f7e739a69c101b554bc",
"test_stellar.py::test_sign_tx[StellarManageSellOfferOp]": "6ed84765b2ed46711be0ed1219d91c27e927119d352f37b2baf8c6501186bbce",