@reflectmoney/stable.ts 2.5.1 → 2.5.2

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
  });
@@ -106,4 +106,8 @@ export declare class ReflectKeeper {
106
106
  pubkey: PublicKey;
107
107
  account: UserPermissions;
108
108
  }[]>;
109
+ fetchAdminByStrategyRole(strategy: number, role: Role): Promise<{
110
+ pubkey: PublicKey;
111
+ account: UserPermissions;
112
+ }[]>;
109
113
  }
@@ -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,25 +205,46 @@ 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
212
  fetchAdminByRole(role) {
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
224
  })
225
225
  .filter(({ account }) => account.protocolRoles.roles.includes(role));
226
226
  });
227
227
  }
228
+ fetchAdminByStrategyRole(strategy, role) {
229
+ return __awaiter(this, void 0, void 0, function* () {
230
+ const data = yield reflect_main_1.UserPermissions.gpaBuilder(reflect_main_1.PROGRAM_ID)
231
+ .addFilter("accountDiscriminator", reflect_main_1.userPermissionsDiscriminator)
232
+ .run(this.connection);
233
+ const strategyPermissionAccounts = data
234
+ .map(({ pubkey, account: { data } }) => {
235
+ const [account] = reflect_main_1.UserPermissions.deserialize(data);
236
+ return {
237
+ pubkey,
238
+ account,
239
+ };
240
+ })
241
+ .filter(({ account }) => account.strategyRoles.some(({ strategyId }) => strategyId === strategy));
242
+ return strategyPermissionAccounts.filter(({ account }) => {
243
+ var _a;
244
+ return (_a = account.strategyRoles
245
+ .find(({ strategyId }) => strategyId === strategy)) === null || _a === void 0 ? void 0 : _a.roles.roles.includes(role);
246
+ });
247
+ });
248
+ }
228
249
  }
229
250
  exports.ReflectKeeper = ReflectKeeper;
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.2",
4
4
  "type": "commonjs",
5
5
  "author": "stablecoinjesus @ Palindrome Engineering",
6
6
  "repository": {