@roochnetwork/rooch-sdk
Version:
58 lines (57 loc) • 1.22 kB
JavaScript
import { bcs } from "../bcs/index.js";
import { MoveAction, TransactionData } from "./transactionData.js";
class Transaction {
callFunction(input) {
this.info = input.info;
this.data = new TransactionData(
MoveAction.newCallFunction(input),
input.maxGas ? BigInt(input.maxGas) : void 0
);
}
getInfo() {
return this.info;
}
getMaxGas() {
return this.getData().maxGas;
}
setMaxGas(input) {
this.getData().maxGas = BigInt(input);
}
setSender(input) {
this.getData().sender = input;
}
setAuth(input) {
this.auth = input;
}
setChainId(input) {
this.getData().chainId = input;
}
setSeqNumber(input) {
this.getData().sequenceNumber = input;
}
hashData() {
return this.getData().hash();
}
encodeData() {
return this.data.encode();
}
encode() {
return bcs.RoochTransaction.serialize({
data: this.data.encode().toBytes(),
auth: this.auth.encode()
});
}
getData() {
this.isValid();
return this.data;
}
isValid() {
if (!this.data) {
throw new Error("Transaction data is not initialized. Call action first.");
}
}
}
export {
Transaction
};
//# sourceMappingURL=transaction.js.map