Skip to content

Commit

Permalink
chore: upgrade dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
gdethier committed Nov 23, 2023
1 parent ea8d3e5 commit d2bc753
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 50 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"dependencies": {
"@craco/craco": "^6.4.5",
"@creativecommons/cc-assets": "^0.1.0",
"@logion/client-browser": "^0.1.0",
"@logion/crossmint": "^0.1.28",
"@logion/client-browser": "^0.2.0-1",
"@logion/crossmint": "^0.1.29-1",
"@logion/extension": "^0.7.2",
"@logion/multiversx": "^0.1.9",
"@multiversx/sdk-extension-provider": "^2.0.7",
Expand Down
2 changes: 1 addition & 1 deletion src/loc/FileModel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ describe("FileModel", () => {
axios,
legalOfficer,
fileId,
file: HashOrContent.fromContent(new BrowserFile(file)),
file: HashOrContent.fromContent(new BrowserFile(file, file.name)),
});

expect(axios.put).toBeCalledWith(
Expand Down
8 changes: 4 additions & 4 deletions src/loc/ImportItemDetails.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {
ItemFileWithContent,
ItemTokenWithRestrictedType,
SpecificLicense,
LogionClassification,
TermsAndConditionsElement,
CreativeCommons,
HashOrContent,
} from "@logion/client";
import { Hash, UUID } from "@logion/node-api";
import './ImportItemDetails.css';
Expand All @@ -19,7 +19,7 @@ export interface Item {
id?: Hash;
displayId: string;
description: string;
files: ItemFileWithContent[];
files: HashOrContent[];
restrictedDelivery: boolean;
token?: ItemTokenWithRestrictedType;
error?: string;
Expand Down Expand Up @@ -61,8 +61,8 @@ export default function ImportItemDetails(props: { locId: UUID, item: Item }) {
<p>Attached file:</p>
<ul>
<li>Name: { props.item.files[0].name }</li>
<li>Content type: { props.item.files[0].contentType.mimeType }</li>
<li>Hash: { props.item.files[0].hashOrContent.contentHash.toHex() }</li>
<li>Content type: { props.item.files[0].mimeType.mimeType }</li>
<li>Hash: { props.item.files[0].contentHash.toHex() }</li>
<li>Size: { props.item.files[0].size.toString() } bytes</li>
</ul>
</div>
Expand Down
27 changes: 11 additions & 16 deletions src/loc/ImportItems.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
ClosedCollectionLoc,
UploadableCollectionItem,
ItemFileWithContent,
HashOrContent,
MimeType,
ItemTokenWithRestrictedType,
Expand Down Expand Up @@ -169,17 +168,13 @@ export default function ImportItems() {
setUploading(true);
const collection = locState as ClosedCollectionLoc;
try {
const itemFile = await HashOrContent.fromContentFinalized(new BrowserFile(file, item.files[0].name));
if(itemFile.size !== item.files[0].size || !itemFile.contentHash.equalTo(item.files[0].contentHash)) {
throw new Error("File does not match size and/or hash in CSV file");
}
await collection.uploadCollectionItemFile({
itemId: item.id!,
itemFile: new ItemFileWithContent({
name: item.files[0].name,
contentType: item.files[0].contentType,
size: item.files[0].size,
hashOrContent: new HashOrContent({
hash: item.files[0].hashOrContent.contentHash,
content: new BrowserFile(file),
}),
}),
itemFile,
});
item.upload = false;
item.error = undefined;
Expand Down Expand Up @@ -296,7 +291,7 @@ export default function ImportItems() {
buttonText="Upload file"
onFileSelected={ file => uploadItemFile(item, file) }
onlyButton={ true }
accept={ item.files[0].contentType.mimeType }
accept={ item.files[0].mimeType.mimeType }
/>
}
{
Expand Down Expand Up @@ -446,15 +441,15 @@ function toItems(csvItems: CsvItem[], collectionAcceptsUpload: boolean): Item[]
let error: string | undefined = undefined;
let errorType: ErrorType | undefined = undefined;

let files: ItemFileWithContent[] = [];
let files: HashOrContent[] = [];
if("fileName" in csvItem) {
files = [
new ItemFileWithContent({
HashOrContent.fromDescription({
hash: csvItem.fileHash,
mimeType: MimeType.from(csvItem.fileContentType),
name: csvItem.fileName,
contentType: MimeType.from(csvItem.fileContentType),
size: BigInt(csvItem.fileSize),
hashOrContent: HashOrContent.fromHash(csvItem.fileHash),
})
}),
];
}

Expand Down
3 changes: 1 addition & 2 deletions src/loc/LocPrivateFileButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function LocPrivateFileButton(props: Props) {
setUploadError("")
if (file) {
setStatus('Hashing')
const content = await HashOrContent.fromContentFinalized(new BrowserFile(file));
const content = await HashOrContent.fromContentFinalized(new BrowserFile(file, formValues.fileName));
const hash = content.contentHash;
const existingItem = locItems.find(item => item.type === "Document" && item.as<FileData>().hash.equalTo(hash));
if (existingItem !== undefined) {
Expand All @@ -49,7 +49,6 @@ export function LocPrivateFileButton(props: Props) {
if(current instanceof EditableRequest) {
return current.addFile({
file: content,
fileName: formValues.fileName,
nature: props.nature ? props.nature : formValues.nature,
});
} else {
Expand Down
20 changes: 4 additions & 16 deletions src/loc/record/AddTokensRecordDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HashOrContent, TokensRecord, ClosedCollectionLoc, ItemFileWithContent, MimeType } from "@logion/client";
import { HashOrContent, TokensRecord, ClosedCollectionLoc } from "@logion/client";
import { useCallback, useState } from "react";
import { Form, Spinner } from "react-bootstrap";
import { Controller, useForm } from "react-hook-form";
Expand Down Expand Up @@ -67,7 +67,7 @@ export default function AddTokensRecordDialog(props: Props) {
if (file) {
setStatus('Hashing')
try {
const content = await HashOrContent.fromContentFinalized(new BrowserFile(file));
const content = await HashOrContent.fromContentFinalized(new BrowserFile(file, formValues.fileName));
setContent(content);
const hash = content.contentHash;
const existingRecord = props.records.find(record => record.id.toHex() === hash.toHex());
Expand All @@ -78,13 +78,7 @@ export default function AddTokensRecordDialog(props: Props) {
const fees = await collection.estimateFeesAddTokensRecord({
recordId: hash,
description: formValues.description,
files: [
new ItemFileWithContent({
contentType: MimeType.from(formValues.contentType),
hashOrContent: content,
name: formValues.fileName,
}),
],
files: [ content ],
});
setFees(fees);
setStatus('Confirming');
Expand All @@ -108,13 +102,7 @@ export default function AddTokensRecordDialog(props: Props) {
await current.addTokensRecord({
recordId: hash,
description: formValues.description,
files: [
new ItemFileWithContent({
contentType: MimeType.from(formValues.contentType),
hashOrContent: content,
name: formValues.fileName,
}),
],
files: [ content ],
signer,
callback,
});
Expand Down
2 changes: 1 addition & 1 deletion src/settings/ValuesFiles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function ValuesFiles() {
await addLoFile({
axios: axiosFactory!(legalOfficer),
legalOfficer: legalOfficer!,
file: HashOrContent.fromContent(new BrowserFile(file)),
file: HashOrContent.fromContent(new BrowserFile(file, file.name)),
fileId
});
} finally {
Expand Down
51 changes: 43 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2985,6 +2985,15 @@ __metadata:
languageName: node
linkType: hard

"@logion/client-browser@npm:^0.2.0-1":
version: 0.2.0-1
resolution: "@logion/client-browser@npm:0.2.0-1"
dependencies:
"@logion/client": ^0.35.0-1
checksum: b5f62bf03776ae570c99d41eb35671af874f7cadb933363b4588f4312d138638d4d7affe6f1e985a8e821ca3d73d0abeb41c798bc8965bfb8decae59d1c4f069
languageName: node
linkType: hard

"@logion/client@npm:^0.34.0":
version: 0.34.0
resolution: "@logion/client@npm:0.34.0"
Expand All @@ -2997,15 +3006,27 @@ __metadata:
languageName: node
linkType: hard

"@logion/crossmint@npm:^0.1.28":
version: 0.1.28
resolution: "@logion/crossmint@npm:0.1.28"
"@logion/client@npm:^0.35.0-1":
version: 0.35.0-3
resolution: "@logion/client@npm:0.35.0-3"
dependencies:
"@logion/node-api": ^0.26.0-1
axios: ^0.27.2
luxon: ^3.0.1
mime-db: ^1.52.0
checksum: bf77aca763af1cf783783a2e7285020c23625effc1f0448b3bdc3139878a63ee5f2b9362486fda672b4a160cd889521ec2657455943132509bf5157da38a0a89
languageName: node
linkType: hard

"@logion/crossmint@npm:^0.1.29-1":
version: 0.1.29-1
resolution: "@logion/crossmint@npm:0.1.29-1"
dependencies:
"@crossmint/connect": ^0.0.8
"@logion/client-browser": ^0.1.0
"@logion/client-browser": ^0.2.0-1
peerDependencies:
"@logion/client-browser": ^0.1.0
checksum: 2cd17c1028f4151f6201e63e1b674f7c8e8b2b093dccab15240d285b2e3d294541ba6d25eaa1c20064911be939a400dd24244791355eb8962768af47aae1fb92
"@logion/client-browser": ^0.2.0-1
checksum: 9895949d484ae93e8b3557b89357e5d78ff3eb57c0cfbf2544e2936cd4279da4e010c33764d9d224367d3b769af8414dafb99815448bec53e1769ec2f1a10426
languageName: node
linkType: hard

Expand Down Expand Up @@ -3049,6 +3070,20 @@ __metadata:
languageName: node
linkType: hard

"@logion/node-api@npm:^0.26.0-1":
version: 0.26.0-1
resolution: "@logion/node-api@npm:0.26.0-1"
dependencies:
"@polkadot/api": ^10.10.1
"@polkadot/util": ^12.5.1
"@polkadot/util-crypto": ^12.5.1
"@types/uuid": ^9.0.2
fast-sha256: ^1.3.0
uuid: ^9.0.0
checksum: ce06294036b8477941d24a673e15abbf9b65be23ee7896ad47f2567e422e98fc9f75efc875f67ed940359b580eb2bacdc5c0496e20be3a434d95424c4f5c9a11
languageName: node
linkType: hard

"@metamask/detect-provider@npm:^2.0.0":
version: 2.0.0
resolution: "@metamask/detect-provider@npm:2.0.0"
Expand Down Expand Up @@ -12575,8 +12610,8 @@ __metadata:
"@babel/preset-react": ^7.18.6
"@craco/craco": ^6.4.5
"@creativecommons/cc-assets": ^0.1.0
"@logion/client-browser": ^0.1.0
"@logion/crossmint": ^0.1.28
"@logion/client-browser": ^0.2.0-1
"@logion/crossmint": ^0.1.29-1
"@logion/extension": ^0.7.2
"@logion/multiversx": ^0.1.9
"@multiversx/sdk-extension-provider": ^2.0.7
Expand Down

0 comments on commit d2bc753

Please sign in to comment.