Skip to content

Latest commit

 

History

History
125 lines (115 loc) · 5.24 KB

fip-0038.md

File metadata and controls

125 lines (115 loc) · 5.24 KB
fip title status type author created updated
38
Add ability to create FIO Chain Account
Accepted
Functionality
Pawel Mastalerz <[email protected]>
2022-01-31
2022-02-23

Abstract

This FIP adds ability to create a new FIO Chain Account with custom permission in one action.

New actions

Contract Action Endpoint Description
fio.address newfioacc /new_fio_chain_account Creates a new FIO Chain Account.

Motivation

Because accounts on FIO Chain are created automatically when a new FIO Public Key is used, the newaccount action is not supported. However, every time a new account is created it has the FIO Public Key, which hashes down to the account name, set as the active and owner permission. This may break some user flows which would want to create a new account with custom permissions in one action.

It's therefore deemed beneficial to enable new account creation with ability to specify custom permission in one action.

Specification

New actions

New FIO Chain Account

Creates a new FIO Chain account.

Contract: fio.address

New action: newfioacc

New end point: /new_fio_chain_account

New fee: new_fio_chain_account, not bundle-eligible, fee amount will be determined during development and updated here

RAM increase: To be determined during implementation

Request body

Parameter Required Format Definition
fio_public_key Yes String The supplied FIO Public Key will be used for: 1) Account name will be a hash of the key; 2) The key will be set as owner and active permissions if those parameters are left empty.
owner Yes JSON JSON of authorizations, same as in auth parameter of updateauth action. May be left empty, in which case the supplied fio_public_key will be used as owner permission.
active Yes JSON JSON of authorizations, same as in auth parameter of updateauth action. May be left empty, in which case the supplied fio_public_key will be used as active permission.
max_fee Yes Positive Int Maximum amount of SUFs the user is willing to pay for fee. Should be preceded by /get_fee for correct value.
actor Yes 12 character string Valid actor of signer
tpid Yes FIO Address FIO Address of the entity which generates this transaction. TPID rewards will be paid to this address. Set to empty if not known.
Example
{
	"fio_public_key": "FIO5rebL4c6KTJcyYb8aaGpw13Tpm8Xu9RaK1TtcvicCaUr4GiRwF",
	"owner": {
		"threshold": 2,
		"keys": [],
		"waits": [],
		"accounts": [
			{
				"permission": {
					"actor": "1jynjfoswglg",
					"permission": "active"
				},
				"weight": 1
			},
			{
				"permission": {
					"actor": "qhdo4r2pltdr",
					"permission": "active"
				},
				"weight": 1
			},
			{
				"permission": {
					"actor": "tsksksw1jxrb",
					"permission": "active"
				},
				"weight": 1
			}
		]
	},
	"active": "",
	"max_fee": 1000000000,
	"actor": "aftyershcu22",
	"tpid": "rewards@wallet"
}

Processing

  • Request is validated per Exception handling
  • New account is created in the same manner as is created when using trnsfiopubky
  • RAM of actor calling action is increased.
  • new_fio_chain_account is charged to actor calling action.
  • Check for maximum FIO transaction size is applied.

Exception handling

Error condition Trigger Type fields:name fields:value Error message
Invalid FIO Public Key Format of FIO Public Key is not valid. 400 "fio_public_key" Value sent in, i.e. "123" "Invalid FIO Public Key format"
Invalid owner permission Format of the permission is not valid. 400 "owner" Value sent in, i.e. "123" "Invalid owner permission format"
Invalid active permission Format of the permission is not valid. 400 "active" Value sent in, i.e. "123" "Invalid active permission format"
Invalid fee value max_fee format is not valid 400 "max_fee" Value sent in, e.g. "-100" "Invalid fee value"
Fee exceeds maximum Actual fee is greater than supplied max_fee 400 "max_fee" Value sent in, e.g. "1000000000" "Fee exceeds supplied maximum"
Insufficient balance Available balance in account is less than fee 400 "max_fee" Value sent in, e.g. "100000000000" "Insufficient balance"
Invalid TPID tpid format is not valid 400 "tpid" Value sent in, e.g. "notvalidfioaddress" "TPID must be empty or valid FIO address"
Signer not actor Signer not actor 403 Type: invalid_signature

Response body

Parameter Format Definition
status String OK if successful
account String Account name of account which was created in this action.
fee_collected Int Amount of SUFs collected as fee
Example
{
  "status": "OK",
  "account": "z4wirlxvsyig",
  "fee_collected": 1000000000
}

Rationale

Enabling of newaccount action was considered. It is a system action now, but could have been made public. However, that approach was deemed more complex as it would require updates to other smart contracts which are calling this action now.

Implementation

TBD

Backwards Compatibility

No changes to existing actions.

Future considerations

None

Discussion link

https://fioprotocol.atlassian.net/wiki/spaces/FC/pages/473104421/Enhanced+permissions