1import { useMemo } from 'react';
2import { isValidAddress } from './utils/crypto';
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',
25 kind?: 'takeLockup' | 'btc' | 'xpub';
26 lock?: 'linear' | 'conditional';
31const useFlowCommand = () => {
32 const flow = useMemo(() => {
33 let flow: FlowType = {};
35 window.location.search
39 if ('' === arg) return;
40 const pam = arg.split('=');
41 flow[pam[0]] = pam.length <= 1 ? true : decodeURIComponent(pam[1]);
44 if (typeof flow === 'object') {
46 case COMMANDS.TAKE_LOCKUP:
47 flow.lock = flow.lock || 'linear';
49 (flow.lock !== 'linear' && flow.lock !== 'conditional') ||
50 !isValidAddress(flow.from)
56 case COMMANDS.BITCOIN:
68 console.log('unrecognized kind of flow:', flow.kind);
69 // eslint-disable-next-line no-fallthrough
84export { 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