Skip to content

Commit

Permalink
Add explicit nameing and fix fn description (#236)
Browse files Browse the repository at this point in the history
* Add explicit nameing and fix website description

* fix build

---------

Co-authored-by: phoebe <[email protected]>
  • Loading branch information
pivilartisant and phoebe authored Jan 31, 2025
1 parent aada304 commit 9faeabe
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions cli/src/lib/index/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ import { storageCostForEntry } from '../utils/storage'
import { updateWebsiteFunctionName } from './const'
import { addressToOwnerBaseKey, indexByOwnerBaseKey } from './keys'
import { getWebsiteOwner } from './read'
import { getOwnerFromWebsiteSC, getSCAddress } from './utils'
import { getOwnerFromWebsiteSC, getIndexSCAddress } from './utils'

/**
* Get the owner of a website using its 'OWNER' storage key
* Update the index smart contract with the given address of a website.
* @param provider - The provider instance
* @param address - The address of the website
*/
export async function updateWebsite(
export async function updateIndexScWebsite(
provider: Provider,
address: string
): Promise<Operation> {
const args = new Args().addString(address)

const scAddress = getSCAddress((await provider.networkInfos()).chainId)
const scAddress = getIndexSCAddress((await provider.networkInfos()).chainId)
const sc = new SmartContract(provider, scAddress)

const estimatedCost = await estimateCost(sc, address)
Expand Down
6 changes: 3 additions & 3 deletions cli/src/lib/index/read.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { bytesToStr, PublicProvider } from '@massalabs/massa-web3'

import { addressToOwnerBaseKey, indexByOwnerBaseKey } from './keys'
import { getSCAddress } from './utils'
import { getIndexSCAddress } from './utils'

/**
* Get the owner of a website according to the index smart contract.
Expand All @@ -13,7 +13,7 @@ export async function getWebsiteOwner(
provider: PublicProvider,
address: string
): Promise<string> {
const scAddress = getSCAddress((await provider.networkInfos()).chainId)
const scAddress = getIndexSCAddress((await provider.networkInfos()).chainId)
const prefix = addressToOwnerBaseKey(address)

const keys = await provider.getStorageKeys(scAddress, prefix)
Expand All @@ -36,7 +36,7 @@ export async function getAddressWebsites(
provider: PublicProvider,
owner: string
): Promise<string[]> {
const scAddress = getSCAddress((await provider.networkInfos()).chainId)
const scAddress = getIndexSCAddress((await provider.networkInfos()).chainId)
const prefix = indexByOwnerBaseKey(owner)

const keys = await provider.getStorageKeys(scAddress, prefix)
Expand Down
2 changes: 1 addition & 1 deletion cli/src/lib/index/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export async function getOwnerFromWebsiteSC(
* @param chainId - The chain id of the network to get the index smart contract address for
* @returns The index smart contract address
*/
export function getSCAddress(chainId: bigint): string {
export function getIndexSCAddress(chainId: bigint): string {
switch (chainId) {
case CHAIN_ID.Mainnet:
return MAINNET_INDEX_ADDRESS
Expand Down
4 changes: 2 additions & 2 deletions cli/src/tasks/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ListrEnquirerPromptAdapter } from '@listr2/prompt-adapter-enquirer'
import { formatMas } from '@massalabs/massa-web3'
import { ListrTask } from 'listr2'

import { updateWebsite } from '../lib/index'
import { updateIndexScWebsite } from '../lib/index'
import { deployCost, deploySC } from '../lib/website/deploySC'

import { UploadCtx } from './tasks'
Expand Down Expand Up @@ -70,7 +70,7 @@ export function deploySCTask(): ListrTask {

subTask.output =
'Updating the DeWeb Index with the new SC address'
await updateWebsite(provider, ctx.sc.address)
await updateIndexScWebsite(provider, ctx.sc.address)
},
rendererOptions: {
outputBar: Infinity,
Expand Down

0 comments on commit 9faeabe

Please sign in to comment.