@cowprotocol/hook-dapp-lib 2.0.11 → 2.0.13

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.
Files changed (3) hide show
  1. package/index.cjs +2 -2
  2. package/index.js +46 -44
  3. package/package.json +2 -2
package/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@cowprotocol/iframe-transport");var a=(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))(a||{});const i=new c.IframeTransport("cowSwapHookDapp");function u({onContext:o}){const e=window.parent,r=new c.WidgetEthereumProvider,t=g();return i.listenToMessageFromWindow(window,a.CONTEXT_UPDATE,o),i.postMessageToWindow(e,a.ACTIVATE,void 0),{actions:t,provider:r}}function g(){return{addHook(o){i.postMessageToWindow(parent,a.ADD_HOOK,o)},editHook(o){i.postMessageToWindow(parent,a.EDIT_HOOK,o)},setSellToken(o){i.postMessageToWindow(parent,a.SET_SELL_TOKEN,o)},setBuyToken(o){i.postMessageToWindow(parent,a.SET_BUY_TOKEN,o)}}}var l=(o=>(o.INTERNAL="INTERNAL",o.IFRAME="IFRAME",o))(l||{}),d=(o=>(o.EOA="EOA",o.SMART_CONTRACT="SMART_CONTRACT",o))(d||{});const y=64,p="cow-swap://libs/hook-dapp-lib/permit",n={BUILD_CUSTOM_HOOK:{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"},CLAIM_GNO_FROM_VALIDATORS:{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]:{type:"INTERNAL",name:"Permit a token",descriptionShort:"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]}},CLAIM_COW_AIRDROP:{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]}},COW_AMM_WITHDRAW:{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"],supportedNetworks:[1,100,8453,42161,11155111]}},CLAIM_LLAMAPAY_VESTING:{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"]}},CREATE_LLAMAPAY_VESTING:{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"],supportedNetworks:[1,100,42161]}},UNI_V2_WITHDRAW:{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"],supportedNetworks:[1,42161,11155111,8453]}},COW_AMM_DEPOSIT:{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.
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("@cowprotocol/iframe-transport");var i=(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))(i||{});const r=new p.IframeTransport("cowSwapHookDapp");function u({onContext:o}){const t=window.parent,e=p.getParentOrigin(),s=new p.WidgetEthereumProvider({targetOrigin:e}),a=g(t,e);return r.listenToMessageFromWindow(window,i.CONTEXT_UPDATE,o,e),r.postMessageToWindow(t,i.ACTIVATE,void 0,e),{actions:a,provider:s}}function g(o,t){return{addHook(e){r.postMessageToWindow(o,i.ADD_HOOK,e,t)},editHook(e){r.postMessageToWindow(o,i.EDIT_HOOK,e,t)},setSellToken(e){r.postMessageToWindow(o,i.SET_SELL_TOKEN,e,t)},setBuyToken(e){r.postMessageToWindow(o,i.SET_BUY_TOKEN,e,t)}}}var l=(o=>(o.INTERNAL="INTERNAL",o.IFRAME="IFRAME",o))(l||{}),d=(o=>(o.EOA="EOA",o.SMART_CONTRACT="SMART_CONTRACT",o))(d||{});const y=64,c="cow-swap://libs/hook-dapp-lib/permit",n={BUILD_CUSTOM_HOOK:{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"},CLAIM_GNO_FROM_VALIDATORS:{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"}},[c]:{type:"INTERNAL",name:"Permit a token",descriptionShort:"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]}},CLAIM_COW_AIRDROP:{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]}},COW_AMM_WITHDRAW:{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"],supportedNetworks:[1,100,8453,42161,11155111]}},CLAIM_LLAMAPAY_VESTING:{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"]}},CREATE_LLAMAPAY_VESTING:{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"],supportedNetworks:[1,100,42161]}},UNI_V2_WITHDRAW:{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"],supportedNetworks:[1,42161,11155111,8453]}},COW_AMM_DEPOSIT:{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
2
 
3
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"],supportedNetworks:[1,100,8453,42161,11155111]}},UNI_V2_DEPOSIT:{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
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]}},MORPHO_BORROW:{name:"Morpho Borrow",type:"IFRAME",descriptionShort:"Supply collateral, borrow, repay and withdraw collateral on Morpho Protocol.",description:"The Morpho Borrow hook enables users to seamlessly combine swaps with borrow-related actions. Users can enter new positions, leave existing ones, or move between different markets through a unified, streamlined process.",version:"0.0.1",website:"https://app.morpho.org/",image:"https://cow-hooks-dapps-morpho-lending.vercel.app/icon.png",url:"https://cow-hooks-dapps-morpho-lending.vercel.app/",conditions:{walletCompatibility:["EOA"],supportedNetworks:[1,137,8453]}},"cow-sdk://bridging/providers/bungee":{name:"Bungee",type:"INTERNAL",descriptionShort:"Bungee Protocol - Swap tokens across chains",description:"Bungee is a liquidity marketplace that lets you swap into any token on any chain in a fully abstracted manner. Trade any token with the best quotes and a gasless UX!",version:"0.0.1",website:"https://www.bungee.exchange",image:"https://files.cow.fi/cow-sdk/bridging/providers/bungee/bungee-logo.png",conditions:{walletCompatibility:["EOA"]}},"cow-sdk://bridging/providers/across":{name:"Across",type:"INTERNAL",descriptionShort:"Across Protocol - Transfer Assets Between Layer 2s and Mainnet",description:"Across is the fastest, cheapest and most secure cross-chain bridge for Ethereum, Arbitrum, Optimism, Polygon and other Layer 1 and Layer 2 networks. Transfer tokens with Across.",version:"0.0.1",website:"https://across.to",image:"https://files.cow.fi/cow-sdk/bridging/providers/across/across-logo.png",conditions:{walletCompatibility:["EOA"]}},"cow-sdk://flashloans/aave/v3/collateral-swap":{name:"Aave Collateral Swap",type:"INTERNAL",descriptionShort:"Aave Collateral Swap Flashloan",description:"The swap adapter contracts integrate Aave Flash Loans and CoW Swap to facilitate advanced actions like swapping collateral assets when there are borrow positions. Learn more at https://aave.com/docs/developers/smart-contracts/swap-features.",version:"0.0.1",website:"https://aave.com",image:"https://files.cow.fi/token-lists/images/1/0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9/logo.png"},"cow-sdk://flashloans/aave/v3/debt-swap":{name:"Aave Debt Swap",type:"INTERNAL",descriptionShort:"Aave Debt Swap Flashloan",description:"The swap adapter contracts integrate Aave Flash Loans and CoW Swap to facilitate advanced actions like swapping debt assets. Learn more at https://aave.com/docs/developers/smart-contracts/swap-features.",version:"0.0.1",website:"https://aave.com",image:"https://files.cow.fi/token-lists/images/1/0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9/logo.png"},"cow-sdk://flashloans/aave/v3/repay-with-collateral":{name:"Aave Repay",type:"INTERNAL",descriptionShort:"Aave Repay with Collateral Flashloan",description:"The swap adapter contracts integrate Aave Flash Loans and CoW Swap to facilitate advanced actions like repaying borrow positions using collateral. Learn more at https://aave.com/docs/developers/smart-contracts/swap-features.",version:"0.0.1",website:"https://aave.com",image:"https://files.cow.fi/token-lists/images/1/0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9/logo.png"}},f=Object.keys(n).reduce((o,e)=>{const r=n[e];return o.push({id:e,...r}),o},[]),v="0xd505accf",k="0x8fcbaf0c";function h(o,e){const r=e.reduce((t,s)=>(t[s.id]=s,t),{});return o.filter(t=>!!t.dappId).map(t=>{const s=t,m=r[s.dappId];return w(s)?{hook:s,dapp:n[p]}:{hook:s,dapp:m||null}})}function w(o){return o.callData.startsWith(v)||o.callData.startsWith(k)}function A(o,e=[]){return h(o,f.concat(e))}exports.CoWHookDappEvents=a;exports.HOOK_DAPP_ID_LENGTH=y;exports.HookDappType=l;exports.HookDappWalletCompatibility=d;exports.PERMIT_HOOK_DAPP_ID=p;exports.doesHookHavePermit=w;exports.hookDappIframeTransport=i;exports.hookDappsRegistry=n;exports.initCoWHookDapp=u;exports.matchHooksToDapps=h;exports.matchHooksToDappsRegistry=A;
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]}},MORPHO_BORROW:{name:"Morpho Borrow",type:"IFRAME",descriptionShort:"Supply collateral, borrow, repay and withdraw collateral on Morpho Protocol.",description:"The Morpho Borrow hook enables users to seamlessly combine swaps with borrow-related actions. Users can enter new positions, leave existing ones, or move between different markets through a unified, streamlined process.",version:"0.0.1",website:"https://app.morpho.org/",image:"https://cow-hooks-dapps-morpho-lending.vercel.app/icon.png",url:"https://cow-hooks-dapps-morpho-lending.vercel.app/",conditions:{walletCompatibility:["EOA"],supportedNetworks:[1,137,8453]}},"cow-sdk://bridging/providers/bungee":{name:"Bungee",type:"INTERNAL",descriptionShort:"Bungee Protocol - Swap tokens across chains",description:"Bungee is a liquidity marketplace that lets you swap into any token on any chain in a fully abstracted manner. Trade any token with the best quotes and a gasless UX!",version:"0.0.1",website:"https://www.bungee.exchange",image:"https://files.cow.fi/cow-sdk/bridging/providers/bungee/bungee-logo.png",conditions:{walletCompatibility:["EOA"]}},"cow-sdk://bridging/providers/across":{name:"Across",type:"INTERNAL",descriptionShort:"Across Protocol - Transfer Assets Between Layer 2s and Mainnet",description:"Across is the fastest, cheapest and most secure cross-chain bridge for Ethereum, Arbitrum, Optimism, Polygon and other Layer 1 and Layer 2 networks. Transfer tokens with Across.",version:"0.0.1",website:"https://across.to",image:"https://files.cow.fi/cow-sdk/bridging/providers/across/across-logo.png",conditions:{walletCompatibility:["EOA"]}},"cow-sdk://flashloans/aave/v3/collateral-swap":{name:"Aave Collateral Swap",type:"INTERNAL",descriptionShort:"Aave Collateral Swap Flashloan",description:"The swap adapter contracts integrate Aave Flash Loans and CoW Swap to facilitate advanced actions like swapping collateral assets when there are borrow positions. Learn more at https://aave.com/docs/developers/smart-contracts/swap-features.",version:"0.0.1",website:"https://aave.com",image:"https://files.cow.fi/token-lists/images/1/0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9/logo.png"},"cow-sdk://flashloans/aave/v3/debt-swap":{name:"Aave Debt Swap",type:"INTERNAL",descriptionShort:"Aave Debt Swap Flashloan",description:"The swap adapter contracts integrate Aave Flash Loans and CoW Swap to facilitate advanced actions like swapping debt assets. Learn more at https://aave.com/docs/developers/smart-contracts/swap-features.",version:"0.0.1",website:"https://aave.com",image:"https://files.cow.fi/token-lists/images/1/0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9/logo.png"},"cow-sdk://flashloans/aave/v3/repay-with-collateral":{name:"Aave Repay",type:"INTERNAL",descriptionShort:"Aave Repay with Collateral Flashloan",description:"The swap adapter contracts integrate Aave Flash Loans and CoW Swap to facilitate advanced actions like repaying borrow positions using collateral. Learn more at https://aave.com/docs/developers/smart-contracts/swap-features.",version:"0.0.1",website:"https://aave.com",image:"https://files.cow.fi/token-lists/images/1/0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9/logo.png"}},f=Object.keys(n).reduce((o,t)=>{const e=n[t];return o.push({id:t,...e}),o},[]),v="0xd505accf",k="0x8fcbaf0c";function h(o,t){const e=t.reduce((s,a)=>(s[a.id]=a,s),{});return o.filter(s=>!!s.dappId).map(s=>{const a=s,m=e[a.dappId];return w(a)?{hook:a,dapp:n[c]}:{hook:a,dapp:m||null}})}function w(o){return o.callData.startsWith(v)||o.callData.startsWith(k)}function A(o,t=[]){return h(o,f.concat(t))}exports.CoWHookDappEvents=i;exports.HOOK_DAPP_ID_LENGTH=y;exports.HookDappType=l;exports.HookDappWalletCompatibility=d;exports.PERMIT_HOOK_DAPP_ID=c;exports.doesHookHavePermit=w;exports.hookDappIframeTransport=r;exports.hookDappsRegistry=n;exports.initCoWHookDapp=u;exports.matchHooksToDapps=h;exports.matchHooksToDappsRegistry=A;
package/index.js CHANGED
@@ -1,33 +1,35 @@
1
- import { IframeTransport as l, WidgetEthereumProvider as d } from "@cowprotocol/iframe-transport";
2
- var s = /* @__PURE__ */ ((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))(s || {});
3
- const i = new l("cowSwapHookDapp");
4
- function A({
1
+ import { IframeTransport as l, getParentOrigin as d, WidgetEthereumProvider as h } from "@cowprotocol/iframe-transport";
2
+ var i = /* @__PURE__ */ ((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))(i || {});
3
+ const r = new l("cowSwapHookDapp");
4
+ function T({
5
5
  onContext: o
6
6
  }) {
7
- const e = window.parent, r = new d(), t = h();
8
- return i.listenToMessageFromWindow(window, s.CONTEXT_UPDATE, o), i.postMessageToWindow(e, s.ACTIVATE, void 0), {
9
- actions: t,
10
- provider: r
7
+ const t = window.parent, e = d(), a = new h({
8
+ targetOrigin: e
9
+ }), s = w(t, e);
10
+ return r.listenToMessageFromWindow(window, i.CONTEXT_UPDATE, o, e), r.postMessageToWindow(t, i.ACTIVATE, void 0, e), {
11
+ actions: s,
12
+ provider: a
11
13
  };
12
14
  }
13
- function h() {
15
+ function w(o, t) {
14
16
  return {
15
- addHook(o) {
16
- i.postMessageToWindow(parent, s.ADD_HOOK, o);
17
+ addHook(e) {
18
+ r.postMessageToWindow(o, i.ADD_HOOK, e, t);
17
19
  },
18
- editHook(o) {
19
- i.postMessageToWindow(parent, s.EDIT_HOOK, o);
20
+ editHook(e) {
21
+ r.postMessageToWindow(o, i.EDIT_HOOK, e, t);
20
22
  },
21
- setSellToken(o) {
22
- i.postMessageToWindow(parent, s.SET_SELL_TOKEN, o);
23
+ setSellToken(e) {
24
+ r.postMessageToWindow(o, i.SET_SELL_TOKEN, e, t);
23
25
  },
24
- setBuyToken(o) {
25
- i.postMessageToWindow(parent, s.SET_BUY_TOKEN, o);
26
+ setBuyToken(e) {
27
+ r.postMessageToWindow(o, i.SET_BUY_TOKEN, e, t);
26
28
  }
27
29
  };
28
30
  }
29
- var w = /* @__PURE__ */ ((o) => (o.INTERNAL = "INTERNAL", o.IFRAME = "IFRAME", o))(w || {}), u = /* @__PURE__ */ ((o) => (o.EOA = "EOA", o.SMART_CONTRACT = "SMART_CONTRACT", o))(u || {});
30
- const T = 64, p = "cow-swap://libs/hook-dapp-lib/permit", n = {
31
+ var u = /* @__PURE__ */ ((o) => (o.INTERNAL = "INTERNAL", o.IFRAME = "IFRAME", o))(u || {}), m = /* @__PURE__ */ ((o) => (o.EOA = "EOA", o.SMART_CONTRACT = "SMART_CONTRACT", o))(m || {});
32
+ const b = 64, p = "cow-swap://libs/hook-dapp-lib/permit", n = {
31
33
  BUILD_CUSTOM_HOOK: {
32
34
  type: "INTERNAL",
33
35
  name: "Build your own hook",
@@ -233,42 +235,42 @@ const T = 64, p = "cow-swap://libs/hook-dapp-lib/permit", n = {
233
235
  website: "https://aave.com",
234
236
  image: "https://files.cow.fi/token-lists/images/1/0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9/logo.png"
235
237
  }
236
- }, m = Object.keys(n).reduce((o, e) => {
237
- const r = n[e];
238
+ }, g = Object.keys(n).reduce((o, t) => {
239
+ const e = n[t];
238
240
  return o.push({
239
- id: e,
240
- ...r
241
+ id: t,
242
+ ...e
241
243
  }), o;
242
- }, []), g = "0xd505accf", y = "0x8fcbaf0c";
243
- function f(o, e) {
244
- const r = e.reduce((t, a) => (t[a.id] = a, t), {});
245
- return o.filter((t) => !!t.dappId).map((t) => {
246
- const a = t, c = r[a.dappId];
247
- return v(a) ? {
248
- hook: a,
244
+ }, []), y = "0xd505accf", f = "0x8fcbaf0c";
245
+ function v(o, t) {
246
+ const e = t.reduce((a, s) => (a[s.id] = s, a), {});
247
+ return o.filter((a) => !!a.dappId).map((a) => {
248
+ const s = a, c = e[s.dappId];
249
+ return k(s) ? {
250
+ hook: s,
249
251
  dapp: n[p]
250
252
  } : {
251
- hook: a,
253
+ hook: s,
252
254
  dapp: c || null
253
255
  };
254
256
  });
255
257
  }
256
- function v(o) {
257
- return o.callData.startsWith(g) || o.callData.startsWith(y);
258
+ function k(o) {
259
+ return o.callData.startsWith(y) || o.callData.startsWith(f);
258
260
  }
259
- function b(o, e = []) {
260
- return f(o, m.concat(e));
261
+ function E(o, t = []) {
262
+ return v(o, g.concat(t));
261
263
  }
262
264
  export {
263
- s as CoWHookDappEvents,
264
- T as HOOK_DAPP_ID_LENGTH,
265
- w as HookDappType,
266
- u as HookDappWalletCompatibility,
265
+ i as CoWHookDappEvents,
266
+ b as HOOK_DAPP_ID_LENGTH,
267
+ u as HookDappType,
268
+ m as HookDappWalletCompatibility,
267
269
  p as PERMIT_HOOK_DAPP_ID,
268
- v as doesHookHavePermit,
269
- i as hookDappIframeTransport,
270
+ k as doesHookHavePermit,
271
+ r as hookDappIframeTransport,
270
272
  n as hookDappsRegistry,
271
- A as initCoWHookDapp,
272
- f as matchHooksToDapps,
273
- b as matchHooksToDappsRegistry
273
+ T as initCoWHookDapp,
274
+ v as matchHooksToDapps,
275
+ E as matchHooksToDappsRegistry
274
276
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cowprotocol/hook-dapp-lib",
3
- "version": "2.0.11",
3
+ "version": "2.0.13",
4
4
  "description": "CoW Swap Hook Dapp Library. Allows you to develop pre/post hooks dapps for CoW Protocol.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -15,7 +15,7 @@
15
15
  "access": "public"
16
16
  },
17
17
  "dependencies": {
18
- "@cowprotocol/iframe-transport": "^2.0.11"
18
+ "@cowprotocol/iframe-transport": "^2.0.13"
19
19
  },
20
20
  "exports": {
21
21
  ".": {