diff --git a/CHANGELOG.md b/CHANGELOG.md index a519d9801..b015364b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # @biconomy/sdk +## 0.0.17 + +### Patch Changes + +- Add mock attestor only for testnets + ## 0.0.16 ### Patch Changes diff --git a/package.json b/package.json index 47fc7ea9a..ca571c409 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@biconomy/sdk", - "version": "0.0.16", + "version": "0.0.17", "author": "Biconomy", "repository": "github:bcnmy/sdk", "main": "./dist/_cjs/index.js", diff --git a/src/sdk/account/toNexusAccount.ts b/src/sdk/account/toNexusAccount.ts index ab94c9c73..9fea9a749 100644 --- a/src/sdk/account/toNexusAccount.ts +++ b/src/sdk/account/toNexusAccount.ts @@ -45,7 +45,6 @@ import { } from "viem/account-abstraction" import { - BICONOMY_ATTESTER_ADDRESS, ENTRY_POINT_ADDRESS, MOCK_ATTESTER_ADDRESS, RHINESTONE_ATTESTER_ADDRESS, @@ -104,9 +103,9 @@ export type ToNexusSmartAccountParameters = { k1ValidatorAddress?: Address /** Optional account address override */ accountAddress?: Address - /** Attesters to add to the account */ + /** Attester addresses to apply to the account */ attesters?: Address[] - /** Optional threshold for the account */ + /** Optional attestors threshold for the account */ attesterThreshold?: number } & Prettify< Pick< @@ -181,11 +180,7 @@ export const toNexusAccount = async ( k1ValidatorAddress = k1ValidatorAddress_, key = "nexus account", name = "Nexus Account", - attesters = [ - RHINESTONE_ATTESTER_ADDRESS, - MOCK_ATTESTER_ADDRESS, - BICONOMY_ATTESTER_ADDRESS - ], + attesters: attesters_ = [RHINESTONE_ATTESTER_ADDRESS], attesterThreshold = 1 } = parameters @@ -218,12 +213,13 @@ export const toNexusAccount = async ( // Review: // Todo: attesters can be added here to do one time setup upon deployment. + chain?.testnet && attesters_.push(MOCK_ATTESTER_ADDRESS) const factoryData = encodeFunctionData({ abi: parseAbi([ "function createAccount(address eoaOwner, uint256 index, address[] attesters, uint8 threshold) external returns (address)" ]), functionName: "createAccount", - args: [signerAddress, index, attesters, attesterThreshold] + args: [signerAddress, index, attesters_, attesterThreshold] }) /** diff --git a/src/sdk/clients/createBundlerClient.test.ts b/src/sdk/clients/createBundlerClient.test.ts index 3d97e7763..407aad3ab 100644 --- a/src/sdk/clients/createBundlerClient.test.ts +++ b/src/sdk/clients/createBundlerClient.test.ts @@ -3,7 +3,6 @@ import { createBundlerClient } from "viem/account-abstraction" import { privateKeyToAccount } from "viem/accounts" import { baseSepolia } from "viem/chains" import { beforeAll, describe, expect, test } from "vitest" -import { index } from "../../test/playground.test" import { type NexusAccount, toNexusAccount } from "../account/toNexusAccount" import { safeMultiplier } from "../account/utils" import { MAINNET_ADDRESS_K1_VALIDATOR_ADDRESS } from "../constants" @@ -41,8 +40,7 @@ describe.each(COMPETITORS)( transport: http(), // You can omit this outside of a testing context k1ValidatorAddress: MAINNET_ADDRESS_K1_VALIDATOR_ADDRESS, - factoryAddress: MAINNET_ADDRESS_K1_VALIDATOR_FACTORY_ADDRESS, - index + factoryAddress: MAINNET_ADDRESS_K1_VALIDATOR_FACTORY_ADDRESS }) nexusAccountAddress = await nexusAccount.getCounterFactualAddress() diff --git a/src/test/playground.test.ts b/src/test/playground.test.ts index c238fd611..2380c8d2d 100644 --- a/src/test/playground.test.ts +++ b/src/test/playground.test.ts @@ -9,7 +9,8 @@ import { type WalletClient, createPublicClient, createWalletClient, - encodeFunctionData + encodeFunctionData, + parseEther } from "viem" import { beforeAll, describe, expect, test } from "vitest" import { playgroundTrue } from "../sdk/account/utils/Utils" @@ -37,8 +38,6 @@ import { getTestParamsForTestnet } from "./testUtils" -export const index = 6n - describe.skipIf(!playgroundTrue())("playground", () => { let network: NetworkConfig // Required for "PUBLIC_TESTNET" networks @@ -62,7 +61,7 @@ describe.skipIf(!playgroundTrue())("playground", () => { bundlerUrl = network.bundlerUrl eoaAccount = network.account as PrivateKeyAccount - recipientAddress = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045" // vitalik.eth + recipientAddress = eoaAccount.address walletClient = createWalletClient({ account: eoaAccount, @@ -89,7 +88,6 @@ describe.skipIf(!playgroundTrue())("playground", () => { transport: http(network.paymasterUrl) }) : undefined, - index, ...testParams }) }) @@ -119,9 +117,19 @@ describe.skipIf(!playgroundTrue())("playground", () => { chain, account: eoaAccount, to: nexusAccountAddress, - value: 100000000000000000n + value: parseEther("0.01") }) const receipt = await publicClient.waitForTransactionReceipt({ hash }) + expect(receipt.status).toBe("success") + const [ownerBalanceTwo, smartAccountBalanceTwo] = await Promise.all([ + publicClient.getBalance({ + address: eoaAccount.address + }), + publicClient.getBalance({ + address: nexusAccountAddress + }) + ]) + console.log({ ownerBalanceTwo, smartAccountBalanceTwo }) } expect(balancesAreOfCorrectType).toBeTruthy() }) @@ -232,7 +240,6 @@ describe.skipIf(!playgroundTrue())("playground", () => { signer: eoaAccount, transport: http(), bundlerTransport: http(bundlerUrl), - index, ...testParams })