Skip to content

Test adapter support tokens - #792

Draft
vicentevieytes wants to merge 65 commits into
mainfrom
vv/test-adapter-enable-token-transfer
Draft

Test adapter support tokens#792
vicentevieytes wants to merge 65 commits into
mainfrom
vv/test-adapter-enable-token-transfer

Conversation

@vicentevieytes

Copy link
Copy Markdown
Collaborator

No description provided.

vicentevieytes and others added 30 commits June 18, 2026 19:32
…ddress

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
fix typo

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@vicentevieytes
vicentevieytes changed the base branch from main to vv/token-adapter July 13, 2026 15:45
// TODO: implement when TON token transfer support is added
return errors.ErrUnsupported
// Real jetton approval (e.g. minting an allowance / notifying the pool) is not
// yet implemented; no tokens actually move so there is nothing to approve yet.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part should probably be sending the tokens to the shared wallet between router and user

@vicentevieytes vicentevieytes changed the title tokenRegistry bindings and deployment Test adapter support tokens Jul 14, 2026
Base automatically changed from vv/token-adapter to main July 16, 2026 17:36
// Source token amounts plus the destination token address, grouped into a single
// ref to stay within the 4-ref-per-cell limit (matches TVM2AnyTokenTransfer in
// contracts/ccip/onramp/types.tolk).
TokenTransfer TVM2AnyTokenTransfer `tlb:"^"`

@vicentevieytes vicentevieytes Jul 22, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed from TokenAmounts to TVM2AnyTokenTransfer to have the DestTokenAddress in the event, which is needed by ConvertCCIPMessageSent (pkg/ccip/chainaccessor/event.go).

Alternatively, we could keep this struct unchanged and use TokenAmounts, and add a separate step where the off-chain queries the destination CrossChainAddress from the corresponding TokenPool.

I think EVM and Solana take this information straight from the event though so I went with this approach.

// exactly the same message it will send to the productive TokenPool.
type MockTokenPool_InMessage =
| MockTokenPool_LockOrBurn
| TokenPool_ApplyChainUpdates;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should get rid of this MockTokenPool and instead use one of the productive pools or a mock pool that uses the real tokenPool lib


// Native TON attached to the transfer notification, used to pay fees + execution costs.
const FORWARD_TON_AMOUNT = toNano('1')
const FORWARD_TON_AMOUNT = toNano('10')

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a big overhead here to not get InsufficientFee or -14 errors. When the message flow is completely defined we can benchmark and estimate from scratch

if bal, balErr := ton_tvm.CallGetterLatest(b.GetContext(), chain.Client, preMintWalletAddr, jettonwallet.GetWalletData); balErr == nil {
preMintBalance = bal
}
b.Logger.Infow("[DEBUG] pre-mint: recipient jetton balance BEFORE mint",

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd remove these debug logs but keep the assertions

if balanceErr != nil {
return sequences.OnChainOutput{}, fmt.Errorf("failed to read jetton balance for pre-mint recipient %s: %w", recipient.String(), balanceErr)
}
b.Logger.Infow("[DEBUG] pre-mint: recipient jetton balance AFTER mint",

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same, remove the debug log


// TODO: add TokenAmounts support for TON token transfers
return router.CCIPSend{
tokenAmounts := make(common.SnakedCell[router.TokenAmount], 0, len(components.TokenAmounts))

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change makes the BuildMessage function return two different types depending on wether this is arbitrary messaging (returns CCIPSend) or if it's a TokenTransfer (returns a TokenTransferMessage struct with the CCIPSend payload as forwardNotification)

Then SendMessage changes it's behavior depending on the type that's passed to it, and it either sends the message to the router or to it's wallet.

This would be simpler with the escrow account entrypoint:

  1. AuthorizeRouterToWithdraw sends the tokens to the escrow account
  2. SendMessage sends CCIPSend to the router, the router will later withdraw the messages when it needs them.

A quick follow up to this should be to change to this model IMO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant