From 5aab4321c300232c160dddbd4bee9cb3eb10669f Mon Sep 17 00:00:00 2001 From: lbqds Date: Mon, 4 Nov 2024 08:15:14 +0800 Subject: [PATCH] Remove the @alephium/cli dependency from the generated code --- packages/cli/src/codegen.ts | 3 +- packages/cli/src/deployment.ts | 16 +++------- packages/cli/src/types.ts | 25 ++------------- packages/web3/src/contract/deployment.ts | 40 ++++++++++++++++++++++++ packages/web3/src/contract/index.ts | 1 + 5 files changed, 50 insertions(+), 35 deletions(-) create mode 100644 packages/web3/src/contract/deployment.ts diff --git a/packages/cli/src/codegen.ts b/packages/cli/src/codegen.ts index a7594cd37..a0a18a830 100644 --- a/packages/cli/src/codegen.ts +++ b/packages/cli/src/codegen.ts @@ -815,8 +815,7 @@ export async function genLoadDeployments(config: Configuration) { const source = ` ${header} - import { RunScriptResult, DeployContractExecutionResult } from '@alephium/cli' - import { NetworkId } from '@alephium/web3' + import { RunScriptResult, DeployContractExecutionResult, NetworkId } from '@alephium/web3' import { ${contractInstanceTypes} } from '.' ${imports} diff --git a/packages/cli/src/deployment.ts b/packages/cli/src/deployment.ts index 1f02ede9f..3f7669acc 100644 --- a/packages/cli/src/deployment.ts +++ b/packages/cli/src/deployment.ts @@ -36,22 +36,16 @@ import { ExecutableScript, isHexString, isDevnet, - TraceableError + TraceableError, + DeployContractExecutionResult, + RunScriptResult, + ExecutionResult } from '@alephium/web3' import { PrivateKeyWallet } from '@alephium/web3-wallet' import path from 'path' import fs, { promises as fsPromises } from 'fs' import * as cryptojs from 'crypto-js' -import { - DeployContractExecutionResult, - RunScriptResult, - Network, - Deployer, - DeployFunction, - Configuration, - ExecutionResult, - DEFAULT_CONFIGURATION_VALUES -} from './types' +import { Network, Deployer, DeployFunction, Configuration, DEFAULT_CONFIGURATION_VALUES } from './types' import { getConfigFile, getDeploymentFilePath, diff --git a/packages/cli/src/types.ts b/packages/cli/src/types.ts index b2fa8fc6e..882485bde 100644 --- a/packages/cli/src/types.ts +++ b/packages/cli/src/types.ts @@ -30,7 +30,9 @@ import { web3, DEFAULT_COMPILER_OPTIONS, NetworkId, - ContractInstance + ContractInstance, + DeployContractExecutionResult, + RunScriptResult } from '@alephium/web3' import { getConfigFile, loadConfig } from './utils' import { Project } from './project' @@ -104,27 +106,6 @@ export function getEnv(configFileName?: string, networkId?: } } -export interface ExecutionResult { - txId: string - unsignedTx: string - signature: string - gasAmount: number - gasPrice: string - blockHash: string - codeHash: string - attoAlphAmount?: string - tokens?: Record -} - -export interface DeployContractExecutionResult extends ExecutionResult { - contractInstance: I - issueTokenAmount?: string -} - -export interface RunScriptResult extends ExecutionResult { - groupIndex: number -} - export interface Deployer { provider: NodeProvider account: Account diff --git a/packages/web3/src/contract/deployment.ts b/packages/web3/src/contract/deployment.ts new file mode 100644 index 000000000..88cd63134 --- /dev/null +++ b/packages/web3/src/contract/deployment.ts @@ -0,0 +1,40 @@ +/* +Copyright 2018 - 2022 The Alephium Authors +This file is part of the alephium project. + +The library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +The library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with the library. If not, see . +*/ + +import { ContractInstance } from './contract' + +export interface ExecutionResult { + txId: string + unsignedTx: string + signature: string + gasAmount: number + gasPrice: string + blockHash: string + codeHash: string + attoAlphAmount?: string + tokens?: Record +} + +export interface DeployContractExecutionResult extends ExecutionResult { + contractInstance: I + issueTokenAmount?: string +} + +export interface RunScriptResult extends ExecutionResult { + groupIndex: number +} diff --git a/packages/web3/src/contract/index.ts b/packages/web3/src/contract/index.ts index 270cd6db3..65618310c 100644 --- a/packages/web3/src/contract/index.ts +++ b/packages/web3/src/contract/index.ts @@ -20,3 +20,4 @@ export * from './ralph' export * from './contract' export * from './events' export * from './script-simulator' +export * from './deployment'