diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index f08c925e..faa89dd0 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -128,9 +128,14 @@ "baker_registry": "TCF Baker Registry", "bakers_history": "Baker History", "transactions": "Transactions", - "contracts": "Accounts", + "contracts": "Contracts", "logs": "Logs", - "receipts": "Receipts" + "receipts": "Receipts", + "tokens": "Tokens", + "tokens_history": "Token History", + "token_transfers": "Token Transfers", + "outputs": "Outputs", + "inputs": "Inputs" } }, "attributes": { @@ -148,6 +153,17 @@ "block_level": "Block Level", "is_baker": "Baker", "is_activated": "Activated", + "address": "Address", + "block_hash": "Block Hash", + "block_number": "Block Number", + "bytecode": "Bytecode", + "bytecode_hash": "Bytecode Hash", + "decimals": "Decimals", + "name": "Name", + "symbol": "Symbol", + "timestamp": "Timestamp", + "token_standard": "Token Standard", + "total_supply": "Total Supply", "token_balances": "Token Balances" }, "accounts_history": { @@ -162,7 +178,10 @@ "cycle": "Cycle", "is_baker": "Registered Baker", "is_active_baker": "Active Baker", - "is_activated": "Activated Account" + "is_activated": "Activated Account", + "address": "Address", + "block_hash": "Block Hash", + "block_number": "Block Number" }, "balance_updates": { "account_id": "Address", @@ -233,7 +252,19 @@ "state_root": "State Root", "total_difficulty": "Total Difficulty", "transactions_root": "Transactions Root", - "uncles": "Uncles" + "uncles": "Uncles", + "bits": "Bits", + "chain_work": "Chain Work", + "height": "Level", + "median_time": "Median Time", + "merkle_root": "Merkle Root", + "next_block_hash": "Next Block Hash", + "previous_block_hash": "Previous Block Hash", + "stripped_size": "Stripped Size", + "time": "Timestamp", + "version": "Version", + "version_hex": "Version Hex", + "weight": "Weight" }, "bakers": { "pkh": "Address", @@ -436,8 +467,9 @@ "block_hash": "Block Hash", "block_number": "Block Level", "bytecode": "Bytecode", - "is_erc20": "ERC20", - "is_erc721": "ERC721" + "bytecode_hash": "Code Hash", + "timestamp": "Timestamp", + "token_standard": "Token Standard" }, "transactions": { "block_hash": "Block Hash", @@ -453,7 +485,8 @@ "nonce": "Nonce", "destination": "Destination", "transaction_index": "Index", - "amount": "Amount" + "amount": "Amount", + "timestamp": "Timestamp" }, "logs": { "address": "Address", @@ -464,7 +497,8 @@ "removed": "Removed", "topics": "Topics", "transaction_hash": "Transaction Hash", - "transaction_index": "Transaction Index" + "transaction_index": "Transaction Index", + "timestamp": "Timestamp" }, "receipts": { "block_hash": "Block Hash", @@ -476,7 +510,44 @@ "root": "Root", "status": "Status", "transaction_hash": "Transaction Hash", - "transaction_index": "Transaction Index" + "transaction_index": "Transaction Index", + "timestamp": "Timestamp" + }, + "token_transfers": { + "block_hash": "Block Hash", + "block_number": "Block Level", + "from_address": "Source", + "log_index": "Log Index", + "timestamp": "Timestamp", + "to_address": "Destination", + "token_address": "Token Address", + "transaction_hash": "Transaction Hash", + "value": "Amount" + }, + "tokens_history": { + "account_address": "Address", + "asof": "As of Date", + "block_hash": "Block Hash", + "block_number": "Block Level", + "token_address": "Token Address", + "transaction_hash": "Transaction Hash", + "value": "Amount" + }, + "tokens": { + "address": "Address", + "block_hash": "Block Hash", + "block_number": "Block Level", + "decimals": "Decimals", + "name": "Name", + "symbol": "Symbol", + "timestamp": "Timestamp", + "total_supply": "Total Supply" + }, + "outputs": { + + }, + "inputs": { + } }, "operators": { diff --git a/src/containers/Modal/parts/TokensTable.tsx b/src/containers/Modal/parts/TokensTable.tsx index ba357cf0..ba8bf34e 100644 --- a/src/containers/Modal/parts/TokensTable.tsx +++ b/src/containers/Modal/parts/TokensTable.tsx @@ -16,6 +16,7 @@ const useStyles = makeStyles({ export default function TokensTable({ items }: { items: Record[] }) { const classes = useStyles(); + const coinTotal = items.reduce((a, c) => { return Number(a) + (Number(c.coinBalance) || 0) }, 0); return ( @@ -24,7 +25,8 @@ export default function TokensTable({ items }: { items: Record[] Token Location - Balance + Tokens + XTZ @@ -33,8 +35,17 @@ export default function TokensTable({ items }: { items: Record[] {row.token} {row.location} {row.balance} + {row.coinBalance} ))} + {coinTotal && ( + + Total + + + {coinTotal} + + )} diff --git a/src/reducers/app/thunks.ts b/src/reducers/app/thunks.ts index 8775a251..e913a31e 100644 --- a/src/reducers/app/thunks.ts +++ b/src/reducers/app/thunks.ts @@ -522,6 +522,9 @@ export const initLoad = (props: InitLoad) => async (dispatch: any, state: any) = } catch (e) { if (e.message) { await dispatch(createMessageAction(e.message, true)); + } else { + console.log(e); + console.log(e.stack) } } }; diff --git a/src/reducers/modal/thunk.ts b/src/reducers/modal/thunk.ts index af9ae3fb..2c8f0e33 100644 --- a/src/reducers/modal/thunk.ts +++ b/src/reducers/modal/thunk.ts @@ -40,9 +40,11 @@ export const fetchAccountTokenBalances = (name: string, address: string) => asyn tokenLedgerPath: '$.args[0].int', dexterPoolAddress: 'KT1PDrBE59Zmxnb8vXRgRAG1XmvTMTs5EDHU', dexterLedgerMap: 542, - quipuPoolAddress: 'KT1DX1kpCEfEg5nG3pXSSwvtkjTr6ZNYuxP4', + quipuPoolAddress: 'KT1Evsp2yA19Whm24khvFPcwimK6UaAJu8Zo', quipuPoolBalancePath: '$.args[1].args[0].args[4].int', - quipuLedgerMap: 1007 + quipuTokenPoolPath: '$.args[1].args[0].args[2].args[1].int', + quipuCoinPoolPath: '$.args[1].args[0].args[1].args[2].int', + quipuLedgerMap: 1517 }; const usdtzDetails = { @@ -54,9 +56,11 @@ export const fetchAccountTokenBalances = (name: string, address: string) => asyn tokenLedgerPath: '$.args[0].int', dexterPoolAddress: 'KT1Tr2eG3eVmPRbymrbU2UppUmKjFPXomGG9', dexterLedgerMap: 543, - quipuPoolAddress: 'KT1MWxucqexguPjhqEyk4XndE1M5tHnhNhH7', + quipuPoolAddress: 'KT1WxgZ1ZSfMgmsSDDcUn8Xn577HwnQ7e1Lb', quipuPoolBalancePath: '$.args[1].args[0].args[4].int', - quipuLedgerMap: 999 + quipuTokenPoolPath: '$.args[1].args[0].args[2].args[1].int', + quipuCoinPoolPath: '$.args[1].args[0].args[1].args[2].int', + quipuLedgerMap: 1509 }; const tzbtcKey = Buffer.from(TezosMessageUtils.writePackedData(`Pair "ledger" 0x${TezosMessageUtils.writeAddress(address)}`, '', TezosParameterFormat.Michelson), 'hex'); @@ -69,9 +73,11 @@ export const fetchAccountTokenBalances = (name: string, address: string) => asyn tokenLedgerPath: '$.args[0].int', dexterPoolAddress: 'KT1BGQR7t4izzKZ7eRodKWTodAsM23P38v7N', dexterLedgerMap: 541, - quipuPoolAddress: 'KT1N1wwNPqT5jGhM91GQ2ae5uY8UzFaXHMJS', + quipuPoolAddress: 'KT1WBLrLE2vG8SedBqiSJFm4VVAZZBytJYHc', quipuPoolBalancePath: '$.args[1].args[0].args[4].int', - quipuLedgerMap: 977 + quipuTokenPoolPath: '$.args[1].args[0].args[2].args[1].int', + quipuCoinPoolPath: '$.args[1].args[0].args[1].args[2].int', + quipuLedgerMap: 1493 }; const wxtzDetails = { @@ -83,9 +89,11 @@ export const fetchAccountTokenBalances = (name: string, address: string) => asyn tokenLedgerPath: '$.int', dexterPoolAddress: 'KT1D56HQfMmwdopmFLTwNHFJSs6Dsg2didFo', dexterLedgerMap: 544, - quipuPoolAddress: 'KT1NABnnQ4pUTJHUwFLiVM2uuEu1RXihAVmB', + quipuPoolAddress: 'KT1W3VGRUjvS869r4ror8kdaxqJAZUbPyjMT', quipuPoolBalancePath: '$.args[1].args[0].args[4].int', - quipuLedgerMap: 987 + quipuTokenPoolPath: '$.args[1].args[0].args[2].args[1].int', + quipuCoinPoolPath: '$.args[1].args[0].args[1].args[2].int', + quipuLedgerMap: 1477 }; const kusdDetails = { @@ -97,9 +105,11 @@ export const fetchAccountTokenBalances = (name: string, address: string) => asyn tokenLedgerPath: '$.args[1].int', dexterPoolAddress: 'KT1AbYeDbjjcAnV1QK7EZUUdqku77CdkTuv6', dexterLedgerMap: 540, - quipuPoolAddress: 'KT1CiSKXR68qYSxnbzjwvfeMCRburaSDonT2', + quipuPoolAddress: 'KT1K4EwTpbvYN9agJdjpyJm4ZZdhpUNKB3F6', quipuPoolBalancePath: '$.args[1].args[0].args[4].int', - quipuLedgerMap: 969 + quipuTokenPoolPath: '$.args[1].args[0].args[2].args[1].int', + quipuCoinPoolPath: '$.args[1].args[0].args[1].args[2].int', + quipuLedgerMap: 1485 }; const stkrDetails = { @@ -109,9 +119,11 @@ export const fetchAccountTokenBalances = (name: string, address: string) => asyn tokenLedgerKey: address, tokenLedgerKeyType: 'address', tokenLedgerPath: '$.int', - quipuPoolAddress: 'KT1R5Fp415CJxSxxXToUj6QvxP1LHaYXaxV6', + quipuPoolAddress: 'KT1BMEEPX7MWzwwadW3NCSZe9XGmFJ7rs7Dr', quipuPoolBalancePath: '$.args[1].args[0].args[4].int', - quipuLedgerMap: 1062 + quipuTokenPoolPath: '$.args[1].args[0].args[2].args[1].int', + quipuCoinPoolPath: '$.args[1].args[0].args[1].args[2].int', + quipuLedgerMap: 1501 }; const blndDetails = { @@ -120,10 +132,7 @@ export const fetchAccountTokenBalances = (name: string, address: string) => asyn tokenLedgerMap: 368, tokenLedgerKey: address, tokenLedgerKeyType: 'address', - tokenLedgerPath: '$.int', - // quipuPoolAddress: 'KT1R5Fp415CJxSxxXToUj6QvxP1LHaYXaxV6', - // quipuPoolBalancePath: '$.args[1].args[0].args[4].int', - // quipuLedgerMap: 1062 + tokenLedgerPath: '$.int' }; const hdaoDetails = { @@ -133,21 +142,53 @@ export const fetchAccountTokenBalances = (name: string, address: string) => asyn tokenLedgerKey: `Pair 0x${TezosMessageUtils.writeAddress(address)} 0`, tokenLedgerKeyType: '', tokenLedgerPath: '$.int', - quipuPoolAddress: 'KT1V41fGzkdTJki4d11T1Rp9yPkCmDhB7jph', - quipuPoolBalancePath: '$.args[1].args[0].args[3].int', - quipuLedgerMap: 1035 + quipuPoolAddress: 'KT1QxLqukyfohPV5kPkw97Rs6cw1DDDvYgbB', + quipuPoolBalancePath: '$.args[1].args[1].args[0].args[0].int', + quipuTokenPoolPath: `$.args[1].args[0].args[3].int`, + quipuCoinPoolPath: '$.args[1].args[0].args[1].args[2].int', + quipuLedgerMap: 1878 }; const usdsDetails = { - tokenSymbol: 'hDAO', + tokenSymbol: 'USDS', tokenDecimals: 6, tokenLedgerMap: 397, tokenLedgerKey: `Pair 0x${TezosMessageUtils.writeAddress(address)} 0`, tokenLedgerKeyType: '', tokenLedgerPath: '$.int', - quipuPoolAddress: 'KT1T4wNjJtNqZ9XCKSZqR5BXsuGczTxhV9Vu', - quipuPoolBalancePath: '$.args[1].args[0].args[3].int', - quipuLedgerMap: 1217 + quipuPoolAddress: 'KT1KFszq8UFCcWxnXuhZPUyHT9FK3gjmSKm6', + quipuPoolBalancePath: '$.args[1].args[1].args[0].args[0].int', + quipuTokenPoolPath: `$.args[1].args[0].args[3].int`, + quipuCoinPoolPath: '$.args[1].args[0].args[1].args[2].int', + quipuLedgerMap: 1894 + }; + + const wrapDetails = { + tokenSymbol: 'WRAP', + tokenDecimals: 8, + tokenLedgerMap: 1777, // KT1LRboPna9yQY9BrjtQYDS1DVxhKESK4VVd + tokenLedgerKey: address, + tokenLedgerKeyType: 'address', + tokenLedgerPath: '$.int', + quipuPoolAddress: 'KT1FG63hhFtMEEEtmBSX2vuFmP87t9E7Ab4t', + quipuPoolBalancePath: '$.args[1].args[1].args[0].args[0].int', + quipuTokenPoolPath: `$.args[1].args[0].args[3].int`, + quipuCoinPoolPath: '$.args[1].args[0].args[1].args[2].int', + quipuLedgerMap: 2013 + }; + + const crunchDetails = { + tokenSymbol: 'CRUNCH', + tokenDecimals: 8, + tokenLedgerMap: 2809, // KT1BHCumksALJQJ8q8to2EPigPW6qpyTr7Ng + tokenLedgerKey: address, + tokenLedgerKeyType: 'address', + tokenLedgerPath: '$.int', + quipuPoolAddress: 'KT1RRgK6eXvCWCiEGWhRZCSVGzhDzwXEEjS4', + quipuPoolBalancePath: '$.args[1].args[1].args[0].args[0].int', + quipuTokenPoolPath: `$.args[1].args[0].args[3].int`, + quipuCoinPoolPath: '$.args[1].args[0].args[1].args[2].int', + quipuLedgerMap: 3266 }; try { @@ -160,14 +201,26 @@ export const fetchAccountTokenBalances = (name: string, address: string) => asyn const hdao = await aggregateTokenBalance(nodeUrl, hdaoDetails, address); const tzbtc = await aggregateTokenBalance(nodeUrl, tzbtcDetails, address); const usds = await aggregateTokenBalance(nodeUrl, usdsDetails, address); + const wrap = await aggregateTokenBalance(nodeUrl, wrapDetails, address); + const crunch = await aggregateTokenBalance(nodeUrl, crunchDetails, address); - await dispatch(setModule(name, [...usdtz, ...ethtz, ...wxtz, ...kusd, ...stkr, ...blnd, ...hdao, ...tzbtc, ...usds])); + await dispatch(setModule(name, [...usdtz, ...ethtz, ...wxtz, ...kusd, ...stkr, ...blnd, ...hdao, ...tzbtc, ...usds, ...wrap, ...crunch])); } catch (e) { const message = 'Unable to fetch operations'; dispatch(createMessageAction(message, true)); } } +/** + * + * @param name Result set attribute name + * @param address Account to query + * @returns + */ + export const fetchAccountNFTBalances = (name: string, address: string) => async (dispatch: any, state: any) => { + // + } + export const fetchOperationsBlock = (name: string, id: any) => async (dispatch: any, state: any) => { const { network, platform, url, apiKey } = state().app.selectedConfig; const serverInfo = { url, apiKey, network }; @@ -388,7 +441,12 @@ const aggregateTokenBalance = async (tezosNode: string, tokenDetails: any, accou tokenBalance = new BigNumber(JSONPath({ path: tokenDetails.tokenLedgerPath, json: accountData })[0]); if (tokenBalance.toNumber() > 0) { - balances.push({ token: tokenDetails.tokenSymbol, location: tokenDetails.tokenSymbol, balance: tokenBalance.dividedBy(scale).toFixed(tokenDetails.tokenDecimals) }); + balances.push({ + token: tokenDetails.tokenSymbol, + location: tokenDetails.tokenSymbol, + balance: tokenBalance.dividedBy(scale).toFixed(tokenDetails.tokenDecimals), + coinBalance: 0 + }); } } } catch (err) { @@ -396,36 +454,55 @@ const aggregateTokenBalance = async (tezosNode: string, tokenDetails: any, accou } let dexterTokenBalance = new BigNumber(0); + let dexterCoinBalance = new BigNumber(0); try { const packedKey = TezosMessageUtils.encodeBigMapKey(Buffer.from(TezosMessageUtils.writePackedData(account, 'address'), 'hex')); const mapResult = await TezosNodeReader.getValueForBigMapKey(tezosNode, tokenDetails.dexterLedgerMap, packedKey); const dexterPoolBalance = new BigNumber(JSONPath({ path: '$.args[0].int', json: mapResult })[0]); + const dexterStorage = await TezosNodeReader.getContractStorage(tezosNode, tokenDetails.dexterPoolAddress); - const dexterPoolSize = new BigNumber(JSONPath({ path: '$.args[4].int', json: dexterStorage })[0]); - dexterTokenBalance = dexterPoolBalance - .dividedBy(dexterPoolSize) - .multipliedBy(new BigNumber(JSONPath({ path: '$.args[3].int', json: dexterStorage })[0])); + const dexterPoolSize = new BigNumber(JSONPath({ path: '$.args[1].args[2].int', json: dexterStorage })[0]); + const dexterTokenPool = new BigNumber(JSONPath({ path: '$.args[3].int', json: dexterStorage })[0]); + const dexterCoinPool = new BigNumber(JSONPath({ path: '$.args[4].int', json: dexterStorage })[0]); + + dexterTokenBalance = dexterPoolBalance.dividedBy(dexterPoolSize).multipliedBy(dexterTokenPool); + dexterCoinBalance = dexterPoolBalance.dividedBy(dexterPoolSize).multipliedBy(dexterCoinPool); if (dexterTokenBalance.toNumber() > 0) { - balances.push({ token: tokenDetails.tokenSymbol, location: 'Dexter', balance: dexterTokenBalance.dividedBy(scale).toFixed(tokenDetails.tokenDecimals) }); + balances.push({ + token: tokenDetails.tokenSymbol, + location: 'Dexter', + balance: dexterTokenBalance.dividedBy(scale).toFixed(tokenDetails.tokenDecimals), + coinBalance: dexterCoinBalance.dividedBy(1_000_000).toFixed(6) + }); } } catch (err) { // } let quipuTokenBalance = new BigNumber(0); + let quipuCoinBalance = new BigNumber(0); try { + console.log(`processing ${tokenDetails.tokenSymbol}`) const packedKey = TezosMessageUtils.encodeBigMapKey(Buffer.from(TezosMessageUtils.writePackedData(account, 'address'), 'hex')); const mapResult = await TezosNodeReader.getValueForBigMapKey(tezosNode, tokenDetails.quipuLedgerMap, packedKey); const quipuPoolBalance = new BigNumber(JSONPath({ path: '$.args[0].args[1].int', json: mapResult })[0]) + const quipuStorage = await TezosNodeReader.getContractStorage(tezosNode, tokenDetails.quipuPoolAddress) const quipuPoolSize = new BigNumber(JSONPath({ path: tokenDetails.quipuPoolBalancePath, json: quipuStorage })[0]); - quipuTokenBalance = quipuPoolBalance - .dividedBy(quipuPoolSize) - .multipliedBy(new BigNumber(JSONPath({ path: '$.args[1].args[0].args[2].args[1].int', json: quipuStorage })[0])); + const quipuTokenPool = new BigNumber(JSONPath({ path: tokenDetails.quipuTokenPoolPath, json: quipuStorage })[0]); + const quipuCoinPool = new BigNumber(JSONPath({ path: tokenDetails.quipuCoinPoolPath, json: quipuStorage })[0]); + console.log(tokenDetails.tokenSymbol, quipuPoolSize.toString(), quipuTokenPool.toString(), quipuCoinPool.toString()) + quipuTokenBalance = quipuPoolBalance.dividedBy(quipuPoolSize).multipliedBy(quipuTokenPool); + quipuCoinBalance = quipuPoolBalance.dividedBy(quipuPoolSize).multipliedBy(quipuCoinPool); if (quipuTokenBalance.toNumber() > 0) { - balances.push({ token: tokenDetails.tokenSymbol, location: 'QuipuSwap', balance: quipuTokenBalance.dividedBy(scale).toFixed(tokenDetails.tokenDecimals) }); + balances.push({ + token: tokenDetails.tokenSymbol, + location: 'QuipuSwap', + balance: quipuTokenBalance.dividedBy(scale).toFixed(tokenDetails.tokenDecimals), + coinBalance: quipuCoinBalance.dividedBy(1_000_000).toFixed(6) + }); } } catch (err) { //