Skip to content

Commit

Permalink
Merge pull request #107 from nervina-labs/develop
Browse files Browse the repository at this point in the history
Release v0.5.1
  • Loading branch information
duanyytop authored May 11, 2022
2 parents 42f527e + a545c52 commit 4f5be88
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 17 deletions.
2 changes: 1 addition & 1 deletion example/aggregator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"build": "tsc"
},
"dependencies": {
"@nervina-labs/cota-sdk": "0.4.8",
"@nervina-labs/cota-sdk": "0.5.0",
"@types/node": "17.0.21",
"ts-node": "10.7.0",
"tslib": "2.4.0",
Expand Down
8 changes: 4 additions & 4 deletions example/aggregator/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
dependencies:
"@cspotcode/source-map-consumer" "0.8.0"

"@nervina-labs/cota-sdk@0.4.8":
version "0.4.8"
resolved "https://registry.yarnpkg.com/@nervina-labs/cota-sdk/-/cota-sdk-0.4.8.tgz#f70ae1f46e34eb62205db877446a65e6d6aa020e"
integrity sha512-JqtSwcorEzUktZlvtyl4CkpVqeLet+LsWGbeS9QUqrW8iFli8LJLq+H7eDiEkLrlK29HSVn63e+lL6XgLT0XCQ==
"@nervina-labs/cota-sdk@0.5.0":
version "0.5.0"
resolved "https://registry.yarnpkg.com/@nervina-labs/cota-sdk/-/cota-sdk-0.5.0.tgz#8095a3aec3d83c0cc8fc35574d6a4cbfd031b365"
integrity sha512-Yi48wnG+ykXrDYVgvnH3CACovhvTYw766+6qD5LsBalYCs7QWZwhhuaYq43hQb0N8G2xGrbPa0xR/qwZkew3/Q==
dependencies:
"@nervosnetwork/ckb-sdk-core" "^0.102.3"
"@nervosnetwork/ckb-sdk-utils" "^0.102.3"
Expand Down
2 changes: 1 addition & 1 deletion example/mainnet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"description": "The examples for mainnet",
"license": "MIT",
"dependencies": {
"@nervina-labs/cota-sdk": "0.4.8"
"@nervina-labs/cota-sdk": "0.5.0"
}
}
8 changes: 4 additions & 4 deletions example/mainnet/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# yarn lockfile v1


"@nervina-labs/cota-sdk@0.4.8":
version "0.4.8"
resolved "https://registry.yarnpkg.com/@nervina-labs/cota-sdk/-/cota-sdk-0.4.8.tgz#f70ae1f46e34eb62205db877446a65e6d6aa020e"
integrity sha512-JqtSwcorEzUktZlvtyl4CkpVqeLet+LsWGbeS9QUqrW8iFli8LJLq+H7eDiEkLrlK29HSVn63e+lL6XgLT0XCQ==
"@nervina-labs/cota-sdk@0.5.0":
version "0.5.0"
resolved "https://registry.yarnpkg.com/@nervina-labs/cota-sdk/-/cota-sdk-0.5.0.tgz#8095a3aec3d83c0cc8fc35574d6a4cbfd031b365"
integrity sha512-Yi48wnG+ykXrDYVgvnH3CACovhvTYw766+6qD5LsBalYCs7QWZwhhuaYq43hQb0N8G2xGrbPa0xR/qwZkew3/Q==
dependencies:
"@nervosnetwork/ckb-sdk-core" "^0.102.3"
"@nervosnetwork/ckb-sdk-utils" "^0.102.3"
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nervina-labs/cota-sdk",
"version": "0.5.0",
"version": "0.5.1",
"description": "The SDK of CoTA",
"repository": "[email protected]:nervina-labs/cota-sdk-js.git",
"author": "duanyytop <[email protected]>",
Expand Down Expand Up @@ -40,7 +40,7 @@
"eslint-config-prettier": "8.5.0",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-prettier": "4.0.0",
"husky": "8.0.0",
"husky": "8.0.1",
"prettier": "2.6.2",
"ts-node": "10.7.0",
"tslib": "2.4.0",
Expand Down
6 changes: 5 additions & 1 deletion src/collector/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import axios from 'axios'
import CKB from '@nervosnetwork/ckb-sdk-core'
import { toCamelcase } from '../utils/case-parser'
import { IndexerCell, CollectResult } from '../types/collector'
import { MIN_CAPACITY } from '../constants'

export class Collector {
private ckbNodeUrl: string
Expand Down Expand Up @@ -79,13 +80,16 @@ export class Collector {
since: '0x0',
})
sum = sum + BigInt(cell.output.capacity)
if (sum >= needCapacity + fee) {
if (sum >= needCapacity + MIN_CAPACITY + fee) {
break
}
}
if (sum < needCapacity + fee) {
throw Error('Capacity not enough')
}
if (sum < needCapacity + MIN_CAPACITY + fee) {
throw Error('Capacity not enough for change')
}
return { inputs, capacity: sum }
}

Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1036,10 +1036,10 @@ hmac-drbg@^1.0.1:
minimalistic-assert "^1.0.0"
minimalistic-crypto-utils "^1.0.1"

[email protected].0:
version "8.0.0"
resolved "https://registry.yarnpkg.com/husky/-/husky-8.0.0.tgz#65b2d94765199d651615716a42ea52f3c2d997a0"
integrity sha512-4qbE/5dzNDNxFEkX9MNRPKl5+omTXQzdILCUWiqG/lWIAioiM5vln265/l6I2Zx8gpW8l1ukZwGQeCFbBZ6+6w==
[email protected].1:
version "8.0.1"
resolved "https://registry.yarnpkg.com/husky/-/husky-8.0.1.tgz#511cb3e57de3e3190514ae49ed50f6bc3f50b3e9"
integrity sha512-xs7/chUH/CKdOCs7Zy0Aev9e/dKOMZf3K1Az1nar3tzlv0jfqnYtu235bstsWTmXOR0EfINrPa97yy4Lz6RiKw==

ignore@^5.2.0:
version "5.2.0"
Expand Down

0 comments on commit 4f5be88

Please sign in to comment.