-
Notifications
You must be signed in to change notification settings - Fork 1
Description
What to do
- Move
createMessagefrom msb to the trac-crypto-api - Move
bigIntToDecimalStringandbufferToBigIntfrom msb to the trac-crypto-api - Move more stuff that makes sense especially if its associated with TNK conversion.
- Change both peer and msb to pull those from the api instead of their own source (and remove the code accordingly).
Benefit
We dont need to commit (support) to those functions on an application level, we eliminate duplication and we can change msb independently from peer which eliminates a coupling layer (making sure that change that on msb wont break peer, especially if a someone uses an expression on package.json like some people do.
Reasoning
Peer, the contract and MSB are using some basic functionality from msb. In this case, it doesnt make sense for MSB itself to export since its free-of-context logic. I would imagine the best place would be the trac-crypto-api.
import { createMessage } from "trac-msb/src/utils/buffer.js";
import { bufferToBigInt, bigIntToDecimalString } from "trac-msb/src/utils/amountSerialization.js";
The bufferToBigInt may be a bit overstretching. We use it to display info on msb. Msb should be able to display info about itself through proper delegation so I would keep that out. That is further suplemented by the fact that a balance representation in binary IS, pretty much, a specific concern of msb (but might still be worth doing). The others probably make a little bit more sense since pretty print of bigints can be associated with wallet-like daps and create message could be seen as an auxiliary function for serializing, hashing and signing (which is a very standard crypto process).
The dump of the imports (for ilustrative purposes).
import { bufferToBigInt, bigIntToDecimalString } from "trac-msb/src/utils/amountSerialization.js";
import PartialTransaction from "trac-msb/src/core/network/protocols/shared/validators/PartialTransaction.js";
import { normalizeTransactionOperation } from "trac-msb/src/utils/normalizers.js";
import { safeDecodeApplyOperation } from "trac-msb/src/utils/protobuf/operationHelpers.js";
import { MainSettlementBus } from "trac-msb/src/index.js";
import { createConfig as createMsbConfig, ENV as MSB_ENV } from "trac-msb/src/config/env.js";
import { createMessage } from "trac-msb/src/utils/buffer.js";
import { bigIntToDecimalString, decimalStringToBigInt } from "trac-msb/src/utils/amountSerialization.js";
import { createMessage } from "trac-msb/src/utils/buffer.js";
import { safeDecodeApplyOperation } from "trac-msb/src/utils/protobuf/operationHelpers.js";
import { MainSettlementBus } from "trac-msb/src/index.js";
import { createConfig as createMsbConfig, ENV as MSB_ENV } from "trac-msb/src/config/env.js";
import { bufferToBigInt, bigIntToDecimalString } from "trac-msb/src/utils/amountSerialization.js";