Skip to content

Commit e31ed6b

Browse files
committed
address review
1 parent 2ba6041 commit e31ed6b

File tree

5 files changed

+53
-13
lines changed

5 files changed

+53
-13
lines changed

packages/thirdweb/src/exports/extensions/erc7702.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,10 @@ export {
2323
} from "../../wallets/in-app/native/auth/index.js";
2424
export { hasStoredPasskey } from "../../wallets/in-app/native/auth/passkeys.js";
2525
export { inAppWallet } from "../../wallets/in-app/native/in-app.js";
26+
27+
//ACCOUNT
28+
export {
29+
type CreateSessionKeyOptions,
30+
createSessionKey,
31+
isCreateSessionKeySupported,
32+
} from "../../extensions/erc7702/account/createSessionKey.js";

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,10 @@ export {
2727
unlinkProfile,
2828
} from "../../wallets/in-app/web/lib/auth/index.js";
2929
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";

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

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export type CreateSessionKeyOptions = {
2626
/**
2727
* The address to add as a session key.
2828
*/
29-
sessionKeyAddress: `0x${string}`;
29+
sessionKeyAddress: string;
3030
/**
3131
* How long the session key should be valid for, in seconds.
3232
*/
@@ -89,9 +89,13 @@ export function createSessionKey(
8989
const req = {
9090
callPolicies: (callPolicies || []).map((policy) => ({
9191
constraints: (policy.constraints || []).map((constraint) => ({
92-
condition: constraint.condition,
92+
condition: Number(constraint.condition),
9393
index: constraint.index || BigInt(0),
94-
limit: constraint.limit || {
94+
limit: constraint.limit ? {
95+
limit: constraint.limit.limit,
96+
limitType: Number(constraint.limit.limitType),
97+
period: constraint.limit.period,
98+
} : {
9599
limit: BigInt(0),
96100
limitType: 0,
97101
period: BigInt(0),
@@ -101,7 +105,11 @@ export function createSessionKey(
101105
maxValuePerUse: policy.maxValuePerUse || BigInt(0),
102106
selector: policy.selector,
103107
target: policy.target,
104-
valueLimit: policy.valueLimit || {
108+
valueLimit: policy.valueLimit ? {
109+
limit: policy.valueLimit.limit,
110+
limitType: Number(policy.valueLimit.limitType),
111+
period: policy.valueLimit.period,
112+
} : {
105113
limit: BigInt(0),
106114
limitType: 0,
107115
period: BigInt(0),
@@ -113,7 +121,11 @@ export function createSessionKey(
113121
transferPolicies: (transferPolicies || []).map((policy) => ({
114122
maxValuePerUse: policy.maxValuePerUse || BigInt(0),
115123
target: policy.target,
116-
valueLimit: policy.valueLimit || {
124+
valueLimit: policy.valueLimit ? {
125+
limit: policy.valueLimit.limit,
126+
limitType: Number(policy.valueLimit.limitType),
127+
period: policy.valueLimit.period,
128+
} : {
117129
limit: BigInt(0),
118130
limitType: 0,
119131
period: BigInt(0),

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

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,37 @@
1+
/* ────────────────────────────────
2+
Enums
3+
──────────────────────────────── */
4+
5+
export enum LimitType {
6+
Unlimited = 0,
7+
Lifetime = 1,
8+
Allowance = 2
9+
}
10+
11+
export enum Condition {
12+
Unconstrained = 0,
13+
Equal = 1,
14+
Greater = 2,
15+
Less = 3,
16+
GreaterOrEqual = 4,
17+
LessOrEqual = 5,
18+
NotEqual = 6
19+
}
20+
121
/* ────────────────────────────────
222
Input types
323
──────────────────────────────── */
424

525
/* ---------- UsageLimit ---------- */
626
interface UsageLimitInput {
7-
limitType: number;
27+
limitType: LimitType;
828
limit: bigint;
929
period: bigint;
1030
}
1131

1232
/* ---------- Constraint ---------- */
1333
interface ConstraintInput {
14-
condition: number;
34+
condition: Condition;
1535
index: bigint;
1636
refValue: `0x${string}`;
1737
limit?: UsageLimitInput;

0 commit comments

Comments
 (0)