Skip to content

Commit 367e6c9

Browse files
🔄 synced file(s) with circlefin/modularwallets-web-sdk-internal (#14)
synced local file(s) with [circlefin/modularwallets-web-sdk-internal](https://github.com/circlefin/modularwallets-web-sdk-internal). <details> <summary>Changed files</summary> <ul> <li>synced local directory <code>examples/</code> with remote directory <code>examples/</code></li><li>synced local directory <code>packages/</code> with remote directory <code>packages/</code></li><li>synced local <code>package.json</code> with remote <code>package.json</code></li><li>synced local <code>pnpm-lock.yaml</code> with remote <code>pnpm-lock.yaml</code></li> </ul> </details> --- This PR was created automatically by the [repo-file-sync-action](https://github.com/BetaHuhn/repo-file-sync-action) workflow run [#15030731845](https://github.com/circlefin/modularwallets-web-sdk-internal/actions/runs/15030731845)
1 parent f4d3d22 commit 367e6c9

File tree

14 files changed

+116
-90
lines changed

14 files changed

+116
-90
lines changed

‎examples/circle-smart-account/index.tsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from 'react'
22
import * as ReactDOM from 'react-dom/client'
33
import { polygonAmoy } from 'viem/chains'
44

5-
import { type Hex, createPublicClient, parseEther } from 'viem'
5+
import { type Hex, createPublicClient, parseUnits } from 'viem'
66
import {
77
type P256Credential,
88
type SmartAccount,
@@ -16,11 +16,15 @@ import {
1616
toModularTransport,
1717
toPasskeyTransport,
1818
toWebAuthnCredential,
19+
encodeTransfer,
20+
ContractAddress
1921
} from '@circle-fin/modular-wallets-core'
2022

2123
const clientKey = import.meta.env.VITE_CLIENT_KEY as string
2224
const clientUrl = import.meta.env.VITE_CLIENT_URL as string
2325

26+
const USDC_DECIMALS = 6
27+
2428
// Create Circle transports
2529
const passkeyTransport = toPasskeyTransport(clientUrl, clientKey)
2630
const modularTransport = toModularTransport(`${clientUrl}/polygonAmoy`, clientKey)
@@ -88,14 +92,16 @@ function Example() {
8892
const to = formData.get('to') as `0x${string}`
8993
const value = formData.get('value') as string
9094

95+
// Create callData for USDC transfer
96+
const callData = encodeTransfer(
97+
to,
98+
ContractAddress.PolygonAmoy_USDC,
99+
parseUnits(value, USDC_DECIMALS)
100+
)
101+
91102
const hash = await bundlerClient.sendUserOperation({
92103
account,
93-
calls: [
94-
{
95-
to,
96-
value: parseEther(value),
97-
},
98-
],
104+
calls: [callData],
99105
paymaster: true,
100106
})
101107
setUserOpHash(hash)
@@ -125,7 +131,7 @@ function Example() {
125131
<h2>Send User Operation</h2>
126132
<form onSubmit={sendUserOperation}>
127133
<input name="to" placeholder="Address" />
128-
<input name="value" placeholder="Amount (ETH)" />
134+
<input name="value" placeholder="Amount (USDC)" />
129135
<button type="submit">Send</button>
130136
{userOpHash && <p>User Operation Hash: {userOpHash}</p>}
131137
{hash && <p>Transaction Hash: {hash}</p>}

‎examples/circle-smart-account/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
"@types/react-dom": "^18.0.10",
1818
"@vitejs/plugin-react": "^4.3.2",
1919
"typescript": "^5.0.3",
20-
"vite": "^5.4.14"
20+
"vite": "^5.4.18"
2121
}
2222
}

‎examples/circle-smart-account/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
"noEmit": true,
1717
"jsx": "react-jsx",
1818
},
19-
"include": ["src"],
19+
"include": ["src", "*.tsx", "*.ts", "vite-env.d.ts"],
2020
"references": [{ "path": "./tsconfig.node.json" }]
2121
}

‎examples/dynamic-integration/index.tsx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
import React, { useEffect } from "react"
2-
import { createPublicClient, Hex, parseEther } from "viem"
2+
import { createPublicClient, Hex, parseUnits } from "viem"
33

44
import { isEthereumWallet } from "@dynamic-labs/ethereum"
55
import { useDynamicContext } from "@dynamic-labs/sdk-react-core"
66
import {
77
toCircleSmartAccount,
88
toModularTransport,
9-
walletClientToLocalAccount
9+
walletClientToLocalAccount,
10+
encodeTransfer,
11+
ContractAddress
1012
} from "@circle-fin/modular-wallets-core"
1113
import { createBundlerClient, SmartAccount } from "viem/account-abstraction"
1214
import { polygonAmoy } from "viem/chains"
1315

1416
const clientKey = import.meta.env.VITE_CLIENT_KEY as string
1517
const clientUrl = import.meta.env.VITE_CLIENT_URL as string
1618

19+
const USDC_DECIMALS = 6
20+
1721
// Create Circle transports
1822
const modularTransport = toModularTransport(`${clientUrl}/polygonAmoy`, clientKey)
1923

@@ -67,14 +71,16 @@ export const Example = () => {
6771
const to = formData.get("to") as `0x${string}`
6872
const value = formData.get("value") as string
6973

74+
// Create callData for USDC transfer
75+
const callData = encodeTransfer(
76+
to,
77+
ContractAddress.PolygonAmoy_USDC,
78+
parseUnits(value, USDC_DECIMALS)
79+
)
80+
7081
const hash = await bundlerClient.sendUserOperation({
7182
account,
72-
calls: [
73-
{
74-
to,
75-
value: parseEther(value),
76-
},
77-
],
83+
calls: [callData],
7884
paymaster: true,
7985
})
8086
setUserOpHash(hash)
@@ -99,7 +105,7 @@ export const Example = () => {
99105
<h2>Send User Operation</h2>
100106
<form onSubmit={sendUserOperation}>
101107
<input name="to" placeholder="Address" />
102-
<input name="value" placeholder="Amount (ETH)" />
108+
<input name="value" placeholder="Amount (USDC)" />
103109
<button type="submit">Send</button>
104110
{userOpHash && <p>User Operation Hash: {userOpHash}</p>}
105111
{hash && <p>Transaction Hash: {hash}</p>}

‎examples/dynamic-integration/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@
1919
"@types/react-dom": "^18.0.10",
2020
"@vitejs/plugin-react": "^4.3.2",
2121
"typescript": "^5.0.3",
22-
"vite": "^5.4.14"
22+
"vite": "^5.4.18"
2323
}
2424
}

‎examples/dynamic-integration/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
"noEmit": true,
1717
"jsx": "react-jsx",
1818
},
19-
"include": ["src"],
19+
"include": ["src", "*.tsx", "*.ts", "vite-env.d.ts"],
2020
"references": [{ "path": "./tsconfig.node.json" }]
2121
}

‎examples/eip-1193/index.tsx

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as ReactDOM from "react-dom/client"
33
import { polygonAmoy } from "viem/chains"
44
import Web3 from "web3"
55

6-
import { type Hex, createClient, createPublicClient, http } from "viem"
6+
import { type Hex, createClient, createPublicClient, http, parseUnits } from "viem"
77
import {
88
type P256Credential,
99
type SmartAccount,
@@ -18,12 +18,16 @@ import {
1818
toModularTransport,
1919
toPasskeyTransport,
2020
toWebAuthnCredential,
21+
encodeTransfer,
22+
ContractAddress,
2123
} from "@circle-fin/modular-wallets-core"
2224

2325
const clientKey = import.meta.env.VITE_CLIENT_KEY as string
2426
const clientUrl = import.meta.env.VITE_CLIENT_URL as string
2527
const publicRpcUrl = import.meta.env.VITE_PUBLIC_RPC_URL as string
2628

29+
const USDC_DECIMALS = 6
30+
2731
// Create Circle transports
2832
const passkeyTransport = toPasskeyTransport(clientUrl, clientKey)
2933
const modularTransport = toModularTransport(`${clientUrl}/polygonAmoy`, clientKey)
@@ -115,19 +119,27 @@ function Example() {
115119
const sendTx = async (event: React.FormEvent<HTMLFormElement>) => {
116120
event.preventDefault()
117121

118-
if (!web3) return
122+
if (!web3 || !account) return
119123

120124
const formData = new FormData(event.currentTarget)
121-
const to = formData.get("to") as `0x${string}`
125+
const sendTo = formData.get("to") as `0x${string}`
122126
const value = formData.get("value") as string
123127

124128
try {
125129
const suggestedGasPrice = ((await web3.eth.getGasPrice()) * 11n) / 10n // 10% higher than the current gas price to ensure the transaction goes through
126-
127-
// Send tokens to the address that was input
130+
131+
// Get the ERC20 transfer method data
132+
const { to, data } = encodeTransfer(
133+
sendTo,
134+
ContractAddress.PolygonAmoy_USDC,
135+
parseUnits(value, USDC_DECIMALS)
136+
)
137+
138+
// Send transaction to the USDC contract address
128139
const tx = await web3.eth.sendTransaction({
129140
to,
130-
value: web3.utils.toWei(value, "ether"),
141+
from: account.address,
142+
data,
131143
gas: 53638, // Estimated gas limit for a simple transaction
132144
gasPrice: suggestedGasPrice,
133145
})
@@ -198,7 +210,7 @@ function Example() {
198210
<h2>Send Transaction</h2>
199211
<form onSubmit={sendTx}>
200212
<input name="to" placeholder="Address" />
201-
<input name="value" placeholder="Amount (ETH)" />
213+
<input name="value" placeholder="Amount (USDC)" />
202214
<button type="submit">Send</button>
203215
</form>
204216
<button onClick={getProviderAddress}>Get address</button>

‎examples/eip-1193/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
"@types/react-dom": "^18.0.10",
1919
"@vitejs/plugin-react": "^4.3.2",
2020
"typescript": "^5.0.3",
21-
"vite": "^5.4.14"
21+
"vite": "^5.4.18"
2222
}
2323
}

‎examples/eip-1193/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
"noEmit": true,
1717
"jsx": "react-jsx",
1818
},
19-
"include": ["src"],
19+
"include": ["src", "*.tsx", "*.ts", "vite-env.d.ts"],
2020
"references": [{ "path": "./tsconfig.node.json" }]
2121
}

‎examples/passkey-recovery/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"@types/react-dom": "^18.0.10",
1919
"@vitejs/plugin-react": "^4.3.2",
2020
"typescript": "^5.0.3",
21-
"vite": "^5.4.14",
21+
"vite": "^5.4.18",
2222
"vite-plugin-node-polyfills": "^0.21.0"
2323
}
2424
}

‎package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@
1515
"@types/jest": "^29.5.12",
1616
"@types/node": "^22.5.3",
1717
"ts-jest": "^29.2.5",
18-
"turbo": "^2.3.3",
18+
"turbo": "^2.5.0",
1919
"typescript": "^5.8.2"
2020
},
2121
"engines": {
2222
"node": "20.18.0"
2323
},
2424
"resolutions": {
2525
"cross-spawn": "^7.0.5",
26-
"nanoid": "^3.3.8"
26+
"nanoid": "^3.3.8",
27+
"image-size": "1.2.1"
2728
},
2829
"packageManager": "[email protected]+sha1.da220e966c2db3275efb5928cf8f3592681b106b"
2930
}

‎packages/w3s-web-core-sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@circle-fin/modular-wallets-core",
33
"description": "Serverless Typescript SDK",
4-
"version": "1.0.7",
4+
"version": "1.0.8",
55
"main": "./dist/index.js",
66
"module": "./dist/index.mjs",
77
"types": "./dist/index.d.ts",

‎packages/w3s-web-core-sdk/src/constants/smartAccount.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export const REPLAY_SAFE_HASH_V1 = {
8181

8282
export const EIP712_PREFIX = '0x1901'
8383

84-
export const MINIMUM_VERIFICATION_GAS_LIMIT = 600_000
84+
export const MINIMUM_VERIFICATION_GAS_LIMIT = 100_000
8585
export const MINIMUM_UNDEPLOY_VERIFICATION_GAS_LIMIT = 1_500_000
8686

8787
export const SEPOLIA_MINIMUM_VERIFICATION_GAS_LIMIT = 600_000

0 commit comments

Comments
 (0)