zh-web-sdk 2.10.13 → 2.10.14

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zh-web-sdk",
3
- "version": "2.10.13",
3
+ "version": "2.10.14",
4
4
  "private": false,
5
5
  "description": "ZeroHash Web SDK",
6
6
  "homepage": "https://github.com/seedcx/zh-web-sdk",
@@ -258,45 +258,42 @@ const AppContainer = ({
258
258
 
259
259
  const eventHandler = useCallback(
260
260
  async (event: MessageEvent) => {
261
+ if (!MiniKit.isInstalled()) {
262
+ const result = MiniKit.install();
263
+ console.log("MiniKit not installed, installing now", { result });
264
+ }
261
265
  if (event.data?.type === "MINIKIT_PAY_COMMAND") {
262
- if (!MiniKit.isInstalled()) {
263
- console.log("Minikit not installed. Installing minikit under sdk");
264
- MiniKit.install();
265
- }
266
- if (MiniKit.isInstalled()) {
267
- console.log("Minikit installed. Processing payment");
268
- const payload = event.data.payload;
269
- try {
270
- const minikitPayload: PayCommandInput = {
271
- reference: payload.reference,
272
- to: payload.to,
273
- tokens: [
274
- {
275
- symbol: payload.token as Tokens,
276
- token_amount: tokenToDecimals(
277
- Number(payload.amount),
278
- payload.token
279
- ).toString(),
280
- },
281
- ],
282
- description: payload.description,
283
- };
284
- const { finalPayload } =
285
- await MiniKit.commandsAsync.pay(minikitPayload);
286
-
287
- iRef.current?.contentWindow?.postMessage(
288
- { type: "MINIKIT_PAY_COMMAND_RESULT", result: finalPayload },
289
- zeroHashAppURL
290
- );
291
- } catch (error) {
292
- iRef.current?.contentWindow?.postMessage(
266
+ const payload = event.data.payload;
267
+ try {
268
+ const minikitPayload: PayCommandInput = {
269
+ reference: payload.reference,
270
+ to: payload.to,
271
+ tokens: [
293
272
  {
294
- type: "MINIKIT_PAY_COMMAND_RESULT",
295
- result: { error: String(error), status: "error" },
273
+ symbol: payload.token as Tokens,
274
+ token_amount: tokenToDecimals(
275
+ Number(payload.amount),
276
+ payload.token
277
+ ).toString(),
296
278
  },
297
- zeroHashAppURL
298
- );
299
- }
279
+ ],
280
+ description: payload.description,
281
+ };
282
+ const { finalPayload } =
283
+ await MiniKit.commandsAsync.pay(minikitPayload);
284
+
285
+ iRef.current?.contentWindow?.postMessage(
286
+ { type: "MINIKIT_PAY_COMMAND_RESULT", payload: { finalPayload } },
287
+ zeroHashAppURL
288
+ );
289
+ } catch (error) {
290
+ iRef.current?.contentWindow?.postMessage(
291
+ {
292
+ type: "MINIKIT_PAY_COMMAND_RESULT",
293
+ result: { error: String(error), status: "error" },
294
+ },
295
+ zeroHashAppURL
296
+ );
300
297
  }
301
298
  }
302
299
  },