Skip to content

Commit c324675

Browse files
committed
fix, get and create auction and setup a fresh genesis for testing
1 parent 9516130 commit c324675

7 files changed

Lines changed: 17 additions & 7 deletions

File tree

examples/common/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// STEP 1: Create the genesis category using the `createGenesisCategory` function
2-
const nameTokenCategory = 'b260f4bff9899f4a33ac066520e0a7902537df73d125f0ade130253f1de8bcbe';
2+
const nameTokenCategory = '43bb481fc6a1c8cc18cdc61da4858194f49e587149cf099c9ea674ee28734c8c';
33

44
// STEP 2: Figure out the following parameters
55
const minStartingBid = 10000;

examples/create-auction.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
} from './common/setup.js';
44
import { aliceAddress, alicePriv } from './common/wallet.js';
55
import { getSignedTransaction } from './common/sign.js';
6+
import { ElectrumNetworkProvider } from 'cashscript';
67

78

89
(async () =>
@@ -20,4 +21,9 @@ import { getSignedTransaction } from './common/sign.js';
2021
})
2122

2223
console.log(preparedTransaction);
24+
25+
const electrum = new ElectrumNetworkProvider('mainnet');
26+
// @ts-ignore
27+
const txid = await electrum.sendRawTransaction(preparedTransaction.hex);
28+
console.log('txid: ', txid);
2329
})();

examples/create-genesis.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,14 @@ const createMintingSetup = async () => {
161161
(async () =>
162162
{
163163
// Do this as Step 1 and once done, comment out the line below
164-
await createSuitableUTXO();
164+
// await createSuitableUTXO();
165165

166166
// Do this as Step 2
167167
// await createGenesisCategory();
168168

169169
// Do this as step 3, copy the tokenID from the terminal and paste it above in the `const nameTokenCategory` variable
170170
// and once done, comment out the line below
171-
// await createMintingSetup();
171+
await createMintingSetup();
172172

173173
// Once this is done, you are ready to go!
174174
})();

lib/functions/get-auctions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const getAuctions = async ({
3333

3434
let initialAmount, previousTxHash, previousHeight, currentAmount;
3535
// if output 4 has op_return then the previous transaction was auction transaction, else it was a bid transaction
36-
if(decodedTx.outputs[4].valueSatoshis == BigInt(0))
36+
if(decodedTx.outputs[2].token?.nft?.capability == 'minting' && decodedTx.outputs[3].token?.nft?.capability == 'mutable')
3737
{
3838
// auction transaction, this means
3939
initialAmount = Number(decodedTx.outputs[3].valueSatoshis);
@@ -57,7 +57,7 @@ export const getAuctions = async ({
5757
previousDecodedTx = null;
5858
}
5959

60-
if(previousDecodedTx.outputs[4].valueSatoshis == BigInt(0))
60+
if(decodedTx.outputs[2].token?.nft?.capability == 'minting' && decodedTx.outputs[3].token?.nft?.capability == 'mutable')
6161
{
6262
initialAmount = Number(previousDecodedTx.outputs[3].valueSatoshis);
6363
const height = await fetchTransactionBlockHeight(electrumClient, previousHash);

lib/manager.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ export class BitcannManager
269269

270270
// Check if the amount is greater than the minimum to start an auction
271271
const auctionPrice = getAuctionPrice(BigInt(currentRegistrationId), BigInt(this.minStartingBid));
272+
console.log('auctionPrice', auctionPrice);
273+
console.log('amount', amount);
272274
if(amount < auctionPrice)
273275
{
274276
throw new InvalidAuctionAmountError();

lib/util/contract.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { binToHex, hexToBin } from '@bitauth/libauth';
22
import type { AddressType, NetworkProvider } from 'cashscript';
33
import { Contract } from 'cashscript';
44
import { BitCANNArtifacts } from '@bitcann/contracts';
5-
import { convertAddressToPkh } from './address';
5+
import { convertAddressToPkh } from './address.js';
66

77

88
/**

lib/util/price.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,7 @@ export const getAuctionPrice = (registrationId: bigint, minStartingBid: bigint):
3333
const decayPoints = minStartingBid * registrationId * 3n;
3434
const currentPricePoints = minStartingBid * 1_000_000n;
3535
const currentAuctionPrice = (currentPricePoints - decayPoints) / 1_000_000n;
36-
return currentAuctionPrice > 20_000n ? currentAuctionPrice : 20_000n;
36+
return currentAuctionPrice > 6000n ? currentAuctionPrice : 6000n;
37+
// TODO: make this 20_000n
38+
// return currentAuctionPrice > 20_000n ? currentAuctionPrice : 20_000n;
3739
};

0 commit comments

Comments
 (0)