@@ -28,6 +28,7 @@ import {
28 getSpawnNonce,
28 getSpawnNonce,
29 getOwnerNonce,
29 getOwnerNonce,
30 getManagementNonce,
30 getManagementNonce,
31} from './utils/nonce';
32} from './utils/nonce';
32import { isPlanet } from './utils/point';
33import { isPlanet } from './utils/point';
@@ -55,7 +56,7 @@ import {
55 configureKeys,
56 configureKeys,
56 getTimeToNextBatch,
57 getTimeToNextBatch,
58− transferPoint,
59+ transferPointRequest,
59 registerProxyAddress,
60 registerProxyAddress,
60} from './utils/roller';
61} from './utils/roller';
@@ -219,7 +220,7 @@ export default function useRoller() {
219 inviteWallet.management.keys.address
220 inviteWallet.management.keys.address
222− const transferPointRequest = await transferPoint(
223+ const transferRequest = await transferPointRequest(
@@ -232,7 +233,7 @@ export default function useRoller() {
232 spawnRequest,
233 spawnRequest,
233 configureKeysRequest,
234 configureKeysRequest,
234 setManagementProxyRequest,
235 setManagementProxyRequest,
235− transferPointRequest
236+ transferRequest
237 tickets.push({
238 tickets.push({
@@ -475,7 +476,7 @@ export default function useRoller() {
477 const keysSigningKey = fromWallet.privateKey;
478 const keysSigningKey = fromWallet.privateKey;
478− await api.configureKeys(
479+ const configureKeysRequest = await api.configureKeys(
479 signTransactionHash(keysHash, Buffer.from(keysSigningKey, 'hex')),
480 signTransactionHash(keysHash, Buffer.from(keysSigningKey, 'hex')),
480 fromOwnerProxy,
481 fromOwnerProxy,
481 ownerAddress,
482 ownerAddress,
@@ -486,7 +487,7 @@ export default function useRoller() {
486 // increaseNonce(point, operator.proxy!);
487 // increaseNonce(point, operator.proxy!);
488 // 2. Set Management Proxy
489 // 2. Set Management Proxy
489− await registerProxyAddress(
490+ const registerProxyAddressRequest = await registerProxyAddress(
491 fromWallet,
492 fromWallet,
@@ -497,27 +498,24 @@ export default function useRoller() {
499 // 3. Transfer point
500 // 3. Transfer point
500− const transferData = { address: to, reset: false };
501+ const transferTxRequest = await transferPointRequest(
501− const transferHash: Hash = await api.hashTransaction(
502+ api,
502 nonce + 2,
506 nonce + 2,
503− fromOwnerProxy,
507+ to
507−
509+ const hashes = await Promise.all([
508− const transferTxHash = await api.transferPoint(
510+ configureKeysRequest,
509− signTransactionHash(transferHash, Buffer.from(keysSigningKey, 'hex')),
511+ registerProxyAddressRequest,
510− fromOwnerProxy,
512+ transferTxRequest,
515− return transferTxHash;
518 const setProxyAddress = useCallback(
517 const setProxyAddress = useCallback(
519 async (proxyType: Proxy, address: EthAddress) => {
518 async (proxyType: Proxy, address: EthAddress) => {
520− console.log(proxyType, address);
521 const _point = need.point(pointCursor);
519 const _point = need.point(pointCursor);
522 const _wallet = wallet.getOrElse(null);
520 const _wallet = wallet.getOrElse(null);
@@ -551,6 +549,40 @@ export default function useRoller() {
551 [api, pointCursor, wallet, nonces]
549 [api, pointCursor, wallet, nonces]
552+ const transferPoint = useCallback(
553+ async (address: EthAddress, reset?: boolean) => {
554+ const _point = need.point(pointCursor);
555+ const _wallet = wallet.getOrElse(null);
558+ // not using need because we want a custom error
559+ throw new Error('Internal Error: Missing Wallet');
562+ const pointDetails = nonces[_point];
564+ getTransferNonce(pointDetails, _wallet.address) ||
565+ getOwnerNonce(pointDetails, _wallet.address);
567+ if (operator === undefined)
568+ throw new Error("Error: Address doesn't match proxy");
570+ const txHash = await transferPointRequest(
579+ const pendingTx = await api.getPendingTx(txHash);
583+ [api, pointCursor, wallet, nonces]
554 // On load, get initial config
586 // On load, get initial config
555 useEffect(() => {
587 useEffect(() => {
556 if (config) {
588 if (config) {