@txnlab/use-wallet 0.0.1
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/README.md +143 -0
- package/dist/cjs/clients/algosigner.d.ts +62 -0
- package/dist/cjs/clients/base.d.ts +72 -0
- package/dist/cjs/clients/defly.d.ts +51 -0
- package/dist/cjs/clients/exodus.d.ts +52 -0
- package/dist/cjs/clients/index.d.ts +300 -0
- package/dist/cjs/clients/myalgowallet.d.ts +40 -0
- package/dist/cjs/clients/perawallet.d.ts +51 -0
- package/dist/cjs/constants/constants.d.ts +10 -0
- package/dist/cjs/constants/index.d.ts +1 -0
- package/dist/cjs/hooks/index.d.ts +2 -0
- package/dist/cjs/hooks/useConnectWallet.d.ts +22 -0
- package/dist/cjs/hooks/useWallet.d.ts +10 -0
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/index.js +3536 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/media/audio.d.ts +1 -0
- package/dist/cjs/providers/algosigner.d.ts +2 -0
- package/dist/cjs/providers/defly.d.ts +2 -0
- package/dist/cjs/providers/exodus.d.ts +2 -0
- package/dist/cjs/providers/index.d.ts +7 -0
- package/dist/cjs/providers/myalgowallet.d.ts +2 -0
- package/dist/cjs/providers/perawallet.d.ts +2 -0
- package/dist/cjs/store/index.d.ts +1 -0
- package/dist/cjs/store/middelware/immer.d.ts +10 -0
- package/dist/cjs/store/state/walletStore.d.ts +19 -0
- package/dist/cjs/types/api.d.ts +11 -0
- package/dist/cjs/types/index.d.ts +3 -0
- package/dist/cjs/types/node.d.ts +41 -0
- package/dist/cjs/types/wallet.d.ts +47 -0
- package/dist/cjs/utils/index.d.ts +4 -0
- package/dist/esm/clients/algosigner.d.ts +62 -0
- package/dist/esm/clients/base.d.ts +72 -0
- package/dist/esm/clients/defly.d.ts +51 -0
- package/dist/esm/clients/exodus.d.ts +52 -0
- package/dist/esm/clients/index.d.ts +300 -0
- package/dist/esm/clients/myalgowallet.d.ts +40 -0
- package/dist/esm/clients/perawallet.d.ts +51 -0
- package/dist/esm/constants/constants.d.ts +10 -0
- package/dist/esm/constants/index.d.ts +1 -0
- package/dist/esm/hooks/index.d.ts +2 -0
- package/dist/esm/hooks/useConnectWallet.d.ts +22 -0
- package/dist/esm/hooks/useWallet.d.ts +10 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +3506 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/media/audio.d.ts +1 -0
- package/dist/esm/providers/algosigner.d.ts +2 -0
- package/dist/esm/providers/defly.d.ts +2 -0
- package/dist/esm/providers/exodus.d.ts +2 -0
- package/dist/esm/providers/index.d.ts +7 -0
- package/dist/esm/providers/myalgowallet.d.ts +2 -0
- package/dist/esm/providers/perawallet.d.ts +2 -0
- package/dist/esm/store/index.d.ts +1 -0
- package/dist/esm/store/middelware/immer.d.ts +10 -0
- package/dist/esm/store/state/walletStore.d.ts +19 -0
- package/dist/esm/types/api.d.ts +11 -0
- package/dist/esm/types/index.d.ts +3 -0
- package/dist/esm/types/node.d.ts +41 -0
- package/dist/esm/types/wallet.d.ts +47 -0
- package/dist/esm/utils/index.d.ts +4 -0
- package/dist/index.d.ts +160 -0
- package/package.json +94 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpful resources:
|
|
3
|
+
* https://github.com/randlabs/myalgo-connect
|
|
4
|
+
*/
|
|
5
|
+
import BaseWallet from "./base";
|
|
6
|
+
import type MyAlgoConnect from "@randlabs/myalgo-connect";
|
|
7
|
+
import type { InitAlgodClient } from "./base";
|
|
8
|
+
import { PROVIDER_ID } from "../constants";
|
|
9
|
+
import { providers } from "../providers";
|
|
10
|
+
import type { WalletProvider } from "../types";
|
|
11
|
+
import { TransactionsArray } from "../types";
|
|
12
|
+
declare type InitWallet = {
|
|
13
|
+
id: PROVIDER_ID;
|
|
14
|
+
client: MyAlgoConnect;
|
|
15
|
+
providers: typeof providers;
|
|
16
|
+
};
|
|
17
|
+
declare class MyAlgoWalletClient extends BaseWallet {
|
|
18
|
+
#private;
|
|
19
|
+
id: PROVIDER_ID;
|
|
20
|
+
provider: WalletProvider;
|
|
21
|
+
constructor(initAlgodClient: InitAlgodClient, initWallet: InitWallet);
|
|
22
|
+
static init(): Promise<MyAlgoWalletClient>;
|
|
23
|
+
connect(): Promise<{
|
|
24
|
+
accounts: {
|
|
25
|
+
providerId: PROVIDER_ID;
|
|
26
|
+
address: string;
|
|
27
|
+
name: string;
|
|
28
|
+
}[];
|
|
29
|
+
id: PROVIDER_ID;
|
|
30
|
+
name: string;
|
|
31
|
+
icon: string;
|
|
32
|
+
isWalletConnect: boolean;
|
|
33
|
+
}>;
|
|
34
|
+
reconnect(): Promise<null>;
|
|
35
|
+
disconnect(): Promise<void>;
|
|
36
|
+
signTransactions(activeAdress: string, transactions: Uint8Array[]): Promise<Uint8Array[]>;
|
|
37
|
+
signEncodedTransactions(transactions: TransactionsArray): Promise<Uint8Array[]>;
|
|
38
|
+
}
|
|
39
|
+
declare const _default: Promise<void | MyAlgoWalletClient>;
|
|
40
|
+
export default _default;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpful resources:
|
|
3
|
+
* https://github.com/perawallet/connect
|
|
4
|
+
*/
|
|
5
|
+
import { providers } from "../providers";
|
|
6
|
+
import type { PeraWalletConnect } from "@perawallet/connect";
|
|
7
|
+
import type { WalletProvider, Wallet } from "../types";
|
|
8
|
+
import { PROVIDER_ID } from "../constants";
|
|
9
|
+
import type { Transaction } from "algosdk";
|
|
10
|
+
import BaseWallet from "./base";
|
|
11
|
+
import type { InitAlgodClient } from "./base";
|
|
12
|
+
import { TransactionsArray } from "../types";
|
|
13
|
+
export interface PeraTransaction {
|
|
14
|
+
txn: Transaction;
|
|
15
|
+
/**
|
|
16
|
+
* Optional list of addresses that must sign the transactions.
|
|
17
|
+
* Wallet skips to sign this txn if signers is empty array.
|
|
18
|
+
* If undefined, wallet tries to sign it.
|
|
19
|
+
*/
|
|
20
|
+
signers?: string[];
|
|
21
|
+
}
|
|
22
|
+
declare type InitWallet = {
|
|
23
|
+
id: PROVIDER_ID;
|
|
24
|
+
client: PeraWalletConnect;
|
|
25
|
+
providers: typeof providers;
|
|
26
|
+
};
|
|
27
|
+
declare class PeraWalletClient extends BaseWallet {
|
|
28
|
+
#private;
|
|
29
|
+
id: PROVIDER_ID;
|
|
30
|
+
provider: WalletProvider;
|
|
31
|
+
constructor(initAlgodClient: InitAlgodClient, initWallet: InitWallet);
|
|
32
|
+
static init(): Promise<PeraWalletClient>;
|
|
33
|
+
connect(onDisconnect: () => void): Promise<Wallet>;
|
|
34
|
+
reconnect(onDisconnect: () => void): 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
|
+
disconnect(): Promise<void>;
|
|
46
|
+
formatTransactionsArray(transactions: TransactionsArray): PeraTransaction[];
|
|
47
|
+
signTransactions(activeAdress: string, transactions: Uint8Array[]): Promise<Uint8Array[]>;
|
|
48
|
+
signEncodedTransactions(transactions: TransactionsArray): Promise<Uint8Array[]>;
|
|
49
|
+
}
|
|
50
|
+
declare const _default: Promise<void | PeraWalletClient>;
|
|
51
|
+
export default _default;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare enum PROVIDER_ID {
|
|
2
|
+
PERA_WALLET = "Pera Wallet",
|
|
3
|
+
MYALGO_WALLET = "MyAlgo Wallet",
|
|
4
|
+
ALGO_SIGNER = "Algo Signer",
|
|
5
|
+
DEFLY = "Defly",
|
|
6
|
+
EXODUS = "Exodus"
|
|
7
|
+
}
|
|
8
|
+
export declare const NODE_SERVER = "https://node.algoexplorerapi.io";
|
|
9
|
+
export declare const NODE_TOKEN = "";
|
|
10
|
+
export declare const NODE_PORT = "";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./constants";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { PROVIDER_ID } from "../types";
|
|
2
|
+
export default function useConnectWallet(): {
|
|
3
|
+
providers: {
|
|
4
|
+
id: PROVIDER_ID;
|
|
5
|
+
name: string;
|
|
6
|
+
icon: string;
|
|
7
|
+
isActive: boolean;
|
|
8
|
+
isConnected: boolean;
|
|
9
|
+
isWalletConnect: boolean;
|
|
10
|
+
connect: () => Promise<void>;
|
|
11
|
+
disconnect: () => Promise<void>;
|
|
12
|
+
reconnect: () => Promise<void>;
|
|
13
|
+
setActive: () => Promise<void>;
|
|
14
|
+
}[];
|
|
15
|
+
activeAccount: import("../types").Account | null;
|
|
16
|
+
accounts: import("../types").Account[];
|
|
17
|
+
connect: (id: PROVIDER_ID) => Promise<void>;
|
|
18
|
+
reconnect: (id: PROVIDER_ID) => Promise<void>;
|
|
19
|
+
disconnect: (id: PROVIDER_ID) => Promise<void>;
|
|
20
|
+
setActive: (id: PROVIDER_ID) => Promise<void>;
|
|
21
|
+
reconnectProviders: () => Promise<void>;
|
|
22
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PROVIDER_ID } from "../types";
|
|
2
|
+
export { PROVIDER_ID };
|
|
3
|
+
export default function useWallet(): {
|
|
4
|
+
accounts: import("../types").Account[];
|
|
5
|
+
activeAccount: import("../types").Account | null;
|
|
6
|
+
signTransactions: (transactions: Array<Uint8Array>) => Promise<Uint8Array[]>;
|
|
7
|
+
sendTransactions: (transactions: Uint8Array[]) => Promise<import("../types").ConfirmedTxn & {
|
|
8
|
+
id: string;
|
|
9
|
+
}>;
|
|
10
|
+
};
|