@parity/product-sdk 0.21.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/address/index.d.ts +1 -0
- package/dist/chunk-BRZNHTLQ.js +89 -0
- package/dist/chunk-BRZNHTLQ.js.map +1 -0
- package/dist/{chunk-6BI66XUJ.js → chunk-DHRCWMY5.js} +9 -10
- package/dist/chunk-DHRCWMY5.js.map +1 -0
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +2 -2
- package/dist/dotns-bswWAmR2.d.ts +136 -0
- package/dist/identity/index.d.ts +495 -49
- package/dist/identity/index.js +796 -46
- package/dist/identity/index.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/individuality/index.d.ts +1 -0
- package/dist/individuality/index.js +3 -0
- package/dist/individuality/index.js.map +1 -0
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +2 -2
- package/dist/testing/index.d.ts +2 -2
- package/dist/{types-CztPAgZT.d.ts → types-B5Zx4RNq.d.ts} +1 -1
- package/package.json +17 -12
- package/src/core/createApp.ts +10 -8
- package/src/identity/dotns-abis.test.ts +43 -0
- package/src/identity/dotns-abis.ts +309 -0
- package/src/identity/dotns-addresses.test.ts +536 -0
- package/src/identity/dotns-addresses.ts +320 -0
- package/src/identity/dotns-errors.ts +36 -0
- package/src/identity/dotns-namehash.test.ts +155 -0
- package/src/identity/dotns-namehash.ts +149 -0
- package/src/identity/dotns-owner.test.ts +92 -0
- package/src/identity/dotns-registry.test.ts +1309 -0
- package/src/identity/dotns-registry.ts +868 -0
- package/src/identity/dotns.test.ts +128 -0
- package/src/identity/dotns.ts +91 -78
- package/src/identity/index.test.ts +43 -0
- package/src/identity/index.ts +42 -16
- package/src/identity/types.ts +29 -38
- package/src/individuality/contract.test.ts +326 -0
- package/src/individuality/index.ts +8 -0
- package/dist/chunk-6BI66XUJ.js.map +0 -1
- package/dist/chunk-BIKT6X54.js +0 -70
- package/dist/chunk-BIKT6X54.js.map +0 -1
- package/dist/dotns-hLSvmo6u.d.ts +0 -178
- package/src/identity/product-account.ts +0 -164
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// Copyright 2026 Parity Technologies (UK) Ltd.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
/**
|
|
4
|
+
* The resolver's SS58 has to reach a `Consumers` key with no conversion, which is
|
|
5
|
+
* why the last test chains both reads instead of asserting on a type: `account` is
|
|
6
|
+
* `string` and `SS58String` carries an optional brand, so hex would satisfy both.
|
|
7
|
+
*
|
|
8
|
+
* Not named `dotns.test.ts` because the DotNS registry PR adds that path.
|
|
9
|
+
*/
|
|
10
|
+
import { describe, expect, test } from "vitest";
|
|
11
|
+
import type { SS58String } from "polkadot-api";
|
|
12
|
+
import { accountIdBytes } from "@parity/product-sdk-address";
|
|
13
|
+
import { type ConsumersChain, lookupUsername } from "@parity/product-sdk-individuality";
|
|
14
|
+
import { type PeopleUsernameQueryApi, resolvePeopleUsernameOwner } from "./dotns.js";
|
|
15
|
+
|
|
16
|
+
const ALICE = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" as SS58String;
|
|
17
|
+
|
|
18
|
+
/** A double that records the key it was asked for. */
|
|
19
|
+
function fakePeopleApi(owner: SS58String | undefined) {
|
|
20
|
+
const keys: Uint8Array[] = [];
|
|
21
|
+
const api: PeopleUsernameQueryApi = {
|
|
22
|
+
query: {
|
|
23
|
+
Resources: {
|
|
24
|
+
UsernameOwnerOf: {
|
|
25
|
+
getValue: async (key: Uint8Array) => {
|
|
26
|
+
keys.push(key);
|
|
27
|
+
return owner;
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
return { api, keys };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
describe("resolvePeopleUsernameOwner", () => {
|
|
37
|
+
test("returns the SS58 the storage yielded, unconverted", async () => {
|
|
38
|
+
const { api } = fakePeopleApi(ALICE);
|
|
39
|
+
expect(await resolvePeopleUsernameOwner("alice.dot", api)).toBe(ALICE);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test("an unowned username is null", async () => {
|
|
43
|
+
const { api } = fakePeopleApi(undefined);
|
|
44
|
+
expect(await resolvePeopleUsernameOwner("nobody.dot", api)).toBeNull();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test("the username is UTF-8 encoded for the storage key", async () => {
|
|
48
|
+
const { api, keys } = fakePeopleApi(ALICE);
|
|
49
|
+
await resolvePeopleUsernameOwner("alice.dot", api);
|
|
50
|
+
expect(keys[0]).toEqual(new TextEncoder().encode("alice.dot"));
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test("the owner reaches the Consumers storage key unconverted", async () => {
|
|
54
|
+
// The one assertion here that spans both reads: the resolver's output goes
|
|
55
|
+
// straight into `lookupUsername` and has to arrive as the storage key
|
|
56
|
+
// untouched. The recorded key is the guard, not a type: see the header.
|
|
57
|
+
const { api } = fakePeopleApi(ALICE);
|
|
58
|
+
const owner = await resolvePeopleUsernameOwner("alice.dot", api);
|
|
59
|
+
expect(owner).not.toBeNull();
|
|
60
|
+
if (owner === null) return;
|
|
61
|
+
|
|
62
|
+
const keys: string[] = [];
|
|
63
|
+
const chain: ConsumersChain = {
|
|
64
|
+
individuality: {
|
|
65
|
+
query: {
|
|
66
|
+
Resources: {
|
|
67
|
+
Consumers: {
|
|
68
|
+
async getValue(key) {
|
|
69
|
+
keys.push(key);
|
|
70
|
+
return undefined;
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const result = await lookupUsername(chain, { account: owner });
|
|
79
|
+
expect(result.ok).toBe(true);
|
|
80
|
+
expect(keys).toEqual([ALICE]);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test("the returned owner still decodes to a 32-byte public key", async () => {
|
|
84
|
+
// What `signMessageWithDotNsIdentity` needs to build a signer. SS58 to
|
|
85
|
+
// bytes is one call; it used to go SS58 to hex to bytes.
|
|
86
|
+
const { api } = fakePeopleApi(ALICE);
|
|
87
|
+
const owner = await resolvePeopleUsernameOwner("alice.dot", api);
|
|
88
|
+
expect(owner).not.toBeNull();
|
|
89
|
+
if (owner === null) return;
|
|
90
|
+
expect(accountIdBytes(owner)).toHaveLength(32);
|
|
91
|
+
});
|
|
92
|
+
});
|