yearn / yearn-sdk

🦧 SDK for the yearn.finance platform. WIP
https://npm.im/@yfi/sdk
MIT License
53 stars 56 forks source link

feat: Change Context configuration dynamically #293

Closed karelianpie closed 1 year ago

karelianpie commented 2 years ago

Description

Add a config setter to be able to change configurations (chainId, context and assetServiceState) dynamically after initialisation. Usage:

// Initialise a Yearn instance
const sdkInstance = new Yearn(1, {
  provider,
  zapper: ZAPPER_API_KEY,
  // ...
});
// then we can dynamically change the config by
sdkInstance.config = {
  chainId: 250,
  context: {
    anotherProvider,
    zapper: 'anotherZapperKey',
    // ...
  },
};

Related Issue

N/A

Motivation and Context

Currently after initialisation it is not possible to change the configs in the context

How Has This Been Tested?

Ran locally with yalc

github-actions[bot] commented 2 years ago

size-limit report 📦

Path Size
dist/sdk.cjs.production.min.js 47.67 KB (+0.38% 🔺)
dist/sdk.esm.js 48 KB (+0.37% 🔺)
karelianpie commented 1 year ago

@xgambitox shall we close this?

karelianpie commented 1 year ago

Closing for now as it's stalled, reopen if to be continued