on master help sign in
set-proxies: show l1/l2 tx from dominion & action
commit99a3edeee38162e176b186ac2ad4e8aec37debc2 authoryosoyubik <yosoyubik@gmail.com> dateTue 28 Sep 2021, 05:20 (5 years ago) parent67d9ca6
5 files changed+28−13
src/lib/utils/roller.ts+2 src/store/lib/useDetailsStore.ts+6−6 src/store/roller.ts+8−2 src/views/UrbitID/Home.js−1 src/views/UrbitID/SetProxy.js+12−4
src/lib/utils/roller.ts+2
@@ -40,6 +40,8 @@ export const getTimeToNextBatch = (nextBatch: number, now: number) => {
4040
4141export const isL2 = (dom?: string) => dom === 'l2' || dom === 'spawn';
4242
43+export const isL2Spawn = (dom?: string) => dom === 'spawn';
44+
4345export const generateInviteWallet = async (point: number, seed: string) => {
4446 const ticket = makeDeterministicTicket(point, seed);
4547 const inviteWallet = await generateWallet(point, ticket, true);
src/store/lib/useDetailsStore.ts+6−6
@@ -19,12 +19,12 @@ const toL1Details = (point: L2Point): L1Point => {
1919 escapeRequestedTo: point.network.escape,
2020 hasSponsor: point.network.sponsor.has,
2121 keyRevisionNumber: point.network.keys.life,
22− managementProxy: point.ownership.managementProxy.address,
23− owner: point.ownership.owner.address,
24− spawnProxy: point.ownership.spawnProxy.address,
22+ managementProxy: point.ownership?.managementProxy?.address!,
23+ owner: point.ownership?.owner?.address!,
24+ spawnProxy: point.ownership?.spawnProxy?.address!,
2525 sponsor: point.network.sponsor.who,
26− transferProxy: point.ownership.transferProxy.address,
27− votingProxy: point.ownership.votingProxy.address,
26+ transferProxy: point.ownership?.transferProxy?.address!,
27+ votingProxy: point.ownership?.votingProxy?.address!,
2828 };
2929};
3030
@@ -59,7 +59,7 @@ export default function useDetailsStore() {
5959 // fetch point details
6060 const l2Point = await api.getPoint(point);
6161 const details =
62− l2Point && l2Point.dominion === 'l2'
62+ l2Point && (l2Point.dominion === 'l2' || l2Point.dominion === 'spawn')
6363 ? toL1Details(l2Point)
6464 : await azimuth.azimuth.getPoint(_contracts, point);
6565 addToDetails({
src/store/roller.ts+8−2
@@ -1,7 +1,7 @@
11import create from 'zustand';
22import { L2Point, PendingTransaction, Ownership } from '@urbit/roller-api';
33
4−import { HOUR, isL2 } from 'lib/utils/roller';
4+import { HOUR, isL2, isL2Spawn } from 'lib/utils/roller';
55import { increaseProxyNonce, setProxyNonce } from 'lib/utils/nonce';
66import { Invite } from 'lib/types/Invite';
77
@@ -11,6 +11,7 @@ export interface RollerStore {
1111 pendingTransactions: PendingTransaction[];
1212 currentPoint: L2Point | null;
1313 currentL2: boolean;
14+ currentL2Spawn: boolean;
1415 nonces: {
1516 [point: number]: Ownership;
1617 };
@@ -37,6 +38,7 @@ export const useRollerStore = create<RollerStore>(set => ({
3738 pendingTransactions: [],
3839 currentPoint: null,
3940 currentL2: false,
41+ currentL2Spawn: false,
4042 invites: [],
4143 recentlyCompleted: 0,
4244 nonces: {},
@@ -51,7 +53,10 @@ export const useRollerStore = create<RollerStore>(set => ({
5153 set(state => {
5254 const updatedOwner = setProxyNonce(owner, proxy, nonce);
5355 if (!updatedOwner) throw new Error("Can't set nonce for this proxy");
54− return { ...state, nonces: { ...state.nonces, [point]: updatedOwner } };
56+ return {
57+ ...state,
58+ nonces: { ...state.nonces, [point]: updatedOwner },
59+ };
5560 }),
5661 setNonces: (point: number, owner: Ownership) =>
5762 set(state => {
@@ -75,6 +80,7 @@ export const useRollerStore = create<RollerStore>(set => ({
7580 set(() => ({
7681 currentPoint,
7782 currentL2: isL2(currentPoint?.dominion),
83+ currentL2Spawn: isL2Spawn(currentPoint?.dominion),
7884 })),
7985 setInvites: (invites: Invite[]) => set(() => ({ invites })),
8086}));
src/views/UrbitID/Home.js−1
@@ -53,7 +53,6 @@ export default function UrbitIDHome() {
5353
5454 const renderProxyAction = useCallback(
5555 (proxyType, address) => {
56− console.log(details);
5756 const disabled =
5857 !isOwner ||
5958 (proxyType === PROXY_TYPE.SPAWN ? networkRevision === 0 : false);
src/views/UrbitID/SetProxy.js+12−4
@@ -110,7 +110,7 @@ export default function SetProxy() {
110110 const { getDetails } = usePointCache();
111111 const { pointCursor } = usePointCursor();
112112 const { contracts } = useNetwork();
113− const { currentL2 } = useRollerStore();
113+ const { currentL2, currentL2Spawn } = useRollerStore();
114114 const { setProxyAddress, getPendingTransactions } = useRoller();
115115 const [newAddress, setNewAddress] = useState('');
116116
@@ -120,6 +120,15 @@ export default function SetProxy() {
120120
121121 const properProxyType = capitalize(proxyTypeToHuman(data.proxyType));
122122
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+
123132 const {
124133 construct,
125134 unconstruct,
@@ -172,7 +181,6 @@ export default function SetProxy() {
172181
173182 const onValues = useCallback(
174183 ({ valid, values, form }) => {
175− console.log('currentL2', currentL2);
176184 if (valid) {
177185 if (values.unset) {
178186 unset();
@@ -186,7 +194,7 @@ export default function SetProxy() {
186194 unconstruct();
187195 }
188196 },
189− [construct, unconstruct, unset, setNewAddress, currentL2]
197+ [construct, unconstruct, unset, setNewAddress]
190198 );
191199
192200 const initialValues = useMemo(() => ({ unset: false }), []);
@@ -255,7 +263,7 @@ export default function SetProxy() {
255263
256264 <Grid.Item full as={FormError} />
257265
258− {currentL2 ? (
266+ {txType === 'L2' ? (
259267 <Grid.Item
260268 as={Button}
261269 full