1import { signTransactionHash } from 'lib/authToken';
2import { Invite } from 'lib/types/Invite';
3import { Just } from 'folktale/maybe';
4import { randomHex } from 'web3-utils';
6 attemptNetworkSeedDerivation,
10import { addHexPrefix } from 'lib/utils/address';
12export const SECOND = 1000;
13export const MINUTE = SECOND * 60;
14export const HOUR = MINUTE * 60;
16export const padZero = (amount: number) =>
17 `${amount < 10 && amount > 0 ? '0' : ''}${amount}`;
19export const getTimeToNextBatch = (nextBatch: number, now: number) => {
20 const toNext = nextBatch - now;
21 const hours = Math.floor(toNext / HOUR);
22 const minutes = Math.floor((toNext - hours * HOUR) / MINUTE);
23 const seconds = Math.floor(
24 (toNext - hours * HOUR - minutes * MINUTE) / SECOND
27 return `${padZero(hours)}h ${padZero(minutes)}m ${padZero(seconds)}s`;
30export const isL2 = (dom?: string) => dom === 'l2' || dom === 'spawn';
32export const spawn = async (
41 ship: _point, //ship that is spawning the planet
46 address: _wallet.address,
47 ship: planet, // ship to spawn
50 const hash = await api.hashTransaction(nonce, from, 'spawn', data);
51 const sSig = signTransactionHash(hash, _wallet.privateKey);
52 return api.spawn(sSig, from, _wallet.address, data);
55export const configureKeys = async (
68 ship: _point, //ship to configure keys
72 const networkSeed = await attemptNetworkSeedDerivation({
82 const seed = Just.hasInstance(networkSeed)
86 const pair = deriveNetworkKeys(seed);
89 encrypt: addHexPrefix(pair.crypt.public),
90 auth: addHexPrefix(pair.auth.public),
91 cryptoSuite: String(CRYPTO_SUITE_VERSION),
95 const hash = await api.hashTransaction(nonce, from, 'configureKeys', data);
96 const sig = signTransactionHash(hash, _wallet.privateKey);
97 return api.configureKeys(sig, from, _wallet.address, data);
100export const transferPoint = async (
109 ship: _point, // ship to transfer
118 const hash = await api.hashTransaction(nonce, from, 'transferPoint', data);
119 const sig = signTransactionHash(hash, _wallet.privateKey);
120 return api.transferPoint(sig, from, _wallet.address, data);
123export const hasPoint = (point: number) => (invite: Invite) =>
124 invite.planet === point;
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