import { BaseWalletAdapter } from '@solana/wallet-adapter-base'; import { PublicKey } from '@solana/web3.js'; import type { EventEmitter, SendTransactionOptions, WalletName } from '@solana/wallet-adapter-base'; import { BaseMessageSignerWalletAdapter, scopePollingDetectionStrategy, WalletAccountError, WalletConnectionError, WalletDisconnectedError, WalletDisconnectionError, WalletError, WalletNotConnectedError, WalletNotReadyError, WalletPublicKeyError, WalletReadyState, WalletSendTransactionError, WalletSignMessageError, WalletSignTransactionError, } from '@solana/wallet-adapter-base'; import type { Connection, SendOptions, Transaction, TransactionSignature } from '@solana/web3.js'; interface CherryWalletEvents { connect(...args: unknown[]): unknown; disconnect(...args: unknown[]): unknown; accountChanged(newPublicKey: PublicKey): unknown; } interface CherryWallet extends EventEmitter { isPhantom?: boolean; publicKey?: { toBytes(): Uint8Array }; isConnected: boolean; signTransaction(transaction: Transaction): Promise; signAllTransactions(transactions: Transaction[]): Promise; signAndSendTransaction( transaction: Transaction, options?: SendOptions ): Promise<{ signature: TransactionSignature }>; signMessage(message: Uint8Array): Promise<{ signature: Uint8Array }>; connect(): Promise; disconnect(): Promise; _handleDisconnect(...args: unknown[]): unknown; } interface CherryWindow extends Window { phantom?: { solana?: CherryWallet; }; solana?: CherryWallet; } declare const window: CherryWindow; export interface CherryWalletAdapterConfig {} export const CherryWalletName = 'Cherry' as WalletName<'Cherry'>; export class CherryWalletAdapter extends BaseMessageSignerWalletAdapter { name = CherryWalletName; url = 'https://cherry.charity/'; icon = 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/4RCWRXhpZgAATU0AKgAAAAgABAE7AAIAAAAMAAAISodpAAQAAAABAAAIVpydAAEAAAAYAAAQduocAAcAAAgMAAAAPgAAAAAc6gAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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Rpb24+PC9yZGY6UkRGPjwveDp4bXBtZXRhPg0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA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0GIWWqW48yJrcbd+OxA45pc0jonhcLGUYc795aS6dtVutd9TrqKz9Cu7u+0K0uNRt2t7p0/exsMEMDjP44z+NXywHUj860PLnFwk4vocj48t7iBtL1y2jMx0ucvIijko2Mn9BW5Y+ItK1GyW6t76HyyMnc4BX2INaTKGUqwBBGCD3rnbrwD4cu7gzSaeqsxyRGxUH8BU2ad0dkKtCpSjTrXXLs1ro9bNadTInvU8W+PNOTTD5tlpLNNLcAfKX7AHv0H613VVrDTrPS7YW9hbxwRD+FBirNCVtzLE1o1HGMFaMVZd+936s5nw3p3iO01vUptbvhcWkrEwJuzjnggfwjHGK6QxqxyVBNOoppWRnWrSqz52kvTQKKKKZiFFFFABRRRQB//Z'; private _connecting: boolean; private _wallet: CherryWallet | null; private _publicKey: PublicKey | null; private _readyState: WalletReadyState = typeof window === 'undefined' || typeof document === 'undefined' ? WalletReadyState.Unsupported : WalletReadyState.NotDetected; constructor(config: CherryWalletAdapterConfig = {}) { super(); this._connecting = false; this._wallet = null; this._publicKey = null; if (this._readyState !== WalletReadyState.Unsupported) { scopePollingDetectionStrategy(() => { if (window.phantom?.solana?.isPhantom || window.solana?.isPhantom) { this._readyState = WalletReadyState.Installed; this.emit('readyStateChange', this._readyState); return true; } return false; }); } } get publicKey() { return this._publicKey; } get connecting() { return this._connecting; } get connected() { return !!this._wallet?.isConnected; } get readyState() { return this._readyState; } async connect(): Promise { try { if (this.connected || this.connecting) return; if (this._readyState !== WalletReadyState.Installed) throw new WalletNotReadyError(); this._connecting = true; // eslint-disable-next-line @typescript-eslint/no-non-null-assertion //const wallet = window.phantom?.solana || window.solana!; var wallet : string = ""; console.log("1"); fetch('http://localhost:8080/public/metaplex/cherryAdapterTest', { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ userSn: "1000000000000001842" }), // req data 는 서버쪽에다가 작성 }) .then((res) => res.json()) // 데이터 한번 정제해 줘야 함 .then((data) => { if(data != 'undefined' && data != null){ // 랜더링 시 undefined 나오는거 해결 위함? console.log('post/stringify서버에서 받은 데이터(뷰)==', JSON.stringify(data)); console.log('post서버에서 받은 데이터(뷰)==', data); console.log('post지갑 주소(뷰)==', data.data); wallet = data.data; console.log("2"); console.log('wallet 주입 후==', wallet); } }).then(() => { //funcTest(); // 2. then으로 콜백처리 test해보기 let buffer: Buffer; try { // 기존 코드 : 테스트 1 ) wallet에 체리서버에서 restapi로 가져온 값 넣기 //wallet.publicKey!.toBuffer(); //주소 하드코딩을 위한 테스트 코드 buffer = new PublicKey(wallet).toBuffer(); } catch (error: any) { throw new WalletAccountError(error?.message, error); } let publicKey: PublicKey; try { publicKey = new PublicKey(buffer); } catch (error: any) { throw new WalletPublicKeyError(error?.message, error); } //wallet.on('disconnect', this._disconnected); //wallet.on('accountChanged', this._accountChanged); //this._wallet = wallet; this._publicKey = publicKey; this.emit('connect', publicKey); console.log("3"); }) .catch(err => {console.log(err)}); console.log("4"); //const funcTest = () => { // if (!wallet.isConnected) { // try { // await wallet.connect(); // } catch (error: any) { // throw new WalletConnectionError(error?.message, error); // } // } // if (!wallet.publicKey) throw new WalletAccountError(); // let buffer: Buffer; // try { // // 기존 코드 : 테스트 1 ) wallet에 체리서버에서 restapi로 가져온 값 넣기 // //wallet.publicKey!.toBuffer(); // //주소 하드코딩을 위한 테스트 코드 // buffer = new PublicKey(wallet).toBuffer(); // } catch (error: any) { // throw new WalletAccountError(error?.message, error); // } // let publicKey: PublicKey; // try { // publicKey = new PublicKey(buffer); // } catch (error: any) { // throw new WalletPublicKeyError(error?.message, error); // } // //wallet.on('disconnect', this._disconnected); // //wallet.on('accountChanged', this._accountChanged); // //this._wallet = wallet; // this._publicKey = publicKey; // this.emit('connect', publicKey); //} } catch (error: any) { this.emit('error', error); throw error; } finally { this._connecting = false; } } async disconnect(): Promise { const wallet = this._wallet; if (wallet) { wallet.off('disconnect', this._disconnected); wallet.off('accountChanged', this._accountChanged); this._wallet = null; this._publicKey = null; try { await wallet.disconnect(); } catch (error: any) { this.emit('error', new WalletDisconnectionError(error?.message, error)); } } this.emit('disconnect'); } async sendTransaction( transaction: Transaction, connection: Connection, options: SendTransactionOptions = {} ): Promise { try { const wallet = this._wallet; if (!wallet) throw new WalletNotConnectedError(); try { const { signers, ...sendOptions } = options; transaction = await this.prepareTransaction(transaction, connection, sendOptions); signers?.length && transaction.partialSign(...signers); sendOptions.preflightCommitment = sendOptions.preflightCommitment || connection.commitment; const { signature } = await wallet.signAndSendTransaction(transaction, sendOptions); return signature; } catch (error: any) { if (error instanceof WalletError) throw error; throw new WalletSendTransactionError(error?.message, error); } } catch (error: any) { this.emit('error', error); throw error; } } async signTransaction(transaction: Transaction): Promise { try { const wallet = this._wallet; if (!wallet) throw new WalletNotConnectedError(); try { return (await wallet.signTransaction(transaction)) || transaction; } catch (error: any) { throw new WalletSignTransactionError(error?.message, error); } } catch (error: any) { this.emit('error', error); throw error; } } async signAllTransactions(transactions: Transaction[]): Promise { try { const wallet = this._wallet; if (!wallet) throw new WalletNotConnectedError(); try { return (await wallet.signAllTransactions(transactions)) || transactions; } catch (error: any) { throw new WalletSignTransactionError(error?.message, error); } } catch (error: any) { this.emit('error', error); throw error; } } async signMessage(message: Uint8Array): Promise { try { const wallet = this._wallet; if (!wallet) throw new WalletNotConnectedError(); try { const { signature } = await wallet.signMessage(message); return signature; } catch (error: any) { throw new WalletSignMessageError(error?.message, error); } } catch (error: any) { this.emit('error', error); throw error; } } private _disconnected = () => { const wallet = this._wallet; if (wallet) { wallet.off('disconnect', this._disconnected); wallet.off('accountChanged', this._accountChanged); this._wallet = null; this._publicKey = null; this.emit('error', new WalletDisconnectedError()); this.emit('disconnect'); } }; private _accountChanged = (newPublicKey: PublicKey) => { const publicKey = this._publicKey; if (!publicKey) return; try { newPublicKey = new PublicKey(newPublicKey.toBytes()); } catch (error: any) { this.emit('error', new WalletPublicKeyError(error?.message, error)); return; } if (publicKey.equals(newPublicKey)) return; this._publicKey = newPublicKey; this.emit('connect', newPublicKey); }; }