@reflectmoney/stable.ts 2.5.1 → 2.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,7 +24,7 @@ export declare class ReflectKeeper {
24
24
  * @param admin - Public key of the admin user
25
25
  * @param connection - Solana connection instance
26
26
  */
27
- constructor({ admin, connection }: {
27
+ constructor({ admin, connection, }: {
28
28
  admin: PublicKey;
29
29
  connection: Connection;
30
30
  });
@@ -102,8 +102,16 @@ export declare class ReflectKeeper {
102
102
  * @returns TransactionInstruction
103
103
  */
104
104
  updateActionRoleProtocol(signer: PublicKey, action: Action, affectedRole: Role, update: Update): import("@solana/web3.js").TransactionInstruction;
105
+ fetchAllAdminAccounts(): Promise<{
106
+ pubkey: PublicKey;
107
+ account: UserPermissions;
108
+ }[]>;
105
109
  fetchAdminByRole(role: Role): Promise<{
106
110
  pubkey: PublicKey;
107
111
  account: UserPermissions;
108
112
  }[]>;
113
+ fetchAdminByStrategyRole(strategy: number, role: Role): Promise<{
114
+ pubkey: PublicKey;
115
+ account: UserPermissions;
116
+ }[]>;
109
117
  }
@@ -31,7 +31,7 @@ class ReflectKeeper {
31
31
  * @param admin - Public key of the admin user
32
32
  * @param connection - Solana connection instance
33
33
  */
34
- constructor({ admin, connection }) {
34
+ constructor({ admin, connection, }) {
35
35
  this.admin = admin;
36
36
  this.connection = connection;
37
37
  this.main = PdaClient_1.PdaClient.deriveMain();
@@ -48,7 +48,7 @@ class ReflectKeeper {
48
48
  main,
49
49
  admin,
50
50
  systemProgram: web3_js_1.SystemProgram.programId,
51
- creds: PdaClient_1.PdaClient.derivePermissions(admin)
51
+ creds: PdaClient_1.PdaClient.derivePermissions(admin),
52
52
  }, reflect_main_1.PROGRAM_ID);
53
53
  return ix;
54
54
  }
@@ -74,7 +74,7 @@ class ReflectKeeper {
74
74
  adminPermissions: PdaClient_1.PdaClient.derivePermissions(this.admin),
75
75
  }, {
76
76
  freeze,
77
- action
77
+ action,
78
78
  });
79
79
  return ix;
80
80
  }
@@ -93,7 +93,7 @@ class ReflectKeeper {
93
93
  adminPermissions: PdaClient_1.PdaClient.derivePermissions(this.admin),
94
94
  }, {
95
95
  freeze,
96
- programIndex
96
+ programIndex,
97
97
  });
98
98
  return ix;
99
99
  }
@@ -111,7 +111,7 @@ class ReflectKeeper {
111
111
  systemProgram: web3_js_1.SystemProgram.programId,
112
112
  }, {
113
113
  newAdmin,
114
- roles
114
+ roles,
115
115
  }, reflect_main_1.PROGRAM_ID);
116
116
  return ix;
117
117
  }
@@ -132,7 +132,7 @@ class ReflectKeeper {
132
132
  systemProgram: web3_js_1.SystemProgram.programId,
133
133
  updateAdminPermissions: PdaClient_1.PdaClient.derivePermissions(adminToUpdate),
134
134
  // Dummy strategy account.
135
- strategy: PdaClient_1.PdaClient.deriveController(0)
135
+ strategy: PdaClient_1.PdaClient.deriveController(0),
136
136
  }, {
137
137
  update,
138
138
  accessLevel: affectedRole,
@@ -156,7 +156,7 @@ class ReflectKeeper {
156
156
  main: PdaClient_1.PdaClient.deriveMain(),
157
157
  systemProgram: web3_js_1.SystemProgram.programId,
158
158
  updateAdminPermissions: PdaClient_1.PdaClient.derivePermissions(adminToUpdate),
159
- strategy: PdaClient_1.PdaClient.deriveController(strategyId)
159
+ strategy: PdaClient_1.PdaClient.deriveController(strategyId),
160
160
  }, {
161
161
  update,
162
162
  role: affectedRole,
@@ -179,11 +179,11 @@ class ReflectKeeper {
179
179
  adminPermissions: PdaClient_1.PdaClient.derivePermissions(signer),
180
180
  main: PdaClient_1.PdaClient.deriveMain(),
181
181
  systemProgram: web3_js_1.SystemProgram.programId,
182
- strategy: PdaClient_1.PdaClient.deriveController(strategyId)
182
+ strategy: PdaClient_1.PdaClient.deriveController(strategyId),
183
183
  }, {
184
184
  update,
185
185
  role: affectedRole,
186
- action
186
+ action,
187
187
  }, reflect_main_1.PROGRAM_ID);
188
188
  return ix;
189
189
  }
@@ -205,24 +205,41 @@ class ReflectKeeper {
205
205
  }, {
206
206
  action,
207
207
  role: affectedRole,
208
- update
208
+ update,
209
209
  }, reflect_main_1.PROGRAM_ID);
210
210
  return ix;
211
211
  }
212
- fetchAdminByRole(role) {
212
+ fetchAllAdminAccounts() {
213
213
  return __awaiter(this, void 0, void 0, function* () {
214
- const data = yield reflect_main_1.UserPermissions
215
- .gpaBuilder(reflect_main_1.PROGRAM_ID)
214
+ const data = yield reflect_main_1.UserPermissions.gpaBuilder(reflect_main_1.PROGRAM_ID)
216
215
  .addFilter("accountDiscriminator", reflect_main_1.userPermissionsDiscriminator)
217
216
  .run(this.connection);
218
- return data.map(({ pubkey, account: { data } }) => {
217
+ return data
218
+ .map(({ pubkey, account: { data } }) => {
219
219
  const [account] = reflect_main_1.UserPermissions.deserialize(data);
220
220
  return {
221
221
  pubkey,
222
- account
222
+ account,
223
223
  };
224
- })
225
- .filter(({ account }) => account.protocolRoles.roles.includes(role));
224
+ });
225
+ });
226
+ }
227
+ fetchAdminByRole(role) {
228
+ return __awaiter(this, void 0, void 0, function* () {
229
+ const data = yield this.fetchAllAdminAccounts();
230
+ return data.filter(({ account }) => account.protocolRoles.roles.includes(role));
231
+ });
232
+ }
233
+ fetchAdminByStrategyRole(strategy, role) {
234
+ return __awaiter(this, void 0, void 0, function* () {
235
+ const data = yield this.fetchAllAdminAccounts();
236
+ const strategyPermissionAccounts = data
237
+ .filter(({ account }) => account.strategyRoles.some(({ strategyId }) => strategyId === strategy));
238
+ return strategyPermissionAccounts.filter(({ account }) => {
239
+ var _a;
240
+ return (_a = account.strategyRoles
241
+ .find(({ strategyId }) => strategyId === strategy)) === null || _a === void 0 ? void 0 : _a.roles.roles.includes(role);
242
+ });
226
243
  });
227
244
  }
228
245
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reflectmoney/stable.ts",
3
- "version": "2.5.1",
3
+ "version": "2.5.3",
4
4
  "type": "commonjs",
5
5
  "author": "stablecoinjesus @ Palindrome Engineering",
6
6
  "repository": {