@tonconnect/sdk 0.0.41 → 0.0.43

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.
@@ -1,6 +1,15 @@
1
+ import { ReturnStrategy } from '@tonconnect/protocol';
1
2
  export interface ConnectAdditionalRequest {
2
3
  /**
3
4
  * Payload for ton_proof
4
5
  */
5
- tonProof: string;
6
+ tonProof?: string;
7
+ /**
8
+ * @default 'back'
9
+ * Return strategy for deeplinks when the user accepts or declines the request.
10
+ * - `'back'` means return to the app which initialized deeplink jump (e.g. browser, native app, ...),
11
+ * - `'none'` means no jumps after user action;
12
+ * - a URL: wallet will open this URL after completing the user's action. Note, that you shouldn't pass your app's URL if it is a webpage. This option should be used for native apps to work around possible OS-specific issues with `'back'` option.
13
+ */
14
+ return?: ReturnStrategy;
6
15
  }
@@ -1,2 +1,3 @@
1
1
  export { SendTransactionRequest } from './send-transaction-request';
2
2
  export { SendTransactionResponse } from './send-transaction-response';
3
+ export { SendTransactionOptions } from './send-transaction-options';
@@ -0,0 +1,11 @@
1
+ import { ReturnStrategy } from '@tonconnect/protocol';
2
+ export interface SendTransactionOptions {
3
+ /**
4
+ * @default 'back'
5
+ * Return strategy for deeplinks when the user accepts or declines the request.
6
+ * - `'back'` means return to the app which initialized deeplink jump (e.g. browser, native app, ...),
7
+ * - `'none'` means no jumps after user action;
8
+ * - a URL: wallet will open this URL after completing the user's action. Note, that you shouldn't pass your app's URL if it is a webpage. This option should be used for native apps to work around possible OS-specific issues with `'back'` option.
9
+ */
10
+ return: ReturnStrategy;
11
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,11 +1,11 @@
1
- import { SendTransactionRpcRequest, SendTransactionRpcResponseError, SendTransactionRpcResponseSuccess } from '@tonconnect/protocol';
1
+ import { ReturnStrategy, SendTransactionRpcRequest, SendTransactionRpcResponseError, SendTransactionRpcResponseSuccess } from '@tonconnect/protocol';
2
2
  import { SendTransactionRequest, SendTransactionResponse } from "../models/methods";
3
3
  import { RpcParser } from "./rpc-parser";
4
4
  import { WithoutId } from "../utils/types";
5
5
  declare class SendTransactionParser extends RpcParser<'sendTransaction'> {
6
6
  convertToRpcRequest(request: Omit<SendTransactionRequest, 'validUntil'> & {
7
7
  valid_until: number;
8
- }): WithoutId<SendTransactionRpcRequest>;
8
+ }, returnStrategy: ReturnStrategy): WithoutId<SendTransactionRpcRequest>;
9
9
  parseAndThrowError(response: WithoutId<SendTransactionRpcResponseError>): never;
10
10
  convertFromRpcResponse(rpcResponse: WithoutId<SendTransactionRpcResponseSuccess>): SendTransactionResponse;
11
11
  }
@@ -12,10 +12,11 @@ const sendTransactionErrors = {
12
12
  [protocol_1.SEND_TRANSACTION_ERROR_CODES.UNKNOWN_APP_ERROR]: errors_1.UnknownAppError
13
13
  };
14
14
  class SendTransactionParser extends rpc_parser_1.RpcParser {
15
- convertToRpcRequest(request) {
15
+ convertToRpcRequest(request, returnStrategy) {
16
16
  return {
17
17
  method: 'sendTransaction',
18
- params: [JSON.stringify(request)]
18
+ params: [JSON.stringify(request)],
19
+ return: returnStrategy
19
20
  };
20
21
  }
21
22
  parseAndThrowError(response) {
@@ -160,7 +160,7 @@ class BridgeProvider {
160
160
  const url = new URL(this.walletConnectionSource.universalLink);
161
161
  url.searchParams.append('v', protocol.version.toString());
162
162
  url.searchParams.append('id', this.session.sessionCrypto.sessionId);
163
- url.searchParams.append('r', protocol_1.Base64.encode(JSON.stringify(message), true));
163
+ url.searchParams.append('r', JSON.stringify(message));
164
164
  return url.toString();
165
165
  }
166
166
  }
@@ -5,6 +5,7 @@ import { ConnectAdditionalRequest } from "./models/methods/connect/connect-addit
5
5
  import { TonConnectOptions } from "./models/ton-connect-options";
6
6
  import { WalletConnectionSourceJS } from "./models/wallet/wallet-connection-source";
7
7
  import { ITonConnect } from "./ton-connect.interface";
8
+ import { SendTransactionOptions } from "./models/methods/send-transaction/send-transaction-options";
8
9
  export declare class TonConnect implements ITonConnect {
9
10
  private readonly walletsList;
10
11
  private readonly dappSettings;
@@ -52,10 +53,11 @@ export declare class TonConnect implements ITonConnect {
52
53
  /**
53
54
  * Asks connected wallet to sign and send the transaction.
54
55
  * @param transaction transaction to send.
56
+ * @param options request options
55
57
  * @returns signed transaction boc that allows you to find the transaction in the blockchain.
56
58
  * If user rejects transaction, method will throw the corresponding error.
57
59
  */
58
- sendTransaction(transaction: SendTransactionRequest): Promise<SendTransactionResponse>;
60
+ sendTransaction(transaction: SendTransactionRequest, options: SendTransactionOptions): Promise<SendTransactionResponse>;
59
61
  /**
60
62
  * Disconnect form thw connected wallet and drop current session.
61
63
  */
@@ -4,6 +4,7 @@ import { SendTransactionRequest, SendTransactionResponse } from "./models/method
4
4
  import { ConnectAdditionalRequest } from "./models/methods/connect/connect-additional-request";
5
5
  import { WalletInfo } from "./models/wallet/wallet-info";
6
6
  import { WalletConnectionSourceJS } from "./models/wallet/wallet-connection-source";
7
+ import { SendTransactionOptions } from "./models/methods/send-transaction/send-transaction-options";
7
8
  export interface ITonConnect {
8
9
  /**
9
10
  * Shows if the wallet is connected right now.
@@ -46,8 +47,9 @@ export interface ITonConnect {
46
47
  /**
47
48
  * Asks connected wallet to sign and send the transaction.
48
49
  * @param transaction transaction to send.
50
+ * @param options request options
49
51
  * @returns signed transaction boc that allows you to find the transaction in the blockchain.
50
52
  * If user rejects transaction, method will throw the corresponding error.
51
53
  */
52
- sendTransaction(transaction: SendTransactionRequest): Promise<SendTransactionResponse>;
54
+ sendTransaction(transaction: SendTransactionRequest, options: SendTransactionOptions): Promise<SendTransactionResponse>;
53
55
  }
@@ -140,15 +140,16 @@ class TonConnect {
140
140
  /**
141
141
  * Asks connected wallet to sign and send the transaction.
142
142
  * @param transaction transaction to send.
143
+ * @param options request options
143
144
  * @returns signed transaction boc that allows you to find the transaction in the blockchain.
144
145
  * If user rejects transaction, method will throw the corresponding error.
145
146
  */
146
- sendTransaction(transaction) {
147
+ sendTransaction(transaction, options) {
147
148
  return __awaiter(this, void 0, void 0, function* () {
148
149
  this.checkConnection();
149
150
  this.checkFeatureSupport('SendTransaction');
150
151
  const { validUntil } = transaction, tx = __rest(transaction, ["validUntil"]);
151
- const response = yield this.provider.sendRequest(send_transaction_parser_1.sendTransactionParser.convertToRpcRequest(Object.assign(Object.assign({}, tx), { valid_until: validUntil })));
152
+ const response = yield this.provider.sendRequest(send_transaction_parser_1.sendTransactionParser.convertToRpcRequest(Object.assign(Object.assign({}, tx), { valid_until: validUntil }), (options === null || options === void 0 ? void 0 : options.return) || 'back'));
152
153
  if (send_transaction_parser_1.sendTransactionParser.isError(response)) {
153
154
  return send_transaction_parser_1.sendTransactionParser.parseAndThrowError(response);
154
155
  }
@@ -241,7 +242,7 @@ class TonConnect {
241
242
  name: 'ton_addr'
242
243
  }
243
244
  ];
244
- if (request) {
245
+ if (request === null || request === void 0 ? void 0 : request.tonProof) {
245
246
  items.push({
246
247
  name: 'ton_proof',
247
248
  payload: request.tonProof
@@ -249,7 +250,8 @@ class TonConnect {
249
250
  }
250
251
  return {
251
252
  manifestUrl: this.dappSettings.manifestUrl,
252
- items
253
+ items,
254
+ return: (request === null || request === void 0 ? void 0 : request.return) || 'back'
253
255
  };
254
256
  }
255
257
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tonconnect/sdk",
3
- "version": "0.0.41",
3
+ "version": "0.0.43",
4
4
  "scripts": {
5
5
  "build": "npx rimraf lib && ttsc && npx rimraf dist && webpack --mode development",
6
6
  "build:production": "npx rimraf lib && ttsc --sourceMap false && npx rimraf dist && webpack --mode production"
@@ -28,7 +28,7 @@
28
28
  "tweetnacl": "^1.0.3",
29
29
  "eventsource": "^2.0.2",
30
30
  "node-fetch": "^2.6.7",
31
- "@tonconnect/protocol": "^0.0.22"
31
+ "@tonconnect/protocol": "^0.0.24"
32
32
  },
33
33
  "files": [
34
34
  "lib",