@story-protocol/core-sdk 0.0.1-beta-rc.3 → 0.0.1-beta-rc.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/declarations/src/client.d.ts +28 -13
- package/dist/declarations/src/client.d.ts.map +1 -1
- package/dist/declarations/src/clients/storyAPI.d.ts +11 -0
- package/dist/declarations/src/clients/storyAPI.d.ts.map +1 -0
- package/dist/declarations/src/index.d.ts +2 -4
- package/dist/declarations/src/index.d.ts.map +1 -1
- package/dist/declarations/src/resources/dispute.d.ts.map +1 -1
- package/dist/declarations/src/resources/ipAccount.d.ts +752 -0
- package/dist/declarations/src/resources/ipAccount.d.ts.map +1 -0
- package/dist/declarations/src/resources/ipAsset.d.ts +674 -4
- package/dist/declarations/src/resources/ipAsset.d.ts.map +1 -1
- package/dist/declarations/src/resources/license.d.ts +736 -66
- package/dist/declarations/src/resources/license.d.ts.map +1 -1
- package/dist/declarations/src/resources/permission.d.ts +58 -58
- package/dist/declarations/src/resources/policy.d.ts +1416 -66
- package/dist/declarations/src/resources/policy.d.ts.map +1 -1
- package/dist/declarations/src/types/resources/ipAccount.d.ts +25 -0
- package/dist/declarations/src/types/resources/ipAccount.d.ts.map +1 -0
- package/dist/declarations/src/types/resources/ipAsset.d.ts +1 -1
- package/dist/declarations/src/types/resources/ipAsset.d.ts.map +1 -1
- package/dist/declarations/src/types/resources/license.d.ts +8 -1
- package/dist/declarations/src/types/resources/license.d.ts.map +1 -1
- package/dist/declarations/src/types/resources/permission.d.ts +2 -2
- package/dist/declarations/src/types/resources/policy.d.ts +11 -1
- package/dist/declarations/src/types/resources/policy.d.ts.map +1 -1
- package/dist/declarations/src/types/resources/royalty.d.ts +17 -0
- package/dist/declarations/src/types/resources/royalty.d.ts.map +1 -0
- package/dist/story-protocol-core-sdk.cjs.dev.js +412 -299
- package/dist/story-protocol-core-sdk.cjs.prod.js +412 -299
- package/dist/story-protocol-core-sdk.esm.js +413 -298
- package/package.json +5 -5
- package/dist/declarations/src/resources/tagging.d.ts +0 -718
- package/dist/declarations/src/resources/tagging.d.ts.map +0 -1
- package/dist/declarations/src/types/resources/tagging.d.ts +0 -23
- package/dist/declarations/src/types/resources/tagging.d.ts.map +0 -1
- package/dist/declarations/src/utils/platform.d.ts +0 -17
- package/dist/declarations/src/utils/platform.d.ts.map +0 -1
@@ -3,9 +3,9 @@
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
5
|
var viem = require('viem');
|
6
|
-
var axios = require('axios');
|
7
6
|
var dotenv = require('dotenv');
|
8
7
|
var chains = require('viem/chains');
|
8
|
+
var axios = require('axios');
|
9
9
|
|
10
10
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
11
11
|
|
@@ -27,8 +27,8 @@ function _interopNamespace(e) {
|
|
27
27
|
return Object.freeze(n);
|
28
28
|
}
|
29
29
|
|
30
|
-
var axios__default = /*#__PURE__*/_interopDefault(axios);
|
31
30
|
var dotenv__namespace = /*#__PURE__*/_interopNamespace(dotenv);
|
31
|
+
var axios__default = /*#__PURE__*/_interopDefault(axios);
|
32
32
|
|
33
33
|
function _toPrimitive(input, hint) {
|
34
34
|
if (typeof input !== "object" || input === null) return input;
|
@@ -447,6 +447,9 @@ 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
|
+
|
450
453
|
function _arrayLikeToArray(arr, len) {
|
451
454
|
if (len == null || len > arr.length) len = arr.length;
|
452
455
|
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
@@ -1181,44 +1184,6 @@ var RegistrationModuleABI = [{
|
|
1181
1184
|
type: "function"
|
1182
1185
|
}];
|
1183
1186
|
|
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
1187
|
var ErrorsABI = [{
|
1223
1188
|
inputs: [{
|
1224
1189
|
internalType: "address",
|
@@ -1910,8 +1875,7 @@ var sepolia = {
|
|
1910
1875
|
PILPolicyFrameworkManager: "0x49cF5C5523011F8B4A0489969096Eb68C571C197",
|
1911
1876
|
RegistrationModule: "0x248c8CbF469ec7CB22Dc9914E569920b93d717a3",
|
1912
1877
|
RoyaltyModule: "0x512bbF310452cC96E0E9818B0870EcA557b86d4D",
|
1913
|
-
RoyaltyPolicyLAP: "0x8404061350BA0CA85c4E733B0be78c5519679003"
|
1914
|
-
TaggingModule: "0xED445f1DeE74Cf470Aab47F4b63734653C4C9537"
|
1878
|
+
RoyaltyPolicyLAP: "0x8404061350BA0CA85c4E733B0be78c5519679003"
|
1915
1879
|
};
|
1916
1880
|
|
1917
1881
|
var IPAccountABI = [].concat(_toConsumableArray(IPAccountImplABI), _toConsumableArray(ErrorsABI));
|
@@ -1932,22 +1896,15 @@ var LicenseRegistryConfig = {
|
|
1932
1896
|
address: viem.getAddress(sepolia.LicenseRegistry)
|
1933
1897
|
};
|
1934
1898
|
var LicensingModuleConfig = {
|
1935
|
-
abi: LicensingModuleABI,
|
1936
|
-
//abi: [...LicensingModuleABI, ...ErrorsABI],
|
1899
|
+
abi: [].concat(_toConsumableArray(LicensingModuleABI), _toConsumableArray(ErrorsABI)),
|
1937
1900
|
address: viem.getAddress(sepolia.LicensingModule)
|
1938
1901
|
};
|
1939
1902
|
var RegistrationModuleConfig = {
|
1940
|
-
abi: RegistrationModuleABI,
|
1941
|
-
//abi: [...RegistrationModuleABI, ...ErrorsABI],
|
1903
|
+
abi: [].concat(_toConsumableArray(RegistrationModuleABI), _toConsumableArray(ErrorsABI)),
|
1942
1904
|
address: viem.getAddress(sepolia.RegistrationModule)
|
1943
1905
|
};
|
1944
|
-
var TaggingModuleConfig = {
|
1945
|
-
abi: [].concat(_toConsumableArray(TaggingModuleABI), _toConsumableArray(ErrorsABI)),
|
1946
|
-
address: viem.getAddress(sepolia.TaggingModule)
|
1947
|
-
};
|
1948
1906
|
var PILPolicyFrameworkManagerConfig = {
|
1949
|
-
abi: PILPolicyFrameworkManagerABI,
|
1950
|
-
//abi: [...PILPolicyFrameworkManagerABI, ...ErrorsABI],
|
1907
|
+
abi: [].concat(_toConsumableArray(PILPolicyFrameworkManagerABI), _toConsumableArray(ErrorsABI)),
|
1951
1908
|
address: viem.getAddress(sepolia.PILPolicyFrameworkManager)
|
1952
1909
|
};
|
1953
1910
|
|
@@ -2088,6 +2045,9 @@ function _waitTx() {
|
|
2088
2045
|
}));
|
2089
2046
|
return _waitTx.apply(this, arguments);
|
2090
2047
|
}
|
2048
|
+
function typedDataToBytes(typedData) {
|
2049
|
+
return viem.encodeAbiParameters(viem.parseAbiParameters(typedData["interface"]), typedData.data);
|
2050
|
+
}
|
2091
2051
|
function chainStringToViemChain(chainId) {
|
2092
2052
|
switch (chainId) {
|
2093
2053
|
case "1":
|
@@ -2105,119 +2065,95 @@ function chainStringToViemChain(chainId) {
|
|
2105
2065
|
}
|
2106
2066
|
}
|
2107
2067
|
|
2108
|
-
|
2109
|
-
|
2110
|
-
|
2111
|
-
|
2112
|
-
|
2113
|
-
|
2114
|
-
|
2115
|
-
|
2116
|
-
|
2117
|
-
|
2118
|
-
|
2119
|
-
|
2120
|
-
|
2121
|
-
|
2122
|
-
|
2123
|
-
|
2124
|
-
|
2125
|
-
|
2126
|
-
|
2127
|
-
|
2128
|
-
|
2129
|
-
|
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();
|
2068
|
+
function computeRoyaltyContext(_x, _x2) {
|
2069
|
+
return _computeRoyaltyContext.apply(this, arguments);
|
2070
|
+
}
|
2071
|
+
function _computeRoyaltyContext() {
|
2072
|
+
_computeRoyaltyContext = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(licenseIds, storyClient) {
|
2073
|
+
var royaltyContext, i, licenseData, royaltyPolicy, policy, targetRoyaltyAmount;
|
2074
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
2075
|
+
while (1) switch (_context.prev = _context.next) {
|
2076
|
+
case 0:
|
2077
|
+
royaltyContext = {
|
2078
|
+
targetAncestors: [],
|
2079
|
+
targetRoyaltyAmount: [],
|
2080
|
+
parentAncestors1: [],
|
2081
|
+
parentAncestors2: [],
|
2082
|
+
parentAncestorsRoyalties1: [],
|
2083
|
+
parentAncestorsRoyalties2: []
|
2084
|
+
};
|
2085
|
+
i = 0;
|
2086
|
+
case 2:
|
2087
|
+
if (!(i < licenseIds.length)) {
|
2088
|
+
_context.next = 16;
|
2089
|
+
break;
|
2153
2090
|
}
|
2154
|
-
|
2155
|
-
|
2156
|
-
|
2157
|
-
|
2158
|
-
|
2159
|
-
|
2160
|
-
|
2161
|
-
|
2162
|
-
|
2163
|
-
|
2164
|
-
|
2165
|
-
|
2166
|
-
|
2167
|
-
|
2168
|
-
|
2169
|
-
|
2170
|
-
|
2171
|
-
|
2172
|
-
|
2173
|
-
|
2174
|
-
|
2175
|
-
|
2176
|
-
|
2177
|
-
|
2178
|
-
|
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();
|
2091
|
+
_context.next = 5;
|
2092
|
+
return storyClient.getLicense(licenseIds[i]);
|
2093
|
+
case 5:
|
2094
|
+
licenseData = _context.sent;
|
2095
|
+
_context.next = 8;
|
2096
|
+
return storyClient.getRoyaltyPolicy(licenseData.licensorIpId);
|
2097
|
+
case 8:
|
2098
|
+
royaltyPolicy = _context.sent;
|
2099
|
+
_context.next = 11;
|
2100
|
+
return storyClient.getPolicy(licenseData.policyId);
|
2101
|
+
case 11:
|
2102
|
+
policy = _context.sent;
|
2103
|
+
if (royaltyPolicy) {
|
2104
|
+
targetRoyaltyAmount = royaltyPolicy.targetRoyaltyAmount.map(function (e) {
|
2105
|
+
return parseInt(e);
|
2106
|
+
});
|
2107
|
+
if (i === 0) {
|
2108
|
+
royaltyContext.parentAncestors1 = royaltyPolicy.targetAncestors;
|
2109
|
+
royaltyContext.parentAncestorsRoyalties1 = targetRoyaltyAmount;
|
2110
|
+
} else {
|
2111
|
+
royaltyContext.parentAncestors2 = royaltyPolicy.targetAncestors;
|
2112
|
+
royaltyContext.parentAncestorsRoyalties2 = targetRoyaltyAmount;
|
2113
|
+
}
|
2114
|
+
updateRoyaltyContext(royaltyContext, [licenseData.licensorIpId], [parseInt(policy.pil.commercialRevShare)]);
|
2115
|
+
updateRoyaltyContext(royaltyContext, royaltyPolicy.targetAncestors, targetRoyaltyAmount);
|
2199
2116
|
}
|
2200
|
-
|
2201
|
-
|
2202
|
-
|
2203
|
-
|
2117
|
+
case 13:
|
2118
|
+
i++;
|
2119
|
+
_context.next = 2;
|
2120
|
+
break;
|
2121
|
+
case 16:
|
2122
|
+
return _context.abrupt("return", royaltyContext);
|
2123
|
+
case 17:
|
2124
|
+
case "end":
|
2125
|
+
return _context.stop();
|
2204
2126
|
}
|
2205
|
-
|
2206
|
-
|
2207
|
-
|
2208
|
-
|
2209
|
-
|
2210
|
-
|
2211
|
-
|
2212
|
-
|
2127
|
+
}, _callee);
|
2128
|
+
}));
|
2129
|
+
return _computeRoyaltyContext.apply(this, arguments);
|
2130
|
+
}
|
2131
|
+
function encodeRoyaltyContext(royaltyContext) {
|
2132
|
+
return typedDataToBytes({
|
2133
|
+
"interface": "(address[], uint32[], address[], address[], uint32[], uint32[])",
|
2134
|
+
data: [[royaltyContext.targetAncestors, royaltyContext.targetRoyaltyAmount, royaltyContext.parentAncestors1, royaltyContext.parentAncestors2, royaltyContext.parentAncestorsRoyalties1, royaltyContext.parentAncestorsRoyalties2]]
|
2135
|
+
});
|
2136
|
+
}
|
2137
|
+
function updateRoyaltyContext(royaltyContext, targetAncestors, targetRoyaltyAccounts) {
|
2138
|
+
for (var i = 0; i < targetAncestors.length; i++) {
|
2139
|
+
var index = royaltyContext.targetAncestors.indexOf(targetAncestors[i]);
|
2140
|
+
if (index === -1) {
|
2141
|
+
royaltyContext.targetAncestors.push(targetAncestors[i]);
|
2142
|
+
royaltyContext.targetRoyaltyAmount.push(targetRoyaltyAccounts[i]);
|
2143
|
+
} else {
|
2144
|
+
royaltyContext.targetRoyaltyAmount[index] += targetRoyaltyAccounts[i];
|
2145
|
+
}
|
2146
|
+
}
|
2147
|
+
}
|
2213
2148
|
|
2214
2149
|
var IPAssetClient = /*#__PURE__*/function () {
|
2215
|
-
function IPAssetClient(rpcClient, wallet) {
|
2150
|
+
function IPAssetClient(rpcClient, wallet, storyClient) {
|
2216
2151
|
_classCallCheck(this, IPAssetClient);
|
2217
2152
|
_defineProperty(this, "ipAssetRegistryConfig", IPAssetRegistryConfig);
|
2218
2153
|
_defineProperty(this, "registrationModuleConfig", RegistrationModuleConfig);
|
2219
2154
|
this.wallet = wallet;
|
2220
2155
|
this.rpcClient = rpcClient;
|
2156
|
+
this.storyClient = storyClient;
|
2221
2157
|
}
|
2222
2158
|
|
2223
2159
|
/**
|
@@ -2247,7 +2183,7 @@ var IPAssetClient = /*#__PURE__*/function () {
|
|
2247
2183
|
_context.next = 3;
|
2248
2184
|
return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.registrationModuleConfig), {}, {
|
2249
2185
|
functionName: "registerRootIp",
|
2250
|
-
args: [parseToBigInt(request.policyId), viem.getAddress(request.tokenContractAddress),
|
2186
|
+
args: [parseToBigInt(request.policyId || "0"), viem.getAddress(request.tokenContractAddress),
|
2251
2187
|
// 0x Address
|
2252
2188
|
parseToBigInt(request.tokenId), request.ipName || "", request.contentHash || HashZero, request.uri || ""],
|
2253
2189
|
account: this.wallet.account
|
@@ -2314,7 +2250,7 @@ var IPAssetClient = /*#__PURE__*/function () {
|
|
2314
2250
|
key: "registerDerivativeIp",
|
2315
2251
|
value: function () {
|
2316
2252
|
var _registerDerivativeIp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
|
2317
|
-
var _request$txOptions2, licenseIds, _yield$this$rpcClient2, call, txHash, targetLog;
|
2253
|
+
var _request$txOptions2, licenseIds, royaltyContext, _yield$this$rpcClient2, call, txHash, targetLog;
|
2318
2254
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
2319
2255
|
while (1) switch (_context2.prev = _context2.next) {
|
2320
2256
|
case 0:
|
@@ -2324,50 +2260,54 @@ var IPAssetClient = /*#__PURE__*/function () {
|
|
2324
2260
|
licenseIds.push(parseToBigInt(licenseId));
|
2325
2261
|
});
|
2326
2262
|
_context2.next = 5;
|
2263
|
+
return computeRoyaltyContext(request.licenseIds, this.storyClient);
|
2264
|
+
case 5:
|
2265
|
+
royaltyContext = _context2.sent;
|
2266
|
+
_context2.next = 8;
|
2327
2267
|
return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.registrationModuleConfig), {}, {
|
2328
2268
|
functionName: "registerDerivativeIp",
|
2329
2269
|
args: [licenseIds, viem.getAddress(request.tokenContractAddress),
|
2330
2270
|
// 0x Address
|
2331
|
-
parseToBigInt(request.tokenId), request.ipName || "", request.contentHash || HashZero, request.uri || "",
|
2271
|
+
parseToBigInt(request.tokenId), request.ipName || "", request.contentHash || HashZero, request.uri || "", encodeRoyaltyContext(royaltyContext)],
|
2332
2272
|
account: this.wallet.account
|
2333
2273
|
}));
|
2334
|
-
case
|
2274
|
+
case 8:
|
2335
2275
|
_yield$this$rpcClient2 = _context2.sent;
|
2336
2276
|
call = _yield$this$rpcClient2.request;
|
2337
|
-
_context2.next =
|
2277
|
+
_context2.next = 12;
|
2338
2278
|
return this.wallet.writeContract(call);
|
2339
|
-
case
|
2279
|
+
case 12:
|
2340
2280
|
txHash = _context2.sent;
|
2341
2281
|
if (!((_request$txOptions2 = request.txOptions) !== null && _request$txOptions2 !== void 0 && _request$txOptions2.waitForTransaction)) {
|
2342
|
-
_context2.next =
|
2282
|
+
_context2.next = 20;
|
2343
2283
|
break;
|
2344
2284
|
}
|
2345
|
-
_context2.next =
|
2285
|
+
_context2.next = 16;
|
2346
2286
|
return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.ipAssetRegistryConfig), {}, {
|
2347
2287
|
eventName: "IPRegistered"
|
2348
2288
|
}));
|
2349
|
-
case
|
2289
|
+
case 16:
|
2350
2290
|
targetLog = _context2.sent;
|
2351
2291
|
return _context2.abrupt("return", {
|
2352
2292
|
txHash: txHash,
|
2353
2293
|
ipId: targetLog.args.ipId
|
2354
2294
|
});
|
2355
|
-
case
|
2295
|
+
case 20:
|
2356
2296
|
return _context2.abrupt("return", {
|
2357
2297
|
txHash: txHash
|
2358
2298
|
});
|
2359
|
-
case
|
2360
|
-
_context2.next =
|
2299
|
+
case 21:
|
2300
|
+
_context2.next = 26;
|
2361
2301
|
break;
|
2362
|
-
case
|
2363
|
-
_context2.prev =
|
2302
|
+
case 23:
|
2303
|
+
_context2.prev = 23;
|
2364
2304
|
_context2.t0 = _context2["catch"](0);
|
2365
2305
|
handleError(_context2.t0, "Failed to register derivative IP");
|
2366
|
-
case
|
2306
|
+
case 26:
|
2367
2307
|
case "end":
|
2368
2308
|
return _context2.stop();
|
2369
2309
|
}
|
2370
|
-
}, _callee2, this, [[0,
|
2310
|
+
}, _callee2, this, [[0, 23]]);
|
2371
2311
|
}));
|
2372
2312
|
function registerDerivativeIp(_x2) {
|
2373
2313
|
return _registerDerivativeIp.apply(this, arguments);
|
@@ -2486,13 +2426,14 @@ var PermissionClient = /*#__PURE__*/function () {
|
|
2486
2426
|
}();
|
2487
2427
|
|
2488
2428
|
var LicenseClient = /*#__PURE__*/function () {
|
2489
|
-
function LicenseClient(rpcClient, wallet) {
|
2429
|
+
function LicenseClient(rpcClient, wallet, storyClient) {
|
2490
2430
|
_classCallCheck(this, LicenseClient);
|
2491
2431
|
_defineProperty(this, "ipAccountABI", IPAccountABI);
|
2492
2432
|
_defineProperty(this, "licenseRegistryConfig", LicenseRegistryConfig);
|
2493
2433
|
_defineProperty(this, "licensingModuleConfig", LicensingModuleConfig);
|
2494
2434
|
this.wallet = wallet;
|
2495
2435
|
this.rpcClient = rpcClient;
|
2436
|
+
this.storyClient = storyClient;
|
2496
2437
|
}
|
2497
2438
|
|
2498
2439
|
/**
|
@@ -2505,68 +2446,79 @@ var LicenseClient = /*#__PURE__*/function () {
|
|
2505
2446
|
* @param request.licensorIpId_ The ID of the IP granting the license (ie. licensor)
|
2506
2447
|
* @param request.mintAmount Number of licenses to mint. License NFT is fungible for same policy and same licensors
|
2507
2448
|
* @param request.receiver Receiver address of the minted license NFT(s).
|
2508
|
-
* @
|
2449
|
+
* @returns licenseId The ID of the minted license NFT(s).
|
2509
2450
|
*/
|
2510
2451
|
_createClass(LicenseClient, [{
|
2511
2452
|
key: "mintLicense",
|
2512
2453
|
value: function () {
|
2513
2454
|
var _mintLicense = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
|
2514
|
-
var _request$txOptions,
|
2455
|
+
var _request$txOptions, royaltyContext, royaltyPolicy, _royaltyContext$targe, _royaltyContext$targe2, targetRoyaltyAmount, _yield$this$rpcClient, call, txHash, targetLog;
|
2515
2456
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
2516
2457
|
while (1) switch (_context.prev = _context.next) {
|
2517
2458
|
case 0:
|
2518
2459
|
_context.prev = 0;
|
2519
|
-
|
2520
|
-
|
2521
|
-
|
2460
|
+
royaltyContext = {
|
2461
|
+
targetAncestors: [],
|
2462
|
+
targetRoyaltyAmount: [],
|
2463
|
+
parentAncestors1: [],
|
2464
|
+
parentAncestors2: [],
|
2465
|
+
parentAncestorsRoyalties1: [],
|
2466
|
+
parentAncestorsRoyalties2: []
|
2522
2467
|
};
|
2523
2468
|
_context.next = 4;
|
2524
|
-
return this.
|
2525
|
-
|
2526
|
-
|
2527
|
-
|
2528
|
-
|
2529
|
-
|
2530
|
-
|
2469
|
+
return this.storyClient.getRoyaltyPolicy(request.licensorIpId);
|
2470
|
+
case 4:
|
2471
|
+
royaltyPolicy = _context.sent;
|
2472
|
+
if (royaltyPolicy) {
|
2473
|
+
(_royaltyContext$targe = royaltyContext.targetAncestors).push.apply(_royaltyContext$targe, _toConsumableArray(royaltyPolicy.targetAncestors));
|
2474
|
+
targetRoyaltyAmount = royaltyPolicy.targetRoyaltyAmount.map(function (e) {
|
2475
|
+
return parseInt(e);
|
2476
|
+
});
|
2477
|
+
(_royaltyContext$targe2 = royaltyContext.targetRoyaltyAmount).push.apply(_royaltyContext$targe2, _toConsumableArray(targetRoyaltyAmount));
|
2478
|
+
}
|
2479
|
+
_context.next = 8;
|
2480
|
+
return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.licensingModuleConfig), {}, {
|
2481
|
+
functionName: "mintLicense",
|
2482
|
+
args: [parseToBigInt(request.policyId), request.licensorIpId, parseToBigInt(request.mintAmount), viem.getAddress(request.receiverAddress), encodeRoyaltyContext(royaltyContext)],
|
2531
2483
|
account: this.wallet.account
|
2532
2484
|
}));
|
2533
|
-
case
|
2485
|
+
case 8:
|
2534
2486
|
_yield$this$rpcClient = _context.sent;
|
2535
2487
|
call = _yield$this$rpcClient.request;
|
2536
|
-
_context.next =
|
2488
|
+
_context.next = 12;
|
2537
2489
|
return this.wallet.writeContract(call);
|
2538
|
-
case
|
2490
|
+
case 12:
|
2539
2491
|
txHash = _context.sent;
|
2540
2492
|
if (!((_request$txOptions = request.txOptions) !== null && _request$txOptions !== void 0 && _request$txOptions.waitForTransaction)) {
|
2541
|
-
_context.next =
|
2493
|
+
_context.next = 20;
|
2542
2494
|
break;
|
2543
2495
|
}
|
2544
|
-
_context.next =
|
2496
|
+
_context.next = 16;
|
2545
2497
|
return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.licenseRegistryConfig), {}, {
|
2546
2498
|
eventName: "TransferSingle"
|
2547
2499
|
}));
|
2548
|
-
case
|
2500
|
+
case 16:
|
2549
2501
|
targetLog = _context.sent;
|
2550
2502
|
return _context.abrupt("return", {
|
2551
2503
|
txHash: txHash,
|
2552
2504
|
licenseId: targetLog.args.id.toString()
|
2553
2505
|
});
|
2554
|
-
case
|
2506
|
+
case 20:
|
2555
2507
|
return _context.abrupt("return", {
|
2556
2508
|
txHash: txHash
|
2557
2509
|
});
|
2558
|
-
case
|
2559
|
-
_context.next =
|
2510
|
+
case 21:
|
2511
|
+
_context.next = 26;
|
2560
2512
|
break;
|
2561
|
-
case
|
2562
|
-
_context.prev =
|
2513
|
+
case 23:
|
2514
|
+
_context.prev = 23;
|
2563
2515
|
_context.t0 = _context["catch"](0);
|
2564
2516
|
handleError(_context.t0, "Failed to mint license");
|
2565
|
-
case
|
2517
|
+
case 26:
|
2566
2518
|
case "end":
|
2567
2519
|
return _context.stop();
|
2568
2520
|
}
|
2569
|
-
}, _callee, this, [[0,
|
2521
|
+
}, _callee, this, [[0, 23]]);
|
2570
2522
|
}));
|
2571
2523
|
function mintLicense(_x) {
|
2572
2524
|
return _mintLicense.apply(this, arguments);
|
@@ -2577,7 +2529,7 @@ var LicenseClient = /*#__PURE__*/function () {
|
|
2577
2529
|
key: "linkIpToParent",
|
2578
2530
|
value: function () {
|
2579
2531
|
var _linkIpToParent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
|
2580
|
-
var _request$txOptions2, IPAccountConfig, licenseIds, _yield$this$rpcClient2, call, txHash;
|
2532
|
+
var _request$txOptions2, IPAccountConfig, licenseIds, royaltyContext, _yield$this$rpcClient2, call, txHash;
|
2581
2533
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
2582
2534
|
while (1) switch (_context2.prev = _context2.next) {
|
2583
2535
|
case 0:
|
@@ -2591,51 +2543,55 @@ var LicenseClient = /*#__PURE__*/function () {
|
|
2591
2543
|
licenseIds.push(parseToBigInt(licenseId));
|
2592
2544
|
});
|
2593
2545
|
_context2.next = 6;
|
2546
|
+
return computeRoyaltyContext(request.licenseIds, this.storyClient);
|
2547
|
+
case 6:
|
2548
|
+
royaltyContext = _context2.sent;
|
2549
|
+
_context2.next = 9;
|
2594
2550
|
return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, IPAccountConfig), {}, {
|
2595
2551
|
functionName: "execute",
|
2596
2552
|
args: [this.licensingModuleConfig.address, parseToBigInt(0), viem.encodeFunctionData({
|
2597
2553
|
abi: this.licensingModuleConfig.abi,
|
2598
2554
|
functionName: "linkIpToParents",
|
2599
|
-
args: [licenseIds, viem.getAddress(request.childIpId),
|
2555
|
+
args: [licenseIds, viem.getAddress(request.childIpId), encodeRoyaltyContext(royaltyContext)]
|
2600
2556
|
})],
|
2601
2557
|
account: this.wallet.account
|
2602
2558
|
}));
|
2603
|
-
case
|
2559
|
+
case 9:
|
2604
2560
|
_yield$this$rpcClient2 = _context2.sent;
|
2605
2561
|
call = _yield$this$rpcClient2.request;
|
2606
|
-
_context2.next =
|
2562
|
+
_context2.next = 13;
|
2607
2563
|
return this.wallet.writeContract(call);
|
2608
|
-
case
|
2564
|
+
case 13:
|
2609
2565
|
txHash = _context2.sent;
|
2610
2566
|
if (!((_request$txOptions2 = request.txOptions) !== null && _request$txOptions2 !== void 0 && _request$txOptions2.waitForTransaction)) {
|
2611
|
-
_context2.next =
|
2567
|
+
_context2.next = 20;
|
2612
2568
|
break;
|
2613
2569
|
}
|
2614
|
-
_context2.next =
|
2570
|
+
_context2.next = 17;
|
2615
2571
|
return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, LicenseRegistryConfig), {}, {
|
2616
2572
|
eventName: "TransferBatch"
|
2617
2573
|
}));
|
2618
|
-
case
|
2574
|
+
case 17:
|
2619
2575
|
return _context2.abrupt("return", {
|
2620
2576
|
txHash: txHash,
|
2621
2577
|
success: true
|
2622
2578
|
});
|
2623
|
-
case
|
2579
|
+
case 20:
|
2624
2580
|
return _context2.abrupt("return", {
|
2625
2581
|
txHash: txHash
|
2626
2582
|
});
|
2627
|
-
case
|
2628
|
-
_context2.next =
|
2583
|
+
case 21:
|
2584
|
+
_context2.next = 26;
|
2629
2585
|
break;
|
2630
|
-
case 20:
|
2631
|
-
_context2.prev = 20;
|
2632
|
-
_context2.t0 = _context2["catch"](0);
|
2633
|
-
handleError(_context2.t0, "Failed to mint license");
|
2634
2586
|
case 23:
|
2587
|
+
_context2.prev = 23;
|
2588
|
+
_context2.t0 = _context2["catch"](0);
|
2589
|
+
handleError(_context2.t0, "Failed to link IP to parents");
|
2590
|
+
case 26:
|
2635
2591
|
case "end":
|
2636
2592
|
return _context2.stop();
|
2637
2593
|
}
|
2638
|
-
}, _callee2, this, [[0,
|
2594
|
+
}, _callee2, this, [[0, 23]]);
|
2639
2595
|
}));
|
2640
2596
|
function linkIpToParent(_x2) {
|
2641
2597
|
return _linkIpToParent.apply(this, arguments);
|
@@ -2868,7 +2824,8 @@ var DisputeClient = /*#__PURE__*/function () {
|
|
2868
2824
|
functionName: "raiseDispute",
|
2869
2825
|
args: [request.targetIpId, request.linkToDisputeEvidence, viem.stringToHex(request.targetTag, {
|
2870
2826
|
size: 32
|
2871
|
-
}), request.calldata || "0x"]
|
2827
|
+
}), request.calldata || "0x"],
|
2828
|
+
account: this.wallet.account
|
2872
2829
|
}));
|
2873
2830
|
case 3:
|
2874
2831
|
_yield$this$rpcClient = _context.sent;
|
@@ -2934,7 +2891,8 @@ var DisputeClient = /*#__PURE__*/function () {
|
|
2934
2891
|
_context2.next = 3;
|
2935
2892
|
return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.disputeModuleConfig), {}, {
|
2936
2893
|
functionName: "cancelDispute",
|
2937
|
-
args: [BigInt(request.disputeId), request.calldata ? request.calldata : "0x"]
|
2894
|
+
args: [BigInt(request.disputeId), request.calldata ? request.calldata : "0x"],
|
2895
|
+
account: this.wallet.account
|
2938
2896
|
}));
|
2939
2897
|
case 3:
|
2940
2898
|
_yield$this$rpcClient2 = _context2.sent;
|
@@ -2989,7 +2947,8 @@ var DisputeClient = /*#__PURE__*/function () {
|
|
2989
2947
|
_context3.next = 3;
|
2990
2948
|
return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.disputeModuleConfig), {}, {
|
2991
2949
|
functionName: "resolveDispute",
|
2992
|
-
args: [BigInt(request.disputeId)]
|
2950
|
+
args: [BigInt(request.disputeId)],
|
2951
|
+
account: this.wallet.account
|
2993
2952
|
}));
|
2994
2953
|
case 3:
|
2995
2954
|
_yield$this$rpcClient3 = _context3.sent;
|
@@ -3027,72 +2986,222 @@ var DisputeClient = /*#__PURE__*/function () {
|
|
3027
2986
|
return DisputeClient;
|
3028
2987
|
}();
|
3029
2988
|
|
3030
|
-
var
|
3031
|
-
function
|
3032
|
-
_classCallCheck(this,
|
3033
|
-
this
|
2989
|
+
var IPAccountClient = /*#__PURE__*/function () {
|
2990
|
+
function IPAccountClient(rpcClient, wallet) {
|
2991
|
+
_classCallCheck(this, IPAccountClient);
|
2992
|
+
_defineProperty(this, "ipAccountABI", IPAccountABI);
|
2993
|
+
this.wallet = wallet;
|
2994
|
+
this.rpcClient = rpcClient;
|
3034
2995
|
}
|
3035
2996
|
|
3036
|
-
/**
|
3037
|
-
*
|
3038
|
-
*
|
3039
|
-
*
|
3040
|
-
*
|
3041
|
-
* @returns
|
2997
|
+
/** Executes a transaction from the IP Account.
|
2998
|
+
* @param request The request object containing necessary data to execute IP Account a transaction.
|
2999
|
+
* @param request.to The recipient of the transaction.
|
3000
|
+
* @param request.value The amount of Ether to send.
|
3001
|
+
* @param request.data The data to send along with the transaction.
|
3002
|
+
* @returns Tx hash for the transaction.
|
3042
3003
|
*/
|
3043
|
-
_createClass(
|
3044
|
-
key: "
|
3004
|
+
_createClass(IPAccountClient, [{
|
3005
|
+
key: "execute",
|
3045
3006
|
value: function () {
|
3046
|
-
var
|
3047
|
-
var
|
3007
|
+
var _execute = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
|
3008
|
+
var _request$txOptions, IPAccountConfig, _yield$this$rpcClient, call, txHash;
|
3048
3009
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
3049
3010
|
while (1) switch (_context.prev = _context.next) {
|
3050
3011
|
case 0:
|
3051
3012
|
_context.prev = 0;
|
3052
|
-
|
3053
|
-
|
3054
|
-
|
3055
|
-
|
3056
|
-
|
3057
|
-
|
3058
|
-
|
3059
|
-
|
3060
|
-
|
3061
|
-
|
3062
|
-
|
3063
|
-
|
3064
|
-
|
3065
|
-
|
3066
|
-
|
3067
|
-
|
3013
|
+
IPAccountConfig = {
|
3014
|
+
abi: this.ipAccountABI,
|
3015
|
+
address: viem.getAddress(request.accountAddress)
|
3016
|
+
};
|
3017
|
+
_context.next = 4;
|
3018
|
+
return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, IPAccountConfig), {}, {
|
3019
|
+
functionName: "execute",
|
3020
|
+
args: [request.to, parseToBigInt(0), request.data],
|
3021
|
+
account: this.wallet.account
|
3022
|
+
}));
|
3023
|
+
case 4:
|
3024
|
+
_yield$this$rpcClient = _context.sent;
|
3025
|
+
call = _yield$this$rpcClient.request;
|
3026
|
+
_context.next = 8;
|
3027
|
+
return this.wallet.writeContract(call);
|
3028
|
+
case 8:
|
3029
|
+
txHash = _context.sent;
|
3030
|
+
if (!((_request$txOptions = request.txOptions) !== null && _request$txOptions !== void 0 && _request$txOptions.waitForTransaction)) {
|
3031
|
+
_context.next = 12;
|
3068
3032
|
break;
|
3069
3033
|
}
|
3070
|
-
throw new Error("Failed to upload file to s3. Status: ".concat(uploadResp.status));
|
3071
|
-
case 10:
|
3072
3034
|
_context.next = 12;
|
3073
|
-
return this.
|
3074
|
-
key: data.key
|
3075
|
-
});
|
3035
|
+
return waitTx(this.rpcClient, txHash);
|
3076
3036
|
case 12:
|
3077
|
-
|
3078
|
-
|
3079
|
-
|
3080
|
-
|
3037
|
+
return _context.abrupt("return", {
|
3038
|
+
txHash: txHash
|
3039
|
+
});
|
3040
|
+
case 15:
|
3041
|
+
_context.prev = 15;
|
3081
3042
|
_context.t0 = _context["catch"](0);
|
3082
|
-
|
3083
|
-
case
|
3043
|
+
handleError(_context.t0, "Failed to execute the IP Account transaction");
|
3044
|
+
case 18:
|
3084
3045
|
case "end":
|
3085
3046
|
return _context.stop();
|
3086
3047
|
}
|
3087
|
-
}, _callee, this, [[0,
|
3048
|
+
}, _callee, this, [[0, 15]]);
|
3049
|
+
}));
|
3050
|
+
function execute(_x) {
|
3051
|
+
return _execute.apply(this, arguments);
|
3052
|
+
}
|
3053
|
+
return execute;
|
3054
|
+
}()
|
3055
|
+
/** Executes a transaction from the IP Account.
|
3056
|
+
* @param request The request object containing necessary data to execute IP Account a transaction.
|
3057
|
+
* @param request.to The recipient of the transaction.
|
3058
|
+
* @param request.value The amount of Ether to send.
|
3059
|
+
* @param request.data The data to send along with the transaction.
|
3060
|
+
* @param request.signer The signer of the transaction.
|
3061
|
+
* @param request.deadline The deadline of the transaction signature.
|
3062
|
+
* @param request.signature The signature of the transaction, EIP-712 encoded.
|
3063
|
+
* @returns Tx hash for the transaction.
|
3064
|
+
*/
|
3065
|
+
}, {
|
3066
|
+
key: "executeWithSig",
|
3067
|
+
value: function () {
|
3068
|
+
var _executeWithSig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
|
3069
|
+
var _request$txOptions2, IPAccountConfig, _yield$this$rpcClient2, call, txHash;
|
3070
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
3071
|
+
while (1) switch (_context2.prev = _context2.next) {
|
3072
|
+
case 0:
|
3073
|
+
_context2.prev = 0;
|
3074
|
+
IPAccountConfig = {
|
3075
|
+
abi: this.ipAccountABI,
|
3076
|
+
address: viem.getAddress(request.accountAddress)
|
3077
|
+
};
|
3078
|
+
_context2.next = 4;
|
3079
|
+
return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, IPAccountConfig), {}, {
|
3080
|
+
functionName: "executeWithSig",
|
3081
|
+
args: [request.to, parseToBigInt(0), request.data, request.signer, parseToBigInt(request.deadline), request.signature],
|
3082
|
+
account: this.wallet.account
|
3083
|
+
}));
|
3084
|
+
case 4:
|
3085
|
+
_yield$this$rpcClient2 = _context2.sent;
|
3086
|
+
call = _yield$this$rpcClient2.request;
|
3087
|
+
_context2.next = 8;
|
3088
|
+
return this.wallet.writeContract(call);
|
3089
|
+
case 8:
|
3090
|
+
txHash = _context2.sent;
|
3091
|
+
if (!((_request$txOptions2 = request.txOptions) !== null && _request$txOptions2 !== void 0 && _request$txOptions2.waitForTransaction)) {
|
3092
|
+
_context2.next = 12;
|
3093
|
+
break;
|
3094
|
+
}
|
3095
|
+
_context2.next = 12;
|
3096
|
+
return waitTx(this.rpcClient, txHash);
|
3097
|
+
case 12:
|
3098
|
+
return _context2.abrupt("return", {
|
3099
|
+
txHash: txHash
|
3100
|
+
});
|
3101
|
+
case 15:
|
3102
|
+
_context2.prev = 15;
|
3103
|
+
_context2.t0 = _context2["catch"](0);
|
3104
|
+
handleError(_context2.t0, "Failed to execute with signature for the IP Account transaction");
|
3105
|
+
case 18:
|
3106
|
+
case "end":
|
3107
|
+
return _context2.stop();
|
3108
|
+
}
|
3109
|
+
}, _callee2, this, [[0, 15]]);
|
3110
|
+
}));
|
3111
|
+
function executeWithSig(_x2) {
|
3112
|
+
return _executeWithSig.apply(this, arguments);
|
3113
|
+
}
|
3114
|
+
return executeWithSig;
|
3115
|
+
}()
|
3116
|
+
}]);
|
3117
|
+
return IPAccountClient;
|
3118
|
+
}();
|
3119
|
+
|
3120
|
+
var StoryAPIClient = /*#__PURE__*/function () {
|
3121
|
+
function StoryAPIClient() {
|
3122
|
+
_classCallCheck(this, StoryAPIClient);
|
3123
|
+
this.httpClient = axios__default["default"].create({
|
3124
|
+
baseURL: "https://api.storyprotocol.net",
|
3125
|
+
timeout: 60000,
|
3126
|
+
headers: {
|
3127
|
+
"x-api-key": "U3RvcnlQcm90b2NvbFRlc3RBUElLRVk="
|
3128
|
+
}
|
3129
|
+
});
|
3130
|
+
}
|
3131
|
+
_createClass(StoryAPIClient, [{
|
3132
|
+
key: "getRoyaltyPolicy",
|
3133
|
+
value: function () {
|
3134
|
+
var _getRoyaltyPolicy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(ipId) {
|
3135
|
+
var royaltyPolicyResp;
|
3136
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
3137
|
+
while (1) switch (_context.prev = _context.next) {
|
3138
|
+
case 0:
|
3139
|
+
_context.next = 2;
|
3140
|
+
return this.httpClient.get("/api/v1/royalties/policies/".concat(ipId));
|
3141
|
+
case 2:
|
3142
|
+
royaltyPolicyResp = _context.sent;
|
3143
|
+
return _context.abrupt("return", royaltyPolicyResp.data.data);
|
3144
|
+
case 4:
|
3145
|
+
case "end":
|
3146
|
+
return _context.stop();
|
3147
|
+
}
|
3148
|
+
}, _callee, this);
|
3149
|
+
}));
|
3150
|
+
function getRoyaltyPolicy(_x) {
|
3151
|
+
return _getRoyaltyPolicy.apply(this, arguments);
|
3152
|
+
}
|
3153
|
+
return getRoyaltyPolicy;
|
3154
|
+
}()
|
3155
|
+
}, {
|
3156
|
+
key: "getLicense",
|
3157
|
+
value: function () {
|
3158
|
+
var _getLicense = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(licenseId) {
|
3159
|
+
var licenseResp;
|
3160
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
3161
|
+
while (1) switch (_context2.prev = _context2.next) {
|
3162
|
+
case 0:
|
3163
|
+
_context2.next = 2;
|
3164
|
+
return this.httpClient.get("/api/v1/licenses/".concat(licenseId));
|
3165
|
+
case 2:
|
3166
|
+
licenseResp = _context2.sent;
|
3167
|
+
return _context2.abrupt("return", licenseResp.data.data);
|
3168
|
+
case 4:
|
3169
|
+
case "end":
|
3170
|
+
return _context2.stop();
|
3171
|
+
}
|
3172
|
+
}, _callee2, this);
|
3173
|
+
}));
|
3174
|
+
function getLicense(_x2) {
|
3175
|
+
return _getLicense.apply(this, arguments);
|
3176
|
+
}
|
3177
|
+
return getLicense;
|
3178
|
+
}()
|
3179
|
+
}, {
|
3180
|
+
key: "getPolicy",
|
3181
|
+
value: function () {
|
3182
|
+
var _getPolicy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(policyId) {
|
3183
|
+
var policyResp;
|
3184
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
3185
|
+
while (1) switch (_context3.prev = _context3.next) {
|
3186
|
+
case 0:
|
3187
|
+
_context3.next = 2;
|
3188
|
+
return this.httpClient.get("/api/v1/policies/".concat(policyId));
|
3189
|
+
case 2:
|
3190
|
+
policyResp = _context3.sent;
|
3191
|
+
return _context3.abrupt("return", policyResp.data.data);
|
3192
|
+
case 4:
|
3193
|
+
case "end":
|
3194
|
+
return _context3.stop();
|
3195
|
+
}
|
3196
|
+
}, _callee3, this);
|
3088
3197
|
}));
|
3089
|
-
function
|
3090
|
-
return
|
3198
|
+
function getPolicy(_x3) {
|
3199
|
+
return _getPolicy.apply(this, arguments);
|
3091
3200
|
}
|
3092
|
-
return
|
3201
|
+
return getPolicy;
|
3093
3202
|
}()
|
3094
3203
|
}]);
|
3095
|
-
return
|
3204
|
+
return StoryAPIClient;
|
3096
3205
|
}();
|
3097
3206
|
|
3098
3207
|
if (typeof process !== "undefined") {
|
@@ -3107,29 +3216,22 @@ var StoryClient = /*#__PURE__*/function () {
|
|
3107
3216
|
*/
|
3108
3217
|
function StoryClient(config) {
|
3109
3218
|
_classCallCheck(this, StoryClient);
|
3110
|
-
_defineProperty(this, "
|
3219
|
+
_defineProperty(this, "_ipAsset", null);
|
3111
3220
|
_defineProperty(this, "_permission", null);
|
3112
3221
|
_defineProperty(this, "_license", null);
|
3113
3222
|
_defineProperty(this, "_policy", null);
|
3114
|
-
_defineProperty(this, "_platform", null);
|
3115
|
-
_defineProperty(this, "_tagging", null);
|
3116
3223
|
_defineProperty(this, "_dispute", null);
|
3224
|
+
_defineProperty(this, "_ipAccount", null);
|
3117
3225
|
this.config = config;
|
3118
3226
|
if (!this.config.transport) {
|
3119
3227
|
throw new Error("transport is null, please pass in a valid RPC Provider URL as the transport.");
|
3120
3228
|
}
|
3121
|
-
this.httpClient = axios__default["default"].create({
|
3122
|
-
baseURL: "https://stag.api.storyprotocol.net",
|
3123
|
-
timeout: 5000,
|
3124
|
-
headers: {
|
3125
|
-
version: "v0-alpha"
|
3126
|
-
}
|
3127
|
-
});
|
3128
3229
|
var clientConfig = {
|
3129
3230
|
chain: chainStringToViemChain(this.config.chainId || "sepolia"),
|
3130
3231
|
transport: this.config.transport
|
3131
3232
|
};
|
3132
3233
|
this.rpcClient = viem.createPublicClient(clientConfig);
|
3234
|
+
this.storyClient = new StoryAPIClient();
|
3133
3235
|
var account = this.config.account;
|
3134
3236
|
if (!account) {
|
3135
3237
|
throw new Error("account is null");
|
@@ -3146,12 +3248,26 @@ var StoryClient = /*#__PURE__*/function () {
|
|
3146
3248
|
*/
|
3147
3249
|
_createClass(StoryClient, [{
|
3148
3250
|
key: "ipAsset",
|
3149
|
-
get:
|
3150
|
-
|
3151
|
-
|
3251
|
+
get:
|
3252
|
+
/**
|
3253
|
+
* Getter for the ip asset client. The client is lazily created when
|
3254
|
+
* this method is called.
|
3255
|
+
*
|
3256
|
+
* @returns the IPAssetClient instance
|
3257
|
+
*/
|
3258
|
+
function get() {
|
3259
|
+
if (this._ipAsset === null) {
|
3260
|
+
this._ipAsset = new IPAssetClient(this.rpcClient, this.wallet, this.storyClient);
|
3152
3261
|
}
|
3153
|
-
return this.
|
3262
|
+
return this._ipAsset;
|
3154
3263
|
}
|
3264
|
+
|
3265
|
+
/**
|
3266
|
+
* Getter for the permission client. The client is lazily created when
|
3267
|
+
* this method is called.
|
3268
|
+
*
|
3269
|
+
* @returns the PermissionClient instance
|
3270
|
+
*/
|
3155
3271
|
}, {
|
3156
3272
|
key: "permission",
|
3157
3273
|
get: function get() {
|
@@ -3160,36 +3276,35 @@ var StoryClient = /*#__PURE__*/function () {
|
|
3160
3276
|
}
|
3161
3277
|
return this._permission;
|
3162
3278
|
}
|
3279
|
+
|
3280
|
+
/**
|
3281
|
+
* Getter for the license client. The client is lazily created when
|
3282
|
+
* this method is called.
|
3283
|
+
*
|
3284
|
+
* @returns the LicenseClient instance
|
3285
|
+
*/
|
3163
3286
|
}, {
|
3164
3287
|
key: "license",
|
3165
3288
|
get: function get() {
|
3166
3289
|
if (this._license === null) {
|
3167
|
-
this._license = new LicenseClient(this.rpcClient, this.wallet);
|
3290
|
+
this._license = new LicenseClient(this.rpcClient, this.wallet, this.storyClient);
|
3168
3291
|
}
|
3169
3292
|
return this._license;
|
3170
3293
|
}
|
3171
|
-
}, {
|
3172
|
-
key: "policy",
|
3173
|
-
get: function get() {
|
3174
|
-
if (this._policy === null) {
|
3175
|
-
this._policy = new PolicyClient(this.rpcClient, this.wallet);
|
3176
|
-
}
|
3177
|
-
return this._policy;
|
3178
|
-
}
|
3179
3294
|
|
3180
3295
|
/**
|
3181
|
-
* Getter for the
|
3296
|
+
* Getter for the policy client. The client is lazily created when
|
3182
3297
|
* this method is called.
|
3183
3298
|
*
|
3184
|
-
* @returns the
|
3299
|
+
* @returns the PolicyClient instance
|
3185
3300
|
*/
|
3186
3301
|
}, {
|
3187
|
-
key: "
|
3302
|
+
key: "policy",
|
3188
3303
|
get: function get() {
|
3189
|
-
if (this.
|
3190
|
-
this.
|
3304
|
+
if (this._policy === null) {
|
3305
|
+
this._policy = new PolicyClient(this.rpcClient, this.wallet);
|
3191
3306
|
}
|
3192
|
-
return this.
|
3307
|
+
return this._policy;
|
3193
3308
|
}
|
3194
3309
|
|
3195
3310
|
/**
|
@@ -3208,18 +3323,18 @@ var StoryClient = /*#__PURE__*/function () {
|
|
3208
3323
|
}
|
3209
3324
|
|
3210
3325
|
/**
|
3211
|
-
* Getter for the
|
3326
|
+
* Getter for the ip account client. The client is lazily created when
|
3212
3327
|
* this method is called.
|
3213
3328
|
*
|
3214
|
-
* @returns the
|
3329
|
+
* @returns the IPAccountClient instance
|
3215
3330
|
*/
|
3216
3331
|
}, {
|
3217
|
-
key: "
|
3332
|
+
key: "ipAccount",
|
3218
3333
|
get: function get() {
|
3219
|
-
if (this.
|
3220
|
-
this.
|
3334
|
+
if (this._ipAccount === null) {
|
3335
|
+
this._ipAccount = new IPAccountClient(this.rpcClient, this.wallet);
|
3221
3336
|
}
|
3222
|
-
return this.
|
3337
|
+
return this._ipAccount;
|
3223
3338
|
}
|
3224
3339
|
}], [{
|
3225
3340
|
key: "newClient",
|
@@ -3236,7 +3351,5 @@ exports.HashZero = HashZero;
|
|
3236
3351
|
exports.IPAssetClient = IPAssetClient;
|
3237
3352
|
exports.LicenseClient = LicenseClient;
|
3238
3353
|
exports.PermissionClient = PermissionClient;
|
3239
|
-
exports.PlatformClient = PlatformClient;
|
3240
3354
|
exports.PolicyClient = PolicyClient;
|
3241
3355
|
exports.StoryClient = StoryClient;
|
3242
|
-
exports.TaggingClient = TaggingClient;
|