on master help sign in
transfer: use setTransferProxy in Transfer.js
355856byosoyubik
src/lib/utils/proxy.ts+4−3
@@ -1,13 +1,14 @@
1import { Ownership } from '@urbit/roller-api';
1import { Ownership } from '@urbit/roller-api';
2
2
3+// TODO: test when all proxies are configured to the same address
3export const getProxy = (
4export const getProxy = (
4 owner: Ownership,
5 owner: Ownership,
5 address: string
6 address: string
6): string | undefined =>
7): string | undefined =>
7− owner.managementProxy?.address === address
8− ? 'manage'
9− : owner.owner?.address === address
8+ owner.owner?.address === address
10 ? 'own'
9 ? 'own'
10+ : owner.managementProxy?.address === address
11+ ? 'manage'
11 : owner.spawnProxy?.address === address
12 : owner.spawnProxy?.address === address
12 ? 'spawn'
13 ? 'spawn'
13 : owner.votingProxy?.address === address
14 : owner.votingProxy?.address === address
src/lib/utils/roller.ts+13−12
@@ -3,7 +3,7 @@ import { Invite } from 'lib/types/Invite';
3import { Just, Nothing } from 'folktale/maybe';
3import { Just, Nothing } from 'folktale/maybe';
4import { randomHex } from 'web3-utils';
4import { randomHex } from 'web3-utils';
5
5
6−import {
6+import RollerRPCAPI, {
7 Proxy,
7 Proxy,
8 Signature,
8 Signature,
9 From,
9 From,
@@ -49,7 +49,7 @@ export const generateInviteWallet = async (point: number, seed: string) => {
49};
49};
50
50
51export const spawn = async (
51export const spawn = async (
52− api: any,
52+ api: RollerRPCAPI,
53 _wallet: any,
53 _wallet: any,
54 _point: number,
54 _point: number,
55 proxy: string,
55 proxy: string,
@@ -72,7 +72,7 @@ export const spawn = async (
72};
72};
73
73
74export const configureKeys = async (
74export const configureKeys = async (
75− api: any,
75+ api: RollerRPCAPI,
76 wallet: any,
76 wallet: any,
77 point: Ship,
77 point: Ship,
78 proxy: string,
78 proxy: string,
@@ -110,7 +110,7 @@ export const configureKeys = async (
110};
110};
111
111
112export const transferPointRequest = async (
112export const transferPointRequest = async (
113− api: any,
113+ api: RollerRPCAPI,
114 _wallet: any,
114 _wallet: any,
115 _point: Ship,
115 _point: Ship,
116 proxy: string,
116 proxy: string,
@@ -146,7 +146,7 @@ const proxyType = (proxy: Proxy) => {
146};
146};
147
147
148const setProxy = async (
148const setProxy = async (
149− api: any,
149+ api: RollerRPCAPI,
150 proxyAddressType: string,
150 proxyAddressType: string,
151 sig: Signature,
151 sig: Signature,
152 from: From,
152 from: From,
@@ -159,14 +159,14 @@ const setProxy = async (
159 case 'spawn':
159 case 'spawn':
160 return await api.setSpawnProxy(sig, from, address, data);
160 return await api.setSpawnProxy(sig, from, address, data);
161 case 'transfer':
161 case 'transfer':
162− return await api.setTrasferProxy(sig, from, address, data);
162+ return await api.setTransferProxy(sig, from, address, data);
163 default:
163 default:
164 throw new Error(`Unknown proxyType ${proxyAddressType}`);
164 throw new Error(`Unknown proxyType ${proxyAddressType}`);
165 }
165 }
166};
166};
167
167
168export const registerProxyAddress = async (
168export const registerProxyAddress = async (
169− api: any,
169+ api: RollerRPCAPI,
170 _wallet: any,
170 _wallet: any,
171 _point: Ship,
171 _point: Ship,
172 proxy: string,
172 proxy: string,
@@ -178,20 +178,21 @@ export const registerProxyAddress = async (
178 ship: _point,
178 ship: _point,
179 proxy,
179 proxy,
180 };
180 };
181− const managementData = { address };
181+ const proxyData = { address };
182− const managementHash = await api.hashTransaction(
182+ const proxyHash = await api.hashTransaction(
183 nonce,
183 nonce,
184 from,
184 from,
185 proxyType(proxyAddressType),
185 proxyType(proxyAddressType),
186− managementData
186+ proxyData
187 );
187 );
188+
188 return setProxy(
189 return setProxy(
189 api,
190 api,
190 proxyAddressType,
191 proxyAddressType,
191− signTransactionHash(managementHash, _wallet.privateKey),
192+ signTransactionHash(proxyHash, _wallet.privateKey),
192 from,
193 from,
193 _wallet.address,
194 _wallet.address,
194− managementData
195+ proxyData
195 );
196 );
196};
197};
197
198
src/views/Point/Point.tsx+2
@@ -189,6 +189,8 @@ export default function Point() {
189 ? 'Network Keys Configured'
189 ? 'Network Keys Configured'
190 : pendingTx.rawTx?.tx?.type === 'transfer-point'
190 : pendingTx.rawTx?.tx?.type === 'transfer-point'
191 ? 'Point Transfered'
191 ? 'Point Transfered'
192+ : pendingTx.rawTx?.tx?.type === 'set-transfer-proxy'
193+ ? 'Transfer Proxy Changed'
192 : ''}
194 : ''}
193 </div>
195 </div>
194 <div className="rollup-timer">
196 <div className="rollup-timer">
src/views/UrbitID/Transfer.js+3−3
@@ -48,7 +48,7 @@ export default function AdminTransfer() {
48 const { pointCursor } = usePointCursor();
48 const { pointCursor } = usePointCursor();
49 const { starReleaseDetails } = useStarReleaseCache();
49 const { starReleaseDetails } = useStarReleaseCache();
50 const { currentL2 } = useRollerStore();
50 const { currentL2 } = useRollerStore();
51− const { transferPoint, getPendingTransactions } = useRoller();
51+ const { setProxyAddress, getPendingTransactions } = useRoller();
52 const [owner, setNewOwner] = useState('');
52 const [owner, setNewOwner] = useState('');
53
53
54 const {
54 const {
@@ -78,7 +78,7 @@ export default function AdminTransfer() {
78 // setLoading(true);
78 // setLoading(true);
79 if (owner === '') return;
79 if (owner === '') return;
80 try {
80 try {
81− await transferPoint(owner);
81+ await setProxyAddress('transfer', owner);
82 getPendingTransactions(point);
82 getPendingTransactions(point);
83 pop();
83 pop();
84 } catch (error) {
84 } catch (error) {
@@ -86,7 +86,7 @@ export default function AdminTransfer() {
86 } finally {
86 } finally {
87 // setLoading(false);
87 // setLoading(false);
88 }
88 }
89− }, [owner, getPendingTransactions, point, pop, transferPoint]);
89+ }, [owner, getPendingTransactions, point, pop, setProxyAddress]);
90
90
91 const onValues = useCallback(
91 const onValues = useCallback(
92 ({ valid, values }) => {
92 ({ valid, values }) => {