Cure Obtuse Solana RPC Interfaces with More Anchor #2044
mmjp-rusty
started this conversation in
Ideas
Replies: 1 comment
-
Another good example is candy machine. All of this length information should be declared in the IDL. If it were declared as an expression, derived from params and compile time known constants, then the pre-allocation of the account can be auto generated.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've been ruminating on why Solana Program interfaces feel heavy. I think Anchor can solve this.
The Problem:
"Sensible Defaults are Impossible" with native Solana.
I think it comes down to state allocation. Solana programs either can't or don't allocate new accounts from what I can tell. Any state that the program needs created, has to be created in advance., and then passed in via the context arg as "accounts".
This forces all callers to be aware not only of the interface of a function they want to call, but also its inner implementation detail, because you have to be aware of any state that it may need to "create".
You cant then have useful overloads, wrappers or abstractions that "create all the things' For you with sensible defaults. Said another way, you can't have "simple" or "low barrier to entry" interfaces. Callers must intimately understand not just the function interface, but also its implementation, to invoke it. This steepens the learning curve and increases cognitive load/complexity.
If Sensible defaults are the cure to obtuse contracts, and sensible defaults are impossible, because state allocation is impossible, then you will have obtuse contracts.
Proposal:
This could possibly be further abstracted away by the Anchor framework. It would require you to annotate your methods, so that sensible defaults for account creation could be derived deterministically.
These derived account defaults could either be annotated with static values as their default "initial" value, or with strategies for contextually deriving defaults from other invocation args or context state. Then if the account is provided at invocation time, the provided account is used, else a default is generated using the described strategy.
e.g.
Ideally this would be just
Accomplished by annotating
As maybe
The idea is that then the anchor client code, generates an overload of "createMultisig" that requires only the the non "context" input args, but spits out multiple instructions instead of just one, to issue both the pre-allocation of the account, and the subsequent create multisig call. It also also generates a keypair for the accounts it generated, and includes that with a result wrapper in it's promise output.
Beta Was this translation helpful? Give feedback.
All reactions