MCPcopy Create free account
hub / github.com/QuipNetwork/cpp-sdk / getVaults

Method getVaults

src/quip_factory.cpp:285–314  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

283 }
284
285 std::vector<Vault> getVaults(const Address &owner) {
286 Address checksummed_owner = quip::toChecksumAddress(owner);
287 std::vector<Vault> vaults;
288 uint32_t index = 0;
289 while (true) {
290 try {
291 VaultId vault_id = getVaultId(checksummed_owner, index);
292 // The contract returns 0x0...0 if the index is out of bounds.
293 if (std::all_of(vault_id.begin(), vault_id.end(),
294 [](uint8_t i) { return i == 0; })) {
295 break;
296 }
297
298 Address wallet_address =
299 getQuipWalletAddress(vault_id, checksummed_owner);
300 if (wallet_address != "0x0000000000000000000000000000000000000000") {
301 Vault v;
302 v.id = vault_id;
303 v.classical_address = wallet_address;
304 vaults.push_back(v);
305 }
306 index++;
307 } catch (const std::exception &e) {
308 // Break the loop on any error, which likely means we're past the end of
309 // the array
310 break;
311 }
312 }
313 return vaults;
314 }
315
316private:
317 VaultId getVaultId(const Address &owner, uint32_t index) {

Callers

nothing calls this directly

Calls 1

toChecksumAddressFunction · 0.85

Tested by

no test coverage detected