Skip to content

Commit a8b6c26

Browse files
authored
feat: fusion (#16)
* feat: fusion * resolved BIC-411
1 parent 1874863 commit a8b6c26

File tree

116 files changed

+4531
-1383
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+4531
-1383
lines changed

.env.example

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ PIMLICO_API_KEY=
99
TENDERLY_API_KEY=
1010
TENDERLY_ACCOUNT_SLUG=
1111
TENDERLY_PROJECT_SLUG=
12-
RUN_PAID_TESTS=false
12+
RUN_PAID_TESTS=false
13+
ALCHEMY_API_KEY=

.github/workflows/funded-tests.yml

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ jobs:
2525
run: bun run fund:nexus
2626
env:
2727
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
28+
ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }}
2829
TESTNET_CHAIN_ID: 84532
2930
MAINNET_CHAIN_ID: 10
3031

@@ -35,6 +36,7 @@ jobs:
3536
PIMLICO_API_KEY: ${{ secrets.PIMLICO_API_KEY }}
3637
PAYMASTER_URL: ${{ secrets.PAYMASTER_URL }}
3738
BUNDLER_URL: ${{ secrets.BUNDLER_URL }}
39+
ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }}
3840
TESTNET_CHAIN_ID: 84532
3941
MAINNET_CHAIN_ID: 10
4042
RUN_PAID_TESTS: true

.github/workflows/unit-tests.yml

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ jobs:
2525
run: bun run fund:nexus
2626
env:
2727
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
28+
ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }}
2829
TESTNET_CHAIN_ID: 84532
2930
MAINNET_CHAIN_ID: 10
3031

@@ -35,6 +36,7 @@ jobs:
3536
PIMLICO_API_KEY: ${{ secrets.PIMLICO_API_KEY }}
3637
PAYMASTER_URL: ${{ secrets.PAYMASTER_URL }}
3738
BUNDLER_URL: ${{ secrets.BUNDLER_URL }}
39+
ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }}
3840
TESTNET_CHAIN_ID: 84532
3941
MAINNET_CHAIN_ID: 10
4042
CI: true

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @biconomy/abstractjs
22

3+
## 0.0.38
4+
5+
### Patch Changes
6+
7+
- Fusion support
8+
39
## 0.0.37
410

511
### Patch Changes

README.md

+4-6
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ The Biconomy SDK is your all-in-one toolkit for building decentralized applicati
1212

1313
- [📚 Table of Contents](#-table-of-contents)
1414
- [🛠️ Quickstart](#-quickstart)
15-
1615
- [Prerequisites](#prerequisites)
1716
- [Installation](#installation)
18-
1917
- [📄 Documentation and Resources](#-documentation-and-resources)
2018
- [💼 Examples](#-examples)
2119
- [License](#license)
@@ -35,10 +33,11 @@ bun add @biconomy/abstractjs viem @rhinestone/module-sdk
3533
import { toMultichainNexusAccount, mcUSDC } from "@biconomy/abstractjs";
3634
import { base, optimism } from "viem/chains";
3735
import { privateKeyToAccount } from "viem/accounts";
38-
36+
import { http } from "viem";
3937
const eoaAccount = privateKeyToAccount(`0x${process.env.PRIVATE_KEY}`)
4038
const mcNexus = await toMultichainNexusAccount({
4139
chains: [base, optimism],
40+
transports: [http(), http()],
4241
signer: eoaAccount
4342
})
4443
const meeClient = await createMeeClient({ account: mcNexus })
@@ -75,7 +74,7 @@ bun install --frozen-lockfile
7574
**Funding test accounts:**
7675

7776
```bash
78-
# Fund test PRIVATE_KEY account with native tokens and USDC
77+
# Fund test nexus accounts with native tokens and USDC, using a funded PRIVATE_KEY master account
7978
bun run fund:nexus
8079
```
8180

@@ -86,7 +85,6 @@ bun run test
8685

8786
# Run tests for a specific subset of tests (by test description)
8887
bun run test -t=mee
89-
9088
```
9189

9290
For detailed information about the testing framework, network configurations, and debugging guidelines, please refer to our [Testing Documentation](./src/test/README.md).
@@ -97,7 +95,7 @@ For a comprehensive understanding of our project and to contribute effectively,
9795

9896
- [**Biconomy Documentation**](https://docs.biconomy.io)
9997
- [**Biconomy Dashboard**](https://dashboard.biconomy.io)
100-
- [**API Documentation**](https://bcnmy.github.io/sdk)
98+
- [**API Documentation**](https://bcnmy.github.io/abstractjs)
10199
- [**Contributing Guidelines**](./CONTRIBUTING.md): Learn how to contribute to our project, from code contributions to documentation improvements.
102100
- [**Code of Conduct**](./CODE_OF_CONDUCT.md): Our commitment to fostering an open and welcoming environment.
103101
- [**Security Policy**](./SECURITY.md): Guidelines for reporting security vulnerabilities.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@biconomy/abstractjs",
3-
"version": "0.0.37",
3+
"version": "0.0.38",
44
"author": "Biconomy",
55
"repository": "github:bcnmy/abstractjs",
66
"main": "./dist/_cjs/index.js",

scripts/fund:nexus.ts

+16-30
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import {
44
type Address,
55
type Chain,
66
type Hex,
7+
type Transport,
78
createPublicClient,
89
createWalletClient,
910
encodeFunctionData,
10-
erc20Abi,
1111
formatEther,
1212
formatUnits,
1313
parseEther,
@@ -18,6 +18,7 @@ import { privateKeyToAccount } from "viem/accounts"
1818
import { base, optimism } from "viem/chains"
1919
import { toMultichainNexusAccount, toNexusAccount } from "../src/sdk/account"
2020
import { getChain } from "../src/sdk/account/utils/getChain"
21+
import { TokenWithPermitAbi } from "../src/sdk/constants"
2122
import { mcUSDC, testnetMcUSDC } from "../src/sdk/constants/tokens"
2223

2324
dotenv.config()
@@ -27,7 +28,6 @@ type EnvVars = {
2728
PRIVATE_KEY: Hex
2829
TESTNET_CHAIN_ID: number
2930
}
30-
const MAINNET_CHAINS_FOR_TESTING = [optimism, base]
3131
const NATIVE_TOKEN_AMOUNT = parseEther("0.001")
3232
const USDC_TOKEN_AMOUNT = parseUnits("1", 6)
3333
const index = 0n
@@ -59,20 +59,22 @@ async function main() {
5959
}
6060

6161
console.log("\n=== MEE Nexus Account ===")
62-
const chains = getTestChains(chain)
63-
const [paymentChain, targetChain] = chains
62+
const chains = [optimism, base]
63+
const transports: Transport[] = [http(), http()]
64+
6465
const mcNexus = await toMultichainNexusAccount({
6566
signer: account,
6667
chains,
68+
transports,
6769
index
6870
})
6971

7072
const mcNexusAddress = await mcNexus
71-
.deploymentOn(paymentChain.id, true)
73+
.deploymentOn(optimism.id, true)
7274
.getAddress()
7375

7476
console.log(`Address: ${mcNexusAddress}`)
75-
console.log(`Network: ${paymentChain.name}`)
77+
console.log(`Network: ${optimism.name}`)
7678

7779
const [meeNexusNativeBalance, usdcNexusBalance] = await getBalances(
7880
{ chainId: MAINNET_CHAIN_ID, tokenAddress: mainnetUsdc },
@@ -85,7 +87,7 @@ async function main() {
8587
const masterClient = createWalletClient({
8688
account,
8789
transport: http(),
88-
chain: paymentChain
90+
chain: optimism
8991
}).extend(publicActions)
9092

9193
if (meeNexusNativeBalance >= NATIVE_TOKEN_AMOUNT) {
@@ -99,8 +101,7 @@ async function main() {
99101
})
100102

101103
const nativeTxReceipt = await masterClient.waitForTransactionReceipt({
102-
hash: nativeTx,
103-
confirmations: 1
104+
hash: nativeTx
104105
})
105106
console.log("Native Transaction:", nativeTxReceipt.transactionHash)
106107
}
@@ -111,15 +112,14 @@ async function main() {
111112
const usdcTx = await masterClient.sendTransaction({
112113
to: mainnetUsdc,
113114
data: encodeFunctionData({
114-
abi: erc20Abi,
115+
abi: TokenWithPermitAbi,
115116
functionName: "transfer",
116117
args: [mcNexusAddress, USDC_TOKEN_AMOUNT]
117118
})
118119
})
119120

120121
const usdcTxReceipt = await masterClient.waitForTransactionReceipt({
121-
hash: usdcTx,
122-
confirmations: 1
122+
hash: usdcTx
123123
})
124124
console.log("USDC Transaction:", usdcTxReceipt.transactionHash)
125125
}
@@ -176,8 +176,7 @@ async function main() {
176176
})
177177
const vanillaNexusUsdcTxReceipt =
178178
await testnetClient.waitForTransactionReceipt({
179-
hash: nativeTx,
180-
confirmations: 1
179+
hash: nativeTx
181180
})
182181
console.log(
183182
`Vanilla Nexus USDC Transaction on testnet chain ${testnetChain.name}:`,
@@ -193,15 +192,14 @@ async function main() {
193192
const vanillaNexusUsdcTx = await testnetClient.sendTransaction({
194193
to: testnetUsdc,
195194
data: encodeFunctionData({
196-
abi: erc20Abi,
195+
abi: TokenWithPermitAbi,
197196
functionName: "transfer",
198197
args: [vanillaNexusAddress, USDC_TOKEN_AMOUNT]
199198
})
200199
})
201200
const vanillaNexusUsdcTxReceipt =
202201
await testnetClient.waitForTransactionReceipt({
203-
hash: vanillaNexusUsdcTx,
204-
confirmations: 1
202+
hash: vanillaNexusUsdcTx
205203
})
206204
console.log(
207205
"Vanilla Nexus USDC Transaction:",
@@ -225,7 +223,7 @@ const getBalances = async (
225223
}),
226224
publicClient.readContract({
227225
address: envVars.tokenAddress,
228-
abi: erc20Abi,
226+
abi: TokenWithPermitAbi,
229227
functionName: "balanceOf",
230228
args: [address]
231229
})
@@ -248,18 +246,6 @@ const getEnvVars = (): EnvVars => {
248246
}
249247
}
250248

251-
const getTestChains = (chain: Chain) => {
252-
const defaultChainsIncludePaymentChain = MAINNET_CHAINS_FOR_TESTING.some(
253-
({ id }) => Number(id) === chain.id
254-
)
255-
if (defaultChainsIncludePaymentChain) {
256-
return MAINNET_CHAINS_FOR_TESTING.sort((a, b) =>
257-
a.id === chain.id ? -1 : 1
258-
)
259-
}
260-
throw new Error("Unsupported chain")
261-
}
262-
263249
main()
264250
.then(() => process.exit(0))
265251
.catch((error) => {

src/sdk/account/decorators/build.test.ts

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import type { Chain, LocalAccount } from "viem"
1+
import type { Chain, LocalAccount, Transport } from "viem"
22
import { beforeAll, describe, expect, it } from "vitest"
3-
import { getTestChains, toNetwork } from "../../../test/testSetup"
3+
import { getTestChainConfig, toNetwork } from "../../../test/testSetup"
44
import type { NetworkConfig } from "../../../test/testUtils"
55
import { type MeeClient, createMeeClient } from "../../clients/createMeeClient"
66
import { mcUSDC } from "../../constants/tokens"
@@ -10,24 +10,26 @@ import {
1010
} from "../toMultiChainNexusAccount"
1111
import { build } from "./build"
1212

13-
describe("mee:build", () => {
13+
describe("mee.build", () => {
1414
let network: NetworkConfig
1515
let eoaAccount: LocalAccount
1616

1717
let mcNexus: MultichainSmartAccount
1818
let meeClient: MeeClient
1919

20-
let targetChain: Chain
2120
let paymentChain: Chain
21+
let targetChain: Chain
22+
let transports: Transport[]
2223

2324
beforeAll(async () => {
2425
network = await toNetwork("MAINNET_FROM_ENV_VARS")
25-
;[paymentChain, targetChain] = getTestChains(network)
26+
;[[paymentChain, targetChain], transports] = getTestChainConfig(network)
2627

2728
eoaAccount = network.account!
2829

2930
mcNexus = await toMultichainNexusAccount({
3031
chains: [paymentChain, targetChain],
32+
transports,
3133
signer: eoaAccount
3234
})
3335

@@ -75,7 +77,7 @@ describe("mee:build", () => {
7577
{
7678
type: "intent",
7779
data: {
78-
amount: BigInt(1000),
80+
amount: 1n,
7981
mcToken: mcUSDC,
8082
toChain: targetChain
8183
}

0 commit comments

Comments
 (0)