Comparing version 1.5.1 to 1.5.2
@@ -25,2 +25,6 @@ /// <reference types="node" /> | ||
getStatus(id: string): Promise<TransactionStatusResponse>; | ||
getData(id: string, options?: { | ||
decode?: boolean; | ||
string?: boolean; | ||
}): Promise<string | Uint8Array>; | ||
sign(transaction: Transaction, jwk: JWKInterface): Promise<void>; | ||
@@ -27,0 +31,0 @@ verify(transaction: Transaction): Promise<boolean>; |
@@ -82,2 +82,17 @@ "use strict"; | ||
} | ||
getData(id, options) { | ||
return this.api.get(`tx/${id}/data`).then(response => { | ||
if (response.status === 200) { | ||
const data = response.data; | ||
if (options && options.decode == true) { | ||
if (options && options.string) { | ||
return ArweaveUtils.b64UrlToString(data); | ||
} | ||
return ArweaveUtils.b64UrlToBuffer(data); | ||
} | ||
return data; | ||
} | ||
return null; | ||
}); | ||
} | ||
async sign(transaction, jwk) { | ||
@@ -84,0 +99,0 @@ let dataToSign = transaction.getSignatureData(); |
{ | ||
"name": "arweave", | ||
"version": "1.5.1", | ||
"version": "1.5.2", | ||
"description": "Arweave JS client library", | ||
@@ -17,7 +17,7 @@ "main": "index.js", | ||
"profile:web": "npx webpack --config-name web --json > ./web.profile.json && npx webpack-bundle-analyzer ./web.profile.json", | ||
"package": "mkdir -p node web && mv dist/node/common/* dist/node/node/* node && mv dist/web/common/* dist/web/web/* web && npm run clean:dist", | ||
"package": "mkdirp node web && cp-cli dist/node/common/ dist/node/node/ && cp-cli dist/node/node/ node && cp-cli dist/web/common/ dist/web/web/ && cp-cli dist/web/web/ web && npm run clean:dist", | ||
"build": "npm run compile:node && npm run compile:web && npm run package && npm run bundle:web && npm run bundle:web-prod", | ||
"clean:dist": "rm -rf dist", | ||
"clean:package": "rm -rf node web", | ||
"clean:bundle": "rm -rf bundles", | ||
"clean:dist": "rimraf dist", | ||
"clean:package": "rimraf node web", | ||
"clean:bundle": "rimraf bundles", | ||
"clean": "npm run clean:dist && npm run clean:package && npm run clean:bundle", | ||
@@ -55,4 +55,7 @@ "prepare": "npm run clean && npm run build", | ||
"chai": "^4.2.0", | ||
"cp-cli": "^2.0.0", | ||
"mkdirp": "^0.5.1", | ||
"mocha": "^5.2.0", | ||
"prettier": "1.16.4", | ||
"rimraf": "^3.0.0", | ||
"ts-loader": "^5.4.5", | ||
@@ -59,0 +62,0 @@ "ts-node": "^7.0.1", |
@@ -28,2 +28,3 @@ # Arweave JS | ||
- [Get a transaction](#get-a-transaction) | ||
- [Get transaction data](#get-transaction-data) | ||
- [Decode data and tags from transactions](#decode-data-and-tags-from-transactions) | ||
@@ -347,2 +348,26 @@ - [ArQL](#arql) | ||
#### Get transaction data | ||
You can get the transaction data from a transaction ID without having to get the entire transaction | ||
```js | ||
// Get the base64url encoded string | ||
arweave.transactions.getData('bNbA3TEQVL60xlgCcqdz4ZPHFZ711cZ3hmkpGttDt_U').then(data => { | ||
console.log(data); | ||
// CjwhRE9DVFlQRSBodG1sPgo... | ||
}); | ||
// Get the data decoded to a Uint8Array for binary data | ||
getData('bNbA3TEQVL60xlgCcqdz4ZPHFZ711cZ3hmkpGttDt_U', {decode: true}).then(data => { | ||
console.log(data); | ||
// Uint8Array [10, 60, 33, 68, ...] | ||
}); | ||
// Get the data decode as string data | ||
arweave.transactions.getData('bNbA3TEQVL60xlgCcqdz4ZPHFZ711cZ3hmkpGttDt_U', {decode: true, string: true}).then(data => { | ||
console.log(data); | ||
// <!DOCTYPE HTML>... | ||
}); | ||
``` | ||
#### Decode data and tags from transactions | ||
@@ -349,0 +374,0 @@ |
@@ -25,2 +25,6 @@ /// <reference types="node" /> | ||
getStatus(id: string): Promise<TransactionStatusResponse>; | ||
getData(id: string, options?: { | ||
decode?: boolean; | ||
string?: boolean; | ||
}): Promise<string | Uint8Array>; | ||
sign(transaction: Transaction, jwk: JWKInterface): Promise<void>; | ||
@@ -27,0 +31,0 @@ verify(transaction: Transaction): Promise<boolean>; |
@@ -82,2 +82,17 @@ "use strict"; | ||
} | ||
getData(id, options) { | ||
return this.api.get(`tx/${id}/data`).then(response => { | ||
if (response.status === 200) { | ||
const data = response.data; | ||
if (options && options.decode == true) { | ||
if (options && options.string) { | ||
return ArweaveUtils.b64UrlToString(data); | ||
} | ||
return ArweaveUtils.b64UrlToBuffer(data); | ||
} | ||
return data; | ||
} | ||
return null; | ||
}); | ||
} | ||
async sign(transaction, jwk) { | ||
@@ -84,0 +99,0 @@ let dataToSign = transaction.getSignatureData(); |
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
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
801207
8657
445
17