Examples assume an understanding of Holochain development.
A class for communicating with Conductor's App interface with a specific Agent.
connection
- (required) either- an instance of
Connection
- or, it is used as the input for
new Connection( connection )
- an instance of
agent
- (required) a 39 byteUint8Array
that is anAgentPubKey
role_name
- (required) a string of the role name for the cell with the mere memory zomesdna_hash
- (required) a 39 byteUint8Array
that is anDnaHash
Example
const cell_agent_hash = new Uint8Array([ ...39 bytes ]);
const dna_hash = new Uint8Array([ ...39 bytes ]);
const client = new MereMemoryClient( 12345, cell_agent_hash, "storage", dna_hash );
Save the given byte array and return the MemoryEntry
address.
bytes
- (required) aUint8Array
Example
await client.save( new Uint8Array([ ... ]) );
// new EntryHash([ ...39 bytes ]);
Reconstruct the saved bytes for the given MemoryEntry
address.
address
- (required) a 39 byteUint8Array
that is anEntryHash
Example
await client.remember( new Uint8Array([ ...39 bytes ]) );
// new Uint8Array([ ... ]);
Register a handler for signing zome calls.
handler
- (required) a function that receives the zome call input and returns the modified zome call input.
Example use-case for the Holochain Launcher
const { invoke } = require('@tauri-apps/api/tauri');
client.setSigningHandler( async zome_call_request => {
zome_call_request.provenance = Array.from( zome_call_request.provenance );
zome_call_request.cell_id = [
Array.from( zome_call_request.cell_id[0] ),
Array.from( zome_call_request.cell_id[1] ),
];
zome_call_request.payload = Array.from( zome_call_request.payload );
zome_call_request.nonce = Array.from( zome_call_request.nonce );
const signedZomeCall = await invoke("sign_zome_call", {
"zomeCallUnsigned": zome_call_request,
});
signedZomeCall.cap_secret = null;
signedZomeCall.provenance = Uint8Array.from( signedZomeCall.provenance );
signedZomeCall.cell_id = [
Uint8Array.from( signedZomeCall.cell_id[0] ),
Uint8Array.from( signedZomeCall.cell_id[1] ),
];
signedZomeCall.payload = Uint8Array.from( signedZomeCall.payload );
signedZomeCall.signature = Uint8Array.from( signedZomeCall.signature || [] );
signedZomeCall.nonce = Uint8Array.from( signedZomeCall.nonce );
return signedZomeCall;
});
Register a handler for signing zome calls.
agent
- (required) a 39 byteUint8Array
that is anAgentPubKey
handler
- (required) a function that receives the zome call input and returns the modified zome call input.secret
- (optional) a string used as thecap_secret
value for all zome calls
import nacl from 'tweetnacl';
import { hashZomeCall } from '@holochain/serialization');
const key_pair = nacl.sign.keyPair();
client.setCapabilityAgent(
new AgentPubKey( key_pair.publicKey ),
async zome_call_request => {
const zome_call_hash = await hashZomeCall( zome_call_request );
zome_call_request.signature = nacl.sign( zome_call_hash, key_pair.secretKey )
.subarray( 0, nacl.sign.signatureLength );
return zome_call_request;
}
});
zome_function
- (required) the zome function nameargs
- (optional) the args corresponding to the zome functiontimeout
- (optional) raiseTimeoutError
after # milliseconds- defaults to
this.options.timeout
- defaults to
Example
await client.call("create_memory_block", {
"sequence": {
"position": 1,
"length": 1,
},
"bytes": new Uint8Array([ ... ]),
});
Close the WebSocket connection.
Will throw error if the WebSocket was passed in
Example
await client.close();
A class for breaking up large byte arrays into consumable chunks.
{
MereMemoryClient,
Chunker,
}