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

Commit 9f52fdb

Browse files
Merge branch 'release/21.0.x' into docs/21.0.0
2 parents 868e7e6 + 1fc00de commit 9f52fdb

14 files changed

+2675
-2189
lines changed

.travis.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ env:
44
sudo: false
55
language: node_js
66
node_js:
7-
- '10.0.0'
7+
- '12.14.1'
88
before_install:
9-
- npm i -g npm@6.4.1
9+
- npm i -g npm@6.13.6
1010
- yarn global add typescript
11-
- yarn global add webpack
11+
- yarn global add webpack
1212
before_script:
1313
- source ./scripts/is_latest.sh
1414
script:
@@ -17,9 +17,9 @@ script:
1717
deploy:
1818
- provider: script
1919
skip_cleanup: true
20-
script:
20+
script:
2121
- ./scripts/publish-edge.sh
22-
on:
22+
on:
2323
branch: develop
2424
notifications:
2525
webhooks:

IMPORTANT.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Important Notice
2+
3+
We (block.one and its affiliates) make available EOSIO and other software, updates, patches and documentation (collectively, Software) on a voluntary basis as a member of the EOSIO community. A condition of you accessing any Software, websites, articles, media, publications, documents or other material (collectively, Material) is your acceptance of the terms of this important notice.
4+
5+
## Software
6+
We are not responsible for ensuring the overall performance of Software or any related applications. Any test results or performance figures are indicative and will not reflect performance under all conditions. Software may contain components that are open sourced and subject to their own licenses; you are responsible for ensuring your compliance with those licenses.
7+
8+
We make no representation, warranty, guarantee or undertaking in respect of Software, whether expressed or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall we be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the Software or the use or other dealings in the Software.
9+
10+
Wallets and related components are complex software that require the highest levels of security. If incorrectly built or used, they may compromise users’ private keys and digital assets. Wallet applications and related components should undergo thorough security evaluations before being used. Only experienced developers should work with such Software.
11+
12+
Material is not made available to any person or entity that is the subject of sanctions administered or enforced by any country or government or otherwise designated on any list of prohibited or restricted parties (including but not limited to the lists maintained by the United Nations Security Council, the U.S. Government, the European Union or its Member States, or other applicable government authority) or organized or resident in a country or territory that is the subject of country-wide or territory-wide sanctions. You represent and warrant that neither you nor any party having a direct or indirect beneficial interest in you or on whose behalf you are acting as agent or nominee is such a person or entity and you will comply with all applicable import, re-import, sanctions, anti-boycott, export, and re-export control laws and regulations. If this is not accurate or you do not agree, then you must immediately cease accessing our Material and delete all copies of Software.
13+
14+
Any person using or offering Software in connection with providing software, goods or services to third parties shall advise such third parties of this important notice, including all limitations, restrictions and exclusions of liability.
15+
16+
## Trademarks
17+
Block.one, EOSIO, EOS, the heptahedron and associated logos and related marks are our trademarks. Other trademarks referenced in Material are the property of their respective owners.
18+
19+
## Third parties
20+
Any reference in Material to any third party or third-party product, resource or service is not an endorsement or recommendation by Block.one. We are not responsible for, and disclaim any and all responsibility and liability for, your use of or reliance on any of these resources. Third-party resources may be updated, changed or terminated at any time, so information in Material may be out of date or inaccurate.
21+
22+
## Forward-looking statements
23+
Please note that in making statements expressing Block.one’s vision, we do not guarantee anything, and all aspects of our vision are subject to change at any time and in all respects at Block.one’s sole discretion, with or without notice. We call these “forward-looking statements”, which includes statements on our website and in other Material, other than statements of historical facts, such as statements regarding EOSIO’s development, expected performance, and future features, or our business strategy, plans, prospects, developments and objectives. These statements are only predictions and reflect Block.one’s current beliefs and expectations with respect to future events; they are based on assumptions and are subject to risk, uncertainties and change at any time.
24+
25+
We operate in a rapidly changing environment and new risks emerge from time to time. Given these risks and uncertainties, you are cautioned not to rely on these forward-looking statements. Actual results, performance or events may differ materially from what is predicted in the forward-looking statements. Some of the factors that could cause actual results, performance or events to differ materially from the forward-looking statements include, without limitation: technical feasibility and barriers; market trends and volatility; continued availability of capital, financing and personnel; product acceptance; the commercial success of any new products or technologies; competition; government regulation and laws; and general economic, market or business conditions.
26+
27+
All statements are valid only as of the date of first posting and Block.one is under no obligation to, and expressly disclaims any obligation to, update or alter any statements, whether as a result of new information, subsequent events or otherwise. Nothing in any Material constitutes technological, financial, investment, legal or other advice, either in general or with regard to any particular situation or implementation. Please consult with experts in appropriate areas before implementing or utilizing anything contained in Material.

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ const { Api, JsonRpc, RpcError } = require('eosjs');
5252
const { JsSignatureProvider } = require('eosjs/dist/eosjs-jssig'); // development only
5353
const fetch = require('node-fetch'); // node only; not needed in browsers
5454
const { TextEncoder, TextDecoder } = require('util'); // node only; native TextEncoder/Decoder
55-
const { TextEncoder, TextDecoder } = require('text-encoding'); // React Native, IE11, and Edge Browsers only
5655
```
5756

5857
## Basic Usage
@@ -77,7 +76,7 @@ const rpc = new JsonRpc('http://127.0.0.1:8888', { fetch });
7776

7877
### API
7978

80-
Include textDecoder and textEncoder when using in Node, React Native, IE11 or Edge Browsers.
79+
Include textDecoder and textEncoder when using in Node. You may exclude these when running in a browser since most modern browsers now natively support these. If your browser does not support these (https://caniuse.com/#feat=textencoder), then you can import them as a dependency through the following deprecated npm package: https://www.npmjs.com/package/text-encoding
8180
```js
8281
const api = new Api({ rpc, signatureProvider, textDecoder: new TextDecoder(), textEncoder: new TextEncoder() });
8382
```
@@ -139,6 +138,6 @@ try {
139138
140139
## Important
141140
142-
See LICENSE for copyright and license terms. Block.one makes its contribution on a voluntary basis as a member of the EOSIO community and is not responsible for ensuring the overall performance of the software or any related applications. We make no representation, warranty, guarantee or undertaking in respect of the software or any related documentation, whether expressed or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall we be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or documentation or the use or other dealings in the software or documentation. Any test results or performance figures are indicative and will not reflect performance under all conditions. Any reference to any third party or third-party product, service or other resource is not an endorsement or recommendation by Block.one. We are not responsible, and disclaim any and all responsibility and liability, for your use of or reliance on any of these resources. Third-party resources may be updated, changed or terminated at any time, so the information here may be out of date or inaccurate. Any person using or offering this software in connection with providing software, goods or services to third parties shall advise such third parties of these license terms, disclaimers and exclusions of liability. Block.one, EOSIO, EOSIO Labs, EOS, the heptahedron and associated logos are trademarks of Block.one.
141+
See [LICENSE](./LICENSE) for copyright and license terms.
143142
144-
Wallets and related components are complex software that require the highest levels of security. If incorrectly built or used, they may compromise users’ private keys and digital assets. Wallet applications and related components should undergo thorough security evaluations before being used. Only experienced developers should work with this software.
143+
All repositories and other materials are provided subject to the terms of this [IMPORTANT](./IMPORTANT.md) notice and you must familiarize yourself with its terms. The notice contains important information, limitations and restrictions relating to our software, publications, trademarks, third-party resources, and forward-looking statements. By accessing any of our repositories and other materials, you accept and agree to the terms of the notice.

docs/basic-usage/00_browser.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ To use `eosjs` in a browser run `npm run build-web` or `yarn build-web`. This w
22
```html
33
<pre style="width: 100%; height: 100%; margin:0px; "></pre>
44

5-
<script src='dist-web/eosjs-api.js'></script>
6-
<script src='dist-web/eosjs-jsonrpc.js'></script>
7-
<script src='dist-web/eosjs-jssig.js'></script>
5+
<script src='dist-web/eosjs-api.min.js'></script>
6+
<script src='dist-web/eosjs-jsonrpc.min.js'></script>
7+
<script src='dist-web/eosjs-jssig.min.js'></script>
88
```
99

1010
To cache ABIs and reduce network usage, reuse the `api` object for all transactions. This implies you should only call `new eosjs_api.Api(...)` once.
@@ -48,7 +48,7 @@ To cache ABIs and reduce network usage, reuse the `api` object for all transacti
4848
```
4949

5050
## Debugging
51-
If you would like readable source files for debugging, change the file reference to the `-debug.js` files inside `dist-web/debug` directory. These files should only be used for development as they are over 10 times as large as the minified versions, and importing the debug versions will increase loading times for the end user.
51+
If you would like readable source files for debugging, change the file reference to the `.js` files inside `dist-web` directory. These files should only be used for development as they are over 10 times as large as the minified versions, and importing the debug versions will increase loading times for the end user.
5252

5353
## IE11 and Edge Support
5454
If you need to support IE11 or Edge you will also need to install a text-encoding polyfill, as eosjs Signing is dependent on the TextEncoder which IE11 and Edge do not provide. Pass the TextEncoder and TextDecoder to the API constructor as demonstrated in the [CommonJS example](01_commonjs.md). Refer to the documentation [here](https://github.com/inexorabletash/text-encoding) to determine the best way to include it in your project.

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ content_title: eosjs
55
`eosjs` is a Javascript library which provides an API for integrating with EOSIO-based blockchains using the [EOSIO Nodeos RPC API](https://developers.eos.io/eosio-nodeos/reference). The documentation for `eosjs` is structured in the following way:
66

77
* [Installation](02_installation.md) explains how to install `eosjs` using `npm` or `yarn`.
8-
* [Basic Usage](basic-usage/) provides information related to importing `eosjs` in various Javascript environments. The [basic-usage](basic-usage/03_basic-usage.md) document specifically provides brief explanations of the components provided by `eosjs` as well as their typical use cases.
8+
* [Basic Usage](basic-usage/) provides information related to importing `eosjs` in various Javascript environments. The [basic-usage](basic-usage/index.md) document specifically provides brief explanations of the components provided by `eosjs` as well as their typical use cases.
99
* [FAQ](faq/) provides answers to frequently asked questions surrounding the `eosjs` software.
1010
* [How-To Guides](how-to-guides/) provides how-tos on everything from getting block information to proposing and signing multi-sig transactions.
1111
* [Troubleshooting](troubleshooting/) provides possible exceptions encountered when developing with `eosjs` and their most common causes.

package.json

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,26 @@
2525
"url": "https://github.com/EOSIO/eosjs.git"
2626
},
2727
"dependencies": {
28+
"@babel/runtime": "7.8.3",
2829
"@types/elliptic": "6.4.10",
29-
"babel-runtime": "6.26.0",
30-
"elliptic": "6.5.0",
31-
"text-encoding": "0.7.0"
30+
"elliptic": "6.5.2"
3231
},
3332
"devDependencies": {
33+
"@babel/core": "7.8.3",
34+
"@babel/plugin-transform-runtime": "7.8.3",
35+
"@babel/preset-env": "7.8.3",
36+
"@babel/preset-stage-1": "7.8.3",
3437
"@blockone/tslint-config-blockone": "3.0.0",
35-
"@types/jest": "24.0.6",
38+
"@types/jest": "24.9.1",
3639
"@types/node": "11.9.4",
37-
"@types/text-encoding": "0.0.35",
38-
"babel-plugin-transform-runtime": "6.23.0",
39-
"babel-preset-env": "1.7.0",
40-
"babel-preset-stage-1": "6.24.1",
41-
"cypress": "3.1.5",
40+
"cypress": "3.8.2",
4241
"eosjs-ecc": "^4.0.7",
43-
"jest": "23.6.0",
42+
"jest": "25.1.0",
4443
"jest-fetch-mock": "2.1.1",
4544
"json-loader": "0.5.7",
4645
"mocha": "5.2.0",
4746
"mochawesome": "4.1.0",
48-
"ts-jest": "24.0.0",
47+
"ts-jest": "25.0.0",
4948
"ts-loader": "5.3.3",
5049
"tslint": "5.12.1",
5150
"tslint-eslint-rules": "5.4.0",
@@ -55,10 +54,6 @@
5554
"typedoc": "^0.16.9",
5655
"typedoc-plugin-external-module-name": "^3.0.0"
5756
},
58-
"resolutions": {
59-
"braces": "^2.3.1",
60-
"lodash": "^4.17.12"
61-
},
6257
"jest": {
6358
"automock": false,
6459
"setupFiles": [

src/Signature.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ export class Signature {
2424

2525
/** Instantiate Signature from an `elliptic`-format Signature */
2626
public static fromElliptic(ellipticSig: EC.Signature, keyType: KeyType, ec?: EC): Signature {
27-
const r = ellipticSig.r.toArray();
28-
const s = ellipticSig.s.toArray();
27+
const r = ellipticSig.r.toArray('be', 32);
28+
const s = ellipticSig.s.toArray('be', 32);
2929
let eosioRecoveryParam;
3030
if (keyType === KeyType.k1) {
3131
eosioRecoveryParam = ellipticSig.recoveryParam + 27;

src/eosjs-serialize.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,9 @@ export class SerialBuffer { // tslint:disable-line max-classes-per-file
419419

420420
/** Append a `symbol` */
421421
public pushSymbol({ name, precision }: { name: string, precision: number }) {
422+
if (!/^[A-Z]{1,7}$/.test(name)) {
423+
throw new Error('Expected symbol to be A-Z and between one and seven characters');
424+
}
422425
const a = [precision & 0xff];
423426
a.push(...this.textEncoder.encode(name));
424427
while (a.length < 8) {

src/tests/eosjs-api.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { TextDecoder, TextEncoder } from 'text-encoding';
1+
const { TextEncoder, TextDecoder } = require('util');
22
import { Api } from '../eosjs-api';
33
import { JsonRpc } from '../eosjs-jsonrpc';
44
import { JsSignatureProvider } from '../eosjs-jssig';
@@ -147,7 +147,7 @@ describe('eosjs-api', () => {
147147
const signatureProvider = new JsSignatureProvider(['5JtUScZK2XEp3g9gh7F8bwtPTRAkASmNrrftmx4AxDKD5K4zDnr']);
148148
const chainId = '038f4b0fc8ff18a4f0842a8f0564611f6e96e8535901dd45e43ac8691a1c4dca';
149149
api = new Api({
150-
rpc, signatureProvider, chainId, textDecoder: new TextDecoder(), textEncoder: new TextEncoder(),
150+
rpc, signatureProvider, chainId, textDecoder: new TextDecoder(), textEncoder: new TextEncoder()
151151
});
152152
});
153153

src/tests/eosjs-serialize.test.ts

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const { TextEncoder, TextDecoder } = require('util');
12
import { ec } from 'elliptic';
23

34
import { createInitialTypes, Type, SerialBuffer } from '../eosjs-serialize';
@@ -13,6 +14,79 @@ describe('Serialize', () => {
1314
expect(types).toBeTruthy();
1415
});
1516

17+
describe('pushAsset', () => {
18+
let serialBuffer: SerialBuffer;
19+
const genericValidSymbolCharacter = 'A';
20+
const invalidSymbolErrorMessage = 'Expected symbol to be A-Z and between one and seven characters';
21+
22+
beforeEach(() => {
23+
serialBuffer = new SerialBuffer({
24+
textEncoder: new TextEncoder(),
25+
textDecoder: new TextDecoder()
26+
});
27+
});
28+
29+
const expectSuccessForICharactersSymbol = (i: number) => {
30+
const symbol = genericValidSymbolCharacter.repeat(i);
31+
const asset = `10.000 ${symbol}`;
32+
33+
serialBuffer.pushAsset(asset);
34+
35+
expect(serialBuffer.length).not.toBe(0);
36+
};
37+
38+
const expectExceptionThrown = (asset: string) => {
39+
let exceptionCaught = false;
40+
41+
try {
42+
serialBuffer.pushAsset(asset);
43+
} catch (e) {
44+
expect(e.message).toBe(invalidSymbolErrorMessage);
45+
exceptionCaught = true;
46+
}
47+
48+
expect(exceptionCaught).toBeTruthy();
49+
};
50+
51+
for (let i = 1; i <= 7; i++) {
52+
it(`should be able to push asset with valid symbol of ${i} character(s)`, () => {
53+
expectSuccessForICharactersSymbol(i);
54+
});
55+
}
56+
57+
it('should be able to push asset with valid EOS symbol "10.000 EOS"', () => {
58+
const asset = '10.000 EOS';
59+
60+
serialBuffer.pushAsset(asset);
61+
62+
expect(serialBuffer.length).not.toBe(0);
63+
});
64+
65+
it('should not be able to push no symbol "10.000 "', () => {
66+
const asset = '10.000 ';
67+
68+
expectExceptionThrown(asset);
69+
});
70+
71+
it('should not be able to push symbol with 8 or more characters "10.000 AAAAAAAA"', () => {
72+
const asset = '10.000 AAAAAAAA';
73+
74+
expectExceptionThrown(asset);
75+
});
76+
77+
it('should not be able to push invalid lowercase symbol "10.000 eos"', () => {
78+
const asset = '10.000 eos';
79+
80+
expectExceptionThrown(asset);
81+
});
82+
83+
it('should not be able to push two symbols "10.000 EOS blah"', () => {
84+
const asset = '10.000 EOS blah';
85+
86+
expectExceptionThrown(asset);
87+
});
88+
});
89+
1690
describe('bool', () => {
1791
let boolType: Type;
1892
let mockedBuffer: SerialBuffer;

0 commit comments

Comments
 (0)