README
OCAP Adapter
Defines the interface of OCAP query resolver.
Usage
yarn add @ocap/tx-pipeline
Then:
const TxPipeline = require('@ocap/tx-pipeline');
const NedbAdapter = require('@ocap/statedb-nedb');
const { DecodeTx, VerifyTx, VerifyBlacklist, DecodeItx, VerifySignature, ExtractState } = TxPipeline;
// Pre-pipelines
// Check-pipelines: formal
// Verify-pipelines: against state db
// Update-pipelines: change state db
// Create pipeline, this should be defined in `@ocap/tx-protocols`
const pipeline = new TxPipeline('transfer');
// Reuse common pipeline
pipeline.use(DecodeTx);
pipeline.use(VerifyTx);
pipeline.use(VerifyBlacklist);
pipeline.use(DecodeItx);
pipeline.use(VerifySignature);
pipeline.use(ExtractState({ from: 'tx.from', to: 'senderState' }));
// Attach custom pipeline
pipeline.use(async ({ itx, tx, context, states }, options) => {
// Do something
});
// Execute transactions
const transaction = {}; // object or base64 encoded string
const adapter = new NedbAdapter({ dbPath: '/path/to/db' });
pipeline
.execute(pipeline, adapter)
.then((hash) => {
console.info('Transaction execution success', hash);
})
.catch((err) => {
console.error('Transaction execution failed', err.message);
});
Pipes not supported
- VerifyModerator: chain administration
- CheckError: log info on error
- AntiReplayExchangeAttack