@cowprotocol/hook-dapp-lib 1.7.1 → 2.0.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.
package/index.mjs DELETED
@@ -1,599 +0,0 @@
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
- class C {
5
- constructor(r) {
6
- this.key = r;
7
- }
8
- postMessageToWindow(r, e, o) {
9
- const c = typeof o == "object" ? o : {}, l = {
10
- key: this.key,
11
- method: e,
12
- ...c
13
- };
14
- r.postMessage(
15
- l,
16
- "*"
17
- // TODO: Change to CoW specific origin in production. https://github.com/cowprotocol/cowswap/issues/3828
18
- );
19
- }
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
- };
24
- return r.addEventListener("message", c), c;
25
- }
26
- stopListeningToMessageFromWindow(r, e, o) {
27
- r.removeEventListener("message", o);
28
- }
29
- stopListeningWindowListener(r, e) {
30
- r.removeEventListener("message", e);
31
- }
32
- }
33
- function H(t) {
34
- return typeof t == "object" && t !== null && "key" in t && "method" in t && typeof t.key == "string" && typeof t.method == "string";
35
- }
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
- "cowSwapIframeRpcProviderTransport"
39
- ), K = [];
40
- window.addEventListener("eip6963:announceProvider", (t) => {
41
- const r = t;
42
- K.push(r.detail);
43
- });
44
- var R = { exports: {} };
45
- (function(t) {
46
- var r = Object.prototype.hasOwnProperty, e = "~";
47
- function o() {
48
- }
49
- Object.create && (o.prototype = /* @__PURE__ */ Object.create(null), new o().__proto__ || (e = !1));
50
- function c(p, i, n) {
51
- this.fn = p, this.context = i, this.once = n || !1;
52
- }
53
- function l(p, i, n, a, m) {
54
- if (typeof n != "function")
55
- throw new TypeError("The listener must be a function");
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;
58
- }
59
- function y(p, i) {
60
- --p._eventsCount === 0 ? p._events = new o() : delete p._events[i];
61
- }
62
- function u() {
63
- this._events = new o(), this._eventsCount = 0;
64
- }
65
- u.prototype.eventNames = function() {
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;
77
- return d;
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
- if (s.fn) {
86
- switch (s.once && this.removeListener(i, s.fn, void 0, !0), E) {
87
- case 1:
88
- return s.fn.call(s.context), !0;
89
- case 2:
90
- return s.fn.call(s.context, n), !0;
91
- case 3:
92
- return s.fn.call(s.context, n, a), !0;
93
- case 4:
94
- return s.fn.call(s.context, n, a, m), !0;
95
- case 5:
96
- return s.fn.call(s.context, n, a, m, f), !0;
97
- case 6:
98
- return s.fn.call(s.context, n, a, m, f, d), !0;
99
- }
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
- } else {
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
- case 1:
108
- s[h].fn.call(s[h].context);
109
- break;
110
- case 2:
111
- s[h].fn.call(s[h].context, n);
112
- break;
113
- case 3:
114
- s[h].fn.call(s[h].context, n, a);
115
- break;
116
- case 4:
117
- s[h].fn.call(s[h].context, n, a, m);
118
- break;
119
- default:
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);
123
- }
124
- }
125
- return !0;
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;
135
- var d = this._events[f];
136
- if (d.fn)
137
- d.fn === n && (!m || d.once) && (!a || d.context === a) && y(this, f);
138
- else {
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);
142
- }
143
- return 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;
147
- }, u.prototype.off = u.prototype.removeListener, u.prototype.addListener = u.prototype.on, u.prefixed = e, u.EventEmitter = u, t.exports = u;
148
- })(R);
149
- var G = R.exports;
150
- const B = 6e5, Y = "2.0";
151
- function z() {
152
- return Math.floor(Math.random() * Number.MAX_SAFE_INTEGER);
153
- }
154
- class j extends Error {
155
- constructor(e, o) {
156
- super(`${e}: ${o}`);
157
- w(this, "isRpcError", !0);
158
- w(this, "code");
159
- w(this, "reason");
160
- this.code = e, this.reason = o;
161
- }
162
- }
163
- class Q extends G.EventEmitter {
164
- constructor({
165
- timeoutMilliseconds: e = B,
166
- eventSource: o = window,
167
- eventTarget: c = window.parent
168
- } = {}) {
169
- super();
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
- /**
178
- * Handle a Rpc Request
179
- */
180
- w(this, "handleRpcRequests", ({ rpcResponse: e }) => {
181
- if (e.id === void 0 || e.id === null)
182
- return;
183
- const o = this.completers["" + e.id];
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
- });
186
- this.timeoutMilliseconds = e, this.eventSource = o, this.eventTarget = c, k.listenToMessageFromWindow(
187
- this.eventSource,
188
- T.PROVIDER_RPC_RESPONSE,
189
- (l) => {
190
- this.handleRpcRequests(l);
191
- }
192
- ), k.listenToMessageFromWindow(
193
- this.eventSource,
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);
203
- }
204
- );
205
- }
206
- request({ method: e, params: o }) {
207
- return this.send(e, o);
208
- }
209
- isConnected() {
210
- return !0;
211
- }
212
- /**
213
- * Differentiate this provider from other providers by providing an isIFrame property that always returns true.
214
- */
215
- get isIFrame() {
216
- return !0;
217
- }
218
- /**
219
- * Always return this for currentProvider.
220
- */
221
- get currentProvider() {
222
- return this;
223
- }
224
- /**
225
- * Helper method that handles transport and request wrapping
226
- * @param method method to execute
227
- * @param params params to pass the method
228
- */
229
- async execute(e, o) {
230
- const c = z(), l = {
231
- jsonrpc: Y,
232
- id: c,
233
- method: e,
234
- params: o
235
- }, y = new Promise(
236
- (u, p) => this.completers[c] = { resolve: u, reject: p }
237
- );
238
- return k.postMessageToWindow(this.eventTarget, T.PROVIDER_RPC_REQUEST, {
239
- rpcRequest: l
240
- }), setTimeout(() => {
241
- this.completers[c] && (this.completers[c].reject(new Error("Request timed out. Please try again and submit it faster.")), delete this.completers[c]);
242
- }, this.timeoutMilliseconds), y;
243
- }
244
- async send(e, o) {
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;
249
- }
250
- /**
251
- * Request the parent window to enable access to the user's web3 provider. Return accounts list immediately if already enabled.
252
- */
253
- async enable() {
254
- if (this.enabled === null) {
255
- const e = this.enabled = this.send("enable", []).catch((o) => {
256
- throw this.enabled === e && (this.enabled = null), o;
257
- });
258
- }
259
- return this.enabled;
260
- }
261
- /**
262
- * Backwards compatibility method for web3.
263
- * @param payload payload to send to the provider
264
- * @param callback callback to be called when the provider resolves
265
- */
266
- async sendAsync(e, o) {
267
- try {
268
- const c = await this.execute(e.method, e.params);
269
- o(null, c);
270
- } catch (c) {
271
- o(c, null);
272
- }
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
- }
285
- handleOnEvent(e) {
286
- const o = e.params;
287
- switch (e.event) {
288
- case "notification":
289
- this.emitNotification(o);
290
- break;
291
- case "connect":
292
- this.emitConnect(o);
293
- break;
294
- case "disconnect":
295
- this.emitDisconnect(o);
296
- break;
297
- case "chainChanged":
298
- this.emitChainChanged(o);
299
- break;
300
- case "accountsChanged":
301
- this.emitAccountsChanged(o);
302
- break;
303
- case "message":
304
- this.emitMessage(o);
305
- break;
306
- case "networkChanged":
307
- this.emitNetworkChanged(o);
308
- break;
309
- case "close":
310
- this.emitClose(o);
311
- break;
312
- default:
313
- console.warn(`[WidgetEthereumProvider] Unknown event type: ${e.event}`);
314
- break;
315
- }
316
- }
317
- emitNotification(e) {
318
- this.emit("notification", e);
319
- }
320
- emitConnect(e) {
321
- this.enabled === null && (this.enabled = Promise.resolve([])), this.emit("connect", e);
322
- }
323
- /**
324
- * @deprecated See https://eips.ethereum.org/EIPS/eip-1193
325
- */
326
- emitClose(e) {
327
- Array.isArray(e) && e.length === 2 ? this.emit("close", e[0], e[1]) : this.emit("close");
328
- }
329
- emitDisconnect(e) {
330
- this.emit("disconnect", e);
331
- }
332
- emitChainChanged(e) {
333
- this.emit("chainChanged", e);
334
- }
335
- /**
336
- * @deprecated See https://eips.ethereum.org/EIPS/eip-1193
337
- */
338
- emitNetworkChanged(e) {
339
- this.emit("networkChanged", e);
340
- }
341
- emitAccountsChanged(e) {
342
- this.enabled = Promise.resolve(e), this.emit("accountsChanged", e);
343
- }
344
- emitMessage(e) {
345
- this.emit("message", e);
346
- }
347
- }
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))(_ || {});
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 };
353
- }
354
- function X() {
355
- return {
356
- addHook(t) {
357
- O.postMessageToWindow(parent, _.ADD_HOOK, t);
358
- },
359
- editHook(t) {
360
- O.postMessageToWindow(parent, _.EDIT_HOOK, t);
361
- },
362
- setSellToken(t) {
363
- O.postMessageToWindow(parent, _.SET_SELL_TOKEN, t);
364
- },
365
- setBuyToken(t) {
366
- O.postMessageToWindow(parent, _.SET_BUY_TOKEN, t);
367
- }
368
- };
369
- }
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 = {
372
- type: "INTERNAL",
373
- name: "Build your own hook",
374
- descriptionShort: "Call any smart contract with your own parameters",
375
- 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.",
376
- image: "https://raw.githubusercontent.com/cowprotocol/cowswap/refs/heads/develop/apps/cowswap-frontend/src/modules/hooksStore/dapps/BuildHookApp/build.png",
377
- version: "v0.1.0",
378
- website: "https://docs.cow.fi/cow-protocol/tutorials/hook-dapp"
379
- }, S = {
380
- type: "INTERNAL",
381
- name: "Claim GNO from validators",
382
- descriptionShort: "Withdraw rewards from your Gnosis validators.",
383
- 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.",
384
- image: "https://raw.githubusercontent.com/cowprotocol/cowswap/897ce91ca60a6b2d3823e6a002c3bf64c5384afe/libs/assets/src/cow-swap/network-gnosis-chain-logo.svg",
385
- version: "v0.1.1",
386
- website: "https://www.gnosis.io",
387
- conditions: {
388
- supportedNetworks: [
389
- 100
390
- ],
391
- position: "pre"
392
- }
393
- }, I = {
394
- type: "INTERNAL",
395
- name: "Permit a token",
396
- descriptionShort: "Infinite permit an address to spend one token on your behalf.",
397
- 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.",
398
- image: "https://raw.githubusercontent.com/cowprotocol/cowswap/refs/heads/develop/apps/cowswap-frontend/src/modules/hooksStore/dapps/PermitHookApp/icon.png",
399
- version: "v0.1.0",
400
- website: "https://docs.cow.fi/cow-protocol/tutorials/hook-dapp",
401
- conditions: {
402
- walletCompatibility: [
403
- "EOA"
404
- ],
405
- supportedNetworks: [
406
- 11155111
407
- ]
408
- }
409
- }, N = {
410
- type: "INTERNAL",
411
- name: "Claim COW Airdrop",
412
- descriptionShort: "Retrieve COW tokens before or after a swap.",
413
- 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.",
414
- image: "https://raw.githubusercontent.com/cowprotocol/cowswap/897ce91ca60a6b2d3823e6a002c3bf64c5384afe/apps/cowswap-frontend/src/modules/hooksStore/dapps/AirdropHookApp/airdrop.svg",
415
- version: "v0.1.0",
416
- website: "https://github.com/bleu/cow-airdrop-contract-deployer",
417
- conditions: {
418
- supportedNetworks: [
419
- 11155111
420
- ]
421
- }
422
- }, P = {
423
- name: "CoW AMM Withdraw Liquidity",
424
- type: "IFRAME",
425
- descriptionShort: "Remove liquidity from a CoW AMM pool before the swap",
426
- 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.",
427
- version: "0.0.1",
428
- website: "https://balancer.fi/pools/cow",
429
- image: "https://cow-hooks-dapps-withdraw-pool.vercel.app/icon.png",
430
- url: "https://cow-hooks-dapps-withdraw-pool.vercel.app/",
431
- conditions: {
432
- position: "pre",
433
- walletCompatibility: [
434
- "EOA"
435
- ],
436
- smartContractWalletSupported: !1
437
- }
438
- }, D = {
439
- type: "IFRAME",
440
- name: "Claim LlamaPay Vesting Hook",
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.",
442
- descriptionShort: "Claim your LlamaPay vesting contract funds",
443
- image: "https://cow-hooks-dapps-claim-vesting.vercel.app/llama-pay-icon.png",
444
- version: "0.1.0",
445
- website: "https://github.com/bleu/cow-hooks-dapps",
446
- url: "https://cow-hooks-dapps-claim-vesting.vercel.app",
447
- conditions: {
448
- supportedNetworks: [
449
- 1,
450
- 100,
451
- 42161
452
- ],
453
- walletCompatibility: [
454
- "EOA"
455
- ],
456
- smartContractWalletSupported: !1
457
- }
458
- }, L = {
459
- type: "IFRAME",
460
- name: "Create LlamaPay Vesting",
461
- descriptionShort: "Create a LlamaPay vesting contract",
462
- 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.",
463
- version: "0.1.0",
464
- website: "https://llamapay.io/vesting",
465
- image: "https://cow-hooks-dapps-create-vesting.vercel.app/llama-pay-icon.png",
466
- url: "https://cow-hooks-dapps-create-vesting.vercel.app",
467
- conditions: {
468
- position: "post",
469
- walletCompatibility: [
470
- "EOA"
471
- ],
472
- smartContractWalletSupported: !1,
473
- supportedNetworks: [
474
- 1,
475
- 100,
476
- 42161
477
- ]
478
- }
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,
544
- CLAIM_GNO_FROM_VALIDATORS: S,
545
- PERMIT_TOKEN: I,
546
- CLAIM_COW_AIRDROP: N,
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({
554
- __proto__: null,
555
- BUILD_CUSTOM_HOOK: M,
556
- CLAIM_COW_AIRDROP: N,
557
- CLAIM_GNO_FROM_VALIDATORS: S,
558
- CLAIM_LLAMAPAY_VESTING: D,
559
- COW_AMM_DEPOSIT: x,
560
- COW_AMM_WITHDRAW: P,
561
- CREATE_LLAMAPAY_VESTING: L,
562
- PERMIT_TOKEN: I,
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(
572
- (o, c) => (o[c.id] = c, o),
573
- {}
574
- );
575
- return t.filter((o) => !!o.dappId).map((o) => {
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
- } : {
581
- hook: c,
582
- dapp: l || null
583
- };
584
- });
585
- }
586
- function ce(t, r = []) {
587
- return ie(t, ee.concat(r));
588
- }
589
- export {
590
- _ as CoWHookDappEvents,
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
599
- };
@@ -1,11 +0,0 @@
1
- import { WidgetEthereumProvider } from '@cowprotocol/iframe-transport';
2
- import { CoWHookDappActions, HookDappContext } from './types';
3
- interface CoWHookDappInit {
4
- onContext(context: HookDappContext): void;
5
- }
6
- export interface CoWHookDappHandler {
7
- actions: CoWHookDappActions;
8
- provider: WidgetEthereumProvider;
9
- }
10
- export declare function initCoWHookDapp({ onContext }: CoWHookDappInit): CoWHookDappHandler;
11
- export {};
package/types.d.ts DELETED
@@ -1,63 +0,0 @@
1
- import { ReactNode } from 'react';
2
- import { HookDappType, HookDappWalletCompatibility } from './consts';
3
- export interface CowHook {
4
- target: string;
5
- callData: string;
6
- gasLimit: string;
7
- dappId: string;
8
- }
9
- export interface HookDappConditions {
10
- position?: 'post' | 'pre';
11
- walletCompatibility?: HookDappWalletCompatibility[];
12
- supportedNetworks?: number[];
13
- }
14
- export interface CowHookCreation {
15
- hook: Omit<CowHook, 'dappId'>;
16
- recipientOverride?: string;
17
- }
18
- export interface TokenData {
19
- address: string;
20
- }
21
- export interface CowHookDetails extends CowHookCreation {
22
- hook: CowHook;
23
- uuid: string;
24
- }
25
- export interface CowHookToEdit extends CowHookCreation {
26
- uuid: string;
27
- }
28
- export interface CoWHookDappActions {
29
- addHook(payload: CowHookCreation): void;
30
- editHook(payload: CowHookToEdit): void;
31
- setSellToken(token: TokenData): void;
32
- setBuyToken(token: TokenData): void;
33
- }
34
- export interface HookDappOrderParams {
35
- kind: 'buy' | 'sell';
36
- validTo: number;
37
- sellTokenAddress: string;
38
- buyTokenAddress: string;
39
- receiver: string;
40
- sellAmount: string;
41
- buyAmount: string;
42
- }
43
- export interface HookDappContext {
44
- chainId: number;
45
- account?: string;
46
- orderParams: HookDappOrderParams | null;
47
- hookToEdit?: CowHookDetails;
48
- isSmartContract: boolean | undefined;
49
- isPreHook: boolean;
50
- isDarkMode: boolean;
51
- balancesDiff: Record<string, Record<string, string>>;
52
- }
53
- export interface HookDappBase {
54
- id: string;
55
- name: string;
56
- descriptionShort?: string;
57
- description?: ReactNode | string;
58
- type: HookDappType;
59
- version: string;
60
- website: string;
61
- image: string;
62
- conditions?: HookDappConditions;
63
- }
package/utils.d.ts DELETED
@@ -1,11 +0,0 @@
1
- import { CowHook, HookDappBase } from './types';
2
- type StrictCowHook = Omit<CowHook, 'dappId'> & {
3
- dappId?: string;
4
- };
5
- export interface HookToDappMatch {
6
- dapp: HookDappBase | null;
7
- hook: CowHook;
8
- }
9
- export declare function matchHooksToDapps(hooks: StrictCowHook[], dapps: HookDappBase[]): HookToDappMatch[];
10
- export declare function matchHooksToDappsRegistry(hooks: StrictCowHook[], additionalHookDapps?: HookDappBase[]): HookToDappMatch[];
11
- export {};