@manahippo/aptos-wallet-adapter 0.4.3 → 0.4.5

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.
Files changed (40) hide show
  1. package/README.md +5 -2
  2. package/dist/WalletAdapters/AptosSnap.d.ts +42 -0
  3. package/dist/WalletAdapters/AptosSnap.d.ts.map +1 -0
  4. package/dist/WalletAdapters/AptosSnap.js +185 -0
  5. package/dist/WalletAdapters/AptosSnap.js.map +1 -0
  6. package/dist/WalletAdapters/FletchWallet.d.ts +57 -0
  7. package/dist/WalletAdapters/FletchWallet.d.ts.map +1 -0
  8. package/dist/WalletAdapters/FletchWallet.js +178 -0
  9. package/dist/WalletAdapters/FletchWallet.js.map +1 -0
  10. package/dist/WalletAdapters/NightlyWallet.d.ts +52 -0
  11. package/dist/WalletAdapters/NightlyWallet.d.ts.map +1 -1
  12. package/dist/WalletAdapters/NightlyWallet.js +270 -230
  13. package/dist/WalletAdapters/NightlyWallet.js.map +1 -1
  14. package/dist/WalletAdapters/PetraWallet.d.ts.map +1 -1
  15. package/dist/WalletAdapters/PetraWallet.js +1 -1
  16. package/dist/WalletAdapters/PetraWallet.js.map +1 -1
  17. package/dist/WalletAdapters/PontemWallet.d.ts +4 -6
  18. package/dist/WalletAdapters/PontemWallet.d.ts.map +1 -1
  19. package/dist/WalletAdapters/PontemWallet.js +4 -5
  20. package/dist/WalletAdapters/PontemWallet.js.map +1 -1
  21. package/dist/WalletAdapters/RiseWallet.d.ts +3 -5
  22. package/dist/WalletAdapters/RiseWallet.d.ts.map +1 -1
  23. package/dist/WalletAdapters/RiseWallet.js +7 -5
  24. package/dist/WalletAdapters/RiseWallet.js.map +1 -1
  25. package/dist/WalletAdapters/index.d.ts +3 -0
  26. package/dist/WalletAdapters/index.d.ts.map +1 -1
  27. package/dist/WalletAdapters/index.js +3 -1
  28. package/dist/WalletAdapters/index.js.map +1 -1
  29. package/dist/WalletProviders/WalletProvider.d.ts.map +1 -1
  30. package/dist/WalletProviders/WalletProvider.js +12 -5
  31. package/dist/WalletProviders/WalletProvider.js.map +1 -1
  32. package/package.json +5 -3
  33. package/src/WalletAdapters/AptosSnap.ts +235 -0
  34. package/src/WalletAdapters/FletchWallet.ts +223 -0
  35. package/src/WalletAdapters/NightlyWallet.ts +285 -260
  36. package/src/WalletAdapters/PetraWallet.ts +2 -1
  37. package/src/WalletAdapters/PontemWallet.ts +8 -9
  38. package/src/WalletAdapters/RiseWallet.ts +10 -7
  39. package/src/WalletAdapters/index.ts +3 -1
  40. package/src/WalletProviders/WalletProvider.tsx +14 -7
@@ -1,261 +1,286 @@
1
1
  export const NightlyWallet = () => {};
2
- // import { TxnBuilderTypes, BCS } from 'aptos';
3
- // import {
4
- // PendingTransaction,
5
- // ScriptFunctionPayload,
6
- // SubmitTransactionRequest,
7
- // TransactionPayload
8
- // } from 'aptos/dist/api/data-contracts';
9
- // import {
10
- // ScriptFunction,
11
- // StructTag,
12
- // TransactionPayloadScriptFunction,
13
- // TypeTagStruct
14
- // } from 'aptos/dist/transaction_builder/aptos_types';
15
- // import { bcsSerializeUint64, bcsToBytes, Seq } from 'aptos/dist/transaction_builder/bcs';
16
- // import { aptosClient } from '../config/aptosConstants';
17
- // import {
18
- // WalletDisconnectionError,
19
- // WalletNotConnectedError,
20
- // WalletNotReadyError,
21
- // WalletSignTransactionError
22
- // } from '../WalletProviders/errors';
23
- // import {
24
- // AccountKeys,
25
- // Address,
26
- // AuthKey,
27
- // BaseWalletAdapter,
28
- // PublicKey,
29
- // scopePollingDetectionStrategy,
30
- // WalletName,
31
- // WalletReadyState
32
- // } from './BaseAdapter';
33
-
34
- // interface INightlyWallet {
35
- // requestId: number;
36
- // connect: (onDisconnect?: () => void, eager?: boolean) => Promise<any>;
37
- // account: () => Promise<string>;
38
- // isConnected: () => Promise<boolean>;
39
- // signAndSubmitTransaction(transaction: any): Promise<void>;
40
- // signTransaction(transaction: any): Promise<any>;
41
- // disconnect(): Promise<void>;
42
- // }
43
-
44
- // interface NightlyWindow extends Window {
45
- // nightly?: {
46
- // aptos: INightlyWallet;
47
- // };
48
- // }
49
-
50
- // declare const window: NightlyWindow;
51
-
52
- // export const NightlyWalletName = 'Nightly Wallet' as WalletName<'Nightly Wallet'>;
53
-
54
- // export interface NightlyWalletAdapterConfig {
55
- // provider?: INightlyWallet;
56
- // // network?: WalletAdapterNetwork;
57
- // timeout?: number;
58
- // }
59
-
60
- // export class NightlyWalletAdapter extends BaseWalletAdapter {
61
- // name = NightlyWalletName;
62
-
63
- // url =
64
- // 'https://chrome.google.com/webstore/detail/nightly/injggoambcadlfkkjcgdfbejanmgfgfm/related?hl=en&authuser=0';
65
-
66
- // icon =
67
- // 'https://lh3.googleusercontent.com/Ha38j09tA-70EiZ17pculpj1KUKDP07ytX4DJx_fumDfod_X2nRTiUg2Y9tDwRBs5jDj-gu52hwaPYVPgq1xAuFA1Q=w128-h128-e365-rj-sc0x00ffffff';
68
-
69
- // protected _provider: INightlyWallet | undefined;
70
-
71
- // // protected _network: WalletAdapterNetwork;
72
- // protected _timeout: number;
73
-
74
- // protected _readyState: WalletReadyState =
75
- // typeof window === 'undefined' || typeof document === 'undefined'
76
- // ? WalletReadyState.Unsupported
77
- // : WalletReadyState.NotDetected;
78
-
79
- // protected _connecting: boolean;
80
-
81
- // protected _wallet: {
82
- // publicKey?: string;
83
- // address?: string;
84
- // authKey?: string;
85
- // isConnected: boolean;
86
- // } | null;
87
-
88
- // constructor({
89
- // // provider,
90
- // // network = WalletAdapterNetwork.Mainnet,
91
- // timeout = 10000
92
- // }: NightlyWalletAdapterConfig = {}) {
93
- // super();
94
-
95
- // this._provider = window.nightly?.aptos;
96
- // // this._network = network;
97
- // this._timeout = timeout;
98
- // this._connecting = false;
99
- // this._wallet = null;
100
-
101
- // if (this._readyState !== WalletReadyState.Unsupported) {
102
- // scopePollingDetectionStrategy(() => {
103
- // if (window.nightly?.aptos) {
104
- // this._readyState = WalletReadyState.Installed;
105
- // this.emit('readyStateChange', this._readyState);
106
- // return true;
107
- // }
108
- // return false;
109
- // });
110
- // }
111
- // }
112
-
113
- // get publicAccount(): AccountKeys {
114
- // return {
115
- // publicKey: this._wallet?.publicKey || null,
116
- // address: this._wallet?.address || null,
117
- // authKey: this._wallet?.authKey || null
118
- // };
119
- // }
120
-
121
- // get connecting(): boolean {
122
- // return this._connecting;
123
- // }
124
-
125
- // get connected(): boolean {
126
- // return !!this._wallet?.isConnected;
127
- // }
128
-
129
- // get readyState(): WalletReadyState {
130
- // return this._readyState;
131
- // }
132
-
133
- // async connect(): Promise<void> {
134
- // try {
135
- // if (this.connected || this.connecting) return;
136
- // if (
137
- // !(
138
- // this._readyState === WalletReadyState.Loadable ||
139
- // this._readyState === WalletReadyState.Installed
140
- // )
141
- // )
142
- // throw new WalletNotReadyError();
143
- // this._connecting = true;
144
-
145
- // const provider = this._provider || window.nightly?.aptos;
146
- // const publicKey = await provider?.connect(() => {
147
- // console.log('Trigger disconnect Aptos');
148
- // });
149
- // this._wallet = {
150
- // publicKey: publicKey?.asString(),
151
- // address: publicKey?.address(),
152
- // isConnected: true
153
- // };
154
-
155
- // this.emit('connect', this._wallet.publicKey || '');
156
- // } catch (error: any) {
157
- // this.emit('error', error);
158
- // throw error;
159
- // } finally {
160
- // this._connecting = false;
161
- // }
162
- // }
163
-
164
- // async disconnect(): Promise<void> {
165
- // const wallet = this._wallet;
166
- // if (wallet) {
167
- // this._wallet = null;
168
-
169
- // try {
170
- // const provider = this._provider || window.nightly?.aptos;
171
- // await provider?.disconnect();
172
- // } catch (error: any) {
173
- // this.emit('error', new WalletDisconnectionError(error?.message, error));
174
- // }
175
- // }
176
-
177
- // this.emit('disconnect');
178
- // }
179
-
180
- // async signTransaction(transaction: TransactionPayload): Promise<SubmitTransactionRequest> {
181
- // try {
182
- // const wallet = this._wallet;
183
- // if (!wallet) throw new WalletNotConnectedError();
184
-
185
- // try {
186
- // const provider = this._provider || window.nightly?.aptos;
187
- // const response = await provider?.signTransaction(transaction);
188
- // if (response) {
189
- // return response;
190
- // } else {
191
- // throw new Error('Transaction failed');
192
- // }
193
- // } catch (error: any) {
194
- // throw new WalletSignTransactionError(error?.message, error);
195
- // }
196
- // } catch (error: any) {
197
- // this.emit('error', error);
198
- // throw error;
199
- // }
200
- // }
201
-
202
- // async signAndSubmitTransaction(tempTransaction: TransactionPayload): Promise<PendingTransaction> {
203
- // try {
204
- // const wallet = this._wallet;
205
- // if (!wallet) throw new WalletNotConnectedError();
206
-
207
- // try {
208
- // const provider = this._provider || window.nightly?.aptos;
209
- // const client = aptosClient;
210
- // const [{ sequence_number: sequnceNumber }, chainId] = await Promise.all([
211
- // client.getAccount(wallet.address || ''),
212
- // client.getChainId()
213
- // ]);
214
- // const transaction = tempTransaction as ScriptFunctionPayload;
215
- // const [txAddress, module, funcName] = transaction.function.split('::');
216
- // const token = new TypeTagStruct(StructTag.fromString(transaction.type_arguments[0]));
217
- // const argts = transaction.arguments.map((arg) => {
218
- // if (typeof arg === 'string') {
219
- // return bcsSerializeUint64(parseInt(arg));
220
- // } else if (typeof arg === 'boolean') {
221
- // const serializer = new BCS.Serializer();
222
- // serializer.serializeBool(arg);
223
- // return serializer.getBytes();
224
- // } else if (typeof arg === 'number') {
225
- // return bcsSerializeUint64(arg);
226
- // } else {
227
- // return arg;
228
- // }
229
- // });
230
- // console.log('txnpayload>>', transaction.arguments, argts);
231
- // const txnPayload = new TransactionPayloadScriptFunction(
232
- // ScriptFunction.natural(`${txAddress}::${module}`, funcName, [token], [...argts])
233
- // );
234
-
235
- // const rawTxn = new TxnBuilderTypes.RawTransaction(
236
- // TxnBuilderTypes.AccountAddress.fromHex(wallet.address || ''),
237
- // BigInt(sequnceNumber),
238
- // txnPayload,
239
- // BigInt(1000),
240
- // BigInt(1),
241
- // BigInt(Math.floor(Date.now() / 1000) + 10),
242
- // new TxnBuilderTypes.ChainId(chainId)
243
- // );
244
- // const bcsTxn = await provider?.signTransaction(rawTxn);
245
- // const response = await aptosClient.submitSignedBCSTransaction(bcsTxn);
246
- // if (response) {
247
- // console.log('tx response>>>', response);
248
- // return response;
249
- // } else {
250
- // throw new Error('Transaction failed');
251
- // }
252
- // } catch (error: any) {
253
- // const errMsg = error instanceof Error ? error.message : error.response.data.message;
254
- // throw new WalletSignTransactionError(errMsg);
255
- // }
256
- // } catch (error: any) {
257
- // this.emit('error', error);
258
- // throw error;
259
- // }
260
- // }
261
- // }
2
+
3
+ import { PendingTransaction, TransactionPayload } from 'aptos/src/generated';
4
+ import * as SHA3 from 'js-sha3';
5
+ import { aptosClient } from '../config/aptosConstants';
6
+ import {
7
+ WalletDisconnectionError,
8
+ WalletNotConnectedError,
9
+ WalletNotReadyError,
10
+ WalletSignMessageError,
11
+ WalletSignTransactionError
12
+ } from '../WalletProviders/errors';
13
+ import {
14
+ AccountKeys,
15
+ BaseWalletAdapter,
16
+ scopePollingDetectionStrategy,
17
+ WalletName,
18
+ WalletReadyState
19
+ } from './BaseAdapter';
20
+
21
+ export class AptosPublicKey {
22
+ private readonly hexString: string;
23
+
24
+ static default() {
25
+ return new AptosPublicKey('0'.repeat(64));
26
+ }
27
+
28
+ address() {
29
+ const hash = SHA3.sha3_256.create();
30
+ hash.update(Buffer.from(this.asPureHex(), 'hex'));
31
+ hash.update('\x00');
32
+ return '0x' + hash.hex();
33
+ }
34
+
35
+ asUint8Array() {
36
+ return new Uint8Array(Buffer.from(this.asPureHex(), 'hex'));
37
+ }
38
+
39
+ asString() {
40
+ return this.hexString;
41
+ }
42
+
43
+ asPureHex() {
44
+ return this.hexString.substr(2);
45
+ }
46
+
47
+ constructor(hexString: string) {
48
+ if (hexString.startsWith('0x')) {
49
+ this.hexString = hexString;
50
+ } else {
51
+ this.hexString = `0x${hexString}`;
52
+ }
53
+ }
54
+ }
55
+ interface AptosNightly {
56
+ publicKey: AptosPublicKey;
57
+ constructor(eventMap: Map<string, (data: any) => any>);
58
+ connect(onDisconnect?: () => void, eagerConnect?: boolean): Promise<AptosPublicKey>;
59
+ disconnect(): Promise<void>;
60
+ signTransaction: (transaction: TransactionPayload) => Promise<Uint8Array>;
61
+ signAllTransactions: (transaction: TransactionPayload[]) => Promise<Uint8Array[]>;
62
+ signMessage(msg: string): Promise<Uint8Array>;
63
+ }
64
+ interface NightlyWindow extends Window {
65
+ nightly?: {
66
+ aptos: AptosNightly;
67
+ };
68
+ }
69
+
70
+ declare const window: NightlyWindow;
71
+
72
+ export const NightlyWalletName = 'Nightly' as WalletName<'Nightly'>;
73
+
74
+ export interface NightlyWalletAdapterConfig {
75
+ provider?: AptosNightly;
76
+ // network?: WalletAdapterNetwork;
77
+ timeout?: number;
78
+ }
79
+
80
+ export class NightlyWalletAdapter extends BaseWalletAdapter {
81
+ name = NightlyWalletName;
82
+
83
+ url =
84
+ 'https://chrome.google.com/webstore/detail/nightly/fiikommddbeccaoicoejoniammnalkfa/related?hl=en&authuser=0';
85
+
86
+ icon =
87
+ 'https://lh3.googleusercontent.com/_feXM9qulMM5w9BYMLzMpZrxW2WlBmdyg3SbETIoRsHdAD9PANnLCEPabC7lzEK0N8fOyyvFkY3746jk8l73zUErxhU=w128-h128-e365-rj-sc0x00ffffff';
88
+
89
+ protected _provider: AptosNightly | undefined;
90
+
91
+ // protected _network: WalletAdapterNetwork;
92
+ protected _timeout: number;
93
+
94
+ protected _readyState: WalletReadyState =
95
+ typeof window === 'undefined' || typeof document === 'undefined'
96
+ ? WalletReadyState.Unsupported
97
+ : WalletReadyState.NotDetected;
98
+
99
+ protected _connecting: boolean;
100
+
101
+ protected _wallet: {
102
+ publicKey?: string;
103
+ address?: string;
104
+ authKey?: string;
105
+ isConnected: boolean;
106
+ } | null;
107
+
108
+ constructor({
109
+ // provider,
110
+ // network = WalletAdapterNetwork.Mainnet,
111
+ timeout = 10000
112
+ }: NightlyWalletAdapterConfig = {}) {
113
+ super();
114
+
115
+ this._provider = window.nightly?.aptos;
116
+ // this._network = network;
117
+ this._timeout = timeout;
118
+ this._connecting = false;
119
+ this._wallet = null;
120
+
121
+ if (this._readyState !== WalletReadyState.Unsupported) {
122
+ scopePollingDetectionStrategy(() => {
123
+ if (window.nightly?.aptos) {
124
+ this._readyState = WalletReadyState.Installed;
125
+ this.emit('readyStateChange', this._readyState);
126
+ return true;
127
+ }
128
+ return false;
129
+ });
130
+ }
131
+ }
132
+
133
+ get publicAccount(): AccountKeys {
134
+ return {
135
+ publicKey: this._wallet?.publicKey || null,
136
+ address: this._wallet?.address || null,
137
+ authKey: this._wallet?.authKey || null
138
+ };
139
+ }
140
+
141
+ get connecting(): boolean {
142
+ return this._connecting;
143
+ }
144
+
145
+ get connected(): boolean {
146
+ return !!this._wallet?.isConnected;
147
+ }
148
+
149
+ get readyState(): WalletReadyState {
150
+ return this._readyState;
151
+ }
152
+
153
+ async connect(): Promise<void> {
154
+ try {
155
+ if (this.connected || this.connecting) return;
156
+ if (
157
+ !(
158
+ this._readyState === WalletReadyState.Loadable ||
159
+ this._readyState === WalletReadyState.Installed
160
+ )
161
+ )
162
+ throw new WalletNotReadyError();
163
+ this._connecting = true;
164
+
165
+ const provider = this._provider || window.nightly?.aptos;
166
+ const publicKey = await provider?.connect(() => {
167
+ this._wallet = null;
168
+ this.emit('disconnect');
169
+ });
170
+ this._wallet = {
171
+ publicKey: publicKey?.asString(),
172
+ address: publicKey?.address(),
173
+ isConnected: true
174
+ };
175
+
176
+ this.emit('connect', this._wallet.publicKey || '');
177
+ } catch (error: any) {
178
+ this.emit('error', error);
179
+ throw error;
180
+ } finally {
181
+ this._connecting = false;
182
+ }
183
+ }
184
+
185
+ async disconnect(): Promise<void> {
186
+ const wallet = this._wallet;
187
+ if (wallet) {
188
+ this._wallet = null;
189
+
190
+ try {
191
+ const provider = this._provider || window.nightly?.aptos;
192
+ await provider?.disconnect();
193
+ } catch (error: any) {
194
+ this.emit('error', new WalletDisconnectionError(error?.message, error));
195
+ }
196
+ }
197
+
198
+ this.emit('disconnect');
199
+ }
200
+
201
+ async signTransaction(payload: TransactionPayload): Promise<Uint8Array> {
202
+ try {
203
+ const wallet = this._wallet;
204
+ if (!wallet) throw new WalletNotConnectedError();
205
+
206
+ try {
207
+ const provider = this._provider || window.nightly?.aptos;
208
+ const response = await provider?.signTransaction(payload);
209
+ if (response) {
210
+ return response;
211
+ } else {
212
+ throw new Error('Transaction failed');
213
+ }
214
+ } catch (error: any) {
215
+ throw new WalletSignTransactionError(error?.message, error);
216
+ }
217
+ } catch (error: any) {
218
+ this.emit('error', error);
219
+ throw error;
220
+ }
221
+ }
222
+
223
+ async signAllTransaction(payload: TransactionPayload[]): Promise<Uint8Array[]> {
224
+ try {
225
+ const wallet = this._wallet;
226
+ if (!wallet) throw new WalletNotConnectedError();
227
+
228
+ try {
229
+ const provider = this._provider || window.nightly?.aptos;
230
+ const response = await provider?.signAllTransactions(payload);
231
+ if (response) {
232
+ return response;
233
+ } else {
234
+ throw new Error('Transaction failed');
235
+ }
236
+ } catch (error: any) {
237
+ throw new WalletSignTransactionError(error?.message, error);
238
+ }
239
+ } catch (error: any) {
240
+ this.emit('error', error);
241
+ throw error;
242
+ }
243
+ }
244
+
245
+ async signAndSubmitTransaction(tx: TransactionPayload): Promise<PendingTransaction> {
246
+ try {
247
+ const wallet = this._wallet;
248
+ if (!wallet) throw new WalletNotConnectedError();
249
+
250
+ try {
251
+ const provider = this._provider || window.nightly?.aptos;
252
+ const response = await provider?.signTransaction(tx);
253
+ const result = await aptosClient.submitSignedBCSTransaction(response);
254
+ if (response) {
255
+ return result;
256
+ } else {
257
+ throw new Error('Transaction failed');
258
+ }
259
+ } catch (error: any) {
260
+ const errMsg = error instanceof Error ? error.message : error.response.data.message;
261
+ throw new WalletSignTransactionError(errMsg);
262
+ }
263
+ } catch (error: any) {
264
+ this.emit('error', error);
265
+ throw error;
266
+ }
267
+ }
268
+
269
+ async signMessage(message: string): Promise<string> {
270
+ try {
271
+ const wallet = this._wallet;
272
+ const provider = this._provider || window.nightly.aptos;
273
+ if (!wallet || !provider) throw new WalletNotConnectedError();
274
+ const response = await provider?.signMessage(message);
275
+ if (response) {
276
+ return Buffer.from(response).toString('hex');
277
+ } else {
278
+ throw new Error('Sign Message failed');
279
+ }
280
+ } catch (error: any) {
281
+ const errMsg = error.message;
282
+ this.emit('error', new WalletSignMessageError(errMsg));
283
+ throw error;
284
+ }
285
+ }
286
+ }
@@ -53,7 +53,8 @@ export interface AptosWalletAdapterConfig {
53
53
  export class AptosWalletAdapter extends BaseWalletAdapter {
54
54
  name = AptosWalletName;
55
55
 
56
- url = 'https://aptos.dev/guides/building-wallet-extension';
56
+ url =
57
+ 'https://chrome.google.com/webstore/detail/petra-aptos-wallet/ejjladinnckdgjemekebdpeokbikhfci';
57
58
 
58
59
  icon = 'https://miro.medium.com/fit/c/176/176/1*Gf747eyRywU8Img0tK5wvw.png';
59
60
 
@@ -12,6 +12,8 @@ import {
12
12
  AccountKeys,
13
13
  BaseWalletAdapter,
14
14
  scopePollingDetectionStrategy,
15
+ SignMessagePayload,
16
+ SignMessageResponse,
15
17
  WalletName,
16
18
  WalletReadyState
17
19
  } from './BaseAdapter';
@@ -45,11 +47,9 @@ interface IPontemWallet {
45
47
  }>;
46
48
  isConnected(): Promise<boolean>;
47
49
  signTransaction(transaction: TransactionPayload, options?: any): Promise<Uint8Array>;
48
- signMessage(message: string): Promise<{
50
+ signMessage(message: SignMessagePayload): Promise<{
49
51
  success: boolean;
50
- result: {
51
- hexString: HexEncodedBytes;
52
- };
52
+ result: SignMessageResponse;
53
53
  }>;
54
54
  disconnect(): Promise<void>;
55
55
  }
@@ -221,20 +221,19 @@ export class PontemWalletAdapter extends BaseWalletAdapter {
221
221
  }
222
222
  return { hash: response.result.hash };
223
223
  } catch (error: any) {
224
- this.emit('error', new WalletSignAndSubmitMessageError(error.error.message));
224
+ this.emit('error', new WalletSignAndSubmitMessageError(error.message));
225
225
  throw error;
226
226
  }
227
227
  }
228
228
 
229
- async signMessage(message: string): Promise<string> {
229
+ async signMessage(messagePayload: SignMessagePayload): Promise<SignMessageResponse> {
230
230
  try {
231
231
  const wallet = this._wallet;
232
232
  const provider = this._provider || window.pontem;
233
233
  if (!wallet || !provider) throw new WalletNotConnectedError();
234
- const response = await provider?.signMessage(message);
235
- console.log('MEMEM>>>', response);
234
+ const response = await provider?.signMessage(messagePayload);
236
235
  if (response.success) {
237
- return response.result.hexString;
236
+ return response.result;
238
237
  } else {
239
238
  throw new Error('Sign Message failed');
240
239
  }
@@ -10,6 +10,8 @@ import {
10
10
  AccountKeys,
11
11
  BaseWalletAdapter,
12
12
  scopePollingDetectionStrategy,
13
+ SignMessagePayload,
14
+ SignMessageResponse,
13
15
  WalletName,
14
16
  WalletReadyState
15
17
  } from './BaseAdapter';
@@ -28,7 +30,7 @@ interface IRiseWallet {
28
30
  isConnected: () => Promise<boolean>;
29
31
  signAndSubmitTransaction(transaction: any): Promise<{ hash: HexEncodedBytes }>;
30
32
  signTransaction(transaction: any, options?: any): Promise<Uint8Array>;
31
- signMessage(message: string): Promise<{ signature: string }>;
33
+ signMessage(message: SignMessagePayload): Promise<SignMessageResponse>;
32
34
  disconnect(): Promise<void>;
33
35
  }
34
36
 
@@ -213,20 +215,21 @@ export class RiseWalletAdapter extends BaseWalletAdapter {
213
215
  }
214
216
  }
215
217
 
216
- async signMessage(message: string): Promise<string> {
218
+ async signMessage(msgPayload: SignMessagePayload): Promise<SignMessageResponse> {
217
219
  try {
218
220
  const wallet = this._wallet;
219
221
  const provider = this._provider || window.rise;
220
222
  if (!wallet || !provider) throw new WalletNotConnectedError();
221
-
222
- const response = await provider?.signMessage(message);
223
- if (response?.signature) {
224
- return response.signature;
223
+ if (typeof msgPayload !== 'object' || !msgPayload.nonce) {
224
+ throw new WalletSignMessageError('Invalid signMessage Payload');
225
+ }
226
+ const response = await provider?.signMessage(msgPayload);
227
+ if (response) {
228
+ return response;
225
229
  } else {
226
230
  throw new Error('Sign Message failed');
227
231
  }
228
232
  } catch (error: any) {
229
- console.log('err', error);
230
233
  const errMsg = error.message;
231
234
  this.emit('error', new WalletSignMessageError(errMsg));
232
235
  throw error;