wallets 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +36 -0
- data/.rubocop.yml +8 -0
- data/.simplecov +37 -0
- data/AGENTS.md +5 -0
- data/CHANGELOG.md +17 -0
- data/CLAUDE.md +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +740 -0
- data/Rakefile +30 -0
- data/lib/generators/wallets/install_generator.rb +43 -0
- data/lib/generators/wallets/templates/create_wallets_tables.rb.erb +113 -0
- data/lib/generators/wallets/templates/initializer.rb +87 -0
- data/lib/wallets/callback_context.rb +28 -0
- data/lib/wallets/callbacks.rb +53 -0
- data/lib/wallets/configuration.rb +119 -0
- data/lib/wallets/engine.rb +23 -0
- data/lib/wallets/models/allocation.rb +47 -0
- data/lib/wallets/models/concerns/has_wallets.rb +93 -0
- data/lib/wallets/models/transaction.rb +154 -0
- data/lib/wallets/models/transfer.rb +122 -0
- data/lib/wallets/models/wallet.rb +654 -0
- data/lib/wallets/railtie.rb +7 -0
- data/lib/wallets/version.rb +5 -0
- data/lib/wallets.rb +45 -0
- data/sig/wallets.rbs +3 -0
- data/wallets.webp +0 -0
- metadata +96 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: f59353d157eeea702a8a157b16914cba3f9fbb6dcaa8845a3ffdbd911fc51777
|
|
4
|
+
data.tar.gz: e1c1d836b7a8013ad6a84da9aa0ba4924361b0d023797a265d15b8bde262d998
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: a1a2714ddd409c47b62efad44eafadce0381ce8843ab71bdbbab4c57f2858d03fdb62980e10be00854009f47405805c54cfada0e3f2837b82334128b19b4bd9a
|
|
7
|
+
data.tar.gz: 21f39ed24795f1b78090c5f1b10e1009e0f42edaa48384c86f3812bf6ea9591ded673a0408df070d0909284bdaefb176ce42376677c70f5abc873e8614877d99
|
data/.gitignore
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/.bundle/
|
|
2
|
+
/.yardoc
|
|
3
|
+
/_yardoc/
|
|
4
|
+
/coverage/
|
|
5
|
+
/doc/
|
|
6
|
+
/pkg/
|
|
7
|
+
/spec/reports/
|
|
8
|
+
/tmp/
|
|
9
|
+
|
|
10
|
+
test/dummy/db/*.sqlite3*
|
|
11
|
+
test/dummy/log/*.log
|
|
12
|
+
test/dummy/tmp/
|
|
13
|
+
test/dummy/public/packs/
|
|
14
|
+
test/dummy/public/packs-test/
|
|
15
|
+
test/dummy/node_modules/
|
|
16
|
+
test/dummy/Gemfile.lock
|
|
17
|
+
test/dummy/config/master.key
|
|
18
|
+
test/dummy/storage/*.sqlite3*
|
|
19
|
+
test/dummy/log/*
|
|
20
|
+
test/coverage/*
|
|
21
|
+
**/.kamal/
|
|
22
|
+
deploy.yml
|
|
23
|
+
.DS_Store
|
|
24
|
+
|
|
25
|
+
/Gemfile.lock
|
|
26
|
+
/gemfiles/*.gemfile.lock
|
|
27
|
+
|
|
28
|
+
/dist/
|
|
29
|
+
*.gem
|
|
30
|
+
|
|
31
|
+
.cursor/
|
|
32
|
+
.claude/
|
|
33
|
+
.aux/
|
|
34
|
+
|
|
35
|
+
TODO
|
|
36
|
+
pay.md
|
data/.rubocop.yml
ADDED
data/.simplecov
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# SimpleCov configuration file (auto-loaded before test suite)
|
|
4
|
+
# This keeps test_helper.rb clean and follows best practices
|
|
5
|
+
|
|
6
|
+
SimpleCov.start do
|
|
7
|
+
# Use SimpleFormatter for terminal-only output (no HTML generation)
|
|
8
|
+
formatter SimpleCov::Formatter::SimpleFormatter
|
|
9
|
+
|
|
10
|
+
# Track coverage for the lib directory (gem source code)
|
|
11
|
+
add_filter "/test/"
|
|
12
|
+
add_filter "/lib/generators/"
|
|
13
|
+
|
|
14
|
+
# Track Ruby files in lib directory
|
|
15
|
+
track_files "lib/**/*.rb"
|
|
16
|
+
|
|
17
|
+
# Enable branch coverage for more detailed metrics
|
|
18
|
+
enable_coverage :branch
|
|
19
|
+
|
|
20
|
+
# Keep the gate focused on the runtime wallet core, not install scaffolding.
|
|
21
|
+
minimum_coverage line: 80, branch: 50
|
|
22
|
+
|
|
23
|
+
# Disambiguate parallel test runs
|
|
24
|
+
command_name "Job #{ENV['TEST_ENV_NUMBER']}" if ENV['TEST_ENV_NUMBER']
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Print coverage summary to terminal after tests complete
|
|
28
|
+
SimpleCov.at_exit do
|
|
29
|
+
SimpleCov.result.format!
|
|
30
|
+
puts "\n" + "=" * 60
|
|
31
|
+
puts "COVERAGE SUMMARY"
|
|
32
|
+
puts "=" * 60
|
|
33
|
+
puts "Line Coverage: #{SimpleCov.result.covered_percent.round(2)}%"
|
|
34
|
+
branch_coverage = SimpleCov.result.coverage_statistics[:branch]&.percent&.round(2) || "N/A"
|
|
35
|
+
puts "Branch Coverage: #{branch_coverage}%"
|
|
36
|
+
puts "=" * 60
|
|
37
|
+
end
|
data/AGENTS.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to AI Agents (like OpenAI's Codex, Cursor Agent, Claude Code, etc) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
Please go ahead and read the full context for this project at `.cursor/rules/0-overview.mdc` and `.cursor/rules/1-quality.mdc` now. Also read the README for a good overview of the project.
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
## [0.1.0] - 2026-03-18
|
|
2
|
+
|
|
3
|
+
Initial release.
|
|
4
|
+
|
|
5
|
+
- Multi-asset wallets per owner via `has_wallets` — `user.wallet(:usd)`, `user.wallet(:gems)`, etc.
|
|
6
|
+
- Append-only transaction ledger with `credit`, `debit`, and `transfer_to` APIs
|
|
7
|
+
- FIFO allocation for expiring balances — oldest credits consumed first
|
|
8
|
+
- Transfer expiration policies: `:preserve` (default), `:none`, `:fixed`
|
|
9
|
+
- Transfers split into multiple inbound legs when consuming buckets with different expirations
|
|
10
|
+
- Embeddability hooks for other gems to reuse the ledger core with custom tables/config/callbacks
|
|
11
|
+
- Idempotent `create_for_owner!` with race condition handling
|
|
12
|
+
- Row-level locking to prevent double-spending
|
|
13
|
+
- Balance snapshots on every transaction for reconciliation
|
|
14
|
+
- Rich metadata support on wallets, transactions, and transfers
|
|
15
|
+
- Lifecycle callbacks: `on_balance_credited`, `on_balance_debited`, `on_transfer_completed`, etc.
|
|
16
|
+
- Install generator with migrations and initializer
|
|
17
|
+
- Rails 6.1+ support (tested through Rails 8.x)
|
data/CLAUDE.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
Please go ahead and read the full context for this project at `.cursor/rules/0-overview.mdc` and `.cursor/rules/1-quality.mdc` now. Also read the README for a good overview of the project.
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Javi R
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|