Skip to content

Commit

Permalink
Elrond - fixing (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
isra67 authored Aug 17, 2021
1 parent 1d8f8ff commit 8733605
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 1,104 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tatumio/tatum",
"version": "1.21.4",
"version": "1.21.5",
"description": "Tatum API client allows browsers and Node.js clients to interact with Tatum API.",
"main": "dist/src/index.js",
"repository": "https://github.com/tatumio/tatum-js",
Expand Down Expand Up @@ -32,7 +32,6 @@
"@binance-chain/javascript-sdk": "^4.1.1",
"@celo-tools/celo-ethers-wrapper": "0.0.5",
"@cityofzion/neon-js": "^4.8.0",
"@elrondnetwork/erdjs": "^6.4.0",
"@emurgo/cardano-serialization-lib-nodejs": "^6.0.0",
"@harmony-js/crypto": "^0.1.56",
"@onflow/config": "^0.0.2",
Expand Down
6 changes: 0 additions & 6 deletions src/model/response/egld/EgldBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { EgldTransaction } from './EgldTx'
export interface EgldShardBlock {
hash: string
nonce: number
round: number
shard: number
}

Expand All @@ -22,9 +21,4 @@ export interface EgldBlock {
numTxs: number
shardBlocks: EgldShardBlock[]
transactions: EgldTransaction[]
accumulatedFees: string
developerFees: string
accumulatedFeesInEpoch: string
developerFeesInEpoch: string
status: string
}
28 changes: 23 additions & 5 deletions src/model/response/egld/EgldTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,27 @@
* @interface EgldTransaction
*/

export interface EgldReceipt {
value: number
sender: string
data: string
txHash: string
}

export interface EgldSmartContractResult {
hash: string
nonce: number
value: number
receiver: string
sender: string
data: string
prevTxHash: string
originalTxHash: string
gasLimit: number
gasPrice: number
callType: number
}

export interface EgldTransaction {
type: string
nonce: number
Expand All @@ -20,14 +41,11 @@ export interface EgldTransaction {
destinationShard: number
blockNonce: number
blockHash: string
notarizedAtSourceInMetaNonce: number
NotarizedAtSourceInMetaHash: string
notarizedAtDestinationInMetaNonce: number
notarizedAtDestinationInMetaHash: string
miniblockType: string
miniblockHash: string
timestamp: number
status: string
hyperblockNonce: number
hyperblockHash: string
receipt: EgldReceipt
smartContractResults: EgldSmartContractResult[]
}
24 changes: 12 additions & 12 deletions src/transaction/egld.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const egldGetGasPrice = async (): Promise<number> => {
/**
* Estimate Gas limit for the transaction.
*/
const egldGetGasLimit = async (tx: EgldSendTransaction): Promise<number> => {
export const egldGetGasLimit = async (tx: EgldSendTransaction): Promise<number> => {
// TODO: use this as TATUM API endpoint
// const gasStationUrl = 'https://api.elrond.com';
// // const gasStationUrl = await getEgldClient();
Expand All @@ -68,15 +68,15 @@ const egldGetGasLimit = async (tx: EgldSendTransaction): Promise<number> => {
return new BigNumber((await egldEstimateGas(tx)) || 50000).toNumber()
}

/**
* Get account nonce
*/
const egldGetAccountNonce = async (from: string): Promise<number> => {
// TODO: use this as TATUM API endpoint
// const {data} = await axios.get(`${ELROND_V3_ENDPOINT}/address/${from}/nonce`);
// return data?.nonce;
return await egldGetTransactionsCount(from)
}
// /**
// * Get account nonce
// */
// const egldGetAccountNonce = async (from: string): Promise<number> => {
// // TODO: use this as TATUM API endpoint
// // const {data} = await axios.get(`${ELROND_V3_ENDPOINT}/address/${from}/nonce`);
// // return data?.nonce;
// return await egldGetTransactionsCount(from)
// }

/**
* Sign transaction
Expand Down Expand Up @@ -597,7 +597,7 @@ export const prepareEgldSpecialRoleEsdtOrNftSignedTransaction = async (body: Egl
* @param provider url of the EGLD Server to connect to. If not set, default public server will be used.
* @returns transaction data to be broadcast to blockchain.
*/
export const prepareEgldTransferFreezeOrWipeOrOwvershipEsdtSignedTransaction = async (body: EgldEsdtTransaction, provider?: string) => {
export const prepareEgldFreezeOrWipeOrOwvershipEsdtSignedTransaction = async (body: EgldEsdtTransaction, provider?: string) => {
await validateBody(body, EgldEsdtTransaction)
const {
fromPrivateKey,
Expand Down Expand Up @@ -641,7 +641,7 @@ export const prepareEgldControlChangesEsdtSignedTransaction = async (body: EgldE
const tx: TransactionConfig = {
from: 0,
to: ESDT_SYSTEM_SMART_CONTRACT_ADDRESS,
data: await prepareEgldEsdtSpecialRoleData(data),
data: await prepareEgldEsdtControlChangesData(data),
}

return await prepareSignedTransactionAbstraction(client, tx, signatureId, fromPrivateKey, { gasLimit, gasPrice: fee?.gasPrice as string } as Fee)
Expand Down
Loading

0 comments on commit 8733605

Please sign in to comment.