@reflectmoney/stable.ts 2.7.4 → 2.8.1
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.
|
@@ -18,15 +18,17 @@ export declare class ReflectKeeper {
|
|
|
18
18
|
private main;
|
|
19
19
|
/** Solana connection instance for RPC communication */
|
|
20
20
|
private connection;
|
|
21
|
+
private devnet;
|
|
21
22
|
/**
|
|
22
23
|
* Creates a new ReflectKeeper instance.
|
|
23
24
|
*
|
|
24
25
|
* @param admin - Public key of the admin user
|
|
25
26
|
* @param connection - Solana connection instance
|
|
26
27
|
*/
|
|
27
|
-
constructor({ admin, connection, }: {
|
|
28
|
+
constructor({ admin, connection, devnet, }: {
|
|
28
29
|
admin: PublicKey;
|
|
29
30
|
connection: Connection;
|
|
31
|
+
devnet?: boolean;
|
|
30
32
|
});
|
|
31
33
|
/**
|
|
32
34
|
* Creates the main program account. This is the initial step of protocol setup.
|
|
@@ -34,7 +36,7 @@ export declare class ReflectKeeper {
|
|
|
34
36
|
* @param admin - Public key of the initial admin
|
|
35
37
|
* @returns TransactionInstruction for initializing the main account
|
|
36
38
|
*/
|
|
37
|
-
static initializeMain(admin: PublicKey): import("@solana/web3.js").TransactionInstruction;
|
|
39
|
+
static initializeMain(admin: PublicKey, devnet?: boolean): import("@solana/web3.js").TransactionInstruction;
|
|
38
40
|
getPermissionAccount(): Promise<UserPermissions>;
|
|
39
41
|
/**
|
|
40
42
|
* Freezes or unfreezes a specific protocol action.
|
|
@@ -13,6 +13,7 @@ exports.ReflectKeeper = void 0;
|
|
|
13
13
|
const web3_js_1 = require("@solana/web3.js");
|
|
14
14
|
const reflect_main_1 = require("../generated/reflect_main");
|
|
15
15
|
const PdaClient_1 = require("./PdaClient");
|
|
16
|
+
const devnet_1 = require("../constants/devnet");
|
|
16
17
|
/**
|
|
17
18
|
* Administrative client for the Reflect protocol.
|
|
18
19
|
* Provides functionality for protocol-level administration including:
|
|
@@ -31,10 +32,11 @@ class ReflectKeeper {
|
|
|
31
32
|
* @param admin - Public key of the admin user
|
|
32
33
|
* @param connection - Solana connection instance
|
|
33
34
|
*/
|
|
34
|
-
constructor({ admin, connection, }) {
|
|
35
|
+
constructor({ admin, connection, devnet = false, }) {
|
|
35
36
|
this.admin = admin;
|
|
36
37
|
this.connection = connection;
|
|
37
|
-
this.
|
|
38
|
+
this.devnet = devnet;
|
|
39
|
+
this.main = PdaClient_1.PdaClient.deriveMain(devnet);
|
|
38
40
|
}
|
|
39
41
|
/**
|
|
40
42
|
* Creates the main program account. This is the initial step of protocol setup.
|
|
@@ -42,19 +44,19 @@ class ReflectKeeper {
|
|
|
42
44
|
* @param admin - Public key of the initial admin
|
|
43
45
|
* @returns TransactionInstruction for initializing the main account
|
|
44
46
|
*/
|
|
45
|
-
static initializeMain(admin) {
|
|
46
|
-
const [main] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("main")], reflect_main_1.PROGRAM_ID);
|
|
47
|
+
static initializeMain(admin, devnet) {
|
|
48
|
+
const [main] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("main")], devnet ? devnet_1.DEVNET_PROGRAM_ID : reflect_main_1.PROGRAM_ID);
|
|
47
49
|
const ix = (0, reflect_main_1.createInitMainInstruction)({
|
|
48
50
|
main,
|
|
49
51
|
admin,
|
|
50
52
|
systemProgram: web3_js_1.SystemProgram.programId,
|
|
51
|
-
creds: PdaClient_1.PdaClient.derivePermissions(admin),
|
|
52
|
-
}, reflect_main_1.PROGRAM_ID);
|
|
53
|
+
creds: PdaClient_1.PdaClient.derivePermissions(admin, devnet),
|
|
54
|
+
}, devnet ? devnet_1.DEVNET_PROGRAM_ID : reflect_main_1.PROGRAM_ID);
|
|
53
55
|
return ix;
|
|
54
56
|
}
|
|
55
57
|
getPermissionAccount() {
|
|
56
58
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
const permissions = PdaClient_1.PdaClient.derivePermissions(this.admin);
|
|
59
|
+
const permissions = PdaClient_1.PdaClient.derivePermissions(this.admin, this.devnet);
|
|
58
60
|
const permissionsAccount = yield reflect_main_1.UserPermissions.fromAccountAddress(this.connection, permissions);
|
|
59
61
|
return permissionsAccount;
|
|
60
62
|
});
|
|
@@ -71,11 +73,11 @@ class ReflectKeeper {
|
|
|
71
73
|
admin: this.admin,
|
|
72
74
|
main: this.main,
|
|
73
75
|
systemProgram: web3_js_1.SystemProgram.programId,
|
|
74
|
-
adminPermissions: PdaClient_1.PdaClient.derivePermissions(this.admin),
|
|
76
|
+
adminPermissions: PdaClient_1.PdaClient.derivePermissions(this.admin, this.devnet),
|
|
75
77
|
}, {
|
|
76
78
|
freeze,
|
|
77
79
|
action,
|
|
78
|
-
});
|
|
80
|
+
}, this.devnet ? devnet_1.DEVNET_PROGRAM_ID : reflect_main_1.PROGRAM_ID);
|
|
79
81
|
return ix;
|
|
80
82
|
}
|
|
81
83
|
/**
|
|
@@ -90,11 +92,11 @@ class ReflectKeeper {
|
|
|
90
92
|
admin: this.admin,
|
|
91
93
|
main: this.main,
|
|
92
94
|
systemProgram: web3_js_1.SystemProgram.programId,
|
|
93
|
-
adminPermissions: PdaClient_1.PdaClient.derivePermissions(this.admin),
|
|
95
|
+
adminPermissions: PdaClient_1.PdaClient.derivePermissions(this.admin, this.devnet),
|
|
94
96
|
}, {
|
|
95
97
|
freeze,
|
|
96
98
|
programIndex,
|
|
97
|
-
});
|
|
99
|
+
}, this.devnet ? devnet_1.DEVNET_PROGRAM_ID : reflect_main_1.PROGRAM_ID);
|
|
98
100
|
return ix;
|
|
99
101
|
}
|
|
100
102
|
/**
|
|
@@ -107,12 +109,12 @@ class ReflectKeeper {
|
|
|
107
109
|
createAdminAccount(signer, newAdmin, roles = 18) {
|
|
108
110
|
const ix = (0, reflect_main_1.createCreateAdminAccountInstruction)({
|
|
109
111
|
caller: signer,
|
|
110
|
-
newCreds: PdaClient_1.PdaClient.derivePermissions(newAdmin),
|
|
112
|
+
newCreds: PdaClient_1.PdaClient.derivePermissions(newAdmin, this.devnet),
|
|
111
113
|
systemProgram: web3_js_1.SystemProgram.programId,
|
|
112
114
|
}, {
|
|
113
115
|
newAdmin,
|
|
114
116
|
roles,
|
|
115
|
-
}, reflect_main_1.PROGRAM_ID);
|
|
117
|
+
}, this.devnet ? devnet_1.DEVNET_PROGRAM_ID : reflect_main_1.PROGRAM_ID);
|
|
116
118
|
return ix;
|
|
117
119
|
}
|
|
118
120
|
/**
|
|
@@ -127,16 +129,16 @@ class ReflectKeeper {
|
|
|
127
129
|
updateRoleHolderProtocol(signer, adminToUpdate, affectedRole, update) {
|
|
128
130
|
const ix = (0, reflect_main_1.createUpdateRoleHolderProtocolInstruction)({
|
|
129
131
|
admin: signer,
|
|
130
|
-
adminPermissions: PdaClient_1.PdaClient.derivePermissions(signer),
|
|
131
|
-
main: PdaClient_1.PdaClient.deriveMain(),
|
|
132
|
+
adminPermissions: PdaClient_1.PdaClient.derivePermissions(signer, this.devnet),
|
|
133
|
+
main: PdaClient_1.PdaClient.deriveMain(this.devnet),
|
|
132
134
|
systemProgram: web3_js_1.SystemProgram.programId,
|
|
133
|
-
updateAdminPermissions: PdaClient_1.PdaClient.derivePermissions(adminToUpdate),
|
|
135
|
+
updateAdminPermissions: PdaClient_1.PdaClient.derivePermissions(adminToUpdate, this.devnet),
|
|
134
136
|
// Dummy strategy account.
|
|
135
|
-
strategy: PdaClient_1.PdaClient.deriveController(0),
|
|
137
|
+
strategy: PdaClient_1.PdaClient.deriveController(0, this.devnet),
|
|
136
138
|
}, {
|
|
137
139
|
update,
|
|
138
140
|
accessLevel: affectedRole,
|
|
139
|
-
}, reflect_main_1.PROGRAM_ID);
|
|
141
|
+
}, this.devnet ? devnet_1.DEVNET_PROGRAM_ID : reflect_main_1.PROGRAM_ID);
|
|
140
142
|
return ix;
|
|
141
143
|
}
|
|
142
144
|
/**
|
|
@@ -152,15 +154,15 @@ class ReflectKeeper {
|
|
|
152
154
|
updateRoleHolderStrategy(signer, strategyId, adminToUpdate, affectedRole, update) {
|
|
153
155
|
const ix = (0, reflect_main_1.createUpdateRoleHolderStrategyInstruction)({
|
|
154
156
|
admin: signer,
|
|
155
|
-
adminPermissions: PdaClient_1.PdaClient.derivePermissions(signer),
|
|
156
|
-
main: PdaClient_1.PdaClient.deriveMain(),
|
|
157
|
+
adminPermissions: PdaClient_1.PdaClient.derivePermissions(signer, this.devnet),
|
|
158
|
+
main: PdaClient_1.PdaClient.deriveMain(this.devnet),
|
|
157
159
|
systemProgram: web3_js_1.SystemProgram.programId,
|
|
158
|
-
updateAdminPermissions: PdaClient_1.PdaClient.derivePermissions(adminToUpdate),
|
|
159
|
-
strategy: PdaClient_1.PdaClient.deriveController(strategyId),
|
|
160
|
+
updateAdminPermissions: PdaClient_1.PdaClient.derivePermissions(adminToUpdate, this.devnet),
|
|
161
|
+
strategy: PdaClient_1.PdaClient.deriveController(strategyId, this.devnet),
|
|
160
162
|
}, {
|
|
161
163
|
update,
|
|
162
164
|
role: affectedRole,
|
|
163
|
-
}, reflect_main_1.PROGRAM_ID);
|
|
165
|
+
}, this.devnet ? devnet_1.DEVNET_PROGRAM_ID : reflect_main_1.PROGRAM_ID);
|
|
164
166
|
return ix;
|
|
165
167
|
}
|
|
166
168
|
/**
|
|
@@ -176,15 +178,15 @@ class ReflectKeeper {
|
|
|
176
178
|
updateActionRoleStrategy(signer, strategyId, action, affectedRole, update) {
|
|
177
179
|
const ix = (0, reflect_main_1.createUpdateActionRoleStrategyInstruction)({
|
|
178
180
|
admin: signer,
|
|
179
|
-
adminPermissions: PdaClient_1.PdaClient.derivePermissions(signer),
|
|
180
|
-
main: PdaClient_1.PdaClient.deriveMain(),
|
|
181
|
+
adminPermissions: PdaClient_1.PdaClient.derivePermissions(signer, this.devnet),
|
|
182
|
+
main: PdaClient_1.PdaClient.deriveMain(this.devnet),
|
|
181
183
|
systemProgram: web3_js_1.SystemProgram.programId,
|
|
182
|
-
strategy: PdaClient_1.PdaClient.deriveController(strategyId),
|
|
184
|
+
strategy: PdaClient_1.PdaClient.deriveController(strategyId, this.devnet),
|
|
183
185
|
}, {
|
|
184
186
|
update,
|
|
185
187
|
role: affectedRole,
|
|
186
188
|
action,
|
|
187
|
-
}, reflect_main_1.PROGRAM_ID);
|
|
189
|
+
}, this.devnet ? devnet_1.DEVNET_PROGRAM_ID : reflect_main_1.PROGRAM_ID);
|
|
188
190
|
return ix;
|
|
189
191
|
}
|
|
190
192
|
/**
|
|
@@ -199,14 +201,14 @@ class ReflectKeeper {
|
|
|
199
201
|
updateActionRoleProtocol(signer, action, affectedRole, update) {
|
|
200
202
|
const ix = (0, reflect_main_1.createUpdateActionRoleProtocolInstruction)({
|
|
201
203
|
admin: signer,
|
|
202
|
-
adminPermissions: PdaClient_1.PdaClient.derivePermissions(signer),
|
|
203
|
-
main: PdaClient_1.PdaClient.deriveMain(),
|
|
204
|
+
adminPermissions: PdaClient_1.PdaClient.derivePermissions(signer, this.devnet),
|
|
205
|
+
main: PdaClient_1.PdaClient.deriveMain(this.devnet),
|
|
204
206
|
systemProgram: web3_js_1.SystemProgram.programId,
|
|
205
207
|
}, {
|
|
206
208
|
action,
|
|
207
209
|
role: affectedRole,
|
|
208
210
|
update,
|
|
209
|
-
}, reflect_main_1.PROGRAM_ID);
|
|
211
|
+
}, this.devnet ? devnet_1.DEVNET_PROGRAM_ID : reflect_main_1.PROGRAM_ID);
|
|
210
212
|
return ix;
|
|
211
213
|
}
|
|
212
214
|
fetchAllAdminAccounts() {
|