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';
12 makeDeterministicTicket,
13 generateOwnershipWallet,
14} from 'lib/walletgen';
16export const SECOND = 1000;
17export const MINUTE = SECOND * 60;
18export const HOUR = MINUTE * 60;
20export const padZero = (amount: number) =>
21 `${amount < 10 && amount > 0 ? '0' : ''}${amount}`;
23export const getTimeToNextBatch = (nextBatch: number, now: number) => {
24 const toNext = nextBatch - now;
25 const hours = Math.floor(toNext / HOUR);
26 const minutes = Math.floor((toNext - hours * HOUR) / MINUTE);
27 const seconds = Math.floor(
28 (toNext - hours * HOUR - minutes * MINUTE) / SECOND
31 return `${padZero(hours)}h ${padZero(minutes)}m ${padZero(seconds)}s`;
34export const isL2 = (dom?: string) => dom === 'l2' || dom === 'spawn';
36export const generateInviteWallet = async (point: number, seed: string) => {
37 const ticket = makeDeterministicTicket(point, seed);
38 const owner = await generateOwnershipWallet(point, ticket);
40 return { ticket, owner };
43export const spawn = async (
52 ship: _point, //ship that is spawning the planet
57 address: _wallet.address,
58 ship: planet, // ship to spawn
61 const hash = await api.hashTransaction(nonce, from, 'spawn', data);
62 const sSig = signTransactionHash(hash, _wallet.privateKey);
63 return api.spawn(sSig, from, _wallet.address, data);
66export const configureKeys = async (
79 ship: _point, //ship to configure keys
83 const networkSeed = await attemptNetworkSeedDerivation({
93 const seed = Just.hasInstance(networkSeed)
97 const pair = deriveNetworkKeys(seed);
100 encrypt: addHexPrefix(pair.crypt.public),
101 auth: addHexPrefix(pair.auth.public),
102 cryptoSuite: String(CRYPTO_SUITE_VERSION),
106 const hash = await api.hashTransaction(nonce, from, 'configureKeys', data);
107 const sig = signTransactionHash(hash, _wallet.privateKey);
108 return api.configureKeys(sig, from, _wallet.address, data);
111export const transferPoint = async (
120 ship: _point, // ship to transfer
129 const hash = await api.hashTransaction(nonce, from, 'transferPoint', data);
130 const sig = signTransactionHash(hash, _wallet.privateKey);
131 return api.transferPoint(sig, from, _wallet.address, data);
134export const hasPoint = (point: number) => (invite: Invite) =>
135 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