Comparing version 1.10.14 to 1.10.15
@@ -12,2 +12,3 @@ import Ar from "./ar"; | ||
import Chunks from "./chunks"; | ||
import Blocks from "./blocks"; | ||
export interface Config { | ||
@@ -34,2 +35,3 @@ api: ApiConfig; | ||
network: Network; | ||
blocks: Blocks; | ||
ar: Ar; | ||
@@ -36,0 +38,0 @@ silo: Silo; |
@@ -34,2 +34,3 @@ "use strict"; | ||
const chunks_1 = __importDefault(require("./chunks")); | ||
const blocks_1 = __importDefault(require("./blocks")); | ||
class Arweave { | ||
@@ -43,2 +44,3 @@ constructor(apiConfig) { | ||
this.network = new network_1.default(this.api); | ||
this.blocks = new blocks_1.default(this.api, this.network); | ||
this.ar = new ar_1.default(); | ||
@@ -45,0 +47,0 @@ } |
@@ -19,4 +19,4 @@ /// <reference types="node" /> | ||
private mergeDefaults; | ||
get(endpoint: string, config?: AxiosRequestConfig): Promise<AxiosResponse>; | ||
post(endpoint: string, body: Buffer | string | object, config?: AxiosRequestConfig): Promise<AxiosResponse>; | ||
get<T = any>(endpoint: string, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>; | ||
post<T = any>(endpoint: string, body: Buffer | string | object, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>; | ||
/** | ||
@@ -23,0 +23,0 @@ * Get an AxiosInstance with the base configuration setup to fire off |
@@ -6,3 +6,4 @@ import { AxiosResponse } from "axios"; | ||
TX_FAILED = "TX_FAILED", | ||
TX_INVALID = "TX_INVALID" | ||
TX_INVALID = "TX_INVALID", | ||
BLOCK_NOT_FOUND = "BLOCK_NOT_FOUND" | ||
} | ||
@@ -9,0 +10,0 @@ export default class ArweaveError extends Error { |
{ | ||
"name": "arweave", | ||
"version": "1.10.14", | ||
"version": "1.10.15", | ||
"description": "Arweave JS client library", | ||
@@ -5,0 +5,0 @@ "main": "./node/index.js", |
@@ -31,2 +31,5 @@ # Arweave JS | ||
- [Decode tags from transactions](#decode-tags-from-transactions) | ||
- [Blocks](#blocks) | ||
- [Get a block by indep_hash](#get-a-block-by-indep-hash) | ||
- [Get current block](#get-current-block) | ||
- [ArQL](#arql) | ||
@@ -175,5 +178,5 @@ - [License](#license) | ||
The create transaction methods simply creates and returns an unsigned transaction object, you must sign the transaction and submit it separeately using the `transactions.sign` and `transactions.submit` methods. | ||
The create transaction methods create and return an unsigned transaction object. You must sign the transaction and submit it separeately using the `transactions.sign` and `transactions.submit` methods. | ||
**Modifying a transaction object after signing it will invalidate the signature**, this will cause it to be rejected by the network if submitted in that state. Transaction prices are based on the size of the data field, so modifying the data field after a transaction has been created isn't recommended as you'll need to manually update the price. | ||
**Modifying a transaction object after signing it will invalidate the signature,** causing it to be rejected by the network if submitted in that state. Transaction prices are based on the size of the data field, so modifying the data field after a transaction has been created isn't recommended as you'll need to manually update the price. | ||
@@ -484,2 +487,41 @@ The transaction ID is a hash of the transaction signature, so a transaction ID can't be known until its contents are finalised and it has been signed. | ||
### Blocks | ||
Blocks are base elements of Arweave's blockweave data structure. | ||
Each block is linked to two prior blocks: the previous block in the "chain" (as with traditional blockchain | ||
protocols), and a block from the previous history of the blockchain (the "recall block"). Each block contains | ||
a list of zero to many transactions. | ||
#### Get a block by indep_hash | ||
Gets block data for given independent hash (see page 63. of [yellow-paper](https://www.arweave.org/yellow-paper.pdf) for details). | ||
```js | ||
const result = await arweave.blocks.get("zbUPQFA4ybnd8h99KI9Iqh4mogXJibr0syEwuJPrFHhOhld7XBMOUDeXfsIGvYDp"); | ||
console.log(result) | ||
// { | ||
// "nonce": "6jdzO4FzS4EVaQVcLBEmxm6uN5-1tqBXW24Pzp6JsRQ", | ||
// "previous_block": "iNgEv6vf9nIrxLWeEu-vPNHFftEh0kfOnx0qd6NKUOc8Z3WeMeOmAmdOHwSUFAGn", | ||
// "timestamp": 1624183433, | ||
// "last_retarget": 1624183433, | ||
// "diff": "115792089220940710686296942055695413965527953310049630981189590430430626054144", | ||
// "height": 711150, | ||
// "hash": "_____8V8BkM8Cyja5ZFJcc7HfX33eM4BKDAvcEBn22s", | ||
// "indep_hash": "zbUPQFA4ybnd8h99KI9Iqh4mogXJibr0syEwuJPrFHhOhld7XBMOUDeXfsIGvYDp", | ||
// "txs": [ ... | ||
``` | ||
#### Get current block | ||
Gets a block data for current block, i.e., block with indep_hash: | ||
```js | ||
const {current} = await arweave.network.getInfo(); | ||
``` | ||
```js | ||
const result = await arweave.blocks.getCurrent(); | ||
console.log(result) | ||
// { | ||
// "indep_hash": "qoJwHSpzl6Ouo140HW2DTv1rGOrgfBEnHi5sHv-fJt_TsK7xA70F2QbjMCopLiMd", | ||
// ... | ||
``` | ||
### ArQL | ||
@@ -486,0 +528,0 @@ |
@@ -12,2 +12,3 @@ import Ar from "./ar"; | ||
import Chunks from "./chunks"; | ||
import Blocks from "./blocks"; | ||
export interface Config { | ||
@@ -34,2 +35,3 @@ api: ApiConfig; | ||
network: Network; | ||
blocks: Blocks; | ||
ar: Ar; | ||
@@ -36,0 +38,0 @@ silo: Silo; |
@@ -12,2 +12,3 @@ "use strict"; | ||
const chunks_1 = require("./chunks"); | ||
const blocks_1 = require("./blocks"); | ||
class Arweave { | ||
@@ -21,2 +22,3 @@ constructor(apiConfig) { | ||
this.network = new network_1.default(this.api); | ||
this.blocks = new blocks_1.default(this.api, this.network); | ||
this.ar = new ar_1.default(); | ||
@@ -23,0 +25,0 @@ } |
@@ -19,4 +19,4 @@ /// <reference types="node" /> | ||
private mergeDefaults; | ||
get(endpoint: string, config?: AxiosRequestConfig): Promise<AxiosResponse>; | ||
post(endpoint: string, body: Buffer | string | object, config?: AxiosRequestConfig): Promise<AxiosResponse>; | ||
get<T = any>(endpoint: string, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>; | ||
post<T = any>(endpoint: string, body: Buffer | string | object, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>; | ||
/** | ||
@@ -23,0 +23,0 @@ * Get an AxiosInstance with the base configuration setup to fire off |
@@ -6,3 +6,4 @@ import { AxiosResponse } from "axios"; | ||
TX_FAILED = "TX_FAILED", | ||
TX_INVALID = "TX_INVALID" | ||
TX_INVALID = "TX_INVALID", | ||
BLOCK_NOT_FOUND = "BLOCK_NOT_FOUND" | ||
} | ||
@@ -9,0 +10,0 @@ export default class ArweaveError extends Error { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1245575
131
13637
574