@aptos-labs/wallet-adapter-react 0.2.0 → 0.2.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @aptos-labs/wallet-adapter-react
2
2
 
3
+ ## 0.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 552d255: Add react package as a dependency
8
+
9
+ ## 0.2.1
10
+
11
+ ### Patch Changes
12
+
13
+ - c3eb031: Export WalletReadyState enum from react package
14
+
3
15
  ## 0.2.0
4
16
 
5
17
  ### Minor Changes
package/README.md CHANGED
@@ -4,6 +4,25 @@ A react provider wrapper for the Aptos Wallet Adapter
4
4
 
5
5
  Dapps that want to use the adapter should install this package and other supported wallet packages.
6
6
 
7
+ ### Support
8
+
9
+ The react provider supports all [wallet standard](https://aptos.dev/guides/wallet-standard) functions and feature functions
10
+
11
+ ##### Standard functions
12
+
13
+ connect
14
+ disconnect
15
+ connected
16
+ account
17
+ network
18
+ signAndSubmitTransaction
19
+ signMessage
20
+
21
+ ##### Feature functions
22
+
23
+ signTransaction
24
+ signMessageAndVerify
25
+
7
26
  ### Usage
8
27
 
9
28
  #### Install Dependencies
@@ -71,6 +90,7 @@ const {
71
90
  signAndSubmitTransaction,
72
91
  signTransaction,
73
92
  signMessage,
93
+ signMessageAndVerify,
74
94
  } = useWallet();
75
95
  ```
76
96
 
@@ -113,29 +133,6 @@ const {
113
133
  </button>
114
134
  ```
115
135
 
116
- ##### signTransaction(payload)
117
-
118
- ```js
119
- const onSignTransaction = async () => {
120
- const payload: Types.TransactionPayload = {
121
- type: "entry_function_payload",
122
- function: "0x1::coin::transfer",
123
- type_arguments: ["0x1::aptos_coin::AptosCoin"],
124
- arguments: [account?.address, 1], // 1 is in Octas
125
- };
126
- try {
127
- const response = await signTransaction(payload);
128
- console.log("response", response);
129
- } catch (error: any) {
130
- console.log("error", error);
131
- }
132
- };
133
-
134
- <button onClick={onSignTransaction}>
135
- Sign transaction
136
- </button>
137
- ```
138
-
139
136
  ##### signMessage(payload)
140
137
 
141
138
  ```js
@@ -185,3 +182,47 @@ const {
185
182
  wallets.map((wallet) => <p>{wallet.name}</p>);
186
183
  }
187
184
  ```
185
+
186
+ ##### signTransaction(payload)
187
+
188
+ ```js
189
+ const onSignTransaction = async () => {
190
+ const payload: Types.TransactionPayload = {
191
+ type: "entry_function_payload",
192
+ function: "0x1::coin::transfer",
193
+ type_arguments: ["0x1::aptos_coin::AptosCoin"],
194
+ arguments: [account?.address, 1], // 1 is in Octas
195
+ };
196
+ try {
197
+ const response = await signTransaction(payload);
198
+ console.log("response", response);
199
+ } catch (error: any) {
200
+ console.log("error", error);
201
+ }
202
+ };
203
+
204
+ <button onClick={onSignTransaction}>
205
+ Sign transaction
206
+ </button>
207
+ ```
208
+
209
+ ##### signMessageAndVerify(payload)
210
+
211
+ ```js
212
+ const onSignMessageAndVerify = async () => {
213
+ const payload = {
214
+ message: "Hello from Aptos Wallet Adapter",
215
+ nonce: "random_string",
216
+ };
217
+ try {
218
+ const response = await signMessageAndVerify(payload);
219
+ console.log("response", response);
220
+ } catch (error: any) {
221
+ console.log("error", error);
222
+ }
223
+ };
224
+
225
+ <button onClick={onSignMessageAndVerify}>
226
+ Sign message and verify
227
+ </button>
228
+ ```
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { AccountInfo, NetworkInfo, WalletName, WalletInfo, Wallet, SignMessagePayload, SignMessageResponse } from '@aptos-labs/wallet-adapter-core';
2
+ export { WalletName, WalletReadyState } from '@aptos-labs/wallet-adapter-core';
2
3
  import { Types } from 'aptos';
3
4
  import { ReactNode, FC } from 'react';
4
5
 
package/dist/index.js CHANGED
@@ -21,11 +21,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var src_exports = {};
22
22
  __export(src_exports, {
23
23
  AptosWalletAdapterProvider: () => AptosWalletAdapterProvider,
24
+ WalletReadyState: () => import_wallet_adapter_core.WalletReadyState,
24
25
  useWallet: () => useWallet
25
26
  });
26
27
  module.exports = __toCommonJS(src_exports);
27
28
 
28
29
  // src/useWallet.tsx
30
+ var import_wallet_adapter_core = require("@aptos-labs/wallet-adapter-core");
29
31
  var import_react = require("react");
30
32
  var DEFAULT_COUNTEXT = {
31
33
  connected: false
@@ -43,7 +45,7 @@ function useWallet() {
43
45
 
44
46
  // src/WalletProvider.tsx
45
47
  var import_react2 = require("react");
46
- var import_wallet_adapter_core = require("@aptos-labs/wallet-adapter-core");
48
+ var import_wallet_adapter_core2 = require("@aptos-labs/wallet-adapter-core");
47
49
  var import_jsx_runtime = require("react/jsx-runtime");
48
50
  var initialState = {
49
51
  connected: false,
@@ -57,7 +59,7 @@ var AptosWalletAdapterProvider = ({
57
59
  autoConnect = false
58
60
  }) => {
59
61
  const [{ connected, account, network, wallet }, setState] = (0, import_react2.useState)(initialState);
60
- const walletCore = (0, import_react2.useMemo)(() => new import_wallet_adapter_core.WalletCore(plugins), []);
62
+ const walletCore = (0, import_react2.useMemo)(() => new import_wallet_adapter_core2.WalletCore(plugins), []);
61
63
  const [wallets, setWallets] = (0, import_react2.useState)(walletCore.wallets);
62
64
  const connect = (walletName) => {
63
65
  try {
@@ -210,5 +212,6 @@ var AptosWalletAdapterProvider = ({
210
212
  // Annotate the CommonJS export names for ESM import in node:
211
213
  0 && (module.exports = {
212
214
  AptosWalletAdapterProvider,
215
+ WalletReadyState,
213
216
  useWallet
214
217
  });
package/dist/index.mjs CHANGED
@@ -1,4 +1,7 @@
1
1
  // src/useWallet.tsx
2
+ import {
3
+ WalletReadyState
4
+ } from "@aptos-labs/wallet-adapter-core";
2
5
  import { createContext, useContext } from "react";
3
6
  var DEFAULT_COUNTEXT = {
4
7
  connected: false
@@ -187,5 +190,6 @@ var AptosWalletAdapterProvider = ({
187
190
  };
188
191
  export {
189
192
  AptosWalletAdapterProvider,
193
+ WalletReadyState,
190
194
  useWallet
191
195
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aptos-labs/wallet-adapter-react",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Aptos Wallet Adapter React Provider",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -28,9 +28,6 @@
28
28
  "Wallet Adapter Provider",
29
29
  "React"
30
30
  ],
31
- "peerDependencies": {
32
- "react": "*"
33
- },
34
31
  "devDependencies": {
35
32
  "@types/react": "^18.0.17",
36
33
  "@types/react-dom": "^18.0.6",
@@ -41,7 +38,8 @@
41
38
  },
42
39
  "dependencies": {
43
40
  "@aptos-labs/wallet-adapter-core": "*",
44
- "aptos": "^1.3.17"
41
+ "aptos": "^1.3.17",
42
+ "react": "^18"
45
43
  },
46
44
  "scripts": {
47
45
  "build": "tsup src/index.tsx --format esm,cjs --dts --external react",
@@ -1,4 +1,3 @@
1
- import * as React from "react";
2
1
  import {
3
2
  FC,
4
3
  ReactNode,
package/src/index.tsx CHANGED
@@ -1,3 +1,4 @@
1
1
  import * as React from "react";
2
- export { useWallet } from "./useWallet";
2
+ export { useWallet, WalletReadyState } from "./useWallet";
3
+ export type { WalletName } from "./useWallet";
3
4
  export * from "./WalletProvider";
package/src/useWallet.tsx CHANGED
@@ -6,11 +6,13 @@ import {
6
6
  SignMessagePayload,
7
7
  SignMessageResponse,
8
8
  Wallet,
9
+ WalletReadyState,
9
10
  } from "@aptos-labs/wallet-adapter-core";
10
11
  import { createContext, useContext } from "react";
11
12
  import { Types } from "aptos";
12
13
 
13
14
  export type { WalletName };
15
+ export { WalletReadyState };
14
16
 
15
17
  export interface WalletContextState {
16
18
  connected: boolean;