From 31dacd11a5b25db58bdb3252b7a20ef94daecb7b Mon Sep 17 00:00:00 2001 From: KOSASIH Date: Wed, 7 Aug 2024 14:18:33 +0700 Subject: [PATCH] Update index.js --- projects/DAPIO/client/index.js | 43 +++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/projects/DAPIO/client/index.js b/projects/DAPIO/client/index.js index fe9890553..0be837123 100644 --- a/projects/DAPIO/client/index.js +++ b/projects/DAPIO/client/index.js @@ -59,4 +59,45 @@ export async function updateDataFeed(dataFeedAddress, dataFeedName, dataFeedDesc return receipt; } -export async function delete +export async function deleteDataFeed(dataFeedAddress) { + const txCount = await web3.eth.getTransactionCount(); + const tx = { + from: '0x...YourEthereumAddress...', + to: dapioContract.address, + value: '0', + gas: '200000', + gasPrice: '20', + nonce: txCount, + data: dapioContract.methods.deleteDataFeed(dataFeedAddress).encodeABI(), + }; + + const signedTx = await web3.eth.accounts.signTransaction(tx, '0x...YourEthereumPrivateKey...'); + const receipt = await web3.eth.sendSignedTransaction(signedTx.rawTransaction); + + return receipt; +} + +export async function getDataFeed(dataFeedAddress) { + const dataFeed = await dapioContract.methods.getDataFeed(dataFeedAddress).call(); + return dataFeed; +} + +export async function getAiModel(aiModelAddress) { + const aiModel = await dapioContract.methods.getAiModel(aiModelAddress).call(); + return aiModel; +} + +export async function getAiModelForDataFeed(dataFeedAddress) { + const aiModelAddress = await dapioContract.methods.getAiModelForDataFeed(dataFeedAddress).call(); + return aiModelAddress; +} + +export async function getDataFeeds() { + const dataFeeds = await dapioContract.methods.getDataFeeds().call(); + return dataFeeds; +} + +export async function getAiModels() { + const aiModels = await dapioContract.methods.getAiModels().call(); + return aiModels; +}