@ton/sandbox 0.23.0 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/blockchain/SmartContract.d.ts +3 -0
- package/dist/blockchain/SmartContract.js +12 -0
- package/dist/index.d.ts +1 -0
- package/dist/utils/ec.d.ts +6 -0
- package/dist/utils/ec.js +20 -0
- package/dist/utils/message.d.ts +3 -1
- package/dist/utils/message.js +14 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.24.0] - 2025-01-17
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Added `SmartContract.ec` getter and setter to work with extra currencies
|
|
13
|
+
- Added an optional `ec` parameter to `internal` helper to set extra currencies
|
|
14
|
+
|
|
8
15
|
## [0.23.0] - 2024-12-18
|
|
9
16
|
|
|
10
17
|
### Updated
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Blockchain } from "./Blockchain";
|
|
3
3
|
import { Address, Cell, Message, ShardAccount, Transaction, TupleItem, TupleReader } from "@ton/core";
|
|
4
|
+
import { ExtraCurrency } from "../utils/ec";
|
|
4
5
|
import { EmulationResult, RunCommonArgs, TickOrTock } from "../executor/Executor";
|
|
5
6
|
export declare function createShardAccount(args: {
|
|
6
7
|
address?: Address;
|
|
@@ -78,6 +79,8 @@ export declare class SmartContract {
|
|
|
78
79
|
constructor(shardAccount: ShardAccount, blockchain: Blockchain);
|
|
79
80
|
snapshot(): SmartContractSnapshot;
|
|
80
81
|
loadFrom(snapshot: SmartContractSnapshot): void;
|
|
82
|
+
get ec(): ExtraCurrency;
|
|
83
|
+
set ec(nv: ExtraCurrency);
|
|
81
84
|
get balance(): bigint;
|
|
82
85
|
set balance(v: bigint);
|
|
83
86
|
get lastTransactionHash(): bigint;
|
|
@@ -14,6 +14,7 @@ var _SmartContract_account, _SmartContract_parsedAccount, _SmartContract_lastTxT
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.SmartContract = exports.EmulationError = exports.TimeError = exports.GetMethodError = exports.createEmptyShardAccount = exports.createShardAccount = void 0;
|
|
16
16
|
const core_1 = require("@ton/core");
|
|
17
|
+
const ec_1 = require("../utils/ec");
|
|
17
18
|
const selector_1 = require("../utils/selector");
|
|
18
19
|
function createShardAccount(args) {
|
|
19
20
|
let wc = args.workchain ?? 0;
|
|
@@ -150,6 +151,17 @@ class SmartContract {
|
|
|
150
151
|
__classPrivateFieldSet(this, _SmartContract_lastTxTime, snapshot.lastTxTime, "f");
|
|
151
152
|
__classPrivateFieldSet(this, _SmartContract_verbosity, snapshot.verbosity === undefined ? undefined : { ...snapshot.verbosity }, "f");
|
|
152
153
|
}
|
|
154
|
+
get ec() {
|
|
155
|
+
return (0, ec_1.extractEc)(this.account.account?.storage.balance.other ?? core_1.Dictionary.empty(core_1.Dictionary.Keys.Uint(32), core_1.Dictionary.Values.BigVarUint(5)));
|
|
156
|
+
}
|
|
157
|
+
set ec(nv) {
|
|
158
|
+
const acc = this.account;
|
|
159
|
+
if (acc.account === undefined) {
|
|
160
|
+
acc.account = createEmptyAccount(this.address);
|
|
161
|
+
}
|
|
162
|
+
acc.account.storage.balance.other = (0, ec_1.packEc)(Object.entries(nv).map(([k, v]) => [Number(k), v]));
|
|
163
|
+
this.account = acc;
|
|
164
|
+
}
|
|
153
165
|
get balance() {
|
|
154
166
|
return this.account.account?.storage.balance.coins ?? 0n;
|
|
155
167
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -10,3 +10,4 @@ export { Treasury, TreasuryContract, } from './treasury/Treasury';
|
|
|
10
10
|
export { prettyLogTransaction, prettyLogTransactions, } from './utils/prettyLogTransaction';
|
|
11
11
|
export { printTransactionFees, } from './utils/printTransactionFees';
|
|
12
12
|
export { internal, } from './utils/message';
|
|
13
|
+
export { ExtraCurrency, } from './utils/ec';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Dictionary } from "@ton/core";
|
|
2
|
+
export type ExtraCurrency = {
|
|
3
|
+
[key: number]: bigint;
|
|
4
|
+
};
|
|
5
|
+
export declare function extractEc(cc: Dictionary<number, bigint>): ExtraCurrency;
|
|
6
|
+
export declare function packEc(ec: Iterable<[number, bigint]>): Dictionary<number, bigint>;
|
package/dist/utils/ec.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.packEc = exports.extractEc = void 0;
|
|
4
|
+
const core_1 = require("@ton/core");
|
|
5
|
+
function extractEc(cc) {
|
|
6
|
+
const r = {};
|
|
7
|
+
for (const [k, v] of cc) {
|
|
8
|
+
r[k] = v;
|
|
9
|
+
}
|
|
10
|
+
return r;
|
|
11
|
+
}
|
|
12
|
+
exports.extractEc = extractEc;
|
|
13
|
+
function packEc(ec) {
|
|
14
|
+
const r = core_1.Dictionary.empty(core_1.Dictionary.Keys.Uint(32), core_1.Dictionary.Values.BigVarUint(5));
|
|
15
|
+
for (const [k, v] of ec) {
|
|
16
|
+
r.set(k, v);
|
|
17
|
+
}
|
|
18
|
+
return r;
|
|
19
|
+
}
|
|
20
|
+
exports.packEc = packEc;
|
package/dist/utils/message.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Address, Cell, Message, StateInit } from "@ton/core";
|
|
1
|
+
import { Address, Cell, Dictionary, Message, StateInit } from "@ton/core";
|
|
2
|
+
import { ExtraCurrency } from "./ec";
|
|
2
3
|
/**
|
|
3
4
|
* Creates {@link Message} from params.
|
|
4
5
|
*/
|
|
@@ -15,4 +16,5 @@ export declare function internal(params: {
|
|
|
15
16
|
forwardFee?: bigint;
|
|
16
17
|
createdAt?: number;
|
|
17
18
|
createdLt?: bigint;
|
|
19
|
+
ec?: Dictionary<number, bigint> | [number, bigint][] | ExtraCurrency;
|
|
18
20
|
}): Message;
|
package/dist/utils/message.js
CHANGED
|
@@ -2,16 +2,29 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.internal = void 0;
|
|
4
4
|
const core_1 = require("@ton/core");
|
|
5
|
+
const ec_1 = require("./ec");
|
|
5
6
|
/**
|
|
6
7
|
* Creates {@link Message} from params.
|
|
7
8
|
*/
|
|
8
9
|
function internal(params) {
|
|
10
|
+
let ecd = undefined;
|
|
11
|
+
if (params.ec !== undefined) {
|
|
12
|
+
if (Array.isArray(params.ec)) {
|
|
13
|
+
ecd = (0, ec_1.packEc)(params.ec);
|
|
14
|
+
}
|
|
15
|
+
else if (params.ec instanceof core_1.Dictionary) {
|
|
16
|
+
ecd = params.ec;
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
ecd = (0, ec_1.packEc)(Object.entries(params.ec).map(([k, v]) => [Number(k), v]));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
9
22
|
return {
|
|
10
23
|
info: {
|
|
11
24
|
type: 'internal',
|
|
12
25
|
dest: params.to,
|
|
13
26
|
src: params.from,
|
|
14
|
-
value: { coins: params.value },
|
|
27
|
+
value: { coins: params.value, other: ecd },
|
|
15
28
|
bounce: params.bounce ?? true,
|
|
16
29
|
ihrDisabled: params.ihrDisabled ?? true,
|
|
17
30
|
bounced: params.bounced ?? false,
|