Package org.exoplatform.wallet.utils
Class WalletUtils
- java.lang.Object
-
- org.exoplatform.wallet.utils.WalletUtils
-
public class WalletUtils extends Object
Utils class to provide common tools and constants
-
-
Field Summary
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidbroadcastTransactionReplacedEvent(TransactionDetail oldTransaction, TransactionDetail newTransaction)static booleancanAccessWallet(Wallet wallet, String currentUser)Return true if user can access wallet detailed informationstatic booleancheckUserIsSpaceManager(String spaceId, String modifier, boolean throwException)static voidcomputeWalletFromIdentity(Wallet wallet, org.exoplatform.social.core.identity.model.Identity identity)static voidcomputeWalletIdentity(Wallet wallet)static doubleconvertFromDecimals(BigInteger amount, int decimals)static BigIntegerconvertToDecimals(double amount, int decimals)static StringdecodeString(String content)static StringencodeString(String content)static StringformatBalance(double balance, Locale locale, boolean simplified)Format Wallet Balance amount in currency format, without currency symbol and switch user locale.static StringformatNumber(Object amount, String lang)static StringformatTransactionHash(String transactionHash)static <T> TfromJsonString(String value, Class<T> resultClass)static StringgetBlockchainURLSuffix()static StringgetContractAddress()static ContractDetailgetContractDetail()static StringgetCurrentUserId()static longgetCurrentUserIdentityId()static LonggetGasLimit()static org.exoplatform.social.core.identity.model.IdentitygetIdentityById(long identityId)static org.exoplatform.social.core.identity.model.IdentitygetIdentityById(String identityId)static org.exoplatform.social.core.identity.model.IdentitygetIdentityByTypeAndId(WalletType type, String remoteId)static org.exoplatform.services.listener.ListenerServicegetListenerService()static LocalegetLocale(Wallet wallet)static StringgetMyWalletLink()static longgetNetworkId()static List<String>getNotificationReceiversUsers(Wallet wallet, String excludedId)static StringgetPermanentLink(org.exoplatform.social.core.space.model.Space space)static StringgetPermanentLink(Wallet wallet)static StringgetResourceBundleKey(Locale locale, String key)static Set<String>getRewardAdministrators()static GlobalSettingsgetSettings()static org.exoplatform.social.core.space.model.SpacegetSpace(String id)static StringgetSpacePrettyName(String id)static org.exoplatform.social.core.space.spi.SpaceServicegetSpaceService()static LocalegetUserLocale(String username)static StringgetWalletLink(String receiverType, String receiverId)static WalletServicegetWalletService()static WalletTokenAdminServicegetWalletTokenAdminService()static StringgetWebsocketURL()static voidhideWalletOwnerPrivateInformation(Wallet wallet)static booleanisAdminAccount(String address)static booleanisUserMemberOfGroupOrUser(String username, String permissionExpression)static booleanisUserMemberOfSpaceOrGroupOrUser(String username, String accessPermission)static booleanisUserRewardingAdmin(String username)static booleanisUserSpaceManager(String id, String modifier)static booleanisUserSpaceMember(String spaceId, String accesssor)static booleanisWalletEmpty(Wallet wallet)static voidlogStatistics(TransactionDetail transactionDetail)static StringtoJsonString(Object object)static Map<String,Object>transactionToMap(TransactionDetail transactionDetail)
-
-
-
Field Detail
-
SIMPLE_CHARS
public static final char[] SIMPLE_CHARS
-
COMETD_CHANNEL
public static final String COMETD_CHANNEL
- See Also:
- Constant Field Values
-
TRANSACTION_EFFECTIVELY_SENT_CODE
public static final int TRANSACTION_EFFECTIVELY_SENT_CODE
- See Also:
- Constant Field Values
-
ETHER_TO_WEI_DECIMALS
public static final int ETHER_TO_WEI_DECIMALS
- See Also:
- Constant Field Values
-
GWEI_TO_WEI_DECIMALS
public static final int GWEI_TO_WEI_DECIMALS
- See Also:
- Constant Field Values
-
JSON_PARSER
public static final org.exoplatform.ws.frameworks.json.JsonParser JSON_PARSER
-
JSON_GENERATOR
public static final org.exoplatform.ws.frameworks.json.JsonGenerator JSON_GENERATOR
-
EMPTY_HASH
public static final String EMPTY_HASH
- See Also:
- Constant Field Values
-
NETWORK_ID
public static final String NETWORK_ID
- See Also:
- Constant Field Values
-
NETWORK_URL
public static final String NETWORK_URL
- See Also:
- Constant Field Values
-
NETWORK_WS_URL
public static final String NETWORK_WS_URL
- See Also:
- Constant Field Values
-
ACCESS_PERMISSION
public static final String ACCESS_PERMISSION
- See Also:
- Constant Field Values
-
TOKEN_ADDRESS
public static final String TOKEN_ADDRESS
- See Also:
- Constant Field Values
-
DEFAULT_INITIAL_USER_FUND
public static final String DEFAULT_INITIAL_USER_FUND
- See Also:
- Constant Field Values
-
DYNAMIC_GAS_PRICE_UPDATE_INTERVAL
public static final String DYNAMIC_GAS_PRICE_UPDATE_INTERVAL
- See Also:
- Constant Field Values
-
GAS_LIMIT
public static final String GAS_LIMIT
- See Also:
- Constant Field Values
-
DEFAULT_MIN_GAS_PRICE
public static final long DEFAULT_MIN_GAS_PRICE
- See Also:
- Constant Field Values
-
DEFAULT_NORMAL_GAS_PRICE
public static final long DEFAULT_NORMAL_GAS_PRICE
- See Also:
- Constant Field Values
-
DEFAULT_MAX_GAS_PRICE
public static final long DEFAULT_MAX_GAS_PRICE
- See Also:
- Constant Field Values
-
MIN_GAS_PRICE
public static final String MIN_GAS_PRICE
- See Also:
- Constant Field Values
-
NORMAL_GAS_PRICE
public static final String NORMAL_GAS_PRICE
- See Also:
- Constant Field Values
-
MAX_GAS_PRICE
public static final String MAX_GAS_PRICE
- See Also:
- Constant Field Values
-
LAST_BLOCK_NUMBER_KEY_NAME
public static final String LAST_BLOCK_NUMBER_KEY_NAME
- See Also:
- Constant Field Values
-
SCOPE_NAME
public static final String SCOPE_NAME
- See Also:
- Constant Field Values
-
INITIAL_FUNDS_KEY_NAME
public static final String INITIAL_FUNDS_KEY_NAME
- See Also:
- Constant Field Values
-
SETTINGS_KEY_NAME
public static final String SETTINGS_KEY_NAME
- See Also:
- Constant Field Values
-
WALLET_CONTEXT
public static final org.exoplatform.commons.api.settings.data.Context WALLET_CONTEXT
-
WALLET_SCOPE
public static final org.exoplatform.commons.api.settings.data.Scope WALLET_SCOPE
-
WALLET_USER_TRANSACTION_NAME
public static final String WALLET_USER_TRANSACTION_NAME
- See Also:
- Constant Field Values
-
WALLET_BROWSER_PHRASE_NAME
public static final String WALLET_BROWSER_PHRASE_NAME
- See Also:
- Constant Field Values
-
ADMIN_KEY_PARAMETER
public static final String ADMIN_KEY_PARAMETER
- See Also:
- Constant Field Values
-
ABI_PATH_PARAMETER
public static final String ABI_PATH_PARAMETER
- See Also:
- Constant Field Values
-
BIN_PATH_PARAMETER
public static final String BIN_PATH_PARAMETER
- See Also:
- Constant Field Values
-
ADMINISTRATORS_GROUP
public static final String ADMINISTRATORS_GROUP
- See Also:
- Constant Field Values
-
REWARDINGS_GROUP
public static final String REWARDINGS_GROUP
- See Also:
- Constant Field Values
-
WALLET_ADMIN_REMOTE_ID
public static final String WALLET_ADMIN_REMOTE_ID
- See Also:
- Constant Field Values
-
PRINCIPAL_CONTRACT_ADMIN_NAME
public static final String PRINCIPAL_CONTRACT_ADMIN_NAME
- See Also:
- Constant Field Values
-
WALLET_MODIFIED_EVENT
public static final String WALLET_MODIFIED_EVENT
- See Also:
- Constant Field Values
-
CONTRACT_MODIFIED_EVENT
public static final String CONTRACT_MODIFIED_EVENT
- See Also:
- Constant Field Values
-
TRANSACTION_MINED_AND_UPDATED_EVENT
public static final String TRANSACTION_MINED_AND_UPDATED_EVENT
- See Also:
- Constant Field Values
-
TRANSACTION_SENT_TO_BLOCKCHAIN_EVENT
public static final String TRANSACTION_SENT_TO_BLOCKCHAIN_EVENT
- See Also:
- Constant Field Values
-
TRANSACTION_CREATED_EVENT
public static final String TRANSACTION_CREATED_EVENT
- See Also:
- Constant Field Values
-
TRANSACTION_MODIFIED_EVENT
public static final String TRANSACTION_MODIFIED_EVENT
- See Also:
- Constant Field Values
-
WALLET_ENABLED_EVENT
public static final String WALLET_ENABLED_EVENT
- See Also:
- Constant Field Values
-
WALLET_DISABLED_EVENT
public static final String WALLET_DISABLED_EVENT
- See Also:
- Constant Field Values
-
WALLET_DELETED_EVENT
public static final String WALLET_DELETED_EVENT
- See Also:
- Constant Field Values
-
WALLET_INITIALIZATION_MODIFICATION_EVENT
public static final String WALLET_INITIALIZATION_MODIFICATION_EVENT
- See Also:
- Constant Field Values
-
CONTRACT_FUNC_TRANSFER
public static final String CONTRACT_FUNC_TRANSFER
- See Also:
- Constant Field Values
-
CONTRACT_FUNC_TRANSFERFROM
public static final String CONTRACT_FUNC_TRANSFERFROM
- See Also:
- Constant Field Values
-
CONTRACT_FUNC_TRANSFEROWNERSHIP
public static final String CONTRACT_FUNC_TRANSFEROWNERSHIP
- See Also:
- Constant Field Values
-
CONTRACT_FUNC_TRANSFORMTOVESTED
public static final String CONTRACT_FUNC_TRANSFORMTOVESTED
- See Also:
- Constant Field Values
-
CONTRACT_FUNC_APPROVE
public static final String CONTRACT_FUNC_APPROVE
- See Also:
- Constant Field Values
-
CONTRACT_FUNC_INITIALIZEACCOUNT
public static final String CONTRACT_FUNC_INITIALIZEACCOUNT
- See Also:
- Constant Field Values
-
CONTRACT_FUNC_REWARD
public static final String CONTRACT_FUNC_REWARD
- See Also:
- Constant Field Values
-
CONTRACT_FUNC_ADDADMIN
public static final String CONTRACT_FUNC_ADDADMIN
- See Also:
- Constant Field Values
-
NEW_ADDRESS_ASSOCIATED_EVENT
public static final String NEW_ADDRESS_ASSOCIATED_EVENT
- See Also:
- Constant Field Values
-
MODIFY_ADDRESS_ASSOCIATED_EVENT
public static final String MODIFY_ADDRESS_ASSOCIATED_EVENT
- See Also:
- Constant Field Values
-
NEW_BLOCK_MINED_EVENT
public static final String NEW_BLOCK_MINED_EVENT
- See Also:
- Constant Field Values
-
TRANSACTION_MINED_EVENT
public static final String TRANSACTION_MINED_EVENT
- See Also:
- Constant Field Values
-
CONTRACT_TRANSACTION_MINED_EVENT
public static final String CONTRACT_TRANSACTION_MINED_EVENT
- See Also:
- Constant Field Values
-
KNOWN_TRANSACTION_REPLACED_EVENT
public static final String KNOWN_TRANSACTION_REPLACED_EVENT
- See Also:
- Constant Field Values
-
TRANSACTION_PENDING_MAX_DAYS
public static final String TRANSACTION_PENDING_MAX_DAYS
- See Also:
- Constant Field Values
-
MAX_PENDING_TRANSACTIONS_TO_SEND
public static final String MAX_PENDING_TRANSACTIONS_TO_SEND
- See Also:
- Constant Field Values
-
MAX_SENDING_TRANSACTIONS_ATTEMPTS
public static final String MAX_SENDING_TRANSACTIONS_ATTEMPTS
- See Also:
- Constant Field Values
-
WALLET_SENDER_NOTIFICATION_ID
public static final String WALLET_SENDER_NOTIFICATION_ID
- See Also:
- Constant Field Values
-
WALLET_RECEIVER_NOTIFICATION_ID
public static final String WALLET_RECEIVER_NOTIFICATION_ID
- See Also:
- Constant Field Values
-
FUNDS_REQUEST_NOTIFICATION_ID
public static final String FUNDS_REQUEST_NOTIFICATION_ID
- See Also:
- Constant Field Values
-
FUNDS_REQUEST_SENT
public static final String FUNDS_REQUEST_SENT
- See Also:
- Constant Field Values
-
CONTRACT_ADDRESS
public static final String CONTRACT_ADDRESS
- See Also:
- Constant Field Values
-
AMOUNT
public static final String AMOUNT
- See Also:
- Constant Field Values
-
SYMBOL
public static final String SYMBOL
- See Also:
- Constant Field Values
-
TOKEN_NAME
public static final String TOKEN_NAME
- See Also:
- Constant Field Values
-
MESSAGE
public static final String MESSAGE
- See Also:
- Constant Field Values
-
HASH
public static final String HASH
- See Also:
- Constant Field Values
-
ACCOUNT_TYPE
public static final String ACCOUNT_TYPE
- See Also:
- Constant Field Values
-
RECEIVER_TYPE
public static final String RECEIVER_TYPE
- See Also:
- Constant Field Values
-
AVATAR
public static final String AVATAR
- See Also:
- Constant Field Values
-
SENDER
public static final String SENDER
- See Also:
- Constant Field Values
-
USER
public static final String USER
- See Also:
- Constant Field Values
-
USER_URL
public static final String USER_URL
- See Also:
- Constant Field Values
-
SENDER_URL
public static final String SENDER_URL
- See Also:
- Constant Field Values
-
RECEIVER
public static final String RECEIVER
- See Also:
- Constant Field Values
-
RECEIVER_URL
public static final String RECEIVER_URL
- See Also:
- Constant Field Values
-
FUNDS_ACCEPT_URL
public static final String FUNDS_ACCEPT_URL
- See Also:
- Constant Field Values
-
OPERATION_GET_TRANSACTION_COUNT
public static final String OPERATION_GET_TRANSACTION_COUNT
- See Also:
- Constant Field Values
-
OPERATION_GET_FILTER_LOGS
public static final String OPERATION_GET_FILTER_LOGS
- See Also:
- Constant Field Values
-
OPERATION_NEW_FILTER
public static final String OPERATION_NEW_FILTER
- See Also:
- Constant Field Values
-
OPERATION_UNINSTALL_FILTER
public static final String OPERATION_UNINSTALL_FILTER
- See Also:
- Constant Field Values
-
OPERATION_GET_FILTER_CHANGES
public static final String OPERATION_GET_FILTER_CHANGES
- See Also:
- Constant Field Values
-
OPERATION_GET_GAS_PRICE
public static final String OPERATION_GET_GAS_PRICE
- See Also:
- Constant Field Values
-
OPERATION_READ_FROM_TOKEN
public static final String OPERATION_READ_FROM_TOKEN
- See Also:
- Constant Field Values
-
OPERATION_GET_ETHER_BALANCE
public static final String OPERATION_GET_ETHER_BALANCE
- See Also:
- Constant Field Values
-
OPERATION_GET_LAST_BLOCK_NUMBER
public static final String OPERATION_GET_LAST_BLOCK_NUMBER
- See Also:
- Constant Field Values
-
OPERATION_GET_TRANSACTION
public static final String OPERATION_GET_TRANSACTION
- See Also:
- Constant Field Values
-
OPERATION_GET_BLOCK
public static final String OPERATION_GET_BLOCK
- See Also:
- Constant Field Values
-
OPERATION_GET_BLOCK_BY_NUMBER
public static final String OPERATION_GET_BLOCK_BY_NUMBER
- See Also:
- Constant Field Values
-
OPERATION_GET_BLOCK_BY_HASH
public static final String OPERATION_GET_BLOCK_BY_HASH
- See Also:
- Constant Field Values
-
OPERATION_GET_TRANSACTION_RECEIPT
public static final String OPERATION_GET_TRANSACTION_RECEIPT
- See Also:
- Constant Field Values
-
OPERATION_SEND_TRANSACTION
public static final String OPERATION_SEND_TRANSACTION
- See Also:
- Constant Field Values
-
FUNDS_REQUEST_SENDER_DETAIL_PARAMETER
public static final org.exoplatform.commons.api.notification.model.ArgumentLiteral<Wallet> FUNDS_REQUEST_SENDER_DETAIL_PARAMETER
-
SENDER_ACCOUNT_DETAIL_PARAMETER
public static final org.exoplatform.commons.api.notification.model.ArgumentLiteral<Wallet> SENDER_ACCOUNT_DETAIL_PARAMETER
-
RECEIVER_ACCOUNT_DETAIL_PARAMETER
public static final org.exoplatform.commons.api.notification.model.ArgumentLiteral<Wallet> RECEIVER_ACCOUNT_DETAIL_PARAMETER
-
FUNDS_REQUEST_PARAMETER
public static final org.exoplatform.commons.api.notification.model.ArgumentLiteral<FundsRequest> FUNDS_REQUEST_PARAMETER
-
CONTRACT_DETAILS_PARAMETER
public static final org.exoplatform.commons.api.notification.model.ArgumentLiteral<ContractDetail> CONTRACT_DETAILS_PARAMETER
-
AMOUNT_PARAMETER
public static final org.exoplatform.commons.api.notification.model.ArgumentLiteral<Double> AMOUNT_PARAMETER
-
MESSAGE_PARAMETER
public static final org.exoplatform.commons.api.notification.model.ArgumentLiteral<String> MESSAGE_PARAMETER
-
HASH_PARAMETER
public static final org.exoplatform.commons.api.notification.model.ArgumentLiteral<String> HASH_PARAMETER
-
SYMBOL_PARAMETER
public static final org.exoplatform.commons.api.notification.model.ArgumentLiteral<String> SYMBOL_PARAMETER
-
CONTRACT_ADDRESS_PARAMETER
public static final org.exoplatform.commons.api.notification.model.ArgumentLiteral<String> CONTRACT_ADDRESS_PARAMETER
-
RESOURCE_BUNDLE_NAME
public static final String RESOURCE_BUNDLE_NAME
- See Also:
- Constant Field Values
-
TOKEN_FUNC_SETSELLPRICE
public static final String TOKEN_FUNC_SETSELLPRICE
- See Also:
- Constant Field Values
-
TOKEN_FUNC_INITIALIZEACCOUNT
public static final String TOKEN_FUNC_INITIALIZEACCOUNT
- See Also:
- Constant Field Values
-
TOKEN_FUNC_DEPOSIT_FUNDS
public static final String TOKEN_FUNC_DEPOSIT_FUNDS
- See Also:
- Constant Field Values
-
ETHER_FUNC_SEND_FUNDS
public static final String ETHER_FUNC_SEND_FUNDS
- See Also:
- Constant Field Values
-
blockchainUrlSuffix
public static String blockchainUrlSuffix
-
-
Method Detail
-
getCurrentUserId
public static final String getCurrentUserId()
-
getCurrentUserIdentityId
public static final long getCurrentUserIdentityId()
-
getNotificationReceiversUsers
public static List<String> getNotificationReceiversUsers(Wallet wallet, String excludedId)
-
getIdentityById
public static org.exoplatform.social.core.identity.model.Identity getIdentityById(long identityId)
-
getIdentityById
public static org.exoplatform.social.core.identity.model.Identity getIdentityById(String identityId)
-
getIdentityByTypeAndId
public static org.exoplatform.social.core.identity.model.Identity getIdentityByTypeAndId(WalletType type, String remoteId)
-
getSpace
public static org.exoplatform.social.core.space.model.Space getSpace(String id)
-
computeWalletIdentity
public static void computeWalletIdentity(Wallet wallet)
-
getRewardAdministrators
public static Set<String> getRewardAdministrators() throws Exception
- Throws:
Exception
-
isUserRewardingAdmin
public static final boolean isUserRewardingAdmin(String username)
-
isUserMemberOfSpaceOrGroupOrUser
public static final boolean isUserMemberOfSpaceOrGroupOrUser(String username, String accessPermission)
-
isUserMemberOfGroupOrUser
public static final boolean isUserMemberOfGroupOrUser(String username, String permissionExpression)
-
getMyWalletLink
public static String getMyWalletLink()
-
getPermanentLink
public static String getPermanentLink(org.exoplatform.social.core.space.model.Space space)
-
canAccessWallet
public static boolean canAccessWallet(Wallet wallet, String currentUser)
Return true if user can access wallet detailed information- Parameters:
wallet- wallet details to checkcurrentUser- user accessing wallet details- Returns:
- true if has access, else false
-
checkUserIsSpaceManager
public static boolean checkUserIsSpaceManager(String spaceId, String modifier, boolean throwException) throws IllegalAccessException
- Throws:
IllegalAccessException
-
computeWalletFromIdentity
public static final void computeWalletFromIdentity(Wallet wallet, org.exoplatform.social.core.identity.model.Identity identity)
-
hideWalletOwnerPrivateInformation
public static final void hideWalletOwnerPrivateInformation(Wallet wallet)
-
convertToDecimals
public static final BigInteger convertToDecimals(double amount, int decimals)
-
convertFromDecimals
public static final double convertFromDecimals(BigInteger amount, int decimals)
-
getSettings
public static final GlobalSettings getSettings()
-
getGasLimit
public static final Long getGasLimit()
-
getContractDetail
public static final ContractDetail getContractDetail()
-
getContractAddress
public static final String getContractAddress()
-
getNetworkId
public static final long getNetworkId()
-
getWebsocketURL
public static final String getWebsocketURL()
-
isWalletEmpty
public static final boolean isWalletEmpty(Wallet wallet)
-
isAdminAccount
public static final boolean isAdminAccount(String address)
-
getBlockchainURLSuffix
public static final String getBlockchainURLSuffix()
-
logStatistics
public static final void logStatistics(TransactionDetail transactionDetail)
-
getWalletTokenAdminService
public static final WalletTokenAdminService getWalletTokenAdminService()
-
getWalletService
public static final WalletService getWalletService()
-
getSpaceService
public static final org.exoplatform.social.core.space.spi.SpaceService getSpaceService()
-
formatBalance
public static final String formatBalance(double balance, Locale locale, boolean simplified)
Format Wallet Balance amount in currency format, without currency symbol and switch user locale.- Parameters:
balance- amount to formatlocale- designated locale to display balancesimplified- if true, the fractions will be ignored when the balance is greater than 100.- Returns:
- formatted balance in user locale
-
getListenerService
public static final org.exoplatform.services.listener.ListenerService getListenerService()
-
broadcastTransactionReplacedEvent
public static void broadcastTransactionReplacedEvent(TransactionDetail oldTransaction, TransactionDetail newTransaction)
-
transactionToMap
public static Map<String,Object> transactionToMap(TransactionDetail transactionDetail)
-
-