@story-protocol/core-sdk 0.0.1-beta-rc.4 → 0.0.1-beta-rc.6

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.
Files changed (34) hide show
  1. package/README.md +97 -43
  2. package/dist/declarations/src/client.d.ts +31 -7
  3. package/dist/declarations/src/client.d.ts.map +1 -1
  4. package/dist/declarations/src/constants/common.d.ts +1 -0
  5. package/dist/declarations/src/constants/common.d.ts.map +1 -1
  6. package/dist/declarations/src/index.d.ts +2 -3
  7. package/dist/declarations/src/index.d.ts.map +1 -1
  8. package/dist/declarations/src/resources/dispute.d.ts +0 -20
  9. package/dist/declarations/src/resources/dispute.d.ts.map +1 -1
  10. package/dist/declarations/src/resources/ipAccount.d.ts +732 -0
  11. package/dist/declarations/src/resources/{tagging.d.ts.map → ipAccount.d.ts.map} +1 -1
  12. package/dist/declarations/src/resources/ipAsset.d.ts +53 -36
  13. package/dist/declarations/src/resources/ipAsset.d.ts.map +1 -1
  14. package/dist/declarations/src/resources/license.d.ts +44 -41
  15. package/dist/declarations/src/resources/license.d.ts.map +1 -1
  16. package/dist/declarations/src/resources/permission.d.ts +3 -43
  17. package/dist/declarations/src/resources/permission.d.ts.map +1 -1
  18. package/dist/declarations/src/resources/policy.d.ts +99 -82
  19. package/dist/declarations/src/resources/policy.d.ts.map +1 -1
  20. package/dist/declarations/src/types/resources/ipAccount.d.ts +25 -0
  21. package/dist/declarations/src/types/resources/ipAccount.d.ts.map +1 -0
  22. package/dist/declarations/src/types/resources/ipAsset.d.ts +5 -5
  23. package/dist/declarations/src/types/resources/ipAsset.d.ts.map +1 -1
  24. package/dist/declarations/src/types/resources/permission.d.ts +3 -3
  25. package/dist/declarations/src/types/resources/permission.d.ts.map +1 -1
  26. package/dist/declarations/src/types/resources/policy.d.ts +39 -1
  27. package/dist/declarations/src/types/resources/policy.d.ts.map +1 -1
  28. package/dist/story-protocol-core-sdk.cjs.dev.js +734 -285
  29. package/dist/story-protocol-core-sdk.cjs.prod.js +734 -285
  30. package/dist/story-protocol-core-sdk.esm.js +736 -286
  31. package/package.json +1 -1
  32. package/dist/declarations/src/resources/tagging.d.ts +0 -718
  33. package/dist/declarations/src/types/resources/tagging.d.ts +0 -23
  34. package/dist/declarations/src/types/resources/tagging.d.ts.map +0 -1
@@ -1,4 +1,4 @@
1
- import { getAddress, decodeEventLog, encodeAbiParameters, parseAbiParameters, encodeFunctionData, zeroAddress, stringToHex, createPublicClient, createWalletClient } from 'viem';
1
+ import { getAddress, encodeAbiParameters, parseAbiParameters, decodeEventLog, encodeFunctionData, zeroAddress, stringToHex, createPublicClient, createWalletClient } from 'viem';
2
2
  import * as dotenv from 'dotenv';
3
3
  import { polygonMumbai, sepolia as sepolia$1, mainnet } from 'viem/chains';
4
4
  import axios from 'axios';
@@ -420,6 +420,10 @@ function handleError(error, msg) {
420
420
  throw new Error("".concat(msg, ": Unknown error type"));
421
421
  }
422
422
 
423
+ var AddressZero = "0x0000000000000000000000000000000000000000";
424
+ var HashZero = "0x0000000000000000000000000000000000000000000000000000000000000000";
425
+ var SepoliaChainId = "11155111";
426
+
423
427
  function _arrayLikeToArray(arr, len) {
424
428
  if (len == null || len > arr.length) len = arr.length;
425
429
  for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
@@ -791,6 +795,42 @@ var IPAssetRegistryABI = [{
791
795
  }],
792
796
  name: "IPRegistered",
793
797
  type: "event"
798
+ }, {
799
+ inputs: [{
800
+ internalType: "uint256",
801
+ name: "chainId",
802
+ type: "uint256"
803
+ }, {
804
+ internalType: "address",
805
+ name: "tokenContract",
806
+ type: "address"
807
+ }, {
808
+ internalType: "uint256",
809
+ name: "tokenId",
810
+ type: "uint256"
811
+ }],
812
+ name: "ipId",
813
+ outputs: [{
814
+ internalType: "address",
815
+ name: "",
816
+ type: "address"
817
+ }],
818
+ stateMutability: "view",
819
+ type: "function"
820
+ }, {
821
+ inputs: [{
822
+ internalType: "address",
823
+ name: "id",
824
+ type: "address"
825
+ }],
826
+ name: "isRegistered",
827
+ outputs: [{
828
+ internalType: "bool",
829
+ name: "",
830
+ type: "bool"
831
+ }],
832
+ stateMutability: "view",
833
+ type: "function"
794
834
  }];
795
835
 
796
836
  var LicensingModuleABI = [{
@@ -901,6 +941,49 @@ var LicensingModuleABI = [{
901
941
  }],
902
942
  stateMutability: "nonpayable",
903
943
  type: "function"
944
+ }, {
945
+ inputs: [{
946
+ components: [{
947
+ internalType: "bool",
948
+ name: "isLicenseTransferable",
949
+ type: "bool"
950
+ }, {
951
+ internalType: "address",
952
+ name: "policyFramework",
953
+ type: "address"
954
+ }, {
955
+ internalType: "bytes",
956
+ name: "frameworkData",
957
+ type: "bytes"
958
+ }, {
959
+ internalType: "address",
960
+ name: "royaltyPolicy",
961
+ type: "address"
962
+ }, {
963
+ internalType: "bytes",
964
+ name: "royaltyData",
965
+ type: "bytes"
966
+ }, {
967
+ internalType: "uint256",
968
+ name: "mintingFee",
969
+ type: "uint256"
970
+ }, {
971
+ internalType: "address",
972
+ name: "mintingFeeToken",
973
+ type: "address"
974
+ }],
975
+ internalType: "struct Licensing.Policy",
976
+ name: "pol",
977
+ type: "tuple"
978
+ }],
979
+ name: "getPolicyId",
980
+ outputs: [{
981
+ internalType: "uint256",
982
+ name: "policyId",
983
+ type: "uint256"
984
+ }],
985
+ stateMutability: "view",
986
+ type: "function"
904
987
  }, {
905
988
  inputs: [{
906
989
  internalType: "uint256[]",
@@ -1154,44 +1237,6 @@ var RegistrationModuleABI = [{
1154
1237
  type: "function"
1155
1238
  }];
1156
1239
 
1157
- var TaggingModuleABI = [{
1158
- inputs: [{
1159
- internalType: "string",
1160
- name: "tag",
1161
- type: "string"
1162
- }, {
1163
- internalType: "address",
1164
- name: "ipId",
1165
- type: "address"
1166
- }],
1167
- name: "removeTag",
1168
- outputs: [{
1169
- internalType: "bool",
1170
- name: "removed",
1171
- type: "bool"
1172
- }],
1173
- stateMutability: "nonpayable",
1174
- type: "function"
1175
- }, {
1176
- inputs: [{
1177
- internalType: "string",
1178
- name: "tag",
1179
- type: "string"
1180
- }, {
1181
- internalType: "address",
1182
- name: "ipId",
1183
- type: "address"
1184
- }],
1185
- name: "setTag",
1186
- outputs: [{
1187
- internalType: "bool",
1188
- name: "added",
1189
- type: "bool"
1190
- }],
1191
- stateMutability: "nonpayable",
1192
- type: "function"
1193
- }];
1194
-
1195
1240
  var ErrorsABI = [{
1196
1241
  inputs: [{
1197
1242
  internalType: "address",
@@ -1840,51 +1885,31 @@ var ErrorsABI = [{
1840
1885
  inputs: [],
1841
1886
  name: "RoyaltyPolicyLAP__ZeroRoyaltyModule",
1842
1887
  type: "error"
1843
- }, {
1844
- inputs: [],
1845
- name: "TaggingModule__DstIpIdDoesNotHaveDstTag",
1846
- type: "error"
1847
- }, {
1848
- inputs: [],
1849
- name: "TaggingModule__InvalidRelationTypeName",
1850
- type: "error"
1851
- }, {
1852
- inputs: [],
1853
- name: "TaggingModule__RelationTypeAlreadyExists",
1854
- type: "error"
1855
- }, {
1856
- inputs: [],
1857
- name: "TaggingModule__RelationTypeDoesNotExist",
1858
- type: "error"
1859
- }, {
1860
- inputs: [],
1861
- name: "TaggingModule__SrcIpIdDoesNotHaveSrcTag",
1862
- type: "error"
1863
1888
  }];
1864
1889
 
1865
1890
  var sepolia = {
1866
- AccessController: "0x31dd83a3FebB5fAD7F7bc8D4E05B623461B74a02",
1867
- AncestorsVaultLAP: "0x9Faa4E491a211bFa415d44554120B1b31b6f4e59",
1868
- ArbitrationPolicySP: "0x75e181d5eb307eCccf8d3b4724109eca14719A75",
1869
- DisputeModule: "0x11dAA3F573C4d6673BBE7f2D96B4C91073A0d55d",
1870
- Governance: "0xa18252Aa11Ff1B20b89C10109050CC46A4067b22",
1871
- IPAccountImpl: "0x7BBaB2BD68fd3990c8dA2c26334a6DF8Acc7E96E",
1872
- IPAccountRegistry: "0x7184bAdAdf24dc261C7C27BceFF53d7A25a06846",
1873
- IPAssetRegistry: "0xF59adB67B7CC87436A7CC41040A7dB24AE90aDB8",
1874
- IPAssetRenderer: "0x986d8E96b30b688FCD84e9A5A757C3d4304B47b6",
1875
- IPMetadataProvider: "0xfcD468A72F76e89F2Df517274063ef7210a32e2A",
1876
- IPResolver: "0xF0920314Fb4C375cdEB5b15c4e77277aCf36E3D7",
1877
- LicenseRegistry: "0x4D6a54B467332dF675cFa689cb294A4cB9122866",
1878
- LicensingModule: "0x0C72b24067a15994f91D92Fd9bA23eB5ebcF8378",
1879
- MockERC20: "0xd53C2A80D24F6B3Ff009E48CF88D3b482E8E1457",
1880
- MockERC721: "0xD3719824a768c139AAa7C5eFc8BDb5D1d13A1564",
1881
- MockTokenGatedHook: "0x2d3ED4354eD09B0E6aa252938aEF41920aB6FC40",
1882
- ModuleRegistry: "0x17Ad1cD06d44ae5F5480A675A4D8BD8DAED40410",
1883
- PILPolicyFrameworkManager: "0x49cF5C5523011F8B4A0489969096Eb68C571C197",
1884
- RegistrationModule: "0x248c8CbF469ec7CB22Dc9914E569920b93d717a3",
1885
- RoyaltyModule: "0x512bbF310452cC96E0E9818B0870EcA557b86d4D",
1886
- RoyaltyPolicyLAP: "0x8404061350BA0CA85c4E733B0be78c5519679003",
1887
- TaggingModule: "0xED445f1DeE74Cf470Aab47F4b63734653C4C9537"
1891
+ AccessController: "0x8eB53745795E2107E3568c647A77a7294C89Ef31",
1892
+ AncestorsVaultLAP: "0x7FD793C4914da052022524BA17508976733B09AA",
1893
+ ArbitrationPolicySP: "0xFfE389378AFa13D91485182D72700d226Cb0db16",
1894
+ DisputeModule: "0xe94d7198EF5657C15be755aC3D9cb386F2Db50Bd",
1895
+ Governance: "0x14Ac96796aadef6053e993aBDc3C1e7830ede901",
1896
+ IPAccountImpl: "0xec3F947902fac41e59aa25669Fe39997BFA1357c",
1897
+ IPAccountRegistry: "0xfe3ef84acECAd1F91583CB09E62953669C1c2bb5",
1898
+ IPAssetRegistry: "0xA3a77482C64e91d4C89114D83Bd51457132ea947",
1899
+ IPAssetRenderer: "0xF36c279a61b32D39e5Bc25e317f779362Be07E1d",
1900
+ IPMetadataProvider: "0x40D52438C3852A872c71eB3a8b81d6274C5b6274",
1901
+ IPResolver: "0x8BcE3019dBe94402A0276A2630373CDDB67fe271",
1902
+ LicenseRegistry: "0x176d33Cc80ed3390256033bbf7Fd651c9C5A364F",
1903
+ LicensingModule: "0x9CDDD88Dd34429a0F39eaDf91a56D1bf0533E72B",
1904
+ MockERC20: "0x1219A0E87e617E6560104fA11cfd4f01FeB47362",
1905
+ MockERC721: "0x9d790FF5B6A7469f32f18E677E15D48b86C6839b",
1906
+ MockTokenGatedHook: "0x25018B7521E7607A7101302401bE81eDCA2E9730",
1907
+ ModuleRegistry: "0x6E09516f10a4094b9B9A8C2b7Aa611A2D7827d3F",
1908
+ PILPolicyFrameworkManager: "0x50c3bCAA67D4eC3f285E4328451315Ab0D9e539f",
1909
+ RegistrationModule: "0x8b3f6b736b520F69c37a575293D3c1ff6383D495",
1910
+ RoyaltyModule: "0x833774B42357939B4c96e1bCF5cE26e815AE3Ae6",
1911
+ RoyaltyPolicyLAP: "0xda483fd6e6ecA1C2D913802F9a6B57a83b73029f",
1912
+ TokenWithdrawalModule: "0x01469702E71F5C8199A15a97e8147D002C60a0B9"
1888
1913
  };
1889
1914
 
1890
1915
  var IPAccountABI = [].concat(_toConsumableArray(IPAccountImplABI), _toConsumableArray(ErrorsABI));
@@ -1912,14 +1937,13 @@ var RegistrationModuleConfig = {
1912
1937
  abi: [].concat(_toConsumableArray(RegistrationModuleABI), _toConsumableArray(ErrorsABI)),
1913
1938
  address: getAddress(sepolia.RegistrationModule)
1914
1939
  };
1915
- var TaggingModuleConfig = {
1916
- abi: [].concat(_toConsumableArray(TaggingModuleABI), _toConsumableArray(ErrorsABI)),
1917
- address: getAddress(sepolia.TaggingModule)
1918
- };
1919
1940
  var PILPolicyFrameworkManagerConfig = {
1920
1941
  abi: [].concat(_toConsumableArray(PILPolicyFrameworkManagerABI), _toConsumableArray(ErrorsABI)),
1921
1942
  address: getAddress(sepolia.PILPolicyFrameworkManager)
1922
1943
  };
1944
+ var RoyaltyPolicyLAPConfig = {
1945
+ address: getAddress(sepolia.RoyaltyPolicyLAP)
1946
+ };
1923
1947
 
1924
1948
  function _createForOfIteratorHelper(o, allowArrayLike) {
1925
1949
  var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
@@ -2078,112 +2102,6 @@ function chainStringToViemChain(chainId) {
2078
2102
  }
2079
2103
  }
2080
2104
 
2081
- var TaggingClient = /*#__PURE__*/function () {
2082
- function TaggingClient(rpcClient, wallet) {
2083
- _classCallCheck(this, TaggingClient);
2084
- _defineProperty(this, "taggingModuleConfig", TaggingModuleConfig);
2085
- this.rpcClient = rpcClient;
2086
- this.wallet = wallet;
2087
- }
2088
- _createClass(TaggingClient, [{
2089
- key: "setTag",
2090
- value: function () {
2091
- var _setTag = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
2092
- var _request$txOptions, _yield$this$rpcClient, call, txHash;
2093
- return _regeneratorRuntime().wrap(function _callee$(_context) {
2094
- while (1) switch (_context.prev = _context.next) {
2095
- case 0:
2096
- _context.prev = 0;
2097
- _context.next = 3;
2098
- return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.taggingModuleConfig), {}, {
2099
- functionName: "setTag",
2100
- args: [request.tag, request.ipId]
2101
- }));
2102
- case 3:
2103
- _yield$this$rpcClient = _context.sent;
2104
- call = _yield$this$rpcClient.request;
2105
- _context.next = 7;
2106
- return this.wallet.writeContract(call);
2107
- case 7:
2108
- txHash = _context.sent;
2109
- if (!((_request$txOptions = request.txOptions) !== null && _request$txOptions !== void 0 && _request$txOptions.waitForTransaction)) {
2110
- _context.next = 11;
2111
- break;
2112
- }
2113
- _context.next = 11;
2114
- return waitTx(this.rpcClient, txHash);
2115
- case 11:
2116
- return _context.abrupt("return", {
2117
- txHash: txHash
2118
- });
2119
- case 14:
2120
- _context.prev = 14;
2121
- _context.t0 = _context["catch"](0);
2122
- handleError(_context.t0, "Failed to set tag");
2123
- case 17:
2124
- case "end":
2125
- return _context.stop();
2126
- }
2127
- }, _callee, this, [[0, 14]]);
2128
- }));
2129
- function setTag(_x) {
2130
- return _setTag.apply(this, arguments);
2131
- }
2132
- return setTag;
2133
- }()
2134
- }, {
2135
- key: "removeTag",
2136
- value: function () {
2137
- var _removeTag = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
2138
- var _request$txOptions2, _yield$this$rpcClient2, call, txHash;
2139
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
2140
- while (1) switch (_context2.prev = _context2.next) {
2141
- case 0:
2142
- _context2.prev = 0;
2143
- _context2.next = 3;
2144
- return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.taggingModuleConfig), {}, {
2145
- functionName: "removeTag",
2146
- args: [request.tag, request.ipId]
2147
- }));
2148
- case 3:
2149
- _yield$this$rpcClient2 = _context2.sent;
2150
- call = _yield$this$rpcClient2.request;
2151
- _context2.next = 7;
2152
- return this.wallet.writeContract(call);
2153
- case 7:
2154
- txHash = _context2.sent;
2155
- if (!((_request$txOptions2 = request.txOptions) !== null && _request$txOptions2 !== void 0 && _request$txOptions2.waitForTransaction)) {
2156
- _context2.next = 11;
2157
- break;
2158
- }
2159
- _context2.next = 11;
2160
- return waitTx(this.rpcClient, txHash);
2161
- case 11:
2162
- return _context2.abrupt("return", {
2163
- txHash: txHash
2164
- });
2165
- case 14:
2166
- _context2.prev = 14;
2167
- _context2.t0 = _context2["catch"](0);
2168
- handleError(_context2.t0, "Failed to remove tag");
2169
- case 17:
2170
- case "end":
2171
- return _context2.stop();
2172
- }
2173
- }, _callee2, this, [[0, 14]]);
2174
- }));
2175
- function removeTag(_x2) {
2176
- return _removeTag.apply(this, arguments);
2177
- }
2178
- return removeTag;
2179
- }()
2180
- }]);
2181
- return TaggingClient;
2182
- }();
2183
-
2184
- var AddressZero = "0x0000000000000000000000000000000000000000";
2185
- var HashZero = "0x0000000000000000000000000000000000000000000000000000000000000000";
2186
-
2187
2105
  function computeRoyaltyContext(_x, _x2) {
2188
2106
  return _computeRoyaltyContext.apply(this, arguments);
2189
2107
  }
@@ -2294,56 +2212,68 @@ var IPAssetClient = /*#__PURE__*/function () {
2294
2212
  key: "registerRootIp",
2295
2213
  value: function () {
2296
2214
  var _registerRootIp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
2297
- var _request$txOptions, _yield$this$rpcClient, call, txHash, targetLog;
2215
+ var _request$txOptions, ipId, _yield$this$rpcClient, call, txHash, targetLog;
2298
2216
  return _regeneratorRuntime().wrap(function _callee$(_context) {
2299
2217
  while (1) switch (_context.prev = _context.next) {
2300
2218
  case 0:
2301
2219
  _context.prev = 0;
2302
2220
  _context.next = 3;
2221
+ return this.isNFTRegistered(SepoliaChainId, request.tokenContractAddress, request.tokenId);
2222
+ case 3:
2223
+ ipId = _context.sent;
2224
+ if (!ipId) {
2225
+ _context.next = 6;
2226
+ break;
2227
+ }
2228
+ return _context.abrupt("return", {
2229
+ ipId: ipId
2230
+ });
2231
+ case 6:
2232
+ _context.next = 8;
2303
2233
  return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.registrationModuleConfig), {}, {
2304
2234
  functionName: "registerRootIp",
2305
- args: [parseToBigInt(request.policyId), getAddress(request.tokenContractAddress),
2235
+ args: [parseToBigInt(request.policyId || "0"), getAddress(request.tokenContractAddress),
2306
2236
  // 0x Address
2307
2237
  parseToBigInt(request.tokenId), request.ipName || "", request.contentHash || HashZero, request.uri || ""],
2308
2238
  account: this.wallet.account
2309
2239
  }));
2310
- case 3:
2240
+ case 8:
2311
2241
  _yield$this$rpcClient = _context.sent;
2312
2242
  call = _yield$this$rpcClient.request;
2313
- _context.next = 7;
2243
+ _context.next = 12;
2314
2244
  return this.wallet.writeContract(call);
2315
- case 7:
2245
+ case 12:
2316
2246
  txHash = _context.sent;
2317
2247
  if (!((_request$txOptions = request.txOptions) !== null && _request$txOptions !== void 0 && _request$txOptions.waitForTransaction)) {
2318
- _context.next = 15;
2248
+ _context.next = 20;
2319
2249
  break;
2320
2250
  }
2321
- _context.next = 11;
2251
+ _context.next = 16;
2322
2252
  return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.ipAssetRegistryConfig), {}, {
2323
2253
  eventName: "IPRegistered"
2324
2254
  }));
2325
- case 11:
2255
+ case 16:
2326
2256
  targetLog = _context.sent;
2327
2257
  return _context.abrupt("return", {
2328
2258
  txHash: txHash,
2329
2259
  ipId: targetLog.args.ipId
2330
2260
  });
2331
- case 15:
2261
+ case 20:
2332
2262
  return _context.abrupt("return", {
2333
2263
  txHash: txHash
2334
2264
  });
2335
- case 16:
2336
- _context.next = 21;
2265
+ case 21:
2266
+ _context.next = 26;
2337
2267
  break;
2338
- case 18:
2339
- _context.prev = 18;
2268
+ case 23:
2269
+ _context.prev = 23;
2340
2270
  _context.t0 = _context["catch"](0);
2341
2271
  handleError(_context.t0, "Failed to register root IP");
2342
- case 21:
2272
+ case 26:
2343
2273
  case "end":
2344
2274
  return _context.stop();
2345
2275
  }
2346
- }, _callee, this, [[0, 18]]);
2276
+ }, _callee, this, [[0, 23]]);
2347
2277
  }));
2348
2278
  function registerRootIp(_x) {
2349
2279
  return _registerRootIp.apply(this, arguments);
@@ -2369,20 +2299,32 @@ var IPAssetClient = /*#__PURE__*/function () {
2369
2299
  key: "registerDerivativeIp",
2370
2300
  value: function () {
2371
2301
  var _registerDerivativeIp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
2372
- var _request$txOptions2, licenseIds, royaltyContext, _yield$this$rpcClient2, call, txHash, targetLog;
2302
+ var _request$txOptions2, ipId, licenseIds, royaltyContext, _yield$this$rpcClient2, call, txHash, targetLog;
2373
2303
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
2374
2304
  while (1) switch (_context2.prev = _context2.next) {
2375
2305
  case 0:
2376
2306
  _context2.prev = 0;
2307
+ _context2.next = 3;
2308
+ return this.isNFTRegistered(SepoliaChainId, request.tokenContractAddress, request.tokenId);
2309
+ case 3:
2310
+ ipId = _context2.sent;
2311
+ if (!(ipId !== "0x")) {
2312
+ _context2.next = 6;
2313
+ break;
2314
+ }
2315
+ return _context2.abrupt("return", {
2316
+ ipId: ipId
2317
+ });
2318
+ case 6:
2377
2319
  licenseIds = [];
2378
2320
  request.licenseIds.forEach(function (licenseId) {
2379
2321
  licenseIds.push(parseToBigInt(licenseId));
2380
2322
  });
2381
- _context2.next = 5;
2323
+ _context2.next = 10;
2382
2324
  return computeRoyaltyContext(request.licenseIds, this.storyClient);
2383
- case 5:
2325
+ case 10:
2384
2326
  royaltyContext = _context2.sent;
2385
- _context2.next = 8;
2327
+ _context2.next = 13;
2386
2328
  return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.registrationModuleConfig), {}, {
2387
2329
  functionName: "registerDerivativeIp",
2388
2330
  args: [licenseIds, getAddress(request.tokenContractAddress),
@@ -2390,49 +2332,83 @@ var IPAssetClient = /*#__PURE__*/function () {
2390
2332
  parseToBigInt(request.tokenId), request.ipName || "", request.contentHash || HashZero, request.uri || "", encodeRoyaltyContext(royaltyContext)],
2391
2333
  account: this.wallet.account
2392
2334
  }));
2393
- case 8:
2335
+ case 13:
2394
2336
  _yield$this$rpcClient2 = _context2.sent;
2395
2337
  call = _yield$this$rpcClient2.request;
2396
- _context2.next = 12;
2338
+ _context2.next = 17;
2397
2339
  return this.wallet.writeContract(call);
2398
- case 12:
2340
+ case 17:
2399
2341
  txHash = _context2.sent;
2400
2342
  if (!((_request$txOptions2 = request.txOptions) !== null && _request$txOptions2 !== void 0 && _request$txOptions2.waitForTransaction)) {
2401
- _context2.next = 20;
2343
+ _context2.next = 25;
2402
2344
  break;
2403
2345
  }
2404
- _context2.next = 16;
2346
+ _context2.next = 21;
2405
2347
  return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.ipAssetRegistryConfig), {}, {
2406
2348
  eventName: "IPRegistered"
2407
2349
  }));
2408
- case 16:
2350
+ case 21:
2409
2351
  targetLog = _context2.sent;
2410
2352
  return _context2.abrupt("return", {
2411
2353
  txHash: txHash,
2412
2354
  ipId: targetLog.args.ipId
2413
2355
  });
2414
- case 20:
2356
+ case 25:
2415
2357
  return _context2.abrupt("return", {
2416
2358
  txHash: txHash
2417
2359
  });
2418
- case 21:
2419
- _context2.next = 26;
2360
+ case 26:
2361
+ _context2.next = 31;
2420
2362
  break;
2421
- case 23:
2422
- _context2.prev = 23;
2363
+ case 28:
2364
+ _context2.prev = 28;
2423
2365
  _context2.t0 = _context2["catch"](0);
2424
2366
  handleError(_context2.t0, "Failed to register derivative IP");
2425
- case 26:
2367
+ case 31:
2426
2368
  case "end":
2427
2369
  return _context2.stop();
2428
2370
  }
2429
- }, _callee2, this, [[0, 23]]);
2371
+ }, _callee2, this, [[0, 28]]);
2430
2372
  }));
2431
2373
  function registerDerivativeIp(_x2) {
2432
2374
  return _registerDerivativeIp.apply(this, arguments);
2433
2375
  }
2434
2376
  return registerDerivativeIp;
2435
2377
  }()
2378
+ }, {
2379
+ key: "isNFTRegistered",
2380
+ value: function () {
2381
+ var _isNFTRegistered = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(chainId, tokenAddress, tokenId) {
2382
+ var ipId, isRegistered;
2383
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
2384
+ while (1) switch (_context3.prev = _context3.next) {
2385
+ case 0:
2386
+ _context3.next = 2;
2387
+ return this.rpcClient.readContract(_objectSpread2(_objectSpread2({}, this.ipAssetRegistryConfig), {}, {
2388
+ functionName: "ipId",
2389
+ args: [parseToBigInt(chainId), tokenAddress, parseToBigInt(tokenId)]
2390
+ }));
2391
+ case 2:
2392
+ ipId = _context3.sent;
2393
+ _context3.next = 5;
2394
+ return this.rpcClient.readContract(_objectSpread2(_objectSpread2({}, this.ipAssetRegistryConfig), {}, {
2395
+ functionName: "isRegistered",
2396
+ args: [ipId]
2397
+ }));
2398
+ case 5:
2399
+ isRegistered = _context3.sent;
2400
+ return _context3.abrupt("return", isRegistered ? ipId : "0x");
2401
+ case 7:
2402
+ case "end":
2403
+ return _context3.stop();
2404
+ }
2405
+ }, _callee3, this);
2406
+ }));
2407
+ function isNFTRegistered(_x3, _x4, _x5) {
2408
+ return _isNFTRegistered.apply(this, arguments);
2409
+ }
2410
+ return isNFTRegistered;
2411
+ }()
2436
2412
  }]);
2437
2413
  return IPAssetClient;
2438
2414
  }();
@@ -2460,7 +2436,7 @@ var PermissionClient = /*#__PURE__*/function () {
2460
2436
  * @param request.ipAsset The address of the IP account that grants the permission for `signer`
2461
2437
  * @param request.signer The address that can call `to` on behalf of the `ipAccount`
2462
2438
  * @param request.to The address that can be called by the `signer` (currently only modules can be `to`)
2463
- * @param request.func The function selector string of `to` that can be called by the `signer` on behalf of the `ipAccount`
2439
+ * @param request.func Optional. The function selector string of `to` that can be called by the `signer` on behalf of the `ipAccount`. Be default, it allows all functions.
2464
2440
  * @param request.permission The new permission level
2465
2441
  * @returns A Promise that resolves to an object containing the transaction hash
2466
2442
  * @emits PermissionSet (ipAccountOwner, ipAccount, signer, to, func, permission)
@@ -2490,7 +2466,7 @@ var PermissionClient = /*#__PURE__*/function () {
2490
2466
  // 0x Address
2491
2467
  getAddress(request.to),
2492
2468
  // 0x Address
2493
- request.func,
2469
+ request.func || "0x00000000",
2494
2470
  // bytes4
2495
2471
  request.permission // uint8
2496
2472
  ]
@@ -2565,7 +2541,7 @@ var LicenseClient = /*#__PURE__*/function () {
2565
2541
  * @param request.licensorIpId_ The ID of the IP granting the license (ie. licensor)
2566
2542
  * @param request.mintAmount Number of licenses to mint. License NFT is fungible for same policy and same licensors
2567
2543
  * @param request.receiver Receiver address of the minted license NFT(s).
2568
- * @return licenseId The ID of the minted license NFT(s).
2544
+ * @returns licenseId The ID of the minted license NFT(s).
2569
2545
  */
2570
2546
  _createClass(LicenseClient, [{
2571
2547
  key: "mintLicense",
@@ -2727,6 +2703,7 @@ var PolicyClient = /*#__PURE__*/function () {
2727
2703
  _defineProperty(this, "ipAccountABI", IPAccountABI);
2728
2704
  _defineProperty(this, "licensingModuleConfig", LicensingModuleConfig);
2729
2705
  _defineProperty(this, "pilPolicyFrameworkManagerConfig", PILPolicyFrameworkManagerConfig);
2706
+ _defineProperty(this, "royaltyPolicyLAPConfig", RoyaltyPolicyLAPConfig);
2730
2707
  this.wallet = wallet;
2731
2708
  this.rpcClient = rpcClient;
2732
2709
  }
@@ -2754,18 +2731,49 @@ var PolicyClient = /*#__PURE__*/function () {
2754
2731
  key: "registerPILPolicy",
2755
2732
  value: function () {
2756
2733
  var _registerPILPolicy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
2757
- var _request$txOptions, _yield$this$rpcClient, call, txHash, targetLog;
2734
+ var _request$txOptions, frameworkData, policyId, _yield$this$rpcClient, call, txHash, targetLog;
2758
2735
  return _regeneratorRuntime().wrap(function _callee$(_context) {
2759
2736
  while (1) switch (_context.prev = _context.next) {
2760
2737
  case 0:
2761
2738
  _context.prev = 0;
2762
- _context.next = 3;
2739
+ // First check if the policy exists
2740
+ frameworkData = {
2741
+ attribution: request.attribution || false,
2742
+ commercialUse: request.commercialUse || false,
2743
+ commercialAttribution: request.commercialAttribution || false,
2744
+ commercializerChecker: request.commercializerChecker || zeroAddress,
2745
+ commercializerCheckerData: request.commercializerCheckerData || "0x",
2746
+ commercialRevShare: request.commercialRevShare || 0,
2747
+ derivativesAllowed: request.derivativesAllowed || false,
2748
+ derivativesAttribution: request.derivativesAttribution || false,
2749
+ derivativesApproval: request.derivativesApproval || false,
2750
+ derivativesReciprocal: request.derivativesReciprocal || false,
2751
+ territories: request.territories || [],
2752
+ distributionChannels: request.distributionChannels || [],
2753
+ contentRestrictions: request.contentRestrictions || []
2754
+ };
2755
+ _context.next = 4;
2756
+ return this.getPolicyId(request.transferable, this.encodeFrameworkData(frameworkData), typedDataToBytes({
2757
+ "interface": "uint32",
2758
+ data: [request.commercialRevShare || 0]
2759
+ }), request.mintingFee || "0", request.mintingFeeToken || zeroAddress, request.royaltyPolicy || zeroAddress);
2760
+ case 4:
2761
+ policyId = _context.sent;
2762
+ if (!(policyId !== 0)) {
2763
+ _context.next = 7;
2764
+ break;
2765
+ }
2766
+ return _context.abrupt("return", {
2767
+ policyId: policyId.toString()
2768
+ });
2769
+ case 7:
2770
+ _context.next = 9;
2763
2771
  return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.pilPolicyFrameworkManagerConfig), {}, {
2764
2772
  functionName: "registerPolicy",
2765
2773
  args: [{
2766
2774
  transferable: request.transferable,
2767
2775
  royaltyPolicy: request.royaltyPolicy || zeroAddress,
2768
- mintingFee: parseToBigInt(request.mintingFee || 0),
2776
+ mintingFee: parseToBigInt(request.mintingFee || "0"),
2769
2777
  mintingFeeToken: request.mintingFeeToken || zeroAddress,
2770
2778
  policy: {
2771
2779
  attribution: request.attribution || false,
@@ -2773,7 +2781,7 @@ var PolicyClient = /*#__PURE__*/function () {
2773
2781
  commercialAttribution: request.commercialAttribution || false,
2774
2782
  commercialRevShare: request.commercialRevShare || 0,
2775
2783
  derivativesAllowed: request.derivativesAllowed || false,
2776
- derivativesAttribution: request.commercialAttribution || false,
2784
+ derivativesAttribution: request.derivativesAttribution || false,
2777
2785
  derivativesApproval: request.derivativesApproval || false,
2778
2786
  derivativesReciprocal: request.derivativesReciprocal || false,
2779
2787
  commercializerChecker: request.commercializerChecker || zeroAddress,
@@ -2785,49 +2793,332 @@ var PolicyClient = /*#__PURE__*/function () {
2785
2793
  }],
2786
2794
  account: this.wallet.account
2787
2795
  }));
2788
- case 3:
2796
+ case 9:
2789
2797
  _yield$this$rpcClient = _context.sent;
2790
2798
  call = _yield$this$rpcClient.request;
2791
- _context.next = 7;
2799
+ _context.next = 13;
2792
2800
  return this.wallet.writeContract(call);
2793
- case 7:
2801
+ case 13:
2794
2802
  txHash = _context.sent;
2795
2803
  if (!((_request$txOptions = request.txOptions) !== null && _request$txOptions !== void 0 && _request$txOptions.waitForTransaction)) {
2796
- _context.next = 15;
2804
+ _context.next = 21;
2797
2805
  break;
2798
2806
  }
2799
- _context.next = 11;
2807
+ _context.next = 17;
2800
2808
  return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.licensingModuleConfig), {}, {
2801
2809
  eventName: "PolicyRegistered"
2802
2810
  }));
2803
- case 11:
2811
+ case 17:
2804
2812
  targetLog = _context.sent;
2805
2813
  return _context.abrupt("return", {
2806
2814
  txHash: txHash,
2807
2815
  policyId: targetLog === null || targetLog === void 0 ? void 0 : targetLog.args.policyId.toString()
2808
2816
  });
2809
- case 15:
2817
+ case 21:
2810
2818
  return _context.abrupt("return", {
2811
2819
  txHash: txHash
2812
2820
  });
2813
- case 16:
2814
- _context.next = 21;
2821
+ case 22:
2822
+ _context.next = 27;
2815
2823
  break;
2816
- case 18:
2817
- _context.prev = 18;
2824
+ case 24:
2825
+ _context.prev = 24;
2818
2826
  _context.t0 = _context["catch"](0);
2819
2827
  handleError(_context.t0, "Failed to register policy");
2820
- case 21:
2828
+ case 27:
2821
2829
  case "end":
2822
2830
  return _context.stop();
2823
2831
  }
2824
- }, _callee, this, [[0, 18]]);
2832
+ }, _callee, this, [[0, 24]]);
2825
2833
  }));
2826
2834
  function registerPILPolicy(_x) {
2827
2835
  return _registerPILPolicy.apply(this, arguments);
2828
2836
  }
2829
2837
  return registerPILPolicy;
2830
2838
  }()
2839
+ /**
2840
+ * Convenient function to register a PIL social remix policy to the registry
2841
+ * Internally, this function must generate a Licensing.Policy struct and call registerPolicy.
2842
+ * @param request - the licensing parameters for the Programmable IP License v1 (PIL) standard.
2843
+ * @param request.territories List of territories where the license is valid. If empty, global.
2844
+ * @param request.distributionChannels List of distribution channels where the license is valid. Empty if no restrictions.
2845
+ * @param request.contentRestrictions List of content restrictions where the license is valid. Empty if no restrictions.
2846
+ * @returns the transaction hash and the policy ID if the txOptions.waitForTransaction is set to true
2847
+ */
2848
+ }, {
2849
+ key: "registerPILSocialRemixPolicy",
2850
+ value: function () {
2851
+ var _registerPILSocialRemixPolicy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
2852
+ var _request$txOptions2, frameworkData, policyId, _yield$this$rpcClient2, call, txHash, targetLog;
2853
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
2854
+ while (1) switch (_context2.prev = _context2.next) {
2855
+ case 0:
2856
+ _context2.prev = 0;
2857
+ // First check if the policy exists
2858
+ frameworkData = {
2859
+ attribution: true,
2860
+ commercialUse: false,
2861
+ commercialAttribution: false,
2862
+ commercializerChecker: zeroAddress,
2863
+ commercializerCheckerData: "0x",
2864
+ commercialRevShare: 0,
2865
+ derivativesAllowed: true,
2866
+ derivativesAttribution: true,
2867
+ derivativesApproval: false,
2868
+ derivativesReciprocal: true,
2869
+ territories: request.territories || [],
2870
+ distributionChannels: request.distributionChannels || [],
2871
+ contentRestrictions: request.contentRestrictions || []
2872
+ };
2873
+ _context2.next = 4;
2874
+ return this.getPolicyId(true, this.encodeFrameworkData(frameworkData), typedDataToBytes({
2875
+ "interface": "uint32",
2876
+ data: [0]
2877
+ }), "0", zeroAddress, zeroAddress);
2878
+ case 4:
2879
+ policyId = _context2.sent;
2880
+ if (!(policyId !== 0)) {
2881
+ _context2.next = 7;
2882
+ break;
2883
+ }
2884
+ return _context2.abrupt("return", {
2885
+ policyId: policyId.toString()
2886
+ });
2887
+ case 7:
2888
+ _context2.next = 9;
2889
+ return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.pilPolicyFrameworkManagerConfig), {}, {
2890
+ functionName: "registerPolicy",
2891
+ args: [{
2892
+ transferable: true,
2893
+ royaltyPolicy: zeroAddress,
2894
+ mintingFee: parseToBigInt(0),
2895
+ mintingFeeToken: zeroAddress,
2896
+ policy: {
2897
+ attribution: true,
2898
+ commercialUse: false,
2899
+ commercialAttribution: false,
2900
+ commercialRevShare: 0,
2901
+ derivativesAllowed: true,
2902
+ derivativesAttribution: true,
2903
+ derivativesApproval: false,
2904
+ derivativesReciprocal: true,
2905
+ commercializerChecker: zeroAddress,
2906
+ commercializerCheckerData: "0x",
2907
+ territories: request.territories || [],
2908
+ distributionChannels: request.distributionChannels || [],
2909
+ contentRestrictions: request.contentRestrictions || []
2910
+ }
2911
+ }],
2912
+ account: this.wallet.account
2913
+ }));
2914
+ case 9:
2915
+ _yield$this$rpcClient2 = _context2.sent;
2916
+ call = _yield$this$rpcClient2.request;
2917
+ _context2.next = 13;
2918
+ return this.wallet.writeContract(call);
2919
+ case 13:
2920
+ txHash = _context2.sent;
2921
+ if (!((_request$txOptions2 = request.txOptions) !== null && _request$txOptions2 !== void 0 && _request$txOptions2.waitForTransaction)) {
2922
+ _context2.next = 21;
2923
+ break;
2924
+ }
2925
+ _context2.next = 17;
2926
+ return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.licensingModuleConfig), {}, {
2927
+ eventName: "PolicyRegistered"
2928
+ }));
2929
+ case 17:
2930
+ targetLog = _context2.sent;
2931
+ return _context2.abrupt("return", {
2932
+ txHash: txHash,
2933
+ policyId: targetLog === null || targetLog === void 0 ? void 0 : targetLog.args.policyId.toString()
2934
+ });
2935
+ case 21:
2936
+ return _context2.abrupt("return", {
2937
+ txHash: txHash
2938
+ });
2939
+ case 22:
2940
+ _context2.next = 27;
2941
+ break;
2942
+ case 24:
2943
+ _context2.prev = 24;
2944
+ _context2.t0 = _context2["catch"](0);
2945
+ handleError(_context2.t0, "Failed to register social remix policy");
2946
+ case 27:
2947
+ case "end":
2948
+ return _context2.stop();
2949
+ }
2950
+ }, _callee2, this, [[0, 24]]);
2951
+ }));
2952
+ function registerPILSocialRemixPolicy(_x2) {
2953
+ return _registerPILSocialRemixPolicy.apply(this, arguments);
2954
+ }
2955
+ return registerPILSocialRemixPolicy;
2956
+ }()
2957
+ /**
2958
+ * Convenient function to register a PIL social remix policy to the registry
2959
+ * Internally, this function must generate a Licensing.Policy struct and call registerPolicy.
2960
+ * @param request - the licensing parameters for the Programmable IP License v1 (PIL) standard.
2961
+ * @param request.commercialRevShare Percentage of revenue that must be shared with the licensor
2962
+ * @param mintingFee Fee to be paid when minting a license
2963
+ * @param mintingFeeToken Token to be used to pay the minting fee
2964
+ * @param request.territories List of territories where the license is valid. If empty, global.
2965
+ * @param request.distributionChannels List of distribution channels where the license is valid. Empty if no restrictions.
2966
+ * @param request.contentRestrictions List of content restrictions where the license is valid. Empty if no restrictions.
2967
+ * @returns the transaction hash and the policy ID if the txOptions.waitForTransaction is set to true
2968
+ */
2969
+ }, {
2970
+ key: "registerPILCommercialUsePolicy",
2971
+ value: function () {
2972
+ var _registerPILCommercialUsePolicy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(request) {
2973
+ var _request$txOptions3, frameworkData, policyId, _yield$this$rpcClient3, call, txHash, targetLog;
2974
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
2975
+ while (1) switch (_context3.prev = _context3.next) {
2976
+ case 0:
2977
+ _context3.prev = 0;
2978
+ // First check if the policy exists
2979
+ frameworkData = {
2980
+ attribution: true,
2981
+ commercialUse: true,
2982
+ commercialAttribution: true,
2983
+ commercializerChecker: zeroAddress,
2984
+ commercializerCheckerData: "0x",
2985
+ commercialRevShare: request.commercialRevShare,
2986
+ derivativesAllowed: true,
2987
+ derivativesAttribution: true,
2988
+ derivativesApproval: false,
2989
+ derivativesReciprocal: true,
2990
+ territories: request.territories || [],
2991
+ distributionChannels: request.distributionChannels || [],
2992
+ contentRestrictions: request.contentRestrictions || []
2993
+ };
2994
+ _context3.next = 4;
2995
+ return this.getPolicyId(true, this.encodeFrameworkData(frameworkData), typedDataToBytes({
2996
+ "interface": "uint32",
2997
+ data: [request.commercialRevShare]
2998
+ }), request.mintingFee || "0", request.mintingFeeToken || zeroAddress, this.royaltyPolicyLAPConfig.address);
2999
+ case 4:
3000
+ policyId = _context3.sent;
3001
+ if (!(policyId !== 0)) {
3002
+ _context3.next = 7;
3003
+ break;
3004
+ }
3005
+ return _context3.abrupt("return", {
3006
+ policyId: policyId.toString()
3007
+ });
3008
+ case 7:
3009
+ _context3.next = 9;
3010
+ return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.pilPolicyFrameworkManagerConfig), {}, {
3011
+ functionName: "registerPolicy",
3012
+ args: [{
3013
+ transferable: true,
3014
+ royaltyPolicy: this.royaltyPolicyLAPConfig.address,
3015
+ mintingFee: parseToBigInt(request.mintingFee || "0"),
3016
+ mintingFeeToken: request.mintingFeeToken || zeroAddress,
3017
+ policy: {
3018
+ attribution: true,
3019
+ commercialUse: true,
3020
+ commercialAttribution: true,
3021
+ commercialRevShare: request.commercialRevShare,
3022
+ derivativesAllowed: true,
3023
+ derivativesAttribution: true,
3024
+ derivativesApproval: false,
3025
+ derivativesReciprocal: true,
3026
+ commercializerChecker: zeroAddress,
3027
+ commercializerCheckerData: "0x",
3028
+ territories: request.territories || [],
3029
+ distributionChannels: request.distributionChannels || [],
3030
+ contentRestrictions: request.contentRestrictions || []
3031
+ }
3032
+ }],
3033
+ account: this.wallet.account
3034
+ }));
3035
+ case 9:
3036
+ _yield$this$rpcClient3 = _context3.sent;
3037
+ call = _yield$this$rpcClient3.request;
3038
+ _context3.next = 13;
3039
+ return this.wallet.writeContract(call);
3040
+ case 13:
3041
+ txHash = _context3.sent;
3042
+ if (!((_request$txOptions3 = request.txOptions) !== null && _request$txOptions3 !== void 0 && _request$txOptions3.waitForTransaction)) {
3043
+ _context3.next = 21;
3044
+ break;
3045
+ }
3046
+ _context3.next = 17;
3047
+ return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.licensingModuleConfig), {}, {
3048
+ eventName: "PolicyRegistered"
3049
+ }));
3050
+ case 17:
3051
+ targetLog = _context3.sent;
3052
+ return _context3.abrupt("return", {
3053
+ txHash: txHash,
3054
+ policyId: targetLog === null || targetLog === void 0 ? void 0 : targetLog.args.policyId.toString()
3055
+ });
3056
+ case 21:
3057
+ return _context3.abrupt("return", {
3058
+ txHash: txHash
3059
+ });
3060
+ case 22:
3061
+ _context3.next = 27;
3062
+ break;
3063
+ case 24:
3064
+ _context3.prev = 24;
3065
+ _context3.t0 = _context3["catch"](0);
3066
+ handleError(_context3.t0, "Failed to register commercial use policy");
3067
+ case 27:
3068
+ case "end":
3069
+ return _context3.stop();
3070
+ }
3071
+ }, _callee3, this, [[0, 24]]);
3072
+ }));
3073
+ function registerPILCommercialUsePolicy(_x3) {
3074
+ return _registerPILCommercialUsePolicy.apply(this, arguments);
3075
+ }
3076
+ return registerPILCommercialUsePolicy;
3077
+ }()
3078
+ }, {
3079
+ key: "getPolicyId",
3080
+ value: function () {
3081
+ var _getPolicyId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(transferable, frameworkData, royaltyData, mintingFee, mintingFeeToken, royaltyPolicy, policyFramework) {
3082
+ var data;
3083
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
3084
+ while (1) switch (_context4.prev = _context4.next) {
3085
+ case 0:
3086
+ _context4.next = 2;
3087
+ return this.rpcClient.readContract(_objectSpread2(_objectSpread2({}, this.licensingModuleConfig), {}, {
3088
+ functionName: "getPolicyId",
3089
+ args: [{
3090
+ isLicenseTransferable: transferable,
3091
+ policyFramework: policyFramework || this.pilPolicyFrameworkManagerConfig.address,
3092
+ frameworkData: frameworkData,
3093
+ royaltyPolicy: royaltyPolicy,
3094
+ royaltyData: royaltyData,
3095
+ mintingFee: parseToBigInt(mintingFee),
3096
+ mintingFeeToken: mintingFeeToken
3097
+ }]
3098
+ }));
3099
+ case 2:
3100
+ data = _context4.sent;
3101
+ return _context4.abrupt("return", Number(data));
3102
+ case 4:
3103
+ case "end":
3104
+ return _context4.stop();
3105
+ }
3106
+ }, _callee4, this);
3107
+ }));
3108
+ function getPolicyId(_x4, _x5, _x6, _x7, _x8, _x9, _x10) {
3109
+ return _getPolicyId.apply(this, arguments);
3110
+ }
3111
+ return getPolicyId;
3112
+ }()
3113
+ }, {
3114
+ key: "encodeFrameworkData",
3115
+ value: function encodeFrameworkData(data) {
3116
+ return typedDataToBytes({
3117
+ "interface": "(bool, bool, bool, address, bytes, uint32, bool, bool, bool, bool, string[], string[], string[])",
3118
+ data: [[data.attribution, data.commercialUse, data.commercialAttribution, data.commercializerChecker, data.commercializerCheckerData, data.commercialRevShare, data.derivativesAllowed, data.derivativesAttribution, data.derivativesApproval, data.derivativesReciprocal, data.territories, data.distributionChannels, data.contentRestrictions]]
3119
+ });
3120
+ }
3121
+
2831
3122
  /**
2832
3123
  * Adds a policy to the set of policies of an IP
2833
3124
  * @param request The request object containing details to add a policy to an IP
@@ -2838,17 +3129,17 @@ var PolicyClient = /*#__PURE__*/function () {
2838
3129
  }, {
2839
3130
  key: "addPolicyToIp",
2840
3131
  value: function () {
2841
- var _addPolicyToIp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
2842
- var _request$txOptions2, IPAccountConfig, _yield$this$rpcClient2, call, txHash, targetLog;
2843
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
2844
- while (1) switch (_context2.prev = _context2.next) {
3132
+ var _addPolicyToIp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(request) {
3133
+ var _request$txOptions4, IPAccountConfig, _yield$this$rpcClient4, call, txHash, targetLog;
3134
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
3135
+ while (1) switch (_context5.prev = _context5.next) {
2845
3136
  case 0:
2846
- _context2.prev = 0;
3137
+ _context5.prev = 0;
2847
3138
  IPAccountConfig = {
2848
3139
  abi: this.ipAccountABI,
2849
3140
  address: getAddress(request.ipId)
2850
3141
  };
2851
- _context2.next = 4;
3142
+ _context5.next = 4;
2852
3143
  return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, IPAccountConfig), {}, {
2853
3144
  functionName: "execute",
2854
3145
  args: [this.licensingModuleConfig.address, parseToBigInt(0), encodeFunctionData({
@@ -2859,44 +3150,44 @@ var PolicyClient = /*#__PURE__*/function () {
2859
3150
  account: this.wallet.account
2860
3151
  }));
2861
3152
  case 4:
2862
- _yield$this$rpcClient2 = _context2.sent;
2863
- call = _yield$this$rpcClient2.request;
2864
- _context2.next = 8;
3153
+ _yield$this$rpcClient4 = _context5.sent;
3154
+ call = _yield$this$rpcClient4.request;
3155
+ _context5.next = 8;
2865
3156
  return this.wallet.writeContract(call);
2866
3157
  case 8:
2867
- txHash = _context2.sent;
2868
- if (!((_request$txOptions2 = request.txOptions) !== null && _request$txOptions2 !== void 0 && _request$txOptions2.waitForTransaction)) {
2869
- _context2.next = 16;
3158
+ txHash = _context5.sent;
3159
+ if (!((_request$txOptions4 = request.txOptions) !== null && _request$txOptions4 !== void 0 && _request$txOptions4.waitForTransaction)) {
3160
+ _context5.next = 16;
2870
3161
  break;
2871
3162
  }
2872
- _context2.next = 12;
3163
+ _context5.next = 12;
2873
3164
  return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.licensingModuleConfig), {}, {
2874
3165
  eventName: "PolicyAddedToIpId"
2875
3166
  }));
2876
3167
  case 12:
2877
- targetLog = _context2.sent;
2878
- return _context2.abrupt("return", {
3168
+ targetLog = _context5.sent;
3169
+ return _context5.abrupt("return", {
2879
3170
  txHash: txHash,
2880
3171
  index: targetLog.args.index.toString()
2881
3172
  });
2882
3173
  case 16:
2883
- return _context2.abrupt("return", {
3174
+ return _context5.abrupt("return", {
2884
3175
  txHash: txHash
2885
3176
  });
2886
3177
  case 17:
2887
- _context2.next = 22;
3178
+ _context5.next = 22;
2888
3179
  break;
2889
3180
  case 19:
2890
- _context2.prev = 19;
2891
- _context2.t0 = _context2["catch"](0);
2892
- handleError(_context2.t0, "Failed to add policy to IP");
3181
+ _context5.prev = 19;
3182
+ _context5.t0 = _context5["catch"](0);
3183
+ handleError(_context5.t0, "Failed to add policy to IP");
2893
3184
  case 22:
2894
3185
  case "end":
2895
- return _context2.stop();
3186
+ return _context5.stop();
2896
3187
  }
2897
- }, _callee2, this, [[0, 19]]);
3188
+ }, _callee5, this, [[0, 19]]);
2898
3189
  }));
2899
- function addPolicyToIp(_x2) {
3190
+ function addPolicyToIp(_x11) {
2900
3191
  return _addPolicyToIp.apply(this, arguments);
2901
3192
  }
2902
3193
  return addPolicyToIp;
@@ -3105,6 +3396,137 @@ var DisputeClient = /*#__PURE__*/function () {
3105
3396
  return DisputeClient;
3106
3397
  }();
3107
3398
 
3399
+ var IPAccountClient = /*#__PURE__*/function () {
3400
+ function IPAccountClient(rpcClient, wallet) {
3401
+ _classCallCheck(this, IPAccountClient);
3402
+ _defineProperty(this, "ipAccountABI", IPAccountABI);
3403
+ this.wallet = wallet;
3404
+ this.rpcClient = rpcClient;
3405
+ }
3406
+
3407
+ /** Executes a transaction from the IP Account.
3408
+ * @param request The request object containing necessary data to execute IP Account a transaction.
3409
+ * @param request.to The recipient of the transaction.
3410
+ * @param request.value The amount of Ether to send.
3411
+ * @param request.data The data to send along with the transaction.
3412
+ * @returns Tx hash for the transaction.
3413
+ */
3414
+ _createClass(IPAccountClient, [{
3415
+ key: "execute",
3416
+ value: function () {
3417
+ var _execute = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
3418
+ var _request$txOptions, IPAccountConfig, _yield$this$rpcClient, call, txHash;
3419
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
3420
+ while (1) switch (_context.prev = _context.next) {
3421
+ case 0:
3422
+ _context.prev = 0;
3423
+ IPAccountConfig = {
3424
+ abi: this.ipAccountABI,
3425
+ address: getAddress(request.accountAddress)
3426
+ };
3427
+ _context.next = 4;
3428
+ return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, IPAccountConfig), {}, {
3429
+ functionName: "execute",
3430
+ args: [request.to, parseToBigInt(0), request.data],
3431
+ account: this.wallet.account
3432
+ }));
3433
+ case 4:
3434
+ _yield$this$rpcClient = _context.sent;
3435
+ call = _yield$this$rpcClient.request;
3436
+ _context.next = 8;
3437
+ return this.wallet.writeContract(call);
3438
+ case 8:
3439
+ txHash = _context.sent;
3440
+ if (!((_request$txOptions = request.txOptions) !== null && _request$txOptions !== void 0 && _request$txOptions.waitForTransaction)) {
3441
+ _context.next = 12;
3442
+ break;
3443
+ }
3444
+ _context.next = 12;
3445
+ return waitTx(this.rpcClient, txHash);
3446
+ case 12:
3447
+ return _context.abrupt("return", {
3448
+ txHash: txHash
3449
+ });
3450
+ case 15:
3451
+ _context.prev = 15;
3452
+ _context.t0 = _context["catch"](0);
3453
+ handleError(_context.t0, "Failed to execute the IP Account transaction");
3454
+ case 18:
3455
+ case "end":
3456
+ return _context.stop();
3457
+ }
3458
+ }, _callee, this, [[0, 15]]);
3459
+ }));
3460
+ function execute(_x) {
3461
+ return _execute.apply(this, arguments);
3462
+ }
3463
+ return execute;
3464
+ }()
3465
+ /** Executes a transaction from the IP Account.
3466
+ * @param request The request object containing necessary data to execute IP Account a transaction.
3467
+ * @param request.to The recipient of the transaction.
3468
+ * @param request.value The amount of Ether to send.
3469
+ * @param request.data The data to send along with the transaction.
3470
+ * @param request.signer The signer of the transaction.
3471
+ * @param request.deadline The deadline of the transaction signature.
3472
+ * @param request.signature The signature of the transaction, EIP-712 encoded.
3473
+ * @returns Tx hash for the transaction.
3474
+ */
3475
+ }, {
3476
+ key: "executeWithSig",
3477
+ value: function () {
3478
+ var _executeWithSig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
3479
+ var _request$txOptions2, IPAccountConfig, _yield$this$rpcClient2, call, txHash;
3480
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
3481
+ while (1) switch (_context2.prev = _context2.next) {
3482
+ case 0:
3483
+ _context2.prev = 0;
3484
+ IPAccountConfig = {
3485
+ abi: this.ipAccountABI,
3486
+ address: getAddress(request.accountAddress)
3487
+ };
3488
+ _context2.next = 4;
3489
+ return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, IPAccountConfig), {}, {
3490
+ functionName: "executeWithSig",
3491
+ args: [request.to, parseToBigInt(0), request.data, request.signer, parseToBigInt(request.deadline), request.signature],
3492
+ account: this.wallet.account
3493
+ }));
3494
+ case 4:
3495
+ _yield$this$rpcClient2 = _context2.sent;
3496
+ call = _yield$this$rpcClient2.request;
3497
+ _context2.next = 8;
3498
+ return this.wallet.writeContract(call);
3499
+ case 8:
3500
+ txHash = _context2.sent;
3501
+ if (!((_request$txOptions2 = request.txOptions) !== null && _request$txOptions2 !== void 0 && _request$txOptions2.waitForTransaction)) {
3502
+ _context2.next = 12;
3503
+ break;
3504
+ }
3505
+ _context2.next = 12;
3506
+ return waitTx(this.rpcClient, txHash);
3507
+ case 12:
3508
+ return _context2.abrupt("return", {
3509
+ txHash: txHash
3510
+ });
3511
+ case 15:
3512
+ _context2.prev = 15;
3513
+ _context2.t0 = _context2["catch"](0);
3514
+ handleError(_context2.t0, "Failed to execute with signature for the IP Account transaction");
3515
+ case 18:
3516
+ case "end":
3517
+ return _context2.stop();
3518
+ }
3519
+ }, _callee2, this, [[0, 15]]);
3520
+ }));
3521
+ function executeWithSig(_x2) {
3522
+ return _executeWithSig.apply(this, arguments);
3523
+ }
3524
+ return executeWithSig;
3525
+ }()
3526
+ }]);
3527
+ return IPAccountClient;
3528
+ }();
3529
+
3108
3530
  var StoryAPIClient = /*#__PURE__*/function () {
3109
3531
  function StoryAPIClient() {
3110
3532
  _classCallCheck(this, StoryAPIClient);
@@ -3125,7 +3547,7 @@ var StoryAPIClient = /*#__PURE__*/function () {
3125
3547
  while (1) switch (_context.prev = _context.next) {
3126
3548
  case 0:
3127
3549
  _context.next = 2;
3128
- return this.httpClient.get("/api/v1/royaltypolicies/".concat(ipId));
3550
+ return this.httpClient.get("/api/v1/royalties/policies/".concat(ipId));
3129
3551
  case 2:
3130
3552
  royaltyPolicyResp = _context.sent;
3131
3553
  return _context.abrupt("return", royaltyPolicyResp.data.data);
@@ -3204,12 +3626,12 @@ var StoryClient = /*#__PURE__*/function () {
3204
3626
  */
3205
3627
  function StoryClient(config) {
3206
3628
  _classCallCheck(this, StoryClient);
3207
- _defineProperty(this, "_ipAccount", null);
3629
+ _defineProperty(this, "_ipAsset", null);
3208
3630
  _defineProperty(this, "_permission", null);
3209
3631
  _defineProperty(this, "_license", null);
3210
3632
  _defineProperty(this, "_policy", null);
3211
- _defineProperty(this, "_tagging", null);
3212
3633
  _defineProperty(this, "_dispute", null);
3634
+ _defineProperty(this, "_ipAccount", null);
3213
3635
  this.config = config;
3214
3636
  if (!this.config.transport) {
3215
3637
  throw new Error("transport is null, please pass in a valid RPC Provider URL as the transport.");
@@ -3236,12 +3658,26 @@ var StoryClient = /*#__PURE__*/function () {
3236
3658
  */
3237
3659
  _createClass(StoryClient, [{
3238
3660
  key: "ipAsset",
3239
- get: function get() {
3240
- if (this._ipAccount === null) {
3241
- this._ipAccount = new IPAssetClient(this.rpcClient, this.wallet, this.storyClient);
3661
+ get:
3662
+ /**
3663
+ * Getter for the ip asset client. The client is lazily created when
3664
+ * this method is called.
3665
+ *
3666
+ * @returns the IPAssetClient instance
3667
+ */
3668
+ function get() {
3669
+ if (this._ipAsset === null) {
3670
+ this._ipAsset = new IPAssetClient(this.rpcClient, this.wallet, this.storyClient);
3242
3671
  }
3243
- return this._ipAccount;
3672
+ return this._ipAsset;
3244
3673
  }
3674
+
3675
+ /**
3676
+ * Getter for the permission client. The client is lazily created when
3677
+ * this method is called.
3678
+ *
3679
+ * @returns the PermissionClient instance
3680
+ */
3245
3681
  }, {
3246
3682
  key: "permission",
3247
3683
  get: function get() {
@@ -3250,6 +3686,13 @@ var StoryClient = /*#__PURE__*/function () {
3250
3686
  }
3251
3687
  return this._permission;
3252
3688
  }
3689
+
3690
+ /**
3691
+ * Getter for the license client. The client is lazily created when
3692
+ * this method is called.
3693
+ *
3694
+ * @returns the LicenseClient instance
3695
+ */
3253
3696
  }, {
3254
3697
  key: "license",
3255
3698
  get: function get() {
@@ -3258,6 +3701,13 @@ var StoryClient = /*#__PURE__*/function () {
3258
3701
  }
3259
3702
  return this._license;
3260
3703
  }
3704
+
3705
+ /**
3706
+ * Getter for the policy client. The client is lazily created when
3707
+ * this method is called.
3708
+ *
3709
+ * @returns the PolicyClient instance
3710
+ */
3261
3711
  }, {
3262
3712
  key: "policy",
3263
3713
  get: function get() {
@@ -3268,33 +3718,33 @@ var StoryClient = /*#__PURE__*/function () {
3268
3718
  }
3269
3719
 
3270
3720
  /**
3271
- * Getter for the tagging client. The client is lazily created when
3721
+ * Getter for the dispute client. The client is lazily created when
3272
3722
  * this method is called.
3273
3723
  *
3274
- * @returns the TaggingClient instance
3724
+ * @returns the DisputeClient instance
3275
3725
  */
3276
3726
  }, {
3277
- key: "tagging",
3727
+ key: "dispute",
3278
3728
  get: function get() {
3279
- if (this._tagging === null) {
3280
- this._tagging = new TaggingClient(this.rpcClient, this.wallet);
3729
+ if (this._dispute === null) {
3730
+ this._dispute = new DisputeClient(this.rpcClient, this.wallet);
3281
3731
  }
3282
- return this._tagging;
3732
+ return this._dispute;
3283
3733
  }
3284
3734
 
3285
3735
  /**
3286
- * Getter for the dispute client. The client is lazily created when
3736
+ * Getter for the ip account client. The client is lazily created when
3287
3737
  * this method is called.
3288
3738
  *
3289
- * @returns the DisputeClient instance
3739
+ * @returns the IPAccountClient instance
3290
3740
  */
3291
3741
  }, {
3292
- key: "dispute",
3742
+ key: "ipAccount",
3293
3743
  get: function get() {
3294
- if (this._dispute === null) {
3295
- this._dispute = new DisputeClient(this.rpcClient, this.wallet);
3744
+ if (this._ipAccount === null) {
3745
+ this._ipAccount = new IPAccountClient(this.rpcClient, this.wallet);
3296
3746
  }
3297
- return this._dispute;
3747
+ return this._ipAccount;
3298
3748
  }
3299
3749
  }], [{
3300
3750
  key: "newClient",
@@ -3305,4 +3755,4 @@ var StoryClient = /*#__PURE__*/function () {
3305
3755
  return StoryClient;
3306
3756
  }();
3307
3757
 
3308
- export { AddressZero, DisputeClient, HashZero, IPAssetClient, LicenseClient, PermissionClient, PolicyClient, StoryClient, TaggingClient };
3758
+ export { AddressZero, DisputeClient, HashZero, IPAssetClient, LicenseClient, PermissionClient, PolicyClient, StoryClient };