Skip to content

Commit

Permalink
Merge pull request #197 from skalenetwork/develop
Browse files Browse the repository at this point in the history
Develop to beta
  • Loading branch information
DmytroNazarenko committed Sep 1, 2022
2 parents 6b21837 + d429b3d commit 7480b2d
Show file tree
Hide file tree
Showing 29 changed files with 13,785 additions and 820 deletions.
3 changes: 2 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
* @dmytronazarenko @kladkogex
*.md @cstrangedk
/docs/ @skalenetwork/docowners
*.md @skalenetwork/docowners
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '12.x'
node-version: '14.x'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: |
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node: [10, 12, 14]
node: [12, 14, 16]
os: [ubuntu-latest, windows-latest]
env:
VERSION: 3.9.1-develop.4
ENDPOINT: ${{ secrets.ENDPOINT }}
USER: ${{ secrets.USER }}
SCHEME: ${{ secrets.SCHEME }}
VERSION: ${{ secrets.VERSION }}
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
SCHAIN_OWNER_PK: ${{ secrets.SCHAIN_OWNER_PK }}
PRIVATEKEY: ${{ secrets.PRIVATEKEY }}
Expand All @@ -24,6 +24,12 @@ jobs:
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Install dependencies
run: |
npm i
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ artifacts.json

# Dependency directories
node_modules/
venv/

# Idea files
.idea/
Expand All @@ -15,3 +16,4 @@ node_modules/
.eslintcache
.nyc_output
coverage

816 changes: 160 additions & 656 deletions LICENSE

Large diffs are not rendered by default.

104 changes: 98 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,27 +253,119 @@ Content `Object` for directory contains:

Reserve space for certain address in Filestorage in bytes.

- **Note**: could be called only by sChain owner
- **Note**: can be called only by ALLOCATOR_ROLE (or schain owner in v1 chains)

```javascript
filestorage.reserveSpace(ownerAddress, addressToReserve, reservedSpace, privateKey);
filestorage.reserveSpace(allocatorAddress, addressToReserve, reservedSpace, privateKey);
```

Create directory using external signing (Metamask etc):
Reserve space using external signing (Metamask etc):

```javascript
filestorage.reserveSpace(ownerAddress, addressToReserve, reservedSpace);
filestorage.reserveSpace(allocatorAddress, addressToReserve, reservedSpace);
```

##### Parameters

| Parameter | Description |
| ------------------------- | ----------------------------------------------------------- |
| `String` ownerAddress | sChain owner address |
| `String` allocatorAddress | Address with ALLOCATOR_ROLE |
| `String` addressToReserve | Address to reserve space for |
| `String` reservedSpace | Reserved space in bytes |
| `String` privateKey | _(optional)_ sChain owner private key, to sign transactions |

#### Grant allocator role

Granting allocator role to be able to reserve space in Filestorage

- **Note**: can be called only by ADMIN_ROLE (on v2+ chains)

```javascript
filestorage.grantAllocatorRole(adminAddress, allocatorAddress, adminPrivateKey);
```

Grant allocator role using external signing (Metamask etc):

```javascript
filestorage.grantAllocatorRole(adminAddress, allocatorAddress, adminPrivateKey);
```

##### Parameters

| Parameter | Description |
| ------------------------- | ----------------------------------------------------------- |
| `String` adminAddress | DEFAULT_ADMIN address |
| `String` allocatorAddress | Address to grant role for |
| `String` adminPrivateKey | _(optional)_ DEFAULT_ADMIN private key, to sign transactions|

#### Get reserved space

Get information about reserved space for account in bytes.

```javascript
filestorage.getReservedSpace(address);
```

##### Parameters

| Parameter | Description |
| ------------------------- | ----------------------------------------------------------- |
| `String` address | Account address |

##### Returns

| Parameter | Description |
| ---------------------- | ------------------------------------------------ |
| `Number` reservedSpace | Reserved space in bytes |

#### Get occupied space

Get information about occupied (actually used) space for account in bytes.

```javascript
filestorage.getOccupiedSpace(address);
```

##### Parameters

| Parameter | Description |
| ------------------------- | ----------------------------------------------------------- |
| `String` address | Account address |

##### Returns

| Parameter | Description |
| ---------------------- | ------------------------------------------------ |
| `Number` occupiedSpace | Occupied space in bytes |

#### Get total space in Filestorage

Get information about total space in Filestorage in bytes.

```javascript
filestorage.getTotalSpace();
```

##### Returns

| Parameter | Description |
| ---------------------- | ------------------------------------------------ |
| `Number` space | Total space in Filestorage in bytes |

#### Get total reserved space

Get information about total reserved space (sum of all reserved spaces) in bytes.

```javascript
filestorage.getTotalReservedSpace();
```

##### Returns

| Parameter | Description |
| ---------------------- | ------------------------------------------------ |
| `Number` reservedSpace | Total reserved space in bytes |

## Development

### Install
Expand Down Expand Up @@ -380,4 +472,4 @@ Example:

![GitHub](https://img.shields.io/github/license/skalenetwork/filestorage.js.svg)

All contributions are made under the [GNU Affero General Public License v3](https://www.gnu.org/licenses/agpl-3.0.en.html). See [LICENSE](LICENSE).
All contributions are made under the [GNU Lesser General Public License v3](https://www.gnu.org/licenses/lgpl-3.0.en.html). See [LICENSE](LICENSE).
92 changes: 39 additions & 53 deletions dist/filestorage.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 7480b2d

Please sign in to comment.