diff --git a/package.json b/package.json
index a359850a..7190ad71 100644
--- a/package.json
+++ b/package.json
@@ -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",
diff --git a/src/loc/FileModel.test.ts b/src/loc/FileModel.test.ts
index 67938835..a908246b 100644
--- a/src/loc/FileModel.test.ts
+++ b/src/loc/FileModel.test.ts
@@ -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(
diff --git a/src/loc/ImportItemDetails.tsx b/src/loc/ImportItemDetails.tsx
index 47b99d11..869c607f 100644
--- a/src/loc/ImportItemDetails.tsx
+++ b/src/loc/ImportItemDetails.tsx
@@ -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';
@@ -19,7 +19,7 @@ export interface Item {
id?: Hash;
displayId: string;
description: string;
- files: ItemFileWithContent[];
+ files: HashOrContent[];
restrictedDelivery: boolean;
token?: ItemTokenWithRestrictedType;
error?: string;
@@ -61,8 +61,8 @@ export default function ImportItemDetails(props: { locId: UUID, item: Item }) {
Attached file:
- Name: { props.item.files[0].name }
- - Content type: { props.item.files[0].contentType.mimeType }
- - Hash: { props.item.files[0].hashOrContent.contentHash.toHex() }
+ - Content type: { props.item.files[0].mimeType.mimeType }
+ - Hash: { props.item.files[0].contentHash.toHex() }
- Size: { props.item.files[0].size.toString() } bytes
diff --git a/src/loc/ImportItems.tsx b/src/loc/ImportItems.tsx
index acebee14..d5944307 100644
--- a/src/loc/ImportItems.tsx
+++ b/src/loc/ImportItems.tsx
@@ -1,7 +1,6 @@
import {
ClosedCollectionLoc,
UploadableCollectionItem,
- ItemFileWithContent,
HashOrContent,
MimeType,
ItemTokenWithRestrictedType,
@@ -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;
@@ -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 }
/>
}
{
@@ -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),
- })
+ }),
];
}
diff --git a/src/loc/LocPrivateFileButton.tsx b/src/loc/LocPrivateFileButton.tsx
index 4fc72b89..ebded1be 100644
--- a/src/loc/LocPrivateFileButton.tsx
+++ b/src/loc/LocPrivateFileButton.tsx
@@ -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().hash.equalTo(hash));
if (existingItem !== undefined) {
@@ -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 {
diff --git a/src/loc/record/AddTokensRecordDialog.tsx b/src/loc/record/AddTokensRecordDialog.tsx
index b25523ed..5c27926b 100644
--- a/src/loc/record/AddTokensRecordDialog.tsx
+++ b/src/loc/record/AddTokensRecordDialog.tsx
@@ -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";
@@ -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());
@@ -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');
@@ -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,
});
diff --git a/src/settings/ValuesFiles.tsx b/src/settings/ValuesFiles.tsx
index 576aeeac..eee7cc2f 100644
--- a/src/settings/ValuesFiles.tsx
+++ b/src/settings/ValuesFiles.tsx
@@ -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 {
diff --git a/yarn.lock b/yarn.lock
index b52dea22..cf86ece5 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -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"
@@ -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
@@ -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"
@@ -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