As noted previously, convenience and complex trading use cases may call for a more comprehensive interface, than chat-based DeBots.
Flex thus supports the option to authorize a trading application to work with the user's TIP3 Wallet directly by lending ownership of it to an app the user trusts. This way Flex workflows may be streamlined, where they previously required constant manual confirmation of actions.
The DApp is identified by an external public key that the user has to specify.
The following diagram details authorization procedure.
There is no way to understand which wallets were created for some FlexClient. So we need UserID Index for it.
This contract contains FlexClient address into code salt and we can find all such contracts for specified FlexClient by code hash. It can be deployed only by FlexClient.
This contract contains data about user:
static uint256 user_id- the user_id, It is used for address calculation
uint256 lend_pubkey- public key of dApp. We need this field to realize that dApp_pubkey changed and we need to change lend_pubkey into every user_id’s FlexWalllet.
address owner- Address that can send message to UserIdIndex. It is address of FlexClient.
bytes name- encrypted login. We use naclbox for encryption.
💡 Login encryption. Use naclbox for encryption. We use key pair of Surf and some random their_pubkey. We can decrypt it with Surf key pair. Surf flow question: should we enter pin code for every crypt operation?
name) - set msg.sender as owner. Deploy AuthIndex with
new_lend_pubkey) - Remove AuthIndex with
lend_pubkey. Deploy AuthIndex with
new_lend_pubkeyremove () - Remove AuthIndex with
UserIdIndex contract should get message only from owner (FlexClient)
Auth index is contract that helps dApp find user_id and FlexClient address by
Auth index contains
dApp_pubkeyas static data and UserIDIndex address as data
UserIDIndex contract is the owner of Auth Index
uint256 static pubkey- it is
dApp_pubkey. Address is calculated from this value.
address owner- is UserIDIndex address that create this contract
constructor() - can be called only by internal message. msg.sender is owner remove () - can be called only by owner
How to find user_id from dApp_pubkey.
We can calculate AuthIndex address if we know dApp_pubkey. From this address we can obtain owner(address of UserIdIndex). From UserIdIndex we can obtain user_id and FlexClient address.
name) - deploy UserIdIndex contract reLendIndex(
address wallets) - change
lend_pubkeyinto UserIdIndex contract(call UserIdIndex.reLendPubkey). set
new_lend_pubkeyfor every wallet from
user_id) - remove UserIdIndex contract getIndexAddress(
user_id) - return Reverse Index address.