cashscript 0.11.1 → 0.11.2
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.
|
@@ -143,18 +143,14 @@ export class TransactionBuilder {
|
|
|
143
143
|
throw new Error('Could not retrieve transaction details for over 10 minutes');
|
|
144
144
|
}
|
|
145
145
|
generateWcTransactionObject(options) {
|
|
146
|
-
const inputs = this.inputs;
|
|
147
|
-
if (!inputs.every(input => isStandardUnlockableUtxo(input))) {
|
|
148
|
-
throw new Error('All inputs must be StandardUnlockableUtxos to generate the wcSourceOutputs');
|
|
149
|
-
}
|
|
150
146
|
const encodedTransaction = this.build();
|
|
151
147
|
const transaction = decodeTransactionUnsafe(hexToBin(encodedTransaction));
|
|
152
|
-
const libauthSourceOutputs = generateLibauthSourceOutputs(inputs);
|
|
148
|
+
const libauthSourceOutputs = generateLibauthSourceOutputs(this.inputs);
|
|
153
149
|
const sourceOutputs = libauthSourceOutputs.map((sourceOutput, index) => {
|
|
154
150
|
return {
|
|
155
151
|
...sourceOutput,
|
|
156
152
|
...transaction.inputs[index],
|
|
157
|
-
...getWcContractInfo(inputs[index]),
|
|
153
|
+
...getWcContractInfo(this.inputs[index]),
|
|
158
154
|
};
|
|
159
155
|
});
|
|
160
156
|
return { ...options, transaction, sourceOutputs };
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -40,9 +40,13 @@ export interface P2PKHUnlocker extends Unlocker {
|
|
|
40
40
|
template: SignatureTemplate;
|
|
41
41
|
}
|
|
42
42
|
export type StandardUnlocker = ContractUnlocker | P2PKHUnlocker;
|
|
43
|
+
export type PlaceholderP2PKHUnlocker = Unlocker & {
|
|
44
|
+
placeholder: true;
|
|
45
|
+
};
|
|
43
46
|
export declare function isContractUnlocker(unlocker: Unlocker): unlocker is ContractUnlocker;
|
|
44
47
|
export declare function isP2PKHUnlocker(unlocker: Unlocker): unlocker is P2PKHUnlocker;
|
|
45
48
|
export declare function isStandardUnlocker(unlocker: Unlocker): unlocker is StandardUnlocker;
|
|
49
|
+
export declare function isPlaceholderUnlocker(unlocker: Unlocker): unlocker is PlaceholderP2PKHUnlocker;
|
|
46
50
|
export interface UtxoP2PKH extends Utxo {
|
|
47
51
|
template: SignatureTemplate;
|
|
48
52
|
}
|
package/dist/interfaces.js
CHANGED
|
@@ -13,6 +13,9 @@ export function isP2PKHUnlocker(unlocker) {
|
|
|
13
13
|
export function isStandardUnlocker(unlocker) {
|
|
14
14
|
return isContractUnlocker(unlocker) || isP2PKHUnlocker(unlocker);
|
|
15
15
|
}
|
|
16
|
+
export function isPlaceholderUnlocker(unlocker) {
|
|
17
|
+
return 'placeholder' in unlocker;
|
|
18
|
+
}
|
|
16
19
|
export function isUtxoP2PKH(utxo) {
|
|
17
20
|
return 'template' in utxo;
|
|
18
21
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type LibauthOutput, type PlaceholderP2PKHUnlocker, type UnlockableUtxo } from './interfaces.js';
|
|
2
2
|
import { type AbiFunction, type Artifact } from '@cashscript/utils';
|
|
3
3
|
import { type Input, type TransactionCommon } from '@bitauth/libauth';
|
|
4
4
|
export interface WcTransactionOptions {
|
|
@@ -6,7 +6,7 @@ export interface WcTransactionOptions {
|
|
|
6
6
|
userPrompt?: string;
|
|
7
7
|
}
|
|
8
8
|
export interface WcTransactionObject {
|
|
9
|
-
transaction: TransactionCommon
|
|
9
|
+
transaction: TransactionCommon;
|
|
10
10
|
sourceOutputs: WcSourceOutput[];
|
|
11
11
|
broadcast?: boolean;
|
|
12
12
|
userPrompt?: string;
|
|
@@ -19,7 +19,7 @@ export interface WcContractInfo {
|
|
|
19
19
|
artifact: Partial<Artifact>;
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
export declare function getWcContractInfo(input:
|
|
22
|
+
export declare function getWcContractInfo(input: UnlockableUtxo): WcContractInfo | {};
|
|
23
23
|
export declare const placeholderSignature: () => Uint8Array;
|
|
24
24
|
export declare const placeholderPublicKey: () => Uint8Array;
|
|
25
|
-
export declare const placeholderP2PKHUnlocker: (userAddress: string) =>
|
|
25
|
+
export declare const placeholderP2PKHUnlocker: (userAddress: string) => PlaceholderP2PKHUnlocker;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { isContractUnlocker } from './interfaces.js';
|
|
1
2
|
import { scriptToBytecode } from '@cashscript/utils';
|
|
2
3
|
import { cashAddressToLockingBytecode } from '@bitauth/libauth';
|
|
3
4
|
export function getWcContractInfo(input) {
|
|
4
5
|
// If the input does not have a contract unlocker, return an empty object
|
|
5
|
-
if (!(
|
|
6
|
+
if (!(isContractUnlocker(input.unlocker)))
|
|
6
7
|
return {};
|
|
7
8
|
const contract = input.unlocker.contract;
|
|
8
9
|
const abiFunctionName = input.unlocker.abiFunction?.name;
|
|
@@ -30,6 +31,7 @@ export const placeholderP2PKHUnlocker = (userAddress) => {
|
|
|
30
31
|
return {
|
|
31
32
|
generateLockingBytecode: () => lockingBytecode,
|
|
32
33
|
generateUnlockingBytecode: () => Uint8Array.from(Array(0)),
|
|
34
|
+
placeholder: true,
|
|
33
35
|
};
|
|
34
36
|
};
|
|
35
37
|
//# sourceMappingURL=walletconnect-utils.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cashscript",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.2",
|
|
4
4
|
"description": "Easily write and interact with Bitcoin Cash contracts",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bitcoin cash",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@bitauth/libauth": "^3.1.0-next.2",
|
|
49
|
-
"@cashscript/utils": "^0.11.
|
|
49
|
+
"@cashscript/utils": "^0.11.2",
|
|
50
50
|
"@electrum-cash/network": "^4.1.1",
|
|
51
51
|
"@mr-zwets/bchn-api-wrapper": "^1.0.1",
|
|
52
52
|
"delay": "^6.0.0",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"jest": "^29.7.0",
|
|
64
64
|
"typescript": "^5.7.3"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "81e7dc182ef71909af721d62751ef403bcfcc41e"
|
|
67
67
|
}
|