@xyo-network/xl1-protocol 1.3.22 → 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 +38 -57
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/node/index.mjs +38 -57
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -2
- package/vite.config.ts +0 -30
package/dist/neutral/index.mjs
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
1
|
// src/block/AllowedBlockPayload.ts
|
|
5
2
|
import { BoundWitnessSchema } from "@xyo-network/boundwitness-model";
|
|
6
3
|
import { isHashStorageMeta, isSchema } from "@xyo-network/payload-model";
|
|
@@ -10,26 +7,26 @@ import { isSchemaPayload, SchemaSchema } from "@xyo-network/schema-payload-plugi
|
|
|
10
7
|
import { AsObjectFactory } from "@xylabs/object";
|
|
11
8
|
import { isPayloadOfSchemaType } from "@xyo-network/payload-model";
|
|
12
9
|
var ChainStakeIntentSchema = "network.xyo.chain.stake.intent";
|
|
13
|
-
var isChainStakeIntent =
|
|
10
|
+
var isChainStakeIntent = (x) => {
|
|
14
11
|
return isPayloadOfSchemaType(ChainStakeIntentSchema)(x) && asNonNegativeInteger(x.nbf) !== void 0 && asNonNegativeInteger(x.exp) !== void 0;
|
|
15
|
-
}
|
|
12
|
+
};
|
|
16
13
|
var asChainStakeIntent = AsObjectFactory.create(isChainStakeIntent);
|
|
17
14
|
var asOptionalChainStakeIntent = AsObjectFactory.createOptional(isChainStakeIntent);
|
|
18
|
-
var asNonNegativeInteger =
|
|
15
|
+
var asNonNegativeInteger = (num) => {
|
|
19
16
|
return Number.isInteger(num) && num >= 0 ? num : void 0;
|
|
20
|
-
}
|
|
17
|
+
};
|
|
21
18
|
|
|
22
19
|
// src/payload/elevatable/Executable.ts
|
|
23
20
|
import { isAnyPayload } from "@xyo-network/payload-model";
|
|
24
|
-
var hasFrom =
|
|
21
|
+
var hasFrom = (value) => {
|
|
25
22
|
return value.from !== void 0;
|
|
26
|
-
}
|
|
27
|
-
var isExecutable =
|
|
23
|
+
};
|
|
24
|
+
var isExecutable = (value) => {
|
|
28
25
|
return isAnyPayload(value) && Array.isArray(value.script);
|
|
29
|
-
}
|
|
30
|
-
var asExecutable =
|
|
26
|
+
};
|
|
27
|
+
var asExecutable = (value) => {
|
|
31
28
|
return isExecutable(value) ? value : void 0;
|
|
32
|
-
}
|
|
29
|
+
};
|
|
33
30
|
|
|
34
31
|
// src/payload/elevatable/Hash.ts
|
|
35
32
|
import { AsObjectFactory as AsObjectFactory2 } from "@xylabs/object";
|
|
@@ -52,51 +49,45 @@ var asOptionalTransfer = AsObjectFactory3.createOptional(isTransfer);
|
|
|
52
49
|
import { AsObjectFactory as AsObjectFactory4 } from "@xylabs/object";
|
|
53
50
|
import { isBoundWitness } from "@xyo-network/boundwitness-model";
|
|
54
51
|
import { isStorageMeta } from "@xyo-network/payload-model";
|
|
55
|
-
var isTransactionBoundWitness =
|
|
52
|
+
var isTransactionBoundWitness = (value) => {
|
|
56
53
|
const typedObj = value;
|
|
57
54
|
return isBoundWitness(value) && typedObj.chain !== void 0 && typedObj.fees !== void 0 && typedObj.exp !== void 0 && typedObj.nbf !== void 0;
|
|
58
|
-
}
|
|
59
|
-
var isSignedTransactionBoundWitness =
|
|
55
|
+
};
|
|
56
|
+
var isSignedTransactionBoundWitness = (value) => {
|
|
60
57
|
return isTransactionBoundWitness(value) && isSigned(value);
|
|
61
|
-
}
|
|
62
|
-
var isSigned =
|
|
63
|
-
var isTransactionBoundWitnessWithStorageMeta =
|
|
64
|
-
var isSignedTransactionBoundWitnessWithStorageMeta =
|
|
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);
|
|
65
62
|
var asTransactionBoundWitness = AsObjectFactory4.create(isTransactionBoundWitness);
|
|
66
63
|
var asOptionalTransactionBoundWitness = AsObjectFactory4.createOptional(isTransactionBoundWitness);
|
|
67
64
|
var asTransactionBoundWitnessWithStorageMeta = AsObjectFactory4.create(isTransactionBoundWitnessWithStorageMeta);
|
|
68
65
|
var asOptionalTransactionBoundWitnessWithStorageMeta = AsObjectFactory4.createOptional(isTransactionBoundWitnessWithStorageMeta);
|
|
69
66
|
|
|
70
67
|
// src/block/AllowedBlockPayload.ts
|
|
71
|
-
var AllowedBlockPayloadSchemas = [
|
|
72
|
-
|
|
73
|
-
ChainStakeIntentSchema,
|
|
74
|
-
SchemaSchema,
|
|
75
|
-
BoundWitnessSchema,
|
|
76
|
-
HashSchema
|
|
77
|
-
];
|
|
78
|
-
var isAllowedBlockPayloadSchema = /* @__PURE__ */ __name((value) => {
|
|
68
|
+
var AllowedBlockPayloadSchemas = [TransferSchema, ChainStakeIntentSchema, SchemaSchema, BoundWitnessSchema, HashSchema];
|
|
69
|
+
var isAllowedBlockPayloadSchema = (value) => {
|
|
79
70
|
return isSchema(value) && AllowedBlockPayloadSchemas.includes(value);
|
|
80
|
-
}
|
|
81
|
-
var isAllowedBlockPayload =
|
|
71
|
+
};
|
|
72
|
+
var isAllowedBlockPayload = (value) => {
|
|
82
73
|
return isTransfer(value) || isChainStakeIntent(value) || isSchemaPayload(value) || isTransactionBoundWitness(value) || isHashPayload(value);
|
|
83
|
-
}
|
|
84
|
-
var isAllowedBlockPayloadWithHashStorageMeta =
|
|
74
|
+
};
|
|
75
|
+
var isAllowedBlockPayloadWithHashStorageMeta = (value) => {
|
|
85
76
|
return isAllowedBlockPayload(value) && isHashStorageMeta(value);
|
|
86
|
-
}
|
|
77
|
+
};
|
|
87
78
|
|
|
88
79
|
// src/block/BlockBoundWitness.ts
|
|
89
80
|
import { isHex } from "@xylabs/hex";
|
|
90
81
|
import { AsObjectFactory as AsObjectFactory5 } from "@xylabs/object";
|
|
91
82
|
import { isBoundWitness as isBoundWitness2 } from "@xyo-network/boundwitness-model";
|
|
92
83
|
import { isStorageMeta as isStorageMeta2 } from "@xyo-network/payload-model";
|
|
93
|
-
var isBlockBoundWitness =
|
|
84
|
+
var isBlockBoundWitness = (value) => {
|
|
94
85
|
const typedObj = value;
|
|
95
86
|
return isBoundWitness2(value) && Number.isInteger(typedObj.block) && isHex(typedObj.chain);
|
|
96
|
-
}
|
|
97
|
-
var isBlockBoundWitnessWithStorageMeta =
|
|
87
|
+
};
|
|
88
|
+
var isBlockBoundWitnessWithStorageMeta = (value) => {
|
|
98
89
|
return isBlockBoundWitness(value) && isStorageMeta2(value);
|
|
99
|
-
}
|
|
90
|
+
};
|
|
100
91
|
var asBlockBoundWitness = AsObjectFactory5.create(isBlockBoundWitness);
|
|
101
92
|
var asOptionalBlockBoundWitness = AsObjectFactory5.createOptional(isBlockBoundWitness);
|
|
102
93
|
var asBlockBoundWitnessWithStorageMeta = AsObjectFactory5.create(isBlockBoundWitnessWithStorageMeta);
|
|
@@ -106,20 +97,18 @@ var asOptionalBlockBoundWitnessWithStorageMeta = AsObjectFactory5.createOptional
|
|
|
106
97
|
import { toHex } from "@xylabs/hex";
|
|
107
98
|
import { getAddress } from "ethers";
|
|
108
99
|
import { parseUnits } from "ethers/utils";
|
|
109
|
-
var getDefaultGasConfig =
|
|
100
|
+
var getDefaultGasConfig = () => {
|
|
110
101
|
return {
|
|
111
102
|
gasLimit: 2e6,
|
|
103
|
+
// Set the gas limit
|
|
112
104
|
gasPrice: parseUnits("100", "gwei")
|
|
113
105
|
};
|
|
114
|
-
}
|
|
106
|
+
};
|
|
115
107
|
var ETH_ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
116
|
-
var toEthAddress =
|
|
108
|
+
var toEthAddress = (value) => {
|
|
117
109
|
const address = typeof value === "object" ? value.address : value;
|
|
118
|
-
return getAddress(toHex(address, {
|
|
119
|
-
|
|
120
|
-
bitLength: 160
|
|
121
|
-
}));
|
|
122
|
-
}, "toEthAddress");
|
|
110
|
+
return getAddress(toHex(address, { prefix: true, bitLength: 160 }));
|
|
111
|
+
};
|
|
123
112
|
|
|
124
113
|
// src/network/Status.ts
|
|
125
114
|
import { isPayloadOfSchemaType as isPayloadOfSchemaType4 } from "@xyo-network/payload-model";
|
|
@@ -140,24 +129,16 @@ var isChainInformationPayload = isPayloadOfSchemaType6(ChainInformationPayloadSc
|
|
|
140
129
|
import { AsObjectFactory as AsObjectFactory6 } from "@xylabs/object";
|
|
141
130
|
import { isPayloadOfSchemaType as isPayloadOfSchemaType7, isStorageMeta as isStorageMeta3 } from "@xyo-network/payload-model";
|
|
142
131
|
var ChainIndexingServiceStateSchema = "network.xyo.chain.indexing.service.state";
|
|
143
|
-
var isChainIndexingServiceState =
|
|
132
|
+
var isChainIndexingServiceState = (payload) => {
|
|
144
133
|
return isPayloadOfSchemaType7(ChainIndexingServiceStateSchema)(payload);
|
|
145
|
-
}
|
|
134
|
+
};
|
|
146
135
|
var asChainIndexingServiceState = AsObjectFactory6.create(isChainIndexingServiceState);
|
|
147
|
-
var isChainIndexingServiceStateWithStorageMeta =
|
|
136
|
+
var isChainIndexingServiceStateWithStorageMeta = (value) => isChainIndexingServiceState(value) && isStorageMeta3(value);
|
|
148
137
|
var asChainIndexingServiceStateWithStorageMeta = AsObjectFactory6.create(isChainIndexingServiceStateWithStorageMeta);
|
|
149
138
|
var asOptionalChainIndexingServiceStateWithStorageMeta = AsObjectFactory6.createOptional(isChainIndexingServiceStateWithStorageMeta);
|
|
150
139
|
|
|
151
140
|
// src/Steps.ts
|
|
152
|
-
var StepSizes = [
|
|
153
|
-
10,
|
|
154
|
-
105,
|
|
155
|
-
1103,
|
|
156
|
-
11576,
|
|
157
|
-
121551,
|
|
158
|
-
1276282,
|
|
159
|
-
13400956
|
|
160
|
-
];
|
|
141
|
+
var StepSizes = [10, 105, 1103, 11576, 121551, 1276282, 13400956];
|
|
161
142
|
export {
|
|
162
143
|
AllowedBlockPayloadSchemas,
|
|
163
144
|
ChainIdentificationPayloadSchema,
|
|
@@ -1 +1 @@
|
|
|
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,SAASA,0BAA0B;AAEnC,SAASC,mBAAmBC,gBAAgB;AAE5C,SAASC,iBAAiBC,oBAAoB;;;ACJ9C,SAASC,uBAAuB;AAEhC,SAASC,6BAA6B;AAK/B,IAAMC,yBAAyB;AAc/B,IAAMC,qBAAqB,wBAACC,MAAAA;AACjC,SAAOC,sBAAwCH,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,SAASU,oBAAoB;AAOtB,IAAMC,UAAU,wBAACC,UAAAA;AACtB,SAAQA,MAAqBC,SAASC;AACxC,GAFuB;AAWhB,IAAMC,eAAe,wBAAwBH,UAAAA;AAClD,SAAOI,aAAaJ,KAAAA,KAAUK,MAAMC,QAASN,MAAsCO,MAAM;AAC3F,GAF4B;AAIrB,IAAMC,eAAe,wBAAwBR,UAAAA;AAClD,SAAOG,aAAaH,KAAAA,IAChBA,QACAE;AACN,GAJ4B;;;ACvB5B,SAASO,mBAAAA,wBAAuB;AAEhC,SAASC,yBAAAA,8BAA6B;AAE/B,IAAMC,aAAa;AASnB,IAAMC,gBAAgBF,uBAAmCC,UAAAA;AAEzD,IAAME,gBAAgBJ,iBAAgBK,OAAOF,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,UAAU,WAAYA,MAAMC,UAAUD;AAC9D,SAAOE,WAAWC,MAAMF,SAAS;IAAEG,QAAQ;IAAMC,WAAW;EAAI,CAAA,CAAA;AAClE,GAH4B;;;ACrB5B,SAASC,yBAAAA,8BAA6B;AAE/B,IAAMC,sBAAsB;AAmB5B,IAAMC,kBAAkBF,uBAAqCC,mBAAAA;;;ACpBpE,SAASE,yBAAAA,8BAA6B;AAE/B,IAAMC,mCAAmC;AAYzC,IAAMC,+BAA+BF,uBAAkDC,gCAAAA;;;ACf9F,SAASE,yBAAAA,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;;;AC7CtE,IAAMM,YAAY;EAAC;EAAI;EAAK;EAAM;EAAQ;EAAS;EAAW;;","names":["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","isSignedTransactionBoundWitness","isSigned","$signatures","length","addresses","isTransactionBoundWitnessWithStorageMeta","isStorageMeta","isSignedTransactionBoundWitnessWithStorageMeta","asTransactionBoundWitness","AsObjectFactory","create","asOptionalTransactionBoundWitness","createOptional","asTransactionBoundWitnessWithStorageMeta","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","toHex","getAddress","parseUnits","getDefaultGasConfig","gasLimit","gasPrice","parseUnits","ETH_ZERO_ADDRESS","toEthAddress","value","address","getAddress","toHex","prefix","bitLength","isPayloadOfSchemaType","NetworkStatusSchema","isNetworkStatus","isPayloadOfSchemaType","ChainIdentificationPayloadSchema","isChainIdentificationPayload","isPayloadOfSchemaType","ChainInformationPayloadSchema","isChainInformationPayload","AsObjectFactory","isPayloadOfSchemaType","isStorageMeta","ChainIndexingServiceStateSchema","isChainIndexingServiceState","payload","isPayloadOfSchemaType","asChainIndexingServiceState","AsObjectFactory","create","isChainIndexingServiceStateWithStorageMeta","value","isStorageMeta","asChainIndexingServiceStateWithStorageMeta","asOptionalChainIndexingServiceStateWithStorageMeta","createOptional","StepSizes"]}
|
|
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,OAAO,IAAK,MAAM;AACrD;;;AC7BA,SAAS,oBAAoB;AAOtB,IAAM,UAAU,CAAC,UAAwC;AAC9D,SAAQ,MAAqB,SAAS;AACxC;AASO,IAAM,eAAe,CAAwB,UAAiD;AACnG,SAAO,aAAa,KAAK,KAAK,MAAM,QAAS,MAAsC,MAAM;AAC3F;AAEO,IAAM,eAAe,CAAwB,UAAoD;AACtG,SAAO,aAAa,KAAK,IACrB,QACA;AACN;;;AC3BA,SAAS,mBAAAA,wBAAuB;AAEhC,SAAS,yBAAAC,8BAA6B;AAE/B,IAAM,aAAa;AASnB,IAAM,gBAAgBA,uBAAmC,UAAU;AAEnE,IAAM,gBAAgBD,iBAAgB,OAAO,aAAa;AAC1D,IAAM,+BAA+BA,iBAAgB,OAAO,aAAa;AACzE,IAAM,wBAAwBA,iBAAgB,eAAe,aAAa;;;ACdjF,SAAS,mBAAAE,wBAAuB;AAEhC,SAAS,yBAAAC,8BAA6B;AAI/B,IAAM,iBAAiB;AAYvB,IAAM,aAAaA,uBAAgC,cAAc;AAEjE,I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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/node/index.mjs
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
1
|
// src/block/AllowedBlockPayload.ts
|
|
5
2
|
import { BoundWitnessSchema } from "@xyo-network/boundwitness-model";
|
|
6
3
|
import { isHashStorageMeta, isSchema } from "@xyo-network/payload-model";
|
|
@@ -10,26 +7,26 @@ import { isSchemaPayload, SchemaSchema } from "@xyo-network/schema-payload-plugi
|
|
|
10
7
|
import { AsObjectFactory } from "@xylabs/object";
|
|
11
8
|
import { isPayloadOfSchemaType } from "@xyo-network/payload-model";
|
|
12
9
|
var ChainStakeIntentSchema = "network.xyo.chain.stake.intent";
|
|
13
|
-
var isChainStakeIntent =
|
|
10
|
+
var isChainStakeIntent = (x) => {
|
|
14
11
|
return isPayloadOfSchemaType(ChainStakeIntentSchema)(x) && asNonNegativeInteger(x.nbf) !== void 0 && asNonNegativeInteger(x.exp) !== void 0;
|
|
15
|
-
}
|
|
12
|
+
};
|
|
16
13
|
var asChainStakeIntent = AsObjectFactory.create(isChainStakeIntent);
|
|
17
14
|
var asOptionalChainStakeIntent = AsObjectFactory.createOptional(isChainStakeIntent);
|
|
18
|
-
var asNonNegativeInteger =
|
|
15
|
+
var asNonNegativeInteger = (num) => {
|
|
19
16
|
return Number.isInteger(num) && num >= 0 ? num : void 0;
|
|
20
|
-
}
|
|
17
|
+
};
|
|
21
18
|
|
|
22
19
|
// src/payload/elevatable/Executable.ts
|
|
23
20
|
import { isAnyPayload } from "@xyo-network/payload-model";
|
|
24
|
-
var hasFrom =
|
|
21
|
+
var hasFrom = (value) => {
|
|
25
22
|
return value.from !== void 0;
|
|
26
|
-
}
|
|
27
|
-
var isExecutable =
|
|
23
|
+
};
|
|
24
|
+
var isExecutable = (value) => {
|
|
28
25
|
return isAnyPayload(value) && Array.isArray(value.script);
|
|
29
|
-
}
|
|
30
|
-
var asExecutable =
|
|
26
|
+
};
|
|
27
|
+
var asExecutable = (value) => {
|
|
31
28
|
return isExecutable(value) ? value : void 0;
|
|
32
|
-
}
|
|
29
|
+
};
|
|
33
30
|
|
|
34
31
|
// src/payload/elevatable/Hash.ts
|
|
35
32
|
import { AsObjectFactory as AsObjectFactory2 } from "@xylabs/object";
|
|
@@ -52,51 +49,45 @@ var asOptionalTransfer = AsObjectFactory3.createOptional(isTransfer);
|
|
|
52
49
|
import { AsObjectFactory as AsObjectFactory4 } from "@xylabs/object";
|
|
53
50
|
import { isBoundWitness } from "@xyo-network/boundwitness-model";
|
|
54
51
|
import { isStorageMeta } from "@xyo-network/payload-model";
|
|
55
|
-
var isTransactionBoundWitness =
|
|
52
|
+
var isTransactionBoundWitness = (value) => {
|
|
56
53
|
const typedObj = value;
|
|
57
54
|
return isBoundWitness(value) && typedObj.chain !== void 0 && typedObj.fees !== void 0 && typedObj.exp !== void 0 && typedObj.nbf !== void 0;
|
|
58
|
-
}
|
|
59
|
-
var isSignedTransactionBoundWitness =
|
|
55
|
+
};
|
|
56
|
+
var isSignedTransactionBoundWitness = (value) => {
|
|
60
57
|
return isTransactionBoundWitness(value) && isSigned(value);
|
|
61
|
-
}
|
|
62
|
-
var isSigned =
|
|
63
|
-
var isTransactionBoundWitnessWithStorageMeta =
|
|
64
|
-
var isSignedTransactionBoundWitnessWithStorageMeta =
|
|
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);
|
|
65
62
|
var asTransactionBoundWitness = AsObjectFactory4.create(isTransactionBoundWitness);
|
|
66
63
|
var asOptionalTransactionBoundWitness = AsObjectFactory4.createOptional(isTransactionBoundWitness);
|
|
67
64
|
var asTransactionBoundWitnessWithStorageMeta = AsObjectFactory4.create(isTransactionBoundWitnessWithStorageMeta);
|
|
68
65
|
var asOptionalTransactionBoundWitnessWithStorageMeta = AsObjectFactory4.createOptional(isTransactionBoundWitnessWithStorageMeta);
|
|
69
66
|
|
|
70
67
|
// src/block/AllowedBlockPayload.ts
|
|
71
|
-
var AllowedBlockPayloadSchemas = [
|
|
72
|
-
|
|
73
|
-
ChainStakeIntentSchema,
|
|
74
|
-
SchemaSchema,
|
|
75
|
-
BoundWitnessSchema,
|
|
76
|
-
HashSchema
|
|
77
|
-
];
|
|
78
|
-
var isAllowedBlockPayloadSchema = /* @__PURE__ */ __name((value) => {
|
|
68
|
+
var AllowedBlockPayloadSchemas = [TransferSchema, ChainStakeIntentSchema, SchemaSchema, BoundWitnessSchema, HashSchema];
|
|
69
|
+
var isAllowedBlockPayloadSchema = (value) => {
|
|
79
70
|
return isSchema(value) && AllowedBlockPayloadSchemas.includes(value);
|
|
80
|
-
}
|
|
81
|
-
var isAllowedBlockPayload =
|
|
71
|
+
};
|
|
72
|
+
var isAllowedBlockPayload = (value) => {
|
|
82
73
|
return isTransfer(value) || isChainStakeIntent(value) || isSchemaPayload(value) || isTransactionBoundWitness(value) || isHashPayload(value);
|
|
83
|
-
}
|
|
84
|
-
var isAllowedBlockPayloadWithHashStorageMeta =
|
|
74
|
+
};
|
|
75
|
+
var isAllowedBlockPayloadWithHashStorageMeta = (value) => {
|
|
85
76
|
return isAllowedBlockPayload(value) && isHashStorageMeta(value);
|
|
86
|
-
}
|
|
77
|
+
};
|
|
87
78
|
|
|
88
79
|
// src/block/BlockBoundWitness.ts
|
|
89
80
|
import { isHex } from "@xylabs/hex";
|
|
90
81
|
import { AsObjectFactory as AsObjectFactory5 } from "@xylabs/object";
|
|
91
82
|
import { isBoundWitness as isBoundWitness2 } from "@xyo-network/boundwitness-model";
|
|
92
83
|
import { isStorageMeta as isStorageMeta2 } from "@xyo-network/payload-model";
|
|
93
|
-
var isBlockBoundWitness =
|
|
84
|
+
var isBlockBoundWitness = (value) => {
|
|
94
85
|
const typedObj = value;
|
|
95
86
|
return isBoundWitness2(value) && Number.isInteger(typedObj.block) && isHex(typedObj.chain);
|
|
96
|
-
}
|
|
97
|
-
var isBlockBoundWitnessWithStorageMeta =
|
|
87
|
+
};
|
|
88
|
+
var isBlockBoundWitnessWithStorageMeta = (value) => {
|
|
98
89
|
return isBlockBoundWitness(value) && isStorageMeta2(value);
|
|
99
|
-
}
|
|
90
|
+
};
|
|
100
91
|
var asBlockBoundWitness = AsObjectFactory5.create(isBlockBoundWitness);
|
|
101
92
|
var asOptionalBlockBoundWitness = AsObjectFactory5.createOptional(isBlockBoundWitness);
|
|
102
93
|
var asBlockBoundWitnessWithStorageMeta = AsObjectFactory5.create(isBlockBoundWitnessWithStorageMeta);
|
|
@@ -106,20 +97,18 @@ var asOptionalBlockBoundWitnessWithStorageMeta = AsObjectFactory5.createOptional
|
|
|
106
97
|
import { toHex } from "@xylabs/hex";
|
|
107
98
|
import { getAddress } from "ethers";
|
|
108
99
|
import { parseUnits } from "ethers/utils";
|
|
109
|
-
var getDefaultGasConfig =
|
|
100
|
+
var getDefaultGasConfig = () => {
|
|
110
101
|
return {
|
|
111
102
|
gasLimit: 2e6,
|
|
103
|
+
// Set the gas limit
|
|
112
104
|
gasPrice: parseUnits("100", "gwei")
|
|
113
105
|
};
|
|
114
|
-
}
|
|
106
|
+
};
|
|
115
107
|
var ETH_ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
116
|
-
var toEthAddress =
|
|
108
|
+
var toEthAddress = (value) => {
|
|
117
109
|
const address = typeof value === "object" ? value.address : value;
|
|
118
|
-
return getAddress(toHex(address, {
|
|
119
|
-
|
|
120
|
-
bitLength: 160
|
|
121
|
-
}));
|
|
122
|
-
}, "toEthAddress");
|
|
110
|
+
return getAddress(toHex(address, { prefix: true, bitLength: 160 }));
|
|
111
|
+
};
|
|
123
112
|
|
|
124
113
|
// src/network/Status.ts
|
|
125
114
|
import { isPayloadOfSchemaType as isPayloadOfSchemaType4 } from "@xyo-network/payload-model";
|
|
@@ -140,24 +129,16 @@ var isChainInformationPayload = isPayloadOfSchemaType6(ChainInformationPayloadSc
|
|
|
140
129
|
import { AsObjectFactory as AsObjectFactory6 } from "@xylabs/object";
|
|
141
130
|
import { isPayloadOfSchemaType as isPayloadOfSchemaType7, isStorageMeta as isStorageMeta3 } from "@xyo-network/payload-model";
|
|
142
131
|
var ChainIndexingServiceStateSchema = "network.xyo.chain.indexing.service.state";
|
|
143
|
-
var isChainIndexingServiceState =
|
|
132
|
+
var isChainIndexingServiceState = (payload) => {
|
|
144
133
|
return isPayloadOfSchemaType7(ChainIndexingServiceStateSchema)(payload);
|
|
145
|
-
}
|
|
134
|
+
};
|
|
146
135
|
var asChainIndexingServiceState = AsObjectFactory6.create(isChainIndexingServiceState);
|
|
147
|
-
var isChainIndexingServiceStateWithStorageMeta =
|
|
136
|
+
var isChainIndexingServiceStateWithStorageMeta = (value) => isChainIndexingServiceState(value) && isStorageMeta3(value);
|
|
148
137
|
var asChainIndexingServiceStateWithStorageMeta = AsObjectFactory6.create(isChainIndexingServiceStateWithStorageMeta);
|
|
149
138
|
var asOptionalChainIndexingServiceStateWithStorageMeta = AsObjectFactory6.createOptional(isChainIndexingServiceStateWithStorageMeta);
|
|
150
139
|
|
|
151
140
|
// src/Steps.ts
|
|
152
|
-
var StepSizes = [
|
|
153
|
-
10,
|
|
154
|
-
105,
|
|
155
|
-
1103,
|
|
156
|
-
11576,
|
|
157
|
-
121551,
|
|
158
|
-
1276282,
|
|
159
|
-
13400956
|
|
160
|
-
];
|
|
141
|
+
var StepSizes = [10, 105, 1103, 11576, 121551, 1276282, 13400956];
|
|
161
142
|
export {
|
|
162
143
|
AllowedBlockPayloadSchemas,
|
|
163
144
|
ChainIdentificationPayloadSchema,
|
package/dist/node/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,SAASA,0BAA0B;AAEnC,SAASC,mBAAmBC,gBAAgB;AAE5C,SAASC,iBAAiBC,oBAAoB;;;ACJ9C,SAASC,uBAAuB;AAEhC,SAASC,6BAA6B;AAK/B,IAAMC,yBAAyB;AAc/B,IAAMC,qBAAqB,wBAACC,MAAAA;AACjC,SAAOC,sBAAwCH,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,SAASU,oBAAoB;AAOtB,IAAMC,UAAU,wBAACC,UAAAA;AACtB,SAAQA,MAAqBC,SAASC;AACxC,GAFuB;AAWhB,IAAMC,eAAe,wBAAwBH,UAAAA;AAClD,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AQ;EAAS;EAAW;;","names":["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","isSignedTransactionBoundWitness","isSigned","$signatures","length","addresses","isTransactionBoundWitnessWithStorageMeta","isStorageMeta","isSignedTransactionBoundWitnessWithStorageMeta","asTransactionBoundWitness","AsObjectFactory","create","asOptionalTransactionBoundWitness","createOptional","asTransactionBoundWitnessWithStorageMeta","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","toHex","getAddress","parseUnits","getDefaultGasConfig","gasLimit","gasPrice","parseUnits","ETH_ZERO_ADDRESS","toEthAddress","value","address","getAddress","toHex","prefix","bitLength","isPayloadOfSchemaType","NetworkStatusSchema","isNetworkStatus","isPayloadOfSchemaType","ChainIdentificationPayloadSchema","isChainIdentificationPayload","isPayloadOfSchemaType","ChainInformationPayloadSchema","isChainInformationPayload","AsObjectFactory","isPayloadOfSchemaType","isStorageMeta","ChainIndexingServiceStateSchema","isChainIndexingServiceState","payload","isPayloadOfSchemaType","asChainIndexingServiceState","AsObjectFactory","create","isChainIndexingServiceStateWithStorageMeta","value","isStorageMeta","asChainIndexingServiceStateWithStorageMeta","asOptionalChainIndexingServiceStateWithStorageMeta","createOptional","StepSizes"]}
|
|
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,OAAO,IAAK,MAAM;AACrD;;;AC7BA,SAAS,oBAAoB;AAOtB,IAAM,UAAU,CAAC,UAAwC;AAC9D,SAAQ,MAAqB,SAAS;AACxC;AASO,IAAM,eAAe,CAAwB,UAAiD;AACnG,SAAO,aAAa,KAAK,KAAK,MAAM,QAAS,MAAsC,MAAM;AAC3F;AAEO,IAAM,eAAe,CAAwB,UAAoD;AACtG,SAAO,aAAa,KAAK,IACrB,QACA;AACN;;;AC3BA,SAAS,mBAAAA,wBAAuB;AAEhC,SAAS,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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/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": {
|
|
@@ -57,7 +57,6 @@
|
|
|
57
57
|
"knip": "^5.56.0",
|
|
58
58
|
"typescript": "^5.8.3",
|
|
59
59
|
"vite": "^6.3.5",
|
|
60
|
-
"vite-plugin-top-level-await": "^1.5.0",
|
|
61
60
|
"vite-tsconfig-paths": "^5.1.4",
|
|
62
61
|
"vitest": "^3.1.4"
|
|
63
62
|
},
|
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
|
-
})
|