@txnlab/use-wallet 2.3.1 → 2.5.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.
Files changed (32) hide show
  1. package/README.md +50 -6
  2. package/dist/cjs/index.js +543 -57
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/cjs/src/clients/index.d.ts +4 -2
  5. package/dist/cjs/src/clients/kibisis/client.d.ts +73 -0
  6. package/dist/cjs/src/clients/kibisis/constants.d.ts +37 -0
  7. package/dist/cjs/src/clients/kibisis/index.d.ts +2 -0
  8. package/dist/cjs/src/clients/kibisis/types.d.ts +86 -0
  9. package/dist/cjs/src/clients/lute/client.d.ts +34 -0
  10. package/dist/cjs/src/clients/lute/constants.d.ts +1 -0
  11. package/dist/cjs/src/clients/lute/index.d.ts +2 -0
  12. package/dist/cjs/src/clients/lute/types.d.ts +15 -0
  13. package/dist/cjs/src/constants/constants.d.ts +2 -0
  14. package/dist/cjs/src/store/state/walletStore.d.ts +2 -2
  15. package/dist/cjs/src/testUtils/mockClients.d.ts +6 -0
  16. package/dist/cjs/src/types/providers.d.ts +16 -2
  17. package/dist/esm/index.js +542 -58
  18. package/dist/esm/src/clients/index.d.ts +4 -2
  19. package/dist/esm/src/clients/kibisis/client.d.ts +73 -0
  20. package/dist/esm/src/clients/kibisis/constants.d.ts +37 -0
  21. package/dist/esm/src/clients/kibisis/index.d.ts +2 -0
  22. package/dist/esm/src/clients/kibisis/types.d.ts +86 -0
  23. package/dist/esm/src/clients/lute/client.d.ts +34 -0
  24. package/dist/esm/src/clients/lute/constants.d.ts +1 -0
  25. package/dist/esm/src/clients/lute/index.d.ts +2 -0
  26. package/dist/esm/src/clients/lute/types.d.ts +15 -0
  27. package/dist/esm/src/constants/constants.d.ts +2 -0
  28. package/dist/esm/src/store/state/walletStore.d.ts +2 -2
  29. package/dist/esm/src/testUtils/mockClients.d.ts +6 -0
  30. package/dist/esm/src/types/providers.d.ts +16 -2
  31. package/dist/index.d.ts +149 -4
  32. package/package.json +31 -37
@@ -4,13 +4,15 @@ import myalgo from './myalgo';
4
4
  import defly from './defly';
5
5
  import exodus from './exodus';
6
6
  import algosigner from './algosigner';
7
+ import lute from './lute';
7
8
  import walletconnect from './walletconnect2';
8
9
  import kmd from './kmd';
9
10
  import mnemonic from './mnemonic';
10
11
  import { CustomProvider } from './custom/types';
11
12
  import custom from './custom';
12
- export { pera, myalgo, defly, exodus, algosigner, walletconnect, kmd, mnemonic, custom, CustomProvider };
13
+ import kibisis from './kibisis';
14
+ export { pera, myalgo, defly, exodus, algosigner, lute, walletconnect, kmd, mnemonic, custom, CustomProvider, kibisis };
13
15
  declare const _default: {
14
- [x: string]: typeof pera | typeof myalgo | typeof defly | typeof exodus | typeof algosigner | typeof walletconnect | typeof kmd | typeof mnemonic | typeof custom | typeof daffi;
16
+ [x: string]: typeof pera | typeof myalgo | typeof defly | typeof exodus | typeof algosigner | typeof lute | typeof walletconnect | typeof kmd | typeof mnemonic | typeof custom | typeof kibisis | typeof daffi;
15
17
  };
16
18
  export default _default;
@@ -0,0 +1,73 @@
1
+ import BaseClient from '../base';
2
+ import { PROVIDER_ID } from '../../constants';
3
+ import type { InitParams, Network, Wallet } from '../../types';
4
+ import type { Arc0027Account, KibisisClientConstructor, ProviderMethods, SendRequestWithTimeoutOptions } from './types';
5
+ declare class KibisisClient extends BaseClient {
6
+ genesisHash: string;
7
+ methods: ProviderMethods[];
8
+ network: Network;
9
+ constructor({ metadata, algosdk, algodClient, genesisHash, methods, network }: KibisisClientConstructor);
10
+ static metadata: {
11
+ id: PROVIDER_ID;
12
+ icon: string;
13
+ isWalletConnect: boolean;
14
+ name: string;
15
+ };
16
+ /**
17
+ * public static functions
18
+ */
19
+ static init({ algodOptions, algosdkStatic, network }: InitParams<PROVIDER_ID.KIBISIS>): Promise<BaseClient | null>;
20
+ static mapAccountsToWallet(accounts: Arc0027Account[]): Wallet;
21
+ static sendRequestWithTimeout<Params, Result>({ method, params, timeout, reference }: SendRequestWithTimeoutOptions<Params>): Promise<Result | undefined>;
22
+ /**
23
+ * private functions
24
+ */
25
+ private convertBytesToBase64;
26
+ private convertBase64ToBytes;
27
+ /**
28
+ * Calls the enable method on the provider that returns the authorized accounts.
29
+ * @returns {Arc0027Account[]} the authorized accounts.
30
+ * @throws {METHOD_CANCELED_ERROR} if the method was cancelled by the user.
31
+ * @throws {METHOD_NOT_SUPPORTED_ERROR} if the method is not supported for the configured network.
32
+ * @throws {METHOD_TIMED_OUT_ERROR} if the method timed out by lack of response.
33
+ * @throws {NETWORK_NOT_SUPPORTED_ERROR} if the network is not supported for the configured network.
34
+ * @throws {UNKNOWN_ERROR} if the response result was empty.
35
+ */
36
+ private enable;
37
+ /**
38
+ * Convenience function that gets the provider information and updates the supported methods. This should be called
39
+ * before interacting with the provider to ensure methods are supported.
40
+ * @throws {METHOD_TIMED_OUT_ERROR} if the method timed out by lack of response.
41
+ * @throws {NETWORK_NOT_SUPPORTED_ERROR} if the network is not supported for the configured network.
42
+ * @throws {UNKNOWN_ERROR} if the response result was empty.
43
+ */
44
+ private refreshSupportedMethods;
45
+ /**
46
+ * Calls the signTxns methods to sign the supplied transactions.
47
+ * @param {Arc0001SignTxns[]} txns - the unsigned or signed transactions as defined in ARC-0001.
48
+ * @returns {(string | null)[]} the authorized accounts.
49
+ * @throws {INVALID_INPUT_ERROR} if computed group ID for the txns does not match the assigned group ID.
50
+ * @throws {INVALID_GROUP_ID_ERROR} if the unsigned txns is malformed or not conforming to ARC-0001.
51
+ * @throws {METHOD_CANCELED_ERROR} if the method was cancelled by the user.
52
+ * @throws {METHOD_NOT_SUPPORTED_ERROR} if the method is not supported for the configured network.
53
+ * @throws {METHOD_TIMED_OUT_ERROR} if the method timed out by lack of response.
54
+ * @throws {NETWORK_NOT_SUPPORTED_ERROR} if the network is not supported for the configured network.
55
+ * @throws {UNAUTHORIZED_SIGNER_ERROR} if a signer in the request is not authorized by the provider.
56
+ * @throws {UNKNOWN_ERROR} if the response result was empty.
57
+ */
58
+ private signTxns;
59
+ /**
60
+ * Validates whether a method is supported with the provider.
61
+ * @param {ProviderMethods} method - the method to validate.
62
+ * @throws {METHOD_NOT_SUPPORTED_ERROR} if the method is not supported for the configured network.
63
+ */
64
+ private validateMethod;
65
+ /**
66
+ * public functions
67
+ */
68
+ connect(): Promise<Wallet>;
69
+ disconnect(): Promise<void>;
70
+ reconnect(): Promise<Wallet | null>;
71
+ signTransactions(connectedAccounts: string[], transactions: Uint8Array[], indexesToSign?: number[], returnGroup?: boolean): Promise<Uint8Array[]>;
72
+ }
73
+ export default KibisisClient;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * arc-0027
3
+ */
4
+ export declare const ARC_0027_PREFIX = "arc0027";
5
+ export declare const ARC_0027_CHANNEL_NAME: string;
6
+ export declare const ARC_0027_ENABLE_REQUEST: string;
7
+ export declare const ARC_0027_GET_PROVIDERS_REQUEST: string;
8
+ export declare const ARC_0027_PROVIDER_ID = "f6d1c86b-4493-42fb-b88d-a62407b4cdf6";
9
+ export declare const ARC_0027_SIGN_TXNS_REQUEST: string;
10
+ /**
11
+ * errors
12
+ */
13
+ export declare const UNKNOWN_ERROR = 4000;
14
+ export declare const METHOD_CANCELED_ERROR = 4001;
15
+ export declare const METHOD_TIMED_OUT_ERROR = 4002;
16
+ export declare const METHOD_NOT_SUPPORTED_ERROR = 4003;
17
+ export declare const NETWORK_NOT_SUPPORTED_ERROR = 4004;
18
+ export declare const UNAUTHORIZED_SIGNER_ERROR = 4100;
19
+ export declare const INVALID_INPUT_ERROR = 4200;
20
+ export declare const INVALID_GROUP_ID_ERROR = 4201;
21
+ /**
22
+ * genesis hashes
23
+ */
24
+ export declare const ALGORAND_BETANET_GENESIS_HASH = "mFgazF+2uRS1tMiL9dsj01hJGySEmPN28B/TjjvpVW0=";
25
+ export declare const ALGORAND_MAINNET_GENESIS_HASH = "wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8=";
26
+ export declare const ALGORAND_TESTNET_GENESIS_HASH = "SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=";
27
+ export declare const VOI_TESTNET_GENESIS_HASH = "IXnoWtviVVJW5LGivNFc0Dq14V3kqaXuK2u5OQrdVZo=";
28
+ /**
29
+ * timeouts
30
+ */
31
+ export declare const DEFAULT_REQUEST_TIMEOUT = 180000;
32
+ export declare const LOWER_REQUEST_TIMEOUT = 3000;
33
+ export declare const UPPER_REQUEST_TIMEOUT = 300000;
34
+ /**
35
+ * icon
36
+ */
37
+ export declare const ICON: string;
@@ -0,0 +1,2 @@
1
+ import kibisis from './client';
2
+ export default kibisis;
@@ -0,0 +1,86 @@
1
+ import type algosdk from 'algosdk';
2
+ import type { Metadata, Network } from '../../types';
3
+ export interface Arc0001SignTxns {
4
+ authAddr?: string;
5
+ multisig?: string;
6
+ signers?: string[];
7
+ stxn?: string;
8
+ txn: string;
9
+ }
10
+ export interface Arc0027Account {
11
+ address: string;
12
+ name?: string;
13
+ }
14
+ export interface KibisisClientConstructor {
15
+ metadata: Metadata;
16
+ algosdk: typeof algosdk;
17
+ algodClient: algosdk.Algodv2;
18
+ genesisHash: string;
19
+ methods: ProviderMethods[];
20
+ network: Network;
21
+ }
22
+ export interface NetworkConfiguration {
23
+ genesisHash: string;
24
+ genesisId: string;
25
+ methods: ProviderMethods[];
26
+ }
27
+ export type ProviderMethods = 'enable' | 'getProviders' | 'postTxns' | 'signAndPostTxns' | 'signBytes' | 'signTxns';
28
+ export interface SendRequestWithTimeoutOptions<Params> {
29
+ method: ProviderMethods;
30
+ params: Params;
31
+ reference: string;
32
+ timeout?: number;
33
+ }
34
+ /**
35
+ * message schema
36
+ */
37
+ export interface RequestMessage<Params> {
38
+ id: string;
39
+ params: Params;
40
+ reference: string;
41
+ }
42
+ export interface ResponseMessage<Result = undefined, ErrorData = undefined> {
43
+ error?: ResponseError<ErrorData>;
44
+ id: string;
45
+ reference: string;
46
+ requestId: string;
47
+ result?: Result;
48
+ }
49
+ export interface ResponseError<Data = undefined> {
50
+ code: number;
51
+ data: Data;
52
+ message: string;
53
+ providerId: string;
54
+ }
55
+ /**
56
+ * message payloads
57
+ */
58
+ export interface EnableParams {
59
+ genesisHash: string;
60
+ providerId: string;
61
+ }
62
+ export interface EnableResult {
63
+ accounts: Arc0027Account[];
64
+ genesisHash: string;
65
+ genesisId: string;
66
+ providerId: string;
67
+ sessionId?: string;
68
+ }
69
+ export interface GetProvidersParams {
70
+ providerId: string;
71
+ }
72
+ export interface GetProvidersResult {
73
+ host: string;
74
+ icon: string;
75
+ name: string;
76
+ networks: NetworkConfiguration[];
77
+ providerId: string;
78
+ }
79
+ export interface SignTxnsParams {
80
+ providerId: string;
81
+ txns: Arc0001SignTxns[];
82
+ }
83
+ export interface SignTxnsResult {
84
+ providerId: string;
85
+ stxns: (string | null)[];
86
+ }
@@ -0,0 +1,34 @@
1
+ import { PROVIDER_ID } from '../../constants';
2
+ import { DecodedSignedTransaction, DecodedTransaction, Network } from '../../types/node';
3
+ import type { InitParams } from '../../types/providers';
4
+ import BaseClient from '../base';
5
+ import type { LuteClientConstructor, LuteConnectOptions } from './types';
6
+ declare class LuteClient extends BaseClient {
7
+ #private;
8
+ clientOptions?: LuteConnectOptions;
9
+ network: Network;
10
+ constructor({ metadata, client, clientOptions, algosdk, algodClient, network }: LuteClientConstructor);
11
+ static metadata: {
12
+ id: PROVIDER_ID;
13
+ name: string;
14
+ icon: string;
15
+ isWalletConnect: boolean;
16
+ };
17
+ static init({ clientOptions, algodOptions, clientStatic, getDynamicClient, algosdkStatic, network }: InitParams<PROVIDER_ID.LUTE>): Promise<BaseClient | null>;
18
+ connect(): Promise<{
19
+ accounts: {
20
+ name: string;
21
+ address: string;
22
+ providerId: PROVIDER_ID;
23
+ }[];
24
+ id: PROVIDER_ID;
25
+ name: string;
26
+ icon: string;
27
+ isWalletConnect: boolean;
28
+ }>;
29
+ reconnect(): Promise<null>;
30
+ disconnect(): Promise<void>;
31
+ shouldSignTxnObject(txn: DecodedTransaction | DecodedSignedTransaction, addresses: string[], indexesToSign: number[] | undefined, idx: number): boolean;
32
+ signTransactions(connectedAccounts: string[], transactions: Uint8Array[], indexesToSign?: number[], returnGroup?: boolean): Promise<Uint8Array[]>;
33
+ }
34
+ export default LuteClient;
@@ -0,0 +1 @@
1
+ export declare const ICON: string;
@@ -0,0 +1,2 @@
1
+ import lute from './client';
2
+ export default lute;
@@ -0,0 +1,15 @@
1
+ import type algosdk from 'algosdk';
2
+ import type { Network } from '../../types/node';
3
+ import type { Metadata } from '../../types/wallet';
4
+ import type LuteConnect from 'lute-connect';
5
+ export type LuteConnectOptions = {
6
+ siteName: string;
7
+ };
8
+ export type LuteClientConstructor = {
9
+ metadata: Metadata;
10
+ client: LuteConnect;
11
+ clientOptions?: LuteConnectOptions;
12
+ algosdk: typeof algosdk;
13
+ algodClient: algosdk.Algodv2;
14
+ network: Network;
15
+ };
@@ -4,10 +4,12 @@ export declare enum PROVIDER_ID {
4
4
  CUSTOM = "custom",
5
5
  PERA = "pera",
6
6
  DAFFI = "daffi",
7
+ LUTE = "lute",
7
8
  MYALGO = "myalgo",
8
9
  ALGOSIGNER = "algosigner",
9
10
  DEFLY = "defly",
10
11
  EXODUS = "exodus",
12
+ KIBISIS = "kibisis",
11
13
  WALLETCONNECT = "walletconnect",
12
14
  MNEMONIC = "mnemonic"
13
15
  }
@@ -30,7 +30,7 @@ export declare const useWalletStore: import("zustand").UseBoundStore<Omit<Omit<O
30
30
  };
31
31
  }, "setState"> & {
32
32
  setState<A extends string | {
33
- type: unknown;
33
+ type: string;
34
34
  }>(nextStateOrUpdater: WalletStore | Partial<WalletStore> | ((state: import("immer/dist/internal").WritableDraft<WalletStore>) => void), shouldReplace?: boolean | undefined, action?: A | undefined): void;
35
35
  }>;
36
36
  export declare const useHydratedWalletStore: import("zustand").UseBoundStore<Omit<Omit<Omit<import("zustand").StoreApi<WalletStore>, "setState"> & {
@@ -47,6 +47,6 @@ export declare const useHydratedWalletStore: import("zustand").UseBoundStore<Omi
47
47
  };
48
48
  }, "setState"> & {
49
49
  setState<A extends string | {
50
- type: unknown;
50
+ type: string;
51
51
  }>(nextStateOrUpdater: WalletStore | Partial<WalletStore> | ((state: import("immer/dist/internal").WritableDraft<WalletStore>) => void), shouldReplace?: boolean | undefined, action?: A | undefined): void;
52
52
  }>;
@@ -2,6 +2,8 @@ import AlgoSignerClient from '../clients/algosigner/client';
2
2
  import DaffiWalletClient from '../clients/daffi/client';
3
3
  import DeflyWalletClient from '../clients/defly/client';
4
4
  import ExodusClient from '../clients/exodus/client';
5
+ import LuteClient from '../clients/lute/client';
6
+ import KibisisClient from '../clients/kibisis/client';
5
7
  import KMDWalletClient from '../clients/kmd/client';
6
8
  import MnemonicWalletClient from '../clients/mnemonic/client';
7
9
  import MyAlgoWalletClient from '../clients/myalgo/client';
@@ -21,12 +23,16 @@ type ClientTypeMap = {
21
23
  [PROVIDER_ID.MYALGO]: MyAlgoWalletClient;
22
24
  [PROVIDER_ID.PERA]: PeraWalletClient;
23
25
  [PROVIDER_ID.WALLETCONNECT]: WalletConnectClient;
26
+ [PROVIDER_ID.LUTE]: LuteClient;
27
+ [PROVIDER_ID.KIBISIS]: KibisisClient;
24
28
  };
25
29
  export declare const createMockClient: <T extends PROVIDER_ID>(providerId: T, clientOptions?: ClientOptions, accounts?: Array<Account>) => ClientTypeMap[T];
26
30
  export declare const createAlgoSignerMockInstance: (clientOptions?: ClientOptions, accounts?: Array<Account>) => AlgoSignerClient;
27
31
  export declare const createDaffiMockInstance: (clientOptions?: ClientOptions, accounts?: Array<Account>) => DaffiWalletClient;
28
32
  export declare const createDeflyMockInstance: (clientOptions?: ClientOptions, accounts?: Array<Account>) => DeflyWalletClient;
29
33
  export declare const createExodusMockInstance: (clientOptions?: ClientOptions, accounts?: Array<Account>) => ExodusClient;
34
+ export declare const createLuteMockInstance: (clientOptions?: ClientOptions, accounts?: Array<Account>) => LuteClient;
35
+ export declare const createKibisisMockInstance: (clientOptions?: ClientOptions, accounts?: Array<Account>) => KibisisClient;
30
36
  export declare const createKmdMockInstance: (clientOptions?: ClientOptions, accounts?: Array<Account>) => KMDWalletClient;
31
37
  export declare const createCustomMockInstance: (clientOptions?: ClientOptions, accounts?: Array<Account>) => CustomWalletClient;
32
38
  export declare const createMnemonicMockInstance: (clientOptions?: ClientOptions, accounts?: Array<Account>) => MnemonicWalletClient;
@@ -2,6 +2,7 @@ import type { PROVIDER_ID } from '../constants';
2
2
  import type { PeraWalletConnect } from '@perawallet/connect';
3
3
  import type { DeflyWalletConnect } from '@blockshake/defly-connect';
4
4
  import type { DaffiWalletConnect } from '@daffiwallet/connect';
5
+ import type LuteConnect from 'lute-connect';
5
6
  import type MyAlgoConnect from '@randlabs/myalgo-connect';
6
7
  import type { WalletConnectModalSign, WalletConnectModalSignOptions } from '@walletconnect/modal-sign-html';
7
8
  import type algosdk from 'algosdk';
@@ -10,6 +11,7 @@ import type { PeraWalletConnectOptions } from '../clients/pera/types';
10
11
  import type { DeflyWalletConnectOptions } from '../clients/defly/types';
11
12
  import type { ExodusOptions } from '../clients/exodus/types';
12
13
  import type { KmdOptions } from '../clients/kmd/types';
14
+ import type { LuteConnectOptions } from '../clients/lute/types';
13
15
  import type { MyAlgoConnectOptions } from '../clients/myalgo/types';
14
16
  import type { DaffiWalletConnectOptions } from '../clients/daffi/types';
15
17
  import type { NonEmptyArray } from './utilities';
@@ -36,6 +38,11 @@ export type ProviderConfigMapping = {
36
38
  clientStatic?: typeof WalletConnectModalSign;
37
39
  getDynamicClient?: () => Promise<typeof WalletConnectModalSign>;
38
40
  };
41
+ [PROVIDER_ID.LUTE]: {
42
+ clientOptions?: LuteConnectOptions;
43
+ clientStatic?: typeof LuteConnect;
44
+ getDynamicClient?: () => Promise<typeof LuteConnect>;
45
+ };
39
46
  [PROVIDER_ID.MYALGO]: {
40
47
  clientOptions?: MyAlgoConnectOptions;
41
48
  clientStatic?: typeof MyAlgoConnect;
@@ -66,6 +73,11 @@ export type ProviderConfigMapping = {
66
73
  clientStatic?: undefined;
67
74
  getDynamicClient?: undefined;
68
75
  };
76
+ [PROVIDER_ID.KIBISIS]: {
77
+ clientOptions?: undefined;
78
+ clientStatic?: undefined;
79
+ getDynamicClient?: undefined;
80
+ };
69
81
  };
70
82
  /**
71
83
  * Enforces correct configuration given for each provider. For example,
@@ -101,9 +113,11 @@ type DynamicClient<T> = {
101
113
  getDynamicClient: () => Promise<T>;
102
114
  };
103
115
  type OneOfStaticOrDynamicClient<T> = StaticClient<T> | DynamicClient<T>;
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> & {
116
+ 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.LUTE> & OneOfStaticOrDynamicClient<typeof LuteConnect> & {
117
+ clientOptions: LuteConnectOptions;
118
+ }) | (ProviderConfig<PROVIDER_ID.WALLETCONNECT> & OneOfStaticOrDynamicClient<typeof WalletConnectModalSign> & {
105
119
  clientOptions: WalletConnectModalSignOptions;
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;
120
+ }) | (ProviderConfig<PROVIDER_ID.MYALGO> & OneOfStaticOrDynamicClient<typeof MyAlgoConnect>) | ProviderConfig<PROVIDER_ID.EXODUS> | ProviderConfig<PROVIDER_ID.KMD> | ProviderConfig<PROVIDER_ID.CUSTOM> | ProviderConfig<PROVIDER_ID.KIBISIS> | PROVIDER_ID.EXODUS | PROVIDER_ID.KMD | PROVIDER_ID.ALGOSIGNER | PROVIDER_ID.MNEMONIC | PROVIDER_ID.CUSTOM | PROVIDER_ID.KIBISIS;
107
121
  export type ProvidersArray = NonEmptyArray<ProviderDef>;
108
122
  export type WalletClient = BaseClient;
109
123
  export type SupportedProviders = Partial<Record<PROVIDER_ID, WalletClient | null>>;
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ import algosdk from 'algosdk';
2
2
  import { PeraWalletConnect } from '@perawallet/connect';
3
3
  import { DeflyWalletConnect } from '@blockshake/defly-connect';
4
4
  import { DaffiWalletConnect } from '@daffiwallet/connect';
5
+ import LuteConnect from 'lute-connect';
5
6
  import MyAlgoConnect from '@randlabs/myalgo-connect';
6
7
  import { WalletConnectModalSignOptions, WalletConnectModalSign } from '@walletconnect/modal-sign-html';
7
8
  import React from 'react';
@@ -72,10 +73,12 @@ declare enum PROVIDER_ID {
72
73
  CUSTOM = "custom",
73
74
  PERA = "pera",
74
75
  DAFFI = "daffi",
76
+ LUTE = "lute",
75
77
  MYALGO = "myalgo",
76
78
  ALGOSIGNER = "algosigner",
77
79
  DEFLY = "defly",
78
80
  EXODUS = "exodus",
81
+ KIBISIS = "kibisis",
79
82
  WALLETCONNECT = "walletconnect",
80
83
  MNEMONIC = "mnemonic"
81
84
  }
@@ -213,6 +216,18 @@ type KMDWalletClientConstructor = {
213
216
  network: Network;
214
217
  };
215
218
 
219
+ type LuteConnectOptions = {
220
+ siteName: string;
221
+ };
222
+ type LuteClientConstructor = {
223
+ metadata: Metadata;
224
+ client: LuteConnect;
225
+ clientOptions?: LuteConnectOptions;
226
+ algosdk: typeof algosdk;
227
+ algodClient: algosdk.Algodv2;
228
+ network: Network;
229
+ };
230
+
216
231
  /**
217
232
  * Helpful resources:
218
233
  * https://github.com/randlabs/myalgo-connect
@@ -325,6 +340,11 @@ type ProviderConfigMapping = {
325
340
  clientStatic?: typeof WalletConnectModalSign;
326
341
  getDynamicClient?: () => Promise<typeof WalletConnectModalSign>;
327
342
  };
343
+ [PROVIDER_ID.LUTE]: {
344
+ clientOptions?: LuteConnectOptions;
345
+ clientStatic?: typeof LuteConnect;
346
+ getDynamicClient?: () => Promise<typeof LuteConnect>;
347
+ };
328
348
  [PROVIDER_ID.MYALGO]: {
329
349
  clientOptions?: MyAlgoConnectOptions;
330
350
  clientStatic?: typeof MyAlgoConnect;
@@ -355,6 +375,11 @@ type ProviderConfigMapping = {
355
375
  clientStatic?: undefined;
356
376
  getDynamicClient?: undefined;
357
377
  };
378
+ [PROVIDER_ID.KIBISIS]: {
379
+ clientOptions?: undefined;
380
+ clientStatic?: undefined;
381
+ getDynamicClient?: undefined;
382
+ };
358
383
  };
359
384
  /**
360
385
  * Enforces correct configuration given for each provider. For example,
@@ -390,9 +415,11 @@ type DynamicClient<T> = {
390
415
  getDynamicClient: () => Promise<T>;
391
416
  };
392
417
  type OneOfStaticOrDynamicClient<T> = StaticClient<T> | DynamicClient<T>;
393
- 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> & {
418
+ 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.LUTE> & OneOfStaticOrDynamicClient<typeof LuteConnect> & {
419
+ clientOptions: LuteConnectOptions;
420
+ }) | (ProviderConfig<PROVIDER_ID.WALLETCONNECT> & OneOfStaticOrDynamicClient<typeof WalletConnectModalSign> & {
394
421
  clientOptions: WalletConnectModalSignOptions;
395
- }) | (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;
422
+ }) | (ProviderConfig<PROVIDER_ID.MYALGO> & OneOfStaticOrDynamicClient<typeof MyAlgoConnect>) | ProviderConfig<PROVIDER_ID.EXODUS> | ProviderConfig<PROVIDER_ID.KMD> | ProviderConfig<PROVIDER_ID.CUSTOM> | ProviderConfig<PROVIDER_ID.KIBISIS> | PROVIDER_ID.EXODUS | PROVIDER_ID.KMD | PROVIDER_ID.ALGOSIGNER | PROVIDER_ID.MNEMONIC | PROVIDER_ID.CUSTOM | PROVIDER_ID.KIBISIS;
396
423
  type ProvidersArray = NonEmptyArray<ProviderDef>;
397
424
  type WalletClient = BaseClient;
398
425
  type SupportedProviders = Partial<Record<PROVIDER_ID, WalletClient | null>>;
@@ -542,7 +569,7 @@ declare const useWalletStore: zustand.UseBoundStore<Omit<Omit<Omit<zustand.Store
542
569
  };
543
570
  }, "setState"> & {
544
571
  setState<A extends string | {
545
- type: unknown;
572
+ type: string;
546
573
  }>(nextStateOrUpdater: WalletStore | Partial<WalletStore> | ((state: immer_dist_internal.WritableDraft<WalletStore>) => void), shouldReplace?: boolean | undefined, action?: A | undefined): void;
547
574
  }>;
548
575
 
@@ -611,6 +638,35 @@ declare class AlgoSignerClient extends BaseClient {
611
638
  getAuthAddress(address: string): string | undefined;
612
639
  }
613
640
 
641
+ declare class LuteClient extends BaseClient {
642
+ #private;
643
+ clientOptions?: LuteConnectOptions;
644
+ network: Network;
645
+ constructor({ metadata, client, clientOptions, algosdk, algodClient, network }: LuteClientConstructor);
646
+ static metadata: {
647
+ id: PROVIDER_ID;
648
+ name: string;
649
+ icon: string;
650
+ isWalletConnect: boolean;
651
+ };
652
+ static init({ clientOptions, algodOptions, clientStatic, getDynamicClient, algosdkStatic, network }: InitParams<PROVIDER_ID.LUTE>): Promise<BaseClient | null>;
653
+ connect(): Promise<{
654
+ accounts: {
655
+ name: string;
656
+ address: string;
657
+ providerId: PROVIDER_ID;
658
+ }[];
659
+ id: PROVIDER_ID;
660
+ name: string;
661
+ icon: string;
662
+ isWalletConnect: boolean;
663
+ }>;
664
+ reconnect(): Promise<null>;
665
+ disconnect(): Promise<void>;
666
+ shouldSignTxnObject(txn: DecodedTransaction | DecodedSignedTransaction, addresses: string[], indexesToSign: number[] | undefined, idx: number): boolean;
667
+ signTransactions(connectedAccounts: string[], transactions: Uint8Array[], indexesToSign?: number[], returnGroup?: boolean): Promise<Uint8Array[]>;
668
+ }
669
+
614
670
  type WalletConnectClientConstructor = {
615
671
  metadata: Metadata;
616
672
  client: WalletConnectModalSign;
@@ -722,6 +778,95 @@ declare class CustomWalletClient extends BaseClient {
722
778
  signTransactions(connectedAccounts: string[], txnGroups: Uint8Array[] | Uint8Array[][], indexesToSign?: number[], returnGroup?: boolean): Promise<Uint8Array[]>;
723
779
  }
724
780
 
781
+ interface Arc0027Account {
782
+ address: string;
783
+ name?: string;
784
+ }
785
+ interface KibisisClientConstructor {
786
+ metadata: Metadata;
787
+ algosdk: typeof algosdk;
788
+ algodClient: algosdk.Algodv2;
789
+ genesisHash: string;
790
+ methods: ProviderMethods[];
791
+ network: Network;
792
+ }
793
+ type ProviderMethods = 'enable' | 'getProviders' | 'postTxns' | 'signAndPostTxns' | 'signBytes' | 'signTxns';
794
+ interface SendRequestWithTimeoutOptions<Params> {
795
+ method: ProviderMethods;
796
+ params: Params;
797
+ reference: string;
798
+ timeout?: number;
799
+ }
800
+
801
+ declare class KibisisClient extends BaseClient {
802
+ genesisHash: string;
803
+ methods: ProviderMethods[];
804
+ network: Network;
805
+ constructor({ metadata, algosdk, algodClient, genesisHash, methods, network }: KibisisClientConstructor);
806
+ static metadata: {
807
+ id: PROVIDER_ID;
808
+ icon: string;
809
+ isWalletConnect: boolean;
810
+ name: string;
811
+ };
812
+ /**
813
+ * public static functions
814
+ */
815
+ static init({ algodOptions, algosdkStatic, network }: InitParams<PROVIDER_ID.KIBISIS>): Promise<BaseClient | null>;
816
+ static mapAccountsToWallet(accounts: Arc0027Account[]): Wallet;
817
+ static sendRequestWithTimeout<Params, Result>({ method, params, timeout, reference }: SendRequestWithTimeoutOptions<Params>): Promise<Result | undefined>;
818
+ /**
819
+ * private functions
820
+ */
821
+ private convertBytesToBase64;
822
+ private convertBase64ToBytes;
823
+ /**
824
+ * Calls the enable method on the provider that returns the authorized accounts.
825
+ * @returns {Arc0027Account[]} the authorized accounts.
826
+ * @throws {METHOD_CANCELED_ERROR} if the method was cancelled by the user.
827
+ * @throws {METHOD_NOT_SUPPORTED_ERROR} if the method is not supported for the configured network.
828
+ * @throws {METHOD_TIMED_OUT_ERROR} if the method timed out by lack of response.
829
+ * @throws {NETWORK_NOT_SUPPORTED_ERROR} if the network is not supported for the configured network.
830
+ * @throws {UNKNOWN_ERROR} if the response result was empty.
831
+ */
832
+ private enable;
833
+ /**
834
+ * Convenience function that gets the provider information and updates the supported methods. This should be called
835
+ * before interacting with the provider to ensure methods are supported.
836
+ * @throws {METHOD_TIMED_OUT_ERROR} if the method timed out by lack of response.
837
+ * @throws {NETWORK_NOT_SUPPORTED_ERROR} if the network is not supported for the configured network.
838
+ * @throws {UNKNOWN_ERROR} if the response result was empty.
839
+ */
840
+ private refreshSupportedMethods;
841
+ /**
842
+ * Calls the signTxns methods to sign the supplied transactions.
843
+ * @param {Arc0001SignTxns[]} txns - the unsigned or signed transactions as defined in ARC-0001.
844
+ * @returns {(string | null)[]} the authorized accounts.
845
+ * @throws {INVALID_INPUT_ERROR} if computed group ID for the txns does not match the assigned group ID.
846
+ * @throws {INVALID_GROUP_ID_ERROR} if the unsigned txns is malformed or not conforming to ARC-0001.
847
+ * @throws {METHOD_CANCELED_ERROR} if the method was cancelled by the user.
848
+ * @throws {METHOD_NOT_SUPPORTED_ERROR} if the method is not supported for the configured network.
849
+ * @throws {METHOD_TIMED_OUT_ERROR} if the method timed out by lack of response.
850
+ * @throws {NETWORK_NOT_SUPPORTED_ERROR} if the network is not supported for the configured network.
851
+ * @throws {UNAUTHORIZED_SIGNER_ERROR} if a signer in the request is not authorized by the provider.
852
+ * @throws {UNKNOWN_ERROR} if the response result was empty.
853
+ */
854
+ private signTxns;
855
+ /**
856
+ * Validates whether a method is supported with the provider.
857
+ * @param {ProviderMethods} method - the method to validate.
858
+ * @throws {METHOD_NOT_SUPPORTED_ERROR} if the method is not supported for the configured network.
859
+ */
860
+ private validateMethod;
861
+ /**
862
+ * public functions
863
+ */
864
+ connect(): Promise<Wallet>;
865
+ disconnect(): Promise<void>;
866
+ reconnect(): Promise<Wallet | null>;
867
+ signTransactions(connectedAccounts: string[], transactions: Uint8Array[], indexesToSign?: number[], returnGroup?: boolean): Promise<Uint8Array[]>;
868
+ }
869
+
725
870
  declare function useWallet(): {
726
871
  clients: Partial<Record<PROVIDER_ID, BaseClient | null>> | null;
727
872
  providers: Provider[] | null;
@@ -759,4 +904,4 @@ interface InitializeProvidersOptions {
759
904
  }
760
905
  declare function useInitializeProviders({ providers, nodeConfig, algosdkStatic, debug }: InitializeProvidersOptions): Partial<Record<PROVIDER_ID, BaseClient | null>> | null;
761
906
 
762
- export { Account, AccountInfo, AlgodClientOptions, Asset, ClientOptions, CommonInitParams, ConfirmedTxn, CustomProvider, DEFAULT_NETWORK, DEFAULT_NODE_BASEURL, DEFAULT_NODE_PORT, DEFAULT_NODE_TOKEN, DecodedSignedTransaction, DecodedTransaction, InitParams, Metadata, Network, NodeConfig, PROVIDER_ID, Provider, ProviderConfig, ProviderConfigMapping, ProvidersArray, PublicNetwork, RawTxnResponse, SupportedProviders, TransactionsArray, Txn, TxnInfo, TxnType, Wallet, WalletClient, WalletProvider, AlgoSignerClient as algosigner, CustomWalletClient as custom, DeflyWalletClient as defly, encodeNFDTransactionsArray, ExodusClient as exodus, KMDWalletClient as kmd, MnemonicWalletClient as mnemonic, MyAlgoWalletClient as myalgo, PeraWalletClient as pera, reconnectProviders, useInitializeProviders, useWallet, WalletConnectClient as walletconnect };
907
+ export { Account, AccountInfo, AlgodClientOptions, Asset, ClientOptions, CommonInitParams, ConfirmedTxn, CustomProvider, DEFAULT_NETWORK, DEFAULT_NODE_BASEURL, DEFAULT_NODE_PORT, DEFAULT_NODE_TOKEN, DecodedSignedTransaction, DecodedTransaction, InitParams, Metadata, Network, NodeConfig, PROVIDER_ID, Provider, ProviderConfig, ProviderConfigMapping, ProvidersArray, PublicNetwork, RawTxnResponse, SupportedProviders, TransactionsArray, Txn, TxnInfo, TxnType, Wallet, WalletClient, WalletProvider, AlgoSignerClient as algosigner, CustomWalletClient as custom, DeflyWalletClient as defly, encodeNFDTransactionsArray, ExodusClient as exodus, KibisisClient as kibisis, KMDWalletClient as kmd, LuteClient as lute, MnemonicWalletClient as mnemonic, MyAlgoWalletClient as myalgo, PeraWalletClient as pera, reconnectProviders, useInitializeProviders, useWallet, WalletConnectClient as walletconnect };