@aeternity/aepp-sdk
Version:
SDK for the æternity blockchain
34 lines • 1.23 kB
JavaScript
import { Buffer as _Buffer } from "buffer";
import { Tag, ConsensusProtocolVersion } from '../constants.js';
import { getProtocolDetails } from './ct-version.js';
export default {
_getProtocolDetails(c, tag) {
const kind = Tag.ContractCallTx === tag || Tag.GaMetaTx === tag ? 'contract-call' : 'oracle-call';
return getProtocolDetails(c, kind).abiVersion;
},
serialize(value, {
tag
}, {
consensusProtocolVersion = ConsensusProtocolVersion.Ceres
}) {
const result = value !== null && value !== void 0 ? value : this._getProtocolDetails(consensusProtocolVersion, tag);
return _Buffer.from([result]);
},
async prepare(value, {
tag
},
// TODO: { consensusProtocolVersion: ConsensusProtocolVersion } | { onNode: Node } | {}
options) {
if (value != null) return value;
if (options.consensusProtocolVersion != null) return undefined;
if (Object.keys(ConsensusProtocolVersion).length === 2) return undefined;
if (options.onNode != null) {
return this._getProtocolDetails((await options.onNode.getNodeInfo()).consensusProtocolVersion, tag);
}
return undefined;
},
deserialize(buffer) {
return buffer[0];
}
};
//# sourceMappingURL=abi-version.js.map