atomicDEX-API icon indicating copy to clipboard operation
atomicDEX-API copied to clipboard

feat(walletconnect): walletconnect integration

Open borngraced opened this issue 1 year ago • 32 comments

#1543 This PR introduces the integration of WalletConnect into the Komodo DeFi Framework (KDF), enabling secure wallet connections for Cosmos and EVM-based chains. KDF acts as the DApp(in this PR), allowing users to initiate and manage transactions securely with external wallets e.g via Metamask.

Changes included:

  • [x] Implemented multi-session handling for concurrent WalletConnect connections across accounts, integrates SQLite/IndexedDB for persistent session storage across devices and enhances relayer disconnection handling for smoother session management
  • [x] Implemented WalletConnect coin activation for Tendermint and EVM.
  • [x] Implemented Withdraw and Swap functionalities for Tendermint and EVM

https://specs.walletconnect.com/2.0/specs/clients/sign/ https://specs.walletconnect.com/2.0/specs/clients/core/pairing/ https://specs.walletconnect.com/2.0/specs/clients/core/crypto/ https://specs.walletconnect.com/2.0/specs/servers/relay/ https://docs.reown.com/advanced/multichain/rpc-reference/ethereum-rpc

Additional improvements include cleanup of unused dependencies, minor code refinements, and WASM compatibility

Updated deps:
Added deps:
Removed deps:

How to test using EVM coin e.g ETH (Native && WASM)

  1. Start kdf (cargo run)
  2. Create WalletConnect session connection
    • Use the RPC below
    • Copy the connection URL and either:
      • Paste directly in your wallet or
      • Generate QR code using QR Code Generator and scan with your wallet (e.g., MetaMask)
  3. Activate ETH coin (set "priv_key_policy": "wallet_connect": { "session_topic": your_session_topic" } in activation params).
  4. Approve authentication request in your Wallet
  5. Withdraw or trade.

Note: To add more eip155 chains, modify the chains array like this: ["eip155:1", "eip155:250"]

New RPC Methods

New connection

method: wc_new_connection

{
	"method": "wc_new_connection",
	"userpass": "{{ _.userpass }}",
	"mmrpc": "2.0",
	"params": {
		"required_namespaces": {
			"eip155": {
				"chains": [
					"eip155:1"
				],
				"methods": [
					"eth_sendTransaction",
					"eth_signTransaction",
					"personal_sign"
				],
				"events": [
					"accountsChanged",
					"chainChanged"
				]
			},
			"cosmos": {
				"chains": [
					"cosmos:cosmoshub-4"
				],
				"methods": [
					"cosmos_signDirect",
					"cosmos_signAmino",
					"cosmos_getAccounts"
				],
				"events": []
			}
		}
	}
}

Get/Retrieve Walletconnect session(s)

method: wc_get_session | wc_get_sessions

{
	"method": "wc_get_session" | "wc_get_sessions",
	"userpass": "{{ _.userpass }}",
	"mmrpc": "2.0",
	"params": {
		"topic": "3a6327f78840427d3a428e8fbaaaaabc8c89c582bb2ff4464d3c73d8e2e5b253"
	}
}

Ping Walletconnect session

method: wc_ping_session

{
	"method": "wc_ping_session",
	"userpass": "{{ _.userpass }}",
	"mmrpc": "2.0",
	"params": {
		"topic": "3a6327f78840427d3a428e8fbaaaaabc8c89c582bb2ff4464d3c73d8e2e5b253"
	}
}

Delete Walletconnect session

method: wc_delete_session

{
	"method": "wc_delete_session",
	"userpass": "{{ _.userpass }}",
	"mmrpc": "2.0",
	"params": {
		"topic": "3a6327f78840427d3a428e8fbaaaaabc8c89c582bb2ff4464d3c73d8e2e5b253"
	}
}

Active ETH/ERC

method: enable_eth_with_tokens

{
    "priv_key_policy": {
        "wallet_connect": {
            "session_topic": "3a6327f78840427d3a428e8fbaaaaabc8c89c582bb2ff4464d3c73d8e2e5b253"
        }
    },
    ...
}

Active Tendermint/Cosmos

method: enable_tendermint_with_assets

{
    "activation_params": {
        "wallet_connect": {
            "session_topic": "'3a6327f78840427d3a428e8fbaaaaabc8c89c582bb2ff4464d3c73d8e2e5b253"
        }
    },
    ...
}

cc @smk762

borngraced avatar Sep 16 '24 19:09 borngraced

@onur-ozkan This PR requires your review on the tendermint code changes at least

shamardy avatar Nov 08 '24 19:11 shamardy

@borngraced cargo lock conflict occurred

laruh avatar Nov 12 '24 08:11 laruh

so what about just sending it for now and when wallets listen to it later we get this feat for free

Two reasons I didn't want to, this will add extra latency and corresponding wallet will return error as they wont't recognize such session request

borngraced avatar Dec 26 '24 09:12 borngraced

Current code state fails to build/run https://github.com/KomodoPlatform/komodo-defi-framework/actions/runs/13696493437/job/38300021140?pr=2223#step:10:1222 (same error seen locally with cargo run or cargo build -vv.

Commit https://github.com/KomodoPlatform/komodo-defi-framework/pull/2223/commits/167734b4c26713b353c612b0cafad2630192cf18 (prior to merging in dev) builds ok, so likely error is result of merge conflict.

smk762 avatar Mar 07 '25 07:03 smk762

"chains": [
    "eip155:1",
    "eip155:137"
],

Would it be ok to use actual chain/network name as shown in coins file instead?

smk762 avatar Mar 07 '25 07:03 smk762

"chains": [
    "eip155:1",
    "eip155:137"
],

Would it be ok to use actual chain/network name as shown in coins file instead?

No, just the chain_id https://specs.walletconnect.com/2.0/specs/clients/sign/namespaces

borngraced avatar Mar 07 '25 08:03 borngraced

Unfortunately I'm still having some trouble with this. Notes below:

Test Workflow

  • run wc_new_connection and use the response.url to generate a QR code (e.g. wc:foo@2?symkey=bar7&relay-protocol=irn&expiryTimestamp=1741582989
  • Scan QR code from Trust Wallet in mobile. Confirm the permissions requested. (unsure if using scan icon on main page is ok, or if settings > wallet connect must be used. Use the latter just in case)
  • Extract the substring between wc: and @ to determine the pairing_topic (e.g. foo)
  • Run wc_get_sessions, then iterate over the returned session list to extract the session_topic (baz) from the item which matches the pairing_topic (foo) extracted from the newly created connection. e.g.
    [
	 {
                "topic": "baz",
                "pairing_topic": "foo",
                "metadata": {
                    ....
                },
                 ...
                "peer_pubkey": "adcd46fc3cf71128ef855c6a1828549ae6e380d2d56afe596c66b1c7820ecc70",
                "subscription_id": "ca5909a8645541a87ed2b45d2a926f0577b14a5e85b14f3b2967ffb51d6602f0",
                "properties": null,
                "expiry": 1742185747
            },
            ...
        ]
  • Attempt to connect ETH with the session_topic. Response includes ErrorData { code: 5300, message: \"Invalid Session Properties requested\", data: None } e.g. with params like
        "priv_key_policy": {
            "wallet_connect": {
                "session_topic": "baz"
            }
        },

If using the "pairing topic" (i.e. foo instead of baz) the response is Session Error: No active WalletConnect session found, so I'm fairly confident the pairing topic is not used here.

General notes:

wc_get_sessions:

  • Using topic param still returns whole list. Is this param only intended for wc_get_session?
  • Sessions from previous runs are still present in response. Unsure if still usable, but unable to delete.
  • new connections will not appear here until after approved in trust wallet mobile app.

wc_get_session:

  • Using topic param still returns data for specific session topic, but this value seems to only be able to determined from running wc_get_sessions first and finding the item that matches the pairing_topic from a substring of the wc_new_connection reponse. Is there another (better) way, because this is a little cumbersome.
  • new connections will not appear here until after approved in trust wallet mobile app.

wc_ping_session:

  • times out, no response returned.
  • in logs: 10 05:24:59, kdf_walletconnect:422] INFO [3569914dd09a5cc4ac92dedab354f06ff5db17ef616233a8ba562cbea51269fd] Publishing message=Request(Request { id: MessageId(445845580595480), jsonrpc: "2.0", params: SessionPing(()) }) 10 05:24:59, kdf_walletconnect:444] INFO [3569914dd09a5cc4ac92dedab354f06ff5db17ef616233a8ba562cbea51269fd] Message published successfully 10 05:25:29, mm2_main::rpc::dispatcher:127] ERROR RPC error response: sessions:78] ping:24] Request timeout error

wc_delete_session:

  • times out, no response returned.
  • In logs: 10 04:05:06, kdf_walletconnect:422] INFO [feeabbad7ac1f1ba720d4441c299eab2b239f0deefb050fe50dbc7a350d55f75] Publishing message=Request(Request { id: MessageId(445844353599488), jsonrpc: "2.0", params: SessionDelete(SessionDeleteRequest { code: 6000, message: "User Disconnected" }) }) 10 04:05:06, kdf_walletconnect:444] INFO [feeabbad7ac1f1ba720d4441c299eab2b239f0deefb050fe50dbc7a350d55f75] Message published successfully
  • Session attempting to delete still appears in wc_get_sessions response
  • Session attempting to delete still appears in wc_get_session response for the topic.

smk762 avatar Mar 10 '25 05:03 smk762

  1. pairing_topic: only for connecting with external wallets, afterwards, it's basically useless.
  2. session_topic: communication with connected external wallet is moved to session_topic from pairing_topic after connecting with external wallet.
  3. for some unknown reason trustwallet is not replying to session_pings. You can skip doing this if you're using trustwallet

Komodefi WalletConnect Test Flow

1. External Wallet Connection Test Flow

I will be using ETH for this test flow.

  • run wc_new_connection and use the response.url to generate a QR code (e.g. wc:foo@2?symkey=bar7&relay-protocol=irn&expiryTimestamp=1741582989
  • Scan QR code from Trust Wallet in mobile. Confirm the permissions requested.
  • If session connection is successful, run wc_get_session e.g with response.topic and with_pairing_topic: true to enable us use pairing_topic to fetch session IF above step is successful, like:
{
	"method": "wc_get_session",
	"userpass": "{{ _.userpass }}",
	"mmrpc": "2.0",
	"params": {
		"with_pairing_topic": true,
		"topic": "efe5d00ff97750d40e96f0e794cc10106245da8b98091af69d2d42faa94efcd5"
	}
}
  • Let's call the result from this request session
  • Scan QR code from Trust Wallet in mobile. Confirm the permissions requested.

2. Coin Activation Test Flow(Needs 1 to be completed)

  • Make sure ETH or any coin you want to use with kdf is already activated in your wallet e.g trust, metamask

  • Activate ETH with enable_eth_with_tokens coin activation rpc, like:

    {
    "userpass": "{{ _.userpass }}",
    "method": "enable_eth_with_tokens",
    "mmrpc": "2.0",
    "params": {
    	"ticker": "ETH",
    	"mm2": 1,
    	"priv_key_policy": {
    		"wallet_connect": {
    			"session_topic": session.topic
    		}
    	},
    	....
    }
    

}

- Accept session/sign request for `ETH` coin in  your external wallet.


#### 3. Swap/Withdraw test
- If the everything above is done as mentioned, you can start a swap/withdrawal as you would normally do
- For `ETH` specifically, when using `metamask` wallet, you are only allowed to withdraw with `sign_and_send_tx` from `metamask` meaning you can't `withdraw` rpc will sign and send the tx. You won't need  to `sendrawtransaction` manually.
 

cc @smk762 

borngraced avatar Mar 10 '25 07:03 borngraced

Thanks. I'm still having some issues with Trust Wallet failing to scan more often than not, so its been a bit difficult to progress with testing, tho I've added the docs I can so far,

Can you please confirm wc_delete_session and wc_ping_session also take the "with_pairing_topic": true?

Code at https://github.com/KomodoPlatform/komodo-defi-framework/blob/wc-integration/mm2src/mm2_main/src/rpc/wc_commands/sessions.rs#L45 implies it as input, but when using it I'm getting error returned.

E.g Session is


            {
                "topic": "feeabbad7ac1f1ba720d4441c299eab2b239f0deefb050fe50dbc7a350d55f75",
                "metadata": {
                	...
                },
                "pairing_topic": "ad604cd186f5dc9498343fbd763f6d6963ea511de0e5d557a33a8e3790d6d4d5",
                "namespaces": {
                	...
                },
                "expiry": 1741952829
            }

Using topic feeabbad7ac1f1ba720d4441c299eab2b239f0deefb050fe50dbc7a350d55f75, the request times out before a response is received for both wc_delete_session and wc_ping_session.

When request is sent, logs show

12 03:14:26, kdf_walletconnect:422] INFO [feeabbad7ac1f1ba720d4441c299eab2b239f0deefb050fe50dbc7a350d55f75] Publishing message=Request(Request { id: MessageId(445887812284165), jsonrpc: "2.0", params: SessionDelete(SessionDeleteRequest { code: 6000, message: "User Disconnected" }) })
12 03:14:27, kdf_walletconnect:444] INFO [feeabbad7ac1f1ba720d4441c299eab2b239f0deefb050fe50dbc7a350d55f75] Message published successfully
12 03:14:27, mm2_main::rpc::dispatcher:127] ERROR RPC error response: sessions:69] delete:37] Internal Error: channel closed

but the request continues to wait. After timeout for wc_delete_session, the session is still shown in the response for wc_get_sessions.

If using the pairing topic with

	"params": {
		"with_pairing_topic": true,
		"topic": "ad604cd186f5dc9498343fbd763f6d6963ea511de0e5d557a33a8e3790d6d4d5"
	}

the response is error:

{
    "mmrpc": "2.0",
    "error": "Internal Error: topic sym_key not found: 31ad8ac1312e01ff7ff656ed5507eb9fd6f2f435668fd86331e00b33627bfc14",
    "error_path": "sessions.lib",
    "error_trace": "sessions:69] lib:281]",
    "error_type": "SessionRequestError",
    "error_data": "Internal Error: topic sym_key not found: 31ad8ac1312e01ff7ff656ed5507eb9fd6f2f435668fd86331e00b33627bfc14",
    "id": null
}

Incidentally, when set to "with_pairing_topic": true, but using the session topic regardless, it also times out - which seems to indicate the with_pairing_topic param is not applied for the wc_delete_session and wc_ping_session requests.

smk762 avatar Mar 12 '25 03:03 smk762

I'm also facing timeouts sometimes when attempting to activate ETH. In logs I see:

12 03:42:07, mm2_main::rpc::dispatcher:127] ERROR RPC error response: platform_coin_with_tokens:454] eth_with_token_activation:489] wallet_connect:178] lib:630] Request timeout error
12 03:42:52, kdf_walletconnect:422] INFO [7320725519c81f17ba098eb2b76463da4c556d08b22e22779005011610bc2a9a] Publishing message=Request(Request { id: MessageId(445888248882691), jsonrpc: "2.0", params: SessionRequest(SessionRequestRequest { request: Request { method: "personal_sign", params: Array [String("0x41757468656e7469636174652077697468204b6f6d6f64656669"), String("0xf5c6738ff36b62a032d11c4badeebf088db58e70")], expiry: None }, chain_id: "eip155:1" }) })
12 03:42:52, kdf_walletconnect:444] INFO [7320725519c81f17ba098eb2b76463da4c556d08b22e22779005011610bc2a9a] Message published successfully
12 03:42:52, mm2_main::rpc::dispatcher:127] ERROR RPC error response: sessions:69] delete:37] Internal Error: channel closed

This instance above was on a topic I attempted to delete, which might explain it a little. A fresh connection, attempting ETH activation post QR scan returned

{
    "mmrpc": "2.0",
    "error": "UnSuccessfulResponse Error: ErrorResponse { id: MessageId(445888342993158), jsonrpc: \"2.0\", error: ErrorData { code: 5300, message: \"Invalid Session Properties requested\", data: None } }",
    "error_path": "platform_coin_with_tokens.eth_with_token_activation.wallet_connect.inbound_message",
    "error_trace": "platform_coin_with_tokens:454] eth_with_token_activation:489] wallet_connect:178] inbound_message:86]",
    "error_type": "Internal",
    "error_data": "UnSuccessfulResponse Error: ErrorResponse { id: MessageId(445888342993158), jsonrpc: \"2.0\", error: ErrorData { code: 5300, message: \"Invalid Session Properties requested\", data: None } }",
    "id": null
}

Which blocks me from any further tests :(

When attempting to initiate another connection at this point, Trust wallet will scan the QR code, but then does nothing (no modal to confirm etc). Seems I need to uninstall, reinstall and use a fresh seed to wake it up again.

smk762 avatar Mar 12 '25 03:03 smk762

Can you please confirm wc_delete_session and wc_ping_session also take the "with_pairing_topic": true?

No, wc_delete_session and wc_ping_session should take only the session topic.

borngraced avatar Mar 12 '25 04:03 borngraced

Can you please confirm wc_delete_session and wc_ping_session also take the "with_pairing_topic": true?

No, wc_delete_session and wc_ping_session should take only the session topic.

Both these methods are working as expected using https://react-wallet.walletconnect.com/ (instead of Trust Wallet android app), and I am able to activate ETH/AVAX/MATIC (with wc confirmation). Unfortunately unable to withdraw, details of browser console error has been shared with @borngraced

smk762 avatar Mar 13 '25 07:03 smk762

Testing current build functions up until as withdrawal attempt is made, upon which clicking "approve" on the 3rd party WC site results in the following error message: image

Error: invalid object key - gas (argument="transaction:gas", value=

{
    "nonce": "0x0",
    "gas": "0x5208",
    "value": "0x3782dace9d90000",
    "data": "0x[]",
    "gasPrice": "0x60db88432",
    "to": "0xab95d01bc8214e4d993043e8ca1b68db2c946498"
}

code=INVALID_ARGUMENT, version=properties/5.7.0)

smk762 avatar Mar 17 '25 01:03 smk762

Still having some errors on withdraw.

Data:

{
  "nonce": "0x0",
  "from": "0x7d86332865dc16c048ed05b89ecd3c5bc57dadd0",
  "gasLimit": "0x5208",
  "value": "0x16345785d8a0000",
  "data": "0x[]",
  "gasPrice": "0x614470df1",
  "to": "0xab95d01bc8214e4d993043e8ca1b68db2c946498"
}

Error: invalid hexlify value (argument="value", value="0x[]", code=INVALID_ARGUMENT, version=bytes/5.7.0)

Response:

{
    "mmrpc": "2.0",
    "error": "Signing error UnSuccessfulResponse Error: ErrorResponse { id: MessageId(446071492638466), jsonrpc: \"2.0\", error: ErrorData { code: -32000, message: \"invalid hexlify value (argument=\\\"value\\\", value=\\\"0x[]\\\", code=INVALID_ARGUMENT, version=bytes/5.7.0)\", data: None } }",
    "error_path": "eth_withdraw.wallet_connect.inbound_message",
    "error_trace": "eth_withdraw:335] wallet_connect:107] inbound_message:86]",
    "error_type": "SigningError",
    "error_data": "UnSuccessfulResponse Error: ErrorResponse { id: MessageId(446071492638466), jsonrpc: \"2.0\", error: ErrorData { code: -32000, message: \"invalid hexlify value (argument=\\\"value\\\", value=\\\"0x[]\\\", code=INVALID_ARGUMENT, version=bytes/5.7.0)\", data: None } }",
    "id": null
}

image

smk762 avatar Mar 20 '25 10:03 smk762

I'm unable to test the Cosmos side, as on sending the wc: string with cosmos included, there is an error in browser console: image

In this state, the connection appears in https://react-wallet.walletconnect.com/pairings but without the title and icon image

And it does not appear in https://react-wallet.walletconnect.com/sessions or response from wc_get_sessions.

smk762 avatar Mar 20 '25 10:03 smk762

I'm unable to test the Cosmos side, as on sending the wc: string with cosmos included, there is an error in browser console: image

In this state, the connection appears in https://react-wallet.walletconnect.com/pairings but without the title and icon image

And it does not appear in https://react-wallet.walletconnect.com/sessions or response from wc_get_sessions.

unfortunately the example wallet didn't add support for comos_getAccounts method. We should add it.

Is it something you can do or I can help with that

borngraced avatar Mar 20 '25 10:03 borngraced

For the EVM/WalletConnect side of things, I'm able to connect, activate coin and withdraw funds - but am failing to complete a swap. Do both swap participants (and seednode) need to be running this branch?

Error logs for swap attempts:

· 2025-03-24 15:54:24 +0800 [] lp_ordermatch:3302] Entering the taker_swap_loop KMD/MATIC with uuid: e60783fe-b1a3-45b3-b6d8-6b373e85d25e
· 2025-03-24 15:54:34 +0800 [] taker_swap:831] Taker swap e60783fe-b1a3-45b3-b6d8-6b373e85d25e has successfully started
+--- 24 07:54:35 -------
| (0:00) [swap uuid=e60783fe-b1a3-45b3-b6d8-6b373e85d25e] Started...
24 07:54:42, coins::eth::wallet_connect:244] INFO target: WalletConnect: sign-and-send, get_gas_price…
+--- 24 07:54:43 -------
| (0:09) [swap uuid=e60783fe-b1a3-45b3-b6d8-6b373e85d25e] Negotiated...
24 07:54:46, coins::eth::wallet_connect:262] INFO target: WalletConnect: sign-and-send, signing and sending tx
24 07:54:46, kdf_walletconnect:422] INFO [b8cbfba89d1b9c2e374c1bd892d63f9baea5910efe3c18a1e927c973015b8d7b] Publishing message=Request(Request { id: MessageId(446157538861826), jsonrpc: "2.0", params: SessionRequest(SessionRequestRequest { request: Request { method: "eth_sendTransaction", params: Array [Object {"nonce": String("0x1"), "from": String("0xa2eb1ea222163eb1c62d3bca74e99b57b3ac4743"), "gasLimit": String("0x5208"), "value": String("0xd2b199d112c7"), "data": String("0x"), "gasPrice": String("0x686d43ed9"), "to": String("0xd8997941dd1346e9231118d5685d866294f59e5b")}], expiry: None }, chain_id: "eip155:137" }) })
24 07:54:46, kdf_walletconnect:444] INFO [b8cbfba89d1b9c2e374c1bd892d63f9baea5910efe3c18a1e927c973015b8d7b] Message published successfully
+--- 24 07:56:44 -------
| (2:09) [swap uuid=e60783fe-b1a3-45b3-b6d8-6b373e85d25e] Negotiated...
+--- 24 07:57:08 -------
| (2:33) [swap uuid=e60783fe-b1a3-45b3-b6d8-6b373e85d25e] Negotiated...
+--- 24 07:57:32 -------
| (2:57) [swap uuid=e60783fe-b1a3-45b3-b6d8-6b373e85d25e] Negotiated...
+--- 24 07:57:56 -------
| (3:22) [swap uuid=e60783fe-b1a3-45b3-b6d8-6b373e85d25e] Negotiated...
24 07:58:12, kdf_walletconnect::connection_handler:81] INFO WalletConnect disconnected with message: Some("Disconnecting for load balancing reasons (4010)"). Attempting to reconnect...
24 07:58:13, kdf_walletconnect::connection_handler:85] INFO Reconnection process complete.
+--- 24 07:58:20 -------
| (3:46) [swap uuid=e60783fe-b1a3-45b3-b6d8-6b373e85d25e] Negotiated...
+--- 24 07:58:44 -------
| (4:10) [swap uuid=e60783fe-b1a3-45b3-b6d8-6b373e85d25e] Negotiated...
+--- 24 07:59:08 -------
| (4:34) [swap uuid=e60783fe-b1a3-45b3-b6d8-6b373e85d25e] Negotiated...
+--- 24 07:59:32 -------
| (4:58) [swap uuid=e60783fe-b1a3-45b3-b6d8-6b373e85d25e] Negotiated...
24 07:59:46, mm2_main::lp_swap::taker_swap:506] ERROR [swap uuid=e60783fe-b1a3-45b3-b6d8-6b373e85d25e] TakerFeeSendFailed(SwapError { error: "taker_swap:1337] mm2src/coins/eth/wallet_connect.rs:263] wallet_connect:136] lib:630] WalletConnectError(TimeoutError)" })
· 2025-03-24 15:59:46 +0800 [swap uuid=e60783fe-b1a3-45b3-b6d8-6b373e85d25e] Finished


· 2025-03-24 16:00:55 +0800 [] lp_ordermatch:3302] Entering the taker_swap_loop KMD/MATIC with uuid: 50adb3d2-681e-4ce5-9abe-ec53e23552ed
· 2025-03-24 16:01:05 +0800 [] taker_swap:831] Taker swap 50adb3d2-681e-4ce5-9abe-ec53e23552ed has successfully started
+--- 24 08:01:06 -------
| (0:00) [swap uuid=50adb3d2-681e-4ce5-9abe-ec53e23552ed] Started...
24 08:01:12, coins::eth::wallet_connect:244] INFO target: WalletConnect: sign-and-send, get_gas_price…
+--- 24 08:01:14 -------
| (0:08) [swap uuid=50adb3d2-681e-4ce5-9abe-ec53e23552ed] Negotiated...
24 08:01:16, coins::eth::wallet_connect:262] INFO target: WalletConnect: sign-and-send, signing and sending tx
24 08:01:16, kdf_walletconnect:422] INFO [b8cbfba89d1b9c2e374c1bd892d63f9baea5910efe3c18a1e927c973015b8d7b] Publishing message=Request(Request { id: MessageId(446157638789123), jsonrpc: "2.0", params: SessionRequest(SessionRequestRequest { request: Request { method: "eth_sendTransaction", params: Array [Object {"nonce": String("0x2"), "from": String("0xa2eb1ea222163eb1c62d3bca74e99b57b3ac4743"), "gasLimit": String("0x5208"), "value": String("0x1a56333a2258f"), "data": String("0x"), "gasPrice": String("0x685556941"), "to": String("0xd8997941dd1346e9231118d5685d866294f59e5b")}], expiry: None }, chain_id: "eip155:137" }) })
24 08:01:17, kdf_walletconnect:444] INFO [b8cbfba89d1b9c2e374c1bd892d63f9baea5910efe3c18a1e927c973015b8d7b] Message published successfully
+--- 24 08:01:38 -------
| (0:33) [swap uuid=50adb3d2-681e-4ce5-9abe-ec53e23552ed] Negotiated...
+--- 24 08:02:02 -------
| (0:57) [swap uuid=50adb3d2-681e-4ce5-9abe-ec53e23552ed] Negotiated...
+--- 24 08:02:26 -------
| (1:21) [swap uuid=50adb3d2-681e-4ce5-9abe-ec53e23552ed] Negotiated...
+--- 24 08:02:51 -------
| (1:45) [swap uuid=50adb3d2-681e-4ce5-9abe-ec53e23552ed] Negotiated...
+--- 24 08:03:15 -------
| (2:09) [swap uuid=50adb3d2-681e-4ce5-9abe-ec53e23552ed] Negotiated...
+--- 24 08:03:39 -------
| (2:33) [swap uuid=50adb3d2-681e-4ce5-9abe-ec53e23552ed] Negotiated...
+--- 24 08:04:03 -------
| (2:57) [swap uuid=50adb3d2-681e-4ce5-9abe-ec53e23552ed] Negotiated...
+--- 24 08:04:27 -------
| (3:21) [swap uuid=50adb3d2-681e-4ce5-9abe-ec53e23552ed] Negotiated...
24 08:04:35, kdf_walletconnect::connection_handler:81] INFO WalletConnect disconnected with message: Some("Disconnecting for load balancing reasons (4010)"). Attempting to reconnect...
24 08:04:36, kdf_walletconnect::connection_handler:85] INFO Reconnection process complete.
+--- 24 08:04:51 -------
| (3:45) [swap uuid=50adb3d2-681e-4ce5-9abe-ec53e23552ed] Negotiated...
+--- 24 08:05:15 -------
| (4:09) [swap uuid=50adb3d2-681e-4ce5-9abe-ec53e23552ed] Negotiated...
+--- 24 08:05:39 -------
| (4:33) [swap uuid=50adb3d2-681e-4ce5-9abe-ec53e23552ed] Negotiated...
+--- 24 08:06:03 -------
| (4:58) [swap uuid=50adb3d2-681e-4ce5-9abe-ec53e23552ed] Negotiated...
24 08:06:17, mm2_main::lp_swap::taker_swap:506] ERROR [swap uuid=50adb3d2-681e-4ce5-9abe-ec53e23552ed] TakerFeeSendFailed(SwapError { error: "taker_swap:1337] mm2src/coins/eth/wallet_connect.rs:263] wallet_connect:136] lib:630] WalletConnectError(TimeoutError)" })
· 2025-03-24 16:06:17 +0800 [swap uuid=50adb3d2-681e-4ce5-9abe-ec53e23552ed] Finished

smk762 avatar Mar 24 '25 08:03 smk762

For the EVM/WalletConnect side of things, I'm able to connect, activate coin and withdraw funds - but am failing to complete a swap. Do both swap participants (and seednode) need to be running this branch?

Error logs for swap attempts:

· 2025-03-24 15:54:24 +0800 [] lp_ordermatch:3302] Entering the taker_swap_loop KMD/MATIC with uuid: e60783fe-b1a3-45b3-b6d8-6b373e85d25e
· 2025-03-24 15:54:34 +0800 [] taker_swap:831] Taker swap e60783fe-b1a3-45b3-b6d8-6b373e85d25e has successfully started
+--- 24 07:54:35 -------
| (0:00) [swap uuid=e60783fe-b1a3-45b3-b6d8-6b373e85d25e] Started...
24 07:54:42, coins::eth::wallet_connect:244] INFO target: WalletConnect: sign-and-send, get_gas_price…
+--- 24 07:54:43 -------
| (0:09) [swap uuid=e60783fe-b1a3-45b3-b6d8-6b373e85d25e] Negotiated...
24 07:54:46, coins::eth::wallet_connect:262] INFO target: WalletConnect: sign-and-send, signing and sending tx
24 07:54:46, kdf_walletconnect:422] INFO [b8cbfba89d1b9c2e374c1bd892d63f9baea5910efe3c18a1e927c973015b8d7b] Publishing message=Request(Request { id: MessageId(446157538861826), jsonrpc: "2.0", params: SessionRequest(SessionRequestRequest { request: Request { method: "eth_sendTransaction", params: Array [Object {"nonce": String("0x1"), "from": String("0xa2eb1ea222163eb1c62d3bca74e99b57b3ac4743"), "gasLimit": String("0x5208"), "value": String("0xd2b199d112c7"), "data": String("0x"), "gasPrice": String("0x686d43ed9"), "to": String("0xd8997941dd1346e9231118d5685d866294f59e5b")}], expiry: None }, chain_id: "eip155:137" }) })
24 07:54:46, kdf_walletconnect:444] INFO [b8cbfba89d1b9c2e374c1bd892d63f9baea5910efe3c18a1e927c973015b8d7b] Message published successfully
+--- 24 07:56:44 -------
| (2:09) [swap uuid=e60783fe-b1a3-45b3-b6d8-6b373e85d25e] Negotiated...
+--- 24 07:57:08 -------
| (2:33) [swap uuid=e60783fe-b1a3-45b3-b6d8-6b373e85d25e] Negotiated...
+--- 24 07:57:32 -------
| (2:57) [swap uuid=e60783fe-b1a3-45b3-b6d8-6b373e85d25e] Negotiated...
+--- 24 07:57:56 -------
| (3:22) [swap uuid=e60783fe-b1a3-45b3-b6d8-6b373e85d25e] Negotiated...
24 07:58:12, kdf_walletconnect::connection_handler:81] INFO WalletConnect disconnected with message: Some("Disconnecting for load balancing reasons (4010)"). Attempting to reconnect...
24 07:58:13, kdf_walletconnect::connection_handler:85] INFO Reconnection process complete.
+--- 24 07:58:20 -------
| (3:46) [swap uuid=e60783fe-b1a3-45b3-b6d8-6b373e85d25e] Negotiated...
+--- 24 07:58:44 -------
| (4:10) [swap uuid=e60783fe-b1a3-45b3-b6d8-6b373e85d25e] Negotiated...
+--- 24 07:59:08 -------
| (4:34) [swap uuid=e60783fe-b1a3-45b3-b6d8-6b373e85d25e] Negotiated...
+--- 24 07:59:32 -------
| (4:58) [swap uuid=e60783fe-b1a3-45b3-b6d8-6b373e85d25e] Negotiated...
24 07:59:46, mm2_main::lp_swap::taker_swap:506] ERROR [swap uuid=e60783fe-b1a3-45b3-b6d8-6b373e85d25e] TakerFeeSendFailed(SwapError { error: "taker_swap:1337] mm2src/coins/eth/wallet_connect.rs:263] wallet_connect:136] lib:630] WalletConnectError(TimeoutError)" })
· 2025-03-24 15:59:46 +0800 [swap uuid=e60783fe-b1a3-45b3-b6d8-6b373e85d25e] Finished


· 2025-03-24 16:00:55 +0800 [] lp_ordermatch:3302] Entering the taker_swap_loop KMD/MATIC with uuid: 50adb3d2-681e-4ce5-9abe-ec53e23552ed
· 2025-03-24 16:01:05 +0800 [] taker_swap:831] Taker swap 50adb3d2-681e-4ce5-9abe-ec53e23552ed has successfully started
+--- 24 08:01:06 -------
| (0:00) [swap uuid=50adb3d2-681e-4ce5-9abe-ec53e23552ed] Started...
24 08:01:12, coins::eth::wallet_connect:244] INFO target: WalletConnect: sign-and-send, get_gas_price…
+--- 24 08:01:14 -------
| (0:08) [swap uuid=50adb3d2-681e-4ce5-9abe-ec53e23552ed] Negotiated...
24 08:01:16, coins::eth::wallet_connect:262] INFO target: WalletConnect: sign-and-send, signing and sending tx
24 08:01:16, kdf_walletconnect:422] INFO [b8cbfba89d1b9c2e374c1bd892d63f9baea5910efe3c18a1e927c973015b8d7b] Publishing message=Request(Request { id: MessageId(446157638789123), jsonrpc: "2.0", params: SessionRequest(SessionRequestRequest { request: Request { method: "eth_sendTransaction", params: Array [Object {"nonce": String("0x2"), "from": String("0xa2eb1ea222163eb1c62d3bca74e99b57b3ac4743"), "gasLimit": String("0x5208"), "value": String("0x1a56333a2258f"), "data": String("0x"), "gasPrice": String("0x685556941"), "to": String("0xd8997941dd1346e9231118d5685d866294f59e5b")}], expiry: None }, chain_id: "eip155:137" }) })
24 08:01:17, kdf_walletconnect:444] INFO [b8cbfba89d1b9c2e374c1bd892d63f9baea5910efe3c18a1e927c973015b8d7b] Message published successfully
+--- 24 08:01:38 -------
| (0:33) [swap uuid=50adb3d2-681e-4ce5-9abe-ec53e23552ed] Negotiated...
+--- 24 08:02:02 -------
| (0:57) [swap uuid=50adb3d2-681e-4ce5-9abe-ec53e23552ed] Negotiated...
+--- 24 08:02:26 -------
| (1:21) [swap uuid=50adb3d2-681e-4ce5-9abe-ec53e23552ed] Negotiated...
+--- 24 08:02:51 -------
| (1:45) [swap uuid=50adb3d2-681e-4ce5-9abe-ec53e23552ed] Negotiated...
+--- 24 08:03:15 -------
| (2:09) [swap uuid=50adb3d2-681e-4ce5-9abe-ec53e23552ed] Negotiated...
+--- 24 08:03:39 -------
| (2:33) [swap uuid=50adb3d2-681e-4ce5-9abe-ec53e23552ed] Negotiated...
+--- 24 08:04:03 -------
| (2:57) [swap uuid=50adb3d2-681e-4ce5-9abe-ec53e23552ed] Negotiated...
+--- 24 08:04:27 -------
| (3:21) [swap uuid=50adb3d2-681e-4ce5-9abe-ec53e23552ed] Negotiated...
24 08:04:35, kdf_walletconnect::connection_handler:81] INFO WalletConnect disconnected with message: Some("Disconnecting for load balancing reasons (4010)"). Attempting to reconnect...
24 08:04:36, kdf_walletconnect::connection_handler:85] INFO Reconnection process complete.
+--- 24 08:04:51 -------
| (3:45) [swap uuid=50adb3d2-681e-4ce5-9abe-ec53e23552ed] Negotiated...
+--- 24 08:05:15 -------
| (4:09) [swap uuid=50adb3d2-681e-4ce5-9abe-ec53e23552ed] Negotiated...
+--- 24 08:05:39 -------
| (4:33) [swap uuid=50adb3d2-681e-4ce5-9abe-ec53e23552ed] Negotiated...
+--- 24 08:06:03 -------
| (4:58) [swap uuid=50adb3d2-681e-4ce5-9abe-ec53e23552ed] Negotiated...
24 08:06:17, mm2_main::lp_swap::taker_swap:506] ERROR [swap uuid=50adb3d2-681e-4ce5-9abe-ec53e23552ed] TakerFeeSendFailed(SwapError { error: "taker_swap:1337] mm2src/coins/eth/wallet_connect.rs:263] wallet_connect:136] lib:630] WalletConnectError(TimeoutError)" })
· 2025-03-24 16:06:17 +0800 [swap uuid=50adb3d2-681e-4ce5-9abe-ec53e23552ed] Finished

message was sent to wallet successfully but did you approve the sign request from your wallet? @smk762

borngraced avatar Mar 24 '25 08:03 borngraced

Yes, approved both times. Third attempt progressed a little further (new WC session, same swap kickstarting), but then failed towards the end (after clicking confirm button in react wallet)

| (5:43) [swap uuid=dacf571a-0a19-4e4f-bf4a-1ccbb6ddce69] Maker payment validated and confirmed...
+--- 24 08:34:38 -------
| (6:07) [swap uuid=dacf571a-0a19-4e4f-bf4a-1ccbb6ddce69] Maker payment validated and confirmed...
24 08:34:54, mm2_main::lp_swap::taker_swap:506] ERROR [swap uuid=dacf571a-0a19-4e4f-bf4a-1ccbb6ddce69] TakerPaymentTransactionFailed(SwapError { error: "taker_swap:1717] mm2src/coins/eth/wallet_connect.rs:263] wallet_connect:136] lib:630] WalletConnectError(TimeoutError)" })
· 2025-03-24 16:34:54 +0800 [swap uuid=dacf571a-0a19-4e4f-bf4a-1ccbb6ddce69] Finished

smk762 avatar Mar 24 '25 08:03 smk762

wc_delete_session times out when session listed in wc_get_sessions response, but not show in https://whiskey-charlie.battlefield.earth/sessions (or equivalent). Ideally, the session list should be the same on both. If deleted via the react wallet, there seems to be no way to delete it from KDF, potentially leading to KDF methods failing attempting to get a response from sessions no longer active externally.

24 08:48:03, kdf_walletconnect:422] INFO [5967a1c960a7da4b6c8b6a21d5d83998a1f95e3e1027099986d055324fbfe9f4] Publishing message=Request(Request { id: MessageId(446158357474312), jsonrpc: "2.0", params: SessionDelete(SessionDeleteRequest { code: 6000, message: "User Disconnected" }) })
24 08:48:04, kdf_walletconnect:444] INFO [5967a1c960a7da4b6c8b6a21d5d83998a1f95e3e1027099986d055324fbfe9f4] Message published successfully

smk762 avatar Mar 24 '25 08:03 smk762

Thanks, session delete works like a charm now!

Using metamask app, was able to:

  • initate a session (params must be for eip155:1 only. Subsequent network switching is handled by app).
  • activate MATIC (must be selected as active network in app, otherwise ChainId not supported: eip155:137 error.
  • perform an atomic swap (two in app confirmations required)

Attempting to withdraw a token (USDC-PLG20) returned the following error:

{
    "mmrpc": "2.0",
    "error": "Signing error UnSuccessfulResponse Error: ErrorResponse { id: MessageId(446186146665731), jsonrpc: \"2.0\", error: ErrorData { code: 5000, message: \"{\\\"code\\\":-32004,\\\"message\\\":\\\"Method not supported.\\\"}\", data: None } }",
    "error_path": "eth_withdraw.wallet_connect.inbound_message",
    "error_trace": "eth_withdraw:336] wallet_connect:109] inbound_message:86]",
    "error_type": "SigningError",
    "error_data": "UnSuccessfulResponse Error: ErrorResponse { id: MessageId(446186146665731), jsonrpc: \"2.0\", error: ErrorData { code: 5000, message: \"{\\\"code\\\":-32004,\\\"message\\\":\\\"Method not supported.\\\"}\", data: None } }",
    "id": null
}

and in console logs:

25 14:57:15, kdf_walletconnect:422] INFO [e178803f58e0a73c04956712c155ade28351274cd766425d3a9c9f038455fa65] Publishing message=Request(Request { id: MessageId(446186146665731), jsonrpc: "2.0", params: SessionRequest(SessionRequestRequest { request: Request { method: "eth_signTransaction", params: Array [Object {"chainId": String("137"), "nonce": String("0x2"), "from": String("0x23f1828f7b994c082ff8e977e4ebe1390415f39c"), "gasLimit": String("0xb17f"), "value": String("0x0"), "data": String("0xa9059cbb000000000000000000000000ab95d01bc8214e4d993043e8ca1b68db2c94649800000000000000000000000000000000000000000000000000000000000186a0"), "gasPrice": String("0x63946c9e8"), "to": String("0xab95d01bc8214e4d993043e8ca1b68db2c946498")}], expiry: None }, chain_id: "eip155:137" }) })
25 14:57:15, kdf_walletconnect:444] INFO [e178803f58e0a73c04956712c155ade28351274cd766425d3a9c9f038455fa65] Message published successfully
25 14:57:18, kdf_walletconnect:294] INFO [e178803f58e0a73c04956712c155ade28351274cd766425d3a9c9f038455fa65] Inbound message payload={"id":446186146665731,"jsonrpc":"2.0","error":{"code":5000,"message":"{\"code\":-32004,\"message\":\"Method not supported.\"}"}}
25 14:57:18, mm2_main::rpc::dispatcher:128] ERROR RPC error response: eth_withdraw:336] wallet_connect:109] inbound_message:86] Signing error UnSuccessfulResponse Error: ErrorResponse { id: MessageId(446186146665731), jsonrpc: "2.0", error: ErrorData { code: 5000, message: "{\"code\":-32004,\"message\":\"Method not supported.\"}", data: None } }

A subsequent attempt to withdraw MATIC via metamask also failed with the same message.

Withdrawal attempts for MATIC/USDC-PLG20 using walletconnect (react example) also failed, but with a different error:

{
    "mmrpc": "2.0",
    "error": "Signing error UnSuccessfulResponse Error: ErrorResponse { id: MessageId(446186266251779), jsonrpc: \"2.0\", error: ErrorData { code: -32000, message: \"invalid transaction.chainId (argument=\\\"transaction\\\", value={\\\"chainId\\\":\\\"137\\\",\\\"nonce\\\":\\\"0x7\\\",\\\"gasLimit\\\":\\\"0xb0dc\\\",\\\"value\\\":\\\"0x0\\\",\\\"data\\\":\\\"0xa9059cbb000000000000000000000000ab95d01bc8214e4d993043e8ca1b68db2c94649800000000000000000000000000000000000000000000000000000000000186a0\\\",\\\"gasPrice\\\":\\\"0x63941e81d\\\",\\\"to\\\":\\\"0xab95d01bc8214e4d993043e8ca1b68db2c946498\\\"}, code=INVALID_ARGUMENT, version=transactions/5.7.0)\", data: None } }",
    "error_path": "eth_withdraw.wallet_connect.inbound_message",
    "error_trace": "eth_withdraw:336] wallet_connect:109] inbound_message:86]",
    "error_type": "SigningError",
    "error_data": "UnSuccessfulResponse Error: ErrorResponse { id: MessageId(446186266251779), jsonrpc: \"2.0\", error: ErrorData { code: -32000, message: \"invalid transaction.chainId (argument=\\\"transaction\\\", value={\\\"chainId\\\":\\\"137\\\",\\\"nonce\\\":\\\"0x7\\\",\\\"gasLimit\\\":\\\"0xb0dc\\\",\\\"value\\\":\\\"0x0\\\",\\\"data\\\":\\\"0xa9059cbb000000000000000000000000ab95d01bc8214e4d993043e8ca1b68db2c94649800000000000000000000000000000000000000000000000000000000000186a0\\\",\\\"gasPrice\\\":\\\"0x63941e81d\\\",\\\"to\\\":\\\"0xab95d01bc8214e4d993043e8ca1b68db2c946498\\\"}, code=INVALID_ARGUMENT, version=transactions/5.7.0)\", data: None } }",
    "id": null
}

With console errors:

25 15:05:02, kdf_walletconnect:422] INFO [0f9216d9204155198c4f0d28fee329de090fc89193d3733eb79d1ddb5aede403] Publishing message=Request(Request { id: MessageId(446186266251779), jsonrpc: "2.0", params: SessionRequest(SessionRequestRequest { request: Request { method: "eth_signTransaction", params: Array [Object {"chainId": String("137"), "nonce": String("0x7"), "from": String("0xa2eb1ea222163eb1c62d3bca74e99b57b3ac4743"), "gasLimit": String("0xb0dc"), "value": String("0x0"), "data": String("0xa9059cbb000000000000000000000000ab95d01bc8214e4d993043e8ca1b68db2c94649800000000000000000000000000000000000000000000000000000000000186a0"), "gasPrice": String("0x63941e81d"), "to": String("0xab95d01bc8214e4d993043e8ca1b68db2c946498")}], expiry: None }, chain_id: "eip155:137" }) })
25 15:05:02, kdf_walletconnect:444] INFO [0f9216d9204155198c4f0d28fee329de090fc89193d3733eb79d1ddb5aede403] Message published successfully
25 15:05:30, kdf_walletconnect:294] INFO [0f9216d9204155198c4f0d28fee329de090fc89193d3733eb79d1ddb5aede403] Inbound message payload={"id":446186266251779,"jsonrpc":"2.0","error":{"code":-32000,"message":"invalid transaction.chainId (argument=\"transaction\", value={\"chainId\":\"137\",\"nonce\":\"0x7\",\"gasLimit\":\"0xb0dc\",\"value\":\"0x0\",\"data\":\"0xa9059cbb000000000000000000000000ab95d01bc8214e4d993043e8ca1b68db2c94649800000000000000000000000000000000000000000000000000000000000186a0\",\"gasPrice\":\"0x63941e81d\",\"to\":\"0xab95d01bc8214e4d993043e8ca1b68db2c946498\"}, code=INVALID_ARGUMENT, version=transactions/5.7.0)"}}
25 15:05:30, mm2_main::rpc::dispatcher:128] ERROR RPC error response: eth_withdraw:336] wallet_connect:109] inbound_message:86] Signing error UnSuccessfulResponse Error: ErrorResponse { id: MessageId(446186266251779), jsonrpc: "2.0", error: ErrorData { code: -32000, message: "invalid transaction.chainId (argument=\"transaction\", value={\"chainId\":\"137\",\"nonce\":\"0x7\",\"gasLimit\":\"0xb0dc\",\"value\":\"0x0\",\"data\":\"0xa9059cbb000000000000000000000000ab95d01bc8214e4d993043e8ca1b68db2c94649800000000000000000000000000000000000000000000000000000000000186a0\",\"gasPrice\":\"0x63941e81d\",\"to\":\"0xab95d01bc8214e4d993043e8ca1b68db2c946498\"}, code=INVALID_ARGUMENT, version=transactions/5.7.0)", data: None } }

smk762 avatar Mar 25 '25 15:03 smk762

Thanks, session delete works like a charm now!

Using metamask app, was able to:

  • initate a session (params must be for eip155:1 only. Subsequent network switching is handled by app).
  • activate MATIC (must be selected as active network in app, otherwise ChainId not supported: eip155:137 error.
  • perform an atomic swap (two in app confirmations required)

Attempting to withdraw a token (USDC-PLG20) returned the following error:

{
    "mmrpc": "2.0",
    "error": "Signing error UnSuccessfulResponse Error: ErrorResponse { id: MessageId(446186146665731), jsonrpc: \"2.0\", error: ErrorData { code: 5000, message: \"{\\\"code\\\":-32004,\\\"message\\\":\\\"Method not supported.\\\"}\", data: None } }",
    "error_path": "eth_withdraw.wallet_connect.inbound_message",
    "error_trace": "eth_withdraw:336] wallet_connect:109] inbound_message:86]",
    "error_type": "SigningError",
    "error_data": "UnSuccessfulResponse Error: ErrorResponse { id: MessageId(446186146665731), jsonrpc: \"2.0\", error: ErrorData { code: 5000, message: \"{\\\"code\\\":-32004,\\\"message\\\":\\\"Method not supported.\\\"}\", data: None } }",
    "id": null
}

and in console logs:

25 14:57:15, kdf_walletconnect:422] INFO [e178803f58e0a73c04956712c155ade28351274cd766425d3a9c9f038455fa65] Publishing message=Request(Request { id: MessageId(446186146665731), jsonrpc: "2.0", params: SessionRequest(SessionRequestRequest { request: Request { method: "eth_signTransaction", params: Array [Object {"chainId": String("137"), "nonce": String("0x2"), "from": String("0x23f1828f7b994c082ff8e977e4ebe1390415f39c"), "gasLimit": String("0xb17f"), "value": String("0x0"), "data": String("0xa9059cbb000000000000000000000000ab95d01bc8214e4d993043e8ca1b68db2c94649800000000000000000000000000000000000000000000000000000000000186a0"), "gasPrice": String("0x63946c9e8"), "to": String("0xab95d01bc8214e4d993043e8ca1b68db2c946498")}], expiry: None }, chain_id: "eip155:137" }) })
25 14:57:15, kdf_walletconnect:444] INFO [e178803f58e0a73c04956712c155ade28351274cd766425d3a9c9f038455fa65] Message published successfully
25 14:57:18, kdf_walletconnect:294] INFO [e178803f58e0a73c04956712c155ade28351274cd766425d3a9c9f038455fa65] Inbound message payload={"id":446186146665731,"jsonrpc":"2.0","error":{"code":5000,"message":"{\"code\":-32004,\"message\":\"Method not supported.\"}"}}
25 14:57:18, mm2_main::rpc::dispatcher:128] ERROR RPC error response: eth_withdraw:336] wallet_connect:109] inbound_message:86] Signing error UnSuccessfulResponse Error: ErrorResponse { id: MessageId(446186146665731), jsonrpc: "2.0", error: ErrorData { code: 5000, message: "{\"code\":-32004,\"message\":\"Method not supported.\"}", data: None } }

A subsequent attempt to withdraw MATIC via metamask also failed with the same message.

Withdrawal attempts for MATIC/USDC-PLG20 using walletconnect (react example) also failed, but with a different error:

{
    "mmrpc": "2.0",
    "error": "Signing error UnSuccessfulResponse Error: ErrorResponse { id: MessageId(446186266251779), jsonrpc: \"2.0\", error: ErrorData { code: -32000, message: \"invalid transaction.chainId (argument=\\\"transaction\\\", value={\\\"chainId\\\":\\\"137\\\",\\\"nonce\\\":\\\"0x7\\\",\\\"gasLimit\\\":\\\"0xb0dc\\\",\\\"value\\\":\\\"0x0\\\",\\\"data\\\":\\\"0xa9059cbb000000000000000000000000ab95d01bc8214e4d993043e8ca1b68db2c94649800000000000000000000000000000000000000000000000000000000000186a0\\\",\\\"gasPrice\\\":\\\"0x63941e81d\\\",\\\"to\\\":\\\"0xab95d01bc8214e4d993043e8ca1b68db2c946498\\\"}, code=INVALID_ARGUMENT, version=transactions/5.7.0)\", data: None } }",
    "error_path": "eth_withdraw.wallet_connect.inbound_message",
    "error_trace": "eth_withdraw:336] wallet_connect:109] inbound_message:86]",
    "error_type": "SigningError",
    "error_data": "UnSuccessfulResponse Error: ErrorResponse { id: MessageId(446186266251779), jsonrpc: \"2.0\", error: ErrorData { code: -32000, message: \"invalid transaction.chainId (argument=\\\"transaction\\\", value={\\\"chainId\\\":\\\"137\\\",\\\"nonce\\\":\\\"0x7\\\",\\\"gasLimit\\\":\\\"0xb0dc\\\",\\\"value\\\":\\\"0x0\\\",\\\"data\\\":\\\"0xa9059cbb000000000000000000000000ab95d01bc8214e4d993043e8ca1b68db2c94649800000000000000000000000000000000000000000000000000000000000186a0\\\",\\\"gasPrice\\\":\\\"0x63941e81d\\\",\\\"to\\\":\\\"0xab95d01bc8214e4d993043e8ca1b68db2c946498\\\"}, code=INVALID_ARGUMENT, version=transactions/5.7.0)\", data: None } }",
    "id": null
}

With console errors:

25 15:05:02, kdf_walletconnect:422] INFO [0f9216d9204155198c4f0d28fee329de090fc89193d3733eb79d1ddb5aede403] Publishing message=Request(Request { id: MessageId(446186266251779), jsonrpc: "2.0", params: SessionRequest(SessionRequestRequest { request: Request { method: "eth_signTransaction", params: Array [Object {"chainId": String("137"), "nonce": String("0x7"), "from": String("0xa2eb1ea222163eb1c62d3bca74e99b57b3ac4743"), "gasLimit": String("0xb0dc"), "value": String("0x0"), "data": String("0xa9059cbb000000000000000000000000ab95d01bc8214e4d993043e8ca1b68db2c94649800000000000000000000000000000000000000000000000000000000000186a0"), "gasPrice": String("0x63941e81d"), "to": String("0xab95d01bc8214e4d993043e8ca1b68db2c946498")}], expiry: None }, chain_id: "eip155:137" }) })
25 15:05:02, kdf_walletconnect:444] INFO [0f9216d9204155198c4f0d28fee329de090fc89193d3733eb79d1ddb5aede403] Message published successfully
25 15:05:30, kdf_walletconnect:294] INFO [0f9216d9204155198c4f0d28fee329de090fc89193d3733eb79d1ddb5aede403] Inbound message payload={"id":446186266251779,"jsonrpc":"2.0","error":{"code":-32000,"message":"invalid transaction.chainId (argument=\"transaction\", value={\"chainId\":\"137\",\"nonce\":\"0x7\",\"gasLimit\":\"0xb0dc\",\"value\":\"0x0\",\"data\":\"0xa9059cbb000000000000000000000000ab95d01bc8214e4d993043e8ca1b68db2c94649800000000000000000000000000000000000000000000000000000000000186a0\",\"gasPrice\":\"0x63941e81d\",\"to\":\"0xab95d01bc8214e4d993043e8ca1b68db2c946498\"}, code=INVALID_ARGUMENT, version=transactions/5.7.0)"}}
25 15:05:30, mm2_main::rpc::dispatcher:128] ERROR RPC error response: eth_withdraw:336] wallet_connect:109] inbound_message:86] Signing error UnSuccessfulResponse Error: ErrorResponse { id: MessageId(446186266251779), jsonrpc: "2.0", error: ErrorData { code: -32000, message: "invalid transaction.chainId (argument=\"transaction\", value={\"chainId\":\"137\",\"nonce\":\"0x7\",\"gasLimit\":\"0xb0dc\",\"value\":\"0x0\",\"data\":\"0xa9059cbb000000000000000000000000ab95d01bc8214e4d993043e8ca1b68db2c94649800000000000000000000000000000000000000000000000000000000000186a0\",\"gasPrice\":\"0x63941e81d\",\"to\":\"0xab95d01bc8214e4d993043e8ca1b68db2c946498\"}, code=INVALID_ARGUMENT, version=transactions/5.7.0)", data: None } }

Metamask doesn't allow eth_signTransaction for security reasons instead we can only use eth_sendTransaction for initiating txs. The given transaction will be signed and broadcasted by Metamask.

So if you want to withdraw with Metamask connected set the broadcast option like this

{
	"userpass": "password",
	"method": "withdraw",
	"mmrpc": "2.0",
	"params": {
		"to": "0x4A434d26fC9cACd44AaCEe20aedC70023E91ad80",
		"coin": "ETH",
		"amount": "0.001",
		"broadcast": true
	}
}

Withdrawal attempts for MATIC/USDC-PLG20 using walletconnect (react example) also failed, but with a different error:

This was fixed already.

borngraced avatar Mar 25 '25 15:03 borngraced

I was able to send a tx via metamask with the broadcast: true param, tho for token transfers it does not appear to be functioning as expected.

Req:

{
    "userpass": "{{userpass}}",
    "mmrpc": "2.0",
    "method": "withdraw",
    "params": {
        "coin": "USDC-PLG20",
        "to": "0xaB95D01Bc8214E4D993043E8Ca1B68dB2c946498",
        "amount": 0.1,
        "broadcast": true
    }

}

Resp:

{
    "mmrpc": "2.0",
    "result": {
        "tx_hex": "02f8b281890285067fb0cc4285067fb0cc4282550294ab95d01bc8214e4d993043e8ca1b68db2c94649880b844a9059cbb000000000000000000000000ab95d01bc8214e4d993043e8ca1b68db2c94649800000000000000000000000000000000000000000000000000000000000186a0c001a0e5d3aeaae6dd45af9c12a06b6ed22d9055e22bcd78268d0656faa3d5584d4983a05187bb0df209626cd8c510c39c782d5b3f9dd34c016ad525929924224323399d",
        "tx_hash": "0420c781d60ab514d975688b548e18506e43d9491f5800308e276e34dd575c4f",
        "from": [
            "0x23f1828F7B994C082Ff8e977e4ebE1390415F39c"
        ],
        "to": [
            "0xaB95D01Bc8214E4D993043E8Ca1B68dB2c946498"
        ],
        "total_amount": "0.1",
        "spent_by_me": "0.1",
        "received_by_me": "0",
        "my_balance_change": "-0.1",
        "block_height": 0,
        "timestamp": 1742952340,
        "fee_details": {
            "type": "Eth",
            "coin": "MATIC",
            "gas": 45276,
            "gas_price": "0.000000027912096834",
            "max_fee_per_gas": null,
            "max_priority_fee_per_gas": null,
            "total_fee": "0.001263748096256184"
        },
        "coin": "USDC-PLG20",
        "internal_id": "",
        "transaction_type": "StandardTransfer",
        "memo": null
    },
    "id": null
}

Console logs:

26 01:24:36, kdf_walletconnect:422] INFO [8c1d30dd2ba975329b03b390ff5540681f374a9ac5bea1afa3900242006c28e8] Publishing message=Request(Request { id: MessageId(446195782900485), jsonrpc: "2.0", params: SessionRequest(SessionRequestRequest { request: Request { method: "personal_sign", params: Array [String("0x41757468656e7469636174652077697468204b6f6d6f64656669"), String("0x23f1828f7b994c082ff8e977e4ebe1390415f39c")], expiry: None }, chain_id: "eip155:137" }) })
26 01:24:37, kdf_walletconnect:444] INFO [8c1d30dd2ba975329b03b390ff5540681f374a9ac5bea1afa3900242006c28e8] Message published successfully
26 01:24:46, kdf_walletconnect:294] INFO [8c1d30dd2ba975329b03b390ff5540681f374a9ac5bea1afa3900242006c28e8] Inbound message payload={"id":446195782900485,"jsonrpc":"2.0","result":"0x9ee9cb85ebb0df249a1389c6a87d90286a7732ddd357ec74d97e63ef4bf17625293f4f79276385b3a03906983eeb9f2e5c4e8e78997d6604c72560a72b7281151c"}


26 01:25:11, kdf_walletconnect:422] INFO [8c1d30dd2ba975329b03b390ff5540681f374a9ac5bea1afa3900242006c28e8] Publishing message=Request(Request { id: MessageId(446195791840774), jsonrpc: "2.0", params: SessionRequest(SessionRequestRequest { request: Request { method: "eth_sendTransaction", params: Array [Object {"chainId": Number(137), "nonce": String("0x2"), "from": String("0x23f1828f7b994c082ff8e977e4ebe1390415f39c"), "gasLimit": String("0xb0dc"), "value": String("0x0"), "data": String("0xa9059cbb000000000000000000000000ab95d01bc8214e4d993043e8ca1b68db2c94649800000000000000000000000000000000000000000000000000000000000186a0"), "gasPrice": String("0x67fb0cc42"), "to": String("0xab95d01bc8214e4d993043e8ca1b68db2c946498")}], expiry: None }, chain_id: "eip155:137" }) })
26 01:25:12, kdf_walletconnect:444] INFO [8c1d30dd2ba975329b03b390ff5540681f374a9ac5bea1afa3900242006c28e8] Message published successfully
26 01:25:35, kdf_walletconnect:294] INFO [8c1d30dd2ba975329b03b390ff5540681f374a9ac5bea1afa3900242006c28e8] Inbound message payload={"id":446195791840774,"jsonrpc":"2.0","result":"0x0420c781d60ab514d975688b548e18506e43d9491f5800308e276e34dd575c4f"}

Explorer links:

  • https://polygonscan.com/tx/0x0420c781d60ab514d975688b548e18506e43d9491f5800308e276e34dd575c4f
  • https://polygonscan.com/address/0x23f1828f7b994c082ff8e977e4ebe1390415f39c#tokentxns

A tx to pay gas for the token transfer looks like it happened, but there is no token transfer recorded on chain. Incidentally, when confirming tx in metamask app, it showed amount in sats - so token xfer might have been rejected due to lack of funds.

A non-token transfer of MATIC itself completed as expected:

https://polygonscan.com/tx/0x062fc218a48a4df7715024bdc8614e82aed9b889c2768cae5a188ec546da0fa0

26 01:38:30, kdf_walletconnect:422] INFO [8c1d30dd2ba975329b03b390ff5540681f374a9ac5bea1afa3900242006c28e8] Publishing message=Request(Request { id: MessageId(446195996354055), jsonrpc: "2.0", params: SessionRequest(SessionRequestRequest { request: Request { method: "eth_sendTransaction", params: Array [Object {"chainId": Number(137), "nonce": String("0x3"), "from": String("0x23f1828f7b994c082ff8e977e4ebe1390415f39c"), "gasLimit": String("0x5208"), "value": String("0x1aa535d3d0c0000"), "data": String("0x"), "gasPrice": String("0x66a2ae5e0"), "to": String("0xab95d01bc8214e4d993043e8ca1b68db2c946498")}], expiry: None }, chain_id: "eip155:137" }) })
26 01:38:31, kdf_walletconnect:444] INFO [8c1d30dd2ba975329b03b390ff5540681f374a9ac5bea1afa3900242006c28e8] Message published successfully
26 01:38:58, kdf_walletconnect:294] INFO [8c1d30dd2ba975329b03b390ff5540681f374a9ac5bea1afa3900242006c28e8] Inbound message payload={"id":446195996354055,"jsonrpc":"2.0","result":"0x062fc218a48a4df7715024bdc8614e82aed9b889c2768cae5a188ec546da0fa0"}

Retesting withdrawal via WC react wallet, using "broadcast": true:

  • MATIC transfer completed on approval without issue https://polygonscan.com/tx/0xa1dd11c9c1240e24e162e22bf8f45f26b94ca6c6c00f4948eb1cf0553a6d5efb
  • USDC_PLG20 transfer not seen on explorer (tho gas tx is there), same as with metamask https://polygonscan.com/tx/0x9ac76247b0588a95ab24c6dc326b453cb01721e5ef242eb26af2118e7e54f00d

Console logs:

26 01:45:54, kdf_walletconnect:422] INFO [15b3efcbf3e596fbe154846dd6b8e904d6ec8e25d23ac889057b4505e4eb4c68] Publishing message=Request(Request { id: MessageId(446196109965313), jsonrpc: "2.0", params: SessionRequest(SessionRequestRequest { request: Request { method: "eth_sendTransaction", params: Array [Object {"chainId": Number(137), "nonce": String("0x7"), "from": String("0xa2eb1ea222163eb1c62d3bca74e99b57b3ac4743"), "gasLimit": String("0x5208"), "value": String("0x11c37937e080000"), "data": String("0x"), "gasPrice": String("0x668911722"), "to": String("0xab95d01bc8214e4d993043e8ca1b68db2c946498")}], expiry: None }, chain_id: "eip155:137" }) })
26 01:45:55, kdf_walletconnect:444] INFO [15b3efcbf3e596fbe154846dd6b8e904d6ec8e25d23ac889057b4505e4eb4c68] Message published successfully
26 01:46:19, kdf_walletconnect:294] INFO [15b3efcbf3e596fbe154846dd6b8e904d6ec8e25d23ac889057b4505e4eb4c68] Inbound message payload={"id":446196109965313,"jsonrpc":"2.0","result":"0xa1dd11c9c1240e24e162e22bf8f45f26b94ca6c6c00f4948eb1cf0553a6d5efb"}

26 01:48:15, kdf_walletconnect:422] INFO [15b3efcbf3e596fbe154846dd6b8e904d6ec8e25d23ac889057b4505e4eb4c68] Publishing message=Request(Request { id: MessageId(446196146043906), jsonrpc: "2.0", params: SessionRequest(SessionRequestRequest { request: Request { method: "eth_sendTransaction", params: Array [Object {"chainId": Number(137), "nonce": String("0x8"), "from": String("0xa2eb1ea222163eb1c62d3bca74e99b57b3ac4743"), "gasLimit": String("0xb0dc"), "value": String("0x0"), "data": String("0xa9059cbb000000000000000000000000ab95d01bc8214e4d993043e8ca1b68db2c9464980000000000000000000000000000000000000000000000000000000000013880"), "gasPrice": String("0x66851e002"), "to": String("0xab95d01bc8214e4d993043e8ca1b68db2c946498")}], expiry: None }, chain_id: "eip155:137" }) })
26 01:48:15, kdf_walletconnect:444] INFO [15b3efcbf3e596fbe154846dd6b8e904d6ec8e25d23ac889057b4505e4eb4c68] Message published successfully

26 01:48:35, kdf_walletconnect:294] INFO [15b3efcbf3e596fbe154846dd6b8e904d6ec8e25d23ac889057b4505e4eb4c68] Inbound message payload={"id":446196146043906,"jsonrpc":"2.0","result":"0x9ac76247b0588a95ab24c6dc326b453cb01721e5ef242eb26af2118e7e54f00d"}

smk762 avatar Mar 26 '25 01:03 smk762

USDC-PLG20 / KMD swap completed successfully with React walletconnect example.

Swap uuid: c20c7d29-838a-4276-aecb-7a2415ea9e21

Transactions

Event Block Time
Taker dex fee / Taker pays dex fee in USDC-PLG20 69512019 Mar-26-2025 06:11:07 AM UTC
Maker payment / Maker funds swap address with KMD 4367766 Mar-26-2025 06:18:21 AM UTC
Taker approves contract to spend USDC-PLG20 69512241 Mar-26-2025 06:18:59 AM UTC
Taker payment / Taker funds swap contract with USDC-PLG20 69512273 Mar-26-2025 06:20:07 AM UTC
Taker payment spent / Maker receives USDC-PLG20 69512300 Mar-26-2025 06:21:03 AM UTC
Maker payment spent / Taker receives KMD 4367770 Mar-26-2025 06:23:17 AM UTC

smk762 avatar Mar 26 '25 07:03 smk762

In metamask, initate a session (params must be for eip155:1 only. Subsequent network switching is handled by app).

This is incorrect: For metamask, only one EIP155 chain ID can be used in wc_new_connection params, and it must be the EIP155 chain ID of the network currently active in app. Subsequent chain switching is handled by the app.

smk762 avatar Mar 26 '25 07:03 smk762

Logs for failed Metamask swap (failed due to low battery / screen sleep)

· 2025-03-26 15:53:54 +0800 [] lp_ordermatch:3302] Entering the taker_swap_loop KMD/USDC-PLG20 with uuid: 6ed8dcfb-d60d-4b9b-87ad-e7640fb141bc
· 2025-03-26 15:54:09 +0800 [] taker_swap:831] Taker swap 6ed8dcfb-d60d-4b9b-87ad-e7640fb141bc has successfully started
+--- 26 07:54:10 -------
| (0:00) [swap uuid=6ed8dcfb-d60d-4b9b-87ad-e7640fb141bc] Started...
26 07:54:12, coins::eth::wallet_connect:246] INFO target: WalletConnect: sign-and-send, get_gas_price…
26 07:54:16, coins::eth::wallet_connect:265] INFO target: WalletConnect: sign-and-send, signing and sending tx
26 07:54:16, kdf_walletconnect:422] INFO [87b9cf9dd31f574e160b961937557114cba5e7132b02acbed8e8f9a4a3c6c6c3] Publishing message=Request(Request { id: MessageId(446201768089348), jsonrpc: "2.0", params: SessionRequest(SessionRequestRequest { request: Request { method: "eth_sendTransaction", params: Array [Object {"chainId": Number(137), "nonce": String("0x4"), "from": String("0x23f1828f7b994c082ff8e977e4ebe1390415f39c"), "gasLimit": String("0xd6d8"), "value": String("0x0"), "data": String("0xa9059cbb000000000000000000000000d8997941dd1346e9231118d5685d866294f59e5b0000000000000000000000000000000000000000000000000000000000000073"), "gasPrice": String("0x609447e17"), "to": String("0x3c499c542cef5e3811e1192ce70d8cc03d5c3359")}], expiry: None }, chain_id: "eip155:137" }) })
26 07:54:17, kdf_walletconnect:444] INFO [87b9cf9dd31f574e160b961937557114cba5e7132b02acbed8e8f9a4a3c6c6c3] Message published successfully
+--- 26 07:54:18 -------
| (0:08) [swap uuid=6ed8dcfb-d60d-4b9b-87ad-e7640fb141bc] Negotiated...

APPROVED (approval request shows 0.00012 USDC; correct units and ticker)

26 07:55:08, kdf_walletconnect:294] INFO [87b9cf9dd31f574e160b961937557114cba5e7132b02acbed8e8f9a4a3c6c6c3] Inbound message payload={"id":446201768089348,"jsonrpc":"2.0","result":"0xff27d8f9018588d7c451c52603ca48016606533bbf1323a4a83d355b4af0a3e4"}
26 07:55:16, kdf_walletconnect::connection_handler:81] INFO WalletConnect disconnected with message: Some("Disconnecting for load balancing reasons (4010)"). Attempting to reconnect...
26 07:55:18, kdf_walletconnect::connection_handler:85] INFO Reconnection process complete.
26 07:55:20, mm2_main::lp_swap::taker_swap:1343] INFO Taker fee tx hash ff27d8f9018588d7c451c52603ca48016606533bbf1323a4a83d355b4af0a3e4
+--- 26 07:55:20 -------
| (1:11) [swap uuid=6ed8dcfb-d60d-4b9b-87ad-e7640fb141bc] Taker fee sent...
26 07:55:21, mm2_main::lp_swap::taker_swap:1427] INFO Got maker payment 7bda1b6f78aacfdccf3ca2e62deaa0bfd466f916ec3ddc26f7df6cec1feba2fc
26 07:55:21, mm2_main::lp_swap::taker_swap:1440] INFO Before wait confirm
26 07:55:21, coins::utxo::rpc_clients:130] INFO Waiting for tx 7bda1b6f78aacfdccf3ca2e62deaa0bfd466f916ec3ddc26f7df6cec1feba2fc confirmations, now 0, required 1, requires_notarization false

| (1:43) [swap uuid=6ed8dcfb-d60d-4b9b-87ad-e7640fb141bc] Maker payment wait confirm started...
26 07:56:08, mm2_main::lp_swap::taker_swap:1458] INFO After wait confirm
+--- 26 07:56:09 -------
| (1:59) [swap uuid=6ed8dcfb-d60d-4b9b-87ad-e7640fb141bc] Maker payment validated and confirmed...
26 07:56:20, coins::eth::wallet_connect:246] INFO target: WalletConnect: sign-and-send, get_gas_price…
26 07:56:24, coins::eth::wallet_connect:265] INFO target: WalletConnect: sign-and-send, signing and sending tx
26 07:56:24, kdf_walletconnect:422] INFO [87b9cf9dd31f574e160b961937557114cba5e7132b02acbed8e8f9a4a3c6c6c3] Publishing message=Request(Request { id: MessageId(446201800816133), jsonrpc: "2.0", params: SessionRequest(SessionRequestRequest { request: Request { method: "eth_sendTransaction", params: Array [Object {"chainId": Number(137), "nonce": String("0x5"), "from": String("0x23f1828f7b994c082ff8e977e4ebe1390415f39c"), "gasLimit": String("0xdb67"), "value": String("0x0"), "data": String("0x095ea7b30000000000000000000000009130b257d37a52e52f21054c4da3450c72f595ceffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), "gasPrice": String("0x609447e2b"), "to": String("0x3c499c542cef5e3811e1192ce70d8cc03d5c3359")}], expiry: None }, chain_id: "eip155:137" }) })
26 07:56:24, kdf_walletconnect:444] INFO [87b9cf9dd31f574e160b961937557114cba5e7132b02acbed8e8f9a4a3c6c6c3] Message published successfully
+--- 26 07:56:33 -------

APPROVED: Spending cap in approval set to very high number (higher than balance or trade value)!

| (1:43) [swap uuid=6ed8dcfb-d60d-4b9b-87ad-e7640fb141bc] Maker payment wait confirm started...
26 07:56:08, mm2_main::lp_swap::taker_swap:1458] INFO After wait confirm
+--- 26 07:56:09 -------
| (1:59) [swap uuid=6ed8dcfb-d60d-4b9b-87ad-e7640fb141bc] Maker payment validated and confirmed...
26 07:56:20, coins::eth::wallet_connect:246] INFO target: WalletConnect: sign-and-send, get_gas_price…
26 07:56:24, coins::eth::wallet_connect:265] INFO target: WalletConnect: sign-and-send, signing and sending tx
26 07:56:24, kdf_walletconnect:422] INFO [87b9cf9dd31f574e160b961937557114cba5e7132b02acbed8e8f9a4a3c6c6c3] Publishing message=Request(Request { id: MessageId(446201800816133), jsonrpc: "2.0", params: SessionRequest(SessionRequestRequest { request: Request { method: "eth_sendTransaction", params: Array [Object {"chainId": Number(137), "nonce": String("0x5"), "from": String("0x23f1828f7b994c082ff8e977e4ebe1390415f39c"), "gasLimit": String("0xdb67"), "value": String("0x0"), "data": String("0x095ea7b30000000000000000000000009130b257d37a52e52f21054c4da3450c72f595ceffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), "gasPrice": String("0x609447e2b"), "to": String("0x3c499c542cef5e3811e1192ce70d8cc03d5c3359")}], expiry: None }, chain_id: "eip155:137" }) })
26 07:56:24, kdf_walletconnect:444] INFO [87b9cf9dd31f574e160b961937557114cba5e7132b02acbed8e8f9a4a3c6c6c3] Message published successfully
+--- 26 07:56:33 -------

+--- 26 07:58:57 -------
| (4:47) [swap uuid=6ed8dcfb-d60d-4b9b-87ad-e7640fb141bc] Maker payment validated and confirmed...
26 07:58:58, coins::eth::wallet_connect:246] INFO target: WalletConnect: sign-and-send, get_gas_price…
26 07:59:02, coins::eth::wallet_connect:265] INFO target: WalletConnect: sign-and-send, signing and sending tx
26 07:59:02, kdf_walletconnect:422] INFO [87b9cf9dd31f574e160b961937557114cba5e7132b02acbed8e8f9a4a3c6c6c3] Publishing message=Request(Request { id: MessageId(446201841352710), jsonrpc: "2.0", params: SessionRequest(SessionRequestRequest { request: Request { method: "eth_sendTransaction", params: Array [Object {"chainId": Number(137), "nonce": String("0x6"), "from": String("0x23f1828f7b994c082ff8e977e4ebe1390415f39c"), "gasLimit": String("0x1adb0"), "value": String("0x0"), "data": String("0x9b415b2a3db0f7ad196da079bf850c150090add6baa16a597872bc6e6683b4e58dfba28d00000000000000000000000000000000000000000000000000000000000186a00000000000000000000000003c499c542cef5e3811e1192ce70d8cc03d5c3359000000000000000000000000229e3418c6477073a7cb3cc8b0faf4c4a8843bcb4e2bbc465de822e3763dca8c8e20b47c54a136ca0000000000000000000000000000000000000000000000000000000000000000000000000000000067e3d118"), "gasPrice": String("0x609447e42"), "to": String("0x9130b257d37a52e52f21054c4da3450c72f595ce")}], expiry: None }, chain_id: "eip155:137" }) })
26 07:59:03, kdf_walletconnect:444] INFO [87b9cf9dd31f574e160b961937557114cba5e7132b02acbed8e8f9a4a3c6c6c3] Message published successfully
+--- 26 07:59:21 -------
| (5:12) [swap uuid=6ed8dcfb-d60d-4b9b-87ad-e7640fb141bc] Maker payment validated and confirmed...

NOT APPROVED: phone screen went dark, and approval pop up disappeared when re-activated. Dont do this on 5% battery kids.

| (4:47) [swap uuid=6ed8dcfb-d60d-4b9b-87ad-e7640fb141bc] Maker payment validated and confirmed...
26 07:58:58, coins::eth::wallet_connect:246] INFO target: WalletConnect: sign-and-send, get_gas_price…
26 07:59:02, coins::eth::wallet_connect:265] INFO target: WalletConnect: sign-and-send, signing and sending tx
26 07:59:02, kdf_walletconnect:422] INFO [87b9cf9dd31f574e160b961937557114cba5e7132b02acbed8e8f9a4a3c6c6c3] Publishing message=Request(Request { id: MessageId(446201841352710), jsonrpc: "2.0", params: SessionRequest(SessionRequestRequest { request: Request { method: "eth_sendTransaction", params: Array [Object {"chainId": Number(137), "nonce": String("0x6"), "from": String("0x23f1828f7b994c082ff8e977e4ebe1390415f39c"), "gasLimit": String("0x1adb0"), "value": String("0x0"), "data": String("0x9b415b2a3db0f7ad196da079bf850c150090add6baa16a597872bc6e6683b4e58dfba28d00000000000000000000000000000000000000000000000000000000000186a00000000000000000000000003c499c542cef5e3811e1192ce70d8cc03d5c3359000000000000000000000000229e3418c6477073a7cb3cc8b0faf4c4a8843bcb4e2bbc465de822e3763dca8c8e20b47c54a136ca0000000000000000000000000000000000000000000000000000000000000000000000000000000067e3d118"), "gasPrice": String("0x609447e42"), "to": String("0x9130b257d37a52e52f21054c4da3450c72f595ce")}], expiry: None }, chain_id: "eip155:137" }) })
26 07:59:03, kdf_walletconnect:444] INFO [87b9cf9dd31f574e160b961937557114cba5e7132b02acbed8e8f9a4a3c6c6c3] Message published successfully
+--- 26 07:59:21 -------
| (5:12) [swap uuid=6ed8dcfb-d60d-4b9b-87ad-e7640fb141bc] Maker payment validated and confirmed...
26 07:59:42, kdf_walletconnect:294] INFO [87b9cf9dd31f574e160b961937557114cba5e7132b02acbed8e8f9a4a3c6c6c3] Inbound message payload={"id":446201841352710,"jsonrpc":"2.0","error":{"code":5000,"message":"MetaMask Tx Signature: User denied transaction signature."}}
26 07:59:42, mm2_main::lp_swap::taker_swap:506] ERROR [swap uuid=6ed8dcfb-d60d-4b9b-87ad-e7640fb141bc] TakerPaymentTransactionFailed(SwapError { error: "taker_swap:1717] mm2src/coins/eth/wallet_connect.rs:266] wallet_connect:138] inbound_message:86] WalletConnectError(UnSuccessfulResponse(\"ErrorResponse { id: MessageId(446201841352710), jsonrpc: \\\"2.0\\\", error: ErrorData { code: 5000, message: \\\"MetaMask Tx Signature: User denied transaction signature.\\\", data: None } }\"))" })
+--- 26 07:59:42 -------
| (5:33) [swap uuid=6ed8dcfb-d60d-4b9b-87ad-e7640fb141bc] Finished
· 2025-03-26 15:59:43 +0800 [swap uuid=6ed8dcfb-d60d-4b9b-87ad-e7640fb141bc] Finished

Worth noting here that unlike the USDC-PLG20 withdraw request approval confirmation pop up, in this case the units and coin ticker are correct.

In terms of UX, the approval which concerns a "spending cap" of a huge number may be met with suspicion.

A second metamask swap attempt (with phone plugged into charger) was successful (uuid: 045c1e43-4082-4bdd-bf2d-bb9027adcd5a)

smk762 avatar Mar 26 '25 08:03 smk762

USDC-PLG20 withdraw still fails. When using params:

{
    "userpass": "{{userpass}}",
    "mmrpc": "2.0",
    "method": "withdraw",
    "params": {
        "coin": "USDC-PLG20",
        "to": "0xaB95D01Bc8214E4D993043E8Ca1B68dB2c946498",
        "amount": 0.762,
        "broadcast": true
    }
}

Metamask app approval pop up requests confirmation for 762000 ERC20 (wrong units, wrong ticker).

App implies successful transfer, and logs show no errors:

26 08:10:13, kdf_walletconnect:422] INFO [87b9cf9dd31f574e160b961937557114cba5e7132b02acbed8e8f9a4a3c6c6c3] Publishing message=Request(Request { id: MessageId(446202013025801), jsonrpc: "2.0", params: SessionRequest(SessionRequestRequest { request: Request { method: "eth_sendTransaction", params: Array [Object {"chainId": Number(137), "nonce": String("0x8"), "from": String("0x23f1828f7b994c082ff8e977e4ebe1390415f39c"), "gasLimit": String("0xb0dc"), "value": String("0x0"), "data": String("0xa9059cbb000000000000000000000000ab95d01bc8214e4d993043e8ca1b68db2c94649800000000000000000000000000000000000000000000000000000000000ba090"), "gasPrice": String("0x609447e21"), "to": String("0xab95d01bc8214e4d993043e8ca1b68db2c946498")}], expiry: None }, chain_id: "eip155:137" }) })
26 08:10:13, kdf_walletconnect:444] INFO [87b9cf9dd31f574e160b961937557114cba5e7132b02acbed8e8f9a4a3c6c6c3] Message published successfully
26 08:12:04, kdf_walletconnect:294] INFO [87b9cf9dd31f574e160b961937557114cba5e7132b02acbed8e8f9a4a3c6c6c3] Inbound message payload={"id":446202013025801,"jsonrpc":"2.0","result":"0x53ab39f4c7146a9bd72753cdcd32df4e91a40c73dfd74dcb6ec48d3dedcac6fe"}

Reviewing transaction on block explorer shows no movement of USDC-PLG20: https://polygonscan.com/tx/0x53ab39f4c7146a9bd72753cdcd32df4e91a40c73dfd74dcb6ec48d3dedcac6fe


A withdrawal through metamask for MATIC (POL) showed the correct unit and ticker. and completed successfully.

26 08:16:09, kdf_walletconnect:422] INFO [87b9cf9dd31f574e160b961937557114cba5e7132b02acbed8e8f9a4a3c6c6c3] Publishing message=Request(Request { id: MessageId(446202104113418), jsonrpc: "2.0", params: SessionRequest(SessionRequestRequest { request: Request { method: "eth_sendTransaction", params: Array [Object {"chainId": Number(137), "nonce": String("0x9"), "from": String("0x23f1828f7b994c082ff8e977e4ebe1390415f39c"), "gasLimit": String("0x5208"), "value": String("0x16345785d8a0000"), "data": String("0x"), "gasPrice": String("0x6076c8f7b"), "to": String("0xab95d01bc8214e4d993043e8ca1b68db2c946498")}], expiry: None }, chain_id: "eip155:137" }) })
26 08:16:09, kdf_walletconnect:444] INFO [87b9cf9dd31f574e160b961937557114cba5e7132b02acbed8e8f9a4a3c6c6c3] Message published successfully
26 08:16:46, kdf_walletconnect:294] INFO [87b9cf9dd31f574e160b961937557114cba5e7132b02acbed8e8f9a4a3c6c6c3] Inbound message payload={"id":446202104113418,"jsonrpc":"2.0","result":"0xf8a2c8152ae9be8b860df859a69dd1506729b19e78f93bba48c62c9f1d0a504c"}

https://polygonscan.com/tx/0xf8a2c8152ae9be8b860df859a69dd1506729b19e78f93bba48c62c9f1d0a504c

smk762 avatar Mar 26 '25 08:03 smk762

Confirmed token withdrawals now functional on WC and metamask. Only tendermint testing remains

smk762 avatar Mar 26 '25 13:03 smk762

Testing tendermint via Keplr mobile wallet:

  • app accepted connection, and was approved:
{
	"method": "wc_new_connection",
	"userpass": "{{userpass}}",
	"mmrpc": "2.0",
	"params": {
		"required_namespaces": {
			"cosmos": {
				"chains": [
					"cosmos:cosmoshub-4"
				],
				"methods": [
					"cosmos_signDirect",
					"cosmos_signAmino",
					"cosmos_getAccounts"
				],
				"events": []
			}
		}
	}
}

Get Sessions shows an unexpected null value under chains


            {
                "topic": "5845bd43bcd151214a9fdc114d09bd8db495dec59994b16dc493faa922c87f14",
                "metadata": {
                    "description": "Your Wallet for the Interchain",
                    "url": "https://www.keplr.app",
                    "icons": [
                        "https://asset-icons.s3.us-west-2.amazonaws.com/keplr_512.png"
                    ],
                    "name": "Keplr"
                },
                "pairing_topic": "31f60345f4f008a1e183639c17809c4ef32e1b6205fa0b57bb5897717eeb0537",
                "namespaces": {
                    "cosmos": {
                        "chains": null,
                        "accounts": [
                            "cosmos:cosmoshub-4:cosmos1nf4dhvs93paezh5gj3k7zz3tcs5wldx3sqz4cw"
                        ],
                        "methods": [
                            "cosmos_getAccounts",
                            "cosmos_signAmino",
                            "cosmos_signDirect",
                            "keplr_enable",
                            "keplr_experimentalSuggestChain",
                            "keplr_getKey",
                            "keplr_signAmino",
                            "keplr_signArbitrary",
                            "keplr_signDirect",
                            "keplr_signEthereum",
                            "keplr_suggestToken"
                        ],
                        "events": [
                            "accountsChanged",
                            "chainChanged",
                            "keplr_accountsChanged"
                        ]
                    }
                },
                "expiry": 1743675982
            }

Attempting to activate ATOM in KDF fails. Req:

{
    "userpass": "{{userpass}}",
    "method": "enable_tendermint_with_assets",
    "mmrpc": "2.0",
    "params": {
        "ticker": "ATOM",
        "tx_history": true,
        "get_balances": true,
        "activation_params": {
            "wallet_connect": {
                "session_topic": "{{session_topic}}"
            }
        },
        "nodes": [
            {
                "url": "https://cosmos-rpc.alpha.komodo.earth/",
                "api_url": "https://cosmos-api.alpha.komodo.earth/",
                "grpc_url": "https://cosmos-grpc.alpha.komodo.earth/",
                "ws_url": "wss://cosmos-rpc.alpha.komodo.earth/websocket"
            },
            {
                "url": "https://cosmoshub.rpc.stakin-nodes.com/"
            }
        ],
        "tokens_params": []
    }
}

Resp:

{
    "mmrpc": "2.0",
    "error": "Error on platform coin ATOM creation: Unable to fetch chain account from WalletConnect. Please try again or reconnect your session - ChainId not supported: cosmos:cosmoshub-4",
    "error_path": "platform_coin_with_tokens.tendermint_with_assets_activation.lib",
    "error_trace": "platform_coin_with_tokens:454] tendermint_with_assets_activation:242] lib:510]",
    "error_type": "PlatformCoinCreationError",
    "error_data": {
        "ticker": "ATOM",
        "error": "Unable to fetch chain account from WalletConnect. Please try again or reconnect your session - ChainId not supported: cosmos:cosmoshub-4"
    },
    "id": null
}

Related console logs for this session:

27 10:25:46, kdf_walletconnect:250] INFO [31f60345f4f008a1e183639c17809c4ef32e1b6205fa0b57bb5897717eeb0537] Subscribing to topic
27 10:25:46, kdf_walletconnect:261] INFO [31f60345f4f008a1e183639c17809c4ef32e1b6205fa0b57bb5897717eeb0537] Subscribed to topic
27 10:25:46, kdf_walletconnect:422] INFO [31f60345f4f008a1e183639c17809c4ef32e1b6205fa0b57bb5897717eeb0537] Publishing message=Request(Request { id: MessageId(446226213533697), jsonrpc: "2.0", params: SessionPropose(SessionProposeRequest { relays: [Relay { protocol: "irn", data: None }], proposer: Proposer { public_key: "525ca7aff07ec802109045150807dc741defc03539d11df628be23974cafa17c", metadata: Metadata { description: "WallectConnect Komodefi Framework Playground", url: "http://127.0.0.1:3000", icons: ["https://avatars.githubusercontent.com/u/21276113?s=200&v=4"], name: "Komodefi Framework" } }, required_namespaces: ProposeNamespaces({"cosmos": ProposeNamespace { chains: {"cosmos:cosmoshub-4"}, methods: {"cosmos_getAccounts", "cosmos_signAmino", "cosmos_signDirect"}, events: {} }}), optional_namespaces: Some(ProposeNamespaces({})) }) })
27 10:25:47, kdf_walletconnect:444] INFO [31f60345f4f008a1e183639c17809c4ef32e1b6205fa0b57bb5897717eeb0537] Message published successfully
27 10:26:23, kdf_walletconnect:294] INFO [31f60345f4f008a1e183639c17809c4ef32e1b6205fa0b57bb5897717eeb0537] Inbound message payload={"id":446226213533697,"jsonrpc":"2.0","result":{"relay":{"protocol":"irn"},"responderPublicKey":"3b4ebb3bc6881fb650c6529082a98ffb5b0188ccbc81067f1ab9e8b3ba630635"}}
27 10:26:24, kdf_walletconnect:294] INFO [5845bd43bcd151214a9fdc114d09bd8db495dec59994b16dc493faa922c87f14] Inbound message payload={"id":1743071182918619,"jsonrpc":"2.0","method":"wc_sessionSettle","params":{"relay":{"protocol":"irn"},"namespaces":{"cosmos":{"accounts":["cosmos:cosmoshub-4:cosmos1nf4dhvs93paezh5gj3k7zz3tcs5wldx3sqz4cw"],"methods":["cosmos_getAccounts","cosmos_signDirect","cosmos_signAmino","keplr_getKey","keplr_signAmino","keplr_signDirect","keplr_signArbitrary","keplr_enable","keplr_signEthereum","keplr_experimentalSuggestChain","keplr_suggestToken"],"events":["accountsChanged","chainChanged","keplr_accountsChanged"]}},"requiredNamespaces":{"cosmos":{"chains":["cosmos:cosmoshub-4"],"methods":["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],"events":[]}},"optionalNamespaces":{},"pairingTopic":"31f60345f4f008a1e183639c17809c4ef32e1b6205fa0b57bb5897717eeb0537","controller":{"publicKey":"3b4ebb3bc6881fb650c6529082a98ffb5b0188ccbc81067f1ab9e8b3ba630635","metadata":{"name":"Keplr","description":"Your Wallet for the Interchain","url":"https://www.keplr.app","icons":["https://asset-icons.s3.us-west-2.amazonaws.com/keplr_512.png"]}},"expiry":1743675982,"sessionProperties":{"keys":"[{\"chainId\":\"cosmoshub-4\",\"name\":\"smk\",\"algo\":\"secp256k1\",\"pubKey\":\"Ayp3NdOwVdLeALPNq8H/tH0yMFsw30v30kBrTtM/rUXY\",\"address\":\"mmrbsgWIe5FeiJRt4QorxCjvtNE=\",\"bech32Address\":\"cosmos1nf4dhvs93paezh5gj3k7zz3tcs5wldx3sqz4cw\",\"ethereumHexAddress\":\"0x9A6AdBb205887b915E88946dE10a2bC428efb4d1\",\"isNanoLedger\":false,\"isKeystone\":false}]"}}}
27 10:26:25, kdf_walletconnect::session::rpc::settle:77] INFO [5845bd43bcd151214a9fdc114d09bd8db495dec59994b16dc493faa922c87f14] Session successfully settled for topic
27 10:26:46, mm2_main::rpc::dispatcher:128] ERROR RPC error response: platform_coin_with_tokens:454] tendermint_with_assets_activation:242] lib:510] Error on platform coin ATOM creation: Unable to fetch chain account from WalletConnect. Please try again or reconnect your session - ChainId not supported: cosmos:cosmoshub-4

Unable to proceed with further cosmos testing until activation succeeds.

smk762 avatar Mar 27 '25 10:03 smk762

Confirmed Keplr activation for ATOM, and successfully generated transactions to broadcast. Using broadcast: true in the withdraw request does not appear to actually broadcast the transaction, I had to do that manually with send_raw_transaction.

ATOM & COSMOS are all marked as "wallet_only": true in the coins file, so I didnt expect this functionality but I tested it anyway with this flag set to false.

Attempting an OSMO sell order returned {"error":"rpc:183] dispatcher_legacy:140] lp_ordermatch:4142] taker_swap:2493] tendermint_coin:1934] Internal error: Could not create HTLC. NotSupported(\"Account type 'osmo' is not supported for HTLCs\")"}.

With IRIS, a swap was successfully initiated, and after two approvals....

smk762 avatar Mar 31 '25 13:03 smk762