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

chore: change timestamp type for ton-proof #47

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pixelplex
Copy link

@pixelplex pixelplex commented Aug 7, 2024

The timestamp parameter within the ton_proof in the @tonconnect/sdk has historically been implemented as a number type, a practice that has been consistently adopted across all dApps and wallets with strict validation. To align the specification with this widespread implementation, I propose updating the specification to officially change the timestamp parameter type from a string to a number. After a thorough review, I can confirm that all existing wallets currently utilize the number type for this parameter, ensuring that this update would maintain compatibility with existing systems.

@@ -109,7 +109,7 @@ type TonProofItemReply = TonProofItemReplySuccess | TonProofItemReplyError;
type TonProofItemReplySuccess = {
name: "ton_proof";
proof: {
timestamp: string; // 64-bit unix epoch time of the signing operation (seconds)
timestamp: number; // 58-bit unix epoch time of the signing operation (seconds)
Copy link

@thekiba thekiba Sep 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
timestamp: number; // 58-bit unix epoch time of the signing operation (seconds)
timestamp: number; // 53-bit unix epoch time of the signing operation (seconds)

JavaScript's number type uses IEEE 754 double-precision floating-point, which has 53 bits of precision for integers. Timestamps beyond 53 bits can lose precision.

For more details, see the ECMAScript specification on number type: https://262.ecma-international.org/15.0/#sec-ecmascript-language-types-number-type

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants