Last active
June 6, 2019 04:11
-
-
Save pizzarob/3f52c1437ec93352f23882e2a836a5c9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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