Skip to content

Commit

Permalink
Merge branch 'feat-env-optimize' into 'main'
Browse files Browse the repository at this point in the history
Feat env optimize

See merge request changying/platform/xteriosdk-web!25
  • Loading branch information
henry committed Dec 23, 2024
2 parents 28d0bac + 4ee8fce commit 958ba00
Show file tree
Hide file tree
Showing 26 changed files with 4,935 additions and 4,617 deletions.
2 changes: 0 additions & 2 deletions examples/example-react-webgl-starter/.env
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
NODE_ENV=production
VITE_API_ROOT=/
VITE_BASE_URL=/
10 changes: 8 additions & 2 deletions examples/example-react-webgl-starter/.env.development
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
NODE_ENV=development
VITE_API_ROOT=/
VITE_BASE_URL=/
VITE_XSDK_APP_ID=bff5dbf8fe27
VITE_XSDK_CLIENT_ID=3715717224014682
VITE_XSDK_CLIENT_SECRET=mzmhYqcqDGdymblv5gb7s9OWcnYpH1ha
VITE_XSDK_PN_APP_ID=f6f4b76c-1e63-4821-9032-5db20044876b
VITE_XSDK_REDIRECT_URI=http://localhost:5173
VITE_XSDK_ENV=Staging
VITE_XSDK_XTER_CHAIN_NAME=XTERIO_TESTNET
VITE_XSDK_XTER_CHAIN_ID=1637450
9 changes: 9 additions & 0 deletions examples/example-react-webgl-starter/.env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
NODE_ENV=production
VITE_XSDK_APP_ID=your_staging_app_id
VITE_XSDK_CLIENT_ID=your_staging_client_id
VITE_XSDK_CLIENT_SECRET=your_staging_client_secret
VITE_XSDK_PN_APP_ID=your_staging_pn_app_id
VITE_XSDK_REDIRECT_URI=https://yourapp.com
VITE_XSDK_ENV=Production
VITE_XSDK_XTER_CHAIN_NAME=XTERIO
VITE_XSDK_XTER_CHAIN_ID=112358
9 changes: 9 additions & 0 deletions examples/example-react-webgl-starter/.env.stage
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
NODE_ENV=production
VITE_XSDK_APP_ID=your_staging_app_id
VITE_XSDK_CLIENT_ID=your_staging_client_id
VITE_XSDK_CLIENT_SECRET=your_staging_client_secret
VITE_XSDK_PN_APP_ID=your_staging_pn_app_id
VITE_XSDK_REDIRECT_URI=https://staging.yourapp.com
VITE_XSDK_ENV=Staging
VITE_XSDK_XTER_CHAIN_NAME=XTERIO_TESTNET
VITE_XSDK_XTER_CHAIN_ID=1637450
8,499 changes: 4,337 additions & 4,162 deletions examples/example-react-webgl-starter/package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion examples/example-react-webgl-starter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"build:stage": "tsc && vite build --mode stage",
"build:production": "tsc && vite build --mode production",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
"dependencies": {
"@xterio-sdk/auth": "^0.0.14",
"@xterio-sdk/auth": "^0.0.16",
"@xterio-sdk/wallet": "^0.0.10",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
17 changes: 9 additions & 8 deletions examples/example-react-webgl-starter/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { useEffect, useRef, useState } from 'react'
import { Unity } from 'react-unity-webgl'
import { IUserInfo, LoginType, XterEventEmiter, XTERIO_EVENTS, XterioAuth } from '@xterio-sdk/auth'
import { useXterioTransaction, useXterioWalletContext } from '@xterio-sdk/wallet'
import { XterioChainId } from './config'
import { SIGNIN_ABI } from './abi'
import { getContract, NETWORK_NAME } from './common'

Expand All @@ -12,11 +11,12 @@ import { SplashLoading } from './components'
import { useSendUnityMessage } from './hooks/useSendUnityMessage'

import './App.css'
import { getXterConfig } from './config/xterio-sdk-config'

const useSignInTrade = () => {
const chainId = XterioChainId
const contractAddress = '0x19c10FFf96B80208f454034C046CCc4445Cd20ba'
const network = NETWORK_NAME.XTERIO
const { xterio_chain_id: chainId, xterio_chain_name } = getXterConfig()
const contractAddress = '0xFB1D1dF539356C677a93b1d4E693a6b657E80135'
const network = xterio_chain_name as NETWORK_NAME
const abi = SIGNIN_ABI
const contract = getContract(network, contractAddress, abi)
const { sendTransaction, state } = useXterioTransaction(contract, 'checkIn')
Expand Down Expand Up @@ -60,7 +60,8 @@ function App() {
// 监听登录
useUnityEventListener('XterLogin', async () => {
if (!XterioAuth.isLogin) {
XterioAuth.login(LoginType.Mini)
// XterioAuth.login(LoginType.Mini) // 弹窗方式登录,只支持邮箱登录
XterioAuth.login(LoginType.Default) // SSO 方式登录,以页面跳转方式登录,支持多种登录方式
}
})

Expand All @@ -86,10 +87,10 @@ function App() {
if (!XterioAuth.isLogin || !aaAddress) {
return
}
await switchChain(XterioChainId)
const type = 2
await switchChain(chainId)
const channel = 1
try {
const res = await sendTransaction?.(type)
const res = await sendTransaction?.(channel)
sendMessage('XterManager', 'CheckIntateCallback', res.transactionHash ? 'true' : 'false')
} catch (err) {
sendMessage('XterManager', 'CheckIntateCallback', 'false')
Expand Down
164 changes: 0 additions & 164 deletions examples/example-react-webgl-starter/src/abi/SignIn.json

This file was deleted.

Loading

0 comments on commit 958ba00

Please sign in to comment.