-
-
Notifications
You must be signed in to change notification settings - Fork 262
feat: add auxiliaryFunds + requiredAssets support to eip5792-middleware
#6623
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
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
1f07924
feat: add isAuxiliaryFundsSupported hook to getCapabilities
ffmcgee725 fcd8531
feat: filter out unsupported hardware wallet accounts
ffmcgee725 e85a685
debug: log
ffmcgee725 0351f46
feat: add guards for eip-7682 requiredAssets optional param
ffmcgee725 c896a02
Merge branch 'main' into jc/WAPI-409
ffmcgee725 0b55763
test: bump test coverage
ffmcgee725 b06a708
docs: update CHANGELOG.md
ffmcgee725 ef2ad99
Merge branch 'main' into jc/WAPI-409
ffmcgee725 6301d16
refactor: minor adjustments and documentation update
ffmcgee725 887747d
test: update processSendCalls.test.ts
ffmcgee725 7e8f0b7
fix: deduplicate requiredAssets & adjust auxFunds validation
ffmcgee725 3fc5fab
yarn
ffmcgee725 0c2c114
jest
ffmcgee725 2b1cfc6
test: bump up stmts test cov for processSendCAlls.test.ts
ffmcgee725 057fd98
Merge branch 'main' into jc/WAPI-409
ffmcgee725 5443291
refactor: extract auxiliaryFunds string into enum
ffmcgee725 c823199
refactor: rename function
ffmcgee725 53db0c9
merge main fix conflicts
ffmcgee725 c22188f
Merge branch 'main' into jc/WAPI-409
ffmcgee725 80eba8b
refactor: address code review issues
ffmcgee725 cb2adae
Merge branch 'main' into jc/WAPI-409
ffmcgee725 f2955b4
test: update
ffmcgee725 6b2341f
chore: update CHANGELOG.md
ffmcgee725 67be6a9
test: address nit
ffmcgee725 20b3c3d
Merge branch 'main' into jc/WAPI-409
adonesky1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,8 @@ export type GetCapabilitiesHooks = { | |
| getSendBundleSupportedChains: ( | ||
| chainIds: Hex[], | ||
| ) => Promise<Record<string, boolean>>; | ||
| /** Function to validate if auxiliary funds capability is supported. */ | ||
| isAuxiliaryFundsSupported: (chainId: Hex) => boolean; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should have been documented as a breaking change |
||
| }; | ||
|
|
||
| /** | ||
|
|
@@ -48,6 +50,7 @@ export async function getCapabilities( | |
| isAtomicBatchSupported, | ||
| isRelaySupported, | ||
| getSendBundleSupportedChains, | ||
| isAuxiliaryFundsSupported, | ||
| } = hooks; | ||
|
|
||
| let chainIdsNormalized = chainIds?.map( | ||
|
|
@@ -106,15 +109,22 @@ export async function getCapabilities( | |
| } | ||
|
|
||
| const status = isSupported ? 'supported' : 'ready'; | ||
| const hexChainId = chainId as Hex; | ||
|
|
||
| if (acc[chainId as Hex] === undefined) { | ||
| acc[chainId as Hex] = {}; | ||
| if (acc[hexChainId] === undefined) { | ||
| acc[hexChainId] = {}; | ||
| } | ||
jiexi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| acc[chainId as Hex].atomic = { | ||
| acc[hexChainId].atomic = { | ||
| status, | ||
| }; | ||
|
|
||
| if (isSupportedAccount && isAuxiliaryFundsSupported(chainId)) { | ||
| acc[hexChainId].auxiliaryFunds = { | ||
| supported: true, | ||
| }; | ||
| } | ||
|
|
||
| return acc; | ||
| }, alternateGasFeesAcc); | ||
| } | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not make this an object with both codes and messages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you're following the pattern above with EIP5792ErrorCode...
Weird pattern to decouple message + code IMO
Up to you we could change it here or just do that in the future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
☝🏾 exactly, following what was previously established. I'm good with refactoring this in a tech debt issue which makes sense when these are moved to
@metamask/rpc-errorspackage. Should I put an issue on our board for moving these out of here and making these objects with both code and messages ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes lets create a ticket for this 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://consensyssoftware.atlassian.net/browse/WAPI-724