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

Thread 90: Swift runtime failure: arithmetic overflow #427

Closed
ramesh-aureus opened this issue Jan 14, 2025 · 6 comments
Closed

Thread 90: Swift runtime failure: arithmetic overflow #427

ramesh-aureus opened this issue Jan 14, 2025 · 6 comments
Labels
bug Something isn't working
Milestone

Comments

@ramesh-aureus
Copy link

Description

While performing any kind of transaction , the ios screen freezes and the xcode takes me to Timestamp file , to this code:

internal func subtracting(nanos: UInt64) -> Self {
    Self(fromUnixTimestampNanos: unixTimestampNanos - nanos)
}

and shows error as :
Thread 90: Swift runtime failure: arithmetic overflow

my implementation code (creating Hedera wallet):

let transactionResponse = try await AccountCreateTransaction()
.key(.single(newPublicKey)) // Set the public key for the account
.initialBalance(Hbar.fromTinybars(0)) // Set the initial balance to 0 HBAR
.execute(client)

Im getting the same error on token transferring, associating , and any other transaction related tasks.

Steps to reproduce

Integrate Hedera-swift-sdk

code on AppDelgate:

let transactionResponse = try await AccountCreateTransaction()
.key(.single(newPublicKey)) // Set the public key for the account
.initialBalance(Hbar.fromTinybars(0)) // Set the initial balance to 0 HBAR
.execute(client)

Additional context

No response

Hedera network

mainnet

Version

latest

Operating system

macOS

@ramesh-aureus ramesh-aureus added the bug Something isn't working label Jan 14, 2025
@RickyLB
Copy link
Contributor

RickyLB commented Jan 21, 2025

@ramesh-aureus Thanks for your patience. Seems though bounds will need to be established in subtracting() to prevent nanos from being greater unixTimestampNanos. Should be a quick fix!

@Ramesh-Giri
Copy link

Thanks for your response @RickyLB . Is there anything i need to do my end?

@ramesh-aureus
Copy link
Author

@RickyLB its working pretty fine on IOS simulator though.. im only having problems on the real devices.

@ramesh-aureus
Copy link
Author

ramesh-aureus commented Jan 30, 2025

Any update on this @RickyLB ??

@RickyLB
Copy link
Contributor

RickyLB commented Jan 30, 2025

Hi @ramesh-aureus, can you check the value of Timestamp.now.UnixTimestampNanos before the program crashes?

@ramesh-aureus
Copy link
Author

my code:

func getHederaTimestampNanos() -> UInt64 {
    let seconds = UInt64(Date().timeIntervalSince1970)  // Get current Unix time in seconds
    let nanos = UInt64(Date().timeIntervalSince1970.truncatingRemainder(dividingBy: 1) * 1_000_000_000) // Get nanoseconds part
    return (seconds * 1_000_000_000) + nanos
}

log:
Debug: About to execute transaction 1738295910254300117

xcode descriptions:

nanos UInt64 6183871904
self Hedera.Timestamp
seconds UInt64 0
subSecondNanos UInt32 2147483647

@RickyLB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants
@Ramesh-Giri @RickyLB @rwalworth @ramesh-aureus and others