Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DynSigner struct: for Solana CLI usage to wrap Box<dyn Signer> to align with Client<C> #2550

Merged
merged 1 commit into from
Jul 3, 2023

Conversation

ochaloup
Copy link
Contributor

@ochaloup ochaloup commented Jun 27, 2023

When using Solana labs CLI utilities (solana-clap-utils, https://github.com/solana-labs/solana/tree/master/clap-utils -> https://github.com/solana-labs/solana/blob/6b013f46ebd30c82f7fa9c50c5a0e9ae32df3c44/clap-utils/src/keypair.rs#L357) the loaded signer of type Box<dyn Signer> is not aligned to the expected Client<C> type of <C: Clone + Deref<Target = impl Signer>>. Using the dyn Signer fails with error:

the size for values of type `dyn solana_sdk::signature::Signer` cannot be known at compilation time [E0277] doesn't have a size known at compile-time Help: the trait `Sized` is not implemented for `dyn solana_sdk::signature::Signer` Note: required by a bound in `anchor_client::Client::<C>::new_with_options`

Adding the helper DynSigner makes possible to match those types and use the Signer loded from the Solana utils with the Anchor client.

let fee_payer: Arc<dyn Signer> = ...
let anchor_client: Client<Arc<DynSigner>> = Client::new_with_options(
  anchor_cluster,
  Arc::new(DynSigner(fee_payer.clone())),
    CommitmentConfig::confirmed(),
);

@vercel
Copy link

vercel bot commented Jun 27, 2023

@ochaloup is attempting to deploy a commit to the coral-xyz Team on Vercel.

A member of the Team first needs to authorize it.

@acheroncrypto
Copy link
Collaborator

Not sure how much usage will come from solana-clap-utils instead of regular solana-sdk's read_keypair_file and it looks like people are already able to do this themselves(without modifications Anchor).

That being said since the code is very small, I don't see any harm with including this in anchor-client. Could you add an entry to the CHANGELOG?

@ochaloup ochaloup force-pushed the dyn-signer branch 2 times, most recently from ff654f4 to a5ccdbc Compare June 29, 2023 06:24
@ochaloup
Copy link
Contributor Author

@acheroncrypto yes, sure, thank you. I added a description into the CHANGELOG.

CHANGELOG.md Outdated Show resolved Hide resolved
@acheroncrypto acheroncrypto merged commit 401d526 into coral-xyz:master Jul 3, 2023
Aursen added a commit to Aursen/anchor that referenced this pull request Sep 11, 2023
commit cec9946
Author: Jesserc <raymondjesse713@gmail.com>
Date:   Sun Sep 10 20:32:34 2023 +0100

    docs: Fix typo and grammar in error documentation

commit 4955a92
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Fri Sep 8 10:01:51 2023 +0200

    Add byte slice(`&[u8]`) support for `idl-build` (coral-xyz#2622)

commit a1e4453
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Tue Sep 5 17:30:53 2023 +0200

    cli: Make conflicting account names a compile-time error (coral-xyz#2621)

commit b9fa898
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Fri Sep 1 22:42:06 2023 +0200

    cli: Fix `anchor account` command panicking outside of workspace (coral-xyz#2620)

commit dcf5928
Author: Will <82029448+wjthieme@users.noreply.github.com>
Date:   Wed Aug 30 19:28:51 2023 +0200

    lang: `Box` the inner enums of `anchor_lang::error::Error` (coral-xyz#2600)

    Co-authored-by: acheron <acheroncrypto@gmail.com>

commit 115679e
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Mon Aug 28 14:13:12 2023 +0200

    bench: Add benchmarking for stack memory usage (coral-xyz#2617)

commit a5e4c02
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Sun Aug 27 10:21:17 2023 +0200

    ts: Bump packages to `0.28.1-beta.2` (coral-xyz#2616)

commit a7205af
Author: Will <82029448+wjthieme@users.noreply.github.com>
Date:   Wed Aug 23 22:10:08 2023 +0200

    lang: `associated_token` constraints don't work when setting `token_program` (coral-xyz#2603)

    Co-authored-by: acheron <acheroncrypto@gmail.com>

commit 6f9f7d9
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Sat Aug 19 13:09:09 2023 +0200

    tests: Move IDL related tests in `misc` to `idl` (coral-xyz#2606)

commit 6eacad4
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Tue Aug 15 23:58:17 2023 +0200

    cli: Add program template with multiple files (coral-xyz#2602)

commit 454f1dd
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Sun Aug 13 16:50:28 2023 +0200

    ts: Add support for unnamed(tuple) enum in accounts (coral-xyz#2601)

commit b5cf67f
Author: Jimii <30603522+jim4067@users.noreply.github.com>
Date:   Sat Aug 12 23:02:37 2023 +0300

    spl: Add `TokenRecordAccount` for pNFTs (coral-xyz#2597)

commit 58428f8
Author: Proph3t <metaproph3t@protonmail.com>
Date:   Fri Aug 11 19:48:28 2023 +0000

    Add `setup_tests.sh` for setting up your local machine for tests (coral-xyz#2594)

commit 4cf447a
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Tue Aug 8 22:03:31 2023 +0200

    bench: Add benchmarking for program binary size (coral-xyz#2591)

commit abfdc4e
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Sat Aug 5 23:47:06 2023 +0200

    chore: Remove duplicate dependency and and alphabetize features (coral-xyz#2590)

commit 2af9cc6
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Wed Aug 2 23:01:05 2023 +0200

    cli: Improve converting non-conflicting paths to names in IDL (coral-xyz#2588)

commit be8764b
Author: Proph3t <metaproph3t@protonmail.com>
Date:   Tue Aug 1 20:23:48 2023 +0000

    Fix typo in account.rs docs (coral-xyz#2587)

commit b7b8736
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Mon Jul 31 23:41:12 2023 +0200

    spl: Export `mpl-token-metadata` crate (coral-xyz#2583)

commit cad868a
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Sat Jul 29 23:49:17 2023 +0200

    Make the new IDL features explicit (coral-xyz#2582)

commit 8f30f00
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Thu Jul 27 23:29:26 2023 +0200

    tests: Improve IDL comparison tests (coral-xyz#2581)

commit df3e959
Author: Pierre <Arrowana@users.noreply.github.com>
Date:   Thu Jul 27 07:56:12 2023 +1000

    chore: Use @noble/hashes/sha256 rather than obscure package (coral-xyz#2580)

commit 5eb678a
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Tue Jul 25 23:52:26 2023 +0200

    ts: Lazy load workspace programs and improve program name accessor (coral-xyz#2579)

commit 4604fbe
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Sat Jul 22 16:39:05 2023 +0200

    cli: Automatically decide IDL generation method (coral-xyz#2578)

commit c548c85
Author: Jean Marchand (Exotic Markets) <jeanno11@orange.fr>
Date:   Sat Jul 22 12:43:56 2023 +0200

    chore: Remove unused crates (coral-xyz#2577)

commit 2bb3237
Author: Jean Marchand (Exotic Markets) <jeanno11@orange.fr>
Date:   Fri Jul 21 11:04:52 2023 +0200

    chore: Fix clippy lints (coral-xyz#2576)

commit 10eb698
Author: dromaz <92167972+dromaz@users.noreply.github.com>
Date:   Thu Jul 20 23:58:13 2023 +0200

    avm: Add support for the `.anchorversion` file (coral-xyz#2553)

    Co-authored-by: acheron <acheroncrypto@gmail.com>

commit 8309bb3
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Wed Jul 19 18:28:38 2023 +0200

    cli: Fix `anchor build --no-docs` (coral-xyz#2575)

commit c306463
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Mon Jul 17 22:47:55 2023 +0200

    tests: Refactor IDL tests (coral-xyz#2573)

commit cf057ac
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Sun Jul 16 17:08:25 2023 +0200

    client: Fix compilation with Solana `1.14` (coral-xyz#2572)

commit 4e5280b
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Fri Jul 14 23:17:23 2023 +0200

    cli: Fix workspace inheritence (coral-xyz#2570)

commit cfc6d29
Author: Lucas Steuernagel <38472950+LucasSte@users.noreply.github.com>
Date:   Fri Jul 14 16:29:16 2023 -0300

    cli: Bump `solang-parser` version (coral-xyz#2569)

commit 472279d
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Thu Jul 13 22:06:12 2023 +0200

    cli: Add `--out` and `--out-ts` arguments for `idl build` command (coral-xyz#2566)

commit b7e91d4
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Tue Jul 11 19:05:14 2023 +0200

    Remove IDL `path` field (coral-xyz#2564)

commit 6ef6b79
Author: Krešimir Klas <kklas@users.noreply.github.com>
Date:   Sat Jul 8 19:59:30 2023 +0200

    IDL generation through compilation (coral-xyz#2011)

    Co-authored-by: acheron <acheroncrypto@gmail.com>

commit 0225b7c
Author: Noah Prince <83885631+ChewingGlass@users.noreply.github.com>
Date:   Fri Jul 7 14:30:38 2023 -0700

    lang: Allow polymorphic CPI calls matching an interface (coral-xyz#2559)

commit 9ff7dfc
Author: Jean Marchand (Exotic Markets) <jeanno11@orange.fr>
Date:   Wed Jul 5 10:05:37 2023 +0200

    lang: Support for `const` in the `InitSpace` macro (coral-xyz#2555)

commit 401d526
Author: chalda <chalda@marinade.finance>
Date:   Mon Jul 3 22:56:58 2023 +0200

    client: Add `DynSigner` (coral-xyz#2550)

commit e55cd3e
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Sat Jul 1 22:59:36 2023 +0200

    lang: Add `Lamports` trait (coral-xyz#2552)

commit 5624bfe
Author: Jean Marchand (Exotic Markets) <jeanno11@orange.fr>
Date:   Thu Jun 29 13:35:38 2023 +0200

    lang: Fix typo in the doc (coral-xyz#2551)

commit 29b8a72
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Tue Jun 27 20:03:51 2023 +0200

    bench: Show change amount and add change note (coral-xyz#2549)

commit 8bdc1b1
Author: Han Yang <dhy1996@live.com.sg>
Date:   Tue Jun 27 01:04:30 2023 +0800

    spl: Only allow spl-token version above 1.1 (coral-xyz#2546)
Aursen added a commit to Aursen/anchor that referenced this pull request Sep 11, 2023
commit cec9946
Author: Jesserc <raymondjesse713@gmail.com>
Date:   Sun Sep 10 20:32:34 2023 +0100

    docs: Fix typo and grammar in error documentation

commit 4955a92
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Fri Sep 8 10:01:51 2023 +0200

    Add byte slice(`&[u8]`) support for `idl-build` (coral-xyz#2622)

commit a1e4453
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Tue Sep 5 17:30:53 2023 +0200

    cli: Make conflicting account names a compile-time error (coral-xyz#2621)

commit b9fa898
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Fri Sep 1 22:42:06 2023 +0200

    cli: Fix `anchor account` command panicking outside of workspace (coral-xyz#2620)

commit dcf5928
Author: Will <82029448+wjthieme@users.noreply.github.com>
Date:   Wed Aug 30 19:28:51 2023 +0200

    lang: `Box` the inner enums of `anchor_lang::error::Error` (coral-xyz#2600)

    Co-authored-by: acheron <acheroncrypto@gmail.com>

commit 115679e
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Mon Aug 28 14:13:12 2023 +0200

    bench: Add benchmarking for stack memory usage (coral-xyz#2617)

commit a5e4c02
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Sun Aug 27 10:21:17 2023 +0200

    ts: Bump packages to `0.28.1-beta.2` (coral-xyz#2616)

commit a7205af
Author: Will <82029448+wjthieme@users.noreply.github.com>
Date:   Wed Aug 23 22:10:08 2023 +0200

    lang: `associated_token` constraints don't work when setting `token_program` (coral-xyz#2603)

    Co-authored-by: acheron <acheroncrypto@gmail.com>

commit 6f9f7d9
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Sat Aug 19 13:09:09 2023 +0200

    tests: Move IDL related tests in `misc` to `idl` (coral-xyz#2606)

commit 6eacad4
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Tue Aug 15 23:58:17 2023 +0200

    cli: Add program template with multiple files (coral-xyz#2602)

commit 454f1dd
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Sun Aug 13 16:50:28 2023 +0200

    ts: Add support for unnamed(tuple) enum in accounts (coral-xyz#2601)

commit b5cf67f
Author: Jimii <30603522+jim4067@users.noreply.github.com>
Date:   Sat Aug 12 23:02:37 2023 +0300

    spl: Add `TokenRecordAccount` for pNFTs (coral-xyz#2597)

commit 58428f8
Author: Proph3t <metaproph3t@protonmail.com>
Date:   Fri Aug 11 19:48:28 2023 +0000

    Add `setup_tests.sh` for setting up your local machine for tests (coral-xyz#2594)

commit 4cf447a
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Tue Aug 8 22:03:31 2023 +0200

    bench: Add benchmarking for program binary size (coral-xyz#2591)

commit abfdc4e
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Sat Aug 5 23:47:06 2023 +0200

    chore: Remove duplicate dependency and and alphabetize features (coral-xyz#2590)

commit 2af9cc6
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Wed Aug 2 23:01:05 2023 +0200

    cli: Improve converting non-conflicting paths to names in IDL (coral-xyz#2588)

commit be8764b
Author: Proph3t <metaproph3t@protonmail.com>
Date:   Tue Aug 1 20:23:48 2023 +0000

    Fix typo in account.rs docs (coral-xyz#2587)

commit b7b8736
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Mon Jul 31 23:41:12 2023 +0200

    spl: Export `mpl-token-metadata` crate (coral-xyz#2583)

commit cad868a
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Sat Jul 29 23:49:17 2023 +0200

    Make the new IDL features explicit (coral-xyz#2582)

commit 8f30f00
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Thu Jul 27 23:29:26 2023 +0200

    tests: Improve IDL comparison tests (coral-xyz#2581)

commit df3e959
Author: Pierre <Arrowana@users.noreply.github.com>
Date:   Thu Jul 27 07:56:12 2023 +1000

    chore: Use @noble/hashes/sha256 rather than obscure package (coral-xyz#2580)

commit 5eb678a
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Tue Jul 25 23:52:26 2023 +0200

    ts: Lazy load workspace programs and improve program name accessor (coral-xyz#2579)

commit 4604fbe
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Sat Jul 22 16:39:05 2023 +0200

    cli: Automatically decide IDL generation method (coral-xyz#2578)

commit c548c85
Author: Jean Marchand (Exotic Markets) <jeanno11@orange.fr>
Date:   Sat Jul 22 12:43:56 2023 +0200

    chore: Remove unused crates (coral-xyz#2577)

commit 2bb3237
Author: Jean Marchand (Exotic Markets) <jeanno11@orange.fr>
Date:   Fri Jul 21 11:04:52 2023 +0200

    chore: Fix clippy lints (coral-xyz#2576)

commit 10eb698
Author: dromaz <92167972+dromaz@users.noreply.github.com>
Date:   Thu Jul 20 23:58:13 2023 +0200

    avm: Add support for the `.anchorversion` file (coral-xyz#2553)

    Co-authored-by: acheron <acheroncrypto@gmail.com>

commit 8309bb3
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Wed Jul 19 18:28:38 2023 +0200

    cli: Fix `anchor build --no-docs` (coral-xyz#2575)

commit c306463
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Mon Jul 17 22:47:55 2023 +0200

    tests: Refactor IDL tests (coral-xyz#2573)

commit cf057ac
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Sun Jul 16 17:08:25 2023 +0200

    client: Fix compilation with Solana `1.14` (coral-xyz#2572)

commit 4e5280b
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Fri Jul 14 23:17:23 2023 +0200

    cli: Fix workspace inheritence (coral-xyz#2570)

commit cfc6d29
Author: Lucas Steuernagel <38472950+LucasSte@users.noreply.github.com>
Date:   Fri Jul 14 16:29:16 2023 -0300

    cli: Bump `solang-parser` version (coral-xyz#2569)

commit 472279d
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Thu Jul 13 22:06:12 2023 +0200

    cli: Add `--out` and `--out-ts` arguments for `idl build` command (coral-xyz#2566)

commit b7e91d4
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Tue Jul 11 19:05:14 2023 +0200

    Remove IDL `path` field (coral-xyz#2564)

commit 6ef6b79
Author: Krešimir Klas <kklas@users.noreply.github.com>
Date:   Sat Jul 8 19:59:30 2023 +0200

    IDL generation through compilation (coral-xyz#2011)

    Co-authored-by: acheron <acheroncrypto@gmail.com>

commit 0225b7c
Author: Noah Prince <83885631+ChewingGlass@users.noreply.github.com>
Date:   Fri Jul 7 14:30:38 2023 -0700

    lang: Allow polymorphic CPI calls matching an interface (coral-xyz#2559)

commit 9ff7dfc
Author: Jean Marchand (Exotic Markets) <jeanno11@orange.fr>
Date:   Wed Jul 5 10:05:37 2023 +0200

    lang: Support for `const` in the `InitSpace` macro (coral-xyz#2555)

commit 401d526
Author: chalda <chalda@marinade.finance>
Date:   Mon Jul 3 22:56:58 2023 +0200

    client: Add `DynSigner` (coral-xyz#2550)

commit e55cd3e
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Sat Jul 1 22:59:36 2023 +0200

    lang: Add `Lamports` trait (coral-xyz#2552)

commit 5624bfe
Author: Jean Marchand (Exotic Markets) <jeanno11@orange.fr>
Date:   Thu Jun 29 13:35:38 2023 +0200

    lang: Fix typo in the doc (coral-xyz#2551)

commit 29b8a72
Author: acheron <98934430+acheroncrypto@users.noreply.github.com>
Date:   Tue Jun 27 20:03:51 2023 +0200

    bench: Show change amount and add change note (coral-xyz#2549)

commit 8bdc1b1
Author: Han Yang <dhy1996@live.com.sg>
Date:   Tue Jun 27 01:04:30 2023 +0800

    spl: Only allow spl-token version above 1.1 (coral-xyz#2546)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants