From 63d4e78df27a42bab4a8dad1b4dc45ff5d260dc5 Mon Sep 17 00:00:00 2001 From: AnhMTV Date: Thu, 30 May 2024 22:07:44 +0700 Subject: [PATCH] Update auto build for production --- .github/workflows/push-webapp.yml | 6 +- .../src/koni/background/handlers/Extension.ts | 150 +----------------- .../Popup/Home/Earning/EarningPools/index.tsx | 2 +- .../src/Popup/Home/Mission/TaskItem.tsx | 2 +- .../Security/ManageWebsiteAccess/index.tsx | 2 +- .../Earning/EarningValidatorSelector.tsx | 2 +- .../src/connector/booka/sdk.ts | 129 ++++++++------- packages/webapp/package.json | 2 +- packages/webapp/webpack.config.cjs | 4 +- 9 files changed, 83 insertions(+), 216 deletions(-) diff --git a/.github/workflows/push-webapp.yml b/.github/workflows/push-webapp.yml index 296ec105e3..85804744b8 100644 --- a/.github/workflows/push-webapp.yml +++ b/.github/workflows/push-webapp.yml @@ -30,8 +30,8 @@ jobs: COINBASE_PAY_ID: ${{ secrets.COINBASE_PAY_ID }} NFT_MINTING_HOST: ${{ secrets.NFT_MINTING_HOST }} BRANCH_NAME: ${{ github.ref_name }} - GAME_API_HOST: ${{ vars.API_DEV_SERVER }} - TELEGRAM_WEBAPP_LINK: ${{ vars.TELEGRAM_WEBAPP_LINK }} + GAME_API_HOST: ${{ vars.API_PROD_SERVER }} + TELEGRAM_WEBAPP_LINK: ${{ vars.TELEGRAM_WEBAPP_LINK_PROD }} run: | yarn install --immutable | grep -v 'YN0013' if [ ${{ github.ref_name }} == 'telegram-wallet' ]; then @@ -44,7 +44,7 @@ jobs: with: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - projectName: ${{ vars.CLOUDFLARE_PAGES_PROJECT_NAME }} + projectName: ${{ vars.CLOUDFLARE_PAGES_PROJECT_NAME_PROD }} gitHubToken: ${{ secrets.GH_AUTOMATION_TOKEN }} branch: ${{ github.ref_name }} directory: './packages/webapp/build' diff --git a/packages/extension-base/src/koni/background/handlers/Extension.ts b/packages/extension-base/src/koni/background/handlers/Extension.ts index 17fa217edd..acfaa15225 100644 --- a/packages/extension-base/src/koni/background/handlers/Extension.ts +++ b/packages/extension-base/src/koni/background/handlers/Extension.ts @@ -7,153 +7,7 @@ import { _AssetRef, _AssetType, _ChainAsset, _ChainInfo, _MultiChainAsset } from import { TransactionError } from '@subwallet/extension-base/background/errors/TransactionError'; import { withErrorLog } from '@subwallet/extension-base/background/handlers/helpers'; import { createSubscription } from '@subwallet/extension-base/background/handlers/subscriptions'; -import { - AccountExternalError, - AccountExternalErrorCode, - AccountsWithCurrentAddress, - AddressBookInfo, - AmountData, - AmountDataWithId, - AssetSetting, - AssetSettingUpdateReq, - BasicTxErrorType, - BasicTxWarningCode, - BondingOptionParams, - BrowserConfirmationType, - CampaignBanner, - CampaignData, - CampaignDataType, - ChainType, - CreateDeriveAccountInfo, - CronReloadRequest, - CurrentAccountInfo, - DeriveAccountInfo, - ExternalRequestPromiseStatus, - ExtrinsicType, - KeyringState, - MantaPayEnableMessage, - MantaPayEnableParams, - MantaPayEnableResponse, - MantaPaySyncState, - NftCollection, - NftJson, - NftTransactionRequest, - NftTransactionResponse, - OptionInputAddress, - PriceJson, - RemarkWithEvent, - RequestAccountCreateExternalV2, - RequestAccountCreateHardwareMultiple, - RequestAccountCreateHardwareV2, - RequestAccountCreateSuriV2, - RequestAccountCreateWithSecretKey, - RequestAccountExportPrivateKey, - RequestAccountMeta, - RequestAddInjectedAccounts, - RequestApproveConnectWalletSession, - RequestApproveWalletConnectNotSupport, - RequestAuthorization, - RequestAuthorizationBlock, - RequestAuthorizationPerAccount, - RequestAuthorizationPerSite, - RequestAuthorizeApproveV2, - RequestBatchRestoreV2, - RequestBondingSubmit, - RequestCameraSettings, - RequestCampaignBannerComplete, - RequestChangeEnableChainPatrol, - RequestChangeLanguage, - RequestChangeMasterPassword, - RequestChangeShowBalance, - RequestChangeShowZeroBalance, - RequestChangeTimeAutoLock, - RequestCheckPublicAndSecretKey, - RequestConfirmationComplete, - RequestConnectWalletConnect, - RequestCrossChainTransfer, - RequestDeleteContactAccount, - RequestDeriveCreateMultiple, - RequestDeriveCreateV2, - RequestDeriveCreateV3, - RequestDeriveValidateV2, - RequestDisconnectWalletConnectSession, - RequestEditContactAccount, - RequestFindRawMetadata, - RequestForgetSite, - RequestFreeBalance, - RequestGetDeriveAccounts, - RequestGetTransaction, - RequestJsonRestoreV2, - RequestKeyringExportMnemonic, - RequestMaxTransferable, - RequestMigratePassword, - RequestParseEvmContractInput, - RequestParseTransactionSubstrate, - RequestPassPhishingPage, - RequestQrParseRLP, - RequestQrSignEvm, - RequestQrSignSubstrate, - RequestRejectConnectWalletSession, - RequestRejectExternalRequest, - RequestRejectWalletConnectNotSupport, - RequestRemoveInjectedAccounts, - RequestResetWallet, - RequestResolveExternalRequest, - RequestSaveRecentAccount, - RequestSeedCreateV2, - RequestSeedValidateV2, - RequestSettingsType, - RequestSigningApprovePasswordV2, - RequestStakePoolingBonding, - RequestStakePoolingUnbonding, - RequestSubscribeHistory, - RequestSubstrateNftSubmitTransaction, - RequestTransfer, - RequestTransferCheckReferenceCount, - RequestTransferCheckSupporting, - RequestTransferExistentialDeposit, - RequestTuringCancelStakeCompound, - RequestTuringStakeCompound, - RequestUnbondingSubmit, - RequestUnlockKeyring, - RequestUnlockType, - ResolveAddressToDomainRequest, - ResolveDomainRequest, - ResponseAccountCreateSuriV2, - ResponseAccountCreateWithSecretKey, - ResponseAccountExportPrivateKey, - ResponseAccountMeta, - ResponseChangeMasterPassword, - ResponseCheckPublicAndSecretKey, - ResponseDeriveValidateV2, - ResponseFindRawMetadata, - ResponseGetDeriveAccounts, - ResponseKeyringExportMnemonic, - ResponseMigratePassword, - ResponseParseEvmContractInput, - ResponseParseTransactionSubstrate, - ResponsePrivateKeyValidateV2, - ResponseQrParseRLP, - ResponseQrSignEvm, - ResponseQrSignSubstrate, - ResponseRejectExternalRequest, - ResponseResetWallet, - ResponseResolveExternalRequest, - ResponseSeedCreateV2, - ResponseSeedValidateV2, - ResponseSubscribeHistory, - ResponseUnlockKeyring, - StakingTxErrorType, - StakingType, - SupportTransferResponse, - ThemeNames, - TransactionHistoryItem, - TransactionResponse, - TransferTxErrorType, - ValidateNetworkRequest, - ValidateNetworkResponse, - ValidatorInfo -} from '@subwallet/extension-base/background/KoniTypes'; +import { AccountExternalError, AccountExternalErrorCode, AccountsWithCurrentAddress, AddressBookInfo, AmountData, AmountDataWithId, AssetSetting, AssetSettingUpdateReq, BasicTxErrorType, BasicTxWarningCode, BondingOptionParams, BrowserConfirmationType, CampaignBanner, CampaignData, CampaignDataType, ChainType, CreateDeriveAccountInfo, CronReloadRequest, CurrentAccountInfo, DeriveAccountInfo, ExternalRequestPromiseStatus, ExtrinsicType, KeyringState, MantaPayEnableMessage, MantaPayEnableParams, MantaPayEnableResponse, MantaPaySyncState, NftCollection, NftJson, NftTransactionRequest, NftTransactionResponse, OptionInputAddress, PriceJson, RemarkWithEvent, RequestAccountCreateExternalV2, RequestAccountCreateHardwareMultiple, RequestAccountCreateHardwareV2, RequestAccountCreateSuriV2, RequestAccountCreateWithSecretKey, RequestAccountExportPrivateKey, RequestAccountMeta, RequestAddInjectedAccounts, RequestApproveConnectWalletSession, RequestApproveWalletConnectNotSupport, RequestAuthorization, RequestAuthorizationBlock, RequestAuthorizationPerAccount, RequestAuthorizationPerSite, RequestAuthorizeApproveV2, RequestBatchRestoreV2, RequestBondingSubmit, RequestCameraSettings, RequestCampaignBannerComplete, RequestChangeEnableChainPatrol, RequestChangeLanguage, RequestChangeMasterPassword, RequestChangeShowBalance, RequestChangeShowZeroBalance, RequestChangeTimeAutoLock, RequestCheckPublicAndSecretKey, RequestConfirmationComplete, RequestConnectWalletConnect, RequestCrossChainTransfer, RequestDeleteContactAccount, RequestDeriveCreateMultiple, RequestDeriveCreateV2, RequestDeriveCreateV3, RequestDeriveValidateV2, RequestDisconnectWalletConnectSession, RequestEditContactAccount, RequestFindRawMetadata, RequestForgetSite, RequestFreeBalance, RequestGetDeriveAccounts, RequestGetTransaction, RequestJsonRestoreV2, RequestKeyringExportMnemonic, RequestMaxTransferable, RequestMigratePassword, RequestParseEvmContractInput, RequestParseTransactionSubstrate, RequestPassPhishingPage, RequestQrParseRLP, RequestQrSignEvm, RequestQrSignSubstrate, RequestRejectConnectWalletSession, RequestRejectExternalRequest, RequestRejectWalletConnectNotSupport, RequestRemoveInjectedAccounts, RequestResetWallet, RequestResolveExternalRequest, RequestSaveRecentAccount, RequestSeedCreateV2, RequestSeedValidateV2, RequestSettingsType, RequestSigningApprovePasswordV2, RequestStakePoolingBonding, RequestStakePoolingUnbonding, RequestSubscribeHistory, RequestSubstrateNftSubmitTransaction, RequestTransfer, RequestTransferCheckReferenceCount, RequestTransferCheckSupporting, RequestTransferExistentialDeposit, RequestTuringCancelStakeCompound, RequestTuringStakeCompound, RequestUnbondingSubmit, RequestUnlockKeyring, RequestUnlockType, ResolveAddressToDomainRequest, ResolveDomainRequest, ResponseAccountCreateSuriV2, ResponseAccountCreateWithSecretKey, ResponseAccountExportPrivateKey, ResponseAccountMeta, ResponseChangeMasterPassword, ResponseCheckPublicAndSecretKey, ResponseDeriveValidateV2, ResponseFindRawMetadata, ResponseGetDeriveAccounts, ResponseKeyringExportMnemonic, ResponseMigratePassword, ResponseParseEvmContractInput, ResponseParseTransactionSubstrate, ResponsePrivateKeyValidateV2, ResponseQrParseRLP, ResponseQrSignEvm, ResponseQrSignSubstrate, ResponseRejectExternalRequest, ResponseResetWallet, ResponseResolveExternalRequest, ResponseSeedCreateV2, ResponseSeedValidateV2, ResponseSubscribeHistory, ResponseUnlockKeyring, StakingTxErrorType, StakingType, SupportTransferResponse, ThemeNames, TransactionHistoryItem, TransactionResponse, TransferTxErrorType, ValidateNetworkRequest, ValidateNetworkResponse, ValidatorInfo } from '@subwallet/extension-base/background/KoniTypes'; import RequestBytesSign from '@subwallet/extension-base/background/RequestBytesSign'; import RequestExtrinsicSign from '@subwallet/extension-base/background/RequestExtrinsicSign'; import { AccountAuthType, AccountJson, AuthorizeRequest, MessageTypes, MetadataRequest, RequestAccountChangePassword, RequestAccountCreateExternal, RequestAccountCreateHardware, RequestAccountCreateSuri, RequestAccountEdit, RequestAccountExport, RequestAccountForget, RequestAccountShow, RequestAccountTie, RequestAccountValidate, RequestAuthorizeCancel, RequestAuthorizeReject, RequestBatchRestore, RequestCurrentAccountAddress, RequestDeriveCreate, RequestDeriveValidate, RequestJsonRestore, RequestMetadataApprove, RequestMetadataReject, RequestSeedCreate, RequestSeedValidate, RequestSigningApproveSignature, RequestSigningCancel, RequestTypes, ResponseAccountExport, ResponseAuthorizeList, ResponseDeriveValidate, ResponseJsonGetAccountInfo, ResponseSeedCreate, ResponseSeedValidate, ResponseSigning, ResponseType, SigningRequest, WindowOpenParams } from '@subwallet/extension-base/background/types'; @@ -4113,9 +3967,11 @@ export default class KoniExtension { const address = request.address; const networkKey = request.networkKey; const apiProps = this.#koniState.getSubstrateApi(networkKey); + if (!apiProps) { return; } + const transaction = apiProps.api.tx.system.remarkWithEvent(request.dataRemark); const rs = await this.#koniState.transactionService.handleTransaction({ address: address, diff --git a/packages/extension-koni-ui/src/Popup/Home/Earning/EarningPools/index.tsx b/packages/extension-koni-ui/src/Popup/Home/Earning/EarningPools/index.tsx index 95b0ce66b5..3236561ef2 100644 --- a/packages/extension-koni-ui/src/Popup/Home/Earning/EarningPools/index.tsx +++ b/packages/extension-koni-ui/src/Popup/Home/Earning/EarningPools/index.tsx @@ -267,8 +267,8 @@ function Component ({ poolGroup, symbol }: ComponentProps) { title={t('{{symbol}} earning options', { replace: { symbol: symbol } })} > } + autoFocusSearch={false} className={'__section-list-container'} enableSearchInput filterBy={filterFunction} diff --git a/packages/extension-koni-ui/src/Popup/Home/Mission/TaskItem.tsx b/packages/extension-koni-ui/src/Popup/Home/Mission/TaskItem.tsx index a102c6e886..ee1021de96 100644 --- a/packages/extension-koni-ui/src/Popup/Home/Mission/TaskItem.tsx +++ b/packages/extension-koni-ui/src/Popup/Home/Mission/TaskItem.tsx @@ -169,7 +169,7 @@ const _TaskItem = ({ actionReloadPoint, className, task }: Props): React.ReactEl if (content) { return (
- content + {content}
); } diff --git a/packages/extension-koni-ui/src/Popup/Settings/Security/ManageWebsiteAccess/index.tsx b/packages/extension-koni-ui/src/Popup/Settings/Security/ManageWebsiteAccess/index.tsx index e7b24decb7..205e0bebb0 100644 --- a/packages/extension-koni-ui/src/Popup/Settings/Security/ManageWebsiteAccess/index.tsx +++ b/packages/extension-koni-ui/src/Popup/Settings/Security/ManageWebsiteAccess/index.tsx @@ -216,8 +216,8 @@ function Component ({ className = '' }: Props): React.ReactElement { /> } + autoFocusSearch={false} enableSearchInput filterBy={filterFunction} list={websiteAccessItems} diff --git a/packages/extension-koni-ui/src/components/Field/Earning/EarningValidatorSelector.tsx b/packages/extension-koni-ui/src/components/Field/Earning/EarningValidatorSelector.tsx index 720a699d69..f34e415255 100644 --- a/packages/extension-koni-ui/src/components/Field/Earning/EarningValidatorSelector.tsx +++ b/packages/extension-koni-ui/src/components/Field/Earning/EarningValidatorSelector.tsx @@ -360,8 +360,8 @@ const Component = (props: Props, ref: ForwardedRef) => { title={t('Select') + ' ' + t(handleValidatorLabel)} > } + autoFocusSearch={false} enableSearchInput={true} filterBy={filterFunction} list={resultList} diff --git a/packages/extension-koni-ui/src/connector/booka/sdk.ts b/packages/extension-koni-ui/src/connector/booka/sdk.ts index 431d1838cf..d1ac17b3cc 100644 --- a/packages/extension-koni-ui/src/connector/booka/sdk.ts +++ b/packages/extension-koni-ui/src/connector/booka/sdk.ts @@ -15,6 +15,8 @@ export const TELEGRAM_WEBAPP_LINK = process.env.TELEGRAM_WEBAPP_LINK || 'BookaGa const storage = SWStorage.instance; const telegramConnector = TelegramConnector.instance; +// Incase of changing the cache version, we need to clear the cache +const cacheVersion = '1.1'; const CACHE_KEYS = { account: 'data--account-cache', taskCategoryList: 'data--task-category-list-cache', @@ -39,65 +41,74 @@ export class BookaSdk { private rankInfoSubject = new BehaviorSubject | undefined>(undefined); constructor () { - storage.getItems(Object.values(CACHE_KEYS)).then(([account, taskCategory, tasks, game, energyConfig, rankInfoMap]) => { - if (account) { - try { - const accountData = JSON.parse(account) as BookaAccount; - - this.accountSubject.next(accountData); - } catch (e) { - console.error('Failed to parse account data', e); - } - } - - if (taskCategory) { - try { - const taskCategoryList = JSON.parse(taskCategory) as TaskCategory[]; - - this.taskCategoryListSubject.next(taskCategoryList); - } catch (e) { - console.error('Failed to parse task list', e); - } - } - - if (tasks) { - try { - const taskList = JSON.parse(tasks) as Task[]; - - this.taskListSubject.next(taskList); - } catch (e) { - console.error('Failed to parse task list', e); - } - } - - if (game) { - try { - const gameList = JSON.parse(game) as Game[]; - - this.gameListSubject.next(gameList); - } catch (e) { - console.error('Failed to parse game list', e); - } - } - - if (energyConfig) { - try { - const _energyConfig = JSON.parse(energyConfig) as EnergyConfig; - - this.energyConfigSubject.next(_energyConfig); - } catch (e) { - console.error('Failed to parse energy config', e); - } - } - - if (rankInfoMap) { - try { - const _rankInfoMap = JSON.parse(rankInfoMap) as Record; - - this.rankInfoSubject.next(_rankInfoMap); - } catch (e) { - console.error('Failed to parse rankInfoMap', e); - } + storage.getItem('cache-version').then((version) => { + if (cacheVersion === version) { + storage.getItems(Object.values(CACHE_KEYS)).then(([account, taskCategory, tasks, game, energyConfig, rankInfoMap]) => { + if (account) { + try { + const accountData = JSON.parse(account) as BookaAccount; + + this.accountSubject.next(accountData); + } catch (e) { + console.error('Failed to parse account data', e); + } + } + + if (taskCategory) { + try { + const taskCategoryList = JSON.parse(taskCategory) as TaskCategory[]; + + this.taskCategoryListSubject.next(taskCategoryList); + } catch (e) { + console.error('Failed to parse task list', e); + } + } + + if (tasks) { + try { + const taskList = JSON.parse(tasks) as Task[]; + + this.taskListSubject.next(taskList); + } catch (e) { + console.error('Failed to parse task list', e); + } + } + + if (game) { + try { + const gameList = JSON.parse(game) as Game[]; + + this.gameListSubject.next(gameList); + } catch (e) { + console.error('Failed to parse game list', e); + } + } + + if (energyConfig) { + try { + const _energyConfig = JSON.parse(energyConfig) as EnergyConfig; + + this.energyConfigSubject.next(_energyConfig); + } catch (e) { + console.error('Failed to parse energy config', e); + } + } + + if (rankInfoMap) { + try { + const _rankInfoMap = JSON.parse(rankInfoMap) as Record; + + this.rankInfoSubject.next(_rankInfoMap); + } catch (e) { + console.error('Failed to parse rankInfoMap', e); + } + } + }).catch(console.error); + } else { + console.debug('Clearing cache'); + storage.removeItems(Object.keys(CACHE_KEYS)).then(() => { + storage.setItem('cache-version', cacheVersion).catch(console.error); + }).catch(console.error); } }).catch(console.error); } diff --git a/packages/webapp/package.json b/packages/webapp/package.json index 92d3c268f8..719defff58 100644 --- a/packages/webapp/package.json +++ b/packages/webapp/package.json @@ -50,4 +50,4 @@ "webpack-cli": "^4.10.0", "webpack-dev-server": "^4.11.1" } -} \ No newline at end of file +} diff --git a/packages/webapp/webpack.config.cjs b/packages/webapp/webpack.config.cjs index 8dab488ec5..b8ebf0826c 100644 --- a/packages/webapp/webpack.config.cjs +++ b/packages/webapp/webpack.config.cjs @@ -177,7 +177,7 @@ const createConfig = (entry, alias = {}, useSplitChunk = false) => { url: false } }, - optimization : { + optimization: { splitChunks: { chunks: 'all', maxSize: 2000000, @@ -200,7 +200,7 @@ const createConfig = (entry, alias = {}, useSplitChunk = false) => { }; module.exports = createConfig({ - fallback: ['./src/fallback.ts', './src/webRunner.ts', './src/index.tsx'], + fallback: ['./src/fallback.ts', './src/webRunner.ts', './src/index.tsx'] }, { 'manta-extension-sdk': './manta-extension-sdk-empty.ts' }, true);