@reflectmoney/stable.ts 1.1.7 → 1.1.9

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.
@@ -34,6 +34,7 @@ export declare abstract class Stablecoin<T extends Controller> {
34
34
  driftClient?: DriftClient;
35
35
  /** Lookup table with stablecoin-specific accounts. */
36
36
  lookupTable: PublicKey;
37
+ isPermissioned: boolean;
37
38
  /**
38
39
  * Loads the controller account for this stablecoin.
39
40
  *
@@ -45,7 +45,7 @@ export declare class UsdcPlusStablecoin extends Stablecoin<DriftUsdcController>
45
45
  * @param signer - Public key of the signer
46
46
  * @returns Promise resolving to the constructed accounts object of type T
47
47
  */
48
- constructAccounts<T>(signer: PublicKey): Promise<T>;
48
+ constructAccounts<T>(signer: PublicKey, permissions?: boolean): Promise<T>;
49
49
  /**
50
50
  * Constructs remaining accounts for transactions.
51
51
  * Currently returns an empty array as no additional accounts are needed.
@@ -49,6 +49,7 @@ class UsdcPlusStablecoin extends Stablecoin_1.Stablecoin {
49
49
  wallet: new nodewallet_1.default(web3_js_1.Keypair.generate()),
50
50
  authority: this.controllerKey
51
51
  });
52
+ this.isPermissioned = true;
52
53
  // Otherwise has to be loaded first.
53
54
  if (stablecoinMintOverride)
54
55
  this.stablecoinMint = stablecoinMintOverride;
@@ -135,8 +136,8 @@ class UsdcPlusStablecoin extends Stablecoin_1.Stablecoin {
135
136
  * @param signer - Public key of the signer
136
137
  * @returns Promise resolving to the constructed accounts object of type T
137
138
  */
138
- constructAccounts(signer) {
139
- return __awaiter(this, void 0, void 0, function* () {
139
+ constructAccounts(signer_1) {
140
+ return __awaiter(this, arguments, void 0, function* (signer, permissions = this.isPermissioned) {
140
141
  const userAccount = (0, sdk_1.getUserAccountPublicKeySync)(constants_1.DRIFT_PROGRAM_ID, this.controllerKey);
141
142
  const userStats = (0, sdk_1.getUserStatsAccountPublicKey)(constants_1.DRIFT_PROGRAM_ID, this.controllerKey);
142
143
  const anchorRemainingAccounts = yield this.constructRemainingAccounts();
@@ -165,7 +166,7 @@ class UsdcPlusStablecoin extends Stablecoin_1.Stablecoin {
165
166
  userReceiptAta,
166
167
  userStats,
167
168
  userUsdcAta,
168
- adminPermissions: null,
169
+ adminPermissions: permissions ? classes_1.PdaClient.derivePermissions(signer) : null,
169
170
  anchorRemainingAccounts,
170
171
  systemProgram: web3_js_1.SystemProgram.programId,
171
172
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID
@@ -208,7 +209,7 @@ class UsdcPlusStablecoin extends Stablecoin_1.Stablecoin {
208
209
  */
209
210
  mint(signer, amount, minimumReceived) {
210
211
  return __awaiter(this, void 0, void 0, function* () {
211
- const accounts = yield this.constructAccounts(signer);
212
+ const accounts = yield this.constructAccounts(signer, true);
212
213
  const ix = (0, reflect_main_1.createMintDriftS1Instruction)(accounts, {
213
214
  minUsdcAmount: minimumReceived,
214
215
  usdcAmount: amount
@@ -224,7 +225,7 @@ class UsdcPlusStablecoin extends Stablecoin_1.Stablecoin {
224
225
  */
225
226
  redeem(signer, amount, minimumReceived) {
226
227
  return __awaiter(this, void 0, void 0, function* () {
227
- const accounts = yield this.constructAccounts(signer);
228
+ const accounts = yield this.constructAccounts(signer, true);
228
229
  const ix = (0, reflect_main_1.createRedeemDriftS1Instruction)(accounts, {
229
230
  canChill: false,
230
231
  minLstRedeem: minimumReceived,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reflectmoney/stable.ts",
3
- "version": "1.1.7",
3
+ "version": "1.1.9",
4
4
  "type": "commonjs",
5
5
  "author": "stablecoinjesus @ Palindrome Engineering",
6
6
  "repository": {