diff --git a/Changelog.md b/Changelog.md index 5cecf057412..cd09f045d60 100644 --- a/Changelog.md +++ b/Changelog.md @@ -14,7 +14,14 @@ * `-fno-shared-code` (default) * `-fshared-code` (legacy) (Helps mitigate the effect of the IC's new cost model, that increases - the cost of function calls). + the cost of function calls). + +* motoko-base + + * Added `Principal.toLedgerAccount` (#582). + + * Added `Text.toLowercase` and `Text.toUppercase` (#590). + ## 0.10.0 (2023-09-11) @@ -31,6 +38,8 @@ * Exposed conversions between adjacent fixed-width types (dfinity/motoko-baseā #585). + * Added library `Region.mo` offering isolated regions of IC stable memory (#580). + ## 0.9.8 (2023-08-11) * motoko (`moc`) diff --git a/doc/md/base/Principal.md b/doc/md/base/Principal.md index 43dc4dff40c..2a522beeec0 100644 --- a/doc/md/base/Principal.md +++ b/doc/md/base/Principal.md @@ -47,6 +47,20 @@ actor MyCanister { } ``` +## Function `toLedgerAccount` +``` motoko no-repl +func toLedgerAccount(principal : Principal, subAccount : ?Blob) : Blob +``` + +Compute the Ledger account identifier of a principal. Optionally specify a sub-account. + +Example: +```motoko include=import +let principal = Principal.fromText("un4fu-tqaaa-aaaab-qadjq-cai"); +let subAccount : Blob = "\4A\8D\3F\2B\6E\01\C8\7D\9E\03\B4\56\7C\F8\9A\01\D2\34\56\78\9A\BC\DE\F0\12\34\56\78\9A\BC\DE\F0"; +let account = Principal.toLedgerAccount(principal, ?subAccount); // => \8C\5C\20\C6\15\3F\7F\51\E2\0D\0F\0F\B5\08\51\5B\47\65\63\A9\62\B4\A9\91\5F\4F\02\70\8A\ED\4F\82 +``` + ## Function `toBlob` ``` motoko no-repl func toBlob(p : Principal) : Blob