Skip to content

Commit

Permalink
Merge branch 'main' into chore/fix-account-e2e-test
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeCap08055 committed Sep 13, 2024
2 parents 0dd0b71 + 5afd947 commit c12681a
Show file tree
Hide file tree
Showing 31 changed files with 20,018 additions and 1,789 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ services/*/docs/index.html
**/metadata.ts
openapi-specs/*
**/target/**
jest.config.json
2 changes: 1 addition & 1 deletion apps/account-api/src/api.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ import { AccountsService, HandlesService, DelegationService, KeysService } from
}),
ScheduleModule.forRoot(),
],
providers: [AccountsService, HandlesService, DelegationService, KeysService, EnqueueService],
providers: [AccountsService, DelegationService, EnqueueService, HandlesService, KeysService],
// Controller order determines the order of display for docs
// v[Desc first][ABC Second], Health, and then Dev only last
controllers: [AccountsControllerV1, DelegationControllerV1, HandlesControllerV1, KeysControllerV1, HealthController],
Expand Down
1 change: 1 addition & 0 deletions apps/account-api/src/build-openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ process.env.PROVIDER_ACCOUNT_SEED_PHRASE =
process.env.PROVIDER_ID = '0';
process.env.WEBHOOK_BASE_URL = 'http://127.0.0.1';
process.env.CAPACITY_LIMIT = '{"type":"amount","value":"80"}';
process.env.GRAPH_ENVIRONMENT_TYPE = 'TestnetPaseo';

// eslint-disable-next-line
import { ApiModule } from './api.module';
Expand Down
51 changes: 50 additions & 1 deletion apps/account-api/src/controllers/v1/keys-v1.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,20 @@ import {
Body,
Post,
UseGuards,
Query,
BadRequestException,
} from '@nestjs/common';
import { ApiBody, ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger';
import { ApiBody, ApiOkResponse, ApiOperation, ApiQuery, ApiTags } from '@nestjs/swagger';
import { KeysRequestDto, AddKeyRequestDto } from '#account-lib/types/dtos/keys.request.dto';
import { TransactionResponse } from '#account-lib/types/dtos/transaction.response.dto';
import { KeysResponse } from '#account-lib/types/dtos/keys.response.dto';
import { ReadOnlyGuard } from '#account-api/guards/read-only.guard';
import {
AddNewPublicKeyAgreementPayloadRequest,
AddNewPublicKeyAgreementRequestDto,
PublicKeyAgreementRequestDto,
PublicKeyAgreementsKeyPayload,
} from '#account-lib/types/dtos/graphs.request.dto';

@Controller('v1/keys')
@ApiTags('v1/keys')
Expand Down Expand Up @@ -76,4 +84,45 @@ export class KeysControllerV1 {
throw new HttpException('Failed to find public keys for the given msaId', HttpStatus.BAD_REQUEST);
}
}

@Get('publicKeyAgreements/getAddKeyPayload')
@HttpCode(HttpStatus.OK)
@ApiOperation({ summary: 'Get a properly encoded StatefulStorageItemizedSignaturePayloadV2 that can be signed.' })
@ApiOkResponse({ description: 'Returned an encoded StatefulStorageItemizedSignaturePayloadV2 for signing' })
/**
* Using the provided query parameters, creates a new payload that can be signed to add new graph keys.
* @param queryParams - The query parameters for adding a new key
* @returns Payload is included for convenience. Encoded payload to be used when signing the transaction.
* @throws An error if the key already exists or the payload creation fails.
*/
async getPublicKeyAgreementsKeyPayload(
@Query() { msaId, newKey }: PublicKeyAgreementsKeyPayload,
): Promise<AddNewPublicKeyAgreementPayloadRequest> {
return this.keysService.getAddPublicKeyAgreementPayload(msaId, newKey);
}

@Post('publicKeyAgreements')
@HttpCode(HttpStatus.OK)
@ApiOperation({ summary: 'Request to add a new public Key' })
@ApiOkResponse({ description: 'Add new key request enqueued' })
@ApiBody({ type: AddNewPublicKeyAgreementRequestDto })
/**
* Using the provided query parameters, adds a new public key for the account
* @param queryParams - The query parameters for adding a new graph key
* @returns A message that the adding anew graph key operation is in progress.
* @throws An error if enqueueing the operation fails.
*/
async AddNewPublicKeyAgreements(@Body() request: AddNewPublicKeyAgreementRequestDto): Promise<TransactionResponse> {
try {
const response = await this.enqueueService.enqueueRequest<PublicKeyAgreementRequestDto>({
...request,
type: TransactionType.ADD_PUBLIC_KEY_AGREEMENT,
});
this.logger.log(`Add graph key in progress. referenceId: ${response.referenceId}`);
return response;
} catch (error) {
this.logger.error(error);
throw new Error('Failed to add new key');
}
}
}
4 changes: 3 additions & 1 deletion apps/account-api/src/metadata.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
/* eslint-disable */
export default async () => {
const t = {
["../../../libs/account-lib/src/types/dtos/graphs.request.dto"]: await import("../../../libs/account-lib/src/types/dtos/graphs.request.dto"),
["../../../libs/account-lib/src/types/dtos/wallet.login.request.dto"]: await import("../../../libs/account-lib/src/types/dtos/wallet.login.request.dto"),
["../../../libs/account-lib/src/types/dtos/accounts.response.dto"]: await import("../../../libs/account-lib/src/types/dtos/accounts.response.dto"),
["@polkadot/types-codec/primitive/U32"]: await import("@polkadot/types-codec/primitive/U32"),
["../../../libs/account-lib/src/types/dtos/wallet.login.config.response.dto"]: await import("../../../libs/account-lib/src/types/dtos/wallet.login.config.response.dto"),
["../../../libs/account-lib/src/types/dtos/wallet.login.response.dto"]: await import("../../../libs/account-lib/src/types/dtos/wallet.login.response.dto"),
["../../../libs/account-lib/src/types/dtos/delegation.response.dto"]: await import("../../../libs/account-lib/src/types/dtos/delegation.response.dto"),
["../../../libs/account-lib/src/types/dtos/transaction.response.dto"]: await import("../../../libs/account-lib/src/types/dtos/transaction.response.dto"),
["../../../libs/account-lib/src/types/dtos/handles.request.dto"]: await import("../../../libs/account-lib/src/types/dtos/handles.request.dto"),
["../../../libs/account-lib/src/types/dtos/keys.response.dto"]: await import("../../../libs/account-lib/src/types/dtos/keys.response.dto")
};
return { "@nestjs/swagger": { "models": [[import("../../../libs/account-lib/src/types/dtos/keys.request.dto"), { "KeysRequestDto": { msaOwnerAddress: { required: true, type: () => String }, msaOwnerSignature: { required: true, type: () => String }, newKeyOwnerSignature: { required: true, type: () => String } } }], [import("../../../libs/account-lib/src/types/dtos/handles.request.dto"), { "HandleRequestDto": { accountId: { required: true, type: () => String }, proof: { required: true, type: () => String } } }], [import("../../../libs/account-lib/src/types/dtos/wallet.login.request.dto"), { "ErrorResponseDto": { message: { required: true, type: () => String } }, "SiwsPayloadDto": { message: { required: true, type: () => String }, signature: { required: true, type: () => String } }, "SignInResponseDto": { siwsPayload: { required: false, type: () => t["../../../libs/account-lib/src/types/dtos/wallet.login.request.dto"].SiwsPayloadDto }, error: { required: false, type: () => t["../../../libs/account-lib/src/types/dtos/wallet.login.request.dto"].ErrorResponseDto } }, "EncodedExtrinsicDto": { pallet: { required: true, type: () => String }, extrinsicName: { required: true, type: () => String }, encodedExtrinsic: { required: true, type: () => String } }, "SignUpResponseDto": { extrinsics: { required: false, type: () => [t["../../../libs/account-lib/src/types/dtos/wallet.login.request.dto"].EncodedExtrinsicDto] }, error: { required: false, type: () => t["../../../libs/account-lib/src/types/dtos/wallet.login.request.dto"].ErrorResponseDto } }, "WalletLoginRequestDto": { signIn: { required: true, type: () => t["../../../libs/account-lib/src/types/dtos/wallet.login.request.dto"].SignInResponseDto }, signUp: { required: true, type: () => t["../../../libs/account-lib/src/types/dtos/wallet.login.request.dto"].SignUpResponseDto } } }], [import("../../../libs/account-lib/src/types/dtos/accounts.response.dto"), { "HandleResponseDto": { base_handle: { required: true, type: () => String }, canonical_base: { required: true, type: () => String }, suffix: { required: true, type: () => Number } }, "AccountResponseDto": { msaId: { required: true, type: () => String }, handle: { required: false, type: () => t["../../../libs/account-lib/src/types/dtos/accounts.response.dto"].HandleResponseDto } }, "MsaIdResponse": { msaId: { required: true, type: () => String } } }], [import("../../../libs/account-lib/src/types/dtos/delegation.response.dto"), { "DelegationResponse": { providerId: { required: true, type: () => String }, schemaPermissions: { required: true }, revokedAt: { required: true, type: () => t["@polkadot/types-codec/primitive/U32"].u32 } } }], [import("../../../libs/account-lib/src/types/dtos/keys.response.dto"), { "KeysResponse": { msaKeys: { required: true } } }], [import("../../../libs/account-lib/src/types/dtos/transaction.response.dto"), { "TransactionResponse": { referenceId: { required: true, type: () => String } } }], [import("../../../libs/account-lib/src/types/dtos/wallet.login.config.response.dto"), { "WalletLoginConfigResponseDto": { providerId: { required: true, type: () => String }, siwfUrl: { required: true, type: () => String }, frequencyRpcUrl: { required: true, type: () => String } } }], [import("../../../libs/account-lib/src/types/dtos/wallet.login.response.dto"), { "WalletLoginResponseDto": { referenceId: { required: true, type: () => String }, msaId: { required: false, type: () => String }, publicKey: { required: false, type: () => String } } }]], "controllers": [[import("./controllers/health.controller"), { "HealthController": { "healthz": {}, "livez": {}, "readyz": {} } }], [import("./controllers/v1/accounts-v1.controller"), { "AccountsControllerV1": { "getSIWFConfig": { type: t["../../../libs/account-lib/src/types/dtos/wallet.login.config.response.dto"].WalletLoginConfigResponseDto }, "getAccountForMsa": { type: t["../../../libs/account-lib/src/types/dtos/accounts.response.dto"].AccountResponseDto }, "getAccountForPublicKey": { type: t["../../../libs/account-lib/src/types/dtos/accounts.response.dto"].AccountResponseDto }, "postSignInWithFrequency": { type: t["../../../libs/account-lib/src/types/dtos/wallet.login.response.dto"].WalletLoginResponseDto } } }], [import("./controllers/v1/delegation-v1.controller"), { "DelegationControllerV1": { "getDelegation": { type: t["../../../libs/account-lib/src/types/dtos/delegation.response.dto"].DelegationResponse } } }], [import("./controllers/v1/handles-v1.controller"), { "HandlesControllerV1": { "createHandle": { type: t["../../../libs/account-lib/src/types/dtos/transaction.response.dto"].TransactionResponse }, "changeHandle": { type: t["../../../libs/account-lib/src/types/dtos/transaction.response.dto"].TransactionResponse }, "getHandle": { type: t["../../../libs/account-lib/src/types/dtos/accounts.response.dto"].HandleResponseDto } } }], [import("./controllers/v1/keys-v1.controller"), { "KeysControllerV1": { "addKey": { type: t["../../../libs/account-lib/src/types/dtos/transaction.response.dto"].TransactionResponse }, "getKeys": { type: t["../../../libs/account-lib/src/types/dtos/keys.response.dto"].KeysResponse } } }]] } };
return { "@nestjs/swagger": { "models": [[import("../../../libs/account-lib/src/types/dtos/keys.request.dto"), { "KeysRequestDto": { msaOwnerAddress: { required: true, type: () => String }, msaOwnerSignature: { required: true, type: () => String }, newKeyOwnerSignature: { required: true, type: () => String } } }], [import("../../../libs/account-lib/src/types/dtos/handles.request.dto"), { "HandleRequestDto": { accountId: { required: true, type: () => String }, proof: { required: true, type: () => String } }, "ChangeHandlePayloadRequest": { encodedPayload: { required: true, type: () => String } } }], [import("../../../libs/account-lib/src/types/dtos/graphs.request.dto"), { "AddItemActionDto": { type: { required: true, type: () => String, enum: t["../../../libs/account-lib/src/types/dtos/graphs.request.dto"].ItemActionType.ADD_ITEM }, encodedPayload: { required: true, type: () => String } }, "DeleteItemActionDto": { type: { required: true, type: () => String, enum: t["../../../libs/account-lib/src/types/dtos/graphs.request.dto"].ItemActionType.DELETE_ITEM }, index: { required: true, type: () => Number } }, "ItemizedSignaturePayloadDto": { schemaId: { required: true, type: () => Number }, targetHash: { required: true, type: () => Number }, expiration: { required: true, type: () => Number }, actions: { required: true, type: () => [Object] } }, "AddNewPublicKeyAgreementRequestDto": { accountId: { required: true, type: () => String }, payload: { required: true, type: () => t["../../../libs/account-lib/src/types/dtos/graphs.request.dto"].ItemizedSignaturePayloadDto }, proof: { required: true, type: () => String } }, "AddNewPublicKeyAgreementPayloadRequest": { payload: { required: true, type: () => t["../../../libs/account-lib/src/types/dtos/graphs.request.dto"].ItemizedSignaturePayloadDto }, encodedPayload: { required: true, type: () => String } }, "PublicKeyAgreementsKeyPayload": { msaId: { required: true, type: () => String }, newKey: { required: true, type: () => String } } }], [import("../../../libs/account-lib/src/types/dtos/wallet.login.request.dto"), { "ErrorResponseDto": { message: { required: true, type: () => String } }, "SiwsPayloadDto": { message: { required: true, type: () => String }, signature: { required: true, type: () => String } }, "SignInResponseDto": { siwsPayload: { required: false, type: () => t["../../../libs/account-lib/src/types/dtos/wallet.login.request.dto"].SiwsPayloadDto }, error: { required: false, type: () => t["../../../libs/account-lib/src/types/dtos/wallet.login.request.dto"].ErrorResponseDto } }, "EncodedExtrinsicDto": { pallet: { required: true, type: () => String }, extrinsicName: { required: true, type: () => String }, encodedExtrinsic: { required: true, type: () => String } }, "SignUpResponseDto": { extrinsics: { required: false, type: () => [t["../../../libs/account-lib/src/types/dtos/wallet.login.request.dto"].EncodedExtrinsicDto] }, error: { required: false, type: () => t["../../../libs/account-lib/src/types/dtos/wallet.login.request.dto"].ErrorResponseDto } }, "WalletLoginRequestDto": { signIn: { required: true, type: () => t["../../../libs/account-lib/src/types/dtos/wallet.login.request.dto"].SignInResponseDto }, signUp: { required: true, type: () => t["../../../libs/account-lib/src/types/dtos/wallet.login.request.dto"].SignUpResponseDto } } }], [import("../../../libs/account-lib/src/types/dtos/accounts.response.dto"), { "HandleResponseDto": { base_handle: { required: true, type: () => String }, canonical_base: { required: true, type: () => String }, suffix: { required: true, type: () => Number } }, "AccountResponseDto": { msaId: { required: true, type: () => String }, handle: { required: false, type: () => t["../../../libs/account-lib/src/types/dtos/accounts.response.dto"].HandleResponseDto } }, "MsaIdResponse": { msaId: { required: true, type: () => String } } }], [import("../../../libs/account-lib/src/types/dtos/delegation.response.dto"), { "DelegationResponse": { providerId: { required: true, type: () => String }, schemaPermissions: { required: true }, revokedAt: { required: true, type: () => t["@polkadot/types-codec/primitive/U32"].u32 } } }], [import("../../../libs/account-lib/src/types/dtos/keys.response.dto"), { "KeysResponse": { msaKeys: { required: true } } }], [import("../../../libs/account-lib/src/types/dtos/transaction.response.dto"), { "TransactionResponse": { referenceId: { required: true, type: () => String } } }], [import("../../../libs/account-lib/src/types/dtos/wallet.login.config.response.dto"), { "WalletLoginConfigResponseDto": { providerId: { required: true, type: () => String }, siwfUrl: { required: true, type: () => String }, frequencyRpcUrl: { required: true, type: () => String } } }], [import("../../../libs/account-lib/src/types/dtos/wallet.login.response.dto"), { "WalletLoginResponseDto": { referenceId: { required: true, type: () => String }, msaId: { required: false, type: () => String }, publicKey: { required: false, type: () => String } } }]], "controllers": [[import("./controllers/health.controller"), { "HealthController": { "healthz": {}, "livez": {}, "readyz": {} } }], [import("./controllers/v1/accounts-v1.controller"), { "AccountsControllerV1": { "getSIWFConfig": { type: t["../../../libs/account-lib/src/types/dtos/wallet.login.config.response.dto"].WalletLoginConfigResponseDto }, "getAccountForMsa": { type: t["../../../libs/account-lib/src/types/dtos/accounts.response.dto"].AccountResponseDto }, "getAccountForPublicKey": { type: t["../../../libs/account-lib/src/types/dtos/accounts.response.dto"].AccountResponseDto }, "postSignInWithFrequency": { type: t["../../../libs/account-lib/src/types/dtos/wallet.login.response.dto"].WalletLoginResponseDto } } }], [import("./controllers/v1/delegation-v1.controller"), { "DelegationControllerV1": { "getDelegation": { type: t["../../../libs/account-lib/src/types/dtos/delegation.response.dto"].DelegationResponse } } }], [import("./controllers/v1/handles-v1.controller"), { "HandlesControllerV1": { "createHandle": { type: t["../../../libs/account-lib/src/types/dtos/transaction.response.dto"].TransactionResponse }, "changeHandle": { type: t["../../../libs/account-lib/src/types/dtos/transaction.response.dto"].TransactionResponse }, "getChangeHandlePayload": { type: t["../../../libs/account-lib/src/types/dtos/handles.request.dto"].ChangeHandlePayloadRequest }, "getHandle": { type: t["../../../libs/account-lib/src/types/dtos/accounts.response.dto"].HandleResponseDto } } }], [import("./controllers/v1/keys-v1.controller"), { "KeysControllerV1": { "addKey": { type: t["../../../libs/account-lib/src/types/dtos/transaction.response.dto"].TransactionResponse }, "getKeys": { type: t["../../../libs/account-lib/src/types/dtos/keys.response.dto"].KeysResponse }, "getPublicKeyAgreementsKeyPayload": { type: t["../../../libs/account-lib/src/types/dtos/graphs.request.dto"].AddNewPublicKeyAgreementPayloadRequest }, "AddNewPublicKeyAgreements": { type: t["../../../libs/account-lib/src/types/dtos/transaction.response.dto"].TransactionResponse } } }]] } };
};
Loading

0 comments on commit c12681a

Please sign in to comment.