Skip to content
This repository has been archived by the owner on Sep 11, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' into feature/typedoc
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Feb 11, 2020
2 parents 2229edf + 5d4783d commit ef086fd
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 34 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.10.1] - 2020-02-06

### Changed
- Expose `tryExecuteAction` and `doLedgerAction` of the `Swap` class.

## [0.10.0] - 2020-01-31

### Changed
Expand Down Expand Up @@ -119,7 +124,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Common code that can be used to build applications on top of COMIT.

[Unreleased]: https://github.com/comit-network/comit-js-sdk/compare/0.10.0...HEAD
[Unreleased]: https://github.com/comit-network/comit-js-sdk/compare/0.10.1...HEAD
[0.10.1]: https://github.com/comit-network/comit-js-sdk/compare/0.10.0...0.10.1
[0.10.0]: https://github.com/comit-network/comit-js-sdk/compare/0.9.1...0.10.0
[0.9.1]: https://github.com/comit-network/comit-js-sdk/compare/0.8.0...0.9.1
[0.9.0]: https://github.com/comit-network/comit-js-sdk/compare/0.8.0...0.9.0
Expand Down
17 changes: 17 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Releasing comit-sdk

This document summarizes the steps to release the `comit-js-sdk`.
Replace `X.Y.Z` with the new version.

1. Open changelog and [decide new version number](https://semver.org/) based on changes.
1. Create release branch `git checkout -b release/X.Y.Z`
1. Update the version in `package.json`
1. Update `CHANGELOG.md`, move unreleased changes under the new version and update links at the bottom of the file.
1. Commit the [changes](https://github.com/comit-network/comit-js-sdk/pull/103/files) with message `Release X.Y.Z`
1. Create a Pull Request, wait for checks and approvals,
1. (don't merge the PR, add the tags first; if merged you might have to remove the branch yourself later)
1. Tag the release commit `git tag X.Y.Z`
1. Push the tag `git push --tags`,
1. Go to the `Checks` section in the PR on Github and wait until the release action to npmjs.com was done,
1. Go to https://npmjs.com, search for `comit-sdk` and check if it was released correctly there,
1. Remove the remote branch if you merged before pushing.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "comit-sdk",
"version": "0.10.0",
"version": "0.10.1",
"description": "An SDK for developing COMIT applications.",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
Expand Down
64 changes: 32 additions & 32 deletions src/swap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class Swap {
return response.data;
}

private tryExecuteAction(
public tryExecuteAction(
actionName: string,
{ maxTimeoutSecs, tryIntervalSecs }: TryParams
) {
Expand All @@ -56,6 +56,37 @@ export class Swap {
);
}

public async doLedgerAction(action: LedgerAction) {
switch (action.type) {
case "bitcoin-broadcast-signed-transaction": {
const { hex, network } = action.payload;

return await this.bitcoinWallet.broadcastTransaction(hex, network);
}
case "bitcoin-send-amount-to-address": {
const { to, amount, network } = action.payload;
const sats = parseInt(amount, 10);

return await this.bitcoinWallet.sendToAddress(to, sats, network);
}
case "ethereum-call-contract": {
const { data, contract_address, gas_limit } = action.payload;

return await this.ethereumWallet.callContract(
data,
contract_address,
gas_limit
);
}
case "ethereum-deploy-contract": {
const { amount, data, gas_limit } = action.payload;
const value = new BigNumber(amount);

return await this.ethereumWallet.deployContract(data, value, gas_limit);
}
}
}

private async executeAction(actionName: string, tryIntervalSecs: number) {
while (true) {
await sleep(tryIntervalSecs * 1000);
Expand Down Expand Up @@ -94,35 +125,4 @@ export class Swap {
return Promise.resolve(this.ethereumWallet.getAccount());
}
}

private async doLedgerAction(action: LedgerAction) {
switch (action.type) {
case "bitcoin-broadcast-signed-transaction": {
const { hex, network } = action.payload;

return await this.bitcoinWallet.broadcastTransaction(hex, network);
}
case "bitcoin-send-amount-to-address": {
const { to, amount, network } = action.payload;
const sats = parseInt(amount, 10);

return await this.bitcoinWallet.sendToAddress(to, sats, network);
}
case "ethereum-call-contract": {
const { data, contract_address, gas_limit } = action.payload;

return await this.ethereumWallet.callContract(
data,
contract_address,
gas_limit
);
}
case "ethereum-deploy-contract": {
const { amount, data, gas_limit } = action.payload;
const value = new BigNumber(amount);

return await this.ethereumWallet.deployContract(data, value, gas_limit);
}
}
}
}

0 comments on commit ef086fd

Please sign in to comment.