@anywalletkit/wallet-ton 0.2.4 → 0.3.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/README.md +29 -5
- package/dist/index.cjs +201 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +121 -4
- package/dist/index.d.ts +121 -4
- package/dist/index.js +198 -20
- package/dist/index.js.map +1 -1
- package/package.json +7 -6
package/dist/index.d.cts
CHANGED
|
@@ -218,6 +218,16 @@ declare class UnsafeTransactionError extends SignerError {
|
|
|
218
218
|
readonly code: string;
|
|
219
219
|
constructor(code: string, message: string);
|
|
220
220
|
}
|
|
221
|
+
/**
|
|
222
|
+
* `sign()` refused a 32-byte message: the wallet contract checks a transfer's signature over the
|
|
223
|
+
* 32-byte hash of its signing cell, so a signature over 32 raw bytes may authorise one. TON Connect
|
|
224
|
+
* proofs and signData go through `signTonProof` / `signTonConnectData`; transactions through
|
|
225
|
+
* `signTransaction` / `sendTransaction`, where they are reviewed.
|
|
226
|
+
*/
|
|
227
|
+
declare class MessageIsTransactionError extends SignerError {
|
|
228
|
+
readonly code = "message-is-transaction";
|
|
229
|
+
constructor();
|
|
230
|
+
}
|
|
221
231
|
/** Emulation of the external message failed (non-zero compute exit, aborted, action phase failed); nothing was signed or sent. */
|
|
222
232
|
declare class SimulationError extends Error {
|
|
223
233
|
readonly exitCode: number | undefined;
|
|
@@ -227,12 +237,26 @@ declare class SimulationError extends Error {
|
|
|
227
237
|
aborted?: boolean;
|
|
228
238
|
});
|
|
229
239
|
}
|
|
240
|
+
/**
|
|
241
|
+
* The external message was handed to the network but no definitive answer came back (no response,
|
|
242
|
+
* a timeout, a non-JSON body): it MAY be on chain. Do not sign again (the next seqno would pay
|
|
243
|
+
* twice) — watch `hash`, the body hash `sendTransaction` returns.
|
|
244
|
+
*/
|
|
245
|
+
declare class BroadcastUnknownError extends Error {
|
|
246
|
+
/** Always true: the transaction may be on its way. */
|
|
247
|
+
readonly maybeSent = true;
|
|
248
|
+
/** Hex hash of the signed body. */
|
|
249
|
+
readonly hash: string;
|
|
250
|
+
constructor(hash: string, cause: unknown);
|
|
251
|
+
}
|
|
230
252
|
|
|
231
253
|
/** JSON-RPC over one toncenter v2 endpoint. */
|
|
232
254
|
declare function tonCenterEndpoint(endpoint: TonEndpoint, opts?: {
|
|
233
255
|
fetch?: typeof fetch;
|
|
234
256
|
timeoutMs?: number;
|
|
235
257
|
}): TonRpc;
|
|
258
|
+
/** An endpoint answered with a refusal (`ok: false`): nothing was taken. A thrown fetch, a timeout or a non-JSON body may have been. */
|
|
259
|
+
declare function isAnsweredRefusal(e: unknown): boolean;
|
|
236
260
|
/** One RPC, or a failover RPC walking the configured list (`retries` extra rounds after the first full pass). */
|
|
237
261
|
declare function createTonRpc(config: TonConfig): TonRpc | undefined;
|
|
238
262
|
/** State of a TON account on chain. */
|
|
@@ -482,9 +506,14 @@ interface TonDescribedMessage {
|
|
|
482
506
|
jetton?: TonJettonDetails;
|
|
483
507
|
hasStateInit: boolean;
|
|
484
508
|
bodyBits: number;
|
|
509
|
+
/**
|
|
510
|
+
* Send mode the wallet sends the message with (IGNORE_ERRORS is always added for an external).
|
|
511
|
+
* 128 carries the whole remaining balance, 32 destroys the account when it is left empty.
|
|
512
|
+
*/
|
|
513
|
+
mode?: number;
|
|
485
514
|
}
|
|
486
515
|
/** Problems a TON description is flagged with. */
|
|
487
|
-
type TonWarningCode = 'zero-value' | 'non-bounceable-contract-call' | 'unknown-body' | 'large-forward-amount' | 'testnet-address' | 'mainnet-address' | 'exotic-workchain' | 'extended-actions';
|
|
516
|
+
type TonWarningCode = 'zero-value' | 'non-bounceable-contract-call' | 'unknown-body' | 'large-forward-amount' | 'testnet-address' | 'mainnet-address' | 'exotic-workchain' | 'extended-actions' | 'carries-all-balance' | 'destroys-account';
|
|
488
517
|
/** One flagged problem; `index` is the message it is about. */
|
|
489
518
|
interface TonWarning {
|
|
490
519
|
code: TonWarningCode;
|
|
@@ -574,6 +603,15 @@ declare class WalletAccountReadOnlyTon implements IWalletAccountReadOnly {
|
|
|
574
603
|
*/
|
|
575
604
|
getTokenBalance(token: string): Promise<bigint>;
|
|
576
605
|
protected stateInitOf(src: TonTransaction['stateInit']): StateInit | undefined;
|
|
606
|
+
/**
|
|
607
|
+
* A destination address with the checks every payment gets: workchain 0 or -1, and a friendly
|
|
608
|
+
* address's test-only flag matching the wallet's network. Used for a native message's `to` and a
|
|
609
|
+
* jetton transfer's recipient and response destination (round 3, L8).
|
|
610
|
+
*/
|
|
611
|
+
protected checkedAddress(to: string): {
|
|
612
|
+
address: Address;
|
|
613
|
+
bounceable: boolean;
|
|
614
|
+
};
|
|
577
615
|
protected transactionMessage(tx: TonTransaction): V5R1Message;
|
|
578
616
|
protected jettonTransferMessage(o: TonTransferOptions): Promise<V5R1Message>;
|
|
579
617
|
protected toMessages(tx: TonTransaction | TonTransaction[]): V5R1Message[];
|
|
@@ -617,6 +655,62 @@ declare class WalletAccountReadOnlyTon implements IWalletAccountReadOnly {
|
|
|
617
655
|
verify(message: string | Uint8Array, signature: string): Promise<boolean>;
|
|
618
656
|
}
|
|
619
657
|
|
|
658
|
+
/** What a dApp asks `ton_proof` for: its domain (host), the time of the proof, its nonce. */
|
|
659
|
+
interface TonProofRequest {
|
|
660
|
+
/** The dApp's host as the wallet saw it (`app.example`), never the dApp's own claim. */
|
|
661
|
+
domain: string;
|
|
662
|
+
/** Unix seconds. */
|
|
663
|
+
timestamp: number;
|
|
664
|
+
/** The dApp's `ton_proof` payload. */
|
|
665
|
+
payload: string;
|
|
666
|
+
}
|
|
667
|
+
/** The `proof` object of a TON Connect `ton_proof` reply. */
|
|
668
|
+
interface TonProof {
|
|
669
|
+
timestamp: number;
|
|
670
|
+
domain: {
|
|
671
|
+
lengthBytes: number;
|
|
672
|
+
value: string;
|
|
673
|
+
};
|
|
674
|
+
payload: string;
|
|
675
|
+
/** Base64 ed25519 signature. */
|
|
676
|
+
signature: string;
|
|
677
|
+
}
|
|
678
|
+
/** A `signData` payload. `cell` payloads need schema-aware rendering and are not signed here. */
|
|
679
|
+
type TonSignDataPayload = {
|
|
680
|
+
type: 'text';
|
|
681
|
+
text: string;
|
|
682
|
+
} | {
|
|
683
|
+
type: 'binary';
|
|
684
|
+
bytes: string;
|
|
685
|
+
};
|
|
686
|
+
/** What a dApp asks `signData` for. */
|
|
687
|
+
interface TonSignDataRequest {
|
|
688
|
+
/** The dApp's host as the wallet saw it. */
|
|
689
|
+
domain: string;
|
|
690
|
+
/** Unix seconds. */
|
|
691
|
+
timestamp: number;
|
|
692
|
+
payload: TonSignDataPayload;
|
|
693
|
+
}
|
|
694
|
+
/** The TON Connect `signData` reply. */
|
|
695
|
+
interface TonSignedData {
|
|
696
|
+
/** Base64 ed25519 signature. */
|
|
697
|
+
signature: string;
|
|
698
|
+
/** Raw form (`0:…`) of the address that signed. */
|
|
699
|
+
address: string;
|
|
700
|
+
timestamp: number;
|
|
701
|
+
domain: string;
|
|
702
|
+
payload: TonSignDataPayload;
|
|
703
|
+
}
|
|
704
|
+
/** The address parts the digests bind to. */
|
|
705
|
+
interface TonAddressParts {
|
|
706
|
+
workChain: number;
|
|
707
|
+
hash: Uint8Array;
|
|
708
|
+
}
|
|
709
|
+
/** The 32 bytes a wallet signs for `ton_proof`. */
|
|
710
|
+
declare function tonProofDigest(address: TonAddressParts, request: TonProofRequest): Uint8Array;
|
|
711
|
+
/** The 32 bytes a wallet signs for `signData` (text / binary). */
|
|
712
|
+
declare function tonSignDataDigest(address: TonAddressParts, request: TonSignDataRequest): Uint8Array;
|
|
713
|
+
|
|
620
714
|
/**
|
|
621
715
|
* Signing TON account on Wallet V5R1. It never holds a key: the V5R1 body is
|
|
622
716
|
* signed by `signer.sign(signingCell.hash(), {scheme: 'ed25519', context:
|
|
@@ -642,14 +736,37 @@ declare class WalletAccountTon extends WalletAccountReadOnlyTon implements IWall
|
|
|
642
736
|
static fromPrivateKey(privateKey: Uint8Array, publicKey: Uint8Array, path: string, config?: TonConfig): WalletAccountTon;
|
|
643
737
|
/** Account index for the standard m/44'/607'/i' path. */
|
|
644
738
|
get index(): number | undefined;
|
|
645
|
-
/**
|
|
739
|
+
/**
|
|
740
|
+
* Hex ed25519 signature over the raw message bytes. A 32-byte message — string or bytes — is
|
|
741
|
+
* refused with {@link MessageIsTransactionError}: the wallet contract checks a transfer's
|
|
742
|
+
* signature over the 32-byte hash of its signing cell, so those bytes could be one. Bytes that
|
|
743
|
+
* carry this account's public key are refused as well: one ed25519 key (an external signer) may
|
|
744
|
+
* also be a Solana wallet, and a Solana transaction names its signer's key. TON Connect goes
|
|
745
|
+
* through {@link signTonProof} and {@link signTonConnectData}.
|
|
746
|
+
*/
|
|
646
747
|
sign(message: string | Uint8Array): Promise<string>;
|
|
748
|
+
/**
|
|
749
|
+
* TON Connect `ton_proof` for this wallet's address: the `proof` object of the connect reply. The
|
|
750
|
+
* digest is built here (0xffff ‖ "ton-connect" ‖ …), so no request can turn it into a transfer.
|
|
751
|
+
* `domain` is the host the wallet saw the request come from.
|
|
752
|
+
*/
|
|
753
|
+
signTonProof(request: TonProofRequest): Promise<TonProof>;
|
|
754
|
+
/** TON Connect `signData` (text / binary) for this wallet's address: the reply the dApp gets. */
|
|
755
|
+
signTonConnectData(request: TonSignDataRequest): Promise<TonSignedData>;
|
|
647
756
|
private checkMaxFee;
|
|
648
757
|
/**
|
|
649
758
|
* Checks → seqno → preflight → signed body. The preflight runs on the
|
|
650
759
|
* zero-signed body (ignore_chksig), so nothing is signed before it passes.
|
|
651
760
|
*/
|
|
652
|
-
|
|
761
|
+
/**
|
|
762
|
+
* Refuse send modes that drain the wallet — 128 (the whole remaining balance) and 32 (the account
|
|
763
|
+
* destroyed once empty) — unless `allowDrainingTransactions`. Checked locally, before any seqno or
|
|
764
|
+
* emulation, so it holds with `simulate: false` too (round 3, M11); the emulation check stays.
|
|
765
|
+
*/
|
|
766
|
+
private assertNoDrain;
|
|
767
|
+
/** The send modes of a prebuilt V5R1 body; an unreadable body is left to the emulation and the node. */
|
|
768
|
+
private bodyModes;
|
|
769
|
+
private signMessages;
|
|
653
770
|
private preflight;
|
|
654
771
|
/** Sign without broadcasting. Returns the external-message BODY as base64 BoC (pass it back to sendTransaction as a Cell). */
|
|
655
772
|
signTransaction(tx: TonSendable, options?: WriteOptions): Promise<string>;
|
|
@@ -701,4 +818,4 @@ declare class WalletManagerTon extends WalletManager<WalletAccountTon, TonConfig
|
|
|
701
818
|
getFeeRates(): Promise<FeeRates>;
|
|
702
819
|
}
|
|
703
820
|
|
|
704
|
-
export { CAIP2, DEFAULT_SEND_MODE, DEFAULT_TONAPI, type DecodedBody, type EmulateOptions, type EmulationOutcome, type EmulationSource, type EmulationVerdict, type GetMethodResult, JETTON_TRANSFER_OP, MAINNET_GLOBAL_ID, MAX_ACTIONS, type ParsedV5R1Body, SEND_MODE, SimulationError, TESTNET_GLOBAL_ID, TON_BASE_PATH, TON_MNEMONIC_PATH, type TonAccountState, type TonAccountStatus, TonCenter, type TonConfig, type TonDescribedKind, type TonDescribedMessage, type TonDescription, type TonEmulateConfig, type TonEndpoint, type TonFees, type TonJettonDetails, type TonProvider, type TonReceipt, type TonRisk, type TonRpc, type TonSendable, type TonSimulation, type TonSimulationSource, type TonTransaction, type TonTransferOptions, type TonWarning, type TonWarningCode, UnsafeTransactionError, type V5R1Message, type V5R1SigningParams, type V5R1WalletIdParts, V5R1_CODE_HEX, V5R1_OP, WalletAccountReadOnlyTon, WalletAccountTon, WalletManagerTon, commentCell, createTonRpc as createTonClient, createTonRpc, decodeBody, WalletManagerTon as default, describeMessageRelaxed, describeTransaction, emulateExternal, emulateViaTonapi, installBufferGlobal, parseEmulation, parseTonapiConsequences, parseTonapiRisk, parseTonapiTrace, parseV5R1Body, resolveEmulate, runEmulation, tonCenterEndpoint, v5r1Address, v5r1Code, v5r1ExternalMessage, v5r1PackSigned, v5r1PackUnsigned, v5r1SigningMessage, v5r1StateInit, v5r1WalletId };
|
|
821
|
+
export { BroadcastUnknownError, CAIP2, DEFAULT_SEND_MODE, DEFAULT_TONAPI, type DecodedBody, type EmulateOptions, type EmulationOutcome, type EmulationSource, type EmulationVerdict, type GetMethodResult, JETTON_TRANSFER_OP, MAINNET_GLOBAL_ID, MAX_ACTIONS, MessageIsTransactionError, type ParsedV5R1Body, SEND_MODE, SimulationError, TESTNET_GLOBAL_ID, TON_BASE_PATH, TON_MNEMONIC_PATH, type TonAccountState, type TonAccountStatus, type TonAddressParts, TonCenter, type TonConfig, type TonDescribedKind, type TonDescribedMessage, type TonDescription, type TonEmulateConfig, type TonEndpoint, type TonFees, type TonJettonDetails, type TonProof, type TonProofRequest, type TonProvider, type TonReceipt, type TonRisk, type TonRpc, type TonSendable, type TonSignDataPayload, type TonSignDataRequest, type TonSignedData, type TonSimulation, type TonSimulationSource, type TonTransaction, type TonTransferOptions, type TonWarning, type TonWarningCode, UnsafeTransactionError, type V5R1Message, type V5R1SigningParams, type V5R1WalletIdParts, V5R1_CODE_HEX, V5R1_OP, WalletAccountReadOnlyTon, WalletAccountTon, WalletManagerTon, commentCell, createTonRpc as createTonClient, createTonRpc, decodeBody, WalletManagerTon as default, describeMessageRelaxed, describeTransaction, emulateExternal, emulateViaTonapi, installBufferGlobal, isAnsweredRefusal, parseEmulation, parseTonapiConsequences, parseTonapiRisk, parseTonapiTrace, parseV5R1Body, resolveEmulate, runEmulation, tonCenterEndpoint, tonProofDigest, tonSignDataDigest, v5r1Address, v5r1Code, v5r1ExternalMessage, v5r1PackSigned, v5r1PackUnsigned, v5r1SigningMessage, v5r1StateInit, v5r1WalletId };
|
package/dist/index.d.ts
CHANGED
|
@@ -218,6 +218,16 @@ declare class UnsafeTransactionError extends SignerError {
|
|
|
218
218
|
readonly code: string;
|
|
219
219
|
constructor(code: string, message: string);
|
|
220
220
|
}
|
|
221
|
+
/**
|
|
222
|
+
* `sign()` refused a 32-byte message: the wallet contract checks a transfer's signature over the
|
|
223
|
+
* 32-byte hash of its signing cell, so a signature over 32 raw bytes may authorise one. TON Connect
|
|
224
|
+
* proofs and signData go through `signTonProof` / `signTonConnectData`; transactions through
|
|
225
|
+
* `signTransaction` / `sendTransaction`, where they are reviewed.
|
|
226
|
+
*/
|
|
227
|
+
declare class MessageIsTransactionError extends SignerError {
|
|
228
|
+
readonly code = "message-is-transaction";
|
|
229
|
+
constructor();
|
|
230
|
+
}
|
|
221
231
|
/** Emulation of the external message failed (non-zero compute exit, aborted, action phase failed); nothing was signed or sent. */
|
|
222
232
|
declare class SimulationError extends Error {
|
|
223
233
|
readonly exitCode: number | undefined;
|
|
@@ -227,12 +237,26 @@ declare class SimulationError extends Error {
|
|
|
227
237
|
aborted?: boolean;
|
|
228
238
|
});
|
|
229
239
|
}
|
|
240
|
+
/**
|
|
241
|
+
* The external message was handed to the network but no definitive answer came back (no response,
|
|
242
|
+
* a timeout, a non-JSON body): it MAY be on chain. Do not sign again (the next seqno would pay
|
|
243
|
+
* twice) — watch `hash`, the body hash `sendTransaction` returns.
|
|
244
|
+
*/
|
|
245
|
+
declare class BroadcastUnknownError extends Error {
|
|
246
|
+
/** Always true: the transaction may be on its way. */
|
|
247
|
+
readonly maybeSent = true;
|
|
248
|
+
/** Hex hash of the signed body. */
|
|
249
|
+
readonly hash: string;
|
|
250
|
+
constructor(hash: string, cause: unknown);
|
|
251
|
+
}
|
|
230
252
|
|
|
231
253
|
/** JSON-RPC over one toncenter v2 endpoint. */
|
|
232
254
|
declare function tonCenterEndpoint(endpoint: TonEndpoint, opts?: {
|
|
233
255
|
fetch?: typeof fetch;
|
|
234
256
|
timeoutMs?: number;
|
|
235
257
|
}): TonRpc;
|
|
258
|
+
/** An endpoint answered with a refusal (`ok: false`): nothing was taken. A thrown fetch, a timeout or a non-JSON body may have been. */
|
|
259
|
+
declare function isAnsweredRefusal(e: unknown): boolean;
|
|
236
260
|
/** One RPC, or a failover RPC walking the configured list (`retries` extra rounds after the first full pass). */
|
|
237
261
|
declare function createTonRpc(config: TonConfig): TonRpc | undefined;
|
|
238
262
|
/** State of a TON account on chain. */
|
|
@@ -482,9 +506,14 @@ interface TonDescribedMessage {
|
|
|
482
506
|
jetton?: TonJettonDetails;
|
|
483
507
|
hasStateInit: boolean;
|
|
484
508
|
bodyBits: number;
|
|
509
|
+
/**
|
|
510
|
+
* Send mode the wallet sends the message with (IGNORE_ERRORS is always added for an external).
|
|
511
|
+
* 128 carries the whole remaining balance, 32 destroys the account when it is left empty.
|
|
512
|
+
*/
|
|
513
|
+
mode?: number;
|
|
485
514
|
}
|
|
486
515
|
/** Problems a TON description is flagged with. */
|
|
487
|
-
type TonWarningCode = 'zero-value' | 'non-bounceable-contract-call' | 'unknown-body' | 'large-forward-amount' | 'testnet-address' | 'mainnet-address' | 'exotic-workchain' | 'extended-actions';
|
|
516
|
+
type TonWarningCode = 'zero-value' | 'non-bounceable-contract-call' | 'unknown-body' | 'large-forward-amount' | 'testnet-address' | 'mainnet-address' | 'exotic-workchain' | 'extended-actions' | 'carries-all-balance' | 'destroys-account';
|
|
488
517
|
/** One flagged problem; `index` is the message it is about. */
|
|
489
518
|
interface TonWarning {
|
|
490
519
|
code: TonWarningCode;
|
|
@@ -574,6 +603,15 @@ declare class WalletAccountReadOnlyTon implements IWalletAccountReadOnly {
|
|
|
574
603
|
*/
|
|
575
604
|
getTokenBalance(token: string): Promise<bigint>;
|
|
576
605
|
protected stateInitOf(src: TonTransaction['stateInit']): StateInit | undefined;
|
|
606
|
+
/**
|
|
607
|
+
* A destination address with the checks every payment gets: workchain 0 or -1, and a friendly
|
|
608
|
+
* address's test-only flag matching the wallet's network. Used for a native message's `to` and a
|
|
609
|
+
* jetton transfer's recipient and response destination (round 3, L8).
|
|
610
|
+
*/
|
|
611
|
+
protected checkedAddress(to: string): {
|
|
612
|
+
address: Address;
|
|
613
|
+
bounceable: boolean;
|
|
614
|
+
};
|
|
577
615
|
protected transactionMessage(tx: TonTransaction): V5R1Message;
|
|
578
616
|
protected jettonTransferMessage(o: TonTransferOptions): Promise<V5R1Message>;
|
|
579
617
|
protected toMessages(tx: TonTransaction | TonTransaction[]): V5R1Message[];
|
|
@@ -617,6 +655,62 @@ declare class WalletAccountReadOnlyTon implements IWalletAccountReadOnly {
|
|
|
617
655
|
verify(message: string | Uint8Array, signature: string): Promise<boolean>;
|
|
618
656
|
}
|
|
619
657
|
|
|
658
|
+
/** What a dApp asks `ton_proof` for: its domain (host), the time of the proof, its nonce. */
|
|
659
|
+
interface TonProofRequest {
|
|
660
|
+
/** The dApp's host as the wallet saw it (`app.example`), never the dApp's own claim. */
|
|
661
|
+
domain: string;
|
|
662
|
+
/** Unix seconds. */
|
|
663
|
+
timestamp: number;
|
|
664
|
+
/** The dApp's `ton_proof` payload. */
|
|
665
|
+
payload: string;
|
|
666
|
+
}
|
|
667
|
+
/** The `proof` object of a TON Connect `ton_proof` reply. */
|
|
668
|
+
interface TonProof {
|
|
669
|
+
timestamp: number;
|
|
670
|
+
domain: {
|
|
671
|
+
lengthBytes: number;
|
|
672
|
+
value: string;
|
|
673
|
+
};
|
|
674
|
+
payload: string;
|
|
675
|
+
/** Base64 ed25519 signature. */
|
|
676
|
+
signature: string;
|
|
677
|
+
}
|
|
678
|
+
/** A `signData` payload. `cell` payloads need schema-aware rendering and are not signed here. */
|
|
679
|
+
type TonSignDataPayload = {
|
|
680
|
+
type: 'text';
|
|
681
|
+
text: string;
|
|
682
|
+
} | {
|
|
683
|
+
type: 'binary';
|
|
684
|
+
bytes: string;
|
|
685
|
+
};
|
|
686
|
+
/** What a dApp asks `signData` for. */
|
|
687
|
+
interface TonSignDataRequest {
|
|
688
|
+
/** The dApp's host as the wallet saw it. */
|
|
689
|
+
domain: string;
|
|
690
|
+
/** Unix seconds. */
|
|
691
|
+
timestamp: number;
|
|
692
|
+
payload: TonSignDataPayload;
|
|
693
|
+
}
|
|
694
|
+
/** The TON Connect `signData` reply. */
|
|
695
|
+
interface TonSignedData {
|
|
696
|
+
/** Base64 ed25519 signature. */
|
|
697
|
+
signature: string;
|
|
698
|
+
/** Raw form (`0:…`) of the address that signed. */
|
|
699
|
+
address: string;
|
|
700
|
+
timestamp: number;
|
|
701
|
+
domain: string;
|
|
702
|
+
payload: TonSignDataPayload;
|
|
703
|
+
}
|
|
704
|
+
/** The address parts the digests bind to. */
|
|
705
|
+
interface TonAddressParts {
|
|
706
|
+
workChain: number;
|
|
707
|
+
hash: Uint8Array;
|
|
708
|
+
}
|
|
709
|
+
/** The 32 bytes a wallet signs for `ton_proof`. */
|
|
710
|
+
declare function tonProofDigest(address: TonAddressParts, request: TonProofRequest): Uint8Array;
|
|
711
|
+
/** The 32 bytes a wallet signs for `signData` (text / binary). */
|
|
712
|
+
declare function tonSignDataDigest(address: TonAddressParts, request: TonSignDataRequest): Uint8Array;
|
|
713
|
+
|
|
620
714
|
/**
|
|
621
715
|
* Signing TON account on Wallet V5R1. It never holds a key: the V5R1 body is
|
|
622
716
|
* signed by `signer.sign(signingCell.hash(), {scheme: 'ed25519', context:
|
|
@@ -642,14 +736,37 @@ declare class WalletAccountTon extends WalletAccountReadOnlyTon implements IWall
|
|
|
642
736
|
static fromPrivateKey(privateKey: Uint8Array, publicKey: Uint8Array, path: string, config?: TonConfig): WalletAccountTon;
|
|
643
737
|
/** Account index for the standard m/44'/607'/i' path. */
|
|
644
738
|
get index(): number | undefined;
|
|
645
|
-
/**
|
|
739
|
+
/**
|
|
740
|
+
* Hex ed25519 signature over the raw message bytes. A 32-byte message — string or bytes — is
|
|
741
|
+
* refused with {@link MessageIsTransactionError}: the wallet contract checks a transfer's
|
|
742
|
+
* signature over the 32-byte hash of its signing cell, so those bytes could be one. Bytes that
|
|
743
|
+
* carry this account's public key are refused as well: one ed25519 key (an external signer) may
|
|
744
|
+
* also be a Solana wallet, and a Solana transaction names its signer's key. TON Connect goes
|
|
745
|
+
* through {@link signTonProof} and {@link signTonConnectData}.
|
|
746
|
+
*/
|
|
646
747
|
sign(message: string | Uint8Array): Promise<string>;
|
|
748
|
+
/**
|
|
749
|
+
* TON Connect `ton_proof` for this wallet's address: the `proof` object of the connect reply. The
|
|
750
|
+
* digest is built here (0xffff ‖ "ton-connect" ‖ …), so no request can turn it into a transfer.
|
|
751
|
+
* `domain` is the host the wallet saw the request come from.
|
|
752
|
+
*/
|
|
753
|
+
signTonProof(request: TonProofRequest): Promise<TonProof>;
|
|
754
|
+
/** TON Connect `signData` (text / binary) for this wallet's address: the reply the dApp gets. */
|
|
755
|
+
signTonConnectData(request: TonSignDataRequest): Promise<TonSignedData>;
|
|
647
756
|
private checkMaxFee;
|
|
648
757
|
/**
|
|
649
758
|
* Checks → seqno → preflight → signed body. The preflight runs on the
|
|
650
759
|
* zero-signed body (ignore_chksig), so nothing is signed before it passes.
|
|
651
760
|
*/
|
|
652
|
-
|
|
761
|
+
/**
|
|
762
|
+
* Refuse send modes that drain the wallet — 128 (the whole remaining balance) and 32 (the account
|
|
763
|
+
* destroyed once empty) — unless `allowDrainingTransactions`. Checked locally, before any seqno or
|
|
764
|
+
* emulation, so it holds with `simulate: false` too (round 3, M11); the emulation check stays.
|
|
765
|
+
*/
|
|
766
|
+
private assertNoDrain;
|
|
767
|
+
/** The send modes of a prebuilt V5R1 body; an unreadable body is left to the emulation and the node. */
|
|
768
|
+
private bodyModes;
|
|
769
|
+
private signMessages;
|
|
653
770
|
private preflight;
|
|
654
771
|
/** Sign without broadcasting. Returns the external-message BODY as base64 BoC (pass it back to sendTransaction as a Cell). */
|
|
655
772
|
signTransaction(tx: TonSendable, options?: WriteOptions): Promise<string>;
|
|
@@ -701,4 +818,4 @@ declare class WalletManagerTon extends WalletManager<WalletAccountTon, TonConfig
|
|
|
701
818
|
getFeeRates(): Promise<FeeRates>;
|
|
702
819
|
}
|
|
703
820
|
|
|
704
|
-
export { CAIP2, DEFAULT_SEND_MODE, DEFAULT_TONAPI, type DecodedBody, type EmulateOptions, type EmulationOutcome, type EmulationSource, type EmulationVerdict, type GetMethodResult, JETTON_TRANSFER_OP, MAINNET_GLOBAL_ID, MAX_ACTIONS, type ParsedV5R1Body, SEND_MODE, SimulationError, TESTNET_GLOBAL_ID, TON_BASE_PATH, TON_MNEMONIC_PATH, type TonAccountState, type TonAccountStatus, TonCenter, type TonConfig, type TonDescribedKind, type TonDescribedMessage, type TonDescription, type TonEmulateConfig, type TonEndpoint, type TonFees, type TonJettonDetails, type TonProvider, type TonReceipt, type TonRisk, type TonRpc, type TonSendable, type TonSimulation, type TonSimulationSource, type TonTransaction, type TonTransferOptions, type TonWarning, type TonWarningCode, UnsafeTransactionError, type V5R1Message, type V5R1SigningParams, type V5R1WalletIdParts, V5R1_CODE_HEX, V5R1_OP, WalletAccountReadOnlyTon, WalletAccountTon, WalletManagerTon, commentCell, createTonRpc as createTonClient, createTonRpc, decodeBody, WalletManagerTon as default, describeMessageRelaxed, describeTransaction, emulateExternal, emulateViaTonapi, installBufferGlobal, parseEmulation, parseTonapiConsequences, parseTonapiRisk, parseTonapiTrace, parseV5R1Body, resolveEmulate, runEmulation, tonCenterEndpoint, v5r1Address, v5r1Code, v5r1ExternalMessage, v5r1PackSigned, v5r1PackUnsigned, v5r1SigningMessage, v5r1StateInit, v5r1WalletId };
|
|
821
|
+
export { BroadcastUnknownError, CAIP2, DEFAULT_SEND_MODE, DEFAULT_TONAPI, type DecodedBody, type EmulateOptions, type EmulationOutcome, type EmulationSource, type EmulationVerdict, type GetMethodResult, JETTON_TRANSFER_OP, MAINNET_GLOBAL_ID, MAX_ACTIONS, MessageIsTransactionError, type ParsedV5R1Body, SEND_MODE, SimulationError, TESTNET_GLOBAL_ID, TON_BASE_PATH, TON_MNEMONIC_PATH, type TonAccountState, type TonAccountStatus, type TonAddressParts, TonCenter, type TonConfig, type TonDescribedKind, type TonDescribedMessage, type TonDescription, type TonEmulateConfig, type TonEndpoint, type TonFees, type TonJettonDetails, type TonProof, type TonProofRequest, type TonProvider, type TonReceipt, type TonRisk, type TonRpc, type TonSendable, type TonSignDataPayload, type TonSignDataRequest, type TonSignedData, type TonSimulation, type TonSimulationSource, type TonTransaction, type TonTransferOptions, type TonWarning, type TonWarningCode, UnsafeTransactionError, type V5R1Message, type V5R1SigningParams, type V5R1WalletIdParts, V5R1_CODE_HEX, V5R1_OP, WalletAccountReadOnlyTon, WalletAccountTon, WalletManagerTon, commentCell, createTonRpc as createTonClient, createTonRpc, decodeBody, WalletManagerTon as default, describeMessageRelaxed, describeTransaction, emulateExternal, emulateViaTonapi, installBufferGlobal, isAnsweredRefusal, parseEmulation, parseTonapiConsequences, parseTonapiRisk, parseTonapiTrace, parseV5R1Body, resolveEmulate, runEmulation, tonCenterEndpoint, tonProofDigest, tonSignDataDigest, v5r1Address, v5r1Code, v5r1ExternalMessage, v5r1PackSigned, v5r1PackUnsigned, v5r1SigningMessage, v5r1StateInit, v5r1WalletId };
|