anza-xyz / anza-xyz/kit

Remove Typescript enums

Aberta
#1,337 1 comentário 0 reações 0 responsáveis Ver no GitHub
major
Linguagem predominante
TypeScript
Estrelas
695
Forks
210
Merge médio
21h 33min
PRs com merge (30d)
90

Descrição

We'd probably be better off not using typescript enums, due to them compiling to a slightly complex reverse-mapped function type, and also not being helpful when logged (which we generally try to be with eg our `Address` type).

We use enums currently for:

```ts
export enum Endian {
Little,
Big,
}
```

- I'd guess that this could just be a union `"Little" | "Big"`

```ts
export enum AccountRole {
// Bitflag guide: is signer ⌄⌄ is writable
WRITABLE_SIGNER = /* 3 */ 0b11, // prettier-ignore
READONLY_SIGNER = /* 2 */ 0b10, // prettier-ignore
WRITABLE = /* 1 */ 0b01, // prettier-ignore
READONLY = /* 0 */ 0b00, // prettier-ignore
}
```

- This would be more useful with string values so that when we log a transaction message instruction account it is legible. We'd need to convert it when compiled though, and would also need to think about the bitshifting used to convert roles etc

```ts
export enum OffchainMessageContentFormat {
RESTRICTED_ASCII_1232_BYTES_MAX = 0,
UTF8_1232_BYTES_MAX = 1,
UTF8_65535_BYTES_MAX = 2,
}
```

This can probably also just a union of strings.

Guia de contribuição

Abrir o guia de contribuição

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.