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): add standalone maker contract and proxy support #2100

Merged
merged 49 commits into from
Jul 18, 2024

Conversation

laruh
Copy link
Member

@laruh laruh commented Apr 24, 2024

related to issue #900

Etomic swap implementation approach was changed to Multi Standalone Etomic Swap contracts (see KomodoPlatform/etomic-swap#7 (comment))

At the first stage we are going to support EtomicSwapMakerNftV2 and EtomicSwapTakerV2 contracts in NFT Swap Komodefi feature, where Maker is NFT owner and Taker swaps ETH/ETH20.

  • The part related to standalone Maker Nft swap contract is r2r
  • Additionally, this commit ebac6e6 contains additional checks for malicious token_uri links like this

https://docs.moralis.io/web3-data-api/evm/reference/get-wallet-nfts?address=0xf622a6C52C94b500542E2AE6bcAD24C53Bc5b6a2&chain=polygon&format=decimal&token_addresses=[]&media_items=false
image
https://en.wikipedia.org/wiki/Zip_bomb

  • In the same commit ebac6e6 clear_all param in clear_nft_db RPC now is optional. false is default.
curl --url "http://127.0.0.1:7783" --data '{"userpass":"'$USERPASS'","method":"clear_nft_db","mmrpc":"2.0","params":{"chains":["POLYGON","BSC"]}}'

Req/Res examples for enable eth with tokens RPC

If we want to add support of other block chain types, we will need to make SignOps more generic, right now it focuses on eth types https://github.com/KomodoPlatform/komodo-defi-proxy/blob/80d92fbe1714c5052628b80d90c5a994640e3762/src/security/sign.rs#L5

use ethereum_types::{Address, H256};
use ethkey::{sign, verify_address, Secret, Signature};

we will implement this as needed.

@laruh laruh added the in progress Changes will be made from the author label Apr 24, 2024
@laruh laruh self-assigned this Apr 24, 2024
@laruh laruh changed the title feat(nft-swap): standalone nft maker swap contract and sepolia testenet support feat(nft-swap): standalone nft maker swap contract and sepolia testenet Apr 24, 2024
@laruh laruh force-pushed the standalone-nft-maker-swap-contract-sepolia-test branch from 1fbe447 to fe498fa Compare April 26, 2024 14:07
@laruh laruh force-pushed the standalone-nft-maker-swap-contract-sepolia-test branch 2 times, most recently from 9dc1ea1 to 942d139 Compare April 29, 2024 08:12
@laruh laruh force-pushed the standalone-nft-maker-swap-contract-sepolia-test branch from 942d139 to 998708b Compare April 29, 2024 08:19
shamardy
shamardy previously approved these changes Jun 21, 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.

Great work! Only non-blocker comments.
@mariocynicys @onur-ozkan can you please check if your comments are resolved and if you have any more comments.
@laruh I guess I will have to review, approve and then merge this PR #2129 first and also this PR KomodoPlatform/komodo-defi-proxy#22 before merging this. Is that correct?

}
match block_on(GETH_WEB3.eth().block_number().timeout(Duration::from_secs(6))) {
Ok(Ok(block_number)) => {
println!("Geth node is ready, latest block number: {:?}", block_number);
Copy link
Collaborator

Choose a reason for hiding this comment

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

We shouldn't use println in tests, we should use log! macro instead

Copy link
Member Author

Choose a reason for hiding this comment

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

agree, fixed here e672485

)
.unwrap();

println!("Transaction sent: {:?}", result);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same with println

Copy link
Member Author

Choose a reason for hiding this comment

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

done e672485

@laruh
Copy link
Member Author

laruh commented Jun 22, 2024

@laruh I guess I will have to review, approve and then merge this PR #2129 first and also this PR KomodoPlatform/komodo-defi-proxy#22 before merging this. Is that correct?

@shamardy
I think this #2100 PR can be merged in dev first, before #2129 if I dont have review notes which require me to refactor the whole architecture. Then I would prefer to do such big changes in #2129 (to avoid conflicts and messed up logic). In this case, yes we have to merge #2129 to #2100 and then #2100 to dev. If #2100 approved with non-blocker changes like your note, then I can do the changes right in this branch and merge it to #2129.

as for proxy PRs. I have two:

To sum up:
So if #2100 is approved without breaking changes for #2129 branch, then we can merge it to dev, and I will change merge branch to dev in #2129.

Proxies PRs:
#2100 uses this feature KomodoPlatform/komodo-defi-proxy#22
#2129 additionally started to use this pr quicknode refactoring KomodoPlatform/komodo-defi-proxy#23

If #2100 will be fully approved, then it means that reviewers agreed with KomodoPlatform/komodo-defi-proxy#22 logic, same for #2129 and KomodoPlatform/komodo-defi-proxy#23

Proxy prs can get more non braking notes after komodefi being approved, but if reviewers decide to change the format of request to Proxy layer, then we have to update komodefi nft opened prs, or open new if previous were merged

@laruh
Copy link
Member Author

laruh commented Jun 24, 2024

reqs examples how to enable nft, with platform coin and separately

curl --url "http://127.0.0.1:7783" --data '{
  "userpass": "'$USERPASS'",
  "method": "enable_eth_with_tokens",
  "mmrpc": "2.0",
  "params": {
    "ticker": "MATIC",
    "mm2": 1,
    "swap_contract_address": "0x9130b257D37A52E52F21054c4DA3450c72f595CE",
    "maker_swap_v2_contract": "0x9130b257D37A52E52F21054c4DA3450c72f595CE",
    "taker_swap_v2_contract": "0x9130b257D37A52E52F21054c4DA3450c72f595CE",
    "fallback_swap_contract": "0x9130b257D37A52E52F21054c4DA3450c72f595CE",
    "nodes": [
      {
        "url": "https://polygon-rpc.com"
      }
    ],
    "erc20_tokens_requests": [],
    "nft_req": {
      "provider":{
        "type": "Moralis",
        "info": {
          "url":"http://localhost:6150/nft-test",
          "proxy_auth":true
        }
      }
    }
  }
}'

curl --url "http://127.0.0.1:7783" --data '{
  "userpass": "'$USERPASS'",
  "method": "enable_nft",
  "mmrpc": "2.0",
  "params": {
    "ticker": "NFT_MATIC",
    "activation_params": {
      "provider":{
        "type": "Moralis",
        "info": {
          "url":"http://localhost:6150/nft-test",
          "proxy_auth":true
        }
      }
    }
  }
}'

…e-nft-maker-swap-contract-sepolia-test

# Conflicts:
#	mm2src/mm2_main/tests/docker_tests/docker_tests_common.rs
#	mm2src/mm2_main/tests/docker_tests_main.rs
@shamardy
Copy link
Collaborator

@laruh please fix merge conflicts so that I can give this one final look then approve and merge. I guess NFT will still work if we don't deploy komodefi proxy latest code, right? Also, since docs and coin config PRs are open, I can merge this PR without waiting for QA, unless some testing using new proxy code or for new enable method is needed first c.c. @KomodoPlatform/qa

@laruh
Copy link
Member Author

laruh commented Jul 18, 2024

@shamardy thanks for pinging, will fix conflicts asap. i suppose they occurred after eth gas limit PR merge this night.

I guess NFT will still work if we don't deploy komodefi proxy latest code, right?

NFT feature should work in both cases: if latest komo proxy code deployed or not deployed. as currently https://moralis-proxy.komodo.earth endpoint doesnt have proxy limits, this url can be used with proxy_auth: false (this field even can be skipped in RPC as we use serde default annotation)
Screenshot 2024-07-18 at 10 51 53

I would say its more about not merging this the second nft pr #2129 to dev, as it contains Quicknode http request changes:
Screenshot 2024-07-18 at 10 59 51

without the up to date proxy version quicknode gui_auth:true wont work

I can merge this PR without waiting for QA, unless some testing using new proxy code or for new enable method is needed first

Yes, I suppose this standalone nft pr could be merged to dev now, while the second nft pr with refund methods, v2 activation and Quicknode changes should be merged after @KomodoPlatform/qa team testing and docs, coins pr approve.

…wap-contract-sepolia-test

# Conflicts:
#	mm2src/coins/eth.rs
#	mm2src/coins/eth/nft_swap_v2/mod.rs
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.

Re-approve

@shamardy shamardy changed the title feat(nft-swap): standalone nft maker swap contract and sepolia testenet feat(nft-swap): add standalone NFT maker swap contract and komodefi-proxy support Jul 18, 2024
@shamardy shamardy changed the title feat(nft-swap): add standalone NFT maker swap contract and komodefi-proxy support feat(nft-swap): standalone NFT maker swap contract and komodefi-proxy support Jul 18, 2024
@shamardy shamardy changed the title feat(nft-swap): standalone NFT maker swap contract and komodefi-proxy support feat(nft-swap): add standalone maker contract and proxy support Jul 18, 2024
@shamardy shamardy merged commit c5e0e00 into dev Jul 18, 2024
25 of 31 checks passed
@shamardy shamardy deleted the standalone-nft-maker-swap-contract-sepolia-test branch July 18, 2024 21:56
shamardy added a commit that referenced this pull request Jul 18, 2024
dimxy added a commit that referenced this pull request Jul 21, 2024
* dev:
  feat(nft-swap): add standalone maker contract and proxy support (#2100)
  feat(ETH): add `gas_limit` coins param to override default values (#2137)
  feat(tendermint): implement better sequence resolving logic (#2164)
  ci(artifact): add target for macos on apple silicon (#2163)
  fix(helpers): extend http to ws address conversion (#2166)
  fix(makerbot): add "testcoin" to provider options (#2161)
  fix(hd_wallet): make extended pubkey of hd wallet generic (#2159)
  fix(docker-tests): implement containers runtime directories (#2162)
  feat(tendermint): improve the `max` handling for tendermint withdraw (#2155)
  revert #2158 (comment) (#2160)
  ci(artifacts): upload build artifacts with in-tree script (#2158)
  test(tendermint): migrate to local/offline containerized testnets (#2128)
  use easingthemes/ssh-deploy@v5.0.3 for all builds except windows (#2157)
  chore(bin): rename mm2 binaries to kdf (#2126)
Alrighttt pushed a commit that referenced this pull request Jul 25, 2024
This commit introduces the following key changes related to issue #900:

- Implement standalone NFT maker swap contract (EtomicSwapMakerNftV2)
- Add komodefi-proxy support for NFT feature, enabling HTTP GET requests

Additional changes include:
- Implement Multi Standalone Etomic Swap contracts approach
- Add support for EtomicSwapTakerV2 contract
- Enhance security with checks for malicious token_uri links
- Make clear_all parameter optional in clear_nft_db RPC (default: false)
- Implement Sepolia testnet support for testing

This change adopts the new Etomic swap implementation approach as discussed in KomodoPlatform/etomic-swap#7 (comment)
Alrighttt added a commit that referenced this pull request Jul 25, 2024
Alrighttt pushed a commit that referenced this pull request Aug 9, 2024
This commit introduces the following key changes related to issue #900:

- Implement standalone NFT maker swap contract (EtomicSwapMakerNftV2)
- Add komodefi-proxy support for NFT feature, enabling HTTP GET requests

Additional changes include:
- Implement Multi Standalone Etomic Swap contracts approach
- Add support for EtomicSwapTakerV2 contract
- Enhance security with checks for malicious token_uri links
- Make clear_all parameter optional in clear_nft_db RPC (default: false)
- Implement Sepolia testnet support for testing

This change adopts the new Etomic swap implementation approach as discussed in KomodoPlatform/etomic-swap#7 (comment)
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)
  ...
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.

4 participants