diff --git a/package.json b/package.json index 24dfa93d..aa259714 100644 --- a/package.json +++ b/package.json @@ -13,11 +13,8 @@ "prepare": "husky install" }, "dependencies": { - "@airswap/constants": "4.0.10", - "@airswap/libraries": "4.0.19", - "@airswap/metadata": "4.0.12", - "@airswap/types": "4.0.5", - "@airswap/utils": "4.0.8", + "@airswap/libraries": "^4.1.3", + "@airswap/metadata": "^4.1.1", "@craco/craco": "^6.2.0", "@fontsource/dm-mono": "^4.5.0", "@greypixel_/nicenumbers": "^0.0.18", diff --git a/src/features/transactions/swapEventSubscriber.ts b/src/features/transactions/swapEventSubscriber.ts index da291c51..b3004294 100644 --- a/src/features/transactions/swapEventSubscriber.ts +++ b/src/features/transactions/swapEventSubscriber.ts @@ -1,14 +1,14 @@ import { Wrapper } from "@airswap/libraries"; +import { getFullSwapERC20 } from "@airswap/utils"; import { Dispatch } from "@reduxjs/toolkit"; -import { Contract, Event as EthersEvent } from "ethers"; +import { BigNumber, Contract, Event as EthersEvent } from "ethers"; import { store } from "../../app/store"; import { notifyTransaction } from "../../components/Toasts/ToastController"; import { mineTransaction } from "./transactionActions"; import { getSenderWalletForWrapperSwapLog, - SwapEventArgs, } from "./transactionUtils"; import { LastLookTransaction } from "./transactionsSlice"; @@ -24,15 +24,15 @@ export default function subscribeToSwapEvents(params: { const _account = account.toLowerCase(); const wrapperAddress = Wrapper.getAddress(chainId) || ""; - const onSwap = async (...argsAndEvent: any[]) => { - // Listeners are called with all args first, then an event object. - const swapEvent: EthersEvent = argsAndEvent[argsAndEvent.length - 1]; - const args = swapEvent.args as unknown as SwapEventArgs; + const onSwap = async (nonce: BigNumber, signerWallet: string, swapEvent: EthersEvent) => { + const fullArgs = await getFullSwapERC20({ + nonce: nonce.toString(), signerWallet + }, await swapEvent.getTransaction()) if ( - args.senderWallet.toLowerCase() !== _account && - args.signerWallet.toLowerCase() !== _account && - (args.senderWallet.toLowerCase() !== wrapperAddress.toLowerCase() || + fullArgs.senderWallet.toLowerCase() !== _account && + fullArgs.signerWallet.toLowerCase() !== _account && + (fullArgs.senderWallet.toLowerCase() !== wrapperAddress.toLowerCase() || (await getSenderWalletForWrapperSwapLog(swapEvent)) !== _account) ) { // Ignore events that don't involve us. @@ -41,11 +41,11 @@ export default function subscribeToSwapEvents(params: { dispatch( mineTransaction({ - signerWallet: args.signerWallet, - nonce: args.nonce.toString(), + signerWallet, + nonce: nonce.toString(), hash: swapEvent.transactionHash, protocol: - args.signerWallet.toLowerCase() === _account + signerWallet.toLowerCase() === _account ? "last-look-erc20" : "request-for-quote-erc20", }) @@ -58,7 +58,7 @@ export default function subscribeToSwapEvents(params: { // Last look transactions don't have a nonce, but the const llTransaction = tx as LastLookTransaction; return ( - llTransaction.order.nonce === args.nonce.toString() && + llTransaction.order.nonce === nonce.toString() && llTransaction.order.signerWallet.toLowerCase() === _account ); } else { diff --git a/yarn.lock b/yarn.lock index f690cd97..657129a0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9,10 +9,10 @@ dependencies: "@openzeppelin/contracts" "^4.8.3" -"@airswap/constants@4.0.10", "@airswap/constants@^4.0.10": - version "4.0.10" - resolved "https://registry.yarnpkg.com/@airswap/constants/-/constants-4.0.10.tgz#b2bf2cdba8dff42414cc5151586bacbfcbc3f0fb" - integrity sha512-jGqSrVf4YWJbMaiDkWXtCIaIw+MHq/BqrmHpfynw1la7woRSjbbKK6aFjgoYGY/XcZTmMPG7COT+oApxXdXdXg== +"@airswap/constants@^4.1.0": + version "4.1.0" + resolved "https://registry.yarnpkg.com/@airswap/constants/-/constants-4.1.0.tgz#87c01d2d8c45819531a713e439049f7c1ee7c81a" + integrity sha512-oGwDIOooNE9usteVF1xrLhDXCiWSezAOFXkBmUyhnX3l+pq1mpdk4XW9Xu5vb2eTxLwuwQ7MyWF19HKpA+7sgQ== "@airswap/jsonrpc-client-websocket@0.0.1": version "0.0.1" @@ -21,22 +21,23 @@ dependencies: get-parameter-names "^0.3.0" -"@airswap/libraries@4.0.19": - version "4.0.19" - resolved "https://registry.yarnpkg.com/@airswap/libraries/-/libraries-4.0.19.tgz#44826c612fc092328ee846efabe8509c8b43f403" - integrity sha512-PeR58cVA3RDDCOGMpO0zslXwidOxF2dufswmeyTpvuGQSXgeBbpkNp+7SkcMbqvdcIWyMMMKwic45LwLES5GBg== +"@airswap/libraries@^4.1.3": + version "4.1.3" + resolved "https://registry.yarnpkg.com/@airswap/libraries/-/libraries-4.1.3.tgz#22ee476259c52a78197466482e8960fed77b875f" + integrity sha512-3pr1OqO4ruCS7zT7+8stM8ZrQBnN5Qgxi9cDHTvbJGE0XExjwR9eSzCkAKLJIsw5y/NvtEWLk0MaG9CIy3En+Q== dependencies: "@airswap/balances" "4.0.2" - "@airswap/constants" "4.0.10" + "@airswap/constants" "^4.1.0" "@airswap/jsonrpc-client-websocket" "0.0.1" "@airswap/maker-registry" "4.0.4" - "@airswap/registry" "4.0.3" + "@airswap/pool" "4.1.0" + "@airswap/registry" "4.1.0" "@airswap/staking" "4.0.3" "@airswap/swap" "4.0.4" - "@airswap/swap-erc20" "4.0.6" - "@airswap/types" "4.0.5" - "@airswap/utils" "4.0.8" - "@airswap/wrapper" "4.0.8" + "@airswap/swap-erc20" "4.1.0" + "@airswap/types" "^4.1.1" + "@airswap/utils" "^4.1.1" + "@airswap/wrapper" "4.1.0" browser-or-node "^2.1.1" ethers "^5.6.9" jayson "^4.0.0" @@ -50,24 +51,31 @@ dependencies: "@openzeppelin/contracts" "^4.8.1" -"@airswap/metadata@4.0.12": - version "4.0.12" - resolved "https://registry.yarnpkg.com/@airswap/metadata/-/metadata-4.0.12.tgz#b8902f55ecbe2b7cccc66f1aab497d548baa6e51" - integrity sha512-lma4zRy0N0zcyR1hb9UkmvK86NDnK+8t3ZbGN62+SYF8d6RiLuHnYh0yDo1ifiYyk+wse/oVe+ex7pUmmIxEyw== +"@airswap/metadata@^4.1.1": + version "4.1.1" + resolved "https://registry.yarnpkg.com/@airswap/metadata/-/metadata-4.1.1.tgz#f4d4be9f71aa2d0ca6da16f616c13f463c73b60d" + integrity sha512-qSvQ09+L7eM6nVh6cb6KviTD9lAaZqscuBLdRzCgwyYr1mwNbj2DTpaMjvsRBoEFZHy+lsaalU95rqFfeAEmnw== dependencies: - "@airswap/constants" "^4.0.10" - "@airswap/types" "^4.0.0" - "@airswap/wrapper" "4.0.8" + "@airswap/constants" "^4.1.0" + "@airswap/types" "^4.1.1" + "@airswap/wrapper" "4.1.0" "@openzeppelin/contracts" "^4.8.3" "@uniswap/token-lists" "^1.0.0-beta.24" axios "^0.21.4" ethers "^5.6.9" valid-url "^1.0.9" -"@airswap/registry@4.0.3": - version "4.0.3" - resolved "https://registry.yarnpkg.com/@airswap/registry/-/registry-4.0.3.tgz#c2ffa76864271b64275965c7badb85d118ee3cca" - integrity sha512-E+50VB5jFu56bjEPjDFVLbyFwJs5WphP+dNcDgxwbyHVgmWfgI2HD2wEXrY0OUjDHvtpqxfT2HkrDx2dypMBTQ== +"@airswap/pool@4.1.0": + version "4.1.0" + resolved "https://registry.yarnpkg.com/@airswap/pool/-/pool-4.1.0.tgz#7e84bb077351ba17fb498612bbf2f9fe07cc5647" + integrity sha512-gpH0VMc6PnbANr8LoTtTl/o2pPPzdS55gSAZQ+0so4cUkFJ8F9KpDD7FIXqwWe8yPYhLCiSxmeEbGuGHZH9mUA== + dependencies: + "@openzeppelin/contracts" "^4.8.3" + +"@airswap/registry@4.1.0": + version "4.1.0" + resolved "https://registry.yarnpkg.com/@airswap/registry/-/registry-4.1.0.tgz#b5c1202b5bae3e220efe6a9a065ca3153dc8515e" + integrity sha512-8SaMUdUOjxPnZxtBclDC68kw72thnVU3TYF6bQOMgV2u4FyZUMWhYJPIeSzbYlcdVgiI+V8syv28QrycaoSqtg== dependencies: "@openzeppelin/contracts" "^4.8.3" @@ -78,10 +86,10 @@ dependencies: "@openzeppelin/contracts" "^4.8.3" -"@airswap/swap-erc20@4.0.6": - version "4.0.6" - resolved "https://registry.yarnpkg.com/@airswap/swap-erc20/-/swap-erc20-4.0.6.tgz#96d96b98cf633e1b50c3cbe02fced3ab1ecb2b4b" - integrity sha512-8mcjTX/4l/M4+bXCya3z5AYUGK73YQhrfTYGIUIDrqesrkVcNg3W/++km3MdGg0WQwKWOPygwfdQ4OVFTX4fWg== +"@airswap/swap-erc20@4.1.0": + version "4.1.0" + resolved "https://registry.yarnpkg.com/@airswap/swap-erc20/-/swap-erc20-4.1.0.tgz#e546f6aabe490efc00f370ee487526b9f9a9083a" + integrity sha512-wLFxzz0JKiFet8BGYc0WTlD9DCe6TOCZEtravmddMkKEVgTSBrhnPUzekPx5o901dNByFIbRDm6IcbGXwQKGsQ== dependencies: "@openzeppelin/contracts" "^4.8.3" @@ -92,32 +100,33 @@ dependencies: "@openzeppelin/contracts" "^4.8.3" -"@airswap/types@4.0.5", "@airswap/types@^4.0.0", "@airswap/types@^4.0.4": - version "4.0.5" - resolved "https://registry.yarnpkg.com/@airswap/types/-/types-4.0.5.tgz#94ccc4f3a9e3c54573a88e62cd9b6670e23c77cc" - integrity sha512-X6ZGCFyKpYo608PM14jX3Co+UdzQzaNPgceSfCI4x1VnZrGImVpNm26pzEO6FahpTmClWeQqk5I/AVGg21w2Vw== +"@airswap/types@^4.1.1": + version "4.1.1" + resolved "https://registry.yarnpkg.com/@airswap/types/-/types-4.1.1.tgz#1296674bca2838c6612c2c1bff6d094544608056" + integrity sha512-geOn5AuyBqley3MIHYvIQ5MGF1ElHoC+VPHmG5UD+1qPP273/cYiy7QfjALkKeM6URXeMiQo5/95E5zye0wzlQ== dependencies: "@uniswap/token-lists" "^1.0.0-beta.31" -"@airswap/utils@4.0.8": - version "4.0.8" - resolved "https://registry.yarnpkg.com/@airswap/utils/-/utils-4.0.8.tgz#a61c3e4dd89cc813c77f337f490d46452dea27ea" - integrity sha512-OfyykOc7RENrYoM8rRjBhNszYEzFkcRMdfeN33kee4j5HLIfB+Mbk7wLLQOiTrB+CgFSuIU1u8lCExfdtMp1VQ== +"@airswap/utils@^4.1.1": + version "4.1.1" + resolved "https://registry.yarnpkg.com/@airswap/utils/-/utils-4.1.1.tgz#35a069c498e6727de9898be2171a8603616f3b59" + integrity sha512-sv8tE2hTzMMgJ20rc/axCKimtUqLYXw6DcNhXAxCWmy+/UPv3OScwL2DoK3nOq4Sctk7i8+QrqrdwSOHSqsM5A== dependencies: - "@airswap/constants" "^4.0.10" - "@airswap/types" "^4.0.4" + "@airswap/constants" "^4.1.0" + "@airswap/swap-erc20" "4.1.0" + "@airswap/types" "^4.1.1" "@metamask/eth-sig-util" "^5.0.2" bignumber.js "^9.0.1" ethereumjs-util "^7.1.5" ethers "^5.6.9" lz-string "^1.5.0" -"@airswap/wrapper@4.0.8": - version "4.0.8" - resolved "https://registry.yarnpkg.com/@airswap/wrapper/-/wrapper-4.0.8.tgz#17659085edf318fcdc191dc332811a1f1957b48c" - integrity sha512-v0CBG1Med1bvug+cT4H1Nzgxhe1fRZPvK3VD7PIxmcOKbfeJzuJTyhnA9hWNE5CUJ5vaEb186Hn6VtwU0sKoEw== +"@airswap/wrapper@4.1.0": + version "4.1.0" + resolved "https://registry.yarnpkg.com/@airswap/wrapper/-/wrapper-4.1.0.tgz#906dbba82bf6aeccf26041de271d8222566fc44a" + integrity sha512-pnisIZl6iHz867JostGR4N1DN3SmFt8LOhki/oPFxr2pG4WfzZogHtWcGrsHHDx6df0gy4u08ouUu5ewNnzcbQ== dependencies: - "@airswap/swap-erc20" "4.0.6" + "@airswap/swap-erc20" "4.1.0" "@openzeppelin/contracts" "^4.8.3" "@ampproject/remapping@^2.2.0":