From 7d7e7ebce225e213b18631acef19062d80da71e9 Mon Sep 17 00:00:00 2001 From: UtkarshBhardwaj007 Date: Tue, 19 May 2026 16:46:58 +0100 Subject: [PATCH] refactor(deps): upgrade product-sdk + bulletin-deploy, migrate to product-sdk-keys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Bumps every @parity/product-sdk-* caret range and bulletin-deploy to current latest. Patch bumps (bulletin/chain-client/contracts/ descriptors/storage/tx) are transitive-only. Minor bumps (host 0.4.0, keys 0.3.0) are additive — no CLI adaptation required. bulletin-deploy 0.7.20 to 0.7.24 brings PoP self-serve guidance, chunk-reupload retry hardening, and auto-reprove on stale alias binding. - Deletes src/utils/productAccountDerivation.ts and consumes the canonical deriveProductAccountPublicKey from @parity/product-sdk-keys. Two callsites updated: src/utils/sessionSigner.ts and src/commands/init/identityLine.ts. Algorithm parity with mobile and desktop is locked by upstream frozen vectors. - Replaces the local algorithm tests with two thinner files: src/utils/productAccount.test.ts (wiring smoke test) and src/utils/sessionSigner.test.ts (preserves regression tests pinning the init/deploy/playground-app equivalence and the rootAccountId-vs-remoteAccount.accountId guard). - Drops unused direct scale-ts dep from package.json. Reviewed by superpowers code-review subagent before push. --- .changeset/product-sdk-keys-migration.md | 5 + package.json | 19 +- pnpm-lock.yaml | 173 ++++++++---------- src/commands/init/identityLine.ts | 7 +- src/utils/productAccount.test.ts | 33 ++++ src/utils/productAccountDerivation.ts | 86 --------- ...rivation.test.ts => sessionSigner.test.ts} | 50 +---- src/utils/sessionSigner.ts | 5 +- 8 files changed, 129 insertions(+), 249 deletions(-) create mode 100644 .changeset/product-sdk-keys-migration.md create mode 100644 src/utils/productAccount.test.ts delete mode 100644 src/utils/productAccountDerivation.ts rename src/utils/{productAccountDerivation.test.ts => sessionSigner.test.ts} (74%) diff --git a/.changeset/product-sdk-keys-migration.md b/.changeset/product-sdk-keys-migration.md new file mode 100644 index 0000000..cd67db7 --- /dev/null +++ b/.changeset/product-sdk-keys-migration.md @@ -0,0 +1,5 @@ +--- +"playground-cli": patch +--- + +Internal: bump `@parity/product-sdk-*` packages and `bulletin-deploy` to current latest, and consume `deriveProductAccountPublicKey` from `@parity/product-sdk-keys` instead of a local mirror. No user-visible behaviour change; output is byte-identical for production inputs. diff --git a/package.json b/package.json index d51d934..403257b 100644 --- a/package.json +++ b/package.json @@ -27,27 +27,26 @@ "@dotdm/contracts": "^2.0.3", "@parity/dotns-cli": "0.6.1", "@parity/product-sdk-address": "^0.1.1", - "@parity/product-sdk-bulletin": "^0.4.0", - "@parity/product-sdk-chain-client": "^0.4.0", - "@parity/product-sdk-contracts": "^0.5.0", - "@parity/product-sdk-descriptors": "^0.4.0", - "@parity/product-sdk-host": "^0.3.0", - "@parity/product-sdk-keys": "^0.2.3", + "@parity/product-sdk-bulletin": "^0.4.2", + "@parity/product-sdk-chain-client": "^0.4.2", + "@parity/product-sdk-contracts": "^0.5.1", + "@parity/product-sdk-descriptors": "^0.4.1", + "@parity/product-sdk-host": "^0.4.0", + "@parity/product-sdk-keys": "^0.3.0", "@parity/product-sdk-logger": "^0.1.1", - "@parity/product-sdk-storage": "^0.1.4", + "@parity/product-sdk-storage": "^0.1.5", "@parity/product-sdk-terminal": "^0.2.1", - "@parity/product-sdk-tx": "^0.2.3", + "@parity/product-sdk-tx": "^0.2.4", "@parity/product-sdk-utils": "^0.1.1", "@polkadot-api/sdk-ink": "^0.7.0", "@scure/sr25519": "^2.2.0", "@sentry/node": "^9.47.1", - "bulletin-deploy": "0.7.20", + "bulletin-deploy": "0.7.24", "commander": "^12.0.0", "ink": "^5.2.1", "polkadot-api": "^2.1.3", "react": "^18.3.1", "react-devtools-core": "file:stubs/react-devtools-core", - "scale-ts": "^1.6.1", "tar": "^7.5.13" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0751e07..b323298 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -28,35 +28,35 @@ importers: specifier: ^0.1.1 version: 0.1.1 '@parity/product-sdk-bulletin': - specifier: ^0.4.0 - version: 0.4.1(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2) + specifier: ^0.4.2 + version: 0.4.2(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2) '@parity/product-sdk-chain-client': - specifier: ^0.4.0 - version: 0.4.1(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2) + specifier: ^0.4.2 + version: 0.4.2(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2) '@parity/product-sdk-contracts': - specifier: ^0.5.0 - version: 0.5.0(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2)(typescript@5.9.3) + specifier: ^0.5.1 + version: 0.5.1(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2)(typescript@5.9.3) '@parity/product-sdk-descriptors': - specifier: ^0.4.0 - version: 0.4.0(esbuild@0.27.7)(rxjs@7.8.2) + specifier: ^0.4.1 + version: 0.4.1(esbuild@0.27.7)(rxjs@7.8.2) '@parity/product-sdk-host': + specifier: ^0.4.0 + version: 0.4.0(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2) + '@parity/product-sdk-keys': specifier: ^0.3.0 version: 0.3.0(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2) - '@parity/product-sdk-keys': - specifier: ^0.2.3 - version: 0.2.3(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2) '@parity/product-sdk-logger': specifier: ^0.1.1 version: 0.1.1 '@parity/product-sdk-storage': - specifier: ^0.1.4 - version: 0.1.4(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2) + specifier: ^0.1.5 + version: 0.1.5(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2) '@parity/product-sdk-terminal': specifier: ^0.2.1 version: 0.2.1(esbuild@0.27.7)(rxjs@7.8.2) '@parity/product-sdk-tx': - specifier: ^0.2.3 - version: 0.2.3(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2) + specifier: ^0.2.4 + version: 0.2.4(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2) '@parity/product-sdk-utils': specifier: ^0.1.1 version: 0.1.1 @@ -70,8 +70,8 @@ importers: specifier: ^9.47.1 version: 9.47.1 bulletin-deploy: - specifier: 0.7.20 - version: 0.7.20(@polkadot/util@14.0.3)(esbuild@0.27.7)(postcss@8.5.10)(react-native@0.85.2(@babel/core@7.29.0)(@types/react@18.3.28)(react@18.3.1))(rxjs@7.8.2)(typescript@5.9.3)(yaml@2.8.4) + specifier: 0.7.24 + version: 0.7.24(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2)(typescript@5.9.3) commander: specifier: ^12.0.0 version: 12.1.0 @@ -87,9 +87,6 @@ importers: react-devtools-core: specifier: file:stubs/react-devtools-core version: file:stubs/react-devtools-core - scale-ts: - specifier: ^1.6.1 - version: 1.6.1 tar: specifier: ^7.5.13 version: 7.5.13 @@ -1179,23 +1176,23 @@ packages: '@parity/product-sdk-address@0.1.1': resolution: {integrity: sha512-sSymun3alNGdvawhdc0Ha0KEkuqMwBZui1bsUVeZIZRJAfWvQzrV1AVaf8aah5JFlcaRdg8FYyp7xL2eP+ZplA==} - '@parity/product-sdk-bulletin@0.4.1': - resolution: {integrity: sha512-PzX6B1XAoMHL/hBaiL1snWWv5sZ8RGBxgulbjVNKBjC8Yn9WMWVCgjGXqnLh73iRSDffqjEJ/jtfmKICnwRiDg==} + '@parity/product-sdk-bulletin@0.4.2': + resolution: {integrity: sha512-hcwAhap8OFTheIs8a9UQp/EMifTrnSYus4rxpwA2MrY5XksCwfynAQigaWgnPoGmByW3R5SNX6l2vPchdU20HA==} - '@parity/product-sdk-chain-client@0.4.1': - resolution: {integrity: sha512-Scqb1YKKfCmluI+dyGnOjKJYGI39wdm+evr+5v1+knsqOYGc8UujIY8Ju1otfm43lmRnnroi751RYtHY7kCLhQ==} + '@parity/product-sdk-chain-client@0.4.2': + resolution: {integrity: sha512-RuPECyfE+BI0s+HiTeGa17zV3UPnbhtcbkFNoRcg6PDVM9anLD/W/hPDC3dBYuCG4AhksHBgogbbo154iP9VVA==} '@parity/product-sdk-contracts@0.4.0': resolution: {integrity: sha512-D12u3c/tg7r1J2J2w6tSKtiiC7PKxuiFQ3UZucLL6Pehmpfk/czSnPrlvwvbJdpTo1V9ckG83NqR1B1Boqiipw==} - '@parity/product-sdk-contracts@0.5.0': - resolution: {integrity: sha512-6iIOEvFPgIsTq4W6N9tlxvGEax1d8+2RJ0FHM/Hy0zadhYMs8jECTdu58tul5wiWGTydqSksG13jS1kztv/Ygg==} + '@parity/product-sdk-contracts@0.5.1': + resolution: {integrity: sha512-eM8nQjSf7T1iRQ1Vpfdj+LxBjIHR3geIIw3tF6lp+MkA4Eshf1UZBN1aCYugQUDh/qQxH+mblJJ/94ODjJnctA==} '@parity/product-sdk-crypto@0.1.1': resolution: {integrity: sha512-No6AyTLw1Nv3ym8SDdXh/tnezdClNOL9pJgaciVr9Ny6hIL5rs6MQiXsP0+1bc1Nwymz5Q4FqsYg/htE4lejNg==} - '@parity/product-sdk-descriptors@0.4.0': - resolution: {integrity: sha512-ckFpRjUVXAlA34ei9gn8XmoguGNwMBsvBuq2A4l+Mlk3fC4tzZxrFrLuEbWfLIyrW20BVGRZ32J8ml5zwu53Eg==} + '@parity/product-sdk-descriptors@0.4.1': + resolution: {integrity: sha512-7OKTRy+116aUTkTZyGFmD0C4slKoiayx03MBUDFPLRjQvDDt4rJ6Id10MigxK0Dyj57ptImYnAfOnwv7pvZn5A==} '@parity/product-sdk-host@0.2.2': resolution: {integrity: sha512-MUHu9FB/7i/pRakhYULzAzcYISjn0nIlVa7YI9ioqMWlaFBwsmWyaC6RaDNOtDFJyW58z6MwTJyx8FdVUMAW0w==} @@ -1208,8 +1205,8 @@ packages: '@novasamatech/product-sdk': optional: true - '@parity/product-sdk-host@0.3.0': - resolution: {integrity: sha512-c4nmD1VQqMlbzqF4vHBRB0YQWLWvmdIS2QgchcDCvlGQbxiL/iz9iLMW9Mz34K8BzHea0bc0mtpYH9HDeYYUZA==} + '@parity/product-sdk-host@0.4.0': + resolution: {integrity: sha512-Kw/ZRMHBHPrR/ST00QZqZa+qXGrrLYVXgrmCJ9YCys+yaPleJl0Q1+HI6zTD0bjaHsooESk+yYLajCRtZAdVVg==} peerDependencies: '@novasamatech/host-api': 0.7.9-4 '@novasamatech/product-sdk': 0.7.9-4 @@ -1222,8 +1219,8 @@ packages: '@parity/product-sdk-keys@0.2.2': resolution: {integrity: sha512-1+dvQlBrjCC5nTntwtkKX/hTvL4oBCchTpAnddeSdQZVcsrgn6jHIePfhKpMOA33BLXPEzS0XYC7LggHIAJ7Mw==} - '@parity/product-sdk-keys@0.2.3': - resolution: {integrity: sha512-TdfUEIb+kWtnVOJQZe4AYYAtudfHTpPNP/3rWhHW5SUNvpH7ZEh5WD4MtB8PfyPqlt6DikLkHtiaZFJKTQ8kVw==} + '@parity/product-sdk-keys@0.3.0': + resolution: {integrity: sha512-GkFAyqITyy9BLQaFpdyf7hQtUtUfaqAVhp0/0Hg6ayMXA5kSjorAHcTj5Off1/2cK8Lw74U/K6O7Z0jkwnUb7g==} '@parity/product-sdk-logger@0.1.1': resolution: {integrity: sha512-AiSV3TTNlMZJftLQsO78BZsEymGFuJtGMSpGrJ+vUtqaZavWaW/Hc6MICBLnEYgeCrdNpv7QBso3dRsTfnAZXQ==} @@ -1231,14 +1228,14 @@ packages: '@parity/product-sdk-signer@0.2.3': resolution: {integrity: sha512-t2FGGuhDSFpTgr8j6S7sKcoKVwlF5chUO0PfruloUwTQXdMR9JlA2e9fqBhIvN5JzO7HYa2ZIFL0uFy4tXYZ9Q==} - '@parity/product-sdk-signer@0.2.4': - resolution: {integrity: sha512-3e3R3P/toG97UbCB+I0L8mQ1CT7QeYteNRO3bvEod+S7ST5CG7meGwllyGiaBR97eMHIYN9pQIkzVmQBFokPpg==} + '@parity/product-sdk-signer@0.3.0': + resolution: {integrity: sha512-baeqdXUZ8PiPKv8jdgyKkKQp7CggeuPqVZ9EOohjW+MZid8/etuZj0UdXh62iFzYtovCBVhfWvf5wIHPoh2SpQ==} '@parity/product-sdk-storage@0.1.3': resolution: {integrity: sha512-kIkQw2MVhev0ZZYtc0dOd5wBnW8P0Av6MFpHboGYmQwzzTS35m/hykffaxadZQtg0BPwaxAtxgyttqcksI9R/A==} - '@parity/product-sdk-storage@0.1.4': - resolution: {integrity: sha512-tNUwidl265/z3rkX2GEPuZTV6q8Uk3Cm3uo1K0cxIN37NHjFaQwSwyF/SAXRhvubYSNzO3gfGVlE4Ar9j/V8WQ==} + '@parity/product-sdk-storage@0.1.5': + resolution: {integrity: sha512-TKW7HesTCihDtR1usKg/xMhKiO1kVPJej0bDhXXKTHCDfVWkdPR1A//oG9b+pQtswVLFm4k+FanFOt8lAQMBDA==} '@parity/product-sdk-terminal@0.2.1': resolution: {integrity: sha512-xcuKoOMHETwHBefEeNSMDqzL+AQFoTmK3i6JBwsvGhpijwJ8QDdoEMhilYiMKnmoyDml9nu/VCcPUKw3Am0zow==} @@ -1246,8 +1243,8 @@ packages: '@parity/product-sdk-tx@0.2.2': resolution: {integrity: sha512-MHkSsB1FovYElYPGdo4szXt5SVNzGK8HE+2OjWJPapsKDl2UqAEVvG+QnC6nhkny1qL+sVnSncJh6cVEbT8sJA==} - '@parity/product-sdk-tx@0.2.3': - resolution: {integrity: sha512-WjzN8pVlGekBP7lN1nypAfU3q8EPtg6L5x/Y0UvFVa/F0R5j4rDFUAs2GeEjrIumSvZhpe0OxYhgTke+/4qz2w==} + '@parity/product-sdk-tx@0.2.4': + resolution: {integrity: sha512-Kp/giVb30/B/z97JE+iGFmz3nZkHSUnaGy4o+6Ed0i2arUuJFY2GsuxEI8+8DvyhmT1HP//GundZSLoJHPTk6Q==} '@parity/product-sdk-utils@0.1.1': resolution: {integrity: sha512-vu/af1K7k7p0/aLKALrGVxz7K94xnY800DxmhnOhu6Hy4+y+8e9WHPecMjbYBBJby4FPMOkWLqEVRN/sk3Ucgw==} @@ -1510,9 +1507,6 @@ packages: '@polkadot-labs/hdkd-helpers@0.0.27': resolution: {integrity: sha512-GTSj/Mw5kwtZbefvq2BhvBnHvs7AY4OnJgppO0kE2S/AuDbD6288C9rmO6qwMNmiNVX8OrYMWaJcs46Mt1UbBw==} - '@polkadot-labs/hdkd-helpers@0.0.28': - resolution: {integrity: sha512-kENij83Dr76RrcfsJmzcqNhThjWTPtzregb/i6o50kH5n1wkaE58/8PFahMnGVc9Trzk7jxfGSNQphQNwq2emg==} - '@polkadot-labs/hdkd-helpers@0.0.29': resolution: {integrity: sha512-yiLm1Gj3j5NrQV+VFMlFzkBgcRBNfq2Sd/U3S8iau2bzhDwgsn4gy6FDt94TRPD5xLxOzi1I3wSLOrgOs2eLVw==} @@ -2020,9 +2014,6 @@ packages: '@scure/base@1.2.6': resolution: {integrity: sha512-g/nm5FgUa//MCj1gV09zTJTaM6KBAHqLN907YVQqf7zC49+DcO4B1so4ZX07Ef10Twr6nuqYEH9GEggFXA4Fmg==} - '@scure/base@2.0.0': - resolution: {integrity: sha512-3E1kpuZginKkek01ovG8krQ0Z44E3DHPjc5S2rjJw9lZn3KSQOs8S7wqikF/AH7iRanHypj85uGyxk0XAyC37w==} - '@scure/base@2.2.0': resolution: {integrity: sha512-b8XEupJibegiXV+tDUseI8oLQc8ei3d/4Jkb2RpbHh3MfE054ov3uIz2dhFkB3FI8iwYkEh0gGCApkrYggkPNg==} @@ -2388,8 +2379,8 @@ packages: buffer@6.0.3: resolution: {integrity: sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==} - bulletin-deploy@0.7.20: - resolution: {integrity: sha512-DqhF8F6iYr2QQ7VkFhGSwT98Iyedid7TNQHHI5UV8WIYiw2vjpZ/2Rko5aR//0ZFzRy3U9iQGZp9VvlYUGi5zQ==} + bulletin-deploy@0.7.24: + resolution: {integrity: sha512-oKDiHyVPpFRddzCL9CRK0r5cryZujnVgWPsOHaRPPBqbdOP73xK70uHgSY3DI1RXt/lFSSWe9nwRBdzJBRY2zQ==} engines: {node: '>=22'} hasBin: true @@ -4607,6 +4598,9 @@ packages: varint@6.0.0: resolution: {integrity: sha512-cXEIW6cfr15lFv563k4GuVuW/fiwjknytD37jIOLSdSWuOI6WnO/oKwmP2FQTU2l01LP8/M5TSAJpzUaGe3uWg==} + verifiablejs@1.2.0: + resolution: {integrity: sha512-+VVQo9yZko+w3THKaYvLbjXdfaiw1WJnX12wJEU5jHsHrMkjDrAMWoKYcBvtlHXufJirr8FlT6v2i/0yA3/ivQ==} + viem@2.48.0: resolution: {integrity: sha512-0uLzTAUNKPpY9Cf3OBCPdwClXx9CEHAkoVYnxMPdHt7cRI1DobMso+pHZvU7itD+hFwE4htmp9QfP+5lb+kn0g==} peerDependencies: @@ -5218,10 +5212,10 @@ snapshots: '@dotdm/env': 1.0.4(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2) '@dotdm/utils': 0.3.1 '@noble/hashes': 2.2.0 - '@parity/product-sdk-bulletin': 0.4.1(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2) + '@parity/product-sdk-bulletin': 0.4.2(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2) '@parity/product-sdk-contracts': 0.4.0(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2)(typescript@5.9.3) - '@parity/product-sdk-descriptors': 0.4.0(esbuild@0.27.7)(rxjs@7.8.2) - '@parity/product-sdk-tx': 0.2.3(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2) + '@parity/product-sdk-descriptors': 0.4.1(esbuild@0.27.7)(rxjs@7.8.2) + '@parity/product-sdk-tx': 0.2.4(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2) multiformats: 13.4.2 polkadot-api: 2.1.3(esbuild@0.27.7)(rxjs@7.8.2) transitivePeerDependencies: @@ -5240,7 +5234,7 @@ snapshots: '@dotdm/env@1.0.4(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2)': dependencies: '@dotdm/utils': 0.3.1 - '@parity/product-sdk-descriptors': 0.4.0(esbuild@0.27.7)(rxjs@7.8.2) + '@parity/product-sdk-descriptors': 0.4.1(esbuild@0.27.7)(rxjs@7.8.2) '@parity/product-sdk-host': 0.2.2(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2) '@polkadot-labs/hdkd': 0.0.26 '@polkadot-labs/hdkd-helpers': 0.0.27 @@ -6593,14 +6587,14 @@ snapshots: '@noble/hashes': 1.8.0 '@polkadot-api/substrate-bindings': 0.12.0 - '@parity/product-sdk-bulletin@0.4.1(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2)': + '@parity/product-sdk-bulletin@0.4.2(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2)': dependencies: '@parity/bulletin-sdk': 0.3.0(multiformats@13.4.2)(polkadot-api@2.1.3(esbuild@0.27.7)(rxjs@7.8.2)) - '@parity/product-sdk-chain-client': 0.4.1(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2) - '@parity/product-sdk-descriptors': 0.4.0(esbuild@0.27.7)(rxjs@7.8.2) - '@parity/product-sdk-host': 0.3.0(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2) + '@parity/product-sdk-chain-client': 0.4.2(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2) + '@parity/product-sdk-descriptors': 0.4.1(esbuild@0.27.7)(rxjs@7.8.2) + '@parity/product-sdk-host': 0.4.0(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2) '@parity/product-sdk-logger': 0.1.1 - '@parity/product-sdk-tx': 0.2.3(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2) + '@parity/product-sdk-tx': 0.2.4(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2) multiformats: 13.4.2 polkadot-api: 2.1.3(esbuild@0.27.7)(rxjs@7.8.2) transitivePeerDependencies: @@ -6612,10 +6606,10 @@ snapshots: - supports-color - utf-8-validate - '@parity/product-sdk-chain-client@0.4.1(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2)': + '@parity/product-sdk-chain-client@0.4.2(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2)': dependencies: - '@parity/product-sdk-descriptors': 0.4.0(esbuild@0.27.7)(rxjs@7.8.2) - '@parity/product-sdk-host': 0.3.0(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2) + '@parity/product-sdk-descriptors': 0.4.1(esbuild@0.27.7)(rxjs@7.8.2) + '@parity/product-sdk-host': 0.4.0(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2) '@parity/product-sdk-logger': 0.1.1 polkadot-api: 2.1.3(esbuild@0.27.7)(rxjs@7.8.2) transitivePeerDependencies: @@ -6650,13 +6644,13 @@ snapshots: - utf-8-validate - zod - '@parity/product-sdk-contracts@0.5.0(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2)(typescript@5.9.3)': + '@parity/product-sdk-contracts@0.5.1(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2)(typescript@5.9.3)': dependencies: '@parity/product-sdk-address': 0.1.1 - '@parity/product-sdk-keys': 0.2.3(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2) + '@parity/product-sdk-keys': 0.3.0(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2) '@parity/product-sdk-logger': 0.1.1 - '@parity/product-sdk-signer': 0.2.4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2) - '@parity/product-sdk-tx': 0.2.3(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2) + '@parity/product-sdk-signer': 0.3.0(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2) + '@parity/product-sdk-tx': 0.2.4(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2) '@polkadot-labs/hdkd-helpers': 0.0.27 polkadot-api: 2.1.3(esbuild@0.27.7)(rxjs@7.8.2) viem: 2.48.0(typescript@5.9.3) @@ -6680,7 +6674,7 @@ snapshots: '@noble/hashes': 1.8.0 tweetnacl: 1.0.3 - '@parity/product-sdk-descriptors@0.4.0(esbuild@0.27.7)(rxjs@7.8.2)': + '@parity/product-sdk-descriptors@0.4.1(esbuild@0.27.7)(rxjs@7.8.2)': dependencies: polkadot-api: 2.1.3(esbuild@0.27.7)(rxjs@7.8.2) transitivePeerDependencies: @@ -6704,7 +6698,7 @@ snapshots: - supports-color - utf-8-validate - '@parity/product-sdk-host@0.3.0(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2)': + '@parity/product-sdk-host@0.4.0(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2)': dependencies: '@parity/product-sdk-logger': 0.1.1 polkadot-api: 2.1.3(esbuild@0.27.7)(rxjs@7.8.2) @@ -6735,14 +6729,16 @@ snapshots: - supports-color - utf-8-validate - '@parity/product-sdk-keys@0.2.3(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2)': + '@parity/product-sdk-keys@0.3.0(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2)': dependencies: '@parity/product-sdk-address': 0.1.1 '@parity/product-sdk-crypto': 0.1.1 - '@parity/product-sdk-storage': 0.1.4(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2) + '@parity/product-sdk-storage': 0.1.5(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2) '@polkadot-labs/hdkd': 0.0.28 '@polkadot-labs/hdkd-helpers': 0.0.10 + '@scure/sr25519': 2.2.0 polkadot-api: 2.1.3(esbuild@0.27.7)(rxjs@7.8.2) + scale-ts: 1.6.1 transitivePeerDependencies: - '@novasamatech/host-api' - '@novasamatech/product-sdk' @@ -6773,11 +6769,11 @@ snapshots: - supports-color - utf-8-validate - '@parity/product-sdk-signer@0.2.4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2)': + '@parity/product-sdk-signer@0.3.0(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2)': dependencies: '@parity/product-sdk-address': 0.1.1 - '@parity/product-sdk-host': 0.3.0(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2) - '@parity/product-sdk-keys': 0.2.3(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2) + '@parity/product-sdk-host': 0.4.0(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2) + '@parity/product-sdk-keys': 0.3.0(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2) '@parity/product-sdk-logger': 0.1.1 polkadot-api: 2.1.3(esbuild@0.27.7)(rxjs@7.8.2) optionalDependencies: @@ -6805,9 +6801,9 @@ snapshots: - supports-color - utf-8-validate - '@parity/product-sdk-storage@0.1.4(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2)': + '@parity/product-sdk-storage@0.1.5(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2)': dependencies: - '@parity/product-sdk-host': 0.3.0(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2) + '@parity/product-sdk-host': 0.4.0(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2) '@parity/product-sdk-logger': 0.1.1 transitivePeerDependencies: - '@novasamatech/host-api' @@ -6857,9 +6853,9 @@ snapshots: - supports-color - utf-8-validate - '@parity/product-sdk-tx@0.2.3(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2)': + '@parity/product-sdk-tx@0.2.4(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2)': dependencies: - '@parity/product-sdk-keys': 0.2.3(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2) + '@parity/product-sdk-keys': 0.3.0(@novasamatech/host-api@0.7.9-4)(@novasamatech/product-sdk@0.7.9-4(@polkadot/api@16.5.6)(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2))(esbuild@0.27.7)(rxjs@7.8.2) '@parity/product-sdk-logger': 0.1.1 '@polkadot-labs/hdkd-helpers': 0.0.10 polkadot-api: 2.1.3(esbuild@0.27.7)(rxjs@7.8.2) @@ -7311,14 +7307,14 @@ snapshots: dependencies: '@noble/hashes': 2.2.0 '@polkadot-api/utils': 0.2.0 - '@scure/base': 2.0.0 + '@scure/base': 2.2.0 scale-ts: 1.6.1 '@polkadot-api/substrate-bindings@0.19.0': dependencies: '@noble/hashes': 2.2.0 '@polkadot-api/utils': 0.3.0 - '@scure/base': 2.0.0 + '@scure/base': 2.2.0 scale-ts: 1.6.1 '@polkadot-api/substrate-bindings@0.20.1': @@ -7412,15 +7408,7 @@ snapshots: dependencies: '@noble/curves': 2.2.0 '@noble/hashes': 2.2.0 - '@scure/base': 2.0.0 - '@scure/sr25519': 1.0.0 - scale-ts: 1.6.1 - - '@polkadot-labs/hdkd-helpers@0.0.28': - dependencies: - '@noble/curves': 2.2.0 - '@noble/hashes': 2.2.0 - '@scure/base': 2.0.0 + '@scure/base': 2.2.0 '@scure/sr25519': 1.0.0 scale-ts: 1.6.1 @@ -7442,7 +7430,7 @@ snapshots: '@polkadot-labs/hdkd@0.0.26': dependencies: - '@polkadot-labs/hdkd-helpers': 0.0.28 + '@polkadot-labs/hdkd-helpers': 0.0.30 '@polkadot-labs/hdkd@0.0.28': dependencies: @@ -7989,8 +7977,6 @@ snapshots: '@scure/base@1.2.6': {} - '@scure/base@2.0.0': {} - '@scure/base@2.2.0': {} '@scure/bip32@1.7.0': @@ -8426,12 +8412,11 @@ snapshots: base64-js: 1.5.1 ieee754: 1.2.1 - bulletin-deploy@0.7.20(@polkadot/util@14.0.3)(esbuild@0.27.7)(postcss@8.5.10)(react-native@0.85.2(@babel/core@7.29.0)(@types/react@18.3.28)(react@18.3.1))(rxjs@7.8.2)(typescript@5.9.3)(yaml@2.8.4): + bulletin-deploy@0.7.24(@polkadot/util@14.0.3)(esbuild@0.27.7)(rxjs@7.8.2)(typescript@5.9.3): dependencies: '@ipld/car': 5.4.3 '@ipld/dag-pb': 4.1.5 '@noble/hashes': 1.8.0 - '@parity/dotns-cli': 0.6.1(@polkadot/util@14.0.3)(postcss@8.5.10)(react-native@0.85.2(@babel/core@7.29.0)(@types/react@18.3.28)(react@18.3.1))(rxjs@7.8.2)(typescript@5.9.3)(yaml@2.8.4) '@polkadot-api/metadata-builders': 0.14.2 '@polkadot-api/substrate-bindings': 0.20.2 '@polkadot-labs/hdkd': 0.0.28 @@ -8443,23 +8428,17 @@ snapshots: ipfs-unixfs-importer: 16.1.5 multiformats: 13.4.2 polkadot-api: 2.1.3(esbuild@0.27.7)(rxjs@7.8.2) + verifiablejs: 1.2.0 viem: 2.48.0(typescript@5.9.3) transitivePeerDependencies: - - '@microsoft/api-extractor' - '@polkadot/util' - - '@swc/core' - bufferutil - encoding - esbuild - - jiti - - postcss - - react-native - rxjs - supports-color - - tsx - typescript - utf-8-validate - - yaml - zod bundle-require@5.1.0(esbuild@0.25.12): @@ -10977,6 +10956,8 @@ snapshots: varint@6.0.0: {} + verifiablejs@1.2.0: {} + viem@2.48.0(typescript@5.9.3): dependencies: '@noble/curves': 1.9.1 diff --git a/src/commands/init/identityLine.ts b/src/commands/init/identityLine.ts index dc83fa8..5265686 100644 --- a/src/commands/init/identityLine.ts +++ b/src/commands/init/identityLine.ts @@ -18,16 +18,11 @@ * `.tsx` per the repo convention "pure logic that lives inside a `.tsx` * component should be lifted into a sibling `.ts` file" (see * `completion.ts` next to `InitScreen.tsx` for the same pattern). - * - * The product-account derivation here uses the local - * `src/utils/productAccountDerivation.ts` mirror; Phase 3 of the - * product-account unification migration will swap that for the canonical - * `@parity/product-sdk-keys` export. Output is byte-identical either way. */ import { deriveH160, ss58Decode, ss58Encode, truncateAddress } from "@parity/product-sdk-address"; +import { deriveProductAccountPublicKey } from "@parity/product-sdk-keys"; import { PLAYGROUND_PRODUCT_ID } from "../../config.js"; -import { deriveProductAccountPublicKey } from "../../utils/productAccountDerivation.js"; export interface ProductAccountAddresses { ss58: string; diff --git a/src/utils/productAccount.test.ts b/src/utils/productAccount.test.ts new file mode 100644 index 0000000..6395ee3 --- /dev/null +++ b/src/utils/productAccount.test.ts @@ -0,0 +1,33 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import { describe, expect, it } from "vitest"; +import { ss58Encode } from "@parity/product-sdk-address"; +import { deriveProductAccountPublicKey } from "@parity/product-sdk-keys"; +import { PLAYGROUND_PRODUCT_ID } from "../config.js"; + +describe("product account integration", () => { + it("derives a stable SS58 address for playground.dot / index 0 from a fixed root", () => { + const root = new Uint8Array(32).fill(0); + const pubkey = deriveProductAccountPublicKey(root, PLAYGROUND_PRODUCT_ID, 0); + const address = ss58Encode(pubkey); + // The algorithm is locked by upstream frozen vectors in @parity/product-sdk-keys; + // here we only assert that wiring (config + sdk import + ss58Encode) does + // not silently produce an empty/malformed address. + expect(typeof address).toBe("string"); + expect(address.length).toBeGreaterThan(40); + expect(pubkey.length).toBe(32); + }); +}); diff --git a/src/utils/productAccountDerivation.ts b/src/utils/productAccountDerivation.ts deleted file mode 100644 index 063595b..0000000 --- a/src/utils/productAccountDerivation.ts +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * Local sr25519 soft-derivation for the product-account public key. - * - * The mobile wallet (polkadot-app-android-v2) derives the product account - * keypair via substrate-sdk-android with derivation path - * `"/product/{productId}/{derivationIndex}"`, applied to the user's wallet - * mnemonic (see `feature_products_impl::ProductAccountDerivationUseCase`). - * - * Sr25519 soft derivation is composable on public keys alone, so given the - * user's bare-mnemonic public key (sent over SSO as `session.rootAccountId` - * — handshake field `rootUserAccountId`, which is `deriveRootAccount()` on - * the mobile = the mnemonic's bare keypair with `derivationPath = null`) we - * can compute the same product-account public key that the mobile derives - * privately, without needing the seed or a mobile round-trip. - * - * The chain-code rule (32 bytes per junction) matches - * `@polkadot-labs/hdkd-helpers::createChainCode`: - * - numeric junction (`+code` not NaN) → SCALE u32 LE, zero-padded - * - string junction → SCALE string (length-prefixed - * compact + UTF-8 bytes), zero-padded - * Upstream silently `RangeError`s if the encoding exceeds 32 bytes (the - * `Uint8Array.set` call throws). We instead throw a descriptive error. The - * paths we care about — `product`, dotNS identifiers, small indices — - * always fit, so this is informational rather than a real fallback. - */ - -import { HDKD } from "@scure/sr25519"; -import { str, u32 } from "scale-ts"; - -/** - * Build the 32-byte chain code for a single derivation junction. - * - * Mirrors `@polkadot-labs/hdkd-helpers/dist/index.js::createChainCode`: - * numeric: SCALE u32 LE - * string : SCALE compact-length + UTF-8 bytes - * Either way, the encoding is zero-padded out to 32 bytes. - */ -function createChainCode(code: string): Uint8Array { - const chainCode = new Uint8Array(32); - const encoded = Number.isNaN(+code) ? str.enc(code) : u32.enc(+code); - if (encoded.length > 32) { - throw new Error( - `Derivation junction "${code}" encodes to ${encoded.length} bytes — exceeds the 32-byte chain-code slot. Long junctions need a blake2b-256 fallback that this helper does not implement; only short junctions (product, dotNS labels, small indices) are supported.`, - ); - } - chainCode.set(encoded); - return chainCode; -} - -/** - * Soft-derive the product-account public key from the parent (root-account) - * public key, following the mobile's `"/product/{productId}/{derivationIndex}"` - * convention. - * - * `parentPublicKey` must be the bare wallet-mnemonic keypair's public key - * (the one with no derivation applied) — i.e. `session.rootAccountId`. Passing - * `session.remoteAccount.accountId` produces the wrong account: that field - * carries the wallet's currently-selected substrate account, which may have - * its own derivation applied that the product path is NOT chained off of. - */ -export function deriveProductAccountPublicKey( - parentPublicKey: Uint8Array, - productId: string, - derivationIndex: number, -): Uint8Array { - let pubkey = parentPublicKey; - for (const code of ["product", productId, String(derivationIndex)]) { - pubkey = HDKD.publicSoft(pubkey, createChainCode(code)); - } - return pubkey; -} diff --git a/src/utils/productAccountDerivation.test.ts b/src/utils/sessionSigner.test.ts similarity index 74% rename from src/utils/productAccountDerivation.test.ts rename to src/utils/sessionSigner.test.ts index 648f340..938cc31 100644 --- a/src/utils/productAccountDerivation.test.ts +++ b/src/utils/sessionSigner.test.ts @@ -18,58 +18,10 @@ import { ss58Encode } from "@parity/product-sdk-address"; import { seedToAccount } from "@parity/product-sdk-keys"; import type { UserSession } from "@parity/product-sdk-terminal"; import { PLAYGROUND_PRODUCT_ID } from "../config.js"; -import { deriveProductAccountPublicKey } from "./productAccountDerivation.js"; import { createPlaygroundSessionSigner } from "./sessionSigner.js"; const DEV_PHRASE = "bottom drive obey lake curtain smoke basket hold race lonely fit walk"; -function toHex(bytes: Uint8Array): string { - return ( - "0x" + - Array.from(bytes) - .map((b) => b.toString(16).padStart(2, "0")) - .join("") - ); -} - -describe("deriveProductAccountPublicKey", () => { - // The mobile wallet derives the product account by applying derivation - // path "/product/{productId}/{derivationIndex}" to the user's mnemonic - // (substrate-sdk-android, EncryptionType.SR25519). For sr25519 soft - // derivation, applying that path to the mnemonic and applying it as - // public-soft to the bare mnemonic keypair's public key produce the - // same final public key. This test pins that property. - test("matches mnemonic+derivation-path keypair (single-junction productId)", () => { - // Empty path → bare master keypair from mnemonic. Same as Android's - // `deriveRootAccount()` / `derivationPath = null`. Public key here is - // what arrives in `session.rootAccountId` over SSO. - const root = seedToAccount(DEV_PHRASE, ""); - const product = seedToAccount(DEV_PHRASE, "/product/playground.dot/0"); - - const local = deriveProductAccountPublicKey(root.publicKey, "playground.dot", 0); - - expect(toHex(local)).toEqual(toHex(product.publicKey)); - }); - - test("matches for a multi-segment productId and non-zero index", () => { - const root = seedToAccount(DEV_PHRASE, ""); - const product = seedToAccount(DEV_PHRASE, "/product/some-app.dot/7"); - - const local = deriveProductAccountPublicKey(root.publicKey, "some-app.dot", 7); - - expect(toHex(local)).toEqual(toHex(product.publicKey)); - }); - - test("different productIds produce different accounts", () => { - const root = seedToAccount(DEV_PHRASE, ""); - - const a = deriveProductAccountPublicKey(root.publicKey, "playground.dot", 0); - const b = deriveProductAccountPublicKey(root.publicKey, "playground42.dot", 0); - - expect(toHex(a)).not.toEqual(toHex(b)); - }); -}); - // ──────────────────────────────────────────────────────────────────────────── // Init / deploy / playground-app equivalence // @@ -89,7 +41,7 @@ describe("deriveProductAccountPublicKey", () => { // "/product/{dotNsId}/0").publicKey` and SS58-encodes it. // // As long as all three pin to the same `(rootPubKey, productId, 0)` triple, -// they yield byte-identical SS58 strings. This test is the regression guard. +// they yield byte-identical SS58 strings. These tests are the regression guard. // ──────────────────────────────────────────────────────────────────────────── describe("init / deploy / playground-app account equivalence", () => { // Build a stand-in for the mobile's SSO handshake response. Mirrors what diff --git a/src/utils/sessionSigner.ts b/src/utils/sessionSigner.ts index 6d6af0f..6b1535e 100644 --- a/src/utils/sessionSigner.ts +++ b/src/utils/sessionSigner.ts @@ -57,7 +57,7 @@ import { fromHex, toHex } from "polkadot-api/utils"; import { ss58Encode } from "@parity/product-sdk-address"; import type { UserSession } from "@parity/product-sdk-terminal"; import type { PolkadotSigner } from "polkadot-api"; -import { deriveProductAccountPublicKey } from "./productAccountDerivation.js"; +import { deriveProductAccountPublicKey } from "@parity/product-sdk-keys"; export interface ProductAccountRef { productId: string; @@ -111,7 +111,8 @@ export function createPlaygroundSessionSigner( // `derivationPath = null`). Sr25519 soft derivation is composable on // public keys alone, so deriving from it locally produces the SAME public // key the mobile derives privately via `mnemonic + "/product/...{idx}"`. - // See `productAccountDerivation.test.ts` for the proof-of-equivalence. + // Algorithm parity with mobile/desktop is locked by the frozen vectors in + // `@parity/product-sdk-keys`'s `product-account.test.ts`. const publicKey = deriveProductAccountPublicKey( new Uint8Array(session.rootAccountId), ref.productId,