Giter Site home page Giter Site logo

Comments (9)

krpeacock avatar krpeacock commented on May 7, 2024 2

Would adding big-integer as a peerDependency and adding that bigint logic to our output be a good idea or a bad one?

from fx-fotos.

emadbaqeri avatar emadbaqeri commented on May 7, 2024 1

indeed. I have an error while starting UI in the browser:
image

I suspect that the reason might be in the platform: I am using windows.

@Roman-Uholnikov Hey there, yes maybe it's because of your OS which is windows. I have setted up the project as ehsan said and it's working properly on my machine which I'm using arch linux

from fx-fotos.

emadbaqeri avatar emadbaqeri commented on May 7, 2024

@ehsan6sha Hey, thank you I have configured my IDE and replaced project files as you said now I can work on the issues.

from fx-fotos.

ehsan6sha avatar ehsan6sha commented on May 7, 2024

For anyone who has the same issue in Dfinity, this is the whole process that worked for me:
(open file temp/instructions.txt)

photos/temp at main ยท functionland/photos (github.com)

To explain here is the changes I made:

1- Added BigInt defenition to the below files by adding this line to the top of each file:

if (typeof BigInt === 'undefined') global.BigInt = require('big-integer')
  • ...\node_modules@dfinity\agent\lib\cjs\agent\http\transforms.js
  • ...\node_modules@dfinity\authentication\lib\cjs\index.js

2- Added Buffer definition to the below files by adding this line to the top of each file:

global.Buffer = global.Buffer || require('buffer').Buffer;
  • ...\node_modules@dfinity\principal\lib\cjs\index.js

3- Added a localStorage definition to the below file by adding this line to the top of each file: (however it seems we can simmply pass it as a parameter in authClient.create)

if (!global.localStorage) {
  global.localStorage = {
    _data       : {},
    setItem     : function(id, val) { return this._data[id] = String(val); },
    getItem     : function(id) { return this._data.hasOwnProperty(id) ? this._data[id] : undefined; },
    removeItem  : function(id) { return delete this._data[id]; },
    clear       : function() { return this._data = {}; }
  };
}
  • ...\node_modules@dfinity\auth-client\lib\cjs\index.js

4- Added window defintion by modifying the below files by adding the below parts of codes:

  • Modified AuthClientCreateOptions defenition to:
export interface AuthClientCreateOptions {
    /**
     * An identity to use as the base
     */
    identity?: SignIdentity;
    /**
     * Optional storage with get, set, and remove. Uses LocalStorage by default
     */
    storage?: AuthClientStorage;
	/**
     * Optional window object with open, addEventListener, removeEventListener, history.pushState, location.href. Uses window by default
     */
    windowObj?: any;
}

in file '...\node_modules@dfinity\auth-client\lib\cjs\index.d.ts'

  • Modified create function defenition to:
static async create(options = {}) {
        var _a;
        const storage = (_a = options.storage) !== null && _a !== void 0 ? _a : new LocalStorage('ic-');
		const windowObj = (_a = options.windowObj) !== null && _a !== void 0 ? _a : window;
        let key = null;
        if (options.identity) {
            key = options.identity;
        }
        else {
            const maybeIdentityStorage = await storage.get(KEY_LOCALSTORAGE_KEY);
            if (maybeIdentityStorage) {
                try {
                    key = identity_1.Ed25519KeyIdentity.fromJSON(maybeIdentityStorage);
                }
                catch (e) {
                    // Ignore this, this means that the localStorage value isn't a valid Ed25519KeyIdentity
                    // serialization.
                }
            }
        }
        let identity = new agent_1.AnonymousIdentity();
        let chain = null;
        if (key) {
            try {
                const chainStorage = await storage.get(KEY_LOCALSTORAGE_DELEGATION);
                if (chainStorage) {
                    chain = identity_1.DelegationChain.fromJSON(chainStorage);
                    // Verify that the delegation isn't expired.
                    if (!authentication_1.isDelegationValid(chain)) {
                        await _deleteStorage(storage);
                        key = null;
                    }
                    else {
                        identity = identity_1.DelegationIdentity.fromDelegation(key, chain);
                    }
                }
            }
            catch (e) {
                console.error(e);
                // If there was a problem loading the chain, delete the key.
                await _deleteStorage(storage);
                key = null;
            }
        }
        return new this(identity, key, chain, storage, windowObj);
    }

in file '...\node_modules@dfinity\auth-client\lib\cjs\index.js'

5- Added the following imports to my file where I wanted to use Dfinity libraries

import 'text-encoding';
import 'react-native-get-random-values'

6- Installed 'react-native-polyfill-globals' to include 'readAsArrayBuffer' for react-native.

7- Changed one occurance of BigInt equality check from normal '===' in @dfinity\candid\lib\cjs\utils\leb128.js to the below:

if (BigInt(0).equals(value)) {

from fx-fotos.

ehsan6sha avatar ehsan6sha commented on May 7, 2024

Would adding big-integer as a peerDependency and adding that bigint logic to our output be a good idea or a bad one?

Do you mean instead of adding it to dfinity files directly, leave them unchanged and instead adding it to the main file? I actually tried that approach and was still getting the same error until I added it directly to the top of dfinity files. I hope i wasn't doing it the wrong way but I tried multiple times

from fx-fotos.

ehsan6sha avatar ehsan6sha commented on May 7, 2024

@Roman-Uholnikov Keyvan said you have an issue after installation, did you try this?

from fx-fotos.

Roman-Uholnikov avatar Roman-Uholnikov commented on May 7, 2024

indeed. I have an error while starting UI in the browser:
image

I suspect that the reason might be in the platform: I am using windows.

from fx-fotos.

ehsan6sha avatar ehsan6sha commented on May 7, 2024

indeed. I have an error while starting UI in the browser:
image
I suspect that the reason might be in the platform: I am using windows.

@Roman-Uholnikov Hey there, yes maybe it's because of your OS which is windows. I have setted up the project as ehsan said and it's working properly on my machine which I'm using arch linux

I just tested on Windows too and is working fine so should not be OS. That's the beauty of expo lol
I am not sure why "browser" is here though. Maybe that is the keyword to issue

from fx-fotos.

ehsan6sha avatar ehsan6sha commented on May 7, 2024

This is patched and will be applied automatically. Fixed in
#63

from fx-fotos.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.