From 8bc361d214bb16d659365a8303c278ee9dbebcc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9rard=20Dethier?= Date: Tue, 16 Apr 2024 15:14:22 +0200 Subject: [PATCH] feat: various fixes. logion-network/logion-internal#1220 --- package.json | 2 +- src/components/identity/PersonalInfo.tsx | 17 ++++------ src/components/identity/type.ts | 9 ----- src/config/development.json.sample | 4 +-- src/loc/ImportItems.tsx | 2 +- src/vault/VaultOutRequest.tsx | 43 ++++++++++-------------- yarn.lock | 16 ++++----- 7 files changed, 34 insertions(+), 59 deletions(-) delete mode 100644 src/components/identity/type.ts diff --git a/package.json b/package.json index 7fbc2c45..148ab7e1 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "license": "Apache-2.0", "dependencies": { "@creativecommons/cc-assets": "^0.1.0", - "@logion/client": "^0.43.0-3", + "@logion/client": "^0.43.0-4", "@logion/client-browser": "^0.3.4", "@logion/crossmint": "^0.1.32", "@logion/extension": "^0.8.0-1", diff --git a/src/components/identity/PersonalInfo.tsx b/src/components/identity/PersonalInfo.tsx index 6ec8439e..0f70f171 100644 --- a/src/components/identity/PersonalInfo.tsx +++ b/src/components/identity/PersonalInfo.tsx @@ -1,23 +1,18 @@ -import { Row } from "../../common/Grid"; +import { LocData } from "@logion/client"; import { Col } from "react-bootstrap"; + +import { Row } from "../../common/Grid"; import Detail from "../../common/Detail"; -import { PersonalInfoProps } from "./type"; -import { LocRequestStatus } from "@logion/client/dist/LocClient.js"; import "./PersonalInfo.css"; import LegalEntity from "./LegalEntity"; -interface PersonalAndStatusInfoProps extends PersonalInfoProps { - status: LocRequestStatus, - seal?: string -} - -export function PersonalInfo(props: { personalAndStatusInfo: PersonalAndStatusInfoProps }) { - const { requesterAddress, userIdentity, userPostalAddress, status, seal, company } = props.personalAndStatusInfo; +export function PersonalInfo(props: { personalAndStatusInfo: LocData }) { + const { requesterAccountId, userIdentity, userPostalAddress, status, seal, company } = props.personalAndStatusInfo; const padding = "/"; return (
-

Identity data (not publicly available) submitted by the following account address: { requesterAddress?.address || padding }

+

Identity data (not publicly available) submitted by the following account address: { requesterAccountId?.address || padding }

Import all diff --git a/src/vault/VaultOutRequest.tsx b/src/vault/VaultOutRequest.tsx index 529b25a8..8a235a26 100644 --- a/src/vault/VaultOutRequest.tsx +++ b/src/vault/VaultOutRequest.tsx @@ -18,18 +18,19 @@ import { useUserContext } from "../wallet-user/UserContext"; import ExtrinsicSubmissionStateView from "src/ExtrinsicSubmissionStateView"; interface FormValues { - legalOfficer: ValidAccountId | null; amount: Amount; destination: string; } export default function VaultOutRequest() { - const { api, accounts, getOfficer, signer, client, submitCall, clearSubmissionState, extrinsicSubmissionState } = useLogionChain(); + const { accounts, getOfficer, signer, client, submitCall, clearSubmissionState, extrinsicSubmissionState } = useLogionChain(); const { availableLegalOfficers, colorTheme } = useCommonContext(); const { protectionState, mutateVaultState } = useUserContext(); const [ showDialog, setShowDialog ] = useState(false); const [ legalOfficersOptions, setLegalOfficersOptions ] = useState[]>([]); + const [ legalOfficer, setLegalOfficer ] = useState(null); + const [ legalOfficerError, setLegalOfficerError ] = useState(); useEffect(() => { if (legalOfficersOptions.length === 0 && protectionState && availableLegalOfficers) { @@ -38,11 +39,10 @@ export default function VaultOutRequest() { buildOptions(candidates) .then(options => setLegalOfficersOptions(options)); } - }, [ accounts, api, availableLegalOfficers, legalOfficersOptions, setLegalOfficersOptions, protectionState ]); + }, [ availableLegalOfficers, legalOfficersOptions, protectionState ]); const { control, handleSubmit, formState: { errors }, reset } = useForm({ defaultValues: { - legalOfficer: null, amount: { value: "", unit: Numbers.NONE @@ -57,10 +57,15 @@ export default function VaultOutRequest() { }, [ reset ]); const transferCallback = useCallback(async (formValues: FormValues) => { + if(!legalOfficer) { + setLegalOfficerError("You must select a Legal Officer"); + return; + } + const call = async (callback: CallCallback) => { await mutateVaultState(async (state: VaultState) => { return await state.createVaultTransferRequest({ - legalOfficer: getOfficer!(formValues!.legalOfficer!)!, + legalOfficer: getOfficer!(legalOfficer!)!, amount: Lgnt.fromPrefixedNumber(new Numbers.PrefixedNumber(formValues.amount.value, formValues.amount.unit)), destination: ValidAccountId.polkadot(formValues.destination), signer: signer!, @@ -74,7 +79,7 @@ export default function VaultOutRequest() { } finally { clearSubmissionState(); } - }, [ getOfficer, mutateVaultState, signer, submitCall, clearSubmissionState, close ]); + }, [ getOfficer, mutateVaultState, signer, submitCall, clearSubmissionState, close, legalOfficer ]); if(availableLegalOfficers === undefined || !client) { return null; @@ -170,28 +175,14 @@ export default function VaultOutRequest() { id="legalOfficer" label="Legal officer" control={ - ( - { setLegalOfficerError(undefined) ; setLegalOfficer(value) } } /> } - feedback={ errors.legalOfficer?.message } + feedback={ legalOfficerError } colors={ colorTheme.dialog } /> diff --git a/yarn.lock b/yarn.lock index b6223d9e..48cc2475 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3216,15 +3216,15 @@ __metadata: languageName: node linkType: hard -"@logion/client@npm:^0.43.0-3": - version: 0.43.0-3 - resolution: "@logion/client@npm:0.43.0-3" +"@logion/client@npm:^0.43.0-4": + version: 0.43.0-4 + resolution: "@logion/client@npm:0.43.0-4" dependencies: "@logion/node-api": ^0.29.0-5 axios: ^1.6.7 luxon: ^3.4.4 mime-db: ^1.52.0 - checksum: 4a1c2f02c1cbca2101e1899b2ee98add3952af4c810662f54a594144b04ee9c8f87f27f632a2833b27e9e407773bf759e96f782af4df508f1fae534402cdd3d2 + checksum: dceb958b5b00d8d27feb0526900634c194230e63bca78b5f617c320422d73878858e50decf981d1569864f5faffe322170f5483d32ddb23ca89c1666d32c5a47 languageName: node linkType: hard @@ -3281,8 +3281,8 @@ __metadata: linkType: hard "@logion/node-api@npm:^0.29.0-5": - version: 0.29.0-5 - resolution: "@logion/node-api@npm:0.29.0-5" + version: 0.29.0-6 + resolution: "@logion/node-api@npm:0.29.0-6" dependencies: "@polkadot/api": ^10.12.2 "@polkadot/util": ^12.6.2 @@ -3290,7 +3290,7 @@ __metadata: "@types/uuid": ^9.0.2 fast-sha256: ^1.3.0 uuid: ^9.0.0 - checksum: 77ff276c92d2613ff9874fa1932c56de62d4d13949b1cbff26ed6b0d3bdaa3c305c1b212e6fc4cb68dccecfc22a47da312531b391e91221b0e8e5c3c087a54d8 + checksum: a5034038bb4a93fc9b5e2fdfa2798a495f6530b232bab0c6c44bff667092df55d1cff6ff11c998ce7a70d6994c61274ac45ddf9f3fe7f2e0be01115628a96f9c languageName: node linkType: hard @@ -12105,7 +12105,7 @@ __metadata: "@babel/preset-react": ^7.23.3 "@babel/preset-typescript": ^7.23.3 "@creativecommons/cc-assets": ^0.1.0 - "@logion/client": ^0.43.0-3 + "@logion/client": ^0.43.0-4 "@logion/client-browser": ^0.3.4 "@logion/crossmint": ^0.1.32 "@logion/extension": ^0.8.0-1