Skip to content

Commit 38193ac

Browse files
committed
Fix typings and update .artifact.ts fixtures
1 parent d899365 commit 38193ac

22 files changed

+386
-35
lines changed

packages/cashscript/test/fixture/announcement.artifact.ts

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,33 @@ export default {
88
},
99
],
1010
bytecode: '6a 6d02 OP_SIZE OP_SWAP OP_CAT OP_CAT 4120636f6e7472616374206d6179206e6f7420696e6a75726520612068756d616e206265696e67206f722c207468726f75676820696e616374696f6e2c20616c6c6f7720612068756d616e206265696e6720746f20636f6d6520746f206861726d2e OP_SIZE OP_DUP 4b OP_GREATERTHAN OP_IF 4c OP_SWAP OP_CAT OP_ENDIF OP_SWAP OP_CAT OP_CAT OP_0 OP_OUTPUTVALUE OP_0 OP_NUMEQUALVERIFY OP_0 OP_OUTPUTBYTECODE OP_EQUALVERIFY e803 OP_INPUTINDEX OP_UTXOVALUE OP_OVER OP_SUB OP_DUP OP_ROT OP_GREATERTHANOREQUAL OP_IF OP_1 OP_OUTPUTBYTECODE OP_INPUTINDEX OP_UTXOBYTECODE OP_EQUALVERIFY OP_1 OP_OUTPUTVALUE OP_OVER OP_NUMEQUALVERIFY OP_ENDIF OP_DROP OP_1',
11-
source: 'pragma cashscript ^0.9.0;\n\n/* This is a contract showcasing covenants outside of regular transactional use.\n * It enforces the contract to make an "announcement" on Memo.cash, and send the\n * remainder of contract funds back to the contract.\n */\ncontract Announcement() {\n function announce() {\n // Create the memo.cash announcement output\n bytes announcement = new LockingBytecodeNullData([\n 0x6d02,\n bytes(\'A contract may not injure a human being or, through inaction, allow a human being to come to harm.\')\n ]);\n\n // Check that the first tx output matches the announcement\n require(tx.outputs[0].value == 0);\n require(tx.outputs[0].lockingBytecode == announcement);\n\n // Calculate leftover money after fee (1000 sats)\n // Check that the second tx output sends the change back if there\'s enough leftover for another announcement\n int minerFee = 1000;\n int changeAmount = tx.inputs[this.activeInputIndex].value - minerFee;\n if (changeAmount >= minerFee) {\n require(tx.outputs[1].lockingBytecode == tx.inputs[this.activeInputIndex].lockingBytecode);\n require(tx.outputs[1].value == changeAmount);\n }\n }\n}\n',
11+
source: 'pragma cashscript >=0.8.0;\n\n/* This is a contract showcasing covenants outside of regular transactional use.\n * It enforces the contract to make an \'announcement\' on Memo.cash, and send the\n * remainder of contract funds back to the contract.\n */\ncontract Announcement() {\n function announce() {\n // Create the memo.cash announcement output\n bytes announcement = new LockingBytecodeNullData([\n 0x6d02,\n bytes(\'A contract may not injure a human being or, through inaction, allow a human being to come to harm.\')\n ]);\n\n // Check that the first tx output matches the announcement\n require(tx.outputs[0].value == 0);\n require(tx.outputs[0].lockingBytecode == announcement);\n\n // Calculate leftover money after fee (1000 sats)\n // Check that the second tx output sends the change back if there\'s enough leftover for another announcement\n int minerFee = 1000;\n int changeAmount = tx.inputs[this.activeInputIndex].value - minerFee;\n if (changeAmount >= minerFee) {\n require(tx.outputs[1].lockingBytecode == tx.inputs[this.activeInputIndex].lockingBytecode);\n require(tx.outputs[1].value == changeAmount);\n }\n }\n}\n',
12+
debug: {
13+
bytecode: '016a026d02827c7e7e4c624120636f6e7472616374206d6179206e6f7420696e6a75726520612068756d616e206265696e67206f722c207468726f75676820696e616374696f6e2c20616c6c6f7720612068756d616e206265696e6720746f20636f6d6520746f206861726d2e8276014ba063014c7c7e687c7e7e00cc009c6900cd517a876902e803c0c65179940079527aa26351cdc0c7876951cc51799c69685177',
14+
sourceMap: '10:29:13:10;11:12:11:18;::::1;;;;12:18:12:118:0;:12::119:1;;;;;;;;;;;;16:27:16:28:0;:16::35:1;:39::40:0;:16:::1;:8::42;17:27:17:28:0;:16::45:1;:49::61:0;;:16:::1;:8::63;21:23:21:27:0;22:37:22:58;:27::65:1;:68::76:0;;:27:::1;23:12:23:24:0;;:28::36;;:12:::1;:38:26:9:0;24:31:24:32;:20::49:1;:63::84:0;:53::101:1;:20;:12::103;25:31:25:32:0;:20::39:1;:43::55:0;;:20:::1;:12::57;23:38:26:9;8:4:27:5;',
15+
logs: [],
16+
requires: [
17+
{
18+
ip: 23,
19+
line: 16,
20+
},
21+
{
22+
ip: 29,
23+
line: 17,
24+
},
25+
{
26+
ip: 47,
27+
line: 24,
28+
},
29+
{
30+
ip: 53,
31+
line: 25,
32+
},
33+
],
34+
},
1235
compiler: {
1336
name: 'cashc',
14-
version: '0.8.0-next.0',
37+
version: '0.10.4',
1538
},
16-
updatedAt: '2023-02-10T15:22:49.703Z',
39+
updatedAt: '2024-12-03T13:57:07.764Z',
1740
} as const;

packages/cashscript/test/fixture/announcement.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
},
3535
"compiler": {
3636
"name": "cashc",
37-
"version": "0.10.0"
37+
"version": "0.10.4"
3838
},
39-
"updatedAt": "2024-09-10T09:54:01.248Z"
39+
"updatedAt": "2024-12-03T13:57:07.512Z"
4040
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
export default {
2+
contractName: 'BigInt',
3+
constructorInputs: [],
4+
abi: [
5+
{
6+
name: 'proofOfBigInt',
7+
inputs: [
8+
{
9+
name: 'x',
10+
type: 'int',
11+
},
12+
{
13+
name: 'y',
14+
type: 'int',
15+
},
16+
],
17+
},
18+
],
19+
bytecode: '0000008000 OP_2DUP OP_GREATERTHANOREQUAL OP_VERIFY OP_SWAP OP_ROT OP_MUL OP_LESSTHANOREQUAL',
20+
source: 'contract BigInt() {\n function proofOfBigInt(int x, int y) {\n int maxInt32PlusOne = 2147483648;\n require(x >= maxInt32PlusOne);\n require(x * y >= maxInt32PlusOne);\n }\n}\n',
21+
debug: {
22+
bytecode: '05000000800051795179a269517a527a95517aa2',
23+
sourceMap: '3:30:3:40;4:16:4:17;;:21::36;;:16:::1;:8::38;5:16:5:17:0;;:20::21;;:16:::1;:25::40:0;;:16:::1',
24+
logs: [],
25+
requires: [
26+
{
27+
ip: 6,
28+
line: 4,
29+
},
30+
{
31+
ip: 15,
32+
line: 5,
33+
},
34+
],
35+
},
36+
compiler: {
37+
name: 'cashc',
38+
version: '0.10.4',
39+
},
40+
updatedAt: '2024-12-03T13:57:07.265Z',
41+
} as const;

packages/cashscript/test/fixture/bigint.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
},
3636
"compiler": {
3737
"name": "cashc",
38-
"version": "0.10.0"
38+
"version": "0.10.4"
3939
},
40-
"updatedAt": "2024-09-10T09:54:00.989Z"
40+
"updatedAt": "2024-12-03T13:57:06.999Z"
4141
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
export default {
2+
contractName: 'BoundedBytes',
3+
constructorInputs: [],
4+
abi: [
5+
{
6+
name: 'spend',
7+
inputs: [
8+
{
9+
name: 'b',
10+
type: 'bytes4',
11+
},
12+
{
13+
name: 'i',
14+
type: 'int',
15+
},
16+
],
17+
},
18+
],
19+
bytecode: 'OP_SWAP OP_4 OP_NUM2BIN OP_EQUAL',
20+
source: 'contract BoundedBytes() {\n function spend(bytes4 b, int i) {\n require(b == bytes4(i));\n }\n}\n',
21+
debug: {
22+
bytecode: '007a517a548087',
23+
sourceMap: '3:16:3:17;;:28::29;;:21::30:1;;:16',
24+
logs: [],
25+
requires: [
26+
{
27+
ip: 7,
28+
line: 3,
29+
},
30+
],
31+
},
32+
compiler: {
33+
name: 'cashc',
34+
version: '0.10.4',
35+
},
36+
updatedAt: '2024-12-03T13:57:09.177Z',
37+
} as const;

packages/cashscript/test/fixture/bounded_bytes.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
},
3232
"compiler": {
3333
"name": "cashc",
34-
"version": "0.10.0"
34+
"version": "0.10.4"
3535
},
36-
"updatedAt": "2024-09-10T09:54:01.995Z"
36+
"updatedAt": "2024-12-03T13:57:08.944Z"
3737
}

packages/cashscript/test/fixture/hodl_vault.artifact.ts

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,36 @@ export default {
3939
],
4040
bytecode: 'OP_6 OP_PICK OP_4 OP_SPLIT OP_SWAP OP_BIN2NUM OP_SWAP OP_BIN2NUM OP_OVER OP_5 OP_ROLL OP_GREATERTHANOREQUAL OP_VERIFY OP_SWAP OP_CHECKLOCKTIMEVERIFY OP_DROP OP_3 OP_ROLL OP_GREATERTHANOREQUAL OP_VERIFY OP_3 OP_ROLL OP_4 OP_ROLL OP_3 OP_ROLL OP_CHECKDATASIGVERIFY OP_CHECKSIG',
4141
source: '// This contract forces HODLing until a certain price target has been reached\n// A minimum block is provided to ensure that oracle price entries from before this block are disregarded\n// i.e. when the BCH price was $1000 in the past, an oracle entry with the old block number and price can not be used.\n// Instead, a message with a block number and price from after the minBlock needs to be passed.\n// This contract serves as a simple example for checkDataSig-based contracts.\ncontract HodlVault(\n pubkey ownerPk,\n pubkey oraclePk,\n int minBlock,\n int priceTarget\n) {\n function spend(sig ownerSig, datasig oracleSig, bytes8 oracleMessage) {\n // message: { blockHeight, price }\n bytes4 blockHeightBin, bytes4 priceBin = oracleMessage.split(4);\n int blockHeight = int(blockHeightBin);\n int price = int(priceBin);\n\n // Check that blockHeight is after minBlock and not in the future\n require(blockHeight >= minBlock);\n require(tx.time >= blockHeight);\n\n // Check that current price is at least priceTarget\n require(price >= priceTarget);\n\n // Handle necessary signature checks\n require(checkDataSig(oracleSig, oracleMessage, oraclePk));\n require(checkSig(ownerSig, ownerPk));\n }\n}\n',
42+
debug: {
43+
bytecode: '5679547f517a81517a815179557aa269517ab175007a537aa269537a547a537aba69517a517aac',
44+
sourceMap: '14:49:14:62;;:69::70;:49::71:1;15:30:15:44:0;;:26::45:1;16:24:16:32:0;;:20::33:1;19:16:19:27:0;;:31::39;;:16:::1;:8::41;20:27:20:38:0;;:8::40:1;;23:16:23:21:0;;:25::36;;:16:::1;:8::38;26:29:26::0;;:40::53;;:55::63;;:16::64:1;:8::66;27:25:27:33:0;;:35::42;;:16::43:1',
45+
logs: [],
46+
requires: [
47+
{
48+
ip: 19,
49+
line: 19,
50+
},
51+
{
52+
ip: 22,
53+
line: 20,
54+
},
55+
{
56+
ip: 29,
57+
line: 23,
58+
},
59+
{
60+
ip: 37,
61+
line: 26,
62+
},
63+
{
64+
ip: 43,
65+
line: 27,
66+
},
67+
],
68+
},
4269
compiler: {
4370
name: 'cashc',
44-
version: '0.8.0-next.0',
71+
version: '0.10.4',
4572
},
46-
updatedAt: '2023-02-10T15:22:49.985Z',
73+
updatedAt: '2024-12-03T13:57:08.243Z',
4774
} as const;

packages/cashscript/test/fixture/hodl_vault.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
},
6969
"compiler": {
7070
"name": "cashc",
71-
"version": "0.10.0"
71+
"version": "0.10.4"
7272
},
73-
"updatedAt": "2024-09-10T09:54:01.493Z"
73+
"updatedAt": "2024-12-03T13:57:07.996Z"
7474
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
export default {
2+
contractName: 'Mecenas',
3+
constructorInputs: [
4+
{
5+
name: 'recipient',
6+
type: 'bytes20',
7+
},
8+
{
9+
name: 'funder',
10+
type: 'bytes20',
11+
},
12+
{
13+
name: 'pledge',
14+
type: 'int',
15+
},
16+
],
17+
abi: [
18+
{
19+
name: 'receive',
20+
inputs: [],
21+
},
22+
{
23+
name: 'reclaim',
24+
inputs: [
25+
{
26+
name: 'pk',
27+
type: 'pubkey',
28+
},
29+
{
30+
name: 's',
31+
type: 'sig',
32+
},
33+
],
34+
},
35+
],
36+
bytecode: 'OP_3 OP_PICK OP_0 OP_NUMEQUAL OP_IF OP_0 OP_OUTPUTBYTECODE 76a914 OP_ROT OP_CAT 88ac OP_CAT OP_EQUALVERIFY e803 OP_INPUTINDEX OP_UTXOVALUE OP_DUP OP_4 OP_PICK OP_SUB OP_2 OP_PICK OP_SUB OP_DUP OP_5 OP_PICK OP_4 OP_PICK OP_ADD OP_LESSTHANOREQUAL OP_IF OP_0 OP_OUTPUTVALUE OP_2OVER OP_SWAP OP_SUB OP_NUMEQUALVERIFY OP_ELSE OP_0 OP_OUTPUTVALUE OP_5 OP_PICK OP_NUMEQUALVERIFY OP_1 OP_OUTPUTBYTECODE OP_INPUTINDEX OP_UTXOBYTECODE OP_EQUALVERIFY OP_1 OP_OUTPUTVALUE OP_OVER OP_NUMEQUALVERIFY OP_ENDIF OP_2DROP OP_2DROP OP_2DROP OP_1 OP_ELSE OP_3 OP_ROLL OP_1 OP_NUMEQUALVERIFY OP_3 OP_PICK OP_HASH160 OP_ROT OP_EQUALVERIFY OP_2SWAP OP_CHECKSIG OP_NIP OP_NIP OP_ENDIF',
37+
source: 'pragma cashscript >=0.8.0;\n\n/* This is an unofficial CashScript port of Licho\'s Mecenas contract. It is\n * not compatible with Licho\'s EC plugin, but rather meant as a demonstration\n * of covenants in CashScript.\n * The time checking has been removed so it can be tested without time requirements.\n */\ncontract Mecenas(bytes20 recipient, bytes20 funder, int pledge/*, int period */) {\n function receive() {\n // require(tx.age >= period);\n\n // Check that the first output sends to the recipient\n require(tx.outputs[0].lockingBytecode == new LockingBytecodeP2PKH(recipient));\n\n int minerFee = 1000;\n int currentValue = tx.inputs[this.activeInputIndex].value;\n int changeValue = currentValue - pledge - minerFee;\n\n // If there is not enough left for *another* pledge after this one, we send the remainder to the recipient\n // Otherwise we send the remainder to the recipient and the change back to the contract\n if (changeValue <= pledge + minerFee) {\n require(tx.outputs[0].value == currentValue - minerFee);\n } else {\n require(tx.outputs[0].value == pledge);\n require(tx.outputs[1].lockingBytecode == tx.inputs[this.activeInputIndex].lockingBytecode);\n require(tx.outputs[1].value == changeValue);\n }\n }\n\n function reclaim(pubkey pk, sig s) {\n require(hash160(pk) == funder);\n require(checkSig(s, pk));\n }\n}\n',
38+
debug: {
39+
bytecode: '5379009c6300cd0376a914527a7e0288ac7e876902e803c0c6007954799452799400795579547993a16300cc52795479949c696700cc55799c6951cdc0c7876951cc51799c69685177777777777767537a519c695379a9527a8769537a537aac777768',
40+
sourceMap: '9:4:28:5;;;;;13:27:13:28;:16::45:1;:49::84:0;:74::83;;:49::84:1;;;:16;:8::86;15:23:15:27:0;16:37:16:58;:27::65:1;17:26:17:38:0;;:41::47;;:26:::1;:50::58:0;;:26:::1;21:12:21:23:0;;:27::33;;:36::44;;:27:::1;:12;:46:23:9:0;22:31:22:32;:20::39:1;:43::55:0;;:58::66;;:43:::1;:20;:12::68;23:15:27:9:0;24:31:24:32;:20::39:1;:43::49:0;;:20:::1;:12::51;25:31:25:32:0;:20::49:1;:63::84:0;:53::101:1;:20;:12::103;26:31:26:32:0;:20::39:1;:43::54:0;;:20:::1;:12::56;23:15:27:9;9:4:28:5;;;;;;;;30::33::0;;;;;31:24:31:26;;:16::27:1;:31::37:0;;:16:::1;:8::39;32:25:32:26:0;;:28::30;;:16::31:1;30:4:33:5;;8:0:34:1',
41+
logs: [],
42+
requires: [
43+
{
44+
ip: 17,
45+
line: 13,
46+
},
47+
{
48+
ip: 46,
49+
line: 22,
50+
},
51+
{
52+
ip: 53,
53+
line: 24,
54+
},
55+
{
56+
ip: 59,
57+
line: 25,
58+
},
59+
{
60+
ip: 65,
61+
line: 26,
62+
},
63+
{
64+
ip: 86,
65+
line: 31,
66+
},
67+
{
68+
ip: 92,
69+
line: 32,
70+
},
71+
],
72+
},
73+
compiler: {
74+
name: 'cashc',
75+
version: '0.10.4',
76+
},
77+
updatedAt: '2024-12-03T13:57:11.555Z',
78+
} as const;

packages/cashscript/test/fixture/mecenas.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
},
7373
"compiler": {
7474
"name": "cashc",
75-
"version": "0.10.0"
75+
"version": "0.10.4"
7676
},
77-
"updatedAt": "2024-09-10T09:54:03.279Z"
77+
"updatedAt": "2024-12-03T13:57:11.304Z"
7878
}

0 commit comments

Comments
 (0)