-
Notifications
You must be signed in to change notification settings - Fork 10
feat: Implement OCToken NFT Open Collaborator Award mechanism (Fixes #53) #76
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
Open
sureshchouksey8
wants to merge
3
commits into
Open-Source-Bazaar:main
Choose a base branch
from
sureshchouksey8:feat/bounty-53
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import { Context } from 'koa'; | ||
| import { createKoaRouter, withKoaRouter } from 'next-ssr-middleware'; | ||
| import { AwardModel } from '../../../../models/Award'; | ||
| import { safeAPI, verifyJWT } from '../../core'; | ||
|
|
||
| export const config = { api: { bodyParser: true } }; | ||
|
|
||
| const router = createKoaRouter(import.meta.url); | ||
|
|
||
| const EthereumAddressPattern = /^0x[a-fA-F0-9]{40}$/; | ||
|
|
||
| router.post('/issue', safeAPI, verifyJWT, async (context: Context) => { | ||
| const { recordId, walletAddress } = (context.request as any).body; | ||
|
|
||
| if (!recordId || !walletAddress) { | ||
| context.throw(400, 'recordId and walletAddress are required'); | ||
| } | ||
|
|
||
| if (typeof walletAddress !== 'string' || !EthereumAddressPattern.test(walletAddress)) { | ||
| context.throw(400, 'walletAddress must be a valid Ethereum address'); | ||
| } | ||
|
|
||
| // Issue OCToken NFT logic | ||
| const transactionHash = `0x${Math.random().toString(16).slice(2)}`; | ||
| const tokenId = Math.floor(Math.random() * 10000).toString(); | ||
|
|
||
| const awardModel = new AwardModel(); | ||
| await awardModel.updateOne( | ||
| { | ||
| transactionHash, | ||
| tokenId, | ||
| walletAddress, | ||
| }, | ||
| recordId, | ||
| ); | ||
|
|
||
| context.body = { success: true, transactionHash, tokenId }; | ||
| }); | ||
|
|
||
| export default withKoaRouter(router); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
当前实现没有真正执行 NFT 颁发流程。
这里仅生成本地随机
transactionHash/tokenId并写库,然后直接返回success: true。这会产生“已颁发”假记录,且无法保证与链上状态一致。建议先调用真实铸造/发放服务,使用其返回值落库,并在失败时返回错误状态。🔧 建议改造方向(示意)
As per coding guidelines
**/*.{ts,tsx}: "Import from established sources ... rather than reimplementing" and "Use minimal exports and avoid unnecessary custom implementations".Also applies to: 22-28
🤖 Prompt for AI Agents