-
Notifications
You must be signed in to change notification settings - Fork 44
feat(sdk): add version/build information display to web interface #2708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
""" WalkthroughBuild-time environment variables for git commit, branch, and build timestamp are now set and exported in the WASM build script. The SDK exposes new methods to retrieve this metadata at runtime. The web demo displays this build and version information in the page header after SDK initialization. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Browser
participant WasmSdk
User->>Browser: Load index.html
Browser->>Browser: Show "Loading version info..."
Browser->>WasmSdk: initializeSdk(network)
WasmSdk-->>Browser: SDK instance
Browser->>WasmSdk: gitCommit(), gitBranch()
WasmSdk-->>Browser: Return commit and branch strings
Browser->>Browser: Update versionInfo element with formatted version info
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (3)
packages/scripts/build-wasm.sh (1)
115-115
: Don’t clobber existing RUSTFLAGSOverwriting
RUSTFLAGS
discards any caller-supplied flags. Append instead:-export RUSTFLAGS="-C lto=off --cfg=env_vars_set" +export RUSTFLAGS="${RUSTFLAGS:-} -C lto=off --cfg=env_vars_set"Keeps the optimisation tweak while respecting user/CI settings.
packages/wasm-sdk/src/sdk.rs (1)
58-81
: Consider making build-info helpers static functionsThe four getters return compile-time constants and don’t depend on
&self
.
Exposing them as associatedimpl WasmSdk
functions (or free functions) avoids forcing callers to have an SDK instance solely to query metadata:-#[wasm_bindgen(js_name = packageVersion)] -pub fn package_version(&self) -> String { +#[wasm_bindgen(js_name = packageVersion)] +pub fn package_version() -> String {(and similarly for the other three).
This keeps the JS API surface minimal and sidesteps needless allocations during SDK initialisation.packages/wasm-sdk/index.html (1)
794-799
: Consider moving inline styling & placeholder text into CSS for maintainability
<div id="versionInfo" style="font-size: 0.8em; color: #b0b0b0; margin-top: -5px;">Loading version info...</div>
embeds styling and placeholder copy directly in the markup.
Moving these attributes to the existing<style>
block (or a dedicated class) keeps presentation concerns in one place and avoids repeating inline declarations if the element is reused elsewhere.
A minimal diff:- <div id="versionInfo" style="font-size: 0.8em; color: #b0b0b0; margin-top: -5px;"> - Loading version info... - </div> + <div id="versionInfo" class="sdk-version-info">Loading version info...</div>and add in the CSS section:
+.sdk-version-info { + font-size: 0.8em; + color: #b0b0b0; + margin-top: -5px; +}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
packages/scripts/build-wasm.sh
(2 hunks)packages/wasm-sdk/index.html
(2 hunks)packages/wasm-sdk/src/sdk.rs
(1 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Applies to packages/wasm-sdk/index.html : Test the WASM SDK using the web interface at 'index.html' in 'packages/wasm-sdk'
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : For WASM builds, fix 'time not implemented on this platform' errors by using js_sys::Date::now().
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : When implementing WASM SDK functionality, always refer to AI_REFERENCE.md first for accurate method signatures and examples.
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/index.html : When adding new queries or state transitions, update the definitions in index.html.
Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Applies to packages/wasm-sdk/build.sh : Build the WASM SDK by running './build.sh' in 'packages/wasm-sdk'
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : The WASM SDK now fully supports where and orderBy clauses for document queries; use the specified JSON array formats and supported operators.
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : Token functions are methods on WasmSdk, not standalone functions; avoid importing them as standalone.
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/index.html : The WASM SDK now fully supports where and orderBy clauses for document queries; use the specified JSON array formats and supported operators.
Learnt from: lklimek
PR: dashpay/platform#2405
File: packages/wasm-sdk/src/verify.rs:26-68
Timestamp: 2025-02-10T11:26:36.709Z
Learning: In the wasm-sdk package, empty vectors and placeholder values are intentionally used in verification functions during the proof-of-concept stage to ensure proper compilation and type checking.
packages/scripts/build-wasm.sh (10)
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : For WASM builds, fix 'time not implemented on this platform' errors by using js_sys::Date::now().
Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Applies to packages/wasm-sdk/build.sh : Build the WASM SDK by running './build.sh' in 'packages/wasm-sdk'
Learnt from: shumkov
PR: #2248
File: packages/rs-drive-abci/src/main.rs:106-111
Timestamp: 2024-10-17T08:52:54.300Z
Learning: In this project, the environment variable CARGO_PKG_RUST_VERSION
is defined and can be used safely with the env!
macro.
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : When implementing WASM SDK functionality, always refer to AI_REFERENCE.md first for accurate method signatures and examples.
Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Applies to packages/wasm-sdk/generate_docs.py : Keep documentation for the WASM SDK in sync by running 'python3 generate_docs.py' in 'packages/wasm-sdk'
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : Token functions are methods on WasmSdk, not standalone functions; avoid importing them as standalone.
Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Applies to packages/wasm-sdk/index.html : Test the WASM SDK using the web interface at 'index.html' in 'packages/wasm-sdk'
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/generate_docs.py : When adding new queries or state transitions, run python3 generate_docs.py to regenerate documentation.
Learnt from: lklimek
PR: #2374
File: Dockerfile:117-118
Timestamp: 2024-12-16T08:59:40.337Z
Learning: In our Dockerfiles, using ONBUILD ARG CARGO_BUILD_PROFILE=dev
works correctly, and CARGO_BUILD_PROFILE
is recognized in subsequent stages.
Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Use WASM bindings to connect Rust and JavaScript code for cross-language integration
packages/wasm-sdk/src/sdk.rs (12)
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : For WASM builds, fix 'time not implemented on this platform' errors by using js_sys::Date::now().
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : When implementing WASM SDK functionality, always refer to AI_REFERENCE.md first for accurate method signatures and examples.
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : Token functions are methods on WasmSdk, not standalone functions; avoid importing them as standalone.
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : The WASM SDK now fully supports where and orderBy clauses for document queries; use the specified JSON array formats and supported operators.
Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Applies to packages/wasm-sdk/build.sh : Build the WASM SDK by running './build.sh' in 'packages/wasm-sdk'
Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Use WASM bindings to connect Rust and JavaScript code for cross-language integration
Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Applies to packages/wasm-sdk/index.html : Test the WASM SDK using the web interface at 'index.html' in 'packages/wasm-sdk'
Learnt from: lklimek
PR: #2254
File: packages/rs-sdk/src/sdk.rs:585-585
Timestamp: 2024-10-18T15:39:51.172Z
Learning: The 'platform' project uses Rust version 1.80, so code in 'packages/rs-sdk' can use features available in Rust 1.80, such as the abs_diff()
method.
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/index.html : The WASM SDK now fully supports where and orderBy clauses for document queries; use the specified JSON array formats and supported operators.
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/index.html : When adding new queries or state transitions, update the definitions in index.html.
Learnt from: shumkov
PR: #2248
File: packages/rs-drive-abci/src/main.rs:106-111
Timestamp: 2024-10-17T08:52:54.300Z
Learning: In this project, the environment variable CARGO_PKG_RUST_VERSION
is defined and can be used safely with the env!
macro.
Learnt from: shumkov
PR: #2489
File: packages/rs-dpp/Cargo.toml:32-32
Timestamp: 2025-03-11T09:39:23.071Z
Learning: In the Dash Platform project, dependencies are currently managed using Git repository references with tags (repo+tag format in Cargo.toml) rather than published crates, as the team is not currently publishing crates to crates.io.
packages/wasm-sdk/index.html (10)
Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Applies to packages/wasm-sdk/index.html : Test the WASM SDK using the web interface at 'index.html' in 'packages/wasm-sdk'
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/index.html : When adding new queries or state transitions, update the definitions in index.html.
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/index.html : The WASM SDK now fully supports where and orderBy clauses for document queries; use the specified JSON array formats and supported operators.
Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Applies to packages/wasm-sdk/build.sh : Build the WASM SDK by running './build.sh' in 'packages/wasm-sdk'
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : For WASM builds, fix 'time not implemented on this platform' errors by using js_sys::Date::now().
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : When implementing WASM SDK functionality, always refer to AI_REFERENCE.md first for accurate method signatures and examples.
Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Applies to packages/wasm-sdk/generate_docs.py : Keep documentation for the WASM SDK in sync by running 'python3 generate_docs.py' in 'packages/wasm-sdk'
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : The WASM SDK now fully supports where and orderBy clauses for document queries; use the specified JSON array formats and supported operators.
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/generate_docs.py : When adding new queries or state transitions, run python3 generate_docs.py to regenerate documentation.
Learnt from: lklimek
PR: #2405
File: packages/wasm-sdk/src/verify.rs:26-68
Timestamp: 2025-02-10T11:26:36.709Z
Learning: In the wasm-sdk package, empty vectors and placeholder values are intentionally used in verification functions during the proof-of-concept stage to ensure proper compilation and type checking.
🪛 Shellcheck (0.10.0)
packages/scripts/build-wasm.sh
[warning] 107-107: Declare and assign separately to avoid masking return values.
(SC2155)
[warning] 108-108: Declare and assign separately to avoid masking return values.
(SC2155)
[warning] 109-109: Declare and assign separately to avoid masking return values.
(SC2155)
[warning] 135-135: Declare and assign separately to avoid masking return values.
(SC2155)
[warning] 136-136: Declare and assign separately to avoid masking return values.
(SC2155)
[warning] 137-137: Declare and assign separately to avoid masking return values.
(SC2155)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build-wasm-sdk
🔇 Additional comments (3)
packages/scripts/build-wasm.sh (1)
128-129
:wasm-pack build
flag--no-opt
may be invalid – please verify
wasm-pack 0.12.x
recognises--dev
,--release
,--profiling
, but not--no-opt
; an unknown flag aborts the build. Double-check the intended option (perhaps--profiling
or--dev
?).packages/wasm-sdk/src/sdk.rs (1)
58-81
: Implementation looks solidEnvironment variables are accessed correctly (
env!
/option_env!
), fallbacks are sensible, and JS names are camel-cased.packages/wasm-sdk/index.html (1)
2997-3012
: Verify that the new WASM getters are synchronous; otherwise await them
initializeSdk()
builds the display string by calling
sdk.packageVersion()
,sdk.gitCommit()
,sdk.gitBranch()
,sdk.buildTime()
, andsdk.version()
withoutawait
.
If any of thesewasm-bindgen
exports return aPromise
(common when returningJsValue
or strings that cross the boundary), the UI will show[object Promise]
instead of the expected text.
- Confirm in
src/sdk.rs
that each#[wasm_bindgen]
function returnsString
(notJsValue
orPromise
).- If any are async, mark the calls with
await
and make the containing blockasync
.Example fix if needed:
-const packageVersion = sdk.packageVersion(); +const packageVersion = await sdk.packageVersion();Failure to do so will silently degrade the header display and could mislead users about the active build.
@coderabbitai full review |
✅ Actions performedFull review triggered. |
1 similar comment
✅ Actions performedFull review triggered. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (2)
packages/wasm-sdk/src/sdk.rs (1)
58-81
: Prefer compile-time constants to avoid repeated allocationEvery call to these getters allocates a fresh
String
.
Since the values are compile-time literals, cache them inconst
/static
vars and return&'static str
(wasm-bindgen can clone for JS):+const PKG_VERSION: &str = env!("CARGO_PKG_VERSION"); +const GIT_COMMIT: &str = option_env!("GIT_COMMIT").unwrap_or("unknown"); +const GIT_BRANCH: &str = option_env!("GIT_BRANCH").unwrap_or("unknown"); +const BUILD_TIME: &str = option_env!("BUILD_TIME").unwrap_or("unknown"); #[wasm_bindgen(js_name = packageVersion)] -pub fn package_version(&self) -> String { - env!("CARGO_PKG_VERSION").to_string() -} +pub fn package_version(&self) -> String { + PKG_VERSION.into() +}Repeat for the other three methods. This eliminates heap work and shrinks generated wasm a little.
packages/wasm-sdk/index.html (1)
794-799
: Avoid inline styles & introduce semantic class for version banner.The new versionInfo element is rendered with inline styling directly in the markup.
Inline styles make subsequent re-styling, theming, and dark-mode support cumbersome and violate separation-of-concerns.Consider extracting these rules into the existing
<style>
section and binding the element via a CSS class instead:-<div id="versionInfo" style="font-size: 0.8em; color: #b0b0b0; margin-top: -5px;"> - Loading version info... -</div> +<div id="versionInfo" class="version-banner">Loading version info…</div>and then in the stylesheet:
.version-banner { font-size: 0.8em; color: #b0b0b0; margin-top: -5px; }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
packages/scripts/build-wasm.sh
(2 hunks)packages/wasm-sdk/index.html
(2 hunks)packages/wasm-sdk/src/sdk.rs
(1 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Applies to packages/wasm-sdk/index.html : Test the WASM SDK using the web interface at 'index.html' in 'packages/wasm-sdk'
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : For WASM builds, fix 'time not implemented on this platform' errors by using js_sys::Date::now().
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : When implementing WASM SDK functionality, always refer to AI_REFERENCE.md first for accurate method signatures and examples.
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/index.html : When adding new queries or state transitions, update the definitions in index.html.
Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Applies to packages/wasm-sdk/build.sh : Build the WASM SDK by running './build.sh' in 'packages/wasm-sdk'
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : The WASM SDK now fully supports where and orderBy clauses for document queries; use the specified JSON array formats and supported operators.
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : Token functions are methods on WasmSdk, not standalone functions; avoid importing them as standalone.
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/index.html : The WASM SDK now fully supports where and orderBy clauses for document queries; use the specified JSON array formats and supported operators.
Learnt from: lklimek
PR: dashpay/platform#2405
File: packages/wasm-sdk/src/verify.rs:26-68
Timestamp: 2025-02-10T11:26:36.709Z
Learning: In the wasm-sdk package, empty vectors and placeholder values are intentionally used in verification functions during the proof-of-concept stage to ensure proper compilation and type checking.
packages/scripts/build-wasm.sh (13)
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : For WASM builds, fix 'time not implemented on this platform' errors by using js_sys::Date::now().
Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Applies to packages/wasm-sdk/build.sh : Build the WASM SDK by running './build.sh' in 'packages/wasm-sdk'
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : When implementing WASM SDK functionality, always refer to AI_REFERENCE.md first for accurate method signatures and examples.
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : Token functions are methods on WasmSdk, not standalone functions; avoid importing them as standalone.
Learnt from: shumkov
PR: #2248
File: packages/rs-drive-abci/src/main.rs:106-111
Timestamp: 2024-10-17T08:52:54.300Z
Learning: In this project, the environment variable CARGO_PKG_RUST_VERSION
is defined and can be used safely with the env!
macro.
Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Applies to packages/wasm-sdk/generate_docs.py : Keep documentation for the WASM SDK in sync by running 'python3 generate_docs.py' in 'packages/wasm-sdk'
Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Use WASM bindings to connect Rust and JavaScript code for cross-language integration
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/generate_docs.py : When adding new queries or state transitions, run python3 generate_docs.py to regenerate documentation.
Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Applies to packages/wasm-sdk/index.html : Test the WASM SDK using the web interface at 'index.html' in 'packages/wasm-sdk'
Learnt from: lklimek
PR: #2381
File: packages/rs-sdk/scripts/connect_to_remote.sh:0-0
Timestamp: 2024-12-10T12:39:38.182Z
Learning: When reviewing scripts in packages/rs-sdk/scripts/
, avoid suggesting additional error handling and timeout management that complicate the script without adding significant value.
Learnt from: lklimek
PR: #2344
File: .github/actions/sccache/action.yaml:0-0
Timestamp: 2024-11-26T12:46:54.812Z
Learning: In the .github/actions/sccache/action.yaml
file, the environment variables CC
and CXX
need quotes around their values (e.g., CC="sccache cc"
) to be interpreted correctly.
Learnt from: lklimek
PR: #2318
File: Dockerfile:0-0
Timestamp: 2024-11-13T10:32:02.981Z
Learning: In the Dockerfile's sccache configuration script, the team relies on sccache to validate required arguments, so explicit error handling for missing variables is unnecessary.
Learnt from: lklimek
PR: #2374
File: Dockerfile:117-118
Timestamp: 2024-12-16T08:59:40.337Z
Learning: In our Dockerfiles, using ONBUILD ARG CARGO_BUILD_PROFILE=dev
works correctly, and CARGO_BUILD_PROFILE
is recognized in subsequent stages.
packages/wasm-sdk/src/sdk.rs (12)
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : For WASM builds, fix 'time not implemented on this platform' errors by using js_sys::Date::now().
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : When implementing WASM SDK functionality, always refer to AI_REFERENCE.md first for accurate method signatures and examples.
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : Token functions are methods on WasmSdk, not standalone functions; avoid importing them as standalone.
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : The WASM SDK now fully supports where and orderBy clauses for document queries; use the specified JSON array formats and supported operators.
Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Applies to packages/wasm-sdk/build.sh : Build the WASM SDK by running './build.sh' in 'packages/wasm-sdk'
Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Use WASM bindings to connect Rust and JavaScript code for cross-language integration
Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Applies to packages/wasm-sdk/index.html : Test the WASM SDK using the web interface at 'index.html' in 'packages/wasm-sdk'
Learnt from: lklimek
PR: #2254
File: packages/rs-sdk/src/sdk.rs:585-585
Timestamp: 2024-10-18T15:39:51.172Z
Learning: The 'platform' project uses Rust version 1.80, so code in 'packages/rs-sdk' can use features available in Rust 1.80, such as the abs_diff()
method.
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/index.html : The WASM SDK now fully supports where and orderBy clauses for document queries; use the specified JSON array formats and supported operators.
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/index.html : When adding new queries or state transitions, update the definitions in index.html.
Learnt from: shumkov
PR: #2248
File: packages/rs-drive-abci/src/main.rs:106-111
Timestamp: 2024-10-17T08:52:54.300Z
Learning: In this project, the environment variable CARGO_PKG_RUST_VERSION
is defined and can be used safely with the env!
macro.
Learnt from: shumkov
PR: #2489
File: packages/rs-dpp/Cargo.toml:32-32
Timestamp: 2025-03-11T09:39:23.071Z
Learning: In the Dash Platform project, dependencies are currently managed using Git repository references with tags (repo+tag format in Cargo.toml) rather than published crates, as the team is not currently publishing crates to crates.io.
packages/wasm-sdk/index.html (8)
Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Applies to packages/wasm-sdk/index.html : Test the WASM SDK using the web interface at 'index.html' in 'packages/wasm-sdk'
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/index.html : When adding new queries or state transitions, update the definitions in index.html.
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/index.html : The WASM SDK now fully supports where and orderBy clauses for document queries; use the specified JSON array formats and supported operators.
Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Applies to packages/wasm-sdk/build.sh : Build the WASM SDK by running './build.sh' in 'packages/wasm-sdk'
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : When implementing WASM SDK functionality, always refer to AI_REFERENCE.md first for accurate method signatures and examples.
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : For WASM builds, fix 'time not implemented on this platform' errors by using js_sys::Date::now().
Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Applies to packages/wasm-sdk/generate_docs.py : Keep documentation for the WASM SDK in sync by running 'python3 generate_docs.py' in 'packages/wasm-sdk'
Learnt from: lklimek
PR: #2405
File: packages/wasm-sdk/src/verify.rs:26-68
Timestamp: 2025-02-10T11:26:36.709Z
Learning: In the wasm-sdk package, empty vectors and placeholder values are intentionally used in verification functions during the proof-of-concept stage to ensure proper compilation and type checking.
🔇 Additional comments (1)
packages/scripts/build-wasm.sh (1)
99-110
: Nice extraction of build-metadata logicMoving the duplicated
export
statements intoset_build_env_vars
removes redundancy and resolves the earlier SC2155 warnings.
The helper is concise and the fallback to"unknown"
covers CI/detached-HEAD cases well.
export RUSTFLAGS="-C lto=off --cfg=env_vars_set" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Preserve existing RUSTFLAGS
instead of clobbering it
export RUSTFLAGS="-C lto=off --cfg=env_vars_set"
overwrites any flags a caller might have set (e.g. -C target-cpu=native
). Safer to append:
-export RUSTFLAGS="-C lto=off --cfg=env_vars_set"
+export RUSTFLAGS="${RUSTFLAGS:-} -C lto=off --cfg=env_vars_set"
This keeps the new switches while respecting upstream configuration.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
export RUSTFLAGS="-C lto=off --cfg=env_vars_set" | |
export RUSTFLAGS="${RUSTFLAGS:-} -C lto=off --cfg=env_vars_set" |
🤖 Prompt for AI Agents
In packages/scripts/build-wasm.sh at lines 124 to 125, the current export of
RUSTFLAGS overwrites any existing flags set by the caller. To fix this, modify
the export statement to append the new flags to the existing RUSTFLAGS variable
instead of replacing it, ensuring that any previously set flags are preserved
while adding "-C lto=off --cfg=env_vars_set".
// Display version information in header | ||
try { | ||
const gitCommit = sdk.gitCommit(); | ||
const gitBranch = sdk.gitBranch(); | ||
|
||
const versionText = `Built from branch: ${gitBranch} (${gitCommit})`; | ||
document.getElementById('versionInfo').textContent = versionText; | ||
document.getElementById('versionInfo').title = `Branch: ${gitBranch}\nCommit: ${gitCommit}`; | ||
} catch (error) { | ||
console.warn('Failed to get version info:', error); | ||
document.getElementById('versionInfo').textContent = 'Version info unavailable'; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Expose all available build metadata & improve formatting/fallbacks.
Only branch/commit are surfaced; packageVersion()
and buildTime()
exported in sdk.rs
remain unused.
Additionally, very long commit hashes reduce readability and empty/placeholder values aren’t handled.
-const gitCommit = sdk.gitCommit();
-const gitBranch = sdk.gitBranch();
-
-const versionText = `Built from branch: ${gitBranch} (${gitCommit})`;
-document.getElementById('versionInfo').textContent = versionText;
-document.getElementById('versionInfo').title = `Branch: ${gitBranch}\nCommit: ${gitCommit}`;
+const gitCommit = sdk.gitCommit?.() ?? '';
+const gitBranch = sdk.gitBranch?.() ?? '';
+const pkgVer = sdk.packageVersion?.() ?? '';
+const buildTime = sdk.buildTime?.() ?? '';
+
+// keep first 9 chars of hash for compactness
+const shortCommit = gitCommit.slice(0, 9);
+
+let header = [];
+if (pkgVer) header.push(`v${pkgVer}`);
+if (shortCommit) header.push(shortCommit + (gitBranch ? `@${gitBranch}` : ''));
+if (buildTime) header.push(`• Built ${buildTime}`);
+
+const versionText = header.join(' ');
+
+const tooltip = `Package: ${pkgVer || 'unknown'}\nBranch: ${gitBranch || 'unknown'}\nCommit: ${gitCommit || 'unknown'}\nBuilt: ${buildTime || 'unknown'}`;
+
+const versionElem = document.getElementById('versionInfo');
+versionElem.textContent = versionText || 'Version info unavailable';
+versionElem.title = tooltip;
Benefits:
- Surfaces all metadata the build script provides.
- Shortens the commit hash for UX while retaining full hash in tooltip.
- Gracefully degrades if any field is missing.
- Guards against optional chaining runtime errors on older builds.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
// Display version information in header | |
try { | |
const gitCommit = sdk.gitCommit(); | |
const gitBranch = sdk.gitBranch(); | |
const versionText = `Built from branch: ${gitBranch} (${gitCommit})`; | |
document.getElementById('versionInfo').textContent = versionText; | |
document.getElementById('versionInfo').title = `Branch: ${gitBranch}\nCommit: ${gitCommit}`; | |
} catch (error) { | |
console.warn('Failed to get version info:', error); | |
document.getElementById('versionInfo').textContent = 'Version info unavailable'; | |
} | |
// Display version information in header | |
try { | |
const gitCommit = sdk.gitCommit?.() ?? ''; | |
const gitBranch = sdk.gitBranch?.() ?? ''; | |
const pkgVer = sdk.packageVersion?.() ?? ''; | |
const buildTime = sdk.buildTime?.() ?? ''; | |
// keep first 9 chars of hash for compactness | |
const shortCommit = gitCommit.slice(0, 9); | |
let header = []; | |
if (pkgVer) header.push(`v${pkgVer}`); | |
if (shortCommit) header.push(shortCommit + (gitBranch ? `@${gitBranch}` : '')); | |
if (buildTime) header.push(`• Built ${buildTime}`); | |
const versionText = header.join(' '); | |
const tooltip = | |
`Package: ${pkgVer || 'unknown'}\n` + | |
`Branch: ${gitBranch || 'unknown'}\n` + | |
`Commit: ${gitCommit || 'unknown'}\n` + | |
`Built: ${buildTime || 'unknown'}`; | |
const versionElem = document.getElementById('versionInfo'); | |
versionElem.textContent = versionText || 'Version info unavailable'; | |
versionElem.title = tooltip; | |
} catch (error) { | |
console.warn('Failed to get version info:', error); | |
document.getElementById('versionInfo').textContent = 'Version info unavailable'; | |
} |
🤖 Prompt for AI Agents
In packages/wasm-sdk/index.html around lines 2997 to 3009, enhance the version
info display by including packageVersion() and buildTime() from sdk.rs along
with gitBranch() and gitCommit(). Shorten the displayed commit hash for
readability but keep the full hash in the tooltip. Add checks to handle missing
or empty values gracefully to avoid runtime errors, and ensure all metadata
fields are shown with proper formatting and fallback text if unavailable.
- Add new WASM functions to expose package version, git commit, branch, and build time - Modify build script to inject git information at build time - Update index.html to display version info in header with tooltip - Provides developers with clear build context and version information 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Create set_build_env_vars() helper function to set build variables - Remove duplicate code between wasm-pack and cargo build paths - Fix SC2155 shellcheck warning by separating variable assignment from export - Maintain same functionality while improving code maintainability 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
828d0fc
to
2914e15
Compare
Issue being fixed or feature implemented
The WASM SDK web interface at
packages/wasm-sdk/index.html
does not show version, build, or commit information, making it difficult for developers to know which version they are testing against. This can be important for debugging and ensuring they're working with the correct build.What was done?
Added new WASM functions in
src/sdk.rs
:packageVersion()
- exposes Cargo package version (not used because it's currently not set in Cargo.toml, but presumably will be at some point)gitCommit()
- exposes git commit hash (injected at build time)gitBranch()
- exposes git branch (injected at build time)buildTime()
- exposes build timestamp (injected at build time)Modified build script (
packages/scripts/build-wasm.sh
):git rev-parse
andgit branch
date -u
Updated web interface (
index.html
):Example display:
v2.0.0 ([email protected]) • Protocol v10 • Built 2025-07-24T17:08:34Z
How Has This Been Tested?
wasm-pack
to be installed for buildingTesting environment:
Breaking Changes
None. This is a purely additive feature that enhances the developer experience without changing any existing functionality.
Checklist:
For repository code-owners and collaborators only
Summary by CodeRabbit
Summary by CodeRabbit
New Features
Chores