| 7 |
| #include <cstdint> |
| 8 | #include <exception> |
| 9 | #include <functional> |
| 10 | #include <iostream> |
| 11 | #include <map> |
| 12 | #include <memory> |
| 13 | #include <mutex> |
| 14 | #include <optional> |
| 15 | #include <stdexcept> |
| 16 | #include <streambuf> |
| 17 | #include <type_traits> |
| 18 | #include <variant> |
| 19 | #include <vector> |
| 20 |
| 21 | #include "wallet_engine_scaffolding.hpp" |
| 22 |
| 23 | #ifndef UNIFFI_CPP_RUST_STREAM |
| 24 | #define UNIFFI_CPP_RUST_STREAM |
| 25 | namespace uniffi { |
| 26 | struct RustStreamBuffer: std::basic_streambuf<char> { |
| 27 | RustStreamBuffer(RustBuffer *buf) { |
| 28 | char* data = reinterpret_cast<char*>(buf->data); |
| 29 | this->setg(data, data, data + buf->len); |
| 30 | this->setp(data, data + buf->capacity); |
| 31 | } |
| 32 | ~RustStreamBuffer() = default; |
| 33 |
| 34 | private: |
| 35 | RustStreamBuffer() = delete; |
| 36 | RustStreamBuffer(const RustStreamBuffer &) = delete; |
| 37 | RustStreamBuffer(RustStreamBuffer &&) = delete; |
| 38 |
| 39 | RustStreamBuffer &operator=(const RustStreamBuffer &) = delete; |
| 40 | RustStreamBuffer &operator=(RustStreamBuffer &&) = delete; |
| 41 | }; |
| 42 |
| 43 | struct RustStream: std::basic_iostream<char> { |
| 44 | RustStream(RustBuffer *buf): |
| 45 | std::basic_iostream<char>(&streambuf), streambuf(RustStreamBuffer(buf)) { } |
| 46 |
| 47 | template <typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>> |
| 48 | RustStream &operator>>(T &val) { |
| 49 | read(reinterpret_cast<char *>(&val), sizeof(T)); |
| 50 |
| 51 | if (std::endian::native != std::endian::big) { |
| 52 | auto bytes = reinterpret_cast<char *>(&val); |
| 53 |
| 54 | std::reverse(bytes, bytes + sizeof(T)); |
| 55 | } |
| 56 |
| 57 | return *this; |
| 58 | } |
| 59 |
| 60 | template <typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>> |
| 61 | RustStream &operator<<(T val) { |
| 62 | if (std::endian::native != std::endian::big) { |
| 63 | auto bytes = reinterpret_cast<char *>(&val); |
| 64 |
| 65 | std::reverse(bytes, bytes + sizeof(T)); |
| 66 | } |
| 67 |
| 68 | write(reinterpret_cast<char *>(&val), sizeof(T)); |
| 69 |
| 70 | return *this; |
| 71 | } |
| 72 | private: |
| 73 | RustStreamBuffer streambuf; |
| 74 | }; |
| 75 |
| 76 | } |
| 77 | #endif |
| 78 |
| 79 | namespace wallet_engine { |
| 80 | struct TonConnectDerivedSession; |
| 81 | struct TonConnectSession; |
| 82 | struct WalletClient; |
| 83 | struct WalletHttpHost; |
| 84 | struct WalletLifecycle; |
| 85 | struct WalletPlatformHost; |
| 86 | struct WalletStatuslessHost; |
| 87 | struct AccountSnapshot; |
| 88 | struct ActivityCursor; |
| 89 | struct ActivityItem; |
| 90 | struct ActivityList; |
| 91 | struct CreateEncryptedCommentRequest; |
| 92 | struct CreateWalletRequest; |
| 93 | struct CreatedWallet; |
| 94 | struct DecryptCommentRequest; |
| 95 | struct DomainError; |
| 96 | struct EncryptedCommentRecipientRequest; |
| 97 | struct HttpHeader; |
| 98 | struct HttpRequest; |
| 99 | struct HttpRequestId; |
| 100 | struct HttpResponse; |
| 101 | struct ImportWalletRequest; |
| 102 | struct JournalCompareExchange; |
| 103 | struct JournalCompareExchangeResult; |
| 104 | struct JournalKey; |
| 105 | struct JournalRecord; |
| 106 | struct NftCollectionDescriptor; |
| 107 | struct NftItem; |
| 108 | struct NftList; |
| 109 | struct NftTransferIntent; |
| 110 | struct NftTransferPreviewRequest; |
| 111 | struct NftTransferRequest; |
| 112 | struct ParsedTonTransferLink; |
| 113 | struct PrepareKeyRotationRequest; |
| 114 | struct PrepareNftTransferRequest; |
| 115 | struct PrepareTransferRequest; |
| 116 | struct PreparedKeyRotation; |
| 117 | struct PreparedTransfer; |
| 118 | struct ProtectedSecretRead; |
| 119 | struct ProtectedSecretRef; |
| 120 | struct ProtectedSecretStore; |
| 121 | struct ProviderConfig; |
| 122 | struct RecoveryPhrase; |
| 123 | struct ResolutionInfo; |
| 124 | struct ResourceState; |
| 125 | struct SendBocRequest; |
| 126 | struct SendEmulation; |
| 127 | struct SendEmulationAction; |
| 128 | struct SendEmulationTransaction; |
| 129 | struct SendIntent; |
| 130 | struct SendMessage; |
| 131 | struct SendPreview; |
| 132 | struct SendPreviewRequest; |
| 133 | struct SendRequest; |
| 134 | struct SendResult; |
| 135 | struct SendSnapshot; |
| 136 | struct SignMessagePreview; |
| 137 | struct SignMessageRequest; |
| 138 | struct SignMessageResult; |
| 139 | struct TonAddressInfo; |
| 140 | struct TonConnectAccountInfo; |
| 141 | struct TonConnectConnectPrompt; |
| 142 | struct TonConnectDerivedRequest; |
| 143 | struct TonConnectDerivedSessionRequest; |
| 144 | struct TonConnectDevice; |
| 145 | struct TonConnectManifest; |
| 146 | struct TonConnectPreparedPost; |
| 147 | struct TonConnectProofReply; |
| 148 | struct TonConnectProofSignRequest; |
| 149 | struct TonConnectProofSignature; |
| 150 | struct TonConnectSessionConfig; |
| 151 | struct TonConnectSignDataRequest; |
| 152 | struct TonConnectSignDataSignRequest; |
| 153 | struct TonConnectSignedData; |
| 154 | struct WalletClientConfig; |
| 155 | struct WalletDescriptor; |
| 156 | struct WalletSnapshot; |
| 157 | struct WalletUpdate; |
| 158 | enum class AccountStatus; |
| 159 | enum class ActivityDirection; |
| 160 | enum class ActivityStatus; |
| 161 | enum class ErrorCategory; |
| 162 | enum class ErrorCode; |
| 163 | struct HttpHostError; |
| 164 | enum class HttpHostErrorKind; |
| 165 | enum class HttpMethod; |
| 166 | struct JournalHostError; |
| 167 | enum class JournalHostErrorKind; |
| 168 | enum class KeyRotationMessageKind; |
| 169 | enum class MnemonicScheme; |
| 170 | enum class Network; |
| 171 | struct NftTransferFunding; |
| 172 | struct NftTransferPayload; |
| 173 | enum class PendingReason; |
| 174 | struct ProtectedSecretHostError; |
| 175 | enum class ProtectedSecretHostErrorKind; |
| 176 | enum class ResourcePhase; |
| 177 | enum class RetryAdvice; |
| 178 | enum class SecretAccessReason; |
| 179 | struct SendAmount; |
| 180 | struct SendExpiration; |
| 181 | struct SendMessageBody; |
| 182 | enum class SendPhase; |
| 183 | struct StatuslessHostError; |
| 184 | enum class StatuslessHostErrorKind; |
| 185 | struct TonAddressError; |
| 186 | struct TonAddressFormat; |
| 187 | enum class TonConnectConnectErrorCode; |
| 188 | enum class TonConnectDevicePlatform; |
| 189 | struct TonConnectIncomingRequest; |
| 190 | enum class TonConnectRpcErrorCode; |
| 191 | struct TonConnectSessionError; |
| 192 | enum class TonConnectSessionPhase; |
| 193 | struct TonConnectSignDataPayload; |
| 194 | struct TonTransferAsset; |
| 195 | struct TonTransferLinkError; |
| 196 | struct TonTransferPayload; |
| 197 | struct WalletClientError; |
| 198 | struct WalletLifecycleError; |
| 199 | enum class WalletOperationOutcome; |
| 200 | typedef std::string Base64Hash; |
| 201 | typedef std::string Boc; |
| 202 | typedef std::string NonEmptyString; |
| 203 | typedef std::string TonAddressString; |
| 204 | typedef std::string UnsignedDecimalString; |
| 205 |
| 206 |
| 207 | /** |
| 208 | * The lifecycle state of a TON account. |
| 209 | */ |
| 210 | enum class AccountStatus: int32_t { |
| 211 | /** |
| 212 | * No account exists at the address. |
| 213 | */ |
| 214 | kNonexistent = 1, |
| 215 | /** |
| 216 | * The account exists but its contract state is not initialized. |
| 217 | */ |
| 218 | kUninitialized = 2, |
| 219 | /** |
| 220 | * The account contract is active. |
| 221 | */ |
| 222 | kActive = 3, |
| 223 | /** |
| 224 | * The account contract is frozen. |
| 225 | */ |
| 226 | kFrozen = 4, |
| 227 | /** |
| 228 | * The provider returned an unrecognized account state. |
| 229 | */ |
| 230 | kUnknown = 5 |
| 231 | }; |
| 232 |
| 233 |
| 234 | /** |
| 235 | * The terminal result of a wallet client operation. |
| 236 | */ |
| 237 | enum class WalletOperationOutcome: int32_t { |
| 238 | /** |
| 239 | * All requested resources completed successfully. |
| 240 | */ |
| 241 | kCompleted = 1, |
| 242 | /** |
| 243 | * Some refresh resources succeeded and some failed. |
| 244 | */ |
| 245 | kPartiallyCompleted = 2, |
| 246 | /** |
| 247 | * The requested operation failed. |
| 248 | */ |
| 249 | kFailed = 3, |
| 250 | /** |
| 251 | * The host or caller cancelled the operation. |
| 252 | */ |
| 253 | kCancelled = 4, |
| 254 | /** |
| 255 | * A newer operation replaced this operation before publication completed. |
| 256 | */ |
| 257 | kSuperseded = 5, |
| 258 | /** |
| 259 | * Preconditions did not permit work, so the client made no request. |
| 260 | */ |
| 261 | kSkipped = 6 |
| 262 | }; |
| 263 |
| 264 |
| 265 | /** |
| 266 | * An HTTP method that the host must execute. |
| 267 | */ |
| 268 | enum class HttpMethod: int32_t { |
| 269 | /** |
| 270 | * An HTTP GET request. |
| 271 | */ |
| 272 | kGet = 1, |
| 273 | /** |
| 274 | * An HTTP POST request. |
| 275 | */ |
| 276 | kPost = 2 |
| 277 | }; |
| 278 |
| 279 |
| 280 | /** |
| 281 | * Classifies a failure reported by the HTTP host. |
| 282 | */ |
| 283 | enum class HttpHostErrorKind: int32_t { |
| 284 | /** |
| 285 | * No network connection is available. |
| 286 | */ |
| 287 | kOffline = 1, |
| 288 | /** |
| 289 | * The request exceeded a host timeout. |
| 290 | */ |
| 291 | kTimeout = 2, |
| 292 | /** |
| 293 | * An established connection ended before completion. |
| 294 | */ |
| 295 | kConnectionLost = 3, |
| 296 | /** |
| 297 | * DNS resolution failed. |
| 298 | */ |
| 299 | kDns = 4, |
| 300 | /** |
| 301 | * TLS negotiation or certificate validation failed. |
| 302 | */ |
| 303 | kTls = 5, |
| 304 | /** |
| 305 | * The request violated a host security policy. |
| 306 | */ |
| 307 | kPolicyViolation = 6, |
| 308 | /** |
| 309 | * The response exceeded a limit imposed by the host. |
| 310 | */ |
| 311 | kResponseTooLarge = 7, |
| 312 | /** |
| 313 | * The host cancelled the request. |
| 314 | */ |
| 315 | kCancelled = 8, |
| 316 | /** |
| 317 | * The failure does not match another kind. |
| 318 | */ |
| 319 | kOther = 9 |
| 320 | }; |
| 321 |
| 322 |
| 323 | /** |
| 324 | * Classifies a protected-storage failure reported by the host. |
| 325 | */ |
| 326 | enum class ProtectedSecretHostErrorKind: int32_t { |
| 327 | /** |
| 328 | * No secret exists for the reference. |
| 329 | */ |
| 330 | kNotFound = 1, |
| 331 | /** |
| 332 | * User or device authentication failed. |
| 333 | */ |
| 334 | kAuthenticationFailed = 2, |
| 335 | /** |
| 336 | * The user or host cancelled the operation. |
| 337 | */ |
| 338 | kCancelled = 3, |
| 339 | /** |
| 340 | * Protected storage is temporarily unavailable. |
| 341 | */ |
| 342 | kUnavailable = 4, |
| 343 | /** |
| 344 | * The request violates a platform security policy. |
| 345 | */ |
| 346 | kPolicyViolation = 5, |
| 347 | /** |
| 348 | * The failure does not match another kind. |
| 349 | */ |
| 350 | kOther = 6 |
| 351 | }; |
| 352 |
| 353 | namespace uniffi { |
| 354 | struct FfiConverterTonAddressFormat; |
| 355 | } // namespace uniffi |
| 356 |
| 357 | /** |
| 358 | * Selects a raw representation or a user-friendly representation with flags. |
| 359 | */ |
| 360 | struct TonAddressFormat { |
| 361 | friend uniffi::FfiConverterTonAddressFormat; |
| 362 | /** |
| 363 | * `workchain:64-hex` without display or network flags. |
| 364 | */ |
| 365 | struct kRaw { |
| 366 | }; |
| 367 | /** |
| 368 | * TEP-2 user-friendly Base64 with a checksum and display flags. |
| 369 | */ |
| 370 | struct kUserFriendly { |
| 371 | /** |
| 372 | * Whether senders should use a bounceable internal message. |
| 373 | */ |
| 374 | bool bounceable; |
| 375 | /** |
| 376 | * Whether mainnet applications must reject the address. |
| 377 | */ |
| 378 | bool testnet; |
| 379 | }; |
| 380 | TonAddressFormat(kRaw variant): variant(variant) {} |
| 381 | TonAddressFormat(kUserFriendly variant): variant(variant) {} |
| 382 |
| 383 | TonAddressFormat(const TonAddressFormat &other): variant(other.variant) {} |
| 384 | TonAddressFormat(TonAddressFormat &&other): variant(std::move(other.variant)) {} |
| 385 |
| 386 | TonAddressFormat &operator=(const TonAddressFormat &other) { |
| 387 | variant = other.variant; |
| 388 | return *this; |
| 389 | } |
| 390 |
| 391 | TonAddressFormat &operator=(TonAddressFormat &&other) { |
| 392 | variant = std::move(other.variant); |
| 393 | return *this; |
| 394 | } |
| 395 |
| 396 | /** |
| 397 | * Returns the variant of this enum |
| 398 | */ |
| 399 | const std::variant<kRaw, kUserFriendly> &get_variant() const { |
| 400 | return variant; |
| 401 | } |
| 402 |
| 403 | private: |
| 404 | std::variant<kRaw, kUserFriendly> variant; |
| 405 |
| 406 | TonAddressFormat(); |
| 407 | }; |
| 408 |
| 409 |
| 410 | /** |
| 411 | * TON Connect RPC error code returned for an unsupported request. |
| 412 | */ |
| 413 | enum class TonConnectRpcErrorCode: int32_t { |
| 414 | /** |
| 415 | * Unexpected wallet-side failure. |
| 416 | */ |
| 417 | kUnknown = 1, |
| 418 | /** |
| 419 | * Malformed request. |
| 420 | */ |
| 421 | kBadRequest = 2, |
| 422 | /** |
| 423 | * Unknown or revoked application session. |
| 424 | */ |
| 425 | kUnknownApp = 3, |
| 426 | /** |
| 427 | * User declined the request. |
| 428 | */ |
| 429 | kUserDeclined = 4, |
| 430 | /** |
| 431 | * Wallet does not implement the method or shape. |
| 432 | */ |
| 433 | kMethodNotSupported = 5 |
| 434 | }; |
| 435 |
| 436 |
| 437 | /** |
| 438 | * An opaque reference to recovery words in host protected storage. |
| 439 | */ |
| 440 | struct ProtectedSecretRef { |
| 441 | /** |
| 442 | * The host storage key. The value does not contain secret bytes. |
| 443 | */ |
| 444 | std::string value; |
| 445 | }; |
| 446 |
| 447 |
| 448 | /** |
| 449 | * Correlation identity generated by Rust. Hosts can use it to bind their |
| 450 | * native cancellation bookkeeping, but must not assign semantic meaning to |
| 451 | * the numeric value. |
| 452 | */ |
| 453 | struct HttpRequestId { |
| 454 | /** |
| 455 | * An opaque numeric value allocated by this client instance. |
| 456 | */ |
| 457 | uint64_t value; |
| 458 | }; |
| 459 |
| 460 |
| 461 | /** |
| 462 | * One HTTP header name and value. |
| 463 | */ |
| 464 | struct HttpHeader { |
| 465 | /** |
| 466 | * The header name. |
| 467 | */ |
| 468 | std::string name; |
| 469 | /** |
| 470 | * The header value. |
| 471 | */ |
| 472 | std::string value; |
| 473 | }; |
| 474 |
| 475 |
| 476 | /** |
| 477 | * Selects how the signed key-rotation request will reach Wallet rev00. |
| 478 | */ |
| 479 | enum class KeyRotationMessageKind: int32_t { |
| 480 | /** |
| 481 | * Complete incoming external message for direct provider submission. |
| 482 | */ |
| 483 | kExternal = 1, |
| 484 | /** |
| 485 | * Complete owner-signed internal message for a gas-paying relayer. |
| 486 | */ |
| 487 | kInternal = 2 |
| 488 | }; |
| 489 |
| 490 |
| 491 | /** |
| 492 | * A deliberately one-shot presentation value, not wallet state. |
| 493 | * |
| 494 | * The UI must discard this value as soon as the recovery-phrase screen is |
| 495 | * dismissed. Neither `WalletDescriptor` nor `WalletSnapshot` contains it. |
| 496 | * |
| 497 | * A newly created wallet has a 12-word phrase; the phrase becomes 24 words |
| 498 | * when the wallet's key is rotated. |
| 499 | */ |
| 500 | struct RecoveryPhrase { |
| 501 | /** |
| 502 | * The recovery words in order, separated by one ASCII space. |
| 503 | * |
| 504 | * Keeping the phrase in one allocation avoids separately allocated |
| 505 | * secret strings at the FFI boundary. Split it only while presenting |
| 506 | * individual words, then release those temporary views. |
| 507 | */ |
| 508 | std::string phrase; |
| 509 | }; |
| 510 |
| 511 |
| 512 | /** |
| 513 | * Runtime platform advertised as the TypeScript protocol's `DeviceInfo.platform`. |
| 514 | * |
| 515 | * This is deliberately different from wallets-list platforms such as `ios`, |
| 516 | * `macos`, or `chrome`, which describe installation targets rather than the |
| 517 | * runtime that produced a connect event. |
| 518 | */ |
| 519 | enum class TonConnectDevicePlatform: int32_t { |
| 520 | /** |
| 521 | * iPhone application. |
| 522 | */ |
| 523 | kIphone = 1, |
| 524 | /** |
| 525 | * iPad application. |
| 526 | */ |
| 527 | kIpad = 2, |
| 528 | /** |
| 529 | * Android application. |
| 530 | */ |
| 531 | kAndroid = 3, |
| 532 | /** |
| 533 | * Windows application. |
| 534 | */ |
| 535 | kWindows = 4, |
| 536 | /** |
| 537 | * macOS application. |
| 538 | */ |
| 539 | kMac = 5, |
| 540 | /** |
| 541 | * Linux application. |
| 542 | */ |
| 543 | kLinux = 6, |
| 544 | /** |
| 545 | * Browser application or extension. |
| 546 | */ |
| 547 | kBrowser = 7 |
| 548 | }; |
| 549 |
| 550 |
| 551 | /** |
| 552 | * The value flow direction for one activity item. |
| 553 | */ |
| 554 | enum class ActivityDirection: int32_t { |
| 555 | /** |
| 556 | * Value left the wallet. |
| 557 | */ |
| 558 | kSent = 1, |
| 559 | /** |
| 560 | * Value entered the wallet. |
| 561 | */ |
| 562 | kReceived = 2 |
| 563 | }; |
| 564 |
| 565 |
| 566 | /** |
| 567 | * The public phase of the current or last send workflow. |
| 568 | */ |
| 569 | enum class SendPhase: int32_t { |
| 570 | /** |
| 571 | * No send has started. |
| 572 | */ |
| 573 | kIdle = 1, |
| 574 | /** |
| 575 | * The engine validates the request, journal, and chain state. |
| 576 | */ |
| 577 | kValidating = 2, |
| 578 | /** |
| 579 | * The host authorizes protected-secret access. |
| 580 | */ |
| 581 | kAuthorizing = 3, |
| 582 | /** |
| 583 | * Rust constructs and signs the transfer. |
| 584 | */ |
| 585 | kPreparing = 4, |
| 586 | /** |
| 587 | * The host writes a durable journal record. |
| 588 | */ |
| 589 | kPersisting = 5, |
| 590 | /** |
| 591 | * The exact signed BOC is durable and ready for submission. |
| 592 | */ |
| 593 | kReadyToSubmit = 6, |
| 594 | /** |
| 595 | * The HTTP host submits the signed BOC. |
| 596 | */ |
| 597 | kSubmitting = 7, |
| 598 | /** |
| 599 | * Submission can have succeeded, but the engine has no definite response. |
| 600 | */ |
| 601 | kSubmissionUnknown = 8, |
| 602 | /** |
| 603 | * The provider accepted the signed BOC. |
| 604 | */ |
| 605 | kSubmitted = 9, |
| 606 | /** |
| 607 | * A signed internal message was durably returned for submission by a relayer. |
| 608 | */ |
| 609 | kHandedOff = 10, |
| 610 | /** |
| 611 | * The external message was found as the inbound message of an on-chain transaction. |
| 612 | */ |
| 613 | kConfirmed = 11, |
| 614 | /** |
| 615 | * Another external message consumed the sequence number reserved by this send. |
| 616 | */ |
| 617 | kReplaced = 12, |
| 618 | /** |
| 619 | * The signed sequence number was consumed, but available provider evidence |
| 620 | * cannot identify which competing internal request executed. |
| 621 | */ |
| 622 | kSequenceNumberConsumed = 13, |
| 623 | /** |
| 624 | * Provider time passed the signed validity window and the message was not observed. |
| 625 | */ |
| 626 | kExpired = 14, |
| 627 | /** |
| 628 | * An explicit same-sequence-number resend replaced this journal attempt. |
| 629 | */ |
| 630 | kSuperseded = 15, |
| 631 | /** |
| 632 | * The send failed before an ambiguous submission result. |
| 633 | */ |
| 634 | kFailed = 16, |
| 635 | /** |
| 636 | * The send was cancelled before its durable commit boundary. |
| 637 | */ |
| 638 | kCancelled = 17 |
| 639 | }; |
| 640 |
| 641 |
| 642 | /** |
| 643 | * Classifies a durable journal failure reported by the host. |
| 644 | */ |
| 645 | enum class JournalHostErrorKind: int32_t { |
| 646 | /** |
| 647 | * Durable storage is temporarily unavailable. |
| 648 | */ |
| 649 | kUnavailable = 1, |
| 650 | /** |
| 651 | * The stored record cannot be read without data loss. |
| 652 | */ |
| 653 | kCorruptData = 2, |
| 654 | /** |
| 655 | * The host cancelled the storage operation. |
| 656 | */ |
| 657 | kCancelled = 3, |
| 658 | /** |
| 659 | * The failure does not match another kind. |
| 660 | */ |
| 661 | kOther = 4 |
| 662 | }; |
| 663 |
| 664 | namespace uniffi { |
| 665 | struct FfiConverterSendExpiration; |
| 666 | } // namespace uniffi |
| 667 |
| 668 | /** |
| 669 | * The policy used to select the wallet message expiration boundary. |
| 670 | */ |
| 671 | struct SendExpiration { |
| 672 | friend uniffi::FfiConverterSendExpiration; |
| 673 | /** |
| 674 | * Derive expiration from fresh provider time and engine configuration. |
| 675 | */ |
| 676 | struct kEngineDefault { |
| 677 | }; |
| 678 | /** |
| 679 | * Preserve a caller-selected Unix expiration timestamp. |
| 680 | */ |
| 681 | struct kExact { |
| 682 | /** |
| 683 | * The Unix expiration timestamp in seconds. |
| 684 | */ |
| 685 | uint64_t unix_timestamp; |
| 686 | }; |
| 687 | SendExpiration(kEngineDefault variant): variant(variant) {} |
| 688 | SendExpiration(kExact variant): variant(variant) {} |
| 689 |
| 690 | SendExpiration(const SendExpiration &other): variant(other.variant) {} |
| 691 | SendExpiration(SendExpiration &&other): variant(std::move(other.variant)) {} |
| 692 |
| 693 | SendExpiration &operator=(const SendExpiration &other) { |
| 694 | variant = other.variant; |
| 695 | return *this; |
| 696 | } |
| 697 |
| 698 | SendExpiration &operator=(SendExpiration &&other) { |
| 699 | variant = std::move(other.variant); |
| 700 | return *this; |
| 701 | } |
| 702 |
| 703 | /** |
| 704 | * Returns the variant of this enum |
| 705 | */ |
| 706 | const std::variant<kEngineDefault, kExact> &get_variant() const { |
| 707 | return variant; |
| 708 | } |
| 709 |
| 710 | private: |
| 711 | std::variant<kEngineDefault, kExact> variant; |
| 712 |
| 713 | SendExpiration(); |
| 714 | }; |
| 715 |
| 716 |
| 717 | /** |
| 718 | * Classifies a failure reported by a status-less provider host. |
| 719 | */ |
| 720 | enum class StatuslessHostErrorKind: int32_t { |
| 721 | /** |
| 722 | * No network connection is available. |
| 723 | */ |
| 724 | kOffline = 1, |
| 725 | /** |
| 726 | * The request exceeded the host deadline. |
| 727 | */ |
| 728 | kTimeout = 2, |
| 729 | /** |
| 730 | * An established relay or proxy connection ended before completion. |
| 731 | */ |
| 732 | kConnectionLost = 3, |
| 733 | /** |
| 734 | * The request violated a host security policy. |
| 735 | */ |
| 736 | kPolicyViolation = 4, |
| 737 | /** |
| 738 | * The response exceeded a limit imposed by the host. |
| 739 | */ |
| 740 | kResponseTooLarge = 5, |
| 741 | /** |
| 742 | * The host cancelled the request. |
| 743 | */ |
| 744 | kCancelled = 6, |
| 745 | /** |
| 746 | * The failure does not match another kind. |
| 747 | */ |
| 748 | kOther = 7 |
| 749 | }; |
| 750 |
| 751 | namespace uniffi { |
| 752 | struct FfiConverterTonConnectSignDataPayload; |
| 753 | } // namespace uniffi |
| 754 |
| 755 | /** |
| 756 | * The data of one `signData` request, exactly as the dApp sent it. |
| 757 | */ |
| 758 | struct TonConnectSignDataPayload { |
| 759 | friend uniffi::FfiConverterTonConnectSignDataPayload; |
| 760 | /** |
| 761 | * UTF-8 text shown to the user and signed verbatim. |
| 762 | */ |
| 763 | struct kText { |
| 764 | /** |
| 765 | * The text to sign. |
| 766 | */ |
| 767 | std::string text; |
| 768 | }; |
| 769 | /** |
| 770 | * Opaque bytes. |
| 771 | */ |
| 772 | struct kBinary { |
| 773 | /** |
| 774 | * The bytes in base64, exactly as the dApp sent them. |
| 775 | */ |
| 776 | std::string bytes; |
| 777 | }; |
| 778 | /** |
| 779 | * A TVM cell described by a TL-B schema; the engine does not decode it. |
| 780 | */ |
| 781 | struct kCell { |
| 782 | /** |
| 783 | * The TL-B schema whose last declared type is the root, exactly as sent. |
| 784 | */ |
| 785 | std::string schema; |
| 786 | /** |
| 787 | * The one-root cell `BoC` in base64, exactly as the dApp sent it. |
| 788 | */ |
| 789 | std::string cell; |
| 790 | }; |
| 791 | TonConnectSignDataPayload(kText variant): variant(variant) {} |
| 792 | TonConnectSignDataPayload(kBinary variant): variant(variant) {} |
| 793 | TonConnectSignDataPayload(kCell variant): variant(variant) {} |
| 794 |
| 795 | TonConnectSignDataPayload(const TonConnectSignDataPayload &other): variant(other.variant) {} |
| 796 | TonConnectSignDataPayload(TonConnectSignDataPayload &&other): variant(std::move(other.variant)) {} |
| 797 |
| 798 | TonConnectSignDataPayload &operator=(const TonConnectSignDataPayload &other) { |
| 799 | variant = other.variant; |
| 800 | return *this; |
| 801 | } |
| 802 |
| 803 | TonConnectSignDataPayload &operator=(TonConnectSignDataPayload &&other) { |
| 804 | variant = std::move(other.variant); |
| 805 | return *this; |
| 806 | } |
| 807 |
| 808 | /** |
| 809 | * Returns the variant of this enum |
| 810 | */ |
| 811 | const std::variant<kText, kBinary, kCell> &get_variant() const { |
| 812 | return variant; |
| 813 | } |
| 814 |
| 815 | private: |
| 816 | std::variant<kText, kBinary, kCell> variant; |
| 817 |
| 818 | TonConnectSignDataPayload(); |
| 819 | }; |
| 820 |
| 821 |
| 822 | /** |
| 823 | * A stable machine-readable domain error code. |
| 824 | */ |
| 825 | enum class ErrorCode: int32_t { |
| 826 | /** |
| 827 | * The provider response did not match the expected schema. |
| 828 | */ |
| 829 | kInvalidProviderResponse = 1, |
| 830 | /** |
| 831 | * The provider returned an HTTP or protocol rejection. |
| 832 | */ |
| 833 | kHttpRejected = 2, |
| 834 | /** |
| 835 | * The provider applied a request limit. |
| 836 | */ |
| 837 | kRateLimited = 3, |
| 838 | /** |
| 839 | * The host reported a transport failure. |
| 840 | */ |
| 841 | kTransportFailed = 4, |
| 842 | /** |
| 843 | * The host cancelled the request. |
| 844 | */ |
| 845 | kHostCancelled = 5, |
| 846 | /** |
| 847 | * The response exceeded a configured bound. |
| 848 | */ |
| 849 | kResponseTooLarge = 6, |
| 850 | /** |
| 851 | * The request violated a host security policy. |
| 852 | */ |
| 853 | kHostPolicyViolation = 7 |
| 854 | }; |
| 855 |
| 856 |
| 857 | /** |
| 858 | * States whether the same operation can be retried safely. |
| 859 | */ |
| 860 | enum class RetryAdvice: int32_t { |
| 861 | /** |
| 862 | * Do not retry the operation without a user or configuration change. |
| 863 | */ |
| 864 | kNone = 1, |
| 865 | /** |
| 866 | * The same read-only operation can be retried. |
| 867 | */ |
| 868 | kSafe = 2, |
| 869 | /** |
| 870 | * Retry after [`DomainError::retry_after_ms`]. |
| 871 | */ |
| 872 | kAfterDelay = 3 |
| 873 | }; |
| 874 |
| 875 |
| 876 | /** |
| 877 | * Selects the TON network used for addresses, providers, and wallet derivation. |
| 878 | */ |
| 879 | enum class Network: int32_t { |
| 880 | /** |
| 881 | * The production TON network. |
| 882 | */ |
| 883 | kMainnet = 1, |
| 884 | /** |
| 885 | * The public TON test network. |
| 886 | */ |
| 887 | kTestnet = 2 |
| 888 | }; |
| 889 |
| 890 |
| 891 | /** |
| 892 | * Explains why the engine requests access to a protected secret. |
| 893 | */ |
| 894 | enum class SecretAccessReason: int32_t { |
| 895 | /** |
| 896 | * Reserved for wallet creation storage policy. |
| 897 | */ |
| 898 | kCreateWallet = 1, |
| 899 | /** |
| 900 | * The engine needs the mnemonic to sign a transfer. |
| 901 | */ |
| 902 | kSignTransfer = 2, |
| 903 | /** |
| 904 | * The engine needs the mnemonic for an off-chain TON Connect ownership proof. |
| 905 | */ |
| 906 | kSignTonConnectProof = 3, |
| 907 | /** |
| 908 | * The engine needs the current mnemonic to prepare a signing-key rotation. |
| 909 | */ |
| 910 | kPrepareKeyRotation = 4, |
| 911 | /** |
| 912 | * The engine needs the mnemonic to encrypt a transfer comment. |
| 913 | */ |
| 914 | kEncryptComment = 5, |
| 915 | /** |
| 916 | * The engine needs the mnemonic to decrypt a transfer comment. |
| 917 | */ |
| 918 | kDecryptComment = 6, |
| 919 | /** |
| 920 | * The user requested the recovery phrase. |
| 921 | */ |
| 922 | kRevealRecoveryPhrase = 7, |
| 923 | /** |
| 924 | * The engine needs the current signing key to derive a TON Connect session key. |
| 925 | */ |
| 926 | kDeriveTonConnectSessionKey = 8, |
| 927 | /** |
| 928 | * The engine needs the current signing key to sign TON Connect signData. |
| 929 | */ |
| 930 | kSignTonConnectData = 9 |
| 931 | }; |
| 932 |
| 933 |
| 934 | /** |
| 935 | * One opaque versioned journal value owned by the engine. |
| 936 | */ |
| 937 | struct JournalRecord { |
| 938 | /** |
| 939 | * The positive compare-and-swap version. |
| 940 | */ |
| 941 | uint64_t version; |
| 942 | /** |
| 943 | * The opaque engine payload. The host must preserve these bytes exactly. |
| 944 | */ |
| 945 | std::vector<uint8_t> payload; |
| 946 | }; |
| 947 |
| 948 |
| 949 | /** |
| 950 | * Selects one durable journal slot for one wallet record. |
| 951 | */ |
| 952 | struct JournalKey { |
| 953 | /** |
| 954 | * The stable application record identifier. |
| 955 | */ |
| 956 | std::string record_id; |
| 957 | /** |
| 958 | * The engine-defined slot name. |
| 959 | */ |
| 960 | std::string slot; |
| 961 | }; |
| 962 |
| 963 |
| 964 | /** |
| 965 | * Why a durable outgoing message cannot yet be resolved to a final outcome. |
| 966 | */ |
| 967 | enum class PendingReason: int32_t { |
| 968 | /** |
| 969 | * Toncenter still exposes an emulated pending transaction for the message. |
| 970 | */ |
| 971 | kInMempool = 1, |
| 972 | /** |
| 973 | * No terminal evidence exists and the signed validity window is still open. |
| 974 | */ |
| 975 | kAwaitingWindow = 2 |
| 976 | }; |
| 977 |
| 978 |
| 979 | /** |
| 980 | * The current state of one independently loaded resource. |
| 981 | */ |
| 982 | enum class ResourcePhase: int32_t { |
| 983 | /** |
| 984 | * No load is active and no successful value is available yet. |
| 985 | */ |
| 986 | kIdle = 1, |
| 987 | /** |
| 988 | * A load is active. |
| 989 | */ |
| 990 | kLoading = 2, |
| 991 | /** |
| 992 | * The latest load for this resource succeeded. |
| 993 | */ |
| 994 | kReady = 3, |
| 995 | /** |
| 996 | * The latest load for this resource failed. |
| 997 | */ |
| 998 | kFailed = 4 |
| 999 | }; |
| 1000 |
| 1001 |
| 1002 | /** |
| 1003 | * The on-chain result of the transaction or internal message. |
| 1004 | */ |
| 1005 | enum class ActivityStatus: int32_t { |
| 1006 | /** |
| 1007 | * The transaction completed and this message was not a bounce. |
| 1008 | */ |
| 1009 | kSuccess = 1, |
| 1010 | /** |
| 1011 | * The transaction was aborted while processing the message. |
| 1012 | */ |
| 1013 | kFailed = 2, |
| 1014 | /** |
| 1015 | * The internal message has the on-chain `bounced` flag. |
| 1016 | */ |
| 1017 | kBounced = 3 |
| 1018 | }; |
| 1019 |
| 1020 |
| 1021 | /** |
| 1022 | * The broad source of a provider or host error. |
| 1023 | */ |
| 1024 | enum class ErrorCategory: int32_t { |
| 1025 | /** |
| 1026 | * Network transport failed. |
| 1027 | */ |
| 1028 | kTransport = 1, |
| 1029 | /** |
| 1030 | * The provider rejected a request or returned invalid data. |
| 1031 | */ |
| 1032 | kProviderProtocol = 2, |
| 1033 | /** |
| 1034 | * The provider applied a request limit. |
| 1035 | */ |
| 1036 | kRateLimit = 3, |
| 1037 | /** |
| 1038 | * The host cancelled the request. |
| 1039 | */ |
| 1040 | kCancellation = 4, |
| 1041 | /** |
| 1042 | * The host rejected the request because of a security or size policy. |
| 1043 | */ |
| 1044 | kHostPolicy = 5 |
| 1045 | }; |
| 1046 |
| 1047 |
| 1048 | /** |
| 1049 | * A request to store secret bytes in platform protected storage. |
| 1050 | */ |
| 1051 | struct ProtectedSecretStore { |
| 1052 | /** |
| 1053 | * The host storage key. |
| 1054 | */ |
| 1055 | ProtectedSecretRef secret_ref; |
| 1056 | /** |
| 1057 | * The mnemonic bytes. The host must not log or persist them outside protected storage. |
| 1058 | */ |
| 1059 | std::vector<uint8_t> bytes; |
| 1060 | /** |
| 1061 | * Whether later reads must require user presence or device authentication. |
| 1062 | */ |
| 1063 | bool require_user_presence; |
| 1064 | }; |
| 1065 |
| 1066 |
| 1067 | /** |
| 1068 | * Requests durable submission of an already signed external wallet message. |
| 1069 | * |
| 1070 | * `seqno` and `valid_until` must be the exact values covered by `signed_boc`. |
| 1071 | * They let the engine reconcile an ambiguous submission without parsing a |
| 1072 | * wallet-version-specific body. |
| 1073 | */ |
| 1074 | struct SendBocRequest { |
| 1075 | /** |
| 1076 | * A unique idempotency identifier chosen by the application. |
| 1077 | */ |
| 1078 | NonEmptyString operation_id; |
| 1079 | /** |
| 1080 | * Allows this submission to replace an unresolved durable send after confirmation. |
| 1081 | */ |
| 1082 | bool force; |
| 1083 | /** |
| 1084 | * The complete signed external-message BOC. |
| 1085 | */ |
| 1086 | Boc signed_boc; |
| 1087 | /** |
| 1088 | * The wallet sequence number covered by the signed message. |
| 1089 | */ |
| 1090 | uint32_t seqno; |
| 1091 | /** |
| 1092 | * The Unix expiration timestamp covered by the signed message. |
| 1093 | */ |
| 1094 | uint64_t valid_until; |
| 1095 | }; |
| 1096 |
| 1097 |
| 1098 | /** |
| 1099 | * The latest parsed balance and status for a wallet account. |
| 1100 | */ |
| 1101 | struct AccountSnapshot { |
| 1102 | /** |
| 1103 | * The exact account balance, in nanograms. |
| 1104 | */ |
| 1105 | UnsignedDecimalString balance_nanograms; |
| 1106 | /** |
| 1107 | * The account lifecycle state. |
| 1108 | */ |
| 1109 | AccountStatus status; |
| 1110 | /** |
| 1111 | * The provider synchronization time as a Unix timestamp. |
| 1112 | */ |
| 1113 | uint64_t sync_utime; |
| 1114 | }; |
| 1115 |
| 1116 |
| 1117 | /** |
| 1118 | * A request to read and authorize access to protected secret bytes. |
| 1119 | */ |
| 1120 | struct ProtectedSecretRead { |
| 1121 | /** |
| 1122 | * The host storage key. |
| 1123 | */ |
| 1124 | ProtectedSecretRef secret_ref; |
| 1125 | /** |
| 1126 | * The operation that needs secret access. |
| 1127 | */ |
| 1128 | SecretAccessReason reason; |
| 1129 | /** |
| 1130 | * User-facing authentication text supplied by Rust. |
| 1131 | */ |
| 1132 | std::string prompt; |
| 1133 | }; |
| 1134 |
| 1135 |
| 1136 | /** |
| 1137 | * Parsed TON address identity and any flags carried by its input representation. |
| 1138 | */ |
| 1139 | struct TonAddressInfo { |
| 1140 | /** |
| 1141 | * Canonical lowercase `workchain:64-hex` account identity. |
| 1142 | */ |
| 1143 | std::string raw; |
| 1144 | /** |
| 1145 | * Signed workchain identifier from the address. |
| 1146 | */ |
| 1147 | int32_t workchain; |
| 1148 | /** |
| 1149 | * Representation and flags used by the parsed input. |
| 1150 | */ |
| 1151 | TonAddressFormat format; |
| 1152 | }; |
| 1153 |
| 1154 |
| 1155 | /** |
| 1156 | * One nonzero incoming or outgoing value transfer in wallet activity. |
| 1157 | */ |
| 1158 | struct ActivityItem { |
| 1159 | /** |
| 1160 | * A stable item key derived from the transaction, direction, and message index. |
| 1161 | */ |
| 1162 | std::string id; |
| 1163 | /** |
| 1164 | * The transaction hash in standard padded Base64. |
| 1165 | */ |
| 1166 | Base64Hash transaction_hash; |
| 1167 | /** |
| 1168 | * The transaction logical time. |
| 1169 | */ |
| 1170 | UnsignedDecimalString logical_time; |
| 1171 | /** |
| 1172 | * The transaction Unix timestamp. |
| 1173 | */ |
| 1174 | uint64_t timestamp; |
| 1175 | /** |
| 1176 | * The value flow direction relative to this wallet. |
| 1177 | */ |
| 1178 | ActivityDirection direction; |
| 1179 | /** |
| 1180 | * The exact transferred value, in nanograms. |
| 1181 | */ |
| 1182 | UnsignedDecimalString amount_nanograms; |
| 1183 | /** |
| 1184 | * The total fee charged by this transaction, in nanograms. |
| 1185 | * |
| 1186 | * A transaction with multiple visible messages repeats this value on each |
| 1187 | * activity item; callers must not sum it per row. |
| 1188 | */ |
| 1189 | UnsignedDecimalString transaction_fee_nanograms; |
| 1190 | /** |
| 1191 | * The on-chain execution status for this message and transaction. |
| 1192 | */ |
| 1193 | ActivityStatus status; |
| 1194 | /** |
| 1195 | * A decoded zero-opcode plaintext comment, including an empty comment. |
| 1196 | */ |
| 1197 | std::optional<std::string> comment; |
| 1198 | /** |
| 1199 | * An opaque encrypted-comment body that can be passed to |
| 1200 | * [`crate::WalletClient::decrypt_comment`]. |
| 1201 | * |
| 1202 | * A sender encrypts to the signing key this wallet had at that time. |
| 1203 | * Decryption tries the current signing key and the anchor key first, then |
| 1204 | * signing keys that earlier rotations replaced, which it recovers from the |
| 1205 | * wallet's public key-change history. |
| 1206 | */ |
| 1207 | std::optional<Boc> encrypted_comment; |
| 1208 | /** |
| 1209 | * The source or destination address, if the provider supplies it. |
| 1210 | */ |
| 1211 | std::optional<TonAddressString> counterparty; |
| 1212 | }; |
| 1213 |
| 1214 |
| 1215 | /** |
| 1216 | * An atomic compare-and-swap request for a journal slot. |
| 1217 | */ |
| 1218 | struct JournalCompareExchange { |
| 1219 | /** |
| 1220 | * The journal slot to change. |
| 1221 | */ |
| 1222 | JournalKey key; |
| 1223 | /** |
| 1224 | * The required current version, or `None` when the slot must be absent. |
| 1225 | */ |
| 1226 | std::optional<uint64_t> expected_version; |
| 1227 | /** |
| 1228 | * The complete replacement value. |
| 1229 | */ |
| 1230 | JournalRecord replacement; |
| 1231 | }; |
| 1232 |
| 1233 |
| 1234 | /** |
| 1235 | * Requests a ready-to-send TON encrypted-comment body. |
| 1236 | * |
| 1237 | * The engine uses the supplied recipient public key or loads it from chain |
| 1238 | * state, then asks the platform host to authorize access to this wallet's |
| 1239 | * protected mnemonic. |
| 1240 | */ |
| 1241 | struct CreateEncryptedCommentRequest { |
| 1242 | /** |
| 1243 | * Recipient wallet address. Must expose `get_public_key` when no key is supplied. |
| 1244 | */ |
| 1245 | TonAddressString recipient; |
| 1246 | /** |
| 1247 | * UTF-8 comment to encrypt. Its encoded form must not exceed 960 bytes. |
| 1248 | */ |
| 1249 | std::string comment; |
| 1250 | /** |
| 1251 | * Optional 32-byte Ed25519 public key used instead of an on-chain lookup. |
| 1252 | * |
| 1253 | * Used directly without deriving or checking the recipient address. The |
| 1254 | * caller must supply the key used by the recipient for comment decryption. |
| 1255 | */ |
| 1256 | std::optional<std::vector<uint8_t>> recipient_public_key = std::nullopt; |
| 1257 | }; |
| 1258 |
| 1259 |
| 1260 | /** |
| 1261 | * Requests explicit decryption of one encrypted-comment message body. |
| 1262 | * |
| 1263 | * [`crate::WalletClient::decrypt_comment`] reads the protected mnemonic once |
| 1264 | * and tries the current signing key, then the anchor key, without any HTTP |
| 1265 | * request. When neither matches and the wallet has rotated its key, it reads |
| 1266 | * the wallet's `change_wallet_key` history from Toncenter v3, recovers each |
| 1267 | * earlier signing key from the encrypted old key its rotation published, and |
| 1268 | * tries those keys. Recovered keys never leave the call. |
| 1269 | */ |
| 1270 | struct DecryptCommentRequest { |
| 1271 | /** |
| 1272 | * Address that sent the encrypted comment. |
| 1273 | * |
| 1274 | * TON binds this bounceable, URL-safe, non-test-only address to the |
| 1275 | * authentication tag. For an incoming activity item this is its |
| 1276 | * `counterparty`; for an outgoing item it is this wallet's address. |
| 1277 | */ |
| 1278 | TonAddressString sender; |
| 1279 | /** |
| 1280 | * Complete message-body cell encoded as a Base64 BOC. |
| 1281 | */ |
| 1282 | Boc body; |
| 1283 | }; |
| 1284 |
| 1285 |
| 1286 | /** |
| 1287 | * The provider cursor for the next older activity page. |
| 1288 | */ |
| 1289 | struct ActivityCursor { |
| 1290 | /** |
| 1291 | * The oldest loaded transaction logical time. |
| 1292 | */ |
| 1293 | UnsignedDecimalString logical_time; |
| 1294 | /** |
| 1295 | * The oldest loaded transaction hash in standard padded Base64. |
| 1296 | */ |
| 1297 | Base64Hash hash; |
| 1298 | }; |
| 1299 |
| 1300 | namespace uniffi { |
| 1301 | struct FfiConverterTonTransferPayload; |
| 1302 | } // namespace uniffi |
| 1303 |
| 1304 | /** |
| 1305 | * The optional payload carried by a parsed TON transfer link. |
| 1306 | */ |
| 1307 | struct TonTransferPayload { |
| 1308 | friend uniffi::FfiConverterTonTransferPayload; |
| 1309 | /** |
| 1310 | * The link contains no message payload. |
| 1311 | */ |
| 1312 | struct kNone { |
| 1313 | }; |
| 1314 | /** |
| 1315 | * The link contains a plaintext comment, which may intentionally be empty. |
| 1316 | */ |
| 1317 | struct kText { |
| 1318 | /** |
| 1319 | * The decoded UTF-8 comment. |
| 1320 | */ |
| 1321 | std::string text; |
| 1322 | }; |
| 1323 | /** |
| 1324 | * The link contains a validated single-root BOC. |
| 1325 | */ |
| 1326 | struct kBoc { |
| 1327 | /** |
| 1328 | * The complete payload cell BOC. |
| 1329 | */ |
| 1330 | Boc boc; |
| 1331 | }; |
| 1332 | TonTransferPayload(kNone variant): variant(variant) {} |
| 1333 | TonTransferPayload(kText variant): variant(variant) {} |
| 1334 | TonTransferPayload(kBoc variant): variant(variant) {} |
| 1335 |
| 1336 | TonTransferPayload(const TonTransferPayload &other): variant(other.variant) {} |
| 1337 | TonTransferPayload(TonTransferPayload &&other): variant(std::move(other.variant)) {} |
| 1338 |
| 1339 | TonTransferPayload &operator=(const TonTransferPayload &other) { |
| 1340 | variant = other.variant; |
| 1341 | return *this; |
| 1342 | } |
| 1343 |
| 1344 | TonTransferPayload &operator=(TonTransferPayload &&other) { |
| 1345 | variant = std::move(other.variant); |
| 1346 | return *this; |
| 1347 | } |
| 1348 |
| 1349 | /** |
| 1350 | * Returns the variant of this enum |
| 1351 | */ |
| 1352 | const std::variant<kNone, kText, kBoc> &get_variant() const { |
| 1353 | return variant; |
| 1354 | } |
| 1355 |
| 1356 | private: |
| 1357 | std::variant<kNone, kText, kBoc> variant; |
| 1358 |
| 1359 | TonTransferPayload(); |
| 1360 | }; |
| 1361 |
| 1362 |
| 1363 | /** |
| 1364 | * One high-level action recognized by Toncenter during emulation. |
| 1365 | * |
| 1366 | * `details_json` preserves action-specific fields without making the stable |
| 1367 | * wallet API depend on Toncenter's growing list of action schemas. |
| 1368 | */ |
| 1369 | struct SendEmulationAction { |
| 1370 | /** |
| 1371 | * The validated action identifier in standard padded Base64. |
| 1372 | */ |
| 1373 | Base64Hash action_id; |
| 1374 | /** |
| 1375 | * Toncenter's action kind, for example `ton_transfer` or `call_contract`. |
| 1376 | */ |
| 1377 | NonEmptyString kind; |
| 1378 | /** |
| 1379 | * Whether Toncenter considers the complete high-level action successful. |
| 1380 | */ |
| 1381 | bool succeeded; |
| 1382 | /** |
| 1383 | * Validated TON account addresses involved in the action. |
| 1384 | */ |
| 1385 | std::vector<TonAddressString> accounts; |
| 1386 | /** |
| 1387 | * Validated transaction hashes associated with the action. |
| 1388 | */ |
| 1389 | std::vector<Base64Hash> transaction_hashes; |
| 1390 | /** |
| 1391 | * Action-specific details serialized as a JSON object. |
| 1392 | */ |
| 1393 | std::string details_json; |
| 1394 | }; |
| 1395 |
| 1396 |
| 1397 | /** |
| 1398 | * A complete HTTP request for the embedding language. |
| 1399 | * |
| 1400 | * The host can add its Toncenter credential according to the actual request |
| 1401 | * URL and its local security policy. Redirects are forbidden. |
| 1402 | */ |
| 1403 | struct HttpRequest { |
| 1404 | /** |
| 1405 | * The identifier used for host cancellation. |
| 1406 | */ |
| 1407 | HttpRequestId id; |
| 1408 | /** |
| 1409 | * The request method. |
| 1410 | */ |
| 1411 | HttpMethod method; |
| 1412 | /** |
| 1413 | * The complete HTTPS request URL. |
| 1414 | */ |
| 1415 | std::string url; |
| 1416 | /** |
| 1417 | * The public request headers. Credential material is not present here. |
| 1418 | */ |
| 1419 | std::vector<HttpHeader> headers; |
| 1420 | /** |
| 1421 | * The request body. GET requests use an empty body. |
| 1422 | */ |
| 1423 | std::vector<uint8_t> body; |
| 1424 | /** |
| 1425 | * End-to-end request timeout, in milliseconds. |
| 1426 | * |
| 1427 | * The host must enforce this deadline across connection setup, response |
| 1428 | * headers, and response-body reads. Expiry is reported as |
| 1429 | * [`HttpHostErrorKind::Timeout`]. |
| 1430 | */ |
| 1431 | uint64_t timeout_ms; |
| 1432 | }; |
| 1433 |
| 1434 | namespace uniffi { |
| 1435 | struct FfiConverterNftTransferPayload; |
| 1436 | } // namespace uniffi |
| 1437 |
| 1438 | /** |
| 1439 | * Optional payload delivered to the new owner with `ownership_assigned`. |
| 1440 | */ |
| 1441 | struct NftTransferPayload { |
| 1442 | friend uniffi::FfiConverterNftTransferPayload; |
| 1443 | /** |
| 1444 | * Use an empty forward payload. |
| 1445 | */ |
| 1446 | struct kEmpty { |
| 1447 | }; |
| 1448 | /** |
| 1449 | * Encode a zero opcode followed by UTF-8 TON snake data. |
| 1450 | */ |
| 1451 | struct kComment { |
| 1452 | /** |
| 1453 | * Plaintext comment delivered to the new owner. |
| 1454 | */ |
| 1455 | std::string text; |
| 1456 | }; |
| 1457 | /** |
| 1458 | * Preserve one caller-built cell as the forward payload. |
| 1459 | */ |
| 1460 | struct kRawPayload { |
| 1461 | /** |
| 1462 | * Complete payload cell encoded as a validated BOC. |
| 1463 | */ |
| 1464 | Boc boc; |
| 1465 | }; |
| 1466 | NftTransferPayload(kEmpty variant): variant(variant) {} |
| 1467 | NftTransferPayload(kComment variant): variant(variant) {} |
| 1468 | NftTransferPayload(kRawPayload variant): variant(variant) {} |
| 1469 |
| 1470 | NftTransferPayload(const NftTransferPayload &other): variant(other.variant) {} |
| 1471 | NftTransferPayload(NftTransferPayload &&other): variant(std::move(other.variant)) {} |
| 1472 |
| 1473 | NftTransferPayload &operator=(const NftTransferPayload &other) { |
| 1474 | variant = other.variant; |
| 1475 | return *this; |
| 1476 | } |
| 1477 |
| 1478 | NftTransferPayload &operator=(NftTransferPayload &&other) { |
| 1479 | variant = std::move(other.variant); |
| 1480 | return *this; |
| 1481 | } |
| 1482 |
| 1483 | /** |
| 1484 | * Returns the variant of this enum |
| 1485 | */ |
| 1486 | const std::variant<kEmpty, kComment, kRawPayload> &get_variant() const { |
| 1487 | return variant; |
| 1488 | } |
| 1489 |
| 1490 | private: |
| 1491 | std::variant<kEmpty, kComment, kRawPayload> variant; |
| 1492 |
| 1493 | NftTransferPayload(); |
| 1494 | }; |
| 1495 |
| 1496 |
| 1497 | /** |
| 1498 | * Two signed delivery forms prepared from the same wallet state. |
| 1499 | * |
| 1500 | * Both BOCs cover the same `seqno` and `valid_until`, so they are alternative |
| 1501 | * representations of one transfer. The caller must hand off only the delivery |
| 1502 | * form selected by its server. This result is not written to the send journal. |
| 1503 | */ |
| 1504 | struct PreparedTransfer { |
| 1505 | /** |
| 1506 | * The application operation identifier. |
| 1507 | */ |
| 1508 | NonEmptyString operation_id; |
| 1509 | /** |
| 1510 | * Complete incoming external message for direct provider submission. |
| 1511 | */ |
| 1512 | Boc external_boc; |
| 1513 | /** |
| 1514 | * Complete owner-signed internal message for a gas-paying relayer. |
| 1515 | */ |
| 1516 | Boc internal_boc; |
| 1517 | /** |
| 1518 | * Fresh wallet sequence number covered by both signed messages. |
| 1519 | */ |
| 1520 | uint32_t seqno; |
| 1521 | /** |
| 1522 | * Unix expiration timestamp covered by both signed messages. |
| 1523 | */ |
| 1524 | uint64_t valid_until; |
| 1525 | }; |
| 1526 |
| 1527 | namespace uniffi { |
| 1528 | struct FfiConverterTonTransferAsset; |
| 1529 | } // namespace uniffi |
| 1530 |
| 1531 | /** |
| 1532 | * The asset selected by a parsed TON transfer link. |
| 1533 | */ |
| 1534 | struct TonTransferAsset { |
| 1535 | friend uniffi::FfiConverterTonTransferAsset; |
| 1536 | /** |
| 1537 | * Transfer Gram. |
| 1538 | */ |
| 1539 | struct kGram { |
| 1540 | }; |
| 1541 | /** |
| 1542 | * Transfer a jetton identified by its master contract. |
| 1543 | */ |
| 1544 | struct kJetton { |
| 1545 | /** |
| 1546 | * The jetton master contract address. |
| 1547 | */ |
| 1548 | TonAddressString master; |
| 1549 | }; |
| 1550 | TonTransferAsset(kGram variant): variant(variant) {} |
| 1551 | TonTransferAsset(kJetton variant): variant(variant) {} |
| 1552 |
| 1553 | TonTransferAsset(const TonTransferAsset &other): variant(other.variant) {} |
| 1554 | TonTransferAsset(TonTransferAsset &&other): variant(std::move(other.variant)) {} |
| 1555 |
| 1556 | TonTransferAsset &operator=(const TonTransferAsset &other) { |
| 1557 | variant = other.variant; |
| 1558 | return *this; |
| 1559 | } |
| 1560 |
| 1561 | TonTransferAsset &operator=(TonTransferAsset &&other) { |
| 1562 | variant = std::move(other.variant); |
| 1563 | return *this; |
| 1564 | } |
| 1565 |
| 1566 | /** |
| 1567 | * Returns the variant of this enum |
| 1568 | */ |
| 1569 | const std::variant<kGram, kJetton> &get_variant() const { |
| 1570 | return variant; |
| 1571 | } |
| 1572 |
| 1573 | private: |
| 1574 | std::variant<kGram, kJetton> variant; |
| 1575 |
| 1576 | TonTransferAsset(); |
| 1577 | }; |
| 1578 |
| 1579 |
| 1580 | /** |
| 1581 | * Host-owned subset of the TypeScript protocol's `DeviceInfo`. |
| 1582 | * |
| 1583 | * Rust fills `maxProtocolVersion` and `features` from the methods the engine |
| 1584 | * actually implements, so platform clients cannot advertise unsupported |
| 1585 | * capabilities. |
| 1586 | */ |
| 1587 | struct TonConnectDevice { |
| 1588 | /** |
| 1589 | * Current wallet runtime platform. |
| 1590 | */ |
| 1591 | TonConnectDevicePlatform platform; |
| 1592 | /** |
| 1593 | * Wallet registry identifier. |
| 1594 | */ |
| 1595 | std::string app_name; |
| 1596 | /** |
| 1597 | * Wallet application version. |
| 1598 | */ |
| 1599 | std::string app_version; |
| 1600 | }; |
| 1601 |
| 1602 |
| 1603 | /** |
| 1604 | * Requests creation of the data needed for Wallet rev00 key rotation. |
| 1605 | */ |
| 1606 | struct PrepareKeyRotationRequest { |
| 1607 | /** |
| 1608 | * Unix timestamp covered by the current key's request signature. |
| 1609 | */ |
| 1610 | uint64_t valid_until; |
| 1611 | /** |
| 1612 | * Delivery channel and channel-specific request opcode. |
| 1613 | */ |
| 1614 | KeyRotationMessageKind message_kind; |
| 1615 | }; |
| 1616 |
| 1617 |
| 1618 | /** |
| 1619 | * A secret-bearing one-shot command. It must never be persisted or logged. |
| 1620 | * |
| 1621 | * The words cross FFI because the user enters them. Rust validates and derives |
| 1622 | * the wallet. The host only provides protected storage. |
| 1623 | */ |
| 1624 | struct ImportWalletRequest { |
| 1625 | /** |
| 1626 | * The stable application record identifier for the imported wallet. |
| 1627 | */ |
| 1628 | std::string record_id; |
| 1629 | /** |
| 1630 | * The network used to derive the wallet contract and address. |
| 1631 | */ |
| 1632 | Network network; |
| 1633 | /** |
| 1634 | * Lowercase English words of a rotation mnemonic (TEP-0003 section 3.3). |
| 1635 | * |
| 1636 | * Pass the phrase exactly as the user recorded it: 12 words for a wallet |
| 1637 | * whose key was never rotated, or 24 words - two independently |
| 1638 | * checksummed BIP-39 halves - after rotation. The engine expands the |
| 1639 | * 12-word form itself; never duplicate the words in the application. |
| 1640 | * |
| 1641 | * [`detect_mnemonic_schemes`] classifies the same word vector without |
| 1642 | * importing it, so the application can explain a rejection. |
| 1643 | */ |
| 1644 | std::vector<std::string> recovery_words; |
| 1645 | }; |
| 1646 |
| 1647 |
| 1648 | /** |
| 1649 | * The result returned after the send workflow reaches a terminal phase. |
| 1650 | */ |
| 1651 | struct SendResult { |
| 1652 | /** |
| 1653 | * The application operation identifier. |
| 1654 | */ |
| 1655 | NonEmptyString operation_id; |
| 1656 | /** |
| 1657 | * The normalized signed external-message hash in standard padded Base64. |
| 1658 | */ |
| 1659 | Base64Hash message_hash; |
| 1660 | /** |
| 1661 | * The exact signed external-message `BoC` submitted to the provider. |
| 1662 | */ |
| 1663 | Boc signed_boc; |
| 1664 | /** |
| 1665 | * The terminal phase. This can be [`SendPhase::SubmissionUnknown`]. |
| 1666 | */ |
| 1667 | SendPhase phase; |
| 1668 | }; |
| 1669 |
| 1670 |
| 1671 | /** |
| 1672 | * Chain-derived metadata for an NFT collection. |
| 1673 | * |
| 1674 | * Product-specific classification, such as Telegram gifts or usernames, |
| 1675 | * intentionally stays outside the engine. |
| 1676 | */ |
| 1677 | struct NftCollectionDescriptor { |
| 1678 | /** |
| 1679 | * The NFT collection contract address. |
| 1680 | */ |
| 1681 | TonAddressString address; |
| 1682 | /** |
| 1683 | * The standard TEP-64 collection name, when available. |
| 1684 | */ |
| 1685 | std::optional<std::string> name; |
| 1686 | /** |
| 1687 | * The standard TEP-64 collection description, when available. |
| 1688 | */ |
| 1689 | std::optional<std::string> description; |
| 1690 | /** |
| 1691 | * The standard TEP-64 collection image reference, when available. |
| 1692 | */ |
| 1693 | std::optional<std::string> image; |
| 1694 | /** |
| 1695 | * All string-valued collection metadata returned by the provider. |
| 1696 | */ |
| 1697 | std::unordered_map<std::string, std::string> content; |
| 1698 | }; |
| 1699 |
| 1700 |
| 1701 | /** |
| 1702 | * The complete HTTP response returned by the host. |
| 1703 | */ |
| 1704 | struct HttpResponse { |
| 1705 | /** |
| 1706 | * The HTTP status code. |
| 1707 | */ |
| 1708 | uint16_t status; |
| 1709 | /** |
| 1710 | * The response headers accepted by the host. |
| 1711 | */ |
| 1712 | std::vector<HttpHeader> headers; |
| 1713 | /** |
| 1714 | * The response body accepted by the host. |
| 1715 | */ |
| 1716 | std::vector<uint8_t> body; |
| 1717 | /** |
| 1718 | * The final response URL reported by the host. It must equal the request URL |
| 1719 | * because the engine does not permit redirects. |
| 1720 | */ |
| 1721 | std::string final_url; |
| 1722 | }; |
| 1723 |
| 1724 | namespace uniffi { |
| 1725 | struct FfiConverterSendMessageBody; |
| 1726 | } // namespace uniffi |
| 1727 |
| 1728 | /** |
| 1729 | * The body encoded into one outgoing internal TON message. |
| 1730 | * |
| 1731 | * Select `Empty` for a value-only transfer, `Comment` for a standard text |
| 1732 | * comment, or `RawPayload` for a pre-serialized contract call. |
| 1733 | */ |
| 1734 | struct SendMessageBody { |
| 1735 | friend uniffi::FfiConverterSendMessageBody; |
| 1736 | /** |
| 1737 | * Encode no body bits or references. |
| 1738 | */ |
| 1739 | struct kEmpty { |
| 1740 | }; |
| 1741 | /** |
| 1742 | * Encode a zero opcode followed by the UTF-8 text as TON snake data. |
| 1743 | */ |
| 1744 | struct kComment { |
| 1745 | /** |
| 1746 | * The plaintext UTF-8 comment, including an intentionally empty one. |
| 1747 | */ |
| 1748 | std::string text; |
| 1749 | }; |
| 1750 | /** |
| 1751 | * Preserve one caller-built cell as the internal-message body. |
| 1752 | */ |
| 1753 | struct kRawPayload { |
| 1754 | /** |
| 1755 | * The complete body cell encoded as a validated BOC. |
| 1756 | */ |
| 1757 | Boc boc; |
| 1758 | }; |
| 1759 | SendMessageBody(kEmpty variant): variant(variant) {} |
| 1760 | SendMessageBody(kComment variant): variant(variant) {} |
| 1761 | SendMessageBody(kRawPayload variant): variant(variant) {} |
| 1762 |
| 1763 | SendMessageBody(const SendMessageBody &other): variant(other.variant) {} |
| 1764 | SendMessageBody(SendMessageBody &&other): variant(std::move(other.variant)) {} |
| 1765 |
| 1766 | SendMessageBody &operator=(const SendMessageBody &other) { |
| 1767 | variant = other.variant; |
| 1768 | return *this; |
| 1769 | } |
| 1770 |
| 1771 | SendMessageBody &operator=(SendMessageBody &&other) { |
| 1772 | variant = std::move(other.variant); |
| 1773 | return *this; |
| 1774 | } |
| 1775 |
| 1776 | /** |
| 1777 | * Returns the variant of this enum |
| 1778 | */ |
| 1779 | const std::variant<kEmpty, kComment, kRawPayload> &get_variant() const { |
| 1780 | return variant; |
| 1781 | } |
| 1782 |
| 1783 | private: |
| 1784 | std::variant<kEmpty, kComment, kRawPayload> variant; |
| 1785 |
| 1786 | SendMessageBody(); |
| 1787 | }; |
| 1788 |
| 1789 | namespace uniffi { |
| 1790 | struct FfiConverterProtectedSecretHostError; |
| 1791 | } // namespace uniffi |
| 1792 |
| 1793 | /** |
| 1794 | * A protected-storage failure returned by [`crate::WalletPlatformHost`]. |
| 1795 | */ |
| 1796 | struct ProtectedSecretHostError: std::runtime_error { |
| 1797 | friend uniffi::FfiConverterProtectedSecretHostError; |
| 1798 |
| 1799 | ProtectedSecretHostError() : std::runtime_error("") {} |
| 1800 | ProtectedSecretHostError(const std::string &what_arg) : std::runtime_error(what_arg) {} |
| 1801 |
| 1802 | virtual ~ProtectedSecretHostError() = default; |
| 1803 |
| 1804 | virtual void throw_underlying() { |
| 1805 | throw *this; |
| 1806 | } |
| 1807 |
| 1808 | protected: |
| 1809 | virtual int32_t get_variant_idx() const { |
| 1810 | return 0; |
| 1811 | }; |
| 1812 | }; |
| 1813 | /** |
| 1814 | * Contains variants of ProtectedSecretHostError |
| 1815 | */ |
| 1816 | namespace protected_secret_host_error { |
| 1817 |
| 1818 | /** |
| 1819 | * Reports a classified host failure with a safe diagnostic message. |
| 1820 | */ |
| 1821 | struct Failed: ProtectedSecretHostError { |
| 1822 | ProtectedSecretHostErrorKind kind; |
| 1823 | std::string diagnostic; |
| 1824 |
| 1825 | Failed() : ProtectedSecretHostError("") {} |
| 1826 | Failed(const std::string &what_arg) : ProtectedSecretHostError(what_arg) {} |
| 1827 |
| 1828 | void throw_underlying() override { |
| 1829 | throw *this; |
| 1830 | } |
| 1831 |
| 1832 | protected: |
| 1833 | int32_t get_variant_idx() const override { |
| 1834 | return 1; |
| 1835 | } |
| 1836 | }; |
| 1837 | } // namespace protected_secret_host_error |
| 1838 |
| 1839 |
| 1840 | /** |
| 1841 | * Configures the Toncenter endpoint. |
| 1842 | */ |
| 1843 | struct ProviderConfig { |
| 1844 | /** |
| 1845 | * The HTTPS base URL for a Toncenter-compatible provider. |
| 1846 | * |
| 1847 | * The engine appends the path for the API used by each request. An optional |
| 1848 | * deployment prefix is preserved, so `https://provider.example/toncenter` |
| 1849 | * produces paths below `/toncenter/api/...`. |
| 1850 | * Loopback HTTP URLs are accepted for local development networks. |
| 1851 | * Supply an already serialized ASCII URL, with any path escaping applied |
| 1852 | * and no credentials, query, or fragment. The engine does not normalize it. |
| 1853 | */ |
| 1854 | std::string toncenter_base_url; |
| 1855 | /** |
| 1856 | * Optional TON DNS root resolver override. |
| 1857 | * |
| 1858 | * When absent, the engine selects the built-in current root for the wallet |
| 1859 | * network. Set an explicit address to update the resolver without changing |
| 1860 | * the engine. |
| 1861 | */ |
| 1862 | std::optional<TonAddressString> dns_root_address; |
| 1863 | /** |
| 1864 | * End-to-end timeout applied to every provider request, in milliseconds. |
| 1865 | * |
| 1866 | * The selected provider host must enforce this deadline across its |
| 1867 | * complete HTTP, relay, or protocol-proxy call. |
| 1868 | */ |
| 1869 | uint64_t request_timeout_ms; |
| 1870 | }; |
| 1871 |
| 1872 |
| 1873 | /** |
| 1874 | * Requests generation of a new wallet account. |
| 1875 | */ |
| 1876 | struct CreateWalletRequest { |
| 1877 | /** |
| 1878 | * Stable application identity, normally a UUID generated by the host. |
| 1879 | */ |
| 1880 | std::string record_id; |
| 1881 | /** |
| 1882 | * The network used to derive the wallet contract and address. |
| 1883 | */ |
| 1884 | Network network; |
| 1885 | }; |
| 1886 |
| 1887 | namespace uniffi { |
| 1888 | struct FfiConverterWalletClientError; |
| 1889 | } // namespace uniffi |
| 1890 |
| 1891 | /** |
| 1892 | * An operational failure returned by [`crate::WalletClient`]. |
| 1893 | */ |
| 1894 | struct WalletClientError: std::runtime_error { |
| 1895 | friend uniffi::FfiConverterWalletClientError; |
| 1896 |
| 1897 | WalletClientError() : std::runtime_error("") {} |
| 1898 | WalletClientError(const std::string &what_arg) : std::runtime_error(what_arg) {} |
| 1899 |
| 1900 | virtual ~WalletClientError() = default; |
| 1901 |
| 1902 | virtual void throw_underlying() { |
| 1903 | throw *this; |
| 1904 | } |
| 1905 |
| 1906 | protected: |
| 1907 | virtual int32_t get_variant_idx() const { |
| 1908 | return 0; |
| 1909 | }; |
| 1910 | }; |
| 1911 | /** |
| 1912 | * Contains variants of WalletClientError |
| 1913 | */ |
| 1914 | namespace wallet_client_error { |
| 1915 |
| 1916 | /** |
| 1917 | * The configured protected-secret reference is blank. |
| 1918 | */ |
| 1919 | struct InvalidLocalSecretReference: WalletClientError { |
| 1920 |
| 1921 | InvalidLocalSecretReference() : WalletClientError("") {} |
| 1922 | InvalidLocalSecretReference(const std::string &what_arg) : WalletClientError(what_arg) {} |
| 1923 |
| 1924 | void throw_underlying() override { |
| 1925 | throw *this; |
| 1926 | } |
| 1927 |
| 1928 | protected: |
| 1929 | int32_t get_variant_idx() const override { |
| 1930 | return 1; |
| 1931 | } |
| 1932 | }; |
| 1933 |
| 1934 | /** |
| 1935 | * The configured public key cannot derive the wallet state. |
| 1936 | */ |
| 1937 | struct InvalidWalletPublicKey: WalletClientError { |
| 1938 |
| 1939 | InvalidWalletPublicKey() : WalletClientError("") {} |
| 1940 | InvalidWalletPublicKey(const std::string &what_arg) : WalletClientError(what_arg) {} |
| 1941 |
| 1942 | void throw_underlying() override { |
| 1943 | throw *this; |
| 1944 | } |
| 1945 |
| 1946 | protected: |
| 1947 | int32_t get_variant_idx() const override { |
| 1948 | return 2; |
| 1949 | } |
| 1950 | }; |
| 1951 |
| 1952 | /** |
| 1953 | * The configured address does not belong to the public key and network. |
| 1954 | */ |
| 1955 | struct WalletIdentityMismatch: WalletClientError { |
| 1956 |
| 1957 | WalletIdentityMismatch() : WalletClientError("") {} |
| 1958 | WalletIdentityMismatch(const std::string &what_arg) : WalletClientError(what_arg) {} |
| 1959 |
| 1960 | void throw_underlying() override { |
| 1961 | throw *this; |
| 1962 | } |
| 1963 |
| 1964 | protected: |
| 1965 | int32_t get_variant_idx() const override { |
| 1966 | return 3; |
| 1967 | } |
| 1968 | }; |
| 1969 |
| 1970 | /** |
| 1971 | * The configured provider base cannot be extended with an endpoint path. |
| 1972 | */ |
| 1973 | struct InvalidProviderBaseUrl: WalletClientError { |
| 1974 |
| 1975 | InvalidProviderBaseUrl() : WalletClientError("") {} |
| 1976 | InvalidProviderBaseUrl(const std::string &what_arg) : WalletClientError(what_arg) {} |
| 1977 |
| 1978 | void throw_underlying() override { |
| 1979 | throw *this; |
| 1980 | } |
| 1981 |
| 1982 | protected: |
| 1983 | int32_t get_variant_idx() const override { |
| 1984 | return 4; |
| 1985 | } |
| 1986 | }; |
| 1987 |
| 1988 | /** |
| 1989 | * The transfer request has an invalid operation ID, destination, or amount. |
| 1990 | */ |
| 1991 | struct InvalidSendRequest: WalletClientError { |
| 1992 |
| 1993 | InvalidSendRequest() : WalletClientError("") {} |
| 1994 | InvalidSendRequest(const std::string &what_arg) : WalletClientError(what_arg) {} |
| 1995 |
| 1996 | void throw_underlying() override { |
| 1997 | throw *this; |
| 1998 | } |
| 1999 |
| 2000 | protected: |
| 2001 | int32_t get_variant_idx() const override { |
| 2002 | return 5; |
| 2003 | } |
| 2004 | }; |
| 2005 |
| 2006 | /** |
| 2007 | * NFT transfer validation or TEP-62 message construction failed before signing. |
| 2008 | */ |
| 2009 | struct NftTransferUnavailable: WalletClientError { |
| 2010 | std::string diagnostic; |
| 2011 |
| 2012 | NftTransferUnavailable() : WalletClientError("") {} |
| 2013 | NftTransferUnavailable(const std::string &what_arg) : WalletClientError(what_arg) {} |
| 2014 |
| 2015 | void throw_underlying() override { |
| 2016 | throw *this; |
| 2017 | } |
| 2018 |
| 2019 | protected: |
| 2020 | int32_t get_variant_idx() const override { |
| 2021 | return 6; |
| 2022 | } |
| 2023 | }; |
| 2024 |
| 2025 | /** |
| 2026 | * Emulation did not prove a complete successful NFT ownership transfer. |
| 2027 | */ |
| 2028 | struct NftTransferEmulationRejected: WalletClientError { |
| 2029 | std::string diagnostic; |
| 2030 |
| 2031 | NftTransferEmulationRejected() : WalletClientError("") {} |
| 2032 | NftTransferEmulationRejected(const std::string &what_arg) : WalletClientError(what_arg) {} |
| 2033 |
| 2034 | void throw_underlying() override { |
| 2035 | throw *this; |
| 2036 | } |
| 2037 |
| 2038 | protected: |
| 2039 | int32_t get_variant_idx() const override { |
| 2040 | return 7; |
| 2041 | } |
| 2042 | }; |
| 2043 |
| 2044 | /** |
| 2045 | * Encrypted-comment preparation or decryption failed safely. |
| 2046 | */ |
| 2047 | struct EncryptedCommentUnavailable: WalletClientError { |
| 2048 | std::string diagnostic; |
| 2049 |
| 2050 | EncryptedCommentUnavailable() : WalletClientError("") {} |
| 2051 | EncryptedCommentUnavailable(const std::string &what_arg) : WalletClientError(what_arg) {} |
| 2052 |
| 2053 | void throw_underlying() override { |
| 2054 | throw *this; |
| 2055 | } |
| 2056 |
| 2057 | protected: |
| 2058 | int32_t get_variant_idx() const override { |
| 2059 | return 8; |
| 2060 | } |
| 2061 | }; |
| 2062 |
| 2063 | /** |
| 2064 | * TON DNS validation, provider resolution, or wallet-record parsing failed. |
| 2065 | */ |
| 2066 | struct DnsResolutionUnavailable: WalletClientError { |
| 2067 | std::string diagnostic; |
| 2068 |
| 2069 | DnsResolutionUnavailable() : WalletClientError("") {} |
| 2070 | DnsResolutionUnavailable(const std::string &what_arg) : WalletClientError(what_arg) {} |
| 2071 |
| 2072 | void throw_underlying() override { |
| 2073 | throw *this; |
| 2074 | } |
| 2075 |
| 2076 | protected: |
| 2077 | int32_t get_variant_idx() const override { |
| 2078 | return 9; |
| 2079 | } |
| 2080 | }; |
| 2081 |
| 2082 | /** |
| 2083 | * Key-rotation chain-state loading or signed-message construction failed. |
| 2084 | */ |
| 2085 | struct KeyRotationUnavailable: WalletClientError { |
| 2086 | std::string diagnostic; |
| 2087 |
| 2088 | KeyRotationUnavailable() : WalletClientError("") {} |
| 2089 | KeyRotationUnavailable(const std::string &what_arg) : WalletClientError(what_arg) {} |
| 2090 |
| 2091 | void throw_underlying() override { |
| 2092 | throw *this; |
| 2093 | } |
| 2094 |
| 2095 | protected: |
| 2096 | int32_t get_variant_idx() const override { |
| 2097 | return 10; |
| 2098 | } |
| 2099 | }; |
| 2100 |
| 2101 | /** |
| 2102 | * The wallet has public identity but no protected secret configured for local signing. |
| 2103 | */ |
| 2104 | struct LocalSigningUnavailable: WalletClientError { |
| 2105 |
| 2106 | LocalSigningUnavailable() : WalletClientError("") {} |
| 2107 | LocalSigningUnavailable(const std::string &what_arg) : WalletClientError(what_arg) {} |
| 2108 |
| 2109 | void throw_underlying() override { |
| 2110 | throw *this; |
| 2111 | } |
| 2112 |
| 2113 | protected: |
| 2114 | int32_t get_variant_idx() const override { |
| 2115 | return 11; |
| 2116 | } |
| 2117 | }; |
| 2118 |
| 2119 | /** |
| 2120 | * A client-local identifier or revision counter overflowed. |
| 2121 | */ |
| 2122 | struct IdentifierExhausted: WalletClientError { |
| 2123 |
| 2124 | IdentifierExhausted() : WalletClientError("") {} |
| 2125 | IdentifierExhausted(const std::string &what_arg) : WalletClientError(what_arg) {} |
| 2126 |
| 2127 | void throw_underlying() override { |
| 2128 | throw *this; |
| 2129 | } |
| 2130 |
| 2131 | protected: |
| 2132 | int32_t get_variant_idx() const override { |
| 2133 | return 12; |
| 2134 | } |
| 2135 | }; |
| 2136 |
| 2137 | /** |
| 2138 | * The internal state lock or active operation state is unavailable. |
| 2139 | */ |
| 2140 | struct StateUnavailable: WalletClientError { |
| 2141 |
| 2142 | StateUnavailable() : WalletClientError("") {} |
| 2143 | StateUnavailable(const std::string &what_arg) : WalletClientError(what_arg) {} |
| 2144 |
| 2145 | void throw_underlying() override { |
| 2146 | throw *this; |
| 2147 | } |
| 2148 |
| 2149 | protected: |
| 2150 | int32_t get_variant_idx() const override { |
| 2151 | return 13; |
| 2152 | } |
| 2153 | }; |
| 2154 |
| 2155 | /** |
| 2156 | * Another signed message is already being prepared or submitted by this client. |
| 2157 | */ |
| 2158 | struct SendAlreadyInProgress: WalletClientError { |
| 2159 |
| 2160 | SendAlreadyInProgress() : WalletClientError("") {} |
| 2161 | SendAlreadyInProgress(const std::string &what_arg) : WalletClientError(what_arg) {} |
| 2162 |
| 2163 | void throw_underlying() override { |
| 2164 | throw *this; |
| 2165 | } |
| 2166 |
| 2167 | protected: |
| 2168 | int32_t get_variant_idx() const override { |
| 2169 | return 14; |
| 2170 | } |
| 2171 | }; |
| 2172 |
| 2173 | /** |
| 2174 | * Another send preview is already fetching or emulating current chain state. |
| 2175 | */ |
| 2176 | struct SendPreviewAlreadyInProgress: WalletClientError { |
| 2177 |
| 2178 | SendPreviewAlreadyInProgress() : WalletClientError("") {} |
| 2179 | SendPreviewAlreadyInProgress(const std::string &what_arg) : WalletClientError(what_arg) {} |
| 2180 |
| 2181 | void throw_underlying() override { |
| 2182 | throw *this; |
| 2183 | } |
| 2184 |
| 2185 | protected: |
| 2186 | int32_t get_variant_idx() const override { |
| 2187 | return 15; |
| 2188 | } |
| 2189 | }; |
| 2190 |
| 2191 | /** |
| 2192 | * A durable prior submission has no definite provider outcome. |
| 2193 | * |
| 2194 | * The caller must not create a replacement transfer because the stored |
| 2195 | * signed message can already be on the network. |
| 2196 | */ |
| 2197 | struct PreviousSubmissionUnresolved: WalletClientError { |
| 2198 |
| 2199 | PreviousSubmissionUnresolved() : WalletClientError("") {} |
| 2200 | PreviousSubmissionUnresolved(const std::string &what_arg) : WalletClientError(what_arg) {} |
| 2201 |
| 2202 | void throw_underlying() override { |
| 2203 | throw *this; |
| 2204 | } |
| 2205 |
| 2206 | protected: |
| 2207 | int32_t get_variant_idx() const override { |
| 2208 | return 16; |
| 2209 | } |
| 2210 | }; |
| 2211 |
| 2212 | /** |
| 2213 | * The provider still reports the sequence number used by the previous send. |
| 2214 | * |
| 2215 | * Refresh chain state and retry only after the wallet sequence number advances. |
| 2216 | */ |
| 2217 | struct WalletSeqnoNotAdvanced: WalletClientError { |
| 2218 |
| 2219 | WalletSeqnoNotAdvanced() : WalletClientError("") {} |
| 2220 | WalletSeqnoNotAdvanced(const std::string &what_arg) : WalletClientError(what_arg) {} |
| 2221 |
| 2222 | void throw_underlying() override { |
| 2223 | throw *this; |
| 2224 | } |
| 2225 |
| 2226 | protected: |
| 2227 | int32_t get_variant_idx() const override { |
| 2228 | return 17; |
| 2229 | } |
| 2230 | }; |
| 2231 |
| 2232 | /** |
| 2233 | * The current on-chain account status does not permit a transfer. |
| 2234 | */ |
| 2235 | struct SendAccountUnavailable: WalletClientError { |
| 2236 | AccountStatus status; |
| 2237 |
| 2238 | SendAccountUnavailable() : WalletClientError("") {} |
| 2239 | SendAccountUnavailable(const std::string &what_arg) : WalletClientError(what_arg) {} |
| 2240 |
| 2241 | void throw_underlying() override { |
| 2242 | throw *this; |
| 2243 | } |
| 2244 |
| 2245 | protected: |
| 2246 | int32_t get_variant_idx() const override { |
| 2247 | return 18; |
| 2248 | } |
| 2249 | }; |
| 2250 |
| 2251 | /** |
| 2252 | * The fresh on-chain balance is smaller than the requested transfer value. |
| 2253 | * |
| 2254 | * This check excludes network fees. A transfer can still fail on-chain |
| 2255 | * when its value fits but the remaining balance cannot pay fees. |
| 2256 | */ |
| 2257 | struct InsufficientBalance: WalletClientError { |
| 2258 | UnsignedDecimalString available_nanograms; |
| 2259 | UnsignedDecimalString requested_nanograms; |
| 2260 |
| 2261 | InsufficientBalance() : WalletClientError("") {} |
| 2262 | InsufficientBalance(const std::string &what_arg) : WalletClientError(what_arg) {} |
| 2263 |
| 2264 | void throw_underlying() override { |
| 2265 | throw *this; |
| 2266 | } |
| 2267 |
| 2268 | protected: |
| 2269 | int32_t get_variant_idx() const override { |
| 2270 | return 19; |
| 2271 | } |
| 2272 | }; |
| 2273 |
| 2274 | /** |
| 2275 | * The requested exact value fits, but the value and emulated wallet fee do not. |
| 2276 | */ |
| 2277 | struct InsufficientBalanceForFees: WalletClientError { |
| 2278 | UnsignedDecimalString available_nanograms; |
| 2279 | UnsignedDecimalString requested_nanograms; |
| 2280 | UnsignedDecimalString estimated_fee_nanograms; |
| 2281 |
| 2282 | InsufficientBalanceForFees() : WalletClientError("") {} |
| 2283 | InsufficientBalanceForFees(const std::string &what_arg) : WalletClientError(what_arg) {} |
| 2284 |
| 2285 | void throw_underlying() override { |
| 2286 | throw *this; |
| 2287 | } |
| 2288 |
| 2289 | protected: |
| 2290 | int32_t get_variant_idx() const override { |
| 2291 | return 20; |
| 2292 | } |
| 2293 | }; |
| 2294 |
| 2295 | /** |
| 2296 | * The protected secret cannot be decoded as a valid wallet recovery phrase. |
| 2297 | */ |
| 2298 | struct InvalidProtectedSecret: WalletClientError { |
| 2299 |
| 2300 | InvalidProtectedSecret() : WalletClientError("") {} |
| 2301 | InvalidProtectedSecret(const std::string &what_arg) : WalletClientError(what_arg) {} |
| 2302 |
| 2303 | void throw_underlying() override { |
| 2304 | throw *this; |
| 2305 | } |
| 2306 |
| 2307 | protected: |
| 2308 | int32_t get_variant_idx() const override { |
| 2309 | return 21; |
| 2310 | } |
| 2311 | }; |
| 2312 |
| 2313 | /** |
| 2314 | * A preview failed while loading fresh wallet state or building its fake-signed message. |
| 2315 | */ |
| 2316 | struct SendPreviewFailed: WalletClientError { |
| 2317 | std::string diagnostic; |
| 2318 |
| 2319 | SendPreviewFailed() : WalletClientError("") {} |
| 2320 | SendPreviewFailed(const std::string &what_arg) : WalletClientError(what_arg) {} |
| 2321 |
| 2322 | void throw_underlying() override { |
| 2323 | throw *this; |
| 2324 | } |
| 2325 |
| 2326 | protected: |
| 2327 | int32_t get_variant_idx() const override { |
| 2328 | return 22; |
| 2329 | } |
| 2330 | }; |
| 2331 |
| 2332 | /** |
| 2333 | * Toncenter could not execute or decode the fake-signed preview emulation. |
| 2334 | */ |
| 2335 | struct EmulationFailed: WalletClientError { |
| 2336 | std::string diagnostic; |
| 2337 |
| 2338 | EmulationFailed() : WalletClientError("") {} |
| 2339 | EmulationFailed(const std::string &what_arg) : WalletClientError(what_arg) {} |
| 2340 |
| 2341 | void throw_underlying() override { |
| 2342 | throw *this; |
| 2343 | } |
| 2344 |
| 2345 | protected: |
| 2346 | int32_t get_variant_idx() const override { |
| 2347 | return 23; |
| 2348 | } |
| 2349 | }; |
| 2350 |
| 2351 | /** |
| 2352 | * The emulator ran correctly, but the current wallet state did not accept |
| 2353 | * the external message, for example because its seqno became stale. |
| 2354 | */ |
| 2355 | struct EmulationMessageNotAccepted: WalletClientError { |
| 2356 | std::string diagnostic; |
| 2357 |
| 2358 | EmulationMessageNotAccepted() : WalletClientError("") {} |
| 2359 | EmulationMessageNotAccepted(const std::string &what_arg) : WalletClientError(what_arg) {} |
| 2360 |
| 2361 | void throw_underlying() override { |
| 2362 | throw *this; |
| 2363 | } |
| 2364 |
| 2365 | protected: |
| 2366 | int32_t get_variant_idx() const override { |
| 2367 | return 24; |
| 2368 | } |
| 2369 | }; |
| 2370 |
| 2371 | /** |
| 2372 | * Emulation proved that the source wallet transaction would not complete. |
| 2373 | */ |
| 2374 | struct EmulationRejected: WalletClientError { |
| 2375 | std::string diagnostic; |
| 2376 | std::optional<int32_t> compute_exit_code; |
| 2377 | std::optional<int32_t> action_result_code; |
| 2378 |
| 2379 | EmulationRejected() : WalletClientError("") {} |
| 2380 | EmulationRejected(const std::string &what_arg) : WalletClientError(what_arg) {} |
| 2381 |
| 2382 | void throw_underlying() override { |
| 2383 | throw *this; |
| 2384 | } |
| 2385 |
| 2386 | protected: |
| 2387 | int32_t get_variant_idx() const override { |
| 2388 | return 25; |
| 2389 | } |
| 2390 | }; |
| 2391 |
| 2392 | /** |
| 2393 | * A send failed before submission became ambiguous. |
| 2394 | */ |
| 2395 | struct SendFailed: WalletClientError { |
| 2396 | std::string diagnostic; |
| 2397 |
| 2398 | SendFailed() : WalletClientError("") {} |
| 2399 | SendFailed(const std::string &what_arg) : WalletClientError(what_arg) {} |
| 2400 |
| 2401 | void throw_underlying() override { |
| 2402 | throw *this; |
| 2403 | } |
| 2404 |
| 2405 | protected: |
| 2406 | int32_t get_variant_idx() const override { |
| 2407 | return 26; |
| 2408 | } |
| 2409 | }; |
| 2410 |
| 2411 | /** |
| 2412 | * A send can have reached the provider, but no definite result is available. |
| 2413 | */ |
| 2414 | struct SubmissionUnknown: WalletClientError { |
| 2415 | std::string diagnostic; |
| 2416 |
| 2417 | SubmissionUnknown() : WalletClientError("") {} |
| 2418 | SubmissionUnknown(const std::string &what_arg) : WalletClientError(what_arg) {} |
| 2419 |
| 2420 | void throw_underlying() override { |
| 2421 | throw *this; |
| 2422 | } |
| 2423 |
| 2424 | protected: |
| 2425 | int32_t get_variant_idx() const override { |
| 2426 | return 27; |
| 2427 | } |
| 2428 | }; |
| 2429 |
| 2430 | /** |
| 2431 | * A send crossed its durable commit boundary and cannot be cancelled. |
| 2432 | */ |
| 2433 | struct SendCancellationTooLate: WalletClientError { |
| 2434 |
| 2435 | SendCancellationTooLate() : WalletClientError("") {} |
| 2436 | SendCancellationTooLate(const std::string &what_arg) : WalletClientError(what_arg) {} |
| 2437 |
| 2438 | void throw_underlying() override { |
| 2439 | throw *this; |
| 2440 | } |
| 2441 |
| 2442 | protected: |
| 2443 | int32_t get_variant_idx() const override { |
| 2444 | return 28; |
| 2445 | } |
| 2446 | }; |
| 2447 |
| 2448 | /** |
| 2449 | * The client is shut down and accepts no new work. |
| 2450 | */ |
| 2451 | struct Shutdown: WalletClientError { |
| 2452 |
| 2453 | Shutdown() : WalletClientError("") {} |
| 2454 | Shutdown(const std::string &what_arg) : WalletClientError(what_arg) {} |
| 2455 |
| 2456 | void throw_underlying() override { |
| 2457 | throw *this; |
| 2458 | } |
| 2459 |
| 2460 | protected: |
| 2461 | int32_t get_variant_idx() const override { |
| 2462 | return 29; |
| 2463 | } |
| 2464 | }; |
| 2465 |
| 2466 | /** |
| 2467 | * Provider data an encrypted-comment operation needs could not be read now. |
| 2468 | * |
| 2469 | * For encryption, the recipient's public key lookup failed, was limited, |
| 2470 | * or was cancelled, so nothing is known about the recipient. For |
| 2471 | * decryption, the wallet's key-change history could not be read or does |
| 2472 | * not reach the current signing key yet, so earlier signing keys could |
| 2473 | * not be tried. The same request can be retried. It is never returned |
| 2474 | * when the recipient is known to be unable to receive an encrypted |
| 2475 | * comment or when every key of this wallet was tried; that is |
| 2476 | * [`Self::EncryptedCommentUnavailable`]. The display text keeps its |
| 2477 | * original "recipient lookup" wording for compatibility. |
| 2478 | */ |
| 2479 | struct EncryptedCommentLookupFailed: WalletClientError { |
| 2480 | std::string diagnostic; |
| 2481 |
| 2482 | EncryptedCommentLookupFailed() : WalletClientError("") {} |
| 2483 | EncryptedCommentLookupFailed(const std::string &what_arg) : WalletClientError(what_arg) {} |
| 2484 |
| 2485 | void throw_underlying() override { |
| 2486 | throw *this; |
| 2487 | } |
| 2488 |
| 2489 | protected: |
| 2490 | int32_t get_variant_idx() const override { |
| 2491 | return 30; |
| 2492 | } |
| 2493 | }; |
| 2494 | } // namespace wallet_client_error |
| 2495 |
| 2496 |
| 2497 | /** |
| 2498 | * One account transaction observed in an emulated message trace. |
| 2499 | */ |
| 2500 | struct SendEmulationTransaction { |
| 2501 | /** |
| 2502 | * Account whose contract executed this transaction. |
| 2503 | */ |
| 2504 | TonAddressString account; |
| 2505 | /** |
| 2506 | * Whether the observed compute and action phases contain no explicit failure. |
| 2507 | */ |
| 2508 | bool succeeded; |
| 2509 | /** |
| 2510 | * Whether this is the source wallet transaction at the root of the trace. |
| 2511 | */ |
| 2512 | bool is_root; |
| 2513 | }; |
| 2514 |
| 2515 |
| 2516 | /** |
| 2517 | * Chain evidence and retry guidance for a durable outgoing message. |
| 2518 | */ |
| 2519 | struct ResolutionInfo { |
| 2520 | /** |
| 2521 | * The confirmed transaction hash, when the message was executed. |
| 2522 | */ |
| 2523 | std::optional<Base64Hash> transaction_hash; |
| 2524 | /** |
| 2525 | * The confirmed transaction logical time. |
| 2526 | */ |
| 2527 | std::optional<UnsignedDecimalString> transaction_lt; |
| 2528 | /** |
| 2529 | * Why the message remains unresolved, when no terminal evidence exists. |
| 2530 | */ |
| 2531 | std::optional<PendingReason> pending_reason; |
| 2532 | /** |
| 2533 | * Whether a new send with `force` can replace this unresolved signed send. |
| 2534 | */ |
| 2535 | bool can_force_retry; |
| 2536 | /** |
| 2537 | * A UI polling hint. This is not a correctness deadline. |
| 2538 | */ |
| 2539 | std::optional<uint64_t> retry_after_hint_ms; |
| 2540 | }; |
| 2541 |
| 2542 | namespace uniffi { |
| 2543 | struct FfiConverterSendAmount; |
| 2544 | } // namespace uniffi |
| 2545 |
| 2546 | /** |
| 2547 | * The transfer value policy applied by the wallet contract. |
| 2548 | */ |
| 2549 | struct SendAmount { |
| 2550 | friend uniffi::FfiConverterSendAmount; |
| 2551 | /** |
| 2552 | * Send one exact nonnegative value and pay network fees separately. |
| 2553 | */ |
| 2554 | struct kExact { |
| 2555 | /** |
| 2556 | * The exact value, in nanograms. |
| 2557 | */ |
| 2558 | UnsignedDecimalString nanograms; |
| 2559 | }; |
| 2560 | /** |
| 2561 | * Send the complete remaining wallet balance after network fees. |
| 2562 | */ |
| 2563 | struct kAll { |
| 2564 | }; |
| 2565 | SendAmount(kExact variant): variant(variant) {} |
| 2566 | SendAmount(kAll variant): variant(variant) {} |
| 2567 |
| 2568 | SendAmount(const SendAmount &other): variant(other.variant) {} |
| 2569 | SendAmount(SendAmount &&other): variant(std::move(other.variant)) {} |
| 2570 |
| 2571 | SendAmount &operator=(const SendAmount &other) { |
| 2572 | variant = other.variant; |
| 2573 | return *this; |
| 2574 | } |
| 2575 |
| 2576 | SendAmount &operator=(SendAmount &&other) { |
| 2577 | variant = std::move(other.variant); |
| 2578 | return *this; |
| 2579 | } |
| 2580 |
| 2581 | /** |
| 2582 | * Returns the variant of this enum |
| 2583 | */ |
| 2584 | const std::variant<kExact, kAll> &get_variant() const { |
| 2585 | return variant; |
| 2586 | } |
| 2587 |
| 2588 | private: |
| 2589 | std::variant<kExact, kAll> variant; |
| 2590 |
| 2591 | SendAmount(); |
| 2592 | }; |
| 2593 |
| 2594 | namespace uniffi { |
| 2595 | struct FfiConverterHttpHostError; |
| 2596 | } // namespace uniffi |
| 2597 |
| 2598 | /** |
| 2599 | * An HTTP failure returned by [`WalletHttpHost`]. |
| 2600 | */ |
| 2601 | struct HttpHostError: std::runtime_error { |
| 2602 | friend uniffi::FfiConverterHttpHostError; |
| 2603 |
| 2604 | HttpHostError() : std::runtime_error("") {} |
| 2605 | HttpHostError(const std::string &what_arg) : std::runtime_error(what_arg) {} |
| 2606 |
| 2607 | virtual ~HttpHostError() = default; |
| 2608 |
| 2609 | virtual void throw_underlying() { |
| 2610 | throw *this; |
| 2611 | } |
| 2612 |
| 2613 | protected: |
| 2614 | virtual int32_t get_variant_idx() const { |
| 2615 | return 0; |
| 2616 | }; |
| 2617 | }; |
| 2618 | /** |
| 2619 | * Contains variants of HttpHostError |
| 2620 | */ |
| 2621 | namespace http_host_error { |
| 2622 |
| 2623 | /** |
| 2624 | * Reports a classified host failure with a safe diagnostic message. |
| 2625 | */ |
| 2626 | struct Failed: HttpHostError { |
| 2627 | HttpHostErrorKind kind; |
| 2628 | std::string diagnostic; |
| 2629 |
| 2630 | Failed() : HttpHostError("") {} |
| 2631 | Failed(const std::string &what_arg) : HttpHostError(what_arg) {} |
| 2632 |
| 2633 | void throw_underlying() override { |
| 2634 | throw *this; |
| 2635 | } |
| 2636 |
| 2637 | protected: |
| 2638 | int32_t get_variant_idx() const override { |
| 2639 | return 1; |
| 2640 | } |
| 2641 | }; |
| 2642 | } // namespace http_host_error |
| 2643 |
| 2644 |
| 2645 | /** |
| 2646 | * Structured error data for account and activity resources. |
| 2647 | */ |
| 2648 | struct DomainError { |
| 2649 | /** |
| 2650 | * The stable machine-readable code. |
| 2651 | */ |
| 2652 | ErrorCode code; |
| 2653 | /** |
| 2654 | * The broad source of the error. |
| 2655 | */ |
| 2656 | ErrorCategory category; |
| 2657 | /** |
| 2658 | * Retry guidance for the failed operation. |
| 2659 | */ |
| 2660 | RetryAdvice retry; |
| 2661 | /** |
| 2662 | * A sanitized developer-facing diagnostic with a bounded length. |
| 2663 | */ |
| 2664 | std::string developer_message; |
| 2665 | /** |
| 2666 | * The provider status code, if the provider returned one. |
| 2667 | */ |
| 2668 | std::optional<uint16_t> provider_status; |
| 2669 | /** |
| 2670 | * The provider delay in milliseconds, if it returned a numeric `Retry-After` header. |
| 2671 | */ |
| 2672 | std::optional<uint64_t> retry_after_ms; |
| 2673 | /** |
| 2674 | * The normalized host failure kind, if the error came from a callback. |
| 2675 | * |
| 2676 | * Status-less host kinds map to the corresponding legacy HTTP kind so |
| 2677 | * existing consumers retain one stable classification field. |
| 2678 | */ |
| 2679 | std::optional<HttpHostErrorKind> host_kind; |
| 2680 | }; |
| 2681 |
| 2682 | namespace uniffi { |
| 2683 | struct FfiConverterJournalHostError; |
| 2684 | } // namespace uniffi |
| 2685 |
| 2686 | /** |
| 2687 | * A durable journal failure returned by [`crate::WalletPlatformHost`]. |
| 2688 | */ |
| 2689 | struct JournalHostError: std::runtime_error { |
| 2690 | friend uniffi::FfiConverterJournalHostError; |
| 2691 |
| 2692 | JournalHostError() : std::runtime_error("") {} |
| 2693 | JournalHostError(const std::string &what_arg) : std::runtime_error(what_arg) {} |
| 2694 |
| 2695 | virtual ~JournalHostError() = default; |
| 2696 |
| 2697 | virtual void throw_underlying() { |
| 2698 | throw *this; |
| 2699 | } |
| 2700 |
| 2701 | protected: |
| 2702 | virtual int32_t get_variant_idx() const { |
| 2703 | return 0; |
| 2704 | }; |
| 2705 | }; |
| 2706 | /** |
| 2707 | * Contains variants of JournalHostError |
| 2708 | */ |
| 2709 | namespace journal_host_error { |
| 2710 |
| 2711 | /** |
| 2712 | * Reports a classified journal failure with a safe diagnostic message. |
| 2713 | */ |
| 2714 | struct Failed: JournalHostError { |
| 2715 | JournalHostErrorKind kind; |
| 2716 | std::string diagnostic; |
| 2717 |
| 2718 | Failed() : JournalHostError("") {} |
| 2719 | Failed(const std::string &what_arg) : JournalHostError(what_arg) {} |
| 2720 |
| 2721 | void throw_underlying() override { |
| 2722 | throw *this; |
| 2723 | } |
| 2724 |
| 2725 | protected: |
| 2726 | int32_t get_variant_idx() const override { |
| 2727 | return 1; |
| 2728 | } |
| 2729 | }; |
| 2730 | } // namespace journal_host_error |
| 2731 |
| 2732 |
| 2733 | /** |
| 2734 | * A `signData` request already validated against the session's wallet. |
| 2735 | */ |
| 2736 | struct TonConnectSignDataRequest { |
| 2737 | /** |
| 2738 | * The data to show and sign. |
| 2739 | */ |
| 2740 | TonConnectSignDataPayload payload; |
| 2741 | /** |
| 2742 | * The network global ID the dApp named, exactly as sent; it matches the wallet. |
| 2743 | */ |
| 2744 | std::optional<std::string> network; |
| 2745 | /** |
| 2746 | * The signer address the dApp named, exactly as sent; it is the wallet's address. |
| 2747 | */ |
| 2748 | std::optional<std::string> from; |
| 2749 | }; |
| 2750 |
| 2751 |
| 2752 | /** |
| 2753 | * Public, persistable wallet metadata. Recovery words never belong here. |
| 2754 | */ |
| 2755 | struct WalletDescriptor { |
| 2756 | /** |
| 2757 | * The stable application record identifier. |
| 2758 | */ |
| 2759 | std::string record_id; |
| 2760 | /** |
| 2761 | * The derived friendly non-bounceable TON address. |
| 2762 | */ |
| 2763 | TonAddressString address; |
| 2764 | /** |
| 2765 | * The raw 32-byte Ed25519 anchor public key of the rotation mnemonic. |
| 2766 | * |
| 2767 | * The anchor key determines the wallet account address and never |
| 2768 | * changes, so this is safe to persist. It lets the engine emulate a |
| 2769 | * first deployment before it asks the host to unlock the recovery |
| 2770 | * phrase. |
| 2771 | */ |
| 2772 | std::vector<uint8_t> public_key; |
| 2773 | /** |
| 2774 | * The network used for derivation and future operations. |
| 2775 | */ |
| 2776 | Network network; |
| 2777 | /** |
| 2778 | * The host protected-storage reference for the mnemonic. |
| 2779 | */ |
| 2780 | ProtectedSecretRef secret_ref; |
| 2781 | }; |
| 2782 |
| 2783 |
| 2784 | /** |
| 2785 | * A durable owner-signed internal message returned to its caller for relaying. |
| 2786 | */ |
| 2787 | struct SignMessageResult { |
| 2788 | /** |
| 2789 | * The application operation identifier. |
| 2790 | */ |
| 2791 | NonEmptyString operation_id; |
| 2792 | /** |
| 2793 | * The complete relaxed internal message encoded as a validated BOC. |
| 2794 | */ |
| 2795 | Boc internal_boc; |
| 2796 | /** |
| 2797 | * The Unix expiration timestamp covered by the signature. |
| 2798 | */ |
| 2799 | uint64_t valid_until; |
| 2800 | /** |
| 2801 | * The durable workflow phase after the message becomes available to the caller. |
| 2802 | */ |
| 2803 | SendPhase phase; |
| 2804 | }; |
| 2805 |
| 2806 |
| 2807 | /** |
| 2808 | * The result of an atomic journal compare-and-swap operation. |
| 2809 | */ |
| 2810 | struct JournalCompareExchangeResult { |
| 2811 | /** |
| 2812 | * Whether the host stored the replacement. |
| 2813 | */ |
| 2814 | bool applied; |
| 2815 | /** |
| 2816 | * The current record after the operation, if one exists. |
| 2817 | */ |
| 2818 | std::optional<JournalRecord> current; |
| 2819 | }; |
| 2820 |
| 2821 | namespace uniffi { |
| 2822 | struct FfiConverterStatuslessHostError; |
| 2823 | } // namespace uniffi |
| 2824 |
| 2825 | /** |
| 2826 | * A failure returned by [`WalletStatuslessHost`]. |
| 2827 | */ |
| 2828 | struct StatuslessHostError: std::runtime_error { |
| 2829 | friend uniffi::FfiConverterStatuslessHostError; |
| 2830 |
| 2831 | StatuslessHostError() : std::runtime_error("") {} |
| 2832 | StatuslessHostError(const std::string &what_arg) : std::runtime_error(what_arg) {} |
| 2833 |
| 2834 | virtual ~StatuslessHostError() = default; |
| 2835 |
| 2836 | virtual void throw_underlying() { |
| 2837 | throw *this; |
| 2838 | } |
| 2839 |
| 2840 | protected: |
| 2841 | virtual int32_t get_variant_idx() const { |
| 2842 | return 0; |
| 2843 | }; |
| 2844 | }; |
| 2845 | /** |
| 2846 | * Contains variants of StatuslessHostError |
| 2847 | */ |
| 2848 | namespace statusless_host_error { |
| 2849 |
| 2850 | /** |
| 2851 | * Reports a classified transport failure with a safe diagnostic message. |
| 2852 | */ |
| 2853 | struct Failed: StatuslessHostError { |
| 2854 | StatuslessHostErrorKind kind; |
| 2855 | std::string diagnostic; |
| 2856 |
| 2857 | Failed() : StatuslessHostError("") {} |
| 2858 | Failed(const std::string &what_arg) : StatuslessHostError(what_arg) {} |
| 2859 |
| 2860 | void throw_underlying() override { |
| 2861 | throw *this; |
| 2862 | } |
| 2863 |
| 2864 | protected: |
| 2865 | int32_t get_variant_idx() const override { |
| 2866 | return 1; |
| 2867 | } |
| 2868 | }; |
| 2869 | } // namespace statusless_host_error |
| 2870 |
| 2871 | namespace uniffi { |
| 2872 | struct FfiConverterWalletLifecycleError; |
| 2873 | } // namespace uniffi |
| 2874 |
| 2875 | /** |
| 2876 | * A wallet creation, import, secret, or derivation failure. |
| 2877 | */ |
| 2878 | struct WalletLifecycleError: std::runtime_error { |
| 2879 | friend uniffi::FfiConverterWalletLifecycleError; |
| 2880 |
| 2881 | WalletLifecycleError() : std::runtime_error("") {} |
| 2882 | WalletLifecycleError(const std::string &what_arg) : std::runtime_error(what_arg) {} |
| 2883 |
| 2884 | virtual ~WalletLifecycleError() = default; |
| 2885 |
| 2886 | virtual void throw_underlying() { |
| 2887 | throw *this; |
| 2888 | } |
| 2889 |
| 2890 | protected: |
| 2891 | virtual int32_t get_variant_idx() const { |
| 2892 | return 0; |
| 2893 | }; |
| 2894 | }; |
| 2895 | /** |
| 2896 | * Contains variants of WalletLifecycleError |
| 2897 | */ |
| 2898 | namespace wallet_lifecycle_error { |
| 2899 |
| 2900 | /** |
| 2901 | * The record ID is empty, too long, or contains unsupported characters. |
| 2902 | */ |
| 2903 | struct InvalidRecordId: WalletLifecycleError { |
| 2904 |
| 2905 | InvalidRecordId() : WalletLifecycleError("") {} |
| 2906 | InvalidRecordId(const std::string &what_arg) : WalletLifecycleError(what_arg) {} |
| 2907 |
| 2908 | void throw_underlying() override { |
| 2909 | throw *this; |
| 2910 | } |
| 2911 |
| 2912 | protected: |
| 2913 | int32_t get_variant_idx() const override { |
| 2914 | return 1; |
| 2915 | } |
| 2916 | }; |
| 2917 |
| 2918 | /** |
| 2919 | * The recovery phrase is not a valid 12- or 24-word Rotation mnemonic. |
| 2920 | * |
| 2921 | * [`detect_mnemonic_schemes`] reports whether the words form a TON or |
| 2922 | * 24-word BIP-39 mnemonic instead, so the application can say why the |
| 2923 | * phrase was rejected. |
| 2924 | */ |
| 2925 | struct InvalidRecoveryPhrase: WalletLifecycleError { |
| 2926 |
| 2927 | InvalidRecoveryPhrase() : WalletLifecycleError("") {} |
| 2928 | InvalidRecoveryPhrase(const std::string &what_arg) : WalletLifecycleError(what_arg) {} |
| 2929 |
| 2930 | void throw_underlying() override { |
| 2931 | throw *this; |
| 2932 | } |
| 2933 |
| 2934 | protected: |
| 2935 | int32_t get_variant_idx() const override { |
| 2936 | return 2; |
| 2937 | } |
| 2938 | }; |
| 2939 |
| 2940 | /** |
| 2941 | * Rust cannot construct the requested wallet address. |
| 2942 | */ |
| 2943 | struct AddressDerivationFailed: WalletLifecycleError { |
| 2944 |
| 2945 | AddressDerivationFailed() : WalletLifecycleError("") {} |
| 2946 | AddressDerivationFailed(const std::string &what_arg) : WalletLifecycleError(what_arg) {} |
| 2947 |
| 2948 | void throw_underlying() override { |
| 2949 | throw *this; |
| 2950 | } |
| 2951 |
| 2952 | protected: |
| 2953 | int32_t get_variant_idx() const override { |
| 2954 | return 3; |
| 2955 | } |
| 2956 | }; |
| 2957 |
| 2958 | /** |
| 2959 | * The TON Connect proof fields or signing key are invalid. |
| 2960 | */ |
| 2961 | struct TonConnectSigningFailed: WalletLifecycleError { |
| 2962 |
| 2963 | TonConnectSigningFailed() : WalletLifecycleError("") {} |
| 2964 | TonConnectSigningFailed(const std::string &what_arg) : WalletLifecycleError(what_arg) {} |
| 2965 |
| 2966 | void throw_underlying() override { |
| 2967 | throw *this; |
| 2968 | } |
| 2969 |
| 2970 | protected: |
| 2971 | int32_t get_variant_idx() const override { |
| 2972 | return 4; |
| 2973 | } |
| 2974 | }; |
| 2975 |
| 2976 | /** |
| 2977 | * The protected mnemonic derives a different address from the descriptor. |
| 2978 | */ |
| 2979 | struct SecretWalletMismatch: WalletLifecycleError { |
| 2980 |
| 2981 | SecretWalletMismatch() : WalletLifecycleError("") {} |
| 2982 | SecretWalletMismatch(const std::string &what_arg) : WalletLifecycleError(what_arg) {} |
| 2983 |
| 2984 | void throw_underlying() override { |
| 2985 | throw *this; |
| 2986 | } |
| 2987 |
| 2988 | protected: |
| 2989 | int32_t get_variant_idx() const override { |
| 2990 | return 5; |
| 2991 | } |
| 2992 | }; |
| 2993 |
| 2994 | /** |
| 2995 | * The host reported a protected-storage failure. |
| 2996 | */ |
| 2997 | struct ProtectedSecretHost: WalletLifecycleError { |
| 2998 | ProtectedSecretHostErrorKind kind; |
| 2999 | std::string diagnostic; |
| 3000 |
| 3001 | ProtectedSecretHost() : WalletLifecycleError("") {} |
| 3002 | ProtectedSecretHost(const std::string &what_arg) : WalletLifecycleError(what_arg) {} |
| 3003 |
| 3004 | void throw_underlying() override { |
| 3005 | throw *this; |
| 3006 | } |
| 3007 |
| 3008 | protected: |
| 3009 | int32_t get_variant_idx() const override { |
| 3010 | return 6; |
| 3011 | } |
| 3012 | }; |
| 3013 |
| 3014 | /** |
| 3015 | * The dApp client id is not 64 lowercase hex characters or the session nonce is empty. |
| 3016 | */ |
| 3017 | struct InvalidTonConnectSessionInput: WalletLifecycleError { |
| 3018 |
| 3019 | InvalidTonConnectSessionInput() : WalletLifecycleError("") {} |
| 3020 | InvalidTonConnectSessionInput(const std::string &what_arg) : WalletLifecycleError(what_arg) {} |
| 3021 |
| 3022 | void throw_underlying() override { |
| 3023 | throw *this; |
| 3024 | } |
| 3025 |
| 3026 | protected: |
| 3027 | int32_t get_variant_idx() const override { |
| 3028 | return 7; |
| 3029 | } |
| 3030 | }; |
| 3031 | } // namespace wallet_lifecycle_error |
| 3032 |
| 3033 | namespace uniffi { |
| 3034 | struct FfiConverterNftTransferFunding; |
| 3035 | } // namespace uniffi |
| 3036 |
| 3037 | /** |
| 3038 | * The TON amounts used to execute one NFT item transfer. |
| 3039 | * |
| 3040 | * Both values are deliberately explicit. The engine does not choose a gas |
| 3041 | * deposit or recipient notification amount on behalf of the application. |
| 3042 | */ |
| 3043 | struct NftTransferFunding { |
| 3044 | friend uniffi::FfiConverterNftTransferFunding; |
| 3045 | /** |
| 3046 | * Attach an exact amount to the NFT item call and forward an exact amount |
| 3047 | * with the ownership notification. |
| 3048 | */ |
| 3049 | struct kExact { |
| 3050 | /** |
| 3051 | * Value attached to the internal message sent to the NFT item contract. |
| 3052 | */ |
| 3053 | UnsignedDecimalString attached_nanograms; |
| 3054 | /** |
| 3055 | * Value forwarded to the new owner in `ownership_assigned`. |
| 3056 | */ |
| 3057 | UnsignedDecimalString forward_nanograms; |
| 3058 | }; |
| 3059 | NftTransferFunding(kExact variant): variant(variant) {} |
| 3060 |
| 3061 | NftTransferFunding(const NftTransferFunding &other): variant(other.variant) {} |
| 3062 | NftTransferFunding(NftTransferFunding &&other): variant(std::move(other.variant)) {} |
| 3063 |
| 3064 | NftTransferFunding &operator=(const NftTransferFunding &other) { |
| 3065 | variant = other.variant; |
| 3066 | return *this; |
| 3067 | } |
| 3068 |
| 3069 | NftTransferFunding &operator=(NftTransferFunding &&other) { |
| 3070 | variant = std::move(other.variant); |
| 3071 | return *this; |
| 3072 | } |
| 3073 |
| 3074 | /** |
| 3075 | * Returns the variant of this enum |
| 3076 | */ |
| 3077 | const std::variant<kExact> &get_variant() const { |
| 3078 | return variant; |
| 3079 | } |
| 3080 |
| 3081 | private: |
| 3082 | std::variant<kExact> variant; |
| 3083 |
| 3084 | NftTransferFunding(); |
| 3085 | }; |
| 3086 |
| 3087 |
| 3088 | /** |
| 3089 | * One-shot data prepared for a Wallet rev00 signing-key rotation. |
| 3090 | * |
| 3091 | * This value does not mean that rotation succeeded on-chain. Before |
| 3092 | * submission, the host must store `replacement_recovery_phrase` in protected |
| 3093 | * storage. It must store `signed_boc` as a pending durable record. Words 13-24 |
| 3094 | * are the new signing half. Until chain state resolves the request, the host |
| 3095 | * must block ordinary signing. |
| 3096 | * |
| 3097 | * The signed request also carries `encryptedOldPrivateKey`, computed over |
| 3098 | * 32-byte Ed25519 seeds as |
| 3099 | * `sha256(new_private_key ‖ "keyChangeSaltV1") XOR old_private_key`, where the |
| 3100 | * old key is the signing key being replaced. Only the new key opens it. The |
| 3101 | * contract publishes it in its key-changed log, so |
| 3102 | * [`crate::WalletClient::decrypt_comment`] can later recover the replaced key. |
| 3103 | * The engine adds it to `signed_boc`; the host handles nothing extra. |
| 3104 | */ |
| 3105 | struct PreparedKeyRotation { |
| 3106 | /** |
| 3107 | * Full 24-word phrase that preserves the anchor and contains the new signing half. |
| 3108 | */ |
| 3109 | RecoveryPhrase replacement_recovery_phrase; |
| 3110 | /** |
| 3111 | * New raw 32-byte Ed25519 signing public key stored by the contract on success. |
| 3112 | */ |
| 3113 | std::vector<uint8_t> new_public_key; |
| 3114 | /** |
| 3115 | * Complete external or relaxed internal signed message as a validated BOC. |
| 3116 | * |
| 3117 | * Its `ChangePublicKey` request holds two references: the new key's |
| 3118 | * wallet-address proof signature and the encrypted old private key. |
| 3119 | */ |
| 3120 | Boc signed_boc; |
| 3121 | /** |
| 3122 | * External delivery form for the same replacement key, sequence and expiration. |
| 3123 | */ |
| 3124 | Boc external_boc; |
| 3125 | /** |
| 3126 | * Internal alternative; submit only one of the two delivery forms. |
| 3127 | */ |
| 3128 | Boc internal_boc; |
| 3129 | /** |
| 3130 | * Sequence number covered by the signed request. |
| 3131 | */ |
| 3132 | uint32_t seqno; |
| 3133 | /** |
| 3134 | * Unix expiration timestamp covered by the signed request. |
| 3135 | */ |
| 3136 | uint64_t valid_until; |
| 3137 | /** |
| 3138 | * Delivery channel encoded into the request opcode. |
| 3139 | */ |
| 3140 | KeyRotationMessageKind message_kind; |
| 3141 | }; |
| 3142 |
| 3143 |
| 3144 | /** |
| 3145 | * Asks which public key a TON encrypted comment for a recipient would use. |
| 3146 | * |
| 3147 | * The fields mean the same as in [`CreateEncryptedCommentRequest`], so the |
| 3148 | * answer predicts whether that request can encrypt, without a comment and |
| 3149 | * without any protected-secret access. |
| 3150 | */ |
| 3151 | struct EncryptedCommentRecipientRequest { |
| 3152 | /** |
| 3153 | * Recipient wallet address. |
| 3154 | */ |
| 3155 | TonAddressString recipient; |
| 3156 | /** |
| 3157 | * Optional 32-byte Ed25519 public key used instead of an on-chain lookup. |
| 3158 | * |
| 3159 | * The host authenticates it as described by |
| 3160 | * [`CreateEncryptedCommentRequest::recipient_public_key`]. |
| 3161 | */ |
| 3162 | std::optional<std::vector<uint8_t>> recipient_public_key = std::nullopt; |
| 3163 | }; |
| 3164 |
| 3165 |
| 3166 | /** |
| 3167 | * Requests a TON Connect `signData` signature with the wallet's current signing key. |
| 3168 | */ |
| 3169 | struct TonConnectSignDataSignRequest { |
| 3170 | /** |
| 3171 | * Wallet whose protected key must sign the data. |
| 3172 | */ |
| 3173 | WalletDescriptor descriptor; |
| 3174 | /** |
| 3175 | * The decoded request to sign. |
| 3176 | */ |
| 3177 | TonConnectSignDataRequest request; |
| 3178 | /** |
| 3179 | * Exact dApp manifest domain shown to and approved by the user. |
| 3180 | */ |
| 3181 | std::string domain; |
| 3182 | /** |
| 3183 | * Unix signing time in seconds. |
| 3184 | */ |
| 3185 | uint64_t timestamp; |
| 3186 | }; |
| 3187 |
| 3188 |
| 3189 | /** |
| 3190 | * Result of creating a wallet. |
| 3191 | * |
| 3192 | * The descriptor is safe to persist. The recovery phrase is transient and |
| 3193 | * exists only so the UI can show it once. |
| 3194 | */ |
| 3195 | struct CreatedWallet { |
| 3196 | /** |
| 3197 | * Metadata that the application must persist. |
| 3198 | */ |
| 3199 | WalletDescriptor descriptor; |
| 3200 | /** |
| 3201 | * A transient phrase that the application can present once. |
| 3202 | */ |
| 3203 | RecoveryPhrase recovery_phrase; |
| 3204 | }; |
| 3205 |
| 3206 |
| 3207 | /** |
| 3208 | * One NFT item returned by the configured Toncenter v3 provider. |
| 3209 | * |
| 3210 | * `content` contains the string-valued on-chain and indexed metadata fields. |
| 3211 | * Common keys include `name`, `description`, `image`, `image_url`, `preview`, |
| 3212 | * `uri`, and `collection_name`. |
| 3213 | */ |
| 3214 | struct NftItem { |
| 3215 | /** |
| 3216 | * The NFT item contract address. |
| 3217 | */ |
| 3218 | TonAddressString address; |
| 3219 | /** |
| 3220 | * The collection contract address, if this item belongs to a collection. |
| 3221 | */ |
| 3222 | std::optional<TonAddressString> collection_address; |
| 3223 | /** |
| 3224 | * Chain-derived collection metadata, if this item belongs to a collection. |
| 3225 | */ |
| 3226 | std::optional<NftCollectionDescriptor> collection; |
| 3227 | /** |
| 3228 | * The current owner reported by the NFT item contract. |
| 3229 | */ |
| 3230 | std::optional<TonAddressString> owner_address; |
| 3231 | /** |
| 3232 | * The effective owner while a sale contract owns the item. |
| 3233 | */ |
| 3234 | std::optional<TonAddressString> real_owner; |
| 3235 | /** |
| 3236 | * The active sale contract address, if the item is on sale. |
| 3237 | */ |
| 3238 | std::optional<TonAddressString> sale_contract_address; |
| 3239 | /** |
| 3240 | * The active auction contract address, if the item is in an auction. |
| 3241 | */ |
| 3242 | std::optional<TonAddressString> auction_contract_address; |
| 3243 | /** |
| 3244 | * The item index inside its collection. |
| 3245 | */ |
| 3246 | UnsignedDecimalString index; |
| 3247 | /** |
| 3248 | * The logical time of the item's latest indexed transaction. |
| 3249 | */ |
| 3250 | UnsignedDecimalString last_transaction_lt; |
| 3251 | /** |
| 3252 | * Whether the item contract has initialized NFT data. |
| 3253 | */ |
| 3254 | bool initialized; |
| 3255 | /** |
| 3256 | * Whether the provider reports an active sale or auction. |
| 3257 | */ |
| 3258 | bool on_sale; |
| 3259 | /** |
| 3260 | * The item contract code hash in the provider representation. |
| 3261 | */ |
| 3262 | std::string code_hash; |
| 3263 | /** |
| 3264 | * The item contract data hash in the provider representation. |
| 3265 | */ |
| 3266 | std::string data_hash; |
| 3267 | /** |
| 3268 | * String-valued item metadata after Toncenter metadata enrichment. |
| 3269 | */ |
| 3270 | std::unordered_map<std::string, std::string> content; |
| 3271 | /** |
| 3272 | * The provider's content-safety classification, when available. |
| 3273 | */ |
| 3274 | std::optional<bool> is_nsfw; |
| 3275 | /** |
| 3276 | * The provider's scam classification, when available. |
| 3277 | */ |
| 3278 | std::optional<bool> is_scam; |
| 3279 | }; |
| 3280 |
| 3281 |
| 3282 | /** |
| 3283 | * A signed TON Connect `signData` request, ready for the success response. |
| 3284 | */ |
| 3285 | struct TonConnectSignedData { |
| 3286 | /** |
| 3287 | * The signed request. |
| 3288 | */ |
| 3289 | TonConnectSignDataRequest request; |
| 3290 | /** |
| 3291 | * The domain bound into the signature. |
| 3292 | */ |
| 3293 | std::string domain; |
| 3294 | /** |
| 3295 | * The Unix signing time in seconds bound into the signature. |
| 3296 | */ |
| 3297 | uint64_t timestamp; |
| 3298 | /** |
| 3299 | * Exact 64-byte Ed25519 signature. |
| 3300 | */ |
| 3301 | std::vector<uint8_t> signature; |
| 3302 | /** |
| 3303 | * The current 32-byte Ed25519 signing public key that made the signature. |
| 3304 | */ |
| 3305 | std::vector<uint8_t> public_key; |
| 3306 | }; |
| 3307 |
| 3308 |
| 3309 | /** |
| 3310 | * One outgoing internal TON message before wallet-contract serialization. |
| 3311 | */ |
| 3312 | struct SendMessage { |
| 3313 | /** |
| 3314 | * A friendly or raw TON destination address. |
| 3315 | */ |
| 3316 | TonAddressString destination; |
| 3317 | /** |
| 3318 | * The exact-value or whole-balance transfer policy. |
| 3319 | */ |
| 3320 | SendAmount amount; |
| 3321 | /** |
| 3322 | * The single body representation encoded into the message. |
| 3323 | */ |
| 3324 | SendMessageBody body; |
| 3325 | /** |
| 3326 | * Whether a failed destination-contract call returns the remaining value. |
| 3327 | * |
| 3328 | * Ordinary account transfers normally keep this false. Contract calls, |
| 3329 | * including NFT item transfers, must enable it. |
| 3330 | */ |
| 3331 | bool bounce; |
| 3332 | /** |
| 3333 | * Optional destination-contract `StateInit` attached independently of the body. |
| 3334 | */ |
| 3335 | std::optional<Boc> state_init; |
| 3336 | }; |
| 3337 |
| 3338 |
| 3339 | /** |
| 3340 | * A resource phase and its optional failure details. |
| 3341 | */ |
| 3342 | struct ResourceState { |
| 3343 | /** |
| 3344 | * The current resource phase. |
| 3345 | */ |
| 3346 | ResourcePhase phase; |
| 3347 | /** |
| 3348 | * The last error. This value is present only for [`ResourcePhase::Failed`]. |
| 3349 | */ |
| 3350 | std::optional<DomainError> error; |
| 3351 | }; |
| 3352 |
| 3353 |
| 3354 | /** |
| 3355 | * The observable state of the send workflow. |
| 3356 | */ |
| 3357 | struct SendSnapshot { |
| 3358 | /** |
| 3359 | * The active or last operation identifier, if a send started. |
| 3360 | */ |
| 3361 | std::optional<NonEmptyString> operation_id; |
| 3362 | /** |
| 3363 | * The current public phase. |
| 3364 | */ |
| 3365 | SendPhase phase; |
| 3366 | /** |
| 3367 | * A sanitized diagnostic for failed or unknown submission states. |
| 3368 | */ |
| 3369 | std::optional<std::string> error_message; |
| 3370 | /** |
| 3371 | * Resolution evidence or pending guidance for the durable outgoing message. |
| 3372 | */ |
| 3373 | std::optional<ResolutionInfo> resolution; |
| 3374 | }; |
| 3375 |
| 3376 |
| 3377 | /** |
| 3378 | * A syntax-validated transfer invoice parsed from a `ton://transfer/` link. |
| 3379 | * |
| 3380 | * This value is not an executable send request. Network policy, expiration, |
| 3381 | * asset resolution, bounce selection, emulation, and user approval remain the |
| 3382 | * responsibility of the later admission and send stages. |
| 3383 | */ |
| 3384 | struct ParsedTonTransferLink { |
| 3385 | /** |
| 3386 | * The Gram recipient or the jetton owner's account address. |
| 3387 | */ |
| 3388 | TonAddressString recipient; |
| 3389 | /** |
| 3390 | * The asset requested by the link. |
| 3391 | */ |
| 3392 | TonTransferAsset asset; |
| 3393 | /** |
| 3394 | * The exact amount in the asset's elementary units, when supplied. |
| 3395 | */ |
| 3396 | std::optional<UnsignedDecimalString> amount; |
| 3397 | /** |
| 3398 | * The optional decoded text or binary payload. |
| 3399 | */ |
| 3400 | TonTransferPayload payload; |
| 3401 | /** |
| 3402 | * The requested Unix expiration, or the engine-default policy when absent. |
| 3403 | */ |
| 3404 | SendExpiration expiration; |
| 3405 | }; |
| 3406 |
| 3407 |
| 3408 | /** |
| 3409 | * Inputs of one derived `MTProto` TON Connect session. |
| 3410 | */ |
| 3411 | struct TonConnectDerivedSessionRequest { |
| 3412 | /** |
| 3413 | * Wallet whose current signing key derives the session key. |
| 3414 | */ |
| 3415 | WalletDescriptor descriptor; |
| 3416 | /** |
| 3417 | * The dApp client id `A`: exactly 64 lowercase hex characters. |
| 3418 | */ |
| 3419 | std::string dapp_client_id; |
| 3420 | /** |
| 3421 | * The raw per-session nonce issued by the server. It must not be empty. |
| 3422 | */ |
| 3423 | std::vector<uint8_t> nonce; |
| 3424 | }; |
| 3425 |
| 3426 |
| 3427 | /** |
| 3428 | * Requests an address-bound off-chain TON Connect ownership proof signature. |
| 3429 | */ |
| 3430 | struct TonConnectProofSignRequest { |
| 3431 | /** |
| 3432 | * Wallet whose protected key must sign the proof. |
| 3433 | */ |
| 3434 | WalletDescriptor descriptor; |
| 3435 | /** |
| 3436 | * Exact manifest domain shown to and approved by the user. |
| 3437 | */ |
| 3438 | std::string domain; |
| 3439 | /** |
| 3440 | * Unix signing timestamp in seconds. |
| 3441 | */ |
| 3442 | uint64_t timestamp; |
| 3443 | /** |
| 3444 | * Exact dApp challenge from the `ton_proof` connect item. |
| 3445 | */ |
| 3446 | std::string payload; |
| 3447 | }; |
| 3448 |
| 3449 |
| 3450 | /** |
| 3451 | * Identifies one wallet client and its provider configuration. |
| 3452 | */ |
| 3453 | struct WalletClientConfig { |
| 3454 | /** |
| 3455 | * The stable application record identifier for this wallet. |
| 3456 | */ |
| 3457 | NonEmptyString record_id; |
| 3458 | /** |
| 3459 | * The friendly TON address that the client reads and sends from. |
| 3460 | */ |
| 3461 | TonAddressString address; |
| 3462 | /** |
| 3463 | * The raw 32-byte Ed25519 public key used for wallet preflight. |
| 3464 | * |
| 3465 | * For an undeployed wallet, this must be the initial key that derives its |
| 3466 | * address and `StateInit`. For an active wallet, this can be the current |
| 3467 | * signing key after rotation; it need not derive the wallet address. |
| 3468 | */ |
| 3469 | std::vector<uint8_t> public_key; |
| 3470 | /** |
| 3471 | * The protected mnemonic reference used for local signing. |
| 3472 | * |
| 3473 | * `None` configures a public-key-only wallet. Read operations and send |
| 3474 | * previews remain available, while [`crate::WalletClient::send`] returns |
| 3475 | * [`crate::WalletClientError::LocalSigningUnavailable`]. |
| 3476 | */ |
| 3477 | std::optional<ProtectedSecretRef> local_secret_ref; |
| 3478 | /** |
| 3479 | * The network for the address and all provider requests. |
| 3480 | */ |
| 3481 | Network network; |
| 3482 | /** |
| 3483 | * Lifetime of a newly signed external message, in seconds. |
| 3484 | * |
| 3485 | * The engine adds this value to the synchronization timestamp returned by |
| 3486 | * the fresh account-state request. It does not use the host device clock. |
| 3487 | * A short value, including zero, can expire before the network includes |
| 3488 | * the message. A long value extends the period in which it can be submitted. |
| 3489 | */ |
| 3490 | uint64_t send_validity_seconds; |
| 3491 | /** |
| 3492 | * Additional provider-time margin before an unseen message becomes expired. |
| 3493 | * |
| 3494 | * This protects against declaring expiration while the transaction index is |
| 3495 | * still catching up with the account state used by the resolver. |
| 3496 | */ |
| 3497 | uint64_t resolution_margin_seconds; |
| 3498 | /** |
| 3499 | * The provider endpoint. |
| 3500 | */ |
| 3501 | ProviderConfig providers; |
| 3502 | }; |
| 3503 |
| 3504 |
| 3505 | /** |
| 3506 | * A bounded summary of the Toncenter trace emulated before authorization. |
| 3507 | */ |
| 3508 | struct SendEmulation { |
| 3509 | /** |
| 3510 | * The masterchain block used as the emulation state snapshot. |
| 3511 | */ |
| 3512 | uint32_t mc_block_seqno; |
| 3513 | /** |
| 3514 | * Fees charged by the source wallet transaction, in nanograms. |
| 3515 | */ |
| 3516 | UnsignedDecimalString wallet_fees_nanograms; |
| 3517 | /** |
| 3518 | * Sum of fees across every transaction currently present in the trace. |
| 3519 | */ |
| 3520 | UnsignedDecimalString trace_fees_nanograms; |
| 3521 | /** |
| 3522 | * Number of transactions currently present in the emulated trace. |
| 3523 | */ |
| 3524 | uint64_t transaction_count; |
| 3525 | /** |
| 3526 | * High-level actions recognized by Toncenter in the emulated trace. |
| 3527 | */ |
| 3528 | std::vector<SendEmulationAction> actions; |
| 3529 | /** |
| 3530 | * Per-account transaction outcomes observed before optional action parsing. |
| 3531 | * |
| 3532 | * This evidence lets typed contract flows validate execution even when a |
| 3533 | * Toncenter deployment does not recognize the corresponding high-level action. |
| 3534 | */ |
| 3535 | std::vector<SendEmulationTransaction> transactions; |
| 3536 | /** |
| 3537 | * Whether every returned transaction completed without an observed phase failure. |
| 3538 | * |
| 3539 | * A false value does not by itself block submission. A recipient can |
| 3540 | * reject or bounce after the source wallet transaction succeeds. |
| 3541 | */ |
| 3542 | bool trace_succeeded; |
| 3543 | /** |
| 3544 | * Whether Toncenter reports that the trace still has unresolved messages. |
| 3545 | */ |
| 3546 | bool is_incomplete; |
| 3547 | }; |
| 3548 |
| 3549 |
| 3550 | /** |
| 3551 | * Immutable choices for a TEP-62 NFT item transfer. |
| 3552 | */ |
| 3553 | struct NftTransferIntent { |
| 3554 | /** |
| 3555 | * NFT item contract that currently owns the transferable item state. |
| 3556 | */ |
| 3557 | TonAddressString nft_address; |
| 3558 | /** |
| 3559 | * Account that becomes the new NFT owner. |
| 3560 | */ |
| 3561 | TonAddressString recipient; |
| 3562 | /** |
| 3563 | * Explicit attached and forwarded TON values. |
| 3564 | */ |
| 3565 | NftTransferFunding funding; |
| 3566 | /** |
| 3567 | * Payload forwarded to the new owner. |
| 3568 | */ |
| 3569 | NftTransferPayload payload; |
| 3570 | /** |
| 3571 | * Wallet message expiration policy. |
| 3572 | */ |
| 3573 | SendExpiration expiration; |
| 3574 | }; |
| 3575 |
| 3576 |
| 3577 | /** |
| 3578 | * Requests fresh validation and emulation of an NFT transfer. |
| 3579 | * |
| 3580 | * Reuse the same operation ID in [`NftTransferRequest`] after confirmation so |
| 3581 | * both operations use the same deterministic TEP-62 `query_id`. |
| 3582 | */ |
| 3583 | struct NftTransferPreviewRequest { |
| 3584 | /** |
| 3585 | * Application-generated correlation identifier. |
| 3586 | */ |
| 3587 | NonEmptyString operation_id; |
| 3588 | /** |
| 3589 | * Immutable NFT transfer choices. |
| 3590 | */ |
| 3591 | NftTransferIntent intent; |
| 3592 | }; |
| 3593 |
| 3594 |
| 3595 | /** |
| 3596 | * The complete transfer intent shared by preview and signed-send operations. |
| 3597 | * |
| 3598 | * Applications can preview this value and then pass the same value to a |
| 3599 | * signed send after the user confirms it. |
| 3600 | */ |
| 3601 | struct SendIntent { |
| 3602 | /** |
| 3603 | * The expiration policy for the wallet message. |
| 3604 | */ |
| 3605 | SendExpiration expiration; |
| 3606 | /** |
| 3607 | * The non-empty ordered outgoing internal-message batch. |
| 3608 | * |
| 3609 | * Wallet V5 accepts at most 255 actions. The engine validates that limit |
| 3610 | * before emulation or secret authorization. |
| 3611 | */ |
| 3612 | std::vector<SendMessage> messages; |
| 3613 | }; |
| 3614 |
| 3615 |
| 3616 | /** |
| 3617 | * A validated internal-message signing preview without submission fee claims. |
| 3618 | */ |
| 3619 | struct SignMessagePreview { |
| 3620 | /** |
| 3621 | * The complete ordered outgoing message batch covered by the future signature. |
| 3622 | */ |
| 3623 | std::vector<SendMessage> messages; |
| 3624 | /** |
| 3625 | * The resolved Unix expiration timestamp that the signer will preserve. |
| 3626 | */ |
| 3627 | uint64_t valid_until; |
| 3628 | /** |
| 3629 | * Whether fresh account state requires the relayed message to carry wallet `StateInit`. |
| 3630 | */ |
| 3631 | bool needs_state_init; |
| 3632 | }; |
| 3633 |
| 3634 |
| 3635 | /** |
| 3636 | * Paginated wallet activity and its independent load states. |
| 3637 | */ |
| 3638 | struct ActivityList { |
| 3639 | /** |
| 3640 | * Activity in descending logical-time order with duplicate items removed. |
| 3641 | */ |
| 3642 | std::vector<ActivityItem> items; |
| 3643 | /** |
| 3644 | * The load state for the first activity page. |
| 3645 | */ |
| 3646 | ResourceState resource; |
| 3647 | /** |
| 3648 | * The load state for an additional activity page. |
| 3649 | */ |
| 3650 | ResourceState pagination_resource; |
| 3651 | /** |
| 3652 | * Whether the provider can have another activity page. |
| 3653 | */ |
| 3654 | bool has_more; |
| 3655 | }; |
| 3656 |
| 3657 |
| 3658 | /** |
| 3659 | * Requests one owner-signed TEP-62 NFT transfer. |
| 3660 | */ |
| 3661 | struct NftTransferRequest { |
| 3662 | /** |
| 3663 | * Unique idempotency identifier chosen by the application. |
| 3664 | */ |
| 3665 | NonEmptyString operation_id; |
| 3666 | /** |
| 3667 | * Allows replacement of an unresolved durable send after explicit confirmation. |
| 3668 | */ |
| 3669 | bool force; |
| 3670 | /** |
| 3671 | * Immutable NFT transfer choices. |
| 3672 | */ |
| 3673 | NftTransferIntent intent; |
| 3674 | }; |
| 3675 |
| 3676 |
| 3677 | /** |
| 3678 | * Requests signed NFT transfer delivery forms without submitting either one. |
| 3679 | */ |
| 3680 | struct PrepareNftTransferRequest { |
| 3681 | /** |
| 3682 | * Correlation identifier, shared with the preview for a stable TEP-62 query ID. |
| 3683 | */ |
| 3684 | NonEmptyString operation_id; |
| 3685 | /** |
| 3686 | * Immutable NFT transfer choices. |
| 3687 | */ |
| 3688 | NftTransferIntent intent; |
| 3689 | }; |
| 3690 |
| 3691 |
| 3692 | /** |
| 3693 | * Paginated NFT items owned by the wallet and their independent load states. |
| 3694 | */ |
| 3695 | struct NftList { |
| 3696 | /** |
| 3697 | * NFT items in descending last-transaction order. |
| 3698 | */ |
| 3699 | std::vector<NftItem> items; |
| 3700 | /** |
| 3701 | * The load state for the first NFT page. |
| 3702 | */ |
| 3703 | ResourceState resource; |
| 3704 | /** |
| 3705 | * The load state for an additional NFT page. |
| 3706 | */ |
| 3707 | ResourceState pagination_resource; |
| 3708 | /** |
| 3709 | * Whether the provider can have another NFT page. |
| 3710 | */ |
| 3711 | bool has_more; |
| 3712 | }; |
| 3713 |
| 3714 |
| 3715 | /** |
| 3716 | * An informational transfer preview produced without unlocking the wallet secret. |
| 3717 | */ |
| 3718 | struct SendPreview { |
| 3719 | /** |
| 3720 | * The complete ordered outgoing message batch that was emulated. |
| 3721 | * |
| 3722 | * This is empty for [`crate::WalletClient::preview_send_boc`] because a |
| 3723 | * caller-supplied signed message is preserved as an opaque BOC. |
| 3724 | */ |
| 3725 | std::vector<SendMessage> messages; |
| 3726 | /** |
| 3727 | * The resolved wallet message expiration timestamp used by this emulation. |
| 3728 | * A signed send resolves `EngineDefault` again from fresh provider time |
| 3729 | * and preserves the same timestamp for `Exact`. |
| 3730 | */ |
| 3731 | uint64_t valid_until; |
| 3732 | /** |
| 3733 | * The complete external message submitted for emulation. |
| 3734 | * |
| 3735 | * Intent previews use a fake signature; BOC previews preserve the caller's |
| 3736 | * exact signed message. |
| 3737 | * The value is a standard padded Base64-encoded BOC. Clients can pass it |
| 3738 | * to an independent emulator or explorer without reconstructing the message. |
| 3739 | */ |
| 3740 | Boc message_boc_base64; |
| 3741 | /** |
| 3742 | * The bounded Toncenter emulation summary shown before authorization. |
| 3743 | */ |
| 3744 | SendEmulation emulation; |
| 3745 | }; |
| 3746 |
| 3747 |
| 3748 | /** |
| 3749 | * Requests both signed delivery forms for one wallet transfer. |
| 3750 | * |
| 3751 | * The engine resolves one fresh wallet sequence number and one expiration |
| 3752 | * timestamp, then signs the transfer as both an incoming external message and |
| 3753 | * an owner-signed internal message. It does not submit or persist either BOC. |
| 3754 | */ |
| 3755 | struct PrepareTransferRequest { |
| 3756 | /** |
| 3757 | * A unique identifier chosen by the application for the prepared transfer. |
| 3758 | */ |
| 3759 | NonEmptyString operation_id; |
| 3760 | /** |
| 3761 | * The immutable messages and expiration policy covered by both signatures. |
| 3762 | */ |
| 3763 | SendIntent intent; |
| 3764 | }; |
| 3765 |
| 3766 |
| 3767 | /** |
| 3768 | * Public transfer intent used to preview a send without unlocking its secret. |
| 3769 | * |
| 3770 | * A preview uses fresh account state and a fake signature. It does not reserve |
| 3771 | * an operation identifier, read the send journal, or request the mnemonic. |
| 3772 | */ |
| 3773 | struct SendPreviewRequest { |
| 3774 | /** |
| 3775 | * The same immutable intent accepted by the signed-send operation. |
| 3776 | */ |
| 3777 | SendIntent intent; |
| 3778 | }; |
| 3779 |
| 3780 |
| 3781 | /** |
| 3782 | * An immutable view of all observable state in one wallet client. |
| 3783 | * |
| 3784 | * Each published change increments `revision`. A failed refresh preserves |
| 3785 | * the last successful resource value and changes its resource state. |
| 3786 | */ |
| 3787 | struct WalletSnapshot { |
| 3788 | /** |
| 3789 | * A client-local counter that increases for every published state change. |
| 3790 | */ |
| 3791 | uint64_t revision; |
| 3792 | /** |
| 3793 | * The stable application record identifier. |
| 3794 | */ |
| 3795 | NonEmptyString record_id; |
| 3796 | /** |
| 3797 | * The wallet address. |
| 3798 | */ |
| 3799 | TonAddressString address; |
| 3800 | /** |
| 3801 | * The wallet network. |
| 3802 | */ |
| 3803 | Network network; |
| 3804 | /** |
| 3805 | * The latest successful account value, if available. |
| 3806 | */ |
| 3807 | std::optional<AccountSnapshot> account; |
| 3808 | /** |
| 3809 | * The load state for `account`. |
| 3810 | */ |
| 3811 | ResourceState account_resource; |
| 3812 | /** |
| 3813 | * Paginated wallet activity. |
| 3814 | */ |
| 3815 | ActivityList activity; |
| 3816 | /** |
| 3817 | * The cursor for the next older activity page. |
| 3818 | */ |
| 3819 | std::optional<ActivityCursor> activity_cursor; |
| 3820 | /** |
| 3821 | * Paginated NFT items owned by the wallet. |
| 3822 | */ |
| 3823 | NftList nfts; |
| 3824 | /** |
| 3825 | * The current transfer workflow state. |
| 3826 | */ |
| 3827 | SendSnapshot send; |
| 3828 | }; |
| 3829 |
| 3830 |
| 3831 | /** |
| 3832 | * Requests an owner-signed Wallet V5 message for delivery by a relayer. |
| 3833 | */ |
| 3834 | struct SignMessageRequest { |
| 3835 | /** |
| 3836 | * A unique idempotency identifier chosen by the application. |
| 3837 | */ |
| 3838 | NonEmptyString operation_id; |
| 3839 | /** |
| 3840 | * Allows this request to replace an earlier signed message whose outcome is unresolved. |
| 3841 | * |
| 3842 | * The earlier message remains valid until its expiration time and can win |
| 3843 | * the sequence-number race. Require explicit user confirmation before use. |
| 3844 | */ |
| 3845 | bool force; |
| 3846 | /** |
| 3847 | * The immutable messages and expiration boundary covered by the signature. |
| 3848 | */ |
| 3849 | SendIntent intent; |
| 3850 | }; |
| 3851 |
| 3852 |
| 3853 | /** |
| 3854 | * Requests one signed wallet transfer. |
| 3855 | */ |
| 3856 | struct SendRequest { |
| 3857 | /** |
| 3858 | * A unique idempotency identifier chosen by the application. |
| 3859 | */ |
| 3860 | NonEmptyString operation_id; |
| 3861 | /** |
| 3862 | * Allows this send to replace an earlier signed send whose on-chain outcome is unresolved. |
| 3863 | * |
| 3864 | * The earlier send can still execute. Require explicit user confirmation |
| 3865 | * before setting this flag because both transfers can affect the balance. |
| 3866 | */ |
| 3867 | bool force; |
| 3868 | /** |
| 3869 | * The immutable message and expiration choices for this operation. |
| 3870 | */ |
| 3871 | SendIntent intent; |
| 3872 | }; |
| 3873 |
| 3874 |
| 3875 | /** |
| 3876 | * The result of a refresh or pagination operation and its resulting snapshot. |
| 3877 | */ |
| 3878 | struct WalletUpdate { |
| 3879 | /** |
| 3880 | * The terminal operation outcome. |
| 3881 | */ |
| 3882 | WalletOperationOutcome outcome; |
| 3883 | /** |
| 3884 | * The number of new unique activity items added by pagination. |
| 3885 | */ |
| 3886 | uint64_t activity_items_added; |
| 3887 | /** |
| 3888 | * The number of new unique NFT items added by pagination. |
| 3889 | */ |
| 3890 | uint64_t nft_items_added; |
| 3891 | /** |
| 3892 | * The immutable snapshot after the operation. |
| 3893 | */ |
| 3894 | WalletSnapshot snapshot; |
| 3895 | }; |
| 3896 |
| 3897 | namespace uniffi { |
| 3898 | struct FfiConverterTonConnectIncomingRequest; |
| 3899 | } // namespace uniffi |
| 3900 |
| 3901 | /** |
| 3902 | * One replay-safe authenticated request awaiting a wallet response. |
| 3903 | */ |
| 3904 | struct TonConnectIncomingRequest { |
| 3905 | friend uniffi::FfiConverterTonConnectIncomingRequest; |
| 3906 | /** |
| 3907 | * A raw `sendTransaction` request that the wallet signs and submits. |
| 3908 | */ |
| 3909 | struct kSendTransaction { |
| 3910 | /** |
| 3911 | * Exact dApp request identifier. |
| 3912 | */ |
| 3913 | std::string id; |
| 3914 | /** |
| 3915 | * Exact RPC method name. |
| 3916 | */ |
| 3917 | std::string method; |
| 3918 | /** |
| 3919 | * Validated wallet send operation. |
| 3920 | */ |
| 3921 | SendRequest request; |
| 3922 | }; |
| 3923 | /** |
| 3924 | * A raw `signMessage` request that the wallet signs without submitting. |
| 3925 | */ |
| 3926 | struct kSignMessage { |
| 3927 | /** |
| 3928 | * Exact dApp request identifier. |
| 3929 | */ |
| 3930 | std::string id; |
| 3931 | /** |
| 3932 | * Exact RPC method name. |
| 3933 | */ |
| 3934 | std::string method; |
| 3935 | /** |
| 3936 | * Validated internal-message signing operation. |
| 3937 | */ |
| 3938 | SignMessageRequest request; |
| 3939 | }; |
| 3940 | /** |
| 3941 | * A dApp-initiated disconnect request. |
| 3942 | */ |
| 3943 | struct kDisconnect { |
| 3944 | /** |
| 3945 | * Exact dApp request identifier. |
| 3946 | */ |
| 3947 | std::string id; |
| 3948 | /** |
| 3949 | * Exact RPC method name. |
| 3950 | */ |
| 3951 | std::string method; |
| 3952 | }; |
| 3953 | /** |
| 3954 | * A malformed or unsupported RPC request with its protocol response. |
| 3955 | */ |
| 3956 | struct kUnsupported { |
| 3957 | /** |
| 3958 | * Exact dApp request identifier. |
| 3959 | */ |
| 3960 | std::string id; |
| 3961 | /** |
| 3962 | * Exact RPC method name. |
| 3963 | */ |
| 3964 | std::string method; |
| 3965 | /** |
| 3966 | * Recommended TON Connect RPC error. |
| 3967 | */ |
| 3968 | TonConnectRpcErrorCode error_code; |
| 3969 | /** |
| 3970 | * Sanitized protocol diagnostic. |
| 3971 | */ |
| 3972 | std::string error_message; |
| 3973 | }; |
| 3974 | /** |
| 3975 | * A validated `signData` request of a derived session; the classic session reports it as `Unsupported`. |
| 3976 | */ |
| 3977 | struct kSignData { |
| 3978 | /** |
| 3979 | * Exact dApp request identifier. |
| 3980 | */ |
| 3981 | std::string id; |
| 3982 | /** |
| 3983 | * Exact RPC method name. |
| 3984 | */ |
| 3985 | std::string method; |
| 3986 | /** |
| 3987 | * Validated data to show and sign. |
| 3988 | */ |
| 3989 | TonConnectSignDataRequest request; |
| 3990 | }; |
| 3991 | TonConnectIncomingRequest(kSendTransaction variant): variant(variant) {} |
| 3992 | TonConnectIncomingRequest(kSignMessage variant): variant(variant) {} |
| 3993 | TonConnectIncomingRequest(kDisconnect variant): variant(variant) {} |
| 3994 | TonConnectIncomingRequest(kUnsupported variant): variant(variant) {} |
| 3995 | TonConnectIncomingRequest(kSignData variant): variant(variant) {} |
| 3996 |
| 3997 | TonConnectIncomingRequest(const TonConnectIncomingRequest &other): variant(other.variant) {} |
| 3998 | TonConnectIncomingRequest(TonConnectIncomingRequest &&other): variant(std::move(other.variant)) {} |
| 3999 |
| 4000 | TonConnectIncomingRequest &operator=(const TonConnectIncomingRequest &other) { |
| 4001 | variant = other.variant; |
| 4002 | return *this; |
| 4003 | } |
| 4004 |
| 4005 | TonConnectIncomingRequest &operator=(TonConnectIncomingRequest &&other) { |
| 4006 | variant = std::move(other.variant); |
| 4007 | return *this; |
| 4008 | } |
| 4009 |
| 4010 | /** |
| 4011 | * Returns the variant of this enum |
| 4012 | */ |
| 4013 | const std::variant<kSendTransaction, kSignMessage, kDisconnect, kUnsupported, kSignData> &get_variant() const { |
| 4014 | return variant; |
| 4015 | } |
| 4016 |
| 4017 | private: |
| 4018 | std::variant<kSendTransaction, kSignMessage, kDisconnect, kUnsupported, kSignData> variant; |
| 4019 |
| 4020 | TonConnectIncomingRequest(); |
| 4021 | }; |
| 4022 |
| 4023 |
| 4024 | /** |
| 4025 | * One authenticated dApp request relayed by the server. |
| 4026 | */ |
| 4027 | struct TonConnectDerivedRequest { |
| 4028 | /** |
| 4029 | * The validated request. Only a derived session reports `SignData`; the |
| 4030 | * classic bridge session reports `signData` as `Unsupported`. |
| 4031 | */ |
| 4032 | TonConnectIncomingRequest request; |
| 4033 | /** |
| 4034 | * The request `id` as a signed 64-bit value. |
| 4035 | * |
| 4036 | * `None` when `id` is not a canonical decimal that fits a signed 64-bit |
| 4037 | * value; `request` is still decoded so the host can answer with the exact |
| 4038 | * id string. |
| 4039 | */ |
| 4040 | std::optional<int64_t> request_id; |
| 4041 | }; |
| 4042 |
| 4043 |
| 4044 | namespace uniffi { |
| 4045 | struct FfiConverterTonConnectDerivedSession; |
| 4046 | } // namespace uniffi |
| 4047 |
| 4048 | /** |
| 4049 | * One `MTProto`-relayed TON Connect session whose key pair was derived from the wallet key. |
| 4050 | * |
| 4051 | * The object keeps no replay state and no event counter: the server issues event |
| 4052 | * identifiers and enforces request ordering. Nothing here is persisted. |
| 4053 | */ |
| 4054 | struct TonConnectDerivedSession |
| 4055 |
| 4056 |
| 4057 |
| 4058 | { |
| 4059 | friend uniffi::FfiConverterTonConnectDerivedSession; |
| 4060 |
| 4061 | TonConnectDerivedSession() = delete; |
| 4062 |
| 4063 | TonConnectDerivedSession(TonConnectDerivedSession &&) = delete; |
| 4064 |
| 4065 | TonConnectDerivedSession &operator=(const TonConnectDerivedSession &) = delete; |
| 4066 | TonConnectDerivedSession &operator=(TonConnectDerivedSession &&) = delete; |
| 4067 |
| 4068 | ~TonConnectDerivedSession(); |
| 4069 | /** |
| 4070 | * Opens an opaque MTProto envelope for hosts that own RPC decoding. |
| 4071 | * In particular, Gram Wallet also supports relayed `signMessage`. |
| 4072 | */ |
| 4073 | std::vector<uint8_t> decrypt_envelope(const std::vector<uint8_t> &body); |
| 4074 | /** |
| 4075 | * Authenticates and validates one dApp request relayed by the server. |
| 4076 | * |
| 4077 | * `body` is the raw `nonce(24) || box` bytes from the dApp; `now` is the |
| 4078 | * current Unix time used for `valid_until` validation. |
| 4079 | */ |
| 4080 | TonConnectDerivedRequest decrypt_request(const std::vector<uint8_t> &body, uint64_t now); |
| 4081 | /** |
| 4082 | * Encrypts a failed-connection event for the dApp. |
| 4083 | */ |
| 4084 | std::vector<uint8_t> encrypt_connect_error(uint64_t event_id, const TonConnectConnectErrorCode &code, const std::string &message); |
| 4085 | /** |
| 4086 | * Encrypts a successful connect event for the dApp. |
| 4087 | * |
| 4088 | * `account` must belong to this session; `proof` is included when the |
| 4089 | * dApp requested `ton_proof`. The device advertises `SendTransaction` and |
| 4090 | * `SignData` (`text`, `binary`, `cell`). |
| 4091 | */ |
| 4092 | std::vector<uint8_t> encrypt_connect_event(uint64_t event_id, const TonConnectAccountInfo &account, std::optional<TonConnectProofReply> proof, const TonConnectDevice &device); |
| 4093 | /** |
| 4094 | * Encrypts a wallet-initiated disconnect event. |
| 4095 | */ |
| 4096 | std::vector<uint8_t> encrypt_disconnect_event(uint64_t event_id); |
| 4097 | /** |
| 4098 | * Encrypts the empty-object result of a dApp-initiated disconnect request. |
| 4099 | */ |
| 4100 | std::vector<uint8_t> encrypt_disconnect_success(const std::string &request_id); |
| 4101 | /** |
| 4102 | * Seals a host-validated protocol envelope without exporting session keys. |
| 4103 | */ |
| 4104 | std::vector<uint8_t> encrypt_envelope(const std::vector<uint8_t> &body); |
| 4105 | /** |
| 4106 | * Encrypts a protocol RPC error response for the selected request. |
| 4107 | */ |
| 4108 | std::vector<uint8_t> encrypt_error(const std::string &request_id, const TonConnectRpcErrorCode &code, const std::string &message); |
| 4109 | /** |
| 4110 | * Encrypts a successful `sendTransaction` response carrying the signed `BoC`. |
| 4111 | */ |
| 4112 | std::vector<uint8_t> encrypt_send_success(const std::string &request_id, const std::string &signed_boc); |
| 4113 | /** |
| 4114 | * Encrypts a successful `signData` response for the signed data. |
| 4115 | * |
| 4116 | * The response names this session's wallet address. It is refused unless |
| 4117 | * the request still matches this session's network and wallet and |
| 4118 | * `signed_data.signature` verifies with this session's signing public key |
| 4119 | * for exactly that address, request, domain, and timestamp. |
| 4120 | */ |
| 4121 | std::vector<uint8_t> encrypt_sign_data_success(const std::string &request_id, const TonConnectSignedData &signed_data); |
| 4122 | /** |
| 4123 | * Opens a server challenge and returns its 32-byte answer. |
| 4124 | * |
| 4125 | * `challenge` is exactly `ephemeral_pk(32) || nonce(24) || box(48)`: a |
| 4126 | * 32-byte answer sealed to `W` under an ephemeral key. |
| 4127 | */ |
| 4128 | std::vector<uint8_t> open_challenge(const std::vector<uint8_t> &challenge); |
| 4129 | /** |
| 4130 | * Returns the session public key `W` as 64 lowercase hex characters. |
| 4131 | */ |
| 4132 | std::string public_key_hex(); |
| 4133 | /** |
| 4134 | * Returns the 32-byte Ed25519 signing public key the session was derived from. |
| 4135 | */ |
| 4136 | std::vector<uint8_t> signing_public_key(); |
| 4137 |
| 4138 | private: |
| 4139 | TonConnectDerivedSession(const TonConnectDerivedSession &); |
| 4140 |
| 4141 | TonConnectDerivedSession(uint64_t); |
| 4142 |
| 4143 | uint64_t _uniffi_internal_clone_pointer() const; |
| 4144 |
| 4145 | uint64_t instance = 0; |
| 4146 | }; |
| 4147 |
| 4148 |
| 4149 | namespace uniffi { |
| 4150 | struct FfiConverterTonConnectSession; |
| 4151 | } // namespace uniffi |
| 4152 |
| 4153 | /** |
| 4154 | * Thread-safe TON Connect session exposed to Swift, Kotlin, and other hosts. |
| 4155 | */ |
| 4156 | struct TonConnectSession |
| 4157 |
| 4158 |
| 4159 |
| 4160 | { |
| 4161 | friend uniffi::FfiConverterTonConnectSession; |
| 4162 |
| 4163 | TonConnectSession() = delete; |
| 4164 |
| 4165 | TonConnectSession(TonConnectSession &&) = delete; |
| 4166 |
| 4167 | TonConnectSession &operator=(const TonConnectSession &) = delete; |
| 4168 | TonConnectSession &operator=(TonConnectSession &&) = delete; |
| 4169 |
| 4170 | ~TonConnectSession(); |
| 4171 | /** |
| 4172 | * Approves the connect request and keeps its encrypted response pending delivery. |
| 4173 | * |
| 4174 | * Persist the session before posting the returned response. After the |
| 4175 | * bridge accepts it, call [`Self::complete_pending_post`]. |
| 4176 | */ |
| 4177 | TonConnectPreparedPost approve_connect(const TonConnectAccountInfo &account, std::optional<TonConnectProofReply> proof, const TonConnectDevice &device); |
| 4178 | /** |
| 4179 | * Returns a complete SSE subscription URL and resets stream framing. |
| 4180 | */ |
| 4181 | std::string begin_events_subscription(); |
| 4182 | /** |
| 4183 | * Removes the pending response after the bridge accepts it. |
| 4184 | */ |
| 4185 | void complete_pending_post(); |
| 4186 | /** |
| 4187 | * Returns the initial connect prompt while approval is pending. |
| 4188 | */ |
| 4189 | std::optional<TonConnectConnectPrompt> connect_prompt(); |
| 4190 | /** |
| 4191 | * Keeps a wallet-initiated disconnect event pending bridge delivery. |
| 4192 | */ |
| 4193 | TonConnectPreparedPost disconnect(); |
| 4194 | /** |
| 4195 | * Ingests an SSE chunk and returns only fresh authenticated requests. |
| 4196 | */ |
| 4197 | std::vector<TonConnectIncomingRequest> ingest_sse_chunk(const std::vector<uint8_t> &chunk, uint64_t now); |
| 4198 | /** |
| 4199 | * Returns the exact response that must be retried before reading more events. |
| 4200 | */ |
| 4201 | std::optional<TonConnectPreparedPost> pending_post(); |
| 4202 | /** |
| 4203 | * Returns restored requests that still await a wallet response. |
| 4204 | */ |
| 4205 | std::vector<TonConnectIncomingRequest> pending_requests(uint64_t now); |
| 4206 | /** |
| 4207 | * Serializes the secret-bearing session, requests, and pending response. |
| 4208 | */ |
| 4209 | std::string persisted(); |
| 4210 | /** |
| 4211 | * Returns the current lifecycle phase. |
| 4212 | */ |
| 4213 | TonConnectSessionPhase phase(); |
| 4214 | /** |
| 4215 | * Keeps a successful dApp-initiated disconnect response pending delivery. |
| 4216 | */ |
| 4217 | TonConnectPreparedPost prepare_disconnect_success(const std::string &request_id); |
| 4218 | /** |
| 4219 | * Keeps a protocol RPC error pending delivery for the selected request. |
| 4220 | */ |
| 4221 | TonConnectPreparedPost prepare_error(const std::string &request_id, const TonConnectRpcErrorCode &code, const std::string &message); |
| 4222 | /** |
| 4223 | * Keeps a successful `sendTransaction` response pending bridge delivery. |
| 4224 | * |
| 4225 | * The response contains the exact signed BOC returned to the dApp. |
| 4226 | */ |
| 4227 | TonConnectPreparedPost prepare_send_success(const std::string &request_id, const std::string &signed_boc); |
| 4228 | /** |
| 4229 | * Keeps a successful `signMessage` response pending bridge delivery. |
| 4230 | * |
| 4231 | * `internal_boc` must contain the complete signed internal message |
| 4232 | * returned by [`crate::WalletClient::sign_message`]. |
| 4233 | */ |
| 4234 | TonConnectPreparedPost prepare_sign_message_success(const std::string &request_id, const std::string &internal_boc); |
| 4235 | /** |
| 4236 | * Rejects the initial connection and keeps its terminal event pending delivery. |
| 4237 | * |
| 4238 | * Persist the session before posting the returned response. After the |
| 4239 | * bridge accepts it, call [`Self::complete_pending_post`]. |
| 4240 | */ |
| 4241 | TonConnectPreparedPost reject_connect(const std::string &message); |
| 4242 |
| 4243 | private: |
| 4244 | TonConnectSession(const TonConnectSession &); |
| 4245 |
| 4246 | TonConnectSession(uint64_t); |
| 4247 |
| 4248 | uint64_t _uniffi_internal_clone_pointer() const; |
| 4249 |
| 4250 | uint64_t instance = 0; |
| 4251 | }; |
| 4252 |
| 4253 |
| 4254 | namespace uniffi { |
| 4255 | struct FfiConverterWalletClient; |
| 4256 | } // namespace uniffi |
| 4257 |
| 4258 | /** |
| 4259 | * Coordinates state and operations for one wallet record. |
| 4260 | * |
| 4261 | * The client owns no transport or platform resources. Call [`Self::shutdown`] |
| 4262 | * before the host releases callback objects or application services. |
| 4263 | */ |
| 4264 | struct WalletClient |
| 4265 |
| 4266 |
| 4267 |
| 4268 | { |
| 4269 | friend uniffi::FfiConverterWalletClient; |
| 4270 |
| 4271 | WalletClient() = delete; |
| 4272 |
| 4273 | WalletClient(WalletClient &&) = delete; |
| 4274 |
| 4275 | WalletClient &operator=(const WalletClient &) = delete; |
| 4276 | WalletClient &operator=(WalletClient &&) = delete; |
| 4277 |
| 4278 | ~WalletClient(); |
| 4279 | /** |
| 4280 | * Creates a client after validation of identifiers, URLs, and credential origin. |
| 4281 | * |
| 4282 | * The initial snapshot has revision zero and idle resource states. |
| 4283 | */ |
| 4284 | static std::shared_ptr<WalletClient> init(const WalletClientConfig &config, const std::shared_ptr<WalletHttpHost> &http_host, const std::shared_ptr<WalletPlatformHost> &platform_host); |
| 4285 | /** |
| 4286 | * Creates a client backed by a provider transport without HTTP metadata. |
| 4287 | * |
| 4288 | * Use this constructor for a relay or protocol proxy that can return only |
| 4289 | * a response body or an opaque transport error. The engine does not apply |
| 4290 | * HTTP status, header, redirect, or final-URL checks in this mode. |
| 4291 | */ |
| 4292 | static std::shared_ptr<WalletClient> new_statusless(const WalletClientConfig &config, const std::shared_ptr<WalletStatuslessHost> &statusless_host, const std::shared_ptr<WalletPlatformHost> &platform_host); |
| 4293 | /** |
| 4294 | * Cancels the active activity page load. |
| 4295 | * |
| 4296 | * This method has no effect when no page load is active. |
| 4297 | */ |
| 4298 | void cancel_load_more_activity(); |
| 4299 | /** |
| 4300 | * Loads the next older activity page and merges unique items by item ID. |
| 4301 | * |
| 4302 | * The method returns `Skipped` during refresh, during another page load, |
| 4303 | * or when no advancing cursor exists. A page must move to an older logical |
| 4304 | * time. Otherwise pagination stops and adds no items. |
| 4305 | */ |
| 4306 | WalletUpdate load_more_activity(); |
| 4307 | /** |
| 4308 | * Stops new work, cancels active host requests, and releases snapshot waiters. |
| 4309 | * |
| 4310 | * The operation is idempotent. It cancels reversible work immediately. |
| 4311 | * If a send crossed its durable commit boundary, shutdown rejects new |
| 4312 | * operations and waits for that send to reach a terminal journal state. |
| 4313 | */ |
| 4314 | void shutdown(); |
| 4315 | /** |
| 4316 | * Returns a clone of the current immutable snapshot. |
| 4317 | * |
| 4318 | * A returned snapshot never changes. Read a newer snapshot to observe a |
| 4319 | * higher revision. |
| 4320 | */ |
| 4321 | WalletSnapshot snapshot(); |
| 4322 | /** |
| 4323 | * Waits until the snapshot revision is greater than `after_revision`. |
| 4324 | * |
| 4325 | * This method returns immediately when a newer revision already exists. |
| 4326 | * Shutdown releases all waiters and returns [`WalletClientError::Shutdown`]. |
| 4327 | */ |
| 4328 | WalletSnapshot wait_for_change(uint64_t after_revision); |
| 4329 | /** |
| 4330 | * Resolves the standard TON DNS `wallet` record for a `.ton` name. |
| 4331 | * |
| 4332 | * The operation is read-only and never requests protected wallet secrets. |
| 4333 | * It uses the configured or network-default root resolver, then asks the |
| 4334 | * configured provider to perform bounded DNS recursion. |
| 4335 | */ |
| 4336 | std::optional<TonAddressString> resolve_dns(const std::string &name); |
| 4337 | /** |
| 4338 | * Creates a TON encrypted-comment body ready for `SendMessageBody::RawPayload`. |
| 4339 | * |
| 4340 | * The engine uses the supplied recipient public key or calls the recipient |
| 4341 | * wallet's `get_public_key` get-method, then asks the platform host to |
| 4342 | * authorize this wallet's protected mnemonic. The sender key is this |
| 4343 | * wallet's current signing key. |
| 4344 | * The host authenticates supplied recipient keys, including rotated keys. |
| 4345 | * No secret is requested when the comment is already too large. |
| 4346 | * The recipient key is resolved exactly as |
| 4347 | * [`Self::resolve_encrypted_comment_recipient`] resolves it, including its |
| 4348 | * errors, and before any secret is requested. |
| 4349 | */ |
| 4350 | Boc create_encrypted_comment(const CreateEncryptedCommentRequest &request); |
| 4351 | /** |
| 4352 | * Decrypts one TON encrypted-comment body after explicit host authorization. |
| 4353 | * |
| 4354 | * The caller supplies the sender address because TON uses its bounceable, |
| 4355 | * URL-safe, non-test-only representation as authenticated salt. |
| 4356 | * |
| 4357 | * The body may use any signing key this wallet ever had. The engine first |
| 4358 | * tries the current signing key and the anchor key, which the recovery |
| 4359 | * phrase holds, without any HTTP request. When neither matches and the |
| 4360 | * wallet has rotated its key, the engine reads the wallet's |
| 4361 | * `change_wallet_key` actions from Toncenter v3, recovers each earlier |
| 4362 | * signing key from the encrypted old key its rotation published, and tries |
| 4363 | * those. The secret is read once per call and recovered keys never leave |
| 4364 | * it. The history holds no secret; later calls reuse it while it still |
| 4365 | * contains the rotation that installed the current signing key. |
| 4366 | * |
| 4367 | * `EncryptedCommentLookupFailed` means the provider did not answer or did |
| 4368 | * not return a history that reaches the current signing key yet; a retry |
| 4369 | * can succeed. |
| 4370 | * `EncryptedCommentUnavailable` means no key of this wallet decrypts the |
| 4371 | * body or the body is malformed. |
| 4372 | */ |
| 4373 | std::string decrypt_comment(const DecryptCommentRequest &request); |
| 4374 | /** |
| 4375 | * Resolves the Ed25519 public key an encrypted comment for a recipient uses. |
| 4376 | * |
| 4377 | * This answers whether [`Self::create_encrypted_comment`] with the same |
| 4378 | * recipient and supplied key can encrypt, without a comment and without |
| 4379 | * requesting any protected secret, so a client configured without a local |
| 4380 | * signing secret can ask it too. A supplied key is verified locally, with |
| 4381 | * no HTTP request and without the single-flight slot. Otherwise the engine |
| 4382 | * reads the recipient account state and, for an active contract, calls its |
| 4383 | * `get_public_key` get-method. |
| 4384 | * |
| 4385 | * `EncryptedCommentUnavailable` means the recipient cannot receive an |
| 4386 | * encrypted comment: the supplied key does not derive its address, its |
| 4387 | * wallet is not deployed or is frozen, or its contract did not return a |
| 4388 | * public key. `EncryptedCommentLookupFailed` means the provider did not |
| 4389 | * answer and nothing is known about the recipient. |
| 4390 | */ |
| 4391 | std::vector<uint8_t> resolve_encrypted_comment_recipient(const EncryptedCommentRecipientRequest &request); |
| 4392 | /** |
| 4393 | * Generates one new signing half and both signed Wallet rev00 delivery forms. |
| 4394 | * `signed_boc` aliases the form selected by `request.message_kind`. |
| 4395 | * |
| 4396 | * The client first fetches fresh account state through its configured |
| 4397 | * provider. Active wallets use the on-chain `seqno` getter, while an |
| 4398 | * account without deployed contract code uses sequence number zero and |
| 4399 | * attaches anchor-based `StateInit`; only the initial 12-word phrase can |
| 4400 | * sign such a deploying request, so a post-rotation phrase then fails with |
| 4401 | * `KeyRotationUnavailable`. The client then asks the host to unlock the |
| 4402 | * protected phrase. It does not update protected storage and does not |
| 4403 | * submit the returned BOC. |
| 4404 | * |
| 4405 | * The request, signed with the current signing key, carries the new key's |
| 4406 | * wallet-address proof signature and the current signing key encrypted |
| 4407 | * with the new one as |
| 4408 | * `sha256(new_private_key ‖ "keyChangeSaltV1") XOR old_private_key`. |
| 4409 | * The contract revision with bytecode hash |
| 4410 | * `e30911420bef1191c09dce58b9df2b4ca4c2d9c383cc3b6a91170349ffa70e2c` |
| 4411 | * publishes that value in its key-changed log, which lets |
| 4412 | * [`WalletClient::decrypt_comment`] recover the replaced key later. |
| 4413 | */ |
| 4414 | PreparedKeyRotation prepare_key_rotation(const PrepareKeyRotationRequest &request); |
| 4415 | /** |
| 4416 | * Cancels the active additional-page NFT load. |
| 4417 | * |
| 4418 | * This method has no effect when no NFT page load is active. |
| 4419 | */ |
| 4420 | void cancel_load_more_nfts(); |
| 4421 | /** |
| 4422 | * Cancels the active first-page NFT refresh. |
| 4423 | * |
| 4424 | * This method has no effect when no NFT refresh is active. |
| 4425 | */ |
| 4426 | void cancel_refresh_nfts(); |
| 4427 | /** |
| 4428 | * Loads the next NFT page and appends items not already present by address. |
| 4429 | * |
| 4430 | * The method returns `Skipped` during an NFT refresh, during another NFT |
| 4431 | * page load, or after the provider returns a short page. |
| 4432 | */ |
| 4433 | WalletUpdate load_more_nfts(); |
| 4434 | /** |
| 4435 | * Loads the newest page of NFTs owned by this wallet. |
| 4436 | * |
| 4437 | * This operation is independent from [`Self::refresh`], so applications |
| 4438 | * can load account, activity, and NFT data concurrently. A newer NFT |
| 4439 | * refresh supersedes the older one and cancels its host request. |
| 4440 | */ |
| 4441 | WalletUpdate refresh_nfts(); |
| 4442 | /** |
| 4443 | * Validates ownership and emulation, then signs external and internal delivery |
| 4444 | * alternatives without broadcasting or writing the send journal. |
| 4445 | */ |
| 4446 | PreparedTransfer prepare_nft_transfer(const PrepareNftTransferRequest &request); |
| 4447 | /** |
| 4448 | * Validates current ownership and emulates one typed TEP-62 NFT transfer. |
| 4449 | * |
| 4450 | * Reuse this request's operation ID for [`Self::send_nft_transfer`] after |
| 4451 | * user confirmation so the TEP-62 query ID remains unchanged. |
| 4452 | */ |
| 4453 | SendPreview preview_nft_transfer(const NftTransferPreviewRequest &request); |
| 4454 | /** |
| 4455 | * Revalidates current ownership and signs/submits one typed TEP-62 transfer. |
| 4456 | * |
| 4457 | * Provider acceptance confirms the source wallet message, not final NFT |
| 4458 | * ownership. Applications must refresh NFT state after confirmation. |
| 4459 | */ |
| 4460 | SendResult send_nft_transfer(const NftTransferRequest &request); |
| 4461 | /** |
| 4462 | * Signs external and internal delivery forms without submitting either one. |
| 4463 | * |
| 4464 | * The client fetches account state and `seqno` once, resolves one |
| 4465 | * `valid_until`, and unlocks the protected phrase once. Both returned BOCs |
| 4466 | * therefore authorize the same transfer and are mutually exclusive |
| 4467 | * delivery alternatives. This method does not read or write the send |
| 4468 | * journal and does not submit either message. |
| 4469 | */ |
| 4470 | PreparedTransfer prepare_transfer(const PrepareTransferRequest &request); |
| 4471 | /** |
| 4472 | * Cancels the current send preview and its active provider request. |
| 4473 | */ |
| 4474 | void cancel_send_preview(); |
| 4475 | /** |
| 4476 | * Emulates external key rotation using public state and zero signatures. |
| 4477 | * Never unlocks a secret, generates a replacement phrase, or submits a BOC. |
| 4478 | */ |
| 4479 | SendPreview preview_key_rotation(); |
| 4480 | /** |
| 4481 | * Emulates a transfer without reading the journal or protected secret. |
| 4482 | * |
| 4483 | * The engine fetches fresh account state and seqno, builds a complete |
| 4484 | * Wallet message with a fake signature, and asks Toncenter to execute it. |
| 4485 | * Calling [`Self::send`] later repeats the chain-state checks and builds a |
| 4486 | * new message from fresh state before the real signature is created. |
| 4487 | */ |
| 4488 | SendPreview preview_send(const SendPreviewRequest &request); |
| 4489 | /** |
| 4490 | * Emulates an already signed external-message BOC without submitting it. |
| 4491 | * |
| 4492 | * The request is validated against the configured source and fresh wallet |
| 4493 | * seqno and provider time. The exact BOC is sent only to the emulation |
| 4494 | * endpoint; this operation does not read or write the journal and does not |
| 4495 | * publish the message to the network. The operation identifier and force |
| 4496 | * flag are ignored, so the same request can be reused with [`Self::send_boc`]. |
| 4497 | */ |
| 4498 | SendPreview preview_send_boc(const SendBocRequest &request); |
| 4499 | /** |
| 4500 | * Validates an internal-message signing request from fresh public state. |
| 4501 | * |
| 4502 | * No wallet-paid fee estimate is returned because a relayer supplies the |
| 4503 | * TON attached to the internal request. Signing repeats these checks and |
| 4504 | * reads the protected secret only after host approval. |
| 4505 | */ |
| 4506 | SignMessagePreview preview_sign_message(const SendPreviewRequest &request); |
| 4507 | /** |
| 4508 | * Emulates the exact transfer fields supplied by a TON Connect request. |
| 4509 | * |
| 4510 | * The preview preserves the dApp validity boundary, payload, and |
| 4511 | * destination `StateInit`. It does not consume the operation identifier. |
| 4512 | */ |
| 4513 | SendPreview preview_ton_connect(const SendRequest &request); |
| 4514 | /** |
| 4515 | * Cancels the active refresh and requests cancellation of its provider requests. |
| 4516 | * |
| 4517 | * This method has no effect when no refresh is active. |
| 4518 | */ |
| 4519 | void cancel_refresh(); |
| 4520 | /** |
| 4521 | * Refreshes account and first-page activity data concurrently. |
| 4522 | * |
| 4523 | * Each resource publishes independently. One request can succeed while |
| 4524 | * the other fails, which produces [`WalletOperationOutcome::PartiallyCompleted`]. |
| 4525 | * A newer refresh supersedes the older refresh and cancels its host requests. |
| 4526 | */ |
| 4527 | WalletUpdate refresh(); |
| 4528 | /** |
| 4529 | * Resolves the durable outgoing message from chain evidence without signing. |
| 4530 | * |
| 4531 | * The operation is idempotent. It never reads protected secret storage and |
| 4532 | * commits terminal evidence with compare-and-swap journal transitions. |
| 4533 | */ |
| 4534 | SendSnapshot resolve_pending(); |
| 4535 | /** |
| 4536 | * Cancels the active send before its durable commit boundary. |
| 4537 | * |
| 4538 | * After journal persistence starts, this method returns |
| 4539 | * [`WalletClientError::SendCancellationTooLate`]. The caller must let the |
| 4540 | * send finish because the signed BOC can already be durable or submitted. |
| 4541 | */ |
| 4542 | void cancel_send(); |
| 4543 | /** |
| 4544 | * Signs, records, and submits one wallet transfer. |
| 4545 | * |
| 4546 | * A preceding [`Self::preview_send`] is an informational UI step, not a |
| 4547 | * prerequisite. This method independently reloads account state and seqno, |
| 4548 | * calculates a new validity window, and builds the real message only after |
| 4549 | * protected-secret authorization. |
| 4550 | * |
| 4551 | * A transport error after submission produces `SubmissionUnknown`. A later |
| 4552 | * [`Self::resolve_pending`] call, refresh, or send attempt can reconcile the |
| 4553 | * persisted message against provider evidence. By default, the unresolved |
| 4554 | * send blocks a new signature. `SendRequest::force` overrides that block |
| 4555 | * after the application obtains explicit user confirmation. |
| 4556 | * |
| 4557 | * Workflow failures return a typed send error. The same bounded diagnostic |
| 4558 | * is published in `snapshot().send.error_message`. |
| 4559 | */ |
| 4560 | SendResult send(const SendRequest &request); |
| 4561 | /** |
| 4562 | * Durably records and submits an already signed external-message BOC. |
| 4563 | * |
| 4564 | * The request must carry the exact `seqno` and expiration covered by the |
| 4565 | * BOC. The engine validates them against fresh provider state, stores the |
| 4566 | * exact BOC in the wallet-wide journal before provider handoff, and exposes |
| 4567 | * the normal pending-resolution and cancellation behavior. |
| 4568 | */ |
| 4569 | SendResult send_boc(const SendBocRequest &request); |
| 4570 | /** |
| 4571 | * Signs and durably records a Wallet V5 `internal_signed` request. |
| 4572 | * |
| 4573 | * This method does not submit the message. The returned BOC is a complete |
| 4574 | * relaxed internal message that the caller can give to a relayer until |
| 4575 | * `valid_until`. The shared send journal prevents another signature from |
| 4576 | * silently reusing the same wallet sequence number. |
| 4577 | */ |
| 4578 | SignMessageResult sign_message(const SignMessageRequest &request); |
| 4579 |
| 4580 | private: |
| 4581 | WalletClient(const WalletClient &); |
| 4582 |
| 4583 | WalletClient(uint64_t); |
| 4584 |
| 4585 | uint64_t _uniffi_internal_clone_pointer() const; |
| 4586 |
| 4587 | uint64_t instance = 0; |
| 4588 | }; |
| 4589 |
| 4590 |
| 4591 |
| 4592 |
| 4593 | /** |
| 4594 | * Executes HTTP work for the engine. |
| 4595 | * |
| 4596 | * The host must enforce the request timeout while it connects and reads the |
| 4597 | * response. It owns any local response limits, must reject redirects, and must |
| 4598 | * return the observed URL in `final_url`. |
| 4599 | */ |
| 4600 | struct WalletHttpHost { |
| 4601 | virtual ~WalletHttpHost() {} |
| 4602 | /** |
| 4603 | * Executes one complete HTTP request and returns an accepted response. |
| 4604 | * |
| 4605 | * The host can add its Toncenter credential according to the actual URL |
| 4606 | * and its local security policy. It must return |
| 4607 | * [`HttpHostErrorKind::Timeout`] when `request.timeout_ms` expires. |
| 4608 | */ |
| 4609 | virtual |
| 4610 | HttpResponse execute_http(const HttpRequest &request) = 0; |
| 4611 | /** |
| 4612 | * Requests cancellation of the request with `request_id`. |
| 4613 | * |
| 4614 | * This callback must be idempotent. It can run before `execute_http` |
| 4615 | * registers the request, so the host must remember an early cancellation. |
| 4616 | */ |
| 4617 | virtual |
| 4618 | void cancel_http(const HttpRequestId &request_id) = 0; |
| 4619 | }; |
| 4620 |
| 4621 | namespace uniffi { |
| 4622 | struct UniffiCallbackInterfaceWalletHttpHost { |
| 4623 | static void execute_http(uint64_t uniffi_handle,RustBuffer request,void * uniffi_future_callback,uint64_t uniffi_callback_data,UniffiForeignFutureDroppedCallbackStruct & uniffi_out_dropped_callback); |
| 4624 | static void cancel_http(uint64_t uniffi_handle,RustBuffer request_id,void * uniffi_future_callback,uint64_t uniffi_callback_data,UniffiForeignFutureDroppedCallbackStruct & uniffi_out_dropped_callback); |
| 4625 |
| 4626 | static void uniffi_free(uint64_t uniffi_handle); |
| 4627 | static uint64_t uniffi_clone(uint64_t uniffi_handle); |
| 4628 | static void init(); |
| 4629 | private: |
| 4630 | static inline UniffiVTableCallbackInterfaceWalletHttpHost vtable = UniffiVTableCallbackInterfaceWalletHttpHost { |
| 4631 | .uniffi_free = reinterpret_cast<void *>(&uniffi_free), |
| 4632 | .uniffi_clone = reinterpret_cast<void *>(&uniffi_clone), |
| 4633 | .execute_http = reinterpret_cast<void *>(&execute_http), |
| 4634 | .cancel_http = reinterpret_cast<void *>(&cancel_http) |
| 4635 | }; |
| 4636 | }; |
| 4637 | } |
| 4638 |
| 4639 | namespace uniffi { |
| 4640 | struct FfiConverterWalletHttpHost; |
| 4641 | } // namespace uniffi |
| 4642 |
| 4643 | /** |
| 4644 | * Executes HTTP work for the engine. |
| 4645 | * |
| 4646 | * The host must enforce the request timeout while it connects and reads the |
| 4647 | * response. It owns any local response limits, must reject redirects, and must |
| 4648 | * return the observed URL in `final_url`. |
| 4649 | */ |
| 4650 | struct WalletHttpHostImpl |
| 4651 |
| 4652 | : public WalletHttpHost |
| 4653 |
| 4654 | { |
| 4655 | friend uniffi::FfiConverterWalletHttpHost; |
| 4656 |
| 4657 | WalletHttpHostImpl() = delete; |
| 4658 |
| 4659 | WalletHttpHostImpl(WalletHttpHostImpl &&) = delete; |
| 4660 |
| 4661 | WalletHttpHostImpl &operator=(const WalletHttpHostImpl &) = delete; |
| 4662 | WalletHttpHostImpl &operator=(WalletHttpHostImpl &&) = delete; |
| 4663 |
| 4664 | ~WalletHttpHostImpl(); |
| 4665 | /** |
| 4666 | * Executes one complete HTTP request and returns an accepted response. |
| 4667 | * |
| 4668 | * The host can add its Toncenter credential according to the actual URL |
| 4669 | * and its local security policy. It must return |
| 4670 | * [`HttpHostErrorKind::Timeout`] when `request.timeout_ms` expires. |
| 4671 | */ |
| 4672 | HttpResponse execute_http(const HttpRequest &request); |
| 4673 | /** |
| 4674 | * Requests cancellation of the request with `request_id`. |
| 4675 | * |
| 4676 | * This callback must be idempotent. It can run before `execute_http` |
| 4677 | * registers the request, so the host must remember an early cancellation. |
| 4678 | */ |
| 4679 | void cancel_http(const HttpRequestId &request_id); |
| 4680 |
| 4681 | private: |
| 4682 | WalletHttpHostImpl(const WalletHttpHostImpl &); |
| 4683 |
| 4684 | WalletHttpHostImpl(uint64_t); |
| 4685 |
| 4686 | uint64_t _uniffi_internal_clone_pointer() const; |
| 4687 |
| 4688 | uint64_t instance = 0; |
| 4689 | }; |
| 4690 |
| 4691 |
| 4692 | namespace uniffi { |
| 4693 | struct FfiConverterWalletLifecycle; |
| 4694 | } // namespace uniffi |
| 4695 |
| 4696 | /** |
| 4697 | * Coordinates wallet creation and recovery-phrase access. |
| 4698 | * |
| 4699 | * It intentionally has no stream, refresh, reconciliation, or journal API. |
| 4700 | * The embedding application owns public wallet metadata. This object owns the |
| 4701 | * boundary between Rust key derivation and protected storage. |
| 4702 | */ |
| 4703 | struct WalletLifecycle |
| 4704 |
| 4705 |
| 4706 |
| 4707 | { |
| 4708 | friend uniffi::FfiConverterWalletLifecycle; |
| 4709 |
| 4710 | WalletLifecycle() = delete; |
| 4711 |
| 4712 | WalletLifecycle(WalletLifecycle &&) = delete; |
| 4713 |
| 4714 | WalletLifecycle &operator=(const WalletLifecycle &) = delete; |
| 4715 | WalletLifecycle &operator=(WalletLifecycle &&) = delete; |
| 4716 |
| 4717 | ~WalletLifecycle(); |
| 4718 | /** |
| 4719 | * Creates a lifecycle service backed by `platform_host`. |
| 4720 | * |
| 4721 | * The application can share this object across wallet operations. The |
| 4722 | * application remains responsible for the lifetime of host resources. |
| 4723 | */ |
| 4724 | static std::shared_ptr<WalletLifecycle> init(const std::shared_ptr<WalletPlatformHost> &platform_host); |
| 4725 | /** |
| 4726 | * Generates the initial 12-word recovery phrase, derives its wallet |
| 4727 | * account, and stores the phrase. |
| 4728 | * |
| 4729 | * A new wallet starts before its first key rotation, so its signing |
| 4730 | * key equals its anchor key and the user records a single 12-word half. |
| 4731 | * |
| 4732 | * Persist `descriptor` after this method succeeds. Present the recovery |
| 4733 | * phrase once, then release all application copies of it. |
| 4734 | */ |
| 4735 | CreatedWallet create_wallet(const CreateWalletRequest &request); |
| 4736 | /** |
| 4737 | * Deletes the protected secret for a wallet descriptor. |
| 4738 | * |
| 4739 | * This method does not delete application metadata or journal records. |
| 4740 | * Delete the stored descriptor only after this method succeeds. |
| 4741 | */ |
| 4742 | void delete_wallet(const WalletDescriptor &descriptor); |
| 4743 | /** |
| 4744 | * Authorizes the current signing key and derives one `MTProto` TON Connect session. |
| 4745 | * |
| 4746 | * Scheme v1: the session secret is HMAC-derived from the signing-key seed, the |
| 4747 | * dApp client id and the server nonce, so every device of the user derives the |
| 4748 | * same key pair. The returned object exposes only the public key `W` and the |
| 4749 | * signing public key it was derived from; the engine does not persist it. |
| 4750 | * A signing-key rotation changes the derived key of every later derivation. |
| 4751 | */ |
| 4752 | std::shared_ptr<TonConnectDerivedSession> derive_ton_connect_session(const TonConnectDerivedSessionRequest &request); |
| 4753 | /** |
| 4754 | * Validates and imports an entered mnemonic as a wallet account. |
| 4755 | * |
| 4756 | * The host stores the phrase with a user-presence requirement. The result |
| 4757 | * contains only metadata that is safe for normal application storage. |
| 4758 | */ |
| 4759 | WalletDescriptor import_wallet(const ImportWalletRequest &request); |
| 4760 | /** |
| 4761 | * Authorizes secret access and returns a verified recovery phrase. |
| 4762 | * |
| 4763 | * Rust derives an address from the returned secret and compares it with |
| 4764 | * the descriptor. Release the returned phrase after the UI closes. |
| 4765 | */ |
| 4766 | RecoveryPhrase reveal_recovery_phrase(const WalletDescriptor &descriptor); |
| 4767 | /** |
| 4768 | * Authorizes the current signing key and signs one TON Connect `signData` request. |
| 4769 | * |
| 4770 | * Rust validates the request against this wallet and builds the protocol digest |
| 4771 | * for `domain` and `timestamp` before any secret access, so the caller cannot use |
| 4772 | * this API as a generic signing oracle. The returned record is what |
| 4773 | * `TonConnectDerivedSession::encrypt_sign_data_success` answers with. The host |
| 4774 | * must block this operation while a key rotation is unresolved. |
| 4775 | */ |
| 4776 | TonConnectSignedData sign_ton_connect_data(const TonConnectSignDataSignRequest &request); |
| 4777 | /** |
| 4778 | * Authorizes the current signing key and signs a TON Connect ownership proof. |
| 4779 | * |
| 4780 | * Rust constructs the protocol digest itself. The caller cannot use this |
| 4781 | * API as a generic Ed25519 signing oracle, and no mnemonic or private-key |
| 4782 | * bytes cross the API boundary. |
| 4783 | * The returned public key must accompany the proof in `ton_addr`. |
| 4784 | * The host must block this operation while a key rotation is unresolved. |
| 4785 | */ |
| 4786 | TonConnectProofSignature sign_ton_connect_proof(const TonConnectProofSignRequest &request); |
| 4787 | /** |
| 4788 | * Derives initial TON Connect account material without reading a secret. |
| 4789 | * |
| 4790 | * Address and `StateInit` remain anchor-based after rotation. For a proof |
| 4791 | * reply, replace `public_key` with [`TonConnectProofSignature::public_key`]. |
| 4792 | */ |
| 4793 | TonConnectAccountInfo ton_connect_account(const WalletDescriptor &descriptor); |
| 4794 |
| 4795 | private: |
| 4796 | WalletLifecycle(const WalletLifecycle &); |
| 4797 |
| 4798 | WalletLifecycle(uint64_t); |
| 4799 |
| 4800 | uint64_t _uniffi_internal_clone_pointer() const; |
| 4801 |
| 4802 | uint64_t instance = 0; |
| 4803 | }; |
| 4804 |
| 4805 |
| 4806 |
| 4807 |
| 4808 | /** |
| 4809 | * Supplies protected storage and durable journal storage. |
| 4810 | * |
| 4811 | * Callback implementations must not call the same client operation |
| 4812 | * recursively. The engine does not hold its wallet-state lock during calls. |
| 4813 | */ |
| 4814 | struct WalletPlatformHost { |
| 4815 | virtual ~WalletPlatformHost() {} |
| 4816 | /** |
| 4817 | * Reads protected secret bytes after the required user authorization. |
| 4818 | * |
| 4819 | * The host must not log the bytes. Return a classified host error when |
| 4820 | * authorization fails or the user cancels the prompt. |
| 4821 | */ |
| 4822 | virtual |
| 4823 | std::vector<uint8_t> read_protected_secret(const ProtectedSecretRead &request) = 0; |
| 4824 | /** |
| 4825 | * Stores secret bytes under the supplied reference. |
| 4826 | * |
| 4827 | * The host must apply the `require_user_presence` policy to later reads. |
| 4828 | */ |
| 4829 | virtual |
| 4830 | void store_protected_secret(const ProtectedSecretStore &request) = 0; |
| 4831 | /** |
| 4832 | * Deletes the protected secret for `secret_ref`. |
| 4833 | */ |
| 4834 | virtual |
| 4835 | void delete_protected_secret(const ProtectedSecretRef &secret_ref) = 0; |
| 4836 | /** |
| 4837 | * Loads the current opaque journal record for `key`. |
| 4838 | */ |
| 4839 | virtual |
| 4840 | std::optional<JournalRecord> load_journal(const JournalKey &key) = 0; |
| 4841 | /** |
| 4842 | * Atomically replaces a journal record when its version matches. |
| 4843 | * |
| 4844 | * The host must compare and replace in one durable transaction. It must |
| 4845 | * return the current record when the expected version does not match. |
| 4846 | */ |
| 4847 | virtual |
| 4848 | JournalCompareExchangeResult compare_exchange_journal(const JournalCompareExchange &mutation) = 0; |
| 4849 | }; |
| 4850 |
| 4851 | namespace uniffi { |
| 4852 | struct UniffiCallbackInterfaceWalletPlatformHost { |
| 4853 | static void read_protected_secret(uint64_t uniffi_handle,RustBuffer request,void * uniffi_future_callback,uint64_t uniffi_callback_data,UniffiForeignFutureDroppedCallbackStruct & uniffi_out_dropped_callback); |
| 4854 | static void store_protected_secret(uint64_t uniffi_handle,RustBuffer request,void * uniffi_future_callback,uint64_t uniffi_callback_data,UniffiForeignFutureDroppedCallbackStruct & uniffi_out_dropped_callback); |
| 4855 | static void delete_protected_secret(uint64_t uniffi_handle,RustBuffer secret_ref,void * uniffi_future_callback,uint64_t uniffi_callback_data,UniffiForeignFutureDroppedCallbackStruct & uniffi_out_dropped_callback); |
| 4856 | static void load_journal(uint64_t uniffi_handle,RustBuffer key,void * uniffi_future_callback,uint64_t uniffi_callback_data,UniffiForeignFutureDroppedCallbackStruct & uniffi_out_dropped_callback); |
| 4857 | static void compare_exchange_journal(uint64_t uniffi_handle,RustBuffer mutation,void * uniffi_future_callback,uint64_t uniffi_callback_data,UniffiForeignFutureDroppedCallbackStruct & uniffi_out_dropped_callback); |
| 4858 |
| 4859 | static void uniffi_free(uint64_t uniffi_handle); |
| 4860 | static uint64_t uniffi_clone(uint64_t uniffi_handle); |
| 4861 | static void init(); |
| 4862 | private: |
| 4863 | static inline UniffiVTableCallbackInterfaceWalletPlatformHost vtable = UniffiVTableCallbackInterfaceWalletPlatformHost { |
| 4864 | .uniffi_free = reinterpret_cast<void *>(&uniffi_free), |
| 4865 | .uniffi_clone = reinterpret_cast<void *>(&uniffi_clone), |
| 4866 | .read_protected_secret = reinterpret_cast<void *>(&read_protected_secret), |
| 4867 | .store_protected_secret = reinterpret_cast<void *>(&store_protected_secret), |
| 4868 | .delete_protected_secret = reinterpret_cast<void *>(&delete_protected_secret), |
| 4869 | .load_journal = reinterpret_cast<void *>(&load_journal), |
| 4870 | .compare_exchange_journal = reinterpret_cast<void *>(&compare_exchange_journal) |
| 4871 | }; |
| 4872 | }; |
| 4873 | } |
| 4874 |
| 4875 | namespace uniffi { |
| 4876 | struct FfiConverterWalletPlatformHost; |
| 4877 | } // namespace uniffi |
| 4878 |
| 4879 | /** |
| 4880 | * Supplies protected storage and durable journal storage. |
| 4881 | * |
| 4882 | * Callback implementations must not call the same client operation |
| 4883 | * recursively. The engine does not hold its wallet-state lock during calls. |
| 4884 | */ |
| 4885 | struct WalletPlatformHostImpl |
| 4886 |
| 4887 | : public WalletPlatformHost |
| 4888 |
| 4889 | { |
| 4890 | friend uniffi::FfiConverterWalletPlatformHost; |
| 4891 |
| 4892 | WalletPlatformHostImpl() = delete; |
| 4893 |
| 4894 | WalletPlatformHostImpl(WalletPlatformHostImpl &&) = delete; |
| 4895 |
| 4896 | WalletPlatformHostImpl &operator=(const WalletPlatformHostImpl &) = delete; |
| 4897 | WalletPlatformHostImpl &operator=(WalletPlatformHostImpl &&) = delete; |
| 4898 |
| 4899 | ~WalletPlatformHostImpl(); |
| 4900 | /** |
| 4901 | * Reads protected secret bytes after the required user authorization. |
| 4902 | * |
| 4903 | * The host must not log the bytes. Return a classified host error when |
| 4904 | * authorization fails or the user cancels the prompt. |
| 4905 | */ |
| 4906 | std::vector<uint8_t> read_protected_secret(const ProtectedSecretRead &request); |
| 4907 | /** |
| 4908 | * Stores secret bytes under the supplied reference. |
| 4909 | * |
| 4910 | * The host must apply the `require_user_presence` policy to later reads. |
| 4911 | */ |
| 4912 | void store_protected_secret(const ProtectedSecretStore &request); |
| 4913 | /** |
| 4914 | * Deletes the protected secret for `secret_ref`. |
| 4915 | */ |
| 4916 | void delete_protected_secret(const ProtectedSecretRef &secret_ref); |
| 4917 | /** |
| 4918 | * Loads the current opaque journal record for `key`. |
| 4919 | */ |
| 4920 | std::optional<JournalRecord> load_journal(const JournalKey &key); |
| 4921 | /** |
| 4922 | * Atomically replaces a journal record when its version matches. |
| 4923 | * |
| 4924 | * The host must compare and replace in one durable transaction. It must |
| 4925 | * return the current record when the expected version does not match. |
| 4926 | */ |
| 4927 | JournalCompareExchangeResult compare_exchange_journal(const JournalCompareExchange &mutation); |
| 4928 |
| 4929 | private: |
| 4930 | WalletPlatformHostImpl(const WalletPlatformHostImpl &); |
| 4931 |
| 4932 | WalletPlatformHostImpl(uint64_t); |
| 4933 |
| 4934 | uint64_t _uniffi_internal_clone_pointer() const; |
| 4935 |
| 4936 | uint64_t instance = 0; |
| 4937 | }; |
| 4938 |
| 4939 |
| 4940 |
| 4941 |
| 4942 | /** |
| 4943 | * Executes provider requests through a transport without HTTP response metadata. |
| 4944 | * |
| 4945 | * The request URL is the logical Toncenter destination and does not require a |
| 4946 | * direct connection to that origin. The host can route it through a trusted |
| 4947 | * relay or protocol proxy, but must not follow or emulate provider redirects. |
| 4948 | * A successful callback returns only the provider body: it makes no claim |
| 4949 | * about an HTTP status, response headers, or final URL. |
| 4950 | */ |
| 4951 | struct WalletStatuslessHost { |
| 4952 | virtual ~WalletStatuslessHost() {} |
| 4953 | /** |
| 4954 | * Executes one complete logical provider request. |
| 4955 | * |
| 4956 | * The host must enforce `request.timeout_ms`. It reports timeout and |
| 4957 | * cancellation explicitly; opaque RPC failures can use |
| 4958 | * [`StatuslessHostErrorKind::Other`] with a bounded diagnostic. |
| 4959 | */ |
| 4960 | virtual |
| 4961 | std::vector<uint8_t> execute_statusless(const HttpRequest &request) = 0; |
| 4962 | /** |
| 4963 | * Requests cancellation of the request with `request_id`. |
| 4964 | * |
| 4965 | * This callback has the same idempotency and early-cancellation contract |
| 4966 | * as [`crate::WalletHttpHost::cancel_http`]. |
| 4967 | */ |
| 4968 | virtual |
| 4969 | void cancel_statusless(const HttpRequestId &request_id) = 0; |
| 4970 | }; |
| 4971 |
| 4972 | namespace uniffi { |
| 4973 | struct UniffiCallbackInterfaceWalletStatuslessHost { |
| 4974 | static void execute_statusless(uint64_t uniffi_handle,RustBuffer request,void * uniffi_future_callback,uint64_t uniffi_callback_data,UniffiForeignFutureDroppedCallbackStruct & uniffi_out_dropped_callback); |
| 4975 | static void cancel_statusless(uint64_t uniffi_handle,RustBuffer request_id,void * uniffi_future_callback,uint64_t uniffi_callback_data,UniffiForeignFutureDroppedCallbackStruct & uniffi_out_dropped_callback); |
| 4976 |
| 4977 | static void uniffi_free(uint64_t uniffi_handle); |
| 4978 | static uint64_t uniffi_clone(uint64_t uniffi_handle); |
| 4979 | static void init(); |
| 4980 | private: |
| 4981 | static inline UniffiVTableCallbackInterfaceWalletStatuslessHost vtable = UniffiVTableCallbackInterfaceWalletStatuslessHost { |
| 4982 | .uniffi_free = reinterpret_cast<void *>(&uniffi_free), |
| 4983 | .uniffi_clone = reinterpret_cast<void *>(&uniffi_clone), |
| 4984 | .execute_statusless = reinterpret_cast<void *>(&execute_statusless), |
| 4985 | .cancel_statusless = reinterpret_cast<void *>(&cancel_statusless) |
| 4986 | }; |
| 4987 | }; |
| 4988 | } |
| 4989 |
| 4990 | namespace uniffi { |
| 4991 | struct FfiConverterWalletStatuslessHost; |
| 4992 | } // namespace uniffi |
| 4993 |
| 4994 | /** |
| 4995 | * Executes provider requests through a transport without HTTP response metadata. |
| 4996 | * |
| 4997 | * The request URL is the logical Toncenter destination and does not require a |
| 4998 | * direct connection to that origin. The host can route it through a trusted |
| 4999 | * relay or protocol proxy, but must not follow or emulate provider redirects. |
| 5000 | * A successful callback returns only the provider body: it makes no claim |
| 5001 | * about an HTTP status, response headers, or final URL. |
| 5002 | */ |
| 5003 | struct WalletStatuslessHostImpl |
| 5004 |
| 5005 | : public WalletStatuslessHost |
| 5006 |
| 5007 | { |
| 5008 | friend uniffi::FfiConverterWalletStatuslessHost; |
| 5009 |
| 5010 | WalletStatuslessHostImpl() = delete; |
| 5011 |
| 5012 | WalletStatuslessHostImpl(WalletStatuslessHostImpl &&) = delete; |
| 5013 |
| 5014 | WalletStatuslessHostImpl &operator=(const WalletStatuslessHostImpl &) = delete; |
| 5015 | WalletStatuslessHostImpl &operator=(WalletStatuslessHostImpl &&) = delete; |
| 5016 |
| 5017 | ~WalletStatuslessHostImpl(); |
| 5018 | /** |
| 5019 | * Executes one complete logical provider request. |
| 5020 | * |
| 5021 | * The host must enforce `request.timeout_ms`. It reports timeout and |
| 5022 | * cancellation explicitly; opaque RPC failures can use |
| 5023 | * [`StatuslessHostErrorKind::Other`] with a bounded diagnostic. |
| 5024 | */ |
| 5025 | std::vector<uint8_t> execute_statusless(const HttpRequest &request); |
| 5026 | /** |
| 5027 | * Requests cancellation of the request with `request_id`. |
| 5028 | * |
| 5029 | * This callback has the same idempotency and early-cancellation contract |
| 5030 | * as [`crate::WalletHttpHost::cancel_http`]. |
| 5031 | */ |
| 5032 | void cancel_statusless(const HttpRequestId &request_id); |
| 5033 |
| 5034 | private: |
| 5035 | WalletStatuslessHostImpl(const WalletStatuslessHostImpl &); |
| 5036 |
| 5037 | WalletStatuslessHostImpl(uint64_t); |
| 5038 |
| 5039 | uint64_t _uniffi_internal_clone_pointer() const; |
| 5040 |
| 5041 | uint64_t instance = 0; |
| 5042 | }; |
| 5043 |
| 5044 |
| 5045 | /** |
| 5046 | * Public account material sent in a TON Connect `ton_addr` reply. |
| 5047 | */ |
| 5048 | struct TonConnectAccountInfo { |
| 5049 | /** |
| 5050 | * Canonical raw TON address (`workchain:hex`). |
| 5051 | */ |
| 5052 | std::string address; |
| 5053 | /** |
| 5054 | * TON network global ID encoded as a decimal string. |
| 5055 | */ |
| 5056 | std::string network; |
| 5057 | /** |
| 5058 | * Canonical standard-base64 wallet `StateInit` `BoC`. |
| 5059 | */ |
| 5060 | std::string wallet_state_init; |
| 5061 | /** |
| 5062 | * Raw 32-byte Ed25519 public key advertised to the dApp. |
| 5063 | * |
| 5064 | * [`WalletLifecycle::ton_connect_account`] supplies the initial anchor |
| 5065 | * key. When signing a proof, replace it with the returned signing key. |
| 5066 | */ |
| 5067 | std::vector<uint8_t> public_key; |
| 5068 | }; |
| 5069 |
| 5070 |
| 5071 | /** |
| 5072 | * Initial dApp request that must be shown before connection approval. |
| 5073 | */ |
| 5074 | struct TonConnectConnectPrompt { |
| 5075 | /** |
| 5076 | * URL of `tonconnect-manifest.json`. |
| 5077 | */ |
| 5078 | std::string manifest_url; |
| 5079 | /** |
| 5080 | * Optional requested network identifier. |
| 5081 | */ |
| 5082 | std::optional<std::string> requested_network; |
| 5083 | /** |
| 5084 | * Optional ownership-proof challenge. |
| 5085 | */ |
| 5086 | std::optional<std::string> proof_payload; |
| 5087 | }; |
| 5088 |
| 5089 |
| 5090 | /** |
| 5091 | * Validated dApp manifest fields needed by wallet UI and proof signing. |
| 5092 | */ |
| 5093 | struct TonConnectManifest { |
| 5094 | /** |
| 5095 | * Canonical dApp URL. |
| 5096 | */ |
| 5097 | std::string url; |
| 5098 | /** |
| 5099 | * Human-readable dApp name. |
| 5100 | */ |
| 5101 | std::string name; |
| 5102 | /** |
| 5103 | * HTTPS raster icon URL. |
| 5104 | */ |
| 5105 | std::string icon_url; |
| 5106 | /** |
| 5107 | * DNS domain bound into `ton_proof`. |
| 5108 | */ |
| 5109 | std::string domain; |
| 5110 | }; |
| 5111 |
| 5112 |
| 5113 | /** |
| 5114 | * A complete encrypted HTTP bridge POST. |
| 5115 | */ |
| 5116 | struct TonConnectPreparedPost { |
| 5117 | /** |
| 5118 | * Absolute bridge message URL including recipient and TTL. |
| 5119 | */ |
| 5120 | std::string url; |
| 5121 | /** |
| 5122 | * Canonical base64 encrypted body. |
| 5123 | */ |
| 5124 | std::string body; |
| 5125 | }; |
| 5126 |
| 5127 |
| 5128 | /** |
| 5129 | * Signed ownership proof supplied when approving a connect request. |
| 5130 | */ |
| 5131 | struct TonConnectProofReply { |
| 5132 | /** |
| 5133 | * Unix signing timestamp in seconds. |
| 5134 | */ |
| 5135 | uint64_t timestamp; |
| 5136 | /** |
| 5137 | * Manifest domain shown to the user. |
| 5138 | */ |
| 5139 | std::string domain; |
| 5140 | /** |
| 5141 | * Exact dApp challenge. |
| 5142 | */ |
| 5143 | std::string payload; |
| 5144 | /** |
| 5145 | * Exact 64-byte Ed25519 signature. |
| 5146 | */ |
| 5147 | std::vector<uint8_t> signature; |
| 5148 | }; |
| 5149 |
| 5150 |
| 5151 | /** |
| 5152 | * Ed25519 result of an authorized TON Connect ownership proof. |
| 5153 | */ |
| 5154 | struct TonConnectProofSignature { |
| 5155 | /** |
| 5156 | * Exact 64-byte Ed25519 signature. |
| 5157 | */ |
| 5158 | std::vector<uint8_t> signature; |
| 5159 | /** |
| 5160 | * Current 32-byte Ed25519 signing public key used for this proof. |
| 5161 | * |
| 5162 | * Use this key in the accompanying `ton_addr` reply. After rotation it |
| 5163 | * differs from the anchor key in the descriptor and initial `StateInit`. |
| 5164 | */ |
| 5165 | std::vector<uint8_t> public_key; |
| 5166 | }; |
| 5167 |
| 5168 |
| 5169 | /** |
| 5170 | * Limits and bridge identity for one wallet-side TON Connect session. |
| 5171 | */ |
| 5172 | struct TonConnectSessionConfig { |
| 5173 | /** |
| 5174 | * Wallet-owned HTTP bridge base URL. |
| 5175 | */ |
| 5176 | std::string bridge_url; |
| 5177 | /** |
| 5178 | * Maximum bytes accepted for one SSE event. |
| 5179 | */ |
| 5180 | uint64_t max_event_bytes; |
| 5181 | /** |
| 5182 | * Bridge message lifetime in seconds. |
| 5183 | */ |
| 5184 | uint32_t message_ttl_seconds; |
| 5185 | }; |
| 5186 |
| 5187 |
| 5188 | /** |
| 5189 | * A recovery-phrase scheme recognized by [`detect_mnemonic_schemes`]. |
| 5190 | * |
| 5191 | * The names follow |
| 5192 | * [TEP-0003](https://github.com/ton-blockchain/TEPs/blob/master/text/0003-wallets.md). |
| 5193 | */ |
| 5194 | enum class MnemonicScheme: int32_t { |
| 5195 | /** |
| 5196 | * A rotation mnemonic (TEP-0003 section 3.3): 12 words before the |
| 5197 | * wallet's first key rotation or 24 words after it. The only scheme |
| 5198 | * wallet import accepts; later rotations replace the signing half. |
| 5199 | */ |
| 5200 | kRotation = 1, |
| 5201 | /** |
| 5202 | * A passwordless legacy 24-word TON mnemonic (TEP-0003 section 3.1). |
| 5203 | * Recognized so the application can explain the rejection; never |
| 5204 | * imported, and no key is derived from it. |
| 5205 | */ |
| 5206 | kTon = 2, |
| 5207 | /** |
| 5208 | * A standard 24-word BIP-39 phrase - the Multichain mnemonic of TEP-0003 |
| 5209 | * section 3.2. Recognized so the application can explain the rejection; |
| 5210 | * never imported, and no key is derived from it. |
| 5211 | */ |
| 5212 | kBip39 = 3 |
| 5213 | }; |
| 5214 |
| 5215 | namespace uniffi { |
| 5216 | struct FfiConverterTonAddressError; |
| 5217 | } // namespace uniffi |
| 5218 |
| 5219 | /** |
| 5220 | * Reports invalid address text or a raw address that cannot use TEP-2 formatting. |
| 5221 | */ |
| 5222 | struct TonAddressError: std::runtime_error { |
| 5223 | friend uniffi::FfiConverterTonAddressError; |
| 5224 |
| 5225 | TonAddressError() : std::runtime_error("") {} |
| 5226 | TonAddressError(const std::string &what_arg) : std::runtime_error(what_arg) {} |
| 5227 |
| 5228 | virtual ~TonAddressError() = default; |
| 5229 |
| 5230 | virtual void throw_underlying() { |
| 5231 | throw *this; |
| 5232 | } |
| 5233 |
| 5234 | protected: |
| 5235 | virtual int32_t get_variant_idx() const { |
| 5236 | return 0; |
| 5237 | }; |
| 5238 | }; |
| 5239 | /** |
| 5240 | * Contains variants of TonAddressError |
| 5241 | */ |
| 5242 | namespace ton_address_error { |
| 5243 |
| 5244 | /** |
| 5245 | * The input is neither a valid raw address nor a valid TEP-2 friendly address. |
| 5246 | */ |
| 5247 | struct InvalidAddress: TonAddressError { |
| 5248 |
| 5249 | InvalidAddress() : TonAddressError("") {} |
| 5250 | InvalidAddress(const std::string &what_arg) : TonAddressError(what_arg) {} |
| 5251 |
| 5252 | void throw_underlying() override { |
| 5253 | throw *this; |
| 5254 | } |
| 5255 |
| 5256 | protected: |
| 5257 | int32_t get_variant_idx() const override { |
| 5258 | return 1; |
| 5259 | } |
| 5260 | }; |
| 5261 |
| 5262 | /** |
| 5263 | * The workchain cannot be encoded by the supported TEP-2 friendly format. |
| 5264 | */ |
| 5265 | struct UnsupportedWorkchain: TonAddressError { |
| 5266 |
| 5267 | UnsupportedWorkchain() : TonAddressError("") {} |
| 5268 | UnsupportedWorkchain(const std::string &what_arg) : TonAddressError(what_arg) {} |
| 5269 |
| 5270 | void throw_underlying() override { |
| 5271 | throw *this; |
| 5272 | } |
| 5273 |
| 5274 | protected: |
| 5275 | int32_t get_variant_idx() const override { |
| 5276 | return 2; |
| 5277 | } |
| 5278 | }; |
| 5279 | } // namespace ton_address_error |
| 5280 |
| 5281 |
| 5282 | /** |
| 5283 | * Connect-event error codes a wallet reports for a failed connection. |
| 5284 | */ |
| 5285 | enum class TonConnectConnectErrorCode: int32_t { |
| 5286 | /** |
| 5287 | * The dApp manifest could not be fetched (protocol code 2). |
| 5288 | */ |
| 5289 | kManifestNotFound = 1, |
| 5290 | /** |
| 5291 | * The dApp manifest is malformed (protocol code 3). |
| 5292 | */ |
| 5293 | kManifestContent = 2, |
| 5294 | /** |
| 5295 | * The user declined the connection (protocol code 300). |
| 5296 | */ |
| 5297 | kUserDeclined = 3 |
| 5298 | }; |
| 5299 |
| 5300 | namespace uniffi { |
| 5301 | struct FfiConverterTonConnectSessionError; |
| 5302 | } // namespace uniffi |
| 5303 |
| 5304 | /** |
| 5305 | * Failure at the FFI-safe TON Connect session boundary. |
| 5306 | */ |
| 5307 | struct TonConnectSessionError: std::runtime_error { |
| 5308 | friend uniffi::FfiConverterTonConnectSessionError; |
| 5309 |
| 5310 | TonConnectSessionError() : std::runtime_error("") {} |
| 5311 | TonConnectSessionError(const std::string &what_arg) : std::runtime_error(what_arg) {} |
| 5312 |
| 5313 | virtual ~TonConnectSessionError() = default; |
| 5314 |
| 5315 | virtual void throw_underlying() { |
| 5316 | throw *this; |
| 5317 | } |
| 5318 |
| 5319 | protected: |
| 5320 | virtual int32_t get_variant_idx() const { |
| 5321 | return 0; |
| 5322 | }; |
| 5323 | }; |
| 5324 | /** |
| 5325 | * Contains variants of TonConnectSessionError |
| 5326 | */ |
| 5327 | namespace ton_connect_session_error { |
| 5328 |
| 5329 | /** |
| 5330 | * The session or protocol input is invalid. |
| 5331 | */ |
| 5332 | struct Failed: TonConnectSessionError { |
| 5333 | std::string diagnostic; |
| 5334 |
| 5335 | Failed() : TonConnectSessionError("") {} |
| 5336 | Failed(const std::string &what_arg) : TonConnectSessionError(what_arg) {} |
| 5337 |
| 5338 | void throw_underlying() override { |
| 5339 | throw *this; |
| 5340 | } |
| 5341 |
| 5342 | protected: |
| 5343 | int32_t get_variant_idx() const override { |
| 5344 | return 1; |
| 5345 | } |
| 5346 | }; |
| 5347 | } // namespace ton_connect_session_error |
| 5348 |
| 5349 |
| 5350 | /** |
| 5351 | * Public lifecycle phase of a TON Connect session. |
| 5352 | */ |
| 5353 | enum class TonConnectSessionPhase: int32_t { |
| 5354 | /** |
| 5355 | * Waiting for connect approval. |
| 5356 | */ |
| 5357 | kPendingConnect = 1, |
| 5358 | /** |
| 5359 | * Connected and accepting RPC requests. |
| 5360 | */ |
| 5361 | kConnected = 2, |
| 5362 | /** |
| 5363 | * Terminally disconnected. |
| 5364 | */ |
| 5365 | kDisconnected = 3 |
| 5366 | }; |
| 5367 |
| 5368 | namespace uniffi { |
| 5369 | struct FfiConverterTonTransferLinkError; |
| 5370 | } // namespace uniffi |
| 5371 |
| 5372 | /** |
| 5373 | * Reports why a `ton://transfer/` link could not be parsed. |
| 5374 | */ |
| 5375 | struct TonTransferLinkError: std::runtime_error { |
| 5376 | friend uniffi::FfiConverterTonTransferLinkError; |
| 5377 |
| 5378 | TonTransferLinkError() : std::runtime_error("") {} |
| 5379 | TonTransferLinkError(const std::string &what_arg) : std::runtime_error(what_arg) {} |
| 5380 |
| 5381 | virtual ~TonTransferLinkError() = default; |
| 5382 |
| 5383 | virtual void throw_underlying() { |
| 5384 | throw *this; |
| 5385 | } |
| 5386 |
| 5387 | protected: |
| 5388 | virtual int32_t get_variant_idx() const { |
| 5389 | return 0; |
| 5390 | }; |
| 5391 | }; |
| 5392 | /** |
| 5393 | * Contains variants of TonTransferLinkError |
| 5394 | */ |
| 5395 | namespace ton_transfer_link_error { |
| 5396 |
| 5397 | /** |
| 5398 | * The URI belongs to a different scheme or command. |
| 5399 | */ |
| 5400 | struct NotTonTransfer: TonTransferLinkError { |
| 5401 |
| 5402 | NotTonTransfer() : TonTransferLinkError("") {} |
| 5403 | NotTonTransfer(const std::string &what_arg) : TonTransferLinkError(what_arg) {} |
| 5404 |
| 5405 | void throw_underlying() override { |
| 5406 | throw *this; |
| 5407 | } |
| 5408 |
| 5409 | protected: |
| 5410 | int32_t get_variant_idx() const override { |
| 5411 | return 1; |
| 5412 | } |
| 5413 | }; |
| 5414 |
| 5415 | /** |
| 5416 | * The URI structure or encoding is invalid. |
| 5417 | */ |
| 5418 | struct InvalidUrl: TonTransferLinkError { |
| 5419 |
| 5420 | InvalidUrl() : TonTransferLinkError("") {} |
| 5421 | InvalidUrl(const std::string &what_arg) : TonTransferLinkError(what_arg) {} |
| 5422 |
| 5423 | void throw_underlying() override { |
| 5424 | throw *this; |
| 5425 | } |
| 5426 |
| 5427 | protected: |
| 5428 | int32_t get_variant_idx() const override { |
| 5429 | return 2; |
| 5430 | } |
| 5431 | }; |
| 5432 |
| 5433 | /** |
| 5434 | * The transfer command has no recipient path segment. |
| 5435 | */ |
| 5436 | struct MissingRecipient: TonTransferLinkError { |
| 5437 |
| 5438 | MissingRecipient() : TonTransferLinkError("") {} |
| 5439 | MissingRecipient(const std::string &what_arg) : TonTransferLinkError(what_arg) {} |
| 5440 |
| 5441 | void throw_underlying() override { |
| 5442 | throw *this; |
| 5443 | } |
| 5444 |
| 5445 | protected: |
| 5446 | int32_t get_variant_idx() const override { |
| 5447 | return 3; |
| 5448 | } |
| 5449 | }; |
| 5450 |
| 5451 | /** |
| 5452 | * The recipient is not a valid TON account address. |
| 5453 | */ |
| 5454 | struct InvalidRecipient: TonTransferLinkError { |
| 5455 |
| 5456 | InvalidRecipient() : TonTransferLinkError("") {} |
| 5457 | InvalidRecipient(const std::string &what_arg) : TonTransferLinkError(what_arg) {} |
| 5458 |
| 5459 | void throw_underlying() override { |
| 5460 | throw *this; |
| 5461 | } |
| 5462 |
| 5463 | protected: |
| 5464 | int32_t get_variant_idx() const override { |
| 5465 | return 4; |
| 5466 | } |
| 5467 | }; |
| 5468 |
| 5469 | /** |
| 5470 | * A singleton baseline query parameter occurs more than once. |
| 5471 | */ |
| 5472 | struct DuplicateParameter: TonTransferLinkError { |
| 5473 | std::string name; |
| 5474 |
| 5475 | DuplicateParameter() : TonTransferLinkError("") {} |
| 5476 | DuplicateParameter(const std::string &what_arg) : TonTransferLinkError(what_arg) {} |
| 5477 |
| 5478 | void throw_underlying() override { |
| 5479 | throw *this; |
| 5480 | } |
| 5481 |
| 5482 | protected: |
| 5483 | int32_t get_variant_idx() const override { |
| 5484 | return 5; |
| 5485 | } |
| 5486 | }; |
| 5487 |
| 5488 | /** |
| 5489 | * The strict baseline does not recognize a query parameter. |
| 5490 | */ |
| 5491 | struct UnsupportedParameter: TonTransferLinkError { |
| 5492 | std::string name; |
| 5493 |
| 5494 | UnsupportedParameter() : TonTransferLinkError("") {} |
| 5495 | UnsupportedParameter(const std::string &what_arg) : TonTransferLinkError(what_arg) {} |
| 5496 |
| 5497 | void throw_underlying() override { |
| 5498 | throw *this; |
| 5499 | } |
| 5500 |
| 5501 | protected: |
| 5502 | int32_t get_variant_idx() const override { |
| 5503 | return 6; |
| 5504 | } |
| 5505 | }; |
| 5506 |
| 5507 | /** |
| 5508 | * `amount` is not a canonical unsigned decimal integer. |
| 5509 | */ |
| 5510 | struct InvalidAmount: TonTransferLinkError { |
| 5511 |
| 5512 | InvalidAmount() : TonTransferLinkError("") {} |
| 5513 | InvalidAmount(const std::string &what_arg) : TonTransferLinkError(what_arg) {} |
| 5514 |
| 5515 | void throw_underlying() override { |
| 5516 | throw *this; |
| 5517 | } |
| 5518 |
| 5519 | protected: |
| 5520 | int32_t get_variant_idx() const override { |
| 5521 | return 7; |
| 5522 | } |
| 5523 | }; |
| 5524 |
| 5525 | /** |
| 5526 | * `exp` is not a canonical unsigned `u64` Unix timestamp. |
| 5527 | */ |
| 5528 | struct InvalidExpiration: TonTransferLinkError { |
| 5529 |
| 5530 | InvalidExpiration() : TonTransferLinkError("") {} |
| 5531 | InvalidExpiration(const std::string &what_arg) : TonTransferLinkError(what_arg) {} |
| 5532 |
| 5533 | void throw_underlying() override { |
| 5534 | throw *this; |
| 5535 | } |
| 5536 |
| 5537 | protected: |
| 5538 | int32_t get_variant_idx() const override { |
| 5539 | return 8; |
| 5540 | } |
| 5541 | }; |
| 5542 |
| 5543 | /** |
| 5544 | * `jetton` is not a valid TON account address. |
| 5545 | */ |
| 5546 | struct InvalidJettonMaster: TonTransferLinkError { |
| 5547 |
| 5548 | InvalidJettonMaster() : TonTransferLinkError("") {} |
| 5549 | InvalidJettonMaster(const std::string &what_arg) : TonTransferLinkError(what_arg) {} |
| 5550 |
| 5551 | void throw_underlying() override { |
| 5552 | throw *this; |
| 5553 | } |
| 5554 |
| 5555 | protected: |
| 5556 | int32_t get_variant_idx() const override { |
| 5557 | return 9; |
| 5558 | } |
| 5559 | }; |
| 5560 |
| 5561 | /** |
| 5562 | * `bin` is not standard Base64 containing one valid BOC root. |
| 5563 | */ |
| 5564 | struct InvalidBinaryPayload: TonTransferLinkError { |
| 5565 |
| 5566 | InvalidBinaryPayload() : TonTransferLinkError("") {} |
| 5567 | InvalidBinaryPayload(const std::string &what_arg) : TonTransferLinkError(what_arg) {} |
| 5568 |
| 5569 | void throw_underlying() override { |
| 5570 | throw *this; |
| 5571 | } |
| 5572 |
| 5573 | protected: |
| 5574 | int32_t get_variant_idx() const override { |
| 5575 | return 10; |
| 5576 | } |
| 5577 | }; |
| 5578 |
| 5579 | /** |
| 5580 | * `text` and `bin` cannot both define the payload. |
| 5581 | */ |
| 5582 | struct ConflictingPayloads: TonTransferLinkError { |
| 5583 |
| 5584 | ConflictingPayloads() : TonTransferLinkError("") {} |
| 5585 | ConflictingPayloads(const std::string &what_arg) : TonTransferLinkError(what_arg) {} |
| 5586 |
| 5587 | void throw_underlying() override { |
| 5588 | throw *this; |
| 5589 | } |
| 5590 |
| 5591 | protected: |
| 5592 | int32_t get_variant_idx() const override { |
| 5593 | return 11; |
| 5594 | } |
| 5595 | }; |
| 5596 |
| 5597 | /** |
| 5598 | * Strict baseline mode does not define the meaning of `bin` for a jetton. |
| 5599 | */ |
| 5600 | struct BinaryJettonConflict: TonTransferLinkError { |
| 5601 |
| 5602 | BinaryJettonConflict() : TonTransferLinkError("") {} |
| 5603 | BinaryJettonConflict(const std::string &what_arg) : TonTransferLinkError(what_arg) {} |
| 5604 |
| 5605 | void throw_underlying() override { |
| 5606 | throw *this; |
| 5607 | } |
| 5608 |
| 5609 | protected: |
| 5610 | int32_t get_variant_idx() const override { |
| 5611 | return 12; |
| 5612 | } |
| 5613 | }; |
| 5614 | } // namespace ton_transfer_link_error |
| 5615 |
| 5616 | namespace uniffi { |
| 5617 | using ::uniffi::RustStream; |
| 5618 | using ::uniffi::RustStreamBuffer; |
| 5619 |
| 5620 | RustBuffer rustbuffer_alloc(uint64_t); |
| 5621 | RustBuffer rustbuffer_from_bytes(const ForeignBytes &); |
| 5622 | void rustbuffer_free(RustBuffer); |
| 5623 | template <typename T> struct HandleMap { |
| 5624 | HandleMap() = default; |
| 5625 |
| 5626 | std::shared_ptr<T> at(uint64_t handle) { |
| 5627 | std::lock_guard<std::mutex> guard(this->mutex); |
| 5628 |
| 5629 | return this->map.at(handle); |
| 5630 | } |
| 5631 |
| 5632 | uint64_t insert(std::shared_ptr<T> impl) { |
| 5633 | std::lock_guard<std::mutex> guard(this->mutex); |
| 5634 |
| 5635 | auto handle = this->cur_handle; |
| 5636 |
| 5637 | this->map.insert({ handle, impl }); |
| 5638 | this->cur_handle += 1; |
| 5639 |
| 5640 | return handle; |
| 5641 | } |
| 5642 |
| 5643 | void erase(uint64_t handle) { |
| 5644 | // We store the object here to avoid re-entrant locking |
| 5645 | std::shared_ptr<T> cleanup; |
| 5646 | { |
| 5647 | std::lock_guard<std::mutex> guard(this->mutex); |
| 5648 | auto it = this->map.find(handle); |
| 5649 | if (it != this->map.end()) { |
| 5650 | cleanup = it->second; |
| 5651 | this->map.erase(it); |
| 5652 | } |
| 5653 | } |
| 5654 | } |
| 5655 | private: |
| 5656 | HandleMap(const HandleMap<T> &) = delete; |
| 5657 | HandleMap(HandleMap<T> &&) = delete; |
| 5658 |
| 5659 | HandleMap<T> &operator=(const HandleMap<T> &) = delete; |
| 5660 | HandleMap<T> &operator=(HandleMap<T> &&) = delete; |
| 5661 |
| 5662 | std::mutex mutex; |
| 5663 | uint64_t cur_handle = 0; |
| 5664 | std::map<uint64_t, std::shared_ptr<T>> map; |
| 5665 | }; |
| 5666 | struct FfiConverterUInt16 { |
| 5667 | static uint16_t lift(uint16_t); |
| 5668 | static uint16_t lower(uint16_t); |
| 5669 | static uint16_t read(RustStream &); |
| 5670 | static void write(RustStream &, uint16_t); |
| 5671 | static uint64_t allocation_size(uint16_t); |
| 5672 | }; |
| 5673 | struct FfiConverterUInt32 { |
| 5674 | static uint32_t lift(uint32_t); |
| 5675 | static uint32_t lower(uint32_t); |
| 5676 | static uint32_t read(RustStream &); |
| 5677 | static void write(RustStream &, uint32_t); |
| 5678 | static uint64_t allocation_size(uint32_t); |
| 5679 | }; |
| 5680 | struct FfiConverterInt32 { |
| 5681 | static int32_t lift(int32_t); |
| 5682 | static int32_t lower(int32_t); |
| 5683 | static int32_t read(RustStream &); |
| 5684 | static void write(RustStream &, int32_t); |
| 5685 | static uint64_t allocation_size(int32_t); |
| 5686 | }; |
| 5687 | struct FfiConverterUInt64 { |
| 5688 | static uint64_t lift(uint64_t); |
| 5689 | static uint64_t lower(uint64_t); |
| 5690 | static uint64_t read(RustStream &); |
| 5691 | static void write(RustStream &, uint64_t); |
| 5692 | static uint64_t allocation_size(uint64_t); |
| 5693 | }; |
| 5694 | struct FfiConverterInt64 { |
| 5695 | static int64_t lift(int64_t); |
| 5696 | static int64_t lower(int64_t); |
| 5697 | static int64_t read(RustStream &); |
| 5698 | static void write(RustStream &, int64_t); |
| 5699 | static uint64_t allocation_size(int64_t); |
| 5700 | }; |
| 5701 | struct FfiConverterBool { |
| 5702 | static bool lift(uint8_t); |
| 5703 | static uint8_t lower(bool); |
| 5704 | static bool read(RustStream &); |
| 5705 | static void write(RustStream &, bool); |
| 5706 | static uint64_t allocation_size(bool); |
| 5707 | }; |
| 5708 | struct FfiConverterString { |
| 5709 | static std::string lift(RustBuffer buf); |
| 5710 | static RustBuffer lower(const std::string &); |
| 5711 | static std::string read(RustStream &); |
| 5712 | static void write(RustStream &, const std::string &); |
| 5713 | static uint64_t allocation_size(const std::string &); |
| 5714 | }; |
| 5715 |
| 5716 | struct FfiConverterBytes { |
| 5717 | static std::vector<uint8_t> lift(RustBuffer); |
| 5718 | static RustBuffer lower(const std::vector<uint8_t> &); |
| 5719 | static std::vector<uint8_t> read(RustStream &); |
| 5720 | static void write(RustStream &, const std::vector<uint8_t> &); |
| 5721 | static uint64_t allocation_size(const std::vector<uint8_t> &); |
| 5722 | }; |
| 5723 |
| 5724 |
| 5725 | struct FfiConverterTonConnectDerivedSession { |
| 5726 | static std::shared_ptr<TonConnectDerivedSession> lift(uint64_t); |
| 5727 | static uint64_t lower(const std::shared_ptr<TonConnectDerivedSession> &); |
| 5728 | static std::shared_ptr<TonConnectDerivedSession> read(RustStream &); |
| 5729 | static void write(RustStream &, const std::shared_ptr<TonConnectDerivedSession> &); |
| 5730 | static uint64_t allocation_size(const std::shared_ptr<TonConnectDerivedSession> &); |
| 5731 | private: |
| 5732 | }; |
| 5733 |
| 5734 |
| 5735 | struct FfiConverterTonConnectSession { |
| 5736 | static std::shared_ptr<TonConnectSession> lift(uint64_t); |
| 5737 | static uint64_t lower(const std::shared_ptr<TonConnectSession> &); |
| 5738 | static std::shared_ptr<TonConnectSession> read(RustStream &); |
| 5739 | static void write(RustStream &, const std::shared_ptr<TonConnectSession> &); |
| 5740 | static uint64_t allocation_size(const std::shared_ptr<TonConnectSession> &); |
| 5741 | private: |
| 5742 | }; |
| 5743 |
| 5744 |
| 5745 | struct FfiConverterWalletClient { |
| 5746 | static std::shared_ptr<WalletClient> lift(uint64_t); |
| 5747 | static uint64_t lower(const std::shared_ptr<WalletClient> &); |
| 5748 | static std::shared_ptr<WalletClient> read(RustStream &); |
| 5749 | static void write(RustStream &, const std::shared_ptr<WalletClient> &); |
| 5750 | static uint64_t allocation_size(const std::shared_ptr<WalletClient> &); |
| 5751 | private: |
| 5752 | }; |
| 5753 |
| 5754 |
| 5755 | struct FfiConverterWalletHttpHost { |
| 5756 | static std::shared_ptr<WalletHttpHost> lift(uint64_t); |
| 5757 | static uint64_t lower(const std::shared_ptr<WalletHttpHost> &); |
| 5758 | static std::shared_ptr<WalletHttpHost> read(RustStream &); |
| 5759 | static void write(RustStream &, const std::shared_ptr<WalletHttpHost> &); |
| 5760 | static uint64_t allocation_size(const std::shared_ptr<WalletHttpHost> &); |
| 5761 | private: |
| 5762 | friend struct UniffiCallbackInterfaceWalletHttpHost; |
| 5763 | inline static HandleMap<WalletHttpHost> handle_map = {}; |
| 5764 | }; |
| 5765 |
| 5766 |
| 5767 | struct FfiConverterWalletLifecycle { |
| 5768 | static std::shared_ptr<WalletLifecycle> lift(uint64_t); |
| 5769 | static uint64_t lower(const std::shared_ptr<WalletLifecycle> &); |
| 5770 | static std::shared_ptr<WalletLifecycle> read(RustStream &); |
| 5771 | static void write(RustStream &, const std::shared_ptr<WalletLifecycle> &); |
| 5772 | static uint64_t allocation_size(const std::shared_ptr<WalletLifecycle> &); |
| 5773 | private: |
| 5774 | }; |
| 5775 |
| 5776 |
| 5777 | struct FfiConverterWalletPlatformHost { |
| 5778 | static std::shared_ptr<WalletPlatformHost> lift(uint64_t); |
| 5779 | static uint64_t lower(const std::shared_ptr<WalletPlatformHost> &); |
| 5780 | static std::shared_ptr<WalletPlatformHost> read(RustStream &); |
| 5781 | static void write(RustStream &, const std::shared_ptr<WalletPlatformHost> &); |
| 5782 | static uint64_t allocation_size(const std::shared_ptr<WalletPlatformHost> &); |
| 5783 | private: |
| 5784 | friend struct UniffiCallbackInterfaceWalletPlatformHost; |
| 5785 | inline static HandleMap<WalletPlatformHost> handle_map = {}; |
| 5786 | }; |
| 5787 |
| 5788 |
| 5789 | struct FfiConverterWalletStatuslessHost { |
| 5790 | static std::shared_ptr<WalletStatuslessHost> lift(uint64_t); |
| 5791 | static uint64_t lower(const std::shared_ptr<WalletStatuslessHost> &); |
| 5792 | static std::shared_ptr<WalletStatuslessHost> read(RustStream &); |
| 5793 | static void write(RustStream &, const std::shared_ptr<WalletStatuslessHost> &); |
| 5794 | static uint64_t allocation_size(const std::shared_ptr<WalletStatuslessHost> &); |
| 5795 | private: |
| 5796 | friend struct UniffiCallbackInterfaceWalletStatuslessHost; |
| 5797 | inline static HandleMap<WalletStatuslessHost> handle_map = {}; |
| 5798 | }; |
| 5799 |
| 5800 | struct FfiConverterTypeAccountSnapshot { |
| 5801 | static AccountSnapshot lift(RustBuffer); |
| 5802 | static RustBuffer lower(const AccountSnapshot &); |
| 5803 | static AccountSnapshot read(RustStream &); |
| 5804 | static void write(RustStream &, const AccountSnapshot &); |
| 5805 | static uint64_t allocation_size(const AccountSnapshot &); |
| 5806 | }; |
| 5807 |
| 5808 | struct FfiConverterTypeActivityCursor { |
| 5809 | static ActivityCursor lift(RustBuffer); |
| 5810 | static RustBuffer lower(const ActivityCursor &); |
| 5811 | static ActivityCursor read(RustStream &); |
| 5812 | static void write(RustStream &, const ActivityCursor &); |
| 5813 | static uint64_t allocation_size(const ActivityCursor &); |
| 5814 | }; |
| 5815 |
| 5816 | struct FfiConverterTypeActivityItem { |
| 5817 | static ActivityItem lift(RustBuffer); |
| 5818 | static RustBuffer lower(const ActivityItem &); |
| 5819 | static ActivityItem read(RustStream &); |
| 5820 | static void write(RustStream &, const ActivityItem &); |
| 5821 | static uint64_t allocation_size(const ActivityItem &); |
| 5822 | }; |
| 5823 |
| 5824 | struct FfiConverterTypeActivityList { |
| 5825 | static ActivityList lift(RustBuffer); |
| 5826 | static RustBuffer lower(const ActivityList &); |
| 5827 | static ActivityList read(RustStream &); |
| 5828 | static void write(RustStream &, const ActivityList &); |
| 5829 | static uint64_t allocation_size(const ActivityList &); |
| 5830 | }; |
| 5831 |
| 5832 | struct FfiConverterTypeCreateEncryptedCommentRequest { |
| 5833 | static CreateEncryptedCommentRequest lift(RustBuffer); |
| 5834 | static RustBuffer lower(const CreateEncryptedCommentRequest &); |
| 5835 | static CreateEncryptedCommentRequest read(RustStream &); |
| 5836 | static void write(RustStream &, const CreateEncryptedCommentRequest &); |
| 5837 | static uint64_t allocation_size(const CreateEncryptedCommentRequest &); |
| 5838 | }; |
| 5839 |
| 5840 | struct FfiConverterTypeCreateWalletRequest { |
| 5841 | static CreateWalletRequest lift(RustBuffer); |
| 5842 | static RustBuffer lower(const CreateWalletRequest &); |
| 5843 | static CreateWalletRequest read(RustStream &); |
| 5844 | static void write(RustStream &, const CreateWalletRequest &); |
| 5845 | static uint64_t allocation_size(const CreateWalletRequest &); |
| 5846 | }; |
| 5847 |
| 5848 | struct FfiConverterTypeCreatedWallet { |
| 5849 | static CreatedWallet lift(RustBuffer); |
| 5850 | static RustBuffer lower(const CreatedWallet &); |
| 5851 | static CreatedWallet read(RustStream &); |
| 5852 | static void write(RustStream &, const CreatedWallet &); |
| 5853 | static uint64_t allocation_size(const CreatedWallet &); |
| 5854 | }; |
| 5855 |
| 5856 | struct FfiConverterTypeDecryptCommentRequest { |
| 5857 | static DecryptCommentRequest lift(RustBuffer); |
| 5858 | static RustBuffer lower(const DecryptCommentRequest &); |
| 5859 | static DecryptCommentRequest read(RustStream &); |
| 5860 | static void write(RustStream &, const DecryptCommentRequest &); |
| 5861 | static uint64_t allocation_size(const DecryptCommentRequest &); |
| 5862 | }; |
| 5863 |
| 5864 | struct FfiConverterTypeDomainError { |
| 5865 | static DomainError lift(RustBuffer); |
| 5866 | static RustBuffer lower(const DomainError &); |
| 5867 | static DomainError read(RustStream &); |
| 5868 | static void write(RustStream &, const DomainError &); |
| 5869 | static uint64_t allocation_size(const DomainError &); |
| 5870 | }; |
| 5871 |
| 5872 | struct FfiConverterTypeEncryptedCommentRecipientRequest { |
| 5873 | static EncryptedCommentRecipientRequest lift(RustBuffer); |
| 5874 | static RustBuffer lower(const EncryptedCommentRecipientRequest &); |
| 5875 | static EncryptedCommentRecipientRequest read(RustStream &); |
| 5876 | static void write(RustStream &, const EncryptedCommentRecipientRequest &); |
| 5877 | static uint64_t allocation_size(const EncryptedCommentRecipientRequest &); |
| 5878 | }; |
| 5879 |
| 5880 | struct FfiConverterTypeHttpHeader { |
| 5881 | static HttpHeader lift(RustBuffer); |
| 5882 | static RustBuffer lower(const HttpHeader &); |
| 5883 | static HttpHeader read(RustStream &); |
| 5884 | static void write(RustStream &, const HttpHeader &); |
| 5885 | static uint64_t allocation_size(const HttpHeader &); |
| 5886 | }; |
| 5887 |
| 5888 | struct FfiConverterTypeHttpRequest { |
| 5889 | static HttpRequest lift(RustBuffer); |
| 5890 | static RustBuffer lower(const HttpRequest &); |
| 5891 | static HttpRequest read(RustStream &); |
| 5892 | static void write(RustStream &, const HttpRequest &); |
| 5893 | static uint64_t allocation_size(const HttpRequest &); |
| 5894 | }; |
| 5895 |
| 5896 | struct FfiConverterTypeHttpRequestId { |
| 5897 | static HttpRequestId lift(RustBuffer); |
| 5898 | static RustBuffer lower(const HttpRequestId &); |
| 5899 | static HttpRequestId read(RustStream &); |
| 5900 | static void write(RustStream &, const HttpRequestId &); |
| 5901 | static uint64_t allocation_size(const HttpRequestId &); |
| 5902 | }; |
| 5903 |
| 5904 | struct FfiConverterTypeHttpResponse { |
| 5905 | static HttpResponse lift(RustBuffer); |
| 5906 | static RustBuffer lower(const HttpResponse &); |
| 5907 | static HttpResponse read(RustStream &); |
| 5908 | static void write(RustStream &, const HttpResponse &); |
| 5909 | static uint64_t allocation_size(const HttpResponse &); |
| 5910 | }; |
| 5911 |
| 5912 | struct FfiConverterTypeImportWalletRequest { |
| 5913 | static ImportWalletRequest lift(RustBuffer); |
| 5914 | static RustBuffer lower(const ImportWalletRequest &); |
| 5915 | static ImportWalletRequest read(RustStream &); |
| 5916 | static void write(RustStream &, const ImportWalletRequest &); |
| 5917 | static uint64_t allocation_size(const ImportWalletRequest &); |
| 5918 | }; |
| 5919 |
| 5920 | struct FfiConverterTypeJournalCompareExchange { |
| 5921 | static JournalCompareExchange lift(RustBuffer); |
| 5922 | static RustBuffer lower(const JournalCompareExchange &); |
| 5923 | static JournalCompareExchange read(RustStream &); |
| 5924 | static void write(RustStream &, const JournalCompareExchange &); |
| 5925 | static uint64_t allocation_size(const JournalCompareExchange &); |
| 5926 | }; |
| 5927 |
| 5928 | struct FfiConverterTypeJournalCompareExchangeResult { |
| 5929 | static JournalCompareExchangeResult lift(RustBuffer); |
| 5930 | static RustBuffer lower(const JournalCompareExchangeResult &); |
| 5931 | static JournalCompareExchangeResult read(RustStream &); |
| 5932 | static void write(RustStream &, const JournalCompareExchangeResult &); |
| 5933 | static uint64_t allocation_size(const JournalCompareExchangeResult &); |
| 5934 | }; |
| 5935 |
| 5936 | struct FfiConverterTypeJournalKey { |
| 5937 | static JournalKey lift(RustBuffer); |
| 5938 | static RustBuffer lower(const JournalKey &); |
| 5939 | static JournalKey read(RustStream &); |
| 5940 | static void write(RustStream &, const JournalKey &); |
| 5941 | static uint64_t allocation_size(const JournalKey &); |
| 5942 | }; |
| 5943 |
| 5944 | struct FfiConverterTypeJournalRecord { |
| 5945 | static JournalRecord lift(RustBuffer); |
| 5946 | static RustBuffer lower(const JournalRecord &); |
| 5947 | static JournalRecord read(RustStream &); |
| 5948 | static void write(RustStream &, const JournalRecord &); |
| 5949 | static uint64_t allocation_size(const JournalRecord &); |
| 5950 | }; |
| 5951 |
| 5952 | struct FfiConverterTypeNftCollectionDescriptor { |
| 5953 | static NftCollectionDescriptor lift(RustBuffer); |
| 5954 | static RustBuffer lower(const NftCollectionDescriptor &); |
| 5955 | static NftCollectionDescriptor read(RustStream &); |
| 5956 | static void write(RustStream &, const NftCollectionDescriptor &); |
| 5957 | static uint64_t allocation_size(const NftCollectionDescriptor &); |
| 5958 | }; |
| 5959 |
| 5960 | struct FfiConverterTypeNftItem { |
| 5961 | static NftItem lift(RustBuffer); |
| 5962 | static RustBuffer lower(const NftItem &); |
| 5963 | static NftItem read(RustStream &); |
| 5964 | static void write(RustStream &, const NftItem &); |
| 5965 | static uint64_t allocation_size(const NftItem &); |
| 5966 | }; |
| 5967 |
| 5968 | struct FfiConverterTypeNftList { |
| 5969 | static NftList lift(RustBuffer); |
| 5970 | static RustBuffer lower(const NftList &); |
| 5971 | static NftList read(RustStream &); |
| 5972 | static void write(RustStream &, const NftList &); |
| 5973 | static uint64_t allocation_size(const NftList &); |
| 5974 | }; |
| 5975 |
| 5976 | struct FfiConverterTypeNftTransferIntent { |
| 5977 | static NftTransferIntent lift(RustBuffer); |
| 5978 | static RustBuffer lower(const NftTransferIntent &); |
| 5979 | static NftTransferIntent read(RustStream &); |
| 5980 | static void write(RustStream &, const NftTransferIntent &); |
| 5981 | static uint64_t allocation_size(const NftTransferIntent &); |
| 5982 | }; |
| 5983 |
| 5984 | struct FfiConverterTypeNftTransferPreviewRequest { |
| 5985 | static NftTransferPreviewRequest lift(RustBuffer); |
| 5986 | static RustBuffer lower(const NftTransferPreviewRequest &); |
| 5987 | static NftTransferPreviewRequest read(RustStream &); |
| 5988 | static void write(RustStream &, const NftTransferPreviewRequest &); |
| 5989 | static uint64_t allocation_size(const NftTransferPreviewRequest &); |
| 5990 | }; |
| 5991 |
| 5992 | struct FfiConverterTypeNftTransferRequest { |
| 5993 | static NftTransferRequest lift(RustBuffer); |
| 5994 | static RustBuffer lower(const NftTransferRequest &); |
| 5995 | static NftTransferRequest read(RustStream &); |
| 5996 | static void write(RustStream &, const NftTransferRequest &); |
| 5997 | static uint64_t allocation_size(const NftTransferRequest &); |
| 5998 | }; |
| 5999 |
| 6000 | struct FfiConverterTypeParsedTonTransferLink { |
| 6001 | static ParsedTonTransferLink lift(RustBuffer); |
| 6002 | static RustBuffer lower(const ParsedTonTransferLink &); |
| 6003 | static ParsedTonTransferLink read(RustStream &); |
| 6004 | static void write(RustStream &, const ParsedTonTransferLink &); |
| 6005 | static uint64_t allocation_size(const ParsedTonTransferLink &); |
| 6006 | }; |
| 6007 |
| 6008 | struct FfiConverterTypePrepareKeyRotationRequest { |
| 6009 | static PrepareKeyRotationRequest lift(RustBuffer); |
| 6010 | static RustBuffer lower(const PrepareKeyRotationRequest &); |
| 6011 | static PrepareKeyRotationRequest read(RustStream &); |
| 6012 | static void write(RustStream &, const PrepareKeyRotationRequest &); |
| 6013 | static uint64_t allocation_size(const PrepareKeyRotationRequest &); |
| 6014 | }; |
| 6015 |
| 6016 | struct FfiConverterTypePrepareNftTransferRequest { |
| 6017 | static PrepareNftTransferRequest lift(RustBuffer); |
| 6018 | static RustBuffer lower(const PrepareNftTransferRequest &); |
| 6019 | static PrepareNftTransferRequest read(RustStream &); |
| 6020 | static void write(RustStream &, const PrepareNftTransferRequest &); |
| 6021 | static uint64_t allocation_size(const PrepareNftTransferRequest &); |
| 6022 | }; |
| 6023 |
| 6024 | struct FfiConverterTypePrepareTransferRequest { |
| 6025 | static PrepareTransferRequest lift(RustBuffer); |
| 6026 | static RustBuffer lower(const PrepareTransferRequest &); |
| 6027 | static PrepareTransferRequest read(RustStream &); |
| 6028 | static void write(RustStream &, const PrepareTransferRequest &); |
| 6029 | static uint64_t allocation_size(const PrepareTransferRequest &); |
| 6030 | }; |
| 6031 |
| 6032 | struct FfiConverterTypePreparedKeyRotation { |
| 6033 | static PreparedKeyRotation lift(RustBuffer); |
| 6034 | static RustBuffer lower(const PreparedKeyRotation &); |
| 6035 | static PreparedKeyRotation read(RustStream &); |
| 6036 | static void write(RustStream &, const PreparedKeyRotation &); |
| 6037 | static uint64_t allocation_size(const PreparedKeyRotation &); |
| 6038 | }; |
| 6039 |
| 6040 | struct FfiConverterTypePreparedTransfer { |
| 6041 | static PreparedTransfer lift(RustBuffer); |
| 6042 | static RustBuffer lower(const PreparedTransfer &); |
| 6043 | static PreparedTransfer read(RustStream &); |
| 6044 | static void write(RustStream &, const PreparedTransfer &); |
| 6045 | static uint64_t allocation_size(const PreparedTransfer &); |
| 6046 | }; |
| 6047 |
| 6048 | struct FfiConverterTypeProtectedSecretRead { |
| 6049 | static ProtectedSecretRead lift(RustBuffer); |
| 6050 | static RustBuffer lower(const ProtectedSecretRead &); |
| 6051 | static ProtectedSecretRead read(RustStream &); |
| 6052 | static void write(RustStream &, const ProtectedSecretRead &); |
| 6053 | static uint64_t allocation_size(const ProtectedSecretRead &); |
| 6054 | }; |
| 6055 |
| 6056 | struct FfiConverterTypeProtectedSecretRef { |
| 6057 | static ProtectedSecretRef lift(RustBuffer); |
| 6058 | static RustBuffer lower(const ProtectedSecretRef &); |
| 6059 | static ProtectedSecretRef read(RustStream &); |
| 6060 | static void write(RustStream &, const ProtectedSecretRef &); |
| 6061 | static uint64_t allocation_size(const ProtectedSecretRef &); |
| 6062 | }; |
| 6063 |
| 6064 | struct FfiConverterTypeProtectedSecretStore { |
| 6065 | static ProtectedSecretStore lift(RustBuffer); |
| 6066 | static RustBuffer lower(const ProtectedSecretStore &); |
| 6067 | static ProtectedSecretStore read(RustStream &); |
| 6068 | static void write(RustStream &, const ProtectedSecretStore &); |
| 6069 | static uint64_t allocation_size(const ProtectedSecretStore &); |
| 6070 | }; |
| 6071 |
| 6072 | struct FfiConverterTypeProviderConfig { |
| 6073 | static ProviderConfig lift(RustBuffer); |
| 6074 | static RustBuffer lower(const ProviderConfig &); |
| 6075 | static ProviderConfig read(RustStream &); |
| 6076 | static void write(RustStream &, const ProviderConfig &); |
| 6077 | static uint64_t allocation_size(const ProviderConfig &); |
| 6078 | }; |
| 6079 |
| 6080 | struct FfiConverterTypeRecoveryPhrase { |
| 6081 | static RecoveryPhrase lift(RustBuffer); |
| 6082 | static RustBuffer lower(const RecoveryPhrase &); |
| 6083 | static RecoveryPhrase read(RustStream &); |
| 6084 | static void write(RustStream &, const RecoveryPhrase &); |
| 6085 | static uint64_t allocation_size(const RecoveryPhrase &); |
| 6086 | }; |
| 6087 |
| 6088 | struct FfiConverterTypeResolutionInfo { |
| 6089 | static ResolutionInfo lift(RustBuffer); |
| 6090 | static RustBuffer lower(const ResolutionInfo &); |
| 6091 | static ResolutionInfo read(RustStream &); |
| 6092 | static void write(RustStream &, const ResolutionInfo &); |
| 6093 | static uint64_t allocation_size(const ResolutionInfo &); |
| 6094 | }; |
| 6095 |
| 6096 | struct FfiConverterTypeResourceState { |
| 6097 | static ResourceState lift(RustBuffer); |
| 6098 | static RustBuffer lower(const ResourceState &); |
| 6099 | static ResourceState read(RustStream &); |
| 6100 | static void write(RustStream &, const ResourceState &); |
| 6101 | static uint64_t allocation_size(const ResourceState &); |
| 6102 | }; |
| 6103 |
| 6104 | struct FfiConverterTypeSendBocRequest { |
| 6105 | static SendBocRequest lift(RustBuffer); |
| 6106 | static RustBuffer lower(const SendBocRequest &); |
| 6107 | static SendBocRequest read(RustStream &); |
| 6108 | static void write(RustStream &, const SendBocRequest &); |
| 6109 | static uint64_t allocation_size(const SendBocRequest &); |
| 6110 | }; |
| 6111 |
| 6112 | struct FfiConverterTypeSendEmulation { |
| 6113 | static SendEmulation lift(RustBuffer); |
| 6114 | static RustBuffer lower(const SendEmulation &); |
| 6115 | static SendEmulation read(RustStream &); |
| 6116 | static void write(RustStream &, const SendEmulation &); |
| 6117 | static uint64_t allocation_size(const SendEmulation &); |
| 6118 | }; |
| 6119 |
| 6120 | struct FfiConverterTypeSendEmulationAction { |
| 6121 | static SendEmulationAction lift(RustBuffer); |
| 6122 | static RustBuffer lower(const SendEmulationAction &); |
| 6123 | static SendEmulationAction read(RustStream &); |
| 6124 | static void write(RustStream &, const SendEmulationAction &); |
| 6125 | static uint64_t allocation_size(const SendEmulationAction &); |
| 6126 | }; |
| 6127 |
| 6128 | struct FfiConverterTypeSendEmulationTransaction { |
| 6129 | static SendEmulationTransaction lift(RustBuffer); |
| 6130 | static RustBuffer lower(const SendEmulationTransaction &); |
| 6131 | static SendEmulationTransaction read(RustStream &); |
| 6132 | static void write(RustStream &, const SendEmulationTransaction &); |
| 6133 | static uint64_t allocation_size(const SendEmulationTransaction &); |
| 6134 | }; |
| 6135 |
| 6136 | struct FfiConverterTypeSendIntent { |
| 6137 | static SendIntent lift(RustBuffer); |
| 6138 | static RustBuffer lower(const SendIntent &); |
| 6139 | static SendIntent read(RustStream &); |
| 6140 | static void write(RustStream &, const SendIntent &); |
| 6141 | static uint64_t allocation_size(const SendIntent &); |
| 6142 | }; |
| 6143 |
| 6144 | struct FfiConverterTypeSendMessage { |
| 6145 | static SendMessage lift(RustBuffer); |
| 6146 | static RustBuffer lower(const SendMessage &); |
| 6147 | static SendMessage read(RustStream &); |
| 6148 | static void write(RustStream &, const SendMessage &); |
| 6149 | static uint64_t allocation_size(const SendMessage &); |
| 6150 | }; |
| 6151 |
| 6152 | struct FfiConverterTypeSendPreview { |
| 6153 | static SendPreview lift(RustBuffer); |
| 6154 | static RustBuffer lower(const SendPreview &); |
| 6155 | static SendPreview read(RustStream &); |
| 6156 | static void write(RustStream &, const SendPreview &); |
| 6157 | static uint64_t allocation_size(const SendPreview &); |
| 6158 | }; |
| 6159 |
| 6160 | struct FfiConverterTypeSendPreviewRequest { |
| 6161 | static SendPreviewRequest lift(RustBuffer); |
| 6162 | static RustBuffer lower(const SendPreviewRequest &); |
| 6163 | static SendPreviewRequest read(RustStream &); |
| 6164 | static void write(RustStream &, const SendPreviewRequest &); |
| 6165 | static uint64_t allocation_size(const SendPreviewRequest &); |
| 6166 | }; |
| 6167 |
| 6168 | struct FfiConverterTypeSendRequest { |
| 6169 | static SendRequest lift(RustBuffer); |
| 6170 | static RustBuffer lower(const SendRequest &); |
| 6171 | static SendRequest read(RustStream &); |
| 6172 | static void write(RustStream &, const SendRequest &); |
| 6173 | static uint64_t allocation_size(const SendRequest &); |
| 6174 | }; |
| 6175 |
| 6176 | struct FfiConverterTypeSendResult { |
| 6177 | static SendResult lift(RustBuffer); |
| 6178 | static RustBuffer lower(const SendResult &); |
| 6179 | static SendResult read(RustStream &); |
| 6180 | static void write(RustStream &, const SendResult &); |
| 6181 | static uint64_t allocation_size(const SendResult &); |
| 6182 | }; |
| 6183 |
| 6184 | struct FfiConverterTypeSendSnapshot { |
| 6185 | static SendSnapshot lift(RustBuffer); |
| 6186 | static RustBuffer lower(const SendSnapshot &); |
| 6187 | static SendSnapshot read(RustStream &); |
| 6188 | static void write(RustStream &, const SendSnapshot &); |
| 6189 | static uint64_t allocation_size(const SendSnapshot &); |
| 6190 | }; |
| 6191 |
| 6192 | struct FfiConverterTypeSignMessagePreview { |
| 6193 | static SignMessagePreview lift(RustBuffer); |
| 6194 | static RustBuffer lower(const SignMessagePreview &); |
| 6195 | static SignMessagePreview read(RustStream &); |
| 6196 | static void write(RustStream &, const SignMessagePreview &); |
| 6197 | static uint64_t allocation_size(const SignMessagePreview &); |
| 6198 | }; |
| 6199 |
| 6200 | struct FfiConverterTypeSignMessageRequest { |
| 6201 | static SignMessageRequest lift(RustBuffer); |
| 6202 | static RustBuffer lower(const SignMessageRequest &); |
| 6203 | static SignMessageRequest read(RustStream &); |
| 6204 | static void write(RustStream &, const SignMessageRequest &); |
| 6205 | static uint64_t allocation_size(const SignMessageRequest &); |
| 6206 | }; |
| 6207 |
| 6208 | struct FfiConverterTypeSignMessageResult { |
| 6209 | static SignMessageResult lift(RustBuffer); |
| 6210 | static RustBuffer lower(const SignMessageResult &); |
| 6211 | static SignMessageResult read(RustStream &); |
| 6212 | static void write(RustStream &, const SignMessageResult &); |
| 6213 | static uint64_t allocation_size(const SignMessageResult &); |
| 6214 | }; |
| 6215 |
| 6216 | struct FfiConverterTypeTonAddressInfo { |
| 6217 | static TonAddressInfo lift(RustBuffer); |
| 6218 | static RustBuffer lower(const TonAddressInfo &); |
| 6219 | static TonAddressInfo read(RustStream &); |
| 6220 | static void write(RustStream &, const TonAddressInfo &); |
| 6221 | static uint64_t allocation_size(const TonAddressInfo &); |
| 6222 | }; |
| 6223 |
| 6224 | struct FfiConverterTypeTonConnectAccountInfo { |
| 6225 | static TonConnectAccountInfo lift(RustBuffer); |
| 6226 | static RustBuffer lower(const TonConnectAccountInfo &); |
| 6227 | static TonConnectAccountInfo read(RustStream &); |
| 6228 | static void write(RustStream &, const TonConnectAccountInfo &); |
| 6229 | static uint64_t allocation_size(const TonConnectAccountInfo &); |
| 6230 | }; |
| 6231 |
| 6232 | struct FfiConverterTypeTonConnectConnectPrompt { |
| 6233 | static TonConnectConnectPrompt lift(RustBuffer); |
| 6234 | static RustBuffer lower(const TonConnectConnectPrompt &); |
| 6235 | static TonConnectConnectPrompt read(RustStream &); |
| 6236 | static void write(RustStream &, const TonConnectConnectPrompt &); |
| 6237 | static uint64_t allocation_size(const TonConnectConnectPrompt &); |
| 6238 | }; |
| 6239 |
| 6240 | struct FfiConverterTypeTonConnectDerivedRequest { |
| 6241 | static TonConnectDerivedRequest lift(RustBuffer); |
| 6242 | static RustBuffer lower(const TonConnectDerivedRequest &); |
| 6243 | static TonConnectDerivedRequest read(RustStream &); |
| 6244 | static void write(RustStream &, const TonConnectDerivedRequest &); |
| 6245 | static uint64_t allocation_size(const TonConnectDerivedRequest &); |
| 6246 | }; |
| 6247 |
| 6248 | struct FfiConverterTypeTonConnectDerivedSessionRequest { |
| 6249 | static TonConnectDerivedSessionRequest lift(RustBuffer); |
| 6250 | static RustBuffer lower(const TonConnectDerivedSessionRequest &); |
| 6251 | static TonConnectDerivedSessionRequest read(RustStream &); |
| 6252 | static void write(RustStream &, const TonConnectDerivedSessionRequest &); |
| 6253 | static uint64_t allocation_size(const TonConnectDerivedSessionRequest &); |
| 6254 | }; |
| 6255 |
| 6256 | struct FfiConverterTypeTonConnectDevice { |
| 6257 | static TonConnectDevice lift(RustBuffer); |
| 6258 | static RustBuffer lower(const TonConnectDevice &); |
| 6259 | static TonConnectDevice read(RustStream &); |
| 6260 | static void write(RustStream &, const TonConnectDevice &); |
| 6261 | static uint64_t allocation_size(const TonConnectDevice &); |
| 6262 | }; |
| 6263 |
| 6264 | struct FfiConverterTypeTonConnectManifest { |
| 6265 | static TonConnectManifest lift(RustBuffer); |
| 6266 | static RustBuffer lower(const TonConnectManifest &); |
| 6267 | static TonConnectManifest read(RustStream &); |
| 6268 | static void write(RustStream &, const TonConnectManifest &); |
| 6269 | static uint64_t allocation_size(const TonConnectManifest &); |
| 6270 | }; |
| 6271 |
| 6272 | struct FfiConverterTypeTonConnectPreparedPost { |
| 6273 | static TonConnectPreparedPost lift(RustBuffer); |
| 6274 | static RustBuffer lower(const TonConnectPreparedPost &); |
| 6275 | static TonConnectPreparedPost read(RustStream &); |
| 6276 | static void write(RustStream &, const TonConnectPreparedPost &); |
| 6277 | static uint64_t allocation_size(const TonConnectPreparedPost &); |
| 6278 | }; |
| 6279 |
| 6280 | struct FfiConverterTypeTonConnectProofReply { |
| 6281 | static TonConnectProofReply lift(RustBuffer); |
| 6282 | static RustBuffer lower(const TonConnectProofReply &); |
| 6283 | static TonConnectProofReply read(RustStream &); |
| 6284 | static void write(RustStream &, const TonConnectProofReply &); |
| 6285 | static uint64_t allocation_size(const TonConnectProofReply &); |
| 6286 | }; |
| 6287 |
| 6288 | struct FfiConverterTypeTonConnectProofSignRequest { |
| 6289 | static TonConnectProofSignRequest lift(RustBuffer); |
| 6290 | static RustBuffer lower(const TonConnectProofSignRequest &); |
| 6291 | static TonConnectProofSignRequest read(RustStream &); |
| 6292 | static void write(RustStream &, const TonConnectProofSignRequest &); |
| 6293 | static uint64_t allocation_size(const TonConnectProofSignRequest &); |
| 6294 | }; |
| 6295 |
| 6296 | struct FfiConverterTypeTonConnectProofSignature { |
| 6297 | static TonConnectProofSignature lift(RustBuffer); |
| 6298 | static RustBuffer lower(const TonConnectProofSignature &); |
| 6299 | static TonConnectProofSignature read(RustStream &); |
| 6300 | static void write(RustStream &, const TonConnectProofSignature &); |
| 6301 | static uint64_t allocation_size(const TonConnectProofSignature &); |
| 6302 | }; |
| 6303 |
| 6304 | struct FfiConverterTypeTonConnectSessionConfig { |
| 6305 | static TonConnectSessionConfig lift(RustBuffer); |
| 6306 | static RustBuffer lower(const TonConnectSessionConfig &); |
| 6307 | static TonConnectSessionConfig read(RustStream &); |
| 6308 | static void write(RustStream &, const TonConnectSessionConfig &); |
| 6309 | static uint64_t allocation_size(const TonConnectSessionConfig &); |
| 6310 | }; |
| 6311 |
| 6312 | struct FfiConverterTypeTonConnectSignDataRequest { |
| 6313 | static TonConnectSignDataRequest lift(RustBuffer); |
| 6314 | static RustBuffer lower(const TonConnectSignDataRequest &); |
| 6315 | static TonConnectSignDataRequest read(RustStream &); |
| 6316 | static void write(RustStream &, const TonConnectSignDataRequest &); |
| 6317 | static uint64_t allocation_size(const TonConnectSignDataRequest &); |
| 6318 | }; |
| 6319 |
| 6320 | struct FfiConverterTypeTonConnectSignDataSignRequest { |
| 6321 | static TonConnectSignDataSignRequest lift(RustBuffer); |
| 6322 | static RustBuffer lower(const TonConnectSignDataSignRequest &); |
| 6323 | static TonConnectSignDataSignRequest read(RustStream &); |
| 6324 | static void write(RustStream &, const TonConnectSignDataSignRequest &); |
| 6325 | static uint64_t allocation_size(const TonConnectSignDataSignRequest &); |
| 6326 | }; |
| 6327 |
| 6328 | struct FfiConverterTypeTonConnectSignedData { |
| 6329 | static TonConnectSignedData lift(RustBuffer); |
| 6330 | static RustBuffer lower(const TonConnectSignedData &); |
| 6331 | static TonConnectSignedData read(RustStream &); |
| 6332 | static void write(RustStream &, const TonConnectSignedData &); |
| 6333 | static uint64_t allocation_size(const TonConnectSignedData &); |
| 6334 | }; |
| 6335 |
| 6336 | struct FfiConverterTypeWalletClientConfig { |
| 6337 | static WalletClientConfig lift(RustBuffer); |
| 6338 | static RustBuffer lower(const WalletClientConfig &); |
| 6339 | static WalletClientConfig read(RustStream &); |
| 6340 | static void write(RustStream &, const WalletClientConfig &); |
| 6341 | static uint64_t allocation_size(const WalletClientConfig &); |
| 6342 | }; |
| 6343 |
| 6344 | struct FfiConverterTypeWalletDescriptor { |
| 6345 | static WalletDescriptor lift(RustBuffer); |
| 6346 | static RustBuffer lower(const WalletDescriptor &); |
| 6347 | static WalletDescriptor read(RustStream &); |
| 6348 | static void write(RustStream &, const WalletDescriptor &); |
| 6349 | static uint64_t allocation_size(const WalletDescriptor &); |
| 6350 | }; |
| 6351 |
| 6352 | struct FfiConverterTypeWalletSnapshot { |
| 6353 | static WalletSnapshot lift(RustBuffer); |
| 6354 | static RustBuffer lower(const WalletSnapshot &); |
| 6355 | static WalletSnapshot read(RustStream &); |
| 6356 | static void write(RustStream &, const WalletSnapshot &); |
| 6357 | static uint64_t allocation_size(const WalletSnapshot &); |
| 6358 | }; |
| 6359 |
| 6360 | struct FfiConverterTypeWalletUpdate { |
| 6361 | static WalletUpdate lift(RustBuffer); |
| 6362 | static RustBuffer lower(const WalletUpdate &); |
| 6363 | static WalletUpdate read(RustStream &); |
| 6364 | static void write(RustStream &, const WalletUpdate &); |
| 6365 | static uint64_t allocation_size(const WalletUpdate &); |
| 6366 | }; |
| 6367 | struct FfiConverterAccountStatus { |
| 6368 | static AccountStatus lift(RustBuffer); |
| 6369 | static RustBuffer lower(const AccountStatus &); |
| 6370 | static AccountStatus read(RustStream &); |
| 6371 | static void write(RustStream &, const AccountStatus &); |
| 6372 | static uint64_t allocation_size(const AccountStatus &); |
| 6373 | }; |
| 6374 | struct FfiConverterActivityDirection { |
| 6375 | static ActivityDirection lift(RustBuffer); |
| 6376 | static RustBuffer lower(const ActivityDirection &); |
| 6377 | static ActivityDirection read(RustStream &); |
| 6378 | static void write(RustStream &, const ActivityDirection &); |
| 6379 | static uint64_t allocation_size(const ActivityDirection &); |
| 6380 | }; |
| 6381 | struct FfiConverterActivityStatus { |
| 6382 | static ActivityStatus lift(RustBuffer); |
| 6383 | static RustBuffer lower(const ActivityStatus &); |
| 6384 | static ActivityStatus read(RustStream &); |
| 6385 | static void write(RustStream &, const ActivityStatus &); |
| 6386 | static uint64_t allocation_size(const ActivityStatus &); |
| 6387 | }; |
| 6388 | struct FfiConverterErrorCategory { |
| 6389 | static ErrorCategory lift(RustBuffer); |
| 6390 | static RustBuffer lower(const ErrorCategory &); |
| 6391 | static ErrorCategory read(RustStream &); |
| 6392 | static void write(RustStream &, const ErrorCategory &); |
| 6393 | static uint64_t allocation_size(const ErrorCategory &); |
| 6394 | }; |
| 6395 | struct FfiConverterErrorCode { |
| 6396 | static ErrorCode lift(RustBuffer); |
| 6397 | static RustBuffer lower(const ErrorCode &); |
| 6398 | static ErrorCode read(RustStream &); |
| 6399 | static void write(RustStream &, const ErrorCode &); |
| 6400 | static uint64_t allocation_size(const ErrorCode &); |
| 6401 | }; |
| 6402 |
| 6403 | struct FfiConverterHttpHostError { |
| 6404 | static std::shared_ptr<HttpHostError> lift(RustBuffer buf); |
| 6405 | static RustBuffer lower(const HttpHostError &); |
| 6406 | static std::shared_ptr<HttpHostError> read(RustStream &stream); |
| 6407 | static void write(RustStream &stream, const HttpHostError &); |
| 6408 | static uint64_t allocation_size(const HttpHostError &); |
| 6409 | }; |
| 6410 | struct FfiConverterHttpHostErrorKind { |
| 6411 | static HttpHostErrorKind lift(RustBuffer); |
| 6412 | static RustBuffer lower(const HttpHostErrorKind &); |
| 6413 | static HttpHostErrorKind read(RustStream &); |
| 6414 | static void write(RustStream &, const HttpHostErrorKind &); |
| 6415 | static uint64_t allocation_size(const HttpHostErrorKind &); |
| 6416 | }; |
| 6417 | struct FfiConverterHttpMethod { |
| 6418 | static HttpMethod lift(RustBuffer); |
| 6419 | static RustBuffer lower(const HttpMethod &); |
| 6420 | static HttpMethod read(RustStream &); |
| 6421 | static void write(RustStream &, const HttpMethod &); |
| 6422 | static uint64_t allocation_size(const HttpMethod &); |
| 6423 | }; |
| 6424 |
| 6425 | struct FfiConverterJournalHostError { |
| 6426 | static std::shared_ptr<JournalHostError> lift(RustBuffer buf); |
| 6427 | static RustBuffer lower(const JournalHostError &); |
| 6428 | static std::shared_ptr<JournalHostError> read(RustStream &stream); |
| 6429 | static void write(RustStream &stream, const JournalHostError &); |
| 6430 | static uint64_t allocation_size(const JournalHostError &); |
| 6431 | }; |
| 6432 | struct FfiConverterJournalHostErrorKind { |
| 6433 | static JournalHostErrorKind lift(RustBuffer); |
| 6434 | static RustBuffer lower(const JournalHostErrorKind &); |
| 6435 | static JournalHostErrorKind read(RustStream &); |
| 6436 | static void write(RustStream &, const JournalHostErrorKind &); |
| 6437 | static uint64_t allocation_size(const JournalHostErrorKind &); |
| 6438 | }; |
| 6439 | struct FfiConverterKeyRotationMessageKind { |
| 6440 | static KeyRotationMessageKind lift(RustBuffer); |
| 6441 | static RustBuffer lower(const KeyRotationMessageKind &); |
| 6442 | static KeyRotationMessageKind read(RustStream &); |
| 6443 | static void write(RustStream &, const KeyRotationMessageKind &); |
| 6444 | static uint64_t allocation_size(const KeyRotationMessageKind &); |
| 6445 | }; |
| 6446 | struct FfiConverterMnemonicScheme { |
| 6447 | static MnemonicScheme lift(RustBuffer); |
| 6448 | static RustBuffer lower(const MnemonicScheme &); |
| 6449 | static MnemonicScheme read(RustStream &); |
| 6450 | static void write(RustStream &, const MnemonicScheme &); |
| 6451 | static uint64_t allocation_size(const MnemonicScheme &); |
| 6452 | }; |
| 6453 | struct FfiConverterNetwork { |
| 6454 | static Network lift(RustBuffer); |
| 6455 | static RustBuffer lower(const Network &); |
| 6456 | static Network read(RustStream &); |
| 6457 | static void write(RustStream &, const Network &); |
| 6458 | static uint64_t allocation_size(const Network &); |
| 6459 | }; |
| 6460 | struct FfiConverterNftTransferFunding { |
| 6461 | static NftTransferFunding lift(RustBuffer); |
| 6462 | static RustBuffer lower(const NftTransferFunding &); |
| 6463 | static NftTransferFunding read(RustStream &); |
| 6464 | static void write(RustStream &, const NftTransferFunding &); |
| 6465 | static uint64_t allocation_size(const NftTransferFunding &); |
| 6466 | }; |
| 6467 | struct FfiConverterNftTransferPayload { |
| 6468 | static NftTransferPayload lift(RustBuffer); |
| 6469 | static RustBuffer lower(const NftTransferPayload &); |
| 6470 | static NftTransferPayload read(RustStream &); |
| 6471 | static void write(RustStream &, const NftTransferPayload &); |
| 6472 | static uint64_t allocation_size(const NftTransferPayload &); |
| 6473 | }; |
| 6474 | struct FfiConverterPendingReason { |
| 6475 | static PendingReason lift(RustBuffer); |
| 6476 | static RustBuffer lower(const PendingReason &); |
| 6477 | static PendingReason read(RustStream &); |
| 6478 | static void write(RustStream &, const PendingReason &); |
| 6479 | static uint64_t allocation_size(const PendingReason &); |
| 6480 | }; |
| 6481 |
| 6482 | struct FfiConverterProtectedSecretHostError { |
| 6483 | static std::shared_ptr<ProtectedSecretHostError> lift(RustBuffer buf); |
| 6484 | static RustBuffer lower(const ProtectedSecretHostError &); |
| 6485 | static std::shared_ptr<ProtectedSecretHostError> read(RustStream &stream); |
| 6486 | static void write(RustStream &stream, const ProtectedSecretHostError &); |
| 6487 | static uint64_t allocation_size(const ProtectedSecretHostError &); |
| 6488 | }; |
| 6489 | struct FfiConverterProtectedSecretHostErrorKind { |
| 6490 | static ProtectedSecretHostErrorKind lift(RustBuffer); |
| 6491 | static RustBuffer lower(const ProtectedSecretHostErrorKind &); |
| 6492 | static ProtectedSecretHostErrorKind read(RustStream &); |
| 6493 | static void write(RustStream &, const ProtectedSecretHostErrorKind &); |
| 6494 | static uint64_t allocation_size(const ProtectedSecretHostErrorKind &); |
| 6495 | }; |
| 6496 | struct FfiConverterResourcePhase { |
| 6497 | static ResourcePhase lift(RustBuffer); |
| 6498 | static RustBuffer lower(const ResourcePhase &); |
| 6499 | static ResourcePhase read(RustStream &); |
| 6500 | static void write(RustStream &, const ResourcePhase &); |
| 6501 | static uint64_t allocation_size(const ResourcePhase &); |
| 6502 | }; |
| 6503 | struct FfiConverterRetryAdvice { |
| 6504 | static RetryAdvice lift(RustBuffer); |
| 6505 | static RustBuffer lower(const RetryAdvice &); |
| 6506 | static RetryAdvice read(RustStream &); |
| 6507 | static void write(RustStream &, const RetryAdvice &); |
| 6508 | static uint64_t allocation_size(const RetryAdvice &); |
| 6509 | }; |
| 6510 | struct FfiConverterSecretAccessReason { |
| 6511 | static SecretAccessReason lift(RustBuffer); |
| 6512 | static RustBuffer lower(const SecretAccessReason &); |
| 6513 | static SecretAccessReason read(RustStream &); |
| 6514 | static void write(RustStream &, const SecretAccessReason &); |
| 6515 | static uint64_t allocation_size(const SecretAccessReason &); |
| 6516 | }; |
| 6517 | struct FfiConverterSendAmount { |
| 6518 | static SendAmount lift(RustBuffer); |
| 6519 | static RustBuffer lower(const SendAmount &); |
| 6520 | static SendAmount read(RustStream &); |
| 6521 | static void write(RustStream &, const SendAmount &); |
| 6522 | static uint64_t allocation_size(const SendAmount &); |
| 6523 | }; |
| 6524 | struct FfiConverterSendExpiration { |
| 6525 | static SendExpiration lift(RustBuffer); |
| 6526 | static RustBuffer lower(const SendExpiration &); |
| 6527 | static SendExpiration read(RustStream &); |
| 6528 | static void write(RustStream &, const SendExpiration &); |
| 6529 | static uint64_t allocation_size(const SendExpiration &); |
| 6530 | }; |
| 6531 | struct FfiConverterSendMessageBody { |
| 6532 | static SendMessageBody lift(RustBuffer); |
| 6533 | static RustBuffer lower(const SendMessageBody &); |
| 6534 | static SendMessageBody read(RustStream &); |
| 6535 | static void write(RustStream &, const SendMessageBody &); |
| 6536 | static uint64_t allocation_size(const SendMessageBody &); |
| 6537 | }; |
| 6538 | struct FfiConverterSendPhase { |
| 6539 | static SendPhase lift(RustBuffer); |
| 6540 | static RustBuffer lower(const SendPhase &); |
| 6541 | static SendPhase read(RustStream &); |
| 6542 | static void write(RustStream &, const SendPhase &); |
| 6543 | static uint64_t allocation_size(const SendPhase &); |
| 6544 | }; |
| 6545 |
| 6546 | struct FfiConverterStatuslessHostError { |
| 6547 | static std::shared_ptr<StatuslessHostError> lift(RustBuffer buf); |
| 6548 | static RustBuffer lower(const StatuslessHostError &); |
| 6549 | static std::shared_ptr<StatuslessHostError> read(RustStream &stream); |
| 6550 | static void write(RustStream &stream, const StatuslessHostError &); |
| 6551 | static uint64_t allocation_size(const StatuslessHostError &); |
| 6552 | }; |
| 6553 | struct FfiConverterStatuslessHostErrorKind { |
| 6554 | static StatuslessHostErrorKind lift(RustBuffer); |
| 6555 | static RustBuffer lower(const StatuslessHostErrorKind &); |
| 6556 | static StatuslessHostErrorKind read(RustStream &); |
| 6557 | static void write(RustStream &, const StatuslessHostErrorKind &); |
| 6558 | static uint64_t allocation_size(const StatuslessHostErrorKind &); |
| 6559 | }; |
| 6560 |
| 6561 | struct FfiConverterTonAddressError { |
| 6562 | static std::shared_ptr<TonAddressError> lift(RustBuffer buf); |
| 6563 | static RustBuffer lower(const TonAddressError &); |
| 6564 | static std::shared_ptr<TonAddressError> read(RustStream &stream); |
| 6565 | static void write(RustStream &stream, const TonAddressError &); |
| 6566 | static uint64_t allocation_size(const TonAddressError &); |
| 6567 | }; |
| 6568 | struct FfiConverterTonAddressFormat { |
| 6569 | static TonAddressFormat lift(RustBuffer); |
| 6570 | static RustBuffer lower(const TonAddressFormat &); |
| 6571 | static TonAddressFormat read(RustStream &); |
| 6572 | static void write(RustStream &, const TonAddressFormat &); |
| 6573 | static uint64_t allocation_size(const TonAddressFormat &); |
| 6574 | }; |
| 6575 | struct FfiConverterTonConnectConnectErrorCode { |
| 6576 | static TonConnectConnectErrorCode lift(RustBuffer); |
| 6577 | static RustBuffer lower(const TonConnectConnectErrorCode &); |
| 6578 | static TonConnectConnectErrorCode read(RustStream &); |
| 6579 | static void write(RustStream &, const TonConnectConnectErrorCode &); |
| 6580 | static uint64_t allocation_size(const TonConnectConnectErrorCode &); |
| 6581 | }; |
| 6582 | struct FfiConverterTonConnectDevicePlatform { |
| 6583 | static TonConnectDevicePlatform lift(RustBuffer); |
| 6584 | static RustBuffer lower(const TonConnectDevicePlatform &); |
| 6585 | static TonConnectDevicePlatform read(RustStream &); |
| 6586 | static void write(RustStream &, const TonConnectDevicePlatform &); |
| 6587 | static uint64_t allocation_size(const TonConnectDevicePlatform &); |
| 6588 | }; |
| 6589 | struct FfiConverterTonConnectIncomingRequest { |
| 6590 | static TonConnectIncomingRequest lift(RustBuffer); |
| 6591 | static RustBuffer lower(const TonConnectIncomingRequest &); |
| 6592 | static TonConnectIncomingRequest read(RustStream &); |
| 6593 | static void write(RustStream &, const TonConnectIncomingRequest &); |
| 6594 | static uint64_t allocation_size(const TonConnectIncomingRequest &); |
| 6595 | }; |
| 6596 | struct FfiConverterTonConnectRpcErrorCode { |
| 6597 | static TonConnectRpcErrorCode lift(RustBuffer); |
| 6598 | static RustBuffer lower(const TonConnectRpcErrorCode &); |
| 6599 | static TonConnectRpcErrorCode read(RustStream &); |
| 6600 | static void write(RustStream &, const TonConnectRpcErrorCode &); |
| 6601 | static uint64_t allocation_size(const TonConnectRpcErrorCode &); |
| 6602 | }; |
| 6603 |
| 6604 | struct FfiConverterTonConnectSessionError { |
| 6605 | static std::shared_ptr<TonConnectSessionError> lift(RustBuffer buf); |
| 6606 | static RustBuffer lower(const TonConnectSessionError &); |
| 6607 | static std::shared_ptr<TonConnectSessionError> read(RustStream &stream); |
| 6608 | static void write(RustStream &stream, const TonConnectSessionError &); |
| 6609 | static uint64_t allocation_size(const TonConnectSessionError &); |
| 6610 | }; |
| 6611 | struct FfiConverterTonConnectSessionPhase { |
| 6612 | static TonConnectSessionPhase lift(RustBuffer); |
| 6613 | static RustBuffer lower(const TonConnectSessionPhase &); |
| 6614 | static TonConnectSessionPhase read(RustStream &); |
| 6615 | static void write(RustStream &, const TonConnectSessionPhase &); |
| 6616 | static uint64_t allocation_size(const TonConnectSessionPhase &); |
| 6617 | }; |
| 6618 | struct FfiConverterTonConnectSignDataPayload { |
| 6619 | static TonConnectSignDataPayload lift(RustBuffer); |
| 6620 | static RustBuffer lower(const TonConnectSignDataPayload &); |
| 6621 | static TonConnectSignDataPayload read(RustStream &); |
| 6622 | static void write(RustStream &, const TonConnectSignDataPayload &); |
| 6623 | static uint64_t allocation_size(const TonConnectSignDataPayload &); |
| 6624 | }; |
| 6625 | struct FfiConverterTonTransferAsset { |
| 6626 | static TonTransferAsset lift(RustBuffer); |
| 6627 | static RustBuffer lower(const TonTransferAsset &); |
| 6628 | static TonTransferAsset read(RustStream &); |
| 6629 | static void write(RustStream &, const TonTransferAsset &); |
| 6630 | static uint64_t allocation_size(const TonTransferAsset &); |
| 6631 | }; |
| 6632 |
| 6633 | struct FfiConverterTonTransferLinkError { |
| 6634 | static std::shared_ptr<TonTransferLinkError> lift(RustBuffer buf); |
| 6635 | static RustBuffer lower(const TonTransferLinkError &); |
| 6636 | static std::shared_ptr<TonTransferLinkError> read(RustStream &stream); |
| 6637 | static void write(RustStream &stream, const TonTransferLinkError &); |
| 6638 | static uint64_t allocation_size(const TonTransferLinkError &); |
| 6639 | }; |
| 6640 | struct FfiConverterTonTransferPayload { |
| 6641 | static TonTransferPayload lift(RustBuffer); |
| 6642 | static RustBuffer lower(const TonTransferPayload &); |
| 6643 | static TonTransferPayload read(RustStream &); |
| 6644 | static void write(RustStream &, const TonTransferPayload &); |
| 6645 | static uint64_t allocation_size(const TonTransferPayload &); |
| 6646 | }; |
| 6647 |
| 6648 | struct FfiConverterWalletClientError { |
| 6649 | static std::shared_ptr<WalletClientError> lift(RustBuffer buf); |
| 6650 | static RustBuffer lower(const WalletClientError &); |
| 6651 | static std::shared_ptr<WalletClientError> read(RustStream &stream); |
| 6652 | static void write(RustStream &stream, const WalletClientError &); |
| 6653 | static uint64_t allocation_size(const WalletClientError &); |
| 6654 | }; |
| 6655 |
| 6656 | struct FfiConverterWalletLifecycleError { |
| 6657 | static std::shared_ptr<WalletLifecycleError> lift(RustBuffer buf); |
| 6658 | static RustBuffer lower(const WalletLifecycleError &); |
| 6659 | static std::shared_ptr<WalletLifecycleError> read(RustStream &stream); |
| 6660 | static void write(RustStream &stream, const WalletLifecycleError &); |
| 6661 | static uint64_t allocation_size(const WalletLifecycleError &); |
| 6662 | }; |
| 6663 | struct FfiConverterWalletOperationOutcome { |
| 6664 | static WalletOperationOutcome lift(RustBuffer); |
| 6665 | static RustBuffer lower(const WalletOperationOutcome &); |
| 6666 | static WalletOperationOutcome read(RustStream &); |
| 6667 | static void write(RustStream &, const WalletOperationOutcome &); |
| 6668 | static uint64_t allocation_size(const WalletOperationOutcome &); |
| 6669 | }; |
| 6670 | struct FfiConverterOptionalUInt16 { |
| 6671 | static std::optional<uint16_t> lift(RustBuffer buf); |
| 6672 | static RustBuffer lower(const std::optional<uint16_t>& val); |
| 6673 | static std::optional<uint16_t> read(RustStream &stream); |
| 6674 | static void write(RustStream &stream, const std::optional<uint16_t>& value); |
| 6675 | static uint64_t allocation_size(const std::optional<uint16_t> &val); |
| 6676 | }; |
| 6677 | struct FfiConverterOptionalInt32 { |
| 6678 | static std::optional<int32_t> lift(RustBuffer buf); |
| 6679 | static RustBuffer lower(const std::optional<int32_t>& val); |
| 6680 | static std::optional<int32_t> read(RustStream &stream); |
| 6681 | static void write(RustStream &stream, const std::optional<int32_t>& value); |
| 6682 | static uint64_t allocation_size(const std::optional<int32_t> &val); |
| 6683 | }; |
| 6684 | struct FfiConverterOptionalUInt64 { |
| 6685 | static std::optional<uint64_t> lift(RustBuffer buf); |
| 6686 | static RustBuffer lower(const std::optional<uint64_t>& val); |
| 6687 | static std::optional<uint64_t> read(RustStream &stream); |
| 6688 | static void write(RustStream &stream, const std::optional<uint64_t>& value); |
| 6689 | static uint64_t allocation_size(const std::optional<uint64_t> &val); |
| 6690 | }; |
| 6691 | struct FfiConverterOptionalInt64 { |
| 6692 | static std::optional<int64_t> lift(RustBuffer buf); |
| 6693 | static RustBuffer lower(const std::optional<int64_t>& val); |
| 6694 | static std::optional<int64_t> read(RustStream &stream); |
| 6695 | static void write(RustStream &stream, const std::optional<int64_t>& value); |
| 6696 | static uint64_t allocation_size(const std::optional<int64_t> &val); |
| 6697 | }; |
| 6698 | struct FfiConverterOptionalBool { |
| 6699 | static std::optional<bool> lift(RustBuffer buf); |
| 6700 | static RustBuffer lower(const std::optional<bool>& val); |
| 6701 | static std::optional<bool> read(RustStream &stream); |
| 6702 | static void write(RustStream &stream, const std::optional<bool>& value); |
| 6703 | static uint64_t allocation_size(const std::optional<bool> &val); |
| 6704 | }; |
| 6705 | struct FfiConverterOptionalString { |
| 6706 | static std::optional<std::string> lift(RustBuffer buf); |
| 6707 | static RustBuffer lower(const std::optional<std::string>& val); |
| 6708 | static std::optional<std::string> read(RustStream &stream); |
| 6709 | static void write(RustStream &stream, const std::optional<std::string>& value); |
| 6710 | static uint64_t allocation_size(const std::optional<std::string> &val); |
| 6711 | }; |
| 6712 | struct FfiConverterOptionalBytes { |
| 6713 | static std::optional<std::vector<uint8_t>> lift(RustBuffer buf); |
| 6714 | static RustBuffer lower(const std::optional<std::vector<uint8_t>>& val); |
| 6715 | static std::optional<std::vector<uint8_t>> read(RustStream &stream); |
| 6716 | static void write(RustStream &stream, const std::optional<std::vector<uint8_t>>& value); |
| 6717 | static uint64_t allocation_size(const std::optional<std::vector<uint8_t>> &val); |
| 6718 | }; |
| 6719 | struct FfiConverterOptionalTypeAccountSnapshot { |
| 6720 | static std::optional<AccountSnapshot> lift(RustBuffer buf); |
| 6721 | static RustBuffer lower(const std::optional<AccountSnapshot>& val); |
| 6722 | static std::optional<AccountSnapshot> read(RustStream &stream); |
| 6723 | static void write(RustStream &stream, const std::optional<AccountSnapshot>& value); |
| 6724 | static uint64_t allocation_size(const std::optional<AccountSnapshot> &val); |
| 6725 | }; |
| 6726 | struct FfiConverterOptionalTypeActivityCursor { |
| 6727 | static std::optional<ActivityCursor> lift(RustBuffer buf); |
| 6728 | static RustBuffer lower(const std::optional<ActivityCursor>& val); |
| 6729 | static std::optional<ActivityCursor> read(RustStream &stream); |
| 6730 | static void write(RustStream &stream, const std::optional<ActivityCursor>& value); |
| 6731 | static uint64_t allocation_size(const std::optional<ActivityCursor> &val); |
| 6732 | }; |
| 6733 | struct FfiConverterOptionalTypeDomainError { |
| 6734 | static std::optional<DomainError> lift(RustBuffer buf); |
| 6735 | static RustBuffer lower(const std::optional<DomainError>& val); |
| 6736 | static std::optional<DomainError> read(RustStream &stream); |
| 6737 | static void write(RustStream &stream, const std::optional<DomainError>& value); |
| 6738 | static uint64_t allocation_size(const std::optional<DomainError> &val); |
| 6739 | }; |
| 6740 | struct FfiConverterOptionalTypeJournalRecord { |
| 6741 | static std::optional<JournalRecord> lift(RustBuffer buf); |
| 6742 | static RustBuffer lower(const std::optional<JournalRecord>& val); |
| 6743 | static std::optional<JournalRecord> read(RustStream &stream); |
| 6744 | static void write(RustStream &stream, const std::optional<JournalRecord>& value); |
| 6745 | static uint64_t allocation_size(const std::optional<JournalRecord> &val); |
| 6746 | }; |
| 6747 | struct FfiConverterOptionalTypeNftCollectionDescriptor { |
| 6748 | static std::optional<NftCollectionDescriptor> lift(RustBuffer buf); |
| 6749 | static RustBuffer lower(const std::optional<NftCollectionDescriptor>& val); |
| 6750 | static std::optional<NftCollectionDescriptor> read(RustStream &stream); |
| 6751 | static void write(RustStream &stream, const std::optional<NftCollectionDescriptor>& value); |
| 6752 | static uint64_t allocation_size(const std::optional<NftCollectionDescriptor> &val); |
| 6753 | }; |
| 6754 | struct FfiConverterOptionalTypeProtectedSecretRef { |
| 6755 | static std::optional<ProtectedSecretRef> lift(RustBuffer buf); |
| 6756 | static RustBuffer lower(const std::optional<ProtectedSecretRef>& val); |
| 6757 | static std::optional<ProtectedSecretRef> read(RustStream &stream); |
| 6758 | static void write(RustStream &stream, const std::optional<ProtectedSecretRef>& value); |
| 6759 | static uint64_t allocation_size(const std::optional<ProtectedSecretRef> &val); |
| 6760 | }; |
| 6761 | struct FfiConverterOptionalTypeResolutionInfo { |
| 6762 | static std::optional<ResolutionInfo> lift(RustBuffer buf); |
| 6763 | static RustBuffer lower(const std::optional<ResolutionInfo>& val); |
| 6764 | static std::optional<ResolutionInfo> read(RustStream &stream); |
| 6765 | static void write(RustStream &stream, const std::optional<ResolutionInfo>& value); |
| 6766 | static uint64_t allocation_size(const std::optional<ResolutionInfo> &val); |
| 6767 | }; |
| 6768 | struct FfiConverterOptionalTypeTonConnectConnectPrompt { |
| 6769 | static std::optional<TonConnectConnectPrompt> lift(RustBuffer buf); |
| 6770 | static RustBuffer lower(const std::optional<TonConnectConnectPrompt>& val); |
| 6771 | static std::optional<TonConnectConnectPrompt> read(RustStream &stream); |
| 6772 | static void write(RustStream &stream, const std::optional<TonConnectConnectPrompt>& value); |
| 6773 | static uint64_t allocation_size(const std::optional<TonConnectConnectPrompt> &val); |
| 6774 | }; |
| 6775 | struct FfiConverterOptionalTypeTonConnectPreparedPost { |
| 6776 | static std::optional<TonConnectPreparedPost> lift(RustBuffer buf); |
| 6777 | static RustBuffer lower(const std::optional<TonConnectPreparedPost>& val); |
| 6778 | static std::optional<TonConnectPreparedPost> read(RustStream &stream); |
| 6779 | static void write(RustStream &stream, const std::optional<TonConnectPreparedPost>& value); |
| 6780 | static uint64_t allocation_size(const std::optional<TonConnectPreparedPost> &val); |
| 6781 | }; |
| 6782 | struct FfiConverterOptionalTypeTonConnectProofReply { |
| 6783 | static std::optional<TonConnectProofReply> lift(RustBuffer buf); |
| 6784 | static RustBuffer lower(const std::optional<TonConnectProofReply>& val); |
| 6785 | static std::optional<TonConnectProofReply> read(RustStream &stream); |
| 6786 | static void write(RustStream &stream, const std::optional<TonConnectProofReply>& value); |
| 6787 | static uint64_t allocation_size(const std::optional<TonConnectProofReply> &val); |
| 6788 | }; |
| 6789 | struct FfiConverterOptionalHttpHostErrorKind { |
| 6790 | static std::optional<HttpHostErrorKind> lift(RustBuffer buf); |
| 6791 | static RustBuffer lower(const std::optional<HttpHostErrorKind>& val); |
| 6792 | static std::optional<HttpHostErrorKind> read(RustStream &stream); |
| 6793 | static void write(RustStream &stream, const std::optional<HttpHostErrorKind>& value); |
| 6794 | static uint64_t allocation_size(const std::optional<HttpHostErrorKind> &val); |
| 6795 | }; |
| 6796 | struct FfiConverterOptionalPendingReason { |
| 6797 | static std::optional<PendingReason> lift(RustBuffer buf); |
| 6798 | static RustBuffer lower(const std::optional<PendingReason>& val); |
| 6799 | static std::optional<PendingReason> read(RustStream &stream); |
| 6800 | static void write(RustStream &stream, const std::optional<PendingReason>& value); |
| 6801 | static uint64_t allocation_size(const std::optional<PendingReason> &val); |
| 6802 | }; |
| 6803 | struct FfiConverterOptionalTypeBase64Hash { |
| 6804 | static std::optional<Base64Hash> lift(RustBuffer buf); |
| 6805 | static RustBuffer lower(const std::optional<Base64Hash>& val); |
| 6806 | static std::optional<Base64Hash> read(RustStream &stream); |
| 6807 | static void write(RustStream &stream, const std::optional<Base64Hash>& value); |
| 6808 | static uint64_t allocation_size(const std::optional<Base64Hash> &val); |
| 6809 | }; |
| 6810 | struct FfiConverterOptionalTypeBoc { |
| 6811 | static std::optional<Boc> lift(RustBuffer buf); |
| 6812 | static RustBuffer lower(const std::optional<Boc>& val); |
| 6813 | static std::optional<Boc> read(RustStream &stream); |
| 6814 | static void write(RustStream &stream, const std::optional<Boc>& value); |
| 6815 | static uint64_t allocation_size(const std::optional<Boc> &val); |
| 6816 | }; |
| 6817 | struct FfiConverterOptionalTypeNonEmptyString { |
| 6818 | static std::optional<NonEmptyString> lift(RustBuffer buf); |
| 6819 | static RustBuffer lower(const std::optional<NonEmptyString>& val); |
| 6820 | static std::optional<NonEmptyString> read(RustStream &stream); |
| 6821 | static void write(RustStream &stream, const std::optional<NonEmptyString>& value); |
| 6822 | static uint64_t allocation_size(const std::optional<NonEmptyString> &val); |
| 6823 | }; |
| 6824 | struct FfiConverterOptionalTypeTonAddressString { |
| 6825 | static std::optional<TonAddressString> lift(RustBuffer buf); |
| 6826 | static RustBuffer lower(const std::optional<TonAddressString>& val); |
| 6827 | static std::optional<TonAddressString> read(RustStream &stream); |
| 6828 | static void write(RustStream &stream, const std::optional<TonAddressString>& value); |
| 6829 | static uint64_t allocation_size(const std::optional<TonAddressString> &val); |
| 6830 | }; |
| 6831 | struct FfiConverterOptionalTypeUnsignedDecimalString { |
| 6832 | static std::optional<UnsignedDecimalString> lift(RustBuffer buf); |
| 6833 | static RustBuffer lower(const std::optional<UnsignedDecimalString>& val); |
| 6834 | static std::optional<UnsignedDecimalString> read(RustStream &stream); |
| 6835 | static void write(RustStream &stream, const std::optional<UnsignedDecimalString>& value); |
| 6836 | static uint64_t allocation_size(const std::optional<UnsignedDecimalString> &val); |
| 6837 | }; |
| 6838 |
| 6839 | struct FfiConverterSequenceString { |
| 6840 | static std::vector<std::string> lift(RustBuffer); |
| 6841 | static RustBuffer lower(const std::vector<std::string> &); |
| 6842 | static std::vector<std::string> read(RustStream &); |
| 6843 | static void write(RustStream &, const std::vector<std::string> &); |
| 6844 | static uint64_t allocation_size(const std::vector<std::string> &); |
| 6845 | }; |
| 6846 |
| 6847 | struct FfiConverterSequenceTypeActivityItem { |
| 6848 | static std::vector<ActivityItem> lift(RustBuffer); |
| 6849 | static RustBuffer lower(const std::vector<ActivityItem> &); |
| 6850 | static std::vector<ActivityItem> read(RustStream &); |
| 6851 | static void write(RustStream &, const std::vector<ActivityItem> &); |
| 6852 | static uint64_t allocation_size(const std::vector<ActivityItem> &); |
| 6853 | }; |
| 6854 |
| 6855 | struct FfiConverterSequenceTypeHttpHeader { |
| 6856 | static std::vector<HttpHeader> lift(RustBuffer); |
| 6857 | static RustBuffer lower(const std::vector<HttpHeader> &); |
| 6858 | static std::vector<HttpHeader> read(RustStream &); |
| 6859 | static void write(RustStream &, const std::vector<HttpHeader> &); |
| 6860 | static uint64_t allocation_size(const std::vector<HttpHeader> &); |
| 6861 | }; |
| 6862 |
| 6863 | struct FfiConverterSequenceTypeNftItem { |
| 6864 | static std::vector<NftItem> lift(RustBuffer); |
| 6865 | static RustBuffer lower(const std::vector<NftItem> &); |
| 6866 | static std::vector<NftItem> read(RustStream &); |
| 6867 | static void write(RustStream &, const std::vector<NftItem> &); |
| 6868 | static uint64_t allocation_size(const std::vector<NftItem> &); |
| 6869 | }; |
| 6870 |
| 6871 | struct FfiConverterSequenceTypeSendEmulationAction { |
| 6872 | static std::vector<SendEmulationAction> lift(RustBuffer); |
| 6873 | static RustBuffer lower(const std::vector<SendEmulationAction> &); |
| 6874 | static std::vector<SendEmulationAction> read(RustStream &); |
| 6875 | static void write(RustStream &, const std::vector<SendEmulationAction> &); |
| 6876 | static uint64_t allocation_size(const std::vector<SendEmulationAction> &); |
| 6877 | }; |
| 6878 |
| 6879 | struct FfiConverterSequenceTypeSendEmulationTransaction { |
| 6880 | static std::vector<SendEmulationTransaction> lift(RustBuffer); |
| 6881 | static RustBuffer lower(const std::vector<SendEmulationTransaction> &); |
| 6882 | static std::vector<SendEmulationTransaction> read(RustStream &); |
| 6883 | static void write(RustStream &, const std::vector<SendEmulationTransaction> &); |
| 6884 | static uint64_t allocation_size(const std::vector<SendEmulationTransaction> &); |
| 6885 | }; |
| 6886 |
| 6887 | struct FfiConverterSequenceTypeSendMessage { |
| 6888 | static std::vector<SendMessage> lift(RustBuffer); |
| 6889 | static RustBuffer lower(const std::vector<SendMessage> &); |
| 6890 | static std::vector<SendMessage> read(RustStream &); |
| 6891 | static void write(RustStream &, const std::vector<SendMessage> &); |
| 6892 | static uint64_t allocation_size(const std::vector<SendMessage> &); |
| 6893 | }; |
| 6894 |
| 6895 | struct FfiConverterSequenceMnemonicScheme { |
| 6896 | static std::vector<MnemonicScheme> lift(RustBuffer); |
| 6897 | static RustBuffer lower(const std::vector<MnemonicScheme> &); |
| 6898 | static std::vector<MnemonicScheme> read(RustStream &); |
| 6899 | static void write(RustStream &, const std::vector<MnemonicScheme> &); |
| 6900 | static uint64_t allocation_size(const std::vector<MnemonicScheme> &); |
| 6901 | }; |
| 6902 |
| 6903 | struct FfiConverterSequenceTonConnectIncomingRequest { |
| 6904 | static std::vector<TonConnectIncomingRequest> lift(RustBuffer); |
| 6905 | static RustBuffer lower(const std::vector<TonConnectIncomingRequest> &); |
| 6906 | static std::vector<TonConnectIncomingRequest> read(RustStream &); |
| 6907 | static void write(RustStream &, const std::vector<TonConnectIncomingRequest> &); |
| 6908 | static uint64_t allocation_size(const std::vector<TonConnectIncomingRequest> &); |
| 6909 | }; |
| 6910 |
| 6911 | struct FfiConverterSequenceTypeBase64Hash { |
| 6912 | static std::vector<Base64Hash> lift(RustBuffer); |
| 6913 | static RustBuffer lower(const std::vector<Base64Hash> &); |
| 6914 | static std::vector<Base64Hash> read(RustStream &); |
| 6915 | static void write(RustStream &, const std::vector<Base64Hash> &); |
| 6916 | static uint64_t allocation_size(const std::vector<Base64Hash> &); |
| 6917 | }; |
| 6918 |
| 6919 | struct FfiConverterSequenceTypeTonAddressString { |
| 6920 | static std::vector<TonAddressString> lift(RustBuffer); |
| 6921 | static RustBuffer lower(const std::vector<TonAddressString> &); |
| 6922 | static std::vector<TonAddressString> read(RustStream &); |
| 6923 | static void write(RustStream &, const std::vector<TonAddressString> &); |
| 6924 | static uint64_t allocation_size(const std::vector<TonAddressString> &); |
| 6925 | }; |
| 6926 |
| 6927 | struct FfiConverterMapStringString { |
| 6928 | static std::unordered_map<std::string, std::string> lift(RustBuffer); |
| 6929 | static RustBuffer lower(const std::unordered_map<std::string, std::string> &); |
| 6930 | static std::unordered_map<std::string, std::string> read(RustStream &); |
| 6931 | static void write(RustStream &, const std::unordered_map<std::string, std::string> &); |
| 6932 | static uint64_t allocation_size(const std::unordered_map<std::string, std::string> &); |
| 6933 | }; |
| 6934 | typedef struct FfiConverterString FfiConverterTypeBase64Hash; |
| 6935 | typedef struct FfiConverterString FfiConverterTypeBoc; |
| 6936 | typedef struct FfiConverterString FfiConverterTypeNonEmptyString; |
| 6937 | typedef struct FfiConverterString FfiConverterTypeTonAddressString; |
| 6938 | typedef struct FfiConverterString FfiConverterTypeUnsignedDecimalString; |
| 6939 | } // namespace uniffi |
| 6940 |
| 6941 | /** |
| 6942 | * Parses the strict baseline `ton://transfer/` format without reading chain or clock state. |
| 6943 | * |
| 6944 | * Query names are case-sensitive. Percent escapes are decoded exactly once, |
| 6945 | * and literal `+` characters remain plus signs instead of becoming spaces. |
| 6946 | */ |
| 6947 | ParsedTonTransferLink parse_ton_transfer_link(const std::string &value); |
| 6948 | /** |
| 6949 | * Parses and validates a dApp manifest with the Rust protocol implementation. |
| 6950 | */ |
| 6951 | TonConnectManifest parse_ton_connect_manifest(const std::string &json); |
| 6952 | /** |
| 6953 | * Creates a fresh encrypted session from a full TON Connect link. |
| 6954 | */ |
| 6955 | std::shared_ptr<TonConnectSession> ton_connect_session_from_link(const std::string &link, const TonConnectSessionConfig &config); |
| 6956 | /** |
| 6957 | * Restores a secret-bearing session without generating new crypto keys. |
| 6958 | */ |
| 6959 | std::shared_ptr<TonConnectSession> ton_connect_session_restore(const std::string &persisted, const TonConnectSessionConfig &config); |
| 6960 | /** |
| 6961 | * Converts a TON address to the requested canonical representation. |
| 6962 | * |
| 6963 | * Raw output is lowercase `workchain:64-hex`. User-friendly output is |
| 6964 | * unpadded URL-safe TEP-2 Base64. Requested friendly flags replace any flags |
| 6965 | * carried by the input. |
| 6966 | */ |
| 6967 | std::string convert_ton_address(const std::string &value, TonAddressFormat format); |
| 6968 | /** |
| 6969 | * Reports whether `value` is a valid raw or user-friendly TON address. |
| 6970 | */ |
| 6971 | bool is_valid_ton_address(const std::string &value); |
| 6972 | /** |
| 6973 | * Parses a raw or user-friendly TON address without changing its account identity. |
| 6974 | * |
| 6975 | * Friendly input accepts the standard and URL-safe Base64 alphabets and returns |
| 6976 | * the flags protected by its checksum in [`TonAddressFormat::UserFriendly`]. |
| 6977 | */ |
| 6978 | TonAddressInfo parse_ton_address(const std::string &value); |
| 6979 | /** |
| 6980 | * Returns the English word list accepted by recovery-phrase validation. |
| 6981 | * |
| 6982 | * This is the canonical BIP-39 English list, so the source order is also the |
| 6983 | * BIP-39 index order. Both halves of a rotation mnemonic draw from it. |
| 6984 | */ |
| 6985 | std::vector<std::string> mnemonic_wordlist(); |
| 6986 | /** |
| 6987 | * Reports every scheme under which the entered recovery words validate. |
| 6988 | * |
| 6989 | * Pass the words exactly as the user recorded them, one word per element - |
| 6990 | * the same value an `ImportWalletRequest` would carry. Each word is trimmed |
| 6991 | * and lowercased before validation, exactly like wallet import. |
| 6992 | * |
| 6993 | * The result lists all matching schemes in the fixed order |
| 6994 | * [`Rotation`](MnemonicScheme::Rotation), [`Ton`](MnemonicScheme::Ton), |
| 6995 | * [`Bip39`](MnemonicScheme::Bip39); the checks are independent, so one |
| 6996 | * phrase can match more than one scheme. An empty result means the words |
| 6997 | * validate under no scheme the engine knows. |
| 6998 | * |
| 6999 | * Wallet import succeeds exactly when the result contains |
| 7000 | * [`MnemonicScheme::Rotation`]. A result without it explains why import |
| 7001 | * reports `InvalidRecoveryPhrase`; the user-facing wording of that |
| 7002 | * explanation belongs to the application. |
| 7003 | * |
| 7004 | * The function derives no key material and logs nothing. Password-protected |
| 7005 | * TON mnemonics are not detectable without the password and report no match. |
| 7006 | */ |
| 7007 | std::vector<MnemonicScheme> detect_mnemonic_schemes(const std::vector<std::string> &words); |
| 7008 | /** |
| 7009 | * Returns the 32-byte anchor public key of a 12- or 24-word Rotation mnemonic. |
| 7010 | * |
| 7011 | * The anchor key is independent of network and does not change on key rotation. |
| 7012 | * Both halves of a 24-word phrase must validate. No storage or network is used. |
| 7013 | */ |
| 7014 | std::vector<uint8_t> rotation_mnemonic_public_key(const std::string &phrase); |
| 7015 | } // namespace wallet_engine |