Skip to content

Commit e392604

Browse files
committed
wts crlf
1 parent 79835e0 commit e392604

File tree

4 files changed

+138
-138
lines changed

4 files changed

+138
-138
lines changed

packages/thirdweb/src/exports/wallets/in-app.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
// --- KEEEP IN SYNC with exports/wallets/in-app.native.ts ---
22

3+
//ACCOUNT
4+
export {
5+
type CreateSessionKeyOptions,
6+
createSessionKey,
7+
isCreateSessionKeySupported,
8+
} from "../../extensions/erc7702/account/createSessionKey.js";
9+
export type {
10+
Condition,
11+
LimitType,
12+
} from "../../extensions/erc7702/account/types.js";
313
export {
414
getSocialIcon,
515
socialIcons,
@@ -27,14 +37,3 @@ export {
2737
unlinkProfile,
2838
} from "../../wallets/in-app/web/lib/auth/index.js";
2939
export { hasStoredPasskey } from "../../wallets/in-app/web/lib/auth/passkeys.js";
30-
31-
//ACCOUNT
32-
export {
33-
type CreateSessionKeyOptions,
34-
createSessionKey,
35-
isCreateSessionKeySupported,
36-
} from "../../extensions/erc7702/account/createSessionKey.js";
37-
export type {
38-
LimitType,
39-
Condition,
40-
} from "../../extensions/erc7702/account/types.js";

packages/thirdweb/src/extensions/erc7702/account/createSessionKey.ts

Lines changed: 123 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,47 @@ import type { BaseTransactionOptions } from "../../../transaction/types.js";
22
import { randomBytesHex } from "../../../utils/random.js";
33
import type { Account } from "../../../wallets/interfaces/wallet.js";
44
import {
5-
createSessionWithSig,
6-
isCreateSessionWithSigSupported,
5+
createSessionWithSig,
6+
isCreateSessionWithSigSupported,
77
} from "../__generated__/MinimalAccount/write/createSessionWithSig.js";
88
import {
9-
type CallSpecInput,
10-
CallSpecRequest,
11-
ConstraintRequest,
12-
SessionSpecRequest,
13-
type TransferSpecInput,
14-
TransferSpecRequest,
15-
UsageLimitRequest,
9+
type CallSpecInput,
10+
CallSpecRequest,
11+
ConstraintRequest,
12+
SessionSpecRequest,
13+
type TransferSpecInput,
14+
TransferSpecRequest,
15+
UsageLimitRequest,
1616
} from "./types.js";
1717

1818
/**
1919
* @extension ERC7702
2020
*/
2121
export type CreateSessionKeyOptions = {
22-
/**
23-
* The admin account that will perform the operation.
24-
*/
25-
account: Account;
26-
/**
27-
* The address to add as a session key.
28-
*/
29-
sessionKeyAddress: string;
30-
/**
31-
* How long the session key should be valid for, in seconds.
32-
*/
33-
durationInSeconds: number;
34-
/**
35-
* Whether to grant full execution permissions to the session key.
36-
*/
37-
grantFullPermissions?: boolean;
38-
/**
39-
* Smart contract interaction policies to apply to the session key, ignored if grantFullPermissions is true.
40-
*/
41-
callPolicies?: CallSpecInput[];
42-
/**
43-
* Value transfer policies to apply to the session key, ignored if grantFullPermissions is true.
44-
*/
45-
transferPolicies?: TransferSpecInput[];
22+
/**
23+
* The admin account that will perform the operation.
24+
*/
25+
account: Account;
26+
/**
27+
* The address to add as a session key.
28+
*/
29+
sessionKeyAddress: string;
30+
/**
31+
* How long the session key should be valid for, in seconds.
32+
*/
33+
durationInSeconds: number;
34+
/**
35+
* Whether to grant full execution permissions to the session key.
36+
*/
37+
grantFullPermissions?: boolean;
38+
/**
39+
* Smart contract interaction policies to apply to the session key, ignored if grantFullPermissions is true.
40+
*/
41+
callPolicies?: CallSpecInput[];
42+
/**
43+
* Value transfer policies to apply to the session key, ignored if grantFullPermissions is true.
44+
*/
45+
transferPolicies?: TransferSpecInput[];
4646
};
4747

4848
/**
@@ -68,100 +68,100 @@ export type CreateSessionKeyOptions = {
6868
* @extension ERC7702
6969
*/
7070
export function createSessionKey(
71-
options: BaseTransactionOptions<CreateSessionKeyOptions>,
71+
options: BaseTransactionOptions<CreateSessionKeyOptions>,
7272
) {
73-
const {
74-
contract,
75-
account,
76-
sessionKeyAddress,
77-
durationInSeconds,
78-
grantFullPermissions,
79-
callPolicies,
80-
transferPolicies,
81-
} = options;
73+
const {
74+
contract,
75+
account,
76+
sessionKeyAddress,
77+
durationInSeconds,
78+
grantFullPermissions,
79+
callPolicies,
80+
transferPolicies,
81+
} = options;
8282

83-
if (durationInSeconds <= 0) {
84-
throw new Error("durationInSeconds must be positive");
85-
}
83+
if (durationInSeconds <= 0) {
84+
throw new Error("durationInSeconds must be positive");
85+
}
8686

87-
return createSessionWithSig({
88-
async asyncParams() {
89-
const req = {
90-
callPolicies: (callPolicies || []).map((policy) => ({
91-
constraints: (policy.constraints || []).map((constraint) => ({
92-
condition: Number(constraint.condition),
93-
index: constraint.index || BigInt(0),
94-
limit: constraint.limit
95-
? {
96-
limit: constraint.limit.limit,
97-
limitType: Number(constraint.limit.limitType),
98-
period: constraint.limit.period,
99-
}
100-
: {
101-
limit: BigInt(0),
102-
limitType: 0,
103-
period: BigInt(0),
104-
},
105-
refValue: constraint.refValue || "0x",
106-
})),
107-
maxValuePerUse: policy.maxValuePerUse || BigInt(0),
108-
selector: policy.selector,
109-
target: policy.target,
110-
valueLimit: policy.valueLimit
111-
? {
112-
limit: policy.valueLimit.limit,
113-
limitType: Number(policy.valueLimit.limitType),
114-
period: policy.valueLimit.period,
115-
}
116-
: {
117-
limit: BigInt(0),
118-
limitType: 0,
119-
period: BigInt(0),
120-
},
121-
})),
122-
expiresAt: BigInt(Math.floor(Date.now() / 1000) + durationInSeconds),
123-
isWildcard: grantFullPermissions ?? true,
124-
signer: sessionKeyAddress,
125-
transferPolicies: (transferPolicies || []).map((policy) => ({
126-
maxValuePerUse: policy.maxValuePerUse || BigInt(0),
127-
target: policy.target,
128-
valueLimit: policy.valueLimit
129-
? {
130-
limit: policy.valueLimit.limit,
131-
limitType: Number(policy.valueLimit.limitType),
132-
period: policy.valueLimit.period,
133-
}
134-
: {
135-
limit: BigInt(0),
136-
limitType: 0,
137-
period: BigInt(0),
138-
},
139-
})),
140-
uid: await randomBytesHex(),
141-
};
87+
return createSessionWithSig({
88+
async asyncParams() {
89+
const req = {
90+
callPolicies: (callPolicies || []).map((policy) => ({
91+
constraints: (policy.constraints || []).map((constraint) => ({
92+
condition: Number(constraint.condition),
93+
index: constraint.index || BigInt(0),
94+
limit: constraint.limit
95+
? {
96+
limit: constraint.limit.limit,
97+
limitType: Number(constraint.limit.limitType),
98+
period: constraint.limit.period,
99+
}
100+
: {
101+
limit: BigInt(0),
102+
limitType: 0,
103+
period: BigInt(0),
104+
},
105+
refValue: constraint.refValue || "0x",
106+
})),
107+
maxValuePerUse: policy.maxValuePerUse || BigInt(0),
108+
selector: policy.selector,
109+
target: policy.target,
110+
valueLimit: policy.valueLimit
111+
? {
112+
limit: policy.valueLimit.limit,
113+
limitType: Number(policy.valueLimit.limitType),
114+
period: policy.valueLimit.period,
115+
}
116+
: {
117+
limit: BigInt(0),
118+
limitType: 0,
119+
period: BigInt(0),
120+
},
121+
})),
122+
expiresAt: BigInt(Math.floor(Date.now() / 1000) + durationInSeconds),
123+
isWildcard: grantFullPermissions ?? true,
124+
signer: sessionKeyAddress,
125+
transferPolicies: (transferPolicies || []).map((policy) => ({
126+
maxValuePerUse: policy.maxValuePerUse || BigInt(0),
127+
target: policy.target,
128+
valueLimit: policy.valueLimit
129+
? {
130+
limit: policy.valueLimit.limit,
131+
limitType: Number(policy.valueLimit.limitType),
132+
period: policy.valueLimit.period,
133+
}
134+
: {
135+
limit: BigInt(0),
136+
limitType: 0,
137+
period: BigInt(0),
138+
},
139+
})),
140+
uid: await randomBytesHex(),
141+
};
142142

143-
const signature = await account.signTypedData({
144-
domain: {
145-
chainId: contract.chain.id,
146-
name: "MinimalAccount",
147-
verifyingContract: contract.address,
148-
version: "1",
149-
},
150-
message: req,
151-
primaryType: "SessionSpec",
152-
types: {
153-
CallSpec: CallSpecRequest,
154-
Constraint: ConstraintRequest,
155-
SessionSpec: SessionSpecRequest,
156-
TransferSpec: TransferSpecRequest,
157-
UsageLimit: UsageLimitRequest,
158-
},
159-
});
143+
const signature = await account.signTypedData({
144+
domain: {
145+
chainId: contract.chain.id,
146+
name: "MinimalAccount",
147+
verifyingContract: contract.address,
148+
version: "1",
149+
},
150+
message: req,
151+
primaryType: "SessionSpec",
152+
types: {
153+
CallSpec: CallSpecRequest,
154+
Constraint: ConstraintRequest,
155+
SessionSpec: SessionSpecRequest,
156+
TransferSpec: TransferSpecRequest,
157+
UsageLimit: UsageLimitRequest,
158+
},
159+
});
160160

161-
return { sessionSpec: req, signature };
162-
},
163-
contract,
164-
});
161+
return { sessionSpec: req, signature };
162+
},
163+
contract,
164+
});
165165
}
166166

167167
/**
@@ -177,5 +177,5 @@ export function createSessionKey(
177177
* ```
178178
*/
179179
export function isCreateSessionKeySupported(availableSelectors: string[]) {
180-
return isCreateSessionWithSigSupported(availableSelectors);
180+
return isCreateSessionWithSigSupported(availableSelectors);
181181
}

packages/thirdweb/src/extensions/erc7702/account/sessionkey.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,9 @@ describe.runIf(process.env.TW_SECRET_KEY)(
8989
{
9090
condition: Condition.Unconstrained,
9191
index: 0n,
92-
refValue: "0x0000000000000000000000000000000000000000000000000000000000000000"
93-
}
92+
refValue:
93+
"0x0000000000000000000000000000000000000000000000000000000000000000",
94+
},
9495
],
9596
maxValuePerUse: 0n,
9697
selector: "0x00000000",

packages/thirdweb/src/extensions/erc7702/account/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
export enum LimitType {
66
Unlimited = 0,
77
Lifetime = 1,
8-
Allowance = 2
8+
Allowance = 2,
99
}
1010

1111
export enum Condition {
@@ -15,7 +15,7 @@ export enum Condition {
1515
Less = 3,
1616
GreaterOrEqual = 4,
1717
LessOrEqual = 5,
18-
NotEqual = 6
18+
NotEqual = 6,
1919
}
2020

2121
/* ────────────────────────────────

0 commit comments

Comments
 (0)