From bf1b08a5be1ec49e15c574889de60161b849b213 Mon Sep 17 00:00:00 2001 From: Jeremias Diaz Date: Wed, 22 Dec 2021 18:09:51 -0300 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20upgrade=20chain=20types?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/middleware/__tests__/queries.ts | 4 +- src/polkadot/augment-api-events.ts | 18 +++++++++ src/polkadot/augment-api-query.ts | 7 ++-- src/polkadot/augment-api-tx.ts | 61 ++++++++++++++++++++++++++++- src/polkadot/types.ts | 12 +++++- 5 files changed, 94 insertions(+), 8 deletions(-) diff --git a/src/middleware/__tests__/queries.ts b/src/middleware/__tests__/queries.ts index 56611d127e..ae55e4ff32 100644 --- a/src/middleware/__tests__/queries.ts +++ b/src/middleware/__tests__/queries.ts @@ -23,8 +23,8 @@ import { proposalVotes, scopesByIdentity, settlements, - tickerExternalAgentHistory, tickerExternalAgentActions, + tickerExternalAgentHistory, tokensByTrustedClaimIssuer, tokensHeldByDid, transactionByHash, @@ -288,7 +288,7 @@ describe('tickerExternalAgentHistory', () => { }; const result = tickerExternalAgentHistory(variables); - + expect(result.query).toBeDefined(); expect(result.variables).toEqual(variables); }); diff --git a/src/polkadot/augment-api-events.ts b/src/polkadot/augment-api-events.ts index 858d3b0d18..e7f011a393 100644 --- a/src/polkadot/augment-api-events.ts +++ b/src/polkadot/augment-api-events.ts @@ -1495,6 +1495,24 @@ declare module '@polkadot/api/types/events' { **/ MembersSwapped: AugmentedEvent; }; + testUtils: { + /** + * Shows the `DID` associated to the `AccountId`, and a flag indicates if that DID has a + * valid CDD claim. + * (Target DID, Target Account, a valid CDD claim exists) + **/ + CddStatus: AugmentedEvent, AccountId, bool]>; + /** + * Emits the `IdentityId` and the `AccountId` of the caller. + * (Caller DID, Caller account) + **/ + DidStatus: AugmentedEvent; + /** + * A new mocked `InvestorUid` has been created for the given Identity. + * (Target DID, New InvestorUid) + **/ + MockInvestorUIDCreated: AugmentedEvent; + }; treasury: { /** * Disbursement to a target Identity. diff --git a/src/polkadot/augment-api-query.ts b/src/polkadot/augment-api-query.ts index 3adfc6150e..bd092277ce 100644 --- a/src/polkadot/augment-api-query.ts +++ b/src/polkadot/augment-api-query.ts @@ -755,7 +755,7 @@ declare module '@polkadot/api/types/storage' { * The `CorporateActions` map stores `Ticker => LocalId => The CA`, * so we can infer `Ticker => CAId`. Therefore, we don't need a double map. **/ - caDocLink: AugmentedQuery< + cADocLink: AugmentedQuery< ApiType, ( arg: CAId | { ticker?: any; local_id?: any } | string | Uint8Array @@ -766,7 +766,7 @@ declare module '@polkadot/api/types/storage' { * The next per-`Ticker` CA ID in the sequence. * The full ID is defined as a combination of `Ticker` and a number in this sequence. **/ - caIdSequence: AugmentedQuery< + cAIdSequence: AugmentedQuery< ApiType, (arg: Ticker | string | Uint8Array) => Observable, [Ticker] @@ -1186,7 +1186,7 @@ declare module '@polkadot/api/types/storage' { }; multiSig: { /** - * Maps a multisig secondary key to a multisig address. + * Maps a multisig signer key to a multisig address. **/ keyToMultiSig: AugmentedQuery< ApiType, @@ -2440,6 +2440,7 @@ declare module '@polkadot/api/types/storage' { **/ inactiveMembers: AugmentedQuery Observable>, []>; }; + testUtils: {}; timestamp: { /** * Did the timestamp get updated in this block? diff --git a/src/polkadot/augment-api-tx.ts b/src/polkadot/augment-api-tx.ts index bb2c89d929..85abf8ad0b 100644 --- a/src/polkadot/augment-api-tx.ts +++ b/src/polkadot/augment-api-tx.ts @@ -64,6 +64,7 @@ import type { FundingRoundName, FundraiserName, IdentityId, + InvestorUid, InvestorZKProofData, ItnRewardStatus, Leg, @@ -1552,6 +1553,9 @@ declare module '@polkadot/api/types/submittable' { /** * Replaces an asset's compliance by ticker with a new compliance. * + * Compliance requirements will be sorted (ascending by id) before + * replacing the current requirements. + * * # Arguments * * `ticker` - the asset ticker, * * `asset_compliance - the new asset compliance. @@ -3873,7 +3877,7 @@ declare module '@polkadot/api/types/submittable' { * # Arguments * * `instruction_id` - Instruction id to affirm. * * `portfolios` - Portfolios that the sender controls and wants to affirm this instruction. - * * `legs` - List of legs needs to affirmed. + * * `max_legs_count` - Number of legs that need to be affirmed. * * # Permissions * * Portfolio @@ -4116,6 +4120,7 @@ declare module '@polkadot/api/types/submittable' { * # Arguments * * `instruction_id` - Instruction id for that affirmation get withdrawn. * * `portfolios` - Portfolios that the sender controls and wants to withdraw affirmation. + * * `max_legs_count` - Number of legs that need to be un-affirmed. * * # Permissions * * Portfolio @@ -4608,7 +4613,7 @@ declare module '@polkadot/api/types/submittable' { [Vec] >; /** - * Changes min bond value to be used in bond(). Only Governance + * Changes min bond value to be used in validate(). Only Governance * committee is allowed to change this value. * * # Arguments @@ -5600,6 +5605,58 @@ declare module '@polkadot/api/types/submittable' { [IdentityId, IdentityId] >; }; + testUtils: { + /** + * Emits an event with caller's identity and CDD status. + **/ + getCddOf: AugmentedSubmittable< + (of: AccountId | string | Uint8Array) => SubmittableExtrinsic, + [AccountId] + >; + /** + * Emits an event with caller's identity. + **/ + getMyDid: AugmentedSubmittable<() => SubmittableExtrinsic, []>; + /** + * Registers a new Identity for the `target_account` and issues a CDD claim to it. + * The Investor UID is generated deterministically by the hash of the generated DID and + * then we fix it to be compliant with UUID v4. + * + * # See + * - [RFC 4122: UUID](https://tools.ietf.org/html/rfc4122) + * + * # Failure + * - `origin` has to be an active CDD provider. Inactive CDD providers cannot add new + * claims. + * - `target_account` (primary key of the new Identity) can be linked to just one and only + * one identity. + **/ + mockCddRegisterDid: AugmentedSubmittable< + (targetAccount: AccountId | string | Uint8Array) => SubmittableExtrinsic, + [AccountId] + >; + /** + * Generates a new `IdentityID` for the caller, and issues a self-generated CDD claim. + * + * The caller account will be the primary key of that identity. + * For each account of `secondary_keys`, a new `JoinIdentity` authorization is created, so + * each of them will need to accept it before become part of this new `IdentityID`. + * + * # Errors + * - `AlreadyLinked` if the caller account or if any of the given `secondary_keys` has already linked to an `IdentityID` + * - `SecondaryKeysContainPrimaryKey` if `secondary_keys` contains the caller account. + * - `DidAlreadyExists` if auto-generated DID already exists. + **/ + registerDid: AugmentedSubmittable< + ( + uid: InvestorUid | string | Uint8Array, + secondaryKeys: + | Vec + | (SecondaryKey | { signer?: any; permissions?: any } | string | Uint8Array)[] + ) => SubmittableExtrinsic, + [InvestorUid, Vec] + >; + }; timestamp: { /** * Set the current time. diff --git a/src/polkadot/types.ts b/src/polkadot/types.ts index eace078820..d97d442c25 100644 --- a/src/polkadot/types.ts +++ b/src/polkadot/types.ts @@ -419,6 +419,13 @@ export enum RewardsTx { SetItnRewardStatus = 'rewards.setItnRewardStatus', } +export enum TestUtilsTx { + RegisterDid = 'testUtils.registerDid', + MockCddRegisterDid = 'testUtils.mockCddRegisterDid', + GetMyDid = 'testUtils.getMyDid', + GetCddOf = 'testUtils.getCddOf', +} + export enum ModuleName { System = 'system', Babe = 'babe', @@ -459,6 +466,7 @@ export enum ModuleName { ExternalAgents = 'externalAgents', Relayer = 'relayer', Rewards = 'rewards', + TestUtils = 'testUtils', } export type TxTag = @@ -500,7 +508,8 @@ export type TxTag = | UtilityTx | ExternalAgentsTx | RelayerTx - | RewardsTx; + | RewardsTx + | TestUtilsTx; export const TxTags = { system: SystemTx, @@ -542,4 +551,5 @@ export const TxTags = { externalAgents: ExternalAgentsTx, relayer: RelayerTx, rewards: RewardsTx, + testUtils: TestUtilsTx, };