Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
applyAsset(store) {
const errors = [];
const packet = store.account.get(this.asset.packetId);
const index = newObj.asset.standbyCarrier.indexOf(this.asset.carrierId);
if (index > -1 && this.asset.deliveryStatus === "pending") {
const carrier = store.account.get(this.asset.carrierId);
if (packet.asset.minTrust <= carrier.asset.trust) {
const packetBalanceWithSecurity = new BigNum(packet.balance).add(
new BigNum(packet.security)
);
const carrierBalanceWithoutSecurity = new BigNum(packet.balance).sub(
new BigNum(packet.security)
);
const updatedCarrier = {
...carrier,
balance: carrierBalanceWithoutSecurity.toString()
};
store.account.set(carrier.address, updatedCarrier);
const updatedData = {
asset: {
deliveryStatus: "ongoing",
activeCarrier: this.asset.carrierId,
balance: packetBalanceWithSecurity.toString()
}
};
const newObj = {
...packet,
...updatedData
applyAsset(store) {
const errors = [];
const packet = store.account.get(this.asset.packetId);
const index = newObj.asset.standbyCarrier.indexOf(this.asset.carrierId);
if (index > -1 && this.asset.deliveryStatus === "pending") {
const carrier = store.account.get(this.asset.carrierId);
if (packet.asset.minTrust <= carrier.asset.trust) {
const packetBalanceWithSecurity = new BigNum(packet.balance).add(
new BigNum(packet.security)
);
const carrierBalanceWithoutSecurity = new BigNum(packet.balance).sub(
new BigNum(packet.security)
);
const updatedCarrier = {
...carrier,
balance: carrierBalanceWithoutSecurity.toString()
};
store.account.set(carrier.address, updatedCarrier);
const updatedData = {
asset: {
deliveryStatus: "ongoing",
activeCarrier: this.asset.carrierId,
balance: packetBalanceWithSecurity.toString()
}
};
const newObj = {
...packet,
undoAsset(store) {
const errors = [];
const packet = store.account.get(this.asset.packetId);
if (packet.asset.activeCarrier === this.asset.carrierId && this.asset.deliveryStatus !== "pending") {
const carrier = store.account.get(this.asset.carrierId);
const packetBalanceWithoutSecurity = new BigNum(packet.balance).sub(
new BigNum(packet.security)
);
const carrierBalanceWithSecurity = new BigNum(packet.balance).add(
new BigNum(packet.security)
);
const updatedCarrier = {
...carrier,
balance: carrierBalanceWithSecurity.toString()
};
store.account.set(carrier.address, updatedCarrier);
const updatedData = {
asset: {
deliveryStatus: "pending",
activeCarrier: null,
balance: packetBalanceWithoutSecurity.toString()
}
applyAsset(store) {
const errors = [];
const packet = store.account.get(this.asset.packetId);
const index = newObj.asset.standbyCarrier.indexOf(this.asset.carrierId);
if (index > -1 && this.asset.deliveryStatus === "pending") {
const carrier = store.account.get(this.asset.carrierId);
if (packet.asset.minTrust <= carrier.asset.trust) {
const packetBalanceWithSecurity = new BigNum(packet.balance).add(
new BigNum(packet.security)
);
const carrierBalanceWithoutSecurity = new BigNum(packet.balance).sub(
new BigNum(packet.security)
);
const updatedCarrier = {
...carrier,
balance: carrierBalanceWithoutSecurity.toString()
};
store.account.set(carrier.address, updatedCarrier);
const updatedData = {
asset: {
deliveryStatus: "ongoing",
activeCarrier: this.asset.carrierId,
balance: packetBalanceWithSecurity.toString()
}
undoAsset(store) {
const errors = [];
const packet = store.account.get(this.asset.packetId);
if (packet.asset.activeCarrier === this.asset.carrierId && this.asset.deliveryStatus !== "pending") {
const carrier = store.account.get(this.asset.carrierId);
const packetBalanceWithoutSecurity = new BigNum(packet.balance).sub(
new BigNum(packet.security)
);
const carrierBalanceWithSecurity = new BigNum(packet.balance).add(
new BigNum(packet.security)
);
const updatedCarrier = {
...carrier,
balance: carrierBalanceWithSecurity.toString()
};
store.account.set(carrier.address, updatedCarrier);
const updatedData = {
asset: {
deliveryStatus: "pending",
activeCarrier: null,
balance: packetBalanceWithoutSecurity.toString()
}
};
const newObj = {
...packet,
undoAsset(store) {
const errors = [];
const packet = store.account.get(this.asset.packetId);
if (packet.asset.activeCarrier === this.asset.carrierId && this.asset.deliveryStatus !== "pending") {
const carrier = store.account.get(this.asset.carrierId);
const packetBalanceWithoutSecurity = new BigNum(packet.balance).sub(
new BigNum(packet.security)
);
const carrierBalanceWithSecurity = new BigNum(packet.balance).add(
new BigNum(packet.security)
);
const updatedCarrier = {
...carrier,
balance: carrierBalanceWithSecurity.toString()
};
store.account.set(carrier.address, updatedCarrier);
const updatedData = {
asset: {
deliveryStatus: "pending",
activeCarrier: null,
balance: packetBalanceWithoutSecurity.toString()
}
};
const newObj = {
...packet,
...updatedData
applyAsset(store) {
const errors = [];
const packet = store.account.get(this.asset.packetId);
const index = newObj.asset.standbyCarrier.indexOf(this.asset.carrierId);
if (index > -1 && this.asset.deliveryStatus === "pending") {
const carrier = store.account.get(this.asset.carrierId);
if (packet.asset.minTrust <= carrier.asset.trust) {
const packetBalanceWithSecurity = new BigNum(packet.balance).add(
new BigNum(packet.security)
);
const carrierBalanceWithoutSecurity = new BigNum(packet.balance).sub(
new BigNum(packet.security)
);
const updatedCarrier = {
...carrier,
balance: carrierBalanceWithoutSecurity.toString()
};
store.account.set(carrier.address, updatedCarrier);
const updatedData = {
asset: {
deliveryStatus: "ongoing",
activeCarrier: this.asset.carrierId,
balance: packetBalanceWithSecurity.toString()
}
};
undoAsset(store) {
const errors = [];
const packet = store.account.get(this.asset.packetId);
if (packet.asset.activeCarrier === this.asset.carrierId && this.asset.deliveryStatus !== "pending") {
const carrier = store.account.get(this.asset.carrierId);
const packetBalanceWithoutSecurity = new BigNum(packet.balance).sub(
new BigNum(packet.security)
);
const carrierBalanceWithSecurity = new BigNum(packet.balance).add(
new BigNum(packet.security)
);
const updatedCarrier = {
...carrier,
balance: carrierBalanceWithSecurity.toString()
};
store.account.set(carrier.address, updatedCarrier);
const updatedData = {
asset: {
deliveryStatus: "pending",
activeCarrier: null,
balance: packetBalanceWithoutSecurity.toString()
}
};