Skip to content

Commit

Permalink
Merge branch 'main' into refactor/checkout-post-message-handler
Browse files Browse the repository at this point in the history
  • Loading branch information
jhesgodi committed Aug 7, 2024
2 parents afa8ce6 + bc564a1 commit 6e82502
Show file tree
Hide file tree
Showing 12 changed files with 86 additions and 21 deletions.
39 changes: 39 additions & 0 deletions .github/actions/setup-playwright/action.yaml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions .github/scripts/check-docs-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 6 additions & 3 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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

Expand Down Expand Up @@ -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 }}
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/publish-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ 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

PublishDocs:
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 }}
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -135,7 +135,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 <https://docs.immutable.com|imx-docs site> 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 <https://docs.immutable.com|imx-docs site> to reflect the change.*"

- name: Notify SDK Slack Docs Publish Failure
if: ${{ failure() && steps.docs_version_check.conclusion == 'success' }}
Expand Down
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
2 changes: 1 addition & 1 deletion examples/passport/identity-with-nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
"dev": "next dev",
"lint": "next lint",
"start": "next start",
"test": "playwright install --with-deps && playwright test"
"test": "playwright test"
}
}
2 changes: 1 addition & 1 deletion examples/passport/wallets-connect-with-nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
2 changes: 1 addition & 1 deletion examples/passport/wallets-signing-with-nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
"dev": "next dev",
"lint": "next lint",
"start": "next start",
"test": "playwright install --with-deps && playwright test"
"test": "playwright test"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
"dev": "next dev",
"lint": "next lint",
"start": "next start",
"test": "playwright install --with-deps && playwright test"
"test": "playwright test"
}
}
20 changes: 18 additions & 2 deletions packages/checkout/sdk/src/widgets/definitions/events/checkout.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -135,6 +150,7 @@ export type CheckoutFailureEvent =
| CheckoutConnectFailureEvent
| CheckoutOnRampFailureEvent
| CheckoutSwapFailureEvent
| CheckoutSwapRejectedEvent
| CheckoutSaleFailureEvent;

export type CheckoutPaymentMethodSelectedEvent = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function CheckoutContextProvider({

// TODO: remove logger after done with development
postMessageHandlerInstance.setLogger((...args: any[]) => {
console.log('🔔 PARENT – ', ...args); // eslint-disable-line
console.log("🔔 PARENT – ", ...args); // eslint-disable-line
});

checkoutDispatch({
Expand Down
1 change: 1 addition & 0 deletions packages/game-bridge/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ window.callFunction = async (jsonData: string) => {

track(moduleName, 'startedCallFunction', {
function: fxName,
requestId,
});
switch (fxName) {
case PASSPORT_FUNCTIONS.init: {
Expand Down

0 comments on commit 6e82502

Please sign in to comment.