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(nft-swap): complete refund methods #2129

Merged
merged 121 commits into from
Aug 2, 2024
Merged

feat(nft-swap): complete refund methods #2129

merged 121 commits into from
Aug 2, 2024

Conversation

laruh
Copy link
Member

@laruh laruh commented May 31, 2024

#900
continues this PR #2100

  • Refund Maker Payment functions impl
  • nft swap_v2 tests started to work correctly on Geth again
  • nft activation started to use NFT conf from coins config aa1d70f (provide EVM NFT configs coins#1061)
    Note: I use nft activation with coin conf usage formulation instead of nft activation from coins conf, as NFT activation still uses some platform coin fields in initialize_global_nft function. Actually erc20 tokens do the same in initialize_erc20_token func.
    The key point is that in coin_conf_with_protocol, NFT, along with all other tokens, now relies on the "protocol" from the coin config file, instead of using the configuration of the platform coin.
  • auth message was moved from Body to Header in Quicknode Http request ece5152 (refactor quicknode: move SignedMessage to Header komodo-defi-proxy#23)

Note

In this PR maker_swap_v2_contract and taker_swap_v2_contract non-optional fields were added for Eth platform coin activation in the eth_coin_from_conf_and_request function.

Currently, if the maker/taker V2 contract addresses are not provided in the request, an error occurs. This is a breaking change, and the legacy 'enable' RPC will fail without these fields. The NFT swap address is optional.

let swap_contract_address: Address = try_s!(json::from_value(req["swap_contract_address"].clone()));
if swap_contract_address == Address::default() {
return ERR!("swap_contract_address can't be zero address");
}
let maker_swap_v2_contract: Address = try_s!(json::from_value(req["maker_swap_v2_contract"].clone()));
if maker_swap_v2_contract == Address::default() {
return ERR!("maker_swap_v2_contract can't be zero address");
}
let taker_swap_v2_contract: Address = try_s!(json::from_value(req["taker_swap_v2_contract"].clone()));
if taker_swap_v2_contract == Address::default() {
return ERR!("taker_swap_v2_contract can't be zero address");
}
let nft_maker_swap_v2_contract: Option<Address> =
try_s!(json::from_value(req["nft_maker_swap_v2_contract"].clone()));
if let Some(nft_maker_swap_v2) = nft_maker_swap_v2_contract {
if nft_maker_swap_v2 == Address::default() {
return ERR!("nft_maker_swap_v2_contract can't be zero address");
}
}

if we prefer to avoid this behavior, then I suggest, instead of returning an error, duplicate the swap_contract_address to the maker_swap_v2_contract and taker_swap_v2_contract fields if these parameters are missing.
This way, the V2 swaps can be initialized, but send funding process will fail since the legacy address lacks the necessary functionality. So currency won't get stuck in the swap contract.

laruh added 30 commits April 18, 2024 20:31
…V2 contract, some --dev args in geth conf, impl wait_for_geth_node_ready
…e-nft-maker-swap-contract-sepolia-test

# Conflicts:
#	mm2src/coins/eth.rs
#	mm2src/mm2_main/tests/docker_tests/eth_docker_tests.rs
…etPayload format, add body: Option<String> for wasm target request, None payload in tests
… for MM_CTX1, remove unnecessary Geth args, simplify request_body creation, change sleep duration in tests
@laruh laruh added in progress Changes will be made from the author and removed under review labels Jul 29, 2024
@laruh laruh mentioned this pull request Jul 29, 2024
21 tasks
mm2src/coins/eth/v2_activation.rs Show resolved Hide resolved
mm2src/coins/eth/taker_swap_v2_abi.json Outdated Show resolved Hide resolved
mm2src/coins/eth/maker_swap_v2_abi.json Outdated Show resolved Hide resolved
@laruh laruh added under review and removed in progress Changes will be made from the author labels Jul 29, 2024
shamardy
shamardy previously approved these changes Aug 1, 2024
Copy link
Collaborator

@shamardy shamardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

@shamardy
Copy link
Collaborator

shamardy commented Aug 1, 2024

@laruh can you please write new changes that need to be documented e.g. swap_v2_contracts field/parameter? we can instead open an issue in the docs repo https://github.com/KomodoPlatform/komodo-docs-mdx/issues and coins repo https://github.com/KomodoPlatform/coins/issues with 2.2.0-beta tag and link the PR to it. I think this is a better approach c.c. @smk762 @cipig

Copy link
Member

@borngraced borngraced left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! last notes from me

mm2src/coins/eth/eth_swap_v2.rs Outdated Show resolved Hide resolved
mm2src/coins/eth.rs Outdated Show resolved Hide resolved
mm2src/coins/eth.rs Outdated Show resolved Hide resolved
Copy link
Member

@borngraced borngraced left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@laruh
Copy link
Member Author

laruh commented Aug 2, 2024

@laruh can you please write new changes that need to be documented e.g. swap_v2_contracts field/parameter? we can instead open an issue in the docs repo https://github.com/KomodoPlatform/komodo-docs-mdx/issues and coins repo https://github.com/KomodoPlatform/coins/issues with 2.2.0-beta tag and link the PR to it. I think this is a better approach c.c. @smk762 @cipig

opened coins issue KomodoPlatform/coins#1115 (I cant create new labels here)
issue in docs KomodoPlatform/komodo-docs-mdx#310

@shamardy
Copy link
Collaborator

shamardy commented Aug 2, 2024

opened coins issue KomodoPlatform/coins#1115 (I cant create new labels here)

created a label and added it to the issue.

@shamardy
Copy link
Collaborator

shamardy commented Aug 2, 2024

In this PR maker_swap_v2_contract and taker_swap_v2_contract non-optional fields were added for Eth platform coin activation in the eth_coin_from_conf_and_request function.

@laruh The above is in the PR description but we made these non-optional, please update PR description even post-merge.

@shamardy shamardy merged commit 9b01339 into dev Aug 2, 2024
20 of 27 checks passed
@shamardy shamardy deleted the nft-refund-payment-geth branch August 2, 2024 15:01
Alrighttt pushed a commit that referenced this pull request Aug 9, 2024
This commit does the following:
- Resolves issues with NFT swap_v2 tests on Geth.
- Updates NFT activation to utilize coins config.
- Moves authentication message from Body to Header in Quicknode HTTP requests.
- Adds optional `swap_v2_contracts` field for Ethereum platform coin activation.
dimxy added a commit to dimxy/komodo-defi-framework that referenced this pull request Aug 12, 2024
* dev: (22 commits)
  chore(release): bump mm2 version to 2.2.0-beta (KomodoPlatform#2188)
  ci(docker-tests): ignore tendermint IBC tests for now (KomodoPlatform#2185)
  feat(nft-swap): complete refund methods (KomodoPlatform#2129)
  chore(release): add changelog entries for v2.1.0-beta (KomodoPlatform#2165)
  fix(zcoin): don't force low r signing to generate htlc pubkey for zcoin (KomodoPlatform#2184)
  chore(rust-analyzer): add rust-analyzer into the workspace toolchain (KomodoPlatform#2179)
  chore: migrate .cargo/config to .cargo/config.toml to avoid deprecation warning (KomodoPlatform#2177)
  fix(swaps): ensure taker payment spend confirmations (KomodoPlatform#2176)
  feat(nft-swap): add standalone maker contract and proxy support (KomodoPlatform#2100)
  feat(ETH): add `gas_limit` coins param to override default values (KomodoPlatform#2137)
  feat(tendermint): implement better sequence resolving logic (KomodoPlatform#2164)
  ci(artifact): add target for macos on apple silicon (KomodoPlatform#2163)
  fix(helpers): extend http to ws address conversion (KomodoPlatform#2166)
  fix(makerbot): add "testcoin" to provider options (KomodoPlatform#2161)
  fix(hd_wallet): make extended pubkey of hd wallet generic (KomodoPlatform#2159)
  fix(docker-tests): implement containers runtime directories (KomodoPlatform#2162)
  feat(tendermint): improve the `max` handling for tendermint withdraw (KomodoPlatform#2155)
  revert KomodoPlatform#2158 (comment) (KomodoPlatform#2160)
  ci(artifacts): upload build artifacts with in-tree script (KomodoPlatform#2158)
  test(tendermint): migrate to local/offline containerized testnets (KomodoPlatform#2128)
  ...
dimxy added a commit that referenced this pull request Aug 15, 2024
* dev:
  chore(mm2_main): replace lib.rs by mm2.rs as the root lib (#2178)
  chore(release): bump mm2 version to 2.2.0-beta (#2188)
  ci(docker-tests): ignore tendermint IBC tests for now (#2185)
  feat(nft-swap): complete refund methods (#2129)
  chore(release): add changelog entries for v2.1.0-beta (#2165)
  fix(zcoin): don't force low r signing to generate htlc pubkey for zcoin (#2184)
  chore(rust-analyzer): add rust-analyzer into the workspace toolchain (#2179)
  chore: migrate .cargo/config to .cargo/config.toml to avoid deprecation warning (#2177)
  fix(swaps): ensure taker payment spend confirmations (#2176)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants