Skip to content

Instantly share code, notes, and snippets.

@pizzarob
Last active June 6, 2019 04:11
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 pizzarob/3f52c1437ec93352f23882e2a836a5c9 to your computer and use it in GitHub Desktop.
Save pizzarob/3f52c1437ec93352f23882e2a836a5c9 to your computer and use it in GitHub Desktop.
if (isEnabled) {
// Get all the vendors in your crate. The creator of the crate (you) is
// added as a default vendor.
const { data: vendors } = await cargo.api.getCrateVendors(CRATE_ID);
// Map through each vendor and get the token contracts they created.
const contractResponses = await Promise.all(
vendors.map(({ vendorId }) => cargo.api.getVendorTokenContracts(vendorId))
);
// Map the responses so we have an array of just the contract data.
const contracts = [];
// Each vendor response has an array of contracts so we spread that data into
// our contracts array do it is one dimensional.
contractResponses.forEach(({ data }) => {
contracts.push(...data);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment