@cowprotocol/widget-react 0.9.1 → 0.9.3

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.js +1 -1
  2. package/index.mjs +182 -152
  3. package/package.json +2 -2
package/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var M=Object.defineProperty;var V=(e,n,t)=>n in e?M(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var l=(e,n,t)=>(V(e,typeof n!="symbol"?n+"":n,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("react/jsx-runtime"),f=require("react");class b{constructor(){l(this,"subscriptions",{})}on(n){const{event:t,handler:r}=n;this.subscriptions[t]||(this.subscriptions[t]=[]),this.subscriptions[t].push(r)}off(n){const{event:t,handler:r}=n;this.subscriptions[t]&&(this.subscriptions[t]=this.subscriptions[t].filter(s=>s!==r))}emit(n,t){this.subscriptions[n]&&this.subscriptions[n].forEach(r=>r(t))}}const L="cowSwapWidget";function T(e,n,t){const s={key:L,method:n,...typeof t=="object"?t:{}};e.postMessage(s,"*")}function m(e,n,t){const r=s=>{!F(s.data)||s.data.key!==L||s.data.method!==n||t(s.data)};return e.addEventListener("message",r),r}function F(e){return typeof e=="object"&&e!==null&&"key"in e&&"method"in e&&typeof e.key=="string"&&typeof e.method=="string"}function D(e,n,t){e.removeEventListener("message",t)}function _(e,n){e.removeEventListener("message",n)}var w=(e=>(e.ACTIVATE="ACTIVATE",e.UPDATE_HEIGHT="UPDATE_HEIGHT",e.SET_FULL_HEIGHT="SET_FULL_HEIGHT",e.EMIT_COW_EVENT="EMIT_COW_EVENT",e.PROVIDER_RPC_REQUEST="PROVIDER_RPC_REQUEST",e))(w||{}),g=(e=>(e.UPDATE_PARAMS="UPDATE_PARAMS",e.UPDATE_APP_DATA="UPDATE_APP_DATA",e.PROVIDER_RPC_RESPONSE="PROVIDER_RPC_RESPONSE",e.PROVIDER_ON_EVENT="PROVIDER_ON_EVENT",e))(g||{}),S=(e=>(e.SWAP="swap",e.LIMIT="limit",e.ADVANCED="advanced",e))(S||{});const N=["primary","background","paper","text","danger","warning","alert","info","success"];class k{constructor(n,t=[]){l(this,"eventEmitter",new b);l(this,"listeners",[]);l(this,"widgetListener");this.contentWindow=n,this.updateListeners(t),this.widgetListener=m(this.contentWindow,w.EMIT_COW_EVENT,r=>this.eventEmitter.emit(r.event,r.payload))}stopListeningIframe(){_(this.contentWindow,this.widgetListener)}updateListeners(n){for(const t of this.listeners)this.eventEmitter.off(t);this.listeners=n||[];for(const t of this.listeners)this.eventEmitter.on(t)}}const G=["connect","disconnect","close","chainChanged","accountsChanged"];class x{constructor(n){l(this,"ethereumProvider",null);l(this,"requestWaitingForConnection",{});l(this,"processRpcCallFromWindow",({rpcRequest:n})=>{if(!this.ethereumProvider){n.id&&(this.requestWaitingForConnection[n.id]=n);return}this.processRpcRequest(n)});this.iframeWidow=n}disconnect(){this.ethereumProvider=null,D(window,w.PROVIDER_RPC_REQUEST,this.processRpcCallFromWindow)}onConnect(n){this.ethereumProvider?this.disconnect():m(window,w.PROVIDER_RPC_REQUEST,this.processRpcCallFromWindow),this.ethereumProvider=n,this.processPendingRequests(),G.forEach(t=>{n.on(t,r=>this.onProviderEvent(t,r))})}processPendingRequests(){Object.keys(this.requestWaitingForConnection).forEach(n=>{this.processRpcRequest(this.requestWaitingForConnection[n])}),this.requestWaitingForConnection={}}processRpcRequest(n){const{id:t,jsonrpc:r,method:s}=n;if(!this.ethereumProvider||!t)return;(s==="enable"?this.ethereumProvider.enable():this.ethereumProvider.request({...n,id:t})).then(d=>this.forwardRpcResponseToIframe({rpcResponse:{jsonrpc:r,id:t,result:d}})).catch(d=>this.forwardRpcResponseToIframe({rpcResponse:{jsonrpc:r,id:t,error:d}}))}onProviderEvent(n,t){T(this.iframeWidow,g.PROVIDER_ON_EVENT,{event:n,params:t})}forwardRpcResponseToIframe(n){T(this.iframeWidow,g.PROVIDER_RPC_RESPONSE,n)}}class ${constructor(n,t){l(this,"forwardSdkMessage");this.appWindow=n,this.iframeWidow=t,this.forwardSdkMessage=r=>{Q(r.data)&&r.origin!==window.location.origin&&(j(r.data)?this.appWindow.parent.postMessage(r.data,"*"):q(r.data)&&this.iframeWidow.postMessage(r.data,"*"))},this.startListening()}startListening(){this.appWindow.addEventListener("message",this.forwardSdkMessage)}stopListening(){this.appWindow.removeEventListener("message",this.forwardSdkMessage)}}function Q(e){return typeof e=="object"&&e!==null&&"id"in e&&typeof e.id=="string"}function j(e){return"method"in e&&typeof e.method=="string"&&"params"in e&&"env"in e&&typeof e.env=="object"&&e.env!==null&&"sdkVersion"in e.env}function q(e){return"success"in e&&typeof e.success=="boolean"&&"version"in e&&typeof e.version=="string"}function O(e){return!!(e&&typeof e=="object")}const A="_";function B(e){const n=typeof e.baseUrl=="string"?e.baseUrl:"https://swap.cow.fi",t=y(e);return n+"/#"+t+"?"+U(e)}function y(e){const{chainId:n=1,sell:t,buy:r,tradeType:s=S.SWAP}=e,c=[(t==null?void 0:t.asset)||A,(r==null?void 0:r.asset)||A].map(encodeURIComponent).join("/");return`/${n}/widget/${s}/${c}`}function U(e){const n=new URLSearchParams;return K(J(n,e),e)}function J(e,n){const{sell:t,buy:r}=n;return t!=null&&t.amount&&e.append("sellAmount",t.amount),r!=null&&r.amount&&e.append("buyAmount",r.amount),e}function K(e,n){const t=n.theme;return t?(O(t)?(e.append("palette",encodeURIComponent(JSON.stringify(t))),e.append("theme",t.baseTheme)):(e.append("palette","null"),e.append("theme",t)),e):(e.append("palette","null"),e)}const H="640px",Y="450px",z=20;function P(e,n){const{params:t,provider:r,listeners:s}=n;let c=r,d=t;const o=X(t);e.innerHTML="",e.appendChild(o);const{contentWindow:p}=o;if(!p)throw console.error("Iframe does not contain a window",o),new Error("Iframe does not contain a window!");const E=[];E.push(Z(p,t.appCode)),E.push(...ee(o,t.height));const u=new k(window,s);let h=C(p,null,c);o.addEventListener("load",()=>I(p,d,c));const a=new $(window,p);return{updateParams:i=>{d=i,I(p,d,c)},updateListeners:i=>u.updateListeners(i),updateProvider:i=>{c=i,h=C(p,h,i)},destroy:()=>{h.disconnect(),u.stopListeningIframe(),E.forEach(i=>window.removeEventListener("message",i)),a.stopListening(),e.removeChild(o)}}}function C(e,n,t){n&&n.disconnect();const r=n||new x(e);return t&&r.onConnect(t),r}function X(e){const{width:n=Y,height:t=H}=e,r=document.createElement("iframe");return r.src=B(e),r.width=n,r.height=t,r.style.border="0",r}function I(e,n,t){const r=!!t,s=y(n),c=U(n).toString(),{theme:d,...o}=n;T(e,g.UPDATE_PARAMS,{urlParams:{pathname:s,search:c},appParams:o,hasProvider:r})}function Z(e,n){const t=m(window,w.ACTIVATE,()=>{_(window,t),T(e,g.UPDATE_APP_DATA,{metaData:n?{appCode:n}:void 0})});return t}function ee(e,n=H){return[m(window,w.UPDATE_HEIGHT,t=>{e.style.height=t.height?`${t.height+z}px`:n}),m(window,w.SET_FULL_HEIGHT,({isUpToSmall:t})=>{e.style.height=t?n:`${document.body.offsetHeight}px`})]}function te(e){const{params:n,provider:t,listeners:r}=e,[s,c]=f.useState(null),d=f.useRef(null),o=f.useRef(t),p=f.useRef(r),E=f.useRef(null),u=f.useRef(null),h=f.useCallback((a,i)=>{try{console.log(`[WIDGET] ${a}`),i()}catch(v){const W=`Error ${a.toLowerCase()}`;console.error(`[WIDGET] ${W}`,v),c({message:W,error:v})}},[c]);return f.useEffect(()=>()=>{d.current=null,o.current=void 0,p.current=void 0;const a=u.current;a&&(h("💥 Destroy widget",()=>a.destroy()),u.current=null)},[]),f.useEffect(()=>{if(!E.current||JSON.stringify(d.current)===JSON.stringify(n))return;const a=E.current,i=u.current;d.current=n,i===null?h("Creating a new widget",()=>{u.current=P(a,{params:n,provider:o.current,listeners:r}),p.current=r}):h("Updating the widget",()=>i.updateParams(n))},[n]),f.useEffect(()=>{if(!u.current||o.current===t)return;o.current=t;const a=E.current;a&&h("Updating the provider",()=>{var i;(i=u.current)==null||i.destroy(),u.current=P(a,{params:n,provider:o.current,listeners:r})})},[t]),f.useEffect(()=>{if(!u.current||p.current===r)return;const a=u.current;h("Updating the listeners",()=>a.updateListeners(r))},[r]),s?R.jsxs("div",{style:{color:"#ff3a3a"},children:[s.message,s.error.message&&R.jsx("pre",{style:{whiteSpace:"pre-wrap",fontSize:"0.75em"},children:s.error.message})]}):R.jsx("div",{ref:E,style:{width:"100%"}})}exports.CowSwapWidget=te;exports.TradeType=S;exports.WIDGET_PALETTE_COLORS=N;exports.WidgetMethodsEmit=w;exports.WidgetMethodsListen=g;exports.createCowSwapWidget=P;exports.isCowSwapWidgetPalette=O;exports.listenToMessageFromWindow=m;exports.postMessageToWindow=T;exports.stopListeningToMessageFromWindow=D;exports.stopListeningWindowListener=_;
1
+ "use strict";var V=Object.defineProperty;var F=(e,t,n)=>t in e?V(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var E=(e,t,n)=>(F(e,typeof t!="symbol"?t+"":t,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("react/jsx-runtime"),f=require("react");class M{constructor(){E(this,"subscriptions",{})}on(t){const{event:n,handler:r}=t;this.subscriptions[n]||(this.subscriptions[n]=[]),this.subscriptions[n].push(r)}off(t){const{event:n,handler:r}=t;this.subscriptions[n]&&(this.subscriptions[n]=this.subscriptions[n].filter(s=>s!==r))}emit(t,n){this.subscriptions[t]&&this.subscriptions[t].forEach(r=>r(n))}}const L="cowSwapWidget";function g(e,t,n){const s={key:L,method:t,...typeof n=="object"?n:{}};e.postMessage(s,"*")}function m(e,t,n){const r=s=>{!k(s.data)||s.data.key!==L||s.data.method!==t||n(s.data)};return e.addEventListener("message",r),r}function k(e){return typeof e=="object"&&e!==null&&"key"in e&&"method"in e&&typeof e.key=="string"&&typeof e.method=="string"}function D(e,t,n){e.removeEventListener("message",n)}function y(e,t){e.removeEventListener("message",t)}var w=(e=>(e.ACTIVATE="ACTIVATE",e.UPDATE_HEIGHT="UPDATE_HEIGHT",e.SET_FULL_HEIGHT="SET_FULL_HEIGHT",e.EMIT_COW_EVENT="EMIT_COW_EVENT",e.PROVIDER_RPC_REQUEST="PROVIDER_RPC_REQUEST",e.INTERCEPT_WINDOW_OPEN="INTERCEPT_WINDOW_OPEN",e))(w||{}),T=(e=>(e.UPDATE_PARAMS="UPDATE_PARAMS",e.UPDATE_APP_DATA="UPDATE_APP_DATA",e.PROVIDER_RPC_RESPONSE="PROVIDER_RPC_RESPONSE",e.PROVIDER_ON_EVENT="PROVIDER_ON_EVENT",e))(T||{}),P=(e=>(e.SWAP="swap",e.LIMIT="limit",e.ADVANCED="advanced",e))(P||{});const G=["primary","background","paper","text","danger","warning","alert","info","success"];class x{constructor(t,n=[]){E(this,"eventEmitter",new M);E(this,"listeners",[]);E(this,"widgetListener");this.contentWindow=t,this.updateListeners(n),this.widgetListener=m(this.contentWindow,w.EMIT_COW_EVENT,r=>this.eventEmitter.emit(r.event,r.payload))}stopListeningIframe(){y(this.contentWindow,this.widgetListener)}updateListeners(t){for(const n of this.listeners)this.eventEmitter.off(n);this.listeners=t||[];for(const n of this.listeners)this.eventEmitter.on(n)}}const j=["connect","disconnect","close","chainChanged","accountsChanged"];class ${constructor(t){E(this,"ethereumProvider",null);E(this,"requestWaitingForConnection",{});E(this,"processRpcCallFromWindow",({rpcRequest:t})=>{if(!this.ethereumProvider){t.id&&(this.requestWaitingForConnection[t.id]=t);return}this.processRpcRequest(t)});this.iframeWidow=t}disconnect(){this.ethereumProvider=null,D(window,w.PROVIDER_RPC_REQUEST,this.processRpcCallFromWindow)}onConnect(t){this.ethereumProvider?this.disconnect():m(window,w.PROVIDER_RPC_REQUEST,this.processRpcCallFromWindow),this.ethereumProvider=t,this.processPendingRequests(),j.forEach(n=>{t.on(n,r=>this.onProviderEvent(n,r))})}processPendingRequests(){Object.keys(this.requestWaitingForConnection).forEach(t=>{this.processRpcRequest(this.requestWaitingForConnection[t])}),this.requestWaitingForConnection={}}processRpcRequest(t){const{id:n,jsonrpc:r,method:s}=t;if(!this.ethereumProvider||!n)return;(s==="enable"?this.ethereumProvider.enable():this.ethereumProvider.request({...t,id:n})).then(d=>this.forwardRpcResponseToIframe({rpcResponse:{jsonrpc:r,id:n,result:d}})).catch(d=>this.forwardRpcResponseToIframe({rpcResponse:{jsonrpc:r,id:n,error:d}}))}onProviderEvent(t,n){g(this.iframeWidow,T.PROVIDER_ON_EVENT,{event:t,params:n})}forwardRpcResponseToIframe(t){g(this.iframeWidow,T.PROVIDER_RPC_RESPONSE,t)}}class Q{constructor(t,n){E(this,"forwardSdkMessage");this.appWindow=t,this.iframeWidow=n,this.forwardSdkMessage=r=>{q(r.data)&&r.origin!==window.location.origin&&(B(r.data)?this.appWindow.parent.postMessage(r.data,"*"):J(r.data)&&this.iframeWidow.postMessage(r.data,"*"))},this.startListening()}startListening(){this.appWindow.addEventListener("message",this.forwardSdkMessage)}stopListening(){this.appWindow.removeEventListener("message",this.forwardSdkMessage)}}function q(e){return typeof e=="object"&&e!==null&&"id"in e&&typeof e.id=="string"}function B(e){return"method"in e&&typeof e.method=="string"&&"params"in e&&"env"in e&&typeof e.env=="object"&&e.env!==null&&"sdkVersion"in e.env}function J(e){return"success"in e&&typeof e.success=="boolean"&&"version"in e&&typeof e.version=="string"}function b(e){return!!(e&&typeof e=="object")}const I="_";function z(e){const t=typeof e.baseUrl=="string"?e.baseUrl:"https://swap.cow.fi",n=N(e);return t+"/#"+n+"?"+U(e)}function N(e){const{chainId:t=1,sell:n,buy:r,tradeType:s=P.SWAP}=e,c=[(n==null?void 0:n.asset)||I,(r==null?void 0:r.asset)||I].map(encodeURIComponent).join("/");return`/${t}/widget/${s}/${c}`}function U(e){const t=new URLSearchParams;return Y(K(t,e),e)}function K(e,t){const{sell:n,buy:r}=t;return n!=null&&n.amount&&e.append("sellAmount",n.amount),r!=null&&r.amount&&e.append("buyAmount",r.amount),e}function Y(e,t){const n=t.theme;return n?(b(n)?(e.append("palette",encodeURIComponent(JSON.stringify(n))),e.append("theme",n.baseTheme)):(e.append("palette","null"),e.append("theme",n)),e):(e.append("palette","null"),e)}const H="640px",X="450px",Z=20;function _(e,t){const{params:n,provider:r,listeners:s}=t;let c=r,d=n;const o=ee(n);e.innerHTML="",e.appendChild(o);const{contentWindow:p}=o;if(!p)throw console.error("Iframe does not contain a window",o),new Error("Iframe does not contain a window!");const h=[];h.push(te(p,n.appCode)),h.push(...re(o,n.height)),h.push(ne());const u=new x(window,s);let l=A(p,null,c);o.addEventListener("load",()=>O(p,d,c));const a=new Q(window,p);return{updateParams:i=>{d=i,O(p,d,c)},updateListeners:i=>u.updateListeners(i),updateProvider:i=>{c=i,l=A(p,l,i)},destroy:()=>{l.disconnect(),u.stopListeningIframe(),h.forEach(i=>window.removeEventListener("message",i)),a.stopListening(),e.removeChild(o)}}}function A(e,t,n){t&&t.disconnect();const r=t||new $(e);return n&&r.onConnect(n),r}function ee(e){const{width:t=X,height:n=H}=e,r=document.createElement("iframe");return r.src=z(e),r.width=t,r.height=n,r.style.border="0",r.allow="clipboard-read; clipboard-write",r}function O(e,t,n){const r=!!n,s=N(t),c=U(t).toString(),{theme:d,...o}=t;g(e,T.UPDATE_PARAMS,{urlParams:{pathname:s,search:c},appParams:o,hasProvider:r})}function te(e,t){return m(window,w.ACTIVATE,()=>{g(e,T.UPDATE_APP_DATA,{metaData:t?{appCode:t}:void 0})})}function ne(){return m(window,w.INTERCEPT_WINDOW_OPEN,({href:e,rel:t,target:n})=>{const r=e.toString();if(!r.startsWith("http")&&r.match(/^[a-zA-Z0-9]+:\/\//)){window.open(r,n,t);return}})}function re(e,t=H){return[m(window,w.UPDATE_HEIGHT,n=>{e.style.height=n.height?`${n.height+Z}px`:t}),m(window,w.SET_FULL_HEIGHT,({isUpToSmall:n})=>{e.style.height=n?t:`${document.body.offsetHeight}px`})]}const se=Object.values(P);function ie(e,t,n){if(v(e)){const r=e[n];return C(r)?r[t]:r}if(C(e)){const r=e[t];return v(r)?r[n]:r}return e}function v(e){return typeof e!="object"?!1:Object.keys(e).every(t=>se.includes(t))}const oe=/^\d+$/;function C(e){return typeof e!="object"?!1:Object.keys(e).every(t=>typeof t=="number"||oe.test(t))}function ae(e){const{params:t,provider:n,listeners:r}=e,[s,c]=f.useState(null),d=f.useRef(null),o=f.useRef(n),p=f.useRef(r),h=f.useRef(null),u=f.useRef(null),l=f.useCallback((a,i)=>{try{console.log(`[WIDGET] ${a}`),i()}catch(W){const S=`Error ${a.toLowerCase()}`;console.error(`[WIDGET] ${S}`,W),c({message:S,error:W})}},[c]);return f.useEffect(()=>()=>{d.current=null,o.current=void 0,p.current=void 0;const a=u.current;a&&(l("💥 Destroy widget",()=>a.destroy()),u.current=null)},[]),f.useEffect(()=>{if(!h.current||JSON.stringify(d.current)===JSON.stringify(t))return;const a=h.current,i=u.current;d.current=t,i===null?l("Creating a new widget",()=>{u.current=_(a,{params:t,provider:o.current,listeners:r}),p.current=r}):l("Updating the widget",()=>i.updateParams(t))},[t]),f.useEffect(()=>{if(!u.current||o.current===n)return;o.current=n;const a=h.current;a&&l("Updating the provider",()=>{var i;(i=u.current)==null||i.destroy(),u.current=_(a,{params:t,provider:o.current,listeners:r})})},[n]),f.useEffect(()=>{if(!u.current||p.current===r)return;const a=u.current;l("Updating the listeners",()=>a.updateListeners(r))},[r]),s?R.jsxs("div",{style:{color:"#ff3a3a"},children:[s.message,s.error.message&&R.jsx("pre",{style:{whiteSpace:"pre-wrap",fontSize:"0.75em"},children:s.error.message})]}):R.jsx("div",{ref:h,style:{width:"100%"}})}exports.CowSwapWidget=ae;exports.TradeType=P;exports.WIDGET_PALETTE_COLORS=G;exports.WidgetMethodsEmit=w;exports.WidgetMethodsListen=T;exports.createCowSwapWidget=_;exports.isCowSwapWidgetPalette=b;exports.isPerNetworkConfig=C;exports.isPerTradeTypeConfig=v;exports.listenToMessageFromWindow=m;exports.postMessageToWindow=g;exports.resolveFlexibleConfig=ie;exports.stopListeningToMessageFromWindow=D;exports.stopListeningWindowListener=y;
package/index.mjs CHANGED
@@ -1,30 +1,30 @@
1
- var H = Object.defineProperty;
2
- var V = (e, n, t) => n in e ? H(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t;
3
- var f = (e, n, t) => (V(e, typeof n != "symbol" ? n + "" : n, t), t);
4
- import { jsxs as b, jsx as v } from "react/jsx-runtime";
5
- import { useState as N, useRef as m, useCallback as F, useEffect as P } from "react";
1
+ var U = Object.defineProperty;
2
+ var H = (e, t, n) => t in e ? U(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var l = (e, t, n) => (H(e, typeof t != "symbol" ? t + "" : t, n), n);
4
+ import { jsxs as V, jsx as I } from "react/jsx-runtime";
5
+ import { useState as F, useRef as m, useCallback as k, useEffect as P } from "react";
6
6
  class M {
7
7
  constructor() {
8
- f(this, "subscriptions", {});
8
+ l(this, "subscriptions", {});
9
9
  }
10
- on(n) {
11
- const { event: t, handler: r } = n;
12
- this.subscriptions[t] || (this.subscriptions[t] = []), this.subscriptions[t].push(r);
10
+ on(t) {
11
+ const { event: n, handler: r } = t;
12
+ this.subscriptions[n] || (this.subscriptions[n] = []), this.subscriptions[n].push(r);
13
13
  }
14
- off(n) {
15
- const { event: t, handler: r } = n;
16
- this.subscriptions[t] && (this.subscriptions[t] = this.subscriptions[t].filter((s) => s !== r));
14
+ off(t) {
15
+ const { event: n, handler: r } = t;
16
+ this.subscriptions[n] && (this.subscriptions[n] = this.subscriptions[n].filter((s) => s !== r));
17
17
  }
18
- emit(n, t) {
19
- this.subscriptions[n] && this.subscriptions[n].forEach((r) => r(t));
18
+ emit(t, n) {
19
+ this.subscriptions[t] && this.subscriptions[t].forEach((r) => r(n));
20
20
  }
21
21
  }
22
- const W = "cowSwapWidget";
23
- function R(e, n, t) {
22
+ const L = "cowSwapWidget";
23
+ function R(e, t, n) {
24
24
  const s = {
25
- key: W,
26
- method: n,
27
- ...typeof t == "object" ? t : {}
25
+ key: L,
26
+ method: t,
27
+ ...typeof n == "object" ? n : {}
28
28
  };
29
29
  e.postMessage(
30
30
  s,
@@ -32,23 +32,23 @@ function R(e, n, t) {
32
32
  // TODO: Change to CoW specific origin in production. https://github.com/cowprotocol/cowswap/issues/3828
33
33
  );
34
34
  }
35
- function w(e, n, t) {
35
+ function w(e, t, n) {
36
36
  const r = (s) => {
37
- !k(s.data) || s.data.key !== W || s.data.method !== n || t(s.data);
37
+ !G(s.data) || s.data.key !== L || s.data.method !== t || n(s.data);
38
38
  };
39
39
  return e.addEventListener("message", r), r;
40
40
  }
41
- function k(e) {
41
+ function G(e) {
42
42
  return typeof e == "object" && e !== null && "key" in e && "method" in e && typeof e.key == "string" && typeof e.method == "string";
43
43
  }
44
- function G(e, n, t) {
45
- e.removeEventListener("message", t);
46
- }
47
- function L(e, n) {
44
+ function x(e, t, n) {
48
45
  e.removeEventListener("message", n);
49
46
  }
50
- var E = /* @__PURE__ */ ((e) => (e.ACTIVATE = "ACTIVATE", e.UPDATE_HEIGHT = "UPDATE_HEIGHT", e.SET_FULL_HEIGHT = "SET_FULL_HEIGHT", e.EMIT_COW_EVENT = "EMIT_COW_EVENT", e.PROVIDER_RPC_REQUEST = "PROVIDER_RPC_REQUEST", e))(E || {}), g = /* @__PURE__ */ ((e) => (e.UPDATE_PARAMS = "UPDATE_PARAMS", e.UPDATE_APP_DATA = "UPDATE_APP_DATA", e.PROVIDER_RPC_RESPONSE = "PROVIDER_RPC_RESPONSE", e.PROVIDER_ON_EVENT = "PROVIDER_ON_EVENT", e))(g || {}), D = /* @__PURE__ */ ((e) => (e.SWAP = "swap", e.LIMIT = "limit", e.ADVANCED = "advanced", e))(D || {});
51
- const ae = [
47
+ function $(e, t) {
48
+ e.removeEventListener("message", t);
49
+ }
50
+ var E = /* @__PURE__ */ ((e) => (e.ACTIVATE = "ACTIVATE", e.UPDATE_HEIGHT = "UPDATE_HEIGHT", e.SET_FULL_HEIGHT = "SET_FULL_HEIGHT", e.EMIT_COW_EVENT = "EMIT_COW_EVENT", e.PROVIDER_RPC_REQUEST = "PROVIDER_RPC_REQUEST", e.INTERCEPT_WINDOW_OPEN = "INTERCEPT_WINDOW_OPEN", e))(E || {}), T = /* @__PURE__ */ ((e) => (e.UPDATE_PARAMS = "UPDATE_PARAMS", e.UPDATE_APP_DATA = "UPDATE_APP_DATA", e.PROVIDER_RPC_RESPONSE = "PROVIDER_RPC_RESPONSE", e.PROVIDER_ON_EVENT = "PROVIDER_ON_EVENT", e))(T || {}), g = /* @__PURE__ */ ((e) => (e.SWAP = "swap", e.LIMIT = "limit", e.ADVANCED = "advanced", e))(g || {});
51
+ const fe = [
52
52
  "primary",
53
53
  "background",
54
54
  "paper",
@@ -59,108 +59,108 @@ const ae = [
59
59
  "info",
60
60
  "success"
61
61
  ];
62
- class x {
63
- constructor(n, t = []) {
64
- f(this, "eventEmitter", new M());
65
- f(this, "listeners", []);
66
- f(this, "widgetListener");
67
- this.contentWindow = n, this.updateListeners(t), this.widgetListener = w(
62
+ class j {
63
+ constructor(t, n = []) {
64
+ l(this, "eventEmitter", new M());
65
+ l(this, "listeners", []);
66
+ l(this, "widgetListener");
67
+ this.contentWindow = t, this.updateListeners(n), this.widgetListener = w(
68
68
  this.contentWindow,
69
69
  E.EMIT_COW_EVENT,
70
70
  (r) => this.eventEmitter.emit(r.event, r.payload)
71
71
  );
72
72
  }
73
73
  stopListeningIframe() {
74
- L(this.contentWindow, this.widgetListener);
74
+ $(this.contentWindow, this.widgetListener);
75
75
  }
76
- updateListeners(n) {
77
- for (const t of this.listeners)
78
- this.eventEmitter.off(t);
79
- this.listeners = n || [];
80
- for (const t of this.listeners)
81
- this.eventEmitter.on(t);
76
+ updateListeners(t) {
77
+ for (const n of this.listeners)
78
+ this.eventEmitter.off(n);
79
+ this.listeners = t || [];
80
+ for (const n of this.listeners)
81
+ this.eventEmitter.on(n);
82
82
  }
83
83
  }
84
- const $ = ["connect", "disconnect", "close", "chainChanged", "accountsChanged"];
85
- class Q {
84
+ const Q = ["connect", "disconnect", "close", "chainChanged", "accountsChanged"];
85
+ class B {
86
86
  /**
87
87
  * Creates an instance of IframeRpcProviderBridge.
88
88
  * @param iframeWidow - The iFrame window that will post up general RPC messages and to which the IframeRpcProviderBridge will forward the RPC result.
89
89
  * Also it will receive some special RPC events coming from the wallet, like connect/chainChanged,accountChanged
90
90
  */
91
- constructor(n) {
91
+ constructor(t) {
92
92
  /**
93
93
  * The Ethereum provider instance.
94
94
  * When is null the JSON-RPC bridge is disconnected from the Ethereum provider.
95
95
  * */
96
- f(this, "ethereumProvider", null);
96
+ l(this, "ethereumProvider", null);
97
97
  /** Stored JSON-RPC requests, to queue them when disconnected. */
98
- f(this, "requestWaitingForConnection", {});
99
- f(this, "processRpcCallFromWindow", ({ rpcRequest: n }) => {
98
+ l(this, "requestWaitingForConnection", {});
99
+ l(this, "processRpcCallFromWindow", ({ rpcRequest: t }) => {
100
100
  if (!this.ethereumProvider) {
101
- n.id && (this.requestWaitingForConnection[n.id] = n);
101
+ t.id && (this.requestWaitingForConnection[t.id] = t);
102
102
  return;
103
103
  }
104
- this.processRpcRequest(n);
104
+ this.processRpcRequest(t);
105
105
  });
106
- this.iframeWidow = n;
106
+ this.iframeWidow = t;
107
107
  }
108
108
  /**
109
109
  * Disconnects the JSON-RPC bridge from the Ethereum provider.
110
110
  */
111
111
  disconnect() {
112
- this.ethereumProvider = null, G(window, E.PROVIDER_RPC_REQUEST, this.processRpcCallFromWindow);
112
+ this.ethereumProvider = null, x(window, E.PROVIDER_RPC_REQUEST, this.processRpcCallFromWindow);
113
113
  }
114
114
  /**
115
115
  * Handles the 'connect' event and sets up event listeners for Ethereum provider events.
116
116
  * @param newProvider - The Ethereum provider to connect.
117
117
  */
118
- onConnect(n) {
119
- this.ethereumProvider ? this.disconnect() : w(window, E.PROVIDER_RPC_REQUEST, this.processRpcCallFromWindow), this.ethereumProvider = n, this.processPendingRequests(), $.forEach((t) => {
120
- n.on(t, (r) => this.onProviderEvent(t, r));
118
+ onConnect(t) {
119
+ this.ethereumProvider ? this.disconnect() : w(window, E.PROVIDER_RPC_REQUEST, this.processRpcCallFromWindow), this.ethereumProvider = t, this.processPendingRequests(), Q.forEach((n) => {
120
+ t.on(n, (r) => this.onProviderEvent(n, r));
121
121
  });
122
122
  }
123
123
  processPendingRequests() {
124
- Object.keys(this.requestWaitingForConnection).forEach((n) => {
125
- this.processRpcRequest(this.requestWaitingForConnection[n]);
124
+ Object.keys(this.requestWaitingForConnection).forEach((t) => {
125
+ this.processRpcRequest(this.requestWaitingForConnection[t]);
126
126
  }), this.requestWaitingForConnection = {};
127
127
  }
128
128
  /**
129
129
  * Processes a JSON-RPC request and sends appropriate response or error via the content window.
130
130
  * @param request - The JSON-RPC request to be processed.
131
131
  */
132
- processRpcRequest(n) {
133
- const { id: t, jsonrpc: r, method: s } = n;
134
- if (!this.ethereumProvider || !t)
132
+ processRpcRequest(t) {
133
+ const { id: n, jsonrpc: r, method: s } = t;
134
+ if (!this.ethereumProvider || !n)
135
135
  return;
136
- (s === "enable" ? this.ethereumProvider.enable() : this.ethereumProvider.request({ ...n, id: t })).then(
136
+ (s === "enable" ? this.ethereumProvider.enable() : this.ethereumProvider.request({ ...t, id: n })).then(
137
137
  (d) => this.forwardRpcResponseToIframe({
138
- rpcResponse: { jsonrpc: r, id: t, result: d }
138
+ rpcResponse: { jsonrpc: r, id: n, result: d }
139
139
  })
140
140
  ).catch(
141
141
  (d) => this.forwardRpcResponseToIframe({
142
- rpcResponse: { jsonrpc: r, id: t, error: d }
142
+ rpcResponse: { jsonrpc: r, id: n, error: d }
143
143
  })
144
144
  );
145
145
  }
146
- onProviderEvent(n, t) {
147
- R(this.iframeWidow, g.PROVIDER_ON_EVENT, {
148
- event: n,
149
- params: t
146
+ onProviderEvent(t, n) {
147
+ R(this.iframeWidow, T.PROVIDER_ON_EVENT, {
148
+ event: t,
149
+ params: n
150
150
  });
151
151
  }
152
152
  /**
153
153
  * Forward a JSON-RPC message to the content window.
154
154
  */
155
- forwardRpcResponseToIframe(n) {
156
- R(this.iframeWidow, g.PROVIDER_RPC_RESPONSE, n);
155
+ forwardRpcResponseToIframe(t) {
156
+ R(this.iframeWidow, T.PROVIDER_RPC_RESPONSE, t);
157
157
  }
158
158
  }
159
- class B {
160
- constructor(n, t) {
161
- f(this, "forwardSdkMessage");
162
- this.appWindow = n, this.iframeWidow = t, this.forwardSdkMessage = (r) => {
163
- q(r.data) && r.origin !== window.location.origin && (J(r.data) ? this.appWindow.parent.postMessage(r.data, "*") : j(r.data) && this.iframeWidow.postMessage(r.data, "*"));
159
+ class q {
160
+ constructor(t, n) {
161
+ l(this, "forwardSdkMessage");
162
+ this.appWindow = t, this.iframeWidow = n, this.forwardSdkMessage = (r) => {
163
+ J(r.data) && r.origin !== window.location.origin && (z(r.data) ? this.appWindow.parent.postMessage(r.data, "*") : K(r.data) && this.iframeWidow.postMessage(r.data, "*"));
164
164
  }, this.startListening();
165
165
  }
166
166
  startListening() {
@@ -170,79 +170,79 @@ class B {
170
170
  this.appWindow.removeEventListener("message", this.forwardSdkMessage);
171
171
  }
172
172
  }
173
- function q(e) {
173
+ function J(e) {
174
174
  return typeof e == "object" && e !== null && "id" in e && typeof e.id == "string";
175
175
  }
176
- function J(e) {
176
+ function z(e) {
177
177
  return "method" in e && typeof e.method == "string" && "params" in e && "env" in e && typeof e.env == "object" && e.env !== null && "sdkVersion" in e.env;
178
178
  }
179
- function j(e) {
180
- return "success" in e && typeof e.success == "boolean" && "version" in e && typeof e.version == "string";
181
- }
182
179
  function K(e) {
183
- return !!(e && typeof e == "object");
180
+ return "success" in e && typeof e.success == "boolean" && "version" in e && typeof e.version == "string";
184
181
  }
185
- const A = "_";
186
182
  function Y(e) {
187
- const n = typeof e.baseUrl == "string" ? e.baseUrl : "https://swap.cow.fi", t = O(e);
188
- return n + "/#" + t + "?" + y(e);
183
+ return !!(e && typeof e == "object");
189
184
  }
190
- function O(e) {
191
- const { chainId: n = 1, sell: t, buy: r, tradeType: s = D.SWAP } = e, c = [(t == null ? void 0 : t.asset) || A, (r == null ? void 0 : r.asset) || A].map(encodeURIComponent).join("/");
192
- return `/${n}/widget/${s}/${c}`;
185
+ const C = "_";
186
+ function X(e) {
187
+ const t = typeof e.baseUrl == "string" ? e.baseUrl : "https://swap.cow.fi", n = y(e);
188
+ return t + "/#" + n + "?" + N(e);
193
189
  }
194
190
  function y(e) {
195
- const n = new URLSearchParams();
196
- return X(z(n, e), e);
191
+ const { chainId: t = 1, sell: n, buy: r, tradeType: s = g.SWAP } = e, c = [(n == null ? void 0 : n.asset) || C, (r == null ? void 0 : r.asset) || C].map(encodeURIComponent).join("/");
192
+ return `/${t}/widget/${s}/${c}`;
193
+ }
194
+ function N(e) {
195
+ const t = new URLSearchParams();
196
+ return ee(Z(t, e), e);
197
197
  }
198
- function z(e, n) {
199
- const { sell: t, buy: r } = n;
200
- return t != null && t.amount && e.append("sellAmount", t.amount), r != null && r.amount && e.append("buyAmount", r.amount), e;
198
+ function Z(e, t) {
199
+ const { sell: n, buy: r } = t;
200
+ return n != null && n.amount && e.append("sellAmount", n.amount), r != null && r.amount && e.append("buyAmount", r.amount), e;
201
201
  }
202
- function X(e, n) {
203
- const t = n.theme;
204
- return t ? (K(t) ? (e.append("palette", encodeURIComponent(JSON.stringify(t))), e.append("theme", t.baseTheme)) : (e.append("palette", "null"), e.append("theme", t)), e) : (e.append("palette", "null"), e);
202
+ function ee(e, t) {
203
+ const n = t.theme;
204
+ return n ? (Y(n) ? (e.append("palette", encodeURIComponent(JSON.stringify(n))), e.append("theme", n.baseTheme)) : (e.append("palette", "null"), e.append("theme", n)), e) : (e.append("palette", "null"), e);
205
205
  }
206
- const U = "640px", Z = "450px", ee = 20;
207
- function I(e, n) {
208
- const { params: t, provider: r, listeners: s } = n;
209
- let c = r, d = t;
210
- const o = te(t);
206
+ const b = "640px", te = "450px", ne = 20;
207
+ function A(e, t) {
208
+ const { params: n, provider: r, listeners: s } = t;
209
+ let c = r, d = n;
210
+ const o = re(n);
211
211
  e.innerHTML = "", e.appendChild(o);
212
212
  const { contentWindow: p } = o;
213
213
  if (!p)
214
214
  throw console.error("Iframe does not contain a window", o), new Error("Iframe does not contain a window!");
215
- const l = [];
216
- l.push(ne(p, t.appCode)), l.push(...re(o, t.height));
217
- const u = new x(window, s);
215
+ const f = [];
216
+ f.push(se(p, n.appCode)), f.push(...oe(o, n.height)), f.push(ie());
217
+ const u = new j(window, s);
218
218
  let h = S(p, null, c);
219
- o.addEventListener("load", () => C(p, d, c));
220
- const a = new B(window, p);
219
+ o.addEventListener("load", () => W(p, d, c));
220
+ const a = new q(window, p);
221
221
  return {
222
222
  updateParams: (i) => {
223
- d = i, C(p, d, c);
223
+ d = i, W(p, d, c);
224
224
  },
225
225
  updateListeners: (i) => u.updateListeners(i),
226
226
  updateProvider: (i) => {
227
227
  c = i, h = S(p, h, i);
228
228
  },
229
229
  destroy: () => {
230
- h.disconnect(), u.stopListeningIframe(), l.forEach((i) => window.removeEventListener("message", i)), a.stopListening(), e.removeChild(o);
230
+ h.disconnect(), u.stopListeningIframe(), f.forEach((i) => window.removeEventListener("message", i)), a.stopListening(), e.removeChild(o);
231
231
  }
232
232
  };
233
233
  }
234
- function S(e, n, t) {
235
- n && n.disconnect();
236
- const r = n || new Q(e);
237
- return t && r.onConnect(t), r;
234
+ function S(e, t, n) {
235
+ t && t.disconnect();
236
+ const r = t || new B(e);
237
+ return n && r.onConnect(n), r;
238
238
  }
239
- function te(e) {
240
- const { width: n = Z, height: t = U } = e, r = document.createElement("iframe");
241
- return r.src = Y(e), r.width = n, r.height = t, r.style.border = "0", r;
239
+ function re(e) {
240
+ const { width: t = te, height: n = b } = e, r = document.createElement("iframe");
241
+ return r.src = X(e), r.width = t, r.height = n, r.style.border = "0", r.allow = "clipboard-read; clipboard-write", r;
242
242
  }
243
- function C(e, n, t) {
244
- const r = !!t, s = O(n), c = y(n).toString(), { theme: d, ...o } = n;
245
- R(e, g.UPDATE_PARAMS, {
243
+ function W(e, t, n) {
244
+ const r = !!n, s = y(t), c = N(t).toString(), { theme: d, ...o } = t;
245
+ R(e, T.UPDATE_PARAMS, {
246
246
  urlParams: {
247
247
  pathname: s,
248
248
  search: c
@@ -251,32 +251,59 @@ function C(e, n, t) {
251
251
  hasProvider: r
252
252
  });
253
253
  }
254
- function ne(e, n) {
255
- const t = w(window, E.ACTIVATE, () => {
256
- L(window, t), R(e, g.UPDATE_APP_DATA, {
257
- metaData: n ? { appCode: n } : void 0
254
+ function se(e, t) {
255
+ return w(window, E.ACTIVATE, () => {
256
+ R(e, T.UPDATE_APP_DATA, {
257
+ metaData: t ? { appCode: t } : void 0
258
258
  });
259
259
  });
260
- return t;
261
260
  }
262
- function re(e, n = U) {
261
+ function ie() {
262
+ return w(window, E.INTERCEPT_WINDOW_OPEN, ({ href: e, rel: t, target: n }) => {
263
+ const r = e.toString();
264
+ if (!r.startsWith("http") && r.match(/^[a-zA-Z0-9]+:\/\//)) {
265
+ window.open(r, n, t);
266
+ return;
267
+ }
268
+ });
269
+ }
270
+ function oe(e, t = b) {
263
271
  return [
264
- w(window, E.UPDATE_HEIGHT, (t) => {
265
- e.style.height = t.height ? `${t.height + ee}px` : n;
272
+ w(window, E.UPDATE_HEIGHT, (n) => {
273
+ e.style.height = n.height ? `${n.height + ne}px` : t;
266
274
  }),
267
- w(window, E.SET_FULL_HEIGHT, ({ isUpToSmall: t }) => {
268
- e.style.height = t ? n : `${document.body.offsetHeight}px`;
275
+ w(window, E.SET_FULL_HEIGHT, ({ isUpToSmall: n }) => {
276
+ e.style.height = n ? t : `${document.body.offsetHeight}px`;
269
277
  })
270
278
  ];
271
279
  }
272
- function ce(e) {
273
- const { params: n, provider: t, listeners: r } = e, [s, c] = N(null), d = m(null), o = m(t), p = m(r), l = m(null), u = m(null), h = F(
280
+ const ae = Object.values(g);
281
+ function he(e, t, n) {
282
+ if (O(e)) {
283
+ const r = e[n];
284
+ return D(r) ? r[t] : r;
285
+ }
286
+ if (D(e)) {
287
+ const r = e[t];
288
+ return O(r) ? r[n] : r;
289
+ }
290
+ return e;
291
+ }
292
+ function O(e) {
293
+ return typeof e != "object" ? !1 : Object.keys(e).every((t) => ae.includes(t));
294
+ }
295
+ const ce = /^\d+$/;
296
+ function D(e) {
297
+ return typeof e != "object" ? !1 : Object.keys(e).every((t) => typeof t == "number" || ce.test(t));
298
+ }
299
+ function le(e) {
300
+ const { params: t, provider: n, listeners: r } = e, [s, c] = F(null), d = m(null), o = m(n), p = m(r), f = m(null), u = m(null), h = k(
274
301
  (a, i) => {
275
302
  try {
276
303
  console.log(`[WIDGET] ${a}`), i();
277
- } catch (T) {
278
- const _ = `Error ${a.toLowerCase()}`;
279
- console.error(`[WIDGET] ${_}`, T), c({ message: _, error: T });
304
+ } catch (_) {
305
+ const v = `Error ${a.toLowerCase()}`;
306
+ console.error(`[WIDGET] ${v}`, _), c({ message: v, error: _ });
280
307
  }
281
308
  },
282
309
  [c]
@@ -286,41 +313,44 @@ function ce(e) {
286
313
  const a = u.current;
287
314
  a && (h("💥 Destroy widget", () => a.destroy()), u.current = null);
288
315
  }, []), P(() => {
289
- if (!l.current || JSON.stringify(d.current) === JSON.stringify(n))
316
+ if (!f.current || JSON.stringify(d.current) === JSON.stringify(t))
290
317
  return;
291
- const a = l.current, i = u.current;
292
- d.current = n, i === null ? h("Creating a new widget", () => {
293
- u.current = I(a, { params: n, provider: o.current, listeners: r }), p.current = r;
294
- }) : h("Updating the widget", () => i.updateParams(n));
295
- }, [n]), P(() => {
296
- if (!u.current || o.current === t)
318
+ const a = f.current, i = u.current;
319
+ d.current = t, i === null ? h("Creating a new widget", () => {
320
+ u.current = A(a, { params: t, provider: o.current, listeners: r }), p.current = r;
321
+ }) : h("Updating the widget", () => i.updateParams(t));
322
+ }, [t]), P(() => {
323
+ if (!u.current || o.current === n)
297
324
  return;
298
- o.current = t;
299
- const a = l.current;
325
+ o.current = n;
326
+ const a = f.current;
300
327
  a && h("Updating the provider", () => {
301
328
  var i;
302
- (i = u.current) == null || i.destroy(), u.current = I(a, { params: n, provider: o.current, listeners: r });
329
+ (i = u.current) == null || i.destroy(), u.current = A(a, { params: t, provider: o.current, listeners: r });
303
330
  });
304
- }, [t]), P(() => {
331
+ }, [n]), P(() => {
305
332
  if (!u.current || p.current === r)
306
333
  return;
307
334
  const a = u.current;
308
335
  h("Updating the listeners", () => a.updateListeners(r));
309
- }, [r]), s ? /* @__PURE__ */ b("div", { style: { color: "#ff3a3a" }, children: [
336
+ }, [r]), s ? /* @__PURE__ */ V("div", { style: { color: "#ff3a3a" }, children: [
310
337
  s.message,
311
- s.error.message && /* @__PURE__ */ v("pre", { style: { whiteSpace: "pre-wrap", fontSize: "0.75em" }, children: s.error.message })
312
- ] }) : /* @__PURE__ */ v("div", { ref: l, style: { width: "100%" } });
338
+ s.error.message && /* @__PURE__ */ I("pre", { style: { whiteSpace: "pre-wrap", fontSize: "0.75em" }, children: s.error.message })
339
+ ] }) : /* @__PURE__ */ I("div", { ref: f, style: { width: "100%" } });
313
340
  }
314
341
  export {
315
- ce as CowSwapWidget,
316
- D as TradeType,
317
- ae as WIDGET_PALETTE_COLORS,
342
+ le as CowSwapWidget,
343
+ g as TradeType,
344
+ fe as WIDGET_PALETTE_COLORS,
318
345
  E as WidgetMethodsEmit,
319
- g as WidgetMethodsListen,
320
- I as createCowSwapWidget,
321
- K as isCowSwapWidgetPalette,
346
+ T as WidgetMethodsListen,
347
+ A as createCowSwapWidget,
348
+ Y as isCowSwapWidgetPalette,
349
+ D as isPerNetworkConfig,
350
+ O as isPerTradeTypeConfig,
322
351
  w as listenToMessageFromWindow,
323
352
  R as postMessageToWindow,
324
- G as stopListeningToMessageFromWindow,
325
- L as stopListeningWindowListener
353
+ he as resolveFlexibleConfig,
354
+ x as stopListeningToMessageFromWindow,
355
+ $ as stopListeningWindowListener
326
356
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cowprotocol/widget-react",
3
- "version": "0.9.1",
3
+ "version": "0.9.3",
4
4
  "type": "commonjs",
5
5
  "description": "CoW Swap Widget Library. Allows you to easily embed a CoW Swap widget on your React application.",
6
6
  "main": "index.js",
@@ -22,6 +22,6 @@
22
22
  "react"
23
23
  ],
24
24
  "dependencies": {
25
- "@cowprotocol/widget-lib": "^0.11.1"
25
+ "@cowprotocol/widget-lib": "^0.13.2"
26
26
  }
27
27
  }