1import { EthAddress, Ship } from '@urbit/roller-api';
2import { useCallback } from 'react';
3import Web3 from 'web3';
4import { ITxData } from '@walletconnect/types';
5import { INITIAL_NETWORK_KEY_REVISION } from './constants';
6import { reticketPointBetweenWallets } from './reticket';
7import BridgeWallet from './types/BridgeWallet';
8import { ReticketProgressCallback } from './types/L2Transaction';
9import useRoller from './useRoller';
10import { registerProxyAddress } from './utils/roller';
11import { useWallet } from 'store/wallet';
12import { useWalletConnect } from './useWalletConnect';
14interface ReticketL2SpawnParams {
15 fromWallet: BridgeWallet;
16 fromWalletType: symbol;
17 fromWalletHdPath: string;
18 toWallet: UrbitWallet;
21 contracts: any; // azimuth contracts
23 onUpdate?: ReticketProgressCallback;
24 transferEth?: boolean;
35 }: ITxData) => Promise<string>;
44 }: ITxData) => Promise<string>;
48 * This hook is used to reticket points that are still on L1 but have the
49 * spawn set to L2. It first performs 3-4 L1 transactions (set keys, set
50 * management / voting proxy, and transfer).
52 * It then sets the spawn proxy using an L2 transaction.
54 * Under the hood, it wraps two existing functions:
55 * `reticketPointBetweenWallets` for L1, and `registerProxyAddress` for L2.
58export const useReticketL2Spawn = () => {
59 const { api } = useRoller();
60 const { walletType }: any = useWallet();
61 const { connector } = useWalletConnect();
63 const performL2SpawnReticket = useCallback(
75 nextRevision = INITIAL_NETWORK_KEY_REVISION,
79 }: ReticketL2SpawnParams) => {
80 // call reticketPointBetweenWallets, with isL2Spawn set to true; this will
81 // skip setting the L1 spawn proxy
82 await reticketPointBetweenWallets({
96 doSetSpawnProxy: false,
99 // instead, set spawn proxy on L2
101 const nonce = await api.getNonce({ ship: point, proxy });
103 await registerProxyAddress(
110 toWallet?.spawn?.keys?.address || to,
116 [api, connector, walletType]
120 performL2SpawnReticket,
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list