Skip to content

Commit

Permalink
chore: remove mock attestor (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
joepegler authored Dec 10, 2024
1 parent d6bcde9 commit 12b47a5
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 20 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @biconomy/sdk

## 0.0.17

### Patch Changes

- Add mock attestor only for testnets

## 0.0.16

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
14 changes: 5 additions & 9 deletions src/sdk/account/toNexusAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import {
} from "viem/account-abstraction"

import {
BICONOMY_ATTESTER_ADDRESS,
ENTRY_POINT_ADDRESS,
MOCK_ATTESTER_ADDRESS,
RHINESTONE_ATTESTER_ADDRESS,
Expand Down Expand Up @@ -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<
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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]
})

/**
Expand Down
4 changes: 1 addition & 3 deletions src/sdk/clients/createBundlerClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()
Expand Down
21 changes: 14 additions & 7 deletions src/test/playground.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -37,8 +38,6 @@ import {
getTestParamsForTestnet
} from "./testUtils"

export const index = 6n

describe.skipIf(!playgroundTrue())("playground", () => {
let network: NetworkConfig
// Required for "PUBLIC_TESTNET" networks
Expand All @@ -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,
Expand All @@ -89,7 +88,6 @@ describe.skipIf(!playgroundTrue())("playground", () => {
transport: http(network.paymasterUrl)
})
: undefined,
index,
...testParams
})
})
Expand Down Expand Up @@ -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()
})
Expand Down Expand Up @@ -232,7 +240,6 @@ describe.skipIf(!playgroundTrue())("playground", () => {
signer: eoaAccount,
transport: http(),
bundlerTransport: http(bundlerUrl),
index,
...testParams
})

Expand Down

0 comments on commit 12b47a5

Please sign in to comment.