Skip to content

Commit 684b5dd

Browse files
Merge pull request #42 from solana-foundation/hotfix-tx
fix wallet transaction flow
2 parents 721b18a + 6de7d43 commit 684b5dd

88 files changed

Lines changed: 5504 additions & 5687 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/docs/app/components/full-page-buynow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export function FullPageBuyNow({ rpcUrl }: FullPageBuyNowProps = {}) {
1010
return (
1111
<PaymentButton
1212
config={{
13-
rpcUrl,
13+
rpcUrl: rpcUrl || process.env.NEXT_PUBLIC_SOLANA_RPC_URL,
1414
mode: 'buyNow',
1515
position: 'inline',
1616
merchant: {

packages/connector/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@solana-commerce/connector",
3-
"version": "0.0.0",
3+
"version": "0.1.0",
44
"description": "Headless wallet connector client and React provider built on Wallet Standard",
55
"main": "./dist/index.js",
66
"module": "./dist/index.mjs",

packages/connector/src/__tests__/connector-client.test.ts

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -685,33 +685,14 @@ describe('ConnectorClient', () => {
685685
});
686686

687687
describe('Debug Mode', () => {
688-
it('should log debug information when enabled', async () => {
689-
const consoleSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
690-
691-
const mockWallet = createMockWallet('Phantom');
692-
mockWalletsApi.get.mockReturnValue([mockWallet]);
693-
688+
it('should accept debug config option', () => {
694689
const client = new ConnectorClient({ debug: true });
695-
await client.select('Phantom');
696-
697-
expect(consoleSpy).toHaveBeenCalled();
698-
699-
consoleSpy.mockRestore();
690+
expect(client).toBeDefined();
700691
});
701692

702-
it('should not log debug information when disabled', async () => {
703-
const consoleSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
704-
705-
const mockWallet = createMockWallet('Phantom');
706-
mockWalletsApi.get.mockReturnValue([mockWallet]);
707-
693+
it('should work without debug config', () => {
708694
const client = new ConnectorClient({ debug: false });
709-
await client.select('Phantom');
710-
711-
// Should not have debug logs
712-
expect(consoleSpy).not.toHaveBeenCalled();
713-
714-
consoleSpy.mockRestore();
695+
expect(client).toBeDefined();
715696
});
716697
});
717698

packages/connector/src/lib/connector-client.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,6 @@ export class ConnectorClient {
280280

281281
this.state = { ...this.state, accounts: nextAccounts, selectedAccount: newSelected };
282282
this.notify();
283-
284-
if (this.config.debug) {
285-
console.log('[Connector] Wallet accounts changed:', nextAccounts.length, 'accounts');
286-
}
287283
});
288284
} catch (error) {
289285
if (this.config.debug) {
@@ -323,14 +319,6 @@ export class ConnectorClient {
323319
const firstNew = accounts.find(a => !previousAddresses.has(a.address));
324320
const selected = firstNew?.address ?? previouslySelected ?? accounts[0]?.address ?? null;
325321

326-
if (this.config.debug) {
327-
console.log(`[Connector] Connected to ${walletName} with ${accounts.length} accounts`);
328-
console.log(
329-
'[Connector] Accounts:',
330-
accounts.map((a: AccountInfo) => a.address),
331-
);
332-
console.log('[Connector] Selected account:', selected);
333-
}
334322
this.state = {
335323
...this.state,
336324
selectedWallet: w.wallet,
@@ -374,9 +362,6 @@ export class ConnectorClient {
374362
if (disconnectFeature) {
375363
try {
376364
await (disconnectFeature as StandardDisconnectFeature['standard:disconnect']).disconnect();
377-
if (this.config.debug) {
378-
console.log('[Connector] Called wallet disconnect feature');
379-
}
380365
} catch (error) {
381366
if (this.config.debug) {
382367
console.warn('[Connector] Wallet disconnect failed:', error);
@@ -451,8 +436,5 @@ export class ConnectorClient {
451436
this.unsubscribers = [];
452437
// Clear external store listeners
453438
this.listeners.clear();
454-
if (this.config.debug) {
455-
console.log('[Connector] destroyed');
456-
}
457439
}
458440
}

packages/connector/src/ui/connector-provider.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,21 @@ function getOrCreateConnectorClient(config?: ConnectorConfig): ConnectorClient {
2626
}
2727

2828
if (!globalConnectorClient) {
29-
console.log('[ConnectorProvider] Creating singleton ConnectorClient');
3029
globalConnectorClient = new ConnectorClient(config);
3130
}
3231

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

3634
return globalConnectorClient;
3735
}
3836

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

4340
if (providerRefCount <= 0) {
4441
// Delay cleanup to handle rapid mount/unmount cycles
4542
cleanupTimeoutId = setTimeout(() => {
4643
if (providerRefCount <= 0 && globalConnectorClient) {
47-
console.log('[ConnectorProvider] Cleaning up singleton ConnectorClient');
4844
// Disconnect wallet before cleanup
4945
globalConnectorClient.disconnect().catch(console.warn);
5046
// If the client has a destroy method, call it

packages/headless/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@solana-commerce/headless",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"main": "./dist/index.js",
55
"module": "./dist/index.mjs",
66
"types": "./dist/index.d.ts",

packages/react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@solana-commerce/react",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"description": "React SDK for Commerce platform",
55
"main": "dist/index.js",
66
"module": "dist/index.mjs",

packages/react/src/__tests__/components/transaction-states.test.tsx

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -190,22 +190,6 @@ describe('Transaction State Components', () => {
190190
expect(onViewTransaction).toHaveBeenCalledWith(defaultSuccessProps.signature);
191191
});
192192

193-
it('should render close button', () => {
194-
render(<TransactionSuccess {...defaultSuccessProps} />);
195-
196-
expect(screen.getByText('Close')).toBeInTheDocument();
197-
});
198-
199-
it('should call onClose when close button is clicked', () => {
200-
const onClose = vi.fn();
201-
render(<TransactionSuccess {...defaultSuccessProps} onClose={onClose} />);
202-
203-
const closeButton = screen.getByText('Close');
204-
fireEvent.click(closeButton);
205-
206-
expect(onClose).toHaveBeenCalledTimes(1);
207-
});
208-
209193
it('should handle different currencies correctly', () => {
210194
const { rerender } = render(<TransactionSuccess {...defaultSuccessProps} currency="SOL" amount={0.5} />);
211195

packages/react/src/components/iframe/iframe-wallet-payment.tsx

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -354,15 +354,27 @@ export const WalletPaymentContent = ({
354354
// Use '*' for srcDoc iframes since origin detection may fail
355355
const targetOrigin = isInSrcDoc ? '*' : parentOrigin || '*';
356356

357-
window.parent.postMessage(
358-
{
359-
type: 'walletConnect',
360-
walletName,
361-
amount: amountValue,
362-
currency: selectedCurrency,
363-
},
364-
targetOrigin,
365-
);
357+
const message = {
358+
type: 'walletConnect',
359+
walletName,
360+
amount: amountValue,
361+
currency: selectedCurrency,
362+
};
363+
364+
if (config.debug) {
365+
console.log('[IframeWalletPayment] Sending walletConnect message to parent:', {
366+
message,
367+
targetOrigin,
368+
isInSrcDoc,
369+
parentOrigin,
370+
});
371+
}
372+
373+
window.parent.postMessage(message, targetOrigin);
374+
375+
if (config.debug) {
376+
console.log('[IframeWalletPayment] walletConnect message sent successfully');
377+
}
366378
} catch (e: any) {
367379
setConnecting(null);
368380
setError(e?.message || 'Failed to request wallet connect');

packages/react/src/components/transaction-states/TransactionSuccess.tsx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,6 @@ export function TransactionSuccess({
102102
</svg>
103103
</a>
104104
)}
105-
106-
<button
107-
type="button"
108-
onClick={onClose}
109-
className="ck-transaction-close-button"
110-
style={{ color: theme.textColor }}
111-
>
112-
Close
113-
</button>
114105
</div>
115106
</div>
116107
);

0 commit comments

Comments
 (0)