Skip to content

chore: E2E test migration #226

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
f176400
test: helper base for e2e tests (#215)
meetmangukiya Oct 7, 2024
884319e
chore: migrate E2E nonStandardErc20 tests to Foundry (#213)
meetmangukiya Oct 7, 2024
efc8caa
chore: migrate E2E internalBalances test to Foundry (#216)
meetmangukiya Oct 7, 2024
59c3410
chore: migrate E2E 0xTrade test to Foundry (#219)
meetmangukiya Oct 7, 2024
8d8f77d
chore: merkle.io for ETH RPC (#227)
mfw78 Oct 7, 2024
9225dff
chore: migrate E2E wineOilMarket tests to Foundry (#214)
meetmangukiya Oct 7, 2024
75bf332
chore: migrate E2E upgradeAuthenticator test to Foundry (#217)
meetmangukiya Oct 7, 2024
89f9189
chore: set fork block number (#228)
mfw78 Oct 7, 2024
3d8a350
chore: migrate E2E burnFees to Foundry (#221)
meetmangukiya Oct 8, 2024
51f4a5b
chore: update test CI/CD for FORK_URL env (#230)
mfw78 Oct 8, 2024
078c5a6
chore: migrate E2E buyEth tests to Foundry (#229)
meetmangukiya Oct 8, 2024
e974119
chore: migrate E2E offchainAllowances test to Foundry (#218)
meetmangukiya Oct 8, 2024
fbfd19f
chore: migrate E2E smartOrder test to Foundry (#220)
meetmangukiya Oct 8, 2024
672c1ba
chore: migrate E2E uniswapTrade test to Foundry (#222)
meetmangukiya Oct 8, 2024
d3e1c19
chore: migrate E2E contractOrdersWithGnosisSafe test to Foundry (#223)
meetmangukiya Oct 8, 2024
b6871bc
chore: migrate E2E deployment test to Foundry (#225)
meetmangukiya Oct 8, 2024
1cbd0de
chore: remove env (#231)
mfw78 Oct 9, 2024
92ae3b5
chore: migrate E2E balancerSwap test to Foundry (#224)
meetmangukiya Oct 9, 2024
521c551
chore: clean dead code (#232)
mfw78 Oct 9, 2024
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
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,9 @@ jobs:
- name: Run Forge tests
if: matrix.profile != 'solc-0.7.6'
run: |
if [ "${{ matrix.profile }}" == "default" ]; then
echo "Setting FORK_URL for default profile"
export FORK_URL="${{ secrets.MAINNET_ARCHIVE_RPC }}"
fi
FOUNDRY_PROFILE=ci forge test -vvv
id: test
2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ deny_warnings = true
fs_permissions = [
{ access = "read", path = "./balancer"},
{ access = "read", path = "./networks.json"},
{ access = "read", path = "./out"}
{ access = "read", path = "./out"},
]

[fmt]
Expand Down
8 changes: 0 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,10 @@
"ethers": "^5.4.0"
},
"devDependencies": {
"@0x/contract-artifacts-v2": "npm:@0x/contract-artifacts@^2.2.2",
"@gnosis.pm/safe-contracts": "^1.3.0",
"@nomicfoundation/hardhat-verify": "^2.0.1",
"@nomiclabs/hardhat-ethers": "^2.2.3",
"@nomiclabs/hardhat-waffle": "^2.0.5",
"@openzeppelin/contracts": "=3.4.0-solc-0.7",
"@safe-global/api-kit": "^1.3.0",
"@safe-global/protocol-kit": "^1.2.0",
"@safe-global/safe-core-sdk-types": "^2.2.0",
"@slack/web-api": "^6.9.0",
"@tenderly/hardhat-tenderly": "~1.1.6",
"@types/chai": "^4.3.4",
"@types/chai-as-promised": "^7.1.5",
Expand All @@ -58,7 +52,6 @@
"@typescript-eslint/parser": "^5.58.0",
"@uniswap/v2-core": "^1.0.1",
"@uniswap/v2-periphery": "^1.1.0-beta.0",
"axios": "^1.3.5",
"canonical-weth": "^1.4.0",
"chai": "^4.3.7",
"chai-as-promised": "^7.1.1",
Expand All @@ -72,7 +65,6 @@
"eslint-plugin-prettier": "^4.2.1",
"ethereum-waffle": "^3.4.4",
"ethers": "^5.7.2",
"globby": "^11.0.4",
"hardhat": "^2.13.1",
"hardhat-deploy": "^0.11.26",
"hardhat-gas-reporter": "^1.0.9",
Expand Down
75 changes: 0 additions & 75 deletions src/ts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,85 +5,10 @@ import { utils } from "ethers";
*/
export const SALT = utils.formatBytes32String("Mattresses in Berlin!");

/**
* The contract used to deploy contracts deterministically with CREATE2.
* The address is chosen by the hardhat-deploy library.
* It is the same in any EVM-based network.
*
* https://github.com/Arachnid/deterministic-deployment-proxy
*/
export const DEPLOYER_CONTRACT = "0x4e59b44847b379578588920ca78fbf26c0b4956c";

/**
* Dictionary containing all deployed contract names.
*/
export const CONTRACT_NAMES = {
authenticator: "GPv2AllowListAuthentication",
settlement: "GPv2Settlement",
} as const;

/**
* The name of a deployed contract.
*/
export type ContractName = (typeof CONTRACT_NAMES)[keyof typeof CONTRACT_NAMES];

/**
* The deployment args for a contract.
*/
export type DeploymentArguments<T> =
T extends typeof CONTRACT_NAMES.authenticator
? never
: T extends typeof CONTRACT_NAMES.settlement
? [string, string]
: unknown[];

/**
* Allowed ABI definition types by Ethers.js.
*/
export type Abi = ConstructorParameters<typeof utils.Interface>[0];

/**
* Artifact information important for computing deterministic deployments.
*/
export interface ArtifactDeployment {
abi: Abi;
bytecode: string;
}

/**
* An artifact with a contract name matching one of the deterministically
* deployed contracts.
*/
export interface NamedArtifactDeployment<C extends ContractName>
extends ArtifactDeployment {
contractName: C;
}

type MaybeNamedArtifactArtifactDeployment<C> = C extends ContractName
? NamedArtifactDeployment<C>
: ArtifactDeployment;

/**
* Computes the deterministic address at which the contract will be deployed.
* This address does not depend on which network the contract is deployed to.
*
* @param contractName Name of the contract for which to find the address.
* @param deploymentArguments Extra arguments that are necessary to deploy.
* @returns The address that is expected to store the deployed code.
*/
export function deterministicDeploymentAddress<C>(
{ abi, bytecode }: MaybeNamedArtifactArtifactDeployment<C>,
deploymentArguments: DeploymentArguments<C>,
): string {
const contractInterface = new utils.Interface(abi);
const deployData = utils.hexConcat([
bytecode,
contractInterface.encodeDeploy(deploymentArguments),
]);

return utils.getCreate2Address(
DEPLOYER_CONTRACT,
SALT,
utils.keccak256(deployData),
);
}
1 change: 0 additions & 1 deletion src/ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export function domain(
export * from "./deploy";
export * from "./interaction";
export * from "./order";
export * from "./proxy";
export * from "./settlement";
export * from "./sign";
export * from "./swap";
Expand Down
13 changes: 0 additions & 13 deletions src/ts/interaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,3 @@ export function normalizeInteraction(
...interaction,
};
}

/**
* Normalizes data for many interactions so that they can be ABI encoded. This
* calls [`normalizeInteraction`] for each interaction.
*
* @param interactions The interactions to normalize.
* @return The normalized interactions.
*/
export function normalizeInteractions(
interactions: InteractionLike[],
): Interaction[] {
return interactions.map(normalizeInteraction);
}
81 changes: 5 additions & 76 deletions src/ts/order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,25 +72,6 @@ export interface Order {
buyTokenBalance?: OrderBalance;
}

/**
* Gnosis Protocol v2 order cancellation data.
*/
export interface OrderCancellations {
/**
* The unique identifier of the order to be cancelled.
*/
orderUids: BytesLike[];
}

/**
* Marker address to indicate that an order is buying Ether.
*
* Note that this address is only has special meaning in the `buyToken` and will
* be treated as a ERC20 token address in the `sellToken` position, causing the
* settlement to revert.
*/
export const BUY_ETH_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";

/**
* Gnosis Protocol v2 order flags.
*/
Expand All @@ -102,12 +83,12 @@ export type OrderFlags = Pick<
/**
* A timestamp value.
*/
export type Timestamp = number | Date;
type Timestamp = number | Date;

/**
* A hash-like app data value.
*/
export type HashLike = BytesLike | number;
type HashLike = BytesLike | number;

/**
* Order kind.
Expand Down Expand Up @@ -168,7 +149,7 @@ export const ORDER_TYPE_FIELDS = [
* @param time The timestamp value to normalize.
* @return Unix timestamp or number of seconds since the Unix Epoch.
*/
export function timestamp(t: Timestamp): number {
function timestamp(t: Timestamp): number {
return typeof t === "number" ? t : ~~(t.getTime() / 1000);
}

Expand All @@ -177,7 +158,7 @@ export function timestamp(t: Timestamp): number {
* @param hashLike A hash-like value to normalize.
* @returns A 32-byte hash encoded as a hex-string.
*/
export function hashify(h: HashLike): string {
function hashify(h: HashLike): string {
return typeof h === "number"
? `0x${h.toString(16).padStart(64, "0")}`
: ethers.utils.hexZeroPad(h, 32);
Expand Down Expand Up @@ -258,21 +239,6 @@ export function hashTypedData(
return ethers.utils._TypedDataEncoder.hash(domain, types, data);
}

/**
* Compute the 32-byte signing hash for the specified order.
*
* @param domain The EIP-712 domain separator to compute the hash for.
* @param order The order to compute the digest for.
* @return Hex-encoded 32-byte order digest.
*/
export function hashOrder(domain: TypedDataDomain, order: Order): string {
return hashTypedData(
domain,
{ Order: ORDER_TYPE_FIELDS },
normalizeOrder(order),
);
}

/**
* The byte length of an order UID.
*/
Expand All @@ -281,7 +247,7 @@ export const ORDER_UID_LENGTH = 56;
/**
* Order unique identifier parameters.
*/
export interface OrderUidParams {
interface OrderUidParams {
/**
* The EIP-712 order struct hash.
*/
Expand All @@ -296,21 +262,6 @@ export interface OrderUidParams {
validTo: number | Date;
}

/**
* Computes the order UID for an order and the given owner.
*/
export function computeOrderUid(
domain: TypedDataDomain,
order: Order,
owner: string,
): string {
return packOrderUidParams({
orderDigest: hashOrder(domain, order),
owner,
validTo: order.validTo,
});
}

/**
* Compute the unique identifier describing a user order in the settlement
* contract.
Expand All @@ -329,25 +280,3 @@ export function packOrderUidParams({
[orderDigest, owner, timestamp(validTo)],
);
}

/**
* Extracts the order unique identifier parameters from the specified bytes.
*
* @param orderUid The order UID encoded as a hexadecimal string.
* @returns The extracted order UID parameters.
*/
export function extractOrderUidParams(orderUid: string): OrderUidParams {
const bytes = ethers.utils.arrayify(orderUid);
if (bytes.length != ORDER_UID_LENGTH) {
throw new Error("invalid order UID length");
}

const view = new DataView(bytes.buffer);
return {
orderDigest: ethers.utils.hexlify(bytes.subarray(0, 32)),
owner: ethers.utils.getAddress(
ethers.utils.hexlify(bytes.subarray(32, 52)),
),
validTo: view.getUint32(52),
};
}
81 changes: 0 additions & 81 deletions src/ts/proxy.ts

This file was deleted.

Loading
Loading