@tonappchain/sdk 0.9.0-rc1 → 0.9.0-rc2
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/dist/artifacts/mainnet/ton/internal/wrappers/NFTCollection.d.ts +4 -4
- package/dist/artifacts/testnet/ton/internal/wrappers/NFTCollection.d.ts +4 -4
- package/dist/esm/src/index.mjs +23 -8
- package/dist/src/sender/BatchSender.js +2 -1
- package/dist/src/wrappers/HighloadQueryId.d.ts +2 -0
- package/dist/src/wrappers/HighloadQueryId.js +7 -6
- package/dist/src/wrappers/HighloadWalletV3.d.ts +6 -0
- package/dist/src/wrappers/HighloadWalletV3.js +16 -2
- package/package.json +1 -1
|
@@ -49,10 +49,10 @@ export declare class NFTCollection implements Contract {
|
|
|
49
49
|
static createFromAddress(address: Address): NFTCollection;
|
|
50
50
|
static createFromConfig(config: NFTCollectionConfig, code: Cell, workchain?: number): NFTCollection;
|
|
51
51
|
sendDeploy(provider: ContractProvider, via: Sender, value: bigint): Promise<void>;
|
|
52
|
-
static deployNFTItemMessage(queryId: number | bigint, itemIndex: number, itemOwner: Address, nftContent: Cell, maybeNewContent?: Cell, forwardPayload?: Cell): Cell;
|
|
52
|
+
static deployNFTItemMessage(queryId: number | bigint, itemIndex: bigint | number, itemOwner: Address, nftContent: Cell, maybeNewContent?: Cell, forwardPayload?: Cell): Cell;
|
|
53
53
|
sendDeployNFTItem(provider: ContractProvider, via: Sender, value: bigint, params: {
|
|
54
54
|
queryId?: number | bigint;
|
|
55
|
-
itemIndex: number;
|
|
55
|
+
itemIndex: bigint | number;
|
|
56
56
|
itemOwner: Address;
|
|
57
57
|
nftContent: Cell;
|
|
58
58
|
maybeNewContent?: Cell;
|
|
@@ -79,7 +79,7 @@ export declare class NFTCollection implements Contract {
|
|
|
79
79
|
adminAddress: Address;
|
|
80
80
|
newAdminAddress: Address | null;
|
|
81
81
|
}>;
|
|
82
|
-
getNFTAddressByIndex(provider: ContractProvider, index:
|
|
83
|
-
getNFTContent(provider: ContractProvider, index:
|
|
82
|
+
getNFTAddressByIndex(provider: ContractProvider, index: bigint | number): Promise<Address>;
|
|
83
|
+
getNFTContent(provider: ContractProvider, index: bigint | number, individualNFTContent: Cell): Promise<Cell>;
|
|
84
84
|
getOriginalAddress(provider: ContractProvider): Promise<String>;
|
|
85
85
|
}
|
|
@@ -49,10 +49,10 @@ export declare class NFTCollection implements Contract {
|
|
|
49
49
|
static createFromAddress(address: Address): NFTCollection;
|
|
50
50
|
static createFromConfig(config: NFTCollectionConfig, code: Cell, workchain?: number): NFTCollection;
|
|
51
51
|
sendDeploy(provider: ContractProvider, via: Sender, value: bigint): Promise<void>;
|
|
52
|
-
static deployNFTItemMessage(queryId: number | bigint, itemIndex: number, itemOwner: Address, nftContent: Cell, maybeNewContent?: Cell, forwardPayload?: Cell): Cell;
|
|
52
|
+
static deployNFTItemMessage(queryId: number | bigint, itemIndex: bigint | number, itemOwner: Address, nftContent: Cell, maybeNewContent?: Cell, forwardPayload?: Cell): Cell;
|
|
53
53
|
sendDeployNFTItem(provider: ContractProvider, via: Sender, value: bigint, params: {
|
|
54
54
|
queryId?: number | bigint;
|
|
55
|
-
itemIndex: number;
|
|
55
|
+
itemIndex: bigint | number;
|
|
56
56
|
itemOwner: Address;
|
|
57
57
|
nftContent: Cell;
|
|
58
58
|
maybeNewContent?: Cell;
|
|
@@ -79,7 +79,7 @@ export declare class NFTCollection implements Contract {
|
|
|
79
79
|
adminAddress: Address;
|
|
80
80
|
newAdminAddress: Address | null;
|
|
81
81
|
}>;
|
|
82
|
-
getNFTAddressByIndex(provider: ContractProvider, index:
|
|
83
|
-
getNFTContent(provider: ContractProvider, index:
|
|
82
|
+
getNFTAddressByIndex(provider: ContractProvider, index: bigint | number): Promise<Address>;
|
|
83
|
+
getNFTContent(provider: ContractProvider, index: bigint | number, individualNFTContent: Cell): Promise<Cell>;
|
|
84
84
|
getOriginalAddress(provider: ContractProvider): Promise<String>;
|
|
85
85
|
}
|
package/dist/esm/src/index.mjs
CHANGED
|
@@ -6294,8 +6294,9 @@ import {
|
|
|
6294
6294
|
import { sign } from "ton-crypto";
|
|
6295
6295
|
|
|
6296
6296
|
// src/wrappers/HighloadQueryId.ts
|
|
6297
|
-
var
|
|
6298
|
-
var
|
|
6297
|
+
var HIGHLOAD_QUERY_ID_BIT_NUMBER_SIZE = 10n;
|
|
6298
|
+
var HIGHLOAD_QUERY_ID_INVALID_BIT_NUMBER = (1n << HIGHLOAD_QUERY_ID_BIT_NUMBER_SIZE) - 1n;
|
|
6299
|
+
var MAX_BIT_NUMBER = HIGHLOAD_QUERY_ID_INVALID_BIT_NUMBER - 1n;
|
|
6299
6300
|
var MAX_SHIFT = 8191n;
|
|
6300
6301
|
var HighloadQueryId = class _HighloadQueryId {
|
|
6301
6302
|
// [0 .. 1022]
|
|
@@ -6339,11 +6340,11 @@ var HighloadQueryId = class _HighloadQueryId {
|
|
|
6339
6340
|
return this.bitnumber;
|
|
6340
6341
|
}
|
|
6341
6342
|
getQueryId() {
|
|
6342
|
-
return (this.shift <<
|
|
6343
|
+
return (this.shift << HIGHLOAD_QUERY_ID_BIT_NUMBER_SIZE) + this.bitnumber;
|
|
6343
6344
|
}
|
|
6344
6345
|
static fromQueryId(queryId) {
|
|
6345
|
-
const shift = queryId >>
|
|
6346
|
-
const bitnumber = queryId &
|
|
6346
|
+
const shift = queryId >> HIGHLOAD_QUERY_ID_BIT_NUMBER_SIZE;
|
|
6347
|
+
const bitnumber = queryId & HIGHLOAD_QUERY_ID_INVALID_BIT_NUMBER;
|
|
6347
6348
|
return this.fromShiftAndBitNumber(shift, bitnumber);
|
|
6348
6349
|
}
|
|
6349
6350
|
static fromSeqno(i) {
|
|
@@ -6374,6 +6375,7 @@ var HIGHLOAD_V3_CODE = Cell8.fromBoc(
|
|
|
6374
6375
|
)[0];
|
|
6375
6376
|
var TIMESTAMP_SIZE = 64;
|
|
6376
6377
|
var TIMEOUT_SIZE = 22;
|
|
6378
|
+
var QUERY_ID_PERIOD = 8388608n;
|
|
6377
6379
|
function highloadWalletV3ConfigToCell(config) {
|
|
6378
6380
|
return beginCell9().storeBuffer(config.publicKey).storeUint(config.subwalletId ?? DEFAULT_SUBWALLET_ID, 32).storeUint(0, 1 + 1 + TIMESTAMP_SIZE).storeUint(config.timeout ?? DEFAULT_TIMEOUT, TIMEOUT_SIZE).endCell();
|
|
6379
6381
|
}
|
|
@@ -6412,7 +6414,16 @@ var HighloadWalletV3 = class _HighloadWalletV3 {
|
|
|
6412
6414
|
return new _HighloadWalletV3(contractAddress(workchain, init), init);
|
|
6413
6415
|
}
|
|
6414
6416
|
static generateCreatedAt() {
|
|
6415
|
-
return Math.floor(Date.now() / 1e3) - 40;
|
|
6417
|
+
return _HighloadWalletV3.normalizeCreatedAt(Math.floor(Date.now() / 1e3) - 40);
|
|
6418
|
+
}
|
|
6419
|
+
/**
|
|
6420
|
+
* The Highload V3 contract accepts bitnumber values [0..1022]. Query IDs
|
|
6421
|
+
* are derived from createdAt, so skip timestamps whose low 10 bits are the
|
|
6422
|
+
* invalid value 1023.
|
|
6423
|
+
*/
|
|
6424
|
+
static normalizeCreatedAt(createdAt) {
|
|
6425
|
+
const queryId = BigInt(createdAt) % QUERY_ID_PERIOD;
|
|
6426
|
+
return (queryId & HIGHLOAD_QUERY_ID_INVALID_BIT_NUMBER) === HIGHLOAD_QUERY_ID_INVALID_BIT_NUMBER ? createdAt + 1 : createdAt;
|
|
6416
6427
|
}
|
|
6417
6428
|
async sendExternalMessage(provider, secretKey, opts) {
|
|
6418
6429
|
let messageCell;
|
|
@@ -6433,6 +6444,7 @@ var HighloadWalletV3 = class _HighloadWalletV3 {
|
|
|
6433
6444
|
if (createdAt == void 0) {
|
|
6434
6445
|
createdAt = _HighloadWalletV3.generateCreatedAt();
|
|
6435
6446
|
}
|
|
6447
|
+
createdAt = _HighloadWalletV3.normalizeCreatedAt(createdAt);
|
|
6436
6448
|
const queryId = this.getQueryIdFromCreatedAt(createdAt);
|
|
6437
6449
|
return await this.sendExternalMessage(provider, secretKey, {
|
|
6438
6450
|
message: this.packActions(messages, value, queryId),
|
|
@@ -6444,7 +6456,7 @@ var HighloadWalletV3 = class _HighloadWalletV3 {
|
|
|
6444
6456
|
});
|
|
6445
6457
|
}
|
|
6446
6458
|
getQueryIdFromCreatedAt(createdAt) {
|
|
6447
|
-
return HighloadQueryId.fromQueryId(BigInt(createdAt) %
|
|
6459
|
+
return HighloadQueryId.fromQueryId(BigInt(createdAt) % QUERY_ID_PERIOD);
|
|
6448
6460
|
}
|
|
6449
6461
|
getExternalMessage(messages, sendMode, value, queryId) {
|
|
6450
6462
|
return this.packActions(
|
|
@@ -6598,7 +6610,7 @@ var BatchSender = class {
|
|
|
6598
6610
|
let validGroupFound = false;
|
|
6599
6611
|
while (groupSize > 0) {
|
|
6600
6612
|
const group = messages.slice(left, left + groupSize);
|
|
6601
|
-
const createdAt =
|
|
6613
|
+
const createdAt = HighloadWalletV3.generateCreatedAt();
|
|
6602
6614
|
const queryId = this.wallet.getQueryIdFromCreatedAt(createdAt);
|
|
6603
6615
|
const externalMsg = this.wallet.getExternalMessage(group, SendMode2.PAY_GAS_SEPARATELY, 0n, queryId);
|
|
6604
6616
|
const isBocSizeValid = externalMsg.body.toBoc().length <= MAX_EXT_MSG_SIZE;
|
|
@@ -6626,6 +6638,7 @@ var BatchSender = class {
|
|
|
6626
6638
|
if (createdAt <= this.lastCreatedAt) {
|
|
6627
6639
|
createdAt = this.lastCreatedAt + 1;
|
|
6628
6640
|
}
|
|
6641
|
+
createdAt = HighloadWalletV3.normalizeCreatedAt(createdAt);
|
|
6629
6642
|
this.lastCreatedAt = createdAt;
|
|
6630
6643
|
return walletContract.sendTransfer({
|
|
6631
6644
|
secretKey: this.secretKey,
|
|
@@ -7613,6 +7626,8 @@ export {
|
|
|
7613
7626
|
FT,
|
|
7614
7627
|
FetchError,
|
|
7615
7628
|
FormatError,
|
|
7629
|
+
HIGHLOAD_QUERY_ID_BIT_NUMBER_SIZE,
|
|
7630
|
+
HIGHLOAD_QUERY_ID_INVALID_BIT_NUMBER,
|
|
7616
7631
|
HighloadQueryId,
|
|
7617
7632
|
HighloadWalletV3,
|
|
7618
7633
|
KeyError,
|
|
@@ -78,7 +78,7 @@ class BatchSender {
|
|
|
78
78
|
let validGroupFound = false;
|
|
79
79
|
while (groupSize > 0) {
|
|
80
80
|
const group = messages.slice(left, left + groupSize);
|
|
81
|
-
const createdAt =
|
|
81
|
+
const createdAt = HighloadWalletV3_1.HighloadWalletV3.generateCreatedAt();
|
|
82
82
|
const queryId = this.wallet.getQueryIdFromCreatedAt(createdAt);
|
|
83
83
|
const externalMsg = this.wallet.getExternalMessage(group, ton_1.SendMode.PAY_GAS_SEPARATELY, 0n, queryId);
|
|
84
84
|
const isBocSizeValid = externalMsg.body.toBoc().length <= Consts_1.MAX_EXT_MSG_SIZE;
|
|
@@ -106,6 +106,7 @@ class BatchSender {
|
|
|
106
106
|
if (createdAt <= this.lastCreatedAt) {
|
|
107
107
|
createdAt = this.lastCreatedAt + 1; // to prevent error::already_executed on highload wallet
|
|
108
108
|
}
|
|
109
|
+
createdAt = HighloadWalletV3_1.HighloadWalletV3.normalizeCreatedAt(createdAt);
|
|
109
110
|
this.lastCreatedAt = createdAt;
|
|
110
111
|
return walletContract.sendTransfer({
|
|
111
112
|
secretKey: this.secretKey,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HighloadQueryId = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
exports.HighloadQueryId = exports.HIGHLOAD_QUERY_ID_INVALID_BIT_NUMBER = exports.HIGHLOAD_QUERY_ID_BIT_NUMBER_SIZE = void 0;
|
|
4
|
+
exports.HIGHLOAD_QUERY_ID_BIT_NUMBER_SIZE = 10n;
|
|
5
|
+
exports.HIGHLOAD_QUERY_ID_INVALID_BIT_NUMBER = (1n << exports.HIGHLOAD_QUERY_ID_BIT_NUMBER_SIZE) - 1n;
|
|
6
|
+
const MAX_BIT_NUMBER = exports.HIGHLOAD_QUERY_ID_INVALID_BIT_NUMBER - 1n;
|
|
6
7
|
const MAX_SHIFT = 8191n; // 2^13 = 8192
|
|
7
8
|
class HighloadQueryId {
|
|
8
9
|
constructor() {
|
|
@@ -49,11 +50,11 @@ class HighloadQueryId {
|
|
|
49
50
|
return this.bitnumber;
|
|
50
51
|
}
|
|
51
52
|
getQueryId() {
|
|
52
|
-
return (this.shift <<
|
|
53
|
+
return (this.shift << exports.HIGHLOAD_QUERY_ID_BIT_NUMBER_SIZE) + this.bitnumber;
|
|
53
54
|
}
|
|
54
55
|
static fromQueryId(queryId) {
|
|
55
|
-
const shift = queryId >>
|
|
56
|
-
const bitnumber = queryId &
|
|
56
|
+
const shift = queryId >> exports.HIGHLOAD_QUERY_ID_BIT_NUMBER_SIZE;
|
|
57
|
+
const bitnumber = queryId & exports.HIGHLOAD_QUERY_ID_INVALID_BIT_NUMBER;
|
|
57
58
|
return this.fromShiftAndBitNumber(shift, bitnumber);
|
|
58
59
|
}
|
|
59
60
|
static fromSeqno(i) {
|
|
@@ -38,6 +38,12 @@ export declare class HighloadWalletV3 implements WalletInstanse {
|
|
|
38
38
|
}): Promise<string>;
|
|
39
39
|
static create(config: HighloadWalletV3Config, code?: Cell, workchain?: number): HighloadWalletV3;
|
|
40
40
|
static generateCreatedAt(): number;
|
|
41
|
+
/**
|
|
42
|
+
* The Highload V3 contract accepts bitnumber values [0..1022]. Query IDs
|
|
43
|
+
* are derived from createdAt, so skip timestamps whose low 10 bits are the
|
|
44
|
+
* invalid value 1023.
|
|
45
|
+
*/
|
|
46
|
+
static normalizeCreatedAt(createdAt: number): number;
|
|
41
47
|
sendExternalMessage(provider: ContractProvider, secretKey: Buffer, opts: {
|
|
42
48
|
message: MessageRelaxed | Cell;
|
|
43
49
|
mode: number;
|
|
@@ -14,6 +14,7 @@ exports.DEFAULT_TIMEOUT = 60 * 60; // 1 hour
|
|
|
14
14
|
const HIGHLOAD_V3_CODE = ton_1.Cell.fromBoc(Buffer.from('b5ee9c7241021001000228000114ff00f4a413f4bcf2c80b01020120020d02014803040078d020d74bc00101c060b0915be101d0d3030171b0915be0fa4030f828c705b39130e0d31f018210ae42e5a4ba9d8040d721d74cf82a01ed55fb04e030020120050a02027306070011adce76a2686b85ffc00201200809001aabb6ed44d0810122d721d70b3f0018aa3bed44d08307d721d70b1f0201200b0c001bb9a6eed44d0810162d721d70b15800e5b8bf2eda2edfb21ab09028409b0ed44d0810120d721f404f404d33fd315d1058e1bf82325a15210b99f326df82305aa0015a112b992306dde923033e2923033e25230800df40f6fa19ed021d721d70a00955f037fdb31e09130e259800df40f6fa19cd001d721d70a00937fdb31e0915be270801f6f2d48308d718d121f900ed44d0d3ffd31ff404f404d33fd315d1f82321a15220b98e12336df82324aa00a112b9926d32de58f82301de541675f910f2a106d0d31fd4d307d30cd309d33fd315d15168baf2a2515abaf2a6f8232aa15250bcf2a304f823bbf2a35304800df40f6fa199d024d721d70a00f2649130e20e01fe5309800df40f6fa18e13d05004d718d20001f264c858cf16cf8301cf168e1030c824cf40cf8384095005a1a514cf40e2f800c94039800df41704c8cbff13cb1ff40012f40012cb3f12cb15c9ed54f80f21d0d30001f265d3020171b0925f03e0fa4001d70b01c000f2a5fa4031fa0031f401fa0031fa00318060d721d300010f0020f265d2000193d431d19130e272b1fb00b585bf03', 'hex'))[0];
|
|
15
15
|
exports.TIMESTAMP_SIZE = 64;
|
|
16
16
|
exports.TIMEOUT_SIZE = 22;
|
|
17
|
+
const QUERY_ID_PERIOD = 8388608n; // 2^23
|
|
17
18
|
function highloadWalletV3ConfigToCell(config) {
|
|
18
19
|
return (0, ton_1.beginCell)()
|
|
19
20
|
.storeBuffer(config.publicKey)
|
|
@@ -57,7 +58,19 @@ class HighloadWalletV3 {
|
|
|
57
58
|
return new HighloadWalletV3((0, ton_1.contractAddress)(workchain, init), init);
|
|
58
59
|
}
|
|
59
60
|
static generateCreatedAt() {
|
|
60
|
-
|
|
61
|
+
// -40 is used to pass check created_at <= now() in smart contract for sure
|
|
62
|
+
return HighloadWalletV3.normalizeCreatedAt(Math.floor(Date.now() / 1000) - 40);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The Highload V3 contract accepts bitnumber values [0..1022]. Query IDs
|
|
66
|
+
* are derived from createdAt, so skip timestamps whose low 10 bits are the
|
|
67
|
+
* invalid value 1023.
|
|
68
|
+
*/
|
|
69
|
+
static normalizeCreatedAt(createdAt) {
|
|
70
|
+
const queryId = BigInt(createdAt) % QUERY_ID_PERIOD;
|
|
71
|
+
return (queryId & HighloadQueryId_1.HIGHLOAD_QUERY_ID_INVALID_BIT_NUMBER) === HighloadQueryId_1.HIGHLOAD_QUERY_ID_INVALID_BIT_NUMBER
|
|
72
|
+
? createdAt + 1
|
|
73
|
+
: createdAt;
|
|
61
74
|
}
|
|
62
75
|
async sendExternalMessage(provider, secretKey, opts) {
|
|
63
76
|
let messageCell;
|
|
@@ -89,6 +102,7 @@ class HighloadWalletV3 {
|
|
|
89
102
|
if (createdAt == undefined) {
|
|
90
103
|
createdAt = HighloadWalletV3.generateCreatedAt();
|
|
91
104
|
}
|
|
105
|
+
createdAt = HighloadWalletV3.normalizeCreatedAt(createdAt);
|
|
92
106
|
const queryId = this.getQueryIdFromCreatedAt(createdAt);
|
|
93
107
|
return await this.sendExternalMessage(provider, secretKey, {
|
|
94
108
|
message: this.packActions(messages, value, queryId),
|
|
@@ -100,7 +114,7 @@ class HighloadWalletV3 {
|
|
|
100
114
|
});
|
|
101
115
|
}
|
|
102
116
|
getQueryIdFromCreatedAt(createdAt) {
|
|
103
|
-
return HighloadQueryId_1.HighloadQueryId.fromQueryId(BigInt(createdAt) %
|
|
117
|
+
return HighloadQueryId_1.HighloadQueryId.fromQueryId(BigInt(createdAt) % QUERY_ID_PERIOD);
|
|
104
118
|
}
|
|
105
119
|
getExternalMessage(messages, sendMode, value, queryId) {
|
|
106
120
|
return this.packActions(messages.map((msg) => ({
|