Skip to content

Commit

Permalink
Prepare release of 0.8.0 alpha.5 (#410)
Browse files Browse the repository at this point in the history
* [skip ci] - new release commit follows right away

* Update docs (Cairo 0 compilation)

* Update scarb to 0.7.0

* Update devnet to 0.6.3

* Update cairo compiler to 2.2.0

* Remove migrate

---------

Co-authored-by: Petar Penović <[email protected]>
  • Loading branch information
FabijanC and penovicp authored Sep 29, 2023
1 parent ad1a41d commit f6b8019
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 159 deletions.
6 changes: 3 additions & 3 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"CAIRO_LANG": "0.11.2",
"STARKNET_DEVNET": "0.6.0",
"CAIRO_COMPILER": "2.1.0",
"SCARB_VERSION": "0.4.0"
"STARKNET_DEVNET": "0.6.3",
"CAIRO_COMPILER": "2.2.0",
"SCARB_VERSION": "0.7.0"
}
1 change: 1 addition & 0 deletions scripts/test-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ trap 'for killable in $(jobs -p); do kill -9 $killable; done' EXIT
rm -rf starknet-hardhat-example
EXAMPLE_REPO_BRANCH="plugin"
if [[ "$CIRCLE_BRANCH" == "master" ]] && [[ "$EXAMPLE_REPO_BRANCH" != "plugin" ]]; then
# prevents using starknet-hardhat-example branch other than "plugin" when starknet-hardhat-plugin PRs are merged
echo "Invalid example repo branch: $EXAMPLE_REPO_BRANCH"
exit 1
fi
Expand Down
6 changes: 0 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import {
starknetTestAction,
starknetRunAction,
starknetPluginVersionAction,
starknetMigrateAction,
starknetCompileCairo1Action,
starknetBuildAction
} from "./task-actions";
Expand Down Expand Up @@ -353,11 +352,6 @@ task("starknet-plugin-version", "Prints the version of the starknet plugin.").se
starknetPluginVersionAction
);

task("migrate", "Migrates a cairo contract to syntax of cairo-lang v0.10.0.")
.addOptionalVariadicPositionalParam("paths", "The name of the contract to migrate")
.addFlag("inplace", "Applies changes to the files in place.")
.setAction(starknetMigrateAction);

task("amarna", "Runs Amarna, the static-analyzer and linter for Cairo.")
.addFlag("script", "Run ./amarna.sh file to use Amarna with custom args.")
.setAction(amarnaAction);
Expand Down
19 changes: 0 additions & 19 deletions src/starknet-wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ interface NonceQueryWrapperOptions {
blockNumber?: BlockNumber;
}

interface MigrateContractWrapperOptions {
files: string[];
inplace: boolean;
}

export abstract class StarknetWrapper {
constructor(
protected externalServer: ExternalServer,
Expand Down Expand Up @@ -108,7 +103,6 @@ export abstract class StarknetWrapper {
command:
| "starknet-compile-deprecated"
| "get_class_hash"
| "cairo-migrate"
| "get_contract_class"
| "get_contract_class_hash"
| "get_compiled_class_hash",
Expand Down Expand Up @@ -281,19 +275,6 @@ export abstract class StarknetWrapper {
return executed.stdout.toString().trim();
}

public async migrateContract(options: MigrateContractWrapperOptions): Promise<ProcessResult> {
const commandArr = [...options.files];

if (options.inplace) {
commandArr.push("-i");
}
const executed = await this.execute("cairo-migrate", commandArr);
if (executed.statusCode) {
throw new StarknetPluginError(executed.stderr.toString());
}
return executed;
}

public async estimateMessageFee(
functionName: string,
fromAddress: string,
Expand Down
10 changes: 0 additions & 10 deletions src/starknet_cli_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from starkware.starknet.compiler.compile import main as starknet_compile_main
from starkware.starknet.core.os.contract_class.deprecated_class_hash import compute_deprecated_class_hash
from starkware.starknet.services.api.contract_class.contract_class import DeprecatedCompiledClass
from starkware.cairo.lang.migrators.migrator import main as cairo_migrate_main
from starkware.starknet.services.api.contract_class.contract_class import CompiledClass
from starkware.starknet.services.api.contract_class.contract_class_utils import load_sierra
from starkware.starknet.core.os.contract_class.class_hash import compute_class_hash
Expand Down Expand Up @@ -68,21 +67,12 @@ async def get_contract_class_hash(args):
print(hex(compute_class_hash(contract_class)))
return 0

async def cairo_migrate_main_wrapper(args):
sys.argv = [sys.argv[0], *args]
try:
return cairo_migrate_main()
except Exception as err:
print(err, file=sys.stderr)
return 1

MAIN_MAP = {
"starknet": starknet_main_wrapper,
"starknet-compile-deprecated": starknet_compile_main_wrapper,
"get_class_hash": get_class_hash,
"get_contract_class_hash": get_contract_class_hash,
"get_compiled_class_hash": get_compiled_class_hash,
"cairo-migrate": cairo_migrate_main_wrapper
}

class MyRequestHandler(BaseHTTPRequestHandler):
Expand Down
22 changes: 0 additions & 22 deletions src/task-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -620,25 +620,3 @@ Use the "network" property of the "starknet" object in your hardhat config file.
export async function starknetPluginVersionAction() {
console.log(`Version: ${version}`);
}

export async function starknetMigrateAction(args: TaskArguments, hre: HardhatRuntimeEnvironment) {
if (!args.paths || args.paths.length < 1) {
throw new StarknetPluginError("Expected at least one file to migrate");
}

const root = hre.config.paths.root;
const defaultSourcesPath = hre.config.paths.starknetSources;
const files: string[] = args.paths || [defaultSourcesPath];
const cairoFiles: string[] = [];
for (let file of files) {
file = adaptPath(root, file);
cairoFiles.push(file);
}

const result = await hre.starknetWrapper.migrateContract({
files: cairoFiles,
inplace: args.inplace
});

processExecuted(result, true);
}
21 changes: 0 additions & 21 deletions test/general-tests/cairo-migrate/check.ts

This file was deleted.

12 changes: 0 additions & 12 deletions test/general-tests/cairo-migrate/hardhat.config.ts

This file was deleted.

4 changes: 0 additions & 4 deletions test/general-tests/cairo-migrate/network.json

This file was deleted.

21 changes: 0 additions & 21 deletions test/general-tests/cairo-migrate/old_contract.cairo

This file was deleted.

4 changes: 0 additions & 4 deletions test/utils/cli-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ export const hardhatStarknetVerify = (args: Array<string>, expectFailure = false
return exec(`npx hardhat starknet-verify ${args.join(" ")}`, expectFailure);
};

export const hardhatStarknetMigrate = (args: Array<string>, expectFailure = false) => {
return exec(`npx hardhat migrate ${args.join(" ")}`, expectFailure);
};

export const hardhatStarknetPluginVersion = () => {
return exec("npx hardhat starknet-plugin-version");
};
Expand Down
48 changes: 11 additions & 37 deletions www/docs/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ This plugin was tested with:
- Node.js v14.17.3
- npm/npx v7.19.1
- Docker v20.10.8 (optional):
- Since plugin version 0.3.4, Docker is no longer necessary if you opt for a Python environment (more info in [Config](#cairo-version)).
- Since plugin version 0.3.4, Docker is no longer necessary if you opt for a Python environment (more info in [Config](#cairo-0-compilation)).
- If you opt for the containerized version, make sure you have a running Docker daemon.
- If you're experiencing Docker access issues, check [this](https://stackoverflow.com/questions/52364905/after-executing-following-code-of-dockerode-npm-getting-error-connect-eacces-v).
- Linux / macOS:
Expand Down Expand Up @@ -125,7 +125,7 @@ starknet.getContractFactory("MyPackage_FooContract");

The name of the file where the contract was defined doesn't play a role.

The plugin doesn't have a default Scarb command yet (a dockerized wrapper will be supported soon). You need to provide a `scarbCommand` (either an exact command or the path to it) under `starknet` in your hardhat config file, or you can override that via `--scarb-command <COMMAND>`.
The plugin doesn't have a default Scarb command yet. You need to provide a `scarbCommand` (either an exact command or the path to it) under `starknet` in your hardhat config file, or you can override that via `--scarb-command <COMMAND>`.

### `starknet-verify`

Expand All @@ -151,20 +151,6 @@ $ npx hardhat starknet-plugin-version

Prints the version of the plugin.

### `migrate`

```
$ npx hardhat migrate [PATH...] [--inplace]
```

**NOT APPLICABLE TO CAIRO 1**

Converts old syntax to Cairo 0.10 syntax. The `--inplace` flag will change the contract file in place.

```
$ npx hardhat migrate --inplace contract/contract.cairo
```

### `run`

Using `--starknet-network` with `hardhat run` currently does not have effect. Use the `network` property of the `starknet` object in your hardhat config file.
Expand Down Expand Up @@ -515,42 +501,28 @@ If you want to have your debug lines printed in the same terminal as your hardha
Specify custom configuration by editing your project's `hardhat.config.ts` (or `hardhat.config.js`).
### Cairo version
### Cairo 0 compilation
Use this configuration option to select the `cairo-lang`/`starknet` version used by the underlying Docker container.
A Docker image tailored to the machine will be pulled. The `-arm` suffix will be applied to the version name, if it's not applied on `hardhat.config.ts`, if the device's architecture is `arm64`. (e.g. `dockerizedVersion: "0.8.1-arm"` and `dockerizedVersion: "0.8.1"` both will work).
If you specify neither `dockerizedVersion` nor [venv](#existing-virtual-environment), the latest dockerized version is used.
A list of available dockerized versions can be found [here](https://hub.docker.com/r/shardlabs/cairo-cli/tags).
Cairo 0 compilation is by default done using the latest stable Dockerized compiler. If you want to use an older Cairo 0 compiler, specify the full semver string ([available versions](https://hub.docker.com/r/shardlabs/cairo-cli/tags)):
```javascript
module.exports = {
starknet: {
dockerizedVersion: "0.8.1"
// Docker image tailored to the machine is pulled. If not applied, the `-arm` suffix is applied to the version name if on an arm64 machine.
dockerizedVersion: "0.11.2"
}
...
};
```
### Existing virtual environment
If you want to use an existing Python virtual environment (pyenv, poetry, conda, miniconda), specify it by using `starknet["venv"]`.
To use the currently activated environment (or if you have the starknet commands globally installed), set `venv` to `"active"`.
In any case, the specified environment is expected to contain the `python3` command.
If you are on a Mac, you may experience Docker-related issues, so this may be the only way to run the plugin.
If you specify neither [dockerizedVersion](#cairo-version) nor `venv`, the latest dockerized version is used.
If you cannot use Docker (e.g. on Mac), you'll need to have the `cairo-lang` Python package installed locally and `python3` command runnable. Use one of the following:
```typescript
module.exports = {
starknet: {
// venv: "active" <- for the active virtual environment
// venv: "active" <- for the active virtual environment or global environment
// venv: "path/to/my-venv" <- for env created with e.g. `python -m venv path/to/my-venv`
// Python virtual environment can be created with: pyenv, poetry, conda, miniconda, ...
venv: "<VENV_PATH>"
}
};
Expand Down Expand Up @@ -769,6 +741,8 @@ const contractFactory = await starknet.getContractFactory(

Recompilation is performed when contracts are updated or when artifacts are missing. A file will be created with the name `cairo-files-cache.json` to handle caching. Recompilation is handled before the following [CLI commands](#cli-commands) are executed.

This feature is **only** guaranteed to work with Cairo 0 contracts.

- `npx hardhat run`
- `npx hardhat test`

Expand Down

0 comments on commit f6b8019

Please sign in to comment.