From 5ed52ab68d6c5305a10f4532087e08de75c814c5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 27 Oct 2023 10:34:55 -0700 Subject: [PATCH 1/4] Bump browserify-sign from 4.2.1 to 4.2.2 (#708) Bumps [browserify-sign](https://github.com/crypto-browserify/browserify-sign) from 4.2.1 to 4.2.2. - [Changelog](https://github.com/browserify/browserify-sign/blob/main/CHANGELOG.md) - [Commits](https://github.com/crypto-browserify/browserify-sign/compare/v4.2.1...v4.2.2) --- updated-dependencies: - dependency-name: browserify-sign dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/yarn.lock b/yarn.lock index 705ebb49..5d57df6e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2146,7 +2146,7 @@ bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.11.9: resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.12.0.tgz#775b3f278efbb9718eec7361f483fb36fbbfea88" integrity sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA== -bn.js@^5.0.0, bn.js@^5.1.1: +bn.js@^5.0.0, bn.js@^5.2.1: version "5.2.1" resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.1.tgz#0bc527a6a0d18d0aa8d5b0538ce4a77dccfa7b70" integrity sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ== @@ -2239,7 +2239,7 @@ browserify-des@^1.0.0: inherits "^2.0.1" safe-buffer "^5.1.2" -browserify-rsa@^4.0.0, browserify-rsa@^4.0.1: +browserify-rsa@^4.0.0, browserify-rsa@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/browserify-rsa/-/browserify-rsa-4.1.0.tgz#b2fd06b5b75ae297f7ce2dc651f918f5be158c8d" integrity sha512-AdEER0Hkspgno2aR97SAf6vi0y0k8NuOpGnVH3O99rcA5Q6sh8QxcngtHuJ6uXwnfAXNM4Gn1Gb7/MV1+Ymbog== @@ -2248,19 +2248,19 @@ browserify-rsa@^4.0.0, browserify-rsa@^4.0.1: randombytes "^2.0.1" browserify-sign@^4.0.0: - version "4.2.1" - resolved "https://registry.yarnpkg.com/browserify-sign/-/browserify-sign-4.2.1.tgz#eaf4add46dd54be3bb3b36c0cf15abbeba7956c3" - integrity sha512-/vrA5fguVAKKAVTNJjgSm1tRQDHUU6DbwO9IROu/0WAzC8PKhucDSh18J0RMvVeHAn5puMd+QHC2erPRNf8lmg== + version "4.2.2" + resolved "https://registry.yarnpkg.com/browserify-sign/-/browserify-sign-4.2.2.tgz#e78d4b69816d6e3dd1c747e64e9947f9ad79bc7e" + integrity sha512-1rudGyeYY42Dk6texmv7c4VcQ0EsvVbLwZkA+AQB7SxvXxmcD93jcHie8bzecJ+ChDlmAm2Qyu0+Ccg5uhZXCg== dependencies: - bn.js "^5.1.1" - browserify-rsa "^4.0.1" + bn.js "^5.2.1" + browserify-rsa "^4.1.0" create-hash "^1.2.0" create-hmac "^1.1.7" - elliptic "^6.5.3" + elliptic "^6.5.4" inherits "^2.0.4" - parse-asn1 "^5.1.5" - readable-stream "^3.6.0" - safe-buffer "^5.2.0" + parse-asn1 "^5.1.6" + readable-stream "^3.6.2" + safe-buffer "^5.2.1" browserify-zlib@^0.2.0: version "0.2.0" @@ -3015,7 +3015,7 @@ electron-to-chromium@^1.4.535: resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.546.tgz#673ff64862859b1593cebfbacc5fb6aebef7c457" integrity sha512-cz9bBM26ZqoEmGHkdHXU3LP7OofVyEzRoMqfALQ9Au9WlB4rogAHzqj/NkNvw2JJjy4xuxS1me+pP2lbCD5Mfw== -elliptic@^6.5.3: +elliptic@^6.5.3, elliptic@^6.5.4: version "6.5.4" resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.4.tgz#da37cebd31e79a1367e941b592ed1fbebd58abbb" integrity sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ== @@ -5607,7 +5607,7 @@ parent-module@^1.0.0: dependencies: callsites "^3.0.0" -parse-asn1@^5.0.0, parse-asn1@^5.1.5: +parse-asn1@^5.0.0, parse-asn1@^5.1.6: version "5.1.6" resolved "https://registry.yarnpkg.com/parse-asn1/-/parse-asn1-5.1.6.tgz#385080a3ec13cb62a62d39409cb3e88844cdaed4" integrity sha512-RnZRo1EPU6JBnra2vGHj0yhp6ebyjBZpmUCLHWiFhxlzvBCCpAuZ7elsBp1PVAbQN0/04VD/19rfzlBSwLstMw== @@ -5885,7 +5885,7 @@ readable-stream@^2.0.6: string_decoder "~1.1.1" util-deprecate "~1.0.1" -readable-stream@^3.0.2, readable-stream@^3.1.1, readable-stream@^3.4.0, readable-stream@^3.5.0, readable-stream@^3.6.0: +readable-stream@^3.0.2, readable-stream@^3.1.1, readable-stream@^3.4.0, readable-stream@^3.5.0, readable-stream@^3.6.0, readable-stream@^3.6.2: version "3.6.2" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.2.tgz#56a9b36ea965c00c5a93ef31eb111a0f11056967" integrity sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA== From 65cc860053981ba90b27d2b3fbfb640dfe2509d1 Mon Sep 17 00:00:00 2001 From: George Date: Fri, 3 Nov 2023 12:21:09 -0700 Subject: [PATCH 2/4] Release beta.4 with a sequence number bugfix. (#711) --- CHANGELOG.md | 4 +++- package.json | 2 +- src/transaction_builder.js | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 40b1bb80..5863b829 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,8 +3,10 @@ ## Unreleased + +## [`v10.0.0-beta.4`](https://github.com/stellar/js-stellar-base/compare/v10.0.0-beta.3...v10.0.0-beta.4) ### Fixed -- The type definition for `Memo.hash` now allows `Buffer`s ([#698](https://github.com/stellar/js-stellar-base/pull/698)). +- You can now correctly clone transactions (`TransactionBuilder.cloneFrom`) with large sequence numbers ([#711](https://github.com/stellar/js-stellar-base/pull/711)). ## [`v10.0.0-beta.3`](https://github.com/stellar/js-stellar-base/compare/v10.0.0-beta.2...v10.0.0-beta.3) diff --git a/package.json b/package.json index 907bdb84..83280199 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "stellar-base", - "version": "10.0.0-beta.3", + "version": "10.0.0-beta.4", "description": "Low-level support library for the Stellar network.", "main": "./lib/index.js", "browser": { diff --git a/src/transaction_builder.js b/src/transaction_builder.js index db318168..15e3ba85 100644 --- a/src/transaction_builder.js +++ b/src/transaction_builder.js @@ -181,7 +181,7 @@ export class TransactionBuilder { throw new TypeError(`expected a 'Transaction', got: ${tx}`); } - const sequenceNum = `${parseInt(tx.sequence, 10) - 1}`; + const sequenceNum = (BigInt(tx.sequence) - 1n).toString(); let source; // rebuild the source account based on the strkey From a50ea4c3f571f94ab9662e49f564e2b77f0bb2f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?jeesun=20=EC=A7=80=EC=84=A0?= Date: Fri, 10 Nov 2023 09:27:07 -0800 Subject: [PATCH 3/4] Correct a TypeScript return type to 'string' (#712) Co-authored-by: Jeesun Kim --- types/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/index.d.ts b/types/index.d.ts index e7f3c99e..d9d858c9 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1229,5 +1229,5 @@ export function walkInvocationTree( export namespace Soroban { function formatTokenAmount(address: string, decimals: number): string; - function parseTokenAmount(value: string, decimals: number): Address; + function parseTokenAmount(value: string, decimals: number): string; } From 9145983a4d9e403941935c0d54dddcf3e549c722 Mon Sep 17 00:00:00 2001 From: George Date: Wed, 15 Nov 2023 09:54:01 -0800 Subject: [PATCH 4/4] Fix JSDoc syntax: empty @examples breaks doc generation (#713) --- src/auth.js | 1 - src/soroban.js | 43 ++++++++++++++++++++++++++----------------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/auth.js b/src/auth.js index 6ca39e16..2f86f9bb 100644 --- a/src/auth.js +++ b/src/auth.js @@ -194,7 +194,6 @@ export async function authorizeEntry( * {@link Operation.invokeHostFunction} * * @see authorizeEntry - * @example */ export function authorizeInvocation( signer, diff --git a/src/soroban.js b/src/soroban.js index 197d3e85..1c4f0b5a 100644 --- a/src/soroban.js +++ b/src/soroban.js @@ -1,25 +1,29 @@ /** - * Soroban helper class - * formatting, parsing, and etc * @class Soroban + * Soroban helper class to assist with formatting and parsing token amounts. */ export class Soroban { /** - * All arithmetic inside the contract is performed on integers to - * avoid potential precision and consistency issues of floating-point + * Given a whole number smart contract amount of a token and an amount of + * decimal places (if the token has any), it returns a "display" value. * - * This function takes the smart contract value and its decimals (if the token has any) and returns a display value - * @param {string} amount - the token amount you want to display - * @param {number} decimals - specify how many decimal places a token has - * @returns {string} - display value + * All arithmetic inside the contract is performed on integers to avoid + * potential precision and consistency issues of floating-point. + * + * @param {string} amount the token amount you want to display + * @param {number} decimals specify how many decimal places a token has + * + * @returns {string} the display value + * @throws {TypeError} if the given amount has a decimal point already + * @example + * formatTokenAmount("123000", 4) === "12.3"; */ static formatTokenAmount(amount, decimals) { - let formatted = amount; - if (amount.includes('.')) { - throw new Error('No decimal is allowed'); + throw new TypeError('No decimals are allowed'); } + let formatted = amount; if (decimals > 0) { if (decimals > formatted.length) { formatted = ['0', formatted.toString().padStart(decimals, '0')].join( @@ -38,19 +42,24 @@ export class Soroban { } /** - * parse token amount to use it on smart contract + * Parse a token amount to use it on smart contract * * This function takes the display value and its decimals (if the token has * any) and returns a string that'll be used within the smart contract. - * @param {string} value - the token amount you want to use it on smart contract - * @param {number} decimals - specify how many decimal places a token has - * @returns {string} - smart contract value * + * @param {string} value the token amount you want to use it on smart + * contract which you've been displaying in a UI + * @param {number} decimals the number of decimal places expected in the + * display value (different than the "actual" number, because suffix zeroes + * might not be present) + * + * @returns {string} the whole number token amount represented by the display + * value with the decimal places shifted over * * @example * const displayValueAmount = "123.4560" - * const parsedAmountForSmartContract = parseTokenAmount("123.4560", 5); - * parsedAmountForSmartContract === "12345600" + * const parsedAmtForSmartContract = parseTokenAmount(displayValueAmount, 5); + * parsedAmtForSmartContract === "12345600" */ static parseTokenAmount(value, decimals) { const [whole, fraction, ...rest] = value.split('.').slice();