@cowprotocol/hook-dapp-lib 1.1.0-RC0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,88 @@
1
+ # CoW Protocol hooks
2
+
3
+ >CoW Hooks allow users to call arbitrary Ethereum action before and/or after swap.
4
+ >For example: before swap give a permission to CoW Protocol smart-contract and after swap bridge tokens to another chain.
5
+
6
+ ### Docs: https://docs.cow.fi/cow-protocol/tutorials/hook-dapp
7
+
8
+ ![](./demo.png)
9
+
10
+ ## CoW Hooks Dapp library
11
+
12
+ [CoW Swap](https://swap.cow.fi/) provides an opportunity to use external dapps to build hooks.
13
+ So, you can put a link to some hook-daap and it will be automatically integrate in CoW Swap!
14
+
15
+ This library is for developers who are interested in developing dapps for CoW Hooks.
16
+ It provides:
17
+ - `EIP-1193` provider to interact with a user wallet
18
+ - `HookDappContext` which contains environment parameters (chainId, account, etc.) and current order parameters (sell token, validTo, etc.)
19
+
20
+ And it expects calling two callbacks:
21
+ - `addHook()` when a hook data is ready and can be added to an order
22
+ - `editHook()` when hook parameters were changed
23
+
24
+ ## Quick start
25
+
26
+ ```
27
+ npm install @cowprotocol/hook-dapp-lib --save
28
+ ```
29
+
30
+ ```
31
+ yarn add @cowprotocol/hook-dapp-lib
32
+ ```
33
+
34
+ Let's create a simple hook-dapp that will check the COW token balance of the order creator.
35
+
36
+ ```html
37
+ <html>
38
+ <body>
39
+ <button id="actionButton">Add hook</button>
40
+
41
+ <script>
42
+ import { initCoWHookDapp, HookDappContext } from '@cowprotocol/hook-dapp-lib'
43
+
44
+ const COW_TOKEN_ADDRESS = '0xdef1ca1fb7fbcdc777520aa7f396b4e015f497ab'
45
+ // ERC20.balanceOf(account)
46
+ const CALL_DATA = (account: string) => `0x70a08231000000000000000000000000${account.slice(2)}`
47
+
48
+ let context: HookDappContext | null = null
49
+
50
+ const { actions } = initCoWHookDapp({ onContext: (_context) => context = _context })
51
+
52
+ document.getElementById('actionButton').addEventListener('click', () => {
53
+ if (!context) {
54
+ console.log('App is not loaded yet, please wait a bit.')
55
+ return
56
+ }
57
+
58
+ if (context.hookToEdit) {
59
+ // Implement a logic for editing an existing hook
60
+ // And call actions.editHook() with new parameters
61
+ }
62
+
63
+ actions.addHook({
64
+ hook: {
65
+ target: COW_TOKEN_ADDRESS,
66
+ callData: CALL_DATA(context.account),
67
+ gasLimit: '32000'
68
+ }
69
+ })
70
+ })
71
+ </script>
72
+ </body>
73
+ </html>
74
+ ```
75
+
76
+ ## Developers
77
+
78
+ #### Test
79
+
80
+ ```
81
+ nx test hook-dapp-lib
82
+ ```
83
+
84
+ #### Build the library
85
+
86
+ ```
87
+ nx build hook-dapp-lib
88
+ ```
package/index.iife.js CHANGED
@@ -1 +1 @@
1
- var cowSwapWidget=function(f){"use strict";var $=Object.defineProperty;var Q=(f,_,O)=>_ in f?$(f,_,{enumerable:!0,configurable:!0,writable:!0,value:O}):f[_]=O;var T=(f,_,O)=>(Q(f,typeof _!="symbol"?_+"":_,O),O);class _{constructor(h){this.key=h}postMessageToWindow(h,e,t){const a=typeof t=="object"?t:{},p={key:this.key,method:e,...a};h.postMessage(p,"*")}listenToMessageFromWindow(h,e,t){const a=p=>{!O(p.data)||p.data.key!==this.key||p.data.method!==e||t(p.data)};return h.addEventListener("message",a),a}stopListeningToMessageFromWindow(h,e,t){h.removeEventListener("message",t)}stopListeningWindowListener(h,e){h.removeEventListener("message",e)}}function O(o){return typeof o=="object"&&o!==null&&"key"in o&&"method"in o&&typeof o.key=="string"&&typeof o.method=="string"}var R=(o=>(o.PROVIDER_RPC_REQUEST="PROVIDER_RPC_REQUEST",o.PROVIDER_RPC_RESPONSE="PROVIDER_RPC_RESPONSE",o.PROVIDER_ON_EVENT="PROVIDER_ON_EVENT",o))(R||{});const A=new _("cowSwapIframeRpcProviderTransport");var N={exports:{}};(function(o){var h=Object.prototype.hasOwnProperty,e="~";function t(){}Object.create&&(t.prototype=Object.create(null),new t().__proto__||(e=!1));function a(c,r,s){this.fn=c,this.context=r,this.once=s||!1}function p(c,r,s,i,w){if(typeof s!="function")throw new TypeError("The listener must be a function");var m=new a(s,i||c,w),l=e?e+r:r;return c._events[l]?c._events[l].fn?c._events[l]=[c._events[l],m]:c._events[l].push(m):(c._events[l]=m,c._eventsCount++),c}function g(c,r){--c._eventsCount===0?c._events=new t:delete c._events[r]}function u(){this._events=new t,this._eventsCount=0}u.prototype.eventNames=function(){var r=[],s,i;if(this._eventsCount===0)return r;for(i in s=this._events)h.call(s,i)&&r.push(e?i.slice(1):i);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(s)):r},u.prototype.listeners=function(r){var s=e?e+r:r,i=this._events[s];if(!i)return[];if(i.fn)return[i.fn];for(var w=0,m=i.length,l=new Array(m);w<m;w++)l[w]=i[w].fn;return l},u.prototype.listenerCount=function(r){var s=e?e+r:r,i=this._events[s];return i?i.fn?1:i.length:0},u.prototype.emit=function(r,s,i,w,m,l){var v=e?e+r:r;if(!this._events[v])return!1;var n=this._events[v],y=arguments.length,C,d;if(n.fn){switch(n.once&&this.removeListener(r,n.fn,void 0,!0),y){case 1:return n.fn.call(n.context),!0;case 2:return n.fn.call(n.context,s),!0;case 3:return n.fn.call(n.context,s,i),!0;case 4:return n.fn.call(n.context,s,i,w),!0;case 5:return n.fn.call(n.context,s,i,w,m),!0;case 6:return n.fn.call(n.context,s,i,w,m,l),!0}for(d=1,C=new Array(y-1);d<y;d++)C[d-1]=arguments[d];n.fn.apply(n.context,C)}else{var Y=n.length,k;for(d=0;d<Y;d++)switch(n[d].once&&this.removeListener(r,n[d].fn,void 0,!0),y){case 1:n[d].fn.call(n[d].context);break;case 2:n[d].fn.call(n[d].context,s);break;case 3:n[d].fn.call(n[d].context,s,i);break;case 4:n[d].fn.call(n[d].context,s,i,w);break;default:if(!C)for(k=1,C=new Array(y-1);k<y;k++)C[k-1]=arguments[k];n[d].fn.apply(n[d].context,C)}}return!0},u.prototype.on=function(r,s,i){return p(this,r,s,i,!1)},u.prototype.once=function(r,s,i){return p(this,r,s,i,!0)},u.prototype.removeListener=function(r,s,i,w){var m=e?e+r:r;if(!this._events[m])return this;if(!s)return g(this,m),this;var l=this._events[m];if(l.fn)l.fn===s&&(!w||l.once)&&(!i||l.context===i)&&g(this,m);else{for(var v=0,n=[],y=l.length;v<y;v++)(l[v].fn!==s||w&&!l[v].once||i&&l[v].context!==i)&&n.push(l[v]);n.length?this._events[m]=n.length===1?n[0]:n:g(this,m)}return this},u.prototype.removeAllListeners=function(r){var s;return r?(s=e?e+r:r,this._events[s]&&g(this,s)):(this._events=new t,this._eventsCount=0),this},u.prototype.off=u.prototype.removeListener,u.prototype.addListener=u.prototype.on,u.prefixed=e,u.EventEmitter=u,o.exports=u})(N);var K=N.exports;const V=6e5,U="2.0";function x(){return Math.floor(Math.random()*Number.MAX_SAFE_INTEGER)}class F extends Error{constructor(e,t){super(`${e}: ${t}`);T(this,"isRpcError",!0);T(this,"code");T(this,"reason");this.code=e,this.reason=t}}class G extends K.EventEmitter{constructor({timeoutMilliseconds:e=V,eventSource:t=window,eventTarget:a=window.parent}={}){super();T(this,"enabled",null);T(this,"timeoutMilliseconds");T(this,"eventSource");T(this,"eventTarget");T(this,"completers",{});T(this,"handleRpcRequests",({rpcResponse:e})=>{if(e.id===void 0||e.id===null)return;const t=this.completers[""+e.id];t&&("error"in e||"result"in e?t.resolve(e):t.reject(new Error("Response from provider did not have error or result key")),delete this.completers[e.id])});this.timeoutMilliseconds=e,this.eventSource=t,this.eventTarget=a,A.listenToMessageFromWindow(this.eventSource,R.PROVIDER_RPC_RESPONSE,p=>{this.handleRpcRequests(p)}),A.listenToMessageFromWindow(this.eventSource,R.PROVIDER_ON_EVENT,p=>{this.handleOnEvent(p)})}request({method:e,params:t}){return this.send(e,t)}isConnected(){return!0}get isIFrame(){return!0}get currentProvider(){return this}async execute(e,t){const a=x(),p={jsonrpc:U,id:a,method:e,params:t},g=new Promise((u,c)=>this.completers[a]={resolve:u,reject:c});return A.postMessageToWindow(this.eventTarget,R.PROVIDER_RPC_REQUEST,{rpcRequest:p}),setTimeout(()=>{this.completers[a]&&(this.completers[a].reject(new Error("Request timed out. Please try again and submit it faster.")),delete this.completers[a])},this.timeoutMilliseconds),g}async send(e,t){const{method:a,params:p}=typeof e=="string"?{method:e,params:t}:{method:e.method,params:e.params},g=await this.execute(a,p);if("error"in g)throw new F(g.error.code,g.error.message);return g.result}async enable(){if(this.enabled===null){const e=this.enabled=this.send("enable",[]).catch(t=>{throw this.enabled===e&&(this.enabled=null),t})}return this.enabled}async sendAsync(e,t){try{const a=await this.execute(e.method,e.params);t(null,a)}catch(a){t(a,null)}}handleOnEvent(e){const t=e.params;switch(e.event){case"notification":this.emitNotification(t);break;case"connect":this.emitConnect(t);break;case"disconnect":this.emitDisconnect(t);break;case"chainChanged":this.emitChainChanged(t);break;case"accountsChanged":this.emitAccountsChanged(t);break;case"message":this.emitMessage(t);break;case"networkChanged":this.emitNetworkChanged(t);break;case"close":this.emitClose(t);break;default:console.warn(`[WidgetEthereumProvider] Unknown event type: ${e.event}`);break}}emitNotification(e){this.emit("notification",e)}emitConnect(e){this.enabled===null&&(this.enabled=Promise.resolve([])),this.emit("connect",e)}emitClose(e){Array.isArray(e)&&e.length===2?this.emit("close",e[0],e[1]):this.emit("close")}emitDisconnect(e){this.emit("disconnect",e)}emitChainChanged(e){this.emit("chainChanged",e)}emitNetworkChanged(e){this.emit("networkChanged",e)}emitAccountsChanged(e){this.enabled=Promise.resolve(e),this.emit("accountsChanged",e)}emitMessage(e){this.emit("message",e)}}var E=(o=>(o.ACTIVATE="ACTIVATE",o.CONTEXT_UPDATE="CONTEXT_UPDATE",o.ADD_HOOK="ADD_HOOK",o.EDIT_HOOK="EDIT_HOOK",o.SET_SELL_TOKEN="SET_SELL_TOKEN",o.SET_BUY_TOKEN="SET_BUY_TOKEN",o))(E||{});const b=new _("cowSwapHookDapp");function B({onContext:o}){const h=window.parent,e=new G,t=q();return b.listenToMessageFromWindow(window,E.CONTEXT_UPDATE,o),b.postMessageToWindow(h,E.ACTIVATE,void 0),{actions:t,provider:e}}function q(){return{addHook(o){b.postMessageToWindow(parent,E.ADD_HOOK,o)},editHook(o){b.postMessageToWindow(parent,E.EDIT_HOOK,o)},setSellToken(o){b.postMessageToWindow(parent,E.SET_SELL_TOKEN,o)},setBuyToken(o){b.postMessageToWindow(parent,E.SET_BUY_TOKEN,o)}}}var S=(o=>(o.INTERNAL="INTERNAL",o.IFRAME="IFRAME",o))(S||{}),I=(o=>(o.EOA="EOA",o.SMART_CONTRACT="SMART_CONTRACT",o))(I||{});const j=64,D={id:"c768665aa144bcf18c14eea0249b6322050e5daeba046d7e94df743a2e504586",type:"INTERNAL",name:"Build your own hook",descriptionShort:"Call any smart contract with your own parameters",description:"Didn't find a suitable hook? You can always create your own! To do this, you need to specify which smart contract you want to call, the parameters for the call and the gas limit.",image:"https://raw.githubusercontent.com/cowprotocol/cowswap/refs/heads/develop/apps/cowswap-frontend/src/modules/hooksStore/dapps/BuildHookApp/build.png",version:"v0.1.0",website:"https://docs.cow.fi/cow-protocol/tutorials/hook-dapp"},P={id:"ee4a6b1065cda592972b9ff7448ec111f29a566f137fef101ead7fbf8b01dd0b",type:"INTERNAL",name:"Claim GNO from validators",descriptionShort:"Withdraw rewards from your Gnosis validators.",description:"This hook allows you to withdraw rewards from your Gnosis Chain validators through CoW Swap. It automates the process of interacting with the Gnosis Deposit Contract, enabling you to claim any available rewards directly to your specified withdrawal address. The hook monitors your validator's accrued rewards and triggers the claimWithdrawals function when rewards are ready for withdrawal. This simplifies the management of Gnosis validator earnings without requiring ready for withdrawal. This simplifies the management of Gnosis validator earnings without requiring manual contract interaction, providing a smoother and more efficient experience for users.",image:"https://raw.githubusercontent.com/cowprotocol/cowswap/897ce91ca60a6b2d3823e6a002c3bf64c5384afe/libs/assets/src/cow-swap/network-gnosis-chain-logo.svg",version:"v0.1.1",website:"https://www.gnosis.io",conditions:{supportedNetworks:[100],position:"pre"}},L={id:"1db4bacb661a90fb6b475fd5b585acba9745bc373573c65ecc3e8f5bfd5dee1f",type:"INTERNAL",name:"Permit a token",descriptionShort:"Infinite permit an address to spend one token on your behalf.",description:"This hook allows you to permit an address to spend your tokens on your behalf. This is useful for allowing a smart contract to spend your tokens without needing to approve each transaction.",image:"https://raw.githubusercontent.com/cowprotocol/cowswap/refs/heads/develop/apps/cowswap-frontend/src/modules/hooksStore/dapps/PermitHookApp/icon.png",version:"v0.1.0",website:"https://docs.cow.fi/cow-protocol/tutorials/hook-dapp",conditions:{walletCompatibility:["EOA"],supportedNetworks:[11155111]}},M={id:"40ed08569519f3b58c410ba35a8e684612663a7c9b58025e0a9c3a54551fb0ff",type:"INTERNAL",name:"Claim COW Airdrop",descriptionShort:"Retrieve COW tokens before or after a swap.",description:"Effortless Airdrop Claims! The Claim COW Airdrop feature simplifies the process of collecting free COW tokens before or after your swap, seamlessly integrating into the CoW Swap platform. Whether you're claiming new airdrops or exploring CoW on a new network, this tool ensures you get your rewards quickly and easily.",image:"https://raw.githubusercontent.com/cowprotocol/cowswap/897ce91ca60a6b2d3823e6a002c3bf64c5384afe/apps/cowswap-frontend/src/modules/hooksStore/dapps/AirdropHookApp/airdrop.svg",version:"v0.1.0",website:"https://github.com/bleu/cow-airdrop-contract-deployer",conditions:{supportedNetworks:[11155111]}},W=Object.freeze(Object.defineProperty({__proto__:null,BUILD_CUSTOM_HOOK:D,CLAIM_COW_AIRDROP:M,CLAIM_GNO_FROM_VALIDATORS:P,PERMIT_TOKEN:L,default:{BUILD_CUSTOM_HOOK:D,CLAIM_GNO_FROM_VALIDATORS:P,PERMIT_TOKEN:L,CLAIM_COW_AIRDROP:M}},Symbol.toStringTag,{value:"Module"}));function H(o,h){const e=h.reduce((t,a)=>(t[a.id]=a,t),{});return o.filter(t=>!!t.dappId).map(t=>{const a=t,p=e[a.dappId];return{hook:a,dapp:p||null}})}function X(o,h=[]){return H(o,Object.values(W).concat(h))}return f.CoWHookDappEvents=E,f.HOOK_DAPP_ID_LENGTH=j,f.HookDappType=S,f.HookDappWalletCompatibility=I,f.hookDappIframeTransport=b,f.hookDappsRegistry=W,f.initCoWHookDapp=B,f.matchHooksToDapps=H,f.matchHooksToDappsRegistry=X,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"}),f}({});
1
+ var cowSwapWidget=function(f){"use strict";var Q=Object.defineProperty;var z=(f,v,b)=>v in f?Q(f,v,{enumerable:!0,configurable:!0,writable:!0,value:b}):f[v]=b;var _=(f,v,b)=>(z(f,typeof v!="symbol"?v+"":v,b),b);class v{constructor(p){this.key=p}postMessageToWindow(p,e,t){const a=typeof t=="object"?t:{},h={key:this.key,method:e,...a};p.postMessage(h,"*")}listenToMessageFromWindow(p,e,t){const a=h=>{!b(h.data)||h.data.key!==this.key||h.data.method!==e||t(h.data)};return p.addEventListener("message",a),a}stopListeningToMessageFromWindow(p,e,t){p.removeEventListener("message",t)}stopListeningWindowListener(p,e){p.removeEventListener("message",e)}}function b(o){return typeof o=="object"&&o!==null&&"key"in o&&"method"in o&&typeof o.key=="string"&&typeof o.method=="string"}var A=(o=>(o.PROVIDER_RPC_REQUEST="PROVIDER_RPC_REQUEST",o.PROVIDER_RPC_RESPONSE="PROVIDER_RPC_RESPONSE",o.PROVIDER_ON_EVENT="PROVIDER_ON_EVENT",o))(A||{});const R=new v("cowSwapIframeRpcProviderTransport");var N={exports:{}};(function(o){var p=Object.prototype.hasOwnProperty,e="~";function t(){}Object.create&&(t.prototype=Object.create(null),new t().__proto__||(e=!1));function a(c,s,r){this.fn=c,this.context=s,this.once=r||!1}function h(c,s,r,i,w){if(typeof r!="function")throw new TypeError("The listener must be a function");var m=new a(r,i||c,w),l=e?e+s:s;return c._events[l]?c._events[l].fn?c._events[l]=[c._events[l],m]:c._events[l].push(m):(c._events[l]=m,c._eventsCount++),c}function g(c,s){--c._eventsCount===0?c._events=new t:delete c._events[s]}function u(){this._events=new t,this._eventsCount=0}u.prototype.eventNames=function(){var s=[],r,i;if(this._eventsCount===0)return s;for(i in r=this._events)p.call(r,i)&&s.push(e?i.slice(1):i);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(r)):s},u.prototype.listeners=function(s){var r=e?e+s:s,i=this._events[r];if(!i)return[];if(i.fn)return[i.fn];for(var w=0,m=i.length,l=new Array(m);w<m;w++)l[w]=i[w].fn;return l},u.prototype.listenerCount=function(s){var r=e?e+s:s,i=this._events[r];return i?i.fn?1:i.length:0},u.prototype.emit=function(s,r,i,w,m,l){var T=e?e+s:s;if(!this._events[T])return!1;var n=this._events[T],E=arguments.length,k,d;if(n.fn){switch(n.once&&this.removeListener(s,n.fn,void 0,!0),E){case 1:return n.fn.call(n.context),!0;case 2:return n.fn.call(n.context,r),!0;case 3:return n.fn.call(n.context,r,i),!0;case 4:return n.fn.call(n.context,r,i,w),!0;case 5:return n.fn.call(n.context,r,i,w,m),!0;case 6:return n.fn.call(n.context,r,i,w,m,l),!0}for(d=1,k=new Array(E-1);d<E;d++)k[d-1]=arguments[d];n.fn.apply(n.context,k)}else{var $=n.length,C;for(d=0;d<$;d++)switch(n[d].once&&this.removeListener(s,n[d].fn,void 0,!0),E){case 1:n[d].fn.call(n[d].context);break;case 2:n[d].fn.call(n[d].context,r);break;case 3:n[d].fn.call(n[d].context,r,i);break;case 4:n[d].fn.call(n[d].context,r,i,w);break;default:if(!k)for(C=1,k=new Array(E-1);C<E;C++)k[C-1]=arguments[C];n[d].fn.apply(n[d].context,k)}}return!0},u.prototype.on=function(s,r,i){return h(this,s,r,i,!1)},u.prototype.once=function(s,r,i){return h(this,s,r,i,!0)},u.prototype.removeListener=function(s,r,i,w){var m=e?e+s:s;if(!this._events[m])return this;if(!r)return g(this,m),this;var l=this._events[m];if(l.fn)l.fn===r&&(!w||l.once)&&(!i||l.context===i)&&g(this,m);else{for(var T=0,n=[],E=l.length;T<E;T++)(l[T].fn!==r||w&&!l[T].once||i&&l[T].context!==i)&&n.push(l[T]);n.length?this._events[m]=n.length===1?n[0]:n:g(this,m)}return this},u.prototype.removeAllListeners=function(s){var r;return s?(r=e?e+s:s,this._events[r]&&g(this,r)):(this._events=new t,this._eventsCount=0),this},u.prototype.off=u.prototype.removeListener,u.prototype.addListener=u.prototype.on,u.prefixed=e,u.EventEmitter=u,o.exports=u})(N);var K=N.exports;const U=6e5,x="2.0";function F(){return Math.floor(Math.random()*Number.MAX_SAFE_INTEGER)}class G extends Error{constructor(e,t){super(`${e}: ${t}`);_(this,"isRpcError",!0);_(this,"code");_(this,"reason");this.code=e,this.reason=t}}class B extends K.EventEmitter{constructor({timeoutMilliseconds:e=U,eventSource:t=window,eventTarget:a=window.parent}={}){super();_(this,"enabled",null);_(this,"timeoutMilliseconds");_(this,"eventSource");_(this,"eventTarget");_(this,"completers",{});_(this,"handleRpcRequests",({rpcResponse:e})=>{if(e.id===void 0||e.id===null)return;const t=this.completers[""+e.id];t&&("error"in e||"result"in e?t.resolve(e):t.reject(new Error("Response from provider did not have error or result key")),delete this.completers[e.id])});this.timeoutMilliseconds=e,this.eventSource=t,this.eventTarget=a,R.listenToMessageFromWindow(this.eventSource,A.PROVIDER_RPC_RESPONSE,h=>{this.handleRpcRequests(h)}),R.listenToMessageFromWindow(this.eventSource,A.PROVIDER_ON_EVENT,h=>{this.handleOnEvent(h)})}request({method:e,params:t}){return this.send(e,t)}isConnected(){return!0}get isIFrame(){return!0}get currentProvider(){return this}async execute(e,t){const a=F(),h={jsonrpc:x,id:a,method:e,params:t},g=new Promise((u,c)=>this.completers[a]={resolve:u,reject:c});return R.postMessageToWindow(this.eventTarget,A.PROVIDER_RPC_REQUEST,{rpcRequest:h}),setTimeout(()=>{this.completers[a]&&(this.completers[a].reject(new Error("Request timed out. Please try again and submit it faster.")),delete this.completers[a])},this.timeoutMilliseconds),g}async send(e,t){const{method:a,params:h}=typeof e=="string"?{method:e,params:t}:{method:e.method,params:e.params},g=await this.execute(a,h);if("error"in g)throw new G(g.error.code,g.error.message);return g.result}async enable(){if(this.enabled===null){const e=this.enabled=this.send("enable",[]).catch(t=>{throw this.enabled===e&&(this.enabled=null),t})}return this.enabled}async sendAsync(e,t){try{const a=await this.execute(e.method,e.params);t(null,a)}catch(a){t(a,null)}}handleOnEvent(e){const t=e.params;switch(e.event){case"notification":this.emitNotification(t);break;case"connect":this.emitConnect(t);break;case"disconnect":this.emitDisconnect(t);break;case"chainChanged":this.emitChainChanged(t);break;case"accountsChanged":this.emitAccountsChanged(t);break;case"message":this.emitMessage(t);break;case"networkChanged":this.emitNetworkChanged(t);break;case"close":this.emitClose(t);break;default:console.warn(`[WidgetEthereumProvider] Unknown event type: ${e.event}`);break}}emitNotification(e){this.emit("notification",e)}emitConnect(e){this.enabled===null&&(this.enabled=Promise.resolve([])),this.emit("connect",e)}emitClose(e){Array.isArray(e)&&e.length===2?this.emit("close",e[0],e[1]):this.emit("close")}emitDisconnect(e){this.emit("disconnect",e)}emitChainChanged(e){this.emit("chainChanged",e)}emitNetworkChanged(e){this.emit("networkChanged",e)}emitAccountsChanged(e){this.enabled=Promise.resolve(e),this.emit("accountsChanged",e)}emitMessage(e){this.emit("message",e)}}var y=(o=>(o.ACTIVATE="ACTIVATE",o.CONTEXT_UPDATE="CONTEXT_UPDATE",o.ADD_HOOK="ADD_HOOK",o.EDIT_HOOK="EDIT_HOOK",o.SET_SELL_TOKEN="SET_SELL_TOKEN",o.SET_BUY_TOKEN="SET_BUY_TOKEN",o))(y||{});const O=new v("cowSwapHookDapp");function q({onContext:o}){const p=window.parent,e=new B,t=Y();return O.listenToMessageFromWindow(window,y.CONTEXT_UPDATE,o),O.postMessageToWindow(p,y.ACTIVATE,void 0),{actions:t,provider:e}}function Y(){return{addHook(o){O.postMessageToWindow(parent,y.ADD_HOOK,o)},editHook(o){O.postMessageToWindow(parent,y.EDIT_HOOK,o)},setSellToken(o){O.postMessageToWindow(parent,y.SET_SELL_TOKEN,o)},setBuyToken(o){O.postMessageToWindow(parent,y.SET_BUY_TOKEN,o)}}}var I=(o=>(o.INTERNAL="INTERNAL",o.IFRAME="IFRAME",o))(I||{}),S=(o=>(o.EOA="EOA",o.SMART_CONTRACT="SMART_CONTRACT",o))(S||{});const j=64,P={id:"c768665aa144bcf18c14eea0249b6322050e5daeba046d7e94df743a2e504586",type:"INTERNAL",name:"Build your own hook",descriptionShort:"Call any smart contract with your own parameters",description:"Didn't find a suitable hook? You can always create your own! To do this, you need to specify which smart contract you want to call, the parameters for the call and the gas limit.",image:"https://raw.githubusercontent.com/cowprotocol/cowswap/refs/heads/develop/apps/cowswap-frontend/src/modules/hooksStore/dapps/BuildHookApp/build.png",version:"v0.1.0",website:"https://docs.cow.fi/cow-protocol/tutorials/hook-dapp"},L={id:"ee4a6b1065cda592972b9ff7448ec111f29a566f137fef101ead7fbf8b01dd0b",type:"INTERNAL",name:"Claim GNO from validators",descriptionShort:"Withdraw rewards from your Gnosis validators.",description:"This hook allows you to withdraw rewards from your Gnosis Chain validators through CoW Swap. It automates the process of interacting with the Gnosis Deposit Contract, enabling you to claim any available rewards directly to your specified withdrawal address. The hook monitors your validator's accrued rewards and triggers the claimWithdrawals function when rewards are ready for withdrawal. This simplifies the management of Gnosis validator earnings without requiring ready for withdrawal. This simplifies the management of Gnosis validator earnings without requiring manual contract interaction, providing a smoother and more efficient experience for users.",image:"https://raw.githubusercontent.com/cowprotocol/cowswap/897ce91ca60a6b2d3823e6a002c3bf64c5384afe/libs/assets/src/cow-swap/network-gnosis-chain-logo.svg",version:"v0.1.1",website:"https://www.gnosis.io",conditions:{supportedNetworks:[100],position:"pre"}},D={id:"1db4bacb661a90fb6b475fd5b585acba9745bc373573c65ecc3e8f5bfd5dee1f",type:"INTERNAL",name:"Permit a token",descriptionShort:"Infinite permit an address to spend one token on your behalf.",description:"This hook allows you to permit an address to spend your tokens on your behalf. This is useful for allowing a smart contract to spend your tokens without needing to approve each transaction.",image:"https://raw.githubusercontent.com/cowprotocol/cowswap/refs/heads/develop/apps/cowswap-frontend/src/modules/hooksStore/dapps/PermitHookApp/icon.png",version:"v0.1.0",website:"https://docs.cow.fi/cow-protocol/tutorials/hook-dapp",conditions:{walletCompatibility:["EOA"],supportedNetworks:[11155111]}},M={id:"40ed08569519f3b58c410ba35a8e684612663a7c9b58025e0a9c3a54551fb0ff",type:"INTERNAL",name:"Claim COW Airdrop",descriptionShort:"Retrieve COW tokens before or after a swap.",description:"Effortless Airdrop Claims! The Claim COW Airdrop feature simplifies the process of collecting free COW tokens before or after your swap, seamlessly integrating into the CoW Swap platform. Whether you're claiming new airdrops or exploring CoW on a new network, this tool ensures you get your rewards quickly and easily.",image:"https://raw.githubusercontent.com/cowprotocol/cowswap/897ce91ca60a6b2d3823e6a002c3bf64c5384afe/apps/cowswap-frontend/src/modules/hooksStore/dapps/AirdropHookApp/airdrop.svg",version:"v0.1.0",website:"https://github.com/bleu/cow-airdrop-contract-deployer",conditions:{supportedNetworks:[11155111]}},W={id:"5d2c081d11a01ca0b76e2fafbc0d3c62a4c9945ce404706fb1e49e826c0f99eb",type:"IFRAME",name:"Claim LlamaPay Vesting Hook",description:"The Claim LlamaPay Vesting Hook is a powerful and user-friendly feature designed to streamline the process of claiming funds from LlamaPay vesting contracts. This tool empowers users to easily access and manage their vested tokens, ensuring a smooth and efficient experience in handling time-locked assets.",descriptionShort:"Claim your LlamaPay vesting contract funds",image:"https://cow-hooks-dapps-claim-vesting.vercel.app/llama-pay-icon.png",version:"0.1.0",website:"https://github.com/bleu/cow-hooks-dapps",url:"https://cow-hooks-dapps-claim-vesting.vercel.app",conditions:{supportedNetworks:[1,100,42161]}},H=Object.freeze(Object.defineProperty({__proto__:null,BUILD_CUSTOM_HOOK:P,CLAIM_COW_AIRDROP:M,CLAIM_GNO_FROM_VALIDATORS:L,CLAIM_LLAMAPAY_VESTING:W,PERMIT_TOKEN:D,default:{BUILD_CUSTOM_HOOK:P,CLAIM_GNO_FROM_VALIDATORS:L,PERMIT_TOKEN:D,CLAIM_COW_AIRDROP:M,CLAIM_LLAMAPAY_VESTING:W}},Symbol.toStringTag,{value:"Module"}));function V(o,p){const e=p.reduce((t,a)=>(t[a.id]=a,t),{});return o.filter(t=>!!t.dappId).map(t=>{const a=t,h=e[a.dappId];return{hook:a,dapp:h||null}})}function X(o,p=[]){return V(o,Object.values(H).concat(p))}return f.CoWHookDappEvents=y,f.HOOK_DAPP_ID_LENGTH=j,f.HookDappType=I,f.HookDappWalletCompatibility=S,f.hookDappIframeTransport=O,f.hookDappsRegistry=H,f.initCoWHookDapp=q,f.matchHooksToDapps=V,f.matchHooksToDappsRegistry=X,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"}),f}({});
package/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var x=Object.defineProperty;var H=(t,a,e)=>a in t?x(t,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[a]=e;var g=(t,a,e)=>(H(t,typeof a!="symbol"?a+"":a,e),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class k{constructor(a){this.key=a}postMessageToWindow(a,e,o){const c=typeof o=="object"?o:{},h={key:this.key,method:e,...c};a.postMessage(h,"*")}listenToMessageFromWindow(a,e,o){const c=h=>{!K(h.data)||h.data.key!==this.key||h.data.method!==e||o(h.data)};return a.addEventListener("message",c),c}stopListeningToMessageFromWindow(a,e,o){a.removeEventListener("message",o)}stopListeningWindowListener(a,e){a.removeEventListener("message",e)}}function K(t){return typeof t=="object"&&t!==null&&"key"in t&&"method"in t&&typeof t.key=="string"&&typeof t.method=="string"}var b=(t=>(t.PROVIDER_RPC_REQUEST="PROVIDER_RPC_REQUEST",t.PROVIDER_RPC_RESPONSE="PROVIDER_RPC_RESPONSE",t.PROVIDER_ON_EVENT="PROVIDER_ON_EVENT",t))(b||{});const C=new k("cowSwapIframeRpcProviderTransport");var R={exports:{}};(function(t){var a=Object.prototype.hasOwnProperty,e="~";function o(){}Object.create&&(o.prototype=Object.create(null),new o().__proto__||(e=!1));function c(l,r,s){this.fn=l,this.context=r,this.once=s||!1}function h(l,r,s,i,m){if(typeof s!="function")throw new TypeError("The listener must be a function");var f=new c(s,i||l,m),p=e?e+r:r;return l._events[p]?l._events[p].fn?l._events[p]=[l._events[p],f]:l._events[p].push(f):(l._events[p]=f,l._eventsCount++),l}function w(l,r){--l._eventsCount===0?l._events=new o:delete l._events[r]}function u(){this._events=new o,this._eventsCount=0}u.prototype.eventNames=function(){var r=[],s,i;if(this._eventsCount===0)return r;for(i in s=this._events)a.call(s,i)&&r.push(e?i.slice(1):i);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(s)):r},u.prototype.listeners=function(r){var s=e?e+r:r,i=this._events[s];if(!i)return[];if(i.fn)return[i.fn];for(var m=0,f=i.length,p=new Array(f);m<f;m++)p[m]=i[m].fn;return p},u.prototype.listenerCount=function(r){var s=e?e+r:r,i=this._events[s];return i?i.fn?1:i.length:0},u.prototype.emit=function(r,s,i,m,f,p){var _=e?e+r:r;if(!this._events[_])return!1;var n=this._events[_],T=arguments.length,E,d;if(n.fn){switch(n.once&&this.removeListener(r,n.fn,void 0,!0),T){case 1:return n.fn.call(n.context),!0;case 2:return n.fn.call(n.context,s),!0;case 3:return n.fn.call(n.context,s,i),!0;case 4:return n.fn.call(n.context,s,i,m),!0;case 5:return n.fn.call(n.context,s,i,m,f),!0;case 6:return n.fn.call(n.context,s,i,m,f,p),!0}for(d=1,E=new Array(T-1);d<T;d++)E[d-1]=arguments[d];n.fn.apply(n.context,E)}else{var W=n.length,O;for(d=0;d<W;d++)switch(n[d].once&&this.removeListener(r,n[d].fn,void 0,!0),T){case 1:n[d].fn.call(n[d].context);break;case 2:n[d].fn.call(n[d].context,s);break;case 3:n[d].fn.call(n[d].context,s,i);break;case 4:n[d].fn.call(n[d].context,s,i,m);break;default:if(!E)for(O=1,E=new Array(T-1);O<T;O++)E[O-1]=arguments[O];n[d].fn.apply(n[d].context,E)}}return!0},u.prototype.on=function(r,s,i){return h(this,r,s,i,!1)},u.prototype.once=function(r,s,i){return h(this,r,s,i,!0)},u.prototype.removeListener=function(r,s,i,m){var f=e?e+r:r;if(!this._events[f])return this;if(!s)return w(this,f),this;var p=this._events[f];if(p.fn)p.fn===s&&(!m||p.once)&&(!i||p.context===i)&&w(this,f);else{for(var _=0,n=[],T=p.length;_<T;_++)(p[_].fn!==s||m&&!p[_].once||i&&p[_].context!==i)&&n.push(p[_]);n.length?this._events[f]=n.length===1?n[0]:n:w(this,f)}return this},u.prototype.removeAllListeners=function(r){var s;return r?(s=e?e+r:r,this._events[s]&&w(this,s)):(this._events=new o,this._eventsCount=0),this},u.prototype.off=u.prototype.removeListener,u.prototype.addListener=u.prototype.on,u.prefixed=e,u.EventEmitter=u,t.exports=u})(R);var V=R.exports;const U=6e5,F="2.0";function G(){return Math.floor(Math.random()*Number.MAX_SAFE_INTEGER)}class B extends Error{constructor(e,o){super(`${e}: ${o}`);g(this,"isRpcError",!0);g(this,"code");g(this,"reason");this.code=e,this.reason=o}}class q extends V.EventEmitter{constructor({timeoutMilliseconds:e=U,eventSource:o=window,eventTarget:c=window.parent}={}){super();g(this,"enabled",null);g(this,"timeoutMilliseconds");g(this,"eventSource");g(this,"eventTarget");g(this,"completers",{});g(this,"handleRpcRequests",({rpcResponse:e})=>{if(e.id===void 0||e.id===null)return;const o=this.completers[""+e.id];o&&("error"in e||"result"in e?o.resolve(e):o.reject(new Error("Response from provider did not have error or result key")),delete this.completers[e.id])});this.timeoutMilliseconds=e,this.eventSource=o,this.eventTarget=c,C.listenToMessageFromWindow(this.eventSource,b.PROVIDER_RPC_RESPONSE,h=>{this.handleRpcRequests(h)}),C.listenToMessageFromWindow(this.eventSource,b.PROVIDER_ON_EVENT,h=>{this.handleOnEvent(h)})}request({method:e,params:o}){return this.send(e,o)}isConnected(){return!0}get isIFrame(){return!0}get currentProvider(){return this}async execute(e,o){const c=G(),h={jsonrpc:F,id:c,method:e,params:o},w=new Promise((u,l)=>this.completers[c]={resolve:u,reject:l});return C.postMessageToWindow(this.eventTarget,b.PROVIDER_RPC_REQUEST,{rpcRequest:h}),setTimeout(()=>{this.completers[c]&&(this.completers[c].reject(new Error("Request timed out. Please try again and submit it faster.")),delete this.completers[c])},this.timeoutMilliseconds),w}async send(e,o){const{method:c,params:h}=typeof e=="string"?{method:e,params:o}:{method:e.method,params:e.params},w=await this.execute(c,h);if("error"in w)throw new B(w.error.code,w.error.message);return w.result}async enable(){if(this.enabled===null){const e=this.enabled=this.send("enable",[]).catch(o=>{throw this.enabled===e&&(this.enabled=null),o})}return this.enabled}async sendAsync(e,o){try{const c=await this.execute(e.method,e.params);o(null,c)}catch(c){o(c,null)}}handleOnEvent(e){const o=e.params;switch(e.event){case"notification":this.emitNotification(o);break;case"connect":this.emitConnect(o);break;case"disconnect":this.emitDisconnect(o);break;case"chainChanged":this.emitChainChanged(o);break;case"accountsChanged":this.emitAccountsChanged(o);break;case"message":this.emitMessage(o);break;case"networkChanged":this.emitNetworkChanged(o);break;case"close":this.emitClose(o);break;default:console.warn(`[WidgetEthereumProvider] Unknown event type: ${e.event}`);break}}emitNotification(e){this.emit("notification",e)}emitConnect(e){this.enabled===null&&(this.enabled=Promise.resolve([])),this.emit("connect",e)}emitClose(e){Array.isArray(e)&&e.length===2?this.emit("close",e[0],e[1]):this.emit("close")}emitDisconnect(e){this.emit("disconnect",e)}emitChainChanged(e){this.emit("chainChanged",e)}emitNetworkChanged(e){this.emit("networkChanged",e)}emitAccountsChanged(e){this.enabled=Promise.resolve(e),this.emit("accountsChanged",e)}emitMessage(e){this.emit("message",e)}}var v=(t=>(t.ACTIVATE="ACTIVATE",t.CONTEXT_UPDATE="CONTEXT_UPDATE",t.ADD_HOOK="ADD_HOOK",t.EDIT_HOOK="EDIT_HOOK",t.SET_SELL_TOKEN="SET_SELL_TOKEN",t.SET_BUY_TOKEN="SET_BUY_TOKEN",t))(v||{});const y=new k("cowSwapHookDapp");function j({onContext:t}){const a=window.parent,e=new q,o=X();return y.listenToMessageFromWindow(window,v.CONTEXT_UPDATE,t),y.postMessageToWindow(a,v.ACTIVATE,void 0),{actions:o,provider:e}}function X(){return{addHook(t){y.postMessageToWindow(parent,v.ADD_HOOK,t)},editHook(t){y.postMessageToWindow(parent,v.EDIT_HOOK,t)},setSellToken(t){y.postMessageToWindow(parent,v.SET_SELL_TOKEN,t)},setBuyToken(t){y.postMessageToWindow(parent,v.SET_BUY_TOKEN,t)}}}var A=(t=>(t.INTERNAL="INTERNAL",t.IFRAME="IFRAME",t))(A||{}),N=(t=>(t.EOA="EOA",t.SMART_CONTRACT="SMART_CONTRACT",t))(N||{});const Y=64,S={id:"c768665aa144bcf18c14eea0249b6322050e5daeba046d7e94df743a2e504586",type:"INTERNAL",name:"Build your own hook",descriptionShort:"Call any smart contract with your own parameters",description:"Didn't find a suitable hook? You can always create your own! To do this, you need to specify which smart contract you want to call, the parameters for the call and the gas limit.",image:"https://raw.githubusercontent.com/cowprotocol/cowswap/refs/heads/develop/apps/cowswap-frontend/src/modules/hooksStore/dapps/BuildHookApp/build.png",version:"v0.1.0",website:"https://docs.cow.fi/cow-protocol/tutorials/hook-dapp"},I={id:"ee4a6b1065cda592972b9ff7448ec111f29a566f137fef101ead7fbf8b01dd0b",type:"INTERNAL",name:"Claim GNO from validators",descriptionShort:"Withdraw rewards from your Gnosis validators.",description:"This hook allows you to withdraw rewards from your Gnosis Chain validators through CoW Swap. It automates the process of interacting with the Gnosis Deposit Contract, enabling you to claim any available rewards directly to your specified withdrawal address. The hook monitors your validator's accrued rewards and triggers the claimWithdrawals function when rewards are ready for withdrawal. This simplifies the management of Gnosis validator earnings without requiring ready for withdrawal. This simplifies the management of Gnosis validator earnings without requiring manual contract interaction, providing a smoother and more efficient experience for users.",image:"https://raw.githubusercontent.com/cowprotocol/cowswap/897ce91ca60a6b2d3823e6a002c3bf64c5384afe/libs/assets/src/cow-swap/network-gnosis-chain-logo.svg",version:"v0.1.1",website:"https://www.gnosis.io",conditions:{supportedNetworks:[100],position:"pre"}},D={id:"1db4bacb661a90fb6b475fd5b585acba9745bc373573c65ecc3e8f5bfd5dee1f",type:"INTERNAL",name:"Permit a token",descriptionShort:"Infinite permit an address to spend one token on your behalf.",description:"This hook allows you to permit an address to spend your tokens on your behalf. This is useful for allowing a smart contract to spend your tokens without needing to approve each transaction.",image:"https://raw.githubusercontent.com/cowprotocol/cowswap/refs/heads/develop/apps/cowswap-frontend/src/modules/hooksStore/dapps/PermitHookApp/icon.png",version:"v0.1.0",website:"https://docs.cow.fi/cow-protocol/tutorials/hook-dapp",conditions:{walletCompatibility:["EOA"],supportedNetworks:[11155111]}},P={id:"40ed08569519f3b58c410ba35a8e684612663a7c9b58025e0a9c3a54551fb0ff",type:"INTERNAL",name:"Claim COW Airdrop",descriptionShort:"Retrieve COW tokens before or after a swap.",description:"Effortless Airdrop Claims! The Claim COW Airdrop feature simplifies the process of collecting free COW tokens before or after your swap, seamlessly integrating into the CoW Swap platform. Whether you're claiming new airdrops or exploring CoW on a new network, this tool ensures you get your rewards quickly and easily.",image:"https://raw.githubusercontent.com/cowprotocol/cowswap/897ce91ca60a6b2d3823e6a002c3bf64c5384afe/apps/cowswap-frontend/src/modules/hooksStore/dapps/AirdropHookApp/airdrop.svg",version:"v0.1.0",website:"https://github.com/bleu/cow-airdrop-contract-deployer",conditions:{supportedNetworks:[11155111]}},$={BUILD_CUSTOM_HOOK:S,CLAIM_GNO_FROM_VALIDATORS:I,PERMIT_TOKEN:D,CLAIM_COW_AIRDROP:P},L=Object.freeze(Object.defineProperty({__proto__:null,BUILD_CUSTOM_HOOK:S,CLAIM_COW_AIRDROP:P,CLAIM_GNO_FROM_VALIDATORS:I,PERMIT_TOKEN:D,default:$},Symbol.toStringTag,{value:"Module"}));function M(t,a){const e=a.reduce((o,c)=>(o[c.id]=c,o),{});return t.filter(o=>!!o.dappId).map(o=>{const c=o,h=e[c.dappId];return{hook:c,dapp:h||null}})}function Q(t,a=[]){return M(t,Object.values(L).concat(a))}exports.CoWHookDappEvents=v;exports.HOOK_DAPP_ID_LENGTH=Y;exports.HookDappType=A;exports.HookDappWalletCompatibility=N;exports.hookDappIframeTransport=y;exports.hookDappsRegistry=L;exports.initCoWHookDapp=j;exports.matchHooksToDapps=M;exports.matchHooksToDappsRegistry=Q;
1
+ "use strict";var H=Object.defineProperty;var V=(t,a,e)=>a in t?H(t,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[a]=e;var g=(t,a,e)=>(V(t,typeof a!="symbol"?a+"":a,e),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class C{constructor(a){this.key=a}postMessageToWindow(a,e,o){const c=typeof o=="object"?o:{},h={key:this.key,method:e,...c};a.postMessage(h,"*")}listenToMessageFromWindow(a,e,o){const c=h=>{!K(h.data)||h.data.key!==this.key||h.data.method!==e||o(h.data)};return a.addEventListener("message",c),c}stopListeningToMessageFromWindow(a,e,o){a.removeEventListener("message",o)}stopListeningWindowListener(a,e){a.removeEventListener("message",e)}}function K(t){return typeof t=="object"&&t!==null&&"key"in t&&"method"in t&&typeof t.key=="string"&&typeof t.method=="string"}var O=(t=>(t.PROVIDER_RPC_REQUEST="PROVIDER_RPC_REQUEST",t.PROVIDER_RPC_RESPONSE="PROVIDER_RPC_RESPONSE",t.PROVIDER_ON_EVENT="PROVIDER_ON_EVENT",t))(O||{});const k=new C("cowSwapIframeRpcProviderTransport");var A={exports:{}};(function(t){var a=Object.prototype.hasOwnProperty,e="~";function o(){}Object.create&&(o.prototype=Object.create(null),new o().__proto__||(e=!1));function c(l,n,r){this.fn=l,this.context=n,this.once=r||!1}function h(l,n,r,i,m){if(typeof r!="function")throw new TypeError("The listener must be a function");var f=new c(r,i||l,m),p=e?e+n:n;return l._events[p]?l._events[p].fn?l._events[p]=[l._events[p],f]:l._events[p].push(f):(l._events[p]=f,l._eventsCount++),l}function w(l,n){--l._eventsCount===0?l._events=new o:delete l._events[n]}function u(){this._events=new o,this._eventsCount=0}u.prototype.eventNames=function(){var n=[],r,i;if(this._eventsCount===0)return n;for(i in r=this._events)a.call(r,i)&&n.push(e?i.slice(1):i);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(r)):n},u.prototype.listeners=function(n){var r=e?e+n:n,i=this._events[r];if(!i)return[];if(i.fn)return[i.fn];for(var m=0,f=i.length,p=new Array(f);m<f;m++)p[m]=i[m].fn;return p},u.prototype.listenerCount=function(n){var r=e?e+n:n,i=this._events[r];return i?i.fn?1:i.length:0},u.prototype.emit=function(n,r,i,m,f,p){var v=e?e+n:n;if(!this._events[v])return!1;var s=this._events[v],_=arguments.length,y,d;if(s.fn){switch(s.once&&this.removeListener(n,s.fn,void 0,!0),_){case 1:return s.fn.call(s.context),!0;case 2:return s.fn.call(s.context,r),!0;case 3:return s.fn.call(s.context,r,i),!0;case 4:return s.fn.call(s.context,r,i,m),!0;case 5:return s.fn.call(s.context,r,i,m,f),!0;case 6:return s.fn.call(s.context,r,i,m,f,p),!0}for(d=1,y=new Array(_-1);d<_;d++)y[d-1]=arguments[d];s.fn.apply(s.context,y)}else{var W=s.length,b;for(d=0;d<W;d++)switch(s[d].once&&this.removeListener(n,s[d].fn,void 0,!0),_){case 1:s[d].fn.call(s[d].context);break;case 2:s[d].fn.call(s[d].context,r);break;case 3:s[d].fn.call(s[d].context,r,i);break;case 4:s[d].fn.call(s[d].context,r,i,m);break;default:if(!y)for(b=1,y=new Array(_-1);b<_;b++)y[b-1]=arguments[b];s[d].fn.apply(s[d].context,y)}}return!0},u.prototype.on=function(n,r,i){return h(this,n,r,i,!1)},u.prototype.once=function(n,r,i){return h(this,n,r,i,!0)},u.prototype.removeListener=function(n,r,i,m){var f=e?e+n:n;if(!this._events[f])return this;if(!r)return w(this,f),this;var p=this._events[f];if(p.fn)p.fn===r&&(!m||p.once)&&(!i||p.context===i)&&w(this,f);else{for(var v=0,s=[],_=p.length;v<_;v++)(p[v].fn!==r||m&&!p[v].once||i&&p[v].context!==i)&&s.push(p[v]);s.length?this._events[f]=s.length===1?s[0]:s:w(this,f)}return this},u.prototype.removeAllListeners=function(n){var r;return n?(r=e?e+n:n,this._events[r]&&w(this,r)):(this._events=new o,this._eventsCount=0),this},u.prototype.off=u.prototype.removeListener,u.prototype.addListener=u.prototype.on,u.prefixed=e,u.EventEmitter=u,t.exports=u})(A);var U=A.exports;const F=6e5,G="2.0";function B(){return Math.floor(Math.random()*Number.MAX_SAFE_INTEGER)}class q extends Error{constructor(e,o){super(`${e}: ${o}`);g(this,"isRpcError",!0);g(this,"code");g(this,"reason");this.code=e,this.reason=o}}class Y extends U.EventEmitter{constructor({timeoutMilliseconds:e=F,eventSource:o=window,eventTarget:c=window.parent}={}){super();g(this,"enabled",null);g(this,"timeoutMilliseconds");g(this,"eventSource");g(this,"eventTarget");g(this,"completers",{});g(this,"handleRpcRequests",({rpcResponse:e})=>{if(e.id===void 0||e.id===null)return;const o=this.completers[""+e.id];o&&("error"in e||"result"in e?o.resolve(e):o.reject(new Error("Response from provider did not have error or result key")),delete this.completers[e.id])});this.timeoutMilliseconds=e,this.eventSource=o,this.eventTarget=c,k.listenToMessageFromWindow(this.eventSource,O.PROVIDER_RPC_RESPONSE,h=>{this.handleRpcRequests(h)}),k.listenToMessageFromWindow(this.eventSource,O.PROVIDER_ON_EVENT,h=>{this.handleOnEvent(h)})}request({method:e,params:o}){return this.send(e,o)}isConnected(){return!0}get isIFrame(){return!0}get currentProvider(){return this}async execute(e,o){const c=B(),h={jsonrpc:G,id:c,method:e,params:o},w=new Promise((u,l)=>this.completers[c]={resolve:u,reject:l});return k.postMessageToWindow(this.eventTarget,O.PROVIDER_RPC_REQUEST,{rpcRequest:h}),setTimeout(()=>{this.completers[c]&&(this.completers[c].reject(new Error("Request timed out. Please try again and submit it faster.")),delete this.completers[c])},this.timeoutMilliseconds),w}async send(e,o){const{method:c,params:h}=typeof e=="string"?{method:e,params:o}:{method:e.method,params:e.params},w=await this.execute(c,h);if("error"in w)throw new q(w.error.code,w.error.message);return w.result}async enable(){if(this.enabled===null){const e=this.enabled=this.send("enable",[]).catch(o=>{throw this.enabled===e&&(this.enabled=null),o})}return this.enabled}async sendAsync(e,o){try{const c=await this.execute(e.method,e.params);o(null,c)}catch(c){o(c,null)}}handleOnEvent(e){const o=e.params;switch(e.event){case"notification":this.emitNotification(o);break;case"connect":this.emitConnect(o);break;case"disconnect":this.emitDisconnect(o);break;case"chainChanged":this.emitChainChanged(o);break;case"accountsChanged":this.emitAccountsChanged(o);break;case"message":this.emitMessage(o);break;case"networkChanged":this.emitNetworkChanged(o);break;case"close":this.emitClose(o);break;default:console.warn(`[WidgetEthereumProvider] Unknown event type: ${e.event}`);break}}emitNotification(e){this.emit("notification",e)}emitConnect(e){this.enabled===null&&(this.enabled=Promise.resolve([])),this.emit("connect",e)}emitClose(e){Array.isArray(e)&&e.length===2?this.emit("close",e[0],e[1]):this.emit("close")}emitDisconnect(e){this.emit("disconnect",e)}emitChainChanged(e){this.emit("chainChanged",e)}emitNetworkChanged(e){this.emit("networkChanged",e)}emitAccountsChanged(e){this.enabled=Promise.resolve(e),this.emit("accountsChanged",e)}emitMessage(e){this.emit("message",e)}}var T=(t=>(t.ACTIVATE="ACTIVATE",t.CONTEXT_UPDATE="CONTEXT_UPDATE",t.ADD_HOOK="ADD_HOOK",t.EDIT_HOOK="EDIT_HOOK",t.SET_SELL_TOKEN="SET_SELL_TOKEN",t.SET_BUY_TOKEN="SET_BUY_TOKEN",t))(T||{});const E=new C("cowSwapHookDapp");function j({onContext:t}){const a=window.parent,e=new Y,o=X();return E.listenToMessageFromWindow(window,T.CONTEXT_UPDATE,t),E.postMessageToWindow(a,T.ACTIVATE,void 0),{actions:o,provider:e}}function X(){return{addHook(t){E.postMessageToWindow(parent,T.ADD_HOOK,t)},editHook(t){E.postMessageToWindow(parent,T.EDIT_HOOK,t)},setSellToken(t){E.postMessageToWindow(parent,T.SET_SELL_TOKEN,t)},setBuyToken(t){E.postMessageToWindow(parent,T.SET_BUY_TOKEN,t)}}}var R=(t=>(t.INTERNAL="INTERNAL",t.IFRAME="IFRAME",t))(R||{}),N=(t=>(t.EOA="EOA",t.SMART_CONTRACT="SMART_CONTRACT",t))(N||{});const $=64,I={id:"c768665aa144bcf18c14eea0249b6322050e5daeba046d7e94df743a2e504586",type:"INTERNAL",name:"Build your own hook",descriptionShort:"Call any smart contract with your own parameters",description:"Didn't find a suitable hook? You can always create your own! To do this, you need to specify which smart contract you want to call, the parameters for the call and the gas limit.",image:"https://raw.githubusercontent.com/cowprotocol/cowswap/refs/heads/develop/apps/cowswap-frontend/src/modules/hooksStore/dapps/BuildHookApp/build.png",version:"v0.1.0",website:"https://docs.cow.fi/cow-protocol/tutorials/hook-dapp"},S={id:"ee4a6b1065cda592972b9ff7448ec111f29a566f137fef101ead7fbf8b01dd0b",type:"INTERNAL",name:"Claim GNO from validators",descriptionShort:"Withdraw rewards from your Gnosis validators.",description:"This hook allows you to withdraw rewards from your Gnosis Chain validators through CoW Swap. It automates the process of interacting with the Gnosis Deposit Contract, enabling you to claim any available rewards directly to your specified withdrawal address. The hook monitors your validator's accrued rewards and triggers the claimWithdrawals function when rewards are ready for withdrawal. This simplifies the management of Gnosis validator earnings without requiring ready for withdrawal. This simplifies the management of Gnosis validator earnings without requiring manual contract interaction, providing a smoother and more efficient experience for users.",image:"https://raw.githubusercontent.com/cowprotocol/cowswap/897ce91ca60a6b2d3823e6a002c3bf64c5384afe/libs/assets/src/cow-swap/network-gnosis-chain-logo.svg",version:"v0.1.1",website:"https://www.gnosis.io",conditions:{supportedNetworks:[100],position:"pre"}},P={id:"1db4bacb661a90fb6b475fd5b585acba9745bc373573c65ecc3e8f5bfd5dee1f",type:"INTERNAL",name:"Permit a token",descriptionShort:"Infinite permit an address to spend one token on your behalf.",description:"This hook allows you to permit an address to spend your tokens on your behalf. This is useful for allowing a smart contract to spend your tokens without needing to approve each transaction.",image:"https://raw.githubusercontent.com/cowprotocol/cowswap/refs/heads/develop/apps/cowswap-frontend/src/modules/hooksStore/dapps/PermitHookApp/icon.png",version:"v0.1.0",website:"https://docs.cow.fi/cow-protocol/tutorials/hook-dapp",conditions:{walletCompatibility:["EOA"],supportedNetworks:[11155111]}},L={id:"40ed08569519f3b58c410ba35a8e684612663a7c9b58025e0a9c3a54551fb0ff",type:"INTERNAL",name:"Claim COW Airdrop",descriptionShort:"Retrieve COW tokens before or after a swap.",description:"Effortless Airdrop Claims! The Claim COW Airdrop feature simplifies the process of collecting free COW tokens before or after your swap, seamlessly integrating into the CoW Swap platform. Whether you're claiming new airdrops or exploring CoW on a new network, this tool ensures you get your rewards quickly and easily.",image:"https://raw.githubusercontent.com/cowprotocol/cowswap/897ce91ca60a6b2d3823e6a002c3bf64c5384afe/apps/cowswap-frontend/src/modules/hooksStore/dapps/AirdropHookApp/airdrop.svg",version:"v0.1.0",website:"https://github.com/bleu/cow-airdrop-contract-deployer",conditions:{supportedNetworks:[11155111]}},D={id:"5d2c081d11a01ca0b76e2fafbc0d3c62a4c9945ce404706fb1e49e826c0f99eb",type:"IFRAME",name:"Claim LlamaPay Vesting Hook",description:"The Claim LlamaPay Vesting Hook is a powerful and user-friendly feature designed to streamline the process of claiming funds from LlamaPay vesting contracts. This tool empowers users to easily access and manage their vested tokens, ensuring a smooth and efficient experience in handling time-locked assets.",descriptionShort:"Claim your LlamaPay vesting contract funds",image:"https://cow-hooks-dapps-claim-vesting.vercel.app/llama-pay-icon.png",version:"0.1.0",website:"https://github.com/bleu/cow-hooks-dapps",url:"https://cow-hooks-dapps-claim-vesting.vercel.app",conditions:{supportedNetworks:[1,100,42161]}},Q={BUILD_CUSTOM_HOOK:I,CLAIM_GNO_FROM_VALIDATORS:S,PERMIT_TOKEN:P,CLAIM_COW_AIRDROP:L,CLAIM_LLAMAPAY_VESTING:D},M=Object.freeze(Object.defineProperty({__proto__:null,BUILD_CUSTOM_HOOK:I,CLAIM_COW_AIRDROP:L,CLAIM_GNO_FROM_VALIDATORS:S,CLAIM_LLAMAPAY_VESTING:D,PERMIT_TOKEN:P,default:Q},Symbol.toStringTag,{value:"Module"}));function x(t,a){const e=a.reduce((o,c)=>(o[c.id]=c,o),{});return t.filter(o=>!!o.dappId).map(o=>{const c=o,h=e[c.dappId];return{hook:c,dapp:h||null}})}function z(t,a=[]){return x(t,Object.values(M).concat(a))}exports.CoWHookDappEvents=T;exports.HOOK_DAPP_ID_LENGTH=$;exports.HookDappType=R;exports.HookDappWalletCompatibility=N;exports.hookDappIframeTransport=E;exports.hookDappsRegistry=M;exports.initCoWHookDapp=j;exports.matchHooksToDapps=x;exports.matchHooksToDappsRegistry=z;
package/index.mjs CHANGED
@@ -1,25 +1,25 @@
1
- var L = Object.defineProperty;
2
- var M = (t, a, e) => a in t ? L(t, a, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[a] = e;
3
- var g = (t, a, e) => (M(t, typeof a != "symbol" ? a + "" : a, e), e);
4
- class R {
1
+ var M = Object.defineProperty;
2
+ var D = (t, a, e) => a in t ? M(t, a, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[a] = e;
3
+ var g = (t, a, e) => (D(t, typeof a != "symbol" ? a + "" : a, e), e);
4
+ class C {
5
5
  constructor(a) {
6
6
  this.key = a;
7
7
  }
8
8
  postMessageToWindow(a, e, o) {
9
- const c = typeof o == "object" ? o : {}, u = {
9
+ const c = typeof o == "object" ? o : {}, h = {
10
10
  key: this.key,
11
11
  method: e,
12
12
  ...c
13
13
  };
14
14
  a.postMessage(
15
- u,
15
+ h,
16
16
  "*"
17
17
  // TODO: Change to CoW specific origin in production. https://github.com/cowprotocol/cowswap/issues/3828
18
18
  );
19
19
  }
20
20
  listenToMessageFromWindow(a, e, o) {
21
- const c = (u) => {
22
- !D(u.data) || u.data.key !== this.key || u.data.method !== e || o(u.data);
21
+ const c = (h) => {
22
+ !x(h.data) || h.data.key !== this.key || h.data.method !== e || o(h.data);
23
23
  };
24
24
  return a.addEventListener("message", c), c;
25
25
  }
@@ -30,43 +30,43 @@ class R {
30
30
  a.removeEventListener("message", e);
31
31
  }
32
32
  }
33
- function D(t) {
33
+ function x(t) {
34
34
  return typeof t == "object" && t !== null && "key" in t && "method" in t && typeof t.key == "string" && typeof t.method == "string";
35
35
  }
36
- var b = /* @__PURE__ */ ((t) => (t.PROVIDER_RPC_REQUEST = "PROVIDER_RPC_REQUEST", t.PROVIDER_RPC_RESPONSE = "PROVIDER_RPC_RESPONSE", t.PROVIDER_ON_EVENT = "PROVIDER_ON_EVENT", t))(b || {});
37
- const C = new R(
36
+ var O = /* @__PURE__ */ ((t) => (t.PROVIDER_RPC_REQUEST = "PROVIDER_RPC_REQUEST", t.PROVIDER_RPC_RESPONSE = "PROVIDER_RPC_RESPONSE", t.PROVIDER_ON_EVENT = "PROVIDER_ON_EVENT", t))(O || {});
37
+ const A = new C(
38
38
  "cowSwapIframeRpcProviderTransport"
39
39
  );
40
- var A = { exports: {} };
40
+ var k = { exports: {} };
41
41
  (function(t) {
42
42
  var a = Object.prototype.hasOwnProperty, e = "~";
43
43
  function o() {
44
44
  }
45
45
  Object.create && (o.prototype = /* @__PURE__ */ Object.create(null), new o().__proto__ || (e = !1));
46
- function c(l, r, s) {
47
- this.fn = l, this.context = r, this.once = s || !1;
46
+ function c(l, n, r) {
47
+ this.fn = l, this.context = n, this.once = r || !1;
48
48
  }
49
- function u(l, r, s, i, m) {
50
- if (typeof s != "function")
49
+ function h(l, n, r, i, m) {
50
+ if (typeof r != "function")
51
51
  throw new TypeError("The listener must be a function");
52
- var f = new c(s, i || l, m), d = e ? e + r : r;
52
+ var f = new c(r, i || l, m), d = e ? e + n : n;
53
53
  return l._events[d] ? l._events[d].fn ? l._events[d] = [l._events[d], f] : l._events[d].push(f) : (l._events[d] = f, l._eventsCount++), l;
54
54
  }
55
- function w(l, r) {
56
- --l._eventsCount === 0 ? l._events = new o() : delete l._events[r];
55
+ function w(l, n) {
56
+ --l._eventsCount === 0 ? l._events = new o() : delete l._events[n];
57
57
  }
58
- function p() {
58
+ function u() {
59
59
  this._events = new o(), this._eventsCount = 0;
60
60
  }
61
- p.prototype.eventNames = function() {
62
- var r = [], s, i;
61
+ u.prototype.eventNames = function() {
62
+ var n = [], r, i;
63
63
  if (this._eventsCount === 0)
64
- return r;
65
- for (i in s = this._events)
66
- a.call(s, i) && r.push(e ? i.slice(1) : i);
67
- return Object.getOwnPropertySymbols ? r.concat(Object.getOwnPropertySymbols(s)) : r;
68
- }, p.prototype.listeners = function(r) {
69
- var s = e ? e + r : r, i = this._events[s];
64
+ return n;
65
+ for (i in r = this._events)
66
+ a.call(r, i) && n.push(e ? i.slice(1) : i);
67
+ return Object.getOwnPropertySymbols ? n.concat(Object.getOwnPropertySymbols(r)) : n;
68
+ }, u.prototype.listeners = function(n) {
69
+ var r = e ? e + n : n, i = this._events[r];
70
70
  if (!i)
71
71
  return [];
72
72
  if (i.fn)
@@ -74,86 +74,86 @@ var A = { exports: {} };
74
74
  for (var m = 0, f = i.length, d = new Array(f); m < f; m++)
75
75
  d[m] = i[m].fn;
76
76
  return d;
77
- }, p.prototype.listenerCount = function(r) {
78
- var s = e ? e + r : r, i = this._events[s];
77
+ }, u.prototype.listenerCount = function(n) {
78
+ var r = e ? e + n : n, i = this._events[r];
79
79
  return i ? i.fn ? 1 : i.length : 0;
80
- }, p.prototype.emit = function(r, s, i, m, f, d) {
81
- var _ = e ? e + r : r;
82
- if (!this._events[_])
80
+ }, u.prototype.emit = function(n, r, i, m, f, d) {
81
+ var v = e ? e + n : n;
82
+ if (!this._events[v])
83
83
  return !1;
84
- var n = this._events[_], v = arguments.length, E, h;
85
- if (n.fn) {
86
- switch (n.once && this.removeListener(r, n.fn, void 0, !0), v) {
84
+ var s = this._events[v], _ = arguments.length, E, p;
85
+ if (s.fn) {
86
+ switch (s.once && this.removeListener(n, s.fn, void 0, !0), _) {
87
87
  case 1:
88
- return n.fn.call(n.context), !0;
88
+ return s.fn.call(s.context), !0;
89
89
  case 2:
90
- return n.fn.call(n.context, s), !0;
90
+ return s.fn.call(s.context, r), !0;
91
91
  case 3:
92
- return n.fn.call(n.context, s, i), !0;
92
+ return s.fn.call(s.context, r, i), !0;
93
93
  case 4:
94
- return n.fn.call(n.context, s, i, m), !0;
94
+ return s.fn.call(s.context, r, i, m), !0;
95
95
  case 5:
96
- return n.fn.call(n.context, s, i, m, f), !0;
96
+ return s.fn.call(s.context, r, i, m, f), !0;
97
97
  case 6:
98
- return n.fn.call(n.context, s, i, m, f, d), !0;
98
+ return s.fn.call(s.context, r, i, m, f, d), !0;
99
99
  }
100
- for (h = 1, E = new Array(v - 1); h < v; h++)
101
- E[h - 1] = arguments[h];
102
- n.fn.apply(n.context, E);
100
+ for (p = 1, E = new Array(_ - 1); p < _; p++)
101
+ E[p - 1] = arguments[p];
102
+ s.fn.apply(s.context, E);
103
103
  } else {
104
- var P = n.length, O;
105
- for (h = 0; h < P; h++)
106
- switch (n[h].once && this.removeListener(r, n[h].fn, void 0, !0), v) {
104
+ var P = s.length, b;
105
+ for (p = 0; p < P; p++)
106
+ switch (s[p].once && this.removeListener(n, s[p].fn, void 0, !0), _) {
107
107
  case 1:
108
- n[h].fn.call(n[h].context);
108
+ s[p].fn.call(s[p].context);
109
109
  break;
110
110
  case 2:
111
- n[h].fn.call(n[h].context, s);
111
+ s[p].fn.call(s[p].context, r);
112
112
  break;
113
113
  case 3:
114
- n[h].fn.call(n[h].context, s, i);
114
+ s[p].fn.call(s[p].context, r, i);
115
115
  break;
116
116
  case 4:
117
- n[h].fn.call(n[h].context, s, i, m);
117
+ s[p].fn.call(s[p].context, r, i, m);
118
118
  break;
119
119
  default:
120
120
  if (!E)
121
- for (O = 1, E = new Array(v - 1); O < v; O++)
122
- E[O - 1] = arguments[O];
123
- n[h].fn.apply(n[h].context, E);
121
+ for (b = 1, E = new Array(_ - 1); b < _; b++)
122
+ E[b - 1] = arguments[b];
123
+ s[p].fn.apply(s[p].context, E);
124
124
  }
125
125
  }
126
126
  return !0;
127
- }, p.prototype.on = function(r, s, i) {
128
- return u(this, r, s, i, !1);
129
- }, p.prototype.once = function(r, s, i) {
130
- return u(this, r, s, i, !0);
131
- }, p.prototype.removeListener = function(r, s, i, m) {
132
- var f = e ? e + r : r;
127
+ }, u.prototype.on = function(n, r, i) {
128
+ return h(this, n, r, i, !1);
129
+ }, u.prototype.once = function(n, r, i) {
130
+ return h(this, n, r, i, !0);
131
+ }, u.prototype.removeListener = function(n, r, i, m) {
132
+ var f = e ? e + n : n;
133
133
  if (!this._events[f])
134
134
  return this;
135
- if (!s)
135
+ if (!r)
136
136
  return w(this, f), this;
137
137
  var d = this._events[f];
138
138
  if (d.fn)
139
- d.fn === s && (!m || d.once) && (!i || d.context === i) && w(this, f);
139
+ d.fn === r && (!m || d.once) && (!i || d.context === i) && w(this, f);
140
140
  else {
141
- for (var _ = 0, n = [], v = d.length; _ < v; _++)
142
- (d[_].fn !== s || m && !d[_].once || i && d[_].context !== i) && n.push(d[_]);
143
- n.length ? this._events[f] = n.length === 1 ? n[0] : n : w(this, f);
141
+ for (var v = 0, s = [], _ = d.length; v < _; v++)
142
+ (d[v].fn !== r || m && !d[v].once || i && d[v].context !== i) && s.push(d[v]);
143
+ s.length ? this._events[f] = s.length === 1 ? s[0] : s : w(this, f);
144
144
  }
145
145
  return this;
146
- }, p.prototype.removeAllListeners = function(r) {
147
- var s;
148
- return r ? (s = e ? e + r : r, this._events[s] && w(this, s)) : (this._events = new o(), this._eventsCount = 0), this;
149
- }, p.prototype.off = p.prototype.removeListener, p.prototype.addListener = p.prototype.on, p.prefixed = e, p.EventEmitter = p, t.exports = p;
150
- })(A);
151
- var x = A.exports;
152
- const W = 6e5, V = "2.0";
153
- function K() {
146
+ }, u.prototype.removeAllListeners = function(n) {
147
+ var r;
148
+ return n ? (r = e ? e + n : n, this._events[r] && w(this, r)) : (this._events = new o(), this._eventsCount = 0), this;
149
+ }, u.prototype.off = u.prototype.removeListener, u.prototype.addListener = u.prototype.on, u.prefixed = e, u.EventEmitter = u, t.exports = u;
150
+ })(k);
151
+ var W = k.exports;
152
+ const V = 6e5, K = "2.0";
153
+ function U() {
154
154
  return Math.floor(Math.random() * Number.MAX_SAFE_INTEGER);
155
155
  }
156
- class U extends Error {
156
+ class H extends Error {
157
157
  constructor(e, o) {
158
158
  super(`${e}: ${o}`);
159
159
  g(this, "isRpcError", !0);
@@ -162,9 +162,9 @@ class U extends Error {
162
162
  this.code = e, this.reason = o;
163
163
  }
164
164
  }
165
- class H extends x.EventEmitter {
165
+ class F extends W.EventEmitter {
166
166
  constructor({
167
- timeoutMilliseconds: e = W,
167
+ timeoutMilliseconds: e = V,
168
168
  eventSource: o = window,
169
169
  eventTarget: c = window.parent
170
170
  } = {}) {
@@ -183,17 +183,17 @@ class H extends x.EventEmitter {
183
183
  const o = this.completers["" + e.id];
184
184
  o && ("error" in e || "result" in e ? o.resolve(e) : o.reject(new Error("Response from provider did not have error or result key")), delete this.completers[e.id]);
185
185
  });
186
- this.timeoutMilliseconds = e, this.eventSource = o, this.eventTarget = c, C.listenToMessageFromWindow(
186
+ this.timeoutMilliseconds = e, this.eventSource = o, this.eventTarget = c, A.listenToMessageFromWindow(
187
187
  this.eventSource,
188
- b.PROVIDER_RPC_RESPONSE,
189
- (u) => {
190
- this.handleRpcRequests(u);
188
+ O.PROVIDER_RPC_RESPONSE,
189
+ (h) => {
190
+ this.handleRpcRequests(h);
191
191
  }
192
- ), C.listenToMessageFromWindow(
192
+ ), A.listenToMessageFromWindow(
193
193
  this.eventSource,
194
- b.PROVIDER_ON_EVENT,
195
- (u) => {
196
- this.handleOnEvent(u);
194
+ O.PROVIDER_ON_EVENT,
195
+ (h) => {
196
+ this.handleOnEvent(h);
197
197
  }
198
198
  );
199
199
  }
@@ -221,24 +221,24 @@ class H extends x.EventEmitter {
221
221
  * @param params params to pass the method
222
222
  */
223
223
  async execute(e, o) {
224
- const c = K(), u = {
225
- jsonrpc: V,
224
+ const c = U(), h = {
225
+ jsonrpc: K,
226
226
  id: c,
227
227
  method: e,
228
228
  params: o
229
229
  }, w = new Promise(
230
- (p, l) => this.completers[c] = { resolve: p, reject: l }
230
+ (u, l) => this.completers[c] = { resolve: u, reject: l }
231
231
  );
232
- return C.postMessageToWindow(this.eventTarget, b.PROVIDER_RPC_REQUEST, {
233
- rpcRequest: u
232
+ return A.postMessageToWindow(this.eventTarget, O.PROVIDER_RPC_REQUEST, {
233
+ rpcRequest: h
234
234
  }), setTimeout(() => {
235
235
  this.completers[c] && (this.completers[c].reject(new Error("Request timed out. Please try again and submit it faster.")), delete this.completers[c]);
236
236
  }, this.timeoutMilliseconds), w;
237
237
  }
238
238
  async send(e, o) {
239
- const { method: c, params: u } = typeof e == "string" ? { method: e, params: o } : { method: e.method, params: e.params }, w = await this.execute(c, u);
239
+ const { method: c, params: h } = typeof e == "string" ? { method: e, params: o } : { method: e.method, params: e.params }, w = await this.execute(c, h);
240
240
  if ("error" in w)
241
- throw new U(w.error.code, w.error.message);
241
+ throw new H(w.error.code, w.error.message);
242
242
  return w.result;
243
243
  }
244
244
  /**
@@ -329,12 +329,12 @@ class H extends x.EventEmitter {
329
329
  }
330
330
  }
331
331
  var T = /* @__PURE__ */ ((t) => (t.ACTIVATE = "ACTIVATE", t.CONTEXT_UPDATE = "CONTEXT_UPDATE", t.ADD_HOOK = "ADD_HOOK", t.EDIT_HOOK = "EDIT_HOOK", t.SET_SELL_TOKEN = "SET_SELL_TOKEN", t.SET_BUY_TOKEN = "SET_BUY_TOKEN", t))(T || {});
332
- const y = new R("cowSwapHookDapp");
333
- function $({ onContext: t }) {
334
- const a = window.parent, e = new H(), o = F();
332
+ const y = new C("cowSwapHookDapp");
333
+ function Q({ onContext: t }) {
334
+ const a = window.parent, e = new F(), o = G();
335
335
  return y.listenToMessageFromWindow(window, T.CONTEXT_UPDATE, t), y.postMessageToWindow(a, T.ACTIVATE, void 0), { actions: o, provider: e };
336
336
  }
337
- function F() {
337
+ function G() {
338
338
  return {
339
339
  addHook(t) {
340
340
  y.postMessageToWindow(parent, T.ADD_HOOK, t);
@@ -350,8 +350,8 @@ function F() {
350
350
  }
351
351
  };
352
352
  }
353
- var G = /* @__PURE__ */ ((t) => (t.INTERNAL = "INTERNAL", t.IFRAME = "IFRAME", t))(G || {}), B = /* @__PURE__ */ ((t) => (t.EOA = "EOA", t.SMART_CONTRACT = "SMART_CONTRACT", t))(B || {});
354
- const Q = 64, k = {
353
+ var B = /* @__PURE__ */ ((t) => (t.INTERNAL = "INTERNAL", t.IFRAME = "IFRAME", t))(B || {}), q = /* @__PURE__ */ ((t) => (t.EOA = "EOA", t.SMART_CONTRACT = "SMART_CONTRACT", t))(q || {});
354
+ const z = 64, R = {
355
355
  id: "c768665aa144bcf18c14eea0249b6322050e5daeba046d7e94df743a2e504586",
356
356
  type: "INTERNAL",
357
357
  name: "Build your own hook",
@@ -375,7 +375,7 @@ const Q = 64, k = {
375
375
  ],
376
376
  position: "pre"
377
377
  }
378
- }, S = {
378
+ }, I = {
379
379
  id: "1db4bacb661a90fb6b475fd5b585acba9745bc373573c65ecc3e8f5bfd5dee1f",
380
380
  type: "INTERNAL",
381
381
  name: "Permit a token",
@@ -392,7 +392,7 @@ const Q = 64, k = {
392
392
  11155111
393
393
  ]
394
394
  }
395
- }, I = {
395
+ }, S = {
396
396
  id: "40ed08569519f3b58c410ba35a8e684612663a7c9b58025e0a9c3a54551fb0ff",
397
397
  type: "INTERNAL",
398
398
  name: "Claim COW Airdrop",
@@ -406,18 +406,37 @@ const Q = 64, k = {
406
406
  11155111
407
407
  ]
408
408
  }
409
- }, q = {
410
- BUILD_CUSTOM_HOOK: k,
409
+ }, L = {
410
+ id: "5d2c081d11a01ca0b76e2fafbc0d3c62a4c9945ce404706fb1e49e826c0f99eb",
411
+ type: "IFRAME",
412
+ name: "Claim LlamaPay Vesting Hook",
413
+ description: "The Claim LlamaPay Vesting Hook is a powerful and user-friendly feature designed to streamline the process of claiming funds from LlamaPay vesting contracts. This tool empowers users to easily access and manage their vested tokens, ensuring a smooth and efficient experience in handling time-locked assets.",
414
+ descriptionShort: "Claim your LlamaPay vesting contract funds",
415
+ image: "https://cow-hooks-dapps-claim-vesting.vercel.app/llama-pay-icon.png",
416
+ version: "0.1.0",
417
+ website: "https://github.com/bleu/cow-hooks-dapps",
418
+ url: "https://cow-hooks-dapps-claim-vesting.vercel.app",
419
+ conditions: {
420
+ supportedNetworks: [
421
+ 1,
422
+ 100,
423
+ 42161
424
+ ]
425
+ }
426
+ }, Y = {
427
+ BUILD_CUSTOM_HOOK: R,
411
428
  CLAIM_GNO_FROM_VALIDATORS: N,
412
- PERMIT_TOKEN: S,
413
- CLAIM_COW_AIRDROP: I
429
+ PERMIT_TOKEN: I,
430
+ CLAIM_COW_AIRDROP: S,
431
+ CLAIM_LLAMAPAY_VESTING: L
414
432
  }, j = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
415
433
  __proto__: null,
416
- BUILD_CUSTOM_HOOK: k,
417
- CLAIM_COW_AIRDROP: I,
434
+ BUILD_CUSTOM_HOOK: R,
435
+ CLAIM_COW_AIRDROP: S,
418
436
  CLAIM_GNO_FROM_VALIDATORS: N,
419
- PERMIT_TOKEN: S,
420
- default: q
437
+ CLAIM_LLAMAPAY_VESTING: L,
438
+ PERMIT_TOKEN: I,
439
+ default: Y
421
440
  }, Symbol.toStringTag, { value: "Module" }));
422
441
  function X(t, a) {
423
442
  const e = a.reduce(
@@ -425,24 +444,24 @@ function X(t, a) {
425
444
  {}
426
445
  );
427
446
  return t.filter((o) => !!o.dappId).map((o) => {
428
- const c = o, u = e[c.dappId];
447
+ const c = o, h = e[c.dappId];
429
448
  return {
430
449
  hook: c,
431
- dapp: u || null
450
+ dapp: h || null
432
451
  };
433
452
  });
434
453
  }
435
- function z(t, a = []) {
454
+ function J(t, a = []) {
436
455
  return X(t, Object.values(j).concat(a));
437
456
  }
438
457
  export {
439
458
  T as CoWHookDappEvents,
440
- Q as HOOK_DAPP_ID_LENGTH,
441
- G as HookDappType,
442
- B as HookDappWalletCompatibility,
459
+ z as HOOK_DAPP_ID_LENGTH,
460
+ B as HookDappType,
461
+ q as HookDappWalletCompatibility,
443
462
  y as hookDappIframeTransport,
444
463
  j as hookDappsRegistry,
445
- $ as initCoWHookDapp,
464
+ Q as initCoWHookDapp,
446
465
  X as matchHooksToDapps,
447
- z as matchHooksToDappsRegistry
466
+ J as matchHooksToDappsRegistry
448
467
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cowprotocol/hook-dapp-lib",
3
- "version": "1.1.0-RC0",
3
+ "version": "1.2.0",
4
4
  "type": "commonjs",
5
5
  "description": "CoW Swap Hook Dapp Library. Allows you to develop pre/post hooks dapps for CoW Protocol.",
6
6
  "main": "index.js",