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Y,EACZ,YAAa,EACb,UAAW,EACX,sBAAuB,EACvB,YAAa,GAGjB,aADuB,MAAM,OAAO,EAAK,EAE7C,EAEA,iBAAkB,eAAgB,GAC9B,MAAM,EAAM,eAAiB,UAAU,yCACjC,EAAS,CACX,YAAa,GAGjB,aADuB,MAAM,OAAO,EAAK,EAE7C,EAEA,WAAY,eAAgB,EAAe,EAAM,EAAM,GACnD,MAAM,EAAM,eAAiB,UAAU,2BACjC,EAAW,IAAI,SACrB,EAAS,OAAO,aAAc,GAC9B,EAAS,OAAO,cAAe,GAC/B,EAAS,OAAO,YAAa,GAC7B,EAAS,OAAO,cAAe,KAAK,UAAU,IAE9C,aADuB,MAAM,OAAO,EAAK,EAE7C,EAEA,0BAA2B,WAE3B,EAIA,2BAA4B,SAAU,EAAI,EAAY,EAAO,GACzD,MAAM,EAAU,CACZ,KAAM,EACN,MAAO,GAEX,OAAO,KAAK,qBAAqB,EAAI,2BAA4B,KAAK,UAAU,GAAU,EAC9F,EAEA,OAAQ,OAAO,OACf,WAAY,OAAO,WACnB,aAAc,OAAO,aACrB,MAAO,OAAO,MACd,YAAa,OAAO,YACpB,kBAAmB,OAAO,kBAC1B,aAAc,OAAO,aACrB,iBAAkB,OAAO,iBACzB,mBAAoB,OAAO,mBAC3B,MAAO,MACP,gBAAiB","file":"/npm/0chain@1.3.14/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/0chain@1.3.14/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/* \n* This file is part of the 0chain js-client distribution (https://github.com/0chain/js-client-sdk).\n* Copyright (c) 2018 0chain LLC.\n* \n* 0chain js-client program is free software: you can redistribute it and/or modify  \n* it under the terms of the GNU General Public License as published by  \n* the Free Software Foundation, version 3.\n*\n* This program is distributed in the hope that it will be useful, but \n* WITHOUT ANY WARRANTY; without even the implied warranty of \n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU \n* General Public License for more details.\n*\n* You should have received a copy of the GNU General Public License \n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*/\n\n// const nacl = require('tweetnacl');\nconst sha3 = require('js-sha3');\nconst bip39 = require('bip39');\nvar BlueBirdPromise = require(\"bluebird\");\n\n//local import \nconst utils = require('./utils');\nvar models = require('./models');\n\"use strict\";\n\nvar miners, proxyServerUrl, sharders, clusterName, version;\nvar preferredBlobbers, tokenLock;\nvar readPrice, writePrice;\nlet bls;\n\n// const StorageSmartContractAddress = \"6dba10422e368813802877a85039d3985d96760ed844092319743fb3a76712d7\";\n// const FaucetSmartContractAddress = \"6dba10422e368813802877a85039d3985d96760ed844092319743fb3a76712d3\";\n// const InterestPoolSmartContractAddress = \"6dba10422e368813802877a85039d3985d96760ed844092319743fb3a76712d9\";\n// const MinerSmartContractAddress = \"6dba10422e368813802877a85039d3985d96760ed844092319743fb3a76712d1\";\n\nconst MultiSigSmartContractAddress = '27b5ef7120252b79f9dd9c05505dd28f328c80f6863ee446daede08a84d651a7';\nconst VestingSmartContractAddress = '2bba5b05949ea59c80aed3ac3474d7379d3be737e8eb5a968c52295e48333ead';\nconst FaucetSmartContractAddress = '6dba10422e368813802877a85039d3985d96760ed844092319743fb3a76712d3';\nconst ZRC20SmartContractAddress = '6dba10422e368813802877a85039d3985d96760ed844092319743fb3a76712d5';\nconst StorageSmartContractAddress = '6dba10422e368813802877a85039d3985d96760ed844092319743fb3a76712d7';\nconst MinerSmartContractAddress = '6dba10422e368813802877a85039d3985d96760ed844092319743fb3a76712d9';\nconst InterestPoolSmartContractAddress = 'cf8d0df9bd8cc637a4ff4e792ffe3686da6220c45f0e1103baa609f3f1751ef4';\n\nconst Endpoints = {\n    REGISTER_CLIENT: 'v1/client/put',\n    PUT_TRANSACTION: 'v1/transaction/put',\n\n    GET_RECENT_FINALIZED: \"v1/block/get/recent_finalized\",\n    GET_LATEST_FINALIZED: \"v1/block/get/latest_finalized\",\n    GET_CHAIN_STATS: \"v1/chain/get/stats\",\n    GET_BLOCK_INFO: \"v1/block/get\",\n    CHECK_TRANSACTION_STATUS: \"v1/transaction/get/confirmation\",\n    GET_BALANCE: \"v1/client/get/balance\",\n    GET_SCSTATE: \"v1/scstate/get\",\n\n    // SC REST\n    SC_REST: \"v1/screst/\",\n    SC_REST_ALLOCATION: \"v1/screst/\" + StorageSmartContractAddress + \"/allocation\",\n    SC_REST_ALLOCATIONS: \"v1/screst/\" + StorageSmartContractAddress + \"/allocations\",\n    SC_REST_READPOOL_STATS: \"v1/screst/\" + StorageSmartContractAddress + \"/getReadPoolStat\",\n    SC_REST_WRITEPOOL_STATS: \"v1/screst/\" + StorageSmartContractAddress + \"/getWritePoolStat\",\n    SC_BLOBBER_STATS: \"v1/screst/\" + StorageSmartContractAddress + \"/getblobbers\",\n\n    GET_LOCKED_TOKENS: \"v1/screst/\" + InterestPoolSmartContractAddress + \"/getPoolsStats\",\n    GET_USER_POOLS: \"v1/screst/\" + MinerSmartContractAddress + \"/getUserPools\",\n\n    //BLOBBER\n    ALLOCATION_FILE_LIST: \"/v1/file/list/\",\n    FILE_STATS_ENDPOINT: \"/v1/file/stats/\",\n    OBJECT_TREE_ENDPOINT: \"/v1/file/objecttree/\",\n    FILE_META_ENDPOINT: \"/v1/file/meta/\",\n    RENAME_ENDPOINT: \"/v1/file/rename/\",\n    COPY_ENDPOINT: \"/v1/file/copy/\",\n    UPLOAD_ENDPOINT: \"/v1/file/upload/\",\n    COMMIT_ENDPOINT: \"/v1/connection/commit/\",\n    COPY_ENDPOINT: \"/v1/file/copy/\",\n    OBJECT_TREE_ENDPOINT: '/v1/file/objecttree/',\n    COMMIT_META_TXN_ENDPOINT: \"/v1/file/commitmetatxn/\",\n\n    PROXY_SERVER_UPLOAD_ENDPOINT: \"/upload\",\n    PROXY_SERVER_DOWNLOAD_ENDPOINT: \"/download\",\n    PROXY_SERVER_SHARE_ENDPOINT: \"/share\",\n    PROXY_SERVER_RENAME_ENDPOINT: \"/rename\",\n    PROXY_SERVER_COPY_ENDPOINT: \"/copy\",\n    PROXY_SERVER_DELETE_ENDPOINT: \"/delete\",\n    PROXY_SERVER_MOVE_ENDPOINT: \"/move\",\n    PROXY_SERVER_ENCRYPT_PUBLIC_KEY_ENDPOINT: \"/publicEncryptionKey\"\n}\n\nconst TransactionType = {\n    SEND: 0, // A transaction to send tokens to another account, state is maintained by account\n    DATA: 10, // A transaction to just store a piece of data on the block chain\n    // STORAGE_WRITE : 101, // A transaction to write data to the blobber\n    // STORAGE_READ  : 103,// A transaction to read data from the blobber\n    SMART_CONTRACT: 1000 // A smart contract transaction type\n}\n\nmodule.exports = {\n\n    BlockInfoOptions: {\n        HEADER: \"header\",\n        FULL: \"full\"\n    },\n\n    AllocationTypes: {\n        FREE: \"Free\",\n        PREMIUM: \"Premium\",\n        MONETIZE: \"Monetize\"\n    },\n\n    /////////////SDK Stuff below //////////////\n    init: function init(configObject, bls_wasm) {\n        var config;\n        if (typeof configObject != \"undefined\" && configObject.hasOwnProperty('miners') &&\n            configObject.hasOwnProperty('sharders')\n            && configObject.hasOwnProperty('clusterName')\n            && configObject.hasOwnProperty('proxyServerUrl')) {\n            config = configObject;\n        }\n        else {\n            const jsonContent = {\n                \"miners\": [\n                    \"http://localhost:7071/\",\n                    \"http://localhost:7072/\",\n                    \"http://localhost:7073/\"\n                ],\n                \"sharders\": [\n                    \"http://localhost:7171/\"\n                ],\n                \"preferredBlobbers\": [\n                    \"http://localhost:7051/\",\n                    \"http://localhost:7052/\",\n                    \"http://localhost:7053/\",\n                    \"http://localhost:7054/\"\n                ],\n                \"readPrice\": {\n                    \"min\": 0,\n                    \"max\": 0\n                },\n                \"writePrice\": {\n                    \"min\": 0,\n                    \"max\": 0\n                },\n                \"tokenLock\": 0,\n                \"proxyServerUrl\": \"http://localhost:9082\",\n                \"transaction_timeout\": 15,\n                \"clusterName\": \"local\"\n            };\n            config = jsonContent;\n        }\n        bls = bls_wasm;\n        bls.init(bls.BN254)\n        miners = config.miners;\n        sharders = config.sharders;\n        clusterName = config.clusterName;\n        proxyServerUrl = config.proxyServerUrl\n        preferredBlobbers = config.preferredBlobbers\n        readPrice = config.readPrice\n        writePrice = config.writePrice\n        tokenLock = config.tokenLock\n        version = \"0.8.0\";\n    },\n\n    getSdkMetadata: () => {\n        return \"version: \" + version + \" cluster: \" + clusterName;\n    },\n\n    getChainStats: () => {\n        return getInformationFromRandomSharder(Endpoints.GET_CHAIN_STATS, {}, (rawData) => {\n            return new models.ChainStats(rawData)\n        });\n    },\n\n    getRecentFinalized: () => {\n        return getInformationFromRandomSharder(Endpoints.GET_RECENT_FINALIZED, {}, (rawData) => {\n            var blocks = [];\n            for (let bs of rawData) {\n                blocks.push(new models.BlockSummary(bs));\n            }\n            return blocks;\n        });\n    },\n\n    getLatestFinalized: () => {\n        return getInformationFromRandomSharder(Endpoints.GET_LATEST_FINALIZED, {}, (rawData) => {\n            return new models.BlockSummary(rawData)\n        });\n    },\n\n    getBlockInfoByHash: function getBlockInfoByHash(hash, options = this.BlockInfoOptions.HEADER) {\n        const blockInfoOptions = this.BlockInfoOptions;\n        return getInformationFromRandomSharder(Endpoints.GET_BLOCK_INFO, { block: hash, content: options }, (rawData) => {\n            if (options == blockInfoOptions.HEADER) {\n                return new models.BlockSummary(rawData.header);\n            } else {\n                return new models.Block(rawData.block);\n            }\n        });\n    },\n\n    getBlockInfoByRound: function getBlockInfoByRound(round, options = this.BlockInfoOptions.HEADER) {\n        const blockInfoOptions = this.BlockInfoOptions;\n        return getInformationFromRandomSharder(Endpoints.GET_BLOCK_INFO, { round: round, content: options }, (rawData) => {\n            if (options == blockInfoOptions.HEADER) {\n                return new models.BlockSummary(rawData.header);\n            } else {\n                return new models.Block(rawData.block);\n            }\n        });\n    },\n\n    getBalance: (client_id) => {\n        return new Promise(async function (resolve, reject) {\n            utils.getConsensusedInformationFromSharders(sharders, Endpoints.GET_BALANCE, { client_id: client_id })\n                .then((res) => {\n                    resolve(res);\n                })\n                .catch((error) => {\n                    if (error.error === \"value not present\") {\n                        resolve({\n                            balance: 0\n                        })\n                    }\n                    else {\n                        reject(error);\n                    }\n                })\n        });\n        // return getInformationFromRandomSharder(Endpoints.GET_BALANCE, { client_id: client_id });\n    },\n\n    getLockedTokens: (client_id) => {\n        return new Promise(async function (resolve, reject) {\n            utils.getConsensusedInformationFromSharders(sharders, Endpoints.GET_LOCKED_TOKENS, { client_id: client_id })\n                .then((res) => {\n                    resolve(res);\n                })\n                .catch((error) => {\n                    resolve({\n                        locked_tokens: []\n                    })\n                })\n        });\n    },\n\n    getUserPools: (client_id) => {\n        return new Promise(async function (resolve, reject) {\n            utils.getConsensusedInformationFromSharders(sharders, Endpoints.GET_USER_POOLS, { client_id: client_id })\n                .then((res) => {\n                    if (res.pools === null) {\n                        resolve({\n                            pools: []\n                        })\n                    }\n                    resolve(res);\n                })\n                .catch((error) => {\n                    resolve({\n                        pools: []\n                    })\n                })\n        });\n    },\n\n    checkTransactionStatus: (hash) => {\n\n        return utils.getConsensusedInformationFromSharders(sharders, Endpoints.CHECK_TRANSACTION_STATUS, { hash: hash }, (rawData) => {\n            return new models.TransactionDetail(rawData)\n        });\n\n        // return getInformationFromRandomSharder(Endpoints.CHECK_TRANSACTION_STATUS, { hash: hash }, (rawData) => {\n        //     return new models.TransactionDetail(rawData)\n        // });\n    },\n\n    createKeys: () => {\n        const mnemonic = bip39.generateMnemonic(256)\n        const keys = createWalletKeys(mnemonic)\n        return {\n            ...keys,\n            mnemonic\n        }\n    },\n\n  registerClient: async function registerClient(){\n    const mnemonic = bip39.generateMnemonic(256);\n    const wallet = await createWallet(mnemonic);\n    //creating read pool\n    await this.createReadPool(wallet)\n    return wallet;\n  },\n\n  createReadPool: async function createReadPool(ae){\n    const payload = {\n      name: \"new_read_pool\",\n      input: null\n    }\n    return this.executeSmartContract(\n      ae,\n      undefined,\n      JSON.stringify(payload)\n    );\n  },\n  \n    validateMnemonic: (mnemonic) => {\n        return bip39.validateMnemonic(mnemonic)\n    },\n\n    restoreWallet: (mnemonic) => {\n        return createWallet(mnemonic);\n    },\n\n    storeData: (ae, payload) => {\n        const toClientId = \"\";\n        return submitTransaction(ae, toClientId, 0, payload, TransactionType.DATA);\n    },\n\n    sendTransaction: (ae, toClientId, val, note) => {\n        return submitTransaction(ae, toClientId, val, note, TransactionType.SEND);\n    },\n\n    //Smart contract address need to pass in toClientId\n    executeSmartContract: (ae, to_client_id, payload, transactionValue = 0) => {\n        const toClientId = typeof to_client_id === \"undefined\" ? StorageSmartContractAddress : to_client_id;\n        return submitTransaction(ae, toClientId, transactionValue, payload, TransactionType.SMART_CONTRACT);\n    },\n\n    getStorageSmartContractStateForKey: (keyName, keyvalue) => {\n        return utils.getConsensusedInformationFromSharders(sharders, Endpoints.GET_SCSTATE, { key: keyName + \":\" + keyvalue, sc_address: StorageSmartContractAddress });\n        // return getInformationFromRandomSharder(Endpoints.GET_SCSTATE, { key: keyName+\":\"+keyvalue, sc_address: StorageSmartContractAddress  });\n    },\n\n  allocateStorage: function allocateStorage(\n    ae,\n    data_shards = 2,\n    parity_shards = 2,\n    size = 2147483648,\n    lockTokens = tokenLock,\n    expiration_date = new Date(),\n    preferred_blobbers = null\n  ) {\n      \n    Date.prototype.addDays = function(days) {\n        var date = new Date(this.valueOf());\n        date.setDate(date.getDate() + days);\n        return date;\n    }\n    \n    expiration_date = Math.floor(expiration_date.addDays(30).getTime()/1000)\n    \n    const payload = {\n      name: \"new_allocation_request\",\n      input: {\n        data_shards: data_shards,\n        parity_shards: parity_shards,\n        owner_id: ae.id,\n        owner_public_key: ae.public_key,\n        size: size,\n        expiration_date: expiration_date,\n        read_price_range: readPrice,\n        write_price_range: writePrice,\n        max_challenge_completion_time: 3600000000000,\n        preferred_blobbers: preferred_blobbers,\n      },\n    };\n\n    return this.executeSmartContract(\n      ae,\n      undefined,\n      JSON.stringify(payload),\n      lockTokens\n    );\n  },\n\n    updateAllocation: function updateAllocation(ae, allocation_id, expiration_date = 2592000, size = 2147483648, tokens) {\n        const payload = {\n            name: \"update_allocation_request\",\n            input: {\n                owner_id: ae.id,\n                id: allocation_id,\n                size: size,\n                expiration_date: expiration_date\n            }\n        }\n        return this.executeSmartContract(ae, undefined, JSON.stringify(payload), tokens);\n    },\n\n    allocationInfo: function allocationInfo(id) {\n        return utils.getConsensusedInformationFromSharders(sharders, Endpoints.SC_REST_ALLOCATION, { allocation: id });\n    },\n\n    listAllocations: function listAllocations(id) {\n        return utils.getConsensusedInformationFromSharders(sharders, Endpoints.SC_REST_ALLOCATIONS, { client: id })\n    },\n\n    readPoolInfo: function readPoolInfo(id) {\n        return utils.getConsensusedInformationFromSharders(\n            sharders, \n            Endpoints.SC_REST_READPOOL_STATS, \n            { client_id: id }\n        )\n    },\n\n    writePoolInfo: function writePoolInfo(id) {\n        return utils.getConsensusedInformationFromSharders(\n            sharders,\n            Endpoints.SC_REST_WRITEPOOL_STATS,\n            { client_id: id }\n        )\n    },\n\n    createLockTokens: async function (ae, val, durationHr, durationMin) {\n        const payload = {\n            name: \"lock\",\n            input: {\n                duration: `${durationHr}h${durationMin}m`\n            }\n        }\n        return this.executeSmartContract(ae, InterestPoolSmartContractAddress, JSON.stringify(payload), val)\n    },\n\n\n    // duration, allocID, blobberID,\n    // \t\tzcncore.ConvertToValue(tokens), zcncore.ConvertToValue(fee)\n    \n    lockTokensInReadPool: async function(ae, allocation, duration, tokens){\n        const payload = {\n            name: \"read_pool_lock\",\n            input: {\n                duration: duration,\n                allocation_id: allocation\n            }\n        }\n        return this.executeSmartContract(ae, undefined, JSON.stringify(payload), tokens)\n    },\n\n    lockTokensInWritePool: async function(ae, allocation, duration, tokens){\n        const payload = {\n            name: \"write_pool_lock\",\n            input: {\n                duration: duration,\n                allocation_id: allocation\n            }\n        }\n        return this.executeSmartContract(ae, undefined, JSON.stringify(payload), tokens)\n    },\n\n    unlockTokens: async function (ae, poolId) {\n        const payload = {\n            name: \"unlock\",\n            input: {\n                pool_id: poolId\n            }\n        }\n        return this.executeSmartContract(ae, InterestPoolSmartContractAddress, JSON.stringify(payload))\n    },\n\n    getAllBlobbers: function getAllBlobbers() {\n        return utils.getConsensusedInformationFromSharders(sharders, Endpoints.SC_BLOBBER_STATS, {});\n    },\n\n    getAllocationFilesFromPath: async function (allocation_id, path, client_id) {        \n        var blobber_url;\n        \n        const completeAllocationInfo = await this.allocationInfo(allocation_id);\n        blobber = completeAllocationInfo.blobbers[0].url;\n        blobber_url = blobber + Endpoints.ALLOCATION_FILE_LIST + allocation_id\n\n        const list = await utils.getReqBlobbers(blobber_url, {path: path}, client_id);\n        \n        return list\n        // return new Promise(async function (resolve, reject) {\n\n            // var blobber_url, data;\n            // var files = [];\n            \n            // for (let blobber of blobber_list) {\n            //     try {\n            //         blobber = completeAllocationInfo.blobbers[0].url;\n            //         blobber_url = blobber + Endpoints.ALLOCATION_FILE_LIST + allocation_id;\n            //         data = await utils.getReq(blobber_url, {path: path});\n    \n            //         if (data.entries != null && data.entries.length > 0) {\n    \n            //             for (let file_data of data.entries) {\n            //                 /* files not contains the element we're looking for so add */\n            //                 if (!files.some(e => e.LookupHash === file_data.LookupHash)) {\n            //                     files.push(file_data);\n            //                 }\n            //             }\n            //         }\n            //     }\n            //     catch (error) {\n            //         console.log(error);\n            //     }\n            // }\n        //     console.log('-----files-----', files)\n        //     resolve(files);\n\n        // });\n    },\n\n    getFileMetaDataFromPath: async function (allocation_id, path, client_id) {\n        const completeAllocationInfo = await this.allocationInfo(allocation_id);\n        const blobber = completeAllocationInfo.blobbers[0].url;\n        return new Promise(async function (resolve, reject) {\n            const blobber_url = blobber + Endpoints.FILE_META_ENDPOINT + allocation_id;\n            const response = await utils.postReqToBlobber(blobber_url, {}, { path: path }, client_id);\n            if (response.status === 200) {\n                const res = {\n                    ...response.data,\n                    blobbers: completeAllocationInfo.blobbers\n                }\n                resolve(res)\n                } else {\n                reject('Not able to fetch file details from blobbers')\n            }\n        });\n    },\n\n    getFileStatsFromPath: async function (allocation_id, path, client_id) {\n        const completeAllocationInfo = await this.allocationInfo(allocation_id);\n        const blobber = completeAllocationInfo.blobbers[0].url;\n        return new Promise(async function (resolve, reject) {\n            const blobber_url = blobber + Endpoints.FILE_STATS_ENDPOINT + allocation_id;\n            const response = await utils.postReqToBlobber(blobber_url, {}, { path: path }, client_id);\n            if (response.status === 200) {\n                resolve(response.data)\n            } else {\n                reject('Not able to fetch file stats from blobbers')\n            }\n        });\n    },\n\n    getFileMetaDataFromPathHash: async function (allocation_id, path_hash, client_id) {\n        const completeAllocationInfo = await this.allocationInfo(allocation_id);\n        const blobber = completeAllocationInfo.blobbers[0].url;\n        return new Promise(async function (resolve, reject) {\n            const blobber_url = blobber + Endpoints.FILE_META_ENDPOINT + allocation_id;\n            const response = await utils.postReqToBlobber(blobber_url, {}, { path_hash: path_hash }, client_id);\n            if (response.status === 200) {\n                const res = {\n                    ...response.data,\n                    blobbers: completeAllocationInfo.blobbers\n                }\n                resolve(res)\n            } else {\n                reject('Not able to fetch file details from blobbers')\n            }\n        });\n    },\n\n    commitMetaTransaction: async function (ae, crudType, allocation_id, path, auth_ticket = '', metadata = '') {\n        if (metadata.length === 0) {\n            if (path.length > 0) {\n                metadata = await this.getFileMetaDataFromPath(allocation_id, path, ae.id)\n            } else if (auth_ticket.length > 0) {\n                const at = utils.parseAuthTicket(auth_ticket)\n                metadata = await this.getFileMetaDataFromPathHash(allocation_id, at.file_path_hash, ae.id)\n            }\n        }\n        const { name, type, lookup_hash, actual_file_hash, mimetype, size, encrypted_key } = metadata\n        const payload = {\n            CrudType: crudType,\n            MetaData: {\n                Name: name,\n                Type: type,\n                Path: path,\n                LookupHash: lookup_hash,\n                Hash: actual_file_hash,\n                MimeType: mimetype,\n                Size: size,\n                EncryptedKey: encrypted_key\n            }\n        }\n        const submitResponse = await submitTransaction(ae, '', 0, JSON.stringify(payload));\n        const transactionData = JSON.parse(submitResponse.transaction_data)        \n        await this.updateMetaCommitToBlobbers(submitResponse.hash, allocation_id, transactionData.MetaData.LookupHash, ae.id);\n        return submitResponse\n    },\n\n    updateMetaCommitToBlobbers: async function(transaction_hash, allocation, lookup_hash, client_id){\n        const completeAllocationInfo = await this.allocationInfo(allocation);\n        blobber_list = completeAllocationInfo.blobbers.map(blobber => {\n            return blobber.url\n        });\n\n        return new Promise(async (resolve, reject) => {\n            for (let blobber of blobber_list) {\n                try {\n                    blobber_url = blobber + Endpoints.COMMIT_META_TXN_ENDPOINT + allocation;\n                    const formData = new FormData();\n                    formData.append('path_hash', lookup_hash);\n                    formData.append('txn_id', transaction_hash);\n                    await utils.postReqToBlobber(blobber_url, formData, {}, client_id);\n                }\n                catch (error) {\n                    reject(error)\n                }\n            }\n            resolve()\n        })\n    },\n\n    uploadObject: async function (file, allocation_id, path, encrypt=false, client_json) {\n        const url = proxyServerUrl + Endpoints.PROXY_SERVER_UPLOAD_ENDPOINT\n        const formData = new FormData();\n        formData.append('file', file);\n        formData.append('allocation', allocation_id);\n        formData.append('remote_path', path);\n        formData.append('client_json', JSON.stringify(client_json))\n        formData.append('encrypt', encrypt)\n        const response = await utils.postReq(url, formData);\n        return response\n    },\n\n    downloadObject: async function (allocation_id, path, client_json) {\n        const url = proxyServerUrl + Endpoints.PROXY_SERVER_DOWNLOAD_ENDPOINT\n        const params = {\n            allocation: allocation_id,\n            remote_path: path,\n            client_json: client_json\n        }\n        const response = await utils.getDownloadReq(url, params);\n        window.location.href = response.request.responseURL\n    },\n\n    renameObject: async function (allocation_id, path, new_name, client_json) {\n        const url = proxyServerUrl + Endpoints.PROXY_SERVER_RENAME_ENDPOINT\n        const formData = new FormData();\n        formData.append('allocation', allocation_id);\n        formData.append('remote_path', path);\n        formData.append('new_name', new_name);\n        formData.append('client_json', JSON.stringify(client_json));\n        const response = await utils.putReq(url, formData);\n        return response\n    },\n\n    deleteObject: async function (allocation_id, path, client_json) {\n        const url = proxyServerUrl + Endpoints.PROXY_SERVER_DELETE_ENDPOINT\n        const formData = new FormData();\n        formData.append('allocation', allocation_id);\n        formData.append('remote_path', path);\n        formData.append('client_json', JSON.stringify(client_json));\n        const response = await utils.delReq(url, formData);\n        return response\n    },\n\n    copyObject: async function (allocation_id, path, dest, client_json) {\n        const url = proxyServerUrl + Endpoints.PROXY_SERVER_COPY_ENDPOINT\n        const formData = new FormData();\n        formData.append('allocation', allocation_id);\n        formData.append('remote_path', path);\n        formData.append('dest_path', dest);\n        formData.append('client_json', JSON.stringify(client_json));\n        const response = await utils.putReq(url, formData);\n        return response\n    },\n\n    shareObject: async function (allocation_id, path, client_id, public_encryption_key, client_json) {\n        const url = proxyServerUrl + Endpoints.PROXY_SERVER_SHARE_ENDPOINT\n        const params = {\n            allocation: allocation_id,\n            remote_path: path,\n            client_id: client_id,\n            public_encryption_key: public_encryption_key,\n            client_json: client_json\n        }\n        const response = await utils.getReq(url, params);\n        return response\n    },\n\n    encryptPublicKey: async function (client_json) {\n        const url = proxyServerUrl + Endpoints.PROXY_SERVER_ENCRYPT_PUBLIC_KEY_ENDPOINT\n        const params = {\n            client_json: client_json\n        }\n        const response = await utils.getReq(url, params);\n        return response\n    },\n\n    moveObject: async function (allocation_id, path, dest, client_json) {\n        const url = proxyServerUrl + Endpoints.PROXY_SERVER_MOVE_ENDPOINT\n        const formData = new FormData();\n        formData.append('allocation', allocation_id);\n        formData.append('remote_path', path);\n        formData.append('dest_path', dest);\n        formData.append('client_json', JSON.stringify(client_json)); \n        const response = await utils.putReq(url, formData);\n        return response\n    },\n\n    getAllocationDirStructure: function () {\n\n    },\n\n    /** Faucets Apis */\n\n    executeFaucetSmartContract: function (ae, methodName, input, transactionValue) {\n        const payload = {\n            name: methodName,\n            input: input\n        }\n        return this.executeSmartContract(ae, FaucetSmartContractAddress, JSON.stringify(payload), transactionValue);\n    },\n\n    Wallet: models.Wallet,\n    ChainStats: models.ChainStats,\n    BlockSummary: models.BlockSummary,\n    Block: models.Block,\n    Transaction: models.Transaction,\n    TransactionDetail: models.TransactionDetail,\n    Confirmation: models.Confirmation,\n    merkle_tree_path: models.merkle_tree_path,\n    VerificationTicket: models.VerificationTicket,\n    utils: utils,\n    TransactionType: TransactionType\n\n}\n\n///^^^^^^  End of expored functions   ^^^^^^////////\n\n// This method will try to get the information from any one of the sharder randomly\n// 1. shuffle the array \n// 2. try get the information from first sharder in the array. if its success will return immedialtely with response otherwise try to get from next sharder until it reach end of array\nasync function getInformationFromRandomSharder(url, params, parser) {\n\n    var errResp = [];\n\n    return new Promise(async (resolve, reject) => {\n        const urls = sharders.map(sharder => sharder + url);\n        const promises = urls.map(url => utils.getReq(url, params));\n        BlueBirdPromise.some(promises, 1)\n            .then(function (result) {\n                if (result[0].data) {\n                    const data = typeof parser !== \"undefined\" ? parser(result[0].data) : result[0].data;\n                    resolve(data);\n                }\n            })\n            .catch(BlueBirdPromise.AggregateError, function (err) {\n                reject({ error: err[0].code });\n                // err.forEach(function (e) {\n                //     console.error(e.stack);\n                // });\n            });\n\n\n        // for (let sharder of utils.shuffleArray(sharders)) {\n        //     //console.log(\"Calling sharder .....\", sharder)\n        //     try {\n        //         response = await utils.getReq(sharder + url, params); //sharder + url\n        //         //console.log(\"response from sharder\",response.data);\n        //         if (response.data) {\n        //             const data = typeof parser !== \"undefined\" ? parser(response.data) : response.data;\n        //             resolve(data);\n        //             break;\n        //         }\n        //     }\n        //     catch (error) {\n        //         errResp.push({ \"sharder\": sharder, \"error\": error });\n        //     }\n        // }\n        // reject(errResp);\n    });\n\n}\n\nfunction createWallet(mnemonic) {\n\n    const { client_id, public_key, private_key } = createWalletKeys(mnemonic)\n    var data = {};\n    data.public_key = public_key;\n    data.id = client_id;\n\n    return new Promise(function (resolve, reject) {\n        utils.doParallelPostReqToAllMiners(miners, Endpoints.REGISTER_CLIENT, data)\n            .then((response) => {\n                const myaccount = response;\n                myaccount.entity.secretKey = private_key;\n                myaccount.entity.mnemonic = mnemonic;\n                var ae = new models.Wallet(myaccount.entity);\n                resolve(ae);\n            })\n            .catch((error) => {\n                reject(error);\n            })\n    });\n}\n\nfunction createWalletKeys(mnemonic) {\n\n    const seed = bip39.mnemonicToSeed(mnemonic).slice(32);\n    const blsSecret = new bls.SecretKey();\n    blsSecret.setLittleEndianMod(seed)\n    const public_key = blsSecret.getPublicKey().serializeToHexStr();\n    const client_id = sha3.sha3_256(utils.hexStringToByte(public_key));\n    const private_key = blsSecret.serializeToHexStr();\n\n    return {\n        client_id,\n        public_key,\n        private_key\n    }\n\n}\n\nasync function submitTransaction(ae, toClientId, val, note, transaction_type) {\n\n    const hashPayload = sha3.sha3_256(note);\n    const ts = Math.floor(new Date().getTime() / 1000);\n\n    const hashdata = ts + \":\" + ae.id + \":\" + toClientId + \":\" + val + \":\" + hashPayload;\n\n    const hash = sha3.sha3_256(hashdata);\n    const bytehash = utils.hexStringToByte(hash);\n    const sec = new bls.SecretKey();\n    sec.deserializeHexStr(ae.secretKey);\n    const sig = sec.sign(bytehash);\n\n    var data = {};\n    data.client_id = ae.id;\n    data.transaction_value = val;\n    data.transaction_data = note;\n    data.transaction_type = transaction_type;\n    data.creation_date = ts;\n    data.to_client_id = toClientId;\n    data.hash = hash;\n\tdata.transaction_fee = 0;\n\tdata.signature = sig.serializeToHexStr();\n    data.version='1.0'\n    return new Promise(function (resolve, reject) {\n        utils.doParallelPostReqToAllMiners(miners, Endpoints.PUT_TRANSACTION, data)\n            .then((response) => {\n                resolve(new models.Transaction(response.entity));\n            })\n            .catch((error) => {\n                reject(error);\n            })\n    });\n}\n"]}