I am having issues verifying the collection when I mint an NFT. I am using the metaplex.nfts().create() function and I am positive the metaplex.indentity() has update authority of the collection NFT.
I get the following error.
MetaplexError: TokenMetadataProgram > Cannont Verify Collection in this Instruction
>> Source: Program > TokenMetadataProgram [metaqbxx...x1s]
>> Problem: The program [TokenMetadataProgram] at address [meta...x1s] raised an error of code [74] that translates to "Cannont Verify Collection in this Instruction".
>> Solution: Check the error message provided by the program.
Caused By: CollectionCannotBeVerifiedInThisInstruction: Cannont Verify Collection in this Instruction
I also know that everything else involved with the minting of the NFT is fine because when I add the collection with verified: 0 it works fine.
Am I able to add an NFT to an existing certified collection using the metaplex.nfts().create() function? If that is not allowed, what is the best way to do so immediately after minting?
Full stack trace:
at RpcClient.parseProgramError (file:///.../node_modules/#metaplex-foundation/js/dist/esm/plugins/rpcModule/RpcClient.mjs:206:28)
at RpcClient.sendTransaction (file:///.../node_modules/#metaplex-foundation/js/dist/esm/plugins/rpcModule/RpcClient.mjs:48:18)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RpcClient.sendAndConfirmTransaction (file:///.../node_modules/#metaplex-foundation/js/dist/esm/plugins/rpcModule/RpcClient.mjs:69:23)
at async TransactionBuilder.sendAndConfirm (file:///.../node_modules/#metaplex-foundation/js/dist/esm/utils/TransactionBuilder.mjs:131:22)
at async file:///.../node_modules/#metaplex-foundation/js/dist/esm/utils/Task.mjs:58:23
at async Disposable.run (file:///.../node_modules/#metaplex-foundation/js/dist/esm/utils/Disposable.mjs:22:14)
at async Task.callback (file:///.../node_modules/#metaplex-foundation/js/dist/esm/plugins/nftModule/NftClient.mjs:48:22)
at async file:///.../node_modules/#metaplex-foundation/js/dist/esm/utils/Task.mjs:58:23
at async Disposable.run (file:///.../node_modules/#metaplex-foundation/js/dist/esm/utils/Disposable.mjs:22:14)
at async mintNft (file:///.../src/mint/mint_lib.js:46:29)
at async mint (file:///.../src/mint/mint_lib.js:71:12)
at async Context.<anonymous> (file:///.../test/mint-test.js:27:20)
The problem is that you try to set the collection as verified true without using a verify_collection instruction. This is not possible since the mpl_token_metadata program checks if someone tries to verify a collection without using that type of instruction, check the onchain code here.
So the actual way of doing this is create the NFT with the collection not verified (verified: 0) and then use createSetAndVerifyCollectionInstruction providing the respective accounts.
Related
I am trying to edit someone else's azure function app. When I run theirs, it works fine and connects to their DB successfully. When I try and change the connection string to my DB it gives me the error
HTTP response code: 500 Internal Server Error
without any other information.
Even if I just change the one line of code which defines the DB connection, it doesn't work. I have tried it on my local machine and it works, it just doesn't work in Azure functions.
Their original code (which works):
postgresql = os.environ.get('POSTGRES_SQL')
cnxn = psycopg2.connect(postgresql)
vs. mine (which doesn't work):
postgresql = 'postgresql://sqladmin:{my-password}#{db-connection-string}?sslmode=require'
cnxn = psycopg2.connect(postgresql)
I am also not sure where their DB connection comes from, using ".get('POSTGRES_SQL')", as they don't pass that parameter in anywhere. Below is how they call the function in Azure Data Factory, note that no parameters are passed in (nor anywhere in the function):
Even I try just a bare bones block of code as seen below, it gives me the same error.
def main(req: func.HttpRequest) -> func.HttpResponse:
postgresql = 'postgresql://sqladmin:{my-password}#{db-connection-string}?sslmode=require'
cnxn = psycopg2.connect(postgresql)
cursor = cnxn.cursor()
cursor.execute("CREATE TABLE staging.test (some-column varchar(100) null)")
cnxn.commit
cursor.close()
return func.HttpResponse(f"This HTTP triggered function executed successfully.")
Please let me know what I'm missing, or if you need any other info. I have already tried all other responses to similar StackOverflow questions.
I'm working on flutter app that uses php apis for server and sqlite for local data.
The problem is with "compute()".
Here is the explanation :
I have three functions that receives data from api on the server, then add the data to my local database (sqlite) table.
First function to get data from server.
Future<List<Map<String, dynamic>>> getServerData(int vers)async {
//my code
}
Second function to insert data into local database:
Future<int> addNewData(List<Map<String, dynamic>>)async {
//my code
}
Third function to call the first and second function:
Future<bool> checkServerData(int vers)async {
List<Map<String, dynamic>> sdt= await getServerData(vers);
int res=await addNewData(sdt);
if(res>0) return true;
else return false;
}
I want to call the third function in a compute function:
compute(checkServerData, 2);
When did that I found this error:
null check operator used on null value.
Note*:
If I used it without calling local database it works good.
The error appears if I called the database to insert data into.
When I searched about this issue I found that it's not allowed to access any resources which generated in one thread from another thread. But I didn't understand exactly how to resolve it or how to use another way that do the same idea.
After searching about the issue specified, I found those workaround solutions:
1: if the process is very important to work in background, you can use the Isolate package classes and functions which allow all isolated processes or contexts to share data between them as messages sending and receiving. But it's something complex for beginners in flutter and dart to understand these things, except those who know about threading in another environments.
To now more about that I will list here some links:
Those for flutter and pub documentation:
https://api.flutter.dev/flutter/dart-isolate/dart-isolate-library.html
https://api.flutter.dev/flutter/dart-isolate/Isolate-class.html
https://pub.dev/packages/flutter_isolate
This is an example in medium.com website:
https://medium.com/flutter-community/thread-and-isolate-with-flutter-30b9631137f3
2: the second solution if the process isn't important to work on background:
using the traditional approaches such as Future.builder or async/await.
You can know more about them here:
https://www.woolha.com/tutorials/flutter-using-futurebuilder-widget-examples
https://dart.dev/codelabs/async-await
and you can review this question and answers in When should I use a FutureBuilder?
I'm using the following flutter code to query firestore which orders the data using the field timestamp.
var results = Firestore.instance.collection('post').orderBy('timestamp').getDocuments().then((value) {
var list = value.documents;
return list.map((doc) {
return doc.documentID;
}).toList();
});
When I run this code, it throws the below exception saying an index is required:
W/Firestore(31110): (21.3.0) [Firestore]: Listen for Query(app/jQH7Fp9xCZWYiqZRe7lE/post where readAccess array_contains_any [WzKImODx6WYVqdSW3D9Az3xrUnM2, PUBLIC] order by -timestamp, -name) failed: Status{code=FAILED_PRECONDITION, description=The query requires an index. You can create it here: https://console.firebase.google.com/v1/r/project/....
The exception even comes with a nice link. When opening that link, a nice UI pops up giving me the ability to create the index, with just a simple click:
Question: simple as the above may seem, I'm not very happy with this. I prefer to be able to create the index from fluttercode. In code I'm looking for something like the below:
Firestore.instance.collection('post').API-TO-CREATE-INDEX('timestamp');
Does it exist? Please advise. Many thanks.
It's not possible to create an index from client apps. You have three main choices:
Clicking the link you already saw.
Using the Firebase CLI to deploy the index from the command line.
Using the gcloud CLI to also deploy from the command line
See also the documentation on managing indexes.
I am getting an error whilst using Firebase Cloud Functions when I try to call a callable function from Flutter.
flutter: caught generic exception
flutter: PlatformException(functionsError, Firebase function failed with exception., {message: NOT FOUND, code: NOT_FOUND})
Here is how I try to call the cloud function with using cloud_functions: ^0.4.2+3
import 'package:cloud_functions/cloud_functions.dart';
_check(String id) async {
HttpsCallable callable = CloudFunctions.instance
.getHttpsCallable(functionName: 'checkUserFavorites');
try {
final HttpsCallableResult result = await callable.call(
<String, dynamic>{
'id': id,
},
);
print(result.data);
} on CloudFunctionsException catch (e) {
print('caught firebase functions exception');
print(e.code);
print(e.message);
print(e.details);
} catch (e) {
print('caught generic exception');
print(e);
}
}
I have experienced similar issues, and with few days of debugging and experimenting I found the solution only after studying the source code of Cloud Functions Plugin for Flutter.
When you deploy Firebase Cloud function, you can choose any region of preference (closer to your application the better). For example
// using DigitalOcean spaces
exports.generateCloudImageUrl = functions
.region('europe-west3')
.https.onCall((reqData, context) => {
...
}
When you want to call this function from Flutter app, you must specify the region, otherwise all goes to us-central1 which is default. See example code on how to use a function deployed in a specific region
final HttpsCallable generateCloudImageUrl = new CloudFunctions(region: "europe-west3")
.getHttpsCallable(functionName: 'generateCloudImageUrl');
// NB! if you initialize with 'CloudFunctions.instance' then this uses 'us-central1' as default region!
see cloud_function source for init.
Update, as of recent release, you can initialize as below;
FirebaseFunctions.instanceFor(region: "europe-west3").httpsCallable(
"generateCloudImageUrl",
options:
HttpsCallableOptions(timeout: const Duration(seconds: 30)));
Cloud functions are supported in the regions that you are currently running them, according to the Cloud Functions Location Documentation, but not in all regions.
According to what you shared in the comments, I would say that there are 3 cenarios to your issue:
europe-west1: The function is probably out of date, since you are getting an unespected data format error, which suggest that it expects different data/format than your default function.
europe-west2: The function is not deployed in this region, this is hinted in the error message message: NOT FOUND.
Default Function (unknown region): This is the most recent version of the function, on a region different than europe-west1 and europe-west2, and it accepts the call
with the data in the format that you are sending.
NOTE: You can check which regions you currently have your cloud function deployed on the cloud functions dashboard, as you can see on the example image below:
Also, I suspect that the default region you using is us-central1, since according to the documentation:
By default, functions run in the us-central1 region
To fix your issue, I suggest that you redeploy your current version of the function to the europe-west regions that you intend to use.
There are three reasons this error mostly happens:
1. Call the correct function:
Make sure to call the correct function in its full name (visible when you start a local emulator). Espacially if you have additional exports of files in your index.js file make sure to call the export name as well.
Syntax: serverLocation-optionalExportParent-yourFunction
Example: us-central1-post_functions-updateShare
Note that the server location can also be configured in your instance
2. Emulator: Same WIFI
Make sure to be connected to the same wifi, when using the emulator. Otherwise, any call will end in unvailablity resulting in
Unhandled Exception: [firebase_functions/unavailable] UNAVAILABLE
3. Emulator: Correct host configuration
To connect to a physical device the host at all emulators at your firebase.json must be configured: Simply add "host": "0.0.0.0".
Now the host in flutter needs to be your ip-adress of the computer. More on that here
In my case, in addition to the regional issue, what really solved to me was to include the script below in index.html:
<script src="https://www.gstatic.com/firebasejs/8.10.1/firebase-functions.js"></script>
After reading this blog post (below), I wanted to use the .orFail() helper function in one of my projects.
http://thecodebarbarian.com/whats-new-in-mongoose-53-orfail-and-global-toobject.html
When the function findById() fails, it throws the exception indicated in the .orFail() function. However, when it doesn't fail, it returns "undefined" instead of the actual model object.
let tenants = await Tenant.findById(req.params.tenantId).orFail(new Error(`ID "${req.params.tenantId}" not found`))
Any ideas?
This issue was confirmed as a bug. It's now fixed on 5.3.2
https://github.com/Automattic/mongoose/issues/7099