Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
0xthrpw committed Feb 20, 2025
1 parent c2e615f commit 04bc9f4
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 49 deletions.
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@use-gesture/react": "^10.3.1",
"caniuse-lite": "^1.0.30001687",
"clsx": "^2.1.0",
"ethereum-identity-kit": "^0.1.6",
"ethereum-identity-kit": "0xthrpw/ethereum-identity-kit#f326b07",
"i18next": "^23.11.5",
"i18next-browser-languagedetector": "^8.0.0",
"i18next-http-backend": "^2.5.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const useSaveListSettings = ({
const { data: walletClient } = useWalletClient()
const { actions, addActions, resetActions, handleNextAction, handleInitiateActions } = useActions()

const newSlot = useMemo(() => generateListStorageLocationSlot(), [])
const newSlot = useMemo(() => generateListStorageLocationSlot(userAddress), [])
const setListStorageLocationTx = useCallback(async () => {
if (!newChain) return

Expand Down
2 changes: 1 addition & 1 deletion src/hooks/efp-actions/use-mint-efp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function useMintEFP() {

const { data: walletClient } = useWalletClient()
const { address: accountAddress } = useAccount()
const nonce = useMemo(() => generateListStorageLocationSlot(), [])
const nonce = useMemo(() => generateListStorageLocationSlot(accountAddress), [])

const mint = async ({
selectedChainId,
Expand Down
8 changes: 4 additions & 4 deletions src/lib/constants/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
* All constants related to blockchain chain go here
*/

import { base, mainnet, optimism } from 'viem/chains'
import { base, mainnet, optimism, baseSepolia, optimismSepolia, sepolia } from 'viem/chains'

export const chains = ['mainnet', 'optimism', 'base'] as const
export const DEFAULT_CHAIN = base
export const chains = ['mainnet', 'optimism', 'base', 'baseSepolia'] as const
export const DEFAULT_CHAIN = baseSepolia

export type Chain = (typeof chains)[number]

Expand All @@ -15,5 +15,5 @@ export const LIST_OP_LIMITS: Record<number, number> = {
[base.id]: Number(process.env.NEXT_PUBLIC_BASE_LIMIT || 500),
// [sepolia.id]: Number(process.env.NEXT_PUBLIC_SEPOLIA_LIMIT || 500),
// [optimismSepolia.id]: Number(process.env.NEXT_PUBLIC_OPTIMISM_SEPOLIA_LIMIT || 500),
// [baseSepolia.id]: Number(process.env.NEXT_PUBLIC_BASE_SEPOLIA_LIMIT || 500),
[baseSepolia.id]: Number(process.env.NEXT_PUBLIC_BASE_SEPOLIA_LIMIT || 500),
} as const
6 changes: 3 additions & 3 deletions src/lib/constants/contracts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { base, mainnet, optimism } from 'viem/chains'
import { base, mainnet, optimism, baseSepolia, optimismSepolia, sepolia } from 'viem/chains'
import { createPublicClient, getContract, http, type Address } from 'viem'

import { efpListRegistryAbi } from '../abi'
Expand All @@ -18,10 +18,10 @@ export const coreEfpContracts: {
}

export const ListRecordContracts: Record<number, Address> = {
[base.id]: process.env['NEXT_PUBLIC_EFP_LIST_RECORDS'] as Address,
// [base.id]: process.env['NEXT_PUBLIC_EFP_LIST_RECORDS'] as Address,
[optimism.id]: process.env['NEXT_PUBLIC_EFP_LIST_RECORDS_OP'] as Address,
[mainnet.id]: process.env['NEXT_PUBLIC_EFP_LIST_RECORDS_MAINNET'] as Address,
// [baseSepolia.id]: process.env['NEXT_PUBLIC_EFP_LIST_RECORDS'] as Address,
[baseSepolia.id]: process.env['NEXT_PUBLIC_EFP_LIST_RECORDS'] as Address,
// [optimismSepolia.id]: process.env['NEXT_PUBLIC_EFP_LIST_RECORDS_OP_SEPOLIA'] as Address,
// [sepolia.id]: process.env['NEXT_PUBLIC_EFP_LIST_RECORDS_SEPOLIA'] as Address
}
Expand Down
8 changes: 4 additions & 4 deletions src/lib/constants/rpc-providers.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { base, mainnet, optimism } from 'viem/chains'
import { base, mainnet, optimism, baseSepolia, optimismSepolia, sepolia } from 'viem/chains'

export const rpcProviders: Record<number, string> = {
[mainnet.id]: `https://eth-mainnet.g.alchemy.com/v2/${process.env.NEXT_PUBLIC_MAINNET_ALCHEMY_ID}`,
// [sepolia.id]: `https://eth-sepolia.g.alchemy.com/v2/${process.env.NEXT_PUBLIC_SEPOLIA_ALCHEMY_ID}`,
[sepolia.id]: `https://eth-sepolia.g.alchemy.com/v2/${process.env.NEXT_PUBLIC_SEPOLIA_ALCHEMY_ID}`,
[optimism.id]: `https://opt-mainnet.g.alchemy.com/v2/${process.env.NEXT_PUBLIC_OPTIMISM_ALCHEMY_ID}`,
// [optimismSepolia.id]: `https://opt-sepolia.g.alchemy.com/v2/${process.env.NEXT_PUBLIC_OP_SEPOLIA_ALCHEMY_ID}`,
[optimismSepolia.id]: `https://opt-sepolia.g.alchemy.com/v2/${process.env.NEXT_PUBLIC_OP_SEPOLIA_ALCHEMY_ID}`,
[base.id]: `https://base-mainnet.g.alchemy.com/v2/${process.env.NEXT_PUBLIC_BASE_ALCHEMY_ID}`,
// [baseSepolia.id]: `https://base-sepolia.g.alchemy.com/v2/${process.env.NEXT_PUBLIC_BASE_SEPOLIA_ALCHEMY_ID}`
[baseSepolia.id]: `https://base-sepolia.g.alchemy.com/v2/${process.env.NEXT_PUBLIC_BASE_SEPOLIA_ALCHEMY_ID}`
}
64 changes: 32 additions & 32 deletions src/lib/wagmi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
walletConnectWallet,
safeWallet,
} from '@rainbow-me/rainbowkit/wallets'
import { mainnet, optimism, base } from 'wagmi/chains'
import { mainnet, optimism, base, baseSepolia } from 'wagmi/chains'
import { type Chain, connectorsForWallets } from '@rainbow-me/rainbowkit'
import { http, fallback, createStorage, cookieStorage, createConfig } from 'wagmi'

Expand Down Expand Up @@ -109,22 +109,22 @@ export const chains: [ChainWithDetails, ...ChainWithDetails[]] = [
},
},
},
// {
// ...baseSepolia,
// iconUrl: '/assets/chains/base.svg',
// custom: {
// chainDetail: 'Ethereum L2 Testnet',
// gasFeeDetail: 'Super Low gas fees'
// }
// },
// {
// ...optimismSepolia,
// iconUrl: '/assets/chains/optimism.svg',
// custom: {
// chainDetail: 'Ethereum L2 Testnet',
// gasFeeDetail: 'Low gas fees'
// }
// },
{
...baseSepolia,
iconUrl: '/assets/chains/base.svg',
custom: {
chainDetail: 'Ethereum L2 Testnet',
gasFeeDetail: 'Super Low gas fees'
}
},
// {
// ...optimismSepolia,
// iconUrl: '/assets/chains/optimism.svg',
// custom: {
// chainDetail: 'Ethereum L2 Testnet',
// gasFeeDetail: 'Low gas fees'
// }
// },
// {
// ...sepolia,
// iconBackground: 'bg-zinc-200',
Expand Down Expand Up @@ -201,21 +201,21 @@ const config = createConfig({
}),
http('https://mainnet.base.org/', { batch: true }),
]),
// [baseSepolia.id]: fallback([
// http(
// `https://base-sepolia.g.alchemy.com/v2/${process.env.NEXT_PUBLIC_BASE_SEPOLIA_ALCHEMY_ID}`,
// {
// batch: true
// }
// ),
// http(
// `https://smart-cosmological-telescope.base-sepolia.quiknode.pro/${process.env.NEXT_PUBLIC_QUICKNODE_ID}`,
// {
// batch: true
// }
// ),
// http('https://sepolia.base.org', { batch: true })
// ])
[baseSepolia.id]: fallback([
http(
`https://base-sepolia.g.alchemy.com/v2/${process.env.NEXT_PUBLIC_BASE_SEPOLIA_ALCHEMY_ID}`,
{
batch: true
}
),
http(
`https://smart-cosmological-telescope.base-sepolia.quiknode.pro/${process.env.NEXT_PUBLIC_QUICKNODE_ID}`,
{
batch: true
}
),
http('https://sepolia.base.org', { batch: true })
])
},
})

Expand Down
9 changes: 6 additions & 3 deletions src/utils/generate-slot.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { keccak256, toHex } from 'viem/utils'

export function generateListStorageLocationSlot() {
const hash = keccak256(toHex(Date.now() * Math.floor(Math.random() * 1000)))
return BigInt(hash.slice(0, 66)) & ((1n << 255n) - 1n)
export function generateListStorageLocationSlot(address: `0x${string}` | undefined) {
const hash = keccak256(toHex(Date.now() * Math.floor(Math.random() * 1000)))
const trimmedHash = BigInt(hash.slice(0, 26)) & ((1n << 96n) - 1n)
return BigInt(address + trimmedHash.toString(16))
// const hash = keccak256(toHex(Date.now() * Math.floor(Math.random() * 1000)))
// return BigInt(hash.slice(0, 66)) & ((1n << 255n) - 1n)
}

0 comments on commit 04bc9f4

Please sign in to comment.