Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(eth-swap): eth tpu v2 methods, eth docker test enhancements #2169

Merged
merged 273 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
273 commits
Select commit Hold shift + click to select a range
e94fac7
provide UrlSignWrapper structure
laruh May 9, 2024
2e8c662
additionally include chain field into UrlSignWrapper
laruh May 9, 2024
0fbf75d
increase erc721 tx confirmation time to 150, add more logs
laruh May 9, 2024
03860e1
review: use map_err for generate_gui_auth_signed_validation, doc comm…
laruh May 10, 2024
b8b05d1
proxy: send regular http post request to proxy for nft feature
laruh May 12, 2024
3de2b92
make erc721 and erc1155 time locks different in tests
laruh May 12, 2024
f2625fd
Merge remote-tracking branch 'refs/remotes/origin/dev' into standalon…
laruh May 13, 2024
930a593
Merge remote-tracking branch 'refs/remotes/origin/dev' into standalon…
laruh May 14, 2024
350abd6
review: impl lock_coins() to keep coins field in CoinsContext private
laruh May 14, 2024
36eaf38
review: rename Gui-Auth types to align with new names in the KomodoDe…
laruh May 15, 2024
4478ccb
review: use "http-rustls-tls" feature in web3 crate for tests
laruh May 15, 2024
7882e6e
review: send Http GET request to activate NFT
laruh May 16, 2024
d03b6d1
review: support GET requests to KomodoDeFi Proxy layer and to 3rd API…
laruh May 17, 2024
ff92a20
impl build_and_send_request func to avoid code repetition
laruh May 17, 2024
a2c47f8
review: panic in wait_for_geth_node_ready if Deth node is not ready a…
laruh May 17, 2024
d6cbfd8
Merge remote-tracking branch 'refs/remotes/origin/dev' into standalon…
laruh May 21, 2024
9c3ff07
merge: fmt, log tx_hash() in NFT payments instead of bytes, import et…
laruh May 21, 2024
0bedba3
send only signed message as header in nft
laruh May 23, 2024
7976761
Merge remote-tracking branch 'refs/remotes/origin/dev' into standalon…
laruh May 24, 2024
a6ad6fc
wip: refund_nft_maker_payment_v2
laruh May 26, 2024
5daf723
wip: refund_nft_maker_payment_v2_secret
laruh May 27, 2024
2daec7a
test send_send_and_refund_erc721_maker_payment_timelock ignoring ERC1155
laruh May 27, 2024
6992931
log info in send_send_and_refund_erc721_maker_payment_timelock
laruh May 27, 2024
3f07f1f
log token_id=2 send_send_and_refund_erc721_maker_payment_timelock
laruh May 27, 2024
0079362
test only refund_nft_maker_payment_v2_timelock
laruh May 28, 2024
0c164fb
test only refund_nft_maker_payment_v2_timelock
laruh May 28, 2024
63af2bc
use global_nft_with_random_privkey in send_send_and_refund_erc721_mak…
laruh May 28, 2024
e2f8ccf
call maker_global_nft.refund_nft_maker_payment_v2_timelock
laruh May 28, 2024
dad6988
use get_erc712_owner func in refund erc721 test
laruh May 28, 2024
9b1a700
add geth_ prefix to Address functions in eth tests
laruh May 28, 2024
fc4d6e4
impl [test] send_send_and_refund_erc1155_maker_payment_timelock
laruh May 28, 2024
cc8e78e
test the refund payment with taker secret
laruh May 29, 2024
87b297a
use Geth node for swap tests
laruh May 29, 2024
780b1e8
reduce code duplication
laruh May 30, 2024
f789e91
provide NftSwapInfo type
laruh May 30, 2024
aa1d70f
use coins config file for NFT activation
laruh May 31, 2024
b9f2a98
reduce code duplication using `validate_state` func
laruh Jun 2, 2024
ece5152
refactor Quicknode HTTP request: move `signed_message` to header
laruh Jun 4, 2024
920861e
tests: increase wait for confirm time and add sleep duration
laruh Jun 5, 2024
e478711
eth tpu v2: deploy maker and taker swap v2 contracts in tests. add ma…
laruh Jun 7, 2024
9803fd5
eth tpu v2: dont include "nft_maker_swap_v2_contract" in eth/erc20 ac…
laruh Jun 8, 2024
2828be0
eth tpu v2: provide init_watchers_swap_contract in swap_watcher_tests.rs
laruh Jun 8, 2024
04d99e4
eth tpu v2: impl TakerCoinSwapOpsV2 for EthCoin, send_taker_funding WIP
laruh Jun 10, 2024
d31566d
eth_docker_tests.rs change sleep Duration in some tests
laruh Jun 10, 2024
4064999
eth tpu v2: impl TakerCoinSwapOpsV2 for EthCoin WIP
laruh Jun 14, 2024
b986279
Merge remote-tracking branch 'refs/remotes/origin/dev' into nft-refun…
laruh Jun 17, 2024
e636da1
avoid code duplication in input_tokens vector
laruh Jun 17, 2024
40ffb65
review: rename validate_state fnc, use extend plus chain in etomic_sw…
laruh Jun 17, 2024
888108c
review: move contract bytes strings to txt files, remove "the"
laruh Jun 18, 2024
8143cc2
review: move code to EthCoinType::Nft arm
laruh Jun 20, 2024
b391a16
state machine: fix log info text related to sign_and_send_taker_fundi…
laruh Jun 22, 2024
5f34f1c
Merge remote-tracking branch 'refs/remotes/origin/dev' into standalon…
laruh Jun 22, 2024
e672485
review: provide log!, instead println! in tests
laruh Jun 22, 2024
986c5e7
Merge remote-tracking branch 'refs/remotes/origin/standalone-nft-make…
laruh Jun 22, 2024
d998062
review: swap part of ERC1155 nfts in eth_docker_tests.rs
laruh Jun 23, 2024
ff4d306
eth tpu v2: leave comms about preimages
laruh Jun 26, 2024
2ae0b04
eth tpu v2: use Public from ethereum_types in impl ParseCoinAssocType…
laruh Jun 28, 2024
0d54567
Merge remote-tracking branch 'refs/remotes/origin/dev' into standalon…
laruh Jun 28, 2024
602206d
Merge remote-tracking branch 'refs/remotes/origin/standalone-nft-make…
laruh Jun 28, 2024
604d182
change sleep duration in send_and_spend_erc721_maker_payment
laruh Jun 28, 2024
36d94b9
change sleep duration in send_and_refund_erc721_maker_payment_timeloc…
laruh Jun 28, 2024
ce6673b
change sleep duration in send_and_refund_erc721_maker_payment_timelock
laruh Jun 28, 2024
933d4b9
change sleep duration in send_and_refund_erc1155_maker_payment_timelock
laruh Jun 28, 2024
1e90600
eth tpu v2: add swap_v2_contracts Opt param in EthActivationV2Request…
laruh Jul 1, 2024
b9049bf
state machine: change doc comment related to sign_and_send_taker_fund…
laruh Jul 3, 2024
8e4cd71
eth tpu v2: send_taker_funding Erc20 WIP (need to optimize code)
laruh Jul 3, 2024
4e9f902
change sleep duration in send_and_refund_erc721_maker_payment_timelock
laruh Jul 3, 2024
801a688
Merge remote-tracking branch 'refs/remotes/origin/dev' into standalon…
laruh Jul 8, 2024
1e050d2
fmt code after merge
laruh Jul 8, 2024
2447763
Merge remote-tracking branch 'refs/remotes/origin/standalone-nft-make…
laruh Jul 8, 2024
fa3f553
fix merge conflicts
laruh Jul 8, 2024
eddeb1a
make "proxy_auth" Optional
laruh Jul 10, 2024
7cbb941
Merge remote-tracking branch 'refs/remotes/origin/dev' into standalon…
laruh Jul 10, 2024
87cc404
Merge remote-tracking branch 'refs/remotes/origin/standalone-nft-make…
laruh Jul 10, 2024
49c1450
eth docker tests: use eth_coin_from_conf_and_request_v2 func in globa…
laruh Jul 13, 2024
5971601
eth docker tests: set global MM_CTX in set_coin_type
laruh Jul 14, 2024
647f425
eth docker tests: init global MM_CTX1 with config
laruh Jul 14, 2024
af70871
eth docker tests: change sleep duration
laruh Jul 14, 2024
ceeaac5
eth tpu v2: refund_taker_funding_secret ETH part
laruh Jul 14, 2024
bb39b36
eth tpu v2: refund_taker_funding_secret ETH and ERC20 parts impl
laruh Jul 15, 2024
ac38aea
eth tpu v2: send_and_refund_taker_funding_by_secret ETH/ERC20 tests. …
laruh Jul 16, 2024
c64af3b
eth tpu v2: add wait_for_confirmations in send_and_refund_taker_fundi…
laruh Jul 16, 2024
bac63a9
eth tpu v2: use public_to_address function
laruh Jul 16, 2024
5c0361f
fix typo and add now_sec()
laruh Jul 16, 2024
49f435d
eth tpu v2: refund_taker_funding_timelock WIP
laruh Jul 16, 2024
b5861b0
eth tpu v2: replace RefundPaymentArgs by RefundTakerPaymentArgs in Ta…
laruh Jul 17, 2024
2b24db6
change sleep Duration
laruh Jul 17, 2024
ae16a3c
eth tpu v2: refund_taker_funding_timelock_impl
laruh Jul 17, 2024
01cd625
eth tpu v2: refactor refund_taker_funding_secret_impl
laruh Jul 17, 2024
191b5f0
Merge remote-tracking branch 'origin/dev' into standalone-nft-maker-s…
laruh Jul 18, 2024
734edbc
Merge remote-tracking branch 'origin/standalone-nft-maker-swap-contra…
laruh Jul 18, 2024
7b69886
fmt and clippy
laruh Jul 18, 2024
078fc5c
Merge remote-tracking branch 'origin/nft-refund-payment-geth' into nf…
laruh Jul 18, 2024
603daa7
use `self.gas_limit` instead of `mod gas_limit` in eth_swap_v2.rs
laruh Jul 18, 2024
99ec522
use EthGasLimit::default() in EthCoin set_coin_type
laruh Jul 18, 2024
b13ab34
Merge remote-tracking branch 'origin/dev' into nft-refund-payment-geth
laruh Jul 19, 2024
dab5bd9
fmt, clippy
laruh Jul 19, 2024
42f6d37
test send_and_refund_taker_funding_timelock_eth WIP
laruh Jul 19, 2024
b3d0e12
Merge remote-tracking branch 'origin/nft-refund-payment-geth' into nf…
laruh Jul 19, 2024
114637a
eth tpu v2: test send_and_refund_taker_funding_timelock_eth
laruh Jul 19, 2024
c924520
eth tpu v2: test send_and_refund_taker_funding_timelock_erc20
laruh Jul 19, 2024
69d2fbe
doc comments
laruh Jul 21, 2024
cac2d0d
review: remove gas_limit module from eth_swap_v2.rs
laruh Jul 21, 2024
2358c11
Merge remote-tracking branch 'origin/nft-refund-payment-geth' into nf…
laruh Jul 21, 2024
071a1f6
review: use `etomic_swap_id` function
laruh Jul 21, 2024
37031bd
Merge remote-tracking branch 'origin/nft-refund-payment-geth' into nf…
laruh Jul 21, 2024
b3c66bd
use etomic_swap_id in eth_swap_v2.rs, remove funding_time_lock from R…
laruh Jul 21, 2024
439243a
review: use fixed size arrays
laruh Jul 22, 2024
ec59a27
Merge remote-tracking branch 'origin/nft-refund-payment-geth' into nf…
laruh Jul 22, 2024
ee9d9dc
review: use fixed size arrays
laruh Jul 22, 2024
b971ad8
update maker_swap_v2_bytes and taker_swap_v2_bytes
laruh Jul 22, 2024
c26c7a5
ignore tendermint tests
laruh Jul 22, 2024
c7e01d5
eth tpu v2 docker tests: balance check in send_and_refund_taker_fundi…
laruh Jul 22, 2024
8719922
eth tpu v2 docker tests: balance check in refund by secret tests
laruh Jul 22, 2024
a7974a9
eth tpu v2 docker tests: add fill_erc20
laruh Jul 22, 2024
472c34b
eth tpu v2 docker tests: change sleep duration, add `wait_for_confirm…
laruh Jul 23, 2024
10b8f9b
eth tpu v2 docker tests: change sleep duration, increase wait for con…
laruh Jul 23, 2024
dc215ec
ignore tendermint tests
laruh Jul 23, 2024
787a2b2
ignore nft, eth docker tests
laruh Jul 23, 2024
9e353a6
add balance checks
laruh Jul 23, 2024
351d538
ignore timelock and leave refund by secret
laruh Jul 23, 2024
e0e9126
more logs, add dexFee to eth_total_payment
laruh Jul 23, 2024
f2ac7ef
update taker_swap_v2_bytes
laruh Jul 23, 2024
fdb7fef
more logs
laruh Jul 23, 2024
52d4ddf
init erc20
laruh Jul 23, 2024
0d34688
provide 0 to send value in refund methods
laruh Jul 23, 2024
7cd09ca
eth tpu v2: update ValidateTakerFundingArgs fields
laruh Jul 23, 2024
14f86b7
leave only send_and_refund_taker_funding_by_secret_erc20 test
laruh Jul 23, 2024
2ffe134
sepolia: fix swap id, test refund by secret and timelock
laruh Jul 23, 2024
fd504b1
remove balance logs
laruh Jul 24, 2024
c629d7a
review: provide eth total payment to sign_and_send_transaction
laruh Jul 25, 2024
60f5432
Merge remote-tracking branch 'origin/nft-refund-payment-geth' into nf…
laruh Jul 25, 2024
ed08df9
review: fix typo
laruh Jul 25, 2024
89e543f
review: update log to "Sent taker funding spend (taker payment)"
laruh Jul 25, 2024
8c03854
Merge remote-tracking branch 'origin/nft-refund-payment-geth' into nf…
laruh Jul 25, 2024
cf1e0bf
allow check_eth_balance dead code in docker tests
laruh Jul 25, 2024
28bc18a
review: remove legacy "derive_htlc_pubkey" function from swap_v2, use…
laruh Jul 25, 2024
5901e74
Merge remote-tracking branch 'origin/nft-refund-payment-geth' into nf…
laruh Jul 25, 2024
173dd33
fmt code
laruh Jul 25, 2024
69a07a8
Merge remote-tracking branch 'origin/dev' into nft-refund-payment-geth
laruh Jul 26, 2024
7570df7
gas limit: TODO about new consts and params for v2 calls
laruh Jul 26, 2024
3042e60
todo burnFee support
laruh Jul 26, 2024
e1e2242
review: update doc comments for taker and maker secret hashes in Send…
laruh Jul 26, 2024
fcd394d
review: specify timelock doc comments for UTXO and smart contracts in…
laruh Jul 26, 2024
6a231a3
review: remove wait_for_confirmation_until and use funding_time_lock …
laruh Jul 26, 2024
45ac62b
Merge remote-tracking branch 'origin/nft-refund-payment-geth' into nf…
laruh Jul 26, 2024
37845ac
todo note about gas_limit params for v2 calls
laruh Jul 26, 2024
e780280
fix clippy and provide sleep duration to test pre-approved timelock u…
laruh Jul 26, 2024
8473304
erc20 tests on sepolia
laruh Jul 28, 2024
84b8ad4
eth tpu v2: validate_taker_funding_impl WIP, provide validation in v2…
laruh Jul 28, 2024
cee5f61
eth tpu v2 tests: wait pending txs before validation call
laruh Jul 28, 2024
10c6a14
eth tpu v2: remove premium from validate_payment_args
laruh Jul 28, 2024
d53bc66
eth tpu v2: use `is_positive` function for eth/erc20 amount
laruh Jul 28, 2024
067b2ae
eth tpu v2 tests: add sleep Duration
laruh Jul 28, 2024
9c157e5
remove dead_code, improve wait_pending_transactions log
laruh Jul 29, 2024
027da95
change sleep duration
laruh Jul 29, 2024
c58808a
review: use Public::from_slice directly in parse_pubkey
laruh Jul 29, 2024
1a5bf73
review: use public_to_address to get address from pubkey
laruh Jul 29, 2024
4c8c425
Merge remote-tracking branch 'origin/nft-refund-payment-geth' into nf…
laruh Jul 29, 2024
d922395
review: use dex_fee plus payment_amount for eth_total_payment
laruh Jul 29, 2024
5d6f943
review: use dex_fee plus payment_amount for eth_total_payment
laruh Jul 29, 2024
27473bb
Merge remote-tracking branch 'origin/nft-refund-payment-geth' into nf…
laruh Jul 29, 2024
2007a70
review: extract sign_and_send_transaction outside the if/else
laruh Jul 29, 2024
5524dca
Merge remote-tracking branch 'origin/nft-refund-payment-geth' into nf…
laruh Jul 29, 2024
9aca0d7
review: minify json
laruh Jul 29, 2024
0ef082d
Merge remote-tracking branch 'origin/nft-refund-payment-geth' into nf…
laruh Jul 29, 2024
2bf5294
eth tpu v2: impl validate_from_to_and_status func, additionally use i…
laruh Jul 29, 2024
8a16714
eth tpu v2: change sleep duration in send_and_refund_taker_funding_by…
laruh Jul 29, 2024
25074b8
eth tpu v2: validate_taker_funding swap method
laruh Jul 31, 2024
95f21dd
eth tpu v2: prepare_taker_payment_approve_data.
laruh Aug 1, 2024
d0c038e
eth tpu v2: spend payment functionality, send_approve_and_spend_eth test
laruh Aug 1, 2024
4ef88fa
eth tpu v2: log approve tx
laruh Aug 1, 2024
fac2d38
eth tpu v2: refactor spend functionality
laruh Aug 1, 2024
b2d6d4b
eth tpu v2: check payment state in approve
laruh Aug 1, 2024
70dfcdc
eth tpu v2: use function.encode_input
laruh Aug 1, 2024
fe730fa
review: drop variables, return result value directly
laruh Aug 2, 2024
4f8ef5b
Merge remote-tracking branch 'origin/nft-refund-payment-geth' into nf…
laruh Aug 2, 2024
a814575
eth tpu v2: use match self.coin_type for token_address in sign_and_br…
laruh Aug 2, 2024
bd41f9a
eth tpu v2 tests: try geth_send_approve_and_spend_eth
laruh Aug 2, 2024
d6e42c5
eth tpu v2: refactor spend. approve impls.
laruh Aug 2, 2024
6949b7a
eth tpu v2 tests: send_and_refund_taker_funding_exceed_payment_timelo…
laruh Aug 4, 2024
89cf307
eth tpu v2 tests: only send_and_refund_taker_funding_exceed_payment_t…
laruh Aug 4, 2024
8df5c47
Merge remote-tracking branch 'origin/dev' into nft-refund-payment-get…
laruh Aug 4, 2024
747e51e
fix code after merge
laruh Aug 4, 2024
ff00bf0
eth docker tests: remove `geth_send_approve_and_spend_eth`
laruh Aug 5, 2024
e5eef68
Revert "ignore tendermint tests"
laruh Aug 6, 2024
ddbcdba
Revert "ignore tendermint tests"
laruh Aug 6, 2024
dfc482d
Merge remote-tracking branch 'origin/dev' into nft-refund-payment-get…
laruh Aug 6, 2024
c5607d8
polish taker_payment_approve and sign_and_broadcast_taker_payment_spe…
laruh Aug 6, 2024
8d33bfe
eth tpu v2: search_for_taker_funding_spend implemented
laruh Aug 6, 2024
5e3e0fd
review fixes
laruh Aug 8, 2024
8b8e0a5
use Arc mut
laruh Aug 8, 2024
4e1352d
return old set_coin_type
laruh Aug 8, 2024
467a421
review: create decoded variable within an inner scope, From<RefundTak…
laruh Aug 9, 2024
284fc0f
use checked_add for eth_total_payment calculation
laruh Aug 9, 2024
9f31649
review: change error type, move match coin_type to the top, update ma…
laruh Aug 12, 2024
67e7f15
docker tests: add `search_for_taker_funding_spend` func in send_appro…
laruh Aug 12, 2024
046dc32
move coin_type match at the beginning in search_for_taker_funding_spe…
laruh Aug 12, 2024
303056f
more doc comments for swap v2 methods
laruh Aug 12, 2024
bf70525
wait_for_taker_payment_spend_impl WIP
laruh Aug 12, 2024
0bae344
review: remove TakerRefundSecretArgs and reuse TakerRefundArgs
laruh Aug 13, 2024
e65f224
review: use checked_add and InvalidData
laruh Aug 13, 2024
46dcbc1
eth tpu v2: wait_for_taker_payment_spend_impl
laruh Aug 13, 2024
6c4814d
move get script_pubkey from loop
laruh Aug 13, 2024
3bf653e
add wait_for_taker_payment_spend to eth tests
laruh Aug 13, 2024
74d31ca
change sleep duration in send_and_refund_taker_funding_exceed, remove…
laruh Aug 13, 2024
8a5d5df
provide get_decoded_and_swap_contract func to reduce code duplication
laruh Aug 14, 2024
a72247f
move match coin_type to the beginning of fn taker_swap_v2_details
laruh Aug 14, 2024
78166b1
review: fn set_chain_id, remove redundant doc comms, update ABIError
laruh Aug 14, 2024
b08be1a
Merge remote-tracking branch 'origin/dev' into nft-refund-payment-get…
laruh Aug 14, 2024
3629f0e
add doc comms, update sleep duration for send_and_refund_taker_fundin…
laruh Aug 14, 2024
f6ffcf1
review: reduce sleep time, use explicit U256::from
laruh Aug 14, 2024
bce1752
review: update wrapper docs
laruh Aug 14, 2024
2ee4ef1
review: etomic_swap_id_v2 with time_lock: u64
laruh Aug 14, 2024
a5765b1
dont wait pending tx for validate_taker_funding
laruh Aug 15, 2024
006963a
move send_and_refund_taker_funding_exceed_pre_approve_timelock_erc20 …
laruh Aug 15, 2024
a859414
re-check payment state in fncs `taker_payment_approve` and `sign_and_…
laruh Aug 15, 2024
738731c
change sleep duration for send_and_refund_taker_funding_by_secret_erc20
laruh Aug 15, 2024
d9e3c4e
review: provide const ZERO_VALUE
laruh Aug 15, 2024
e1144d1
review: fix missed maker_secret_hash, unify EthCoinType match arms
laruh Aug 18, 2024
fbe7bb6
review: fix timelocks doc comms, make them clearer.
laruh Aug 18, 2024
adb69d5
review: provide RefundMakerPaymentTimelockArgs, RefundMakerPaymentSec…
laruh Aug 19, 2024
28694c7
change sleep duration in send_and_refund_taker_funding_by_secret_erc20
laruh Aug 19, 2024
a933c74
review: return 10 sec sleep in wait_for_taker_payment_spend_impl
laruh Aug 19, 2024
e5bde47
review: fix ABIError match and use InvalidData
laruh Aug 19, 2024
be41221
remove "reuse refund_taker_funding_timelock_impl" clarification
laruh Aug 19, 2024
983ea4d
review: change fn refund_taker_funding_timelock_impl name
laruh Aug 19, 2024
07fa30a
Merge remote-tracking branch 'origin/dev' into nft-refund-payment-get…
laruh Aug 20, 2024
8e50c8f
fix compile error
laruh Aug 20, 2024
1c635b4
fix eth docker tests: ensure_p2p_context before eth_coin_from_conf_an…
laruh Aug 20, 2024
6f34920
fix eth docker tests: init CryptoCtx for MM_CTX1
laruh Aug 20, 2024
098e270
fix eth docker tests: build mmctx for global Nft
laruh Aug 20, 2024
8469aff
fix eth docker tests: init_p2p_context right in lazy static
laruh Aug 21, 2024
98f78d2
fix eth docker tests: use ensure_p2p_context
laruh Aug 21, 2024
885c0e9
comment for_slp_ops.wait_ready
laruh Aug 21, 2024
525b99d
Revert "comment for_slp_ops.wait_ready"
laruh Aug 21, 2024
0e35898
docker tests: init_p2p_context in lazy static
laruh Aug 21, 2024
fbdbf10
docker tests: exclude p2pctx in build_web3_instances for tests
laruh Aug 22, 2024
eb83c70
Revert "docker tests: exclude p2pctx in build_web3_instances for tests"
laruh Aug 22, 2024
f7668ce
docker tests: provide build_web3_instances_for_test and eth_coin_from…
laruh Aug 22, 2024
653c063
review: remove unused code, except SwapAddresses::init and eth_coin_v…
laruh Aug 25, 2024
20b9428
Merge remote-tracking branch 'origin/dev' into nft-refund-payment-get…
laruh Aug 25, 2024
1fda81b
fix clippy
laruh Aug 25, 2024
722b807
review: remove From impl for RefundPaymentArgs
laruh Aug 25, 2024
f1e6b20
provide test func changes notification in doc comms
laruh Aug 25, 2024
f9f8d50
use p2p ctx only if `komodo_proxy` is true
shamardy Aug 27, 2024
b744a1d
correct GETH_NONCE_LOCK in geth_erc1155_balance and ERC20 ticker in e…
laruh Aug 28, 2024
2381b7d
review: provide check_decoded_length
laruh Aug 28, 2024
1faea01
ignore taker sepolia tests
laruh Aug 28, 2024
6dd0fc2
review: provide smart contract methods links
laruh Aug 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions mm2src/coins/coin_errors.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::eth::nft_swap_v2::errors::{Erc721FunctionError, HtlcParamsError, PaymentStatusErr, PrepareTxDataError};
use crate::eth::eth_swap_v2::{PaymentStatusErr, ValidatePaymentV2Err};
use crate::eth::nft_swap_v2::errors::{Erc721FunctionError, HtlcParamsError, PrepareTxDataError};
use crate::eth::{EthAssocTypesError, EthNftAssocTypesError, Web3RpcError};
use crate::{utxo::rpc_clients::UtxoRpcError, NumConversError, UnexpectedDerivationMethod};
use enum_derives::EnumFromStringify;
Expand Down Expand Up @@ -50,6 +51,7 @@ pub enum ValidatePaymentError {
TimelockOverflow(TryFromIntError),
#[display(fmt = "Nft Protocol is not supported yet!")]
NftProtocolNotSupported,
InvalidData(String),
}

impl From<SPVError> for ValidatePaymentError {
Expand Down Expand Up @@ -84,9 +86,8 @@ impl From<PaymentStatusErr> for ValidatePaymentError {
fn from(err: PaymentStatusErr) -> Self {
match err {
PaymentStatusErr::Transport(e) => Self::Transport(e),
PaymentStatusErr::AbiError(e)
| PaymentStatusErr::Internal(e)
| PaymentStatusErr::TxDeserializationError(e) => Self::InternalError(e),
PaymentStatusErr::ABIError(e) | PaymentStatusErr::Internal(e) => Self::InternalError(e),
PaymentStatusErr::InvalidData(e) => Self::InvalidData(e),
}
}
}
Expand All @@ -95,7 +96,16 @@ impl From<HtlcParamsError> for ValidatePaymentError {
fn from(err: HtlcParamsError) -> Self {
match err {
HtlcParamsError::WrongPaymentTx(e) => ValidatePaymentError::WrongPaymentTx(e),
HtlcParamsError::TxDeserializationError(e) => ValidatePaymentError::TxDeserializationError(e),
HtlcParamsError::ABIError(e) | HtlcParamsError::InvalidData(e) => ValidatePaymentError::InvalidData(e),
}
}
}

impl From<ValidatePaymentV2Err> for ValidatePaymentError {
fn from(err: ValidatePaymentV2Err) -> Self {
match err {
ValidatePaymentV2Err::UnexpectedPaymentState(e) => ValidatePaymentError::UnexpectedPaymentState(e),
ValidatePaymentV2Err::WrongPaymentTx(e) => ValidatePaymentError::WrongPaymentTx(e),
}
}
}
Expand Down
100 changes: 78 additions & 22 deletions mm2src/coins/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ mod eip1559_gas_fee;
pub(crate) use eip1559_gas_fee::FeePerGasEstimated;
use eip1559_gas_fee::{BlocknativeGasApiCaller, FeePerGasSimpleEstimator, GasApiConfig, GasApiProvider,
InfuraGasApiCaller};
mod eth_swap_v2;
pub(crate) mod eth_swap_v2;

/// https://github.com/artemii235/etomic-swap/blob/master/contracts/EtomicSwap.sol
/// Dev chain (195.201.137.5:8565) contract address: 0x83965C539899cC0F918552e5A26915de40ee8852
Expand Down Expand Up @@ -827,9 +827,18 @@ impl EthCoinImpl {
/// The id used to differentiate payments on Etomic swap smart contract
pub(crate) fn etomic_swap_id(&self, time_lock: u32, secret_hash: &[u8]) -> Vec<u8> {
let timelock_bytes = time_lock.to_le_bytes();
self.generate_etomic_swap_id(&timelock_bytes, secret_hash)
}

let mut input = Vec::with_capacity(timelock_bytes.len() + secret_hash.len());
input.extend_from_slice(&timelock_bytes);
/// The id used to differentiate payments on Etomic swap v2 smart contracts
pub(crate) fn etomic_swap_id_v2(&self, time_lock: u64, secret_hash: &[u8]) -> Vec<u8> {
let timelock_bytes = time_lock.to_le_bytes();
self.generate_etomic_swap_id(&timelock_bytes, secret_hash)
}

fn generate_etomic_swap_id(&self, time_lock_bytes: &[u8], secret_hash: &[u8]) -> Vec<u8> {
let mut input = Vec::with_capacity(time_lock_bytes.len() + secret_hash.len());
input.extend_from_slice(time_lock_bytes);
input.extend_from_slice(secret_hash);
sha256(&input).to_vec()
}
Expand Down Expand Up @@ -7031,32 +7040,38 @@ impl Eip1559Ops for EthCoin {

#[async_trait]
impl TakerCoinSwapOpsV2 for EthCoin {
/// Wrapper for [EthCoin::send_taker_funding_impl]
async fn send_taker_funding(&self, args: SendTakerFundingArgs<'_>) -> Result<Self::Tx, TransactionErr> {
self.send_taker_funding_impl(args).await
}

async fn validate_taker_funding(&self, _args: ValidateTakerFundingArgs<'_, Self>) -> ValidateSwapV2TxResult {
todo!()
/// Wrapper for [EthCoin::validate_taker_funding_impl]
async fn validate_taker_funding(&self, args: ValidateTakerFundingArgs<'_, Self>) -> ValidateSwapV2TxResult {
self.validate_taker_funding_impl(args).await
}

async fn refund_taker_funding_timelock(&self, _args: RefundPaymentArgs<'_>) -> Result<Self::Tx, TransactionErr> {
todo!()
async fn refund_taker_funding_timelock(
&self,
args: RefundTakerPaymentArgs<'_>,
) -> Result<Self::Tx, TransactionErr> {
self.refund_taker_payment_with_timelock_impl(args).await
}

async fn refund_taker_funding_secret(
&self,
_args: RefundFundingSecretArgs<'_, Self>,
args: RefundFundingSecretArgs<'_, Self>,
) -> Result<Self::Tx, TransactionErr> {
todo!()
self.refund_taker_funding_secret_impl(args).await
}

/// Wrapper for [EthCoin::search_for_taker_funding_spend_impl]
async fn search_for_taker_funding_spend(
&self,
_tx: &Self::Tx,
tx: &Self::Tx,
_from_block: u64,
_secret_hash: &[u8],
) -> Result<Option<FundingTxSpend<Self>>, SearchForFundingSpendErr> {
todo!()
self.search_for_taker_funding_spend_impl(tx).await
}

/// Eth doesnt have preimages
Expand All @@ -7080,18 +7095,21 @@ impl TakerCoinSwapOpsV2 for EthCoin {
Ok(())
}

/// Eth doesnt use multisig
/// Wrapper for [EthCoin::taker_payment_approve]
async fn sign_and_send_taker_funding_spend(
&self,
_preimage: &TxPreimageWithSig<Self>,
_args: &GenTakerFundingSpendArgs<'_, Self>,
args: &GenTakerFundingSpendArgs<'_, Self>,
_swap_unique_data: &[u8],
) -> Result<Self::Tx, TransactionErr> {
todo!()
self.taker_payment_approve(args).await
}

async fn refund_combined_taker_payment(&self, _args: RefundPaymentArgs<'_>) -> Result<Self::Tx, TransactionErr> {
todo!()
async fn refund_combined_taker_payment(
&self,
args: RefundTakerPaymentArgs<'_>,
) -> Result<Self::Tx, TransactionErr> {
self.refund_taker_payment_with_timelock_impl(args).await
}

/// Eth doesnt have preimages
Expand All @@ -7115,23 +7133,25 @@ impl TakerCoinSwapOpsV2 for EthCoin {
Ok(())
}

/// Wrapper for [EthCoin::sign_and_broadcast_taker_payment_spend_impl]
async fn sign_and_broadcast_taker_payment_spend(
&self,
_preimage: &TxPreimageWithSig<Self>,
_gen_args: &GenTakerPaymentSpendArgs<'_, Self>,
_secret: &[u8],
gen_args: &GenTakerPaymentSpendArgs<'_, Self>,
secret: &[u8],
_swap_unique_data: &[u8],
) -> Result<Self::Tx, TransactionErr> {
todo!()
self.sign_and_broadcast_taker_payment_spend_impl(gen_args, secret).await
}

/// Wrapper for [EthCoin::wait_for_taker_payment_spend_impl]
async fn wait_for_taker_payment_spend(
&self,
_taker_payment: &Self::Tx,
taker_payment: &Self::Tx,
_from_block: u64,
_wait_until: u64,
wait_until: u64,
) -> MmResult<Self::Tx, WaitForTakerPaymentSpendError> {
todo!()
self.wait_for_taker_payment_spend_impl(taker_payment, wait_until).await
}
}

Expand Down Expand Up @@ -7162,3 +7182,39 @@ impl CommonSwapOpsV2 for EthCoin {
self.derive_htlc_pubkey_v2(swap_unique_data).to_bytes()
}
}

#[cfg(all(feature = "for-tests", not(target_arch = "wasm32")))]
impl EthCoin {
pub async fn set_coin_type(&self, new_coin_type: EthCoinType) -> EthCoin {
let coin = EthCoinImpl {
ticker: self.ticker.clone(),
coin_type: new_coin_type,
priv_key_policy: self.priv_key_policy.clone(),
derivation_method: Arc::clone(&self.derivation_method),
sign_message_prefix: self.sign_message_prefix.clone(),
swap_contract_address: self.swap_contract_address,
swap_v2_contracts: self.swap_v2_contracts,
fallback_swap_contract: self.fallback_swap_contract,
contract_supports_watchers: self.contract_supports_watchers,
web3_instances: AsyncMutex::new(self.web3_instances.lock().await.clone()),
decimals: self.decimals,
history_sync_state: Mutex::new(self.history_sync_state.lock().unwrap().clone()),
required_confirmations: AtomicU64::new(
self.required_confirmations.load(std::sync::atomic::Ordering::SeqCst),
),
swap_txfee_policy: Mutex::new(self.swap_txfee_policy.lock().unwrap().clone()),
max_eth_tx_type: self.max_eth_tx_type,
ctx: self.ctx.clone(),
chain_id: self.chain_id,
trezor_coin: self.trezor_coin.clone(),
logs_block_range: self.logs_block_range,
address_nonce_locks: Arc::clone(&self.address_nonce_locks),
erc20_tokens_infos: Arc::clone(&self.erc20_tokens_infos),
nfts_infos: Arc::clone(&self.nfts_infos),
platform_fee_estimator_state: Arc::clone(&self.platform_fee_estimator_state),
gas_limit: EthGasLimit::default(),
abortable_system: self.abortable_system.create_subsystem().unwrap(),
};
EthCoin(Arc::new(coin))
}
onur-ozkan marked this conversation as resolved.
Show resolved Hide resolved
}
Loading
Loading