def test_compute_address(self): contract = SmartContract() contract.owner = Account("93ee6143cdc10ce79f15b2a6c2ad38e9b6021c72a1779051f47154fd54cfbd5e") contract.owner.nonce = 0 contract.compute_address() self.assertEqual("00000000000000000500bb652200ed1f994200ab6699462cab4b1af7b11ebd5e", contract.address.hex()) self.assertEqual("erd1qqqqqqqqqqqqqpgqhdjjyq8dr7v5yq9tv6v5vt9tfvd00vg7h40q6779zn", contract.address.bech32()) contract.owner.nonce = 1 contract.compute_address() self.assertEqual("000000000000000005006e4f90488e27342f9a46e1809452c85ee7186566bd5e", contract.address.hex()) self.assertEqual("erd1qqqqqqqqqqqqqpgqde8eqjywyu6zlxjxuxqfg5kgtmn3setxh40qen8egy", contract.address.bech32())
def compute_dns_address_for_shard_id(shard_id) -> Address: deployer_pubkey_prefix = InitialDNSAddress[:len(InitialDNSAddress) - ShardIdentiferLen] deployer_pubkey = deployer_pubkey_prefix + bytes([0, shard_id]) deployer = Account(address=Address(deployer_pubkey)) deployer.nonce = 0 # Workaround: currently, in erdpy, in order to compute the address of a contract, one has to create an instance of the class "SmartContract". # This might change in the future. contract = SmartContract() contract.owner = deployer contract.compute_address() return contract.address
def get_delegation_address() -> Address: contract = SmartContract() contract.owner = get_owner_of_genesis_contracts() contract.owner.nonce = 0 contract.compute_address() return contract.address