@dynamic-labs/ton 4.60.0 → 4.61.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +9 -9
- package/src/TonWalletConnector.cjs +1 -1
- package/src/TonWalletConnector.js +1 -1
- package/src/connectors/TonConnectConnector/TonConnectConnector.cjs +709 -0
- package/src/connectors/TonConnectConnector/TonConnectConnector.d.ts +169 -0
- package/src/connectors/TonConnectConnector/TonConnectConnector.js +705 -0
- package/src/connectors/TonConnectConnector/index.d.ts +1 -0
- package/src/consts.d.ts +4 -0
- package/src/index.cjs +11 -5
- package/src/index.d.ts +6 -1
- package/src/index.js +8 -3
- package/src/types.d.ts +61 -1
- package/src/utils/debugLog/debugLog.cjs +55 -0
- package/src/utils/debugLog/debugLog.d.ts +34 -0
- package/src/utils/debugLog/debugLog.js +49 -0
- package/src/utils/debugLog/index.d.ts +1 -0
- package/src/utils/fetchTonWalletConnectors/fetchTonWalletConnectors.cjs +113 -0
- package/src/utils/fetchTonWalletConnectors/fetchTonWalletConnectors.d.ts +41 -0
- package/src/utils/fetchTonWalletConnectors/fetchTonWalletConnectors.js +108 -0
- package/src/utils/fetchTonWalletConnectors/index.d.ts +1 -0
- package/src/utils/index.d.ts +1 -0
- package/src/waas/connector/DynamicWaasTonConnector.d.ts +6 -9
- package/src/wallet/TonWallet/TonWallet.cjs +140 -0
- package/src/wallet/TonWallet/TonWallet.d.ts +65 -0
- package/src/wallet/TonWallet/TonWallet.js +136 -0
- package/src/wallet/TonWallet/index.d.ts +1 -0
- package/src/wallet/WaasTonWallet.cjs +1 -1
- package/src/wallet/WaasTonWallet.js +1 -1
- package/src/wallet/isTonWallet/isTonWallet.cjs +7 -1
- package/src/wallet/isTonWallet/isTonWallet.d.ts +7 -1
- package/src/wallet/isTonWallet/isTonWallet.js +7 -1
- package/src/TonWalletConnectors.cjs +0 -13
- package/src/TonWalletConnectors.d.ts +0 -2
- package/src/TonWalletConnectors.js +0 -9
- package/src/wallet/TonWallet.cjs +0 -109
- package/src/wallet/TonWallet.d.ts +0 -60
- package/src/wallet/TonWallet.js +0 -105
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../_virtual/_tslib.cjs');
|
|
7
|
+
var utils = require('@dynamic-labs/utils');
|
|
8
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
9
|
+
var sdk = require('@tonconnect/sdk');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* TON wallet implementation
|
|
13
|
+
*
|
|
14
|
+
* Provides methods for interacting with TON wallets including:
|
|
15
|
+
* - Sending TON (native currency)
|
|
16
|
+
* - Sending Jettons (tokens)
|
|
17
|
+
* - Signing messages
|
|
18
|
+
* - Getting balances
|
|
19
|
+
*/
|
|
20
|
+
class TonWallet extends walletConnectorCore.Wallet {
|
|
21
|
+
constructor(props) {
|
|
22
|
+
super(props);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Send TON (native currency) to an address
|
|
26
|
+
*
|
|
27
|
+
* @param to - Recipient address
|
|
28
|
+
* @param amount - Amount in TON (will be converted to nanoTON)
|
|
29
|
+
* @param comment - Optional transaction comment
|
|
30
|
+
* @returns Transaction result with hash
|
|
31
|
+
*/
|
|
32
|
+
sendTon(to, amount, comment) {
|
|
33
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
const amountStr = typeof amount === 'number' ? amount.toString() : amount;
|
|
35
|
+
const amountNano = BigInt(Math.floor(parseFloat(amountStr) * 1000000000));
|
|
36
|
+
const hash = yield this.sendBalance({
|
|
37
|
+
amount: amountNano.toString(),
|
|
38
|
+
comment,
|
|
39
|
+
toAddress: to,
|
|
40
|
+
});
|
|
41
|
+
return {
|
|
42
|
+
boc: hash,
|
|
43
|
+
hash: hash || '',
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Send balance (native TON) - implements the base Wallet interface
|
|
49
|
+
*
|
|
50
|
+
* @param options - Send options
|
|
51
|
+
* @returns Transaction hash
|
|
52
|
+
*/
|
|
53
|
+
sendBalance(_a) {
|
|
54
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ amount, comment, toAddress, }) {
|
|
55
|
+
// Keys are ordered alphabetically in the destructuring for linting
|
|
56
|
+
// but we maintain logical order in usage
|
|
57
|
+
const result = yield this._connector.sendTransaction({
|
|
58
|
+
messages: [
|
|
59
|
+
Object.assign({ address: toAddress, amount: amount }, (comment
|
|
60
|
+
? { payload: this._connector.encodeComment(comment) }
|
|
61
|
+
: {})),
|
|
62
|
+
],
|
|
63
|
+
validUntil: Math.floor(Date.now() / 1000) + 300, // 5 minutes from now
|
|
64
|
+
});
|
|
65
|
+
return (result === null || result === void 0 ? void 0 : result.boc) || (result === null || result === void 0 ? void 0 : result.hash);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Send Jetton (token) to an address
|
|
70
|
+
*
|
|
71
|
+
* @param options - Jetton send options
|
|
72
|
+
* @returns Transaction result
|
|
73
|
+
*/
|
|
74
|
+
sendJetton(options) {
|
|
75
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
return this._connector.sendJettonTransaction(options);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Sign a message
|
|
81
|
+
*
|
|
82
|
+
* @param message - Message to sign (string or Uint8Array)
|
|
83
|
+
* @returns Signature
|
|
84
|
+
*/
|
|
85
|
+
signMessage(message) {
|
|
86
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
87
|
+
const messageString = typeof message === 'string' ? message : new TextDecoder().decode(message);
|
|
88
|
+
const signature = yield this._connector.signMessage(messageString);
|
|
89
|
+
if (!signature) {
|
|
90
|
+
throw new utils.DynamicError('Failed to sign message');
|
|
91
|
+
}
|
|
92
|
+
return signature;
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Get balance of an address
|
|
97
|
+
*
|
|
98
|
+
* @param address - Optional address (defaults to current wallet address)
|
|
99
|
+
* @returns Balance in TON as a string
|
|
100
|
+
*/
|
|
101
|
+
getBalance(address) {
|
|
102
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
const targetAddress = address || this.address;
|
|
104
|
+
if (!targetAddress) {
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|
|
107
|
+
return this._connector.getBalance(targetAddress);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Get network details
|
|
112
|
+
*
|
|
113
|
+
* @returns Network information
|
|
114
|
+
*/
|
|
115
|
+
getNetworkDetails() {
|
|
116
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
117
|
+
const network = yield this._connector.getNetwork();
|
|
118
|
+
// Network is returned as a string (chain ID)
|
|
119
|
+
const chainId = network
|
|
120
|
+
? parseInt(network, 10)
|
|
121
|
+
: parseInt(sdk.CHAIN.MAINNET, 10); // Mainnet default
|
|
122
|
+
let name;
|
|
123
|
+
if (chainId === parseInt(sdk.CHAIN.MAINNET, 10)) {
|
|
124
|
+
name = 'mainnet';
|
|
125
|
+
}
|
|
126
|
+
else if (chainId === parseInt(sdk.CHAIN.TESTNET, 10)) {
|
|
127
|
+
name = 'testnet';
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
name = 'unknown';
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
chainId,
|
|
134
|
+
name,
|
|
135
|
+
};
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
exports.TonWallet = TonWallet;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Wallet, WalletProps } from '@dynamic-labs/wallet-connector-core';
|
|
2
|
+
import type { TonConnectConnector } from '../../connectors/TonConnectConnector/TonConnectConnector';
|
|
3
|
+
import type { SendJettonOptions, TonTransactionResult } from '../../types';
|
|
4
|
+
/**
|
|
5
|
+
* TON wallet implementation
|
|
6
|
+
*
|
|
7
|
+
* Provides methods for interacting with TON wallets including:
|
|
8
|
+
* - Sending TON (native currency)
|
|
9
|
+
* - Sending Jettons (tokens)
|
|
10
|
+
* - Signing messages
|
|
11
|
+
* - Getting balances
|
|
12
|
+
*/
|
|
13
|
+
export declare class TonWallet extends Wallet<TonConnectConnector> {
|
|
14
|
+
constructor(props: WalletProps<TonConnectConnector>);
|
|
15
|
+
/**
|
|
16
|
+
* Send TON (native currency) to an address
|
|
17
|
+
*
|
|
18
|
+
* @param to - Recipient address
|
|
19
|
+
* @param amount - Amount in TON (will be converted to nanoTON)
|
|
20
|
+
* @param comment - Optional transaction comment
|
|
21
|
+
* @returns Transaction result with hash
|
|
22
|
+
*/
|
|
23
|
+
sendTon(to: string, amount: string | number, comment?: string): Promise<TonTransactionResult>;
|
|
24
|
+
/**
|
|
25
|
+
* Send balance (native TON) - implements the base Wallet interface
|
|
26
|
+
*
|
|
27
|
+
* @param options - Send options
|
|
28
|
+
* @returns Transaction hash
|
|
29
|
+
*/
|
|
30
|
+
sendBalance({ amount, comment, toAddress, }: {
|
|
31
|
+
amount: string;
|
|
32
|
+
comment?: string;
|
|
33
|
+
toAddress: string;
|
|
34
|
+
}): Promise<string | undefined>;
|
|
35
|
+
/**
|
|
36
|
+
* Send Jetton (token) to an address
|
|
37
|
+
*
|
|
38
|
+
* @param options - Jetton send options
|
|
39
|
+
* @returns Transaction result
|
|
40
|
+
*/
|
|
41
|
+
sendJetton(options: SendJettonOptions): Promise<TonTransactionResult>;
|
|
42
|
+
/**
|
|
43
|
+
* Sign a message
|
|
44
|
+
*
|
|
45
|
+
* @param message - Message to sign (string or Uint8Array)
|
|
46
|
+
* @returns Signature
|
|
47
|
+
*/
|
|
48
|
+
signMessage(message: string | Uint8Array): Promise<string>;
|
|
49
|
+
/**
|
|
50
|
+
* Get balance of an address
|
|
51
|
+
*
|
|
52
|
+
* @param address - Optional address (defaults to current wallet address)
|
|
53
|
+
* @returns Balance in TON as a string
|
|
54
|
+
*/
|
|
55
|
+
getBalance(address?: string): Promise<string | undefined>;
|
|
56
|
+
/**
|
|
57
|
+
* Get network details
|
|
58
|
+
*
|
|
59
|
+
* @returns Network information
|
|
60
|
+
*/
|
|
61
|
+
getNetworkDetails(): Promise<{
|
|
62
|
+
chainId: number;
|
|
63
|
+
name: string;
|
|
64
|
+
}>;
|
|
65
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../_virtual/_tslib.js';
|
|
3
|
+
import { DynamicError } from '@dynamic-labs/utils';
|
|
4
|
+
import { Wallet } from '@dynamic-labs/wallet-connector-core';
|
|
5
|
+
import { CHAIN } from '@tonconnect/sdk';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* TON wallet implementation
|
|
9
|
+
*
|
|
10
|
+
* Provides methods for interacting with TON wallets including:
|
|
11
|
+
* - Sending TON (native currency)
|
|
12
|
+
* - Sending Jettons (tokens)
|
|
13
|
+
* - Signing messages
|
|
14
|
+
* - Getting balances
|
|
15
|
+
*/
|
|
16
|
+
class TonWallet extends Wallet {
|
|
17
|
+
constructor(props) {
|
|
18
|
+
super(props);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Send TON (native currency) to an address
|
|
22
|
+
*
|
|
23
|
+
* @param to - Recipient address
|
|
24
|
+
* @param amount - Amount in TON (will be converted to nanoTON)
|
|
25
|
+
* @param comment - Optional transaction comment
|
|
26
|
+
* @returns Transaction result with hash
|
|
27
|
+
*/
|
|
28
|
+
sendTon(to, amount, comment) {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
const amountStr = typeof amount === 'number' ? amount.toString() : amount;
|
|
31
|
+
const amountNano = BigInt(Math.floor(parseFloat(amountStr) * 1000000000));
|
|
32
|
+
const hash = yield this.sendBalance({
|
|
33
|
+
amount: amountNano.toString(),
|
|
34
|
+
comment,
|
|
35
|
+
toAddress: to,
|
|
36
|
+
});
|
|
37
|
+
return {
|
|
38
|
+
boc: hash,
|
|
39
|
+
hash: hash || '',
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Send balance (native TON) - implements the base Wallet interface
|
|
45
|
+
*
|
|
46
|
+
* @param options - Send options
|
|
47
|
+
* @returns Transaction hash
|
|
48
|
+
*/
|
|
49
|
+
sendBalance(_a) {
|
|
50
|
+
return __awaiter(this, arguments, void 0, function* ({ amount, comment, toAddress, }) {
|
|
51
|
+
// Keys are ordered alphabetically in the destructuring for linting
|
|
52
|
+
// but we maintain logical order in usage
|
|
53
|
+
const result = yield this._connector.sendTransaction({
|
|
54
|
+
messages: [
|
|
55
|
+
Object.assign({ address: toAddress, amount: amount }, (comment
|
|
56
|
+
? { payload: this._connector.encodeComment(comment) }
|
|
57
|
+
: {})),
|
|
58
|
+
],
|
|
59
|
+
validUntil: Math.floor(Date.now() / 1000) + 300, // 5 minutes from now
|
|
60
|
+
});
|
|
61
|
+
return (result === null || result === void 0 ? void 0 : result.boc) || (result === null || result === void 0 ? void 0 : result.hash);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Send Jetton (token) to an address
|
|
66
|
+
*
|
|
67
|
+
* @param options - Jetton send options
|
|
68
|
+
* @returns Transaction result
|
|
69
|
+
*/
|
|
70
|
+
sendJetton(options) {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
return this._connector.sendJettonTransaction(options);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Sign a message
|
|
77
|
+
*
|
|
78
|
+
* @param message - Message to sign (string or Uint8Array)
|
|
79
|
+
* @returns Signature
|
|
80
|
+
*/
|
|
81
|
+
signMessage(message) {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
const messageString = typeof message === 'string' ? message : new TextDecoder().decode(message);
|
|
84
|
+
const signature = yield this._connector.signMessage(messageString);
|
|
85
|
+
if (!signature) {
|
|
86
|
+
throw new DynamicError('Failed to sign message');
|
|
87
|
+
}
|
|
88
|
+
return signature;
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Get balance of an address
|
|
93
|
+
*
|
|
94
|
+
* @param address - Optional address (defaults to current wallet address)
|
|
95
|
+
* @returns Balance in TON as a string
|
|
96
|
+
*/
|
|
97
|
+
getBalance(address) {
|
|
98
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
const targetAddress = address || this.address;
|
|
100
|
+
if (!targetAddress) {
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
return this._connector.getBalance(targetAddress);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Get network details
|
|
108
|
+
*
|
|
109
|
+
* @returns Network information
|
|
110
|
+
*/
|
|
111
|
+
getNetworkDetails() {
|
|
112
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
+
const network = yield this._connector.getNetwork();
|
|
114
|
+
// Network is returned as a string (chain ID)
|
|
115
|
+
const chainId = network
|
|
116
|
+
? parseInt(network, 10)
|
|
117
|
+
: parseInt(CHAIN.MAINNET, 10); // Mainnet default
|
|
118
|
+
let name;
|
|
119
|
+
if (chainId === parseInt(CHAIN.MAINNET, 10)) {
|
|
120
|
+
name = 'mainnet';
|
|
121
|
+
}
|
|
122
|
+
else if (chainId === parseInt(CHAIN.TESTNET, 10)) {
|
|
123
|
+
name = 'testnet';
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
name = 'unknown';
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
chainId,
|
|
130
|
+
name,
|
|
131
|
+
};
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export { TonWallet };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TonWallet } from './TonWallet';
|
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Type guard to check if a wallet is a TON wallet
|
|
8
|
+
*
|
|
9
|
+
* @param wallet - The wallet to check
|
|
10
|
+
* @returns True if the wallet is a TON wallet
|
|
11
|
+
*/
|
|
12
|
+
const isTonWallet = (wallet) => (wallet === null || wallet === void 0 ? void 0 : wallet.chain) === 'TON';
|
|
7
13
|
|
|
8
14
|
exports.isTonWallet = isTonWallet;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import { Wallet } from '@dynamic-labs/wallet-connector-core';
|
|
2
2
|
import { TonWallet } from '../TonWallet';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Type guard to check if a wallet is a TON wallet
|
|
5
|
+
*
|
|
6
|
+
* @param wallet - The wallet to check
|
|
7
|
+
* @returns True if the wallet is a TON wallet
|
|
8
|
+
*/
|
|
9
|
+
export declare const isTonWallet: (wallet: Wallet | null | undefined) => wallet is TonWallet;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Type guard to check if a wallet is a TON wallet
|
|
4
|
+
*
|
|
5
|
+
* @param wallet - The wallet to check
|
|
6
|
+
* @returns True if the wallet is a TON wallet
|
|
7
|
+
*/
|
|
8
|
+
const isTonWallet = (wallet) => (wallet === null || wallet === void 0 ? void 0 : wallet.chain) === 'TON';
|
|
3
9
|
|
|
4
10
|
export { isTonWallet };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
|
-
var DynamicWaasTonConnectors = require('./waas/DynamicWaasTonConnectors.cjs');
|
|
7
|
-
|
|
8
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
-
const TonWalletConnectors = () => [
|
|
10
|
-
...DynamicWaasTonConnectors.DynamicWaasTonConnectors(),
|
|
11
|
-
];
|
|
12
|
-
|
|
13
|
-
exports.TonWalletConnectors = TonWalletConnectors;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
import { DynamicWaasTonConnectors } from './waas/DynamicWaasTonConnectors.js';
|
|
3
|
-
|
|
4
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
|
-
const TonWalletConnectors = () => [
|
|
6
|
-
...DynamicWaasTonConnectors(),
|
|
7
|
-
];
|
|
8
|
-
|
|
9
|
-
export { TonWalletConnectors };
|
package/src/wallet/TonWallet.cjs
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
|
-
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
7
|
-
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
8
|
-
var prepareTonTransfer = require('../utils/prepareTonTransfer/prepareTonTransfer.cjs');
|
|
9
|
-
var prepareJettonTransfer = require('../utils/prepareJettonTransfer/prepareJettonTransfer.cjs');
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Base TonWallet class for TON blockchain wallets.
|
|
13
|
-
* Provides core functionality for interacting with TON wallets.
|
|
14
|
-
*/
|
|
15
|
-
class TonWallet extends walletConnectorCore.Wallet {
|
|
16
|
-
/**
|
|
17
|
-
* Get the TonClient for interacting with the TON blockchain.
|
|
18
|
-
* @param chainId - Optional chain ID to get client for specific network
|
|
19
|
-
* @returns TonClient instance
|
|
20
|
-
*/
|
|
21
|
-
getTonClient(chainId) {
|
|
22
|
-
return this._connector.getTonClient(chainId);
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Generates a TON Connect proof for authentication.
|
|
26
|
-
* @param payload - The payload string to include in the proof
|
|
27
|
-
* @returns Complete TON Connect proof object
|
|
28
|
-
*/
|
|
29
|
-
generateTonConnectProof(payload) {
|
|
30
|
-
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
yield this.sync();
|
|
32
|
-
return this._connector.generateTonConnectProof(payload);
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Signs a message with the wallet.
|
|
37
|
-
* @param message - The message to sign
|
|
38
|
-
* @returns The signature as a string
|
|
39
|
-
*/
|
|
40
|
-
signMessage(message) {
|
|
41
|
-
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
42
|
-
yield this.sync();
|
|
43
|
-
return this._connector.signMessage(message);
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Sends a TON Connect transaction.
|
|
48
|
-
* @param request - The SendTransactionRequest containing messages to send
|
|
49
|
-
* @returns The transaction hash
|
|
50
|
-
*/
|
|
51
|
-
sendTransaction(request) {
|
|
52
|
-
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
yield this.sync();
|
|
54
|
-
return this._connector.sendTransaction(request);
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Sends native TON to a given address.
|
|
59
|
-
* @param amount - The amount in TON (will be converted to nanotons)
|
|
60
|
-
* @param toAddress - The recipient address
|
|
61
|
-
* @returns The transaction hash
|
|
62
|
-
*/
|
|
63
|
-
sendBalance(_a) {
|
|
64
|
-
return _tslib.__awaiter(this, arguments, void 0, function* ({ amount, toAddress, }) {
|
|
65
|
-
yield this.sync();
|
|
66
|
-
const client = this.getTonClient();
|
|
67
|
-
const network = (yield this._connector.getNetwork());
|
|
68
|
-
const request = yield prepareTonTransfer.prepareTonTransfer({
|
|
69
|
-
amount,
|
|
70
|
-
client,
|
|
71
|
-
network,
|
|
72
|
-
recipient: toAddress,
|
|
73
|
-
timeout: 60,
|
|
74
|
-
walletAddress: this.address,
|
|
75
|
-
});
|
|
76
|
-
return this.sendTransaction(request);
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Sends jettons (non-native tokens) to a given address.
|
|
81
|
-
* @param jettonMasterAddress - The jetton master contract address
|
|
82
|
-
* @param recipientAddress - The recipient's main wallet address
|
|
83
|
-
* @param jettonAmount - Amount of jettons in base units (bigint)
|
|
84
|
-
* @param forwardTonAmount - TON amount to forward with notification (bigint)
|
|
85
|
-
* @param forwardPayload - Optional comment/memo
|
|
86
|
-
* @returns The transaction hash
|
|
87
|
-
*/
|
|
88
|
-
sendJetton(_a) {
|
|
89
|
-
return _tslib.__awaiter(this, arguments, void 0, function* ({ jettonMasterAddress, recipientAddress, jettonAmount, forwardTonAmount, forwardPayload, }) {
|
|
90
|
-
yield this.sync();
|
|
91
|
-
const client = this.getTonClient();
|
|
92
|
-
const network = (yield this._connector.getNetwork());
|
|
93
|
-
const request = yield prepareJettonTransfer.prepareJettonTransfer({
|
|
94
|
-
client,
|
|
95
|
-
forwardPayload,
|
|
96
|
-
forwardTonAmount,
|
|
97
|
-
jettonAmount,
|
|
98
|
-
jettonMasterAddress,
|
|
99
|
-
network,
|
|
100
|
-
recipientAddress,
|
|
101
|
-
timeout: 60,
|
|
102
|
-
walletAddress: this.address,
|
|
103
|
-
});
|
|
104
|
-
return this.sendTransaction(request);
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
exports.TonWallet = TonWallet;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { TonClient } from '@ton/ton';
|
|
2
|
-
import { Wallet } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
-
import { TonWalletConnector } from '../TonWalletConnector';
|
|
4
|
-
import { SendTransactionRequest, TonConnectProof } from '../types';
|
|
5
|
-
/**
|
|
6
|
-
* Base TonWallet class for TON blockchain wallets.
|
|
7
|
-
* Provides core functionality for interacting with TON wallets.
|
|
8
|
-
*/
|
|
9
|
-
export declare class TonWallet extends Wallet<TonWalletConnector> {
|
|
10
|
-
/**
|
|
11
|
-
* Get the TonClient for interacting with the TON blockchain.
|
|
12
|
-
* @param chainId - Optional chain ID to get client for specific network
|
|
13
|
-
* @returns TonClient instance
|
|
14
|
-
*/
|
|
15
|
-
getTonClient(chainId?: string): TonClient;
|
|
16
|
-
/**
|
|
17
|
-
* Generates a TON Connect proof for authentication.
|
|
18
|
-
* @param payload - The payload string to include in the proof
|
|
19
|
-
* @returns Complete TON Connect proof object
|
|
20
|
-
*/
|
|
21
|
-
generateTonConnectProof(payload: string): Promise<TonConnectProof>;
|
|
22
|
-
/**
|
|
23
|
-
* Signs a message with the wallet.
|
|
24
|
-
* @param message - The message to sign
|
|
25
|
-
* @returns The signature as a string
|
|
26
|
-
*/
|
|
27
|
-
signMessage(message: string): Promise<string>;
|
|
28
|
-
/**
|
|
29
|
-
* Sends a TON Connect transaction.
|
|
30
|
-
* @param request - The SendTransactionRequest containing messages to send
|
|
31
|
-
* @returns The transaction hash
|
|
32
|
-
*/
|
|
33
|
-
sendTransaction(request: SendTransactionRequest): Promise<string>;
|
|
34
|
-
/**
|
|
35
|
-
* Sends native TON to a given address.
|
|
36
|
-
* @param amount - The amount in TON (will be converted to nanotons)
|
|
37
|
-
* @param toAddress - The recipient address
|
|
38
|
-
* @returns The transaction hash
|
|
39
|
-
*/
|
|
40
|
-
sendBalance({ amount, toAddress, }: {
|
|
41
|
-
amount: string;
|
|
42
|
-
toAddress: string;
|
|
43
|
-
}): Promise<string | undefined>;
|
|
44
|
-
/**
|
|
45
|
-
* Sends jettons (non-native tokens) to a given address.
|
|
46
|
-
* @param jettonMasterAddress - The jetton master contract address
|
|
47
|
-
* @param recipientAddress - The recipient's main wallet address
|
|
48
|
-
* @param jettonAmount - Amount of jettons in base units (bigint)
|
|
49
|
-
* @param forwardTonAmount - TON amount to forward with notification (bigint)
|
|
50
|
-
* @param forwardPayload - Optional comment/memo
|
|
51
|
-
* @returns The transaction hash
|
|
52
|
-
*/
|
|
53
|
-
sendJetton({ jettonMasterAddress, recipientAddress, jettonAmount, forwardTonAmount, forwardPayload, }: {
|
|
54
|
-
jettonMasterAddress: string;
|
|
55
|
-
recipientAddress: string;
|
|
56
|
-
jettonAmount: bigint;
|
|
57
|
-
forwardTonAmount: bigint;
|
|
58
|
-
forwardPayload?: string;
|
|
59
|
-
}): Promise<string>;
|
|
60
|
-
}
|