@aptos-labs/wallet-adapter-react 1.4.0 → 2.0.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.
- package/CHANGELOG.md +21 -0
- package/dist/index.d.ts +5 -7
- package/dist/index.js +17 -46
- package/dist/index.mjs +17 -46
- package/package.json +2 -2
- package/src/WalletProvider.tsx +37 -56
- package/src/index.tsx +1 -1
- package/src/useWallet.tsx +23 -24
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @aptos-labs/wallet-adapter-react
|
|
2
2
|
|
|
3
|
+
## 2.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 31e0084: Support TypeScript SDK V2. Fully compatible with existing SDK V1 and Wallet Adapter V1
|
|
8
|
+
but with a full SDK V2 support for the dapp.
|
|
9
|
+
|
|
10
|
+
- Add support for SDK V2 input types
|
|
11
|
+
- `signAndSubmitTransaction()` accept only SDK V2 transaction input type
|
|
12
|
+
- Implement a `submitTransaction()` function for multi signers transactions
|
|
13
|
+
- `signTransaction()` to support both SDK V1 and V2 versions
|
|
14
|
+
- Convert wallet `SignedTransaction` response from `signTransaction()` to TS SDK V2 `AccountAuthenticator`
|
|
15
|
+
- Demo app to demonstrate different trnsaction flows - single signer, sponsor and multi agent transactions
|
|
16
|
+
- Reject promise on core and/or provider errors instead of just returning `false`
|
|
17
|
+
- Use `@aptos-labs/ts-sdk@experimental` version `0.0.7`
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies [31e0084]
|
|
22
|
+
- @aptos-labs/wallet-adapter-core@3.0.0
|
|
23
|
+
|
|
3
24
|
## 1.4.0
|
|
4
25
|
|
|
5
26
|
### Minor Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AccountInfo, NetworkInfo, WalletName, WalletInfo, Wallet, Types,
|
|
1
|
+
import { AccountInfo, NetworkInfo, WalletName, WalletInfo, Wallet, InputGenerateTransactionData, InputGenerateTransactionOptions, AnyRawTransaction, Types, AccountAuthenticator, InputSubmitTransactionData, PendingTransactionResponse, SignMessagePayload, SignMessageResponse } from '@aptos-labs/wallet-adapter-core';
|
|
2
2
|
export { NetworkName, Wallet, WalletName, WalletReadyState, isInAppBrowser, isMobile, isRedirectable } from '@aptos-labs/wallet-adapter-core';
|
|
3
3
|
import { ReactNode, FC } from 'react';
|
|
4
4
|
|
|
@@ -11,13 +11,11 @@ interface WalletContextState {
|
|
|
11
11
|
disconnect(): void;
|
|
12
12
|
wallet: WalletInfo | null;
|
|
13
13
|
wallets: ReadonlyArray<Wallet>;
|
|
14
|
-
signAndSubmitTransaction
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
signMessage(message: SignMessagePayload): Promise<SignMessageResponse
|
|
14
|
+
signAndSubmitTransaction(transaction: InputGenerateTransactionData, options?: InputGenerateTransactionOptions): Promise<any>;
|
|
15
|
+
signTransaction(transactionOrPayload: AnyRawTransaction | Types.TransactionPayload, asFeePayer?: boolean, options?: InputGenerateTransactionOptions): Promise<AccountAuthenticator>;
|
|
16
|
+
submitTransaction(transaction: InputSubmitTransactionData): Promise<PendingTransactionResponse>;
|
|
17
|
+
signMessage(message: SignMessagePayload): Promise<SignMessageResponse>;
|
|
18
18
|
signMessageAndVerify(message: SignMessagePayload): Promise<boolean>;
|
|
19
|
-
submitTransaction(transaction: InputGenerateTransactionData): Promise<any>;
|
|
20
|
-
signMultiAgentTransaction(transaction: TxnBuilderTypes.MultiAgentRawTransaction | TxnBuilderTypes.FeePayerRawTransaction): Promise<any>;
|
|
21
19
|
}
|
|
22
20
|
declare function useWallet(): WalletContextState;
|
|
23
21
|
|
package/dist/index.js
CHANGED
|
@@ -33,11 +33,11 @@ module.exports = __toCommonJS(src_exports);
|
|
|
33
33
|
// src/useWallet.tsx
|
|
34
34
|
var import_wallet_adapter_core = require("@aptos-labs/wallet-adapter-core");
|
|
35
35
|
var import_react = require("react");
|
|
36
|
-
var
|
|
36
|
+
var DEFAULT_CONTEXT = {
|
|
37
37
|
connected: false
|
|
38
38
|
};
|
|
39
39
|
var WalletContext = (0, import_react.createContext)(
|
|
40
|
-
|
|
40
|
+
DEFAULT_CONTEXT
|
|
41
41
|
);
|
|
42
42
|
function useWallet() {
|
|
43
43
|
const context = (0, import_react.useContext)(WalletContext);
|
|
@@ -77,8 +77,7 @@ var AptosWalletAdapterProvider = ({
|
|
|
77
77
|
console.log("connect error", error);
|
|
78
78
|
if (onError)
|
|
79
79
|
onError(error);
|
|
80
|
-
|
|
81
|
-
throw error;
|
|
80
|
+
return Promise.reject(error);
|
|
82
81
|
} finally {
|
|
83
82
|
setIsLoading(false);
|
|
84
83
|
}
|
|
@@ -86,37 +85,19 @@ var AptosWalletAdapterProvider = ({
|
|
|
86
85
|
const disconnect = async () => {
|
|
87
86
|
try {
|
|
88
87
|
await walletCore.disconnect();
|
|
89
|
-
} catch (e) {
|
|
90
|
-
console.log("disconnect error", e);
|
|
91
|
-
if (onError)
|
|
92
|
-
onError(e);
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
const signAndSubmitTransaction = async (transaction, options) => {
|
|
96
|
-
try {
|
|
97
|
-
return await walletCore.signAndSubmitTransaction(transaction, options);
|
|
98
88
|
} catch (error) {
|
|
99
89
|
if (onError)
|
|
100
90
|
onError(error);
|
|
101
|
-
|
|
102
|
-
throw error;
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
const signAndSubmitBCSTransaction = async (transaction, options) => {
|
|
106
|
-
try {
|
|
107
|
-
return await walletCore.signAndSubmitBCSTransaction(transaction, options);
|
|
108
|
-
} catch (error) {
|
|
109
|
-
throw error;
|
|
91
|
+
return Promise.reject(error);
|
|
110
92
|
}
|
|
111
93
|
};
|
|
112
|
-
const signTransaction = async (transaction, options) => {
|
|
94
|
+
const signTransaction = async (transaction, asFeePayer, options) => {
|
|
113
95
|
try {
|
|
114
|
-
return await walletCore.signTransaction(transaction, options);
|
|
96
|
+
return await walletCore.signTransaction(transaction, asFeePayer, options);
|
|
115
97
|
} catch (error) {
|
|
116
98
|
if (onError)
|
|
117
99
|
onError(error);
|
|
118
|
-
|
|
119
|
-
throw error;
|
|
100
|
+
return Promise.reject(error);
|
|
120
101
|
}
|
|
121
102
|
};
|
|
122
103
|
const signMessage = async (message) => {
|
|
@@ -125,9 +106,7 @@ var AptosWalletAdapterProvider = ({
|
|
|
125
106
|
} catch (error) {
|
|
126
107
|
if (onError)
|
|
127
108
|
onError(error);
|
|
128
|
-
|
|
129
|
-
throw error;
|
|
130
|
-
return null;
|
|
109
|
+
return Promise.reject(error);
|
|
131
110
|
}
|
|
132
111
|
};
|
|
133
112
|
const signMessageAndVerify = async (message) => {
|
|
@@ -136,31 +115,25 @@ var AptosWalletAdapterProvider = ({
|
|
|
136
115
|
} catch (error) {
|
|
137
116
|
if (onError)
|
|
138
117
|
onError(error);
|
|
139
|
-
|
|
140
|
-
throw error;
|
|
141
|
-
return false;
|
|
118
|
+
return Promise.reject(error);
|
|
142
119
|
}
|
|
143
120
|
};
|
|
144
|
-
const
|
|
121
|
+
const submitTransaction = async (transaction) => {
|
|
145
122
|
try {
|
|
146
|
-
return await walletCore.
|
|
123
|
+
return await walletCore.submitTransaction(transaction);
|
|
147
124
|
} catch (error) {
|
|
148
125
|
if (onError)
|
|
149
126
|
onError(error);
|
|
150
|
-
|
|
151
|
-
throw error;
|
|
152
|
-
return false;
|
|
127
|
+
return Promise.reject(error);
|
|
153
128
|
}
|
|
154
129
|
};
|
|
155
|
-
const
|
|
130
|
+
const signAndSubmitTransaction = async (transaction, options) => {
|
|
156
131
|
try {
|
|
157
|
-
return await walletCore.
|
|
132
|
+
return await walletCore.signAndSubmitTransaction(transaction, options);
|
|
158
133
|
} catch (error) {
|
|
159
134
|
if (onError)
|
|
160
135
|
onError(error);
|
|
161
|
-
|
|
162
|
-
throw error;
|
|
163
|
-
return false;
|
|
136
|
+
return Promise.reject(error);
|
|
164
137
|
}
|
|
165
138
|
};
|
|
166
139
|
(0, import_react2.useEffect)(() => {
|
|
@@ -253,13 +226,11 @@ var AptosWalletAdapterProvider = ({
|
|
|
253
226
|
wallet,
|
|
254
227
|
wallets,
|
|
255
228
|
signAndSubmitTransaction,
|
|
256
|
-
signAndSubmitBCSTransaction,
|
|
257
229
|
signTransaction,
|
|
258
230
|
signMessage,
|
|
259
231
|
signMessageAndVerify,
|
|
260
|
-
|
|
261
|
-
submitTransaction
|
|
262
|
-
isLoading
|
|
232
|
+
isLoading,
|
|
233
|
+
submitTransaction
|
|
263
234
|
},
|
|
264
235
|
children
|
|
265
236
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
isMobile
|
|
8
8
|
} from "@aptos-labs/wallet-adapter-core";
|
|
9
9
|
import { createContext, useContext } from "react";
|
|
10
|
-
var
|
|
10
|
+
var DEFAULT_CONTEXT = {
|
|
11
11
|
connected: false
|
|
12
12
|
};
|
|
13
13
|
var WalletContext = createContext(
|
|
14
|
-
|
|
14
|
+
DEFAULT_CONTEXT
|
|
15
15
|
);
|
|
16
16
|
function useWallet() {
|
|
17
17
|
const context = useContext(WalletContext);
|
|
@@ -56,8 +56,7 @@ var AptosWalletAdapterProvider = ({
|
|
|
56
56
|
console.log("connect error", error);
|
|
57
57
|
if (onError)
|
|
58
58
|
onError(error);
|
|
59
|
-
|
|
60
|
-
throw error;
|
|
59
|
+
return Promise.reject(error);
|
|
61
60
|
} finally {
|
|
62
61
|
setIsLoading(false);
|
|
63
62
|
}
|
|
@@ -65,37 +64,19 @@ var AptosWalletAdapterProvider = ({
|
|
|
65
64
|
const disconnect = async () => {
|
|
66
65
|
try {
|
|
67
66
|
await walletCore.disconnect();
|
|
68
|
-
} catch (e) {
|
|
69
|
-
console.log("disconnect error", e);
|
|
70
|
-
if (onError)
|
|
71
|
-
onError(e);
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
const signAndSubmitTransaction = async (transaction, options) => {
|
|
75
|
-
try {
|
|
76
|
-
return await walletCore.signAndSubmitTransaction(transaction, options);
|
|
77
67
|
} catch (error) {
|
|
78
68
|
if (onError)
|
|
79
69
|
onError(error);
|
|
80
|
-
|
|
81
|
-
throw error;
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
const signAndSubmitBCSTransaction = async (transaction, options) => {
|
|
85
|
-
try {
|
|
86
|
-
return await walletCore.signAndSubmitBCSTransaction(transaction, options);
|
|
87
|
-
} catch (error) {
|
|
88
|
-
throw error;
|
|
70
|
+
return Promise.reject(error);
|
|
89
71
|
}
|
|
90
72
|
};
|
|
91
|
-
const signTransaction = async (transaction, options) => {
|
|
73
|
+
const signTransaction = async (transaction, asFeePayer, options) => {
|
|
92
74
|
try {
|
|
93
|
-
return await walletCore.signTransaction(transaction, options);
|
|
75
|
+
return await walletCore.signTransaction(transaction, asFeePayer, options);
|
|
94
76
|
} catch (error) {
|
|
95
77
|
if (onError)
|
|
96
78
|
onError(error);
|
|
97
|
-
|
|
98
|
-
throw error;
|
|
79
|
+
return Promise.reject(error);
|
|
99
80
|
}
|
|
100
81
|
};
|
|
101
82
|
const signMessage = async (message) => {
|
|
@@ -104,9 +85,7 @@ var AptosWalletAdapterProvider = ({
|
|
|
104
85
|
} catch (error) {
|
|
105
86
|
if (onError)
|
|
106
87
|
onError(error);
|
|
107
|
-
|
|
108
|
-
throw error;
|
|
109
|
-
return null;
|
|
88
|
+
return Promise.reject(error);
|
|
110
89
|
}
|
|
111
90
|
};
|
|
112
91
|
const signMessageAndVerify = async (message) => {
|
|
@@ -115,31 +94,25 @@ var AptosWalletAdapterProvider = ({
|
|
|
115
94
|
} catch (error) {
|
|
116
95
|
if (onError)
|
|
117
96
|
onError(error);
|
|
118
|
-
|
|
119
|
-
throw error;
|
|
120
|
-
return false;
|
|
97
|
+
return Promise.reject(error);
|
|
121
98
|
}
|
|
122
99
|
};
|
|
123
|
-
const
|
|
100
|
+
const submitTransaction = async (transaction) => {
|
|
124
101
|
try {
|
|
125
|
-
return await walletCore.
|
|
102
|
+
return await walletCore.submitTransaction(transaction);
|
|
126
103
|
} catch (error) {
|
|
127
104
|
if (onError)
|
|
128
105
|
onError(error);
|
|
129
|
-
|
|
130
|
-
throw error;
|
|
131
|
-
return false;
|
|
106
|
+
return Promise.reject(error);
|
|
132
107
|
}
|
|
133
108
|
};
|
|
134
|
-
const
|
|
109
|
+
const signAndSubmitTransaction = async (transaction, options) => {
|
|
135
110
|
try {
|
|
136
|
-
return await walletCore.
|
|
111
|
+
return await walletCore.signAndSubmitTransaction(transaction, options);
|
|
137
112
|
} catch (error) {
|
|
138
113
|
if (onError)
|
|
139
114
|
onError(error);
|
|
140
|
-
|
|
141
|
-
throw error;
|
|
142
|
-
return false;
|
|
115
|
+
return Promise.reject(error);
|
|
143
116
|
}
|
|
144
117
|
};
|
|
145
118
|
useEffect(() => {
|
|
@@ -232,13 +205,11 @@ var AptosWalletAdapterProvider = ({
|
|
|
232
205
|
wallet,
|
|
233
206
|
wallets,
|
|
234
207
|
signAndSubmitTransaction,
|
|
235
|
-
signAndSubmitBCSTransaction,
|
|
236
208
|
signTransaction,
|
|
237
209
|
signMessage,
|
|
238
210
|
signMessageAndVerify,
|
|
239
|
-
|
|
240
|
-
submitTransaction
|
|
241
|
-
isLoading
|
|
211
|
+
isLoading,
|
|
212
|
+
submitTransaction
|
|
242
213
|
},
|
|
243
214
|
children
|
|
244
215
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aptos-labs/wallet-adapter-react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Aptos Wallet Adapter React Provider",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@aptos-labs/wallet-adapter-tsconfig": "0.0.0"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@aptos-labs/wallet-adapter-core": "
|
|
40
|
+
"@aptos-labs/wallet-adapter-core": "3.0.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"react": "^18"
|
package/src/WalletProvider.tsx
CHANGED
|
@@ -13,11 +13,15 @@ import type {
|
|
|
13
13
|
SignMessagePayload,
|
|
14
14
|
Wallet,
|
|
15
15
|
WalletInfo,
|
|
16
|
+
InputGenerateTransactionOptions,
|
|
17
|
+
AnyRawTransaction,
|
|
18
|
+
InputGenerateTransactionData,
|
|
19
|
+
InputSubmitTransactionData,
|
|
20
|
+
AccountAuthenticator,
|
|
21
|
+
PendingTransactionResponse,
|
|
22
|
+
SignMessageResponse,
|
|
16
23
|
WalletName,
|
|
17
|
-
TransactionOptions,
|
|
18
|
-
TxnBuilderTypes,
|
|
19
24
|
Types,
|
|
20
|
-
InputGenerateTransactionData,
|
|
21
25
|
} from "@aptos-labs/wallet-adapter-core";
|
|
22
26
|
import { WalletCore } from "@aptos-labs/wallet-adapter-core";
|
|
23
27
|
|
|
@@ -65,7 +69,7 @@ export const AptosWalletAdapterProvider: FC<AptosWalletProviderProps> = ({
|
|
|
65
69
|
} catch (error: any) {
|
|
66
70
|
console.log("connect error", error);
|
|
67
71
|
if (onError) onError(error);
|
|
68
|
-
|
|
72
|
+
return Promise.reject(error);
|
|
69
73
|
} finally {
|
|
70
74
|
setIsLoading(false);
|
|
71
75
|
}
|
|
@@ -74,90 +78,69 @@ export const AptosWalletAdapterProvider: FC<AptosWalletProviderProps> = ({
|
|
|
74
78
|
const disconnect = async () => {
|
|
75
79
|
try {
|
|
76
80
|
await walletCore.disconnect();
|
|
77
|
-
} catch (
|
|
78
|
-
console.log("disconnect error", e);
|
|
79
|
-
if (onError) onError(e);
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const signAndSubmitTransaction = async (
|
|
84
|
-
transaction: Types.TransactionPayload,
|
|
85
|
-
options?: TransactionOptions
|
|
86
|
-
) => {
|
|
87
|
-
try {
|
|
88
|
-
return await walletCore.signAndSubmitTransaction(transaction, options);
|
|
89
|
-
} catch (error: any) {
|
|
81
|
+
} catch (error) {
|
|
90
82
|
if (onError) onError(error);
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
const signAndSubmitBCSTransaction = async (
|
|
96
|
-
transaction: TxnBuilderTypes.TransactionPayload,
|
|
97
|
-
options?: TransactionOptions
|
|
98
|
-
) => {
|
|
99
|
-
try {
|
|
100
|
-
return await walletCore.signAndSubmitBCSTransaction(transaction, options);
|
|
101
|
-
} catch (error: any) {
|
|
102
|
-
throw error;
|
|
83
|
+
return Promise.reject(error);
|
|
103
84
|
}
|
|
104
85
|
};
|
|
105
86
|
|
|
106
87
|
const signTransaction = async (
|
|
107
|
-
transaction: Types.TransactionPayload,
|
|
108
|
-
|
|
109
|
-
|
|
88
|
+
transaction: AnyRawTransaction | Types.TransactionPayload,
|
|
89
|
+
asFeePayer?: boolean,
|
|
90
|
+
options?: InputGenerateTransactionOptions
|
|
91
|
+
): Promise<AccountAuthenticator> => {
|
|
110
92
|
try {
|
|
111
|
-
return await walletCore.signTransaction(transaction, options);
|
|
93
|
+
return await walletCore.signTransaction(transaction, asFeePayer, options);
|
|
112
94
|
} catch (error: any) {
|
|
113
95
|
if (onError) onError(error);
|
|
114
|
-
|
|
96
|
+
return Promise.reject(error);
|
|
115
97
|
}
|
|
116
98
|
};
|
|
117
99
|
|
|
118
|
-
const signMessage = async (
|
|
100
|
+
const signMessage = async (
|
|
101
|
+
message: SignMessagePayload
|
|
102
|
+
): Promise<SignMessageResponse> => {
|
|
119
103
|
try {
|
|
120
104
|
return await walletCore.signMessage(message);
|
|
121
105
|
} catch (error: any) {
|
|
122
106
|
if (onError) onError(error);
|
|
123
|
-
|
|
124
|
-
return null;
|
|
107
|
+
return Promise.reject(error);
|
|
125
108
|
}
|
|
126
109
|
};
|
|
127
110
|
|
|
128
|
-
const signMessageAndVerify = async (
|
|
111
|
+
const signMessageAndVerify = async (
|
|
112
|
+
message: SignMessagePayload
|
|
113
|
+
): Promise<boolean> => {
|
|
129
114
|
try {
|
|
130
115
|
return await walletCore.signMessageAndVerify(message);
|
|
131
116
|
} catch (error: any) {
|
|
132
117
|
if (onError) onError(error);
|
|
133
|
-
|
|
134
|
-
return false;
|
|
118
|
+
return Promise.reject(error);
|
|
135
119
|
}
|
|
136
120
|
};
|
|
137
121
|
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
) => {
|
|
122
|
+
const submitTransaction = async (
|
|
123
|
+
transaction: InputSubmitTransactionData
|
|
124
|
+
): Promise<PendingTransactionResponse> => {
|
|
141
125
|
try {
|
|
142
|
-
return await walletCore.
|
|
126
|
+
return await walletCore.submitTransaction(transaction);
|
|
143
127
|
} catch (error: any) {
|
|
144
128
|
if (onError) onError(error);
|
|
145
|
-
|
|
146
|
-
return false;
|
|
129
|
+
return Promise.reject(error);
|
|
147
130
|
}
|
|
148
|
-
}
|
|
131
|
+
};
|
|
149
132
|
|
|
150
|
-
const
|
|
151
|
-
|
|
133
|
+
const signAndSubmitTransaction = async (
|
|
134
|
+
transaction: InputGenerateTransactionData,
|
|
135
|
+
options?: InputGenerateTransactionOptions
|
|
152
136
|
) => {
|
|
153
137
|
try {
|
|
154
|
-
return await walletCore.
|
|
138
|
+
return await walletCore.signAndSubmitTransaction(transaction, options);
|
|
155
139
|
} catch (error: any) {
|
|
156
140
|
if (onError) onError(error);
|
|
157
|
-
|
|
158
|
-
return false;
|
|
141
|
+
return Promise.reject(error);
|
|
159
142
|
}
|
|
160
|
-
}
|
|
143
|
+
};
|
|
161
144
|
|
|
162
145
|
useEffect(() => {
|
|
163
146
|
if (autoConnect) {
|
|
@@ -261,13 +244,11 @@ export const AptosWalletAdapterProvider: FC<AptosWalletProviderProps> = ({
|
|
|
261
244
|
wallet,
|
|
262
245
|
wallets,
|
|
263
246
|
signAndSubmitTransaction,
|
|
264
|
-
signAndSubmitBCSTransaction,
|
|
265
247
|
signTransaction,
|
|
266
248
|
signMessage,
|
|
267
249
|
signMessageAndVerify,
|
|
268
|
-
signMultiAgentTransaction,
|
|
269
|
-
submitTransaction,
|
|
270
250
|
isLoading,
|
|
251
|
+
submitTransaction,
|
|
271
252
|
}}
|
|
272
253
|
>
|
|
273
254
|
{children}
|
package/src/index.tsx
CHANGED
package/src/useWallet.tsx
CHANGED
|
@@ -2,7 +2,6 @@ import {
|
|
|
2
2
|
AccountInfo,
|
|
3
3
|
NetworkInfo,
|
|
4
4
|
WalletInfo,
|
|
5
|
-
WalletName,
|
|
6
5
|
SignMessagePayload,
|
|
7
6
|
SignMessageResponse,
|
|
8
7
|
Wallet,
|
|
@@ -11,20 +10,24 @@ import {
|
|
|
11
10
|
isInAppBrowser,
|
|
12
11
|
isRedirectable,
|
|
13
12
|
isMobile,
|
|
14
|
-
|
|
15
|
-
TxnBuilderTypes,
|
|
16
|
-
Types,
|
|
13
|
+
InputGenerateTransactionOptions,
|
|
17
14
|
InputGenerateTransactionData,
|
|
15
|
+
AnyRawTransaction,
|
|
16
|
+
InputSubmitTransactionData,
|
|
17
|
+
PendingTransactionResponse,
|
|
18
|
+
AccountAuthenticator,
|
|
19
|
+
Types,
|
|
20
|
+
WalletName,
|
|
18
21
|
} from "@aptos-labs/wallet-adapter-core";
|
|
19
22
|
import { createContext, useContext } from "react";
|
|
20
23
|
|
|
21
|
-
export type {
|
|
24
|
+
export type { Wallet, WalletName };
|
|
22
25
|
export {
|
|
23
26
|
WalletReadyState,
|
|
24
|
-
NetworkName,
|
|
25
27
|
isInAppBrowser,
|
|
26
28
|
isRedirectable,
|
|
27
29
|
isMobile,
|
|
30
|
+
NetworkName,
|
|
28
31
|
};
|
|
29
32
|
|
|
30
33
|
export interface WalletContextState {
|
|
@@ -36,32 +39,28 @@ export interface WalletContextState {
|
|
|
36
39
|
disconnect(): void;
|
|
37
40
|
wallet: WalletInfo | null;
|
|
38
41
|
wallets: ReadonlyArray<Wallet>;
|
|
39
|
-
signAndSubmitTransaction
|
|
40
|
-
transaction:
|
|
41
|
-
options?:
|
|
42
|
-
): Promise<any>;
|
|
43
|
-
signAndSubmitBCSTransaction<T extends TxnBuilderTypes.TransactionPayload>(
|
|
44
|
-
transaction: T,
|
|
45
|
-
options?: TransactionOptions
|
|
42
|
+
signAndSubmitTransaction(
|
|
43
|
+
transaction: InputGenerateTransactionData,
|
|
44
|
+
options?: InputGenerateTransactionOptions
|
|
46
45
|
): Promise<any>;
|
|
47
|
-
signTransaction
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
signTransaction(
|
|
47
|
+
transactionOrPayload: AnyRawTransaction | Types.TransactionPayload,
|
|
48
|
+
asFeePayer?: boolean,
|
|
49
|
+
options?: InputGenerateTransactionOptions
|
|
50
|
+
): Promise<AccountAuthenticator>;
|
|
51
|
+
submitTransaction(
|
|
52
|
+
transaction: InputSubmitTransactionData
|
|
53
|
+
): Promise<PendingTransactionResponse>;
|
|
54
|
+
signMessage(message: SignMessagePayload): Promise<SignMessageResponse>;
|
|
52
55
|
signMessageAndVerify(message: SignMessagePayload): Promise<boolean>;
|
|
53
|
-
submitTransaction(transaction: InputGenerateTransactionData): Promise<any>;
|
|
54
|
-
signMultiAgentTransaction(
|
|
55
|
-
transaction: TxnBuilderTypes.MultiAgentRawTransaction | TxnBuilderTypes.FeePayerRawTransaction,
|
|
56
|
-
): Promise<any>;
|
|
57
56
|
}
|
|
58
57
|
|
|
59
|
-
const
|
|
58
|
+
const DEFAULT_CONTEXT = {
|
|
60
59
|
connected: false,
|
|
61
60
|
};
|
|
62
61
|
|
|
63
62
|
export const WalletContext = createContext<WalletContextState>(
|
|
64
|
-
|
|
63
|
+
DEFAULT_CONTEXT as WalletContextState
|
|
65
64
|
);
|
|
66
65
|
|
|
67
66
|
export function useWallet(): WalletContextState {
|