-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbountrip.test.js
More file actions
85 lines (73 loc) · 3.44 KB
/
Copy pathbountrip.test.js
File metadata and controls
85 lines (73 loc) · 3.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import NearService from './services/near.service.js';
(async () => {
const networkId = 'testnet';
const contractId = 'quantum-coders.testnet';
const sender = 'quantum-coders.testnet';
const receiver = contractId;
try {
// 1. Crear una bounty
console.log('\n1. Creando una bounty...');
const prizes = ['1', '0.5'];
const createBountyTx = await NearService.createBountyTransaction({
networkId,
sender,
receiver,
prizes,
});
console.log('Transacción de create_bounty creada:', createBountyTx);
// Formatear la transacción para visualización
const formattedCreateBountyTx = NearService.formatTransactionForResponse(createBountyTx);
console.log('Transacción formateada:', JSON.stringify(formattedCreateBountyTx, null, 2));
// 2. Participar en una bounty
console.log('\n2. Participando en una bounty...');
const participateTx = await NearService.participateTransaction({
networkId,
sender: 'participant1.testnet',
receiver,
bountyId: 0,
});
console.log('Transacción de participate creada:', participateTx);
// Formatear la transacción para visualización
const formattedParticipateTx = NearService.formatTransactionForResponse(participateTx);
console.log('Transacción formateada:', JSON.stringify(formattedParticipateTx, null, 2));
// 3. Finalizar una bounty
console.log('\n3. Finalizando una bounty...');
const finalizeBountyTx = await NearService.finalizeBountyTransaction({
networkId,
sender,
receiver,
bountyId: 0,
winners: ['participant1.testnet'],
});
console.log('Transacción de finalize_bounty creada:', finalizeBountyTx);
// Formatear la transacción para visualización
const formattedFinalizeBountyTx = NearService.formatTransactionForResponse(finalizeBountyTx);
console.log('Transacción formateada:', JSON.stringify(formattedFinalizeBountyTx, null, 2));
// 4. Obtener todas las bounties
console.log('\n4. Obteniendo todas las bounties...');
const allBounties = await NearService.getAllBounties({networkId, contractId});
console.log('Todas las bounties:', allBounties);
// 5. Obtener una bounty específica
console.log('\n5. Obteniendo una bounty específica...');
const specificBounty = await NearService.getBounty({networkId, contractId, bountyId: 0});
console.log('Bounty específica:', specificBounty);
// 6. Obtener bounties de un participante
console.log('\n6. Obteniendo bounties de un participante...');
const participantBounties = await NearService.getParticipantBounties({
networkId,
contractId,
participantId: 'participant_comet22.testnet',
});
console.log('Bounties del participante: participant_comet22.testnet', participantBounties);
// 7. Obtener bounties de un creador
console.log('\n7. Obteniendo bounties de un creador...');
const creatorBounties = await NearService.getCreatorBounties({
networkId,
contractId,
creatorId: sender,
});
console.log('Bounties del creador:', creatorBounties);
} catch (error) {
console.error('Error durante las pruebas:', error);
}
})();