object HubContract : SmartContract
(source)
const val CARRY_SPACE_SIZE: Int |
|
const val DEMAND_INFO_SIZE: Int |
|
const val DEMAND_SIZE: Int |
|
const val FEE_DEMAND_REWARD: Long |
|
const val FEE_TRAVEL_DEPOSIT: Long |
|
const val LOG_LEVEL: Int |
|
const val MAX_GAS_ITEM_VALUE: Long |
|
const val MIN_GAS_ITEM_VALUE: Long |
|
const val REP_REQUIRED_SIZE: Int |
|
const val RESERVATION_SIZE: Int |
|
const val SCRIPT_HASH_SIZE: Int |
|
const val STATS_ENABLED: Boolean |
|
const val STORAGE_KEY_INITIALIZED: String |
|
const val STORAGE_KEY_INIT_WALLET_P1: String |
|
const val STORAGE_KEY_INIT_WALLET_P2: String |
|
const val STORAGE_KEY_INIT_WALLET_P3: String |
|
const val STORAGE_KEY_STATS_DEMANDS: String |
|
const val STORAGE_KEY_STATS_FUNDS: String |
|
const val STORAGE_KEY_STATS_ROUTES: String |
|
const val STORAGE_KEY_SUFFIX_DEMAND: Byte |
|
const val STORAGE_KEY_SUFFIX_REP: Byte |
|
const val STORAGE_KEY_SUFFIX_RESERVATIONS: Byte |
|
const val STORAGE_KEY_SUFFIX_TRAVEL: Byte |
|
const val TESTS_ENABLED: Boolean |
|
const val TIMESTAMP_SIZE: Int |
|
const val TRAVEL_EXTRA_EXPIRY_ON_MATCH: Long |
|
const val TRAVEL_SIZE: Int |
|
const val TX_HASH_SIZE: Int |
|
const val VALUE_SIZE: Int |
fun Main(operation: String, vararg args: ByteArray): Any
The entry point of the smart contract. |
|
fun ByteArray.concat(b2: ByteArray): ByteArray
Concatenates two ByteArray together. |
|
fun demand_create(owner: ScriptHash, expiry: BigInteger, repRequired: BigInteger, itemSize: BigInteger, itemValue: BigInteger, infoBlob: ByteArray, nowTime: Int): Demand
Creates a new Demand object. |
|
fun Demand.demand_getExpiry(): BigInteger
Gets the expiry timestamp of a Demand. |
|
fun Demand.demand_getInfoBlob(): ByteArray
Gets the info string for a Demand. |
|
fun Demand.demand_getItemSize(): BigInteger
Gets the size of the desired item. |
|
fun Demand.demand_getItemValue(): BigInteger
Gets the desired item's value. |
|
fun Demand.demand_getLookupKey(cityPairHash: Hash160, nowTime: Int): ByteArray
Gets the key used to store the demand for tracking lookup. Tracking requires knowledge of the "identifier" and city pair. |
|
fun Demand.demand_getMatchKey(): ByteArray
Gets the storage key to store a Travel match for this Demand. |
|
fun Demand.demand_getMatchedAtTime(): BigInteger
Gets the time at which this Demand was matched with a Travel. |
|
fun Demand.demand_getOwnerScriptHash(): ScriptHash
Gets the owner of the Demand. |
|
fun Demand.demand_getRepRequired(): BigInteger
Gets the reputation score required of a Travel in order to match this Demand. |
|
fun Hash160.demand_getStorageKey(): ByteArray
Gets the storage key for a Demand, which is essentially just the city pair hash with a suffix. This is called on the city pair hash. |
|
fun Demand.demand_getTotalValue(): BigInteger
Gets the Demand's total value (item value + reward fee). |
|
fun Demand.demand_isMatched(): Boolean
Determines whether the given Demand has been matched with a Travel object. |
|
fun Demand.demand_reserveValueAndFee(owner: ScriptHash): Unit
Reserves the item's value and reward fee for a new demand. |
|
fun Demand.demand_reserveValueAndFee2(owner: ScriptHash, matchedTravel: Travel): Unit
Reserves the item's value and reward fee for a new demand. This form of the method is used when a Travel was found to be matched with the Demand. |
|
fun Demand.demand_storeAndMatch(owner: ScriptHash, cityPairHash: Hash160, nowTime: Int): Boolean
Performs all the legwork necessary to store and match a Demand with a Travel. |
|
fun DemandList.demands_findMatchableDemand(repRequired: BigInteger, carrySpaceAvailable: BigInteger, expiresAfter: BigInteger, nowTime: Int): Demand
Finds a Demand in a DemandList that fits the given attributes. |
|
fun DemandList.demands_getAt(index: Int): Travel
Gets the Demand at the given index in a DemandList. |
|
external fun getBalance(account: Account, asset_id: ByteArray): Long
Calls "Neo.Account.GetBalance". |
|
fun getGasAssetId(): ByteArray
Returns the GAS asset ID as a byte array. |
|
fun getWalletScriptP1(): ByteArray
Gets part 1 of the wallet script code (code before the public key), set at init time. |
|
fun getWalletScriptP2(): ByteArray
Gets part 2 of the wallet script code (code after the public key, before the script hash), set at init time. |
|
fun getWalletScriptP3(): ByteArray
Gets part 3 of the wallet script code (code after the script hash), set at init time. |
|
fun initialize(walletScriptP1: ByteArray, walletScriptP2: ByteArray, walletScriptP3: ByteArray): Boolean
Initializes the smart contract. This takes the three parts of the wallet script as arguments. These parts are stored and then used to verify the integrity of user wallets in the system. |
|
fun isInitialized(): Boolean
Checks whether the contract has been initialized. |
|
fun log_debug(msg: String): Unit
Dispatches a Runtime.notify with the specified arg at the DEBUG level (3). |
|
fun log_debug2(msg: String, arg: Any): Unit
Dispatches a Runtime.notify with the specified args at the DEBUG level (3). |
|
fun log_err(msg: String): Unit
Dispatches a Runtime.notify with the specified arg at the ERROR level (1). |
|
fun log_info(msg: String): Unit
Dispatches a Runtime.notify with the specified arg at INFO level (2). |
|
fun log_info2(msg: String, arg: Any): Unit
Dispatches a Runtime.notify with the specified args at INFO level (2). |
|
fun log_info3(msg: String, arg0: Any, arg1: Any): Unit
Dispatches a Runtime.notify with the specified args at INFO level (2). |
|
fun ByteArray.pad(count: Int): ByteArray
Pads a BigInteger that has been converted to a ByteArray to a specified byte length. |
|
fun ByteArray.range(index: Int, count: Int): ByteArray
Extracts a range of bytes from a ByteArray. |
|
fun ReservationList.res_findByValue(value: BigInteger): Int
Finds the reserved funds object with the given value in a ReservationList. |
|
fun ReservationList.res_findByValueAndRecipient(value: BigInteger, recipient: ScriptHash): Int
Finds the reserved funds object with the given value and recipient in a ReservationList. |
|
fun ReservationList.res_getAt(index: Int): Reservation
Gets the reserved funds object at the given index in a ReservationList. |
|
fun Reservation.res_getExpiry(): BigInteger
Gets the expiry timestamp for an individual Reservation. |
|
fun Reservation.res_getRecipient(): ScriptHash
Gets the intended recipient of reserved funds. |
|
fun ReservationList.res_getTotalOnHoldGasValue(excludeRecipient: ScriptHash, nowTime: Int): Long
Calculates the total value of GAS that a list of reserved funds is holding, considering expiry times and whether funds were already paid out to the intended recipient. |
|
fun Reservation.res_getValue(): BigInteger
Gets the GAS value of an individual Reservation. |
|
fun ReservationList.res_replaceRecipientAt(idx: Int, recipient: ScriptHash): ReservationList
Finds the reserved funds object at the given idx and replaces its recipient with the one given. |
|
fun Reservation.res_wasPaidToRecipient(): Boolean
Determines whether the reserved funds were paid out to the recipient. |
|
fun reservation_create(expiry: BigInteger, value: BigInteger, recipient: ScriptHash): Reservation
Creates a reserved funds object. |
|
fun stats_getDemandsCount(): BigInteger
Returns the number of demands created over time. |
|
fun stats_getReservedFundsCount(): BigInteger
Returns the amount of funds reserved over time as a fixed8 int. |
|
fun stats_getRouteUsageCount(): BigInteger
Returns the number of unique routes used over time. |
|
fun stats_recordDemandCreation(): Unit
Increments the counter that keeps the number of Demands created over time. |
|
fun stats_recordReservedFunds(value: BigInteger): Unit
Increments the counter that keeps a count of all funds reserved over time. |
|
fun stats_recordRouteUsage(cityPairHash: Hash160): Boolean
Increments the counter that keeps the number of unique routes used over time. |
|
fun ByteArray.take(count: Int): ByteArray
Takes a number of bytes from the start of a ByteArray. |
|
fun BigInteger.toByteArray(padToSize: Int = 0): ByteArray
Converts a BigInteger to a padded ByteArray. |
|
fun travel_create(owner: ScriptHash, expiry: BigInteger, repRequired: BigInteger, carrySpace: BigInteger, nowTime: Int): Travel
Creates a new Travel object. |
|
fun Travel.travel_getCarrySpace(): BigInteger
Gets the item carry space available. |
|
fun Travel.travel_getExpiry(): BigInteger
Gets the expiry timestamp of a Travel. |
|
fun Travel.travel_getLookupKey(cityPairHash: Hash160, nowTime: Int): ByteArray
Gets the key used to store the demand for tracking lookup. Tracking requires knowledge of the "identifier" and city pair. |
|
fun Travel.travel_getMatchKey(): ByteArray
Gets the storage key to store a Demand match for this Travel. |
|
fun Travel.travel_getMatchedAtTime(): BigInteger
Gets the time at which this Travel was matched with a Demand. |
|
fun Travel.travel_getOwnerScriptHash(): ScriptHash
Gets the owner of the Travel. |
|
fun Travel.travel_getRepRequired(): BigInteger
Gets the reputation score required of a Demand in order to match this Travel. |
|
fun Hash160.travel_getStorageKey(): ByteArray
Gets the storage key for a Travel, which is essentially just the city pair hash with a suffix. This is called on the city pair hash. |
|
fun Travel.travel_isMatched(): Boolean
Determines whether the given Travel has been matched with a Demand object. |
|
fun Travel.travel_overwriteExpiry(owner: ScriptHash, expiry: BigInteger): Unit
Re-reserves the deposit due by a traveller when they create a Travel with a revised expiry time. This method also updates a wallet's "state lock" with the new expiry time. |
|
fun Travel.travel_reserveDeposit(owner: ScriptHash): Unit
Reserves the deposit due by a traveller when they create a Travel. |
|
fun Travel.travel_storeAndMatch(owner: ScriptHash, cityPairHash: Hash160, nowTime: Int): Boolean
Performs all the legwork necessary to store and match a Travel with a Demand. |
|
fun TravelList.travels_findMatchableTravel(repRequired: BigInteger, carrySpaceRequired: BigInteger, expiryLimit: BigInteger, nowTime: Int): Travel
Finds a Travel in a TravelList that fits the given attributes. |
|
fun TravelList.travels_getAt(index: Int): Travel
Gets the Travel at the given index in a TravelList. |
|
fun tx_getOutgoingGasValue(originator: ScriptHash): Long
Finds the outgoing GAS value of the current transaction. This is useful for calculating whether the wallet can cover system fees when funds are going to be reserved in the invocation. |
|
external fun vm_booland(arg0: Any, arg1: Any): Boolean
Inserts the "BOOLAND" OpCode. Returns true if the given args are both true. |
|
external fun vm_throw(): Unit
Inserts the "THROW" OpCode. Aborts execution. |
|
external fun vm_throwIfNot(arg: Any): Unit
Inserts the "THROWIFNOT" OpCode. Aborts execution if the supplied arg is not true. |
|
fun ScriptHash.wallet_canOpenDemandOrTravel(nowTime: Int): Boolean
Indicates whether a wallet is in a state that allows it to open a demand or travel. At the moment this contract supports one active transaction per user wallet at any one time. |
|
fun ScriptHash.wallet_checkWitness(): Boolean
Calls Runtime.checkWitness on the provided script hash. Avoids making the call if the current ScriptContainer is null, which is the case when rpc "invokescript" is used. |
|
fun ScriptHash.wallet_clearFundReservations(): Unit
Deletes a wallet's reserved funds from storage. |
|
fun ScriptHash.wallet_clearState(): Unit
Clears all wallet system state, allowing for new Chain Line transactions. |
|
fun ScriptHash.wallet_getFundReservations(): ReservationList
Gets the list of reserved funds for the given wallet. |
|
fun ScriptHash.wallet_getFundReservationsStorageKey(): ByteArray
Gets the storage key used to store/lookup reserved funds for a wallet. |
|
fun ScriptHash.wallet_getGasBalance(): Long
Gets the GAS balance of a user wallet. |
|
fun ScriptHash.wallet_getReputationScore(): BigInteger
Gets the reputation score for a user wallet. |
|
fun ScriptHash.wallet_getReputationStorageKey(): ByteArray
Gets the storage key used to store/lookup user reputation for a wallet. |
|
fun ScriptHash.wallet_hasFunds(requiredBalance: Long, excludeRecipient: ScriptHash, nowTime: Int, countOutputs: Boolean): Boolean
Check if the wallet has enough funds to perform a transaction after reserved funds and tx outputs are considered. Note: Please ensure that the script has been through wallet_validate before this is called. |
|
fun ScriptHash.wallet_incrementReputationScore(): Unit
Increments the reputation score for the user wallet by 1. |
|
fun ScriptHash.wallet_requestTxOut(nowTime: Int): Boolean
Requests permission to perform a withdrawal from a user wallet using the value in tx outputs. Note: Please ensure that the script has been through wallet_validate before this is called. |
|
fun ScriptHash.wallet_reserveFunds(expiry: BigInteger, value: BigInteger, recipient: ScriptHash): Unit
Reserves funds in a previously validated user wallet. Overwrites any existing fund reservations. |
|
fun ScriptHash.wallet_setFundsPaidToRecipientTxHash(recipient: ScriptHash, value: BigInteger, txHash: Hash256): Boolean
Sets the transaction hash of funds that have been transferred to the recipient of reserved funds. |
|
fun ScriptHash.wallet_storeFundReservations(resList: ReservationList): Unit
Stores reserved funds for the given wallet. |
|
fun ScriptHash.wallet_storeReputationScore(rep: BigInteger): Unit
Stores a reputation score for a user wallet. |
|
fun ScriptHash.wallet_validate(pubKey: PublicKey): Boolean
Calls wallet_checkWitness on and validates the integrity of the provided script hash. |