Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Add deprecation tag to algod v1 client #642

Merged
merged 1 commit into from
Sep 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/client/algod.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { default: HTTPClient } = require('./client');
const { setSendTransactionHeaders } = require('./v2/algod/sendRawTransaction');

/** @deprecated v1 algod APIs are deprecated, please use the v2 client */
function Algod(
token = '',
baseServer = 'http://r2.algorand.network',
Expand All @@ -20,6 +21,7 @@ function Algod(
* Takes an object and convert its note field to Buffer, if exist.
* @param o
* @returns {*}
* @deprecated v1 algod APIs are deprecated, please use the v2 client
*/
function noteb64ToNote(o) {
if (!(o.noteb64 === undefined || o.noteb64 === null)) {
Expand All @@ -33,6 +35,7 @@ function Algod(
* status retrieves the StatusResponse from the running node
* @param headerObj, optional
* @returns {Promise<*>}
* @deprecated v1 algod APIs are deprecated, please use the v2 client
*/
this.status = async (headerObj = {}) => {
const res = await c.get('/v1/status', {}, headerObj);
Expand All @@ -43,6 +46,7 @@ function Algod(
* healthCheck returns an empty object iff the node is running
* @param headerObj, optional
* @returns {Promise<*>}
* @deprecated v1 algod APIs are deprecated, please use the v2 client
*/
this.healthCheck = async (headerObj = {}) => {
const res = await c.get('/health', {}, headerObj);
Expand All @@ -58,6 +62,7 @@ function Algod(
* @param roundNumber
* @param headerObj, optional
* @returns {Promise<*>}
* @deprecated v1 algod APIs are deprecated, please use the v2 client
*/
this.statusAfterBlock = async (roundNumber, headerObj = {}) => {
if (!Number.isInteger(roundNumber))
Expand All @@ -76,6 +81,7 @@ function Algod(
* @param maxTxns - number
* @param headerObj, optional
* @returns {Promise<*>}
* @deprecated v1 algod APIs are deprecated, please use the v2 client
*/
this.pendingTransactions = async (maxTxns, headerObj = {}) => {
if (!Number.isInteger(maxTxns)) throw Error('maxTxns should be an integer');
Expand All @@ -101,6 +107,7 @@ function Algod(
* versions retrieves the VersionResponse from the running node
* @param headerObj, optional
* @returns {Promise<*>}
* @deprecated v1 algod APIs are deprecated, please use the v2 client
*/
this.versions = async (headerObj = {}) => {
const res = await c.get('/versions', {}, headerObj);
Expand All @@ -111,6 +118,7 @@ function Algod(
* LedgerSupply gets the supply details for the specified node's Ledger
* @param headerObj, optional
* @returns {Promise<*>}
* @deprecated v1 algod APIs are deprecated, please use the v2 client
*/
this.ledgerSupply = async (headerObj = {}) => {
const res = await c.get('/v1/ledger/supply', {}, headerObj);
Expand All @@ -125,6 +133,7 @@ function Algod(
* @param maxTxns - number, optional
* @param headers, optional
* @returns {Promise<*>}
* @deprecated v1 algod APIs are deprecated, please use the v2 client
*/
this.transactionByAddress = async (
addr,
Expand Down Expand Up @@ -161,6 +170,7 @@ function Algod(
* @param maxTxns - number, optional
* @param headerObj, optional
* @returns {Promise<*>}
* @deprecated v1 algod APIs are deprecated, please use the v2 client
*/
this.transactionByAddressAndDate = async (
addr,
Expand Down Expand Up @@ -188,6 +198,7 @@ function Algod(
* @param txid
* @param headerObj, optional
* @returns {Promise<*>}
* @deprecated v1 algod APIs are deprecated, please use the v2 client
*/
this.transactionById = async (txid, headerObj = {}) => {
const res = await c.get(`/v1/transaction/${txid}`, {}, headerObj);
Expand All @@ -203,6 +214,7 @@ function Algod(
* @param txid
* @param headerObj, optional
* @returns {Promise<*>}
* @deprecated v1 algod APIs are deprecated, please use the v2 client
*/
this.transactionInformation = async (addr, txid, headerObj = {}) => {
const res = await c.get(
Expand All @@ -221,6 +233,7 @@ function Algod(
* @param txid
* @param headerObj, optional
* @returns {Promise<*>}
* @deprecated v1 algod APIs are deprecated, please use the v2 client
*/
this.pendingTransactionInformation = async (txid, headerObj = {}) => {
const res = await c.get(`/v1/transactions/pending/${txid}`, {}, headerObj);
Expand All @@ -235,6 +248,7 @@ function Algod(
* @param addr - string
* @param headerObj, optional
* @returns {Promise<*>}
* @deprecated v1 algod APIs are deprecated, please use the v2 client
*/
this.accountInformation = async (addr, headerObj = {}) => {
const res = await c.get(`/v1/account/${addr}`, {}, headerObj);
Expand All @@ -246,6 +260,7 @@ function Algod(
* @param index - number
* @param headerObj, optional
* @returns {Promise<*>}
* @deprecated v1 algod APIs are deprecated, please use the v2 client
*/
this.assetInformation = async (index, headerObj = {}) => {
const res = await c.get(`/v1/asset/${index}`, {}, headerObj);
Expand All @@ -256,6 +271,7 @@ function Algod(
* suggestedFee gets the recommended transaction fee from the node
* @param headerObj, optional
* @returns {Promise<*>}
* @deprecated v1 algod APIs are deprecated, please use the v2 client
*/
this.suggestedFee = async (headerObj = {}) => {
const res = await c.get('/v1/transactions/fee', {}, headerObj);
Expand All @@ -267,6 +283,7 @@ function Algod(
* @param txn - Uin8Array
* @param headerObj, optional
* @returns {Promise<*>}
* @deprecated v1 algod APIs are deprecated, please use the v2 client
*/
this.sendRawTransaction = async (txn, headerObj = {}) => {
const txHeaders = setSendTransactionHeaders(headerObj);
Expand All @@ -279,6 +296,7 @@ function Algod(
* @param txn - Array of Uin8Array
* @param headerObj, optional
* @returns {Promise<*>}
* @deprecated v1 algod APIs are deprecated, please use the v2 client
*/
this.sendRawTransactions = async (txns, headerObj = {}) => {
const txHeaders = setSendTransactionHeaders(headerObj);
Expand All @@ -297,6 +315,7 @@ function Algod(
* getTransactionParams returns to common needed parameters for a new transaction
* @param headerObj, optional
* @returns {Promise<*>}
* @deprecated v1 algod APIs are deprecated, please use the v2 client
*/
this.getTransactionParams = async (headerObj = {}) => {
const res = await c.get('/v1/transactions/params', {}, headerObj);
Expand All @@ -307,6 +326,7 @@ function Algod(
* suggestParams returns to common needed parameters for a new transaction, in a format the transaction builder expects
* @param headerObj, optional
* @returns {Object}
* @deprecated v1 algod APIs are deprecated, please use the v2 client
*/
this.suggestParams = async (headerObj = {}) => {
const result = await this.getTransactionParams(headerObj);
Expand All @@ -325,6 +345,7 @@ function Algod(
* @param roundNumber
* @param headerObj, optional
* @returns {Promise<*>}
* @deprecated v1 algod APIs are deprecated, please use the v2 client
*/
this.block = async (roundNumber, headerObj = {}) => {
if (!Number.isInteger(roundNumber))
Expand Down