Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

eosjs-ecc version bump to include ripemdhash updates #589

Merged
merged 2 commits into from
Oct 4, 2019

Conversation

Trevor-Ultra
Copy link
Contributor

@Trevor-Ultra Trevor-Ultra commented Sep 24, 2019

Change Description

Fixes #576
eosjs-ecc just got a branch merged that fixes ripemd hashing when using the signature provider with applications such as electron. This patch resolves issues while using the signature provider; and bumps the version to 4.0.7 of eosjs-ecc.

This new version of eosjs-ecc includes changes from the last 4 months. The old version excludes these changes and uses a version of eosjs-ecc from a year ago.

API Changes

  • API Changes

Documentation Additions

  • Documentation Additions

@GreenBusDriver
Copy link
Contributor

@Trevor-Ultra Please update the eosjs package.json version so I can use this PR (and I'll merge it immediately), or I'll use the other PR I just created. I'd rather merge your contribution if you've got the time to make this change; I just need the eosjs package.json updated to 20.0.1

@Trevor-Ultra
Copy link
Contributor Author

@GreenBusDriver Ready to go. 👍

@GreenBusDriver GreenBusDriver merged commit a17e95e into EOSIO:master Oct 4, 2019
@lansehuiyi6
Copy link

lansehuiyi6 commented Nov 27, 2019

Change Description

Fixes #576
eosjs-ecc just got a branch merged that fixes ripemd hashing when using the signature provider with applications such as electron. This patch resolves issues while using the signature provider; and bumps the version to 4.0.7 of eosjs-ecc.

This new version of eosjs-ecc includes changes from the last 4 months. The old version excludes these changes and uses a version of eosjs-ecc from a year ago.

API Changes

  • API Changes

Documentation Additions

  • Documentation Additions

Hi, i used eosjs with the follow version with electron , ("eosjs": "^16.0.9", "eosjs-ecc": "^4.0.7",), and when i try to get the signData when i send the 'newaccount' action , a error "Digest method not supported" was throwed. What should i do, if the fix already been fixed as you mentioned in #576 "#589 Fixed the SignatureProvider issue that some people are finding. We've forked the eosio and eosjs-ecc library for the temporary fix. EOSJS just needs a version bump for eosjs-ecc and the problem should be resolved."
==========================Code======================
const Transaction = eos.fc.structs.transaction;
const buf = Fcbuffer.toBuffer(Transaction, transaction);
const chain_id_buf = new Buffer(chain_id, 'hex')
const sign_buf = Buffer.concat([chain_id_buf, buf, new Buffer(new Uint8Array(32))])
=========================Error=======================
Error: Digest method not supported in key_weight.key in authority.keys in newaccount.owner
ByteBufferNB(offset=55,markedOffset=-1,limit=102,capacity=102)

90 B1 CA 6C 1A 67 9D 46 A0 9A 6A 6C 1A 67 9D 46 ...l.g.F..jl.g.F
01 00 00 00 01 00 02 46 79 BC 19 5C DD 7C 28 93 .......Fy...|(.
5B C6 6A 69 AA 74 16 AE 16 8E 50 58 9B 7B 31 9C [.ji.t....PX.{1.
8D DD A6 14 85 7B 07<01 00 00 00 01 00 00 00 01 .....{..........
00 02 46 79 BC 19 5C DD 7C 28 93 5B C6 6A 69 AA ..Fy...|(.[.ji.
74 16 AE 16 8E 50 58 9B 7B 31 9C 8D DD A6 14 85 t....PX.{1......
7B 07 01 00 00 00> {.....

@lansehuiyi6
Copy link

@Trevor-Ultra Please update the eosjs package.json version so I can use this PR (and I'll merge it immediately), or I'll use the other PR I just created. I'd rather merge your contribution if you've got the time to make this change; I just need the eosjs package.json updated to 20.0.1

Hi, GreenBusDriver, could you also merge this fix for Digest method issue (update eosjs.ecc from 4.0.4 to 4.0.7) to v16.0.9, and also publish a npm package? Because V20.0 has lot's of difference from V16.0.9.

@lansehuiyi6
Copy link

I've found this is because of Fcbuffer.tobuffer will use the [email protected] which depend [email protected]. So if there's a version include the ecc update after v16.0.9, that will help a lot.

@tbfleming
Copy link
Contributor

16.x is obsolete; we do not update it ever.

@lansehuiyi6
Copy link

16.x is obsolete; we do not update it ever.

hi, tbfleming, is there's any example how to get rawTransaction with [email protected] offline like use Fcbuffer way with [email protected]?

@tbfleming
Copy link
Contributor

The transact method has several options to controll what it does.

@lansehuiyi6
Copy link

The transact method has several options to controll what it does.

yes, i just want to get the raw transaction with any node_url.

const signatureProvider = new JsSignatureProvider(privateKeys);
const rpc = new JsonRpc('', { fetch });
const api = new Api({ rpc, signatureProvider, textDecoder: new TextDecoder(), textEncoder: new TextEncoder() });

let transaction =
{ expiration: '2019-04-28T11:20:58',
ref_block_num: 26609,
ref_block_prefix: 934109041,
max_net_usage_words: 0,
max_cpu_usage_ms: 0,
delay_sec: 0,
context_free_actions: [],
actions: [{
account: 'eosio.token',
name: 'transfer',
authorization: [{
actor: 'aarontestnet',
permission: 'active',
}],
data: {
from: 'aarontestnet',
to: 'htlceostest1',
quantity: '0.0001 EOS',
memo: '',
},
}],
transaction_extensions: [] };
transaction = { ...transaction, actions: await api.serializeActions(transaction.actions) };
const serializedTransaction = api.serializeTransaction(transaction);

But what i got is the url is needed.

{ TypeError: fetching abi for eosio.token: Only absolute URLs are supported
at getNodeRequestOptions (/home/lizhan/wanglu/demo/js_shadow2/node_modules/node-fetch/lib/index.js:1299:9)
at /home/lizhan/wanglu/demo/js_shadow2/node_modules/node-fetch/lib/index.js:1404:19
at new Promise ()
at fetch (/home/lizhan/wanglu/demo/js_shadow2/node_modules/node-fetch/lib/index.js:1401:9)
at JsonRpc. (/home/lizhan/wanglu/demo/js_shadow2/node_modules/eosjs/dist/eosjs-jsonrpc.js:99:46)
at step (/home/lizhan/wanglu/demo/js_shadow2/node_modules/eosjs/dist/eosjs-jsonrpc.js:36:23)
at Object.next (/home/lizhan/wanglu/demo/js_shadow2/node_modules/eosjs/dist/eosjs-jsonrpc.js:17:53)
at /home/lizhan/wanglu/demo/js_shadow2/node_modules/eosjs/dist/eosjs-jsonrpc.js:11:71
at new Promise ()
at __awaiter (/home/lizhan/wanglu/demo/js_shadow2/node_modules/eosjs/dist/eosjs-jsonrpc.js:7:12) isFetchError: true }

@tbfleming
Copy link
Contributor

eosjs 20 needs to fetch abis from a node to know how to serialize actions.

@lansehuiyi6
Copy link

lansehuiyi6 commented Nov 28, 2019

eosjs 20 needs to fetch abis from a node to know how to serialize actions.

yes, so could you help to tell me how to provided a fetch which contain the abi ?
Is there any examble?

I just saw the code below at eosjs-api.test.ts, but what if i only have the abi json, and how to write it in js?

    const fetch = async (input: any, init: any): Promise<any> => ({
        ok: true,
        json: async () => {
            if (input === '/v1/chain/get_raw_code_and_abi') {
                return {
                    account_name: 'testeostoken',
                    abi: "DmVvc2lvOjphYmkvMS4wAQxhY2NvdW50X25hbWUEbmFtZQUIdHJhbnNmZXIABARmcm9tDGFjY291bnRfbmFtZQJ0bwxhY2NvdW50X25hbWUIcXVhbnRpdHkFYXNzZXQEbWVtbwZzdHJpbmcGY3JlYXRlAAIGaXNzdWVyDGFjY291bnRfbmFtZQ5tYXhpbXVtX3N1cHBseQVhc3NldAVpc3N1ZQADAnRvDGFjY291bnRfbmFtZQhxdWFudGl0eQVhc3NldARtZW1vBnN0cmluZwdhY2NvdW50AAEHYmFsYW5jZQVhc3NldA5jdXJyZW5jeV9zdGF0cwADBnN1cHBseQVhc3NldAptYXhfc3VwcGx5BWFzc2V0Bmlzc3VlcgxhY2NvdW50X25hbWUDAAAAVy08zc0IdHJhbnNmZXLnBSMjIFRyYW5zZmVyIFRlcm1zICYgQ29uZGl0aW9ucwoKSSwge3tmcm9tfX0sIGNlcnRpZnkgdGhlIGZvbGxvd2luZyB0byBiZSB0cnVlIHRvIHRoZSBiZXN0IG9mIG15IGtub3dsZWRnZToKCjEuIEkgY2VydGlmeSB0aGF0IHt7cXVhbnRpdHl9fSBpcyBub3QgdGhlIHByb2NlZWRzIG9mIGZyYXVkdWxlbnQgb3IgdmlvbGVudCBhY3Rpdml0aWVzLgoyLiBJIGNlcnRpZnkgdGhhdCwgdG8gdGhlIGJlc3Qgb2YgbXkga25vd2xlZGdlLCB7e3RvfX0gaXMgbm90IHN1cHBvcnRpbmcgaW5pdGlhdGlvbiBvZiB2aW9sZW5jZSBhZ2FpbnN0IG90aGVycy4KMy4gSSBoYXZlIGRpc2Nsb3NlZCBhbnkgY29udHJhY3R1YWwgdGVybXMgJiBjb25kaXRpb25zIHdpdGggcmVzcGVjdCB0byB7e3F1YW50aXR5fX0gdG8ge3t0b319LgoKSSB1bmRlcnN0YW5kIHRoYXQgZnVuZHMgdHJhbnNmZXJzIGFyZSBub3QgcmV2ZXJzaWJsZSBhZnRlciB0aGUge3t0cmFuc2FjdGlvbi5kZWxheX19IHNlY29uZHMgb3Igb3RoZXIgZGVsYXkgYXMgY29uZmlndXJlZCBieSB7e2Zyb219fSdzIHBlcm1pc3Npb25zLgoKSWYgdGhpcyBhY3Rpb24gZmFpbHMgdG8gYmUgaXJyZXZlcnNpYmx5IGNvbmZpcm1lZCBhZnRlciByZWNlaXZpbmcgZ29vZHMgb3Igc2VydmljZXMgZnJvbSAne3t0b319JywgSSBhZ3JlZSB0byBlaXRoZXIgcmV0dXJuIHRoZSBnb29kcyBvciBzZXJ2aWNlcyBvciByZXNlbmQge3txdWFudGl0eX19IGluIGEgdGltZWx5IG1hbm5lci4KAAAAAAClMXYFaXNzdWUAAAAAAKhs1EUGY3JlYXRlAAIAAAA4T00RMgNpNjQBCGN1cnJlbmN5AQZ1aW50NjQHYWNjb3VudAAAAAAAkE3GA2k2NAEIY3VycmVuY3kBBnVpbnQ2NA5jdXJyZW5jeV9zdGF0cwAAAA===", // tslint:disable-line
                };
            }

            return transaction;
        },
    });

    beforeEach(() => {
        const rpc = new JsonRpc('', { fetch });
        const signatureProvider = new JsSignatureProvider(['5JtUScZK2XEp3g9gh7F8bwtPTRAkASmNrrftmx4AxDKD5K4zDnr']);
        const chainId = '038f4b0fc8ff18a4f0842a8f0564611f6e96e8535901dd45e43ac8691a1c4dca';
        api = new Api({
            rpc, signatureProvider, chainId, textDecoder: new TextDecoder(), textEncoder: new TextEncoder(),
        });
    });

@tbfleming
Copy link
Contributor

These questions aren't about the original issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error: Digest method not supported
4 participants