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

Commit

Permalink
Merge branch 'develop' into beta3-prep
Browse files Browse the repository at this point in the history
  • Loading branch information
c0d3ster authored Dec 6, 2018
2 parents 50ed834 + 8b096ed commit a64c59d
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 63 deletions.
17 changes: 15 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
env:
global:
PUBLISH_NPM_LATEST_FROM="master"
sudo: false
language: node_js
node_js:
- '10.0.0'
before_install:
- npm i -g npm@6.4.1
- yarn global add typescript
- yarn global add webpack
before_script:
- source ./scripts/is_latest.sh
script:
- yarn run lint
- yarn run test
deploy:
- provider: script
skip_cleanup: true
script:
- ./scripts/publish.sh
- ./scripts/publish-edge.sh
on:
branch: develop
branch: develop
- provider: script
skip_cleanup: true
script:
- ./scripts/publish-tag.sh $PUBLISH_NPM_LATEST_FROM
on:
tags: true
condition: $TRAVIS_IS_LATEST_TAG = true # sourced from ./scripts/is_latest.sh
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eosjs",
"version": "20.0.0-beta3.0",
"version": "20.0.0-beta3",
"description": "Talk to eos API",
"main": "dist/index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion scripts/is_latest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if [ "$latest_tag" == "" ]; then
latest_tag="v0.0.0";
else
tag_commit="$(git rev-list -n 1 ${latest_tag})";
if [ "$tag_commit" = "$current_commit" ]; then
if [ "$tag_commit" == "$current_commit" ]; then
is_latest=true;
fi
fi
Expand Down
26 changes: 26 additions & 0 deletions scripts/publish-edge.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

. "${TRAVIS_BUILD_DIR}/scripts/publish-utils.sh";

echo "Running on branch/tag ${TRAVIS_BRANCH}":

echo "Setting up git"
setup_git

echo "Creating new version"
git checkout -- .

git status

# get the short commit hash to include in the npm package
current_commit="$(git rev-parse --short HEAD)";

npm version prerelease -preid "${current_commit}" -no-git-tag-version

git commit -a -m "Updating version [skip ci]"

echo "Publish to NPM"

cp .npmrc.template $HOME/.npmrc

npm publish --tag edge
37 changes: 37 additions & 0 deletions scripts/publish-tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

. "${TRAVIS_BUILD_DIR}/scripts/publish-utils.sh";

if [[ "$TRAVIS_TAG" == "" ]]; then
echo "No tag specified, skipping...";
else
echo "Running on branch/tag ${TRAVIS_TAG}":

echo "Setting up git"
setup_git

echo "Creating new version"
git checkout -- .

git status

npm version -no-git-tag-version $TRAVIS_TAG

echo "Pushing to git"
git commit -a -m "Publishing version ${TRAVIS_TAG} [skip ci]"

git push origin HEAD:${1}

echo "Build and Publish to NPM"

cp .npmrc.template $HOME/.npmrc

if [[ "$TRAVIS_TAG" == *"-beta"* ]]; then
echo "Publishing with beta tag to npm"
npm publish --tag beta
else
echo "Publishing with latest tag to npm"
npm publish
fi
fi

16 changes: 16 additions & 0 deletions scripts/publish-utils.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

setup_git() {
# Set the user name and email to match the API token holder
# This will make sure the git commits will have the correct photo
# and the user gets the credit for a checkin
git config --global user.email "devops@block.one"
git config --global user.name "blockone-devops"
git config --global push.default matching

# Get the credentials from a file
git config credential.helper "store --file=.git/credentials"

# This associates the API Key with the account
echo "https://${GITHUB_API_KEY}:@github.com" > .git/credentials
}
55 changes: 0 additions & 55 deletions scripts/publish.sh

This file was deleted.

31 changes: 27 additions & 4 deletions src/eosjs-serialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,21 @@ export interface Field {
type: Type;
}

/** Options for serialize() and deserialize() */
export interface SerializerOptions {
bytesAsUint8Array?: boolean;
}

/** State for serialize() and deserialize() */
export class SerializerState {
public options: SerializerOptions;

/** Have any binary extensions been skipped? */
public skippedBinaryExtension = false;

constructor(options: SerializerOptions = {}) {
this.options = options;
}
}

/** A type in an abi */
Expand Down Expand Up @@ -146,7 +157,7 @@ export class SerialBuffer {

/** Return data with excess storage trimmed away */
public asUint8Array() {
return new Uint8Array(this.array.buffer, 0, this.length);
return new Uint8Array(this.array.buffer, this.array.byteOffset, this.length);
}

/** Append bytes */
Expand Down Expand Up @@ -182,7 +193,7 @@ export class SerialBuffer {
if (this.readPos + len > this.length) {
throw new Error("Read past end of buffer");
}
const result = new Uint8Array(this.array.buffer, this.readPos, len);
const result = new Uint8Array(this.array.buffer, this.array.byteOffset + this.readPos, len);
this.readPos += len;
return result;
}
Expand Down Expand Up @@ -858,8 +869,20 @@ export function createInitialTypes(): Map<string, Type> {

bytes: createType({
name: "bytes",
serialize(buffer: SerialBuffer, data: string) { buffer.pushBytes(hexToUint8Array(data)); },
deserialize(buffer: SerialBuffer) { return arrayToHex(buffer.getBytes()); },
serialize(buffer: SerialBuffer, data: string | Uint8Array | number[]) {
if (data instanceof Uint8Array || Array.isArray(data)) {
buffer.pushBytes(data);
} else {
buffer.pushBytes(hexToUint8Array(data));
}
},
deserialize(buffer: SerialBuffer, state?: SerializerState) {
if (state.options.bytesAsUint8Array) {
return buffer.getBytes();
} else {
return arrayToHex(buffer.getBytes());
}
},
}),
string: createType({
name: "string",
Expand Down

0 comments on commit a64c59d

Please sign in to comment.