@tonappchain/sdk 0.9.0-rc2 → 0.9.0-rc3
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/esm/src/index.mjs +1096 -237
- package/dist/src/accountAbstraction/BaseAccountAPI.d.ts +62 -0
- package/dist/src/accountAbstraction/BaseAccountAPI.js +163 -0
- package/dist/src/accountAbstraction/Ed25519.d.ts +47 -0
- package/dist/src/accountAbstraction/Ed25519.js +100 -0
- package/dist/src/accountAbstraction/HttpRpcClient.d.ts +26 -0
- package/dist/src/accountAbstraction/HttpRpcClient.js +45 -0
- package/dist/src/accountAbstraction/PaymasterAPI.d.ts +21 -0
- package/dist/src/accountAbstraction/PaymasterAPI.js +18 -0
- package/dist/src/accountAbstraction/Permit2.d.ts +37 -0
- package/dist/src/accountAbstraction/Permit2.js +41 -0
- package/dist/src/accountAbstraction/PermitFlow.d.ts +43 -0
- package/dist/src/accountAbstraction/PermitFlow.js +80 -0
- package/dist/src/accountAbstraction/TacAccountAPI.d.ts +53 -0
- package/dist/src/accountAbstraction/TacAccountAPI.js +84 -0
- package/dist/src/accountAbstraction/TacAccountSdk.d.ts +101 -0
- package/dist/src/accountAbstraction/TacAccountSdk.js +163 -0
- package/dist/src/accountAbstraction/TacERC20PaymasterAPI.d.ts +59 -0
- package/dist/src/accountAbstraction/TacERC20PaymasterAPI.js +88 -0
- package/dist/src/accountAbstraction/TransactionDetailsForUserOp.d.ts +10 -0
- package/dist/src/accountAbstraction/TransactionDetailsForUserOp.js +2 -0
- package/dist/src/accountAbstraction/abi.d.ts +3 -0
- package/dist/src/accountAbstraction/abi.js +32 -0
- package/dist/src/accountAbstraction/index.d.ts +24 -0
- package/dist/src/accountAbstraction/index.js +44 -0
- package/dist/src/accountAbstraction/internal/entryPointAbi.d.ts +1 -0
- package/dist/src/accountAbstraction/internal/entryPointAbi.js +16 -0
- package/dist/src/accountAbstraction/internal/userOp.d.ts +54 -0
- package/dist/src/accountAbstraction/internal/userOp.js +72 -0
- package/dist/src/accountAbstraction/networks.d.ts +22 -0
- package/dist/src/accountAbstraction/networks.js +20 -0
- package/dist/src/accountAbstraction/signer.d.ts +12 -0
- package/dist/src/accountAbstraction/signer.js +14 -0
- package/dist/src/adapters/LiteClientOpener.js +12 -1
- package/dist/src/adapters/SandboxOpener.d.ts +1 -1
- package/dist/src/adapters/SandboxOpener.js +20 -1
- package/dist/src/adapters/TonClient4Opener.js +15 -1
- package/dist/src/adapters/TonClientOpener.js +14 -1
- package/dist/src/assets/FT.d.ts +4 -2
- package/dist/src/assets/FT.js +26 -13
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/interfaces/ContractOpener.d.ts +1 -0
- package/dist/src/structs/InternalStruct.d.ts +5 -0
- package/package.json +1 -1
package/dist/esm/src/index.mjs
CHANGED
|
@@ -7,6 +7,914 @@ import {
|
|
|
7
7
|
testnet_exports
|
|
8
8
|
} from "../chunk-6AEFUAMZ.mjs";
|
|
9
9
|
|
|
10
|
+
// src/accountAbstraction/abi.ts
|
|
11
|
+
var TacAccountFactoryABI = [
|
|
12
|
+
"function getOrCreateAccount(bytes32 publicKey) external returns (address)",
|
|
13
|
+
"function getAccountAddress(bytes32 publicKey) public view returns (address)"
|
|
14
|
+
];
|
|
15
|
+
var TacAccountABI = [
|
|
16
|
+
// From TacBaseAccount (execute surface)
|
|
17
|
+
"function execute(address target, uint256 value, bytes calldata data) external",
|
|
18
|
+
"function executeBatch(tuple(address target, uint256 value, bytes data)[] calls) external",
|
|
19
|
+
// From IAccount + TacBaseAccount
|
|
20
|
+
"function getNonce() public view returns (uint256)",
|
|
21
|
+
"function getNonce(uint192 key) public view returns (uint256)",
|
|
22
|
+
// From TacAccount
|
|
23
|
+
"function publicKey() public view returns (bytes32)",
|
|
24
|
+
"function entryPoint() public view returns (address)"
|
|
25
|
+
];
|
|
26
|
+
var TacERC20PaymasterABI = [
|
|
27
|
+
"function token() public view returns (address)",
|
|
28
|
+
"function tacPermit2() public view returns (address)",
|
|
29
|
+
"function priceMarkup() public view returns (uint32)",
|
|
30
|
+
"function refundPostOpCost() public view returns (uint256)",
|
|
31
|
+
"function internalBalance(address account) public view returns (uint256)",
|
|
32
|
+
"function getPrice() public view returns (uint192)"
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
// src/accountAbstraction/BaseAccountAPI.ts
|
|
36
|
+
import { concat as concat2, Contract } from "ethers";
|
|
37
|
+
|
|
38
|
+
// src/accountAbstraction/internal/entryPointAbi.ts
|
|
39
|
+
var IEntryPointABI = [
|
|
40
|
+
// off-chain-matching userOpHash (avoids re-implementing EIP-712 packing in the SDK)
|
|
41
|
+
"function getUserOpHash((address sender,uint256 nonce,bytes initCode,bytes callData,bytes32 accountGasLimits,uint256 preVerificationGas,bytes32 gasFees,bytes paymasterAndData,bytes signature) userOp) view returns (bytes32)",
|
|
42
|
+
// reverts with SenderAddressResult(sender) — used to derive an undeployed account address
|
|
43
|
+
"function getSenderAddress(bytes initCode)",
|
|
44
|
+
"error SenderAddressResult(address sender)",
|
|
45
|
+
"function senderCreator() view returns (address)",
|
|
46
|
+
"function getNonce(address sender, uint192 key) view returns (uint256)",
|
|
47
|
+
"event UserOperationEvent(bytes32 indexed userOpHash, address indexed sender, address indexed paymaster, uint256 nonce, bool success, uint256 actualGasCost, uint256 actualGasUsed)"
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
// src/accountAbstraction/internal/userOp.ts
|
|
51
|
+
import { concat, hexlify, toBeHex, toBigInt, toQuantity, zeroPadValue } from "ethers";
|
|
52
|
+
function toHexBytes(v) {
|
|
53
|
+
return v == null || v === "" ? "0x" : hexlify(v);
|
|
54
|
+
}
|
|
55
|
+
function packUint(high128, low128) {
|
|
56
|
+
return zeroPadValue(toBeHex((toBigInt(high128) << 128n) + toBigInt(low128)), 32);
|
|
57
|
+
}
|
|
58
|
+
function packPaymasterData(paymaster, paymasterVerificationGasLimit, postOpGasLimit, paymasterData) {
|
|
59
|
+
return concat([paymaster, packUint(paymasterVerificationGasLimit, postOpGasLimit), toHexBytes(paymasterData)]);
|
|
60
|
+
}
|
|
61
|
+
function packUserOp(op) {
|
|
62
|
+
let paymasterAndData = "0x";
|
|
63
|
+
if (op.paymaster != null) {
|
|
64
|
+
if (op.paymasterVerificationGasLimit == null || op.paymasterPostOpGasLimit == null) {
|
|
65
|
+
throw new Error("paymaster with no gas limits");
|
|
66
|
+
}
|
|
67
|
+
paymasterAndData = packPaymasterData(
|
|
68
|
+
op.paymaster,
|
|
69
|
+
op.paymasterVerificationGasLimit,
|
|
70
|
+
op.paymasterPostOpGasLimit,
|
|
71
|
+
op.paymasterData
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
const initCode = op.factory == null ? "0x" : concat([op.factory, toHexBytes(op.factoryData)]);
|
|
75
|
+
return {
|
|
76
|
+
sender: op.sender,
|
|
77
|
+
nonce: toBeHex(toBigInt(op.nonce)),
|
|
78
|
+
initCode,
|
|
79
|
+
callData: toHexBytes(op.callData),
|
|
80
|
+
accountGasLimits: packUint(op.verificationGasLimit, op.callGasLimit),
|
|
81
|
+
preVerificationGas: toBeHex(toBigInt(op.preVerificationGas)),
|
|
82
|
+
gasFees: packUint(op.maxPriorityFeePerGas, op.maxFeePerGas),
|
|
83
|
+
paymasterAndData,
|
|
84
|
+
signature: toHexBytes(op.signature)
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function deepHexlify(obj) {
|
|
88
|
+
if (typeof obj === "function") {
|
|
89
|
+
return void 0;
|
|
90
|
+
}
|
|
91
|
+
if (obj == null || typeof obj === "string" || typeof obj === "boolean") {
|
|
92
|
+
return obj;
|
|
93
|
+
}
|
|
94
|
+
if (typeof obj === "bigint" || typeof obj === "number") {
|
|
95
|
+
return toQuantity(obj);
|
|
96
|
+
}
|
|
97
|
+
if (obj instanceof Uint8Array) {
|
|
98
|
+
return hexlify(obj);
|
|
99
|
+
}
|
|
100
|
+
if (Array.isArray(obj)) {
|
|
101
|
+
return obj.map((member) => deepHexlify(member));
|
|
102
|
+
}
|
|
103
|
+
const record = obj;
|
|
104
|
+
return Object.keys(record).reduce((set, key) => ({ ...set, [key]: deepHexlify(record[key]) }), {});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// src/accountAbstraction/BaseAccountAPI.ts
|
|
108
|
+
var BaseAccountAPI = class {
|
|
109
|
+
constructor(params) {
|
|
110
|
+
this.isPhantom = true;
|
|
111
|
+
this.provider = params.provider;
|
|
112
|
+
this.entryPointAddress = params.entryPointAddress;
|
|
113
|
+
this.accountAddress = params.accountAddress;
|
|
114
|
+
this.paymasterAPI = params.paymasterAPI;
|
|
115
|
+
this.entryPointView = new Contract(params.entryPointAddress, IEntryPointABI, params.provider);
|
|
116
|
+
}
|
|
117
|
+
async init() {
|
|
118
|
+
if (await this.provider.getCode(this.entryPointAddress) === "0x") {
|
|
119
|
+
throw new Error(`entryPoint not deployed at ${this.entryPointAddress}`);
|
|
120
|
+
}
|
|
121
|
+
await this.getAccountAddress();
|
|
122
|
+
return this;
|
|
123
|
+
}
|
|
124
|
+
/** Whether the account contract is not yet deployed. */
|
|
125
|
+
async checkAccountPhantom() {
|
|
126
|
+
if (!this.isPhantom) {
|
|
127
|
+
return this.isPhantom;
|
|
128
|
+
}
|
|
129
|
+
const senderAddressCode = await this.provider.getCode(await this.getAccountAddress());
|
|
130
|
+
if (senderAddressCode.length > 2) {
|
|
131
|
+
this.isPhantom = false;
|
|
132
|
+
}
|
|
133
|
+
return this.isPhantom;
|
|
134
|
+
}
|
|
135
|
+
/** Compute the account address before deployment (via EntryPoint.getSenderAddress). */
|
|
136
|
+
async getCounterFactualAddress() {
|
|
137
|
+
const { factory, factoryData } = await this.getFactoryData() ?? {};
|
|
138
|
+
if (factory == null) {
|
|
139
|
+
throw new Error("no counterfactual address without a factory");
|
|
140
|
+
}
|
|
141
|
+
const initCode = concat2([factory, toHexBytes(factoryData)]);
|
|
142
|
+
try {
|
|
143
|
+
await this.entryPointView.getSenderAddress.staticCall(initCode);
|
|
144
|
+
} catch (e) {
|
|
145
|
+
const err = e;
|
|
146
|
+
if (err.revert?.name === "SenderAddressResult") {
|
|
147
|
+
return err.revert.args?.[0];
|
|
148
|
+
}
|
|
149
|
+
if (err.data != null) {
|
|
150
|
+
return this.entryPointView.interface.decodeErrorResult("SenderAddressResult", err.data)[0];
|
|
151
|
+
}
|
|
152
|
+
throw e;
|
|
153
|
+
}
|
|
154
|
+
throw new Error("getSenderAddress did not revert as expected");
|
|
155
|
+
}
|
|
156
|
+
/** initCode for the UserOp (factory + factoryData), or null if already deployed. */
|
|
157
|
+
async getRequiredFactoryData() {
|
|
158
|
+
if (await this.checkAccountPhantom()) {
|
|
159
|
+
return await this.getFactoryData();
|
|
160
|
+
}
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
/** Maximum gas used for verification (creation cost is added on top when phantom). */
|
|
164
|
+
async getVerificationGasLimit() {
|
|
165
|
+
return 1e5;
|
|
166
|
+
}
|
|
167
|
+
/** Return userOpHash for signing — computed on-chain to match EntryPoint exactly. */
|
|
168
|
+
async getUserOpHash(op) {
|
|
169
|
+
return await this.entryPointView.getUserOpHash.staticCall(packUserOp(op));
|
|
170
|
+
}
|
|
171
|
+
/** Account address (valid even before deployment). */
|
|
172
|
+
async getAccountAddress() {
|
|
173
|
+
if (this.senderAddress == null) {
|
|
174
|
+
this.senderAddress = this.accountAddress ?? await this.getCounterFactualAddress();
|
|
175
|
+
}
|
|
176
|
+
return this.senderAddress;
|
|
177
|
+
}
|
|
178
|
+
async encodeUserOpCallDataAndGasLimit(detailsForUserOp) {
|
|
179
|
+
const value = detailsForUserOp.value != null && detailsForUserOp.value !== "" ? BigInt(detailsForUserOp.value) : 0n;
|
|
180
|
+
const callData = await this.encodeExecute(detailsForUserOp.target, value, detailsForUserOp.data);
|
|
181
|
+
const callGasLimit = detailsForUserOp.gasLimit != null && detailsForUserOp.gasLimit !== "" ? BigInt(detailsForUserOp.gasLimit) : await this.provider.estimateGas({
|
|
182
|
+
from: this.entryPointAddress,
|
|
183
|
+
to: await this.getAccountAddress(),
|
|
184
|
+
data: callData
|
|
185
|
+
});
|
|
186
|
+
return { callData, callGasLimit };
|
|
187
|
+
}
|
|
188
|
+
async estimateCreationGas(factoryParams) {
|
|
189
|
+
if (factoryParams == null) {
|
|
190
|
+
return 0n;
|
|
191
|
+
}
|
|
192
|
+
const senderCreator = await this.entryPointView.senderCreator();
|
|
193
|
+
return await this.provider.estimateGas({
|
|
194
|
+
from: senderCreator,
|
|
195
|
+
to: factoryParams.factory,
|
|
196
|
+
data: toHexBytes(factoryParams.factoryData)
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Create an unsigned UserOperation with all fields filled (signature empty).
|
|
201
|
+
*/
|
|
202
|
+
async createUnsignedUserOp(info) {
|
|
203
|
+
const { callData, callGasLimit } = await this.encodeUserOpCallDataAndGasLimit(info);
|
|
204
|
+
const factoryParams = await this.getRequiredFactoryData();
|
|
205
|
+
const initGas = await this.estimateCreationGas(factoryParams);
|
|
206
|
+
const verificationGasLimit = BigInt(await this.getVerificationGasLimit()) + initGas;
|
|
207
|
+
let maxFeePerGas = info.maxFeePerGas;
|
|
208
|
+
let maxPriorityFeePerGas = info.maxPriorityFeePerGas;
|
|
209
|
+
if (maxFeePerGas == null || maxPriorityFeePerGas == null) {
|
|
210
|
+
const feeData = await this.provider.getFeeData();
|
|
211
|
+
maxFeePerGas ?? (maxFeePerGas = feeData.maxFeePerGas ?? void 0);
|
|
212
|
+
maxPriorityFeePerGas ?? (maxPriorityFeePerGas = feeData.maxPriorityFeePerGas ?? void 0);
|
|
213
|
+
}
|
|
214
|
+
if (maxFeePerGas == null || maxPriorityFeePerGas == null) {
|
|
215
|
+
throw new Error("could not resolve gas fees from provider; pass maxFeePerGas/maxPriorityFeePerGas explicitly");
|
|
216
|
+
}
|
|
217
|
+
let partialUserOp = {
|
|
218
|
+
sender: await this.getAccountAddress(),
|
|
219
|
+
nonce: info.nonce ?? await this.getNonce(),
|
|
220
|
+
factory: factoryParams?.factory,
|
|
221
|
+
factoryData: factoryParams?.factoryData,
|
|
222
|
+
callData,
|
|
223
|
+
callGasLimit,
|
|
224
|
+
verificationGasLimit,
|
|
225
|
+
maxFeePerGas,
|
|
226
|
+
maxPriorityFeePerGas,
|
|
227
|
+
preVerificationGas: 6e4,
|
|
228
|
+
signature: "",
|
|
229
|
+
authorizationList: []
|
|
230
|
+
};
|
|
231
|
+
if (this.paymasterAPI != null) {
|
|
232
|
+
const pmFields = await this.paymasterAPI.getTemporaryPaymasterData();
|
|
233
|
+
if (pmFields != null) {
|
|
234
|
+
partialUserOp = {
|
|
235
|
+
...partialUserOp,
|
|
236
|
+
paymaster: pmFields.paymaster,
|
|
237
|
+
paymasterPostOpGasLimit: pmFields.paymasterPostOpGasLimit,
|
|
238
|
+
paymasterVerificationGasLimit: pmFields.paymasterVerificationGasLimit,
|
|
239
|
+
paymasterData: pmFields.paymasterData
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return partialUserOp;
|
|
244
|
+
}
|
|
245
|
+
/** Sign a filled userOp. */
|
|
246
|
+
async signUserOp(userOp) {
|
|
247
|
+
const userOpHash = await this.getUserOpHash(userOp);
|
|
248
|
+
const signature = await this.signUserOpHash(userOpHash);
|
|
249
|
+
return { ...userOp, signature };
|
|
250
|
+
}
|
|
251
|
+
/** Create and sign a UserOperation. */
|
|
252
|
+
async createSignedUserOp(info) {
|
|
253
|
+
return await this.signUserOp(await this.createUnsignedUserOp(info));
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
// src/accountAbstraction/Ed25519.ts
|
|
258
|
+
import { AbiCoder, concat as concat3, hexlify as hexlify2, zeroPadValue as zeroPadValue2 } from "ethers";
|
|
259
|
+
var abiCoder = AbiCoder.defaultAbiCoder();
|
|
260
|
+
function packRawEd25519Signature(sig) {
|
|
261
|
+
return abiCoder.encode(["bytes32[2]"], [[zeroPadValue2(hexlify2(sig.r), 32), zeroPadValue2(hexlify2(sig.s), 32)]]);
|
|
262
|
+
}
|
|
263
|
+
function packPermitBoundUserOpSignature(sig, permitHash) {
|
|
264
|
+
return concat3([zeroPadValue2(hexlify2(sig.r), 32), zeroPadValue2(hexlify2(sig.s), 32), zeroPadValue2(hexlify2(permitHash), 32)]);
|
|
265
|
+
}
|
|
266
|
+
function packPermit2InnerSignature(sig, userOpHash) {
|
|
267
|
+
return concat3([zeroPadValue2(hexlify2(sig.r), 32), zeroPadValue2(hexlify2(sig.s), 32), zeroPadValue2(hexlify2(userOpHash), 32)]);
|
|
268
|
+
}
|
|
269
|
+
function buildPermitBinding(userOpHash, permitHash) {
|
|
270
|
+
return concat3([zeroPadValue2(hexlify2(userOpHash), 32), zeroPadValue2(hexlify2(permitHash), 32)]);
|
|
271
|
+
}
|
|
272
|
+
var ZERO_HASH = "0x" + "00".repeat(32);
|
|
273
|
+
function packTonConnectUserOpSignature(parts, permitHash = ZERO_HASH) {
|
|
274
|
+
return abiCoder.encode(
|
|
275
|
+
["bytes32", "bytes32", "uint64", "string", "int32", "bytes32", "bytes32"],
|
|
276
|
+
[
|
|
277
|
+
zeroPadValue2(hexlify2(parts.r), 32),
|
|
278
|
+
zeroPadValue2(hexlify2(parts.s), 32),
|
|
279
|
+
parts.timestamp,
|
|
280
|
+
parts.domain,
|
|
281
|
+
parts.workchain,
|
|
282
|
+
zeroPadValue2(hexlify2(parts.addrHash), 32),
|
|
283
|
+
zeroPadValue2(hexlify2(permitHash), 32)
|
|
284
|
+
]
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
function packTonConnectPermit2InnerSignature(parts, userOpHash) {
|
|
288
|
+
return abiCoder.encode(
|
|
289
|
+
["bytes32", "bytes32", "uint64", "string", "int32", "bytes32", "bytes32"],
|
|
290
|
+
[
|
|
291
|
+
zeroPadValue2(hexlify2(parts.r), 32),
|
|
292
|
+
zeroPadValue2(hexlify2(parts.s), 32),
|
|
293
|
+
parts.timestamp,
|
|
294
|
+
parts.domain,
|
|
295
|
+
parts.workchain,
|
|
296
|
+
zeroPadValue2(hexlify2(parts.addrHash), 32),
|
|
297
|
+
zeroPadValue2(hexlify2(userOpHash), 32)
|
|
298
|
+
]
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
function ed25519SignerFromSecretKey(secretKey, ed25519Sign) {
|
|
302
|
+
return async (message) => {
|
|
303
|
+
const msgBytes = hexToBytes(message);
|
|
304
|
+
const sig = ed25519Sign(msgBytes, secretKey);
|
|
305
|
+
if (sig.length !== 64) {
|
|
306
|
+
throw new Error(`expected 64-byte Ed25519 signature, got ${sig.length}`);
|
|
307
|
+
}
|
|
308
|
+
return {
|
|
309
|
+
r: "0x" + bytesToHex(sig.slice(0, 32)),
|
|
310
|
+
s: "0x" + bytesToHex(sig.slice(32, 64))
|
|
311
|
+
};
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
function hexToBytes(hex) {
|
|
315
|
+
const clean = hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
316
|
+
const out = new Uint8Array(clean.length / 2);
|
|
317
|
+
for (let i = 0; i < out.length; i++) out[i] = parseInt(clean.slice(i * 2, i * 2 + 2), 16);
|
|
318
|
+
return out;
|
|
319
|
+
}
|
|
320
|
+
function bytesToHex(bytes) {
|
|
321
|
+
let s = "";
|
|
322
|
+
for (let i = 0; i < bytes.length; i++) s += bytes[i].toString(16).padStart(2, "0");
|
|
323
|
+
return s;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// src/accountAbstraction/HttpRpcClient.ts
|
|
327
|
+
import { JsonRpcProvider, resolveProperties } from "ethers";
|
|
328
|
+
var HttpRpcClient = class {
|
|
329
|
+
constructor(bundlerUrl, entryPointAddress, chainId) {
|
|
330
|
+
this.bundlerUrl = bundlerUrl;
|
|
331
|
+
this.entryPointAddress = entryPointAddress;
|
|
332
|
+
this.chainId = chainId;
|
|
333
|
+
this.userOpJsonRpcProvider = new JsonRpcProvider(this.bundlerUrl);
|
|
334
|
+
this.initializing = this.validateChainId();
|
|
335
|
+
}
|
|
336
|
+
async validateChainId() {
|
|
337
|
+
const chain = await this.userOpJsonRpcProvider.send("eth_chainId", []);
|
|
338
|
+
const bundlerChain = parseInt(chain);
|
|
339
|
+
if (bundlerChain !== this.chainId) {
|
|
340
|
+
throw new Error(`bundler ${this.bundlerUrl} is on chainId ${bundlerChain}, but the client expects ${this.chainId}`);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Send a UserOperation to the bundler.
|
|
345
|
+
* @returns the userOpHash (id of this operation).
|
|
346
|
+
*/
|
|
347
|
+
async sendUserOpToBundler(userOp) {
|
|
348
|
+
await this.initializing;
|
|
349
|
+
const hexifiedUserOp = deepHexlify(await resolveProperties(userOp));
|
|
350
|
+
return await this.userOpJsonRpcProvider.send("eth_sendUserOperation", [hexifiedUserOp, this.entryPointAddress]);
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Ask the bundler to estimate gas for a UserOperation.
|
|
354
|
+
*/
|
|
355
|
+
async estimateUserOpGas(userOp) {
|
|
356
|
+
await this.initializing;
|
|
357
|
+
const hexifiedUserOp = deepHexlify(userOp);
|
|
358
|
+
return await this.userOpJsonRpcProvider.send("eth_estimateUserOperationGas", [hexifiedUserOp, this.entryPointAddress]);
|
|
359
|
+
}
|
|
360
|
+
/** Fetch the bundler's receipt for a UserOperation, or null if not yet mined. */
|
|
361
|
+
async getUserOperationReceipt(userOpHash) {
|
|
362
|
+
await this.initializing;
|
|
363
|
+
return await this.userOpJsonRpcProvider.send("eth_getUserOperationReceipt", [userOpHash]);
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
// src/sdk/Consts.ts
|
|
368
|
+
import { toNano } from "@ton/ton";
|
|
369
|
+
var JETTON_TRANSFER_FORWARD_TON_AMOUNT = toNano(0.2);
|
|
370
|
+
var NFT_TRANSFER_FORWARD_TON_AMOUNT = toNano(0.3);
|
|
371
|
+
var LEGACY_FORWARD_FEE_ESTIMATE_NUMERATOR = 3n;
|
|
372
|
+
var LEGACY_FORWARD_FEE_ESTIMATE_DENOMINATOR = 2n;
|
|
373
|
+
var LEGACY_STRICTLY_GREATER_THAN_FEE_EPSILON = 1n;
|
|
374
|
+
var LEGACY_JETTON_WALLET_MIN_TONS_FOR_STORAGE = 10000000n;
|
|
375
|
+
var LEGACY_JETTON_WALLET_GAS_CONSUMPTION = 15000000n;
|
|
376
|
+
var LEGACY_JETTON_WALLET_GAS_CONSUMPTION_COUNT = 2n;
|
|
377
|
+
var LEGACY_JETTON_TRANSFER_BASE_OUTBOUND_MESSAGE_COUNT = 1n;
|
|
378
|
+
var LEGACY_JETTON_TRANSFER_WITH_FORWARD_OUTBOUND_MESSAGE_COUNT = 2n;
|
|
379
|
+
var LEGACY_JETTON_WALLET_TRANSFER_GAS_AND_STORAGE = LEGACY_JETTON_WALLET_GAS_CONSUMPTION_COUNT * LEGACY_JETTON_WALLET_GAS_CONSUMPTION + LEGACY_JETTON_WALLET_MIN_TONS_FOR_STORAGE;
|
|
380
|
+
var LEGACY_NFT_ITEM_MIN_TONS_FOR_STORAGE = 50000000n;
|
|
381
|
+
var LEGACY_NFT_TRANSFER_BASE_OUTBOUND_MESSAGE_COUNT = 1n;
|
|
382
|
+
var LEGACY_NFT_TRANSFER_WITH_FORWARD_OUTBOUND_MESSAGE_COUNT = 2n;
|
|
383
|
+
var USDT_JETTON_WALLET_CODE_HASH = "89468f02c78e570802e39979c8516fc38df07ea76a48357e0536f2ba7b3ee37b";
|
|
384
|
+
var DYNAMIC_JETTON_WALLET_CODE_HASHES = [USDT_JETTON_WALLET_CODE_HASH];
|
|
385
|
+
var FIXED_POINT_SHIFT = 2 ** 16;
|
|
386
|
+
var MAX_ITERATION_COUNT = 120;
|
|
387
|
+
var DEFAULT_DELAY = 0;
|
|
388
|
+
var SOLIDITY_SIGNATURE_REGEX = /^[a-zA-Z_][a-zA-Z0-9_]*(\((bytes,bytes)\))?$/;
|
|
389
|
+
var SOLIDITY_METHOD_NAME_REGEX = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
390
|
+
var MAX_EXT_MSG_SIZE = 65535;
|
|
391
|
+
var MAX_HIGHLOAD_GROUP_MSG_NUM = 254;
|
|
392
|
+
var MAX_MSG_DEPTH = 512;
|
|
393
|
+
var TON_SYMBOL = "TON";
|
|
394
|
+
var TAC_SYMBOL = "TAC";
|
|
395
|
+
var TON_MAINNET_GLOBAL_ID = -239;
|
|
396
|
+
var TON_TESTNET_GLOBAL_ID = -3;
|
|
397
|
+
var FIFTEEN_MINUTES = 15 * 60 * 1e3;
|
|
398
|
+
var ONE_YEAR_SECONDS = 365 * 24 * 3600;
|
|
399
|
+
var TON_DECIMALS = 9;
|
|
400
|
+
var TAC_DECIMALS = 18;
|
|
401
|
+
var FIVE_MINUTES = 5 * 60 * 1e3;
|
|
402
|
+
var MINUTE = 60 * 1e3;
|
|
403
|
+
var TON_BURN_ADDRESS = "EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c";
|
|
404
|
+
var DEFAULT_HTTP_CLIENT_TIMEOUT_MS = 3e4;
|
|
405
|
+
var DEFAULT_RETRY_MAX_COUNT = 5;
|
|
406
|
+
var DEFAULT_RETRY_DELAY_MS = 1e3;
|
|
407
|
+
var DEFAULT_RETRY_MAX_DELAY_MS = 3e4;
|
|
408
|
+
var DEFAULT_RETRY_BACKOFF_MULTIPLIER = 3;
|
|
409
|
+
var DEFAULT_WAIT_TIMEOUT_MS = 3e5;
|
|
410
|
+
var DEFAULT_WAIT_MAX_ATTEMPTS = 30;
|
|
411
|
+
var DEFAULT_WAIT_DELAY_MS = 1e4;
|
|
412
|
+
var DEFAULT_FIND_TX_LIMIT = 100;
|
|
413
|
+
var DEFAULT_MAX_SCANNED_TRANSACTIONS = 100;
|
|
414
|
+
var DEFAULT_FIND_TX_MAX_DEPTH = 10;
|
|
415
|
+
var DEFAULT_RETRY_ON_NOT_FOUND = true;
|
|
416
|
+
var DEFAULT_RETRY_ON_NOT_FOUND_RETRIES = 10;
|
|
417
|
+
var DEFAULT_RETRY_ON_NOT_FOUND_DELAY_MS = 5e3;
|
|
418
|
+
var IGNORE_MSG_VALUE_1_NANO = 1n;
|
|
419
|
+
var CROSS_CHAIN_MESSAGE_VERSION_V1 = 1n;
|
|
420
|
+
var NFT_BRIDGE_AMOUNT = 1n;
|
|
421
|
+
var DEFAULT_EIP1559_PRIORITY_FEE = 0n;
|
|
422
|
+
var IGNORE_OPCODE = [
|
|
423
|
+
3576854235
|
|
424
|
+
// Excess
|
|
425
|
+
];
|
|
426
|
+
var HTTP_NOT_FOUND_STATUS_CODE = 404;
|
|
427
|
+
|
|
428
|
+
// src/structs/Struct.ts
|
|
429
|
+
var SimplifiedStatuses = /* @__PURE__ */ ((SimplifiedStatuses2) => {
|
|
430
|
+
SimplifiedStatuses2["PENDING"] = "PENDING";
|
|
431
|
+
SimplifiedStatuses2["FAILED"] = "FAILED";
|
|
432
|
+
SimplifiedStatuses2["SUCCESSFUL"] = "SUCCESSFUL";
|
|
433
|
+
SimplifiedStatuses2["OPERATION_ID_NOT_FOUND"] = "OPERATION_ID_NOT_FOUND";
|
|
434
|
+
return SimplifiedStatuses2;
|
|
435
|
+
})(SimplifiedStatuses || {});
|
|
436
|
+
var Network = /* @__PURE__ */ ((Network2) => {
|
|
437
|
+
Network2["TESTNET"] = "testnet";
|
|
438
|
+
Network2["MAINNET"] = "mainnet";
|
|
439
|
+
Network2["DEV"] = "dev";
|
|
440
|
+
return Network2;
|
|
441
|
+
})(Network || {});
|
|
442
|
+
var BlockchainType = /* @__PURE__ */ ((BlockchainType2) => {
|
|
443
|
+
BlockchainType2["TAC"] = "TAC";
|
|
444
|
+
BlockchainType2["TON"] = "TON";
|
|
445
|
+
return BlockchainType2;
|
|
446
|
+
})(BlockchainType || {});
|
|
447
|
+
var CurrencyType = /* @__PURE__ */ ((CurrencyType2) => {
|
|
448
|
+
CurrencyType2["TAC"] = "TAC";
|
|
449
|
+
CurrencyType2["TON"] = "TON";
|
|
450
|
+
return CurrencyType2;
|
|
451
|
+
})(CurrencyType || {});
|
|
452
|
+
var OperationType = /* @__PURE__ */ ((OperationType2) => {
|
|
453
|
+
OperationType2["PENDING"] = "PENDING";
|
|
454
|
+
OperationType2["TON_TAC_TON"] = "TON-TAC-TON";
|
|
455
|
+
OperationType2["ROLLBACK"] = "ROLLBACK";
|
|
456
|
+
OperationType2["TON_TAC"] = "TON-TAC";
|
|
457
|
+
OperationType2["TAC_TON"] = "TAC-TON";
|
|
458
|
+
OperationType2["UNKNOWN"] = "UNKNOWN";
|
|
459
|
+
return OperationType2;
|
|
460
|
+
})(OperationType || {});
|
|
461
|
+
var OperationExecutionStatus = /* @__PURE__ */ ((OperationExecutionStatus2) => {
|
|
462
|
+
OperationExecutionStatus2["SUCCESS"] = "success";
|
|
463
|
+
OperationExecutionStatus2["FAILED"] = "failed";
|
|
464
|
+
return OperationExecutionStatus2;
|
|
465
|
+
})(OperationExecutionStatus || {});
|
|
466
|
+
var AssetType = /* @__PURE__ */ ((AssetType2) => {
|
|
467
|
+
AssetType2["NFT"] = "NFT";
|
|
468
|
+
AssetType2["FT"] = "FT";
|
|
469
|
+
return AssetType2;
|
|
470
|
+
})(AssetType || {});
|
|
471
|
+
var NFTAddressType = /* @__PURE__ */ ((NFTAddressType2) => {
|
|
472
|
+
NFTAddressType2["ITEM"] = "ITEM";
|
|
473
|
+
NFTAddressType2["COLLECTION"] = "COLLECTION";
|
|
474
|
+
return NFTAddressType2;
|
|
475
|
+
})(NFTAddressType || {});
|
|
476
|
+
var StageName = /* @__PURE__ */ ((StageName2) => {
|
|
477
|
+
StageName2["COLLECTED_IN_TAC"] = "collectedInTAC";
|
|
478
|
+
StageName2["INCLUDED_IN_TAC_CONSENSUS"] = "includedInTACConsensus";
|
|
479
|
+
StageName2["EXECUTED_IN_TAC"] = "executedInTAC";
|
|
480
|
+
StageName2["COLLECTED_IN_TON"] = "collectedInTON";
|
|
481
|
+
StageName2["INCLUDED_IN_TON_CONSENSUS"] = "includedInTONConsensus";
|
|
482
|
+
StageName2["EXECUTED_IN_TON"] = "executedInTON";
|
|
483
|
+
return StageName2;
|
|
484
|
+
})(StageName || {});
|
|
485
|
+
var TokenSymbol = /* @__PURE__ */ ((TokenSymbol2) => {
|
|
486
|
+
TokenSymbol2["TAC_SYMBOL"] = "TAC";
|
|
487
|
+
TokenSymbol2["TON_SYMBOL"] = "TON";
|
|
488
|
+
return TokenSymbol2;
|
|
489
|
+
})(TokenSymbol || {});
|
|
490
|
+
var defaultWaitOptions = {
|
|
491
|
+
timeout: DEFAULT_WAIT_TIMEOUT_MS,
|
|
492
|
+
maxAttempts: DEFAULT_WAIT_MAX_ATTEMPTS,
|
|
493
|
+
delay: DEFAULT_WAIT_DELAY_MS
|
|
494
|
+
};
|
|
495
|
+
var Origin = /* @__PURE__ */ ((Origin2) => {
|
|
496
|
+
Origin2["TON"] = "TON";
|
|
497
|
+
Origin2["TAC"] = "TAC";
|
|
498
|
+
return Origin2;
|
|
499
|
+
})(Origin || {});
|
|
500
|
+
var AssetFeeMode = /* @__PURE__ */ ((AssetFeeMode2) => {
|
|
501
|
+
AssetFeeMode2["TAC_ORIGINAL"] = "TAC_ORIGINAL";
|
|
502
|
+
AssetFeeMode2["LEGACY"] = "LEGACY";
|
|
503
|
+
AssetFeeMode2["DYNAMIC"] = "DYNAMIC";
|
|
504
|
+
return AssetFeeMode2;
|
|
505
|
+
})(AssetFeeMode || {});
|
|
506
|
+
var TransactionTreeDirection = /* @__PURE__ */ ((TransactionTreeDirection2) => {
|
|
507
|
+
TransactionTreeDirection2["FORWARD"] = "forward";
|
|
508
|
+
TransactionTreeDirection2["BACKWARD"] = "backward";
|
|
509
|
+
TransactionTreeDirection2["BOTH"] = "both";
|
|
510
|
+
return TransactionTreeDirection2;
|
|
511
|
+
})(TransactionTreeDirection || {});
|
|
512
|
+
|
|
513
|
+
// src/accountAbstraction/networks.ts
|
|
514
|
+
var AA_NETWORKS = {
|
|
515
|
+
["testnet" /* TESTNET */]: {
|
|
516
|
+
chainId: 2391,
|
|
517
|
+
entryPoint: "0x239DBD98defbad1c369034a2897bD5b8b57b468A",
|
|
518
|
+
accountFactory: "0x7879c3237811A86092E89AD94837163Ae71d6669",
|
|
519
|
+
// paymaster for token USD₮ (0xbA7E…9220, 6-dec); the fee token is read on-chain
|
|
520
|
+
paymaster: "0xD41B5AC8803bd9371c0bdB44CB95B8b1879F8865",
|
|
521
|
+
permit2: "0x36d6565DcdE4674115bBd1d86E511bebB1C425b9"
|
|
522
|
+
// bundlerUrl: undefined — provide it via TacAccountSdk.create({ bundlerUrl })
|
|
523
|
+
}
|
|
524
|
+
// MAINNET: account abstraction not deployed yet
|
|
525
|
+
};
|
|
526
|
+
|
|
527
|
+
// src/accountAbstraction/PaymasterAPI.ts
|
|
528
|
+
var PaymasterAPI = class {
|
|
529
|
+
/** Temporary values to put into the paymaster fields (used for gas estimation). */
|
|
530
|
+
async getTemporaryPaymasterData() {
|
|
531
|
+
return await this.getPaymasterData();
|
|
532
|
+
}
|
|
533
|
+
/** Final paymaster parameters (after gas estimation). */
|
|
534
|
+
async getPaymasterData() {
|
|
535
|
+
return null;
|
|
536
|
+
}
|
|
537
|
+
};
|
|
538
|
+
|
|
539
|
+
// src/accountAbstraction/Permit2.ts
|
|
540
|
+
import { AbiCoder as AbiCoder2, concat as concat4, keccak256 } from "ethers";
|
|
541
|
+
var abiCoder2 = AbiCoder2.defaultAbiCoder();
|
|
542
|
+
var PERMIT_TUPLE_TYPE = "tuple(tuple(address,uint256)[],uint256,uint256,uint256,address)";
|
|
543
|
+
function buildPermitMessage(input) {
|
|
544
|
+
const permit = [
|
|
545
|
+
input.permitted.map((p) => [p.token, p.amount]),
|
|
546
|
+
input.nonce,
|
|
547
|
+
input.deadline,
|
|
548
|
+
input.chainId,
|
|
549
|
+
input.verifyingContract
|
|
550
|
+
];
|
|
551
|
+
const messageHex = abiCoder2.encode([PERMIT_TUPLE_TYPE], [permit]);
|
|
552
|
+
const permitHash = keccak256(messageHex);
|
|
553
|
+
return { permit, messageHex, permitHash };
|
|
554
|
+
}
|
|
555
|
+
function packPermitData(permit, signatureBlob) {
|
|
556
|
+
return abiCoder2.encode([PERMIT_TUPLE_TYPE, "bytes"], [permit, signatureBlob]);
|
|
557
|
+
}
|
|
558
|
+
function packPermitPaymasterData(permit, signatureBlob) {
|
|
559
|
+
return concat4(["0x01", packPermitData(permit, signatureBlob)]);
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
// src/accountAbstraction/PermitFlow.ts
|
|
563
|
+
import { concat as concat6, Contract as Contract2 } from "ethers";
|
|
564
|
+
|
|
565
|
+
// src/accountAbstraction/TacERC20PaymasterAPI.ts
|
|
566
|
+
import { concat as concat5, toBeHex as toBeHex2, zeroPadValue as zeroPadValue3 } from "ethers";
|
|
567
|
+
var TacPaymasterMode = /* @__PURE__ */ ((TacPaymasterMode2) => {
|
|
568
|
+
TacPaymasterMode2[TacPaymasterMode2["TRANSFER_FROM_REQUESTOR"] = 0] = "TRANSFER_FROM_REQUESTOR";
|
|
569
|
+
TacPaymasterMode2[TacPaymasterMode2["TRANSFER_VIA_PERMIT"] = 1] = "TRANSFER_VIA_PERMIT";
|
|
570
|
+
TacPaymasterMode2[TacPaymasterMode2["INTERNAL_BALANCE"] = 2] = "INTERNAL_BALANCE";
|
|
571
|
+
return TacPaymasterMode2;
|
|
572
|
+
})(TacPaymasterMode || {});
|
|
573
|
+
var DEFAULT_PM_VERIFICATION_GAS_LIMIT = 1e5;
|
|
574
|
+
var DEFAULT_PM_POST_OP_GAS_LIMIT = 1e5;
|
|
575
|
+
var TacERC20PaymasterAPI = class extends PaymasterAPI {
|
|
576
|
+
constructor(params) {
|
|
577
|
+
super();
|
|
578
|
+
this.paymaster = params.paymaster;
|
|
579
|
+
this.mode = params.mode;
|
|
580
|
+
this.paymasterVerificationGasLimit = params.paymasterVerificationGasLimit ?? DEFAULT_PM_VERIFICATION_GAS_LIMIT;
|
|
581
|
+
this.paymasterPostOpGasLimit = params.paymasterPostOpGasLimit ?? DEFAULT_PM_POST_OP_GAS_LIMIT;
|
|
582
|
+
}
|
|
583
|
+
async getTemporaryPaymasterData() {
|
|
584
|
+
return await this.getPaymasterData();
|
|
585
|
+
}
|
|
586
|
+
async getPaymasterData() {
|
|
587
|
+
return {
|
|
588
|
+
paymaster: this.paymaster,
|
|
589
|
+
paymasterVerificationGasLimit: this.paymasterVerificationGasLimit,
|
|
590
|
+
paymasterPostOpGasLimit: this.paymasterPostOpGasLimit,
|
|
591
|
+
paymasterData: this._buildPaymasterData()
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
_buildPaymasterData() {
|
|
595
|
+
switch (this.mode) {
|
|
596
|
+
case 0 /* TRANSFER_FROM_REQUESTOR */:
|
|
597
|
+
case 2 /* INTERNAL_BALANCE */:
|
|
598
|
+
return packModeByte(this.mode);
|
|
599
|
+
case 1 /* TRANSFER_VIA_PERMIT */:
|
|
600
|
+
throw new Error(
|
|
601
|
+
"TacPaymasterMode.TRANSFER_VIA_PERMIT requires the double-signing flow. Use buildSignedUserOpWithPermit(...) instead of composing this PaymasterAPI into a TacAccountAPI."
|
|
602
|
+
);
|
|
603
|
+
default:
|
|
604
|
+
throw new Error(`unknown TacPaymasterMode: ${this.mode}`);
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
function packModeByte(mode) {
|
|
609
|
+
return zeroPadValue3(toBeHex2(mode), 1);
|
|
610
|
+
}
|
|
611
|
+
function packPaymasterAndData(params) {
|
|
612
|
+
return concat5([
|
|
613
|
+
params.paymaster,
|
|
614
|
+
zeroPadValue3(toBeHex2(params.paymasterVerificationGasLimit), 16),
|
|
615
|
+
zeroPadValue3(toBeHex2(params.paymasterPostOpGasLimit), 16),
|
|
616
|
+
params.paymasterData
|
|
617
|
+
]);
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
// src/accountAbstraction/PermitFlow.ts
|
|
621
|
+
var DEFAULT_PM_GAS = 1e5;
|
|
622
|
+
var PLACEHOLDER_INNER_SIG = "0x" + "00".repeat(96);
|
|
623
|
+
async function buildSignedUserOpWithPermit(input) {
|
|
624
|
+
const { accountAPI, paymaster, permitInput, ed25519Signer, txDetails } = input;
|
|
625
|
+
const pmVerifGas = input.paymasterVerificationGasLimit ?? DEFAULT_PM_GAS;
|
|
626
|
+
const pmPostOpGas = input.paymasterPostOpGasLimit ?? DEFAULT_PM_GAS;
|
|
627
|
+
const entryPoint = new Contract2(accountAPI.entryPointAddress, IEntryPointABI, accountAPI.provider);
|
|
628
|
+
const { permit, permitHash } = buildPermitMessage(permitInput);
|
|
629
|
+
const userOp = await accountAPI.createUnsignedUserOp(txDetails);
|
|
630
|
+
userOp.paymaster = paymaster;
|
|
631
|
+
userOp.paymasterVerificationGasLimit = pmVerifGas;
|
|
632
|
+
userOp.paymasterPostOpGasLimit = pmPostOpGas;
|
|
633
|
+
userOp.paymasterData = concat6([
|
|
634
|
+
packModeByte(1 /* TRANSFER_VIA_PERMIT */),
|
|
635
|
+
packPermitData(permit, PLACEHOLDER_INNER_SIG)
|
|
636
|
+
]);
|
|
637
|
+
const userOpHashR1 = await entryPoint.getUserOpHash.staticCall(packUserOp(userOp));
|
|
638
|
+
const sigR1 = await ed25519Signer(buildPermitBinding(userOpHashR1, permitHash));
|
|
639
|
+
const innerSig = packPermit2InnerSignature(sigR1, userOpHashR1);
|
|
640
|
+
userOp.paymasterData = concat6([packModeByte(1 /* TRANSFER_VIA_PERMIT */), packPermitData(permit, innerSig)]);
|
|
641
|
+
const userOpHashR2 = await entryPoint.getUserOpHash.staticCall(packUserOp(userOp));
|
|
642
|
+
const sigR2 = await ed25519Signer(buildPermitBinding(userOpHashR2, permitHash));
|
|
643
|
+
userOp.signature = packPermitBoundUserOpSignature(sigR2, permitHash);
|
|
644
|
+
return userOp;
|
|
645
|
+
}
|
|
646
|
+
async function buildSignedUserOpWithPermitTonConnect(input) {
|
|
647
|
+
const { accountAPI, paymaster, permitInput, tonConnectSigner, txDetails } = input;
|
|
648
|
+
const pmVerifGas = input.paymasterVerificationGasLimit ?? DEFAULT_PM_GAS;
|
|
649
|
+
const pmPostOpGas = input.paymasterPostOpGasLimit ?? DEFAULT_PM_GAS;
|
|
650
|
+
const entryPoint = new Contract2(accountAPI.entryPointAddress, IEntryPointABI, accountAPI.provider);
|
|
651
|
+
const { permit, permitHash } = buildPermitMessage(permitInput);
|
|
652
|
+
const userOp = await accountAPI.createUnsignedUserOp(txDetails);
|
|
653
|
+
userOp.paymaster = paymaster;
|
|
654
|
+
userOp.paymasterVerificationGasLimit = pmVerifGas;
|
|
655
|
+
userOp.paymasterPostOpGasLimit = pmPostOpGas;
|
|
656
|
+
userOp.paymasterData = concat6([
|
|
657
|
+
packModeByte(1 /* TRANSFER_VIA_PERMIT */),
|
|
658
|
+
packPermitData(permit, PLACEHOLDER_INNER_SIG)
|
|
659
|
+
]);
|
|
660
|
+
const userOpHashR1 = await entryPoint.getUserOpHash.staticCall(packUserOp(userOp));
|
|
661
|
+
const partsR1 = await tonConnectSigner(buildPermitBinding(userOpHashR1, permitHash));
|
|
662
|
+
const innerSig = packTonConnectPermit2InnerSignature(partsR1, userOpHashR1);
|
|
663
|
+
userOp.paymasterData = concat6([packModeByte(1 /* TRANSFER_VIA_PERMIT */), packPermitData(permit, innerSig)]);
|
|
664
|
+
const userOpHashR2 = await entryPoint.getUserOpHash.staticCall(packUserOp(userOp));
|
|
665
|
+
const partsR2 = await tonConnectSigner(buildPermitBinding(userOpHashR2, permitHash));
|
|
666
|
+
userOp.signature = packTonConnectUserOpSignature(partsR2, permitHash);
|
|
667
|
+
return userOp;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
// src/accountAbstraction/signer.ts
|
|
671
|
+
import { mnemonicToWalletKey, sign } from "ton-crypto";
|
|
672
|
+
async function aaSignerFromMnemonic(mnemonic) {
|
|
673
|
+
const keypair = await mnemonicToWalletKey(mnemonic.trim().split(/\s+/));
|
|
674
|
+
const signer = ed25519SignerFromSecretKey(
|
|
675
|
+
keypair.secretKey,
|
|
676
|
+
(message, secretKey) => sign(Buffer.from(message), Buffer.from(secretKey))
|
|
677
|
+
);
|
|
678
|
+
return { publicKey: "0x" + keypair.publicKey.toString("hex"), signer };
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
// src/accountAbstraction/TacAccountAPI.ts
|
|
682
|
+
import { Contract as Contract3 } from "ethers";
|
|
683
|
+
var ZERO_HASH2 = "0x" + "00".repeat(32);
|
|
684
|
+
var TacAccountAPI = class extends BaseAccountAPI {
|
|
685
|
+
constructor(params) {
|
|
686
|
+
super(params);
|
|
687
|
+
if (params.signer == null === (params.tonConnectSigner == null)) {
|
|
688
|
+
throw new Error("TacAccountAPI requires exactly one of `signer` or `tonConnectSigner`");
|
|
689
|
+
}
|
|
690
|
+
this.publicKey = params.publicKey;
|
|
691
|
+
this.signer = params.signer;
|
|
692
|
+
this.tonConnectSigner = params.tonConnectSigner;
|
|
693
|
+
this.factoryAddress = params.factoryAddress;
|
|
694
|
+
}
|
|
695
|
+
async _getAccountContract() {
|
|
696
|
+
if (this.accountContract == null) {
|
|
697
|
+
const addr = await this.getAccountAddress();
|
|
698
|
+
this.accountContract = new Contract3(addr, TacAccountABI, this.provider);
|
|
699
|
+
}
|
|
700
|
+
return this.accountContract;
|
|
701
|
+
}
|
|
702
|
+
_getFactory() {
|
|
703
|
+
if (this.factoryContract == null) {
|
|
704
|
+
this.factoryContract = new Contract3(this.factoryAddress, TacAccountFactoryABI, this.provider);
|
|
705
|
+
}
|
|
706
|
+
return this.factoryContract;
|
|
707
|
+
}
|
|
708
|
+
/** Derive the deterministic account address directly from the factory's view. */
|
|
709
|
+
async getCounterFactualAddress() {
|
|
710
|
+
return await this._getFactory().getAccountAddress.staticCall(this.publicKey);
|
|
711
|
+
}
|
|
712
|
+
/** initCode for an undeployed account: factory + `getOrCreateAccount(publicKey)` calldata. */
|
|
713
|
+
async getFactoryData() {
|
|
714
|
+
const factory = this._getFactory();
|
|
715
|
+
return {
|
|
716
|
+
factory: this.factoryAddress,
|
|
717
|
+
factoryData: factory.interface.encodeFunctionData("getOrCreateAccount", [this.publicKey])
|
|
718
|
+
};
|
|
719
|
+
}
|
|
720
|
+
/** Sequential nonce from the deployed account, or 0 if still phantom. */
|
|
721
|
+
async getNonce() {
|
|
722
|
+
if (await this.checkAccountPhantom()) {
|
|
723
|
+
return 0n;
|
|
724
|
+
}
|
|
725
|
+
const accountContract = await this._getAccountContract();
|
|
726
|
+
return await accountContract.getFunction("getNonce()").staticCall();
|
|
727
|
+
}
|
|
728
|
+
/** Encode a single call as `TacBaseAccount.execute(target, value, data)` calldata. */
|
|
729
|
+
async encodeExecute(target, value, data) {
|
|
730
|
+
const accountContract = await this._getAccountContract();
|
|
731
|
+
return accountContract.interface.encodeFunctionData("execute", [target, value, data]);
|
|
732
|
+
}
|
|
733
|
+
/**
|
|
734
|
+
* Sign userOpHash with the configured signer (64-byte raw, or TonConnect with
|
|
735
|
+
* `permitHash = 0`). For paymaster Mode 1 use {@link buildSignedUserOpWithPermit}.
|
|
736
|
+
*/
|
|
737
|
+
async signUserOpHash(userOpHash) {
|
|
738
|
+
if (this.signer != null) {
|
|
739
|
+
const sig = await this.signer(userOpHash);
|
|
740
|
+
return packRawEd25519Signature(sig);
|
|
741
|
+
}
|
|
742
|
+
if (this.tonConnectSigner != null) {
|
|
743
|
+
const binding = buildPermitBinding(userOpHash, ZERO_HASH2);
|
|
744
|
+
const parts = await this.tonConnectSigner(binding);
|
|
745
|
+
return packTonConnectUserOpSignature(parts, ZERO_HASH2);
|
|
746
|
+
}
|
|
747
|
+
throw new Error("TacAccountAPI: no signer configured");
|
|
748
|
+
}
|
|
749
|
+
};
|
|
750
|
+
|
|
751
|
+
// src/accountAbstraction/TacAccountSdk.ts
|
|
752
|
+
import { Contract as Contract4, getDefaultProvider, MaxUint256, parseUnits } from "ethers";
|
|
753
|
+
|
|
754
|
+
// src/sdk/Artifacts.ts
|
|
755
|
+
function getArtifacts(network) {
|
|
756
|
+
switch (network) {
|
|
757
|
+
case "mainnet" /* MAINNET */:
|
|
758
|
+
return mainnet_exports;
|
|
759
|
+
case "testnet" /* TESTNET */:
|
|
760
|
+
return testnet_exports;
|
|
761
|
+
case "dev" /* DEV */:
|
|
762
|
+
return dev_exports;
|
|
763
|
+
default:
|
|
764
|
+
throw new Error(`Unsupported network: ${network}`);
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
// src/accountAbstraction/TacAccountSdk.ts
|
|
769
|
+
var TacAccountSdk = class _TacAccountSdk {
|
|
770
|
+
constructor(network, provider, addresses, chainId, bundlerUrl, publicKey, signer) {
|
|
771
|
+
this.network = network;
|
|
772
|
+
this.provider = provider;
|
|
773
|
+
this.addresses = addresses;
|
|
774
|
+
this.chainId = chainId;
|
|
775
|
+
this.bundlerUrl = bundlerUrl;
|
|
776
|
+
this._permitCounter = 0;
|
|
777
|
+
this._publicKey = publicKey;
|
|
778
|
+
this._signer = signer;
|
|
779
|
+
this.account = new TacAccountAPI({
|
|
780
|
+
provider,
|
|
781
|
+
entryPointAddress: addresses.entryPoint,
|
|
782
|
+
factoryAddress: addresses.accountFactory,
|
|
783
|
+
publicKey,
|
|
784
|
+
signer
|
|
785
|
+
});
|
|
786
|
+
}
|
|
787
|
+
static async create(params) {
|
|
788
|
+
const cfg = AA_NETWORKS[params.network];
|
|
789
|
+
if (cfg == null) {
|
|
790
|
+
throw new Error(`account abstraction is not available on network "${params.network}" yet`);
|
|
791
|
+
}
|
|
792
|
+
let provider = params.provider;
|
|
793
|
+
if (provider == null) {
|
|
794
|
+
const rpc = getArtifacts(params.network).TAC_RPC_ENDPOINT;
|
|
795
|
+
if (rpc == null) {
|
|
796
|
+
throw new Error(`no default TAC RPC for network "${params.network}"; pass a custom provider`);
|
|
797
|
+
}
|
|
798
|
+
provider = getDefaultProvider(rpc);
|
|
799
|
+
}
|
|
800
|
+
const addresses = {
|
|
801
|
+
entryPoint: params.addresses?.entryPoint ?? cfg.entryPoint,
|
|
802
|
+
accountFactory: params.addresses?.accountFactory ?? cfg.accountFactory,
|
|
803
|
+
paymaster: params.addresses?.paymaster ?? cfg.paymaster,
|
|
804
|
+
permit2: params.addresses?.permit2 ?? cfg.permit2
|
|
805
|
+
};
|
|
806
|
+
const { publicKey, signer } = await aaSignerFromMnemonic(params.mnemonic);
|
|
807
|
+
return new _TacAccountSdk(
|
|
808
|
+
params.network,
|
|
809
|
+
provider,
|
|
810
|
+
addresses,
|
|
811
|
+
cfg.chainId,
|
|
812
|
+
params.bundlerUrl ?? cfg.bundlerUrl,
|
|
813
|
+
publicKey,
|
|
814
|
+
signer
|
|
815
|
+
);
|
|
816
|
+
}
|
|
817
|
+
/** The deterministic smart-account address (derived from the TON public key). */
|
|
818
|
+
async getAccountAddress() {
|
|
819
|
+
this._address ?? (this._address = await this.account.getAccountAddress());
|
|
820
|
+
return this._address;
|
|
821
|
+
}
|
|
822
|
+
/** Send a call paying gas natively (account must hold TAC). */
|
|
823
|
+
async sendUserOp(tx) {
|
|
824
|
+
const op = await this.account.createSignedUserOp(this._txDetails(tx));
|
|
825
|
+
return await this._submit(op);
|
|
826
|
+
}
|
|
827
|
+
/** Send a call paying gas in an ERC-20 via the paymaster (Mode 1 — Permit2). */
|
|
828
|
+
async sendUserOpWithPermit(tx) {
|
|
829
|
+
const token = await this._tokenInfoResolved();
|
|
830
|
+
const op = await buildSignedUserOpWithPermit({
|
|
831
|
+
accountAPI: this.account,
|
|
832
|
+
paymaster: this.addresses.paymaster,
|
|
833
|
+
paymasterVerificationGasLimit: tx.paymasterVerificationGasLimit ?? 5e5,
|
|
834
|
+
paymasterPostOpGasLimit: tx.paymasterPostOpGasLimit ?? 15e4,
|
|
835
|
+
permitInput: {
|
|
836
|
+
permitted: [{ token: tx.feeToken ?? token.address, amount: tx.maxFee ?? parseUnits("1000", token.decimals) }],
|
|
837
|
+
nonce: this._newPermitNonce(),
|
|
838
|
+
deadline: tx.deadline ?? MaxUint256,
|
|
839
|
+
chainId: this.chainId,
|
|
840
|
+
verifyingContract: this.addresses.permit2
|
|
841
|
+
},
|
|
842
|
+
ed25519Signer: this._signer,
|
|
843
|
+
txDetails: this._txDetails(tx)
|
|
844
|
+
});
|
|
845
|
+
return await this._submit(op);
|
|
846
|
+
}
|
|
847
|
+
/** Send a call paying gas from the account's pre-credited internal balance (Mode 2). */
|
|
848
|
+
async sendUserOpViaInternalBalance(tx) {
|
|
849
|
+
return await this._sendViaMode(tx, 2 /* INTERNAL_BALANCE */);
|
|
850
|
+
}
|
|
851
|
+
/** Send a call where the paymaster pulls the fee token via a pre-set allowance (Mode 0). */
|
|
852
|
+
async sendUserOpViaAllowance(tx) {
|
|
853
|
+
return await this._sendViaMode(tx, 0 /* TRANSFER_FROM_REQUESTOR */);
|
|
854
|
+
}
|
|
855
|
+
/** Poll the bundler for a UserOperation receipt. */
|
|
856
|
+
async waitForReceipt(userOpHash, opts) {
|
|
857
|
+
const client = this._bundlerClient();
|
|
858
|
+
const end = Date.now() + (opts?.timeoutMs ?? 12e4);
|
|
859
|
+
while (Date.now() < end) {
|
|
860
|
+
const r = await client.getUserOperationReceipt(userOpHash);
|
|
861
|
+
if (r != null) {
|
|
862
|
+
return r;
|
|
863
|
+
}
|
|
864
|
+
await new Promise((res) => setTimeout(res, opts?.intervalMs ?? 3e3));
|
|
865
|
+
}
|
|
866
|
+
throw new Error(`userOp ${userOpHash} not mined within timeout`);
|
|
867
|
+
}
|
|
868
|
+
/** The bundler client (throws if no bundler URL was configured). */
|
|
869
|
+
bundler() {
|
|
870
|
+
return this._bundlerClient();
|
|
871
|
+
}
|
|
872
|
+
// ── internals ──────────────────────────────────────────────────────────────
|
|
873
|
+
_bundlerClient() {
|
|
874
|
+
if (this.bundlerUrl == null || this.bundlerUrl === "") {
|
|
875
|
+
throw new Error("no bundler URL configured \u2014 pass `bundlerUrl` to TacAccountSdk.create({ ... })");
|
|
876
|
+
}
|
|
877
|
+
this._bundler ?? (this._bundler = new HttpRpcClient(this.bundlerUrl, this.addresses.entryPoint, this.chainId));
|
|
878
|
+
return this._bundler;
|
|
879
|
+
}
|
|
880
|
+
_txDetails(tx) {
|
|
881
|
+
return { target: tx.target, value: tx.value ?? 0, data: tx.data, gasLimit: tx.gasLimit ?? 1e6 };
|
|
882
|
+
}
|
|
883
|
+
async _sendViaMode(tx, mode) {
|
|
884
|
+
const paymasterAPI = new TacERC20PaymasterAPI({ paymaster: this.addresses.paymaster, mode });
|
|
885
|
+
const account = new TacAccountAPI({
|
|
886
|
+
provider: this.provider,
|
|
887
|
+
entryPointAddress: this.addresses.entryPoint,
|
|
888
|
+
factoryAddress: this.addresses.accountFactory,
|
|
889
|
+
publicKey: this._publicKey,
|
|
890
|
+
signer: this._signer,
|
|
891
|
+
accountAddress: await this.getAccountAddress(),
|
|
892
|
+
paymasterAPI
|
|
893
|
+
});
|
|
894
|
+
const op = await account.createSignedUserOp(this._txDetails(tx));
|
|
895
|
+
return await this._submit(op);
|
|
896
|
+
}
|
|
897
|
+
async _submit(op) {
|
|
898
|
+
const userOpHash = await this._bundlerClient().sendUserOpToBundler(op);
|
|
899
|
+
const receipt = await this.waitForReceipt(userOpHash);
|
|
900
|
+
return { userOpHash, receipt };
|
|
901
|
+
}
|
|
902
|
+
async _tokenInfoResolved() {
|
|
903
|
+
if (this._tokenInfo == null) {
|
|
904
|
+
const pm = new Contract4(this.addresses.paymaster, ["function token() view returns (address)"], this.provider);
|
|
905
|
+
const address3 = await pm.token();
|
|
906
|
+
const erc20 = new Contract4(address3, ["function decimals() view returns (uint8)"], this.provider);
|
|
907
|
+
const decimals = Number(await erc20.decimals());
|
|
908
|
+
this._tokenInfo = { address: address3, decimals };
|
|
909
|
+
}
|
|
910
|
+
return this._tokenInfo;
|
|
911
|
+
}
|
|
912
|
+
/** Unique permit nonce (Permit2 replay protection): timestamp-ms high bits + a counter. */
|
|
913
|
+
_newPermitNonce() {
|
|
914
|
+
return BigInt(Date.now()) << 16n | BigInt(this._permitCounter++ & 65535);
|
|
915
|
+
}
|
|
916
|
+
};
|
|
917
|
+
|
|
10
918
|
// src/adapters/BaseContractOpener.ts
|
|
11
919
|
import {
|
|
12
920
|
Address as Address6,
|
|
@@ -305,157 +1213,11 @@ var tonIndexerRequiredForTonTransactionBocError = new SettingError(
|
|
|
305
1213
|
);
|
|
306
1214
|
var invalidAmountError = (reason) => new FormatError(`Invalid amount: ${reason}`, 144);
|
|
307
1215
|
|
|
308
|
-
// src/sdk/Consts.ts
|
|
309
|
-
import { toNano } from "@ton/ton";
|
|
310
|
-
var JETTON_TRANSFER_FORWARD_TON_AMOUNT = toNano(0.2);
|
|
311
|
-
var NFT_TRANSFER_FORWARD_TON_AMOUNT = toNano(0.3);
|
|
312
|
-
var LEGACY_FORWARD_FEE_ESTIMATE_NUMERATOR = 3n;
|
|
313
|
-
var LEGACY_FORWARD_FEE_ESTIMATE_DENOMINATOR = 2n;
|
|
314
|
-
var LEGACY_STRICTLY_GREATER_THAN_FEE_EPSILON = 1n;
|
|
315
|
-
var LEGACY_JETTON_WALLET_MIN_TONS_FOR_STORAGE = 10000000n;
|
|
316
|
-
var LEGACY_JETTON_WALLET_GAS_CONSUMPTION = 15000000n;
|
|
317
|
-
var LEGACY_JETTON_WALLET_GAS_CONSUMPTION_COUNT = 2n;
|
|
318
|
-
var LEGACY_JETTON_TRANSFER_BASE_OUTBOUND_MESSAGE_COUNT = 1n;
|
|
319
|
-
var LEGACY_JETTON_TRANSFER_WITH_FORWARD_OUTBOUND_MESSAGE_COUNT = 2n;
|
|
320
|
-
var LEGACY_JETTON_WALLET_TRANSFER_GAS_AND_STORAGE = LEGACY_JETTON_WALLET_GAS_CONSUMPTION_COUNT * LEGACY_JETTON_WALLET_GAS_CONSUMPTION + LEGACY_JETTON_WALLET_MIN_TONS_FOR_STORAGE;
|
|
321
|
-
var LEGACY_NFT_ITEM_MIN_TONS_FOR_STORAGE = 50000000n;
|
|
322
|
-
var LEGACY_NFT_TRANSFER_BASE_OUTBOUND_MESSAGE_COUNT = 1n;
|
|
323
|
-
var LEGACY_NFT_TRANSFER_WITH_FORWARD_OUTBOUND_MESSAGE_COUNT = 2n;
|
|
324
|
-
var USDT_JETTON_WALLET_CODE_HASH = "89468f02c78e570802e39979c8516fc38df07ea76a48357e0536f2ba7b3ee37b";
|
|
325
|
-
var DYNAMIC_JETTON_WALLET_CODE_HASHES = [USDT_JETTON_WALLET_CODE_HASH];
|
|
326
|
-
var FIXED_POINT_SHIFT = 2 ** 16;
|
|
327
|
-
var MAX_ITERATION_COUNT = 120;
|
|
328
|
-
var DEFAULT_DELAY = 0;
|
|
329
|
-
var SOLIDITY_SIGNATURE_REGEX = /^[a-zA-Z_][a-zA-Z0-9_]*(\((bytes,bytes)\))?$/;
|
|
330
|
-
var SOLIDITY_METHOD_NAME_REGEX = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
331
|
-
var MAX_EXT_MSG_SIZE = 65535;
|
|
332
|
-
var MAX_HIGHLOAD_GROUP_MSG_NUM = 254;
|
|
333
|
-
var MAX_MSG_DEPTH = 512;
|
|
334
|
-
var TON_SYMBOL = "TON";
|
|
335
|
-
var TAC_SYMBOL = "TAC";
|
|
336
|
-
var TON_MAINNET_GLOBAL_ID = -239;
|
|
337
|
-
var TON_TESTNET_GLOBAL_ID = -3;
|
|
338
|
-
var FIFTEEN_MINUTES = 15 * 60 * 1e3;
|
|
339
|
-
var ONE_YEAR_SECONDS = 365 * 24 * 3600;
|
|
340
|
-
var TON_DECIMALS = 9;
|
|
341
|
-
var TAC_DECIMALS = 18;
|
|
342
|
-
var FIVE_MINUTES = 5 * 60 * 1e3;
|
|
343
|
-
var MINUTE = 60 * 1e3;
|
|
344
|
-
var TON_BURN_ADDRESS = "EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c";
|
|
345
|
-
var DEFAULT_HTTP_CLIENT_TIMEOUT_MS = 3e4;
|
|
346
|
-
var DEFAULT_RETRY_MAX_COUNT = 5;
|
|
347
|
-
var DEFAULT_RETRY_DELAY_MS = 1e3;
|
|
348
|
-
var DEFAULT_RETRY_MAX_DELAY_MS = 3e4;
|
|
349
|
-
var DEFAULT_RETRY_BACKOFF_MULTIPLIER = 3;
|
|
350
|
-
var DEFAULT_WAIT_TIMEOUT_MS = 3e5;
|
|
351
|
-
var DEFAULT_WAIT_MAX_ATTEMPTS = 30;
|
|
352
|
-
var DEFAULT_WAIT_DELAY_MS = 1e4;
|
|
353
|
-
var DEFAULT_FIND_TX_LIMIT = 100;
|
|
354
|
-
var DEFAULT_MAX_SCANNED_TRANSACTIONS = 100;
|
|
355
|
-
var DEFAULT_FIND_TX_MAX_DEPTH = 10;
|
|
356
|
-
var DEFAULT_RETRY_ON_NOT_FOUND = true;
|
|
357
|
-
var DEFAULT_RETRY_ON_NOT_FOUND_RETRIES = 10;
|
|
358
|
-
var DEFAULT_RETRY_ON_NOT_FOUND_DELAY_MS = 5e3;
|
|
359
|
-
var IGNORE_MSG_VALUE_1_NANO = 1n;
|
|
360
|
-
var CROSS_CHAIN_MESSAGE_VERSION_V1 = 1n;
|
|
361
|
-
var NFT_BRIDGE_AMOUNT = 1n;
|
|
362
|
-
var DEFAULT_EIP1559_PRIORITY_FEE = 0n;
|
|
363
|
-
var IGNORE_OPCODE = [
|
|
364
|
-
3576854235
|
|
365
|
-
// Excess
|
|
366
|
-
];
|
|
367
|
-
var HTTP_NOT_FOUND_STATUS_CODE = 404;
|
|
368
|
-
|
|
369
1216
|
// src/sdk/Utils.ts
|
|
370
1217
|
import { Address as Address5, beginCell as beginCell5, storeMessage, storeStateInit } from "@ton/ton";
|
|
371
|
-
import { getCreate2Address, keccak256, solidityPacked } from "ethers";
|
|
1218
|
+
import { getCreate2Address, keccak256 as keccak2562, solidityPacked } from "ethers";
|
|
372
1219
|
import { sha256_sync } from "ton-crypto";
|
|
373
1220
|
|
|
374
|
-
// src/structs/Struct.ts
|
|
375
|
-
var SimplifiedStatuses = /* @__PURE__ */ ((SimplifiedStatuses2) => {
|
|
376
|
-
SimplifiedStatuses2["PENDING"] = "PENDING";
|
|
377
|
-
SimplifiedStatuses2["FAILED"] = "FAILED";
|
|
378
|
-
SimplifiedStatuses2["SUCCESSFUL"] = "SUCCESSFUL";
|
|
379
|
-
SimplifiedStatuses2["OPERATION_ID_NOT_FOUND"] = "OPERATION_ID_NOT_FOUND";
|
|
380
|
-
return SimplifiedStatuses2;
|
|
381
|
-
})(SimplifiedStatuses || {});
|
|
382
|
-
var Network = /* @__PURE__ */ ((Network2) => {
|
|
383
|
-
Network2["TESTNET"] = "testnet";
|
|
384
|
-
Network2["MAINNET"] = "mainnet";
|
|
385
|
-
Network2["DEV"] = "dev";
|
|
386
|
-
return Network2;
|
|
387
|
-
})(Network || {});
|
|
388
|
-
var BlockchainType = /* @__PURE__ */ ((BlockchainType2) => {
|
|
389
|
-
BlockchainType2["TAC"] = "TAC";
|
|
390
|
-
BlockchainType2["TON"] = "TON";
|
|
391
|
-
return BlockchainType2;
|
|
392
|
-
})(BlockchainType || {});
|
|
393
|
-
var CurrencyType = /* @__PURE__ */ ((CurrencyType2) => {
|
|
394
|
-
CurrencyType2["TAC"] = "TAC";
|
|
395
|
-
CurrencyType2["TON"] = "TON";
|
|
396
|
-
return CurrencyType2;
|
|
397
|
-
})(CurrencyType || {});
|
|
398
|
-
var OperationType = /* @__PURE__ */ ((OperationType2) => {
|
|
399
|
-
OperationType2["PENDING"] = "PENDING";
|
|
400
|
-
OperationType2["TON_TAC_TON"] = "TON-TAC-TON";
|
|
401
|
-
OperationType2["ROLLBACK"] = "ROLLBACK";
|
|
402
|
-
OperationType2["TON_TAC"] = "TON-TAC";
|
|
403
|
-
OperationType2["TAC_TON"] = "TAC-TON";
|
|
404
|
-
OperationType2["UNKNOWN"] = "UNKNOWN";
|
|
405
|
-
return OperationType2;
|
|
406
|
-
})(OperationType || {});
|
|
407
|
-
var OperationExecutionStatus = /* @__PURE__ */ ((OperationExecutionStatus2) => {
|
|
408
|
-
OperationExecutionStatus2["SUCCESS"] = "success";
|
|
409
|
-
OperationExecutionStatus2["FAILED"] = "failed";
|
|
410
|
-
return OperationExecutionStatus2;
|
|
411
|
-
})(OperationExecutionStatus || {});
|
|
412
|
-
var AssetType = /* @__PURE__ */ ((AssetType2) => {
|
|
413
|
-
AssetType2["NFT"] = "NFT";
|
|
414
|
-
AssetType2["FT"] = "FT";
|
|
415
|
-
return AssetType2;
|
|
416
|
-
})(AssetType || {});
|
|
417
|
-
var NFTAddressType = /* @__PURE__ */ ((NFTAddressType2) => {
|
|
418
|
-
NFTAddressType2["ITEM"] = "ITEM";
|
|
419
|
-
NFTAddressType2["COLLECTION"] = "COLLECTION";
|
|
420
|
-
return NFTAddressType2;
|
|
421
|
-
})(NFTAddressType || {});
|
|
422
|
-
var StageName = /* @__PURE__ */ ((StageName2) => {
|
|
423
|
-
StageName2["COLLECTED_IN_TAC"] = "collectedInTAC";
|
|
424
|
-
StageName2["INCLUDED_IN_TAC_CONSENSUS"] = "includedInTACConsensus";
|
|
425
|
-
StageName2["EXECUTED_IN_TAC"] = "executedInTAC";
|
|
426
|
-
StageName2["COLLECTED_IN_TON"] = "collectedInTON";
|
|
427
|
-
StageName2["INCLUDED_IN_TON_CONSENSUS"] = "includedInTONConsensus";
|
|
428
|
-
StageName2["EXECUTED_IN_TON"] = "executedInTON";
|
|
429
|
-
return StageName2;
|
|
430
|
-
})(StageName || {});
|
|
431
|
-
var TokenSymbol = /* @__PURE__ */ ((TokenSymbol2) => {
|
|
432
|
-
TokenSymbol2["TAC_SYMBOL"] = "TAC";
|
|
433
|
-
TokenSymbol2["TON_SYMBOL"] = "TON";
|
|
434
|
-
return TokenSymbol2;
|
|
435
|
-
})(TokenSymbol || {});
|
|
436
|
-
var defaultWaitOptions = {
|
|
437
|
-
timeout: DEFAULT_WAIT_TIMEOUT_MS,
|
|
438
|
-
maxAttempts: DEFAULT_WAIT_MAX_ATTEMPTS,
|
|
439
|
-
delay: DEFAULT_WAIT_DELAY_MS
|
|
440
|
-
};
|
|
441
|
-
var Origin = /* @__PURE__ */ ((Origin2) => {
|
|
442
|
-
Origin2["TON"] = "TON";
|
|
443
|
-
Origin2["TAC"] = "TAC";
|
|
444
|
-
return Origin2;
|
|
445
|
-
})(Origin || {});
|
|
446
|
-
var AssetFeeMode = /* @__PURE__ */ ((AssetFeeMode2) => {
|
|
447
|
-
AssetFeeMode2["TAC_ORIGINAL"] = "TAC_ORIGINAL";
|
|
448
|
-
AssetFeeMode2["LEGACY"] = "LEGACY";
|
|
449
|
-
AssetFeeMode2["DYNAMIC"] = "DYNAMIC";
|
|
450
|
-
return AssetFeeMode2;
|
|
451
|
-
})(AssetFeeMode || {});
|
|
452
|
-
var TransactionTreeDirection = /* @__PURE__ */ ((TransactionTreeDirection2) => {
|
|
453
|
-
TransactionTreeDirection2["FORWARD"] = "forward";
|
|
454
|
-
TransactionTreeDirection2["BACKWARD"] = "backward";
|
|
455
|
-
TransactionTreeDirection2["BOTH"] = "both";
|
|
456
|
-
return TransactionTreeDirection2;
|
|
457
|
-
})(TransactionTreeDirection || {});
|
|
458
|
-
|
|
459
1221
|
// src/assets/AssetCache.ts
|
|
460
1222
|
var AssetCache = class {
|
|
461
1223
|
/**
|
|
@@ -498,8 +1260,8 @@ var AssetCache = class {
|
|
|
498
1260
|
AssetCache.cache = /* @__PURE__ */ new WeakMap();
|
|
499
1261
|
|
|
500
1262
|
// src/assets/FT.ts
|
|
501
|
-
import { Address as Address2, beginCell as beginCell2, Cell as Cell2 } from "@ton/ton";
|
|
502
|
-
import { Contract, isAddress as isEthereumAddress2 } from "ethers";
|
|
1263
|
+
import { Address as Address2, beginCell as beginCell2, Cell as Cell2, ComputeError } from "@ton/ton";
|
|
1264
|
+
import { Contract as Contract5, isAddress as isEthereumAddress2 } from "ethers";
|
|
503
1265
|
|
|
504
1266
|
// src/sdk/Validator.ts
|
|
505
1267
|
import { Address } from "@ton/ton";
|
|
@@ -820,11 +1582,9 @@ var FT = class _FT {
|
|
|
820
1582
|
const result = await this.getOriginAndData(configuration, address3);
|
|
821
1583
|
return result.origin;
|
|
822
1584
|
}
|
|
823
|
-
static async getOriginAndData(configuration, address3) {
|
|
1585
|
+
static async getOriginAndData(configuration, address3, contractState) {
|
|
824
1586
|
const { jettonMinterCode, crossChainLayerAddress, jettonWalletCode } = configuration.TONParams;
|
|
825
|
-
const { code: thisCodeBOC } = await configuration.TONParams.contractOpener.getContractState(
|
|
826
|
-
Address2.parse(address3)
|
|
827
|
-
);
|
|
1587
|
+
const { code: thisCodeBOC } = contractState ?? await configuration.TONParams.contractOpener.getContractState(Address2.parse(address3));
|
|
828
1588
|
if (!thisCodeBOC) {
|
|
829
1589
|
throw emptyContractError;
|
|
830
1590
|
}
|
|
@@ -852,7 +1612,7 @@ var FT = class _FT {
|
|
|
852
1612
|
const fromTVM = await configuration.TACParams.tokenUtils["exists(address)"](address3);
|
|
853
1613
|
if (fromTVM) {
|
|
854
1614
|
const cclErc20Abi = configuration.artifacts.tac.compilationArtifacts.ICrossChainLayerERC20.abi;
|
|
855
|
-
const erc20Token = new
|
|
1615
|
+
const erc20Token = new Contract5(address3, cclErc20Abi, configuration.TACParams.provider);
|
|
856
1616
|
const info = await erc20Token.getInfo();
|
|
857
1617
|
return info.tvmAddress;
|
|
858
1618
|
}
|
|
@@ -901,7 +1661,7 @@ var FT = class _FT {
|
|
|
901
1661
|
return TAC_DECIMALS;
|
|
902
1662
|
}
|
|
903
1663
|
const erc20TokenAbi = configuration.artifacts.tac.compilationArtifacts.IERC20WithDecimals.abi;
|
|
904
|
-
const erc20Token = new
|
|
1664
|
+
const erc20Token = new Contract5(
|
|
905
1665
|
evmAddress,
|
|
906
1666
|
erc20TokenAbi,
|
|
907
1667
|
configuration.TACParams.provider
|
|
@@ -910,12 +1670,13 @@ var FT = class _FT {
|
|
|
910
1670
|
}
|
|
911
1671
|
static async fromAddress(configuration, address3) {
|
|
912
1672
|
const tvmAddress = isEthereumAddress2(address3) ? await this.getTVMAddress(configuration, address3) : address3;
|
|
1673
|
+
const contractState = await configuration.TONParams.contractOpener.getContractState(Address2.parse(tvmAddress));
|
|
913
1674
|
const {
|
|
914
1675
|
origin,
|
|
915
1676
|
jettonMinter,
|
|
916
1677
|
evmAddress: cachedEvmAddress,
|
|
917
1678
|
jettonData
|
|
918
|
-
} = await this.getOriginAndData(configuration, tvmAddress).catch((e) => {
|
|
1679
|
+
} = await this.getOriginAndData(configuration, tvmAddress, contractState).catch((e) => {
|
|
919
1680
|
if (e instanceof ContractError) {
|
|
920
1681
|
const jettonMinter2 = configuration.TONParams.contractOpener.open(
|
|
921
1682
|
configuration.artifacts.ton.wrappers.JettonMinter.createFromAddress(Address2.parse(tvmAddress))
|
|
@@ -946,7 +1707,9 @@ var FT = class _FT {
|
|
|
946
1707
|
if (finalEvmAddress || isEthereumAddress2(address3)) {
|
|
947
1708
|
token._evmAddress = finalEvmAddress || address3;
|
|
948
1709
|
}
|
|
949
|
-
|
|
1710
|
+
if (contractState.state !== "uninitialized") {
|
|
1711
|
+
await token.refreshDisplayMultiplier();
|
|
1712
|
+
}
|
|
950
1713
|
return token;
|
|
951
1714
|
}
|
|
952
1715
|
get rawAmount() {
|
|
@@ -958,6 +1721,7 @@ var FT = class _FT {
|
|
|
958
1721
|
ft._evmAddress = this._evmAddress;
|
|
959
1722
|
ft._displayMultiplierNumerator = this._displayMultiplierNumerator;
|
|
960
1723
|
ft._displayMultiplierDenominator = this._displayMultiplierDenominator;
|
|
1724
|
+
ft._hasDisplayMultiplier = this._hasDisplayMultiplier;
|
|
961
1725
|
ft._displayMultiplierFetchedAt = this._displayMultiplierFetchedAt;
|
|
962
1726
|
ft._displayMultiplierCacheDuration = this._displayMultiplierCacheDuration;
|
|
963
1727
|
return ft;
|
|
@@ -995,17 +1759,26 @@ var FT = class _FT {
|
|
|
995
1759
|
async getDecimals() {
|
|
996
1760
|
return this._decimals;
|
|
997
1761
|
}
|
|
998
|
-
async
|
|
1762
|
+
async getDisplayMultiplier() {
|
|
999
1763
|
try {
|
|
1000
1764
|
const multiplier = await this._jettonMinter.getDisplayMultiplier();
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
this.
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1765
|
+
return { hasDisplayMultiplier: true, ...multiplier };
|
|
1766
|
+
} catch (error) {
|
|
1767
|
+
if (this._hasDisplayMultiplier || !(error instanceof ComputeError) || error.exitCode !== 11) {
|
|
1768
|
+
throw error;
|
|
1769
|
+
}
|
|
1770
|
+
return { hasDisplayMultiplier: false, numerator: 1n, denominator: 1n };
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
async refreshDisplayMultiplier() {
|
|
1774
|
+
if (this._hasDisplayMultiplier === false) {
|
|
1775
|
+
return;
|
|
1008
1776
|
}
|
|
1777
|
+
const multiplier = await this.getDisplayMultiplier();
|
|
1778
|
+
this._hasDisplayMultiplier = multiplier.hasDisplayMultiplier;
|
|
1779
|
+
this._displayMultiplierNumerator = multiplier.numerator;
|
|
1780
|
+
this._displayMultiplierDenominator = multiplier.denominator;
|
|
1781
|
+
this._displayMultiplierFetchedAt = Date.now();
|
|
1009
1782
|
}
|
|
1010
1783
|
async ensureFreshDisplayMultiplier() {
|
|
1011
1784
|
const age = Date.now() - this._displayMultiplierFetchedAt;
|
|
@@ -1092,11 +1865,11 @@ var FT = class _FT {
|
|
|
1092
1865
|
return BigInt(await wallet.getJettonBalance());
|
|
1093
1866
|
}
|
|
1094
1867
|
async getUserBalanceExtended(userAddress) {
|
|
1095
|
-
await this.ensureFreshDisplayMultiplier();
|
|
1096
1868
|
const masterState = await this._configuration.TONParams.contractOpener.getContractState(this._tvmAddress);
|
|
1097
1869
|
if (masterState.state !== "active") {
|
|
1098
1870
|
return { exists: false };
|
|
1099
1871
|
}
|
|
1872
|
+
await this.ensureFreshDisplayMultiplier();
|
|
1100
1873
|
const wallet = await this.getWallet(userAddress);
|
|
1101
1874
|
const rawAmount = await wallet.getJettonBalance();
|
|
1102
1875
|
const decimals = await this.getDecimals();
|
|
@@ -1129,7 +1902,7 @@ var FT = class _FT {
|
|
|
1129
1902
|
if (evmAddress === nativeTACAddress) {
|
|
1130
1903
|
return this._configuration.TACParams.provider.getBalance(userAddress);
|
|
1131
1904
|
}
|
|
1132
|
-
const erc20Token = new
|
|
1905
|
+
const erc20Token = new Contract5(
|
|
1133
1906
|
evmAddress,
|
|
1134
1907
|
this._configuration.artifacts.tac.compilationArtifacts.IERC20WithDecimals.abi,
|
|
1135
1908
|
this._configuration.TACParams.provider
|
|
@@ -1164,7 +1937,7 @@ var FT = class _FT {
|
|
|
1164
1937
|
|
|
1165
1938
|
// src/assets/NFT.ts
|
|
1166
1939
|
import { Address as Address3, address, beginCell as beginCell3, Cell as Cell3, fromNano } from "@ton/ton";
|
|
1167
|
-
import { Contract as
|
|
1940
|
+
import { Contract as Contract6, isAddress as isEthereumAddress3 } from "ethers";
|
|
1168
1941
|
var NFT = class _NFT {
|
|
1169
1942
|
constructor(nftAddress, origin, configuration, feeMode = _NFT.resolveFeeMode(origin)) {
|
|
1170
1943
|
this.type = "NFT" /* NFT */;
|
|
@@ -1278,7 +2051,7 @@ var NFT = class _NFT {
|
|
|
1278
2051
|
const exists = await configuration.TACParams.tokenUtils["exists(address)"](collectionAddress);
|
|
1279
2052
|
if (exists) {
|
|
1280
2053
|
const cclErc721TokenAbi = configuration.artifacts.tac.compilationArtifacts.ICrossChainLayerERC721.abi;
|
|
1281
|
-
const cclErc721Token = new
|
|
2054
|
+
const cclErc721Token = new Contract6(
|
|
1282
2055
|
collectionAddress,
|
|
1283
2056
|
cclErc721TokenAbi,
|
|
1284
2057
|
configuration.TACParams.provider
|
|
@@ -1411,7 +2184,7 @@ var NFT = class _NFT {
|
|
|
1411
2184
|
return await this.isOwnedBy(userAddress) ? 1n : 0n;
|
|
1412
2185
|
}
|
|
1413
2186
|
Validator.validateEVMAddress(userAddress);
|
|
1414
|
-
const nft = new
|
|
2187
|
+
const nft = new Contract6(
|
|
1415
2188
|
await this.getEVMAddress(),
|
|
1416
2189
|
this._configuration.artifacts.tac.compilationArtifacts.IERC721.abi,
|
|
1417
2190
|
this._configuration.TACParams.provider
|
|
@@ -1508,7 +2281,7 @@ var TAC = class _TAC {
|
|
|
1508
2281
|
|
|
1509
2282
|
// src/assets/TON.ts
|
|
1510
2283
|
import { Address as Address4, beginCell as beginCell4 } from "@ton/ton";
|
|
1511
|
-
import { Contract as
|
|
2284
|
+
import { Contract as Contract7 } from "ethers";
|
|
1512
2285
|
var TON = class _TON {
|
|
1513
2286
|
constructor(config) {
|
|
1514
2287
|
this.type = "FT" /* FT */;
|
|
@@ -1595,7 +2368,7 @@ var TON = class _TON {
|
|
|
1595
2368
|
return this.getUserBalance(userAddress);
|
|
1596
2369
|
}
|
|
1597
2370
|
Validator.validateEVMAddress(userAddress);
|
|
1598
|
-
const token = new
|
|
2371
|
+
const token = new Contract7(
|
|
1599
2372
|
await this.getEVMAddress(),
|
|
1600
2373
|
this._config.artifacts.tac.compilationArtifacts.IERC20WithDecimals.abi,
|
|
1601
2374
|
this._config.TACParams.provider
|
|
@@ -2479,7 +3252,16 @@ var BaseContractOpener = class {
|
|
|
2479
3252
|
};
|
|
2480
3253
|
|
|
2481
3254
|
// src/adapters/LiteClientOpener.ts
|
|
2482
|
-
import {
|
|
3255
|
+
import {
|
|
3256
|
+
beginCell as beginCell7,
|
|
3257
|
+
Cell as Cell6,
|
|
3258
|
+
ComputeError as ComputeError2,
|
|
3259
|
+
loadTransaction,
|
|
3260
|
+
openContract,
|
|
3261
|
+
parseTuple,
|
|
3262
|
+
serializeTuple,
|
|
3263
|
+
TupleReader
|
|
3264
|
+
} from "@ton/ton";
|
|
2483
3265
|
import { LiteClient, LiteRoundRobinEngine, LiteSingleEngine } from "@tonappchain/ton-lite-client";
|
|
2484
3266
|
function intToIP(int) {
|
|
2485
3267
|
const part1 = int & 255;
|
|
@@ -2518,7 +3300,23 @@ var LiteClientOpener = class _LiteClientOpener extends BaseContractOpener {
|
|
|
2518
3300
|
return new _LiteClientOpener(client, engine, logger, engines);
|
|
2519
3301
|
}
|
|
2520
3302
|
open(contract) {
|
|
2521
|
-
return
|
|
3303
|
+
return openContract(contract, ({ address: address3, init }) => ({
|
|
3304
|
+
...this.client.provider(address3, init),
|
|
3305
|
+
open: (src) => this.open(src),
|
|
3306
|
+
get: async (name, args) => {
|
|
3307
|
+
const block = await this.client.getMasterchainInfo();
|
|
3308
|
+
const result = await this.client.runMethod(
|
|
3309
|
+
address3,
|
|
3310
|
+
name.toString(),
|
|
3311
|
+
serializeTuple(args).toBoc({ idx: false, crc32: false }),
|
|
3312
|
+
block.last
|
|
3313
|
+
);
|
|
3314
|
+
if (result.exitCode !== 0 && result.exitCode !== 1) {
|
|
3315
|
+
throw new ComputeError2(`Exit code: ${result.exitCode}`, result.exitCode);
|
|
3316
|
+
}
|
|
3317
|
+
return { stack: new TupleReader(result.result ? parseTuple(Cell6.fromBase64(result.result)) : []) };
|
|
3318
|
+
}
|
|
3319
|
+
}));
|
|
2522
3320
|
}
|
|
2523
3321
|
disableReconnect(singleEngine) {
|
|
2524
3322
|
const engine = singleEngine;
|
|
@@ -2790,6 +3588,8 @@ import { Address as Address11 } from "@ton/ton";
|
|
|
2790
3588
|
import { getHttpEndpoint as getHttpEndpoint2 } from "@orbs-network/ton-access";
|
|
2791
3589
|
import {
|
|
2792
3590
|
beginCell as beginCell8,
|
|
3591
|
+
ComputeError as ComputeError4,
|
|
3592
|
+
openContract as openContract3,
|
|
2793
3593
|
storeMessage as storeMessage3,
|
|
2794
3594
|
TonClient,
|
|
2795
3595
|
TonClient4 as TonClient42
|
|
@@ -2797,7 +3597,7 @@ import {
|
|
|
2797
3597
|
|
|
2798
3598
|
// src/adapters/TonClient4Opener.ts
|
|
2799
3599
|
import { getHttpV4Endpoint as getHttpV4Endpoint2 } from "@orbs-network/ton-access";
|
|
2800
|
-
import { TonClient4 } from "@ton/ton";
|
|
3600
|
+
import { ComputeError as ComputeError3, openContract as openContract2, TonClient4 } from "@ton/ton";
|
|
2801
3601
|
var TonClient4Opener = class _TonClient4Opener extends BaseContractOpener {
|
|
2802
3602
|
constructor(client4, logger) {
|
|
2803
3603
|
super(logger);
|
|
@@ -2808,7 +3608,21 @@ var TonClient4Opener = class _TonClient4Opener extends BaseContractOpener {
|
|
|
2808
3608
|
return new _TonClient4Opener(client4, logger);
|
|
2809
3609
|
}
|
|
2810
3610
|
open(contract) {
|
|
2811
|
-
return
|
|
3611
|
+
return openContract2(contract, ({ address: address3, init }) => ({
|
|
3612
|
+
...this.client4.provider(address3, init),
|
|
3613
|
+
open: (src) => this.open(src),
|
|
3614
|
+
get: async (name, args) => {
|
|
3615
|
+
if (typeof name !== "string") {
|
|
3616
|
+
throw new Error("Method name must be a string for TonClient4 provider");
|
|
3617
|
+
}
|
|
3618
|
+
const block = await this.client4.getLastBlock();
|
|
3619
|
+
const result = await this.client4.runMethod(block.last.seqno, address3, name, args);
|
|
3620
|
+
if (result.exitCode !== 0 && result.exitCode !== 1) {
|
|
3621
|
+
throw new ComputeError3(`Exit code: ${result.exitCode}`, result.exitCode);
|
|
3622
|
+
}
|
|
3623
|
+
return { stack: result.reader };
|
|
3624
|
+
}
|
|
3625
|
+
}));
|
|
2812
3626
|
}
|
|
2813
3627
|
async getContractState(address3) {
|
|
2814
3628
|
const latestBlock = await this.client4.getLastBlock();
|
|
@@ -2884,7 +3698,23 @@ var TonClientOpener = class _TonClientOpener extends BaseContractOpener {
|
|
|
2884
3698
|
return new _TonClientOpener(client, logger);
|
|
2885
3699
|
}
|
|
2886
3700
|
open(contract) {
|
|
2887
|
-
return
|
|
3701
|
+
return openContract3(contract, ({ address: address3, init }) => ({
|
|
3702
|
+
...this.client.provider(address3, init),
|
|
3703
|
+
open: (src) => this.open(src),
|
|
3704
|
+
get: async (name, args) => {
|
|
3705
|
+
if (typeof name !== "string") {
|
|
3706
|
+
throw new Error("Method name must be a string for TonClient provider");
|
|
3707
|
+
}
|
|
3708
|
+
const result = await this.client.runMethodWithError(address3, name, args);
|
|
3709
|
+
if (result.exit_code !== 0 && result.exit_code !== 1) {
|
|
3710
|
+
throw new ComputeError4(
|
|
3711
|
+
`Unable to execute get method. Got exit_code: ${result.exit_code}`,
|
|
3712
|
+
result.exit_code
|
|
3713
|
+
);
|
|
3714
|
+
}
|
|
3715
|
+
return { stack: result.stack };
|
|
3716
|
+
}
|
|
3717
|
+
}));
|
|
2888
3718
|
}
|
|
2889
3719
|
async getContractState(address3) {
|
|
2890
3720
|
return this.client.getContractState(address3);
|
|
@@ -3399,13 +4229,30 @@ async function createDefaultRetryableOpener(tonRpcEndpoint, networkType, maxRetr
|
|
|
3399
4229
|
}
|
|
3400
4230
|
|
|
3401
4231
|
// src/adapters/SandboxOpener.ts
|
|
4232
|
+
import { ComputeError as ComputeError5 } from "@ton/ton";
|
|
3402
4233
|
var SandboxOpener = class extends BaseContractOpener {
|
|
3403
4234
|
constructor(blockchain) {
|
|
3404
4235
|
super();
|
|
3405
4236
|
this.blockchain = blockchain;
|
|
3406
4237
|
}
|
|
3407
4238
|
open(contract) {
|
|
3408
|
-
return this.blockchain.openContract(contract)
|
|
4239
|
+
return new Proxy(this.blockchain.openContract(contract), {
|
|
4240
|
+
get: (target, prop) => {
|
|
4241
|
+
const value = Reflect.get(target, prop);
|
|
4242
|
+
if (typeof prop !== "string" || !prop.startsWith("get") || typeof value !== "function") return value;
|
|
4243
|
+
return (...args) => {
|
|
4244
|
+
const result = value.apply(target, args);
|
|
4245
|
+
if (!(result instanceof Promise)) return result;
|
|
4246
|
+
return result.catch((error) => {
|
|
4247
|
+
if (error instanceof Error && "exitCode" in error && typeof error.exitCode === "number") {
|
|
4248
|
+
const { vmLogs, debugLogs } = error;
|
|
4249
|
+
throw new ComputeError5(error.message, error.exitCode, { logs: vmLogs, debugLogs });
|
|
4250
|
+
}
|
|
4251
|
+
throw error;
|
|
4252
|
+
});
|
|
4253
|
+
};
|
|
4254
|
+
}
|
|
4255
|
+
});
|
|
3409
4256
|
}
|
|
3410
4257
|
async getContractState(address3) {
|
|
3411
4258
|
const state = await this.blockchain.provider(address3).getState();
|
|
@@ -3542,7 +4389,7 @@ var AbiHandler = class {
|
|
|
3542
4389
|
};
|
|
3543
4390
|
|
|
3544
4391
|
// src/agnosticSdk/DebugHelpers.ts
|
|
3545
|
-
import { AbiCoder as
|
|
4392
|
+
import { AbiCoder as AbiCoder4, formatEther } from "ethers";
|
|
3546
4393
|
|
|
3547
4394
|
// src/agnosticSdk/AgnosticStructs.ts
|
|
3548
4395
|
var AgnosticStructs_exports = {};
|
|
@@ -3589,14 +4436,14 @@ var DebugHelpers = class {
|
|
|
3589
4436
|
try {
|
|
3590
4437
|
switch (hook.hookType) {
|
|
3591
4438
|
case 0 /* Custom */:
|
|
3592
|
-
return
|
|
4439
|
+
return AbiCoder4.defaultAbiCoder().decode(
|
|
3593
4440
|
["tuple(bool,address,uint256,bytes,bytes)"],
|
|
3594
4441
|
hook.hookData
|
|
3595
4442
|
)[0];
|
|
3596
4443
|
case 1 /* FullBalanceApprove */:
|
|
3597
|
-
return
|
|
4444
|
+
return AbiCoder4.defaultAbiCoder().decode(["tuple(address,address,bool)"], hook.hookData)[0];
|
|
3598
4445
|
case 2 /* FullBalanceTransfer */:
|
|
3599
|
-
return
|
|
4446
|
+
return AbiCoder4.defaultAbiCoder().decode(["tuple(address,address,bool)"], hook.hookData)[0];
|
|
3600
4447
|
default:
|
|
3601
4448
|
throw new Error(`Unknown hook type: ${hook.hookType}`);
|
|
3602
4449
|
}
|
|
@@ -3816,7 +4663,7 @@ ${stepNumber}. ${this._describeHook(hook, contractInterfaces)}`);
|
|
|
3816
4663
|
* @returns The encoded zap call that can be used as calldata in tac sdk
|
|
3817
4664
|
*/
|
|
3818
4665
|
encodeZapCall(zapCall) {
|
|
3819
|
-
return
|
|
4666
|
+
return AbiCoder4.defaultAbiCoder().encode(
|
|
3820
4667
|
[
|
|
3821
4668
|
"tuple(tuple(uint8,bytes)[],tuple(address[],tuple(address,uint256,uint256)[],bool))"
|
|
3822
4669
|
],
|
|
@@ -3835,7 +4682,7 @@ ${stepNumber}. ${this._describeHook(hook, contractInterfaces)}`);
|
|
|
3835
4682
|
};
|
|
3836
4683
|
|
|
3837
4684
|
// src/agnosticSdk/HooksHandler.ts
|
|
3838
|
-
import { AbiCoder as
|
|
4685
|
+
import { AbiCoder as AbiCoder5, getAddress } from "ethers";
|
|
3839
4686
|
var HooksHandler = class {
|
|
3840
4687
|
/**
|
|
3841
4688
|
* Create a custom hook with optional dynamic value replacement
|
|
@@ -3855,11 +4702,11 @@ var HooksHandler = class {
|
|
|
3855
4702
|
let improvedMissionInfo = "0x";
|
|
3856
4703
|
if (dynamicReplacements && dynamicReplacements.length > 0) {
|
|
3857
4704
|
const replacement = dynamicReplacements[0];
|
|
3858
|
-
const replacementData =
|
|
4705
|
+
const replacementData = AbiCoder5.defaultAbiCoder().encode(
|
|
3859
4706
|
["tuple(uint16,uint16,address,address)"],
|
|
3860
4707
|
[[replacement.position, replacement.len, replacement.token, replacement.balanceAddress]]
|
|
3861
4708
|
);
|
|
3862
|
-
improvedMissionInfo =
|
|
4709
|
+
improvedMissionInfo = AbiCoder5.defaultAbiCoder().encode(
|
|
3863
4710
|
["uint8", "bytes"],
|
|
3864
4711
|
[0 /* Amount */, replacementData]
|
|
3865
4712
|
);
|
|
@@ -3872,7 +4719,7 @@ var HooksHandler = class {
|
|
|
3872
4719
|
data,
|
|
3873
4720
|
improvedMissionInfo
|
|
3874
4721
|
};
|
|
3875
|
-
const encodedHookData =
|
|
4722
|
+
const encodedHookData = AbiCoder5.defaultAbiCoder().encode(
|
|
3876
4723
|
["tuple(bool,address,uint256,bytes,bytes)"],
|
|
3877
4724
|
[
|
|
3878
4725
|
[
|
|
@@ -3902,7 +4749,7 @@ var HooksHandler = class {
|
|
|
3902
4749
|
to,
|
|
3903
4750
|
isFromSAPerspective
|
|
3904
4751
|
};
|
|
3905
|
-
const encodedHookData =
|
|
4752
|
+
const encodedHookData = AbiCoder5.defaultAbiCoder().encode(
|
|
3906
4753
|
["tuple(address,address,bool)"],
|
|
3907
4754
|
[[approveHookData.token, approveHookData.to, approveHookData.isFromSAPerspective]]
|
|
3908
4755
|
);
|
|
@@ -3924,7 +4771,7 @@ var HooksHandler = class {
|
|
|
3924
4771
|
to,
|
|
3925
4772
|
isFromSAPerspective
|
|
3926
4773
|
};
|
|
3927
|
-
const encodedHookData =
|
|
4774
|
+
const encodedHookData = AbiCoder5.defaultAbiCoder().encode(
|
|
3928
4775
|
["tuple(address,address,bool)"],
|
|
3929
4776
|
[[transferHookData.token, transferHookData.to, transferHookData.isFromSAPerspective]]
|
|
3930
4777
|
);
|
|
@@ -4381,23 +5228,9 @@ var AgnosticProxySDK = class {
|
|
|
4381
5228
|
}
|
|
4382
5229
|
};
|
|
4383
5230
|
|
|
4384
|
-
// src/sdk/Artifacts.ts
|
|
4385
|
-
function getArtifacts(network) {
|
|
4386
|
-
switch (network) {
|
|
4387
|
-
case "mainnet" /* MAINNET */:
|
|
4388
|
-
return mainnet_exports;
|
|
4389
|
-
case "testnet" /* TESTNET */:
|
|
4390
|
-
return testnet_exports;
|
|
4391
|
-
case "dev" /* DEV */:
|
|
4392
|
-
return dev_exports;
|
|
4393
|
-
default:
|
|
4394
|
-
throw new Error(`Unsupported network: ${network}`);
|
|
4395
|
-
}
|
|
4396
|
-
}
|
|
4397
|
-
|
|
4398
5231
|
// src/sdk/Configuration.ts
|
|
4399
|
-
import { Address as
|
|
4400
|
-
import { AbiCoder as
|
|
5232
|
+
import { Address as Address14, Dictionary as Dictionary2, loadConfigParamsAsSlice, parseFullConfig } from "@ton/ton";
|
|
5233
|
+
import { AbiCoder as AbiCoder6, Contract as Contract14, getDefaultProvider as getDefaultProvider2, id, keccak256 as keccak2563, toUtf8Bytes } from "ethers";
|
|
4401
5234
|
|
|
4402
5235
|
// src/sdk/Fees.ts
|
|
4403
5236
|
var DEFAULT_CONTRACT_FEE_USAGE_PARAMS = {
|
|
@@ -4671,7 +5504,7 @@ var Configuration = class _Configuration {
|
|
|
4671
5504
|
contractOpener.setLogger(logger);
|
|
4672
5505
|
}
|
|
4673
5506
|
const settings = contractOpener.open(
|
|
4674
|
-
artifacts.ton.wrappers.Settings.createFromAddress(
|
|
5507
|
+
artifacts.ton.wrappers.Settings.createFromAddress(Address14.parse(settingsAddress))
|
|
4675
5508
|
);
|
|
4676
5509
|
const allSettingsSlice = (await settings.getAll()).beginParse();
|
|
4677
5510
|
const allSettings = allSettingsSlice.loadDictDirect(Dictionary2.Keys.BigUint(256), Dictionary2.Values.Cell());
|
|
@@ -4726,13 +5559,13 @@ var Configuration = class _Configuration {
|
|
|
4726
5559
|
}
|
|
4727
5560
|
saFactoryAddress = TACParams2.saFactoryAddress;
|
|
4728
5561
|
} else {
|
|
4729
|
-
provider = TACParams2?.provider ??
|
|
5562
|
+
provider = TACParams2?.provider ?? getDefaultProvider2(artifacts.TAC_RPC_ENDPOINT);
|
|
4730
5563
|
settingsAddress = TACParams2?.settingsAddress ?? artifacts.TAC_SETTINGS_ADDRESS;
|
|
4731
5564
|
saFactoryAddress = TACParams2?.saFactoryAddress ?? artifacts.TAC_SMART_ACCOUNT_FACTORY_ADDRESS;
|
|
4732
5565
|
}
|
|
4733
5566
|
Validator.validateEVMAddress(settingsAddress);
|
|
4734
5567
|
const settingsAbi = artifacts.tac.compilationArtifacts.ISettings.abi;
|
|
4735
|
-
const settings = new
|
|
5568
|
+
const settings = new Contract14(settingsAddress, settingsAbi, provider);
|
|
4736
5569
|
const loaded = await this.loadTACSettingsViaMulticall(network, provider, settingsAddress);
|
|
4737
5570
|
let crossChainLayerAddress;
|
|
4738
5571
|
let tokenUtilsAddress;
|
|
@@ -4744,21 +5577,21 @@ var Configuration = class _Configuration {
|
|
|
4744
5577
|
trustedTACExecutors = loaded.trustedTACExecutors;
|
|
4745
5578
|
trustedTONExecutors = loaded.trustedTONExecutors;
|
|
4746
5579
|
} else {
|
|
4747
|
-
crossChainLayerAddress = await settings.getAddressSetting(
|
|
4748
|
-
tokenUtilsAddress = await settings.getAddressSetting(
|
|
5580
|
+
crossChainLayerAddress = await settings.getAddressSetting(keccak2563(toUtf8Bytes("CrossChainLayerAddress")));
|
|
5581
|
+
tokenUtilsAddress = await settings.getAddressSetting(keccak2563(toUtf8Bytes("TokenUtilsAddress")));
|
|
4749
5582
|
trustedTACExecutors = await settings.getTrustedEVMExecutors();
|
|
4750
5583
|
trustedTONExecutors = await settings.getTrustedTVMExecutors();
|
|
4751
5584
|
}
|
|
4752
5585
|
const crossChainLayerAbi = artifacts.tac.compilationArtifacts.ICrossChainLayer.abi;
|
|
4753
|
-
const crossChainLayer = new
|
|
5586
|
+
const crossChainLayer = new Contract14(
|
|
4754
5587
|
crossChainLayerAddress,
|
|
4755
5588
|
crossChainLayerAbi,
|
|
4756
5589
|
provider
|
|
4757
5590
|
);
|
|
4758
5591
|
const tokenUtilsAbi = artifacts.tac.compilationArtifacts.ITokenUtils.abi;
|
|
4759
|
-
const tokenUtils = new
|
|
5592
|
+
const tokenUtils = new Contract14(tokenUtilsAddress, tokenUtilsAbi, provider);
|
|
4760
5593
|
const TacSAFactoryAbi = artifacts.tac.compilationArtifacts.ISAFactory.abi;
|
|
4761
|
-
const smartAccountFactory = new
|
|
5594
|
+
const smartAccountFactory = new Contract14(
|
|
4762
5595
|
saFactoryAddress,
|
|
4763
5596
|
TacSAFactoryAbi,
|
|
4764
5597
|
provider
|
|
@@ -4771,7 +5604,7 @@ var Configuration = class _Configuration {
|
|
|
4771
5604
|
crossChainLayer,
|
|
4772
5605
|
trustedTACExecutors,
|
|
4773
5606
|
trustedTONExecutors,
|
|
4774
|
-
abiCoder: new
|
|
5607
|
+
abiCoder: new AbiCoder6()
|
|
4775
5608
|
};
|
|
4776
5609
|
}
|
|
4777
5610
|
static async loadTACSettingsViaMulticall(network, provider, settingsAddress) {
|
|
@@ -4783,14 +5616,14 @@ var Configuration = class _Configuration {
|
|
|
4783
5616
|
const multicallAbi = artifacts.tac.multicall.MULTICALL_ABI_ETHERS;
|
|
4784
5617
|
try {
|
|
4785
5618
|
Validator.validateEVMAddress(multicallAddress);
|
|
4786
|
-
const multicall = new
|
|
4787
|
-
const
|
|
5619
|
+
const multicall = new Contract14(multicallAddress, multicallAbi, provider);
|
|
5620
|
+
const abiCoder3 = new AbiCoder6();
|
|
4788
5621
|
const selectorGetAddressSetting = id("getAddressSetting(bytes32)").slice(0, 10);
|
|
4789
5622
|
const selectorGetTrustedEVMExecutors = id("getTrustedEVMExecutors()").slice(0, 10);
|
|
4790
5623
|
const selectorGetTrustedTVMExecutors = id("getTrustedTVMExecutors()").slice(0, 10);
|
|
4791
|
-
const crossChainLayerKey =
|
|
4792
|
-
const tokenUtilsKey =
|
|
4793
|
-
const encodeGetAddressSetting = (key) => selectorGetAddressSetting +
|
|
5624
|
+
const crossChainLayerKey = keccak2563(toUtf8Bytes("CrossChainLayerAddress"));
|
|
5625
|
+
const tokenUtilsKey = keccak2563(toUtf8Bytes("TokenUtilsAddress"));
|
|
5626
|
+
const encodeGetAddressSetting = (key) => selectorGetAddressSetting + abiCoder3.encode(["bytes32"], [key]).slice(2);
|
|
4794
5627
|
const calls = [
|
|
4795
5628
|
{ target: settingsAddress, allowFailure: false, callData: encodeGetAddressSetting(crossChainLayerKey) },
|
|
4796
5629
|
{ target: settingsAddress, allowFailure: false, callData: encodeGetAddressSetting(tokenUtilsKey) },
|
|
@@ -4800,10 +5633,10 @@ var Configuration = class _Configuration {
|
|
|
4800
5633
|
const results = await multicall.aggregate3.staticCall(calls);
|
|
4801
5634
|
if (results.some((result) => !result.success)) return null;
|
|
4802
5635
|
return {
|
|
4803
|
-
crossChainLayerAddress:
|
|
4804
|
-
tokenUtilsAddress:
|
|
4805
|
-
trustedTACExecutors:
|
|
4806
|
-
trustedTONExecutors:
|
|
5636
|
+
crossChainLayerAddress: abiCoder3.decode(["address"], results[0].returnData)[0],
|
|
5637
|
+
tokenUtilsAddress: abiCoder3.decode(["address"], results[1].returnData)[0],
|
|
5638
|
+
trustedTACExecutors: abiCoder3.decode(["address[]"], results[2].returnData)[0],
|
|
5639
|
+
trustedTONExecutors: abiCoder3.decode(["string[]"], results[3].returnData)[0]
|
|
4807
5640
|
};
|
|
4808
5641
|
} catch {
|
|
4809
5642
|
return null;
|
|
@@ -4825,7 +5658,7 @@ var Configuration = class _Configuration {
|
|
|
4825
5658
|
return this.TONParams.contractOpener.closeConnections?.();
|
|
4826
5659
|
}
|
|
4827
5660
|
async isContractDeployedOnTVM(address3) {
|
|
4828
|
-
return (await this.TONParams.contractOpener.getContractState(
|
|
5661
|
+
return (await this.TONParams.contractOpener.getContractState(Address14.parse(address3))).state === "active";
|
|
4829
5662
|
}
|
|
4830
5663
|
static async retrieveTONFeesParams(contractOpener) {
|
|
4831
5664
|
try {
|
|
@@ -5156,7 +5989,7 @@ var LiteSequencerClient = class {
|
|
|
5156
5989
|
};
|
|
5157
5990
|
|
|
5158
5991
|
// src/sdk/OperationTracker.ts
|
|
5159
|
-
import { Address as
|
|
5992
|
+
import { Address as Address15, Cell as Cell7, loadMessage } from "@ton/ton";
|
|
5160
5993
|
var DefaultLiteSequencerClientFactory = class {
|
|
5161
5994
|
createClients(endpoints) {
|
|
5162
5995
|
return endpoints.map((endpoint) => new LiteSequencerClient(endpoint));
|
|
@@ -5227,7 +6060,7 @@ var OperationTracker = class {
|
|
|
5227
6060
|
if (message.info.type !== "external-in") {
|
|
5228
6061
|
throw externalInMessageRequiredError(message.info.type);
|
|
5229
6062
|
}
|
|
5230
|
-
const destination =
|
|
6063
|
+
const destination = Address15.parse(message.info.dest.toString());
|
|
5231
6064
|
const messageHash = getNormalizedExtMessageHash(message);
|
|
5232
6065
|
return this.getOperationIdByTonTransaction(
|
|
5233
6066
|
async () => {
|
|
@@ -5557,7 +6390,7 @@ var OperationTracker = class {
|
|
|
5557
6390
|
};
|
|
5558
6391
|
|
|
5559
6392
|
// src/sdk/Simulator.ts
|
|
5560
|
-
import { Address as
|
|
6393
|
+
import { Address as Address16, toNano as toNano2 } from "@ton/ton";
|
|
5561
6394
|
var Simulator = class {
|
|
5562
6395
|
constructor(config, operationTracker, logger = new NoopLogger()) {
|
|
5563
6396
|
this.config = config;
|
|
@@ -5607,7 +6440,7 @@ var Simulator = class {
|
|
|
5607
6440
|
const isRoundTrip = options.isRoundTrip ?? (assets.length !== 0 || simulation.outMessages?.length !== 0);
|
|
5608
6441
|
const CrossChainLayerC = this.config.artifacts.ton.wrappers.CrossChainLayer;
|
|
5609
6442
|
const crossChainLayer = this.config.TONParams.contractOpener.open(
|
|
5610
|
-
CrossChainLayerC.createFromAddress(
|
|
6443
|
+
CrossChainLayerC.createFromAddress(Address16.parse(this.config.TONParams.crossChainLayerAddress))
|
|
5611
6444
|
);
|
|
5612
6445
|
const fullStateCCL = await crossChainLayer.getFullData();
|
|
5613
6446
|
const feeParams = {
|
|
@@ -6023,7 +6856,7 @@ var TacExplorerClient = class {
|
|
|
6023
6856
|
};
|
|
6024
6857
|
|
|
6025
6858
|
// src/sdk/TACTransactionManager.ts
|
|
6026
|
-
import { Contract as
|
|
6859
|
+
import { Contract as Contract15 } from "ethers";
|
|
6027
6860
|
var TACTransactionManager = class {
|
|
6028
6861
|
constructor(config, operationTracker, logger = new NoopLogger()) {
|
|
6029
6862
|
this.config = config;
|
|
@@ -6091,7 +6924,7 @@ var TACTransactionManager = class {
|
|
|
6091
6924
|
const hasTransactionParams = Object.keys(transactionParams).length > 0;
|
|
6092
6925
|
if (asset.type === "FT" /* FT */) {
|
|
6093
6926
|
this.logger.debug(`Approving FT ${evmAddress} for ${spenderAddress}`);
|
|
6094
|
-
const contract = new
|
|
6927
|
+
const contract = new Contract15(
|
|
6095
6928
|
evmAddress,
|
|
6096
6929
|
this.config.artifacts.tac.compilationArtifacts.IERC20WithDecimals.abi,
|
|
6097
6930
|
this.config.TACParams.provider
|
|
@@ -6100,7 +6933,7 @@ var TACTransactionManager = class {
|
|
|
6100
6933
|
await tx.wait();
|
|
6101
6934
|
} else {
|
|
6102
6935
|
this.logger.debug(`Approving NFT ${evmAddress} for ${spenderAddress}`);
|
|
6103
|
-
const contract = new
|
|
6936
|
+
const contract = new Contract15(
|
|
6104
6937
|
evmAddress,
|
|
6105
6938
|
this.config.artifacts.tac.compilationArtifacts.IERC721.abi,
|
|
6106
6939
|
this.config.TACParams.provider
|
|
@@ -6113,14 +6946,14 @@ var TACTransactionManager = class {
|
|
|
6113
6946
|
async estimateApprovalGas(asset, signer, spenderAddress, transactionParams = {}) {
|
|
6114
6947
|
const evmAddress = await asset.getEVMAddress();
|
|
6115
6948
|
if (asset.type === "FT" /* FT */) {
|
|
6116
|
-
const contract2 = new
|
|
6949
|
+
const contract2 = new Contract15(
|
|
6117
6950
|
evmAddress,
|
|
6118
6951
|
this.config.artifacts.tac.compilationArtifacts.IERC20WithDecimals.abi,
|
|
6119
6952
|
this.config.TACParams.provider
|
|
6120
6953
|
);
|
|
6121
6954
|
return contract2.connect(signer).approve.estimateGas(spenderAddress, asset.rawAmount, transactionParams);
|
|
6122
6955
|
}
|
|
6123
|
-
const contract = new
|
|
6956
|
+
const contract = new Contract15(
|
|
6124
6957
|
evmAddress,
|
|
6125
6958
|
this.config.artifacts.tac.compilationArtifacts.IERC721.abi,
|
|
6126
6959
|
this.config.TACParams.provider
|
|
@@ -6291,7 +7124,7 @@ import {
|
|
|
6291
7124
|
storeOutList,
|
|
6292
7125
|
toNano as toNano3
|
|
6293
7126
|
} from "@ton/ton";
|
|
6294
|
-
import { sign } from "ton-crypto";
|
|
7127
|
+
import { sign as sign2 } from "ton-crypto";
|
|
6295
7128
|
|
|
6296
7129
|
// src/wrappers/HighloadQueryId.ts
|
|
6297
7130
|
var HIGHLOAD_QUERY_ID_BIT_NUMBER_SIZE = 10n;
|
|
@@ -6436,7 +7269,7 @@ var HighloadWalletV3 = class _HighloadWalletV3 {
|
|
|
6436
7269
|
}
|
|
6437
7270
|
const queryId = opts.queryId instanceof HighloadQueryId ? opts.queryId.getQueryId() : opts.queryId;
|
|
6438
7271
|
const messageInner = beginCell9().storeUint(opts.subwalletId, 32).storeRef(messageCell).storeUint(opts.mode, 8).storeUint(queryId, 23).storeUint(opts.createdAt, TIMESTAMP_SIZE).storeUint(opts.timeout, TIMEOUT_SIZE).endCell();
|
|
6439
|
-
const externalMessage = beginCell9().storeBuffer(
|
|
7272
|
+
const externalMessage = beginCell9().storeBuffer(sign2(messageInner.hash(), secretKey)).storeRef(messageInner).endCell();
|
|
6440
7273
|
await provider.external(externalMessage);
|
|
6441
7274
|
return externalMessage.toBoc().toString("base64");
|
|
6442
7275
|
}
|
|
@@ -6698,7 +7531,7 @@ import {
|
|
|
6698
7531
|
WalletContractV4,
|
|
6699
7532
|
WalletContractV5R1
|
|
6700
7533
|
} from "@ton/ton";
|
|
6701
|
-
import { mnemonicToWalletKey } from "ton-crypto";
|
|
7534
|
+
import { mnemonicToWalletKey as mnemonicToWalletKey2 } from "ton-crypto";
|
|
6702
7535
|
|
|
6703
7536
|
// src/sender/RawSender.ts
|
|
6704
7537
|
import { beginCell as beginCell10, external, fromNano as fromNano3, internal as internal2, storeMessage as storeMessage4 } from "@ton/ton";
|
|
@@ -6922,7 +7755,7 @@ var SenderFactory = class {
|
|
|
6922
7755
|
if (!(params.version in wallets)) {
|
|
6923
7756
|
throw unknownWalletError(params.version);
|
|
6924
7757
|
}
|
|
6925
|
-
const keypair = await
|
|
7758
|
+
const keypair = await mnemonicToWalletKey2(params.mnemonic.split(" "));
|
|
6926
7759
|
const config = {
|
|
6927
7760
|
workchain: 0,
|
|
6928
7761
|
publicKey: keypair.publicKey,
|
|
@@ -7605,6 +8438,7 @@ var TonTxFinalizer = class {
|
|
|
7605
8438
|
}
|
|
7606
8439
|
};
|
|
7607
8440
|
export {
|
|
8441
|
+
AA_NETWORKS,
|
|
7608
8442
|
AddressError,
|
|
7609
8443
|
AgnosticProxySDK,
|
|
7610
8444
|
AgnosticStructs_exports as AgnosticStructs,
|
|
@@ -7612,6 +8446,7 @@ export {
|
|
|
7612
8446
|
AssetFeeMode,
|
|
7613
8447
|
AssetType,
|
|
7614
8448
|
AxiosHttpClient,
|
|
8449
|
+
BaseAccountAPI,
|
|
7615
8450
|
BaseContractOpener,
|
|
7616
8451
|
BatchSender,
|
|
7617
8452
|
BitError,
|
|
@@ -7630,6 +8465,7 @@ export {
|
|
|
7630
8465
|
HIGHLOAD_QUERY_ID_INVALID_BIT_NUMBER,
|
|
7631
8466
|
HighloadQueryId,
|
|
7632
8467
|
HighloadWalletV3,
|
|
8468
|
+
HttpRpcClient,
|
|
7633
8469
|
KeyError,
|
|
7634
8470
|
LiteClientOpener,
|
|
7635
8471
|
LiteSequencerClient,
|
|
@@ -7645,6 +8481,7 @@ export {
|
|
|
7645
8481
|
OperationTracker,
|
|
7646
8482
|
OperationType,
|
|
7647
8483
|
Origin,
|
|
8484
|
+
PaymasterAPI,
|
|
7648
8485
|
RetryableContractOpener,
|
|
7649
8486
|
SandboxOpener,
|
|
7650
8487
|
SenderFactory,
|
|
@@ -7658,7 +8495,14 @@ export {
|
|
|
7658
8495
|
TIMESTAMP_SIZE,
|
|
7659
8496
|
TON,
|
|
7660
8497
|
TONTransactionManager,
|
|
8498
|
+
TacAccountABI,
|
|
8499
|
+
TacAccountAPI,
|
|
8500
|
+
TacAccountFactoryABI,
|
|
8501
|
+
TacAccountSdk,
|
|
8502
|
+
TacERC20PaymasterABI,
|
|
8503
|
+
TacERC20PaymasterAPI,
|
|
7661
8504
|
TacExplorerClient,
|
|
8505
|
+
TacPaymasterMode,
|
|
7662
8506
|
TacSdk,
|
|
7663
8507
|
TokenError,
|
|
7664
8508
|
TokenSymbol,
|
|
@@ -7670,14 +8514,20 @@ export {
|
|
|
7670
8514
|
TransactionError,
|
|
7671
8515
|
TransactionTreeDirection,
|
|
7672
8516
|
WalletError,
|
|
8517
|
+
aaSignerFromMnemonic,
|
|
7673
8518
|
allEndpointsFailedError,
|
|
7674
8519
|
blockGasLimitFetchError,
|
|
7675
8520
|
buildJettonOffChainMetadata,
|
|
7676
8521
|
buildJettonOnchainMetadata,
|
|
7677
8522
|
buildNFTOffChainMetadata,
|
|
7678
8523
|
buildNFTOnchainMetadata,
|
|
8524
|
+
buildPermitBinding,
|
|
8525
|
+
buildPermitMessage,
|
|
8526
|
+
buildSignedUserOpWithPermit,
|
|
8527
|
+
buildSignedUserOpWithPermitTonConnect,
|
|
7679
8528
|
createDefaultRetryableOpener,
|
|
7680
8529
|
defaultWaitOptions,
|
|
8530
|
+
ed25519SignerFromSecretKey,
|
|
7681
8531
|
emptyArrayError,
|
|
7682
8532
|
emptyContractError,
|
|
7683
8533
|
emptySettingError,
|
|
@@ -7710,6 +8560,15 @@ export {
|
|
|
7710
8560
|
operationIdRequiredForFinalizationError,
|
|
7711
8561
|
orbsOpener,
|
|
7712
8562
|
orbsOpener4,
|
|
8563
|
+
packModeByte,
|
|
8564
|
+
packPaymasterAndData,
|
|
8565
|
+
packPermit2InnerSignature,
|
|
8566
|
+
packPermitBoundUserOpSignature,
|
|
8567
|
+
packPermitData,
|
|
8568
|
+
packPermitPaymasterData,
|
|
8569
|
+
packRawEd25519Signature,
|
|
8570
|
+
packTonConnectPermit2InnerSignature,
|
|
8571
|
+
packTonConnectUserOpSignature,
|
|
7713
8572
|
prefixError,
|
|
7714
8573
|
printExecutionStagesTable,
|
|
7715
8574
|
profilingFetchError,
|