@xyo-network/xl1-protocol 1.3.21 → 1.3.23
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.mjs +72 -77
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/node/index.mjs +72 -77
- package/dist/node/index.mjs.map +1 -1
- package/dist/types/index.d.ts +6 -6
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +6 -6
- package/vite.config.ts +0 -30
package/dist/neutral/index.mjs
CHANGED
|
@@ -1,41 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
|
-
// src/ethereum.ts
|
|
5
|
-
import { toHex } from "@xylabs/hex";
|
|
6
|
-
import { getAddress } from "ethers";
|
|
7
|
-
import { parseUnits } from "ethers/utils";
|
|
8
|
-
var getDefaultGasConfig = /* @__PURE__ */ __name(() => {
|
|
9
|
-
return {
|
|
10
|
-
gasLimit: 2e6,
|
|
11
|
-
gasPrice: parseUnits("100", "gwei")
|
|
12
|
-
};
|
|
13
|
-
}, "getDefaultGasConfig");
|
|
14
|
-
var ETH_ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
15
|
-
var toEthAddress = /* @__PURE__ */ __name((value) => {
|
|
16
|
-
const address = typeof value === "object" ? value.address : value;
|
|
17
|
-
return getAddress(toHex(address, {
|
|
18
|
-
prefix: true,
|
|
19
|
-
bitLength: 160
|
|
20
|
-
}));
|
|
21
|
-
}, "toEthAddress");
|
|
22
|
-
|
|
23
|
-
// src/network/Status.ts
|
|
24
|
-
import { isPayloadOfSchemaType } from "@xyo-network/payload-model";
|
|
25
|
-
var NetworkStatusSchema = "network.xyo.chain.status";
|
|
26
|
-
var isNetworkStatus = isPayloadOfSchemaType(NetworkStatusSchema);
|
|
27
|
-
|
|
28
|
-
// src/Steps.ts
|
|
29
|
-
var StepSizes = [
|
|
30
|
-
10,
|
|
31
|
-
105,
|
|
32
|
-
1103,
|
|
33
|
-
11576,
|
|
34
|
-
121551,
|
|
35
|
-
1276282,
|
|
36
|
-
13400956
|
|
37
|
-
];
|
|
38
|
-
|
|
39
1
|
// src/block/AllowedBlockPayload.ts
|
|
40
2
|
import { BoundWitnessSchema } from "@xyo-network/boundwitness-model";
|
|
41
3
|
import { isHashStorageMeta, isSchema } from "@xyo-network/payload-model";
|
|
@@ -43,43 +5,43 @@ import { isSchemaPayload, SchemaSchema } from "@xyo-network/schema-payload-plugi
|
|
|
43
5
|
|
|
44
6
|
// src/payload/elevatable/ChainStakeIntent.ts
|
|
45
7
|
import { AsObjectFactory } from "@xylabs/object";
|
|
46
|
-
import { isPayloadOfSchemaType
|
|
8
|
+
import { isPayloadOfSchemaType } from "@xyo-network/payload-model";
|
|
47
9
|
var ChainStakeIntentSchema = "network.xyo.chain.stake.intent";
|
|
48
|
-
var isChainStakeIntent =
|
|
49
|
-
return
|
|
50
|
-
}
|
|
10
|
+
var isChainStakeIntent = (x) => {
|
|
11
|
+
return isPayloadOfSchemaType(ChainStakeIntentSchema)(x) && asNonNegativeInteger(x.nbf) !== void 0 && asNonNegativeInteger(x.exp) !== void 0;
|
|
12
|
+
};
|
|
51
13
|
var asChainStakeIntent = AsObjectFactory.create(isChainStakeIntent);
|
|
52
14
|
var asOptionalChainStakeIntent = AsObjectFactory.createOptional(isChainStakeIntent);
|
|
53
|
-
var asNonNegativeInteger =
|
|
15
|
+
var asNonNegativeInteger = (num) => {
|
|
54
16
|
return Number.isInteger(num) && num >= 0 ? num : void 0;
|
|
55
|
-
}
|
|
17
|
+
};
|
|
56
18
|
|
|
57
19
|
// src/payload/elevatable/Executable.ts
|
|
58
20
|
import { isAnyPayload } from "@xyo-network/payload-model";
|
|
59
|
-
var hasFrom =
|
|
21
|
+
var hasFrom = (value) => {
|
|
60
22
|
return value.from !== void 0;
|
|
61
|
-
}
|
|
62
|
-
var isExecutable =
|
|
23
|
+
};
|
|
24
|
+
var isExecutable = (value) => {
|
|
63
25
|
return isAnyPayload(value) && Array.isArray(value.script);
|
|
64
|
-
}
|
|
65
|
-
var asExecutable =
|
|
26
|
+
};
|
|
27
|
+
var asExecutable = (value) => {
|
|
66
28
|
return isExecutable(value) ? value : void 0;
|
|
67
|
-
}
|
|
29
|
+
};
|
|
68
30
|
|
|
69
31
|
// src/payload/elevatable/Hash.ts
|
|
70
32
|
import { AsObjectFactory as AsObjectFactory2 } from "@xylabs/object";
|
|
71
|
-
import { isPayloadOfSchemaType as
|
|
33
|
+
import { isPayloadOfSchemaType as isPayloadOfSchemaType2 } from "@xyo-network/payload-model";
|
|
72
34
|
var HashSchema = "network.xyo.hash";
|
|
73
|
-
var isHashPayload =
|
|
35
|
+
var isHashPayload = isPayloadOfSchemaType2(HashSchema);
|
|
74
36
|
var asHashPayload = AsObjectFactory2.create(isHashPayload);
|
|
75
37
|
var asHashPayloadWithStorageMeta = AsObjectFactory2.create(isHashPayload);
|
|
76
38
|
var asOptionalHashPayload = AsObjectFactory2.createOptional(isHashPayload);
|
|
77
39
|
|
|
78
40
|
// src/payload/elevatable/TransferPayload.ts
|
|
79
41
|
import { AsObjectFactory as AsObjectFactory3 } from "@xylabs/object";
|
|
80
|
-
import { isPayloadOfSchemaType as
|
|
42
|
+
import { isPayloadOfSchemaType as isPayloadOfSchemaType3 } from "@xyo-network/payload-model";
|
|
81
43
|
var TransferSchema = "network.xyo.transfer";
|
|
82
|
-
var isTransfer =
|
|
44
|
+
var isTransfer = isPayloadOfSchemaType3(TransferSchema);
|
|
83
45
|
var asTransfer = AsObjectFactory3.create(isTransfer);
|
|
84
46
|
var asOptionalTransfer = AsObjectFactory3.createOptional(isTransfer);
|
|
85
47
|
|
|
@@ -87,51 +49,72 @@ var asOptionalTransfer = AsObjectFactory3.createOptional(isTransfer);
|
|
|
87
49
|
import { AsObjectFactory as AsObjectFactory4 } from "@xylabs/object";
|
|
88
50
|
import { isBoundWitness } from "@xyo-network/boundwitness-model";
|
|
89
51
|
import { isStorageMeta } from "@xyo-network/payload-model";
|
|
90
|
-
var isTransactionBoundWitness =
|
|
52
|
+
var isTransactionBoundWitness = (value) => {
|
|
91
53
|
const typedObj = value;
|
|
92
54
|
return isBoundWitness(value) && typedObj.chain !== void 0 && typedObj.fees !== void 0 && typedObj.exp !== void 0 && typedObj.nbf !== void 0;
|
|
93
|
-
}
|
|
94
|
-
var
|
|
55
|
+
};
|
|
56
|
+
var isSignedTransactionBoundWitness = (value) => {
|
|
57
|
+
return isTransactionBoundWitness(value) && isSigned(value);
|
|
58
|
+
};
|
|
59
|
+
var isSigned = (value) => isBoundWitness(value) && value.$signatures.length === value.addresses.length && value.addresses.length > 0;
|
|
60
|
+
var isTransactionBoundWitnessWithStorageMeta = (value) => isTransactionBoundWitness(value) && isStorageMeta(value);
|
|
61
|
+
var isSignedTransactionBoundWitnessWithStorageMeta = (value) => isSignedTransactionBoundWitness(value) && isStorageMeta(value);
|
|
95
62
|
var asTransactionBoundWitness = AsObjectFactory4.create(isTransactionBoundWitness);
|
|
96
63
|
var asOptionalTransactionBoundWitness = AsObjectFactory4.createOptional(isTransactionBoundWitness);
|
|
97
64
|
var asTransactionBoundWitnessWithStorageMeta = AsObjectFactory4.create(isTransactionBoundWitnessWithStorageMeta);
|
|
98
65
|
var asOptionalTransactionBoundWitnessWithStorageMeta = AsObjectFactory4.createOptional(isTransactionBoundWitnessWithStorageMeta);
|
|
99
66
|
|
|
100
67
|
// src/block/AllowedBlockPayload.ts
|
|
101
|
-
var AllowedBlockPayloadSchemas = [
|
|
102
|
-
|
|
103
|
-
ChainStakeIntentSchema,
|
|
104
|
-
SchemaSchema,
|
|
105
|
-
BoundWitnessSchema,
|
|
106
|
-
HashSchema
|
|
107
|
-
];
|
|
108
|
-
var isAllowedBlockPayloadSchema = /* @__PURE__ */ __name((value) => {
|
|
68
|
+
var AllowedBlockPayloadSchemas = [TransferSchema, ChainStakeIntentSchema, SchemaSchema, BoundWitnessSchema, HashSchema];
|
|
69
|
+
var isAllowedBlockPayloadSchema = (value) => {
|
|
109
70
|
return isSchema(value) && AllowedBlockPayloadSchemas.includes(value);
|
|
110
|
-
}
|
|
111
|
-
var isAllowedBlockPayload =
|
|
71
|
+
};
|
|
72
|
+
var isAllowedBlockPayload = (value) => {
|
|
112
73
|
return isTransfer(value) || isChainStakeIntent(value) || isSchemaPayload(value) || isTransactionBoundWitness(value) || isHashPayload(value);
|
|
113
|
-
}
|
|
114
|
-
var isAllowedBlockPayloadWithHashStorageMeta =
|
|
74
|
+
};
|
|
75
|
+
var isAllowedBlockPayloadWithHashStorageMeta = (value) => {
|
|
115
76
|
return isAllowedBlockPayload(value) && isHashStorageMeta(value);
|
|
116
|
-
}
|
|
77
|
+
};
|
|
117
78
|
|
|
118
79
|
// src/block/BlockBoundWitness.ts
|
|
119
80
|
import { isHex } from "@xylabs/hex";
|
|
120
81
|
import { AsObjectFactory as AsObjectFactory5 } from "@xylabs/object";
|
|
121
82
|
import { isBoundWitness as isBoundWitness2 } from "@xyo-network/boundwitness-model";
|
|
122
83
|
import { isStorageMeta as isStorageMeta2 } from "@xyo-network/payload-model";
|
|
123
|
-
var isBlockBoundWitness =
|
|
84
|
+
var isBlockBoundWitness = (value) => {
|
|
124
85
|
const typedObj = value;
|
|
125
86
|
return isBoundWitness2(value) && Number.isInteger(typedObj.block) && isHex(typedObj.chain);
|
|
126
|
-
}
|
|
127
|
-
var isBlockBoundWitnessWithStorageMeta =
|
|
87
|
+
};
|
|
88
|
+
var isBlockBoundWitnessWithStorageMeta = (value) => {
|
|
128
89
|
return isBlockBoundWitness(value) && isStorageMeta2(value);
|
|
129
|
-
}
|
|
90
|
+
};
|
|
130
91
|
var asBlockBoundWitness = AsObjectFactory5.create(isBlockBoundWitness);
|
|
131
92
|
var asOptionalBlockBoundWitness = AsObjectFactory5.createOptional(isBlockBoundWitness);
|
|
132
93
|
var asBlockBoundWitnessWithStorageMeta = AsObjectFactory5.create(isBlockBoundWitnessWithStorageMeta);
|
|
133
94
|
var asOptionalBlockBoundWitnessWithStorageMeta = AsObjectFactory5.createOptional(isBlockBoundWitnessWithStorageMeta);
|
|
134
95
|
|
|
96
|
+
// src/ethereum.ts
|
|
97
|
+
import { toHex } from "@xylabs/hex";
|
|
98
|
+
import { getAddress } from "ethers";
|
|
99
|
+
import { parseUnits } from "ethers/utils";
|
|
100
|
+
var getDefaultGasConfig = () => {
|
|
101
|
+
return {
|
|
102
|
+
gasLimit: 2e6,
|
|
103
|
+
// Set the gas limit
|
|
104
|
+
gasPrice: parseUnits("100", "gwei")
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
var ETH_ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
108
|
+
var toEthAddress = (value) => {
|
|
109
|
+
const address = typeof value === "object" ? value.address : value;
|
|
110
|
+
return getAddress(toHex(address, { prefix: true, bitLength: 160 }));
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// src/network/Status.ts
|
|
114
|
+
import { isPayloadOfSchemaType as isPayloadOfSchemaType4 } from "@xyo-network/payload-model";
|
|
115
|
+
var NetworkStatusSchema = "network.xyo.chain.status";
|
|
116
|
+
var isNetworkStatus = isPayloadOfSchemaType4(NetworkStatusSchema);
|
|
117
|
+
|
|
135
118
|
// src/services/Chain/ChainIdentification.ts
|
|
136
119
|
import { isPayloadOfSchemaType as isPayloadOfSchemaType5 } from "@xyo-network/payload-model";
|
|
137
120
|
var ChainIdentificationPayloadSchema = "network.xyo.chain.identification";
|
|
@@ -146,13 +129,16 @@ var isChainInformationPayload = isPayloadOfSchemaType6(ChainInformationPayloadSc
|
|
|
146
129
|
import { AsObjectFactory as AsObjectFactory6 } from "@xylabs/object";
|
|
147
130
|
import { isPayloadOfSchemaType as isPayloadOfSchemaType7, isStorageMeta as isStorageMeta3 } from "@xyo-network/payload-model";
|
|
148
131
|
var ChainIndexingServiceStateSchema = "network.xyo.chain.indexing.service.state";
|
|
149
|
-
var isChainIndexingServiceState =
|
|
132
|
+
var isChainIndexingServiceState = (payload) => {
|
|
150
133
|
return isPayloadOfSchemaType7(ChainIndexingServiceStateSchema)(payload);
|
|
151
|
-
}
|
|
134
|
+
};
|
|
152
135
|
var asChainIndexingServiceState = AsObjectFactory6.create(isChainIndexingServiceState);
|
|
153
|
-
var isChainIndexingServiceStateWithStorageMeta =
|
|
136
|
+
var isChainIndexingServiceStateWithStorageMeta = (value) => isChainIndexingServiceState(value) && isStorageMeta3(value);
|
|
154
137
|
var asChainIndexingServiceStateWithStorageMeta = AsObjectFactory6.create(isChainIndexingServiceStateWithStorageMeta);
|
|
155
138
|
var asOptionalChainIndexingServiceStateWithStorageMeta = AsObjectFactory6.createOptional(isChainIndexingServiceStateWithStorageMeta);
|
|
139
|
+
|
|
140
|
+
// src/Steps.ts
|
|
141
|
+
var StepSizes = [10, 105, 1103, 11576, 121551, 1276282, 13400956];
|
|
156
142
|
export {
|
|
157
143
|
AllowedBlockPayloadSchemas,
|
|
158
144
|
ChainIdentificationPayloadSchema,
|
|
@@ -177,7 +163,11 @@ export {
|
|
|
177
163
|
asOptionalChainIndexingServiceStateWithStorageMeta,
|
|
178
164
|
asOptionalChainStakeIntent,
|
|
179
165
|
asOptionalHashPayload,
|
|
166
|
+
asOptionalTransactionBoundWitness,
|
|
167
|
+
asOptionalTransactionBoundWitnessWithStorageMeta,
|
|
180
168
|
asOptionalTransfer,
|
|
169
|
+
asTransactionBoundWitness,
|
|
170
|
+
asTransactionBoundWitnessWithStorageMeta,
|
|
181
171
|
asTransfer,
|
|
182
172
|
getDefaultGasConfig,
|
|
183
173
|
hasFrom,
|
|
@@ -194,6 +184,11 @@ export {
|
|
|
194
184
|
isExecutable,
|
|
195
185
|
isHashPayload,
|
|
196
186
|
isNetworkStatus,
|
|
187
|
+
isSigned,
|
|
188
|
+
isSignedTransactionBoundWitness,
|
|
189
|
+
isSignedTransactionBoundWitnessWithStorageMeta,
|
|
190
|
+
isTransactionBoundWitness,
|
|
191
|
+
isTransactionBoundWitnessWithStorageMeta,
|
|
197
192
|
isTransfer,
|
|
198
193
|
toEthAddress
|
|
199
194
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ethereum.ts","../../src/network/Status.ts","../../src/Steps.ts","../../src/block/AllowedBlockPayload.ts","../../src/payload/elevatable/ChainStakeIntent.ts","../../src/payload/elevatable/Executable.ts","../../src/payload/elevatable/Hash.ts","../../src/payload/elevatable/TransferPayload.ts","../../src/transaction/TransactionBoundWitness.ts","../../src/block/BlockBoundWitness.ts","../../src/services/Chain/ChainIdentification.ts","../../src/services/Chain/ChainInformation.ts","../../src/services/stakeIntent/ChainIndexingServiceStateSchema.ts"],"sourcesContent":["import type { Hex } from '@xylabs/hex'\nimport { toHex } from '@xylabs/hex'\nimport type { AccountInstance } from '@xyo-network/account-model'\nimport { getAddress } from 'ethers'\nimport { parseUnits } from 'ethers/utils'\n\nexport interface GasConfig {\n gasLimit?: number\n gasPrice?: bigint\n}\n\nexport const getDefaultGasConfig = (): GasConfig => {\n return {\n gasLimit: 2_000_000, // Set the gas limit\n gasPrice: parseUnits('100', 'gwei'),\n }\n}\n\nexport type EthAddress = Hex\n\nexport const ETH_ZERO_ADDRESS: EthAddress = '0x0000000000000000000000000000000000000000' as const\n\nexport const toEthAddress = (value: bigint | string | AccountInstance): EthAddress => {\n const address = (typeof value === 'object') ? value.address : value\n return getAddress(toHex(address, { prefix: true, bitLength: 160 })) as EthAddress\n}\n","import type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nexport const NetworkStatusSchema = 'network.xyo.chain.status' as const\nexport type NetworkStatusSchema = typeof NetworkStatusSchema\n\nexport type NetworkStatusState = 'online' | 'offline' | 'degraded' | 'unknown'\n\nexport type NetworkStatusUpdate = {\n end: number\n start: number\n update: string\n}\n\nexport interface NetworkStatusFields {\n description: string\n state: NetworkStatusState\n updates?: NetworkStatusUpdate[]\n}\n\nexport type NetworkStatus = Payload<NetworkStatusFields, NetworkStatusSchema>\n\nexport const isNetworkStatus = isPayloadOfSchemaType<NetworkStatus>(NetworkStatusSchema)\n","export const StepSizes = [10, 105, 1103, 11_576, 121_551, 1_276_282, 13_400_956]\n","import { BoundWitnessSchema } from '@xyo-network/boundwitness-model'\nimport type { Schema, WithStorageMeta } from '@xyo-network/payload-model'\nimport { isHashStorageMeta, isSchema } from '@xyo-network/payload-model'\nimport type { SchemaPayload } from '@xyo-network/schema-payload-plugin'\nimport { isSchemaPayload, SchemaSchema } from '@xyo-network/schema-payload-plugin'\n\nimport type {\n ChainStakeIntent, HashPayload, Transfer,\n} from '#payload'\nimport {\n ChainStakeIntentSchema, HashSchema, isChainStakeIntent, isHashPayload, isTransfer, TransferSchema,\n} from '#payload'\nimport { isTransactionBoundWitness, type TransactionBoundWitness } from '#transaction'\n\nexport type AllowedBlockPayload = Transfer | ChainStakeIntent | SchemaPayload | TransactionBoundWitness | HashPayload\nexport const AllowedBlockPayloadSchemas: Schema[] = [TransferSchema, ChainStakeIntentSchema, SchemaSchema, BoundWitnessSchema, HashSchema]\nexport type AllowedBlockPayloadSchema = typeof AllowedBlockPayloadSchemas[number]\n\nexport const isAllowedBlockPayloadSchema = (value: unknown): value is AllowedBlockPayloadSchema => {\n return isSchema(value) && AllowedBlockPayloadSchemas.includes(value)\n}\n\nexport const isAllowedBlockPayload = (value: unknown): value is AllowedBlockPayload => {\n return isTransfer(value) || isChainStakeIntent(value) || isSchemaPayload(value) || isTransactionBoundWitness(value) || isHashPayload(value)\n}\n\nexport const isAllowedBlockPayloadWithHashStorageMeta = (value: unknown): value is WithStorageMeta<AllowedBlockPayload> => {\n return isAllowedBlockPayload(value) && isHashStorageMeta(value)\n}\n","import { AsObjectFactory } from '@xylabs/object'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nimport type { BlockDuration } from '../../BlockDuration.ts'\nimport type { FromFields } from './Executable.ts'\n\nexport const ChainStakeIntentSchema = 'network.xyo.chain.stake.intent' as const\nexport type ChainStakeIntentSchema = typeof ChainStakeIntentSchema\n\nexport type Intent = 'producer' // | 'bank'\n\nexport interface ChainStakeIntentFields extends BlockDuration, FromFields {\n /*\n * The intent of the staking\n */\n intent: Intent\n}\n\nexport type ChainStakeIntent = Payload<ChainStakeIntentFields, ChainStakeIntentSchema>\n\nexport const isChainStakeIntent = (x?: unknown | null): x is ChainStakeIntent => {\n return isPayloadOfSchemaType<ChainStakeIntent>(ChainStakeIntentSchema)(x)\n && asNonNegativeInteger(x.nbf) !== undefined\n && asNonNegativeInteger(x.exp) !== undefined\n}\nexport const asChainStakeIntent = AsObjectFactory.create(isChainStakeIntent)\nexport const asOptionalChainStakeIntent = AsObjectFactory.createOptional(isChainStakeIntent)\n\nconst asNonNegativeInteger = (num: number) => {\n return (Number.isInteger(num) && num >= 0) ? num : undefined\n}\n","import type { Address } from '@xylabs/hex'\nimport type { EmptyObject } from '@xylabs/object'\nimport { isAnyPayload } from '@xyo-network/payload-model'\n\nexport interface FromFields {\n // the address that is treated as the source of this action\n from: Address\n}\n\nexport const hasFrom = (value: unknown): value is FromFields => {\n return (value as FromFields).from !== undefined\n}\n\nexport interface ExecutableFields {\n script: string[]\n}\n\nexport type Executable<T extends EmptyObject = EmptyObject> = T & ExecutableFields\nexport type OptionalExecutable<T extends EmptyObject = EmptyObject> = T & Partial<ExecutableFields>\n\nexport const isExecutable = <T extends EmptyObject>(value: T | undefined): value is Executable<T> => {\n return isAnyPayload(value) && Array.isArray((value as unknown as ExecutableFields).script)\n}\n\nexport const asExecutable = <T extends EmptyObject>(value: T | undefined): Executable<T> | undefined => {\n return isExecutable(value)\n ? value as unknown as Executable<T>\n : undefined\n}\n","import type { Hash } from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nexport const HashSchema = 'network.xyo.hash' as const\nexport type HashSchema = typeof HashSchema\n\nexport interface HashFields {\n hash: Hash\n}\n\nexport type HashPayload = Payload<HashFields, HashSchema>\n\nexport const isHashPayload = isPayloadOfSchemaType<HashPayload>(HashSchema)\n\nexport const asHashPayload = AsObjectFactory.create(isHashPayload)\nexport const asHashPayloadWithStorageMeta = AsObjectFactory.create(isHashPayload)\nexport const asOptionalHashPayload = AsObjectFactory.createOptional(isHashPayload)\n","import type {\n Address,\n Hex,\n} from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nimport type { FromFields } from './Executable.ts'\n\nexport const TransferSchema = 'network.xyo.transfer' as const\nexport type TransferSchema = typeof TransferSchema\n\nexport interface TransferFields extends FromFields {\n epoch: number\n // the amount that is being sent to another address\n transfers: Record<Address, Hex>\n}\n\n// if this payload is included in a boundwitness, it needs to be available for inspection to be included in block\nexport type Transfer = Payload<TransferFields, TransferSchema>\n\nexport const isTransfer = isPayloadOfSchemaType<Transfer>(TransferSchema)\n\nexport const asTransfer = AsObjectFactory.create(isTransfer)\nexport const asOptionalTransfer = AsObjectFactory.createOptional(isTransfer)\n","import type { Address } from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { BoundWitness, Signed } from '@xyo-network/boundwitness-model'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport { isStorageMeta } from '@xyo-network/payload-model'\n\nimport type {\n FromFields,\n OptionalExecutable,\n} from '#payload'\n\nimport type { BlockDuration } from '../BlockDuration.ts'\nimport type { TransactionFeesFields } from './TransactionFeesFields.ts'\n\nexport interface TransactionBoundWitnessFields extends BlockDuration, TransactionFeesFields {\n chain: Address\n}\n\nexport type TransactionBoundWitness = BoundWitness<TransactionBoundWitnessFields & OptionalExecutable & FromFields>\n\nexport const isTransactionBoundWitness = (value: unknown): value is TransactionBoundWitness => {\n const typedObj = value as TransactionBoundWitness\n return isBoundWitness(value)\n && typedObj.chain !== undefined\n && typedObj.fees !== undefined\n && typedObj.exp !== undefined\n && typedObj.nbf !== undefined\n}\n\nexport const isSignedTransactionBoundWitness = (value: unknown): value is Signed<TransactionBoundWitness> => {\n return isTransactionBoundWitness(value) && isSigned(value)\n}\n\nexport const isSigned = <T extends BoundWitness = BoundWitness>(value: unknown): value is Signed<T> =>\n isBoundWitness(value)\n && value.$signatures.length === value.addresses.length\n && value.addresses.length > 0\n\nexport const isTransactionBoundWitnessWithStorageMeta = (value: unknown): value is WithStorageMeta<TransactionBoundWitness> =>\n isTransactionBoundWitness(value)\n && isStorageMeta(value)\n\nexport const isSignedTransactionBoundWitnessWithStorageMeta = (value: unknown): value is WithStorageMeta<Signed<TransactionBoundWitness>> =>\n isSignedTransactionBoundWitness(value)\n && isStorageMeta(value)\n\nexport const asTransactionBoundWitness = AsObjectFactory.create(isTransactionBoundWitness)\nexport const asOptionalTransactionBoundWitness = AsObjectFactory.createOptional(isTransactionBoundWitness)\n\nexport const asTransactionBoundWitnessWithStorageMeta = AsObjectFactory.create(isTransactionBoundWitnessWithStorageMeta)\nexport const asOptionalTransactionBoundWitnessWithStorageMeta = AsObjectFactory.createOptional(isTransactionBoundWitnessWithStorageMeta)\n","import type { Hash, Hex } from '@xylabs/hex'\nimport { isHex } from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport { isStorageMeta } from '@xyo-network/payload-model'\n\nexport interface BlockBoundWitnessMeta {\n $epoch: number\n}\n\nexport interface BlockBoundWitnessFields {\n /** Block number */\n block: number\n /** Chain id - this should be \"0\" for the genesis block */\n chain: Hex\n /** Previous block hash if not block 0 */\n previous: Hash | null /* the previous block hash */\n /** Version of the protocol being used major * 1,000,000 + minor * 1,000 + patch */\n protocol: number\n /** Step hashes */\n step_hashes: Hex[]\n}\n\nexport type BlockBoundWitness = BoundWitness<BlockBoundWitnessFields & BlockBoundWitnessMeta>\n\nexport const isBlockBoundWitness = (value: unknown): value is BlockBoundWitness => {\n const typedObj = value as BlockBoundWitness\n return isBoundWitness(value)\n && Number.isInteger(typedObj.block)\n && isHex(typedObj.chain)\n}\n\nexport const isBlockBoundWitnessWithStorageMeta = (value: unknown): value is WithStorageMeta<BlockBoundWitness> => {\n return isBlockBoundWitness(value) && isStorageMeta(value)\n}\n\nexport const asBlockBoundWitness = AsObjectFactory.create(isBlockBoundWitness)\nexport const asOptionalBlockBoundWitness = AsObjectFactory.createOptional(isBlockBoundWitness)\n\nexport const asBlockBoundWitnessWithStorageMeta = AsObjectFactory.create(isBlockBoundWitnessWithStorageMeta)\nexport const asOptionalBlockBoundWitnessWithStorageMeta = AsObjectFactory.createOptional(isBlockBoundWitnessWithStorageMeta)\n","import type { Address } from '@xylabs/hex'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nexport const ChainIdentificationPayloadSchema = 'network.xyo.chain.identification' as const\nexport type ChainIdentificationPayloadSchema = typeof ChainIdentificationPayloadSchema\n\n/**\n * Identification required to uniquely identify a chain\n */\nexport interface ChainIdentification {\n /** @field the id of the chain */\n id: Address\n}\n\nexport type ChainIdentificationPayload = Payload<ChainIdentification, ChainIdentificationPayloadSchema>\nexport const isChainIdentificationPayload = isPayloadOfSchemaType<ChainIdentificationPayload>(ChainIdentificationPayloadSchema)\n","import type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nexport const ChainInformationPayloadSchema = 'network.xyo.chain.information' as const\nexport type ChainInformationPayloadSchema = typeof ChainInformationPayloadSchema\n\nimport type { ChainIdentification } from './ChainIdentification.ts'\n\n/**\n * Information required to produce a chain\n */\nexport interface ChainInformation extends ChainIdentification {\n // TODO: Add these fields which are currently promises on the smart contract\n // forkedAtBlockNumber: bigint\n // forkedAtHash: Hash\n // forkedChainId: Address\n}\n\nexport type ChainInformationPayload = Payload<ChainIdentification, ChainInformationPayloadSchema>\nexport const isChainInformationPayload = isPayloadOfSchemaType<ChainInformationPayload>(ChainInformationPayloadSchema)\n","import type { Hash } from '@xylabs/hex'\nimport type { JsonValue } from '@xylabs/object'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { Payload, WithStorageMeta } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType, isStorageMeta } from '@xyo-network/payload-model'\n\nexport interface ChainIndexingServiceStateFields<T extends JsonValue = JsonValue> {\n /**\n * The hash of the last block that this service has indexing\n */\n endBlockHash: Hash\n /**\n * The hash of the block that the service started indexing. If undefined, the service is\n * assumed to have started indexing from the genesis block\n */\n startBlockHash?: Hash\n /**\n * The indexed state for the range\n */\n state: T\n}\nexport const ChainIndexingServiceStateSchema = 'network.xyo.chain.indexing.service.state' as const\nexport type ChainIndexingServiceStateSchema = typeof ChainIndexingServiceStateSchema\n\n/**\n * The result of a ChainIndexingServiceState\n */\nexport type ChainIndexingServiceState<T extends JsonValue = JsonValue> = Payload<ChainIndexingServiceStateFields<T>, ChainIndexingServiceStateSchema>\n\n/**\n * Identity functions for determining if an object is an ChainIndexingServiceState\n */\nexport const isChainIndexingServiceState = <T extends JsonValue = JsonValue>(payload?: unknown): payload is ChainIndexingServiceState<T> => {\n return isPayloadOfSchemaType<ChainIndexingServiceState<T>>(ChainIndexingServiceStateSchema)(payload)\n}\nexport const asChainIndexingServiceState = AsObjectFactory.create<ChainIndexingServiceState<JsonValue>>(isChainIndexingServiceState)\n\nexport const isChainIndexingServiceStateWithStorageMeta\n= <T extends JsonValue = JsonValue>(value: unknown): value is WithStorageMeta<ChainIndexingServiceState<T>> =>\n isChainIndexingServiceState<T>(value) && isStorageMeta(value)\n\nexport const asChainIndexingServiceStateWithStorageMeta\n= AsObjectFactory.create<WithStorageMeta<ChainIndexingServiceState>>(isChainIndexingServiceStateWithStorageMeta)\n\nexport const asOptionalChainIndexingServiceStateWithStorageMeta\n= AsObjectFactory.createOptional<WithStorageMeta<ChainIndexingServiceState>>(isChainIndexingServiceStateWithStorageMeta)\n"],"mappings":";;;;AACA,SAASA,aAAa;AAEtB,SAASC,kBAAkB;AAC3B,SAASC,kBAAkB;AAOpB,IAAMC,sBAAsB,6BAAA;AACjC,SAAO;IACLC,UAAU;IACVC,UAAUC,WAAW,OAAO,MAAA;EAC9B;AACF,GALmC;AAS5B,IAAMC,mBAA+B;AAErC,IAAMC,eAAe,wBAACC,UAAAA;AAC3B,QAAMC,UAAW,OAAOD,UAAU,WAAYA,MAAMC,UAAUD;AAC9D,SAAOE,WAAWC,MAAMF,SAAS;IAAEG,QAAQ;IAAMC,WAAW;EAAI,CAAA,CAAA;AAClE,GAH4B;;;ACrB5B,SAASC,6BAA6B;AAE/B,IAAMC,sBAAsB;AAmB5B,IAAMC,kBAAkBF,sBAAqCC,mBAAAA;;;ACtB7D,IAAME,YAAY;EAAC;EAAI;EAAK;EAAM;EAAQ;EAAS;EAAW;;;;ACArE,SAASC,0BAA0B;AAEnC,SAASC,mBAAmBC,gBAAgB;AAE5C,SAASC,iBAAiBC,oBAAoB;;;ACJ9C,SAASC,uBAAuB;AAEhC,SAASC,yBAAAA,8BAA6B;AAK/B,IAAMC,yBAAyB;AAc/B,IAAMC,qBAAqB,wBAACC,MAAAA;AACjC,SAAOC,uBAAwCH,sBAAAA,EAAwBE,CAAAA,KAClEE,qBAAqBF,EAAEG,GAAG,MAAMC,UAChCF,qBAAqBF,EAAEK,GAAG,MAAMD;AACvC,GAJkC;AAK3B,IAAME,qBAAqBC,gBAAgBC,OAAOT,kBAAAA;AAClD,IAAMU,6BAA6BF,gBAAgBG,eAAeX,kBAAAA;AAEzE,IAAMG,uBAAuB,wBAACS,QAAAA;AAC5B,SAAQC,OAAOC,UAAUF,GAAAA,KAAQA,OAAO,IAAKA,MAAMP;AACrD,GAF6B;;;AC3B7B,SAAS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AAA,8BAA6B;AAE/B,IAAMC,gCAAgC;AAgBtC,IAAMC,4BAA4BF,uBAA+CC,6BAAAA;;;ACjBxF,SAASE,mBAAAA,wBAAuB;AAEhC,SAASC,yBAAAA,wBAAuBC,iBAAAA,sBAAqB;AAiB9C,IAAMC,kCAAkC;AAWxC,IAAMC,8BAA8B,wBAAkCC,YAAAA;AAC3E,SAAOC,uBAAoDH,+BAAAA,EAAiCE,OAAAA;AAC9F,GAF2C;AAGpC,IAAME,8BAA8BC,iBAAgBC,OAA6CL,2BAAAA;AAEjG,IAAMM,6CACX,wBAAkCC,UAClCP,4BAA+BO,KAAAA,KAAUC,eAAcD,KAAAA,GADvD;AAGK,IAAME,6CACXL,iBAAgBC,OAAmDC,0CAAAA;AAE9D,IAAMI,qDACXN,iBAAgBO,eAA2DL,0CAAAA;","names":["toHex","getAddress","parseUnits","getDefaultGasConfig","gasLimit","gasPrice","parseUnits","ETH_ZERO_ADDRESS","toEthAddress","value","address","getAddress","toHex","prefix","bitLength","isPayloadOfSchemaType","NetworkStatusSchema","isNetworkStatus","StepSizes","BoundWitnessSchema","isHashStorageMeta","isSchema","isSchemaPayload","SchemaSchema","AsObjectFactory","isPayloadOfSchemaType","ChainStakeIntentSchema","isChainStakeIntent","x","isPayloadOfSchemaType","asNonNegativeInteger","nbf","undefined","exp","asChainStakeIntent","AsObjectFactory","create","asOptionalChainStakeIntent","createOptional","num","Number","isInteger","isAnyPayload","hasFrom","value","from","undefined","isExecutable","isAnyPayload","Array","isArray","script","asExecutable","AsObjectFactory","isPayloadOfSchemaType","HashSchema","isHashPayload","asHashPayload","create","asHashPayloadWithStorageMeta","asOptionalHashPayload","createOptional","AsObjectFactory","isPayloadOfSchemaType","TransferSchema","isTransfer","asTransfer","create","asOptionalTransfer","createOptional","AsObjectFactory","isBoundWitness","isStorageMeta","isTransactionBoundWitness","value","typedObj","isBoundWitness","chain","undefined","fees","exp","nbf","isTransactionBoundWitnessWithStorageMeta","value","isTransactionBoundWitness","isStorageMeta","asTransactionBoundWitness","AsObjectFactory","create","isTransactionBoundWitness","asOptionalTransactionBoundWitness","createOptional","asTransactionBoundWitnessWithStorageMeta","isTransactionBoundWitnessWithStorageMeta","asOptionalTransactionBoundWitnessWithStorageMeta","AllowedBlockPayloadSchemas","TransferSchema","ChainStakeIntentSchema","SchemaSchema","BoundWitnessSchema","HashSchema","isAllowedBlockPayloadSchema","value","isSchema","includes","isAllowedBlockPayload","isTransfer","isChainStakeIntent","isSchemaPayload","isTransactionBoundWitness","isHashPayload","isAllowedBlockPayloadWithHashStorageMeta","isHashStorageMeta","isHex","AsObjectFactory","isBoundWitness","isStorageMeta","isBlockBoundWitness","value","typedObj","isBoundWitness","Number","isInteger","block","isHex","chain","isBlockBoundWitnessWithStorageMeta","isStorageMeta","asBlockBoundWitness","AsObjectFactory","create","asOptionalBlockBoundWitness","createOptional","asBlockBoundWitnessWithStorageMeta","asOptionalBlockBoundWitnessWithStorageMeta","isPayloadOfSchemaType","ChainIdentificationPayloadSchema","isChainIdentificationPayload","isPayloadOfSchemaType","ChainInformationPayloadSchema","isChainInformationPayload","AsObjectFactory","isPayloadOfSchemaType","isStorageMeta","ChainIndexingServiceStateSchema","isChainIndexingServiceState","payload","isPayloadOfSchemaType","asChainIndexingServiceState","AsObjectFactory","create","isChainIndexingServiceStateWithStorageMeta","value","isStorageMeta","asChainIndexingServiceStateWithStorageMeta","asOptionalChainIndexingServiceStateWithStorageMeta","createOptional"]}
|
|
1
|
+
{"version":3,"sources":["../../src/block/AllowedBlockPayload.ts","../../src/payload/elevatable/ChainStakeIntent.ts","../../src/payload/elevatable/Executable.ts","../../src/payload/elevatable/Hash.ts","../../src/payload/elevatable/TransferPayload.ts","../../src/transaction/TransactionBoundWitness.ts","../../src/block/BlockBoundWitness.ts","../../src/ethereum.ts","../../src/network/Status.ts","../../src/services/Chain/ChainIdentification.ts","../../src/services/Chain/ChainInformation.ts","../../src/services/stakeIntent/ChainIndexingServiceStateSchema.ts","../../src/Steps.ts"],"sourcesContent":["import { BoundWitnessSchema } from '@xyo-network/boundwitness-model'\nimport type { Schema, WithStorageMeta } from '@xyo-network/payload-model'\nimport { isHashStorageMeta, isSchema } from '@xyo-network/payload-model'\nimport type { SchemaPayload } from '@xyo-network/schema-payload-plugin'\nimport { isSchemaPayload, SchemaSchema } from '@xyo-network/schema-payload-plugin'\n\nimport type {\n ChainStakeIntent, HashPayload, Transfer,\n} from '#payload'\nimport {\n ChainStakeIntentSchema, HashSchema, isChainStakeIntent, isHashPayload, isTransfer, TransferSchema,\n} from '#payload'\nimport { isTransactionBoundWitness, type TransactionBoundWitness } from '#transaction'\n\nexport type AllowedBlockPayload = Transfer | ChainStakeIntent | SchemaPayload | TransactionBoundWitness | HashPayload\nexport const AllowedBlockPayloadSchemas: Schema[] = [TransferSchema, ChainStakeIntentSchema, SchemaSchema, BoundWitnessSchema, HashSchema]\nexport type AllowedBlockPayloadSchema = typeof AllowedBlockPayloadSchemas[number]\n\nexport const isAllowedBlockPayloadSchema = (value: unknown): value is AllowedBlockPayloadSchema => {\n return isSchema(value) && AllowedBlockPayloadSchemas.includes(value)\n}\n\nexport const isAllowedBlockPayload = (value: unknown): value is AllowedBlockPayload => {\n return isTransfer(value) || isChainStakeIntent(value) || isSchemaPayload(value) || isTransactionBoundWitness(value) || isHashPayload(value)\n}\n\nexport const isAllowedBlockPayloadWithHashStorageMeta = (value: unknown): value is WithStorageMeta<AllowedBlockPayload> => {\n return isAllowedBlockPayload(value) && isHashStorageMeta(value)\n}\n","import { AsObjectFactory } from '@xylabs/object'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nimport type { BlockDuration } from '../../BlockDuration.ts'\nimport type { FromFields } from './Executable.ts'\n\nexport const ChainStakeIntentSchema = 'network.xyo.chain.stake.intent' as const\nexport type ChainStakeIntentSchema = typeof ChainStakeIntentSchema\n\nexport type Intent = 'producer' // | 'bank'\n\nexport interface ChainStakeIntentFields extends BlockDuration, FromFields {\n /*\n * The intent of the staking\n */\n intent: Intent\n}\n\nexport type ChainStakeIntent = Payload<ChainStakeIntentFields, ChainStakeIntentSchema>\n\nexport const isChainStakeIntent = (x?: unknown | null): x is ChainStakeIntent => {\n return isPayloadOfSchemaType<ChainStakeIntent>(ChainStakeIntentSchema)(x)\n && asNonNegativeInteger(x.nbf) !== undefined\n && asNonNegativeInteger(x.exp) !== undefined\n}\nexport const asChainStakeIntent = AsObjectFactory.create(isChainStakeIntent)\nexport const asOptionalChainStakeIntent = AsObjectFactory.createOptional(isChainStakeIntent)\n\nconst asNonNegativeInteger = (num: number) => {\n return (Number.isInteger(num) && num >= 0) ? num : undefined\n}\n","import type { Address } from '@xylabs/hex'\nimport type { EmptyObject } from '@xylabs/object'\nimport { isAnyPayload } from '@xyo-network/payload-model'\n\nexport interface FromFields {\n // the address that is treated as the source of this action\n from: Address\n}\n\nexport const hasFrom = (value: unknown): value is FromFields => {\n return (value as FromFields).from !== undefined\n}\n\nexport interface ExecutableFields {\n script: string[]\n}\n\nexport type Executable<T extends EmptyObject = EmptyObject> = T & ExecutableFields\nexport type OptionalExecutable<T extends EmptyObject = EmptyObject> = T & Partial<ExecutableFields>\n\nexport const isExecutable = <T extends EmptyObject>(value: T | undefined): value is Executable<T> => {\n return isAnyPayload(value) && Array.isArray((value as unknown as ExecutableFields).script)\n}\n\nexport const asExecutable = <T extends EmptyObject>(value: T | undefined): Executable<T> | undefined => {\n return isExecutable(value)\n ? value as unknown as Executable<T>\n : undefined\n}\n","import type { Hash } from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nexport const HashSchema = 'network.xyo.hash' as const\nexport type HashSchema = typeof HashSchema\n\nexport interface HashFields {\n hash: Hash\n}\n\nexport type HashPayload = Payload<HashFields, HashSchema>\n\nexport const isHashPayload = isPayloadOfSchemaType<HashPayload>(HashSchema)\n\nexport const asHashPayload = AsObjectFactory.create(isHashPayload)\nexport const asHashPayloadWithStorageMeta = AsObjectFactory.create(isHashPayload)\nexport const asOptionalHashPayload = AsObjectFactory.createOptional(isHashPayload)\n","import type {\n Address,\n Hex,\n} from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nimport type { FromFields } from './Executable.ts'\n\nexport const TransferSchema = 'network.xyo.transfer' as const\nexport type TransferSchema = typeof TransferSchema\n\nexport interface TransferFields extends FromFields {\n epoch: number\n // the amount that is being sent to another address\n transfers: Record<Address, Hex>\n}\n\n// if this payload is included in a boundwitness, it needs to be available for inspection to be included in block\nexport type Transfer = Payload<TransferFields, TransferSchema>\n\nexport const isTransfer = isPayloadOfSchemaType<Transfer>(TransferSchema)\n\nexport const asTransfer = AsObjectFactory.create(isTransfer)\nexport const asOptionalTransfer = AsObjectFactory.createOptional(isTransfer)\n","import type { Address } from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { BoundWitness, Signed } from '@xyo-network/boundwitness-model'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport { isStorageMeta } from '@xyo-network/payload-model'\n\nimport type {\n FromFields,\n OptionalExecutable,\n} from '#payload'\n\nimport type { BlockDuration } from '../BlockDuration.ts'\nimport type { TransactionFeesFields } from './TransactionFeesFields.ts'\n\nexport interface TransactionBoundWitnessFields extends BlockDuration, TransactionFeesFields {\n chain: Address\n}\n\nexport type TransactionBoundWitness = BoundWitness<TransactionBoundWitnessFields & OptionalExecutable & FromFields>\n\nexport const isTransactionBoundWitness = (value: unknown): value is TransactionBoundWitness => {\n const typedObj = value as TransactionBoundWitness\n return isBoundWitness(value)\n && typedObj.chain !== undefined\n && typedObj.fees !== undefined\n && typedObj.exp !== undefined\n && typedObj.nbf !== undefined\n}\n\nexport const isSignedTransactionBoundWitness = (value: unknown): value is Signed<TransactionBoundWitness> => {\n return isTransactionBoundWitness(value) && isSigned(value)\n}\n\nexport const isSigned = <T extends BoundWitness = BoundWitness>(value: unknown): value is Signed<T> =>\n isBoundWitness(value)\n && value.$signatures.length === value.addresses.length\n && value.addresses.length > 0\n\nexport const isTransactionBoundWitnessWithStorageMeta = (value: unknown): value is WithStorageMeta<TransactionBoundWitness> =>\n isTransactionBoundWitness(value)\n && isStorageMeta(value)\n\nexport const isSignedTransactionBoundWitnessWithStorageMeta = (value: unknown): value is WithStorageMeta<Signed<TransactionBoundWitness>> =>\n isSignedTransactionBoundWitness(value)\n && isStorageMeta(value)\n\nexport const asTransactionBoundWitness = AsObjectFactory.create(isTransactionBoundWitness)\nexport const asOptionalTransactionBoundWitness = AsObjectFactory.createOptional(isTransactionBoundWitness)\n\nexport const asTransactionBoundWitnessWithStorageMeta = AsObjectFactory.create(isTransactionBoundWitnessWithStorageMeta)\nexport const asOptionalTransactionBoundWitnessWithStorageMeta = AsObjectFactory.createOptional(isTransactionBoundWitnessWithStorageMeta)\n","import type { Hash, Hex } from '@xylabs/hex'\nimport { isHex } from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport { isStorageMeta } from '@xyo-network/payload-model'\n\nexport interface BlockBoundWitnessMeta {\n $epoch: number\n}\n\nexport interface BlockBoundWitnessFields {\n /** Block number */\n block: number\n /** Chain id - this should be \"0\" for the genesis block */\n chain: Hex\n /** Previous block hash if not block 0 */\n previous: Hash | null /* the previous block hash */\n /** Version of the protocol being used major * 1,000,000 + minor * 1,000 + patch */\n protocol: number\n /** Step hashes */\n step_hashes: Hex[]\n}\n\nexport type BlockBoundWitness = BoundWitness<BlockBoundWitnessFields & BlockBoundWitnessMeta>\n\nexport const isBlockBoundWitness = (value: unknown): value is BlockBoundWitness => {\n const typedObj = value as BlockBoundWitness\n return isBoundWitness(value)\n && Number.isInteger(typedObj.block)\n && isHex(typedObj.chain)\n}\n\nexport const isBlockBoundWitnessWithStorageMeta = (value: unknown): value is WithStorageMeta<BlockBoundWitness> => {\n return isBlockBoundWitness(value) && isStorageMeta(value)\n}\n\nexport const asBlockBoundWitness = AsObjectFactory.create(isBlockBoundWitness)\nexport const asOptionalBlockBoundWitness = AsObjectFactory.createOptional(isBlockBoundWitness)\n\nexport const asBlockBoundWitnessWithStorageMeta = AsObjectFactory.create(isBlockBoundWitnessWithStorageMeta)\nexport const asOptionalBlockBoundWitnessWithStorageMeta = AsObjectFactory.createOptional(isBlockBoundWitnessWithStorageMeta)\n","import type { Hex } from '@xylabs/hex'\nimport { toHex } from '@xylabs/hex'\nimport type { AccountInstance } from '@xyo-network/account-model'\nimport { getAddress } from 'ethers'\nimport { parseUnits } from 'ethers/utils'\n\nexport interface GasConfig {\n gasLimit?: number\n gasPrice?: bigint\n}\n\nexport const getDefaultGasConfig = (): GasConfig => {\n return {\n gasLimit: 2_000_000, // Set the gas limit\n gasPrice: parseUnits('100', 'gwei'),\n }\n}\n\nexport type EthAddress = Hex\n\nexport const ETH_ZERO_ADDRESS: EthAddress = '0x0000000000000000000000000000000000000000' as const\n\nexport const toEthAddress = (value: bigint | string | AccountInstance): EthAddress => {\n const address = (typeof value === 'object') ? value.address : value\n return getAddress(toHex(address, { prefix: true, bitLength: 160 })) as EthAddress\n}\n","import type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nexport const NetworkStatusSchema = 'network.xyo.chain.status' as const\nexport type NetworkStatusSchema = typeof NetworkStatusSchema\n\nexport type NetworkStatusState = 'online' | 'offline' | 'degraded' | 'unknown'\n\nexport type NetworkStatusUpdate = {\n end: number\n start: number\n update: string\n}\n\nexport interface NetworkStatusFields {\n description: string\n state: NetworkStatusState\n updates?: NetworkStatusUpdate[]\n}\n\nexport type NetworkStatus = Payload<NetworkStatusFields, NetworkStatusSchema>\n\nexport const isNetworkStatus = isPayloadOfSchemaType<NetworkStatus>(NetworkStatusSchema)\n","import type { Address } from '@xylabs/hex'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nexport const ChainIdentificationPayloadSchema = 'network.xyo.chain.identification' as const\nexport type ChainIdentificationPayloadSchema = typeof ChainIdentificationPayloadSchema\n\n/**\n * Identification required to uniquely identify a chain\n */\nexport interface ChainIdentification {\n /** @field the id of the chain */\n id: Address\n}\n\nexport type ChainIdentificationPayload = Payload<ChainIdentification, ChainIdentificationPayloadSchema>\nexport const isChainIdentificationPayload = isPayloadOfSchemaType<ChainIdentificationPayload>(ChainIdentificationPayloadSchema)\n","import type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nexport const ChainInformationPayloadSchema = 'network.xyo.chain.information' as const\nexport type ChainInformationPayloadSchema = typeof ChainInformationPayloadSchema\n\nimport type { ChainIdentification } from './ChainIdentification.ts'\n\n/**\n * Information required to produce a chain\n */\nexport interface ChainInformation extends ChainIdentification {\n // TODO: Add these fields which are currently promises on the smart contract\n // forkedAtBlockNumber: bigint\n // forkedAtHash: Hash\n // forkedChainId: Address\n}\n\nexport type ChainInformationPayload = Payload<ChainIdentification, ChainInformationPayloadSchema>\nexport const isChainInformationPayload = isPayloadOfSchemaType<ChainInformationPayload>(ChainInformationPayloadSchema)\n","import type { Hash } from '@xylabs/hex'\nimport type { JsonValue } from '@xylabs/object'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { Payload, WithStorageMeta } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType, isStorageMeta } from '@xyo-network/payload-model'\n\nexport interface ChainIndexingServiceStateFields<T extends JsonValue = JsonValue> {\n /**\n * The hash of the last block that this service has indexing\n */\n endBlockHash: Hash\n /**\n * The hash of the block that the service started indexing. If undefined, the service is\n * assumed to have started indexing from the genesis block\n */\n startBlockHash?: Hash\n /**\n * The indexed state for the range\n */\n state: T\n}\nexport const ChainIndexingServiceStateSchema = 'network.xyo.chain.indexing.service.state' as const\nexport type ChainIndexingServiceStateSchema = typeof ChainIndexingServiceStateSchema\n\n/**\n * The result of a ChainIndexingServiceState\n */\nexport type ChainIndexingServiceState<T extends JsonValue = JsonValue> = Payload<ChainIndexingServiceStateFields<T>, ChainIndexingServiceStateSchema>\n\n/**\n * Identity functions for determining if an object is an ChainIndexingServiceState\n */\nexport const isChainIndexingServiceState = <T extends JsonValue = JsonValue>(payload?: unknown): payload is ChainIndexingServiceState<T> => {\n return isPayloadOfSchemaType<ChainIndexingServiceState<T>>(ChainIndexingServiceStateSchema)(payload)\n}\nexport const asChainIndexingServiceState = AsObjectFactory.create<ChainIndexingServiceState<JsonValue>>(isChainIndexingServiceState)\n\nexport const isChainIndexingServiceStateWithStorageMeta\n= <T extends JsonValue = JsonValue>(value: unknown): value is WithStorageMeta<ChainIndexingServiceState<T>> =>\n isChainIndexingServiceState<T>(value) && isStorageMeta(value)\n\nexport const asChainIndexingServiceStateWithStorageMeta\n= AsObjectFactory.create<WithStorageMeta<ChainIndexingServiceState>>(isChainIndexingServiceStateWithStorageMeta)\n\nexport const asOptionalChainIndexingServiceStateWithStorageMeta\n= AsObjectFactory.createOptional<WithStorageMeta<ChainIndexingServiceState>>(isChainIndexingServiceStateWithStorageMeta)\n","export const StepSizes = [10, 105, 1103, 11_576, 121_551, 1_276_282, 13_400_956]\n"],"mappings":";AAAA,SAAS,0BAA0B;AAEnC,SAAS,mBAAmB,gBAAgB;AAE5C,SAAS,iBAAiB,oBAAoB;;;ACJ9C,SAAS,uBAAuB;AAEhC,SAAS,6BAA6B;AAK/B,IAAM,yBAAyB;AAc/B,IAAM,qBAAqB,CAAC,MAA8C;AAC/E,SAAO,sBAAwC,sBAAsB,EAAE,CAAC,KACnE,qBAAqB,EAAE,GAAG,MAAM,UAChC,qBAAqB,EAAE,GAAG,MAAM;AACvC;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OfSchemaType","AsObjectFactory","AsObjectFactory","isBoundWitness","isStorageMeta","isPayloadOfSchemaType","isPayloadOfSchemaType","isPayloadOfSchemaType","AsObjectFactory","isPayloadOfSchemaType","isStorageMeta"]}
|
package/dist/node/index.mjs
CHANGED
|
@@ -1,41 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
|
-
// src/ethereum.ts
|
|
5
|
-
import { toHex } from "@xylabs/hex";
|
|
6
|
-
import { getAddress } from "ethers";
|
|
7
|
-
import { parseUnits } from "ethers/utils";
|
|
8
|
-
var getDefaultGasConfig = /* @__PURE__ */ __name(() => {
|
|
9
|
-
return {
|
|
10
|
-
gasLimit: 2e6,
|
|
11
|
-
gasPrice: parseUnits("100", "gwei")
|
|
12
|
-
};
|
|
13
|
-
}, "getDefaultGasConfig");
|
|
14
|
-
var ETH_ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
15
|
-
var toEthAddress = /* @__PURE__ */ __name((value) => {
|
|
16
|
-
const address = typeof value === "object" ? value.address : value;
|
|
17
|
-
return getAddress(toHex(address, {
|
|
18
|
-
prefix: true,
|
|
19
|
-
bitLength: 160
|
|
20
|
-
}));
|
|
21
|
-
}, "toEthAddress");
|
|
22
|
-
|
|
23
|
-
// src/network/Status.ts
|
|
24
|
-
import { isPayloadOfSchemaType } from "@xyo-network/payload-model";
|
|
25
|
-
var NetworkStatusSchema = "network.xyo.chain.status";
|
|
26
|
-
var isNetworkStatus = isPayloadOfSchemaType(NetworkStatusSchema);
|
|
27
|
-
|
|
28
|
-
// src/Steps.ts
|
|
29
|
-
var StepSizes = [
|
|
30
|
-
10,
|
|
31
|
-
105,
|
|
32
|
-
1103,
|
|
33
|
-
11576,
|
|
34
|
-
121551,
|
|
35
|
-
1276282,
|
|
36
|
-
13400956
|
|
37
|
-
];
|
|
38
|
-
|
|
39
1
|
// src/block/AllowedBlockPayload.ts
|
|
40
2
|
import { BoundWitnessSchema } from "@xyo-network/boundwitness-model";
|
|
41
3
|
import { isHashStorageMeta, isSchema } from "@xyo-network/payload-model";
|
|
@@ -43,43 +5,43 @@ import { isSchemaPayload, SchemaSchema } from "@xyo-network/schema-payload-plugi
|
|
|
43
5
|
|
|
44
6
|
// src/payload/elevatable/ChainStakeIntent.ts
|
|
45
7
|
import { AsObjectFactory } from "@xylabs/object";
|
|
46
|
-
import { isPayloadOfSchemaType
|
|
8
|
+
import { isPayloadOfSchemaType } from "@xyo-network/payload-model";
|
|
47
9
|
var ChainStakeIntentSchema = "network.xyo.chain.stake.intent";
|
|
48
|
-
var isChainStakeIntent =
|
|
49
|
-
return
|
|
50
|
-
}
|
|
10
|
+
var isChainStakeIntent = (x) => {
|
|
11
|
+
return isPayloadOfSchemaType(ChainStakeIntentSchema)(x) && asNonNegativeInteger(x.nbf) !== void 0 && asNonNegativeInteger(x.exp) !== void 0;
|
|
12
|
+
};
|
|
51
13
|
var asChainStakeIntent = AsObjectFactory.create(isChainStakeIntent);
|
|
52
14
|
var asOptionalChainStakeIntent = AsObjectFactory.createOptional(isChainStakeIntent);
|
|
53
|
-
var asNonNegativeInteger =
|
|
15
|
+
var asNonNegativeInteger = (num) => {
|
|
54
16
|
return Number.isInteger(num) && num >= 0 ? num : void 0;
|
|
55
|
-
}
|
|
17
|
+
};
|
|
56
18
|
|
|
57
19
|
// src/payload/elevatable/Executable.ts
|
|
58
20
|
import { isAnyPayload } from "@xyo-network/payload-model";
|
|
59
|
-
var hasFrom =
|
|
21
|
+
var hasFrom = (value) => {
|
|
60
22
|
return value.from !== void 0;
|
|
61
|
-
}
|
|
62
|
-
var isExecutable =
|
|
23
|
+
};
|
|
24
|
+
var isExecutable = (value) => {
|
|
63
25
|
return isAnyPayload(value) && Array.isArray(value.script);
|
|
64
|
-
}
|
|
65
|
-
var asExecutable =
|
|
26
|
+
};
|
|
27
|
+
var asExecutable = (value) => {
|
|
66
28
|
return isExecutable(value) ? value : void 0;
|
|
67
|
-
}
|
|
29
|
+
};
|
|
68
30
|
|
|
69
31
|
// src/payload/elevatable/Hash.ts
|
|
70
32
|
import { AsObjectFactory as AsObjectFactory2 } from "@xylabs/object";
|
|
71
|
-
import { isPayloadOfSchemaType as
|
|
33
|
+
import { isPayloadOfSchemaType as isPayloadOfSchemaType2 } from "@xyo-network/payload-model";
|
|
72
34
|
var HashSchema = "network.xyo.hash";
|
|
73
|
-
var isHashPayload =
|
|
35
|
+
var isHashPayload = isPayloadOfSchemaType2(HashSchema);
|
|
74
36
|
var asHashPayload = AsObjectFactory2.create(isHashPayload);
|
|
75
37
|
var asHashPayloadWithStorageMeta = AsObjectFactory2.create(isHashPayload);
|
|
76
38
|
var asOptionalHashPayload = AsObjectFactory2.createOptional(isHashPayload);
|
|
77
39
|
|
|
78
40
|
// src/payload/elevatable/TransferPayload.ts
|
|
79
41
|
import { AsObjectFactory as AsObjectFactory3 } from "@xylabs/object";
|
|
80
|
-
import { isPayloadOfSchemaType as
|
|
42
|
+
import { isPayloadOfSchemaType as isPayloadOfSchemaType3 } from "@xyo-network/payload-model";
|
|
81
43
|
var TransferSchema = "network.xyo.transfer";
|
|
82
|
-
var isTransfer =
|
|
44
|
+
var isTransfer = isPayloadOfSchemaType3(TransferSchema);
|
|
83
45
|
var asTransfer = AsObjectFactory3.create(isTransfer);
|
|
84
46
|
var asOptionalTransfer = AsObjectFactory3.createOptional(isTransfer);
|
|
85
47
|
|
|
@@ -87,51 +49,72 @@ var asOptionalTransfer = AsObjectFactory3.createOptional(isTransfer);
|
|
|
87
49
|
import { AsObjectFactory as AsObjectFactory4 } from "@xylabs/object";
|
|
88
50
|
import { isBoundWitness } from "@xyo-network/boundwitness-model";
|
|
89
51
|
import { isStorageMeta } from "@xyo-network/payload-model";
|
|
90
|
-
var isTransactionBoundWitness =
|
|
52
|
+
var isTransactionBoundWitness = (value) => {
|
|
91
53
|
const typedObj = value;
|
|
92
54
|
return isBoundWitness(value) && typedObj.chain !== void 0 && typedObj.fees !== void 0 && typedObj.exp !== void 0 && typedObj.nbf !== void 0;
|
|
93
|
-
}
|
|
94
|
-
var
|
|
55
|
+
};
|
|
56
|
+
var isSignedTransactionBoundWitness = (value) => {
|
|
57
|
+
return isTransactionBoundWitness(value) && isSigned(value);
|
|
58
|
+
};
|
|
59
|
+
var isSigned = (value) => isBoundWitness(value) && value.$signatures.length === value.addresses.length && value.addresses.length > 0;
|
|
60
|
+
var isTransactionBoundWitnessWithStorageMeta = (value) => isTransactionBoundWitness(value) && isStorageMeta(value);
|
|
61
|
+
var isSignedTransactionBoundWitnessWithStorageMeta = (value) => isSignedTransactionBoundWitness(value) && isStorageMeta(value);
|
|
95
62
|
var asTransactionBoundWitness = AsObjectFactory4.create(isTransactionBoundWitness);
|
|
96
63
|
var asOptionalTransactionBoundWitness = AsObjectFactory4.createOptional(isTransactionBoundWitness);
|
|
97
64
|
var asTransactionBoundWitnessWithStorageMeta = AsObjectFactory4.create(isTransactionBoundWitnessWithStorageMeta);
|
|
98
65
|
var asOptionalTransactionBoundWitnessWithStorageMeta = AsObjectFactory4.createOptional(isTransactionBoundWitnessWithStorageMeta);
|
|
99
66
|
|
|
100
67
|
// src/block/AllowedBlockPayload.ts
|
|
101
|
-
var AllowedBlockPayloadSchemas = [
|
|
102
|
-
|
|
103
|
-
ChainStakeIntentSchema,
|
|
104
|
-
SchemaSchema,
|
|
105
|
-
BoundWitnessSchema,
|
|
106
|
-
HashSchema
|
|
107
|
-
];
|
|
108
|
-
var isAllowedBlockPayloadSchema = /* @__PURE__ */ __name((value) => {
|
|
68
|
+
var AllowedBlockPayloadSchemas = [TransferSchema, ChainStakeIntentSchema, SchemaSchema, BoundWitnessSchema, HashSchema];
|
|
69
|
+
var isAllowedBlockPayloadSchema = (value) => {
|
|
109
70
|
return isSchema(value) && AllowedBlockPayloadSchemas.includes(value);
|
|
110
|
-
}
|
|
111
|
-
var isAllowedBlockPayload =
|
|
71
|
+
};
|
|
72
|
+
var isAllowedBlockPayload = (value) => {
|
|
112
73
|
return isTransfer(value) || isChainStakeIntent(value) || isSchemaPayload(value) || isTransactionBoundWitness(value) || isHashPayload(value);
|
|
113
|
-
}
|
|
114
|
-
var isAllowedBlockPayloadWithHashStorageMeta =
|
|
74
|
+
};
|
|
75
|
+
var isAllowedBlockPayloadWithHashStorageMeta = (value) => {
|
|
115
76
|
return isAllowedBlockPayload(value) && isHashStorageMeta(value);
|
|
116
|
-
}
|
|
77
|
+
};
|
|
117
78
|
|
|
118
79
|
// src/block/BlockBoundWitness.ts
|
|
119
80
|
import { isHex } from "@xylabs/hex";
|
|
120
81
|
import { AsObjectFactory as AsObjectFactory5 } from "@xylabs/object";
|
|
121
82
|
import { isBoundWitness as isBoundWitness2 } from "@xyo-network/boundwitness-model";
|
|
122
83
|
import { isStorageMeta as isStorageMeta2 } from "@xyo-network/payload-model";
|
|
123
|
-
var isBlockBoundWitness =
|
|
84
|
+
var isBlockBoundWitness = (value) => {
|
|
124
85
|
const typedObj = value;
|
|
125
86
|
return isBoundWitness2(value) && Number.isInteger(typedObj.block) && isHex(typedObj.chain);
|
|
126
|
-
}
|
|
127
|
-
var isBlockBoundWitnessWithStorageMeta =
|
|
87
|
+
};
|
|
88
|
+
var isBlockBoundWitnessWithStorageMeta = (value) => {
|
|
128
89
|
return isBlockBoundWitness(value) && isStorageMeta2(value);
|
|
129
|
-
}
|
|
90
|
+
};
|
|
130
91
|
var asBlockBoundWitness = AsObjectFactory5.create(isBlockBoundWitness);
|
|
131
92
|
var asOptionalBlockBoundWitness = AsObjectFactory5.createOptional(isBlockBoundWitness);
|
|
132
93
|
var asBlockBoundWitnessWithStorageMeta = AsObjectFactory5.create(isBlockBoundWitnessWithStorageMeta);
|
|
133
94
|
var asOptionalBlockBoundWitnessWithStorageMeta = AsObjectFactory5.createOptional(isBlockBoundWitnessWithStorageMeta);
|
|
134
95
|
|
|
96
|
+
// src/ethereum.ts
|
|
97
|
+
import { toHex } from "@xylabs/hex";
|
|
98
|
+
import { getAddress } from "ethers";
|
|
99
|
+
import { parseUnits } from "ethers/utils";
|
|
100
|
+
var getDefaultGasConfig = () => {
|
|
101
|
+
return {
|
|
102
|
+
gasLimit: 2e6,
|
|
103
|
+
// Set the gas limit
|
|
104
|
+
gasPrice: parseUnits("100", "gwei")
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
var ETH_ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
108
|
+
var toEthAddress = (value) => {
|
|
109
|
+
const address = typeof value === "object" ? value.address : value;
|
|
110
|
+
return getAddress(toHex(address, { prefix: true, bitLength: 160 }));
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// src/network/Status.ts
|
|
114
|
+
import { isPayloadOfSchemaType as isPayloadOfSchemaType4 } from "@xyo-network/payload-model";
|
|
115
|
+
var NetworkStatusSchema = "network.xyo.chain.status";
|
|
116
|
+
var isNetworkStatus = isPayloadOfSchemaType4(NetworkStatusSchema);
|
|
117
|
+
|
|
135
118
|
// src/services/Chain/ChainIdentification.ts
|
|
136
119
|
import { isPayloadOfSchemaType as isPayloadOfSchemaType5 } from "@xyo-network/payload-model";
|
|
137
120
|
var ChainIdentificationPayloadSchema = "network.xyo.chain.identification";
|
|
@@ -146,13 +129,16 @@ var isChainInformationPayload = isPayloadOfSchemaType6(ChainInformationPayloadSc
|
|
|
146
129
|
import { AsObjectFactory as AsObjectFactory6 } from "@xylabs/object";
|
|
147
130
|
import { isPayloadOfSchemaType as isPayloadOfSchemaType7, isStorageMeta as isStorageMeta3 } from "@xyo-network/payload-model";
|
|
148
131
|
var ChainIndexingServiceStateSchema = "network.xyo.chain.indexing.service.state";
|
|
149
|
-
var isChainIndexingServiceState =
|
|
132
|
+
var isChainIndexingServiceState = (payload) => {
|
|
150
133
|
return isPayloadOfSchemaType7(ChainIndexingServiceStateSchema)(payload);
|
|
151
|
-
}
|
|
134
|
+
};
|
|
152
135
|
var asChainIndexingServiceState = AsObjectFactory6.create(isChainIndexingServiceState);
|
|
153
|
-
var isChainIndexingServiceStateWithStorageMeta =
|
|
136
|
+
var isChainIndexingServiceStateWithStorageMeta = (value) => isChainIndexingServiceState(value) && isStorageMeta3(value);
|
|
154
137
|
var asChainIndexingServiceStateWithStorageMeta = AsObjectFactory6.create(isChainIndexingServiceStateWithStorageMeta);
|
|
155
138
|
var asOptionalChainIndexingServiceStateWithStorageMeta = AsObjectFactory6.createOptional(isChainIndexingServiceStateWithStorageMeta);
|
|
139
|
+
|
|
140
|
+
// src/Steps.ts
|
|
141
|
+
var StepSizes = [10, 105, 1103, 11576, 121551, 1276282, 13400956];
|
|
156
142
|
export {
|
|
157
143
|
AllowedBlockPayloadSchemas,
|
|
158
144
|
ChainIdentificationPayloadSchema,
|
|
@@ -177,7 +163,11 @@ export {
|
|
|
177
163
|
asOptionalChainIndexingServiceStateWithStorageMeta,
|
|
178
164
|
asOptionalChainStakeIntent,
|
|
179
165
|
asOptionalHashPayload,
|
|
166
|
+
asOptionalTransactionBoundWitness,
|
|
167
|
+
asOptionalTransactionBoundWitnessWithStorageMeta,
|
|
180
168
|
asOptionalTransfer,
|
|
169
|
+
asTransactionBoundWitness,
|
|
170
|
+
asTransactionBoundWitnessWithStorageMeta,
|
|
181
171
|
asTransfer,
|
|
182
172
|
getDefaultGasConfig,
|
|
183
173
|
hasFrom,
|
|
@@ -194,6 +184,11 @@ export {
|
|
|
194
184
|
isExecutable,
|
|
195
185
|
isHashPayload,
|
|
196
186
|
isNetworkStatus,
|
|
187
|
+
isSigned,
|
|
188
|
+
isSignedTransactionBoundWitness,
|
|
189
|
+
isSignedTransactionBoundWitnessWithStorageMeta,
|
|
190
|
+
isTransactionBoundWitness,
|
|
191
|
+
isTransactionBoundWitnessWithStorageMeta,
|
|
197
192
|
isTransfer,
|
|
198
193
|
toEthAddress
|
|
199
194
|
};
|
package/dist/node/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ethereum.ts","../../src/network/Status.ts","../../src/Steps.ts","../../src/block/AllowedBlockPayload.ts","../../src/payload/elevatable/ChainStakeIntent.ts","../../src/payload/elevatable/Executable.ts","../../src/payload/elevatable/Hash.ts","../../src/payload/elevatable/TransferPayload.ts","../../src/transaction/TransactionBoundWitness.ts","../../src/block/BlockBoundWitness.ts","../../src/services/Chain/ChainIdentification.ts","../../src/services/Chain/ChainInformation.ts","../../src/services/stakeIntent/ChainIndexingServiceStateSchema.ts"],"sourcesContent":["import type { Hex } from '@xylabs/hex'\nimport { toHex } from '@xylabs/hex'\nimport type { AccountInstance } from '@xyo-network/account-model'\nimport { getAddress } from 'ethers'\nimport { parseUnits } from 'ethers/utils'\n\nexport interface GasConfig {\n gasLimit?: number\n gasPrice?: bigint\n}\n\nexport const getDefaultGasConfig = (): GasConfig => {\n return {\n gasLimit: 2_000_000, // Set the gas limit\n gasPrice: parseUnits('100', 'gwei'),\n }\n}\n\nexport type EthAddress = Hex\n\nexport const ETH_ZERO_ADDRESS: EthAddress = '0x0000000000000000000000000000000000000000' as const\n\nexport const toEthAddress = (value: bigint | string | AccountInstance): EthAddress => {\n const address = (typeof value === 'object') ? value.address : value\n return getAddress(toHex(address, { prefix: true, bitLength: 160 })) as EthAddress\n}\n","import type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nexport const NetworkStatusSchema = 'network.xyo.chain.status' as const\nexport type NetworkStatusSchema = typeof NetworkStatusSchema\n\nexport type NetworkStatusState = 'online' | 'offline' | 'degraded' | 'unknown'\n\nexport type NetworkStatusUpdate = {\n end: number\n start: number\n update: string\n}\n\nexport interface NetworkStatusFields {\n description: string\n state: NetworkStatusState\n updates?: NetworkStatusUpdate[]\n}\n\nexport type NetworkStatus = Payload<NetworkStatusFields, NetworkStatusSchema>\n\nexport const isNetworkStatus = isPayloadOfSchemaType<NetworkStatus>(NetworkStatusSchema)\n","export const StepSizes = [10, 105, 1103, 11_576, 121_551, 1_276_282, 13_400_956]\n","import { BoundWitnessSchema } from '@xyo-network/boundwitness-model'\nimport type { Schema, WithStorageMeta } from '@xyo-network/payload-model'\nimport { isHashStorageMeta, isSchema } from '@xyo-network/payload-model'\nimport type { SchemaPayload } from '@xyo-network/schema-payload-plugin'\nimport { isSchemaPayload, SchemaSchema } from '@xyo-network/schema-payload-plugin'\n\nimport type {\n ChainStakeIntent, HashPayload, Transfer,\n} from '#payload'\nimport {\n ChainStakeIntentSchema, HashSchema, isChainStakeIntent, isHashPayload, isTransfer, TransferSchema,\n} from '#payload'\nimport { isTransactionBoundWitness, type TransactionBoundWitness } from '#transaction'\n\nexport type AllowedBlockPayload = Transfer | ChainStakeIntent | SchemaPayload | TransactionBoundWitness | HashPayload\nexport const AllowedBlockPayloadSchemas: Schema[] = [TransferSchema, ChainStakeIntentSchema, SchemaSchema, BoundWitnessSchema, HashSchema]\nexport type AllowedBlockPayloadSchema = typeof AllowedBlockPayloadSchemas[number]\n\nexport const isAllowedBlockPayloadSchema = (value: unknown): value is AllowedBlockPayloadSchema => {\n return isSchema(value) && AllowedBlockPayloadSchemas.includes(value)\n}\n\nexport const isAllowedBlockPayload = (value: unknown): value is AllowedBlockPayload => {\n return isTransfer(value) || isChainStakeIntent(value) || isSchemaPayload(value) || isTransactionBoundWitness(value) || isHashPayload(value)\n}\n\nexport const isAllowedBlockPayloadWithHashStorageMeta = (value: unknown): value is WithStorageMeta<AllowedBlockPayload> => {\n return isAllowedBlockPayload(value) && isHashStorageMeta(value)\n}\n","import { AsObjectFactory } from '@xylabs/object'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nimport type { BlockDuration } from '../../BlockDuration.ts'\nimport type { FromFields } from './Executable.ts'\n\nexport const ChainStakeIntentSchema = 'network.xyo.chain.stake.intent' as const\nexport type ChainStakeIntentSchema = typeof ChainStakeIntentSchema\n\nexport type Intent = 'producer' // | 'bank'\n\nexport interface ChainStakeIntentFields extends BlockDuration, FromFields {\n /*\n * The intent of the staking\n */\n intent: Intent\n}\n\nexport type ChainStakeIntent = Payload<ChainStakeIntentFields, ChainStakeIntentSchema>\n\nexport const isChainStakeIntent = (x?: unknown | null): x is ChainStakeIntent => {\n return isPayloadOfSchemaType<ChainStakeIntent>(ChainStakeIntentSchema)(x)\n && asNonNegativeInteger(x.nbf) !== undefined\n && asNonNegativeInteger(x.exp) !== undefined\n}\nexport const asChainStakeIntent = AsObjectFactory.create(isChainStakeIntent)\nexport const asOptionalChainStakeIntent = AsObjectFactory.createOptional(isChainStakeIntent)\n\nconst asNonNegativeInteger = (num: number) => {\n return (Number.isInteger(num) && num >= 0) ? num : undefined\n}\n","import type { Address } from '@xylabs/hex'\nimport type { EmptyObject } from '@xylabs/object'\nimport { isAnyPayload } from '@xyo-network/payload-model'\n\nexport interface FromFields {\n // the address that is treated as the source of this action\n from: Address\n}\n\nexport const hasFrom = (value: unknown): value is FromFields => {\n return (value as FromFields).from !== undefined\n}\n\nexport interface ExecutableFields {\n script: string[]\n}\n\nexport type Executable<T extends EmptyObject = EmptyObject> = T & ExecutableFields\nexport type OptionalExecutable<T extends EmptyObject = EmptyObject> = T & Partial<ExecutableFields>\n\nexport const isExecutable = <T extends EmptyObject>(value: T | undefined): value is Executable<T> => {\n return isAnyPayload(value) && Array.isArray((value as unknown as ExecutableFields).script)\n}\n\nexport const asExecutable = <T extends EmptyObject>(value: T | undefined): Executable<T> | undefined => {\n return isExecutable(value)\n ? value as unknown as Executable<T>\n : undefined\n}\n","import type { Hash } from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nexport const HashSchema = 'network.xyo.hash' as const\nexport type HashSchema = typeof HashSchema\n\nexport interface HashFields {\n hash: Hash\n}\n\nexport type HashPayload = Payload<HashFields, HashSchema>\n\nexport const isHashPayload = isPayloadOfSchemaType<HashPayload>(HashSchema)\n\nexport const asHashPayload = AsObjectFactory.create(isHashPayload)\nexport const asHashPayloadWithStorageMeta = AsObjectFactory.create(isHashPayload)\nexport const asOptionalHashPayload = AsObjectFactory.createOptional(isHashPayload)\n","import type {\n Address,\n Hex,\n} from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nimport type { FromFields } from './Executable.ts'\n\nexport const TransferSchema = 'network.xyo.transfer' as const\nexport type TransferSchema = typeof TransferSchema\n\nexport interface TransferFields extends FromFields {\n epoch: number\n // the amount that is being sent to another address\n transfers: Record<Address, Hex>\n}\n\n// if this payload is included in a boundwitness, it needs to be available for inspection to be included in block\nexport type Transfer = Payload<TransferFields, TransferSchema>\n\nexport const isTransfer = isPayloadOfSchemaType<Transfer>(TransferSchema)\n\nexport const asTransfer = AsObjectFactory.create(isTransfer)\nexport const asOptionalTransfer = AsObjectFactory.createOptional(isTransfer)\n","import type { Address } from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { BoundWitness, Signed } from '@xyo-network/boundwitness-model'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport { isStorageMeta } from '@xyo-network/payload-model'\n\nimport type {\n FromFields,\n OptionalExecutable,\n} from '#payload'\n\nimport type { BlockDuration } from '../BlockDuration.ts'\nimport type { TransactionFeesFields } from './TransactionFeesFields.ts'\n\nexport interface TransactionBoundWitnessFields extends BlockDuration, TransactionFeesFields {\n chain: Address\n}\n\nexport type TransactionBoundWitness = BoundWitness<TransactionBoundWitnessFields & OptionalExecutable & FromFields>\n\nexport const isTransactionBoundWitness = (value: unknown): value is TransactionBoundWitness => {\n const typedObj = value as TransactionBoundWitness\n return isBoundWitness(value)\n && typedObj.chain !== undefined\n && typedObj.fees !== undefined\n && typedObj.exp !== undefined\n && typedObj.nbf !== undefined\n}\n\nexport const isSignedTransactionBoundWitness = (value: unknown): value is Signed<TransactionBoundWitness> => {\n return isTransactionBoundWitness(value) && isSigned(value)\n}\n\nexport const isSigned = <T extends BoundWitness = BoundWitness>(value: unknown): value is Signed<T> =>\n isBoundWitness(value)\n && value.$signatures.length === value.addresses.length\n && value.addresses.length > 0\n\nexport const isTransactionBoundWitnessWithStorageMeta = (value: unknown): value is WithStorageMeta<TransactionBoundWitness> =>\n isTransactionBoundWitness(value)\n && isStorageMeta(value)\n\nexport const isSignedTransactionBoundWitnessWithStorageMeta = (value: unknown): value is WithStorageMeta<Signed<TransactionBoundWitness>> =>\n isSignedTransactionBoundWitness(value)\n && isStorageMeta(value)\n\nexport const asTransactionBoundWitness = AsObjectFactory.create(isTransactionBoundWitness)\nexport const asOptionalTransactionBoundWitness = AsObjectFactory.createOptional(isTransactionBoundWitness)\n\nexport const asTransactionBoundWitnessWithStorageMeta = AsObjectFactory.create(isTransactionBoundWitnessWithStorageMeta)\nexport const asOptionalTransactionBoundWitnessWithStorageMeta = AsObjectFactory.createOptional(isTransactionBoundWitnessWithStorageMeta)\n","import type { Hash, Hex } from '@xylabs/hex'\nimport { isHex } from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport { isStorageMeta } from '@xyo-network/payload-model'\n\nexport interface BlockBoundWitnessMeta {\n $epoch: number\n}\n\nexport interface BlockBoundWitnessFields {\n /** Block number */\n block: number\n /** Chain id - this should be \"0\" for the genesis block */\n chain: Hex\n /** Previous block hash if not block 0 */\n previous: Hash | null /* the previous block hash */\n /** Version of the protocol being used major * 1,000,000 + minor * 1,000 + patch */\n protocol: number\n /** Step hashes */\n step_hashes: Hex[]\n}\n\nexport type BlockBoundWitness = BoundWitness<BlockBoundWitnessFields & BlockBoundWitnessMeta>\n\nexport const isBlockBoundWitness = (value: unknown): value is BlockBoundWitness => {\n const typedObj = value as BlockBoundWitness\n return isBoundWitness(value)\n && Number.isInteger(typedObj.block)\n && isHex(typedObj.chain)\n}\n\nexport const isBlockBoundWitnessWithStorageMeta = (value: unknown): value is WithStorageMeta<BlockBoundWitness> => {\n return isBlockBoundWitness(value) && isStorageMeta(value)\n}\n\nexport const asBlockBoundWitness = AsObjectFactory.create(isBlockBoundWitness)\nexport const asOptionalBlockBoundWitness = AsObjectFactory.createOptional(isBlockBoundWitness)\n\nexport const asBlockBoundWitnessWithStorageMeta = AsObjectFactory.create(isBlockBoundWitnessWithStorageMeta)\nexport const asOptionalBlockBoundWitnessWithStorageMeta = AsObjectFactory.createOptional(isBlockBoundWitnessWithStorageMeta)\n","import type { Address } from '@xylabs/hex'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nexport const ChainIdentificationPayloadSchema = 'network.xyo.chain.identification' as const\nexport type ChainIdentificationPayloadSchema = typeof ChainIdentificationPayloadSchema\n\n/**\n * Identification required to uniquely identify a chain\n */\nexport interface ChainIdentification {\n /** @field the id of the chain */\n id: Address\n}\n\nexport type ChainIdentificationPayload = Payload<ChainIdentification, ChainIdentificationPayloadSchema>\nexport const isChainIdentificationPayload = isPayloadOfSchemaType<ChainIdentificationPayload>(ChainIdentificationPayloadSchema)\n","import type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nexport const ChainInformationPayloadSchema = 'network.xyo.chain.information' as const\nexport type ChainInformationPayloadSchema = typeof ChainInformationPayloadSchema\n\nimport type { ChainIdentification } from './ChainIdentification.ts'\n\n/**\n * Information required to produce a chain\n */\nexport interface ChainInformation extends ChainIdentification {\n // TODO: Add these fields which are currently promises on the smart contract\n // forkedAtBlockNumber: bigint\n // forkedAtHash: Hash\n // forkedChainId: Address\n}\n\nexport type ChainInformationPayload = Payload<ChainIdentification, ChainInformationPayloadSchema>\nexport const isChainInformationPayload = isPayloadOfSchemaType<ChainInformationPayload>(ChainInformationPayloadSchema)\n","import type { Hash } from '@xylabs/hex'\nimport type { JsonValue } from '@xylabs/object'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { Payload, WithStorageMeta } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType, isStorageMeta } from '@xyo-network/payload-model'\n\nexport interface ChainIndexingServiceStateFields<T extends JsonValue = JsonValue> {\n /**\n * The hash of the last block that this service has indexing\n */\n endBlockHash: Hash\n /**\n * The hash of the block that the service started indexing. If undefined, the service is\n * assumed to have started indexing from the genesis block\n */\n startBlockHash?: Hash\n /**\n * The indexed state for the range\n */\n state: T\n}\nexport const ChainIndexingServiceStateSchema = 'network.xyo.chain.indexing.service.state' as const\nexport type ChainIndexingServiceStateSchema = typeof ChainIndexingServiceStateSchema\n\n/**\n * The result of a ChainIndexingServiceState\n */\nexport type ChainIndexingServiceState<T extends JsonValue = JsonValue> = Payload<ChainIndexingServiceStateFields<T>, ChainIndexingServiceStateSchema>\n\n/**\n * Identity functions for determining if an object is an ChainIndexingServiceState\n */\nexport const isChainIndexingServiceState = <T extends JsonValue = JsonValue>(payload?: unknown): payload is ChainIndexingServiceState<T> => {\n return isPayloadOfSchemaType<ChainIndexingServiceState<T>>(ChainIndexingServiceStateSchema)(payload)\n}\nexport const asChainIndexingServiceState = AsObjectFactory.create<ChainIndexingServiceState<JsonValue>>(isChainIndexingServiceState)\n\nexport const isChainIndexingServiceStateWithStorageMeta\n= <T extends JsonValue = JsonValue>(value: unknown): value is WithStorageMeta<ChainIndexingServiceState<T>> =>\n isChainIndexingServiceState<T>(value) && isStorageMeta(value)\n\nexport const asChainIndexingServiceStateWithStorageMeta\n= AsObjectFactory.create<WithStorageMeta<ChainIndexingServiceState>>(isChainIndexingServiceStateWithStorageMeta)\n\nexport const asOptionalChainIndexingServiceStateWithStorageMeta\n= AsObjectFactory.createOptional<WithStorageMeta<ChainIndexingServiceState>>(isChainIndexingServiceStateWithStorageMeta)\n"],"mappings":";;;;AACA,SAASA,aAAa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B;AAiB9C,IAAMC,kCAAkC;AAWxC,IAAMC,8BAA8B,wBAAkCC,YAAAA;AAC3E,SAAOC,uBAAoDH,+BAAAA,EAAiCE,OAAAA;AAC9F,GAF2C;AAGpC,IAAME,8BAA8BC,iBAAgBC,OAA6CL,2BAAAA;AAEjG,IAAMM,6CACX,wBAAkCC,UAClCP,4BAA+BO,KAAAA,KAAUC,eAAcD,KAAAA,GADvD;AAGK,IAAME,6CACXL,iBAAgBC,OAAmDC,0CAAAA;AAE9D,IAAMI,qDACXN,iBAAgBO,eAA2DL,0CAAAA;","names":["toHex","getAddress","parseUnits","getDefaultGasConfig","gasLimit","gasPrice","parseUnits","ETH_ZERO_ADDRESS","toEthAddress","value","address","getAddress","toHex","prefix","bitLength","isPayloadOfSchemaType","NetworkStatusSchema","isNetworkStatus","StepSizes","BoundWitnessSchema","isHashStorageMeta","isSchema","isSchemaPayload","SchemaSchema","AsObjectFactory","isPayloadOfSchemaType","ChainStakeIntentSchema","isChainStakeIntent","x","isPayloadOfSchemaType","asNonNegativeInteger","nbf","undefined","exp","asChainStakeIntent","AsObjectFactory","create","asOptionalChainStakeIntent","createOptional","num","Number","isInteger","isAnyPayload","hasFrom","value","from","undefined","isExecutable","isAnyPayload","Array","isArray","script","asExecutable","AsObjectFactory","isPayloadOfSchemaType","HashSchema","isHashPayload","asHashPayload","create","asHashPayloadWithStorageMeta","asOptionalHashPayload","createOptional","AsObjectFactory","isPayloadOfSchemaType","TransferSchema","isTransfer","asTransfer","create","asOptionalTransfer","createOptional","AsObjectFactory","isBoundWitness","isStorageMeta","isTransactionBoundWitness","value","typedObj","isBoundWitness","chain","undefined","fees","exp","nbf","isTransactionBoundWitnessWithStorageMeta","value","isTransactionBoundWitness","isStorageMeta","asTransactionBoundWitness","AsObjectFactory","create","isTransactionBoundWitness","asOptionalTransactionBoundWitness","createOptional","asTransactionBoundWitnessWithStorageMeta","isTransactionBoundWitnessWithStorageMeta","asOptionalTransactionBoundWitnessWithStorageMeta","AllowedBlockPayloadSchemas","TransferSchema","ChainStakeIntentSchema","SchemaSchema","BoundWitnessSchema","HashSchema","isAllowedBlockPayloadSchema","value","isSchema","includes","isAllowedBlockPayload","isTransfer","isChainStakeIntent","isSchemaPayload","isTransactionBoundWitness","isHashPayload","isAllowedBlockPayloadWithHashStorageMeta","isHashStorageMeta","isHex","AsObjectFactory","isBoundWitness","isStorageMeta","isBlockBoundWitness","value","typedObj","isBoundWitness","Number","isInteger","block","isHex","chain","isBlockBoundWitnessWithStorageMeta","isStorageMeta","asBlockBoundWitness","AsObjectFactory","create","asOptionalBlockBoundWitness","createOptional","asBlockBoundWitnessWithStorageMeta","asOptionalBlockBoundWitnessWithStorageMeta","isPayloadOfSchemaType","ChainIdentificationPayloadSchema","isChainIdentificationPayload","isPayloadOfSchemaType","ChainInformationPayloadSchema","isChainInformationPayload","AsObjectFactory","isPayloadOfSchemaType","isStorageMeta","ChainIndexingServiceStateSchema","isChainIndexingServiceState","payload","isPayloadOfSchemaType","asChainIndexingServiceState","AsObjectFactory","create","isChainIndexingServiceStateWithStorageMeta","value","isStorageMeta","asChainIndexingServiceStateWithStorageMeta","asOptionalChainIndexingServiceStateWithStorageMeta","createOptional"]}
|
|
1
|
+
{"version":3,"sources":["../../src/block/AllowedBlockPayload.ts","../../src/payload/elevatable/ChainStakeIntent.ts","../../src/payload/elevatable/Executable.ts","../../src/payload/elevatable/Hash.ts","../../src/payload/elevatable/TransferPayload.ts","../../src/transaction/TransactionBoundWitness.ts","../../src/block/BlockBoundWitness.ts","../../src/ethereum.ts","../../src/network/Status.ts","../../src/services/Chain/ChainIdentification.ts","../../src/services/Chain/ChainInformation.ts","../../src/services/stakeIntent/ChainIndexingServiceStateSchema.ts","../../src/Steps.ts"],"sourcesContent":["import { BoundWitnessSchema } from '@xyo-network/boundwitness-model'\nimport type { Schema, WithStorageMeta } from '@xyo-network/payload-model'\nimport { isHashStorageMeta, isSchema } from '@xyo-network/payload-model'\nimport type { SchemaPayload } from '@xyo-network/schema-payload-plugin'\nimport { isSchemaPayload, SchemaSchema } from '@xyo-network/schema-payload-plugin'\n\nimport type {\n ChainStakeIntent, HashPayload, Transfer,\n} from '#payload'\nimport {\n ChainStakeIntentSchema, HashSchema, isChainStakeIntent, isHashPayload, isTransfer, TransferSchema,\n} from '#payload'\nimport { isTransactionBoundWitness, type TransactionBoundWitness } from '#transaction'\n\nexport type AllowedBlockPayload = Transfer | ChainStakeIntent | SchemaPayload | TransactionBoundWitness | HashPayload\nexport const AllowedBlockPayloadSchemas: Schema[] = [TransferSchema, ChainStakeIntentSchema, SchemaSchema, BoundWitnessSchema, HashSchema]\nexport type AllowedBlockPayloadSchema = typeof AllowedBlockPayloadSchemas[number]\n\nexport const isAllowedBlockPayloadSchema = (value: unknown): value is AllowedBlockPayloadSchema => {\n return isSchema(value) && AllowedBlockPayloadSchemas.includes(value)\n}\n\nexport const isAllowedBlockPayload = (value: unknown): value is AllowedBlockPayload => {\n return isTransfer(value) || isChainStakeIntent(value) || isSchemaPayload(value) || isTransactionBoundWitness(value) || isHashPayload(value)\n}\n\nexport const isAllowedBlockPayloadWithHashStorageMeta = (value: unknown): value is WithStorageMeta<AllowedBlockPayload> => {\n return isAllowedBlockPayload(value) && isHashStorageMeta(value)\n}\n","import { AsObjectFactory } from '@xylabs/object'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nimport type { BlockDuration } from '../../BlockDuration.ts'\nimport type { FromFields } from './Executable.ts'\n\nexport const ChainStakeIntentSchema = 'network.xyo.chain.stake.intent' as const\nexport type ChainStakeIntentSchema = typeof ChainStakeIntentSchema\n\nexport type Intent = 'producer' // | 'bank'\n\nexport interface ChainStakeIntentFields extends BlockDuration, FromFields {\n /*\n * The intent of the staking\n */\n intent: Intent\n}\n\nexport type ChainStakeIntent = Payload<ChainStakeIntentFields, ChainStakeIntentSchema>\n\nexport const isChainStakeIntent = (x?: unknown | null): x is ChainStakeIntent => {\n return isPayloadOfSchemaType<ChainStakeIntent>(ChainStakeIntentSchema)(x)\n && asNonNegativeInteger(x.nbf) !== undefined\n && asNonNegativeInteger(x.exp) !== undefined\n}\nexport const asChainStakeIntent = AsObjectFactory.create(isChainStakeIntent)\nexport const asOptionalChainStakeIntent = AsObjectFactory.createOptional(isChainStakeIntent)\n\nconst asNonNegativeInteger = (num: number) => {\n return (Number.isInteger(num) && num >= 0) ? num : undefined\n}\n","import type { Address } from '@xylabs/hex'\nimport type { EmptyObject } from '@xylabs/object'\nimport { isAnyPayload } from '@xyo-network/payload-model'\n\nexport interface FromFields {\n // the address that is treated as the source of this action\n from: Address\n}\n\nexport const hasFrom = (value: unknown): value is FromFields => {\n return (value as FromFields).from !== undefined\n}\n\nexport interface ExecutableFields {\n script: string[]\n}\n\nexport type Executable<T extends EmptyObject = EmptyObject> = T & ExecutableFields\nexport type OptionalExecutable<T extends EmptyObject = EmptyObject> = T & Partial<ExecutableFields>\n\nexport const isExecutable = <T extends EmptyObject>(value: T | undefined): value is Executable<T> => {\n return isAnyPayload(value) && Array.isArray((value as unknown as ExecutableFields).script)\n}\n\nexport const asExecutable = <T extends EmptyObject>(value: T | undefined): Executable<T> | undefined => {\n return isExecutable(value)\n ? value as unknown as Executable<T>\n : undefined\n}\n","import type { Hash } from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nexport const HashSchema = 'network.xyo.hash' as const\nexport type HashSchema = typeof HashSchema\n\nexport interface HashFields {\n hash: Hash\n}\n\nexport type HashPayload = Payload<HashFields, HashSchema>\n\nexport const isHashPayload = isPayloadOfSchemaType<HashPayload>(HashSchema)\n\nexport const asHashPayload = AsObjectFactory.create(isHashPayload)\nexport const asHashPayloadWithStorageMeta = AsObjectFactory.create(isHashPayload)\nexport const asOptionalHashPayload = AsObjectFactory.createOptional(isHashPayload)\n","import type {\n Address,\n Hex,\n} from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nimport type { FromFields } from './Executable.ts'\n\nexport const TransferSchema = 'network.xyo.transfer' as const\nexport type TransferSchema = typeof TransferSchema\n\nexport interface TransferFields extends FromFields {\n epoch: number\n // the amount that is being sent to another address\n transfers: Record<Address, Hex>\n}\n\n// if this payload is included in a boundwitness, it needs to be available for inspection to be included in block\nexport type Transfer = Payload<TransferFields, TransferSchema>\n\nexport const isTransfer = isPayloadOfSchemaType<Transfer>(TransferSchema)\n\nexport const asTransfer = AsObjectFactory.create(isTransfer)\nexport const asOptionalTransfer = AsObjectFactory.createOptional(isTransfer)\n","import type { Address } from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { BoundWitness, Signed } from '@xyo-network/boundwitness-model'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport { isStorageMeta } from '@xyo-network/payload-model'\n\nimport type {\n FromFields,\n OptionalExecutable,\n} from '#payload'\n\nimport type { BlockDuration } from '../BlockDuration.ts'\nimport type { TransactionFeesFields } from './TransactionFeesFields.ts'\n\nexport interface TransactionBoundWitnessFields extends BlockDuration, TransactionFeesFields {\n chain: Address\n}\n\nexport type TransactionBoundWitness = BoundWitness<TransactionBoundWitnessFields & OptionalExecutable & FromFields>\n\nexport const isTransactionBoundWitness = (value: unknown): value is TransactionBoundWitness => {\n const typedObj = value as TransactionBoundWitness\n return isBoundWitness(value)\n && typedObj.chain !== undefined\n && typedObj.fees !== undefined\n && typedObj.exp !== undefined\n && typedObj.nbf !== undefined\n}\n\nexport const isSignedTransactionBoundWitness = (value: unknown): value is Signed<TransactionBoundWitness> => {\n return isTransactionBoundWitness(value) && isSigned(value)\n}\n\nexport const isSigned = <T extends BoundWitness = BoundWitness>(value: unknown): value is Signed<T> =>\n isBoundWitness(value)\n && value.$signatures.length === value.addresses.length\n && value.addresses.length > 0\n\nexport const isTransactionBoundWitnessWithStorageMeta = (value: unknown): value is WithStorageMeta<TransactionBoundWitness> =>\n isTransactionBoundWitness(value)\n && isStorageMeta(value)\n\nexport const isSignedTransactionBoundWitnessWithStorageMeta = (value: unknown): value is WithStorageMeta<Signed<TransactionBoundWitness>> =>\n isSignedTransactionBoundWitness(value)\n && isStorageMeta(value)\n\nexport const asTransactionBoundWitness = AsObjectFactory.create(isTransactionBoundWitness)\nexport const asOptionalTransactionBoundWitness = AsObjectFactory.createOptional(isTransactionBoundWitness)\n\nexport const asTransactionBoundWitnessWithStorageMeta = AsObjectFactory.create(isTransactionBoundWitnessWithStorageMeta)\nexport const asOptionalTransactionBoundWitnessWithStorageMeta = AsObjectFactory.createOptional(isTransactionBoundWitnessWithStorageMeta)\n","import type { Hash, Hex } from '@xylabs/hex'\nimport { isHex } from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport { isStorageMeta } from '@xyo-network/payload-model'\n\nexport interface BlockBoundWitnessMeta {\n $epoch: number\n}\n\nexport interface BlockBoundWitnessFields {\n /** Block number */\n block: number\n /** Chain id - this should be \"0\" for the genesis block */\n chain: Hex\n /** Previous block hash if not block 0 */\n previous: Hash | null /* the previous block hash */\n /** Version of the protocol being used major * 1,000,000 + minor * 1,000 + patch */\n protocol: number\n /** Step hashes */\n step_hashes: Hex[]\n}\n\nexport type BlockBoundWitness = BoundWitness<BlockBoundWitnessFields & BlockBoundWitnessMeta>\n\nexport const isBlockBoundWitness = (value: unknown): value is BlockBoundWitness => {\n const typedObj = value as BlockBoundWitness\n return isBoundWitness(value)\n && Number.isInteger(typedObj.block)\n && isHex(typedObj.chain)\n}\n\nexport const isBlockBoundWitnessWithStorageMeta = (value: unknown): value is WithStorageMeta<BlockBoundWitness> => {\n return isBlockBoundWitness(value) && isStorageMeta(value)\n}\n\nexport const asBlockBoundWitness = AsObjectFactory.create(isBlockBoundWitness)\nexport const asOptionalBlockBoundWitness = AsObjectFactory.createOptional(isBlockBoundWitness)\n\nexport const asBlockBoundWitnessWithStorageMeta = AsObjectFactory.create(isBlockBoundWitnessWithStorageMeta)\nexport const asOptionalBlockBoundWitnessWithStorageMeta = AsObjectFactory.createOptional(isBlockBoundWitnessWithStorageMeta)\n","import type { Hex } from '@xylabs/hex'\nimport { toHex } from '@xylabs/hex'\nimport type { AccountInstance } from '@xyo-network/account-model'\nimport { getAddress } from 'ethers'\nimport { parseUnits } from 'ethers/utils'\n\nexport interface GasConfig {\n gasLimit?: number\n gasPrice?: bigint\n}\n\nexport const getDefaultGasConfig = (): GasConfig => {\n return {\n gasLimit: 2_000_000, // Set the gas limit\n gasPrice: parseUnits('100', 'gwei'),\n }\n}\n\nexport type EthAddress = Hex\n\nexport const ETH_ZERO_ADDRESS: EthAddress = '0x0000000000000000000000000000000000000000' as const\n\nexport const toEthAddress = (value: bigint | string | AccountInstance): EthAddress => {\n const address = (typeof value === 'object') ? value.address : value\n return getAddress(toHex(address, { prefix: true, bitLength: 160 })) as EthAddress\n}\n","import type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nexport const NetworkStatusSchema = 'network.xyo.chain.status' as const\nexport type NetworkStatusSchema = typeof NetworkStatusSchema\n\nexport type NetworkStatusState = 'online' | 'offline' | 'degraded' | 'unknown'\n\nexport type NetworkStatusUpdate = {\n end: number\n start: number\n update: string\n}\n\nexport interface NetworkStatusFields {\n description: string\n state: NetworkStatusState\n updates?: NetworkStatusUpdate[]\n}\n\nexport type NetworkStatus = Payload<NetworkStatusFields, NetworkStatusSchema>\n\nexport const isNetworkStatus = isPayloadOfSchemaType<NetworkStatus>(NetworkStatusSchema)\n","import type { Address } from '@xylabs/hex'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nexport const ChainIdentificationPayloadSchema = 'network.xyo.chain.identification' as const\nexport type ChainIdentificationPayloadSchema = typeof ChainIdentificationPayloadSchema\n\n/**\n * Identification required to uniquely identify a chain\n */\nexport interface ChainIdentification {\n /** @field the id of the chain */\n id: Address\n}\n\nexport type ChainIdentificationPayload = Payload<ChainIdentification, ChainIdentificationPayloadSchema>\nexport const isChainIdentificationPayload = isPayloadOfSchemaType<ChainIdentificationPayload>(ChainIdentificationPayloadSchema)\n","import type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nexport const ChainInformationPayloadSchema = 'network.xyo.chain.information' as const\nexport type ChainInformationPayloadSchema = typeof ChainInformationPayloadSchema\n\nimport type { ChainIdentification } from './ChainIdentification.ts'\n\n/**\n * Information required to produce a chain\n */\nexport interface ChainInformation extends ChainIdentification {\n // TODO: Add these fields which are currently promises on the smart contract\n // forkedAtBlockNumber: bigint\n // forkedAtHash: Hash\n // forkedChainId: Address\n}\n\nexport type ChainInformationPayload = Payload<ChainIdentification, ChainInformationPayloadSchema>\nexport const isChainInformationPayload = isPayloadOfSchemaType<ChainInformationPayload>(ChainInformationPayloadSchema)\n","import type { Hash } from '@xylabs/hex'\nimport type { JsonValue } from '@xylabs/object'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { Payload, WithStorageMeta } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType, isStorageMeta } from '@xyo-network/payload-model'\n\nexport interface ChainIndexingServiceStateFields<T extends JsonValue = JsonValue> {\n /**\n * The hash of the last block that this service has indexing\n */\n endBlockHash: Hash\n /**\n * The hash of the block that the service started indexing. If undefined, the service is\n * assumed to have started indexing from the genesis block\n */\n startBlockHash?: Hash\n /**\n * The indexed state for the range\n */\n state: T\n}\nexport const ChainIndexingServiceStateSchema = 'network.xyo.chain.indexing.service.state' as const\nexport type ChainIndexingServiceStateSchema = typeof ChainIndexingServiceStateSchema\n\n/**\n * The result of a ChainIndexingServiceState\n */\nexport type ChainIndexingServiceState<T extends JsonValue = JsonValue> = Payload<ChainIndexingServiceStateFields<T>, ChainIndexingServiceStateSchema>\n\n/**\n * Identity functions for determining if an object is an ChainIndexingServiceState\n */\nexport const isChainIndexingServiceState = <T extends JsonValue = JsonValue>(payload?: unknown): payload is ChainIndexingServiceState<T> => {\n return isPayloadOfSchemaType<ChainIndexingServiceState<T>>(ChainIndexingServiceStateSchema)(payload)\n}\nexport const asChainIndexingServiceState = AsObjectFactory.create<ChainIndexingServiceState<JsonValue>>(isChainIndexingServiceState)\n\nexport const isChainIndexingServiceStateWithStorageMeta\n= <T extends JsonValue = JsonValue>(value: unknown): value is WithStorageMeta<ChainIndexingServiceState<T>> =>\n isChainIndexingServiceState<T>(value) && isStorageMeta(value)\n\nexport const asChainIndexingServiceStateWithStorageMeta\n= AsObjectFactory.create<WithStorageMeta<ChainIndexingServiceState>>(isChainIndexingServiceStateWithStorageMeta)\n\nexport const asOptionalChainIndexingServiceStateWithStorageMeta\n= AsObjectFactory.createOptional<WithStorageMeta<ChainIndexingServiceState>>(isChainIndexingServiceStateWithStorageMeta)\n","export const StepSizes = [10, 105, 1103, 11_576, 121_551, 1_276_282, 13_400_956]\n"],"mappings":";AAAA,SAAS,0BAA0B;AAEnC,SAAS,mBAAmB,gBAAgB;AAE5C,SAAS,iBAAiB,oBAAoB;;;ACJ9C,SAAS,uBAAuB;AAEhC,SAAS,6BAA6B;AAK/B,IAAM,yBAAyB;AAc/B,IAAM,qBAAqB,CAAC,MAA8C;AAC/E,SAAO,sBAAwC,sBAAsB,EAAE,CAAC,KACnE,qBAAqB,EAAE,GAAG,MAAM,UAChC,qBAAqB,EAAE,GAAG,MAAM;AACvC;AACO,IAAM,qBAAqB,gBAAgB,OAAO,kBAAkB;AACpE,IAAM,6BAA6B,gBAAgB,eAAe,kBAAkB;AAE3F,IAAM,uBAAuB,CAAC,QAAgB;AAC5C,SAAQ,OAAO,UAAU,GAAG,KAAK,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AAsB,MAAiB;AAClD,SAAO;AAAA,IACL,UAAU;AAAA;AAAA,IACV,UAAU,WAAW,OAAO,MAAM;AAAA,EACpC;AACF;AAIO,IAAM,mBAA+B;AAErC,IAAM,eAAe,CAAC,UAAyD;AACpF,QAAM,UAAW,OAAO,UAAU,WAAY,MAAM,UAAU;AAC9D,SAAO,WAAW,MAAM,SAAS,EAAE,QAAQ,MAAM,WAAW,IAAI,CAAC,CAAC;AACpE;;;ACxBA,SAAS,yBAAAG,8BAA6B;AAE/B,IAAM,sBAAsB;AAmB5B,IAAM,kBAAkBA,uBAAqC,mBAAmB;;;ACpBvF,SAAS,yBAAAC,8BAA6B;AAE/B,IAAM,mCAAmC;AAYzC,IAAM,+BAA+BA,uBAAkD,gCAAgC;;;ACf9H,SAAS,yBAAAC,8BAA6B;AAE/B,IAAM,gCAAgC;AAgBtC,IAAM,4BAA4BA,uBAA+C,6BAA6B;;;ACjBrH,SAAS,mBAAAC,wBAAuB;AAEhC,SAAS,yBAAAC,wBAAuB,iBAAAC,sBAAqB;AAiB9C,IAAM,kCAAkC;AAWxC,IAAM,8BAA8B,CAAkC,YAA+D;AAC1I,SAAOD,uBAAoD,+BAA+B,EAAE,OAAO;AACrG;AACO,IAAM,8BAA8BD,iBAAgB,OAA6C,2BAA2B;AAE5H,IAAM,6CACX,CAAkC,UAClC,4BAA+B,KAAK,KAAKE,eAAc,KAAK;AAEvD,IAAM,6CACXF,iBAAgB,OAAmD,0CAA0C;AAExG,IAAM,qDACXA,iBAAgB,eAA2D,0CAA0C;;;AC7ChH,IAAM,YAAY,CAAC,IAAI,KAAK,MAAM,OAAQ,QAAS,SAAW,QAAU;","names":["AsObjectFactory","isPayloadOfSchemaType","AsObjectFactory","isPayloadOfSchemaType","AsObjectFactory","AsObjectFactory","isBoundWitness","isStorageMeta","isPayloadOfSchemaType","isPayloadOfSchemaType","isPayloadOfSchemaType","AsObjectFactory","isPayloadOfSchemaType","isStorageMeta"]}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from './Addressable.ts';
|
|
2
|
+
export * from './block/index.ts';
|
|
2
3
|
export * from './BlockDuration.ts';
|
|
3
4
|
export * from './ChainIterator.ts';
|
|
4
5
|
export * from './ChainIteratorEventData.ts';
|
|
@@ -6,11 +7,10 @@ export * from './ethereum.ts';
|
|
|
6
7
|
export * from './Initializable.ts';
|
|
7
8
|
export * from './network/index.ts';
|
|
8
9
|
export * from './OpenTelemetryProviders.ts';
|
|
10
|
+
export * from './payload/index.ts';
|
|
11
|
+
export * from './provider/index.ts';
|
|
12
|
+
export * from './repository/index.ts';
|
|
13
|
+
export * from './services/index.ts';
|
|
9
14
|
export * from './Steps.ts';
|
|
10
|
-
export * from '
|
|
11
|
-
export * from '#payload';
|
|
12
|
-
export * from '#provider';
|
|
13
|
-
export * from '#repository';
|
|
14
|
-
export * from '#services';
|
|
15
|
-
export * from '#validation';
|
|
15
|
+
export * from './transaction/index.ts';
|
|
16
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,eAAe,CAAA;AAC7B,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,eAAe,CAAA;AAC7B,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,uBAAuB,CAAA;AACrC,cAAc,qBAAqB,CAAA;AACnC,cAAc,YAAY,CAAA;AAC1B,cAAc,wBAAwB,CAAA"}
|
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-protocol",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.23",
|
|
5
5
|
"description": "XYO Layer One Protocol",
|
|
6
6
|
"homepage": "https://xylabs.com",
|
|
7
7
|
"bugs": {
|
|
@@ -53,10 +53,10 @@
|
|
|
53
53
|
"dependency-cruiser": "^16.10.2",
|
|
54
54
|
"dotenv": "^16.5.0",
|
|
55
55
|
"eslint": "^9.27.0",
|
|
56
|
+
"eslint-import-resolver-typescript": "^4.3.5",
|
|
56
57
|
"knip": "^5.56.0",
|
|
57
58
|
"typescript": "^5.8.3",
|
|
58
59
|
"vite": "^6.3.5",
|
|
59
|
-
"vite-plugin-top-level-await": "^1.5.0",
|
|
60
60
|
"vite-tsconfig-paths": "^5.1.4",
|
|
61
61
|
"vitest": "^3.1.4"
|
|
62
62
|
},
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from './Addressable.ts'
|
|
2
|
+
export * from './block/index.ts'
|
|
2
3
|
export * from './BlockDuration.ts'
|
|
3
4
|
export * from './ChainIterator.ts'
|
|
4
5
|
export * from './ChainIteratorEventData.ts'
|
|
@@ -6,10 +7,9 @@ export * from './ethereum.ts'
|
|
|
6
7
|
export * from './Initializable.ts'
|
|
7
8
|
export * from './network/index.ts'
|
|
8
9
|
export * from './OpenTelemetryProviders.ts'
|
|
10
|
+
export * from './payload/index.ts'
|
|
11
|
+
export * from './provider/index.ts'
|
|
12
|
+
export * from './repository/index.ts'
|
|
13
|
+
export * from './services/index.ts'
|
|
9
14
|
export * from './Steps.ts'
|
|
10
|
-
export * from '
|
|
11
|
-
export * from '#payload'
|
|
12
|
-
export * from '#provider'
|
|
13
|
-
export * from '#repository'
|
|
14
|
-
export * from '#services'
|
|
15
|
-
export * from '#validation'
|
|
15
|
+
export * from './transaction/index.ts'
|
package/vite.config.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { config } from 'dotenv'
|
|
2
|
-
import { defineConfig } from 'vite'
|
|
3
|
-
import topLevelAwait from 'vite-plugin-top-level-await'
|
|
4
|
-
|
|
5
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
|
-
const TopLevelAwaitPlugin = topLevelAwait as any
|
|
7
|
-
|
|
8
|
-
config()
|
|
9
|
-
|
|
10
|
-
const parsedPort = Number.parseInt(process.env.PORT ?? '')
|
|
11
|
-
const port = Number.isNaN(parsedPort) ? 3000 : parsedPort
|
|
12
|
-
|
|
13
|
-
// https://vitejs.dev/config/
|
|
14
|
-
export default defineConfig({
|
|
15
|
-
base: '/',
|
|
16
|
-
build: { target: 'esnext' },
|
|
17
|
-
// @bitauth/libauth does not have top level awaits that SB does not like
|
|
18
|
-
optimizeDeps: { exclude: ['@bitauth/libauth'] },
|
|
19
|
-
plugins: [{
|
|
20
|
-
...TopLevelAwaitPlugin({
|
|
21
|
-
// The export name of top-level await promise for each chunk module
|
|
22
|
-
promiseExportName: '__tla',
|
|
23
|
-
// The function to generate import names of top-level await promise in each chunk module
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
|
-
promiseImportName: (i: any) => `__tla_${i}`,
|
|
26
|
-
}),
|
|
27
|
-
apply: 'serve',
|
|
28
|
-
}],
|
|
29
|
-
server: { port, sourcemapIgnoreList: () => true },
|
|
30
|
-
})
|