@dstoken-solana/rwa-rbac 0.1.3 → 0.2.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.
package/dist/index.es.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { PublicKey, SystemProgram } from '@solana/web3.js';
2
- import { Program, BN } from '@coral-xyz/anchor';
3
- import { TOKEN_2022_PROGRAM_ID, getAssociatedTokenAddressSync, ASSOCIATED_TOKEN_PROGRAM_ID, getAccount } from '@solana/spl-token';
4
- import { getCreateAssetControllerIx, getAssetControllerPda, assetControllerProgramId, getAssetControllerEventAuthority, getIdentityRegistryPda, getIssueTokensIx, getTrackerAccountPda, getPolicyEnginePda, policyEngineProgramId, getIdentityAccountPda, getWalletIdentityAccountPda, getFreezeTokenIx, getThawTokenIx, getRevokeTokensIx, getCloseMintIx, getUpdateInterestBearingMintRateIx, getSeizeTokensIx, identityRegistryProgramId, getExtraMetasListPda, getPolicyEngineEventAuthority, getRemoveLevelFromIdentityAccount, getIdentityRegistryProgram, getPolicyEngineProgram, RwaClient } from '@dstoken-solana/rwa-token-sdk';
2
+ import { utils, Program, BN } from '@coral-xyz/anchor';
3
+ import { TOKEN_2022_PROGRAM_ID, getAssociatedTokenAddressSync, ASSOCIATED_TOKEN_PROGRAM_ID } from '@solana/spl-token';
4
+ import { getCreateAssetControllerIx, getAssetControllerPda, assetControllerProgramId, getAssetControllerEventAuthority, getIdentityRegistryPda, getIssueTokensIx, getTrackerAccountPda, getPolicyEnginePda, policyEngineProgramId, getIdentityAccountPda, getWalletIdentityAccountPda, getFreezeTokenIx, getThawTokenIx, getRevokeTokensIx, getCloseMintIx, getUpdateInterestBearingMintRateIx, getSeizeTokensIx, identityRegistryProgramId, getExtraMetasListPda, getPolicyEngineEventAuthority, getIdentityRegistryEventAuthority, getIdentityAccount, getRemoveLevelFromIdentityAccount, getIdentityRegistryProgram, getPolicyEngineProgram, RwaClient } from '@dstoken-solana/rwa-token-sdk';
5
5
 
6
6
  const IMR_PROGRAM = new PublicKey("D2V7wTBbNCKgYwirgRUnSmc2QyKnHSVmRotWJ4rz8Jp9");
7
7
  const RBAC_PROGRAM = new PublicKey("3g6fUgMsJQhjPUYxNjEU5PyzGf8DerbDx8p5Qh4yMnRR");
@@ -41,15 +41,16 @@ const deriveUserRolePda = (id, assetAccessController, programId = RBAC_PROGRAM)
41
41
  Buffer.from("UserRole"),
42
42
  ], programId)[0];
43
43
  };
44
+ const getEventAuthority = (programId) => PublicKey.findProgramAddressSync([Buffer.from("__event_authority")], programId)[0];
44
45
 
45
- var address$2 = "3g6fUgMsJQhjPUYxNjEU5PyzGf8DerbDx8p5Qh4yMnRR";
46
- var metadata$2 = {
46
+ var address$1 = "3g6fUgMsJQhjPUYxNjEU5PyzGf8DerbDx8p5Qh4yMnRR";
47
+ var metadata$1 = {
47
48
  name: "rwa_rbac",
48
49
  version: "0.1.0",
49
50
  spec: "0.1.0",
50
51
  description: "Created with Anchor"
51
52
  };
52
- var instructions$2 = [
53
+ var instructions$1 = [
53
54
  {
54
55
  name: "add_level_to_identity_account",
55
56
  discriminator: [
@@ -122,6 +123,9 @@ var instructions$2 = [
122
123
  },
123
124
  {
124
125
  name: "asset_mint"
126
+ },
127
+ {
128
+ name: "event_authority"
125
129
  }
126
130
  ],
127
131
  args: [
@@ -212,6 +216,12 @@ var instructions$2 = [
212
216
  },
213
217
  {
214
218
  name: "asset_mint"
219
+ },
220
+ {
221
+ name: "event_authority_identity_metadata_registry"
222
+ },
223
+ {
224
+ name: "event_authority_identity_registry"
215
225
  }
216
226
  ],
217
227
  args: [
@@ -295,101 +305,6 @@ var instructions$2 = [
295
305
  }
296
306
  ]
297
307
  },
298
- {
299
- name: "add_token_lock",
300
- discriminator: [
301
- 195,
302
- 26,
303
- 109,
304
- 80,
305
- 46,
306
- 7,
307
- 195,
308
- 55
309
- ],
310
- accounts: [
311
- {
312
- name: "payer",
313
- writable: true,
314
- signer: true
315
- },
316
- {
317
- name: "user",
318
- signer: true
319
- },
320
- {
321
- name: "controller_authority",
322
- writable: true,
323
- relations: [
324
- "asset_access_controller"
325
- ]
326
- },
327
- {
328
- name: "asset_access_controller",
329
- relations: [
330
- "authorized_user_role"
331
- ]
332
- },
333
- {
334
- name: "authorized_user_role",
335
- optional: true
336
- },
337
- {
338
- name: "token_locks_program",
339
- address: "9bNt3ZiZpDdHqAt5Q1Wq6twFe5RKmMCwA7MJyK2HgGnU"
340
- },
341
- {
342
- name: "investor_locks",
343
- writable: true
344
- },
345
- {
346
- name: "investor"
347
- },
348
- {
349
- name: "wallet_identity_account"
350
- },
351
- {
352
- name: "identity_account"
353
- },
354
- {
355
- name: "asset_mint",
356
- writable: true
357
- },
358
- {
359
- name: "unlocked_token_account",
360
- writable: true
361
- },
362
- {
363
- name: "locked_token_account",
364
- writable: true
365
- },
366
- {
367
- name: "asset_controller"
368
- },
369
- {
370
- name: "identity_registry",
371
- writable: true
372
- },
373
- {
374
- name: "asset_controller_program",
375
- address: "7tXjmbkZVY3Gmg9kDBebcNXT1yC5pyoxxXVLwdbv9tvP"
376
- },
377
- {
378
- name: "token_program",
379
- address: "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
380
- },
381
- {
382
- name: "system_program",
383
- address: "11111111111111111111111111111111"
384
- }
385
- ],
386
- args: [
387
- {
388
- name: "cpi_data",
389
- type: "bytes"
390
- }
391
- ]
392
- },
393
308
  {
394
309
  name: "assign_user_role",
395
310
  discriminator: [
@@ -430,6 +345,38 @@ var instructions$2 = [
430
345
  {
431
346
  name: "system_program",
432
347
  address: "11111111111111111111111111111111"
348
+ },
349
+ {
350
+ name: "event_authority",
351
+ pda: {
352
+ seeds: [
353
+ {
354
+ kind: "const",
355
+ value: [
356
+ 95,
357
+ 95,
358
+ 101,
359
+ 118,
360
+ 101,
361
+ 110,
362
+ 116,
363
+ 95,
364
+ 97,
365
+ 117,
366
+ 116,
367
+ 104,
368
+ 111,
369
+ 114,
370
+ 105,
371
+ 116,
372
+ 121
373
+ ]
374
+ }
375
+ ]
376
+ }
377
+ },
378
+ {
379
+ name: "program"
433
380
  }
434
381
  ],
435
382
  args: [
@@ -490,6 +437,9 @@ var instructions$2 = [
490
437
  {
491
438
  name: "system_program",
492
439
  address: "11111111111111111111111111111111"
440
+ },
441
+ {
442
+ name: "event_authority"
493
443
  }
494
444
  ],
495
445
  args: [
@@ -558,6 +508,9 @@ var instructions$2 = [
558
508
  {
559
509
  name: "system_program",
560
510
  address: "11111111111111111111111111111111"
511
+ },
512
+ {
513
+ name: "event_authority"
561
514
  }
562
515
  ],
563
516
  args: [
@@ -616,6 +569,9 @@ var instructions$2 = [
616
569
  {
617
570
  name: "system_program",
618
571
  address: "11111111111111111111111111111111"
572
+ },
573
+ {
574
+ name: "event_authority"
619
575
  }
620
576
  ],
621
577
  args: [
@@ -674,6 +630,9 @@ var instructions$2 = [
674
630
  {
675
631
  name: "system_program",
676
632
  address: "11111111111111111111111111111111"
633
+ },
634
+ {
635
+ name: "event_authority"
677
636
  }
678
637
  ],
679
638
  args: [
@@ -752,6 +711,9 @@ var instructions$2 = [
752
711
  },
753
712
  {
754
713
  name: "asset_mint"
714
+ },
715
+ {
716
+ name: "event_authority_identity_registry"
755
717
  }
756
718
  ],
757
719
  args: [
@@ -806,6 +768,9 @@ var instructions$2 = [
806
768
  {
807
769
  name: "policy_engine",
808
770
  writable: true
771
+ },
772
+ {
773
+ name: "event_authority"
809
774
  }
810
775
  ],
811
776
  args: [
@@ -860,6 +825,9 @@ var instructions$2 = [
860
825
  {
861
826
  name: "policy_engine",
862
827
  writable: true
828
+ },
829
+ {
830
+ name: "event_authority"
863
831
  }
864
832
  ],
865
833
  args: [
@@ -869,70 +837,6 @@ var instructions$2 = [
869
837
  }
870
838
  ]
871
839
  },
872
- {
873
- name: "close_investor_locks",
874
- discriminator: [
875
- 255,
876
- 60,
877
- 220,
878
- 115,
879
- 217,
880
- 104,
881
- 157,
882
- 171
883
- ],
884
- accounts: [
885
- {
886
- name: "payer",
887
- writable: true,
888
- signer: true
889
- },
890
- {
891
- name: "user",
892
- signer: true
893
- },
894
- {
895
- name: "controller_authority",
896
- relations: [
897
- "asset_access_controller"
898
- ]
899
- },
900
- {
901
- name: "asset_access_controller",
902
- relations: [
903
- "authorized_user_role"
904
- ]
905
- },
906
- {
907
- name: "authorized_user_role",
908
- optional: true
909
- },
910
- {
911
- name: "token_locks_program",
912
- address: "9bNt3ZiZpDdHqAt5Q1Wq6twFe5RKmMCwA7MJyK2HgGnU"
913
- },
914
- {
915
- name: "investor_locks",
916
- writable: true
917
- },
918
- {
919
- name: "investor"
920
- },
921
- {
922
- name: "locked_token_account",
923
- writable: true
924
- },
925
- {
926
- name: "token_program"
927
- },
928
- {
929
- name: "system_program",
930
- address: "11111111111111111111111111111111"
931
- }
932
- ],
933
- args: [
934
- ]
935
- },
936
840
  {
937
841
  name: "close_mint_account",
938
842
  discriminator: [
@@ -1118,6 +1022,9 @@ var instructions$2 = [
1118
1022
  {
1119
1023
  name: "system_program",
1120
1024
  address: "11111111111111111111111111111111"
1025
+ },
1026
+ {
1027
+ name: "event_authority"
1121
1028
  }
1122
1029
  ],
1123
1030
  args: [
@@ -1128,16 +1035,16 @@ var instructions$2 = [
1128
1035
  ]
1129
1036
  },
1130
1037
  {
1131
- name: "create_investor_locks",
1038
+ name: "create_user_role",
1132
1039
  discriminator: [
1133
- 223,
1134
- 81,
1135
- 139,
1136
- 162,
1137
- 204,
1138
- 48,
1139
- 24,
1140
- 213
1040
+ 13,
1041
+ 20,
1042
+ 224,
1043
+ 42,
1044
+ 3,
1045
+ 120,
1046
+ 67,
1047
+ 23
1141
1048
  ],
1142
1049
  accounts: [
1143
1050
  {
@@ -1150,13 +1057,12 @@ var instructions$2 = [
1150
1057
  signer: true
1151
1058
  },
1152
1059
  {
1153
- name: "controller_authority",
1154
- relations: [
1155
- "asset_access_controller"
1156
- ]
1060
+ name: "new_user_role",
1061
+ writable: true
1157
1062
  },
1158
1063
  {
1159
1064
  name: "asset_access_controller",
1065
+ writable: true,
1160
1066
  relations: [
1161
1067
  "authorized_user_role"
1162
1068
  ]
@@ -1166,123 +1072,45 @@ var instructions$2 = [
1166
1072
  optional: true
1167
1073
  },
1168
1074
  {
1169
- name: "token_locks_program",
1170
- address: "9bNt3ZiZpDdHqAt5Q1Wq6twFe5RKmMCwA7MJyK2HgGnU"
1171
- },
1075
+ name: "system_program",
1076
+ address: "11111111111111111111111111111111"
1077
+ }
1078
+ ],
1079
+ args: [
1172
1080
  {
1173
- name: "investor_locks",
1174
- writable: true
1081
+ name: "name",
1082
+ type: "string"
1175
1083
  },
1176
1084
  {
1177
- name: "investor"
1085
+ name: "allowed_admin_ixs",
1086
+ type: "u64"
1178
1087
  },
1179
1088
  {
1180
- name: "identity_account"
1181
- },
1089
+ name: "allowed_medici_ixs",
1090
+ type: "u64"
1091
+ }
1092
+ ]
1093
+ },
1094
+ {
1095
+ name: "delete_user_role",
1096
+ discriminator: [
1097
+ 177,
1098
+ 139,
1099
+ 27,
1100
+ 46,
1101
+ 113,
1102
+ 250,
1103
+ 139,
1104
+ 225
1105
+ ],
1106
+ accounts: [
1182
1107
  {
1183
- name: "asset_mint",
1108
+ name: "receiver",
1184
1109
  writable: true
1185
1110
  },
1186
1111
  {
1187
- name: "locked_token_account",
1188
- writable: true
1189
- },
1190
- {
1191
- name: "asset_controller"
1192
- },
1193
- {
1194
- name: "asset_controller_program",
1195
- address: "7tXjmbkZVY3Gmg9kDBebcNXT1yC5pyoxxXVLwdbv9tvP"
1196
- },
1197
- {
1198
- name: "token_program",
1199
- address: "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
1200
- },
1201
- {
1202
- name: "system_program",
1203
- address: "11111111111111111111111111111111"
1204
- }
1205
- ],
1206
- args: [
1207
- ]
1208
- },
1209
- {
1210
- name: "create_user_role",
1211
- discriminator: [
1212
- 13,
1213
- 20,
1214
- 224,
1215
- 42,
1216
- 3,
1217
- 120,
1218
- 67,
1219
- 23
1220
- ],
1221
- accounts: [
1222
- {
1223
- name: "payer",
1224
- writable: true,
1225
- signer: true
1226
- },
1227
- {
1228
- name: "user",
1229
- signer: true
1230
- },
1231
- {
1232
- name: "new_user_role",
1233
- writable: true
1234
- },
1235
- {
1236
- name: "asset_access_controller",
1237
- writable: true,
1238
- relations: [
1239
- "authorized_user_role"
1240
- ]
1241
- },
1242
- {
1243
- name: "authorized_user_role",
1244
- optional: true
1245
- },
1246
- {
1247
- name: "system_program",
1248
- address: "11111111111111111111111111111111"
1249
- }
1250
- ],
1251
- args: [
1252
- {
1253
- name: "name",
1254
- type: "string"
1255
- },
1256
- {
1257
- name: "allowed_admin_ixs",
1258
- type: "u64"
1259
- },
1260
- {
1261
- name: "allowed_medici_ixs",
1262
- type: "u64"
1263
- }
1264
- ]
1265
- },
1266
- {
1267
- name: "delete_user_role",
1268
- discriminator: [
1269
- 177,
1270
- 139,
1271
- 27,
1272
- 46,
1273
- 113,
1274
- 250,
1275
- 139,
1276
- 225
1277
- ],
1278
- accounts: [
1279
- {
1280
- name: "receiver",
1281
- writable: true
1282
- },
1283
- {
1284
- name: "user",
1285
- signer: true
1112
+ name: "user",
1113
+ signer: true
1286
1114
  },
1287
1115
  {
1288
1116
  name: "asset_access_controller",
@@ -1352,6 +1180,9 @@ var instructions$2 = [
1352
1180
  {
1353
1181
  name: "system_program",
1354
1182
  address: "11111111111111111111111111111111"
1183
+ },
1184
+ {
1185
+ name: "event_authority"
1355
1186
  }
1356
1187
  ],
1357
1188
  args: [
@@ -1414,6 +1245,9 @@ var instructions$2 = [
1414
1245
  },
1415
1246
  {
1416
1247
  name: "identity_registry"
1248
+ },
1249
+ {
1250
+ name: "event_authority"
1417
1251
  }
1418
1252
  ],
1419
1253
  args: [
@@ -1573,6 +1407,9 @@ var instructions$2 = [
1573
1407
  },
1574
1408
  {
1575
1409
  name: "wallet_identity_account"
1410
+ },
1411
+ {
1412
+ name: "event_authority"
1576
1413
  }
1577
1414
  ],
1578
1415
  args: [
@@ -1748,6 +1585,12 @@ var instructions$2 = [
1748
1585
  name: "wallet_identity",
1749
1586
  writable: true
1750
1587
  },
1588
+ {
1589
+ name: "event_authority_identity_metadata_registry"
1590
+ },
1591
+ {
1592
+ name: "event_authority_identity_registry"
1593
+ },
1751
1594
  {
1752
1595
  name: "system_program",
1753
1596
  address: "11111111111111111111111111111111"
@@ -1760,6 +1603,73 @@ var instructions$2 = [
1760
1603
  }
1761
1604
  ]
1762
1605
  },
1606
+ {
1607
+ name: "remove_identity_account",
1608
+ discriminator: [
1609
+ 78,
1610
+ 35,
1611
+ 174,
1612
+ 50,
1613
+ 72,
1614
+ 181,
1615
+ 12,
1616
+ 42
1617
+ ],
1618
+ accounts: [
1619
+ {
1620
+ name: "payer",
1621
+ writable: true,
1622
+ signer: true
1623
+ },
1624
+ {
1625
+ name: "user",
1626
+ signer: true
1627
+ },
1628
+ {
1629
+ name: "controller_authority",
1630
+ relations: [
1631
+ "asset_access_controller"
1632
+ ]
1633
+ },
1634
+ {
1635
+ name: "asset_access_controller",
1636
+ relations: [
1637
+ "authorized_user_role"
1638
+ ]
1639
+ },
1640
+ {
1641
+ name: "authorized_user_role",
1642
+ optional: true
1643
+ },
1644
+ {
1645
+ name: "identity_registry_program",
1646
+ address: "GZsnjqT3c5zbHqsctrJ4EG4rbEfo7ZXyyUG7aDJNmxfA"
1647
+ },
1648
+ {
1649
+ name: "identity_registry"
1650
+ },
1651
+ {
1652
+ name: "identity_account",
1653
+ writable: true
1654
+ },
1655
+ {
1656
+ name: "wallet_identity",
1657
+ writable: true
1658
+ },
1659
+ {
1660
+ name: "event_authority"
1661
+ },
1662
+ {
1663
+ name: "identity_owner"
1664
+ }
1665
+ ],
1666
+ args: [
1667
+ {
1668
+ name: "cpi_data",
1669
+ type: "bytes"
1670
+ }
1671
+ ]
1672
+ },
1763
1673
  {
1764
1674
  name: "remove_investor",
1765
1675
  discriminator: [
@@ -1828,6 +1738,12 @@ var instructions$2 = [
1828
1738
  {
1829
1739
  name: "tracker_account",
1830
1740
  writable: true
1741
+ },
1742
+ {
1743
+ name: "event_authority_identity_metadata_registry"
1744
+ },
1745
+ {
1746
+ name: "event_authority_identity_registry"
1831
1747
  }
1832
1748
  ],
1833
1749
  args: [
@@ -1905,6 +1821,9 @@ var instructions$2 = [
1905
1821
  },
1906
1822
  {
1907
1823
  name: "asset_mint"
1824
+ },
1825
+ {
1826
+ name: "event_authority"
1908
1827
  }
1909
1828
  ],
1910
1829
  args: [
@@ -1987,6 +1906,9 @@ var instructions$2 = [
1987
1906
  },
1988
1907
  {
1989
1908
  name: "asset_mint"
1909
+ },
1910
+ {
1911
+ name: "event_authority_identity_registry"
1990
1912
  }
1991
1913
  ],
1992
1914
  args: [
@@ -2070,92 +1992,6 @@ var instructions$2 = [
2070
1992
  }
2071
1993
  ]
2072
1994
  },
2073
- {
2074
- name: "remove_token_lock",
2075
- discriminator: [
2076
- 168,
2077
- 128,
2078
- 173,
2079
- 188,
2080
- 172,
2081
- 228,
2082
- 154,
2083
- 90
2084
- ],
2085
- accounts: [
2086
- {
2087
- name: "user",
2088
- signer: true
2089
- },
2090
- {
2091
- name: "controller_authority",
2092
- writable: true,
2093
- relations: [
2094
- "asset_access_controller"
2095
- ]
2096
- },
2097
- {
2098
- name: "asset_access_controller",
2099
- relations: [
2100
- "authorized_user_role"
2101
- ]
2102
- },
2103
- {
2104
- name: "authorized_user_role",
2105
- optional: true
2106
- },
2107
- {
2108
- name: "token_locks_program",
2109
- address: "9bNt3ZiZpDdHqAt5Q1Wq6twFe5RKmMCwA7MJyK2HgGnU"
2110
- },
2111
- {
2112
- name: "investor_locks",
2113
- writable: true
2114
- },
2115
- {
2116
- name: "investor"
2117
- },
2118
- {
2119
- name: "wallet_identity_account"
2120
- },
2121
- {
2122
- name: "identity_account"
2123
- },
2124
- {
2125
- name: "asset_mint",
2126
- writable: true
2127
- },
2128
- {
2129
- name: "unlocked_token_account",
2130
- writable: true
2131
- },
2132
- {
2133
- name: "locked_token_account",
2134
- writable: true
2135
- },
2136
- {
2137
- name: "asset_controller"
2138
- },
2139
- {
2140
- name: "identity_registry",
2141
- writable: true
2142
- },
2143
- {
2144
- name: "asset_controller_program",
2145
- address: "7tXjmbkZVY3Gmg9kDBebcNXT1yC5pyoxxXVLwdbv9tvP"
2146
- },
2147
- {
2148
- name: "token_program",
2149
- address: "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
2150
- }
2151
- ],
2152
- args: [
2153
- {
2154
- name: "indices",
2155
- type: "bytes"
2156
- }
2157
- ]
2158
- },
2159
1995
  {
2160
1996
  name: "remove_user_role",
2161
1997
  discriminator: [
@@ -2187,6 +2023,38 @@ var instructions$2 = [
2187
2023
  {
2188
2024
  name: "authorized_user_role",
2189
2025
  optional: true
2026
+ },
2027
+ {
2028
+ name: "event_authority",
2029
+ pda: {
2030
+ seeds: [
2031
+ {
2032
+ kind: "const",
2033
+ value: [
2034
+ 95,
2035
+ 95,
2036
+ 101,
2037
+ 118,
2038
+ 101,
2039
+ 110,
2040
+ 116,
2041
+ 95,
2042
+ 97,
2043
+ 117,
2044
+ 116,
2045
+ 104,
2046
+ 111,
2047
+ 114,
2048
+ 105,
2049
+ 116,
2050
+ 121
2051
+ ]
2052
+ }
2053
+ ]
2054
+ }
2055
+ },
2056
+ {
2057
+ name: "program"
2190
2058
  }
2191
2059
  ],
2192
2060
  args: [
@@ -2278,6 +2146,9 @@ var instructions$2 = [
2278
2146
  {
2279
2147
  name: "system_program",
2280
2148
  address: "11111111111111111111111111111111"
2149
+ },
2150
+ {
2151
+ name: "event_authority"
2281
2152
  }
2282
2153
  ],
2283
2154
  args: [
@@ -2342,6 +2213,9 @@ var instructions$2 = [
2342
2213
  {
2343
2214
  name: "token_program",
2344
2215
  address: "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
2216
+ },
2217
+ {
2218
+ name: "event_authority"
2345
2219
  }
2346
2220
  ],
2347
2221
  args: [
@@ -2396,6 +2270,9 @@ var instructions$2 = [
2396
2270
  {
2397
2271
  name: "policy_engine",
2398
2272
  writable: true
2273
+ },
2274
+ {
2275
+ name: "event_authority"
2399
2276
  }
2400
2277
  ],
2401
2278
  args: [
@@ -2672,7 +2549,7 @@ var instructions$2 = [
2672
2549
  ]
2673
2550
  }
2674
2551
  ];
2675
- var accounts$2 = [
2552
+ var accounts$1 = [
2676
2553
  {
2677
2554
  name: "AssetAccessController",
2678
2555
  discriminator: [
@@ -2700,7 +2577,35 @@ var accounts$2 = [
2700
2577
  ]
2701
2578
  }
2702
2579
  ];
2703
- var errors$2 = [
2580
+ var events$1 = [
2581
+ {
2582
+ name: "AssignUserRoleEvent",
2583
+ discriminator: [
2584
+ 66,
2585
+ 20,
2586
+ 203,
2587
+ 47,
2588
+ 242,
2589
+ 72,
2590
+ 213,
2591
+ 93
2592
+ ]
2593
+ },
2594
+ {
2595
+ name: "RemoveUserRoleEvent",
2596
+ discriminator: [
2597
+ 213,
2598
+ 162,
2599
+ 73,
2600
+ 7,
2601
+ 11,
2602
+ 89,
2603
+ 226,
2604
+ 140
2605
+ ]
2606
+ }
2607
+ ];
2608
+ var errors$1 = [
2704
2609
  {
2705
2610
  code: 6000,
2706
2611
  name: "UnknownInstruction",
@@ -2735,9 +2640,14 @@ var errors$2 = [
2735
2640
  code: 6006,
2736
2641
  name: "InvalidLevel",
2737
2642
  msg: "Invalid level"
2643
+ },
2644
+ {
2645
+ code: 6007,
2646
+ name: "IllegalOperation",
2647
+ msg: "Illegal operation"
2738
2648
  }
2739
2649
  ];
2740
- var types$2 = [
2650
+ var types$1 = [
2741
2651
  {
2742
2652
  name: "AssetAccessController",
2743
2653
  type: {
@@ -2781,6 +2691,66 @@ var types$2 = [
2781
2691
  ]
2782
2692
  }
2783
2693
  },
2694
+ {
2695
+ name: "AssignUserRoleEvent",
2696
+ type: {
2697
+ kind: "struct",
2698
+ fields: [
2699
+ {
2700
+ name: "addresses",
2701
+ type: {
2702
+ vec: "pubkey"
2703
+ }
2704
+ },
2705
+ {
2706
+ name: "role",
2707
+ type: "string"
2708
+ },
2709
+ {
2710
+ name: "role_id",
2711
+ type: "u64"
2712
+ },
2713
+ {
2714
+ name: "sender",
2715
+ type: "pubkey"
2716
+ },
2717
+ {
2718
+ name: "seed",
2719
+ type: "pubkey"
2720
+ }
2721
+ ]
2722
+ }
2723
+ },
2724
+ {
2725
+ name: "RemoveUserRoleEvent",
2726
+ type: {
2727
+ kind: "struct",
2728
+ fields: [
2729
+ {
2730
+ name: "addresses",
2731
+ type: {
2732
+ vec: "pubkey"
2733
+ }
2734
+ },
2735
+ {
2736
+ name: "role",
2737
+ type: "string"
2738
+ },
2739
+ {
2740
+ name: "role_id",
2741
+ type: "u64"
2742
+ },
2743
+ {
2744
+ name: "sender",
2745
+ type: "pubkey"
2746
+ },
2747
+ {
2748
+ name: "seed",
2749
+ type: "pubkey"
2750
+ }
2751
+ ]
2752
+ }
2753
+ },
2784
2754
  {
2785
2755
  name: "UserRole",
2786
2756
  type: {
@@ -2835,33 +2805,35 @@ var types$2 = [
2835
2805
  }
2836
2806
  ];
2837
2807
  var rwa_rbac = {
2838
- address: address$2,
2839
- metadata: metadata$2,
2840
- instructions: instructions$2,
2841
- accounts: accounts$2,
2842
- errors: errors$2,
2843
- types: types$2
2808
+ address: address$1,
2809
+ metadata: metadata$1,
2810
+ instructions: instructions$1,
2811
+ accounts: accounts$1,
2812
+ events: events$1,
2813
+ errors: errors$1,
2814
+ types: types$1
2844
2815
  };
2845
2816
 
2846
2817
  var rbacIDL = /*#__PURE__*/Object.freeze({
2847
2818
  __proto__: null,
2848
- address: address$2,
2849
- metadata: metadata$2,
2850
- instructions: instructions$2,
2851
- accounts: accounts$2,
2852
- errors: errors$2,
2853
- types: types$2,
2819
+ address: address$1,
2820
+ metadata: metadata$1,
2821
+ instructions: instructions$1,
2822
+ accounts: accounts$1,
2823
+ events: events$1,
2824
+ errors: errors$1,
2825
+ types: types$1,
2854
2826
  'default': rwa_rbac
2855
2827
  });
2856
2828
 
2857
- var address$1 = "D2V7wTBbNCKgYwirgRUnSmc2QyKnHSVmRotWJ4rz8Jp9";
2858
- var metadata$1 = {
2829
+ var address = "D2V7wTBbNCKgYwirgRUnSmc2QyKnHSVmRotWJ4rz8Jp9";
2830
+ var metadata = {
2859
2831
  name: "rwa_imr",
2860
2832
  version: "0.1.0",
2861
2833
  spec: "0.1.0",
2862
2834
  description: "Created with Anchor"
2863
2835
  };
2864
- var instructions$1 = [
2836
+ var instructions = [
2865
2837
  {
2866
2838
  name: "add_levels",
2867
2839
  discriminator: [
@@ -2918,6 +2890,41 @@ var instructions$1 = [
2918
2890
  },
2919
2891
  {
2920
2892
  name: "asset_mint"
2893
+ },
2894
+ {
2895
+ name: "event_authority_identity_registry"
2896
+ },
2897
+ {
2898
+ name: "event_authority",
2899
+ pda: {
2900
+ seeds: [
2901
+ {
2902
+ kind: "const",
2903
+ value: [
2904
+ 95,
2905
+ 95,
2906
+ 101,
2907
+ 118,
2908
+ 101,
2909
+ 110,
2910
+ 116,
2911
+ 95,
2912
+ 97,
2913
+ 117,
2914
+ 116,
2915
+ 104,
2916
+ 111,
2917
+ 114,
2918
+ 105,
2919
+ 116,
2920
+ 121
2921
+ ]
2922
+ }
2923
+ ]
2924
+ }
2925
+ },
2926
+ {
2927
+ name: "program"
2921
2928
  }
2922
2929
  ],
2923
2930
  args: [
@@ -2998,6 +3005,9 @@ var instructions$1 = [
2998
3005
  {
2999
3006
  name: "system_program",
3000
3007
  address: "11111111111111111111111111111111"
3008
+ },
3009
+ {
3010
+ name: "event_authority_identity_registry"
3001
3011
  }
3002
3012
  ],
3003
3013
  args: [
@@ -3059,6 +3069,9 @@ var instructions$1 = [
3059
3069
  },
3060
3070
  {
3061
3071
  name: "asset_mint"
3072
+ },
3073
+ {
3074
+ name: "event_authority_identity_registry"
3062
3075
  }
3063
3076
  ],
3064
3077
  args: [
@@ -3144,6 +3157,41 @@ var instructions$1 = [
3144
3157
  {
3145
3158
  name: "system_program",
3146
3159
  address: "11111111111111111111111111111111"
3160
+ },
3161
+ {
3162
+ name: "event_authority_identity_registry"
3163
+ },
3164
+ {
3165
+ name: "event_authority",
3166
+ pda: {
3167
+ seeds: [
3168
+ {
3169
+ kind: "const",
3170
+ value: [
3171
+ 95,
3172
+ 95,
3173
+ 101,
3174
+ 118,
3175
+ 101,
3176
+ 110,
3177
+ 116,
3178
+ 95,
3179
+ 97,
3180
+ 117,
3181
+ 116,
3182
+ 104,
3183
+ 111,
3184
+ 114,
3185
+ 105,
3186
+ 116,
3187
+ 121
3188
+ ]
3189
+ }
3190
+ ]
3191
+ }
3192
+ },
3193
+ {
3194
+ name: "program"
3147
3195
  }
3148
3196
  ],
3149
3197
  args: [
@@ -3224,6 +3272,41 @@ var instructions$1 = [
3224
3272
  {
3225
3273
  name: "tracker_account",
3226
3274
  writable: true
3275
+ },
3276
+ {
3277
+ name: "event_authority_identity_registry"
3278
+ },
3279
+ {
3280
+ name: "event_authority",
3281
+ pda: {
3282
+ seeds: [
3283
+ {
3284
+ kind: "const",
3285
+ value: [
3286
+ 95,
3287
+ 95,
3288
+ 101,
3289
+ 118,
3290
+ 101,
3291
+ 110,
3292
+ 116,
3293
+ 95,
3294
+ 97,
3295
+ 117,
3296
+ 116,
3297
+ 104,
3298
+ 111,
3299
+ 114,
3300
+ 105,
3301
+ 116,
3302
+ 121
3303
+ ]
3304
+ }
3305
+ ]
3306
+ }
3307
+ },
3308
+ {
3309
+ name: "program"
3227
3310
  }
3228
3311
  ],
3229
3312
  args: [
@@ -3285,6 +3368,9 @@ var instructions$1 = [
3285
3368
  },
3286
3369
  {
3287
3370
  name: "asset_mint"
3371
+ },
3372
+ {
3373
+ name: "event_authority_identity_registry"
3288
3374
  }
3289
3375
  ],
3290
3376
  args: [
@@ -3299,7 +3385,7 @@ var instructions$1 = [
3299
3385
  ]
3300
3386
  }
3301
3387
  ];
3302
- var accounts$1 = [
3388
+ var accounts = [
3303
3389
  {
3304
3390
  name: "Investor",
3305
3391
  discriminator: [
@@ -3314,7 +3400,61 @@ var accounts$1 = [
3314
3400
  ]
3315
3401
  }
3316
3402
  ];
3317
- var errors$1 = [
3403
+ var events = [
3404
+ {
3405
+ name: "AddLevelsEvent",
3406
+ discriminator: [
3407
+ 90,
3408
+ 156,
3409
+ 44,
3410
+ 28,
3411
+ 242,
3412
+ 1,
3413
+ 130,
3414
+ 61
3415
+ ]
3416
+ },
3417
+ {
3418
+ name: "RegisterInvestorEvent",
3419
+ discriminator: [
3420
+ 137,
3421
+ 181,
3422
+ 142,
3423
+ 164,
3424
+ 140,
3425
+ 196,
3426
+ 246,
3427
+ 182
3428
+ ]
3429
+ },
3430
+ {
3431
+ name: "RemoveInvestorEvent",
3432
+ discriminator: [
3433
+ 221,
3434
+ 84,
3435
+ 243,
3436
+ 216,
3437
+ 215,
3438
+ 253,
3439
+ 246,
3440
+ 253
3441
+ ]
3442
+ },
3443
+ {
3444
+ name: "RemoveLevelsEvent",
3445
+ discriminator: [
3446
+ 145,
3447
+ 158,
3448
+ 97,
3449
+ 146,
3450
+ 126,
3451
+ 14,
3452
+ 2,
3453
+ 225
3454
+ ]
3455
+ }
3456
+ ];
3457
+ var errors = [
3318
3458
  {
3319
3459
  code: 6000,
3320
3460
  name: "UnknownInstruction",
@@ -3351,598 +3491,39 @@ var errors$1 = [
3351
3491
  msg: "Unknown level"
3352
3492
  }
3353
3493
  ];
3354
- var types$1 = [
3494
+ var types = [
3355
3495
  {
3356
- name: "Investor",
3496
+ name: "AddLevelsEvent",
3357
3497
  type: {
3358
3498
  kind: "struct",
3359
3499
  fields: [
3360
3500
  {
3361
- name: "authority",
3362
- docs: [
3363
- "Authority keypair allowed to write this account, will match authority or delegate of IdentityRegistry",
3364
- "at time of creation of IdentityAccount."
3365
- ],
3366
- type: "pubkey"
3501
+ name: "investor_id",
3502
+ type: "string"
3367
3503
  },
3368
3504
  {
3369
- name: "identity_account",
3370
- docs: [
3371
- "IdentityAccount associated with this investor."
3372
- ],
3505
+ name: "sender",
3373
3506
  type: "pubkey"
3374
3507
  },
3375
3508
  {
3376
- name: "identity_registry",
3377
- docs: [
3378
- "IdentityRegistryAccount associated with this investor."
3379
- ],
3380
- type: "pubkey"
3381
- },
3382
- {
3383
- name: "bump",
3384
- docs: [
3385
- "PDA Seed Bump"
3386
- ],
3387
- type: "u8"
3388
- },
3389
- {
3390
- name: "investor_id",
3391
- docs: [
3392
- "Unique ID for Investor, generated off-chain."
3393
- ],
3394
- type: "string"
3395
- },
3396
- {
3397
- name: "collision_hash",
3398
- docs: [
3399
- "Metadata for investor, generated off-chain."
3400
- ],
3401
- type: "string"
3402
- },
3403
- {
3404
- name: "last_updated_by",
3405
- docs: [
3406
- "User that last modified this investor. Read from payer of instruction."
3407
- ],
3408
- type: "pubkey"
3409
- },
3410
- {
3411
- name: "levels",
3412
- docs: [
3413
- "Levels assigned to investor."
3414
- ],
3415
- type: {
3416
- vec: {
3417
- defined: {
3418
- name: "LevelData"
3419
- }
3420
- }
3421
- }
3422
- },
3423
- {
3424
- name: "country",
3425
- type: "u8"
3426
- }
3427
- ]
3428
- }
3429
- },
3430
- {
3431
- name: "LevelData",
3432
- type: {
3433
- kind: "struct",
3434
- fields: [
3435
- {
3436
- name: "level",
3437
- docs: [
3438
- "Maps to IdentityAccount level used in RWA Token."
3439
- ],
3440
- type: "u8"
3441
- },
3442
- {
3443
- name: "proof_hash",
3444
- docs: [
3445
- "Hash generated off-chain."
3446
- ],
3447
- type: "string"
3448
- }
3449
- ]
3450
- }
3451
- }
3452
- ];
3453
- var rwa_imr = {
3454
- address: address$1,
3455
- metadata: metadata$1,
3456
- instructions: instructions$1,
3457
- accounts: accounts$1,
3458
- errors: errors$1,
3459
- types: types$1
3460
- };
3461
-
3462
- var imrIDL = /*#__PURE__*/Object.freeze({
3463
- __proto__: null,
3464
- address: address$1,
3465
- metadata: metadata$1,
3466
- instructions: instructions$1,
3467
- accounts: accounts$1,
3468
- errors: errors$1,
3469
- types: types$1,
3470
- 'default': rwa_imr
3471
- });
3472
-
3473
- var address = "9bNt3ZiZpDdHqAt5Q1Wq6twFe5RKmMCwA7MJyK2HgGnU";
3474
- var metadata = {
3475
- name: "token_locks",
3476
- version: "0.1.0",
3477
- spec: "0.1.0",
3478
- description: "Created with Anchor"
3479
- };
3480
- var instructions = [
3481
- {
3482
- name: "add_token_lock",
3483
- discriminator: [
3484
- 195,
3485
- 26,
3486
- 109,
3487
- 80,
3488
- 46,
3489
- 7,
3490
- 195,
3491
- 55
3492
- ],
3493
- accounts: [
3494
- {
3495
- name: "payer",
3496
- writable: true,
3497
- signer: true
3498
- },
3499
- {
3500
- name: "authority",
3501
- docs: [
3502
- "Authority of AssetController (required to execute seize CPI)."
3503
- ],
3504
- writable: true,
3505
- signer: true,
3506
- relations: [
3507
- "investor"
3508
- ]
3509
- },
3510
- {
3511
- name: "investor_locks",
3512
- writable: true
3513
- },
3514
- {
3515
- name: "investor",
3516
- relations: [
3517
- "investor_locks"
3518
- ]
3519
- },
3520
- {
3521
- name: "wallet_identity_account"
3522
- },
3523
- {
3524
- name: "identity_account",
3525
- relations: [
3526
- "investor"
3527
- ]
3528
- },
3529
- {
3530
- name: "asset_mint",
3531
- writable: true
3532
- },
3533
- {
3534
- name: "unlocked_token_account",
3535
- writable: true
3536
- },
3537
- {
3538
- name: "locked_token_account",
3539
- writable: true,
3540
- relations: [
3541
- "investor_locks"
3542
- ]
3543
- },
3544
- {
3545
- name: "asset_controller"
3546
- },
3547
- {
3548
- name: "identity_registry",
3549
- writable: true,
3550
- relations: [
3551
- "investor"
3552
- ]
3553
- },
3554
- {
3555
- name: "asset_controller_program",
3556
- address: "7tXjmbkZVY3Gmg9kDBebcNXT1yC5pyoxxXVLwdbv9tvP"
3557
- },
3558
- {
3559
- name: "token_program",
3560
- address: "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
3561
- },
3562
- {
3563
- name: "system_program",
3564
- address: "11111111111111111111111111111111"
3565
- }
3566
- ],
3567
- args: [
3568
- {
3569
- name: "value",
3570
- type: "u64"
3571
- },
3572
- {
3573
- name: "release_time",
3574
- type: "i64"
3575
- },
3576
- {
3577
- name: "reason_code",
3578
- type: "u64"
3579
- },
3580
- {
3581
- name: "reason_string",
3582
- type: "string"
3583
- }
3584
- ]
3585
- },
3586
- {
3587
- name: "close_investor_locks",
3588
- discriminator: [
3589
- 255,
3590
- 60,
3591
- 220,
3592
- 115,
3593
- 217,
3594
- 104,
3595
- 157,
3596
- 171
3597
- ],
3598
- accounts: [
3599
- {
3600
- name: "payer",
3601
- writable: true,
3602
- signer: true
3603
- },
3604
- {
3605
- name: "authority",
3606
- signer: true,
3607
- relations: [
3608
- "investor"
3609
- ]
3610
- },
3611
- {
3612
- name: "investor_locks",
3613
- writable: true
3614
- },
3615
- {
3616
- name: "investor",
3617
- relations: [
3618
- "investor_locks"
3619
- ]
3620
- },
3621
- {
3622
- name: "locked_token_account",
3623
- writable: true,
3624
- relations: [
3625
- "investor_locks"
3626
- ]
3627
- },
3628
- {
3629
- name: "token_program",
3630
- address: "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
3631
- },
3632
- {
3633
- name: "system_program",
3634
- address: "11111111111111111111111111111111"
3635
- }
3636
- ],
3637
- args: [
3638
- ]
3639
- },
3640
- {
3641
- name: "create_investor_locks",
3642
- discriminator: [
3643
- 223,
3644
- 81,
3645
- 139,
3646
- 162,
3647
- 204,
3648
- 48,
3649
- 24,
3650
- 213
3651
- ],
3652
- accounts: [
3653
- {
3654
- name: "payer",
3655
- writable: true,
3656
- signer: true
3657
- },
3658
- {
3659
- name: "authority",
3660
- signer: true,
3661
- relations: [
3662
- "investor"
3663
- ]
3664
- },
3665
- {
3666
- name: "investor_locks",
3667
- writable: true,
3668
- pda: {
3669
- seeds: [
3670
- {
3671
- kind: "account",
3672
- path: "investor.investor_id",
3673
- account: "Investor"
3674
- },
3675
- {
3676
- kind: "account",
3677
- path: "investor.identity_registry",
3678
- account: "Investor"
3679
- },
3680
- {
3681
- kind: "const",
3682
- value: [
3683
- 73,
3684
- 110,
3685
- 118,
3686
- 101,
3687
- 115,
3688
- 116,
3689
- 111,
3690
- 114,
3691
- 76,
3692
- 111,
3693
- 99,
3694
- 107,
3695
- 115
3696
- ]
3697
- }
3698
- ]
3699
- }
3700
- },
3701
- {
3702
- name: "investor"
3703
- },
3704
- {
3705
- name: "identity_account",
3706
- docs: [
3707
- "CHECKED: Matches known address."
3708
- ],
3709
- relations: [
3710
- "investor"
3711
- ]
3712
- },
3713
- {
3714
- name: "asset_mint",
3715
- writable: true
3716
- },
3717
- {
3718
- name: "locked_token_account",
3719
- writable: true,
3720
- pda: {
3721
- seeds: [
3722
- {
3723
- kind: "account",
3724
- path: "investor.investor_id",
3725
- account: "Investor"
3726
- },
3727
- {
3728
- kind: "account",
3729
- path: "investor.identity_registry",
3730
- account: "Investor"
3731
- },
3732
- {
3733
- kind: "const",
3734
- value: [
3735
- 76,
3736
- 111,
3737
- 99,
3738
- 107,
3739
- 101,
3740
- 100,
3741
- 84,
3742
- 111,
3743
- 107,
3744
- 101,
3745
- 110,
3746
- 65,
3747
- 99,
3748
- 99,
3749
- 111,
3750
- 117,
3751
- 110,
3752
- 116
3753
- ]
3754
- }
3755
- ]
3509
+ name: "levels",
3510
+ type: "bytes"
3511
+ },
3512
+ {
3513
+ name: "expiries",
3514
+ type: {
3515
+ vec: "i64"
3516
+ }
3517
+ },
3518
+ {
3519
+ name: "proof_hashes",
3520
+ type: {
3521
+ vec: "string"
3522
+ }
3756
3523
  }
3757
- },
3758
- {
3759
- name: "asset_controller"
3760
- },
3761
- {
3762
- name: "asset_controller_program",
3763
- address: "7tXjmbkZVY3Gmg9kDBebcNXT1yC5pyoxxXVLwdbv9tvP"
3764
- },
3765
- {
3766
- name: "token_program",
3767
- address: "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
3768
- },
3769
- {
3770
- name: "system_program",
3771
- address: "11111111111111111111111111111111"
3772
- }
3773
- ],
3774
- args: [
3775
- ]
3776
- },
3777
- {
3778
- name: "remove_token_lock",
3779
- discriminator: [
3780
- 168,
3781
- 128,
3782
- 173,
3783
- 188,
3784
- 172,
3785
- 228,
3786
- 154,
3787
- 90
3788
- ],
3789
- accounts: [
3790
- {
3791
- name: "user",
3792
- signer: true
3793
- },
3794
- {
3795
- name: "authority",
3796
- docs: [
3797
- "Authority of AssetController (required to execute seize CPI)."
3798
- ],
3799
- writable: true,
3800
- signer: true,
3801
- relations: [
3802
- "investor"
3803
- ]
3804
- },
3805
- {
3806
- name: "investor_locks",
3807
- writable: true
3808
- },
3809
- {
3810
- name: "investor",
3811
- relations: [
3812
- "investor_locks"
3813
- ]
3814
- },
3815
- {
3816
- name: "wallet_identity_account"
3817
- },
3818
- {
3819
- name: "identity_account",
3820
- relations: [
3821
- "investor"
3822
- ]
3823
- },
3824
- {
3825
- name: "asset_mint",
3826
- writable: true
3827
- },
3828
- {
3829
- name: "unlocked_token_account",
3830
- writable: true
3831
- },
3832
- {
3833
- name: "locked_token_account",
3834
- writable: true,
3835
- relations: [
3836
- "investor_locks"
3837
- ]
3838
- },
3839
- {
3840
- name: "asset_controller"
3841
- },
3842
- {
3843
- name: "identity_registry",
3844
- writable: true,
3845
- relations: [
3846
- "investor"
3847
- ]
3848
- },
3849
- {
3850
- name: "asset_controller_program",
3851
- address: "7tXjmbkZVY3Gmg9kDBebcNXT1yC5pyoxxXVLwdbv9tvP"
3852
- },
3853
- {
3854
- name: "token_program",
3855
- address: "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
3856
- }
3857
- ],
3858
- args: [
3859
- {
3860
- name: "is_user_authorized",
3861
- type: "bool"
3862
- },
3863
- {
3864
- name: "indices",
3865
- type: "bytes"
3866
- }
3867
- ]
3868
- }
3869
- ];
3870
- var accounts = [
3871
- {
3872
- name: "Investor",
3873
- discriminator: [
3874
- 174,
3875
- 129,
3876
- 17,
3877
- 83,
3878
- 36,
3879
- 116,
3880
- 26,
3881
- 196
3882
- ]
3883
- },
3884
- {
3885
- name: "InvestorLocks",
3886
- discriminator: [
3887
- 199,
3888
- 60,
3889
- 219,
3890
- 46,
3891
- 221,
3892
- 205,
3893
- 1,
3894
- 7
3895
- ]
3896
- }
3897
- ];
3898
- var errors = [
3899
- {
3900
- code: 6000,
3901
- name: "UnknownInstruction",
3902
- msg: "Unknown program instruction from CPI data"
3903
- },
3904
- {
3905
- code: 6001,
3906
- name: "UnknownAccount",
3907
- msg: "Unknown account discriminator"
3908
- },
3909
- {
3910
- code: 6002,
3911
- name: "FailedDeserialization",
3912
- msg: "Invalid account on deserialization"
3913
- },
3914
- {
3915
- code: 6003,
3916
- name: "InvalidReleaseTime",
3917
- msg: "Invalid release time"
3918
- },
3919
- {
3920
- code: 6004,
3921
- name: "InvalidReasonString",
3922
- msg: "Invalid reason string"
3923
- },
3924
- {
3925
- code: 6005,
3926
- name: "InvalidLockValue",
3927
- msg: "Invalid lock value"
3928
- },
3929
- {
3930
- code: 6006,
3931
- name: "UnauthorizedUser",
3932
- msg: "User initiating instruction is not authorized by RBAC"
3933
- },
3934
- {
3935
- code: 6007,
3936
- name: "InvalidTokenAccountState",
3937
- msg: "Invalid token account state"
3524
+ ]
3525
+ }
3938
3526
  },
3939
- {
3940
- code: 6008,
3941
- name: "LockNotFound",
3942
- msg: "Lock not found"
3943
- }
3944
- ];
3945
- var types = [
3946
3527
  {
3947
3528
  name: "Investor",
3948
3529
  type: {
@@ -4019,117 +3600,116 @@ var types = [
4019
3600
  }
4020
3601
  },
4021
3602
  {
4022
- name: "InvestorLocks",
3603
+ name: "LevelData",
4023
3604
  type: {
4024
3605
  kind: "struct",
4025
3606
  fields: [
4026
3607
  {
4027
- name: "investor",
3608
+ name: "level",
4028
3609
  docs: [
4029
- "Address of Investor account."
3610
+ "Maps to IdentityAccount level used in RWA Token."
4030
3611
  ],
4031
- type: "pubkey"
3612
+ type: "u8"
4032
3613
  },
4033
3614
  {
4034
- name: "locked_token_account",
3615
+ name: "proof_hash",
4035
3616
  docs: [
4036
- "Account storing locked tokens for wallet. Will be frozen upon initialization of",
4037
- "InvestorLocks."
3617
+ "Hash generated off-chain."
4038
3618
  ],
4039
- type: "pubkey"
4040
- },
4041
- {
4042
- name: "locks",
4043
- type: {
4044
- vec: {
4045
- defined: {
4046
- name: "Lock"
4047
- }
4048
- }
4049
- }
3619
+ type: "string"
4050
3620
  }
4051
3621
  ]
4052
3622
  }
4053
3623
  },
4054
3624
  {
4055
- name: "LevelData",
3625
+ name: "RegisterInvestorEvent",
4056
3626
  type: {
4057
3627
  kind: "struct",
4058
3628
  fields: [
3629
+ {
3630
+ name: "investor_id",
3631
+ type: "string"
3632
+ },
4059
3633
  {
4060
3634
  name: "level",
4061
- docs: [
4062
- "Maps to IdentityAccount level used in RWA Token."
4063
- ],
4064
3635
  type: "u8"
4065
3636
  },
4066
3637
  {
4067
- name: "proof_hash",
4068
- docs: [
4069
- "Hash generated off-chain."
4070
- ],
3638
+ name: "expiry",
3639
+ type: "i64"
3640
+ },
3641
+ {
3642
+ name: "collision_hash",
3643
+ type: "string"
3644
+ },
3645
+ {
3646
+ name: "sender",
3647
+ type: "pubkey"
3648
+ },
3649
+ {
3650
+ name: "country",
3651
+ type: "u8"
3652
+ }
3653
+ ]
3654
+ }
3655
+ },
3656
+ {
3657
+ name: "RemoveInvestorEvent",
3658
+ type: {
3659
+ kind: "struct",
3660
+ fields: [
3661
+ {
3662
+ name: "investor_id",
4071
3663
  type: "string"
3664
+ },
3665
+ {
3666
+ name: "sender",
3667
+ type: "pubkey"
4072
3668
  }
4073
3669
  ]
4074
3670
  }
4075
3671
  },
4076
3672
  {
4077
- name: "Lock",
3673
+ name: "RemoveLevelsEvent",
4078
3674
  type: {
4079
3675
  kind: "struct",
4080
3676
  fields: [
4081
3677
  {
4082
- name: "value",
4083
- docs: [
4084
- "Amount of tokens to lock."
4085
- ],
4086
- type: "u64"
4087
- },
4088
- {
4089
- name: "release_time",
4090
- docs: [
4091
- "Timestamp from which the lock will be inactive. If value is 0, the lock",
4092
- "will remain active until removed."
4093
- ],
4094
- type: "i64"
3678
+ name: "investor_id",
3679
+ type: "string"
4095
3680
  },
4096
3681
  {
4097
- name: "reason_code",
4098
- docs: [
4099
- "Reason code for locking."
4100
- ],
4101
- type: "u64"
3682
+ name: "sender",
3683
+ type: "pubkey"
4102
3684
  },
4103
3685
  {
4104
- name: "reason_string",
4105
- docs: [
4106
- "Detailed reason for the lock. Since string has no length limit, we calculate",
4107
- "total space needed dynamically at time of resizing."
4108
- ],
4109
- type: "string"
3686
+ name: "levels",
3687
+ type: "bytes"
4110
3688
  }
4111
3689
  ]
4112
3690
  }
4113
3691
  }
4114
3692
  ];
4115
- var token_locks = {
3693
+ var rwa_imr = {
4116
3694
  address: address,
4117
3695
  metadata: metadata,
4118
3696
  instructions: instructions,
4119
3697
  accounts: accounts,
3698
+ events: events,
4120
3699
  errors: errors,
4121
3700
  types: types
4122
3701
  };
4123
3702
 
4124
- var tokenLocksIdl = /*#__PURE__*/Object.freeze({
3703
+ var imrIDL = /*#__PURE__*/Object.freeze({
4125
3704
  __proto__: null,
4126
3705
  address: address,
4127
3706
  metadata: metadata,
4128
3707
  instructions: instructions,
4129
3708
  accounts: accounts,
3709
+ events: events,
4130
3710
  errors: errors,
4131
3711
  types: types,
4132
- 'default': token_locks
3712
+ 'default': rwa_imr
4133
3713
  });
4134
3714
 
4135
3715
  var AdminFlags;
@@ -4174,7 +3754,8 @@ var MediciFlags;
4174
3754
  MediciFlags[MediciFlags["CHANGE_COUNTRY"] = 134217728] = "CHANGE_COUNTRY";
4175
3755
  MediciFlags[MediciFlags["CHANGE_MAPPING"] = 268435456] = "CHANGE_MAPPING";
4176
3756
  MediciFlags[MediciFlags["CHANGE_ISSUANCE_POLICIES"] = 536870912] = "CHANGE_ISSUANCE_POLICIES";
4177
- MediciFlags[MediciFlags["ALL"] = 1073741823] = "ALL";
3757
+ MediciFlags[MediciFlags["REMOVE_IDENTITY_ACCOUNT"] = 1073741824] = "REMOVE_IDENTITY_ACCOUNT";
3758
+ MediciFlags[MediciFlags["ALL"] = 2147483647] = "ALL";
4178
3759
  })(MediciFlags || (MediciFlags = {}));
4179
3760
 
4180
3761
  /******************************************************************************
@@ -4300,6 +3881,7 @@ class AssetController {
4300
3881
  associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
4301
3882
  systemProgram: SystemProgram.programId,
4302
3883
  walletIdentityAccount: getWalletIdentityAccountPda(args.assetMint, args.wallet),
3884
+ eventAuthority: getAssetControllerEventAuthority(),
4303
3885
  })
4304
3886
  .instruction();
4305
3887
  });
@@ -4423,6 +4005,7 @@ class AssetController {
4423
4005
  tokenProgram: TOKEN_2022_PROGRAM_ID,
4424
4006
  associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
4425
4007
  systemProgram: SystemProgram.programId,
4008
+ eventAuthority: getAssetControllerEventAuthority(),
4426
4009
  })
4427
4010
  .instruction();
4428
4011
  });
@@ -4506,6 +4089,7 @@ class AssetController {
4506
4089
  sourceTokenAccount: getAssociatedTokenAddressSync(new PublicKey(args.assetMint), new PublicKey(args.from), false, TOKEN_2022_PROGRAM_ID),
4507
4090
  destinationTokenAccount: getAssociatedTokenAddressSync(new PublicKey(args.assetMint), new PublicKey(args.to), true, TOKEN_2022_PROGRAM_ID),
4508
4091
  tokenProgram: TOKEN_2022_PROGRAM_ID,
4092
+ eventAuthority: getAssetControllerEventAuthority(),
4509
4093
  })
4510
4094
  .remainingAccounts([
4511
4095
  {
@@ -4600,6 +4184,7 @@ class PolicyEngine {
4600
4184
  policyEngineProgram: policyEngineProgramId,
4601
4185
  policyEngine: getPolicyEnginePda(args.assetMint),
4602
4186
  systemProgram: SystemProgram.programId,
4187
+ eventAuthority: getPolicyEngineEventAuthority(),
4603
4188
  })
4604
4189
  .instruction();
4605
4190
  });
@@ -4627,6 +4212,7 @@ class PolicyEngine {
4627
4212
  policyEngineProgram: policyEngineProgramId,
4628
4213
  policyEngine: getPolicyEnginePda(args.assetMint),
4629
4214
  systemProgram: SystemProgram.programId,
4215
+ eventAuthority: getPolicyEngineEventAuthority(),
4630
4216
  })
4631
4217
  .instruction();
4632
4218
  });
@@ -4654,6 +4240,7 @@ class PolicyEngine {
4654
4240
  policyEngineProgram: policyEngineProgramId,
4655
4241
  policyEngine: getPolicyEnginePda(args.assetMint),
4656
4242
  systemProgram: SystemProgram.programId,
4243
+ eventAuthority: getPolicyEngineEventAuthority(),
4657
4244
  })
4658
4245
  .instruction();
4659
4246
  });
@@ -4680,6 +4267,7 @@ class PolicyEngine {
4680
4267
  authorizedUserRole: authorizedUserRole || null,
4681
4268
  policyEngineProgram: policyEngineProgramId,
4682
4269
  policyEngine: getPolicyEnginePda(args.assetMint),
4270
+ eventAuthority: getPolicyEngineEventAuthority(),
4683
4271
  })
4684
4272
  .instruction();
4685
4273
  });
@@ -4707,6 +4295,7 @@ class PolicyEngine {
4707
4295
  policyEngineProgram: policyEngineProgramId,
4708
4296
  policyEngine: getPolicyEnginePda(args.assetMint),
4709
4297
  systemProgram: SystemProgram.programId,
4298
+ eventAuthority: getPolicyEngineEventAuthority(),
4710
4299
  })
4711
4300
  .instruction();
4712
4301
  });
@@ -4732,6 +4321,7 @@ class PolicyEngine {
4732
4321
  authorizedUserRole: authorizedUserRole || null,
4733
4322
  policyEngineProgram: policyEngineProgramId,
4734
4323
  policyEngine: getPolicyEnginePda(args.assetMint),
4324
+ eventAuthority: getPolicyEngineEventAuthority(),
4735
4325
  })
4736
4326
  .instruction();
4737
4327
  });
@@ -4757,6 +4347,7 @@ class PolicyEngine {
4757
4347
  authorizedUserRole: authorizedUserRole || null,
4758
4348
  policyEngineProgram: policyEngineProgramId,
4759
4349
  policyEngine: getPolicyEnginePda(args.assetMint),
4350
+ eventAuthority: getPolicyEngineEventAuthority(),
4760
4351
  })
4761
4352
  .instruction();
4762
4353
  });
@@ -4850,6 +4441,7 @@ class IdentityRegistry {
4850
4441
  identityAccount,
4851
4442
  walletIdentity: getWalletIdentityAccountPda(args.assetMint, args.owner),
4852
4443
  systemProgram: SystemProgram.programId,
4444
+ eventAuthority: getIdentityRegistryEventAuthority(),
4853
4445
  })
4854
4446
  .instruction());
4855
4447
  returnIxs.push(trackerAccountIx);
@@ -4859,6 +4451,41 @@ class IdentityRegistry {
4859
4451
  };
4860
4452
  });
4861
4453
  }
4454
+ /**
4455
+ * Asynchronously generates instructions to remove a non-investor user with an identity account.
4456
+ * @param args - {@link SetupUserArgs}
4457
+ * @param authority - RBAC AssetAccessController ControllerAuthority.
4458
+ * @param assetAccessController - RBAC AssetAccessController account.
4459
+ * @param authorizedUserRole - Optional UserRole account. Required if user is not an admin.
4460
+ * @returns A Promise that resolves to the instructions to setup a user.
4461
+ *
4462
+ * It is required for at least a single user to be setup before issuing tokens.
4463
+ */
4464
+ removeUserIxn(args, assetAccessController, authorizedUserRole) {
4465
+ return __awaiter(this, void 0, void 0, function* () {
4466
+ const ix = yield this.rwaClient.identityRegistry.revokeIdentityAccount(args);
4467
+ const identityAccountAddress = getIdentityAccountPda(args.assetMint, args.owner);
4468
+ const identityAccount = yield getIdentityAccount(identityAccountAddress, this.rwaClient.provider);
4469
+ const controllerAuthority = deriveControllerAuthorityPda(assetAccessController);
4470
+ const returnIx = yield this.rbacProgram.methods
4471
+ .removeIdentityAccount(ix.data)
4472
+ .accountsStrict({
4473
+ payer: args.payer,
4474
+ user: args.signer,
4475
+ controllerAuthority,
4476
+ assetAccessController,
4477
+ authorizedUserRole: authorizedUserRole || null,
4478
+ identityRegistryProgram: identityRegistryProgramId,
4479
+ identityRegistry: getIdentityRegistryPda(args.assetMint),
4480
+ identityAccount: identityAccountAddress,
4481
+ walletIdentity: getWalletIdentityAccountPda(args.assetMint, args.owner),
4482
+ eventAuthority: getIdentityRegistryEventAuthority(),
4483
+ identityOwner: identityAccount.owner,
4484
+ })
4485
+ .instruction();
4486
+ return returnIx;
4487
+ });
4488
+ }
4862
4489
  /**
4863
4490
  * Asynchronously update a non-investor user identity account level.
4864
4491
  * @param args - {@link AddLevelToIdentityAccountArgs}
@@ -4888,6 +4515,7 @@ class IdentityRegistry {
4888
4515
  policyEngine: getPolicyEnginePda(args.assetMint),
4889
4516
  trackerAccount: getTrackerAccountPda(args.assetMint, args.owner),
4890
4517
  assetMint: args.assetMint,
4518
+ eventAuthority: getIdentityRegistryEventAuthority(),
4891
4519
  })
4892
4520
  .instruction();
4893
4521
  });
@@ -4922,6 +4550,7 @@ class IdentityRegistry {
4922
4550
  policyEngine: getPolicyEnginePda(args.assetMint),
4923
4551
  trackerAccount: getTrackerAccountPda(args.assetMint, args.owner),
4924
4552
  assetMint: args.assetMint,
4553
+ eventAuthority: getIdentityRegistryEventAuthority(),
4925
4554
  })
4926
4555
  .instruction();
4927
4556
  });
@@ -4988,6 +4617,8 @@ class IdentityRegistry {
4988
4617
  assetMint: args.assetMint,
4989
4618
  walletIdentity,
4990
4619
  systemProgram: SystemProgram.programId,
4620
+ eventAuthority: getIdentityRegistryEventAuthority(),
4621
+ program: identityRegistryProgramId,
4991
4622
  })
4992
4623
  .instruction();
4993
4624
  return this.rbacProgram.methods
@@ -5004,6 +4635,7 @@ class IdentityRegistry {
5004
4635
  assetMint: args.assetMint,
5005
4636
  walletIdentity,
5006
4637
  systemProgram: SystemProgram.programId,
4638
+ eventAuthority: getIdentityRegistryEventAuthority(),
5007
4639
  })
5008
4640
  .instruction();
5009
4641
  });
@@ -5030,6 +4662,8 @@ class IdentityRegistry {
5030
4662
  walletIdentity,
5031
4663
  identityAccount,
5032
4664
  identityRegistry,
4665
+ eventAuthority: getIdentityRegistryEventAuthority(),
4666
+ program: identityRegistryProgramId,
5033
4667
  })
5034
4668
  .instruction();
5035
4669
  return this.rbacProgram.methods
@@ -5044,6 +4678,7 @@ class IdentityRegistry {
5044
4678
  walletIdentity,
5045
4679
  identityAccount,
5046
4680
  identityRegistry,
4681
+ eventAuthority: getIdentityRegistryEventAuthority(),
5047
4682
  })
5048
4683
  .instruction();
5049
4684
  });
@@ -5059,6 +4694,27 @@ class IdentityMetadataRegistry {
5059
4694
  this.rbacProgram = rbacProgram;
5060
4695
  this.imrProgram = imrProgram;
5061
4696
  }
4697
+ /**
4698
+ * Parses inner instructions data field for array of events emitted by program using CPI Events.
4699
+ * @param ixs - Array of CompiledInstruction from a transaction inner instructions.
4700
+ * @returns Array of Events
4701
+ * */
4702
+ parseEvents(ixs) {
4703
+ const eventCoder = this.imrProgram.coder.events;
4704
+ const events = ixs
4705
+ .map(({ data }) => {
4706
+ try {
4707
+ const buffer = Buffer.from(utils.bytes.bs58.decode(data));
4708
+ const event = eventCoder.decode(utils.bytes.base64.encode(buffer.slice(8)));
4709
+ return event;
4710
+ }
4711
+ catch (err) {
4712
+ console.error("Error decoding events", err);
4713
+ }
4714
+ })
4715
+ .filter((v) => v != null);
4716
+ return events;
4717
+ }
5062
4718
  /**
5063
4719
  * Asynchronously generates instructions to setup an investor.
5064
4720
  * @param args - {@link SetupInvestorArgs}
@@ -5090,6 +4746,9 @@ class IdentityMetadataRegistry {
5090
4746
  walletIdentity: getWalletIdentityAccountPda(args.assetMint, investor.toString() // Investor is owner of IdentityAccount
5091
4747
  ),
5092
4748
  systemProgram: SystemProgram.programId,
4749
+ eventAuthority: getEventAuthority(IMR_PROGRAM),
4750
+ eventAuthorityIdentityRegistry: getIdentityRegistryEventAuthority(),
4751
+ program: identityRegistryProgramId,
5093
4752
  })
5094
4753
  .instruction();
5095
4754
  returnIxs.push(yield this.rbacProgram.methods
@@ -5107,6 +4766,8 @@ class IdentityMetadataRegistry {
5107
4766
  identityAccount,
5108
4767
  walletIdentity: getWalletIdentityAccountPda(args.assetMint, investor.toString()),
5109
4768
  systemProgram: SystemProgram.programId,
4769
+ eventAuthorityIdentityMetadataRegistry: getEventAuthority(IMR_PROGRAM),
4770
+ eventAuthorityIdentityRegistry: getIdentityRegistryEventAuthority(),
5110
4771
  })
5111
4772
  .instruction());
5112
4773
  const policyProgram = getPolicyEngineProgram(this.imrProgram.provider);
@@ -5171,6 +4832,9 @@ class IdentityMetadataRegistry {
5171
4832
  policyEngine: getPolicyEnginePda(args.assetMint),
5172
4833
  trackerAccount,
5173
4834
  assetMint: args.assetMint,
4835
+ eventAuthorityIdentityRegistry: getIdentityRegistryEventAuthority(),
4836
+ eventAuthority: getEventAuthority(IMR_PROGRAM),
4837
+ program: IMR_PROGRAM,
5174
4838
  })
5175
4839
  .instruction();
5176
4840
  return this.rbacProgram.methods
@@ -5191,6 +4855,8 @@ class IdentityMetadataRegistry {
5191
4855
  policyEngine: getPolicyEnginePda(args.assetMint),
5192
4856
  trackerAccount,
5193
4857
  assetMint: args.assetMint,
4858
+ eventAuthorityIdentityRegistry: getIdentityRegistryEventAuthority(),
4859
+ eventAuthorityIdentityMetadataRegistry: getEventAuthority(IMR_PROGRAM),
5194
4860
  })
5195
4861
  .instruction();
5196
4862
  });
@@ -5223,6 +4889,7 @@ class IdentityMetadataRegistry {
5223
4889
  policyEngine: getPolicyEnginePda(args.assetMint),
5224
4890
  trackerAccount,
5225
4891
  assetMint: args.assetMint,
4892
+ eventAuthorityIdentityRegistry: getIdentityRegistryEventAuthority(),
5226
4893
  })
5227
4894
  .instruction();
5228
4895
  return this.rbacProgram.methods
@@ -5242,6 +4909,7 @@ class IdentityMetadataRegistry {
5242
4909
  policyEngine: getPolicyEnginePda(args.assetMint),
5243
4910
  trackerAccount,
5244
4911
  assetMint: args.assetMint,
4912
+ eventAuthorityIdentityRegistry: getIdentityRegistryEventAuthority(),
5245
4913
  })
5246
4914
  .instruction();
5247
4915
  });
@@ -5275,6 +4943,7 @@ class IdentityMetadataRegistry {
5275
4943
  policyEngine: getPolicyEnginePda(args.assetMint),
5276
4944
  trackerAccount,
5277
4945
  assetMint: args.assetMint,
4946
+ eventAuthorityIdentityRegistry: getIdentityRegistryEventAuthority(),
5278
4947
  })
5279
4948
  .instruction();
5280
4949
  return this.rbacProgram.methods
@@ -5295,6 +4964,7 @@ class IdentityMetadataRegistry {
5295
4964
  policyEngine: getPolicyEnginePda(args.assetMint),
5296
4965
  trackerAccount,
5297
4966
  assetMint: args.assetMint,
4967
+ eventAuthorityIdentityRegistry: getIdentityRegistryEventAuthority(),
5298
4968
  })
5299
4969
  .instruction();
5300
4970
  });
@@ -5328,6 +4998,8 @@ class IdentityMetadataRegistry {
5328
4998
  walletIdentity: getWalletIdentityAccountPda(args.assetMint, investor.toString()),
5329
4999
  policyEngineProgram: policyEngineProgramId,
5330
5000
  trackerAccount: getTrackerAccountPda(args.assetMint, investor.toString()),
5001
+ eventAuthorityIdentityMetadataRegistry: getEventAuthority(IMR_PROGRAM),
5002
+ eventAuthorityIdentityRegistry: getIdentityRegistryEventAuthority(),
5331
5003
  })
5332
5004
  .instruction();
5333
5005
  });
@@ -5354,266 +5026,13 @@ class IdentityMetadataRegistry {
5354
5026
  identityRegistry,
5355
5027
  assetMint: args.assetMint,
5356
5028
  systemProgram: SystemProgram.programId,
5029
+ eventAuthorityIdentityRegistry: getIdentityRegistryEventAuthority(),
5357
5030
  })
5358
5031
  .instruction();
5359
5032
  });
5360
5033
  }
5361
5034
  }
5362
5035
 
5363
- /**
5364
- * Role-based access client for accessing Token Locks
5365
- */
5366
- class TokenLocks {
5367
- constructor(rwaClient, rbacProgram, tokenLocksProgram) {
5368
- this.rwaClient = rwaClient;
5369
- this.rbacProgram = rbacProgram;
5370
- this.tokenLocksProgram = tokenLocksProgram;
5371
- }
5372
- /**
5373
- * Asynchronously create InvestorLocks account for a wallet.
5374
- * @param args - {@link CreateOrCloseInvestorLocksArgs}
5375
- * @param assetAccessController - RBAC AssetAccessController account.
5376
- * @param authorizedUserRole - Optional UserRole account. Required if user is not an admin.
5377
- * @returns A Promise that resolves to a transaction instruction.
5378
- * */
5379
- createInvestorLocks(args, assetAccessController, authorizedUserRole) {
5380
- return __awaiter(this, void 0, void 0, function* () {
5381
- const identityRegistry = getIdentityRegistryPda(args.assetMint);
5382
- const investor = deriveInvestorPda(args.investorId, identityRegistry);
5383
- return this.rbacProgram.methods
5384
- .createInvestorLocks()
5385
- .accountsStrict({
5386
- payer: args.payer,
5387
- user: args.signer,
5388
- controllerAuthority: deriveControllerAuthorityPda(assetAccessController),
5389
- assetAccessController,
5390
- authorizedUserRole: authorizedUserRole || null,
5391
- tokenLocksProgram: TL_PROGRAM,
5392
- investorLocks: deriveInvestorLocks(args.investorId, identityRegistry),
5393
- investor,
5394
- identityAccount: getIdentityAccountPda(args.assetMint, investor.toString()),
5395
- assetMint: args.assetMint,
5396
- lockedTokenAccount: deriveLockedTokenAccount(args.investorId, identityRegistry),
5397
- assetController: getAssetControllerPda(args.assetMint),
5398
- assetControllerProgram: assetControllerProgramId,
5399
- tokenProgram: TOKEN_2022_PROGRAM_ID,
5400
- systemProgram: SystemProgram.programId,
5401
- })
5402
- .instruction();
5403
- });
5404
- }
5405
- /**
5406
- * Asynchronously close InvestorLocks account for a wallet.
5407
- * @param args - {@link CreateOrCloseInvestorLocksArgs}
5408
- * @param assetAccessController - RBAC AssetAccessController account.
5409
- * @param authorizedUserRole - Optional UserRole account. Required if user is not an admin.
5410
- * @returns A Promise that resolves to a transaction instruction.
5411
- * */
5412
- closeInvestorLocks(args, assetAccessController, authorizedUserRole) {
5413
- return __awaiter(this, void 0, void 0, function* () {
5414
- const controllerAuthority = deriveControllerAuthorityPda(assetAccessController);
5415
- const identityRegistry = getIdentityRegistryPda(args.assetMint);
5416
- return this.rbacProgram.methods
5417
- .closeInvestorLocks()
5418
- .accountsStrict({
5419
- payer: args.payer,
5420
- user: args.signer,
5421
- controllerAuthority,
5422
- assetAccessController,
5423
- authorizedUserRole: authorizedUserRole || null,
5424
- tokenLocksProgram: TL_PROGRAM,
5425
- investorLocks: deriveInvestorLocks(args.investorId, identityRegistry),
5426
- investor: deriveInvestorPda(args.investorId, identityRegistry),
5427
- systemProgram: SystemProgram.programId,
5428
- tokenProgram: TOKEN_2022_PROGRAM_ID,
5429
- lockedTokenAccount: deriveLockedTokenAccount(args.investorId, identityRegistry),
5430
- })
5431
- .instruction();
5432
- });
5433
- }
5434
- /**
5435
- * Asynchronously add a lock to InvestorLocks.
5436
- * @param args - {@link AddTokenLockArgs}
5437
- * @param assetAccessController - RBAC AssetAccessController account.
5438
- * @param authorizedUserRole - Optional UserRole account. Required if user is not an admin.
5439
- * @returns A Promise that resolves to a transaction instruction.
5440
- * */
5441
- addTokenLock(args, assetAccessController, authorizedUserRole) {
5442
- return __awaiter(this, void 0, void 0, function* () {
5443
- const assetController = getAssetControllerPda(args.assetMint);
5444
- const identityRegistry = getIdentityRegistryPda(args.assetMint);
5445
- const investorLocks = deriveInvestorLocks(args.investorId, identityRegistry);
5446
- const investor = deriveInvestorPda(args.investorId, identityRegistry);
5447
- const unlockedTokenAccount = getAssociatedTokenAddressSync(new PublicKey(args.assetMint), args.wallet, false, TOKEN_2022_PROGRAM_ID);
5448
- const controllerAuthority = deriveControllerAuthorityPda(assetAccessController);
5449
- const ix = yield this.tokenLocksProgram.methods
5450
- .addTokenLock(args.value, args.releaseTime, args.reasonCode, args.reasonString)
5451
- .accountsStrict({
5452
- payer: args.payer,
5453
- authority: controllerAuthority,
5454
- investorLocks,
5455
- investor,
5456
- assetMint: args.assetMint,
5457
- identityAccount: getIdentityAccountPda(args.assetMint, investor.toString()),
5458
- unlockedTokenAccount,
5459
- lockedTokenAccount: deriveLockedTokenAccount(args.investorId, identityRegistry),
5460
- assetController,
5461
- assetControllerProgram: assetControllerProgramId,
5462
- tokenProgram: TOKEN_2022_PROGRAM_ID,
5463
- identityRegistry: getIdentityRegistryPda(args.assetMint),
5464
- systemProgram: SystemProgram.programId,
5465
- walletIdentityAccount: getWalletIdentityAccountPda(args.assetMint, args.wallet.toString()),
5466
- })
5467
- .instruction();
5468
- return this.rbacProgram.methods
5469
- .addTokenLock(ix.data)
5470
- .accountsStrict({
5471
- payer: args.payer,
5472
- user: args.signer,
5473
- controllerAuthority,
5474
- assetAccessController,
5475
- authorizedUserRole: authorizedUserRole || null,
5476
- tokenLocksProgram: TL_PROGRAM,
5477
- investorLocks,
5478
- investor,
5479
- assetMint: args.assetMint,
5480
- unlockedTokenAccount,
5481
- lockedTokenAccount: deriveLockedTokenAccount(args.investorId, identityRegistry),
5482
- assetController,
5483
- identityRegistry: getIdentityRegistryPda(args.assetMint),
5484
- assetControllerProgram: assetControllerProgramId,
5485
- tokenProgram: TOKEN_2022_PROGRAM_ID,
5486
- systemProgram: SystemProgram.programId,
5487
- identityAccount: getIdentityAccountPda(args.assetMint, investor.toString()),
5488
- walletIdentityAccount: getWalletIdentityAccountPda(args.assetMint, args.wallet.toString()),
5489
- })
5490
- .remainingAccounts([
5491
- {
5492
- pubkey: getPolicyEnginePda(args.assetMint),
5493
- isWritable: true,
5494
- isSigner: false,
5495
- },
5496
- {
5497
- pubkey: identityRegistryProgramId,
5498
- isWritable: false,
5499
- isSigner: false,
5500
- },
5501
- {
5502
- pubkey: policyEngineProgramId,
5503
- isWritable: false,
5504
- isSigner: false,
5505
- },
5506
- {
5507
- pubkey: getIdentityRegistryPda(args.assetMint),
5508
- isWritable: false,
5509
- isSigner: false,
5510
- },
5511
- {
5512
- pubkey: getTrackerAccountPda(args.assetMint, investor.toString()),
5513
- isWritable: true,
5514
- isSigner: false,
5515
- },
5516
- {
5517
- pubkey: getExtraMetasListPda(args.assetMint),
5518
- isWritable: false,
5519
- isSigner: false,
5520
- },
5521
- {
5522
- pubkey: getWalletIdentityAccountPda(args.assetMint, investor.toString()),
5523
- isWritable: false,
5524
- isSigner: false,
5525
- },
5526
- ])
5527
- .instruction();
5528
- });
5529
- }
5530
- /**
5531
- * Asynchronously remove a lock from InvestorLocks using RBAC authority.
5532
- * @param args - {@link RemoveTokenLockArgs}
5533
- * @param assetAccessController - RBAC AssetAccessController account.
5534
- * @param authorizedUserRole - Optional UserRole account. Required if user is not an admin.
5535
- * @returns A Promise that resolves to a transaction instruction.
5536
- * */
5537
- removeTokenLock(args, assetAccessController, authorizedUserRole) {
5538
- return __awaiter(this, void 0, void 0, function* () {
5539
- const assetController = getAssetControllerPda(args.assetMint);
5540
- const identityRegistry = getIdentityRegistryPda(args.assetMint);
5541
- const investorLocks = deriveInvestorLocks(args.investorId, identityRegistry);
5542
- const investor = deriveInvestorPda(args.investorId, identityRegistry);
5543
- const unlockedTokenAccount = getAssociatedTokenAddressSync(new PublicKey(args.assetMint), args.wallet, false, TOKEN_2022_PROGRAM_ID);
5544
- const controllerAuthority = deriveControllerAuthorityPda(assetAccessController);
5545
- return this.rbacProgram.methods
5546
- .removeTokenLock(Buffer.from(args.indices))
5547
- .accountsStrict({
5548
- user: args.signer,
5549
- controllerAuthority,
5550
- assetAccessController,
5551
- authorizedUserRole: authorizedUserRole || null,
5552
- tokenLocksProgram: TL_PROGRAM,
5553
- investorLocks,
5554
- investor,
5555
- identityAccount: getIdentityAccountPda(args.assetMint, investor.toString()),
5556
- walletIdentityAccount: getWalletIdentityAccountPda(args.assetMint, args.wallet.toString()),
5557
- assetMint: args.assetMint,
5558
- unlockedTokenAccount,
5559
- lockedTokenAccount: deriveLockedTokenAccount(args.investorId, identityRegistry),
5560
- assetController,
5561
- identityRegistry: getIdentityRegistryPda(args.assetMint),
5562
- assetControllerProgram: assetControllerProgramId,
5563
- tokenProgram: TOKEN_2022_PROGRAM_ID,
5564
- })
5565
- .remainingAccounts([
5566
- {
5567
- pubkey: getPolicyEnginePda(args.assetMint),
5568
- isWritable: true,
5569
- isSigner: false,
5570
- },
5571
- {
5572
- pubkey: identityRegistryProgramId,
5573
- isWritable: false,
5574
- isSigner: false,
5575
- },
5576
- {
5577
- pubkey: policyEngineProgramId,
5578
- isWritable: false,
5579
- isSigner: false,
5580
- },
5581
- {
5582
- pubkey: getIdentityRegistryPda(args.assetMint),
5583
- isWritable: false,
5584
- isSigner: false,
5585
- },
5586
- {
5587
- pubkey: getTrackerAccountPda(args.assetMint, investor.toString()),
5588
- isWritable: true,
5589
- isSigner: false,
5590
- },
5591
- {
5592
- pubkey: getExtraMetasListPda(args.assetMint),
5593
- isWritable: false,
5594
- isSigner: false,
5595
- },
5596
- {
5597
- pubkey: getWalletIdentityAccountPda(args.assetMint, investor.toString()),
5598
- isWritable: false,
5599
- isSigner: false,
5600
- },
5601
- ])
5602
- .instruction();
5603
- });
5604
- }
5605
- /**
5606
- * Asynchronously fetches a token account.
5607
- * @param account - Account to load.
5608
- * @returns A Promise that resolves to a token account.
5609
- * */
5610
- fetchTokenAccount(account_1) {
5611
- return __awaiter(this, arguments, void 0, function* (account, commitment = "processed") {
5612
- return getAccount(this.rwaClient.provider.connection, account, commitment, TOKEN_2022_PROGRAM_ID);
5613
- });
5614
- }
5615
- }
5616
-
5617
5036
  class RwaRbacClient {
5618
5037
  constructor(config, provider) {
5619
5038
  this.rwaClient = new RwaClient(config, provider);
@@ -5623,7 +5042,27 @@ class RwaRbacClient {
5623
5042
  this.policyEngine = new PolicyEngine(this.rwaClient, this.rbacProgram);
5624
5043
  this.identityRegistry = new IdentityRegistry(this.rwaClient, this.rbacProgram);
5625
5044
  this.identityMetadataRegistry = new IdentityMetadataRegistry(this.rwaClient, this.rbacProgram, new Program(imrIDL, this.provider));
5626
- this.tokenLocks = new TokenLocks(this.rwaClient, this.rbacProgram, new Program(tokenLocksIdl, this.provider));
5045
+ }
5046
+ /**
5047
+ * Parses inner instructions data field for array of events emitted by program using CPI Events.
5048
+ * @param ixs - Array of CompiledInstruction from a transaction inner instructions.
5049
+ * @returns Array of Events
5050
+ * */
5051
+ parseEvents(ixs) {
5052
+ const eventCoder = this.rbacProgram.coder.events;
5053
+ const events = ixs
5054
+ .map(({ data }) => {
5055
+ try {
5056
+ const buffer = Buffer.from(utils.bytes.bs58.decode(data));
5057
+ const event = eventCoder.decode(utils.bytes.base64.encode(buffer.slice(8)));
5058
+ return event;
5059
+ }
5060
+ catch (err) {
5061
+ console.error("Error decoding events", err);
5062
+ }
5063
+ })
5064
+ .filter((v) => v != null);
5065
+ return events;
5627
5066
  }
5628
5067
  /**
5629
5068
  * Asynchronously generates instruction to create AssetAccessController for an organization.
@@ -5734,6 +5173,8 @@ class RwaRbacClient {
5734
5173
  authorizedUserRole: args.authorizedUserRole || null,
5735
5174
  assetAccessController: args.assetAccessController,
5736
5175
  systemProgram: SystemProgram.programId,
5176
+ eventAuthority: getEventAuthority(RBAC_PROGRAM),
5177
+ program: RBAC_PROGRAM,
5737
5178
  })
5738
5179
  .instruction();
5739
5180
  });
@@ -5752,6 +5193,8 @@ class RwaRbacClient {
5752
5193
  userRole: args.userRole,
5753
5194
  authorizedUserRole: args.authorizedUserRole || null,
5754
5195
  assetAccessController: args.assetAccessController,
5196
+ eventAuthority: getEventAuthority(RBAC_PROGRAM),
5197
+ program: RBAC_PROGRAM,
5755
5198
  })
5756
5199
  .instruction();
5757
5200
  });
@@ -5785,4 +5228,4 @@ const computeFlags = (...flags) => {
5785
5228
  return flags.reduce((accumulator, flag) => accumulator | flag, 0);
5786
5229
  };
5787
5230
 
5788
- export { AdminFlags, AssetController, IMR_PROGRAM, IdentityMetadataRegistry, IdentityRegistry, MediciFlags, PolicyEngine, RBAC_PROGRAM, rwa_imr as RwaImrIdl, RwaRbacClient, rwa_rbac as RwaRbacIdl, TL_PROGRAM, TokenLocks, token_locks as TokenLocksIdl, computeFlags, deriveAssetAccessControllerPda, deriveControllerAuthorityPda, deriveInvestorLocks, deriveInvestorPda, deriveLockedTokenAccount, deriveUserRolePda };
5231
+ export { AdminFlags, AssetController, IMR_PROGRAM, IdentityMetadataRegistry, IdentityRegistry, MediciFlags, PolicyEngine, RBAC_PROGRAM, rwa_imr as RwaImrIdl, RwaRbacClient, rwa_rbac as RwaRbacIdl, TL_PROGRAM, computeFlags, deriveAssetAccessControllerPda, deriveControllerAuthorityPda, deriveInvestorLocks, deriveInvestorPda, deriveLockedTokenAccount, deriveUserRolePda, getEventAuthority };