On mainnet-beta, signMetadata() returns a program error, whereas it works on devnet - web3js

The odd part is, the transactions both look completely successful. It's just that signMetadata throws an exception when using mainnet-beta.
Two txns for comparison, using identical code:
Mainnet-beta: https://solscan.io/tx/4zJ9qHRr3kDbhm7vMw4KmBmM4EZ8onx9ozbgKxrfw5wrvMTzaLfC1iDiYY1sQKbYKmYqVnDn4kntAwkwkG8US5Yy
Devnet: https://solscan.io/tx/3SZpHSEw3xhLKcBNiy6iPgkJvVnJNCCUjMfGHnmfvh7KWxd6zgnuDoQo1fbTCB4Uc6DqrsWfmDKAbyNR8g5wSCeK?cluster=devnet
The general shape of the code that is creating those txns:
const ret = await actions
.mintNFT({
connection,
wallet,
uri: `${apiHost}/metadata/${uuid}.json`,
maxSupply: 0,
})
.then((res) => res);
await sleep(20000);
// Sign the txn
const signTx = await actions.signMetadata({
connection,
wallet,
editionMint: ret.mint,
signer: undefined,
});
Calling mintNFT then signMetadata after a 20 second delay, which I'd seen in some example doc or another.
The specific exception: Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: custom program error: 0x39
Even when I look at the related NFT mint, everything appears correct. They show up in my wallet and look right on Solscan.
Mainnet-beta: https://solscan.io/token/KzFd3E5M1uZrYknzUmMnw7Z2xL11opQ24zmCBY9mPgD#txs
Devnet: https://solscan.io/token/7v3kbyjQeEyP4Ubw73kmfHcvwK5Jo63S4fqiHSFCS3Lt?cluster=devnet#txs
Package.json
{
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"#solana/web3.js": "^1.4",
"bignumber.js": "^9",
"#metaplex-foundation/mpl-core": "^0.0.4",
"#metaplex-foundation/mpl-token-metadata": "^1.2.4",
"#metaplex/js": "^4.11.2",
"#pinata/sdk": "^1.1.23",
"#types/node": "^17.0.12",
"#types/react": "18.0.1",
"#types/sharp": "^0.30.2",
"#types/uuid": "^8.3.4",
"dotenv": "^11.0.0",
"isomorphic-fetch": "^3.0.0",
"next": "12.1.4",
"react": "18.0.0",
"react-dom": "18.0.0",
"sharp": "^0.29.3",
"uuid": "^8.3.2"
},
"devDependencies": {
"eslint": "8.12.0",
"eslint-config-next": "12.1.4",
"ts-node": "^10.4.0",
"typescript": "^4.5.4"
}
}

The preflight confirmation level of your connection may be set to finalized, which means that the transaction is simulated against the most recent finalized block, which is 32 slots ago.
If the cluster is going slowly, which mainnet-beta has been recently, with 732ms slots compared to 390ms slots in devnet, then it'll take longer to produce the 32 blocks.
That way, when you try to simulate your second transaction 20 seconds later, your first one hasn't landed in a finalized block yet, so the cluster rejects it.
To get around this, you can use a commitment level of confirmed on your connection, by creating it with:
const connection = new Connection('https://api.mainnet-beta.solana.com', 'confirmed');
More information about confirmation levels: https://docs.solana.com/developing/clients/jsonrpc-api#configuring-state-commitment

Related

Expo start error on building JS bundle : type cast in HMRClient.js

Issue :
I rencently encountered a blocking issue in my expo project (React Native).
The type cast expression is expected to be wrapped with parenthesis
I checked my code and didn't notice any change that would cause this problem.
When I type the instructions to start the expo building (shell) with MetroBundler, it always throws an error.
expo start
Expo DevTools is running at http://localhost:19002
Opening DevTools in the browser... (press shift-d to disable)
Starting Metro Bundler
ERROR :
Failed building JavaScript bundle.
SyntaxError: C:\xamppN\htdocs\mobile-new\node_modules\react-native\Libraries\Utilities\HMRClient.js: The type cast expression is expected to be wrapped with parenthesis (284:31)
282 | function flushEarlyLogs(client) {
283 | try {
> 284 | pendingLogs.forEach(([level: LogLevel, data: Array<mixed>]) => {
| ^
285 | HMRClient.log(level, data);
286 | });
287 | } finally {
The type cast expression is expected to be wrapped with parenthesis
I tried :
Editing the targeted file, it's inside a node module, not
very effective if I have to yarn install later.
Deleting all node_modules and installing again didn't worked
Updating expo to last version, didn't change anything, same error
More infos :
package.json :
"dependencies": {
"antd": "^3.23.2",
"expo": "^39.0.0",
"expo-asset": "~8.2.0",
"expo-av": "~8.6.0",
"expo-barcode-scanner": "~9.0.0",
"expo-cli": "^3.27.14",
"expo-constants": "~9.2.0",
"expo-localization": "~9.0.0",
"expo-permissions": "~9.3.0",
"expo-secure-store": "~9.2.0",
"expo-updates": "~0.3.3",
"expokit": "31.0.2",
"moment": "^2.22.2",
"node-forge": "^0.10.0",
"npm": "^6.14.8",
"react": "16.13.1",
"react-datetime-inputs": "^0.0.6",
"react-mixin": "^2.0.2",
"react-native": "https://github.com/expo/react-native/archive/sdk-39.0.0.tar.gz",
"react-native-create-bridge": "^2.0.1",
"react-native-dialog": "^5.6.0",
"react-native-dialog-input": "^1.0.7",
"react-native-gesture-handler": "~1.7.0",
"react-native-imei": "^0.1.2",
"react-native-modal-datetime-picker": "^7.5.0",
"react-native-pay-password": "^0.0.2",
"react-native-reanimated": "~1.13.0",
"react-native-sentry": "^0.43.2",
"react-native-sha1": "^1.2.3",
"react-navigation": "^4.0.6",
"react-navigation-drawer": "^2.2.2",
"react-select": "^3.0.4",
"react-timer-mixin": "^0.13.4",
"sentry-expo": "~2.0.0",
"yarn": "^1.16.0"
It was a conflict between "yarn": "^1.16.0" and "npm": "^6.14.8".
You should choose ONE package manager and avoid cross dependencies.

How to solve this MERN stack filebase64 error?

import FileBase from 'react-file-base64';
I get an error after I hover the triple dot indicator in VS Code.
My setup has already been successful (other input fields have successfully inserted on the MongoDB Cloud) aside from the filebase64 part of inserting an image.
module "d:/nodejs/memories_project/client/node_modules/react-file-base64/build/build.min"
Could not find a declaration file for module 'react-file-base64'. 'd:/nodejs/memories_project/client/node_modules/react-file-base64/build/build.min.js' implicitly has an 'any' type.
Try npm i --save-dev #types/react-file-base64 if it exists or add a new declaration (.d.ts) file containing declare module 'react-file-base64';ts(7016)
Here are the dependencies of my package.json:
"dependencies": {
"#material-ui/core": "^4.9.10",
"#material-ui/icons": "^4.9.1",
"#testing-library/jest-dom": "^4.2.4",
"#testing-library/react": "^9.3.2",
"#testing-library/user-event": "^7.1.2",
"axios": "^0.19.2",
"moment": "^2.27.0",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-file-base64": "^1.0.3",
"react-redux": "^7.1.3",
"react-scripts": "3.4.1",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0"
},
If the value is not being saved on the database, that means it is empty or does not exist. Check if the name of the field in the model file (/server/models/) is the same as you have in the Form file (/client/src/components/).
Now the error message has nothing to do with the actual problem.
This happens because react-file-base64 doesn't provide any typing. To get rid of the error you will need to declare the module in a .d.ts file.
To do it, create a .d.ts file (e.g. index.d.ts) in your project root (where the package.json is located) with the following code:
declare module 'react-file-base64';
Or you can declare all with
declare module '*';
I had a similar issue and spent over two hours trying to debug. It can be from a range of issues, my silly mistake was that I had the multiple option set to true when I had not configured it for multiple image uploading.
My code fix as an example.
<FileBase
type="file"
multiple={false}
onDone={({base64}) => setListingData({ ...listingData, selectedFile: base64})}
/>
All you need is to change the Component, the latest I see on its documentation is using FileBase64 not FileBase
So change it into > import FileBase from 'react-file-base64';
Source

How to identify source of React.createClass warning? React v15.6

How can I identify the dependency that is causing the warning?
Warning: Accessing createClass via the main React package is deprecated, and will be removed in React v16.0....
I understand the changes that are coming with React v16.0. I want to help the dependency resolve the warnings but I don't know who needs help.
Package.json
"dependencies": {
"autosuggest-highlight": "^3.1.0",
"material-ui": "next",
"material-ui-icons": "^1.0.0-alpha.19",
"nuka-carousel": "^2.2.1",
"react": "^15.6.1",
"react-autosuggest": "^9.3.2",
"react-dom": "^15.6.1",
"react-helmet": "^5.1.3",
"react-router-dom": "^4.1.2",
"react-tap-event-plugin": "^2.0.1",
"typeface-roboto": "^0.0.35"
},
"devDependencies": {
"enzyme": "^2.9.1",
"jest-enzyme": "^3.6.1",
"react-scripts": "^1.0.10",
"react-test-renderer": "^15.6.1"
},
You see next to the warning in the console the line of it. Jump to that line in the chrome-debugger, (just click on it)
Set a break-point there
Reload the page, and you'll get there
Next, in the debugger there is the stack tab, open it, to see all the functions path to that line.. You should be able to identify the problematic source

The Angular 2 final release and the documentations "The Tour of Heroes"

Last 2 days I've been looking at the Angular 2, I'm new to it so I went straight "the official documentation" which is the Tour of Heroes example, it's ok "Just ok" tutorial and I followed the steps and I could understand a lot from it, when I reached the HTTP part and how to get access to Data sources issues started to pop up, I'm not sure if it's me very beginner in this OR the documentation is not up-to-date with the final release, :/ Google people, a big company and you guys can not assign this task to a team who take care of the documentation and keeps it updated with the releases? My opinion it's such task is mandatory for some reasons and it's the company responsibility or the Angular 2 project team's responsibility, it's new release and it's completely different from the angularjs 1.x so don't you guys think that you should provide solid reliable support in the form of up-to-date documentation right? Unless you want React to be in the lead ;)
If anyone knows good documentation for http and how to retrieve modify save and delete data and it's compatible with the final release please share it, now the issue that I collided with in the Tour of Heroes tutorial is that I get error because of this line:
import { InMemoryWebApiModule } from 'angular-in-memory-web-api';
can't find the module 'angular2-in-memory-web-api'
I was ok I'm not gonna use this in memory web Api, so I created asp.net web Api and it works fine and here is the GetHeroes method in the Heroes Controller it's so straight forward:
// GET: api/Heroes
public IQueryable<Hero> GetHeroes()
{
return db.Heroes;
}
of course I test the method and it returns all the heroes so the api working just fine, now this's the method from the hero.service.ts :
getheroes(): Promise<Hero[]>
{
return this.http.get(this.heroesUrl)
.toPromise()
.then(response => response.json().data as Hero[])
}
ok I get no errors but data is nt showing like literally nothing however when I remeove .data as Hero[] part I get enter image description here
and once I click on "one hero" I get nothing as well and the url like this : 4200/details/undefined notice instead of the hero Id I get undefined ?! anyway I noticed that in many videos of some people "tutoring" angular 2 that there is no common steps to work Http for accessing data and doing CRUD operation through api , every one doing it in different way and the thing is when I try to follow it's just not working with what I have and this's from my package.json:
"dependencies": {
"#angular/common": "2.0.0",
"#angular/compiler": "2.0.0",
"#angular/core": "2.0.0",
"#angular/forms": "2.0.0",
"#angular/http": "2.0.0",
"#angular/platform-browser": "2.0.0",
"#angular/platform-browser-dynamic": "2.0.0",
"#angular/router": "3.0.0",
"core-js": "^2.4.1",
"rxjs": "5.0.0-beta.12",
"ts-helpers": "^1.1.1",
"zone.js": "^0.6.23"
},
"devDependencies": {
"#types/jasmine": "^2.2.30",
"angular-cli": "1.0.0-beta.15",
"codelyzer": "~0.0.26",
"jasmine-core": "2.4.1",
"jasmine-spec-reporter": "2.5.0",
"karma": "1.2.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-remap-istanbul": "^0.2.1",
"protractor": "4.0.5",
"ts-node": "1.2.1",
"tslint": "3.13.0",
"typescript": "2.0.2"
}
So anyone can help or share something official and compatible with the final release? I wish the Google people pay attention and take care of the documentations, not everyone is an expert.
You must to fix the line:
import { InMemoryWebApiModule } from 'angular-in-memory-web-api';
To:
import { InMemoryWebApiModule } from 'angular2-in-memory-web-api';
You missed the 2 ...
Also in in-memory-data.service.ts file fix it
There is a mistake in documentation

Angular2 cli generates 'Error: Trying to add a new entry to an already existing one'

I'm using the Angular2 Cli as the runtime environment for my Angular 2 application. I'm really impressed with its architecture, best of class development tools, and overall well-thought-out-ness (for lack of a better word).
However, about every fifth save (build) my server generates the error message:
Error: Trying to add a new entry to an already existing one:
I then have to kill the process and restart it to get around the problem.
Here is the full text:
file changed app/vtClass.ts
The Broccoli Plugin: [BroccoliTypeScriptCompiler] failed with:
Error: Trying to add a new entry to an already existing one: /home/vturner/vtstuff/angular/projects/ang2-cli2/tmp/broccoli_type_script_compiler-input_base_path-sdRX1KMo.tmp/0/src/app/ang2-cli2.spec.ts
at BroccoliTypeScriptCompiler._addNewFileEntry (/home/vturner/vtstuff/angular/projects/ang2-cli2/node_modules/angular-cli/lib/broccoli/broccoli-typescript.js:212:13)
at /home/vturner/vtstuff/angular/projects/ang2-cli2/node_modules/angular-cli/lib/broccoli/broccoli-typescript.js:159:38
at Array.forEach (native)
at BroccoliTypeScriptCompiler._doFullBuild (/home/vturner/vtstuff/angular/projects/ang2-cli2/node_modules/angular-cli/lib/broccoli/broccoli-typescript.js:159:16)
at BroccoliTypeScriptCompiler._doIncrementalBuild (/home/vturner/vtstuff/angular/projects/ang2-cli2/node_modules/angular-cli/lib/broccoli/broccoli-typescript.js:116:12)
at BroccoliTypeScriptCompiler.build (/home/vturner/vtstuff/angular/projects/ang2-cli2/node_modules/angular-cli/lib/broccoli/broccoli-typescript.js:45:12)
at /home/vturner/vtstuff/angular/projects/ang2-cli2/node_modules/broccoli-caching-writer/index.js:152:21
at lib$rsvp$$internal$$tryCatch (/home/vturner/vtstuff/angular/projects/ang2-cli2/node_modules/rsvp/dist/rsvp.js:1036:16)
at lib$rsvp$$internal$$invokeCallback (/home/vturner/vtstuff/angular/projects/ang2-cli2/node_modules/rsvp/dist/rsvp.js:1048:17)
at lib$rsvp$$internal$$publish (/home/vturner/vtstuff/angular/projects/ang2-cli2/node_modules/rsvp/dist/rsvp.js:1019:11)
The broccoli plugin was instantiated at:
at BroccoliTypeScriptCompiler.Plugin (/home/vturner/vtstuff/angular/projects/ang2-cli2/node_modules/broccoli-plugin/index.js:10:31)
at BroccoliTypeScriptCompiler.CachingWriter [as constructor] (/home/vturner/vtstuff/angular/projects/ang2-cli2/node_modules/broccoli-caching-writer/index.js:21:10)
at BroccoliTypeScriptCompiler (/home/vturner/vtstuff/angular/projects/ang2-cli2/node_modules/angular-cli/lib/broccoli/broccoli-typescript.js:25:35)
at Angular2App.toTree (/home/vturner/vtstuff/angular/projects/ang2-cli2/node_modules/angular-cli/lib/broccoli/angular2-app.js:67:16)
at module.exports (/home/vturner/vtstuff/angular/projects/ang2-cli2/angular-cli-build.js:11:14)
at Class.module.exports.Task.extend.setupBroccoliBuilder (/home/vturner/vtstuff/angular/projects/ang2-cli2/node_modules/angular-cli/node_modules/angular-cli/lib/models/builder.js:55:19)
at Class.module.exports.Task.extend.init (/home/vturner/vtstuff/angular/projects/ang2-cli2/node_modules/angular-cli/node_modules/angular-cli/lib/models/builder.js:89:10)
at new Class (/home/vturner/vtstuff/angular/projects/ang2-cli2/node_modules/core-object/core-object.js:18:12)
at Class.module.exports.Task.extend.run (/home/vturner/vtstuff/angular/projects/ang2-cli2/node_modules/angular-cli/node_modules/angular-cli/lib/tasks/serve.js:15:19)
at /home/vturner/vtstuff/angular/projects/ang2-cli2/node_modules/angular-cli/node_modules/angular-cli/lib/commands/serve.js:70:22
I only seem to get the problem when there's a coding error, but that's not to say there's a 1-1 correspondence between coding errors and this message -- most coding errors I generate do not generate this message.
Once I get the error, the server seems to go into a blocked state where no matter what I do, including fixing the coding problem, will make the problem go away. It only goes away when I cycle the server.
It's getting really tedious to have to keep checking for this condition and cycling the server, which takes about 6s, to fix this.
I can post my code, but I don't see any rhyme or reason between the code and getting this message, so I don't think this will help i.e. I think it's an environmental issue and not a coding issue. I've tried deleting the tmp directory listed in the error message but this didn't work.
I start my server like so:
vturner#vturner-virtual-machine ~/vtstuff/angular/projects/ang2-cli2 $
sudo ng serve
Could not start watchman; falling back to NodeWatcher for file system events.
Visit http://www.ember-cli.com/user-guide/#watchman for more info.
Livereload server on http://localhost:49152
Serving on http://localhost:4200/
Build successful - 8049ms.
Slowest Trees | Total
----------------------------------------------+---------------------
BroccoliTypeScriptCompiler | 7643ms
Slowest Trees (cumulative) | Total (avg)
----------------------------------------------+---------------------
BroccoliTypeScriptCompiler (1) | 7643ms
file changed app/vtClass.ts
Build successful - 1072ms.
Note: I've been running the server as sudo, because I was either having permissions problems or I read somewhere that it runs faster as sudo (this last one may only be true on windows), but I don't think running as sudo is related to my problem.
Here is my package.json:
{
"name": "ang2-cli2",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"start": "ng server",
"postinstall": "typings install --ambient",
"lint": "tslint src/**/*.ts",
"format": "clang-format -i -style=file --glob=src/**/*.ts",
"pree2e": "webdriver-manager update",
"e2e": "protractor"
},
"private": true,
"dependencies": {
"angular2": "2.0.0-beta.11",
"es6-shim": "^0.35.0",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.2",
"systemjs": "0.19.20",
"three": "^0.75.0",
"zone.js": "^0.6.4"
},
"devDependencies": {
"angular-cli": "0.0.*",
"angular-cli-github-pages": "^0.2.0",
"clang-format": "^1.0.35",
"codelyzer": "0.0.12",
"ember-cli-inject-live-reload": "^1.4.0",
"jasmine-core": "^2.3.4",
"jasmine-spec-reporter": "^2.4.0",
"karma": "^0.13.15",
"karma-chrome-launcher": "^0.2.1",
"karma-jasmine": "^0.3.6",
"protractor": "^3.0.0",
"ts-node": "^0.5.5",
"tslint": "^3.6.0",
"typescript": "^1.8.7",
"typings": "^0.6.6"
}
}
Can anyone tell me what I'm doing wrong, or what I can do to prevent this?
Many Thanks.
If you are a windows user , please run your terminal in administrative mode. I was facing the same problem , it worked for me :)

Resources