diff --git a/abi/KaliAccessManagerV2.json b/abi/ACCESS.ts
similarity index 99%
rename from abi/KaliAccessManagerV2.json
rename to abi/ACCESS.ts
index edf886b5..59865197 100644
--- a/abi/KaliAccessManagerV2.json
+++ b/abi/ACCESS.ts
@@ -1,4 +1,4 @@
-[
+export const ACCESS_ABI = [
{
"inputs": [],
"stateMutability": "nonpayable",
@@ -504,4 +504,4 @@
"stateMutability": "view",
"type": "function"
}
-]
+] as const;
diff --git a/abi/KaliDAO.json b/abi/DAO.ts
similarity index 99%
rename from abi/KaliDAO.json
rename to abi/DAO.ts
index 47670f0d..5418755f 100644
--- a/abi/KaliDAO.json
+++ b/abi/DAO.ts
@@ -1,4 +1,4 @@
-[
+export const DAO_ABI = [
{
"inputs": [],
"name": "AlreadyVoted",
@@ -1523,4 +1523,4 @@
"stateMutability": "view",
"type": "function"
}
-]
+] as const;
diff --git a/abi/KaliDAOcrowdsaleV2.json b/abi/SWAP.ts
similarity index 99%
rename from abi/KaliDAOcrowdsaleV2.json
rename to abi/SWAP.ts
index 0409628d..4d5384f1 100644
--- a/abi/KaliDAOcrowdsaleV2.json
+++ b/abi/SWAP.ts
@@ -1,4 +1,4 @@
-[
+export const SWAP_ABI = [
{
"inputs": [
{
@@ -521,4 +521,4 @@
"stateMutability": "view",
"type": "function"
}
-]
\ No newline at end of file
+] as const;
\ No newline at end of file
diff --git a/abi/index.ts b/abi/index.ts
new file mode 100644
index 00000000..b26a8222
--- /dev/null
+++ b/abi/index.ts
@@ -0,0 +1,5 @@
+import { SWAP_ABI } from "./SWAP";
+import { DAO_ABI } from './DAO';
+import { ACCESS_ABI } from "./ACCESS";
+
+export { SWAP_ABI, ACCESS_ABI, DAO_ABI }
\ No newline at end of file
diff --git a/components/dao-dashboard/layout/Nav.tsx b/components/dao-dashboard/layout/Nav.tsx
index 2ad72ab5..a3f0c67b 100644
--- a/components/dao-dashboard/layout/Nav.tsx
+++ b/components/dao-dashboard/layout/Nav.tsx
@@ -4,7 +4,7 @@ import { useContractRead } from 'wagmi'
import { DashboardElementProps } from './types'
import Link from 'next/link'
import { addresses } from '@constants/addresses'
-import SWAP_ABI from '@abi/KaliDAOcrowdsaleV2.json'
+import { SWAP_ABI } from '@abi/index'
import { AddressZero } from '@ethersproject/constants'
import { navItem, navMenu } from './layout.css'
import Wrappr from './Wrappr'
@@ -17,8 +17,8 @@ const Nav = ({ address, chainId }: DashboardElementProps) => {
error: swapError,
isError: isSwapError,
} = useContractRead({
- addressOrName: chainId ? addresses?.[chainId]?.['extensions']['crowdsale2'] : AddressZero,
- contractInterface: SWAP_ABI,
+ address: chainId ? addresses?.[chainId]?.['extensions']['crowdsale2'] : AddressZero,
+ abi: SWAP_ABI,
chainId: chainId,
functionName: 'crowdsales',
args: [address],
@@ -43,7 +43,7 @@ const Nav = ({ address, chainId }: DashboardElementProps) => {
},
]
- if (swap && swap?.saleEnds * 1000 > Date.now()) {
+ if (swap && swap.saleEnds * 1000 > Date.now()) {
items.push({
id: 2,
title: 'Swap',
diff --git a/components/dao-dashboard/layout/Profile.tsx b/components/dao-dashboard/layout/Profile.tsx
index d3e7fd47..c2392cec 100644
--- a/components/dao-dashboard/layout/Profile.tsx
+++ b/components/dao-dashboard/layout/Profile.tsx
@@ -16,7 +16,7 @@ import {
IconGitHub,
} from '@kalidao/reality'
import { useRouter } from 'next/router'
-import { chain, useQuery } from 'wagmi'
+import { useQuery } from 'wagmi'
import { getDaoInfo } from '@graph/queries'
import { DashboardElementProps } from './types'
import Link from 'next/link'
diff --git a/components/dao-dashboard/layout/index.tsx b/components/dao-dashboard/layout/index.tsx
index 894e9778..38e37584 100644
--- a/components/dao-dashboard/layout/index.tsx
+++ b/components/dao-dashboard/layout/index.tsx
@@ -37,9 +37,9 @@ const DashboardLayout = ({ title, content, children }: Props) => {
}}
justify="space-between"
>
-
-
-
+
+
+
{children}
diff --git a/components/dao-dashboard/layout/types.ts b/components/dao-dashboard/layout/types.ts
index 29b34a97..5a8acf91 100644
--- a/components/dao-dashboard/layout/types.ts
+++ b/components/dao-dashboard/layout/types.ts
@@ -1,4 +1,4 @@
export type DashboardElementProps = {
- address: string
+ address: `0x${string}`
chainId: number
}
diff --git a/components/dao-dashboard/members/types.ts b/components/dao-dashboard/members/types.ts
index f4e96e3a..e113c8ac 100644
--- a/components/dao-dashboard/members/types.ts
+++ b/components/dao-dashboard/members/types.ts
@@ -1,5 +1,5 @@
export interface Member {
- address: string
+ address: `0x${string}`
proposals: any[]
shares: string
}
diff --git a/components/dao-dashboard/newproposal/apps/SetRedemption.tsx b/components/dao-dashboard/newproposal/apps/SetRedemption.tsx
index d9b1864e..8d06e248 100644
--- a/components/dao-dashboard/newproposal/apps/SetRedemption.tsx
+++ b/components/dao-dashboard/newproposal/apps/SetRedemption.tsx
@@ -1,8 +1,8 @@
import React, { useState, useEffect } from 'react'
import { useRouter } from 'next/router'
-import { ethers } from 'ethers'
+import { ethers, BigNumber } from 'ethers'
import { useContract, useSigner } from 'wagmi'
-import KALIDAO_ABI from '@abi/KaliDAO.json'
+import { DAO_ABI } from '@abi/index'
import { addresses } from '@constants/addresses'
import { fetchExtensionStatus } from '@utils/fetchExtensionStatus'
import { Warning } from '@design/elements'
@@ -17,15 +17,15 @@ import { DateInput } from '@design/DateInput'
export default function SetRedemption({ setProposal, title, content }: ProposalProps) {
const router = useRouter()
- const daoAddress = router.query.dao as string
+ const daoAddress = router.query.dao as `0x${string}`
const daoChainId = Number(router.query.chainId)
const { data: signer } = useSigner()
const redemptionAddress = addresses[daoChainId]['extensions']['redemption']
const tokenArray = getRedemptionTokens(daoChainId)
const kalidao = useContract({
- addressOrName: daoAddress,
- contractInterface: KALIDAO_ABI,
+ address: daoAddress,
+ abi: DAO_ABI,
signerOrProvider: signer,
})
@@ -92,12 +92,12 @@ export default function SetRedemption({ setProposal, title, content }: ProposalP
)
try {
- const tx = await kalidao.propose(
+ const tx = await kalidao?.propose(
9, // EXTENSION prop
docs,
[addresses[daoChainId]['extensions']['redemption']],
- [_toggleRedemption],
- [payload],
+ [BigNumber.from(_toggleRedemption)],
+ [payload as `0x${string}`],
)
console.log('tx', tx)
} catch (e) {
diff --git a/components/dao-dashboard/newproposal/apps/SetSwap.tsx b/components/dao-dashboard/newproposal/apps/SetSwap.tsx
index 896d8a29..6302e251 100644
--- a/components/dao-dashboard/newproposal/apps/SetSwap.tsx
+++ b/components/dao-dashboard/newproposal/apps/SetSwap.tsx
@@ -1,12 +1,11 @@
import React, { useState, useEffect } from 'react'
import { useRouter } from 'next/router'
-import { ethers } from 'ethers'
+import { ethers, BigNumber } from 'ethers'
import { erc20ABI, useContract, useContractRead, useSigner } from 'wagmi'
import { Select } from '@design/Select'
-import { Stack, Input, Box, Text, Button, FieldSet, FileInput, Textarea } from '@kalidao/reality'
+import { Stack, Input, Button, FieldSet, Textarea } from '@kalidao/reality'
import FileUploader from '@components/tools/FileUpload'
-import KALIDAO_ABI from '@abi/KaliDAO.json'
-import KALIACCESS_ABI from '@abi/KaliAccessManagerV2.json'
+import { DAO_ABI, ACCESS_ABI } from '@abi/index'
import { addresses } from '@constants/addresses'
import { Warning } from '@design/elements'
import { fetchEnsAddress } from '@utils/fetchEnsAddress'
@@ -19,29 +18,37 @@ import { DateInput } from '@design/DateInput'
import { JSONContent } from '@tiptap/react'
import { createSwapDetails } from './createSwapDetails'
+class List {
+ readonly list: `0x${string}[]`
+
+ constructor(list: `0x${string}[]`) {
+ this.list = list
+ }
+}
+
export default function SetCrowdsale({ setProposal, title, content }: ProposalProps) {
const router = useRouter()
- const daoAddress = router.query.dao as string
+ const daoAddress = router.query.dao as `0x${string}`
const chainId = Number(router.query.chainId)
const { data: signer } = useSigner()
const crowdsaleAddress = addresses[chainId]['extensions']['crowdsale2']
const { data: kalidaoToken } = useContractRead({
- addressOrName: daoAddress,
- contractInterface: KALIDAO_ABI,
+ address: daoAddress,
+ abi: DAO_ABI,
functionName: 'symbol',
chainId: Number(chainId),
})
const kalidao = useContract({
- addressOrName: daoAddress,
- contractInterface: KALIDAO_ABI,
+ address: daoAddress,
+ abi: DAO_ABI,
signerOrProvider: signer,
})
const kaliAccess = useContract({
- addressOrName: addresses[chainId]['access2'],
- contractInterface: KALIACCESS_ABI,
+ address: addresses[chainId]['access2'],
+ abi: ACCESS_ABI,
signerOrProvider: signer,
})
@@ -67,9 +74,8 @@ export default function SetCrowdsale({ setProposal, title, content }: ProposalPr
return
}
- let list = []
+ let list: `0x${string}`[] = []
let _customAccess = customAccess.split(', ')
-
for (let i = 0; i < _customAccess.length; i++) {
const address = await fetchEnsAddress(_customAccess[i])
@@ -79,11 +85,13 @@ export default function SetCrowdsale({ setProposal, title, content }: ProposalPr
return
}
- list.push(address)
+ if (address) {
+ list.push(address as `0x${string}`)
+ }
}
try {
- const tx = await kaliAccess.createList(list, ethers.utils.formatBytes32String('0x0'), '')
+ const tx = await kaliAccess?.createList(list, ethers.constants.HashZero, '')
console.log('tx ', tx)
setIsRecorded(true)
setWarning('')
@@ -142,9 +150,10 @@ export default function SetCrowdsale({ setProposal, title, content }: ProposalPr
_purchaseAccess = 1
} else {
try {
- let id = await kaliAccess.listCount()
- id = ethers.utils.formatUnits(id, 'wei')
- _purchaseAccess = parseInt(id)
+ const id = await kaliAccess?.listCount()
+ if (!id) return
+ const idWei = ethers.utils.formatUnits(id, 'wei')
+ _purchaseAccess = parseInt(idWei)
} catch (e) {
console.log(e)
}
@@ -227,7 +236,7 @@ export default function SetCrowdsale({ setProposal, title, content }: ProposalPr
payload = abiCoder.encode(
['uint256', 'uint256', 'address', 'uint32', 'uint96', 'uint96', 'string'],
[_purchaseAccess, _swapMultiplier, _tokenToSwap, crowdsaleEnd, _totalLimit, _personalLimit, detailsHash],
- )
+ ) as `0x${string}`
// console.log(payload)
} catch (e) {
setWarning('Error setting the crowdsale proposal.')
@@ -240,11 +249,11 @@ export default function SetCrowdsale({ setProposal, title, content }: ProposalPr
setStatus('Creating proposal...')
try {
setWarning('')
- const tx = await kalidao.propose(
+ const tx = await kalidao?.propose(
9, // EXTENSION prop
docs,
[crowdsaleAddress],
- [1],
+ [BigNumber.from(1)],
[payload],
)
console.log('tx', tx)
diff --git a/components/dao-dashboard/newproposal/internal/CallContract.tsx b/components/dao-dashboard/newproposal/internal/CallContract.tsx
index 75149893..b308865d 100644
--- a/components/dao-dashboard/newproposal/internal/CallContract.tsx
+++ b/components/dao-dashboard/newproposal/internal/CallContract.tsx
@@ -3,9 +3,9 @@ import { useContract, useSigner } from 'wagmi'
import { Warning } from '@design/elements'
import { Box, Button, Text, Stack, Input, Textarea } from '@kalidao/reality'
import { Select } from '@design/Select'
-import KALIDAO_ABI from '@abi/KaliDAO.json'
+import { DAO_ABI } from '@abi/index'
import { useRouter } from 'next/router'
-import { ethers } from 'ethers'
+import { ethers, BigNumber } from 'ethers'
import Back from '@design/proposal/Back'
import { createProposal } from '../utils'
import { ProposalProps } from '../utils/types'
@@ -13,17 +13,17 @@ import { ProposalProps } from '../utils/types'
export default function CallContract({ setProposal, title, content }: ProposalProps) {
const router = useRouter()
const daoChainId = Number(router.query.chainId)
- const daoAddress = router.query.dao as string
+ const daoAddress = router.query.dao as `0x${string}`
const { data: signer } = useSigner()
const kalidao = useContract({
- addressOrName: daoAddress as string,
- contractInterface: KALIDAO_ABI,
+ address: daoAddress,
+ abi: DAO_ABI,
signerOrProvider: signer,
})
// form
- const [contractAddress, setContractAddress] = useState()
+ const [contractAddress, setContractAddress] = useState<`0x${string}`>()
const [contractAbi, setContractAbi] = useState()
const [writeFuncs, setWriteFuncs] = useState()
const [writeOptions, setWriteOptions] = useState()
@@ -96,7 +96,7 @@ export default function CallContract({ setProposal, title, content }: ProposalPr
// TODO: Popup to change network if on different network from DAO
const submit = async () => {
- if (!functionName) return
+ if (!functionName || !contractAddress) return
let docs
try {
docs = await createProposal(daoAddress, daoChainId, 2, title, content)
@@ -107,15 +107,15 @@ export default function CallContract({ setProposal, title, content }: ProposalPr
try {
let iface = new ethers.utils.Interface(contractAbi as string)
- let payload = iface.encodeFunctionData(functionName, inputParams)
+ let payload = iface.encodeFunctionData(functionName, inputParams) as `0x${string}`
console.log('Proposal Params - ', 2, docs, [contractAddress], [0], [payload])
try {
- const tx = await kalidao.propose(
+ const tx = await kalidao?.propose(
2, // CALL prop
docs,
[contractAddress],
- [0],
+ [BigNumber.from(0)],
[payload],
)
console.log('tx', tx)
@@ -128,6 +128,13 @@ export default function CallContract({ setProposal, title, content }: ProposalPr
}
}
+ const handleContractAddress = (e: React.ChangeEvent) => {
+ e.preventDefault()
+ if (e.currentTarget.value.slice(0, 2) == '0x' && ethers.utils.isAddress(e.currentTarget.value)) {
+ setContractAddress(e.currentTarget.value as `0x${string}`)
+ }
+ }
+
return (
@@ -145,7 +152,7 @@ export default function CallContract({ setProposal, title, content }: ProposalPr
name="contractAddress"
type="text"
defaultValue={contractAddress}
- onChange={(e) => setContractAddress(e.target.value)}
+ onChange={handleContractAddress}
/>