-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
327 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import BigNumber from 'bignumber.js' | ||
import {get, post} from '../connector/tatum' | ||
import {AlgoBlock, AlgoTx, TransactionHash} from '../model' | ||
|
||
/** | ||
* For more details, see <a href="https://tatum.io/apidoc#operation/AlgorandBroadcast" target="_blank">Tatum API documentation</a> | ||
*/ | ||
export const algorandBroadcast = async (txData: string, signatureId?: string): Promise<TransactionHash> => | ||
post(`/v3/algorand/broadcast`, {txData, signatureId}) | ||
|
||
/** | ||
* For more details, see <a href="https://tatum.io/apidoc#operation/AlgorandGetTransactionCount" target="_blank">Tatum API documentation</a> | ||
*/ | ||
export const algorandGetTransactionsCount = async (address: string): Promise<number> => | ||
get(`/v3/algorand/transaction/count/${address}`) | ||
|
||
/** | ||
* For more details, see <a href="https://tatum.io/apidoc#operation/AlgorandGetCurrentBlock" target="_blank">Tatum API documentation</a> | ||
*/ | ||
export const algorandGetCurrentBlock = async (): Promise<number> => | ||
get(`/v3/algorand/block/current`) | ||
|
||
/** | ||
* For more details, see <a href="https://tatum.io/apidoc#operation/AlgorandGetBlock" target="_blank">Tatum API documentation</a> | ||
*/ | ||
export const algorandGetBlock = async (roundNumber: string): Promise<AlgoBlock> => | ||
get(`/v3/algorand/block/${roundNumber}`) | ||
|
||
/** | ||
* For more details, see <a href="https://tatum.io/apidoc#operation/AlgorandGetBalance" target="_blank">Tatum API documentation</a> | ||
*/ | ||
export const algorandGetAccountBalance = async (address: string): Promise<BigNumber> => | ||
get(`/v3/algorand/account/balance/${address}`) | ||
|
||
/** | ||
* For more details, see <a href="https://tatum.io/apidoc#operation/AlgorandGetTransaction" target="_blank">Tatum API documentation</a> | ||
*/ | ||
export const algorandGetTransaction = async (txid: string): Promise<AlgoTx> => get(`/v3/algorand/transaction/${txid}`) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import {AlgoTx} from './AlgoTx' | ||
|
||
/** | ||
* | ||
* @export | ||
* @interface AlgoBlock | ||
*/ | ||
export interface AlgoBlock { | ||
/** | ||
* [gh]hash to which this block belongs. | ||
* @type {string} | ||
* @memberof AlgoBlock | ||
*/ | ||
genesisHash: string; | ||
|
||
/** | ||
* [gen] ID hash to which this block belongs. | ||
* @type {string} | ||
* @memberof AlgoBlock | ||
*/ | ||
genesisId: string; | ||
|
||
/** | ||
* [prev] Previous block hash. | ||
* @type {string} | ||
* @memberof AlgoBlock | ||
*/ | ||
previousBlockHash: string; | ||
|
||
/** | ||
* (optional) | ||
* @type {any} | ||
* @memberof AlgoBlock | ||
*/ | ||
rewards: any; | ||
|
||
/** | ||
* [rnd] Current round on which this block was appended to the chain. | ||
* @type {string} | ||
* @memberof AlgoBlock | ||
*/ | ||
round: string; | ||
|
||
/** | ||
* [seed] Sortition seed. | ||
* @type {string} | ||
* @memberof AlgoBlock | ||
*/ | ||
seed: string; | ||
|
||
/** | ||
* [ts] Block creation timestamp in seconds since eposh. | ||
* @type {number} | ||
* @memberof AlgoBlock | ||
*/ | ||
timestamp: number; | ||
|
||
/** | ||
* [txns]list of transactions corresponding to a given round. | ||
* @type {Array<AlgoTx>} | ||
* @memberof AlgoBlock | ||
*/ | ||
txns: AlgoTx[]; | ||
|
||
/** | ||
* [txn] TransactionsRoot authenticates the set of transactions appearing in the block. | ||
* More specifically, it's the root of a merkle tree whose leaves are the block's Txids, in lexicographic order. | ||
* For the empty block, it's 0. | ||
* Note that the TxnRoot does not authenticate the signatures on the transactions, only the transactions themselves. | ||
* Two blocks with the same transactions but in a different order and with different order and with different signatures will have the same TxnRot. | ||
* @type {string} | ||
* @memberof AlgoBlock | ||
*/ | ||
txn: string; | ||
|
||
/** | ||
* [tc] TxnCounter counts the number of transactions committed in the ledger, from the time at which support for this feature was introduced. | ||
* (optional) | ||
* @type {number} | ||
* @memberof AlgoBlock | ||
*/ | ||
txnc: number; | ||
|
||
/** | ||
* (optional) | ||
* @type {any} | ||
* @memberof AlgoBlock | ||
*/ | ||
|
||
upgradeState: any; | ||
|
||
/** | ||
* (optional) | ||
* @type {any} | ||
* @memberof AlgoBlock | ||
*/ | ||
upgradeVote: any; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
/** | ||
* | ||
* @export | ||
* @interface AlgoTx | ||
*/ | ||
export interface AlgoTx { | ||
/** | ||
* [rc] rewards applied to close-remainder-to account. | ||
* @type {number} | ||
* @memberof AlgoTx | ||
*/ | ||
closeRewards: number; | ||
|
||
/** | ||
* [ca]closing amount for transaction. | ||
* @type {number} | ||
* @memberof AlgoTx | ||
*/ | ||
closingAmount: number; | ||
|
||
/** | ||
* Round when the transaction was confirmed. | ||
* @type {number} | ||
* @memberof AlgoTx | ||
*/ | ||
confirmedRound: number; | ||
|
||
/** | ||
* [fee] Transaction fee. | ||
* @type {number} | ||
* @memberof AlgoTx | ||
*/ | ||
fee: number; | ||
|
||
/** | ||
* [fv] First valid round for this transaction. | ||
* @type {number} | ||
* @memberof AlgoTx | ||
*/ | ||
firstValid: number; | ||
|
||
/** | ||
* [gh] Hash of genesis block. | ||
* @type {string} | ||
* @memberof AlgoTx | ||
*/ | ||
|
||
genisisHash: string; | ||
|
||
/** | ||
* [gen] genesis block ID. | ||
* @type {string} | ||
* @memberof AlgoTx | ||
*/ | ||
genesisId: string; | ||
|
||
/** | ||
* Transaction ID. | ||
* @type {string} | ||
* @memberof AlgoTx | ||
*/ | ||
id: string; | ||
|
||
/** | ||
* Offset into the round where this transaction was confirmed. | ||
* @type {number} | ||
* @memberof AlgoTx | ||
*/ | ||
intraRoundOffset: number; | ||
|
||
/** | ||
* [lv] Last valid round for this transation. | ||
* @type {number} | ||
* @memberof AlgoTx | ||
*/ | ||
lastValid: number; | ||
|
||
/** | ||
* [note] Free form data. | ||
* @type {string} | ||
* @memberof AlgoTx | ||
*/ | ||
note: string; | ||
|
||
/** | ||
* optional | ||
* @type {any} | ||
* @memberof AlgoTx | ||
*/ | ||
paymentTransaction: any; | ||
|
||
/** | ||
* [rr] rewards applied to receiver account | ||
* @type {number} | ||
* @memberof AlgoTx | ||
*/ | ||
receiverRewards: number; | ||
|
||
/** | ||
* Time when the block this transaction is in was confirmed. | ||
* @type {number} | ||
* @memberof AlgoTx | ||
*/ | ||
roundTime: number; | ||
|
||
/** | ||
* [snd] Sender's address | ||
* @type {string} | ||
* @memberof AlgoTx | ||
*/ | ||
sender: string; | ||
|
||
/** | ||
* [rs] rewards applied to sender account | ||
* @type {number} | ||
* @memberof AlgoTx | ||
*/ | ||
senderRewards: number; | ||
|
||
/** | ||
* signature | ||
* @type {any} | ||
* @memberof AlgoTx | ||
*/ | ||
signature: any; | ||
|
||
/** | ||
* [type] Indicates what type of transaction this is. Different types have different fields. | ||
* | ||
* Valid types, and where their fields are stored: | ||
* [pay] payment-transaction | ||
* [keyreg] keyreg-transaction | ||
* [acfg] asset-config-transaction | ||
* [axfer] asset-transfer-transaction | ||
* [afrz] asset-freeze-transaction | ||
* [appl] application-transaction | ||
* | ||
* @type {string} | ||
* @memberof AlgoTx | ||
*/ | ||
txType: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.