@txnlab/use-wallet 2.1.2 → 2.2.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.
@@ -0,0 +1,18 @@
1
+ import BaseClient from '../base';
2
+ import { PROVIDER_ID } from '../../constants';
3
+ import type { Network } from '../../types/node';
4
+ import type { InitParams } from '../../types/providers';
5
+ import type { Metadata, Wallet } from '../../types/wallet';
6
+ import type { CustomProvider, CustomWalletClientConstructor } from './types';
7
+ declare class CustomWalletClient extends BaseClient {
8
+ network: Network;
9
+ providerProxy: CustomProvider;
10
+ static metadata: Metadata;
11
+ constructor({ providerProxy, metadata, algosdk, algodClient, network }: CustomWalletClientConstructor);
12
+ static init({ clientOptions, algodOptions, algosdkStatic, network }: InitParams<PROVIDER_ID.CUSTOM>): Promise<BaseClient | null>;
13
+ connect(): Promise<Wallet>;
14
+ disconnect(): Promise<void>;
15
+ reconnect(): Promise<Wallet | null>;
16
+ signTransactions(connectedAccounts: string[], txnGroups: Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean): Promise<Uint8Array[]>;
17
+ }
18
+ export default CustomWalletClient;
@@ -0,0 +1 @@
1
+ export declare const ICON = "data:image/svg+xml,%3Csvg fill='%23000000' width='800px' height='800px' viewBox='0 0 24 24' id='wallet' data-name='Flat Line' xmlns='http://www.w3.org/2000/svg' class='icon flat-line'%3E%3Cpath id='secondary' d='M16,12h5V8H5A2,2,0,0,1,3,6V19a1,1,0,0,0,1,1H20a1,1,0,0,0,1-1V16H16a1,1,0,0,1-1-1V13A1,1,0,0,1,16,12Z' style='fill: rgb(44, 169, 188); stroke-width: 2;'%3E%3C/path%3E%3Cpath id='primary' d='M19,4H5A2,2,0,0,0,3,6H3A2,2,0,0,0,5,8H21' style='fill: none; stroke: rgb(0, 0, 0); stroke-linecap: round; stroke-linejoin: round; stroke-width: 2;'%3E%3C/path%3E%3Cpath id='primary-2' data-name='primary' d='M21,8V19a1,1,0,0,1-1,1H4a1,1,0,0,1-1-1V6A2,2,0,0,0,5,8Zm0,4H16a1,1,0,0,0-1,1v2a1,1,0,0,0,1,1h5Z' style='fill: none; stroke: rgb(0, 0, 0); stroke-linecap: round; stroke-linejoin: round; stroke-width: 2;'%3E%3C/path%3E%3C/svg%3E";
@@ -0,0 +1,2 @@
1
+ import custom from './client';
2
+ export default custom;
@@ -0,0 +1,25 @@
1
+ import type algosdk from 'algosdk';
2
+ import type { Network } from '../../types/node';
3
+ import type { Metadata, Wallet } from '../../types/wallet';
4
+ export type CustomOptions = {
5
+ name: string;
6
+ icon?: string;
7
+ getProvider: (params: {
8
+ network?: Network;
9
+ algod?: algosdk.Algodv2;
10
+ algosdkStatic?: typeof algosdk;
11
+ }) => CustomProvider;
12
+ };
13
+ export type CustomProvider = {
14
+ connect(metadata: Metadata): Promise<Wallet>;
15
+ disconnect(): Promise<void>;
16
+ reconnect(metadata: Metadata): Promise<Wallet | null>;
17
+ signTransactions(connectedAccounts: string[], txnGroups: Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean): Promise<Uint8Array[]>;
18
+ };
19
+ export type CustomWalletClientConstructor = {
20
+ providerProxy: CustomProvider;
21
+ metadata: Metadata;
22
+ algosdk: typeof algosdk;
23
+ algodClient: algosdk.Algodv2;
24
+ network: Network;
25
+ };
@@ -7,8 +7,10 @@ import algosigner from './algosigner';
7
7
  import walletconnect from './walletconnect2';
8
8
  import kmd from './kmd';
9
9
  import mnemonic from './mnemonic';
10
- export { pera, myalgo, defly, exodus, algosigner, walletconnect, kmd, mnemonic };
10
+ import { CustomProvider } from './custom/types';
11
+ import custom from './custom';
12
+ export { pera, myalgo, defly, exodus, algosigner, walletconnect, kmd, mnemonic, custom, CustomProvider };
11
13
  declare const _default: {
12
- [x: string]: typeof pera | typeof myalgo | typeof defly | typeof exodus | typeof algosigner | typeof walletconnect | typeof kmd | typeof mnemonic | typeof daffi;
14
+ [x: string]: typeof pera | typeof myalgo | typeof defly | typeof exodus | typeof algosigner | typeof walletconnect | typeof kmd | typeof mnemonic | typeof custom | typeof daffi;
13
15
  };
14
16
  export default _default;
@@ -1,6 +1,7 @@
1
1
  import { Network } from '../types/node';
2
2
  export declare enum PROVIDER_ID {
3
3
  KMD = "kmd",
4
+ CUSTOM = "custom",
4
5
  PERA = "pera",
5
6
  DAFFI = "daffi",
6
7
  MYALGO = "myalgo",
@@ -9,8 +9,10 @@ import PeraWalletClient from '../clients/pera/client';
9
9
  import WalletConnectClient from '../clients/walletconnect2/client';
10
10
  import { PROVIDER_ID } from '../constants';
11
11
  import type { Account, ClientOptions } from '../types';
12
+ import CustomWalletClient from '../clients/custom/client';
12
13
  type ClientTypeMap = {
13
14
  [PROVIDER_ID.ALGOSIGNER]: AlgoSignerClient;
15
+ [PROVIDER_ID.CUSTOM]: CustomWalletClient;
14
16
  [PROVIDER_ID.DAFFI]: DaffiWalletClient;
15
17
  [PROVIDER_ID.DEFLY]: DeflyWalletClient;
16
18
  [PROVIDER_ID.EXODUS]: ExodusClient;
@@ -26,6 +28,7 @@ export declare const createDaffiMockInstance: (clientOptions?: ClientOptions, ac
26
28
  export declare const createDeflyMockInstance: (clientOptions?: ClientOptions, accounts?: Array<Account>) => DeflyWalletClient;
27
29
  export declare const createExodusMockInstance: (clientOptions?: ClientOptions, accounts?: Array<Account>) => ExodusClient;
28
30
  export declare const createKmdMockInstance: (clientOptions?: ClientOptions, accounts?: Array<Account>) => KMDWalletClient;
31
+ export declare const createCustomMockInstance: (clientOptions?: ClientOptions, accounts?: Array<Account>) => CustomWalletClient;
29
32
  export declare const createMnemonicMockInstance: (clientOptions?: ClientOptions, accounts?: Array<Account>) => MnemonicWalletClient;
30
33
  export declare const createMyAlgoMockInstance: (clientOptions?: ClientOptions, accounts?: Array<Account>) => MyAlgoWalletClient;
31
34
  export declare const createPeraMockInstance: (clientOptions?: ClientOptions, accounts?: Array<Account>) => PeraWalletClient;
@@ -14,6 +14,7 @@ import type { MyAlgoConnectOptions } from '../clients/myalgo/types';
14
14
  import type { DaffiWalletConnectOptions } from '../clients/daffi/types';
15
15
  import type { NonEmptyArray } from './utilities';
16
16
  import type BaseClient from '../clients/base';
17
+ import type { CustomOptions } from '../clients/custom/types';
17
18
  export type ProviderConfigMapping = {
18
19
  [PROVIDER_ID.PERA]: {
19
20
  clientOptions?: PeraWalletConnectOptions;
@@ -50,6 +51,11 @@ export type ProviderConfigMapping = {
50
51
  clientStatic?: undefined;
51
52
  getDynamicClient?: undefined;
52
53
  };
54
+ [PROVIDER_ID.CUSTOM]: {
55
+ clientOptions?: CustomOptions;
56
+ clientStatic?: undefined;
57
+ getDynamicClient?: undefined;
58
+ };
53
59
  [PROVIDER_ID.ALGOSIGNER]: {
54
60
  clientOptions?: undefined;
55
61
  clientStatic?: undefined;
@@ -97,7 +103,7 @@ type DynamicClient<T> = {
97
103
  type OneOfStaticOrDynamicClient<T> = StaticClient<T> | DynamicClient<T>;
98
104
  type ProviderDef = (ProviderConfig<PROVIDER_ID.PERA> & OneOfStaticOrDynamicClient<typeof PeraWalletConnect>) | (ProviderConfig<PROVIDER_ID.DEFLY> & OneOfStaticOrDynamicClient<typeof DeflyWalletConnect>) | (ProviderConfig<PROVIDER_ID.DAFFI> & OneOfStaticOrDynamicClient<typeof DaffiWalletConnect>) | (ProviderConfig<PROVIDER_ID.WALLETCONNECT> & OneOfStaticOrDynamicClient<typeof WalletConnectModalSign> & {
99
105
  clientOptions: WalletConnectModalSignOptions;
100
- }) | (ProviderConfig<PROVIDER_ID.MYALGO> & OneOfStaticOrDynamicClient<typeof MyAlgoConnect>) | ProviderConfig<PROVIDER_ID.EXODUS> | ProviderConfig<PROVIDER_ID.KMD> | PROVIDER_ID.EXODUS | PROVIDER_ID.KMD | PROVIDER_ID.ALGOSIGNER | PROVIDER_ID.MNEMONIC;
106
+ }) | (ProviderConfig<PROVIDER_ID.MYALGO> & OneOfStaticOrDynamicClient<typeof MyAlgoConnect>) | ProviderConfig<PROVIDER_ID.EXODUS> | ProviderConfig<PROVIDER_ID.KMD> | ProviderConfig<PROVIDER_ID.CUSTOM> | PROVIDER_ID.EXODUS | PROVIDER_ID.KMD | PROVIDER_ID.ALGOSIGNER | PROVIDER_ID.MNEMONIC | PROVIDER_ID.CUSTOM;
101
107
  export type ProvidersArray = NonEmptyArray<ProviderDef>;
102
108
  export type WalletClient = BaseClient;
103
109
  export type SupportedProviders = Partial<Record<PROVIDER_ID, WalletClient | null>>;