ModuleId required for crowdfunding recipe is not present - substrate

The crowdfunding app has an import ModuleId
use sp_runtime::{
traits::{AccountIdConversion, Saturating, Zero},
ModuleId,
};
const PALLET_ID: ModuleId = ModuleId(*b"ex/cfund");
I am now using FRAME 2.0, sp_runtime no more contain ModuleId, what is the alternative for it?
unresolved import `sp_runtime::ModuleId`

ModuleId -> PalletId
Occurred here: https://github.com/paritytech/substrate/pull/8477

Related

Phaser 3. Importing phaser/src/core/Game produce error during runtime

The phaser game not starting error on
import Game1 from "phaser/src/core/Game";
import { Game } from "phaser";
console.log(Game1, Game);
const app = new Game1(gameSettings);
the following output of the console log which are similar class:
but when I trie to make use the one from the phaser js directly, no error found
import { Game } from "phaser";
const app = new Game(gameSettings);
Thanks in advance for answers which part I do wrong.
In all example I found on the web I see this kind of imports for Phaser
import 'phaser';
import Phaser from 'phaser';
import * as Phaser from 'phaser';
and then boot the game with
new Phaser.Game(config)

MatDialog Error: No provider for InjectionToken mat-dialog-scroll-strategy

By including Provider: MatDialog in the Constructur
constructor(groupService: GroupService, public dialog: MatDialog) {}
I get following error at runtime
Error: No provider for InjectionToken mat-dialog-scroll-strategy!
I have included the Matdialog in the "app.module.ts"
Do I need a different Provider for it and which one? I use angular-material 2.0.0b12
You need to include MatDialog Module in the imports.
import {MatDialogModule} from '#angular/material';
#NgModule({
imports :[MatDialogModule],
...
})
Edit 2022
You need to include MatDialog Module in the imports.
import {MatDialogModule} from '#angular/material/dialog';
#NgModule({
imports :[MatDialogModule],
...
})
This error also happens if you try to open dialog of a lazy loaded module from service with #Injectable({providedIn: 'root'}).
To fix it you have to either move that dialog to main module or remove providedIn notation and add it as provides: [] in lazy loaded module.
Import the dialog from import {MatDialogModule} from '#angular/material/dialog';
by adding following code to your module.ts file
import {MatDialogModule} from '#angular/material/dialog';
Then import it in imports as the following can see,
const MaterialComponent = [MatDialogModule];

How to access a struct from an external package in Go

I'm trying to import a struct from another package in the following file:
// main.go
import "path/to/models/product"
product = Product{Name: "Shoes"}
// models/product.go
type Product struct{
Name string
}
But in the main.go file the struct Product is undefined. How do I import the struct?
In Go you import "complete" packages, not functions or types from packages.
(See this related question for more details: What's C++'s `using` equivalent in golang)
See Spec: Import declarations for syntax and deeper explanation of the import keyword and import declarations.
Once you import a package, you may refer to its exported identifiers with qualified identifiers which has the form: packageName.Identifier.
So your example could look like this:
import "path/to/models/product"
import "fmt"
func main() {
p := product.Product{Name: "Shoes"}
// Use product, e.g. print it:
fmt.Println(p) // This requires `import "fmt"`
}

intl package and date formatting strange behaviour

I start to use intl package in my dart project.
After start to use this package i use this code:
DateTime now = new DateTime.now();
var formatter = new DateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
String nowFormatted = formatter.format(now);
And it works correctly.
After i use intl i obtain this message in log:
Uncaught LocaleDataException: Locale data has not been initialized, call initializeDateFormatting(<locale>).
I cannot understand why i should pass locale in this code snippet
intl: ^0.15.7
I've the same issue to the current Intl version so I've solved with
these imports:
import 'package:intl/intl.dart';
import 'package:intl/date_symbol_data_local.dart';
and the code:
initializeDateFormatting();
DateTime now = DateTime.now();
var dateString = DateFormat('dd-MM-yyyy').format(now);
final String configFileName = 'lastConfig.$dateString.json';
Verify your imports:
import 'package:intl/date_symbol_data_local.dart';
import 'package:intl/intl.dart';
Set initializeDateFormatting according to your language, example:
initializeDateFormatting('pt_BR', null);
If you encounter this problem, write initializeDateFormatting('az'); top of "Material App". I searched for 1 hour and nobody wrote it clearly.
it is really solved.
I have solved this use in this way:
DateTime now = new DateTime.now();
var formatter = new DateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", 'en');
String nowFormatted = formatter.format(now);
But I have to make this to my dart file used to configure itnl support:
library translation_helper;
import 'dart:async';
import 'package:intl/date_symbol_data_local.dart';
import '../../resources/messages_all.dart';
void setupLanguage(){
//var germanDatesFuture = initializeDateFormatting('de_DE', null);
var enDatesFuture = initializeDateFormatting('en', null);
var germanMessagesFuture = initializeMessages('de');
var englishMessagesFuture = initializeMessages('en');
var italianMessagesFuture = initializeMessages('it');
var polishMessagesFuture = initializeMessages('pl');
Future
.wait([
enDatesFuture,
germanMessagesFuture,
englishMessagesFuture,
italianMessagesFuture,
polishMessagesFuture
]);
}
Before I was missing:
var enDatesFuture = initializeDateFormatting('en', null);
For more info I use:
dart 1.15.0
intl 0.12.7
Use this function in main
initializeDateFormatting();
and import like this
import 'package:intl/date_symbol_data_local.dart';
There's no need to call initializeDateFormatting directly from your code. Just call load method of app's localization delegates.
So you specify delegates like this:
final localizationsDelegates = <LocalizationsDelegate>[
AppLocalizationsDelegate(),
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
CupertinoLocalizationsDelegate()
];
...
MaterialApp(
localizationsDelegates: localizationsDelegates,
)
And pre-load them with system's locale:
import 'dart:ui' as ui;
...
for (final delegate in localizationsDelegates) {
await delegate.load(ui.Locale(ui.window.locale.languageCode));
}
In your pubspec.yaml, add this dependencie package: intl:
In your highest StatefulWidget (in your dart file), add these imports:
import 'package:intl/intl.dart';
import 'package:intl/date_symbol_data_local.dart';
In its State, override initState add :
#override
void initState() {
super.initState();
initializeDateFormatting(); //very important
}
And the code:
DateTime now = new DateTime.now();
var formatter = new DateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
String nowFormatted = formatter.format(now);
My issue was that I was getting error specifically for the "en_US" Locale even when I was not particularly using it. But I solved it by:
initializeDateFormatting('en', null);
initializeDateFormatting('en_US,', null);
In your class with MaterialApp add this code
import 'package:intl/date_symbol_data_local.dart';
#override
void initState() {
// TODO: implement initState
super.initState();`enter code here`
initializeDateFormatting();
}
To initialize the date format as per the system locale.
import 'package:intl/intl_standalone.dart'; // For standlone app
import 'package:intl/intl_browser.dart'; // For standlone app
import 'package:intl/date_symbol_data_local.dart';
...
await initializeDateFormatting(await findSystemLocale(), null);
I got the same error. But, only when switching between locales ('en' and 'si') within the app. None of the other solutions worked for me. So I just came up with this dumbest solution, and it worked. Just wrapped date-formatting in a try-catch block while initializeDateFormatting() is being called inside the catch block
String date(DateTime date, String _languageCode) {
try {
var formatter = new DateFormat.yMMMMd(_languageCode);
return formatter.format(date);
} catch(e) {
initializeDateFormatting();
var formatter = new DateFormat.yMMMMd(_languageCode);
return formatter.format(date);
}
}
Depending on intl: ^0.18.0
Just add this line in the method that listens to each time the locale changes
Intl.defaultLocale = languageCode;
package: https://pub.dev/packages/intl

How do I access my app code from my tests in a Swift project?

I have an Swift Xcode project with code such as:
class Utils: NSObject {
class func cleanString (input: String, trim: Bool) -> String {
// ...
}
}
and then I try to test it:
import XCTest
class AppTests: XCTestCase {
func testConfiguratio() {
Utils.cleanString("foo", trim: true)
}
}
but I get this error:
/Users/pupeno/Projects/macninja/AppTests/AppTests.swift:35:9: Use of unresolved identifier 'Utils'
I have Host Application APIs enabled:
What am I missing?
As it has been said already, the library code and the test code are 2 different modules. So you have to import the library into the test code and also make the functions that you want to test public, e.g:
public class Utils: NSObject {
public class func cleanString (input: String, trim: Bool) -> String {
// ...
}
}
and
import XCTest
import Utils
class AppTests: XCTestCase {
func testConfiguratio() {
Utils.cleanString("foo", trim: true)
}
}
If you want to see working code look at my IBANtools library project which implements exactly this scenario (class functions, swift framework, lots of testing).
If this is an OSX project - make sure you included
#Testable import YOURPROJECTNAME
Above the 'class AppTests: XCTestCase'
and clean your project files.
My Previous question where I had a similar issue is here
Hope this helps ( even a year later...)
The module that contains your tests is distinct from the module that contains your app code. When you want to access classes that are contained within a separate module you need to ensure that the to-be-imported classes are marked as public:
public class Utils: NSObject {
class func cleanString (input: String, trim: Bool) -> String {
// ...
}
}

Resources