@@ -17,14 +17,13 @@ import { simulateTransaction } from "../../../transaction/actions/simulate.js";
17
17
import { addAdmin } from "./addAdmin.js" ;
18
18
import { getAllAdmins } from "../__generated__/IAccountPermissions/read/getAllAdmins.js" ;
19
19
import { removeAdmin } from "./removeAdmin.js" ;
20
- import { getAllSigners } from "../__generated__/IAccountPermissions/read/getAllSigners.js" ;
21
20
import { addSessionKey } from "./addSessionKey.js" ;
22
21
import { parseEventLogs } from "../../../event/actions/parse-logs.js" ;
23
22
import { adminUpdatedEvent } from "../__generated__/IAccountPermissions/events/AdminUpdated.js" ;
24
23
import { signerPermissionsUpdatedEvent } from "../__generated__/IAccountPermissions/events/SignerPermissionsUpdated.js" ;
25
24
import { ADDRESS_ZERO } from "../../../constants/addresses.js" ;
26
25
27
- describe . todo ( "Account Permissions" , ( ) => {
26
+ describe ( "Account Permissions" , ( ) => {
28
27
let accountFactoryContract : ThirdwebContract ;
29
28
let accountContract : ThirdwebContract ;
30
29
@@ -57,74 +56,55 @@ describe.todo("Account Permissions", () => {
57
56
} ) ;
58
57
} ) ;
59
58
60
- it ( "should fetch the correct inital state " , async ( ) => {
61
- const admins = await getAllAdmins ( {
59
+ it ( "should allow adding admins " , async ( ) => {
60
+ let admins = await getAllAdmins ( {
62
61
contract : accountContract ,
63
62
} ) ;
64
63
expect ( admins ) . toEqual ( [ TEST_ACCOUNT_A . address ] ) ;
65
- } ) ;
66
-
67
- it ( "should allow adding admins" , async ( ) => {
68
- const receipt = await sendAndConfirmTransaction ( {
64
+ let receipt = await sendAndConfirmTransaction ( {
69
65
transaction : addAdmin ( {
70
66
account : TEST_ACCOUNT_A ,
71
67
contract : accountContract ,
72
68
adminAddress : TEST_ACCOUNT_B . address ,
73
69
} ) ,
74
70
account : TEST_ACCOUNT_A ,
75
71
} ) ;
76
- const logs = parseEventLogs ( {
72
+ let logs = parseEventLogs ( {
77
73
events : [ adminUpdatedEvent ( ) ] ,
78
74
logs : receipt . logs ,
79
75
} ) ;
80
76
expect ( logs . length ) . toBe ( 1 ) ;
81
77
expect ( logs [ 0 ] ?. args . signer ) . toBe ( TEST_ACCOUNT_B . address ) ;
82
78
expect ( logs [ 0 ] ?. args . isAdmin ) . toBe ( true ) ;
83
- } ) ;
84
-
85
- it ( "should fetch the correct state after adding" , async ( ) => {
86
- const admins = await getAllAdmins ( {
79
+ admins = await getAllAdmins ( {
87
80
contract : accountContract ,
88
81
} ) ;
89
82
expect ( admins . length ) . toBe ( 2 ) ;
90
83
expect ( admins ) . toStrictEqual ( [
91
84
TEST_ACCOUNT_A . address ,
92
85
TEST_ACCOUNT_B . address ,
93
86
] ) ;
94
- } ) ;
95
-
96
- it ( "should allow removing admins" , async ( ) => {
97
- const receipt = await sendAndConfirmTransaction ( {
87
+ receipt = await sendAndConfirmTransaction ( {
98
88
transaction : removeAdmin ( {
99
89
account : TEST_ACCOUNT_B ,
100
90
contract : accountContract ,
101
91
adminAddress : TEST_ACCOUNT_A . address ,
102
92
} ) ,
103
93
account : TEST_ACCOUNT_B ,
104
94
} ) ;
105
- const logs = parseEventLogs ( {
95
+ logs = parseEventLogs ( {
106
96
events : [ adminUpdatedEvent ( ) ] ,
107
97
logs : receipt . logs ,
108
98
} ) ;
109
99
expect ( logs [ 0 ] ?. args . signer ) . toBe ( TEST_ACCOUNT_A . address ) ;
110
100
expect ( logs [ 0 ] ?. args . isAdmin ) . toBe ( false ) ;
111
- } ) ;
112
-
113
- it ( "should fetch the correct state after removing" , async ( ) => {
114
- const admins = await getAllAdmins ( {
101
+ admins = await getAllAdmins ( {
115
102
contract : accountContract ,
116
103
} ) ;
117
104
expect ( admins . length ) . toBe ( 1 ) ;
118
105
expect ( admins ) . toStrictEqual ( [ TEST_ACCOUNT_B . address ] ) ;
119
106
} ) ;
120
107
121
- it ( "should fetch the correct before adding a session key" , async ( ) => {
122
- const signers = await getAllSigners ( {
123
- contract : accountContract ,
124
- } ) ;
125
- expect ( signers ) . toEqual ( [ ] ) ;
126
- } ) ;
127
-
128
108
it ( "should allow adding session keys" , async ( ) => {
129
109
const receipt = await sendAndConfirmTransaction ( {
130
110
transaction : addSessionKey ( {
@@ -143,6 +123,8 @@ describe.todo("Account Permissions", () => {
143
123
} ) ;
144
124
expect ( logs [ 0 ] ?. args . authorizingSigner ) . toBe ( TEST_ACCOUNT_B . address ) ;
145
125
expect ( logs [ 0 ] ?. args . targetSigner ) . toBe ( TEST_ACCOUNT_A . address ) ;
146
- expect ( logs [ 0 ] ?. args . permissions . approvedTargets ) . toBe ( [ ADDRESS_ZERO ] ) ;
126
+ expect ( logs [ 0 ] ?. args . permissions . approvedTargets ) . toStrictEqual ( [
127
+ ADDRESS_ZERO ,
128
+ ] ) ;
147
129
} ) ;
148
130
} ) ;
0 commit comments