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

Feature/defi r (#1188) #1189

Open
wants to merge 53 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
071ee1a
Feature/defi r (#1188)
RustemYuzlibaev Jul 17, 2024
94a84ef
Update AssetListItem.vue
RustemYuzlibaev Jul 25, 2024
9408dad
Merge branch 'master' into tech/defi-r
RustemYuzlibaev Jul 25, 2024
21afd15
support non-added assets
RustemYuzlibaev Jul 25, 2024
e347af7
Merge branch 'tech/defi-r' of github.com:sora-xor/sora2-wallet-web in…
RustemYuzlibaev Jul 25, 2024
66b80d0
add dates
RustemYuzlibaev Jul 26, 2024
5fee94f
Merge branch 'master' into tech/defi-r
RustemYuzlibaev Jul 26, 2024
9adc8c2
calc sbt permissions
RustemYuzlibaev Jul 28, 2024
16a648e
add translations
RustemYuzlibaev Jul 28, 2024
818c6c7
use vars
RustemYuzlibaev Jul 29, 2024
ca3f46d
make comments
RustemYuzlibaev Jul 29, 2024
8878870
fix tests
RustemYuzlibaev Jul 29, 2024
e9b3fc6
remove token creation
RustemYuzlibaev Jul 30, 2024
423e98c
remove token creation
RustemYuzlibaev Jul 30, 2024
382f856
Merge branch 'tech/defi-r' of github.com:sora-xor/sora2-wallet-web in…
RustemYuzlibaev Jul 30, 2024
0ef17bf
fix typo
RustemYuzlibaev Jul 30, 2024
7efdad1
hide date for non-involved user
RustemYuzlibaev Jul 31, 2024
9721c00
leave assetLitstItam component intact
RustemYuzlibaev Aug 2, 2024
3d0e2f2
upd tests
RustemYuzlibaev Aug 2, 2024
171a2cb
remove unused imports
RustemYuzlibaev Aug 2, 2024
e567101
bump version
RustemYuzlibaev Aug 5, 2024
62cdd89
Update package.json
RustemYuzlibaev Aug 6, 2024
85979a7
fix unspecified date
RustemYuzlibaev Aug 20, 2024
08c1e72
fix conflict
RustemYuzlibaev Aug 20, 2024
5a45caf
Tech/defi r vasiliy (#1199)
Kron1749 Aug 21, 2024
c7dfaa1
Merge branch 'master' into tech/defi-r
RustemYuzlibaev Aug 21, 2024
f5c1fc8
up ui library
RustemYuzlibaev Aug 25, 2024
0c2f781
Update package.json
RustemYuzlibaev Aug 25, 2024
bfc149e
fix translation issues
RustemYuzlibaev Sep 4, 2024
894ff33
specify locale date
RustemYuzlibaev Sep 5, 2024
9d605d6
Update package.json
RustemYuzlibaev Sep 5, 2024
fb4eb95
add warning
RustemYuzlibaev Sep 10, 2024
07b8632
Merge branch 'master' into tech/defi-r
RustemYuzlibaev Sep 10, 2024
af800ed
update unit tests
RustemYuzlibaev Sep 10, 2024
bd08bd9
Merge branch 'tech/defi-r' of github.com:sora-xor/sora2-wallet-web in…
RustemYuzlibaev Sep 10, 2024
72a9947
Merge branch 'master' into tech/defi-r
RustemYuzlibaev Sep 12, 2024
13a5a46
change imports
RustemYuzlibaev Sep 12, 2024
cd00847
Update TokenLogo.vue
RustemYuzlibaev Sep 12, 2024
187d534
fix import
RustemYuzlibaev Sep 16, 2024
3210916
add auto-attach on assets
RustemYuzlibaev Oct 3, 2024
c7754a9
Merge branch 'master' into tech/defi-r
RustemYuzlibaev Oct 3, 2024
c893b0c
disable unsupported operations
RustemYuzlibaev Oct 3, 2024
8394ed5
migrate to new storage
RustemYuzlibaev Oct 6, 2024
ead4042
fix routing
RustemYuzlibaev Oct 8, 2024
25a8094
Merge branch 'master' into tech/defi-r
RustemYuzlibaev Oct 8, 2024
6efaf1d
not allow send to non-owner
RustemYuzlibaev Oct 9, 2024
b23ee70
Update WalletSend.vue
RustemYuzlibaev Oct 10, 2024
b560bb7
fix xorless
RustemYuzlibaev Oct 10, 2024
774b36a
Update package.json
RustemYuzlibaev Oct 10, 2024
eb099a7
Merge branch 'master' into tech/defi-r
RustemYuzlibaev Oct 22, 2024
a640dc3
Merge branch 'master' into tech/defi-r
RustemYuzlibaev Oct 22, 2024
4b0d2a6
Update ReceiveToken.vue
RustemYuzlibaev Oct 22, 2024
ef09b04
Update AssetDetailsSBT.vue
RustemYuzlibaev Oct 22, 2024
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@soramitsu/soraneo-wallet-web",
"version": "1.43.4",
"version": "1.43.4-beta-1",
"license": "Apache-2.0",
"private": false,
"publishConfig": {
Expand Down
2 changes: 0 additions & 2 deletions src/SoraWallet.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import { Component, Mixins } from 'vue-property-decorator';

import AddAsset from './components/AddAsset/AddAsset.vue';
import CreateToken from './components/CreateToken.vue';
import LoadingMixin from './components/mixins/LoadingMixin';
import TranslationMixin from './components/mixins/TranslationMixin';
import ReceiveToken from './components/ReceiveToken.vue';
Expand All @@ -34,7 +33,6 @@ import type { AccountAsset } from '@sora-substrate/sdk/build/assets/types';
components: {
AddAsset,
SelectAsset,
CreateToken,
ReceiveToken,
Wallet,
WalletAssetDetails,
Expand Down
241 changes: 241 additions & 0 deletions src/components/AssetDetails/AssetDetailsSBT.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
<template>
<wallet-base :title="sbtSymbol || TranslationConsts.SBT" show-back @back="handleBack" class="sbt-permissions-info">
<s-card class="asset-details" primary>
<div class="asset-details-container s-flex">
<token-logo :token="asset" size="large" />
<div class="asset-details-title">{{ t('sbtDetails.kycVerification', { KYC: TranslationConsts.KYC }) }}</div>
<div class="asset-details-desc">
{{ t('sbtDetails.description') }}
</div>
<div class="asset-details-subtitle">{{ t('sbtDetails.issuedBy', { SBT: TranslationConsts.SBT }) }}</div>
<account-card class="asset-details-issuer">
<template #avatar>
<wallet-avatar slot="avatar" class="account-gravatar" :address="asset.address" :size="28" />
</template>
<template #name>
{{ t('sbtDetails.kycProvider', { KYC: TranslationConsts.KYC }) }}
<s-icon name="el-icon-success" size="16" />
</template>
<template #description>
<div class="asset-details-instition-mark">{{ t('sbtDetails.regulatedInsitution') }}</div>
<formatted-address :value="asset.address" :symbols="24" :tooltip-text="t('account.walletAddress')" />
</template>
</account-card>
<template v-if="showExpiryDate">
<info-line
:label="t('sbtDetails.expiryDate')"
:label-tooltip="t('sbtDetails.expiryDateTooltip')"
:value="expiryDate"
/>
<info-line
:label="t('sbtDetails.expiresIn')"
:label-tooltip="t('sbtDetails.expiresInTooltip')"
:value="expiresIn"
/>
</template>
<div v-if="regulatedAssets.length" class="asset-details-regulated-section">
<div class="asset-details-subtitle">{{ regulatedAssetsTitle }}</div>
<div class="asset-details-regulated-assets">
<div v-for="(asset, index) in regulatedAssets" :key="index">
<asset-list-item
:asset="asset"
:pinnable="false"
with-clickable-logo
@show-details="handleOpenAssetDetails"
>
<template #default="asset">
<s-button
class="wallet-assets__button el-button--details"
type="action"
size="small"
alternative
:tooltip="t('assets.details')"
@click="handleOpenAssetDetails(asset)"
>
<s-icon name="arrows-chevron-right-rounded-24" size="24" />
</s-button>
</template>
</asset-list-item>
<s-divider v-if="index < regulatedAssets.length - 1" />
</div>
</div>
</div>
<div v-else class="asset-details-subtitle asset-details-subtitle--no-permission">
{{ t('sbtDetails.noPermissions') }}
</div>
</div>
</s-card>
</wallet-base>
</template>

<script lang="ts">
import { AccountAsset, Asset } from '@sora-substrate/sdk/build/assets/types';
import { Component, Mixins, Prop } from 'vue-property-decorator';

import { api } from '../../api';
import { RouteNames } from '../../consts';
import { mutation, state } from '../../store/decorators';
import { Route } from '../../store/router/types';
import AccountCard from '../Account/AccountCard.vue';
import WalletAvatar from '../Account/WalletAvatar.vue';
import AssetListItem from '../AssetListItem.vue';
import TokenLogo from '../AssetLogos/TokenLogo.vue';
import InfoLine from '../InfoLine.vue';
import NumberFormatterMixin from '../mixins/NumberFormatterMixin';
import TranslationMixin from '../mixins/TranslationMixin';
import FormattedAddress from '../shared/FormattedAddress.vue';
import WalletBase from '../WalletBase.vue';

@Component({
components: {
AccountCard,
AssetListItem,
FormattedAddress,
TokenLogo,
InfoLine,
WalletAvatar,
WalletBase,
},
})
export default class WalletAssetDetails extends Mixins(TranslationMixin, NumberFormatterMixin) {
@state.router.currentRouteParams private currentRouteParams!: Record<string, AccountAsset>;
@state.account.address private connected!: string;
@mutation.router.navigate navigate!: (options: Route) => Promise<void>;

@Prop({ required: true, type: Object }) readonly asset!: Asset;

regulatedAssets: Array<Asset | undefined> = [];
showExpiryDate = false;
sbtSymbol = '';
expiryDate = '';
expiresIn = '';
isOwnerOpenedPage = false;

get regulatedAssetsTitle(): string {
return this.isOwnerOpenedPage ? this.t('sbtDetails.listOperable') : this.t('sbtDetails.accessPermitted');
}

handleOpenAssetDetails(asset: AccountAsset): void {
this.navigate({
name: RouteNames.WalletAssetDetails,
params: { asset, fromSbtDetails: true, prevAsset: this.currentRouteParams.asset },
});
}

handleBack(): void {
this.navigate({ name: RouteNames.Wallet });
}

isZeroBalance(asset: AccountAsset): boolean {
return this.isCodecZero(asset.balance.transferable, asset.decimals);
}

async checkExpirationDate(): Promise<void> {
const ownedAssets = await api.assets.getOwnedAssetIds(this.connected);

if (ownedAssets.includes(this.asset.address)) {
this.showExpiryDate = false;
this.isOwnerOpenedPage = true;
return;
}

if (this.isZeroBalance(this.asset as AccountAsset)) {
this.showExpiryDate = false;
return;
}

this.showExpiryDate = true;

const expiryDate = await api.extendedAssets.getSbtExpiration(this.connected, this.asset.address);

this.expiryDate = this.formatDate(Number(expiryDate), 'lll');
this.expiresIn = this.getRelativeTime(Number(expiryDate));
}

async mounted(): Promise<void> {
const { regulatedAssets, symbol } = await api.extendedAssets.getSbtMetaInfo(this.asset.address);
const infos = regulatedAssets.map((address) => api.assets.getAssetInfo(address));

this.sbtSymbol = symbol;

const regulatedAssetsInfos = (await Promise.allSettled(infos))
.map((result) => (result.status === 'fulfilled' ? result.value : undefined))
.filter(Boolean);

this.regulatedAssets = regulatedAssetsInfos;

this.checkExpirationDate();
}
}
</script>

<style lang="scss">
.sbt-permissions-info {
.asset-details {
&-container {
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
}

&-title {
margin-top: $basic-spacing;
font-size: var(--s-icon-font-size-big);
font-weight: 500;
}

&-desc {
margin-top: $inner-spacing-mini;
color: var(--s-color-base-content-secondary);
text-align: center;
font-weight: 300;
width: 80%;
}

&-regulated-section {
width: 100%;
}

&-issuer {
margin-bottom: $basic-spacing;
margin-top: $inner-spacing-mini;
}

&-subtitle {
color: var(--s-color-base-content-secondary);
margin-top: $inner-spacing-big;
text-transform: uppercase;
align-self: flex-start;
font-weight: 600;

&--no-permission {
align-self: center;
}
}

&-instition-mark {
font-size: var(--s-font-size-mini);
color: var(--s-color-status-info);
}
}

.account-card {
width: 100%;
}

// overwrite card
.el-card.asset-details {
padding: 0 !important;
}

.el-divider {
margin: 0;
}

.el-icon-success {
color: var(--s-color-fiat-value);
margin-left: 4px;
}
}
</style>
Loading