From 31e45f40edcb81ab53a7c38c9ac90c619aaa1b34 Mon Sep 17 00:00:00 2001 From: Jon C Date: Tue, 24 Oct 2023 01:20:51 +0200 Subject: [PATCH] transfer-hook: Move interface and example into subfolders --- .github/workflows/pull-request-token.yml | 2 +- Cargo.toml | 4 ++-- docs/src/token-2022/extensions.mdx | 10 +++++----- token/client/Cargo.toml | 2 +- token/program-2022-test/Cargo.toml | 4 ++-- token/program-2022/Cargo.toml | 2 +- .../example}/Cargo.toml | 8 ++++---- .../example}/README.md | 2 +- .../example}/src/entrypoint.rs | 0 .../example}/src/lib.rs | 0 .../example}/src/processor.rs | 0 .../example}/src/state.rs | 0 .../example}/tests/functional.rs | 0 .../interface}/Cargo.toml | 10 +++++----- .../interface}/README.md | 4 ++-- .../interface}/src/error.rs | 0 .../interface}/src/instruction.rs | 0 .../interface}/src/lib.rs | 0 .../interface}/src/offchain.rs | 0 .../interface}/src/onchain.rs | 0 20 files changed, 24 insertions(+), 24 deletions(-) rename token/{transfer-hook-example => transfer-hook/example}/Cargo.toml (61%) rename token/{transfer-hook-example => transfer-hook/example}/README.md (96%) rename token/{transfer-hook-example => transfer-hook/example}/src/entrypoint.rs (100%) rename token/{transfer-hook-example => transfer-hook/example}/src/lib.rs (100%) rename token/{transfer-hook-example => transfer-hook/example}/src/processor.rs (100%) rename token/{transfer-hook-example => transfer-hook/example}/src/state.rs (100%) rename token/{transfer-hook-example => transfer-hook/example}/tests/functional.rs (100%) rename token/{transfer-hook-interface => transfer-hook/interface}/Cargo.toml (55%) rename token/{transfer-hook-interface => transfer-hook/interface}/README.md (98%) rename token/{transfer-hook-interface => transfer-hook/interface}/src/error.rs (100%) rename token/{transfer-hook-interface => transfer-hook/interface}/src/instruction.rs (100%) rename token/{transfer-hook-interface => transfer-hook/interface}/src/lib.rs (100%) rename token/{transfer-hook-interface => transfer-hook/interface}/src/offchain.rs (100%) rename token/{transfer-hook-interface => transfer-hook/interface}/src/onchain.rs (100%) diff --git a/.github/workflows/pull-request-token.yml b/.github/workflows/pull-request-token.yml index 575c1fc9419..f01dcbaeb67 100644 --- a/.github/workflows/pull-request-token.yml +++ b/.github/workflows/pull-request-token.yml @@ -146,7 +146,7 @@ jobs: echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH - name: Build and test transfer hook example - run: ./ci/cargo-test-sbf.sh token/transfer-hook-example + run: ./ci/cargo-test-sbf.sh token/transfer-hook/example - name: Upload program uses: actions/upload-artifact@v2 diff --git a/Cargo.toml b/Cargo.toml index d4f442d410b..f6f1dd68302 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -57,8 +57,8 @@ members = [ "token/program", "token/program-2022", "token/program-2022-test", - "token/transfer-hook-example", - "token/transfer-hook-interface", + "token/transfer-hook/example", + "token/transfer-hook/interface", "token/client", "utils/cgen", "utils/test-client", diff --git a/docs/src/token-2022/extensions.mdx b/docs/src/token-2022/extensions.mdx index e617764b466..204d6dd7590 100644 --- a/docs/src/token-2022/extensions.mdx +++ b/docs/src/token-2022/extensions.mdx @@ -1346,22 +1346,22 @@ explained in detail in many of the linked `README` files below under #### Resources The interface description and structs exist at -[spl-transfer-hook-interface](https://github.com/solana-labs/solana-program-library/tree/master/token/transfer-hook-interface), +[spl-transfer-hook-interface](https://github.com/solana-labs/solana-program-library/tree/master/token/transfer-hook/interface), along with a sample minimal program implementation. You can find detailed instructions on how to implement this interface for an on-chain program or interact with a program that implements transfer-hook in the repository's -[README](https://github.com/solana-labs/solana-program-library/tree/master/token/transfer-hook-interface/README.md). +[README](https://github.com/solana-labs/solana-program-library/tree/master/token/transfer-hook/interface/README.md). The `spl-transfer-hook-interface` library provides offchain and onchain helpers for resolving the additional accounts required. See -[invoke.rs](https://github.com/solana-labs/solana-program-library/tree/master/token/transfer-hook-interface/src/invoke.rs) +[invoke.rs](https://github.com/solana-labs/solana-program-library/tree/master/token/transfer-hook/interface/src/invoke.rs) for usage on-chain, and -[offchain.rs](https://github.com/solana-labs/solana-program-library/tree/master/token/transfer-hook-interface/src/offchain.rs) +[offchain.rs](https://github.com/solana-labs/solana-program-library/tree/master/token/transfer-hook/interface/src/offchain.rs) for fetching the additional required account metas with any async off-chain client like `BanksClient` or `RpcClient`. A usable example program exists at -[spl-transfer-hook-example](https://github.com/solana-labs/solana-program-library/tree/master/token/transfer-hook-example). +[spl-transfer-hook-example](https://github.com/solana-labs/solana-program-library/tree/master/token/transfer-hook/example). Token-2022 uses this example program in tests to ensure that it properly uses the transfer hook interface. diff --git a/token/client/Cargo.toml b/token/client/Cargo.toml index 9c209264e3c..adfcd321074 100644 --- a/token/client/Cargo.toml +++ b/token/client/Cargo.toml @@ -25,7 +25,7 @@ spl-memo = { version = "4.0.0", path = "../../memo/program", features = ["no-ent spl-token = { version = "4.0", path="../program", features = [ "no-entrypoint" ] } spl-token-2022 = { version = "0.9", path="../program-2022" } spl-token-metadata-interface = { version = "0.2", path="../../token-metadata/interface" } -spl-transfer-hook-interface = { version = "0.3", path="../transfer-hook-interface" } +spl-transfer-hook-interface = { version = "0.3", path="../transfer-hook/interface" } thiserror = "1.0" [features] diff --git a/token/program-2022-test/Cargo.toml b/token/program-2022-test/Cargo.toml index 75068f62fd4..3ecd10c686c 100644 --- a/token/program-2022-test/Cargo.toml +++ b/token/program-2022-test/Cargo.toml @@ -30,6 +30,6 @@ spl-token-2022 = { version = "0.9", path="../program-2022", features = ["no-entr spl-instruction-padding = { version = "0.1.0", path="../../instruction-padding/program", features = ["no-entrypoint"] } spl-token-client = { version = "0.7", path = "../client" } spl-token-metadata-interface = { version = "0.2", path = "../../token-metadata/interface" } -spl-transfer-hook-example = { version = "0.3", path="../transfer-hook-example", features = ["no-entrypoint"] } -spl-transfer-hook-interface = { version = "0.3", path="../transfer-hook-interface" } +spl-transfer-hook-example = { version = "0.3", path="../transfer-hook/example", features = ["no-entrypoint"] } +spl-transfer-hook-interface = { version = "0.3", path="../transfer-hook/interface" } test-case = "3.2" diff --git a/token/program-2022/Cargo.toml b/token/program-2022/Cargo.toml index a3e014566e7..7d4167340df 100644 --- a/token/program-2022/Cargo.toml +++ b/token/program-2022/Cargo.toml @@ -28,7 +28,7 @@ solana-zk-token-sdk = "1.17.2" spl-memo = { version = "4.0.0", path = "../../memo/program", features = [ "no-entrypoint" ] } spl-token = { version = "4.0", path = "../program", features = ["no-entrypoint"] } spl-token-metadata-interface = { version = "0.2.0", path = "../../token-metadata/interface" } -spl-transfer-hook-interface = { version = "0.3.0", path = "../transfer-hook-interface" } +spl-transfer-hook-interface = { version = "0.3.0", path = "../transfer-hook/interface" } spl-type-length-value = { version = "0.3.0", path = "../../libraries/type-length-value" } spl-pod = { version = "0.1.0", path = "../../libraries/pod" } thiserror = "1.0" diff --git a/token/transfer-hook-example/Cargo.toml b/token/transfer-hook/example/Cargo.toml similarity index 61% rename from token/transfer-hook-example/Cargo.toml rename to token/transfer-hook/example/Cargo.toml index 101ad3d24c0..b8a48219254 100644 --- a/token/transfer-hook-example/Cargo.toml +++ b/token/transfer-hook/example/Cargo.toml @@ -14,10 +14,10 @@ test-sbf = [] [dependencies] arrayref = "0.3.7" solana-program = "1.17.2" -spl-tlv-account-resolution = { version = "0.4" , path = "../../libraries/tlv-account-resolution" } -spl-token-2022 = { version = "0.9", path = "../program-2022", features = ["no-entrypoint"] } -spl-transfer-hook-interface = { version = "0.3" , path = "../transfer-hook-interface" } -spl-type-length-value = { version = "0.3" , path = "../../libraries/type-length-value" } +spl-tlv-account-resolution = { version = "0.4" , path = "../../../libraries/tlv-account-resolution" } +spl-token-2022 = { version = "0.9", path = "../../program-2022", features = ["no-entrypoint"] } +spl-transfer-hook-interface = { version = "0.3" , path = "../interface" } +spl-type-length-value = { version = "0.3" , path = "../../../libraries/type-length-value" } [dev-dependencies] solana-program-test = "1.17.2" diff --git a/token/transfer-hook-example/README.md b/token/transfer-hook/example/README.md similarity index 96% rename from token/transfer-hook-example/README.md rename to token/transfer-hook/example/README.md index 1988b78d515..f3d2aef4a4b 100644 --- a/token/transfer-hook-example/README.md +++ b/token/transfer-hook/example/README.md @@ -4,7 +4,7 @@ Full example program and tests implementing the `spl-transfer-hook-interface`, to be used for testing a program that calls into the `spl-transfer-hook-interface`. See the -[SPL Transfer Hook Interface](https://github.com/solana-labs/solana-program-library/tree/master/token/transfer-hook-interface) +[SPL Transfer Hook Interface](https://github.com/solana-labs/solana-program-library/tree/master/token/transfer-hook/interface) code for more information. ### Example usage of example diff --git a/token/transfer-hook-example/src/entrypoint.rs b/token/transfer-hook/example/src/entrypoint.rs similarity index 100% rename from token/transfer-hook-example/src/entrypoint.rs rename to token/transfer-hook/example/src/entrypoint.rs diff --git a/token/transfer-hook-example/src/lib.rs b/token/transfer-hook/example/src/lib.rs similarity index 100% rename from token/transfer-hook-example/src/lib.rs rename to token/transfer-hook/example/src/lib.rs diff --git a/token/transfer-hook-example/src/processor.rs b/token/transfer-hook/example/src/processor.rs similarity index 100% rename from token/transfer-hook-example/src/processor.rs rename to token/transfer-hook/example/src/processor.rs diff --git a/token/transfer-hook-example/src/state.rs b/token/transfer-hook/example/src/state.rs similarity index 100% rename from token/transfer-hook-example/src/state.rs rename to token/transfer-hook/example/src/state.rs diff --git a/token/transfer-hook-example/tests/functional.rs b/token/transfer-hook/example/tests/functional.rs similarity index 100% rename from token/transfer-hook-example/tests/functional.rs rename to token/transfer-hook/example/tests/functional.rs diff --git a/token/transfer-hook-interface/Cargo.toml b/token/transfer-hook/interface/Cargo.toml similarity index 55% rename from token/transfer-hook-interface/Cargo.toml rename to token/transfer-hook/interface/Cargo.toml index 1029761fa5a..79644bcd4ee 100644 --- a/token/transfer-hook-interface/Cargo.toml +++ b/token/transfer-hook/interface/Cargo.toml @@ -11,11 +11,11 @@ edition = "2021" arrayref = "0.3.7" bytemuck = { version = "1.14.0", features = ["derive"] } solana-program = "1.17.2" -spl-discriminator = { version = "0.1" , path = "../../libraries/discriminator" } -spl-program-error = { version = "0.3" , path = "../../libraries/program-error" } -spl-tlv-account-resolution = { version = "0.4" , path = "../../libraries/tlv-account-resolution" } -spl-type-length-value = { version = "0.3" , path = "../../libraries/type-length-value" } -spl-pod = { version = "0.1", path = "../../libraries/pod" } +spl-discriminator = { version = "0.1" , path = "../../../libraries/discriminator" } +spl-program-error = { version = "0.3" , path = "../../../libraries/program-error" } +spl-tlv-account-resolution = { version = "0.4" , path = "../../../libraries/tlv-account-resolution" } +spl-type-length-value = { version = "0.3" , path = "../../../libraries/type-length-value" } +spl-pod = { version = "0.1", path = "../../../libraries/pod" } [lib] crate-type = ["cdylib", "lib"] diff --git a/token/transfer-hook-interface/README.md b/token/transfer-hook/interface/README.md similarity index 98% rename from token/transfer-hook-interface/README.md rename to token/transfer-hook/interface/README.md index 1a149f7d54b..84dab20d08d 100644 --- a/token/transfer-hook-interface/README.md +++ b/token/transfer-hook/interface/README.md @@ -142,8 +142,8 @@ program: The `spl-transfer-hook-interface` library provides offchain and onchain helpers for resolving the additional accounts required. See -[invoke.rs](https://github.com/solana-labs/solana-program-library/tree/master/token/transfer-hook-interface/src/invoke.rs) +[invoke.rs](https://github.com/solana-labs/solana-program-library/tree/master/token/transfer-hook/interface/src/invoke.rs) for usage on-chain, and -[offchain.rs](https://github.com/solana-labs/solana-program-library/tree/master/token/transfer-hook-interface/src/offchain.rs) +[offchain.rs](https://github.com/solana-labs/solana-program-library/tree/master/token/transfer-hook/interface/src/offchain.rs) for fetching the additional required account metas with any async off-chain client like `BanksClient` or `RpcClient`. diff --git a/token/transfer-hook-interface/src/error.rs b/token/transfer-hook/interface/src/error.rs similarity index 100% rename from token/transfer-hook-interface/src/error.rs rename to token/transfer-hook/interface/src/error.rs diff --git a/token/transfer-hook-interface/src/instruction.rs b/token/transfer-hook/interface/src/instruction.rs similarity index 100% rename from token/transfer-hook-interface/src/instruction.rs rename to token/transfer-hook/interface/src/instruction.rs diff --git a/token/transfer-hook-interface/src/lib.rs b/token/transfer-hook/interface/src/lib.rs similarity index 100% rename from token/transfer-hook-interface/src/lib.rs rename to token/transfer-hook/interface/src/lib.rs diff --git a/token/transfer-hook-interface/src/offchain.rs b/token/transfer-hook/interface/src/offchain.rs similarity index 100% rename from token/transfer-hook-interface/src/offchain.rs rename to token/transfer-hook/interface/src/offchain.rs diff --git a/token/transfer-hook-interface/src/onchain.rs b/token/transfer-hook/interface/src/onchain.rs similarity index 100% rename from token/transfer-hook-interface/src/onchain.rs rename to token/transfer-hook/interface/src/onchain.rs