Skip to content

Commit

Permalink
feat(addresses): Use ERC20 instance IDs
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
espendk committed Nov 11, 2023
1 parent b691cff commit a48ac5b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
19 changes: 10 additions & 9 deletions src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit a48ac5b

Please sign in to comment.