Contribution Guide
Relevant source files
The following files were used as context for generating this wiki page:This guide provides instructions for developers wishing to contribute to the sui-svelte-wallet-kit project. It covers setting up the development environment, coding standards, running checks, and the process for building and publishing the package. Adhering to these guidelines ensures code quality and consistency across the project.
The project is a Svelte 5 wallet kit for the Sui blockchain, built with TypeScript and Svelte Runes. It is managed using pnpm as the package manager.
Sources: README.md:3-8, package.json:2,44
1. Project Setup
To begin development, clone the repository and install the dependencies. The project uses pnpm for package management.
# Install dependencies
pnpm i
This command installs all necessary dependencies and devDependencies as defined in the package.json file.
Sources: README.md:278-281, package.json:44,61
Key Dependencies
The project relies on several key libraries for its functionality.
| Dependency | Description |
|---|---|
@mysten/sui | Core library for interacting with the Sui blockchain. |
@mysten/enoki | Used for zkLogin with Google. |
@mysten/wallet-standard | Implements the wallet standard for wallet interactions. |
@suiet/wallet-sdk | Provides wallet detection and connection logic. |
svelte | The core Svelte framework (version 5). |
@sveltejs/kit | The Svelte application framework for building the demo and the package. |
typescript | Provides static typing for the entire codebase. |
eslint | Enforces code style and quality. |
prettier | Used for automatic code formatting. |
Sources: package.json:62-85
2. Development Workflow
The development process involves running a local development server, adhering to coding standards through linting and formatting, and ensuring type safety with TypeScript checks.
Available Scripts
The package.json file defines several scripts to aid in development.
| Script | Description |
|---|---|
dev | Starts the Vite development server for the example app. |
build | Builds the production version of the example app. |
package | Packages the library for distribution into the dist/ directory. |
check | Runs svelte-check to perform type-checking across the project. |
format | Formats all files in the project using Prettier. |
lint | Checks for formatting issues with Prettier and runs ESLint. |
lint:package | Uses publint to check for issues with the packaged dist/ output. |
publish:patch | Bumps the patch version, builds, and publishes the package. |
Sources: package.json:13-27, README.md:278-287
Coding Standards
The project enforces strict coding standards using ESLint and Prettier.
ESLint Configuration
The ESLint setup is defined in eslint.config.js. It combines configurations for JavaScript, TypeScript, and Svelte, and integrates with Prettier to avoid conflicting rules.
Key configurations include:
- Base Rules:
js.configs.recommendedfor standard JavaScript rules. - TypeScript:
ts.configs.recommendedfor TypeScript-specific rules. Theno-undefrule is disabled as TypeScript's own checks handle this. - Svelte:
svelte.configs.recommendedandsvelte.configs.prettierfor Svelte files. - Prettier:
eslint-config-prettieris included to disable ESLint rules that conflict with Prettier. - Globals: Browser and Node.js global variables are enabled.
- Parser:
typescript-eslintis used as the parser, including for.sveltefiles.
Sources: eslint.config.js:5-39
TypeScript Configuration
The tsconfig.json file configures the TypeScript compiler with strict settings to ensure type safety.
Key compilerOptions include:
strict: true: Enables all strict type-checking options.checkJs: true: Reports errors in.jsfiles.moduleResolution: "bundler": Aligns module resolution with modern bundlers.esModuleInterop: true: Enables compatibility with CommonJS modules.
Sources: tsconfig.json:3-11
3. Building and Publishing
The process of preparing a new release is automated through scripts for building, checking, and publishing.
Build Process
The library is packaged using the package script, which executes svelte-kit sync && svelte-package. This command compiles the Svelte components and TypeScript code from src/lib into JavaScript and type definition files within the dist/ directory.
This diagram illustrates the build flow initiated by the prepack script.
Sources: package.json:18-19, README.md:282
Pre-Publish Checks
Before publishing, a sanity check script, scripts/publish-check.sh, must be run. This script validates the package structure and ensures all necessary components are in place for a successful release.
The script performs the following checks:
- File Existence: Verifies that
package.json,README.md,LICENSE, andsrc/lib/index.tsexist. package.jsonFields: Ensuresname,version, anddescriptionfields are present.- Build Success: Runs
pnpm run prepackand confirms it exits without errors. distDirectory: Checks that thedist/directory was created.- Output Files: Confirms that
dist/index.jsanddist/index.d.tsexist in the build output.
This diagram shows the validation steps in the publish-check.sh script.
Sources: scripts/publish-check.sh
Publishing a New Version
The project uses pnpm version combined with build and publish steps for releasing new versions. The publish:* scripts automate this process.
pnpm run publish:patch: Bumps the patch version (e.g., 0.9.1 -> 0.9.2).pnpm run publish:minor: Bumps the minor version (e.g., 0.9.1 -> 0.10.0).pnpm run publish:major: Bumps the major version (e.g., 0.9.1 -> 1.0.0).
Each script follows the same sequence:
pnpm version <type>: Updates the version inpackage.jsonand creates a git tag.pnpm build: Builds the package for production.pnpm publish: Publishes the new version to the npm registry.
Sources: package.json:25-27
Conclusion
Contributing to sui-svelte-wallet-kit involves following a structured workflow that prioritizes code quality, type safety, and consistency. By using the provided scripts for development, checking, and publishing, contributors can ensure their changes integrate smoothly and maintain the high standards of the project. Always run the lint and check scripts, and validate the package with publish-check.sh before submitting a contribution.