new proto.vm.tx.new_swap module

This commit is contained in:
The MMGen Project 2025-06-15 09:16:57 +00:00
commit 76a913678d
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
2 changed files with 37 additions and 19 deletions

View file

@ -13,29 +13,14 @@ proto.eth.tx.new_swap: Ethereum new swap transaction class
"""
from ....tx.new_swap import NewSwap as TxNewSwap
from ...vm.tx.new_swap import VmNewSwap
from .new import New, TokenNew
class NewSwap(New, TxNewSwap):
class NewSwap(VmNewSwap, New, TxNewSwap):
desc = 'Ethereum swap transaction'
def update_data_output(self, trade_limit):
parsed_memo = self.swap_proto_mod.Memo.parse(self.swap_memo)
self.swap_memo = str(self.swap_proto_mod.Memo(
self.swap_cfg,
self.recv_proto,
self.recv_asset,
self.recv_proto.coin_addr(parsed_memo.address),
trade_limit = trade_limit))
self.set_gas_with_data(self.swap_memo.encode())
@property
def vault_idx(self):
return 0
@property
def vault_output(self):
return self.outputs[0]
class TokenNewSwap(TokenNew, NewSwap):
desc = 'Ethereum token swap transaction'

33
mmgen/proto/vm/tx/new_swap.py Executable file
View file

@ -0,0 +1,33 @@
#!/usr/bin/env python3
#
# MMGen Wallet, a terminal-based cryptocurrency wallet
# Copyright (C)2013-2025 The MMGen Project <mmgen@tuta.io>
# Licensed under the GNU General Public License, Version 3:
# https://www.gnu.org/licenses
# Public project repositories:
# https://github.com/mmgen/mmgen-wallet
# https://gitlab.com/mmgen/mmgen-wallet
"""
proto.vm.tx.new_swap: new swap transaction methods for VM chains
"""
class VmNewSwap:
def update_data_output(self, trade_limit):
parsed_memo = self.swap_proto_mod.Memo.parse(self.swap_memo)
self.swap_memo = str(self.swap_proto_mod.Memo(
self.swap_cfg,
self.recv_proto,
self.recv_asset,
self.recv_proto.coin_addr(parsed_memo.address),
trade_limit = trade_limit))
self.set_gas_with_data(self.swap_memo.encode())
@property
def vault_idx(self):
return 0
@property
def vault_output(self):
return self.outputs[0]