Skip to content

Commit

Permalink
Patch - Token Deployer for Etherlink (#873)
Browse files Browse the repository at this point in the history
* WIP:
- Implementing WAGMI for Etherlink Login
- Changing useTezos hook to handle login with Etherlink
- Changing Validation options when Etherlink is active.

* WIP - Etherlink Integration

* WIP:

* Changes
- Login and Logout working in many cases
- Created common ToolbarAccount Component
- Improved useTezos for Etherlink Support
- Improved utils.ts for helper functions

* WIP - Lite DAO Create

* WIP - Offchain DAO Almost Works.

* Other Code Improvements

* Removed unused deps

* Removed unused deps

* Removed Unused Code

* Build Fix

* Removed bun lock

* Build Issue Fix

* Removed package-lock for yarn package

* removed unused deps

* Fix for Build

* DAO Details for Etherlink

* eslint fixes

* Code Improvement for Polls

* TS Fixes

* Removed console.logs and debug points

* Change Remix URL

* Switched to Connectkit

* Using switchChain Hook from wagmi

* Added a useNetwork hook

* Fix for Proposal and Voting Weight

* Etherlink ERC20 Token Deployer (#868)

* WIP:
- Implementing WAGMI for Etherlink Login
- Changing useTezos hook to handle login with Etherlink
- Changing Validation options when Etherlink is active.

* WIP:

* WIP - Offchain DAO Almost Works.

* Token Deployer for Etherlink

* Updated changelog

* Fixes after Rebase

* Fixed Toolbar Color

* Fix for DAO Route after merge

* Minor Fix

* Fix for Token Deployer

* Navigate to Deployer without Login
  • Loading branch information
ashutoshpw authored Nov 7, 2024
1 parent 402a5b1 commit dcf0ef3
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 13 deletions.
8 changes: 2 additions & 6 deletions src/modules/creator/token/etherlink/steps/Ownership.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,8 @@ export const Ownership: React.FC = () => {
<OptionButton
underline="none"
onClick={() => {
if (etherlink.isConnected) {
window.open(`https://www.cookbook.dev/contracts/simple-token`)
} else {
const href = `/creator/deployment`
history.push(href)
}
const href = `/creator/deployment`
history.push(href)
}}
>
<MainButton variant="contained" color="secondary">
Expand Down
17 changes: 12 additions & 5 deletions src/modules/creator/token/etherlink/steps/Summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ import {
ThirdContainerRow,
ThirdContainerLastRow
} from "../../ui"
import { useTezos } from "services/beacon/hooks/useTezos"
export const ContractSummary: React.FC = () => {
const theme = useTheme()
const isMobile = useMediaQuery(theme.breakpoints.down("sm"))
const history = useHistory()
const match = useRouteMatch()

const { etherlink, connect } = useTezos()
const { state, dispatch } = useContext(DeploymentContext)
const { tokenDistribution, tokenSettings } = state.data

Expand Down Expand Up @@ -64,15 +66,20 @@ export const ContractSummary: React.FC = () => {
},
next: {
handler: () => {
mutate({
...state.data
})
setIsLoading(true)
if (etherlink.isConnected) {
mutate({
...state.data
})
setIsLoading(true)
} else {
connect()
}
},
text: isLoading ? "Deploying..." : "Launch"
}
})
}, [dispatch, history, match.path, match.url, mutate, state.data, isLoading])
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [dispatch, history, match.path, match.url, mutate, state.data, isLoading, etherlink.isConnected])

return (
<>
Expand Down
2 changes: 2 additions & 0 deletions src/modules/explorer/pages/DAOList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ export const DAOList: React.FC = () => {
return []
}, [daos, searchText, account])

console.log({ daos, currentDAOs, myDAOs })

const filterDAOs = (filter: string) => {
setSearchText(filter.trim())
}
Expand Down
2 changes: 2 additions & 0 deletions src/modules/lite/explorer/pages/ProposalDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ export const ProposalDetails: React.FC<{ id: string }> = ({ id }) => {
poll?.referenceBlock
)

console.log({ voteWeight })

const [votingPower, setVotingPower] = useState(poll?.isXTZ ? voteWeight?.votingXTZWeight : voteWeight?.votingWeight)

const choices = usePollChoices(poll, refresh)
Expand Down
8 changes: 6 additions & 2 deletions src/services/beacon/hooks/useTezos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ export const useTezos = (): WalletConnectReturn => {
isConnected: isEtherlinkConnected,
connect: connectWithWagmi,
disconnect: disconnectEtherWallet,
network: etherlinkNetwork
network: etherlinkNetwork,
provider: ethProvider,
signer: ethSigner
} = useContext(EtherlinkContext)

const queryClient = useQueryClient()
Expand Down Expand Up @@ -209,7 +211,9 @@ export const useTezos = (): WalletConnectReturn => {
isEtherlink: network?.startsWith("etherlink"),
etherlink: {
isConnected: isEtherlinkConnected,
account: ethAccount
account: ethAccount,
provider: ethProvider,
signer: ethSigner
}
}
}
5 changes: 5 additions & 0 deletions src/services/wagmi/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { disconnect as disconnectEtherlink } from "@wagmi/core"
import { config as wagmiConfig } from "services/wagmi/config"
import { etherlink, etherlinkTestnet } from "wagmi/chains"
import { useSIWE, useModal, SIWESession } from "connectkit"
import { useEthersProvider, useEthersSigner } from "./ethers"

interface EtherlinkType {
isConnected: boolean
Expand All @@ -21,6 +22,8 @@ export const EtherlinkContext = createContext<any | undefined>(undefined)

export const EtherlinkProvider: React.FC<{ children: ReactNode }> = ({ children }) => {
const { setOpen } = useModal()
const provider = useEthersProvider()
const signer = useEthersSigner()
const { chains, switchChain } = useSwitchChain()
// const { data, isReady, isRejected, isLoading, isSignedIn, signOut, signIn, error } = useSIWE({
// onSignIn: (session?: SIWESession) => {
Expand Down Expand Up @@ -58,6 +61,8 @@ export const EtherlinkProvider: React.FC<{ children: ReactNode }> = ({ children
<EtherlinkContext.Provider
value={{
isConnected,
provider,
signer,
account: {
address: address || ""
},
Expand Down

0 comments on commit dcf0ef3

Please sign in to comment.