Replies: 5 comments 4 replies
-
As I've told you in private, think Background on |
Beta Was this translation helpful? Give feedback.
-
I agree. We should follow the |
Beta Was this translation helpful? Give feedback.
-
I think the |
Beta Was this translation helpful? Give feedback.
-
One point mentioned by @juniset, we should probably document somewhere that Developers coming from ETH will assume this is done through local private/public keys, like how it works with MetaMask. |
Beta Was this translation helpful? Give feedback.
-
Hey all,
today I'll propose new interfaces for
Provider
,Signer
and especiallyContract
.Provider
andSigner
A Provider should stay similar to an ethers.js Provider, allowing for interactions with the blockchain without signing. Traditionally these are reading states from the blockchain, but due to how StarkNet is build you can do a little more with it in starknet.js, like sending contract deployment transactions etc.
A Signer extends a Provider and inherits/implements all of its methods. It also introduces some methods which are just possible with a Signer, eg creating/verifying signatures. It's primarily interacting with an account contract on starknet.
Signer
Signer should get an additional method
verifyMessage(typedData: TypedData, signature: Signature): Promise<boolean>
, which allows the signer to check if the given signature signs the given message using the signers pub key.There should also be a
verifyMessageHash(typedDataHash: BigNumberish, signature: Signature): Promise<boolean>
, which allows the signer to check if the given signature is valid for the account by callingis_valid_signature
on the account contract.Method inputs
Instance methods like
invokeFunction
should do more preprocessing and not expect results from helper functions likegetSelectorFromName
orcompileCalldata
.This will allow other actors in the ecosystem to implement their own
Provider
orSigner
, with the ability to show human readable data to the user. This is very important for wallets, but also Hardware wallets like Ledger, so we don't just approve hashes and hex values like we do in Ethereum today.entry_point_selector
It should always be the human readable string, like "
mint
" or "transfer
". It should not be a pre-computed address like the result ofgetSelectorFromName
or any other hex value.calldata
This one is a little bit more complicated. Basically there are 2 difference appearances of
calldata
. In Providers and Signers the calldata normally isn't aware of any ABI or context. In these cases, likeaddTransaction
there should be a 2nd parameter which accepts an ABI. This way signers like Argent X, Ledger or whatever, can show relevant information to the user approving. This parameter should be optional, and wallets can handle it differently if it's not provided (deny signing, display warning etc).signature
Signatures should not assume that there's just one signing party. Signature is always a flat array of
BigNumberish
with variable lengthn
.Contract
Contracts can do data transforming in JS based on an ABI. They can also call and invoke to starknet through a provided Signer.
We should split between Contract and ContractFactory (which is also able to deploy contracts) like they do with ethers.js
Contracts should be able to transform most common Cairo values, like
Uint256
, to JS objects like BigNumber. It could also allow the user to pass there own transformers, similar to howJSON.parse
does it.Beta Was this translation helpful? Give feedback.
All reactions