Skip to content

Commit

Permalink
Merge pull request #1 from TIHBS/v2-rewrite-support-prepare
Browse files Browse the repository at this point in the history
Support standard 2PC4BC protocol
  • Loading branch information
ghareeb-falazi authored Sep 28, 2024
2 parents 10328ae + 63f21e4 commit 98e8e69
Show file tree
Hide file tree
Showing 25 changed files with 5,110 additions and 5,286 deletions.
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#
# SPDX-License-Identifier: Apache-2.0
#

coverage
39 changes: 39 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* SPDX-License-Identifier: Apache-2.0
*/

module.exports = {
env: {
node: true,
mocha: true,
es6: true
},
parserOptions: {
ecmaVersion: 8,
sourceType: 'script'
},
extends: "eslint:recommended",
rules: {
indent: ['error', 4],
'linebreak-style': ['error', 'unix'],
quotes: ['error', 'single'],
semi: ['error', 'always'],
'no-unused-vars': ['error', { args: 'none' }],
'no-console': 'off',
curly: 'error',
eqeqeq: 'error',
'no-throw-literal': 'error',
strict: 'error',
'no-var': 'error',
'dot-notation': 'error',
'no-tabs': 'error',
'no-trailing-spaces': 'error',
'no-use-before-define': 'error',
'no-useless-call': 'error',
'no-with': 'error',
'operator-linebreak': 'error',
yoda: 'error',
'quote-props': ['error', 'as-needed'],
'no-constant-condition': ["error", { "checkLoops": false }]
}
};
26 changes: 26 additions & 0 deletions .github/workflows/github-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: run api testing
on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
api-test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Install Dependencies
run: npm install

- name: API testing
run: npm run test
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/fabric-resource-manager.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import globals from "globals";


export default [
{files: ["**/*.js"], languageOptions: {sourceType: "commonjs"}},
{languageOptions: { globals: globals.browser }},
];
12 changes: 5 additions & 7 deletions ledger-api/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class State {
/**
* Convert object to buffer containing JSON data serialization
* Typically used before putState()ledger API
* @param {State} JSON object to serialize
* @param {JSON} object JSON object to serialize
* @return {Buffer} buffer with the data to store
*/
static serialize(object) {
Expand All @@ -43,17 +43,15 @@ class State {
* Covert serialized data to JSON object
* Typically used after getState() ledger API
* @param {Buffer} buffer to deserialize into JSON object
* @return {json} json with the data to store
* @return {JSON} json with the data to store
*/
static fromBuffer(buffer) {
let json = JSON.parse(buffer.toString('utf8'));

return json;
static jsonFromBuffer(buffer) {
return JSON.parse(buffer.toString('utf8'));
}


/**
* Join the keyParts to make a unififed string
* Join the keyParts to make a unified string
* @param {Array<string>} keyParts
*/
static makeKey(keyParts) {
Expand Down
21 changes: 11 additions & 10 deletions ledger-api/statelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,21 @@ class StateList {

async _getAllResults(iterator) {
const allResults = [];
while (true) {
const res = await iterator.next();
let res = await iterator.next();
while (!res.done) {
if (res.value) {
// if not a getHistoryForKey iterator then key is contained in res.value.key
allResults.push(State.fromBuffer(res.value.value));
}

// check to see if we have reached then end
if (res.done) {
// explicitly close the iterator
await iterator.close();
return allResults;
allResults.push(State.jsonFromBuffer(res.value.value));
}

res = await iterator.next();
}

if (iterator.close) {
iterator.close();
}

return allResults;
}

}
Expand Down
4 changes: 4 additions & 0 deletions lib/resource-manager/lock-type.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/*
* SPDX-License-Identifier: Apache-2.0
*/

/**
* @enum
*/
Expand Down
Loading

0 comments on commit 98e8e69

Please sign in to comment.