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

BlinkMart-Protocol合约功能需求 #1

Closed
Fankouzu opened this issue Aug 21, 2024 · 2 comments
Closed

BlinkMart-Protocol合约功能需求 #1

Fankouzu opened this issue Aug 21, 2024 · 2 comments
Assignees

Comments

@Fankouzu
Copy link
Member

Fankouzu commented Aug 21, 2024

合约需求

  1. 下单收款
    • 签名人提交金额,订单id, 收款人地址从商品PDA获取
      OrderPDA: { owner: ...., payee: ...., order_id: ...., amount: ...., }
  2. 确认收货放款
    • 签名人确认放款,系统收取手续费,剩余货款发送到收款人账户
  3. 系统退款
    • 系统管理员取消订单,货款原路返回
@Fankouzu Fankouzu converted this from a draft issue Aug 21, 2024
@davvviid
Copy link
Collaborator

davvviid commented Sep 2, 2024

测试流程是: 商家上架商品 -》买家下单 1 -》买家下单 2 -》 卖家确认收货 -》商家提现 -》 买家退单 2 -》 商家下架商品

@davvviid
Copy link
Collaborator

davvviid commented Sep 2, 2024

以下变量没有说明获取方式的,则需要从数据库查询

// **************************************************************
// 平台设置后台管理信息
function initialize()

  • administrator (管理员)
  • treasury (收款地址)
  • operation (运营人员)
  • transactionFees (手续费)

// 上架商品
function listing()

  • productId (在卖家上架商品时,随机生成固定长度的ID)
  • administrator (管理员)
  • treasury (收款地址, 每个商品都可设置不同的收款地址)
  • salesPrice

// 下架 商品
function delisting()

// 买家下单
function placeOrder()

  • orderId (买家在推特Blink触发action时,在Get或Post请求中,随机生成固定长度的ID)
  • productId (在listing()中生成的productId)
  • payer (买家自己)
  • orderQuantity (购买数量)

// 买家退货或取消订单
function cancelOrder()

// 买家确认收货
function confirmReceipt()

// 卖家提现
function confirmReceipt()

// **************************************************************
PDA: order、 product、admin 获取方法

  • 复制我代码中的findPda函数,programId 从数据库中获取,
    function findPda(seeds: Array<Buffer | Uint8Array>,) {
    return anchor.web3.PublicKey.findProgramAddressSync(seeds, anchor.web3.PublicKey(programId));
    }
  • const [product, ] = findPda([Buffer.from("product"), Buffer.from(productId)]) // 此刻的productId是已经创建成功的商品,所以从数据库中获取
  • const [order, ] = findPda([Buffer.from("order"), Buffer.from(orderId)]) // (买家在推特Blink触发action时,在Get或Post请求中,随机生成固定长度的orderId)
  • admin 从数据库获取,不需要再次生成
    // **************************************************************

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

2 participants