From 4517d4572c7f2e2770e27a09ddeb91bef58ea67a Mon Sep 17 00:00:00 2001 From: lbqds Date: Fri, 29 Nov 2024 10:20:07 +0800 Subject: [PATCH 1/8] Remove the check for contract deployment --- packages/cli/cli_internal.ts | 16 ++-------------- packages/cli/src/deployment.ts | 4 +--- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/packages/cli/cli_internal.ts b/packages/cli/cli_internal.ts index 24605aafa..661fb4350 100644 --- a/packages/cli/cli_internal.ts +++ b/packages/cli/cli_internal.ts @@ -23,15 +23,7 @@ import path from 'path' import { deployAndSaveProgress } from './scripts/deploy' import { Configuration, DEFAULT_CONFIGURATION_VALUES } from './src/types' import { createProject, genRalph } from './scripts/create-project' -import { - checkFullNodeVersion, - codegen, - getConfigFile, - getSdkFullNodeVersion, - isDeployed, - isNetworkLive, - loadConfig -} from './src' +import { checkFullNodeVersion, codegen, getConfigFile, getSdkFullNodeVersion, isNetworkLive, loadConfig } from './src' import { Project } from './src/project' function getConfig(options: any): Configuration { @@ -111,17 +103,13 @@ program console.log(`Full node version: ${connectedFullNodeVersion}`) const cwd = path.resolve(process.cwd()) - const isContractDeployed = isDeployed(config) - if (!config.forceRecompile && isContractDeployed) { - console.warn(`The contracts has been deployed on testnet/mainnet, and the artifacts will not be updated.`) - } const project = await Project.compile( config.compilerOptions, cwd, config.sourceDir, config.artifactDir, connectedFullNodeVersion, - config.forceRecompile || !isContractDeployed + config.forceRecompile ) console.log('✅ Compilation completed!') if (options.skipGenerate) { diff --git a/packages/cli/src/deployment.ts b/packages/cli/src/deployment.ts index 3f7669acc..6e96f4dd0 100644 --- a/packages/cli/src/deployment.ts +++ b/packages/cli/src/deployment.ts @@ -50,7 +50,6 @@ import { getConfigFile, getDeploymentFilePath, getNetwork, - isDeployed, loadConfig, retryFetch, taskIdToVariable, @@ -597,14 +596,13 @@ export async function deploy( const artifactDir = configuration.artifactDir ?? DEFAULT_CONFIGURATION_VALUES.artifactDir let project: Project | undefined = undefined if (configuration.skipRecompile !== true) { - const forceRecompile = configuration.forceRecompile || !isDeployed(configuration) project = await Project.compile( configuration.compilerOptions, path.resolve(process.cwd()), configuration.sourceDir ?? DEFAULT_CONFIGURATION_VALUES.sourceDir, artifactDir, undefined, - forceRecompile + configuration.forceRecompile ) } From 708c0cf5e3d7b9ae2d11ecb413143f1a3a3810e0 Mon Sep 17 00:00:00 2001 From: lbqds Date: Fri, 29 Nov 2024 09:25:13 +0800 Subject: [PATCH 2/8] Update schema --- packages/web3/src/api/api-alephium.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/web3/src/api/api-alephium.ts b/packages/web3/src/api/api-alephium.ts index 2c79a9d0c..2dd5fae8c 100644 --- a/packages/web3/src/api/api-alephium.ts +++ b/packages/web3/src/api/api-alephium.ts @@ -3041,6 +3041,22 @@ export class Api extends HttpClient + this.request({ + path: `/contracts/${codeHash}/code`, + method: 'GET', + format: 'json', + ...params + }).then(convertHttpResponse), + /** * No description * From 05ba0a7e4c062e77823c17262f74e10d78919c22 Mon Sep 17 00:00:00 2001 From: lbqds Date: Fri, 29 Nov 2024 10:45:06 +0800 Subject: [PATCH 3/8] Introduce skipRecompileIfDeployedOnMainnet flag --- packages/cli/cli_internal.ts | 9 +- packages/cli/src/deployment.ts | 2 +- packages/cli/src/project.ts | 110 +++++++++++++++++++------ packages/cli/src/types.ts | 3 +- packages/web3/src/contract/contract.ts | 17 ++++ 5 files changed, 111 insertions(+), 30 deletions(-) diff --git a/packages/cli/cli_internal.ts b/packages/cli/cli_internal.ts index 661fb4350..f7f58dfc8 100644 --- a/packages/cli/cli_internal.ts +++ b/packages/cli/cli_internal.ts @@ -96,6 +96,12 @@ program throw new Error(`${networkId} is not live`) } + if (config.forceRecompile && config.skipRecompileIfDeployedOnMainnet) { + throw new Error( + `The forceRecompile and skipRecompileIfDeployedOnMainnet flags cannot be enabled at the same time` + ) + } + web3.setCurrentNodeProvider(nodeUrl) const connectedFullNodeVersion = (await web3.getCurrentNodeProvider().infos.getInfosVersion()).version const sdkFullNodeVersion = getSdkFullNodeVersion() @@ -109,7 +115,8 @@ program config.sourceDir, config.artifactDir, connectedFullNodeVersion, - config.forceRecompile + config.forceRecompile, + config.skipRecompileIfDeployedOnMainnet ) console.log('✅ Compilation completed!') if (options.skipGenerate) { diff --git a/packages/cli/src/deployment.ts b/packages/cli/src/deployment.ts index 6e96f4dd0..a1c69adae 100644 --- a/packages/cli/src/deployment.ts +++ b/packages/cli/src/deployment.ts @@ -595,7 +595,7 @@ export async function deploy( const prevProjectArtifact = await ProjectArtifact.from(projectRootDir) const artifactDir = configuration.artifactDir ?? DEFAULT_CONFIGURATION_VALUES.artifactDir let project: Project | undefined = undefined - if (configuration.skipRecompile !== true) { + if (configuration.skipRecompileOnDeployment !== true) { project = await Project.compile( configuration.compilerOptions, path.resolve(process.cwd()), diff --git a/packages/cli/src/project.ts b/packages/cli/src/project.ts index 3897c9701..4566c4a07 100644 --- a/packages/cli/src/project.ts +++ b/packages/cli/src/project.ts @@ -30,7 +30,8 @@ import { CompilerOptions, Constant, Enum, - TraceableError + TraceableError, + getContractByCodeHash } from '@alephium/web3' import * as path from 'path' import fs from 'fs' @@ -38,6 +39,7 @@ import { promises as fsPromises } from 'fs' import { parseError } from './error' const crypto = new WebCrypto() +const mainnetNodeUrl = 'https://node.mainnet.alephium.org' class TypedMatcher { matcher: RegExp @@ -390,18 +392,18 @@ export class Project { contracts: Map>, scripts: Map>, globalWarnings: string[], - changedSources: string[], + changedContracts: string[], forceRecompile: boolean, errorOnWarnings: boolean ): void { const warnings: string[] = forceRecompile ? globalWarnings : [] contracts.forEach((contract) => { - if (Project.needToUpdate(forceRecompile, changedSources, contract.sourceInfo.name)) { + if (Project.needToUpdate(forceRecompile, changedContracts, contract.sourceInfo.name)) { warnings.push(...contract.warnings) } }) scripts.forEach((script) => { - if (Project.needToUpdate(forceRecompile, changedSources, script.sourceInfo.name)) { + if (Project.needToUpdate(forceRecompile, changedContracts, script.sourceInfo.name)) { warnings.push(...script.warnings) } }) @@ -475,8 +477,8 @@ export class Project { return fsPromises.writeFile(filePath, JSON.stringify(object, null, 2)) } - private static needToUpdate(forceRecompile: boolean, changedSources: string[], name: string): boolean { - return forceRecompile || changedSources.includes(name) + private static needToUpdate(forceRecompile: boolean, changedContracts: string[], name: string): boolean { + return forceRecompile || changedContracts.includes(name) } private async checkMethodIndex(newArtifact: Compiled) { @@ -500,7 +502,7 @@ export class Project { private async saveArtifactsToFile( projectRootDir: string, forceRecompile: boolean, - changedSources: string[] + changedContracts: string[] ): Promise { const artifactsRootDir = this.artifactsRootDir const saveToFile = async function (compiled: Compiled): Promise { @@ -512,29 +514,29 @@ export class Project { return fsPromises.writeFile(artifactPath, compiled.artifact.toString()) } for (const [_, contract] of this.contracts) { - if (Project.needToUpdate(forceRecompile, changedSources, contract.sourceInfo.name)) { + if (Project.needToUpdate(forceRecompile, changedContracts, contract.sourceInfo.name)) { await saveToFile(contract) } else { await this.checkMethodIndex(contract) } } for (const [_, script] of this.scripts) { - if (Project.needToUpdate(forceRecompile, changedSources, script.sourceInfo.name)) { + if (Project.needToUpdate(forceRecompile, changedContracts, script.sourceInfo.name)) { await saveToFile(script) } } await this.saveStructsToFile() await this.saveConstantsToFile() - await this.saveProjectArtifact(projectRootDir, forceRecompile, changedSources) + await this.saveProjectArtifact(projectRootDir, forceRecompile, changedContracts) } - private async saveProjectArtifact(projectRootDir: string, forceRecompile: boolean, changedSources: string[]) { + private async saveProjectArtifact(projectRootDir: string, forceRecompile: boolean, changedContracts: string[]) { if (!forceRecompile) { // we should not update the `codeHashDebug` if the `forceRecompile` is disable const prevProjectArtifact = await ProjectArtifact.from(projectRootDir) if (prevProjectArtifact !== undefined) { for (const [name, info] of this.projectArtifact.infos) { - if (!changedSources.includes(name)) { + if (!changedContracts.includes(name)) { const prevInfo = prevProjectArtifact.infos.get(name) info.bytecodeDebugPatch = prevInfo?.bytecodeDebugPatch ?? info.bytecodeDebugPatch info.codeHashDebug = prevInfo?.codeHashDebug ?? info.codeHashDebug @@ -588,6 +590,48 @@ export class Project { } } + private static async getDeployedContracts(sourceInfos: SourceInfo[], artifactsRootDir: string): Promise { + const nodeProvider = new NodeProvider(mainnetNodeUrl) + const result: string[] = [] + for (const sourceInfo of sourceInfos) { + const artifactPath = sourceInfo.getArtifactPath(artifactsRootDir) + if (sourceInfo.type === SourceKind.Contract) { + try { + const content = await fsPromises.readFile(artifactPath) + const artifact = JSON.parse(content.toString()) + const codeHash = artifact['codeHash'] + const contractCode = await getContractByCodeHash(nodeProvider, codeHash) + if (contractCode !== undefined) result.push(artifact.name) + } catch (error) { + console.error(`Failed to load contract artifact: ${sourceInfo.name}`) + } + } + } + return result + } + + private static async filterChangedContracts( + sourceInfos: SourceInfo[], + artifactsRootDir: string, + changedContracts: string[], + skipRecompileIfDeployedOnMainnet: boolean + ): Promise { + if (!skipRecompileIfDeployedOnMainnet) return changedContracts + const deployedContracts = await this.getDeployedContracts(sourceInfos, artifactsRootDir) + const filteredChangedContracts: string[] = [] + changedContracts.forEach((c) => { + if (deployedContracts.includes(c)) { + console.warn( + `The contract ${c} has already been deployed to the mainnet. Even if the contract is updated, the bytecode will not be regenerated. ` + + `To regenerate the bytecode, please enable the forceCompile flag` + ) + } else { + filteredChangedContracts.push(c) + } + }) + return filteredChangedContracts + } + private static async compile_( fullNodeVersion: string, provider: NodeProvider, @@ -597,8 +641,9 @@ export class Project { artifactsRootDir: string, errorOnWarnings: boolean, compilerOptions: node.CompilerOptions, - changedSources: string[], - forceRecompile: boolean + changedContracts: string[], + forceRecompile: boolean, + skipRecompileIfDeployedOnMainnet: boolean ): Promise { const removeDuplicates = sourceInfos.reduce((acc: SourceInfo[], sourceInfo: SourceInfo) => { if (acc.find((info) => info.sourceCodeHash === sourceInfo.sourceCodeHash) === undefined) { @@ -644,7 +689,7 @@ export class Project { contracts, scripts, result.warnings ?? [], - changedSources, + changedContracts, forceRecompile, errorOnWarnings ) @@ -659,7 +704,13 @@ export class Project { result.enums ?? [], projectArtifact ) - await project.saveArtifactsToFile(projectRootDir, forceRecompile, changedSources) + const filteredChangedContracts = await Project.filterChangedContracts( + sourceInfos, + artifactsRootDir, + changedContracts, + skipRecompileIfDeployedOnMainnet + ) + await project.saveArtifactsToFile(projectRootDir, forceRecompile, filteredChangedContracts) return project } @@ -671,8 +722,9 @@ export class Project { artifactsRootDir: string, errorOnWarnings: boolean, compilerOptions: node.CompilerOptions, - changedSources: string[], - forceRecompile: boolean + changedContracts: string[], + forceRecompile: boolean, + skipRecompileIfDeployedOnMainnet: boolean ): Promise { const projectArtifact = await ProjectArtifact.from(projectRootDir) if (projectArtifact === undefined) { @@ -725,8 +777,9 @@ export class Project { artifactsRootDir, errorOnWarnings, compilerOptions, - changedSources, - forceRecompile + changedContracts, + forceRecompile, + skipRecompileIfDeployedOnMainnet ) } } @@ -856,19 +909,20 @@ export class Project { contractsRootDir = Project.DEFAULT_CONTRACTS_DIR, artifactsRootDir = Project.DEFAULT_ARTIFACTS_DIR, defaultFullNodeVersion: string | undefined = undefined, - forceRecompile = false + forceRecompile = false, + skipRecompileIfDeployedOnMainnet = false ): Promise { const provider = web3.getCurrentNodeProvider() const fullNodeVersion = defaultFullNodeVersion ?? (await provider.infos.getInfosVersion()).version const sourceFiles = await Project.loadSourceFiles(projectRootDir, contractsRootDir) const { errorOnWarnings, ...nodeCompilerOptions } = { ...DEFAULT_COMPILER_OPTIONS, ...compilerOptionsPartial } const projectArtifact = await ProjectArtifact.from(projectRootDir) - const changedSources = projectArtifact?.getChangedSources(sourceFiles) ?? sourceFiles.map((s) => s.name) + const changedContracts = projectArtifact?.getChangedSources(sourceFiles) ?? sourceFiles.map((s) => s.name) if ( forceRecompile || projectArtifact === undefined || projectArtifact.needToReCompile(nodeCompilerOptions, fullNodeVersion) || - changedSources.length > 0 + changedContracts.length > 0 ) { if (fs.existsSync(artifactsRootDir)) { removeOldArtifacts(artifactsRootDir, sourceFiles) @@ -883,8 +937,9 @@ export class Project { artifactsRootDir, errorOnWarnings, nodeCompilerOptions, - changedSources, - forceRecompile + changedContracts, + forceRecompile, + skipRecompileIfDeployedOnMainnet ) } // we need to reload those contracts that did not regenerate bytecode @@ -896,8 +951,9 @@ export class Project { artifactsRootDir, errorOnWarnings, nodeCompilerOptions, - changedSources, - forceRecompile + changedContracts, + forceRecompile, + skipRecompileIfDeployedOnMainnet ) } } diff --git a/packages/cli/src/types.ts b/packages/cli/src/types.ts index 772cc3e77..bb19b8f98 100644 --- a/packages/cli/src/types.ts +++ b/packages/cli/src/types.ts @@ -53,12 +53,13 @@ export interface Configuration { deploymentScriptDir?: string deploymentsDir?: string compilerOptions?: CompilerOptions - skipRecompile?: boolean + skipRecompileOnDeployment?: boolean networks: Record> enableDebugMode?: boolean forceRecompile?: boolean + skipRecompileIfDeployedOnMainnet?: boolean } export const DEFAULT_CONFIGURATION_VALUES = { diff --git a/packages/web3/src/contract/contract.ts b/packages/web3/src/contract/contract.ts index c1f0459dd..eef44fbc2 100644 --- a/packages/web3/src/contract/contract.ts +++ b/packages/web3/src/contract/contract.ts @@ -2159,3 +2159,20 @@ export const getContractIdFromUnsignedTx = async ( // This function only works in the simple case where a single non-subcontract is created in the tx export const getTokenIdFromUnsignedTx = getContractIdFromUnsignedTx + +export async function getContractByCodeHash( + nodeProvider: NodeProvider, + codeHash: HexString +): Promise { + if (isHexString(codeHash) && codeHash.length === 64) { + try { + return await nodeProvider.contracts.getContractsCodeHashCode(codeHash) + } catch (error) { + if (error instanceof Error && error.message.includes('not found')) { + return undefined + } + throw new TraceableError(`Failed to get contract by code hash ${codeHash}`, error) + } + } + throw new Error(`Invalid code hash: ${codeHash}`) +} From d0aa6fb0d1a81b533de8f28aef72c3a9288d7f22 Mon Sep 17 00:00:00 2001 From: lbqds Date: Fri, 29 Nov 2024 11:08:20 +0800 Subject: [PATCH 4/8] Introduce skipRecompileContracts config --- packages/cli/cli_internal.ts | 7 +++++- packages/cli/src/project.ts | 47 ++++++++++++++++++++++++++---------- packages/cli/src/types.ts | 1 + 3 files changed, 41 insertions(+), 14 deletions(-) diff --git a/packages/cli/cli_internal.ts b/packages/cli/cli_internal.ts index f7f58dfc8..59ae13a38 100644 --- a/packages/cli/cli_internal.ts +++ b/packages/cli/cli_internal.ts @@ -102,6 +102,10 @@ program ) } + if (config.forceRecompile && (config.skipRecompileContracts ?? []).length > 0) { + throw new Error(`The skipRecompileContracts cannot be specified when forceRecompile is enabled`) + } + web3.setCurrentNodeProvider(nodeUrl) const connectedFullNodeVersion = (await web3.getCurrentNodeProvider().infos.getInfosVersion()).version const sdkFullNodeVersion = getSdkFullNodeVersion() @@ -116,7 +120,8 @@ program config.artifactDir, connectedFullNodeVersion, config.forceRecompile, - config.skipRecompileIfDeployedOnMainnet + config.skipRecompileIfDeployedOnMainnet, + config.skipRecompileContracts ?? [] ) console.log('✅ Compilation completed!') if (options.skipGenerate) { diff --git a/packages/cli/src/project.ts b/packages/cli/src/project.ts index 4566c4a07..48ea85fcd 100644 --- a/packages/cli/src/project.ts +++ b/packages/cli/src/project.ts @@ -603,7 +603,7 @@ export class Project { const contractCode = await getContractByCodeHash(nodeProvider, codeHash) if (contractCode !== undefined) result.push(artifact.name) } catch (error) { - console.error(`Failed to load contract artifact: ${sourceInfo.name}`) + console.error(`Failed to check the contract deployment: ${sourceInfo.name}, error: ${error}`) } } } @@ -614,16 +614,30 @@ export class Project { sourceInfos: SourceInfo[], artifactsRootDir: string, changedContracts: string[], - skipRecompileIfDeployedOnMainnet: boolean + skipRecompileIfDeployedOnMainnet: boolean, + skipRecompileContracts: string[] ): Promise { - if (!skipRecompileIfDeployedOnMainnet) return changedContracts - const deployedContracts = await this.getDeployedContracts(sourceInfos, artifactsRootDir) + let deployedContracts: string[] + if (skipRecompileIfDeployedOnMainnet) { + const remainSourceInfo = sourceInfos.filter( + (s) => s.type === SourceKind.Contract && !skipRecompileContracts.includes(s.name) + ) + deployedContracts = await this.getDeployedContracts(remainSourceInfo, artifactsRootDir) + } else { + deployedContracts = [] + } + const filteredChangedContracts: string[] = [] changedContracts.forEach((c) => { - if (deployedContracts.includes(c)) { + if (skipRecompileContracts.includes(c)) { + console.warn( + `The contract ${c} is in the skipRecompileContracts list. Even if the contract is updated, the code will not be regenerated. ` + + `To regenerate the bytecode, please remove the contract from the skipRecompileContracts list.` + ) + } else if (deployedContracts.includes(c)) { console.warn( `The contract ${c} has already been deployed to the mainnet. Even if the contract is updated, the bytecode will not be regenerated. ` + - `To regenerate the bytecode, please enable the forceCompile flag` + `To regenerate the bytecode, please enable the forceCompile flag.` ) } else { filteredChangedContracts.push(c) @@ -643,7 +657,8 @@ export class Project { compilerOptions: node.CompilerOptions, changedContracts: string[], forceRecompile: boolean, - skipRecompileIfDeployedOnMainnet: boolean + skipRecompileIfDeployedOnMainnet: boolean, + skipRecompileContracts: string[] ): Promise { const removeDuplicates = sourceInfos.reduce((acc: SourceInfo[], sourceInfo: SourceInfo) => { if (acc.find((info) => info.sourceCodeHash === sourceInfo.sourceCodeHash) === undefined) { @@ -708,7 +723,8 @@ export class Project { sourceInfos, artifactsRootDir, changedContracts, - skipRecompileIfDeployedOnMainnet + skipRecompileIfDeployedOnMainnet, + skipRecompileContracts ) await project.saveArtifactsToFile(projectRootDir, forceRecompile, filteredChangedContracts) return project @@ -724,7 +740,8 @@ export class Project { compilerOptions: node.CompilerOptions, changedContracts: string[], forceRecompile: boolean, - skipRecompileIfDeployedOnMainnet: boolean + skipRecompileIfDeployedOnMainnet: boolean, + skipRecompileContracts: string[] ): Promise { const projectArtifact = await ProjectArtifact.from(projectRootDir) if (projectArtifact === undefined) { @@ -779,7 +796,8 @@ export class Project { compilerOptions, changedContracts, forceRecompile, - skipRecompileIfDeployedOnMainnet + skipRecompileIfDeployedOnMainnet, + skipRecompileContracts ) } } @@ -910,7 +928,8 @@ export class Project { artifactsRootDir = Project.DEFAULT_ARTIFACTS_DIR, defaultFullNodeVersion: string | undefined = undefined, forceRecompile = false, - skipRecompileIfDeployedOnMainnet = false + skipRecompileIfDeployedOnMainnet = false, + skipRecompileContracts: string[] = [] ): Promise { const provider = web3.getCurrentNodeProvider() const fullNodeVersion = defaultFullNodeVersion ?? (await provider.infos.getInfosVersion()).version @@ -939,7 +958,8 @@ export class Project { nodeCompilerOptions, changedContracts, forceRecompile, - skipRecompileIfDeployedOnMainnet + skipRecompileIfDeployedOnMainnet, + skipRecompileContracts ) } // we need to reload those contracts that did not regenerate bytecode @@ -953,7 +973,8 @@ export class Project { nodeCompilerOptions, changedContracts, forceRecompile, - skipRecompileIfDeployedOnMainnet + skipRecompileIfDeployedOnMainnet, + skipRecompileContracts ) } } diff --git a/packages/cli/src/types.ts b/packages/cli/src/types.ts index bb19b8f98..1f74dbdcf 100644 --- a/packages/cli/src/types.ts +++ b/packages/cli/src/types.ts @@ -60,6 +60,7 @@ export interface Configuration { enableDebugMode?: boolean forceRecompile?: boolean skipRecompileIfDeployedOnMainnet?: boolean + skipRecompileContracts?: string[] } export const DEFAULT_CONFIGURATION_VALUES = { From bb531ff8145f9431682c9047a2daef71f4ee2801 Mon Sep 17 00:00:00 2001 From: lbqds Date: Fri, 29 Nov 2024 11:29:14 +0800 Subject: [PATCH 5/8] Load mainnet node url from config --- packages/cli/cli_internal.ts | 21 ++++++++++----------- packages/cli/src/deployment.ts | 5 ++++- packages/cli/src/project.ts | 32 ++++++++++++++++++++++---------- 3 files changed, 36 insertions(+), 22 deletions(-) diff --git a/packages/cli/cli_internal.ts b/packages/cli/cli_internal.ts index 59ae13a38..55eae7e03 100644 --- a/packages/cli/cli_internal.ts +++ b/packages/cli/cli_internal.ts @@ -30,6 +30,14 @@ function getConfig(options: any): Configuration { const configFile = options.config ? (options.config as string) : getConfigFile() console.log(`Loading alephium config file: ${configFile}`) const config = loadConfig(configFile) + if (config.forceRecompile && config.skipRecompileIfDeployedOnMainnet) { + throw new Error(`The forceRecompile and skipRecompileIfDeployedOnMainnet flags cannot be enabled at the same time`) + } + + if (config.forceRecompile && (config.skipRecompileContracts ?? []).length > 0) { + throw new Error(`The skipRecompileContracts cannot be specified when forceRecompile is enabled`) + } + const isDebugModeEnabled = config.enableDebugMode || options.debug if (isDebugModeEnabled) enableDebugMode() return { ...config, enableDebugMode: isDebugModeEnabled } @@ -96,16 +104,6 @@ program throw new Error(`${networkId} is not live`) } - if (config.forceRecompile && config.skipRecompileIfDeployedOnMainnet) { - throw new Error( - `The forceRecompile and skipRecompileIfDeployedOnMainnet flags cannot be enabled at the same time` - ) - } - - if (config.forceRecompile && (config.skipRecompileContracts ?? []).length > 0) { - throw new Error(`The skipRecompileContracts cannot be specified when forceRecompile is enabled`) - } - web3.setCurrentNodeProvider(nodeUrl) const connectedFullNodeVersion = (await web3.getCurrentNodeProvider().infos.getInfosVersion()).version const sdkFullNodeVersion = getSdkFullNodeVersion() @@ -121,7 +119,8 @@ program connectedFullNodeVersion, config.forceRecompile, config.skipRecompileIfDeployedOnMainnet, - config.skipRecompileContracts ?? [] + config.skipRecompileContracts ?? [], + config.networks['mainnet'].nodeUrl ) console.log('✅ Compilation completed!') if (options.skipGenerate) { diff --git a/packages/cli/src/deployment.ts b/packages/cli/src/deployment.ts index a1c69adae..6da96fa1e 100644 --- a/packages/cli/src/deployment.ts +++ b/packages/cli/src/deployment.ts @@ -602,7 +602,10 @@ export async function deploy( configuration.sourceDir ?? DEFAULT_CONFIGURATION_VALUES.sourceDir, artifactDir, undefined, - configuration.forceRecompile + configuration.forceRecompile, + configuration.skipRecompileIfDeployedOnMainnet, + configuration.skipRecompileContracts ?? [], + configuration.networks['mainnet'].nodeUrl ) } diff --git a/packages/cli/src/project.ts b/packages/cli/src/project.ts index 48ea85fcd..d9109a8b3 100644 --- a/packages/cli/src/project.ts +++ b/packages/cli/src/project.ts @@ -39,7 +39,7 @@ import { promises as fsPromises } from 'fs' import { parseError } from './error' const crypto = new WebCrypto() -const mainnetNodeUrl = 'https://node.mainnet.alephium.org' +const defaultMainnetNodeUrl = 'https://node.mainnet.alephium.org' class TypedMatcher { matcher: RegExp @@ -590,8 +590,12 @@ export class Project { } } - private static async getDeployedContracts(sourceInfos: SourceInfo[], artifactsRootDir: string): Promise { - const nodeProvider = new NodeProvider(mainnetNodeUrl) + private static async getDeployedContracts( + mainnetNodeUrl: string | undefined, + sourceInfos: SourceInfo[], + artifactsRootDir: string + ): Promise { + const nodeProvider = new NodeProvider(mainnetNodeUrl ?? defaultMainnetNodeUrl) const result: string[] = [] for (const sourceInfo of sourceInfos) { const artifactPath = sourceInfo.getArtifactPath(artifactsRootDir) @@ -611,6 +615,7 @@ export class Project { } private static async filterChangedContracts( + mainnetNodeUrl: string | undefined, sourceInfos: SourceInfo[], artifactsRootDir: string, changedContracts: string[], @@ -622,7 +627,7 @@ export class Project { const remainSourceInfo = sourceInfos.filter( (s) => s.type === SourceKind.Contract && !skipRecompileContracts.includes(s.name) ) - deployedContracts = await this.getDeployedContracts(remainSourceInfo, artifactsRootDir) + deployedContracts = await this.getDeployedContracts(mainnetNodeUrl, remainSourceInfo, artifactsRootDir) } else { deployedContracts = [] } @@ -658,7 +663,8 @@ export class Project { changedContracts: string[], forceRecompile: boolean, skipRecompileIfDeployedOnMainnet: boolean, - skipRecompileContracts: string[] + skipRecompileContracts: string[], + mainnetNodeUrl: string | undefined ): Promise { const removeDuplicates = sourceInfos.reduce((acc: SourceInfo[], sourceInfo: SourceInfo) => { if (acc.find((info) => info.sourceCodeHash === sourceInfo.sourceCodeHash) === undefined) { @@ -720,6 +726,7 @@ export class Project { projectArtifact ) const filteredChangedContracts = await Project.filterChangedContracts( + mainnetNodeUrl, sourceInfos, artifactsRootDir, changedContracts, @@ -741,7 +748,8 @@ export class Project { changedContracts: string[], forceRecompile: boolean, skipRecompileIfDeployedOnMainnet: boolean, - skipRecompileContracts: string[] + skipRecompileContracts: string[], + mainnetNodeUrl: string | undefined ): Promise { const projectArtifact = await ProjectArtifact.from(projectRootDir) if (projectArtifact === undefined) { @@ -797,7 +805,8 @@ export class Project { changedContracts, forceRecompile, skipRecompileIfDeployedOnMainnet, - skipRecompileContracts + skipRecompileContracts, + mainnetNodeUrl ) } } @@ -929,7 +938,8 @@ export class Project { defaultFullNodeVersion: string | undefined = undefined, forceRecompile = false, skipRecompileIfDeployedOnMainnet = false, - skipRecompileContracts: string[] = [] + skipRecompileContracts: string[] = [], + mainnetNodeUrl: string | undefined = undefined ): Promise { const provider = web3.getCurrentNodeProvider() const fullNodeVersion = defaultFullNodeVersion ?? (await provider.infos.getInfosVersion()).version @@ -959,7 +969,8 @@ export class Project { changedContracts, forceRecompile, skipRecompileIfDeployedOnMainnet, - skipRecompileContracts + skipRecompileContracts, + mainnetNodeUrl ) } // we need to reload those contracts that did not regenerate bytecode @@ -974,7 +985,8 @@ export class Project { changedContracts, forceRecompile, skipRecompileIfDeployedOnMainnet, - skipRecompileContracts + skipRecompileContracts, + mainnetNodeUrl ) } } From d51b0bd1aee5fd53874f4628c4c0dcf30f23a815 Mon Sep 17 00:00:00 2001 From: lbqds Date: Fri, 29 Nov 2024 16:23:21 +0800 Subject: [PATCH 6/8] Rename and add more tests --- packages/cli/src/project.ts | 4 ++-- packages/web3/src/contract/contract.ts | 2 +- test/contract.test.ts | 12 +++++++++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/cli/src/project.ts b/packages/cli/src/project.ts index d9109a8b3..873591691 100644 --- a/packages/cli/src/project.ts +++ b/packages/cli/src/project.ts @@ -31,7 +31,7 @@ import { Constant, Enum, TraceableError, - getContractByCodeHash + getContractCodeByCodeHash } from '@alephium/web3' import * as path from 'path' import fs from 'fs' @@ -604,7 +604,7 @@ export class Project { const content = await fsPromises.readFile(artifactPath) const artifact = JSON.parse(content.toString()) const codeHash = artifact['codeHash'] - const contractCode = await getContractByCodeHash(nodeProvider, codeHash) + const contractCode = await getContractCodeByCodeHash(nodeProvider, codeHash) if (contractCode !== undefined) result.push(artifact.name) } catch (error) { console.error(`Failed to check the contract deployment: ${sourceInfo.name}, error: ${error}`) diff --git a/packages/web3/src/contract/contract.ts b/packages/web3/src/contract/contract.ts index eef44fbc2..f8048dcf7 100644 --- a/packages/web3/src/contract/contract.ts +++ b/packages/web3/src/contract/contract.ts @@ -2160,7 +2160,7 @@ export const getContractIdFromUnsignedTx = async ( // This function only works in the simple case where a single non-subcontract is created in the tx export const getTokenIdFromUnsignedTx = getContractIdFromUnsignedTx -export async function getContractByCodeHash( +export async function getContractCodeByCodeHash( nodeProvider: NodeProvider, codeHash: HexString ): Promise { diff --git a/test/contract.test.ts b/test/contract.test.ts index 00325fccf..00e456b4d 100644 --- a/test/contract.test.ts +++ b/test/contract.test.ts @@ -42,7 +42,8 @@ import { MINIMAL_CONTRACT_DEPOSIT, ContractStateWithMaps, getDebugMessagesFromTx, - printDebugMessagesFromTx + printDebugMessagesFromTx, + getContractCodeByCodeHash } from '../packages/web3' import { Contract, Script, getContractIdFromUnsignedTx } from '../packages/web3' import { @@ -885,4 +886,13 @@ describe('contract', function () { const state1 = await sub.fetchState() expect(state1.fields.result).toEqual(1n) }) + + it('should get contract code by code hash', async () => { + const nodeProvider = web3.getCurrentNodeProvider() + const contractCode = await getContractCodeByCodeHash(nodeProvider, Sub.contract.codeHash) + expect(contractCode).toEqual(Sub.contract.bytecode) + const randomHash = binToHex(randomBytes(32)) + const notExist = await getContractCodeByCodeHash(nodeProvider, randomHash) + expect(notExist).toEqual(undefined) + }) }) From 53828bf2ab56d051ce22eb6d157b3279e82f07e0 Mon Sep 17 00:00:00 2001 From: lbqds Date: Fri, 29 Nov 2024 18:08:09 +0800 Subject: [PATCH 7/8] Address comments --- packages/cli/src/project.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/project.ts b/packages/cli/src/project.ts index 873591691..a50b6c1c0 100644 --- a/packages/cli/src/project.ts +++ b/packages/cli/src/project.ts @@ -37,6 +37,7 @@ import * as path from 'path' import fs from 'fs' import { promises as fsPromises } from 'fs' import { parseError } from './error' +import * as fetchRetry from 'fetch-retry' const crypto = new WebCrypto() const defaultMainnetNodeUrl = 'https://node.mainnet.alephium.org' @@ -595,7 +596,19 @@ export class Project { sourceInfos: SourceInfo[], artifactsRootDir: string ): Promise { - const nodeProvider = new NodeProvider(mainnetNodeUrl ?? defaultMainnetNodeUrl) + const nodeProvider = new NodeProvider( + mainnetNodeUrl ?? defaultMainnetNodeUrl, + undefined, + fetchRetry.default(fetch, { + retryOn: [429], + retries: 3, + retryDelay: 1000 + }) + ) + const networkId = (await nodeProvider.infos.getInfosChainParams()).networkId + if (networkId !== 0) { + throw new Error(`The node url ${mainnetNodeUrl} does not point to the mainnet`) + } const result: string[] = [] for (const sourceInfo of sourceInfos) { const artifactPath = sourceInfo.getArtifactPath(artifactsRootDir) From 35cb7d760cdcd4f6ba8edf617e2227ed94358757 Mon Sep 17 00:00:00 2001 From: lbqds Date: Fri, 29 Nov 2024 20:08:59 +0800 Subject: [PATCH 8/8] Update full node to 3.9.1 --- .project.json | 2 +- artifacts/add/Add.ral.json | 2 +- artifacts/add/AddMain.ral.json | 2 +- artifacts/add/DestroyAdd.ral.json | 2 +- artifacts/greeter/Greeter.ral.json | 2 +- artifacts/greeter/GreeterMain.ral.json | 2 +- artifacts/nft/DeprecatedNFTTest1.ral.json | 2 +- artifacts/nft/DeprecatedNFTTest2.ral.json | 2 +- artifacts/nft/DeprecatedNFTTest3.ral.json | 2 +- artifacts/nft/DeprecatedNFTTest4.ral.json | 2 +- artifacts/nft/DeprecatedNFTTest5.ral.json | 2 +- artifacts/nft/DeprecatedNFTTest6.ral.json | 2 +- artifacts/nft/DeprecatedNFTTest7.ral.json | 2 +- artifacts/nft/MintNFTTest.ral.json | 2 +- artifacts/nft/NFTCollectionTest.ral.json | 2 +- artifacts/nft/NFTCollectionWithRoyaltyTest.ral.json | 2 +- artifacts/nft/NFTTest.ral.json | 2 +- artifacts/nft/NFTTestStd.ral.json | 2 +- artifacts/nft/WithdrawNFTCollectionTest.ral.json | 2 +- artifacts/nft/WrongNFTTest.ral.json | 2 +- artifacts/sub/Sub.ral.json | 2 +- artifacts/test/Assert.ral.json | 2 +- artifacts/test/CallScript0.ral.json | 2 +- artifacts/test/CallScript1.ral.json | 2 +- artifacts/test/Debug.ral.json | 2 +- artifacts/test/Deposit.ral.json | 2 +- artifacts/test/DepositToken.ral.json | 2 +- artifacts/test/InsertIntoMap.ral.json | 2 +- artifacts/test/MapTest.ral.json | 2 +- artifacts/test/MapTestWrapper.ral.json | 2 +- artifacts/test/MetaData.ral.json | 2 +- artifacts/test/MultiDeposit.ral.json | 2 +- artifacts/test/MultiWithdraw.ral.json | 2 +- artifacts/test/OwnerOnly.ral.json | 2 +- artifacts/test/RemoveFromMap.ral.json | 2 +- artifacts/test/TemplateArrayVar.ral.json | 2 +- artifacts/test/TestAssert.ral.json | 2 +- artifacts/test/Transact.ral.json | 2 +- artifacts/test/UpdateMapValue.ral.json | 2 +- artifacts/test/UpdateUserAccount.ral.json | 2 +- artifacts/test/UserAccount.ral.json | 2 +- artifacts/test/Warnings.ral.json | 2 +- artifacts/test/Withdraw.ral.json | 2 +- artifacts/token/FakeTokenTest.ral.json | 2 +- artifacts/token/TokenTest.ral.json | 2 +- artifacts/token/TokenTestStd.ral.json | 2 +- docker/docker-compose.yml | 2 +- packages/web3/package.json | 2 +- packages/web3/src/api/api-alephium.ts | 8 ++++---- packages/web3/src/contract/contract.ts | 2 +- 50 files changed, 53 insertions(+), 53 deletions(-) diff --git a/.project.json b/.project.json index 2aafd558a..09e815e61 100644 --- a/.project.json +++ b/.project.json @@ -1,5 +1,5 @@ { - "fullNodeVersion": "v3.9.0", + "fullNodeVersion": "v3.9.1", "compilerOptionsUsed": { "ignoreUnusedConstantsWarnings": false, "ignoreUnusedVariablesWarnings": false, diff --git a/artifacts/add/Add.ral.json b/artifacts/add/Add.ral.json index c3add7e60..df1fcc96e 100644 --- a/artifacts/add/Add.ral.json +++ b/artifacts/add/Add.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "Add", "bytecode": "0206124024404f407440a140af010002100205d34fbb20db1600160100020201000c0c0205d36a51f82d1600160100020200000202021805160016015f06160016015f075da00016002a16012aa100a000160016010e0dce000100020103040c0011d319adf50e1300641600130164170517041603d1a21601160216041605c118010104060015d3f6ce55a6130064160013016417051704160316021340c8ac1603d1a21601160216041605c118010201010003d320f98f621600b0", "codeHash": "6a1f1415a68d55365e205b39e5418cd1f6fc8c2c7926d3662c77d69b55c92681", diff --git a/artifacts/add/AddMain.ral.json b/artifacts/add/AddMain.ral.json index bc09fa32c..487c76fb5 100644 --- a/artifacts/add/AddMain.ral.json +++ b/artifacts/add/AddMain.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "AddMain", "bytecodeTemplate": "0101030002000c{1}{2}17011700160016010e0e{0}01001818", "fieldsSig": { diff --git a/artifacts/add/DestroyAdd.ral.json b/artifacts/add/DestroyAdd.ral.json index d972b02ef..e7929ec86 100644 --- a/artifacts/add/DestroyAdd.ral.json +++ b/artifacts/add/DestroyAdd.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "DestroyAdd", "bytecodeTemplate": "01010300000005{1}0d0c{0}0105", "fieldsSig": { diff --git a/artifacts/greeter/Greeter.ral.json b/artifacts/greeter/Greeter.ral.json index 0cbcaf39a..8b013bbc6 100644 --- a/artifacts/greeter/Greeter.ral.json +++ b/artifacts/greeter/Greeter.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "Greeter", "bytecode": "190111010000000106d3952f757b030c7bce0002", "codeHash": "4bbf82c83dcb0a3df905c290fbc12a19ce5160a7b655c1a347913481da12d747", diff --git a/artifacts/greeter/GreeterMain.ral.json b/artifacts/greeter/GreeterMain.ral.json index 3c5f475f2..b577f728f 100644 --- a/artifacts/greeter/GreeterMain.ral.json +++ b/artifacts/greeter/GreeterMain.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "GreeterMain", "bytecodeTemplate": "01010300020014{0}17000c0d160001000d2f0c7b{0}17010c0d1601d4952f757b0d2f0c7b", "fieldsSig": { diff --git a/artifacts/nft/DeprecatedNFTTest1.ral.json b/artifacts/nft/DeprecatedNFTTest1.ral.json index e7f86ff40..af914c487 100644 --- a/artifacts/nft/DeprecatedNFTTest1.ral.json +++ b/artifacts/nft/DeprecatedNFTTest1.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "DeprecatedNFTTest1", "bytecode": "02010e010000000103d3ee6a5cd5ce0102", "codeHash": "cc6928c9c6777077abcb5b9c4f7c5d620d6cae07ec6f00f5e8b0efe6a7b913c4", diff --git a/artifacts/nft/DeprecatedNFTTest2.ral.json b/artifacts/nft/DeprecatedNFTTest2.ral.json index 2796570c9..94209890a 100644 --- a/artifacts/nft/DeprecatedNFTTest2.ral.json +++ b/artifacts/nft/DeprecatedNFTTest2.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "DeprecatedNFTTest2", "bytecode": "02020e1c010000000103d3ee6a5cd5ce0102010000000103d33e65d93dce0002", "codeHash": "ade9aee476ee752050a1e9e1b19039f05261cb3f53941152617174faf9eae572", diff --git a/artifacts/nft/DeprecatedNFTTest3.ral.json b/artifacts/nft/DeprecatedNFTTest3.ral.json index 09097b04d..c5dbf35fa 100644 --- a/artifacts/nft/DeprecatedNFTTest3.ral.json +++ b/artifacts/nft/DeprecatedNFTTest3.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "DeprecatedNFTTest3", "bytecode": "02020e19010000000103d3ee6a5cd5ce0102010000000001d34d12f529", "codeHash": "465bc3739cd1649e58e0470971bd2fabf21363ab9fc2c15052fb2440dd06ada5", diff --git a/artifacts/nft/DeprecatedNFTTest4.ral.json b/artifacts/nft/DeprecatedNFTTest4.ral.json index ab6b803af..36174e232 100644 --- a/artifacts/nft/DeprecatedNFTTest4.ral.json +++ b/artifacts/nft/DeprecatedNFTTest4.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "DeprecatedNFTTest4", "bytecode": "02020e1b010000000103d3ee6a5cd5ce0102010000000103d35f9a418a0402", "codeHash": "a5de0fa0b3580303ac63423f09ce5ed95fccbf789679b32130a53c26fef182e9", diff --git a/artifacts/nft/DeprecatedNFTTest5.ral.json b/artifacts/nft/DeprecatedNFTTest5.ral.json index a10840489..2d5ff1dbf 100644 --- a/artifacts/nft/DeprecatedNFTTest5.ral.json +++ b/artifacts/nft/DeprecatedNFTTest5.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "DeprecatedNFTTest5", "bytecode": "02020e1e010000000103d3ee6a5cd5ce0102010000000305d35c9ec8a3ce000c0c02", "codeHash": "8b1374f39db98c485af3dd05d0b0ce861e9528f290ca9dc0d7108e8b48b50161", diff --git a/artifacts/nft/DeprecatedNFTTest6.ral.json b/artifacts/nft/DeprecatedNFTTest6.ral.json index f6a916442..3c035c54d 100644 --- a/artifacts/nft/DeprecatedNFTTest6.ral.json +++ b/artifacts/nft/DeprecatedNFTTest6.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "DeprecatedNFTTest6", "bytecode": "02020e1c010000000103d3ee6a5cd5ce0102010000000204d30e0a3ac10c0d02", "codeHash": "8bc0d39f0607d4a771ec70ae1057b71dbcde404177cb3b25fd7d93d553a2b8cd", diff --git a/artifacts/nft/DeprecatedNFTTest7.ral.json b/artifacts/nft/DeprecatedNFTTest7.ral.json index 5b80b012e..e308beed4 100644 --- a/artifacts/nft/DeprecatedNFTTest7.ral.json +++ b/artifacts/nft/DeprecatedNFTTest7.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "DeprecatedNFTTest7", "bytecode": "02020e1d010000000103d3ee6a5cd5ce0102010000000204d3289dd321ce000b02", "codeHash": "b95c9acf088b090f5d9d34f28ab079cf22b9e53af8ae6864113c71172231ef4c", diff --git a/artifacts/nft/MintNFTTest.ral.json b/artifacts/nft/MintNFTTest.ral.json index b6e504e5c..b8eabe878 100644 --- a/artifacts/nft/MintNFTTest.ral.json +++ b/artifacts/nft/MintNFTTest.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "MintNFTTest", "bytecodeTemplate": "01010300000015{2}4c0ab413c40de0b6b3a7640000a2{1}0d0d{0}0107184a09b413c40de0b6b3a7640000a2{1}0d0d{0}010418", "fieldsSig": { diff --git a/artifacts/nft/NFTCollectionTest.ral.json b/artifacts/nft/NFTCollectionTest.ral.json index 6168b4b77..e538aacf9 100644 --- a/artifacts/nft/NFTCollectionTest.ral.json +++ b/artifacts/nft/NFTCollectionTest.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "NFTCollectionTest", "bytecode": "04050912402d4040408a010000000102ce0102010000000102a0000201000102010f16000001310c7b160040cb17011601c50d7b16010201000203000816010002170216001602410e7b01030105011fd3b8b591eeb41701b1a00016001406414c5048000313046413006417031702160113c40de0b6b3a7640000a2a00040ce00160216030d1601c91704a0000d2aa100160402", "codeHash": "087f9292bb326a4d39a6fac09928cb25edf2837718f830f3a166a937f8724779", diff --git a/artifacts/nft/NFTCollectionWithRoyaltyTest.ral.json b/artifacts/nft/NFTCollectionWithRoyaltyTest.ral.json index a37463cd3..4979e3eb2 100644 --- a/artifacts/nft/NFTCollectionWithRoyaltyTest.ral.json +++ b/artifacts/nft/NFTCollectionWithRoyaltyTest.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "NFTCollectionWithRoyaltyTest", "bytecode": "06080912402d40404050405b406c40b6010000000102ce0102010000000102a0000201000102010f16000001310c7b160040cb17011601c50d7b16010201000203000816010002170216001602410e7b0100020201061601ce032c1367102d0201010202000316001601a9010202020008b4ce02450f7b16001601a801030105011fd3b8b591eeb41701b1a00016001406414c5048000313046413006417031702160113c40de0b6b3a7640000a2a00040ce00160216030d1601c91704a0000d2aa100160402", "codeHash": "3b64d5e360566a4e4f568f773536a3ea74e66d12231aa44f19d2214ba87b38d6", diff --git a/artifacts/nft/NFTTest.ral.json b/artifacts/nft/NFTTest.ral.json index acb775d72..4f6bbe983 100644 --- a/artifacts/nft/NFTTest.ral.json +++ b/artifacts/nft/NFTTest.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "NFTTest", "bytecode": "04020914010000000102ce0202010000000203ce00ce0102", "codeHash": "4897086210869e612d82995b765a447c5319a55a56e8a0c3c07b4d9ca81e15b1", diff --git a/artifacts/nft/NFTTestStd.ral.json b/artifacts/nft/NFTTestStd.ral.json index a2e8460cc..cfe373f54 100644 --- a/artifacts/nft/NFTTestStd.ral.json +++ b/artifacts/nft/NFTTestStd.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "NFTTestStd", "bytecode": "040309144020010000000102ce0202010000000203ce00ce0102010000000002d36811cfdd02", "codeHash": "b7ff3fa8dfacc7ae5edbabd6573d0699dffc5a0f07ad14023f682a201b7bce55", diff --git a/artifacts/nft/WithdrawNFTCollectionTest.ral.json b/artifacts/nft/WithdrawNFTCollectionTest.ral.json index ce80b2c7e..191f795e2 100644 --- a/artifacts/nft/WithdrawNFTCollectionTest.ral.json +++ b/artifacts/nft/WithdrawNFTCollectionTest.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "WithdrawNFTCollectionTest", "bytecodeTemplate": "01010300000006b4{1}0e0c{0}0106", "fieldsSig": { diff --git a/artifacts/nft/WrongNFTTest.ral.json b/artifacts/nft/WrongNFTTest.ral.json index c38f9e059..f3c2a61f4 100644 --- a/artifacts/nft/WrongNFTTest.ral.json +++ b/artifacts/nft/WrongNFTTest.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "WrongNFTTest", "bytecode": "04020917010000000102ce0202010000000206040c7bce00ce0102", "codeHash": "7dd2ed643a98b2a1a52a9b9e536fcdae60d961b583b8109f777d846bfdfcae8d", diff --git a/artifacts/sub/Sub.ral.json b/artifacts/sub/Sub.ral.json index 2909cefa0..3e4f324ff 100644 --- a/artifacts/sub/Sub.ral.json +++ b/artifacts/sub/Sub.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "Sub", "bytecode": "01011e01000202010dd321939f9e05160016015fa00016002a16012ba100a00002", "codeHash": "3461ebfaca02ad0a3f587a5b67a461c0cbd82d14261407b1d9277ed4ad129234", diff --git a/artifacts/test/Assert.ral.json b/artifacts/test/Assert.ral.json index 8841064f1..f510249ee 100644 --- a/artifacts/test/Assert.ral.json +++ b/artifacts/test/Assert.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "Assert", "bytecode": "000110010000000006d362d460120d0e2f0f7b", "codeHash": "46dc5e3835be6551dacbf81565912ec67575aa77522312ceed88472817735d6b", diff --git a/artifacts/test/CallScript0.ral.json b/artifacts/test/CallScript0.ral.json index 6eaf9e8b2..3e57ff0ce 100644 --- a/artifacts/test/CallScript0.ral.json +++ b/artifacts/test/CallScript0.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "CallScript0", "bytecodeTemplate": "01010000000206{1}0d0e{0}010302", "fieldsSig": { diff --git a/artifacts/test/CallScript1.ral.json b/artifacts/test/CallScript1.ral.json index a4ee4d947..45e178c1d 100644 --- a/artifacts/test/CallScript1.ral.json +++ b/artifacts/test/CallScript1.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "CallScript1", "bytecodeTemplate": "0101000000070a{1}0d0e{0}01030c11{2}010202", "fieldsSig": { diff --git a/artifacts/test/Debug.ral.json b/artifacts/test/Debug.ral.json index d98f4e05f..6c23eeeee 100644 --- a/artifacts/test/Debug.ral.json +++ b/artifacts/test/Debug.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "Debug", "bytecode": "00010b010000000001d38681d619", "codeHash": "cc0e1966e6847f2c03384e78df1dcd9a0c2b5db1b7c1e901d66e26e2b000eb2c", diff --git a/artifacts/test/Deposit.ral.json b/artifacts/test/Deposit.ral.json index 5e3ca78e6..e474f2211 100644 --- a/artifacts/test/Deposit.ral.json +++ b/artifacts/test/Deposit.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "Deposit", "bytecodeTemplate": "01010300000007b413c40de0b6b3a7640000a20c0c{0}0100", "fieldsSig": { diff --git a/artifacts/test/DepositToken.ral.json b/artifacts/test/DepositToken.ral.json index e64b9f2c6..633a210db 100644 --- a/artifacts/test/DepositToken.ral.json +++ b/artifacts/test/DepositToken.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "DepositToken", "bytecodeTemplate": "01010300000009b4{1}{2}a3{2}0d0c{0}0102", "fieldsSig": { diff --git a/artifacts/test/InsertIntoMap.ral.json b/artifacts/test/InsertIntoMap.ral.json index 8da7bb8bd..9a3897fd8 100644 --- a/artifacts/test/InsertIntoMap.ral.json +++ b/artifacts/test/InsertIntoMap.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "InsertIntoMap", "bytecodeTemplate": "01010300020010{2}{3}17011700{1}d10f2ca2{1}160016010f0c{0}0100", "fieldsSig": { diff --git a/artifacts/test/MapTest.ral.json b/artifacts/test/MapTest.ral.json index 7861373a0..6d83d278b 100644 --- a/artifacts/test/MapTest.ral.json +++ b/artifacts/test/MapTest.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "MapTest", "bytecode": "0004405c40dc4153418001030303001fd3a9cdcc691600d1a2140a5f5f6d61705f5f305f5f160047441601b11602d202011600d1a2140a5f5f6d61705f5f315f5f16014044b11602d201011600d1a2140a5f5f6d61705f5f325f5f1402001144b11602d2010101000104004036d3c50ed2bb0c0d0d140a5f5f6d61705f5f305f5f16004744cb1703160301000c0d0d160301011702170116020d2a0c0e0c140a5f5f6d61705f5f305f5f16004744cb010216020d2a0c0e0c140a5f5f6d61705f5f315f5f16014044cb010216020d2a0c0e0c140a5f5f6d61705f5f325f5f1402001144cb01020100010400402dd392ac08660c0d0d140a5f5f6d61705f5f305f5f16004744cb1703160301000c0d0d160301011702170116000d0c140a5f5f6d61705f5f305f5f16004744cb010316000d0c140a5f5f6d61705f5f315f5f16014044cb010316000d0c140a5f5f6d61705f5f325f5f1402001144cb0103010001020212d3143f7dc50c0d0d140a5f5f6d61705f5f305f5f16004744cb1701160101000c0d0d1601010102", "codeHash": "9c0dad73dd47255270a366794f84539f06816e30c68b1f1cca767707fa8db596", diff --git a/artifacts/test/MapTestWrapper.ral.json b/artifacts/test/MapTestWrapper.ral.json index 2fbf27b0e..ca2f20bb7 100644 --- a/artifacts/test/MapTestWrapper.ral.json +++ b/artifacts/test/MapTestWrapper.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "MapTestWrapper", "bytecode": "01031d4030404301030303000dd3a9cdcc691600d10f2ca21600160116020f0cce000100010001010006d3c50ed2bb16000d0cce000101010001010006d392ac086616000d0cce000102", "codeHash": "1d525d3e4cbd1c8f4c0431bf6881e888eeebae012a14532530097f62dd766e9a", diff --git a/artifacts/test/MetaData.ral.json b/artifacts/test/MetaData.ral.json index 8e4d8ecf3..b8ae8d4da 100644 --- a/artifacts/test/MetaData.ral.json +++ b/artifacts/test/MetaData.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "MetaData", "bytecode": "000319402c4033010300000006d38d0b3636b4b413c40de0b6b3a7640000a702000200000004b413c40de0b6b3a7640000a80200000000000102", "codeHash": "5b113459525557465f1cc5aeee453dfd5823d1a6094372cee6067f7466b40896", diff --git a/artifacts/test/MultiDeposit.ral.json b/artifacts/test/MultiDeposit.ral.json index 24455f114..f510d3f7c 100644 --- a/artifacts/test/MultiDeposit.ral.json +++ b/artifacts/test/MultiDeposit.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "MultiDeposit", "bytecodeTemplate": "0101030002004024{0}{1}17011700b413c40de0b6b3a7640000a20c0c16000100b413c40de0b6b3a7640000a20c0c16010100b4{2}13c40de0b6b3a7640000a313c40de0b6b3a76400000d0c16000102b4{2}13c40de0b6b3a7640000a313c40de0b6b3a76400000d0c16010102", "fieldsSig": { diff --git a/artifacts/test/MultiWithdraw.ral.json b/artifacts/test/MultiWithdraw.ral.json index d665af2de..959b042ff 100644 --- a/artifacts/test/MultiWithdraw.ral.json +++ b/artifacts/test/MultiWithdraw.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "MultiWithdraw", "bytecodeTemplate": "01010300020016{0}{1}170117000c0c160001010c0c1601010113c40de0b6b3a76400000d0c1600010313c40de0b6b3a76400000d0c16010103", "fieldsSig": { diff --git a/artifacts/test/OwnerOnly.ral.json b/artifacts/test/OwnerOnly.ral.json index 151627277..ccd7724ff 100644 --- a/artifacts/test/OwnerOnly.ral.json +++ b/artifacts/test/OwnerOnly.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "OwnerOnly", "bytecode": "010111010000000006d3bf853dbdb4ce00450c7b", "codeHash": "c8ecfd7b7e1f3d0169d80e0abb59702516eeff301d47e0e7be70a631bd9414ca", diff --git a/artifacts/test/RemoveFromMap.ral.json b/artifacts/test/RemoveFromMap.ral.json index 586df9024..1ed2e7c95 100644 --- a/artifacts/test/RemoveFromMap.ral.json +++ b/artifacts/test/RemoveFromMap.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "RemoveFromMap", "bytecodeTemplate": "01010300000005{1}0d0c{0}0102", "fieldsSig": { diff --git a/artifacts/test/TemplateArrayVar.ral.json b/artifacts/test/TemplateArrayVar.ral.json index d7cca2c1a..ac32d6b6b 100644 --- a/artifacts/test/TemplateArrayVar.ral.json +++ b/artifacts/test/TemplateArrayVar.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "TemplateArrayVar", "bytecodeTemplate": "010103000e00408d{1}{2}{3}{4}1703170217011700{6}{7}{8}170617051704{0}18{5}1816030f2f16020e2f1a16010d2f1a16000c2f1a0c7b160016011708170716070c2f16080d2f1a0c7b16021603170a170916090e2f160a0f2f1a0c7b16060e2f16050d2f1a16040c2f1a0c7b0c170b160b0e314c40260c170c160c0e314c1b160b7a0e314d0e2c160c7a0e314d2a78160b0e2c160c2a2f0c7b160c0d2a170c4a21160b0d2a170b4a7fd60c170d160d0f314c11160d7a0f314d102a78160d2f0c7b160d0d2a170d4a2b", "fieldsSig": { diff --git a/artifacts/test/TestAssert.ral.json b/artifacts/test/TestAssert.ral.json index 89db5c9f5..a972733ff 100644 --- a/artifacts/test/TestAssert.ral.json +++ b/artifacts/test/TestAssert.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "TestAssert", "bytecodeTemplate": "010103000000040c0c{0}0100", "fieldsSig": { diff --git a/artifacts/test/Transact.ral.json b/artifacts/test/Transact.ral.json index 82687dd67..024ffbf16 100644 --- a/artifacts/test/Transact.ral.json +++ b/artifacts/test/Transact.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "Transact", "bytecode": "03064027404e40674080408e409c010100010009d353dbb7aab413c40de0b6b3a7640000a9a00013c40de0b6b3a76400002aa10002010200010009d3a248861cb413c40de0b6b3a7640000a8a00013c40de0b6b3a76400002ba1000201010101000ad3bf2d01bdb4ce001600aca00116002aa1010201020101000ad35496306fb4ce001600aba00116002ba10102010000000103d3815a8d0da00002010000000103d3a51b051ca00102", "codeHash": "85e3e9a803741af8e92bd43b1b07cde53f39b86cab0ef1a85bab12b10d691b55", diff --git a/artifacts/test/UpdateMapValue.ral.json b/artifacts/test/UpdateMapValue.ral.json index 4cac34526..eea8763fb 100644 --- a/artifacts/test/UpdateMapValue.ral.json +++ b/artifacts/test/UpdateMapValue.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "UpdateMapValue", "bytecodeTemplate": "01010300000005{1}0d0c{0}0101", "fieldsSig": { diff --git a/artifacts/test/UpdateUserAccount.ral.json b/artifacts/test/UpdateUserAccount.ral.json index 45da16296..f48c512df 100644 --- a/artifacts/test/UpdateUserAccount.ral.json +++ b/artifacts/test/UpdateUserAccount.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "UpdateUserAccount", "bytecodeTemplate": "01010300040015{1}{2}{3}{4}17031702170117001600160116021603100c{0}0100{5}0d0c{0}0101", "fieldsSig": { diff --git a/artifacts/test/UserAccount.ral.json b/artifacts/test/UserAccount.ral.json index b4084112f..f72145724 100644 --- a/artifacts/test/UserAccount.ral.json +++ b/artifacts/test/UserAccount.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "UserAccount", "bytecode": "080340284037404d010004040013d388b067e71600ce01410c7b1602ce02410c7b1601a1021603a103160116032aa101010001010003d3185a39e11600a100010000000507d384cc0995a001ce01a002ce02a00302", "codeHash": "4e9f7eac1b76eaa2268b5af6ebb5640252892dc170aad6c1ee7b639131a55816", diff --git a/artifacts/test/Warnings.ral.json b/artifacts/test/Warnings.ral.json index 0ec9d29a1..74f622e1a 100644 --- a/artifacts/test/Warnings.ral.json +++ b/artifacts/test/Warnings.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "Warnings", "bytecode": "02010c010002020002d31bbce4a602", "codeHash": "873e095edb39cdb4b11b1157003daeacad06d259a938cd270e22b8e89b75feea", diff --git a/artifacts/test/Withdraw.ral.json b/artifacts/test/Withdraw.ral.json index 8672865ca..3f39517ad 100644 --- a/artifacts/test/Withdraw.ral.json +++ b/artifacts/test/Withdraw.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "Withdraw", "bytecodeTemplate": "010103000000040c0c{0}0101", "fieldsSig": { diff --git a/artifacts/token/FakeTokenTest.ral.json b/artifacts/token/FakeTokenTest.ral.json index adf5e5e81..857b04aad 100644 --- a/artifacts/token/FakeTokenTest.ral.json +++ b/artifacts/token/FakeTokenTest.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "FakeTokenTest", "bytecode": "010509121b4024402f010000000103044d18010000000103044d18010000000103044d18010000000103044d18010000000001d38d0b3636", "codeHash": "52f971cb44d54a5353e94dc8db991d2726f76760af782e79bd8a66a9b5b294b7", diff --git a/artifacts/token/TokenTest.ral.json b/artifacts/token/TokenTest.ral.json index a97204d07..e9146b952 100644 --- a/artifacts/token/TokenTest.ral.json +++ b/artifacts/token/TokenTest.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "TokenTest", "bytecode": "050409121b4024010000000102ce0002010000000102ce0102010000000102ce0202010000000102ce0302", "codeHash": "a2800413eb2c5c23d48068db23df5f8eeaba04653e12c8ed59d589720d96dadd", diff --git a/artifacts/token/TokenTestStd.ral.json b/artifacts/token/TokenTestStd.ral.json index a013d4791..5fb8ce858 100644 --- a/artifacts/token/TokenTestStd.ral.json +++ b/artifacts/token/TokenTestStd.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.0", + "version": "v3.9.1", "name": "TokenTestStd", "bytecode": "050509121b40244030010000000102ce0002010000000102ce0102010000000102ce0202010000000102ce0302010000000002d36811cfdd02", "codeHash": "4aa5c769148cada8eeb1cd3791f6e793ed92009ac79ebb64dc79d4d7f2969c8b", diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 2cd4b9fc1..d298a0fc5 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -29,7 +29,7 @@ services: condition: service_healthy alephium: - image: alephium/alephium:v3.9.0 + image: alephium/alephium:v3.9.1 restart: unless-stopped ports: - 19973:19973/tcp diff --git a/packages/web3/package.json b/packages/web3/package.json index 3bf3caa18..43e55cbac 100644 --- a/packages/web3/package.json +++ b/packages/web3/package.json @@ -33,7 +33,7 @@ }, "author": "Alephium dev ", "config": { - "alephium_version": "3.9.0", + "alephium_version": "3.9.1", "explorer_backend_version": "2.3.2" }, "scripts": { diff --git a/packages/web3/src/api/api-alephium.ts b/packages/web3/src/api/api-alephium.ts index 2dd5fae8c..bdfb5e2e6 100644 --- a/packages/web3/src/api/api-alephium.ts +++ b/packages/web3/src/api/api-alephium.ts @@ -1647,7 +1647,7 @@ export class HttpClient { /** * @title Alephium API - * @version 3.9.0 + * @version 3.9.1 * @baseUrl ../ */ export class Api extends HttpClient { @@ -3045,11 +3045,11 @@ export class Api extends HttpClient + getContractsCodehashCode: (codeHash: string, params: RequestParams = {}) => this.request({ path: `/contracts/${codeHash}/code`, method: 'GET', diff --git a/packages/web3/src/contract/contract.ts b/packages/web3/src/contract/contract.ts index f8048dcf7..e1e921d71 100644 --- a/packages/web3/src/contract/contract.ts +++ b/packages/web3/src/contract/contract.ts @@ -2166,7 +2166,7 @@ export async function getContractCodeByCodeHash( ): Promise { if (isHexString(codeHash) && codeHash.length === 64) { try { - return await nodeProvider.contracts.getContractsCodeHashCode(codeHash) + return await nodeProvider.contracts.getContractsCodehashCode(codeHash) } catch (error) { if (error instanceof Error && error.message.includes('not found')) { return undefined