Skip to content

Commit

Permalink
Feat: smart account init (#2014)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomiir authored Mar 4, 2024
1 parent eede7d2 commit ff9884b
Show file tree
Hide file tree
Showing 68 changed files with 1,067 additions and 157 deletions.
22 changes: 22 additions & 0 deletions apps/gallery/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# @apps/gallery

## 4.0.12

### Patch Changes

- [#2014](https://github.com/WalletConnect/web3modal/pull/2014) [`95b35e1`](https://github.com/WalletConnect/web3modal/commit/95b35e1ebaf261a56a29cd9254d85b7c1430bfc0) Thanks [@tomiir](https://github.com/tomiir)! - Smart Account RPC handler canary

- Smart Account initialization and feature flag

- Updated dependencies [[`95b35e1`](https://github.com/WalletConnect/web3modal/commit/95b35e1ebaf261a56a29cd9254d85b7c1430bfc0)]:
- @web3modal/ui@4.0.12
- @web3modal/common@4.0.12

## 4.0.12-0c59f84f.0

### Patch Changes

- Smart Account RPC handler canary

- Updated dependencies []:
- @web3modal/ui@4.0.12-0c59f84f.0
- @web3modal/common@4.0.12-0c59f84f.0

## 4.0.11

### Patch Changes
Expand Down
6 changes: 3 additions & 3 deletions apps/gallery/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@apps/gallery",
"version": "4.0.11",
"version": "4.0.12",
"private": true,
"main": "index.js",
"scripts": {
Expand All @@ -9,8 +9,8 @@
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
},
"dependencies": {
"@web3modal/common": "4.0.11",
"@web3modal/ui": "4.0.11",
"@web3modal/common": "4.0.12",
"@web3modal/ui": "4.0.12",
"lit": "3.1.0",
"storybook": "7.6.7"
},
Expand Down
24 changes: 24 additions & 0 deletions apps/laboratory/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# @apps/laboratory

## 4.0.12

### Patch Changes

- [#2014](https://github.com/WalletConnect/web3modal/pull/2014) [`95b35e1`](https://github.com/WalletConnect/web3modal/commit/95b35e1ebaf261a56a29cd9254d85b7c1430bfc0) Thanks [@tomiir](https://github.com/tomiir)! - Smart Account RPC handler canary

- Smart Account initialization and feature flag

- Updated dependencies [[`95b35e1`](https://github.com/WalletConnect/web3modal/commit/95b35e1ebaf261a56a29cd9254d85b7c1430bfc0)]:
- @web3modal/ethers@4.0.12
- @web3modal/wagmi@4.0.12
- @web3modal/siwe@4.0.12

## 4.0.12-0c59f84f.0

### Patch Changes

- Smart Account RPC handler canary

- Updated dependencies []:
- @web3modal/ethers@4.0.12-0c59f84f.0
- @web3modal/wagmi@4.0.12-0c59f84f.0
- @web3modal/siwe@4.0.12-0c59f84f.0

## 4.0.11

### Patch Changes
Expand Down
8 changes: 4 additions & 4 deletions apps/laboratory/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@apps/laboratory",
"version": "4.0.11",
"version": "4.0.12",
"private": true,
"scripts": {
"dev:laboratory": "next dev",
Expand All @@ -24,9 +24,9 @@
"@sentry/browser": "7.92.0",
"@sentry/react": "7.92.0",
"@tanstack/react-query": "5.17.19",
"@web3modal/ethers": "4.0.11",
"@web3modal/siwe": "4.0.11",
"@web3modal/wagmi": "4.0.11",
"@web3modal/ethers": "4.0.12",
"@web3modal/siwe": "4.0.12",
"@web3modal/wagmi": "4.0.12",
"framer-motion": "10.17.9",
"next": "14.0.4",
"next-auth": "4.24.5",
Expand Down
103 changes: 103 additions & 0 deletions apps/laboratory/src/components/Wagmi/WagmiSendUSDCTest.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import { Button, useToast, Stack, Link, Text, Spacer, Input } from '@chakra-ui/react'
import { useAccount, useWriteContract } from 'wagmi'
import { useCallback, useState } from 'react'
import { sepolia } from 'wagmi/chains'

const minTokenAbi = [
{
inputs: [
{ internalType: 'address', name: 'to', type: 'address' },
{ internalType: 'uint256', name: 'value', type: 'uint256' }
],
name: 'transfer',
outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
stateMutability: 'nonpayable',
type: 'function'
},
{
inputs: [{ internalType: 'address', name: 'account', type: 'address' }],
name: 'balanceOf',
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
stateMutability: 'view',
type: 'function'
},
{
inputs: [],
name: 'decimals',
outputs: [{ internalType: 'uint8', name: '', type: 'uint8' }],
stateMutability: 'view',
type: 'function'
}
]

export function WagmiSendUSDCTest() {
const [isLoading, setLoading] = useState(false)
const [address, setAddress] = useState('')
const [amount, setAmount] = useState('')
const { status, chain } = useAccount()
const toast = useToast()

const { writeContract } = useWriteContract({
mutation: {
onSuccess: hash => {
setLoading(false)
toast({
title: 'Transaction Success',
description: hash,
status: 'success',
isClosable: true
})
},
onError: () => {
setLoading(false)
toast({
title: 'Error',
description: 'Failed to send transaction',
status: 'error',
isClosable: true
})
}
}
})

const onSendTransaction = useCallback(() => {
setLoading(true)
writeContract({
abi: minTokenAbi,
functionName: 'transfer',
args: [address, amount],
address: '0x1c7d4b196cb0c7b01d743fbc6116a902379c7238'
})
}, [writeContract, address, amount])

return chain?.id === sepolia.id && status === 'connected' ? (
<Stack direction={['column', 'column', 'row']}>
<Button
data-test-id="sign-transaction-button"
onClick={onSendTransaction}
disabled={!writeContract}
isDisabled={isLoading}
>
Send USDC
</Button>

<Spacer />
<Input placeholder="0xf34ffa..." onChange={e => setAddress(e.target.value)} value={address} />
<Input
placeholder="Enter an amount"
onChange={e => setAmount(e.target.value)}
value={amount}
type="number"
/>
<Link isExternal href="https://faucet.circle.com">
<Button variant="outline" colorScheme="blue" isDisabled={isLoading}>
USDC Faucet
</Button>
</Link>
</Stack>
) : (
<Text fontSize="md" color="yellow">
Switch to Sepolia Ethereum Testnet to test this feature
</Text>
)
}
7 changes: 7 additions & 0 deletions apps/laboratory/src/components/Wagmi/WagmiTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { WagmiSignMessageTest } from './WagmiSignMessageTest'
import { WagmiSignTypedDataTest } from './WagmiSignTypedDataTest'
import { StackDivider, Card, CardHeader, Heading, CardBody, Box, Stack } from '@chakra-ui/react'
import { WagmiWriteContractTest } from './WagmiWriteContractTest'
import { WagmiSendUSDCTest } from './WagmiSendUSDCTest'

export function WagmiTests() {
return (
Expand Down Expand Up @@ -39,6 +40,12 @@ export function WagmiTests() {
</Heading>
<WagmiWriteContractTest />
</Box>
<Box>
<Heading size="xs" textTransform="uppercase" pb="2">
USDC Send
</Heading>
<WagmiSendUSDCTest />
</Box>
</Stack>
</CardBody>
</Card>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { sepolia } from 'wagmi/chains'

const TEST_TX = {
to: vitalikEthAddress as Address,
value: parseGwei('0.0002')
value: parseGwei('0.3')
}

export function WagmiTransactionTest() {
Expand Down
20 changes: 20 additions & 0 deletions examples/html-ethers5/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# @examples/html-ethers5

## 4.0.12

### Patch Changes

- [#2014](https://github.com/WalletConnect/web3modal/pull/2014) [`95b35e1`](https://github.com/WalletConnect/web3modal/commit/95b35e1ebaf261a56a29cd9254d85b7c1430bfc0) Thanks [@tomiir](https://github.com/tomiir)! - Smart Account RPC handler canary

- Smart Account initialization and feature flag

- Updated dependencies [[`95b35e1`](https://github.com/WalletConnect/web3modal/commit/95b35e1ebaf261a56a29cd9254d85b7c1430bfc0)]:
- @web3modal/ethers5@4.0.12

## 4.0.12-0c59f84f.0

### Patch Changes

- Smart Account RPC handler canary

- Updated dependencies []:
- @web3modal/ethers5@4.0.12-0c59f84f.0

## 4.0.11

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions examples/html-ethers5/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "@examples/html-ethers5",
"private": true,
"version": "4.0.11",
"version": "4.0.12",
"scripts": {
"dev:example": "vite --port 3011",
"build:examples": "vite build"
},
"dependencies": {
"@web3modal/ethers5": "4.0.11",
"@web3modal/ethers5": "4.0.12",
"ethers": "5.7.2"
},
"devDependencies": {
Expand Down
20 changes: 20 additions & 0 deletions examples/html-wagmi/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# @examples/html-wagmi

## 4.0.12

### Patch Changes

- [#2014](https://github.com/WalletConnect/web3modal/pull/2014) [`95b35e1`](https://github.com/WalletConnect/web3modal/commit/95b35e1ebaf261a56a29cd9254d85b7c1430bfc0) Thanks [@tomiir](https://github.com/tomiir)! - Smart Account RPC handler canary

- Smart Account initialization and feature flag

- Updated dependencies [[`95b35e1`](https://github.com/WalletConnect/web3modal/commit/95b35e1ebaf261a56a29cd9254d85b7c1430bfc0)]:
- @web3modal/wagmi@4.0.12

## 4.0.12-0c59f84f.0

### Patch Changes

- Smart Account RPC handler canary

- Updated dependencies []:
- @web3modal/wagmi@4.0.12-0c59f84f.0

## 4.0.11

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions examples/html-wagmi/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "@examples/html-wagmi",
"private": true,
"version": "4.0.11",
"version": "4.0.12",
"scripts": {
"dev:example": "vite --port 3001",
"build:examples": "vite build"
},
"dependencies": {
"@web3modal/wagmi": "4.0.11",
"@web3modal/wagmi": "4.0.12",
"@wagmi/connectors": "4.1.14",
"@wagmi/core": "2.6.5",
"react": "18.2.0",
Expand Down
20 changes: 20 additions & 0 deletions examples/next-wagmi/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# @examples/next-wagmi

## 4.0.12

### Patch Changes

- [#2014](https://github.com/WalletConnect/web3modal/pull/2014) [`95b35e1`](https://github.com/WalletConnect/web3modal/commit/95b35e1ebaf261a56a29cd9254d85b7c1430bfc0) Thanks [@tomiir](https://github.com/tomiir)! - Smart Account RPC handler canary

- Smart Account initialization and feature flag

- Updated dependencies [[`95b35e1`](https://github.com/WalletConnect/web3modal/commit/95b35e1ebaf261a56a29cd9254d85b7c1430bfc0)]:
- @web3modal/wagmi@4.0.12

## 4.0.12-0c59f84f.0

### Patch Changes

- Smart Account RPC handler canary

- Updated dependencies []:
- @web3modal/wagmi@4.0.12-0c59f84f.0

## 4.0.11

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions examples/next-wagmi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@examples/next-wagmi",
"version": "4.0.11",
"version": "4.0.12",
"private": true,
"scripts": {
"dev": "next dev",
Expand All @@ -10,7 +10,7 @@
},
"dependencies": {
"@tanstack/react-query": "5.17.19",
"@web3modal/wagmi": "4.0.11",
"@web3modal/wagmi": "4.0.12",
"next": "14.1.0",
"react": "18.2.0",
"react-dom": "18.2.0",
Expand Down
20 changes: 20 additions & 0 deletions examples/react-ethers5/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# @examples/react-ethers5

## 4.0.12

### Patch Changes

- [#2014](https://github.com/WalletConnect/web3modal/pull/2014) [`95b35e1`](https://github.com/WalletConnect/web3modal/commit/95b35e1ebaf261a56a29cd9254d85b7c1430bfc0) Thanks [@tomiir](https://github.com/tomiir)! - Smart Account RPC handler canary

- Smart Account initialization and feature flag

- Updated dependencies [[`95b35e1`](https://github.com/WalletConnect/web3modal/commit/95b35e1ebaf261a56a29cd9254d85b7c1430bfc0)]:
- @web3modal/ethers5@4.0.12

## 4.0.12-0c59f84f.0

### Patch Changes

- Smart Account RPC handler canary

- Updated dependencies []:
- @web3modal/ethers5@4.0.12-0c59f84f.0

## 4.0.11

### Patch Changes
Expand Down
Loading

0 comments on commit ff9884b

Please sign in to comment.