@reflectmoney/stable.ts 2.5.0 → 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
|
});
|
|
@@ -102,4 +102,12 @@ 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
|
+
fetchAdminByRole(role: Role): Promise<{
|
|
106
|
+
pubkey: PublicKey;
|
|
107
|
+
account: UserPermissions;
|
|
108
|
+
}[]>;
|
|
109
|
+
fetchAdminByStrategyRole(strategy: number, role: Role): Promise<{
|
|
110
|
+
pubkey: PublicKey;
|
|
111
|
+
account: UserPermissions;
|
|
112
|
+
}[]>;
|
|
105
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,9 +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
|
+
fetchAdminByRole(role) {
|
|
213
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
214
|
+
const data = yield reflect_main_1.UserPermissions.gpaBuilder(reflect_main_1.PROGRAM_ID)
|
|
215
|
+
.addFilter("accountDiscriminator", reflect_main_1.userPermissionsDiscriminator)
|
|
216
|
+
.run(this.connection);
|
|
217
|
+
return data
|
|
218
|
+
.map(({ pubkey, account: { data } }) => {
|
|
219
|
+
const [account] = reflect_main_1.UserPermissions.deserialize(data);
|
|
220
|
+
return {
|
|
221
|
+
pubkey,
|
|
222
|
+
account,
|
|
223
|
+
};
|
|
224
|
+
})
|
|
225
|
+
.filter(({ account }) => account.protocolRoles.roles.includes(role));
|
|
226
|
+
});
|
|
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
|
+
}
|
|
212
249
|
}
|
|
213
250
|
exports.ReflectKeeper = ReflectKeeper;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reflectmoney/stable.ts",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.2",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "stablecoinjesus @ Palindrome Engineering",
|
|
6
6
|
"repository": {
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"test": "mocha --require ts-node/register ./tests/index.test.ts",
|
|
12
|
-
"test:slippage": "mocha --require ts-node/register ./tests/slippage.test.ts"
|
|
12
|
+
"test:slippage": "mocha --require ts-node/register ./tests/slippage.test.ts",
|
|
13
|
+
"test:keeper": "mocha --require ts-node/register ./tests/keeper.test.ts"
|
|
13
14
|
},
|
|
14
15
|
"dependencies": {
|
|
15
16
|
"@coral-xyz/anchor": "0.29.0",
|