From 4543892507361af70255b2946a15c877626775e3 Mon Sep 17 00:00:00 2001 From: James-Mart Date: Fri, 6 Sep 2024 20:36:49 +0000 Subject: [PATCH 01/28] add cmake support for cargo-psibase packages --- CMakeLists.txt | 2 +- libraries/psibase/sdk/pack_service.cmake | 84 ++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 79dbc8d72..03e926240 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.16.3) +cmake_minimum_required(VERSION 3.20) cmake_policy(VERSION 3.16.3...3.25.1) project(psibase) include(ExternalProject) diff --git a/libraries/psibase/sdk/pack_service.cmake b/libraries/psibase/sdk/pack_service.cmake index 8c0f0d19e..acf647d44 100644 --- a/libraries/psibase/sdk/pack_service.cmake +++ b/libraries/psibase/sdk/pack_service.cmake @@ -306,3 +306,87 @@ function(psibase_package) ) add_custom_target(${_NAME} ALL DEPENDS ${_OUTPUT}) endfunction() + +# Description: - Use this function when you want to add additional details to a package that is +# built/managed by cargo-psibase, as opposed to packages built entirely using CMake. +# OUTPUT - [Required] The package file. +# PATH - [Required] The path to the cargo workspace (e.g. `services/user/Branding`). +# POSTINSTALL - [Optional] Additional actions that should be run at the end of installation (e.g. `services/user/Branding/postinstall.json`) +# UI - [Optional] A service to upload to, and a UI directory to build/upload. (e.g. `branding services/user/Branding/ui`) +function(cargo_psibase_package) + cmake_parse_arguments(ARG "" "PATH;OUTPUT;POSTINSTALL" "UI" ${ARGN}) + + if(NOT ARG_PATH OR NOT ARG_OUTPUT) + message(FATAL_ERROR "Both PATH and OUTPUT must be specified for cargo_psibase_package") + endif() + + # Set variables + cmake_path(GET ARG_OUTPUT FILENAME PACKAGE_NAME) + cmake_path(GET ARG_OUTPUT STEM TARGET_NAME) + set(PACKAGE_OUTPUT ${ARG_PATH}/target/wasm32-wasi/release/packages/${PACKAGE_NAME}) + set(TMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/tmp_${TARGET_NAME}) + set(OUTPUT_DEPENDS) + set(POSTINSTALL_COMMAND) + if(ARG_POSTINSTALL) + set(ARG_POSTINSTALL ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_POSTINSTALL}) + list(APPEND POSTINSTALL_COMMAND + COMMAND ${CMAKE_COMMAND} -E make_directory ${TMP_DIR}/script + COMMAND ${CMAKE_COMMAND} -E copy ${ARG_POSTINSTALL} ${TMP_DIR}/script/postinstall.json + ) + list(APPEND OUTPUT_DEPENDS ${ARG_POSTINSTALL}) + endif() + set(UI_COMMAND) + if (ARG_UI) + list(GET ARG_UI 0 SERVICE_NAME) + list(GET ARG_UI 1 UI_PATH) + set(UI_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${UI_PATH}) + list(APPEND UI_COMMAND + COMMAND ${CMAKE_COMMAND} -E make_directory ${TMP_DIR}/data/${SERVICE_NAME} + COMMAND ${CMAKE_COMMAND} -E copy_directory ${UI_PATH}/dist ${TMP_DIR}/data/${SERVICE_NAME} + ) + list(APPEND OUTPUT_DEPENDS ${TARGET_NAME}_UI_BUILT) + endif() + set(MERGE_COMMAND) + list(APPEND MERGE_COMMAND + COMMAND cd ${TMP_DIR} && zip -ur ${ARG_OUTPUT} . -x ${PACKAGE_NAME} + ) + + # Build the UI if needed + if (ARG_UI) + set(OUTPUT_PATH ${UI_PATH}/dist) + file(GLOB_RECURSE UI_SOURCES ${UI_PATH}/src/*) + list(APPEND UI_SOURCES ${UI_PATH}/package.json ${UI_PATH}/yarn.lock) + add_custom_command( + OUTPUT ${OUTPUT_PATH}/index.html + BYPRODUCTS ${OUTPUT_PATH} + DEPENDS ${UI_SOURCES} + COMMAND cd ${UI_PATH} && yarn --mutex network && yarn build + COMMENT "Building ${TARGET_NAME} UI" + ) + add_custom_target(${TARGET_NAME}_UI_BUILT DEPENDS ${OUTPUT_PATH}/index.html) + endif() + + # Build the package if needed + ExternalProject_Add(${TARGET_NAME} + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_PATH} + BUILD_BYPRODUCTS ${PACKAGE_OUTPUT} + CONFIGURE_COMMAND "" + BUILD_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/rust/release/cargo-psibase package + --manifest-path ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_PATH}/Cargo.toml + INSTALL_COMMAND "" + BUILD_ALWAYS 1 + ) + list(APPEND OUTPUT_DEPENDS ${TARGET_NAME}) + + # Make the final output + add_custom_command( + OUTPUT ${ARG_OUTPUT} + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/${PACKAGE_OUTPUT} ${ARG_OUTPUT} + ${POSTINSTALL_COMMAND} + ${UI_COMMAND} + ${MERGE_COMMAND} + DEPENDS ${OUTPUT_DEPENDS} + VERBATIM + ) + add_custom_target(${TARGET_NAME}_output ALL DEPENDS ${ARG_OUTPUT}) +endfunction() \ No newline at end of file From 70f85dab800c9eaf4a2afe8b7676bdc480fcdd5a Mon Sep 17 00:00:00 2001 From: James-Mart Date: Wed, 11 Sep 2024 19:54:08 +0000 Subject: [PATCH 02/28] remove support for POSTINSTALL and UI in cargo_psibase_package CMake function --- libraries/psibase/sdk/pack_service.cmake | 55 ++---------------------- 1 file changed, 4 insertions(+), 51 deletions(-) diff --git a/libraries/psibase/sdk/pack_service.cmake b/libraries/psibase/sdk/pack_service.cmake index acf647d44..c6a3e9531 100644 --- a/libraries/psibase/sdk/pack_service.cmake +++ b/libraries/psibase/sdk/pack_service.cmake @@ -311,10 +311,8 @@ endfunction() # built/managed by cargo-psibase, as opposed to packages built entirely using CMake. # OUTPUT - [Required] The package file. # PATH - [Required] The path to the cargo workspace (e.g. `services/user/Branding`). -# POSTINSTALL - [Optional] Additional actions that should be run at the end of installation (e.g. `services/user/Branding/postinstall.json`) -# UI - [Optional] A service to upload to, and a UI directory to build/upload. (e.g. `branding services/user/Branding/ui`) function(cargo_psibase_package) - cmake_parse_arguments(ARG "" "PATH;OUTPUT;POSTINSTALL" "UI" ${ARGN}) + cmake_parse_arguments(ARG "" "PATH;OUTPUT" "" ${ARGN}) if(NOT ARG_PATH OR NOT ARG_OUTPUT) message(FATAL_ERROR "Both PATH and OUTPUT must be specified for cargo_psibase_package") @@ -323,48 +321,7 @@ function(cargo_psibase_package) # Set variables cmake_path(GET ARG_OUTPUT FILENAME PACKAGE_NAME) cmake_path(GET ARG_OUTPUT STEM TARGET_NAME) - set(PACKAGE_OUTPUT ${ARG_PATH}/target/wasm32-wasi/release/packages/${PACKAGE_NAME}) - set(TMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/tmp_${TARGET_NAME}) - set(OUTPUT_DEPENDS) - set(POSTINSTALL_COMMAND) - if(ARG_POSTINSTALL) - set(ARG_POSTINSTALL ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_POSTINSTALL}) - list(APPEND POSTINSTALL_COMMAND - COMMAND ${CMAKE_COMMAND} -E make_directory ${TMP_DIR}/script - COMMAND ${CMAKE_COMMAND} -E copy ${ARG_POSTINSTALL} ${TMP_DIR}/script/postinstall.json - ) - list(APPEND OUTPUT_DEPENDS ${ARG_POSTINSTALL}) - endif() - set(UI_COMMAND) - if (ARG_UI) - list(GET ARG_UI 0 SERVICE_NAME) - list(GET ARG_UI 1 UI_PATH) - set(UI_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${UI_PATH}) - list(APPEND UI_COMMAND - COMMAND ${CMAKE_COMMAND} -E make_directory ${TMP_DIR}/data/${SERVICE_NAME} - COMMAND ${CMAKE_COMMAND} -E copy_directory ${UI_PATH}/dist ${TMP_DIR}/data/${SERVICE_NAME} - ) - list(APPEND OUTPUT_DEPENDS ${TARGET_NAME}_UI_BUILT) - endif() - set(MERGE_COMMAND) - list(APPEND MERGE_COMMAND - COMMAND cd ${TMP_DIR} && zip -ur ${ARG_OUTPUT} . -x ${PACKAGE_NAME} - ) - - # Build the UI if needed - if (ARG_UI) - set(OUTPUT_PATH ${UI_PATH}/dist) - file(GLOB_RECURSE UI_SOURCES ${UI_PATH}/src/*) - list(APPEND UI_SOURCES ${UI_PATH}/package.json ${UI_PATH}/yarn.lock) - add_custom_command( - OUTPUT ${OUTPUT_PATH}/index.html - BYPRODUCTS ${OUTPUT_PATH} - DEPENDS ${UI_SOURCES} - COMMAND cd ${UI_PATH} && yarn --mutex network && yarn build - COMMENT "Building ${TARGET_NAME} UI" - ) - add_custom_target(${TARGET_NAME}_UI_BUILT DEPENDS ${OUTPUT_PATH}/index.html) - endif() + set(PACKAGE_OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_PATH}/target/wasm32-wasi/release/packages/${PACKAGE_NAME}) # Build the package if needed ExternalProject_Add(${TARGET_NAME} @@ -376,16 +333,12 @@ function(cargo_psibase_package) INSTALL_COMMAND "" BUILD_ALWAYS 1 ) - list(APPEND OUTPUT_DEPENDS ${TARGET_NAME}) # Make the final output add_custom_command( OUTPUT ${ARG_OUTPUT} - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/${PACKAGE_OUTPUT} ${ARG_OUTPUT} - ${POSTINSTALL_COMMAND} - ${UI_COMMAND} - ${MERGE_COMMAND} - DEPENDS ${OUTPUT_DEPENDS} + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PACKAGE_OUTPUT} ${ARG_OUTPUT} + DEPENDS ${TARGET_NAME} VERBATIM ) add_custom_target(${TARGET_NAME}_output ALL DEPENDS ${ARG_OUTPUT}) From 8b709171d131b8e67b91d4c6e9e17a180cf49b2d Mon Sep 17 00:00:00 2001 From: James-Mart Date: Wed, 11 Sep 2024 19:55:25 +0000 Subject: [PATCH 03/28] add js_target for chainmail ui --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 03e926240..b1d9b861b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -234,6 +234,7 @@ set(JS_DIRS services/user/Supervisor/ui:Supervisor_js services/user/Explorer/ui:Explorer_js services/user/Tokens/ui:Tokens_js + services/user/Webmail/ui:Webmail_js ) set(ADMIN_DIR services/user/XAdmin/ui:XAdmin_js) set(COMMON_LIB_DIR services/user/CommonApi/common/packages/common-lib/:CommonApiCommonLib_js) From e3d8c1b0e395d5aecdf04fc309899a950ba3ec69 Mon Sep 17 00:00:00 2001 From: James-Mart Date: Mon, 23 Sep 2024 18:54:54 +0000 Subject: [PATCH 04/28] rename webmail to chainmail --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b1d9b861b..04e0c4e2d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -234,7 +234,7 @@ set(JS_DIRS services/user/Supervisor/ui:Supervisor_js services/user/Explorer/ui:Explorer_js services/user/Tokens/ui:Tokens_js - services/user/Webmail/ui:Webmail_js + services/user/Chainmail/ui:Chainmail_js ) set(ADMIN_DIR services/user/XAdmin/ui:XAdmin_js) set(COMMON_LIB_DIR services/user/CommonApi/common/packages/common-lib/:CommonApiCommonLib_js) From 2fc6b51dd82f96ff9fd32f1b406614859eb3c1f9 Mon Sep 17 00:00:00 2001 From: James-Mart Date: Wed, 11 Sep 2024 19:55:52 +0000 Subject: [PATCH 05/28] trigger build of cargo psibase package from cmake --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 04e0c4e2d..f8f792c0d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -407,6 +407,12 @@ psibase_package( DEPENDS ${ClientDataPlugin_DEP} ) +cargo_psibase_package( + OUTPUT ${SERVICE_DIR}/Webmail.psi + PATH services/user/Webmail + # DEPENDS ${Webmail_js_DEP} +) + psibase_package( OUTPUT ${SERVICE_DIR}/AuthSig.psi NAME AuthSig From 6ba7714cea3e45b6b64eb1c902ad76144c0cf2ae Mon Sep 17 00:00:00 2001 From: James-Mart Date: Mon, 23 Sep 2024 18:57:11 +0000 Subject: [PATCH 06/28] more webmail->chainmail renaming --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f8f792c0d..7a99bccaa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -408,9 +408,9 @@ psibase_package( ) cargo_psibase_package( - OUTPUT ${SERVICE_DIR}/Webmail.psi - PATH services/user/Webmail - # DEPENDS ${Webmail_js_DEP} + OUTPUT ${SERVICE_DIR}/Chainmail.psi + PATH services/user/Chainmail + # DEPENDS ${Chainmail_js_DEP} ) psibase_package( From d2a43ed7816eff8b6477da25b02bdeb2e10e17e5 Mon Sep 17 00:00:00 2001 From: James-Mart Date: Mon, 23 Sep 2024 18:59:05 +0000 Subject: [PATCH 07/28] Add UI and postinstall script to chainmail --- services/user/Chainmail/service/Cargo.toml | 3 +++ services/user/Chainmail/service/src/lib.rs | 30 +++++++++++++++++++--- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/services/user/Chainmail/service/Cargo.toml b/services/user/Chainmail/service/Cargo.toml index 1f7a77320..eb9bb9afd 100644 --- a/services/user/Chainmail/service/Cargo.toml +++ b/services/user/Chainmail/service/Cargo.toml @@ -10,6 +10,9 @@ publish = false [package.metadata.psibase] server = "chainmail" plugin = "plugin" +postinstall = [ + { sender = "chainmail", service = "chainmail", method = "init", rawData = "0000" }, +] [dependencies] psibase = { path = "../../../../rust/psibase/" } diff --git a/services/user/Chainmail/service/src/lib.rs b/services/user/Chainmail/service/src/lib.rs index e463c5abb..4e576b908 100644 --- a/services/user/Chainmail/service/src/lib.rs +++ b/services/user/Chainmail/service/src/lib.rs @@ -100,16 +100,38 @@ fn serve_rest_api(request: &HttpRequest) -> Option { #[psibase::service] mod service { use psibase::services::accounts::Wrapper as AccountsSvc; - use psibase::{ - anyhow, check, get_sender, get_service, serve_content, serve_simple_ui, store_content, - AccountNumber, HexBytes, HttpReply, HttpRequest, Table, WebContentRow, - }; + use psibase::*; + use serde::{Deserialize, Serialize}; use crate::serve_rest_api; #[table(record = "WebContentRow")] struct WebContentTable; + #[table(name = "InitTable", index = 1)] + #[derive(Serialize, Deserialize, ToSchema, Fracpack)] + struct InitRow {} + impl InitRow { + #[primary_key] + fn pk(&self) {} + } + + #[action] + fn init() { + let table = InitTable::new(); + check( + table.get_index_pk().get(&()).is_none(), + "Service already initialized", + ); + table.put(&InitRow {}).unwrap(); + + // TODO: Depends on #845 + // use services::events::Wrapper as EventsSvc; + // EventsSvc::call().setSchema(&create_schema()); + // EventsSvc::call().addIndex(DbId::HistoryEvent, SERVICE, MethodNumber::from("sent"), 0); + // EventsSvc::call().addIndex(DbId::HistoryEvent, SERVICE, MethodNumber::from("sent"), 1); + } + #[action] fn send(receiver: AccountNumber, subject: String, body: String) { check( From 817370664f391e8cf32edfd5fcc70a465d9ac999 Mon Sep 17 00:00:00 2001 From: James-Mart Date: Tue, 24 Sep 2024 16:13:07 +0000 Subject: [PATCH 08/28] add missing 'description' property to package config docs --- doc/psidk/src/development/services/rust-service/package.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/psidk/src/development/services/rust-service/package.md b/doc/psidk/src/development/services/rust-service/package.md index 882d48cba..c8de2d67e 100644 --- a/doc/psidk/src/development/services/rust-service/package.md +++ b/doc/psidk/src/development/services/rust-service/package.md @@ -7,6 +7,7 @@ A [psibase package](../../../specifications/data-formats/package.md) may be comp The available fields are: - `package-name`: Must be present on the top-level crate for the package. +- `description`: A description of the package. - `services`: A list of services to include in the psibase package. - `server`: May be present on any crate that builds a service. The value is a crate which will handle HTTP requests sent to this service. The other crate will be built and included in the current package. - `plugin`: May be present on any crate that builds a service. The value is a crate that should be built with `cargo component` and uploaded as `/plugin.wasm` @@ -25,6 +26,8 @@ version = "0.1.0" [package.metadata.psibase] # Builds example.psi package-name = "example" +# Description of the package +description = "An example package" # Most services besides the core system services don't need extra flags. flags = [] # This service handles its own HTTP requests From e7c6ecee586a236b8c97d6f0608e7eacc6b51fae Mon Sep 17 00:00:00 2001 From: James-Mart Date: Tue, 24 Sep 2024 16:13:57 +0000 Subject: [PATCH 09/28] fix incorrect custom command dependency in cargo_psibase_package --- libraries/psibase/sdk/pack_service.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/psibase/sdk/pack_service.cmake b/libraries/psibase/sdk/pack_service.cmake index c6a3e9531..714fb8a68 100644 --- a/libraries/psibase/sdk/pack_service.cmake +++ b/libraries/psibase/sdk/pack_service.cmake @@ -338,7 +338,7 @@ function(cargo_psibase_package) add_custom_command( OUTPUT ${ARG_OUTPUT} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PACKAGE_OUTPUT} ${ARG_OUTPUT} - DEPENDS ${TARGET_NAME} + DEPENDS ${PACKAGE_OUTPUT} VERBATIM ) add_custom_target(${TARGET_NAME}_output ALL DEPENDS ${ARG_OUTPUT}) From e3624b85d5c4c21bcf0b1375a6e1ba5cbd27d3a0 Mon Sep 17 00:00:00 2001 From: James-Mart Date: Tue, 24 Sep 2024 16:14:58 +0000 Subject: [PATCH 10/28] add support for cargo_psibase_packages to depend on UI targets --- CMakeLists.txt | 2 +- libraries/psibase/sdk/pack_service.cmake | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a99bccaa..10fce6be5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -410,7 +410,7 @@ psibase_package( cargo_psibase_package( OUTPUT ${SERVICE_DIR}/Chainmail.psi PATH services/user/Chainmail - # DEPENDS ${Chainmail_js_DEP} + DEPENDS ${Chainmail_js_DEP} ) psibase_package( diff --git a/libraries/psibase/sdk/pack_service.cmake b/libraries/psibase/sdk/pack_service.cmake index 714fb8a68..963d8e4e6 100644 --- a/libraries/psibase/sdk/pack_service.cmake +++ b/libraries/psibase/sdk/pack_service.cmake @@ -311,8 +311,9 @@ endfunction() # built/managed by cargo-psibase, as opposed to packages built entirely using CMake. # OUTPUT - [Required] The package file. # PATH - [Required] The path to the cargo workspace (e.g. `services/user/Branding`). +# DEPENDS ... - [Required] Targets that this target depends on function(cargo_psibase_package) - cmake_parse_arguments(ARG "" "PATH;OUTPUT" "" ${ARGN}) + cmake_parse_arguments(ARG "" "PATH;OUTPUT;DEPENDS" "" ${ARGN}) if(NOT ARG_PATH OR NOT ARG_OUTPUT) message(FATAL_ERROR "Both PATH and OUTPUT must be specified for cargo_psibase_package") @@ -332,6 +333,7 @@ function(cargo_psibase_package) --manifest-path ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_PATH}/Cargo.toml INSTALL_COMMAND "" BUILD_ALWAYS 1 + DEPENDS ${ARG_DEPENDS} ) # Make the final output From 16a4562054ff99668ad9e03bcb95d9c75c47adc4 Mon Sep 17 00:00:00 2001 From: James-Mart Date: Tue, 24 Sep 2024 16:15:34 +0000 Subject: [PATCH 11/28] minor refactor of events service rust wrapper --- rust/psibase/src/services/events.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/rust/psibase/src/services/events.rs b/rust/psibase/src/services/events.rs index d19fcb6bd..f84a45bd1 100644 --- a/rust/psibase/src/services/events.rs +++ b/rust/psibase/src/services/events.rs @@ -1,19 +1,15 @@ #[crate::service(name = "events", dispatch = false, psibase_mod = "crate")] #[allow(non_snake_case, unused_variables)] mod service { + use crate::{AccountNumber, DbId, MethodNumber, Schema}; #[action] - fn setSchema(schema: crate::Schema) { + fn setSchema(schema: Schema) { unimplemented!() } #[action] - fn addIndex( - db_id: crate::DbId, - service: crate::AccountNumber, - event: crate::MethodNumber, - column: u8, - ) { + fn addIndex(db_id: DbId, service: AccountNumber, event: MethodNumber, column: u8) { unimplemented!() } } From 6b75b2f5356a801be33f361ddd7e503b50629bf3 Mon Sep 17 00:00:00 2001 From: James-Mart Date: Tue, 24 Sep 2024 16:16:38 +0000 Subject: [PATCH 12/28] finish configuring the chainmail package with dependencies/version/ui --- CMakeLists.txt | 7 ++++--- services/user/Chainmail/Cargo.lock | 6 +++--- services/user/Chainmail/Cargo.toml | 22 ++++++++++++++-------- services/user/Chainmail/plugin/Cargo.toml | 2 +- services/user/Chainmail/service/Cargo.toml | 11 ++++++++++- 5 files changed, 32 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 10fce6be5..82237ed95 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -732,7 +732,7 @@ psibase_package( NAME DevDefault VERSION ${PSIBASE_VERSION} DESCRIPTION "All development services" - PACKAGE_DEPENDS Accounts AuthAny AuthSig AuthDelegate ClientData CommonApi CpuLimit + PACKAGE_DEPENDS Accounts AuthAny AuthSig AuthDelegate Chainmail ClientData CommonApi CpuLimit Docs Events Explorer Fractal Invite Nft Packages Producers HttpServer Sites SetCode Supervisor Symbol TokenUsers Tokens Transact Homepage ) @@ -742,7 +742,7 @@ psibase_package( NAME ProdDefault VERSION ${PSIBASE_VERSION} DESCRIPTION "All production services" - PACKAGE_DEPENDS Accounts AuthAny AuthSig AuthDelegate ClientData CommonApi CpuLimit + PACKAGE_DEPENDS Accounts AuthAny AuthSig AuthDelegate Chainmail ClientData CommonApi CpuLimit Docs Events Explorer Fractal Invite Nft Packages Producers HttpServer Sites SetCode Supervisor Symbol Tokens Transact Homepage ) @@ -771,7 +771,7 @@ function(write_package_index target dir) endfunction() write_package_index(package-index ${SERVICE_DIR} - Accounts AuthAny AuthSig ClientData CommonApi CpuLimit DevDefault ProdDefault + Accounts AuthAny AuthSig Chainmail ClientData CommonApi CpuLimit DevDefault ProdDefault Docs Events Explorer Fractal Invite Nft Nop Minimal Packages Producers HttpServer Sites SetCode Supervisor Symbol TokenUsers Tokens Transact Homepage) @@ -781,6 +781,7 @@ install( ${SERVICE_DIR}/AuthAny.psi ${SERVICE_DIR}/AuthDelegate.psi ${SERVICE_DIR}/AuthSig.psi + ${SERVICE_DIR}/Chainmail.psi ${SERVICE_DIR}/ClientData.psi ${SERVICE_DIR}/CommonApi.psi ${SERVICE_DIR}/DevDefault.psi diff --git a/services/user/Chainmail/Cargo.lock b/services/user/Chainmail/Cargo.lock index 5ec65dd5b..c3fefaf5d 100644 --- a/services/user/Chainmail/Cargo.lock +++ b/services/user/Chainmail/Cargo.lock @@ -364,7 +364,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chainmail" -version = "0.1.0" +version = "0.12.0" dependencies = [ "async-graphql", "chainmail_package", @@ -374,7 +374,7 @@ dependencies = [ [[package]] name = "chainmail_package" -version = "0.0.0" +version = "0.12.0" dependencies = [ "chainmail", "plugin", @@ -1438,7 +1438,7 @@ dependencies = [ [[package]] name = "plugin" -version = "0.1.0" +version = "0.12.0" dependencies = [ "chainmail", "chainmail_package", diff --git a/services/user/Chainmail/Cargo.toml b/services/user/Chainmail/Cargo.toml index fd3624b35..c2e07c5ba 100644 --- a/services/user/Chainmail/Cargo.toml +++ b/services/user/Chainmail/Cargo.toml @@ -3,7 +3,7 @@ resolver = "2" members = ["service", "plugin"] [workspace.package] -version = "0.1.0" +version = "0.12.0" rust-version = "1.64" edition = "2021" repository = "https://github.com/gofractally/psibase" @@ -12,6 +12,17 @@ publish = false [package] name = "chainmail_package" +version.workspace = true +rust-version.workspace = true +edition.workspace = true +repository.workspace = true +homepage.workspace = true +publish.workspace = true + +[package.metadata.psibase] +package-name = "Chainmail" +description = "Message-sending application" +services = ["chainmail"] [profile.release] codegen-units = 1 @@ -20,14 +31,9 @@ debug = false strip = true lto = true -[package.metadata.psibase] -package-name = "Chainmail" -description = "Basic email app" -services = ["chainmail"] - [lib] crate-type = ["rlib"] [dependencies] -chainmail = { path = "service" } -plugin = { path = "plugin" } +chainmail = { path = "service", version = "0.12.0" } +plugin = { path = "plugin", version = "0.12.0" } diff --git a/services/user/Chainmail/plugin/Cargo.toml b/services/user/Chainmail/plugin/Cargo.toml index 1cba67759..4875410a0 100644 --- a/services/user/Chainmail/plugin/Cargo.toml +++ b/services/user/Chainmail/plugin/Cargo.toml @@ -26,4 +26,4 @@ world = "impl" "transact:plugin" = { path = "../../../system/Transact/plugin/wit/world.wit" } [dev-dependencies] -chainmail_package = { path = ".." } +chainmail_package = { path = "..", version = "0.12.0" } diff --git a/services/user/Chainmail/service/Cargo.toml b/services/user/Chainmail/service/Cargo.toml index eb9bb9afd..54f375925 100644 --- a/services/user/Chainmail/service/Cargo.toml +++ b/services/user/Chainmail/service/Cargo.toml @@ -10,14 +10,23 @@ publish = false [package.metadata.psibase] server = "chainmail" plugin = "plugin" +data = [{ src = "../ui/dist/", dst = "/" }] postinstall = [ { sender = "chainmail", service = "chainmail", method = "init", rawData = "0000" }, ] +[package.metadata.psibase.dependencies] +Accounts = "0.12.0" +CommonApi = "0.12.0" +SetCode = "0.12.0" +HttpServer = "0.12.0" +Supervisor = "0.12.0" +Events = "0.12.0" + [dependencies] psibase = { path = "../../../../rust/psibase/" } async-graphql = "7.0.7" serde = { version = "1.0.209", features = ["derive"] } [dev-dependencies] -chainmail_package = { path = ".." } +chainmail_package = { path = "..", version = "0.12.0" } From 140be1ae279b894f51ded19f24dc8fce2806a4f7 Mon Sep 17 00:00:00 2001 From: James-Mart Date: Tue, 24 Sep 2024 16:17:10 +0000 Subject: [PATCH 13/28] add events service indexing configuration to chainmail initialization --- services/user/Chainmail/service/src/lib.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/services/user/Chainmail/service/src/lib.rs b/services/user/Chainmail/service/src/lib.rs index 4e576b908..2dbe09fe0 100644 --- a/services/user/Chainmail/service/src/lib.rs +++ b/services/user/Chainmail/service/src/lib.rs @@ -99,9 +99,10 @@ fn serve_rest_api(request: &HttpRequest) -> Option { #[psibase::service] mod service { - use psibase::services::accounts::Wrapper as AccountsSvc; use psibase::*; use serde::{Deserialize, Serialize}; + use services::accounts::Wrapper as AccountsSvc; + use services::events::Wrapper as EventsSvc; use crate::serve_rest_api; @@ -125,11 +126,9 @@ mod service { ); table.put(&InitRow {}).unwrap(); - // TODO: Depends on #845 - // use services::events::Wrapper as EventsSvc; - // EventsSvc::call().setSchema(&create_schema()); - // EventsSvc::call().addIndex(DbId::HistoryEvent, SERVICE, MethodNumber::from("sent"), 0); - // EventsSvc::call().addIndex(DbId::HistoryEvent, SERVICE, MethodNumber::from("sent"), 1); + EventsSvc::call().setSchema(create_schema::()); + EventsSvc::call().addIndex(DbId::HistoryEvent, SERVICE, MethodNumber::from("sent"), 0); + EventsSvc::call().addIndex(DbId::HistoryEvent, SERVICE, MethodNumber::from("sent"), 1); } #[action] From eafed70d48f80e529bc9a838e0c29f0d71624909 Mon Sep 17 00:00:00 2001 From: James-Mart Date: Tue, 24 Sep 2024 16:25:00 +0000 Subject: [PATCH 14/28] use cmake code compatible with cmake 3.16.3 --- CMakeLists.txt | 2 +- libraries/psibase/sdk/pack_service.cmake | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 82237ed95..9931c0985 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.20) +cmake_minimum_required(VERSION 3.16.3) cmake_policy(VERSION 3.16.3...3.25.1) project(psibase) include(ExternalProject) diff --git a/libraries/psibase/sdk/pack_service.cmake b/libraries/psibase/sdk/pack_service.cmake index 963d8e4e6..b066d0faf 100644 --- a/libraries/psibase/sdk/pack_service.cmake +++ b/libraries/psibase/sdk/pack_service.cmake @@ -320,8 +320,8 @@ function(cargo_psibase_package) endif() # Set variables - cmake_path(GET ARG_OUTPUT FILENAME PACKAGE_NAME) - cmake_path(GET ARG_OUTPUT STEM TARGET_NAME) + get_filename_component(PACKAGE_NAME ${ARG_OUTPUT} NAME) + get_filename_component(TARGET_NAME ${ARG_OUTPUT} NAME_WE) set(PACKAGE_OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_PATH}/target/wasm32-wasi/release/packages/${PACKAGE_NAME}) # Build the package if needed From 7d30f4d0ebfc407d2c93e51a8e1c081994d023be Mon Sep 17 00:00:00 2001 From: James-Mart Date: Tue, 24 Sep 2024 17:35:02 +0000 Subject: [PATCH 15/28] add missing dependency --- libraries/psibase/sdk/pack_service.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/psibase/sdk/pack_service.cmake b/libraries/psibase/sdk/pack_service.cmake index b066d0faf..55e862ba4 100644 --- a/libraries/psibase/sdk/pack_service.cmake +++ b/libraries/psibase/sdk/pack_service.cmake @@ -333,7 +333,7 @@ function(cargo_psibase_package) --manifest-path ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_PATH}/Cargo.toml INSTALL_COMMAND "" BUILD_ALWAYS 1 - DEPENDS ${ARG_DEPENDS} + DEPENDS ${ARG_DEPENDS} cargo-psibase ) # Make the final output From edad8cc9cb1a46630fce38fc573a5a1f2b8a8aff Mon Sep 17 00:00:00 2001 From: James-Mart Date: Tue, 24 Sep 2024 18:13:06 +0000 Subject: [PATCH 16/28] fix cargo-psibase-package target name --- libraries/psibase/sdk/pack_service.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/psibase/sdk/pack_service.cmake b/libraries/psibase/sdk/pack_service.cmake index 55e862ba4..746fed481 100644 --- a/libraries/psibase/sdk/pack_service.cmake +++ b/libraries/psibase/sdk/pack_service.cmake @@ -325,7 +325,7 @@ function(cargo_psibase_package) set(PACKAGE_OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_PATH}/target/wasm32-wasi/release/packages/${PACKAGE_NAME}) # Build the package if needed - ExternalProject_Add(${TARGET_NAME} + ExternalProject_Add(${TARGET_NAME}_ext SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_PATH} BUILD_BYPRODUCTS ${PACKAGE_OUTPUT} CONFIGURE_COMMAND "" @@ -343,5 +343,5 @@ function(cargo_psibase_package) DEPENDS ${PACKAGE_OUTPUT} VERBATIM ) - add_custom_target(${TARGET_NAME}_output ALL DEPENDS ${ARG_OUTPUT}) + add_custom_target(${TARGET_NAME} ALL DEPENDS ${ARG_OUTPUT}) endfunction() \ No newline at end of file From 06496e4a04a6ec1171b0ed7776026526778348bd Mon Sep 17 00:00:00 2001 From: James-Mart Date: Tue, 24 Sep 2024 18:49:51 +0000 Subject: [PATCH 17/28] ensure package dependencies are listed in meta.json in sorted order --- rust/cargo-psibase/src/package.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rust/cargo-psibase/src/package.rs b/rust/cargo-psibase/src/package.rs index 0887614ac..7ed168583 100644 --- a/rust/cargo-psibase/src/package.rs +++ b/rust/cargo-psibase/src/package.rs @@ -326,13 +326,14 @@ pub async fn build_package( } }; - let meta = Meta { + let mut meta = Meta { name: package_name.to_string(), version: package_version.to_string(), description: package_description.unwrap_or_else(|| package_name.to_string()), depends, accounts, }; + meta.depends.sort_by(|a, b| a.name.cmp(&b.name)); let mut service_wasms = Vec::new(); for (service, info, id) in services { From 1aba738ad7cab857bb0ab8c0bc5945c448a3c114 Mon Sep 17 00:00:00 2001 From: James-Mart Date: Tue, 24 Sep 2024 19:18:17 +0000 Subject: [PATCH 18/28] try to fix 'no rule to make target' --- libraries/psibase/sdk/pack_service.cmake | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/psibase/sdk/pack_service.cmake b/libraries/psibase/sdk/pack_service.cmake index 746fed481..392f1541d 100644 --- a/libraries/psibase/sdk/pack_service.cmake +++ b/libraries/psibase/sdk/pack_service.cmake @@ -336,11 +336,10 @@ function(cargo_psibase_package) DEPENDS ${ARG_DEPENDS} cargo-psibase ) - # Make the final output add_custom_command( OUTPUT ${ARG_OUTPUT} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PACKAGE_OUTPUT} ${ARG_OUTPUT} - DEPENDS ${PACKAGE_OUTPUT} + DEPENDS ${TARGET_NAME}_ext VERBATIM ) add_custom_target(${TARGET_NAME} ALL DEPENDS ${ARG_OUTPUT}) From 92dfc6c1f01f5a1c332714324656c30b463146ff Mon Sep 17 00:00:00 2001 From: James-Mart Date: Tue, 24 Sep 2024 20:10:04 +0000 Subject: [PATCH 19/28] remove incorrect required cmake function annotation --- libraries/psibase/sdk/pack_service.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/psibase/sdk/pack_service.cmake b/libraries/psibase/sdk/pack_service.cmake index 392f1541d..5310ea058 100644 --- a/libraries/psibase/sdk/pack_service.cmake +++ b/libraries/psibase/sdk/pack_service.cmake @@ -311,7 +311,7 @@ endfunction() # built/managed by cargo-psibase, as opposed to packages built entirely using CMake. # OUTPUT - [Required] The package file. # PATH - [Required] The path to the cargo workspace (e.g. `services/user/Branding`). -# DEPENDS ... - [Required] Targets that this target depends on +# DEPENDS ... - Targets that this target depends on function(cargo_psibase_package) cmake_parse_arguments(ARG "" "PATH;OUTPUT;DEPENDS" "" ${ARGN}) From 304eb9a3b482a860ab46b6f6915930e47fde1087 Mon Sep 17 00:00:00 2001 From: James-Mart Date: Tue, 24 Sep 2024 20:48:57 +0000 Subject: [PATCH 20/28] move description property to 'package' table instead of 'package.metadata.psibase' table. --- doc/psidk/src/development/services/rust-service/package.md | 4 +--- rust/test_package/Cargo.toml | 2 +- services/user/Chainmail/Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/doc/psidk/src/development/services/rust-service/package.md b/doc/psidk/src/development/services/rust-service/package.md index c8de2d67e..13827debe 100644 --- a/doc/psidk/src/development/services/rust-service/package.md +++ b/doc/psidk/src/development/services/rust-service/package.md @@ -7,7 +7,6 @@ A [psibase package](../../../specifications/data-formats/package.md) may be comp The available fields are: - `package-name`: Must be present on the top-level crate for the package. -- `description`: A description of the package. - `services`: A list of services to include in the psibase package. - `server`: May be present on any crate that builds a service. The value is a crate which will handle HTTP requests sent to this service. The other crate will be built and included in the current package. - `plugin`: May be present on any crate that builds a service. The value is a crate that should be built with `cargo component` and uploaded as `/plugin.wasm` @@ -22,12 +21,11 @@ Example: [package] name = "example" version = "0.1.0" +description = "An example package" [package.metadata.psibase] # Builds example.psi package-name = "example" -# Description of the package -description = "An example package" # Most services besides the core system services don't need extra flags. flags = [] # This service handles its own HTTP requests diff --git a/rust/test_package/Cargo.toml b/rust/test_package/Cargo.toml index 65d1e5a8f..ab438fac4 100644 --- a/rust/test_package/Cargo.toml +++ b/rust/test_package/Cargo.toml @@ -1,5 +1,6 @@ [package] name = "test_package" +description = "Test for package building" version.workspace = true rust-version.workspace = true repository.workspace = true @@ -9,7 +10,6 @@ publish = false [package.metadata.psibase] package-name = "TestPackage" -description = "Test for package building" services = ["tpack"] [lib] diff --git a/services/user/Chainmail/Cargo.toml b/services/user/Chainmail/Cargo.toml index c2e07c5ba..f6ec5bfd3 100644 --- a/services/user/Chainmail/Cargo.toml +++ b/services/user/Chainmail/Cargo.toml @@ -12,6 +12,7 @@ publish = false [package] name = "chainmail_package" +description = "Message-sending application" version.workspace = true rust-version.workspace = true edition.workspace = true @@ -21,7 +22,6 @@ publish.workspace = true [package.metadata.psibase] package-name = "Chainmail" -description = "Message-sending application" services = ["chainmail"] [profile.release] From a5c6b50e53b4bc3d8ed21bdd2246852fc3a1e810 Mon Sep 17 00:00:00 2001 From: James-Mart Date: Tue, 24 Sep 2024 20:52:57 +0000 Subject: [PATCH 21/28] do not comment out valid config item: database-cache-size --- programs/psinode/main.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/programs/psinode/main.cpp b/programs/psinode/main.cpp index 0d99e7d49..e481f0313 100644 --- a/programs/psinode/main.cpp +++ b/programs/psinode/main.cpp @@ -1439,8 +1439,9 @@ void to_config(const PsinodeConfig& config, ConfigFile& file) if (!config.tls.trustfiles.empty()) { file.set( - "", "tls-trustfile", config.tls.trustfiles, [](std::string_view text) - { return std::string(text); }, "A file containing trusted certificate authorities"); + "", "tls-trustfile", config.tls.trustfiles, + [](std::string_view text) { return std::string(text); }, + "A file containing trusted certificate authorities"); } #endif if (!config.services.empty()) @@ -1451,8 +1452,9 @@ void to_config(const PsinodeConfig& config, ConfigFile& file) services.push_back(to_string(service)); } file.set( - "", "service", services, [](std::string_view text) - { return service_from_string(text).host; }, "Native service root directory"); + "", "service", services, + [](std::string_view text) { return service_from_string(text).host; }, + "Native service root directory"); } if (!std::holds_alternative(config.admin)) { @@ -1480,6 +1482,7 @@ void to_config(const PsinodeConfig& config, ConfigFile& file) // private keys. file.keep("", "key"); file.keep("", "leeway"); + file.keep("", "database-cache-size"); // to_config(config.loggers, file); } From bd52ef9bc6bb1ffd5968624f5ab66bee5c54b912 Mon Sep 17 00:00:00 2001 From: James-Mart Date: Tue, 24 Sep 2024 21:56:56 +0000 Subject: [PATCH 22/28] fix - new packages weren't getting installed --- libraries/psibase/sdk/pack_service.cmake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/psibase/sdk/pack_service.cmake b/libraries/psibase/sdk/pack_service.cmake index 5310ea058..10b464776 100644 --- a/libraries/psibase/sdk/pack_service.cmake +++ b/libraries/psibase/sdk/pack_service.cmake @@ -336,10 +336,14 @@ function(cargo_psibase_package) DEPENDS ${ARG_DEPENDS} cargo-psibase ) + # Adding this target tells cmake how to build package_output, which is needed because the + # below custom command depends on it. + add_custom_target(${TARGET_NAME}_package DEPENDS ${PACKAGE_OUTPUT}) + add_dependencies(${TARGET_NAME}_package ${TARGET_NAME}_ext) add_custom_command( OUTPUT ${ARG_OUTPUT} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PACKAGE_OUTPUT} ${ARG_OUTPUT} - DEPENDS ${TARGET_NAME}_ext + DEPENDS ${PACKAGE_OUTPUT} VERBATIM ) add_custom_target(${TARGET_NAME} ALL DEPENDS ${ARG_OUTPUT}) From 66b72fb3d0566ed49325829c7319cf39b33d1210 Mon Sep 17 00:00:00 2001 From: James-Mart Date: Wed, 25 Sep 2024 13:32:34 +0000 Subject: [PATCH 23/28] trying to fix 'no rule to make target' --- libraries/psibase/sdk/pack_service.cmake | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libraries/psibase/sdk/pack_service.cmake b/libraries/psibase/sdk/pack_service.cmake index 10b464776..8a41c9487 100644 --- a/libraries/psibase/sdk/pack_service.cmake +++ b/libraries/psibase/sdk/pack_service.cmake @@ -336,15 +336,17 @@ function(cargo_psibase_package) DEPENDS ${ARG_DEPENDS} cargo-psibase ) - # Adding this target tells cmake how to build package_output, which is needed because the - # below custom command depends on it. - add_custom_target(${TARGET_NAME}_package DEPENDS ${PACKAGE_OUTPUT}) - add_dependencies(${TARGET_NAME}_package ${TARGET_NAME}_ext) + add_custom_command( + OUTPUT ${PACKAGE_OUTPUT} + COMMAND ${CMAKE_COMMAND} -E true + DEPENDS ${TARGET_NAME}_ext + ) + add_custom_command( OUTPUT ${ARG_OUTPUT} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PACKAGE_OUTPUT} ${ARG_OUTPUT} DEPENDS ${PACKAGE_OUTPUT} VERBATIM ) - add_custom_target(${TARGET_NAME} ALL DEPENDS ${ARG_OUTPUT}) + add_custom_target(${TARGET_NAME} ALL DEPENDS ${ARG_OUTPUT} cargo-psibase) endfunction() \ No newline at end of file From 962e4f4a7ecd08c565279cd2411d4a5177c3699c Mon Sep 17 00:00:00 2001 From: Steven Watanabe Date: Wed, 25 Sep 2024 08:50:25 -0600 Subject: [PATCH 24/28] Avoid throwing in WASM builds even when exceptions are "enabled." It's currently stubbed to abort and the message from a direct call to abortMessage is better. --- libraries/psio/include/psio/check.hpp | 2 +- libraries/psio/include/psio/view.hpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/psio/include/psio/check.hpp b/libraries/psio/include/psio/check.hpp index 0d3a4b229..7e029a6df 100644 --- a/libraries/psio/include/psio/check.hpp +++ b/libraries/psio/include/psio/check.hpp @@ -17,7 +17,7 @@ namespace psio template [[noreturn]] void abort_error(const T& msg) { -#ifdef __cpp_exceptions +#ifndef COMPILING_WASM throw std::runtime_error((std::string)error_to_str(msg)); #else psibase::abortMessage(error_to_str(msg)); diff --git a/libraries/psio/include/psio/view.hpp b/libraries/psio/include/psio/view.hpp index 877022bde..88abb2bd5 100644 --- a/libraries/psio/include/psio/view.hpp +++ b/libraries/psio/include/psio/view.hpp @@ -221,7 +221,7 @@ namespace psio (void)unpack_numeric(&offset, this->data, pos, 4); if (offset == 1) { -#ifdef __cpp_exceptions +#ifdef COMPILING_WASM throw std::bad_optional_access{}; #else abort_error("bad optional access"); @@ -340,7 +340,7 @@ namespace psio } else { -#ifdef __cpp_exceptions +#ifdef COMPILING_WASM throw std::bad_variant_access{}; #else abort_error("bad variant access"); @@ -358,7 +358,7 @@ namespace psio } else { -#ifdef __cpp_exceptions +#ifdef COMPILING_WASM throw std::bad_variant_access{}; #else abort_error("bad variant access"); @@ -556,7 +556,7 @@ namespace psio } else { -#ifdef __cpp_exceptions +#ifdef COMPILING_WASM throw std::out_of_range("view our of range"); #else abort_error("view our of range"); @@ -625,7 +625,7 @@ namespace psio } else { -#ifdef __cpp_exceptions +#ifdef COMPILING_WASM throw std::out_of_range("view out of range"); #else abort_error("view out of range"); From c2dac535e8f1917456eae208ceda1c944fd30c50 Mon Sep 17 00:00:00 2001 From: Steven Watanabe Date: Wed, 25 Sep 2024 08:54:04 -0600 Subject: [PATCH 25/28] Use the right test --- libraries/psio/include/psio/view.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libraries/psio/include/psio/view.hpp b/libraries/psio/include/psio/view.hpp index 88abb2bd5..4c5961633 100644 --- a/libraries/psio/include/psio/view.hpp +++ b/libraries/psio/include/psio/view.hpp @@ -221,7 +221,7 @@ namespace psio (void)unpack_numeric(&offset, this->data, pos, 4); if (offset == 1) { -#ifdef COMPILING_WASM +#ifndef COMPILING_WASM throw std::bad_optional_access{}; #else abort_error("bad optional access"); @@ -340,7 +340,7 @@ namespace psio } else { -#ifdef COMPILING_WASM +#ifndef COMPILING_WASM throw std::bad_variant_access{}; #else abort_error("bad variant access"); @@ -358,7 +358,7 @@ namespace psio } else { -#ifdef COMPILING_WASM +#ifndef COMPILING_WASM throw std::bad_variant_access{}; #else abort_error("bad variant access"); @@ -556,7 +556,7 @@ namespace psio } else { -#ifdef COMPILING_WASM +#ifndef COMPILING_WASM throw std::out_of_range("view our of range"); #else abort_error("view our of range"); @@ -625,7 +625,7 @@ namespace psio } else { -#ifdef COMPILING_WASM +#ifndef COMPILING_WASM throw std::out_of_range("view out of range"); #else abort_error("view out of range"); From 220a1f0aa1b0b6c7eb4c93feb4f1bb1015addcfe Mon Sep 17 00:00:00 2001 From: Mike Manfredi Date: Wed, 25 Sep 2024 19:37:51 +0000 Subject: [PATCH 26/28] patching line of code I didn't intend to commit in previous PR --- services/user/Branding/ui/src/App.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/user/Branding/ui/src/App.tsx b/services/user/Branding/ui/src/App.tsx index 9135d3a6c..e5f43c462 100644 --- a/services/user/Branding/ui/src/App.tsx +++ b/services/user/Branding/ui/src/App.tsx @@ -20,7 +20,7 @@ export const App = () => { const init = async () => { await supervisor.onLoaded(); supervisor.preLoadPlugins([{ service: "branding" }]); - setTimeout(getNetworkName, 1500); + await getNetworkName(); }; useEffect(() => { From 8f222708bee6ca04ea9c87d29bc98042ba1b20a6 Mon Sep 17 00:00:00 2001 From: James-Mart Date: Thu, 26 Sep 2024 14:03:13 +0000 Subject: [PATCH 27/28] add target-level dep on external project --- libraries/psibase/sdk/pack_service.cmake | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/libraries/psibase/sdk/pack_service.cmake b/libraries/psibase/sdk/pack_service.cmake index 8a41c9487..0c634a12f 100644 --- a/libraries/psibase/sdk/pack_service.cmake +++ b/libraries/psibase/sdk/pack_service.cmake @@ -336,16 +336,11 @@ function(cargo_psibase_package) DEPENDS ${ARG_DEPENDS} cargo-psibase ) - add_custom_command( - OUTPUT ${PACKAGE_OUTPUT} - COMMAND ${CMAKE_COMMAND} -E true - DEPENDS ${TARGET_NAME}_ext - ) - add_custom_command( OUTPUT ${ARG_OUTPUT} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PACKAGE_OUTPUT} ${ARG_OUTPUT} DEPENDS ${PACKAGE_OUTPUT} + DEPENDS ${TARGET_NAME}_ext VERBATIM ) add_custom_target(${TARGET_NAME} ALL DEPENDS ${ARG_OUTPUT} cargo-psibase) From 22332bc249aa5e5b6ad2caa97ebe0063175b7813 Mon Sep 17 00:00:00 2001 From: Mike Manfredi Date: Thu, 26 Sep 2024 22:10:01 +0000 Subject: [PATCH 28/28] removed preload, which fails to await if a method is called before the requested preload has completed --- services/user/Branding/ui/src/App.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/services/user/Branding/ui/src/App.tsx b/services/user/Branding/ui/src/App.tsx index e5f43c462..56ec90b21 100644 --- a/services/user/Branding/ui/src/App.tsx +++ b/services/user/Branding/ui/src/App.tsx @@ -19,7 +19,6 @@ export const App = () => { const init = async () => { await supervisor.onLoaded(); - supervisor.preLoadPlugins([{ service: "branding" }]); await getNetworkName(); };