Skip to content

Commit

Permalink
add sdk docu
Browse files Browse the repository at this point in the history
  • Loading branch information
Platinium authored and Platinium committed Aug 11, 2024
1 parent fc89268 commit 3ee3cdd
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 3 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ The repository needs to have its workflow permissions set to `read and write`, i
- [ ] [contract-template.md](./docs/references/contract-template.md)
- [X] [account-types.md](./docs/references/account-types.md)
- [X] [examples.md](./docs/references/examples.md)
- [ ] [sdk.md](./docs/references/sdk.md)
- [X] [sdk.md](./docs/references/sdk.md)
- [X] [first-contract.md](./docs/tutorials/first-contract.md)
- [X] [invoke-contract.md](./docs/tutorials/invoke-contract.md)


### Reminders

- when contract deployment supports lite accounts, add to the documentation
- when contract deployment supports lite accounts, add to the documentation
- move api documentation to the code a la js/ typedoc and just link to it, only manually add documentation to the doc here that describes how those components might be used (examples) or in conjunction
6 changes: 5 additions & 1 deletion docs/discussions/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,8 @@ As for a formal docs site, we don't have that at the moment.

However, you can checkout the AssemblyScript docs for usage of the smart contract language. It is very similar to TypeScript. Then, everything you need to interface with the VSC chain state is available in the @vsc.eco/sdk npm package.

If you have any concrete suggestions about what we should include in a formal documentation site, please let us know.
If you have any concrete suggestions about what we should include in a formal documentation site, please let us know.

## Why is the documentation structured in this way?

The documentation approach is based on the _Diátaxis_ principle. You can watch a summary about it [here](https://www.youtube.com/watch?v=t4vKPhjcMZg).
2 changes: 2 additions & 0 deletions docs/references/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ The VSC clients are libraries that serve a set of wrappers and abstraction layer

## VSC javascript client

The API documentation can be found [here](https://vsc-eco.github.io/client/).

### Installation

The [VSC javascript client](https://github.com/vsc-eco/client) can be installed via [_npm_](https://www.npmjs.com/package/@vsc.eco/client).
Expand Down
47 changes: 47 additions & 0 deletions docs/references/sdk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# SDK

The VSC sdks are libraries that abstract away various functionalities that are useful in the context of coding a VSC smart contract.

> Nice to know: They also serve access to e.g. the smart contract's database layer by exposing namespaces and interfaces. At the stage of the contract execution, invocations of such interfaces are translated to generalized calls of the VSC node. Thereby ensuring that those functionalities are equal regardless of the language implementation of the SDK.
## VSC javascript (assemblyscript) sdk

The [VSC javascript sdk](https://github.com/vsc-eco/sdk) is a library that is compatible with assemblyscript projects, thereby it can be used directly in the [contract template]([email protected]:vsc-eco/contract-template.git). It is included in the project by default.

The API documentation can be found [here](https://vsc-eco.github.io/sdk/).

### Example usage

Import the library.

```typescript
import { db, console } from "@vsc.eco/sdk/assembly";
```

Execute a function.

```typescript
export function mySampleMethod(payload: String): string {
...
db.setObject("key-1", payload);
const val = db.getObject("key-1");
console.log(val)
...
}
```

### Frequently used

**namespace db**
- db.setObject
- db.getObject

**namespace arrays**
- Arrays.toHexString
- Arrays.fromHexString

**namespace console**
- console.log

**no namespace**
- getEnv

0 comments on commit 3ee3cdd

Please sign in to comment.