Skip to content
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

fix: faucet not funding full amount #12

Merged
merged 7 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ on:
- "v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+"
pull_request:
branches:
- "main"

jobs:
build-and-publish-latest:
Expand Down
5 changes: 4 additions & 1 deletion internal/chain/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ func (b *TxBuild) Transfer(ctx context.Context, to string, value *big.Int) (byte
if err != nil {
panic(err)
}
log.Infof("DEBUG: value passed into transfer is %s", value)


amount, err := convertToUint128(value)
if err != nil {
Expand Down Expand Up @@ -98,7 +100,8 @@ func (b *TxBuild) Transfer(ctx context.Context, to string, value *big.Int) (byte
}

// convertToUint128 converts a string to a Uint128 protobuf
func convertToUint128(numStr *big.Int) (*primproto.Uint128, error) {
func convertToUint128(num *big.Int) (*primproto.Uint128, error) {
numStr := new(big.Int).Set(num)

// check if the number is negative or overflows Uint128
if numStr.Sign() < 0 {
Expand Down
8 changes: 6 additions & 2 deletions internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ func (s *Server) consumeQueue() {
defer s.mutex.Unlock()
for len(s.queue) != 0 {
address := <-s.queue
txHash, err := s.Transfer(context.Background(), address, s.cfg.payout)
log.Infof("DEBUG: cfg value before transfer from queue is %s", s.cfg.payoutNano)
txHash, err := s.Transfer(context.Background(), address, s.cfg.payoutNano)
log.Infof("DEBUG: cfg value after transfer from queue is %s", s.cfg.payoutNano)
if err != nil {
log.WithError(err).Error("Failed to handle transaction in the queue")
} else {
Expand Down Expand Up @@ -102,7 +104,9 @@ func (s *Server) handleClaim() http.HandlerFunc {

ctx, cancel := context.WithTimeout(r.Context(), 5*time.Second)
defer cancel()
txHash, err := s.Transfer(ctx, address, s.cfg.payout)
log.Infof("DEBUG: cfg value before transfer from handleClaim is %s", s.cfg.payoutNano)
txHash, err := s.Transfer(ctx, address, s.cfg.payoutNano)
log.Infof("DEBUG: cfg value after transfer from handleClaim is %s", s.cfg.payoutNano)
s.mutex.Unlock()
if err != nil {
log.WithError(err).Error("Failed to send transaction")
Expand Down
Loading