You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently account public keys are encoded together with their signature algorithm, hashing algorithm and weight before being passed into Cadence as byte strings. This solution is a relic of the early days of Cadence, before we had support for more sophisticated composite types.
We'd like to move towards a more user-friendly solution, perhaps something like this:
struct AccountKey {
let keyIndex: Int
let publicKey: Crypto.PublicKey
let hashAlgorithm: Crypto.HashAlgorithm
let weight: UFix64
let isRevoked: Bool
}
Add an AuthAccount.Keys type with the following functions:
Add a AuthAccount.Keys.add function:
/// Adds a new key with the given weight
fun add(
_ publicKey: PublicKey,
hashAlgorithm: HashAlgorithm,
weight: UFix64
): AccountKey
Add a AuthAccount.Keys.get function:
/// Returns the key at the given index, if it exists.
/// Revoked keys are always returned, but they have `isRevoked` field set to true
fun get(keyIndex: Int): AccountKey?
Add a AuthAccount.Keys.revoke function:
/// Marks the key at the given index revoked, but does not delete it
fun revoke(keyIndex: Int)
Add an AuthAccount.keys field with type AuthAccount.Keys
Add an PublicAccount.Keys type with the following functions:
Add a PublicAccount.Keys.get function:
/// Returns the key at the given index, if it exists.
/// Revoked keys are always returned, but they have `isRevoked` field set to true
fun get(keyIndex: Int): AccountKey?
Add an PublicAccount.keys field with type PublicAccount.Keys
Tests
Documentation
The text was updated successfully, but these errors were encountered:
@SupunS Maybe you could take this on next? Adding this new account key management API would be a great UX improvement. Let me know if you want to talk this through
Context
Currently account public keys are encoded together with their signature algorithm, hashing algorithm and weight before being passed into Cadence as byte strings. This solution is a relic of the early days of Cadence, before we had support for more sophisticated composite types.
We'd like to move towards a more user-friendly solution, perhaps something like this:
Definition of Done
Add an
AccountKey
type:Add an
AuthAccount.Keys
type with the following functions:Add a
AuthAccount.Keys.add
function:Add a
AuthAccount.Keys.get
function:Add a
AuthAccount.Keys.revoke
function:Add an
AuthAccount.keys
field with typeAuthAccount.Keys
Add an
PublicAccount.Keys
type with the following functions:Add a
PublicAccount.Keys.get
function:Add an
PublicAccount.keys
field with typePublicAccount.Keys
Tests
Documentation
The text was updated successfully, but these errors were encountered: