Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(crypto): remove long dependency #3502

Merged
merged 7 commits into from Feb 17, 2020
Merged

refactor(crypto): remove long dependency #3502

merged 7 commits into from Feb 17, 2020

Conversation

@faustbrian
Copy link
Collaborator

faustbrian commented Feb 14, 2020

The long@3 dependency can cause problems if people also have long@4 installed because node.js will think it should use long@4 even though we don't have it as a dependency. This will cause the value instanceof Long check in the bytebuffer dependency to fail because its own dependency is long@3 but node.js will force it to use long@4 if it is installed, which will throw an exception because the instance signatures will differ.

The bytebuffer types have been removed because they don't reflect their JavaScript code. The types state that you can only pass in a number or Long but their code will actually perform assertions and use Long internally to create an instance. This means that whatever long version is installed will be used.

ByteBufferPrototype.writeUint64 = function(value, offset) {
    var relative = typeof offset === 'undefined';
    if (relative) offset = this.offset;
    if (!this.noAssert) {
        if (typeof value === 'number')
            value = Long.fromNumber(value);
        else if (typeof value === 'string')
            value = Long.fromString(value);
        else if (!(value && value instanceof Long))
            throw TypeError("Illegal value: "+value+" (not an integer or Long)");
        if (typeof offset !== 'number' || offset % 1 !== 0)
            throw TypeError("Illegal offset: "+offset+" (not an integer)");
        offset >>>= 0;
        if (offset < 0 || offset + 0 > this.buffer.length)
            throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.length);
    }
    if (typeof value === 'number')
        value = Long.fromNumber(value);
    else if (typeof value === 'string')
        value = Long.fromString(value);
faustbrian added 4 commits Feb 14, 2020
wip
wip
wip
@codecov

This comment has been minimized.

Copy link

codecov bot commented Feb 14, 2020

Codecov Report

Merging #3502 into 2.6 will increase coverage by <.01%.
The diff coverage is 88.88%.

Impacted file tree graph

@@            Coverage Diff             @@
##              2.6    #3502      +/-   ##
==========================================
+ Coverage   66.13%   66.14%   +<.01%     
==========================================
  Files         439      439              
  Lines       12460    12464       +4     
  Branches     1711     1711              
==========================================
+ Hits         8241     8244       +3     
- Misses       4185     4186       +1     
  Partials       34       34
Impacted Files Coverage Δ
packages/crypto/src/transactions/types/schemas.ts 100% <100%> (ø) ⬆️
packages/crypto/src/transactions/registry.ts 71.05% <100%> (+0.78%) ⬆️
.../core-transactions/src/handlers/multi-signature.ts 68.62% <80%> (ø) ⬆️
packages/core-transaction-pool/src/storage.ts 97.5% <0%> (-2.5%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8c9b225...e543457. Read the comment docs.

faustbrian added 2 commits Feb 14, 2020
wip
@faustbrian faustbrian merged commit bf16abd into 2.6 Feb 17, 2020
24 checks passed
24 checks passed
crypto (12.x)
Details
bridgechain-registration (12.x)
Details
unit (12.x)
Details
bridgechain-resignation (12.x)
Details
integration (12.x)
Details
bridgechain-update (12.x)
Details
e2e (12.x)
Details
business-registration (12.x)
Details
business-resignation (12.x)
Details
business-update (12.x)
Details
delegate-registration (12.x)
Details
delegate-resignation (12.x)
Details
htlc-claim (12.x)
Details
htlc-lock (12.x)
Details
htlc-refund (12.x)
Details
ipfs (12.x)
Details
multi-payment (12.x)
Details
multi-signature-registration (12.x)
Details
second-signature-registration (12.x)
Details
transfer (12.x)
Details
vote (12.x)
Details
LGTM analysis: JavaScript No new or fixed alerts
Details
codecov/patch 88.88% of diff hit (target 66.13%)
Details
codecov/project 66.14% (+<.01%) compared to 8c9b225
Details
@ArkEcosystemBot ArkEcosystemBot deleted the longs branch Feb 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.