mirror of
https://github.com/cosmos/cosmjs.git
synced 2025-03-11 14:09:15 +00:00
commit
7115fb265f
@ -35,7 +35,7 @@ workflows:
|
||||
jobs:
|
||||
build:
|
||||
docker:
|
||||
- image: circleci/node:10-buster
|
||||
- image: circleci/node:12-buster
|
||||
steps:
|
||||
- run:
|
||||
name: Install Git Large File Storage (LFS)
|
||||
@ -108,7 +108,7 @@ jobs:
|
||||
name: Install nodejs
|
||||
# In the current image, `sudo apt install nodejs` requires `sudo apt update` which is too slow
|
||||
command: |
|
||||
wget -O "$HOME/nodejs.deb" https://deb.nodesource.com/node_10.x/pool/main/n/nodejs/nodejs_10.23.0-deb-1nodesource1_amd64.deb
|
||||
wget -O "$HOME/nodejs.deb" https://deb.nodesource.com/node_12.x/pool/main/n/nodejs/nodejs_12.22.1-deb-1nodesource1_amd64.deb
|
||||
sudo dpkg -i "$HOME/nodejs.deb"
|
||||
- run:
|
||||
name: Install yarn
|
||||
@ -340,7 +340,7 @@ jobs:
|
||||
name: Install nodejs
|
||||
# In the current image, `sudo apt install nodejs` requires `sudo apt update` which is too slow
|
||||
command: |
|
||||
wget -O "$HOME/nodejs.deb" https://deb.nodesource.com/node_10.x/pool/main/n/nodejs/nodejs_10.23.0-deb-1nodesource1_amd64.deb
|
||||
wget -O "$HOME/nodejs.deb" https://deb.nodesource.com/node_12.x/pool/main/n/nodejs/nodejs_12.22.1-deb-1nodesource1_amd64.deb
|
||||
sudo dpkg -i "$HOME/nodejs.deb"
|
||||
- run:
|
||||
name: Install yarn
|
||||
@ -440,7 +440,7 @@ jobs:
|
||||
name: Install nodejs
|
||||
# In the current image, `sudo apt install nodejs` requires `sudo apt update` which is too slow
|
||||
command: |
|
||||
wget -O "$HOME/nodejs.deb" https://deb.nodesource.com/node_10.x/pool/main/n/nodejs/nodejs_10.23.0-deb-1nodesource1_amd64.deb
|
||||
wget -O "$HOME/nodejs.deb" https://deb.nodesource.com/node_12.x/pool/main/n/nodejs/nodejs_12.22.1-deb-1nodesource1_amd64.deb
|
||||
sudo dpkg -i "$HOME/nodejs.deb"
|
||||
- run:
|
||||
name: Install yarn
|
||||
@ -493,7 +493,7 @@ jobs:
|
||||
./scripts/launchpad/stop.sh
|
||||
docs-build:
|
||||
docker:
|
||||
- image: circleci/node:10-buster
|
||||
- image: circleci/node:12-buster
|
||||
steps:
|
||||
- run:
|
||||
name: Install Git Large File Storage (LFS)
|
||||
@ -524,7 +524,7 @@ jobs:
|
||||
paths: docs_deployment
|
||||
docs-deploy:
|
||||
docker:
|
||||
- image: circleci/node:10-buster
|
||||
- image: circleci/node:12-buster
|
||||
steps:
|
||||
- attach_workspace:
|
||||
at: .
|
||||
@ -542,7 +542,7 @@ jobs:
|
||||
command: npx gh-pages@3.0.0 --message "Update docs [skip ci]" --dist docs_deployment --user "CI deployment <ci@cosmwasm.com>" --repo "git@github.com:cosmos/cosmjs.git"
|
||||
lint:
|
||||
docker:
|
||||
- image: circleci/node:10-buster
|
||||
- image: circleci/node:12-buster
|
||||
steps:
|
||||
- run:
|
||||
name: Install Git Large File Storage (LFS)
|
||||
|
@ -24,6 +24,7 @@ and this project adheres to
|
||||
|
||||
### Removed
|
||||
|
||||
- Node.js v10 is no longer supported. Please use v12 or later.
|
||||
- @cosmjs/tendermint-rpc: `Client` has been removed. Please use
|
||||
`Tendermint33Client` or `Tendermint34Client`, depending on your needs.
|
||||
|
||||
|
@ -6,7 +6,7 @@ work on CosmJS, i.e. modify it. It is not intended for users of CosmJS.
|
||||
## Prerequisite
|
||||
|
||||
- A UNIX-like development environment
|
||||
- Node.js 10+, Docker and yarn
|
||||
- Node.js 12+, Docker and yarn
|
||||
- `sha256sum`, which you
|
||||
[can get on macOS as well](https://unix.stackexchange.com/questions/426837/no-sha256sum-in-macos)
|
||||
|
||||
|
@ -77,7 +77,7 @@ optipng docs/cosmjs-tree*.png
|
||||
|
||||
Currently the codebase supports the following runtime environments:
|
||||
|
||||
1. Node.js 10+
|
||||
1. Node.js 12+
|
||||
2. Modern browsers (Chromium/Firefox/Safari, no Internet Explorer or
|
||||
[Edge Spartan](https://en.wikipedia.org/wiki/Microsoft_Edge#Development))
|
||||
3. Browser extensions (Chromium/Firefox)
|
||||
|
@ -1,38 +1,17 @@
|
||||
// Global symbols in some environments
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
// Global symbols in both browsers and Node.js since v11
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder
|
||||
/* eslint-disable-next-line @typescript-eslint/naming-convention */
|
||||
declare const TextEncoder: any | undefined;
|
||||
/* eslint-disable-next-line @typescript-eslint/naming-convention */
|
||||
declare const TextDecoder: any | undefined;
|
||||
|
||||
function isValidUtf8(data: Uint8Array): boolean {
|
||||
const toStringAndBack = Buffer.from(Buffer.from(data).toString("utf8"), "utf8");
|
||||
return Buffer.compare(Buffer.from(data), toStringAndBack) === 0;
|
||||
}
|
||||
// https://nodejs.org/docs/latest-v12.x/api/util.html#util_class_util_textencoder
|
||||
// https://nodejs.org/docs/latest-v12.x/api/util.html#util_class_util_textdecoder
|
||||
// See https://github.com/microsoft/TypeScript/issues/31535
|
||||
declare const TextEncoder: any;
|
||||
declare const TextDecoder: any;
|
||||
|
||||
export function toUtf8(str: string): Uint8Array {
|
||||
// Browser and future nodejs (https://github.com/nodejs/node/issues/20365)
|
||||
if (typeof TextEncoder !== "undefined") {
|
||||
return new TextEncoder().encode(str);
|
||||
}
|
||||
|
||||
// Use Buffer hack instead of nodejs util.TextEncoder to ensure
|
||||
// webpack does not bundle the util module for browsers.
|
||||
return new Uint8Array(Buffer.from(str, "utf8"));
|
||||
return new TextEncoder().encode(str);
|
||||
}
|
||||
|
||||
export function fromUtf8(data: Uint8Array): string {
|
||||
// Browser and future nodejs (https://github.com/nodejs/node/issues/20365)
|
||||
if (typeof TextDecoder !== "undefined") {
|
||||
return new TextDecoder("utf-8", { fatal: true }).decode(data);
|
||||
}
|
||||
|
||||
// Use Buffer hack instead of nodejs util.TextDecoder to ensure
|
||||
// webpack does not bundle the util module for browsers.
|
||||
// Buffer.toString has no fatal option
|
||||
if (!isValidUtf8(data)) {
|
||||
throw new Error("Invalid UTF8 data");
|
||||
}
|
||||
return Buffer.from(data).toString("utf8");
|
||||
return new TextDecoder("utf-8", { fatal: true }).decode(data);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user