Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

feat: identity pattern and example #599

Merged
merged 9 commits into from
Feb 20, 2023
Merged

feat: identity pattern and example #599

merged 9 commits into from
Feb 20, 2023

Conversation

harrysolovay
Copy link
Contributor

@harrysolovay harrysolovay commented Feb 18, 2023

A new pattern IdentityInfoUtil allows devs to more easily construct and decode identity info without thinking about the encoding/decoding of contained data types.

Before, we would have had to write this:

IdentityInfo(Rune.rec({
  display: Data.Raw13($.str.encode("Chev Chelios")),
  web: Data.None(),
  email: Data.None(),
  twitter: Data.None(),
  riot: Data.None(),
  image: Data.None(),
  legal: Data.None(),
  pgpFingerprint: undefined,
  additional: Rune.tuple([
    Rune.tuple([
      Data.Raw6($.str.encode("stars")),
      Data.Raw1($.u8.encode(5)),
    ]),
  ]),
}))

We can now write this instead:

const transcoders = new IdentityInfoTranscoders({ stars: $.u8 })

transcoders.encode({
  display: "Chev Chelios",
  additional: { stars: 5 },
})

@harrysolovay harrysolovay changed the title chore: identity pallet usage example feat: identity pattern and example Feb 18, 2023
tjjfvi
tjjfvi previously approved these changes Feb 20, 2023
codegen/frame/type.ts Outdated Show resolved Hide resolved
codegen/frame/type.ts Outdated Show resolved Hide resolved
@tjjfvi tjjfvi merged commit 7ddf479 into main Feb 20, 2023
@tjjfvi tjjfvi deleted the identity-pallet-example branch February 20, 2023 18:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants