@manahippo/aptos-wallet-adapter 0.4.4 → 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.
@@ -1,2 +1,54 @@
1
1
  export declare const NightlyWallet: () => void;
2
+ import { PendingTransaction, TransactionPayload } from 'aptos/src/generated';
3
+ import { AccountKeys, BaseWalletAdapter, WalletName, WalletReadyState } from './BaseAdapter';
4
+ export declare class AptosPublicKey {
5
+ private readonly hexString;
6
+ static default(): AptosPublicKey;
7
+ address(): string;
8
+ asUint8Array(): Uint8Array;
9
+ asString(): string;
10
+ asPureHex(): string;
11
+ constructor(hexString: string);
12
+ }
13
+ interface AptosNightly {
14
+ publicKey: AptosPublicKey;
15
+ constructor(eventMap: Map<string, (data: any) => any>): any;
16
+ connect(onDisconnect?: () => void, eagerConnect?: boolean): Promise<AptosPublicKey>;
17
+ disconnect(): Promise<void>;
18
+ signTransaction: (transaction: TransactionPayload) => Promise<Uint8Array>;
19
+ signAllTransactions: (transaction: TransactionPayload[]) => Promise<Uint8Array[]>;
20
+ signMessage(msg: string): Promise<Uint8Array>;
21
+ }
22
+ export declare const NightlyWalletName: WalletName<"Nightly">;
23
+ export interface NightlyWalletAdapterConfig {
24
+ provider?: AptosNightly;
25
+ timeout?: number;
26
+ }
27
+ export declare class NightlyWalletAdapter extends BaseWalletAdapter {
28
+ name: WalletName<"Nightly">;
29
+ url: string;
30
+ icon: string;
31
+ protected _provider: AptosNightly | undefined;
32
+ protected _timeout: number;
33
+ protected _readyState: WalletReadyState;
34
+ protected _connecting: boolean;
35
+ protected _wallet: {
36
+ publicKey?: string;
37
+ address?: string;
38
+ authKey?: string;
39
+ isConnected: boolean;
40
+ } | null;
41
+ constructor({ timeout }?: NightlyWalletAdapterConfig);
42
+ get publicAccount(): AccountKeys;
43
+ get connecting(): boolean;
44
+ get connected(): boolean;
45
+ get readyState(): WalletReadyState;
46
+ connect(): Promise<void>;
47
+ disconnect(): Promise<void>;
48
+ signTransaction(payload: TransactionPayload): Promise<Uint8Array>;
49
+ signAllTransaction(payload: TransactionPayload[]): Promise<Uint8Array[]>;
50
+ signAndSubmitTransaction(tx: TransactionPayload): Promise<PendingTransaction>;
51
+ signMessage(message: string): Promise<string>;
52
+ }
53
+ export {};
2
54
  //# sourceMappingURL=NightlyWallet.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"NightlyWallet.d.ts","sourceRoot":"","sources":["../../src/WalletAdapters/NightlyWallet.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,YAAW,CAAC"}
1
+ {"version":3,"file":"NightlyWallet.d.ts","sourceRoot":"","sources":["../../src/WalletAdapters/NightlyWallet.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,YAAW,CAAC;AAEtC,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAU7E,OAAO,EACL,WAAW,EACX,iBAAiB,EAEjB,UAAU,EACV,gBAAgB,EACjB,MAAM,eAAe,CAAC;AAEvB,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IAEnC,MAAM,CAAC,OAAO;IAId,OAAO;IAOP,YAAY;IAIZ,QAAQ;IAIR,SAAS;gBAIG,SAAS,EAAE,MAAM;CAO9B;AACD,UAAU,YAAY;IACpB,SAAS,EAAE,cAAc,CAAC;IAC1B,WAAW,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,GAAG,CAAC,OAAE;IACvD,OAAO,CAAC,YAAY,CAAC,EAAE,MAAM,IAAI,EAAE,YAAY,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IACpF,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,eAAe,EAAE,CAAC,WAAW,EAAE,kBAAkB,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IAC1E,mBAAmB,EAAE,CAAC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EAAE,EAAE,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAwB7E,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAiBpD"}
@@ -1,235 +1,275 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
2
34
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NightlyWallet = void 0;
35
+ exports.NightlyWalletAdapter = exports.NightlyWalletName = exports.AptosPublicKey = exports.NightlyWallet = void 0;
4
36
  const NightlyWallet = () => { };
5
37
  exports.NightlyWallet = NightlyWallet;
6
- // import { TxnBuilderTypes, BCS } from 'aptos';
7
- // import {
8
- // PendingTransaction,
9
- // ScriptFunctionPayload,
10
- // SubmitTransactionRequest,
11
- // TransactionPayload
12
- // } from 'aptos/dist/api/data-contracts';
13
- // import {
14
- // ScriptFunction,
15
- // StructTag,
16
- // TransactionPayloadScriptFunction,
17
- // TypeTagStruct
18
- // } from 'aptos/dist/transaction_builder/aptos_types';
19
- // import { bcsSerializeUint64, bcsToBytes, Seq } from 'aptos/dist/transaction_builder/bcs';
20
- // import { aptosClient } from '../config/aptosConstants';
21
- // import {
22
- // WalletDisconnectionError,
23
- // WalletNotConnectedError,
24
- // WalletNotReadyError,
25
- // WalletSignTransactionError
26
- // } from '../WalletProviders/errors';
27
- // import {
28
- // AccountKeys,
29
- // Address,
30
- // AuthKey,
31
- // BaseWalletAdapter,
32
- // PublicKey,
33
- // scopePollingDetectionStrategy,
34
- // WalletName,
35
- // WalletReadyState
36
- // } from './BaseAdapter';
37
- // interface INightlyWallet {
38
- // requestId: number;
39
- // connect: (onDisconnect?: () => void, eager?: boolean) => Promise<any>;
40
- // account: () => Promise<string>;
41
- // isConnected: () => Promise<boolean>;
42
- // signAndSubmitTransaction(transaction: any): Promise<void>;
43
- // signTransaction(transaction: any): Promise<any>;
44
- // disconnect(): Promise<void>;
45
- // }
46
- // interface NightlyWindow extends Window {
47
- // nightly?: {
48
- // aptos: INightlyWallet;
49
- // };
50
- // }
51
- // declare const window: NightlyWindow;
52
- // export const NightlyWalletName = 'Nightly Wallet' as WalletName<'Nightly Wallet'>;
53
- // export interface NightlyWalletAdapterConfig {
54
- // provider?: INightlyWallet;
55
- // // network?: WalletAdapterNetwork;
56
- // timeout?: number;
57
- // }
58
- // export class NightlyWalletAdapter extends BaseWalletAdapter {
59
- // name = NightlyWalletName;
60
- // url =
61
- // 'https://chrome.google.com/webstore/detail/nightly/injggoambcadlfkkjcgdfbejanmgfgfm/related?hl=en&authuser=0';
62
- // icon =
63
- // 'https://lh3.googleusercontent.com/Ha38j09tA-70EiZ17pculpj1KUKDP07ytX4DJx_fumDfod_X2nRTiUg2Y9tDwRBs5jDj-gu52hwaPYVPgq1xAuFA1Q=w128-h128-e365-rj-sc0x00ffffff';
64
- // protected _provider: INightlyWallet | undefined;
65
- // // protected _network: WalletAdapterNetwork;
66
- // protected _timeout: number;
67
- // protected _readyState: WalletReadyState =
68
- // typeof window === 'undefined' || typeof document === 'undefined'
69
- // ? WalletReadyState.Unsupported
70
- // : WalletReadyState.NotDetected;
71
- // protected _connecting: boolean;
72
- // protected _wallet: {
73
- // publicKey?: string;
74
- // address?: string;
75
- // authKey?: string;
76
- // isConnected: boolean;
77
- // } | null;
78
- // constructor({
79
- // // provider,
80
- // // network = WalletAdapterNetwork.Mainnet,
81
- // timeout = 10000
82
- // }: NightlyWalletAdapterConfig = {}) {
83
- // super();
84
- // this._provider = window.nightly?.aptos;
85
- // // this._network = network;
86
- // this._timeout = timeout;
87
- // this._connecting = false;
88
- // this._wallet = null;
89
- // if (this._readyState !== WalletReadyState.Unsupported) {
90
- // scopePollingDetectionStrategy(() => {
91
- // if (window.nightly?.aptos) {
92
- // this._readyState = WalletReadyState.Installed;
93
- // this.emit('readyStateChange', this._readyState);
94
- // return true;
95
- // }
96
- // return false;
97
- // });
98
- // }
99
- // }
100
- // get publicAccount(): AccountKeys {
101
- // return {
102
- // publicKey: this._wallet?.publicKey || null,
103
- // address: this._wallet?.address || null,
104
- // authKey: this._wallet?.authKey || null
105
- // };
106
- // }
107
- // get connecting(): boolean {
108
- // return this._connecting;
109
- // }
110
- // get connected(): boolean {
111
- // return !!this._wallet?.isConnected;
112
- // }
113
- // get readyState(): WalletReadyState {
114
- // return this._readyState;
115
- // }
116
- // async connect(): Promise<void> {
117
- // try {
118
- // if (this.connected || this.connecting) return;
119
- // if (
120
- // !(
121
- // this._readyState === WalletReadyState.Loadable ||
122
- // this._readyState === WalletReadyState.Installed
123
- // )
124
- // )
125
- // throw new WalletNotReadyError();
126
- // this._connecting = true;
127
- // const provider = this._provider || window.nightly?.aptos;
128
- // const publicKey = await provider?.connect(() => {
129
- // console.log('Trigger disconnect Aptos');
130
- // });
131
- // this._wallet = {
132
- // publicKey: publicKey?.asString(),
133
- // address: publicKey?.address(),
134
- // isConnected: true
135
- // };
136
- // this.emit('connect', this._wallet.publicKey || '');
137
- // } catch (error: any) {
138
- // this.emit('error', error);
139
- // throw error;
140
- // } finally {
141
- // this._connecting = false;
142
- // }
143
- // }
144
- // async disconnect(): Promise<void> {
145
- // const wallet = this._wallet;
146
- // if (wallet) {
147
- // this._wallet = null;
148
- // try {
149
- // const provider = this._provider || window.nightly?.aptos;
150
- // await provider?.disconnect();
151
- // } catch (error: any) {
152
- // this.emit('error', new WalletDisconnectionError(error?.message, error));
153
- // }
154
- // }
155
- // this.emit('disconnect');
156
- // }
157
- // async signTransaction(transaction: TransactionPayload): Promise<SubmitTransactionRequest> {
158
- // try {
159
- // const wallet = this._wallet;
160
- // if (!wallet) throw new WalletNotConnectedError();
161
- // try {
162
- // const provider = this._provider || window.nightly?.aptos;
163
- // const response = await provider?.signTransaction(transaction);
164
- // if (response) {
165
- // return response;
166
- // } else {
167
- // throw new Error('Transaction failed');
168
- // }
169
- // } catch (error: any) {
170
- // throw new WalletSignTransactionError(error?.message, error);
171
- // }
172
- // } catch (error: any) {
173
- // this.emit('error', error);
174
- // throw error;
175
- // }
176
- // }
177
- // async signAndSubmitTransaction(tempTransaction: TransactionPayload): Promise<PendingTransaction> {
178
- // try {
179
- // const wallet = this._wallet;
180
- // if (!wallet) throw new WalletNotConnectedError();
181
- // try {
182
- // const provider = this._provider || window.nightly?.aptos;
183
- // const client = aptosClient;
184
- // const [{ sequence_number: sequnceNumber }, chainId] = await Promise.all([
185
- // client.getAccount(wallet.address || ''),
186
- // client.getChainId()
187
- // ]);
188
- // const transaction = tempTransaction as ScriptFunctionPayload;
189
- // const [txAddress, module, funcName] = transaction.function.split('::');
190
- // const token = new TypeTagStruct(StructTag.fromString(transaction.type_arguments[0]));
191
- // const argts = transaction.arguments.map((arg) => {
192
- // if (typeof arg === 'string') {
193
- // return bcsSerializeUint64(parseInt(arg));
194
- // } else if (typeof arg === 'boolean') {
195
- // const serializer = new BCS.Serializer();
196
- // serializer.serializeBool(arg);
197
- // return serializer.getBytes();
198
- // } else if (typeof arg === 'number') {
199
- // return bcsSerializeUint64(arg);
200
- // } else {
201
- // return arg;
202
- // }
203
- // });
204
- // console.log('txnpayload>>', transaction.arguments, argts);
205
- // const txnPayload = new TransactionPayloadScriptFunction(
206
- // ScriptFunction.natural(`${txAddress}::${module}`, funcName, [token], [...argts])
207
- // );
208
- // const rawTxn = new TxnBuilderTypes.RawTransaction(
209
- // TxnBuilderTypes.AccountAddress.fromHex(wallet.address || ''),
210
- // BigInt(sequnceNumber),
211
- // txnPayload,
212
- // BigInt(1000),
213
- // BigInt(1),
214
- // BigInt(Math.floor(Date.now() / 1000) + 10),
215
- // new TxnBuilderTypes.ChainId(chainId)
216
- // );
217
- // const bcsTxn = await provider?.signTransaction(rawTxn);
218
- // const response = await aptosClient.submitSignedBCSTransaction(bcsTxn);
219
- // if (response) {
220
- // console.log('tx response>>>', response);
221
- // return response;
222
- // } else {
223
- // throw new Error('Transaction failed');
224
- // }
225
- // } catch (error: any) {
226
- // const errMsg = error instanceof Error ? error.message : error.response.data.message;
227
- // throw new WalletSignTransactionError(errMsg);
228
- // }
229
- // } catch (error: any) {
230
- // this.emit('error', error);
231
- // throw error;
232
- // }
233
- // }
234
- // }
38
+ const SHA3 = __importStar(require("js-sha3"));
39
+ const aptosConstants_1 = require("../config/aptosConstants");
40
+ const errors_1 = require("../WalletProviders/errors");
41
+ const BaseAdapter_1 = require("./BaseAdapter");
42
+ class AptosPublicKey {
43
+ constructor(hexString) {
44
+ if (hexString.startsWith('0x')) {
45
+ this.hexString = hexString;
46
+ }
47
+ else {
48
+ this.hexString = `0x${hexString}`;
49
+ }
50
+ }
51
+ static default() {
52
+ return new AptosPublicKey('0'.repeat(64));
53
+ }
54
+ address() {
55
+ const hash = SHA3.sha3_256.create();
56
+ hash.update(Buffer.from(this.asPureHex(), 'hex'));
57
+ hash.update('\x00');
58
+ return '0x' + hash.hex();
59
+ }
60
+ asUint8Array() {
61
+ return new Uint8Array(Buffer.from(this.asPureHex(), 'hex'));
62
+ }
63
+ asString() {
64
+ return this.hexString;
65
+ }
66
+ asPureHex() {
67
+ return this.hexString.substr(2);
68
+ }
69
+ }
70
+ exports.AptosPublicKey = AptosPublicKey;
71
+ exports.NightlyWalletName = 'Nightly';
72
+ class NightlyWalletAdapter extends BaseAdapter_1.BaseWalletAdapter {
73
+ constructor({
74
+ // provider,
75
+ // network = WalletAdapterNetwork.Mainnet,
76
+ timeout = 10000 } = {}) {
77
+ var _a;
78
+ super();
79
+ this.name = exports.NightlyWalletName;
80
+ this.url = 'https://chrome.google.com/webstore/detail/nightly/fiikommddbeccaoicoejoniammnalkfa/related?hl=en&authuser=0';
81
+ this.icon = 'https://lh3.googleusercontent.com/_feXM9qulMM5w9BYMLzMpZrxW2WlBmdyg3SbETIoRsHdAD9PANnLCEPabC7lzEK0N8fOyyvFkY3746jk8l73zUErxhU=w128-h128-e365-rj-sc0x00ffffff';
82
+ this._readyState = typeof window === 'undefined' || typeof document === 'undefined'
83
+ ? BaseAdapter_1.WalletReadyState.Unsupported
84
+ : BaseAdapter_1.WalletReadyState.NotDetected;
85
+ this._provider = (_a = window.nightly) === null || _a === void 0 ? void 0 : _a.aptos;
86
+ // this._network = network;
87
+ this._timeout = timeout;
88
+ this._connecting = false;
89
+ this._wallet = null;
90
+ if (this._readyState !== BaseAdapter_1.WalletReadyState.Unsupported) {
91
+ (0, BaseAdapter_1.scopePollingDetectionStrategy)(() => {
92
+ var _a;
93
+ if ((_a = window.nightly) === null || _a === void 0 ? void 0 : _a.aptos) {
94
+ this._readyState = BaseAdapter_1.WalletReadyState.Installed;
95
+ this.emit('readyStateChange', this._readyState);
96
+ return true;
97
+ }
98
+ return false;
99
+ });
100
+ }
101
+ }
102
+ get publicAccount() {
103
+ var _a, _b, _c;
104
+ return {
105
+ publicKey: ((_a = this._wallet) === null || _a === void 0 ? void 0 : _a.publicKey) || null,
106
+ address: ((_b = this._wallet) === null || _b === void 0 ? void 0 : _b.address) || null,
107
+ authKey: ((_c = this._wallet) === null || _c === void 0 ? void 0 : _c.authKey) || null
108
+ };
109
+ }
110
+ get connecting() {
111
+ return this._connecting;
112
+ }
113
+ get connected() {
114
+ var _a;
115
+ return !!((_a = this._wallet) === null || _a === void 0 ? void 0 : _a.isConnected);
116
+ }
117
+ get readyState() {
118
+ return this._readyState;
119
+ }
120
+ connect() {
121
+ var _a;
122
+ return __awaiter(this, void 0, void 0, function* () {
123
+ try {
124
+ if (this.connected || this.connecting)
125
+ return;
126
+ if (!(this._readyState === BaseAdapter_1.WalletReadyState.Loadable ||
127
+ this._readyState === BaseAdapter_1.WalletReadyState.Installed))
128
+ throw new errors_1.WalletNotReadyError();
129
+ this._connecting = true;
130
+ const provider = this._provider || ((_a = window.nightly) === null || _a === void 0 ? void 0 : _a.aptos);
131
+ const publicKey = yield (provider === null || provider === void 0 ? void 0 : provider.connect(() => {
132
+ this._wallet = null;
133
+ this.emit('disconnect');
134
+ }));
135
+ this._wallet = {
136
+ publicKey: publicKey === null || publicKey === void 0 ? void 0 : publicKey.asString(),
137
+ address: publicKey === null || publicKey === void 0 ? void 0 : publicKey.address(),
138
+ isConnected: true
139
+ };
140
+ this.emit('connect', this._wallet.publicKey || '');
141
+ }
142
+ catch (error) {
143
+ this.emit('error', error);
144
+ throw error;
145
+ }
146
+ finally {
147
+ this._connecting = false;
148
+ }
149
+ });
150
+ }
151
+ disconnect() {
152
+ var _a;
153
+ return __awaiter(this, void 0, void 0, function* () {
154
+ const wallet = this._wallet;
155
+ if (wallet) {
156
+ this._wallet = null;
157
+ try {
158
+ const provider = this._provider || ((_a = window.nightly) === null || _a === void 0 ? void 0 : _a.aptos);
159
+ yield (provider === null || provider === void 0 ? void 0 : provider.disconnect());
160
+ }
161
+ catch (error) {
162
+ this.emit('error', new errors_1.WalletDisconnectionError(error === null || error === void 0 ? void 0 : error.message, error));
163
+ }
164
+ }
165
+ this.emit('disconnect');
166
+ });
167
+ }
168
+ signTransaction(payload) {
169
+ var _a;
170
+ return __awaiter(this, void 0, void 0, function* () {
171
+ try {
172
+ const wallet = this._wallet;
173
+ if (!wallet)
174
+ throw new errors_1.WalletNotConnectedError();
175
+ try {
176
+ const provider = this._provider || ((_a = window.nightly) === null || _a === void 0 ? void 0 : _a.aptos);
177
+ const response = yield (provider === null || provider === void 0 ? void 0 : provider.signTransaction(payload));
178
+ if (response) {
179
+ return response;
180
+ }
181
+ else {
182
+ throw new Error('Transaction failed');
183
+ }
184
+ }
185
+ catch (error) {
186
+ throw new errors_1.WalletSignTransactionError(error === null || error === void 0 ? void 0 : error.message, error);
187
+ }
188
+ }
189
+ catch (error) {
190
+ this.emit('error', error);
191
+ throw error;
192
+ }
193
+ });
194
+ }
195
+ signAllTransaction(payload) {
196
+ var _a;
197
+ return __awaiter(this, void 0, void 0, function* () {
198
+ try {
199
+ const wallet = this._wallet;
200
+ if (!wallet)
201
+ throw new errors_1.WalletNotConnectedError();
202
+ try {
203
+ const provider = this._provider || ((_a = window.nightly) === null || _a === void 0 ? void 0 : _a.aptos);
204
+ const response = yield (provider === null || provider === void 0 ? void 0 : provider.signAllTransactions(payload));
205
+ if (response) {
206
+ return response;
207
+ }
208
+ else {
209
+ throw new Error('Transaction failed');
210
+ }
211
+ }
212
+ catch (error) {
213
+ throw new errors_1.WalletSignTransactionError(error === null || error === void 0 ? void 0 : error.message, error);
214
+ }
215
+ }
216
+ catch (error) {
217
+ this.emit('error', error);
218
+ throw error;
219
+ }
220
+ });
221
+ }
222
+ signAndSubmitTransaction(tx) {
223
+ var _a;
224
+ return __awaiter(this, void 0, void 0, function* () {
225
+ try {
226
+ const wallet = this._wallet;
227
+ if (!wallet)
228
+ throw new errors_1.WalletNotConnectedError();
229
+ try {
230
+ const provider = this._provider || ((_a = window.nightly) === null || _a === void 0 ? void 0 : _a.aptos);
231
+ const response = yield (provider === null || provider === void 0 ? void 0 : provider.signTransaction(tx));
232
+ const result = yield aptosConstants_1.aptosClient.submitSignedBCSTransaction(response);
233
+ if (response) {
234
+ return result;
235
+ }
236
+ else {
237
+ throw new Error('Transaction failed');
238
+ }
239
+ }
240
+ catch (error) {
241
+ const errMsg = error instanceof Error ? error.message : error.response.data.message;
242
+ throw new errors_1.WalletSignTransactionError(errMsg);
243
+ }
244
+ }
245
+ catch (error) {
246
+ this.emit('error', error);
247
+ throw error;
248
+ }
249
+ });
250
+ }
251
+ signMessage(message) {
252
+ return __awaiter(this, void 0, void 0, function* () {
253
+ try {
254
+ const wallet = this._wallet;
255
+ const provider = this._provider || window.nightly.aptos;
256
+ if (!wallet || !provider)
257
+ throw new errors_1.WalletNotConnectedError();
258
+ const response = yield (provider === null || provider === void 0 ? void 0 : provider.signMessage(message));
259
+ if (response) {
260
+ return Buffer.from(response).toString('hex');
261
+ }
262
+ else {
263
+ throw new Error('Sign Message failed');
264
+ }
265
+ }
266
+ catch (error) {
267
+ const errMsg = error.message;
268
+ this.emit('error', new errors_1.WalletSignMessageError(errMsg));
269
+ throw error;
270
+ }
271
+ });
272
+ }
273
+ }
274
+ exports.NightlyWalletAdapter = NightlyWalletAdapter;
235
275
  //# sourceMappingURL=NightlyWallet.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"NightlyWallet.js","sourceRoot":"","sources":["../../src/WalletAdapters/NightlyWallet.ts"],"names":[],"mappings":";;;AAAO,MAAM,aAAa,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;AAAzB,QAAA,aAAa,iBAAY;AACtC,gDAAgD;AAChD,WAAW;AACX,wBAAwB;AACxB,2BAA2B;AAC3B,8BAA8B;AAC9B,uBAAuB;AACvB,0CAA0C;AAC1C,WA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AAQ,CAAC,IAAI,CAAC,OAAO,CAAC;oBACpF,MAAM,IAAI,mCAA0B,CAAC,MAAM,CAAC,CAAC;iBAC9C;aACF;YAAC,OAAO,KAAU,EAAE;gBACnB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;gBAC1B,MAAM,KAAK,CAAC;aACb;;KACF;IAEK,WAAW,CAAC,OAAe;;YAC/B,IAAI;gBACF,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC;gBAC5B,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;gBACxD,IAAI,CAAC,MAAM,IAAI,CAAC,QAAQ;oBAAE,MAAM,IAAI,gCAAuB,EAAE,CAAC;gBAC9D,MAAM,QAAQ,GAAG,MAAM,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,WAAW,CAAC,OAAO,CAAC,CAAA,CAAC;gBACtD,IAAI,QAAQ,EAAE;oBACZ,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;iBAC9C;qBAAM;oBACL,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;iBACxC;aACF;YAAC,OAAO,KAAU,EAAE;gBACnB,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC;gBAC7B,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,+BAAsB,CAAC,MAAM,CAAC,CAAC,CAAC;gBACvD,MAAM,KAAK,CAAC;aACb;QACH,CAAC;KAAA;CACF;AA9MD,oDA8MC"}
@@ -5,6 +5,7 @@ export * from './HippoWallet';
5
5
  export * from './MartianWallet';
6
6
  export * from './FewchaWallet';
7
7
  export * from './PontemWallet';
8
+ export * from './NightlyWallet';
8
9
  export * from './RiseWallet';
9
10
  export * from './SpikaWallet';
10
11
  export * from './HyperPayWallet';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/WalletAdapters/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAE/B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/WalletAdapters/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC"}
@@ -21,7 +21,7 @@ __exportStar(require("./HippoWallet"), exports);
21
21
  __exportStar(require("./MartianWallet"), exports);
22
22
  __exportStar(require("./FewchaWallet"), exports);
23
23
  __exportStar(require("./PontemWallet"), exports);
24
- // export * from './NightlyWallet';
24
+ __exportStar(require("./NightlyWallet"), exports);
25
25
  __exportStar(require("./RiseWallet"), exports);
26
26
  __exportStar(require("./SpikaWallet"), exports);
27
27
  __exportStar(require("./HyperPayWallet"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/WalletAdapters/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,gDAA8B;AAC9B,yDAAuC;AACvC,gDAA8B;AAC9B,kDAAgC;AAChC,iDAA+B;AAC/B,iDAA+B;AAC/B,mCAAmC;AACnC,+CAA6B;AAC7B,gDAA8B;AAC9B,mDAAiC;AACjC,iDAA+B;AAC/B,8CAA4B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/WalletAdapters/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,gDAA8B;AAC9B,yDAAuC;AACvC,gDAA8B;AAC9B,kDAAgC;AAChC,iDAA+B;AAC/B,iDAA+B;AAC/B,kDAAgC;AAChC,+CAA6B;AAC7B,gDAA8B;AAC9B,mDAAiC;AACjC,iDAA+B;AAC/B,8CAA4B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manahippo/aptos-wallet-adapter",
3
- "version": "0.4.4",
3
+ "version": "0.4.5",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "files": [
@@ -30,6 +30,7 @@
30
30
  "@types/node": "^18.7.6",
31
31
  "@types/react": "^18.0.17",
32
32
  "aptos": "^1.3.14",
33
- "eventemitter3": "^4.0.7"
33
+ "eventemitter3": "^4.0.7",
34
+ "js-sha3": "^0.8.0"
34
35
  }
35
36
  }
@@ -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
+ }
@@ -5,7 +5,7 @@ export * from './HippoWallet';
5
5
  export * from './MartianWallet';
6
6
  export * from './FewchaWallet';
7
7
  export * from './PontemWallet';
8
- // export * from './NightlyWallet';
8
+ export * from './NightlyWallet';
9
9
  export * from './RiseWallet';
10
10
  export * from './SpikaWallet';
11
11
  export * from './HyperPayWallet';