balancer-sdk icon indicating copy to clipboard operation
balancer-sdk copied to clipboard

Move ethers from devDependencies to dependencies

Open ocozalp opened this issue 1 year ago • 5 comments

Hello,

I'm trying to make balancer-sdk work in a project that uses ethers v6 and I'm having issues with it because balancer-sdk uses ethers v5 (and it uses Interface class under ethers.util, in the latest versions it's ethers.Interface).

Can you consider moving ethers to dependencies so balancer-sdk uses its own ethers version?

ocozalp avatar Jan 16 '24 21:01 ocozalp

Created a PR here: https://github.com/balancer/balancer-sdk/pull/561

ocozalp avatar Jan 16 '24 22:01 ocozalp

Got the same problem in a node.js project using ethers v6. For now, I sorted out using package aliases:

"devDependencies": {
     "@balancer-labs/sdk": "^1.1.5",
     "ethers": "5.7.2",
     "ethers-v6": "npm:[email protected]",
}

Then, you can simply adjust your imports like this:

const { ethers } = require('ethers-v6');
// or in ES6 syntax
import { ethers } from 'ethers-v6';

Pedrojok01 avatar Jan 19 '24 08:01 Pedrojok01

This issue is still relevant. I had to downgrade to ethers ^5.0.0 to use balancer-sdk

0xEzSwim avatar May 03 '24 09:05 0xEzSwim

Trying to understand more about the issue here. Can anyone who has this issue confirm what version of the SDK is being used and even point me towards a repo where I can replicate? The SDK has depenedcies on ethers sub packages but doesn't have a direct dep on "ethers" full package so I can't understand the issue atm. Thanks!

johngrantuk avatar May 06 '24 14:05 johngrantuk

@johngrantuk For my case, I use "@balancer-labs/sdk": "^1.1.5" and "ethers": "^6.7.1".

When I have these two as dependencies and run tests I see this

  ● Test suite failed to run

    TypeError: Cannot read properties of undefined (reading 'Interface')

      5 | import { Injectable } from '@nestjs/common';
    > 6 | import { BalancerSDK, Network } from '@balancer-labs/sdk';
        | ^


      at Function.components [as createInterface] (../node_modules/@balancer-labs/src/contracts/factories/ComposableStablePool__factory.ts:16:9)
 

That fails because all interfaces in balancer-sdk extend ethers.utils.Interface but in later versions of ethers it's moved to ethers.Interface. It's tricky to override this (I manually change yarn.lock file :|) since ethers is a dev dependency for balancer-sdk. Moving it to dependencies will allow us to use whatever ethers version we need and also use balancer-sdk without an issue.

ocozalp avatar May 06 '24 15:05 ocozalp

Thanks for patience here. Should be live on package: v1.1.6-beta.18 and please just let us know if there's any issue.

johngrantuk avatar May 14 '24 13:05 johngrantuk

Thanks @johngrantuk !

ocozalp avatar May 14 '24 14:05 ocozalp