Skip to content

Commit

Permalink
fix(autonomi): use bigint for u64
Browse files Browse the repository at this point in the history
  • Loading branch information
b-zee committed Nov 8, 2024
1 parent 78b846c commit 12235a5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 8 additions & 0 deletions autonomi/src/client/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,14 @@ mod archive {
pub struct JsArchive(Archive);

/// Create new metadata with the current time as uploaded, created and modified.
///
/// # Example
///
/// ```js
/// const metadata = createMetadata(BigInt(3));
/// const archive = new atnm.Archive();
/// archive.addFile("foo", addr, metadata);
/// ```
#[wasm_bindgen(js_name = createMetadata)]
pub fn create_metadata(size: u64) -> Result<JsValue, JsError> {
let metadata = Metadata::new_with_size(size);
Expand Down
6 changes: 3 additions & 3 deletions autonomi/tests-js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ describe('autonomi', function () {
const data = randomData(32);
const addr = await client.putData(data, wallet);
const archive = new atnm.Archive();
archive.addFile("foo", addr, atnm.createMetadata(data.length));
archive.addFile("foo", addr, atnm.createMetadata(BigInt(data.length)));
const archiveAddr = await client.putArchive(archive, wallet);

const archiveFetched = await client.getArchive(archiveAddr);

assert.deepEqual(archive, archiveFetched);
assert.deepEqual(archive.map(), archiveFetched.map());
});

it('writes archive to vault and fetches it', async () => {
Expand All @@ -59,7 +59,7 @@ describe('autonomi', function () {
const secretKey = atnm.genSecretKey();

const archive = new atnm.Archive();
archive.addFile('foo', addr, atnm.createMetadata(data.length));
archive.addFile('foo', addr, atnm.createMetadata(BigInt(data.length)));
const archiveAddr = await client.putArchive(archive, wallet);

const userData = new atnm.UserData();
Expand Down

0 comments on commit 12235a5

Please sign in to comment.