@ledgerhq/hw-app-eth
Advanced tools
Comparing version 7.0.0-nightly.0 to 7.0.0-nightly.1
{ | ||
"entry": ["src/Eth.ts"], | ||
"ignoreUnused": ["@ledgerhq/hw-transport-mocker"] | ||
} | ||
"entry": [ | ||
"src/Eth.ts" | ||
], | ||
"ignoreUnused": [ | ||
"@ledgerhq/hw-transport-mocker" | ||
], | ||
"ignoreUnresolved": [ | ||
"@ethersproject/abstract-signer", | ||
"@ethersproject/address", | ||
"@ethersproject/base64", | ||
"@ethersproject/basex", | ||
"@ethersproject/bignumber", | ||
"@ethersproject/bytes", | ||
"@ethersproject/constants", | ||
"@ethersproject/contracts", | ||
"@ethersproject/hash", | ||
"@ethersproject/hdnode", | ||
"@ethersproject/json-wallets", | ||
"@ethersproject/keccak256", | ||
"@ethersproject/logger", | ||
"@ethersproject/properties", | ||
"@ethersproject/providers", | ||
"@ethersproject/random", | ||
"@ethersproject/sha2", | ||
"@ethersproject/signing-key", | ||
"@ethersproject/solidity", | ||
"@ethersproject/strings", | ||
"@ethersproject/transactions", | ||
"@ethersproject/units", | ||
"@ethersproject/wallet", | ||
"@ethersproject/web", | ||
"@ethersproject/wordlists" | ||
], | ||
"ignoreUnimported": [] | ||
} |
@@ -142,2 +142,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
erc20: true, | ||
uniswapV3: false, | ||
}) | ||
@@ -144,0 +145,0 @@ .catch(e => { |
@@ -10,10 +10,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
}; | ||
// This implements the resolution of a Transaction using Ledger's own API | ||
import { utils } from "ethers"; | ||
import { log } from "@ledgerhq/logs"; | ||
import { Interface } from "@ethersproject/abi"; | ||
import { signDomainResolution, signAddressResolution, } from "@ledgerhq/domain-service/signers/index"; | ||
import { decodeTxInfo, tokenSelectors, nftSelectors, mergeResolutions } from "../../utils"; | ||
import { UNISWAP_UNIVERSAL_ROUTER_ADDRESS } from "../../modules/Uniswap/constants"; | ||
import { byContractAddressAndChainId, findERC20SignaturesInfo } from "./erc20"; | ||
import { loadInfosForUniswap } from "../../modules/Uniswap"; | ||
import { loadInfosForContractMethod } from "./contracts"; | ||
import { getNFTInfo, loadNftPlugin } from "./nfts"; | ||
import { decodeTxInfo, tokenSelectors, nftSelectors, mergeResolutions } from "../../utils"; | ||
/** | ||
@@ -78,3 +79,5 @@ * @ignore for external documentation | ||
} | ||
if (shouldResolve.externalPlugins) { | ||
// Uniswap has its own way of working, so we need to handle it separately | ||
// This will prevent an error if we add Uniswap to the CAL service | ||
if (shouldResolve.externalPlugins && contractAddress !== UNISWAP_UNIVERSAL_ROUTER_ADDRESS) { | ||
const contractMethodInfos = yield loadInfosForContractMethod(contractAddress, selector, chainIdTruncated, loadConfig); | ||
@@ -88,3 +91,3 @@ if (contractMethodInfos) { | ||
if (erc20OfInterest && erc20OfInterest.length && abi) { | ||
const contract = new Interface(abi); | ||
const contract = new utils.Interface(abi); | ||
const args = contract.parseTransaction(decodedTx).args; | ||
@@ -102,2 +105,3 @@ for (const path of erc20OfInterest) { | ||
token: true, // enforcing resolution of tokens for external plugins that need info on assets (e.g. for a swap) | ||
uniswapV3: false, | ||
}); | ||
@@ -112,2 +116,12 @@ resolution = mergeResolutions([resolution, externalPluginResolution]); | ||
} | ||
if (shouldResolve.uniswapV3) { | ||
const { pluginData, tokenDescriptors } = yield loadInfosForUniswap(decodedTx, chainIdTruncated); | ||
if (pluginData && tokenDescriptors) { | ||
resolution.externalPlugin.push({ | ||
payload: pluginData.toString("hex"), | ||
signature: "", | ||
}); | ||
resolution.erc20Tokens.push(...tokenDescriptors.map(d => d.toString("hex"))); | ||
} | ||
} | ||
return resolution; | ||
@@ -133,2 +147,3 @@ }); | ||
externalPlugins: resolutionConfig.externalPlugins, | ||
uniswapV3: resolutionConfig.uniswapV3, | ||
}; | ||
@@ -135,0 +150,0 @@ const pluginsResolution = yield loadNanoAppPlugins(contractAddress, selector, decodedTx, chainIdTruncated, loadConfig, shouldResolve); |
@@ -29,2 +29,3 @@ import { DomainServiceResolution as DomainDescriptor } from "@ledgerhq/domain-service/types"; | ||
domains?: DomainDescriptor[]; | ||
uniswapV3?: boolean; | ||
}; | ||
@@ -31,0 +32,0 @@ export type LedgerEthTransactionService = { |
@@ -62,3 +62,3 @@ import { BigNumber } from "bignumber.js"; | ||
// Default to 1 for non EIP 155 txs | ||
chainId: rlpTx.length > 6 ? rlpTx[6] : Buffer.from("0x01", "hex"), | ||
chainId: rlpTx.length > 6 ? rlpTx[6] : Buffer.from("01", "hex"), | ||
}; | ||
@@ -65,0 +65,0 @@ } |
@@ -162,2 +162,3 @@ "use strict"; | ||
erc20: true, | ||
uniswapV3: false, | ||
}) | ||
@@ -164,0 +165,0 @@ .catch(e => { |
@@ -12,10 +12,11 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// This implements the resolution of a Transaction using Ledger's own API | ||
const ethers_1 = require("ethers"); | ||
const logs_1 = require("@ledgerhq/logs"); | ||
const abi_1 = require("@ethersproject/abi"); | ||
const index_1 = require("@ledgerhq/domain-service/signers/index"); | ||
const utils_1 = require("../../utils"); | ||
const constants_1 = require("../../modules/Uniswap/constants"); | ||
const erc20_1 = require("./erc20"); | ||
const Uniswap_1 = require("../../modules/Uniswap"); | ||
const contracts_1 = require("./contracts"); | ||
const nfts_1 = require("./nfts"); | ||
const utils_1 = require("../../utils"); | ||
/** | ||
@@ -80,3 +81,5 @@ * @ignore for external documentation | ||
} | ||
if (shouldResolve.externalPlugins) { | ||
// Uniswap has its own way of working, so we need to handle it separately | ||
// This will prevent an error if we add Uniswap to the CAL service | ||
if (shouldResolve.externalPlugins && contractAddress !== constants_1.UNISWAP_UNIVERSAL_ROUTER_ADDRESS) { | ||
const contractMethodInfos = yield (0, contracts_1.loadInfosForContractMethod)(contractAddress, selector, chainIdTruncated, loadConfig); | ||
@@ -90,3 +93,3 @@ if (contractMethodInfos) { | ||
if (erc20OfInterest && erc20OfInterest.length && abi) { | ||
const contract = new abi_1.Interface(abi); | ||
const contract = new ethers_1.utils.Interface(abi); | ||
const args = contract.parseTransaction(decodedTx).args; | ||
@@ -104,2 +107,3 @@ for (const path of erc20OfInterest) { | ||
token: true, // enforcing resolution of tokens for external plugins that need info on assets (e.g. for a swap) | ||
uniswapV3: false, | ||
}); | ||
@@ -114,2 +118,12 @@ resolution = (0, utils_1.mergeResolutions)([resolution, externalPluginResolution]); | ||
} | ||
if (shouldResolve.uniswapV3) { | ||
const { pluginData, tokenDescriptors } = yield (0, Uniswap_1.loadInfosForUniswap)(decodedTx, chainIdTruncated); | ||
if (pluginData && tokenDescriptors) { | ||
resolution.externalPlugin.push({ | ||
payload: pluginData.toString("hex"), | ||
signature: "", | ||
}); | ||
resolution.erc20Tokens.push(...tokenDescriptors.map(d => d.toString("hex"))); | ||
} | ||
} | ||
return resolution; | ||
@@ -135,2 +149,3 @@ }); | ||
externalPlugins: resolutionConfig.externalPlugins, | ||
uniswapV3: resolutionConfig.uniswapV3, | ||
}; | ||
@@ -137,0 +152,0 @@ const pluginsResolution = yield loadNanoAppPlugins(contractAddress, selector, decodedTx, chainIdTruncated, loadConfig, shouldResolve); |
@@ -29,2 +29,3 @@ import { DomainServiceResolution as DomainDescriptor } from "@ledgerhq/domain-service/types"; | ||
domains?: DomainDescriptor[]; | ||
uniswapV3?: boolean; | ||
}; | ||
@@ -31,0 +32,0 @@ export type LedgerEthTransactionService = { |
@@ -71,3 +71,3 @@ "use strict"; | ||
// Default to 1 for non EIP 155 txs | ||
chainId: rlpTx.length > 6 ? rlpTx[6] : Buffer.from("0x01", "hex"), | ||
chainId: rlpTx.length > 6 ? rlpTx[6] : Buffer.from("01", "hex"), | ||
}; | ||
@@ -74,0 +74,0 @@ } |
{ | ||
"name": "@ledgerhq/hw-app-eth", | ||
"version": "7.0.0-nightly.0", | ||
"version": "7.0.0-nightly.1", | ||
"description": "Ledger Hardware Wallet Ethereum Application API", | ||
@@ -34,10 +34,10 @@ "keywords": [ | ||
"semver": "^7.3.5", | ||
"@ledgerhq/cryptoassets-evm-signatures": "^14.0.0-nightly.0", | ||
"@ledgerhq/domain-service": "^1.2.6-nightly.0", | ||
"@ledgerhq/cryptoassets-evm-signatures": "^14.0.0-nightly.1", | ||
"@ledgerhq/domain-service": "^1.2.6-nightly.1", | ||
"@ledgerhq/errors": "^6.19.1", | ||
"@ledgerhq/evm-tools": "^1.2.3-nightly.0", | ||
"@ledgerhq/evm-tools": "^1.2.3-nightly.1", | ||
"@ledgerhq/hw-transport": "^6.31.4", | ||
"@ledgerhq/hw-transport-mocker": "^6.29.4", | ||
"@ledgerhq/logs": "^6.12.0", | ||
"@ledgerhq/types-live": "^6.52.0-nightly.0" | ||
"@ledgerhq/types-live": "^6.52.0-nightly.1" | ||
}, | ||
@@ -57,2 +57,7 @@ "gitHead": "dd0dea64b58e5a9125c8a422dcffd29e5ef6abec", | ||
}, | ||
"overrides": { | ||
"@ethersproject/providers": { | ||
"ws": "7.5.10" | ||
} | ||
}, | ||
"scripts": { | ||
@@ -59,0 +64,0 @@ "clean": "rimraf lib lib-es", |
@@ -555,3 +555,3 @@ <img src="https://user-images.githubusercontent.com/4631227/191834116-59cf590e-25cc-4956-ae5c-812ea464f324.png" height="100" /> | ||
Type: {nft: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?, externalPlugins: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?, erc20: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?, domains: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\<DomainDescriptor>?} | ||
Type: {nft: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?, externalPlugins: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?, erc20: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?, domains: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\<DomainDescriptor>?, uniswapV3: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?} | ||
@@ -564,1 +564,2 @@ #### Properties | ||
* `domains` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\<DomainDescriptor>?**  | ||
* `uniswapV3` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?**  |
@@ -210,2 +210,3 @@ /******************************************************************************** | ||
erc20: true, | ||
uniswapV3: false, | ||
}) | ||
@@ -212,0 +213,0 @@ .catch(e => { |
@@ -1,4 +0,3 @@ | ||
// This implements the resolution of a Transaction using Ledger's own API | ||
import { utils } from "ethers"; | ||
import { log } from "@ledgerhq/logs"; | ||
import { Interface } from "@ethersproject/abi"; | ||
import { | ||
@@ -9,6 +8,8 @@ signDomainResolution, | ||
import { LedgerEthTransactionResolution, LedgerEthTransactionService, LoadConfig } from "../types"; | ||
import { decodeTxInfo, tokenSelectors, nftSelectors, mergeResolutions } from "../../utils"; | ||
import { UNISWAP_UNIVERSAL_ROUTER_ADDRESS } from "../../modules/Uniswap/constants"; | ||
import { byContractAddressAndChainId, findERC20SignaturesInfo } from "./erc20"; | ||
import { loadInfosForUniswap } from "../../modules/Uniswap"; | ||
import { loadInfosForContractMethod } from "./contracts"; | ||
import { getNFTInfo, loadNftPlugin } from "./nfts"; | ||
import { decodeTxInfo, tokenSelectors, nftSelectors, mergeResolutions } from "../../utils"; | ||
@@ -19,2 +20,3 @@ type PotentialResolutions = { | ||
externalPlugins: boolean | undefined; | ||
uniswapV3: boolean | undefined; | ||
}; | ||
@@ -117,3 +119,5 @@ | ||
if (shouldResolve.externalPlugins) { | ||
// Uniswap has its own way of working, so we need to handle it separately | ||
// This will prevent an error if we add Uniswap to the CAL service | ||
if (shouldResolve.externalPlugins && contractAddress !== UNISWAP_UNIVERSAL_ROUTER_ADDRESS) { | ||
const contractMethodInfos = await loadInfosForContractMethod( | ||
@@ -135,3 +139,3 @@ contractAddress, | ||
if (erc20OfInterest && erc20OfInterest.length && abi) { | ||
const contract = new Interface(abi); | ||
const contract = new utils.Interface(abi); | ||
const args = contract.parseTransaction(decodedTx).args; | ||
@@ -155,2 +159,3 @@ | ||
token: true, // enforcing resolution of tokens for external plugins that need info on assets (e.g. for a swap) | ||
uniswapV3: false, | ||
}, | ||
@@ -166,2 +171,13 @@ ); | ||
if (shouldResolve.uniswapV3) { | ||
const { pluginData, tokenDescriptors } = await loadInfosForUniswap(decodedTx, chainIdTruncated); | ||
if (pluginData && tokenDescriptors) { | ||
resolution.externalPlugin.push({ | ||
payload: pluginData.toString("hex"), | ||
signature: "", | ||
}); | ||
resolution.erc20Tokens.push(...tokenDescriptors.map(d => d.toString("hex"))); | ||
} | ||
} | ||
return resolution; | ||
@@ -194,2 +210,3 @@ }; | ||
externalPlugins: resolutionConfig.externalPlugins, | ||
uniswapV3: resolutionConfig.uniswapV3, | ||
}; | ||
@@ -196,0 +213,0 @@ |
@@ -47,2 +47,4 @@ import { DomainServiceResolution as DomainDescriptor } from "@ledgerhq/domain-service/types"; | ||
domains?: DomainDescriptor[]; | ||
// activate uniswap v3 plugin resolution | ||
uniswapV3?: boolean; | ||
}; | ||
@@ -49,0 +51,0 @@ |
@@ -75,3 +75,3 @@ import { BigNumber } from "bignumber.js"; | ||
// Default to 1 for non EIP 155 txs | ||
chainId: rlpTx.length > 6 ? rlpTx[6] : Buffer.from("0x01", "hex"), | ||
chainId: rlpTx.length > 6 ? rlpTx[6] : Buffer.from("01", "hex"), | ||
}; | ||
@@ -78,0 +78,0 @@ } |
@@ -20,2 +20,3 @@ import { ethers } from "ethers"; | ||
random2: "0xc3f95102D5c8F2c83e49Ce3Acfb905eDfb7f37dE", // satan.eth | ||
uniswapUniversaRouter: "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD", | ||
}; | ||
@@ -96,5 +97,11 @@ | ||
}, | ||
uniswap: { | ||
["permit2>swap-out-v3>unwrap"]: | ||
"0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000669ba25a00000000000000000000000000000000000000000000000000000000000000030a010c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000016000000000000000000000000055747be9f9f5beb232ad59fe7af013b81d95fd5e000000000000000000000000ffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000066c32ea60000000000000000000000000000000000000000000000000000000000000006000000000000000000000000ef1c6e67703c7bd7107eed8303fbe6ec2554bf6b00000000000000000000000000000000000000000000000000000000669ba25a00000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000413cbf00ab90b6d1b17401cbf49e00c40f98bcb3f39461ca65e26009f9e9f77029279a4587efa2d792ea61ede56e0fbd7c1305007bc59d09bc60eaba46efa23edd1c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000233a3559d9da00000000000000000000000000000000000000000000000062e76d8ff4b926e800000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002bc02aaa39b223fe8d0a0e5c4f27ead9083c756cc200271055747be9f9f5beb232ad59fe7af013b81d95fd5e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000233a3559d9da000", | ||
["wrap>swap-in-v3"]: | ||
"0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000669bbbd800000000000000000000000000000000000000000000000000000000000000020b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000019c1d62a9f2000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000019c1d62a9f200000000000000000000000000000000000000000000000004227ffe925d0fc0000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002bc02aaa39b223fe8d0a0e5c4f27ead9083c756cc200271055747be9f9f5beb232ad59fe7af013b81d95fd5e000000000000000000000000000000000000000000", | ||
}, | ||
}; | ||
export const getTransactionHash = (to: string, data: string): string => | ||
export const getSerializedTransaction = (to: string, data: string): string => | ||
ethers.utils | ||
@@ -101,0 +108,0 @@ .serializeTransaction({ |
import axios from "axios"; | ||
import { getTransactionHash, transactionData, transactionContracts } from "./fixtures/utils"; | ||
import { getSerializedTransaction, transactionData, transactionContracts } from "./fixtures/utils"; | ||
import { ERC1155_CLEAR_SIGNED_SELECTORS, ERC721_CLEAR_SIGNED_SELECTORS } from "../src/utils"; | ||
@@ -9,2 +9,4 @@ import partialPluginResponse from "./fixtures/REST/Paraswap-Plugin.json"; | ||
import * as nftServices from "../src/services/ledger/nfts"; | ||
import signatureCALEth from "./fixtures/SignatureCALEth"; | ||
import * as uniswapModule from "../src/modules/Uniswap"; | ||
import { ResolutionConfig } from "../src/services/types"; | ||
@@ -18,2 +20,3 @@ import { ledgerService } from "../src/Eth"; | ||
externalPlugins: true, | ||
uniswapV3: true, | ||
}; | ||
@@ -28,2 +31,4 @@ | ||
jest.spyOn(erc20Services, "byContractAddressAndChainId"); | ||
jest.spyOn(uniswapModule, "loadInfosForUniswap"); | ||
jest.spyOn(uniswapModule, "getCommandsAndTokensFromUniswapCalldata"); | ||
@@ -40,3 +45,3 @@ describe("Ledger Service", () => { | ||
axios.get.mockImplementation(async () => null); | ||
const txHash = getTransactionHash( | ||
const txHash = getSerializedTransaction( | ||
transactionContracts.erc20, | ||
@@ -70,3 +75,3 @@ transactionData.erc20.approve, | ||
axios.get.mockImplementation(async () => null); | ||
const txHash = getTransactionHash( | ||
const txHash = getSerializedTransaction( | ||
transactionContracts.erc20, | ||
@@ -100,3 +105,3 @@ transactionData.erc20.transfer, | ||
axios.get.mockImplementation(async () => null); | ||
const txHash = getTransactionHash( | ||
const txHash = getSerializedTransaction( | ||
transactionContracts.random, | ||
@@ -128,3 +133,3 @@ transactionData.erc20.approve, | ||
axios.get.mockImplementation(async () => null); | ||
const txHash = getTransactionHash( | ||
const txHash = getSerializedTransaction( | ||
transactionContracts.random, | ||
@@ -187,3 +192,3 @@ transactionData.erc20.transfer, | ||
const txHash = getTransactionHash( | ||
const txHash = getSerializedTransaction( | ||
transactionContracts.erc721, | ||
@@ -218,3 +223,3 @@ transactionData.erc721.approve, | ||
const txHash = getTransactionHash( | ||
const txHash = getSerializedTransaction( | ||
transactionContracts.erc721, | ||
@@ -249,3 +254,3 @@ transactionData.erc721.setApprovalForAll, | ||
const txHash = getTransactionHash( | ||
const txHash = getSerializedTransaction( | ||
transactionContracts.erc721, | ||
@@ -280,3 +285,3 @@ transactionData.erc721.transferFrom, | ||
const txHash = getTransactionHash( | ||
const txHash = getSerializedTransaction( | ||
transactionContracts.erc721, | ||
@@ -311,3 +316,3 @@ transactionData.erc721.safeTransferFrom, | ||
const txHash = getTransactionHash( | ||
const txHash = getSerializedTransaction( | ||
transactionContracts.erc721, | ||
@@ -342,3 +347,3 @@ transactionData.erc721.safeTransferFromWithData, | ||
const txHash = getTransactionHash( | ||
const txHash = getSerializedTransaction( | ||
transactionContracts.erc20, | ||
@@ -373,3 +378,3 @@ transactionData.erc721.safeTransferFrom, | ||
const txHash = getTransactionHash( | ||
const txHash = getSerializedTransaction( | ||
transactionContracts.random, | ||
@@ -432,3 +437,3 @@ transactionData.erc721.safeTransferFrom, | ||
const txHash = getTransactionHash( | ||
const txHash = getSerializedTransaction( | ||
transactionContracts.erc1155, | ||
@@ -463,3 +468,3 @@ transactionData.erc1155.setApprovalForAll, | ||
const txHash = getTransactionHash( | ||
const txHash = getSerializedTransaction( | ||
transactionContracts.erc1155, | ||
@@ -494,3 +499,3 @@ transactionData.erc1155.safeTransferFrom, | ||
const txHash = getTransactionHash( | ||
const txHash = getSerializedTransaction( | ||
transactionContracts.erc1155, | ||
@@ -525,3 +530,3 @@ transactionData.erc1155.safeBatchTransferFrom, | ||
const txHash = getTransactionHash( | ||
const txHash = getSerializedTransaction( | ||
transactionContracts.erc20, | ||
@@ -556,3 +561,3 @@ transactionData.erc1155.safeTransferFrom, | ||
const txHash = getTransactionHash( | ||
const txHash = getSerializedTransaction( | ||
transactionContracts.random, | ||
@@ -593,3 +598,3 @@ transactionData.erc1155.safeTransferFrom, | ||
const txHash = getTransactionHash( | ||
const txHash = getSerializedTransaction( | ||
transactionContracts.paraswap, | ||
@@ -636,3 +641,3 @@ transactionData.paraswap.simpleSwap, | ||
const txHash = getTransactionHash( | ||
const txHash = getSerializedTransaction( | ||
transactionContracts.paraswap, | ||
@@ -670,3 +675,92 @@ transactionData.paraswap.swapOnUniswapV2Fork, | ||
}); | ||
describe("UNISWAP", () => { | ||
it("should resolve a Uniswap universal router transaction (permit2>swap-out-v3>unwrap)", async () => { | ||
// @ts-expect-error not casted as jest mock | ||
axios.get.mockImplementation(async (uri: string) => { | ||
if (uri.endsWith("evm/1/erc20-signatures.json")) { | ||
return { data: signatureCALEth }; | ||
} | ||
return null; | ||
}); | ||
const txHash = getSerializedTransaction( | ||
transactionContracts.uniswapUniversaRouter, | ||
transactionData.uniswap["permit2>swap-out-v3>unwrap"], | ||
); | ||
const resolution = await ledgerService.resolveTransaction( | ||
txHash, | ||
loadConfig, | ||
resolutionConfig, | ||
); | ||
expect(resolution).toEqual({ | ||
domains: [], | ||
erc20Tokens: [ | ||
"0457455448c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000012000000013045022100b47ee8551c15a2cf681c649651e987d7e527c481d27c38da1f971a8242792bd3022069c3f688ac5493a23dab5798e3c9b07484765069e1d4be14321aae4d92cb8cbe", | ||
"0457455448c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000012000000013045022100b47ee8551c15a2cf681c649651e987d7e527c481d27c38da1f971a8242792bd3022069c3f688ac5493a23dab5798e3c9b07484765069e1d4be14321aae4d92cb8cbe", | ||
], | ||
nfts: [], | ||
externalPlugin: [ | ||
{ | ||
payload: | ||
"07556e69737761703fc91a3afd70395cd496c647d5a6cc9d4b2b7fad3593564c3044022014391e8f355867a57fe88f6a5a4dbcb8bf8f888a9db3ff3449caf72d120396bd02200c13d9c3f79400fe0aa0434ac54d59b79503c9964a4abc3e8cd22763e0242935", | ||
signature: "", | ||
}, | ||
], | ||
plugin: [], | ||
}); | ||
expect(contractServices.loadInfosForContractMethod).toHaveBeenCalledTimes(0); | ||
expect(erc20Services.findERC20SignaturesInfo).toHaveBeenCalledTimes(3); | ||
expect(erc20Services.byContractAddressAndChainId).toHaveBeenCalledTimes(3); | ||
expect(uniswapModule.loadInfosForUniswap).toHaveBeenCalledTimes(1); | ||
expect(uniswapModule.getCommandsAndTokensFromUniswapCalldata).toHaveBeenCalledTimes(1); | ||
expect(nftServices.getNFTInfo).not.toHaveBeenCalled(); | ||
expect(nftServices.loadNftPlugin).not.toHaveBeenCalled(); | ||
}); | ||
it("should resolve a Uniswap universal router transaction (wrap>swap-in-v3)", async () => { | ||
// @ts-expect-error not casted as jest mock | ||
axios.get.mockImplementation(async (uri: string) => { | ||
if (uri.endsWith("evm/1/erc20-signatures.json")) { | ||
return { data: signatureCALEth }; | ||
} | ||
return null; | ||
}); | ||
const txHash = getSerializedTransaction( | ||
transactionContracts.uniswapUniversaRouter, | ||
transactionData.uniswap["wrap>swap-in-v3"], | ||
); | ||
const resolution = await ledgerService.resolveTransaction( | ||
txHash, | ||
loadConfig, | ||
resolutionConfig, | ||
); | ||
expect(resolution).toEqual({ | ||
domains: [], | ||
erc20Tokens: [ | ||
"0457455448c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000012000000013045022100b47ee8551c15a2cf681c649651e987d7e527c481d27c38da1f971a8242792bd3022069c3f688ac5493a23dab5798e3c9b07484765069e1d4be14321aae4d92cb8cbe", | ||
"0457455448c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000012000000013045022100b47ee8551c15a2cf681c649651e987d7e527c481d27c38da1f971a8242792bd3022069c3f688ac5493a23dab5798e3c9b07484765069e1d4be14321aae4d92cb8cbe", | ||
], | ||
nfts: [], | ||
externalPlugin: [ | ||
{ | ||
payload: | ||
"07556e69737761703fc91a3afd70395cd496c647d5a6cc9d4b2b7fad3593564c3044022014391e8f355867a57fe88f6a5a4dbcb8bf8f888a9db3ff3449caf72d120396bd02200c13d9c3f79400fe0aa0434ac54d59b79503c9964a4abc3e8cd22763e0242935", | ||
signature: "", | ||
}, | ||
], | ||
plugin: [], | ||
}); | ||
expect(contractServices.loadInfosForContractMethod).toHaveBeenCalledTimes(0); | ||
expect(erc20Services.findERC20SignaturesInfo).toHaveBeenCalledTimes(3); | ||
expect(erc20Services.byContractAddressAndChainId).toHaveBeenCalledTimes(3); | ||
expect(uniswapModule.loadInfosForUniswap).toHaveBeenCalledTimes(1); | ||
expect(uniswapModule.getCommandsAndTokensFromUniswapCalldata).toHaveBeenCalledTimes(1); | ||
expect(nftServices.getNFTInfo).not.toHaveBeenCalled(); | ||
expect(nftServices.loadNftPlugin).not.toHaveBeenCalled(); | ||
}); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2307579
252
27257
564