@txnlab/use-wallet 2.6.0 → 2.6.2

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.
@@ -15,7 +15,7 @@ declare class MagicAuth extends BaseClient {
15
15
  icon: string;
16
16
  isWalletConnect: boolean;
17
17
  };
18
- static init({ clientOptions, algodOptions, clientStatic, getDynamicClient, algosdkStatic, network }: InitParams<PROVIDER_ID.MAGIC>): Promise<BaseClient | null>;
18
+ static init({ clientOptions, algodOptions, clientStatic, getDynamicClient, extensionStatic, getDynamicExtension, algosdkStatic, network }: InitParams<PROVIDER_ID.MAGIC>): Promise<BaseClient | null>;
19
19
  connect(_: () => void, arg?: any): Promise<Wallet>;
20
20
  reconnect(): Promise<{
21
21
  accounts: {
@@ -1,8 +1,8 @@
1
+ import type { AlgorandExtension } from '@magic-ext/algorand';
2
+ import type { SDKBase, InstanceWithExtensions } from '@magic-sdk/provider';
1
3
  import type algosdk from 'algosdk';
2
4
  import type { Network } from '../../types/node';
3
5
  import type { Metadata } from '../../types/wallet';
4
- import { SDKBase, InstanceWithExtensions } from '@magic-sdk/provider';
5
- import { AlgorandExtension } from '@magic-ext/algorand';
6
6
  export type MagicAuthConnectOptions = {
7
7
  apiKey: string;
8
8
  };
@@ -3,6 +3,8 @@ import type { PeraWalletConnect } from '@perawallet/connect';
3
3
  import type { DeflyWalletConnect } from '@blockshake/defly-connect';
4
4
  import type { DaffiWalletConnect } from '@daffiwallet/connect';
5
5
  import type LuteConnect from 'lute-connect';
6
+ import type { Magic } from 'magic-sdk';
7
+ import type { AlgorandExtension } from '@magic-ext/algorand';
6
8
  import type MyAlgoConnect from '@randlabs/myalgo-connect';
7
9
  import type { WalletConnectModalSign, WalletConnectModalSignOptions } from '@walletconnect/modal-sign-html';
8
10
  import type algosdk from 'algosdk';
@@ -17,7 +19,6 @@ import type { DaffiWalletConnectOptions } from '../clients/daffi/types';
17
19
  import type { NonEmptyArray } from './utilities';
18
20
  import type BaseClient from '../clients/base';
19
21
  import type { CustomOptions } from '../clients/custom/types';
20
- import { Magic } from 'magic-sdk';
21
22
  export type ProviderConfigMapping = {
22
23
  [PROVIDER_ID.PERA]: {
23
24
  clientOptions?: PeraWalletConnectOptions;
@@ -85,6 +86,8 @@ export type ProviderConfigMapping = {
85
86
  };
86
87
  clientStatic?: undefined;
87
88
  getDynamicClient?: () => Promise<typeof Magic>;
89
+ extensionStatic?: typeof AlgorandExtension;
90
+ getDynamicExtension?: () => Promise<typeof AlgorandExtension>;
88
91
  };
89
92
  };
90
93
  /**
@@ -121,7 +124,16 @@ type DynamicClient<T> = {
121
124
  getDynamicClient: () => Promise<T>;
122
125
  };
123
126
  type OneOfStaticOrDynamicClient<T> = StaticClient<T> | DynamicClient<T>;
124
- type ProviderDef = (ProviderConfig<PROVIDER_ID.PERA> & OneOfStaticOrDynamicClient<typeof PeraWalletConnect>) | (ProviderConfig<PROVIDER_ID.MAGIC> & OneOfStaticOrDynamicClient<typeof Magic> & {
127
+ type StaticAlgoExtension<T> = {
128
+ extensionStatic: T;
129
+ getDynamicExtension?: undefined;
130
+ };
131
+ type DynamicAlgoExtension<T> = {
132
+ extensionStatic?: undefined;
133
+ getDynamicExtension: () => Promise<T>;
134
+ };
135
+ type OneOfStaticOrDynamicAlgoExtension<T> = StaticAlgoExtension<T> | DynamicAlgoExtension<T>;
136
+ type ProviderDef = (ProviderConfig<PROVIDER_ID.PERA> & OneOfStaticOrDynamicClient<typeof PeraWalletConnect>) | (ProviderConfig<PROVIDER_ID.MAGIC> & OneOfStaticOrDynamicClient<typeof Magic> & OneOfStaticOrDynamicAlgoExtension<typeof AlgorandExtension> & {
125
137
  clientOptions: {
126
138
  apiKey: string;
127
139
  };
package/dist/esm/index.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import require$$0, { useDebugValue, useState, useEffect, createContext, useContext, useMemo } from 'react';
2
- import { AlgorandExtension } from '@magic-ext/algorand';
3
2
  import { Buffer as Buffer$1 } from 'buffer';
4
3
 
5
4
  var PROVIDER_ID;
@@ -2637,7 +2636,7 @@ class MagicAuth extends BaseClient {
2637
2636
  icon: ICON$4,
2638
2637
  isWalletConnect: true
2639
2638
  };
2640
- static async init({ clientOptions, algodOptions, clientStatic, getDynamicClient, algosdkStatic, network = DEFAULT_NETWORK }) {
2639
+ static async init({ clientOptions, algodOptions, clientStatic, getDynamicClient, extensionStatic, getDynamicExtension, algosdkStatic, network = DEFAULT_NETWORK }) {
2641
2640
  try {
2642
2641
  debugLog(`${PROVIDER_ID.MAGIC.toUpperCase()} initializing...`);
2643
2642
  let Magic;
@@ -2647,12 +2646,22 @@ class MagicAuth extends BaseClient {
2647
2646
  else if (getDynamicClient) {
2648
2647
  Magic = await getDynamicClient();
2649
2648
  }
2650
- else if (!clientOptions || !clientOptions.apiKey) {
2651
- throw new Error('Magic provider missing API Key to be passed by required property: clientOptions');
2652
- }
2653
2649
  else {
2654
2650
  throw new Error('Magic provider missing required property: clientStatic or getDynamicClient');
2655
2651
  }
2652
+ let AlgorandExtension;
2653
+ if (extensionStatic) {
2654
+ AlgorandExtension = extensionStatic;
2655
+ }
2656
+ else if (getDynamicExtension) {
2657
+ AlgorandExtension = await getDynamicExtension();
2658
+ }
2659
+ else {
2660
+ throw new Error('Magic provider missing required property: extensionStatic or getDynamicExtension');
2661
+ }
2662
+ if (!clientOptions || !clientOptions.apiKey) {
2663
+ throw new Error('Magic provider missing API Key to be passed by required property: clientOptions');
2664
+ }
2656
2665
  const algosdk = algosdkStatic || (await Algod.init(algodOptions)).algosdk;
2657
2666
  const algodClient = getAlgodClient(algosdk, algodOptions);
2658
2667
  const magic = new Magic(clientOptions?.apiKey, {
@@ -15,7 +15,7 @@ declare class MagicAuth extends BaseClient {
15
15
  icon: string;
16
16
  isWalletConnect: boolean;
17
17
  };
18
- static init({ clientOptions, algodOptions, clientStatic, getDynamicClient, algosdkStatic, network }: InitParams<PROVIDER_ID.MAGIC>): Promise<BaseClient | null>;
18
+ static init({ clientOptions, algodOptions, clientStatic, getDynamicClient, extensionStatic, getDynamicExtension, algosdkStatic, network }: InitParams<PROVIDER_ID.MAGIC>): Promise<BaseClient | null>;
19
19
  connect(_: () => void, arg?: any): Promise<Wallet>;
20
20
  reconnect(): Promise<{
21
21
  accounts: {
@@ -1,8 +1,8 @@
1
+ import type { AlgorandExtension } from '@magic-ext/algorand';
2
+ import type { SDKBase, InstanceWithExtensions } from '@magic-sdk/provider';
1
3
  import type algosdk from 'algosdk';
2
4
  import type { Network } from '../../types/node';
3
5
  import type { Metadata } from '../../types/wallet';
4
- import { SDKBase, InstanceWithExtensions } from '@magic-sdk/provider';
5
- import { AlgorandExtension } from '@magic-ext/algorand';
6
6
  export type MagicAuthConnectOptions = {
7
7
  apiKey: string;
8
8
  };
@@ -3,6 +3,8 @@ import type { PeraWalletConnect } from '@perawallet/connect';
3
3
  import type { DeflyWalletConnect } from '@blockshake/defly-connect';
4
4
  import type { DaffiWalletConnect } from '@daffiwallet/connect';
5
5
  import type LuteConnect from 'lute-connect';
6
+ import type { Magic } from 'magic-sdk';
7
+ import type { AlgorandExtension } from '@magic-ext/algorand';
6
8
  import type MyAlgoConnect from '@randlabs/myalgo-connect';
7
9
  import type { WalletConnectModalSign, WalletConnectModalSignOptions } from '@walletconnect/modal-sign-html';
8
10
  import type algosdk from 'algosdk';
@@ -17,7 +19,6 @@ import type { DaffiWalletConnectOptions } from '../clients/daffi/types';
17
19
  import type { NonEmptyArray } from './utilities';
18
20
  import type BaseClient from '../clients/base';
19
21
  import type { CustomOptions } from '../clients/custom/types';
20
- import { Magic } from 'magic-sdk';
21
22
  export type ProviderConfigMapping = {
22
23
  [PROVIDER_ID.PERA]: {
23
24
  clientOptions?: PeraWalletConnectOptions;
@@ -85,6 +86,8 @@ export type ProviderConfigMapping = {
85
86
  };
86
87
  clientStatic?: undefined;
87
88
  getDynamicClient?: () => Promise<typeof Magic>;
89
+ extensionStatic?: typeof AlgorandExtension;
90
+ getDynamicExtension?: () => Promise<typeof AlgorandExtension>;
88
91
  };
89
92
  };
90
93
  /**
@@ -121,7 +124,16 @@ type DynamicClient<T> = {
121
124
  getDynamicClient: () => Promise<T>;
122
125
  };
123
126
  type OneOfStaticOrDynamicClient<T> = StaticClient<T> | DynamicClient<T>;
124
- type ProviderDef = (ProviderConfig<PROVIDER_ID.PERA> & OneOfStaticOrDynamicClient<typeof PeraWalletConnect>) | (ProviderConfig<PROVIDER_ID.MAGIC> & OneOfStaticOrDynamicClient<typeof Magic> & {
127
+ type StaticAlgoExtension<T> = {
128
+ extensionStatic: T;
129
+ getDynamicExtension?: undefined;
130
+ };
131
+ type DynamicAlgoExtension<T> = {
132
+ extensionStatic?: undefined;
133
+ getDynamicExtension: () => Promise<T>;
134
+ };
135
+ type OneOfStaticOrDynamicAlgoExtension<T> = StaticAlgoExtension<T> | DynamicAlgoExtension<T>;
136
+ type ProviderDef = (ProviderConfig<PROVIDER_ID.PERA> & OneOfStaticOrDynamicClient<typeof PeraWalletConnect>) | (ProviderConfig<PROVIDER_ID.MAGIC> & OneOfStaticOrDynamicClient<typeof Magic> & OneOfStaticOrDynamicAlgoExtension<typeof AlgorandExtension> & {
125
137
  clientOptions: {
126
138
  apiKey: string;
127
139
  };
package/dist/index.d.ts CHANGED
@@ -3,15 +3,15 @@ import { PeraWalletConnect } from '@perawallet/connect';
3
3
  import { DeflyWalletConnect } from '@blockshake/defly-connect';
4
4
  import { DaffiWalletConnect } from '@daffiwallet/connect';
5
5
  import LuteConnect from 'lute-connect';
6
+ import { Magic } from 'magic-sdk';
7
+ import { AlgorandExtension } from '@magic-ext/algorand';
6
8
  import MyAlgoConnect from '@randlabs/myalgo-connect';
7
9
  import { WalletConnectModalSignOptions, WalletConnectModalSign } from '@walletconnect/modal-sign-html';
8
- import { Magic } from 'magic-sdk';
9
10
  import React from 'react';
10
11
  import * as zustand_middleware from 'zustand/middleware';
11
12
  import * as immer_dist_internal from 'immer/dist/internal';
12
13
  import * as zustand from 'zustand';
13
14
  import { InstanceWithExtensions, SDKBase } from '@magic-sdk/provider';
14
- import { AlgorandExtension } from '@magic-ext/algorand';
15
15
 
16
16
  type PublicNetwork = 'betanet' | 'testnet' | 'mainnet';
17
17
  type Network = PublicNetwork | string;
@@ -391,6 +391,8 @@ type ProviderConfigMapping = {
391
391
  };
392
392
  clientStatic?: undefined;
393
393
  getDynamicClient?: () => Promise<typeof Magic>;
394
+ extensionStatic?: typeof AlgorandExtension;
395
+ getDynamicExtension?: () => Promise<typeof AlgorandExtension>;
394
396
  };
395
397
  };
396
398
  /**
@@ -427,7 +429,16 @@ type DynamicClient<T> = {
427
429
  getDynamicClient: () => Promise<T>;
428
430
  };
429
431
  type OneOfStaticOrDynamicClient<T> = StaticClient<T> | DynamicClient<T>;
430
- type ProviderDef = (ProviderConfig<PROVIDER_ID.PERA> & OneOfStaticOrDynamicClient<typeof PeraWalletConnect>) | (ProviderConfig<PROVIDER_ID.MAGIC> & OneOfStaticOrDynamicClient<typeof Magic> & {
432
+ type StaticAlgoExtension<T> = {
433
+ extensionStatic: T;
434
+ getDynamicExtension?: undefined;
435
+ };
436
+ type DynamicAlgoExtension<T> = {
437
+ extensionStatic?: undefined;
438
+ getDynamicExtension: () => Promise<T>;
439
+ };
440
+ type OneOfStaticOrDynamicAlgoExtension<T> = StaticAlgoExtension<T> | DynamicAlgoExtension<T>;
441
+ type ProviderDef = (ProviderConfig<PROVIDER_ID.PERA> & OneOfStaticOrDynamicClient<typeof PeraWalletConnect>) | (ProviderConfig<PROVIDER_ID.MAGIC> & OneOfStaticOrDynamicClient<typeof Magic> & OneOfStaticOrDynamicAlgoExtension<typeof AlgorandExtension> & {
431
442
  clientOptions: {
432
443
  apiKey: string;
433
444
  };
@@ -747,7 +758,7 @@ declare class MagicAuth extends BaseClient {
747
758
  icon: string;
748
759
  isWalletConnect: boolean;
749
760
  };
750
- static init({ clientOptions, algodOptions, clientStatic, getDynamicClient, algosdkStatic, network }: InitParams<PROVIDER_ID.MAGIC>): Promise<BaseClient | null>;
761
+ static init({ clientOptions, algodOptions, clientStatic, getDynamicClient, extensionStatic, getDynamicExtension, algosdkStatic, network }: InitParams<PROVIDER_ID.MAGIC>): Promise<BaseClient | null>;
751
762
  connect(_: () => void, arg?: any): Promise<Wallet>;
752
763
  reconnect(): Promise<{
753
764
  accounts: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@txnlab/use-wallet",
3
3
  "author": "TxnLab, Inc.",
4
- "version": "2.6.0",
4
+ "version": "2.6.2",
5
5
  "license": "MIT",
6
6
  "description": "React hooks for using Algorand compatible wallets in dApps.",
7
7
  "scripts": {
@@ -120,7 +120,7 @@
120
120
  "@magic-ext/algorand": {
121
121
  "optional": true
122
122
  },
123
- "@magic-sdk": {
123
+ "magic-sdk": {
124
124
  "optional": true
125
125
  },
126
126
  "@blockshake/defly-connect": {