Skip to content

Commit

Permalink
fix: added document name
Browse files Browse the repository at this point in the history
  • Loading branch information
veeso committed Dec 10, 2024
1 parent d9b4358 commit e99df04
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/declarations/deferred_data/deferred_data.did
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,15 @@ type Contract = record {
buyers : vec text;
};
type ContractDocument = record {
name : text;
mime_type : text;
access_list : vec RestrictionLevel;
};
type ContractDocumentData = record { data : blob; mime_type : text };
type ContractDocumentData = record {
data : blob;
name : text;
mime_type : text;
};
type ContractError = variant {
DocumentNotFound : nat64;
ContractNotFound : nat;
Expand Down
2 changes: 2 additions & 0 deletions src/declarations/deferred_data/deferred_data.did.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ export interface Contract {
'buyers' : Array<string>,
}
export interface ContractDocument {
'name' : string,
'mime_type' : string,
'access_list' : Array<RestrictionLevel>,
}
export interface ContractDocumentData {
'data' : Uint8Array | number[],
'name' : string,
'mime_type' : string,
}
export type ContractError = { 'DocumentNotFound' : bigint } |
Expand Down
2 changes: 2 additions & 0 deletions src/declarations/deferred_data/deferred_data.did.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const idlFactory = ({ IDL }) => {
'Agent' : IDL.Null,
});
const ContractDocument = IDL.Record({
'name' : IDL.Text,
'mime_type' : IDL.Text,
'access_list' : IDL.Vec(RestrictionLevel),
});
Expand Down Expand Up @@ -120,6 +121,7 @@ export const idlFactory = ({ IDL }) => {
});
const ContractDocumentData = IDL.Record({
'data' : IDL.Vec(IDL.Nat8),
'name' : IDL.Text,
'mime_type' : IDL.Text,
});
const Result_1 = IDL.Variant({
Expand Down
7 changes: 6 additions & 1 deletion src/deferred_data/deferred_data.did
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,15 @@ type Contract = record {
buyers : vec text;
};
type ContractDocument = record {
name : text;
mime_type : text;
access_list : vec RestrictionLevel;
};
type ContractDocumentData = record { data : blob; mime_type : text };
type ContractDocumentData = record {
data : blob;
name : text;
mime_type : text;
};
type ContractError = variant {
DocumentNotFound : nat64;
ContractNotFound : nat;
Expand Down
2 changes: 2 additions & 0 deletions src/deferred_data/src/app/storage/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ impl ContractStorage {
Ok(ContractDocumentData {
data: document_data,
mime_type: document_properties.mime_type.clone(),
name: document_properties.name.clone(),
})
}
}
Expand Down Expand Up @@ -372,6 +373,7 @@ mod test {
let document = ContractDocument {
mime_type: "application/pdf".to_string(),
access_list: vec![RestrictionLevel::Seller],
name: "contract.pdf".to_string(),
};

let document_id =
Expand Down
1 change: 1 addition & 0 deletions src/deferred_data/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ mod test {
ContractDocument {
access_list: vec![RestrictionLevel::Public],
mime_type: "application/pdf".to_string(),
name: "document".to_string(),
},
vec![0x01, 0x02, 0x03, 0x04],
)
Expand Down
2 changes: 2 additions & 0 deletions src/did/src/deferred/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,15 @@ pub type ContractDocuments = Vec<(u64, ContractDocument)>;
pub struct ContractDocument {
pub access_list: Vec<RestrictionLevel>,
pub mime_type: String,
pub name: String,
}

/// A struct which defines a document data
#[derive(Clone, Debug, CandidType, PartialEq, Serialize, Deserialize)]
pub struct ContractDocumentData {
pub data: Vec<u8>,
pub mime_type: String,
pub name: String,
}

/// A restricted property, which defines the access level to the property and its value
Expand Down
1 change: 1 addition & 0 deletions src/repr/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ fn repr_contract() -> anyhow::Result<()> {
ContractDocument {
access_list: vec![RestrictionLevel::Agent, RestrictionLevel::Seller],
mime_type: "application/pdf".to_string(),
name: "Contract".to_string(),
},
)];

Expand Down

0 comments on commit e99df04

Please sign in to comment.