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

New purchase logic proposal #14

Open
ZenVoich opened this issue Dec 21, 2022 · 0 comments
Open

New purchase logic proposal #14

ZenVoich opened this issue Dec 21, 2022 · 0 comments

Comments

@ZenVoich
Copy link
Contributor

Diagram:
image

Pseudo code:

public func receive(caller : Principal, tokenId : Types.TokenIdentifier) : async Result.Result<(), Types.CommonError> {
  // if token is not available refund ICP
  if (not tokenAvailable(tokenId)) {
    addRefund(caller, tokenId);
    return #err;
  };

  let paid = await checkPayment(caller, tokenId);
  if (not paid) {
    return #err;
  };

  if (not tokenAvailable(tokenId)) {
    addRefund(caller, tokenId);
    return #err;
  };

  transferToken(caller, tokenId);
  addDisbursement(fees);
  addDisbursement(tokenOwner);
  return #ok;
};

accountId for payment computed from canisterPrincipal + userPrincipal + tokenId
In addRefund we add cron job to return icp to user if payment was recieved and token was sold to another user.
In addRefund we also check if there any deferred disbursements in conflict with refund. (if the same user is calls receive multiple times)

Pros:

  1. Fewer steps to buy NFT
  2. No lock logic. No one can lock entire collection
  3. ???

Cons:

  1. Backwards incompatible. Other marketplaces should implement the new logic.
  2. Sometimes(rarely?) we need to refund ICP(fee but low)
  3. ???
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

No branches or pull requests

1 participant