Skip to content

Commit

Permalink
chore: rename
Browse files Browse the repository at this point in the history
  • Loading branch information
joepegler committed Jul 9, 2024
1 parent 1e6f4ed commit 29d3f55
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 26 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Minor Changes

- Distributed Sessions
- Delegated Sessions

## 4.5.2

Expand Down
2 changes: 1 addition & 1 deletion src/account/BiconomySmartAccountV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1605,7 +1605,7 @@ export class BiconomySmartAccountV2 extends BaseSmartContractAccount {

if (!defaultedChain) throw new Error("Chain is not provided")

if (this.sessionType === "DAN") {
if (this.sessionType === "DELEGATED") {
return getDanSessionTxParams(
defaultedConditionalSession,
defaultedChain,
Expand Down
22 changes: 11 additions & 11 deletions src/modules/sessions/dan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ import {
createABISessionDatum
} from "./abi"

export type PolicyWithoutSessionKey = Omit<Policy, "sessionKeyAddress">
export type PolicyLeaf = Omit<Policy, "sessionKeyAddress">
export const DEFAULT_SESSION_DURATION = 60 * 60

export type CreateDistributedParams = {
export type CreateDelegatedParams = {
/** The user's smart account instance */
smartAccountClient: BiconomySmartAccountV2,
/** An array of session configurations */
policy: PolicyWithoutSessionKey[],
policy: PolicyLeaf[],
/** The storage client to store the session keys */
sessionStorageClient?: ISessionStorage,
/** The build userop dto */
Expand All @@ -54,7 +54,7 @@ export type CreateDistributedParams = {

/**
*
* createDistributedSession
* createDelegatedSession
*
* Creates a session for a user's smart account.
* This grants a dapp permission to execute a specific function on a specific contract on behalf of a user.
Expand All @@ -71,9 +71,9 @@ export type CreateDistributedParams = {
*
* @example
*
* import { type PolicyWithoutSessionKey, type Session, createDistributedSession } from "@biconomy/account"
* import { type PolicyLeaf, type Session, createDelegatedSession } from "@biconomy/account"
*
* const policy: PolicyWithoutSessionKey[] = [{
* const policy: PolicyLeaf[] = [{
* contractAddress: nftAddress,
* functionSelector: "safeMint(address)",
* rules: [
Expand All @@ -90,21 +90,21 @@ export type CreateDistributedParams = {
* valueLimit: 0n
* }]
*
* const { wait, session } = await createDistributedSession({
* const { wait, session } = await createDelegatedSession({
* smartAccountClient,
* policy
* })
*
* const { success } = await wait()
*/
export const createDistributedSession = async ({
export const createDelegatedSession = async ({
smartAccountClient,
policy,
sessionStorageClient,
buildUseropDto,
chainId,
browserWallet
}: CreateDistributedParams): Promise<SessionGrantedPayload> => {
}: CreateDelegatedParams): Promise<SessionGrantedPayload> => {
const defaultedChainId =
chainId ??
extractChainIdFromBundlerUrl(smartAccountClient?.bundler?.getBundlerUrl() ?? "");
Expand Down Expand Up @@ -219,9 +219,9 @@ export type DanSessionKeyRequestParams = {
*
* getDANSessionKey
*
* @description This function is used to generate a new session key for a Distributed Account Network (DAN) session. This information is kept in the session storage and can be used to validate userops without the user's direct involvement.
* @description This function is used to generate a new session key for a Delegated Account Network (DAN) session. This information is kept in the session storage and can be used to validate userops without the user's direct involvement.
*
* Generates a new session key for a Distributed Account Network (DAN) session.
* Generates a new session key for a Delegated Account Network (DAN) session.
* @param smartAccount - The user's {@link BiconomySmartAccountV2} smartAccount instance.
* @param browserWallet - Optional. The user's {@link IBrowserWallet} instance.
* @param hardcodedValues - Optional. {@link DanModuleInfo} - Additional information for the DAN module configuration to override the default values.
Expand Down
6 changes: 3 additions & 3 deletions src/modules/sessions/sessionSmartAccountClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
import type { ISessionStorage } from "../interfaces/ISessionStorage";
import type { ModuleInfo, StrictSessionParams } from "../utils/Types";

export type SessionType = "SINGLE" | "BATCHED" | "DAN";
export type SessionType = "SINGLE" | "BATCHED" | "DELEGATED";
export type ImpersonatedSmartAccountConfig = Omit<
BiconomySmartAccountV2Config,
"signer"
Expand Down Expand Up @@ -50,7 +50,7 @@ export type SendSessionTransactionFunction = (
*
* @param biconomySmartAccountConfig - Configuration for initializing the BiconomySmartAccountV2 instance {@link ImpersonatedSmartAccountConfig}.
* @param conditionalSession - {@link SessionSearchParam} The session data that contains the sessionID and sessionSigner. If not provided, The default session storage (localStorage in browser, fileStorage in node backend) is used to fetch the sessionIDInfo
* @param sessionType - {@link SessionType}: One of "SINGLE", "BATCHED" or "DAN". Default is "SINGLE".
* @param sessionType - {@link SessionType}: One of "SINGLE", "BATCHED" or "DELEGATED". Default is "SINGLE".
* @returns A promise that resolves to a new instance of {@link BiconomySmartAccountV2}.
* @throws An error if something is wrong with the smart account instance creation.
*
Expand Down Expand Up @@ -97,7 +97,7 @@ export const createSessionSmartAccountClient = async (
let defaultedSessionType: SessionType = "SINGLE";
if (sessionType === true || sessionType === "BATCHED")
defaultedSessionType = "BATCHED";
if (sessionType === "DAN") defaultedSessionType = "DAN";
if (sessionType === "DELEGATED") defaultedSessionType = "DELEGATED";

const { sessionStorageClient, sessionIDInfo } = await resumeSession(
conditionalSession ?? biconomySmartAccountConfig.accountAddress,
Expand Down
2 changes: 1 addition & 1 deletion src/modules/walletprovider-sdk/networkSigner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export declare class NetworkSigner {
* @param authModule - Authentication module, used to get confirmation from the User before request execution
*/
constructor(wpClient: IWalletProviderServiceClient, threshold: number, totalNodes: number, authModule: AuthModule);
/** API to generate a distributed key that's generated by Silent Network.
/** API to generate a delegated key that's generated by Silent Network.
* Uses `authModule` to get authentication of the request from the User
* @param ephKey - ephemeral key used to authenticate the user during the session.
* @param permissions - optional permissions that will be stored in the key metadata.
Expand Down
15 changes: 6 additions & 9 deletions tests/modules/write.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ import {
DanModuleInfo,
ECDSA_OWNERSHIP_MODULE_ADDRESSES_BY_VERSION,
NodeWallet,
type PolicyWithoutSessionKey,
createDistributedSession,
type PolicyLeaf,
createDelegatedSession,
createECDSAOwnershipValidationModule,
createMultiChainValidationModule,
createSessionKeyManagerModule,
Expand Down Expand Up @@ -176,14 +176,11 @@ describe("Modules:Write", () => {

// User must be connected with a wallet to grant permissions
test("should create a single session on behalf of a user", async () => {
const { sessionKeyAddress, sessionStorageClient } =
await createSessionKeyEOA(smartAccountThree, chain)

const { wait, session } = await createSession(
smartAccountThree,
[
{
sessionKeyAddress,
contractAddress: nftAddress,
functionSelector: "safeMint(address)",
rules: [
Expand All @@ -200,7 +197,7 @@ describe("Modules:Write", () => {
valueLimit: 0n
}
],
sessionStorageClient,
undefined,
withSponsorship
)

Expand Down Expand Up @@ -1463,7 +1460,7 @@ describe("Modules:Write", () => {

test("should create and use an DAN session on behalf of a user (abstracted)", async () => {

const policy: PolicyWithoutSessionKey[] = [
const policy: PolicyLeaf[] = [
{
contractAddress: nftAddress,
functionSelector: "safeMint(address)",
Expand All @@ -1479,7 +1476,7 @@ describe("Modules:Write", () => {
}
]

const { wait } = await createDistributedSession({ smartAccountClient: smartAccount, policy })
const { wait } = await createDelegatedSession({ smartAccountClient: smartAccount, policy })

const { success } = await wait()
expect(success).toBe("true")
Expand All @@ -1503,7 +1500,7 @@ describe("Modules:Write", () => {
chainId
},
smartAccountAddress,
"DAN"
"DELEGATED"
)

const { wait: waitForMint } = await smartAccountWithSession.sendTransaction(
Expand Down

0 comments on commit 29d3f55

Please sign in to comment.