Skip to content

Latest commit

 

History

History
428 lines (220 loc) · 12.6 KB

CoreAddresses.md

File metadata and controls

428 lines (220 loc) · 12.6 KB

Module 0x1::CoreAddresses

Module providing well-known addresses and related logic.

Note: this module currently defines zero-argument functions like Self::DIEM_ROOT_ADDRESS() using capitalization in the name, following the convention for constants. Eventually, those functions are planned to become actual global constants, once the Move language supports this feature.

Constants

The operation can only be performed by the account where currencies are registered

const ECURRENCY_INFO: u64 = 3;

The operation can only be performed by the account at 0xA550C18 (Diem Root)

const EDIEM_ROOT: u64 = 0;

The operation can only be performed by the account at 0xB1E55ED (Treasury & Compliance)

const ETREASURY_COMPLIANCE: u64 = 1;

The operation can only be performed by the VM

const EVM: u64 = 2;

Function DIEM_ROOT_ADDRESS

The address of the Diem root account. This account is created in genesis, and cannot be changed. This address has ultimate authority over the permissions granted (or removed) from accounts on-chain.

public fun DIEM_ROOT_ADDRESS(): address
Implementation
public fun DIEM_ROOT_ADDRESS(): address {
    0xA550C18
}

Function CURRENCY_INFO_ADDRESS

The (singleton) address under which the 0x1::Diem::CurrencyInfo resource for every registered currency is published. This is the same as the DIEM_ROOT_ADDRESS but there is no requirement that it must be this from an operational viewpoint, so this is why this is separated out.

public fun CURRENCY_INFO_ADDRESS(): address
Implementation
public fun CURRENCY_INFO_ADDRESS(): address {
    0xA550C18
}

Function TREASURY_COMPLIANCE_ADDRESS

The account address of the treasury and compliance account in charge of minting/burning and other day-to-day but privileged operations. The account at this address is created in genesis.

public fun TREASURY_COMPLIANCE_ADDRESS(): address
Implementation
public fun TREASURY_COMPLIANCE_ADDRESS(): address {
    0xB1E55ED
}

Function VM_RESERVED_ADDRESS

The reserved address for transactions inserted by the VM into blocks (e.g. block metadata transactions). Because the transaction is sent from the VM, an account cannot exist at the 0x0 address since there is no signer for the transaction.

public fun VM_RESERVED_ADDRESS(): address
Implementation
public fun VM_RESERVED_ADDRESS(): address {
    0x0
}

Function CORE_CODE_ADDRESS

The reserved address where all core modules are published. No account can be created at this address.

public fun CORE_CODE_ADDRESS(): address
Implementation
public fun CORE_CODE_ADDRESS(): address {
    0x1
}

Function assert_diem_root

Assert that the account is the Diem root address.

public fun assert_diem_root(account: &signer)
Implementation
public fun assert_diem_root(account: &signer) {
    assert(Signer::address_of(account) == DIEM_ROOT_ADDRESS(), Errors::requires_address(EDIEM_ROOT))
}
Specification
pragma opaque;
include AbortsIfNotDiemRoot;

Specifies that a function aborts if the account does not have the Diem root address.

schema AbortsIfNotDiemRoot {
    account: signer;
    aborts_if Signer::spec_address_of(account) != DIEM_ROOT_ADDRESS()
        with Errors::REQUIRES_ADDRESS;
}

Function assert_treasury_compliance

Assert that the signer has the treasury compliance address.

public fun assert_treasury_compliance(account: &signer)
Implementation
Specification
pragma opaque;
include AbortsIfNotTreasuryCompliance;

Specifies that a function aborts if the account does not have the treasury compliance address.

Function assert_vm

Assert that the signer has the VM reserved address.

public fun assert_vm(account: &signer)
Implementation
public fun assert_vm(account: &signer) {
    assert(Signer::address_of(account) == VM_RESERVED_ADDRESS(), Errors::requires_address(EVM))
}
Specification
pragma opaque;
include AbortsIfNotVM;

Specifies that a function aborts if the account does not have the VM reserved address.

schema AbortsIfNotVM {
    account: signer;
    aborts_if Signer::spec_address_of(account) != VM_RESERVED_ADDRESS()
        with Errors::REQUIRES_ADDRESS;
}

Function assert_currency_info

Assert that the signer has the currency info address.

public fun assert_currency_info(account: &signer)
Implementation
Specification
pragma opaque;
include AbortsIfNotCurrencyInfo;

Specifies that a function aborts if the account has not the currency info address.

schema AbortsIfNotCurrencyInfo {
    account: signer;
    aborts_if Signer::spec_address_of(account) != CURRENCY_INFO_ADDRESS()
        with Errors::REQUIRES_ADDRESS;
}