Skip to content

Commit

Permalink
@airswap/utils fix: lowercase addresses for getFullSwapERC20
Browse files Browse the repository at this point in the history
  • Loading branch information
dmosites committed Jan 31, 2024
1 parent 148557b commit 07cf57c
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 17 deletions.
2 changes: 1 addition & 1 deletion source/batch-call/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@airswap/swap-erc20": "4.2.0"
},
"devDependencies": {
"@airswap/utils": "4.2.3",
"@airswap/utils": "4.2.4",
"prompt-confirm": "^2.0.4"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion source/pool/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@openzeppelin/contracts": "^4.8.3"
},
"devDependencies": {
"@airswap/utils": "4.2.3",
"@airswap/utils": "4.2.4",
"@airswap/merkle": "0.0.2",
"prompt-confirm": "^2.0.4"
},
Expand Down
2 changes: 1 addition & 1 deletion source/registry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"access": "public"
},
"devDependencies": {
"@airswap/utils": "4.2.3",
"@airswap/utils": "4.2.4",
"prompt-confirm": "^2.0.4"
}
}
2 changes: 1 addition & 1 deletion source/staking/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"access": "public"
},
"devDependencies": {
"@airswap/utils": "4.2.3",
"@airswap/utils": "4.2.4",
"prompt-confirm": "^2.0.4"
}
}
2 changes: 1 addition & 1 deletion source/swap-erc20/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"devDependencies": {
"@airswap/staking": "4.0.5",
"@airswap/utils": "4.2.3",
"@airswap/utils": "4.2.4",
"prompt-confirm": "^2.0.4"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion source/swap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@openzeppelin/contracts": "^4.8.3"
},
"devDependencies": {
"@airswap/utils": "4.2.3",
"@airswap/utils": "4.2.4",
"@nomicfoundation/hardhat-network-helpers": "^1.0.7"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion source/wrapper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@openzeppelin/contracts": "^4.8.3"
},
"devDependencies": {
"@airswap/utils": "4.2.3",
"@airswap/utils": "4.2.4",
"@uniswap/v2-periphery": "^1.1.0-beta.0",
"prompt-confirm": "^2.0.4"
},
Expand Down
4 changes: 2 additions & 2 deletions tools/libraries/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@airswap/libraries",
"version": "4.2.4",
"version": "4.2.5",
"description": "AirSwap: Libraries for Developers",
"repository": {
"type": "git",
Expand Down Expand Up @@ -33,7 +33,7 @@
"@airswap/staking": "4.0.5",
"@airswap/swap": "4.2.0",
"@airswap/swap-erc20": "4.2.0",
"@airswap/utils": "4.2.3",
"@airswap/utils": "4.2.4",
"@airswap/wrapper": "4.1.5",
"browser-or-node": "^2.1.1",
"ethers": "^5.6.9",
Expand Down
2 changes: 1 addition & 1 deletion tools/utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@airswap/utils",
"version": "4.2.3",
"version": "4.2.4",
"description": "AirSwap: Utilities for Developers",
"repository": {
"type": "git",
Expand Down
14 changes: 11 additions & 3 deletions tools/utils/src/swap-erc20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,9 @@ const parseTransfer = (log: any) => {
parsed = erc20Interface.parseLog(log)
if (parsed.name === 'Transfer') {
transfer = {
token: log.address,
from: parsed.args[0],
to: parsed.args[1],
token: log.address?.toLowerCase(),
from: parsed.args[0]?.toLowerCase(),
to: parsed.args[1]?.toLowerCase(),
amount: ethers.BigNumber.from(parsed.args[2]),
}
}
Expand All @@ -360,6 +360,10 @@ export const getFullSwapERC20 = async (
const transfers = []
let transfer: any
let length = logs.length

feeReceiver = feeReceiver.toLowerCase()
signerWallet = signerWallet.toLowerCase()

while (length--) {
if ((transfer = parseTransfer(logs[length]))) {
transfers.push(transfer)
Expand Down Expand Up @@ -390,6 +394,10 @@ export const getFullSwapERC20 = async (
}
}

if (!signer || !sender) {
throw new Error('getFullSwapERC20: Swap not found')
}

return {
nonce: nonce.toString(),
signerWallet: signer.from,
Expand Down
8 changes: 4 additions & 4 deletions tools/utils/test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ describe('Utils', async () => {

it('Gets full SwapERC20 from signerWallet and logs', async () => {
const nonce = '1'
const signerWallet = '0x51C72848c68a965f66FA7a88855F9f7784502a7F'
const signerWallet = '0x51c72848c68a965f66fa7a88855f9f7784502a7f'
const feeReceiver = '0xaD30f7EEBD9Bd5150a256F47DA41d4403033CdF0'
const fullSwap = await getFullSwapERC20(
nonce,
Expand All @@ -212,10 +212,10 @@ describe('Utils', async () => {
expect(fullSwap).to.deep.equal({
nonce,
signerWallet,
signerToken: '0xdAC17F958D2ee523a2206206994597C13D831ec7',
signerToken: '0xdac17f958d2ee523a2206206994597c13d831ec7',
signerAmount: '1008438461',
senderWallet: '0x74de5d4FCbf63E00296fd95d33236B9794016631',
senderToken: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
senderWallet: '0x74de5d4fcbf63e00296fd95d33236b9794016631',
senderToken: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
senderAmount: '461545050000000000',
feeAmount: '705906',
})
Expand Down

0 comments on commit 07cf57c

Please sign in to comment.