Skip to content

Commit 17f09b9

Browse files
authored
Merge pull request #206 from rabbitholegg/mmackz-utils-balancer
refactor(balancer): use built-in utils
2 parents fc1cb13 + 40d06a5 commit 17f09b9

File tree

6 files changed

+15
-68
lines changed

6 files changed

+15
-68
lines changed

.changeset/five-jobs-pump.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@rabbitholegg/questdk-plugin-balancer": minor
3+
---
4+
5+
use utils package

packages/balancer/src/Balancer.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { apply, GreaterThanOrEqual } from '@rabbitholegg/questdk/filter'
22
import { describe, expect, test } from 'vitest'
33
import { zeroAddress, parseEther, parseUnits } from 'viem'
44
import { swap, getSupportedTokenAddresses } from './Balancer'
5-
import { Chains } from './utils'
5+
import { Chains } from '@rabbitholegg/questdk-plugin-utils'
66
import { BALANCER_ABI } from './abi'
77
import { VAULT_CONTRACT, CHAIN_ID_ARRAY } from './constants'
88
import { failingTestCases, passingTestCases } from './test-transactions'

packages/balancer/src/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Chains } from './utils'
1+
import { Chains } from '@rabbitholegg/questdk-plugin-utils'
22

33
export const VAULT_CONTRACT = '0xba12222222228d8ba445958a75a0704d566bf2c8'
44
export const PATCH_CONTRACT = '0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789'

packages/balancer/src/test-transactions.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ import {
33
GreaterThanOrEqual,
44
type SwapActionParams,
55
} from '@rabbitholegg/questdk'
6-
import { type TestParams, createTestCase, Chains } from './utils'
6+
import {
7+
type TestParams,
8+
createTestCase,
9+
Chains,
10+
} from '@rabbitholegg/questdk-plugin-utils'
711
import { VAULT_CONTRACT } from './constants'
812

913
export const POLYGON_SWAP: TestParams<SwapActionParams> = {

packages/balancer/src/token-addresses.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { type Address, zeroAddress as ETH_ADDRESS } from 'viem'
2-
import { Chains } from './utils'
2+
import { Chains } from '@rabbitholegg/questdk-plugin-utils'
33

44
const ethereumTokenAddresses: Address[] = [
55
ETH_ADDRESS, // ETH

packages/balancer/src/utils.ts

Lines changed: 2 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,7 @@
1-
import type { ActionParams, FilterOperator } from '@rabbitholegg/questdk'
2-
import type { Address, Hash } from 'viem'
1+
import type { FilterOperator } from '@rabbitholegg/questdk'
2+
import type { Address } from 'viem'
33
import { getAddress } from 'viem'
44

5-
export enum Chains {
6-
ETHEREUM = 1,
7-
OPTIMISM = 10,
8-
BINANCE_SMART_CHAIN = 56,
9-
GNOSIS = 100,
10-
POLYGON_POS = 137,
11-
ZK_SYNC_ERA = 324,
12-
POLYGON_ZK = 1101,
13-
MANTLE = 5000,
14-
BASE = 8453,
15-
ARBITRUM_ONE = 42161,
16-
CELO = 42220,
17-
AVALANCHE = 43114,
18-
LINEA = 59144,
19-
SCROLL = 534352,
20-
}
21-
22-
interface Transaction {
23-
chainId: number
24-
from: Address
25-
hash?: Hash
26-
input: string
27-
to: Address
28-
value: string
29-
}
30-
31-
export interface TestCase<T extends ActionParams> {
32-
transaction: Transaction
33-
params: T
34-
description: string
35-
}
36-
37-
export type TestParams<T extends ActionParams> = {
38-
transaction: Transaction
39-
params: T
40-
}
41-
42-
/**
43-
* Creates a test case object for a given action and transaction.
44-
*
45-
* This function takes a `TestParams` object that includes both a `Transaction` and
46-
* `ActionParams`, a description of the test case, and an optional set of overrides
47-
* for the action parameters. It returns a `TestCase` object that contains the transaction,
48-
* the combined action parameters with any overrides applied, and the description.
49-
*
50-
* @param {TestParams<T>} testParams - An object containing the transaction and action parameters.
51-
* @param {string} description - A brief description of the test case.
52-
* @param {Partial<T>} [overrides] - Optional overrides for the action parameters.
53-
* @returns {TestCase<T>} A test case object with the transaction, params, and description.
54-
*/
55-
export function createTestCase<T extends ActionParams>(
56-
testParams: TestParams<T>,
57-
description: string,
58-
overrides: Partial<T> = {},
59-
): TestCase<T> {
60-
return {
61-
transaction: testParams.transaction,
62-
params: { ...testParams.params, ...overrides },
63-
description,
64-
}
65-
}
66-
675
export const buildPathQuery = (tokenIn?: Address, tokenOut?: Address) => {
686
const conditions: FilterOperator[] = []
697

0 commit comments

Comments
 (0)