Skip to content

Commit

Permalink
Fix claim auth and transfer display (#165)
Browse files Browse the repository at this point in the history
* Fix transfer display (#164)

* Fix CSM token typo
  • Loading branch information
yashirooooo authored May 28, 2021
1 parent 2391125 commit 9f3a798
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dev-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
run: yarn install --immutable

- name: Build bundle
run: yarn build
run: CSM_CLAIM_USER=${{ secrets.CSM_CLAIM_USER }} CSM_CLAIM_PASSWD=${{ secrets.CSM_CLAIM_PASSWD }} CRU_CLAIM_USER=${{ secrets.CRU_CLAIM_USER }} CRU_CLAIM_PASSWD=${{ secrets.CRU_CLAIM_PASSWD }} yarn build

- name: Build and push docker
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
run: yarn install --immutable

- name: Build the IPFS bundle
run: NODE_ENV=production yarn build:www
run: CSM_CLAIM_USER=${{ secrets.CSM_CLAIM_USER }} CSM_CLAIM_PASSWD=${{ secrets.CSM_CLAIM_PASSWD }} CRU_CLAIM_USER=${{ secrets.CRU_CLAIM_USER }} CRU_CLAIM_PASSWD=${{ secrets.CRU_CLAIM_PASSWD }} NODE_ENV=production yarn build:www

- name: Build and push docker
run: |
Expand Down
4 changes: 4 additions & 0 deletions env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ echo -n > $TARGET
declare -a vars=(
"WS_URL"
"SAMPLE"
"CRU_CLAIM_USER"
"CRU_CLAIM_PASSWD"
"CSM_CLAIM_USER"
"CSM_CLAIM_PASSWD"
)

echo "window.process_env = {" >> $TARGET
Expand Down
3 changes: 2 additions & 1 deletion packages/apps/public/locales/zh/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1488,5 +1488,6 @@
"Send CRU": "发送CRU",
"Send CSM": "发送CSM",
"Send Candy": "发送糖果",
"Candy": "糖果"
"Candy": "糖果",
"Claim CRU": "认领CRU"
}
6 changes: 5 additions & 1 deletion packages/apps/webpack.base.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,11 @@ function createWebpack (context, mode = 'production') {
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
VERSION: JSON.stringify(pkgJson.version),
WS_URL: JSON.stringify(process.env.WS_URL)
WS_URL: JSON.stringify(process.env.WS_URL),
CRU_CLAIM_USER: JSON.stringify(process.env.CRU_CLAIM_USER),
CRU_CLAIM_PASSWD: JSON.stringify(process.env.CRU_CLAIM_PASSWD),
CSM_CLAIM_USER: JSON.stringify(process.env.CSM_CLAIM_USER),
CSM_CLAIM_PASSWD: JSON.stringify(process.env.CSM_CLAIM_PASSWD)
}
}),
new webpack.optimize.SplitChunksPlugin(),
Expand Down
59 changes: 38 additions & 21 deletions packages/page-accounts/src/Accounts/Account.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright 2017-2021 @polkadot/app-accounts authors & contributors
// SPDX-License-Identifier: Apache-2.0

import './account.css';

import type { SubmittableExtrinsic } from '@polkadot/api/types';
import type { DeriveBalancesAll, DeriveDemocracyLock } from '@polkadot/api-derive/types';
import type { Ledger } from '@polkadot/hw-ledger';
Expand Down Expand Up @@ -260,24 +262,6 @@ function Account ({ account: { address, meta }, className = '', delegation, filt
>
{t('Unlock vested amount')}
</Menu.Item>
),
isFunction(api.api.tx.csm?.transfer) && (
<Menu.Item
icon='paper-plane'
label={t<string>('Send CSM')}
onClick={toggleTransferCsm}
>
{t('Send CSM')}
</Menu.Item>
),
isFunction(api.api.tx.candy?.transfer) && (
<Menu.Item
icon='paper-plane'
label={t<string>('Send Candy')}
onClick={toggleTransferCandy}
>
{t('Send Candy')}
</Menu.Item>
)
]),
createMenuGroup('deriveGroup', [
Expand Down Expand Up @@ -391,7 +375,7 @@ function Account ({ account: { address, meta }, className = '', delegation, filt
/>
])
].filter((i) => i),
[_clearDemocracyLocks, _showOnHardware, _vestingVest, api, delegation, democracyUnlockTx, genesisHash, identity, isDevelopment, isEditable, isExternal, isHardware, isInjected, isMultisig, multiInfos, onSetGenesisHash, proxy, recoveryInfo, t, toggleBackup, toggleDelegate, toggleDerive, toggleForget, toggleIdentityMain, toggleIdentitySub, toggleMultisig, togglePassword, toggleProxyOverview, toggleRecoverAccount, toggleRecoverSetup, toggleUndelegate, toggleTransferCandy, toggleTransferCsm, vestingVestTx]);
[_clearDemocracyLocks, _showOnHardware, _vestingVest, api, delegation, democracyUnlockTx, genesisHash, identity, isDevelopment, isEditable, isExternal, isHardware, isInjected, isMultisig, multiInfos, onSetGenesisHash, proxy, recoveryInfo, t, toggleBackup, toggleDelegate, toggleDerive, toggleForget, toggleIdentityMain, toggleIdentitySub, toggleMultisig, togglePassword, toggleProxyOverview, toggleRecoverAccount, toggleRecoverSetup, toggleUndelegate, vestingVestTx]);

if (!isVisible) {
return null;
Expand Down Expand Up @@ -650,15 +634,48 @@ function Account ({ account: { address, meta }, className = '', delegation, filt
<td className='number'>
<PreClaimCRU18 value={address} />
</td>

<td className='button'>
{isFunction(api.api.tx.balances?.transfer) && (
{/* {isFunction(api.api.tx.balances?.transfer) && (
<Button
icon='paper-plane'
label={t<string>('Send CRU')}
onClick={toggleTransfer}
/>
)}
)} */}

<Popup
className='my-popup'
on='click'
trigger={<Button
icon='paper-plane'
label={t<string>('Send')}
/>}
>

{isFunction(api.api.tx.balances?.transfer) && (
<Button
icon='paper-plane'
label={t<string>('Send CRU')}
onClick={toggleTransfer}
/>
)}
{isFunction(api.api.tx.csm?.transfer) && (
<Button
icon='paper-plane'
label={t<string>('Send CSM')}
onClick={toggleTransferCsm}
/>
)}
{isFunction(api.api.tx.candy?.transfer) && (
<Button
icon='paper-plane'
label={t<string>('Send Candy')}
onClick={toggleTransferCandy}
/>
)}

</Popup>
<Popup
className={`theme--${theme}`}
isOpen={isSettingsOpen}
Expand Down
3 changes: 3 additions & 0 deletions packages/page-accounts/src/Accounts/account.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.my-popup {
max-width: 150px!important;
}
4 changes: 2 additions & 2 deletions packages/page-claims/src/claims/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import { base64Encode } from '@polkadot/util-crypto';
const MAX_RETRY = 3;
const RETRY_INTERVAL = 1000;
const USERNAME = 'crustbridgeadmin';
const PASSWD = '102938'
const USERNAME = process.env.CRU_CLAIM_USER;
const PASSWD = process.env.CRU_CLAIM_PASSWD

function sleep(ms){
return new Promise((resolve)=>setTimeout(resolve,ms));
Expand Down
2 changes: 1 addition & 1 deletion packages/page-claims/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function ClaimsApp ({ basePath, onStatusChange }: Props): React.ReactElement<Pro
const itemsRef = useRef([{
isRoot: true,
name: 'claims',
text: t<string>('Claim tokens')
text: t<string>('Claim CRU')
}, {
name: 'claimsMainnet',
text: t<string>('Claim CRU18')
Expand Down
4 changes: 2 additions & 2 deletions packages/page-claims/src/maxwellCsmClaims/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import { base64Encode } from '@polkadot/util-crypto';
const MAX_RETRY = 3;
const RETRY_INTERVAL = 1000;
const USERNAME = '123';
const PASSWD = '123'
const USERNAME = process.env.CSM_CLAIM_USER
const PASSWD = process.env.CSM_CLAIM_PASSWD

function sleep(ms){
return new Promise((resolve)=>setTimeout(resolve,ms));
Expand Down
4 changes: 2 additions & 2 deletions packages/page-claims/src/maxwellCsmClaims/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ function CSMClaims (): React.ReactElement<Props> {

const handleAccountStep = useCallback(async () => {
setIsBusy(true);
const result = await httpPost("http://101.132.117.183:13330/csmClaim/" + ethereumTxHash);
const result = await httpPost("https://csm-bridge-api.crust.network/csmClaim/" + ethereumTxHash);

setIsBusy(false);
setResult(result.statusText);
Expand Down Expand Up @@ -272,7 +272,7 @@ function CSMClaims (): React.ReactElement<Props> {
<main>
{!isOldClaimProcess && <Warning />}
<h1>
<Trans>Claim your CSM tokens</Trans>
<Trans>Claim your <em>CSM</em> tokens</Trans>
</h1>
<Columar>
<Columar.Column>
Expand Down

0 comments on commit 9f3a798

Please sign in to comment.