Test adapter support tokens - #792
Conversation
… vv/token-registry-bindings-and-deployment
…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>
|
|
||
| // TODO: add TokenAmounts support for TON token transfers | ||
| return router.CCIPSend{ | ||
| tokenAmounts := make(common.SnakedCell[router.TokenAmount], 0, len(components.TokenAmounts)) |
There was a problem hiding this comment.
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:
- AuthorizeRouterToWithdraw sends the tokens to the escrow account
- 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
There was a problem hiding this comment.
let's link this comment in the follow up ticket
… vv/test-adapter-enable-token-transfer
… vv/test-adapter-enable-token-transfer
patricios-space
left a comment
There was a problem hiding this comment.
Great job! Only remoteTokenAddress: cca.codec.encode is a critical change, the rests are nit picks
| remoteChainSelector: DestChainSelector, | ||
| remotePoolAddresses: [EVM_ADDRESS], | ||
| remoteTokenAddress: EVM_ADDRESS, | ||
| remoteTokenAddress: cca.codec.encode(DEST_TOKEN_ADDRESS).endCell().beginParse(), |
There was a problem hiding this comment.
This is wrong. We expect just the slice here. The codec prefixes the slice with the buffer length, which is already done by the wrapper.
| remoteTokenAddress: cca.codec.encode(DEST_TOKEN_ADDRESS).endCell().beginParse(), | |
| remoteTokenAddress: FromBuffer(DEST_TOKEN_ADDRESS), |
| var feeAdmin *address.Address | ||
| if input.FeeAggregator != "" { | ||
| feeAdmin, err = address.ParseAddr(input.FeeAggregator) | ||
| if err != nil { | ||
| return sequences.OnChainOutput{}, fmt.Errorf("failed to parse fee aggregator address %q: %w", input.FeeAggregator, err) | ||
| } | ||
| } |
There was a problem hiding this comment.
This parsing logic should maybe go into a function?
| var feeAdmin *address.Address | |
| if input.FeeAggregator != "" { | |
| feeAdmin, err = address.ParseAddr(input.FeeAggregator) | |
| if err != nil { | |
| return sequences.OnChainOutput{}, fmt.Errorf("failed to parse fee aggregator address %q: %w", input.FeeAggregator, err) | |
| } | |
| } | |
| feeAdmin, err := parseAddr(input.FeeAggregator) | |
| if err != nil { | |
| return sequences.OnChainOutput{}, fmt.Errorf("failed to parse fee aggregator address: %w", err) | |
| } |
| } | ||
|
|
||
| stateCCIP, err := tonstate.LoadCCIPOnChainStateUsingDataStore(input.ExistingDataStore, input.ChainSelector) | ||
| if err != nil { |
There was a problem hiding this comment.
Why is this necessary? stateCCIP is only used inside the else block
There was a problem hiding this comment.
moved to the else block
|
|
||
| // TODO: add TokenAmounts support for TON token transfers | ||
| return router.CCIPSend{ | ||
| tokenAmounts := make(common.SnakedCell[router.TokenAmount], 0, len(components.TokenAmounts)) |
There was a problem hiding this comment.
let's link this comment in the follow up ticket
| var eAny any | ||
| var err error | ||
| switch msg := m.(type) { | ||
| case router.CCIPSend: |
No description provided.