@story-protocol/core-sdk 0.0.1-beta-rc.5 → 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.
- package/README.md +97 -43
- package/dist/declarations/src/constants/common.d.ts +1 -0
- package/dist/declarations/src/constants/common.d.ts.map +1 -1
- package/dist/declarations/src/resources/dispute.d.ts +0 -20
- package/dist/declarations/src/resources/dispute.d.ts.map +1 -1
- package/dist/declarations/src/resources/ipAccount.d.ts +0 -20
- package/dist/declarations/src/resources/ipAccount.d.ts.map +1 -1
- package/dist/declarations/src/resources/ipAsset.d.ts +52 -21
- package/dist/declarations/src/resources/ipAsset.d.ts.map +1 -1
- package/dist/declarations/src/resources/license.d.ts +43 -40
- package/dist/declarations/src/resources/license.d.ts.map +1 -1
- package/dist/declarations/src/resources/permission.d.ts +1 -41
- package/dist/declarations/src/resources/permission.d.ts.map +1 -1
- package/dist/declarations/src/resources/policy.d.ts +99 -82
- package/dist/declarations/src/resources/policy.d.ts.map +1 -1
- package/dist/declarations/src/types/resources/ipAsset.d.ts +4 -4
- package/dist/declarations/src/types/resources/ipAsset.d.ts.map +1 -1
- package/dist/declarations/src/types/resources/permission.d.ts +1 -1
- package/dist/declarations/src/types/resources/permission.d.ts.map +1 -1
- package/dist/declarations/src/types/resources/policy.d.ts +39 -1
- package/dist/declarations/src/types/resources/policy.d.ts.map +1 -1
- package/dist/story-protocol-core-sdk.cjs.dev.js +551 -114
- package/dist/story-protocol-core-sdk.cjs.prod.js +551 -114
- package/dist/story-protocol-core-sdk.esm.js +552 -115
- package/package.json +1 -1
@@ -1,4 +1,4 @@
|
|
1
|
-
import { getAddress,
|
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';
|
@@ -422,6 +422,7 @@ function handleError(error, msg) {
|
|
422
422
|
|
423
423
|
var AddressZero = "0x0000000000000000000000000000000000000000";
|
424
424
|
var HashZero = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
425
|
+
var SepoliaChainId = "11155111";
|
425
426
|
|
426
427
|
function _arrayLikeToArray(arr, len) {
|
427
428
|
if (len == null || len > arr.length) len = arr.length;
|
@@ -794,6 +795,42 @@ var IPAssetRegistryABI = [{
|
|
794
795
|
}],
|
795
796
|
name: "IPRegistered",
|
796
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"
|
797
834
|
}];
|
798
835
|
|
799
836
|
var LicensingModuleABI = [{
|
@@ -904,6 +941,49 @@ var LicensingModuleABI = [{
|
|
904
941
|
}],
|
905
942
|
stateMutability: "nonpayable",
|
906
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"
|
907
987
|
}, {
|
908
988
|
inputs: [{
|
909
989
|
internalType: "uint256[]",
|
@@ -1805,50 +1885,31 @@ var ErrorsABI = [{
|
|
1805
1885
|
inputs: [],
|
1806
1886
|
name: "RoyaltyPolicyLAP__ZeroRoyaltyModule",
|
1807
1887
|
type: "error"
|
1808
|
-
}, {
|
1809
|
-
inputs: [],
|
1810
|
-
name: "TaggingModule__DstIpIdDoesNotHaveDstTag",
|
1811
|
-
type: "error"
|
1812
|
-
}, {
|
1813
|
-
inputs: [],
|
1814
|
-
name: "TaggingModule__InvalidRelationTypeName",
|
1815
|
-
type: "error"
|
1816
|
-
}, {
|
1817
|
-
inputs: [],
|
1818
|
-
name: "TaggingModule__RelationTypeAlreadyExists",
|
1819
|
-
type: "error"
|
1820
|
-
}, {
|
1821
|
-
inputs: [],
|
1822
|
-
name: "TaggingModule__RelationTypeDoesNotExist",
|
1823
|
-
type: "error"
|
1824
|
-
}, {
|
1825
|
-
inputs: [],
|
1826
|
-
name: "TaggingModule__SrcIpIdDoesNotHaveSrcTag",
|
1827
|
-
type: "error"
|
1828
1888
|
}];
|
1829
1889
|
|
1830
1890
|
var sepolia = {
|
1831
|
-
AccessController: "
|
1832
|
-
AncestorsVaultLAP: "
|
1833
|
-
ArbitrationPolicySP: "
|
1834
|
-
DisputeModule: "
|
1835
|
-
Governance: "
|
1836
|
-
IPAccountImpl: "
|
1837
|
-
IPAccountRegistry: "
|
1838
|
-
IPAssetRegistry: "
|
1839
|
-
IPAssetRenderer: "
|
1840
|
-
IPMetadataProvider: "
|
1841
|
-
IPResolver: "
|
1842
|
-
LicenseRegistry: "
|
1843
|
-
LicensingModule: "
|
1844
|
-
MockERC20: "
|
1845
|
-
MockERC721: "
|
1846
|
-
MockTokenGatedHook: "
|
1847
|
-
ModuleRegistry: "
|
1848
|
-
PILPolicyFrameworkManager: "
|
1849
|
-
RegistrationModule: "
|
1850
|
-
RoyaltyModule: "
|
1851
|
-
RoyaltyPolicyLAP: "
|
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"
|
1852
1913
|
};
|
1853
1914
|
|
1854
1915
|
var IPAccountABI = [].concat(_toConsumableArray(IPAccountImplABI), _toConsumableArray(ErrorsABI));
|
@@ -1880,6 +1941,9 @@ var PILPolicyFrameworkManagerConfig = {
|
|
1880
1941
|
abi: [].concat(_toConsumableArray(PILPolicyFrameworkManagerABI), _toConsumableArray(ErrorsABI)),
|
1881
1942
|
address: getAddress(sepolia.PILPolicyFrameworkManager)
|
1882
1943
|
};
|
1944
|
+
var RoyaltyPolicyLAPConfig = {
|
1945
|
+
address: getAddress(sepolia.RoyaltyPolicyLAP)
|
1946
|
+
};
|
1883
1947
|
|
1884
1948
|
function _createForOfIteratorHelper(o, allowArrayLike) {
|
1885
1949
|
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
@@ -2148,12 +2212,24 @@ var IPAssetClient = /*#__PURE__*/function () {
|
|
2148
2212
|
key: "registerRootIp",
|
2149
2213
|
value: function () {
|
2150
2214
|
var _registerRootIp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
|
2151
|
-
var _request$txOptions, _yield$this$rpcClient, call, txHash, targetLog;
|
2215
|
+
var _request$txOptions, ipId, _yield$this$rpcClient, call, txHash, targetLog;
|
2152
2216
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
2153
2217
|
while (1) switch (_context.prev = _context.next) {
|
2154
2218
|
case 0:
|
2155
2219
|
_context.prev = 0;
|
2156
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;
|
2157
2233
|
return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.registrationModuleConfig), {}, {
|
2158
2234
|
functionName: "registerRootIp",
|
2159
2235
|
args: [parseToBigInt(request.policyId || "0"), getAddress(request.tokenContractAddress),
|
@@ -2161,43 +2237,43 @@ var IPAssetClient = /*#__PURE__*/function () {
|
|
2161
2237
|
parseToBigInt(request.tokenId), request.ipName || "", request.contentHash || HashZero, request.uri || ""],
|
2162
2238
|
account: this.wallet.account
|
2163
2239
|
}));
|
2164
|
-
case
|
2240
|
+
case 8:
|
2165
2241
|
_yield$this$rpcClient = _context.sent;
|
2166
2242
|
call = _yield$this$rpcClient.request;
|
2167
|
-
_context.next =
|
2243
|
+
_context.next = 12;
|
2168
2244
|
return this.wallet.writeContract(call);
|
2169
|
-
case
|
2245
|
+
case 12:
|
2170
2246
|
txHash = _context.sent;
|
2171
2247
|
if (!((_request$txOptions = request.txOptions) !== null && _request$txOptions !== void 0 && _request$txOptions.waitForTransaction)) {
|
2172
|
-
_context.next =
|
2248
|
+
_context.next = 20;
|
2173
2249
|
break;
|
2174
2250
|
}
|
2175
|
-
_context.next =
|
2251
|
+
_context.next = 16;
|
2176
2252
|
return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.ipAssetRegistryConfig), {}, {
|
2177
2253
|
eventName: "IPRegistered"
|
2178
2254
|
}));
|
2179
|
-
case
|
2255
|
+
case 16:
|
2180
2256
|
targetLog = _context.sent;
|
2181
2257
|
return _context.abrupt("return", {
|
2182
2258
|
txHash: txHash,
|
2183
2259
|
ipId: targetLog.args.ipId
|
2184
2260
|
});
|
2185
|
-
case
|
2261
|
+
case 20:
|
2186
2262
|
return _context.abrupt("return", {
|
2187
2263
|
txHash: txHash
|
2188
2264
|
});
|
2189
|
-
case
|
2190
|
-
_context.next =
|
2265
|
+
case 21:
|
2266
|
+
_context.next = 26;
|
2191
2267
|
break;
|
2192
|
-
case
|
2193
|
-
_context.prev =
|
2268
|
+
case 23:
|
2269
|
+
_context.prev = 23;
|
2194
2270
|
_context.t0 = _context["catch"](0);
|
2195
2271
|
handleError(_context.t0, "Failed to register root IP");
|
2196
|
-
case
|
2272
|
+
case 26:
|
2197
2273
|
case "end":
|
2198
2274
|
return _context.stop();
|
2199
2275
|
}
|
2200
|
-
}, _callee, this, [[0,
|
2276
|
+
}, _callee, this, [[0, 23]]);
|
2201
2277
|
}));
|
2202
2278
|
function registerRootIp(_x) {
|
2203
2279
|
return _registerRootIp.apply(this, arguments);
|
@@ -2223,20 +2299,32 @@ var IPAssetClient = /*#__PURE__*/function () {
|
|
2223
2299
|
key: "registerDerivativeIp",
|
2224
2300
|
value: function () {
|
2225
2301
|
var _registerDerivativeIp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
|
2226
|
-
var _request$txOptions2, licenseIds, royaltyContext, _yield$this$rpcClient2, call, txHash, targetLog;
|
2302
|
+
var _request$txOptions2, ipId, licenseIds, royaltyContext, _yield$this$rpcClient2, call, txHash, targetLog;
|
2227
2303
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
2228
2304
|
while (1) switch (_context2.prev = _context2.next) {
|
2229
2305
|
case 0:
|
2230
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:
|
2231
2319
|
licenseIds = [];
|
2232
2320
|
request.licenseIds.forEach(function (licenseId) {
|
2233
2321
|
licenseIds.push(parseToBigInt(licenseId));
|
2234
2322
|
});
|
2235
|
-
_context2.next =
|
2323
|
+
_context2.next = 10;
|
2236
2324
|
return computeRoyaltyContext(request.licenseIds, this.storyClient);
|
2237
|
-
case
|
2325
|
+
case 10:
|
2238
2326
|
royaltyContext = _context2.sent;
|
2239
|
-
_context2.next =
|
2327
|
+
_context2.next = 13;
|
2240
2328
|
return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.registrationModuleConfig), {}, {
|
2241
2329
|
functionName: "registerDerivativeIp",
|
2242
2330
|
args: [licenseIds, getAddress(request.tokenContractAddress),
|
@@ -2244,49 +2332,83 @@ var IPAssetClient = /*#__PURE__*/function () {
|
|
2244
2332
|
parseToBigInt(request.tokenId), request.ipName || "", request.contentHash || HashZero, request.uri || "", encodeRoyaltyContext(royaltyContext)],
|
2245
2333
|
account: this.wallet.account
|
2246
2334
|
}));
|
2247
|
-
case
|
2335
|
+
case 13:
|
2248
2336
|
_yield$this$rpcClient2 = _context2.sent;
|
2249
2337
|
call = _yield$this$rpcClient2.request;
|
2250
|
-
_context2.next =
|
2338
|
+
_context2.next = 17;
|
2251
2339
|
return this.wallet.writeContract(call);
|
2252
|
-
case
|
2340
|
+
case 17:
|
2253
2341
|
txHash = _context2.sent;
|
2254
2342
|
if (!((_request$txOptions2 = request.txOptions) !== null && _request$txOptions2 !== void 0 && _request$txOptions2.waitForTransaction)) {
|
2255
|
-
_context2.next =
|
2343
|
+
_context2.next = 25;
|
2256
2344
|
break;
|
2257
2345
|
}
|
2258
|
-
_context2.next =
|
2346
|
+
_context2.next = 21;
|
2259
2347
|
return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.ipAssetRegistryConfig), {}, {
|
2260
2348
|
eventName: "IPRegistered"
|
2261
2349
|
}));
|
2262
|
-
case
|
2350
|
+
case 21:
|
2263
2351
|
targetLog = _context2.sent;
|
2264
2352
|
return _context2.abrupt("return", {
|
2265
2353
|
txHash: txHash,
|
2266
2354
|
ipId: targetLog.args.ipId
|
2267
2355
|
});
|
2268
|
-
case
|
2356
|
+
case 25:
|
2269
2357
|
return _context2.abrupt("return", {
|
2270
2358
|
txHash: txHash
|
2271
2359
|
});
|
2272
|
-
case
|
2273
|
-
_context2.next =
|
2360
|
+
case 26:
|
2361
|
+
_context2.next = 31;
|
2274
2362
|
break;
|
2275
|
-
case
|
2276
|
-
_context2.prev =
|
2363
|
+
case 28:
|
2364
|
+
_context2.prev = 28;
|
2277
2365
|
_context2.t0 = _context2["catch"](0);
|
2278
2366
|
handleError(_context2.t0, "Failed to register derivative IP");
|
2279
|
-
case
|
2367
|
+
case 31:
|
2280
2368
|
case "end":
|
2281
2369
|
return _context2.stop();
|
2282
2370
|
}
|
2283
|
-
}, _callee2, this, [[0,
|
2371
|
+
}, _callee2, this, [[0, 28]]);
|
2284
2372
|
}));
|
2285
2373
|
function registerDerivativeIp(_x2) {
|
2286
2374
|
return _registerDerivativeIp.apply(this, arguments);
|
2287
2375
|
}
|
2288
2376
|
return registerDerivativeIp;
|
2289
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
|
+
}()
|
2290
2412
|
}]);
|
2291
2413
|
return IPAssetClient;
|
2292
2414
|
}();
|
@@ -2314,7 +2436,7 @@ var PermissionClient = /*#__PURE__*/function () {
|
|
2314
2436
|
* @param request.ipAsset The address of the IP account that grants the permission for `signer`
|
2315
2437
|
* @param request.signer The address that can call `to` on behalf of the `ipAccount`
|
2316
2438
|
* @param request.to The address that can be called by the `signer` (currently only modules can be `to`)
|
2317
|
-
* @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.
|
2318
2440
|
* @param request.permission The new permission level
|
2319
2441
|
* @returns A Promise that resolves to an object containing the transaction hash
|
2320
2442
|
* @emits PermissionSet (ipAccountOwner, ipAccount, signer, to, func, permission)
|
@@ -2344,7 +2466,7 @@ var PermissionClient = /*#__PURE__*/function () {
|
|
2344
2466
|
// 0x Address
|
2345
2467
|
getAddress(request.to),
|
2346
2468
|
// 0x Address
|
2347
|
-
request.func,
|
2469
|
+
request.func || "0x00000000",
|
2348
2470
|
// bytes4
|
2349
2471
|
request.permission // uint8
|
2350
2472
|
]
|
@@ -2581,6 +2703,7 @@ var PolicyClient = /*#__PURE__*/function () {
|
|
2581
2703
|
_defineProperty(this, "ipAccountABI", IPAccountABI);
|
2582
2704
|
_defineProperty(this, "licensingModuleConfig", LicensingModuleConfig);
|
2583
2705
|
_defineProperty(this, "pilPolicyFrameworkManagerConfig", PILPolicyFrameworkManagerConfig);
|
2706
|
+
_defineProperty(this, "royaltyPolicyLAPConfig", RoyaltyPolicyLAPConfig);
|
2584
2707
|
this.wallet = wallet;
|
2585
2708
|
this.rpcClient = rpcClient;
|
2586
2709
|
}
|
@@ -2608,18 +2731,49 @@ var PolicyClient = /*#__PURE__*/function () {
|
|
2608
2731
|
key: "registerPILPolicy",
|
2609
2732
|
value: function () {
|
2610
2733
|
var _registerPILPolicy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
|
2611
|
-
var _request$txOptions, _yield$this$rpcClient, call, txHash, targetLog;
|
2734
|
+
var _request$txOptions, frameworkData, policyId, _yield$this$rpcClient, call, txHash, targetLog;
|
2612
2735
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
2613
2736
|
while (1) switch (_context.prev = _context.next) {
|
2614
2737
|
case 0:
|
2615
2738
|
_context.prev = 0;
|
2616
|
-
|
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;
|
2617
2771
|
return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.pilPolicyFrameworkManagerConfig), {}, {
|
2618
2772
|
functionName: "registerPolicy",
|
2619
2773
|
args: [{
|
2620
2774
|
transferable: request.transferable,
|
2621
2775
|
royaltyPolicy: request.royaltyPolicy || zeroAddress,
|
2622
|
-
mintingFee: parseToBigInt(request.mintingFee || 0),
|
2776
|
+
mintingFee: parseToBigInt(request.mintingFee || "0"),
|
2623
2777
|
mintingFeeToken: request.mintingFeeToken || zeroAddress,
|
2624
2778
|
policy: {
|
2625
2779
|
attribution: request.attribution || false,
|
@@ -2627,7 +2781,7 @@ var PolicyClient = /*#__PURE__*/function () {
|
|
2627
2781
|
commercialAttribution: request.commercialAttribution || false,
|
2628
2782
|
commercialRevShare: request.commercialRevShare || 0,
|
2629
2783
|
derivativesAllowed: request.derivativesAllowed || false,
|
2630
|
-
derivativesAttribution: request.
|
2784
|
+
derivativesAttribution: request.derivativesAttribution || false,
|
2631
2785
|
derivativesApproval: request.derivativesApproval || false,
|
2632
2786
|
derivativesReciprocal: request.derivativesReciprocal || false,
|
2633
2787
|
commercializerChecker: request.commercializerChecker || zeroAddress,
|
@@ -2639,49 +2793,332 @@ var PolicyClient = /*#__PURE__*/function () {
|
|
2639
2793
|
}],
|
2640
2794
|
account: this.wallet.account
|
2641
2795
|
}));
|
2642
|
-
case
|
2796
|
+
case 9:
|
2643
2797
|
_yield$this$rpcClient = _context.sent;
|
2644
2798
|
call = _yield$this$rpcClient.request;
|
2645
|
-
_context.next =
|
2799
|
+
_context.next = 13;
|
2646
2800
|
return this.wallet.writeContract(call);
|
2647
|
-
case
|
2801
|
+
case 13:
|
2648
2802
|
txHash = _context.sent;
|
2649
2803
|
if (!((_request$txOptions = request.txOptions) !== null && _request$txOptions !== void 0 && _request$txOptions.waitForTransaction)) {
|
2650
|
-
_context.next =
|
2804
|
+
_context.next = 21;
|
2651
2805
|
break;
|
2652
2806
|
}
|
2653
|
-
_context.next =
|
2807
|
+
_context.next = 17;
|
2654
2808
|
return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.licensingModuleConfig), {}, {
|
2655
2809
|
eventName: "PolicyRegistered"
|
2656
2810
|
}));
|
2657
|
-
case
|
2811
|
+
case 17:
|
2658
2812
|
targetLog = _context.sent;
|
2659
2813
|
return _context.abrupt("return", {
|
2660
2814
|
txHash: txHash,
|
2661
2815
|
policyId: targetLog === null || targetLog === void 0 ? void 0 : targetLog.args.policyId.toString()
|
2662
2816
|
});
|
2663
|
-
case
|
2817
|
+
case 21:
|
2664
2818
|
return _context.abrupt("return", {
|
2665
2819
|
txHash: txHash
|
2666
2820
|
});
|
2667
|
-
case
|
2668
|
-
_context.next =
|
2821
|
+
case 22:
|
2822
|
+
_context.next = 27;
|
2669
2823
|
break;
|
2670
|
-
case
|
2671
|
-
_context.prev =
|
2824
|
+
case 24:
|
2825
|
+
_context.prev = 24;
|
2672
2826
|
_context.t0 = _context["catch"](0);
|
2673
2827
|
handleError(_context.t0, "Failed to register policy");
|
2674
|
-
case
|
2828
|
+
case 27:
|
2675
2829
|
case "end":
|
2676
2830
|
return _context.stop();
|
2677
2831
|
}
|
2678
|
-
}, _callee, this, [[0,
|
2832
|
+
}, _callee, this, [[0, 24]]);
|
2679
2833
|
}));
|
2680
2834
|
function registerPILPolicy(_x) {
|
2681
2835
|
return _registerPILPolicy.apply(this, arguments);
|
2682
2836
|
}
|
2683
2837
|
return registerPILPolicy;
|
2684
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
|
+
|
2685
3122
|
/**
|
2686
3123
|
* Adds a policy to the set of policies of an IP
|
2687
3124
|
* @param request The request object containing details to add a policy to an IP
|
@@ -2692,17 +3129,17 @@ var PolicyClient = /*#__PURE__*/function () {
|
|
2692
3129
|
}, {
|
2693
3130
|
key: "addPolicyToIp",
|
2694
3131
|
value: function () {
|
2695
|
-
var _addPolicyToIp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
2696
|
-
var _request$
|
2697
|
-
return _regeneratorRuntime().wrap(function
|
2698
|
-
while (1) switch (
|
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) {
|
2699
3136
|
case 0:
|
2700
|
-
|
3137
|
+
_context5.prev = 0;
|
2701
3138
|
IPAccountConfig = {
|
2702
3139
|
abi: this.ipAccountABI,
|
2703
3140
|
address: getAddress(request.ipId)
|
2704
3141
|
};
|
2705
|
-
|
3142
|
+
_context5.next = 4;
|
2706
3143
|
return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, IPAccountConfig), {}, {
|
2707
3144
|
functionName: "execute",
|
2708
3145
|
args: [this.licensingModuleConfig.address, parseToBigInt(0), encodeFunctionData({
|
@@ -2713,44 +3150,44 @@ var PolicyClient = /*#__PURE__*/function () {
|
|
2713
3150
|
account: this.wallet.account
|
2714
3151
|
}));
|
2715
3152
|
case 4:
|
2716
|
-
_yield$this$
|
2717
|
-
call = _yield$this$
|
2718
|
-
|
3153
|
+
_yield$this$rpcClient4 = _context5.sent;
|
3154
|
+
call = _yield$this$rpcClient4.request;
|
3155
|
+
_context5.next = 8;
|
2719
3156
|
return this.wallet.writeContract(call);
|
2720
3157
|
case 8:
|
2721
|
-
txHash =
|
2722
|
-
if (!((_request$
|
2723
|
-
|
3158
|
+
txHash = _context5.sent;
|
3159
|
+
if (!((_request$txOptions4 = request.txOptions) !== null && _request$txOptions4 !== void 0 && _request$txOptions4.waitForTransaction)) {
|
3160
|
+
_context5.next = 16;
|
2724
3161
|
break;
|
2725
3162
|
}
|
2726
|
-
|
3163
|
+
_context5.next = 12;
|
2727
3164
|
return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.licensingModuleConfig), {}, {
|
2728
3165
|
eventName: "PolicyAddedToIpId"
|
2729
3166
|
}));
|
2730
3167
|
case 12:
|
2731
|
-
targetLog =
|
2732
|
-
return
|
3168
|
+
targetLog = _context5.sent;
|
3169
|
+
return _context5.abrupt("return", {
|
2733
3170
|
txHash: txHash,
|
2734
3171
|
index: targetLog.args.index.toString()
|
2735
3172
|
});
|
2736
3173
|
case 16:
|
2737
|
-
return
|
3174
|
+
return _context5.abrupt("return", {
|
2738
3175
|
txHash: txHash
|
2739
3176
|
});
|
2740
3177
|
case 17:
|
2741
|
-
|
3178
|
+
_context5.next = 22;
|
2742
3179
|
break;
|
2743
3180
|
case 19:
|
2744
|
-
|
2745
|
-
|
2746
|
-
handleError(
|
3181
|
+
_context5.prev = 19;
|
3182
|
+
_context5.t0 = _context5["catch"](0);
|
3183
|
+
handleError(_context5.t0, "Failed to add policy to IP");
|
2747
3184
|
case 22:
|
2748
3185
|
case "end":
|
2749
|
-
return
|
3186
|
+
return _context5.stop();
|
2750
3187
|
}
|
2751
|
-
},
|
3188
|
+
}, _callee5, this, [[0, 19]]);
|
2752
3189
|
}));
|
2753
|
-
function addPolicyToIp(
|
3190
|
+
function addPolicyToIp(_x11) {
|
2754
3191
|
return _addPolicyToIp.apply(this, arguments);
|
2755
3192
|
}
|
2756
3193
|
return addPolicyToIp;
|