CashScript / cashscript

⚖️ Easily write and interact with Bitcoin Cash smart contracts
https://cashscript.org
MIT License
111 stars 77 forks source link

is ContractOptions interface exposed / should it be? #165

Closed emergent-reasons closed 8 months ago

emergent-reasons commented 8 months ago

I mean this one in the constructor:

export declare class Contract {
    constructor(artifact: Artifact, constructorArgs: Argument[], options?: ContractOptions | undefined);
}
2qx commented 8 months ago

If this is the case, it (kinda) blocks passing the options through mainnet-js too...

https://github.com/mainnet-cash/mainnet-js/issues/188

emergent-reasons commented 8 months ago

Today I used patch-package to patch cashscript@0.9.1 for the project I'm working on.

Just needed the typing for ContractOptions. I was able to get it this way with Sahid's help:

ConstructorParameters<typeof Contract>[2]

but he also mentioned this tool for submitting an easy patch (maybe).

Here is the diff that solved my problem:

diff --git a/node_modules/cashscript/dist/index.d.ts b/node_modules/cashscript/dist/index.d.ts
index 4dc79b9..f95cb4a 100644
--- a/node_modules/cashscript/dist/index.d.ts
+++ b/node_modules/cashscript/dist/index.d.ts
@@ -6,6 +6,6 @@ export { TransactionBuilder } from './TransactionBuilder.js';
 export { Argument, encodeArgument } from './Argument.js';
 export { Artifact, AbiFunction, AbiInput } from '@cashscript/utils';
 export * as utils from '@cashscript/utils';
-export { Utxo, Recipient, SignatureAlgorithm, HashType, Network, isUtxoP2PKH, } from './interfaces.js';
+export { ContractOptions, Utxo, Recipient, SignatureAlgorithm, HashType, Network, isUtxoP2PKH, } from './interfaces.js';
 export * from './Errors.js';
 export { NetworkProvider, BitcoinRpcNetworkProvider, ElectrumNetworkProvider, FullStackNetworkProvider, } from './network/index.js';

This issue body was partially generated by patch-package.

rkalis commented 8 months ago

Yeah we should definitely export it. Thanks for opening the issue, looks like you were able to workaround it for now. So I think we'll release a new version with this fixed next Wednesday.

rkalis commented 8 months ago

We just exported this in v0.9.2.