@cowprotocol/hook-dapp-lib 1.3.1 → 1.7.1

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/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
+ import { default as hookDappsRegistry } from './hookDappsRegistry.json';
1
2
  export { initCoWHookDapp } from './initCoWHookDapp';
2
3
  export * from './hookDappIframeTransport';
3
4
  export * from './types';
4
5
  export * from './consts';
5
6
  export * from './utils';
6
- import * as hookDappsRegistry from './hookDappsRegistry.json';
7
7
  export { hookDappsRegistry };
package/index.iife.js CHANGED
@@ -1 +1,5 @@
1
- var cowSwapWidget=function(f){"use strict";var J=Object.defineProperty;var Z=(f,y,T)=>y in f?J(f,y,{enumerable:!0,configurable:!0,writable:!0,value:T}):f[y]=T;var v=(f,y,T)=>(Z(f,typeof y!="symbol"?y+"":y,T),T);class y{constructor(d){this.key=d}postMessageToWindow(d,e,t){const a=typeof t=="object"?t:{},h={key:this.key,method:e,...a};d.postMessage(h,"*")}listenToMessageFromWindow(d,e,t){const a=h=>{!T(h.data)||h.data.key!==this.key||h.data.method!==e||t(h.data)};return d.addEventListener("message",a),a}stopListeningToMessageFromWindow(d,e,t){d.removeEventListener("message",t)}stopListeningWindowListener(d,e){d.removeEventListener("message",e)}}function T(o){return typeof o=="object"&&o!==null&&"key"in o&&"method"in o&&typeof o.key=="string"&&typeof o.method=="string"}var k=(o=>(o.PROVIDER_RPC_REQUEST="PROVIDER_RPC_REQUEST",o.PROVIDER_RPC_RESPONSE="PROVIDER_RPC_RESPONSE",o.PROVIDER_ON_EVENT="PROVIDER_ON_EVENT",o))(k||{});const R=new y("cowSwapIframeRpcProviderTransport");var S={exports:{}};(function(o){var d=Object.prototype.hasOwnProperty,e="~";function t(){}Object.create&&(t.prototype=Object.create(null),new t().__proto__||(e=!1));function a(c,n,r){this.fn=c,this.context=n,this.once=r||!1}function h(c,n,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+n:n;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,n){--c._eventsCount===0?c._events=new t:delete c._events[n]}function u(){this._events=new t,this._eventsCount=0}u.prototype.eventNames=function(){var n=[],r,i;if(this._eventsCount===0)return n;for(i in r=this._events)d.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 w=0,m=i.length,l=new Array(m);w<m;w++)l[w]=i[w].fn;return l},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,w,m,l){var E=e?e+n:n;if(!this._events[E])return!1;var s=this._events[E],b=arguments.length,A,p;if(s.fn){switch(s.once&&this.removeListener(n,s.fn,void 0,!0),b){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,w),!0;case 5:return s.fn.call(s.context,r,i,w,m),!0;case 6:return s.fn.call(s.context,r,i,w,m,l),!0}for(p=1,A=new Array(b-1);p<b;p++)A[p-1]=arguments[p];s.fn.apply(s.context,A)}else{var z=s.length,C;for(p=0;p<z;p++)switch(s[p].once&&this.removeListener(n,s[p].fn,void 0,!0),b){case 1:s[p].fn.call(s[p].context);break;case 2:s[p].fn.call(s[p].context,r);break;case 3:s[p].fn.call(s[p].context,r,i);break;case 4:s[p].fn.call(s[p].context,r,i,w);break;default:if(!A)for(C=1,A=new Array(b-1);C<b;C++)A[C-1]=arguments[C];s[p].fn.apply(s[p].context,A)}}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,w){var m=e?e+n:n;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 E=0,s=[],b=l.length;E<b;E++)(l[E].fn!==r||w&&!l[E].once||i&&l[E].context!==i)&&s.push(l[E]);s.length?this._events[m]=s.length===1?s[0]:s:g(this,m)}return this},u.prototype.removeAllListeners=function(n){var r;return n?(r=e?e+n:n,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})(S);var U=S.exports;const F=6e5,G="2.0";function q(){return Math.floor(Math.random()*Number.MAX_SAFE_INTEGER)}class B extends Error{constructor(e,t){super(`${e}: ${t}`);v(this,"isRpcError",!0);v(this,"code");v(this,"reason");this.code=e,this.reason=t}}class Y extends U.EventEmitter{constructor({timeoutMilliseconds:e=F,eventSource:t=window,eventTarget:a=window.parent}={}){super();v(this,"enabled",null);v(this,"timeoutMilliseconds");v(this,"eventSource");v(this,"eventTarget");v(this,"completers",{});v(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,k.PROVIDER_RPC_RESPONSE,h=>{this.handleRpcRequests(h)}),R.listenToMessageFromWindow(this.eventSource,k.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=q(),h={jsonrpc:G,id:a,method:e,params:t},g=new Promise((u,c)=>this.completers[a]={resolve:u,reject:c});return R.postMessageToWindow(this.eventTarget,k.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 B(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 _=(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))(_||{});const O=new y("cowSwapHookDapp");function j({onContext:o}){const d=window.parent,e=new Y,t=X();return O.listenToMessageFromWindow(window,_.CONTEXT_UPDATE,o),O.postMessageToWindow(d,_.ACTIVATE,void 0),{actions:t,provider:e}}function X(){return{addHook(o){O.postMessageToWindow(parent,_.ADD_HOOK,o)},editHook(o){O.postMessageToWindow(parent,_.EDIT_HOOK,o)},setSellToken(o){O.postMessageToWindow(parent,_.SET_SELL_TOKEN,o)},setBuyToken(o){O.postMessageToWindow(parent,_.SET_BUY_TOKEN,o)}}}var I=(o=>(o.INTERNAL="INTERNAL",o.IFRAME="IFRAME",o))(I||{}),N=(o=>(o.EOA="EOA",o.SMART_CONTRACT="SMART_CONTRACT",o))(N||{});const $=64,L={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"},M={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]}},D={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:"5dc71fa5829d976c462bdf37b38b6fd9bbc289252a5a18e61525f8c8a3c775df",name:"CoW AMM Withdraw Liquidity",type:"IFRAME",descriptionShort:"Remove liquidity from a CoW AMM pool before the swap",description:"Reduce or withdraw liquidity from a pool before a token swap integrating the process directly into the transaction flow. By adjusting your liquidity ahead of time, you gain more control over your assets without any extra steps. Optimize your position in a pool, all in one seamless action — no need for multiple transactions or added complexity.",version:"0.0.1",website:"https://balancer.fi/pools/cow",image:"https://cow-hooks-dapps-withdraw-pool.vercel.app/icon.png",url:"https://cow-hooks-dapps-withdraw-pool.vercel.app/",conditions:{position:"pre",walletCompatibility:["EOA"],smartContractWalletSupported:!1}},H={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],walletCompatibility:["EOA"],smartContractWalletSupported:!1}},V={id:"a316488cecc23fde8c39d3e748e0cb12bd4d18305826d36576d4bba74bd97baf",type:"IFRAME",name:"Create LlamaPay Vesting",descriptionShort:"Create a LlamaPay vesting contract",description:"This hook allows you to easily set up vesting contracts with LlamaPay. Enter the recipient’s address or ENS name, then choose how much to transfer: the token buy will be automatically detected by the hook and the contracts will be linked to your LlamaPay dashboard for seamless tracking.",version:"0.1.0",website:"https://llamapay.io/vesting",image:"https://cow-hooks-dapps-create-vesting.vercel.app/llama-pay-icon.png",url:"https://cow-hooks-dapps-create-vesting.vercel.app",conditions:{position:"post",walletCompatibility:["EOA"],smartContractWalletSupported:!1,supportedNetworks:[1,100,42161]}},x=Object.freeze(Object.defineProperty({__proto__:null,BUILD_CUSTOM_HOOK:L,CLAIM_COW_AIRDROP:D,CLAIM_GNO_FROM_VALIDATORS:M,CLAIM_LLAMAPAY_VESTING:H,COW_AMM_WITHDRAW:W,CREATE_LLAMAPAY_VESTING:V,PERMIT_TOKEN:P,default:{BUILD_CUSTOM_HOOK:L,CLAIM_GNO_FROM_VALIDATORS:M,PERMIT_TOKEN:P,CLAIM_COW_AIRDROP:D,COW_AMM_WITHDRAW:W,CLAIM_LLAMAPAY_VESTING:H,CREATE_LLAMAPAY_VESTING:V}},Symbol.toStringTag,{value:"Module"}));function K(o,d){const e=d.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 Q(o,d=[]){return K(o,Object.values(x).concat(d))}return f.CoWHookDappEvents=_,f.HOOK_DAPP_ID_LENGTH=$,f.HookDappType=I,f.HookDappWalletCompatibility=N,f.hookDappIframeTransport=O,f.hookDappsRegistry=x,f.initCoWHookDapp=j,f.matchHooksToDapps=K,f.matchHooksToDappsRegistry=Q,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"}),f}({});
1
+ var cowSwapWidget=function(f){"use strict";var ae=Object.defineProperty;var ce=(f,E,k)=>E in f?ae(f,E,{enumerable:!0,configurable:!0,writable:!0,value:k}):f[E]=k;var y=(f,E,k)=>ce(f,typeof E!="symbol"?E+"":E,k);class E{constructor(p){this.key=p}postMessageToWindow(p,e,o){const a=typeof o=="object"?o:{},l={key:this.key,method:e,...a};p.postMessage(l,"*")}listenToMessageFromWindow(p,e,o){const a=l=>{!k(l.data)||l.data.key!==this.key||l.data.method!==e||o(l.data)};return p.addEventListener("message",a),a}stopListeningToMessageFromWindow(p,e,o){p.removeEventListener("message",o)}stopListeningWindowListener(p,e){p.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 I=(t=>(t.PROVIDER_RPC_REQUEST="PROVIDER_RPC_REQUEST",t.PROVIDER_RPC_RESPONSE="PROVIDER_RPC_RESPONSE",t.PROVIDER_ON_EVENT="PROVIDER_ON_EVENT",t.SEND_PROVIDER_META_INFO="SEND_PROVIDER_META_INFO",t.REQUEST_PROVIDER_META_INFO="REQUEST_PROVIDER_META_INFO",t))(I||{});const b=new E("cowSwapIframeRpcProviderTransport"),B=[];window.addEventListener("eip6963:announceProvider",t=>{const p=t;B.push(p.detail)});var M={exports:{}};(function(t){var p=Object.prototype.hasOwnProperty,e="~";function o(){}Object.create&&(o.prototype=Object.create(null),new o().__proto__||(e=!1));function a(c,i,n){this.fn=c,this.context=i,this.once=n||!1}function l(c,i,n,r,w){if(typeof n!="function")throw new TypeError("The listener must be a function");var m=new a(n,r||c,w),d=e?e+i:i;return c._events[d]?c._events[d].fn?c._events[d]=[c._events[d],m]:c._events[d].push(m):(c._events[d]=m,c._eventsCount++),c}function g(c,i){--c._eventsCount===0?c._events=new o:delete c._events[i]}function u(){this._events=new o,this._eventsCount=0}u.prototype.eventNames=function(){var i=[],n,r;if(this._eventsCount===0)return i;for(r in n=this._events)p.call(n,r)&&i.push(e?r.slice(1):r);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(n)):i},u.prototype.listeners=function(i){var n=e?e+i:i,r=this._events[n];if(!r)return[];if(r.fn)return[r.fn];for(var w=0,m=r.length,d=new Array(m);w<m;w++)d[w]=r[w].fn;return d},u.prototype.listenerCount=function(i){var n=e?e+i:i,r=this._events[n];return r?r.fn?1:r.length:0},u.prototype.emit=function(i,n,r,w,m,d){var v=e?e+i:i;if(!this._events[v])return!1;var s=this._events[v],T=arguments.length,A,h;if(s.fn){switch(s.once&&this.removeListener(i,s.fn,void 0,!0),T){case 1:return s.fn.call(s.context),!0;case 2:return s.fn.call(s.context,n),!0;case 3:return s.fn.call(s.context,n,r),!0;case 4:return s.fn.call(s.context,n,r,w),!0;case 5:return s.fn.call(s.context,n,r,w,m),!0;case 6:return s.fn.call(s.context,n,r,w,m,d),!0}for(h=1,A=new Array(T-1);h<T;h++)A[h-1]=arguments[h];s.fn.apply(s.context,A)}else{var re=s.length,C;for(h=0;h<re;h++)switch(s[h].once&&this.removeListener(i,s[h].fn,void 0,!0),T){case 1:s[h].fn.call(s[h].context);break;case 2:s[h].fn.call(s[h].context,n);break;case 3:s[h].fn.call(s[h].context,n,r);break;case 4:s[h].fn.call(s[h].context,n,r,w);break;default:if(!A)for(C=1,A=new Array(T-1);C<T;C++)A[C-1]=arguments[C];s[h].fn.apply(s[h].context,A)}}return!0},u.prototype.on=function(i,n,r){return l(this,i,n,r,!1)},u.prototype.once=function(i,n,r){return l(this,i,n,r,!0)},u.prototype.removeListener=function(i,n,r,w){var m=e?e+i:i;if(!this._events[m])return this;if(!n)return g(this,m),this;var d=this._events[m];if(d.fn)d.fn===n&&(!w||d.once)&&(!r||d.context===r)&&g(this,m);else{for(var v=0,s=[],T=d.length;v<T;v++)(d[v].fn!==n||w&&!d[v].once||r&&d[v].context!==r)&&s.push(d[v]);s.length?this._events[m]=s.length===1?s[0]:s:g(this,m)}return this},u.prototype.removeAllListeners=function(i){var n;return i?(n=e?e+i:i,this._events[n]&&g(this,n)):(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})(M);var Y=M.exports;const j=6e5,z="2.0";function Q(){return Math.floor(Math.random()*Number.MAX_SAFE_INTEGER)}class X extends Error{constructor(e,o){super(`${e}: ${o}`);y(this,"isRpcError",!0);y(this,"code");y(this,"reason");this.code=e,this.reason=o}}class $ extends Y.EventEmitter{constructor({timeoutMilliseconds:e=j,eventSource:o=window,eventTarget:a=window.parent}={}){super();y(this,"enabled",null);y(this,"timeoutMilliseconds");y(this,"eventSource");y(this,"eventTarget");y(this,"completers",{});y(this,"providerMetaInfo",null);y(this,"providerMetaInfoCallback");y(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=a,b.listenToMessageFromWindow(this.eventSource,I.PROVIDER_RPC_RESPONSE,l=>{this.handleRpcRequests(l)}),b.listenToMessageFromWindow(this.eventSource,I.PROVIDER_ON_EVENT,l=>{this.handleOnEvent(l)}),b.listenToMessageFromWindow(this.eventSource,I.SEND_PROVIDER_META_INFO,l=>{this.providerMetaInfo=l,this.providerMetaInfoCallback&&this.providerMetaInfoCallback(this.providerMetaInfo)})}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 a=Q(),l={jsonrpc:z,id:a,method:e,params:o},g=new Promise((u,c)=>this.completers[a]={resolve:u,reject:c});return b.postMessageToWindow(this.eventTarget,I.PROVIDER_RPC_REQUEST,{rpcRequest:l}),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,o){const{method:a,params:l}=typeof e=="string"?{method:e,params:o}:{method:e.method,params:e.params},g=await this.execute(a,l);if("error"in g)throw new X(g.error.code,g.error.message);return g.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 a=await this.execute(e.method,e.params);o(null,a)}catch(a){o(a,null)}}onProviderMetaInfo(e){this.providerMetaInfo?e(this.providerMetaInfo):(this.providerMetaInfoCallback=e,b.postMessageToWindow(this.eventTarget,I.REQUEST_PROVIDER_META_INFO,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.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))(_||{});const O=new E("cowSwapHookDapp");function J({onContext:t}){const p=window.parent,e=new $,o=Z();return O.listenToMessageFromWindow(window,_.CONTEXT_UPDATE,t),O.postMessageToWindow(p,_.ACTIVATE,void 0),{actions:o,provider:e}}function Z(){return{addHook(t){O.postMessageToWindow(parent,_.ADD_HOOK,t)},editHook(t){O.postMessageToWindow(parent,_.EDIT_HOOK,t)},setSellToken(t){O.postMessageToWindow(parent,_.SET_SELL_TOKEN,t)},setBuyToken(t){O.postMessageToWindow(parent,_.SET_BUY_TOKEN,t)}}}var S=(t=>(t.INTERNAL="INTERNAL",t.IFRAME="IFRAME",t))(S||{}),N=(t=>(t.EOA="EOA",t.SMART_CONTRACT="SMART_CONTRACT",t))(N||{});const ee=64,P={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"},D={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"}},R={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={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={name:"CoW AMM Withdraw Liquidity",type:"IFRAME",descriptionShort:"Remove liquidity from a CoW AMM pool before the swap",description:"Reduce or withdraw liquidity from a pool before a token swap integrating the process directly into the transaction flow. By adjusting your liquidity ahead of time, you gain more control over your assets without any extra steps. Optimize your position in a pool, all in one seamless action — no need for multiple transactions or added complexity.",version:"0.0.1",website:"https://balancer.fi/pools/cow",image:"https://cow-hooks-dapps-withdraw-pool.vercel.app/icon.png",url:"https://cow-hooks-dapps-withdraw-pool.vercel.app/",conditions:{position:"pre",walletCompatibility:["EOA"],smartContractWalletSupported:!1}},V={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],walletCompatibility:["EOA"],smartContractWalletSupported:!1}},U={type:"IFRAME",name:"Create LlamaPay Vesting",descriptionShort:"Create a LlamaPay vesting contract",description:"This hook allows you to easily set up vesting contracts with LlamaPay. Enter the recipient’s address or ENS name, then choose how much to transfer: the token buy will be automatically detected by the hook and the contracts will be linked to your LlamaPay dashboard for seamless tracking.",version:"0.1.0",website:"https://llamapay.io/vesting",image:"https://cow-hooks-dapps-create-vesting.vercel.app/llama-pay-icon.png",url:"https://cow-hooks-dapps-create-vesting.vercel.app",conditions:{position:"post",walletCompatibility:["EOA"],smartContractWalletSupported:!1,supportedNetworks:[1,100,42161]}},H={type:"IFRAME",name:"Withdraw Uniswap v2 Liquidity",descriptionShort:"Remove liquidity from a Uniswap v2 Weighted pool before the swap",description:"Reduce or withdraw Uniswap v2 from a pool before a token swap integrating the process directly into the transaction flow. By adjusting your liquidity ahead of time, you gain more control over your assets without any extra steps. Optimize your position in a pool, all in one seamless action — no need for multiple transactions or added complexity.",version:"0.0.1",website:"https://app.uniswap.org/pools/v2",image:"https://cow-hooks-dapps-withdraw-uniswap-v2.vercel.app/icon.png",url:"https://cow-hooks-dapps-withdraw-uniswap-v2.vercel.app/",conditions:{position:"pre",walletCompatibility:["EOA"],smartContractWalletSupported:!1,supportedNetworks:[1,42161,11155111,8453]}},x={name:"CoW AMM Deposit",type:"IFRAME",descriptionShort:"Add liquidity to any of the CoW AMM pools",description:`Easily increase your position in a liquidity pool, adding both tokens in the right ratio.
2
+
3
+ Whether you're seeking to increase your exposure to specific tokens or maximize the returns from your assets, this tool offers a quick and efficient way to enhance your liquidity position after a token swap, all in a smooth, efficient process.`,version:"0.0.1",website:"https://balancer.fi/pools/cow",image:"https://cow-hooks-dapps-cow-amm-deposit.vercel.app/icon.png",url:"https://cow-hooks-dapps-cow-amm-deposit.vercel.app/",conditions:{position:"post",walletCompatibility:["EOA"],smartContractWalletSupported:!1}},F={name:"Uniswap v2 Deposit",type:"IFRAME",descriptionShort:"Add liquidity to a Uniswap v2 pool after the swap",description:`Easily increase your position in a liquidity pool, adding both tokens in the right ratio.
4
+
5
+ Whether you're seeking to increase your exposure to specific tokens or maximize the returns from your assets, this tool offers a quick and efficient way to enhance your liquidity position after a token swap, all in a smooth, efficient process.`,version:"0.0.1",website:"https://app.uniswap.org/pools/v2",image:"https://cow-hooks-dapps-9zio.vercel.app/icon.png",url:"https://cow-hooks-dapps-9zio.vercel.app/",conditions:{position:"post",walletCompatibility:["EOA"],supportedNetworks:[1,42161,11155111,8453]}},q={BUILD_CUSTOM_HOOK:P,CLAIM_GNO_FROM_VALIDATORS:D,PERMIT_TOKEN:R,CLAIM_COW_AIRDROP:L,COW_AMM_WITHDRAW:W,CLAIM_LLAMAPAY_VESTING:V,CREATE_LLAMAPAY_VESTING:U,UNI_V2_WITHDRAW:H,COW_AMM_DEPOSIT:x,UNI_V2_DEPOSIT:F},K=Object.freeze(Object.defineProperty({__proto__:null,BUILD_CUSTOM_HOOK:P,CLAIM_COW_AIRDROP:L,CLAIM_GNO_FROM_VALIDATORS:D,CLAIM_LLAMAPAY_VESTING:V,COW_AMM_DEPOSIT:x,COW_AMM_WITHDRAW:W,CREATE_LLAMAPAY_VESTING:U,PERMIT_TOKEN:R,UNI_V2_DEPOSIT:F,UNI_V2_WITHDRAW:H,default:q},Symbol.toStringTag,{value:"Module"})),te=Object.keys(K).reduce((t,p)=>{const e=K[p];return t.push({id:p,...e}),t},[]),oe="0xd505accf",se="0x8fcbaf0c",ie="1db4bacb661a90fb6b475fd5b585acba9745bc373573c65ecc3e8f5bfd5dee1f";function G(t,p){const e=p.reduce((o,a)=>(o[a.id]=a,o),{});return t.filter(o=>!!o.dappId).map(o=>{const a=o,l=e[a.dappId];return(!l||a.dappId===ie)&&(a.callData.startsWith(oe)||a.callData.startsWith(se))?{hook:a,dapp:R}:{hook:a,dapp:l||null}})}function ne(t,p=[]){return G(t,te.concat(p))}return f.CoWHookDappEvents=_,f.HOOK_DAPP_ID_LENGTH=ee,f.HookDappType=S,f.HookDappWalletCompatibility=N,f.hookDappIframeTransport=O,f.hookDappsRegistry=q,f.initCoWHookDapp=J,f.matchHooksToDapps=G,f.matchHooksToDappsRegistry=ne,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"}),f}({});
package/index.js CHANGED
@@ -1 +1,5 @@
1
- "use strict";var K=Object.defineProperty;var U=(t,a,e)=>a in t?K(t,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[a]=e;var g=(t,a,e)=>(U(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=>{!F(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 F(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 A=new C("cowSwapIframeRpcProviderTransport");var k={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 y=e?e+n:n;if(!this._events[y])return!1;var s=this._events[y],v=arguments.length,_,d;if(s.fn){switch(s.once&&this.removeListener(n,s.fn,void 0,!0),v){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,_=new Array(v-1);d<v;d++)_[d-1]=arguments[d];s.fn.apply(s.context,_)}else{var V=s.length,T;for(d=0;d<V;d++)switch(s[d].once&&this.removeListener(n,s[d].fn,void 0,!0),v){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(!_)for(T=1,_=new Array(v-1);T<v;T++)_[T-1]=arguments[T];s[d].fn.apply(s[d].context,_)}}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 y=0,s=[],v=p.length;y<v;y++)(p[y].fn!==r||m&&!p[y].once||i&&p[y].context!==i)&&s.push(p[y]);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})(k);var G=k.exports;const q=6e5,B="2.0";function Y(){return Math.floor(Math.random()*Number.MAX_SAFE_INTEGER)}class j 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 X extends G.EventEmitter{constructor({timeoutMilliseconds:e=q,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,A.listenToMessageFromWindow(this.eventSource,O.PROVIDER_RPC_RESPONSE,h=>{this.handleRpcRequests(h)}),A.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=Y(),h={jsonrpc:B,id:c,method:e,params:o},w=new Promise((u,l)=>this.completers[c]={resolve:u,reject:l});return A.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 j(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 E=(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))(E||{});const b=new C("cowSwapHookDapp");function $({onContext:t}){const a=window.parent,e=new X,o=Q();return b.listenToMessageFromWindow(window,E.CONTEXT_UPDATE,t),b.postMessageToWindow(a,E.ACTIVATE,void 0),{actions:o,provider:e}}function Q(){return{addHook(t){b.postMessageToWindow(parent,E.ADD_HOOK,t)},editHook(t){b.postMessageToWindow(parent,E.EDIT_HOOK,t)},setSellToken(t){b.postMessageToWindow(parent,E.SET_SELL_TOKEN,t)},setBuyToken(t){b.postMessageToWindow(parent,E.SET_BUY_TOKEN,t)}}}var R=(t=>(t.INTERNAL="INTERNAL",t.IFRAME="IFRAME",t))(R||{}),S=(t=>(t.EOA="EOA",t.SMART_CONTRACT="SMART_CONTRACT",t))(S||{});const z=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"},N={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]}},P={id:"5dc71fa5829d976c462bdf37b38b6fd9bbc289252a5a18e61525f8c8a3c775df",name:"CoW AMM Withdraw Liquidity",type:"IFRAME",descriptionShort:"Remove liquidity from a CoW AMM pool before the swap",description:"Reduce or withdraw liquidity from a pool before a token swap integrating the process directly into the transaction flow. By adjusting your liquidity ahead of time, you gain more control over your assets without any extra steps. Optimize your position in a pool, all in one seamless action — no need for multiple transactions or added complexity.",version:"0.0.1",website:"https://balancer.fi/pools/cow",image:"https://cow-hooks-dapps-withdraw-pool.vercel.app/icon.png",url:"https://cow-hooks-dapps-withdraw-pool.vercel.app/",conditions:{position:"pre",walletCompatibility:["EOA"],smartContractWalletSupported:!1}},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],walletCompatibility:["EOA"],smartContractWalletSupported:!1}},W={id:"a316488cecc23fde8c39d3e748e0cb12bd4d18305826d36576d4bba74bd97baf",type:"IFRAME",name:"Create LlamaPay Vesting",descriptionShort:"Create a LlamaPay vesting contract",description:"This hook allows you to easily set up vesting contracts with LlamaPay. Enter the recipient’s address or ENS name, then choose how much to transfer: the token buy will be automatically detected by the hook and the contracts will be linked to your LlamaPay dashboard for seamless tracking.",version:"0.1.0",website:"https://llamapay.io/vesting",image:"https://cow-hooks-dapps-create-vesting.vercel.app/llama-pay-icon.png",url:"https://cow-hooks-dapps-create-vesting.vercel.app",conditions:{position:"post",walletCompatibility:["EOA"],smartContractWalletSupported:!1,supportedNetworks:[1,100,42161]}},J={BUILD_CUSTOM_HOOK:I,CLAIM_GNO_FROM_VALIDATORS:N,PERMIT_TOKEN:L,CLAIM_COW_AIRDROP:M,COW_AMM_WITHDRAW:P,CLAIM_LLAMAPAY_VESTING:D,CREATE_LLAMAPAY_VESTING:W},x=Object.freeze(Object.defineProperty({__proto__:null,BUILD_CUSTOM_HOOK:I,CLAIM_COW_AIRDROP:M,CLAIM_GNO_FROM_VALIDATORS:N,CLAIM_LLAMAPAY_VESTING:D,COW_AMM_WITHDRAW:P,CREATE_LLAMAPAY_VESTING:W,PERMIT_TOKEN:L,default:J},Symbol.toStringTag,{value:"Module"}));function H(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 H(t,Object.values(x).concat(a))}exports.CoWHookDappEvents=E;exports.HOOK_DAPP_ID_LENGTH=z;exports.HookDappType=R;exports.HookDappWalletCompatibility=S;exports.hookDappIframeTransport=b;exports.hookDappsRegistry=x;exports.initCoWHookDapp=$;exports.matchHooksToDapps=H;exports.matchHooksToDappsRegistry=Z;
1
+ "use strict";var G=Object.defineProperty;var B=(t,r,e)=>r in t?G(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e;var w=(t,r,e)=>B(t,typeof r!="symbol"?r+"":r,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class C{constructor(r){this.key=r}postMessageToWindow(r,e,o){const c=typeof o=="object"?o:{},l={key:this.key,method:e,...c};r.postMessage(l,"*")}listenToMessageFromWindow(r,e,o){const c=l=>{!Y(l.data)||l.data.key!==this.key||l.data.method!==e||o(l.data)};return r.addEventListener("message",c),c}stopListeningToMessageFromWindow(r,e,o){r.removeEventListener("message",o)}stopListeningWindowListener(r,e){r.removeEventListener("message",e)}}function Y(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.SEND_PROVIDER_META_INFO="SEND_PROVIDER_META_INFO",t.REQUEST_PROVIDER_META_INFO="REQUEST_PROVIDER_META_INFO",t))(O||{});const k=new C("cowSwapIframeRpcProviderTransport"),j=[];window.addEventListener("eip6963:announceProvider",t=>{const r=t;j.push(r.detail)});var R={exports:{}};(function(t){var r=Object.prototype.hasOwnProperty,e="~";function o(){}Object.create&&(o.prototype=Object.create(null),new o().__proto__||(e=!1));function c(p,i,n){this.fn=p,this.context=i,this.once=n||!1}function l(p,i,n,a,m){if(typeof n!="function")throw new TypeError("The listener must be a function");var f=new c(n,a||p,m),d=e?e+i:i;return p._events[d]?p._events[d].fn?p._events[d]=[p._events[d],f]:p._events[d].push(f):(p._events[d]=f,p._eventsCount++),p}function y(p,i){--p._eventsCount===0?p._events=new o:delete p._events[i]}function u(){this._events=new o,this._eventsCount=0}u.prototype.eventNames=function(){var i=[],n,a;if(this._eventsCount===0)return i;for(a in n=this._events)r.call(n,a)&&i.push(e?a.slice(1):a);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(n)):i},u.prototype.listeners=function(i){var n=e?e+i:i,a=this._events[n];if(!a)return[];if(a.fn)return[a.fn];for(var m=0,f=a.length,d=new Array(f);m<f;m++)d[m]=a[m].fn;return d},u.prototype.listenerCount=function(i){var n=e?e+i:i,a=this._events[n];return a?a.fn?1:a.length:0},u.prototype.emit=function(i,n,a,m,f,d){var g=e?e+i:i;if(!this._events[g])return!1;var s=this._events[g],E=arguments.length,_,h;if(s.fn){switch(s.once&&this.removeListener(i,s.fn,void 0,!0),E){case 1:return s.fn.call(s.context),!0;case 2:return s.fn.call(s.context,n),!0;case 3:return s.fn.call(s.context,n,a),!0;case 4:return s.fn.call(s.context,n,a,m),!0;case 5:return s.fn.call(s.context,n,a,m,f),!0;case 6:return s.fn.call(s.context,n,a,m,f,d),!0}for(h=1,_=new Array(E-1);h<E;h++)_[h-1]=arguments[h];s.fn.apply(s.context,_)}else{var K=s.length,A;for(h=0;h<K;h++)switch(s[h].once&&this.removeListener(i,s[h].fn,void 0,!0),E){case 1:s[h].fn.call(s[h].context);break;case 2:s[h].fn.call(s[h].context,n);break;case 3:s[h].fn.call(s[h].context,n,a);break;case 4:s[h].fn.call(s[h].context,n,a,m);break;default:if(!_)for(A=1,_=new Array(E-1);A<E;A++)_[A-1]=arguments[A];s[h].fn.apply(s[h].context,_)}}return!0},u.prototype.on=function(i,n,a){return l(this,i,n,a,!1)},u.prototype.once=function(i,n,a){return l(this,i,n,a,!0)},u.prototype.removeListener=function(i,n,a,m){var f=e?e+i:i;if(!this._events[f])return this;if(!n)return y(this,f),this;var d=this._events[f];if(d.fn)d.fn===n&&(!m||d.once)&&(!a||d.context===a)&&y(this,f);else{for(var g=0,s=[],E=d.length;g<E;g++)(d[g].fn!==n||m&&!d[g].once||a&&d[g].context!==a)&&s.push(d[g]);s.length?this._events[f]=s.length===1?s[0]:s:y(this,f)}return this},u.prototype.removeAllListeners=function(i){var n;return i?(n=e?e+i:i,this._events[n]&&y(this,n)):(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 z=R.exports;const Q=6e5,X="2.0";function $(){return Math.floor(Math.random()*Number.MAX_SAFE_INTEGER)}class J extends Error{constructor(e,o){super(`${e}: ${o}`);w(this,"isRpcError",!0);w(this,"code");w(this,"reason");this.code=e,this.reason=o}}class Z extends z.EventEmitter{constructor({timeoutMilliseconds:e=Q,eventSource:o=window,eventTarget:c=window.parent}={}){super();w(this,"enabled",null);w(this,"timeoutMilliseconds");w(this,"eventSource");w(this,"eventTarget");w(this,"completers",{});w(this,"providerMetaInfo",null);w(this,"providerMetaInfoCallback");w(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,l=>{this.handleRpcRequests(l)}),k.listenToMessageFromWindow(this.eventSource,O.PROVIDER_ON_EVENT,l=>{this.handleOnEvent(l)}),k.listenToMessageFromWindow(this.eventSource,O.SEND_PROVIDER_META_INFO,l=>{this.providerMetaInfo=l,this.providerMetaInfoCallback&&this.providerMetaInfoCallback(this.providerMetaInfo)})}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=$(),l={jsonrpc:X,id:c,method:e,params:o},y=new Promise((u,p)=>this.completers[c]={resolve:u,reject:p});return k.postMessageToWindow(this.eventTarget,O.PROVIDER_RPC_REQUEST,{rpcRequest:l}),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),y}async send(e,o){const{method:c,params:l}=typeof e=="string"?{method:e,params:o}:{method:e.method,params:e.params},y=await this.execute(c,l);if("error"in y)throw new J(y.error.code,y.error.message);return y.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)}}onProviderMetaInfo(e){this.providerMetaInfo?e(this.providerMetaInfo):(this.providerMetaInfoCallback=e,k.postMessageToWindow(this.eventTarget,O.REQUEST_PROVIDER_META_INFO,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 T=new C("cowSwapHookDapp");function ee({onContext:t}){const r=window.parent,e=new Z,o=te();return T.listenToMessageFromWindow(window,v.CONTEXT_UPDATE,t),T.postMessageToWindow(r,v.ACTIVATE,void 0),{actions:o,provider:e}}function te(){return{addHook(t){T.postMessageToWindow(parent,v.ADD_HOOK,t)},editHook(t){T.postMessageToWindow(parent,v.EDIT_HOOK,t)},setSellToken(t){T.postMessageToWindow(parent,v.SET_SELL_TOKEN,t)},setBuyToken(t){T.postMessageToWindow(parent,v.SET_BUY_TOKEN,t)}}}var M=(t=>(t.INTERNAL="INTERNAL",t.IFRAME="IFRAME",t))(M||{}),S=(t=>(t.EOA="EOA",t.SMART_CONTRACT="SMART_CONTRACT",t))(S||{});const oe=64,N={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={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"}},I={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]}},D={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]}},L={name:"CoW AMM Withdraw Liquidity",type:"IFRAME",descriptionShort:"Remove liquidity from a CoW AMM pool before the swap",description:"Reduce or withdraw liquidity from a pool before a token swap integrating the process directly into the transaction flow. By adjusting your liquidity ahead of time, you gain more control over your assets without any extra steps. Optimize your position in a pool, all in one seamless action — no need for multiple transactions or added complexity.",version:"0.0.1",website:"https://balancer.fi/pools/cow",image:"https://cow-hooks-dapps-withdraw-pool.vercel.app/icon.png",url:"https://cow-hooks-dapps-withdraw-pool.vercel.app/",conditions:{position:"pre",walletCompatibility:["EOA"],smartContractWalletSupported:!1}},W={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],walletCompatibility:["EOA"],smartContractWalletSupported:!1}},x={type:"IFRAME",name:"Create LlamaPay Vesting",descriptionShort:"Create a LlamaPay vesting contract",description:"This hook allows you to easily set up vesting contracts with LlamaPay. Enter the recipient’s address or ENS name, then choose how much to transfer: the token buy will be automatically detected by the hook and the contracts will be linked to your LlamaPay dashboard for seamless tracking.",version:"0.1.0",website:"https://llamapay.io/vesting",image:"https://cow-hooks-dapps-create-vesting.vercel.app/llama-pay-icon.png",url:"https://cow-hooks-dapps-create-vesting.vercel.app",conditions:{position:"post",walletCompatibility:["EOA"],smartContractWalletSupported:!1,supportedNetworks:[1,100,42161]}},V={type:"IFRAME",name:"Withdraw Uniswap v2 Liquidity",descriptionShort:"Remove liquidity from a Uniswap v2 Weighted pool before the swap",description:"Reduce or withdraw Uniswap v2 from a pool before a token swap integrating the process directly into the transaction flow. By adjusting your liquidity ahead of time, you gain more control over your assets without any extra steps. Optimize your position in a pool, all in one seamless action — no need for multiple transactions or added complexity.",version:"0.0.1",website:"https://app.uniswap.org/pools/v2",image:"https://cow-hooks-dapps-withdraw-uniswap-v2.vercel.app/icon.png",url:"https://cow-hooks-dapps-withdraw-uniswap-v2.vercel.app/",conditions:{position:"pre",walletCompatibility:["EOA"],smartContractWalletSupported:!1,supportedNetworks:[1,42161,11155111,8453]}},U={name:"CoW AMM Deposit",type:"IFRAME",descriptionShort:"Add liquidity to any of the CoW AMM pools",description:`Easily increase your position in a liquidity pool, adding both tokens in the right ratio.
2
+
3
+ Whether you're seeking to increase your exposure to specific tokens or maximize the returns from your assets, this tool offers a quick and efficient way to enhance your liquidity position after a token swap, all in a smooth, efficient process.`,version:"0.0.1",website:"https://balancer.fi/pools/cow",image:"https://cow-hooks-dapps-cow-amm-deposit.vercel.app/icon.png",url:"https://cow-hooks-dapps-cow-amm-deposit.vercel.app/",conditions:{position:"post",walletCompatibility:["EOA"],smartContractWalletSupported:!1}},H={name:"Uniswap v2 Deposit",type:"IFRAME",descriptionShort:"Add liquidity to a Uniswap v2 pool after the swap",description:`Easily increase your position in a liquidity pool, adding both tokens in the right ratio.
4
+
5
+ Whether you're seeking to increase your exposure to specific tokens or maximize the returns from your assets, this tool offers a quick and efficient way to enhance your liquidity position after a token swap, all in a smooth, efficient process.`,version:"0.0.1",website:"https://app.uniswap.org/pools/v2",image:"https://cow-hooks-dapps-9zio.vercel.app/icon.png",url:"https://cow-hooks-dapps-9zio.vercel.app/",conditions:{position:"post",walletCompatibility:["EOA"],supportedNetworks:[1,42161,11155111,8453]}},F={BUILD_CUSTOM_HOOK:N,CLAIM_GNO_FROM_VALIDATORS:P,PERMIT_TOKEN:I,CLAIM_COW_AIRDROP:D,COW_AMM_WITHDRAW:L,CLAIM_LLAMAPAY_VESTING:W,CREATE_LLAMAPAY_VESTING:x,UNI_V2_WITHDRAW:V,COW_AMM_DEPOSIT:U,UNI_V2_DEPOSIT:H},b=Object.freeze(Object.defineProperty({__proto__:null,BUILD_CUSTOM_HOOK:N,CLAIM_COW_AIRDROP:D,CLAIM_GNO_FROM_VALIDATORS:P,CLAIM_LLAMAPAY_VESTING:W,COW_AMM_DEPOSIT:U,COW_AMM_WITHDRAW:L,CREATE_LLAMAPAY_VESTING:x,PERMIT_TOKEN:I,UNI_V2_DEPOSIT:H,UNI_V2_WITHDRAW:V,default:F},Symbol.toStringTag,{value:"Module"})),se=Object.keys(b).reduce((t,r)=>{const e=b[r];return t.push({id:r,...e}),t},[]),ie="0xd505accf",ne="0x8fcbaf0c",re="1db4bacb661a90fb6b475fd5b585acba9745bc373573c65ecc3e8f5bfd5dee1f";function q(t,r){const e=r.reduce((o,c)=>(o[c.id]=c,o),{});return t.filter(o=>!!o.dappId).map(o=>{const c=o,l=e[c.dappId];return(!l||c.dappId===re)&&(c.callData.startsWith(ie)||c.callData.startsWith(ne))?{hook:c,dapp:I}:{hook:c,dapp:l||null}})}function ae(t,r=[]){return q(t,se.concat(r))}exports.CoWHookDappEvents=v;exports.HOOK_DAPP_ID_LENGTH=oe;exports.HookDappType=M;exports.HookDappWalletCompatibility=S;exports.hookDappIframeTransport=T;exports.hookDappsRegistry=F;exports.initCoWHookDapp=ee;exports.matchHooksToDapps=q;exports.matchHooksToDappsRegistry=ae;
package/index.mjs CHANGED
@@ -1,199 +1,205 @@
1
- var W = Object.defineProperty;
2
- var x = (t, a, e) => a in t ? W(t, a, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[a] = e;
3
- var g = (t, a, e) => (x(t, typeof a != "symbol" ? a + "" : a, e), e);
1
+ var F = Object.defineProperty;
2
+ var q = (t, r, e) => r in t ? F(t, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[r] = e;
3
+ var w = (t, r, e) => q(t, typeof r != "symbol" ? r + "" : r, e);
4
4
  class C {
5
- constructor(a) {
6
- this.key = a;
5
+ constructor(r) {
6
+ this.key = r;
7
7
  }
8
- postMessageToWindow(a, e, o) {
9
- const c = typeof o == "object" ? o : {}, h = {
8
+ postMessageToWindow(r, e, o) {
9
+ const c = typeof o == "object" ? o : {}, l = {
10
10
  key: this.key,
11
11
  method: e,
12
12
  ...c
13
13
  };
14
- a.postMessage(
15
- h,
14
+ r.postMessage(
15
+ l,
16
16
  "*"
17
17
  // TODO: Change to CoW specific origin in production. https://github.com/cowprotocol/cowswap/issues/3828
18
18
  );
19
19
  }
20
- listenToMessageFromWindow(a, e, o) {
21
- const c = (h) => {
22
- !V(h.data) || h.data.key !== this.key || h.data.method !== e || o(h.data);
20
+ listenToMessageFromWindow(r, e, o) {
21
+ const c = (l) => {
22
+ !H(l.data) || l.data.key !== this.key || l.data.method !== e || o(l.data);
23
23
  };
24
- return a.addEventListener("message", c), c;
24
+ return r.addEventListener("message", c), c;
25
25
  }
26
- stopListeningToMessageFromWindow(a, e, o) {
27
- a.removeEventListener("message", o);
26
+ stopListeningToMessageFromWindow(r, e, o) {
27
+ r.removeEventListener("message", o);
28
28
  }
29
- stopListeningWindowListener(a, e) {
30
- a.removeEventListener("message", e);
29
+ stopListeningWindowListener(r, e) {
30
+ r.removeEventListener("message", e);
31
31
  }
32
32
  }
33
- function V(t) {
33
+ function H(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 A = /* @__PURE__ */ ((t) => (t.PROVIDER_RPC_REQUEST = "PROVIDER_RPC_REQUEST", t.PROVIDER_RPC_RESPONSE = "PROVIDER_RPC_RESPONSE", t.PROVIDER_ON_EVENT = "PROVIDER_ON_EVENT", t))(A || {});
37
- const O = new C(
36
+ var T = /* @__PURE__ */ ((t) => (t.PROVIDER_RPC_REQUEST = "PROVIDER_RPC_REQUEST", t.PROVIDER_RPC_RESPONSE = "PROVIDER_RPC_RESPONSE", t.PROVIDER_ON_EVENT = "PROVIDER_ON_EVENT", t.SEND_PROVIDER_META_INFO = "SEND_PROVIDER_META_INFO", t.REQUEST_PROVIDER_META_INFO = "REQUEST_PROVIDER_META_INFO", t))(T || {});
37
+ const k = new C(
38
38
  "cowSwapIframeRpcProviderTransport"
39
- );
40
- var k = { exports: {} };
39
+ ), K = [];
40
+ window.addEventListener("eip6963:announceProvider", (t) => {
41
+ const r = t;
42
+ K.push(r.detail);
43
+ });
44
+ var R = { exports: {} };
41
45
  (function(t) {
42
- var a = Object.prototype.hasOwnProperty, e = "~";
46
+ var r = Object.prototype.hasOwnProperty, e = "~";
43
47
  function o() {
44
48
  }
45
49
  Object.create && (o.prototype = /* @__PURE__ */ Object.create(null), new o().__proto__ || (e = !1));
46
- function c(l, n, r) {
47
- this.fn = l, this.context = n, this.once = r || !1;
50
+ function c(p, i, n) {
51
+ this.fn = p, this.context = i, this.once = n || !1;
48
52
  }
49
- function h(l, n, r, i, m) {
50
- if (typeof r != "function")
53
+ function l(p, i, n, a, m) {
54
+ if (typeof n != "function")
51
55
  throw new TypeError("The listener must be a function");
52
- var f = new c(r, i || l, m), d = e ? e + n : n;
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;
56
+ var f = new c(n, a || p, m), d = e ? e + i : i;
57
+ return p._events[d] ? p._events[d].fn ? p._events[d] = [p._events[d], f] : p._events[d].push(f) : (p._events[d] = f, p._eventsCount++), p;
54
58
  }
55
- function w(l, n) {
56
- --l._eventsCount === 0 ? l._events = new o() : delete l._events[n];
59
+ function y(p, i) {
60
+ --p._eventsCount === 0 ? p._events = new o() : delete p._events[i];
57
61
  }
58
62
  function u() {
59
63
  this._events = new o(), this._eventsCount = 0;
60
64
  }
61
65
  u.prototype.eventNames = function() {
62
- var n = [], r, i;
63
- if (this._eventsCount === 0)
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
- if (!i)
71
- return [];
72
- if (i.fn)
73
- return [i.fn];
74
- for (var m = 0, f = i.length, d = new Array(f); m < f; m++)
75
- d[m] = i[m].fn;
66
+ var i = [], n, a;
67
+ if (this._eventsCount === 0) return i;
68
+ for (a in n = this._events)
69
+ r.call(n, a) && i.push(e ? a.slice(1) : a);
70
+ return Object.getOwnPropertySymbols ? i.concat(Object.getOwnPropertySymbols(n)) : i;
71
+ }, u.prototype.listeners = function(i) {
72
+ var n = e ? e + i : i, a = this._events[n];
73
+ if (!a) return [];
74
+ if (a.fn) return [a.fn];
75
+ for (var m = 0, f = a.length, d = new Array(f); m < f; m++)
76
+ d[m] = a[m].fn;
76
77
  return d;
77
- }, u.prototype.listenerCount = function(n) {
78
- var r = e ? e + n : n, i = this._events[r];
79
- return i ? i.fn ? 1 : i.length : 0;
80
- }, u.prototype.emit = function(n, r, i, m, f, d) {
81
- var y = e ? e + n : n;
82
- if (!this._events[y])
83
- return !1;
84
- var s = this._events[y], v = arguments.length, E, p;
78
+ }, u.prototype.listenerCount = function(i) {
79
+ var n = e ? e + i : i, a = this._events[n];
80
+ return a ? a.fn ? 1 : a.length : 0;
81
+ }, u.prototype.emit = function(i, n, a, m, f, d) {
82
+ var g = e ? e + i : i;
83
+ if (!this._events[g]) return !1;
84
+ var s = this._events[g], E = arguments.length, v, h;
85
85
  if (s.fn) {
86
- switch (s.once && this.removeListener(n, s.fn, void 0, !0), v) {
86
+ switch (s.once && this.removeListener(i, s.fn, void 0, !0), E) {
87
87
  case 1:
88
88
  return s.fn.call(s.context), !0;
89
89
  case 2:
90
- return s.fn.call(s.context, r), !0;
90
+ return s.fn.call(s.context, n), !0;
91
91
  case 3:
92
- return s.fn.call(s.context, r, i), !0;
92
+ return s.fn.call(s.context, n, a), !0;
93
93
  case 4:
94
- return s.fn.call(s.context, r, i, m), !0;
94
+ return s.fn.call(s.context, n, a, m), !0;
95
95
  case 5:
96
- return s.fn.call(s.context, r, i, m, f), !0;
96
+ return s.fn.call(s.context, n, a, m, f), !0;
97
97
  case 6:
98
- return s.fn.call(s.context, r, i, m, f, d), !0;
98
+ return s.fn.call(s.context, n, a, m, f, d), !0;
99
99
  }
100
- for (p = 1, E = new Array(v - 1); p < v; p++)
101
- E[p - 1] = arguments[p];
102
- s.fn.apply(s.context, E);
100
+ for (h = 1, v = new Array(E - 1); h < E; h++)
101
+ v[h - 1] = arguments[h];
102
+ s.fn.apply(s.context, v);
103
103
  } else {
104
- var D = s.length, T;
105
- for (p = 0; p < D; p++)
106
- switch (s[p].once && this.removeListener(n, s[p].fn, void 0, !0), v) {
104
+ var U = s.length, A;
105
+ for (h = 0; h < U; h++)
106
+ switch (s[h].once && this.removeListener(i, s[h].fn, void 0, !0), E) {
107
107
  case 1:
108
- s[p].fn.call(s[p].context);
108
+ s[h].fn.call(s[h].context);
109
109
  break;
110
110
  case 2:
111
- s[p].fn.call(s[p].context, r);
111
+ s[h].fn.call(s[h].context, n);
112
112
  break;
113
113
  case 3:
114
- s[p].fn.call(s[p].context, r, i);
114
+ s[h].fn.call(s[h].context, n, a);
115
115
  break;
116
116
  case 4:
117
- s[p].fn.call(s[p].context, r, i, m);
117
+ s[h].fn.call(s[h].context, n, a, m);
118
118
  break;
119
119
  default:
120
- if (!E)
121
- for (T = 1, E = new Array(v - 1); T < v; T++)
122
- E[T - 1] = arguments[T];
123
- s[p].fn.apply(s[p].context, E);
120
+ if (!v) for (A = 1, v = new Array(E - 1); A < E; A++)
121
+ v[A - 1] = arguments[A];
122
+ s[h].fn.apply(s[h].context, v);
124
123
  }
125
124
  }
126
125
  return !0;
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
- if (!this._events[f])
134
- return this;
135
- if (!r)
136
- return w(this, f), this;
126
+ }, u.prototype.on = function(i, n, a) {
127
+ return l(this, i, n, a, !1);
128
+ }, u.prototype.once = function(i, n, a) {
129
+ return l(this, i, n, a, !0);
130
+ }, u.prototype.removeListener = function(i, n, a, m) {
131
+ var f = e ? e + i : i;
132
+ if (!this._events[f]) return this;
133
+ if (!n)
134
+ return y(this, f), this;
137
135
  var d = this._events[f];
138
136
  if (d.fn)
139
- d.fn === r && (!m || d.once) && (!i || d.context === i) && w(this, f);
137
+ d.fn === n && (!m || d.once) && (!a || d.context === a) && y(this, f);
140
138
  else {
141
- for (var y = 0, s = [], v = d.length; y < v; y++)
142
- (d[y].fn !== r || m && !d[y].once || i && d[y].context !== i) && s.push(d[y]);
143
- s.length ? this._events[f] = s.length === 1 ? s[0] : s : w(this, f);
139
+ for (var g = 0, s = [], E = d.length; g < E; g++)
140
+ (d[g].fn !== n || m && !d[g].once || a && d[g].context !== a) && s.push(d[g]);
141
+ s.length ? this._events[f] = s.length === 1 ? s[0] : s : y(this, f);
144
142
  }
145
143
  return this;
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;
144
+ }, u.prototype.removeAllListeners = function(i) {
145
+ var n;
146
+ return i ? (n = e ? e + i : i, this._events[n] && y(this, n)) : (this._events = new o(), this._eventsCount = 0), this;
149
147
  }, 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 H = k.exports;
152
- const K = 6e5, U = "2.0";
153
- function F() {
148
+ })(R);
149
+ var G = R.exports;
150
+ const B = 6e5, Y = "2.0";
151
+ function z() {
154
152
  return Math.floor(Math.random() * Number.MAX_SAFE_INTEGER);
155
153
  }
156
- class G extends Error {
154
+ class j extends Error {
157
155
  constructor(e, o) {
158
156
  super(`${e}: ${o}`);
159
- g(this, "isRpcError", !0);
160
- g(this, "code");
161
- g(this, "reason");
157
+ w(this, "isRpcError", !0);
158
+ w(this, "code");
159
+ w(this, "reason");
162
160
  this.code = e, this.reason = o;
163
161
  }
164
162
  }
165
- class q extends H.EventEmitter {
163
+ class Q extends G.EventEmitter {
166
164
  constructor({
167
- timeoutMilliseconds: e = K,
165
+ timeoutMilliseconds: e = B,
168
166
  eventSource: o = window,
169
167
  eventTarget: c = window.parent
170
168
  } = {}) {
171
169
  super();
172
- g(this, "enabled", null);
173
- g(this, "timeoutMilliseconds");
174
- g(this, "eventSource");
175
- g(this, "eventTarget");
176
- g(this, "completers", {});
170
+ w(this, "enabled", null);
171
+ w(this, "timeoutMilliseconds");
172
+ w(this, "eventSource");
173
+ w(this, "eventTarget");
174
+ w(this, "completers", {});
175
+ w(this, "providerMetaInfo", null);
176
+ w(this, "providerMetaInfoCallback");
177
177
  /**
178
178
  * Handle a Rpc Request
179
179
  */
180
- g(this, "handleRpcRequests", ({ rpcResponse: e }) => {
180
+ w(this, "handleRpcRequests", ({ rpcResponse: e }) => {
181
181
  if (e.id === void 0 || e.id === null)
182
182
  return;
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, O.listenToMessageFromWindow(
186
+ this.timeoutMilliseconds = e, this.eventSource = o, this.eventTarget = c, k.listenToMessageFromWindow(
187
187
  this.eventSource,
188
- A.PROVIDER_RPC_RESPONSE,
189
- (h) => {
190
- this.handleRpcRequests(h);
188
+ T.PROVIDER_RPC_RESPONSE,
189
+ (l) => {
190
+ this.handleRpcRequests(l);
191
191
  }
192
- ), O.listenToMessageFromWindow(
192
+ ), k.listenToMessageFromWindow(
193
193
  this.eventSource,
194
- A.PROVIDER_ON_EVENT,
195
- (h) => {
196
- this.handleOnEvent(h);
194
+ T.PROVIDER_ON_EVENT,
195
+ (l) => {
196
+ this.handleOnEvent(l);
197
+ }
198
+ ), k.listenToMessageFromWindow(
199
+ this.eventSource,
200
+ T.SEND_PROVIDER_META_INFO,
201
+ (l) => {
202
+ this.providerMetaInfo = l, this.providerMetaInfoCallback && this.providerMetaInfoCallback(this.providerMetaInfo);
197
203
  }
198
204
  );
199
205
  }
@@ -221,25 +227,25 @@ class q extends H.EventEmitter {
221
227
  * @param params params to pass the method
222
228
  */
223
229
  async execute(e, o) {
224
- const c = F(), h = {
225
- jsonrpc: U,
230
+ const c = z(), l = {
231
+ jsonrpc: Y,
226
232
  id: c,
227
233
  method: e,
228
234
  params: o
229
- }, w = new Promise(
230
- (u, l) => this.completers[c] = { resolve: u, reject: l }
235
+ }, y = new Promise(
236
+ (u, p) => this.completers[c] = { resolve: u, reject: p }
231
237
  );
232
- return O.postMessageToWindow(this.eventTarget, A.PROVIDER_RPC_REQUEST, {
233
- rpcRequest: h
238
+ return k.postMessageToWindow(this.eventTarget, T.PROVIDER_RPC_REQUEST, {
239
+ rpcRequest: l
234
240
  }), setTimeout(() => {
235
241
  this.completers[c] && (this.completers[c].reject(new Error("Request timed out. Please try again and submit it faster.")), delete this.completers[c]);
236
- }, this.timeoutMilliseconds), w;
242
+ }, this.timeoutMilliseconds), y;
237
243
  }
238
244
  async send(e, o) {
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
- if ("error" in w)
241
- throw new G(w.error.code, w.error.message);
242
- return w.result;
245
+ const { method: c, params: l } = typeof e == "string" ? { method: e, params: o } : { method: e.method, params: e.params }, y = await this.execute(c, l);
246
+ if ("error" in y)
247
+ throw new j(y.error.code, y.error.message);
248
+ return y.result;
243
249
  }
244
250
  /**
245
251
  * Request the parent window to enable access to the user's web3 provider. Return accounts list immediately if already enabled.
@@ -265,6 +271,17 @@ class q extends H.EventEmitter {
265
271
  o(c, null);
266
272
  }
267
273
  }
274
+ /**
275
+ * Subscribe to provider meta info
276
+ * @param callback
277
+ */
278
+ onProviderMetaInfo(e) {
279
+ this.providerMetaInfo ? e(this.providerMetaInfo) : (this.providerMetaInfoCallback = e, k.postMessageToWindow(
280
+ this.eventTarget,
281
+ T.REQUEST_PROVIDER_META_INFO,
282
+ null
283
+ ));
284
+ }
268
285
  handleOnEvent(e) {
269
286
  const o = e.params;
270
287
  switch (e.event) {
@@ -329,30 +346,29 @@ class q extends H.EventEmitter {
329
346
  }
330
347
  }
331
348
  var _ = /* @__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))(_ || {});
332
- const b = new C("cowSwapHookDapp");
333
- function J({ onContext: t }) {
334
- const a = window.parent, e = new q(), o = B();
335
- return b.listenToMessageFromWindow(window, _.CONTEXT_UPDATE, t), b.postMessageToWindow(a, _.ACTIVATE, void 0), { actions: o, provider: e };
349
+ const O = new C("cowSwapHookDapp");
350
+ function re({ onContext: t }) {
351
+ const r = window.parent, e = new Q(), o = X();
352
+ return O.listenToMessageFromWindow(window, _.CONTEXT_UPDATE, t), O.postMessageToWindow(r, _.ACTIVATE, void 0), { actions: o, provider: e };
336
353
  }
337
- function B() {
354
+ function X() {
338
355
  return {
339
356
  addHook(t) {
340
- b.postMessageToWindow(parent, _.ADD_HOOK, t);
357
+ O.postMessageToWindow(parent, _.ADD_HOOK, t);
341
358
  },
342
359
  editHook(t) {
343
- b.postMessageToWindow(parent, _.EDIT_HOOK, t);
360
+ O.postMessageToWindow(parent, _.EDIT_HOOK, t);
344
361
  },
345
362
  setSellToken(t) {
346
- b.postMessageToWindow(parent, _.SET_SELL_TOKEN, t);
363
+ O.postMessageToWindow(parent, _.SET_SELL_TOKEN, t);
347
364
  },
348
365
  setBuyToken(t) {
349
- b.postMessageToWindow(parent, _.SET_BUY_TOKEN, t);
366
+ O.postMessageToWindow(parent, _.SET_BUY_TOKEN, t);
350
367
  }
351
368
  };
352
369
  }
353
- var Y = /* @__PURE__ */ ((t) => (t.INTERNAL = "INTERNAL", t.IFRAME = "IFRAME", t))(Y || {}), j = /* @__PURE__ */ ((t) => (t.EOA = "EOA", t.SMART_CONTRACT = "SMART_CONTRACT", t))(j || {});
354
- const Z = 64, R = {
355
- id: "c768665aa144bcf18c14eea0249b6322050e5daeba046d7e94df743a2e504586",
370
+ var $ = /* @__PURE__ */ ((t) => (t.INTERNAL = "INTERNAL", t.IFRAME = "IFRAME", t))($ || {}), J = /* @__PURE__ */ ((t) => (t.EOA = "EOA", t.SMART_CONTRACT = "SMART_CONTRACT", t))(J || {});
371
+ const ae = 64, M = {
356
372
  type: "INTERNAL",
357
373
  name: "Build your own hook",
358
374
  descriptionShort: "Call any smart contract with your own parameters",
@@ -361,7 +377,6 @@ const Z = 64, R = {
361
377
  version: "v0.1.0",
362
378
  website: "https://docs.cow.fi/cow-protocol/tutorials/hook-dapp"
363
379
  }, S = {
364
- id: "ee4a6b1065cda592972b9ff7448ec111f29a566f137fef101ead7fbf8b01dd0b",
365
380
  type: "INTERNAL",
366
381
  name: "Claim GNO from validators",
367
382
  descriptionShort: "Withdraw rewards from your Gnosis validators.",
@@ -376,7 +391,6 @@ const Z = 64, R = {
376
391
  position: "pre"
377
392
  }
378
393
  }, I = {
379
- id: "1db4bacb661a90fb6b475fd5b585acba9745bc373573c65ecc3e8f5bfd5dee1f",
380
394
  type: "INTERNAL",
381
395
  name: "Permit a token",
382
396
  descriptionShort: "Infinite permit an address to spend one token on your behalf.",
@@ -393,7 +407,6 @@ const Z = 64, R = {
393
407
  ]
394
408
  }
395
409
  }, N = {
396
- id: "40ed08569519f3b58c410ba35a8e684612663a7c9b58025e0a9c3a54551fb0ff",
397
410
  type: "INTERNAL",
398
411
  name: "Claim COW Airdrop",
399
412
  descriptionShort: "Retrieve COW tokens before or after a swap.",
@@ -406,8 +419,7 @@ const Z = 64, R = {
406
419
  11155111
407
420
  ]
408
421
  }
409
- }, L = {
410
- id: "5dc71fa5829d976c462bdf37b38b6fd9bbc289252a5a18e61525f8c8a3c775df",
422
+ }, P = {
411
423
  name: "CoW AMM Withdraw Liquidity",
412
424
  type: "IFRAME",
413
425
  descriptionShort: "Remove liquidity from a CoW AMM pool before the swap",
@@ -423,8 +435,7 @@ const Z = 64, R = {
423
435
  ],
424
436
  smartContractWalletSupported: !1
425
437
  }
426
- }, M = {
427
- id: "5d2c081d11a01ca0b76e2fafbc0d3c62a4c9945ce404706fb1e49e826c0f99eb",
438
+ }, D = {
428
439
  type: "IFRAME",
429
440
  name: "Claim LlamaPay Vesting Hook",
430
441
  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.",
@@ -444,8 +455,7 @@ const Z = 64, R = {
444
455
  ],
445
456
  smartContractWalletSupported: !1
446
457
  }
447
- }, P = {
448
- id: "a316488cecc23fde8c39d3e748e0cb12bd4d18305826d36576d4bba74bd97baf",
458
+ }, L = {
449
459
  type: "IFRAME",
450
460
  name: "Create LlamaPay Vesting",
451
461
  descriptionShort: "Create a LlamaPay vesting contract",
@@ -466,49 +476,124 @@ const Z = 64, R = {
466
476
  42161
467
477
  ]
468
478
  }
469
- }, X = {
470
- BUILD_CUSTOM_HOOK: R,
479
+ }, W = {
480
+ type: "IFRAME",
481
+ name: "Withdraw Uniswap v2 Liquidity",
482
+ descriptionShort: "Remove liquidity from a Uniswap v2 Weighted pool before the swap",
483
+ description: "Reduce or withdraw Uniswap v2 from a pool before a token swap integrating the process directly into the transaction flow. By adjusting your liquidity ahead of time, you gain more control over your assets without any extra steps. Optimize your position in a pool, all in one seamless action — no need for multiple transactions or added complexity.",
484
+ version: "0.0.1",
485
+ website: "https://app.uniswap.org/pools/v2",
486
+ image: "https://cow-hooks-dapps-withdraw-uniswap-v2.vercel.app/icon.png",
487
+ url: "https://cow-hooks-dapps-withdraw-uniswap-v2.vercel.app/",
488
+ conditions: {
489
+ position: "pre",
490
+ walletCompatibility: [
491
+ "EOA"
492
+ ],
493
+ smartContractWalletSupported: !1,
494
+ supportedNetworks: [
495
+ 1,
496
+ 42161,
497
+ 11155111,
498
+ 8453
499
+ ]
500
+ }
501
+ }, x = {
502
+ name: "CoW AMM Deposit",
503
+ type: "IFRAME",
504
+ descriptionShort: "Add liquidity to any of the CoW AMM pools",
505
+ description: `Easily increase your position in a liquidity pool, adding both tokens in the right ratio.
506
+
507
+ Whether you're seeking to increase your exposure to specific tokens or maximize the returns from your assets, this tool offers a quick and efficient way to enhance your liquidity position after a token swap, all in a smooth, efficient process.`,
508
+ version: "0.0.1",
509
+ website: "https://balancer.fi/pools/cow",
510
+ image: "https://cow-hooks-dapps-cow-amm-deposit.vercel.app/icon.png",
511
+ url: "https://cow-hooks-dapps-cow-amm-deposit.vercel.app/",
512
+ conditions: {
513
+ position: "post",
514
+ walletCompatibility: [
515
+ "EOA"
516
+ ],
517
+ smartContractWalletSupported: !1
518
+ }
519
+ }, V = {
520
+ name: "Uniswap v2 Deposit",
521
+ type: "IFRAME",
522
+ descriptionShort: "Add liquidity to a Uniswap v2 pool after the swap",
523
+ description: `Easily increase your position in a liquidity pool, adding both tokens in the right ratio.
524
+
525
+ Whether you're seeking to increase your exposure to specific tokens or maximize the returns from your assets, this tool offers a quick and efficient way to enhance your liquidity position after a token swap, all in a smooth, efficient process.`,
526
+ version: "0.0.1",
527
+ website: "https://app.uniswap.org/pools/v2",
528
+ image: "https://cow-hooks-dapps-9zio.vercel.app/icon.png",
529
+ url: "https://cow-hooks-dapps-9zio.vercel.app/",
530
+ conditions: {
531
+ position: "post",
532
+ walletCompatibility: [
533
+ "EOA"
534
+ ],
535
+ supportedNetworks: [
536
+ 1,
537
+ 42161,
538
+ 11155111,
539
+ 8453
540
+ ]
541
+ }
542
+ }, Z = {
543
+ BUILD_CUSTOM_HOOK: M,
471
544
  CLAIM_GNO_FROM_VALIDATORS: S,
472
545
  PERMIT_TOKEN: I,
473
546
  CLAIM_COW_AIRDROP: N,
474
- COW_AMM_WITHDRAW: L,
475
- CLAIM_LLAMAPAY_VESTING: M,
476
- CREATE_LLAMAPAY_VESTING: P
477
- }, $ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
547
+ COW_AMM_WITHDRAW: P,
548
+ CLAIM_LLAMAPAY_VESTING: D,
549
+ CREATE_LLAMAPAY_VESTING: L,
550
+ UNI_V2_WITHDRAW: W,
551
+ COW_AMM_DEPOSIT: x,
552
+ UNI_V2_DEPOSIT: V
553
+ }, b = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
478
554
  __proto__: null,
479
- BUILD_CUSTOM_HOOK: R,
555
+ BUILD_CUSTOM_HOOK: M,
480
556
  CLAIM_COW_AIRDROP: N,
481
557
  CLAIM_GNO_FROM_VALIDATORS: S,
482
- CLAIM_LLAMAPAY_VESTING: M,
483
- COW_AMM_WITHDRAW: L,
484
- CREATE_LLAMAPAY_VESTING: P,
558
+ CLAIM_LLAMAPAY_VESTING: D,
559
+ COW_AMM_DEPOSIT: x,
560
+ COW_AMM_WITHDRAW: P,
561
+ CREATE_LLAMAPAY_VESTING: L,
485
562
  PERMIT_TOKEN: I,
486
- default: X
487
- }, Symbol.toStringTag, { value: "Module" }));
488
- function Q(t, a) {
489
- const e = a.reduce(
563
+ UNI_V2_DEPOSIT: V,
564
+ UNI_V2_WITHDRAW: W,
565
+ default: Z
566
+ }, Symbol.toStringTag, { value: "Module" })), ee = Object.keys(b).reduce((t, r) => {
567
+ const e = b[r];
568
+ return t.push({ id: r, ...e }), t;
569
+ }, []), te = "0xd505accf", oe = "0x8fcbaf0c", se = "1db4bacb661a90fb6b475fd5b585acba9745bc373573c65ecc3e8f5bfd5dee1f";
570
+ function ie(t, r) {
571
+ const e = r.reduce(
490
572
  (o, c) => (o[c.id] = c, o),
491
573
  {}
492
574
  );
493
575
  return t.filter((o) => !!o.dappId).map((o) => {
494
- const c = o, h = e[c.dappId];
495
- return {
576
+ const c = o, l = e[c.dappId];
577
+ return (!l || c.dappId === se) && (c.callData.startsWith(te) || c.callData.startsWith(oe)) ? {
578
+ hook: c,
579
+ dapp: I
580
+ } : {
496
581
  hook: c,
497
- dapp: h || null
582
+ dapp: l || null
498
583
  };
499
584
  });
500
585
  }
501
- function ee(t, a = []) {
502
- return Q(t, Object.values($).concat(a));
586
+ function ce(t, r = []) {
587
+ return ie(t, ee.concat(r));
503
588
  }
504
589
  export {
505
590
  _ as CoWHookDappEvents,
506
- Z as HOOK_DAPP_ID_LENGTH,
507
- Y as HookDappType,
508
- j as HookDappWalletCompatibility,
509
- b as hookDappIframeTransport,
510
- $ as hookDappsRegistry,
511
- J as initCoWHookDapp,
512
- Q as matchHooksToDapps,
513
- ee as matchHooksToDappsRegistry
591
+ ae as HOOK_DAPP_ID_LENGTH,
592
+ $ as HookDappType,
593
+ J as HookDappWalletCompatibility,
594
+ O as hookDappIframeTransport,
595
+ Z as hookDappsRegistry,
596
+ re as initCoWHookDapp,
597
+ ie as matchHooksToDapps,
598
+ ce as matchHooksToDappsRegistry
514
599
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cowprotocol/hook-dapp-lib",
3
- "version": "1.3.1",
3
+ "version": "1.7.1",
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",