Skip to content

Instantly share code, notes, and snippets.

@jafri
Created July 8, 2019 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jafri/fe44e7eda7d88b576de6e89f34d60728 to your computer and use it in GitHub Desktop.
Save jafri/fe44e7eda7d88b576de6e89f34d60728 to your computer and use it in GitHub Desktop.
[[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