Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add account info getter #111

Closed
wants to merge 11 commits into from
4 changes: 2 additions & 2 deletions packages/types/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export default {
};
```

A subsequent `yarn generate:defs` updates the types.
A subsequent `yarn generate:types` updates the types.

To update the polkadot types, upgrade the `@polkadot/types` package and generate the types again.

The type generation process is elaborated on in the polkadot.{js} [docs](https://polkadot.js.org/docs/api/examples/promise/typegen#types-setup).
The type generation process is elaborated on in the polkadot.{js} [docs](https://polkadot.js.org/docs/api/examples/promise/typegen#types-setup).
9 changes: 7 additions & 2 deletions packages/types/src/interfaces/augment-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import type { Assignment, AssignmentCount, AssignmentParams, Attestation, Attest
import type { FixedI64F64, IpfsCid, PalletString } from '@encointer/types/interfaces/common';
import type { AnnouncementSigner, Bip340, CidDigest, CidName, CommunityCeremony, CommunityIdentifier, CommunityMetadataType, CommunityRules, DegreeFixed, DegreeRpc, GeoHash, Location, LocationRpc, NominalIncomeType } from '@encointer/types/interfaces/community';
import type { EncointerBalanceTransferArgs, EncointerGetter, EncointerGetterArgs, EncointerPublicGetter, EncointerTrustedCall, EncointerTrustedCallSigned, EncointerTrustedGetter, EncointerTrustedGetterSigned, GrantReputationArgs, RegisterAttestationsArgs, RegisterParticipantArgs } from '@encointer/types/interfaces/encointerWorker';
import type { BalanceSetBalanceArgs, BalanceShieldArgs, BalanceTransferArgs, BalanceUnshieldArgs, IntegriteeGetter, IntegriteePublicGetter, IntegriteeTrustedCall, IntegriteeTrustedCallSigned, IntegriteeTrustedGetter, IntegriteeTrustedGetterSigned, IntegriteeTrustedOperation, TimestampSetArgs } from '@encointer/types/interfaces/integriteeWorker';
import type { BalanceSetBalanceArgs, BalanceShieldArgs, BalanceTransferArgs, BalanceUnshieldArgs, GuessTheNumberArgs, GuessTheNumberInfo, GuessTheNumberSetWinningsArgs, GuessType, IntegriteeGetter, IntegriteePublicGetter, IntegriteeTrustedCall, IntegriteeTrustedCallSigned, IntegriteeTrustedGetter, IntegriteeTrustedGetterSigned, IntegriteeTrustedOperation, TimestampSetArgs } from '@encointer/types/interfaces/integriteeWorker';
import type { SchedulerState, SystemNumber } from '@encointer/types/interfaces/scheduler';
import type { DirectRequestStatus, Enclave, GetterArgs, ParentchainId, Request, RpcReturnValue, ShardIdentifier, TrustedOperationStatus, Vault, WorkerEncoded } from '@encointer/types/interfaces/worker';
import type { DirectRequestStatus, Enclave, EnclaveFingerprint, GetterArgs, ParentchainId, Request, RpcReturnValue, ShardIdentifier, TrustedOperationStatus, Vault, WorkerEncoded } from '@encointer/types/interfaces/worker';
import type { Data, StorageKey } from '@polkadot/types';
import type { BitVec, Bool, Bytes, F32, F64, I128, I16, I256, I32, I64, I8, ISize, Json, Null, OptionBool, Raw, Text, Type, U128, U16, U256, U32, U64, U8, USize, bool, f32, f64, i128, i16, i256, i32, i64, i8, isize, u128, u16, u256, u32, u64, u8, usize } from '@polkadot/types-codec';
import type { TAssetConversion } from '@polkadot/types/interfaces/assetConversion';
Expand Down Expand Up @@ -426,6 +426,7 @@ declare module '@polkadot/types/types/registry' {
ElectionSize: ElectionSize;
ElectionStatus: ElectionStatus;
Enclave: Enclave;
EnclaveFingerprint: EnclaveFingerprint;
EncodedFinalityProofs: EncodedFinalityProofs;
EncodedJustification: EncodedJustification;
EncointerBalanceTransferArgs: EncointerBalanceTransferArgs;
Expand Down Expand Up @@ -593,6 +594,10 @@ declare module '@polkadot/types/types/registry' {
GrantReputationArgs: GrantReputationArgs;
GroupIndex: GroupIndex;
GroupRotationInfo: GroupRotationInfo;
GuessTheNumberArgs: GuessTheNumberArgs;
GuessTheNumberInfo: GuessTheNumberInfo;
GuessTheNumberSetWinningsArgs: GuessTheNumberSetWinningsArgs;
GuessType: GuessType;
H1024: H1024;
H128: H128;
H160: H160;
Expand Down
39 changes: 24 additions & 15 deletions packages/types/src/interfaces/integriteeWorker/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,14 @@ export default {
types: {
IntegriteePublicGetter: {
_enum: {
total_issuance: 'CommunityIdentifier',
participant_count: 'CommunityIdentifier',
meetup_count: 'CommunityIdentifier',
ceremony_reward: 'CommunityIdentifier',
location_tolerance: 'CommunityIdentifier',
time_tolerance: 'CommunityIdentifier',
scheduler_state: 'CommunityIdentifier'
guess_the_number_last_lucky_number: null,
guess_the_number_last_winning_distance: null,
guess_the_number_info: null,
}
},
IntegriteeTrustedGetter: {
_enum: {
free_balance: 'AccountId',
reserved_balance: 'AccountId',
nonce: 'AccountId',
account_info: 'AccountId',
}
},
IntegriteeTrustedGetterSigned: {
Expand Down Expand Up @@ -44,17 +38,32 @@ export default {
IntegriteeTrustedCall: {
_enum: {
noop: 'AccountId',
balance_set_balance: 'BalanceSetBalanceArgs',
timestamp_set: 'TimestampSetArgs',
balance_transfer: 'BalanceTransferArgs',
balance_unshield: 'BalanceUnshieldArgs',
balance_shield: 'BalanceShieldArgs',
timestamp_set: 'TimestampSetArgs',
guess_the_number_set_winnings: 'GuessTheNumberSetWinningsArgs',
guess_the_number_push_by_one_day: 'AccountId',
guess_the_number: 'GuessTheNumberArgs',
balance_set_balance: 'BalanceSetBalanceArgs',
}
},
BalanceSetBalanceArgs: '(AccountId, AccountId, BalanceType, BalanceType)',
GuessType: 'u32',
GuessTheNumberInfo: {
account: 'AccountId',
balance: 'Balance',
winnings: 'Balance',
next_round_timestamp: 'Moment',
last_winners: 'Vec<AccountId>',
maybe_last_lucky_number: 'Option<GuessType>',
maybe_last_winning_distance: 'Option<GuessType>',
},
GuessTheNumberSetWinningsArgs: '(AccountId, Balance)',
GuessTheNumberArgs: '(AccountId, GuessType)',
TimestampSetArgs: '(AccountId, H160, BalanceType)',
BalanceTransferArgs: '(AccountId, AccountId, BalanceType)',
BalanceUnshieldArgs: '(AccountId, AccountId, BalanceType, ShardIdentifier)',
BalanceShieldArgs: '(AccountId, AccountId, BalanceType, ParentchainId)',
TimestampSetArgs: '(AccountId, H160, BalanceType)',
BalanceUnshieldArgs: '(AccountId, AccountId, BalanceType, ShardIdentifier)',
BalanceSetBalanceArgs: '(AccountId, AccountId, BalanceType, BalanceType)',
}
}
70 changes: 40 additions & 30 deletions packages/types/src/interfaces/integriteeWorker/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
/* eslint-disable */

import type { BalanceType } from '@encointer/types/interfaces/balances';
import type { CommunityIdentifier } from '@encointer/types/interfaces/community';
import type { ParentchainId, ShardIdentifier } from '@encointer/types/interfaces/worker';
import type { Enum, Struct, u32 } from '@polkadot/types-codec';
import type { Enum, Option, Struct, Vec, u32 } from '@polkadot/types-codec';
import type { ITuple } from '@polkadot/types-codec/types';
import type { MultiSignature } from '@polkadot/types/interfaces/extrinsics';
import type { AccountId, H160 } from '@polkadot/types/interfaces/runtime';
import type { AccountId, Balance, H160, Moment } from '@polkadot/types/interfaces/runtime';

/** @name BalanceSetBalanceArgs */
export interface BalanceSetBalanceArgs extends ITuple<[AccountId, AccountId, BalanceType, BalanceType]> {}
Expand All @@ -21,6 +20,26 @@ export interface BalanceTransferArgs extends ITuple<[AccountId, AccountId, Balan
/** @name BalanceUnshieldArgs */
export interface BalanceUnshieldArgs extends ITuple<[AccountId, AccountId, BalanceType, ShardIdentifier]> {}

/** @name GuessTheNumberArgs */
export interface GuessTheNumberArgs extends ITuple<[AccountId, GuessType]> {}

/** @name GuessTheNumberInfo */
export interface GuessTheNumberInfo extends Struct {
readonly account: AccountId;
readonly balance: Balance;
readonly winnings: Balance;
readonly next_round_timestamp: Moment;
readonly last_winners: Vec<AccountId>;
readonly maybe_last_lucky_number: Option<GuessType>;
readonly maybe_last_winning_distance: Option<GuessType>;
}

/** @name GuessTheNumberSetWinningsArgs */
export interface GuessTheNumberSetWinningsArgs extends ITuple<[AccountId, Balance]> {}

/** @name GuessType */
export interface GuessType extends u32 {}

/** @name IntegriteeGetter */
export interface IntegriteeGetter extends Enum {
readonly isPublic: boolean;
Expand All @@ -32,38 +51,33 @@ export interface IntegriteeGetter extends Enum {

/** @name IntegriteePublicGetter */
export interface IntegriteePublicGetter extends Enum {
readonly isTotalIssuance: boolean;
readonly asTotalIssuance: CommunityIdentifier;
readonly isParticipantCount: boolean;
readonly asParticipantCount: CommunityIdentifier;
readonly isMeetupCount: boolean;
readonly asMeetupCount: CommunityIdentifier;
readonly isCeremonyReward: boolean;
readonly asCeremonyReward: CommunityIdentifier;
readonly isLocationTolerance: boolean;
readonly asLocationTolerance: CommunityIdentifier;
readonly isTimeTolerance: boolean;
readonly asTimeTolerance: CommunityIdentifier;
readonly isSchedulerState: boolean;
readonly asSchedulerState: CommunityIdentifier;
readonly type: 'TotalIssuance' | 'ParticipantCount' | 'MeetupCount' | 'CeremonyReward' | 'LocationTolerance' | 'TimeTolerance' | 'SchedulerState';
readonly isGuessTheNumberLastLuckyNumber: boolean;
readonly isGuessTheNumberLastWinningDistance: boolean;
readonly isGuessTheNumberInfo: boolean;
readonly type: 'GuessTheNumberLastLuckyNumber' | 'GuessTheNumberLastWinningDistance' | 'GuessTheNumberInfo';
}

/** @name IntegriteeTrustedCall */
export interface IntegriteeTrustedCall extends Enum {
readonly isNoop: boolean;
readonly asNoop: AccountId;
readonly isBalanceSetBalance: boolean;
readonly asBalanceSetBalance: BalanceSetBalanceArgs;
readonly isTimestampSet: boolean;
readonly asTimestampSet: TimestampSetArgs;
readonly isBalanceTransfer: boolean;
readonly asBalanceTransfer: BalanceTransferArgs;
readonly isBalanceUnshield: boolean;
readonly asBalanceUnshield: BalanceUnshieldArgs;
readonly isBalanceShield: boolean;
readonly asBalanceShield: BalanceShieldArgs;
readonly isTimestampSet: boolean;
readonly asTimestampSet: TimestampSetArgs;
readonly type: 'Noop' | 'BalanceSetBalance' | 'BalanceTransfer' | 'BalanceUnshield' | 'BalanceShield' | 'TimestampSet';
readonly isGuessTheNumberSetWinnings: boolean;
readonly asGuessTheNumberSetWinnings: GuessTheNumberSetWinningsArgs;
readonly isGuessTheNumberPushByOneDay: boolean;
readonly asGuessTheNumberPushByOneDay: AccountId;
readonly isGuessTheNumber: boolean;
readonly asGuessTheNumber: GuessTheNumberArgs;
readonly isBalanceSetBalance: boolean;
readonly asBalanceSetBalance: BalanceSetBalanceArgs;
readonly type: 'Noop' | 'TimestampSet' | 'BalanceTransfer' | 'BalanceUnshield' | 'BalanceShield' | 'GuessTheNumberSetWinnings' | 'GuessTheNumberPushByOneDay' | 'GuessTheNumber' | 'BalanceSetBalance';
}

/** @name IntegriteeTrustedCallSigned */
Expand All @@ -75,13 +89,9 @@ export interface IntegriteeTrustedCallSigned extends Struct {

/** @name IntegriteeTrustedGetter */
export interface IntegriteeTrustedGetter extends Enum {
readonly isFreeBalance: boolean;
readonly asFreeBalance: AccountId;
readonly isReservedBalance: boolean;
readonly asReservedBalance: AccountId;
readonly isNonce: boolean;
readonly asNonce: AccountId;
readonly type: 'FreeBalance' | 'ReservedBalance' | 'Nonce';
readonly isAccountInfo: boolean;
readonly asAccountInfo: AccountId;
readonly type: 'AccountInfo';
Comment on lines -78 to +94
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been generated by a subsequent yarn generated:types

}

/** @name IntegriteeTrustedGetterSigned */
Expand Down
1 change: 1 addition & 0 deletions packages/types/src/interfaces/worker/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export default {
rpc: {},
types: {
ShardIdentifier: 'Hash',
EnclaveFingerprint: 'H256',
GetterArgs: '(AccountId, CommunityIdentifier)',
Enclave: {
pubkey: 'AccountId',
Expand Down
5 changes: 4 additions & 1 deletion packages/types/src/interfaces/worker/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import type { CommunityIdentifier } from '@encointer/types/interfaces/community';
import type { Bytes, Enum, Struct, Text, bool, u64 } from '@polkadot/types-codec';
import type { ITuple } from '@polkadot/types-codec/types';
import type { AccountId, Hash } from '@polkadot/types/interfaces/runtime';
import type { AccountId, H256, Hash } from '@polkadot/types/interfaces/runtime';

/** @name DirectRequestStatus */
export interface DirectRequestStatus extends Enum {
Expand All @@ -23,6 +23,9 @@ export interface Enclave extends Struct {
readonly url: Text;
}

/** @name EnclaveFingerprint */
export interface EnclaveFingerprint extends H256 {}

/** @name GetterArgs */
export interface GetterArgs extends ITuple<[AccountId, CommunityIdentifier]> {}

Expand Down
Loading
Loading