Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove the constructor from InterhcainAddressTracker to make it easier r to be upgradable. #114

Merged
merged 6 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion contracts/test/utils/TestInterchainAddressTracker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ contract TestInterchainAddressTracker is InterchainAddressTracker, Ownable {
string memory chainName_,
string[] memory trustedChainNames,
string[] memory trustedAddresses
) InterchainAddressTracker(chainName_) Ownable(msg.sender) {
) Ownable(msg.sender) {
_setChainName(chainName_);

if (_CHAIN_NAME_SLOT != bytes32(uint256(keccak256('interchain-address-tracker-chain-name')) - 1))
revert Invalid();

Expand Down
12 changes: 3 additions & 9 deletions contracts/utils/InterchainAddressTracker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,9 @@ contract InterchainAddressTracker is IInterchainAddressTracker {
// bytes32(uint256(keccak256('interchain-address-tracker-chain-name')) - 1)
bytes32 internal constant _CHAIN_NAME_SLOT = 0x0e2c162a1f4b5cff9fdbd6b34678a9bcb9898a0b9fbca695b112d61688d8b2ac;

/**
* @dev Constructs the InterchainAddressTracker contract.
* @param chainName_ The name of the current chain.
*/
constructor(string memory chainName_) {
if (bytes(chainName_).length == 0) revert ZeroStringLength();

function _setChainName(string memory chainName_) internal {
StringStorage.set(_CHAIN_NAME_SLOT, chainName_);
}
}

/**
* @dev Gets the name of the chain this is deployed at
Expand Down Expand Up @@ -60,7 +54,7 @@ contract InterchainAddressTracker is IInterchainAddressTracker {
* @param address_ Address of the sender
* @return bool true if the sender chain/address are trusted, false otherwise
*/
function isTrustedAddress(string calldata chain, string calldata address_) external view returns (bool) {
function isTrustedAddress(string calldata chain, string calldata address_) public view returns (bool) {
bytes32 addressHash = keccak256(bytes(address_));

return addressHash == trustedAddressHash(chain);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@axelar-network/axelar-gmp-sdk-solidity",
"version": "5.6.1",
"version": "5.6.2",
"description": "Solidity GMP SDK and utilities provided by Axelar for cross-chain development",
"main": "index.js",
"scripts": {
Expand Down
16 changes: 1 addition & 15 deletions test/utils/InterchainAddressTracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ const { deployContract } = require('../utils.js');
describe('InterchainAddressTracker', () => {
let ownerWallet,
otherWallet,
interchainAddressTracker,
interchainAddressTrackerFactory;
interchainAddressTracker;

const otherRemoteAddress = 'any string as an address';
const otherChain = 'Other Name';
Expand All @@ -29,10 +28,6 @@ describe('InterchainAddressTracker', () => {
'TestInterchainAddressTracker',
[chainName, defaultChains, defaultAddresses],
);

interchainAddressTrackerFactory = await ethers.getContractFactory(
'InterchainAddressTracker',
);
});

it('check internal constants', async () => {
Expand All @@ -45,15 +40,6 @@ describe('InterchainAddressTracker', () => {
expect(await interchainAddressTracker.chainName()).to.equal(chainName);
});

it('Should revert on interchainAddressTracker deployment with invalid chain name', async () => {
await expect(
interchainAddressTrackerFactory.deploy(''),
).to.be.revertedWithCustomError(
interchainAddressTracker,
'ZeroStringLength',
);
});

it('Should get empty strings for the trusted address for unregistered chains', async () => {
expect(await interchainAddressTracker.trustedAddress(otherChain)).to.equal(
'',
Expand Down