generated from MetaMask/metamask-module-template
-
-
Notifications
You must be signed in to change notification settings - Fork 4
feat!: add KeyringRequest.origin
#273
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
22 commits
Select commit
Hold shift + click to select a range
2fa0ee7
feat: add KeyringRequest.origin
ccharly 93954ce
feat!: add new RestrictedKeyringClient
ccharly 03a1594
refactor: rename Restricted -> Public
ccharly 2dd007a
refactor: make KeyringPublicClient a true class
ccharly 35694bc
test: re-use tests for the new KeyringPublicClient
ccharly 2d7389c
chore: (wip) add new KeyringVersion + versionned internal clients
ccharly 22f2b9b
refactor: make KeyringClient.send protected + KeyringInternalSnapClie…
ccharly 5279b8b
chore: lint
ccharly 6ea5a18
refactor: move KeyringVersion internally into keyring-snap-bridge
ccharly 795b48f
chore: bumps snaps-* + use new action from snaps-controllers package
ccharly 82d3699
chore: yarn.lock
ccharly a324a79
chore: lint
ccharly ad9f8f1
feat: add safeguard against empty and non-defined origins
ccharly 842b9e4
refactor: add submitRequestV1 to KeyringInternalSnapClient
ccharly c335bed
chore: update readme
ccharly cf843c1
chore: fix keyring-snap-sdk's keyring-api dep
ccharly 7ef17ae
Revert "chore: fix keyring-snap-sdk's keyring-api dep"
ccharly 03fdc7b
chore: typo
ccharly 2352190
fix: use array instead of objects for platform version mapping
ccharly 747bf47
chore: comment
ccharly 2a0c476
Merge branch 'main' into feat/keyring-request-origin
ccharly 6bbc1a6
Merge branch 'main' into feat/keyring-request-origin
ccharly 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './v1'; |
23 changes: 23 additions & 0 deletions
23
packages/keyring-internal-api/src/compatibility/v1.test.ts
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,23 @@ | ||
import { EthMethod, EthScope } from '@metamask/keyring-api'; | ||
|
||
import { toKeyringRequestV1 } from './v1'; | ||
|
||
describe('v1', () => { | ||
describe('toKeyringRequestV1', () => { | ||
const request = { | ||
id: 'mock-request-id', | ||
scope: EthScope.Mainnet, | ||
account: '55583f38-d81b-48f8-8494-fc543c2b5c95', | ||
origin: 'test', | ||
request: { | ||
method: EthMethod.PersonalSign, | ||
params: {}, | ||
}, | ||
}; | ||
const { origin, ...requestV1 } = request; | ||
|
||
it('converts a keyring request to a keyring request v1', () => { | ||
expect(toKeyringRequestV1(request)).toStrictEqual(requestV1); | ||
}); | ||
}); | ||
}); |
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,34 @@ | ||
import type { KeyringRequest } from '@metamask/keyring-api'; | ||
import { | ||
KeyringRequestStruct, | ||
KeyringResponseStruct, | ||
} from '@metamask/keyring-api'; | ||
import { omit, type Infer } from '@metamask/superstruct'; | ||
|
||
/** | ||
* Keyring request (v1). | ||
*/ | ||
export const KeyringRequestV1Struct = omit(KeyringRequestStruct, ['origin']); | ||
|
||
export type KeyringRequestV1 = Infer<typeof KeyringRequestV1Struct>; | ||
|
||
/** | ||
* Response to a call to `submitRequest` (v1). | ||
*/ | ||
export const KeyringResponseV1Struct = KeyringResponseStruct; | ||
|
||
export type KeyringResponseV1 = Infer<typeof KeyringResponseV1Struct>; | ||
|
||
export const SubmitRequestResponseV1Struct = KeyringResponseV1Struct; | ||
|
||
/** | ||
* Converts a keyring request to a keyring request v1. | ||
* | ||
* @param request - A keyring request. | ||
* @returns A keyring request v1. | ||
*/ | ||
export function toKeyringRequestV1(request: KeyringRequest): KeyringRequestV1 { | ||
const { origin, ...requestV1 } = request; | ||
|
||
return requestV1; | ||
} |
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 |
---|---|---|
@@ -1,2 +1,4 @@ | ||
export * from './compatibility'; | ||
export type * from './eth'; | ||
export * from './types'; | ||
export * from './versions'; |
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,12 @@ | ||
export enum KeyringVersion { | ||
/** Default. */ | ||
V1 = 'v1', | ||
|
||
/** | ||
* Introduction of `KeyringRequest.origin`. | ||
* | ||
* Snap will now receive the `origin` as part of a `KeyringRequest` when `submitRequest` is invoked. | ||
* We also expect Snaps to display this `origin` in their confirmation screens (if any). | ||
*/ | ||
V2 = 'v2', | ||
} |
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
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.