@aptos-labs/wallet-adapter-react 0.0.0-aip-62-20240325204648

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 ADDED
@@ -0,0 +1,250 @@
1
+ # @aptos-labs/wallet-adapter-react
2
+
3
+ ## 0.0.0-aip-62-20240325204648
4
+
5
+ ### Minor Changes
6
+
7
+ - Add support for AIP-62 new wallet standard
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+ - @aptos-labs/wallet-adapter-core@0.0.0-aip-62-20240325204648
13
+
14
+ ## 2.1.8
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies [8ebd4c7]
19
+ - @aptos-labs/wallet-adapter-core@3.6.0
20
+
21
+ ## 2.1.7
22
+
23
+ ### Patch Changes
24
+
25
+ - Updated dependencies [4ca4201]
26
+ - @aptos-labs/wallet-adapter-core@3.5.0
27
+
28
+ ## 2.1.6
29
+
30
+ ### Patch Changes
31
+
32
+ - Updated dependencies [e1e9eb2]
33
+ - @aptos-labs/wallet-adapter-core@3.4.0
34
+
35
+ ## 2.1.5
36
+
37
+ ### Patch Changes
38
+
39
+ - Updated dependencies [570cbda]
40
+ - @aptos-labs/wallet-adapter-core@3.3.0
41
+
42
+ ## 2.1.4
43
+
44
+ ### Patch Changes
45
+
46
+ - Updated dependencies [3f38c51]
47
+ - @aptos-labs/wallet-adapter-core@3.2.1
48
+
49
+ ## 2.1.3
50
+
51
+ ### Patch Changes
52
+
53
+ - Updated dependencies [12163ca]
54
+ - Updated dependencies [a6f0e46]
55
+ - @aptos-labs/wallet-adapter-core@3.2.0
56
+
57
+ ## 2.1.2
58
+
59
+ ### Patch Changes
60
+
61
+ - a1c08cc: Export missing InputTransactionData type
62
+
63
+ ## 2.1.1
64
+
65
+ ### Patch Changes
66
+
67
+ - 6266a29: Consolidate options argument on signAndSubmitTransaction
68
+ - Updated dependencies [6266a29]
69
+ - @aptos-labs/wallet-adapter-core@3.1.1
70
+
71
+ ## 2.1.0
72
+
73
+ ### Minor Changes
74
+
75
+ - aa3d15a: Make sender optional when sign and submit single signer transaction
76
+
77
+ ### Patch Changes
78
+
79
+ - Updated dependencies [6257015]
80
+ - Updated dependencies [aa3d15a]
81
+ - @aptos-labs/wallet-adapter-core@3.1.0
82
+
83
+ ## 2.0.0
84
+
85
+ ### Major Changes
86
+
87
+ - 31e0084: Support TypeScript SDK V2. Fully compatible with existing SDK V1 and Wallet Adapter V1
88
+ but with a full SDK V2 support for the dapp.
89
+
90
+ - Add support for SDK V2 input types
91
+ - `signAndSubmitTransaction()` accept only SDK V2 transaction input type
92
+ - Implement a `submitTransaction()` function for multi signers transactions
93
+ - `signTransaction()` to support both SDK V1 and V2 versions
94
+ - Convert wallet `SignedTransaction` response from `signTransaction()` to TS SDK V2 `AccountAuthenticator`
95
+ - Demo app to demonstrate different trnsaction flows - single signer, sponsor and multi agent transactions
96
+ - Reject promise on core and/or provider errors instead of just returning `false`
97
+ - Use `@aptos-labs/ts-sdk@experimental` version `0.0.7`
98
+
99
+ ### Patch Changes
100
+
101
+ - Updated dependencies [31e0084]
102
+ - @aptos-labs/wallet-adapter-core@3.0.0
103
+
104
+ ## 1.4.0
105
+
106
+ ### Minor Changes
107
+
108
+ - 7acfa69: Adding support for the new Typescript SDK in the package `@aptos-labs/ts-sdk`. The wallet adapter now supports submitting a basic transaction with the new SDK types.
109
+
110
+ ### Patch Changes
111
+
112
+ - dd6e1ed: Moves dependencies to peer dependencies as needed
113
+ - Updated dependencies [7acfa69]
114
+ - Updated dependencies [dd6e1ed]
115
+ - @aptos-labs/wallet-adapter-core@2.6.0
116
+
117
+ ## 1.3.2
118
+
119
+ ### Patch Changes
120
+
121
+ - 7e314e5: Update aptos dependency
122
+ - Updated dependencies [7e314e5]
123
+ - @aptos-labs/wallet-adapter-core@2.5.1
124
+
125
+ ## 1.3.1
126
+
127
+ ### Patch Changes
128
+
129
+ - Updated dependencies [c95933a]
130
+ - @aptos-labs/wallet-adapter-core@2.5.0
131
+
132
+ ## 1.3.0
133
+
134
+ ### Minor Changes
135
+
136
+ - 3834890: Add an optional `onError` prop to error handle wallet callbacks
137
+
138
+ ### Patch Changes
139
+
140
+ - Updated dependencies [d2a0bbd]
141
+ - Updated dependencies [b0586e8]
142
+ - @aptos-labs/wallet-adapter-core@2.4.0
143
+
144
+ ## 1.2.3
145
+
146
+ ### Patch Changes
147
+
148
+ - dc98bf4: fix sendAndSubmitTransaction params
149
+ - Updated dependencies [dc98bf4]
150
+ - @aptos-labs/wallet-adapter-core@2.3.3
151
+
152
+ ## 1.2.2
153
+
154
+ ### Patch Changes
155
+
156
+ - 22ecf6a: Throw `wallet already connected` error when trying to connect to an already connected wallet
157
+ - e4b06de: Await for wallet connect request before setting isLoading state
158
+ - Updated dependencies [22ecf6a]
159
+ - @aptos-labs/wallet-adapter-core@2.3.2
160
+
161
+ ## 1.2.1
162
+
163
+ ### Patch Changes
164
+
165
+ - Updated dependencies [06f334f]
166
+ - @aptos-labs/wallet-adapter-core@2.3.1
167
+
168
+ ## 1.2.0
169
+
170
+ ### Minor Changes
171
+
172
+ - 1605d28: Support ReadonlyArray of Wallets in AptosWalletAdapterProvider and WalletCore
173
+
174
+ ### Patch Changes
175
+
176
+ - Updated dependencies [bb1595e]
177
+ - Updated dependencies [1605d28]
178
+ - @aptos-labs/wallet-adapter-core@2.3.0
179
+
180
+ ## 1.1.0
181
+
182
+ ### Minor Changes
183
+
184
+ - d8d5a8a: Support deeplink on React Provider and Nextjs demo app
185
+
186
+ ## 1.0.6
187
+
188
+ ### Patch Changes
189
+
190
+ - Updated dependencies [814939c]
191
+ - @aptos-labs/wallet-adapter-core@2.2.0
192
+
193
+ ## 1.0.5
194
+
195
+ ### Patch Changes
196
+
197
+ - 56a3f9f: BCS transaction support in react provider package
198
+
199
+ ## 1.0.4
200
+
201
+ ### Patch Changes
202
+
203
+ - 8dea640: Fix wallet adapter auto reconnect on page refresh
204
+ - Updated dependencies [50968c4]
205
+ - Updated dependencies [8dea640]
206
+ - @aptos-labs/wallet-adapter-core@2.1.0
207
+
208
+ ## 1.0.3
209
+
210
+ ### Patch Changes
211
+
212
+ - 03eb0f5: Define core package version to use
213
+
214
+ ## 0.2.4
215
+
216
+ ### Patch Changes
217
+
218
+ - e03f79c: Update Blocto and Martian package version and fix a minor autoConnect bug
219
+
220
+ ## 0.2.3
221
+
222
+ ### Patch Changes
223
+
224
+ - 7498973: Support Loadable wallet for ant-design and export NetworkName
225
+
226
+ ## 0.2.2
227
+
228
+ ### Patch Changes
229
+
230
+ - 552d255: Add react package as a dependency
231
+
232
+ ## 0.2.1
233
+
234
+ ### Patch Changes
235
+
236
+ - c3eb031: Export WalletReadyState enum from react package
237
+
238
+ ## 0.2.0
239
+
240
+ ### Minor Changes
241
+
242
+ - 6e53116: Add support to verify a signed message
243
+
244
+ ### Patch Changes
245
+
246
+ - Updated dependencies [18a0429]
247
+ - Updated dependencies [42e29f6]
248
+ - Updated dependencies [576bb57]
249
+ - Updated dependencies [6e53116]
250
+ - @aptos-labs/wallet-adapter-core@0.2.0
package/README.md ADDED
@@ -0,0 +1,263 @@
1
+ > **_NOTE:_** This documentation is for Wallet Adapter `v2.0.0` and up that is fully comatible with the Aptos TypeScript SDK V2. For Wallet Adapter `v^1.*.*` refer to [this guide](./READMEV1.md)
2
+
3
+ # Wallet Adapter React Provider
4
+
5
+ A react provider wrapper for the Aptos Wallet Adapter
6
+
7
+ Dapps that want to use the adapter should install this package and other supported wallet packages.
8
+
9
+ ### Support
10
+
11
+ The react provider supports all [wallet standard](https://aptos.dev/guides/wallet-standard) functions and feature functions
12
+
13
+ ##### Standard functions
14
+
15
+ ```
16
+ connect
17
+ disconnect
18
+ connected
19
+ account
20
+ network
21
+ signAndSubmitTransaction
22
+ signMessage
23
+ ```
24
+
25
+ ##### Feature functions - functions that may not be supported by all wallets
26
+
27
+ ```
28
+ signTransaction
29
+ signMessageAndVerify
30
+ signAndSubmitBCSTransaction
31
+ submitTransaction
32
+ ```
33
+
34
+ ### Usage
35
+
36
+ #### Install Dependencies
37
+
38
+ Install wallet dependencies you want to include in your app.
39
+ To do that, you can look at our [supported wallets list](https://github.com/aptos-labs/aptos-wallet-adapter#supported-wallet-packages). Each wallet is a link to npm package where you can install it from.
40
+
41
+ Next, install the `@aptos-labs/wallet-adapter-react`
42
+
43
+ ```
44
+ pnpm i @aptos-labs/wallet-adapter-react
45
+ ```
46
+
47
+ using npm
48
+
49
+ ```
50
+ npm i @aptos-labs/wallet-adapter-react
51
+ ```
52
+
53
+ #### Import dependencies
54
+
55
+ On the `App.jsx` file,
56
+
57
+ Import the installed wallets.
58
+
59
+ ```js
60
+ import { SomeAptosWallet } from "some-aptos-wallet-package";
61
+ ```
62
+
63
+ Import the `AptosWalletAdapterProvider`.
64
+
65
+ ```js
66
+ import { AptosWalletAdapterProvider } from "@aptos-labs/wallet-adapter-react";
67
+ ```
68
+
69
+ Wrap your app with the Provider, pass it the `plugins (wallets)` you want to have on your app as an array and a `autoConnect` option (set to false by default)
70
+
71
+ ```js
72
+ const wallets = [new AptosWallet()];
73
+
74
+ <AptosWalletAdapterProvider
75
+ plugins={wallets}
76
+ autoConnect={true}
77
+ onError={(error) => {
78
+ console.log("error", error);
79
+ }}
80
+ >
81
+ <App />
82
+ </AptosWalletAdapterProvider>;
83
+ ```
84
+
85
+ #### Use Wallet
86
+
87
+ On any page you want to use the wallet props, import `useWallet` from `@aptos-labs/wallet-adapter-react`
88
+
89
+ ```js
90
+ import { useWallet } from "@aptos-labs/wallet-adapter-react";
91
+ ```
92
+
93
+ Then you can use the exported properties
94
+
95
+ ```js
96
+ const {
97
+ connect,
98
+ account,
99
+ network,
100
+ connected,
101
+ disconnect,
102
+ wallet,
103
+ wallets,
104
+ signAndSubmitTransaction,
105
+ signAndSubmitBCSTransaction,
106
+ signTransaction,
107
+ signMessage,
108
+ signMessageAndVerify,
109
+ } = useWallet();
110
+ ```
111
+
112
+ ### Use a UI package (recommended)
113
+
114
+ As part of the wallet adapter repo we provide a wallet connect UI package that provides a wallet connect button and a wallet select modal.
115
+ You can find it [here](../wallet-adapter-ant-design/) with instructions on how to use it.
116
+
117
+ #### Examples
118
+
119
+ ##### Initialize Aptos
120
+
121
+ ```js
122
+ const aptosConfig = new AptosConfig({ network: Network.TESTNET });
123
+ const aptos = new Aptos(aptosConfig);
124
+ ```
125
+
126
+ ##### connect(walletName)
127
+
128
+ ```js
129
+ const onConnect = async (walletName) => {
130
+ await connect(walletName);
131
+ };
132
+
133
+ <button onClick={() => onConnect(wallet.name)}>{wallet.name}</button>;
134
+ ```
135
+
136
+ ##### disconnect()
137
+
138
+ ```js
139
+ <button onClick={disconnect}>Disconnect</button>
140
+ ```
141
+
142
+ ##### signAndSubmitTransaction(payload)
143
+
144
+ ```js
145
+ const onSignAndSubmitTransaction = async () => {
146
+ const response = await signAndSubmitTransaction({
147
+ sender: account.address,
148
+ data: {
149
+ function: "0x1::coin::transfer",
150
+ typeArguments: ["0x1::aptos_coin::AptosCoin"],
151
+ functionArguments: [account.address, 1],
152
+ },
153
+ });
154
+ // if you want to wait for transaction
155
+ try {
156
+ await aptos.waitForTransaction({ transactionHash: response.hash });
157
+ } catch (error) {
158
+ console.error(error);
159
+ }
160
+ };
161
+
162
+ <button onClick={onSignAndSubmitTransaction}>
163
+ Sign and submit transaction
164
+ </button>;
165
+ ```
166
+
167
+ ##### signAndSubmitBCSTransaction(payload)
168
+
169
+ ```js
170
+ const onSignAndSubmitBCSTransaction = async () => {
171
+ const response = await signAndSubmitTransaction({
172
+ sender: account.address,
173
+ data: {
174
+ function: "0x1::coin::transfer",
175
+ typeArguments: [parseTypeTag(APTOS_COIN)],
176
+ functionArguments: [AccountAddress.from(account.address), new U64(1)],
177
+ },
178
+ });
179
+ // if you want to wait for transaction
180
+ try {
181
+ await aptos.waitForTransaction({ transactionHash: response.hash });
182
+ } catch (error) {
183
+ console.error(error);
184
+ }
185
+ };
186
+
187
+ <button onClick={onSignAndSubmitTransaction}>
188
+ Sign and submit BCS transaction
189
+ </button>;
190
+ ```
191
+
192
+ ##### signMessage(payload)
193
+
194
+ ```js
195
+ const onSignMessage = async () => {
196
+ const payload = {
197
+ message: "Hello from Aptos Wallet Adapter",
198
+ nonce: "random_string",
199
+ };
200
+ const response = await signMessage(payload);
201
+ };
202
+
203
+ <button onClick={onSignMessage}>Sign message</button>;
204
+ ```
205
+
206
+ ##### Account
207
+
208
+ ```js
209
+ <div>{account?.address}</div>
210
+ <div>{account?.publicKey}</div>
211
+ ```
212
+
213
+ ##### Network
214
+
215
+ ```js
216
+ <div>{network?.name}</div>
217
+ ```
218
+
219
+ ##### Wallet
220
+
221
+ ```js
222
+ <div>{wallet?.name}</div>
223
+ <div>{wallet?.icon}</div>
224
+ <div>{wallet?.url}</div>
225
+ ```
226
+
227
+ ##### Wallets
228
+
229
+ ```js
230
+ {
231
+ wallets.map((wallet) => <p>{wallet.name}</p>);
232
+ }
233
+ ```
234
+
235
+ ##### signTransaction(payload)
236
+
237
+ ```js
238
+ const onSignTransaction = async () => {
239
+ const payload = {
240
+ type: "entry_function_payload",
241
+ function: "0x1::coin::transfer",
242
+ type_arguments: ["0x1::aptos_coin::AptosCoin"],
243
+ arguments: [account?.address, 1], // 1 is in Octas
244
+ };
245
+ const response = await signTransaction(payload);
246
+ };
247
+
248
+ <button onClick={onSignTransaction}>Sign transaction</button>;
249
+ ```
250
+
251
+ ##### signMessageAndVerify(payload)
252
+
253
+ ```js
254
+ const onSignMessageAndVerify = async () => {
255
+ const payload = {
256
+ message: "Hello from Aptos Wallet Adapter",
257
+ nonce: "random_string",
258
+ };
259
+ const response = await signMessageAndVerify(payload);
260
+ };
261
+
262
+ <button onClick={onSignMessageAndVerify}>Sign message and verify</button>;
263
+ ```