Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test("balanceOf", () => {
const resultFunction = abi.balanceOf(scriptHash, fromAddr);
const resultScript = resultFunction().str;
expect(resultScript).toBe(
`14${u.reverseHex(
wallet.getScriptHashFromAddress(fromAddr)
)}51c10962616c616e63654f6667${u.reverseHex(scriptHash)}`
);
});
test("decimals", () => {
const resultFunction = abi.decimals(scriptHash);
const resultScript = resultFunction().str;
expect(resultScript).toBe(
`0008646563696d616c7367${u.reverseHex(scriptHash)}`
);
});
scriptHashArray.forEach(scriptHash => {
if (address) {
const addrScriptHash = u.reverseHex(
wallet.getScriptHashFromAddress(address)
);
sb.emitAppCall(scriptHash, "name")
.emitAppCall(scriptHash, "symbol")
.emitAppCall(scriptHash, "decimals")
.emitAppCall(scriptHash, "totalSupply")
.emitAppCall(scriptHash, "balanceOf", [addrScriptHash]);
} else {
sb.emitAppCall(scriptHash, "name")
.emitAppCall(scriptHash, "symbol")
.emitAppCall(scriptHash, "decimals")
.emitAppCall(scriptHash, "totalSupply");
}
});
export async function addAttributeIfExecutingAsSmartContract<
T extends ManagedApiBasicConfig
>(config: T): Promise {
if (!config.sendingFromSmartContract) {
return config;
}
config.tx!.addAttribute(
tx.TxAttrUsage.Script,
u.reverseHex(config.sendingFromSmartContract)
);
return config;
}
].map(hash => u.reverseHex(hash.toBigEndian()));
}