Created
July 8, 2019 16:30
-
-
Save jafri/fe44e7eda7d88b576de6e89f34d60728 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[[eosio::action]] void modifypkg2(uint64_t id, package newpackage) { | |
require_auth(newpackage.provider); | |
packages_t packages(_self, _self.value); | |
auto idxKey = package::_by_package_service_provider( | |
newpackage.package_id, newpackage.service, newpackage.provider); | |
auto cidx = packages.get_index<"bypkg"_n>(); | |
auto existing = cidx.find(idxKey); | |
eosio::check(existing != cidx.end(), "does not exist"); | |
eosio::check(newpackage.quota.symbol == DAPPSERVICES_QUOTA_SYMBOL, "wrong symbol"); | |
packages.modify(existing, newpackage.provider, [&](package &r) { | |
r.provider = newpackage.provider; | |
r.service = newpackage.service; | |
r.package_id = newpackage.package_id; | |
r.quota = newpackage.quota; | |
r.min_stake_quantity = newpackage.min_stake_quantity; | |
r.min_unstake_period = newpackage.min_unstake_period; | |
r.package_json_uri = newpackage.package_json_uri; | |
r.api_endpoint = newpackage.api_endpoint; | |
r.package_period = newpackage.package_period; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment