Skip to content

Commit

Permalink
feat(satp-hermes): fabric and besu bridges, wrapper contracts with on…
Browse files Browse the repository at this point in the history
…tology (hyperledger-cacti#3382)

feat(satp-hermes): added forge to compile solidity contracts

Signed-off-by: Carlos Amaro <[email protected]>
  • Loading branch information
LordKubaya committed Oct 2, 2024
1 parent 4f405c6 commit be86d7c
Show file tree
Hide file tree
Showing 76 changed files with 15,052 additions and 3,290 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"PrivacyPolicyOpts": {
"description": "identifier of the policy used to process a view",
"type": "string",
"enum": ["pruneState"],
"x-enum-varnames": ["PruneState"]
"enum": ["pruneState", "singleTransaction"],
"x-enum-varnames": ["PruneState", "SingleTransaction"]
},
"MergePolicyOpts": {
"description": "identifier of the policy used to merge views (can be none)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ export interface MergeViewsResponse {
*/

export const PrivacyPolicyOpts = {
PruneState: 'pruneState'
PruneState: 'pruneState',
SingleTransaction: 'singleTransaction'
} as const;

export type PrivacyPolicyOpts = typeof PrivacyPolicyOpts[keyof typeof PrivacyPolicyOpts];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,24 @@ export class PrivacyPolicies {
return view;
}

public singleTransaction(
view: View,
stateId: string,
transactionId: string,
): View {
const snapshot = view.getSnapshot();
snapshot.filterTransaction(stateId, transactionId);
return view;
}

public getPrivacyPolicy(opts: PrivacyPolicyOpts): IPrivacyPolicy | undefined {
switch (opts) {
case PrivacyPolicyOpts.PruneState:
return this.pruneState;
break;
case PrivacyPolicyOpts.SingleTransaction:
return this.singleTransaction;
break;
default:
return undefined;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,22 @@ export class Snapshot {
this.stateBins = stateBins;
}

public selectStates(states: string[]): void {
const stateBins: State[] = [];
for (const state of this.stateBins) {
if (states.includes(state.getId())) {
stateBins.push(state);
}
}
this.stateBins = stateBins;
}

public filterTransaction(stateId: string, transaction: string): void {
this.selectStates([stateId]);
const state = this.stateBins[0];
state.selectTransactions([transaction]);
}

public getSnapshotJson(): string {
const snapshotJson = {
id: this.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ export class State {
return this.transactions;
}

public selectTransactions(txs: string[]): void {
const transactions: Transaction[] = [];
for (const tx of this.transactions) {
if (txs.includes(tx.getId())) {
transactions.push(tx);
}
}
this.transactions = transactions;
}

public getInitialTime(): string {
if (this.transactions.length >= 1) {
return this.transactions[0].getTimeStamp();
Expand Down
1 change: 1 addition & 0 deletions packages/cactus-plugin-satp-hermes/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ src/main/typescript/generated/gateway-client/typescript-axios/.openapi-generator
src/main/typescript/generated/gateway-client/typescript-axios/api.ts
src/main/typescript/generated/gateway-client/typescript-axios/git_push.sh
src/main/typescript/generated/gateway-client/typescript-axios/.openapi-generator/FILES
src/main/typescript/fabric-contracts/satp/chaincode-typescript/.yarn/
3 changes: 3 additions & 0 deletions packages/cactus-plugin-satp-hermes/foundry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[profile.default]
solc-version = "0.8.20"
evm-version = "paris"
262 changes: 138 additions & 124 deletions packages/cactus-plugin-satp-hermes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,157 +3,171 @@
"version": "2.0.0-rc.6",
"description": "SATP-Hermes implementation of SATP.",
"customMetadata": {
"satp-draft-versions": {
"satp-core": "02",
"satp-architecture": "02",
"satp-crash": "02"
}
"satp-draft-versions": {
"satp-core": "02",
"satp-architecture": "02",
"satp-crash": "02"
}
},
"keywords": [
"Hyperledger",
"Integration",
"Interoperability",
"Blockchain",
"Distributed Ledger Technology",
"IETF",
"Secure Asset Transfer Protocol"
"Hyperledger",
"Integration",
"Interoperability",
"Blockchain",
"Distributed Ledger Technology",
"IETF",
"Secure Asset Transfer Protocol"
],
"repository": {
"type": "git",
"url": "git+https://github.com/hyperledger/cacti.git"
"type": "git",
"url": "git+https://github.com/hyperledger/cacti.git"
},
"license": "Apache-2.0",
"author": {
"name": "Hyperledger Cacti Contributors",
"email": "[email protected]",
"url": "https://www.hyperledger.org/use/cacti"
"name": "Hyperledger Cacti Contributors",
"email": "[email protected]",
"url": "https://www.hyperledger.org/use/cacti"
},
"contributors": [
{
"name": "André Augusto",
"email": "[email protected]",
"url": "https://github.com/AndreAugusto11"
},
{
"name": "Tzu-Shen, Wang",
"url": "https://github.com/jscode017"
},
{
"name": "Rafael Belchior",
"url": "https://github.com/RafaelAPB"
}
{
"name": "André Augusto",
"email": "[email protected]",
"url": "https://github.com/AndreAugusto11"
},
{
"name": "Tzu-Shen, Wang",
"url": "https://github.com/jscode017"
},
{
"name": "Rafael Belchior",
"url": "https://github.com/RafaelAPB"
},
{
"name": "Carlos Amaro",
"url": "https://github.com/LordKubaya"
}
],
"main": "dist/lib/main/typescript/index.js",
"module": "dist/lib/main/typescript/index.js",
"types": "dist/lib/main/typescript/index.d.ts",
"files": [
"dist/*"
"dist/*"
],
"scripts": {
"build": "run-p tsc codegen",
"build-proto": "buf build --path src/main/proto --verbose",
"build:dev:backend:postbuild": "mkdir -p ./dist/lib/knex && cp -r ./src/knex/* ./dist/lib/knex",
"bundle-openapi-yaml": "swagger-cli bundle ./src/main/yml/bol/openapi-blo.yml -o ./src/main/yml/bol/openapi-blo-bundled.yml -r -t yaml",
"bundle-openapi-json": "swagger-cli bundle ./src/main/yml/bol/openapi-blo.yml -o ./src/main/json/openapi-blo-bundled.json -r -t json",
"codegen": "run-p 'codegen:*'",
"codegen:openapi": "npm run generate-sdk",
"codegen:proto": "npm run generate-proto",
"generate-proto": "cd src/main/proto && buf generate --template buf.gen.yaml --config buf.yaml --verbose",
"generate-sdk": "run-p 'generate-sdk:*'",
"generate-sdk:typescript-axios-bol": "yarn bundle-openapi-yaml && yarn bundle-openapi-json && openapi-generator-cli generate -i ./src/main/yml/bol/openapi-blo-bundled.yml -g typescript-axios -o ./src/main/typescript/generated/gateway-client/typescript-axios/ --reserved-words-mappings protected=protected --enable-post-process-file",
"generate-sdk:go": "openapi-generator-cli generate -i ./src/main/yml/bol/openapi-blo-bundled.yml -g go -o ./src/main/go/generated/gateway-client --additional-properties=packageName=generated,generateInterfaces=true,packageVersion=v0.0.1,moduleName=github.com/hyperledger/cacti/packages/cactus-plugin-satp-hermes/src/main/go/generated --git-user-id hyperledger --git-repo-id cacti/packages/cactus-plugin-satp-hermes/src/main/go/generated",
"lint": "run-p 'lint:*'",
"lint:eslint": "eslint './src/**/*.{js,ts}' --quiet --fix && cspell \"*/*/src/**/*.{js,ts}\"",
"lint:oapi": "vacuum lint -d -e ./src/main/yml/bol/openapi-blo-bundled.yml",
"lint:protobuf": "buf lint --path src/main/proto --verbose",
"pretsc": "npm run generate-sdk",
"tsc": "tsc --project ./tsconfig.yml",
"watch": "tsc --build --watch"
"build": "run-p tsc codegen",
"build-proto": "buf build --path src/main/proto --verbose",
"build:dev:backend:postbuild": "mkdir -p ./dist/lib/knex && cp -r ./src/knex/* ./dist/lib/knex",
"bundle-openapi-yaml": "swagger-cli bundle ./src/main/yml/bol/openapi-blo.yml -o ./src/main/yml/bol/openapi-blo-bundled.yml -r -t yaml",
"bundle-openapi-json": "swagger-cli bundle ./src/main/yml/bol/openapi-blo.yml -o ./src/main/json/openapi-blo-bundled.json -r -t json",
"codegen": "run-p 'codegen:*'",
"codegen:openapi": "npm run generate-sdk",
"codegen:proto": "npm run generate-proto",
"codegen:abi": "yarn forge:all && abi-types-generator './src/solidity/generated/satp-wrapper.sol/SATPWrapperContract.json' --output='./src/main/typescript/generated'",
"generate-proto": "cd src/main/proto && buf generate --template buf.gen.yaml --config buf.yaml --verbose",
"generate-sdk": "run-p 'generate-sdk:*'",
"generate-sdk:typescript-axios-bol": "yarn bundle-openapi-yaml && yarn bundle-openapi-json && openapi-generator-cli generate -i ./src/main/yml/bol/openapi-blo-bundled.yml -g typescript-axios -o ./src/main/typescript/generated/gateway-client/typescript-axios/ --reserved-words-mappings protected=protected --enable-post-process-file",
"generate-sdk:go": "openapi-generator-cli generate -i ./src/main/yml/bol/openapi-blo-bundled.yml -g go -o ./src/main/go/generated/gateway-client --additional-properties=packageName=generated,generateInterfaces=true,packageVersion=v0.0.1,moduleName=github.com/hyperledger/cacti/packages/cactus-plugin-satp-hermes/src/main/go/generated --git-user-id hyperledger --git-repo-id cacti/packages/cactus-plugin-satp-hermes/src/main/go/generated",
"lint": "run-p 'lint:*'",
"lint:eslint": "eslint './src/**/*.{js,ts}' --quiet --fix && cspell \"*/*/src/**/*.{js,ts}\"",
"lint:oapi": "vacuum lint -d -e ./src/main/yml/bol/openapi-blo-bundled.yml",
"lint:protobuf": "buf lint --path src/main/proto --verbose",
"pretsc": "npm run generate-sdk",
"tsc": "tsc --project ./tsconfig.yml",
"watch": "tsc --build --watch",
"forge": "forge build ./src/solidity/*.sol --out ./src/solidity/generated",
"forge:test": "forge build ./src/test/solidity/contracts/*.sol --out ./src/test/solidity/generated",
"forge:all": "run-p 'forge' 'forge:test'"
},
"jest": {
"moduleNameMapper": {
"(.+)\\.js": "$1"
}
"moduleNameMapper": {
"(.+)\\.js": "$1"
}
},
"dependencies": {
"@connectrpc/connect": "1.5.0",
"@connectrpc/connect-express": "1.5.0",
"@connectrpc/connect-node": "1.5.0",
"@connectrpc/protoc-gen-connect-es": "1.5.0",
"@hyperledger/cactus-cmd-api-server": "2.0.0-rc.6",
"@hyperledger/cactus-common": "2.0.0-rc.6",
"@hyperledger/cactus-core": "2.0.0-rc.6",
"@hyperledger/cactus-core-api": "2.0.0-rc.6",
"@hyperledger/cactus-plugin-bungee-hermes": "2.0.0-rc.6",
"@hyperledger/cactus-plugin-keychain-memory": "2.0.0-rc.6",
"@hyperledger/cactus-plugin-ledger-connector-besu": "2.0.0-rc.6",
"@hyperledger/cactus-plugin-ledger-connector-fabric": "2.0.0-rc.6",
"@hyperledger/cactus-plugin-object-store-ipfs": "2.0.0-rc.6",
"@hyperledger/cactus-test-tooling": "2.0.0-rc.6",
"@openzeppelin/contracts": "4.4.0",
"axios": "1.7.7",
"body-parser": "1.20.3",
"class-transformer": "0.5.1",
"class-validator": "0.14.1",
"crypto-js": "4.2.0",
"express": "4.17.2",
"fabric-network": "2.2.19",
"fs-extra": "11.2.0",
"knex": "2.4.0",
"kubo-rpc-client": "3.0.1",
"secp256k1": "4.0.3",
"socket.io": "4.6.2",
"sqlite3": "5.1.5",
"swagger-ui-express": "5.0.0",
"typescript-optional": "2.0.1",
"uuid": "10.0.0",
"web3": "1.6.1",
"web3-utils": "1.6.1"
"@connectrpc/connect": "1.5.0",
"@connectrpc/connect-express": "1.5.0",
"@connectrpc/connect-node": "1.5.0",
"@connectrpc/protoc-gen-connect-es": "1.5.0",
"@foundry-rs/hardhat-forge": "^0.1.17",
"@hyperledger/cactus-cmd-api-server": "2.0.0-rc.2",
"@hyperledger/cactus-common": "2.0.0-rc.6",
"@hyperledger/cactus-core": "2.0.0-rc.6",
"@hyperledger/cactus-core-api": "2.0.0-rc.6",
"@hyperledger/cactus-plugin-bungee-hermes": "2.0.0-rc.6",
"@hyperledger/cactus-plugin-keychain-memory": "2.0.0-rc.6",
"@hyperledger/cactus-plugin-ledger-connector-besu": "2.0.0-rc.6",
"@hyperledger/cactus-plugin-ledger-connector-fabric": "2.0.0-rc.6",
"@hyperledger/cactus-plugin-object-store-ipfs": "2.0.0-rc.6",
"@hyperledger/cactus-test-tooling": "2.0.0-rc.6",
"@openzeppelin/contracts": "5.0.2",
"axios": "1.7.7",
"body-parser": "1.20.3",
"class-transformer": "0.5.1",
"class-validator": "0.14.1",
"crypto-js": "4.2.0",
"ethers": "^6.13.1",
"express": "4.17.2",
"fabric-network": "2.2.19",
"fs-extra": "11.2.0",
"hardhat": "2.22.5",
"knex": "2.4.0",
"kubo-rpc-client": "3.0.1",
"npm-run-all": "^4.1.5",
"openzeppelin-solidity": "3.4.2",
"secp256k1": "4.0.3",
"socket.io": "4.6.2",
"sqlite3": "5.1.5",
"swagger-ui-express": "5.0.0",
"typescript-optional": "2.0.1",
"uuid": "10.0.0",
"web3": "1.6.1",
"web3-utils": "1.6.1"
},
"devDependencies": {
"@apidevtools/swagger-cli": "4.0.4",
"@bufbuild/buf": "1.29.0",
"@bufbuild/protobuf": "1.7.2",
"@bufbuild/protoc-gen-es": "1.7.2",
"@quobix/vacuum": "^0.9.10",
"@types/body-parser": "1.19.4",
"@types/crypto-js": "4.0.1",
"@types/express": "4.17.21",
"@types/fs-extra": "11.0.4",
"@types/node": "18.18.2",
"@types/swagger-ui-express": "4.1.6",
"@types/tape": "4.13.4",
"@types/uuid": "10.0.0",
"body-parser": "1.20.3",
"express": "4.20.0",
"fabric-network": "2.2.20",
"kubo-rpc-client": "3.0.1",
"swagger-cli": "4.0.4",
"typescript": "5.5.2"
"@apidevtools/swagger-cli": "4.0.4",
"@bufbuild/buf": "1.29.0",
"@bufbuild/protobuf": "1.7.2",
"@bufbuild/protoc-gen-es": "1.7.2",
"@quobix/vacuum": "^0.9.10",
"@types/body-parser": "1.19.4",
"@types/crypto-js": "4.0.1",
"@types/express": "4.17.21",
"@types/fs-extra": "11.0.4",
"@types/node": "18.18.2",
"@types/swagger-ui-express": "4.1.6",
"@types/tape": "4.13.4",
"@types/uuid": "10.0.0",
"body-parser": "1.20.2",
"ethereum-abi-types-generator": "^1.3.4",
"express": "4.19.2",
"fabric-network": "2.2.20",
"kubo-rpc-client": "3.0.1",
"swagger-cli": "4.0.4",
"typescript": "5.5.2"
},
"engines": {
"node": ">=18",
"npm": ">=8"
"node": ">=18",
"npm": ">=8"
},
"publishConfig": {
"access": "public"
"access": "public"
},
"watch": {
"tsc": {
"patterns": [
"src/",
"src/*/yml/**/*"
],
"ignore": [
"src/**/generated/*"
],
"extensions": [
"ts",
"yml"
],
"quiet": true,
"verbose": false,
"runOnChangeOnly": true
}
"tsc": {
"patterns": [
"src/",
"src/*/yml/**/*"
],
"ignore": [
"src/**/generated/*"
],
"extensions": [
"ts",
"yml"
],
"quiet": true,
"verbose": false,
"runOnChangeOnly": true
}
}
}
Loading

0 comments on commit be86d7c

Please sign in to comment.