Skip to content

Commit

Permalink
chore: add timers
Browse files Browse the repository at this point in the history
  • Loading branch information
joepegler committed Sep 14, 2024
1 parent b4e78d6 commit 96a840b
Show file tree
Hide file tree
Showing 127 changed files with 2,104 additions and 4,912 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ Particle Auth Fix
- E2E tests for session validation modules ([4ad7ea7](https://github.com/bcnmy/biconomy-client-sdk/pull/401/commits/4ad7ea7f8eb6a28854dcce83834b2b7ff9ad3287))
- Added [TSDoc](https://bcnmy.github.io/biconomy-client-sdk) ([638dae](https://github.com/bcnmy/biconomy-client-sdk/pull/401/commits/638daee0ed6924f67c5151a2d0e5a02d32e4bf23))
- Make txs more typesafe and default with valueOrData ([b1e5b5e](https://github.com/bcnmy/biconomy-client-sdk/pull/401/commits/b1e5b5e02ab3a7fb99faa1d45b55e3cbe8d6bc93))
- Added createSmartAccountClient alias ([232472](https://github.com/bcnmy/biconomy-client-sdk/pull/401/commits/232472c788bed0619cf6295ade076b6ec3a9e0f8))
- Added toNexusClient alias ([232472](https://github.com/bcnmy/biconomy-client-sdk/pull/401/commits/232472c788bed0619cf6295ade076b6ec3a9e0f8))
- Improve dx of using paymster to build userOps ([bb54888](https://github.com/bcnmy/biconomy-client-sdk/pull/401/commits/bb548884e76a94a20329e49b18994503de9e3888))
- Add ethers v6 signer support ([9727fd](https://github.com/bcnmy/biconomy-client-sdk/pull/401/commits/9727fd51e47d62904399d17d48f5c9d6b9e591e5))
- Improved dx of using gas payments with erc20 ([741806](https://github.com/bcnmy/biconomy-client-sdk/pull/401/commits/741806da68457eba262e1a49be77fcc24360ba36))
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ bun i
```

```typescript
import { createSmartAccountClient } from "@biconomy/account";
import { toNexusClient } from "@biconomy/account";

const smartAccount = await createSmartAccountClient({
const smartAccount = await toNexusClient({
signer: viemWalletOrEthersSigner,
bundlerUrl: "", // From dashboard.biconomy.io
paymasterUrl: "", // From dashboard.biconomy.io
Expand Down
Binary file modified bun.lockb
Binary file not shown.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@
"dev": "bun link && concurrently \"bun run esm:watch\" \"bun run cjs:watch\" \"bun run esm:watch:aliases\" \"bun run cjs:watch:aliases\"",
"build": "bun run clean && bun run build:cjs && bun run build:esm && bun run build:types",
"clean": "rimraf ./dist/_esm ./dist/_cjs ./dist/_types ./dist/tsconfig",
"test": "vitest -c ./tests/vitest.config.ts",
"test": "vitest -c ./packages/tests/vitest.config.ts",
"test:watch": "bun run test dev",
"playground": "RUN_PLAYGROUND=true vitest -c ./tests/vitest.config.ts -t=playground",
"playground": "RUN_PLAYGROUND=true vitest -c ./packages/tests/vitest.config.ts -t=playground",
"playground:watch": "RUN_PLAYGROUND=true bun run test -t=playground --watch",
"size": "size-limit",
"docs": "typedoc --tsconfig ./tsconfig/tsconfig.esm.json",
Expand Down Expand Up @@ -109,7 +109,7 @@
"typedoc": "^0.25.9",
"vitest": "^1.3.1",
"yargs": "^17.7.2",
"viem": "^2.21.2"
"viem": "2.21.6"
},
"peerDependencies": {
"typescript": "^5"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import type { Hex } from "viem"
import { entryPoint07Address } from "viem/account-abstraction"
import { EntrypointAbi, K1ValidatorAbi, K1ValidatorFactoryAbi } from "./abi"
import addresses from "./addresses"

export const ENTRYPOINT_SIMULATIONS: Hex =
"0x74Cb5e4eE81b86e70f9045036a1C5477de69eE87"
export const ENTRYPOINT_ADDRESS: Hex =
"0x0000000071727De22E5E9d8BAf0edAc6f37da032"

const entryPoint = {
address: ENTRYPOINT_ADDRESS,
address: entryPoint07Address,
abi: EntrypointAbi
} as const

Expand Down
4 changes: 4 additions & 0 deletions packages/sdk/account/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from "./utils/index.js"
export * from "./signers/local-account.js"
export * from "./signers/wallet-client.js"
export * from "./toNexusAccount.js"
File renamed without changes.
File renamed without changes.
115 changes: 115 additions & 0 deletions packages/sdk/account/toNexusAccount.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import { http, type Account, type Address, type Chain, isHex } from "viem"
import { afterAll, beforeAll, describe, expect, test } from "vitest"
import { toNetwork } from "../../tests/testSetup"
import {
getBalance,
getTestAccount,
killNetwork,
toTestClient,
topUp
} from "../../tests/testUtils"
import type { MasterClient, NetworkConfig } from "../../tests/testUtils"
import { type NexusAccount, toNexusAccount } from "./toNexusAccount"
import type { UserOperationStruct } from "./utils/Types"

describe("nexus.account", () => {
let network: NetworkConfig
let chain: Chain
let bundlerUrl: string

// Test utils
let testClient: MasterClient
let account: Account
let nexusAccountAddress: Address
let nexusAccount: NexusAccount

beforeAll(async () => {
network = await toNetwork()

chain = network.chain
bundlerUrl = network.bundlerUrl
account = getTestAccount(0)
testClient = toTestClient(chain, getTestAccount(0))

nexusAccount = await toNexusAccount({
owner: account,
chain,
transport: http()
})

nexusAccountAddress = await nexusAccount.getCounterFactualAddress()
})
afterAll(async () => {
await killNetwork([network?.rpcPort, network?.bundlerPort])
})

test.concurrent("should have 4337 account actions", async () => {
const [
counterfactualAddress,
userOpHash,
address,
factoryArgs,
stubSignature,
signedMessage,
nonce,
initCode,
isDeployed,
encodedExecute,
encodedExecuteBatch
] = await Promise.all([
nexusAccount.getCounterFactualAddress(),
nexusAccount.getUserOpHash({
sender: account.address,
nonce: 0n,
data: "0x",
signature: "0x",
verificationGasLimit: 1n,
preVerificationGas: 1n,
callData: "0x",
callGasLimit: 1n,
maxFeePerGas: 1n,
maxPriorityFeePerGas: 1n
} as UserOperationStruct),
nexusAccount.getAddress(),
nexusAccount.getFactoryArgs(),
nexusAccount.getStubSignature(),
nexusAccount.signMessage({ message: "hello" }),
nexusAccount.getNonce(),
nexusAccount.getInitCode(),
nexusAccount.isDeployed(),
nexusAccount.encodeExecute({ to: account.address, value: 100n }),
nexusAccount.encodeExecuteBatch([{ to: account.address, value: 100n }])
])

expect(counterfactualAddress).toBe(
"0xa3962DB24D3cAb711e18d5A508591C6dB82a0f54"
)
expect(isHex(userOpHash)).toBe(true)
expect(address).toBe("0xa3962DB24D3cAb711e18d5A508591C6dB82a0f54")
expect(factoryArgs.factory).toBe(
"0x8025afaD10209b8bEF3A3C94684AaE4D309c9996"
)
expect(factoryArgs.factoryData).toBe(
"0x0d51f0b7000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
)
expect(stubSignature).toBe(
"0x0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000d98238BBAeA4f91683d250003799EAd31d7F5c55000000000000000000000000000000000000000000000000000000000000004181d4b4981670cb18f99f0b4a66446df1bf5b204d24cfcb659bf38ba27a4359b5711649ec2423c5e1247245eba2964679b6a1dbb85c992ae40b9b00c6935b02ff1b00000000000000000000000000000000000000000000000000000000000000"
)
expect(signedMessage).toBe(
"0x0000000000000000000000008025afad10209b8bef3a3c94684aae4d309c99960000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000a40d51f0b7000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb9226600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000008025afad10209b8bef3a3c94684aae4d309c99960000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000a40d51f0b7000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000055d98238bbaea4f91683d250003799ead31d7f5c55f16ea9a3478698f695fd1401bfe27e9e4a7e8e3da94aa72b021125e31fa899cc573c48ea3fe1d4ab61a9db10c19032026e3ed2dbccba5a178235ac27f94504311c000000000000000000000064926492649264926492649264926492649264926492649264926492649264926492649264926492649264926492649264926492649264926492649264926492"
)
expect(nonce).toBe(
22906337356820620590513465594309079979684970955157942146586636189696n
)
expect(initCode).toBe(
"0x8025afaD10209b8bEF3A3C94684AaE4D309c99960d51f0b7000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
)
expect(isDeployed).toBe(false)
expect(encodedExecute).toBe(
"0xe9ae5c53000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000034f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000000000000000064000000000000000000000000"
)
expect(encodedExecuteBatch).toBe(
"0xe9ae5c530100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266000000000000000000000000000000000000000000000000000000000000006400000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000"
)
})
})
Loading

0 comments on commit 96a840b

Please sign in to comment.