Skip to content

Commit

Permalink
fix unsignedHyper's new prototype (#719)
Browse files Browse the repository at this point in the history
* fix unsignedHyper's new prototype

* use bigint for better precision
  • Loading branch information
piyalbasu authored Sep 20, 2023
1 parent d74f602 commit 121b91c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
3 changes: 1 addition & 2 deletions src/actions/transactionBuilder.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import axios from "axios";
import { UnsignedHyper } from "stellar-sdk";

// Resets everything to it's default state
export const RESET_TXBUILDER = "RESET_TXBUILDER";
Expand Down Expand Up @@ -88,7 +87,7 @@ export function fetchSequence(accountId, horizonBaseUrl) {
.then((r) =>
dispatch({
type: FETCH_SEQUENCE_SUCCESS,
sequence: UnsignedHyper.fromString(r.data.sequence).add(1).toString(),
sequence: (BigInt(r.data.sequence) + BigInt(1)).toString(),
}),
)
.catch((r) => dispatch({ type: FETCH_SEQUENCE_FAIL, payload: r }));
Expand Down
2 changes: 1 addition & 1 deletion src/components/FormComponents/MemoPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function contentValidator(value) {
value.content !== UnsignedHyper.fromString(value.content).toString()
) {
return `MEMO_ID is an unsigned 64-bit integer and the max valid
value is ${UnsignedHyper.MAX_UNSIGNED_VALUE.toString()}`;
value is 18446744073709551615`;
}
break;
case "MEMO_HASH":
Expand Down
6 changes: 2 additions & 4 deletions src/helpers/Libify.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// Libify could also be used to generate source code from input but might not be
// the best choice since source code differs based on content.

import Sdk from "stellar-sdk";
import * as Sdk from "stellar-sdk";
import * as SorobanSdk from "soroban-client";
import defaults from "lodash/defaults";
import each from "lodash/each";
Expand Down Expand Up @@ -765,9 +765,7 @@ Libify.buildTransaction = function (attributes, operations, networkPassphrase) {

try {
let account;
const sequence = Sdk.UnsignedHyper.fromString(attributes.sequence)
.subtract(1)
.toString();
const sequence = (BigInt(attributes.sequence) - BigInt(1)).toString();

if (Sdk.StrKey.isValidMed25519PublicKey(attributes.sourceAccount)) {
account = new Sdk.MuxedAccount.fromAddress(
Expand Down

0 comments on commit 121b91c

Please sign in to comment.