on master help sign in
set-proxies: show l1/l2 tx from dominion & action
99a3edeyosoyubik
src/lib/utils/roller.ts+2
@@ -40,6 +40,8 @@ export const getTimeToNextBatch = (nextBatch: number, now: number) => {
40
40
41export const isL2 = (dom?: string) => dom === 'l2' || dom === 'spawn';
41export const isL2 = (dom?: string) => dom === 'l2' || dom === 'spawn';
42
42
43+export const isL2Spawn = (dom?: string) => dom === 'spawn';
44+
43export const generateInviteWallet = async (point: number, seed: string) => {
45export const generateInviteWallet = async (point: number, seed: string) => {
44 const ticket = makeDeterministicTicket(point, seed);
46 const ticket = makeDeterministicTicket(point, seed);
45 const inviteWallet = await generateWallet(point, ticket, true);
47 const inviteWallet = await generateWallet(point, ticket, true);
src/store/lib/useDetailsStore.ts+6−6
@@ -19,12 +19,12 @@ const toL1Details = (point: L2Point): L1Point => {
19 escapeRequestedTo: point.network.escape,
19 escapeRequestedTo: point.network.escape,
20 hasSponsor: point.network.sponsor.has,
20 hasSponsor: point.network.sponsor.has,
21 keyRevisionNumber: point.network.keys.life,
21 keyRevisionNumber: point.network.keys.life,
22− managementProxy: point.ownership.managementProxy.address,
22+ managementProxy: point.ownership?.managementProxy?.address!,
23− owner: point.ownership.owner.address,
23+ owner: point.ownership?.owner?.address!,
24− spawnProxy: point.ownership.spawnProxy.address,
24+ spawnProxy: point.ownership?.spawnProxy?.address!,
25 sponsor: point.network.sponsor.who,
25 sponsor: point.network.sponsor.who,
26− transferProxy: point.ownership.transferProxy.address,
26+ transferProxy: point.ownership?.transferProxy?.address!,
27− votingProxy: point.ownership.votingProxy.address,
27+ votingProxy: point.ownership?.votingProxy?.address!,
28 };
28 };
29};
29};
30
30
@@ -59,7 +59,7 @@ export default function useDetailsStore() {
59 // fetch point details
59 // fetch point details
60 const l2Point = await api.getPoint(point);
60 const l2Point = await api.getPoint(point);
61 const details =
61 const details =
62− l2Point && l2Point.dominion === 'l2'
62+ l2Point && (l2Point.dominion === 'l2' || l2Point.dominion === 'spawn')
63 ? toL1Details(l2Point)
63 ? toL1Details(l2Point)
64 : await azimuth.azimuth.getPoint(_contracts, point);
64 : await azimuth.azimuth.getPoint(_contracts, point);
65 addToDetails({
65 addToDetails({
src/store/roller.ts+8−2
@@ -1,7 +1,7 @@
1import create from 'zustand';
1import create from 'zustand';
2import { L2Point, PendingTransaction, Ownership } from '@urbit/roller-api';
2import { L2Point, PendingTransaction, Ownership } from '@urbit/roller-api';
3
3
4−import { HOUR, isL2 } from 'lib/utils/roller';
4+import { HOUR, isL2, isL2Spawn } from 'lib/utils/roller';
5import { increaseProxyNonce, setProxyNonce } from 'lib/utils/nonce';
5import { increaseProxyNonce, setProxyNonce } from 'lib/utils/nonce';
6import { Invite } from 'lib/types/Invite';
6import { Invite } from 'lib/types/Invite';
7
7
@@ -11,6 +11,7 @@ export interface RollerStore {
11 pendingTransactions: PendingTransaction[];
11 pendingTransactions: PendingTransaction[];
12 currentPoint: L2Point | null;
12 currentPoint: L2Point | null;
13 currentL2: boolean;
13 currentL2: boolean;
14+ currentL2Spawn: boolean;
14 nonces: {
15 nonces: {
15 [point: number]: Ownership;
16 [point: number]: Ownership;
16 };
17 };
@@ -37,6 +38,7 @@ export const useRollerStore = create<RollerStore>(set => ({
37 pendingTransactions: [],
38 pendingTransactions: [],
38 currentPoint: null,
39 currentPoint: null,
39 currentL2: false,
40 currentL2: false,
41+ currentL2Spawn: false,
40 invites: [],
42 invites: [],
41 recentlyCompleted: 0,
43 recentlyCompleted: 0,
42 nonces: {},
44 nonces: {},
@@ -51,7 +53,10 @@ export const useRollerStore = create<RollerStore>(set => ({
51 set(state => {
53 set(state => {
52 const updatedOwner = setProxyNonce(owner, proxy, nonce);
54 const updatedOwner = setProxyNonce(owner, proxy, nonce);
53 if (!updatedOwner) throw new Error("Can't set nonce for this proxy");
55 if (!updatedOwner) throw new Error("Can't set nonce for this proxy");
56+ return {
57+ ...state,
54− return { ...state, nonces: { ...state.nonces, [point]: updatedOwner } };
58+ nonces: { ...state.nonces, [point]: updatedOwner },
59+ };
55 }),
60 }),
56 setNonces: (point: number, owner: Ownership) =>
61 setNonces: (point: number, owner: Ownership) =>
57 set(state => {
62 set(state => {
@@ -75,6 +80,7 @@ export const useRollerStore = create<RollerStore>(set => ({
75 set(() => ({
80 set(() => ({
76 currentPoint,
81 currentPoint,
77 currentL2: isL2(currentPoint?.dominion),
82 currentL2: isL2(currentPoint?.dominion),
83+ currentL2Spawn: isL2Spawn(currentPoint?.dominion),
78 })),
84 })),
79 setInvites: (invites: Invite[]) => set(() => ({ invites })),
85 setInvites: (invites: Invite[]) => set(() => ({ invites })),
80}));
86}));
src/views/UrbitID/Home.js−1
@@ -53,7 +53,6 @@ export default function UrbitIDHome() {
53
53
54 const renderProxyAction = useCallback(
54 const renderProxyAction = useCallback(
55 (proxyType, address) => {
55 (proxyType, address) => {
56− console.log(details);
57 const disabled =
56 const disabled =
58 !isOwner ||
57 !isOwner ||
59 (proxyType === PROXY_TYPE.SPAWN ? networkRevision === 0 : false);
58 (proxyType === PROXY_TYPE.SPAWN ? networkRevision === 0 : false);
src/views/UrbitID/SetProxy.js+12−4
@@ -110,7 +110,7 @@ export default function SetProxy() {
110 const { getDetails } = usePointCache();
110 const { getDetails } = usePointCache();
111 const { pointCursor } = usePointCursor();
111 const { pointCursor } = usePointCursor();
112 const { contracts } = useNetwork();
112 const { contracts } = useNetwork();
113− const { currentL2 } = useRollerStore();
113+ const { currentL2, currentL2Spawn } = useRollerStore();
114 const { setProxyAddress, getPendingTransactions } = useRoller();
114 const { setProxyAddress, getPendingTransactions } = useRoller();
115 const [newAddress, setNewAddress] = useState('');
115 const [newAddress, setNewAddress] = useState('');
116
116
@@ -120,6 +120,15 @@ export default function SetProxy() {
120
120
121 const properProxyType = capitalize(proxyTypeToHuman(data.proxyType));
121 const properProxyType = capitalize(proxyTypeToHuman(data.proxyType));
122
122
123+ const txType =
124+ data.proxyType === 'MANAGEMENT' && (currentL2Spawn || !currentL2)
125+ ? 'ETH_TX'
126+ : data.proxyType === 'MANAGEMENT' && currentL2 && !currentL2Spawn
127+ ? 'L2'
128+ : data.proxyType === 'SPAWN' && currentL2
129+ ? 'L2'
130+ : 'ETH_TX';
131+
123 const {
132 const {
124 construct,
133 construct,
125 unconstruct,
134 unconstruct,
@@ -172,7 +181,6 @@ export default function SetProxy() {
172
181
173 const onValues = useCallback(
182 const onValues = useCallback(
174 ({ valid, values, form }) => {
183 ({ valid, values, form }) => {
175− console.log('currentL2', currentL2);
176 if (valid) {
184 if (valid) {
177 if (values.unset) {
185 if (values.unset) {
178 unset();
186 unset();
@@ -186,7 +194,7 @@ export default function SetProxy() {
186 unconstruct();
194 unconstruct();
187 }
195 }
188 },
196 },
189− [construct, unconstruct, unset, setNewAddress, currentL2]
197+ [construct, unconstruct, unset, setNewAddress]
190 );
198 );
191
199
192 const initialValues = useMemo(() => ({ unset: false }), []);
200 const initialValues = useMemo(() => ({ unset: false }), []);
@@ -255,7 +263,7 @@ export default function SetProxy() {
255
263
256 <Grid.Item full as={FormError} />
264 <Grid.Item full as={FormError} />
257
265
258− {currentL2 ? (
266+ {txType === 'L2' ? (
259 <Grid.Item
267 <Grid.Item
260 as={Button}
268 as={Button}
261 full
269 full