@@ -28,6 +28,7 @@ import {
2828 getSpawnNonce,
2929 getOwnerNonce,
3030 getManagementNonce,
31+ getTransferNonce,
3132} from './utils/nonce';
3233import { isPlanet } from './utils/point';
3334
@@ -55,7 +56,7 @@ import {
5556 configureKeys,
5657 getTimeToNextBatch,
5758 spawn,
58− transferPoint,
59+ transferPointRequest,
5960 registerProxyAddress,
6061} from './utils/roller';
6162
@@ -219,7 +220,7 @@ export default function useRoller() {
219220 inviteWallet.management.keys.address
220221 );
221222
222− const transferPointRequest = await transferPoint(
223+ const transferRequest = await transferPointRequest(
223224 api,
224225 _wallet,
225226 planet,
@@ -232,7 +233,7 @@ export default function useRoller() {
232233 spawnRequest,
233234 configureKeysRequest,
234235 setManagementProxyRequest,
235− transferPointRequest
236+ transferRequest
236237 );
237238 tickets.push({
238239 ticket,
@@ -475,7 +476,7 @@ export default function useRoller() {
475476 );
476477
477478 const keysSigningKey = fromWallet.privateKey;
478− await api.configureKeys(
479+ const configureKeysRequest = await api.configureKeys(
479480 signTransactionHash(keysHash, Buffer.from(keysSigningKey, 'hex')),
480481 fromOwnerProxy,
481482 ownerAddress,
@@ -486,7 +487,7 @@ export default function useRoller() {
486487 // increaseNonce(point, operator.proxy!);
487488
488489 // 2. Set Management Proxy
489− await registerProxyAddress(
490+ const registerProxyAddressRequest = await registerProxyAddress(
490491 api,
491492 fromWallet,
492493 point,
@@ -497,27 +498,24 @@ export default function useRoller() {
497498 );
498499
499500 // 3. Transfer point
500− const transferData = { address: to, reset: false };
501− const transferHash: Hash = await api.hashTransaction(
501+ const transferTxRequest = await transferPointRequest(
502+ api,
503+ fromWallet,
504+ point,
505+ operator.proxy!,
502506 nonce + 2,
503− fromOwnerProxy,
504− 'transferPoint',
505− transferData
507+ to
506508 );
507−
508− const transferTxHash = await api.transferPoint(
509− signTransactionHash(transferHash, Buffer.from(keysSigningKey, 'hex')),
510− fromOwnerProxy,
511− ownerAddress,
512− transferData
513− );
514−
515− return transferTxHash;
509+ const hashes = await Promise.all([
510+ configureKeysRequest,
511+ registerProxyAddressRequest,
512+ transferTxRequest,
513+ ]);
514+ return hashes;
516515 };
517516
518517 const setProxyAddress = useCallback(
519518 async (proxyType: Proxy, address: EthAddress) => {
520− console.log(proxyType, address);
521519 const _point = need.point(pointCursor);
522520 const _wallet = wallet.getOrElse(null);
523521
@@ -551,6 +549,40 @@ export default function useRoller() {
551549 [api, pointCursor, wallet, nonces]
552550 );
553551
552+ const transferPoint = useCallback(
553+ async (address: EthAddress, reset?: boolean) => {
554+ const _point = need.point(pointCursor);
555+ const _wallet = wallet.getOrElse(null);
556+
557+ if (!_wallet) {
558+ // not using need because we want a custom error
559+ throw new Error('Internal Error: Missing Wallet');
560+ }
561+
562+ const pointDetails = nonces[_point];
563+ const operator =
564+ getTransferNonce(pointDetails, _wallet.address) ||
565+ getOwnerNonce(pointDetails, _wallet.address);
566+
567+ if (operator === undefined)
568+ throw new Error("Error: Address doesn't match proxy");
569+
570+ const txHash = await transferPointRequest(
571+ api,
572+ _wallet,
573+ _point,
574+ operator.proxy!,
575+ operator.nonce!,
576+ address,
577+ reset || false
578+ );
579+ const pendingTx = await api.getPendingTx(txHash);
580+
581+ return pendingTx;
582+ },
583+ [api, pointCursor, wallet, nonces]
584+ );
585+
554586 // On load, get initial config
555587 useEffect(() => {
556588 if (config) {