Skip to content

Commit

Permalink
Merge branch 'wevm:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
nikola-bozin-txfusion authored Sep 11, 2024
2 parents ca4040b + dccccc9 commit 101f3e1
Show file tree
Hide file tree
Showing 109 changed files with 903 additions and 614 deletions.
5 changes: 0 additions & 5 deletions .changeset/.lucky-actors-smell.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/rich-seas-jog.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/slimy-melons-bathe.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/three-fireants-beg.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/wise-planets-press.md

This file was deleted.

2 changes: 2 additions & 0 deletions .github/actions/install-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ runs:
steps:
- name: Set up foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly-143abd6a768eeb52a5785240b763d72a56987b4a

- name: Set up pnpm
uses: wevm/actions/.github/actions/pnpm@main
1 change: 1 addition & 0 deletions examples/account-abstraction_biconomy-bundler/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_PRIVATE_KEY=
3 changes: 3 additions & 0 deletions examples/account-abstraction_biconomy-bundler/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Biconomy Bundler Example

[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/wevm/viem/tree/main/examples/account-abstraction_biconomy-bundler)
20 changes: 20 additions & 0 deletions examples/account-abstraction_biconomy-bundler/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body>
<h1>Biconomy Bundler Example</h1>
<div id="app"><button>Send User Operation</button></div>
<script type="module">
document.querySelector('button').addEventListener('click', async () => {
document.querySelector('#app').innerHTML = 'Sending...'
const response = await import('./index.ts').then((x) => x.default);
document.querySelector('#app').innerHTML = response
.map((x) => `<div style="margin-top: 16px;">${x}</div>`)
.join('');
})
</script>
</body>
</html>
59 changes: 59 additions & 0 deletions examples/account-abstraction_biconomy-bundler/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { http, type Hex, createPublicClient, parseEther } from 'viem'
import {
createBundlerClient,
createPaymasterClient,
toCoinbaseSmartAccount,
} from 'viem/account-abstraction'
import { privateKeyToAccount } from 'viem/accounts'
import { sepolia } from 'viem/chains'

const client = createPublicClient({
chain: sepolia,
transport: http(),
})

const owner = privateKeyToAccount(import.meta.env.VITE_PRIVATE_KEY as Hex)

const account = await toCoinbaseSmartAccount({
client,
owners: [owner],
})

const paymasterClient = createPaymasterClient({
transport: http(
'https://paymaster.biconomy.io/api/v1/11155111/kxBB8jbLI.fb3e07cf-c4cd-4d20-8503-c396e405b0df',
),
})

const bundlerClient = createBundlerClient({
account,
client,
transport: http(
'https://bundler.biconomy.io/api/v2/11155111/kxBB8jbLI.fb3e07cf-c4cd-4d20-8503-c396e405b0df',
),
paymaster: paymasterClient,
paymasterContext: {
mode: 'SPONSORED',
calculateGasLimits: true,
expiryDuration: 300,
sponsorshipInfo: {
webhookData: {},
smartAccountInfo: {
name: 'BICONOMY',
version: '2.0.0',
},
},
},
})

const hash = await bundlerClient.sendUserOperation({
calls: [
// send 0.000001 ETH to self
{
to: account.address,
value: parseEther('0.000001'),
},
],
})

export default [`User Operation Hash: ${hash}`]
15 changes: 15 additions & 0 deletions examples/account-abstraction_biconomy-bundler/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "example-biconomy-bundler",
"private": true,
"type": "module",
"scripts": {
"dev": "vite"
},
"dependencies": {
"viem": "latest"
},
"devDependencies": {
"typescript": "^5.0.3",
"vite": "^4.4.5"
}
}
20 changes: 20 additions & 0 deletions examples/account-abstraction_biconomy-bundler/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": ["ESNext", "DOM"],
"moduleResolution": "Node",
"strict": true,
"resolveJsonModule": true,
"isolatedModules": true,
"esModuleInterop": true,
"noEmit": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"skipLibCheck": true
},
"include": ["src"]
}

10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"sherif": "^0.8.4",
"simple-git-hooks": "^2.8.1",
"size-limit": "^11.1.2",
"typescript": "5.5.2",
"typescript": "5.6.2",
"vitest": "^1.0.4"
},
"trustedDependencies": ["c-kzg"],
Expand Down Expand Up @@ -121,7 +121,7 @@
{
"name": "import { createClient, http } from 'viem'",
"path": "./src/_esm/index.js",
"limit": "6.4 kB",
"limit": "6.5 kB",
"import": "{ createClient, http }"
},
{
Expand All @@ -148,6 +148,12 @@
"limit": "20 kB",
"import": "{ privateKeyToAccount }"
},
{
"name": "import { mnemonicToAccount } from 'viem/accounts'",
"path": "./src/_esm/accounts/index.js",
"limit": "30 kB",
"import": "{ mnemonicToAccount }"
},
{
"name": "import * from 'viem/actions'",
"path": "./src/_esm/actions/index.js",
Expand Down
Loading

0 comments on commit 101f3e1

Please sign in to comment.