@story-protocol/core-sdk 1.4.3 → 1.4.4
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/abi/generated.d.ts +16 -0
- package/dist/declarations/src/abi/generated.d.ts.map +1 -1
- package/dist/declarations/src/client.d.ts +6 -0
- package/dist/declarations/src/client.d.ts.map +1 -1
- package/dist/declarations/src/resources/group.d.ts.map +1 -1
- package/dist/declarations/src/resources/nftClient.d.ts +5 -1
- package/dist/declarations/src/resources/nftClient.d.ts.map +1 -1
- package/dist/declarations/src/types/config.d.ts +48 -1
- package/dist/declarations/src/types/config.d.ts.map +1 -1
- package/dist/declarations/src/types/resources/nftClient.d.ts +6 -0
- package/dist/declarations/src/types/resources/nftClient.d.ts.map +1 -1
- package/dist/declarations/src/utils/oov3.d.ts +4 -0
- package/dist/declarations/src/utils/oov3.d.ts.map +1 -1
- package/dist/declarations/src/utils/pilFlavor.d.ts.map +1 -1
- package/dist/story-protocol-core-sdk.cjs.dev.js +203 -43
- package/dist/story-protocol-core-sdk.cjs.prod.js +203 -43
- package/dist/story-protocol-core-sdk.esm.js +204 -44
- package/package.json +3 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as dotenv from 'dotenv';
|
|
2
|
-
import { encodeFunctionData, decodeEventLog, isAddress, formatEther, maxUint256, http, createPublicClient, createWalletClient, stringToHex, encodeAbiParameters, zeroHash, toFunctionSelector, keccak256,
|
|
2
|
+
import { encodeFunctionData, decodeEventLog, isAddress, formatEther, maxUint256, http, createPublicClient, createWalletClient, stringToHex, encodeAbiParameters, zeroAddress, getAddress as getAddress$1, zeroHash, toFunctionSelector, keccak256, toHex, maxUint32, erc20Abi as erc20Abi$1 } from 'viem';
|
|
3
3
|
import { defineChain } from 'viem/utils';
|
|
4
4
|
import bs58 from 'bs58';
|
|
5
5
|
import { base58btc } from 'multiformats/bases/base58';
|
|
@@ -2640,6 +2640,10 @@ function getAddress(address,chainId){return address[chainId||0]||"0x";}// Contra
|
|
|
2640
2640
|
* @param to address
|
|
2641
2641
|
* @param tokenId uint256
|
|
2642
2642
|
*//**
|
|
2643
|
+
* SpgnftImplBalanceOfRequest
|
|
2644
|
+
*
|
|
2645
|
+
* @param owner address
|
|
2646
|
+
*//**
|
|
2643
2647
|
* SpgnftImplHasRoleRequest
|
|
2644
2648
|
*
|
|
2645
2649
|
* @param role bytes32
|
|
@@ -2662,38 +2666,43 @@ function getAddress(address,chainId){return address[chainId||0]||"0x";}// Contra
|
|
|
2662
2666
|
*/},{key:"parseTxTransferEvent",value:function parseTxTransferEvent(txReceipt){var targetLogs=[];var _iterator38=_createForOfIteratorHelper(txReceipt.logs),_step38;try{for(_iterator38.s();!(_step38=_iterator38.n()).done;){var log=_step38.value;try{var event=decodeEventLog({abi:spgnftImplAbi,eventName:"Transfer",data:log.data,topics:log.topics});if(event.eventName==="Transfer"){targetLogs.push(event.args);}}catch(e){/* empty */}}}catch(err){_iterator38.e(err);}finally{_iterator38.f();}return targetLogs;}}]);}();/**
|
|
2663
2667
|
* contract SPGNFTImpl readonly method
|
|
2664
2668
|
*/var SpgnftImplReadOnlyClient=/*#__PURE__*/function(_SpgnftImplEventClien){function SpgnftImplReadOnlyClient(rpcClient,address){_classCallCheck(this,SpgnftImplReadOnlyClient);return _callSuper(this,SpgnftImplReadOnlyClient,[rpcClient,address]);}/**
|
|
2669
|
+
* method balanceOf for contract SPGNFTImpl
|
|
2670
|
+
*
|
|
2671
|
+
* @param request SpgnftImplBalanceOfRequest
|
|
2672
|
+
* @return Promise<SpgnftImplBalanceOfResponse>
|
|
2673
|
+
*/_inherits(SpgnftImplReadOnlyClient,_SpgnftImplEventClien);return _createClass(SpgnftImplReadOnlyClient,[{key:"balanceOf",value:(function(){var _balanceOf3=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee188(request){return _regenerator().w(function(_context188){while(1)switch(_context188.n){case 0:_context188.n=1;return this.rpcClient.readContract({abi:spgnftImplAbi,address:this.address,functionName:"balanceOf",args:[request.owner]});case 1:return _context188.a(2,_context188.v);}},_callee188,this);}));function balanceOf(_x134){return _balanceOf3.apply(this,arguments);}return balanceOf;}()/**
|
|
2665
2674
|
* method hasRole for contract SPGNFTImpl
|
|
2666
2675
|
*
|
|
2667
2676
|
* @param request SpgnftImplHasRoleRequest
|
|
2668
2677
|
* @return Promise<SpgnftImplHasRoleResponse>
|
|
2669
|
-
*/
|
|
2678
|
+
*/)},{key:"hasRole",value:(function(){var _hasRole=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee189(request){return _regenerator().w(function(_context189){while(1)switch(_context189.n){case 0:_context189.n=1;return this.rpcClient.readContract({abi:spgnftImplAbi,address:this.address,functionName:"hasRole",args:[request.role,request.account]});case 1:return _context189.a(2,_context189.v);}},_callee189,this);}));function hasRole(_x135){return _hasRole.apply(this,arguments);}return hasRole;}()/**
|
|
2670
2679
|
* method mintFee for contract SPGNFTImpl
|
|
2671
2680
|
*
|
|
2672
2681
|
* @param request SpgnftImplMintFeeRequest
|
|
2673
2682
|
* @return Promise<SpgnftImplMintFeeResponse>
|
|
2674
|
-
*/)},{key:"mintFee",value:(function(){var _mintFee=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
2683
|
+
*/)},{key:"mintFee",value:(function(){var _mintFee=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee190(){return _regenerator().w(function(_context190){while(1)switch(_context190.n){case 0:_context190.n=1;return this.rpcClient.readContract({abi:spgnftImplAbi,address:this.address,functionName:"mintFee"});case 1:return _context190.a(2,_context190.v);}},_callee190,this);}));function mintFee(){return _mintFee.apply(this,arguments);}return mintFee;}()/**
|
|
2675
2684
|
* method mintFeeToken for contract SPGNFTImpl
|
|
2676
2685
|
*
|
|
2677
2686
|
* @param request SpgnftImplMintFeeTokenRequest
|
|
2678
2687
|
* @return Promise<SpgnftImplMintFeeTokenResponse>
|
|
2679
|
-
*/)},{key:"mintFeeToken",value:(function(){var _mintFeeToken=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
2688
|
+
*/)},{key:"mintFeeToken",value:(function(){var _mintFeeToken=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee191(){return _regenerator().w(function(_context191){while(1)switch(_context191.n){case 0:_context191.n=1;return this.rpcClient.readContract({abi:spgnftImplAbi,address:this.address,functionName:"mintFeeToken"});case 1:return _context191.a(2,_context191.v);}},_callee191,this);}));function mintFeeToken(){return _mintFeeToken.apply(this,arguments);}return mintFeeToken;}()/**
|
|
2680
2689
|
* method publicMinting for contract SPGNFTImpl
|
|
2681
2690
|
*
|
|
2682
2691
|
* @param request SpgnftImplPublicMintingRequest
|
|
2683
2692
|
* @return Promise<SpgnftImplPublicMintingResponse>
|
|
2684
|
-
*/)},{key:"publicMinting",value:(function(){var _publicMinting=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
2693
|
+
*/)},{key:"publicMinting",value:(function(){var _publicMinting=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee192(){return _regenerator().w(function(_context192){while(1)switch(_context192.n){case 0:_context192.n=1;return this.rpcClient.readContract({abi:spgnftImplAbi,address:this.address,functionName:"publicMinting"});case 1:return _context192.a(2,_context192.v);}},_callee192,this);}));function publicMinting(){return _publicMinting.apply(this,arguments);}return publicMinting;}()/**
|
|
2685
2694
|
* method tokenURI for contract SPGNFTImpl
|
|
2686
2695
|
*
|
|
2687
2696
|
* @param request SpgnftImplTokenUriRequest
|
|
2688
2697
|
* @return Promise<SpgnftImplTokenUriResponse>
|
|
2689
|
-
*/)},{key:"tokenUri",value:(function(){var _tokenUri=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
2698
|
+
*/)},{key:"tokenUri",value:(function(){var _tokenUri=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee193(request){return _regenerator().w(function(_context193){while(1)switch(_context193.n){case 0:_context193.n=1;return this.rpcClient.readContract({abi:spgnftImplAbi,address:this.address,functionName:"tokenURI",args:[request.tokenId]});case 1:return _context193.a(2,_context193.v);}},_callee193,this);}));function tokenUri(_x136){return _tokenUri.apply(this,arguments);}return tokenUri;}())}]);}(SpgnftImplEventClient);/**
|
|
2690
2699
|
* contract SPGNFTImpl write method
|
|
2691
2700
|
*/var SpgnftImplClient=/*#__PURE__*/function(_SpgnftImplReadOnlyCl){function SpgnftImplClient(rpcClient,wallet,address){var _this15;_classCallCheck(this,SpgnftImplClient);_this15=_callSuper(this,SpgnftImplClient,[rpcClient,address]);_this15.wallet=wallet;return _this15;}/**
|
|
2692
2701
|
* method setTokenURI for contract SPGNFTImpl
|
|
2693
2702
|
*
|
|
2694
2703
|
* @param request SpgnftImplSetTokenUriRequest
|
|
2695
2704
|
* @return Promise<WriteContractReturnType>
|
|
2696
|
-
*/_inherits(SpgnftImplClient,_SpgnftImplReadOnlyCl);return _createClass(SpgnftImplClient,[{key:"setTokenUri",value:(function(){var _setTokenUri=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
2705
|
+
*/_inherits(SpgnftImplClient,_SpgnftImplReadOnlyCl);return _createClass(SpgnftImplClient,[{key:"setTokenUri",value:(function(){var _setTokenUri=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee194(request){var _yield$this$rpcClient93,call;return _regenerator().w(function(_context194){while(1)switch(_context194.n){case 0:_context194.n=1;return this.rpcClient.simulateContract({abi:spgnftImplAbi,address:this.address,functionName:"setTokenURI",account:this.wallet.account,args:[request.tokenId,request.tokenUri]});case 1:_yield$this$rpcClient93=_context194.v;call=_yield$this$rpcClient93.request;_context194.n=2;return this.wallet.writeContract(call);case 2:return _context194.a(2,_context194.v);}},_callee194,this);}));function setTokenUri(_x137){return _setTokenUri.apply(this,arguments);}return setTokenUri;}()/**
|
|
2697
2706
|
* method setTokenURI for contract SPGNFTImpl with only encode
|
|
2698
2707
|
*
|
|
2699
2708
|
* @param request SpgnftImplSetTokenUriRequest
|
|
@@ -2713,7 +2722,7 @@ function getAddress(address,chainId){return address[chainId||0]||"0x";}// Contra
|
|
|
2713
2722
|
*
|
|
2714
2723
|
* @param request TotalLicenseTokenLimitHookSetTotalLicenseTokenLimitRequest
|
|
2715
2724
|
* @return Promise<WriteContractReturnType>
|
|
2716
|
-
*/return _createClass(TotalLicenseTokenLimitHookClient,[{key:"setTotalLicenseTokenLimit",value:(function(){var _setTotalLicenseTokenLimit=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
2725
|
+
*/return _createClass(TotalLicenseTokenLimitHookClient,[{key:"setTotalLicenseTokenLimit",value:(function(){var _setTotalLicenseTokenLimit=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee195(request){var _yield$this$rpcClient94,call;return _regenerator().w(function(_context195){while(1)switch(_context195.n){case 0:_context195.n=1;return this.rpcClient.simulateContract({abi:totalLicenseTokenLimitHookAbi,address:this.address,functionName:"setTotalLicenseTokenLimit",account:this.wallet.account,args:[request.licensorIpId,request.licenseTemplate,request.licenseTermsId,request.limit]});case 1:_yield$this$rpcClient94=_context195.v;call=_yield$this$rpcClient94.request;_context195.n=2;return this.wallet.writeContract(call);case 2:return _context195.a(2,_context195.v);}},_callee195,this);}));function setTotalLicenseTokenLimit(_x138){return _setTotalLicenseTokenLimit.apply(this,arguments);}return setTotalLicenseTokenLimit;}()/**
|
|
2717
2726
|
* method setTotalLicenseTokenLimit for contract TotalLicenseTokenLimitHook with only encode
|
|
2718
2727
|
*
|
|
2719
2728
|
* @param request TotalLicenseTokenLimitHookSetTotalLicenseTokenLimitRequest
|
|
@@ -2763,19 +2772,19 @@ function getAddress(address,chainId){return address[chainId||0]||"0x";}// Contra
|
|
|
2763
2772
|
*
|
|
2764
2773
|
* @param request WrappedIpAllowanceRequest
|
|
2765
2774
|
* @return Promise<WrappedIpAllowanceResponse>
|
|
2766
|
-
*/return _createClass(WrappedIpReadOnlyClient,[{key:"allowance",value:(function(){var _allowance2=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
2775
|
+
*/return _createClass(WrappedIpReadOnlyClient,[{key:"allowance",value:(function(){var _allowance2=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee196(request){var result;return _regenerator().w(function(_context196){while(1)switch(_context196.n){case 0:_context196.n=1;return this.rpcClient.readContract({abi:wrappedIpAbi,address:this.address,functionName:"allowance",args:[request.owner,request.spender]});case 1:result=_context196.v;return _context196.a(2,{result:result});}},_callee196,this);}));function allowance(_x139){return _allowance2.apply(this,arguments);}return allowance;}()/**
|
|
2767
2776
|
* method balanceOf for contract WrappedIP
|
|
2768
2777
|
*
|
|
2769
2778
|
* @param request WrappedIpBalanceOfRequest
|
|
2770
2779
|
* @return Promise<WrappedIpBalanceOfResponse>
|
|
2771
|
-
*/)},{key:"balanceOf",value:(function(){var
|
|
2780
|
+
*/)},{key:"balanceOf",value:(function(){var _balanceOf4=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee197(request){var result;return _regenerator().w(function(_context197){while(1)switch(_context197.n){case 0:_context197.n=1;return this.rpcClient.readContract({abi:wrappedIpAbi,address:this.address,functionName:"balanceOf",args:[request.owner]});case 1:result=_context197.v;return _context197.a(2,{result:result});}},_callee197,this);}));function balanceOf(_x140){return _balanceOf4.apply(this,arguments);}return balanceOf;}())}]);}();/**
|
|
2772
2781
|
* contract WrappedIP write method
|
|
2773
2782
|
*/var WrappedIpClient=/*#__PURE__*/function(_WrappedIpReadOnlyCli){function WrappedIpClient(rpcClient,wallet,address){var _this16;_classCallCheck(this,WrappedIpClient);_this16=_callSuper(this,WrappedIpClient,[rpcClient,address]);_this16.wallet=wallet;return _this16;}/**
|
|
2774
2783
|
* method approve for contract WrappedIP
|
|
2775
2784
|
*
|
|
2776
2785
|
* @param request WrappedIpApproveRequest
|
|
2777
2786
|
* @return Promise<WriteContractReturnType>
|
|
2778
|
-
*/_inherits(WrappedIpClient,_WrappedIpReadOnlyCli);return _createClass(WrappedIpClient,[{key:"approve",value:(function(){var _approve3=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
2787
|
+
*/_inherits(WrappedIpClient,_WrappedIpReadOnlyCli);return _createClass(WrappedIpClient,[{key:"approve",value:(function(){var _approve3=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee198(request){var _yield$this$rpcClient95,call;return _regenerator().w(function(_context198){while(1)switch(_context198.n){case 0:_context198.n=1;return this.rpcClient.simulateContract({abi:wrappedIpAbi,address:this.address,functionName:"approve",account:this.wallet.account,args:[request.spender,request.amount]});case 1:_yield$this$rpcClient95=_context198.v;call=_yield$this$rpcClient95.request;_context198.n=2;return this.wallet.writeContract(call);case 2:return _context198.a(2,_context198.v);}},_callee198,this);}));function approve(_x141){return _approve3.apply(this,arguments);}return approve;}()/**
|
|
2779
2788
|
* method approve for contract WrappedIP with only encode
|
|
2780
2789
|
*
|
|
2781
2790
|
* @param request WrappedIpApproveRequest
|
|
@@ -2785,7 +2794,7 @@ function getAddress(address,chainId){return address[chainId||0]||"0x";}// Contra
|
|
|
2785
2794
|
*
|
|
2786
2795
|
* @param request WrappedIpDepositRequest
|
|
2787
2796
|
* @return Promise<WriteContractReturnType>
|
|
2788
|
-
*/},{key:"deposit",value:(function(){var _deposit=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
2797
|
+
*/},{key:"deposit",value:(function(){var _deposit=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee199(){var _yield$this$rpcClient96,call;return _regenerator().w(function(_context199){while(1)switch(_context199.n){case 0:_context199.n=1;return this.rpcClient.simulateContract({abi:wrappedIpAbi,address:this.address,functionName:"deposit",account:this.wallet.account});case 1:_yield$this$rpcClient96=_context199.v;call=_yield$this$rpcClient96.request;_context199.n=2;return this.wallet.writeContract(call);case 2:return _context199.a(2,_context199.v);}},_callee199,this);}));function deposit(){return _deposit.apply(this,arguments);}return deposit;}()/**
|
|
2789
2798
|
* method deposit for contract WrappedIP with only encode
|
|
2790
2799
|
*
|
|
2791
2800
|
* @param request WrappedIpDepositRequest
|
|
@@ -2795,7 +2804,7 @@ function getAddress(address,chainId){return address[chainId||0]||"0x";}// Contra
|
|
|
2795
2804
|
*
|
|
2796
2805
|
* @param request WrappedIpTransferRequest
|
|
2797
2806
|
* @return Promise<WriteContractReturnType>
|
|
2798
|
-
*/},{key:"transfer",value:(function(){var _transfer2=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
2807
|
+
*/},{key:"transfer",value:(function(){var _transfer2=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee200(request){var _yield$this$rpcClient97,call;return _regenerator().w(function(_context200){while(1)switch(_context200.n){case 0:_context200.n=1;return this.rpcClient.simulateContract({abi:wrappedIpAbi,address:this.address,functionName:"transfer",account:this.wallet.account,args:[request.to,request.amount]});case 1:_yield$this$rpcClient97=_context200.v;call=_yield$this$rpcClient97.request;_context200.n=2;return this.wallet.writeContract(call);case 2:return _context200.a(2,_context200.v);}},_callee200,this);}));function transfer(_x142){return _transfer2.apply(this,arguments);}return transfer;}()/**
|
|
2799
2808
|
* method transfer for contract WrappedIP with only encode
|
|
2800
2809
|
*
|
|
2801
2810
|
* @param request WrappedIpTransferRequest
|
|
@@ -2805,7 +2814,7 @@ function getAddress(address,chainId){return address[chainId||0]||"0x";}// Contra
|
|
|
2805
2814
|
*
|
|
2806
2815
|
* @param request WrappedIpTransferFromRequest
|
|
2807
2816
|
* @return Promise<WriteContractReturnType>
|
|
2808
|
-
*/},{key:"transferFrom",value:(function(){var _transferFrom2=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
2817
|
+
*/},{key:"transferFrom",value:(function(){var _transferFrom2=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee201(request){var _yield$this$rpcClient98,call;return _regenerator().w(function(_context201){while(1)switch(_context201.n){case 0:_context201.n=1;return this.rpcClient.simulateContract({abi:wrappedIpAbi,address:this.address,functionName:"transferFrom",account:this.wallet.account,args:[request.from,request.to,request.amount]});case 1:_yield$this$rpcClient98=_context201.v;call=_yield$this$rpcClient98.request;_context201.n=2;return this.wallet.writeContract(call);case 2:return _context201.a(2,_context201.v);}},_callee201,this);}));function transferFrom(_x143){return _transferFrom2.apply(this,arguments);}return transferFrom;}()/**
|
|
2809
2818
|
* method transferFrom for contract WrappedIP with only encode
|
|
2810
2819
|
*
|
|
2811
2820
|
* @param request WrappedIpTransferFromRequest
|
|
@@ -2815,7 +2824,7 @@ function getAddress(address,chainId){return address[chainId||0]||"0x";}// Contra
|
|
|
2815
2824
|
*
|
|
2816
2825
|
* @param request WrappedIpWithdrawRequest
|
|
2817
2826
|
* @return Promise<WriteContractReturnType>
|
|
2818
|
-
*/},{key:"withdraw",value:(function(){var _withdraw=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
2827
|
+
*/},{key:"withdraw",value:(function(){var _withdraw=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee202(request){var _yield$this$rpcClient99,call;return _regenerator().w(function(_context202){while(1)switch(_context202.n){case 0:_context202.n=1;return this.rpcClient.simulateContract({abi:wrappedIpAbi,address:this.address,functionName:"withdraw",account:this.wallet.account,args:[request.value]});case 1:_yield$this$rpcClient99=_context202.v;call=_yield$this$rpcClient99.request;_context202.n=2;return this.wallet.writeContract(call);case 2:return _context202.a(2,_context202.v);}},_callee202,this);}));function withdraw(_x144){return _withdraw.apply(this,arguments);}return withdraw;}()/**
|
|
2819
2828
|
* method withdraw for contract WrappedIP with only encode
|
|
2820
2829
|
*
|
|
2821
2830
|
* @param request WrappedIpWithdrawRequest
|
|
@@ -4129,6 +4138,10 @@ var getMinimumBond = /*#__PURE__*/function () {
|
|
|
4129
4138
|
* - Executing the settlement transaction
|
|
4130
4139
|
* - Waiting for transaction confirmation
|
|
4131
4140
|
*
|
|
4141
|
+
* Retry behavior: If the OOV3 contract reverts with "Assertion not expired" (because
|
|
4142
|
+
* the assertion liveness period has not yet elapsed), the function retries up to 5 times
|
|
4143
|
+
* with a 3-second delay between attempts. Other errors are not retried.
|
|
4144
|
+
*
|
|
4132
4145
|
* @see https://docs.story.foundation/docs/uma-arbitration-policy#/
|
|
4133
4146
|
* @see https://docs.uma.xyz/developers/optimistic-oracle-v3
|
|
4134
4147
|
*
|
|
@@ -4139,11 +4152,19 @@ var getMinimumBond = /*#__PURE__*/function () {
|
|
|
4139
4152
|
*/
|
|
4140
4153
|
var settleAssertion = /*#__PURE__*/function () {
|
|
4141
4154
|
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(privateKey, disputeId, transport) {
|
|
4142
|
-
var baseConfig, rpcClient, walletClient, arbitrationPolicyUmaClient, oov3Contract, assertionId, txHash, _t;
|
|
4155
|
+
var maxAttempts, retryDelayMs, attempt, baseConfig, rpcClient, walletClient, arbitrationPolicyUmaClient, oov3Contract, assertionId, txHash, msg, _t;
|
|
4143
4156
|
return _regenerator().w(function (_context4) {
|
|
4144
4157
|
while (1) switch (_context4.p = _context4.n) {
|
|
4145
4158
|
case 0:
|
|
4146
|
-
|
|
4159
|
+
maxAttempts = 5;
|
|
4160
|
+
retryDelayMs = 3000;
|
|
4161
|
+
attempt = 1;
|
|
4162
|
+
case 1:
|
|
4163
|
+
if (!(attempt <= maxAttempts)) {
|
|
4164
|
+
_context4.n = 11;
|
|
4165
|
+
break;
|
|
4166
|
+
}
|
|
4167
|
+
_context4.p = 2;
|
|
4147
4168
|
baseConfig = {
|
|
4148
4169
|
chain: chainStringToViemChain("aeneid"),
|
|
4149
4170
|
transport: http(transport !== null && transport !== void 0 ? transport : aeneid.rpcUrls["default"].http[0])
|
|
@@ -4153,37 +4174,57 @@ var settleAssertion = /*#__PURE__*/function () {
|
|
|
4153
4174
|
account: privateKeyToAccount(privateKey)
|
|
4154
4175
|
}));
|
|
4155
4176
|
arbitrationPolicyUmaClient = new ArbitrationPolicyUmaClient(rpcClient, walletClient);
|
|
4156
|
-
_context4.n =
|
|
4177
|
+
_context4.n = 3;
|
|
4157
4178
|
return getOov3Contract(arbitrationPolicyUmaClient);
|
|
4158
|
-
case
|
|
4179
|
+
case 3:
|
|
4159
4180
|
oov3Contract = _context4.v;
|
|
4160
|
-
_context4.n =
|
|
4181
|
+
_context4.n = 4;
|
|
4161
4182
|
return arbitrationPolicyUmaClient.disputeIdToAssertionId({
|
|
4162
4183
|
disputeId: BigInt(disputeId)
|
|
4163
4184
|
});
|
|
4164
|
-
case
|
|
4185
|
+
case 4:
|
|
4165
4186
|
assertionId = _context4.v;
|
|
4166
|
-
_context4.n =
|
|
4187
|
+
_context4.n = 5;
|
|
4167
4188
|
return walletClient.writeContract({
|
|
4168
4189
|
address: oov3Contract,
|
|
4169
4190
|
abi: ASSERTION_ABI,
|
|
4170
4191
|
functionName: "settleAssertion",
|
|
4171
4192
|
args: [assertionId]
|
|
4172
4193
|
});
|
|
4173
|
-
case
|
|
4194
|
+
case 5:
|
|
4174
4195
|
txHash = _context4.v;
|
|
4175
|
-
_context4.n =
|
|
4196
|
+
_context4.n = 6;
|
|
4176
4197
|
return rpcClient.waitForTransactionReceipt({
|
|
4177
4198
|
hash: txHash
|
|
4178
4199
|
});
|
|
4179
|
-
case
|
|
4200
|
+
case 6:
|
|
4180
4201
|
return _context4.a(2, txHash);
|
|
4181
|
-
case
|
|
4182
|
-
_context4.p =
|
|
4202
|
+
case 7:
|
|
4203
|
+
_context4.p = 7;
|
|
4183
4204
|
_t = _context4.v;
|
|
4205
|
+
msg = _t instanceof Error ? _t.message : String(_t);
|
|
4206
|
+
if (!(attempt < maxAttempts && msg.includes("Assertion not expired"))) {
|
|
4207
|
+
_context4.n = 9;
|
|
4208
|
+
break;
|
|
4209
|
+
}
|
|
4210
|
+
_context4.n = 8;
|
|
4211
|
+
return new Promise(function (resolve) {
|
|
4212
|
+
return setTimeout(resolve, retryDelayMs);
|
|
4213
|
+
});
|
|
4214
|
+
case 8:
|
|
4215
|
+
return _context4.a(3, 10);
|
|
4216
|
+
case 9:
|
|
4184
4217
|
return _context4.a(2, handleError(_t, "Failed to settle assertion"));
|
|
4218
|
+
case 10:
|
|
4219
|
+
attempt++;
|
|
4220
|
+
_context4.n = 1;
|
|
4221
|
+
break;
|
|
4222
|
+
case 11:
|
|
4223
|
+
throw new Error("Failed to settle assertion: max retries exceeded");
|
|
4224
|
+
case 12:
|
|
4225
|
+
return _context4.a(2);
|
|
4185
4226
|
}
|
|
4186
|
-
}, _callee4, null, [[
|
|
4227
|
+
}, _callee4, null, [[2, 7]]);
|
|
4187
4228
|
}));
|
|
4188
4229
|
return function settleAssertion(_x8, _x9, _x0) {
|
|
4189
4230
|
return _ref4.apply(this, arguments);
|
|
@@ -4777,6 +4818,48 @@ var AccessPermission = /*#__PURE__*/function (AccessPermission) {
|
|
|
4777
4818
|
return AccessPermission;
|
|
4778
4819
|
}({});
|
|
4779
4820
|
|
|
4821
|
+
var MAINNET_CHAIN_ID = 1514;
|
|
4822
|
+
var AENEID_CHAIN_ID = 1315;
|
|
4823
|
+
|
|
4824
|
+
/** Per-chain whitelist: chainId -> set of allowed currency token addresses (checksummed). */
|
|
4825
|
+
var CURRENCY_TOKEN_WHITELIST = _defineProperty(_defineProperty({}, MAINNET_CHAIN_ID, new Set([getAddress$1(wrappedIpAddress[MAINNET_CHAIN_ID])])), AENEID_CHAIN_ID, new Set([getAddress$1(wrappedIpAddress[AENEID_CHAIN_ID]), getAddress$1(erc20Address[AENEID_CHAIN_ID])]));
|
|
4826
|
+
|
|
4827
|
+
/** Human-readable description and error hint per chain. */
|
|
4828
|
+
var CHAIN_CURRENCY_HINT = _defineProperty(_defineProperty({}, MAINNET_CHAIN_ID, "On Mainnet, only WIP is allowed as currency token."), AENEID_CHAIN_ID, "On Aeneid Testnet, only WIP or MERC20 is allowed as currency token.");
|
|
4829
|
+
var toChainId = function toChainId(chainId) {
|
|
4830
|
+
if (chainId === "mainnet" || chainId === 1514) {
|
|
4831
|
+
return 1514;
|
|
4832
|
+
}
|
|
4833
|
+
if (chainId === "aeneid" || chainId === 1315) {
|
|
4834
|
+
return 1315;
|
|
4835
|
+
}
|
|
4836
|
+
return chainId;
|
|
4837
|
+
};
|
|
4838
|
+
|
|
4839
|
+
/**
|
|
4840
|
+
* Validates that the currency token is allowed for the given chain.
|
|
4841
|
+
* - Aeneid Testnet (1315): allows WIP or MERC20
|
|
4842
|
+
* - Mainnet (1514): allows WIP only
|
|
4843
|
+
*
|
|
4844
|
+
* @param token - The currency token address to validate
|
|
4845
|
+
* @param chainId - The chain ID (1315 or "aeneid" for Aeneid, 1514 or "mainnet" for Mainnet)
|
|
4846
|
+
* @throws Error if token is zero address or not allowed for the chain
|
|
4847
|
+
*/
|
|
4848
|
+
var validateCurrencyToken = function validateCurrencyToken(token, chainId) {
|
|
4849
|
+
if (token === null || token === undefined || token === zeroAddress) {
|
|
4850
|
+
throw new Error("Currency token cannot be zero address.");
|
|
4851
|
+
}
|
|
4852
|
+
var resolvedChainId = toChainId(chainId);
|
|
4853
|
+
var allowedTokens = CURRENCY_TOKEN_WHITELIST[resolvedChainId];
|
|
4854
|
+
if (allowedTokens === null || allowedTokens === undefined) {
|
|
4855
|
+
throw new Error("Unsupported chain ID: ".concat(chainId, "."));
|
|
4856
|
+
}
|
|
4857
|
+
var normalizedToken = getAddress$1(token);
|
|
4858
|
+
if (!allowedTokens.has(normalizedToken)) {
|
|
4859
|
+
throw new Error("".concat(CHAIN_CURRENCY_HINT[resolvedChainId], " The provided token is not allowed."));
|
|
4860
|
+
}
|
|
4861
|
+
};
|
|
4862
|
+
|
|
4780
4863
|
/**
|
|
4781
4864
|
* Gets the function signature from an ABI for a given method name
|
|
4782
4865
|
* @param abi - The contract ABI
|
|
@@ -5551,6 +5634,9 @@ var GroupClient = /*#__PURE__*/function () {
|
|
|
5551
5634
|
}
|
|
5552
5635
|
throw new Error("Currency token cannot be the zero address.");
|
|
5553
5636
|
case 4:
|
|
5637
|
+
currencyTokens.forEach(function (token) {
|
|
5638
|
+
return validateCurrencyToken(validateAddress(token), _this.chainId);
|
|
5639
|
+
});
|
|
5554
5640
|
collectAndClaimParams = {
|
|
5555
5641
|
groupIpId: validateAddress(groupIpId),
|
|
5556
5642
|
currencyTokens: validateAddresses(currencyTokens),
|
|
@@ -5714,6 +5800,7 @@ var GroupClient = /*#__PURE__*/function () {
|
|
|
5714
5800
|
case 0:
|
|
5715
5801
|
groupIpId = _ref6.groupIpId, currencyToken = _ref6.currencyToken, memberIpIds = _ref6.memberIpIds;
|
|
5716
5802
|
_context9.p = 1;
|
|
5803
|
+
validateCurrencyToken(validateAddress(currencyToken), this.chainId);
|
|
5717
5804
|
_context9.n = 2;
|
|
5718
5805
|
return this.groupingModuleClient.getClaimableReward({
|
|
5719
5806
|
groupId: validateAddress(groupIpId),
|
|
@@ -5794,6 +5881,7 @@ var GroupClient = /*#__PURE__*/function () {
|
|
|
5794
5881
|
case 0:
|
|
5795
5882
|
groupIpId = _ref8.groupIpId, currencyToken = _ref8.currencyToken, memberIpIds = _ref8.memberIpIds, txOptions = _ref8.txOptions;
|
|
5796
5883
|
_context1.p = 1;
|
|
5884
|
+
validateCurrencyToken(validateAddress(currencyToken), this.chainId);
|
|
5797
5885
|
claimRewardParam = {
|
|
5798
5886
|
groupId: validateAddress(groupIpId),
|
|
5799
5887
|
ipIds: validateAddresses(memberIpIds),
|
|
@@ -5853,6 +5941,7 @@ var GroupClient = /*#__PURE__*/function () {
|
|
|
5853
5941
|
case 0:
|
|
5854
5942
|
groupIpId = _ref9.groupIpId, currencyToken = _ref9.currencyToken, txOptions = _ref9.txOptions;
|
|
5855
5943
|
_context10.p = 1;
|
|
5944
|
+
validateCurrencyToken(validateAddress(currencyToken), this.chainId);
|
|
5856
5945
|
collectRoyaltiesParam = {
|
|
5857
5946
|
groupId: validateAddress(groupIpId),
|
|
5858
5947
|
token: validateAddress(currencyToken)
|
|
@@ -7122,6 +7211,11 @@ _defineProperty(PILFlavor, "validateLicenseTerms", function (params, chainId) {
|
|
|
7122
7211
|
throw new PILFlavorError("Royalty policy requires currency token.");
|
|
7123
7212
|
}
|
|
7124
7213
|
|
|
7214
|
+
// Validate currency token is allowed for the chain when currency is set (Aeneid: WIP or MERC20; Mainnet: WIP only). Zero address is allowed (e.g. no royalty).
|
|
7215
|
+
if (currency !== null && currency !== undefined && currency !== zeroAddress && chainId !== undefined) {
|
|
7216
|
+
validateCurrencyToken(currency, chainId);
|
|
7217
|
+
}
|
|
7218
|
+
|
|
7125
7219
|
// Validate defaultMintingFee
|
|
7126
7220
|
if (normalized.defaultMintingFee < 0n) {
|
|
7127
7221
|
throw new PILFlavorError("DefaultMintingFee should be greater than or equal to 0.");
|
|
@@ -7271,6 +7365,7 @@ var validateLicenseTermsData = /*#__PURE__*/function () {
|
|
|
7271
7365
|
_context2.n = 5;
|
|
7272
7366
|
break;
|
|
7273
7367
|
}
|
|
7368
|
+
validateCurrencyToken(licenseTerm.currency, chainId);
|
|
7274
7369
|
_context2.n = 4;
|
|
7275
7370
|
return royaltyModuleReadOnlyClient.isWhitelistedRoyaltyToken({
|
|
7276
7371
|
token: licenseTerm.currency
|
|
@@ -13521,6 +13616,32 @@ var NftClient = /*#__PURE__*/function () {
|
|
|
13521
13616
|
return _getTokenURI.apply(this, arguments);
|
|
13522
13617
|
}
|
|
13523
13618
|
return getTokenURI;
|
|
13619
|
+
}()
|
|
13620
|
+
/**
|
|
13621
|
+
* Returns the number of NFTs owned by an address in a specific SPG NFT collection.
|
|
13622
|
+
*/
|
|
13623
|
+
)
|
|
13624
|
+
}, {
|
|
13625
|
+
key: "getNFTBalance",
|
|
13626
|
+
value: (function () {
|
|
13627
|
+
var _getNFTBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(_ref3) {
|
|
13628
|
+
var spgNftContract, owner, spgNftClient, ownerAddress;
|
|
13629
|
+
return _regenerator().w(function (_context6) {
|
|
13630
|
+
while (1) switch (_context6.n) {
|
|
13631
|
+
case 0:
|
|
13632
|
+
spgNftContract = _ref3.spgNftContract, owner = _ref3.owner;
|
|
13633
|
+
spgNftClient = new SpgnftImplReadOnlyClient(this.rpcClient, validateAddress(spgNftContract));
|
|
13634
|
+
ownerAddress = validateAddress(owner !== null && owner !== void 0 ? owner : this.wallet.account.address);
|
|
13635
|
+
return _context6.a(2, spgNftClient.balanceOf({
|
|
13636
|
+
owner: ownerAddress
|
|
13637
|
+
}));
|
|
13638
|
+
}
|
|
13639
|
+
}, _callee6, this);
|
|
13640
|
+
}));
|
|
13641
|
+
function getNFTBalance(_x6) {
|
|
13642
|
+
return _getNFTBalance.apply(this, arguments);
|
|
13643
|
+
}
|
|
13644
|
+
return getNFTBalance;
|
|
13524
13645
|
}())
|
|
13525
13646
|
}]);
|
|
13526
13647
|
}();
|
|
@@ -15013,6 +15134,12 @@ var StoryClient = /*#__PURE__*/function () {
|
|
|
15013
15134
|
transport: this.config.transport
|
|
15014
15135
|
};
|
|
15015
15136
|
this.rpcClient = createPublicClient(clientConfig);
|
|
15137
|
+
|
|
15138
|
+
// If a txHashResolver is provided (e.g. for AA wallets like ZeroDev/Dynamic),
|
|
15139
|
+
// patch waitForTransactionReceipt to resolve the hash first.
|
|
15140
|
+
if (config.txHashResolver) {
|
|
15141
|
+
this.applyTxHashResolver(config.txHashResolver);
|
|
15142
|
+
}
|
|
15016
15143
|
if (this.config.wallet) {
|
|
15017
15144
|
this.wallet = this.config.wallet;
|
|
15018
15145
|
} else if (this.config.account) {
|
|
@@ -15024,7 +15151,38 @@ var StoryClient = /*#__PURE__*/function () {
|
|
|
15024
15151
|
throw new Error("must specify a wallet or account");
|
|
15025
15152
|
}
|
|
15026
15153
|
}
|
|
15154
|
+
|
|
15155
|
+
/**
|
|
15156
|
+
* Patches rpcClient.waitForTransactionReceipt to first resolve the hash
|
|
15157
|
+
* through the provided resolver. This transparently supports AA wallets
|
|
15158
|
+
* where writeContract returns a UserOperation hash instead of a tx hash.
|
|
15159
|
+
*/
|
|
15027
15160
|
return _createClass(StoryClient, [{
|
|
15161
|
+
key: "applyTxHashResolver",
|
|
15162
|
+
value: function applyTxHashResolver(resolver) {
|
|
15163
|
+
var originalWaitForReceipt = this.rpcClient.waitForTransactionReceipt.bind(this.rpcClient);
|
|
15164
|
+
this.rpcClient.waitForTransactionReceipt = /*#__PURE__*/function () {
|
|
15165
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(args) {
|
|
15166
|
+
var resolvedHash;
|
|
15167
|
+
return _regenerator().w(function (_context) {
|
|
15168
|
+
while (1) switch (_context.n) {
|
|
15169
|
+
case 0:
|
|
15170
|
+
_context.n = 1;
|
|
15171
|
+
return resolver(args.hash);
|
|
15172
|
+
case 1:
|
|
15173
|
+
resolvedHash = _context.v;
|
|
15174
|
+
return _context.a(2, originalWaitForReceipt(_objectSpread2(_objectSpread2({}, args), {}, {
|
|
15175
|
+
hash: resolvedHash
|
|
15176
|
+
})));
|
|
15177
|
+
}
|
|
15178
|
+
}, _callee);
|
|
15179
|
+
}));
|
|
15180
|
+
return function (_x) {
|
|
15181
|
+
return _ref.apply(this, arguments);
|
|
15182
|
+
};
|
|
15183
|
+
}();
|
|
15184
|
+
}
|
|
15185
|
+
}, {
|
|
15028
15186
|
key: "chainId",
|
|
15029
15187
|
get: function get() {
|
|
15030
15188
|
return this.config.chainId;
|
|
@@ -15149,22 +15307,22 @@ var StoryClient = /*#__PURE__*/function () {
|
|
|
15149
15307
|
}, {
|
|
15150
15308
|
key: "getWalletBalance",
|
|
15151
15309
|
value: function () {
|
|
15152
|
-
var _getWalletBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
15153
|
-
return _regenerator().w(function (
|
|
15154
|
-
while (1) switch (
|
|
15310
|
+
var _getWalletBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
15311
|
+
return _regenerator().w(function (_context2) {
|
|
15312
|
+
while (1) switch (_context2.n) {
|
|
15155
15313
|
case 0:
|
|
15156
15314
|
if (this.wallet.account) {
|
|
15157
|
-
|
|
15315
|
+
_context2.n = 1;
|
|
15158
15316
|
break;
|
|
15159
15317
|
}
|
|
15160
15318
|
throw new Error("No account found in wallet");
|
|
15161
15319
|
case 1:
|
|
15162
|
-
|
|
15320
|
+
_context2.n = 2;
|
|
15163
15321
|
return this.getBalance(this.wallet.account.address);
|
|
15164
15322
|
case 2:
|
|
15165
|
-
return
|
|
15323
|
+
return _context2.a(2, _context2.v);
|
|
15166
15324
|
}
|
|
15167
|
-
},
|
|
15325
|
+
}, _callee2, this);
|
|
15168
15326
|
}));
|
|
15169
15327
|
function getWalletBalance() {
|
|
15170
15328
|
return _getWalletBalance.apply(this, arguments);
|
|
@@ -15174,22 +15332,22 @@ var StoryClient = /*#__PURE__*/function () {
|
|
|
15174
15332
|
}, {
|
|
15175
15333
|
key: "getBalance",
|
|
15176
15334
|
value: function () {
|
|
15177
|
-
var _getBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
15335
|
+
var _getBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(address) {
|
|
15178
15336
|
var validAddress;
|
|
15179
|
-
return _regenerator().w(function (
|
|
15180
|
-
while (1) switch (
|
|
15337
|
+
return _regenerator().w(function (_context3) {
|
|
15338
|
+
while (1) switch (_context3.n) {
|
|
15181
15339
|
case 0:
|
|
15182
15340
|
validAddress = validateAddress(address);
|
|
15183
|
-
|
|
15341
|
+
_context3.n = 1;
|
|
15184
15342
|
return this.rpcClient.getBalance({
|
|
15185
15343
|
address: validAddress
|
|
15186
15344
|
});
|
|
15187
15345
|
case 1:
|
|
15188
|
-
return
|
|
15346
|
+
return _context3.a(2, _context3.v);
|
|
15189
15347
|
}
|
|
15190
|
-
},
|
|
15348
|
+
}, _callee3, this);
|
|
15191
15349
|
}));
|
|
15192
|
-
function getBalance(
|
|
15350
|
+
function getBalance(_x2) {
|
|
15193
15351
|
return _getBalance.apply(this, arguments);
|
|
15194
15352
|
}
|
|
15195
15353
|
return getBalance;
|
|
@@ -15209,7 +15367,8 @@ var StoryClient = /*#__PURE__*/function () {
|
|
|
15209
15367
|
return new StoryClient({
|
|
15210
15368
|
chainId: config.chainId,
|
|
15211
15369
|
transport: config.transport,
|
|
15212
|
-
wallet: config.wallet
|
|
15370
|
+
wallet: config.wallet,
|
|
15371
|
+
txHashResolver: config.txHashResolver
|
|
15213
15372
|
});
|
|
15214
15373
|
}
|
|
15215
15374
|
|
|
@@ -15222,7 +15381,8 @@ var StoryClient = /*#__PURE__*/function () {
|
|
|
15222
15381
|
return new StoryClient({
|
|
15223
15382
|
account: config.account,
|
|
15224
15383
|
chainId: config.chainId,
|
|
15225
|
-
transport: config.transport
|
|
15384
|
+
transport: config.transport,
|
|
15385
|
+
txHashResolver: config.txHashResolver
|
|
15226
15386
|
});
|
|
15227
15387
|
}
|
|
15228
15388
|
}]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@story-protocol/core-sdk",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.4",
|
|
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",
|
|
@@ -50,6 +50,8 @@
|
|
|
50
50
|
"@types/mocha": "^10.0.2",
|
|
51
51
|
"@types/node": "^20.8.2",
|
|
52
52
|
"@types/sinon": "^10.0.18",
|
|
53
|
+
"@zerodev/ecdsa-validator": "^5.4.9",
|
|
54
|
+
"@zerodev/sdk": "^5.5.7",
|
|
53
55
|
"c8": "^8.0.1",
|
|
54
56
|
"chai": "^4.3.10",
|
|
55
57
|
"chai-as-promised": "^7.1.1",
|