Skip to content

Commit

Permalink
chore: merge left behind mee work
Browse files Browse the repository at this point in the history
  • Loading branch information
joepegler committed Dec 19, 2024
2 parents 311e899 + 0dd2016 commit e25d104
Show file tree
Hide file tree
Showing 45 changed files with 437 additions and 306 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
PRIVATE_KEY=
CHAIN_ID=84532
ALT_CHAIN_ID=11155111
RPC_URL=
BUNDLER_URL=
BICONOMY_SDK_DEBUG=false
RUN_PLAYGROUND=false
PAYMASTER_URL=
PIMLICO_API_KEY=
1 change: 1 addition & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ jobs:
PAYMASTER_URL: ${{ secrets.PAYMASTER_URL }}
BUNDLER_URL: ${{ secrets.BUNDLER_URL }}
CHAIN_ID: 84532
ALT_CHAIN_ID: 11155420
CI: true
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ bun add @biconomy/sdk viem @rhinestone/module-sdk

2. **Basic Usage:**
```typescript
import { createNexusClient } from "@biconomy/sdk";
import { createSmartAccountClient } from "@biconomy/sdk";
import { http } from "viem";

const nexusClient = await createNexusClient({
const nexusClient = await createSmartAccountClient({
signer: account,
chain,
transport: http(),
Expand Down
Binary file modified bun.lockb
Binary file not shown.
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,5 @@
},
"type": "module",
"types": "./dist/_types/index.d.ts",
"typings": "./dist/_types/index.d.ts",
"dependencies": {
"@silencelaboratories/walletprovider-sdk": "^0.3.0"
}
"typings": "./dist/_types/index.d.ts"
}
8 changes: 4 additions & 4 deletions src/sdk/account/toNexusAccount.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ import {
import type { MasterClient, NetworkConfig } from "../../test/testUtils"
import {
type NexusClient,
createNexusClient
} from "../clients/createNexusClient"
createSmartAccountClient
} from "../clients/createSmartAccountClient"
import {
BICONOMY_ATTESTER_ADDRESS,
MAINNET_ADDRESS_K1_VALIDATOR_FACTORY_ADDRESS,
Expand Down Expand Up @@ -90,7 +90,7 @@ describe("nexus.account", async () => {
transport: http()
})

nexusClient = await createNexusClient({
nexusClient = await createSmartAccountClient({
signer: eoaAccount,
chain,
transport: http(),
Expand All @@ -106,7 +106,7 @@ describe("nexus.account", async () => {
})

test("should override account address", async () => {
const newNexusClient = await createNexusClient({
const newNexusClient = await createSmartAccountClient({
chain,
transport: http(),
bundlerTransport: http(bundlerUrl),
Expand Down
1 change: 0 additions & 1 deletion src/sdk/account/utils/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ export type UserOpReceipt = {
logs: Log[]
}

export type Service = "Bundler" | "Paymaster"
export type BigNumberish = Hex | number | bigint
export type BytesLike = Uint8Array | Hex | string

Expand Down
2 changes: 1 addition & 1 deletion src/sdk/account/utils/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import type { AccountMetadata, EIP712DomainReturn } from "./Types"
* @param value - The value to check
* @returns True if the value is null or undefined
*/
export const isNullOrUndefined = (value: any): value is undefined => {
export const isNullOrUndefined = (value: AnyData): value is undefined => {
return value === null || value === undefined
}

Expand Down
85 changes: 0 additions & 85 deletions src/sdk/account/utils/getAAError.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/sdk/account/utils/getChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ type StringOrStrings = string | string[]
*
* @example
*
* import { getCustomChain, createNexusClient } from "@biconomy/sdk"
* import { getCustomChain, createSmartAccountClient } from "@biconomy/sdk"
*
* const customChain = getCustomChain(
* "My Custom Chain",
Expand All @@ -81,7 +81,7 @@ type StringOrStrings = string | string[]
* transport: http()
* })
*
* const smartAccountCustomChain = await createNexusClient({
* const smartAccountCustomChain = await createSmartAccountClient({
* signer: walletClientWithCustomChain,
* bundlerUrl,
* customChain
Expand Down
2 changes: 1 addition & 1 deletion src/sdk/account/utils/toSigner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { JsonRpcProvider, JsonRpcSigner, ethers } from "ethers"
import { http, type Address, type Hex, createWalletClient } from "viem"
import { privateKeyToAccount } from "viem/accounts"
import { afterAll, beforeAll, describe, expect, it } from "vitest"
import { toNetwork } from "../../../test/testSetup"
import { toNetwork, toNetworks } from "../../../test/testSetup"
import { type NetworkConfig, killNetwork, pKey } from "../../../test/testUtils"
import { type EthersWallet, addressEquals } from "./Utils"
import { toSigner } from "./toSigner"
Expand Down
1 change: 1 addition & 0 deletions src/sdk/account/utils/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { toSigner } from "./toSigner"

describe("utils", async () => {
const privKey = generatePrivateKey()

test.concurrent(
"should have consistent behaviour between ethers.AbiCoder.defaultAbiCoder() and viem.encodeAbiParameters()",
async () => {
Expand Down
1 change: 1 addition & 0 deletions src/sdk/clients/createBicoBundlerClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ describe("bico.bundler", async () => {
nexusAccountAddress = await nexusAccount.getCounterFactualAddress()
await topUp(testClient, nexusAccountAddress)
})

afterAll(async () => {
await killNetwork([network?.rpcPort, network?.bundlerPort])
})
Expand Down
21 changes: 12 additions & 9 deletions src/sdk/clients/createBicoPaymasterClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,23 @@ import {
createWalletClient
} from "viem"
import { afterAll, beforeAll, describe, expect, test } from "vitest"
import { paymasterTruthy, toNetwork } from "../../test/testSetup"
import { paymasterTruthy, toNetworks } from "../../test/testSetup"
import { getTestParamsForTestnet, killNetwork } from "../../test/testUtils"
import type { NetworkConfig, TestnetParams } from "../../test/testUtils"
import { type NexusAccount, toNexusAccount } from "../account/toNexusAccount"
import {
type BicoPaymasterClient,
createBicoPaymasterClient
} from "./createBicoPaymasterClient"
import { type NexusClient, createNexusClient } from "./createNexusClient"
import {
type NexusClient,
createSmartAccountClient
} from "./createSmartAccountClient"

describe.runIf(paymasterTruthy())("bico.paymaster", async () => {
let network: NetworkConfig
// Required for "PUBLIC_TESTNET" networks
let testParams: TestnetParams
// Required for "TESTNET_FROM_ENV_VARS" networks
let testnetParams: TestnetParams

let chain: Chain
let bundlerUrl: string
Expand All @@ -39,7 +42,7 @@ describe.runIf(paymasterTruthy())("bico.paymaster", async () => {
let nexusClient: NexusClient

beforeAll(async () => {
network = await toNetwork("PUBLIC_TESTNET")
;[network] = await toNetworks("TESTNET_FROM_ENV_VARS")

chain = network.chain
bundlerUrl = network.bundlerUrl
Expand All @@ -59,7 +62,7 @@ describe.runIf(paymasterTruthy())("bico.paymaster", async () => {
transport: http()
})

testParams = getTestParamsForTestnet(publicClient)
testnetParams = getTestParamsForTestnet(publicClient)

paymaster = createBicoPaymasterClient({
transport: http(paymasterUrl)
Expand All @@ -69,18 +72,18 @@ describe.runIf(paymasterTruthy())("bico.paymaster", async () => {
signer: account,
chain,
transport: http(),
...testParams
...testnetParams
})

nexusAccountAddress = await nexusAccount.getCounterFactualAddress()

nexusClient = await createNexusClient({
nexusClient = await createSmartAccountClient({
signer: account,
chain,
transport: http(),
bundlerTransport: http(bundlerUrl),
paymaster,
...testParams
...testnetParams
})
})
afterAll(async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/sdk/clients/createBundlerClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { type NexusAccount, toNexusAccount } from "../account/toNexusAccount"
import { safeMultiplier } from "../account/utils"
import { MAINNET_ADDRESS_K1_VALIDATOR_ADDRESS } from "../constants"
import { MAINNET_ADDRESS_K1_VALIDATOR_FACTORY_ADDRESS } from "../constants"
import type { NexusClient } from "./createNexusClient"
import type { NexusClient } from "./createSmartAccountClient"
import { erc7579Actions } from "./decorators/erc7579"
import { smartAccountActions } from "./decorators/smartAccount"

Expand Down
6 changes: 3 additions & 3 deletions src/sdk/clients/createNexusClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,18 @@ export type NexusClientConfig<
* @returns Nexus Client. {@link NexusClient}
*
* @example
* import { createNexusClient } from '@biconomy/sdk'
* import { createSmartAccountClient } from '@biconomy/sdk'
* import { http } from 'viem'
* import { mainnet } from 'viem/chains'
*
* const nexusClient = await createNexusClient({
* const nexusClient = await createSmartAccountClient({
* chain: mainnet,
* transport: http('https://mainnet.infura.io/v3/YOUR-PROJECT-ID'),
* bundlerTransport: http('https://api.biconomy.io'),
* signer: '0x...',
* })
*/
export async function createNexusClient(
export async function createSmartAccountClient(
parameters: NexusClientConfig
): Promise<NexusClient> {
const {
Expand Down
16 changes: 9 additions & 7 deletions src/sdk/clients/createNexusSessionClient.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SmartSessionMode } from "@rhinestone/module-sdk"
import { http, type Address, type Chain, type Hex, toBytes, toHex } from "viem"
import { http, type Address, type Chain, type Hex } from "viem"
import type { LocalAccount, PublicClient } from "viem"
import { encodeFunctionData } from "viem"
import { afterAll, beforeAll, describe, expect, test } from "vitest"
Expand Down Expand Up @@ -29,8 +29,10 @@ import {
} from "../modules/smartSessionsValidator/decorators"
import { toSmartSessionsValidator } from "../modules/smartSessionsValidator/toSmartSessionsValidator"
import type { Module } from "../modules/utils/Types"
import { type NexusClient, createNexusClient } from "./createNexusClient"
import { createNexusSessionClient } from "./createNexusSessionClient"
import {
type NexusClient,
createSmartAccountClient
} from "./createSmartAccountClient"

describe("nexus.session.client", async () => {
let network: NetworkConfig
Expand All @@ -49,7 +51,7 @@ describe("nexus.session.client", async () => {
let sessionsModule: Module

beforeAll(async () => {
network = await toNetwork("BASE_SEPOLIA_FORKED")
network = await toNetwork("BESPOKE_ANVIL_NETWORK_FORKING_BASE_SEPOLIA")

chain = network.chain
bundlerUrl = network.bundlerUrl
Expand All @@ -59,7 +61,7 @@ describe("nexus.session.client", async () => {

testClient = toTestClient(chain, getTestAccount(5))

nexusClient = await createNexusClient({
nexusClient = await createSmartAccountClient({
signer: eoaAccount,
chain,
transport: http(),
Expand Down Expand Up @@ -181,7 +183,7 @@ describe("nexus.session.client", async () => {
functionName: "getNumber"
})

const smartSessionNexusClient = await createNexusSessionClient({
const smartSessionNexusClient = await createSmartAccountClient({
chain,
accountAddress: nexusClient.account.address,
signer: sessionKeyAccount,
Expand Down Expand Up @@ -238,7 +240,7 @@ describe("nexus.session.client", async () => {
moduleData: sessionData.moduleData
})

const smartSessionNexusClient = await createNexusSessionClient({
const smartSessionNexusClient = await createSmartAccountClient({
chain,
accountAddress: nexusClient.account.address,
signer: sessionKeyAccount,
Expand Down
7 changes: 0 additions & 7 deletions src/sdk/clients/createNexusSessionClient.ts

This file was deleted.

Loading

0 comments on commit e25d104

Please sign in to comment.