@manahippo/aptos-wallet-adapter 0.1.15 → 0.1.18
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +16 -16
- package/dist/WalletAdapters/AptosWallet.d.ts.map +1 -1
- package/dist/WalletAdapters/AptosWallet.js +1 -1
- package/dist/WalletAdapters/AptosWallet.js.map +1 -1
- package/dist/WalletAdapters/FewchaWallet.d.ts.map +1 -1
- package/dist/WalletAdapters/FewchaWallet.js +19 -13
- package/dist/WalletAdapters/FewchaWallet.js.map +1 -1
- package/dist/WalletAdapters/HippoExtensionWallet.d.ts +4 -1
- package/dist/WalletAdapters/HippoExtensionWallet.d.ts.map +1 -1
- package/dist/WalletAdapters/HippoExtensionWallet.js +3 -6
- package/dist/WalletAdapters/HippoExtensionWallet.js.map +1 -1
- package/dist/WalletAdapters/HippoWallet.d.ts.map +1 -1
- package/dist/WalletAdapters/HippoWallet.js +3 -2
- package/dist/WalletAdapters/HippoWallet.js.map +1 -1
- package/dist/WalletAdapters/MartianWallet.d.ts +2 -1
- package/dist/WalletAdapters/MartianWallet.d.ts.map +1 -1
- package/dist/WalletAdapters/MartianWallet.js +11 -5
- package/dist/WalletAdapters/MartianWallet.js.map +1 -1
- package/dist/WalletAdapters/MultiMaskWallet.js +1 -1
- package/dist/WalletAdapters/MultiMaskWallet.js.map +1 -1
- package/dist/WalletAdapters/NightlyWallet.d.ts +0 -41
- package/dist/WalletAdapters/NightlyWallet.d.ts.map +1 -1
- package/dist/WalletAdapters/NightlyWallet.js +229 -199
- package/dist/WalletAdapters/NightlyWallet.js.map +1 -1
- package/dist/WalletAdapters/index.d.ts +0 -1
- package/dist/WalletAdapters/index.d.ts.map +1 -1
- package/dist/WalletAdapters/index.js +1 -1
- package/dist/WalletAdapters/index.js.map +1 -1
- package/dist/WalletProviders/WalletProvider.d.ts.map +1 -1
- package/dist/WalletProviders/WalletProvider.js.map +1 -1
- package/dist/WalletProviders/useWallet.d.ts.map +1 -1
- package/dist/WalletProviders/useWallet.js.map +1 -1
- package/package.json +9 -9
- package/src/WalletAdapters/AptosWallet.ts +1 -4
- package/src/WalletAdapters/FewchaWallet.ts +26 -18
- package/src/WalletAdapters/HippoExtensionWallet.ts +10 -7
- package/src/WalletAdapters/HippoWallet.ts +4 -9
- package/src/WalletAdapters/MartianWallet.ts +11 -8
- package/src/WalletAdapters/MultiMaskWallet.ts +1 -1
- package/src/WalletAdapters/NightlyWallet.ts +229 -229
- package/src/WalletAdapters/index.ts +1 -1
- package/src/WalletProviders/WalletProvider.tsx +0 -1
- package/src/WalletProviders/useWallet.ts +0 -1
@@ -3,7 +3,7 @@ import {
|
|
3
3
|
SubmitTransactionRequest,
|
4
4
|
TransactionPayload
|
5
5
|
} from 'aptos/dist/api/data-contracts';
|
6
|
-
import {
|
6
|
+
import { WEBWALLET_URL } from '../config/aptosConstants';
|
7
7
|
import {
|
8
8
|
WalletDisconnectionError,
|
9
9
|
WalletNotConnectedError,
|
@@ -14,7 +14,6 @@ import Web3, { Web3Provider, Web3ProviderType } from '@fewcha/web3';
|
|
14
14
|
import {
|
15
15
|
AccountKeys,
|
16
16
|
BaseWalletAdapter,
|
17
|
-
PublicKey,
|
18
17
|
scopePollingDetectionStrategy,
|
19
18
|
WalletName,
|
20
19
|
WalletReadyState
|
@@ -22,8 +21,13 @@ import {
|
|
22
21
|
|
23
22
|
export const FewchaWalletName = 'Fewcha Wallet' as WalletName<'Fewcha Wallet'>;
|
24
23
|
|
25
|
-
|
26
|
-
|
24
|
+
interface FewchaWindow extends Window {
|
25
|
+
fewcha: Web3ProviderType;
|
26
|
+
}
|
27
|
+
|
28
|
+
declare const window: FewchaWindow;
|
29
|
+
|
30
|
+
const defaultWeb3 = new Web3(new Web3Provider(window.fewcha));
|
27
31
|
|
28
32
|
export interface FewchaAdapterConfig {
|
29
33
|
provider?: string;
|
@@ -65,12 +69,7 @@ export class FewchaWalletAdapter extends BaseWalletAdapter {
|
|
65
69
|
|
66
70
|
if (this._readyState !== WalletReadyState.Unsupported) {
|
67
71
|
scopePollingDetectionStrategy(() => {
|
68
|
-
|
69
|
-
|
70
|
-
if (wallet) {
|
71
|
-
const provider = new Web3Provider(wallet);
|
72
|
-
const web3 = new Web3(provider);
|
73
|
-
this._provider = web3.action;
|
72
|
+
if (window.fewcha) {
|
74
73
|
this._readyState = WalletReadyState.Installed;
|
75
74
|
this.emit('readyStateChange', this._readyState);
|
76
75
|
return true;
|
@@ -80,9 +79,8 @@ export class FewchaWalletAdapter extends BaseWalletAdapter {
|
|
80
79
|
}
|
81
80
|
|
82
81
|
window.addEventListener('aptos#connected', async () => {
|
83
|
-
const publicAccount = await this._provider?.account();
|
82
|
+
const publicAccount: any = await this._provider?.account();
|
84
83
|
const isConnected = await this._provider?.isConnected();
|
85
|
-
console.log('loginnnn>>', publicAccount, publicAccount?.publicKey);
|
86
84
|
if (publicAccount?.publicKey && isConnected) {
|
87
85
|
this._wallet = {
|
88
86
|
connected: isConnected,
|
@@ -92,8 +90,10 @@ export class FewchaWalletAdapter extends BaseWalletAdapter {
|
|
92
90
|
}
|
93
91
|
});
|
94
92
|
|
95
|
-
window.addEventListener('aptos#transaction', (e) => {
|
96
|
-
|
93
|
+
window.addEventListener('aptos#transaction', (e: any) => {
|
94
|
+
if (e?.detail?.tx) {
|
95
|
+
this.emit('success', e?.detail?.tx);
|
96
|
+
}
|
97
97
|
});
|
98
98
|
|
99
99
|
window.addEventListener('aptos#disconnected', () => {
|
@@ -105,7 +105,7 @@ export class FewchaWalletAdapter extends BaseWalletAdapter {
|
|
105
105
|
return {
|
106
106
|
publicKey: this._wallet?.publicKey || null,
|
107
107
|
address: this._wallet?.address || null,
|
108
|
-
authKey: this._wallet?.
|
108
|
+
authKey: this._wallet?.authKey || null
|
109
109
|
};
|
110
110
|
}
|
111
111
|
|
@@ -134,6 +134,10 @@ export class FewchaWalletAdapter extends BaseWalletAdapter {
|
|
134
134
|
|
135
135
|
this._connecting = true;
|
136
136
|
const provider = this._provider;
|
137
|
+
const isConnected = await this._provider?.isConnected();
|
138
|
+
if (isConnected) {
|
139
|
+
await provider?.disconnect();
|
140
|
+
}
|
137
141
|
await provider?.connect();
|
138
142
|
} catch (error: any) {
|
139
143
|
this.emit('error', error);
|
@@ -190,14 +194,18 @@ export class FewchaWalletAdapter extends BaseWalletAdapter {
|
|
190
194
|
|
191
195
|
try {
|
192
196
|
const provider = this._provider;
|
193
|
-
const tx = await
|
194
|
-
|
197
|
+
const tx = await provider?.generateTransaction(transaction);
|
198
|
+
if (tx) {
|
199
|
+
await provider?.signAndSubmitTransaction(tx.data);
|
200
|
+
}
|
195
201
|
|
196
202
|
const promise = await new Promise((resolve, reject) => {
|
197
203
|
this.once('success', resolve);
|
198
204
|
this.once('error', reject);
|
199
205
|
});
|
200
|
-
return
|
206
|
+
return {
|
207
|
+
hash: promise
|
208
|
+
} as PendingTransaction;
|
201
209
|
} catch (error: any) {
|
202
210
|
const errMsg = error instanceof Error ? error.message : error.response.data.message;
|
203
211
|
throw new WalletSignTransactionError(errMsg);
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { MaybeHexString } from 'aptos';
|
1
2
|
import {
|
2
3
|
PendingTransaction,
|
3
4
|
SubmitTransactionRequest,
|
@@ -12,14 +13,17 @@ import {
|
|
12
13
|
import {
|
13
14
|
AccountKeys,
|
14
15
|
BaseWalletAdapter,
|
15
|
-
PublicKey,
|
16
16
|
scopePollingDetectionStrategy,
|
17
17
|
WalletName,
|
18
18
|
WalletReadyState
|
19
19
|
} from './BaseAdapter';
|
20
20
|
|
21
21
|
interface IHippoWallet {
|
22
|
-
connect: () => Promise<{
|
22
|
+
connect: () => Promise<{
|
23
|
+
address: MaybeHexString;
|
24
|
+
publicKey: MaybeHexString;
|
25
|
+
authKey: MaybeHexString;
|
26
|
+
}>;
|
23
27
|
account: () => Promise<string>;
|
24
28
|
isConnected: () => Promise<boolean>;
|
25
29
|
signAndSubmitTransaction(transaction: any): Promise<any>;
|
@@ -33,8 +37,7 @@ interface HippoWindow extends Window {
|
|
33
37
|
|
34
38
|
declare const window: HippoWindow;
|
35
39
|
|
36
|
-
export const HippoExtensionWalletName =
|
37
|
-
'Hippo Wallet' as WalletName<'Hippo Wallet'>;
|
40
|
+
export const HippoExtensionWalletName = 'Hippo Wallet' as WalletName<'Hippo Wallet'>;
|
38
41
|
|
39
42
|
export interface HippoExtensionWalletAdapterConfig {
|
40
43
|
provider?: IHippoWallet;
|
@@ -45,7 +48,7 @@ export interface HippoExtensionWalletAdapterConfig {
|
|
45
48
|
export class HippoExtensionWalletAdapter extends BaseWalletAdapter {
|
46
49
|
name = HippoExtensionWalletName;
|
47
50
|
|
48
|
-
url = 'https://hippo-wallet
|
51
|
+
url = 'https://github.com/hippospace/hippo-wallet';
|
49
52
|
|
50
53
|
icon = 'https://ui-test1-22e7c.web.app/static/media/hippo_logo.ecded6bf411652de9b7f.png';
|
51
54
|
|
@@ -92,7 +95,7 @@ export class HippoExtensionWalletAdapter extends BaseWalletAdapter {
|
|
92
95
|
return {
|
93
96
|
publicKey: this._wallet?.publicKey || null,
|
94
97
|
address: this._wallet?.address || null,
|
95
|
-
authKey: this._wallet?.
|
98
|
+
authKey: this._wallet?.authKey || null
|
96
99
|
};
|
97
100
|
}
|
98
101
|
|
@@ -124,7 +127,7 @@ export class HippoExtensionWalletAdapter extends BaseWalletAdapter {
|
|
124
127
|
const response = await provider?.connect();
|
125
128
|
|
126
129
|
this._wallet = {
|
127
|
-
|
130
|
+
...response,
|
128
131
|
isConnected: true
|
129
132
|
};
|
130
133
|
|
@@ -10,13 +10,7 @@ import {
|
|
10
10
|
WalletNotReadyError,
|
11
11
|
WalletSignAndSubmitMessageError
|
12
12
|
} from '../WalletProviders/errors';
|
13
|
-
import {
|
14
|
-
AccountKeys,
|
15
|
-
BaseWalletAdapter,
|
16
|
-
PublicKey,
|
17
|
-
WalletName,
|
18
|
-
WalletReadyState
|
19
|
-
} from './BaseAdapter';
|
13
|
+
import { AccountKeys, BaseWalletAdapter, WalletName, WalletReadyState } from './BaseAdapter';
|
20
14
|
|
21
15
|
export const HippoWalletName = 'Hippo Web Wallet' as WalletName<'Hippo Web Wallet'>;
|
22
16
|
|
@@ -63,7 +57,7 @@ export class HippoWalletAdapter extends BaseWalletAdapter {
|
|
63
57
|
return {
|
64
58
|
publicKey: this._wallet?.publicKey || null,
|
65
59
|
address: this._wallet?.address || null,
|
66
|
-
authKey: this._wallet?.
|
60
|
+
authKey: this._wallet?.authKey || null
|
67
61
|
};
|
68
62
|
}
|
69
63
|
|
@@ -154,7 +148,8 @@ export class HippoWalletAdapter extends BaseWalletAdapter {
|
|
154
148
|
method: 'signTransaction',
|
155
149
|
payload: transaction
|
156
150
|
}),
|
157
|
-
origin: window.location.origin
|
151
|
+
origin: window.location.origin,
|
152
|
+
isPopUp: 'true'
|
158
153
|
}).toString();
|
159
154
|
const popup = window.open(
|
160
155
|
`${WEBWALLET_URL}?${request}`,
|
@@ -1,11 +1,10 @@
|
|
1
1
|
import { MaybeHexString } from 'aptos';
|
2
2
|
import {
|
3
3
|
PendingTransaction,
|
4
|
-
ScriptFunctionPayload,
|
5
4
|
SubmitTransactionRequest,
|
6
5
|
TransactionPayload
|
7
6
|
} from 'aptos/dist/api/data-contracts';
|
8
|
-
import { aptosClient } from '../config/aptosConstants';
|
7
|
+
// import { aptosClient } from '../config/aptosConstants';
|
9
8
|
import {
|
10
9
|
WalletDisconnectionError,
|
11
10
|
WalletNotConnectedError,
|
@@ -15,7 +14,6 @@ import {
|
|
15
14
|
import {
|
16
15
|
AccountKeys,
|
17
16
|
BaseWalletAdapter,
|
18
|
-
PublicKey,
|
19
17
|
scopePollingDetectionStrategy,
|
20
18
|
WalletName,
|
21
19
|
WalletReadyState
|
@@ -31,13 +29,14 @@ interface ConnectMartianAccount {
|
|
31
29
|
interface MartianAccount {
|
32
30
|
address: MaybeHexString;
|
33
31
|
publicKey: MaybeHexString;
|
34
|
-
|
32
|
+
authKey: MaybeHexString;
|
35
33
|
isConnected: boolean;
|
36
34
|
}
|
37
35
|
interface IMartianWallet {
|
38
36
|
connect: (params?: any) => Promise<ConnectMartianAccount>;
|
39
37
|
account(): Promise<MartianAccount>;
|
40
38
|
isConnected(): Promise<boolean>;
|
39
|
+
generateTransaction(sender: MaybeHexString, payload: any): Promise<any>;
|
41
40
|
signAndSubmitTransaction(transaction: any): Promise<string>;
|
42
41
|
// signTransaction(transaction: any): Promise<void>;
|
43
42
|
disconnect(): Promise<void>;
|
@@ -108,7 +107,7 @@ export class MartianWalletAdapter extends BaseWalletAdapter {
|
|
108
107
|
return {
|
109
108
|
publicKey: this._wallet?.publicKey || null,
|
110
109
|
address: this._wallet?.address || null,
|
111
|
-
authKey: this._wallet?.
|
110
|
+
authKey: this._wallet?.authKey || null
|
112
111
|
};
|
113
112
|
}
|
114
113
|
|
@@ -140,7 +139,9 @@ export class MartianWalletAdapter extends BaseWalletAdapter {
|
|
140
139
|
this._connecting = true;
|
141
140
|
|
142
141
|
const provider = window.martian;
|
143
|
-
|
142
|
+
const isConnected = await provider?.isConnected();
|
143
|
+
if (isConnected) await provider?.disconnect();
|
144
|
+
// console.log(4, isConnected);
|
144
145
|
const response = await provider?.connect();
|
145
146
|
// console.log(5, response);
|
146
147
|
|
@@ -149,6 +150,7 @@ export class MartianWalletAdapter extends BaseWalletAdapter {
|
|
149
150
|
}
|
150
151
|
|
151
152
|
const walletAccount = await provider?.account();
|
153
|
+
// console.log(6, walletAccount);
|
152
154
|
if (walletAccount) {
|
153
155
|
this._wallet = {
|
154
156
|
...walletAccount,
|
@@ -189,7 +191,8 @@ export class MartianWalletAdapter extends BaseWalletAdapter {
|
|
189
191
|
const wallet = this._wallet;
|
190
192
|
const provider = this._provider;
|
191
193
|
if (!wallet) throw new WalletNotConnectedError();
|
192
|
-
const tx = await
|
194
|
+
const tx = await provider?.generateTransaction(wallet.address || '', transactionPyld);
|
195
|
+
if (!tx) throw new WalletSignTransactionError('No transaction');
|
193
196
|
const response = await provider?.signAndSubmitTransaction(tx);
|
194
197
|
|
195
198
|
if (!response) {
|
@@ -209,7 +212,7 @@ export class MartianWalletAdapter extends BaseWalletAdapter {
|
|
209
212
|
const wallet = this._wallet;
|
210
213
|
const provider = this._provider;
|
211
214
|
if (!wallet) throw new WalletNotConnectedError();
|
212
|
-
const tx = await
|
215
|
+
const tx = await provider?.generateTransaction(wallet.address || '', transactionPyld);
|
213
216
|
const response = await provider?.signAndSubmitTransaction(tx);
|
214
217
|
|
215
218
|
if (!response) {
|
@@ -96,7 +96,7 @@ export class MultiMaskWalletAdapter extends BaseWalletAdapter {
|
|
96
96
|
return {
|
97
97
|
publicKey: this._wallet?.publicKey || null,
|
98
98
|
address: this._wallet?.address || null,
|
99
|
-
authKey: this._wallet?.
|
99
|
+
authKey: this._wallet?.authKey || null
|
100
100
|
};
|
101
101
|
}
|
102
102
|
|