@tonconnect/sdk
Advanced tools
Comparing version 0.0.31 to 0.0.32
import { TonConnectError } from "../ton-connect.error"; | ||
/** | ||
* Thrown when passed DappMetadata is in incorrect format. | ||
*/ | ||
export declare class DappMetadataError extends TonConnectError { | ||
constructor(...args: ConstructorParameters<typeof TonConnectError>); | ||
} |
@@ -5,2 +5,5 @@ "use strict"; | ||
const ton_connect_error_1 = require("../ton-connect.error"); | ||
/** | ||
* Thrown when passed DappMetadata is in incorrect format. | ||
*/ | ||
class DappMetadataError extends ton_connect_error_1.TonConnectError { | ||
@@ -7,0 +10,0 @@ constructor(...args) { |
import { TonConnectError } from "../../../ton-connect.error"; | ||
/** | ||
* Thrown when user rejects the action in the wallet. | ||
*/ | ||
export declare class UserRejectsError extends TonConnectError { | ||
constructor(...args: ConstructorParameters<typeof TonConnectError>); | ||
} |
@@ -5,2 +5,5 @@ "use strict"; | ||
const ton_connect_error_1 = require("../../../ton-connect.error"); | ||
/** | ||
* Thrown when user rejects the action in the wallet. | ||
*/ | ||
class UserRejectsError extends ton_connect_error_1.TonConnectError { | ||
@@ -7,0 +10,0 @@ constructor(...args) { |
import { TonConnectError } from "../../ton-connect.error"; | ||
/** | ||
* Thrown when request to the wallet contains errors. | ||
*/ | ||
export declare class BadRequestError extends TonConnectError { | ||
constructor(...args: ConstructorParameters<typeof TonConnectError>); | ||
} |
@@ -5,2 +5,5 @@ "use strict"; | ||
const ton_connect_error_1 = require("../../ton-connect.error"); | ||
/** | ||
* Thrown when request to the wallet contains errors. | ||
*/ | ||
class BadRequestError extends ton_connect_error_1.TonConnectError { | ||
@@ -7,0 +10,0 @@ constructor(...args) { |
import { TonConnectError } from "../../ton-connect.error"; | ||
/** | ||
* Thrown when app tries to send rpc request to the injected wallet while not connected. | ||
*/ | ||
export declare class UnknownAppError extends TonConnectError { | ||
constructor(...args: ConstructorParameters<typeof TonConnectError>); | ||
} |
@@ -5,2 +5,5 @@ "use strict"; | ||
const ton_connect_error_1 = require("../../ton-connect.error"); | ||
/** | ||
* Thrown when app tries to send rpc request to the injected wallet while not connected. | ||
*/ | ||
class UnknownAppError extends ton_connect_error_1.TonConnectError { | ||
@@ -7,0 +10,0 @@ constructor(...args) { |
import { TonConnectError } from "../ton-connect.error"; | ||
/** | ||
* Thrown when `Storage` was not specified in the `DappMetadata` and default `localStorage` was not detected in the environment. | ||
*/ | ||
export declare class LocalstorageNotFoundError extends TonConnectError { | ||
constructor(...args: ConstructorParameters<typeof TonConnectError>); | ||
} |
@@ -5,2 +5,5 @@ "use strict"; | ||
const ton_connect_error_1 = require("../ton-connect.error"); | ||
/** | ||
* Thrown when `Storage` was not specified in the `DappMetadata` and default `localStorage` was not detected in the environment. | ||
*/ | ||
class LocalstorageNotFoundError extends ton_connect_error_1.TonConnectError { | ||
@@ -7,0 +10,0 @@ constructor(...args) { |
@@ -0,3 +1,6 @@ | ||
/** | ||
* Base class for TonConnect errors. You can check if the error was triggered by the @tonconnect/sdk using `err instanceof TonConnectError`. | ||
*/ | ||
export declare class TonConnectError extends Error { | ||
constructor(...args: ConstructorParameters<typeof Error>); | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TonConnectError = void 0; | ||
/** | ||
* Base class for TonConnect errors. You can check if the error was triggered by the @tonconnect/sdk using `err instanceof TonConnectError`. | ||
*/ | ||
class TonConnectError extends Error { | ||
@@ -5,0 +8,0 @@ constructor(...args) { |
import { TonConnectError } from "./ton-connect.error"; | ||
/** | ||
* Unhanded unknown error. | ||
*/ | ||
export declare class UnknownError extends TonConnectError { | ||
constructor(...args: ConstructorParameters<typeof TonConnectError>); | ||
} |
@@ -5,2 +5,5 @@ "use strict"; | ||
const ton_connect_error_1 = require("./ton-connect.error"); | ||
/** | ||
* Unhanded unknown error. | ||
*/ | ||
class UnknownError extends ton_connect_error_1.TonConnectError { | ||
@@ -7,0 +10,0 @@ constructor(...args) { |
import { TonConnectError } from "../ton-connect.error"; | ||
/** | ||
* Thrown when wallet connection called but wallet already connected. To avoid the error, disconnect the wallet before doing a new connection. | ||
*/ | ||
export declare class WalletAlreadyConnectedError extends TonConnectError { | ||
constructor(...args: ConstructorParameters<typeof TonConnectError>); | ||
} |
@@ -5,2 +5,5 @@ "use strict"; | ||
const ton_connect_error_1 = require("../ton-connect.error"); | ||
/** | ||
* Thrown when wallet connection called but wallet already connected. To avoid the error, disconnect the wallet before doing a new connection. | ||
*/ | ||
class WalletAlreadyConnectedError extends ton_connect_error_1.TonConnectError { | ||
@@ -7,0 +10,0 @@ constructor(...args) { |
import { TonConnectError } from "../ton-connect.error"; | ||
/** | ||
* Thrown when send transaction or other protocol methods called while wallet is not connected. | ||
*/ | ||
export declare class WalletNotConnectedError extends TonConnectError { | ||
constructor(...args: ConstructorParameters<typeof TonConnectError>); | ||
} |
@@ -5,2 +5,5 @@ "use strict"; | ||
const ton_connect_error_1 = require("../ton-connect.error"); | ||
/** | ||
* Thrown when send transaction or other protocol methods called while wallet is not connected. | ||
*/ | ||
class WalletNotConnectedError extends ton_connect_error_1.TonConnectError { | ||
@@ -7,0 +10,0 @@ constructor(...args) { |
import { TonConnectError } from "../ton-connect.error"; | ||
/** | ||
* Thrown when there is an attempt to connect to the injected wallet while it is not exists in the webpage. | ||
*/ | ||
export declare class WalletNotInjectedError extends TonConnectError { | ||
constructor(...args: ConstructorParameters<typeof TonConnectError>); | ||
} |
@@ -5,2 +5,5 @@ "use strict"; | ||
const ton_connect_error_1 = require("../ton-connect.error"); | ||
/** | ||
* Thrown when there is an attempt to connect to the injected wallet while it is not exists in the webpage. | ||
*/ | ||
class WalletNotInjectedError extends ton_connect_error_1.TonConnectError { | ||
@@ -7,0 +10,0 @@ constructor(...args) { |
import { TonConnectError } from "../ton-connect.error"; | ||
/** | ||
* Thrown when an error occurred while fetching the wallets list. | ||
*/ | ||
export declare class FetchWalletsError extends TonConnectError { | ||
constructor(...args: ConstructorParameters<typeof TonConnectError>); | ||
} |
@@ -5,2 +5,5 @@ "use strict"; | ||
const ton_connect_error_1 = require("../ton-connect.error"); | ||
/** | ||
* Thrown when an error occurred while fetching the wallets list. | ||
*/ | ||
class FetchWalletsError extends ton_connect_error_1.TonConnectError { | ||
@@ -7,0 +10,0 @@ constructor(...args) { |
export interface DappMetadata { | ||
/** | ||
* Dapp name. Might be simple, will not be used as identifier. | ||
* @default `document.title` if exists, 'Unknown dapp' overwise | ||
*/ | ||
name: string; | ||
/** | ||
* URL to the dapp icon. Must be PNG, ICO, ... . SVG icons are not supported. | ||
* @default best quality favicon declared via <link> in the document or '' if there are no any icons in the document. | ||
*/ | ||
icon: string; | ||
/** | ||
* Dapp URL. Will be used as the dapp identifier. Will be used to open the dapp after click to its icon in the wallet. | ||
* It is recommended to pass url without closing slash, e.g. 'https://mydapp.com' instead of 'https://mydapp.com/'. | ||
* @default `window.location.origin` if exists, otherwise (if not explicitly specified) an error will be thrown. | ||
*/ | ||
url: string; | ||
} |
export * from './wallet'; | ||
export * from './methods'; | ||
export { DappMetadata } from './dapp/dapp-metadata'; | ||
export { DappSettings } from './dapp/dapp-settings'; | ||
export { TonConnectOptions } from './ton-connect-options'; |
export interface ConnectAdditionalRequest { | ||
/** | ||
* Payload for ton_proof | ||
*/ | ||
tonProof: string; | ||
} |
export interface SendTransactionRequest { | ||
/** | ||
* Sending transaction deadline in unix epoch seconds. | ||
*/ | ||
valid_until: number; | ||
/** | ||
* Messages to send: min is 1, max is 4. | ||
*/ | ||
messages: { | ||
/** | ||
* Receiver's address. | ||
*/ | ||
address: string; | ||
/** | ||
* Amount to send in nanoTon. | ||
*/ | ||
amount: string; | ||
/** | ||
* Contract specific data to add to the transaction. | ||
*/ | ||
initState?: string; | ||
/** | ||
* Contract specific data to add to the transaction. | ||
*/ | ||
payload?: string; | ||
}[]; | ||
} |
export interface SendTransactionResponse { | ||
/** | ||
* Signed boc | ||
*/ | ||
boc: string; | ||
} |
import { CHAIN } from '@tonconnect/protocol'; | ||
export interface Account { | ||
/** | ||
* User's address in "hex" format: "<wc>:<hex>". | ||
*/ | ||
address: string; | ||
/** | ||
* User's selected chain. | ||
*/ | ||
chain: CHAIN; | ||
} |
export type { Account } from './account'; | ||
export type { Wallet } from './wallet'; | ||
export type { WalletConnectionSource } from './wallet-connection-source'; | ||
export type { WalletConnectionSource, WalletConnectionSourceHTTP, WalletConnectionSourceJS } from './wallet-connection-source'; | ||
export { WalletInfo, WalletInfoInjected, WalletInfoRemote, isWalletInfoInjected } from './wallet-info'; |
export declare type WalletConnectionSource = WalletConnectionSourceHTTP | WalletConnectionSourceJS; | ||
export interface WalletConnectionSourceHTTP { | ||
/** | ||
* Base part of the wallet universal url. The link should support [Ton Connect parameters]{@link https://github.com/ton-connect/docs/blob/main/bridge.md#universal-link}. | ||
*/ | ||
universalLink: string; | ||
/** | ||
* Url of the wallet's implementation of the [HTTP bridge]{@link https://github.com/ton-connect/docs/blob/main/bridge.md#http-bridge}. | ||
*/ | ||
bridgeUrl: string; | ||
} | ||
export interface WalletConnectionSourceJS { | ||
/** | ||
* If the wallet handles JS Bridge connection, specifies the binding for the bridge object accessible through window. Example: the key "tonkeeper" means the bridge can be accessed as window.tonkeeper. | ||
*/ | ||
jsBridgeKey: string; | ||
} | ||
export declare function isWalletConnectionSourceJS(value: WalletConnectionSource): value is WalletConnectionSourceJS; |
export interface WalletInfoBase { | ||
/** | ||
* Name of the wallet. | ||
*/ | ||
name: string; | ||
/** | ||
* Url to the icon of the wallet. Resolution 288×288px. On non-transparent background, without rounded corners. PNG format. | ||
*/ | ||
imageUrl: string; | ||
/** | ||
* Will be used in the protocol later. | ||
*/ | ||
tondns?: string; | ||
/** | ||
* Info or landing page of your wallet. May be useful for TON newcomers. | ||
*/ | ||
aboutUrl: string; | ||
} | ||
export interface WalletInfoRemote extends WalletInfoBase { | ||
/** | ||
* Base part of the wallet universal url. The link should support [Ton Connect parameters]{@link https://github.com/ton-connect/docs/blob/main/bridge.md#universal-link}. | ||
*/ | ||
universalLink: string; | ||
/** | ||
* Url of the wallet's implementation of the [HTTP bridge]{@link https://github.com/ton-connect/docs/blob/main/bridge.md#http-bridge}. | ||
*/ | ||
bridgeUrl: string; | ||
} | ||
export interface WalletInfoInjected extends WalletInfoBase { | ||
/** | ||
* If the wallet handles JS Bridge connection, specifies the binding for the bridge object accessible through window. Example: the key "tonkeeper" means the bridge can be accessed as window.tonkeeper. | ||
*/ | ||
jsBridgeKey: string; | ||
/** | ||
* Indicates if the wallet currently is injected to the webpage. | ||
*/ | ||
injected: boolean; | ||
/** | ||
* Indicates if the dapp is opened inside this wallet's browser. | ||
*/ | ||
embedded: boolean; | ||
@@ -15,0 +42,0 @@ } |
import { DeviceInfo, TonProofItemReply } from '@tonconnect/protocol'; | ||
import { Account } from ".."; | ||
export interface Wallet { | ||
/** | ||
* Information about user's wallet's device. | ||
*/ | ||
device: DeviceInfo; | ||
/** | ||
* Provider type: http bridge or injected js. | ||
*/ | ||
provider: 'http' | 'injected'; | ||
/** | ||
* Selected account. | ||
*/ | ||
account: Account; | ||
/** | ||
* Response for connect items request. | ||
*/ | ||
connectItems?: { | ||
@@ -8,0 +20,0 @@ tonProof?: TonProofItemReply; |
@@ -0,5 +1,21 @@ | ||
/** | ||
* Imitation of the localStorage. | ||
*/ | ||
export interface IStorage { | ||
/** | ||
* Saves the `value` to the storage. Value can be accessed later by the `key`. Implementation may use backend as a storage due to the fact that the function returns a promise. | ||
* @param key key to access to the value later. | ||
* @param value value to save. | ||
*/ | ||
setItem(key: string, value: string): Promise<void>; | ||
/** | ||
* Reads the `value` from the storage. Implementation may use backend as a storage due to the fact that the function returns a promise. | ||
* @param key key to access the value. | ||
*/ | ||
getItem(key: string): Promise<string | null>; | ||
/** | ||
* Removes the `value` from the storage. Implementation may use backend as a storage due to the fact that the function returns a promise. | ||
* @param key key to access the value. | ||
*/ | ||
removeItem(key: string): Promise<void>; | ||
} |
import { TonConnectError } from "./errors/ton-connect.error"; | ||
import { Account, DappMetadata, Wallet, WalletConnectionSource, WalletInfo } from "./models"; | ||
import { Account, Wallet, WalletConnectionSource, WalletInfo } from "./models"; | ||
import { SendTransactionRequest, SendTransactionResponse } from "./models/methods"; | ||
import { ConnectAdditionalRequest } from "./models/methods/connect/connect-additional-request"; | ||
import { TonConnectOptions } from "./models/ton-connect-options"; | ||
import { WalletConnectionSourceJS } from "./models/wallet/wallet-connection-source"; | ||
import { IStorage } from "./storage/models/storage.interface"; | ||
import { ITonConnect } from "./ton-connect.interface"; | ||
@@ -29,6 +29,3 @@ export declare class TonConnect implements ITonConnect { | ||
private set wallet(value); | ||
constructor(options?: { | ||
dappMetedata?: Partial<DappMetadata>; | ||
storage?: IStorage; | ||
}); | ||
constructor(options?: TonConnectOptions); | ||
/** | ||
@@ -35,0 +32,0 @@ * Returns available wallets list. |
@@ -35,6 +35,6 @@ "use strict"; | ||
this.dappSettings = { | ||
metadata: (0, options_1.mergeOptions)(options === null || options === void 0 ? void 0 : options.dappMetedata, (0, web_api_1.getWebPageMetadata)()), | ||
dappMetedata: (0, options_1.mergeOptions)(options === null || options === void 0 ? void 0 : options.dappMetedata, (0, web_api_1.getWebPageMetadata)()), | ||
storage: (options === null || options === void 0 ? void 0 : options.storage) || new default_storage_1.DefaultStorage() | ||
}; | ||
if (!this.dappSettings.metadata.url) { | ||
if (!this.dappSettings.dappMetedata.url) { | ||
throw new dapp_metadata_error_1.DappMetadataError('Dapp url must be specified if window.location.origin is undefined.'); | ||
@@ -214,3 +214,3 @@ } | ||
const webPageMetadata = (0, web_api_1.getWebPageMetadata)(); | ||
const metadata = (0, options_1.mergeOptions)(this.dappSettings.metadata, webPageMetadata); | ||
const metadata = (0, options_1.mergeOptions)(this.dappSettings.dappMetedata, webPageMetadata); | ||
const items = [ | ||
@@ -217,0 +217,0 @@ { |
{ | ||
"name": "@tonconnect/sdk", | ||
"version": "0.0.31", | ||
"version": "0.0.32", | ||
"scripts": { | ||
@@ -31,3 +31,3 @@ "build": "npx rimraf lib && ttsc", | ||
"node-fetch": "^2.6.7", | ||
"@tonconnect/protocol": "^0.0.18" | ||
"@tonconnect/protocol": "^0.0.19" | ||
}, | ||
@@ -46,3 +46,6 @@ "files": [ | ||
"typescript-transform-paths": "^3.3.1" | ||
}, | ||
"typedoc": { | ||
"entryPoint": "./src/index.ts" | ||
} | ||
} |
@@ -9,3 +9,4 @@ # TON Connect SDK | ||
## Get started | ||
# Get started | ||
## Install package | ||
`npm i @tonconnect/sdk` | ||
@@ -49,3 +50,3 @@ | ||
injected?: boolean; // true if this wallet is injected to the webpage | ||
embedded?: boolean; // true if dapp is opened inside this wallet's browser | ||
embedded?: boolean; // true if the dapp is opened inside this wallet's browser | ||
}[] | ||
@@ -52,0 +53,0 @@ */ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
107820
2101
115
+ Added@tonconnect/protocol@0.0.19(transitive)
- Removed@tonconnect/protocol@0.0.18(transitive)
Updated@tonconnect/protocol@^0.0.19