From 7b49435351f2742900ee1c99448af178dbc52853 Mon Sep 17 00:00:00 2001 From: Anna Topalidi <60363870+antopalidi@users.noreply.github.com> Date: Mon, 13 May 2024 14:56:16 +0200 Subject: [PATCH] Credit renewal flow (#77) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add census type radio buttons * fix lint * fix transformLocales * createion elections with cencus permissions * add batch queue * add verification methods for voting * remove whenever, add info to readme * update the vocdoni census after delete authorization * add internal_census field * change readme * change views vote * add helper method * add modal window, add internal census logic to voting * add loginModal * fix login modal, fix wallet generation * create election without verification_types * create election without voters * fix erb linter * refactoring, add system tests for internsl census * change titles in census form * fix preview, fix tests * fix missink keys * fix use doublequote quotes * add spec for job * fic create internal command, add tests * add spec for cell * add spec for form * add spec for controller * add spec for AuthorizationsData model * add spec for AuthorizationExtensions * add system test for vote online * fix lint * add spec for voter model * remove the unnecessary method * fix new-vote.js * fix CensusPermissionsForm * update ruby * add wrapper for node * Use a Sdk service for running sdk actions * clean js * add election to sdk runner * fix create wallet test * update create census test * create an election from the backend * Create the election using node * normalize locales * fix wizard test * make tests deterministic * fix factories * start elections * use values for results * remove unused test * fix erb file * fix unit tests * fix syntac error * fix more tests * fix tests * fix tests * fix tests * fix wrong method for translated * avoid external library * better management of the case auto_start * fix test * debug sdk * prevent comunitaction with api * add the test log to artifacts * use expect to wait for ajax * handle & update results * message acording election start mode * linting * Merge node-wrapper branch * remove js * fix npm lint * fix rubocop * fix census controller * fix test * change census view * change voter_verified? * change voter_verified? * fix voter_verified? for empty required_authorizations * update sdk * Refactor deterministicWallet method to align with JS implementation and enhance security * fix tests * fix test * fix updating of voting statistics * change logic: creating technical_voter when no one is authorized for selected authorization types; add spec * fix test * Update README.md Co-authored-by: Ivan Vergés * Update README.md Co-authored-by: Ivan Vergés * fix translata of authorizations handler_name * Save the census wallet for later use. Allow to send updated census * test script for census change * fix test using mjs for node wrapper * fix script * script working * update census job, add information on the need to update the census * add census traking * fix non_voters method, fix job * fix job * refactor the job, add new services * fix rubocop, locale * npm update, fix BigInt * fix erblint * refactor steps controller, add flash, permissions * change chrome version for test * change chrome version for test * change chrome version for test * change chrome version for test * change chromedriver version for test * change chromedriver version 121 for test * change chromedriver version 121 for test * fix tests * add tests * fix locale keys * update chromedriver config * add ajax for update census info * Add text to the voting page when the voter is not yet listed in the census * fix translate missing * fix tests * delete test * fix erb lint * remove the code * fix ajax * add tests * improve census view * fix tests * fix tests * change massage in the setup form for internal census * improve the census update view * replace flash message to ajax * change texts for check census * add helpers * add helper methods * remove code * remove code * remove migration, remove AuthorizationsData * delete override * destroy tech voter after census update * fix test * fix ajax: update census * fix erb linter * ensure user is redirected to where the action started * change the users context for the internal census form Co-authored-by: Ivan Vergés * refactoring VotesController * change text for update census result * remove cron task * Update README.md Co-authored-by: Ivan Vergés * add DECIDIM_COMPAT_VERSION Co-authored-by: Ivan Vergés * update gemspec * refactoring: dynamic_census attribute is not used * add custom version number, add info to readme * bundle * add credit renewal flow, add tests * add comments * fix erb linter, fix test * add test * remove migrations * remove api_endpoint_env method * remove btn for propd env * update instructions and provider * fix specs * rubocop --------- Co-authored-by: Ivan Vergés --- Gemfile | 2 +- Gemfile.lock | 185 ++++++------ README.md | 33 ++- .../admin/decidim_vocdoni_admin.js | 1 + .../src/decidim/vocdoni/admin/steps/vote.js | 1 + .../src/decidim/vocdoni/voter/setup-vote.js | 2 +- .../admin/steps/_available_credits.html.erb | 44 ++- config/locales/en.yml | 10 + lib/decidim/vocdoni.rb | 18 +- lib/decidim/vocdoni/version.rb | 2 +- lib/tasks/vocdoni_upgrade_tasks.rake | 13 + node-wrapper/node_runner.js | 2 +- package-lock.json | 272 +++--------------- package.json | 13 +- .../vocdoni/election_published_event_spec.rb | 6 +- .../lib/decidim/vocdoni/module_config_spec.rb | 12 +- .../vocdoni/census_updater_service_spec.rb | 1 - spec/services/decidim/vocdoni/sdk_spec.rb | 2 +- .../admin/admin_creates_wallet_spec.rb | 34 +++ 19 files changed, 281 insertions(+), 372 deletions(-) create mode 100644 lib/tasks/vocdoni_upgrade_tasks.rake diff --git a/Gemfile b/Gemfile index a0315a03..c7b3d5e3 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ source "https://rubygems.org" ruby RUBY_VERSION -DECIDIM_VERSION = "0.27.5" +DECIDIM_VERSION = "0.27.6" gem "decidim", DECIDIM_VERSION gem "decidim-vocdoni", path: "." diff --git a/Gemfile.lock b/Gemfile.lock index d20f5fb8..edccc2f7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -75,7 +75,7 @@ GEM addressable (2.8.6) public_suffix (>= 2.0.2, < 6.0) ast (2.4.2) - axe-core-api (4.8.1) + axe-core-api (4.9.0) dumb_delegator virtus axe-core-rspec (4.1.0) @@ -97,7 +97,7 @@ GEM html_tokenizer (~> 0.0.6) parser (>= 2.4) smart_properties - bigdecimal (3.1.6) + bigdecimal (3.1.8) bindex (0.8.1) bootsnap (1.18.3) msgpack (~> 1.2) @@ -133,7 +133,7 @@ GEM actionpack (>= 5.0) cells (>= 4.1.6, < 5.0.0) charlock_holmes (0.7.7) - chef-utils (18.4.2) + chef-utils (18.4.12) concurrent-ruby childprocess (4.1.0) codecov (0.6.0) @@ -149,7 +149,7 @@ GEM coffee-script-source (1.12.2) commonmarker (0.23.10) concurrent-ruby (1.2.3) - crack (0.4.6) + crack (1.0.0) bigdecimal rexml crass (1.0.6) @@ -162,63 +162,63 @@ GEM db-query-matchers (0.10.0) activesupport (>= 4.0, < 7) rspec (~> 3.0) - decidim (0.27.5) - decidim-accountability (= 0.27.5) - decidim-admin (= 0.27.5) - decidim-api (= 0.27.5) - decidim-assemblies (= 0.27.5) - decidim-blogs (= 0.27.5) - decidim-budgets (= 0.27.5) - decidim-comments (= 0.27.5) - decidim-core (= 0.27.5) - decidim-debates (= 0.27.5) - decidim-forms (= 0.27.5) - decidim-generators (= 0.27.5) - decidim-meetings (= 0.27.5) - decidim-pages (= 0.27.5) - decidim-participatory_processes (= 0.27.5) - decidim-proposals (= 0.27.5) - decidim-sortitions (= 0.27.5) - decidim-surveys (= 0.27.5) - decidim-system (= 0.27.5) - decidim-templates (= 0.27.5) - decidim-verifications (= 0.27.5) - decidim-accountability (0.27.5) - decidim-comments (= 0.27.5) - decidim-core (= 0.27.5) - decidim-admin (0.27.5) + decidim (0.27.6) + decidim-accountability (= 0.27.6) + decidim-admin (= 0.27.6) + decidim-api (= 0.27.6) + decidim-assemblies (= 0.27.6) + decidim-blogs (= 0.27.6) + decidim-budgets (= 0.27.6) + decidim-comments (= 0.27.6) + decidim-core (= 0.27.6) + decidim-debates (= 0.27.6) + decidim-forms (= 0.27.6) + decidim-generators (= 0.27.6) + decidim-meetings (= 0.27.6) + decidim-pages (= 0.27.6) + decidim-participatory_processes (= 0.27.6) + decidim-proposals (= 0.27.6) + decidim-sortitions (= 0.27.6) + decidim-surveys (= 0.27.6) + decidim-system (= 0.27.6) + decidim-templates (= 0.27.6) + decidim-verifications (= 0.27.6) + decidim-accountability (0.27.6) + decidim-comments (= 0.27.6) + decidim-core (= 0.27.6) + decidim-admin (0.27.6) active_link_to (~> 1.0) - decidim-core (= 0.27.5) + decidim-core (= 0.27.6) devise (~> 4.7) devise-i18n (~> 1.2) devise_invitable (~> 2.0, >= 2.0.9) - decidim-api (0.27.5) + decidim-api (0.27.6) + decidim-core (= 0.27.6) graphql (~> 1.12, < 1.13) graphql-docs (~> 2.1.0) rack-cors (~> 1.0) - decidim-assemblies (0.27.5) - decidim-core (= 0.27.5) - decidim-blogs (0.27.5) - decidim-admin (= 0.27.5) - decidim-comments (= 0.27.5) - decidim-core (= 0.27.5) - decidim-budgets (0.27.5) - decidim-comments (= 0.27.5) - decidim-core (= 0.27.5) - decidim-comments (0.27.5) - decidim-core (= 0.27.5) + decidim-assemblies (0.27.6) + decidim-core (= 0.27.6) + decidim-blogs (0.27.6) + decidim-admin (= 0.27.6) + decidim-comments (= 0.27.6) + decidim-core (= 0.27.6) + decidim-budgets (0.27.6) + decidim-comments (= 0.27.6) + decidim-core (= 0.27.6) + decidim-comments (0.27.6) + decidim-core (= 0.27.6) redcarpet (~> 3.5, >= 3.5.1) - decidim-core (0.27.5) + decidim-core (0.27.6) active_link_to (~> 1.0) acts_as_list (~> 0.9) batch-loader (~> 1.2) browser (~> 2.7) - carrierwave (~> 2.2.1) + carrierwave (~> 2.2.5, >= 2.2.5) cells-erb (~> 0.1.0) cells-rails (~> 0.1.3) charlock_holmes (~> 0.7) date_validator (~> 0.12.0) - decidim-api (= 0.27.5) devise (~> 4.7) devise-i18n (~> 1.2) diffy (~> 3.3) @@ -234,7 +234,6 @@ GEM loofah (~> 2.19.0) mime-types (>= 1.16, < 4.0) mini_magick (~> 4.9) - mustache (~> 1.1.0) omniauth (~> 2.0) omniauth-facebook (~> 5.0) omniauth-google-oauth2 (~> 1.0) @@ -259,15 +258,15 @@ GEM webpacker (= 6.0.0.rc.5) webpush (~> 1.1) wisper (~> 2.0) - decidim-debates (0.27.5) - decidim-comments (= 0.27.5) - decidim-core (= 0.27.5) - decidim-dev (0.27.5) + decidim-debates (0.27.6) + decidim-comments (= 0.27.6) + decidim-core (= 0.27.6) + decidim-dev (0.27.6) axe-core-rspec (~> 4.1.0) byebug (~> 11.0) capybara (~> 3.24) db-query-matchers (~> 0.10.0) - decidim (= 0.27.5) + decidim (= 0.27.6) erb_lint (~> 0.0.35) factory_bot_rails (~> 4.8) i18n-tasks (~> 0.9.18) @@ -290,45 +289,44 @@ GEM w3c_rspec_validators (~> 0.3.0) webmock (~> 3.6) wisper-rspec (~> 1.0) - decidim-forms (0.27.5) - decidim-core (= 0.27.5) + decidim-forms (0.27.6) + decidim-core (= 0.27.6) wicked_pdf (~> 2.1) wkhtmltopdf-binary (~> 0.12) - decidim-generators (0.27.5) - decidim-core (= 0.27.5) - decidim-meetings (0.27.5) - decidim-core (= 0.27.5) - decidim-forms (= 0.27.5) + decidim-generators (0.27.6) + decidim-core (= 0.27.6) + decidim-meetings (0.27.6) + decidim-core (= 0.27.6) + decidim-forms (= 0.27.6) icalendar (~> 2.5) - decidim-pages (0.27.5) - decidim-core (= 0.27.5) - decidim-participatory_processes (0.27.5) - decidim-core (= 0.27.5) - decidim-proposals (0.27.5) - decidim-comments (= 0.27.5) - decidim-core (= 0.27.5) + decidim-pages (0.27.6) + decidim-core (= 0.27.6) + decidim-participatory_processes (0.27.6) + decidim-core (= 0.27.6) + decidim-proposals (0.27.6) + decidim-comments (= 0.27.6) + decidim-core (= 0.27.6) doc2text (~> 0.4.5) redcarpet (~> 3.5, >= 3.5.1) - decidim-sortitions (0.27.5) - decidim-admin (= 0.27.5) - decidim-comments (= 0.27.5) - decidim-core (= 0.27.5) - decidim-proposals (= 0.27.5) - decidim-surveys (0.27.5) - decidim-core (= 0.27.5) - decidim-forms (= 0.27.5) - decidim-templates (= 0.27.5) - decidim-system (0.27.5) + decidim-sortitions (0.27.6) + decidim-admin (= 0.27.6) + decidim-comments (= 0.27.6) + decidim-core (= 0.27.6) + decidim-proposals (= 0.27.6) + decidim-surveys (0.27.6) + decidim-core (= 0.27.6) + decidim-forms (= 0.27.6) + decidim-system (0.27.6) active_link_to (~> 1.0) - decidim-core (= 0.27.5) + decidim-core (= 0.27.6) devise (~> 4.7) devise-i18n (~> 1.2) devise_invitable (~> 2.0, >= 2.0.9) - decidim-templates (0.27.5) - decidim-core (= 0.27.5) - decidim-forms (= 0.27.5) - decidim-verifications (0.27.5) - decidim-core (= 0.27.5) + decidim-templates (0.27.6) + decidim-core (= 0.27.6) + decidim-forms (= 0.27.6) + decidim-verifications (0.27.6) + decidim-core (= 0.27.6) declarative-builder (0.1.0) declarative-option (< 0.2.0) declarative-option (0.1.0) @@ -347,8 +345,8 @@ GEM devise (>= 4.6) diff-lcs (1.5.1) diffy (3.4.2) - doc2text (0.4.6) - nokogiri (>= 1.13.2, < 1.15.0) + doc2text (0.4.7) + nokogiri (>= 1.13.2, < 1.17.0) rubyzip (~> 2.3.0) docile (1.4.0) doorkeeper (5.6.8) @@ -419,7 +417,7 @@ GEM html-pipeline (2.14.3) activesupport (>= 2) nokogiri (>= 1.4) - html_tokenizer (0.0.7) + html_tokenizer (0.0.8) htmlentities (4.3.4) i18n (1.14.1) concurrent-ruby (~> 1.0) @@ -442,7 +440,7 @@ GEM ruby-vips (>= 2.0.17, < 3) invisible_captcha (0.13.0) rails (>= 3.2.0) - json (2.7.1) + json (2.7.2) jwt (2.7.1) kaminari (1.2.2) activesupport (>= 4.1.0) @@ -502,7 +500,6 @@ GEM chef-utils msgpack (1.7.2) multi_xml (0.6.0) - mustache (1.1.1) net-http (0.4.1) uri net-imap (0.4.10) @@ -663,7 +660,7 @@ GEM rspec-html-matchers (0.9.4) nokogiri (~> 1) rspec (>= 3.0.0.a, < 4) - rspec-mocks (3.13.0) + rspec-mocks (3.13.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) rspec-rails (4.1.2) @@ -676,7 +673,7 @@ GEM rspec-support (~> 3.10) rspec-retry (0.6.2) rspec-core (> 3.3) - rspec-support (3.13.0) + rspec-support (3.13.1) rspec_junit_formatter (0.3.0) rspec-core (>= 2, < 4, != 2.12.0) rubocop (1.28.2) @@ -780,7 +777,7 @@ GEM activemodel (>= 6.0.0) bindex (>= 0.4.0) railties (>= 6.0.0) - webmock (3.20.0) + webmock (3.23.0) addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) @@ -795,11 +792,11 @@ GEM websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - wicked_pdf (2.7.0) + wicked_pdf (2.8.0) activesupport wisper (2.0.1) wisper-rspec (1.1.0) - wkhtmltopdf-binary (0.12.6.6) + wkhtmltopdf-binary (0.12.6.7) xpath (3.2.0) nokogiri (~> 1.8) zeitwerk (2.6.13) @@ -815,8 +812,8 @@ DEPENDENCIES bootsnap (~> 1.7) byebug (~> 11.0) codecov (~> 0.6.0) - decidim (= 0.27.5) - decidim-dev (= 0.27.5) + decidim (= 0.27.6) + decidim-dev (= 0.27.6) decidim-vocdoni! faker (~> 2.14) i18n-tasks (~> 0.9.37) @@ -832,4 +829,4 @@ RUBY VERSION ruby 3.0.6p216 BUNDLED WITH - 2.4.21 + 2.4.22 diff --git a/README.md b/README.md index 3881914c..88fc6181 100644 --- a/README.md +++ b/README.md @@ -33,18 +33,26 @@ gem "decidim-vocdoni", github: "decidim-vocdoni/decidim-module-vocdoni" And then execute: -```bash +``` bundle -bin/rails decidim_vocdoni:install:migrations -bin/rails decidim_vocdoni:webpacker:install +bin/rails decidim:upgrade bin/rails db:migrate ``` +> **EXPERTS ONLY** +> +> Under the hood, when running `bin/rails decidim:upgrade` the `decidim-vocdoni` gem will run the following (that can also be run manually if you consider): +> +> ```bash +> bin/rails decidim_vocdoni:install:migrations +> bin/rails decidim_vocdoni:webpacker:install +> ``` + Depending on your Decidim version, you can choose the corresponding version to ensure compatibility: | Version | Compatible Decidim versions | -|---|---| -| 1.x | 0.27.x | +|---------|-----------------------------| +| 1.x | 0.27.x | ## Cron based tasks @@ -84,11 +92,20 @@ So, ensure you have a working Node.js application accessible by the Decidim inst ```json { "dependencies": { - "@vocdoni/sdk": "^0.5.3" + "@vocdoni/sdk": "^0.8.0" } } ``` +## Pricing + +The usage of the Vocdoni platform has some economic costs, as its using a Blockchain. + +For using it in a production environment with guaranties, you may contact with the maintaners of this plugin [PokeCode](https://pokecode.net) asking for a pricing. Costs will vary depending on your census size and the number of elections you want to perform. + +As there could be other resellers and not only the PokeCode, this needs to be configured through the ENV +variables: VOCDONI_RESELLER_NAME, VOCDONI_RESELLER_EMAIL + ## Configuration By default, the module is configured to read the configuration from ENV variables. @@ -97,10 +114,12 @@ Currently, the following ENV variables are supported: | ENV variable | Description | Default value | | ------------ | ----------- |-------| -| VOCDONI_API_ENDPOINT_ENV | The environment of the Vocdoni API. Only two values are accepted: `dev`, `stg`. Read more on [Vocdoni SDK Usage Environment](https://github.com/vocdoni/vocdoni-sdk#environment) | `stg` | +| VOCDONI_API_ENDPOINT_ENV | The environment of the Vocdoni API. Only two values are accepted: `dev`, `stg`, `prod`. Read more on [Vocdoni SDK Usage Environment](https://github.com/vocdoni/vocdoni-sdk#environment) | `stg` | | VOCDONI_MINUTES_BEFORE_START | How many minutes should the setup be run before the election starts (when configured automatically) | `10` | | VOCDONI_MANUAL_START_DELAY | How many seconds after the action of starting an election manually people will be allowed to vote. Note that this time is needed in order to configure the election in the blockchain. You might want to increase it if communication with the Vocdoni API is slow. | `30` | | DECIDIM_VOCDONI_SDK_DEBUG | This is for development purposes. If set to `true`, any call to the Vocdoni API using the SDK ruby wrapper will be logged into the `node_debug.log` file (on the application main folder). | `false` | +| VOCDONI_RESELLER_NAME | The name of the Vocdoni reseller, the organization that manages the tokens to work with the Vocdoni platform. | `PokeCode SL` | +| VOCDONI_RESELLER_EMAIL | The email of the Vocdoni reseller. | vocdoni@pokecode.net | It is also possible to configure the module using the `decidim-vocdoni` initializer: diff --git a/app/packs/entrypoints/admin/decidim_vocdoni_admin.js b/app/packs/entrypoints/admin/decidim_vocdoni_admin.js index f6a33285..40381013 100644 --- a/app/packs/entrypoints/admin/decidim_vocdoni_admin.js +++ b/app/packs/entrypoints/admin/decidim_vocdoni_admin.js @@ -6,6 +6,7 @@ import "src/decidim/vocdoni/admin/steps/election_status" import "src/decidim/vocdoni/admin/steps/vote" import "src/decidim/vocdoni/admin/steps/results" import "src/decidim/vocdoni/admin/steps/update_census" +import "src/decidim/clipboard" // Images require.context("../../images", true) diff --git a/app/packs/src/decidim/vocdoni/admin/steps/vote.js b/app/packs/src/decidim/vocdoni/admin/steps/vote.js index b53a5f0a..974d783f 100644 --- a/app/packs/src/decidim/vocdoni/admin/steps/vote.js +++ b/app/packs/src/decidim/vocdoni/admin/steps/vote.js @@ -4,6 +4,7 @@ const WAIT_TIME_MS = 30000; // Fetch the votes from the API export const getElectionResults = async () => { const vocdoniClientElement = document.querySelector(".js-vocdoni-client"); + if (!vocdoniClientElement || !vocdoniClientElement.dataset.resultsPath) { return null; } diff --git a/app/packs/src/decidim/vocdoni/voter/setup-vote.js b/app/packs/src/decidim/vocdoni/voter/setup-vote.js index 89b3f67a..9b64d02d 100644 --- a/app/packs/src/decidim/vocdoni/voter/setup-vote.js +++ b/app/packs/src/decidim/vocdoni/voter/setup-vote.js @@ -32,7 +32,7 @@ const submitVote = async (options) => { // TODO: we should pinpoint what exactly is the culprit of this issue // and if it's a bug in the SDK, we should fix it there switch (options.env) { - case "prd": + case "prod": client.url = "https://api.vocdoni.io/v2"; break; case "stg": diff --git a/app/views/decidim/vocdoni/admin/steps/_available_credits.html.erb b/app/views/decidim/vocdoni/admin/steps/_available_credits.html.erb index 737b45a0..9fe72263 100644 --- a/app/views/decidim/vocdoni/admin/steps/_available_credits.html.erb +++ b/app/views/decidim/vocdoni/admin/steps/_available_credits.html.erb @@ -1,8 +1,8 @@

- <%= icon "credit-card", role: "img", "aria-hidden": true %>  - <%= t("available", scope: "decidim.vocdoni.admin.steps.credits") %>:  - + <%= icon "credit-card", role: "img", "aria-hidden": true %>  + <%= t("available", scope: "decidim.vocdoni.admin.steps.credits") %>:  +

@@ -12,19 +12,47 @@

- <%= t("warning", scope: "decidim.vocdoni.admin.steps.credits") %> + <%= t("warning", scope: "decidim.vocdoni.admin.steps.credits") %>

- <% unless Decidim::Vocdoni.api_endpoint_env == "prd" %> + <% if Decidim::Vocdoni.api_endpoint_env == "prod" %> +
+

+ <%= t("decidim.vocdoni.admin.steps.credits.prod_mode_html", + reseller_name: Decidim::Vocdoni.vocdoni_reseller_name, + reseller_email: Decidim::Vocdoni.vocdoni_reseller_email, + wallet_address: @current_vocdoni_wallet.private_key).html_safe %> +

+
+ +
+ +
+
+
+ <% else %>

<%= t("dev_mode", scope: "decidim.vocdoni.admin.steps.credits", env: "#{Decidim::Vocdoni.api_endpoint_env}").html_safe %>

<% end %> - <%= link_to credits_election_path(election), method: :remote, class: "button primary js-vocdoni-credits-collect-faucet-tokens" do %> - <%= icon "euro", role: "img", "aria-hidden": true %>  - <%= t("get_more", scope: "decidim.vocdoni.admin.steps.credits") %> + <% unless Decidim::Vocdoni.api_endpoint_env == "prod" %> + <%= link_to credits_election_path(election), method: :remote, class: "button primary js-vocdoni-credits-collect-faucet-tokens" do %> + <%= icon "euro", role: "img", "aria-hidden": true %>  + <%= t("get_more", scope: "decidim.vocdoni.admin.steps.credits") %> + <% end %> <% end %>
diff --git a/config/locales/en.yml b/config/locales/en.yml index ff2bde99..962d461e 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -293,9 +293,19 @@ en: view: View landing page credits: available: Available credits + copied: Copied! + copy_wallet: Copy wallet address + copy_wallet_clarification: Copy wallet address to clipboard + copy_wallet_message: The wallet address has been successfully copied to + clipboard. dev_mode: You are using Vocdoni in the %{env} environment. It is possible to collect credits for free (without any warranty) get_more: Get more credits + prod_mode_html: 'The usage of the Vocdoni platform has costs. Please get + in touch with %{reseller_name} + to ask for a quote. You need to also tell them your organization address:' warning: You have no credits left. You can get more credits by clicking on the button below. danger_zone: diff --git a/lib/decidim/vocdoni.rb b/lib/decidim/vocdoni.rb index 126705b7..bd420e2e 100644 --- a/lib/decidim/vocdoni.rb +++ b/lib/decidim/vocdoni.rb @@ -14,7 +14,7 @@ module Vocdoni # Hash constant defining the Vocdoni API endpoints for each environment. API_ENDPOINTS = { - "prd" => "https://api.vocdoni.net/v2", + "prod" => "https://api.vocdoni.io/v2", "stg" => "https://api-stg.vocdoni.net/v2", "dev" => "https://api-dev.vocdoni.net/v2" }.freeze @@ -49,15 +49,19 @@ module Vocdoni true end - # Public: Returns the API endpoint URL based on the environment specified in the configuration. - def self.api_endpoint_url - API_ENDPOINTS[api_endpoint_env] + # Public: Setting to configure the reseller name + config_accessor :vocdoni_reseller_name do + ENV.fetch("VOCDONI_RESELLER_NAME", "PokeCode SL") end - def self.api_endpoint_env - return "stg" if config.api_endpoint_env.downcase == "stg" + # Public: Setting to configure the reseller email + config_accessor :vocdoni_reseller_email do + ENV.fetch("VOCDONI_RESELLER_EMAIL", "vocdoni@pokecode.net") + end - "dev" + # Public: Returns the API endpoint URL based on the environment specified in the configuration. + def self.api_endpoint_url + API_ENDPOINTS[api_endpoint_env] end def self.explorer_vote_domain diff --git a/lib/decidim/vocdoni/version.rb b/lib/decidim/vocdoni/version.rb index 7306d635..4db19d26 100644 --- a/lib/decidim/vocdoni/version.rb +++ b/lib/decidim/vocdoni/version.rb @@ -3,7 +3,7 @@ module Decidim # This holds the decidim-meetings version. module Vocdoni - DECIDIM_VERSION = "0.27.5" + DECIDIM_VERSION = "0.27.6" DECIDIM_COMPAT_VERSION = ">= 0.27" def self.version diff --git a/lib/tasks/vocdoni_upgrade_tasks.rake b/lib/tasks/vocdoni_upgrade_tasks.rake new file mode 100644 index 00000000..b345b963 --- /dev/null +++ b/lib/tasks/vocdoni_upgrade_tasks.rake @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +Rake::Task["decidim:webpacker:install"].enhance do + Rake::Task["decidim_vocdoni:webpacker:install"].invoke +end + +Rake::Task["decidim:choose_target_plugins"].enhance do + ENV["FROM"] = "#{ENV.fetch("FROM", nil)},decidim_vocdoni" +end + +Rake::Task["decidim:webpacker:upgrade"].enhance do + Rake::Task["decidim_vocdoni:webpacker:install"].invoke +end diff --git a/node-wrapper/node_runner.js b/node-wrapper/node_runner.js index 3874eb95..dde20314 100644 --- a/node-wrapper/node_runner.js +++ b/node-wrapper/node_runner.js @@ -6,7 +6,7 @@ * */ try { const args = #{args} - Promise.resolve(#{func}(...args)).then(result => { + Promise.resolve(#{func}(...args)).then(result => { const output = JSON.stringify(['ok', result, []]) process.stdout.write(output) }) diff --git a/package-lock.json b/package-lock.json index cfce48b5..8249c5d3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "decidim-vocdoni", - "version": "0.27.5", + "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "decidim-vocdoni", - "version": "0.27.5", + "version": "1.0.0", "license": "AGPL-3.0", "dependencies": { - "@vocdoni/sdk": "0.7.3" + "@vocdoni/sdk": "0.8.0" }, "devDependencies": { "@babel/eslint-parser": "^7.19.1", @@ -21,15 +21,14 @@ "@babel/plugin-transform-runtime": "^7.19.6", "@babel/preset-env": "^7.20.2", "@babel/preset-react": "^7.18.6", - "@decidim/dev": "0.27.5", - "@decidim/eslint-config": "0.27.5", - "@decidim/stylelint-config": "0.27.5", + "@decidim/dev": "0.27.6", + "@decidim/eslint-config": "0.27.6", + "@decidim/stylelint-config": "0.27.6", "eslint-config-prettier": "^8.5.0", "eslint-config-standard": "^11.0.0", "eslint-plugin-import": "^2.22.0", "eslint-plugin-standard": "^3.1.0", "sass-embedded": "~1.57.1", - "snarkjs": "vocdoni/snarkjs#v0.7.0-groth16browser", "web-worker": "1.2.0" } }, @@ -1906,18 +1905,18 @@ } }, "node_modules/@decidim/dev": { - "version": "0.27.5", - "resolved": "https://registry.npmjs.org/@decidim/dev/-/dev-0.27.5.tgz", - "integrity": "sha512-+UiXYQAzNc3uDecTaWNA05hCAqpB7QjnxEGXnLGl9mo0jx7qn8SMMjOmlIi7VhIXOLIXDHcaDunTOUVvKwu4ug==", + "version": "0.27.6", + "resolved": "https://registry.npmjs.org/@decidim/dev/-/dev-0.27.6.tgz", + "integrity": "sha512-dDCVCEXTCzmB113rN/AXcG5KWHZzcFPRM9DmRUKqP2b6gySfe79RLt3/blZs8l22167QxM/Fqjr3UrtuDIxyvQ==", "dev": true, "dependencies": { "axe-core": "^4.1.4" } }, "node_modules/@decidim/eslint-config": { - "version": "0.27.5", - "resolved": "https://registry.npmjs.org/@decidim/eslint-config/-/eslint-config-0.27.5.tgz", - "integrity": "sha512-DUX+2HlpLFJtupZ/mdscNBwIh/Se35wJ5mWyeOuW0rqTAP0beh+09+iUzCLkBjlaqwvt8TyLeYjiWFj37roYrQ==", + "version": "0.27.6", + "resolved": "https://registry.npmjs.org/@decidim/eslint-config/-/eslint-config-0.27.6.tgz", + "integrity": "sha512-tmYhIbrSPBoWwDopFkZP1BejqHhZPHAvAjJh0wxOhXWTqQZ9l3qgFy+E0hW14CnsKgQ46lGXkI5D2gxS+VvMmg==", "dev": true, "peerDependencies": { "eslint": "^7.25.0", @@ -1932,9 +1931,9 @@ } }, "node_modules/@decidim/stylelint-config": { - "version": "0.27.5", - "resolved": "https://registry.npmjs.org/@decidim/stylelint-config/-/stylelint-config-0.27.5.tgz", - "integrity": "sha512-kvYWcEUniL+rtRXm+EIy6k9G8eXTuCv5oQKetlEruTAV2Q0KSZCo/1HVfKYIPA5gOeQ8JYDZ6XN7vk7MifEumQ==", + "version": "0.27.6", + "resolved": "https://registry.npmjs.org/@decidim/stylelint-config/-/stylelint-config-0.27.6.tgz", + "integrity": "sha512-qcHP1rR3GOLFN0uggKk6gg371dhLCTDDNgDWD0dtFvlDuBxchh0QfHJ+PBZpNDeG3h6tVPOq5ruLhUIC3UWG8w==", "dev": true, "peerDependencies": { "stylelint": "13.11.0" @@ -2862,9 +2861,9 @@ "peer": true }, "node_modules/@types/node": { - "version": "20.11.16", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.16.tgz", - "integrity": "sha512-gKb0enTmRCzXSSUJDq6/sPcqrfCv2mkkG6Jt/clpn5eiCbKTY+SgZUxo+p8ZKMof5dCp9vHQUAB7wOUTod22wQ==", + "version": "20.12.11", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.11.tgz", + "integrity": "sha512-vDg9PZ/zi+Nqp6boSOT7plNuthRugEKixDv5sFTIpkE89MmNtEArAShI4mxuX2+UrLEe9pxC1vm2cjm9YlWbJw==", "dependencies": { "undici-types": "~5.26.4" } @@ -2891,18 +2890,18 @@ "peer": true }, "node_modules/@vocdoni/proto": { - "version": "1.15.4", - "resolved": "https://registry.npmjs.org/@vocdoni/proto/-/proto-1.15.4.tgz", - "integrity": "sha512-UbIMfRjSGdQdmOEBTVR1LnvqabVBF8TDpI44V+AC0oCn/E6WRo3y8zgGXKZw00SbqCGkFKvqTyWRvsK5Rky1qA==", + "version": "1.15.5", + "resolved": "https://registry.npmjs.org/@vocdoni/proto/-/proto-1.15.5.tgz", + "integrity": "sha512-6Tm8aluCbz10gsVLnyFnsOM7dfFMFD3w8fmG26RQh9fFZJ6eLOf3FKKXC6nlMm3x6a6pKXHEFvT89ePks0WMNA==", "dependencies": { "long": "^5.2.1", "protobufjs": "^7.1.2" } }, "node_modules/@vocdoni/sdk": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/@vocdoni/sdk/-/sdk-0.7.3.tgz", - "integrity": "sha512-PQy63OU+hh1qhydPEkC5+9fmn46WyH9eQtgOUGysWWt6hsHW3bBqLBuhml/ZBkakFDYyECGJeFApWg7n69muPA==", + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/@vocdoni/sdk/-/sdk-0.8.0.tgz", + "integrity": "sha512-Kj2RG7b8Ifdspf1r9gcwPdtExojFzkhZg9l35mPRp2VD3P82QtMl1DDbDlRwSZ4ajSHkXH2dWgUZ0KKJH75ySg==", "dependencies": { "@ethersproject/abstract-signer": "^5.7.0", "@ethersproject/address": "^5.7.0", @@ -2915,7 +2914,7 @@ "@ethersproject/units": "^5.7.0", "@ethersproject/wallet": "^5.7.0", "@size-limit/file": "^8.2.4", - "@vocdoni/proto": "1.15.4", + "@vocdoni/proto": "1.15.5", "axios": "0.27.2", "blake2b": "^2.1.4", "iso-language-codes": "^1.1.0", @@ -3404,22 +3403,6 @@ "resolved": "https://registry.npmjs.org/bech32/-/bech32-1.1.4.tgz", "integrity": "sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ==" }, - "node_modules/bfj": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/bfj/-/bfj-7.1.0.tgz", - "integrity": "sha512-I6MMLkn+anzNdCUp9hMRyui1HaNEUCco50lxbvNS4+EyXg8lN3nJ48PjPWtbH8UVS9CuMoaKE9U2V3l29DaRQw==", - "dev": true, - "dependencies": { - "bluebird": "^3.7.2", - "check-types": "^11.2.3", - "hoopy": "^0.1.4", - "jsonpath": "^1.1.1", - "tryer": "^1.0.1" - }, - "engines": { - "node": ">= 8.0.0" - } - }, "node_modules/binary-extensions": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", @@ -3447,12 +3430,6 @@ "nanoassert": "^2.0.0" } }, - "node_modules/bluebird": { - "version": "3.7.2", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", - "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==", - "dev": true - }, "node_modules/bn.js": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", @@ -3678,12 +3655,6 @@ "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/check-types": { - "version": "11.2.3", - "resolved": "https://registry.npmjs.org/check-types/-/check-types-11.2.3.tgz", - "integrity": "sha512-+67P1GkJRaxQD6PKK0Et9DhwQB+vGg3PM5+aavopCpZT1lj9jeqfvpgTLAWErNj8qApkkmXlu/Ug74kmhagkXg==", - "dev": true - }, "node_modules/chokidar": { "version": "3.5.3", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", @@ -3711,18 +3682,6 @@ "fsevents": "~2.3.2" } }, - "node_modules/circom_runtime": { - "version": "0.1.23", - "resolved": "https://registry.npmjs.org/circom_runtime/-/circom_runtime-0.1.23.tgz", - "integrity": "sha512-S0A63qM5LtlcTgsHX4z/U6nWAKo/KQBrz4umxVMyADPHxt6qDWy2AahPc2lAWQT42cFIDuonFPjgCjviSgQU8A==", - "dev": true, - "dependencies": { - "ffjavascript": "0.2.59" - }, - "bin": { - "calcwit": "calcwit.js" - } - }, "node_modules/clone-regexp": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/clone-regexp/-/clone-regexp-2.2.0.tgz", @@ -3898,7 +3857,8 @@ "version": "0.1.4", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", - "dev": true + "dev": true, + "peer": true }, "node_modules/define-data-property": { "version": "1.1.2", @@ -4249,88 +4209,6 @@ "node": ">=0.8.0" } }, - "node_modules/escodegen": { - "version": "1.14.3", - "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.14.3.tgz", - "integrity": "sha512-qFcX0XJkdg+PB3xjZZG/wKSuT1PnQWx57+TVSjIMmILd2yC/6ByYElPwJnslDsuWuSAp4AwJGumarAAmJch5Kw==", - "dev": true, - "dependencies": { - "esprima": "^4.0.1", - "estraverse": "^4.2.0", - "esutils": "^2.0.2", - "optionator": "^0.8.1" - }, - "bin": { - "escodegen": "bin/escodegen.js", - "esgenerate": "bin/esgenerate.js" - }, - "engines": { - "node": ">=4.0" - }, - "optionalDependencies": { - "source-map": "~0.6.1" - } - }, - "node_modules/escodegen/node_modules/estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", - "dev": true, - "engines": { - "node": ">=4.0" - } - }, - "node_modules/escodegen/node_modules/levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha512-0OO4y2iOHix2W6ujICbKIaEQXvFQHue65vUG3pb5EUomzPI90z9hsA1VsO/dbIIpC53J8gxM9Q4Oho0jrCM/yA==", - "dev": true, - "dependencies": { - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/escodegen/node_modules/optionator": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", - "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", - "dev": true, - "dependencies": { - "deep-is": "~0.1.3", - "fast-levenshtein": "~2.0.6", - "levn": "~0.3.0", - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2", - "word-wrap": "~1.2.3" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/escodegen/node_modules/prelude-ls": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w==", - "dev": true, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/escodegen/node_modules/type-check": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha512-ZCmOJdvOWDBYJlzAoFkC+Q0+bUyEOS1ltgp1MGU03fqHG+dbi9tBFU2Rd9QKiDZFAYrhPh2JUf7rZRIuHRKtOg==", - "dev": true, - "dependencies": { - "prelude-ls": "~1.1.2" - }, - "engines": { - "node": ">= 0.8.0" - } - }, "node_modules/eslint": { "version": "7.32.0", "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.32.0.tgz", @@ -4936,6 +4814,7 @@ "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", "dev": true, + "peer": true, "bin": { "esparse": "bin/esparse.js", "esvalidate": "bin/esvalidate.js" @@ -5057,7 +4936,8 @@ "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", - "dev": true + "dev": true, + "peer": true }, "node_modules/fastest-levenshtein": { "version": "1.0.16", @@ -5078,17 +4958,6 @@ "reusify": "^1.0.4" } }, - "node_modules/ffjavascript": { - "version": "0.2.59", - "resolved": "https://registry.npmjs.org/ffjavascript/-/ffjavascript-0.2.59.tgz", - "integrity": "sha512-QssOEUv+wilz9Sg7Zaj6KWAm7QceOAEsFuEBTltUsDo1cjn11rA/LGYvzFBPbzNfxRlZxwgJ7uxpCQcdDlrNfw==", - "dev": true, - "dependencies": { - "wasmbuilder": "0.0.16", - "wasmcurves": "0.2.1", - "web-worker": "^1.2.0" - } - }, "node_modules/file-entry-cache": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", @@ -5577,15 +5446,6 @@ "minimalistic-crypto-utils": "^1.0.1" } }, - "node_modules/hoopy": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/hoopy/-/hoopy-0.1.4.tgz", - "integrity": "sha512-HRcs+2mr52W0K+x8RzcLzuPPmVIKMSv97RGHy0Ea9y/mpcaK+xTrjICA04KAHi4GRzxliNqNJEFYWHghy3rSfQ==", - "dev": true, - "engines": { - "node": ">= 6.0.0" - } - }, "node_modules/hosted-git-info": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-4.1.0.tgz", @@ -6350,30 +6210,6 @@ "node": ">=6" } }, - "node_modules/jsonpath": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/jsonpath/-/jsonpath-1.1.1.tgz", - "integrity": "sha512-l6Cg7jRpixfbgoWgkrl77dgEj8RPvND0wMH6TwQmi9Qs4TFfS9u5cUFnbeKTwj5ga5Y3BTGGNI28k117LJ009w==", - "dev": true, - "dependencies": { - "esprima": "1.2.2", - "static-eval": "2.0.2", - "underscore": "1.12.1" - } - }, - "node_modules/jsonpath/node_modules/esprima": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-1.2.2.tgz", - "integrity": "sha512-+JpPZam9w5DuJ3Q67SqsMGtiHKENSMRVoxvArfJZK01/BfLEObtZ6orJa/MtoGNR/rfMgp5837T41PAmTwAv/A==", - "dev": true, - "bin": { - "esparse": "bin/esparse.js", - "esvalidate": "bin/esvalidate.js" - }, - "engines": { - "node": ">=0.4.0" - } - }, "node_modules/jsx-ast-utils": { "version": "3.3.5", "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-3.3.5.tgz", @@ -7463,9 +7299,9 @@ "integrity": "sha512-SVtmxhRE/CGkn3eZY1T6pC8Nln6Fr/lu1mKSgRud0eC73whjGfoAogbn78LkD8aFL0zz3bAFerKSnOl7NlErBA==" }, "node_modules/protobufjs": { - "version": "7.2.6", - "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.2.6.tgz", - "integrity": "sha512-dgJaEDDL6x8ASUZ1YqWciTRrdOuYNzoOf27oHNfdyvKqHr5i0FV7FSLU+aIeFjyFgVxrpTOtQUi0BLLBymZaBw==", + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.3.0.tgz", + "integrity": "sha512-YWD03n3shzV9ImZRX3ccbjqLxj7NokGN0V/ESiBV5xWqrommYHYiihuIyavq03pWSGqlyvYUFmfoMKd+1rPA/g==", "hasInstallScript": true, "dependencies": { "@protobufjs/aspromise": "^1.1.2", @@ -8224,22 +8060,12 @@ "dev": true, "peer": true }, - "node_modules/snarkjs": { - "version": "0.7.0", - "resolved": "git+ssh://git@github.com/vocdoni/snarkjs.git#d6e37e9120e44b6681e32d8f552d4fec0f3e1b23", - "dev": true, - "license": "GPL-3.0", - "dependencies": { - "bfj": "^7.0.2", - "circom_runtime": "0.1.23", - "ffjavascript": "0.2.59" - } - }, "node_modules/source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -8297,15 +8123,6 @@ "dev": true, "peer": true }, - "node_modules/static-eval": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/static-eval/-/static-eval-2.0.2.tgz", - "integrity": "sha512-N/D219Hcr2bPjLxPiV+TQE++Tsmrady7TqAJugLy7Xk1EumfDWS/f5dtBbkRCGE7wKKXuYockQoj8Rm2/pVKyg==", - "dev": true, - "dependencies": { - "escodegen": "^1.8.1" - } - }, "node_modules/string_decoder": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", @@ -8761,12 +8578,6 @@ "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/tryer": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/tryer/-/tryer-1.0.1.tgz", - "integrity": "sha512-c3zayb8/kWWpycWYg87P71E1S1ZL6b6IJxfb5fvsUgsf0S2MVGaDhDXXjDMpdCpfWXqptc+4mXwmiy1ypXqRAA==", - "dev": true - }, "node_modules/tsconfig-paths": { "version": "3.15.0", "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.15.0.tgz", @@ -8918,12 +8729,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/underscore": { - "version": "1.12.1", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.12.1.tgz", - "integrity": "sha512-hEQt0+ZLDVUMhebKxL4x1BTtDY7bavVofhZ9KZ4aI26X9SRaE+Y3m83XUL1UP2jn8ynjndwCCpEHdUG+9pP1Tw==", - "dev": true - }, "node_modules/undici-types": { "version": "5.26.5", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", @@ -9246,15 +9051,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/word-wrap": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", - "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", diff --git a/package.json b/package.json index 6c308be3..52e0ecc0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "decidim-vocdoni", - "version": "0.27.5", + "version": "1.0.0", "description": "An elections component for decidim's participatory spaces based on the Vocdoni SDK", "main": "index.js", "directories": { @@ -36,18 +36,17 @@ "@babel/plugin-transform-runtime": "^7.19.6", "@babel/preset-env": "^7.20.2", "@babel/preset-react": "^7.18.6", - "@decidim/dev": "0.27.5", - "@decidim/eslint-config": "0.27.5", - "@decidim/stylelint-config": "0.27.5", + "@decidim/dev": "0.27.6", + "@decidim/eslint-config": "0.27.6", + "@decidim/stylelint-config": "0.27.6", "eslint-config-prettier": "^8.5.0", "eslint-config-standard": "^11.0.0", "eslint-plugin-import": "^2.22.0", "eslint-plugin-standard": "^3.1.0", "sass-embedded": "~1.57.1", - "web-worker": "1.2.0", - "snarkjs": "vocdoni/snarkjs#v0.7.0-groth16browser" + "web-worker": "1.2.0" }, "dependencies": { - "@vocdoni/sdk": "0.7.3" + "@vocdoni/sdk": "0.8.0" } } diff --git a/spec/events/decidim/vocdoni/election_published_event_spec.rb b/spec/events/decidim/vocdoni/election_published_event_spec.rb index 1f215597..3b7791a1 100644 --- a/spec/events/decidim/vocdoni/election_published_event_spec.rb +++ b/spec/events/decidim/vocdoni/election_published_event_spec.rb @@ -6,11 +6,13 @@ include_context "when a simple event" let(:event_name) { "decidim.events.vocdoni.election_published" } - let(:resource) { create(:vocdoni_election) } + let(:participatory_space) { create(:participatory_process, :with_steps, title: { en: "A participatory process" }) } + let(:component) { create(:vocdoni_component, participatory_space: participatory_space) } + let(:resource) { create(:vocdoni_election, component: component) } let(:participatory_space_title) { resource.participatory_space.title["en"] } let(:resource_title) { resource.title["en"] } - it_behaves_like "a simple event" + it_behaves_like "a simple event", skip_space_checks: true describe "email_subject" do it "is generated correctly" do diff --git a/spec/lib/decidim/vocdoni/module_config_spec.rb b/spec/lib/decidim/vocdoni/module_config_spec.rb index 6108b322..f519a17b 100644 --- a/spec/lib/decidim/vocdoni/module_config_spec.rb +++ b/spec/lib/decidim/vocdoni/module_config_spec.rb @@ -10,6 +10,8 @@ module Decidim let(:env) do { "VOCDONI_MINUTES_BEFORE_START" => minutes, + "VOCDONI_RESELLER_NAME" => reseller_name, + "VOCDONI_RESELLER_EMAIL" => reseller_email, "DECIDIM_VOCDONI_VOTES_OVERWRITE_MAX" => votes_overwrite_max, "VOCDONI_API_ENDPOINT_ENV" => vocdoni_env, "VOCDONI_MANUAL_START_DELAY" => start_delay @@ -19,6 +21,8 @@ module Decidim let(:minutes) { "11" } let(:votes_overwrite_max) { "8" } let(:start_delay) { "33" } + let(:reseller_name) { "Test reseller" } + let(:reseller_email) { "test_reseller@example.org" } let(:config) { JSON.parse cmd_capture("bin/rails runner 'puts Decidim::Vocdoni.config.to_json'", env: env) } let(:endpoint_env) { cmd_capture("bin/rails runner 'puts Decidim::Vocdoni.api_endpoint_env'", env: env) } @@ -31,6 +35,8 @@ def cmd_capture(cmd, env: {}) it "has the correct configuration" do expect(config).to eq({ "minimum_minutes_before_start" => 11, + "vocdoni_reseller_email" => "test_reseller@example.org", + "vocdoni_reseller_name" => "Test reseller", "votes_overwrite_max" => 8, "api_endpoint_env" => "STG", "manual_start_time_delay" => 33, @@ -39,20 +45,20 @@ def cmd_capture(cmd, env: {}) end it "has the correct endpoint env" do - expect(endpoint_env.strip).to eq("stg") + expect(endpoint_env.strip).to eq("STG") end it "has the correct endpoint url" do expect(Decidim::Vocdoni::API_ENDPOINTS["stg"]).to eq("https://api-stg.vocdoni.net/v2") expect(Decidim::Vocdoni::API_ENDPOINTS["dev"]).to eq("https://api-dev.vocdoni.net/v2") - expect(Decidim::Vocdoni::API_ENDPOINTS["prd"]).to eq("https://api.vocdoni.net/v2") + expect(Decidim::Vocdoni::API_ENDPOINTS["prod"]).to eq("https://api.vocdoni.io/v2") end context "when enpoint is wrong" do let(:vocdoni_env) { "WRONG" } it "defaults to dev" do - expect(endpoint_env.strip).to eq("dev") + expect(endpoint_env.strip).to eq("WRONG") end end end diff --git a/spec/services/decidim/vocdoni/census_updater_service_spec.rb b/spec/services/decidim/vocdoni/census_updater_service_spec.rb index 8a76b64c..9c8efc64 100644 --- a/spec/services/decidim/vocdoni/census_updater_service_spec.rb +++ b/spec/services/decidim/vocdoni/census_updater_service_spec.rb @@ -34,7 +34,6 @@ expect(Rails.logger).not_to receive(:info).with(/Technical voter .* deleted successfully./) expect { service.update_census }.not_to raise_error - expect(Decidim::Vocdoni::Voter.where(email: election.technical_voter_email, election: election)).not_to exist end diff --git a/spec/services/decidim/vocdoni/sdk_spec.rb b/spec/services/decidim/vocdoni/sdk_spec.rb index e4c04986..7741d14a 100644 --- a/spec/services/decidim/vocdoni/sdk_spec.rb +++ b/spec/services/decidim/vocdoni/sdk_spec.rb @@ -86,7 +86,7 @@ module Vocdoni expect(subject.info).to eq({ "clientInfo" => { "address" => "7e5f4552091a69125d5dfcb7b8c2659029395bdf", - "balance" => 500, + "balance" => 10_000, "electionIndex" => 0, "metadata" => { "description" => { "default" => "" }, diff --git a/spec/system/decidim/admin/admin_creates_wallet_spec.rb b/spec/system/decidim/admin/admin_creates_wallet_spec.rb index dea9b799..d042b6e9 100644 --- a/spec/system/decidim/admin/admin_creates_wallet_spec.rb +++ b/spec/system/decidim/admin/admin_creates_wallet_spec.rb @@ -37,6 +37,40 @@ expect(page).to have_content("You are not authorized to perform this action") expect(Decidim::Vocdoni::Wallet.all.count).to eq 1 end + + context "when prod environment" do + before do + allow(Decidim::Vocdoni).to receive(:api_endpoint_env).and_return("prod") + allow(Decidim::Vocdoni).to receive(:vocdoni_reseller_name).and_return("Test reseller") + allow(Decidim::Vocdoni).to receive(:vocdoni_reseller_email).and_return("test_reseller@example.org") + end + + it "shows the information about receiving coins" do + visit_steps_page + + expect(page).to have_content("The usage of the Vocdoni platform has costs") + expect(page).to have_content("Test reseller") + expect(page).to have_css("input[value='#{wallet.private_key}']") + expected_href = "mailto:test_reseller@example.org?subject=Decidim Vocdoni Inquiry&body=Please provide a quote for the Vocdoni platform usage. My organization Vocdoni address is: 0x0000000000000000000000000000000000000000000000000000000000000001" + expect(page).to have_css("a[href='#{expected_href}']") + end + end + + context "when stg environment" do + before do + allow(Decidim::Vocdoni).to receive(:api_endpoint_env).and_return("stg") + allow(Decidim::Vocdoni).to receive(:vocdoni_reseller_name).and_return("Test reseller") + allow(Decidim::Vocdoni).to receive(:vocdoni_reseller_email).and_return("test_reseller@example.org") + end + + it "doesn't show the information about receiving coins" do + visit_steps_page + + expect(page).not_to have_content("The usage of the Vocdoni platform has costs") + expect(page).not_to have_content("Test reseller") + expect(page).not_to have_css("input[value='#{wallet.private_key}']") + end + end end def visit_steps_page