Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add message type to associate CW contract address #1681

Merged
merged 4 commits into from
May 17, 2024
Merged

Conversation

codchen
Copy link
Collaborator

@codchen codchen commented May 17, 2024

Describe your changes and provide context

Add a new AssociateContractAddress message type for CW contracts to be explicitly associated with their EVM address counterparts.

Testing performed to validate your change

unit tests

local Sei

tonychen@Tonys-MacBook-Pro sei-chain % ~/go/bin/seid tx evm associate-contract-address sei14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sh9m79m --from=admin --fees=200000usei -y --broadcast-mode=block
code: 0
codespace: ""
data: 0A370A352F73656970726F746F636F6C2E736569636861696E2E65766D2E4D73674173736F6369617465436F6E747261637441646472657373
events:
- attributes:
  - index: true
    key: c3BlbmRlcg==
    value: c2VpMXdncmZ0bHU4bXphOW53cXhjNGxzcHk1dnJncGhjaGxwdDAzemx2
  - index: true
    key: YW1vdW50
    value: MjAwMDAwdXNlaQ==
  type: coin_spent
- attributes:
  - index: true
    key: ZmVl
    value: MjAwMDAwdXNlaQ==
  - index: true
    key: ZmVlX3BheWVy
    value: c2VpMXdncmZ0bHU4bXphOW53cXhjNGxzcHk1dnJncGhjaGxwdDAzemx2
  type: tx
- attributes:
  - index: true
    key: YWNjX3NlcQ==
    value: c2VpMXdncmZ0bHU4bXphOW53cXhjNGxzcHk1dnJncGhjaGxwdDAzemx2LzI=
  type: tx
- attributes:
  - index: true
    key: c2lnbmF0dXJl
    value: c2lyNGducXlkRUFkdncvMlFsdDRUdk55eCt2bEpndXhYakpDM3J5ME9DWUdVUks2Z0hBdE8zNmNRY25lZFdteVJRT2JjcjRRd25nMHFzemhXN0wvbmc9PQ==
  type: tx
- attributes:
  - index: true
    key: ZXZtX2FkZHI=
    value: MHg5NkNkNjhEYkVDNEQ2ZDU3RmVFQkM4MzBmZDA2QThEQWU2ODNBMTc2
  - index: true
    key: c2VpX2FkZHI=
    value: c2VpMXdncmZ0bHU4bXphOW53cXhjNGxzcHk1dnJncGhjaGxwdDAzemx2
  type: signer
- attributes:
  - index: true
    key: YWN0aW9u
    value: L3NlaXByb3RvY29sLnNlaWNoYWluLmV2bS5Nc2dBc3NvY2lhdGVDb250cmFjdEFkZHJlc3M=
  type: message
- attributes:
  - index: true
    key: c2VpX2FkZHI=
    value: c2VpMTRoajJ0YXZxOGZwZXNkd3h4Y3U0NHJ0eTNoaDkwdmh1anJ2Y21zdGw0enIzdHhtZnZ3OXNoOW03OW0=
  - index: true
    key: ZXZtX2FkZHI=
    value: MHg1QThENjQ4REVFNTdiMmZjOTBEOThEQzE3ZmE4ODcxNTliNjk2Mzhi
  type: address_associated
gas_used: "84894"
gas_wanted: "200000"
height: "33"
info: ""
logs:
- events:
  - attributes:
    - key: sei_addr
      value: sei14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sh9m79m
    - key: evm_addr
      value: 0x5A8D648DEE57b2fc90D98DC17fa887159b69638b
    type: address_associated
  - attributes:
    - key: action
      value: /seiprotocol.seichain.evm.MsgAssociateContractAddress
    type: message
  log: ""
  msg_index: 0
raw_log: '[{"events":[{"type":"address_associated","attributes":[{"key":"sei_addr","value":"sei14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sh9m79m"},{"key":"evm_addr","value":"0x5A8D648DEE57b2fc90D98DC17fa887159b69638b"}]},{"type":"message","attributes":[{"key":"action","value":"/seiprotocol.seichain.evm.MsgAssociateContractAddress"}]}]}]'
timestamp: ""
tx: null
txhash: B93ADACED00C29E91F6F1B5BEC73378BA2A7082E49C0FD86B109774EB03E4C29
tonychen@Tonys-MacBook-Pro sei-chain % ~/go/bin/seid q evm evm-addr sei14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sh9m79m
associated: true
evm_address: 0x5A8D648DEE57b2fc90D98DC17fa887159b69638b
tonychen@Tonys-MacBook-Pro sei-chain % ~/go/bin/seid q evm sei-addr 0x5A8D648DEE57b2fc90D98DC17fa887159b69638b
associated: true
sei_address: sei14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sh9m79m

@codecov-commenter
Copy link

codecov-commenter commented May 17, 2024

Codecov Report

Attention: Patch coverage is 37.77778% with 28 lines in your changes are missing coverage. Please review.

Project coverage is 60.86%. Comparing base (16a2b18) to head (8ac1efa).

Current head 8ac1efa differs from pull request most recent head 98356e8

Please upload reports for the commit 98356e8 to get more accurate results.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1681      +/-   ##
==========================================
- Coverage   60.91%   60.86%   -0.06%     
==========================================
  Files         367      368       +1     
  Lines       26811    26848      +37     
==========================================
+ Hits        16333    16342       +9     
- Misses       9367     9394      +27     
- Partials     1111     1112       +1     
Files Coverage Δ
app/app.go 65.02% <100.00%> (ø)
x/evm/keeper/address.go 84.61% <ø> (-1.60%) ⬇️
x/evm/keeper/keeper.go 49.46% <100.00%> (+0.13%) ⬆️
x/evm/types/codec.go 50.00% <100.00%> (+0.70%) ⬆️
x/evm/types/message_register_pointer.go 0.00% <ø> (ø)
x/evm/handler.go 12.12% <0.00%> (-1.22%) ⬇️
x/evm/keeper/msg_server.go 76.27% <81.25%> (+0.30%) ⬆️
x/evm/types/message_associate_contract_address.go 0.00% <0.00%> (ø)

}
evmAddr := common.BytesToAddress(addr)
existingEvmAddr, ok := server.GetEVMAddress(ctx, addr)
if ok {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to handle the case where ok == false ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's the case where we set the association (because no existing association)

@stevenlanders
Copy link
Contributor

if someone tries to send an NFT to a contract address and it is not associated, what do they see?

@philipsu522 philipsu522 merged commit c725b57 into main May 17, 2024
47 checks passed
@philipsu522 philipsu522 deleted the contract-asso branch May 17, 2024 15:11
@codchen
Copy link
Collaborator Author

codchen commented May 20, 2024

if someone tries to send an NFT to a contract address and it is not associated, what do they see?

the tx would fail with an error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants