Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
chore: rename & rearrange variables
Browse files Browse the repository at this point in the history
Signed-off-by: Jawad Tariq <[email protected]>
  • Loading branch information
JDawg287 committed Oct 23, 2023
1 parent 2883e7a commit 08ead8a
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 109 deletions.
34 changes: 17 additions & 17 deletions contracts/topos-core/SubnetRegistrator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ contract SubnetRegistrator is Initializable, Ownable {
using Bytes32SetsLib for Bytes32SetsLib.Set;

struct Subnet {
string httpEndpoint;
string wsEndpoint;
uint256 chainId;
string currencySymbol;
string endpointHttp;
string endpointWs;
string logoURL;
string name;
string currencySymbol;
uint256 chainId;
}

/// @notice Set of subnet IDs
Expand Down Expand Up @@ -57,30 +57,30 @@ contract SubnetRegistrator is Initializable, Ownable {
}

/// @notice Register a new subnet
/// @param httpEndpoint JSON RPC http endpoint of a subnet
/// @param wsEndpoint JSON RPC ws endpoint of a subnet
/// @param chainId subnet network ID
/// @param currencySymbol currencySymbol for a subnet currency
/// @param endpointHttp JSON RPC http endpoint of a subnet
/// @param endpointWs JSON RPC ws endpoint of a subnet
/// @param logoURL URL for the logo of a subnet
/// @param name name of a subnet
/// @param subnetId FROST public key of a subnet
/// @param currencySymbol currencySymbol for a subnet currency
/// @param chainId subnet network ID
function registerSubnet(
string calldata httpEndpoint,
string calldata wsEndpoint,
uint256 chainId,
string calldata currencySymbol,
string calldata endpointHttp,
string calldata endpointWs,
string calldata logoURL,
string calldata name,
SubnetId subnetId,
string calldata currencySymbol,
uint256 chainId
SubnetId subnetId
) public onlyOwner {
subnetSet.insert(SubnetId.unwrap(subnetId));
Subnet storage subnet = subnets[subnetId];
subnet.httpEndpoint = httpEndpoint;
subnet.wsEndpoint = wsEndpoint;
subnet.chainId = chainId;
subnet.currencySymbol = currencySymbol;
subnet.endpointHttp = endpointHttp;
subnet.endpointWs = endpointWs;
subnet.logoURL = logoURL;
subnet.name = name;
subnet.currencySymbol = currencySymbol;
subnet.chainId = chainId;
emit NewSubnetRegistered(subnetId);
}

Expand Down
16 changes: 8 additions & 8 deletions scripts/register-subnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const main = async function (...args: string[]) {
subnetRegistratorAddress,
subnetName,
subnetChainId,
subnetHttpEndpoint,
subnetWsEndpoint,
subnetEndpointHttp,
subnetEndpointWs,
subnetCurrencySymbol,
subnetLogoUrl,
_adminPrivateKey,
Expand All @@ -29,12 +29,12 @@ const main = async function (...args: string[]) {
process.exit(1)
}

if (!subnetHttpEndpoint) {
if (!subnetEndpointHttp) {
console.error('ERROR: Please provide the subnet HTTP endpoint!')
process.exit(1)
}

if (!subnetWsEndpoint) {
if (!subnetEndpointWs) {
console.error('ERROR: Please provide the subnet WS endpoint!')
process.exit(1)
}
Expand Down Expand Up @@ -108,13 +108,13 @@ const main = async function (...args: string[]) {
}

const tx: ContractTransaction = await contract.registerSubnet(
subnetHttpEndpoint,
subnetWsEndpoint,
subnetChainId,
subnetCurrencySymbol,
subnetEndpointHttp,
subnetEndpointWs,
subnetLogoUrl,
subnetName,
subnetId,
subnetCurrencySymbol,
subnetChainId,
{ gasLimit: 4_000_000 }
)

Expand Down
168 changes: 84 additions & 84 deletions test/topos-core/SubnetRegistrator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { expect } from 'chai'
describe('SubnetRegistrator', () => {
let subnetRegistrator: Contract

const httpEndpoint = 'http://127.0.0.1'
const wsEndpoint = 'ws://127.0.0.1'
const chainId = 1
const currencySymbol = 'SUB'
const endpointHttp = 'http://127.0.0.1'
const endpointWs = 'ws://127.0.0.1'
const logoURL = 'http://image-url.com'
const subnetName = 'Test Subnet'
const name = 'Test Subnet'
const subnetId = ethers.utils.formatBytes32String('subnetId')
const subnetCurrencySymbol = 'SUB'
const chainId = 1

async function deploySubnetRegistratorFixture() {
const [admin, nonAdmin, toposDeployer] = await ethers.getSigners()
Expand All @@ -37,13 +37,13 @@ describe('SubnetRegistrator', () => {
subnetRegistrator
.connect(nonAdmin)
.registerSubnet(
httpEndpoint,
wsEndpoint,
chainId,
currencySymbol,
endpointHttp,
endpointWs,
logoURL,
subnetName,
subnetId,
subnetCurrencySymbol,
chainId
name,
subnetId
)
).to.be.revertedWith('Ownable: caller is not the owner')
})
Expand All @@ -52,27 +52,27 @@ describe('SubnetRegistrator', () => {
const { admin, subnetRegistrator } =
await deploySubnetRegistratorFixture()
await registerSubnet(
httpEndpoint,
wsEndpoint,
admin,
chainId,
currencySymbol,
endpointHttp,
endpointWs,
logoURL,
subnetName,
name,
subnetId,
subnetCurrencySymbol,
chainId,
subnetRegistrator,
admin
subnetRegistrator
)
await expect(
registerSubnet(
httpEndpoint,
wsEndpoint,
admin,
chainId,
currencySymbol,
endpointHttp,
endpointWs,
logoURL,
subnetName,
name,
subnetId,
subnetCurrencySymbol,
chainId,
subnetRegistrator,
admin
subnetRegistrator
)
).to.be.revertedWith('Bytes32Set: key already exists in the set.')
})
Expand All @@ -81,21 +81,21 @@ describe('SubnetRegistrator', () => {
const { admin, subnetRegistrator } =
await deploySubnetRegistratorFixture()
await registerSubnet(
httpEndpoint,
wsEndpoint,
admin,
chainId,
currencySymbol,
endpointHttp,
endpointWs,
logoURL,
subnetName,
name,
subnetId,
subnetCurrencySymbol,
chainId,
subnetRegistrator,
admin
subnetRegistrator
)
const subnet = await subnetRegistrator.subnets(subnetId)
expect(subnet.name).to.equal(subnetName)
expect(subnet.currencySymbol).to.equal(subnetCurrencySymbol)
expect(subnet.httpEndpoint).to.equal(httpEndpoint)
expect(subnet.wsEndpoint).to.equal(wsEndpoint)
expect(subnet.name).to.equal(name)
expect(subnet.currencySymbol).to.equal(currencySymbol)
expect(subnet.endpointHttp).to.equal(endpointHttp)
expect(subnet.endpointWs).to.equal(endpointWs)
expect(subnet.logoURL).to.equal(logoURL)
expect(subnet.chainId).to.equal(chainId)
})
Expand All @@ -104,15 +104,15 @@ describe('SubnetRegistrator', () => {
const { admin, subnetRegistrator } =
await deploySubnetRegistratorFixture()
await registerSubnet(
httpEndpoint,
wsEndpoint,
admin,
chainId,
currencySymbol,
endpointHttp,
endpointWs,
logoURL,
subnetName,
name,
subnetId,
subnetCurrencySymbol,
chainId,
subnetRegistrator,
admin
subnetRegistrator
)
const count = await subnetRegistrator.getSubnetCount()
expect(count).to.equal(1)
Expand All @@ -122,15 +122,15 @@ describe('SubnetRegistrator', () => {
const { admin, subnetRegistrator } =
await deploySubnetRegistratorFixture()
await registerSubnet(
httpEndpoint,
wsEndpoint,
admin,
chainId,
currencySymbol,
endpointHttp,
endpointWs,
logoURL,
subnetName,
name,
subnetId,
subnetCurrencySymbol,
chainId,
subnetRegistrator,
admin
subnetRegistrator
)
const id = await subnetRegistrator.getSubnetIdAtIndex(0)
expect(id).to.equal(subnetId)
Expand All @@ -140,15 +140,15 @@ describe('SubnetRegistrator', () => {
const { admin, subnetRegistrator } =
await deploySubnetRegistratorFixture()
await registerSubnet(
httpEndpoint,
wsEndpoint,
admin,
chainId,
currencySymbol,
endpointHttp,
endpointWs,
logoURL,
subnetName,
name,
subnetId,
subnetCurrencySymbol,
chainId,
subnetRegistrator,
admin
subnetRegistrator
)
const exists = await subnetRegistrator.subnetExists(subnetId)
expect(exists).to.be.true
Expand All @@ -159,15 +159,15 @@ describe('SubnetRegistrator', () => {
await deploySubnetRegistratorFixture()
await expect(
registerSubnet(
httpEndpoint,
wsEndpoint,
admin,
chainId,
currencySymbol,
endpointHttp,
endpointWs,
logoURL,
subnetName,
name,
subnetId,
subnetCurrencySymbol,
chainId,
subnetRegistrator,
admin
subnetRegistrator
)
)
.to.emit(subnetRegistrator, 'NewSubnetRegistered')
Expand Down Expand Up @@ -195,15 +195,15 @@ describe('SubnetRegistrator', () => {
const { admin, subnetRegistrator } =
await deploySubnetRegistratorFixture()
await registerSubnet(
httpEndpoint,
wsEndpoint,
admin,
chainId,
currencySymbol,
endpointHttp,
endpointWs,
logoURL,
subnetName,
name,
subnetId,
subnetCurrencySymbol,
chainId,
subnetRegistrator,
admin
subnetRegistrator
)
await expect(removeSubnet(subnetId, subnetRegistrator, admin))
.to.emit(subnetRegistrator, 'SubnetRemoved')
Expand All @@ -212,26 +212,26 @@ describe('SubnetRegistrator', () => {
})

async function registerSubnet(
httpEndpoint: string,
wsEndpoint: string,
admin: Wallet,
chainId: number,
currencySymbol: string,
endpointHttp: string,
endpointWs: string,
logoURL: string,
subnetName: string,
name: string,
subnetId: string,
subnetCurrencySymbol: string,
chainId: number,
subnetRegistrator: Contract,
admin: Wallet
subnetRegistrator: Contract
) {
return await subnetRegistrator
.connect(admin)
.registerSubnet(
httpEndpoint,
wsEndpoint,
chainId,
currencySymbol,
endpointHttp,
endpointWs,
logoURL,
subnetName,
subnetId,
subnetCurrencySymbol,
chainId
name,
subnetId
)
}

Expand Down

0 comments on commit 08ead8a

Please sign in to comment.