Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/docs/app/components/full-page-buynow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function FullPageBuyNow({ rpcUrl }: FullPageBuyNowProps = {}) {
return (
<PaymentButton
config={{
rpcUrl,
rpcUrl: rpcUrl || process.env.NEXT_PUBLIC_SOLANA_RPC_URL,
mode: 'buyNow',
position: 'inline',
merchant: {
Expand Down
2 changes: 1 addition & 1 deletion packages/connector/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@solana-commerce/connector",
"version": "0.0.0",
"version": "0.1.0",
"description": "Headless wallet connector client and React provider built on Wallet Standard",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
Expand Down
27 changes: 4 additions & 23 deletions packages/connector/src/__tests__/connector-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -685,33 +685,14 @@ describe('ConnectorClient', () => {
});

describe('Debug Mode', () => {
it('should log debug information when enabled', async () => {
const consoleSpy = vi.spyOn(console, 'log').mockImplementation(() => {});

const mockWallet = createMockWallet('Phantom');
mockWalletsApi.get.mockReturnValue([mockWallet]);

it('should accept debug config option', () => {
const client = new ConnectorClient({ debug: true });
await client.select('Phantom');

expect(consoleSpy).toHaveBeenCalled();

consoleSpy.mockRestore();
expect(client).toBeDefined();
});

it('should not log debug information when disabled', async () => {
const consoleSpy = vi.spyOn(console, 'log').mockImplementation(() => {});

const mockWallet = createMockWallet('Phantom');
mockWalletsApi.get.mockReturnValue([mockWallet]);

it('should work without debug config', () => {
const client = new ConnectorClient({ debug: false });
await client.select('Phantom');

// Should not have debug logs
expect(consoleSpy).not.toHaveBeenCalled();

consoleSpy.mockRestore();
expect(client).toBeDefined();
});
});

Expand Down
18 changes: 0 additions & 18 deletions packages/connector/src/lib/connector-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,6 @@ export class ConnectorClient {

this.state = { ...this.state, accounts: nextAccounts, selectedAccount: newSelected };
this.notify();

if (this.config.debug) {
console.log('[Connector] Wallet accounts changed:', nextAccounts.length, 'accounts');
}
});
} catch (error) {
if (this.config.debug) {
Expand Down Expand Up @@ -323,14 +319,6 @@ export class ConnectorClient {
const firstNew = accounts.find(a => !previousAddresses.has(a.address));
const selected = firstNew?.address ?? previouslySelected ?? accounts[0]?.address ?? null;

if (this.config.debug) {
console.log(`[Connector] Connected to ${walletName} with ${accounts.length} accounts`);
console.log(
'[Connector] Accounts:',
accounts.map((a: AccountInfo) => a.address),
);
console.log('[Connector] Selected account:', selected);
}
this.state = {
...this.state,
selectedWallet: w.wallet,
Expand Down Expand Up @@ -374,9 +362,6 @@ export class ConnectorClient {
if (disconnectFeature) {
try {
await (disconnectFeature as StandardDisconnectFeature['standard:disconnect']).disconnect();
if (this.config.debug) {
console.log('[Connector] Called wallet disconnect feature');
}
} catch (error) {
if (this.config.debug) {
console.warn('[Connector] Wallet disconnect failed:', error);
Expand Down Expand Up @@ -451,8 +436,5 @@ export class ConnectorClient {
this.unsubscribers = [];
// Clear external store listeners
this.listeners.clear();
if (this.config.debug) {
console.log('[Connector] destroyed');
}
}
}
4 changes: 0 additions & 4 deletions packages/connector/src/ui/connector-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,21 @@ function getOrCreateConnectorClient(config?: ConnectorConfig): ConnectorClient {
}

if (!globalConnectorClient) {
console.log('[ConnectorProvider] Creating singleton ConnectorClient');
globalConnectorClient = new ConnectorClient(config);
}

providerRefCount++;
console.log('[ConnectorProvider] Provider mounted, ref count:', providerRefCount);

return globalConnectorClient;
}

function releaseConnectorClient(): void {
providerRefCount--;
console.log('[ConnectorProvider] Provider unmounted, ref count:', providerRefCount);

if (providerRefCount <= 0) {
// Delay cleanup to handle rapid mount/unmount cycles
cleanupTimeoutId = setTimeout(() => {
if (providerRefCount <= 0 && globalConnectorClient) {
console.log('[ConnectorProvider] Cleaning up singleton ConnectorClient');
// Disconnect wallet before cleanup
globalConnectorClient.disconnect().catch(console.warn);
// If the client has a destroy method, call it
Expand Down
2 changes: 1 addition & 1 deletion packages/headless/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@solana-commerce/headless",
"version": "0.1.0",
"version": "0.1.1",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@solana-commerce/react",
"version": "0.1.0",
"version": "0.1.1",
"description": "React SDK for Commerce platform",
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,22 +190,6 @@ describe('Transaction State Components', () => {
expect(onViewTransaction).toHaveBeenCalledWith(defaultSuccessProps.signature);
});

it('should render close button', () => {
render(<TransactionSuccess {...defaultSuccessProps} />);

expect(screen.getByText('Close')).toBeInTheDocument();
});

it('should call onClose when close button is clicked', () => {
const onClose = vi.fn();
render(<TransactionSuccess {...defaultSuccessProps} onClose={onClose} />);

const closeButton = screen.getByText('Close');
fireEvent.click(closeButton);

expect(onClose).toHaveBeenCalledTimes(1);
});

it('should handle different currencies correctly', () => {
const { rerender } = render(<TransactionSuccess {...defaultSuccessProps} currency="SOL" amount={0.5} />);

Expand Down
30 changes: 21 additions & 9 deletions packages/react/src/components/iframe/iframe-wallet-payment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -354,15 +354,27 @@ export const WalletPaymentContent = ({
// Use '*' for srcDoc iframes since origin detection may fail
const targetOrigin = isInSrcDoc ? '*' : parentOrigin || '*';

window.parent.postMessage(
{
type: 'walletConnect',
walletName,
amount: amountValue,
currency: selectedCurrency,
},
targetOrigin,
);
const message = {
type: 'walletConnect',
walletName,
amount: amountValue,
currency: selectedCurrency,
};

if (config.debug) {
console.log('[IframeWalletPayment] Sending walletConnect message to parent:', {
message,
targetOrigin,
isInSrcDoc,
parentOrigin,
});
}

window.parent.postMessage(message, targetOrigin);

if (config.debug) {
console.log('[IframeWalletPayment] walletConnect message sent successfully');
}
} catch (e: any) {
setConnecting(null);
setError(e?.message || 'Failed to request wallet connect');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,6 @@ export function TransactionSuccess({
</svg>
</a>
)}

<button
type="button"
onClick={onClose}
className="ck-transaction-close-button"
style={{ color: theme.textColor }}
>
Close
</button>
</div>
</div>
);
Expand Down
Loading