Skip to content

Commit

Permalink
Merge pull request #13 from DIG-Network/constants
Browse files Browse the repository at this point in the history
Add way to get mainnet/testnet constants
  • Loading branch information
Yakuhito authored Sep 24, 2024
2 parents e0abb19 + b39ad0c commit 19b30cf
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
12 changes: 12 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,18 @@ export declare function syntheticKeyToPuzzleHash(syntheticKey: Buffer): Buffer
* @returns {BigInt} The cost of the coin spends.
*/
export declare function getCost(coinSpends: Array<CoinSpend>): bigint
/**
* Returns the mainnet genesis challenge.
*
* @returns {Buffer} The mainnet genesis challenge.
*/
export declare function getMainnetGenesisChallenge(): Buffer
/**
* Returns the testnet11 genesis challenge.
*
* @returns {Buffer} The testnet11 genesis challenge.
*/
export declare function getTestnet11GenesisChallenge(): Buffer
export declare class Peer {
/**
* Creates a new Peer instance.
Expand Down
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ if (!nativeBinding) {
throw new Error(`Failed to load native binding`)
}

const { newLineageProof, newEveProof, Peer, selectCoins, sendXch, morphLauncherId, createServerCoin, mintStore, oracleSpend, addFee, masterPublicKeyToWalletSyntheticKey, masterPublicKeyToFirstPuzzleHash, masterSecretKeyToWalletSyntheticSecretKey, secretKeyToPublicKey, puzzleHashToAddress, addressToPuzzleHash, adminDelegatedPuzzleFromKey, writerDelegatedPuzzleFromKey, oracleDelegatedPuzzle, signCoinSpends, getCoinId, updateStoreMetadata, updateStoreOwnership, meltStore, signMessage, verifySignedMessage, syntheticKeyToPuzzleHash, getCost } = nativeBinding
const { newLineageProof, newEveProof, Peer, selectCoins, sendXch, morphLauncherId, createServerCoin, mintStore, oracleSpend, addFee, masterPublicKeyToWalletSyntheticKey, masterPublicKeyToFirstPuzzleHash, masterSecretKeyToWalletSyntheticSecretKey, secretKeyToPublicKey, puzzleHashToAddress, addressToPuzzleHash, adminDelegatedPuzzleFromKey, writerDelegatedPuzzleFromKey, oracleDelegatedPuzzle, signCoinSpends, getCoinId, updateStoreMetadata, updateStoreOwnership, meltStore, signMessage, verifySignedMessage, syntheticKeyToPuzzleHash, getCost, getMainnetGenesisChallenge, getTestnet11GenesisChallenge } = nativeBinding

module.exports.newLineageProof = newLineageProof
module.exports.newEveProof = newEveProof
Expand Down Expand Up @@ -340,3 +340,5 @@ module.exports.signMessage = signMessage
module.exports.verifySignedMessage = verifySignedMessage
module.exports.syntheticKeyToPuzzleHash = syntheticKeyToPuzzleHash
module.exports.getCost = getCost
module.exports.getMainnetGenesisChallenge = getMainnetGenesisChallenge
module.exports.getTestnet11GenesisChallenge = getTestnet11GenesisChallenge
16 changes: 16 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1313,3 +1313,19 @@ pub fn get_cost(coin_spends: Vec<CoinSpend>) -> napi::Result<BigInt> {
.map_err(js::err)?
.to_js()
}

#[napi]
/// Returns the mainnet genesis challenge.
///
/// @returns {Buffer} The mainnet genesis challenge.
pub fn get_mainnet_genesis_challenge() -> napi::Result<Buffer> {
MAINNET_CONSTANTS.genesis_challenge.to_js()
}

#[napi]
/// Returns the testnet11 genesis challenge.
///
/// @returns {Buffer} The testnet11 genesis challenge.
pub fn get_testnet11_genesis_challenge() -> napi::Result<Buffer> {
TESTNET11_CONSTANTS.genesis_challenge.to_js()
}

0 comments on commit 19b30cf

Please sign in to comment.