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

MIPX v1 - New json rpc method for swaps #25

Merged
merged 44 commits into from
Jul 1, 2024
Merged
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
1447a80
mip2 v1
tommasini Nov 10, 2023
c937f19
Remove non used sections
tommasini Nov 10, 2023
4d007d1
fix typo
tommasini Nov 10, 2023
2487b5c
change example amount to 1 token value
tommasini Nov 10, 2023
bf9e4d2
added reference for draft EIP
tommasini Nov 11, 2023
c8ec086
Update MIPs/mip-2.md
tommasini Nov 27, 2023
7b65338
changed for MIP-3 and updated Motivation Section
tommasini Nov 27, 2023
cb3717d
deleted mip2
tommasini Nov 27, 2023
59b0df9
update motivatino
tommasini Nov 28, 2023
a0ba3ae
add comparison to snaps to the motivation section
tommasini Dec 20, 2023
89c269a
change params to use position params instead and add user_address par…
tommasini Dec 20, 2023
ed3b859
add user_address property to the json rpc method
tommasini Dec 21, 2023
fcb37f7
added support for multiple swap tokens and cross chain swaps. Also ad…
tommasini Dec 21, 2023
5b7282e
add security concerns
tommasini Dec 21, 2023
61bee6d
add increase revenue motivation
tommasini Dec 22, 2023
210d269
add more security considerations
tommasini Dec 22, 2023
f1490e1
update MIP3 wallet_swapAsset with new structure, new optional propert…
tommasini Mar 5, 2024
21ed5a6
Addressed review on MIP
tommasini Mar 5, 2024
b200f89
address review
tommasini Mar 15, 2024
3d2bc1c
developers must ensure the correct chain is being used
tommasini Mar 15, 2024
5cd62ad
remove referal code
tommasini Apr 24, 2024
54bedb4
Update MIPs/mip-3.md
tommasini Apr 24, 2024
7ee3634
remove caveats
tommasini Apr 24, 2024
d87d5bf
Update MIPs/mip-3.md
tommasini Apr 24, 2024
aae1e4e
Update MIPs/mip-3.md
tommasini Apr 24, 2024
23bf4eb
Update MIPs/mip-3.md
tommasini Apr 24, 2024
f6269fe
Update MIPs/mip-3.md
tommasini Apr 24, 2024
6eb6317
Update MIPs/mip-3.md
tommasini Apr 24, 2024
091e2ac
update error codes
tommasini May 20, 2024
63762e5
Added mobile PR to MIP responsible to add swapAsset rpc method to mob…
tommasini May 20, 2024
69b7f5b
Update MIPs/mip-3.md
tommasini May 27, 2024
55c71d3
added dash on json rpc appearances, renamed mip to x
tommasini May 30, 2024
d64432f
address review for copy
tommasini May 30, 2024
e3f7244
added explanation while checking the selected account on the dapp and…
tommasini May 30, 2024
2b1211a
address all comments on the review of the mip
tommasini Jun 10, 2024
3fe0f34
change addresses to use caip10 format
tommasini Jun 21, 2024
c119eeb
update cross chain swap error method
tommasini Jun 21, 2024
f78e3ad
added caip-10 error handling
tommasini Jun 24, 2024
09fd777
Update MIPs/mip-x.md
tommasini Jun 25, 2024
326c0a4
removing the double d from method not supported
tommasini Jun 25, 2024
61f515e
Update MIPs/mip-x.md
adonesky1 Jul 1, 2024
5892b6b
Update MIPs/mip-x.md
adonesky1 Jul 1, 2024
cae24e9
Update MIPs/mip-x.md
adonesky1 Jul 1, 2024
a4c38d4
Update MIPs/mip-x.md
adonesky1 Jul 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions MIPs/mip-x.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,17 @@ Ensuring Correct Chain Context for `wallet_swapAsset`: Before initiating a swap,
```markdown
if (!isSwappable) {
Alert.alert(`Swap is not available on this chain ${networkName}`);
throw rpcErrors.methodNotSupported(
throw rpcErrors.methoddNotSupported(
tommasini marked this conversation as resolved.
Show resolved Hide resolved
`Swap is not available on this chain ${networkName}`,
);
}
```

- **Cross-Chain Swap Attempt**: Given the current limitations, MetaMask does not support cross-chain swaps. If a swap request involves tokens from different blockchains (as indicated by their CAIP-10 formatted addresses), MetaMask will throw an error to indicate this unsupported operation. This ensures developers and users are aware of the limitations and can adjust their actions accordingly.
- **Cross-Chain Swap Attempt**: Given the current limitations, MetaMask does not support cross-chain swaps. If a swap request involves tokens from different blockchains (as indicated by their CAIP-10 formatted addresses), MetaMask will throw an error to indicate this unsupported operation. This ensures developers and users are aware of the limitations and can adjust their actions accordingly. See more details about error codes in the api-spec: https://github.com/MetaMask/api-specs/pull/201

```markdown
if (parseChainIdFromCaip10(fromToken.address) !== parseChainIdFromCaip10(toToken.address)) {
throw rpcErrors.invalidParams(
throw rpcErrors.methoddNotSupported(
Copy link
Collaborator

Choose a reason for hiding this comment

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

is the double d in methodd on purpose? confused since i see you made this change in two different places haha

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AHAHAHAHHA and I missed this error on two diff places XD

'Cross-chain swaps are currently not supported. Both fromToken and toToken must be on the same blockchain.',
);
}
Expand Down