@xyo-network/xl1-wrappers 4.0.10 → 4.0.12
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/dist/neutral/index.d.ts +1 -6
- package/dist/neutral/index.d.ts.map +1 -1
- package/dist/neutral/index.mjs +2 -273
- package/dist/neutral/index.mjs.map +4 -4
- package/package.json +17 -25
- package/dist/neutral/Address.d.ts +0 -11
- package/dist/neutral/Address.d.ts.map +0 -1
- package/dist/neutral/AddressState.d.ts +0 -10
- package/dist/neutral/AddressState.d.ts.map +0 -1
- package/dist/neutral/Base.d.ts +0 -19
- package/dist/neutral/Base.d.ts.map +0 -1
- package/dist/neutral/BlockWindow.d.ts +0 -25
- package/dist/neutral/BlockWindow.d.ts.map +0 -1
- package/dist/neutral/BlockWindowBalanceCache.d.ts +0 -14
- package/dist/neutral/BlockWindowBalanceCache.d.ts.map +0 -1
- package/dist/neutral/Fees.d.ts +0 -15
- package/dist/neutral/Fees.d.ts.map +0 -1
- package/dist/neutral/Signature.d.ts +0 -13
- package/dist/neutral/Signature.d.ts.map +0 -1
- package/dist/neutral/chain/chain.d.ts +0 -8
- package/dist/neutral/chain/chain.d.ts.map +0 -1
- package/dist/neutral/chain/index.d.ts +0 -2
- package/dist/neutral/chain/index.d.ts.map +0 -1
- package/dist/neutral/lib/createSignatureWrappers.d.ts +0 -5
- package/dist/neutral/lib/createSignatureWrappers.d.ts.map +0 -1
- package/dist/neutral/lib/index.d.ts +0 -2
- package/dist/neutral/lib/index.d.ts.map +0 -1
- package/dist/neutral/transaction/HydratedTransaction.d.ts +0 -47
- package/dist/neutral/transaction/HydratedTransaction.d.ts.map +0 -1
- package/dist/neutral/transaction/index.d.ts +0 -2
- package/dist/neutral/transaction/index.d.ts.map +0 -1
package/dist/neutral/index.d.ts
CHANGED
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
export * from '
|
|
2
|
-
export * from './chain/index.ts';
|
|
3
|
-
export * from './Fees.ts';
|
|
4
|
-
export * from './lib/index.ts';
|
|
5
|
-
export * from './Signature.ts';
|
|
6
|
-
export * from './transaction/index.ts';
|
|
1
|
+
export * from '@xyo-network/xl1-sdk/wrappers';
|
|
7
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,cAAc,+BAA+B,CAAA"}
|
package/dist/neutral/index.mjs
CHANGED
|
@@ -1,274 +1,3 @@
|
|
|
1
|
-
// src/
|
|
2
|
-
|
|
3
|
-
config;
|
|
4
|
-
value;
|
|
5
|
-
constructor(value, config = {}) {
|
|
6
|
-
this.config = config;
|
|
7
|
-
this.value = value;
|
|
8
|
-
}
|
|
9
|
-
get provider() {
|
|
10
|
-
return this.config.provider;
|
|
11
|
-
}
|
|
12
|
-
static async create(value, config = {}) {
|
|
13
|
-
const valueErrors = await this.validateValue(value);
|
|
14
|
-
if (valueErrors.length > 0) {
|
|
15
|
-
throw new Error(`Invalid value for ${this.constructor.name}: ${String(value)}`);
|
|
16
|
-
}
|
|
17
|
-
const configErrors = await this.validateConfig(config);
|
|
18
|
-
if (configErrors.length > 0) {
|
|
19
|
-
throw new Error(`Invalid config for ${this.constructor.name}: ${JSON.stringify(config)}`);
|
|
20
|
-
}
|
|
21
|
-
return Reflect.construct(this, [value, config]);
|
|
22
|
-
}
|
|
23
|
-
static validateConfig(_config) {
|
|
24
|
-
return [];
|
|
25
|
-
}
|
|
26
|
-
static validateValue(_value) {
|
|
27
|
-
return [];
|
|
28
|
-
}
|
|
29
|
-
validate() {
|
|
30
|
-
return [];
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
// src/chain/chain.ts
|
|
35
|
-
var ChainWrapper = class extends BaseWrapper {
|
|
36
|
-
get id() {
|
|
37
|
-
return this.value;
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
// src/Fees.ts
|
|
42
|
-
import { hexToBigInt } from "@ariestools/sdk";
|
|
43
|
-
import { AttoXL1 } from "@xyo-network/xl1-protocol-lib";
|
|
44
|
-
function parseHexOrBigInt(value) {
|
|
45
|
-
return AttoXL1(typeof value === "bigint" ? value : hexToBigInt(value));
|
|
46
|
-
}
|
|
47
|
-
var FeesWrapper = class _FeesWrapper {
|
|
48
|
-
base;
|
|
49
|
-
gasLimit;
|
|
50
|
-
gasPrice;
|
|
51
|
-
priority;
|
|
52
|
-
constructor({
|
|
53
|
-
base,
|
|
54
|
-
gasLimit,
|
|
55
|
-
gasPrice,
|
|
56
|
-
priority
|
|
57
|
-
}) {
|
|
58
|
-
this.base = parseHexOrBigInt(base);
|
|
59
|
-
this.gasLimit = parseHexOrBigInt(gasLimit);
|
|
60
|
-
this.gasPrice = parseHexOrBigInt(gasPrice);
|
|
61
|
-
this.priority = parseHexOrBigInt(priority);
|
|
62
|
-
}
|
|
63
|
-
static validate({
|
|
64
|
-
base,
|
|
65
|
-
gasLimit,
|
|
66
|
-
gasPrice,
|
|
67
|
-
priority
|
|
68
|
-
}) {
|
|
69
|
-
const errors = [];
|
|
70
|
-
const baseValue = parseHexOrBigInt(base);
|
|
71
|
-
const gasLimitValue = parseHexOrBigInt(gasLimit);
|
|
72
|
-
const gasPriceValue = parseHexOrBigInt(gasPrice);
|
|
73
|
-
const priorityValue = parseHexOrBigInt(priority);
|
|
74
|
-
if (baseValue <= 0n) {
|
|
75
|
-
errors.push(new Error("Base fee cannot be negative or zero"));
|
|
76
|
-
}
|
|
77
|
-
if (gasLimitValue < 0n) {
|
|
78
|
-
errors.push(new Error("Gas limit cannot be negative"));
|
|
79
|
-
}
|
|
80
|
-
if (gasPriceValue < 0n) {
|
|
81
|
-
errors.push(new Error("Gas price cannot be negative"));
|
|
82
|
-
}
|
|
83
|
-
if (priorityValue < 0n) {
|
|
84
|
-
errors.push(new Error("Priority cannot be negative"));
|
|
85
|
-
}
|
|
86
|
-
return errors;
|
|
87
|
-
}
|
|
88
|
-
async validate() {
|
|
89
|
-
return await _FeesWrapper.validate({
|
|
90
|
-
base: this.base,
|
|
91
|
-
gasLimit: this.gasLimit,
|
|
92
|
-
gasPrice: this.gasPrice,
|
|
93
|
-
priority: this.priority
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
// src/lib/createSignatureWrappers.ts
|
|
99
|
-
import { asHex } from "@ariestools/sdk";
|
|
100
|
-
import { PayloadBuilder } from "@xyo-network/sdk";
|
|
101
|
-
|
|
102
|
-
// src/Signature.ts
|
|
103
|
-
import { toArrayBuffer } from "@ariestools/sdk";
|
|
104
|
-
import { BoundWitnessValidator } from "@xyo-network/sdk";
|
|
105
|
-
var SignatureWrapper = class _SignatureWrapper {
|
|
106
|
-
address;
|
|
107
|
-
hash;
|
|
108
|
-
signature;
|
|
109
|
-
constructor(signature, address, hash) {
|
|
110
|
-
this.signature = signature;
|
|
111
|
-
this.address = address;
|
|
112
|
-
this.hash = hash;
|
|
113
|
-
}
|
|
114
|
-
static async validate(hash, address, signature) {
|
|
115
|
-
return await BoundWitnessValidator.validateSignature(toArrayBuffer(hash), address, toArrayBuffer(signature));
|
|
116
|
-
}
|
|
117
|
-
async validate() {
|
|
118
|
-
return await _SignatureWrapper.validate(this.hash, this.address, this.signature);
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
// src/lib/createSignatureWrappers.ts
|
|
123
|
-
var createSignatureWrappers = async (bw) => {
|
|
124
|
-
const signatures = [];
|
|
125
|
-
const hash = await PayloadBuilder.dataHash(bw);
|
|
126
|
-
for (let i = 0; i < bw.$signatures.length; i++) {
|
|
127
|
-
signatures.push(
|
|
128
|
-
new SignatureWrapper(asHex(bw.$signatures[i], true), bw.addresses[i], hash)
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
return signatures;
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
// src/transaction/HydratedTransaction.ts
|
|
135
|
-
import { hexToBigInt as hexToBigInt2, isDefined } from "@ariestools/sdk";
|
|
136
|
-
import { PayloadBuilder as PayloadBuilder2 } from "@xyo-network/sdk";
|
|
137
|
-
import {
|
|
138
|
-
elevatedTransaction,
|
|
139
|
-
isAllowedBlockPayload,
|
|
140
|
-
isTransfer,
|
|
141
|
-
tryExtractElevatedHashes,
|
|
142
|
-
tryExtractElevatedHashesFromScript,
|
|
143
|
-
XYO_ZERO_ADDRESS
|
|
144
|
-
} from "@xyo-network/xl1-protocol-lib";
|
|
145
|
-
import { transactionRequiredGas } from "@xyo-network/xl1-protocol-sdk";
|
|
146
|
-
import { validateTransaction } from "@xyo-network/xl1-validation";
|
|
147
|
-
var sumTransfers = (payload) => {
|
|
148
|
-
let total = 0n;
|
|
149
|
-
for (const i of Object.values(payload.transfers)) {
|
|
150
|
-
total += hexToBigInt2(i ?? "00");
|
|
151
|
-
}
|
|
152
|
-
return total;
|
|
153
|
-
};
|
|
154
|
-
var HydratedTransactionWrapper = class _HydratedTransactionWrapper {
|
|
155
|
-
data;
|
|
156
|
-
fees;
|
|
157
|
-
context;
|
|
158
|
-
payloadsCache = [];
|
|
159
|
-
_signatureCache = [];
|
|
160
|
-
constructor(data, context) {
|
|
161
|
-
this.context = context ?? { singletons: {} };
|
|
162
|
-
this.data = data;
|
|
163
|
-
this.fees = new FeesWrapper(
|
|
164
|
-
this.boundWitness.fees
|
|
165
|
-
);
|
|
166
|
-
}
|
|
167
|
-
get boundWitness() {
|
|
168
|
-
return this.data[0];
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* A copy of the transaction that excludes non-elevated payloads — i.e. only what ends up on chain.
|
|
172
|
-
*/
|
|
173
|
-
get elevated() {
|
|
174
|
-
return elevatedTransaction(this.data);
|
|
175
|
-
}
|
|
176
|
-
get elevatedPayloadCount() {
|
|
177
|
-
const { script } = this.data[0];
|
|
178
|
-
return script ? tryExtractElevatedHashesFromScript(script).length : 0;
|
|
179
|
-
}
|
|
180
|
-
get elevatedPayloads() {
|
|
181
|
-
return tryExtractElevatedHashes(this.data);
|
|
182
|
-
}
|
|
183
|
-
get externalPayloads() {
|
|
184
|
-
const allPayloads = this.payloads;
|
|
185
|
-
return Object.fromEntries(
|
|
186
|
-
this.boundWitness.payload_hashes.map((payloadHash, i) => {
|
|
187
|
-
const payload = allPayloads.find((p) => p._hash === payloadHash);
|
|
188
|
-
return [payloadHash, isDefined(payload) ? payload : this.boundWitness.payload_schemas[i]];
|
|
189
|
-
})
|
|
190
|
-
);
|
|
191
|
-
}
|
|
192
|
-
get from() {
|
|
193
|
-
return this.data[0].from;
|
|
194
|
-
}
|
|
195
|
-
get payloadCount() {
|
|
196
|
-
return this.payloadsCache.length;
|
|
197
|
-
}
|
|
198
|
-
get payloads() {
|
|
199
|
-
return [...this.payloadsCache];
|
|
200
|
-
}
|
|
201
|
-
get privateExternalPayloads() {
|
|
202
|
-
const allPayloads = this.payloads;
|
|
203
|
-
return Object.fromEntries(
|
|
204
|
-
this.boundWitness.payload_hashes.flatMap((payloadHash, i) => allPayloads.every((p) => p._hash !== payloadHash) ? [[payloadHash, this.boundWitness.payload_schemas[i]]] : [])
|
|
205
|
-
);
|
|
206
|
-
}
|
|
207
|
-
// list all the payloads that are included in the transaction and are not elevated and found in the hydration
|
|
208
|
-
get publicExternalPayloads() {
|
|
209
|
-
const allPayloads = this.payloads;
|
|
210
|
-
const elevatedPayloads = this.elevatedPayloads;
|
|
211
|
-
return allPayloads.filter((p) => elevatedPayloads.every((ep) => ep._hash !== p._hash));
|
|
212
|
-
}
|
|
213
|
-
get signatureCount() {
|
|
214
|
-
return this._signatureCache.length;
|
|
215
|
-
}
|
|
216
|
-
get signatures() {
|
|
217
|
-
return [...this._signatureCache];
|
|
218
|
-
}
|
|
219
|
-
static async parse(transaction, validate = false) {
|
|
220
|
-
const wrapper = new _HydratedTransactionWrapper(
|
|
221
|
-
transaction
|
|
222
|
-
);
|
|
223
|
-
if (validate) {
|
|
224
|
-
await wrapper.parse();
|
|
225
|
-
const errors = await wrapper.validate();
|
|
226
|
-
if (errors.length > 0) {
|
|
227
|
-
throw new Error(`Block validation failed: ${errors.join(", ")}`);
|
|
228
|
-
}
|
|
229
|
-
return wrapper;
|
|
230
|
-
}
|
|
231
|
-
return await wrapper.parse();
|
|
232
|
-
}
|
|
233
|
-
elevatedPayload(index) {
|
|
234
|
-
return this.elevatedPayloads.at(index);
|
|
235
|
-
}
|
|
236
|
-
gasRequired() {
|
|
237
|
-
return transactionRequiredGas(this.data);
|
|
238
|
-
}
|
|
239
|
-
payload(index) {
|
|
240
|
-
return this.payloads.at(index);
|
|
241
|
-
}
|
|
242
|
-
reward() {
|
|
243
|
-
return this.payloadsCache.reduce((acc, payload) => acc + (isTransfer(payload) && payload.from === XYO_ZERO_ADDRESS ? sumTransfers(payload) : 0n), 0n);
|
|
244
|
-
}
|
|
245
|
-
signature(index) {
|
|
246
|
-
return this._signatureCache[index];
|
|
247
|
-
}
|
|
248
|
-
async validate() {
|
|
249
|
-
const signatureErrors = await Promise.all(this._signatureCache.map(async (signature) => signature.validate()));
|
|
250
|
-
const transactionErrors = await validateTransaction({ ...this.context, chainId: this.data[0].chain }, this.data);
|
|
251
|
-
return [...signatureErrors.flat(), ...transactionErrors];
|
|
252
|
-
}
|
|
253
|
-
async parse(validate = false) {
|
|
254
|
-
const payloadsWithHashMeta = await PayloadBuilder2.addHashMeta(this.data[1]);
|
|
255
|
-
const transactionPayloads = payloadsWithHashMeta.filter(isAllowedBlockPayload);
|
|
256
|
-
this._signatureCache = await createSignatureWrappers(this.data[0]);
|
|
257
|
-
for (const payload of transactionPayloads) {
|
|
258
|
-
this.payloadsCache.push(payload);
|
|
259
|
-
}
|
|
260
|
-
if (validate) {
|
|
261
|
-
await this.validate();
|
|
262
|
-
}
|
|
263
|
-
return this;
|
|
264
|
-
}
|
|
265
|
-
};
|
|
266
|
-
export {
|
|
267
|
-
BaseWrapper,
|
|
268
|
-
ChainWrapper,
|
|
269
|
-
FeesWrapper,
|
|
270
|
-
HydratedTransactionWrapper,
|
|
271
|
-
SignatureWrapper,
|
|
272
|
-
createSignatureWrappers
|
|
273
|
-
};
|
|
1
|
+
// src/index.ts
|
|
2
|
+
export * from "@xyo-network/xl1-sdk/wrappers";
|
|
274
3
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/
|
|
4
|
-
"sourcesContent": ["import type { PromisableArray } from '@ariestools/sdk'\nimport type { XyoConnection } from '@xyo-network/xl1-protocol-lib'\n\n/** Configuration for a base wrapper, providing a connection and a value to wrap. */\nexport interface BaseWrapperConfig<T> {\n provider: XyoConnection\n value: T\n}\n\n/** Abstract base class for protocol value wrappers with validation support. */\nexport class BaseWrapper<T, C extends BaseWrapperConfig<T> = BaseWrapperConfig<T>> {\n protected readonly config: Partial<C>\n protected readonly value: T\n protected constructor(value: T, config: Partial<C> = {}) {\n this.config = config\n this.value = value\n }\n\n get provider(): XyoConnection | undefined {\n return this.config.provider\n }\n\n static async create<T, C extends BaseWrapperConfig<T> = BaseWrapperConfig<T>>(value: T, config: Partial<C> = {}) {\n const valueErrors = await this.validateValue(value)\n if (valueErrors.length > 0) {\n throw new Error(`Invalid value for ${this.constructor.name}: ${String(value)}`)\n }\n const configErrors = await this.validateConfig(config)\n if (configErrors.length > 0) {\n throw new Error(`Invalid config for ${this.constructor.name}: ${JSON.stringify(config)}`)\n }\n return Reflect.construct(this, [value, config]) as BaseWrapper<T, C>\n }\n\n static validateConfig(_config: unknown): PromisableArray<Error> {\n return []\n }\n\n static validateValue(_value: unknown): PromisableArray<Error> {\n return []\n }\n\n validate(): PromisableArray<Error> {\n return []\n }\n}\n", "import type { Address } from '@ariestools/sdk'\n\nimport type { BaseWrapperConfig } from '../Base.ts'\nimport { BaseWrapper } from '../Base.ts'\n\n/** Wrapper for a chain identifier address. */\nexport class ChainWrapper extends BaseWrapper<Address, BaseWrapperConfig<Address>> {\n get id(): Address {\n return this.value\n }\n}\n", "import type { Hex, Promisable } from '@ariestools/sdk'\nimport { hexToBigInt } from '@ariestools/sdk'\nimport type { TransactionFeesBigInt, TransactionFeesHex } from '@xyo-network/xl1-protocol-lib'\nimport { AttoXL1 } from '@xyo-network/xl1-protocol-lib'\nimport type { TransactionFeesInstance } from '@xyo-network/xl1-protocol-sdk'\n\nfunction parseHexOrBigInt(value: Hex | bigint) {\n return AttoXL1((typeof value === 'bigint' ? value : hexToBigInt(value)))\n}\n\n/** Wrapper for transaction fee fields (base, gasLimit, gasPrice, priority) with validation. */\nexport class FeesWrapper implements TransactionFeesInstance {\n base: AttoXL1\n gasLimit: AttoXL1\n gasPrice: AttoXL1\n priority: AttoXL1\n\n constructor({\n base, gasLimit, gasPrice, priority,\n }: TransactionFeesHex | TransactionFeesBigInt) {\n this.base = parseHexOrBigInt(base)\n this.gasLimit = parseHexOrBigInt(gasLimit)\n this.gasPrice = parseHexOrBigInt(gasPrice)\n this.priority = parseHexOrBigInt(priority)\n }\n\n static validate({\n base, gasLimit, gasPrice, priority,\n }: TransactionFeesHex | TransactionFeesBigInt): Promisable<Error[]> {\n const errors: Error[] = []\n const baseValue = parseHexOrBigInt(base)\n const gasLimitValue = parseHexOrBigInt(gasLimit)\n const gasPriceValue = parseHexOrBigInt(gasPrice)\n const priorityValue = parseHexOrBigInt(priority)\n if (baseValue <= 0n) {\n errors.push(new Error('Base fee cannot be negative or zero'))\n }\n if (gasLimitValue < 0n) {\n errors.push(new Error('Gas limit cannot be negative'))\n }\n if (gasPriceValue < 0n) {\n errors.push(new Error('Gas price cannot be negative'))\n }\n if (priorityValue < 0n) {\n errors.push(new Error('Priority cannot be negative'))\n }\n return errors\n }\n\n async validate(): Promise<Error[]> {\n return await FeesWrapper.validate({\n base: this.base, gasLimit: this.gasLimit, gasPrice: this.gasPrice, priority: this.priority,\n })\n }\n}\n", "import { asHex } from '@ariestools/sdk'\nimport type { BoundWitness } from '@xyo-network/sdk'\nimport { PayloadBuilder } from '@xyo-network/sdk'\nimport type { SignatureInstance } from '@xyo-network/xl1-protocol-sdk'\n\nimport { SignatureWrapper } from '../Signature.ts'\n\n/** Creates SignatureWrapper instances for each signature in a BoundWitness. */\nexport const createSignatureWrappers = async (bw: BoundWitness): Promise<SignatureInstance[]> => {\n const signatures: SignatureInstance[] = []\n const hash = await PayloadBuilder.dataHash(bw)\n for (let i = 0; i < bw.$signatures.length; i++) {\n signatures.push(\n new SignatureWrapper(asHex(bw.$signatures[i], true), bw.addresses[i], hash),\n )\n }\n return signatures\n}\n", "import type { Hash, Hex } from '@ariestools/sdk'\nimport { toArrayBuffer } from '@ariestools/sdk'\nimport type { XyoAddress } from '@xyo-network/sdk'\nimport { BoundWitnessValidator } from '@xyo-network/sdk'\nimport type { SignatureInstance } from '@xyo-network/xl1-protocol-sdk'\n\n/** Wrapper for cryptographic signatures with validation against BoundWitness hashes. */\nexport class SignatureWrapper implements SignatureInstance {\n address: XyoAddress\n hash: Hash\n signature: Hex\n\n constructor(signature: Hex, address: XyoAddress, hash: Hash) {\n this.signature = signature\n this.address = address\n this.hash = hash\n }\n\n static async validate(hash: Hash, address: XyoAddress, signature: Hex): Promise<Error[]> {\n return await BoundWitnessValidator.validateSignature(toArrayBuffer(hash), address, toArrayBuffer(signature))\n }\n\n async validate(): Promise<Error[]> {\n return await SignatureWrapper.validate(this.hash, this.address, this.signature)\n }\n}\n", "import type { Hash, Hex } from '@ariestools/sdk'\nimport { hexToBigInt, isDefined } from '@ariestools/sdk'\nimport type {\n Payload, Schema,\n WithHashMeta,\n} from '@xyo-network/sdk'\nimport { PayloadBuilder } from '@xyo-network/sdk'\nimport type {\n AllowedBlockPayload, BaseContext, HydratedTransactionWithHashMeta, Transfer,\n} from '@xyo-network/xl1-protocol-lib'\nimport {\n elevatedTransaction, isAllowedBlockPayload, isTransfer, tryExtractElevatedHashes, tryExtractElevatedHashesFromScript, XYO_ZERO_ADDRESS,\n} from '@xyo-network/xl1-protocol-lib'\nimport type {\n HydratedTransactionInstance, SignatureInstance,\n TransactionFeesInstance,\n} from '@xyo-network/xl1-protocol-sdk'\nimport { transactionRequiredGas } from '@xyo-network/xl1-protocol-sdk'\nimport { validateTransaction } from '@xyo-network/xl1-validation'\n\nimport { FeesWrapper } from '../Fees.ts'\nimport { createSignatureWrappers } from '../lib/index.ts'\n\nconst sumTransfers = (payload: Transfer) => {\n let total = 0n\n for (const i of Object.values(payload.transfers)) {\n total += hexToBigInt(i ?? '00' as Hex)\n }\n return total\n}\n\n/** Context for hydrated transaction wrapper operations. */\nexport interface HydratedTransactionWrapperContext extends BaseContext {\n\n}\n\n/** Wrapper for a hydrated transaction providing access to payloads, signatures, fees, and validation. */\nexport class HydratedTransactionWrapper<T extends HydratedTransactionWithHashMeta> implements HydratedTransactionInstance<T> {\n data: T\n fees: TransactionFeesInstance\n\n protected context: HydratedTransactionWrapperContext\n protected payloadsCache: WithHashMeta<AllowedBlockPayload & T[1][number]>[] = []\n\n private _signatureCache: SignatureInstance[] = []\n\n protected constructor(data: T, context?: HydratedTransactionWrapperContext) {\n this.context = context ?? { singletons: {} }\n this.data = data\n this.fees = new FeesWrapper(\n this.boundWitness.fees,\n )\n }\n\n get boundWitness(): T[0] {\n return this.data[0]\n }\n\n /**\n * A copy of the transaction that excludes non-elevated payloads \u2014 i.e. only what ends up on chain.\n */\n get elevated(): HydratedTransactionWithHashMeta {\n return elevatedTransaction(this.data)\n }\n\n get elevatedPayloadCount(): number {\n const { script } = this.data[0]\n return script ? tryExtractElevatedHashesFromScript(script).length : 0\n }\n\n get elevatedPayloads() {\n return tryExtractElevatedHashes(this.data) as WithHashMeta<AllowedBlockPayload & T[1][number]>[]\n }\n\n get externalPayloads(): Record<Hash, Schema | Payload> {\n const allPayloads = this.payloads\n return Object.fromEntries(\n this.boundWitness.payload_hashes.map((payloadHash, i) => {\n const payload = allPayloads.find(p => p._hash === payloadHash)\n return [payloadHash, isDefined(payload) ? payload : this.boundWitness.payload_schemas[i]]\n }),\n )\n }\n\n get from() {\n return this.data[0].from\n }\n\n get payloadCount(): number {\n return this.payloadsCache.length\n }\n\n get payloads(): WithHashMeta<WithHashMeta<T[1][number]>>[] {\n return [...this.payloadsCache]\n }\n\n get privateExternalPayloads(): Record<Hash, Schema> {\n const allPayloads = this.payloads\n return Object.fromEntries(\n this.boundWitness.payload_hashes.flatMap((payloadHash, i) => (\n allPayloads.every(p => p._hash !== payloadHash)\n ? [[payloadHash, this.boundWitness.payload_schemas[i]]]\n : []\n )),\n )\n }\n\n // list all the payloads that are included in the transaction and are not elevated and found in the hydration\n get publicExternalPayloads(): Payload[] {\n const allPayloads = this.payloads\n const elevatedPayloads = this.elevatedPayloads\n return allPayloads.filter(p => elevatedPayloads.every(ep => ep._hash !== p._hash))\n }\n\n get signatureCount(): number {\n return this._signatureCache.length\n }\n\n get signatures(): SignatureInstance[] {\n return [...this._signatureCache]\n }\n\n static async parse<T extends HydratedTransactionWithHashMeta>(transaction: T, validate = false): Promise<HydratedTransactionInstance<[T[0],\n T[1][number][]]>> {\n const wrapper = new HydratedTransactionWrapper<T>(\n transaction,\n )\n if (validate) {\n await wrapper.parse()\n const errors = await wrapper.validate()\n if (errors.length > 0) {\n throw new Error(`Block validation failed: ${errors.join(', ')}`)\n }\n return wrapper\n }\n return await wrapper.parse()\n }\n\n elevatedPayload(index: number): WithHashMeta<AllowedBlockPayload & T[1][number]> | undefined {\n return this.elevatedPayloads.at(index)\n }\n\n gasRequired(): bigint {\n return transactionRequiredGas(this.data)\n }\n\n payload(index: number) {\n return this.payloads.at(index) as WithHashMeta<AllowedBlockPayload & T[1][number]>\n }\n\n reward(): bigint {\n return this.payloadsCache.reduce((acc: bigint, payload) => acc + (\n isTransfer(payload) && (payload.from === XYO_ZERO_ADDRESS) ? sumTransfers(payload) : 0n), 0n)\n }\n\n signature(index: number): SignatureInstance | undefined {\n return this._signatureCache[index]\n }\n\n async validate(): Promise<Error[]> {\n const signatureErrors = await Promise.all(this._signatureCache.map(async signature => signature.validate()))\n const transactionErrors = await validateTransaction({ ...this.context, chainId: this.data[0].chain }, this.data)\n return [...signatureErrors.flat(), ...transactionErrors]\n }\n\n protected async parse(validate = false): Promise<HydratedTransactionInstance<[WithHashMeta<T[0]>, WithHashMeta<T[1][number]>[]]>> {\n const payloadsWithHashMeta = await PayloadBuilder.addHashMeta(this.data[1])\n const transactionPayloads = payloadsWithHashMeta.filter(isAllowedBlockPayload)\n this._signatureCache = await createSignatureWrappers(this.data[0])\n for (const payload of transactionPayloads) {\n this.payloadsCache.push(payload)\n }\n if (validate) {\n await this.validate()\n }\n return this\n }\n}\n"],
|
|
5
|
-
"mappings": ";
|
|
6
|
-
"names": [
|
|
3
|
+
"sources": ["../../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["// Compatibility shim: this package re-exports from @xyo-network/xl1-sdk.\nexport * from '@xyo-network/xl1-sdk/wrappers'\n"],
|
|
5
|
+
"mappings": ";AACA,cAAc;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@xyo-network/xl1-wrappers",
|
|
4
|
-
"version": "4.0.
|
|
4
|
+
"version": "4.0.12",
|
|
5
5
|
"description": "XYO Layer One SDK Wrappers",
|
|
6
6
|
"homepage": "https://xylabs.com",
|
|
7
7
|
"bugs": {
|
|
@@ -35,63 +35,54 @@
|
|
|
35
35
|
"README.md"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@xyo-network/xl1-
|
|
39
|
-
"@xyo-network/xl1-protocol-sdk": "~4.0.10",
|
|
40
|
-
"@xyo-network/xl1-validation": "~4.0.10"
|
|
38
|
+
"@xyo-network/xl1-sdk": "~4.0.12"
|
|
41
39
|
},
|
|
42
40
|
"devDependencies": {
|
|
43
|
-
"@ariestools/sdk": "~
|
|
41
|
+
"@ariestools/sdk": "~8.0.3",
|
|
42
|
+
"@ariestools/threads": "~8.0.3",
|
|
44
43
|
"@bitauth/libauth": "~3.0.0",
|
|
44
|
+
"@metamask/json-rpc-engine": "~10.5.0",
|
|
45
45
|
"@metamask/providers": "~22.1.1",
|
|
46
46
|
"@noble/post-quantum": "~0.6.1",
|
|
47
47
|
"@opentelemetry/api": "~1.9.1",
|
|
48
48
|
"@opentelemetry/sdk-trace-base": "~2.9.0",
|
|
49
49
|
"@scure/base": "~2.2.0",
|
|
50
50
|
"@scure/bip39": "~2.2.0",
|
|
51
|
-
"@xylabs/
|
|
52
|
-
"@xylabs/
|
|
53
|
-
"@
|
|
54
|
-
"@
|
|
55
|
-
"@xyo-network/sdk": "~7.0.8",
|
|
56
|
-
"@xyo-network/sdk-protocol": "~7.0.13",
|
|
51
|
+
"@xylabs/toolchain": "~8.6.10",
|
|
52
|
+
"@xylabs/tsconfig": "~8.6.10",
|
|
53
|
+
"@xyo-network/sdk": "~7.0.11",
|
|
54
|
+
"@xyo-network/sdk-protocol": "~7.0.15",
|
|
57
55
|
"ajv": "~8.20.0",
|
|
58
56
|
"async-mutex": "~0.5.0",
|
|
59
|
-
"cosmiconfig": "~9.0.2",
|
|
60
57
|
"debug": "~4.4.3",
|
|
61
58
|
"eslint": "~10.6.0",
|
|
62
59
|
"ethers": "~6.17.0",
|
|
63
60
|
"hash-wasm": "~4.12.0",
|
|
64
61
|
"idb": "~8.0.3",
|
|
65
|
-
"lru-cache": "~11.5.1",
|
|
66
62
|
"observable-fns": "~0.6.1",
|
|
67
63
|
"typescript": "~6.0.3",
|
|
68
|
-
"vite": "~8.1.3",
|
|
69
|
-
"vitest": "~4.1.9",
|
|
70
64
|
"webextension-polyfill": "~0.12.0",
|
|
71
|
-
"zod": "~4.4.3"
|
|
72
|
-
"@xyo-network/xl1-test": "~4.0.10"
|
|
65
|
+
"zod": "~4.4.3"
|
|
73
66
|
},
|
|
74
67
|
"peerDependencies": {
|
|
75
|
-
"@ariestools/sdk": "^
|
|
68
|
+
"@ariestools/sdk": "^8.0.3",
|
|
69
|
+
"@ariestools/threads": "^8.0.3",
|
|
76
70
|
"@bitauth/libauth": "^3.0.0",
|
|
71
|
+
"@metamask/json-rpc-engine": "^10.5.0",
|
|
77
72
|
"@metamask/providers": "^22.1.1",
|
|
78
73
|
"@noble/post-quantum": "^0.6.1",
|
|
79
74
|
"@opentelemetry/api": "^1.9.1",
|
|
80
75
|
"@opentelemetry/sdk-trace-base": "^2.9.0",
|
|
81
76
|
"@scure/base": "^2.2.0",
|
|
82
77
|
"@scure/bip39": "^2.2.0",
|
|
83
|
-
"@
|
|
84
|
-
"@
|
|
85
|
-
"@xyo-network/sdk": "^7.0.8",
|
|
86
|
-
"@xyo-network/sdk-protocol": "^7.0.13",
|
|
78
|
+
"@xyo-network/sdk": "^7.0.11",
|
|
79
|
+
"@xyo-network/sdk-protocol": "^7.0.15",
|
|
87
80
|
"ajv": "^8.20.0",
|
|
88
81
|
"async-mutex": "^0.5.0",
|
|
89
|
-
"cosmiconfig": "^9.0.2",
|
|
90
82
|
"debug": "^4.4.3",
|
|
91
83
|
"ethers": "^6.17.0",
|
|
92
84
|
"hash-wasm": "^4.12.0",
|
|
93
85
|
"idb": "^8.0.3",
|
|
94
|
-
"lru-cache": "^11.5.1",
|
|
95
86
|
"observable-fns": "^0.6.1",
|
|
96
87
|
"webextension-polyfill": "^0.12.0",
|
|
97
88
|
"zod": "^4.4.3"
|
|
@@ -102,5 +93,6 @@
|
|
|
102
93
|
"engineStrict": true,
|
|
103
94
|
"publishConfig": {
|
|
104
95
|
"access": "public"
|
|
105
|
-
}
|
|
96
|
+
},
|
|
97
|
+
"deprecated": "Use @xyo-network/xl1-sdk/wrappers instead. Replace @xyo-network/xl1-wrappers with @xyo-network/xl1-sdk/wrappers. This package is a compatibility shim only and will not receive further updates."
|
|
106
98
|
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { Promisable } from '@ariestools/sdk';
|
|
2
|
-
import { type XyoAddress } from '@xyo-network/sdk';
|
|
3
|
-
import type { AddressInstance } from '@xyo-network/xl1-protocol-sdk';
|
|
4
|
-
import { BaseWrapper } from './Base.ts';
|
|
5
|
-
/** Wrapper around an Ethereum-style address with validation. */
|
|
6
|
-
export declare class AddressWrapper extends BaseWrapper<XyoAddress> implements AddressInstance {
|
|
7
|
-
get address(): XyoAddress;
|
|
8
|
-
static validateValue(address: unknown): Promisable<Error[]>;
|
|
9
|
-
validate(): Promise<Error[]>;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=Address.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Address.d.ts","sourceRoot":"","sources":["../../src/Address.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAEpE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAEvC,gEAAgE;AAChE,qBAAa,cAAe,SAAQ,WAAW,CAAC,UAAU,CAAE,YAAW,eAAe;IACpF,IAAI,OAAO,IAAI,UAAU,CAExB;WAEe,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,UAAU,CAAC,KAAK,EAAE,CAAC;IAIrD,QAAQ,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;CAG5C"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Promisable } from '@ariestools/sdk';
|
|
2
|
-
import type { XL1AmountInstance } from '@xyo-network/xl1-protocol-lib';
|
|
3
|
-
import type { AddressStateInstance, BlockWindowInstance } from '@xyo-network/xl1-protocol-sdk';
|
|
4
|
-
import { AddressWrapper } from './Address.ts';
|
|
5
|
-
/** Wrapper for an address with associated block window and balance state. */
|
|
6
|
-
export declare class AddressStateWrapper extends AddressWrapper implements AddressStateInstance {
|
|
7
|
-
get blockWindow(): BlockWindowInstance;
|
|
8
|
-
balance(): Promisable<[XL1AmountInstance, BlockWindowInstance]>;
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=AddressState.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AddressState.d.ts","sourceRoot":"","sources":["../../src/AddressState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AACtE,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,+BAA+B,CAAA;AAEtC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAE7C,6EAA6E;AAC7E,qBAAa,mBAAoB,SAAQ,cAAe,YAAW,oBAAoB;IACrF,IAAI,WAAW,IAAI,mBAAmB,CAErC;IAED,OAAO,IAAI,UAAU,CAAC,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,CAAC;CAGhE"}
|
package/dist/neutral/Base.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { PromisableArray } from '@ariestools/sdk';
|
|
2
|
-
import type { XyoConnection } from '@xyo-network/xl1-protocol-lib';
|
|
3
|
-
/** Configuration for a base wrapper, providing a connection and a value to wrap. */
|
|
4
|
-
export interface BaseWrapperConfig<T> {
|
|
5
|
-
provider: XyoConnection;
|
|
6
|
-
value: T;
|
|
7
|
-
}
|
|
8
|
-
/** Abstract base class for protocol value wrappers with validation support. */
|
|
9
|
-
export declare class BaseWrapper<T, C extends BaseWrapperConfig<T> = BaseWrapperConfig<T>> {
|
|
10
|
-
protected readonly config: Partial<C>;
|
|
11
|
-
protected readonly value: T;
|
|
12
|
-
protected constructor(value: T, config?: Partial<C>);
|
|
13
|
-
get provider(): XyoConnection | undefined;
|
|
14
|
-
static create<T, C extends BaseWrapperConfig<T> = BaseWrapperConfig<T>>(value: T, config?: Partial<C>): Promise<BaseWrapper<T, C>>;
|
|
15
|
-
static validateConfig(_config: unknown): PromisableArray<Error>;
|
|
16
|
-
static validateValue(_value: unknown): PromisableArray<Error>;
|
|
17
|
-
validate(): PromisableArray<Error>;
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=Base.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Base.d.ts","sourceRoot":"","sources":["../../src/Base.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAElE,oFAAoF;AACpF,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,QAAQ,EAAE,aAAa,CAAA;IACvB,KAAK,EAAE,CAAC,CAAA;CACT;AAED,+EAA+E;AAC/E,qBAAa,WAAW,CAAC,CAAC,EAAE,CAAC,SAAS,iBAAiB,CAAC,CAAC,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC;IAC/E,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAA;IACrC,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;IAC3B,SAAS,aAAa,KAAK,EAAE,CAAC,EAAE,MAAM,GAAE,OAAO,CAAC,CAAC,CAAM;IAKvD,IAAI,QAAQ,IAAI,aAAa,GAAG,SAAS,CAExC;WAEY,MAAM,CAAC,CAAC,EAAE,CAAC,SAAS,iBAAiB,CAAC,CAAC,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,GAAE,OAAO,CAAC,CAAC,CAAM;IAY/G,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,eAAe,CAAC,KAAK,CAAC;IAI/D,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,OAAO,GAAG,eAAe,CAAC,KAAK,CAAC;IAI7D,QAAQ,IAAI,eAAe,CAAC,KAAK,CAAC;CAGnC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { Hash, Promisable } from '@ariestools/sdk';
|
|
2
|
-
import type { HydratedBlock } from '@xyo-network/xl1-protocol-lib';
|
|
3
|
-
import type { BlockWindowInstance } from '@xyo-network/xl1-protocol-sdk';
|
|
4
|
-
/** Navigable store of hydrated blocks within a block window range. */
|
|
5
|
-
export interface HydratedBlockRangeStore extends BlockWindowInstance {
|
|
6
|
-
first(): Promisable<HydratedBlock>;
|
|
7
|
-
fromHash(hash: Hash): Promisable<HydratedBlock>;
|
|
8
|
-
fromNumber(number: number): Promisable<HydratedBlock>;
|
|
9
|
-
last(): Promisable<HydratedBlock>;
|
|
10
|
-
next(): Promisable<HydratedBlock>;
|
|
11
|
-
next(count: number): Promisable<HydratedBlock[]>;
|
|
12
|
-
prev(): Promisable<HydratedBlock>;
|
|
13
|
-
prev(count: number): Promisable<HydratedBlock[]>;
|
|
14
|
-
}
|
|
15
|
-
/** Wrapper that exposes block window properties from a HydratedBlockRangeStore. */
|
|
16
|
-
export declare class BlockWindowWrapper implements BlockWindowInstance {
|
|
17
|
-
private _store;
|
|
18
|
-
constructor(store: HydratedBlockRangeStore);
|
|
19
|
-
get count(): number;
|
|
20
|
-
get numberRange(): [number, number];
|
|
21
|
-
get range(): [import("@ariestools/sdk").BrandedHash, import("@ariestools/sdk").BrandedHash];
|
|
22
|
-
static validate(_store: HydratedBlockRangeStore): Promisable<Error[]>;
|
|
23
|
-
validate(): Promise<Error[]>;
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=BlockWindow.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BlockWindow.d.ts","sourceRoot":"","sources":["../../src/BlockWindow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAClE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AAExE,sEAAsE;AACtE,MAAM,WAAW,uBAAwB,SAAQ,mBAAmB;IAClE,KAAK,IAAI,UAAU,CAAC,aAAa,CAAC,CAAA;IAClC,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,UAAU,CAAC,aAAa,CAAC,CAAA;IAC/C,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC,aAAa,CAAC,CAAA;IACrD,IAAI,IAAI,UAAU,CAAC,aAAa,CAAC,CAAA;IACjC,IAAI,IAAI,UAAU,CAAC,aAAa,CAAC,CAAA;IACjC,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAAC,aAAa,EAAE,CAAC,CAAA;IAChD,IAAI,IAAI,UAAU,CAAC,aAAa,CAAC,CAAA;IACjC,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAAC,aAAa,EAAE,CAAC,CAAA;CACjD;AAED,mFAAmF;AACnF,qBAAa,kBAAmB,YAAW,mBAAmB;IAC5D,OAAO,CAAC,MAAM,CAAyB;gBAE3B,KAAK,EAAE,uBAAuB;IAI1C,IAAI,KAAK,WAER;IAED,IAAI,WAAW,qBAEd;IAED,IAAI,KAAK,mFAER;IAED,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,uBAAuB,GAAG,UAAU,CAAC,KAAK,EAAE,CAAC;IAI/D,QAAQ,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;CAGnC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Promisable } from '@ariestools/sdk';
|
|
2
|
-
import type { XyoAddress } from '@xyo-network/sdk';
|
|
3
|
-
import type { HydratedBlockRangeStore } from './BlockWindow.ts';
|
|
4
|
-
/** Interface for querying address balances within a block window. */
|
|
5
|
-
export interface BlockWindowBalanceCacheInstance {
|
|
6
|
-
balance(address: XyoAddress): Promisable<bigint>;
|
|
7
|
-
}
|
|
8
|
-
/** Cache for looking up account balances within a hydrated block range. */
|
|
9
|
-
export declare class BlockWindowBalanceCache implements BlockWindowBalanceCacheInstance {
|
|
10
|
-
private _store;
|
|
11
|
-
constructor(store: HydratedBlockRangeStore);
|
|
12
|
-
balance(_address: XyoAddress): Promisable<bigint>;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=BlockWindowBalanceCache.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BlockWindowBalanceCache.d.ts","sourceRoot":"","sources":["../../src/BlockWindowBalanceCache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAElD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAE/D,qEAAqE;AACrE,MAAM,WAAW,+BAA+B;IAC9C,OAAO,CAAC,OAAO,EAAE,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC,CAAA;CACjD;AAED,2EAA2E;AAC3E,qBAAa,uBAAwB,YAAW,+BAA+B;IAC7E,OAAO,CAAC,MAAM,CAAyB;gBAE3B,KAAK,EAAE,uBAAuB;IAI1C,OAAO,CAAC,QAAQ,EAAE,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC;CAGlD"}
|
package/dist/neutral/Fees.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { Promisable } from '@ariestools/sdk';
|
|
2
|
-
import type { TransactionFeesBigInt, TransactionFeesHex } from '@xyo-network/xl1-protocol-lib';
|
|
3
|
-
import { AttoXL1 } from '@xyo-network/xl1-protocol-lib';
|
|
4
|
-
import type { TransactionFeesInstance } from '@xyo-network/xl1-protocol-sdk';
|
|
5
|
-
/** Wrapper for transaction fee fields (base, gasLimit, gasPrice, priority) with validation. */
|
|
6
|
-
export declare class FeesWrapper implements TransactionFeesInstance {
|
|
7
|
-
base: AttoXL1;
|
|
8
|
-
gasLimit: AttoXL1;
|
|
9
|
-
gasPrice: AttoXL1;
|
|
10
|
-
priority: AttoXL1;
|
|
11
|
-
constructor({ base, gasLimit, gasPrice, priority, }: TransactionFeesHex | TransactionFeesBigInt);
|
|
12
|
-
static validate({ base, gasLimit, gasPrice, priority, }: TransactionFeesHex | TransactionFeesBigInt): Promisable<Error[]>;
|
|
13
|
-
validate(): Promise<Error[]>;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=Fees.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Fees.d.ts","sourceRoot":"","sources":["../../src/Fees.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAO,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEtD,OAAO,KAAK,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AAC9F,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAA;AACvD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAA;AAM5E,+FAA+F;AAC/F,qBAAa,WAAY,YAAW,uBAAuB;IACzD,IAAI,EAAE,OAAO,CAAA;IACb,QAAQ,EAAE,OAAO,CAAA;IACjB,QAAQ,EAAE,OAAO,CAAA;IACjB,QAAQ,EAAE,OAAO,CAAA;gBAEL,EACV,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,GACnC,EAAE,kBAAkB,GAAG,qBAAqB;IAO7C,MAAM,CAAC,QAAQ,CAAC,EACd,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,GACnC,EAAE,kBAAkB,GAAG,qBAAqB,GAAG,UAAU,CAAC,KAAK,EAAE,CAAC;IAqB7D,QAAQ,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;CAKnC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Hash, Hex } from '@ariestools/sdk';
|
|
2
|
-
import type { XyoAddress } from '@xyo-network/sdk';
|
|
3
|
-
import type { SignatureInstance } from '@xyo-network/xl1-protocol-sdk';
|
|
4
|
-
/** Wrapper for cryptographic signatures with validation against BoundWitness hashes. */
|
|
5
|
-
export declare class SignatureWrapper implements SignatureInstance {
|
|
6
|
-
address: XyoAddress;
|
|
7
|
-
hash: Hash;
|
|
8
|
-
signature: Hex;
|
|
9
|
-
constructor(signature: Hex, address: XyoAddress, hash: Hash);
|
|
10
|
-
static validate(hash: Hash, address: XyoAddress, signature: Hex): Promise<Error[]>;
|
|
11
|
-
validate(): Promise<Error[]>;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=Signature.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Signature.d.ts","sourceRoot":"","sources":["../../src/Signature.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAEhD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAElD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AAEtE,wFAAwF;AACxF,qBAAa,gBAAiB,YAAW,iBAAiB;IACxD,OAAO,EAAE,UAAU,CAAA;IACnB,IAAI,EAAE,IAAI,CAAA;IACV,SAAS,EAAE,GAAG,CAAA;gBAEF,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI;WAM9C,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAIlF,QAAQ,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;CAGnC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { Address } from '@ariestools/sdk';
|
|
2
|
-
import type { BaseWrapperConfig } from '../Base.ts';
|
|
3
|
-
import { BaseWrapper } from '../Base.ts';
|
|
4
|
-
/** Wrapper for a chain identifier address. */
|
|
5
|
-
export declare class ChainWrapper extends BaseWrapper<Address, BaseWrapperConfig<Address>> {
|
|
6
|
-
get id(): Address;
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=chain.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../../../src/chain/chain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAE9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAExC,8CAA8C;AAC9C,qBAAa,YAAa,SAAQ,WAAW,CAAC,OAAO,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAChF,IAAI,EAAE,IAAI,OAAO,CAEhB;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/chain/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { BoundWitness } from '@xyo-network/sdk';
|
|
2
|
-
import type { SignatureInstance } from '@xyo-network/xl1-protocol-sdk';
|
|
3
|
-
/** Creates SignatureWrapper instances for each signature in a BoundWitness. */
|
|
4
|
-
export declare const createSignatureWrappers: (bw: BoundWitness) => Promise<SignatureInstance[]>;
|
|
5
|
-
//# sourceMappingURL=createSignatureWrappers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createSignatureWrappers.d.ts","sourceRoot":"","sources":["../../../src/lib/createSignatureWrappers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAEpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AAItE,+EAA+E;AAC/E,eAAO,MAAM,uBAAuB,GAAU,IAAI,YAAY,KAAG,OAAO,CAAC,iBAAiB,EAAE,CAS3F,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAA"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import type { Hash } from '@ariestools/sdk';
|
|
2
|
-
import type { Payload, Schema, WithHashMeta } from '@xyo-network/sdk';
|
|
3
|
-
import type { AllowedBlockPayload, BaseContext, HydratedTransactionWithHashMeta } from '@xyo-network/xl1-protocol-lib';
|
|
4
|
-
import type { HydratedTransactionInstance, SignatureInstance, TransactionFeesInstance } from '@xyo-network/xl1-protocol-sdk';
|
|
5
|
-
/** Context for hydrated transaction wrapper operations. */
|
|
6
|
-
export interface HydratedTransactionWrapperContext extends BaseContext {
|
|
7
|
-
}
|
|
8
|
-
/** Wrapper for a hydrated transaction providing access to payloads, signatures, fees, and validation. */
|
|
9
|
-
export declare class HydratedTransactionWrapper<T extends HydratedTransactionWithHashMeta> implements HydratedTransactionInstance<T> {
|
|
10
|
-
data: T;
|
|
11
|
-
fees: TransactionFeesInstance;
|
|
12
|
-
protected context: HydratedTransactionWrapperContext;
|
|
13
|
-
protected payloadsCache: WithHashMeta<AllowedBlockPayload & T[1][number]>[];
|
|
14
|
-
private _signatureCache;
|
|
15
|
-
protected constructor(data: T, context?: HydratedTransactionWrapperContext);
|
|
16
|
-
get boundWitness(): T[0];
|
|
17
|
-
/**
|
|
18
|
-
* A copy of the transaction that excludes non-elevated payloads — i.e. only what ends up on chain.
|
|
19
|
-
*/
|
|
20
|
-
get elevated(): HydratedTransactionWithHashMeta;
|
|
21
|
-
get elevatedPayloadCount(): number;
|
|
22
|
-
get elevatedPayloads(): WithHashMeta<AllowedBlockPayload & T[1][number]>[];
|
|
23
|
-
get externalPayloads(): Record<Hash, Schema | Payload>;
|
|
24
|
-
get from(): import("@xyo-network/sdk").XyoQuantAddress | (Lowercase<string> & {
|
|
25
|
-
readonly __hex: true;
|
|
26
|
-
} & {
|
|
27
|
-
readonly __address: true;
|
|
28
|
-
});
|
|
29
|
-
get payloadCount(): number;
|
|
30
|
-
get payloads(): WithHashMeta<WithHashMeta<T[1][number]>>[];
|
|
31
|
-
get privateExternalPayloads(): Record<Hash, Schema>;
|
|
32
|
-
get publicExternalPayloads(): Payload[];
|
|
33
|
-
get signatureCount(): number;
|
|
34
|
-
get signatures(): SignatureInstance[];
|
|
35
|
-
static parse<T extends HydratedTransactionWithHashMeta>(transaction: T, validate?: boolean): Promise<HydratedTransactionInstance<[
|
|
36
|
-
T[0],
|
|
37
|
-
T[1][number][]
|
|
38
|
-
]>>;
|
|
39
|
-
elevatedPayload(index: number): WithHashMeta<AllowedBlockPayload & T[1][number]> | undefined;
|
|
40
|
-
gasRequired(): bigint;
|
|
41
|
-
payload(index: number): WithHashMeta<AllowedBlockPayload & T[1][number]>;
|
|
42
|
-
reward(): bigint;
|
|
43
|
-
signature(index: number): SignatureInstance | undefined;
|
|
44
|
-
validate(): Promise<Error[]>;
|
|
45
|
-
protected parse(validate?: boolean): Promise<HydratedTransactionInstance<[WithHashMeta<T[0]>, WithHashMeta<T[1][number]>[]]>>;
|
|
46
|
-
}
|
|
47
|
-
//# sourceMappingURL=HydratedTransaction.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HydratedTransaction.d.ts","sourceRoot":"","sources":["../../../src/transaction/HydratedTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAO,MAAM,iBAAiB,CAAA;AAEhD,OAAO,KAAK,EACV,OAAO,EAAE,MAAM,EACf,YAAY,EACb,MAAM,kBAAkB,CAAA;AAEzB,OAAO,KAAK,EACV,mBAAmB,EAAE,WAAW,EAAE,+BAA+B,EAClE,MAAM,+BAA+B,CAAA;AAItC,OAAO,KAAK,EACV,2BAA2B,EAAE,iBAAiB,EAC9C,uBAAuB,EACxB,MAAM,+BAA+B,CAAA;AAetC,2DAA2D;AAC3D,MAAM,WAAW,iCAAkC,SAAQ,WAAW;CAErE;AAED,yGAAyG;AACzG,qBAAa,0BAA0B,CAAC,CAAC,SAAS,+BAA+B,CAAE,YAAW,2BAA2B,CAAC,CAAC,CAAC;IAC1H,IAAI,EAAE,CAAC,CAAA;IACP,IAAI,EAAE,uBAAuB,CAAA;IAE7B,SAAS,CAAC,OAAO,EAAE,iCAAiC,CAAA;IACpD,SAAS,CAAC,aAAa,EAAE,YAAY,CAAC,mBAAmB,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAK;IAEhF,OAAO,CAAC,eAAe,CAA0B;IAEjD,SAAS,aAAa,IAAI,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,iCAAiC;IAQ1E,IAAI,YAAY,IAAI,CAAC,CAAC,CAAC,CAAC,CAEvB;IAED;;OAEG;IACH,IAAI,QAAQ,IAAI,+BAA+B,CAE9C;IAED,IAAI,oBAAoB,IAAI,MAAM,CAGjC;IAED,IAAI,gBAAgB,IAC4B,YAAY,CAAC,mBAAmB,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CACjG;IAED,IAAI,gBAAgB,IAAI,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAQrD;IAED,IAAI,IAAI;;;;OAEP;IAED,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED,IAAI,QAAQ,IAAI,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAEzD;IAED,IAAI,uBAAuB,IAAI,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CASlD;IAGD,IAAI,sBAAsB,IAAI,OAAO,EAAE,CAItC;IAED,IAAI,cAAc,IAAI,MAAM,CAE3B;IAED,IAAI,UAAU,IAAI,iBAAiB,EAAE,CAEpC;WAEY,KAAK,CAAC,CAAC,SAAS,+BAA+B,EAAE,WAAW,EAAE,CAAC,EAAE,QAAQ,UAAQ,GAAG,OAAO,CAAC,2BAA2B,CAAC;QAAC,CAAC,CAAC,CAAC,CAAC;QACxI,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE;KAAC,CAAC,CAAC;IAenB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAAC,mBAAmB,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,SAAS;IAI5F,WAAW,IAAI,MAAM;IAIrB,OAAO,CAAC,KAAK,EAAE,MAAM,GACe,YAAY,CAAC,mBAAmB,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAGpF,MAAM,IAAI,MAAM;IAKhB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS;IAIjD,QAAQ,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;cAMlB,KAAK,CAAC,QAAQ,UAAQ,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CAYlI"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transaction/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA"}
|