@w3ux/react-connect-kit 0.1.14 → 0.1.16
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/LedgerAccountsProvider/defaults.js +6 -5
- package/LedgerAccountsProvider/defaults.js.map +1 -1
- package/LedgerAccountsProvider/index.d.ts +1 -1
- package/LedgerAccountsProvider/index.js +11 -11
- package/LedgerAccountsProvider/index.js.map +1 -1
- package/LedgerAccountsProvider/types.d.ts +6 -6
- package/LedgerAccountsProvider/types.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export var defaultLedgerAccountsContext = {
|
|
2
|
-
ledgerAccountExists: function (address) { return false; },
|
|
3
|
-
addLedgerAccount: function (address, index, callback) { return null; },
|
|
4
|
-
removeLedgerAccount: function (address, callback) { },
|
|
5
|
-
renameLedgerAccount: function (address, newName) { },
|
|
6
|
-
getLedgerAccount: function (address) { return null; },
|
|
2
|
+
ledgerAccountExists: function (network, address) { return false; },
|
|
3
|
+
addLedgerAccount: function (network, address, index, callback) { return null; },
|
|
4
|
+
removeLedgerAccount: function (network, address, callback) { },
|
|
5
|
+
renameLedgerAccount: function (network, address, newName) { },
|
|
6
|
+
getLedgerAccount: function (network, address) { return null; },
|
|
7
|
+
getLedgerAccounts: function (network) { return []; },
|
|
7
8
|
ledgerAccounts: [],
|
|
8
9
|
};
|
|
9
10
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/LedgerAccountsProvider/defaults.ts"],"names":[],"mappings":"AAAA;wCACwC;AACxC,6GAA6G;AAI7G,MAAM,CAAC,IAAM,4BAA4B,GAAmC;IAC1E,mBAAmB,EAAE,UAAC,OAAO,IAAK,OAAA,KAAK,EAAL,CAAK;
|
|
1
|
+
{"version":3,"sources":["../src/LedgerAccountsProvider/defaults.ts"],"names":[],"mappings":"AAAA;wCACwC;AACxC,6GAA6G;AAI7G,MAAM,CAAC,IAAM,4BAA4B,GAAmC;IAC1E,mBAAmB,EAAE,UAAC,OAAO,EAAE,OAAO,IAAK,OAAA,KAAK,EAAL,CAAK;IAChD,gBAAgB,EAAE,UAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,IAAK,OAAA,IAAI,EAAJ,CAAI;IAC7D,mBAAmB,EAAE,UAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,IAAM,CAAC;IACvD,mBAAmB,EAAE,UAAC,OAAO,EAAE,OAAO,EAAE,OAAO,IAAM,CAAC;IACtD,gBAAgB,EAAE,UAAC,OAAO,EAAE,OAAO,IAAK,OAAA,IAAI,EAAJ,CAAI;IAC5C,iBAAiB,EAAE,UAAC,OAAO,IAAK,OAAA,EAAE,EAAF,CAAE;IAClC,cAAc,EAAE,EAAE;CACnB,CAAC","file":"defaults.js","sourcesContent":["/* @license Copyright 2024 w3ux authors & contributors\nSPDX-License-Identifier: GPL-3.0-only */\n/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function, no-unused-vars */\n\nimport { LedgerAccountsContextInterface } from \"./types\";\n\nexport const defaultLedgerAccountsContext: LedgerAccountsContextInterface = {\n ledgerAccountExists: (network, address) => false,\n addLedgerAccount: (network, address, index, callback) => null,\n removeLedgerAccount: (network, address, callback) => {},\n renameLedgerAccount: (network, address, newName) => {},\n getLedgerAccount: (network, address) => null,\n getLedgerAccounts: (network) => [],\n ledgerAccounts: [],\n};\n"]}
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { LedgerAccountsContextInterface, LedgerAccountsProviderProps } from "./types";
|
|
3
3
|
export declare const LedgerAccountsContext: import("react").Context<LedgerAccountsContextInterface>;
|
|
4
4
|
export declare const useLedgerAccounts: () => LedgerAccountsContextInterface;
|
|
5
|
-
export declare const LedgerAccountsProvider: ({ children,
|
|
5
|
+
export declare const LedgerAccountsProvider: ({ children, }: LedgerAccountsProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -23,19 +23,18 @@ import { createContext, useContext, useRef, useState } from "react";
|
|
|
23
23
|
import { defaultLedgerAccountsContext } from "./defaults";
|
|
24
24
|
import { getLocalLedgerAccounts, getLocalLedgerAddresses, isLocalLedgerAccount, renameLocalLedgerAddress, } from "./utils";
|
|
25
25
|
import { setStateWithRef } from "@w3ux/utils";
|
|
26
|
-
import { useEffectIgnoreInitial } from "@w3ux/hooks";
|
|
27
26
|
export var LedgerAccountsContext = createContext(defaultLedgerAccountsContext);
|
|
28
27
|
export var useLedgerAccounts = function () { return useContext(LedgerAccountsContext); };
|
|
29
28
|
export var LedgerAccountsProvider = function (_a) {
|
|
30
|
-
var children = _a.children
|
|
31
|
-
var _b = useState(getLocalLedgerAccounts(
|
|
29
|
+
var children = _a.children;
|
|
30
|
+
var _b = useState(getLocalLedgerAccounts()), ledgerAccounts = _b[0], setLedgerAccountsState = _b[1];
|
|
32
31
|
var ledgerAccountsRef = useRef(ledgerAccounts);
|
|
33
|
-
var ledgerAccountExists = function (address) {
|
|
32
|
+
var ledgerAccountExists = function (network, address) {
|
|
34
33
|
return !!getLocalLedgerAccounts().find(function (account) {
|
|
35
34
|
return isLocalLedgerAccount(network, account, address);
|
|
36
35
|
});
|
|
37
36
|
};
|
|
38
|
-
var addLedgerAccount = function (address, index, callback) {
|
|
37
|
+
var addLedgerAccount = function (network, address, index, callback) {
|
|
39
38
|
var newLedgerAccounts = getLocalLedgerAccounts();
|
|
40
39
|
var ledgerAddress = getLocalLedgerAddresses().find(function (a) {
|
|
41
40
|
return isLocalLedgerAccount(network, a, address);
|
|
@@ -61,7 +60,7 @@ export var LedgerAccountsProvider = function (_a) {
|
|
|
61
60
|
}
|
|
62
61
|
return null;
|
|
63
62
|
};
|
|
64
|
-
var removeLedgerAccount = function (address, callback) {
|
|
63
|
+
var removeLedgerAccount = function (network, address, callback) {
|
|
65
64
|
var newLedgerAccounts = getLocalLedgerAccounts().filter(function (account) {
|
|
66
65
|
if (account.address !== address) {
|
|
67
66
|
return true;
|
|
@@ -82,7 +81,7 @@ export var LedgerAccountsProvider = function (_a) {
|
|
|
82
81
|
callback();
|
|
83
82
|
}
|
|
84
83
|
};
|
|
85
|
-
var renameLedgerAccount = function (address, newName) {
|
|
84
|
+
var renameLedgerAccount = function (network, address, newName) {
|
|
86
85
|
var newLedgerAccounts = getLocalLedgerAccounts().map(function (account) {
|
|
87
86
|
return isLocalLedgerAccount(network, account, address)
|
|
88
87
|
? __assign(__assign({}, account), { name: newName }) : account;
|
|
@@ -91,7 +90,7 @@ export var LedgerAccountsProvider = function (_a) {
|
|
|
91
90
|
localStorage.setItem("ledger_accounts", JSON.stringify(newLedgerAccounts));
|
|
92
91
|
setStateWithRef(newLedgerAccounts.filter(function (account) { return account.network === network; }), setLedgerAccountsState, ledgerAccountsRef);
|
|
93
92
|
};
|
|
94
|
-
var getLedgerAccount = function (address) {
|
|
93
|
+
var getLedgerAccount = function (network, address) {
|
|
95
94
|
var localLedgerAccounts = getLocalLedgerAccounts();
|
|
96
95
|
if (!localLedgerAccounts) {
|
|
97
96
|
return null;
|
|
@@ -100,15 +99,16 @@ export var LedgerAccountsProvider = function (_a) {
|
|
|
100
99
|
return isLocalLedgerAccount(network, account, address);
|
|
101
100
|
}) || null);
|
|
102
101
|
};
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
102
|
+
var getLedgerAccounts = function (network) {
|
|
103
|
+
return ledgerAccountsRef.current.filter(function (a) { return a.network === network; });
|
|
104
|
+
};
|
|
106
105
|
return (_jsx(LedgerAccountsContext.Provider, { value: {
|
|
107
106
|
ledgerAccountExists: ledgerAccountExists,
|
|
108
107
|
getLedgerAccount: getLedgerAccount,
|
|
109
108
|
addLedgerAccount: addLedgerAccount,
|
|
110
109
|
removeLedgerAccount: removeLedgerAccount,
|
|
111
110
|
renameLedgerAccount: renameLedgerAccount,
|
|
111
|
+
getLedgerAccounts: getLedgerAccounts,
|
|
112
112
|
ledgerAccounts: ledgerAccountsRef.current,
|
|
113
113
|
}, children: children }));
|
|
114
114
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/LedgerAccountsProvider/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;wCACwC;AAExC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpE,OAAO,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;AAM1D,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"sources":["../src/LedgerAccountsProvider/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;wCACwC;AAExC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpE,OAAO,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;AAM1D,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,CAAC,IAAM,qBAAqB,GAChC,aAAa,CAAiC,4BAA4B,CAAC,CAAC;AAE9E,MAAM,CAAC,IAAM,iBAAiB,GAAG,cAAM,OAAA,UAAU,CAAC,qBAAqB,CAAC,EAAjC,CAAiC,CAAC;AAEzE,MAAM,CAAC,IAAM,sBAAsB,GAAG,UAAC,EAET;QAD5B,QAAQ,cAAA;IAER,qCAAqC;IAC/B,IAAA,KAA2C,QAAQ,CACvD,sBAAsB,EAAE,CACzB,EAFM,cAAc,QAAA,EAAE,sBAAsB,QAE5C,CAAC;IACF,IAAM,iBAAiB,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;IAEjD,0DAA0D;IAC1D,IAAM,mBAAmB,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,EAAE,iBAAiB,CAAC,OAAO;SAC1C,YAEA,QAAQ,GACsB,CAClC,CAAC;AACJ,CAAC,CAAC","file":"index.js","sourcesContent":["/* @license Copyright 2024 w3ux authors & contributors\nSPDX-License-Identifier: GPL-3.0-only */\n\nimport { createContext, useContext, useRef, useState } from \"react\";\nimport { defaultLedgerAccountsContext } from \"./defaults\";\nimport {\n LedgerAccountsContextInterface,\n LedgerAccountsProviderProps,\n} from \"./types\";\nimport { LedgerAccount } from \"../types\";\nimport {\n getLocalLedgerAccounts,\n getLocalLedgerAddresses,\n isLocalLedgerAccount,\n renameLocalLedgerAddress,\n} from \"./utils\";\nimport { setStateWithRef } from \"@w3ux/utils\";\n\nexport const LedgerAccountsContext =\n createContext<LedgerAccountsContextInterface>(defaultLedgerAccountsContext);\n\nexport const useLedgerAccounts = () => useContext(LedgerAccountsContext);\n\nexport const LedgerAccountsProvider = ({\n children,\n}: LedgerAccountsProviderProps) => {\n // Store the fetched ledger accounts.\n const [ledgerAccounts, setLedgerAccountsState] = useState<LedgerAccount[]>(\n getLocalLedgerAccounts()\n );\n const ledgerAccountsRef = useRef(ledgerAccounts);\n\n // Check if a Ledger address exists in imported addresses.\n const ledgerAccountExists = (network: string, address: string) =>\n !!getLocalLedgerAccounts().find((account) =>\n isLocalLedgerAccount(network, account, address)\n );\n\n // Adds a ledger address to the list of fetched addresses.\n const addLedgerAccount = (\n network: string,\n address: string,\n index: number,\n callback?: () => void\n ) => {\n let newLedgerAccounts = getLocalLedgerAccounts();\n\n const ledgerAddress = getLocalLedgerAddresses().find((a) =>\n isLocalLedgerAccount(network, a, address)\n );\n\n if (\n ledgerAddress &&\n !newLedgerAccounts.find((account) =>\n isLocalLedgerAccount(network, account, address)\n )\n ) {\n const newAccount = {\n address,\n network,\n name: ledgerAddress.name,\n source: \"ledger\",\n index,\n };\n\n // Update the full list of local ledger accounts with new entry.\n newLedgerAccounts = [...newLedgerAccounts].concat(newAccount);\n localStorage.setItem(\n \"ledger_accounts\",\n JSON.stringify(newLedgerAccounts)\n );\n\n // Store only those accounts on the current network in state.\n setStateWithRef(\n newLedgerAccounts.filter((account) => account.network === network),\n setLedgerAccountsState,\n ledgerAccountsRef\n );\n\n // Handle optional callback function.\n if (typeof callback === \"function\") {\n callback();\n }\n return newAccount;\n }\n return null;\n };\n\n // Removes a Ledger account from state and local storage.\n const removeLedgerAccount = (\n network: string,\n address: string,\n callback?: () => void\n ) => {\n // Remove th account from local storage records\n const newLedgerAccounts = getLocalLedgerAccounts().filter((account) => {\n if (account.address !== address) {\n return true;\n }\n if (account.network !== network) {\n return true;\n }\n return false;\n });\n if (!newLedgerAccounts.length) {\n localStorage.removeItem(\"ledger_accounts\");\n } else {\n localStorage.setItem(\n \"ledger_accounts\",\n JSON.stringify(newLedgerAccounts)\n );\n }\n\n // Update state with the new list of accounts.\n setStateWithRef(\n newLedgerAccounts.filter((account) => account.network === network),\n setLedgerAccountsState,\n ledgerAccountsRef\n );\n\n // Handle optional callback function.\n if (typeof callback === \"function\") {\n callback();\n }\n };\n\n // Renames an imported ledger account.\n const renameLedgerAccount = (\n network: string,\n address: string,\n newName: string\n ) => {\n // Update the local storage records.\n const newLedgerAccounts = getLocalLedgerAccounts().map((account) =>\n isLocalLedgerAccount(network, account, address)\n ? {\n ...account,\n name: newName,\n }\n : account\n );\n renameLocalLedgerAddress(address, newName, network);\n localStorage.setItem(\"ledger_accounts\", JSON.stringify(newLedgerAccounts));\n\n // Update state with the new list of accounts.\n setStateWithRef(\n newLedgerAccounts.filter((account) => account.network === network),\n setLedgerAccountsState,\n ledgerAccountsRef\n );\n };\n\n // Gets an imported address along with its Ledger metadata.\n const getLedgerAccount = (network: string, address: string) => {\n const localLedgerAccounts = getLocalLedgerAccounts();\n if (!localLedgerAccounts) {\n return null;\n }\n return (\n localLedgerAccounts.find((account) =>\n isLocalLedgerAccount(network, account, address)\n ) || null\n );\n };\n\n // Gets Ledger accounts for a network.\n const getLedgerAccounts = (network: string) =>\n ledgerAccountsRef.current.filter((a) => a.network === network);\n\n return (\n <LedgerAccountsContext.Provider\n value={{\n ledgerAccountExists,\n getLedgerAccount,\n addLedgerAccount,\n removeLedgerAccount,\n renameLedgerAccount,\n getLedgerAccounts,\n ledgerAccounts: ledgerAccountsRef.current,\n }}\n >\n {children}\n </LedgerAccountsContext.Provider>\n );\n};\n"]}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
2
|
import { LedgerAccount } from "../types";
|
|
3
3
|
export interface LedgerAccountsContextInterface {
|
|
4
|
-
ledgerAccountExists: (a: string) => boolean;
|
|
5
|
-
addLedgerAccount: (address: string, index: number, callback?: () => void) => LedgerAccount | null;
|
|
6
|
-
removeLedgerAccount: (address: string, callback?: () => void) => void;
|
|
7
|
-
renameLedgerAccount: (address: string, name: string) => void;
|
|
8
|
-
getLedgerAccount: (address: string) => LedgerAccount | null;
|
|
4
|
+
ledgerAccountExists: (network: string, a: string) => boolean;
|
|
5
|
+
addLedgerAccount: (network: string, address: string, index: number, callback?: () => void) => LedgerAccount | null;
|
|
6
|
+
removeLedgerAccount: (network: string, address: string, callback?: () => void) => void;
|
|
7
|
+
renameLedgerAccount: (network: string, address: string, name: string) => void;
|
|
8
|
+
getLedgerAccount: (network: string, address: string) => LedgerAccount | null;
|
|
9
|
+
getLedgerAccounts: (network: string) => LedgerAccount[];
|
|
9
10
|
ledgerAccounts: LedgerAccount[];
|
|
10
11
|
}
|
|
11
12
|
export interface LedgerAccountsProviderProps {
|
|
12
13
|
children: ReactNode;
|
|
13
|
-
network: string;
|
|
14
14
|
}
|
|
15
15
|
export interface LedgerAddress {
|
|
16
16
|
address: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/LedgerAccountsProvider/types.ts"],"names":[],"mappings":"AAAA;wCACwC","file":"types.js","sourcesContent":["/* @license Copyright 2024 w3ux authors & contributors\nSPDX-License-Identifier: GPL-3.0-only */\n\nimport { ReactNode } from \"react\";\nimport { LedgerAccount } from \"../types\";\n\nexport interface LedgerAccountsContextInterface {\n ledgerAccountExists: (a: string) => boolean;\n addLedgerAccount: (\n address: string,\n index: number,\n callback?: () => void\n ) => LedgerAccount | null;\n removeLedgerAccount: (address: string
|
|
1
|
+
{"version":3,"sources":["../src/LedgerAccountsProvider/types.ts"],"names":[],"mappings":"AAAA;wCACwC","file":"types.js","sourcesContent":["/* @license Copyright 2024 w3ux authors & contributors\nSPDX-License-Identifier: GPL-3.0-only */\n\nimport { ReactNode } from \"react\";\nimport { LedgerAccount } from \"../types\";\n\nexport interface LedgerAccountsContextInterface {\n ledgerAccountExists: (network: string, a: string) => boolean;\n addLedgerAccount: (\n network: string,\n address: string,\n index: number,\n callback?: () => void\n ) => LedgerAccount | null;\n removeLedgerAccount: (\n network: string,\n address: string,\n callback?: () => void\n ) => void;\n renameLedgerAccount: (network: string, address: string, name: string) => void;\n getLedgerAccount: (network: string, address: string) => LedgerAccount | null;\n getLedgerAccounts: (network: string) => LedgerAccount[];\n ledgerAccounts: LedgerAccount[];\n}\n\nexport interface LedgerAccountsProviderProps {\n children: ReactNode;\n}\n\nexport interface LedgerAddress {\n address: string;\n index: number;\n name: string;\n network: string;\n pubKey: string;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@w3ux/react-connect-kit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"license": "GPL-3.0-only",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"dependencies": {
|
|
@@ -9,6 +9,6 @@
|
|
|
9
9
|
"@polkagate/extension-dapp": "^0.46.12",
|
|
10
10
|
"@w3ux/extension-assets": "^0.2.3",
|
|
11
11
|
"@w3ux/hooks": "^0.0.3",
|
|
12
|
-
"@w3ux/utils": "^0.
|
|
12
|
+
"@w3ux/utils": "^0.1.1"
|
|
13
13
|
}
|
|
14
14
|
}
|