I try to interact with Ethereum node via web3 lib. (meteor add ethereum:web3)
Meteor 1.5.4.1
lib.js:
if (typeof web3 === ‘undefined’){
web3 = new Web3(new Web3.providers.HttpProvider(‘http://127.0.0.1:21045’));
}
main.js:
web3.eth.defaultContractEvent = “0x*************************************”;
contract_event = web3.eth.contract(abi_event).at(web3.eth.defaultContractEvent);
var events = contract_event.allEvents({fromBlock: 0, toBlock: ‘latest’});
get error at last line
C:\Users***\AppData\Local.meteor\packages\meteor-tool\1.5.2_2\mt-os.windows.x86_32\dev_bundle\server-lib\node_modules\fibers\future.js:280
throw(ex);
^
TypeError: XHR2 is not a function
at [object Object].HttpProvider.prepareRequest (packages\ethereum_web3.js:4315:15)
at [object Object].HttpProvider.sendAsync (packages\ethereum_web3.js:4364:22)
at [object Object].RequestManager.sendAsync (packages\ethereum_web3.js:6369:19)
at Object.send [as newFilter] (packages\ethereum_web3.js:5080:42)
at new Filter (packages\ethereum_web3.js:3568:25)
at [object Object].AllSolidityEvents.execute (packages\ethereum_web3.js:2716:12)
at server/main.js:135:30
at Function.time (C:\***\.meteor\local\build\programs\server\profile.js:309:28)
at C:\***\.meteor\local\build\programs\server\boot.js:348:13
at C:\***\.meteor\local\build\programs\server\boot.js:389:5
Exited with code: 1
what is the problem?
Related
I want to use Box Node SDK on Deno (v1.30.3) . here is a simple example.
import BoxSDK from "npm:box-node-sdk#2.8.1";
import conf from "/path/to/config.json" assert {type: "json"};
const sdk = BoxSDK.getPreconfiguredInstance(conf);
const client = sdk.getAppAuthClient("enterprise");
client.users.get(client.CURRENT_USER_ID).then((me: any) => {
console.log(me); // should print user’s name
})
This is what I get.
error: Uncaught Error: Not implemented: crypto.Sign
throw new Error(message);
^
at notImplemented (https://deno.land/std#0.177.0/node/_utils.ts:23:9)
at new Sign (https://deno.land/std#0.177.0/node/internal/crypto/sig.ts:45:5)
at Object.createSign (https://deno.land/std#0.177.0/node/crypto.ts:268:10)
at Object.sign (file:///Users/hkobayashi/Library/Caches/deno/npm/registry.npmjs.org/jwa/1.4.1/index.js:151:25)
at Object.jwsSign \[as sign\] (file:///Users/hkobayashi/Library/Caches/deno/npm/registry.npmjs.org/jws/3.2.2/lib/sign-stream.js:32:24)
at Object.module.exports \[as sign\] (file:///Users/hkobayashi/Library/Caches/deno/npm/registry.npmjs.org/jsonwebtoken/8.5.1/sign.js:204:16)
at TokenManager.getTokensJWTGrant (file:///Users/hkobayashi/Library/Caches/deno/npm/registry.npmjs.org/box-node-sdk/2.8.1/lib/token-manager.js:286:48)
at AppAuthSession.\_refreshAppAuthAccessToken (file:///Users/hkobayashi/Library/Caches/deno/npm/registry.npmjs.org/box-node-sdk/2.8.1/lib/sessions/app-auth-session.js:79:18)
at AppAuthSession.getAccessToken (file:///Users/hkobayashi/Library/Caches/deno/npm/registry.npmjs.org/box-node-sdk/2.8.1/lib/sessions/app-auth-session.js:124:25)
at BoxClient.\_makeRequest (file:///Users/hkobayashi/Library/Caches/deno/npm/registry.npmjs.org/box-node-sdk/2.8.1/lib/box-client.js:300:18)
at BoxClient.get (file:///Users/hkobayashi/Library/Caches/deno/npm/registry.npmjs.org/box-node-sdk/2.8.1/lib/box-client.js:452:21)
at wrappedClientMethod (file:///Users/hkobayashi/Library/Caches/deno/npm/registry.npmjs.org/box-node-sdk/2.8.1/lib/box-client.js:589:30)
at Users.get (file:///Users/hkobayashi/Library/Caches/deno/npm/registry.npmjs.org/box-node-sdk/2.8.1/lib/managers/users.js:42:67)
at file:///Users/hkobayashi/dev/poc/poc24-deno/2023-02/box-hello.ts:8:14
Does this mean deno's crypto library hasn't yet fully implemented?
is there any workaround?
Edit:
After some changes with help from #Frank van Puffelen
I getting a new error see below updated code and updated error
Hello everyone im trying to save a gif which I create with flutter_ffmpeg: ^0.4.2
With this code im trying to create a gif of picked video from user which is currently widget.videopathasstring
THis is the path of picked video.
Directory gifDirectory;
String gifOutputFile;
getpreviewvideo() async {
String currentvideo = widget.videopathasstring;
await getApplicationDocumentsDirectory().then((directory) {
print("13");
gifDirectory = Directory(directory.path + '/gif');
print("14");
gifDirectory.exists().then((exists) async {
print("0");
if (!exists) {
print("1");
await gifDirectory.create();
}
}).then((value) => {
print("3"),
gifOutputFile = gifDirectory.path +
'/' +
DateTime.now().millisecondsSinceEpoch.toString() +
'.gif',
});
});
print("4");
var arguments = [
'-i',
currentvideo,
'-t',
'2.5',
'-ss',
'2.0',
'-f',
'gif',
gifOutputFile,
];
_flutterFFmpeg.executeWithArguments(arguments).then((rc) {
print("FFmpeg process exited with rc $rc");
});
return File(gifOutputFile);
}
The problem is im getting this error
GTMSessionFetcher invoking fetch callbacks, data {length = 0, bytes = 0x}, error (null)
2
GTMSessionFetcher invoking fetch callbacks, data {length = 613, bytes = 0x7b0a2020 226e616d 65223a20 22616c6c ... 36316263 34220a7d }, error (null)
flutter: 13
flutter: 14
flutter: 4
flutter: Invalid argument(s) (path): Must not be null
flutter: 0
-[NSNull length]: unrecognized selector sent to instance 0x1dc5f0558
flutter: 3
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull length]: unrecognized selector sent to instance 0x1dc5f0558'
*** First throw call stack:
(0x181e8904c 0x19a4fdf54 0x181f66014 0x181e1e474 0x181e1d5b0 0x181e15410 0x181e0d0a0 0x100e3c4b8 0x100e3b324 0x100e3bb24 0x10065528c 0x181af9914 0x181afb660 0x181afe788 0x181b0cdd0 0x181b0d5f8 0x1f212a0b8 0x1f2129e94)
libc++abi: terminating with uncaught exception of type NSException
* thread #65, queue = 'com.apple.root.default-qos', stop reason = signal SIGABRT
frame #0: 0x00000001b8cd0964 libsystem_kernel.dylib`__pthread_kill + 8
libsystem_kernel.dylib`__pthread_kill:
-> 0x1b8cd0964 <+8>: b.lo 0x1b8cd0984 ; <+40>
0x1b8cd0968 <+12>: pacibsp
0x1b8cd096c <+16>: stp x29, x30, [sp, #-0x10]!
0x1b8cd0970 <+20>: mov x29, sp
Target 0: (Runner) stopped.
Lost connection to device.
Exited (sigterm)
Hope anyone can help
It seems you're not uploading the file to Cloud Storage, which only happens once you call putFile.
Have a look at the FlutterFire documentation on uploading files for an example of how to use putFile
In:
const jsdom = require("jsdom");
const initialVirtualConsole = jsdom.createVirtualConsole();
I get:
TypeError: jsdom.createVirtualConsole is not a function
at Query.<anonymous> (/my_jsdom_script.js:112:55)
at emitNone (events.js:72:20)
at Query.emit (events.js:166:7)
at Query.Sequence.end (/Users/xxx/Sites/node_modules/mysql/lib/protocol/sequences/Sequence.js:99:12)
at Query._handleFinalResultPacket (/Users/xxx/Sites/node_modules/mysql/lib/protocol/sequences/Query.js:144:8)
at Query.EofPacket (/Users/xxx/Sites/node_modules/mysql/lib/protocol/sequences/Query.js:128:8)
at Protocol._parsePacket (/Users/xxx/Sites/node_modules/mysql/lib/protocol/Protocol.js:280:23)
at Parser.write (/Users/xxx/Sites/node_modules/mysql/lib/protocol/Parser.js:73:12)
at Protocol.write (/Users/xxx/Sites/node_modules/mysql/lib/protocol/Protocol.js:39:16)
at Socket.<anonymous> (/Users/xxx/Sites/node_modules/mysql/lib/Connection.js:96:28)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at readableAddChunk (_stream_readable.js:146:16)
at Socket.Readable.push (_stream_readable.js:110:10)
at TCP.onread (net.js:523:20)
I would like to run the tests for jsdom on my local machine to see how jsdom performs in my local environment.
Could anyone be so good as to guide a noob in running the tests in https://github.com/tmpvar/jsdom/tree/master/test ?
Here's what's in my beforeEach() block (I'm using mocha over node.js to test)
import jsdom from 'jsdom'
const virtualConsole = jsdom.createVirtualConsole()
const document = jsdom.jsdom(undefined, {
virtualConsole: virtualConsole.sendTo(console)
})
virtualConsole.on('log', (...args) => {
// do something with `args` sent to logs
// e.g, assign result to a variable and run your assertions over it
})
window = document.defaultView
global.window = window
global.document = document
Check out the tests for further examples: https://github.com/tmpvar/jsdom/blob/master/test/jsdom/virtual-console.js
I realize that similar topics have been discussed, I have browsed through them all and tried to mimic solutions for about 4 hours but none of them seem to solve the problem. I would not have posted this with having exhausted any potential solution I could find.
I am trying to convert a large csv to JSON and then insert it into my Meteor collection following the conversion.
Here is my code using the Meteor.bindElement approach:
if Meteor.isServer
#Fiber = Meteor.npmRequire("fibers")
Meteor.startup ->
#Converter Class
if Data.find().count() is 0
Converter = Meteor.npmRequire('csvtojson').core.Converter
fs = Meteor.npmRequire('fs')
csvFileName = '/Path/To/My/File.csv'
fileStream = fs.createReadStream(csvFileName)
#new converter instance
csvConverter = new Converter(constructResult: true)
#end_parsed will be emitted once parsing finished
csvConverter.on "end_parsed", (jsonObj) ->
console.log jsonObj
boundFunction = Meteor.bindEnvironment(->
Data.insert jsonObj
return
, (e) ->
throw e
return
)
insertToDB boundFunction
#read from file
fileStream.pipe csvConverter
return
After parsing I am able to log the JSON just fine but when I try to add it to the collection like this:
csvConverter.on "end_parsed", (jsonObj) ->
console.log jsonObj
Data.insert jsonObj
I get the error:
throw new Error("Meteor code must always run within a Fiber. " +
W20141112-20:08:44.306(-8)? (STDERR) ^
W20141112-20:08:44.306(-8)? (STDERR) Error: Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor libraries with Meteor.bindEnvironment.
W20141112-20:08:44.306(-8)? (STDERR) at Object.Meteor._nodeCodeMustBeInFiber (packages/meteor/dynamics_nodejs.js:9)
W20141112-20:08:44.306(-8)? (STDERR) at _.extend.get (packages/meteor/dynamics_nodejs.js:21)
W20141112-20:08:44.306(-8)? (STDERR) at Object.DDP.randomStream (packages/ddp/random_stream.js:69)
W20141112-20:08:44.306(-8)? (STDERR) at self._makeNewID (packages/mongo/collection.js:72)
W20141112-20:08:44.306(-8)? (STDERR) at Mongo.Collection.(anonymous function) [as insert] (packages/mongo/collection.js:485)
W20141112-20:08:44.307(-8)? (STDERR) at csvAdv.<anonymous> (server/startup.coffee:16:13)
W20141112-20:08:44.307(-8)? (STDERR) at csvAdv.emit (events.js:95:17)
W20141112-20:08:44.307(-8)? (STDERR) at csvAdv.<anonymous> (/Users/samuel_chordas/CurrentClasses/CSCI477a/JPL/JataTwo/packages/npm-container/.build.npm-container/npm/node_modules/csvtojson/libs/core/init_onend.js:9:10)
W20141112-20:08:44.307(-8)? (STDERR) at csvAdv.emit (events.js:117:20)
W20141112-20:08:44.307(-8)? (STDERR) at _stream_readable.js:929:16
=> Exited with code: 8
Which I was able to get rid of by wrapping the function in a fiber with the following code but it DOES NOT write to my collection:
if Meteor.isServer
#Fiber = Meteor.npmRequire("fibers")
Meteor.startup ->
#Converter Class
if Data.find().count() is 0
Converter = Meteor.npmRequire('csvtojson').core.Converter
fs = Meteor.npmRequire('fs')
csvFileName = '/Path/To/My/File.csv'
fileStream = fs.createReadStream(csvFileName)
#new converter instance
csvConverter = new Converter(constructResult: true)
#end_parsed will be emitted once parsing finished
csvConverter.on "end_parsed", (jsonObj) ->
Fiber ->
Data.insert jsonObj
return
fileStream.pipe csvConverter
return
So I tried resorting to using the bindEnvironment as shown in the first block of code which results in the same "Error("Meteor code must always run within a Fiber" error.
Here is my collection in my /lib folder:
#Data = new Mongo.Collection 'data'
I am pretty new to Meteor Javascript and Coffescript so any feedback would be appreciated.
Also I would like to add that I can't get .run() to work on Fiber.
Try moving the definition of boundFunction outside of the end_parsed event handler.
boundFunction = Meteor.bindEnvironment((jsonObj) ->
Data.insert jsonObj
return
, (e) ->
throw e
)
csvConverter.on "end_parsed", (jsonObj) ->
console.log jsonObj
boundFunction jsonObj
return
I suspect the "Meteor code must always run within a Fiber." error is not coming from Data.insert but from Meteor.bindEnvironment itself. Meteor.bindEnvironment
is called from inside a "Meteor context"
takes a function
binds that function to the same "Meteor context" that bindEnvironment was called from
In your implementation, by the time you call bindEnvironment, the "Meteor context" has already been lost, so bindEnvironment can't do anything to help.
My code goes here (in coffeescript):
describe "Chat", ->
it "should contain 1 message after insert()", ->
collection = new Meteor.Collection(null)
collection.insert({username:'guest', message : 'hi'})
expect(collection.find({}).count()).not.toBe(0 )
When runs in Meteor, it complains:
Error: TypeError: Cannot read property '_docs' of undefined
at [object Object].LocalCollection.Cursor._getRawObjects (/Users/user/WebstormProjects/mud-craft/.meteor/local/build/programs/server/packages/minimongo.js:512:18)
at [object Object].LocalCollection.Cursor.count (/Users/user/WebstormProjects/mud-craft/.meteor/local/build/programs/server/packages/minimongo.js:260:15)
at Object.<anonymous> (/Users/user/WebstormProjects/mud-craft/tests/jasmine/server/unit/sample_server_test.coffee:6:5)
But it's ok in product code.