@opcat-labs/scrypt-ts-opcat 2.0.1-beta-4e9e00a1-20251208 → 2.0.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.
- package/assets/.templates/smart-contract/builtin-libs/p2pk.scrypt.map +1 -1
- package/assets/.templates/smart-contract/builtin-libs/p2pk.scrypt.tpl +0 -3
- package/assets/.templates/smart-contract/builtin-libs/p2pkh.scrypt.map +1 -1
- package/assets/.templates/smart-contract/builtin-libs/p2pkh.scrypt.tpl +0 -3
- package/assets/smart-contract/builtin-libs/backtrace.scrypt +12 -12
- package/assets/smart-contract/builtin-libs/byteStringReader.scrypt +5 -5
- package/assets/smart-contract/builtin-libs/byteStringWriter.scrypt +6 -6
- package/assets/smart-contract/builtin-libs/contextUtils.scrypt +16 -16
- package/assets/smart-contract/builtin-libs/p2pk.scrypt +1 -4
- package/assets/smart-contract/builtin-libs/p2pkh.scrypt +1 -4
- package/assets/smart-contract/builtin-libs/stateLib.scrypt +1 -1
- package/assets/smart-contract/builtin-libs/stateUtils.scrypt +1 -1
- package/assets/smart-contract/builtin-libs/stdUtils.scrypt +12 -12
- package/assets/smart-contract/builtin-libs/txHashPreimageUtils.scrypt +7 -7
- package/assets/smart-contract/builtin-libs/txUtils.scrypt +12 -12
- package/assets/smart-contract/types/structs.scrypt +8 -8
- package/dist/cjs/providers/dummyProvider.cjs +0 -10
- package/dist/cjs/providers/dummyProvider.js.map +1 -1
- package/dist/cjs/providers/mempoolProvider.cjs +0 -44
- package/dist/cjs/providers/mempoolProvider.js.map +1 -1
- package/dist/cjs/providers/rpcProvider.cjs +3 -46
- package/dist/cjs/providers/rpcProvider.js.map +1 -1
- package/dist/cjs/psbt/extPsbt.cjs +1 -8
- package/dist/cjs/psbt/extPsbt.js.map +1 -1
- package/dist/cjs/psbt/psbt.cjs +1 -3
- package/dist/cjs/psbt/psbt.js.map +1 -1
- package/dist/cjs/smart-contract/builtin-libs/index.cjs +1 -5
- package/dist/cjs/smart-contract/builtin-libs/index.js.map +1 -1
- package/dist/cjs/smart-contract/smartContract.cjs +0 -22
- package/dist/cjs/smart-contract/smartContract.js.map +1 -1
- package/dist/esm/providers/dummyProvider.js +0 -10
- package/dist/esm/providers/dummyProvider.js.map +1 -1
- package/dist/esm/providers/mempoolProvider.js +0 -44
- package/dist/esm/providers/mempoolProvider.js.map +1 -1
- package/dist/esm/providers/rpcProvider.js +2 -45
- package/dist/esm/providers/rpcProvider.js.map +1 -1
- package/dist/esm/psbt/extPsbt.js +1 -8
- package/dist/esm/psbt/extPsbt.js.map +1 -1
- package/dist/esm/psbt/psbt.js +1 -3
- package/dist/esm/psbt/psbt.js.map +1 -1
- package/dist/esm/smart-contract/builtin-libs/index.js +0 -1
- package/dist/esm/smart-contract/builtin-libs/index.js.map +1 -1
- package/dist/esm/smart-contract/smartContract.js +1 -23
- package/dist/esm/smart-contract/smartContract.js.map +1 -1
- package/dist/types/providers/chainProvider.d.ts +0 -12
- package/dist/types/providers/chainProvider.d.ts.map +1 -1
- package/dist/types/providers/dummyProvider.d.ts +2 -4
- package/dist/types/providers/dummyProvider.d.ts.map +1 -1
- package/dist/types/providers/mempoolProvider.d.ts +2 -4
- package/dist/types/providers/mempoolProvider.d.ts.map +1 -1
- package/dist/types/providers/rpcProvider.d.ts +2 -4
- package/dist/types/providers/rpcProvider.d.ts.map +1 -1
- package/dist/types/psbt/extPsbt.d.ts.map +1 -1
- package/dist/types/psbt/psbt.d.ts.map +1 -1
- package/dist/types/smart-contract/builtin-libs/index.d.ts +0 -1
- package/dist/types/smart-contract/builtin-libs/index.d.ts.map +1 -1
- package/dist/types/smart-contract/smartContract.d.ts +0 -20
- package/dist/types/smart-contract/smartContract.d.ts.map +1 -1
- package/package.json +3 -4
- package/scrypt.index.json +0 -4
- package/src/smart-contract/builtin-libs/index.ts +1 -2
- package/assets/.templates/smart-contract/builtin-libs/genesis.scrypt.map +0 -1
- package/assets/.templates/smart-contract/builtin-libs/genesis.scrypt.tpl +0 -32
- package/assets/.templates/smart-contract/builtin-libs/genesis.transformer.json +0 -9
- package/assets/smart-contract/builtin-libs/genesis.scrypt +0 -34
- package/dist/cjs/smart-contract/builtin-libs/genesis.cjs +0 -201
- package/dist/cjs/smart-contract/builtin-libs/genesis.js.map +0 -1
- package/dist/esm/smart-contract/builtin-libs/genesis.js +0 -197
- package/dist/esm/smart-contract/builtin-libs/genesis.js.map +0 -1
- package/dist/types/smart-contract/builtin-libs/genesis.d.ts +0 -67
- package/dist/types/smart-contract/builtin-libs/genesis.d.ts.map +0 -1
- package/src/smart-contract/builtin-libs/genesis.ts +0 -203
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.genesisCheckDeploy = exports.Genesis = exports.MAX_GENESIS_CHECK_OUTPUT = void 0;
|
|
13
|
-
const smartContract_js_1 = require('../smartContract.cjs');
|
|
14
|
-
const decorators_js_1 = require('../decorators.cjs');
|
|
15
|
-
const index_js_1 = require('../fns/index.cjs');
|
|
16
|
-
const txUtils_js_1 = require('./txUtils.cjs');
|
|
17
|
-
const common_js_1 = require('../../utils/common.cjs');
|
|
18
|
-
/**
|
|
19
|
-
* Maximum number of outputs to check during genesis deployment
|
|
20
|
-
*/
|
|
21
|
-
exports.MAX_GENESIS_CHECK_OUTPUT = 3;
|
|
22
|
-
/**
|
|
23
|
-
* Genesis contract for validating initial deployment outputs.
|
|
24
|
-
*
|
|
25
|
-
* This contract ensures that during deployment, all non-empty outputs have
|
|
26
|
-
* distinct script hashes, preventing duplicate deployments to the same address.
|
|
27
|
-
* Empty scriptHashes (represented by empty ByteString) are treated as placeholders
|
|
28
|
-
* and are not validated for uniqueness.
|
|
29
|
-
*
|
|
30
|
-
* @category Contract
|
|
31
|
-
* @category Genesis
|
|
32
|
-
* @onchain
|
|
33
|
-
*/
|
|
34
|
-
let Genesis = class Genesis extends smartContract_js_1.SmartContract {
|
|
35
|
-
constructor() {
|
|
36
|
-
// eslint-disable-next-line prefer-rest-params
|
|
37
|
-
super(...arguments);
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Validates the deployment transaction outputs.
|
|
41
|
-
*
|
|
42
|
-
* This method performs the following checks:
|
|
43
|
-
* 1. Serializes all non-empty output data (scriptHash, satoshis, dataHash)
|
|
44
|
-
* 2. Ensures all non-empty script hashes are unique
|
|
45
|
-
* 3. Verifies the serialized outputs match the transaction context
|
|
46
|
-
*
|
|
47
|
-
* Empty scriptHashes (len == 0) are treated as placeholders and are skipped
|
|
48
|
-
* in both serialization and uniqueness validation.
|
|
49
|
-
*
|
|
50
|
-
* @param outputs - Fixed array of 3 transaction outputs to validate
|
|
51
|
-
* @throws {Error} If any two non-empty outputs have the same scriptHash
|
|
52
|
-
* @throws {Error} If outputs don't match the transaction context
|
|
53
|
-
* @onchain
|
|
54
|
-
*/
|
|
55
|
-
checkDeploy(outputs) {
|
|
56
|
-
// Serialize all outputs
|
|
57
|
-
let outputBytes = (0, index_js_1.toByteString)('');
|
|
58
|
-
for (let index = 0; index < exports.MAX_GENESIS_CHECK_OUTPUT; index++) {
|
|
59
|
-
const _output = outputs[index];
|
|
60
|
-
if ((0, index_js_1.len)(_output.scriptHash) > 0n) {
|
|
61
|
-
outputBytes += txUtils_js_1.TxUtils.buildDataOutput(_output.scriptHash, _output.satoshis, _output.dataHash);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
// Ensure all non-empty script hashes are unique (no duplicate deployments)
|
|
65
|
-
// Empty scriptHashes (len == 0) are placeholders and should be skipped
|
|
66
|
-
if ((0, index_js_1.len)(outputs[0].scriptHash) > 0n && (0, index_js_1.len)(outputs[1].scriptHash) > 0n) {
|
|
67
|
-
(0, index_js_1.assert)(outputs[0].scriptHash != outputs[1].scriptHash, 'Duplicate scriptHash: outputs[0] and outputs[1] have the same scriptHash');
|
|
68
|
-
}
|
|
69
|
-
if ((0, index_js_1.len)(outputs[0].scriptHash) > 0n && (0, index_js_1.len)(outputs[2].scriptHash) > 0n) {
|
|
70
|
-
(0, index_js_1.assert)(outputs[0].scriptHash != outputs[2].scriptHash, 'Duplicate scriptHash: outputs[0] and outputs[2] have the same scriptHash');
|
|
71
|
-
}
|
|
72
|
-
if ((0, index_js_1.len)(outputs[1].scriptHash) > 0n && (0, index_js_1.len)(outputs[2].scriptHash) > 0n) {
|
|
73
|
-
(0, index_js_1.assert)(outputs[1].scriptHash != outputs[2].scriptHash, 'Duplicate scriptHash: outputs[1] and outputs[2] have the same scriptHash');
|
|
74
|
-
}
|
|
75
|
-
// Verify outputs match the transaction context
|
|
76
|
-
(0, index_js_1.assert)(this.checkOutputs(outputBytes), 'Outputs mismatch with the transaction context');
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
exports.Genesis = Genesis;
|
|
80
|
-
__decorate([
|
|
81
|
-
(0, decorators_js_1.method)(),
|
|
82
|
-
__metadata("design:type", Function),
|
|
83
|
-
__metadata("design:paramtypes", [Object]),
|
|
84
|
-
__metadata("design:returntype", void 0)
|
|
85
|
-
], Genesis.prototype, "checkDeploy", null);
|
|
86
|
-
exports.Genesis = Genesis = __decorate([
|
|
87
|
-
(0, decorators_js_1.tags)(['GENESIS']),
|
|
88
|
-
__metadata("design:paramtypes", [])
|
|
89
|
-
], Genesis);
|
|
90
|
-
/**
|
|
91
|
-
* Creates a contract call function for Genesis.checkDeploy that automatically
|
|
92
|
-
* builds the TxOut array from the transaction outputs.
|
|
93
|
-
*
|
|
94
|
-
* This function handles the conversion of transaction outputs to the TxOut format
|
|
95
|
-
* required by the Genesis contract, including:
|
|
96
|
-
* - Creating empty placeholders for unused output slots
|
|
97
|
-
* - Computing scriptHash and dataHash for each output
|
|
98
|
-
* - Limiting to MAX_GENESIS_CHECK_OUTPUT (3) outputs
|
|
99
|
-
*
|
|
100
|
-
* @returns A ContractCall function that can be used with ExtPsbt.addContractInput
|
|
101
|
-
*
|
|
102
|
-
* @example
|
|
103
|
-
* ```typescript
|
|
104
|
-
* const genesis = new Genesis();
|
|
105
|
-
* genesis.bindToUtxo(genesisUtxo);
|
|
106
|
-
*
|
|
107
|
-
* const deployPsbt = new ExtPsbt({ network })
|
|
108
|
-
* .addContractInput(genesis, genesisCheckDeploy())
|
|
109
|
-
* .addContractOutput(minter, Postage.MINTER_POSTAGE)
|
|
110
|
-
* .change(changeAddress, feeRate)
|
|
111
|
-
* .seal();
|
|
112
|
-
* ```
|
|
113
|
-
*
|
|
114
|
-
* @category Genesis
|
|
115
|
-
*/
|
|
116
|
-
function genesisCheckDeploy() {
|
|
117
|
-
return (contract, psbt) => {
|
|
118
|
-
// Create output array with empty placeholders
|
|
119
|
-
const emptyOutput = {
|
|
120
|
-
scriptHash: (0, index_js_1.toByteString)(''),
|
|
121
|
-
satoshis: 0n,
|
|
122
|
-
dataHash: (0, index_js_1.sha256)((0, index_js_1.toByteString)('')),
|
|
123
|
-
};
|
|
124
|
-
const outputs = (0, index_js_1.fill)(emptyOutput, exports.MAX_GENESIS_CHECK_OUTPUT);
|
|
125
|
-
// Fill with actual outputs from the transaction
|
|
126
|
-
const txOutputs = psbt.txOutputs;
|
|
127
|
-
for (let i = 0; i < txOutputs.length && i < exports.MAX_GENESIS_CHECK_OUTPUT; i++) {
|
|
128
|
-
const output = txOutputs[i];
|
|
129
|
-
outputs[i] = {
|
|
130
|
-
scriptHash: (0, index_js_1.sha256)((0, index_js_1.toByteString)((0, common_js_1.uint8ArrayToHex)(output.script))),
|
|
131
|
-
satoshis: BigInt(output.value),
|
|
132
|
-
dataHash: (0, index_js_1.sha256)((0, index_js_1.toByteString)((0, common_js_1.uint8ArrayToHex)(output.data))),
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
contract.checkDeploy(outputs);
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
exports.genesisCheckDeploy = genesisCheckDeploy;
|
|
139
|
-
// Embedded artifact for Genesis contract
|
|
140
|
-
const desc = {
|
|
141
|
-
version: 10,
|
|
142
|
-
compilerVersion: '1.21.0+commit.2ada378',
|
|
143
|
-
contract: 'Genesis',
|
|
144
|
-
md5: 'd3404c4b368255eec0f93e2d868e4510',
|
|
145
|
-
structs: [
|
|
146
|
-
{
|
|
147
|
-
name: 'TxOut',
|
|
148
|
-
params: [
|
|
149
|
-
{ name: 'scriptHash', type: 'bytes' },
|
|
150
|
-
{ name: 'dataHash', type: 'bytes' },
|
|
151
|
-
{ name: 'satoshis', type: 'int' },
|
|
152
|
-
],
|
|
153
|
-
genericTypes: [],
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
name: 'SHPreimage',
|
|
157
|
-
params: [
|
|
158
|
-
{ name: 'nVersion', type: 'bytes' },
|
|
159
|
-
{ name: 'hashPrevouts', type: 'bytes' },
|
|
160
|
-
{ name: 'spentScriptHash', type: 'bytes' },
|
|
161
|
-
{ name: 'spentDataHash', type: 'bytes' },
|
|
162
|
-
{ name: 'value', type: 'int' },
|
|
163
|
-
{ name: 'nSequence', type: 'bytes' },
|
|
164
|
-
{ name: 'hashSpentAmounts', type: 'bytes' },
|
|
165
|
-
{ name: 'hashSpentScriptHashes', type: 'bytes' },
|
|
166
|
-
{ name: 'hashSpentDataHashes', type: 'bytes' },
|
|
167
|
-
{ name: 'hashSequences', type: 'bytes' },
|
|
168
|
-
{ name: 'hashOutputs', type: 'bytes' },
|
|
169
|
-
{ name: 'inputIndex', type: 'int' },
|
|
170
|
-
{ name: 'nLockTime', type: 'int' },
|
|
171
|
-
{ name: 'sigHashType', type: 'int' },
|
|
172
|
-
],
|
|
173
|
-
genericTypes: [],
|
|
174
|
-
},
|
|
175
|
-
],
|
|
176
|
-
library: [
|
|
177
|
-
{ name: 'TxUtils', params: [], properties: [], genericTypes: [] },
|
|
178
|
-
{ name: 'ContextUtils', params: [], properties: [], genericTypes: [] },
|
|
179
|
-
{ name: 'StdUtils', params: [], properties: [], genericTypes: [] },
|
|
180
|
-
],
|
|
181
|
-
alias: [],
|
|
182
|
-
abi: [
|
|
183
|
-
{
|
|
184
|
-
type: 'function',
|
|
185
|
-
name: 'checkDeploy',
|
|
186
|
-
index: 0,
|
|
187
|
-
params: [
|
|
188
|
-
{ name: 'outputs', type: 'TxOut[3]' },
|
|
189
|
-
{ name: '__scrypt_ts_shPreimage', type: 'SHPreimage' },
|
|
190
|
-
],
|
|
191
|
-
},
|
|
192
|
-
{ type: 'constructor', params: [] },
|
|
193
|
-
],
|
|
194
|
-
stateProps: [],
|
|
195
|
-
buildType: 'release',
|
|
196
|
-
file: '',
|
|
197
|
-
hex: '512097dfd76851bf465e8f715593b217714858bbe9570ff3bd5e33840a34e20ff0262102ba79df5f8ae7604a9830f03c7933028186aede0675a16f025dc4f8be8eec0382201008ce7480da41702918d1ec8e6849ba32b4d65b1e40dc669c31a1e6306b266c0111790111790111790111790111790111790111790111790111790111790111790111790111790111795d798277549d5c79827701209d5b79827701209d5a79827701209d597900a26958798277549d5779827701209d5679827701209d5579827701209d5479827701209d5379827701209d527900a2697800a26976519c6476529c6751686476539c67516864760281009c67516864760282009c67516864760283009c675168695d795d797e5c797e5b797e5a79767600a2637609ffffffffffffffff00a16700686976586e8b806e7c7f75007f6b6d6d6d6c7e59797e58797e57797e56797e55797e54797e5379546e8b806e7c7f75007f6b6d6d6c7e5279546e8b806e7c7f75007f6b6d6d6c7e7854807e6b6d6d6d6d6d6d6d6c54797855795579210ac407f0e4bd44bfc207355a778b046225a7068fc59ee7eda43ad905aadbffc800206c266b30e6a1319c66dc401e5bd6b432ba49688eecd118297041da8074ce0810577956795679aa7676517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e01007e817757795679567956795679537956795479577995939521414136d08c5ed2bf3ba048afe6dcaebafeffffffffffffffffffffffffffffff006e6e9776009f636e936776687777777b757c6e5296a0636e7c947b757c6853798277527982775379012080517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e01205279947f77545379935279930130787e527e54797e58797e527e53797e52797e57797e6b6d6d6d6d6d6d6c765779ac6b6d6d6d6d6d6c776900011b766b796c766b796c766b796c755279827700a06370707c527982777882777801209d7601209d537900a2695379767600a2637609ffffffffffffffff00a16700686976586e8b806e7c7f75007f6b6d6d6d6c55797e53797e6b6d6d6c777e547a7572537a537975686d750118766b796c766b796c766b796c755279827700a06370707c527982777882777801209d7601209d537900a2695379767600a2637609ffffffffffffffff00a16700686976586e8b806e7c7f75007f6b6d6d6d6c55797e53797e6b6d6d6c777e547a7572537a537975686d750115766b796c766b796c766b796c755279827700a06370707c527982777882777801209d7601209d537900a2695379767600a2637609ffffffffffffffff00a16700686976586e8b806e7c7f75007f6b6d6d6d6c55797e53797e6b6d6d6c777e547a7572537a537975686d75011b766b796c766b796c766b796c6d7c77827700a0630118766b796c766b796c766b796c6d7c77827700a067006863011b766b796c766b796c766b796c6d7c770119766b796c766b796c766b796c6d7c7787916968011b766b796c766b796c766b796c6d7c77827700a0630115766b796c766b796c766b796c6d7c77827700a067006863011b766b796c766b796c766b796c6d7c770116766b796c766b796c766b796c6d7c77879169680118766b796c766b796c766b796c6d7c77827700a0630115766b796c766b796c766b796c6d7c77827700a0670068630118766b796c766b796c766b796c6d7c770116766b796c766b796c766b796c6d7c778791696876aa5979876b6d6d6d6d6d6d6d6d6d6d6d6d6d6d6c',
|
|
198
|
-
sourceMapFile: '',
|
|
199
|
-
};
|
|
200
|
-
Genesis.loadArtifact(desc);
|
|
201
|
-
//# sourceMappingURL=genesis.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"genesis.js","sourceRoot":"","sources":["../../../../src/smart-contract/builtin-libs/genesis.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0DAAoD;AACpD,oDAAgD;AAChD,8CAA0E;AAE1E,6CAAuC;AAEvC,qDAAwD;AAExD;;GAEG;AACU,QAAA,wBAAwB,GAAG,CAAC,CAAC;AAE1C;;;;;;;;;;;GAWG;AAEI,IAAM,OAAO,GAAb,MAAM,OAAQ,SAAQ,gCAAa;IACxC;QACE,8CAA8C;QAC9C,KAAK,CAAC,GAAG,SAAS,CAAC,CAAC;IACtB,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IAEI,WAAW,CAAC,OAA2D;QAC5E,wBAAwB;QACxB,IAAI,WAAW,GAAG,IAAA,uBAAY,EAAC,EAAE,CAAC,CAAC;QACnC,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,gCAAwB,EAAE,KAAK,EAAE,EAAE,CAAC;YAC9D,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;YAC/B,IAAI,IAAA,cAAG,EAAC,OAAO,CAA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EAAE,IAAI,EAAE,KAAK,EAAE;gBACnC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE;gBAClC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,KAAK,EAAE;aACrC;YACD,YAAY,EAAE,EAAE;SACjB;KACF;IACD,OAAO,EAAE;QACP,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE;QACjE,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE;QACtE,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE;KACnE;IACD,KAAK,EAAE,EAAE;IACT,GAAG,EAAE;QACH;YACE,IAAI,EAAE,UAAU;YAChB,IAAI,EAAE,aAAa;YACnB,KAAK,EAAE,CAAC;YACR,MAAM,EAAE;gBACN,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE;gBACrC,EAAE,IAAI,EAAE,wBAAwB,EAAE,IAAI,EAAE,YAAY,EAAE;aACvD;SACF;QACD,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,EAAE,EAAE;KACpC;IACD,UAAU,EAAE,EAAE;IACd,SAAS,EAAE,SAAS;IACpB,IAAI,EAAE,EAAE;IACR,GAAG,EAAE,g5FAAg5F;IACr5F,aAAa,EAAE,EAAE;CAClB,CAAC;AAEF,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
|
-
import { SmartContract } from '../smartContract.js';
|
|
11
|
-
import { method, tags } from '../decorators.js';
|
|
12
|
-
import { assert, toByteString, len, sha256, fill } from '../fns/index.js';
|
|
13
|
-
import { TxUtils } from './txUtils.js';
|
|
14
|
-
import { uint8ArrayToHex } from '../../utils/common.js';
|
|
15
|
-
/**
|
|
16
|
-
* Maximum number of outputs to check during genesis deployment
|
|
17
|
-
*/
|
|
18
|
-
export const MAX_GENESIS_CHECK_OUTPUT = 3;
|
|
19
|
-
/**
|
|
20
|
-
* Genesis contract for validating initial deployment outputs.
|
|
21
|
-
*
|
|
22
|
-
* This contract ensures that during deployment, all non-empty outputs have
|
|
23
|
-
* distinct script hashes, preventing duplicate deployments to the same address.
|
|
24
|
-
* Empty scriptHashes (represented by empty ByteString) are treated as placeholders
|
|
25
|
-
* and are not validated for uniqueness.
|
|
26
|
-
*
|
|
27
|
-
* @category Contract
|
|
28
|
-
* @category Genesis
|
|
29
|
-
* @onchain
|
|
30
|
-
*/
|
|
31
|
-
let Genesis = class Genesis extends SmartContract {
|
|
32
|
-
constructor() {
|
|
33
|
-
// eslint-disable-next-line prefer-rest-params
|
|
34
|
-
super(...arguments);
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Validates the deployment transaction outputs.
|
|
38
|
-
*
|
|
39
|
-
* This method performs the following checks:
|
|
40
|
-
* 1. Serializes all non-empty output data (scriptHash, satoshis, dataHash)
|
|
41
|
-
* 2. Ensures all non-empty script hashes are unique
|
|
42
|
-
* 3. Verifies the serialized outputs match the transaction context
|
|
43
|
-
*
|
|
44
|
-
* Empty scriptHashes (len == 0) are treated as placeholders and are skipped
|
|
45
|
-
* in both serialization and uniqueness validation.
|
|
46
|
-
*
|
|
47
|
-
* @param outputs - Fixed array of 3 transaction outputs to validate
|
|
48
|
-
* @throws {Error} If any two non-empty outputs have the same scriptHash
|
|
49
|
-
* @throws {Error} If outputs don't match the transaction context
|
|
50
|
-
* @onchain
|
|
51
|
-
*/
|
|
52
|
-
checkDeploy(outputs) {
|
|
53
|
-
// Serialize all outputs
|
|
54
|
-
let outputBytes = toByteString('');
|
|
55
|
-
for (let index = 0; index < MAX_GENESIS_CHECK_OUTPUT; index++) {
|
|
56
|
-
const _output = outputs[index];
|
|
57
|
-
if (len(_output.scriptHash) > 0n) {
|
|
58
|
-
outputBytes += TxUtils.buildDataOutput(_output.scriptHash, _output.satoshis, _output.dataHash);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
// Ensure all non-empty script hashes are unique (no duplicate deployments)
|
|
62
|
-
// Empty scriptHashes (len == 0) are placeholders and should be skipped
|
|
63
|
-
if (len(outputs[0].scriptHash) > 0n && len(outputs[1].scriptHash) > 0n) {
|
|
64
|
-
assert(outputs[0].scriptHash != outputs[1].scriptHash, 'Duplicate scriptHash: outputs[0] and outputs[1] have the same scriptHash');
|
|
65
|
-
}
|
|
66
|
-
if (len(outputs[0].scriptHash) > 0n && len(outputs[2].scriptHash) > 0n) {
|
|
67
|
-
assert(outputs[0].scriptHash != outputs[2].scriptHash, 'Duplicate scriptHash: outputs[0] and outputs[2] have the same scriptHash');
|
|
68
|
-
}
|
|
69
|
-
if (len(outputs[1].scriptHash) > 0n && len(outputs[2].scriptHash) > 0n) {
|
|
70
|
-
assert(outputs[1].scriptHash != outputs[2].scriptHash, 'Duplicate scriptHash: outputs[1] and outputs[2] have the same scriptHash');
|
|
71
|
-
}
|
|
72
|
-
// Verify outputs match the transaction context
|
|
73
|
-
assert(this.checkOutputs(outputBytes), 'Outputs mismatch with the transaction context');
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
__decorate([
|
|
77
|
-
method(),
|
|
78
|
-
__metadata("design:type", Function),
|
|
79
|
-
__metadata("design:paramtypes", [Object]),
|
|
80
|
-
__metadata("design:returntype", void 0)
|
|
81
|
-
], Genesis.prototype, "checkDeploy", null);
|
|
82
|
-
Genesis = __decorate([
|
|
83
|
-
tags(['GENESIS']),
|
|
84
|
-
__metadata("design:paramtypes", [])
|
|
85
|
-
], Genesis);
|
|
86
|
-
export { Genesis };
|
|
87
|
-
/**
|
|
88
|
-
* Creates a contract call function for Genesis.checkDeploy that automatically
|
|
89
|
-
* builds the TxOut array from the transaction outputs.
|
|
90
|
-
*
|
|
91
|
-
* This function handles the conversion of transaction outputs to the TxOut format
|
|
92
|
-
* required by the Genesis contract, including:
|
|
93
|
-
* - Creating empty placeholders for unused output slots
|
|
94
|
-
* - Computing scriptHash and dataHash for each output
|
|
95
|
-
* - Limiting to MAX_GENESIS_CHECK_OUTPUT (3) outputs
|
|
96
|
-
*
|
|
97
|
-
* @returns A ContractCall function that can be used with ExtPsbt.addContractInput
|
|
98
|
-
*
|
|
99
|
-
* @example
|
|
100
|
-
* ```typescript
|
|
101
|
-
* const genesis = new Genesis();
|
|
102
|
-
* genesis.bindToUtxo(genesisUtxo);
|
|
103
|
-
*
|
|
104
|
-
* const deployPsbt = new ExtPsbt({ network })
|
|
105
|
-
* .addContractInput(genesis, genesisCheckDeploy())
|
|
106
|
-
* .addContractOutput(minter, Postage.MINTER_POSTAGE)
|
|
107
|
-
* .change(changeAddress, feeRate)
|
|
108
|
-
* .seal();
|
|
109
|
-
* ```
|
|
110
|
-
*
|
|
111
|
-
* @category Genesis
|
|
112
|
-
*/
|
|
113
|
-
export function genesisCheckDeploy() {
|
|
114
|
-
return (contract, psbt) => {
|
|
115
|
-
// Create output array with empty placeholders
|
|
116
|
-
const emptyOutput = {
|
|
117
|
-
scriptHash: toByteString(''),
|
|
118
|
-
satoshis: 0n,
|
|
119
|
-
dataHash: sha256(toByteString('')),
|
|
120
|
-
};
|
|
121
|
-
const outputs = fill(emptyOutput, MAX_GENESIS_CHECK_OUTPUT);
|
|
122
|
-
// Fill with actual outputs from the transaction
|
|
123
|
-
const txOutputs = psbt.txOutputs;
|
|
124
|
-
for (let i = 0; i < txOutputs.length && i < MAX_GENESIS_CHECK_OUTPUT; i++) {
|
|
125
|
-
const output = txOutputs[i];
|
|
126
|
-
outputs[i] = {
|
|
127
|
-
scriptHash: sha256(toByteString(uint8ArrayToHex(output.script))),
|
|
128
|
-
satoshis: BigInt(output.value),
|
|
129
|
-
dataHash: sha256(toByteString(uint8ArrayToHex(output.data))),
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
contract.checkDeploy(outputs);
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
// Embedded artifact for Genesis contract
|
|
136
|
-
const desc = {
|
|
137
|
-
version: 10,
|
|
138
|
-
compilerVersion: '1.21.0+commit.2ada378',
|
|
139
|
-
contract: 'Genesis',
|
|
140
|
-
md5: 'd3404c4b368255eec0f93e2d868e4510',
|
|
141
|
-
structs: [
|
|
142
|
-
{
|
|
143
|
-
name: 'TxOut',
|
|
144
|
-
params: [
|
|
145
|
-
{ name: 'scriptHash', type: 'bytes' },
|
|
146
|
-
{ name: 'dataHash', type: 'bytes' },
|
|
147
|
-
{ name: 'satoshis', type: 'int' },
|
|
148
|
-
],
|
|
149
|
-
genericTypes: [],
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
name: 'SHPreimage',
|
|
153
|
-
params: [
|
|
154
|
-
{ name: 'nVersion', type: 'bytes' },
|
|
155
|
-
{ name: 'hashPrevouts', type: 'bytes' },
|
|
156
|
-
{ name: 'spentScriptHash', type: 'bytes' },
|
|
157
|
-
{ name: 'spentDataHash', type: 'bytes' },
|
|
158
|
-
{ name: 'value', type: 'int' },
|
|
159
|
-
{ name: 'nSequence', type: 'bytes' },
|
|
160
|
-
{ name: 'hashSpentAmounts', type: 'bytes' },
|
|
161
|
-
{ name: 'hashSpentScriptHashes', type: 'bytes' },
|
|
162
|
-
{ name: 'hashSpentDataHashes', type: 'bytes' },
|
|
163
|
-
{ name: 'hashSequences', type: 'bytes' },
|
|
164
|
-
{ name: 'hashOutputs', type: 'bytes' },
|
|
165
|
-
{ name: 'inputIndex', type: 'int' },
|
|
166
|
-
{ name: 'nLockTime', type: 'int' },
|
|
167
|
-
{ name: 'sigHashType', type: 'int' },
|
|
168
|
-
],
|
|
169
|
-
genericTypes: [],
|
|
170
|
-
},
|
|
171
|
-
],
|
|
172
|
-
library: [
|
|
173
|
-
{ name: 'TxUtils', params: [], properties: [], genericTypes: [] },
|
|
174
|
-
{ name: 'ContextUtils', params: [], properties: [], genericTypes: [] },
|
|
175
|
-
{ name: 'StdUtils', params: [], properties: [], genericTypes: [] },
|
|
176
|
-
],
|
|
177
|
-
alias: [],
|
|
178
|
-
abi: [
|
|
179
|
-
{
|
|
180
|
-
type: 'function',
|
|
181
|
-
name: 'checkDeploy',
|
|
182
|
-
index: 0,
|
|
183
|
-
params: [
|
|
184
|
-
{ name: 'outputs', type: 'TxOut[3]' },
|
|
185
|
-
{ name: '__scrypt_ts_shPreimage', type: 'SHPreimage' },
|
|
186
|
-
],
|
|
187
|
-
},
|
|
188
|
-
{ type: 'constructor', params: [] },
|
|
189
|
-
],
|
|
190
|
-
stateProps: [],
|
|
191
|
-
buildType: 'release',
|
|
192
|
-
file: '',
|
|
193
|
-
hex: '512097dfd76851bf465e8f715593b217714858bbe9570ff3bd5e33840a34e20ff0262102ba79df5f8ae7604a9830f03c7933028186aede0675a16f025dc4f8be8eec0382201008ce7480da41702918d1ec8e6849ba32b4d65b1e40dc669c31a1e6306b266c0111790111790111790111790111790111790111790111790111790111790111790111790111790111795d798277549d5c79827701209d5b79827701209d5a79827701209d597900a26958798277549d5779827701209d5679827701209d5579827701209d5479827701209d5379827701209d527900a2697800a26976519c6476529c6751686476539c67516864760281009c67516864760282009c67516864760283009c675168695d795d797e5c797e5b797e5a79767600a2637609ffffffffffffffff00a16700686976586e8b806e7c7f75007f6b6d6d6d6c7e59797e58797e57797e56797e55797e54797e5379546e8b806e7c7f75007f6b6d6d6c7e5279546e8b806e7c7f75007f6b6d6d6c7e7854807e6b6d6d6d6d6d6d6d6c54797855795579210ac407f0e4bd44bfc207355a778b046225a7068fc59ee7eda43ad905aadbffc800206c266b30e6a1319c66dc401e5bd6b432ba49688eecd118297041da8074ce0810577956795679aa7676517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e01007e817757795679567956795679537956795479577995939521414136d08c5ed2bf3ba048afe6dcaebafeffffffffffffffffffffffffffffff006e6e9776009f636e936776687777777b757c6e5296a0636e7c947b757c6853798277527982775379012080517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e01205279947f77545379935279930130787e527e54797e58797e527e53797e52797e57797e6b6d6d6d6d6d6d6c765779ac6b6d6d6d6d6d6c776900011b766b796c766b796c766b796c755279827700a06370707c527982777882777801209d7601209d537900a2695379767600a2637609ffffffffffffffff00a16700686976586e8b806e7c7f75007f6b6d6d6d6c55797e53797e6b6d6d6c777e547a7572537a537975686d750118766b796c766b796c766b796c755279827700a06370707c527982777882777801209d7601209d537900a2695379767600a2637609ffffffffffffffff00a16700686976586e8b806e7c7f75007f6b6d6d6d6c55797e53797e6b6d6d6c777e547a7572537a537975686d750115766b796c766b796c766b796c755279827700a06370707c527982777882777801209d7601209d537900a2695379767600a2637609ffffffffffffffff00a16700686976586e8b806e7c7f75007f6b6d6d6d6c55797e53797e6b6d6d6c777e547a7572537a537975686d75011b766b796c766b796c766b796c6d7c77827700a0630118766b796c766b796c766b796c6d7c77827700a067006863011b766b796c766b796c766b796c6d7c770119766b796c766b796c766b796c6d7c7787916968011b766b796c766b796c766b796c6d7c77827700a0630115766b796c766b796c766b796c6d7c77827700a067006863011b766b796c766b796c766b796c6d7c770116766b796c766b796c766b796c6d7c77879169680118766b796c766b796c766b796c6d7c77827700a0630115766b796c766b796c766b796c6d7c77827700a0670068630118766b796c766b796c766b796c6d7c770116766b796c766b796c766b796c6d7c778791696876aa5979876b6d6d6d6d6d6d6d6d6d6d6d6d6d6d6c',
|
|
194
|
-
sourceMapFile: '',
|
|
195
|
-
};
|
|
196
|
-
Genesis.loadArtifact(desc);
|
|
197
|
-
//# sourceMappingURL=genesis.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"genesis.js","sourceRoot":"","sources":["../../../../src/smart-contract/builtin-libs/genesis.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE1E,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAE1C;;;;;;;;;;;GAWG;AAEI,IAAM,OAAO,GAAb,MAAM,OAAQ,SAAQ,aAAa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AY,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { SmartContract } from '../smartContract.js';
|
|
2
|
-
import { FixedArray, TxOut } from '../types/index.js';
|
|
3
|
-
import { ContractCall } from '../../psbt/types.js';
|
|
4
|
-
/**
|
|
5
|
-
* Maximum number of outputs to check during genesis deployment
|
|
6
|
-
*/
|
|
7
|
-
export declare const MAX_GENESIS_CHECK_OUTPUT = 3;
|
|
8
|
-
/**
|
|
9
|
-
* Genesis contract for validating initial deployment outputs.
|
|
10
|
-
*
|
|
11
|
-
* This contract ensures that during deployment, all non-empty outputs have
|
|
12
|
-
* distinct script hashes, preventing duplicate deployments to the same address.
|
|
13
|
-
* Empty scriptHashes (represented by empty ByteString) are treated as placeholders
|
|
14
|
-
* and are not validated for uniqueness.
|
|
15
|
-
*
|
|
16
|
-
* @category Contract
|
|
17
|
-
* @category Genesis
|
|
18
|
-
* @onchain
|
|
19
|
-
*/
|
|
20
|
-
export declare class Genesis extends SmartContract {
|
|
21
|
-
constructor();
|
|
22
|
-
/**
|
|
23
|
-
* Validates the deployment transaction outputs.
|
|
24
|
-
*
|
|
25
|
-
* This method performs the following checks:
|
|
26
|
-
* 1. Serializes all non-empty output data (scriptHash, satoshis, dataHash)
|
|
27
|
-
* 2. Ensures all non-empty script hashes are unique
|
|
28
|
-
* 3. Verifies the serialized outputs match the transaction context
|
|
29
|
-
*
|
|
30
|
-
* Empty scriptHashes (len == 0) are treated as placeholders and are skipped
|
|
31
|
-
* in both serialization and uniqueness validation.
|
|
32
|
-
*
|
|
33
|
-
* @param outputs - Fixed array of 3 transaction outputs to validate
|
|
34
|
-
* @throws {Error} If any two non-empty outputs have the same scriptHash
|
|
35
|
-
* @throws {Error} If outputs don't match the transaction context
|
|
36
|
-
* @onchain
|
|
37
|
-
*/
|
|
38
|
-
checkDeploy(outputs: FixedArray<TxOut, typeof MAX_GENESIS_CHECK_OUTPUT>): void;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Creates a contract call function for Genesis.checkDeploy that automatically
|
|
42
|
-
* builds the TxOut array from the transaction outputs.
|
|
43
|
-
*
|
|
44
|
-
* This function handles the conversion of transaction outputs to the TxOut format
|
|
45
|
-
* required by the Genesis contract, including:
|
|
46
|
-
* - Creating empty placeholders for unused output slots
|
|
47
|
-
* - Computing scriptHash and dataHash for each output
|
|
48
|
-
* - Limiting to MAX_GENESIS_CHECK_OUTPUT (3) outputs
|
|
49
|
-
*
|
|
50
|
-
* @returns A ContractCall function that can be used with ExtPsbt.addContractInput
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* ```typescript
|
|
54
|
-
* const genesis = new Genesis();
|
|
55
|
-
* genesis.bindToUtxo(genesisUtxo);
|
|
56
|
-
*
|
|
57
|
-
* const deployPsbt = new ExtPsbt({ network })
|
|
58
|
-
* .addContractInput(genesis, genesisCheckDeploy())
|
|
59
|
-
* .addContractOutput(minter, Postage.MINTER_POSTAGE)
|
|
60
|
-
* .change(changeAddress, feeRate)
|
|
61
|
-
* .seal();
|
|
62
|
-
* ```
|
|
63
|
-
*
|
|
64
|
-
* @category Genesis
|
|
65
|
-
*/
|
|
66
|
-
export declare function genesisCheckDeploy(): ContractCall<Genesis>;
|
|
67
|
-
//# sourceMappingURL=genesis.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"genesis.d.ts","sourceRoot":"","sources":["../../../../src/smart-contract/builtin-libs/genesis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGnD;;GAEG;AACH,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAE1C;;;;;;;;;;;GAWG;AACH,qBACa,OAAQ,SAAQ,aAAa;;IAMxC;;;;;;;;;;;;;;;OAeG;IAEI,WAAW,CAAC,OAAO,EAAE,UAAU,CAAC,KAAK,EAAE,OAAO,wBAAwB,CAAC;CAsC/E;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,kBAAkB,IAAI,YAAY,CAAC,OAAO,CAAC,CAuB1D"}
|