Skip to content

Commit

Permalink
Merge branch 'develop' into test/YOEXT-196/wallet-creation-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vsubhuman authored Oct 7, 2023
2 parents c5d2c36 + a21d997 commit 6efb47b
Show file tree
Hide file tree
Showing 296 changed files with 13,773 additions and 7,765 deletions.
8 changes: 6 additions & 2 deletions packages/yoroi-connector/src/cardanoApiInject.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,15 @@

// DEPRECATED
getCollateralUtxos(requiredAmount) {
return CardanoAPI._cardano_rpc_call("get_collateral_utxos", [requiredAmount]);
const amount = typeof requiredAmount === 'object' ? requiredAmount.amount : requiredAmount;
const strAmount = amount == null || amount === '' ? null : String(amount);
return CardanoAPI._cardano_rpc_call("get_collateral_utxos", [strAmount]);
}

getCollateral(requiredAmount) {
return CardanoAPI._cardano_rpc_call("get_collateral_utxos", [requiredAmount]);
const amount = typeof requiredAmount === 'object' ? requiredAmount.amount : requiredAmount;
const strAmount = amount == null || amount === '' ? null : String(amount);
return CardanoAPI._cardano_rpc_call("get_collateral_utxos", [strAmount]);
}
}
window.CardanoAPI = CardanoAPI;
Expand Down
1 change: 1 addition & 0 deletions packages/yoroi-extension/.babelrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const nodePlugins = {
'@emurgo/cardano-serialization-lib-browser': '@emurgo/cardano-serialization-lib-nodejs',
'ergo-lib-wasm-browser': 'ergo-lib-wasm-nodejs',
'@emurgo/cardano-message-signing-browser': '@emurgo/cardano-message-signing-nodejs',
'@emurgo/cross-csl-browser': '@emurgo/cross-csl-nodejs',
}
}]
]
Expand Down
3 changes: 2 additions & 1 deletion packages/yoroi-extension/.flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
.*/.circleci/.*
<PROJECT_ROOT>/dev/.*
<PROJECT_ROOT>/build/.*
<PROJECT_ROOT>/node_modules/@emurgo/cross-csl-browser/node_modules/resolve/test/resolver/malformed_package_json/package.json
<PROJECT_ROOT>/node_modules/@emurgo/yoroi-lib/node_modules/resolve/test/resolver/malformed_package_json/package.json
<PROJECT_ROOT>/node_modules/trezor-connect-flow/node_modules/resolve/test/resolver/malformed_package_json/package.json

Expand All @@ -30,7 +31,7 @@ deprecated-utility=error

[options]
types_first=true
include_warnings=true
include_warnings=false
esproposal.decorators=ignore
module.ignore_non_literal_requires=true
module.name_mapper.extension='scss' -> '<PROJECT_ROOT>/flow/mappers/CSSModule.js.flow'
Expand Down
6 changes: 3 additions & 3 deletions packages/yoroi-extension/app/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import MaintenancePage from './containers/MaintenancePage';
import CrashPage from './containers/CrashPage';
import { Logger } from './utils/logging';
import { LayoutProvider } from './styles/context/layout';
import { ThemeProvider } from '@mui/material/styles';
import { ColorModeProvider } from './styles/context/mode';
import { CssBaseline } from '@mui/material';
import { globalStyles } from './styles/globalStyles';
import Support from './components/widgets/Support';
Expand Down Expand Up @@ -96,15 +96,15 @@ class App extends Component<Props, State> {
return (
<div style={{ height: '100%' }}>
<LayoutProvider layout={currentTheme}>
<ThemeProvider theme={muiTheme}>
<ColorModeProvider currentTheme={currentTheme}>
<CssBaseline />
{globalStyles(muiTheme)}
<ThemeManager cssVariables={themeVars} />
{/* Automatically pass a theme prop to all components in this subtree. */}
<IntlProvider {...{ locale, key: locale, messages: mergedMessages }}>
{this.getContent()}
</IntlProvider>
</ThemeProvider>
</ColorModeProvider>
</LayoutProvider>
</div>
);
Expand Down
19 changes: 19 additions & 0 deletions packages/yoroi-extension/app/Routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ const TermsOfUsePagePromise = () => import('./containers/profile/TermsOfUsePage'
const TermsOfUsePage = React.lazy(TermsOfUsePagePromise);
const UriPromptPagePromise = () => import('./containers/profile/UriPromptPage');
const UriPromptPage = React.lazy(UriPromptPagePromise);
const OptForAnalyticsPagePromise = () => import('./containers/profile/OptForAnalyticsPage');
const OptForAnalyticsPage = React.lazy(OptForAnalyticsPagePromise);

// SETTINGS
const GeneralSettingsPagePromise = () =>
Expand All @@ -57,6 +59,9 @@ const TermsOfUseSettingsPage = React.lazy(TermsOfUseSettingsPagePromise);
const SupportSettingsPagePromise = () =>
import('./containers/settings/categories/SupportSettingsPage');
const SupportSettingsPage = React.lazy(SupportSettingsPagePromise);
const AnalyticsSettingsPagePromise = () =>
import('./containers/settings/categories/AnalyticsSettingsPage');
const AnalyticsSettingsPage = React.lazy(AnalyticsSettingsPagePromise);

const NightlyPagePromise = () => import('./containers/profile/NightlyPage');
const NightlyPage = React.lazy(NightlyPagePromise);
Expand Down Expand Up @@ -162,6 +167,8 @@ export const LazyLoadPromises: Array<() => any> = [
ConnectedWebsitesPagePromise,
YoroiPalettePagePromise,
YoroiThemesPagePromise,
OptForAnalyticsPagePromise,
AnalyticsSettingsPagePromise,
];

// populated by ConfigWebpackPlugin
Expand Down Expand Up @@ -201,6 +208,11 @@ export const Routes = (stores: StoresMap, actions: ActionsMap): Node => (
path={ROUTES.PROFILE.URI_PROMPT}
component={props => <UriPromptPage {...props} stores={stores} actions={actions} />}
/>
<Route
exact
path={ROUTES.PROFILE.OPT_FOR_ANALYTICS}
component={props => <OptForAnalyticsPage {...props} stores={stores} actions={actions} />}
/>
<Route
exact
path={ROUTES.MY_WALLETS}
Expand Down Expand Up @@ -398,6 +410,13 @@ const SettingsSubpages = (stores, actions) => (
<ComplexityLevelSettingsPage {...props} stores={stores} actions={actions} />
)}
/>
<Route
exact
path={ROUTES.SETTINGS.ANALYTICS}
component={props => (
<AnalyticsSettingsPage {...props} stores={stores} actions={actions} />
)}
/>
<Redirect to={ROUTES.SETTINGS.GENERAL} />
</Switch>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default class DelegationTransactionActions {
signTransaction: AsyncAction<{|
password?: string,
publicDeriver: PublicDeriver<>,
dialog?: any,
|}> = new AsyncAction();
setShouldDeregister: Action<boolean> = new Action();
complete: Action<void> = new Action();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ export default class BaseProfileActions {
updateHideBalance: AsyncAction<void> = new AsyncAction();
acceptNightly: Action<void> = new Action();
updateUnitOfAccount: AsyncAction<UnitOfAccountSettingType> = new AsyncAction();
optForAnalytics: Action<boolean> = new Action();
}
101 changes: 49 additions & 52 deletions packages/yoroi-extension/app/api/ada/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1038,17 +1038,6 @@ export default class AdaApi {
request.network
).reduce((acc, next) => Object.assign(acc, next), {});
const protocolParams = {
keyDeposit: RustModule.WalletV4.BigNum.from_str(config.KeyDeposit),
linearFee: RustModule.WalletV4.LinearFee.new(
RustModule.WalletV4.BigNum.from_str(config.LinearFee.coefficient),
RustModule.WalletV4.BigNum.from_str(config.LinearFee.constant),
),
coinsPerUtxoWord: RustModule.WalletV4.BigNum.from_str(config.CoinsPerUtxoWord),
poolDeposit: RustModule.WalletV4.BigNum.from_str(config.PoolDeposit),
networkId: request.network.NetworkId,
};
let unsignedTxResponse;
const trxMetadata =
request.metadata !== undefined ? createMetadata(request.metadata): undefined;
Expand All @@ -1062,7 +1051,16 @@ export default class AdaApi {
receiver,
request.utxos,
request.absSlotNumber,
protocolParams,
{
keyDeposit: RustModule.WalletV4.BigNum.from_str(config.KeyDeposit),
linearFee: RustModule.WalletV4.LinearFee.new(
RustModule.WalletV4.BigNum.from_str(config.LinearFee.coefficient),
RustModule.WalletV4.BigNum.from_str(config.LinearFee.constant),
),
coinsPerUtxoWord: RustModule.WalletV4.BigNum.from_str(config.CoinsPerUtxoWord),
poolDeposit: RustModule.WalletV4.BigNum.from_str(config.PoolDeposit),
networkId: request.network.NetworkId,
},
trxMetadata,
);
} else {
Expand Down Expand Up @@ -1096,14 +1094,14 @@ export default class AdaApi {
if (otherAddresses.length > 1) {
throw new Error(`${nameof(this.createUnsignedTxForUtxos)} can't send to more than one address`);
}
unsignedTxResponse = shelleyNewAdaUnsignedTx(
unsignedTxResponse = await shelleyNewAdaUnsignedTx(
otherAddresses.length === 1
? [{
address: otherAddresses[0].address,
amount: builtSendTokenList(
request.defaultToken,
request.tokens,
request.utxos.map(utxo => multiTokenFromRemote(utxo, protocolParams.networkId)),
request.utxos.map(utxo => multiTokenFromRemote(utxo, request.network.NetworkId)),
),
}]
: [],
Expand All @@ -1113,7 +1111,14 @@ export default class AdaApi {
},
request.utxos,
request.absSlotNumber,
protocolParams,
{
keyDeposit: config.KeyDeposit,
linearFeeCoefficient: config.LinearFee.coefficient,
linearFeeConstant: config.LinearFee.constant,
coinsPerUtxoWord: config.CoinsPerUtxoWord,
poolDeposit: config.PoolDeposit,
networkId: request.network.NetworkId,
},
[],
[],
false,
Expand Down Expand Up @@ -1277,14 +1282,12 @@ export default class AdaApi {
).reduce((acc, next) => Object.assign(acc, next), {});

const protocolParams = {
keyDeposit: RustModule.WalletV4.BigNum.from_str(config.KeyDeposit),
linearFee: RustModule.WalletV4.LinearFee.new(
RustModule.WalletV4.BigNum.from_str(config.LinearFee.coefficient),
RustModule.WalletV4.BigNum.from_str(config.LinearFee.constant),
),
coinsPerUtxoWord: RustModule.WalletV4.BigNum.from_str(config.CoinsPerUtxoWord),
poolDeposit: RustModule.WalletV4.BigNum.from_str(config.PoolDeposit),
networkId: network.NetworkId,
keyDeposit: config.KeyDeposit,
linearFeeCoefficient: config.LinearFee.coefficient,
linearFeeConstant: config.LinearFee.constant,
coinsPerUtxoWord: config.CoinsPerUtxoWord,
poolDeposit: config.PoolDeposit,
networkId: request.publicDeriver.getParent().networkInfo.NetworkId,
};

const defaultToken = request.publicDeriver.getParent().getDefaultToken();
Expand Down Expand Up @@ -1413,7 +1416,7 @@ export default class AdaApi {
const minAmount = Scope.WalletV4.min_ada_required(
cardanoValueFromMultiToken(amount),
dataHash != null,
protocolParams.coinsPerUtxoWord,
RustModule.WalletV4.BigNum.from_str(protocolParams.coinsPerUtxoWord),
);

if ((new BigNumber(minAmount.to_str())).gt(new BigNumber(target.value ?? '0'))) {
Expand Down Expand Up @@ -1450,7 +1453,7 @@ export default class AdaApi {
nativeScripts,
};

const unsignedTxResponse = shelleyNewAdaUnsignedTxForConnector(
const unsignedTxResponse = await shelleyNewAdaUnsignedTxForConnector(
outputs,
mint,
auxiliaryData,
Expand Down Expand Up @@ -1493,14 +1496,12 @@ export default class AdaApi {
).reduce((acc, next) => Object.assign(acc, next), {});

const protocolParams = {
keyDeposit: RustModule.WalletV4.BigNum.from_str(config.KeyDeposit),
linearFee: RustModule.WalletV4.LinearFee.new(
RustModule.WalletV4.BigNum.from_str(config.LinearFee.coefficient),
RustModule.WalletV4.BigNum.from_str(config.LinearFee.constant),
),
coinsPerUtxoWord: RustModule.WalletV4.BigNum.from_str(config.CoinsPerUtxoWord),
poolDeposit: RustModule.WalletV4.BigNum.from_str(config.PoolDeposit),
networkId: request.publicDeriver.getParent().getNetworkInfo().NetworkId,
keyDeposit: config.KeyDeposit,
linearFeeCoefficient: config.LinearFee.coefficient,
linearFeeConstant: config.LinearFee.constant,
coinsPerUtxoWord: config.CoinsPerUtxoWord,
poolDeposit: config.PoolDeposit,
networkId: request.publicDeriver.getParent().networkInfo.NetworkId,
};

const publicKeyDbRow = await request.publicDeriver.getPublicKey();
Expand Down Expand Up @@ -1532,7 +1533,7 @@ export default class AdaApi {
if (changeAddr == null) {
throw new Error(`${nameof(this.createDelegationTx)} no internal addresses left. Should never happen`);
}
const unsignedTx = shelleyNewAdaUnsignedTx(
const unsignedTx = await shelleyNewAdaUnsignedTx(
[],
{
address: changeAddr.addr.Hash,
Expand Down Expand Up @@ -1620,14 +1621,12 @@ export default class AdaApi {
).reduce((acc, next) => Object.assign(acc, next), {});

const protocolParams = {
keyDeposit: RustModule.WalletV4.BigNum.from_str(config.KeyDeposit),
linearFee: RustModule.WalletV4.LinearFee.new(
RustModule.WalletV4.BigNum.from_str(config.LinearFee.coefficient),
RustModule.WalletV4.BigNum.from_str(config.LinearFee.constant),
),
coinsPerUtxoWord: RustModule.WalletV4.BigNum.from_str(config.CoinsPerUtxoWord),
poolDeposit: RustModule.WalletV4.BigNum.from_str(config.PoolDeposit),
networkId: request.publicDeriver.getParent().getNetworkInfo().NetworkId,
keyDeposit: config.KeyDeposit,
linearFeeCoefficient: config.LinearFee.coefficient,
linearFeeConstant: config.LinearFee.constant,
coinsPerUtxoWord: config.CoinsPerUtxoWord,
poolDeposit: config.PoolDeposit,
networkId: request.publicDeriver.getParent().networkInfo.NetworkId,
};

const utxos = await request.publicDeriver.getAllUtxos();
Expand Down Expand Up @@ -1714,7 +1713,7 @@ export default class AdaApi {
if (finalWithdrawals.length === 0 && certificates.length === 0) {
throw new RewardAddressEmptyError();
}
const unsignedTxResponse = shelleyNewAdaUnsignedTx(
const unsignedTxResponse = await shelleyNewAdaUnsignedTx(
[],
{
address: changeAddr.addr.Hash,
Expand Down Expand Up @@ -1783,14 +1782,12 @@ export default class AdaApi {
).reduce((acc, next) => Object.assign(acc, next), {});

const protocolParams = {
keyDeposit: RustModule.WalletV4.BigNum.from_str(config.KeyDeposit),
linearFee: RustModule.WalletV4.LinearFee.new(
RustModule.WalletV4.BigNum.from_str(config.LinearFee.coefficient),
RustModule.WalletV4.BigNum.from_str(config.LinearFee.constant),
),
coinsPerUtxoWord: RustModule.WalletV4.BigNum.from_str(config.CoinsPerUtxoWord),
poolDeposit: RustModule.WalletV4.BigNum.from_str(config.PoolDeposit),
networkId: request.publicDeriver.getParent().getNetworkInfo().NetworkId,
keyDeposit: config.KeyDeposit,
linearFeeCoefficient: config.LinearFee.coefficient,
linearFeeConstant: config.LinearFee.constant,
coinsPerUtxoWord: config.CoinsPerUtxoWord,
poolDeposit: config.PoolDeposit,
networkId: request.publicDeriver.getParent().networkInfo.NetworkId,
};

const allUtxo = await request.publicDeriver.getAllUtxos();
Expand Down Expand Up @@ -1818,7 +1815,7 @@ export default class AdaApi {
trxMetadata = request.normalWallet.metadata;
}

const unsignedTx = shelleyNewAdaUnsignedTx(
const unsignedTx = await shelleyNewAdaUnsignedTx(
[],
{
address: changeAddr.addr.Hash,
Expand Down
Loading

0 comments on commit 6efb47b

Please sign in to comment.