Skip to content

Commit

Permalink
Update auto build for production
Browse files Browse the repository at this point in the history
  • Loading branch information
saltict committed May 30, 2024
1 parent 8fdbd72 commit 63d4e78
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 216 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/push-webapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
Expand Down
150 changes: 3 additions & 147 deletions packages/extension-base/src/koni/background/handlers/Extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ function Component ({ poolGroup, symbol }: ComponentProps) {
title={t<string>('{{symbol}} earning options', { replace: { symbol: symbol } })}
>
<SwList.Section
autoFocusSearch={false}
actionBtnIcon={<Icon phosphorIcon={FadersHorizontal} />}
autoFocusSearch={false}
className={'__section-list-container'}
enableSearchInput
filterBy={filterFunction}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ const _TaskItem = ({ actionReloadPoint, className, task }: Props): React.ReactEl
if (content) {
return (
<div className='__task-date'>
content
{content}
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ function Component ({ className = '' }: Props): React.ReactElement<Props> {
/>

<SwList.Section
autoFocusSearch={false}
actionBtnIcon={<Icon phosphorIcon={FadersHorizontal} />}
autoFocusSearch={false}
enableSearchInput
filterBy={filterFunction}
list={websiteAccessItems}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,8 @@ const Component = (props: Props, ref: ForwardedRef<InputRef>) => {
title={t('Select') + ' ' + t(handleValidatorLabel)}
>
<SwList.Section
autoFocusSearch={false}
actionBtnIcon={<Icon phosphorIcon={FadersHorizontal} />}
autoFocusSearch={false}
enableSearchInput={true}
filterBy={filterFunction}
list={resultList}
Expand Down
129 changes: 70 additions & 59 deletions packages/extension-koni-ui/src/connector/booka/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -39,65 +41,74 @@ export class BookaSdk {
private rankInfoSubject = new BehaviorSubject<Record<AccountRankType, RankInfo> | 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<AccountRankType, RankInfo>;

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<AccountRankType, RankInfo>;

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);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@
"webpack-cli": "^4.10.0",
"webpack-dev-server": "^4.11.1"
}
}
}
4 changes: 2 additions & 2 deletions packages/webapp/webpack.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ const createConfig = (entry, alias = {}, useSplitChunk = false) => {
url: false
}
},
optimization : {
optimization: {
splitChunks: {
chunks: 'all',
maxSize: 2000000,
Expand All @@ -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);

0 comments on commit 63d4e78

Please sign in to comment.