Skip to content

Instantly share code, notes, and snippets.

@deckb
Last active October 9, 2018 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deckb/27a5b87698c87900e923b8c27f65fe35 to your computer and use it in GitHub Desktop.
Save deckb/27a5b87698c87900e923b8c27f65fe35 to your computer and use it in GitHub Desktop.
unreg_proposal

proposal unregd upgrade

https://eosflare.io/tx/832da87e51beb3bcae185526b528113a63f00235a6b11fe572c9fab0b77efee5

tools used

eospy: https://github.com/eosnewyork/eospy

1st action in the proposal is to create the account eosio.regram owned by eosio.unregd

pycleos get bin2json --code eosio --action newaccount -b 0000000000ea305520cd65ea02ea30550100000000010000000000ea305500000000a8ed32320100000100000000020000000000ea305500000000a8ed323201009098ba5303ea305500804a1401ea3055010000
{
    "args": {
        "creator": "eosio",
        "name": "eosio.regram",
        "owner": {
            "threshold": 1,
            "keys": [],
            "accounts": [
                {
                    "permission": {
                        "actor": "eosio",
                        "permission": "active"
                    },
                    "weight": 1
                }
            ],
            "waits": []
        },
        "active": {
            "threshold": 1,
            "keys": [],
            "accounts": [
                {
                    "permission": {
                        "actor": "eosio",
                        "permission": "active"
                    },
                    "weight": 1
                },
                {
                    "permission": {
                        "actor": "eosio.unregd",
                        "permission": "eosio.code"
                    },
                    "weight": 1
                }
            ],
            "waits": []
        }
    }
}

2nd action is to buy ram for eosio.regram

pycleos get bin2json --code eosio --action buyrambytes -b 0000000000ea305520cd65ea02ea30550100000000010000000000ea305500000000a8ed32320100000100000000020000000000ea305500000000a8ed323201009098ba5303ea305500804a1401ea3055010000
{
    "args": {
        "payer": "eosio",
        "receiver": "eosio.regram",
        "bytes": 1
    }
}

3rd action is to transfer from eosio.saving to eosio.regram

pycleos get bin2json -c eosio.token -a transfer -b c0a6db0603ea305520cd65ea02ea305500497f0f0000000004454f53000000002d746f2070617920666f722052414d20636f737473206f6620756e72656769737465726564206163636f756e7473
{
    "args": {
        "from": "eosio.saving",
        "to": "eosio.regram",
        "quantity": "26000.0000 EOS",
        "memo": "to pay for RAM costs of unregistered accounts"
    }
}

4th action is an updateauth for eosio.unregd of eosio.code

pycleos get bin2json -c eosio -a updateauth -b 9098ba5303ea305500000000a8ed32320000000080ab26a70100000000020000000000ea305500000000a8ed323201009098ba5303ea305500804a1401ea3055010000
{
    "args": {
        "account": "eosio.unregd",
        "permission": "active",
        "parent": "owner",
        "auth": {
            "threshold": 1,
            "keys": [],
            "accounts": [
                {
                    "permission": {
                        "actor": "eosio",
                        "permission": "active"
                    },
                    "weight": 1
                },
                {
                    "permission": {
                        "actor": "eosio.unregd",
                        "permission": "eosio.code"
                    },
                    "weight": 1
                }
            ],
            "waits": []
        }
    }
}

5th action is setting the contract code

# we need to check the sha256sum

cleos multisig review argentinaeos unregdupdate | jq -r .transaction.actions[4].data.code | xxd -r -p | sha256sum
eefd39e3bb5ad6d723cc9863cd3ed6d8c612259cbe17f3ec9af2a2229bf07d7e  -

# versus the wasm we built

sha256sum eosio.unregd.wasm
eefd39e3bb5ad6d723cc9863cd3ed6d8c612259cbe17f3ec9af2a2229bf07d7e  eosio.unregd.wasm

6th action is setting the abi

# check the abi
cleos multisig review argentinaeos unregdupdate | jq -r '.transaction.actions[5].data.abi' | abi_hex_to_json | jq '' > /tmp/abi1.json

# get the current abit
cat eosio.unregd.abi | jq '' > /tmp/abi2.json

# diff the two
diff /tmp/abi1.json /tmp/abi2.json
1a2
>   "____comment": "This file was generated by eosio-abigen. DO NOT EDIT - 2018-09-02T08:20:41",
147,148c148
<   "abi_extensions": [],
<   "variants": []
---
>   "abi_extensions": []

7th action is using the maxeos action of the contract

 pycleos -u https://api-kylin.eosasia.one get bin2json -c eosio.unregd -a setmaxeos -b c83200000000000004454f5300000000
{
    "args": {
        "maxeos": "1.3000 EOS"
    }
}

Review

A review of the code and proposal looks technically sound. However the abi file is missing the Ricardian contracts.

EDIT The RCs have been added

"name": "regaccount",
      "type": "regaccount",
      "ricardian_contract": "## ACTION NAME : regaccount\n### Description### Description\n\nThe intent of the `regaccount` action is to create an EOS account using the stored information {{ Ethereum address }} and token balance from the `eosio.unregd` contract, after verifying the submitted Ethereum {{ signature }}. This is intended to be used only once for each Ethereum address stored in the `eosio.unregd` contract.The intent of the `regaccount` action is to create an EOS account using the stored information {{ Ethereum address }} and token balance from the `eosio.unregd` contract, after verifying the submitted Ethereum {{ signature }}. This is intended to be used only once for each Ethereum address stored in the `eosio.unregd` contract.\n\nAs an authorized party, I {{ signer }} wish to create an account {{ account }} on the EOS chain with ID: aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906, accessible with EOS public key {{ eos_pubkey_str }} by submitting cryptographic proof {{ signature }} corresponding to the {{ Ethereum address }}.As an authorized party, I {{ signer }} wish to create an account {{ account }} on the EOS chain with ID: aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906, accessible with EOS public key {{ eos_pubkey_str }} by submitting cryptographic proof {{ signature }} corresponding to the {{ Ethereum address }}.\n\nAs signer, I stipulate that if I am not the beneficial owner of these tokens, I have been authorized to take this action by the party submitting the cryptographic proof {{signature}}.As signer, I stipulate that if I am not the beneficial owner of these tokens, I have been authorized to take this action by the party submitting the cryptographic proof {{signature}}.\n\nIn case of dispute, all cases should be brought to the EOS Core Arbitration Forum at https://eoscorearbitration.io/.In case of dispute, all cases should be brought to the EOS Core Arbitration Forum at https://eoscorearbitration.io/.\n"
    },
    {
      "name": "setmaxeos",
      "type": "setmaxeos",
      "ricardian_contract": "## ACTION NAME : setmaxeos\n## Description## Description\n\nThe intent of the `{{ setmaxeos }}` action is to set the maximum amount of EOS this contract is willing to pay when creating a new account.The intent of the `{{ setmaxeos }}` action is to set the maximum amount of EOS this contract is willing to pay when creating a new account.\n\nAs an authorized party I {{ signer }} wish to set the new maximum amount as {{ maxeos }}.As an authorized party I {{ signer }} wish to set the new maximum amount as {{ maxeos }}.\n"
    },
    {
      "name": "chngaddress",
      "type": "chngaddress",
      "ricardian_contract": "## ACTION NAME : chngaddress\n### Description### Description\n\nThe intent of the `{{ chngaddress }}` action is to update the the stored information by updating the old Ethereum address {{old_address}} to a new Ethereum address {{new_address}}.The intent of the `{{ chngaddress }}` action is to update the the stored information by updating the old Ethereum address {{old_address}} to a new Ethereum address {{new_address}}.\n\nAs an authorized party I {{ signer }} wish to modify the Ethereum address {{old_address}} to a new Ethereum address {{new_address}}. As an authorized party I {{ signer }} wish to modify the Ethereum address {{old_address}} to a new Ethereum address {{new_address}}. \n"
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment