-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6725e1a
commit 8134b7d
Showing
23 changed files
with
9,556 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: CI | ||
|
||
on: [push, pull_request ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ${{ matrix.operating-system }} | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
operating-system: [ubuntu-latest] | ||
node-version: [16.x] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Install node ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
cache: 'yarn' | ||
node-version: ${{ matrix.node-version }} | ||
- name: Install dependencies | ||
run: yarn install --pure-lockfile | ||
|
||
- name: Build of common | ||
run: cd packages/common && yarn run build | ||
- name: Run Tests of common | ||
run: cd packages/common && yarn run test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Covers JetBrains IDEs | ||
.idea/ | ||
# Project | ||
node_modules | ||
dist | ||
coverage | ||
.env | ||
.cache | ||
.DS_Store | ||
*.tgz | ||
*.log | ||
.turbo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 BOSAGORA Foundation | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "del-osx", | ||
"version": "1.0.0", | ||
"description": "JS SDK for links e-mail and wallet addresses", | ||
"repository": "https://github.com/bosagora/del-sdk", | ||
"author": "BOSagora Foundation", | ||
"private": true, | ||
"workspaces": { | ||
"packages": [ | ||
"packages/*" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
{ | ||
"name": "del-sdk-client", | ||
"version": "1.0.0", | ||
"author": "BOSagora Foundation", | ||
"license": "MIT", | ||
"main": "dist/index.js", | ||
"module": "dist/sdk-client.esm.js", | ||
"typings": "dist/index.d.ts", | ||
"files": [ | ||
"dist" | ||
], | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"engines": { | ||
"node": ">=16" | ||
}, | ||
"scripts": { | ||
"start": "tsdx watch", | ||
"build": "tsdx build", | ||
"test": "TESTING=true tsdx test --verbose --runInBand", | ||
"lint": "tsdx lint", | ||
"prepare": "tsdx build", | ||
"size": "size-limit", | ||
"analyze": "size-limit --why", | ||
"clean": "rm -Rf .turbo dist", | ||
"examples": "node ./scripts/generate-examples-md.js ./examples ./examples.md" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "tsdx lint --fix" | ||
} | ||
}, | ||
"prettier": { | ||
"printWidth": 80, | ||
"semi": true, | ||
"singleQuote": false, | ||
"trailingComma": "es5" | ||
}, | ||
"size-limit": [ | ||
{ | ||
"path": "dist/sdk-client.cjs.production.min.js", | ||
"limit": "10 KB" | ||
}, | ||
{ | ||
"path": "dist/sdk-client.esm.js", | ||
"limit": "10 KB" | ||
} | ||
], | ||
"devDependencies": { | ||
"@size-limit/preset-small-lib": "^7.0.8", | ||
"@types/jest": "^29.0.3", | ||
"ganache": "^7.5.0", | ||
"glob": "^8.0.3", | ||
"husky": "^7.0.4", | ||
"size-limit": "^7.0.8", | ||
"tsdx": "^0.14.1", | ||
"tslib": "^2.3.1", | ||
"typescript": "^4.6.2" | ||
}, | ||
"dependencies": { | ||
"@ethersproject/abstract-signer": "^5.7.0", | ||
"@ethersproject/bignumber": "^5.7.0", | ||
"@ethersproject/constants": "^5.7.0", | ||
"@ethersproject/contracts": "^5.7.0", | ||
"@ethersproject/networks": "npm:boa-networks@^5.7.2", | ||
"@ethersproject/providers": "^5.7.0", | ||
"@ethersproject/wallet": "^5.7.0", | ||
"del-osx-lib": "^1.0.6", | ||
"del-sdk-common": "^1.0.0", | ||
"dotenv": "^16.3.1" | ||
}, | ||
"jest": { | ||
"testEnvironment": "../../test-environment.js", | ||
"testEnvironmentOptions": { | ||
"url" : "http://localhost:7070" | ||
}, | ||
"testTimeout": 120000 | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
# Aragon JS SDK (common) changelog | ||
|
||
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). | ||
|
||
<!-- | ||
TEMPLATE: | ||
(Leave "## [UPCOMING]" first and describe the changes below it) | ||
### Added | ||
- Feature 1, 2, 3 | ||
### Changed | ||
- Change 1, 2, 3 | ||
### Fixed | ||
- Fix 1, 2, 3 | ||
--> | ||
## UPCOMING | ||
## 1.1.1 | ||
- Adds new error `DataDecodingError` | ||
- Adds new error `IpfsError` | ||
## 1.1.0 | ||
### Added | ||
- Adds `PluginInstallationPreparationError` | ||
- `runAndRetry` function | ||
### Removes | ||
- removed `random.ts` | ||
## 1.0.0 | ||
|
||
Release | ||
|
||
## 0.12.0-beta | ||
### Added | ||
- `getCompactProposalId` and `getExtendedProposalId` functions | ||
## 0.11.0-beta | ||
|
||
Release candidate 1 | ||
|
||
### Changed | ||
- Rename `EnsureAllowanceError` to `UpdateAllowanceError` | ||
- Changes `encodeProposalId` and `decodeProposalId` function to support the new format | ||
|
||
### Adds | ||
- Adds `isProposalId()` function to the package | ||
- Adds `encodeProposalId(addr, nonce)` and `decodeProposalId(pid)` | ||
- Adds `UnsupportedNetworkError` error type | ||
|
||
## 0.10.1-beta | ||
- Fix `hextoBytes` throwing an error when `0x` is the input | ||
|
||
## 0.10.0-beta | ||
- Adds new error `EnsureAllowanceError` | ||
- Adds new error `InvalidPrecisionError` | ||
- Adds `boolArrayToBitmap` and `bitmapToBoolArray` | ||
|
||
## 0.9.1-alpha | ||
On 2022-12-13 15:57:38 | ||
### Fixed | ||
- IPFS uri resolving | ||
|
||
## [0.9.0-alpha] | ||
### Added | ||
- Adds new error `MissingExecPermissionError` | ||
|
||
### Fixed | ||
- Fix helper function to resolve IPFS CIDS | ||
|
||
## [0.8.0-alpha] | ||
### Added | ||
- Helper function to resolve IPFS CID's | ||
|
||
## [0.7.0-alpha] | ||
### Added | ||
- New error type for failed pinning on IPFS | ||
|
||
## [0.6.0-alpha] | ||
### Added | ||
- New error types | ||
## 0.5.0-alpha | ||
On 2022-09-22 11:10:24 | ||
### Added | ||
- New error types | ||
## 0.4.0-alpha | ||
On 2022-09-21 14:49:57 | ||
### Added | ||
- New error types | ||
## 0.3.0-alpha | ||
On 2022-09-20 12:08:47 | ||
### Added | ||
- New error types | ||
### Fixed | ||
- `Buffer` being used not compatible with web environments | ||
### Updated | ||
- Renaming `bufferToHexString` to `bytesToHex` | ||
- Renaming `hexStringToBuffer` to `hexToBytes` | ||
- Version bump | ||
|
||
## 0.0.2-alpha | ||
|
||
### Added | ||
- Github actions automation to deploy this package | ||
- `Random.getFloat()` | ||
|
||
## 0.0.1-alpha | ||
|
||
- Initial version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
# DMS SDK Common | ||
|
||
del-sdk-common provides general purpose components to use across the entire Aragon SDK: | ||
- Interfaces | ||
- Constants | ||
- Types | ||
- Enumerations | ||
- Helpers | ||
|
||
# Installation | ||
|
||
Use [npm](https://www.npmjs.com/) or [yarn](https://yarnpkg.com/) to install | ||
del-sdk-common. | ||
|
||
```bash | ||
npm install del-sdk-common | ||
yarn add del-sdk-common | ||
``` | ||
|
||
# Usage | ||
|
||
## Constants | ||
|
||
## Encoding | ||
|
||
### Converting buffers and hex strings | ||
|
||
```ts | ||
import { hexToBytes, bytesToHex } from "del-sdk-common"; | ||
|
||
const buff = hexToBytes("0xffffffff"); | ||
// [255, 255, 255, 255] | ||
|
||
const str0x = bytesToHex(new Uint8Array([100, 100, 100, 100, 100, 100])); | ||
// "0x646464646464" | ||
|
||
const str = bytesToHex(new Uint8Array([100, 100, 100, 100, 100, 100]), true); | ||
// "646464646464" | ||
``` | ||
|
||
### Converting between buffers and big integers | ||
|
||
```ts | ||
import { bigIntToBuffer, bigIntToLeBuffer } from "del-sdk-common"; | ||
|
||
const bi = BigInt("111122223333444455556666777788889999000011112222333344445555666677778888999900") | ||
const buff = bigIntToBuffer(bi); | ||
// Uint8Array(32) [ 245, 172, 243, 22, 170, 44, 13, 78, ..., 220 ] | ||
|
||
const buffLe = bigIntToLeBuffer(bi); | ||
// Uint8Array(32) [ 220, 67, 63, 224, 21, 50, 154, 103, ..., 245 ] | ||
``` | ||
|
||
```ts | ||
import { bufferToBigInt, bufferLeToBigInt } from "del-sdk-common"; | ||
|
||
const buff = new Uint8Array([ | ||
245, 172, 243, 22, 170, 44, 13, 78, | ||
106, 70, 70, 147, 249, 71, 137, 190, | ||
155, 21, 186, 14, 206, 88, 97, 129, | ||
103, 154, 50, 21, 224, 63, 67, 220 | ||
]); | ||
const hex = bufferToBigInt(buff); | ||
// 111122223333444455556666777788889999000011112222333344445555666677778888999900n | ||
|
||
const buffLe = new Uint8Array([ | ||
220, 67, 63, 224, 21, 50, 154, 103, | ||
129, 97, 88, 206, 14, 186, 21, 155, | ||
190, 137, 71, 249, 147, 70, 70, 106, | ||
78, 13, 44, 170, 22, 243, 172, 245 | ||
]); | ||
const hex = bufferLeToBigInt(buffLe); | ||
// 111122223333444455556666777788889999000011112222333344445555666677778888999900n | ||
``` | ||
|
||
### Percent ratios stored on-chain | ||
|
||
Encodes ratio values between 0 and 1 translated into an integer range with the given digit precision | ||
|
||
```ts | ||
import { encodeRatio, decodeRatio } from "del-sdk-common"; | ||
|
||
let digits = 1 | ||
encodeRatio(0.5, digits) // 5 | ||
encodeRatio(0.53625, digits) // 5 | ||
encodeRatio(0.57625, digits) // 6 | ||
|
||
digits = 4 | ||
encodeRatio(0.5, digits) // 5000 | ||
encodeRatio(0.53625, digits) // 5362 | ||
encodeRatio(0.57625, digits) // 5762 | ||
``` | ||
|
||
### Hex prefix guards | ||
|
||
```ts | ||
import { strip0x, ensure0x } from "del-sdk-common"; | ||
|
||
strip0x("1234") | ||
// "1234" | ||
strip0x("0x1234") | ||
// "1234" | ||
|
||
ensure0x("1234") | ||
// "0x1234" | ||
ensure0x("0x1234") | ||
// "0x1234" | ||
``` | ||
|
||
### Proposal ID's | ||
|
||
For nonce based proposal ID's | ||
|
||
```ts | ||
import { encodeProposalId, decodeProposalId } from "del-sdk-common"; | ||
|
||
encodeProposalId(pluginAddr, nonce) | ||
// 0x1234567890123456789012345678901234567890_0x7 | ||
|
||
decodeProposalId("0x1234567890123456789012345678901234567890_0x7") | ||
// { pluginAddress: "0x12345...", nonce: 7 } | ||
|
||
``` | ||
|
||
## Errors | ||
|
||
## Promises | ||
|
||
## Types |
Oops, something went wrong.