@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
@@ -447,6 +447,10 @@ function handleError(error, msg) {
447
447
  throw new Error("".concat(msg, ": Unknown error type"));
448
448
  }
449
449
 
450
+ var AddressZero = "0x0000000000000000000000000000000000000000";
451
+ var HashZero = "0x0000000000000000000000000000000000000000000000000000000000000000";
452
+ var SepoliaChainId = "11155111";
453
+
450
454
  function _arrayLikeToArray(arr, len) {
451
455
  if (len == null || len > arr.length) len = arr.length;
452
456
  for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
@@ -818,6 +822,42 @@ var IPAssetRegistryABI = [{
818
822
  }],
819
823
  name: "IPRegistered",
820
824
  type: "event"
825
+ }, {
826
+ inputs: [{
827
+ internalType: "uint256",
828
+ name: "chainId",
829
+ type: "uint256"
830
+ }, {
831
+ internalType: "address",
832
+ name: "tokenContract",
833
+ type: "address"
834
+ }, {
835
+ internalType: "uint256",
836
+ name: "tokenId",
837
+ type: "uint256"
838
+ }],
839
+ name: "ipId",
840
+ outputs: [{
841
+ internalType: "address",
842
+ name: "",
843
+ type: "address"
844
+ }],
845
+ stateMutability: "view",
846
+ type: "function"
847
+ }, {
848
+ inputs: [{
849
+ internalType: "address",
850
+ name: "id",
851
+ type: "address"
852
+ }],
853
+ name: "isRegistered",
854
+ outputs: [{
855
+ internalType: "bool",
856
+ name: "",
857
+ type: "bool"
858
+ }],
859
+ stateMutability: "view",
860
+ type: "function"
821
861
  }];
822
862
 
823
863
  var LicensingModuleABI = [{
@@ -928,6 +968,49 @@ var LicensingModuleABI = [{
928
968
  }],
929
969
  stateMutability: "nonpayable",
930
970
  type: "function"
971
+ }, {
972
+ inputs: [{
973
+ components: [{
974
+ internalType: "bool",
975
+ name: "isLicenseTransferable",
976
+ type: "bool"
977
+ }, {
978
+ internalType: "address",
979
+ name: "policyFramework",
980
+ type: "address"
981
+ }, {
982
+ internalType: "bytes",
983
+ name: "frameworkData",
984
+ type: "bytes"
985
+ }, {
986
+ internalType: "address",
987
+ name: "royaltyPolicy",
988
+ type: "address"
989
+ }, {
990
+ internalType: "bytes",
991
+ name: "royaltyData",
992
+ type: "bytes"
993
+ }, {
994
+ internalType: "uint256",
995
+ name: "mintingFee",
996
+ type: "uint256"
997
+ }, {
998
+ internalType: "address",
999
+ name: "mintingFeeToken",
1000
+ type: "address"
1001
+ }],
1002
+ internalType: "struct Licensing.Policy",
1003
+ name: "pol",
1004
+ type: "tuple"
1005
+ }],
1006
+ name: "getPolicyId",
1007
+ outputs: [{
1008
+ internalType: "uint256",
1009
+ name: "policyId",
1010
+ type: "uint256"
1011
+ }],
1012
+ stateMutability: "view",
1013
+ type: "function"
931
1014
  }, {
932
1015
  inputs: [{
933
1016
  internalType: "uint256[]",
@@ -1181,44 +1264,6 @@ var RegistrationModuleABI = [{
1181
1264
  type: "function"
1182
1265
  }];
1183
1266
 
1184
- var TaggingModuleABI = [{
1185
- inputs: [{
1186
- internalType: "string",
1187
- name: "tag",
1188
- type: "string"
1189
- }, {
1190
- internalType: "address",
1191
- name: "ipId",
1192
- type: "address"
1193
- }],
1194
- name: "removeTag",
1195
- outputs: [{
1196
- internalType: "bool",
1197
- name: "removed",
1198
- type: "bool"
1199
- }],
1200
- stateMutability: "nonpayable",
1201
- type: "function"
1202
- }, {
1203
- inputs: [{
1204
- internalType: "string",
1205
- name: "tag",
1206
- type: "string"
1207
- }, {
1208
- internalType: "address",
1209
- name: "ipId",
1210
- type: "address"
1211
- }],
1212
- name: "setTag",
1213
- outputs: [{
1214
- internalType: "bool",
1215
- name: "added",
1216
- type: "bool"
1217
- }],
1218
- stateMutability: "nonpayable",
1219
- type: "function"
1220
- }];
1221
-
1222
1267
  var ErrorsABI = [{
1223
1268
  inputs: [{
1224
1269
  internalType: "address",
@@ -1867,51 +1912,31 @@ var ErrorsABI = [{
1867
1912
  inputs: [],
1868
1913
  name: "RoyaltyPolicyLAP__ZeroRoyaltyModule",
1869
1914
  type: "error"
1870
- }, {
1871
- inputs: [],
1872
- name: "TaggingModule__DstIpIdDoesNotHaveDstTag",
1873
- type: "error"
1874
- }, {
1875
- inputs: [],
1876
- name: "TaggingModule__InvalidRelationTypeName",
1877
- type: "error"
1878
- }, {
1879
- inputs: [],
1880
- name: "TaggingModule__RelationTypeAlreadyExists",
1881
- type: "error"
1882
- }, {
1883
- inputs: [],
1884
- name: "TaggingModule__RelationTypeDoesNotExist",
1885
- type: "error"
1886
- }, {
1887
- inputs: [],
1888
- name: "TaggingModule__SrcIpIdDoesNotHaveSrcTag",
1889
- type: "error"
1890
1915
  }];
1891
1916
 
1892
1917
  var sepolia = {
1893
- AccessController: "0x31dd83a3FebB5fAD7F7bc8D4E05B623461B74a02",
1894
- AncestorsVaultLAP: "0x9Faa4E491a211bFa415d44554120B1b31b6f4e59",
1895
- ArbitrationPolicySP: "0x75e181d5eb307eCccf8d3b4724109eca14719A75",
1896
- DisputeModule: "0x11dAA3F573C4d6673BBE7f2D96B4C91073A0d55d",
1897
- Governance: "0xa18252Aa11Ff1B20b89C10109050CC46A4067b22",
1898
- IPAccountImpl: "0x7BBaB2BD68fd3990c8dA2c26334a6DF8Acc7E96E",
1899
- IPAccountRegistry: "0x7184bAdAdf24dc261C7C27BceFF53d7A25a06846",
1900
- IPAssetRegistry: "0xF59adB67B7CC87436A7CC41040A7dB24AE90aDB8",
1901
- IPAssetRenderer: "0x986d8E96b30b688FCD84e9A5A757C3d4304B47b6",
1902
- IPMetadataProvider: "0xfcD468A72F76e89F2Df517274063ef7210a32e2A",
1903
- IPResolver: "0xF0920314Fb4C375cdEB5b15c4e77277aCf36E3D7",
1904
- LicenseRegistry: "0x4D6a54B467332dF675cFa689cb294A4cB9122866",
1905
- LicensingModule: "0x0C72b24067a15994f91D92Fd9bA23eB5ebcF8378",
1906
- MockERC20: "0xd53C2A80D24F6B3Ff009E48CF88D3b482E8E1457",
1907
- MockERC721: "0xD3719824a768c139AAa7C5eFc8BDb5D1d13A1564",
1908
- MockTokenGatedHook: "0x2d3ED4354eD09B0E6aa252938aEF41920aB6FC40",
1909
- ModuleRegistry: "0x17Ad1cD06d44ae5F5480A675A4D8BD8DAED40410",
1910
- PILPolicyFrameworkManager: "0x49cF5C5523011F8B4A0489969096Eb68C571C197",
1911
- RegistrationModule: "0x248c8CbF469ec7CB22Dc9914E569920b93d717a3",
1912
- RoyaltyModule: "0x512bbF310452cC96E0E9818B0870EcA557b86d4D",
1913
- RoyaltyPolicyLAP: "0x8404061350BA0CA85c4E733B0be78c5519679003",
1914
- TaggingModule: "0xED445f1DeE74Cf470Aab47F4b63734653C4C9537"
1918
+ AccessController: "0x8eB53745795E2107E3568c647A77a7294C89Ef31",
1919
+ AncestorsVaultLAP: "0x7FD793C4914da052022524BA17508976733B09AA",
1920
+ ArbitrationPolicySP: "0xFfE389378AFa13D91485182D72700d226Cb0db16",
1921
+ DisputeModule: "0xe94d7198EF5657C15be755aC3D9cb386F2Db50Bd",
1922
+ Governance: "0x14Ac96796aadef6053e993aBDc3C1e7830ede901",
1923
+ IPAccountImpl: "0xec3F947902fac41e59aa25669Fe39997BFA1357c",
1924
+ IPAccountRegistry: "0xfe3ef84acECAd1F91583CB09E62953669C1c2bb5",
1925
+ IPAssetRegistry: "0xA3a77482C64e91d4C89114D83Bd51457132ea947",
1926
+ IPAssetRenderer: "0xF36c279a61b32D39e5Bc25e317f779362Be07E1d",
1927
+ IPMetadataProvider: "0x40D52438C3852A872c71eB3a8b81d6274C5b6274",
1928
+ IPResolver: "0x8BcE3019dBe94402A0276A2630373CDDB67fe271",
1929
+ LicenseRegistry: "0x176d33Cc80ed3390256033bbf7Fd651c9C5A364F",
1930
+ LicensingModule: "0x9CDDD88Dd34429a0F39eaDf91a56D1bf0533E72B",
1931
+ MockERC20: "0x1219A0E87e617E6560104fA11cfd4f01FeB47362",
1932
+ MockERC721: "0x9d790FF5B6A7469f32f18E677E15D48b86C6839b",
1933
+ MockTokenGatedHook: "0x25018B7521E7607A7101302401bE81eDCA2E9730",
1934
+ ModuleRegistry: "0x6E09516f10a4094b9B9A8C2b7Aa611A2D7827d3F",
1935
+ PILPolicyFrameworkManager: "0x50c3bCAA67D4eC3f285E4328451315Ab0D9e539f",
1936
+ RegistrationModule: "0x8b3f6b736b520F69c37a575293D3c1ff6383D495",
1937
+ RoyaltyModule: "0x833774B42357939B4c96e1bCF5cE26e815AE3Ae6",
1938
+ RoyaltyPolicyLAP: "0xda483fd6e6ecA1C2D913802F9a6B57a83b73029f",
1939
+ TokenWithdrawalModule: "0x01469702E71F5C8199A15a97e8147D002C60a0B9"
1915
1940
  };
1916
1941
 
1917
1942
  var IPAccountABI = [].concat(_toConsumableArray(IPAccountImplABI), _toConsumableArray(ErrorsABI));
@@ -1939,14 +1964,13 @@ var RegistrationModuleConfig = {
1939
1964
  abi: [].concat(_toConsumableArray(RegistrationModuleABI), _toConsumableArray(ErrorsABI)),
1940
1965
  address: viem.getAddress(sepolia.RegistrationModule)
1941
1966
  };
1942
- var TaggingModuleConfig = {
1943
- abi: [].concat(_toConsumableArray(TaggingModuleABI), _toConsumableArray(ErrorsABI)),
1944
- address: viem.getAddress(sepolia.TaggingModule)
1945
- };
1946
1967
  var PILPolicyFrameworkManagerConfig = {
1947
1968
  abi: [].concat(_toConsumableArray(PILPolicyFrameworkManagerABI), _toConsumableArray(ErrorsABI)),
1948
1969
  address: viem.getAddress(sepolia.PILPolicyFrameworkManager)
1949
1970
  };
1971
+ var RoyaltyPolicyLAPConfig = {
1972
+ address: viem.getAddress(sepolia.RoyaltyPolicyLAP)
1973
+ };
1950
1974
 
1951
1975
  function _createForOfIteratorHelper(o, allowArrayLike) {
1952
1976
  var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
@@ -2105,112 +2129,6 @@ function chainStringToViemChain(chainId) {
2105
2129
  }
2106
2130
  }
2107
2131
 
2108
- var TaggingClient = /*#__PURE__*/function () {
2109
- function TaggingClient(rpcClient, wallet) {
2110
- _classCallCheck(this, TaggingClient);
2111
- _defineProperty(this, "taggingModuleConfig", TaggingModuleConfig);
2112
- this.rpcClient = rpcClient;
2113
- this.wallet = wallet;
2114
- }
2115
- _createClass(TaggingClient, [{
2116
- key: "setTag",
2117
- value: function () {
2118
- var _setTag = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
2119
- var _request$txOptions, _yield$this$rpcClient, call, txHash;
2120
- return _regeneratorRuntime().wrap(function _callee$(_context) {
2121
- while (1) switch (_context.prev = _context.next) {
2122
- case 0:
2123
- _context.prev = 0;
2124
- _context.next = 3;
2125
- return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.taggingModuleConfig), {}, {
2126
- functionName: "setTag",
2127
- args: [request.tag, request.ipId]
2128
- }));
2129
- case 3:
2130
- _yield$this$rpcClient = _context.sent;
2131
- call = _yield$this$rpcClient.request;
2132
- _context.next = 7;
2133
- return this.wallet.writeContract(call);
2134
- case 7:
2135
- txHash = _context.sent;
2136
- if (!((_request$txOptions = request.txOptions) !== null && _request$txOptions !== void 0 && _request$txOptions.waitForTransaction)) {
2137
- _context.next = 11;
2138
- break;
2139
- }
2140
- _context.next = 11;
2141
- return waitTx(this.rpcClient, txHash);
2142
- case 11:
2143
- return _context.abrupt("return", {
2144
- txHash: txHash
2145
- });
2146
- case 14:
2147
- _context.prev = 14;
2148
- _context.t0 = _context["catch"](0);
2149
- handleError(_context.t0, "Failed to set tag");
2150
- case 17:
2151
- case "end":
2152
- return _context.stop();
2153
- }
2154
- }, _callee, this, [[0, 14]]);
2155
- }));
2156
- function setTag(_x) {
2157
- return _setTag.apply(this, arguments);
2158
- }
2159
- return setTag;
2160
- }()
2161
- }, {
2162
- key: "removeTag",
2163
- value: function () {
2164
- var _removeTag = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
2165
- var _request$txOptions2, _yield$this$rpcClient2, call, txHash;
2166
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
2167
- while (1) switch (_context2.prev = _context2.next) {
2168
- case 0:
2169
- _context2.prev = 0;
2170
- _context2.next = 3;
2171
- return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.taggingModuleConfig), {}, {
2172
- functionName: "removeTag",
2173
- args: [request.tag, request.ipId]
2174
- }));
2175
- case 3:
2176
- _yield$this$rpcClient2 = _context2.sent;
2177
- call = _yield$this$rpcClient2.request;
2178
- _context2.next = 7;
2179
- return this.wallet.writeContract(call);
2180
- case 7:
2181
- txHash = _context2.sent;
2182
- if (!((_request$txOptions2 = request.txOptions) !== null && _request$txOptions2 !== void 0 && _request$txOptions2.waitForTransaction)) {
2183
- _context2.next = 11;
2184
- break;
2185
- }
2186
- _context2.next = 11;
2187
- return waitTx(this.rpcClient, txHash);
2188
- case 11:
2189
- return _context2.abrupt("return", {
2190
- txHash: txHash
2191
- });
2192
- case 14:
2193
- _context2.prev = 14;
2194
- _context2.t0 = _context2["catch"](0);
2195
- handleError(_context2.t0, "Failed to remove tag");
2196
- case 17:
2197
- case "end":
2198
- return _context2.stop();
2199
- }
2200
- }, _callee2, this, [[0, 14]]);
2201
- }));
2202
- function removeTag(_x2) {
2203
- return _removeTag.apply(this, arguments);
2204
- }
2205
- return removeTag;
2206
- }()
2207
- }]);
2208
- return TaggingClient;
2209
- }();
2210
-
2211
- var AddressZero = "0x0000000000000000000000000000000000000000";
2212
- var HashZero = "0x0000000000000000000000000000000000000000000000000000000000000000";
2213
-
2214
2132
  function computeRoyaltyContext(_x, _x2) {
2215
2133
  return _computeRoyaltyContext.apply(this, arguments);
2216
2134
  }
@@ -2321,56 +2239,68 @@ var IPAssetClient = /*#__PURE__*/function () {
2321
2239
  key: "registerRootIp",
2322
2240
  value: function () {
2323
2241
  var _registerRootIp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
2324
- var _request$txOptions, _yield$this$rpcClient, call, txHash, targetLog;
2242
+ var _request$txOptions, ipId, _yield$this$rpcClient, call, txHash, targetLog;
2325
2243
  return _regeneratorRuntime().wrap(function _callee$(_context) {
2326
2244
  while (1) switch (_context.prev = _context.next) {
2327
2245
  case 0:
2328
2246
  _context.prev = 0;
2329
2247
  _context.next = 3;
2248
+ return this.isNFTRegistered(SepoliaChainId, request.tokenContractAddress, request.tokenId);
2249
+ case 3:
2250
+ ipId = _context.sent;
2251
+ if (!ipId) {
2252
+ _context.next = 6;
2253
+ break;
2254
+ }
2255
+ return _context.abrupt("return", {
2256
+ ipId: ipId
2257
+ });
2258
+ case 6:
2259
+ _context.next = 8;
2330
2260
  return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.registrationModuleConfig), {}, {
2331
2261
  functionName: "registerRootIp",
2332
- args: [parseToBigInt(request.policyId), viem.getAddress(request.tokenContractAddress),
2262
+ args: [parseToBigInt(request.policyId || "0"), viem.getAddress(request.tokenContractAddress),
2333
2263
  // 0x Address
2334
2264
  parseToBigInt(request.tokenId), request.ipName || "", request.contentHash || HashZero, request.uri || ""],
2335
2265
  account: this.wallet.account
2336
2266
  }));
2337
- case 3:
2267
+ case 8:
2338
2268
  _yield$this$rpcClient = _context.sent;
2339
2269
  call = _yield$this$rpcClient.request;
2340
- _context.next = 7;
2270
+ _context.next = 12;
2341
2271
  return this.wallet.writeContract(call);
2342
- case 7:
2272
+ case 12:
2343
2273
  txHash = _context.sent;
2344
2274
  if (!((_request$txOptions = request.txOptions) !== null && _request$txOptions !== void 0 && _request$txOptions.waitForTransaction)) {
2345
- _context.next = 15;
2275
+ _context.next = 20;
2346
2276
  break;
2347
2277
  }
2348
- _context.next = 11;
2278
+ _context.next = 16;
2349
2279
  return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.ipAssetRegistryConfig), {}, {
2350
2280
  eventName: "IPRegistered"
2351
2281
  }));
2352
- case 11:
2282
+ case 16:
2353
2283
  targetLog = _context.sent;
2354
2284
  return _context.abrupt("return", {
2355
2285
  txHash: txHash,
2356
2286
  ipId: targetLog.args.ipId
2357
2287
  });
2358
- case 15:
2288
+ case 20:
2359
2289
  return _context.abrupt("return", {
2360
2290
  txHash: txHash
2361
2291
  });
2362
- case 16:
2363
- _context.next = 21;
2292
+ case 21:
2293
+ _context.next = 26;
2364
2294
  break;
2365
- case 18:
2366
- _context.prev = 18;
2295
+ case 23:
2296
+ _context.prev = 23;
2367
2297
  _context.t0 = _context["catch"](0);
2368
2298
  handleError(_context.t0, "Failed to register root IP");
2369
- case 21:
2299
+ case 26:
2370
2300
  case "end":
2371
2301
  return _context.stop();
2372
2302
  }
2373
- }, _callee, this, [[0, 18]]);
2303
+ }, _callee, this, [[0, 23]]);
2374
2304
  }));
2375
2305
  function registerRootIp(_x) {
2376
2306
  return _registerRootIp.apply(this, arguments);
@@ -2396,20 +2326,32 @@ var IPAssetClient = /*#__PURE__*/function () {
2396
2326
  key: "registerDerivativeIp",
2397
2327
  value: function () {
2398
2328
  var _registerDerivativeIp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
2399
- var _request$txOptions2, licenseIds, royaltyContext, _yield$this$rpcClient2, call, txHash, targetLog;
2329
+ var _request$txOptions2, ipId, licenseIds, royaltyContext, _yield$this$rpcClient2, call, txHash, targetLog;
2400
2330
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
2401
2331
  while (1) switch (_context2.prev = _context2.next) {
2402
2332
  case 0:
2403
2333
  _context2.prev = 0;
2334
+ _context2.next = 3;
2335
+ return this.isNFTRegistered(SepoliaChainId, request.tokenContractAddress, request.tokenId);
2336
+ case 3:
2337
+ ipId = _context2.sent;
2338
+ if (!(ipId !== "0x")) {
2339
+ _context2.next = 6;
2340
+ break;
2341
+ }
2342
+ return _context2.abrupt("return", {
2343
+ ipId: ipId
2344
+ });
2345
+ case 6:
2404
2346
  licenseIds = [];
2405
2347
  request.licenseIds.forEach(function (licenseId) {
2406
2348
  licenseIds.push(parseToBigInt(licenseId));
2407
2349
  });
2408
- _context2.next = 5;
2350
+ _context2.next = 10;
2409
2351
  return computeRoyaltyContext(request.licenseIds, this.storyClient);
2410
- case 5:
2352
+ case 10:
2411
2353
  royaltyContext = _context2.sent;
2412
- _context2.next = 8;
2354
+ _context2.next = 13;
2413
2355
  return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.registrationModuleConfig), {}, {
2414
2356
  functionName: "registerDerivativeIp",
2415
2357
  args: [licenseIds, viem.getAddress(request.tokenContractAddress),
@@ -2417,49 +2359,83 @@ var IPAssetClient = /*#__PURE__*/function () {
2417
2359
  parseToBigInt(request.tokenId), request.ipName || "", request.contentHash || HashZero, request.uri || "", encodeRoyaltyContext(royaltyContext)],
2418
2360
  account: this.wallet.account
2419
2361
  }));
2420
- case 8:
2362
+ case 13:
2421
2363
  _yield$this$rpcClient2 = _context2.sent;
2422
2364
  call = _yield$this$rpcClient2.request;
2423
- _context2.next = 12;
2365
+ _context2.next = 17;
2424
2366
  return this.wallet.writeContract(call);
2425
- case 12:
2367
+ case 17:
2426
2368
  txHash = _context2.sent;
2427
2369
  if (!((_request$txOptions2 = request.txOptions) !== null && _request$txOptions2 !== void 0 && _request$txOptions2.waitForTransaction)) {
2428
- _context2.next = 20;
2370
+ _context2.next = 25;
2429
2371
  break;
2430
2372
  }
2431
- _context2.next = 16;
2373
+ _context2.next = 21;
2432
2374
  return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.ipAssetRegistryConfig), {}, {
2433
2375
  eventName: "IPRegistered"
2434
2376
  }));
2435
- case 16:
2377
+ case 21:
2436
2378
  targetLog = _context2.sent;
2437
2379
  return _context2.abrupt("return", {
2438
2380
  txHash: txHash,
2439
2381
  ipId: targetLog.args.ipId
2440
2382
  });
2441
- case 20:
2383
+ case 25:
2442
2384
  return _context2.abrupt("return", {
2443
2385
  txHash: txHash
2444
2386
  });
2445
- case 21:
2446
- _context2.next = 26;
2387
+ case 26:
2388
+ _context2.next = 31;
2447
2389
  break;
2448
- case 23:
2449
- _context2.prev = 23;
2390
+ case 28:
2391
+ _context2.prev = 28;
2450
2392
  _context2.t0 = _context2["catch"](0);
2451
2393
  handleError(_context2.t0, "Failed to register derivative IP");
2452
- case 26:
2394
+ case 31:
2453
2395
  case "end":
2454
2396
  return _context2.stop();
2455
2397
  }
2456
- }, _callee2, this, [[0, 23]]);
2398
+ }, _callee2, this, [[0, 28]]);
2457
2399
  }));
2458
2400
  function registerDerivativeIp(_x2) {
2459
2401
  return _registerDerivativeIp.apply(this, arguments);
2460
2402
  }
2461
2403
  return registerDerivativeIp;
2462
2404
  }()
2405
+ }, {
2406
+ key: "isNFTRegistered",
2407
+ value: function () {
2408
+ var _isNFTRegistered = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(chainId, tokenAddress, tokenId) {
2409
+ var ipId, isRegistered;
2410
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
2411
+ while (1) switch (_context3.prev = _context3.next) {
2412
+ case 0:
2413
+ _context3.next = 2;
2414
+ return this.rpcClient.readContract(_objectSpread2(_objectSpread2({}, this.ipAssetRegistryConfig), {}, {
2415
+ functionName: "ipId",
2416
+ args: [parseToBigInt(chainId), tokenAddress, parseToBigInt(tokenId)]
2417
+ }));
2418
+ case 2:
2419
+ ipId = _context3.sent;
2420
+ _context3.next = 5;
2421
+ return this.rpcClient.readContract(_objectSpread2(_objectSpread2({}, this.ipAssetRegistryConfig), {}, {
2422
+ functionName: "isRegistered",
2423
+ args: [ipId]
2424
+ }));
2425
+ case 5:
2426
+ isRegistered = _context3.sent;
2427
+ return _context3.abrupt("return", isRegistered ? ipId : "0x");
2428
+ case 7:
2429
+ case "end":
2430
+ return _context3.stop();
2431
+ }
2432
+ }, _callee3, this);
2433
+ }));
2434
+ function isNFTRegistered(_x3, _x4, _x5) {
2435
+ return _isNFTRegistered.apply(this, arguments);
2436
+ }
2437
+ return isNFTRegistered;
2438
+ }()
2463
2439
  }]);
2464
2440
  return IPAssetClient;
2465
2441
  }();
@@ -2487,7 +2463,7 @@ var PermissionClient = /*#__PURE__*/function () {
2487
2463
  * @param request.ipAsset The address of the IP account that grants the permission for `signer`
2488
2464
  * @param request.signer The address that can call `to` on behalf of the `ipAccount`
2489
2465
  * @param request.to The address that can be called by the `signer` (currently only modules can be `to`)
2490
- * @param request.func The function selector string of `to` that can be called by the `signer` on behalf of the `ipAccount`
2466
+ * @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.
2491
2467
  * @param request.permission The new permission level
2492
2468
  * @returns A Promise that resolves to an object containing the transaction hash
2493
2469
  * @emits PermissionSet (ipAccountOwner, ipAccount, signer, to, func, permission)
@@ -2517,7 +2493,7 @@ var PermissionClient = /*#__PURE__*/function () {
2517
2493
  // 0x Address
2518
2494
  viem.getAddress(request.to),
2519
2495
  // 0x Address
2520
- request.func,
2496
+ request.func || "0x00000000",
2521
2497
  // bytes4
2522
2498
  request.permission // uint8
2523
2499
  ]
@@ -2592,7 +2568,7 @@ var LicenseClient = /*#__PURE__*/function () {
2592
2568
  * @param request.licensorIpId_ The ID of the IP granting the license (ie. licensor)
2593
2569
  * @param request.mintAmount Number of licenses to mint. License NFT is fungible for same policy and same licensors
2594
2570
  * @param request.receiver Receiver address of the minted license NFT(s).
2595
- * @return licenseId The ID of the minted license NFT(s).
2571
+ * @returns licenseId The ID of the minted license NFT(s).
2596
2572
  */
2597
2573
  _createClass(LicenseClient, [{
2598
2574
  key: "mintLicense",
@@ -2754,6 +2730,7 @@ var PolicyClient = /*#__PURE__*/function () {
2754
2730
  _defineProperty(this, "ipAccountABI", IPAccountABI);
2755
2731
  _defineProperty(this, "licensingModuleConfig", LicensingModuleConfig);
2756
2732
  _defineProperty(this, "pilPolicyFrameworkManagerConfig", PILPolicyFrameworkManagerConfig);
2733
+ _defineProperty(this, "royaltyPolicyLAPConfig", RoyaltyPolicyLAPConfig);
2757
2734
  this.wallet = wallet;
2758
2735
  this.rpcClient = rpcClient;
2759
2736
  }
@@ -2781,18 +2758,49 @@ var PolicyClient = /*#__PURE__*/function () {
2781
2758
  key: "registerPILPolicy",
2782
2759
  value: function () {
2783
2760
  var _registerPILPolicy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
2784
- var _request$txOptions, _yield$this$rpcClient, call, txHash, targetLog;
2761
+ var _request$txOptions, frameworkData, policyId, _yield$this$rpcClient, call, txHash, targetLog;
2785
2762
  return _regeneratorRuntime().wrap(function _callee$(_context) {
2786
2763
  while (1) switch (_context.prev = _context.next) {
2787
2764
  case 0:
2788
2765
  _context.prev = 0;
2789
- _context.next = 3;
2766
+ // First check if the policy exists
2767
+ frameworkData = {
2768
+ attribution: request.attribution || false,
2769
+ commercialUse: request.commercialUse || false,
2770
+ commercialAttribution: request.commercialAttribution || false,
2771
+ commercializerChecker: request.commercializerChecker || viem.zeroAddress,
2772
+ commercializerCheckerData: request.commercializerCheckerData || "0x",
2773
+ commercialRevShare: request.commercialRevShare || 0,
2774
+ derivativesAllowed: request.derivativesAllowed || false,
2775
+ derivativesAttribution: request.derivativesAttribution || false,
2776
+ derivativesApproval: request.derivativesApproval || false,
2777
+ derivativesReciprocal: request.derivativesReciprocal || false,
2778
+ territories: request.territories || [],
2779
+ distributionChannels: request.distributionChannels || [],
2780
+ contentRestrictions: request.contentRestrictions || []
2781
+ };
2782
+ _context.next = 4;
2783
+ return this.getPolicyId(request.transferable, this.encodeFrameworkData(frameworkData), typedDataToBytes({
2784
+ "interface": "uint32",
2785
+ data: [request.commercialRevShare || 0]
2786
+ }), request.mintingFee || "0", request.mintingFeeToken || viem.zeroAddress, request.royaltyPolicy || viem.zeroAddress);
2787
+ case 4:
2788
+ policyId = _context.sent;
2789
+ if (!(policyId !== 0)) {
2790
+ _context.next = 7;
2791
+ break;
2792
+ }
2793
+ return _context.abrupt("return", {
2794
+ policyId: policyId.toString()
2795
+ });
2796
+ case 7:
2797
+ _context.next = 9;
2790
2798
  return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.pilPolicyFrameworkManagerConfig), {}, {
2791
2799
  functionName: "registerPolicy",
2792
2800
  args: [{
2793
2801
  transferable: request.transferable,
2794
2802
  royaltyPolicy: request.royaltyPolicy || viem.zeroAddress,
2795
- mintingFee: parseToBigInt(request.mintingFee || 0),
2803
+ mintingFee: parseToBigInt(request.mintingFee || "0"),
2796
2804
  mintingFeeToken: request.mintingFeeToken || viem.zeroAddress,
2797
2805
  policy: {
2798
2806
  attribution: request.attribution || false,
@@ -2800,7 +2808,7 @@ var PolicyClient = /*#__PURE__*/function () {
2800
2808
  commercialAttribution: request.commercialAttribution || false,
2801
2809
  commercialRevShare: request.commercialRevShare || 0,
2802
2810
  derivativesAllowed: request.derivativesAllowed || false,
2803
- derivativesAttribution: request.commercialAttribution || false,
2811
+ derivativesAttribution: request.derivativesAttribution || false,
2804
2812
  derivativesApproval: request.derivativesApproval || false,
2805
2813
  derivativesReciprocal: request.derivativesReciprocal || false,
2806
2814
  commercializerChecker: request.commercializerChecker || viem.zeroAddress,
@@ -2812,49 +2820,332 @@ var PolicyClient = /*#__PURE__*/function () {
2812
2820
  }],
2813
2821
  account: this.wallet.account
2814
2822
  }));
2815
- case 3:
2823
+ case 9:
2816
2824
  _yield$this$rpcClient = _context.sent;
2817
2825
  call = _yield$this$rpcClient.request;
2818
- _context.next = 7;
2826
+ _context.next = 13;
2819
2827
  return this.wallet.writeContract(call);
2820
- case 7:
2828
+ case 13:
2821
2829
  txHash = _context.sent;
2822
2830
  if (!((_request$txOptions = request.txOptions) !== null && _request$txOptions !== void 0 && _request$txOptions.waitForTransaction)) {
2823
- _context.next = 15;
2831
+ _context.next = 21;
2824
2832
  break;
2825
2833
  }
2826
- _context.next = 11;
2834
+ _context.next = 17;
2827
2835
  return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.licensingModuleConfig), {}, {
2828
2836
  eventName: "PolicyRegistered"
2829
2837
  }));
2830
- case 11:
2838
+ case 17:
2831
2839
  targetLog = _context.sent;
2832
2840
  return _context.abrupt("return", {
2833
2841
  txHash: txHash,
2834
2842
  policyId: targetLog === null || targetLog === void 0 ? void 0 : targetLog.args.policyId.toString()
2835
2843
  });
2836
- case 15:
2844
+ case 21:
2837
2845
  return _context.abrupt("return", {
2838
2846
  txHash: txHash
2839
2847
  });
2840
- case 16:
2841
- _context.next = 21;
2848
+ case 22:
2849
+ _context.next = 27;
2842
2850
  break;
2843
- case 18:
2844
- _context.prev = 18;
2851
+ case 24:
2852
+ _context.prev = 24;
2845
2853
  _context.t0 = _context["catch"](0);
2846
2854
  handleError(_context.t0, "Failed to register policy");
2847
- case 21:
2855
+ case 27:
2848
2856
  case "end":
2849
2857
  return _context.stop();
2850
2858
  }
2851
- }, _callee, this, [[0, 18]]);
2859
+ }, _callee, this, [[0, 24]]);
2852
2860
  }));
2853
2861
  function registerPILPolicy(_x) {
2854
2862
  return _registerPILPolicy.apply(this, arguments);
2855
2863
  }
2856
2864
  return registerPILPolicy;
2857
2865
  }()
2866
+ /**
2867
+ * Convenient function to register a PIL social remix policy to the registry
2868
+ * Internally, this function must generate a Licensing.Policy struct and call registerPolicy.
2869
+ * @param request - the licensing parameters for the Programmable IP License v1 (PIL) standard.
2870
+ * @param request.territories List of territories where the license is valid. If empty, global.
2871
+ * @param request.distributionChannels List of distribution channels where the license is valid. Empty if no restrictions.
2872
+ * @param request.contentRestrictions List of content restrictions where the license is valid. Empty if no restrictions.
2873
+ * @returns the transaction hash and the policy ID if the txOptions.waitForTransaction is set to true
2874
+ */
2875
+ }, {
2876
+ key: "registerPILSocialRemixPolicy",
2877
+ value: function () {
2878
+ var _registerPILSocialRemixPolicy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
2879
+ var _request$txOptions2, frameworkData, policyId, _yield$this$rpcClient2, call, txHash, targetLog;
2880
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
2881
+ while (1) switch (_context2.prev = _context2.next) {
2882
+ case 0:
2883
+ _context2.prev = 0;
2884
+ // First check if the policy exists
2885
+ frameworkData = {
2886
+ attribution: true,
2887
+ commercialUse: false,
2888
+ commercialAttribution: false,
2889
+ commercializerChecker: viem.zeroAddress,
2890
+ commercializerCheckerData: "0x",
2891
+ commercialRevShare: 0,
2892
+ derivativesAllowed: true,
2893
+ derivativesAttribution: true,
2894
+ derivativesApproval: false,
2895
+ derivativesReciprocal: true,
2896
+ territories: request.territories || [],
2897
+ distributionChannels: request.distributionChannels || [],
2898
+ contentRestrictions: request.contentRestrictions || []
2899
+ };
2900
+ _context2.next = 4;
2901
+ return this.getPolicyId(true, this.encodeFrameworkData(frameworkData), typedDataToBytes({
2902
+ "interface": "uint32",
2903
+ data: [0]
2904
+ }), "0", viem.zeroAddress, viem.zeroAddress);
2905
+ case 4:
2906
+ policyId = _context2.sent;
2907
+ if (!(policyId !== 0)) {
2908
+ _context2.next = 7;
2909
+ break;
2910
+ }
2911
+ return _context2.abrupt("return", {
2912
+ policyId: policyId.toString()
2913
+ });
2914
+ case 7:
2915
+ _context2.next = 9;
2916
+ return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.pilPolicyFrameworkManagerConfig), {}, {
2917
+ functionName: "registerPolicy",
2918
+ args: [{
2919
+ transferable: true,
2920
+ royaltyPolicy: viem.zeroAddress,
2921
+ mintingFee: parseToBigInt(0),
2922
+ mintingFeeToken: viem.zeroAddress,
2923
+ policy: {
2924
+ attribution: true,
2925
+ commercialUse: false,
2926
+ commercialAttribution: false,
2927
+ commercialRevShare: 0,
2928
+ derivativesAllowed: true,
2929
+ derivativesAttribution: true,
2930
+ derivativesApproval: false,
2931
+ derivativesReciprocal: true,
2932
+ commercializerChecker: viem.zeroAddress,
2933
+ commercializerCheckerData: "0x",
2934
+ territories: request.territories || [],
2935
+ distributionChannels: request.distributionChannels || [],
2936
+ contentRestrictions: request.contentRestrictions || []
2937
+ }
2938
+ }],
2939
+ account: this.wallet.account
2940
+ }));
2941
+ case 9:
2942
+ _yield$this$rpcClient2 = _context2.sent;
2943
+ call = _yield$this$rpcClient2.request;
2944
+ _context2.next = 13;
2945
+ return this.wallet.writeContract(call);
2946
+ case 13:
2947
+ txHash = _context2.sent;
2948
+ if (!((_request$txOptions2 = request.txOptions) !== null && _request$txOptions2 !== void 0 && _request$txOptions2.waitForTransaction)) {
2949
+ _context2.next = 21;
2950
+ break;
2951
+ }
2952
+ _context2.next = 17;
2953
+ return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.licensingModuleConfig), {}, {
2954
+ eventName: "PolicyRegistered"
2955
+ }));
2956
+ case 17:
2957
+ targetLog = _context2.sent;
2958
+ return _context2.abrupt("return", {
2959
+ txHash: txHash,
2960
+ policyId: targetLog === null || targetLog === void 0 ? void 0 : targetLog.args.policyId.toString()
2961
+ });
2962
+ case 21:
2963
+ return _context2.abrupt("return", {
2964
+ txHash: txHash
2965
+ });
2966
+ case 22:
2967
+ _context2.next = 27;
2968
+ break;
2969
+ case 24:
2970
+ _context2.prev = 24;
2971
+ _context2.t0 = _context2["catch"](0);
2972
+ handleError(_context2.t0, "Failed to register social remix policy");
2973
+ case 27:
2974
+ case "end":
2975
+ return _context2.stop();
2976
+ }
2977
+ }, _callee2, this, [[0, 24]]);
2978
+ }));
2979
+ function registerPILSocialRemixPolicy(_x2) {
2980
+ return _registerPILSocialRemixPolicy.apply(this, arguments);
2981
+ }
2982
+ return registerPILSocialRemixPolicy;
2983
+ }()
2984
+ /**
2985
+ * Convenient function to register a PIL social remix policy to the registry
2986
+ * Internally, this function must generate a Licensing.Policy struct and call registerPolicy.
2987
+ * @param request - the licensing parameters for the Programmable IP License v1 (PIL) standard.
2988
+ * @param request.commercialRevShare Percentage of revenue that must be shared with the licensor
2989
+ * @param mintingFee Fee to be paid when minting a license
2990
+ * @param mintingFeeToken Token to be used to pay the minting fee
2991
+ * @param request.territories List of territories where the license is valid. If empty, global.
2992
+ * @param request.distributionChannels List of distribution channels where the license is valid. Empty if no restrictions.
2993
+ * @param request.contentRestrictions List of content restrictions where the license is valid. Empty if no restrictions.
2994
+ * @returns the transaction hash and the policy ID if the txOptions.waitForTransaction is set to true
2995
+ */
2996
+ }, {
2997
+ key: "registerPILCommercialUsePolicy",
2998
+ value: function () {
2999
+ var _registerPILCommercialUsePolicy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(request) {
3000
+ var _request$txOptions3, frameworkData, policyId, _yield$this$rpcClient3, call, txHash, targetLog;
3001
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
3002
+ while (1) switch (_context3.prev = _context3.next) {
3003
+ case 0:
3004
+ _context3.prev = 0;
3005
+ // First check if the policy exists
3006
+ frameworkData = {
3007
+ attribution: true,
3008
+ commercialUse: true,
3009
+ commercialAttribution: true,
3010
+ commercializerChecker: viem.zeroAddress,
3011
+ commercializerCheckerData: "0x",
3012
+ commercialRevShare: request.commercialRevShare,
3013
+ derivativesAllowed: true,
3014
+ derivativesAttribution: true,
3015
+ derivativesApproval: false,
3016
+ derivativesReciprocal: true,
3017
+ territories: request.territories || [],
3018
+ distributionChannels: request.distributionChannels || [],
3019
+ contentRestrictions: request.contentRestrictions || []
3020
+ };
3021
+ _context3.next = 4;
3022
+ return this.getPolicyId(true, this.encodeFrameworkData(frameworkData), typedDataToBytes({
3023
+ "interface": "uint32",
3024
+ data: [request.commercialRevShare]
3025
+ }), request.mintingFee || "0", request.mintingFeeToken || viem.zeroAddress, this.royaltyPolicyLAPConfig.address);
3026
+ case 4:
3027
+ policyId = _context3.sent;
3028
+ if (!(policyId !== 0)) {
3029
+ _context3.next = 7;
3030
+ break;
3031
+ }
3032
+ return _context3.abrupt("return", {
3033
+ policyId: policyId.toString()
3034
+ });
3035
+ case 7:
3036
+ _context3.next = 9;
3037
+ return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.pilPolicyFrameworkManagerConfig), {}, {
3038
+ functionName: "registerPolicy",
3039
+ args: [{
3040
+ transferable: true,
3041
+ royaltyPolicy: this.royaltyPolicyLAPConfig.address,
3042
+ mintingFee: parseToBigInt(request.mintingFee || "0"),
3043
+ mintingFeeToken: request.mintingFeeToken || viem.zeroAddress,
3044
+ policy: {
3045
+ attribution: true,
3046
+ commercialUse: true,
3047
+ commercialAttribution: true,
3048
+ commercialRevShare: request.commercialRevShare,
3049
+ derivativesAllowed: true,
3050
+ derivativesAttribution: true,
3051
+ derivativesApproval: false,
3052
+ derivativesReciprocal: true,
3053
+ commercializerChecker: viem.zeroAddress,
3054
+ commercializerCheckerData: "0x",
3055
+ territories: request.territories || [],
3056
+ distributionChannels: request.distributionChannels || [],
3057
+ contentRestrictions: request.contentRestrictions || []
3058
+ }
3059
+ }],
3060
+ account: this.wallet.account
3061
+ }));
3062
+ case 9:
3063
+ _yield$this$rpcClient3 = _context3.sent;
3064
+ call = _yield$this$rpcClient3.request;
3065
+ _context3.next = 13;
3066
+ return this.wallet.writeContract(call);
3067
+ case 13:
3068
+ txHash = _context3.sent;
3069
+ if (!((_request$txOptions3 = request.txOptions) !== null && _request$txOptions3 !== void 0 && _request$txOptions3.waitForTransaction)) {
3070
+ _context3.next = 21;
3071
+ break;
3072
+ }
3073
+ _context3.next = 17;
3074
+ return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.licensingModuleConfig), {}, {
3075
+ eventName: "PolicyRegistered"
3076
+ }));
3077
+ case 17:
3078
+ targetLog = _context3.sent;
3079
+ return _context3.abrupt("return", {
3080
+ txHash: txHash,
3081
+ policyId: targetLog === null || targetLog === void 0 ? void 0 : targetLog.args.policyId.toString()
3082
+ });
3083
+ case 21:
3084
+ return _context3.abrupt("return", {
3085
+ txHash: txHash
3086
+ });
3087
+ case 22:
3088
+ _context3.next = 27;
3089
+ break;
3090
+ case 24:
3091
+ _context3.prev = 24;
3092
+ _context3.t0 = _context3["catch"](0);
3093
+ handleError(_context3.t0, "Failed to register commercial use policy");
3094
+ case 27:
3095
+ case "end":
3096
+ return _context3.stop();
3097
+ }
3098
+ }, _callee3, this, [[0, 24]]);
3099
+ }));
3100
+ function registerPILCommercialUsePolicy(_x3) {
3101
+ return _registerPILCommercialUsePolicy.apply(this, arguments);
3102
+ }
3103
+ return registerPILCommercialUsePolicy;
3104
+ }()
3105
+ }, {
3106
+ key: "getPolicyId",
3107
+ value: function () {
3108
+ var _getPolicyId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(transferable, frameworkData, royaltyData, mintingFee, mintingFeeToken, royaltyPolicy, policyFramework) {
3109
+ var data;
3110
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
3111
+ while (1) switch (_context4.prev = _context4.next) {
3112
+ case 0:
3113
+ _context4.next = 2;
3114
+ return this.rpcClient.readContract(_objectSpread2(_objectSpread2({}, this.licensingModuleConfig), {}, {
3115
+ functionName: "getPolicyId",
3116
+ args: [{
3117
+ isLicenseTransferable: transferable,
3118
+ policyFramework: policyFramework || this.pilPolicyFrameworkManagerConfig.address,
3119
+ frameworkData: frameworkData,
3120
+ royaltyPolicy: royaltyPolicy,
3121
+ royaltyData: royaltyData,
3122
+ mintingFee: parseToBigInt(mintingFee),
3123
+ mintingFeeToken: mintingFeeToken
3124
+ }]
3125
+ }));
3126
+ case 2:
3127
+ data = _context4.sent;
3128
+ return _context4.abrupt("return", Number(data));
3129
+ case 4:
3130
+ case "end":
3131
+ return _context4.stop();
3132
+ }
3133
+ }, _callee4, this);
3134
+ }));
3135
+ function getPolicyId(_x4, _x5, _x6, _x7, _x8, _x9, _x10) {
3136
+ return _getPolicyId.apply(this, arguments);
3137
+ }
3138
+ return getPolicyId;
3139
+ }()
3140
+ }, {
3141
+ key: "encodeFrameworkData",
3142
+ value: function encodeFrameworkData(data) {
3143
+ return typedDataToBytes({
3144
+ "interface": "(bool, bool, bool, address, bytes, uint32, bool, bool, bool, bool, string[], string[], string[])",
3145
+ 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]]
3146
+ });
3147
+ }
3148
+
2858
3149
  /**
2859
3150
  * Adds a policy to the set of policies of an IP
2860
3151
  * @param request The request object containing details to add a policy to an IP
@@ -2865,17 +3156,17 @@ var PolicyClient = /*#__PURE__*/function () {
2865
3156
  }, {
2866
3157
  key: "addPolicyToIp",
2867
3158
  value: function () {
2868
- var _addPolicyToIp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
2869
- var _request$txOptions2, IPAccountConfig, _yield$this$rpcClient2, call, txHash, targetLog;
2870
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
2871
- while (1) switch (_context2.prev = _context2.next) {
3159
+ var _addPolicyToIp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(request) {
3160
+ var _request$txOptions4, IPAccountConfig, _yield$this$rpcClient4, call, txHash, targetLog;
3161
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
3162
+ while (1) switch (_context5.prev = _context5.next) {
2872
3163
  case 0:
2873
- _context2.prev = 0;
3164
+ _context5.prev = 0;
2874
3165
  IPAccountConfig = {
2875
3166
  abi: this.ipAccountABI,
2876
3167
  address: viem.getAddress(request.ipId)
2877
3168
  };
2878
- _context2.next = 4;
3169
+ _context5.next = 4;
2879
3170
  return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, IPAccountConfig), {}, {
2880
3171
  functionName: "execute",
2881
3172
  args: [this.licensingModuleConfig.address, parseToBigInt(0), viem.encodeFunctionData({
@@ -2886,44 +3177,44 @@ var PolicyClient = /*#__PURE__*/function () {
2886
3177
  account: this.wallet.account
2887
3178
  }));
2888
3179
  case 4:
2889
- _yield$this$rpcClient2 = _context2.sent;
2890
- call = _yield$this$rpcClient2.request;
2891
- _context2.next = 8;
3180
+ _yield$this$rpcClient4 = _context5.sent;
3181
+ call = _yield$this$rpcClient4.request;
3182
+ _context5.next = 8;
2892
3183
  return this.wallet.writeContract(call);
2893
3184
  case 8:
2894
- txHash = _context2.sent;
2895
- if (!((_request$txOptions2 = request.txOptions) !== null && _request$txOptions2 !== void 0 && _request$txOptions2.waitForTransaction)) {
2896
- _context2.next = 16;
3185
+ txHash = _context5.sent;
3186
+ if (!((_request$txOptions4 = request.txOptions) !== null && _request$txOptions4 !== void 0 && _request$txOptions4.waitForTransaction)) {
3187
+ _context5.next = 16;
2897
3188
  break;
2898
3189
  }
2899
- _context2.next = 12;
3190
+ _context5.next = 12;
2900
3191
  return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.licensingModuleConfig), {}, {
2901
3192
  eventName: "PolicyAddedToIpId"
2902
3193
  }));
2903
3194
  case 12:
2904
- targetLog = _context2.sent;
2905
- return _context2.abrupt("return", {
3195
+ targetLog = _context5.sent;
3196
+ return _context5.abrupt("return", {
2906
3197
  txHash: txHash,
2907
3198
  index: targetLog.args.index.toString()
2908
3199
  });
2909
3200
  case 16:
2910
- return _context2.abrupt("return", {
3201
+ return _context5.abrupt("return", {
2911
3202
  txHash: txHash
2912
3203
  });
2913
3204
  case 17:
2914
- _context2.next = 22;
3205
+ _context5.next = 22;
2915
3206
  break;
2916
3207
  case 19:
2917
- _context2.prev = 19;
2918
- _context2.t0 = _context2["catch"](0);
2919
- handleError(_context2.t0, "Failed to add policy to IP");
3208
+ _context5.prev = 19;
3209
+ _context5.t0 = _context5["catch"](0);
3210
+ handleError(_context5.t0, "Failed to add policy to IP");
2920
3211
  case 22:
2921
3212
  case "end":
2922
- return _context2.stop();
3213
+ return _context5.stop();
2923
3214
  }
2924
- }, _callee2, this, [[0, 19]]);
3215
+ }, _callee5, this, [[0, 19]]);
2925
3216
  }));
2926
- function addPolicyToIp(_x2) {
3217
+ function addPolicyToIp(_x11) {
2927
3218
  return _addPolicyToIp.apply(this, arguments);
2928
3219
  }
2929
3220
  return addPolicyToIp;
@@ -3132,6 +3423,137 @@ var DisputeClient = /*#__PURE__*/function () {
3132
3423
  return DisputeClient;
3133
3424
  }();
3134
3425
 
3426
+ var IPAccountClient = /*#__PURE__*/function () {
3427
+ function IPAccountClient(rpcClient, wallet) {
3428
+ _classCallCheck(this, IPAccountClient);
3429
+ _defineProperty(this, "ipAccountABI", IPAccountABI);
3430
+ this.wallet = wallet;
3431
+ this.rpcClient = rpcClient;
3432
+ }
3433
+
3434
+ /** Executes a transaction from the IP Account.
3435
+ * @param request The request object containing necessary data to execute IP Account a transaction.
3436
+ * @param request.to The recipient of the transaction.
3437
+ * @param request.value The amount of Ether to send.
3438
+ * @param request.data The data to send along with the transaction.
3439
+ * @returns Tx hash for the transaction.
3440
+ */
3441
+ _createClass(IPAccountClient, [{
3442
+ key: "execute",
3443
+ value: function () {
3444
+ var _execute = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
3445
+ var _request$txOptions, IPAccountConfig, _yield$this$rpcClient, call, txHash;
3446
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
3447
+ while (1) switch (_context.prev = _context.next) {
3448
+ case 0:
3449
+ _context.prev = 0;
3450
+ IPAccountConfig = {
3451
+ abi: this.ipAccountABI,
3452
+ address: viem.getAddress(request.accountAddress)
3453
+ };
3454
+ _context.next = 4;
3455
+ return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, IPAccountConfig), {}, {
3456
+ functionName: "execute",
3457
+ args: [request.to, parseToBigInt(0), request.data],
3458
+ account: this.wallet.account
3459
+ }));
3460
+ case 4:
3461
+ _yield$this$rpcClient = _context.sent;
3462
+ call = _yield$this$rpcClient.request;
3463
+ _context.next = 8;
3464
+ return this.wallet.writeContract(call);
3465
+ case 8:
3466
+ txHash = _context.sent;
3467
+ if (!((_request$txOptions = request.txOptions) !== null && _request$txOptions !== void 0 && _request$txOptions.waitForTransaction)) {
3468
+ _context.next = 12;
3469
+ break;
3470
+ }
3471
+ _context.next = 12;
3472
+ return waitTx(this.rpcClient, txHash);
3473
+ case 12:
3474
+ return _context.abrupt("return", {
3475
+ txHash: txHash
3476
+ });
3477
+ case 15:
3478
+ _context.prev = 15;
3479
+ _context.t0 = _context["catch"](0);
3480
+ handleError(_context.t0, "Failed to execute the IP Account transaction");
3481
+ case 18:
3482
+ case "end":
3483
+ return _context.stop();
3484
+ }
3485
+ }, _callee, this, [[0, 15]]);
3486
+ }));
3487
+ function execute(_x) {
3488
+ return _execute.apply(this, arguments);
3489
+ }
3490
+ return execute;
3491
+ }()
3492
+ /** Executes a transaction from the IP Account.
3493
+ * @param request The request object containing necessary data to execute IP Account a transaction.
3494
+ * @param request.to The recipient of the transaction.
3495
+ * @param request.value The amount of Ether to send.
3496
+ * @param request.data The data to send along with the transaction.
3497
+ * @param request.signer The signer of the transaction.
3498
+ * @param request.deadline The deadline of the transaction signature.
3499
+ * @param request.signature The signature of the transaction, EIP-712 encoded.
3500
+ * @returns Tx hash for the transaction.
3501
+ */
3502
+ }, {
3503
+ key: "executeWithSig",
3504
+ value: function () {
3505
+ var _executeWithSig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
3506
+ var _request$txOptions2, IPAccountConfig, _yield$this$rpcClient2, call, txHash;
3507
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
3508
+ while (1) switch (_context2.prev = _context2.next) {
3509
+ case 0:
3510
+ _context2.prev = 0;
3511
+ IPAccountConfig = {
3512
+ abi: this.ipAccountABI,
3513
+ address: viem.getAddress(request.accountAddress)
3514
+ };
3515
+ _context2.next = 4;
3516
+ return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, IPAccountConfig), {}, {
3517
+ functionName: "executeWithSig",
3518
+ args: [request.to, parseToBigInt(0), request.data, request.signer, parseToBigInt(request.deadline), request.signature],
3519
+ account: this.wallet.account
3520
+ }));
3521
+ case 4:
3522
+ _yield$this$rpcClient2 = _context2.sent;
3523
+ call = _yield$this$rpcClient2.request;
3524
+ _context2.next = 8;
3525
+ return this.wallet.writeContract(call);
3526
+ case 8:
3527
+ txHash = _context2.sent;
3528
+ if (!((_request$txOptions2 = request.txOptions) !== null && _request$txOptions2 !== void 0 && _request$txOptions2.waitForTransaction)) {
3529
+ _context2.next = 12;
3530
+ break;
3531
+ }
3532
+ _context2.next = 12;
3533
+ return waitTx(this.rpcClient, txHash);
3534
+ case 12:
3535
+ return _context2.abrupt("return", {
3536
+ txHash: txHash
3537
+ });
3538
+ case 15:
3539
+ _context2.prev = 15;
3540
+ _context2.t0 = _context2["catch"](0);
3541
+ handleError(_context2.t0, "Failed to execute with signature for the IP Account transaction");
3542
+ case 18:
3543
+ case "end":
3544
+ return _context2.stop();
3545
+ }
3546
+ }, _callee2, this, [[0, 15]]);
3547
+ }));
3548
+ function executeWithSig(_x2) {
3549
+ return _executeWithSig.apply(this, arguments);
3550
+ }
3551
+ return executeWithSig;
3552
+ }()
3553
+ }]);
3554
+ return IPAccountClient;
3555
+ }();
3556
+
3135
3557
  var StoryAPIClient = /*#__PURE__*/function () {
3136
3558
  function StoryAPIClient() {
3137
3559
  _classCallCheck(this, StoryAPIClient);
@@ -3152,7 +3574,7 @@ var StoryAPIClient = /*#__PURE__*/function () {
3152
3574
  while (1) switch (_context.prev = _context.next) {
3153
3575
  case 0:
3154
3576
  _context.next = 2;
3155
- return this.httpClient.get("/api/v1/royaltypolicies/".concat(ipId));
3577
+ return this.httpClient.get("/api/v1/royalties/policies/".concat(ipId));
3156
3578
  case 2:
3157
3579
  royaltyPolicyResp = _context.sent;
3158
3580
  return _context.abrupt("return", royaltyPolicyResp.data.data);
@@ -3231,12 +3653,12 @@ var StoryClient = /*#__PURE__*/function () {
3231
3653
  */
3232
3654
  function StoryClient(config) {
3233
3655
  _classCallCheck(this, StoryClient);
3234
- _defineProperty(this, "_ipAccount", null);
3656
+ _defineProperty(this, "_ipAsset", null);
3235
3657
  _defineProperty(this, "_permission", null);
3236
3658
  _defineProperty(this, "_license", null);
3237
3659
  _defineProperty(this, "_policy", null);
3238
- _defineProperty(this, "_tagging", null);
3239
3660
  _defineProperty(this, "_dispute", null);
3661
+ _defineProperty(this, "_ipAccount", null);
3240
3662
  this.config = config;
3241
3663
  if (!this.config.transport) {
3242
3664
  throw new Error("transport is null, please pass in a valid RPC Provider URL as the transport.");
@@ -3263,12 +3685,26 @@ var StoryClient = /*#__PURE__*/function () {
3263
3685
  */
3264
3686
  _createClass(StoryClient, [{
3265
3687
  key: "ipAsset",
3266
- get: function get() {
3267
- if (this._ipAccount === null) {
3268
- this._ipAccount = new IPAssetClient(this.rpcClient, this.wallet, this.storyClient);
3688
+ get:
3689
+ /**
3690
+ * Getter for the ip asset client. The client is lazily created when
3691
+ * this method is called.
3692
+ *
3693
+ * @returns the IPAssetClient instance
3694
+ */
3695
+ function get() {
3696
+ if (this._ipAsset === null) {
3697
+ this._ipAsset = new IPAssetClient(this.rpcClient, this.wallet, this.storyClient);
3269
3698
  }
3270
- return this._ipAccount;
3699
+ return this._ipAsset;
3271
3700
  }
3701
+
3702
+ /**
3703
+ * Getter for the permission client. The client is lazily created when
3704
+ * this method is called.
3705
+ *
3706
+ * @returns the PermissionClient instance
3707
+ */
3272
3708
  }, {
3273
3709
  key: "permission",
3274
3710
  get: function get() {
@@ -3277,6 +3713,13 @@ var StoryClient = /*#__PURE__*/function () {
3277
3713
  }
3278
3714
  return this._permission;
3279
3715
  }
3716
+
3717
+ /**
3718
+ * Getter for the license client. The client is lazily created when
3719
+ * this method is called.
3720
+ *
3721
+ * @returns the LicenseClient instance
3722
+ */
3280
3723
  }, {
3281
3724
  key: "license",
3282
3725
  get: function get() {
@@ -3285,6 +3728,13 @@ var StoryClient = /*#__PURE__*/function () {
3285
3728
  }
3286
3729
  return this._license;
3287
3730
  }
3731
+
3732
+ /**
3733
+ * Getter for the policy client. The client is lazily created when
3734
+ * this method is called.
3735
+ *
3736
+ * @returns the PolicyClient instance
3737
+ */
3288
3738
  }, {
3289
3739
  key: "policy",
3290
3740
  get: function get() {
@@ -3295,33 +3745,33 @@ var StoryClient = /*#__PURE__*/function () {
3295
3745
  }
3296
3746
 
3297
3747
  /**
3298
- * Getter for the tagging client. The client is lazily created when
3748
+ * Getter for the dispute client. The client is lazily created when
3299
3749
  * this method is called.
3300
3750
  *
3301
- * @returns the TaggingClient instance
3751
+ * @returns the DisputeClient instance
3302
3752
  */
3303
3753
  }, {
3304
- key: "tagging",
3754
+ key: "dispute",
3305
3755
  get: function get() {
3306
- if (this._tagging === null) {
3307
- this._tagging = new TaggingClient(this.rpcClient, this.wallet);
3756
+ if (this._dispute === null) {
3757
+ this._dispute = new DisputeClient(this.rpcClient, this.wallet);
3308
3758
  }
3309
- return this._tagging;
3759
+ return this._dispute;
3310
3760
  }
3311
3761
 
3312
3762
  /**
3313
- * Getter for the dispute client. The client is lazily created when
3763
+ * Getter for the ip account client. The client is lazily created when
3314
3764
  * this method is called.
3315
3765
  *
3316
- * @returns the DisputeClient instance
3766
+ * @returns the IPAccountClient instance
3317
3767
  */
3318
3768
  }, {
3319
- key: "dispute",
3769
+ key: "ipAccount",
3320
3770
  get: function get() {
3321
- if (this._dispute === null) {
3322
- this._dispute = new DisputeClient(this.rpcClient, this.wallet);
3771
+ if (this._ipAccount === null) {
3772
+ this._ipAccount = new IPAccountClient(this.rpcClient, this.wallet);
3323
3773
  }
3324
- return this._dispute;
3774
+ return this._ipAccount;
3325
3775
  }
3326
3776
  }], [{
3327
3777
  key: "newClient",
@@ -3340,4 +3790,3 @@ exports.LicenseClient = LicenseClient;
3340
3790
  exports.PermissionClient = PermissionClient;
3341
3791
  exports.PolicyClient = PolicyClient;
3342
3792
  exports.StoryClient = StoryClient;
3343
- exports.TaggingClient = TaggingClient;