Skip to content

Commit

Permalink
Remove the @alephium/cli dependency from the generated code
Browse files Browse the repository at this point in the history
  • Loading branch information
Lbqds committed Nov 4, 2024
1 parent 80870be commit 5aab432
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 35 deletions.
3 changes: 1 addition & 2 deletions packages/cli/src/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
16 changes: 5 additions & 11 deletions packages/cli/src/deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
25 changes: 3 additions & 22 deletions packages/cli/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -104,27 +106,6 @@ export function getEnv<Settings = unknown>(configFileName?: string, networkId?:
}
}

export interface ExecutionResult {
txId: string
unsignedTx: string
signature: string
gasAmount: number
gasPrice: string
blockHash: string
codeHash: string
attoAlphAmount?: string
tokens?: Record<string, string>
}

export interface DeployContractExecutionResult<I extends ContractInstance = ContractInstance> extends ExecutionResult {
contractInstance: I
issueTokenAmount?: string
}

export interface RunScriptResult extends ExecutionResult {
groupIndex: number
}

export interface Deployer {
provider: NodeProvider
account: Account
Expand Down
40 changes: 40 additions & 0 deletions packages/web3/src/contract/deployment.ts
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/

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<string, string>
}

export interface DeployContractExecutionResult<I extends ContractInstance = ContractInstance> extends ExecutionResult {
contractInstance: I
issueTokenAmount?: string
}

export interface RunScriptResult extends ExecutionResult {
groupIndex: number
}
1 change: 1 addition & 0 deletions packages/web3/src/contract/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ export * from './ralph'
export * from './contract'
export * from './events'
export * from './script-simulator'
export * from './deployment'

0 comments on commit 5aab432

Please sign in to comment.