Skip to content

Latest commit

 

History

History
157 lines (137 loc) · 6.08 KB

fip-0018.md

File metadata and controls

157 lines (137 loc) · 6.08 KB
fip title status type author created updated
18
Chain-level public address
Final
Functionality
Pawel Mastalerz <[email protected]>
2020-09-30
2021-06-15

Abstract

This FIPs adds ability for wallets to map all tokens on a particular chain to a single public address.

Modified actions and end points:

Action Endpoint Description
addaddress add_pub_address Modified error handling.
get_pub_address Modified processing.
remaddress remove_pub_address Modified processing and error handling.

Motivation

Currently when public address is mapped to the FIO Address using add_pub_address it requires chain code and token code to be specified. This allows for granular control over which tokens are mapped and also allows different tokens on same chain to be mapped to different public addresses.

Unfortunately, it also creates issues for wallets who want to map all tokens on a particular chain to a single address:

  • Since add_pub_address only allows for 5 mappings at a time, the wallet has to make many calls.
  • Since a FIO Address currently supports a maximum of 100 public addresses mapped, some wallets may not be able to map all desired tokens.
  • As new tokens are added to a chain, the wallet would have to make new add_pub_address calls.

Specification

Modifications to existing actions

Add Public Address

Existing action name: addaddress

Existing end point: /add_pub_address

Request

No changes

Example
{
  "fio_address": "purse@alice",
  "public_addresses": [
    {
      "chain_code": "BTC",
      "token_code": "BTC",
      "public_address": "1PMycacnJaSqwwJqjawXBErnLsZ7RkXUAs"
    },
    {
      "chain_code": "ETH",
      "token_code": "*",
      "public_address": "0xab5801a7d398351b8be11c439e05c5b3259aec9b"
    }
  ],
  "max_fee": 0,
  "tpid": "rewards@wallet",
  "actor": "aftyershcu22"
}

Processing

No changes

Exception handling

Specifying * as token code will now be allowed.

Response

No changes

Example

No changes

Get Public Address

Existing end point: /get_pub_address

Request

No changes

Example

No changes

Processing

If token code specified in request is not found for that blockchain, check for a * token code for that blockchain and if found return the corresponding public address. Please note that it should be possible to specify a token code of * as well as specific code. Example:

chain_code: ETH
token_code: *
public_address: pub_add_1
chain_code: ETH
token_code: USDC
public_address: pub_add_2

For get_pub_address with chain_code: ETH and token_code: USDC pub_add_2 is returned

For get_pub_address with chain_code: ETH and token_code: USDT pub_add_1 is returned

Exception handling

No changes

Response

No changes

Example

No changes

Remove Public Address

Existing action name: remaddress

Existing end point: /remove_pub_address

Request

No changes

Example
{
  "fio_address": "purse@alice",
  "public_addresses": [
    {
      "chain_code": "BTC",
      "token_code": "BTC",
      "public_address": "1PMycacnJaSqwwJqjawXBErnLsZ7RkXUAs"
    },
    {
      "chain_code": "ETH",
      "token_code": "*",
      "public_address": "0xab5801a7d398351b8be11c439e05c5b3259aec9b"
    }
  ],
  "max_fee": 0,
  "tpid": "rewards@wallet",
  "actor": "aftyershcu22"
}

Processing

When * is specified as token_code only that entry is removed. For example is FIO Address is mapped to ETH-USDC and ETH-* and user removes ETH-* as a mapping, ETH-USDC is retained.

Exception handling

Specifying * as token code will now be allowed.

Response

No changes

Example

No changes

Rationale

The FIO Protocol functionality can be significantly improved for wallets without major compatibility disruptions.

An approach was considered to remove all mappings for all tokens on a chain when * is sent, but it was determined that this would not be a desired behavior as users may want use * and individual tokens at the same time.

It will be important for wallets implementing this functionality after it has been launched to carefully consider the UX. Specifically, if a user has mapped several tokens on a chain to the same address and now sees and uses "map all" feature, the wallet has to either remove previous individual token mappings automatically, or make it clear to the user that they have both all and individual tokens mapped. This is important since the user may change the "map all" public address in the future and not realize that it does not apply to mappings of individual tokens.

Implementation

Release information

The contract actions addaddress and remaddress were modified to accept chain-level public addresses in fio.contracts v2.3.0.

The add_pub_address, get_pub_address, and remove_pub_address API endpoints were modified to accept chain-level public addresses in fio v3.0.0.

Backwards Compatibility

Even though existing actions and getters are modified backwards compatibility is retained:

  • For add_pub_address only error handling is modified, request/response formats are not changing
  • For get_pub_address only processing is modified, request/response formats are not changing Chain API code deploy will be required. After deployment, nodes which have not upgraded, will not return expected results for users who have adopted the use of chain-level public address, but would otherwise function properly.

Future considerations

None

Discussion link

https://fioprotocol.atlassian.net/browse/WP-150