Comments (8)
@BMillman19
While using version 2.0.8
on React Native
project, we encounter similar issues.
Besides the same issue of isomorphic-fetch
.
In ./utils/lib/src/abi_encoder/emv_data_type_factory.js
'use strict'
var __extends =
(this && this.__extends) ||
(function () {
var extendStatics = function (d, b) {
extendStatics =
Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && // <- this line will throw error
function (d, b) {
d.__proto__ = b
}) ||
function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]
}
return extendStatics(d, b)
}
return function (d, b) {
extendStatics(d, b)
function __ () {
this.constructor = d
}
d.prototype =
b === null ? Object.create(b) : ((__.prototype = b.prototype), new __())
}
})()
...
In ./node_modules/chalk/index.js
(this seems to be a dependency module)
'use strict';
const escapeStringRegexp = require('escape-string-regexp');
const ansiStyles = require('ansi-styles');
const stdoutColor = require('supports-color').stdout;
const template = require('./templates.js');
const isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm');
// `supportsColor.level` → `ansiStyles.color[name]` mapping
const levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m'];
// `color-convert` models to exclude from the Chalk API due to conflicts and such
const skipModels = new Set(['gray']);
// Object = global;
const styles = Object.create(null);
function applyOptions(obj, options) {
options = options || {};
// Detect level if not set manually
const scLevel = stdoutColor ? stdoutColor.level : 0;
obj.level = options.level === undefined ? scLevel : options.level;
obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;
}
function Chalk(options) {
// We check for this.template here since calling `chalk.constructor()`
// by itself will have a `this` of a previously constructed chalk object
if (!this || !(this instanceof Chalk) || this.template) {
const chalk = {};
applyOptions(chalk, options);
chalk.template = function () {
const args = [].slice.call(arguments);
return chalkTag.apply(null, [chalk.template].concat(args));
};
Object.setPrototypeOf(chalk, Chalk.prototype); // this line throws error
Object.setPrototypeOf(chalk.template, chalk);
chalk.template.constructor = Chalk;
return chalk.template;
}
applyOptions(this, options);
}
...
Work Around (Hack)
The two error cases above seems to be the same problem.
Caused by Object.setPrototypeOf
doesn’t work on JSC on Android.
For now we add polyfill to these places.
Here's the polyfill we use
Object.setPrototypeOf = Object.setPrototypeOf || function (obj, proto) {
obj.__proto__ = proto
return obj
}
'use strict'
var __extends =
(this && this.__extends) ||
(function () {
var extendStatics = function (d, b) {
// Apply polyfill here
Object.setPrototypeOf = Object.setPrototypeOf || function (obj, proto) {
obj.__proto__ = proto
return obj
}
extendStatics =
Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array &&
function (d, b) {
d.__proto__ = b
}) ||
function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]
}
return extendStatics(d, b)
}
return function (d, b) {
extendStatics(d, b)
function __ () {
this.constructor = d
}
d.prototype =
b === null ? Object.create(b) : ((__.prototype = b.prototype), new __())
}
})()
...
'use strict';
const escapeStringRegexp = require('escape-string-regexp');
const ansiStyles = require('ansi-styles');
const stdoutColor = require('supports-color').stdout;
const template = require('./templates.js');
const isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm');
// `supportsColor.level` → `ansiStyles.color[name]` mapping
const levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m'];
// `color-convert` models to exclude from the Chalk API due to conflicts and such
const skipModels = new Set(['gray']);
// Object = global;
const styles = Object.create(null);
function applyOptions(obj, options) {
options = options || {};
// Detect level if not set manually
const scLevel = stdoutColor ? stdoutColor.level : 0;
obj.level = options.level === undefined ? scLevel : options.level;
obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;
}
function Chalk(options) {
// We check for this.template here since calling `chalk.constructor()`
// by itself will have a `this` of a previously constructed chalk object
if (!this || !(this instanceof Chalk) || this.template) {
const chalk = {};
applyOptions(chalk, options);
chalk.template = function () {
const args = [].slice.call(arguments);
return chalkTag.apply(null, [chalk.template].concat(args));
};
// Apply polyfill here
Object.setPrototypeOf = Object.setPrototypeOf || function (obj, proto) { error
obj.__proto__ = proto
return obj
}
Object.setPrototypeOf(chalk, Chalk.prototype);
Object.setPrototypeOf(chalk.template, chalk);
chalk.template.constructor = Chalk;
return chalk.template;
}
applyOptions(this, options);
}
...
Discussion
The hacking work around doesn't seems to be a good solution.
@BMillman19 Is there any suggestions ?
I'm willing to help, contribute the react-native
support.
from 0x-monorepo.
Actually it turns out that it may have been related to my simulator not being in debug mode.
This is due to the different run time that React Native is using.
In debug mode, React Native is running on Chrome which uses V8.
While running on physical device , React Native uses JSC(JavaScriptCore).
from 0x-monorepo.
This is also causing an issue for me!
from 0x-monorepo.
Hm, what replacement library would you recommend we use such that it works in browsers, node and react-native contexts?
from 0x-monorepo.
@fabioberger Actually it turns out that it may have been related to my simulator not being in debug mode. If the issue pops up again I'll do some more diligence. Really is one of the strangest bugs I've ever encountered in React Native.
Thank you for the quick response, though!
from 0x-monorepo.
@kylanhurt is connect working for you in react native?
from 0x-monorepo.
@BMillman19 It's working. The isometric fetch issue is a nagging issue for many React Native projects (including outside of 0x-related stuff).
I hope people find this issue so that they can see if my solution fixes it for them.
from 0x-monorepo.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
from 0x-monorepo.
Related Issues (20)
- sol-compiler: build fails behind proxy since #1596 HOT 2
- sol-tracing-utils: consider changing the solidity parser HOT 1
- sol-compiler: fails on file with structs only HOT 2
- @0x/utils: Extra space in `provider.send` varies HOT 4
- @0x/contract-wrappers: `marketBuyOrdersFillOrKill` incorrect ABI encoding HOT 2
- [sol-compiler] New release of sol-compiler?
- Buy Contract - Call fails after payment token approval
- @0x/sol-compiler bug: sol-compiler not recognizing pragma experimental 0.5.0 HOT 2
- @0x/staking wrong dependency HOT 2
- sol-compiler does not recognize solc versions after 0.5.12 HOT 1
- Using sol-trace with external, existing contracts as interfaces HOT 3
- command for new package? HOT 2
- Instant revamp bake-off HOT 23
- 0x-contract-wrappers & 0x/abi-gen: TypeError: Cannot instantiate typing.Union HOT 2
- sol-compiler update link for solc binary downloads HOT 2
- Issues with installing project dependencies on MacOS Catalina HOT 3
- asset-swapper: CryptoCom is missing from market operation types HOT 2
- [abi-gen] [base-contract] Crypto algorithms blocking javascript main thread HOT 2
- [sol-compiler] AST is not present in the output when requested HOT 2
- python: getting signature using private key HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from 0x-monorepo.