Skip to content

Commit

Permalink
Merge branch 'master' into piotr-dziubecki-patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
hoffmannjan authored Jul 6, 2021
2 parents c556d4d + dae83ae commit 1d83e99
Show file tree
Hide file tree
Showing 21 changed files with 120 additions and 738 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/ci-casper-client-sdk.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: ci-casper-client-sdk
name: ci-casper-js-sdk

on:
push:
branches: [ master ]
branches: [ master, next ]
paths-ignore:
- '**.md'

pull_request:
branches: [ master ]
branches: [ master, next ]
paths-ignore:
- '**.md'

Expand All @@ -23,6 +23,13 @@ jobs:
node-version: [14.x]

steps:
- name: Set release tag
run: |
if [ ${{ github.ref }} == 'refs/heads/next' ]; then
echo "release_tag=next" >> $GITHUB_ENV
else
echo "release_tag=latest" >> $GITHUB_ENV
fi
- name: Checkout 🛎️
uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
Expand All @@ -41,4 +48,5 @@ jobs:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages # The branch the action should deploy to.
FOLDER: docs/ # The folder that the typedoc generates files.
TARGET_FOLDER: ${{ env.release_tag }}
CLEAN: true # Automatically remove deleted files from the deploy branch
16 changes: 13 additions & 3 deletions .github/workflows/publish-casper-client-sdk.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: publish-casper-client-sdk
name: publish-casper-js-sdk

on:
release:
Expand All @@ -19,6 +19,15 @@ jobs:

steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.release.target_commitish }}
- name: Set release tag
run: |
if [ ${{ github.event.release.target_commitish }} == 'next' ]; then
echo "release_tag=next" >> $GITHUB_ENV
else
echo "release_tag=latest" >> $GITHUB_ENV
fi
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
Expand All @@ -27,14 +36,15 @@ jobs:
- uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
tag: ${{ env.release_tag }}
access: "public"
check-version: true
- name: Get latest release version number
id: get_version
uses: battila7/get-version-action@v2
- run: cp dist/lib.js casper-client-sdk.v${{ steps.get_version.outputs.version }}.js
- run: cp dist/lib.js casper-js-sdk.v${{ steps.get_version.outputs.version }}.js
- uses: meeDamian/github-release@2.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: casper-client-sdk.v${{ steps.get_version.outputs.version }}.js
files: casper-js-sdk.v${{ steps.get_version.outputs.version }}.js
allow_override: true
20 changes: 19 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
# Changelog

All notable changes to casper-client-sdk.
All notable changes to casper-js-sdk.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 1.4.3

## Changed

- Changed repo name and npm package name from `casper-client-sdk` to `casper-js-sdk`.

## 1.4.2

## Added

- `newTransferWithoutObligatoryId` renamed to `newTransferWithOptionalTransferId`

## 1.4.1

## Added

- `newTransferWithoutObligatoryId` restores the function that gives abilitity to send transfer without providing id.

## 1.4.0

## Changed
Expand Down
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,23 @@

## Installation

If you start new project it's recommended to use `2.x` version which contains some breaking changes (the `1.x` will stop being supported in a few months).

```bash
# Basic Node.JS installation
npm install casper-js-sdk@next --save
```

To use the legacy version run

```bash
# Basic Node.JS installation
npm install casper-client-sdk --save
npm install casper-js-sdk --save
```

## Documentation

Documentation generated from code is available [here](https://casper-ecosystem.github.io/casper-client-sdk/)
Documentation generated from code for [`2.x`](https://casper-ecosystem.github.io/casper-js-sdk/next) and [`1.x`](https://casper-ecosystem.github.io/casper-js-sdk/latest/).

## Tests

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "casper-client-sdk",
"version": "1.4.0",
"name": "casper-js-sdk",
"version": "1.4.3",
"license": "Apache 2.0",
"description": "SDK to interact with the Casper blockchain",
"homepage": "https://github.com/casper-ecosystem/casper-client-sdk#README.md",
"homepage": "https://github.com/casper-ecosystem/casper-js-sdk#README.md",
"repository": {
"type": "git",
"url": "https://github.com/casper-ecosystem/casper-client-sdk.git"
"url": "https://github.com/casper-ecosystem/casper-js-sdk.git"
},
"main": "dist/lib.node.js",
"browser": "dist/lib.js",
Expand Down
79 changes: 61 additions & 18 deletions src/lib/DeployUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ export class UniqAddress {
transferId: BigNumber;

/**
* Constructs UniqAddress
* @param publicKey PublicKey instance
* @param transferId BigNumberish value (can be also string representing number). Max U64.
*/
* Constructs UniqAddress
* @param publicKey PublicKey instance
* @param transferId BigNumberish value (can be also string representing number). Max U64.
*/
constructor(publicKey: PublicKey, transferId: BigNumberish) {
if (!(publicKey instanceof PublicKey)) {
throw new Error('publicKey is not an instance of PublicKey');
Expand All @@ -124,17 +124,17 @@ export class UniqAddress {
}

/**
* Returns string in format "accountHex-transferIdHex"
* @param ttl in humanized string
*/
* Returns string in format "accountHex-transferIdHex"
* @param ttl in humanized string
*/
toString(): string {
return `${this.publicKey.toAccountHex()}-${this.transferId.toHexString()}`;
}

/**
* Builds UniqAddress from string
* @param value value returned from UniqAddress.toString()
*/
* Builds UniqAddress from string
* @param value value returned from UniqAddress.toString()
*/
static fromString(value: string): UniqAddress {
const [accountHex, transferHex] = value.split('-');
const publicKey = PublicKey.fromHex(accountHex);
Expand Down Expand Up @@ -743,6 +743,47 @@ export class ExecutableDeployItem implements ToBytes {
);
}

// TODO: Abstract the logic of this and newTransfer so there won't be so much redundancy.
/**
* Constructor for Transfer deploy item without obligatory transfer-id.
* @param amount The number of motes to transfer
* @param target URef of the target purse or the public key of target account. You could generate this public key from accountHex by PublicKey.fromHex
* @param sourcePurse URef of the source purse. If this is omitted, the main purse of the account creating this \
* transfer will be used as the source purse
* @param id user-defined transfer id. This parameter is optional.
*/
public static newTransferWithOptionalTransferId(
amount: BigNumberish,
target: URef | PublicKey,
sourcePurse?: URef | null,
id?: BigNumberish
) {
const runtimeArgs = RuntimeArgs.fromMap({});
runtimeArgs.insert('amount', CLValue.u512(amount));
if (sourcePurse) {
runtimeArgs.insert('source', CLValue.uref(sourcePurse));
}
if (target instanceof URef) {
runtimeArgs.insert('target', CLValue.uref(target));
} else if (target instanceof PublicKey) {
runtimeArgs.insert('target', CLValue.byteArray(target.toAccountHash()));
} else {
throw new Error('Please specify target');
}
if (id !== undefined && id !== null) {
runtimeArgs.insert(
'id',
CLValue.option(CLTypedAndToBytesHelper.u64(id), CLTypeHelper.u64())
);
} else {
runtimeArgs.insert('id', CLValue.option(null, CLTypeHelper.u64()));
}

return ExecutableDeployItem.fromExecutableDeployItemInternal(
new Transfer(runtimeArgs)
);
}

/**
* Constructor for Transfer deploy item using UniqAddress.
* @param source PublicKey of source account
Expand Down Expand Up @@ -920,14 +961,16 @@ export const serializeBody = (

export const serializeApprovals = (approvals: Approval[]): Uint8Array => {
const len = toBytesU32(approvals.length);
const bytes = concat(approvals.map(approval => {
return concat([
Uint8Array.from(Buffer.from(approval.signer, 'hex')),
Uint8Array.from(Buffer.from(approval.signature, 'hex'))
]);
}));
const bytes = concat(
approvals.map(approval => {
return concat([
Uint8Array.from(Buffer.from(approval.signer, 'hex')),
Uint8Array.from(Buffer.from(approval.signature, 'hex'))
]);
})
);
return concat([len, bytes]);
}
};

/**
* Supported contract type
Expand Down Expand Up @@ -1152,4 +1195,4 @@ export const deployToBytes = (deploy: Deploy): Uint8Array => {
serializeBody(deploy.payment, deploy.session),
serializeApprovals(deploy.approvals)
]);
}
};
5 changes: 0 additions & 5 deletions test/keys-manager/.gitignore

This file was deleted.

34 changes: 0 additions & 34 deletions test/keys-manager/README.md

This file was deleted.

25 changes: 0 additions & 25 deletions test/keys-manager/client/package.json

This file was deleted.

33 changes: 0 additions & 33 deletions test/keys-manager/client/src/keys-manager-set-all.js

This file was deleted.

Loading

0 comments on commit 1d83e99

Please sign in to comment.