@dstoken-solana/rwa-rbac 0.0.1-rc14 → 0.0.1-rc15
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.
- package/dist/client/AssetController.js +297 -326
- package/dist/client/AssetController.js.map +1 -1
- package/dist/client/IdentityMetadataRegistry.js +238 -259
- package/dist/client/IdentityMetadataRegistry.js.map +1 -1
- package/dist/client/IdentityRegistry.js +167 -187
- package/dist/client/IdentityRegistry.js.map +1 -1
- package/dist/client/PolicyEngine.js +111 -132
- package/dist/client/PolicyEngine.js.map +1 -1
- package/dist/client/RwaRbacClient.js +94 -111
- package/dist/client/RwaRbacClient.js.map +1 -1
- package/dist/client/TokenLocks.js +198 -214
- package/dist/client/TokenLocks.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import { PublicKey, SystemProgram, } from "@solana/web3.js";
|
|
11
2
|
import { ASSOCIATED_TOKEN_PROGRAM_ID, createAssociatedTokenAccountInstruction, getAssociatedTokenAddressSync, TOKEN_2022_PROGRAM_ID, } from "@solana/spl-token";
|
|
12
3
|
import { assetControllerProgramId, getAssetControllerEventAuthority, getAssetControllerPda, getCloseMintIx, getCreateAssetControllerIx, getExtraMetasListPda, getFreezeTokenIx, getIdentityAccountPda, getIdentityRegistryPda, getPolicyEnginePda, getRevokeTokensIx, getSeizeTokensIx, getThawTokenIx, getTrackerAccountPda, getUpdateInterestBearingMintRateIx, getWalletIdentityAccountPda, identityRegistryProgramId, policyEngineProgramId, } from "@dstoken-solana/rwa-token-sdk";
|
|
@@ -16,6 +7,8 @@ import { deriveInvestorLocks, deriveControllerAuthorityPda, deriveInvestorPda, d
|
|
|
16
7
|
* Represents the role-based access client for Asset Controller for an RWA.
|
|
17
8
|
*/
|
|
18
9
|
export class AssetController {
|
|
10
|
+
rwaClient;
|
|
11
|
+
rbacProgram;
|
|
19
12
|
constructor(rwaClient, rbacProgram) {
|
|
20
13
|
this.rwaClient = rwaClient;
|
|
21
14
|
this.rbacProgram = rbacProgram;
|
|
@@ -25,10 +18,8 @@ export class AssetController {
|
|
|
25
18
|
* @param args - {@link CreateAssetControllerIx}
|
|
26
19
|
* @returns A Promise that resolves to the instructions to create an asset controller.
|
|
27
20
|
*/
|
|
28
|
-
setupNewRegistry(args) {
|
|
29
|
-
return
|
|
30
|
-
return getCreateAssetControllerIx(args, this.rwaClient.provider);
|
|
31
|
-
});
|
|
21
|
+
async setupNewRegistry(args) {
|
|
22
|
+
return getCreateAssetControllerIx(args, this.rwaClient.provider);
|
|
32
23
|
}
|
|
33
24
|
/**
|
|
34
25
|
* Update the asset controller's metadata.
|
|
@@ -37,27 +28,25 @@ export class AssetController {
|
|
|
37
28
|
* @param authorizedUserRole - Optional UserRole account. Required if user is not an admin.
|
|
38
29
|
* @returns A Promise that resolves to the instructions to update the asset controller's metadata.
|
|
39
30
|
* */
|
|
40
|
-
updateAssetMetadata(args, assetAccessController, authorizedUserRole) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
.instruction();
|
|
60
|
-
});
|
|
31
|
+
async updateAssetMetadata(args, assetAccessController, authorizedUserRole) {
|
|
32
|
+
const updateIx = await this.rwaClient.assetController.updateAssetMetadata(args);
|
|
33
|
+
const ixData = updateIx.data;
|
|
34
|
+
return this.rbacProgram.methods
|
|
35
|
+
.updateAssetMetadata(ixData)
|
|
36
|
+
.accountsStrict({
|
|
37
|
+
payer: args.payer,
|
|
38
|
+
user: args.signer,
|
|
39
|
+
controllerAuthority: args.authority,
|
|
40
|
+
assetAccessController,
|
|
41
|
+
authorizedUserRole: authorizedUserRole || null,
|
|
42
|
+
assetMint: args.assetMint,
|
|
43
|
+
assetController: getAssetControllerPda(args.assetMint),
|
|
44
|
+
assetControllerProgram: assetControllerProgramId,
|
|
45
|
+
tokenProgram: TOKEN_2022_PROGRAM_ID,
|
|
46
|
+
eventAuthority: getAssetControllerEventAuthority(),
|
|
47
|
+
systemProgram: SystemProgram.programId,
|
|
48
|
+
})
|
|
49
|
+
.instruction();
|
|
61
50
|
}
|
|
62
51
|
/**
|
|
63
52
|
* Asynchronously generates instructions to issue tokens and lock tokens according to issuance policy.
|
|
@@ -65,118 +54,112 @@ export class AssetController {
|
|
|
65
54
|
* @param assetAccessController - RBAC AssetAccessController account.
|
|
66
55
|
* @param authorizedUserRole - Optional UserRole account. Required if user is not an admin.
|
|
67
56
|
*/
|
|
68
|
-
issueTokenIxns(args, assetAccessController, authorizedUserRole) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
return ixs;
|
|
159
|
-
});
|
|
57
|
+
async issueTokenIxns(args, assetAccessController, authorizedUserRole) {
|
|
58
|
+
const identityRegistry = getIdentityRegistryPda(args.assetMint);
|
|
59
|
+
const investorPda = deriveInvestorPda(args.investorId, identityRegistry);
|
|
60
|
+
const unlockedTokenAccount = getAssociatedTokenAddressSync(new PublicKey(args.assetMint), new PublicKey(args.wallet), false, TOKEN_2022_PROGRAM_ID);
|
|
61
|
+
const trackerAccount = getTrackerAccountPda(args.assetMint, investorPda.toString());
|
|
62
|
+
const controllerAuthority = deriveControllerAuthorityPda(assetAccessController);
|
|
63
|
+
const ixs = [];
|
|
64
|
+
// Check if unlockedTokenAccount exists.
|
|
65
|
+
const tokenAccountData = await this.rbacProgram.provider.connection.getAccountInfo(unlockedTokenAccount);
|
|
66
|
+
if (!tokenAccountData) {
|
|
67
|
+
// ATA needs to be created separately as controller_pda cannot be payer.
|
|
68
|
+
const createAtaIx = createAssociatedTokenAccountInstruction(new PublicKey(args.payer), unlockedTokenAccount, new PublicKey(args.wallet), new PublicKey(args.assetMint), TOKEN_2022_PROGRAM_ID);
|
|
69
|
+
ixs.push(createAtaIx);
|
|
70
|
+
}
|
|
71
|
+
ixs.push(await this.rbacProgram.methods
|
|
72
|
+
.issueTokens(args.amount, args.issuanceTimestamp, args.reasonCode == undefined ? null : args.reasonCode, args.reasonString == undefined ? null : args.reasonString)
|
|
73
|
+
.accountsStrict({
|
|
74
|
+
payer: args.payer,
|
|
75
|
+
user: args.signer,
|
|
76
|
+
controllerAuthority,
|
|
77
|
+
assetAccessController: assetAccessController,
|
|
78
|
+
authorizedUserRole: authorizedUserRole || null,
|
|
79
|
+
assetControllerProgram: assetControllerProgramId,
|
|
80
|
+
assetMint: args.assetMint,
|
|
81
|
+
assetController: getAssetControllerPda(args.assetMint),
|
|
82
|
+
to: args.wallet,
|
|
83
|
+
tokenAccount: unlockedTokenAccount,
|
|
84
|
+
policyEngine: getPolicyEnginePda(args.assetMint),
|
|
85
|
+
policyEngineProgram: policyEngineProgramId,
|
|
86
|
+
identityAccount: getIdentityAccountPda(args.assetMint, investorPda.toString()),
|
|
87
|
+
trackerAccount,
|
|
88
|
+
identityRegistry,
|
|
89
|
+
tokenProgram: TOKEN_2022_PROGRAM_ID,
|
|
90
|
+
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
91
|
+
systemProgram: SystemProgram.programId,
|
|
92
|
+
walletIdentityAccount: getWalletIdentityAccountPda(args.assetMint, args.wallet),
|
|
93
|
+
tokenLocksProgram: TL_PROGRAM,
|
|
94
|
+
investorLocks: deriveInvestorLocks(args.investorId, identityRegistry),
|
|
95
|
+
investor: investorPda,
|
|
96
|
+
lockedTokenAccount: deriveLockedTokenAccount(args.investorId, identityRegistry),
|
|
97
|
+
})
|
|
98
|
+
.remainingAccounts([
|
|
99
|
+
{
|
|
100
|
+
pubkey: getPolicyEnginePda(args.assetMint),
|
|
101
|
+
isWritable: true,
|
|
102
|
+
isSigner: false,
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
pubkey: identityRegistryProgramId,
|
|
106
|
+
isWritable: false,
|
|
107
|
+
isSigner: false,
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
pubkey: policyEngineProgramId,
|
|
111
|
+
isWritable: false,
|
|
112
|
+
isSigner: false,
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
pubkey: identityRegistry,
|
|
116
|
+
isWritable: false,
|
|
117
|
+
isSigner: false,
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
pubkey: getIdentityAccountPda(args.assetMint, investorPda.toString()),
|
|
121
|
+
isWritable: false,
|
|
122
|
+
isSigner: false,
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
pubkey: getIdentityAccountPda(args.assetMint, args.wallet.toString()),
|
|
126
|
+
isWritable: false,
|
|
127
|
+
isSigner: false,
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
pubkey: trackerAccount,
|
|
131
|
+
isWritable: true,
|
|
132
|
+
isSigner: false,
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
pubkey: getExtraMetasListPda(args.assetMint),
|
|
136
|
+
isWritable: false,
|
|
137
|
+
isSigner: false,
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
pubkey: getWalletIdentityAccountPda(args.assetMint, investorPda.toString()),
|
|
141
|
+
isWritable: false,
|
|
142
|
+
isSigner: false,
|
|
143
|
+
},
|
|
144
|
+
])
|
|
145
|
+
.instruction());
|
|
146
|
+
return ixs;
|
|
160
147
|
}
|
|
161
148
|
/**
|
|
162
149
|
* Asynchronously generates instructions to revoke assets.
|
|
163
150
|
* @param args - {@link VoidTokensArgs}
|
|
164
151
|
* @returns A Promise that resolves to the instructions to revoke assets.
|
|
165
152
|
*/
|
|
166
|
-
voidTokenIxns(args) {
|
|
167
|
-
return
|
|
168
|
-
return this.rwaClient.assetController.voidTokenIxns(args);
|
|
169
|
-
});
|
|
153
|
+
async voidTokenIxns(args) {
|
|
154
|
+
return this.rwaClient.assetController.voidTokenIxns(args);
|
|
170
155
|
}
|
|
171
156
|
/**
|
|
172
157
|
* Executes a token transfer.
|
|
173
158
|
* @param args - {@link TransferTokensArgs}
|
|
174
159
|
* @returns A promise that resolves to transaction instruction.
|
|
175
160
|
*/
|
|
176
|
-
transfer(args) {
|
|
177
|
-
return
|
|
178
|
-
return this.rwaClient.assetController.transfer(args);
|
|
179
|
-
});
|
|
161
|
+
async transfer(args) {
|
|
162
|
+
return this.rwaClient.assetController.transfer(args);
|
|
180
163
|
}
|
|
181
164
|
/**
|
|
182
165
|
* Asynchronously generates instruction to freeze a token account.
|
|
@@ -185,26 +168,24 @@ export class AssetController {
|
|
|
185
168
|
* @param authorizedUserRole - Optional UserRole account. Required if user is not an admin.
|
|
186
169
|
* @returns A Promise that resolves to the instruction to freeze.
|
|
187
170
|
*/
|
|
188
|
-
freezeTokenIxn(args, assetAccessController, authorizedUserRole) {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
.instruction();
|
|
207
|
-
});
|
|
171
|
+
async freezeTokenIxn(args, assetAccessController, authorizedUserRole) {
|
|
172
|
+
const freezeIx = await getFreezeTokenIx(args, this.rwaClient.provider);
|
|
173
|
+
const ixData = freezeIx.data;
|
|
174
|
+
const tokenAccount = getAssociatedTokenAddressSync(new PublicKey(args.assetMint), new PublicKey(args.owner), false, TOKEN_2022_PROGRAM_ID);
|
|
175
|
+
return this.rbacProgram.methods
|
|
176
|
+
.freezeTokenAccount(ixData)
|
|
177
|
+
.accountsStrict({
|
|
178
|
+
user: args.signer,
|
|
179
|
+
controllerAuthority: args.authority,
|
|
180
|
+
assetAccessController: assetAccessController,
|
|
181
|
+
authorizedUserRole: authorizedUserRole || null,
|
|
182
|
+
assetControllerProgram: assetControllerProgramId,
|
|
183
|
+
assetMint: args.assetMint,
|
|
184
|
+
assetController: getAssetControllerPda(args.assetMint),
|
|
185
|
+
tokenAccount,
|
|
186
|
+
tokenProgram: TOKEN_2022_PROGRAM_ID,
|
|
187
|
+
})
|
|
188
|
+
.instruction();
|
|
208
189
|
}
|
|
209
190
|
/**
|
|
210
191
|
* Asynchronously generates instruction to thaw a token account.
|
|
@@ -213,27 +194,25 @@ export class AssetController {
|
|
|
213
194
|
* @param authorizedUserRole - Optional UserRole account. Required if user is not an admin.
|
|
214
195
|
* @returns A Promise that resolves to the instruction to thaw.
|
|
215
196
|
*/
|
|
216
|
-
thawTokenIxn(args, assetAccessController, authorizedUserRole) {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
.instruction();
|
|
236
|
-
});
|
|
197
|
+
async thawTokenIxn(args, assetAccessController, authorizedUserRole) {
|
|
198
|
+
const thawIx = await getThawTokenIx(args, this.rwaClient.provider);
|
|
199
|
+
const ixData = thawIx.data;
|
|
200
|
+
const tokenAccount = getAssociatedTokenAddressSync(new PublicKey(args.assetMint), new PublicKey(args.owner), false, TOKEN_2022_PROGRAM_ID);
|
|
201
|
+
return this.rbacProgram.methods
|
|
202
|
+
.thawTokenAccount(ixData)
|
|
203
|
+
.accountsStrict({
|
|
204
|
+
user: args.signer,
|
|
205
|
+
controllerAuthority: args.authority,
|
|
206
|
+
assetAccessController: assetAccessController,
|
|
207
|
+
authorizedUserRole: authorizedUserRole || null,
|
|
208
|
+
assetControllerProgram: assetControllerProgramId,
|
|
209
|
+
assetMint: args.assetMint,
|
|
210
|
+
assetController: getAssetControllerPda(args.assetMint),
|
|
211
|
+
identityRegistryAccount: getIdentityRegistryPda(args.assetMint),
|
|
212
|
+
tokenAccount,
|
|
213
|
+
tokenProgram: TOKEN_2022_PROGRAM_ID,
|
|
214
|
+
})
|
|
215
|
+
.instruction();
|
|
237
216
|
}
|
|
238
217
|
/**
|
|
239
218
|
* Asynchronously generates instructions to revoke tokens from a user.
|
|
@@ -244,42 +223,40 @@ export class AssetController {
|
|
|
244
223
|
* @param authorizedUserRole - Optional UserRole account. Required if user is not an admin.
|
|
245
224
|
* @returns A Promise that resolves to the instructions to revoke.
|
|
246
225
|
*/
|
|
247
|
-
revokeTokenIxn(args, investorId, signer, assetAccessController, authorizedUserRole) {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
.instruction();
|
|
282
|
-
});
|
|
226
|
+
async revokeTokenIxn(args, investorId, signer, assetAccessController, authorizedUserRole) {
|
|
227
|
+
if (!args.wallet) {
|
|
228
|
+
throw new Error("Use wallet arg for wallet to revoke tokens from.");
|
|
229
|
+
}
|
|
230
|
+
// Set owner (even though it is InvestorPda) as wallet to generate ix data.
|
|
231
|
+
args.owner = args.wallet;
|
|
232
|
+
const revokeIx = await getRevokeTokensIx(args, this.rwaClient.provider);
|
|
233
|
+
const identityRegistry = getIdentityRegistryPda(args.assetMint);
|
|
234
|
+
const investorPda = deriveInvestorPda(investorId, identityRegistry);
|
|
235
|
+
const ixData = revokeIx.data;
|
|
236
|
+
const assetController = getAssetControllerPda(args.assetMint);
|
|
237
|
+
const revokeTokenAccount = getAssociatedTokenAddressSync(new PublicKey(args.assetMint), new PublicKey(args.wallet), false, TOKEN_2022_PROGRAM_ID);
|
|
238
|
+
return await this.rbacProgram.methods
|
|
239
|
+
.revokeTokens(ixData)
|
|
240
|
+
.accountsStrict({
|
|
241
|
+
user: signer,
|
|
242
|
+
controllerAuthority: args.authority,
|
|
243
|
+
assetAccessController: assetAccessController,
|
|
244
|
+
authorizedUserRole: authorizedUserRole || null,
|
|
245
|
+
assetControllerProgram: assetControllerProgramId,
|
|
246
|
+
assetMint: args.assetMint,
|
|
247
|
+
assetController,
|
|
248
|
+
revokeTokenAccount,
|
|
249
|
+
identityRegistry,
|
|
250
|
+
identityAccount: getIdentityAccountPda(args.assetMint, investorPda.toString()),
|
|
251
|
+
trackerAccount: getTrackerAccountPda(args.assetMint, investorPda.toString()),
|
|
252
|
+
policyEngineProgram: policyEngineProgramId,
|
|
253
|
+
policyEngine: getPolicyEnginePda(args.assetMint),
|
|
254
|
+
walletIdentityAccount: getWalletIdentityAccountPda(args.assetMint, args.wallet),
|
|
255
|
+
tokenProgram: TOKEN_2022_PROGRAM_ID,
|
|
256
|
+
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
257
|
+
systemProgram: SystemProgram.programId,
|
|
258
|
+
})
|
|
259
|
+
.instruction();
|
|
283
260
|
}
|
|
284
261
|
/**
|
|
285
262
|
* Asynchronously generates instruction to close mint.
|
|
@@ -288,24 +265,22 @@ export class AssetController {
|
|
|
288
265
|
* @param authorizedUserRole - Optional UserRole account. Required if user is not an admin.
|
|
289
266
|
* @returns A Promise that resolves to the instruction to close mint.
|
|
290
267
|
*/
|
|
291
|
-
closeMintIxn(args, assetAccessController, authorizedUserRole) {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
.instruction();
|
|
308
|
-
});
|
|
268
|
+
async closeMintIxn(args, assetAccessController, authorizedUserRole) {
|
|
269
|
+
const closeIx = await getCloseMintIx(args, this.rwaClient.provider);
|
|
270
|
+
const ixData = closeIx.data;
|
|
271
|
+
return this.rbacProgram.methods
|
|
272
|
+
.closeMintAccount(ixData)
|
|
273
|
+
.accountsStrict({
|
|
274
|
+
user: args.signer,
|
|
275
|
+
controllerAuthority: args.authority,
|
|
276
|
+
assetAccessController,
|
|
277
|
+
authorizedUserRole: authorizedUserRole || null,
|
|
278
|
+
assetControllerProgram: assetControllerProgramId,
|
|
279
|
+
assetMint: args.assetMint,
|
|
280
|
+
assetController: getAssetControllerPda(args.assetMint),
|
|
281
|
+
tokenProgram: TOKEN_2022_PROGRAM_ID,
|
|
282
|
+
})
|
|
283
|
+
.instruction();
|
|
309
284
|
}
|
|
310
285
|
/**
|
|
311
286
|
* Asynchronously generates instruction to update mint interest rate.
|
|
@@ -314,25 +289,23 @@ export class AssetController {
|
|
|
314
289
|
* @param authorizedUserRole - Optional UserRole account. Required if user is not an admin.
|
|
315
290
|
* @returns A Promise that resolves to the instruction to update mint interest rate.
|
|
316
291
|
*/
|
|
317
|
-
updateInterestBearingMintRateIxn(args, assetAccessController, authorizedUserRole) {
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
.instruction();
|
|
335
|
-
});
|
|
292
|
+
async updateInterestBearingMintRateIxn(args, assetAccessController, authorizedUserRole) {
|
|
293
|
+
const updateIx = await getUpdateInterestBearingMintRateIx(args, this.rwaClient.provider);
|
|
294
|
+
const ixData = updateIx.data;
|
|
295
|
+
return this.rbacProgram.methods
|
|
296
|
+
.updateInterestBearingMintRate(ixData)
|
|
297
|
+
.accountsStrict({
|
|
298
|
+
user: args.signer,
|
|
299
|
+
controllerAuthority: args.authority,
|
|
300
|
+
assetAccessController: assetAccessController,
|
|
301
|
+
authorizedUserRole: authorizedUserRole || null,
|
|
302
|
+
assetControllerProgram: assetControllerProgramId,
|
|
303
|
+
assetMint: args.assetMint,
|
|
304
|
+
assetController: getAssetControllerPda(args.assetMint),
|
|
305
|
+
eventAuthority: getAssetControllerEventAuthority(),
|
|
306
|
+
tokenProgram: TOKEN_2022_PROGRAM_ID,
|
|
307
|
+
})
|
|
308
|
+
.instruction();
|
|
336
309
|
}
|
|
337
310
|
/**
|
|
338
311
|
* Asynchronously generates instruction to seize tokens.
|
|
@@ -342,84 +315,82 @@ export class AssetController {
|
|
|
342
315
|
* @param authorizedUserRole - Optional UserRole account. Required if user is not an admin.
|
|
343
316
|
* @returns A Promise that resolves to the instruction to seize.
|
|
344
317
|
*/
|
|
345
|
-
seizeTokensIxn(args, investorId, signer, assetAccessController, authorizedUserRole) {
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
.instruction();
|
|
422
|
-
});
|
|
318
|
+
async seizeTokensIxn(args, investorId, signer, assetAccessController, authorizedUserRole) {
|
|
319
|
+
const identityRegistry = getIdentityRegistryPda(args.assetMint);
|
|
320
|
+
const investorPda = deriveInvestorPda(investorId, identityRegistry);
|
|
321
|
+
const [_, seizeIx] = await getSeizeTokensIx({ ...args, wallet: args.from, from: investorPda.toString() }, this.rwaClient.provider);
|
|
322
|
+
return this.rbacProgram.methods
|
|
323
|
+
.seizeTokens(seizeIx.data)
|
|
324
|
+
.accountsStrict({
|
|
325
|
+
user: signer,
|
|
326
|
+
controllerAuthority: args.authority,
|
|
327
|
+
assetAccessController: assetAccessController,
|
|
328
|
+
authorizedUserRole: authorizedUserRole || null,
|
|
329
|
+
assetControllerProgram: assetControllerProgramId,
|
|
330
|
+
assetMint: args.assetMint,
|
|
331
|
+
assetController: getAssetControllerPda(args.assetMint),
|
|
332
|
+
sourceTokenAccount: getAssociatedTokenAddressSync(new PublicKey(args.assetMint), new PublicKey(args.from), false, TOKEN_2022_PROGRAM_ID),
|
|
333
|
+
destinationTokenAccount: getAssociatedTokenAddressSync(new PublicKey(args.assetMint), new PublicKey(args.to), true, TOKEN_2022_PROGRAM_ID),
|
|
334
|
+
tokenProgram: TOKEN_2022_PROGRAM_ID,
|
|
335
|
+
})
|
|
336
|
+
.remainingAccounts([
|
|
337
|
+
{
|
|
338
|
+
pubkey: getPolicyEnginePda(args.assetMint),
|
|
339
|
+
isWritable: true,
|
|
340
|
+
isSigner: false,
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
pubkey: identityRegistryProgramId,
|
|
344
|
+
isWritable: false,
|
|
345
|
+
isSigner: false,
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
pubkey: policyEngineProgramId,
|
|
349
|
+
isWritable: false,
|
|
350
|
+
isSigner: false,
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
pubkey: getIdentityRegistryPda(args.assetMint),
|
|
354
|
+
isWritable: false,
|
|
355
|
+
isSigner: false,
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
pubkey: getIdentityAccountPda(args.assetMint, args.to),
|
|
359
|
+
isWritable: false,
|
|
360
|
+
isSigner: false,
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
pubkey: getIdentityAccountPda(args.assetMint, investorPda.toString()),
|
|
364
|
+
isWritable: false,
|
|
365
|
+
isSigner: false,
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
pubkey: getTrackerAccountPda(args.assetMint, args.to),
|
|
369
|
+
isWritable: true,
|
|
370
|
+
isSigner: false,
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
pubkey: getTrackerAccountPda(args.assetMint, investorPda.toString()),
|
|
374
|
+
isWritable: true,
|
|
375
|
+
isSigner: false,
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
pubkey: getExtraMetasListPda(args.assetMint),
|
|
379
|
+
isWritable: false,
|
|
380
|
+
isSigner: false,
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
pubkey: getWalletIdentityAccountPda(args.assetMint, args.to),
|
|
384
|
+
isWritable: false,
|
|
385
|
+
isSigner: false,
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
pubkey: getWalletIdentityAccountPda(args.assetMint, args.from),
|
|
389
|
+
isWritable: false,
|
|
390
|
+
isSigner: false,
|
|
391
|
+
},
|
|
392
|
+
])
|
|
393
|
+
.instruction();
|
|
423
394
|
}
|
|
424
395
|
}
|
|
425
396
|
//# sourceMappingURL=AssetController.js.map
|