-
Notifications
You must be signed in to change notification settings - Fork 18
TON-858: tonapi emulation #373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
heyllog
wants to merge
19
commits into
main
Choose a base branch
from
feat/TON-858-tonapi-emulation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 14 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
547fafb
feat(emulation): start creating models for emulation
heyllog 7f09223
feat(emulation): move types to clients
heyllog a6b9d84
feat(emulation): move ApiClient to api/interfaces
heyllog 4cdd5c4
feat(emulation): fetchEmulation returns new model
heyllog d6d3a0e
feat(emulation): delete dead code
heyllog 7e072d0
feat(emulation): fetchEmulation added in tonapi
heyllog 41b4b3d
feat(emulation): add nft actions mapping
heyllog d04fd19
Merge branch 'main' into feat/TON-858-tonapi-emulation
heyllog c6ee476
feat(emulation): more adjustments
heyllog e3651b5
feat(emulation): remove moneyflow from response
heyllog a64a12f
feat(emulation): remove unused old code
heyllog 90280c2
feat(emulation): rework models
heyllog 90845d2
feat(emulation): make opcode hex
heyllog d144286
feat(appkit): add status mapping
heyllog b966c6c
feat(emulation): replace null with undefined
heyllog 260a70d
feat(emulation): update exports
heyllog 9eb4764
feat(emulation): replace record with object
heyllog 2d3bb09
feat(emulation): map bits and cells to number
heyllog 2b60c6c
feat(emulation): map bits and cells to number in EmulationActionMessa…
heyllog File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
packages/walletkit/src/api/models/emulation/EmulationAction.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
|
|
||
| import type { UserFriendlyAddress, LogicalTime, Hex } from '../core/Primitives'; | ||
|
|
||
| /** | ||
| * High-level action extracted from an emulated transaction trace. | ||
| */ | ||
| export interface EmulationAction { | ||
| /** | ||
| * Trace identifier this action belongs to | ||
| */ | ||
| traceId: string | null; | ||
|
|
||
| /** | ||
| * Hex-encoded unique identifier of the action | ||
| */ | ||
| actionId: Hex; | ||
|
|
||
| /** | ||
| * Logical time when the action started | ||
| */ | ||
| startLt: LogicalTime; | ||
|
|
||
| /** | ||
| * Logical time when the action ended | ||
| */ | ||
| endLt: LogicalTime; | ||
|
|
||
| /** | ||
| * Unix timestamp when the action started | ||
| * @format timestamp | ||
| */ | ||
| startUtime: number; | ||
|
|
||
| /** | ||
| * Unix timestamp when the action ended | ||
| * @format timestamp | ||
| */ | ||
| endUtime: number; | ||
|
|
||
| /** | ||
| * Logical time when the trace ended | ||
| */ | ||
| traceEndLt: LogicalTime; | ||
|
|
||
| /** | ||
| * Unix timestamp when the trace ended | ||
| * @format timestamp | ||
| */ | ||
| traceEndUtime: number; | ||
|
|
||
| /** | ||
| * Masterchain block sequence number when the trace ended | ||
| * @format int | ||
| */ | ||
| traceMcSeqnoEnd: number; | ||
|
|
||
| /** | ||
| * Hex-encoded hashes of transactions involved in this action | ||
| */ | ||
| transactions: Hex[]; | ||
|
|
||
| /** | ||
| * Whether the action completed successfully | ||
| */ | ||
| isSuccess: boolean; | ||
|
|
||
| /** | ||
| * Action type identifier (e.g. "jetton_transfer", "ton_transfer", "jetton_swap") | ||
| */ | ||
| type: string; | ||
|
|
||
| /** | ||
| * Hex-encoded external message hash of the root trace | ||
| */ | ||
| traceExternalHash: Hex; | ||
|
|
||
| /** | ||
| * Addresses of accounts involved in this action | ||
| */ | ||
| accounts: UserFriendlyAddress[]; | ||
|
|
||
| /** | ||
| * Action-specific detail fields keyed by name | ||
| */ | ||
| details: Record<string, unknown>; | ||
| } | ||
29 changes: 29 additions & 0 deletions
29
packages/walletkit/src/api/models/emulation/EmulationAddressBookEntry.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
|
|
||
| import type { UserFriendlyAddress } from '../core/Primitives'; | ||
|
|
||
| /** | ||
| * Address book entry providing human-readable metadata for an on-chain address. | ||
| */ | ||
| export interface EmulationAddressBookEntry { | ||
| /** | ||
| * DNS domain name associated with the address, if any | ||
| */ | ||
| domain?: string; | ||
|
|
||
| /** | ||
| * User-friendly representation of the address | ||
| */ | ||
| userFriendly: UserFriendlyAddress; | ||
|
|
||
| /** | ||
| * List of known interfaces implemented by the contract | ||
| */ | ||
| interfaces: string[]; | ||
| } |
122 changes: 122 additions & 0 deletions
122
packages/walletkit/src/api/models/emulation/EmulationMessage.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
|
|
||
| import type { UserFriendlyAddress, LogicalTime, Hex, Base64String } from '../core/Primitives'; | ||
| import type { TokenAmount } from '../core/TokenAmount'; | ||
| import type { ExtraCurrencies } from '../core/ExtraCurrencies'; | ||
|
|
||
| /** | ||
| * Message sent or received within an emulated transaction trace. | ||
| */ | ||
| export interface EmulationMessage { | ||
| /** | ||
| * Hex-encoded hash of the message | ||
| */ | ||
| hash: Hex; | ||
|
|
||
| /** | ||
| * Hex-encoded normalized hash used for deduplication across message variants | ||
| */ | ||
| normalizedHash?: Hex; | ||
|
|
||
| /** | ||
| * Source address of the message, or null for external inbound messages | ||
| */ | ||
| source: UserFriendlyAddress | null; | ||
|
|
||
| /** | ||
| * Destination address of the message | ||
| */ | ||
| destination: UserFriendlyAddress; | ||
|
|
||
| /** | ||
| * Amount of nanotons transferred, or null for external inbound messages | ||
| */ | ||
| value: TokenAmount | null; | ||
|
|
||
| /** | ||
| * Extra currencies transferred with the message | ||
| */ | ||
| valueExtraCurrencies: ExtraCurrencies; | ||
|
|
||
| /** | ||
| * Forwarding fee in nanotons, or null for external inbound messages | ||
| */ | ||
| fwdFee: TokenAmount | null; | ||
|
|
||
| /** | ||
| * IHR (Instant Hypercube Routing) fee in nanotons, or null for external inbound messages | ||
| */ | ||
| ihrFee: TokenAmount | null; | ||
|
|
||
| /** | ||
| * Logical time when the message was created, or null for external inbound messages | ||
| */ | ||
| createdLt: LogicalTime | null; | ||
|
|
||
| /** | ||
| * Unix timestamp when the message was created, or null for external inbound messages | ||
| * @format timestamp | ||
| */ | ||
| createdAt: number | null; | ||
|
|
||
| /** | ||
| * Hex-encoded opcode from the message body, if present | ||
| */ | ||
| opcode: Hex | null; | ||
|
|
||
| /** | ||
| * Whether IHR delivery is disabled, or null for external inbound messages | ||
| */ | ||
| ihrDisabled: boolean | null; | ||
|
|
||
| /** | ||
| * Whether the message requested a bounce on failure, or null for external inbound messages | ||
| */ | ||
| isBounce: boolean | null; | ||
|
|
||
| /** | ||
| * Whether the message was bounced back, or null for external inbound messages | ||
| */ | ||
| isBounced: boolean | null; | ||
|
|
||
| /** | ||
| * Import fee paid for delivering an external inbound message, null for all other message types | ||
| */ | ||
| importFee: TokenAmount | null; | ||
|
|
||
| /** | ||
| * Decoded content of the message body | ||
| */ | ||
| messageContent: EmulationMessageContent; | ||
|
|
||
| /** | ||
| * Initial state (StateInit) attached to the message, if any | ||
| */ | ||
| initState: unknown | null; | ||
| } | ||
|
|
||
| /** | ||
| * Decoded content of an emulation message body. | ||
| */ | ||
| export interface EmulationMessageContent { | ||
| /** | ||
| * Hex-encoded hash of the message content, or null if not available | ||
| */ | ||
| hash: Hex | null; | ||
|
|
||
| /** | ||
| * Message body in BOC base64 format, or null if not available | ||
| */ | ||
| body: Base64String | null; | ||
|
|
||
| /** | ||
| * Structured decoded representation of the message body, if available | ||
| */ | ||
| decoded: unknown | null; | ||
| } |
64 changes: 64 additions & 0 deletions
64
packages/walletkit/src/api/models/emulation/EmulationResponse.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
|
|
||
| import type { Hex, Base64String } from '../core/Primitives'; | ||
| import type { EmulationAction } from './EmulationAction'; | ||
| import type { EmulationAddressBookEntry } from './EmulationAddressBookEntry'; | ||
| import type { EmulationTraceNode } from './EmulationTraceNode'; | ||
| import type { EmulationTransaction } from './EmulationTransaction'; | ||
|
|
||
| /** | ||
| * Unified emulation response model, normalised from either Toncenter or TonAPI sources. | ||
| */ | ||
| export interface EmulationResponse { | ||
| /** | ||
| * Masterchain block sequence number used during emulation | ||
| * @format int | ||
| */ | ||
| mcBlockSeqno: number; | ||
|
|
||
| /** | ||
| * Root node of the transaction execution tree | ||
| */ | ||
| trace: EmulationTraceNode; | ||
|
|
||
| /** | ||
| * Map of transaction hashes to transaction details | ||
| */ | ||
| transactions: Record<string, EmulationTransaction>; | ||
|
heyllog marked this conversation as resolved.
Outdated
|
||
|
|
||
| /** | ||
| * High-level actions extracted from the trace | ||
| */ | ||
| actions: EmulationAction[]; | ||
|
|
||
| /** | ||
| * Random seed used during emulation, hex-encoded | ||
| */ | ||
| randSeed: Hex; | ||
|
|
||
| /** | ||
| * Whether the trace is incomplete due to limits or errors | ||
| */ | ||
| isIncomplete: boolean; | ||
|
|
||
| /** | ||
| * Map of code cell hashes to their BOC base64 representations | ||
| */ | ||
| codeCells: Record<string, Base64String>; | ||
|
heyllog marked this conversation as resolved.
Outdated
|
||
|
|
||
| /** | ||
| * Map of data cell hashes to their BOC base64 representations | ||
| */ | ||
| dataCells: Record<string, Base64String>; | ||
|
heyllog marked this conversation as resolved.
Outdated
|
||
|
|
||
| /** | ||
| * Address book mapping raw addresses to human-readable metadata | ||
| */ | ||
| addressBook: Record<string, EmulationAddressBookEntry>; | ||
|
heyllog marked this conversation as resolved.
Outdated
|
||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.