Skip to content

Commit

Permalink
feat: various fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
gdethier committed Apr 16, 2024
1 parent e7e4f5d commit 8bc361d
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 59 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
17 changes: 6 additions & 11 deletions src/components/identity/PersonalInfo.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<div className="PersonalInfo">
<p className="title">Identity data (not publicly available) submitted by the following account address: <strong>{ requesterAddress?.address || padding }</strong></p>
<p className="title">Identity data (not publicly available) submitted by the following account address: <strong>{ requesterAccountId?.address || padding }</strong></p>
<Row>
<Col>
<LegalEntity
Expand Down
9 changes: 0 additions & 9 deletions src/components/identity/type.ts

This file was deleted.

4 changes: 1 addition & 3 deletions src/config/development.json.sample
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
"APP_NAME": "Logion Wallet DEV",
"directory": "http://localhost:8090",
"rpcEndpoints": [
"ws://localhost:9944",
"ws://localhost:9945",
"ws://localhost:9946"
"ws://localhost:9944"
],
"crossmintApiKey": "",
"logionClassification": "",
Expand Down
2 changes: 1 addition & 1 deletion src/loc/ImportItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ export default function ImportItems() {
<Button
variant="polkadot"
onClick={ importAll }
disabled={ extrinsicSubmissionState.inProgress }
disabled={ getNotSubmitted(items) === 0 || extrinsicSubmissionState.inProgress }
>
<Icon icon={{id: "import_items"}} height="23px" /> Import all
</Button>
Expand Down
43 changes: 17 additions & 26 deletions src/vault/VaultOutRequest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<OptionType<ValidAccountId>[]>([]);
const [ legalOfficer, setLegalOfficer ] = useState<ValidAccountId | null>(null);
const [ legalOfficerError, setLegalOfficerError ] = useState<string>();

useEffect(() => {
if (legalOfficersOptions.length === 0 && protectionState && availableLegalOfficers) {
Expand All @@ -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<FormValues>({
defaultValues: {
legalOfficer: null,
amount: {
value: "",
unit: Numbers.NONE
Expand All @@ -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!,
Expand All @@ -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;
Expand Down Expand Up @@ -170,28 +175,14 @@ export default function VaultOutRequest() {
id="legalOfficer"
label="Legal officer"
control={
<Controller
name="legalOfficer"
control={ control }
rules={{
required: 'You must select a Legal Officer',
minLength: {
value: 1,
message: 'You must select a Legal Officer'
},

}}
render={({ field }) => (
<Select
isInvalid={ !!errors.legalOfficer?.message }
options={ legalOfficersOptions }
value={ field.value }
onChange={ field.onChange }
/>
)}
<Select
isInvalid={ !!legalOfficerError }
options={ legalOfficersOptions }
value={ legalOfficer }
onChange={ value => { setLegalOfficerError(undefined) ; setLegalOfficer(value) } }
/>
}
feedback={ errors.legalOfficer?.message }
feedback={ legalOfficerError }
colors={ colorTheme.dialog }
/>
</>
Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -3281,16 +3281,16 @@ __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
"@polkadot/util-crypto": ^12.6.2
"@types/uuid": ^9.0.2
fast-sha256: ^1.3.0
uuid: ^9.0.0
checksum: 77ff276c92d2613ff9874fa1932c56de62d4d13949b1cbff26ed6b0d3bdaa3c305c1b212e6fc4cb68dccecfc22a47da312531b391e91221b0e8e5c3c087a54d8
checksum: a5034038bb4a93fc9b5e2fdfa2798a495f6530b232bab0c6c44bff667092df55d1cff6ff11c998ce7a70d6994c61274ac45ddf9f3fe7f2e0be01115628a96f9c
languageName: node
linkType: hard

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8bc361d

Please sign in to comment.