Skip to content

Commit

Permalink
chore: smart sessions update ++ (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
VGabriel45 authored Jan 15, 2025
1 parent 9714916 commit 24bded1
Show file tree
Hide file tree
Showing 24 changed files with 1,381 additions and 474 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.25

### Patch Changes

- Upgrade smart session and rhinestone sdk version

## 0.0.24

### Patch Changes
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
@@ -1,6 +1,6 @@
{
"name": "@biconomy/sdk",
"version": "0.0.24",
"version": "0.0.25",
"author": "Biconomy",
"repository": "github:bcnmy/sdk",
"main": "./dist/_cjs/index.js",
Expand Down Expand Up @@ -38,12 +38,12 @@
"viem": "2.21.6",
"vitest": "^1.3.1",
"yargs": "^17.7.2",
"@rhinestone/module-sdk": "0.1.28"
"@rhinestone/module-sdk": ">=0.1.0 <=0.2.3"
},
"peerDependencies": {
"typescript": "^5",
"viem": "^2.20.0",
"@rhinestone/module-sdk": "0.1.28"
"@rhinestone/module-sdk": ">=0.1.0 <=0.2.3"
},
"exports": {
".": {
Expand Down
4 changes: 1 addition & 3 deletions src/sdk/account/toNexusAccount.addresses.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ describe("nexus.account.addresses", async () => {
const counterfactualAddressFromHelper = await getCounterFactualAddress(
testClient as unknown as PublicClient,
eoaAccount.address,
true,
0n,
[RHINESTONE_ATTESTER_ADDRESS],
1,
Expand All @@ -96,7 +95,6 @@ describe("nexus.account.addresses", async () => {
const counterfactualAddressFromHelper = await getCounterFactualAddress(
testClient as unknown as PublicClient,
eoaAccount.address,
true,
0n,
[RHINESTONE_ATTESTER_ADDRESS],
1,
Expand Down Expand Up @@ -146,6 +144,6 @@ describe("nexus.account.addresses", async () => {
const testnetAddress = await testnetClient.account.getAddress()
const mainnetAddress = await mainnetClient.account.getAddress()

expect(testnetAddress).not.toBe(mainnetAddress)
expect(testnetAddress).toBe(mainnetAddress)
})
})
3 changes: 0 additions & 3 deletions src/sdk/account/toNexusAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ import {
ENTRY_POINT_ADDRESS,
MAINNET_ADDRESS_K1_VALIDATOR_ADDRESS,
MAINNET_ADDRESS_K1_VALIDATOR_FACTORY_ADDRESS,
MOCK_ATTESTER_ADDRESS,
RHINESTONE_ATTESTER_ADDRESS
} from "../constants"
// Constants
Expand Down Expand Up @@ -216,7 +215,6 @@ 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)"
Expand Down Expand Up @@ -255,7 +253,6 @@ export const toNexusAccount = async (
const addressFromFactory = await getCounterFactualAddress_(
publicClient,
signerAddress,
false,
index,
attesters_,
attesterThreshold,
Expand Down
6 changes: 0 additions & 6 deletions src/sdk/account/utils/getCounterFactualAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { Address } from "viem"
import type { PublicClient } from "viem"
import {
MAINNET_ADDRESS_K1_VALIDATOR_FACTORY_ADDRESS,
MOCK_ATTESTER_ADDRESS,
RHINESTONE_ATTESTER_ADDRESS
} from "../../constants"

Expand All @@ -26,16 +25,11 @@ import {
export const getCounterFactualAddress = async (
publicClient: PublicClient,
signerAddress: Address,
isTestnet = false,
index = 0n,
attesters = [RHINESTONE_ATTESTER_ADDRESS],
threshold = 1,
factoryAddress = MAINNET_ADDRESS_K1_VALIDATOR_FACTORY_ADDRESS
) => {
if (isTestnet) {
attesters.push(MOCK_ATTESTER_ADDRESS)
}

return await publicClient.readContract({
address: factoryAddress,
abi: [
Expand Down
3 changes: 3 additions & 0 deletions src/sdk/clients/createBicoPaymasterClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ describe("bico.paymaster", async () => {
bundlerTransport: http(bundlerUrl)
})

console.log(nexusClient.account.address, "nexusClient.account.address")

const initialBalance = await publicClient.getBalance({
address: nexusAccountAddress
})
Expand All @@ -160,6 +162,7 @@ describe("bico.paymaster", async () => {
feeTokenAddress: baseSepoliaUSDCAddress
})
const receipt = await nexusClient.waitForUserOperationReceipt({ hash })

expect(receipt.success).toBe("true")

// Get final balance
Expand Down
26 changes: 16 additions & 10 deletions src/sdk/clients/createNexusSessionClient.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { isSessionEnabled } from "@rhinestone/module-sdk"
import { http, type Address, type Chain, type Hex } from "viem"
import type { LocalAccount, PublicClient } from "viem"
import { encodeFunctionData } from "viem"
Expand All @@ -13,11 +14,7 @@ import {
} from "../../test/testUtils"
import type { MasterClient, NetworkConfig } from "../../test/testUtils"
import { SMART_SESSIONS_ADDRESS, SmartSessionMode } from "../constants"
import {
isPermissionEnabled,
parse,
stringify
} from "../modules/smartSessionsValidator/Helpers"
import { parse, stringify } from "../modules/smartSessionsValidator/Helpers"
import type {
CreateSessionDataParams,
SessionData
Expand Down Expand Up @@ -121,7 +118,8 @@ describe("nexus.session.client", async () => {
actionPoliciesInfo: [
{
contractAddress: testAddresses.Counter, // counter address
functionSelector: "0x273ea3e3" as Hex // function selector for increment count
functionSelector: "0x273ea3e3" as Hex, // function selector for increment count,
sudo: true
}
]
}
Expand Down Expand Up @@ -157,9 +155,13 @@ describe("nexus.session.client", async () => {

expect(receipt.success).toBe(true)

const isEnabled = await isPermissionEnabled({
const isEnabled = await isSessionEnabled({
client: nexusClient.account.client as PublicClient,
accountAddress: nexusClient.account.address,
account: {
type: "nexus",
address: nexusClient.account.address,
deployedOnChains: [chain.id]
},
permissionId: createSessionsResponse.permissionIds[0]
})
expect(isEnabled).toBe(true)
Expand Down Expand Up @@ -243,9 +245,13 @@ describe("nexus.session.client", async () => {
smartSessionUseActions(usePermissionsModule)
)

const isEnabled = await isPermissionEnabled({
const isEnabled = await isSessionEnabled({
client: testClient as unknown as PublicClient,
accountAddress: nexusClient.account.address,
account: {
type: "nexus",
address: nexusClient.account.address,
deployedOnChains: [chain.id]
},
permissionId: sessionData.moduleData.permissionIds[0]
})
expect(isEnabled).toBe(true)
Expand Down
Loading

0 comments on commit 24bded1

Please sign in to comment.