@aeternity/aepp-sdk
Version:
SDK for the æternity blockchain
32 lines (31 loc) • 882 B
JavaScript
import shortUInt from './short-u-int.js';
import { ArgumentError } from '../../../utils/errors.js';
import { getHeight } from '../../../chain.js';
/**
* Time to leave
*/
export default {
...shortUInt,
serialize(value) {
return shortUInt.serialize(value !== null && value !== void 0 ? value : 0);
},
async prepare(value, params,
// TODO: { absoluteTtl: true } | { absoluteTtl: false, onNode: Node }
{
onNode,
absoluteTtl,
_isInternalBuild,
...options
}) {
if (absoluteTtl !== true && value !== 0 && (value != null || _isInternalBuild === true)) {
if (onNode == null) throw new ArgumentError('onNode', 'provided', onNode);
value = (value !== null && value !== void 0 ? value : 3) + (await getHeight({
...options,
onNode,
cached: true
}));
}
return value;
}
};
//# sourceMappingURL=ttl.js.map