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

Sign up to get free protection for your applications and to get access to all the features.
@@ -420,6 +420,9 @@ function handleError(error, msg) {
420
420
  throw new Error("".concat(msg, ": Unknown error type"));
421
421
  }
422
422
 
423
+ var AddressZero = "0x0000000000000000000000000000000000000000";
424
+ var HashZero = "0x0000000000000000000000000000000000000000000000000000000000000000";
425
+
423
426
  function _arrayLikeToArray(arr, len) {
424
427
  if (len == null || len > arr.length) len = arr.length;
425
428
  for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
@@ -1154,44 +1157,6 @@ var RegistrationModuleABI = [{
1154
1157
  type: "function"
1155
1158
  }];
1156
1159
 
1157
- var TaggingModuleABI = [{
1158
- inputs: [{
1159
- internalType: "string",
1160
- name: "tag",
1161
- type: "string"
1162
- }, {
1163
- internalType: "address",
1164
- name: "ipId",
1165
- type: "address"
1166
- }],
1167
- name: "removeTag",
1168
- outputs: [{
1169
- internalType: "bool",
1170
- name: "removed",
1171
- type: "bool"
1172
- }],
1173
- stateMutability: "nonpayable",
1174
- type: "function"
1175
- }, {
1176
- inputs: [{
1177
- internalType: "string",
1178
- name: "tag",
1179
- type: "string"
1180
- }, {
1181
- internalType: "address",
1182
- name: "ipId",
1183
- type: "address"
1184
- }],
1185
- name: "setTag",
1186
- outputs: [{
1187
- internalType: "bool",
1188
- name: "added",
1189
- type: "bool"
1190
- }],
1191
- stateMutability: "nonpayable",
1192
- type: "function"
1193
- }];
1194
-
1195
1160
  var ErrorsABI = [{
1196
1161
  inputs: [{
1197
1162
  internalType: "address",
@@ -1883,8 +1848,7 @@ var sepolia = {
1883
1848
  PILPolicyFrameworkManager: "0x49cF5C5523011F8B4A0489969096Eb68C571C197",
1884
1849
  RegistrationModule: "0x248c8CbF469ec7CB22Dc9914E569920b93d717a3",
1885
1850
  RoyaltyModule: "0x512bbF310452cC96E0E9818B0870EcA557b86d4D",
1886
- RoyaltyPolicyLAP: "0x8404061350BA0CA85c4E733B0be78c5519679003",
1887
- TaggingModule: "0xED445f1DeE74Cf470Aab47F4b63734653C4C9537"
1851
+ RoyaltyPolicyLAP: "0x8404061350BA0CA85c4E733B0be78c5519679003"
1888
1852
  };
1889
1853
 
1890
1854
  var IPAccountABI = [].concat(_toConsumableArray(IPAccountImplABI), _toConsumableArray(ErrorsABI));
@@ -1912,10 +1876,6 @@ var RegistrationModuleConfig = {
1912
1876
  abi: [].concat(_toConsumableArray(RegistrationModuleABI), _toConsumableArray(ErrorsABI)),
1913
1877
  address: getAddress(sepolia.RegistrationModule)
1914
1878
  };
1915
- var TaggingModuleConfig = {
1916
- abi: [].concat(_toConsumableArray(TaggingModuleABI), _toConsumableArray(ErrorsABI)),
1917
- address: getAddress(sepolia.TaggingModule)
1918
- };
1919
1879
  var PILPolicyFrameworkManagerConfig = {
1920
1880
  abi: [].concat(_toConsumableArray(PILPolicyFrameworkManagerABI), _toConsumableArray(ErrorsABI)),
1921
1881
  address: getAddress(sepolia.PILPolicyFrameworkManager)
@@ -2078,112 +2038,6 @@ function chainStringToViemChain(chainId) {
2078
2038
  }
2079
2039
  }
2080
2040
 
2081
- var TaggingClient = /*#__PURE__*/function () {
2082
- function TaggingClient(rpcClient, wallet) {
2083
- _classCallCheck(this, TaggingClient);
2084
- _defineProperty(this, "taggingModuleConfig", TaggingModuleConfig);
2085
- this.rpcClient = rpcClient;
2086
- this.wallet = wallet;
2087
- }
2088
- _createClass(TaggingClient, [{
2089
- key: "setTag",
2090
- value: function () {
2091
- var _setTag = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
2092
- var _request$txOptions, _yield$this$rpcClient, call, txHash;
2093
- return _regeneratorRuntime().wrap(function _callee$(_context) {
2094
- while (1) switch (_context.prev = _context.next) {
2095
- case 0:
2096
- _context.prev = 0;
2097
- _context.next = 3;
2098
- return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.taggingModuleConfig), {}, {
2099
- functionName: "setTag",
2100
- args: [request.tag, request.ipId]
2101
- }));
2102
- case 3:
2103
- _yield$this$rpcClient = _context.sent;
2104
- call = _yield$this$rpcClient.request;
2105
- _context.next = 7;
2106
- return this.wallet.writeContract(call);
2107
- case 7:
2108
- txHash = _context.sent;
2109
- if (!((_request$txOptions = request.txOptions) !== null && _request$txOptions !== void 0 && _request$txOptions.waitForTransaction)) {
2110
- _context.next = 11;
2111
- break;
2112
- }
2113
- _context.next = 11;
2114
- return waitTx(this.rpcClient, txHash);
2115
- case 11:
2116
- return _context.abrupt("return", {
2117
- txHash: txHash
2118
- });
2119
- case 14:
2120
- _context.prev = 14;
2121
- _context.t0 = _context["catch"](0);
2122
- handleError(_context.t0, "Failed to set tag");
2123
- case 17:
2124
- case "end":
2125
- return _context.stop();
2126
- }
2127
- }, _callee, this, [[0, 14]]);
2128
- }));
2129
- function setTag(_x) {
2130
- return _setTag.apply(this, arguments);
2131
- }
2132
- return setTag;
2133
- }()
2134
- }, {
2135
- key: "removeTag",
2136
- value: function () {
2137
- var _removeTag = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
2138
- var _request$txOptions2, _yield$this$rpcClient2, call, txHash;
2139
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
2140
- while (1) switch (_context2.prev = _context2.next) {
2141
- case 0:
2142
- _context2.prev = 0;
2143
- _context2.next = 3;
2144
- return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.taggingModuleConfig), {}, {
2145
- functionName: "removeTag",
2146
- args: [request.tag, request.ipId]
2147
- }));
2148
- case 3:
2149
- _yield$this$rpcClient2 = _context2.sent;
2150
- call = _yield$this$rpcClient2.request;
2151
- _context2.next = 7;
2152
- return this.wallet.writeContract(call);
2153
- case 7:
2154
- txHash = _context2.sent;
2155
- if (!((_request$txOptions2 = request.txOptions) !== null && _request$txOptions2 !== void 0 && _request$txOptions2.waitForTransaction)) {
2156
- _context2.next = 11;
2157
- break;
2158
- }
2159
- _context2.next = 11;
2160
- return waitTx(this.rpcClient, txHash);
2161
- case 11:
2162
- return _context2.abrupt("return", {
2163
- txHash: txHash
2164
- });
2165
- case 14:
2166
- _context2.prev = 14;
2167
- _context2.t0 = _context2["catch"](0);
2168
- handleError(_context2.t0, "Failed to remove tag");
2169
- case 17:
2170
- case "end":
2171
- return _context2.stop();
2172
- }
2173
- }, _callee2, this, [[0, 14]]);
2174
- }));
2175
- function removeTag(_x2) {
2176
- return _removeTag.apply(this, arguments);
2177
- }
2178
- return removeTag;
2179
- }()
2180
- }]);
2181
- return TaggingClient;
2182
- }();
2183
-
2184
- var AddressZero = "0x0000000000000000000000000000000000000000";
2185
- var HashZero = "0x0000000000000000000000000000000000000000000000000000000000000000";
2186
-
2187
2041
  function computeRoyaltyContext(_x, _x2) {
2188
2042
  return _computeRoyaltyContext.apply(this, arguments);
2189
2043
  }
@@ -2302,7 +2156,7 @@ var IPAssetClient = /*#__PURE__*/function () {
2302
2156
  _context.next = 3;
2303
2157
  return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.registrationModuleConfig), {}, {
2304
2158
  functionName: "registerRootIp",
2305
- args: [parseToBigInt(request.policyId), getAddress(request.tokenContractAddress),
2159
+ args: [parseToBigInt(request.policyId || "0"), getAddress(request.tokenContractAddress),
2306
2160
  // 0x Address
2307
2161
  parseToBigInt(request.tokenId), request.ipName || "", request.contentHash || HashZero, request.uri || ""],
2308
2162
  account: this.wallet.account
@@ -2565,7 +2419,7 @@ var LicenseClient = /*#__PURE__*/function () {
2565
2419
  * @param request.licensorIpId_ The ID of the IP granting the license (ie. licensor)
2566
2420
  * @param request.mintAmount Number of licenses to mint. License NFT is fungible for same policy and same licensors
2567
2421
  * @param request.receiver Receiver address of the minted license NFT(s).
2568
- * @return licenseId The ID of the minted license NFT(s).
2422
+ * @returns licenseId The ID of the minted license NFT(s).
2569
2423
  */
2570
2424
  _createClass(LicenseClient, [{
2571
2425
  key: "mintLicense",
@@ -3105,6 +2959,137 @@ var DisputeClient = /*#__PURE__*/function () {
3105
2959
  return DisputeClient;
3106
2960
  }();
3107
2961
 
2962
+ var IPAccountClient = /*#__PURE__*/function () {
2963
+ function IPAccountClient(rpcClient, wallet) {
2964
+ _classCallCheck(this, IPAccountClient);
2965
+ _defineProperty(this, "ipAccountABI", IPAccountABI);
2966
+ this.wallet = wallet;
2967
+ this.rpcClient = rpcClient;
2968
+ }
2969
+
2970
+ /** Executes a transaction from the IP Account.
2971
+ * @param request The request object containing necessary data to execute IP Account a transaction.
2972
+ * @param request.to The recipient of the transaction.
2973
+ * @param request.value The amount of Ether to send.
2974
+ * @param request.data The data to send along with the transaction.
2975
+ * @returns Tx hash for the transaction.
2976
+ */
2977
+ _createClass(IPAccountClient, [{
2978
+ key: "execute",
2979
+ value: function () {
2980
+ var _execute = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
2981
+ var _request$txOptions, IPAccountConfig, _yield$this$rpcClient, call, txHash;
2982
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
2983
+ while (1) switch (_context.prev = _context.next) {
2984
+ case 0:
2985
+ _context.prev = 0;
2986
+ IPAccountConfig = {
2987
+ abi: this.ipAccountABI,
2988
+ address: getAddress(request.accountAddress)
2989
+ };
2990
+ _context.next = 4;
2991
+ return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, IPAccountConfig), {}, {
2992
+ functionName: "execute",
2993
+ args: [request.to, parseToBigInt(0), request.data],
2994
+ account: this.wallet.account
2995
+ }));
2996
+ case 4:
2997
+ _yield$this$rpcClient = _context.sent;
2998
+ call = _yield$this$rpcClient.request;
2999
+ _context.next = 8;
3000
+ return this.wallet.writeContract(call);
3001
+ case 8:
3002
+ txHash = _context.sent;
3003
+ if (!((_request$txOptions = request.txOptions) !== null && _request$txOptions !== void 0 && _request$txOptions.waitForTransaction)) {
3004
+ _context.next = 12;
3005
+ break;
3006
+ }
3007
+ _context.next = 12;
3008
+ return waitTx(this.rpcClient, txHash);
3009
+ case 12:
3010
+ return _context.abrupt("return", {
3011
+ txHash: txHash
3012
+ });
3013
+ case 15:
3014
+ _context.prev = 15;
3015
+ _context.t0 = _context["catch"](0);
3016
+ handleError(_context.t0, "Failed to execute the IP Account transaction");
3017
+ case 18:
3018
+ case "end":
3019
+ return _context.stop();
3020
+ }
3021
+ }, _callee, this, [[0, 15]]);
3022
+ }));
3023
+ function execute(_x) {
3024
+ return _execute.apply(this, arguments);
3025
+ }
3026
+ return execute;
3027
+ }()
3028
+ /** Executes a transaction from the IP Account.
3029
+ * @param request The request object containing necessary data to execute IP Account a transaction.
3030
+ * @param request.to The recipient of the transaction.
3031
+ * @param request.value The amount of Ether to send.
3032
+ * @param request.data The data to send along with the transaction.
3033
+ * @param request.signer The signer of the transaction.
3034
+ * @param request.deadline The deadline of the transaction signature.
3035
+ * @param request.signature The signature of the transaction, EIP-712 encoded.
3036
+ * @returns Tx hash for the transaction.
3037
+ */
3038
+ }, {
3039
+ key: "executeWithSig",
3040
+ value: function () {
3041
+ var _executeWithSig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
3042
+ var _request$txOptions2, IPAccountConfig, _yield$this$rpcClient2, call, txHash;
3043
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
3044
+ while (1) switch (_context2.prev = _context2.next) {
3045
+ case 0:
3046
+ _context2.prev = 0;
3047
+ IPAccountConfig = {
3048
+ abi: this.ipAccountABI,
3049
+ address: getAddress(request.accountAddress)
3050
+ };
3051
+ _context2.next = 4;
3052
+ return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, IPAccountConfig), {}, {
3053
+ functionName: "executeWithSig",
3054
+ args: [request.to, parseToBigInt(0), request.data, request.signer, parseToBigInt(request.deadline), request.signature],
3055
+ account: this.wallet.account
3056
+ }));
3057
+ case 4:
3058
+ _yield$this$rpcClient2 = _context2.sent;
3059
+ call = _yield$this$rpcClient2.request;
3060
+ _context2.next = 8;
3061
+ return this.wallet.writeContract(call);
3062
+ case 8:
3063
+ txHash = _context2.sent;
3064
+ if (!((_request$txOptions2 = request.txOptions) !== null && _request$txOptions2 !== void 0 && _request$txOptions2.waitForTransaction)) {
3065
+ _context2.next = 12;
3066
+ break;
3067
+ }
3068
+ _context2.next = 12;
3069
+ return waitTx(this.rpcClient, txHash);
3070
+ case 12:
3071
+ return _context2.abrupt("return", {
3072
+ txHash: txHash
3073
+ });
3074
+ case 15:
3075
+ _context2.prev = 15;
3076
+ _context2.t0 = _context2["catch"](0);
3077
+ handleError(_context2.t0, "Failed to execute with signature for the IP Account transaction");
3078
+ case 18:
3079
+ case "end":
3080
+ return _context2.stop();
3081
+ }
3082
+ }, _callee2, this, [[0, 15]]);
3083
+ }));
3084
+ function executeWithSig(_x2) {
3085
+ return _executeWithSig.apply(this, arguments);
3086
+ }
3087
+ return executeWithSig;
3088
+ }()
3089
+ }]);
3090
+ return IPAccountClient;
3091
+ }();
3092
+
3108
3093
  var StoryAPIClient = /*#__PURE__*/function () {
3109
3094
  function StoryAPIClient() {
3110
3095
  _classCallCheck(this, StoryAPIClient);
@@ -3125,7 +3110,7 @@ var StoryAPIClient = /*#__PURE__*/function () {
3125
3110
  while (1) switch (_context.prev = _context.next) {
3126
3111
  case 0:
3127
3112
  _context.next = 2;
3128
- return this.httpClient.get("/api/v1/royaltypolicies/".concat(ipId));
3113
+ return this.httpClient.get("/api/v1/royalties/policies/".concat(ipId));
3129
3114
  case 2:
3130
3115
  royaltyPolicyResp = _context.sent;
3131
3116
  return _context.abrupt("return", royaltyPolicyResp.data.data);
@@ -3204,12 +3189,12 @@ var StoryClient = /*#__PURE__*/function () {
3204
3189
  */
3205
3190
  function StoryClient(config) {
3206
3191
  _classCallCheck(this, StoryClient);
3207
- _defineProperty(this, "_ipAccount", null);
3192
+ _defineProperty(this, "_ipAsset", null);
3208
3193
  _defineProperty(this, "_permission", null);
3209
3194
  _defineProperty(this, "_license", null);
3210
3195
  _defineProperty(this, "_policy", null);
3211
- _defineProperty(this, "_tagging", null);
3212
3196
  _defineProperty(this, "_dispute", null);
3197
+ _defineProperty(this, "_ipAccount", null);
3213
3198
  this.config = config;
3214
3199
  if (!this.config.transport) {
3215
3200
  throw new Error("transport is null, please pass in a valid RPC Provider URL as the transport.");
@@ -3236,12 +3221,26 @@ var StoryClient = /*#__PURE__*/function () {
3236
3221
  */
3237
3222
  _createClass(StoryClient, [{
3238
3223
  key: "ipAsset",
3239
- get: function get() {
3240
- if (this._ipAccount === null) {
3241
- this._ipAccount = new IPAssetClient(this.rpcClient, this.wallet, this.storyClient);
3224
+ get:
3225
+ /**
3226
+ * Getter for the ip asset client. The client is lazily created when
3227
+ * this method is called.
3228
+ *
3229
+ * @returns the IPAssetClient instance
3230
+ */
3231
+ function get() {
3232
+ if (this._ipAsset === null) {
3233
+ this._ipAsset = new IPAssetClient(this.rpcClient, this.wallet, this.storyClient);
3242
3234
  }
3243
- return this._ipAccount;
3235
+ return this._ipAsset;
3244
3236
  }
3237
+
3238
+ /**
3239
+ * Getter for the permission client. The client is lazily created when
3240
+ * this method is called.
3241
+ *
3242
+ * @returns the PermissionClient instance
3243
+ */
3245
3244
  }, {
3246
3245
  key: "permission",
3247
3246
  get: function get() {
@@ -3250,6 +3249,13 @@ var StoryClient = /*#__PURE__*/function () {
3250
3249
  }
3251
3250
  return this._permission;
3252
3251
  }
3252
+
3253
+ /**
3254
+ * Getter for the license client. The client is lazily created when
3255
+ * this method is called.
3256
+ *
3257
+ * @returns the LicenseClient instance
3258
+ */
3253
3259
  }, {
3254
3260
  key: "license",
3255
3261
  get: function get() {
@@ -3258,6 +3264,13 @@ var StoryClient = /*#__PURE__*/function () {
3258
3264
  }
3259
3265
  return this._license;
3260
3266
  }
3267
+
3268
+ /**
3269
+ * Getter for the policy client. The client is lazily created when
3270
+ * this method is called.
3271
+ *
3272
+ * @returns the PolicyClient instance
3273
+ */
3261
3274
  }, {
3262
3275
  key: "policy",
3263
3276
  get: function get() {
@@ -3268,33 +3281,33 @@ var StoryClient = /*#__PURE__*/function () {
3268
3281
  }
3269
3282
 
3270
3283
  /**
3271
- * Getter for the tagging client. The client is lazily created when
3284
+ * Getter for the dispute client. The client is lazily created when
3272
3285
  * this method is called.
3273
3286
  *
3274
- * @returns the TaggingClient instance
3287
+ * @returns the DisputeClient instance
3275
3288
  */
3276
3289
  }, {
3277
- key: "tagging",
3290
+ key: "dispute",
3278
3291
  get: function get() {
3279
- if (this._tagging === null) {
3280
- this._tagging = new TaggingClient(this.rpcClient, this.wallet);
3292
+ if (this._dispute === null) {
3293
+ this._dispute = new DisputeClient(this.rpcClient, this.wallet);
3281
3294
  }
3282
- return this._tagging;
3295
+ return this._dispute;
3283
3296
  }
3284
3297
 
3285
3298
  /**
3286
- * Getter for the dispute client. The client is lazily created when
3299
+ * Getter for the ip account client. The client is lazily created when
3287
3300
  * this method is called.
3288
3301
  *
3289
- * @returns the DisputeClient instance
3302
+ * @returns the IPAccountClient instance
3290
3303
  */
3291
3304
  }, {
3292
- key: "dispute",
3305
+ key: "ipAccount",
3293
3306
  get: function get() {
3294
- if (this._dispute === null) {
3295
- this._dispute = new DisputeClient(this.rpcClient, this.wallet);
3307
+ if (this._ipAccount === null) {
3308
+ this._ipAccount = new IPAccountClient(this.rpcClient, this.wallet);
3296
3309
  }
3297
- return this._dispute;
3310
+ return this._ipAccount;
3298
3311
  }
3299
3312
  }], [{
3300
3313
  key: "newClient",
@@ -3305,4 +3318,4 @@ var StoryClient = /*#__PURE__*/function () {
3305
3318
  return StoryClient;
3306
3319
  }();
3307
3320
 
3308
- export { AddressZero, DisputeClient, HashZero, IPAssetClient, LicenseClient, PermissionClient, PolicyClient, StoryClient, TaggingClient };
3321
+ export { AddressZero, DisputeClient, HashZero, IPAssetClient, LicenseClient, PermissionClient, PolicyClient, StoryClient };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@story-protocol/core-sdk",
3
- "version": "0.0.1-beta-rc.4",
3
+ "version": "0.0.1-beta-rc.5",
4
4
  "description": "Story Protocol Core SDK",
5
5
  "main": "dist/story-protocol-core-sdk.cjs.js",
6
6
  "module": "dist/story-protocol-core-sdk.esm.js",