├── .gitignore ├── README.md ├── assets └── examples │ ├── vcs-1427-1.json │ ├── vcs-1427-2.json │ ├── vcs-1427-3.json │ └── vcs-1427-4.js ├── backend ├── head-sync │ ├── configs │ │ └── configs │ ├── go.mod │ ├── go.sum │ ├── helpers │ │ ├── configs.go │ │ ├── logs.go │ │ └── postgresql.go │ └── main.go ├── indexer │ ├── configs │ │ └── configs │ ├── go.mod │ ├── go.sum │ ├── helpers │ │ ├── configs.go │ │ ├── logs.go │ │ └── postgresql.go │ └── main.go ├── pinning │ ├── configs │ │ └── configs │ ├── go.mod │ ├── go.sum │ ├── helpers │ │ ├── configs.go │ │ ├── helpers.go │ │ ├── http_client.go │ │ ├── logs.go │ │ └── postgresql.go │ └── main.go ├── postgres │ ├── 01.install.sql │ ├── 02.helpers.sql │ ├── 03.01.auth-alteration-1.sql │ ├── 03.auth.sql │ ├── 04.01.head-alteration-1.sql │ ├── 04.head.sql │ ├── 05.01.scraper-alteration-1.sql │ ├── 05.02.scraper-alteration-1.sql │ ├── 05.03.scraper-alteration-1.sql │ ├── 05.scraper.sql │ ├── 06.estuary.sql │ ├── 07.pinning.sql │ ├── 08.bacalhau.sql │ ├── 09.functions.sql │ └── 10.pipelines.sql └── rest-api │ ├── api │ └── api.go │ ├── configs │ └── configs │ ├── go.mod │ ├── go.sum │ ├── internal │ ├── configs.go │ ├── helpers.go │ ├── logs.go │ └── postgresql.go │ └── main.go ├── cli ├── .env.example ├── README.md ├── assets │ ├── Virtuzone___UAE_Corporate_Tax_Guide_2023.pdf │ ├── test document.pdf │ ├── test image.jpg │ └── test.zip ├── package.json └── src │ └── examples │ ├── add_asset.js │ ├── add_asset_with_nested_assets.js │ ├── add_asset_with_nested_template.js │ ├── add_big_asset.js │ ├── add_template.js │ ├── authenticate.js │ ├── create_invalid_dag-pb.js │ ├── get_account.js │ ├── get_accounts.js │ ├── get_asset.js │ ├── get_raw_data.js │ ├── get_template.js │ ├── search.js │ ├── search_assets.js │ ├── search_templates.js │ ├── serialize_dag_cbor.js │ └── sign_cid.js ├── client ├── decarbonize.travel │ ├── .babelrc │ ├── .env.example │ ├── LICENSE │ ├── README.md │ ├── assets │ │ ├── Brave-logo-color-RGB.svg │ │ ├── metamask-fox.svg │ │ ├── unverified.png │ │ └── verified.png │ ├── package.json │ ├── public │ │ └── index.html │ ├── src │ │ ├── components │ │ │ ├── asset │ │ │ │ └── Asset.vue │ │ │ ├── helpers │ │ │ │ ├── FormElements.vue │ │ │ │ ├── Header.vue │ │ │ │ ├── JsonEditor.vue │ │ │ │ └── LoadingBlocker.vue │ │ │ └── template │ │ │ │ └── Template.vue │ │ ├── fonts │ │ │ └── OpenSans │ │ │ │ ├── OpenSans-Bold.ttf │ │ │ │ ├── OpenSans-BoldItalic.ttf │ │ │ │ ├── OpenSans-ExtraBold.ttf │ │ │ │ ├── OpenSans-ExtraBoldItalic.ttf │ │ │ │ ├── OpenSans-Italic.ttf │ │ │ │ ├── OpenSans-Light.ttf │ │ │ │ ├── OpenSans-LightItalic.ttf │ │ │ │ ├── OpenSans-Medium.ttf │ │ │ │ ├── OpenSans-MediumItalic.ttf │ │ │ │ ├── OpenSans-Regular.ttf │ │ │ │ ├── OpenSans-SemiBold.ttf │ │ │ │ ├── OpenSans-SemiBoldItalic.ttf │ │ │ │ └── font.scss │ │ ├── js │ │ │ ├── asset │ │ │ │ └── asset.js │ │ │ ├── helpers │ │ │ │ ├── form-elements.js │ │ │ │ ├── header.js │ │ │ │ ├── json-editor.js │ │ │ │ └── loading-blocker.js │ │ │ ├── router.js │ │ │ └── template │ │ │ │ └── template.js │ │ ├── locales │ │ │ └── en_GB.js │ │ ├── mixins │ │ │ ├── authentication │ │ │ │ └── authentication.js │ │ │ ├── clipboard │ │ │ │ └── copy-to-clipboard.js │ │ │ ├── cookie │ │ │ │ └── cookie.js │ │ │ ├── delay │ │ │ │ └── delay.js │ │ │ ├── error │ │ │ │ └── print.js │ │ │ ├── file │ │ │ │ └── human-readable-file-size.js │ │ │ ├── form-elements │ │ │ │ ├── sync-form-files.js │ │ │ │ └── update-form.js │ │ │ ├── i18n │ │ │ │ └── language.js │ │ │ ├── ipfs │ │ │ │ ├── cid-obj-to-str.js │ │ │ │ ├── determine-template-type-and-keys.js │ │ │ │ ├── ensure-ipfs-is-running.js │ │ │ │ ├── fg-storage.js │ │ │ │ └── normalize-schema-fields.js │ │ │ └── router │ │ │ │ └── navigate.js │ │ ├── scss │ │ │ ├── asset │ │ │ │ └── asset.scss │ │ │ ├── components │ │ │ │ └── vue-json-pretty │ │ │ │ │ └── styles.css │ │ │ ├── helpers │ │ │ │ ├── form-elements.scss │ │ │ │ ├── header.scss │ │ │ │ ├── json-editor.scss │ │ │ │ └── loading-blocker.scss │ │ │ ├── router.scss │ │ │ └── template │ │ │ │ └── template.scss │ │ └── stores │ │ │ └── main.js │ └── webpack.config.js ├── form │ ├── .babelrc │ ├── .env.example │ ├── LICENSE │ ├── README.md │ ├── assets │ │ ├── Brave-logo-color-RGB.svg │ │ ├── metamask-fox.svg │ │ ├── unverified.png │ │ └── verified.png │ ├── package.json │ ├── public │ │ └── index.html │ ├── src │ │ ├── components │ │ │ ├── asset │ │ │ │ └── Asset.vue │ │ │ ├── helpers │ │ │ │ ├── FormElements.vue │ │ │ │ ├── Header.vue │ │ │ │ ├── JsonEditor.vue │ │ │ │ └── LoadingBlocker.vue │ │ │ └── template │ │ │ │ └── Template.vue │ │ ├── fonts │ │ │ └── OpenSans │ │ │ │ ├── OpenSans-Bold.ttf │ │ │ │ ├── OpenSans-BoldItalic.ttf │ │ │ │ ├── OpenSans-ExtraBold.ttf │ │ │ │ ├── OpenSans-ExtraBoldItalic.ttf │ │ │ │ ├── OpenSans-Italic.ttf │ │ │ │ ├── OpenSans-Light.ttf │ │ │ │ ├── OpenSans-LightItalic.ttf │ │ │ │ ├── OpenSans-Medium.ttf │ │ │ │ ├── OpenSans-MediumItalic.ttf │ │ │ │ ├── OpenSans-Regular.ttf │ │ │ │ ├── OpenSans-SemiBold.ttf │ │ │ │ ├── OpenSans-SemiBoldItalic.ttf │ │ │ │ └── font.scss │ │ ├── js │ │ │ ├── asset │ │ │ │ └── asset.js │ │ │ ├── helpers │ │ │ │ ├── form-elements.js │ │ │ │ ├── header.js │ │ │ │ ├── json-editor.js │ │ │ │ └── loading-blocker.js │ │ │ ├── router.js │ │ │ └── template │ │ │ │ └── template.js │ │ ├── locales │ │ │ └── en_GB.js │ │ ├── mixins │ │ │ ├── authentication │ │ │ │ └── authentication.js │ │ │ ├── clipboard │ │ │ │ └── copy-to-clipboard.js │ │ │ ├── cookie │ │ │ │ └── cookie.js │ │ │ ├── delay │ │ │ │ └── delay.js │ │ │ ├── error │ │ │ │ └── print.js │ │ │ ├── file │ │ │ │ └── human-readable-file-size.js │ │ │ ├── form-elements │ │ │ │ ├── sync-form-files.js │ │ │ │ └── update-form.js │ │ │ ├── i18n │ │ │ │ └── language.js │ │ │ ├── ipfs │ │ │ │ ├── cid-obj-to-str.js │ │ │ │ ├── determine-template-type-and-keys.js │ │ │ │ ├── ensure-ipfs-is-running.js │ │ │ │ ├── fg-storage.js │ │ │ │ └── normalize-schema-fields.js │ │ │ └── router │ │ │ │ └── navigate.js │ │ ├── scss │ │ │ ├── asset │ │ │ │ └── asset.scss │ │ │ ├── components │ │ │ │ └── vue-json-pretty │ │ │ │ │ └── styles.css │ │ │ ├── helpers │ │ │ │ ├── form-elements.scss │ │ │ │ ├── header.scss │ │ │ │ ├── json-editor.scss │ │ │ │ └── loading-blocker.scss │ │ │ ├── router.scss │ │ │ └── template │ │ │ │ └── template.scss │ │ └── stores │ │ │ └── main.js │ └── webpack.config.js ├── landing-page │ ├── .babelrc │ ├── LICENSE │ ├── README.md │ ├── package.json │ ├── public │ │ └── index.html │ ├── src │ │ ├── components │ │ │ ├── helpers │ │ │ │ └── Header.vue │ │ │ └── main │ │ │ │ └── Main.vue │ │ ├── fonts │ │ │ └── OpenSans │ │ │ │ ├── OpenSans-Bold 2.ttf │ │ │ │ ├── OpenSans-Bold.ttf │ │ │ │ ├── OpenSans-BoldItalic 2.ttf │ │ │ │ ├── OpenSans-BoldItalic.ttf │ │ │ │ ├── OpenSans-ExtraBold 2.ttf │ │ │ │ ├── OpenSans-ExtraBold.ttf │ │ │ │ ├── OpenSans-ExtraBoldItalic 2.ttf │ │ │ │ ├── OpenSans-ExtraBoldItalic.ttf │ │ │ │ ├── OpenSans-Italic 2.ttf │ │ │ │ ├── OpenSans-Italic.ttf │ │ │ │ ├── OpenSans-Light 2.ttf │ │ │ │ ├── OpenSans-Light.ttf │ │ │ │ ├── OpenSans-LightItalic 2.ttf │ │ │ │ ├── OpenSans-LightItalic.ttf │ │ │ │ ├── OpenSans-Medium.ttf │ │ │ │ ├── OpenSans-MediumItalic.ttf │ │ │ │ ├── OpenSans-Regular.ttf │ │ │ │ ├── OpenSans-SemiBold 2.ttf │ │ │ │ ├── OpenSans-SemiBold.ttf │ │ │ │ ├── OpenSans-SemiBoldItalic.ttf │ │ │ │ └── font.scss │ │ ├── js │ │ │ ├── helpers │ │ │ │ ├── header 2.js │ │ │ │ └── header.js │ │ │ ├── main │ │ │ │ ├── main 2.js │ │ │ │ └── main.js │ │ │ └── router.js │ │ ├── locales │ │ │ └── en_GB.js │ │ ├── mixins │ │ │ └── i18n │ │ │ │ └── language.js │ │ ├── scss │ │ │ ├── helpers │ │ │ │ ├── header 2.scss │ │ │ │ └── header.scss │ │ │ ├── main │ │ │ │ └── main.scss │ │ │ └── router.scss │ │ └── stores │ │ │ └── main.js │ └── webpack.config.js ├── pipeline-inspector │ ├── .babelrc │ ├── .env.example │ ├── LICENSE │ ├── README.md │ ├── assets │ │ ├── Brave-logo-color-RGB.svg │ │ └── metamask-fox.svg │ ├── package.json │ ├── public │ │ └── index.html │ ├── src │ │ ├── components │ │ │ ├── helpers │ │ │ │ ├── Header.vue │ │ │ │ └── LoadingBlocker.vue │ │ │ └── pipelines │ │ │ │ └── Pipelines.vue │ │ ├── fonts │ │ │ └── OpenSans │ │ │ │ ├── OpenSans-Bold.ttf │ │ │ │ ├── OpenSans-BoldItalic.ttf │ │ │ │ ├── OpenSans-ExtraBold.ttf │ │ │ │ ├── OpenSans-ExtraBoldItalic.ttf │ │ │ │ ├── OpenSans-Italic.ttf │ │ │ │ ├── OpenSans-Light.ttf │ │ │ │ ├── OpenSans-LightItalic.ttf │ │ │ │ ├── OpenSans-Medium.ttf │ │ │ │ ├── OpenSans-MediumItalic.ttf │ │ │ │ ├── OpenSans-Regular.ttf │ │ │ │ ├── OpenSans-SemiBold.ttf │ │ │ │ ├── OpenSans-SemiBoldItalic.ttf │ │ │ │ └── font.scss │ │ ├── js │ │ │ ├── helpers │ │ │ │ ├── header.js │ │ │ │ └── loading-blocker.js │ │ │ ├── pipelines │ │ │ │ └── pipelines.js │ │ │ └── router.js │ │ ├── locales │ │ │ └── en_GB.js │ │ ├── mixins │ │ │ ├── api │ │ │ │ ├── api-profile.js │ │ │ │ └── get-token.js │ │ │ ├── authentication │ │ │ │ └── authentication.js │ │ │ ├── clipboard │ │ │ │ └── copy-to-clipboard.js │ │ │ ├── cookie │ │ │ │ └── cookie.js │ │ │ ├── delay │ │ │ │ └── delay.js │ │ │ ├── error │ │ │ │ └── print.js │ │ │ ├── file │ │ │ │ └── human-readable-file-size.js │ │ │ ├── form-elements │ │ │ │ ├── list-elements-group-by.js │ │ │ │ ├── sync-form-files.js │ │ │ │ └── update-form.js │ │ │ ├── i18n │ │ │ │ └── language.js │ │ │ ├── ipfs │ │ │ │ ├── cid-obj-to-str.js │ │ │ │ ├── determine-template-type-and-keys.js │ │ │ │ ├── ensure-ipfs-is-running.js │ │ │ │ ├── fg-storage.js │ │ │ │ └── normalize-schema-fields.js │ │ │ ├── provenance │ │ │ │ └── provenance.js │ │ │ └── router │ │ │ │ └── navigate.js │ │ ├── scss │ │ │ ├── components │ │ │ │ └── vue-json-pretty │ │ │ │ │ └── styles.css │ │ │ ├── helpers │ │ │ │ ├── header.scss │ │ │ │ └── loading-blocker.scss │ │ │ ├── pipelines │ │ │ │ └── pipelines.scss │ │ │ └── router.scss │ │ └── stores │ │ │ └── main.js │ └── webpack.config.js └── web │ ├── .babelrc │ ├── .env.example │ ├── LICENSE │ ├── README.md │ ├── assets │ ├── Bacalhau-WA.png │ ├── Bacalhau-WA.xcf │ ├── Toucan.json │ ├── account.png │ ├── acr.json │ ├── attribution-account.txt │ ├── attribution-bulb.txt │ ├── attribution-ecology.txt │ ├── attribution-environment.txt │ ├── attribution-planet-earth.txt │ ├── attribution-private-key.txt │ ├── attribution-theme.txt │ ├── bulb.png │ ├── contract.png │ ├── ecology.png │ ├── environment.png │ ├── gold-standard.json │ ├── planet-earth.png │ ├── private-key.png │ ├── programmer.png │ ├── theme.png │ └── verra.json │ ├── package.json │ ├── public │ └── index.html │ ├── src │ ├── components │ │ ├── about │ │ │ └── About.vue │ │ ├── assets │ │ │ └── Assets.vue │ │ ├── dashboard │ │ │ └── Dashboard.vue │ │ ├── functions │ │ │ └── Functions.vue │ │ ├── helpers │ │ │ ├── Contributor.vue │ │ │ ├── FormElements.vue │ │ │ ├── Header.vue │ │ │ ├── JsonEditor.vue │ │ │ └── LoadingBlocker.vue │ │ ├── main │ │ │ └── Main.vue │ │ ├── pipelines │ │ │ ├── CreatePipeline.vue │ │ │ └── Pipelines.vue │ │ ├── profile │ │ │ └── Profile.vue │ │ └── templates │ │ │ └── Templates.vue │ ├── fonts │ │ └── OpenSans │ │ │ ├── OpenSans-Bold.ttf │ │ │ ├── OpenSans-BoldItalic.ttf │ │ │ ├── OpenSans-ExtraBold.ttf │ │ │ ├── OpenSans-ExtraBoldItalic.ttf │ │ │ ├── OpenSans-Italic.ttf │ │ │ ├── OpenSans-Light.ttf │ │ │ ├── OpenSans-LightItalic.ttf │ │ │ ├── OpenSans-Medium.ttf │ │ │ ├── OpenSans-MediumItalic.ttf │ │ │ ├── OpenSans-Regular.ttf │ │ │ ├── OpenSans-SemiBold.ttf │ │ │ ├── OpenSans-SemiBoldItalic.ttf │ │ │ └── font.scss │ ├── index.js │ ├── js │ │ ├── about │ │ │ └── about.js │ │ ├── assets │ │ │ └── assets.js │ │ ├── dashboard │ │ │ └── dashboard.js │ │ ├── functions │ │ │ └── functions.js │ │ ├── helpers │ │ │ ├── contributor.js │ │ │ ├── form-elements.js │ │ │ ├── header.js │ │ │ ├── json-editor.js │ │ │ └── loading-blocker.js │ │ ├── main │ │ │ └── main.js │ │ ├── pipelines │ │ │ ├── create-pipeline.js │ │ │ └── pipelines.js │ │ ├── profile │ │ │ └── profile.js │ │ ├── router.js │ │ └── templates │ │ │ └── templates.js │ ├── locales │ │ └── en_GB.js │ ├── mixins │ │ ├── api │ │ │ ├── api-profile.js │ │ │ └── get-token.js │ │ ├── authentication │ │ │ └── authentication.js │ │ ├── clipboard │ │ │ └── copy-to-clipboard.js │ │ ├── cookie │ │ │ └── cookie.js │ │ ├── delay │ │ │ └── delay.js │ │ ├── error │ │ │ └── print.js │ │ ├── file │ │ │ └── human-readable-file-size.js │ │ ├── form-elements │ │ │ ├── list-elements-group-by.js │ │ │ ├── sync-form-files.js │ │ │ └── update-form.js │ │ ├── i18n │ │ │ └── language.js │ │ ├── ipfs │ │ │ ├── cid-obj-to-str.js │ │ │ ├── determine-template-type-and-keys.js │ │ │ ├── ensure-ipfs-is-running.js │ │ │ ├── fg-storage.js │ │ │ └── normalize-schema-fields.js │ │ ├── provenance │ │ │ └── provenance.js │ │ └── router │ │ │ └── navigate.js │ ├── scss │ │ ├── about │ │ │ └── about.scss │ │ ├── assets │ │ │ └── assets.scss │ │ ├── components │ │ │ └── vue-json-pretty │ │ │ │ └── styles.css │ │ ├── dashboard │ │ │ └── dashboard.scss │ │ ├── functions │ │ │ └── functions.scss │ │ ├── helpers │ │ │ ├── contributor.scss │ │ │ ├── form-elements.scss │ │ │ ├── header.scss │ │ │ ├── json-editor.scss │ │ │ └── loading-blocker.scss │ │ ├── main │ │ │ └── main.scss │ │ ├── pipelines │ │ │ ├── create-pipeline.scss │ │ │ └── pipelines.scss │ │ ├── profile │ │ │ └── profile.scss │ │ ├── router.scss │ │ └── templates │ │ │ └── templates.scss │ └── stores │ │ └── main.js │ └── webpack.config.js ├── co2-storage.png ├── functions ├── bacalhau │ └── travel-decarbonization │ │ └── v0 │ │ ├── go.mod │ │ ├── go.sum │ │ ├── inputs │ │ └── asset │ │ ├── main.go │ │ ├── outputs │ │ ├── Driving Emissions (kg CO2) │ │ ├── Emissions Description │ │ ├── Flying Emissions (kg CO2) │ │ ├── Net Zero │ │ ├── Offset Amount (kg CO2e) │ │ ├── Offset Chain │ │ ├── Offset Transaction Hash │ │ ├── Total Emissions (kg CO2) │ │ └── travel-emissions.json │ │ └── wasm │ │ └── main.wasm └── docker │ ├── inputs │ ├── 1.jpg │ ├── 2.jpg │ ├── 3.jpg │ ├── 4.jpg │ ├── 5.jpg │ ├── 6.jpg │ ├── 7.jpg │ ├── 8.jpg │ ├── 9.jpg │ └── Sunda-pangolin.jpg │ └── outputs │ ├── preds1.json │ ├── preds2.json │ └── preds3.json ├── js-api ├── README.md ├── package.json └── src │ └── js │ ├── auth │ └── Auth.js │ ├── helpers │ ├── Common.js │ ├── Estuary.js │ └── FG.js │ ├── index.js │ └── storage │ └── FGStorage.js ├── node ├── install.sh └── install.sh.original └── signing-records └── contracts ├── CO2storageCidSignatureVerifier.sol ├── CO2storageMessageSignatureVerifier.sol └── CO2storageProvenanceMessageSignatureVerifier.sol /.gitignore: -------------------------------------------------------------------------------- 1 | **/.DS_Store 2 | **/libs/ 3 | **/logs/ 4 | **/.settings 5 | **/.htaccess 6 | **/.project 7 | **/favicon.ico 8 | **/humans.txt 9 | **/robots.txt 10 | **/.buildpath 11 | **/node_modules/ 12 | **/dist/ 13 | **/npm-debug.log* 14 | **/yarn-debug.log* 15 | **/yarn-error.log* 16 | **/test/unit/coverage/ 17 | **/test/e2e/reports/ 18 | **/selenium-debug.log 19 | **/.sass-cache 20 | **/target 21 | **/package-lock.json 22 | **/*.code-workspace 23 | **/.env 24 | **/.env.local 25 | **/.env.dev 26 | **/.env.prod 27 | **/.env.development 28 | **/.env.production 29 | **/*.key 30 | **/*.ext 31 | **/*.csr 32 | **/*.crt 33 | **/*.srl 34 | **/*.pem 35 | 36 | # Editor directories and files 37 | **/.idea 38 | **/.vscode 39 | **/*.suo 40 | **/*.ntvs* 41 | **/*.njsproj 42 | **/*.sln 43 | -------------------------------------------------------------------------------- /assets/examples/vcs-1427-3.json: -------------------------------------------------------------------------------- 1 | { 2 | "code": "VCS", 3 | "statistics": [ 4 | { 5 | "code": "issued", 6 | "value": "961909151" 7 | }, 8 | { 9 | "code": "retired", 10 | "value": "500893492" 11 | }, 12 | { 13 | "code": "resourcesRegistered", 14 | "value": "1807" 15 | }, 16 | { 17 | "code": "resourcesRegisteredWithCertificatesIssued", 18 | "value": "1482" 19 | }, 20 | { 21 | "code": "resourcesRegisteredWithoutCertificatesIssued", 22 | "value": "325" 23 | }, 24 | { 25 | "code": "resourcesBufferCreditsDeposited", 26 | "value": "63284391" 27 | } 28 | ] 29 | } -------------------------------------------------------------------------------- /backend/head-sync/configs/configs: -------------------------------------------------------------------------------- 1 | [postgresql] 2 | postgresql_host = localhost 3 | postgresql_port = 5432 4 | postgresql_database = co2_storage 5 | postgresql_user = co2_storage 6 | postgresql_password = DATABASE_PASSWORD 7 | 8 | [log] 9 | logfile = logs/log 10 | -------------------------------------------------------------------------------- /backend/head-sync/helpers/configs.go: -------------------------------------------------------------------------------- 1 | package helpers 2 | 3 | import ( 4 | "bufio" 5 | "io" 6 | "os" 7 | "strings" 8 | ) 9 | 10 | type Config map[string]string 11 | 12 | func ReadConfigs(path string) (Config, error) { 13 | // init config 14 | config := Config{ 15 | "file": path, 16 | } 17 | 18 | // return error if config filepath is not provided 19 | if len(path) == 0 { 20 | return config, nil 21 | } 22 | 23 | // open configs file 24 | file, err := os.Open(path) 25 | if err != nil { 26 | return nil, err 27 | } 28 | defer file.Close() 29 | 30 | // instatiate new reader 31 | reader := bufio.NewReader(file) 32 | 33 | // parse through config file 34 | for { 35 | line, err := reader.ReadString('\n') 36 | 37 | // check line for '=' delimiter 38 | if equal := strings.Index(line, "="); equal >= 0 { 39 | // extract key 40 | if key := strings.TrimSpace(line[:equal]); len(key) > 0 { 41 | // init value 42 | value := "" 43 | if len(line) > equal { 44 | // assign value if not empty 45 | value = strings.TrimSpace(line[equal+1:]) 46 | } 47 | 48 | // assign the config map 49 | config[key] = value 50 | } 51 | } 52 | 53 | // process errors 54 | if err == io.EOF { 55 | break 56 | } 57 | if err != nil { 58 | return nil, err 59 | } 60 | } 61 | 62 | return config, nil 63 | } 64 | -------------------------------------------------------------------------------- /backend/head-sync/helpers/logs.go: -------------------------------------------------------------------------------- 1 | package helpers 2 | 3 | import ( 4 | "os" 5 | 6 | log "github.com/sirupsen/logrus" 7 | ) 8 | 9 | func WriteLog(level string, message string, category string) { 10 | // provide configs file path 11 | confsPath := "configs/configs" 12 | 13 | // init config 14 | config := Config{ 15 | "file": confsPath, 16 | } 17 | 18 | // read configs 19 | config, rcerr := ReadConfigs(confsPath) 20 | 21 | if rcerr != nil { 22 | panic(rcerr) 23 | } 24 | 25 | // open log file 26 | file, logerr := os.OpenFile(config["logfile"], os.O_APPEND|os.O_CREATE|os.O_RDWR, 0666) 27 | if logerr != nil { 28 | panic(logerr) 29 | } 30 | defer file.Close() 31 | 32 | // set log output to log file 33 | log.SetOutput(file) 34 | 35 | // set formatter 36 | log.SetFormatter(&log.JSONFormatter{}) 37 | 38 | // log message into a log file 39 | switch level { 40 | case "trace": 41 | log.WithFields(log.Fields{ 42 | "category": category, 43 | }).Trace(message) 44 | case "debug": 45 | log.WithFields(log.Fields{ 46 | "category": category, 47 | }).Debug(message) 48 | case "info": 49 | log.WithFields(log.Fields{ 50 | "category": category, 51 | }).Info(message) 52 | case "warn": 53 | log.WithFields(log.Fields{ 54 | "category": category, 55 | }).Warn(message) 56 | case "error": 57 | log.WithFields(log.Fields{ 58 | "category": category, 59 | }).Error(message) 60 | case "fatal": 61 | log.WithFields(log.Fields{ 62 | "category": category, 63 | }).Fatal(message) 64 | case "panic": 65 | log.WithFields(log.Fields{ 66 | "category": category, 67 | }).Panic(message) 68 | default: 69 | log.WithFields(log.Fields{ 70 | "category": category, 71 | }).Info(message) 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /backend/head-sync/helpers/postgresql.go: -------------------------------------------------------------------------------- 1 | package helpers 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "os" 7 | 8 | "github.com/jackc/pgx/v4/log/logrusadapter" 9 | "github.com/jackc/pgx/v4/pgxpool" 10 | log "github.com/sirupsen/logrus" 11 | ) 12 | 13 | func DbInit(host string, port int, user string, 14 | password string, dbname string) (*pgxpool.Pool, error) { 15 | psqlconn := fmt.Sprintf("postgres://%s:%s@%s:%d/%s", user, password, host, port, dbname) 16 | 17 | // provide configs file path 18 | confsPath := "configs/configs" 19 | 20 | // init config 21 | confs := Config{ 22 | "file": confsPath, 23 | } 24 | 25 | // read configs 26 | confs, rcerr := ReadConfigs(confsPath) 27 | 28 | if rcerr != nil { 29 | panic(rcerr) 30 | } 31 | 32 | // open log file 33 | logFile, logErr := os.OpenFile(confs["logfile"], os.O_APPEND|os.O_CREATE|os.O_RDWR, 0666) 34 | if logErr != nil { 35 | fmt.Fprintf(os.Stderr, "Unable to opent log file: %v\n", logErr) 36 | os.Exit(1) 37 | } 38 | 39 | pgxPoolConfig, pgxPoolConfigErr := pgxpool.ParseConfig(psqlconn) 40 | if pgxPoolConfigErr != nil { 41 | fmt.Fprintf(os.Stderr, "Unable to parse pgxPoolConfig: %v\n", pgxPoolConfigErr) 42 | os.Exit(1) 43 | } 44 | 45 | logger := &log.Logger{ 46 | Out: logFile, 47 | Formatter: new(log.JSONFormatter), 48 | Hooks: make(log.LevelHooks), 49 | Level: log.InfoLevel, 50 | ExitFunc: os.Exit, 51 | ReportCaller: false, 52 | } 53 | 54 | pgxPoolConfig.ConnConfig.Logger = logrusadapter.NewLogger(logger) 55 | 56 | db, err := pgxpool.ConnectConfig(context.Background(), pgxPoolConfig) 57 | 58 | if err != nil { 59 | fmt.Fprintf(os.Stderr, "Unable to connect to database: %v\n", err) 60 | os.Exit(1) 61 | } 62 | 63 | return db, nil 64 | } 65 | -------------------------------------------------------------------------------- /backend/indexer/configs/configs: -------------------------------------------------------------------------------- 1 | [postgresql] 2 | postgresql_host = localhost 3 | postgresql_port = 5432 4 | postgresql_database = co2_storage 5 | postgresql_user = co2_storage 6 | postgresql_password = DATABASE_PASSWORD 7 | 8 | [log] 9 | logfile = logs/log 10 | 11 | [scheduler] 12 | scrape_ipfs_every = @every 5s 13 | 14 | [ipfs] 15 | ipfs_node = /ip4/127.0.0.1/tcp/5001 16 | -------------------------------------------------------------------------------- /backend/indexer/helpers/configs.go: -------------------------------------------------------------------------------- 1 | package helpers 2 | 3 | import ( 4 | "bufio" 5 | "io" 6 | "os" 7 | "strings" 8 | ) 9 | 10 | type Config map[string]string 11 | 12 | func ReadConfigs(path string) (Config, error) { 13 | // init config 14 | config := Config{ 15 | "file": path, 16 | } 17 | 18 | // return error if config filepath is not provided 19 | if len(path) == 0 { 20 | return config, nil 21 | } 22 | 23 | // open configs file 24 | file, err := os.Open(path) 25 | if err != nil { 26 | return nil, err 27 | } 28 | defer file.Close() 29 | 30 | // instatiate new reader 31 | reader := bufio.NewReader(file) 32 | 33 | // parse through config file 34 | for { 35 | line, err := reader.ReadString('\n') 36 | 37 | // check line for '=' delimiter 38 | if equal := strings.Index(line, "="); equal >= 0 { 39 | // extract key 40 | if key := strings.TrimSpace(line[:equal]); len(key) > 0 { 41 | // init value 42 | value := "" 43 | if len(line) > equal { 44 | // assign value if not empty 45 | value = strings.TrimSpace(line[equal+1:]) 46 | } 47 | 48 | // assign the config map 49 | config[key] = value 50 | } 51 | } 52 | 53 | // process errors 54 | if err == io.EOF { 55 | break 56 | } 57 | if err != nil { 58 | return nil, err 59 | } 60 | } 61 | 62 | return config, nil 63 | } 64 | -------------------------------------------------------------------------------- /backend/indexer/helpers/logs.go: -------------------------------------------------------------------------------- 1 | package helpers 2 | 3 | import ( 4 | "os" 5 | 6 | log "github.com/sirupsen/logrus" 7 | ) 8 | 9 | func WriteLog(level string, message string, category string) { 10 | // provide configs file path 11 | confsPath := "configs/configs" 12 | 13 | // init config 14 | config := Config{ 15 | "file": confsPath, 16 | } 17 | 18 | // read configs 19 | config, rcerr := ReadConfigs(confsPath) 20 | 21 | if rcerr != nil { 22 | panic(rcerr) 23 | } 24 | 25 | // open log file 26 | file, logerr := os.OpenFile(config["logfile"], os.O_APPEND|os.O_CREATE|os.O_RDWR, 0666) 27 | if logerr != nil { 28 | panic(logerr) 29 | } 30 | defer file.Close() 31 | 32 | // set log output to log file 33 | log.SetOutput(file) 34 | 35 | // set formatter 36 | log.SetFormatter(&log.JSONFormatter{}) 37 | 38 | // log message into a log file 39 | switch level { 40 | case "trace": 41 | log.WithFields(log.Fields{ 42 | "category": category, 43 | }).Trace(message) 44 | case "debug": 45 | log.WithFields(log.Fields{ 46 | "category": category, 47 | }).Debug(message) 48 | case "info": 49 | log.WithFields(log.Fields{ 50 | "category": category, 51 | }).Info(message) 52 | case "warn": 53 | log.WithFields(log.Fields{ 54 | "category": category, 55 | }).Warn(message) 56 | case "error": 57 | log.WithFields(log.Fields{ 58 | "category": category, 59 | }).Error(message) 60 | case "fatal": 61 | log.WithFields(log.Fields{ 62 | "category": category, 63 | }).Fatal(message) 64 | case "panic": 65 | log.WithFields(log.Fields{ 66 | "category": category, 67 | }).Panic(message) 68 | default: 69 | log.WithFields(log.Fields{ 70 | "category": category, 71 | }).Info(message) 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /backend/indexer/helpers/postgresql.go: -------------------------------------------------------------------------------- 1 | package helpers 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "os" 7 | 8 | "github.com/jackc/pgx/v4/log/logrusadapter" 9 | "github.com/jackc/pgx/v4/pgxpool" 10 | log "github.com/sirupsen/logrus" 11 | ) 12 | 13 | func DbInit(host string, port int, user string, 14 | password string, dbname string) (*pgxpool.Pool, error) { 15 | psqlconn := fmt.Sprintf("postgres://%s:%s@%s:%d/%s", user, password, host, port, dbname) 16 | 17 | // provide configs file path 18 | confsPath := "configs/configs" 19 | 20 | // init config 21 | confs := Config{ 22 | "file": confsPath, 23 | } 24 | 25 | // read configs 26 | confs, rcerr := ReadConfigs(confsPath) 27 | 28 | if rcerr != nil { 29 | panic(rcerr) 30 | } 31 | 32 | // open log file 33 | logFile, logErr := os.OpenFile(confs["logfile"], os.O_APPEND|os.O_CREATE|os.O_RDWR, 0666) 34 | if logErr != nil { 35 | fmt.Fprintf(os.Stderr, "Unable to opent log file: %v\n", logErr) 36 | os.Exit(1) 37 | } 38 | 39 | pgxPoolConfig, pgxPoolConfigErr := pgxpool.ParseConfig(psqlconn) 40 | if pgxPoolConfigErr != nil { 41 | fmt.Fprintf(os.Stderr, "Unable to parse pgxPoolConfig: %v\n", pgxPoolConfigErr) 42 | os.Exit(1) 43 | } 44 | 45 | logger := &log.Logger{ 46 | Out: logFile, 47 | Formatter: new(log.JSONFormatter), 48 | Hooks: make(log.LevelHooks), 49 | Level: log.InfoLevel, 50 | ExitFunc: os.Exit, 51 | ReportCaller: false, 52 | } 53 | 54 | pgxPoolConfig.ConnConfig.Logger = logrusadapter.NewLogger(logger) 55 | 56 | db, err := pgxpool.ConnectConfig(context.Background(), pgxPoolConfig) 57 | 58 | if err != nil { 59 | fmt.Fprintf(os.Stderr, "Unable to connect to database: %v\n", err) 60 | os.Exit(1) 61 | } 62 | 63 | return db, nil 64 | } 65 | -------------------------------------------------------------------------------- /backend/pinning/configs/configs: -------------------------------------------------------------------------------- 1 | [postgresql] 2 | postgresql_host = localhost 3 | postgresql_port = 5432 4 | postgresql_database = co2_storage 5 | postgresql_user = co2_storage 6 | postgresql_password = DATABASE_PASSWORD 7 | 8 | [log] 9 | logfile = logs/log 10 | 11 | [scheduler] 12 | try_pinning_every = @every 5s 13 | check_pinning_nodes = @every 1m 14 | calculate_pin_size = @every 1m 15 | 16 | [ipfs] 17 | ipfs_node_addr = /ip4/127.0.0.1/tcp/5001 18 | ipfs_node_id = 12D3KooWQk7d16YumM6Pn1BJ7FiKjDdnJnFTLu56CTR7YJAs2fej 19 | bootstrap_peers = /ip4/127.0.0.1/udp/4001/quic/p2p/12D3KooWQk7d16YumM6Pn1BJ7FiKjDdnJnFTLu56CTR7YJAs2fej,/dns4/node0.preload.ipfs.io/tcp/443/wss/p2p/QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic,/dns4/node1.preload.ipfs.io/tcp/443/wss/p2p/Qmbut9Ywz9YEDrz8ySBSgWyJk41Uvm2QJPhwDJzJyGFsD6,/dns4/node2.preload.ipfs.io/tcp/443/wss/p2p/QmV7gnbW5VTcJ3oyM2Xk1rdFBJ3kTkvxc87UFGsun29STS,/dns4/node3.preload.ipfs.io/tcp/443/wss/p2p/QmY7JB6MQXhxHvq7dBDh4HpbH29v4yE9JRadAVpndvzySN,/dns4/proxy.co2.storage/udp/4001/quic/p2p/12D3KooWGWHSrAxr6sznTpdcGuqz6zfQ2Y43PZQzhg22uJmGP9n1,/dns4/web2.co2.storage/udp/4001/quic/p2p/12D3KooWFBCcWEDW9GYr9Aw8D2QL7hZakPAw1DGfeZCwfsrjd43b,/dns4/web1.co2.storage/udp/4001/quic/p2p/12D3KooWCPzmui9TSQQG8HTNcZeFiHz6AGS19aaCwxJdjykVqq7f,/dns4/green.filecoin.space/udp/4001/quic/p2p/12D3KooWJmYbQp2sgKX22vZgSRVURkpMQ5YCSc8vf3toHesJc5Y9 -------------------------------------------------------------------------------- /backend/pinning/helpers/configs.go: -------------------------------------------------------------------------------- 1 | package helpers 2 | 3 | import ( 4 | "bufio" 5 | "io" 6 | "os" 7 | "strings" 8 | ) 9 | 10 | type Config map[string]string 11 | 12 | func ReadConfigs(path string) (Config, error) { 13 | // init config 14 | config := Config{ 15 | "file": path, 16 | } 17 | 18 | // return error if config filepath is not provided 19 | if len(path) == 0 { 20 | return config, nil 21 | } 22 | 23 | // open configs file 24 | file, err := os.Open(path) 25 | if err != nil { 26 | return nil, err 27 | } 28 | defer file.Close() 29 | 30 | // instatiate new reader 31 | reader := bufio.NewReader(file) 32 | 33 | // parse through config file 34 | for { 35 | line, err := reader.ReadString('\n') 36 | 37 | // check line for '=' delimiter 38 | if equal := strings.Index(line, "="); equal >= 0 { 39 | // extract key 40 | if key := strings.TrimSpace(line[:equal]); len(key) > 0 { 41 | // init value 42 | value := "" 43 | if len(line) > equal { 44 | // assign value if not empty 45 | value = strings.TrimSpace(line[equal+1:]) 46 | } 47 | 48 | // assign the config map 49 | config[key] = value 50 | } 51 | } 52 | 53 | // process errors 54 | if err == io.EOF { 55 | break 56 | } 57 | if err != nil { 58 | return nil, err 59 | } 60 | } 61 | 62 | return config, nil 63 | } 64 | -------------------------------------------------------------------------------- /backend/pinning/helpers/http_client.go: -------------------------------------------------------------------------------- 1 | package helpers 2 | 3 | import ( 4 | "crypto/tls" 5 | "net/http" 6 | "net/url" 7 | "strconv" 8 | ) 9 | 10 | func HttpProxyClient(proxyProtocol string, proxyHost string, 11 | proxyPort int) (*http.Client, error) { 12 | proxyUrl, _ := url.Parse(proxyProtocol + 13 | "://" + proxyHost + ":" + strconv.Itoa(proxyPort)) 14 | tr := &http.Transport{ 15 | Proxy: http.ProxyURL(proxyUrl), 16 | TLSClientConfig: &tls.Config{ 17 | InsecureSkipVerify: true, 18 | }, 19 | } 20 | client := &http.Client{Transport: tr} 21 | 22 | return client, nil 23 | } 24 | 25 | func HttpClient() (*http.Client, error) { 26 | tr := &http.Transport{ 27 | TLSClientConfig: &tls.Config{ 28 | InsecureSkipVerify: true, 29 | }, 30 | } 31 | client := &http.Client{Transport: tr} 32 | 33 | return client, nil 34 | } 35 | -------------------------------------------------------------------------------- /backend/pinning/helpers/logs.go: -------------------------------------------------------------------------------- 1 | package helpers 2 | 3 | import ( 4 | "os" 5 | 6 | log "github.com/sirupsen/logrus" 7 | ) 8 | 9 | func WriteLog(level string, message string, category string) { 10 | // provide configs file path 11 | confsPath := "configs/configs" 12 | 13 | // init config 14 | config := Config{ 15 | "file": confsPath, 16 | } 17 | 18 | // read configs 19 | config, rcerr := ReadConfigs(confsPath) 20 | 21 | if rcerr != nil { 22 | panic(rcerr) 23 | } 24 | 25 | // open log file 26 | file, logerr := os.OpenFile(config["logfile"], os.O_APPEND|os.O_CREATE|os.O_RDWR, 0666) 27 | if logerr != nil { 28 | panic(logerr) 29 | } 30 | defer file.Close() 31 | 32 | // set log output to log file 33 | log.SetOutput(file) 34 | 35 | // set formatter 36 | log.SetFormatter(&log.JSONFormatter{}) 37 | 38 | // log message into a log file 39 | switch level { 40 | case "trace": 41 | log.WithFields(log.Fields{ 42 | "category": category, 43 | }).Trace(message) 44 | case "debug": 45 | log.WithFields(log.Fields{ 46 | "category": category, 47 | }).Debug(message) 48 | case "info": 49 | log.WithFields(log.Fields{ 50 | "category": category, 51 | }).Info(message) 52 | case "warn": 53 | log.WithFields(log.Fields{ 54 | "category": category, 55 | }).Warn(message) 56 | case "error": 57 | log.WithFields(log.Fields{ 58 | "category": category, 59 | }).Error(message) 60 | case "fatal": 61 | log.WithFields(log.Fields{ 62 | "category": category, 63 | }).Fatal(message) 64 | case "panic": 65 | log.WithFields(log.Fields{ 66 | "category": category, 67 | }).Panic(message) 68 | default: 69 | log.WithFields(log.Fields{ 70 | "category": category, 71 | }).Info(message) 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /backend/pinning/helpers/postgresql.go: -------------------------------------------------------------------------------- 1 | package helpers 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "os" 7 | 8 | "github.com/jackc/pgx/v4/log/logrusadapter" 9 | "github.com/jackc/pgx/v4/pgxpool" 10 | log "github.com/sirupsen/logrus" 11 | ) 12 | 13 | func DbInit(host string, port int, user string, 14 | password string, dbname string) (*pgxpool.Pool, error) { 15 | psqlconn := fmt.Sprintf("postgres://%s:%s@%s:%d/%s", user, password, host, port, dbname) 16 | 17 | // provide configs file path 18 | confsPath := "configs/configs" 19 | 20 | // init config 21 | confs := Config{ 22 | "file": confsPath, 23 | } 24 | 25 | // read configs 26 | confs, rcerr := ReadConfigs(confsPath) 27 | 28 | if rcerr != nil { 29 | panic(rcerr) 30 | } 31 | 32 | // open log file 33 | logFile, logErr := os.OpenFile(confs["logfile"], os.O_APPEND|os.O_CREATE|os.O_RDWR, 0666) 34 | if logErr != nil { 35 | fmt.Fprintf(os.Stderr, "Unable to opent log file: %v\n", logErr) 36 | os.Exit(1) 37 | } 38 | 39 | pgxPoolConfig, pgxPoolConfigErr := pgxpool.ParseConfig(psqlconn) 40 | if pgxPoolConfigErr != nil { 41 | fmt.Fprintf(os.Stderr, "Unable to parse pgxPoolConfig: %v\n", pgxPoolConfigErr) 42 | os.Exit(1) 43 | } 44 | 45 | logger := &log.Logger{ 46 | Out: logFile, 47 | Formatter: new(log.JSONFormatter), 48 | Hooks: make(log.LevelHooks), 49 | Level: log.InfoLevel, 50 | ExitFunc: os.Exit, 51 | ReportCaller: false, 52 | } 53 | 54 | pgxPoolConfig.ConnConfig.Logger = logrusadapter.NewLogger(logger) 55 | 56 | db, err := pgxpool.ConnectConfig(context.Background(), pgxPoolConfig) 57 | 58 | if err != nil { 59 | fmt.Fprintf(os.Stderr, "Unable to connect to database: %v\n", err) 60 | os.Exit(1) 61 | } 62 | 63 | return db, nil 64 | } 65 | -------------------------------------------------------------------------------- /backend/postgres/01.install.sql: -------------------------------------------------------------------------------- 1 | -- login as postgres 2 | CREATE ROLE co2_storage WITH LOGIN PASSWORD 'secret'; 3 | CREATE DATABASE co2_storage; 4 | \c co2_storage 5 | CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; 6 | CREATE EXTENSION IF NOT EXISTS pgcrypto; 7 | CREATE SCHEMA IF NOT EXISTS co2_storage_api AUTHORIZATION co2_storage; 8 | CREATE SCHEMA IF NOT EXISTS co2_storage_scraper AUTHORIZATION co2_storage; 9 | CREATE SCHEMA IF NOT EXISTS co2_storage_helpers AUTHORIZATION co2_storage; 10 | -------------------------------------------------------------------------------- /backend/postgres/02.helpers.sql: -------------------------------------------------------------------------------- 1 | -- Full text search update / trigger function 2 | -- 3 | --DROP FUNCTION IF EXISTS co2_storage_helpers.update_full_text_search(); 4 | CREATE OR REPLACE FUNCTION co2_storage_helpers.update_full_text_search() RETURNS TRIGGER AS $update_full_text_search$ 5 | DECLARE 6 | considered_columns VARCHAR[] = regexp_split_to_array(TG_ARGV[4], '\|\|\|'); 7 | counter SMALLINT = 1; 8 | no_of_columns SMALLINT = array_length(considered_columns , 1); 9 | fts VARCHAR = ''; 10 | BEGIN 11 | WHILE counter <= no_of_columns LOOP 12 | fts = concat(fts, format(' COALESCE(translate(NULLIF(cast("%s" AS TEXT),''''),''/.-*'','' ''),'''') ', considered_columns[counter])); 13 | IF (counter < no_of_columns) THEN 14 | fts = concat(fts, ' || '' '' || '); 15 | END IF; 16 | counter = counter + 1; 17 | END LOOP; 18 | EXECUTE format('UPDATE %s SET %s = to_tsvector(''%s'', %s) WHERE "id" = ''%s'';', concat('"', TG_ARGV[0], '"."', TG_ARGV[1], '"'), concat('"', TG_ARGV[3], '"'), TG_ARGV[2], fts, NEW.id); 19 | RETURN NULL; -- result will be ignored since this is AFTER trigger function 20 | END; 21 | $update_full_text_search$ LANGUAGE plpgsql; 22 | -------------------------------------------------------------------------------- /backend/postgres/04.01.head-alteration-1.sql: -------------------------------------------------------------------------------- 1 | -- Head 2 | -- 3 | -- Added archived to co2_storage_api.chain 4 | ALTER TABLE co2_storage_api.chain 5 | ADD COLUMN "archived" BOOLEAN DEFAULT FALSE; -------------------------------------------------------------------------------- /backend/postgres/05.01.scraper-alteration-1.sql: -------------------------------------------------------------------------------- 1 | -- Contents 2 | -- 3 | -- Adding pinning_node, replication_nodes, archive, archive_deals 4 | -- archived, restored and size to co2_storage_scraper.contents 5 | -- 6 | -- Adding contents_pinning_node_idx to indexes 7 | ALTER TABLE co2_storage_scraper.contents 8 | ADD COLUMN "ipfs_nodes" VARCHAR(1024)[] DEFAULT '{}', 9 | ADD COLUMN "archive" BOOLEAN DEFAULT FALSE, 10 | ADD COLUMN "archive_deals" VARCHAR(1024)[] DEFAULT '{}', 11 | ADD COLUMN "archived" TIMESTAMPTZ[] DEFAULT '{}', 12 | ADD COLUMN "restored" TIMESTAMPTZ[] DEFAULT '{}', 13 | ADD COLUMN "size" BIGINT DEFAULT NULL; 14 | -------------------------------------------------------------------------------- /backend/postgres/05.02.scraper-alteration-1.sql: -------------------------------------------------------------------------------- 1 | -- Contents 2 | -- 3 | -- Adding protocol and license to co2_storage_scraper.contents 4 | ALTER TABLE co2_storage_scraper.contents 5 | ADD COLUMN "protocol" VARCHAR(255) DEFAULT NULL, 6 | ADD COLUMN "license" VARCHAR(255) DEFAULT NULL; 7 | 8 | -- Create indexes 9 | CREATE INDEX IF NOT EXISTS contents_protocol_idx ON co2_storage_scraper.contents ("protocol"); 10 | CREATE INDEX IF NOT EXISTS contents_license_idx ON co2_storage_scraper.contents ("license"); 11 | -------------------------------------------------------------------------------- /backend/rest-api/internal/configs.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "bufio" 5 | "io" 6 | "os" 7 | "strings" 8 | ) 9 | 10 | type Config map[string]string 11 | 12 | func ReadConfigs(path string) (Config, error) { 13 | // init config 14 | config := Config{ 15 | "file": path, 16 | } 17 | 18 | // return error if config filepath is not provided 19 | if len(path) == 0 { 20 | return config, nil 21 | } 22 | 23 | // open configs file 24 | file, err := os.Open(path) 25 | if err != nil { 26 | return nil, err 27 | } 28 | defer file.Close() 29 | 30 | // instatiate new reader 31 | reader := bufio.NewReader(file) 32 | 33 | // parse through config file 34 | for { 35 | line, err := reader.ReadString('\n') 36 | 37 | // check line for '=' delimiter 38 | if equal := strings.Index(line, "="); equal >= 0 { 39 | // extract key 40 | if key := strings.TrimSpace(line[:equal]); len(key) > 0 { 41 | // init value 42 | value := "" 43 | if len(line) > equal { 44 | // assign value if not empty 45 | value = strings.TrimSpace(line[equal+1:]) 46 | } 47 | 48 | // assign the config map 49 | config[key] = value 50 | } 51 | } 52 | 53 | // process errors 54 | if err == io.EOF { 55 | break 56 | } 57 | if err != nil { 58 | return nil, err 59 | } 60 | } 61 | 62 | return config, nil 63 | } 64 | -------------------------------------------------------------------------------- /backend/rest-api/internal/logs.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "os" 5 | 6 | log "github.com/sirupsen/logrus" 7 | ) 8 | 9 | func WriteLog(level string, message string, category string) { 10 | // provide configs file path 11 | confsPath := "configs/configs" 12 | 13 | // init config 14 | config := Config{ 15 | "file": confsPath, 16 | } 17 | 18 | // read configs 19 | config, rcerr := ReadConfigs(confsPath) 20 | 21 | if rcerr != nil { 22 | panic(rcerr) 23 | } 24 | 25 | // open log file 26 | file, logerr := os.OpenFile(config["logfile"], os.O_APPEND|os.O_CREATE|os.O_RDWR, 0666) 27 | if logerr != nil { 28 | panic(logerr) 29 | } 30 | defer file.Close() 31 | 32 | // set log output to log file 33 | log.SetOutput(file) 34 | 35 | // set formatter 36 | log.SetFormatter(&log.JSONFormatter{}) 37 | 38 | // log message into a log file 39 | switch level { 40 | case "trace": 41 | log.WithFields(log.Fields{ 42 | "category": category, 43 | }).Trace(message) 44 | case "debug": 45 | log.WithFields(log.Fields{ 46 | "category": category, 47 | }).Debug(message) 48 | case "info": 49 | log.WithFields(log.Fields{ 50 | "category": category, 51 | }).Info(message) 52 | case "warn": 53 | log.WithFields(log.Fields{ 54 | "category": category, 55 | }).Warn(message) 56 | case "error": 57 | log.WithFields(log.Fields{ 58 | "category": category, 59 | }).Error(message) 60 | case "fatal": 61 | log.WithFields(log.Fields{ 62 | "category": category, 63 | }).Fatal(message) 64 | case "panic": 65 | log.WithFields(log.Fields{ 66 | "category": category, 67 | }).Panic(message) 68 | default: 69 | log.WithFields(log.Fields{ 70 | "category": category, 71 | }).Info(message) 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /backend/rest-api/internal/postgresql.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "os" 7 | 8 | "github.com/jackc/pgx/v4/log/logrusadapter" 9 | "github.com/jackc/pgx/v4/pgxpool" 10 | log "github.com/sirupsen/logrus" 11 | ) 12 | 13 | func DbInit(host string, port int, user string, 14 | password string, dbname string) (*pgxpool.Pool, error) { 15 | psqlconn := fmt.Sprintf("postgres://%s:%s@%s:%d/%s", user, password, host, port, dbname) 16 | 17 | // provide configs file path 18 | confsPath := "configs/configs" 19 | 20 | // init config 21 | confs := Config{ 22 | "file": confsPath, 23 | } 24 | 25 | // read configs 26 | confs, rcerr := ReadConfigs(confsPath) 27 | 28 | if rcerr != nil { 29 | panic(rcerr) 30 | } 31 | 32 | // open log file 33 | logFile, logErr := os.OpenFile(confs["logfile"], os.O_APPEND|os.O_CREATE|os.O_RDWR, 0666) 34 | if logErr != nil { 35 | fmt.Fprintf(os.Stderr, "Unable to opent log file: %v\n", logErr) 36 | os.Exit(1) 37 | } 38 | 39 | pgxPoolConfig, pgxPoolConfigErr := pgxpool.ParseConfig(psqlconn) 40 | if pgxPoolConfigErr != nil { 41 | fmt.Fprintf(os.Stderr, "Unable to parse pgxPoolConfig: %v\n", pgxPoolConfigErr) 42 | os.Exit(1) 43 | } 44 | 45 | logger := &log.Logger{ 46 | Out: logFile, 47 | Formatter: new(log.JSONFormatter), 48 | Hooks: make(log.LevelHooks), 49 | Level: log.InfoLevel, 50 | ExitFunc: os.Exit, 51 | ReportCaller: false, 52 | } 53 | 54 | pgxPoolConfig.ConnConfig.Logger = logrusadapter.NewLogger(logger) 55 | 56 | db, err := pgxpool.ConnectConfig(context.Background(), pgxPoolConfig) 57 | 58 | if err != nil { 59 | fmt.Fprintf(os.Stderr, "Unable to connect to database: %v\n", err) 60 | os.Exit(1) 61 | } 62 | 63 | return db, nil 64 | } 65 | -------------------------------------------------------------------------------- /backend/rest-api/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | "net/http" 6 | "os" 7 | "strconv" 8 | 9 | "github.com/adgsm/co2-storage-rest-api/api" 10 | "github.com/adgsm/co2-storage-rest-api/internal" 11 | "github.com/joho/godotenv" 12 | ) 13 | 14 | func main() { 15 | // provide configs file path 16 | confsPath := "configs/configs" 17 | 18 | // read configs 19 | config, rcerr := internal.ReadConfigs(confsPath) 20 | 21 | if rcerr != nil { 22 | panic(rcerr) 23 | } 24 | 25 | // cast port to int 26 | port, atoierr := strconv.Atoi(config["postgresql_port"]) 27 | 28 | if atoierr != nil { 29 | panic(atoierr) 30 | } 31 | 32 | // init db connection 33 | db, dberr := internal.DbInit(config["postgresql_host"], port, 34 | config["postgresql_user"], goDotEnvVariable(config["postgresql_password"]), config["postgresql_database"]) 35 | 36 | if dberr != nil { 37 | panic(dberr) 38 | } 39 | 40 | // close db connections 41 | // when func closes 42 | defer db.Close() 43 | 44 | // start API 45 | a := api.New(db, goDotEnvVariable(config["rpc_provider"])) 46 | // log.Fatal(http.ListenAndServeTLS(":"+config["api_port"], config["tsl_cert"], config["tsl_key"], a)) 47 | log.Fatal(http.ListenAndServe(":"+config["api_port"], a)) 48 | } 49 | 50 | // Load/read the .env file and 51 | // return the value of the key 52 | func goDotEnvVariable(key string) string { 53 | // load .env file 54 | err := godotenv.Load(".env") 55 | 56 | if err != nil { 57 | panic(err) 58 | } 59 | 60 | return os.Getenv(key) 61 | } 62 | -------------------------------------------------------------------------------- /cli/.env.example: -------------------------------------------------------------------------------- 1 | ESTUARY_API_KEY=ESTxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxARY 2 | INFURA_API_KEY=... 3 | PK=0x... 4 | FG_TOKEN=... -------------------------------------------------------------------------------- /cli/README.md: -------------------------------------------------------------------------------- 1 | # CLI | Example 2 | by [Momcilo Dzunic aka smartbee.eth](https://twitter.com/mdzunic) 3 | 4 | ### License 5 | Licensed under the MIT license. 6 | http://www.opensource.org/licenses/mit-license.php 7 | -------------------------------------------------------------------------------- /cli/assets/Virtuzone___UAE_Corporate_Tax_Guide_2023.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/protocol/co2-storage/6e3794920177ee6ce926f2d2c095861a037d089d/cli/assets/Virtuzone___UAE_Corporate_Tax_Guide_2023.pdf -------------------------------------------------------------------------------- /cli/assets/test document.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/protocol/co2-storage/6e3794920177ee6ce926f2d2c095861a037d089d/cli/assets/test document.pdf -------------------------------------------------------------------------------- /cli/assets/test image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/protocol/co2-storage/6e3794920177ee6ce926f2d2c095861a037d089d/cli/assets/test image.jpg -------------------------------------------------------------------------------- /cli/assets/test.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/protocol/co2-storage/6e3794920177ee6ce926f2d2c095861a037d089d/cli/assets/test.zip -------------------------------------------------------------------------------- /cli/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "CLI-example", 3 | "version": "0.0.1", 4 | "description": "CLI example", 5 | "type": "module", 6 | "author": { 7 | "name": "Momcilo Dzunic", 8 | "email": "momcilo.dzunic@protocol.ai" 9 | }, 10 | "devDependencies": { 11 | "env-cmd": "^10.1.0" 12 | }, 13 | "scripts": { 14 | "authenticate": "env-cmd node src/examples/authenticate.js", 15 | "search_templates": "env-cmd node src/examples/search_templates.js", 16 | "get_template": "env-cmd node src/examples/get_template.js", 17 | "add_template": "env-cmd node src/examples/add_template.js", 18 | "search_assets": "env-cmd node src/examples/search_assets.js", 19 | "search": "env-cmd node src/examples/search.js", 20 | "get_asset": "env-cmd node src/examples/get_asset.js", 21 | "add_asset": "env-cmd node src/examples/add_asset.js", 22 | "add_big_asset": "env-cmd node src/examples/add_big_asset.js", 23 | "add_asset_with_nested_template": "env-cmd node src/examples/add_asset_with_nested_template.js", 24 | "add_asset_with_nested_assets": "env-cmd node src/examples/add_asset_with_nested_assets.js", 25 | "sign_cid": "env-cmd node src/examples/sign_cid.js", 26 | "get_accounts": "env-cmd node src/examples/get_accounts.js", 27 | "get_account": "env-cmd node src/examples/get_account.js", 28 | "get_raw_data": "env-cmd node src/examples/get_raw_data.js", 29 | "serialize-dag-cbor": "env-cmd node src/examples/serialize_dag_cbor.js", 30 | "test": "env-cmd node src/examples/create_invalid_dag-pb.js" 31 | }, 32 | "dependencies": { 33 | "@co2-storage/js-api": "^1.4.4", 34 | "@ipld/dag-pb": "^4.0.4", 35 | "fs": "^0.0.1-security", 36 | "ipfs-unixfs": "^11.0.1", 37 | "multiformats": "^12.0.1", 38 | "path": "^0.12.7", 39 | "web3": "^4.0.1" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /cli/src/examples/add_template.js: -------------------------------------------------------------------------------- 1 | import { FGStorage } from '@co2-storage/js-api' 2 | 3 | const authType = "pk" 4 | const ipfsNodeType = "client" 5 | //const ipfsNodeAddr = "/ip4/127.0.0.1/tcp/5001" 6 | //const fgApiUrl = "http://localhost:3020" 7 | const ipfsNodeAddr = "/dns4/web1.co2.storage/tcp/5002/https" 8 | const fgApiUrl = "https://web1.co2.storage" 9 | 10 | const fgStorage = new FGStorage({authType: authType, ipfsNodeType: ipfsNodeType, ipfsNodeAddr: ipfsNodeAddr, fgApiHost: fgApiUrl}) 11 | 12 | /** 13 | * Add a template 14 | * parameters: (template:json, template name:string, template base:string, template description:string, template parent:string(CID), chain_name: string) 15 | */ 16 | 17 | const template = { 18 | Country: { type: 'string', mandatory: true }, 19 | Retired: { type: 'boolean' }, 20 | Vintage: { type: 'date', mandatory: true } 21 | } 22 | const templateName = 'CLI example test template (1.0.3-v1)' 23 | const templateBase = {title: 'VCS', reference: 'bafyreigenzubua7r7rlxomgpyy2o4q46u6anvw3qvbxmlxhifkbrdbhcwm'} 24 | const templateDescription = 'Test template (1.0.3-v1)' 25 | const templateParent = 'bafyreigijwcxu4nda2nol5x3cepjhel6mlvgyiizvivki3dpg3ttegdl2y' 26 | const chainName = 'sandbox' 27 | let addTemplateResponse = await fgStorage.addTemplate(template, templateName, templateBase, templateDescription, templateParent, chainName) 28 | if(addTemplateResponse.error != null) { 29 | console.error(addTemplateResponse.error) 30 | await new Promise(reject => setTimeout(reject, 300)); 31 | process.exit() 32 | } 33 | 34 | console.dir(addTemplateResponse.result, {depth: null}) 35 | 36 | await new Promise(resolve => setTimeout(resolve, 1000)); 37 | 38 | // Exit program 39 | process.exit() 40 | -------------------------------------------------------------------------------- /cli/src/examples/authenticate.js: -------------------------------------------------------------------------------- 1 | import { Auth } from '@co2-storage/js-api' 2 | 3 | const authType = "pk" 4 | const auth = new Auth(authType) 5 | 6 | /** 7 | * Authenticate with a private key 8 | */ 9 | 10 | let authResponse = await auth.authenticate() 11 | 12 | if(authResponse.error != null) { 13 | console.error(authResponse.error) 14 | await new Promise(reject => setTimeout(reject, 300)); 15 | process.exit() 16 | } 17 | 18 | console.dir(authResponse.result, {depth: null}) 19 | 20 | await new Promise(resolve => setTimeout(resolve, 1000)); 21 | 22 | // Exit program 23 | process.exit() -------------------------------------------------------------------------------- /cli/src/examples/get_account.js: -------------------------------------------------------------------------------- 1 | import { FGStorage } from '@co2-storage/js-api' 2 | 3 | const authType = "pk" 4 | const ipfsNodeType = "client" 5 | //const ipfsNodeAddr = "/ip4/127.0.0.1/tcp/5001" 6 | //const fgApiUrl = "http://localhost:3020" 7 | const ipfsNodeAddr = "/dns4/web2.co2.storage/tcp/5002/https" 8 | const fgApiUrl = "https://web2.co2.storage" 9 | 10 | const fgStorage = new FGStorage({authType: authType, ipfsNodeType: ipfsNodeType, ipfsNodeAddr: ipfsNodeAddr, fgApiHost: fgApiUrl}) 11 | 12 | /** 13 | * Get account 14 | */ 15 | 16 | let accountResponse = await fgStorage.getAccount('sandbox') 17 | if(accountResponse.error != null) { 18 | console.error(accountResponse.error) 19 | await new Promise(reject => setTimeout(reject, 300)); 20 | process.exit() 21 | } 22 | 23 | console.dir(accountResponse.result, {depth: null}) 24 | 25 | await new Promise(resolve => setTimeout(resolve, 1000)); 26 | 27 | // Exit program 28 | process.exit() 29 | -------------------------------------------------------------------------------- /cli/src/examples/get_accounts.js: -------------------------------------------------------------------------------- 1 | import { FGStorage } from '@co2-storage/js-api' 2 | 3 | const authType = "pk" 4 | const ipfsNodeType = "client" 5 | //const ipfsNodeAddr = "/ip4/127.0.0.1/tcp/5001" 6 | //const fgApiUrl = "http://localhost:3020" 7 | const ipfsNodeAddr = "/dns4/web2.co2.storage/tcp/5002/https" 8 | const fgApiUrl = "https://web2.co2.storage" 9 | 10 | const fgStorage = new FGStorage({authType: authType, ipfsNodeType: ipfsNodeType, ipfsNodeAddr: ipfsNodeAddr, fgApiHost: fgApiUrl}) 11 | 12 | /** 13 | * Get accounts 14 | */ 15 | 16 | let accountsResponse = await fgStorage.getAccounts('sandbox') 17 | if(accountsResponse.error != null) { 18 | console.error(accountsResponse.error) 19 | await new Promise(reject => setTimeout(reject, 300)); 20 | process.exit() 21 | } 22 | 23 | console.dir(accountsResponse.result, {depth: null}) 24 | 25 | await new Promise(resolve => setTimeout(resolve, 1000)); 26 | 27 | // Exit program 28 | process.exit() 29 | -------------------------------------------------------------------------------- /cli/src/examples/get_asset.js: -------------------------------------------------------------------------------- 1 | import { FGStorage } from '@co2-storage/js-api' 2 | 3 | const authType = "pk" 4 | const ipfsNodeType = "client" 5 | //const ipfsNodeAddr = "/ip4/127.0.0.1/tcp/5001" 6 | //const fgApiUrl = "http://localhost:3020" 7 | const ipfsNodeAddr = "/dns4/web2.co2.storage/tcp/5002/https" 8 | const fgApiUrl = "https://web2.co2.storage" 9 | 10 | const fgStorage = new FGStorage({authType: authType, ipfsNodeType: ipfsNodeType, ipfsNodeAddr: ipfsNodeAddr, fgApiHost: fgApiUrl}) 11 | 12 | /** 13 | * Search assets 14 | * parameters: (chainName, phrases, cid, name, base, account, offset, limit, sortBy, sortDir) 15 | * // default data_chain: 'sandbox', phrases: null, cid: null, name: null, base: null, account: null, offset: 0, limit: 10 16 | */ 17 | 18 | let searchAssetsResponse = await fgStorage.searchAssets('sandbox') // ('SP Audits', 'Water') 19 | if(searchAssetsResponse.error != null) { 20 | console.error(searchAssetsResponse.error) 21 | await new Promise(reject => setTimeout(reject, 300)); 22 | process.exit() 23 | } 24 | 25 | /** 26 | * Get asset 27 | * parameters: asset block CID 28 | */ 29 | 30 | const lastListedAsset = searchAssetsResponse.result.assets[searchAssetsResponse.result.assets.length-1] 31 | if(lastListedAsset) { 32 | let getAssetResponse = await fgStorage.getAsset(lastListedAsset.block) 33 | if(getAssetResponse.error != null) { 34 | console.error(getAssetResponse.error) 35 | await new Promise(reject => setTimeout(reject, 300)); 36 | process.exit() 37 | } 38 | 39 | console.dir(getAssetResponse.result, {depth: null}) 40 | } 41 | 42 | await new Promise(resolve => setTimeout(resolve, 1000)); 43 | 44 | // Exit program 45 | process.exit() 46 | -------------------------------------------------------------------------------- /cli/src/examples/get_raw_data.js: -------------------------------------------------------------------------------- 1 | import { FGStorage } from '@co2-storage/js-api' 2 | 3 | import { CID } from 'multiformats/cid' 4 | 5 | 6 | const authType = "pk" // or "metamask" 7 | const ipfsNodeType = "client" 8 | const ipfsNodeAddr = "/dns4/web2.co2.storage/tcp/5002/https" 9 | const fgApiUrl = "https://web2.co2.storage" 10 | 11 | const fgStorage = new FGStorage({authType: authType, ipfsNodeType: ipfsNodeType, ipfsNodeAddr: ipfsNodeAddr, fgApiHost: fgApiUrl}) 12 | 13 | const ipfs = await fgStorage.ensureIpfsIsRunning() 14 | 15 | const cid = 'bafybeibks5ute3txdug5cy3dyyggogbp7cmav57rylgwllnl6lghsjyml4' 16 | // Get all at once 17 | //const buffer = await fgStorage.getRawData(cid) 18 | // Get first 100000 bytes 19 | const buffer = await fgStorage.getRawData(cid, {offset: 0, length: 100000}, (bytes) => { 20 | console.log(`${bytes} bytes received`) 21 | }) 22 | 23 | //console.log(buffer) 24 | process.exit() 25 | -------------------------------------------------------------------------------- /cli/src/examples/get_template.js: -------------------------------------------------------------------------------- 1 | import { FGStorage } from '@co2-storage/js-api' 2 | 3 | const authType = "pk" 4 | const ipfsNodeType = "client" 5 | //const ipfsNodeAddr = "/ip4/127.0.0.1/tcp/5001" 6 | //const fgApiUrl = "http://localhost:3020" 7 | const ipfsNodeAddr = "/dns4/web1.co2.storage/tcp/5002/https" 8 | const fgApiUrl = "https://web1.co2.storage" 9 | 10 | const fgStorage = new FGStorage({authType: authType, ipfsNodeType: ipfsNodeType, ipfsNodeAddr: ipfsNodeAddr, fgApiHost: fgApiUrl}) 11 | 12 | /** 13 | * Search templates 14 | * parameters: (chainName, phrases, cid, name, base, account, offset, limit, sortBy, sortDir) 15 | * // default data_chain: 'sandbox', phrases: null, cid: null, name: null, base: null, account: null, offset: 0, limit: 10 16 | */ 17 | 18 | let searchTemplatesResponse = await fgStorage.searchTemplates('sandbox') // ('SP Audits', 'Water') 19 | if(searchTemplatesResponse.error != null) { 20 | console.error(searchTemplatesResponse.error) 21 | await new Promise(reject => setTimeout(reject, 300)); 22 | process.exit() 23 | } 24 | 25 | /** 26 | * Get template 27 | * parameters: template block CID 28 | */ 29 | 30 | const lastListedTemplate = searchTemplatesResponse.result.templates[searchTemplatesResponse.result.templates.length-1] 31 | if(lastListedTemplate) { 32 | let getTemplateResponse = await fgStorage.getTemplate(lastListedTemplate.block) 33 | if(getTemplateResponse.error != null) { 34 | console.error(getTemplateResponse.error) 35 | await new Promise(reject => setTimeout(reject, 300)); 36 | process.exit() 37 | } 38 | 39 | console.dir(getTemplateResponse.result, {depth: null}) 40 | } 41 | 42 | await new Promise(resolve => setTimeout(resolve, 1000)); 43 | 44 | // Exit program 45 | process.exit() 46 | -------------------------------------------------------------------------------- /cli/src/examples/search.js: -------------------------------------------------------------------------------- 1 | import { FGStorage } from '@co2-storage/js-api' 2 | 3 | const authType = "pk" 4 | const ipfsNodeType = "client" 5 | //const ipfsNodeAddr = "/ip4/127.0.0.1/tcp/5001" 6 | //const fgApiUrl = "http://localhost:3020" 7 | const ipfsNodeAddr = "/dns4/web1.co2.storage/tcp/5002/https" 8 | const fgApiUrl = "https://web1.co2.storage" 9 | 10 | const fgStorage = new FGStorage({authType: authType, ipfsNodeType: ipfsNodeType, ipfsNodeAddr: ipfsNodeAddr, fgApiHost: fgApiUrl}) 11 | 12 | /** 13 | * Search 14 | * parameters: (chainName, phrases, dataStructure, cid, parent, name, description, base, 15 | reference, contentCid, creator, createdFrom, createdTo, version, offset, limit, sortBy, sortDir) 16 | */ 17 | 18 | let searchResponse = await fgStorage.search(null, null, 'asset', null, null, null, null, null, 19 | 'bafyreigcprw3dp3mrsv2xgysomratgv3oz4cpl3rsiij2hzucckyxfbpd4') 20 | if(searchResponse.error != null) { 21 | console.error(searchResponse.error) 22 | await new Promise(reject => setTimeout(reject, 300)); 23 | process.exit() 24 | } 25 | 26 | console.dir(searchResponse.result, {depth: null}) 27 | 28 | await new Promise(resolve => setTimeout(resolve, 1000)); 29 | 30 | // Exit program 31 | process.exit() 32 | -------------------------------------------------------------------------------- /cli/src/examples/search_assets.js: -------------------------------------------------------------------------------- 1 | import { FGStorage } from '@co2-storage/js-api' 2 | 3 | const authType = "pk" 4 | const ipfsNodeType = "client" 5 | //const ipfsNodeAddr = "/ip4/127.0.0.1/tcp/5001" 6 | //const fgApiUrl = "http://localhost:3020" 7 | const ipfsNodeAddr = "/dns4/web2.co2.storage/tcp/5002/https" 8 | const fgApiUrl = "https://web2.co2.storage" 9 | 10 | const fgStorage = new FGStorage({authType: authType, ipfsNodeType: ipfsNodeType, ipfsNodeAddr: ipfsNodeAddr, fgApiHost: fgApiUrl}) 11 | 12 | /** 13 | * Search assets 14 | * parameters: (chainName, phrases, cid, name, base, account, offset, limit, sortBy, sortDir) 15 | * // default data_chain: 'sandbox', phrases: null, cid: null, name: null, base: null, account: null, offset: 0, limit: 10 16 | */ 17 | 18 | let searchAssetsResponse = await fgStorage.searchAssets('sandbox') // ('SP Audits', 'Water') 19 | if(searchAssetsResponse.error != null) { 20 | console.error(searchAssetsResponse.error) 21 | await new Promise(reject => setTimeout(reject, 300)); 22 | process.exit() 23 | } 24 | 25 | console.dir(searchAssetsResponse.result, {depth: null}) 26 | 27 | await new Promise(resolve => setTimeout(resolve, 1000)); 28 | 29 | // Exit program 30 | process.exit() 31 | -------------------------------------------------------------------------------- /cli/src/examples/search_templates.js: -------------------------------------------------------------------------------- 1 | import { FGStorage } from '@co2-storage/js-api' 2 | 3 | const authType = "pk" 4 | const ipfsNodeType = "client" 5 | //const ipfsNodeAddr = "/ip4/127.0.0.1/tcp/5001" 6 | //const fgApiUrl = "http://localhost:3020" 7 | const ipfsNodeAddr = "/dns4/web1.co2.storage/tcp/5002/https" 8 | const fgApiUrl = "https://web1.co2.storage" 9 | 10 | const fgStorage = new FGStorage({authType: authType, ipfsNodeType: ipfsNodeType, ipfsNodeAddr: ipfsNodeAddr, fgApiHost: fgApiUrl}) 11 | 12 | /** 13 | * Search templates 14 | * parameters: (chainName, phrases, cid, name, base, account, offset, limit, sortBy, sortDir) 15 | * // default data_chain: 'sandbox', phrases: null, cid: null, name: null, base: null, account: null, offset: 0, limit: 10 16 | */ 17 | 18 | let searchTemplatesResponse = await fgStorage.searchTemplates('sandbox') // ('SP Audits', 'Water') 19 | if(searchTemplatesResponse.error != null) { 20 | console.error(searchTemplatesResponse.error) 21 | await new Promise(reject => setTimeout(reject, 300)); 22 | process.exit() 23 | } 24 | 25 | console.dir(searchTemplatesResponse.result, {depth: null}) 26 | 27 | await new Promise(resolve => setTimeout(resolve, 1000)); 28 | 29 | // Exit program 30 | process.exit() 31 | -------------------------------------------------------------------------------- /cli/src/examples/serialize_dag_cbor.js: -------------------------------------------------------------------------------- 1 | import { FGStorage } from '@co2-storage/js-api' 2 | 3 | const authType = "pk" 4 | const ipfsNodeType = "client" 5 | //const ipfsNodeAddr = "/ip4/127.0.0.1/tcp/5001" 6 | //const fgApiUrl = "http://localhost:3020" 7 | const ipfsNodeAddr = "/dns4/web1.co2.storage/tcp/5002/https" 8 | const fgApiUrl = "https://web1.co2.storage" 9 | 10 | const fgStorage = new FGStorage({authType: authType, ipfsNodeType: ipfsNodeType, ipfsNodeAddr: ipfsNodeAddr, fgApiHost: fgApiUrl}) 11 | 12 | //const dagCbors = ["bafyreih4pji37htdhepzltpq6fifgdkwgb2l7yflm4if3pbwqwz6vi6k3q"] 13 | //const dagCbors = ["bafyreibxm2zsr66qotjh2vraapnukyrd4n6qvbwfxllwqpi7ssfzchgomu"] 14 | const dagCbors = ["bafyreibdvfxofhmoclyan6dvqzvuuzz57ezfuspcd3q3dm5w6xd2vwsysm"] 15 | 16 | try { 17 | const serialized = await fgStorage.serializeBacalhauJobInputs(dagCbors) 18 | console.log(serialized.result.toString()) 19 | // console.dir(serialized, {depth: null}) 20 | } catch (error) { 21 | console.log(error) 22 | } 23 | 24 | process.exit() -------------------------------------------------------------------------------- /cli/src/examples/sign_cid.js: -------------------------------------------------------------------------------- 1 | import { FGStorage } from '@co2-storage/js-api' 2 | 3 | const authType = "pk" 4 | const ipfsNodeType = "client" 5 | //const ipfsNodeAddr = "/ip4/127.0.0.1/tcp/5001" 6 | //const fgApiUrl = "http://localhost:3020" 7 | const ipfsNodeAddr = "/dns4/web1.co2.storage/tcp/5002/https" 8 | const fgApiUrl = "https://web1.co2.storage" 9 | 10 | const fgStorage = new FGStorage({authType: authType, ipfsNodeType: ipfsNodeType, ipfsNodeAddr: ipfsNodeAddr, fgApiHost: fgApiUrl}) 11 | 12 | /** 13 | * Sign CID 14 | * parameters: blockCid: string, callback: function(response) 15 | */ 16 | 17 | const cid = 'bafyreicakk2qxdwlx52l547jj3goez5horyslk6jprofr3k3dgwvnurwzm' 18 | const contributorName = 'Moca' 19 | const contributionLicense = 'CC0 (No Rights Reserved, Public Domain)' 20 | const contributionNote = 'Test note' 21 | const indexingDataChain = 'test' 22 | 23 | const response = await fgStorage.addProvenanceMessage(cid, contributorName, contributionLicense, contributionNote, indexingDataChain) 24 | 25 | console.dir(response, { depth: null }) 26 | 27 | await new Promise(resolve => setTimeout(resolve, 1000)) 28 | 29 | // Exit program 30 | process.exit() 31 | -------------------------------------------------------------------------------- /client/decarbonize.travel/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "sourceType": "unambiguous", 3 | "presets": ["@babel/preset-env"], 4 | "plugins": [ 5 | [ 6 | "@babel/plugin-transform-runtime", {} 7 | ] 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /client/decarbonize.travel/.env.example: -------------------------------------------------------------------------------- 1 | ESTUARY_API_KEY=... 2 | INFURA_API_KEY=... 3 | PK=0x... 4 | SYSTEM_PK=0x... 5 | COSMOS_PK=... -------------------------------------------------------------------------------- /client/decarbonize.travel/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Momcilo Dzunic 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /client/decarbonize.travel/README.md: -------------------------------------------------------------------------------- 1 | # form.co2.storage 2 | by [Momcilo Dzunic aka smartbee.eth](https://twitter.com/mdzunic) 3 | 4 | Simple co2.storage type/template previewer for easy asset creation. 5 | 6 | ### Demo 7 | 8 | [https://form.co2.storage/](https://form.co2.storage/) 9 | 10 | ### Use 11 | // clean dist 12 | npm run clean 13 | 14 | // build for production 15 | npm run build 16 | 17 | // run dev server with hot reload 18 | npm run start 19 | 20 | ### License 21 | Licensed under the MIT license. 22 | http://www.opensource.org/licenses/mit-license.php 23 | -------------------------------------------------------------------------------- /client/decarbonize.travel/assets/unverified.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/protocol/co2-storage/6e3794920177ee6ce926f2d2c095861a037d089d/client/decarbonize.travel/assets/unverified.png -------------------------------------------------------------------------------- /client/decarbonize.travel/assets/verified.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/protocol/co2-storage/6e3794920177ee6ce926f2d2c095861a037d089d/client/decarbonize.travel/assets/verified.png -------------------------------------------------------------------------------- /client/decarbonize.travel/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Decarbonize your travel 9 | 10 | 12 | 13 | 14 |
15 | 16 |
17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /client/decarbonize.travel/src/components/helpers/Header.vue: -------------------------------------------------------------------------------- 1 | 21 | 22 | 12 | 13 | 14 |
15 | 16 |
17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /client/form/src/components/helpers/Header.vue: -------------------------------------------------------------------------------- 1 | 21 | 22 | 11 | 12 | 13 |
14 | 15 |
16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /client/landing-page/src/components/helpers/Header.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | 12 | 13 | 14 |
15 | 16 |
17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /client/pipeline-inspector/src/components/helpers/Header.vue: -------------------------------------------------------------------------------- 1 | 22 | 23 | 12 | 13 | 14 |
15 | 16 |
17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /client/web/src/components/helpers/Contributor.vue: -------------------------------------------------------------------------------- 1 |