|
| 1 | +import BigNumber from 'bignumber.js' |
| 2 | +import { mapObject } from '../../utils/other' |
| 3 | + |
| 4 | +// # AENS |
| 5 | +export const NAME_TTL = 180000 |
| 6 | +// # max number of block into the future that the name is going to be available |
| 7 | +// # https://github.com/aeternity/protocol/blob/epoch-v0.22.0/AENS.md#update |
| 8 | +// # https://github.com/aeternity/protocol/blob/44a93d3aab957ca820183c3520b9daf6b0fedff4/AENS.md#aens-entry |
| 9 | +export const NAME_MAX_TTL = 36000 |
| 10 | +export const NAME_MAX_CLIENT_TTL = 84600 |
| 11 | +export const CLIENT_TTL = NAME_MAX_CLIENT_TTL |
| 12 | +// # see https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L67 |
| 13 | +export const NAME_FEE_MULTIPLIER = 1e14 // 100000000000000 |
| 14 | +export const NAME_FEE_BID_INCREMENT = 0.05 // # the increment is in percentage |
| 15 | +// # see https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L272 |
| 16 | +export const NAME_BID_TIMEOUT_BLOCKS = 480 // # ~1 day |
| 17 | +// # this is the max length for a domain that requires a base fee to be paid |
| 18 | +export const NAME_MAX_LENGTH_FEE = 31 |
| 19 | +export const NAME_BID_MAX_LENGTH = 12 // # this is the max length for a domain to be part of a bid |
| 20 | +export const POINTER_KEY_BY_PREFIX = { |
| 21 | + ak: 'account_pubkey', |
| 22 | + ok: 'oracle_pubkey', |
| 23 | + ct: 'contract_pubkey', |
| 24 | + ch: 'channel' |
| 25 | +} |
| 26 | +// # https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L290 |
| 27 | +// # https://github.com/aeternity/protocol/blob/master/AENS.md#protocol-fees-and-protection-times |
| 28 | +// # bid ranges: |
| 29 | +export const NAME_BID_RANGES = mapObject({ |
| 30 | + 31: 3, |
| 31 | + 30: 5, |
| 32 | + 29: 8, |
| 33 | + 28: 13, |
| 34 | + 27: 21, |
| 35 | + 26: 34, |
| 36 | + 25: 55, |
| 37 | + 24: 89, |
| 38 | + 23: 144, |
| 39 | + 22: 233, |
| 40 | + 21: 377, |
| 41 | + 20: 610, |
| 42 | + 19: 987, |
| 43 | + 18: 1597, |
| 44 | + 17: 2584, |
| 45 | + 16: 4181, |
| 46 | + 15: 6765, |
| 47 | + 14: 10946, |
| 48 | + 13: 17711, |
| 49 | + 12: 28657, |
| 50 | + 11: 46368, |
| 51 | + 10: 75025, |
| 52 | + 9: 121393, |
| 53 | + 8: 196418, |
| 54 | + 7: 317811, |
| 55 | + 6: 514229, |
| 56 | + 5: 832040, |
| 57 | + 4: 1346269, |
| 58 | + 3: 2178309, |
| 59 | + 2: 3524578, |
| 60 | + 1: 5702887 |
| 61 | +}, ([key, value]) => [key, new BigNumber(value).times(NAME_FEE_MULTIPLIER)]) |
| 62 | + |
| 63 | +// # ref: https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L273 |
| 64 | +// # name bid timeouts |
| 65 | +export const NAME_BID_TIMEOUTS = { |
| 66 | + 13: BigNumber(0), |
| 67 | + 12: BigNumber(NAME_BID_TIMEOUT_BLOCKS), // # 480 blocks |
| 68 | + 8: BigNumber(31).times(NAME_BID_TIMEOUT_BLOCKS), // # 14880 blocks |
| 69 | + 4: BigNumber(62).times(NAME_BID_TIMEOUT_BLOCKS) // # 29760 blocks |
| 70 | +} |
| 71 | + |
| 72 | +// # Tag constant for ids (type uint8) |
| 73 | +// # see https://github.com/aeternity/protocol/blob/master/serializations.md#the-id-type |
| 74 | +// # <<Tag:1/unsigned-integer-unit:8, Hash:32/binary-unit:8>> |
| 75 | +const ID_TAG_ACCOUNT = 1 |
| 76 | +const ID_TAG_NAME = 2 |
| 77 | +const ID_TAG_COMMITMENT = 3 |
| 78 | +const ID_TAG_ORACLE = 4 |
| 79 | +const ID_TAG_CONTRACT = 5 |
| 80 | +const ID_TAG_CHANNEL = 6 |
| 81 | + |
| 82 | +export const ID_TAG = { |
| 83 | + account: ID_TAG_ACCOUNT, |
| 84 | + name: ID_TAG_NAME, |
| 85 | + commitment: ID_TAG_COMMITMENT, |
| 86 | + oracle: ID_TAG_ORACLE, |
| 87 | + contract: ID_TAG_CONTRACT, |
| 88 | + channel: ID_TAG_CHANNEL |
| 89 | +} |
| 90 | + |
| 91 | +export const PREFIX_ID_TAG = { |
| 92 | + ak: ID_TAG.account, |
| 93 | + nm: ID_TAG.name, |
| 94 | + cm: ID_TAG.commitment, |
| 95 | + ok: ID_TAG.oracle, |
| 96 | + ct: ID_TAG.contract, |
| 97 | + ch: ID_TAG.channel |
| 98 | +} |
| 99 | + |
| 100 | +export const ID_TAG_PREFIX = mapObject(PREFIX_ID_TAG, ([key, value]) => [value, key]) |
0 commit comments