From db3723afa5e3cae7a6a732300013ce8804443281 Mon Sep 17 00:00:00 2001 From: grumbach Date: Sat, 11 Jan 2025 02:51:19 +0900 Subject: [PATCH] feat: fix docs and bad namings in API --- ant-protocol/src/storage/graph.rs | 22 +++-- autonomi/nodejs/dist/linkedList.d.ts | 8 +- autonomi/nodejs/dist/linkedList.js | 6 +- autonomi/src/client/graph.rs | 23 ++--- autonomi/tests/graph.rs | 12 +-- .../api/autonomi-client/README.md | 76 +++++++---------- .../api/autonomi-client/data_types.md | 12 +-- .../api/autonomi-client/errors.md | 50 ----------- docs/online-documentation/api/index.md | 2 +- .../guides/client_modes.md | 6 +- .../online-documentation/guides/data_types.md | 85 +++++++------------ .../guides/testing_guide.md | 36 ++++---- nodejs/README.md | 10 +-- nodejs/package.json | 2 +- nodejs/src/client.ts | 10 +-- nodejs/src/index.ts | 2 +- nodejs/src/types.ts | 2 +- nodejs/tests/client.test.ts | 10 +-- 18 files changed, 142 insertions(+), 232 deletions(-) diff --git a/ant-protocol/src/storage/graph.rs b/ant-protocol/src/storage/graph.rs index c84e16d156..ea21cecff3 100644 --- a/ant-protocol/src/storage/graph.rs +++ b/ant-protocol/src/storage/graph.rs @@ -22,7 +22,7 @@ pub struct GraphEntry { pub owner: PublicKey, pub parents: Vec, pub content: GraphContent, - pub outputs: Option>, + pub outputs: Vec<(PublicKey, GraphContent)>, /// signs the above 4 fields with the owners key pub signature: Signature, } @@ -33,7 +33,7 @@ impl GraphEntry { owner: PublicKey, parents: Vec, content: GraphContent, - outputs: Option>, + outputs: Vec<(PublicKey, GraphContent)>, signing_key: &SecretKey, ) -> Self { let signature = signing_key.sign(Self::bytes_to_sign(&owner, &parents, &content, &outputs)); @@ -51,7 +51,7 @@ impl GraphEntry { owner: PublicKey, parents: Vec, content: GraphContent, - outputs: Option>, + outputs: Vec<(PublicKey, GraphContent)>, signature: Signature, ) -> Self { Self { @@ -68,7 +68,7 @@ impl GraphEntry { owner: &PublicKey, parents: &[PublicKey], content: &[u8], - outputs: &Option>, + outputs: &[(PublicKey, GraphContent)], ) -> Vec { let mut bytes = Vec::new(); bytes.extend_from_slice(&owner.to_bytes()); @@ -83,14 +83,12 @@ impl GraphEntry { bytes.extend_from_slice("content".as_bytes()); bytes.extend_from_slice(content); bytes.extend_from_slice("outputs".as_bytes()); - if let Some(outputs) = outputs { - bytes.extend_from_slice( - &outputs - .iter() - .flat_map(|(p, c)| [&p.to_bytes(), c.as_slice()].concat()) - .collect::>(), - ); - } + bytes.extend_from_slice( + &outputs + .iter() + .flat_map(|(p, c)| [&p.to_bytes(), c.as_slice()].concat()) + .collect::>(), + ); bytes } diff --git a/autonomi/nodejs/dist/linkedList.d.ts b/autonomi/nodejs/dist/linkedList.d.ts index 94a3ef1fbf..21330fcc23 100644 --- a/autonomi/nodejs/dist/linkedList.d.ts +++ b/autonomi/nodejs/dist/linkedList.d.ts @@ -1,9 +1,9 @@ -import { LinkedListOptions, PaymentOption } from './types'; -export declare class LinkedList { +import { GarphEntryOptions, PaymentOption } from './types'; +export declare class GarphEntry { private nativeList; private constructor(); - static create(address: string): Promise; + static create(address: string): Promise; get(): Promise; - put(options: LinkedListOptions, payment: PaymentOption): Promise; + put(options: GarphEntryOptions, payment: PaymentOption): Promise; getCost(key: string): Promise; } diff --git a/autonomi/nodejs/dist/linkedList.js b/autonomi/nodejs/dist/linkedList.js index 0c3c3f4fd4..c17c9b45a8 100644 --- a/autonomi/nodejs/dist/linkedList.js +++ b/autonomi/nodejs/dist/linkedList.js @@ -1,7 +1,7 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.LinkedList = void 0; -class LinkedList { +exports.GarphEntry = void 0; +class GarphEntry { constructor(nativeList) { this.nativeList = nativeList; } @@ -22,4 +22,4 @@ class LinkedList { throw new Error('Not implemented'); } } -exports.LinkedList = LinkedList; +exports.GarphEntry = GarphEntry; diff --git a/autonomi/src/client/graph.rs b/autonomi/src/client/graph.rs index b9fb0fcca2..6b4db4b060 100644 --- a/autonomi/src/client/graph.rs +++ b/autonomi/src/client/graph.rs @@ -48,8 +48,8 @@ pub enum GraphError { } impl Client { - /// Fetches a Transaction from the network. - pub async fn transaction_get( + /// Fetches a GraphEntry from the network. + pub async fn graph_entry_get( &self, address: GraphEntryAddress, ) -> Result, GraphError> { @@ -58,12 +58,13 @@ impl Client { Ok(transactions) } - pub async fn transaction_put( + /// Puts a GraphEntry to the network. + pub async fn graph_entry_put( &self, - transaction: GraphEntry, + entry: GraphEntry, wallet: &EvmWallet, ) -> Result<(), GraphError> { - let address = transaction.address(); + let address = entry.address(); // pay for the transaction let xor_name = address.xorname(); @@ -80,7 +81,7 @@ impl Client { Some((proof, price)) => (proof, price), None => { // transaction was skipped, meaning it was already paid for - error!("Transaction at address: {address:?} was already paid for"); + error!("GraphEntry at address: {address:?} was already paid for"); return Err(GraphError::AlreadyExists(address)); } }; @@ -90,7 +91,7 @@ impl Client { let record = Record { key: NetworkAddress::from_graph_entry_address(address).to_record_key(), value: try_serialize_record( - &(proof, &transaction), + &(proof, &entry), RecordKind::DataWithPayment(DataTypes::GraphEntry), ) .map_err(|_| GraphError::Serialization)? @@ -136,10 +137,10 @@ impl Client { Ok(()) } - /// Get the cost to create a transaction - pub async fn transaction_cost(&self, key: SecretKey) -> Result { + /// Get the cost to create a GraphEntry + pub async fn graph_entry_cost(&self, key: SecretKey) -> Result { let pk = key.public_key(); - trace!("Getting cost for transaction of {pk:?}"); + trace!("Getting cost for GraphEntry of {pk:?}"); let address = GraphEntryAddress::from_owner(pk); let xor = *address.xorname(); @@ -151,7 +152,7 @@ impl Client { .map(|quote| quote.price()) .sum::(), ); - debug!("Calculated the cost to create transaction of {pk:?} is {total_cost}"); + debug!("Calculated the cost to create GraphEntry of {pk:?} is {total_cost}"); Ok(total_cost) } } diff --git a/autonomi/tests/graph.rs b/autonomi/tests/graph.rs index 55c76679ca..18e6850cd0 100644 --- a/autonomi/tests/graph.rs +++ b/autonomi/tests/graph.rs @@ -21,28 +21,28 @@ async fn transaction_put() -> Result<()> { let key = bls::SecretKey::random(); let content = [0u8; 32]; - let transaction = GraphEntry::new(key.public_key(), vec![], content, vec![].into(), &key); + let transaction = GraphEntry::new(key.public_key(), vec![], content, vec![], &key); // estimate the cost of the transaction - let cost = client.transaction_cost(key.clone()).await?; + let cost = client.graph_entry_cost(key.clone()).await?; println!("transaction cost: {cost}"); // put the transaction - client.transaction_put(transaction.clone(), &wallet).await?; + client.graph_entry_put(transaction.clone(), &wallet).await?; println!("transaction put 1"); // wait for the transaction to be replicated tokio::time::sleep(tokio::time::Duration::from_secs(5)).await; // check that the transaction is stored - let txs = client.transaction_get(transaction.address()).await?; + let txs = client.graph_entry_get(transaction.address()).await?; assert_eq!(txs, vec![transaction.clone()]); println!("transaction got 1"); // try put another transaction with the same address let content2 = [1u8; 32]; - let transaction2 = GraphEntry::new(key.public_key(), vec![], content2, vec![].into(), &key); - let res = client.transaction_put(transaction2.clone(), &wallet).await; + let transaction2 = GraphEntry::new(key.public_key(), vec![], content2, vec![], &key); + let res = client.graph_entry_put(transaction2.clone(), &wallet).await; assert!(matches!( res, diff --git a/docs/online-documentation/api/autonomi-client/README.md b/docs/online-documentation/api/autonomi-client/README.md index 8cce40941b..d3b2f11dde 100644 --- a/docs/online-documentation/api/autonomi-client/README.md +++ b/docs/online-documentation/api/autonomi-client/README.md @@ -186,32 +186,32 @@ Mutable references with version tracking: println!("Version: {}", metadata.version); ``` -### 3. LinkedList +### 3. GraphEntry -Decentralized DAG structures for transaction chains: +Decentralized Graph structures for linked data: === "Node.js" ```typescript - import { LinkedList } from 'autonomi'; + import { GraphEntry } from 'autonomi'; - // Create a new linked list - const list = await client.createLinkedList(); + // Create a new graph + const entry = await client.createGraphEntry(); // Append items - await client.appendToList(list.address, item1); - await client.appendToList(list.address, item2); + await client.appendToGraph(entry.address, item1); + await client.appendToGraph(entry.address, item2); - // Read list contents - const items = await client.getList(list.address); + // Read graph contents + const items = await client.getGraph(entry.address); - // Get list history - const history = await client.getListHistory(list.address); + // Get graph history + const history = await client.getGraphHistory(entry.address); for (const entry of history) { console.log(`Version ${entry.version}: ${entry.data}`); } // Check for forks - const forks = await client.detectForks(list.address); + const forks = await client.detectForks(entry.address); if (!forks) { console.log('No forks detected'); } else { @@ -221,57 +221,43 @@ Decentralized DAG structures for transaction chains: === "Python" ```python - from autonomi import LinkedList + from autonomi import GraphEntry - # Create a new linked list - list = client.create_linked_list() + # Create a new graph + entry = client.create_graph_entry() # Append items - client.append_to_list(list.address, item1) - client.append_to_list(list.address, item2) + client.append_to_graph(entry.address, item1) + client.append_to_graph(entry.address, item2) # Read list contents - items = client.get_list(list.address) + items = client.get_graph(entry.address) - # Get list history - history = client.get_list_history(list.address) + # Get graph history + history = client.get_graph_history(entry.address) for entry in history: print(f"Version {entry.version}: {entry.data}") - - # Check for forks - forks = client.detect_forks(list.address) - if not forks: - print("No forks detected") - else: - handle_forks(forks.branches) ``` === "Rust" ```rust - use autonomi::LinkedList; + use autonomi::GraphEntry; - // Create a new linked list - let list = client.create_linked_list().await?; + // Create a new graph + let entry = client.create_graph_entry().await?; // Append items - client.append_to_list(list.address(), item1).await?; - client.append_to_list(list.address(), item2).await?; + client.append_to_graph(entry.address(), item1).await?; + client.append_to_graph(entry.address(), item2).await?; - // Read list contents - let items = client.get_list(list.address()).await?; + // Read graph contents + let items = client.get_graph(entry.address()).await?; - // Get list history - let history = client.get_list_history(list.address()).await?; + // Get graph history + let history = client.get_graph_history(entry.address()).await?; for entry in history { println!("Version {}: {:?}", entry.version, entry.data); } - - // Check for forks - let forks = client.detect_forks(list.address()).await?; - match forks { - Fork::None => println!("No forks detected"), - Fork::Detected(branches) => handle_forks(branches), - } ``` ### 4. ScratchPad @@ -467,7 +453,7 @@ Each language provides appropriate error handling mechanisms: === "Rust" ```rust - use autonomi::error::{ChunkError, PointerError, ListError, ScratchPadError}; + use autonomi::error::{ChunkError, PointerError, GraphError, ScratchPadError}; // Handle chunk operations match client.get_chunk(address).await { @@ -591,7 +577,7 @@ Each language provides appropriate error handling mechanisms: 1. **Data Type Selection** - Use Chunks for immutable data - Use Pointers for mutable references - - Use LinkedLists for ordered collections + - Use GraphEntrys for ordered collections - Use ScratchPads for temporary data 2. **Error Handling** diff --git a/docs/online-documentation/api/autonomi-client/data_types.md b/docs/online-documentation/api/autonomi-client/data_types.md index c43c47ca53..3b9cd4c660 100644 --- a/docs/online-documentation/api/autonomi-client/data_types.md +++ b/docs/online-documentation/api/autonomi-client/data_types.md @@ -127,13 +127,13 @@ A mutable reference to data in the network. } ``` -## LinkedList +## GraphEntry -A decentralized DAG structure for ordered data. +A decentralized Graph structure for linked data. === "Node.js" ```typescript - interface LinkedList { + interface GraphEntry { readonly address: Address; readonly length: number; append(item: T): void; @@ -144,7 +144,7 @@ A decentralized DAG structure for ordered data. === "Python" ```python - class LinkedList(Generic[T]): + class GraphEntry(Generic[T]): @property def address(self) -> Address: ... @property @@ -156,12 +156,12 @@ A decentralized DAG structure for ordered data. === "Rust" ```rust - pub struct LinkedList { + pub struct GraphEntry { pub address: Address, pub length: usize, } - impl LinkedList { + impl GraphEntry { pub fn append(&mut self, item: T); pub fn get(&self, index: usize) -> Option<&T>; pub fn to_vec(&self) -> Vec; diff --git a/docs/online-documentation/api/autonomi-client/errors.md b/docs/online-documentation/api/autonomi-client/errors.md index 965c99eca9..94ab492a7e 100644 --- a/docs/online-documentation/api/autonomi-client/errors.md +++ b/docs/online-documentation/api/autonomi-client/errors.md @@ -113,56 +113,6 @@ Errors related to pointer operations. } ``` -### ListError - -Errors related to linked list operations. - -=== "Node.js" - ```typescript - class ListError extends Error { - static NotFound: typeof ListError; - static InvalidIndex: typeof ListError; - static ForkDetected: typeof ListError; - } - - try { - const item = await client.getListItem(address, index); - } catch (error) { - if (error instanceof ListError.InvalidIndex) { - // Handle invalid index - } - } - ``` - -=== "Python" - ```python - class ListError(Exception): - class NotFound(ListError): pass - class InvalidIndex(ListError): pass - class ForkDetected(ListError): pass - - try: - item = client.get_list_item(address, index) - except ListError.InvalidIndex: - # Handle invalid index - pass - ``` - -=== "Rust" - ```rust - pub enum ListError { - NotFound, - InvalidIndex, - ForkDetected, - } - - match client.get_list_item(address, index).await { - Ok(item) => { /* Process item */ } - Err(ListError::InvalidIndex) => { /* Handle invalid index */ } - Err(e) => { /* Handle other errors */ } - } - ``` - ## Error Handling Patterns ### Retry Logic diff --git a/docs/online-documentation/api/index.md b/docs/online-documentation/api/index.md index 1c0592f224..670862ecf9 100644 --- a/docs/online-documentation/api/index.md +++ b/docs/online-documentation/api/index.md @@ -8,7 +8,7 @@ The [Autonomi Client API](autonomi-client/README.md) is the core library for int - Data storage and retrieval - Pointer management -- Linked list operations +- Graph operations - File system operations - Error handling diff --git a/docs/online-documentation/guides/client_modes.md b/docs/online-documentation/guides/client_modes.md index 6cf3360727..4339cf2c62 100644 --- a/docs/online-documentation/guides/client_modes.md +++ b/docs/online-documentation/guides/client_modes.md @@ -43,7 +43,7 @@ const client = await Client.connect({ // Read operations const data = await client.dataGetPublic(address); -const list = await client.linkedListGet(listAddress); +const list = await client.GraphEntryGet(listAddress); ``` ### Python @@ -61,7 +61,7 @@ file = client.get_file(file_map, "output.txt") ## Upgrading to Read-Write Mode -You can upgrade a read-only client to read-write mode by adding a wallet. This enables write operations like storing data or updating linked lists. +You can upgrade a read-only client to read-write mode by adding a wallet. This enables write operations like storing data or updating graphs. ### Rust @@ -127,7 +127,7 @@ address = client.store_bytes(b"Hello World") The following operations require a wallet (read-write mode): - Storing public data (`dataPutPublic`) -- Creating/updating linked lists (`linkedListPut`) +- Creating/updating graphs (`GraphEntryPut`) - Setting pointers (`pointerPut`) - Writing to vaults (`writeBytesToVault`) - Updating user data (`putUserDataToVault`) diff --git a/docs/online-documentation/guides/data_types.md b/docs/online-documentation/guides/data_types.md index 25810a307a..d9cad3859e 100644 --- a/docs/online-documentation/guides/data_types.md +++ b/docs/online-documentation/guides/data_types.md @@ -70,7 +70,7 @@ Key characteristics: 2. **Latest Version Publishing** ```rust // Point to latest version while maintaining history - let history = client.create_linked_list().await?; + let history = client.create_graph_entry().await?; let latest = client.create_pointer(history.address()).await?; ``` @@ -81,62 +81,37 @@ Key characteristics: let redirect_pointer = client.create_pointer(data_pointer.address()).await?; ``` -### 3. LinkedList +### 3. GraphEntry -LinkedLists in Autonomi are powerful structures that can form transaction chains or decentralized Directed Acyclic Graphs (DAGs) on the network. They provide both historical tracking and CRDT-like properties. +Graphs in Autonomi are powerful structures of connected data on the network. They provide both historical tracking and CRDT-like properties. ```rust -// Create a new linked list -let list = client.create_linked_list().await?; - -// Append items to create history -client.append_to_list(list.address(), item1).await?; -client.append_to_list(list.address(), item2).await?; - -// Read list contents including history -let items = client.get_list(list.address()).await?; - -// Check for forks -let forks = client.detect_forks(list.address()).await?; +// Create a new graph entry, signed with a secret key +let graph_content = [42u8; 32]; // 32 bytes of content +let graph_entry = GraphEntry::new( + public_key, // Graph entry address and owner + vec![parent_pks], // Parent graph entries + graph_content, // 32 bytes graph content + vec![], // Optional outputs (links to other graph entries) + &secret_key // Secret key for signing +); + +// Calculate the cost to create a graph entry +let cost = client.graph_entry_cost(secret_key).await?; + +// Store the entry in the network +client.graph_entry_put(graph_entry, &wallet).await?; + +// Retrieve the entry from the network +let retrieved_entry = client.graph_entry_get(graph_entry.address()).await?; ``` Key characteristics: -- Decentralized DAG structure -- Fork detection and handling -- Transaction chain support +- Decentralized Graph structure +- Each entry is signed by a unique key (sk) and addressed at that key (pk) - CRDT-like conflict resolution -- Version history tracking -- Support for value transfer (cryptocurrency-like) - -#### DAG Properties -1. **Fork Detection** - ```rust - // Detect and handle forks in the list - match client.detect_forks(list.address()).await? { - Fork::None => proceed_with_updates(), - Fork::Detected(branches) => resolve_conflict(branches), - } - ``` - -2. **Transaction Chains** - ```rust - // Create a transaction chain - let transaction = Transaction { - previous: Some(last_tx_hash), - amount: 100, - recipient: address, - }; - client.append_to_list(chain.address(), transaction).await?; - ``` - -3. **History Tracking** - ```rust - // Get full history of changes - let history = client.get_list_history(list.address()).await?; - for entry in history { - println!("Version {}: {:?}", entry.version, entry.data); - } - ``` +- Graph Traversal +- Can be used for value transfer (cryptocurrency-like) ### 4. ScratchPad @@ -250,9 +225,9 @@ client.get_file(file_map, "output.dat").await?; #### Directories -Directories use linked lists and pointers to maintain a mutable collection of entries: +Directories use graphs and pointers to maintain a mutable collection of entries: -- LinkedList stores directory entries +- GraphEntry stores directory entries - Pointer maintains current directory state - Hierarchical structure support @@ -281,7 +256,7 @@ let tree = client.list_recursive(root.address()).await?; - Version tracking built-in 3. **Collections** - - Use linked lists for ordered data + - Use graphs for linked data - Efficient for append operations - Good for logs and sequences @@ -295,7 +270,7 @@ let tree = client.list_recursive(root.address()).await?; 1. **Choose the Right Type** - Chunks for immutable data - Pointers for mutable references - - LinkedLists for collections + - GraphEntry for collections - ScratchPads for temporary storage 2. **Efficient Data Structures** @@ -341,5 +316,5 @@ let tree = client.list_recursive(root.address()).await?; - Solution: Use version checking 3. **Performance** - - LinkedList traversal costs + - GraphEntry traversal costs - Solution: Use appropriate data structures for access patterns diff --git a/docs/online-documentation/guides/testing_guide.md b/docs/online-documentation/guides/testing_guide.md index 9ab95321ba..7a78d86e58 100644 --- a/docs/online-documentation/guides/testing_guide.md +++ b/docs/online-documentation/guides/testing_guide.md @@ -27,21 +27,21 @@ cargo install cargo-test ### Node.js Example ```typescript -import { Client, LinkedList } from '@autonomi/client'; +import { Client, GraphEntry } from '@autonomi/client'; -describe('LinkedList Operations', () => { +describe('GraphEntry Operations', () => { let client: Client; beforeEach(() => { client = new Client(); }); - test('should store and retrieve linked list', async () => { - const list = new LinkedList(); + test('should store and retrieve graph', async () => { + const list = new GraphEntry(); list.append("test data"); - const address = await client.linkedListPut(list); - const retrieved = await client.linkedListGet(address); + const address = await client.GraphEntryPut(list); + const retrieved = await client.GraphEntryGet(address); expect(retrieved.toString()).toBe("test data"); }); @@ -52,18 +52,18 @@ describe('LinkedList Operations', () => { ```python import pytest -from autonomi import Client, LinkedList +from autonomi import Client, GraphEntry @pytest.mark.asyncio -async def test_linked_list_operations(): +async def test_graph_entry_operations(): client = Client() # Create and store list - list_obj = LinkedList() - list_obj.append("test data") + entry_obj = GraphEntry() + entry_obj.append("test data") - address = await client.linked_list_put(list_obj) - retrieved = await client.linked_list_get(address) + address = await client.graph_entry_put(entry_obj) + retrieved = await client.graph_entry_get(address) assert str(retrieved) == "test data" ``` @@ -76,14 +76,14 @@ mod tests { use super::*; #[test] - fn test_linked_list_operations() { + fn test_graph_entry_operations() { let client = Client::new(); - let mut list = LinkedList::new(); - list.append("test data"); - - let address = client.linked_list_put(&list).unwrap(); - let retrieved = client.linked_list_get(&address).unwrap(); + let mut entry = GraphEntry::new(); + entry.append("test data"); + + let address = client.graph_entry_put(&entry).unwrap(); + let retrieved = client.graph_entry_get(&address).unwrap(); assert_eq!(retrieved.to_string(), "test data"); } diff --git a/nodejs/README.md b/nodejs/README.md index 9c2619b922..3eac715e8a 100644 --- a/nodejs/README.md +++ b/nodejs/README.md @@ -42,7 +42,7 @@ async function example() { - Async/await API - Support for: - Public and private data operations - - Linked Lists + - Graph - Pointers - Vaults - User data management @@ -66,12 +66,12 @@ dataPutPublic(data: Buffer, payment: PaymentOption): Promise dataGetPublic(address: string): Promise ``` -#### Linked List Operations +#### Graph Operations ```typescript -linkedListGet(address: string): Promise -linkedListPut(options: LinkedListOptions, payment: PaymentOption): Promise -linkedListCost(key: string): Promise +GarphEntryGet(address: string): Promise +GarphEntryPut(options: GarphEntryOptions, payment: PaymentOption): Promise +GarphEntryCost(key: string): Promise ``` #### Pointer Operations diff --git a/nodejs/package.json b/nodejs/package.json index 8a67efcc56..18141ca7f1 100644 --- a/nodejs/package.json +++ b/nodejs/package.json @@ -16,7 +16,7 @@ "autonomi", "client", "network", - "linked-list", + "graph", "pointer", "vault" ], diff --git a/nodejs/src/client.ts b/nodejs/src/client.ts index 7839c8bc1c..62f8322bc2 100644 --- a/nodejs/src/client.ts +++ b/nodejs/src/client.ts @@ -1,4 +1,4 @@ -import { NetworkConfig, PaymentOption, LinkedListOptions, PointerOptions, VaultOptions, UserData } from './types'; +import { NetworkConfig, PaymentOption, GarphEntryOptions, PointerOptions, VaultOptions, UserData } from './types'; export class Client { private nativeClient: any; // Will be replaced with actual native binding type @@ -23,18 +23,18 @@ export class Client { throw new Error('Not implemented'); } - // Linked List Operations - async linkedListGet(address: string): Promise { + // Graph Operations + async graphEntryGet(address: string): Promise { // TODO: Implement native binding call throw new Error('Not implemented'); } - async linkedListPut(options: LinkedListOptions, payment: PaymentOption): Promise { + async graphEntryPut(options: GarphEntryOptions, payment: PaymentOption): Promise { // TODO: Implement native binding call throw new Error('Not implemented'); } - async linkedListCost(key: string): Promise { + async graphEntryCost(key: string): Promise { // TODO: Implement native binding call throw new Error('Not implemented'); } diff --git a/nodejs/src/index.ts b/nodejs/src/index.ts index 2a09e8fb44..8849a59383 100644 --- a/nodejs/src/index.ts +++ b/nodejs/src/index.ts @@ -1,6 +1,6 @@ export * from './client'; export * from './types'; export * from './wallet'; -export * from './linkedList'; +export * from './GarphEntry'; export * from './pointer'; export * from './vault'; \ No newline at end of file diff --git a/nodejs/src/types.ts b/nodejs/src/types.ts index 0adcbef559..254e005157 100644 --- a/nodejs/src/types.ts +++ b/nodejs/src/types.ts @@ -8,7 +8,7 @@ export interface PaymentOption { wallet: string; } -export interface LinkedListOptions { +export interface GarphEntryOptions { owner: PublicKey; counter: number; target: string; diff --git a/nodejs/tests/client.test.ts b/nodejs/tests/client.test.ts index ccacd2a2bd..3f856e11ea 100644 --- a/nodejs/tests/client.test.ts +++ b/nodejs/tests/client.test.ts @@ -7,18 +7,18 @@ describe('Client', () => { }); }); - describe('linkedListOperations', () => { - it('should throw not implemented error for linkedListGet', async () => { + describe('GarphEntryOperations', () => { + it('should throw not implemented error for GarphEntryGet', async () => { const client = await Client.connect({ peers: [] }).catch(() => null); if (!client) return; - await expect(client.linkedListGet('address')).rejects.toThrow('Not implemented'); + await expect(client.GarphEntryGet('address')).rejects.toThrow('Not implemented'); }); - it('should throw not implemented error for linkedListPut', async () => { + it('should throw not implemented error for GarphEntryPut', async () => { const client = await Client.connect({ peers: [] }).catch(() => null); if (!client) return; await expect( - client.linkedListPut( + client.GarphEntryPut( { owner: 'owner', counter: 0,