All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Added
SmartContract.ec
getter and setter to work with extra currencies - Added an optional
ec
parameter tointernal
helper to set extra currencies
- Updated emulator WASM binary
- Added
blockchain.recordStorage
flag. If set totrue
,BlockchainTransaction
will haveoldStorage
andnewStorage
fields. Note that enabling this flag will disable a certain optimization, which will slow down contract emulation
SandboxContract
now wraps methods starting withis
(having the same semantics asget
) as well assend
andget
- Updated dependencies
- Added the ability to create
Blockchain
using a customIExecutor
instead of the defaultExecutor
- Added more information to
EmulationError
, extended its error message
- Fixed a bug in the emulator that caused send mode 16 to not properly work
- Changed the default and slim configs to use the latest config at the time of release, which reduces gas fees by a factor of 2.5x
- Updated emulator WASM binary
- Changed the default and slim configs to use the latest config at the time of release, which enables TVM v6 opcodes
This release contains a breaking change.
- Added
IExecutor
interface with the prospect of creating custom executor - Added
open
andgetTransactions
to sandbox'sContractProvider
- Added
toSandboxContract
helper function to castOpenedContract<T>
toSandboxContract<T>
when applicable
- Changed the default executor to have
async
methods (it still has sync nature) - Improved get method return object
- Changed the default and slim configs to use the latest config at the time of release, which enables new TVM opcodes
- Updated emulator WASM binary
- Fixed a bug in
Blockchain
that led to storage fetch errors (for example, network errors inRemoteBlockchainStorage
) being cached and breaking that contract address forever
- On transaction emulation error, an
EmulationError
is now thrown that has anerror
string,vmLogs
, andexitCode
(the latter two being optional). The error is no longer being dumped into console
- Step by step execution (
blockchain.sendMessageIter
) - Better docs
now
fromBlockchain
is now honored inSmartContract.receiveMessage
- Exit code 1 is now counted as success in get methods
- Migrated dependencies to @ton organization packages
- Bumped @ton/test-utils version to 0.3.1
- Added the ability to emulate ticktock transactions. There are 3 ways to do that:
blockchain.runTickTock(Address | Address[], TickOrTock, MessageParams?)
,smartContract.runTickTock(TickOrTock, MessageParams?)
, or you can changeContractProvider
in your wrapper classes to beSandboxContractProvider
and invoketickTock(TickOrTock)
on it.TickOrTock
is a union type'tick' | 'tock'
- Added new verbosity levels:
'vm_logs_location'
(same as'vm_logs'
but also display code cell hash and offset),'vm_logs_gas'
(same as'vm_logs_location'
but also display gas remaining),'vm_logs_verbose'
(same as'vm_logs_full'
but display stack values in a more verbose way)
- Changed emulator WASM binary
- Changed emulator WASM binary
- Changed treasury code
- Fixed certain interactions between snapshots and treasuries
- Added
printTransactionFees
helper for easier calculation of fees of different operations - Added
blockchain.snapshot
,blockchain.loadFrom
,smartContract.snapshot
,smartContract.loadFrom
methods to create state snapshots of the respective objects and restore from them at a later point in time. They return and accept new types,BlockchainSnapshot
andSmartContractSnapshot
This release contains a breaking change.
- Added
blockchain.createWallets
method which accepts a numbern
and optionalTreasuryParams
. It createsn
treasuries and returns them as an array
RemoteBlockchainStorage
now requires aRemoteBlockchainStorageClient
instead ofTonClient4
. There is a helper function,wrapTonClient4ForRemote
, to wrap aTonClient4
intoRemoteBlockchainStorageClient
. This is a breaking change- Updated default config
Blockchain.create
now accepts an optionalBlockchainConfig = Cell | 'default' | 'slim'
as the config. If nothing or'default'
is specified, the default config is used, if'slim'
is specified, the slim config is used (it is much smaller than the default config, which improves performance), if aCell
is passed, then it is used as the config
- Removed ton as a peer dependency
- Added
externals: ExternalOut[]
field toBlockchainTransaction
andSendMessageResult
.ExternalOut
is a specialized type for external out messages compatible withMessage
from ton-core
- Get methods now throw a specialized error type
GetMethodError
when exit code is not 0 - Smart contracts now throw a specialized error type
TimeError
when trying to run a transaction at a unix timestamp that is less than the unix timestamp of the last transaction - Get methods now return
gasUsed
andlogs
from theContractProvider
on opened contracts
- Consecutive transaction emulations have been optimized
- Fixed
blockchain.now
override for get methods in opened contracts
- Added
treasury.getBalance
method - Added
blockchain.now
getter and setter to override current unix time as seen during contract execution (both transactions and get methods). Note that this is unix timestamp, not JS timestamp, so you need to useMath.floor(Date.now() / 1000)
instead ofDate.now()
to set current time
RemoteBlockchainStorage
constructor now accepts a second optional parameter,blockSeqno?: number
. If passed, all accounts will be pulled from that block number instead of the latest one
- Changed ton and ton-core dev and peer dependencies to versions 13.4.1 and 0.48.0 respectively
- Fixed typos in
SendMode.PAY_GAS_SEPARATLY
(missing E) from ton-core
This release contains multiple breaking changes.
- Added
blockchain.libs: Cell | undefined
getter and setter for global libraries dictionary (as aCell
)
blockchain.treasury
now accepts an optionalTreasuryParams
argument (see below for definition) instead of the old optionalworkchain?: number
argument. This is a breaking change
export type TreasuryParams = Partial<{
workchain: number
predeploy: boolean
balance: bigint
resetBalanceIfZero: boolean
}>
OpenedContract
was renamed toSandboxContract
. This is a breaking changeLogsVerbosity
now has a new field,print: boolean
(defaults totrue
on theBlockchain
instance), which controls whether toconsole.log
any logs at all (both from transactions and get methods). This is a breaking changesmartContract.get
andblockchain.runGetMethod
now returnGetMethodResult
(see below for definition). The differences from the previous return type are as follows:logs
renamed tovmLogs
. This is a breaking changegasUsed
is now of typebigint
. This is a breaking changeblockchainLogs: string
anddebugLogs: string
were added
export type GetMethodResult = {
stack: TupleItem[]
stackReader: TupleReader
exitCode: number
gasUsed: bigint
blockchainLogs: string
vmLogs: string
debugLogs: string
}
- Properties
storage
andmessageQueue
onBlockchain
are now protected. This is a breaking change - All properties and methods of
Blockchain
that were private are now protected to improve extensibility. Note that any invariants expected byBlockchain
must be upheld blockchain.sendMessage
andsmartContract.receiveMessage
now accept an optionalMessageParams
argument (see below for definition). These parameters are used for every transaction in the chain in case ofblockchain.sendMessage
export type MessageParams = Partial<{
now: number
randomSeed: Buffer
ignoreChksig: boolean
}>
blockchain.runGetMethod
andsmartContract.get
now accept an optionalGetMethodParams
argument (see below for definition)
export type GetMethodParams = Partial<{
now: number
randomSeed: Buffer
gasLimit: bigint
}>
SendMessageResult
now hastransactions: BlockchainTransaction[]
instead oftransactions: Transaction[]
. Definition ofBlockchainTransaction
:
export type BlockchainTransaction = Transaction & {
blockchainLogs: string
vmLogs: string
debugLogs: string
events: Event[]
parent?: BlockchainTransaction
children: BlockchainTransaction[]
}
smartContract.receiveMessage
now returnsSmartContractTransaction
(see below for definition)
export type SmartContractTransaction = Transaction & {
blockchainLogs: string
vmLogs: string
debugLogs: string
}
- Emulator WASM binary has been updated
- Fixed empty message bodies in bounced messages. This fix is contained in the emulator WASM binary
- Treasuries obtained by
blockchain.treasury
calls are now initialized during this call and will no longer produce an extra transaction when first sending a message - Transaction processing loop now prefetches contracts, which should provide a performance boost in some scenarios
Blockchain
andSmartContract
now useLogsVerbosity
(see below for definition) as the verbosity type, which allows for more control over what kinds of logs are printed. Logs from TVM debug primitives are now enabled by default, again. (You can disable them globally by setting verbosity withdebugLogs: false
on theBlockchain
instance)
Definition of LogsVerbosity
:
type LogsVerbosity = {
blockchainLogs: boolean
vmLogs: Verbosity
debugLogs: boolean
}
- Added
blockchain.runGetMethod(address, method, stack)
to run a get method on the specified address - Added
blockchain.setShardAccount(address, account)
to directly set the state of smart contracts - Added
account: ShardAccount
getter and setter toSmartContract
- Exported helper methods
createEmptyShardAccount
,createShardAccount
for use withblockchain.setShardAccount
andsmartContract.account
setter - Added the ability to pass
Cell
s intoblockchain.sendMessage
- Removed unnecessary
async
modifiers fromsmartContract.receiveMessage
andsmartContract.get
- Logs from TVM debug primitives (for example,
DUMP
andSTRDUMP
with corresponding FunC functions~dump()
and~strdump()
) now respect theverbosity
parameter and will only work when it is notnone
- Logs from TVM debug primitives are now printed using a single
console.log
call per one TVM execution to avoid cluttering the terminal during unit tests
- Fixed potential race conditions between execution of different transaction chains on the same
Blockchain
instance by use of anAsyncLock
- Changed
blockchain.pushMessage
,blockchain.processQueue
,blockchain.runQueue
to be private