diff --git a/packages/yoroi-ergo-connector/example-cardano/index.html b/packages/yoroi-ergo-connector/example-cardano/index.html index e292f87191..17afaef849 100644 --- a/packages/yoroi-ergo-connector/example-cardano/index.html +++ b/packages/yoroi-ergo-connector/example-cardano/index.html @@ -57,6 +57,10 @@
' + JSON.stringify(addresses, undefined, 2) + '' }); @@ -626,11 +633,12 @@ createTx.addEventListener('click', () => { getCollateralUtxos.addEventListener('click', () => { toggleSpinner('show'); - + if (!accessGranted) { alertError('Should request access first'); return; } + const amount = '4900000'; cardanoApi.getCollateralUtxos( Buffer.from( @@ -649,6 +657,47 @@ getCollateralUtxos.addEventListener('click', () => { }) }) +signData.addEventListener('click', () => { + toggleSpinner('show'); + + if (!accessGranted) { + alertError('Should request access first'); + return; + } + + let address; + if (usedAddresses && usedAddresses.length > 0) { + address = usedAddresses[0]; + } else if (unusedAddresses && unusedAddresses.length > 0) { + address = unusedAddresses[0]; + } else { + alertError('Should request used or unused addresses first'); + return; + } + + if (isCBOR()) { + address = addressToCbor(address); + } + + const payload = document.querySelector('#sign-data-payload').value; + let payloadHex; + if (payload.startsWith('0x')) { + payloadHex = Buffer.from(payload.replace('^0x', ''), 'hex').toString('hex'); + } else { + payloadHex = Buffer.from(payload, 'utf8').toString('hex'); + } + + console.log('address >>> ', address); + cardanoApi.signData(address, payloadHex).then(sig => { + alertSuccess('Signature:' + JSON.stringify(sig)) + }).catch(error => { + console.error(error); + alertError(error.info); + }).then(() => { + toggleSpinner('hide'); + }); +}); + function alertError (text) { toggleSpinner('hide'); alertEl.className = 'alert alert-danger' diff --git a/packages/yoroi-ergo-connector/src/inject.js b/packages/yoroi-ergo-connector/src/inject.js index 3921e083a8..84302a7f31 100644 --- a/packages/yoroi-ergo-connector/src/inject.js +++ b/packages/yoroi-ergo-connector/src/inject.js @@ -254,9 +254,8 @@ class CardanoAPI { return this._cardano_rpc_call('sign_tx/cardano', [{ tx, partialSign, returnTx }]); } - signData(address, sigStructure) { - // TODO - throw new Error('Not implemented yet'); + signData(address, payload) { + return this._cardano_rpc_call("sign_data", [address, payload]); } getCollateralUtxos(requiredAmount) { diff --git a/packages/yoroi-extension/app/actions/profile-actions.js b/packages/yoroi-extension/app/actions/profile-actions.js index 656ef6b3fd..77b2eb044c 100644 --- a/packages/yoroi-extension/app/actions/profile-actions.js +++ b/packages/yoroi-extension/app/actions/profile-actions.js @@ -2,15 +2,13 @@ import { AsyncAction, Action } from './lib/Action'; import type { NetworkRow } from '../api/ada/lib/storage/database/primitives/tables'; import BaseProfileActions from './base/base-profile-actions'; - +import type { WalletsNavigation } from '../api/localStorage'; // ======= PROFILE ACTIONS ======= export default class ProfileActions extends BaseProfileActions { acceptTermsOfUse: AsyncAction
+ {balanceDisplay} {truncateToken(getTokenName(tokenInfo))} +
} + {showFiat === true && ++ {balanceDisplay} USD +
} + > + ); + } +}; \ No newline at end of file diff --git a/packages/yoroi-extension/app/components/common/AmountDisplay.scss b/packages/yoroi-extension/app/components/common/AmountDisplay.scss new file mode 100644 index 0000000000..2646b52e52 --- /dev/null +++ b/packages/yoroi-extension/app/components/common/AmountDisplay.scss @@ -0,0 +1,20 @@ +@import '../../themes/mixins/loading-spinner'; + +.isLoading { + position: relative; + display: flex; + align-items: center; + justify-content: center; + margin-left: 12px; + @include loading-spinner('../../assets/images/spinner-dark.svg', 16); +} + +.amount { + font-weight: 500; + font-size: 16px; +} + +.fiat { + color: var(--yoroi-palette-gray-600); + font-size: 14px; +} \ No newline at end of file diff --git a/packages/yoroi-extension/app/components/common/TextField.js b/packages/yoroi-extension/app/components/common/TextField.js index 0bc4ee131f..7c7b99c7c0 100644 --- a/packages/yoroi-extension/app/components/common/TextField.js +++ b/packages/yoroi-extension/app/components/common/TextField.js @@ -63,7 +63,7 @@ function TextField({ onBlur={onBlur} onChange={onChange} type={type !== 'password' ? type : showPassword ? 'text' : 'password'} - variant={revamp ? 'standard' : 'outlined'} + variant={revamp === true ? 'standard' : 'outlined'} /* In order to show placeholders for classic theme we dont' need to override 'shrink' and 'notched' prop status so we pass an empty object diff --git a/packages/yoroi-extension/app/components/topbar/BuySellAdaButton.js b/packages/yoroi-extension/app/components/topbar/BuySellAdaButton.js index 304d0e3ff5..18c7a4d604 100644 --- a/packages/yoroi-extension/app/components/topbar/BuySellAdaButton.js +++ b/packages/yoroi-extension/app/components/topbar/BuySellAdaButton.js @@ -38,7 +38,15 @@ class BuySellAdaButton extends Component