Skip to content

Commit

Permalink
Minor changes pre 0.3.0 release (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
TerrorJack authored Apr 2, 2021
1 parent 4df678a commit ce1e47f
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 23 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
- 13
- 12
sdk_ver:
- 0.7.0-beta.0
- 0.7.0-beta.1
steps:

- name: checkout
Expand All @@ -89,7 +89,8 @@ jobs:

- name: setup-dfx
run: |
curl -L https://sdk.dfinity.org/downloads/dfx/${{ matrix.sdk_ver }}/x86_64-linux/dfx-${{ matrix.sdk_ver }}.tar.gz | sudo tar xz --strip-components 1 -C /usr/local/bin
mkdir -p ~/.local/bin
curl -L https://sdk.dfinity.org/downloads/dfx/${{ matrix.sdk_ver }}/x86_64-linux/dfx-${{ matrix.sdk_ver }}.tar.gz | tar xz --strip-components 1 -C ~/.local/bin
- name: cache
uses: actions/cache@v2
Expand All @@ -102,7 +103,9 @@ jobs:
- name: test
run: |
sudo cp dfinity/rs/target/release/ic-rosetta-api /usr/local/bin
export PATH=~/.local/bin:$PATH
cp dfinity/rs/target/release/ic-rosetta-api ~/.local/bin
cp \
dfinity/rs/rosetta-api/docker/dfx.json \
dfinity/rs/rosetta-api/ledger.did \
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/protobuf-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: protobuf-check

on:
push:
pull_request:
schedule:
- cron: "0 * * * *"

jobs:

protobuf-check:
name: protobuf-check
runs-on: ubuntu-latest
steps:

- name: checkout
uses: actions/checkout@v2

- name: checkout-dfinity
uses: actions/checkout@v2
with:
repository: dfinity-lab/dfinity
token: ${{ secrets.GH_TOKEN }}
path: dfinity

- name: setup-protoc
run: |
mkdir -p ~/.local/bin
pushd ${{ runner.temp }}
curl -L -o protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v3.13.0/protoc-3.13.0-linux-x86_64.zip
unzip protoc.zip
cp bin/protoc ~/.local/bin
popd
- name: check
run: |
export PATH=~/.local/bin:$PATH
pushd dfinity/rs/rosetta-api/canister
protoc \
--js_out \
import_style=commonjs,binary:${{ github.workspace }}/autogen \
--proto_path proto \
--proto_path ../../types/base_types/proto \
proto/types.proto \
../../types/base_types/proto/ic_base_types/pb/v1/types.proto
popd
git diff --exit-code
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
autogen/
dist/
node_modules/
.idea/
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
(#14)
- Update offline `/construction/combine` implementation to match upstream.
Breaking change. (#13)
- Support decoding `signed_transaction`. (#22)
- Support bundling for NodeJS. (#18)
- Replace some internal utils by using `@dfinity/agent`, and use `tweetnacl` for
ed25519 logic. (#16) (#17)
- Test against multiple Node.js major versions. (#15)

# `0.2.0`
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,23 @@ console.log(tx.amount);
//
// 额外的交易费用的 BigInt 值。
console.log(tx.fee);

// The block height when the transaction was created as a BigInt. It's returned
// by /construction/metadata and a part of the /construction/payloads call.
//
// 事务创建时最新的区块高度的 BigInt 值。该值由 /construction/metadata 返回,并作为
// /construction/payloads 调用的一部分。
console.log(tx.last_height);

// The source account's public key as a Buffer.
//
// 转出账户公钥的 Buffer 值。
console.log(tx.sender_pubkey);

// The ingress_expiry value as a BigInt, as nanoseconds since the unix epoch.
//
// ingress_expiry 的 BigInt 值,纳秒为单位的 unix 时间戳。
console.log(tx.ingress_expiry);
```

### Creating & using a JS bundle
Expand Down
16 changes: 8 additions & 8 deletions lib/session.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const { blobToHex } = require("@dfinity/agent");
const { RosettaClient } = require("@lunarhq/rosetta-ts-client");
const assert = require("assert").strict;
// const assert = require("assert").strict;
const { key_to_pub_key, pub_key_to_address, address_to_hex } = require("./key");
const { transfer_combine } = require("./construction_combine");
const { signed_transaction_decode } = require("./signed_transaction_decode");
// const { signed_transaction_decode } = require("./signed_transaction_decode");

class Session extends RosettaClient {
/**
Expand Down Expand Up @@ -127,13 +127,13 @@ class Session extends RosettaClient {

const combine_res = transfer_combine(src_key, payloads_res);

const tx = signed_transaction_decode(combine_res.signed_transaction);
// const tx = signed_transaction_decode(combine_res.signed_transaction);

assert(tx.from.compare(pub_key_to_address(key_to_pub_key(src_key))) === 0);
assert(tx.to.compare(dest_addr) === 0);
assert(tx.amount === count);
assert(tx.fee === (await this.suggested_fee));
assert(tx.sender_pubkey.compare(key_to_pub_key(src_key)) === 0);
// assert(tx.from.compare(pub_key_to_address(key_to_pub_key(src_key))) === 0);
// assert(tx.to.compare(dest_addr) === 0);
// assert(tx.amount === count);
// assert(tx.fee === (await this.suggested_fee));
// assert(tx.sender_pubkey.compare(key_to_pub_key(src_key)) === 0);

const submit_res = await this.transfer_post_combine(combine_res);

Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
},
"homepage": "https://github.com/dfinity-lab/rosetta-client",
"scripts": {
"build": "webpack --entry ./index.js --mode none --output-library-type commonjs --progress --target node"
"build": "webpack --entry ./index.js --mode production --no-optimization-minimize --no-output-iife --output-library-type commonjs --progress --target node"
},
"files": [
"autogen",
"lib"
],
"dependencies": {
"@dfinity/agent": "0.6.28",
"@dfinity/agent": "^0.6.28",
"@lunarhq/rosetta-ts-client": "^1.4.8-rc3",
"cbor": "^7.0.4",
"crc": "^3.8.0",
Expand Down

0 comments on commit ce1e47f

Please sign in to comment.