@dstoken-solana/rwa-rbac 0.2.1 → 0.3.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.js CHANGED
@@ -55,98 +55,6 @@ var metadata$1 = {
55
55
  description: "Created with Anchor"
56
56
  };
57
57
  var instructions$1 = [
58
- {
59
- name: "add_level_to_identity_account",
60
- discriminator: [
61
- 102,
62
- 204,
63
- 64,
64
- 169,
65
- 252,
66
- 177,
67
- 192,
68
- 232
69
- ],
70
- accounts: [
71
- {
72
- name: "payer",
73
- writable: true,
74
- signer: true
75
- },
76
- {
77
- name: "user",
78
- signer: true
79
- },
80
- {
81
- name: "controller_authority",
82
- relations: [
83
- "asset_access_controller"
84
- ]
85
- },
86
- {
87
- name: "asset_access_controller",
88
- relations: [
89
- "authorized_user_role"
90
- ]
91
- },
92
- {
93
- name: "authorized_user_role",
94
- optional: true
95
- },
96
- {
97
- name: "identity_registry_program",
98
- address: "GZsnjqT3c5zbHqsctrJ4EG4rbEfo7ZXyyUG7aDJNmxfA"
99
- },
100
- {
101
- name: "identity_registry"
102
- },
103
- {
104
- name: "identity_account",
105
- writable: true
106
- },
107
- {
108
- name: "identity_account_owner",
109
- docs: [
110
- "to ensure that it is not an Investor account. If it is an Investor account,",
111
- "CPI to IdentityMetadataRegistry should be called."
112
- ]
113
- },
114
- {
115
- name: "system_program",
116
- address: "11111111111111111111111111111111"
117
- },
118
- {
119
- name: "policy_engine_program"
120
- },
121
- {
122
- name: "policy_engine",
123
- writable: true
124
- },
125
- {
126
- name: "tracker_account"
127
- },
128
- {
129
- name: "asset_mint"
130
- },
131
- {
132
- name: "event_authority"
133
- }
134
- ],
135
- args: [
136
- {
137
- name: "level",
138
- type: "u8"
139
- },
140
- {
141
- name: "expiry",
142
- type: "i64"
143
- },
144
- {
145
- name: "enforce_limits",
146
- type: "bool"
147
- }
148
- ]
149
- },
150
58
  {
151
59
  name: "add_levels",
152
60
  discriminator: [
@@ -1250,6 +1158,12 @@ var instructions$1 = [
1250
1158
  {
1251
1159
  name: "identity_registry"
1252
1160
  },
1161
+ {
1162
+ name: "token_account"
1163
+ },
1164
+ {
1165
+ name: "asset_mint"
1166
+ },
1253
1167
  {
1254
1168
  name: "event_authority"
1255
1169
  }
@@ -1471,63 +1385,6 @@ var instructions$1 = [
1471
1385
  }
1472
1386
  ]
1473
1387
  },
1474
- {
1475
- name: "refresh_level_to_identity_account",
1476
- discriminator: [
1477
- 23,
1478
- 68,
1479
- 237,
1480
- 111,
1481
- 144,
1482
- 169,
1483
- 239,
1484
- 91
1485
- ],
1486
- accounts: [
1487
- {
1488
- name: "payer",
1489
- writable: true,
1490
- signer: true
1491
- },
1492
- {
1493
- name: "user",
1494
- signer: true
1495
- },
1496
- {
1497
- name: "controller_authority",
1498
- relations: [
1499
- "asset_access_controller"
1500
- ]
1501
- },
1502
- {
1503
- name: "asset_access_controller",
1504
- relations: [
1505
- "authorized_user_role"
1506
- ]
1507
- },
1508
- {
1509
- name: "authorized_user_role",
1510
- optional: true
1511
- },
1512
- {
1513
- name: "identity_registry_program",
1514
- address: "GZsnjqT3c5zbHqsctrJ4EG4rbEfo7ZXyyUG7aDJNmxfA"
1515
- },
1516
- {
1517
- name: "identity_registry"
1518
- },
1519
- {
1520
- name: "identity_account",
1521
- writable: true
1522
- }
1523
- ],
1524
- args: [
1525
- {
1526
- name: "cpi_data",
1527
- type: "bytes"
1528
- }
1529
- ]
1530
- },
1531
1388
  {
1532
1389
  name: "register_investor",
1533
1390
  discriminator: [
@@ -1753,90 +1610,6 @@ var instructions$1 = [
1753
1610
  args: [
1754
1611
  ]
1755
1612
  },
1756
- {
1757
- name: "remove_level_from_identity_account",
1758
- discriminator: [
1759
- 194,
1760
- 231,
1761
- 187,
1762
- 54,
1763
- 197,
1764
- 136,
1765
- 170,
1766
- 55
1767
- ],
1768
- accounts: [
1769
- {
1770
- name: "payer",
1771
- writable: true,
1772
- signer: true
1773
- },
1774
- {
1775
- name: "user",
1776
- signer: true
1777
- },
1778
- {
1779
- name: "controller_authority",
1780
- relations: [
1781
- "asset_access_controller"
1782
- ]
1783
- },
1784
- {
1785
- name: "asset_access_controller",
1786
- relations: [
1787
- "authorized_user_role"
1788
- ]
1789
- },
1790
- {
1791
- name: "authorized_user_role",
1792
- optional: true
1793
- },
1794
- {
1795
- name: "identity_registry_program",
1796
- address: "GZsnjqT3c5zbHqsctrJ4EG4rbEfo7ZXyyUG7aDJNmxfA"
1797
- },
1798
- {
1799
- name: "identity_registry"
1800
- },
1801
- {
1802
- name: "identity_account",
1803
- writable: true
1804
- },
1805
- {
1806
- name: "identity_account_owner",
1807
- docs: [
1808
- "to ensure that it is not an Investor account. If it is an Investor account,",
1809
- "CPI to IdentityMetadataRegistry should be called."
1810
- ]
1811
- },
1812
- {
1813
- name: "system_program",
1814
- address: "11111111111111111111111111111111"
1815
- },
1816
- {
1817
- name: "policy_engine_program"
1818
- },
1819
- {
1820
- name: "policy_engine",
1821
- writable: true
1822
- },
1823
- {
1824
- name: "tracker_account"
1825
- },
1826
- {
1827
- name: "asset_mint"
1828
- },
1829
- {
1830
- name: "event_authority"
1831
- }
1832
- ],
1833
- args: [
1834
- {
1835
- name: "cpi_data",
1836
- type: "bytes"
1837
- }
1838
- ]
1839
- },
1840
1613
  {
1841
1614
  name: "remove_levels",
1842
1615
  discriminator: [
@@ -3933,16 +3706,6 @@ class AssetController {
3933
3706
  .instruction();
3934
3707
  });
3935
3708
  }
3936
- /**
3937
- * Asynchronously generates instructions to revoke assets.
3938
- * @param args - {@link VoidTokensArgs}
3939
- * @returns A Promise that resolves to the instructions to revoke assets.
3940
- */
3941
- voidTokenIxns(args) {
3942
- return __awaiter(this, void 0, void 0, function* () {
3943
- return this.rwaClient.assetController.voidTokenIxns(args);
3944
- });
3945
- }
3946
3709
  /**
3947
3710
  * Executes a token transfer.
3948
3711
  * @param args - {@link TransferTokensArgs}
@@ -4013,13 +3776,13 @@ class AssetController {
4013
3776
  /**
4014
3777
  * Asynchronously generates instructions to revoke tokens from a user.
4015
3778
  * @param args - {@link RevokeTokensArgs}
4016
- * @param payer - Payer public key.
4017
3779
  * @param signer - User signer public key.
4018
3780
  * @param assetAccessController - RBAC AssetAccessController account.
3781
+ * @param investorId - Optional investorId. Required if user is not an investor.
4019
3782
  * @param authorizedUserRole - Optional UserRole account. Required if user is not an admin.
4020
3783
  * @returns A Promise that resolves to the instructions to revoke.
4021
3784
  */
4022
- revokeTokenIxn(args, investorId, signer, assetAccessController, authorizedUserRole) {
3785
+ revokeTokenIxn(args, signer, assetAccessController, investorId, authorizedUserRole) {
4023
3786
  return __awaiter(this, void 0, void 0, function* () {
4024
3787
  if (!args.wallet) {
4025
3788
  throw new Error("Use wallet arg for wallet to revoke tokens from.");
@@ -4028,7 +3791,7 @@ class AssetController {
4028
3791
  args.owner = args.wallet;
4029
3792
  const revokeIx = yield rwaTokenSdk.getRevokeTokensIx(args, this.rwaClient.provider);
4030
3793
  const identityRegistry = rwaTokenSdk.getIdentityRegistryPda(args.assetMint);
4031
- const investorPda = deriveInvestorPda(investorId, identityRegistry);
3794
+ const investorPda = investorId ? deriveInvestorPda(investorId, identityRegistry) : null;
4032
3795
  const ixData = revokeIx.data;
4033
3796
  const assetController = rwaTokenSdk.getAssetControllerPda(args.assetMint);
4034
3797
  const revokeTokenAccount = splToken.getAssociatedTokenAddressSync(new web3_js.PublicKey(args.assetMint), new web3_js.PublicKey(args.wallet), false, splToken.TOKEN_2022_PROGRAM_ID);
@@ -4044,8 +3807,8 @@ class AssetController {
4044
3807
  assetController,
4045
3808
  revokeTokenAccount,
4046
3809
  identityRegistry,
4047
- identityAccount: rwaTokenSdk.getIdentityAccountPda(args.assetMint, investorPda.toString()),
4048
- trackerAccount: rwaTokenSdk.getTrackerAccountPda(args.assetMint, investorPda.toString()),
3810
+ identityAccount: rwaTokenSdk.getIdentityAccountPda(args.assetMint, investorId ? investorPda.toString() : args.owner),
3811
+ trackerAccount: rwaTokenSdk.getTrackerAccountPda(args.assetMint, investorId ? investorPda.toString() : args.owner),
4049
3812
  policyEngineProgram: rwaTokenSdk.policyEngineProgramId,
4050
3813
  policyEngine: rwaTokenSdk.getPolicyEnginePda(args.assetMint),
4051
3814
  walletIdentityAccount: rwaTokenSdk.getWalletIdentityAccountPda(args.assetMint, args.wallet),
@@ -4533,112 +4296,6 @@ class IdentityRegistry {
4533
4296
  return returnIx;
4534
4297
  });
4535
4298
  }
4536
- /**
4537
- * Asynchronously update a non-investor user identity account level.
4538
- * @param args - {@link AddLevelToIdentityAccountArgs}
4539
- * @param assetAccessController - RBAC AssetAccessController account.
4540
- * @param authorizedUserRole - Optional UserRole account. Required if user is not an admin.
4541
- * @returns A Promise that resolves to the instructions to update user account identity.
4542
- * */
4543
- addIdentityLevelToUserAccount(args, assetAccessController, authorizedUserRole) {
4544
- return __awaiter(this, void 0, void 0, function* () {
4545
- var _a;
4546
- const identityAccount = rwaTokenSdk.getIdentityAccountPda(args.assetMint, args.owner);
4547
- const controllerAuthority = deriveControllerAuthorityPda(assetAccessController);
4548
- return this.rbacProgram.methods
4549
- .addLevelToIdentityAccount(args.levels[0], args.expiries[0], (_a = args.ignorePolicy) !== null && _a !== void 0 ? _a : false)
4550
- .accountsStrict({
4551
- payer: args.payer,
4552
- user: args.signer,
4553
- controllerAuthority,
4554
- assetAccessController,
4555
- authorizedUserRole: authorizedUserRole || null,
4556
- identityRegistryProgram: rwaTokenSdk.identityRegistryProgramId,
4557
- identityRegistry: rwaTokenSdk.getIdentityRegistryPda(args.assetMint),
4558
- identityAccount,
4559
- identityAccountOwner: args.owner,
4560
- systemProgram: web3_js.SystemProgram.programId,
4561
- policyEngineProgram: rwaTokenSdk.policyEngineProgramId,
4562
- policyEngine: rwaTokenSdk.getPolicyEnginePda(args.assetMint),
4563
- trackerAccount: rwaTokenSdk.getTrackerAccountPda(args.assetMint, args.owner),
4564
- assetMint: args.assetMint,
4565
- eventAuthority: rwaTokenSdk.getIdentityRegistryEventAuthority(),
4566
- })
4567
- .instruction();
4568
- });
4569
- }
4570
- /**
4571
- * Asynchronously reduces a non-Investor user identity account level.
4572
- * @param args - {@link RemoveLevelFromIdentityAccount}
4573
- * @param assetAccessController - RBAC AssetAccessController account.
4574
- * @param authorizedUserRole - Optional UserRole account. Required if user is not an admin.
4575
- * @returns A Promise that resolves to the instructions to reduce the level of a user identity account.
4576
- */
4577
- removeIdentityLevelFromUserAccount(args, assetAccessController, authorizedUserRole) {
4578
- return __awaiter(this, void 0, void 0, function* () {
4579
- const removeLevelIx = yield rwaTokenSdk.getRemoveLevelFromIdentityAccount(args, this.rwaClient.provider);
4580
- const ixData = removeLevelIx.data;
4581
- const controllerAuthority = deriveControllerAuthorityPda(assetAccessController);
4582
- const identityAccount = rwaTokenSdk.getIdentityAccountPda(args.assetMint, args.owner);
4583
- return this.rbacProgram.methods
4584
- .removeLevelFromIdentityAccount(ixData)
4585
- .accountsStrict({
4586
- payer: args.payer,
4587
- user: args.signer,
4588
- controllerAuthority,
4589
- assetAccessController,
4590
- authorizedUserRole: authorizedUserRole || null,
4591
- identityRegistryProgram: rwaTokenSdk.identityRegistryProgramId,
4592
- identityRegistry: rwaTokenSdk.getIdentityRegistryPda(args.assetMint),
4593
- identityAccount,
4594
- identityAccountOwner: args.owner,
4595
- systemProgram: web3_js.SystemProgram.programId,
4596
- policyEngineProgram: rwaTokenSdk.policyEngineProgramId,
4597
- policyEngine: rwaTokenSdk.getPolicyEnginePda(args.assetMint),
4598
- trackerAccount: rwaTokenSdk.getTrackerAccountPda(args.assetMint, args.owner),
4599
- assetMint: args.assetMint,
4600
- eventAuthority: rwaTokenSdk.getIdentityRegistryEventAuthority(),
4601
- })
4602
- .instruction();
4603
- });
4604
- }
4605
- /**
4606
- * Asynchronously generates instruction to refresh expiry on an Identity Account level.
4607
- * @param args - {@link RefreshLevelArgs}
4608
- * @param assetAccessController - RBAC AssetAccessController account.
4609
- * @param authorizedUserRole - Optional UserRole account. Required if user is not an admin.
4610
- * @returns A Promise that resolves to refresh expiry on an Identity Account level.
4611
- * */
4612
- refreshLevelToIdentityAccountIxn(args, assetAccessController, authorizedUserRole) {
4613
- return __awaiter(this, void 0, void 0, function* () {
4614
- const identityProgram = rwaTokenSdk.getIdentityRegistryProgram(this.rwaClient.provider);
4615
- const identityRegistry = rwaTokenSdk.getIdentityRegistryPda(args.assetMint);
4616
- const identityAccount = rwaTokenSdk.getIdentityAccountPda(args.assetMint, args.owner);
4617
- const controllerAuthority = deriveControllerAuthorityPda(assetAccessController);
4618
- const refreshIx = yield identityProgram.methods
4619
- .refreshLevelToIdentityAccount(args.level, args.expiry)
4620
- .accountsStrict({
4621
- payer: args.payer,
4622
- signer: controllerAuthority,
4623
- identityRegistry,
4624
- identityAccount,
4625
- })
4626
- .instruction();
4627
- return this.rbacProgram.methods
4628
- .refreshLevelToIdentityAccount(refreshIx.data)
4629
- .accountsStrict({
4630
- payer: args.payer,
4631
- user: args.signer,
4632
- controllerAuthority,
4633
- assetAccessController,
4634
- authorizedUserRole: authorizedUserRole || null,
4635
- identityRegistryProgram: rwaTokenSdk.identityRegistryProgramId,
4636
- identityRegistry,
4637
- identityAccount,
4638
- })
4639
- .instruction();
4640
- });
4641
- }
4642
4299
  /**
4643
4300
  * Asynchronously generates instruction to attach wallet to identity.
4644
4301
  * @param args - {@link AttachDetachWalletArgs}
@@ -4701,6 +4358,7 @@ class IdentityRegistry {
4701
4358
  const identityRegistry = rwaTokenSdk.getIdentityRegistryPda(args.assetMint);
4702
4359
  const identityAccount = rwaTokenSdk.getIdentityAccountPda(args.assetMint, args.owner);
4703
4360
  const walletIdentity = rwaTokenSdk.getWalletIdentityAccountPda(args.assetMint, args.wallet.toString());
4361
+ const tokenAccount = splToken.getAssociatedTokenAddressSync(new web3_js.PublicKey(args.assetMint), new web3_js.PublicKey(args.wallet), false, splToken.TOKEN_2022_PROGRAM_ID);
4704
4362
  const ix = yield identityProgram.methods
4705
4363
  .detachWalletFromIdentity()
4706
4364
  .accountsStrict({
@@ -4711,6 +4369,8 @@ class IdentityRegistry {
4711
4369
  identityRegistry,
4712
4370
  eventAuthority: rwaTokenSdk.getIdentityRegistryEventAuthority(),
4713
4371
  program: rwaTokenSdk.identityRegistryProgramId,
4372
+ tokenAccount: tokenAccount,
4373
+ assetMint: args.assetMint,
4714
4374
  })
4715
4375
  .instruction();
4716
4376
  return this.rbacProgram.methods
@@ -4726,6 +4386,8 @@ class IdentityRegistry {
4726
4386
  identityAccount,
4727
4387
  identityRegistry,
4728
4388
  eventAuthority: rwaTokenSdk.getIdentityRegistryEventAuthority(),
4389
+ tokenAccount: tokenAccount,
4390
+ assetMint: args.assetMint,
4729
4391
  })
4730
4392
  .instruction();
4731
4393
  });