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

t #89

Closed
wants to merge 10 commits into from
12 changes: 12 additions & 0 deletions Be/passthrough/passtrough.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,18 @@ res.header('Access-Control-Allow-Origin', SERVING);
}
}
);
//Endpoint /txs/:hash/withdrawals
app.get('/txs/:hash/withdrawals', async (req, res) => {
res.header('Access-Control-Allow-Origin', SERVING);
const { hash } = req.params;
try {
const response = await axios.get(`${blockfrostApis[req.headers.project_id]}/txs/${hash}/withdrawals`, { headers: { project_id: blockfrostApiKeys[req.headers.project_id] } });
res.json(response.data);
}catch (error) {
const statusCode = error.response.status || 500;
res.status(statusCode).json({ error: error.message });
}
});

//Endpoint :txs/${txHash}
app.get('/txs/:txHash', async (req, res) => {
Expand Down
4 changes: 2 additions & 2 deletions Fe/src/components/Minting/minting.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ import { toast } from 'react-toastify';class Minting extends React.Component {
}
}

async newLucidInstance(settings) {
getNewLucidInstance(settings);
async newLucidInstance(settings){
return getNewLucidInstance(settings);
}


Expand Down
45 changes: 36 additions & 9 deletions Fe/src/helpers/TransactionHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async function getTransactionHistory(address, settings, page=0 , limit = 10){
}else if ( settings.metadataProvider === "Blockfrost"){
const api = settings.api.url
const response = await fetch(
`${api}/addresses/${address}/transactions?order=acs`,
`${api}/addresses/${address}/transactions`,
{
method: "GET",
headers: {
Expand All @@ -47,7 +47,7 @@ async function getTransactionHistory(address, settings, page=0 , limit = 10){
if (json.error)
return []
json.sort((a,b) => b.block_height - a.block_height)
return await getTransactionDetails(json.slice(page*limit,(page+1)*limit), settings)
return await getTransactionDetails(json.slice(page*limit,(page+1)*limit), settings, address)
}else if(settings.metadataProvider === "Maestro")
{
const MaestroUrl = `https://${settings.network}.gomaestro-api.org`
Expand All @@ -72,12 +72,17 @@ async function getTransactionHistory(address, settings, page=0 , limit = 10){

}

async function getTransactionDetails(transactionIds, settings){
async function getTransactionDetails(transactionIds, settings, address){
let transactionInfo = {...JSON.parse(localStorage.getItem('transactionInfo'))};

const lucid = await Lucid.new(
null,
settings.network
);


// I want to refresh every 15 minutes
let fullTransactionsInfo = transactionIds.map( async (transactionId) => {
if (transactionInfo[transactionId.tx_hash] && transactionInfo[transactionId.tx_hash].provider === settings.metadataProvider ){
if (transactionInfo[transactionId.tx_hash] && transactionInfo[transactionId.tx_hash].provider === settings.metadataProvider && Date.now() - transactionInfo[transactionId.tx_hash].fetch_time < 900000){
return (transactionInfo[transactionId.tx_hash])
}
else
Expand Down Expand Up @@ -138,10 +143,35 @@ async function getTransactionDetails(transactionIds, settings){
}
}
);
let withdraw
try{
const withdrawResponce = await fetch(
`${api}/txs/${transactionId.tx_hash}/withdrawals`,
{

method: "GET",
headers: {
project_id: settings.api.projectId
}
}
)
withdraw = await withdrawResponce.json()
}catch(e){
console.log(e)
withdraw = []
}
let fullTransactionInfo = {...transactionId};
fullTransactionInfo.utxos = await response.json();
transactionInfo[transactionId.tx_hash] = fullTransactionInfo
transactionInfo[transactionId.tx_hash].fetch_time = Date.now()
transactionInfo[transactionId.tx_hash].withdrawals = {}
transactionInfo[transactionId.tx_hash].withdrawals.amount = 0
withdraw.forEach( w => {
if(lucid.utils.getAddressDetails(address).stakeCredential.hash === lucid.utils.getAddressDetails(w.address).stakeCredential.hash) {
transactionInfo[transactionId.tx_hash].withdrawals.amount += Number(w.amount)}
})

// transactionInfo[transactionId.tx_hash].withdrawals = withdrawResponce.ok ? await withdrawResponce.json() : null
transactionInfo[transactionId.tx_hash].provider = "Blockfrost"
localStorage.setItem('transactionInfo', JSON.stringify(transactionInfo));
return transactionInfo[transactionId.tx_hash]
Expand All @@ -156,10 +186,7 @@ async function getTransactionDetails(transactionIds, settings){
} },
).then((res) => res.json());

const lucid = await Lucid.new(
null,
settings.network
);


let fullTransactionInfo = {...transactionId};
fullTransactionInfo.utxos = {}
Expand Down
11 changes: 5 additions & 6 deletions Fe/src/helpers/newLucid.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import { Lucid, Blockfrost ,Kupmios, Maestro} from "lucid-cardano";
async function getNewLucidInstance(settings){
return new Promise(async (resolve, reject) => {
const provider = getProvider(settings);

let lucid = await Lucid.new(
provider,
settings.network,
);
resolve(lucid);
let lucid = await Lucid.new(
provider,
settings.network,
);
resolve(lucid);

});
}
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
# BroClanWallet
Bro Clan is a multisig Wallet for the Cardano ecosystem.

## Running BroClan:


This is the monorepo of the software that runs The [BroClan Multisig Wallet](https://broclan.io)

You can run access this app via our servise on broclan.io
## Running BroClan:



We also provide dockerfiles and docker Images for all components.

Expand Down