-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Follow on-chain storage format change
- Fold separate flags into a bigint, as bits - Compress metadata wit CBOR - Introduce versioned storage format for metadata - Add proper error handling around invalid metadata
- Loading branch information
Showing
10 changed files
with
113 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export type { DataEntry } from './data-entry' | ||
export type * from './poll' | ||
export * from './poll-flags' | ||
export type { IconSize } from './icon-size' | ||
export type { IconProps } from './icon-props' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { PollManager } from './poll' | ||
|
||
export const FLAG_ACTIVE = 1n << 0n | ||
export const FLAG_PUBLISH_VOTERS = 1n << 1n | ||
export const FLAG_PUBLISH_VOTES = 1n << 2n | ||
export const FLAG_HIDDEN = 1n << 3n | ||
export const FLAG_WEIGHT_LOG10 = 1n << 4n | ||
export const FLAG_WEIGHT_ONE = 1n << 5n | ||
|
||
type Params = PollManager.ProposalParamsStructOutput | ||
|
||
export const isPollActive = (params: Params | undefined): boolean => !!((params?.flags ?? 0n) & FLAG_ACTIVE) | ||
|
||
export const inactivatePoll = (params: Params): Params => ({ | ||
...params, | ||
flags: isPollActive(params) ? params.flags ^ FLAG_ACTIVE : params.flags, | ||
}) | ||
|
||
export const shouldPublishVotes = (params: Params | undefined): boolean => | ||
!!((params?.flags ?? 0n) & FLAG_PUBLISH_VOTES) | ||
|
||
export const shouldPublishVoters = (params: Params | undefined): boolean => | ||
!!((params?.flags ?? 0n) & FLAG_PUBLISH_VOTERS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters