Created wallet router usage analysis
This commit is contained in:
parent
8f333916c5
commit
e94afb52bf
|
@ -4,7 +4,8 @@
|
|||
|
||||
- Wallet Router
|
||||
- I've analysed the main components of the wallet router, see here:
|
||||
- [wallet/router analysis](./analysis/wallet_router.md)
|
||||
- [wallet/Router file analysis](./analysis/wallet_router.md)
|
||||
- [wallet/Router struct usage](./analysis/wallet_router_usage.md)
|
||||
|
||||
## Schedule
|
||||
- I raised an axe to the crew meetings, swung hard and true. Toppled and prostrate they settled motionless. Tonight we revel in the light of their embers!
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
- Represents a transaction path including details like from/to networks, fees, and estimated costs.
|
||||
- `Router`
|
||||
- Manages routing of transactions using different bridges defined for various transaction types.
|
||||
- [Usage analysis](./wallet_router_usage.md)
|
||||
- **Functions:**
|
||||
- `requireApproval()`
|
||||
- Determines if token approval is required before executing a transaction over a bridge.
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
# Initialisation
|
||||
The `Router` struct is only initialised in one place in the application, in `wallet/api.go`:
|
||||
|
||||
```go
|
||||
func NewAPI(s *Service) *API {
|
||||
router := NewRouter(s)
|
||||
return &API{s, s.reader, router}
|
||||
}
|
||||
|
||||
type API struct {
|
||||
s *Service
|
||||
reader *Reader
|
||||
router *Router
|
||||
}
|
||||
```
|
||||
|
||||
# Method and field calls
|
||||
|
||||
The `API.router` field is only called in two places:
|
||||
|
||||
## `GetSuggestedRoutes()`
|
||||
|
||||
This function is a straight through wrapper of `Router.suggestedRoutes()`:
|
||||
|
||||
```go
|
||||
func (api *API) GetSuggestedRoutes(
|
||||
ctx context.Context,
|
||||
sendType SendType,
|
||||
addrFrom common.Address,
|
||||
addrTo common.Address,
|
||||
amountIn *hexutil.Big,
|
||||
tokenID string,
|
||||
disabledFromChainIDs,
|
||||
disabledToChaindIDs,
|
||||
preferedChainIDs []uint64,
|
||||
gasFeeMode GasFeeMode,
|
||||
fromLockedAmount map[uint64]*hexutil.Big,
|
||||
) (*SuggestedRoutes, error) {
|
||||
log.Debug("call to GetSuggestedRoutes")
|
||||
return api.router.suggestedRoutes(ctx, sendType, addrFrom, addrTo, amountIn.ToInt(), tokenID, disabledFromChainIDs,
|
||||
disabledToChaindIDs, preferedChainIDs, gasFeeMode, fromLockedAmount)
|
||||
}
|
||||
```
|
||||
|
||||
## `CreateMultiTransaction()`
|
||||
|
||||
This function simply makes a read call to `Router.bridges`
|
||||
|
||||
```go
|
||||
func (api *API) CreateMultiTransaction(ctx context.Context, multiTransactionCommand *transfer.MultiTransactionCommand, data []*bridge.TransactionBridge, password string) (*transfer.MultiTransactionCommandResult, error) {
|
||||
log.Debug("[WalletAPI:: CreateMultiTransaction] create multi transaction")
|
||||
return api.s.transactionManager.CreateMultiTransactionFromCommand(ctx, multiTransactionCommand, data, api.router.bridges, password)
|
||||
}
|
||||
```
|
Loading…
Reference in New Issue