-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
1,589 additions
and
1,334 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 |
---|---|---|
@@ -1,9 +1,15 @@ | ||
/** | ||
* contribution-tier service | ||
*/ | ||
|
||
import { factories } from '@strapi/strapi'; | ||
import { createTransaction, Commands } from '../../../utils/network'; | ||
|
||
export default factories.createCoreService('api::contribution-tier.contribution-tier', () => ({ | ||
async registerOnChain({ account, tierId, campaignId, amount }) { | ||
const params = { | ||
campaignId, | ||
tierId, | ||
amount, | ||
}; | ||
|
||
export default factories.createCoreService( | ||
'api::contribution-tier.contribution-tier', | ||
); | ||
const txResult = await createTransaction(Commands.Create, params, account); | ||
return txResult; | ||
}, | ||
})); |
This file contains 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 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 |
---|---|---|
@@ -1,7 +1,14 @@ | ||
/** | ||
* contribution service | ||
*/ | ||
|
||
import { factories } from '@strapi/strapi'; | ||
import { createTransaction, Commands } from '../../../utils/network'; | ||
|
||
export default factories.createCoreService('api::contribution.contribution', () => ({ | ||
async registerOnChain({ account, tierId, campaignId }) { | ||
const params = { | ||
campaignId, | ||
tierId, | ||
}; | ||
|
||
export default factories.createCoreService('api::contribution.contribution'); | ||
const txResult = await createTransaction(Commands.Create, params, account); | ||
return txResult; | ||
}, | ||
})); |
This file contains 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 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 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 |
---|---|---|
@@ -1,83 +1,34 @@ | ||
/** | ||
* project service | ||
*/ | ||
|
||
import { factories } from '@strapi/strapi'; | ||
|
||
export default factories.createCoreService('api::project.project'); | ||
|
||
// import { factories } from '@strapi/strapi'; | ||
// import { Program, AnchorProvider, web3, utils, BN, setProvider } from "@coral-xyz/anchor" | ||
// import { PublicKey, TransactionInstruction } from '@solana/web3.js'; | ||
// import { Buffer } from 'buffer'; | ||
|
||
// // Make sure to load your program IDL and program key | ||
// import idl from './crowdfunding.json'; | ||
// import { Crowdfunding } from './crowdfunding'; | ||
// import { publicKey } from '@coral-xyz/anchor/dist/cjs/utils'; | ||
|
||
// const idl_string= JSON.stringify(idl); | ||
// const idl_object = JSON.parse(idl_string); | ||
// const programId = new PublicKey(idl.address); | ||
// const { SystemProgram } = web3; | ||
|
||
// export default factories.createCoreService('api::project.project', ({ strapi }) => ({ | ||
// async createProject(projectIdInput: number, softCapInput: number, hardCapInput: number, deadlineInput: number) { | ||
// try { | ||
|
||
// // Setup provider and program | ||
// const provider = AnchorProvider.env(); | ||
// const program = new Program(idl, new PublicKey('6BsMtttdteCnV3b6XmxTiLS9VQfb57yu7cRH8SKfP4u3'), provider); | ||
|
||
// const owner = provider.wallet.publicKey; | ||
// const muzikieAddress = new PublicKey("3fh3nfHi22i93zq971bJFEC5o1NCaQYND4g33yMQS2ko"); | ||
|
||
// // Convert inputs to anchor types (BN, etc.) | ||
// const projectId = new BN(projectIdInput); | ||
// const softCap = new BN(softCapInput); | ||
// const hardCap = new BN(hardCapInput); | ||
// const deadline = new BN(deadlineInput); | ||
|
||
// // Find the program derived address (PDA) for the project | ||
// const [projectPDA] = await PublicKey.findProgramAddress( | ||
// [Buffer.from(projectId.toArrayLike(Buffer, 'le', 8))], | ||
// program.programId | ||
// ); | ||
|
||
// // Build the transaction instruction to create the project | ||
// const tx = new web3.Transaction(); | ||
// tx.add( | ||
// program.instruction.initProject( | ||
// projectId, | ||
// softCap, | ||
// hardCap, | ||
// deadline, | ||
// owner, | ||
// muzikieAddress, | ||
// { | ||
// accounts: { | ||
// owner: owner, | ||
// projectState: projectPDA, | ||
// systemProgram: SystemProgram.programId, | ||
// }, | ||
// } | ||
// ) | ||
// ); | ||
|
||
// // Send the transaction | ||
// const signature = await provider.sendAndConfirm(tx); | ||
|
||
// // Log the transaction signature and return the project PDA | ||
// console.log('Transaction signature', signature); | ||
|
||
// return { | ||
// message: 'Project created successfully', | ||
// projectPDA: projectPDA.toString(), | ||
// signature: signature, | ||
// }; | ||
// } catch (error) { | ||
// strapi.log.error('Error creating project on Solana blockchain:', error); | ||
// throw new Error('Failed to create project on blockchain.'); | ||
// } | ||
// } | ||
// })); | ||
import { createTransaction, Commands } from '../../../utils/network'; | ||
|
||
export default factories.createCoreService('api::project.project', () => ({ | ||
async createCampaign({ account, softGoal, hardGoal, deadline, apiId }) { | ||
const params = { | ||
apiId, | ||
softGoal, | ||
hardGoal, | ||
deadline, | ||
}; | ||
|
||
const txResult = await createTransaction(Commands.Create, params, account); | ||
return txResult; | ||
}, | ||
|
||
async publish({ account, campaignId }) { | ||
const params = { | ||
campaignId, | ||
}; | ||
|
||
const txResult = await createTransaction(Commands.Publish, params, account); | ||
return txResult; | ||
}, | ||
|
||
async payout({ account, campaignId }) { | ||
const params = { | ||
campaignId, | ||
}; | ||
|
||
const txResult = await createTransaction(Commands.Payout, params, account); | ||
return txResult; | ||
}, | ||
})); |
This file contains 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,6 @@ | ||
export const chainID = Buffer.from(process.env.CHAIN_ID as string, 'hex'); | ||
export enum endpoints { | ||
getAuthAccount ='auth_getAuthAccount', | ||
postTransaction ='txpool_postTransaction', | ||
}; | ||
export const DERIVATION_PATH = "m/44'/134'/0"; |
Oops, something went wrong.