Skip to content

Commit

Permalink
fix: failing commerce func test (#2352)
Browse files Browse the repository at this point in the history
  • Loading branch information
zaidarain1 authored Oct 28, 2024
1 parent 12eb353 commit 656ba9c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion tests/func-tests/checkout/widgets-nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"dependencies": {
"@biom3/react": "^0.25.21",
"@ethersproject/providers": "^5.7.2",
"@imtbl/sdk": "1.60.0",
"@imtbl/sdk": "1.61.0",
"next": "14.2.7",
"react": "^18",
"react-dom": "^18"
Expand Down
28 changes: 14 additions & 14 deletions tests/func-tests/checkout/widgets-nextjs/src/app/widgets/page.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
"use client";
import { Box } from '@biom3/react';
import { checkout } from '@imtbl/sdk';
import { CheckoutFlowType, ConnectionSuccess, Widget, WidgetType } from '@imtbl/sdk/checkout';
import { CommerceFlowType, ConnectionSuccess, Widget, WidgetType } from '@imtbl/sdk/checkout';
import { useEffect, useState } from 'react';

const checkoutSDK = new checkout.Checkout();

function Widgets() {

const [widget, setWidget] = useState<Widget<WidgetType.CHECKOUT>>();
const [widget, setWidget] = useState<Widget<WidgetType.IMMUTABLE_COMMERCE>>();

useEffect(() => {

const loadWidgets = async () => {
const widgetsFactory = await checkoutSDK.widgets({ config: {} });

const widget = widgetsFactory.create(WidgetType.CHECKOUT, {})
const widget = widgetsFactory.create(WidgetType.IMMUTABLE_COMMERCE, {})
setWidget(widget);
}

Expand All @@ -26,16 +26,16 @@ function Widgets() {
useEffect(() => {
if (!widget) return;
widget.mount("widget-root", {
flow: CheckoutFlowType.WALLET,
flow: CommerceFlowType.WALLET,
});

widget.addListener(
checkout.CheckoutEventType.SUCCESS,
(payload: checkout.CheckoutSuccessEvent) => {
checkout.CommerceEventType.SUCCESS,
(payload: checkout.CommerceSuccessEvent) => {
const { type, data } = payload;

// capture provider after user connects their wallet
if (type === checkout.CheckoutSuccessEventType.CONNECT_SUCCESS) {
if (type === checkout.CommerceSuccessEventType.CONNECT_SUCCESS) {
const { walletProviderName } = data as ConnectionSuccess;
console.log('connected to ', walletProviderName);
// setProvider(data.provider);
Expand All @@ -48,26 +48,26 @@ function Widgets() {

// detect when user fails to connect
widget.addListener(
checkout.CheckoutEventType.FAILURE,
(payload: checkout.CheckoutFailureEvent) => {
checkout.CommerceEventType.FAILURE,
(payload: checkout.CommerceFailureEvent) => {
const { type, data } = payload;

if (type === checkout.CheckoutFailureEventType.CONNECT_FAILED) {
if (type === checkout.CommerceFailureEventType.CONNECT_FAILED) {
console.log('failed to connect', data.reason);
}
}
);

// remove widget from view when closed
widget.addListener(checkout.CheckoutEventType.CLOSE, () => {
widget.addListener(checkout.CommerceEventType.CLOSE, () => {
widget.unmount();
});

// clean up event listeners
return () => {
widget.removeListener(checkout.CheckoutEventType.SUCCESS);
widget.removeListener(checkout.CheckoutEventType.DISCONNECTED);
widget.removeListener(checkout.CheckoutEventType.CLOSE);
widget.removeListener(checkout.CommerceEventType.SUCCESS);
widget.removeListener(checkout.CommerceEventType.DISCONNECTED);
widget.removeListener(checkout.CommerceEventType.CLOSE);
};


Expand Down
14 changes: 7 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5118,9 +5118,9 @@ __metadata:
languageName: node
linkType: hard

"@imtbl/sdk@npm:1.60.0":
version: 1.60.0
resolution: "@imtbl/sdk@npm:1.60.0"
"@imtbl/sdk@npm:1.61.0":
version: 1.61.0
resolution: "@imtbl/sdk@npm:1.61.0"
dependencies:
"@0xsequence/abi": ^1.4.3
"@0xsequence/core": ^1.4.3
Expand Down Expand Up @@ -5193,7 +5193,7 @@ __metadata:
optional: true
prisma:
optional: true
checksum: 2b3ae70a91b233205d1de0931087a141fdc9bed871451be5e054d5f433ad18207ecb3156f890f4dd3e0d2d34a45394b7b3362b1fcb09a5c6003e5cc09a00e88c
checksum: 93f3c3198842d5b4d7a44eb2b20091697c1dbc64fcc3e677fd7e8fa77c456611cb189aab874a8b8d4e8df27e83f189affbdfe40291e810f423d8f818da72b0c7
languageName: node
linkType: hard

Expand Down Expand Up @@ -12253,7 +12253,7 @@ __metadata:
dependencies:
"@biom3/react": ^0.25.21
"@ethersproject/providers": ^5.7.2
"@imtbl/sdk": 1.60.0
"@imtbl/sdk": 1.61.0
"@playwright/test": ^1.45.3
"@types/node": ^20
"@types/react": ^18.3.4
Expand Down Expand Up @@ -35132,7 +35132,7 @@ __metadata:
resolution: "seaport-core@https://github.com/immutable/seaport-core.git#commit=0633350ec34f21fcede657ff812f11cf7d19144e"
dependencies:
seaport-types: ^0.0.1
checksum: d8adba0d54106c6fe9370f0775fadef2198e5eab440b36919d1f917705ce2f0a7028e4da021b6df049aa3ca35d7e673a28b78a731130f0ff9fdf7a8bd32e3b94
checksum: 392bce86bbfc4f7c00b65575b238825f4c696bddf5af08be7aa496862e63879375387fd4400f6e900ffee08d65c1f75cf3adad9c6c41ddcf7a3b0389cd73c3c7
languageName: node
linkType: hard

Expand Down Expand Up @@ -35176,7 +35176,7 @@ __metadata:
seaport-sol: ^1.5.0
seaport-types: ^0.0.1
solady: ^0.0.84
checksum: a77e141e4ab5d2c4bb190a38fbb6cda3011fdf5f350b250fbeb4d82ae81cf917a966a2dcb8d9e4fd1bed29e5510ede9b15941b0ac77aeb4272dab94c9f51e7ff
checksum: f31a7443a50fa1c35ec03ea031743d1d10896653ae443fa15ab8e6f5b4a2ca43f6743d523ae4e1f14df867451e5b2b2130b0bfa58a1085b0bcae3fceb8dfdc9b
languageName: node
linkType: hard

Expand Down

0 comments on commit 656ba9c

Please sign in to comment.