Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release hotfix to main #1375

Merged
merged 5 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 15 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,17 @@
"@astar-network/metamask-astar-types": "^0.6.1",
"@ethersproject/bignumber": "^5.5.0",
"@layerzerolabs/scan-client": "^0.0.8",
"@polkadot/api": "^11.3.1",
"@polkadot/api-contract": "^11.3.1",
"@polkadot/extension-dapp": "0.47.5",
"@polkadot/hw-ledger": "^12.6.2",
"@polkadot/keyring": "^12.6.2",
"@polkadot/networks": "^12.6.2",
"@polkadot/rpc-provider": "^11.3.1",
"@polkadot/types": "^11.3.1",
"@polkadot/types-known": "^11.3.1",
"@polkadot/types-support": "^11.3.1",
"@polkadot/ui-keyring": "^3.6.6",
"@polkadot/util": "^12.6.2",
"@polkadot/util-crypto": "^12.6.2",
"@polkadot/vue-identicon": "^3.6.6",
"@polkadot/wasm-crypto": "^7.3.2",
"@polkadot/x-randomvalues": "^12.6.2",
"@polkadot/api": "12.3.1",
"@polkadot/api-contract": "12.3.1",
"@polkadot/extension-dapp": "0.51.1",
"@polkadot/hw-ledger": "13.0.2",
"@polkadot/keyring": "13.0.2",
"@polkadot/types": "12.3.1",
"@polkadot/types-known": "12.3.1",
"@polkadot/ui-keyring": "3.8.3",
"@polkadot/util": "13.0.2",
"@polkadot/util-crypto": "13.0.2",
"@polkadot/vue-identicon": "3.8.3",
"@quasar/app-webpack": "^3.11.2",
"@quasar/extras": "^1.16.7",
"@vue/apollo-composable": "^4.0.0-beta.4",
Expand All @@ -72,7 +67,7 @@
"luxon": "^2.5.2",
"marked": "^4.0.15",
"path": "^0.12.7",
"polkasafe": "^1.4.2",
"polkasafe": "^1.4.3",
"quasar": "^2.12.7",
"query-string": "^7.1.0",
"reflect-metadata": "^0.1.13",
Expand Down Expand Up @@ -135,6 +130,9 @@
"tailwindcss": "npm:@tailwindcss/postcss7-compat@^2.0.3",
"tailwindcss-theme-variants": "^2.0.0-alpha.2"
},
"resolutions": {
"@polkadot/types": "12.3.1"
},
"browserslist": [
"last 10 Chrome versions",
"last 10 Firefox versions",
Expand Down
75 changes: 1 addition & 74 deletions src/components/header/modals/SelectAccount.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,8 @@
</fieldset>
</div>
<div class="wrapper__row--button">
<div v-if="currentNetworkChain === astarChain.ASTAR" class="row--ledger-check">
<span class="text--is-ledger">
{{ $t('wallet.isLedgerAccount') }}
</span>
<div class="toggle--custom">
<q-toggle v-model="toggleIsLedger" color="#0085ff" />
</div>
</div>
<astar-button
:disabled="(substrateAccounts.length > 0 && !selAccount) || (isLedger && !isLedgerReady)"
:disabled="substrateAccounts.length > 0 && !selAccount"
class="btn--connect"
@click="selectAccount(selAccount)"
>
Expand Down Expand Up @@ -146,8 +138,6 @@ export default defineComponent({
setup(props) {
const isShowBalance = ref<boolean>(false);
const isLoadingBalance = ref<boolean>(false);
const toggleIsLedger = ref<boolean>(false);
const isLedgerReady = ref<boolean>(false);
const accountBalanceMap = ref<SubstrateAccount[]>([]);

const isClosing = ref<boolean>(false);
Expand Down Expand Up @@ -289,67 +279,6 @@ export default defineComponent({
{ immediate: true }
);

const updateIsLedgerAccount = async (isLedger: boolean): Promise<void> => {
localStorage.setItem(LOCAL_STORAGE.IS_LEDGER, isLedger.toString());
store.commit('general/setIsLedger', isLedger);
if (isLedger) {
try {
// Memo: send a popup request for permission(first time only)
const ledgerData = new Ledger('hid', 'astar');
if (process.env.DEV) {
console.info('ledgerData', ledgerData);
}

const { address } = await ledgerData.getAddress();
if (address) {
isLedgerReady.value = true;
const transport = (ledgerData as any).__internal__app.transport;
transport.close();
localStorage.setItem(LOCAL_STORAGE.IS_LEDGER, isLedger.toString());
store.commit('general/setIsLedger', isLedger);
}
} catch (error: any) {
console.error(error);
const idLedgerLocked = '0x5515';
const idNotRunningApp = '28161';
let errMsg = '';

if (error.message.includes(idLedgerLocked)) {
errMsg = error.message;
} else if (error.message.includes(idNotRunningApp)) {
errMsg = t('warning.ledgerNotOpened');
}

if (errMsg) {
store.dispatch('general/showAlertMsg', {
msg: errMsg,
alertType: 'error',
});
}
}
} else {
isLedgerReady.value = false;
}
};

watch([selAccount], () => {
toggleIsLedger.value = false;
});

watch(
[isLedger],
() => {
toggleIsLedger.value = isLedger.value;
},
{
immediate: true,
}
);

watch([toggleIsLedger], async () => {
await updateIsLedgerAccount(toggleIsLedger.value);
});

onUnmounted(() => {
window.removeEventListener('resize', onHeightChange);
});
Expand All @@ -371,11 +300,9 @@ export default defineComponent({
endpointKey,
isMathWallet,
windowHeight,
toggleIsLedger,
isShowBalance,
currentNetworkChain,
astarChain,
isLedgerReady,
isLedger,
displayBalance,
backModal,
Expand Down
1 change: 1 addition & 0 deletions src/config/localStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export enum LOCAL_STORAGE {
MULTISIG = 'multisig',
CLOSE_DAPP_STAKING_V3_ONBOARDING = 'closeDappStakingV3Onboarding',
DECOMMISSION = 'decommission',
HAS_RAW_METADATA_V15 = 'hasRawMetadataV15',
}

// Memo: A helper function to return the account's history data that is stored in the browser
Expand Down
2 changes: 0 additions & 2 deletions src/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ export * from './useSidebar';
export * from './useAccount';
export * from './useBalance';
export * from './useContracts';
export * from './useMessages';
export * from './useWasm';
export * from './useChainMetadata';
export * from './useGetMinStaking';
Expand All @@ -23,7 +22,6 @@ export * from './chain/useAvgBlockTime';
export * from './dapps-staking/useSignPayload';
export * from './dapps-staking/useCampaign';
export * from './wallet/useWalletIcon';
export * from './wallet/useLedger';
export * from './wallet/useAccountUnification';
export * from './xcm/useXcmBridge';
export * from './transfer/useTokenTransfer';
Expand Down
11 changes: 0 additions & 11 deletions src/hooks/types/Message.ts

This file was deleted.

118 changes: 0 additions & 118 deletions src/hooks/useAbi.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/hooks/useBalance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function useCall(addressRef: Ref<string>) {
const vesting = results[1].unwrapOr(undefined)?.toArray() || [];
const currentBlock = results[2];
const vestedClaimable = results[3].vestedClaimable;
const locks: (PalletBalancesBalanceLock | BalanceLockTo212)[] = results[3].lockedBreakdown;
const locks = <(PalletBalancesBalanceLock | BalanceLockTo212)[]>results[3].lockedBreakdown;

const extendedVesting: ExtendedVestingInfo[] = [];
vestedRef.value = new BN(0);
Expand Down
11 changes: 10 additions & 1 deletion src/hooks/useChainInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import { getSpecTypes } from '@polkadot/types-known';
import { TypeRegistry } from '@polkadot/types/create';
import { formatBalance, isNumber } from '@polkadot/util';
import { defaults as addressDefaults } from '@polkadot/util-crypto/address/defaults';
import { HexString } from '@polkadot/util/types';
import { ASTAR_NATIVE_TOKEN } from 'src/config/chain';
import { useChainMetadata } from 'src/hooks/useChainMetadata';
import { ref } from 'vue';

export interface ChainInfo extends MetadataDef {
color: string | undefined;
tokenSymbol: ASTAR_NATIVE_TOKEN;
rawMetadata: HexString | undefined;
}

const registry = new TypeRegistry();
Expand All @@ -20,6 +22,7 @@ export const DEFAULT_SS58 = registry.createType('u32', addressDefaults.prefix);

function createInfo(api: ApiPromise, systemChain: string, specName: string): ChainInfo {
// console.log('chainInfo', `${systemChain} | ${systemName} | ${specName}`);

return {
chain: systemChain,
color: '#2096F3',
Expand All @@ -31,12 +34,14 @@ function createInfo(api: ApiPromise, systemChain: string, specName: string): Cha
tokenDecimals: (api.registry.chainDecimals || [DEFAULT_DECIMALS.toNumber()])[0],
tokenSymbol: (api.registry.chainTokens ||
formatBalance.getDefaults().unit)[0] as ASTAR_NATIVE_TOKEN,

types: getSpecTypes(
api.registry,
systemChain,
api.runtimeVersion.specName,
api.runtimeVersion.specVersion
) as unknown as Record<string, string>,
rawMetadata: undefined,
};
}

Expand All @@ -47,7 +52,11 @@ export function useChainInfo(api: ApiPromise) {
api.isReady.then(async () => {
const specName: string = api.runtimeVersion.specName.toString();
const systemChain: string = ((await api.rpc.system.chain()) || '<unknown>').toString();
chainInfo.value = createInfo(api, systemChain, specName);
let info = createInfo(api, systemChain, specName);
const metadata = await api.call.metadata.metadataAtVersion(15);
info.rawMetadata = metadata.toHex();

chainInfo.value = info;
});

return {
Expand Down
Loading
Loading