-
Notifications
You must be signed in to change notification settings - Fork 5.3k
feat: Add Multichain API to Flask #27782
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
995 commits
Select commit
Hold shift + click to select a range
3771ebc
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi 7688c40
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi 9faf0e6
remove unnecessary JSON.stringify in wallet_createSession
jiexi 08ff03d
add missing import
jiexi c7f9adc
remove eip3085 handling from wallet_createSession
jiexi f7f5c28
remove unused hooks
jiexi 9d7a8a4
jsdoc wallet_createSession handler
jiexi f2e64be
remove processScopedProperties
jiexi 9f58f3f
lint
jiexi 61f1182
use preview build 298fc547
jiexi b27d53b
Update app/scripts/lib/rpc-method-middleware/handlers/wallet-requestP…
jiexi bea54cf
move getCaveat in requestPermittedChainsPermissionIncremental to afte…
jiexi 2e078a8
Merge branch 'main' into caip25-permission-migration
jiexi 50748b6
Merge remote-tracking branch 'origin/caip25-permission-migration' int…
jiexi 6aea438
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi ec4f301
move getCaveat in requestPermittedChainsPermissionIncremental to afte…
jiexi df60de4
Update ui/pages/permissions-connect/connect-page/connect-page.tsx
jiexi 11faff5
Update ui/components/multichain/pages/review-permissions-page/site-ce…
jiexi abc0343
remove delays from sign.flow.ts
jiexi 8d99f45
lint
jiexi 422f379
Merge branch 'main' into caip25-permission-migration
jiexi e932140
lint
jiexi b1d52ad
Merge branch 'main' into caip25-permission-migration
jiexi cec2311
Merge branch 'main' into caip25-permission-migration
jiexi ebee234
Multichain API E2E Test: wallet_revokeSession (#29639)
ffmcgee725 0c0adf8
address partially mutation state bugs (#29682)
adonesky1 1817ba9
Multichain API E2E Test: wallet_createSession called with an existing…
ffmcgee725 6ebcb5f
Jl/restore legacy fixtures (#29674)
jiexi 2846b0d
remove extraneous hooks
adonesky1 19826fe
dedupe
adonesky1 7240c13
lint
adonesky1 f166986
Merge branch 'main' into caip25-permission-migration
jiexi fe7469e
Merge remote-tracking branch 'origin/caip25-permission-migration' int…
jiexi 10d4d9c
Update LavaMoat policies
metamaskbot 492687c
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi bb38fc4
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi 0ba6f86
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi 16c42b8
use preview build e05b7d3e
jiexi 69a188b
Update LavaMoat policies
metamaskbot 6633fb7
dedupe
adonesky1 113e643
update hookname: getCaveatForOrigin
adonesky1 106e7a6
Update LavaMoat policies
metamaskbot 24fe195
wrap rpcErrors in flask build flags
adonesky1 65bd138
use preview build f3715655
jiexi baf0afc
fix getCaveatForOrigin
adonesky1 4b52240
Merge branch 'main' into caip25-permission-migration
jiexi 20204ec
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi 9df1ef3
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi 04d64da
use preview build 6244b7be
jiexi b89c40c
lint
jiexi 8776db0
Multichain API E2E test: wallet_sessionChanged (#29706)
ffmcgee725 62621a1
Merge branch 'main' into caip25-permission-migration
adonesky1 113ba76
lint
adonesky1 29d2381
lint
adonesky1 ec919bd
Docs: Update Developer Docs link in README (#29733)
Montoya 236b2d4
Merge branch 'main' into caip25-permission-migration
jiexi 9d73bd9
jsdoc captureKeyringTypesWithMissingIdentities
jiexi 89ed1b3
Merge remote-tracking branch 'origin/caip25-permission-migration' int…
jiexi eb67f19
jsdoc sortAccountsByLastSelected
jiexi c86e052
Merge branch 'main' into caip25-permission-migration
jiexi ea4294a
Update app/scripts/migrations/138.ts
adonesky1 fdeb41e
Update app/scripts/migrations/138.ts
adonesky1 28094b5
Update app/scripts/migrations/138.ts
adonesky1 ab87b63
add comment/link for BUILT_IN_NETWORKS
adonesky1 9cdf8b7
address feedback / cleanup migration
adonesky1 43a0749
bail out of migration when encountering any data malformation
adonesky1 134f730
make malformation checks against networkConfigurations more strict
adonesky1 27b7353
Merge branch 'main' into caip25-permission-migration
jiexi 8bdde06
Merge remote-tracking branch 'origin/caip25-permission-migration' int…
jiexi fe26dcf
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi 724e178
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi b2581f4
lint
jiexi 6a6b1bf
Trigger
jiexi b213d94
add isNonEmptyArrayOfStrings to migration
jiexi 2f0a4e5
Merge branch 'main' into caip25-permission-migration
jiexi 0de03cc
Update test/e2e/tests/request-queuing/ui.spec.js
jiexi 9233f06
Revert ui/ducks/bridge/selectors.ts
jiexi dcdee7f
Merge remote-tracking branch 'origin/caip25-permission-migration' int…
jiexi 5357693
Merge branch 'main' into caip25-permission-migration
jiexi 651a40c
cleanup fixtures
jiexi b032101
clean fixtures deprecated-networks.spec.js and switch-custom-network.…
jiexi 4c700fd
remove ERC_4337_ACCOUNT from withPreferencesControllerAdditionalAccou…
jiexi 0f6c9f9
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
adonesky1 79678cd
update yarn.lock post rebase
adonesky1 6865dc5
Update LavaMoat policies
metamaskbot 0412864
dedupe
adonesky1 792306f
fix wallet locked behavior
adonesky1 dea12c0
Update LavaMoat policies
metamaskbot ba9efbb
revert unecessary change to fixtures
jiexi 7797d67
Merge branch 'main' into caip25-permission-migration
jiexi 608ac95
revert unecessary change to fixtures 2
jiexi 03624be
restore styling changes fixture
jiexi bd1e230
undo fixture changes that aren't needed
jiexi 76f77b0
Merge branch 'main' into caip25-permission-migration
jiexi 962c343
lint
jiexi 3d0cfdd
lint
jiexi aba2d8a
Merge branch 'main' into caip25-permission-migration
jiexi 1fb0f29
Update ui/components/multichain/edit-accounts-modal/edit-accounts-mod…
adonesky1 1bf080d
Multichain API E2E Test: handling when MetaMask is password locked (#…
ffmcgee725 5f96f94
Fix wallet_revokePermission spec
jiexi 4762e5c
Merge branch 'main' into caip25-permission-migration
jiexi 18440d6
Merge remote-tracking branch 'origin/caip25-permission-migration' int…
jiexi 15fa319
Merge branch 'main' into caip25-permission-migration
jiexi c1b4b29
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi 540899a
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi ad7169d
Update LavaMoat policies
metamaskbot d52827e
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi 9b74e4c
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi a15a668
use preview build 2ba45577
jiexi a91d9b4
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi f85ad62
Update LavaMoat policies
metamaskbot 6e0dbeb
remove caipPermissionAdapterMiddleware
jiexi 721c85b
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi 58be906
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi 66d0308
yarn dedupe
jiexi d4410f2
Update LavaMoat policies
metamaskbot b8ae6c3
lint?
jiexi 7f32e4d
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi 0c2a696
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi a69d816
remove unneeded hooks
jiexi cfe4339
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi 67dae48
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi d65cabf
fix remove network
jiexi fc286d9
lint
jiexi ea676b4
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi 1ff78c6
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi 51ad9d9
yarn
jiexi 7199240
Restore wallet locked behavior
jiexi 96c77a2
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi ef209cd
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi 0c27eb1
move missing caveat check
jiexi 6bcd229
lint
jiexi 464e972
remove connect.spec
jiexi 2d08956
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi 5bd7d64
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi 16f9f38
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi d5ab747
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi acdac1f
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi 970ad3b
lint
jiexi 94c8dd9
WIP: adapt to new CAIP-25 approval UI
jiexi 08c32f0
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi ec9ddca
update approval UI to modify only evm portion of returned CAIP-25 per…
jiexi e0c548e
update wallet_createSession to pass in a validated CAIP-25 permission…
jiexi 95e1275
lint
jiexi c18440b
Fix connect page supported request chain id check
jiexi ffbf346
WIP: fix snaps request accounts
jiexi a265050
Fix snaps account grant
jiexi 9b6cf67
lint
jiexi 16c0b5d
lint
jiexi 80c0fd8
Update app/scripts/lib/rpc-method-middleware/handlers/wallet-createSe…
jiexi 4feca47
delete password-locked spec
jiexi c40afc6
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi c5cfbde
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi cf15677
remove console.log
jiexi 22e6e6b
loosen wallet_revokeSession fixture assert
jiexi 6d511af
remove secp256k1 v5 force resolution
adonesky1 a139124
yarn.lock reset
adonesky1 7cce39d
Update LavaMoat policies
metamaskbot 6867030
lint
adonesky1 3e7c8ae
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi 66a4c65
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi 6311273
Update app/scripts/lib/rpc-method-middleware/handlers/request-account…
adonesky1 b07aac2
remove comment
adonesky1 ccb8644
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi 164d189
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi 22957ef
Update LavaMoat policies
FrederikBolding 3613394
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi f054b45
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi 97a5097
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi e22b7bc
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi f665043
yarn dedupe
jiexi ecdb0b8
Update app/scripts/metamask-controller.js
jiexi e1d3631
DRY multichain eth subscription add and removal
jiexi fd30905
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi f90be7c
update getRemovedAuthorizations to include removed scopes as well as …
jiexi 8a5f2cf
switch to createDeepEqualSelector
jiexi 551b56c
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi 75db2f7
add default value to createUnsupportedMethodMiddleware
jiexi 1e20517
Bump api-specs to 0.10.14
jiexi 84cc007
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi d5445f1
yarn dedupe
jiexi eed6a10
Lint
jiexi 1d43a4a
codefence UNSUPPORTED_RPC_METHODS in MMC
jiexi 03a40aa
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi 5152d05
bump @metamask/api-specs to 0.10.15
jiexi 7103714
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi 57c5874
Fix sessionChanged not firing
jiexi c960844
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi 701820c
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi 68f4c35
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi f4b58b4
Add permission differs
jiexi de7ebf7
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi 259e36a
Make createUnsupportedMethodMiddleware accept a Set again
jiexi 1230a38
Add back BARAD_DUR flag. Replaces Multichain API flask code fences. S…
jiexi e381705
rename BARAD_DUR to MULTICHAIN_API
jiexi a219b31
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi 1cf91a7
Fix flipped connectExternalCaip condition
jiexi 1b8d61b
Fix MMC test
jiexi 4446500
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi b2be74f
fix bad merge
jiexi 986adf9
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi 9b81f88
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi 9ae93dc
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi db2d7b3
WIP update e2e tests
jiexi 454ffdc
Finish update e2e tests -ish
jiexi 7f6ad99
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi 2a454ef
Fix ganacheOptions renamed to localNodeOptions
jiexi d9c024c
Merge branch 'main', remote-tracking branch 'origin' into jl/caip-mul…
adonesky1 3cf5850
bump api-specs version
adonesky1 55f1101
Merge branch 'main' into jl/caip-multichain-migrate-core
adonesky1 1a59473
Merge branch 'main' into jl/caip-multichain-migrate-core
adonesky1 3130fa9
dedupe
adonesky1 f86d829
Update LavaMoat policies
metamaskbot 60c3e89
Update LavaMoat policies
metamaskbot 157a555
chore: update @metamask/multichain (#30495)
ffmcgee725 52304af
Rename supportedRequiredScopesObjects/supportedOptionalScopesObjects
mcmire 808cf97
Roll back change to ui/ducks/bridge/selectors.ts
mcmire 3b8eaf6
Merge branch 'main' into jl/caip-multichain-migrate-core
mcmire 166a8cb
Revert maskType: 'alpha' changes
mcmire 9a3599e
Add link to planning ticket
mcmire 5a48fbc
Update LavaMoat policies
metamaskbot c279367
Remove duplicate key
mcmire 30e82ba
Revert this file, we can update it later
mcmire fdf1cd0
Use provider.request and not provider.sendAsync
mcmire 825188e
Use createSelector instead of createDeepEqualSelector
mcmire 44d34d9
Merge branch 'main' into jl/caip-multichain-migrate-core
mcmire ee43107
Bump api-specs to make e2e test pass
mcmire 8d7d22d
Update LavaMoat policies
metamaskbot ec39686
Add missing MethodNames
mcmire 5074638
Perhaps fix api-specs-multichain
mcmire e50c7a2
Get more tests passing
mcmire a3f2b02
Fix lint issues
mcmire 7b0b747
Fix more tests
mcmire 8a8fb7f
Merge branch 'main' into jl/caip-multichain-migrate-core
mcmire 5d9aa06
Maybe get more tests to pass
mcmire 9c02711
Address nit in createSession handler
mcmire deb1b0f
Ohhhhh, I forgot the end()
mcmire 0079d5e
Fix wallet_invokeMethod tests
mcmire 0b26c90
Merge branch 'main' into jl/caip-multichain-migrate-core
mcmire 501c13d
Merge branch 'main' into jl/caip-multichain-migrate-core
mcmire cf5e8e3
Maybe mock the foo.io HTTP request in the multichain API tests?
mcmire 303b4e2
Add rejectApprovalRequestsForOrigin as a hook for multichain method m…
mcmire 9714b30
Mock foo.io in multichain API specs
mcmire b6102ed
Fix multichain-api test helpers
mcmire 6b690a1
Group new wallet_ constants with others
mcmire ea57e9a
Invert this condition
mcmire 63f0ba4
Fix lint error
mcmire c700391
Merge branch 'main' into jl/caip-multichain-migrate-core
adonesky1 b710fbb
refactor: `wallet_createSession` should call `PermissionController.re…
ffmcgee725 45ea711
Merge branch 'main' into jl/caip-multichain-migrate-core
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,263 @@ | ||
import { | ||
diffMap, | ||
getChangedAuthorizations, | ||
getRemovedAuthorizations, | ||
} from './differs'; | ||
|
||
describe('PermissionController selectors', () => { | ||
describe('diffMap', () => { | ||
it('returns the new value if the previous value is undefined', () => { | ||
const newAccounts = new Map([['foo.bar', ['0x1']]]); | ||
expect(diffMap(newAccounts, undefined)).toBe(newAccounts); | ||
}); | ||
|
||
it('returns an empty map if the new and previous values are the same', () => { | ||
const newAccounts = new Map([['foo.bar', ['0x1']]]); | ||
expect(diffMap(newAccounts, newAccounts)).toStrictEqual(new Map()); | ||
}); | ||
|
||
it('returns a new map of the changed key/value pairs if the new and previous maps differ', () => { | ||
// We set this on the new and previous value under the key 'foo.bar' to | ||
// check that identical values are excluded. | ||
const identicalValue = ['0x1']; | ||
|
||
const previousAccounts = new Map([ | ||
['bar.baz', ['0x1']], // included: different accounts | ||
['fizz.buzz', ['0x1']], // included: removed in new value | ||
]); | ||
previousAccounts.set('foo.bar', identicalValue); | ||
|
||
const newAccounts = new Map([ | ||
['bar.baz', ['0x1', '0x2']], // included: different accounts | ||
['baz.fizz', ['0x3']], // included: brand new | ||
]); | ||
newAccounts.set('foo.bar', identicalValue); | ||
|
||
expect(diffMap(newAccounts, previousAccounts)).toStrictEqual( | ||
new Map([ | ||
['bar.baz', ['0x1', '0x2']], | ||
['fizz.buzz', []], | ||
['baz.fizz', ['0x3']], | ||
]), | ||
); | ||
}); | ||
}); | ||
|
||
describe('getChangedAuthorizations', () => { | ||
it('returns an empty map if the previous value is undefined', () => { | ||
expect(getChangedAuthorizations(new Map(), undefined)).toStrictEqual( | ||
new Map(), | ||
); | ||
}); | ||
|
||
it('returns an empty map if the new and previous values are the same', () => { | ||
const newAuthorizations = new Map(); | ||
expect( | ||
getChangedAuthorizations(newAuthorizations, newAuthorizations), | ||
).toStrictEqual(new Map()); | ||
}); | ||
|
||
it('returns a new map of the current values of changed scopes but excluding removed scopes in authorizations', () => { | ||
const previousAuthorizations = new Map([ | ||
[ | ||
'foo.bar', | ||
{ | ||
requiredScopes: { | ||
'eip155:1': { | ||
accounts: ['eip155:1:0xdead' as const], | ||
}, | ||
}, | ||
optionalScopes: { | ||
'eip155:5': { | ||
accounts: [], | ||
}, | ||
'eip155:10': { | ||
accounts: [], | ||
}, | ||
}, | ||
isMultichainOrigin: true, | ||
}, | ||
], | ||
]); | ||
|
||
const newAuthorizations = new Map([ | ||
[ | ||
'foo.bar', | ||
{ | ||
requiredScopes: { | ||
'eip155:1': { | ||
accounts: ['eip155:1:0xbeef' as const], | ||
}, | ||
}, | ||
optionalScopes: { | ||
'eip155:5': { | ||
accounts: ['eip155:5:0x123' as const], | ||
}, | ||
}, | ||
isMultichainOrigin: true, | ||
}, | ||
], | ||
]); | ||
|
||
expect( | ||
getChangedAuthorizations(newAuthorizations, previousAuthorizations), | ||
).toStrictEqual( | ||
new Map([ | ||
[ | ||
'foo.bar', | ||
{ | ||
requiredScopes: { | ||
'eip155:1': { | ||
accounts: ['eip155:1:0xbeef'], | ||
}, | ||
}, | ||
optionalScopes: { | ||
'eip155:5': { | ||
accounts: ['eip155:5:0x123'], | ||
}, | ||
}, | ||
}, | ||
], | ||
]), | ||
); | ||
}); | ||
|
||
it('returns a new map with empty requiredScopes and optionalScopes for revoked authorizations', () => { | ||
const previousAuthorizations = new Map([ | ||
[ | ||
'foo.bar', | ||
{ | ||
requiredScopes: { | ||
'eip155:1': { | ||
accounts: ['eip155:1:0xdead' as const], | ||
}, | ||
}, | ||
optionalScopes: { | ||
'eip155:5': { | ||
accounts: [], | ||
}, | ||
'eip155:10': { | ||
accounts: [], | ||
}, | ||
}, | ||
isMultichainOrigin: true, | ||
}, | ||
], | ||
]); | ||
|
||
const newAuthorizations = new Map(); | ||
|
||
expect( | ||
getChangedAuthorizations(newAuthorizations, previousAuthorizations), | ||
).toStrictEqual( | ||
new Map([ | ||
[ | ||
'foo.bar', | ||
{ | ||
requiredScopes: {}, | ||
optionalScopes: {}, | ||
}, | ||
], | ||
]), | ||
); | ||
}); | ||
}); | ||
|
||
describe('getRemovedAuthorizations', () => { | ||
it('returns an empty map if the previous value is undefined', () => { | ||
expect(getRemovedAuthorizations(new Map(), undefined)).toStrictEqual( | ||
new Map(), | ||
); | ||
}); | ||
|
||
it('returns an empty map if the new and previous values are the same', () => { | ||
const newAuthorizations = new Map(); | ||
expect( | ||
getRemovedAuthorizations(newAuthorizations, newAuthorizations), | ||
).toStrictEqual(new Map()); | ||
}); | ||
|
||
it('returns a new map of the removed scopes in authorizations', () => { | ||
const previousAuthorizations = new Map([ | ||
[ | ||
'foo.bar', | ||
{ | ||
requiredScopes: { | ||
'eip155:1': { | ||
accounts: [], | ||
}, | ||
}, | ||
optionalScopes: { | ||
'eip155:5': { | ||
accounts: [], | ||
}, | ||
'eip155:10': { | ||
accounts: [], | ||
}, | ||
}, | ||
isMultichainOrigin: true, | ||
}, | ||
], | ||
]); | ||
|
||
const newAuthorizations = new Map([ | ||
[ | ||
'foo.bar', | ||
{ | ||
requiredScopes: { | ||
'eip155:1': { | ||
accounts: [], | ||
}, | ||
}, | ||
optionalScopes: { | ||
'eip155:10': { | ||
accounts: [], | ||
}, | ||
}, | ||
isMultichainOrigin: true, | ||
}, | ||
], | ||
]); | ||
|
||
expect( | ||
getRemovedAuthorizations(newAuthorizations, previousAuthorizations), | ||
).toStrictEqual( | ||
new Map([ | ||
[ | ||
'foo.bar', | ||
{ | ||
requiredScopes: {}, | ||
optionalScopes: { | ||
'eip155:5': { | ||
accounts: [], | ||
}, | ||
}, | ||
}, | ||
], | ||
]), | ||
); | ||
}); | ||
|
||
it('returns a new map of the revoked authorizations', () => { | ||
const mockAuthorization = { | ||
requiredScopes: { | ||
'eip155:1': { | ||
accounts: [], | ||
}, | ||
}, | ||
optionalScopes: {}, | ||
isMultichainOrigin: true, | ||
}; | ||
const previousAuthorizations = new Map([ | ||
['foo.bar', mockAuthorization], | ||
['bar.baz', mockAuthorization], | ||
]); | ||
|
||
const newAuthorizations = new Map([['foo.bar', mockAuthorization]]); | ||
|
||
expect( | ||
getRemovedAuthorizations(newAuthorizations, previousAuthorizations), | ||
).toStrictEqual(new Map([['bar.baz', mockAuthorization]])); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.