Skip to content

Commit 8a01358

Browse files
fix: show pusher payout result
1 parent ebba430 commit 8a01358

File tree

9 files changed

+355
-14
lines changed

9 files changed

+355
-14
lines changed

packages/connectkit/.eslintignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules
2+
build
3+
dist
4+
*.d.ts
5+
rollup.config.js
6+
bundle-analysis.html
7+

packages/connectkit/.eslintrc.json

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,23 @@
55
"sourceType": "module",
66
"ecmaFeatures": { "jsx": true }
77
},
8-
"plugins": ["react-hooks"],
9-
"extends": ["plugin:react/recommended", "plugin:react-hooks/recommended"],
8+
"plugins": ["@typescript-eslint", "react", "react-hooks"],
9+
"extends": [
10+
"eslint:recommended",
11+
"plugin:@typescript-eslint/recommended",
12+
"plugin:react/recommended",
13+
"plugin:react-hooks/recommended"
14+
],
15+
"settings": {
16+
"react": {
17+
"version": "detect"
18+
}
19+
},
1020
"rules": {
1121
"react-hooks/rules-of-hooks": "error",
1222
"react-hooks/exhaustive-deps": "warn",
13-
"react/react-in-jsx-scope": "off"
23+
"react/react-in-jsx-scope": "off",
24+
"@typescript-eslint/no-explicit-any": "warn",
25+
"@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }]
1426
}
1527
}

packages/connectkit/bundle-analysis.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

packages/connectkit/package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
".": {
1313
"import": "./build/src/index.js",
1414
"types": "./build/index.d.ts"
15-
},
16-
"./world": {
17-
"import": "./build/src/world.js",
18-
"types": "./build/world.d.ts"
1915
}
2016
},
2117
"types": "./build/index.d.ts",
@@ -69,7 +65,8 @@
6965
"react-use-measure": "^2.1.1",
7066
"resize-observer-polyfill": "^1.5.1",
7167
"styled-components": "^5.3.5",
72-
"pino-pretty": "^10.0.0"
68+
"pino-pretty": "^10.0.0",
69+
"pusher-js": "^8.4.0"
7370
},
7471
"peerDependencies": {
7572
"@creit.tech/stellar-wallets-kit": "^1.9.5",
@@ -101,7 +98,11 @@
10198
"@types/react-dom": "^18.2.18",
10299
"@types/rollup-plugin-peer-deps-external": "^2.2.5",
103100
"@types/styled-components": "^5.1.25",
101+
"@typescript-eslint/eslint-plugin": "^6.21.0",
102+
"@typescript-eslint/parser": "^6.21.0",
104103
"@walletconnect/types": "^2.22.3",
104+
"eslint": "^8.57.0",
105+
"eslint-plugin-react": "^7.37.0",
105106
"eslint-plugin-react-hooks": "^5.2.0",
106107
"rollup": "^3.29.5",
107108
"rollup-plugin-dts": "^6.1.1",

packages/connectkit/rollup.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { visualizer } from "rollup-plugin-visualizer";
77
export default [
88
// Build a folder of files for better tree-shaking
99
{
10-
input: ["./src/index.ts", "./src/world.ts"],
10+
input: ["./src/index.ts"],
1111
external: [
1212
"@creit.tech/stellar-wallets-kit",
1313
"@reown/appkit",
@@ -35,6 +35,7 @@ export default [
3535
"styled-components",
3636
"wagmi",
3737
"react",
38+
"pusher-js",
3839
],
3940
output: [
4041
{

packages/connectkit/src/components/Pages/Confirmation/index.tsx

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
} from "../../../constants/rozoConfig";
3232
import { useRozoPay } from "../../../hooks/useDaimoPay";
3333
import { usePayoutPolling } from "../../../hooks/usePayoutPolling";
34+
import { usePusherPayout } from "../../../hooks/usePusherPayout";
3435
import { useSupportedChains } from "../../../hooks/useSupportedChains";
3536
import styled from "../../../styles/styled";
3637
import Button from "../../Common/Button";
@@ -58,6 +59,14 @@ const Confirmation: React.FC = () => {
5859
const paymentCompletedSent = React.useRef<string | null>(null);
5960
const payoutCompletedSent = React.useRef<string | null>(null);
6061

62+
// Local state for Pusher payout transaction hash
63+
const [pusherPayoutTxHash, setPusherPayoutTxHash] = useState<
64+
string | undefined
65+
>(undefined);
66+
const [pusherPayoutTxHashUrl, setPusherPayoutTxHashUrl] = useState<
67+
string | undefined
68+
>(undefined);
69+
6170
const showProcessingPayout = useMemo(() => {
6271
const { payParams, tokenMode } = paymentStateContext;
6372

@@ -165,7 +174,7 @@ const Confirmation: React.FC = () => {
165174

166175
// Use payout polling hook
167176
const { payoutLoading, payoutTxHash, payoutTxHashUrl } = usePayoutPolling({
168-
enabled: showProcessingPayout,
177+
enabled: false,
169178
rozoPaymentId,
170179
order,
171180
done,
@@ -174,6 +183,42 @@ const Confirmation: React.FC = () => {
174183
triggerResize,
175184
});
176185

186+
// Use Pusher hook for real-time status updates
187+
const enablePusher = context.options?.enablePusher ?? false;
188+
usePusherPayout({
189+
enabled: enablePusher,
190+
rozoPaymentId,
191+
onPayoutCompleted: (payload) => {
192+
context.log("[CONFIRMATION] Pusher payout completed:", payload);
193+
// If we receive payout completed from Pusher and have the destination txhash,
194+
// we can use it to update the payout state
195+
if (payload.destination_txhash && rozoPaymentId) {
196+
const payoutKey = `${payload.destination_txhash}-${rozoPaymentId}`;
197+
if (payoutCompletedSent.current !== payoutKey) {
198+
payoutCompletedSent.current = payoutKey;
199+
200+
// Update local state for UI display
201+
setPusherPayoutTxHash(payload.destination_txhash);
202+
203+
// Generate transaction URL if we have the order
204+
if (order) {
205+
const destChainId = getOrderDestChainId(order);
206+
const txUrl = getChainExplorerTxUrl(
207+
destChainId,
208+
payload.destination_txhash
209+
);
210+
setPusherPayoutTxHashUrl(txUrl);
211+
}
212+
213+
// Update payment state
214+
setPaymentPayoutCompleted(payload.destination_txhash, rozoPaymentId);
215+
triggerResize();
216+
}
217+
}
218+
},
219+
log: context.log,
220+
});
221+
177222
/**
178223
* Sets the payment completed state.
179224
* This is called when the payment is confirmed and the transaction hash is available.
@@ -297,14 +342,17 @@ const Confirmation: React.FC = () => {
297342
<ModalBody>
298343
{payoutLoading ? (
299344
<LoadingText>Processing payout...</LoadingText>
300-
) : payoutTxHashUrl && payoutTxHash ? (
345+
) : (pusherPayoutTxHashUrl && pusherPayoutTxHash) ||
346+
(payoutTxHashUrl && payoutTxHash) ? (
301347
<Link
302-
href={payoutTxHashUrl}
348+
href={pusherPayoutTxHashUrl || payoutTxHashUrl || "#"}
303349
target="_blank"
304350
rel="noopener noreferrer"
305351
style={{ fontSize: 14, fontWeight: 400 }}
306352
>
307-
{getAddressContraction(payoutTxHash)}
353+
{getAddressContraction(
354+
pusherPayoutTxHash || payoutTxHash || ""
355+
)}
308356
<ExternalIcon />
309357
</Link>
310358
) : (

0 commit comments

Comments
 (0)