diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d2156642..1be41e325 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - JSON Schema for `tact.config.json`: PR [#194](https://github.com/tact-lang/tact/pull/194) - Display an error for integer overflow at compile-time: PR [#200](https://github.com/tact-lang/tact/pull/200) - Non-modifying `StringBuilder`'s `concat` method for chained string concatenations: PR [#217](https://github.com/tact-lang/tact/pull/217) +- `toString` extension function for `Address` type: PR [#224](https://github.com/tact-lang/tact/pull/224) ### Changed - Update the `dump` function to handle addresses: PR [#175](https://github.com/tact-lang/tact/pull/175) diff --git a/src/imports/stdlib.ts b/src/imports/stdlib.ts index 8feb81eb5..36befa1d0 100644 --- a/src/imports/stdlib.ts +++ b/src/imports/stdlib.ts @@ -250,7 +250,8 @@ files['std/text.tact'] = 'bHNlIHsKICAgICAgICAgICAgdGhyb3coMTM0KTsKICAgICAgICB9CiAgICB9CgogICAgLy8gUGFkZGluZwogICAgbGV0IHRvdGFsOiBJbnQgPSByZXN1bHQuYml0cygp' + 'OwogICAgbGV0IHBhZGRpbmc6IEludCA9IHRvdGFsICUgODsKICAgIGlmIChwYWRkaW5nICE9IDApIHsKICAgICAgICBsZXQgczogU2xpY2UgPSByZXN1bHQuYXNTbGlj' + 'ZSgpOwogICAgICAgIHJldHVybiBzLmxvYWRCaXRzKHRvdGFsIC0gcGFkZGluZyk7CiAgICB9IGVsc2UgewogICAgICAgIHJldHVybiByZXN1bHQuYXNTbGljZSgpOwog' + - 'ICAgfQp9'; + 'ICAgfQp9CgovLwovLyBBZGRyZXNzIGNvbnZlcnNpb24KLy8KCkBuYW1lKF9fdGFjdF9hZGRyZXNzX3RvX3VzZXJmcmllbmRseSkKZXh0ZW5kcyBuYXRpdmUgdG9TdHJp' + + 'bmcoc2VsZjogQWRkcmVzcyk6IFN0cmluZzs='; files['stdlib_ex.fc'] = 'Zm9yYWxsIFggLT4gdHVwbGUgX190YWN0X3NldCh0dXBsZSB4LCBYIHYsIGludCBpKSBhc20gIlNFVElOREVYVkFSUSI7CigpIF9fdGFjdF9ub3AoKSBhc20gIk5PUCI7' + 'CnNsaWNlIF9fdGFjdF9zdHJfdG9fc2xpY2Uoc2xpY2UgcykgYXNtICJOT1AiOwpzbGljZSBfX3RhY3Rfc2xpY2VfdG9fc3RyKHNsaWNlIHMpIGFzbSAiTk9QIjsKc2xp' + diff --git a/src/test/feature-strings.spec.ts b/src/test/feature-strings.spec.ts index ae157fe1f..5d70cec1e 100644 --- a/src/test/feature-strings.spec.ts +++ b/src/test/feature-strings.spec.ts @@ -60,5 +60,7 @@ describe('feature-strings', () => { expect(await contract.getStringWithEscapedChars4()).toEqual( "\u{2028}\u{2029} \u0044 \x41\x42\x43" ); + + expect(await contract.getStringWithAddress()).toEqual('EQBKgXCNLPexWhs2L79kiARR1phGH1LwXxRbNsCFF9doc2lN'); }); }); \ No newline at end of file diff --git a/src/test/features/strings.tact b/src/test/features/strings.tact index 551fc2a60..a39377b80 100644 --- a/src/test/features/strings.tact +++ b/src/test/features/strings.tact @@ -99,4 +99,8 @@ contract StringsTester { get fun stringWithEscapedChars4(): String { return "\u{2028}\u{2029} \u0044 \x41\x42\x43"; } + + get fun stringWithAddress(): String { + return address("EQBKgXCNLPexWhs2L79kiARR1phGH1LwXxRbNsCFF9doc2lN").toString(); + } } \ No newline at end of file diff --git a/stdlib/std/text.tact b/stdlib/std/text.tact index abc73cfa8..1171158ee 100644 --- a/stdlib/std/text.tact +++ b/stdlib/std/text.tact @@ -91,4 +91,11 @@ extends fun fromBase64(self: Slice): Slice { } else { return result.asSlice(); } -} \ No newline at end of file +} + +// +// Address conversion +// + +@name(__tact_address_to_userfriendly) +extends native toString(self: Address): String; \ No newline at end of file