Skip to content

Commit

Permalink
feat: Aleph persistent storage fetch method
Browse files Browse the repository at this point in the history
  • Loading branch information
RezaRahemtola committed Jun 3, 2024
1 parent aef24b9 commit e6222d6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/utils/aleph-persistent-storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const AGGREGATE_KEY = 'libertai-chat-ui';
export class AlephPersistentStorage {
constructor(account) {
this.account = account;
this.client = new AuthenticatedAlephHttpClient(this.account);
}

static async initialize(signer) {
Expand All @@ -19,11 +20,14 @@ export class AlephPersistentStorage {
}

async save(content) {
const client = new AuthenticatedAlephHttpClient(this.account);
const message = await client.createAggregate({
const message = await this.client.createAggregate({
key: AGGREGATE_KEY,
content,
});
console.log(`Saved on Aleph with hash ${message.item_hash}`);
console.log(`Data saved on Aleph with hash ${message.item_hash}`);
}

async fetch() {
return this.client.fetchAggregate(this.account.address, AGGREGATE_KEY);
}
}

0 comments on commit e6222d6

Please sign in to comment.