@dstoken-solana/rwa-rbac 0.0.1-rc13 → 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 +316 -455
- package/dist/client/AssetController.js.map +1 -1
- package/dist/client/IdentityMetadataRegistry.js +252 -352
- package/dist/client/IdentityMetadataRegistry.js.map +1 -1
- package/dist/client/IdentityRegistry.js +180 -276
- package/dist/client/IdentityRegistry.js.map +1 -1
- package/dist/client/PolicyEngine.js +123 -225
- package/dist/client/PolicyEngine.js.map +1 -1
- package/dist/client/RwaRbacClient.js +124 -226
- package/dist/client/RwaRbacClient.js.map +1 -1
- package/dist/client/TokenLocks.js +211 -279
- package/dist/client/TokenLocks.js.map +1 -1
- package/dist/client/index.js +6 -22
- package/dist/client/index.js.map +1 -1
- package/dist/constants.js +4 -7
- package/dist/constants.js.map +1 -1
- package/dist/index.js +5 -21
- package/dist/index.js.map +1 -1
- package/dist/pdas.js +14 -29
- package/dist/pdas.js.map +1 -1
- package/dist/types/flags.js +4 -7
- package/dist/types/flags.js.map +1 -1
- package/dist/types/generated/index.js +4 -12
- package/dist/types/generated/index.js.map +1 -1
- package/dist/types/generated/rwa_imr.js +1 -2
- package/dist/types/generated/rwa_rbac.js +1 -2
- package/dist/types/generated/token_locks.js +1 -2
- package/dist/types/index.js +3 -19
- package/dist/types/index.js.map +1 -1
- package/dist/types/instructions.js +1 -2
- package/dist/utils.js +2 -10
- package/dist/utils.js.map +1 -1
- package/package.json +3 -2
|
@@ -1,63 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
24
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
-
exports.AssetController = void 0;
|
|
51
|
-
var web3_js_1 = require("@solana/web3.js");
|
|
52
|
-
var spl_token_1 = require("@solana/spl-token");
|
|
53
|
-
var rwa_token_sdk_1 = require("@dstoken-solana/rwa-token-sdk");
|
|
54
|
-
var constants_1 = require("../constants");
|
|
55
|
-
var pdas_1 = require("../pdas");
|
|
1
|
+
import { PublicKey, SystemProgram, } from "@solana/web3.js";
|
|
2
|
+
import { ASSOCIATED_TOKEN_PROGRAM_ID, createAssociatedTokenAccountInstruction, getAssociatedTokenAddressSync, TOKEN_2022_PROGRAM_ID, } from "@solana/spl-token";
|
|
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";
|
|
4
|
+
import { TL_PROGRAM } from "../constants";
|
|
5
|
+
import { deriveInvestorLocks, deriveControllerAuthorityPda, deriveInvestorPda, deriveLockedTokenAccount, } from "../pdas";
|
|
56
6
|
/**
|
|
57
7
|
* Represents the role-based access client for Asset Controller for an RWA.
|
|
58
8
|
*/
|
|
59
|
-
|
|
60
|
-
|
|
9
|
+
export class AssetController {
|
|
10
|
+
rwaClient;
|
|
11
|
+
rbacProgram;
|
|
12
|
+
constructor(rwaClient, rbacProgram) {
|
|
61
13
|
this.rwaClient = rwaClient;
|
|
62
14
|
this.rbacProgram = rbacProgram;
|
|
63
15
|
}
|
|
@@ -66,13 +18,9 @@ var AssetController = /** @class */ (function () {
|
|
|
66
18
|
* @param args - {@link CreateAssetControllerIx}
|
|
67
19
|
* @returns A Promise that resolves to the instructions to create an asset controller.
|
|
68
20
|
*/
|
|
69
|
-
|
|
70
|
-
return
|
|
71
|
-
|
|
72
|
-
return [2 /*return*/, (0, rwa_token_sdk_1.getCreateAssetControllerIx)(args, this.rwaClient.provider)];
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
};
|
|
21
|
+
async setupNewRegistry(args) {
|
|
22
|
+
return getCreateAssetControllerIx(args, this.rwaClient.provider);
|
|
23
|
+
}
|
|
76
24
|
/**
|
|
77
25
|
* Update the asset controller's metadata.
|
|
78
26
|
* @param args - {@link UpdateAssetMetadataArgs}
|
|
@@ -80,167 +28,139 @@ var AssetController = /** @class */ (function () {
|
|
|
80
28
|
* @param authorizedUserRole - Optional UserRole account. Required if user is not an admin.
|
|
81
29
|
* @returns A Promise that resolves to the instructions to update the asset controller's metadata.
|
|
82
30
|
* */
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
tokenProgram: spl_token_1.TOKEN_2022_PROGRAM_ID,
|
|
104
|
-
eventAuthority: (0, rwa_token_sdk_1.getAssetControllerEventAuthority)(),
|
|
105
|
-
systemProgram: web3_js_1.SystemProgram.programId,
|
|
106
|
-
})
|
|
107
|
-
.instruction()];
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
};
|
|
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();
|
|
50
|
+
}
|
|
112
51
|
/**
|
|
113
52
|
* Asynchronously generates instructions to issue tokens and lock tokens according to issuance policy.
|
|
114
53
|
* @param args - {@link IssueTokensWithLockArgs}
|
|
115
54
|
* @param assetAccessController - RBAC AssetAccessController account.
|
|
116
55
|
* @param authorizedUserRole - Optional UserRole account. Required if user is not an admin.
|
|
117
56
|
*/
|
|
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
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
isSigner: false,
|
|
210
|
-
},
|
|
211
|
-
])
|
|
212
|
-
.instruction()];
|
|
213
|
-
case 2:
|
|
214
|
-
_b.apply(_a, [_c.sent()]);
|
|
215
|
-
return [2 /*return*/, ixs];
|
|
216
|
-
}
|
|
217
|
-
});
|
|
218
|
-
});
|
|
219
|
-
};
|
|
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;
|
|
147
|
+
}
|
|
220
148
|
/**
|
|
221
149
|
* Asynchronously generates instructions to revoke assets.
|
|
222
150
|
* @param args - {@link VoidTokensArgs}
|
|
223
151
|
* @returns A Promise that resolves to the instructions to revoke assets.
|
|
224
152
|
*/
|
|
225
|
-
|
|
226
|
-
return
|
|
227
|
-
|
|
228
|
-
return [2 /*return*/, this.rwaClient.assetController.voidTokenIxns(args)];
|
|
229
|
-
});
|
|
230
|
-
});
|
|
231
|
-
};
|
|
153
|
+
async voidTokenIxns(args) {
|
|
154
|
+
return this.rwaClient.assetController.voidTokenIxns(args);
|
|
155
|
+
}
|
|
232
156
|
/**
|
|
233
157
|
* Executes a token transfer.
|
|
234
158
|
* @param args - {@link TransferTokensArgs}
|
|
235
159
|
* @returns A promise that resolves to transaction instruction.
|
|
236
160
|
*/
|
|
237
|
-
|
|
238
|
-
return
|
|
239
|
-
|
|
240
|
-
return [2 /*return*/, this.rwaClient.assetController.transfer(args)];
|
|
241
|
-
});
|
|
242
|
-
});
|
|
243
|
-
};
|
|
161
|
+
async transfer(args) {
|
|
162
|
+
return this.rwaClient.assetController.transfer(args);
|
|
163
|
+
}
|
|
244
164
|
/**
|
|
245
165
|
* Asynchronously generates instruction to freeze a token account.
|
|
246
166
|
* @param args - {@link FreezeTokenArgs}
|
|
@@ -248,34 +168,25 @@ var AssetController = /** @class */ (function () {
|
|
|
248
168
|
* @param authorizedUserRole - Optional UserRole account. Required if user is not an admin.
|
|
249
169
|
* @returns A Promise that resolves to the instruction to freeze.
|
|
250
170
|
*/
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
assetController: (0, rwa_token_sdk_1.getAssetControllerPda)(args.assetMint),
|
|
271
|
-
tokenAccount: tokenAccount,
|
|
272
|
-
tokenProgram: spl_token_1.TOKEN_2022_PROGRAM_ID,
|
|
273
|
-
})
|
|
274
|
-
.instruction()];
|
|
275
|
-
}
|
|
276
|
-
});
|
|
277
|
-
});
|
|
278
|
-
};
|
|
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();
|
|
189
|
+
}
|
|
279
190
|
/**
|
|
280
191
|
* Asynchronously generates instruction to thaw a token account.
|
|
281
192
|
* @param args - {@link FreezeTokenArgs}
|
|
@@ -283,35 +194,26 @@ var AssetController = /** @class */ (function () {
|
|
|
283
194
|
* @param authorizedUserRole - Optional UserRole account. Required if user is not an admin.
|
|
284
195
|
* @returns A Promise that resolves to the instruction to thaw.
|
|
285
196
|
*/
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
identityRegistryAccount: (0, rwa_token_sdk_1.getIdentityRegistryPda)(args.assetMint),
|
|
307
|
-
tokenAccount: tokenAccount,
|
|
308
|
-
tokenProgram: spl_token_1.TOKEN_2022_PROGRAM_ID,
|
|
309
|
-
})
|
|
310
|
-
.instruction()];
|
|
311
|
-
}
|
|
312
|
-
});
|
|
313
|
-
});
|
|
314
|
-
};
|
|
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();
|
|
216
|
+
}
|
|
315
217
|
/**
|
|
316
218
|
* Asynchronously generates instructions to revoke tokens from a user.
|
|
317
219
|
* @param args - {@link RevokeTokensArgs}
|
|
@@ -321,52 +223,41 @@ var AssetController = /** @class */ (function () {
|
|
|
321
223
|
* @param authorizedUserRole - Optional UserRole account. Required if user is not an admin.
|
|
322
224
|
* @returns A Promise that resolves to the instructions to revoke.
|
|
323
225
|
*/
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
walletIdentityAccount: (0, rwa_token_sdk_1.getWalletIdentityAccountPda)(args.assetMint, args.wallet),
|
|
360
|
-
tokenProgram: spl_token_1.TOKEN_2022_PROGRAM_ID,
|
|
361
|
-
associatedTokenProgram: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
362
|
-
systemProgram: web3_js_1.SystemProgram.programId,
|
|
363
|
-
})
|
|
364
|
-
.instruction()];
|
|
365
|
-
case 2: return [2 /*return*/, _a.sent()];
|
|
366
|
-
}
|
|
367
|
-
});
|
|
368
|
-
});
|
|
369
|
-
};
|
|
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();
|
|
260
|
+
}
|
|
370
261
|
/**
|
|
371
262
|
* Asynchronously generates instruction to close mint.
|
|
372
263
|
* @param args - {@link CloseMintArgs}
|
|
@@ -374,32 +265,23 @@ var AssetController = /** @class */ (function () {
|
|
|
374
265
|
* @param authorizedUserRole - Optional UserRole account. Required if user is not an admin.
|
|
375
266
|
* @returns A Promise that resolves to the instruction to close mint.
|
|
376
267
|
*/
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
assetMint: args.assetMint,
|
|
395
|
-
assetController: (0, rwa_token_sdk_1.getAssetControllerPda)(args.assetMint),
|
|
396
|
-
tokenProgram: spl_token_1.TOKEN_2022_PROGRAM_ID,
|
|
397
|
-
})
|
|
398
|
-
.instruction()];
|
|
399
|
-
}
|
|
400
|
-
});
|
|
401
|
-
});
|
|
402
|
-
};
|
|
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();
|
|
284
|
+
}
|
|
403
285
|
/**
|
|
404
286
|
* Asynchronously generates instruction to update mint interest rate.
|
|
405
287
|
* @param args - {@link UpdateInterestBearingMintRateArgs}
|
|
@@ -407,33 +289,24 @@ var AssetController = /** @class */ (function () {
|
|
|
407
289
|
* @param authorizedUserRole - Optional UserRole account. Required if user is not an admin.
|
|
408
290
|
* @returns A Promise that resolves to the instruction to update mint interest rate.
|
|
409
291
|
*/
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
assetController: (0, rwa_token_sdk_1.getAssetControllerPda)(args.assetMint),
|
|
429
|
-
eventAuthority: (0, rwa_token_sdk_1.getAssetControllerEventAuthority)(),
|
|
430
|
-
tokenProgram: spl_token_1.TOKEN_2022_PROGRAM_ID,
|
|
431
|
-
})
|
|
432
|
-
.instruction()];
|
|
433
|
-
}
|
|
434
|
-
});
|
|
435
|
-
});
|
|
436
|
-
};
|
|
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();
|
|
309
|
+
}
|
|
437
310
|
/**
|
|
438
311
|
* Asynchronously generates instruction to seize tokens.
|
|
439
312
|
* @param args - {@link SeizeTokensArgs}
|
|
@@ -442,94 +315,82 @@ var AssetController = /** @class */ (function () {
|
|
|
442
315
|
* @param authorizedUserRole - Optional UserRole account. Required if user is not an admin.
|
|
443
316
|
* @returns A Promise that resolves to the instruction to seize.
|
|
444
317
|
*/
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
isWritable: false,
|
|
524
|
-
isSigner: false,
|
|
525
|
-
},
|
|
526
|
-
])
|
|
527
|
-
.instruction()];
|
|
528
|
-
}
|
|
529
|
-
});
|
|
530
|
-
});
|
|
531
|
-
};
|
|
532
|
-
return AssetController;
|
|
533
|
-
}());
|
|
534
|
-
exports.AssetController = AssetController;
|
|
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();
|
|
394
|
+
}
|
|
395
|
+
}
|
|
535
396
|
//# sourceMappingURL=AssetController.js.map
|