From a48ac5bbce55890f58277e55fd9971ca663472e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Espen=20H=C3=B8jsgaard?= Date: Sat, 11 Nov 2023 09:56:28 +0100 Subject: [PATCH] feat(addresses): Use ERC20 instance IDs Instead of the ambiguous token symbols use the instance ID's assigned by context-addresses. This makes all token instances available and enforces clarity on which ERC20 instance one is interacting with. To ease the transition, the default instances are still available using just the token symbol as identifier. However, use of this is deprecated. --- src/configuration.ts | 19 ++++++++++--------- yarn.lock | 6 +++--- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/configuration.ts b/src/configuration.ts index 1a036a8ba..a8fad8677 100644 --- a/src/configuration.ts +++ b/src/configuration.ts @@ -589,21 +589,22 @@ function readContextErc20Addresses() { erc20.networkInstances )) { const networkName = eth.getNetworkName(+networkId); - for (const [, /*erc20InstanceId*/ erc20Instance] of Object.entries( + for (const [erc20InstanceId, erc20Instance] of Object.entries( networkInstances )) { - // FIXME: All instances should be available, not just the default. - // This requires regisering the address ID instead of the token symbol - // + changes to configuration, but probably not more than that? - if (!erc20Instance.default) { - continue; - } addressesConfiguration.setAddress( - erc20.symbol, + erc20InstanceId, erc20Instance.address, networkName ); - break; + // Also register the default instance as the token symbol for convenience + if (erc20Instance.default) { + addressesConfiguration.setAddress( + erc20.symbol, + erc20Instance.address, + networkName + ); + } } } } diff --git a/yarn.lock b/yarn.lock index b9dd2b6da..4867a4bb8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1237,11 +1237,11 @@ __metadata: linkType: hard "@mangrovedao/context-addresses@npm:next": - version: 0.0.2-1 - resolution: "@mangrovedao/context-addresses@npm:0.0.2-1" + version: 0.0.2-2 + resolution: "@mangrovedao/context-addresses@npm:0.0.2-2" dependencies: semver: ^7.5.4 - checksum: b4d1a36868af691d99fe18485a3c903b53dfeb7b3866382021971f10026ae4bcd259ced9efe56a04f1d2a6b1f90ff55e9213d3e676e2e4d9a3435ae836a01904 + checksum: 1f9389c1533da92d6032d26cab4edb483a5608096933e8a70c733a26dea0f39208e514fd43006c6d5ad5a08c984f47dff5b5d252a85664854114b8b7d51b12b0 languageName: node linkType: hard