Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"url": "https://github.com/violetprotocol/mauve-periphery"
},
"files": [
"utils/**/*",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are we intending to use this? There are some seemingly small problems that could arise if we use this package outside of testing modules, since the generateAccessToken stuff here was originally written as a test utility.

Maybe it's even worth putting some code in the generateAccessToken function itself to throw if we're not in a testing state to disallow usage of the function in dev or prod.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to be used for testing in the swap-router-contracts repo as well.

What issues do you see could arise?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We wouldn't want this to be used by any kind of real EAT generation, which is possible if it's imported. Since we have a default expiry that's hardcoded you could end up with generating EATs with completely wrong expiries which could be really dangerous.

Feels safer to disable the function to be called by anything other than tests.

"contracts/base",
"contracts/interfaces",
"contracts/libraries",
Expand Down
10 changes: 5 additions & 5 deletions test/EATMulticall.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { BigNumber, Wallet } from 'ethers'
import { Wallet } from 'ethers'
import { ethers } from 'hardhat'
import { TestEATMulticall } from '../typechain/TestEATMulticall'
import { AccessTokenVerifier } from '../typechain/AccessTokenVerifier'
import { expect } from './shared/expect'
import { utils, messages } from '@violetprotocol/ethereum-access-token-helpers'
import { messages } from '@violetprotocol/ethereum-access-token-helpers'

import snapshotGasCost from './shared/snapshotGasCost'
import { parseEther, splitSignature } from 'ethers/lib/utils'
import { generateAccessTokenForMulticall } from './shared/generateAccessToken'
import { parseEther } from 'ethers/lib/utils'
import { generateAccessTokenForMulticall } from '../utils/generateAccessToken'

// generated randomly from privatekeys.pw
// DO NOT USE IN SENSITIVE PLACES
Expand Down Expand Up @@ -45,7 +45,7 @@ describe('EATMulticall', async () => {

beforeEach('create multicall', async () => {
const multicallTestFactory = await ethers.getContractFactory('TestEATMulticall')
testMulticall = (await multicallTestFactory.deploy(verifier.address)) as TestEATMulticall
testMulticall = await multicallTestFactory.deploy(verifier.address)
})

it('revert messages are returned', async () => {
Expand Down
6 changes: 3 additions & 3 deletions test/MockSwapRouter.gas.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { abi as IMauvePoolABI } from '@violetprotocol/mauve-core/artifacts/contracts/interfaces/IMauvePool.sol/IMauvePool.json'
import { Fixture } from 'ethereum-waffle'
import { BigNumber, constants, ContractTransaction, Wallet } from 'ethers'
import { BigNumber, constants, Contract, ContractTransaction, Wallet } from 'ethers'
import { ethers, waffle } from 'hardhat'
import {
IMauvePool,
Expand All @@ -19,8 +19,8 @@ import { expect } from './shared/expect'
import { encodePath } from './shared/path'
import snapshotGasCost from './shared/snapshotGasCost'
import { getMaxTick, getMinTick } from './shared/ticks'
import { generateAccessTokenForMulticall } from './shared/generateAccessToken'
import { swapRouterBytes32 } from './shared/roles'
import { generateAccessTokenForMulticall } from '../utils'
import { swapRouterBytes32 } from '../utils/roles'

describe('MockSwapRouter gas tests', function () {
this.timeout(40000)
Expand Down
2 changes: 1 addition & 1 deletion test/MockSwapRouter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { encodePath } from './shared/path'
import { getMaxTick, getMinTick } from './shared/ticks'
import { computePoolAddress } from './shared/computePoolAddress'
import { CreatePoolIfNecessary } from './shared/createPoolIfNecessary'
import { generateAccessTokenForMulticall } from './shared/generateAccessToken'
import { generateAccessTokenForMulticall } from '../utils/'

describe('MockSwapRouter', function () {
this.timeout(40000)
Expand Down
2 changes: 1 addition & 1 deletion test/NonfungiblePositionManager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import poolAtAddress from './shared/poolAtAddress'
import snapshotGasCost from './shared/snapshotGasCost'
import { getMaxTick, getMinTick } from './shared/ticks'
import { sortedTokens } from './shared/tokenSort'
import { generateAccessToken, generateAccessTokenForMulticall } from './shared/generateAccessToken'
import { generateAccessToken, generateAccessTokenForMulticall } from '../utils/generateAccessToken'

describe('NonfungiblePositionManager', () => {
let wallets: Wallet[]
Expand Down
2 changes: 1 addition & 1 deletion test/NonfungibleTokenPositionDescriptor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { getMaxTick, getMinTick } from './shared/ticks'
import { sortedTokens } from './shared/tokenSort'
import { extractJSONFromURI } from './shared/extractJSONFromURI'
import { CreatePoolIfNecessary } from './shared/createPoolIfNecessary'
import { generateAccessTokenForMulticall } from './shared/generateAccessToken'
import { generateAccessTokenForMulticall } from '../utils/generateAccessToken'

const DAI = '0x6B175474E89094C44Da98b954EedeAC495271d0F'
const USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'
Expand Down
2 changes: 1 addition & 1 deletion test/PositionValue.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { expect } from './shared/expect'

import { abi as IMauvePoolABI } from '@violetprotocol/mauve-core/artifacts/contracts/interfaces/IMauvePool.sol/IMauvePool.json'
import { CreatePoolIfNecessary } from './shared/createPoolIfNecessary'
import { generateAccessTokenForMulticall } from './shared/generateAccessToken'
import { generateAccessTokenForMulticall } from '../utils/generateAccessToken'

describe('PositionValue', async () => {
const [...wallets] = waffle.provider.getWallets()
Expand Down
2 changes: 1 addition & 1 deletion test/TickLens.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { getMaxTick, getMinTick } from './shared/ticks'
import { computePoolAddress } from './shared/computePoolAddress'
import snapshotGasCost from './shared/snapshotGasCost'
import { CreatePoolIfNecessary } from './shared/createPoolIfNecessary'
import { generateAccessTokenForMulticall } from './shared/generateAccessToken'
import { generateAccessTokenForMulticall } from '../utils/generateAccessToken'

describe('TickLens', () => {
let wallets: Wallet[]
Expand Down
2 changes: 1 addition & 1 deletion test/shared/completeFixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
import { CreatePoolIfNecessary, createPoolIfNecessary } from './createPoolIfNecessary'
import { parseEther } from 'ethers/lib/utils'
import { EAT_ISSUER_PK } from './eatSigner'
import { positionManagerBytes32 } from './roles'
import { positionManagerBytes32 } from '../../utils/roles'

export type Domain = {
name: string
Expand Down
2 changes: 1 addition & 1 deletion test/shared/externalFixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { AccessTokenVerifier, IMauveFactoryReduced, IWETH9, MockTimeSwapRouter }
import WETH9 from '../contracts/WETH9.json'
import { Contract } from '@ethersproject/contracts'
import { EAT_ISSUER_PK } from './eatSigner'
import { swapRouterBytes32 } from './roles'
import { swapRouterBytes32 } from '../../utils/roles'

const wethFixture: Fixture<{ weth9: IWETH9 }> = async ([wallet]) => {
const weth9 = (await waffle.deployContract(wallet, {
Expand Down
2 changes: 1 addition & 1 deletion test/shared/quoter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { FeeAmount, TICK_SPACINGS } from './constants'
import { CreatePoolIfNecessary } from './createPoolIfNecessary'
import { encodePriceSqrt } from './encodePriceSqrt'
import { getMaxTick, getMinTick } from './ticks'
import { generateAccessTokenForMulticall } from './generateAccessToken'
import { generateAccessTokenForMulticall } from '../../utils'
import { Domain } from './completeFixture'

export async function createPool(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { Wallet, BigNumber } from 'ethers'
import { Contract } from '@ethersproject/contracts'
import { ethers, Wallet, BigNumber } from 'ethers'
import { messages, utils } from '@violetprotocol/ethereum-access-token-helpers'
import { EATMulticall } from '../../typechain'
import { splitSignature } from 'ethers/lib/utils'
import { ethers } from 'hardhat'

export const generateAccessToken = async (
signer: Wallet,
domain: messages.Domain,
functionName: string,
caller: Wallet,
contract: EATMulticall,
contract: Contract,
parameters: any[],
expiry?: BigNumber
) => {
Expand All @@ -32,7 +31,7 @@ export const generateAccessTokenForMulticall = async (
signer: Wallet,
domain: messages.Domain,
caller: Wallet,
contract: EATMulticall,
contract: Contract,
parameters: any[],
expiry?: BigNumber
) => {
Expand All @@ -57,7 +56,7 @@ export const generateAccessTokenForMulticallWithDeadline = async (
signer: Wallet,
domain: messages.Domain,
caller: Wallet,
contract: EATMulticall,
contract: Contract,
parameters: any[],
expiry?: BigNumber
) => {
Expand Down
2 changes: 2 additions & 0 deletions utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './generateAccessToken'
export * from './roles'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if this might be better in a constants folder since it's not really a util?

File renamed without changes.