Skip to content

Task 2-1: Upgrade Metaplex Umi SDK

Phase: 2 Priority: Medium Module: solana Depends on: Không có Reference: docs/bountyhunter-blockchain-p2/details/feature-solana-integration/SPEC.md

Background

solana-cnft.service.ts sử dụng @metaplex-foundation/js (Metaplex JS SDK v1) và @metaplex-foundation/umi cho cNFT operations. Các package này có thể đã lỗi thời, đặc biệt mpl-bubblegum cho Compressed NFT — Metaplex đã có breaking changes trong instruction format của bubblegum program. Sử dụng version cũ có thể gây lỗi khi mint/transfer cNFT trên các cluster mới.

Tasks

Note: Trước khi upgrade, chạy npm outdated để xem version hiện tại và version mới nhất. Breaking changes trong mpl-bubblegum >= 1.0.0 bao gồm thay đổi instruction builders và account structs. Cần cẩn thận: không upgrade nếu chưa có test coverage — breaking change có thể không phát hiện tại compile time.

  • [ ] Kiểm tra version hiện tại trong package.json:
    cat package.json | grep -E "metaplex|umi|bubblegum"
    
  • [ ] Chạy npm outdated để xem danh sách packages cần upgrade
  • [ ] Upgrade @metaplex-foundation/umi@metaplex-foundation/mpl-bubblegum:
    npm install @metaplex-foundation/umi@latest
    npm install @metaplex-foundation/mpl-bubblegum@latest
    npm install @metaplex-foundation/mpl-token-metadata@latest
    
  • [ ] Kiểm tra breaking changes trong changelog:
  • mintV1mintToCollectionV1 (nếu đã đổi)
  • transfer instruction parameter changes
  • createTree account struct changes
  • [ ] Cập nhật solana-cnft.service.ts nếu API đã thay đổi:
    // Ví dụ nếu mint API thay đổi:
    // Trước (v0.x):
    // await mintV1(umi, { leafOwner, merkleTree, ... }).sendAndConfirm(umi);
    
    // Sau (v1.x nếu có thay đổi):
    // await mintToCollectionV1(umi, { leafOwner, merkleTree, collection, ... }).sendAndConfirm(umi);
    
  • [ ] Chạy TypeScript compiler để bắt lỗi type:
    npx tsc --noEmit
    
  • [ ] Chạy unit tests sau upgrade:
    npm run test -- --testPathPattern=solana
    

Verification / Acceptance Criteria

  • [ ] npx tsc --noEmit không có lỗi TypeScript sau upgrade
  • [ ] npm run test -- --testPathPattern=solana tất cả pass
  • [ ] @metaplex-foundation/mpl-bubblegum version >= 1.0.0 (hoặc latest stable)
  • [ ] cNFT mint test (devnet hoặc mock) pass sau upgrade
  • [ ] Không có deprecated API warnings trong solana-cnft.service.ts
  • [ ] package.jsonpackage-lock.json được commit với versions mới

Files to Modify

  • package.json
  • package-lock.json
  • src/solana/solana-cnft.service.ts (nếu API có thay đổi)