cashscript 0.8.0-next.4 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -179,13 +179,13 @@ export class Transaction {
179
179
  throw Error('Attempted to build a transaction without outputs');
180
180
  }
181
181
  const allUtxos = await this.provider.getUtxos(this.address);
182
- const manualTokenInputs = this.inputs.filter((input) => input.token);
183
- // This will throw if the amount is not enough
184
- if (manualTokenInputs.length > 0) {
185
- selectAllTokenUtxos(manualTokenInputs, this.outputs);
182
+ const tokenInputs = this.inputs.length > 0
183
+ ? this.inputs.filter((input) => input.token)
184
+ : selectAllTokenUtxos(allUtxos, this.outputs);
185
+ // This throws if the manually selected inputs are not enough to cover the outputs
186
+ if (this.inputs.length > 0) {
187
+ selectAllTokenUtxos(this.inputs, this.outputs);
186
188
  }
187
- const automaticTokenInputs = selectAllTokenUtxos(allUtxos, this.outputs);
188
- const tokenInputs = manualTokenInputs.length > 0 ? manualTokenInputs : automaticTokenInputs;
189
189
  if (this.tokenChange) {
190
190
  const tokenChangeOutputs = createFungibleTokenChangeOutputs(tokenInputs, this.outputs, this.address);
191
191
  this.outputs.push(...tokenChangeOutputs);
@@ -304,7 +304,7 @@ export class Transaction {
304
304
  // even if they report UTXOs in a different order
305
305
  bchUtxos.sort(utxoComparator).reverse();
306
306
  // Add all automatically added token inputs to the transaction
307
- for (const utxo of automaticTokenInputs) {
307
+ for (const utxo of tokenInputs) {
308
308
  this.inputs.push(utxo);
309
309
  satsAvailable += addPrecision(utxo.satoshis);
310
310
  if (!this.hardcodedFee)
package/dist/index.d.ts CHANGED
@@ -2,9 +2,9 @@ import SignatureTemplate from './SignatureTemplate.js';
2
2
  export { SignatureTemplate };
3
3
  export { Contract, ContractFunction } from './Contract.js';
4
4
  export { Transaction } from './Transaction.js';
5
- export { Argument } from './Argument.js';
5
+ export { Argument, encodeArgument } from './Argument.js';
6
6
  export { Artifact, AbiFunction, AbiInput } from '@cashscript/utils';
7
7
  export * as utils from '@cashscript/utils';
8
- export { Utxo, Recipient, SignatureAlgorithm, HashType, Network, } from './interfaces.js';
8
+ export { Utxo, Recipient, SignatureAlgorithm, HashType, Network, isSignableUtxo, } from './interfaces.js';
9
9
  export * from './Errors.js';
10
10
  export { NetworkProvider, BitcoinRpcNetworkProvider, ElectrumNetworkProvider, FullStackNetworkProvider, } from './network/index.js';
package/dist/index.js CHANGED
@@ -2,8 +2,9 @@ import SignatureTemplate from './SignatureTemplate.js';
2
2
  export { SignatureTemplate };
3
3
  export { Contract } from './Contract.js';
4
4
  export { Transaction } from './Transaction.js';
5
+ export { encodeArgument } from './Argument.js';
5
6
  export * as utils from '@cashscript/utils';
6
- export { SignatureAlgorithm, HashType, Network, } from './interfaces.js';
7
+ export { SignatureAlgorithm, HashType, Network, isSignableUtxo, } from './interfaces.js';
7
8
  export * from './Errors.js';
8
9
  export { BitcoinRpcNetworkProvider, ElectrumNetworkProvider, FullStackNetworkProvider, } from './network/index.js';
9
10
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cashscript",
3
- "version": "0.8.0-next.4",
3
+ "version": "0.8.0",
4
4
  "description": "Easily write and interact with Bitcoin Cash contracts",
5
5
  "keywords": [
6
6
  "bitcoin cash",
@@ -44,7 +44,7 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@bitauth/libauth": "^2.0.0-alpha.8",
47
- "@cashscript/utils": "^0.8.0-next.4",
47
+ "@cashscript/utils": "^0.8.0",
48
48
  "bip68": "^1.0.4",
49
49
  "bitcoin-rpc-promise-retry": "^1.3.0",
50
50
  "delay": "^5.0.0",
@@ -58,5 +58,5 @@
58
58
  "jest": "^29.4.1",
59
59
  "typescript": "^4.1.5"
60
60
  },
61
- "gitHead": "f4c3f9c21cca98465e5cad919e64b4c6292e9a1f"
61
+ "gitHead": "9864e23e5b7eb024cf4712a785a5a3fe09d6eee5"
62
62
  }