polkahub 0.6.0 → 0.7.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.
@@ -1,14 +1,18 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
2
  import { useAvailableAccounts, AddressIdentity } from '@polkahub/context';
3
3
  import { AddressInput as AddressInput$1 } from '@polkahub/ui-components';
4
+ import { getSs58AddressInfo } from 'polkadot-api';
4
5
  import { useMemo } from 'react';
5
6
 
6
7
  const AddressInput = (props) => {
8
+ const { format } = props;
7
9
  const availableAccounts = useAvailableAccounts();
8
10
  const hints = useMemo(() => {
9
11
  const addressToAccounts = {};
10
12
  Object.values(availableAccounts).flat().forEach((acc) => {
11
13
  var _a;
14
+ if (format === "ss58" && !getSs58AddressInfo(acc.address).isValid || format === "eth" && !(acc.address.startsWith("0x") && acc.address.length === 42))
15
+ return;
12
16
  addressToAccounts[_a = acc.address] ?? (addressToAccounts[_a] = []);
13
17
  addressToAccounts[acc.address].push(acc);
14
18
  });
@@ -17,7 +21,7 @@ const AddressInput = (props) => {
17
21
  (acc, v) => (v.name?.length ?? 0) > (acc.name?.length ?? 0) ? v : acc
18
22
  )
19
23
  );
20
- }, [availableAccounts]);
24
+ }, [availableAccounts, format]);
21
25
  return /* @__PURE__ */ jsx(
22
26
  AddressInput$1,
23
27
  {
@@ -1 +1 @@
1
- {"version":3,"file":"AddressInput.js","sources":["../src/AddressInput.tsx"],"sourcesContent":["import { AddressIdentity, useAvailableAccounts } from \"@polkahub/context\";\nimport { Account, AccountAddress } from \"@polkahub/plugin\";\nimport { AddressInput as AddressInputComponent } from \"@polkahub/ui-components\";\nimport { FC, useMemo } from \"react\";\n\nexport const AddressInput: FC<{\n value?: AccountAddress | null;\n onChange?: (value: AccountAddress | null) => void;\n disableClear?: boolean;\n className?: string;\n triggerClassName?: string;\n}> = (props) => {\n const availableAccounts = useAvailableAccounts();\n\n const hints = useMemo(() => {\n const addressToAccounts: Record<AccountAddress, Account[]> = {};\n Object.values(availableAccounts)\n .flat()\n .forEach((acc) => {\n addressToAccounts[acc.address] ??= [];\n addressToAccounts[acc.address].push(acc);\n });\n\n return Object.values(addressToAccounts).map((group) =>\n group.reduce((acc, v) =>\n (v.name?.length ?? 0) > (acc.name?.length ?? 0) ? v : acc\n )\n );\n }, [availableAccounts]);\n\n return (\n <AddressInputComponent\n hinted={Object.values(hints).flat()}\n renderAddress={(account: Account | string) =>\n typeof account === \"string\" ? (\n <AddressIdentity addr={account} copyable={false} />\n ) : (\n <AddressIdentity\n addr={account.address}\n name={account?.name}\n copyable={false}\n />\n )\n }\n {...props}\n />\n );\n};\n"],"names":["AddressInputComponent"],"mappings":";;;;;AAKO,MAAM,YAAA,GAMR,CAAC,KAAA,KAAU;AACd,EAAA,MAAM,oBAAoB,oBAAA,EAAqB;AAE/C,EAAA,MAAM,KAAA,GAAQ,QAAQ,MAAM;AAC1B,IAAA,MAAM,oBAAuD,EAAC;AAC9D,IAAA,MAAA,CAAO,OAAO,iBAAiB,CAAA,CAC5B,MAAK,CACL,OAAA,CAAQ,CAAC,GAAA,KAAQ;AAlBxB,MAAA,IAAA,EAAA;AAmBQ,MAAA,iBAAA,CAAA,EAAA,GAAkB,GAAA,CAAI,OAAA,CAAA,KAAtB,iBAAA,CAAA,EAAA,CAAA,GAAmC,EAAC,CAAA;AACpC,MAAA,iBAAA,CAAkB,GAAA,CAAI,OAAO,CAAA,CAAE,IAAA,CAAK,GAAG,CAAA;AAAA,IACzC,CAAC,CAAA;AAEH,IAAA,OAAO,MAAA,CAAO,MAAA,CAAO,iBAAiB,CAAA,CAAE,GAAA;AAAA,MAAI,CAAC,UAC3C,KAAA,CAAM,MAAA;AAAA,QAAO,CAAC,GAAA,EAAK,CAAA,KAAA,CAChB,CAAA,CAAE,IAAA,EAAM,MAAA,IAAU,CAAA,KAAM,GAAA,CAAI,IAAA,EAAM,MAAA,IAAU,CAAA,CAAA,GAAK,CAAA,GAAI;AAAA;AACxD,KACF;AAAA,EACF,CAAA,EAAG,CAAC,iBAAiB,CAAC,CAAA;AAEtB,EAAA,uBACE,GAAA;AAAA,IAACA,cAAA;AAAA,IAAA;AAAA,MACC,MAAA,EAAQ,MAAA,CAAO,MAAA,CAAO,KAAK,EAAE,IAAA,EAAK;AAAA,MAClC,aAAA,EAAe,CAAC,OAAA,KACd,OAAO,OAAA,KAAY,QAAA,mBACjB,GAAA,CAAC,eAAA,EAAA,EAAgB,IAAA,EAAM,OAAA,EAAS,QAAA,EAAU,KAAA,EAAO,CAAA,mBAEjD,GAAA;AAAA,QAAC,eAAA;AAAA,QAAA;AAAA,UACC,MAAM,OAAA,CAAQ,OAAA;AAAA,UACd,MAAM,OAAA,EAAS,IAAA;AAAA,UACf,QAAA,EAAU;AAAA;AAAA,OACZ;AAAA,MAGH,GAAG;AAAA;AAAA,GACN;AAEJ;;;;"}
1
+ {"version":3,"file":"AddressInput.js","sources":["../src/AddressInput.tsx"],"sourcesContent":["import { AddressIdentity, useAvailableAccounts } from \"@polkahub/context\";\nimport { Account, AccountAddress } from \"@polkahub/plugin\";\nimport { AddressInput as AddressInputComponent } from \"@polkahub/ui-components\";\nimport { getSs58AddressInfo } from \"polkadot-api\";\nimport { FC, useMemo } from \"react\";\n\nexport const AddressInput: FC<{\n value?: AccountAddress | null;\n onChange?: (value: AccountAddress | null) => void;\n disableClear?: boolean;\n className?: string;\n triggerClassName?: string;\n format?: \"ss58\" | \"eth\";\n}> = (props) => {\n const { format } = props;\n const availableAccounts = useAvailableAccounts();\n\n const hints = useMemo(() => {\n const addressToAccounts: Record<AccountAddress, Account[]> = {};\n Object.values(availableAccounts)\n .flat()\n .forEach((acc) => {\n if (\n (format === \"ss58\" && !getSs58AddressInfo(acc.address).isValid) ||\n (format === \"eth\" &&\n !(acc.address.startsWith(\"0x\") && acc.address.length === 42))\n )\n return;\n addressToAccounts[acc.address] ??= [];\n addressToAccounts[acc.address].push(acc);\n });\n\n return Object.values(addressToAccounts).map((group) =>\n group.reduce((acc, v) =>\n (v.name?.length ?? 0) > (acc.name?.length ?? 0) ? v : acc\n )\n );\n }, [availableAccounts, format]);\n\n return (\n <AddressInputComponent\n hinted={Object.values(hints).flat()}\n renderAddress={(account: Account | string) =>\n typeof account === \"string\" ? (\n <AddressIdentity addr={account} copyable={false} />\n ) : (\n <AddressIdentity\n addr={account.address}\n name={account?.name}\n copyable={false}\n />\n )\n }\n {...props}\n />\n );\n};\n"],"names":["AddressInputComponent"],"mappings":";;;;;;AAMO,MAAM,YAAA,GAOR,CAAC,KAAA,KAAU;AACd,EAAA,MAAM,EAAE,QAAO,GAAI,KAAA;AACnB,EAAA,MAAM,oBAAoB,oBAAA,EAAqB;AAE/C,EAAA,MAAM,KAAA,GAAQ,QAAQ,MAAM;AAC1B,IAAA,MAAM,oBAAuD,EAAC;AAC9D,IAAA,MAAA,CAAO,OAAO,iBAAiB,CAAA,CAC5B,MAAK,CACL,OAAA,CAAQ,CAAC,GAAA,KAAQ;AArBxB,MAAA,IAAA,EAAA;AAsBQ,MAAA,IACG,WAAW,MAAA,IAAU,CAAC,mBAAmB,GAAA,CAAI,OAAO,EAAE,OAAA,IACtD,MAAA,KAAW,KAAA,IACV,EAAE,IAAI,OAAA,CAAQ,UAAA,CAAW,IAAI,CAAA,IAAK,GAAA,CAAI,QAAQ,MAAA,KAAW,EAAA,CAAA;AAE3D,QAAA;AACF,MAAA,iBAAA,CAAA,EAAA,GAAkB,GAAA,CAAI,OAAA,CAAA,KAAtB,iBAAA,CAAA,EAAA,CAAA,GAAmC,EAAC,CAAA;AACpC,MAAA,iBAAA,CAAkB,GAAA,CAAI,OAAO,CAAA,CAAE,IAAA,CAAK,GAAG,CAAA;AAAA,IACzC,CAAC,CAAA;AAEH,IAAA,OAAO,MAAA,CAAO,MAAA,CAAO,iBAAiB,CAAA,CAAE,GAAA;AAAA,MAAI,CAAC,UAC3C,KAAA,CAAM,MAAA;AAAA,QAAO,CAAC,GAAA,EAAK,CAAA,KAAA,CAChB,CAAA,CAAE,IAAA,EAAM,MAAA,IAAU,CAAA,KAAM,GAAA,CAAI,IAAA,EAAM,MAAA,IAAU,CAAA,CAAA,GAAK,CAAA,GAAI;AAAA;AACxD,KACF;AAAA,EACF,CAAA,EAAG,CAAC,iBAAA,EAAmB,MAAM,CAAC,CAAA;AAE9B,EAAA,uBACE,GAAA;AAAA,IAACA,cAAA;AAAA,IAAA;AAAA,MACC,MAAA,EAAQ,MAAA,CAAO,MAAA,CAAO,KAAK,EAAE,IAAA,EAAK;AAAA,MAClC,aAAA,EAAe,CAAC,OAAA,KACd,OAAO,OAAA,KAAY,QAAA,mBACjB,GAAA,CAAC,eAAA,EAAA,EAAgB,IAAA,EAAM,OAAA,EAAS,QAAA,EAAU,KAAA,EAAO,CAAA,mBAEjD,GAAA;AAAA,QAAC,eAAA;AAAA,QAAA;AAAA,UACC,MAAM,OAAA,CAAQ,OAAA;AAAA,UACd,MAAM,OAAA,EAAS,IAAA;AAAA,UACf,QAAA,EAAU;AAAA;AAAA,OACZ;AAAA,MAGH,GAAG;AAAA;AAAA,GACN;AAEJ;;;;"}
@@ -22,6 +22,7 @@ declare const AddressInput: FC<{
22
22
  disableClear?: boolean;
23
23
  className?: string;
24
24
  triggerClassName?: string;
25
+ format?: "ss58" | "eth";
25
26
  }>;
26
27
 
27
28
  declare const PolkaHubModalTrigger: FC;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polkahub",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "author": "Victor Oliva (https://github.com/voliva)",
5
5
  "repository": {
6
6
  "type": "git",
@@ -31,19 +31,20 @@
31
31
  "@react-rxjs/core": "^0.10.8",
32
32
  "@react-rxjs/utils": "^0.9.7",
33
33
  "lucide-react": "^1.14.0",
34
+ "polkadot-api": "^2.1.3",
34
35
  "@polkahub/context": "0.6.0",
35
- "@polkahub/mimir": "0.6.0",
36
36
  "@polkahub/ledger": "0.6.0",
37
- "@polkahub/pjs-wallet": "0.6.0",
37
+ "@polkahub/mimir": "0.6.0",
38
38
  "@polkahub/multisig": "0.6.0",
39
+ "@polkahub/pjs-wallet": "0.6.0",
40
+ "@polkahub/proxy": "0.6.0",
39
41
  "@polkahub/plugin": "0.6.0",
40
42
  "@polkahub/select-account": "0.6.0",
41
- "@polkahub/proxy": "0.6.0",
42
- "@polkahub/read-only": "0.6.0",
43
43
  "@polkahub/state": "0.6.0",
44
- "@polkahub/ui-components": "0.6.0",
44
+ "@polkahub/ui-components": "0.7.0",
45
+ "@polkahub/vault": "0.6.0",
45
46
  "@polkahub/wallet-connect": "0.6.0",
46
- "@polkahub/vault": "0.6.0"
47
+ "@polkahub/read-only": "0.7.0"
47
48
  },
48
49
  "peerDependencies": {
49
50
  "@types/react": "^19.2.2",
@@ -51,7 +52,7 @@
51
52
  },
52
53
  "devDependencies": {
53
54
  "@types/react": "^19.2.14",
54
- "react": "^19.2.5"
55
+ "react": "^19.2.6"
55
56
  },
56
57
  "scripts": {
57
58
  "build": "tsc -b && rollup -c ../../rollup.config.js"