-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add setRegularKey endpoint * Add missing autofill params in LedgerContext * Fix post rebase * Add dedicated view to set a regular key * Add cypress tests * Display current regular key in the view * Fix post rebase * Use in-memory messaging * Add post review changes * Fix Permissions view * Fix cypress tests
- Loading branch information
1 parent
57a9933
commit 5c0fd8e
Showing
26 changed files
with
878 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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 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 './setRegularKey'; |
This file contains 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,53 @@ | ||
import { | ||
SetRegularKeyRequest, | ||
SetRegularKeyResponse, | ||
GEM_WALLET, | ||
RequestSetRegularKeyMessage, | ||
ResponseType | ||
} from '@gemwallet/constants'; | ||
|
||
import { deserializeError } from '../helpers/errors'; | ||
import { sendMessageToContentScript } from '../helpers/extensionMessaging'; | ||
|
||
export const setRegularKey = async ( | ||
payload: SetRegularKeyRequest | ||
): Promise<SetRegularKeyResponse> => { | ||
/* response: | ||
* if the transaction succeeds: | ||
* - type: 'response' | ||
* - result: | ||
* - hash: transaction hash | ||
* | ||
* if the user rejects the transaction: | ||
* - type: 'reject' | ||
* - result: undefined | ||
* | ||
* if the transaction fails: | ||
* - throw an error | ||
*/ | ||
let response: SetRegularKeyResponse = { | ||
type: ResponseType.Reject, | ||
result: undefined | ||
}; | ||
|
||
try { | ||
const message: RequestSetRegularKeyMessage = { | ||
app: GEM_WALLET, | ||
type: 'REQUEST_SET_REGULAR_KEY/V3', | ||
payload | ||
}; | ||
const { result, error } = await sendMessageToContentScript(message); | ||
const parsedError = error ? deserializeError(error) : undefined; | ||
if (parsedError) { | ||
throw parsedError; | ||
} | ||
|
||
if (result) { | ||
response.type = ResponseType.Response; | ||
response.result = result; | ||
} | ||
} catch (e) { | ||
throw e; | ||
} | ||
return response; | ||
}; |
This file contains 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 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 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 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.