Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default async function(ledger: AssetLedger) {
return Promise.all(
[ AssetLedgerCapability.DESTROY_ASSET,
AssetLedgerCapability.REVOKE_ASSET,
AssetLedgerCapability.TOGGLE_TRANSFERS,
AssetLedgerCapability.UPDATE_ASSET,
].map(async (capability) => {
const code = getInterfaceCode(capability);
const attrs = {
to: ledger.id,
data: functionSignature + ledger.provider.encoder.encodeParameters(inputTypes, [code]).substr(2),
};
const res = await ledger.provider.post({
method: 'eth_call',
params: [attrs, 'latest'],
});
return ledger.provider.encoder.decodeParameters(outputTypes, res.result)[0] ? capability : -1;
}),
).then((abilities) => {
export function getInterfaceCode(capability: AssetLedgerCapability): string {
if (capability == AssetLedgerCapability.DESTROY_ASSET) {
return '0x9d118770';
} else if (capability == AssetLedgerCapability.REVOKE_ASSET) {
return '0x20c5429b';
} else if (capability == AssetLedgerCapability.UPDATE_ASSET) {
return '0xbda0e852';
} else if (capability == AssetLedgerCapability.TOGGLE_TRANSFERS) {
return '0xbedb86fb';
} else {
return null;
}
}