1import { useMemo } from 'react';
2import { isValidAddress } from './utils/address';
4// looks into the GET parameters and attempts to construct a "flow" object,
5// which would indicate bridge is to be used for one specific flow.
6// expects to find any of the following sets of parameters, varying by kind.
9// & lock = linear | conditional // which lockup contract, defaults to linear
10// & from = 0x1234abcd // ethereum address to accept transfer from
13// & utx = somebase64string
19 TAKE_LOCKUP: 'takeLockup',
24interface LockupFlowKind {
26 lock: 'linear' | 'conditional';
28 [k: string]: string | boolean;
31interface BitcoinFlowKind {
34 [k: string]: string | boolean;
37interface XpubFlowKind {
39 [k: string]: string | boolean;
42interface DefaultFlowKind {
44 [k: string]: string | boolean | undefined;
54const useFlowCommand = () => {
55 const flow = useMemo(() => {
56 let flow: FlowType = {};
58 window.location.search
62 if ('' === arg) return;
63 const pam = arg.split('=');
65 flow[pam[0]] = pam.length <= 1 ? true : decodeURIComponent(pam[1]);
69 if (flow && typeof flow === 'object') {
71 case COMMANDS.TAKE_LOCKUP:
72 flow.lock = flow.lock || 'linear';
74 (flow.lock !== 'linear' && flow.lock !== 'conditional') ||
75 !isValidAddress(flow.from)
81 case COMMANDS.BITCOIN:
83 if (flow.utx && typeof flow.utx === 'string') {
100 console.log('unrecognized kind of flow:', flow.kind);
113export { COMMANDS, useFlowCommand };
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list