@@ -4,16 +4,11 @@ import * as need from 'lib/need';
44import * as ob from 'urbit-ob';
55import * as wg from 'lib/walletgen';
66
7−import { addHexPrefix } from 'lib/utils/address';
87import { convertToInt } from './convertToInt';
98import { ensureHexPrefix } from 'form/formatters';
109import { getOutgoingPoints, maybeGetResult } from 'views/Points';
11−import { getTimeToNextBatch } from './utils/roller';
12−import { Invite } from 'types/Invite';
1310import { isDevelopment, isRopsten } from './flags';
1411import { isPlanet } from './utils/point';
15−import { Just } from 'folktale/maybe';
16−import { randomHex } from 'web3-utils';
1712import { ROLLER_HOSTS } from './constants';
1813import { signTransactionHash } from './authToken';
1914import { useNetwork } from 'store/network';
@@ -23,7 +18,6 @@ import { useRollerStore } from 'store/roller';
2318import { useWallet } from 'store/wallet';
2419
2520import {
26− attemptNetworkSeedDerivation,
2721 deriveNetworkKeys,
2822 CRYPTO_SUITE_VERSION,
2923 deriveNetworkSeedFromUrbitWallet,
@@ -42,105 +36,19 @@ import {
4236 Hash,
4337} from '@urbit/roller-api';
4438
39+import {
40+ configureKeys,
41+ getTimeToNextBatch,
42+ spawn,
43+ transferPoint,
44+} from './utils/roller';
45+
4546import {
4647 getStoredInvites,
4748 setPendingInvites,
4849 setStoredInvites,
4950} from 'store/storage/roller';
5051
51−const spawn = async (
52− api: any,
53− _wallet: any,
54− _point: number,
55− proxy: string,
56− nonce: number,
57− planet: number
58−) => {
59− const from = {
60− ship: _point, //ship that is spawning the planet
61− proxy,
62− };
63−
64− const data = {
65− address: _wallet.address,
66− ship: planet, // ship to spawn
67− };
68−
69− const hash = await api.hashTransaction(nonce, from, 'spawn', data);
70− const sSig = signTransactionHash(hash, _wallet.privateKey);
71− return api.spawn(sSig, from, _wallet.address, data);
72−};
73−
74−const configureKeys = async (
75− api: any,
76− _wallet: any,
77− _point: number,
78− proxy: string,
79− nonce: number,
80− details: any,
81− authToken: string,
82− authMnemonic: string,
83− wallet: any,
84− urbitWallet: any
85−) => {
86− const from = {
87− ship: _point, //ship that is spawning the planet
88− proxy,
89− };
90−
91− const networkSeed = await attemptNetworkSeedDerivation({
92− urbitWallet,
93− wallet,
94− authMnemonic,
95− details,
96− point: _point,
97− authToken,
98− revision: 1,
99− });
100−
101− const seed = Just.hasInstance(networkSeed)
102− ? networkSeed.value
103− : randomHex(32);
104−
105− const pair = deriveNetworkKeys(seed);
106−
107− const data = {
108− encrypt: addHexPrefix(pair.crypt.public),
109− auth: addHexPrefix(pair.auth.public),
110− cryptoSuite: String(CRYPTO_SUITE_VERSION),
111− breach: false,
112− };
113−
114− const hash = await api.hashTransaction(nonce, from, 'configureKeys', data);
115− const sig = signTransactionHash(hash, _wallet.privateKey);
116− return api.configureKeys(sig, from, _wallet.address, data);
117−};
118−
119−const transferPoint = async (
120− api: any,
121− _wallet: any,
122− _point: number,
123− proxy: string,
124− nonce: number,
125− address: string
126−) => {
127− const from = {
128− ship: _point, //ship that is spawning the planet
129− proxy,
130− };
131−
132− const data = {
133− address,
134− reset: false,
135− };
136−
137− const hash = await api.hashTransaction(nonce, from, 'transferPoint', data);
138− const sig = signTransactionHash(hash, _wallet.privateKey);
139− return api.transferPoint(sig, from, _wallet.address, data);
140−};
141−
142−const hasPoint = (point: number) => (invite: Invite) => invite.planet === point;
143−
14452const getProxyAndNonce = (
14553 point: L2Point,
14654 address: string
@@ -277,7 +185,7 @@ export default function useRoller() {
277185 const transferPointRequest = await transferPoint(
278186 api,
279187 _wallet,
280− _point,
188+ planet,
281189 proxy,
282190 nonceInc + 2,
283191 owner.keys.address