@reflectmoney/stable.ts 2.7.4 → 2.8.0
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
38
|
this.main = PdaClient_1.PdaClient.deriveMain();
|
|
39
|
+
this.devnet = 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
53
|
creds: PdaClient_1.PdaClient.derivePermissions(admin),
|
|
52
|
-
}, reflect_main_1.PROGRAM_ID);
|
|
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
|
});
|
|
@@ -75,7 +77,7 @@ class ReflectKeeper {
|
|
|
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
|
/**
|
|
@@ -94,7 +96,7 @@ class ReflectKeeper {
|
|
|
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
|
/**
|
|
@@ -112,7 +114,7 @@ class ReflectKeeper {
|
|
|
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
|
/**
|
|
@@ -136,7 +138,7 @@ class ReflectKeeper {
|
|
|
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
|
/**
|
|
@@ -160,7 +162,7 @@ class ReflectKeeper {
|
|
|
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
|
/**
|
|
@@ -184,7 +186,7 @@ class ReflectKeeper {
|
|
|
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
|
/**
|
|
@@ -206,7 +208,7 @@ class ReflectKeeper {
|
|
|
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() {
|