Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update develop from master #13

Merged
merged 7 commits into from
Jan 10, 2024
Merged
Prev Previous commit
Next Next commit
Fix all code sample formatting
  • Loading branch information
Eugene Luzgin committed Jun 17, 2020
commit 0929ef97df78232a3b57e555034a78c97d71a596
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,29 @@ Make sure to install typescript by running, this command in terminal:
# Using the SDK

# Import if installing manually
```
const { Fio, Ecc } = require('fiojs');

```
# Import if using NPM package manager
```
const { Fio, Ecc } = require('@fioprotocol/fiojs');

```
# Errors Installing?
if you don’t have tsc, install it, by navigating to terminal:
```
npm install -g typescript

```
// Include textDecoder and textEncoder when using in Node, React Native, IE11 or Edge Browsers.
```
const { TextEncoder, TextDecoder } = require('util'); // node only; native TextEncoder/Decoder
const { TextEncoder, TextDecoder } = require('text-encoding'); // React Native, IE11, and Edge Browsers only

```
# How to Test
The mock tests run under `npm run test`

# prepareTransaction
Client-side serialization and signing. It is recommended that the FIO TypeScript SDK is used for FIO API calls. But, instead, if you plan to use external RPC code. This is example RPC code, for use outside of the `Fio` JS Library instance:

```
info = await rpc.get_info();
blockInfo = await rpc.get_block(info.last_irreversible_block_num);
currentDate = new Date();
Expand Down Expand Up @@ -102,16 +106,16 @@ if (json.processed && json.processed.except) {
}

expect(Object.keys(json)).toContain('transaction_id');

```
# accountHash
Hashes public key to an on-chain Fio account name.

```
const accountHash = Fio.accountHash('FIO7bxrQUTbQ4mqcoefhWPz1aFieN4fA9RQAiozRz7FrUChHZ7Rb8');
expect(accountHash).toEqual('5kmx4qbqlpld');

```
# createSharedCipher
The shared cipher class contains a secret used to encrypt and decrypt messages. For example, Alice sends a new_funds_request to Bob. In the `new_funds_request` there is a `content` field. The `content` field is encrypted by Alice and decrypted by Bob.

```
newFundsContent = {
payee_public_address: 'purse@alice',
amount: '1.75',
Expand All @@ -134,7 +138,7 @@ cipherAliceHex = cipherAlice.encrypt('new_funds_content', newFundsContent);
cipherBob = Fio.createSharedCipher({privateKey: privateKeyBob, publicKey: publicKeyAlice, textEncoder: new TextEncoder(), textDecoder: new TextDecoder()});
newFundsContentBob = cipherBob.decrypt('new_funds_content', cipherAliceHex);
expect(newFundsContentBob).toEqual(newFundsContent);

```
See `src/encryption-fio.abi.json` for other message types like `new_funds_content`.

# Message Encryption
Expand Down