-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add wallet functionality (#144)
- Loading branch information
1 parent
4568cbc
commit bfb7ad4
Showing
23 changed files
with
263 additions
and
30 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
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
export enum ApiActions { | ||
FDP_STORAGE = 'fdp-storage', | ||
SIGNER_SIGN_MESSAGE = 'signer.signMessage', | ||
SEND_TRANSACTION = 'send-transaction', | ||
GET_USER_BALANCE = 'get-user-balance', | ||
ECHO = 'echo', | ||
} |
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,23 @@ | ||
import { ApiActions } from './constants/api-actions.enum' | ||
import { BlossomMessages } from './messages/blossom-messages' | ||
|
||
export class Wallet { | ||
constructor(private messages: BlossomMessages) {} | ||
|
||
/** | ||
* Returns account balance of current user in wei | ||
* @returns current balance in wei | ||
*/ | ||
public getUserBalance(): Promise<string> { | ||
return this.messages.sendMessage(ApiActions.GET_USER_BALANCE) | ||
} | ||
|
||
/** | ||
* Creates a transaction with current user as signer. | ||
* @param address receiver account | ||
* @param amount transaction amount in wei | ||
*/ | ||
public sendTransaction(address: string, amount: string): Promise<void> { | ||
return this.messages.sendMessage(ApiActions.SEND_TRANSACTION, { to: address, amount }) | ||
} | ||
} |
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,15 @@ | ||
import { DappId } from '../../model/general.types' | ||
import { dappUrlToId } from '../../services/fdp-storage/fdp-storage.utils' | ||
import { Storage } from '../../services/storage/storage.service' | ||
import { SwarmExtension } from '../../swarm-api/swarm-extension' | ||
|
||
const storage = new Storage() | ||
|
||
export async function getDappId(sender: chrome.runtime.MessageSender): Promise<DappId> { | ||
const { extensionId } = await storage.getSwarm() | ||
const swarmExtension = new SwarmExtension(extensionId) | ||
|
||
const { beeApiUrl } = await swarmExtension.beeAddress() | ||
|
||
return dappUrlToId(sender.url, beeApiUrl) | ||
} |
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
Oops, something went wrong.