From a89b1dfd5c7deece46825a44fb1446a473eec37a Mon Sep 17 00:00:00 2001 From: AttikusFinch Date: Sat, 27 Jul 2024 11:37:03 +0500 Subject: [PATCH] Add bounceable option to "toUserFriendlyAddress" --- packages/sdk/src/utils/address.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/sdk/src/utils/address.ts b/packages/sdk/src/utils/address.ts index f1e67f02..80b0ddc7 100644 --- a/packages/sdk/src/utils/address.ts +++ b/packages/sdk/src/utils/address.ts @@ -1,6 +1,7 @@ import { WrongAddressError, ParseHexError } from 'src/errors'; import { Base64 } from '@tonconnect/protocol'; +const BounceableTag = 0x11; const noBounceableTag = 0x51; const testOnlyTag = 0x80; @@ -9,10 +10,14 @@ const testOnlyTag = 0x80; * @param hexAddress raw TON address formatted as "0:". * @param [testOnly=false] convert address to test-only form. [See details]{@link https://ton.org/docs/learn/overviews/addresses#user-friendly-address} */ -export function toUserFriendlyAddress(hexAddress: string, testOnly = false): string { +export function toUserFriendlyAddress(hexAddress: string, testOnly = false, bounceable = false): string { const { wc, hex } = parseHexAddress(hexAddress); let tag = noBounceableTag; + if (bounceable) { + tag = BounceableTag; + } + if (testOnly) { tag |= testOnlyTag; }