improvement(RPC): unified interface for legacy and current RPC interfaces#2450
improvement(RPC): unified interface for legacy and current RPC interfaces#2450onur-ozkan merged 7 commits intodevfrom
Conversation
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
| let no_method = block_on(mm.rpc(&json! ({ | ||
| "userpass": mm.userpass, | ||
| "coin": "RICK", | ||
| "ipaddr": "electrum1.cipig.net", | ||
| "port": 10017 | ||
| }))) | ||
| .unwrap(); | ||
| assert!(no_method.0.is_server_error()); | ||
| assert_eq!((no_method.2)[ACCESS_CONTROL_ALLOW_ORIGIN], "http://localhost:4000"); |
There was a problem hiding this comment.
This was testing unknown methods on the legacy dispatcher (not very useful to cover to be honest). The behavior for unknown RPCs in the legacy dispatcher has changed: if a method isn't found there, we now try to find it in the current dispatcher.
|
Please let me know how this would affect docs. A simple find/delete for the param is simple enough, and v2 methods tend to include a {
"userpass": "{{userpass}}",
"method": "get_enabled_coins"
}{
"userpass": "{{userpass}}",
"mmrpc": "2.0",
"method": "get_enabled_coins" // "params": {},
// "id": null // Accepted values: Integers
}The response structure of these is also significantly different: v1: {
"result": [
{
"ticker": "DOC",
"address": "RUYJYSTuCKm9gouWzQN1LirHFEYThwzA2d"
},
{
"ticker": "MARTY",
"address": "RUYJYSTuCKm9gouWzQN1LirHFEYThwzA2d"
}
]
}v2: {
"mmrpc": "2.0",
"result": {
"coins": [
{
"ticker": "DOC"
},
{
"ticker": "MARTY"
}
]
},
"id": null
}Will This PR effectively removes any v1 method with a v2 version. Will there be a way to force |
|
My note about this approach (I already asked this in the internal channel): |
|
Covering both comments above: If you are using |
Signed-off-by: onur-ozkan <work@onurozkan.dev>
| return dispatcher_legacy::process_single_request(ctx, req, client, local_only) | ||
| .await | ||
| .map_err(|e| ERRL!("{}", e)); | ||
| match dispatcher_legacy::process_single_request(ctx.clone(), req.clone(), client, local_only).await { |
There was a problem hiding this comment.
Should we not first try rpc version 2 rather than legacy?
to make preference for v2, in case of identical rpc name for v2 and legacy
There was a problem hiding this comment.
This approach will cause BC on identical RPC names as they don't set mmrpc field.
* dev: (30 commits) chore(core): replace hash_raw_entry with stable entry() API (GLEECBTC#2473) chore(core): adapt `MmError` and usages for compatibility with new rustc versions (GLEECBTC#2443) feat(wallet): add `delete_wallet` RPC (GLEECBTC#2497) chore(release): add changelog entries for v2.5.0-beta (GLEECBTC#2494) chore(release): bump kdf version to 2.5.0-beta (GLEECBTC#2492) feat(tests): zcoin unit test to validate dex fee (GLEECBTC#2460) fix(zcoin): correctly track unconfirmed z-coin notes (GLEECBTC#2331) improvement(orders): remove BTC specific volume from min_trading_vol logic (GLEECBTC#2483) feat(ibc-routing-part-2): supporting entire Cosmos network for swaps (GLEECBTC#2476) fix(startup): don't initialize WalletConnect during startup (GLEECBTC#2485) fix(dns): better ip resolution (GLEECBTC#2487) improvement(event-streaming): strong type streamer IDs (GLEECBTC#2441) bump timed-map to `1.4.1` (GLEECBTC#2481) improvement(RPC): unified interface for legacy and current RPC interfaces (GLEECBTC#2450) improvement(tendermint): `tendermint_tx_internal_id` helper (GLEECBTC#2438) feat(walletconnect): add WalletConnect v2 support for EVM and Cosmos (GLEECBTC#2223) feat(ibc-routing-part-1): supporting entire Cosmos network for swaps (GLEECBTC#2459) fix(test): fix HD Wallet message signing tests (GLEECBTC#2474) improvement(builds): enable static CRT linking for MSVC builds (GLEECBTC#2464) feat(wallet): implement HD multi-address support for message signing (GLEECBTC#2432) ... # Conflicts: # mm2src/coins/qrc20.rs # mm2src/mm2_main/src/lp_swap/maker_swap.rs
Allows using any (legacy or current) RPC methods without needing to include
mmrpcin the RPC payloads. It has been annoying to constantly add and remove that field between different RPCs. With this PR, we can leave it to KDF and it will handle it automatically. Ideally, we should remove it entirely from the codebase but that would cause breaking change for downstreams.