-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replace ethers with viem, add wagmi, working ui
- Loading branch information
Showing
14 changed files
with
2,842 additions
and
1,700 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
src/wagmi-generated.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* eslint-env node */ | ||
module.exports = { | ||
env: { | ||
browser: true, | ||
es6: true, | ||
node: true, | ||
mocha: true | ||
}, | ||
extends: [ | ||
'airbnb-base', | ||
'plugin:react/recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
'prettier/@typescript-eslint', | ||
'plugin:prettier/recommended' | ||
], | ||
globals: { | ||
Atomics: 'readonly', | ||
SharedArrayBuffer: 'readonly', | ||
BigInt: 'readonly' | ||
}, | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
ecmaVersion: 2020, | ||
sourceType: 'module' | ||
}, | ||
plugins: ['@typescript-eslint'], | ||
rules: { | ||
'@typescript-eslint/explicit-function-return-type': 'off', | ||
'@typescript-eslint/no-unused-vars': 'error', | ||
'@typescript-eslint/no-explicit-any': 'warn', | ||
'@typescript-eslint/camelcase': 'off', | ||
'no-await-in-loop': 'off', | ||
'no-plusplus': 'off', | ||
'no-console': 'off', | ||
'no-continue': 'off', | ||
'import/prefer-default-export': 'off', | ||
'no-restricted-syntax': 'off', | ||
'no-constant-condition': 'off', | ||
'class-methods-use-this': 'off', | ||
'no-underscore-dangle': 'off', | ||
'no-bitwise': 'off', | ||
'no-restricted-properties': 'off', | ||
'import/extensions': [ | ||
'error', | ||
'ignorePackages', | ||
{ | ||
js: 'never', | ||
jsx: 'never', | ||
ts: 'never', | ||
tsx: 'never' | ||
} | ||
], | ||
'import/no-extraneous-dependencies': 'off', | ||
'no-useless-constructor': 'off', | ||
'react/prop-types': 'off', | ||
'react/jsx-no-target-blank': 'off' | ||
}, | ||
settings: { | ||
'import/resolver': { | ||
node: { | ||
extensions: ['.js', '.jsx', '.ts', '.tsx', '.d.ts'] | ||
} | ||
}, | ||
react: { | ||
pragma: 'React', | ||
version: 'detect' | ||
} | ||
} | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,6 @@ node_modules | |
dist | ||
build | ||
.openzeppelin/.session | ||
typechain-types | ||
artifacts | ||
cache | ||
cache | ||
src/wagmi-generated.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,37 @@ | ||
import { providers } from 'ethers'; | ||
import { HeadTail__factory } from '../typechain-types'; | ||
import { CustomTransport, Hex, WalletClient, getContract, getContractAddress } from 'viem'; | ||
import { hardhat } from 'viem/chains'; | ||
import { headTailAbi } from './wagmi-generated'; | ||
import { publicClient } from './config'; | ||
import { bytecode } from '../artifacts/contracts/HeadTail.sol/HeadTail.json'; | ||
|
||
export async function deployHeadTailContract(rpc: providers.JsonRpcProvider, from: string) { | ||
const signer = rpc.getSigner(from); | ||
const factory = new HeadTail__factory(signer); | ||
export async function deployHeadTailContract( | ||
walletClient: WalletClient<CustomTransport, typeof hardhat> | ||
) { | ||
if (!walletClient.account) { | ||
throw new Error('account is none'); | ||
} | ||
|
||
return factory.deploy(); | ||
const transactionCount = await publicClient.getTransactionCount({ | ||
address: walletClient.account.address | ||
}); | ||
|
||
const contractAddress = getContractAddress({ | ||
from: walletClient.account.address, | ||
nonce: BigInt(transactionCount) | ||
}); | ||
|
||
await walletClient.deployContract({ | ||
abi: headTailAbi, | ||
account: walletClient.account, | ||
bytecode: bytecode as Hex | ||
}); | ||
|
||
return getContract({ | ||
address: contractAddress, | ||
abi: headTailAbi, | ||
client: { | ||
public: publicClient, | ||
wallet: walletClient | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
import { HttpTransport, PublicClient, createPublicClient, http } from 'viem'; | ||
import { hardhat } from 'viem/chains'; | ||
|
||
export const CONFIG = { | ||
WEB3_PROVIDER_URL: 'http://localhost:8545' | ||
}; | ||
|
||
export const publicClient: PublicClient<HttpTransport, typeof hardhat> = createPublicClient({ | ||
chain: hardhat, | ||
transport: http() | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
export {}; | ||
|
||
type EthereumProvider = { request(...args: any): Promise<any> }; | ||
|
||
declare global { | ||
interface Window { | ||
ethereum?: EthereumProvider; | ||
} | ||
} |
Oops, something went wrong.