-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1384 from emeraldpay/feature/storybooks-for-web-demo
storybooks for web demo
- Loading branch information
Showing
27 changed files
with
922 additions
and
92 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
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
51 changes: 51 additions & 0 deletions
51
packages/react-app/stories/ExampleWeb/Blockchains.stories.tsx
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,51 @@ | ||
import {BlockchainCode} from '@emeraldwallet/core'; | ||
import type {Meta, StoryObj} from '@storybook/react'; | ||
import SelectHDPath from '../../src/create-account/SelectHDPath'; | ||
import {createSeeds, createWallets, initLauncher, ledgerSeedId} from "../wallets"; | ||
import {providerForStore} from "../storeProvider"; | ||
import {createNew} from './data'; | ||
import {accounts} from "@emeraldwallet/store"; | ||
|
||
const { api, backend} = createNew() | ||
|
||
let seedId = 'e23378da-d4b2-4843-ae4d-f42888a11b58'; | ||
|
||
api.vault.addSeedAddress( | ||
seedId, | ||
"m/44'/60'/0'/0/0", | ||
'0xc4cf138d349ead73f7a93306096a626c40f56653', | ||
); | ||
api.vault.addSeedAddress( | ||
seedId, | ||
"m/84'/0'/0'/0/0", | ||
'bc1qqvc28z0kgc7fmdfu440sd7knpgzytgnurszh6t', | ||
); | ||
|
||
let configure = [ | ||
accounts.actions.setSeedsAction([ | ||
{ | ||
id: seedId, | ||
type: 'mnemonic', | ||
createdAt: new Date(), | ||
available: true, | ||
}, | ||
]), | ||
] | ||
|
||
|
||
export default { | ||
title: 'Example Web / Multiple Blockchains', | ||
component: SelectHDPath, | ||
decorators: [providerForStore(api, backend, [...initLauncher, ...configure])], | ||
} as Meta; | ||
|
||
type Story = StoryObj<typeof SelectHDPath>; | ||
|
||
export const Default: Story = { | ||
name: 'Multiple Blockchains', | ||
args: { | ||
seed: { type: 'id', value: seedId }, | ||
blockchains: [BlockchainCode.BTC, BlockchainCode.ETH], | ||
onChange: (accountId, indexes) => console.log('Account selected', accountId, indexes), | ||
} | ||
}; |
100 changes: 100 additions & 0 deletions
100
packages/react-app/stories/ExampleWeb/CancelTx.stories.tsx
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,100 @@ | ||
import {providerForStore} from "../storeProvider"; | ||
import {Meta} from "@storybook/react"; | ||
import * as React from 'react'; | ||
import {accounts, StoredTransaction, tokens, TxAction, txStash} from "@emeraldwallet/store"; | ||
import {CreateTransaction} from "../../src/transaction"; | ||
import {BackendMock, MemoryApiMock} from "../__mocks__"; | ||
import {WalletEntry} from "@emeraldpay/emerald-vault-core"; | ||
import {BlockchainCode, TokenRegistry, workflow} from "@emeraldwallet/core"; | ||
import {State, Status} from "@emeraldwallet/core/lib/persistentState"; | ||
|
||
const api = new MemoryApiMock(); | ||
const backend = new BackendMock(); | ||
|
||
const entries: WalletEntry[] = [ | ||
{ | ||
id: '2a19e023-f119-4dab-b2cb-4b3e73fa32c9-1', | ||
address: { | ||
type: 'single', | ||
value: '0x0', | ||
}, | ||
key: { | ||
type: 'hd-path', | ||
hdPath: "m/44'/60'/0'/0/0", | ||
seedId: 'c782ff2b-ba6e-43e2-9e2d-92d05cc37b03', | ||
}, | ||
blockchain: 100, | ||
createdAt: new Date(), | ||
}, | ||
]; | ||
|
||
let actions = [ | ||
accounts.actions.setWalletsAction([ | ||
{ | ||
entries, | ||
id: '2a19e023-f119-4dab-b2cb-4b3e73fa32c9', | ||
createdAt: new Date(), | ||
}, | ||
]), | ||
{ | ||
type: 'LAUNCHER/TOKENS', | ||
payload: [ | ||
{ | ||
name: 'Wrapped Ether', | ||
blockchain: 100, | ||
address: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', | ||
symbol: 'WETH', | ||
decimals: 18, | ||
type: 'ERC20', | ||
}, | ||
], | ||
}, | ||
|
||
accounts.actions.setBalanceAction({ | ||
address: '0x0', | ||
balance: '1000000000000000000/WEI', | ||
entryId: '2a19e023-f119-4dab-b2cb-4b3e73fa32c9-1', | ||
}), | ||
tokens.actions.setTokenBalance(BlockchainCode.ETH, '0x0', '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', { | ||
decimals: 18, | ||
symbol: 'WETH', | ||
unitsValue: '1000000000000000000', | ||
}), | ||
|
||
txStash.actions.setTransaction({ | ||
blockchain: BlockchainCode.ETH, | ||
amount: '1000000000000000000/WEI', | ||
asset: 'ETH', | ||
target: workflow.TxTarget.MANUAL, | ||
type: "transfer", | ||
meta: { | ||
type: workflow.TxMetaType.ETHER_CANCEL, | ||
} | ||
}), | ||
]; | ||
|
||
// @ts-ignore | ||
let prevTx: StoredTransaction = { | ||
blockchain: 100, | ||
changes: [], | ||
convertChanges: undefined, | ||
meta: { | ||
txId: "0xc88ffa6d41ac14f583b86aa27674ddcc442c12e1d5bb6bb7aa2c7c77824e50d3", | ||
blockchain: BlockchainCode.ETH, | ||
timestamp: new Date(), | ||
}, | ||
sinceTimestamp: new Date(), | ||
state: State.SUBMITTED, | ||
status: Status.UNKNOWN, | ||
txId: "0xc88ffa6d41ac14f583b86aa27674ddcc442c12e1d5bb6bb7aa2c7c77824e50d3", | ||
} | ||
|
||
export default { | ||
title: 'Example Web / Cancel Tx', | ||
decorators: [providerForStore(api, backend, actions),], | ||
} as Meta; | ||
|
||
export const Default = { | ||
name: 'Cancel Tx', | ||
render: () => <CreateTransaction action={TxAction.CANCEL} storedTx={prevTx} entryId="2a19e023-f119-4dab-b2cb-4b3e73fa32c9-1" /> | ||
}; |
Oops, something went wrong.