Comparing version 12.1.0 to 12.1.1
@@ -67,8 +67,18 @@ "use strict"; | ||
function computeMessageForwardFees(msgPrices, cell) { | ||
let msg = (0, parse_1.parseMessage)(cell.beginParse()); | ||
let msgSlice = cell.beginParse(); | ||
let storageStats = { bits: 0, cells: 0 }; | ||
const hasInit = msgSlice.readBit(); | ||
let init = null; | ||
if (hasInit) { | ||
if (!msgSlice.readBit()) { | ||
init = (0, parse_1.parseStateInit)(msgSlice); | ||
} | ||
else { | ||
init = (0, parse_1.parseStateInit)(msgSlice.readRef()); | ||
} | ||
} | ||
// Init | ||
if (msg.init) { | ||
let c = collectCellStats(msg.body); | ||
c.bits -= msg.body.bits.cursor; | ||
if (init) { | ||
let c = collectCellStats(cell); | ||
c.bits -= cell.bits.cursor; | ||
c.cells -= 1; | ||
@@ -79,4 +89,4 @@ storageStats.bits += c.bits; | ||
// Body | ||
let bc = collectCellStats(msg.body); | ||
bc.bits -= msg.body.bits.cursor; | ||
let bc = collectCellStats(cell); | ||
bc.bits -= cell.bits.cursor; | ||
bc.cells -= 1; | ||
@@ -83,0 +93,0 @@ storageStats.bits += bc.bits; |
@@ -139,2 +139,19 @@ "use strict"; | ||
}); | ||
it('should estimate forward fees', () => { | ||
const props = { | ||
config: { | ||
workchain: { | ||
message: { | ||
lumpPrice: (0, convert_1.toNano)("0.001"), | ||
bitPrice: (0, convert_1.toNano)("0.065536"), | ||
cellPrice: (0, convert_1.toNano)("6.5536"), | ||
firstFrac: (0, convert_1.toNano)("0.000021845") | ||
} | ||
}, | ||
}, | ||
outMsg: Cell_1.Cell.fromBoc(Buffer.from("te6cckEBAQEAMgAAYEIALbtiC8uT7KtHvEy+HRkhOmXeqLGAzipIZQfHIpiBISgAAAAAAAAAAAAAAAAAAJE8Ikw=", 'base64'))[0] | ||
}; | ||
let fwdFees = (0, fees_1.computeMessageForwardFees)(props.config.workchain.message, props.outMsg); | ||
expect((0, convert_1.fromNano)(fwdFees.fees.add(fwdFees.remaining))).toEqual('0.001'); | ||
}); | ||
// it('should compute storage fees', () => { | ||
@@ -141,0 +158,0 @@ // let fees = computeStorageFees({ |
{ | ||
"name": "ton", | ||
"version": "12.1.0", | ||
"version": "12.1.1", | ||
"repository": "https://github.com/tonwhales/ton.git", | ||
@@ -5,0 +5,0 @@ "author": "Steve Korshakov <steve@korshakov.com>", |
455449
11775