From 0241480a7b48dee3b385db29848a69cf32fe5387 Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Tue, 9 Jan 2024 12:30:58 +0100 Subject: [PATCH] fix: iOS 15 usage and bump version (#513) # Motivation It was reported that the last version of NNS dapp shipped with SvelteKit v2 and per extension Rollup v4 was not usable on iOS 15 (iOS 17 was fine). Afternarrowing down the issue I figured out that the root cause of the issue was the usage of a static variable using within an object parameter. # Error stacktrace on iOS v15 ``` Unhandled Promise Rejection: SyntaxError: Unexpected token '{' ``` # Changes - Replace static usage of `SubAccount.ZERO` with an object to fix the issue - Add entry in CHANGELOG - Bump version to release the patch to npm asap. # Screenshot ![image](https://github.com/dfinity/ic-js/assets/16886711/f6581810-d0de-4f74-bcbf-3133fb31f112) # Test The fix was tested locally by bundling the library and including it in NNS dapp which was build and served `npx serve public` + `npx local-ssl-proxy --source 3001 --target 3000`. Finally the fix was validated by loading https://locahost:3001 in Xcode simulator with iOS 15.4. --- CHANGELOG.md | 23 +++++++++++++++++++ package-lock.json | 6 ++--- package.json | 2 +- packages/ledger-icp/README.md | 2 +- packages/ledger-icp/package.json | 2 +- .../ledger-icp/src/account_identifier.spec.ts | 6 +++-- packages/ledger-icp/src/account_identifier.ts | 4 +--- 7 files changed, 34 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6712af7b..c928dcad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,26 @@ +# 2024.01.09-1115Z + +## Overview + +The current status of the libraries at the time of the release is as follows: + +| Library | Version | Status | +| ------------------------ | ------- | ---------- | +| `@dfinity/ckbtc` | v2.1.0 | Unchanged | +| `@dfinity/cketh` | v0.0.1 | Unchanged | +| `@dfinity/cmc` | v2.1.0 | Unchanged | +| `@dfinity/ic-management` | v2.1.0 | Unchanged | +| `@dfinity/ledger-icp` | v2.1.1 | Patched 🤕 | +| `@dfinity/ledger-icrc` | v2.1.0 | Unchanged | +| `@dfinity/nns` | v3.1.0 | Unchanged | +| `@dfinity/nns-proto` | v1.0.0 | Unchanged | +| `@dfinity/sns` | v2.1.0 | Unchanged | +| `@dfinity/utils` | v2.0.0 | Unchanged️ | + +## Fix + +- When `@dfinity/ledger-icp` is bundled with Rollup v4, it leads to an incompatibility issue with iOS 15. + # 2024.01.03-1115Z ## Overview diff --git a/package-lock.json b/package-lock.json index 2dd6c061..f8e76c1a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@dfinity/ic-js", - "version": "2024.01.03-1115Z", + "version": "2024.01.09-1115Z", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@dfinity/ic-js", - "version": "2024.01.03-1115Z", + "version": "2024.01.09-1115Z", "license": "Apache-2.0", "workspaces": [ "packages/utils", @@ -7188,7 +7188,7 @@ }, "packages/ledger-icp": { "name": "@dfinity/ledger-icp", - "version": "2.1.0", + "version": "2.1.1", "license": "Apache-2.0", "peerDependencies": { "@dfinity/agent": "^0.20.2", diff --git a/package.json b/package.json index f27bf592..320609d3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@dfinity/ic-js", - "version": "2024.01.03-1115Z", + "version": "2024.01.09-1115Z", "description": "A collection of library for interfacing with the Internet Computer.", "license": "Apache-2.0", "workspaces": [ diff --git a/packages/ledger-icp/README.md b/packages/ledger-icp/README.md index 1fb61985..41e1c155 100644 --- a/packages/ledger-icp/README.md +++ b/packages/ledger-icp/README.md @@ -166,7 +166,7 @@ const data = await metadata(); | -------------- | ------------------ | | `toUint8Array` | `() => Uint8Array` | -[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icp/src/account_identifier.ts#L111) +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ledger-icp/src/account_identifier.ts#L109) ### :factory: LedgerCanister diff --git a/packages/ledger-icp/package.json b/packages/ledger-icp/package.json index df1f5593..a3e4aaa9 100644 --- a/packages/ledger-icp/package.json +++ b/packages/ledger-icp/package.json @@ -1,6 +1,6 @@ { "name": "@dfinity/ledger-icp", - "version": "2.1.0", + "version": "2.1.1", "description": "A library for interfacing with the ICP ledger on the Internet Computer.", "license": "Apache-2.0", "main": "dist/cjs/index.cjs.js", diff --git a/packages/ledger-icp/src/account_identifier.spec.ts b/packages/ledger-icp/src/account_identifier.spec.ts index 5cf15dd2..01cb920e 100644 --- a/packages/ledger-icp/src/account_identifier.spec.ts +++ b/packages/ledger-icp/src/account_identifier.spec.ts @@ -11,7 +11,9 @@ describe("SubAccount", () => { }); it("defines ZERO as a 32-byte zeroed array", () => { - expect(SubAccount.ZERO.toUint8Array()).toEqual(new Uint8Array(32).fill(0)); + expect(SubAccount.fromID(0).toUint8Array()).toEqual( + new Uint8Array(32).fill(0), + ); }); it("can be initialized from a principal", () => { @@ -96,7 +98,7 @@ describe("AccountIdentifier", () => { principal: Principal.fromText( "bwz3t-ercuj-owo6s-4adfr-sbu4o-l72hg-kfhc5-5sapm-tj6bn-3scho-uqe", ), - subAccount: SubAccount.ZERO, + subAccount: SubAccount.fromID(0), }).toHex(), ).toBe("df4ad42194201b15ecbbe66ff68559a126854d8141fd935c5bd53433c2fb28d4"); }); diff --git a/packages/ledger-icp/src/account_identifier.ts b/packages/ledger-icp/src/account_identifier.ts index c8478739..b52fa9c0 100644 --- a/packages/ledger-icp/src/account_identifier.ts +++ b/packages/ledger-icp/src/account_identifier.ts @@ -18,7 +18,7 @@ export class AccountIdentifier { public static fromPrincipal({ principal, - subAccount = SubAccount.ZERO, + subAccount = SubAccount.fromID(0), }: { principal: Principal; subAccount?: SubAccount; @@ -106,8 +106,6 @@ export class SubAccount { return new SubAccount(bytes); } - public static ZERO: SubAccount = this.fromID(0); - public toUint8Array(): Uint8Array { return this.bytes; }