forked from leather-io/extension
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c3f20af
commit 482099a
Showing
24 changed files
with
208 additions
and
188 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,30 @@ | ||
import { ExtensionMethods, InternalMethods, Message } from '@content-scripts/message-types'; | ||
|
||
/* | ||
* Vault <-> Background Script | ||
*/ | ||
export type VaultMessage<M extends ExtensionMethods, P> = Omit<Message<M, P>, 'source'>; | ||
|
||
export type GetWallet = VaultMessage<InternalMethods.getWallet, undefined>; | ||
export type MakeWallet = VaultMessage<InternalMethods.makeWallet, undefined>; | ||
export type StoreSeed = VaultMessage< | ||
InternalMethods.storeSeed, | ||
{ secretKey: string; password?: string } | ||
>; | ||
export type CreateNewAccount = VaultMessage<InternalMethods.createNewAccount, undefined>; | ||
export type SignOut = VaultMessage<InternalMethods.signOut, undefined>; | ||
export type SetPassword = VaultMessage<InternalMethods.setPassword, string>; | ||
export type UnlockWallet = VaultMessage<InternalMethods.unlockWallet, string>; | ||
export type LockWallet = VaultMessage<InternalMethods.lockWallet, undefined>; | ||
export type SwitchAccount = VaultMessage<InternalMethods.switchAccount, number>; | ||
|
||
export type VaultActions = | ||
| GetWallet | ||
| MakeWallet | ||
| StoreSeed | ||
| CreateNewAccount | ||
| SignOut | ||
| SetPassword | ||
| UnlockWallet | ||
| SwitchAccount | ||
| LockWallet; |
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
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
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,63 @@ | ||
import { FinishedTxPayload, SponsoredFinishedTxPayload } from '@stacks/connect'; | ||
|
||
export const MESSAGE_SOURCE = 'stacks-wallet' as const; | ||
|
||
export enum ExternalMethods { | ||
transactionRequest = 'transactionRequest', | ||
transactionResponse = 'transactionResponse', | ||
authenticationRequest = 'authenticationRequest', | ||
authenticationResponse = 'authenticationResponse', | ||
} | ||
|
||
export enum InternalMethods { | ||
getWallet = 'getWallet', | ||
makeWallet = 'makeWallet', | ||
storeSeed = 'storeSeed', | ||
createNewAccount = 'createNewAccount', | ||
signOut = 'signOut', | ||
setPassword = 'setPassword', | ||
switchAccountIndex = 'switchAccountIndex', | ||
unlockWallet = 'unlockWallet', | ||
lockWallet = 'lockWallet', | ||
switchAccount = 'switchAccount', | ||
} | ||
|
||
export type ExtensionMethods = ExternalMethods | InternalMethods; | ||
|
||
interface BaseMessage { | ||
source: typeof MESSAGE_SOURCE; | ||
method: ExtensionMethods; | ||
} | ||
|
||
/* | ||
* Content Script <-> Background Script | ||
*/ | ||
export interface Message<M extends ExtensionMethods, P> extends BaseMessage { | ||
method: M; | ||
payload: P; | ||
} | ||
|
||
export type AuthenticationRequestMessage = Message<ExternalMethods.authenticationRequest, string>; | ||
|
||
export type AuthenticationResponseMessage = Message< | ||
ExternalMethods.authenticationResponse, | ||
{ | ||
authenticationRequest: string; | ||
authenticationResponse: string; | ||
} | ||
>; | ||
|
||
export type TransactionRequestMessage = Message<ExternalMethods.transactionRequest, string>; | ||
|
||
export type TxResult = SponsoredFinishedTxPayload | FinishedTxPayload; | ||
|
||
export type TransactionResponseMessage = Message< | ||
ExternalMethods.transactionResponse, | ||
{ | ||
transactionRequest: string; | ||
transactionResponse: TxResult; | ||
} | ||
>; | ||
|
||
export type MessageFromContentScript = AuthenticationRequestMessage | TransactionRequestMessage; | ||
export type MessageToContentScript = AuthenticationResponseMessage | TransactionResponseMessage; |
Oops, something went wrong.