Open
Description
For example CreateAssetTx.
The issue is that there is no consistent way to getInputs
or serialize it using toBytes()
This is how I currently read the inputs
const inputs: avaxSerial.TransferableInput[] = [];
// @ts-ignore
if (transaction.unsignedTx.inputs) {
// @ts-ignore
inputs.push(...transaction.unsignedTx.inputs);
// @ts-ignore
} else if (transaction.unsignedTx.baseTx.inputs) {
// @ts-ignore
inputs.push(...transaction.unsignedTx.baseTx.inputs);
}
and this is how I serialize
export function serializeSignedTx(tx: avaxSerial.SignedTx): Buffer {
if (tx.unsignedTx.vm) {
return Buffer.from(tx.toBytes());
} else if (tx.unsignedTx._type.startsWith('avm.')) {
return Buffer.from(
utils.concatBytes(
new Short(0).toBytes(),
utils.getManagerForVM('AVM').codecs[0].PackPrefix(tx.unsignedTx),
utils.getManagerForVM('AVM').codecs[0].PackPrefixList(tx.credentials),
),
);
} else {
return Buffer.from(
utils.concatBytes(
new Short(0).toBytes(),
utils.getManagerForVM('PVM').codecs[0].PackPrefix(tx.unsignedTx),
utils.getManagerForVM('PVM').codecs[0].PackPrefixList(tx.credentials),
),
);
}
}
is there better way?
Metadata
Metadata
Assignees
Labels
No labels