UNPKG

@samudai_xyz/web3-sdk

Version:

## All in one web3 integrations for Samudai

666 lines (665 loc) 42.5 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.GnosisFetch = void 0; const networks_1 = require("../../gnosis/utils/networks"); const ethers_1 = require("ethers"); const types_1 = require("../../gnosis/utils/types"); const axios_1 = __importDefault(require("axios")); class GnosisFetch { constructor(safeAddress, chainId) { this.safeAddress = ''; this.txServiceUrl = ''; this.getExecutedTransactions = async () => { try { if (this.safeAddress !== '') { const res = await axios_1.default.get(`${this.txServiceUrl}/api/v1/safes/${this.safeAddress}/multisig-transactions/?executed=true`); return res.data; } else { throw new Error('Safe address not provided'); } } catch (err) { throw err; } }; this.getRecentTransactions = async () => { try { if (this.safeAddress !== '') { const res = await axios_1.default.get(`${this.txServiceUrl}/api/v1/safes/${this.safeAddress}/all-transactions/?limit=20&executed=false&queued=true&trusted=true`); return res.data; } else { throw new Error('Safe address not provided'); } } catch (err) { throw err; } }; this.getTransactionDetails = async (txHash) => { try { if (this.safeAddress !== '') { const res = await axios_1.default.get(`${this.txServiceUrl}/api/v1/multisig-transactions/${txHash}`); const safeInfo = await axios_1.default.get(`${this.txServiceUrl}/api/v1/safes/${this.safeAddress}`); //const safeData = safeInfo.data const confirmations = safeInfo.data.threshold; const data = { confirmation: confirmations, safeMultisigTransactionResponse: res.data, }; return data; } else { throw new Error('Safe address not provided'); } } catch (err) { throw err; } }; this.getSafeOwners = async () => { try { const owners = []; const result = await axios_1.default.get(`${this.txServiceUrl}/api/v1/safes/${this.safeAddress}/`); const safeOwners = result.data.owners; for (const owner of safeOwners) { //const address = (await this.provider?.lookupAddress(owner)) || owner owners.push(owner); } return owners; } catch (err) { return null; } }; this.getOwnersNeedToBeNudged = async (reactedOwners) => { try { const owners = []; const result = await axios_1.default.get(`${this.txServiceUrl}/api/v1/safes/${this.safeAddress}/`); const safeOwners = result.data.owners; for (const owner of safeOwners) { owners.push(owner); } let ownersNeedToBeNudged; ownersNeedToBeNudged = owners.filter((owner) => !reactedOwners.includes(owner)); return ownersNeedToBeNudged; } catch (error) { return null; } }; // change them to this.safeadress this.getSafeBalance = async () => { try { const result = await axios_1.default.get(`${this.txServiceUrl}/api/v1/safes/${this.safeAddress}/balances/usd/?trusted=false&exclude_spam=false` // `https://safe-transaction-goerli.safe.global/api/v1/safes/0x6744fC3A5A9CAAeC22c939Bb0737679b768C5e4c/balances/usd/?trusted=false&exclude_spam=false` ); const balance = result.data; return balance; } catch (err) { throw err; } }; this.getSafeBalanceinUSD = async () => { try { const result = await axios_1.default.get(`https://api.portals.fi/v2/account?owner=${this.safeAddress}&networks=ethereum`, { headers: { Authorization: 'Bearer 8c182698-36a3-4e89-8fb7-bb476148235c', }, }); const balance = result.data.balances; return balance; } catch (err) { throw err; } }; this.getWidgetTokenBalance = async () => { try { const tokenDetails = await this.getSafeBalance(); const tokenDetailsUSD = await this.getSafeBalanceinUSD(); const token_map = new Map(); if (tokenDetails.length > 0) { for (let token = 0; token < tokenDetails.length; token++) { const token_item = { address: '', decimals: 0, logoUri: '', name: '', symbol: '', type: '', usd: 0, balance: 0, }; if (tokenDetails[token].token === null && tokenDetails[token].balance !== null) { token_item.address = '0x0000000000000000000000000000000000000000'; token_item.decimals = 18; token_item.symbol = 'ETH'; token_item.name = 'Ethereum'; token_item.balance = Number(ethers_1.ethers.utils.formatUnits(ethers_1.BigNumber.from(tokenDetails[token].balance), 18)); token_map.set('0x0000000000000000000000000000000000000000', token_item); } else if (tokenDetails[token].token !== null) { token_item.address = tokenDetails[token].tokenAddress.toLowerCase(); token_item.decimals = tokenDetails[token].token.decimals; token_item.symbol = tokenDetails[token].token.symbol; token_item.name = tokenDetails[token].token.name; token_item.logoUri = tokenDetails[token].token.logoUri; token_item.balance = Number(ethers_1.ethers.utils.formatUnits(ethers_1.BigNumber.from(tokenDetails[token].balance), tokenDetails[token].token.decimals)); token_map.set(token_item.address, token_item); } else { return; } } if (tokenDetailsUSD.length > 0) { for (let token = 0; token < tokenDetailsUSD.length; token++) { const addr = tokenDetailsUSD[token].address; const token_item = token_map.get(addr); token_item.usd = tokenDetailsUSD[token].price; if (token_item.logoUri === '') { token_item.logoUri = tokenDetailsUSD[token].image === undefined || tokenDetailsUSD[token].image === '' ? 'https://app.safe.global/images/common/token-placeholder.svg' : tokenDetailsUSD[token].image; } token_map.set(addr, token_item); } } const widget = []; token_map.forEach((key, value) => { const widgetItem = { symbol: '', balance: 0, usdValue: 0, tokenAddress: '', }; widgetItem.balance = key.balance; widgetItem.symbol = key.symbol; widgetItem.usdValue = key.usd; widgetItem.tokenAddress = key.address; widget.push(widgetItem); }); return widget; } else { throw new Error('No assets found for the corresponding wallet'); } } catch (error) { throw error; } }; this.getTokenDetailsPortal = async (tokenAddress, token_map) => { try { if (token_map.has(tokenAddress) === false) { const result = await axios_1.default.get(`https://api.portals.fi/v2/tokens?addresses=ethereum%3A${tokenAddress}&platforms=basic&networks=ethereum&sortDirection=asc&limit=25&page=0`, { headers: { Authorization: 'Bearer 8c182698-36a3-4e89-8fb7-bb476148235c', }, }); const tokenDetails = result.data.tokens[0]; const token_item = { address: '', decimals: 0, logoUri: '', name: '', symbol: '', type: '', usd: 0.0, }; token_item.address = tokenDetails.address; token_item.decimals = tokenDetails.decimals; token_item.logoUri = tokenDetails.image === undefined || tokenDetails.image === '' ? 'https://app.safe.global/images/common/token-placeholder.svg' : tokenDetails.image; token_item.name = tokenDetails.name; token_item.symbol = tokenDetails.symbol; token_item.usd = tokenDetails.price; token_map.set(tokenAddress, token_item); return token_item; } else { const tokenDetails = token_map.get(tokenAddress); return tokenDetails; } } catch (err) { throw err; } }; this.getTokenMap = async () => { try { const tokenDetails = await this.getSafeBalance(); const tokenDetailsUSD = await this.getSafeBalanceinUSD(); const token_map = new Map(); if (tokenDetails.length > 0) { for (let token = 0; token < tokenDetails.length; token++) { const token_item = { address: '', decimals: 0, logoUri: '', name: '', symbol: '', type: '', usd: 0, }; if (tokenDetails[token].token === null && tokenDetails[token].balance !== null) { token_item.address = '0x0000000000000000000000000000000000000000'; token_item.decimals = 18; token_item.symbol = 'ETH'; token_item.name = 'Ethereum'; token_item.logoUri = 'https://assets.coingecko.com/coins/images/279/large/ethereum.png?1696501628'; token_map.set('0x0000000000000000000000000000000000000000', token_item); } else if (tokenDetails[token].token !== null) { token_item.address = tokenDetails[token].tokenAddress.toLowerCase(); token_item.decimals = tokenDetails[token].token.decimals; token_item.symbol = tokenDetails[token].token.symbol; token_item.name = tokenDetails[token].token.name; token_item.logoUri = tokenDetails[token].token.logoUri; token_map.set(token_item.address, token_item); } else { return; } } if (tokenDetailsUSD.length > 0) { for (let token = 0; token < tokenDetailsUSD.length; token++) { const addr = tokenDetailsUSD[token].address; const token_item = token_map.get(addr); token_item.usd = tokenDetailsUSD[token].price; if (token_item.logoUri === '') { token_item.logoUri = tokenDetailsUSD[token].image === undefined || tokenDetailsUSD[token].image === '' ? 'https://app.safe.global/images/common/token-placeholder.svg' : tokenDetailsUSD[token].image; } token_map.set(addr, token_item); } } return token_map; } else { throw new Error('No assets found for the corresponding wallet'); } } catch (error) { throw error; } }; this.getQueuedPayments = async () => { try { const res = await axios_1.default.get(`${this.txServiceUrl}/api/v1/safes/${this.safeAddress}/all-transactions/?executed=false&queued=true&trusted=true`); let token_map = await this.getTokenMap(); let queueTransaction = []; let isExecMap = new Map(); res.data.results.map((item) => { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l; const transactionDetails = []; const confirmation = []; const transaction = { nonce: 0, type: types_1.TransactionType.OTHER, nature: types_1.TransactionNature.OTHER, date: '', amountUSD: 0, transactionDetails: transactionDetails, confirmationsRequired: 0, confirmations: confirmation, safeTxHash: '', }; transaction.safeTxHash = item === null || item === void 0 ? void 0 : item.safeTxHash; transaction.nonce = item === null || item === void 0 ? void 0 : item.nonce; if (!isExecMap.has(item === null || item === void 0 ? void 0 : item.nonce)) { isExecMap.set(item === null || item === void 0 ? void 0 : item.nonce, item === null || item === void 0 ? void 0 : item.isExecuted); } if (isExecMap.get(item === null || item === void 0 ? void 0 : item.nonce) === false) { if ((item === null || item === void 0 ? void 0 : item.txType) === 'MULTISIG_TRANSACTION') { // When you send a single ERC20 token transaction.safeTxHash = item === null || item === void 0 ? void 0 : item.safeTxHash; transaction.nonce = item === null || item === void 0 ? void 0 : item.nonce; transaction.date = item === null || item === void 0 ? void 0 : item.submissionDate; item === null || item === void 0 ? void 0 : item.confirmations.map((ownerObject) => { confirmation.push(ownerObject.owner); }); transaction.confirmations = confirmation; transaction.confirmationsRequired = item === null || item === void 0 ? void 0 : item.confirmationsRequired; if ((item === null || item === void 0 ? void 0 : item.data) === null && (item === null || item === void 0 ? void 0 : item.value) === '0') { transaction.type = types_1.TransactionType.REJECTION; } else if (((_a = item === null || item === void 0 ? void 0 : item.dataDecoded) === null || _a === void 0 ? void 0 : _a.method) === 'transfer') { let transactionDetailsTemp = { walletAddress: '', currency: '', amount: 0, logo: '', amountUSD: 0, }; transaction.type = types_1.TransactionType.SENT; transaction.nature = types_1.TransactionNature.SINGLE; transactionDetailsTemp.walletAddress = (_d = (_c = (_b = item === null || item === void 0 ? void 0 : item.dataDecoded) === null || _b === void 0 ? void 0 : _b.parameters) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.value; const tokenDetails = token_map === null || token_map === void 0 ? void 0 : token_map.get(item === null || item === void 0 ? void 0 : item.to.toLowerCase()); transactionDetailsTemp.amount = Number(ethers_1.ethers.utils.formatUnits(ethers_1.BigNumber.from((_g = (_f = (_e = item === null || item === void 0 ? void 0 : item.dataDecoded) === null || _e === void 0 ? void 0 : _e.parameters) === null || _f === void 0 ? void 0 : _f[1]) === null || _g === void 0 ? void 0 : _g.value), tokenDetails === null || tokenDetails === void 0 ? void 0 : tokenDetails.decimals)); transactionDetailsTemp.amountUSD = tokenDetails.usd != undefined ? tokenDetails.usd : 0; transaction.amountUSD = transactionDetailsTemp.amountUSD * transactionDetailsTemp.amount; transactionDetailsTemp.currency = tokenDetails.symbol; transactionDetailsTemp.logo = tokenDetails.logoUri; transaction.transactionDetails.push(transactionDetailsTemp); } // single Ether transfer else if ((item === null || item === void 0 ? void 0 : item.data) === null && (item === null || item === void 0 ? void 0 : item.value) != null) { let transactionDetailsTemp = { walletAddress: '', currency: '', amount: 0, logo: '', amountUSD: 0, }; transaction.type = types_1.TransactionType.SENT; transaction.nature = types_1.TransactionNature.SINGLE; transactionDetailsTemp.walletAddress = item === null || item === void 0 ? void 0 : item.to; const tokenDetails = token_map === null || token_map === void 0 ? void 0 : token_map.get('0x0000000000000000000000000000000000000000'); transactionDetailsTemp.amount = Number(ethers_1.ethers.utils.formatUnits(ethers_1.BigNumber.from(item === null || item === void 0 ? void 0 : item.value), tokenDetails === null || tokenDetails === void 0 ? void 0 : tokenDetails.decimals)); transactionDetailsTemp.amountUSD = tokenDetails.usd != undefined ? tokenDetails.usd : 0; transaction.amountUSD = transactionDetailsTemp.amountUSD * transactionDetailsTemp.amount; transactionDetailsTemp.currency = tokenDetails.symbol; transactionDetailsTemp.logo = tokenDetails.logoUri; transaction.transactionDetails.push(transactionDetailsTemp); } else if (((_h = item === null || item === void 0 ? void 0 : item.dataDecoded) === null || _h === void 0 ? void 0 : _h.method) === 'multiSend') { transaction.type = types_1.TransactionType.SENT; transaction.nature = types_1.TransactionNature.BATCH; (_l = (_k = (_j = item === null || item === void 0 ? void 0 : item.dataDecoded) === null || _j === void 0 ? void 0 : _j.parameters[0]) === null || _k === void 0 ? void 0 : _k.valueDecoded) === null || _l === void 0 ? void 0 : _l.map((tx) => { var _a, _b, _c, _d, _e, _f; if (tx.data === null && tx.value != null) { let transactionDetailsTemp = { walletAddress: '', currency: '', amount: 0, logo: '', amountUSD: 0, }; const tokenDetails = token_map === null || token_map === void 0 ? void 0 : token_map.get('0x0000000000000000000000000000000000000000'); transactionDetailsTemp.walletAddress = tx.to; transactionDetailsTemp.amount = Number(ethers_1.ethers.utils.formatUnits(ethers_1.BigNumber.from(tx.value), tokenDetails === null || tokenDetails === void 0 ? void 0 : tokenDetails.decimals)); transactionDetailsTemp.logo = tokenDetails.logoUri; transactionDetailsTemp.currency = tokenDetails.symbol; transactionDetailsTemp.amountUSD = tokenDetails.usd != undefined ? tokenDetails.usd : 0; transaction.amountUSD += transactionDetailsTemp.amountUSD * transactionDetailsTemp.amount; transaction.transactionDetails.push(transactionDetailsTemp); } else { let transactionDetailsTemp = { walletAddress: '', currency: '', amount: 0, logo: '', amountUSD: 0, }; const tokenDetails = token_map === null || token_map === void 0 ? void 0 : token_map.get(tx.to.toLowerCase()); transactionDetailsTemp.walletAddress = (_c = (_b = (_a = tx.dataDecoded) === null || _a === void 0 ? void 0 : _a.parameters) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.value; transactionDetailsTemp.amount = Number(ethers_1.ethers.utils.formatUnits(ethers_1.BigNumber.from((_f = (_e = (_d = tx.dataDecoded) === null || _d === void 0 ? void 0 : _d.parameters) === null || _e === void 0 ? void 0 : _e[1]) === null || _f === void 0 ? void 0 : _f.value), tokenDetails === null || tokenDetails === void 0 ? void 0 : tokenDetails.decimals)); transactionDetailsTemp.amountUSD = tokenDetails.usd != undefined ? tokenDetails.usd : 0; transactionDetailsTemp.logo = tokenDetails.logoUri; transactionDetailsTemp.currency = tokenDetails.symbol; transaction.amountUSD += transactionDetailsTemp.amountUSD * transactionDetailsTemp.amount; transaction.transactionDetails.push(transactionDetailsTemp); } }); } else { transaction.nature = types_1.TransactionNature.OTHER; transaction.type = types_1.TransactionType.OTHER; } } queueTransaction.push(transaction); } }); return queueTransaction; } catch (err) { throw err; } }; this.getTransactionHistory = async () => { var _a, _b, _c, _d, _e, _f, _g; try { const res = await axios_1.default.get(`${this.txServiceUrl}/api/v1/safes/${this.safeAddress}/all-transactions/?executed=true&queued=false&trusted=true`); let token_map = await this.getTokenMap(); let historyTransaction = []; let txURL = 'https://etherscan.io/tx/'; for (let i = 0; i < res.data.results.length; i++) { let item = res.data.results[i]; const transactionDetails = []; const transaction = { nonce: -1, type: types_1.TransactionType.OTHER, nature: types_1.TransactionNature.OTHER, executionDate: '', amountUSD: 0, transactionDetails: transactionDetails, executedBy: '', safeTxHash: '', txHash: '', url: '', }; transaction.executionDate = item === null || item === void 0 ? void 0 : item.executionDate; if ((item === null || item === void 0 ? void 0 : item.txType) === 'ETHEREUM_TRANSACTION') { // RECIEVED transaction.txHash = item === null || item === void 0 ? void 0 : item.txHash; transaction.type = types_1.TransactionType.RECEIVED; transaction.url = txURL + (item === null || item === void 0 ? void 0 : item.txHash); if (((_a = item === null || item === void 0 ? void 0 : item.transfers) === null || _a === void 0 ? void 0 : _a.length) > 1) { transaction.nature = types_1.TransactionNature.BATCH; } else if (((_b = item === null || item === void 0 ? void 0 : item.transfers) === null || _b === void 0 ? void 0 : _b.length) === 1) { transaction.nature = types_1.TransactionNature.SINGLE; } else { transaction.nature = types_1.TransactionNature.OTHER; } if (((_c = item === null || item === void 0 ? void 0 : item.transfers) === null || _c === void 0 ? void 0 : _c.length) > 0) { item === null || item === void 0 ? void 0 : item.transfers.map(async (tx) => { let transactionDetailsTemp = { from: '', walletAddress: '', currency: '', amount: 0, logo: '', amountUSD: 0, }; transactionDetailsTemp.from = item === null || item === void 0 ? void 0 : item.from; transactionDetailsTemp.walletAddress = tx === null || tx === void 0 ? void 0 : tx.to; if ((tx === null || tx === void 0 ? void 0 : tx.type) === 'ETHER_TRANSFER') { // Recieving ether const tokenDetails = token_map === null || token_map === void 0 ? void 0 : token_map.get('0x0000000000000000000000000000000000000000'); transactionDetailsTemp.amount = Number(ethers_1.ethers.utils.formatUnits(ethers_1.BigNumber.from(tx === null || tx === void 0 ? void 0 : tx.value), tokenDetails === null || tokenDetails === void 0 ? void 0 : tokenDetails.decimals)); transactionDetailsTemp.amountUSD = tokenDetails.usd != undefined ? tokenDetails.usd : 0; transaction.amountUSD += transactionDetailsTemp.amountUSD * transactionDetailsTemp.amount; transactionDetailsTemp.currency = tokenDetails.symbol; transactionDetailsTemp.logo = tokenDetails.logoUri; transaction.transactionDetails.push(transactionDetailsTemp); } else if ((tx === null || tx === void 0 ? void 0 : tx.type) === 'ERC20_TRANSFER') { // Recieving other erc20 tokens const tokenDetails = await this.getTokenDetailsPortal(tx === null || tx === void 0 ? void 0 : tx.tokenAddress.toLowerCase(), token_map); transactionDetailsTemp.amount = Number(ethers_1.ethers.utils.formatUnits(ethers_1.BigNumber.from(tx === null || tx === void 0 ? void 0 : tx.value), tokenDetails === null || tokenDetails === void 0 ? void 0 : tokenDetails.decimals)); transactionDetailsTemp.amountUSD = tokenDetails.usd != undefined ? tokenDetails.usd : 0; transaction.amountUSD += transactionDetailsTemp.amountUSD * transactionDetailsTemp.amount; transactionDetailsTemp.currency = tokenDetails.symbol; transactionDetailsTemp.logo = tokenDetails.logoUri; transaction.transactionDetails.push(transactionDetailsTemp); } else { transaction.type = types_1.TransactionType.OTHER; } }); } } else if ((item === null || item === void 0 ? void 0 : item.txType) === 'MULTISIG_TRANSACTION') { // SENT transaction.nonce = item === null || item === void 0 ? void 0 : item.nonce; transaction.executionDate = item === null || item === void 0 ? void 0 : item.executionDate; transaction.safeTxHash = item === null || item === void 0 ? void 0 : item.safeTxHash; transaction.txHash = item === null || item === void 0 ? void 0 : item.transactionHash; transaction.url = txURL + (item === null || item === void 0 ? void 0 : item.transactionHash); transaction.executedBy = item === null || item === void 0 ? void 0 : item.executor; // single if (((_d = item === null || item === void 0 ? void 0 : item.transfers) === null || _d === void 0 ? void 0 : _d.length) === 1) { transaction.nature = types_1.TransactionNature.SINGLE; transaction.type = types_1.TransactionType.SENT; let transactionDetailsTemp = { from: '', walletAddress: '', currency: '', amount: 0, logo: '', amountUSD: 0, }; if ((item === null || item === void 0 ? void 0 : item.transfers[0].type) === 'ETHER_TRANSFER') { const tokenDetails = token_map === null || token_map === void 0 ? void 0 : token_map.get('0x0000000000000000000000000000000000000000'); transactionDetailsTemp.walletAddress = item === null || item === void 0 ? void 0 : item.transfers[0].to; transactionDetailsTemp.amount = Number(ethers_1.ethers.utils.formatUnits(ethers_1.BigNumber.from(item === null || item === void 0 ? void 0 : item.transfers[0].value), tokenDetails === null || tokenDetails === void 0 ? void 0 : tokenDetails.decimals)); transactionDetailsTemp.amountUSD = tokenDetails.usd != undefined ? tokenDetails.usd : 0; transaction.amountUSD = transactionDetailsTemp.amountUSD * transactionDetailsTemp.amount; transactionDetailsTemp.currency = tokenDetails.symbol; transactionDetailsTemp.logo = tokenDetails.logoUri; transaction.transactionDetails.push(transactionDetailsTemp); } else if ((item === null || item === void 0 ? void 0 : item.transfers[0].type) === 'ERC20_TRANSFER') { const tokenDetails = await this.getTokenDetailsPortal(item === null || item === void 0 ? void 0 : item.transfers[0].tokenAddress.toLowerCase(), token_map); transactionDetailsTemp.walletAddress = item === null || item === void 0 ? void 0 : item.transfers[0].to; transactionDetailsTemp.amount = Number(ethers_1.ethers.utils.formatUnits(ethers_1.BigNumber.from(item === null || item === void 0 ? void 0 : item.transfers[0].value), tokenDetails === null || tokenDetails === void 0 ? void 0 : tokenDetails.decimals)); transactionDetailsTemp.amountUSD = tokenDetails.usd != undefined ? tokenDetails.usd : 0; transaction.amountUSD = transactionDetailsTemp.amountUSD * transactionDetailsTemp.amount; transactionDetailsTemp.currency = tokenDetails.symbol; transactionDetailsTemp.logo = tokenDetails.logoUri; transaction.transactionDetails.push(transactionDetailsTemp); } else { transaction.type = types_1.TransactionType.OTHER; } } else if (((_e = item === null || item === void 0 ? void 0 : item.transfers) === null || _e === void 0 ? void 0 : _e.length) > 1 && ((_f = item === null || item === void 0 ? void 0 : item.dataDecoded) === null || _f === void 0 ? void 0 : _f.method) === 'multiSend') { transaction.nature = types_1.TransactionNature.BATCH; transaction.type = types_1.TransactionType.SENT; item === null || item === void 0 ? void 0 : item.transfers.map(async (tx) => { let transactionDetailsTemp = { from: '', walletAddress: '', currency: '', amount: 0, logo: '', amountUSD: 0, }; if (tx.type === 'ETHER_TRANSFER') { const tokenDetails = token_map === null || token_map === void 0 ? void 0 : token_map.get('0x0000000000000000000000000000000000000000'); transactionDetailsTemp.walletAddress = tx.to; transactionDetailsTemp.amount = Number(ethers_1.ethers.utils.formatUnits(ethers_1.BigNumber.from(tx.value), tokenDetails === null || tokenDetails === void 0 ? void 0 : tokenDetails.decimals)); transactionDetailsTemp.amountUSD = tokenDetails.usd != undefined ? tokenDetails.usd : 0; transaction.amountUSD += transactionDetailsTemp.amountUSD * transactionDetailsTemp.amount; transactionDetailsTemp.currency = tokenDetails.symbol; transactionDetailsTemp.logo = tokenDetails.logoUri; transaction.transactionDetails.push(transactionDetailsTemp); } else if (tx.type === 'ERC20_TRANSFER') { const tokenDetails = await this.getTokenDetailsPortal(tx.tokenAddress.toLowerCase(), token_map); transactionDetailsTemp.walletAddress = tx.to; transactionDetailsTemp.amount = Number(ethers_1.ethers.utils.formatUnits(ethers_1.BigNumber.from(tx.value), tokenDetails === null || tokenDetails === void 0 ? void 0 : tokenDetails.decimals)); transactionDetailsTemp.amountUSD = tokenDetails.usd != undefined ? tokenDetails.usd : 0; transaction.amountUSD += transactionDetailsTemp.amountUSD * transactionDetailsTemp.amount; transactionDetailsTemp.currency = tokenDetails.symbol; transactionDetailsTemp.logo = tokenDetails.logoUri; transaction.transactionDetails.push(transactionDetailsTemp); } else { transaction.type = types_1.TransactionType.OTHER; } }); } else if (((_g = item === null || item === void 0 ? void 0 : item.transfers) === null || _g === void 0 ? void 0 : _g.length) === 0 && (item === null || item === void 0 ? void 0 : item.data) === null && (item === null || item === void 0 ? void 0 : item.value) === '0') { transaction.nature = types_1.TransactionNature.OTHER; transaction.type = types_1.TransactionType.REJECTION; } } else { // OTHERS transaction.nature = types_1.TransactionNature.OTHER; transaction.type = types_1.TransactionType.OTHER; } historyTransaction.push(transaction); } return historyTransaction; } catch (error) { throw error; } }; this.getPendingTransactions = async () => { try { if (this.safeAddress !== '') { const safeInfo = await axios_1.default.get(`${this.txServiceUrl}/api/v1/safes/${this.safeAddress}`); const result = await axios_1.default.get(`${this.txServiceUrl}/api/v1/safes/${this.safeAddress}/multisig-transactions/?executed=false&nonce__gte=${safeInfo.data.nonce}`); const pendingTx = result.data; return pendingTx; } else { throw new Error('Safe address not provided'); } } catch (err) { throw err; } }; this.safeAddress = safeAddress; this.chainId = chainId; networks_1.Networks.forEach((network) => { if (network.chainId === chainId) { this.txServiceUrl = network.url; } }); } } exports.GnosisFetch = GnosisFetch;