diff --git a/packages/types/src/interfaces/augment-types.ts b/packages/types/src/interfaces/augment-types.ts index adc5dcae..03f2d308 100644 --- a/packages/types/src/interfaces/augment-types.ts +++ b/packages/types/src/interfaces/augment-types.ts @@ -10,8 +10,10 @@ import type { BusinessData, BusinessIdentifier, OfferingData, OfferingIdentifier import type { Assignment, AssignmentCount, AssignmentParams, Attestation, AttestationIndexType, CeremonyIndexType, CeremonyPhaseType, ClaimOfAttendance, ClaimOfAttendanceSigningPayload, CommunityCeremonyStats, CommunityReputation, Meetup, MeetupAssignment, MeetupIndexType, MeetupResult, MeetupTimeOffsetType, ParticipantIndexType, ParticipantRegistration, ProofOfAttendance, RegistrationType, Reputation } from '@encointer/types/interfaces/ceremony'; 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 { SchedulerState, SystemNumber } from '@encointer/types/interfaces/scheduler'; -import type { BalanceSetBalanceArgs, BalanceShieldArgs, BalanceTransferArgs, BalanceUnshieldArgs, DirectRequestStatus, Enclave, Getter, GetterArgs, ParentchainId, PublicGetter, Request, RpcReturnValue, ShardIdentifier, TimestampSetArgs, TrustedCall, TrustedCallSigned, TrustedGetter, TrustedGetterSigned, TrustedOperation, TrustedOperationStatus, Vault, WorkerEncoded } from '@encointer/types/interfaces/worker'; +import type { DirectRequestStatus, Enclave, 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 { AssetApproval, AssetApprovalKey, AssetBalance, AssetDestroyWitness, AssetDetails, AssetMetadata, TAssetBalance, TAssetDepositBalance } from '@polkadot/types/interfaces/assets'; @@ -409,6 +411,14 @@ declare module '@polkadot/types/types/registry' { Enclave: Enclave; EncodedFinalityProofs: EncodedFinalityProofs; EncodedJustification: EncodedJustification; + EncointerBalanceTransferArgs: EncointerBalanceTransferArgs; + EncointerGetter: EncointerGetter; + EncointerGetterArgs: EncointerGetterArgs; + EncointerPublicGetter: EncointerPublicGetter; + EncointerTrustedCall: EncointerTrustedCall; + EncointerTrustedCallSigned: EncointerTrustedCallSigned; + EncointerTrustedGetter: EncointerTrustedGetter; + EncointerTrustedGetterSigned: EncointerTrustedGetterSigned; Epoch: Epoch; EpochAuthorship: EpochAuthorship; Era: Era; @@ -545,7 +555,6 @@ declare module '@polkadot/types/types/registry' { FungiblesAccessError: FungiblesAccessError; Gas: Gas; GeoHash: GeoHash; - Getter: Getter; GetterArgs: GetterArgs; GiltBid: GiltBid; GlobalValidationData: GlobalValidationData; @@ -558,6 +567,7 @@ declare module '@polkadot/types/types/registry' { GrandpaPrecommit: GrandpaPrecommit; GrandpaPrevote: GrandpaPrevote; GrandpaSignedPrecommit: GrandpaSignedPrecommit; + GrantReputationArgs: GrantReputationArgs; GroupIndex: GroupIndex; GroupRotationInfo: GroupRotationInfo; H1024: H1024; @@ -630,6 +640,13 @@ declare module '@polkadot/types/types/registry' { InstantiateReturnValueTo267: InstantiateReturnValueTo267; InstructionV2: InstructionV2; InstructionWeights: InstructionWeights; + IntegriteeGetter: IntegriteeGetter; + IntegriteePublicGetter: IntegriteePublicGetter; + IntegriteeTrustedCall: IntegriteeTrustedCall; + IntegriteeTrustedCallSigned: IntegriteeTrustedCallSigned; + IntegriteeTrustedGetter: IntegriteeTrustedGetter; + IntegriteeTrustedGetterSigned: IntegriteeTrustedGetterSigned; + IntegriteeTrustedOperation: IntegriteeTrustedOperation; InteriorMultiLocation: InteriorMultiLocation; InvalidDisputeStatementKind: InvalidDisputeStatementKind; InvalidTransaction: InvalidTransaction; @@ -879,7 +896,6 @@ declare module '@polkadot/types/types/registry' { ProxyDefinition: ProxyDefinition; ProxyState: ProxyState; ProxyType: ProxyType; - PublicGetter: PublicGetter; PvfCheckStatement: PvfCheckStatement; PvfExecTimeoutKind: PvfExecTimeoutKind; PvfPrepTimeoutKind: PvfPrepTimeoutKind; @@ -914,7 +930,9 @@ declare module '@polkadot/types/types/registry' { ReferendumInfoFinished: ReferendumInfoFinished; ReferendumInfoTo239: ReferendumInfoTo239; ReferendumStatus: ReferendumStatus; + RegisterAttestationsArgs: RegisterAttestationsArgs; RegisteredParachainInfo: RegisteredParachainInfo; + RegisterParticipantArgs: RegisterParticipantArgs; RegistrarIndex: RegistrarIndex; RegistrarInfo: RegistrarInfo; Registration: Registration; @@ -1155,11 +1173,6 @@ declare module '@polkadot/types/types/registry' { TreasuryProposal: TreasuryProposal; TrieId: TrieId; TrieIndex: TrieIndex; - TrustedCall: TrustedCall; - TrustedCallSigned: TrustedCallSigned; - TrustedGetter: TrustedGetter; - TrustedGetterSigned: TrustedGetterSigned; - TrustedOperation: TrustedOperation; TrustedOperationStatus: TrustedOperationStatus; Type: Type; u128: u128; diff --git a/packages/types/src/interfaces/definitions.ts b/packages/types/src/interfaces/definitions.ts index 36e0e16a..c4f166d2 100644 --- a/packages/types/src/interfaces/definitions.ts +++ b/packages/types/src/interfaces/definitions.ts @@ -5,3 +5,5 @@ export { default as ceremony } from './ceremony/definitions.js'; export { default as community } from './community/definitions.js'; export { default as scheduler } from './scheduler/definitions.js'; export { default as worker } from './worker/definitions.js'; +export { default as encointerWorker } from './encointerWorker/definitions.js' +export { default as integriteeWorker } from './integriteeWorker/definitions.js' diff --git a/packages/types/src/interfaces/encointerWorker/definitions.ts b/packages/types/src/interfaces/encointerWorker/definitions.ts new file mode 100644 index 00000000..091d18b2 --- /dev/null +++ b/packages/types/src/interfaces/encointerWorker/definitions.ts @@ -0,0 +1,53 @@ +export default { + rpc: {}, + types: { + EncointerGetterArgs: '(AccountId, CommunityIdentifier)', + EncointerPublicGetter: { + _enum: { + total_issuance: 'CommunityIdentifier', + participant_count: 'CommunityIdentifier', + meetup_count: 'CommunityIdentifier', + ceremony_reward: 'CommunityIdentifier', + location_tolerance: 'CommunityIdentifier', + time_tolerance: 'CommunityIdentifier', + scheduler_state: 'CommunityIdentifier' + } + }, + EncointerTrustedGetter: { + _enum: { + balance: '(AccountId, CommunityIdentifier)', + participant_index: '(AccountId, CommunityIdentifier)', + meetup_index: '(AccountId, CommunityIdentifier)', + attestations: '(AccountId, CommunityIdentifier)', + meetup_registry: '(AccountId, CommunityIdentifier)' + } + }, + EncointerTrustedGetterSigned: { + getter: 'EncointerTrustedGetter', + signature: 'Signature' + }, + EncointerGetter: { + _enum: { + public: 'EncointerPublicGetter', + trusted: 'EncointerTrustedGetterSigned' + } + }, + EncointerTrustedCallSigned: { + call: 'EncointerTrustedCall', + nonce: 'u32', + signature: 'Signature' + }, + EncointerTrustedCall: { + _enum: { + balance_transfer: 'EncointerBalanceTransferArgs', + ceremonies_register_participant: 'RegisterParticipantArgs', + ceremonies_register_attestations: 'RegisterAttestationsArgs', + ceremonies_grant_reputation: 'GrantReputationArgs' + } + }, + EncointerBalanceTransferArgs: '(AccountId, AccountId, CommunityIdentifier, BalanceType)', + RegisterParticipantArgs: '(AccountId, CommunityIdentifier, Option>)', + RegisterAttestationsArgs: '(AccountId, Vec>)', + GrantReputationArgs: '(AccountId, CommunityIdentifier, AccountId)' + } +} diff --git a/packages/types/src/interfaces/encointerWorker/index.ts b/packages/types/src/interfaces/encointerWorker/index.ts new file mode 100644 index 00000000..7f1de782 --- /dev/null +++ b/packages/types/src/interfaces/encointerWorker/index.ts @@ -0,0 +1,4 @@ +// Auto-generated via `yarn polkadot-types-from-defs`, do not edit +/* eslint-disable */ + +export * from './types.js'; diff --git a/packages/types/src/interfaces/encointerWorker/types.ts b/packages/types/src/interfaces/encointerWorker/types.ts new file mode 100644 index 00000000..2436ee89 --- /dev/null +++ b/packages/types/src/interfaces/encointerWorker/types.ts @@ -0,0 +1,96 @@ +// Auto-generated via `yarn polkadot-types-from-defs`, do not edit +/* eslint-disable */ + +import type { BalanceType } from '@encointer/types/interfaces/balances'; +import type { Attestation, ProofOfAttendance } from '@encointer/types/interfaces/ceremony'; +import type { CommunityIdentifier } from '@encointer/types/interfaces/community'; +import type { Enum, Option, Struct, Vec, u32 } from '@polkadot/types-codec'; +import type { ITuple } from '@polkadot/types-codec/types'; +import type { Signature } from '@polkadot/types/interfaces/extrinsics'; +import type { AccountId } from '@polkadot/types/interfaces/runtime'; + +/** @name EncointerBalanceTransferArgs */ +export interface EncointerBalanceTransferArgs extends ITuple<[AccountId, AccountId, CommunityIdentifier, BalanceType]> {} + +/** @name EncointerGetter */ +export interface EncointerGetter extends Enum { + readonly isPublic: boolean; + readonly asPublic: EncointerPublicGetter; + readonly isTrusted: boolean; + readonly asTrusted: EncointerTrustedGetterSigned; + readonly type: 'Public' | 'Trusted'; +} + +/** @name EncointerGetterArgs */ +export interface EncointerGetterArgs extends ITuple<[AccountId, CommunityIdentifier]> {} + +/** @name EncointerPublicGetter */ +export interface EncointerPublicGetter 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'; +} + +/** @name EncointerTrustedCall */ +export interface EncointerTrustedCall extends Enum { + readonly isBalanceTransfer: boolean; + readonly asBalanceTransfer: EncointerBalanceTransferArgs; + readonly isCeremoniesRegisterParticipant: boolean; + readonly asCeremoniesRegisterParticipant: RegisterParticipantArgs; + readonly isCeremoniesRegisterAttestations: boolean; + readonly asCeremoniesRegisterAttestations: RegisterAttestationsArgs; + readonly isCeremoniesGrantReputation: boolean; + readonly asCeremoniesGrantReputation: GrantReputationArgs; + readonly type: 'BalanceTransfer' | 'CeremoniesRegisterParticipant' | 'CeremoniesRegisterAttestations' | 'CeremoniesGrantReputation'; +} + +/** @name EncointerTrustedCallSigned */ +export interface EncointerTrustedCallSigned extends Struct { + readonly call: EncointerTrustedCall; + readonly nonce: u32; + readonly signature: Signature; +} + +/** @name EncointerTrustedGetter */ +export interface EncointerTrustedGetter extends Enum { + readonly isBalance: boolean; + readonly asBalance: ITuple<[AccountId, CommunityIdentifier]>; + readonly isParticipantIndex: boolean; + readonly asParticipantIndex: ITuple<[AccountId, CommunityIdentifier]>; + readonly isMeetupIndex: boolean; + readonly asMeetupIndex: ITuple<[AccountId, CommunityIdentifier]>; + readonly isAttestations: boolean; + readonly asAttestations: ITuple<[AccountId, CommunityIdentifier]>; + readonly isMeetupRegistry: boolean; + readonly asMeetupRegistry: ITuple<[AccountId, CommunityIdentifier]>; + readonly type: 'Balance' | 'ParticipantIndex' | 'MeetupIndex' | 'Attestations' | 'MeetupRegistry'; +} + +/** @name EncointerTrustedGetterSigned */ +export interface EncointerTrustedGetterSigned extends Struct { + readonly getter: EncointerTrustedGetter; + readonly signature: Signature; +} + +/** @name GrantReputationArgs */ +export interface GrantReputationArgs extends ITuple<[AccountId, CommunityIdentifier, AccountId]> {} + +/** @name RegisterAttestationsArgs */ +export interface RegisterAttestationsArgs extends ITuple<[AccountId, Vec]> {} + +/** @name RegisterParticipantArgs */ +export interface RegisterParticipantArgs extends ITuple<[AccountId, CommunityIdentifier, Option]> {} + +export type PHANTOM_ENCOINTERWORKER = 'encointerWorker'; diff --git a/packages/types/src/interfaces/integriteeWorker/definitions.ts b/packages/types/src/interfaces/integriteeWorker/definitions.ts new file mode 100644 index 00000000..bd324299 --- /dev/null +++ b/packages/types/src/interfaces/integriteeWorker/definitions.ts @@ -0,0 +1,60 @@ +export default { + rpc: {}, + types: { + IntegriteePublicGetter: { + _enum: { + total_issuance: 'CommunityIdentifier', + participant_count: 'CommunityIdentifier', + meetup_count: 'CommunityIdentifier', + ceremony_reward: 'CommunityIdentifier', + location_tolerance: 'CommunityIdentifier', + time_tolerance: 'CommunityIdentifier', + scheduler_state: 'CommunityIdentifier' + } + }, + IntegriteeTrustedGetter: { + _enum: { + free_balance: 'AccountId', + reserved_balance: 'AccountId', + nonce: 'AccountId', + } + }, + IntegriteeTrustedGetterSigned: { + getter: 'IntegriteeTrustedGetter', + signature: 'MultiSignature' + }, + IntegriteeGetter: { + _enum: { + public: 'IntegriteePublicGetter', + trusted: 'IntegriteeTrustedGetterSigned' + } + }, + IntegriteeTrustedOperation: { + _enum: { + indirect_call: 'IntegriteeTrustedCallSigned', + direct_call: 'IntegriteeTrustedCallSigned', + get: 'IntegriteeGetter' + } + }, + IntegriteeTrustedCallSigned: { + call: 'IntegriteeTrustedCall', + nonce: 'u32', + signature: 'MultiSignature' + }, + IntegriteeTrustedCall: { + _enum: { + noop: 'AccountId', + balance_set_balance: 'BalanceSetBalanceArgs', + balance_transfer: 'BalanceTransferArgs', + balance_unshield: 'BalanceUnshieldArgs', + balance_shield: 'BalanceShieldArgs', + timestamp_set: 'TimestampSetArgs', + } + }, + BalanceSetBalanceArgs: '(AccountId, AccountId, BalanceType, BalanceType)', + BalanceTransferArgs: '(AccountId, AccountId, BalanceType)', + BalanceUnshieldArgs: '(AccountId, AccountId, BalanceType, ShardIdentifier)', + BalanceShieldArgs: '(AccountId, AccountId, BalanceType, ParentchainId)', + TimestampSetArgs: '(AccountId, H160, BalanceType)', + } +} diff --git a/packages/types/src/interfaces/integriteeWorker/index.ts b/packages/types/src/interfaces/integriteeWorker/index.ts new file mode 100644 index 00000000..7f1de782 --- /dev/null +++ b/packages/types/src/interfaces/integriteeWorker/index.ts @@ -0,0 +1,4 @@ +// Auto-generated via `yarn polkadot-types-from-defs`, do not edit +/* eslint-disable */ + +export * from './types.js'; diff --git a/packages/types/src/interfaces/integriteeWorker/types.ts b/packages/types/src/interfaces/integriteeWorker/types.ts new file mode 100644 index 00000000..aa239de8 --- /dev/null +++ b/packages/types/src/interfaces/integriteeWorker/types.ts @@ -0,0 +1,107 @@ +// Auto-generated via `yarn polkadot-types-from-defs`, do not edit +/* 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 { ITuple } from '@polkadot/types-codec/types'; +import type { MultiSignature } from '@polkadot/types/interfaces/extrinsics'; +import type { AccountId, H160 } from '@polkadot/types/interfaces/runtime'; + +/** @name BalanceSetBalanceArgs */ +export interface BalanceSetBalanceArgs extends ITuple<[AccountId, AccountId, BalanceType, BalanceType]> {} + +/** @name BalanceShieldArgs */ +export interface BalanceShieldArgs extends ITuple<[AccountId, AccountId, BalanceType, ParentchainId]> {} + +/** @name BalanceTransferArgs */ +export interface BalanceTransferArgs extends ITuple<[AccountId, AccountId, BalanceType]> {} + +/** @name BalanceUnshieldArgs */ +export interface BalanceUnshieldArgs extends ITuple<[AccountId, AccountId, BalanceType, ShardIdentifier]> {} + +/** @name IntegriteeGetter */ +export interface IntegriteeGetter extends Enum { + readonly isPublic: boolean; + readonly asPublic: IntegriteePublicGetter; + readonly isTrusted: boolean; + readonly asTrusted: IntegriteeTrustedGetterSigned; + readonly type: 'Public' | 'Trusted'; +} + +/** @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'; +} + +/** @name IntegriteeTrustedCall */ +export interface IntegriteeTrustedCall extends Enum { + readonly isNoop: boolean; + readonly asNoop: AccountId; + readonly isBalanceSetBalance: boolean; + readonly asBalanceSetBalance: BalanceSetBalanceArgs; + 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'; +} + +/** @name IntegriteeTrustedCallSigned */ +export interface IntegriteeTrustedCallSigned extends Struct { + readonly call: IntegriteeTrustedCall; + readonly nonce: u32; + readonly signature: MultiSignature; +} + +/** @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'; +} + +/** @name IntegriteeTrustedGetterSigned */ +export interface IntegriteeTrustedGetterSigned extends Struct { + readonly getter: IntegriteeTrustedGetter; + readonly signature: MultiSignature; +} + +/** @name IntegriteeTrustedOperation */ +export interface IntegriteeTrustedOperation extends Enum { + readonly isIndirectCall: boolean; + readonly asIndirectCall: IntegriteeTrustedCallSigned; + readonly isDirectCall: boolean; + readonly asDirectCall: IntegriteeTrustedCallSigned; + readonly isGet: boolean; + readonly asGet: IntegriteeGetter; + readonly type: 'IndirectCall' | 'DirectCall' | 'Get'; +} + +/** @name TimestampSetArgs */ +export interface TimestampSetArgs extends ITuple<[AccountId, H160, BalanceType]> {} + +export type PHANTOM_INTEGRITEEWORKER = 'integriteeWorker'; diff --git a/packages/types/src/interfaces/types.ts b/packages/types/src/interfaces/types.ts index d7f4cdf3..b8fe7d58 100644 --- a/packages/types/src/interfaces/types.ts +++ b/packages/types/src/interfaces/types.ts @@ -6,5 +6,7 @@ export * from './bazaar/types.js'; export * from './ceremony/types.js'; export * from './common/types.js'; export * from './community/types.js'; +export * from './encointerWorker/types.js'; +export * from './integriteeWorker/types.js'; export * from './scheduler/types.js'; export * from './worker/types.js'; diff --git a/packages/types/src/interfaces/worker/definitions.ts b/packages/types/src/interfaces/worker/definitions.ts index 514fef64..4be7303b 100644 --- a/packages/types/src/interfaces/worker/definitions.ts +++ b/packages/types/src/interfaces/worker/definitions.ts @@ -9,34 +9,6 @@ export default { timestamp: 'u64', url: 'Text' }, - PublicGetter: { - _enum: { - total_issuance: 'CommunityIdentifier', - participant_count: 'CommunityIdentifier', - meetup_count: 'CommunityIdentifier', - ceremony_reward: 'CommunityIdentifier', - location_tolerance: 'CommunityIdentifier', - time_tolerance: 'CommunityIdentifier', - scheduler_state: 'CommunityIdentifier' - } - }, - TrustedGetter: { - _enum: { - free_balance: 'AccountId', - reserved_balance: 'AccountId', - nonce: 'AccountId', - } - }, - TrustedGetterSigned: { - getter: 'TrustedGetter', - signature: 'MultiSignature' - }, - Getter: { - _enum: { - public: 'PublicGetter', - trusted: 'TrustedGetterSigned' - } - }, RpcReturnValue: { value: 'Vec', do_watch: 'bool', @@ -69,28 +41,6 @@ export default { shard: 'ShardIdentifier', cyphertext: 'WorkerEncoded' }, - TrustedOperation: { - _enum: { - indirect_call: 'TrustedCallSigned', - direct_call: 'TrustedCallSigned', - get: 'Getter' - } - }, - TrustedCallSigned: { - call: 'TrustedCall', - nonce: 'u32', - signature: 'MultiSignature' - }, - TrustedCall: { - _enum: { - noop: 'AccountId', - balance_set_balance: 'BalanceSetBalanceArgs', - balance_transfer: 'BalanceTransferArgs', - balance_unshield: 'BalanceUnshieldArgs', - balance_shield: 'BalanceShieldArgs', - timestamp_set: 'TimestampSetArgs', - } - }, Vault: '(AccountId, ParentchainId)', ParentchainId: { _enum: { @@ -99,10 +49,5 @@ export default { TargetB: null, } }, - BalanceSetBalanceArgs: '(AccountId, AccountId, BalanceType, BalanceType)', - BalanceTransferArgs: '(AccountId, AccountId, BalanceType)', - BalanceUnshieldArgs: '(AccountId, AccountId, BalanceType, ShardIdentifier)', - BalanceShieldArgs: '(AccountId, AccountId, BalanceType, ParentchainId)', - TimestampSetArgs: '(AccountId, H160, BalanceType)', } } diff --git a/packages/types/src/interfaces/worker/types.ts b/packages/types/src/interfaces/worker/types.ts index 72001ccd..194f3aca 100644 --- a/packages/types/src/interfaces/worker/types.ts +++ b/packages/types/src/interfaces/worker/types.ts @@ -1,24 +1,10 @@ // Auto-generated via `yarn polkadot-types-from-defs`, do not edit /* eslint-disable */ -import type { BalanceType } from '@encointer/types/interfaces/balances'; import type { CommunityIdentifier } from '@encointer/types/interfaces/community'; -import type { Bytes, Enum, Struct, Text, bool, u32, u64 } from '@polkadot/types-codec'; +import type { Bytes, Enum, Struct, Text, bool, u64 } from '@polkadot/types-codec'; import type { ITuple } from '@polkadot/types-codec/types'; -import type { MultiSignature } from '@polkadot/types/interfaces/extrinsics'; -import type { AccountId, H160, Hash } from '@polkadot/types/interfaces/runtime'; - -/** @name BalanceSetBalanceArgs */ -export interface BalanceSetBalanceArgs extends ITuple<[AccountId, AccountId, BalanceType, BalanceType]> {} - -/** @name BalanceShieldArgs */ -export interface BalanceShieldArgs extends ITuple<[AccountId, AccountId, BalanceType, ParentchainId]> {} - -/** @name BalanceTransferArgs */ -export interface BalanceTransferArgs extends ITuple<[AccountId, AccountId, BalanceType]> {} - -/** @name BalanceUnshieldArgs */ -export interface BalanceUnshieldArgs extends ITuple<[AccountId, AccountId, BalanceType, ShardIdentifier]> {} +import type { AccountId, Hash } from '@polkadot/types/interfaces/runtime'; /** @name DirectRequestStatus */ export interface DirectRequestStatus extends Enum { @@ -37,15 +23,6 @@ export interface Enclave extends Struct { readonly url: Text; } -/** @name Getter */ -export interface Getter extends Enum { - readonly isPublic: boolean; - readonly asPublic: PublicGetter; - readonly isTrusted: boolean; - readonly asTrusted: TrustedGetterSigned; - readonly type: 'Public' | 'Trusted'; -} - /** @name GetterArgs */ export interface GetterArgs extends ITuple<[AccountId, CommunityIdentifier]> {} @@ -57,25 +34,6 @@ export interface ParentchainId extends Enum { readonly type: 'Integritee' | 'TargetA' | 'TargetB'; } -/** @name PublicGetter */ -export interface PublicGetter 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'; -} - /** @name Request */ export interface Request extends Struct { readonly shard: ShardIdentifier; @@ -92,61 +50,6 @@ export interface RpcReturnValue extends Struct { /** @name ShardIdentifier */ export interface ShardIdentifier extends Hash {} -/** @name TimestampSetArgs */ -export interface TimestampSetArgs extends ITuple<[AccountId, H160, BalanceType]> {} - -/** @name TrustedCall */ -export interface TrustedCall extends Enum { - readonly isNoop: boolean; - readonly asNoop: AccountId; - readonly isBalanceSetBalance: boolean; - readonly asBalanceSetBalance: BalanceSetBalanceArgs; - 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'; -} - -/** @name TrustedCallSigned */ -export interface TrustedCallSigned extends Struct { - readonly call: TrustedCall; - readonly nonce: u32; - readonly signature: MultiSignature; -} - -/** @name TrustedGetter */ -export interface TrustedGetter 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'; -} - -/** @name TrustedGetterSigned */ -export interface TrustedGetterSigned extends Struct { - readonly getter: TrustedGetter; - readonly signature: MultiSignature; -} - -/** @name TrustedOperation */ -export interface TrustedOperation extends Enum { - readonly isIndirectCall: boolean; - readonly asIndirectCall: TrustedCallSigned; - readonly isDirectCall: boolean; - readonly asDirectCall: TrustedCallSigned; - readonly isGet: boolean; - readonly asGet: Getter; - readonly type: 'IndirectCall' | 'DirectCall' | 'Get'; -} - /** @name TrustedOperationStatus */ export interface TrustedOperationStatus extends Enum { readonly isSubmitted: boolean; diff --git a/packages/worker-api/src/encointerWorker.ts b/packages/worker-api/src/encointerWorker.ts index 49d14030..516eafc4 100644 --- a/packages/worker-api/src/encointerWorker.ts +++ b/packages/worker-api/src/encointerWorker.ts @@ -5,12 +5,17 @@ import {communityIdentifierFromString} from '@encointer/util'; import NodeRSA from 'node-rsa'; import type { - CommunityIdentifier, MeetupIndexType, ParticipantIndexType, SchedulerState, ShardIdentifier, TrustedCallSigned, + CommunityIdentifier, + MeetupIndexType, + ParticipantIndexType, + SchedulerState, + ShardIdentifier, + EncointerTrustedCallSigned, + Attestation, } from '@encointer/types'; import {type CallOptions, Request} from './interface.js'; import {callGetter, sendTrustedCall} from './sendRequest.js'; -import {createTrustedCall} from "@encointer/worker-api/requests.js"; import {PubKeyPinPair, toAccount} from "@encointer/util/common"; import type {KeyringPair} from "@polkadot/keyring/types"; import {Worker} from "@encointer/worker-api/worker.js"; @@ -92,25 +97,14 @@ export class EncointerWorker extends Worker { }, options) } - public async trustedBalanceTransfer(accountOrPubKey: KeyringPair | PubKeyPinPair, shard: ShardIdentifier, mrenclave: string, params: BalanceTransferArgs, options: CallOptions = {} as CallOptions): Promise { - const nonce = await this.getNonce(accountOrPubKey, mrenclave, options); - const call = createTrustedCall(this, ['balance_transfer', 'BalanceTransferArgs'], accountOrPubKey, shard, mrenclave, nonce, params); - return this.sendTrustedCall(call, shard, options); - } - - public async balanceUnshieldFunds(accountOrPubKey: KeyringPair | PubKeyPinPair, shard: ShardIdentifier, mrenclave: string, params: BalanceUnshieldArgs, options: CallOptions = {} as CallOptions): Promise { - const nonce = await this.getNonce(accountOrPubKey, mrenclave, options); - const call = createTrustedCall(this, ['balance_unshield', 'BalanceUnshieldArgs'], accountOrPubKey, shard, mrenclave, nonce, params); - return this.sendTrustedCall(call, shard, options); - } - - async sendTrustedCall(call: TrustedCallSigned, shard: ShardIdentifier, options: CallOptions = {} as CallOptions): Promise { - if (this.shieldingKey() == undefined) { - const key = await this.getShieldingKey(options); - console.log(`Setting the shielding pubKey of the worker.`) - this.setShieldingKey(key); - } - - return sendTrustedCall(this, call, shard, true, 'TrustedOperationResult', options); - } + // Todo: `sendTrustedCall` must be generic over the trusted call or we have to duplicate code for encointer. + // async sendTrustedCall(call: EncointerTrustedCallSigned, shard: ShardIdentifier, options: CallOptions = {} as CallOptions): Promise { + // if (this.shieldingKey() == undefined) { + // const key = await this.getShieldingKey(options); + // console.log(`Setting the shielding pubKey of the worker.`) + // this.setShieldingKey(key); + // } + // + // return sendTrustedCall(this, call, shard, true, 'TrustedOperationResult', options); + // } } diff --git a/packages/worker-api/src/integriteeWorker.ts b/packages/worker-api/src/integriteeWorker.ts index 0d32d22d..ce955413 100644 --- a/packages/worker-api/src/integriteeWorker.ts +++ b/packages/worker-api/src/integriteeWorker.ts @@ -8,7 +8,7 @@ import type {KeyringPair} from '@polkadot/keyring/types'; import type {Balance, Hash} from '@polkadot/types/interfaces/runtime'; import type { BalanceTransferArgs, BalanceUnshieldArgs, - ShardIdentifier, TrustedCallSigned, + ShardIdentifier, IntegriteeTrustedCallSigned, } from '@encointer/types'; import {type CallOptions, Request} from './interface.js'; @@ -45,7 +45,7 @@ export class IntegriteeWorker extends Worker { return this.sendTrustedCall(call, shard, options); } - async sendTrustedCall(call: TrustedCallSigned, shard: ShardIdentifier, options: CallOptions = {} as CallOptions): Promise { + async sendTrustedCall(call: IntegriteeTrustedCallSigned, shard: ShardIdentifier, options: CallOptions = {} as CallOptions): Promise { if (this.shieldingKey() == undefined) { const key = await this.getShieldingKey(options); console.log(`Setting the shielding pubKey of the worker.`) diff --git a/packages/worker-api/src/requests.ts b/packages/worker-api/src/requests.ts index 95fb4e01..511affdb 100644 --- a/packages/worker-api/src/requests.ts +++ b/packages/worker-api/src/requests.ts @@ -3,20 +3,20 @@ import { type IWorker, type PublicGetterArgs, type TrustedGetterArgs } from "@encointer/worker-api/interface.js"; -import type {BalanceTransferArgs, BalanceUnshieldArgs, ShardIdentifier, TrustedCallSigned} from "@encointer/types"; +import type {BalanceTransferArgs, BalanceUnshieldArgs, ShardIdentifier, IntegriteeTrustedCallSigned} from "@encointer/types"; import type {KeyringPair} from "@polkadot/keyring/types"; -import {PubKeyPinPair, toAccount} from "@encointer/util/common.js"; +import {type PubKeyPinPair, toAccount} from "@encointer/util/common.js"; import type {u32} from "@polkadot/types"; import bs58 from "bs58"; // Todo: Properly resolve cid vs shard export const clientRequestGetter = (self: IWorker, request: string, args: PublicGetterArgs) => { const { cid } = args; - const getter = self.createType('PublicGetter', { + const getter = self.createType('IntegriteePublicGetter', { [request]: cid }); - const g = self.createType( 'Getter',{ + const g = self.createType( 'IntegriteeGetter',{ public: { getter, } @@ -32,12 +32,12 @@ export const clientRequestGetter = (self: IWorker, request: string, args: Public export const clientRequestTrustedGetter = (self: IWorker, request: string, args: TrustedGetterArgs) => { const {shard, account} = args; const address = account.address; - const getter = self.createType('TrustedGetter', { + const getter = self.createType('IntegriteeTrustedGetter', { [request]: address }); const signature = account.sign(getter.toU8a()); - const g = self.createType( 'Getter',{ + const g = self.createType( 'IntegriteeGetter',{ trusted: { getter, signature: { Sr25519: signature }, @@ -69,18 +69,18 @@ export const createTrustedCall = ( mrenclave: string, nonce: u32, params: TrustedCallArgs -): TrustedCallSigned => { +): IntegriteeTrustedCallSigned => { const [variant, argType] = trustedCall; const hash = self.createType('Hash', bs58.decode(mrenclave)); - const call = self.createType('TrustedCall', { + const call = self.createType('IntegriteeTrustedCall', { [variant]: self.createType(argType, params) }); const payload = Uint8Array.from([...call.toU8a(), ...nonce.toU8a(), ...hash.toU8a(), ...shard.toU8a()]); - return self.createType('TrustedCallSigned', { + return self.createType('IntegriteeIntegriteeTrustedCallSigned', { call: call, nonce: nonce, signature: { Sr25519: toAccount(accountOrPubKey, self.keyring()).sign(payload) }, diff --git a/packages/worker-api/src/sendRequest.ts b/packages/worker-api/src/sendRequest.ts index 7c27413a..b4a5dd5c 100644 --- a/packages/worker-api/src/sendRequest.ts +++ b/packages/worker-api/src/sendRequest.ts @@ -12,7 +12,7 @@ import { clientRequestGetter, clientRequestTrustedGetter, } from "@encointer/worker-api/requests.js"; -import type {ShardIdentifier, TrustedCallSigned} from "@encointer/types"; +import type {ShardIdentifier, IntegriteeTrustedCallSigned} from "@encointer/types"; const sendWorkerRequest = (self: IWorker, clientRequest: any, parserType: string, options: CallOptions): Promise =>{ const requestId = self.rqStack.push(parserType) + self.rsCount; @@ -54,7 +54,7 @@ export const callGetter = async (self: IWorker, workerMethod: WorkerMethod, a return result as Promise } -export const sendTrustedCall = async (self: IWorker, call: TrustedCallSigned, shard: ShardIdentifier, direct: boolean, parser: string, options: CallOptions = {} as CallOptions): Promise => { +export const sendTrustedCall = async (self: IWorker, call: IntegriteeTrustedCallSigned, shard: ShardIdentifier, direct: boolean, parser: string, options: CallOptions = {} as CallOptions): Promise => { if( !self.isOpened ) { await self.open(); } @@ -66,11 +66,11 @@ export const sendTrustedCall = async (self: IWorker, call: TrustedCallSigned, let top; if (direct) { - top = self.createType('TrustedOperation', { + top = self.createType('IntegriteeTrustedOperation', { direct_call: call }) } else { - top = self.createType('TrustedOperation', { + top = self.createType('IntegriteeTrustedOperation', { indirect_call: call }) }