Skip to content

Commit dfa7ea1

Browse files
committed
Final changes before 0.12 release
- Rename bitauthUri to getBitauthUri and update docs for it - Move around some utils - Add getVmResourceUsage to release notes and docs - Update docs for MockNetworkProvider default changes - Update libauth version in examples/
1 parent fac7543 commit dfa7ea1

File tree

19 files changed

+82
-53
lines changed

19 files changed

+82
-53
lines changed

examples/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"lint": "eslint . --ext .ts --ignore-path ../.eslintignore"
1212
},
1313
"dependencies": {
14-
"@bitauth/libauth": "^3.1.0-next.2",
14+
"@bitauth/libauth": "^3.1.0-next.8",
1515
"@types/node": "^22.17.0",
1616
"cashc": "^0.12.0",
1717
"cashscript": "^0.12.0",

examples/testing-suite/artifacts/example.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
},
4242
"compiler": {
4343
"name": "cashc",
44-
"version": "0.11.3"
44+
"version": "0.12.0"
4545
},
46-
"updatedAt": "2025-08-05T08:32:16.100Z"
46+
"updatedAt": "2025-10-02T09:56:11.510Z"
4747
}

examples/testing-suite/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"test": "NODE_OPTIONS='--experimental-vm-modules --no-warnings' jest"
2626
},
2727
"dependencies": {
28-
"@bitauth/libauth": "^3.1.0-next.2",
28+
"@bitauth/libauth": "^3.1.0-next.8",
2929
"cashc": "^0.12.0",
3030
"cashscript": "^0.12.0",
3131
"url-join": "^5.0.0"

packages/cashscript/src/TransactionBuilder.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,7 @@ export class TransactionBuilder {
247247
return vmResourceUsage;
248248
}
249249

250-
// TODO: rename to getBitauthUri()
251-
bitauthUri(): string {
250+
getBitauthUri(): string {
252251
console.warn('WARNING: it is unsafe to use this Bitauth URI when using real private keys as they are included in the transaction template');
253252
return getBitauthUri(this.getLibauthTemplate());
254253
}
@@ -273,7 +272,7 @@ export class TransactionBuilder {
273272
return raw ? await this.getTxDetails(txid, raw) : await this.getTxDetails(txid);
274273
} catch (e: any) {
275274
const reason = e.error ?? e.message;
276-
throw new FailedTransactionError(reason, this.bitauthUri());
275+
throw new FailedTransactionError(reason, this.getBitauthUri());
277276
}
278277
}
279278

packages/cashscript/src/libauth-template/LibauthTemplate.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ import {
3131
VmTarget,
3232
} from '../interfaces.js';
3333
import SignatureTemplate from '../SignatureTemplate.js';
34-
import { addressToLockScript, extendedStringify, getSignatureAndPubkeyFromP2PKHInput, zip } from '../utils.js';
34+
import { addressToLockScript, extendedStringify, zip } from '../utils.js';
3535
import { TransactionBuilder } from '../TransactionBuilder.js';
3636
import { deflate } from 'pako';
3737
import MockNetworkProvider from '../network/MockNetworkProvider.js';
38-
import { addHexPrefixExceptEmpty, formatBytecodeForDebugging, formatParametersForDebugging, getLockScriptName, getUnlockScriptName, lockingBytecodeIsSetToSlot, serialiseTokenDetails } from './utils.js';
38+
import { addHexPrefixExceptEmpty, formatBytecodeForDebugging, formatParametersForDebugging, getLockScriptName, getSignatureAndPubkeyFromP2PKHInput, getUnlockScriptName, lockingBytecodeIsSetToSlot, serialiseTokenDetails } from './utils.js';
3939

4040
// TODO: Add / improve descriptions throughout the template generation
4141

packages/cashscript/src/libauth-template/utils.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { AbiFunction, AbiInput, Artifact, bytecodeToScript, formatBitAuthScript } from '@cashscript/utils';
22
import { HashType, LibauthTokenDetails, SignatureAlgorithm, TokenDetails } from '../interfaces.js';
3-
import { hexToBin, binToHex, isHex, decodeCashAddress, type WalletTemplateScenarioBytecode } from '@bitauth/libauth';
3+
import { hexToBin, binToHex, isHex, decodeCashAddress, type WalletTemplateScenarioBytecode, Input, assertSuccess, decodeAuthenticationInstructions, AuthenticationInstructionPush } from '@bitauth/libauth';
44
import { EncodedFunctionArgument } from '../Argument.js';
55
import { zip } from '../utils.js';
66
import SignatureTemplate from '../SignatureTemplate.js';
@@ -112,3 +112,15 @@ interface LibauthTemplateTokenDetails {
112112
export const lockingBytecodeIsSetToSlot = (lockingBytecode?: WalletTemplateScenarioBytecode | ['slot']): boolean => {
113113
return Array.isArray(lockingBytecode) && lockingBytecode.length === 1 && lockingBytecode[0] === 'slot';
114114
};
115+
116+
export const getSignatureAndPubkeyFromP2PKHInput = (
117+
libauthInput: Input,
118+
): { signature: Uint8Array; publicKey: Uint8Array } => {
119+
const inputData = (assertSuccess(
120+
decodeAuthenticationInstructions(libauthInput.unlockingBytecode))
121+
) as AuthenticationInstructionPush[];
122+
const signature = inputData[0].data;
123+
const publicKey = inputData[1].data;
124+
125+
return { signature, publicKey };
126+
};

packages/cashscript/src/utils.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ import {
1414
bigIntToCompactUint,
1515
NonFungibleTokenCapability,
1616
bigIntToVmNumber,
17-
assertSuccess,
18-
AuthenticationInstructionPush,
19-
AuthenticationInstructions,
20-
decodeAuthenticationInstructions,
21-
Input,
2217
} from '@bitauth/libauth';
2318
import {
2419
encodeInt,
@@ -373,15 +368,3 @@ export const isFungibleTokenUtxo = (utxo: Utxo): boolean => (
373368
export const isNonTokenUtxo = (utxo: Utxo): boolean => utxo.token === undefined;
374369

375370
export const delay = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms));
376-
377-
export const getSignatureAndPubkeyFromP2PKHInput = (
378-
libauthInput: Input,
379-
): { signature: Uint8Array; publicKey: Uint8Array } => {
380-
const inputData = (assertSuccess(
381-
decodeAuthenticationInstructions(libauthInput.unlockingBytecode)) as AuthenticationInstructions
382-
) as AuthenticationInstructionPush[];
383-
const signature = inputData[0].data;
384-
const publicKey = inputData[1].data;
385-
386-
return { signature, publicKey };
387-
};

packages/cashscript/test/debugging-old-artifacts.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe('Debugging tests - old artifacts', () => {
3535
.addInput(contractUtxo, contractTestLogs.unlock.spend(alicePub, new SignatureTemplate(alicePriv)))
3636
.addOutput({ to: contractTestLogs.address, amount: 10000n });
3737

38-
console.warn(transaction.bitauthUri());
38+
console.warn(transaction.getBitauthUri());
3939

4040
expect(() => transaction.debug()).not.toThrow();
4141
});
@@ -50,7 +50,7 @@ describe('Debugging tests - old artifacts', () => {
5050
.addInput(contractUtxo, contractTestLogs.unlock.spend(alicePub, new SignatureTemplate(bobPriv)))
5151
.addOutput({ to: contractTestLogs.address, amount: 10000n });
5252

53-
console.warn(transaction.bitauthUri());
53+
console.warn(transaction.getBitauthUri());
5454

5555
expect(() => transaction.debug()).toThrow();
5656
});

packages/cashscript/test/e2e/MultiContract.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ describe('Multi Contract', () => {
8787
.addInput(bobAddressUtxos[0], bobSignatureTemplate.unlockP2PKH())
8888
.addOutput({ to, amount });
8989

90-
console.log(transaction.bitauthUri());
90+
console.log(transaction.getBitauthUri());
9191

9292
const txPromise = transaction.send();
9393

@@ -173,7 +173,7 @@ describe('Multi Contract', () => {
173173
.addInput(bobAddressUtxos[0], bobSignatureTemplate.unlockP2PKH())
174174
.addOutput({ to, amount });
175175

176-
console.log(transaction.bitauthUri());
176+
console.log(transaction.getBitauthUri());
177177

178178
const txPromise = transaction.send();
179179

packages/cashscript/test/libauth-template/LibauthTemplate.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ describe('Libauth Template generation tests (single-contract)', () => {
55
it(`should generate a valid libauth template for ${fixture.name}`, () => {
66
const generatedTemplate = fixture.transaction.getLibauthTemplate();
77
// console.warn(JSON.stringify(generatedTemplate, null, 2));
8-
// console.warn(fixture.transaction.bitauthUri());
8+
// console.warn(fixture.transaction.getBitauthUri());
99
expect(generatedTemplate).toEqual(fixture.template);
1010
});
1111
});

0 commit comments

Comments
 (0)