diff --git a/CHANGE_LOG.md b/CHANGE_LOG.md index 2112684f..b38f99a2 100644 --- a/CHANGE_LOG.md +++ b/CHANGE_LOG.md @@ -1,6 +1,6 @@ # change log -## v1.5.0 +## v1.5.10 * `Conflux`'s option can pass `networkId` now, and add a new method `updateNetworkId` to sync networkId from RPC. * `format.address` will return new CIP37 addresses, if you pass a hex address, `networkId` should also be passed as second parameter diff --git a/README.md b/README.md index 78eaa8f6..9698f47e 100644 --- a/README.md +++ b/README.md @@ -6,15 +6,10 @@ JavaScript Conflux Software Development Kit -## 1.5 Key features -v1.5 add support for [CIP37](https://github.com/Conflux-Chain/CIPs/blob/master/CIPs/cip-37.md) address. +## 1.5.10 Key features +v1.5.10 add support for [CIP37](https://github.com/Conflux-Chain/CIPs/blob/master/CIPs/cip-37.md) address. And only work with `conflux-rust v1.1.1` or above. -```sh -# For now you can install it with `next` tag -$ npm install js-conflux-sdk@next -``` - The biggest difference you `must to know` is class `Conflux`'s init option add a new field `networkId`. If you still want use hex40 address when invoke RPC methods, `networkId must be set`, only with `networkId` conflux can firgure out a right CIP37 address from hex40 address. @@ -91,10 +86,13 @@ or ``` +CDN services such as `jsdelivr` provide link you can directly use for example: +https://cdn.jsdelivr.net/npm/js-conflux-sdk/dist/js-conflux-sdk.umd.min.js + ## Documentation * [Overview](./docs/overview.md) -* [Complete document for send transaction](./docs/how_to_send_tx.md) +* [Complete document for sending transaction](./docs/how_to_send_tx.md) * [Interacting with contract](./docs/interact_with_contract.md) * [SDK support for CIP37 address](./docs/conflux_checksum_address.md) * [API](./docs/api.md) diff --git a/docs/overview.md b/docs/overview.md index a4300cc0..e8e38e71 100644 --- a/docs/overview.md +++ b/docs/overview.md @@ -71,7 +71,7 @@ Notice: one address can have two form `checksumed` and `not checksumed`, these t ### Send Transaction -For detail explanation of send transaction check [here](./how_to_send_tx.md) +Check [here](./how_to_send_tx.md) to know more details ### chainId `chainId` is used to distinguish different network and prevent replay attack, currently: diff --git a/package.json b/package.json index 35b46f90..eb931ddd 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "js-conflux-sdk", "description": "JavaScript Conflux Software Development Kit", - "version": "1.5.9", + "version": "1.5.10", "license": "LGPL-3.0", "author": "Haizhou@conflux-chain.org", "repository": "https://github.com/Conflux-Chain/js-conflux-sdk.git", diff --git a/src/CONST.js b/src/CONST.js index 11bee01a..11eeed76 100644 --- a/src/CONST.js +++ b/src/CONST.js @@ -61,7 +61,7 @@ const TRANSACTION_STORAGE_LIMIT = 0; * * @type {number} * > CONST.MAINNET_ID - 0 + 1029 */ const MAINNET_ID = 1029; @@ -70,10 +70,19 @@ const MAINNET_ID = 1029; * * @type {number} * > CONST.TESTNET_ID - 0 + 1 */ const TESTNET_ID = 1; +/** + * zero address + * + * @type {string} + * > ZERO_ADDRESS + 0x0000000000000000000000000000000000000000 + */ +const ZERO_ADDRESS_HEX = '0x0000000000000000000000000000000000000000'; + module.exports = { WORD_BYTES, WORD_CHARS, @@ -85,4 +94,5 @@ module.exports = { TRANSACTION_STORAGE_LIMIT, TESTNET_ID, MAINNET_ID, + ZERO_ADDRESS_HEX, }; diff --git a/src/Conflux.js b/src/Conflux.js index 0229c228..669948be 100644 --- a/src/Conflux.js +++ b/src/Conflux.js @@ -7,6 +7,7 @@ const Contract = require('./contract'); const internalContract = require('./contract/internal'); const PendingTransaction = require('./subscribe/PendingTransaction'); const Subscription = require('./subscribe/Subscription'); +const pkg = require('../package.json'); /** * A sdk of conflux. @@ -49,6 +50,8 @@ class Conflux { useHexAddressInParameter = false, ...rest } = {}) { + this.version = pkg.version; + /** * Provider for rpc call * diff --git a/src/util/format.js b/src/util/format.js index ac6076d6..02aeb957 100644 --- a/src/util/format.js +++ b/src/util/format.js @@ -642,6 +642,6 @@ format.traces = format({ format.blockTraces = format({ transactionTraces: [format.traces], -}); +}).$or(null); module.exports = format; diff --git a/types/index.d.ts b/types/index.d.ts index 85f27ead..46922fad 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,5 +1,4 @@ -import JSBI from 'jsbi'; - +type JSBI = BigInt; type EPOCH_LABEL = 'latest_mined' | 'latest_state' | 'latest_checkpoint' | 'latest_confirmed' | 'earliest'; type EpochNumber = number | EPOCH_LABEL; type Address = string; @@ -10,6 +9,7 @@ type Quantity = string | number | JSBI; interface ConfluxOption { url: string, timeout?: number, + networkId?: number, logger?: object, defaultGasPrice?: number, defaultGasRatio?: number, @@ -96,6 +96,14 @@ export class Conflux { getLogs(options: object): Promise; + traceBlock(blockHash: string): Promise; + + getDepositList(address: string, epochNumber?: EpochNumber): Promise; + + getVoteList(address: string, epochNumber?: EpochNumber): Promise; + + getSupplyInfo(epochNumber: EpochNumber): Promise; + // ----------------------------- subscription ------------------------------- subscribe(name: string, ...args: any[]): Promise diff --git a/types/rpc.d.ts b/types/rpc.d.ts index 26547d84..f4691ef3 100644 --- a/types/rpc.d.ts +++ b/types/rpc.d.ts @@ -18,7 +18,8 @@ export interface BlockHeader { refereeHashes: string[]; size: number; timestamp: number; - transactionsRoot: string + transactionsRoot: string; + gasUsed: string; } export interface Block extends BlockHeader { @@ -115,6 +116,11 @@ export interface TransactionReceipt { outcomeStatus: number; logsBloom: string; logs: CfxLog[]; + storageCollateralized: string; + storageReleased: Object[]; + txExecErrorMsg: string; + gasCoveredBySponsor: boolean; + storageCoveredBySponsor: boolean; } export interface Account { @@ -125,4 +131,5 @@ export interface Account { collateralForStorage: number; accumulatedInterestReturn: number; admin: Address; + address: Address; }