From bc8d10e0883942f7eb558737e35b93c0d0705279 Mon Sep 17 00:00:00 2001 From: Nik <2661899+CodeSchwert@users.noreply.github.com> Date: Tue, 6 Aug 2024 18:02:55 +1200 Subject: [PATCH 1/7] fix: SDK reference docs alpha version check (#2069) --- .github/scripts/check-docs-version.sh | 6 ++++++ .github/workflows/publish-docs.yaml | 7 ++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/scripts/check-docs-version.sh b/.github/scripts/check-docs-version.sh index c2b8586824..eb575cb018 100755 --- a/.github/scripts/check-docs-version.sh +++ b/.github/scripts/check-docs-version.sh @@ -20,3 +20,9 @@ if [ -d "$CLONE_DIR/api-docs/sdk-references/ts-immutable-sdk/$VERSION" ]; then echo "There is already a docs folder for v$VERSION. Please create a separate PR to update the SDK reference docs for v$VERSION." exit 1 fi + +# check the version contains `alpha` string +if echo "$VERSION" | grep -q "alpha"; then + echo "Skipping docs generation for alpha version" + exit 1 +fi diff --git a/.github/workflows/publish-docs.yaml b/.github/workflows/publish-docs.yaml index a498bea6e1..81a860f37a 100644 --- a/.github/workflows/publish-docs.yaml +++ b/.github/workflows/publish-docs.yaml @@ -26,11 +26,11 @@ jobs: VERSION=$(git describe --tags --abbrev=0) if echo "$VERSION" | grep -q "alpha"; then echo "Skipping docs generation for alpha version" - echo "is_alpha=true" >> $GITHUB_ENV + echo "is_alpha=true" >> $GITHUB_OUTPUT exit 0 else echo "Generating docs for non-alpha version" - echo "is_alpha=false" >> $GITHUB_ENV + echo "is_alpha=false" >> $GITHUB_OUTPUT fi shell: bash @@ -47,6 +47,7 @@ jobs: steps: - name: Is Alpha Version run: | + echo "Is Alpha Version: ${{ needs.AlphaCheck.outputs.is_alpha }}" echo "Is Alpha Version: ${{ env.IS_ALPHA }}" - name: Check Public Release Branch @@ -135,7 +136,7 @@ jobs: if: ${{ success() && steps.docs_push.conclusion == 'success' && steps.netlify_build.conclusion == 'success' && steps.netlify_deploy.conclusion == 'success' }} uses: ./.github/actions/notify-slack-publish-status with: - message: "✅ SDK reference documents published successfully - https://docs.immutable.com/sdk-references/ts-immutable-sdk/${{ env.VERSION }}/modules/_imtbl_sdk.html\n\n>*`${{ env.GITHUB_USER }}` Please ensure you and the team updated all Sample Code + Guides on the to reflect the change.*" + message: "✅ SDK reference documents published successfully - https://docs.immutable.com/sdk-references/ts-immutable-sdk/${{ env.VERSION }}/\n\n>*`${{ env.GITHUB_USER }}` Please ensure you and the team updated all Sample Code + Guides on the to reflect the change.*" - name: Notify SDK Slack Docs Publish Failure if: ${{ failure() && steps.docs_version_check.conclusion == 'success' }} From 3d18c96a75598e9f2c0eef924e4fb1ff775f079a Mon Sep 17 00:00:00 2001 From: Ji Young Lee <641712+jiyounglee@users.noreply.github.com> Date: Tue, 6 Aug 2024 16:06:32 +1000 Subject: [PATCH 2/7] [NO CHANEGELOG] [Checkout Widget] Add checkout connect success event and swap rejected event (#2072) --- .../widgets/definitions/events/checkout.ts | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/checkout/sdk/src/widgets/definitions/events/checkout.ts b/packages/checkout/sdk/src/widgets/definitions/events/checkout.ts index 3adc8f02be..19d8fb2310 100644 --- a/packages/checkout/sdk/src/widgets/definitions/events/checkout.ts +++ b/packages/checkout/sdk/src/widgets/definitions/events/checkout.ts @@ -1,6 +1,6 @@ import { Web3Provider } from '@ethersproject/providers'; import { CheckoutFlowType } from '../parameters/checkout'; -import { ConnectionFailed } from './connect'; +import { ConnectionFailed, ConnectionSuccess } from './connect'; import { SaleFailed, SalePaymentMethod, @@ -16,7 +16,7 @@ import { BridgeFailed, BridgeTransactionSent, } from './bridge'; -import { SwapFailed, SwapSuccess } from './swap'; +import { SwapFailed, SwapRejected, SwapSuccess } from './swap'; import { WalletNetworkSwitch } from './wallet'; export enum CheckoutEventType { @@ -39,6 +39,8 @@ export enum CheckoutSuccessEventType { export enum CheckoutFailureEventType { BRIDGE_FAILED = 'BRIDGE_FAILED', BRIDGE_CLAIM_WITHDRAWAL_FAILED = 'BRIDGE_CLAIM_WITHDRAWAL_FAILED', + SWAP_FAILED = 'SWAP_FAILED', + SWAP_REJECTED = 'SWAP_REJECTED', } export enum CheckoutUserActionEventType { @@ -89,7 +91,13 @@ export type CheckoutSwapSuccessEvent = { data: SwapSuccess; }; // FIMXE: TransactionSent +export type CheckoutConnectSuccessEvent = { + flow: CheckoutFlowType.CONNECT; + data: ConnectionSuccess; +}; + export type CheckoutSuccessEvent = + | CheckoutConnectSuccessEvent | CheckoutBridgeSuccessEvent | CheckoutBridgeClaimWithdrawalSuccessEvent | CheckoutOnRampSuccessEvent @@ -121,9 +129,16 @@ export type CheckoutOnRampFailureEvent = { export type CheckoutSwapFailureEvent = { flow: CheckoutFlowType.SWAP; + type: CheckoutFailureEventType.SWAP_FAILED; data: SwapFailed; }; // FIMXE: Error +export type CheckoutSwapRejectedEvent = { + flow: CheckoutFlowType.SWAP; + type: CheckoutFailureEventType.SWAP_REJECTED; + data: SwapRejected; +}; // FIMXE: Error + export type CheckoutSaleFailureEvent = { flow: CheckoutFlowType.SALE; data: SaleFailed; @@ -135,6 +150,7 @@ export type CheckoutFailureEvent = | CheckoutConnectFailureEvent | CheckoutOnRampFailureEvent | CheckoutSwapFailureEvent + | CheckoutSwapRejectedEvent | CheckoutSaleFailureEvent; export type CheckoutPaymentMethodSelectedEvent = { From 851881cb66903abddfcee7fdb32ccdec1d715dbc Mon Sep 17 00:00:00 2001 From: Nik <2661899+CodeSchwert@users.noreply.github.com> Date: Tue, 6 Aug 2024 18:50:45 +1200 Subject: [PATCH 3/7] fix: check alpha version on publish job (#2075) --- .github/workflows/publish-docs.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/publish-docs.yaml b/.github/workflows/publish-docs.yaml index 81a860f37a..4d0f157a71 100644 --- a/.github/workflows/publish-docs.yaml +++ b/.github/workflows/publish-docs.yaml @@ -38,7 +38,7 @@ jobs: name: Publish SDK Reference Docs runs-on: ubuntu-latest needs: AlphaCheck - # if: ${{ needs.AlphaCheck.outputs.is_alpha == 'false' }} + if: ${{ needs.AlphaCheck.outputs.is_alpha == 'false' }} env: SDK_PUBLISH_SLACK_WEBHOOK: ${{ secrets.SDK_PUBLISH_SLACK_WEBHOOK }} NETLIFY_BUILD_HOOK: ${{ secrets.NETLIFY_BUILD_HOOK }} @@ -47,7 +47,6 @@ jobs: steps: - name: Is Alpha Version run: | - echo "Is Alpha Version: ${{ needs.AlphaCheck.outputs.is_alpha }}" echo "Is Alpha Version: ${{ env.IS_ALPHA }}" - name: Check Public Release Branch From ed1f91af2c1d31ad10e9b9e64ca8ffea4c859d21 Mon Sep 17 00:00:00 2001 From: zaidarain1 Date: Tue, 6 Aug 2024 17:16:32 +1000 Subject: [PATCH 4/7] feat: [DX-3082] Speed up examples workflows (#2071) --- .github/actions/setup-playwright/action.yaml | 39 +++++++++++++++++++ .github/workflows/pr.yaml | 9 +++-- examples/README.md | 2 +- .../identity-with-nextjs/package.json | 2 +- .../wallets-connect-with-nextjs/package.json | 2 +- .../wallets-signing-with-nextjs/package.json | 2 +- .../package.json | 2 +- 7 files changed, 50 insertions(+), 8 deletions(-) create mode 100644 .github/actions/setup-playwright/action.yaml diff --git a/.github/actions/setup-playwright/action.yaml b/.github/actions/setup-playwright/action.yaml new file mode 100644 index 0000000000..c51cd85801 --- /dev/null +++ b/.github/actions/setup-playwright/action.yaml @@ -0,0 +1,39 @@ +name: "Playwright setup" +description: "Install the browsers and dependencies for Playwright to run" + +runs: + using: "composite" + steps: + - name: Playwright versions in sync check + shell: bash + run: | + versions=$(yarn why --json @playwright/test | grep -h 'workspace:.' | jq --raw-output '.children[].locator' | sed -e 's/@playwright\/test@.*://') + unique_versions=$(echo "$versions" | sort | uniq) + if [ $(echo "$unique_versions" | wc -l) -ne 1 ]; then + echo "Playwright versions are not in sync:" + echo "$unique_versions" + exit 1 + else + echo "All Playwright versions are in sync." + fi + + - name: Get Playwright version + shell: bash + run: echo "PLAYWRIGHT_VERSION=$(node -e "console.log(require('playwright/package.json').version)")" >> $GITHUB_ENV + + - name: Cache Playwright Browsers + id: cache-playwright-browsers + uses: actions/cache@v4 + with: + path: ~/.cache/ms-playwright + key: playwright-browsers-${{ runner.os }}-${{ env.PLAYWRIGHT_VERSION }} + + - name: Install Playwright with dependencies + shell: bash + if: steps.cache-playwright-browsers.outputs.cache-hit != 'true' + run: yarn dlx playwright@${{ env.PLAYWRIGHT_VERSION }} install --with-deps + + - name: Install Playwright dependencies + shell: bash + if: steps.cache-playwright-browsers.outputs.cache-hit == 'true' + run: yarn dlx playwright@${{ env.PLAYWRIGHT_VERSION }} install-deps \ No newline at end of file diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 6c6f37c9ad..c6975f5347 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -127,7 +127,7 @@ jobs: build-examples: name: Build Examples needs: build-sdk - runs-on: ubuntu-latest-4-cores + runs-on: ubuntu-latest-8-cores env: NODE_OPTIONS: --max-old-space-size=14366 steps: @@ -165,7 +165,7 @@ jobs: test-examples: name: Test Examples needs: build-sdk - runs-on: ubuntu-latest-4-cores + runs-on: ubuntu-latest-8-cores env: NODE_OPTIONS: --max-old-space-size=14366 steps: @@ -178,6 +178,9 @@ jobs: - name: Setup examples uses: ./.github/actions/setup-examples + - name: Setup playwright + uses: ./.github/actions/setup-playwright + - name: Test examples run: yarn test:examples @@ -217,7 +220,7 @@ jobs: func-test-zkevm: name: zkevm func tests - runs-on: ubuntu-latest-4-cores + runs-on: ubuntu-latest-8-cores needs: build-sdk env: ZKEVM_ORDERBOOK_BANKER: ${{ secrets.ZKEVM_ORDERBOOK_BANKER }} diff --git a/examples/README.md b/examples/README.md index 1465ee67d0..f7d57ec1b4 100644 --- a/examples/README.md +++ b/examples/README.md @@ -263,7 +263,7 @@ Example of the base level of testing required can be found in `/examples/passpor Add the test runner to the scripts in your package.json ``` -"test": "playwright install --with-deps && playwright test" +"test": "playwright test" ``` Run your tests with `yarn test` diff --git a/examples/passport/identity-with-nextjs/package.json b/examples/passport/identity-with-nextjs/package.json index df78b485c0..3def6249e6 100644 --- a/examples/passport/identity-with-nextjs/package.json +++ b/examples/passport/identity-with-nextjs/package.json @@ -25,6 +25,6 @@ "dev": "next dev", "lint": "next lint", "start": "next start", - "test": "playwright install --with-deps && playwright test" + "test": "playwright test" } } diff --git a/examples/passport/wallets-connect-with-nextjs/package.json b/examples/passport/wallets-connect-with-nextjs/package.json index 0aa9490603..0ae494671b 100644 --- a/examples/passport/wallets-connect-with-nextjs/package.json +++ b/examples/passport/wallets-connect-with-nextjs/package.json @@ -28,6 +28,6 @@ "dev": "next dev", "lint": "eslint app --ext .js,.jsx,.ts,.tsx", "start": "next start", - "test": "playwright install --with-deps && playwright test" + "test": "playwright test" } } diff --git a/examples/passport/wallets-signing-with-nextjs/package.json b/examples/passport/wallets-signing-with-nextjs/package.json index f517ce0d4d..c6392416a3 100644 --- a/examples/passport/wallets-signing-with-nextjs/package.json +++ b/examples/passport/wallets-signing-with-nextjs/package.json @@ -28,6 +28,6 @@ "dev": "next dev", "lint": "next lint", "start": "next start", - "test": "playwright install --with-deps && playwright test" + "test": "playwright test" } } diff --git a/examples/passport/wallets-transactions-with-nextjs/package.json b/examples/passport/wallets-transactions-with-nextjs/package.json index 588b6a2b24..a8e80d80d4 100644 --- a/examples/passport/wallets-transactions-with-nextjs/package.json +++ b/examples/passport/wallets-transactions-with-nextjs/package.json @@ -25,6 +25,6 @@ "dev": "next dev", "lint": "next lint", "start": "next start", - "test": "playwright install --with-deps && playwright test" + "test": "playwright test" } } From 623c9f2179f668812401c054439a8c1a6d60ff76 Mon Sep 17 00:00:00 2001 From: Nik <2661899+CodeSchwert@users.noreply.github.com> Date: Tue, 6 Aug 2024 22:15:05 +1200 Subject: [PATCH 5/7] fix: set correct SDK version in SDK reference docs (#2076) --- .github/workflows/publish-docs.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/publish-docs.yaml b/.github/workflows/publish-docs.yaml index 4d0f157a71..f9cb1f0af2 100644 --- a/.github/workflows/publish-docs.yaml +++ b/.github/workflows/publish-docs.yaml @@ -87,12 +87,6 @@ jobs: node-version-file: .nvmrc cache: "yarn" - - name: Update SDK package.json version - run: | - tmp=$(mktemp) - jq '.version = "${{ env.VERSION }}"' ./package.json > "$tmp" && mv "$tmp" ./package.json - shell: bash - - name: Restore cached node_modules id: restore-cache-node_modules uses: actions/cache@v4 @@ -107,6 +101,12 @@ jobs: - name: Build run: export NODE_OPTIONS=--max-old-space-size=6144 && yarn build + - name: Update SDK package.json version + run: | + tmp=$(mktemp) + jq '.version = "${{ env.VERSION }}"' ./sdk/package.json > "$tmp" && mv "$tmp" ./sdk/package.json + shell: bash + - name: Build SDK Docs run: yarn docs:build From b2d6729a6d8075314076cf92a7d45316daf0f720 Mon Sep 17 00:00:00 2001 From: Nik <2661899+CodeSchwert@users.noreply.github.com> Date: Tue, 6 Aug 2024 23:29:30 +1200 Subject: [PATCH 6/7] feat: game-bridge track request ID (#2073) --- packages/game-bridge/src/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/game-bridge/src/index.ts b/packages/game-bridge/src/index.ts index 26eca7c226..60927c2230 100644 --- a/packages/game-bridge/src/index.ts +++ b/packages/game-bridge/src/index.ts @@ -214,6 +214,7 @@ window.callFunction = async (jsonData: string) => { track(moduleName, 'startedCallFunction', { function: fxName, + requestId, }); switch (fxName) { case PASSPORT_FUNCTIONS.init: { From bc564a12df93eee0794e8b2b10bf498ad8934dcb Mon Sep 17 00:00:00 2001 From: Jhonatan Gonzalez Date: Wed, 7 Aug 2024 09:33:28 +1000 Subject: [PATCH 7/7] [NO CHANGELOG][Checkout Widget] Fix initial iframe url (#2070) --- .../checkout/widgets-lib/src/lib/constants.ts | 2 +- .../src/widgets/checkout/CheckoutWidget.tsx | 36 +++-------------- .../context/CheckoutContextProvider.tsx | 40 +++++++++++-------- 3 files changed, 30 insertions(+), 48 deletions(-) diff --git a/packages/checkout/widgets-lib/src/lib/constants.ts b/packages/checkout/widgets-lib/src/lib/constants.ts index 829ca640a6..e830330218 100644 --- a/packages/checkout/widgets-lib/src/lib/constants.ts +++ b/packages/checkout/widgets-lib/src/lib/constants.ts @@ -121,6 +121,6 @@ export const WITHDRAWAL_CLAIM_GAS_LIMIT = 91000; */ export const CHECKOUT_APP_URL = { [ENV_DEVELOPMENT]: 'https://checkout.dev.immutable.com', - [Environment.SANDBOX]: 'http://localhost:3001', + [Environment.SANDBOX]: 'https://checkout.sandbox.immutable.com', [Environment.PRODUCTION]: 'https://checkout.immutable.com', }; diff --git a/packages/checkout/widgets-lib/src/widgets/checkout/CheckoutWidget.tsx b/packages/checkout/widgets-lib/src/widgets/checkout/CheckoutWidget.tsx index 2274a88a92..3e10fa61c7 100644 --- a/packages/checkout/widgets-lib/src/widgets/checkout/CheckoutWidget.tsx +++ b/packages/checkout/widgets-lib/src/widgets/checkout/CheckoutWidget.tsx @@ -3,7 +3,6 @@ import { Checkout, CheckoutWidgetConfiguration, CheckoutWidgetParams, - WalletProviderName, } from '@imtbl/checkout-sdk'; import { CheckoutActions, @@ -34,8 +33,11 @@ export default function CheckoutWidget(props: CheckoutWidgetInputs) { initialCheckoutState, ); const checkoutReducerValues = useMemo( - () => ({ checkoutState, checkoutDispatch }), - [checkoutState, checkoutDispatch], + () => ({ + checkoutState: { ...checkoutState, iframeUrl, checkout }, + checkoutDispatch, + }), + [checkoutState, checkoutDispatch, iframeUrl, checkout], ); useEffect(() => { @@ -49,34 +51,6 @@ export default function CheckoutWidget(props: CheckoutWidgetInputs) { }); }, [iframeUrl]); - useEffect(() => { - checkoutDispatch({ - payload: { - type: CheckoutActions.SET_CHECKOUT, - checkout, - }, - }); - - const connectProvider = async () => { - const createProviderResult = await checkout.createProvider({ - walletProviderName: WalletProviderName.METAMASK, - }); - - const connectResult = await checkout.connect({ - provider: createProviderResult.provider, - }); - - checkoutDispatch({ - payload: { - type: CheckoutActions.SET_PROVIDER, - provider: connectResult.provider, - }, - }); - }; - - connectProvider(); - }, [checkout]); - return ( diff --git a/packages/checkout/widgets-lib/src/widgets/checkout/context/CheckoutContextProvider.tsx b/packages/checkout/widgets-lib/src/widgets/checkout/context/CheckoutContextProvider.tsx index f72b746f1d..82280d97e7 100644 --- a/packages/checkout/widgets-lib/src/widgets/checkout/context/CheckoutContextProvider.tsx +++ b/packages/checkout/widgets-lib/src/widgets/checkout/context/CheckoutContextProvider.tsx @@ -1,7 +1,6 @@ import { PostMessageHandler } from '@imtbl/checkout-sdk'; import { - Dispatch, - ReactNode, useContext, useEffect, + Dispatch, ReactNode, useContext, useEffect, } from 'react'; import { CheckoutAction, @@ -10,32 +9,42 @@ import { CheckoutState, } from './CheckoutContext'; import { ProviderRelay } from './ProviderRelay'; -import { CHECKOUT_APP_URL } from '../../../lib'; type CheckoutContextProviderProps = { values: { - checkoutState: CheckoutState, - checkoutDispatch: Dispatch, - }, children: ReactNode + checkoutState: CheckoutState; + checkoutDispatch: Dispatch; + }; + children: ReactNode; }; -export function CheckoutContextProvider({ values, children }: CheckoutContextProviderProps) { +export function CheckoutContextProvider({ + values, + children, +}: CheckoutContextProviderProps) { const { checkoutState, checkoutDispatch } = values; - const { checkout } = checkoutState; - const { provider, checkoutAppIframe, postMessageHandler } = checkoutState; + const { + checkout, + provider, + checkoutAppIframe, + postMessageHandler, + iframeUrl, + } = checkoutState; useEffect(() => { - if (!checkoutAppIframe || !checkout) return; + if (!checkoutAppIframe || !checkout || !iframeUrl) return; + + const postMessageHandlerInstance = new PostMessageHandler({ + targetOrigin: new URL(iframeUrl).origin, + eventTarget: checkoutAppIframe, + }); checkoutDispatch({ payload: { type: CheckoutActions.SET_POST_MESSAGE_HANDLER, - postMessageHandler: new PostMessageHandler({ - targetOrigin: CHECKOUT_APP_URL[checkout.config.environment], - eventTarget: checkoutAppIframe, - }), + postMessageHandler: postMessageHandlerInstance, }, }); - }, [checkoutAppIframe, checkout]); + }, [checkoutAppIframe, checkout, iframeUrl]); useEffect(() => { if (!provider || !postMessageHandler) return undefined; @@ -55,7 +64,6 @@ export function CheckoutContextProvider({ values, children }: CheckoutContextPro {children} - ); }