|
@@ -18,6 +18,7 @@ SUBCOMMANDS:
|
|
|
build Builds the workspace
|
|
|
cluster Cluster commands
|
|
|
deploy Deploys each program in the workspace
|
|
|
+ expand Expands the macros of a program or the workspace
|
|
|
help Prints this message or the help of the given subcommand(s)
|
|
|
idl Commands for interacting with interface definitions
|
|
|
init Initializes a workspace
|
|
@@ -30,21 +31,6 @@ SUBCOMMANDS:
|
|
|
Cargo.toml
|
|
|
```
|
|
|
|
|
|
-## Init
|
|
|
-
|
|
|
-```
|
|
|
-anchor init
|
|
|
-```
|
|
|
-
|
|
|
-Initializes a project workspace with the following structure.
|
|
|
-
|
|
|
-* `Anchor.toml`: Anchor configuration file.
|
|
|
-* `Cargo.toml`: Rust workspace configuration file.
|
|
|
-* `package.json`: JavaScript dependencies file.
|
|
|
-* `programs/`: Directory for Solana program crates.
|
|
|
-* `app/`: Directory for your application frontend.
|
|
|
-* `tests/`: Directory for JavaScript integration tests.
|
|
|
-* `migrations/deploy.js`: Deploy script.
|
|
|
|
|
|
## Build
|
|
|
|
|
@@ -60,77 +46,49 @@ anchor build --verifiable
|
|
|
|
|
|
Runs the build inside a docker image so that the output binary is deterministic (assuming a Cargo.lock file is used). This command must be run from within a single crate subdirectory within the workspace. For example, `programs/<my-program>/`.
|
|
|
|
|
|
-## Deploy
|
|
|
+## Cluster
|
|
|
+
|
|
|
+### Cluster list
|
|
|
|
|
|
```
|
|
|
-anchor deploy
|
|
|
+anchor cluster list
|
|
|
```
|
|
|
|
|
|
-Deploys all programs in the workspace to the configured cluster.
|
|
|
-
|
|
|
-::: tip Note
|
|
|
-This is different from the `solana program deploy` command, because everytime it's run
|
|
|
-it will generate a *new* program address.
|
|
|
-:::
|
|
|
-
|
|
|
-## Upgrade
|
|
|
+This lists cluster endpoints:
|
|
|
|
|
|
```
|
|
|
-anchor upgrade <target/deploy/program.so> --program-id <program-id>
|
|
|
-```
|
|
|
+Cluster Endpoints:
|
|
|
|
|
|
-Uses Solana's upgradeable BPF loader to upgrade the on chain program code.
|
|
|
+* Mainnet - https://solana-api.projectserum.com
|
|
|
+* Mainnet - https://api.mainnet-beta.solana.com
|
|
|
+* Devnet - https://api.devnet.solana.com
|
|
|
+* Testnet - https://api.testnet.solana.com
|
|
|
+```
|
|
|
|
|
|
-## Test
|
|
|
+## Deploy
|
|
|
|
|
|
```
|
|
|
-anchor test
|
|
|
+anchor deploy
|
|
|
```
|
|
|
|
|
|
-Run an integration test suite against the configured cluster, deploying new versions
|
|
|
-of all workspace programs before running them.
|
|
|
-
|
|
|
-If the configured network is a localnet, then automatically starts the localnetwork and runs
|
|
|
-the test.
|
|
|
-
|
|
|
-::: tip Note
|
|
|
-Be sure to shutdown any other local validators, otherwise `anchor test` will fail to run.
|
|
|
-
|
|
|
-If you'd prefer to run the program against your local validator use `anchor test --skip-local-validator`.
|
|
|
-:::
|
|
|
-
|
|
|
-When running tests we stream program logs to `.anchor/program-logs/<address>.<program-name>.log`
|
|
|
+Deploys all programs in the workspace to the configured cluster.
|
|
|
|
|
|
::: tip Note
|
|
|
-The Anchor workflow [recommends](https://www.parity.io/paritys-checklist-for-secure-smart-contract-development/)
|
|
|
-to test your program using integration tests in a language other
|
|
|
-than Rust to make sure that bugs related to syntax misunderstandings
|
|
|
-are coverable with tests and not just replicated in tests.
|
|
|
+This is different from the `solana program deploy` command, because everytime it's run
|
|
|
+it will generate a *new* program address.
|
|
|
:::
|
|
|
|
|
|
-## Migrate
|
|
|
+## Expand
|
|
|
|
|
|
```
|
|
|
-anchor migrate
|
|
|
+anchor expand
|
|
|
```
|
|
|
|
|
|
-Runs the deploy script located at `migrations/deploy.js`, injecting a provider configured
|
|
|
-from the workspace's `Anchor.toml`. For example,
|
|
|
+If run inside a program folder, expands the macros of the program.
|
|
|
|
|
|
-```javascript
|
|
|
-// File: migrations/deploys.js
|
|
|
+If run in the workspace but outside a program folder, expands the macros of the workspace.
|
|
|
|
|
|
-const anchor = require("@project-serum/anchor");
|
|
|
-
|
|
|
-module.exports = async function (provider) {
|
|
|
- anchor.setProvider(provider);
|
|
|
-
|
|
|
- // Add your deploy script here.
|
|
|
-}
|
|
|
-```
|
|
|
-
|
|
|
-Migrations are a new feature
|
|
|
-and only support this simple deploy script at the moment.
|
|
|
+If run with the `--program-name` option, expand only the given program.
|
|
|
|
|
|
## Idl
|
|
|
|
|
@@ -195,6 +153,46 @@ anchor idl set-authority -n <new-authority> -p <program-id>
|
|
|
Sets a new authority on the IDL account. Both the `new-authority` and `program-id`
|
|
|
must be encoded in base 58.
|
|
|
|
|
|
+## Init
|
|
|
+
|
|
|
+```
|
|
|
+anchor init
|
|
|
+```
|
|
|
+
|
|
|
+Initializes a project workspace with the following structure.
|
|
|
+
|
|
|
+* `Anchor.toml`: Anchor configuration file.
|
|
|
+* `Cargo.toml`: Rust workspace configuration file.
|
|
|
+* `package.json`: JavaScript dependencies file.
|
|
|
+* `programs/`: Directory for Solana program crates.
|
|
|
+* `app/`: Directory for your application frontend.
|
|
|
+* `tests/`: Directory for JavaScript integration tests.
|
|
|
+* `migrations/deploy.js`: Deploy script.
|
|
|
+
|
|
|
+## Migrate
|
|
|
+
|
|
|
+```
|
|
|
+anchor migrate
|
|
|
+```
|
|
|
+
|
|
|
+Runs the deploy script located at `migrations/deploy.js`, injecting a provider configured
|
|
|
+from the workspace's `Anchor.toml`. For example,
|
|
|
+
|
|
|
+```javascript
|
|
|
+// File: migrations/deploys.js
|
|
|
+
|
|
|
+const anchor = require("@project-serum/anchor");
|
|
|
+
|
|
|
+module.exports = async function (provider) {
|
|
|
+ anchor.setProvider(provider);
|
|
|
+
|
|
|
+ // Add your deploy script here.
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+Migrations are a new feature
|
|
|
+and only support this simple deploy script at the moment.
|
|
|
+
|
|
|
## New
|
|
|
|
|
|
```
|
|
@@ -203,24 +201,40 @@ anchor new <program-name>
|
|
|
|
|
|
Creates a new program in the workspace's `programs/` directory initialized with boilerplate.
|
|
|
|
|
|
-## Cluster
|
|
|
-
|
|
|
-### Cluster list
|
|
|
+## Test
|
|
|
|
|
|
```
|
|
|
-anchor cluster list
|
|
|
+anchor test
|
|
|
```
|
|
|
|
|
|
-This lists cluster endpoints:
|
|
|
+Run an integration test suit against the configured cluster, deploying new versions
|
|
|
+of all workspace programs before running them.
|
|
|
|
|
|
-```
|
|
|
-Cluster Endpoints:
|
|
|
+If the configured network is a localnet, then automatically starts the localnetwork and runs
|
|
|
+the test.
|
|
|
+
|
|
|
+::: tip Note
|
|
|
+Be sure to shutdown any other local validators, otherwise `anchor test` will fail to run.
|
|
|
+
|
|
|
+If you'd prefer to run the program against your local validator use `anchor test --skip-local-validator`.
|
|
|
+:::
|
|
|
+
|
|
|
+When running tests we stream program logs to `.anchor/program-logs/<address>.<program-name>.log`
|
|
|
+
|
|
|
+::: tip Note
|
|
|
+The Anchor workflow [recommends](https://www.parity.io/paritys-checklist-for-secure-smart-contract-development/)
|
|
|
+to test your program using integration tests in a language other
|
|
|
+than Rust to make sure that bugs related to syntax misunderstandings
|
|
|
+are coverable with tests and not just replicated in tests.
|
|
|
+:::
|
|
|
+
|
|
|
+## Upgrade
|
|
|
|
|
|
-* Mainnet - https://solana-api.projectserum.com
|
|
|
-* Mainnet - https://api.mainnet-beta.solana.com
|
|
|
-* Devnet - https://api.devnet.solana.com
|
|
|
-* Testnet - https://api.testnet.solana.com
|
|
|
```
|
|
|
+anchor upgrade <target/deploy/program.so> --program-id <program-id>
|
|
|
+```
|
|
|
+
|
|
|
+Uses Solana's upgradeable BPF loader to upgrade the on chain program code.
|
|
|
|
|
|
## Verify
|
|
|
|