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

Cw4973 #99

Open
wants to merge 43 commits into
base: main
Choose a base branch
from
Open

Cw4973 #99

wants to merge 43 commits into from

Conversation

hoanm
Copy link

@hoanm hoanm commented Nov 11, 2022

Cw4973 - Account-bound Tokens (ABT)

Cw4973 is implemented based on the description of EIP-4973. Some requirements in the description will be changed for suitable with CosmWasm characteristics.

In the contract, I also implement the signature based on ADR 036 and signature verification based on @cosmjs/amino.

Specification

Cw4973 is extended from Cw721-base with some modifications in execution section:

  • All the metadata structures are unchanged.
  • All the query functions and query messages are unchanged.
  • All the execute functions and execute messages are removed.
  • We add 3 following execute functions and execute messages to the contract:
    • Give
    • Take
    • Unequip

pub gas: String,
}

// TODO: the order of these fields is VERY IMPORTANT, DO NOT CHANGE IT
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// TODO: the order of these fields is VERY IMPORTANT, DO NOT CHANGE IT
// The order of these fields is VERY IMPORTANT, DO NOT CHANGE IT

Not a TODO?

Copy link
Collaborator

@JakeHartnell JakeHartnell left a comment

Choose a reason for hiding this comment

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

NICE!

Copy link
Collaborator

@0xekez 0xekez left a comment

Choose a reason for hiding this comment

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

i love the naming of the api and signature verification. just a couple questions from a first past.

mut deps: DepsMut,
env: Env,
info: MessageInfo,
msg: InstantiateMsg,
Copy link
Collaborator

Choose a reason for hiding this comment

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

what do you think about making the InstantiateMsg an alias for Cw721BaseInstantiateMsg(ex)?

type InstantiateMsg = Cw721BaseInstantiateMsg;

that would remove the need for the first line of the function and imo helps convey the intent a little better.

}

// the get_hash funtion will concat the address of the sender, the address of the 'to', the uri of the nft and the hash of the string
fn _get_hash(active: &str, passive: &str, uri: &str, chain_id: &str) -> Vec<u8> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

could you expand a little on what these function arguments are? are active, passive, and uri intended to be additional metadata? i'm curious why you include chain id?

Comment on lines +295 to +296
// TODO: modify this function to specify the others fields of the signing document
fn _get_sign_doc(signer: &str, message: &str) -> String {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this and your types in state.rs are 🙏.

  1. is it possible to write an integration test for this? using cosmjs from the readme would be great.
  2. if you'd like, i think this signing logic would be a very helpful package to have. would you be interested in breaking it out into one?

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

Successfully merging this pull request may close these issues.

None yet

4 participants