@xyo-network/react-wallet 2.55.3 → 2.55.4

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.
@@ -3,7 +3,18 @@ import { usePromise } from '@xyo-network/react-shared';
3
3
  import { useAccountFromContext } from '../contexts';
4
4
  export const useAccount = ({ mnemonic, account, path, required, seed } = {}) => {
5
5
  const [contextAccount] = useAccountFromContext(!account && required);
6
- const [activeAccount] = usePromise(async () => ((account ?? mnemonic) ? await HDWallet.fromMnemonic(mnemonic) : seed ? await HDWallet.fromSeed(seed) : contextAccount), [account, mnemonic, contextAccount, seed]);
6
+ const [activeAccount] = usePromise(async () => {
7
+ if (account) {
8
+ return account;
9
+ }
10
+ else if (mnemonic) {
11
+ return await HDWallet.fromMnemonic(mnemonic);
12
+ }
13
+ else if (seed) {
14
+ return await HDWallet.fromSeed(seed);
15
+ }
16
+ return contextAccount;
17
+ }, [account, mnemonic, contextAccount, seed]);
7
18
  return usePromise(async () => (path ? await activeAccount?.derivePath?.(path) : activeAccount));
8
19
  };
9
20
  //# sourceMappingURL=useAccount.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useAccount.js","sourceRoot":"","sources":["../../../src/hooks/useAccount.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAE/C,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAGtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAUnD,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,KAAwB,EAAE,EAAE,EAAE;IAChG,MAAM,CAAC,cAAc,CAAC,GAAG,qBAAqB,CAAC,CAAC,OAAO,IAAI,QAAQ,CAAC,CAAA;IACpE,MAAM,CAAC,aAAa,CAAC,GAAG,UAAU,CAChC,KAAK,IAAI,EAAE,CAAC,CAA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AAO,cAAc,CAAA;IACvB,CAAC,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,IAAI,CAAC,CAAC,CAAA;IAC7C,OAAO,UAAU,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,aAAa,EAAE,UAAU,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAA;AACjG,CAAC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"useAccount.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAccount.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE5C,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAI1D,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,CAAC,EAAE,QAAQ,CAAA;CAChB;AAED,eAAO,MAAM,UAAU,iDAAiD,iBAAiB,2GAOxF,CAAA"}
1
+ {"version":3,"file":"useAccount.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAccount.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE5C,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAI1D,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,CAAC,EAAE,QAAQ,CAAA;CAChB;AAED,eAAO,MAAM,UAAU,iDAAiD,iBAAiB,2GAaxF,CAAA"}
package/package.json CHANGED
@@ -21,9 +21,9 @@
21
21
  "@xylabs/react-shared": "^2.17.3",
22
22
  "@xyo-network/account": "^2.63.2",
23
23
  "@xyo-network/core": "^2.63.2",
24
- "@xyo-network/react-address-render": "^2.55.3",
25
- "@xyo-network/react-network": "^2.55.3",
26
- "@xyo-network/react-shared": "^2.55.3",
24
+ "@xyo-network/react-address-render": "^2.55.4",
25
+ "@xyo-network/react-network": "^2.55.4",
26
+ "@xyo-network/react-shared": "^2.55.4",
27
27
  "@xyo-network/wallet-model": "^2.63.2"
28
28
  },
29
29
  "peerDependencies": {
@@ -40,7 +40,7 @@
40
40
  "@storybook/react": "^7.0.23",
41
41
  "@xylabs/ts-scripts-yarn3": "^2.17.17",
42
42
  "@xylabs/tsconfig-react": "^2.17.17",
43
- "@xyo-network/react-storybook": "^2.55.3",
43
+ "@xyo-network/react-storybook": "^2.55.4",
44
44
  "typescript": "^5.1.3"
45
45
  },
46
46
  "browser": "dist/esm/index.js",
@@ -85,5 +85,5 @@
85
85
  },
86
86
  "sideEffects": false,
87
87
  "types": "dist/types/index.d.ts",
88
- "version": "2.55.3"
88
+ "version": "2.55.4"
89
89
  }
@@ -15,9 +15,15 @@ export interface AccountHookParams {
15
15
 
16
16
  export const useAccount = ({ mnemonic, account, path, required, seed }: AccountHookParams = {}) => {
17
17
  const [contextAccount] = useAccountFromContext(!account && required)
18
- const [activeAccount] = usePromise(
19
- async () => (account ?? mnemonic ? await HDWallet.fromMnemonic(mnemonic as string) : seed ? await HDWallet.fromSeed(seed) : contextAccount),
20
- [account, mnemonic, contextAccount, seed],
21
- )
18
+ const [activeAccount] = usePromise(async () => {
19
+ if (account) {
20
+ return account
21
+ } else if (mnemonic) {
22
+ return await HDWallet.fromMnemonic(mnemonic as string)
23
+ } else if (seed) {
24
+ return await HDWallet.fromSeed(seed)
25
+ }
26
+ return contextAccount
27
+ }, [account, mnemonic, contextAccount, seed])
22
28
  return usePromise(async () => (path ? await activeAccount?.derivePath?.(path) : activeAccount))
23
29
  }