@txnlab/use-wallet 0.1.1 → 0.1.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.
- package/LICENSE.md +20 -0
- package/README.md +150 -64
- package/dist/cjs/clients/algosigner.d.ts +1 -1
- package/dist/cjs/clients/index.d.ts +107 -1
- package/dist/cjs/clients/kmd.d.ts +32 -0
- package/dist/cjs/clients/walletconnect.d.ts +52 -0
- package/dist/cjs/constants/constants.d.ts +9 -1
- package/dist/cjs/hooks/useConnectWallet.d.ts +10 -2
- package/dist/cjs/hooks/useWallet.d.ts +2 -0
- package/dist/cjs/index.js +9165 -354
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/providers/index.d.ts +2 -0
- package/dist/cjs/providers/kmd.d.ts +2 -0
- package/dist/cjs/providers/walletconnect.d.ts +2 -0
- package/dist/cjs/types/node.d.ts +1 -1
- package/dist/esm/clients/algosigner.d.ts +1 -1
- package/dist/esm/clients/index.d.ts +107 -1
- package/dist/esm/clients/kmd.d.ts +32 -0
- package/dist/esm/clients/walletconnect.d.ts +52 -0
- package/dist/esm/constants/constants.d.ts +9 -1
- package/dist/esm/hooks/useConnectWallet.d.ts +10 -2
- package/dist/esm/hooks/useWallet.d.ts +2 -0
- package/dist/esm/index.js +9143 -345
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/providers/index.d.ts +2 -0
- package/dist/esm/providers/kmd.d.ts +2 -0
- package/dist/esm/providers/walletconnect.d.ts +2 -0
- package/dist/esm/types/node.d.ts +1 -1
- package/dist/index.d.ts +136 -11
- package/package.json +2 -1
package/dist/cjs/types/node.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ declare type AlgoSignerTransaction = {
|
|
|
13
13
|
signers?: [];
|
|
14
14
|
multisig?: string;
|
|
15
15
|
};
|
|
16
|
-
declare type SupportedLedgers = "MainNet" | "TestNet" | "BetaNet" |
|
|
16
|
+
declare type SupportedLedgers = "MainNet" | "TestNet" | "BetaNet" | string;
|
|
17
17
|
declare type AlgoSigner = {
|
|
18
18
|
connect: () => Promise<Record<string, never>>;
|
|
19
19
|
accounts: (ledger: {
|
|
@@ -1,5 +1,53 @@
|
|
|
1
1
|
import { PROVIDER_ID } from "../constants";
|
|
2
2
|
export declare const clients: {
|
|
3
|
+
"KMD Wallet": Promise<void | {
|
|
4
|
+
"__#6@#client": import("algosdk").Kmd;
|
|
5
|
+
walletId: string;
|
|
6
|
+
id: PROVIDER_ID;
|
|
7
|
+
provider: import("..").WalletProvider;
|
|
8
|
+
connect(): Promise<import("..").Wallet>;
|
|
9
|
+
disconnect(): Promise<void>;
|
|
10
|
+
reconnect(): Promise<import("..").Wallet | null>;
|
|
11
|
+
requestPassword(): Promise<string>;
|
|
12
|
+
getWalletToken(walletId: string, password: string): Promise<string>;
|
|
13
|
+
releaseToken(token: string): Promise<void>;
|
|
14
|
+
listWallets(): Promise<Record<string, string>>;
|
|
15
|
+
listAccounts(wallet: string, password: string): Promise<import("..").Account[]>;
|
|
16
|
+
signTransactions(activeAddress: string, transactions: Uint8Array[]): Promise<Uint8Array[]>;
|
|
17
|
+
signEncodedTransactions(transactions: import("..").TransactionsArray): Promise<Uint8Array[]>;
|
|
18
|
+
algodClient: import("algosdk").Algodv2;
|
|
19
|
+
algosdk: typeof import("algosdk/dist/types/src/main");
|
|
20
|
+
keepWCAlive: HTMLAudioElement;
|
|
21
|
+
healthCheck(): Promise<{}>;
|
|
22
|
+
getAccountInfo(address: string): Promise<import("..").AccountInfo>;
|
|
23
|
+
getAssets(address: string): Promise<import("..").Asset[]>;
|
|
24
|
+
waitForConfirmation(txId: string, timeout?: number): Promise<{
|
|
25
|
+
"confirmed-round": number;
|
|
26
|
+
"global-state-delta": Record<string, unknown>[];
|
|
27
|
+
"pool-error": string;
|
|
28
|
+
txn: {
|
|
29
|
+
sig: Uint8Array;
|
|
30
|
+
txn: import("..").Txn;
|
|
31
|
+
};
|
|
32
|
+
txId: string;
|
|
33
|
+
}>;
|
|
34
|
+
decodeTransaction: (txn: string, isSigned: boolean) => import("algosdk").Transaction;
|
|
35
|
+
logEncodedTransaction(txn: string, isSigned: boolean): void;
|
|
36
|
+
groupTransactionsBySender(transactions: import("..").TransactionsArray): Record<string, any>;
|
|
37
|
+
sendRawTransactions(transactions: Uint8Array[]): Promise<{
|
|
38
|
+
"confirmed-round": number;
|
|
39
|
+
"global-state-delta": Record<string, unknown>[];
|
|
40
|
+
"pool-error": string;
|
|
41
|
+
txn: {
|
|
42
|
+
sig: Uint8Array;
|
|
43
|
+
txn: import("..").Txn;
|
|
44
|
+
};
|
|
45
|
+
txId: string;
|
|
46
|
+
id: any;
|
|
47
|
+
}>;
|
|
48
|
+
keepWCAliveStart(): void;
|
|
49
|
+
keepWCAliveStop(): void;
|
|
50
|
+
}>;
|
|
3
51
|
"Pera Wallet": Promise<void | {
|
|
4
52
|
"__#1@#client": import("@perawallet/connect/dist/PeraWalletConnect").default;
|
|
5
53
|
id: PROVIDER_ID;
|
|
@@ -109,7 +157,7 @@ export declare const clients: {
|
|
|
109
157
|
"__#3@#client": {
|
|
110
158
|
connect: () => Promise<Record<string, never>>;
|
|
111
159
|
accounts: (ledger: {
|
|
112
|
-
ledger:
|
|
160
|
+
ledger: string;
|
|
113
161
|
}) => Promise<{
|
|
114
162
|
address: string;
|
|
115
163
|
}[]>;
|
|
@@ -297,4 +345,62 @@ export declare const clients: {
|
|
|
297
345
|
keepWCAliveStart(): void;
|
|
298
346
|
keepWCAliveStop(): void;
|
|
299
347
|
}>;
|
|
348
|
+
"Wallet Connect": Promise<void | {
|
|
349
|
+
"__#7@#client": import("@walletconnect/client").default;
|
|
350
|
+
id: PROVIDER_ID;
|
|
351
|
+
provider: import("..").WalletProvider;
|
|
352
|
+
connect(): Promise<import("..").Wallet>;
|
|
353
|
+
reconnect(): Promise<{
|
|
354
|
+
accounts: {
|
|
355
|
+
name: string;
|
|
356
|
+
address: string;
|
|
357
|
+
providerId: PROVIDER_ID;
|
|
358
|
+
}[];
|
|
359
|
+
id: PROVIDER_ID;
|
|
360
|
+
name: string;
|
|
361
|
+
icon: string;
|
|
362
|
+
isWalletConnect: boolean;
|
|
363
|
+
} | null>;
|
|
364
|
+
check(): boolean;
|
|
365
|
+
disconnect(): Promise<void>;
|
|
366
|
+
formatTransactionsArray(transactions: import("..").TransactionsArray): {
|
|
367
|
+
txn: string;
|
|
368
|
+
message?: string | undefined;
|
|
369
|
+
signers?: [] | string[] | undefined;
|
|
370
|
+
}[];
|
|
371
|
+
signTransactions(activeAdress: string, transactions: Uint8Array[]): Promise<Uint8Array[]>;
|
|
372
|
+
signEncodedTransactions(transactions: import("..").TransactionsArray): Promise<Uint8Array[]>;
|
|
373
|
+
algodClient: import("algosdk").Algodv2;
|
|
374
|
+
algosdk: typeof import("algosdk/dist/types/src/main");
|
|
375
|
+
keepWCAlive: HTMLAudioElement;
|
|
376
|
+
healthCheck(): Promise<{}>;
|
|
377
|
+
getAccountInfo(address: string): Promise<import("..").AccountInfo>;
|
|
378
|
+
getAssets(address: string): Promise<import("..").Asset[]>;
|
|
379
|
+
waitForConfirmation(txId: string, timeout?: number): Promise<{
|
|
380
|
+
"confirmed-round": number;
|
|
381
|
+
"global-state-delta": Record<string, unknown>[];
|
|
382
|
+
"pool-error": string;
|
|
383
|
+
txn: {
|
|
384
|
+
sig: Uint8Array;
|
|
385
|
+
txn: import("..").Txn;
|
|
386
|
+
};
|
|
387
|
+
txId: string;
|
|
388
|
+
}>;
|
|
389
|
+
decodeTransaction: (txn: string, isSigned: boolean) => import("algosdk").Transaction;
|
|
390
|
+
logEncodedTransaction(txn: string, isSigned: boolean): void;
|
|
391
|
+
groupTransactionsBySender(transactions: import("..").TransactionsArray): Record<string, any>;
|
|
392
|
+
sendRawTransactions(transactions: Uint8Array[]): Promise<{
|
|
393
|
+
"confirmed-round": number;
|
|
394
|
+
"global-state-delta": Record<string, unknown>[];
|
|
395
|
+
"pool-error": string;
|
|
396
|
+
txn: {
|
|
397
|
+
sig: Uint8Array;
|
|
398
|
+
txn: import("..").Txn;
|
|
399
|
+
};
|
|
400
|
+
txId: string;
|
|
401
|
+
id: any;
|
|
402
|
+
}>;
|
|
403
|
+
keepWCAliveStart(): void;
|
|
404
|
+
keepWCAliveStop(): void;
|
|
405
|
+
}>;
|
|
300
406
|
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Kmd } from "algosdk";
|
|
2
|
+
import BaseWallet from "./base";
|
|
3
|
+
import type { InitAlgodClient } from "./base";
|
|
4
|
+
import { PROVIDER_ID } from "../constants";
|
|
5
|
+
import { providers } from "../providers";
|
|
6
|
+
import type { Account, Wallet, WalletProvider } from "../types";
|
|
7
|
+
import { TransactionsArray } from "../types";
|
|
8
|
+
declare type InitWallet = {
|
|
9
|
+
client: Kmd;
|
|
10
|
+
id: PROVIDER_ID;
|
|
11
|
+
providers: typeof providers;
|
|
12
|
+
};
|
|
13
|
+
declare class KMDWallet extends BaseWallet {
|
|
14
|
+
#private;
|
|
15
|
+
walletId: string;
|
|
16
|
+
id: PROVIDER_ID;
|
|
17
|
+
provider: WalletProvider;
|
|
18
|
+
constructor(initAlgodClient: InitAlgodClient, initWallet: InitWallet);
|
|
19
|
+
static init(): Promise<KMDWallet>;
|
|
20
|
+
connect(): Promise<Wallet>;
|
|
21
|
+
disconnect(): Promise<void>;
|
|
22
|
+
reconnect(): Promise<Wallet | null>;
|
|
23
|
+
requestPassword(): Promise<string>;
|
|
24
|
+
getWalletToken(walletId: string, password: string): Promise<string>;
|
|
25
|
+
releaseToken(token: string): Promise<void>;
|
|
26
|
+
listWallets(): Promise<Record<string, string>>;
|
|
27
|
+
listAccounts(wallet: string, password: string): Promise<Array<Account>>;
|
|
28
|
+
signTransactions(activeAddress: string, transactions: Uint8Array[]): Promise<Uint8Array[]>;
|
|
29
|
+
signEncodedTransactions(transactions: TransactionsArray): Promise<Uint8Array[]>;
|
|
30
|
+
}
|
|
31
|
+
declare const _default: Promise<void | KMDWallet>;
|
|
32
|
+
export default _default;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpful resources:
|
|
3
|
+
* https://developer.algorand.org/docs/get-details/walletconnect/
|
|
4
|
+
*/
|
|
5
|
+
import type WalletConnect from "@walletconnect/client";
|
|
6
|
+
import type { IWalletConnectOptions } from "@walletconnect/types";
|
|
7
|
+
import type QRCodeModal from "algorand-walletconnect-qrcode-modal";
|
|
8
|
+
import { providers } from "../providers";
|
|
9
|
+
import type { WalletProvider, Wallet } from "../types/wallet";
|
|
10
|
+
import { PROVIDER_ID } from "../constants";
|
|
11
|
+
import BaseWallet from "./base";
|
|
12
|
+
import type { InitAlgodClient } from "./base";
|
|
13
|
+
import { TransactionsArray } from "../types/api";
|
|
14
|
+
declare type WalletConnectTransaction = {
|
|
15
|
+
txn: string;
|
|
16
|
+
message?: string;
|
|
17
|
+
signers?: string[] | [];
|
|
18
|
+
};
|
|
19
|
+
declare type InitWallet = {
|
|
20
|
+
id: PROVIDER_ID;
|
|
21
|
+
walletConnect: typeof WalletConnect;
|
|
22
|
+
bridge: string;
|
|
23
|
+
qrcodeModal: typeof QRCodeModal;
|
|
24
|
+
WalletConnectOptions?: IWalletConnectOptions;
|
|
25
|
+
providers: typeof providers;
|
|
26
|
+
};
|
|
27
|
+
declare class WalletConnectClient extends BaseWallet {
|
|
28
|
+
#private;
|
|
29
|
+
id: PROVIDER_ID;
|
|
30
|
+
provider: WalletProvider;
|
|
31
|
+
constructor(initAlgodClient: InitAlgodClient, initWallet: InitWallet);
|
|
32
|
+
static init(): Promise<WalletConnectClient>;
|
|
33
|
+
connect(): Promise<Wallet>;
|
|
34
|
+
reconnect(): Promise<{
|
|
35
|
+
accounts: {
|
|
36
|
+
name: string;
|
|
37
|
+
address: string;
|
|
38
|
+
providerId: PROVIDER_ID;
|
|
39
|
+
}[];
|
|
40
|
+
id: PROVIDER_ID;
|
|
41
|
+
name: string;
|
|
42
|
+
icon: string;
|
|
43
|
+
isWalletConnect: boolean;
|
|
44
|
+
} | null>;
|
|
45
|
+
check(): boolean;
|
|
46
|
+
disconnect(): Promise<void>;
|
|
47
|
+
formatTransactionsArray(transactions: TransactionsArray): WalletConnectTransaction[];
|
|
48
|
+
signTransactions(activeAdress: string, transactions: Uint8Array[]): Promise<Uint8Array[]>;
|
|
49
|
+
signEncodedTransactions(transactions: TransactionsArray): Promise<Uint8Array[]>;
|
|
50
|
+
}
|
|
51
|
+
declare const _default: Promise<void | WalletConnectClient>;
|
|
52
|
+
export default _default;
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
export declare enum PROVIDER_ID {
|
|
2
|
+
KMD_WALLET = "KMD Wallet",
|
|
2
3
|
PERA_WALLET = "Pera Wallet",
|
|
3
4
|
MYALGO_WALLET = "MyAlgo Wallet",
|
|
4
5
|
ALGO_SIGNER = "Algo Signer",
|
|
5
6
|
DEFLY = "Defly",
|
|
6
|
-
EXODUS = "Exodus"
|
|
7
|
+
EXODUS = "Exodus",
|
|
8
|
+
WALLET_CONNECT = "Wallet Connect"
|
|
7
9
|
}
|
|
8
10
|
export declare const NODE_SERVER: string;
|
|
9
11
|
export declare const NODE_TOKEN: string;
|
|
10
12
|
export declare const NODE_PORT: string;
|
|
13
|
+
export declare const NODE_NETWORK: string;
|
|
14
|
+
export declare const KMD_HOST: string;
|
|
15
|
+
export declare const KMD_TOKEN: string;
|
|
16
|
+
export declare const KMD_PORT: string;
|
|
17
|
+
export declare const KMD_WALLET: string;
|
|
18
|
+
export declare const KMD_PASSWORD: string;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { PROVIDER_ID } from "../types";
|
|
2
|
+
declare type Options = Partial<{
|
|
3
|
+
providers: PROVIDER_ID[];
|
|
4
|
+
}>;
|
|
5
|
+
export default function useConnectWallet(options?: Options): {
|
|
3
6
|
providers: {
|
|
4
7
|
id: PROVIDER_ID;
|
|
5
8
|
name: string;
|
|
6
9
|
icon: string;
|
|
10
|
+
accounts: import("../types").Account[];
|
|
11
|
+
activeAccount: import("../types").Account | null;
|
|
7
12
|
isActive: boolean;
|
|
8
13
|
isConnected: boolean;
|
|
9
14
|
isWalletConnect: boolean;
|
|
@@ -11,12 +16,15 @@ export default function useConnectWallet(): {
|
|
|
11
16
|
disconnect: () => Promise<void>;
|
|
12
17
|
reconnect: () => Promise<void>;
|
|
13
18
|
setActive: () => Promise<void>;
|
|
19
|
+
selectAccount: (account: string) => Promise<void>;
|
|
14
20
|
}[];
|
|
15
21
|
activeAccount: import("../types").Account | null;
|
|
16
22
|
accounts: import("../types").Account[];
|
|
17
23
|
connect: (id: PROVIDER_ID) => Promise<void>;
|
|
18
24
|
reconnect: (id: PROVIDER_ID) => Promise<void>;
|
|
19
25
|
disconnect: (id: PROVIDER_ID) => Promise<void>;
|
|
26
|
+
selectActiveAccount: (providerId: PROVIDER_ID, address: string) => Promise<void>;
|
|
20
27
|
setActive: (id: PROVIDER_ID) => Promise<void>;
|
|
21
28
|
reconnectProviders: () => Promise<void>;
|
|
22
29
|
};
|
|
30
|
+
export {};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import algosdk from "algosdk";
|
|
1
2
|
import { PROVIDER_ID } from "../types";
|
|
2
3
|
import { TransactionsArray } from "../types";
|
|
3
4
|
export { PROVIDER_ID };
|
|
4
5
|
export default function useWallet(): {
|
|
5
6
|
accounts: import("../types").Account[];
|
|
6
7
|
activeAccount: import("../types").Account | null;
|
|
8
|
+
signer: algosdk.TransactionSigner;
|
|
7
9
|
signTransactions: (transactions: Array<Uint8Array>) => Promise<Uint8Array[]>;
|
|
8
10
|
sendTransactions: (transactions: Uint8Array[]) => Promise<import("../types").ConfirmedTxn & {
|
|
9
11
|
id: string;
|