@xyo-network/xl1-protocol 1.3.39 → 1.3.40
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/index.d.ts +40 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/neutral/index.mjs +75 -8
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/node/index.mjs +75 -8
- package/dist/node/index.mjs.map +1 -1
- package/dist/types/constants/TransactionGasCosts.d.ts +1 -1
- package/dist/types/constants/TransactionGasCosts.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/transaction/TransactionFeesFields.d.ts +1 -1
- package/dist/types/transaction/TransactionFeesFields.d.ts.map +1 -1
- package/dist/types/xl1/XL1.d.ts +45 -0
- package/dist/types/xl1/XL1.d.ts.map +1 -0
- package/dist/types/xl1/index.d.ts +2 -0
- package/dist/types/xl1/index.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/constants/TransactionGasCosts.ts +1 -1
- package/src/index.ts +1 -1
- package/src/transaction/TransactionFeesFields.ts +1 -1
- package/src/xl1/XL1.ts +88 -0
- package/src/xl1/index.ts +1 -0
- package/dist/types/XL1.d.ts +0 -11
- package/dist/types/XL1.d.ts.map +0 -1
- package/src/XL1.ts +0 -13
package/dist/index.d.ts
CHANGED
|
@@ -24,13 +24,47 @@ interface OpenTelemetryProviders {
|
|
|
24
24
|
type XL1 = bigint & {
|
|
25
25
|
readonly _tag: 'XL1';
|
|
26
26
|
};
|
|
27
|
-
declare const XL1:
|
|
27
|
+
declare const XL1: TypingFunc<XL1>;
|
|
28
|
+
type MilliXL1 = bigint & {
|
|
29
|
+
readonly _tag: 'MilliXL1';
|
|
30
|
+
};
|
|
31
|
+
declare const MilliXL1: TypingFunc<MilliXL1>;
|
|
28
32
|
type MicroXL1 = bigint & {
|
|
29
33
|
readonly _tag: 'MicroXL1';
|
|
30
34
|
};
|
|
31
|
-
declare const MicroXL1:
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
declare const MicroXL1: TypingFunc<MicroXL1>;
|
|
36
|
+
type NanoXL1 = bigint & {
|
|
37
|
+
readonly _tag: 'NanoXL1';
|
|
38
|
+
};
|
|
39
|
+
declare const NanoXL1: TypingFunc<NanoXL1>;
|
|
40
|
+
type PicoXL1 = bigint & {
|
|
41
|
+
readonly _tag: 'PicoXL1';
|
|
42
|
+
};
|
|
43
|
+
declare const PicoXL1: TypingFunc<PicoXL1>;
|
|
44
|
+
type FemtoXL1 = bigint & {
|
|
45
|
+
readonly _tag: 'FemtoXL1';
|
|
46
|
+
};
|
|
47
|
+
declare const FemtoXL1: TypingFunc<FemtoXL1>;
|
|
48
|
+
type AttoXL1 = bigint & {
|
|
49
|
+
readonly _tag: 'AttoXL1';
|
|
50
|
+
};
|
|
51
|
+
declare const AttoXL1: TypingFunc<AttoXL1>;
|
|
52
|
+
declare const XL1ConvertDict: Record<string, number>;
|
|
53
|
+
type TypingFunc<T extends bigint> = (value: bigint) => T;
|
|
54
|
+
declare function toXL1<T extends bigint>(value: T, factor: number): XL1;
|
|
55
|
+
declare function fromXL1<T extends bigint>(value: XL1, factor: number, typingFunc: TypingFunc<T>): T;
|
|
56
|
+
declare const milliXL1ToXL1: (value: MilliXL1) => XL1;
|
|
57
|
+
declare const milliXL1FromXL1: (value: XL1) => MilliXL1;
|
|
58
|
+
declare const microXL1ToXL1: (value: MicroXL1) => XL1;
|
|
59
|
+
declare const microXL1FromXL1: (value: XL1) => MicroXL1;
|
|
60
|
+
declare const nanoXL1ToXL1: (value: NanoXL1) => XL1;
|
|
61
|
+
declare const nanoXL1FromXL1: (value: XL1) => NanoXL1;
|
|
62
|
+
declare const picoXL1ToXL1: (value: PicoXL1) => XL1;
|
|
63
|
+
declare const picoXL1FromXL1: (value: XL1) => PicoXL1;
|
|
64
|
+
declare const femtoXL1ToXL1: (value: FemtoXL1) => XL1;
|
|
65
|
+
declare const femtoXL1FromXL1: (value: XL1) => FemtoXL1;
|
|
66
|
+
declare const attoXL1ToXL1: (value: AttoXL1) => XL1;
|
|
67
|
+
declare const attoXL1FromXL1: (value: XL1) => AttoXL1;
|
|
34
68
|
|
|
35
69
|
interface Addressable {
|
|
36
70
|
address: Address;
|
|
@@ -498,6 +532,6 @@ type HydratedTransactionStateValidationFunction<T extends TransactionBoundWitnes
|
|
|
498
532
|
|
|
499
533
|
type HydratedTransactionValidatorFunction<T extends TransactionBoundWitness = TransactionBoundWitness> = (hydratedTransaction: HydratedTransactionWithHashStorageMeta<HydratedTransaction<T>>, chainId?: Address) => Promisable<Error[]>;
|
|
500
534
|
|
|
501
|
-
export { AllowedBlockPayloadSchemas, BlockNumberSchema, ChainIdentificationPayloadSchema, ChainIndexingServiceStateSchema, ChainInformationPayloadSchema, ChainStakeIntentSchema, HashSchema, MicroXL1, NetworkStatusSchema, StepSizes, TransactionGasCosts, TransferSchema, XL1, asBlockBoundWitness, asBlockBoundWitnessWithStorageMeta, asBlockNumber, asBlockNumberWithSources, asChainIndexingServiceState, asChainIndexingServiceStateWithStorageMeta, asChainStakeIntent, asExecutable, asHashPayload, asHashPayloadWithStorageMeta, asOptionalBlockBoundWitness, asOptionalBlockBoundWitnessWithStorageMeta, asOptionalBlockNumber, asOptionalBlockNumberWithSources, asOptionalChainIndexingServiceStateWithStorageMeta, asOptionalChainStakeIntent, asOptionalHashPayload, asOptionalTransactionBoundWitness, asOptionalTransactionBoundWitnessWithStorageMeta, asOptionalTransfer, asTransactionBoundWitness, asTransactionBoundWitnessWithStorageMeta, asTransfer, defaultTransactionFees, hasFrom, isAllowedBlockPayload, isAllowedBlockPayloadSchema, isAllowedBlockPayloadWithHashStorageMeta, isBlockBoundWitness, isBlockBoundWitnessWithStorageMeta, isBlockNumber, isBlockNumberWithSources, isChainIdentificationPayload, isChainIndexingServiceState, isChainIndexingServiceStateWithStorageMeta, isChainInformationPayload, isChainStakeIntent, isExecutable, isHashPayload, isNetworkStatus, isSigned, isSignedTransactionBoundWitness, isSignedTransactionBoundWitnessWithStorageMeta, isTransactionBoundWitness, isTransactionBoundWitnessWithStorageMeta, isTransfer,
|
|
502
|
-
export type { AccountBalanceService, Addressable, AllowedBlockPayload, AllowedBlockPayloadSchema, BaseAccountableServiceParams, BaseServiceParams, BlockBoundWitness, BlockBoundWitnessFields, BlockBoundWitnessMeta, BlockDuration, BlockEnd, BlockNumber, BlockNumberFields, BlockProducer, BlockRewardService, BlockStart, BlockValidatorFunction, BoundWitnessValidationFunction, ChainAnalyzer, ChainBlockNumberIterator, ChainContractViewer, ChainHashIterator, ChainIdentification, ChainIdentificationPayload, ChainIndexingServiceState, ChainIndexingServiceStateFields, ChainInformation, ChainInformationPayload, ChainIterator, ChainIteratorEventData, ChainReference, ChainService, ChainServiceCollection, ChainStakeIntent, ChainStakeIntentFields, ChainStakeViewer, ChainStaker, DefaultNetworkIds, ElectionService, EventingChainBlockNumberIterator, EventingChainHashIterator, EventingChainIterator, Executable, ExecutableFields, FromFields, HashFields, HashPayload, HeadEventArgs, HeadEventData, HydratedBlock, HydratedBlockStateValidationFunction, HydratedBlockValidatorFunction, HydratedBoundWitnessValidationFunction, HydratedBoundWitnessWithHashStorageMeta, HydratedTransaction, HydratedTransactionStateValidationFunction, HydratedTransactionValidatorFunction, HydratedTransactionWithHashStorageMeta, HydratedTransactionWithStorageMeta, InBlockPayloadValidationFunction, Initializable, Intent, IterableRepository, IterableTransactionRepository, NetworkId, NetworkStatus, NetworkStatusFields, NetworkStatusState, NetworkStatusUpdate, NextBlockProducer, OpenTelemetryProviders, OptionalBlockDuration, OptionalExecutable, PendingTransactionsService, ReadRepository, ReadonlyIterableTransactionRepository, Service, ServiceName, SignedHydratedBlock, SignedHydratedTransaction, SignedHydratedTransactionWithStorageMeta, StakeIntentService, TransactionBoundWitness, TransactionBoundWitnessFields, TransactionFeesBigInt, TransactionFeesFields, TransactionFeesHex, TransactionReadRepository, TransactionRepository, TransactionRepositoryIterator, TransactionWriteRepository, Transfer, TransferFields, WriteRepository, XyoChainIteratorParams, XyoDataLakeProvider, XyoDataLakeViewer, XyoNetwork, XyoPayloadLakeProvider, XyoPayloadLakeViewer, XyoProvider, XyoRunner, XyoSigner, XyoViewer, XyoWallet };
|
|
535
|
+
export { AllowedBlockPayloadSchemas, AttoXL1, BlockNumberSchema, ChainIdentificationPayloadSchema, ChainIndexingServiceStateSchema, ChainInformationPayloadSchema, ChainStakeIntentSchema, FemtoXL1, HashSchema, MicroXL1, MilliXL1, NanoXL1, NetworkStatusSchema, PicoXL1, StepSizes, TransactionGasCosts, TransferSchema, XL1, XL1ConvertDict, asBlockBoundWitness, asBlockBoundWitnessWithStorageMeta, asBlockNumber, asBlockNumberWithSources, asChainIndexingServiceState, asChainIndexingServiceStateWithStorageMeta, asChainStakeIntent, asExecutable, asHashPayload, asHashPayloadWithStorageMeta, asOptionalBlockBoundWitness, asOptionalBlockBoundWitnessWithStorageMeta, asOptionalBlockNumber, asOptionalBlockNumberWithSources, asOptionalChainIndexingServiceStateWithStorageMeta, asOptionalChainStakeIntent, asOptionalHashPayload, asOptionalTransactionBoundWitness, asOptionalTransactionBoundWitnessWithStorageMeta, asOptionalTransfer, asTransactionBoundWitness, asTransactionBoundWitnessWithStorageMeta, asTransfer, attoXL1FromXL1, attoXL1ToXL1, defaultTransactionFees, femtoXL1FromXL1, femtoXL1ToXL1, fromXL1, hasFrom, isAllowedBlockPayload, isAllowedBlockPayloadSchema, isAllowedBlockPayloadWithHashStorageMeta, isBlockBoundWitness, isBlockBoundWitnessWithStorageMeta, isBlockNumber, isBlockNumberWithSources, isChainIdentificationPayload, isChainIndexingServiceState, isChainIndexingServiceStateWithStorageMeta, isChainInformationPayload, isChainStakeIntent, isExecutable, isHashPayload, isNetworkStatus, isSigned, isSignedTransactionBoundWitness, isSignedTransactionBoundWitnessWithStorageMeta, isTransactionBoundWitness, isTransactionBoundWitnessWithStorageMeta, isTransfer, microXL1FromXL1, microXL1ToXL1, milliXL1FromXL1, milliXL1ToXL1, minTransactionFees, nanoXL1FromXL1, nanoXL1ToXL1, picoXL1FromXL1, picoXL1ToXL1, toXL1 };
|
|
536
|
+
export type { AccountBalanceService, Addressable, AllowedBlockPayload, AllowedBlockPayloadSchema, BaseAccountableServiceParams, BaseServiceParams, BlockBoundWitness, BlockBoundWitnessFields, BlockBoundWitnessMeta, BlockDuration, BlockEnd, BlockNumber, BlockNumberFields, BlockProducer, BlockRewardService, BlockStart, BlockValidatorFunction, BoundWitnessValidationFunction, ChainAnalyzer, ChainBlockNumberIterator, ChainContractViewer, ChainHashIterator, ChainIdentification, ChainIdentificationPayload, ChainIndexingServiceState, ChainIndexingServiceStateFields, ChainInformation, ChainInformationPayload, ChainIterator, ChainIteratorEventData, ChainReference, ChainService, ChainServiceCollection, ChainStakeIntent, ChainStakeIntentFields, ChainStakeViewer, ChainStaker, DefaultNetworkIds, ElectionService, EventingChainBlockNumberIterator, EventingChainHashIterator, EventingChainIterator, Executable, ExecutableFields, FromFields, HashFields, HashPayload, HeadEventArgs, HeadEventData, HydratedBlock, HydratedBlockStateValidationFunction, HydratedBlockValidatorFunction, HydratedBoundWitnessValidationFunction, HydratedBoundWitnessWithHashStorageMeta, HydratedTransaction, HydratedTransactionStateValidationFunction, HydratedTransactionValidatorFunction, HydratedTransactionWithHashStorageMeta, HydratedTransactionWithStorageMeta, InBlockPayloadValidationFunction, Initializable, Intent, IterableRepository, IterableTransactionRepository, NetworkId, NetworkStatus, NetworkStatusFields, NetworkStatusState, NetworkStatusUpdate, NextBlockProducer, OpenTelemetryProviders, OptionalBlockDuration, OptionalExecutable, PendingTransactionsService, ReadRepository, ReadonlyIterableTransactionRepository, Service, ServiceName, SignedHydratedBlock, SignedHydratedTransaction, SignedHydratedTransactionWithStorageMeta, StakeIntentService, TransactionBoundWitness, TransactionBoundWitnessFields, TransactionFeesBigInt, TransactionFeesFields, TransactionFeesHex, TransactionReadRepository, TransactionRepository, TransactionRepositoryIterator, TransactionWriteRepository, Transfer, TransferFields, TypingFunc, WriteRepository, XyoChainIteratorParams, XyoDataLakeProvider, XyoDataLakeViewer, XyoNetwork, XyoPayloadLakeProvider, XyoPayloadLakeViewer, XyoProvider, XyoRunner, XyoSigner, XyoViewer, XyoWallet };
|
|
503
537
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sources":["../src/Initializable.ts","../src/OpenTelemetryProviders.ts","../src/XL1.ts","../src/fields/Addressable.ts","../src/fields/BlockDuration.ts","../src/fields/BlockNumber.ts","../src/fields/ChainReference.ts","../src/payload/elevatable/Executable.ts","../src/payload/elevatable/ChainStakeIntent.ts","../src/payload/elevatable/Hash.ts","../src/payload/elevatable/TransferPayload.ts","../src/transaction/TransactionFeesFields.ts","../src/transaction/TransactionBoundWitness.ts","../src/transaction/HydratedTransaction.ts","../src/block/AllowedBlockPayload.ts","../src/block/BlockBoundWitness.ts","../src/block/HydratedBlock.ts","../src/chain/ChainAnalyzer.ts","../src/constants/StepSizes.ts","../src/constants/TransactionGasCosts.ts","../src/repository/Repository.ts","../src/repository/TransactionReadRepository.ts","../src/repository/TransactionRepositoryIterator.ts","../src/repository/TransactionWriteRepository.ts","../src/repository/TransactionRepository.ts","../src/services/AccountBalanceService.ts","../src/services/BlockProducer.ts","../src/services/Service.ts","../src/services/BlockReward.ts","../src/services/Chain/ChainContractViewer.ts","../src/services/Chain/ChainIdentification.ts","../src/services/Chain/ChainInformation.ts","../src/services/Chain/ChainStaker.ts","../src/services/Chain/ChainStakeViewer.ts","../src/services/Chain/ChainService.ts","../src/services/Election.ts","../src/services/stakeIntent/ChainIndexingServiceStateSchema.ts","../src/services/stakeIntent/StakeIntentService.ts","../src/services/ChainServiceCollection.ts","../src/services/Params.ts","../src/services/PendingTransactionsService.ts","../src/iterator/ChainIteratorEventData.ts","../src/iterator/ChainIterator.ts","../src/network/NetworkId.ts","../src/network/Status.ts","../src/provider/v1/XyoDataLake.ts","../src/provider/v1/XyoNetwork.ts","../src/provider/v1/XyoRunner.ts","../src/provider/v1/XyoSigner.ts","../src/provider/v1/XyoViewer.ts","../src/provider/v1/XyoWallet.ts","../src/provider/v1/XyoProvider.ts","../src/validation/block/BlockValidationFunction.ts","../src/validation/block/HydratedBlockStateValidationFunction.ts","../src/validation/block/HydratedBlockValidationFunction.ts","../src/validation/boundwitness/BoundWitnessValidationFunction.ts","../src/validation/boundwitness/HydratedBoundWitnessValidationFunction.ts","../src/validation/payload/InBlockPayloadValidationFunction.ts","../src/validation/transaction/HydratedTransactionStateValidationFunction.ts","../src/validation/transaction/HydratedTransactionValidationFunction.ts"],"sourcesContent":["import type { Promisable } from '@xylabs/promise'\n\nexport type Initializable<T, R> = (params: T) => Promisable<R>\n","import type { MeterProvider, TracerProvider } from '@opentelemetry/api'\n\nexport interface OpenTelemetryProviders {\n meterProvider?: MeterProvider\n traceProvider?: TracerProvider\n}\n","export type XL1 = bigint & { readonly _tag: 'XL1' } // 1e-18\nexport type MicroXL1 = bigint & { readonly _tag: 'MicroXL1' } // 1e-24\n\nexport const XL1 = (value: bigint): XL1 => value as XL1\nexport const MicroXL1 = (value: bigint): MicroXL1 => value as MicroXL1\n\nexport const mXL1ToXL1 = (value: MicroXL1): XL1 => {\n return XL1(BigInt(value) / BigInt(1_000_000))\n}\n\nexport const mXL1FromXL1 = (value: XL1): MicroXL1 => {\n return MicroXL1(BigInt(value) * BigInt(1_000_000))\n}\n","import type { Address } from '@xylabs/hex'\n\n// NOTE: Minimal interface in case of reuse across validators, producers, wallets, modules, etc.\nexport interface Addressable {\n address: Address\n}\n","export interface BlockStart {\n /**\n * The block at which the duration starts\n */\n nbf: number\n}\n\nexport interface BlockEnd {\n /**\n * The block at which the duration ends\n */\n exp: number\n}\n\n/**\n * A optional duration referenced to block numbers\n */\nexport interface OptionalBlockDuration extends Partial<BlockStart>, Partial<BlockEnd> {}\n\n/**\n * A duration referenced to block numbers\n */\nexport interface BlockDuration extends BlockStart, BlockEnd {}\n","import type { Hex } from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { Payload, WithSources } from '@xyo-network/payload-model'\nimport {\n isPayloadOfSchemaType,\n isPayloadOfSchemaTypeWithSources,\n} from '@xyo-network/payload-model'\n\nexport const BlockNumberSchema = 'network.xyo.chain.block.number' as const\nexport type BlockNumberSchema = typeof BlockNumberSchema\n\nexport interface BlockNumberFields {\n /**\n * The block number\n */\n block: Hex\n /**\n * The chain id\n */\n chain?: Hex\n}\n/**\n * The number of a block\n */\nexport type BlockNumber = Payload<BlockNumberFields, BlockNumberSchema>\n\n/**\n * Identity function for determining if an object is a BlockNumber\n */\nexport const isBlockNumber = isPayloadOfSchemaType<BlockNumber>(BlockNumberSchema)\nexport const asBlockNumber = AsObjectFactory.create<BlockNumber>(isBlockNumber)\nexport const asOptionalBlockNumber = AsObjectFactory.createOptional<BlockNumber>(isBlockNumber)\n\n/**\n * Identity function for determining if an object is a BlockNumber with sources\n */\nexport const isBlockNumberWithSources = isPayloadOfSchemaTypeWithSources<BlockNumber>(BlockNumberSchema)\nexport const asBlockNumberWithSources = AsObjectFactory.create<WithSources<BlockNumber>>(isBlockNumberWithSources)\nexport const asOptionalBlockNumberWithSources = AsObjectFactory.createOptional<WithSources<BlockNumber>>(isBlockNumberWithSources)\n","import type { Address } from '@xylabs/hex'\n\n/**\n * Required info for a chain reference\n */\nexport interface ChainReference {\n /**\n * The contract address referenced by the chain\n */\n chain: Address\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 { AsObjectFactory } from '@xylabs/object'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nimport type { BlockDuration } from '#fields'\n\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 { 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 { Hex } from '@xylabs/hex'\n\nimport { MicroXL1 } from '../XL1.ts'\n\nexport interface TransactionFeesBigInt {\n base: MicroXL1\n gasLimit: MicroXL1\n gasPrice: MicroXL1\n priority: MicroXL1\n}\n\nexport type TransactionFeesHex = {\n [K in keyof TransactionFeesBigInt]: Hex;\n}\n\nexport interface TransactionFeesFields {\n fees: TransactionFeesHex\n}\n\nexport const minTransactionFees: TransactionFeesBigInt = {\n base: MicroXL1(1000n), gasPrice: MicroXL1(1n), gasLimit: MicroXL1(1000n), priority: MicroXL1(0n),\n} as const\n\nexport const defaultTransactionFees: TransactionFeesBigInt = {\n base: minTransactionFees.base, gasPrice: MicroXL1(10n), gasLimit: MicroXL1(1_000_000n), priority: MicroXL1(0n),\n} as const\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 { BlockDuration } from '#fields'\nimport type { FromFields, OptionalExecutable } from '#payload'\n\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 { Signed } from '@xyo-network/boundwitness-model'\nimport type {\n Payload, WithHashStorageMeta, WithStorageMeta,\n} from '@xyo-network/payload-model'\n\nimport type { TransactionBoundWitness } from './TransactionBoundWitness.ts'\n\nexport type HydratedTransaction<T extends TransactionBoundWitness = TransactionBoundWitness, P extends Payload = Payload> = [T, P[]]\n\nexport type HydratedTransactionWithStorageMeta<T extends HydratedTransaction = HydratedTransaction>\n = [WithStorageMeta<T[0]>, WithStorageMeta<T[1][number]>[]]\n\nexport type HydratedTransactionWithHashStorageMeta<T extends HydratedTransaction = HydratedTransaction>\n = [WithHashStorageMeta<T[0]>, WithHashStorageMeta<T[1][number]>[]]\n\nexport type SignedHydratedTransaction<T extends HydratedTransaction = HydratedTransaction> = [Signed<T[0]>, T[1][number][]] & HydratedTransaction\n\nexport type SignedHydratedTransactionWithStorageMeta<T extends HydratedTransaction = HydratedTransaction>\n = [WithStorageMeta<Signed<T[0]>>, WithStorageMeta<T[1][number]>[]] & SignedHydratedTransaction<T> & HydratedTransaction\n","import { BoundWitnessSchema } from '@xyo-network/boundwitness-model'\nimport type { Schema, WithStorageMeta } from '@xyo-network/payload-model'\nimport { isHashStorageMeta, isSchema } from '@xyo-network/payload-model'\nimport type { SchemaPayload } from '@xyo-network/schema-payload-plugin'\nimport { isSchemaPayload, SchemaSchema } from '@xyo-network/schema-payload-plugin'\n\nimport type {\n ChainStakeIntent, HashPayload, Transfer,\n} from '#payload'\nimport {\n ChainStakeIntentSchema, HashSchema, isChainStakeIntent, isHashPayload, isTransfer, TransferSchema,\n} from '#payload'\nimport { isTransactionBoundWitness, type TransactionBoundWitness } from '#transaction'\n\nexport type AllowedBlockPayload = Transfer | ChainStakeIntent | SchemaPayload | TransactionBoundWitness | HashPayload\nexport const AllowedBlockPayloadSchemas: Schema[] = [TransferSchema, ChainStakeIntentSchema, SchemaSchema, BoundWitnessSchema, HashSchema]\nexport type AllowedBlockPayloadSchema = typeof AllowedBlockPayloadSchemas[number]\n\nexport const isAllowedBlockPayloadSchema = (value: unknown): value is AllowedBlockPayloadSchema => {\n return isSchema(value) && AllowedBlockPayloadSchemas.includes(value)\n}\n\nexport const isAllowedBlockPayload = (value: unknown): value is AllowedBlockPayload => {\n return isTransfer(value) || isChainStakeIntent(value) || isSchemaPayload(value) || isTransactionBoundWitness(value) || isHashPayload(value)\n}\n\nexport const isAllowedBlockPayloadWithHashStorageMeta = (value: unknown): value is WithStorageMeta<AllowedBlockPayload> => {\n return isAllowedBlockPayload(value) && isHashStorageMeta(value)\n}\n","import 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 { Signed } from '@xyo-network/boundwitness-model'\nimport type { Payload, WithStorageMeta } from '@xyo-network/payload-model'\n\nimport type { BlockBoundWitness } from './BlockBoundWitness.ts'\n\nexport type HydratedBlock = [WithStorageMeta<BlockBoundWitness>, WithStorageMeta<Payload>[]]\n\nexport type SignedHydratedBlock = [WithStorageMeta<Signed<BlockBoundWitness>>, WithStorageMeta<Payload>[]] & HydratedBlock\n","import type { Promisable } from '@xylabs/promise'\nimport type { Payload } from '@xyo-network/payload-model'\n\nimport type { HydratedBlock } from '#block'\n\nexport interface ChainAnalyzer<T extends Payload = Payload> {\n onBlock(block: HydratedBlock): Promisable<boolean>\n result(): T\n shouldContinue(): boolean\n}\n","export const StepSizes = [10, 105, 1103, 11_576, 121_551, 1_276_282, 13_400_956] as const\n","import { MicroXL1 } from '../XL1.ts'\n\nexport const TransactionGasCosts = {\n /**\n * The cost of storing each character that is added to the chain\n * This includes the transaction JSON and all the elevated payloads' JSON\n */\n characterStorage: MicroXL1(10n),\n\n /** The cost of static validating every payload that will be included in the chain */\n payloadValidation: MicroXL1(1000n),\n\n /** The cost of validating each signature that will be included in the chain */\n signatureValidation: MicroXL1(1000n),\n\n /** The cost of validating each hash that will be included in the chain */\n hashValidation: MicroXL1(100n),\n\n /** The cost of validating a balance state, triggered by a Transfer payload or gas collection */\n balanceValidation: MicroXL1(100n),\n} as const\n\n/** Gas Calculation\n *\n * 1 Million microXL1 (mXL1) = 1 XL1\n *\n * Gas amount is calculated as follows:\n *\n * 1. Each byte in the transaction cost 10 gas\n * 2. Each payload validation in the transaction costs 1000 gas\n * 3. Each signature verification in the transaction costs 1000 gas\n * 4. Each hash validation in the transaction costs 100 gas\n * 5. Each balance validation in the transaction costs 100 gas\n * 6. Processing/Compute/Storage Cost?\n * 7. operation Costs?\n *\n * The total gas cost is calculated by multiplying the gas amount by the gas price.\n *\n * minGasPrice is initially set to 100 mXL1\n * minBase is initially set to 1000 mXL1\n * minPriority is always 0 mXL1, but can be set to increase the priority of the transaction\n *\n */\n","export interface ReadRepository<TId, TData> {\n get(id: TId): Promise<TData | undefined>\n}\n\nexport interface IterableRepository<TId, TData> {\n next(id: TId): Promise<TData | undefined>\n}\n\nexport interface WriteRepository<TData, TResp> {\n insert(data: TData): Promise<TResp>\n}\n","import type { HydratedTransaction, TransactionBoundWitness } from '#transaction'\n\nimport type { ReadRepository } from './Repository.ts'\n\nexport interface TransactionReadRepository extends ReadRepository<TransactionBoundWitness, HydratedTransaction> {}\n","import type { HydratedTransaction, TransactionBoundWitness } from '#transaction'\n\nimport type { IterableRepository } from './Repository.ts'\n\nexport interface TransactionRepositoryIterator extends IterableRepository<TransactionBoundWitness, HydratedTransaction> {}\n","import type { HydratedTransaction } from '#transaction'\n\nimport type { WriteRepository } from './Repository.ts'\n\nexport interface TransactionWriteRepository extends WriteRepository<HydratedTransaction, boolean> {}\n","import type { TransactionReadRepository } from './TransactionReadRepository.ts'\nimport type { TransactionRepositoryIterator } from './TransactionRepositoryIterator.ts'\nimport type { TransactionWriteRepository } from './TransactionWriteRepository.ts'\n\nexport interface TransactionRepository extends TransactionReadRepository, TransactionWriteRepository {}\n\nexport interface ReadonlyIterableTransactionRepository extends TransactionReadRepository, TransactionRepositoryIterator {}\n\nexport interface IterableTransactionRepository extends TransactionRepository, TransactionRepositoryIterator {}\n","import type {\n Address, Hash, Hex,\n} from '@xylabs/hex'\n\nexport interface AccountBalanceService {\n getBalanceValue?: (address: Address) => bigint\n getBalanceValues?: Record<Address, bigint>\n\n getBalance(address: Address): Hex\n getBalances(): Record<Address, Hex>\n sync(head: Hash): Promise<void>\n}\n","import type { BlockBoundWitness, HydratedBlock } from '#block'\nimport type { Addressable } from '#fields'\nimport type { IterableRepository } from '#repository'\n\nexport type NextBlockProducer = IterableRepository<BlockBoundWitness, HydratedBlock>\n\nexport interface BlockProducer extends Addressable, NextBlockProducer {}\n","import type { Meter, Tracer } from '@opentelemetry/api'\nimport type { Logger } from '@xylabs/logger'\n\nexport type ServiceName = Exclude<string, 'reserved-service-name-value'>\n\nexport interface Service {\n logger?: Logger\n meter?: Meter\n tracer?: Tracer\n}\n","import type { Promisable } from '@xylabs/promise'\n\nimport type { Service } from './Service.ts'\n\nexport interface BlockRewardService extends Service {\n getRewardForBlock(block: bigint): Promisable<bigint>\n}\n","import type { Address } from '@xylabs/hex'\n\nexport interface ChainContractViewer {\n active(): Promise<bigint>\n chainId(): Promise<Address>\n forkedAtBlockNumber(): Promise<bigint>\n forkedAtHash(): Promise<bigint>\n forkedChainId(): Promise<Address>\n minWithdrawalBlocks(): Promise<bigint>\n rewardsContract(): Promise<string>\n stakingTokenAddress(): Promise<string>\n}\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","export interface ChainStaker {\n addStake(staked: string, amount: bigint): Promise<boolean>\n removeStake(slot: bigint): Promise<boolean>\n withdrawStake(slot: bigint): Promise<boolean>\n}\n","import type { ChainContractViewer } from './ChainContractViewer.ts'\n\nexport interface ChainStakeViewer extends ChainContractViewer {\n activeByAddressStaked(address: string): Promise<bigint>\n activeByStaker(address: string): Promise<bigint>\n pending(): Promise<bigint>\n pendingByStaker(staker: string): Promise<bigint>\n withdrawn(): Promise<bigint>\n withdrawnByStaker(staker: string): Promise<bigint>\n}\n","import type { Service } from '../Service.ts'\nimport type { ChainContractViewer } from './ChainContractViewer.ts'\nimport type { ChainInformation } from './ChainInformation.ts'\nimport type { ChainStaker } from './ChainStaker.ts'\nimport type { ChainStakeViewer } from './ChainStakeViewer.ts'\n\nexport interface ChainService extends ChainInformation, ChainContractViewer, ChainStakeViewer, ChainStaker, Service {}\n","import type { Address } from '@xylabs/hex'\n\nimport type { BlockBoundWitness } from '#block'\n\nimport type { Service } from './Service.ts'\n\nexport interface ElectionService extends Service {\n\n /**\n * Given the current block, get the leader for the next block\n * @param current The previous block\n */\n getCreatorCommitteeForNextBlock(current: BlockBoundWitness): Promise<Address[]>\n\n}\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","import type { Address } from '@xylabs/hex'\n\nimport type { Intent } from '#payload'\n\nexport interface StakeIntentService {\n\n /**\n * Gets the declared ranges for an address based on historical on-chain data\n * @param address The address to get the declared ranges for\n * @param intent The declared intent to filter for\n */\n getDeclaredCandidateRanges(address: Address, intent: Intent): Promise<Readonly<Readonly<[number, number]>[]>>\n\n /**\n * Gets the declared candidates for a block based on historical on-chain data\n * @param block The block number to get the declared candidates for\n * @param intent The declared intent to filter for\n */\n getDeclaredCandidatesForBlock(block: number, intent: Intent): Promise<Address[]>\n\n /**\n * Checks if the address is staked for a block for a given intent\n * @param block The block number to check\n * @param intent The declared intent to filter for\n * @param address The address to check\n */\n isStakedForBlock(block: number, intent: Intent, address: Address): Promise<boolean>\n}\n","import type { ArchivistInstance, WriteArchivist } from '@xyo-network/archivist-model'\nimport type { WalletInstance } from '@xyo-network/wallet-model'\n\nimport type { EventingChainBlockNumberIterator } from '../iterator/index.ts'\nimport type { AccountBalanceService } from './AccountBalanceService.ts'\nimport type { BlockProducer } from './BlockProducer.ts'\nimport type { BlockRewardService } from './BlockReward.ts'\nimport type {\n ChainContractViewer, ChainInformation, ChainStaker, ChainStakeViewer,\n} from './Chain/index.ts'\nimport type { ElectionService } from './Election.ts'\nimport type { StakeIntentService } from './stakeIntent/index.ts'\n\nexport interface ChainServiceCollection {\n\n account: WalletInstance\n /**\n * Services for working with account balances\n */\n balanceService: AccountBalanceService\n /**\n * The archivist which the chain data is stored in\n */\n chainArchivist: ArchivistInstance\n chainContractViewer: ChainContractViewer\n /**\n * Hydrated information about the chain\n */\n chainInformation: ChainInformation\n /**\n * The chain iterator\n */\n chainIterator?: EventingChainBlockNumberIterator\n chainStakeViewer: ChainStakeViewer\n chainStaker: ChainStaker\n chainSubmissionsArchivistWrite: WriteArchivist\n electionService: ElectionService\n producer: BlockProducer\n rewardService: BlockRewardService\n /**\n * Services for working with staked intents\n */\n stakeIntentService: StakeIntentService\n}\n","import type { BaseParams } from '@xylabs/base'\nimport type { EmptyObject } from '@xylabs/object'\nimport type { AccountInstance } from '@xyo-network/account-model'\n\nimport type { OpenTelemetryProviders } from '../OpenTelemetryProviders.ts'\n\nexport type BaseServiceParams<TAdditionalParams extends EmptyObject = EmptyObject> = BaseParams<TAdditionalParams & OpenTelemetryProviders>\n\nexport type BaseAccountableServiceParams = BaseServiceParams<{\n account: AccountInstance\n}>\n","import type { Hash } from '@xylabs/hex'\n\nimport type { HydratedTransaction } from '#transaction'\n\nimport type { Service } from './Service.ts'\n\nexport interface PendingTransactionsService extends Service {\n getPendingTransactions(head: Hash, limit: number, timeout?: number): Promise<HydratedTransaction[]>\n}\n","import type { EventData } from '@xylabs/events'\n\nimport type { BlockBoundWitness } from '#block'\n\nexport type HeadEventArgs = { blocks: [BlockBoundWitness] }\n\nexport interface HeadEventData extends EventData {\n headUpdated: HeadEventArgs\n}\n\nexport interface ChainIteratorEventData extends HeadEventData { }\n","import type { BaseParams } from '@xylabs/base'\nimport type { BaseEmitter } from '@xylabs/events'\nimport type { Hash } from '@xylabs/hex'\nimport type { ArchivistInstance } from '@xyo-network/archivist-model'\n\nimport type { BlockBoundWitness } from '#block'\nimport type { IterableRepository, ReadRepository } from '#repository'\nimport type { BaseServiceParams, ChainIdentification } from '#services'\n\nimport type { ChainIteratorEventData } from './ChainIteratorEventData.ts'\n\nexport interface ChainIterator<TKey, THead> extends ReadRepository<TKey, BlockBoundWitness>, IterableRepository<TKey, BlockBoundWitness> {\n chainIdentification: ChainIdentification\n head(): Promise<THead>\n previous(cursor?: TKey | undefined, limit?: number): Promise<BlockBoundWitness[]>\n updateHead(head: THead): Promise<void>\n}\n\nexport interface EventingChainIterator<TKey, THead> extends ChainIterator<TKey, THead>, BaseEmitter<BaseParams, ChainIteratorEventData> { }\n\nexport interface ChainBlockNumberIterator extends ChainIterator<number, BlockBoundWitness> { }\nexport interface EventingChainBlockNumberIterator extends EventingChainIterator<number, BlockBoundWitness> { }\n\nexport interface ChainHashIterator extends ChainIterator<Hash, Hash> { }\nexport interface EventingChainHashIterator extends EventingChainIterator<Hash, Hash> { }\n\nexport interface XyoChainIteratorParams extends BaseServiceParams {\n chainArchivist: ArchivistInstance\n head: BlockBoundWitness\n}\n","export type DefaultNetworkIds = 'mainnet' | 'sequence' | 'local'\nexport type NetworkId<T extends string | void = void> = | T extends void ? DefaultNetworkIds : T | DefaultNetworkIds\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 { Hash } from '@xylabs/hex'\nimport type { Promisable } from '@xylabs/promise'\nimport type { Payload } from '@xyo-network/payload-model'\n\nexport interface XyoPayloadLakeViewer {\n getPayloads(hashes: Hash[]): Promisable<Payload[]>\n}\n\nexport interface XyoPayloadLakeProvider extends XyoPayloadLakeViewer {\n addPayloads(payloads: Payload[]): Promisable<Hash[]>\n}\n\nexport interface XyoDataLakeViewer extends XyoPayloadLakeViewer {\n // if resolves to hash payload, keep going until hitting a non-payload or maxDepth, or unable to find\n fetch(hashes: Hash[], maxDepth?: number): Promisable<(ArrayBuffer | Payload)[]>\n // same as fetch but never follows hash payloads\n get(hashes: Hash[]): Promisable<(ArrayBuffer | Payload)[]>\n // same as fetch, except returns each step\n trace(hashes: Hash[]): Promisable<[(ArrayBuffer | Payload), Payload[]][]>\n}\n\nexport interface XyoDataLakeProvider extends XyoDataLakeViewer, XyoPayloadLakeProvider {\n add(items: ArrayBuffer[]): Promisable<Hash[]>\n}\n","import type { Promisable } from '@xylabs/promise'\n\nimport type { NetworkStatus } from '#network'\n\nexport interface XyoNetwork {\n status(): Promisable<NetworkStatus>\n}\n","import type { Hash } from '@xylabs/hex'\nimport type { Promisable } from '@xylabs/promise'\n\nimport type { SignedHydratedTransaction } from '#transaction'\n\nexport interface XyoRunner {\n broadcastTransaction(transaction: SignedHydratedTransaction): Promisable<Hash>\n}\n","import type { Address } from '@xylabs/hex'\nimport type { Promisable } from '@xylabs/promise'\nimport type { Signed } from '@xyo-network/boundwitness-model'\nimport type { Payload } from '@xyo-network/payload-model'\n\nimport type { AllowedBlockPayload } from '#block'\nimport type { TransactionBoundWitness, TransactionFeesBigInt } from '#transaction'\n\nexport interface XyoSigner {\n address(): Promisable<Address>\n createSignedTransaction(\n chain: Address,\n elevatedPayloads: AllowedBlockPayload[],\n additionalPayloads: Payload[],\n nbf: number,\n exp: number,\n fees: TransactionFeesBigInt,\n from?: Address,\n ): Promisable<Signed<TransactionBoundWitness>>\n}\n","import type { Address, Hash } from '@xylabs/hex'\nimport type { Promisable } from '@xylabs/promise'\n\nimport type { SignedHydratedBlock } from '#block'\nimport type { Transfer } from '#payload'\nimport type { SignedHydratedTransaction, TransactionBoundWitness } from '#transaction'\n\nexport interface XyoViewer {\n accountBalance: (address: Address) => Promisable<bigint>\n accountHistory: (address: Address) => Promisable<[TransactionBoundWitness[], Transfer[]]>\n\n blockByHash(hash: Hash): Promisable<SignedHydratedBlock | null>\n blockByNumber(blockNumber: number): Promisable<SignedHydratedBlock | null>\n blocksByHash(hash: Hash, limit?: number): Promisable<SignedHydratedBlock[]>\n\n chainId(): Promisable<Address>\n\n currentBlock(): Promisable<SignedHydratedBlock>\n currentBlockHash(): Promisable<Hash>\n currentBlockNumber(): Promisable<number>\n\n transactionByBlockHashAndIndex(blockHash: Hash, transactionIndex: number): Promisable<SignedHydratedTransaction | null>\n transactionByBlockNumberAndIndex(blockNumber: number, transactionIndex: number): Promisable<SignedHydratedTransaction | null>\n transactionByHash(transactionHash: Hash): Promisable<SignedHydratedTransaction | null>\n}\n","import type { Address } from '@xylabs/hex'\nimport type { Promisable } from '@xylabs/promise'\n\n// TODO: define the permissions object and return object types\n\nexport interface XyoWallet {\n accounts(): Promisable<Address[]>\n addChain(chain: Address, name?: string): Promisable<object>\n chain(): Promisable<Address>\n chains(): Promisable<object>\n permissions(): Promisable<Record<string, object>>\n requestPermissions(permissions: object): Promisable<object>\n revokePermissions(permissions: object): Promisable<object>\n switchChain(chain: Address): Promisable<void>\n}\n","import type { Address } from '@xylabs/hex'\nimport type { Signed } from '@xyo-network/boundwitness-model'\nimport type { Payload } from '@xyo-network/payload-model'\n\nimport type { AllowedBlockPayload } from '#block'\nimport type { TransactionBoundWitness, TransactionFeesBigInt } from '#transaction'\n\nimport type { XyoDataLakeProvider } from './XyoDataLake.ts'\nimport type { XyoNetwork } from './XyoNetwork.ts'\nimport type { XyoRunner } from './XyoRunner.ts'\nimport type { XyoSigner } from './XyoSigner.ts'\nimport type { XyoViewer } from './XyoViewer.ts'\nimport type { XyoWallet } from './XyoWallet.ts'\n\nexport interface XyoProvider {\n network?: XyoNetwork\n runner?: XyoRunner\n send?: (\n elevatedPayloads: AllowedBlockPayload[],\n additionalPayloads: Payload[],\n chain?: Address,\n nbf?: number,\n exp?: number,\n from?: Address,\n fees?: TransactionFeesBigInt,\n ) => Promise<Signed<TransactionBoundWitness>>\n signer?: XyoSigner\n storage?: XyoDataLakeProvider\n viewer?: XyoViewer\n wallet?: XyoWallet\n}\n","import type { Address } from '@xylabs/hex'\nimport type { Promisable } from '@xylabs/promise'\n\nimport type { BlockBoundWitness } from '#block'\n\nexport type BlockValidatorFunction = (\n block: BlockBoundWitness,\n chainId?: Address,\n) => Promisable<Error[]>\n","import type { Address } from '@xylabs/hex'\nimport type { Promisable } from '@xylabs/promise'\nimport type { ReadArchivist } from '@xyo-network/archivist-model'\n\nimport type { HydratedBlock } from '#block'\n\n/**\n * A function that validates a hydrated block against chain state.\n * @param hydratedBlock The hydrated block to validate.\n * @param chainId The chain ID to use for validation.\n * @param archivist The archivist to use for validation.\n * @returns An array of errors if the block is invalid, or an empty array if it is valid.\n */\nexport type HydratedBlockStateValidationFunction = (\n hydratedBlock: HydratedBlock,\n chainId: Address,\n archivist: ReadArchivist,\n) => Promisable<Error[]>\n","import type { Address } from '@xylabs/hex'\nimport type { Promisable } from '@xylabs/promise'\n\nimport type { HydratedBlock } from '#block'\n\n/**\n * A function that validates a hydrated block.\n * @param hydratedBlock The hydrated block to validate.\n * @param chainId The chain ID to use for validation.\n * @returns An array of errors if the block is invalid, or an empty array if it is valid.\n */\nexport type HydratedBlockValidatorFunction = (\n hydratedBlock: HydratedBlock,\n chainId?: Address,\n) => Promisable<Error[]>\n","import type { Promisable } from '@xylabs/promise'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\n\nexport type BoundWitnessValidationFunction<T extends BoundWitness = BoundWitness> = (\n bw: T\n) => Promisable<Error[]>\n","import type { Promisable } from '@xylabs/promise'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport type { Payload, WithHashStorageMeta } from '@xyo-network/payload-model'\n\nexport type HydratedBoundWitnessWithHashStorageMeta<T extends BoundWitness = BoundWitness, P extends Payload = Payload>\n = [WithHashStorageMeta<T>, WithHashStorageMeta<P>[]]\n\nexport type HydratedBoundWitnessValidationFunction<T extends BoundWitness = BoundWitness> = (\n bw: HydratedBoundWitnessWithHashStorageMeta<T>\n) => Promisable<Error[]>\n","import type { Promisable } from '@xylabs/promise'\nimport type { Payload, WithHashStorageMeta } from '@xyo-network/payload-model'\n\nimport type { HydratedBlock } from '#block'\n\nexport type InBlockPayloadValidationFunction = (\n payload: WithHashStorageMeta<Payload>, block: HydratedBlock\n) => Promisable<Error[]>\n","import type { Address } from '@xylabs/hex'\nimport type { Promisable } from '@xylabs/promise'\nimport type { HydratedBoundWitnessWithStorageMeta, ReadArchivist } from '@xyo-network/archivist-model'\n\nimport type { TransactionBoundWitness } from '#transaction'\n\n/**\n * A function that validates a hydrated transaction against chain state.\n * @param hydratedTransaction The hydrated transaction to validate.\n * @param chainId The chain ID to use for validation.\n * @param archivist The archivist to use for validation.\n * @returns An array of errors if the transaction is invalid, or an empty array if it is valid.\n */\nexport type HydratedTransactionStateValidationFunction<T extends TransactionBoundWitness = TransactionBoundWitness> = (\n hydratedTransaction: HydratedBoundWitnessWithStorageMeta<T>,\n chainId: Address,\n archivist: ReadArchivist,\n) => Promisable<Error[]>\n","import type { Address } from '@xylabs/hex'\nimport type { Promisable } from '@xylabs/promise'\n\nimport type {\n HydratedTransaction, HydratedTransactionWithHashStorageMeta, TransactionBoundWitness,\n} from '#transaction'\n\n/**\n * A function that validates a hydrated transaction.\n * @param bw The hydrated transaction to validate.\n * @param chainId The chain ID to use for validation.\n * @returns An array of errors if the transaction is invalid, or an empty array if it is valid.\n */\nexport type HydratedTransactionValidatorFunction<T extends TransactionBoundWitness = TransactionBoundWitness> = (\n hydratedTransaction: HydratedTransactionWithHashStorageMeta<HydratedTransaction<T>>,\n chainId?: Address,\n) => Promisable<Error[]>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACO;;ACAA;AACP;AACA;AACA;;ACJO;AACP;AACA;AAIO;AAHA;AACP;AACA;AAEO;AACA;AACA;;ACRA;AACP;AACA;;ACHO;AACP;AACA;AACO;AACP;AACA;AACO;AACP;AACO;AACP;;ACPO;AACA;AACA;AACP;AACA;AACA;AACO;AACA;AACA;AACP;AACA;AACA;AACO;AACA;AACA;AACP;AACA;AACA;AACO;;ACnBA;AACP;AACA;;ACDO;AACP;AACA;AACO;AACA;AACP;AACA;AACO;AACA;AACA;AACA;;ACTA;AACA;AACA;AACA;AACP;AACA;AACO;AACA;AACA;AACP;AACA;AACA;AACO;;ACbA;AACA;AACA;AACP;AACA;AACO;AACA;AACA;AACP;AACA;AACA;AACO;AACP;AACA;AACA;AACO;;ACdA;AACA;AACA;AACP;AACA;AACA;AACO;AACA;AACA;AACP;AACA;AACA;AACO;;ACbA;AACP;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACO;AACP;AACA;AACO;AACA;;ACTA;AACP;AACA;AACO;AACA;AACA;AACA;AACA;AACA;AACA;AACP;AACA;AACA;AACO;AACA;AACP;AACA;AACA;AACO;;ACrBA;AACA;AACA;AACA;AACA;;ACHA;AACA;AACA;AACA;AACA;AACA;;ACNA;AACP;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACO;AACA;AACA;AACA;AACP;AACA;AACA;AACO;AACA;AACP;AACA;AACA;AACO;;ACtBA;AACA;;ACDA;AACP;AACA;AACA;AACA;;ACPO;;ACCA;AACP;AACA;AACA;AACA;AACA;AACA;;ACPO;AACP;AACA;AACO;AACP;AACA;AACO;AACP;AACA;;ACNO;AACP;;ACDO;AACP;;ACDO;AACP;;ACAO;AACP;AACO;AACP;AACO;AACP;;ACPO;AACP;AACA;AACA;AACA;AACA;AACA;;ACJO;AACA;AACP;;ACHO;AACA;AACP;AACA;AACA;AACA;;ACLO;AACP;AACA;;ACHO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACRO;AACA;AACA;AACP;AACA;AACO;AACA;;ACPA;AACA;;AAEA;AACP;AACO;AACA;;ACPA;AACP;AACA;AACA;AACA;;ACHO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;;ACHO;AACP;;ACHO;AACP;AACA;;ACFO;AACP;AACA;AACA;AACA;AACO;AACA;AACA;AACA;AACA;AACP;AACA;AACA;AACO;AACA;AACP;AACA;AACA;AACO;;ACnBA;AACP;AACA;AACA;AACA;;ACGO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACnBO;AACA;AACP;AACA;;ACJO;AACP;AACA;;ACHO;AACP;AACA;AACO;AACP;AACA;AACO;AACP;;ACDO;AACP;AACA;AACA;AACA;AACA;AACO;AACP;AACO;AACP;AACO;AACP;AACO;AACP;AACO;AACP;AACO;AACP;AACA;AACA;;AC3BO;AACA;;ACAA;AACA;AACA;AACA;AACP;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACO;AACA;;ACZA;AACP;AACA;AACO;AACP;AACA;AACO;AACP;AACA;AACA;AACA;AACO;AACP;AACA;;ACdO;AACP;AACA;;ACDO;AACP;AACA;;ACCO;AACP;AACA;AACA;;ACJO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AChBO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AChBO;;ACCA;;ACDA;;ACDA;;ACCA;AACA;;ACDA;;ACCA;;ACDA;;;"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sources":["../src/Initializable.ts","../src/OpenTelemetryProviders.ts","../src/xl1/XL1.ts","../src/fields/Addressable.ts","../src/fields/BlockDuration.ts","../src/fields/BlockNumber.ts","../src/fields/ChainReference.ts","../src/payload/elevatable/Executable.ts","../src/payload/elevatable/ChainStakeIntent.ts","../src/payload/elevatable/Hash.ts","../src/payload/elevatable/TransferPayload.ts","../src/transaction/TransactionFeesFields.ts","../src/transaction/TransactionBoundWitness.ts","../src/transaction/HydratedTransaction.ts","../src/block/AllowedBlockPayload.ts","../src/block/BlockBoundWitness.ts","../src/block/HydratedBlock.ts","../src/chain/ChainAnalyzer.ts","../src/constants/StepSizes.ts","../src/constants/TransactionGasCosts.ts","../src/repository/Repository.ts","../src/repository/TransactionReadRepository.ts","../src/repository/TransactionRepositoryIterator.ts","../src/repository/TransactionWriteRepository.ts","../src/repository/TransactionRepository.ts","../src/services/AccountBalanceService.ts","../src/services/BlockProducer.ts","../src/services/Service.ts","../src/services/BlockReward.ts","../src/services/Chain/ChainContractViewer.ts","../src/services/Chain/ChainIdentification.ts","../src/services/Chain/ChainInformation.ts","../src/services/Chain/ChainStaker.ts","../src/services/Chain/ChainStakeViewer.ts","../src/services/Chain/ChainService.ts","../src/services/Election.ts","../src/services/stakeIntent/ChainIndexingServiceStateSchema.ts","../src/services/stakeIntent/StakeIntentService.ts","../src/services/ChainServiceCollection.ts","../src/services/Params.ts","../src/services/PendingTransactionsService.ts","../src/iterator/ChainIteratorEventData.ts","../src/iterator/ChainIterator.ts","../src/network/NetworkId.ts","../src/network/Status.ts","../src/provider/v1/XyoDataLake.ts","../src/provider/v1/XyoNetwork.ts","../src/provider/v1/XyoRunner.ts","../src/provider/v1/XyoSigner.ts","../src/provider/v1/XyoViewer.ts","../src/provider/v1/XyoWallet.ts","../src/provider/v1/XyoProvider.ts","../src/validation/block/BlockValidationFunction.ts","../src/validation/block/HydratedBlockStateValidationFunction.ts","../src/validation/block/HydratedBlockValidationFunction.ts","../src/validation/boundwitness/BoundWitnessValidationFunction.ts","../src/validation/boundwitness/HydratedBoundWitnessValidationFunction.ts","../src/validation/payload/InBlockPayloadValidationFunction.ts","../src/validation/transaction/HydratedTransactionStateValidationFunction.ts","../src/validation/transaction/HydratedTransactionValidationFunction.ts"],"sourcesContent":["import type { Promisable } from '@xylabs/promise'\n\nexport type Initializable<T, R> = (params: T) => Promisable<R>\n","import type { MeterProvider, TracerProvider } from '@opentelemetry/api'\n\nexport interface OpenTelemetryProviders {\n meterProvider?: MeterProvider\n traceProvider?: TracerProvider\n}\n","export type XL1 = bigint & { readonly _tag: 'XL1' } // 1e-18\nexport type MilliXL1 = bigint & { readonly _tag: 'MilliXL1' } // 1e-15 [XL1 * 1e3 = milliXL1] [milliXL1 / 1e3 = XL1]\nexport type MicroXL1 = bigint & { readonly _tag: 'MicroXL1' } // 1e-12 [XL1 * 1e6 = microXL1] [microXL1 / 1e6 = XL1]\nexport type NanoXL1 = bigint & { readonly _tag: 'NanoXL1' } // 1e-9 [XL1 * 1e9 = nanoXL1] [nanoXL1 / 1e9 = XL1]\nexport type PicoXL1 = bigint & { readonly _tag: 'PicoXL1' } // 1e-6 [XL1 * 1e12 = picoXL1] [picoXL1 / 1e12 = XL1]\nexport type FemtoXL1 = bigint & { readonly _tag: 'FemtoXL1' } // 1e-3 [XL1 * 1e15 = femtoXL1] [femtoXL1 / 1e15 = XL1]\nexport type AttoXL1 = bigint & { readonly _tag: 'AttoXL1' } // 1e-0 [XL1 * 1e18 = attoXL1] [attoXL1 / 1e18 = XL1]\n\nexport const XL1: TypingFunc<XL1> = (value: bigint): XL1 => value as XL1\nexport const MilliXL1: TypingFunc<MilliXL1> = (value: bigint): MilliXL1 => value as MilliXL1\nexport const MicroXL1: TypingFunc<MicroXL1> = (value: bigint): MicroXL1 => value as MicroXL1\nexport const NanoXL1: TypingFunc<NanoXL1> = (value: bigint): NanoXL1 => value as NanoXL1\nexport const PicoXL1: TypingFunc<PicoXL1> = (value: bigint): PicoXL1 => value as PicoXL1\nexport const FemtoXL1: TypingFunc<FemtoXL1> = (value: bigint): FemtoXL1 => value as FemtoXL1\nexport const AttoXL1: TypingFunc<AttoXL1> = (value: bigint): AttoXL1 => value as AttoXL1\n\nexport const XL1ConvertDict: Record<string, number> = {\n milli: 3,\n micro: 6,\n nano: 9,\n pico: 12,\n femto: 15,\n atto: 18,\n}\n\nexport type TypingFunc<T extends bigint> = (value: bigint) => T\n\nexport function toXL1<T extends bigint>(value: T, factor: number): XL1 {\n return XL1(value / (10n ** BigInt(factor)))\n}\n\nexport function fromXL1<T extends bigint>(value: XL1, factor: number, typingFunc: TypingFunc<T>): T {\n return typingFunc(value * (10n ** BigInt(factor)))\n}\n\n// milli\nexport const milliXL1ToXL1 = (value: MilliXL1): XL1 => {\n return toXL1(value, XL1ConvertDict.milli)\n}\n\nexport const milliXL1FromXL1 = (value: XL1): MilliXL1 => {\n return fromXL1(value, XL1ConvertDict.micro, MilliXL1)\n}\n\n// micro\nexport const microXL1ToXL1 = (value: MicroXL1): XL1 => {\n return toXL1(value, XL1ConvertDict.micro)\n}\n\nexport const microXL1FromXL1 = (value: XL1): MicroXL1 => {\n return fromXL1(value, XL1ConvertDict.micro, MicroXL1)\n}\n\n// nano\nexport const nanoXL1ToXL1 = (value: NanoXL1): XL1 => {\n return toXL1(value, XL1ConvertDict.nano)\n}\n\nexport const nanoXL1FromXL1 = (value: XL1): NanoXL1 => {\n return fromXL1(value, XL1ConvertDict.nano, NanoXL1)\n}\n\n// pico\nexport const picoXL1ToXL1 = (value: PicoXL1): XL1 => {\n return toXL1(value, XL1ConvertDict.pico)\n}\n\nexport const picoXL1FromXL1 = (value: XL1): PicoXL1 => {\n return fromXL1(value, XL1ConvertDict.pico, PicoXL1)\n}\n\n// femto\nexport const femtoXL1ToXL1 = (value: FemtoXL1): XL1 => {\n return toXL1(value, XL1ConvertDict.femto)\n}\n\nexport const femtoXL1FromXL1 = (value: XL1): FemtoXL1 => {\n return fromXL1(value, XL1ConvertDict.femto, FemtoXL1)\n}\n\n// atto\nexport const attoXL1ToXL1 = (value: AttoXL1): XL1 => {\n return toXL1(value, XL1ConvertDict.atto)\n}\n\nexport const attoXL1FromXL1 = (value: XL1): AttoXL1 => {\n return fromXL1(value, XL1ConvertDict.atto, AttoXL1)\n}\n","import type { Address } from '@xylabs/hex'\n\n// NOTE: Minimal interface in case of reuse across validators, producers, wallets, modules, etc.\nexport interface Addressable {\n address: Address\n}\n","export interface BlockStart {\n /**\n * The block at which the duration starts\n */\n nbf: number\n}\n\nexport interface BlockEnd {\n /**\n * The block at which the duration ends\n */\n exp: number\n}\n\n/**\n * A optional duration referenced to block numbers\n */\nexport interface OptionalBlockDuration extends Partial<BlockStart>, Partial<BlockEnd> {}\n\n/**\n * A duration referenced to block numbers\n */\nexport interface BlockDuration extends BlockStart, BlockEnd {}\n","import type { Hex } from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { Payload, WithSources } from '@xyo-network/payload-model'\nimport {\n isPayloadOfSchemaType,\n isPayloadOfSchemaTypeWithSources,\n} from '@xyo-network/payload-model'\n\nexport const BlockNumberSchema = 'network.xyo.chain.block.number' as const\nexport type BlockNumberSchema = typeof BlockNumberSchema\n\nexport interface BlockNumberFields {\n /**\n * The block number\n */\n block: Hex\n /**\n * The chain id\n */\n chain?: Hex\n}\n/**\n * The number of a block\n */\nexport type BlockNumber = Payload<BlockNumberFields, BlockNumberSchema>\n\n/**\n * Identity function for determining if an object is a BlockNumber\n */\nexport const isBlockNumber = isPayloadOfSchemaType<BlockNumber>(BlockNumberSchema)\nexport const asBlockNumber = AsObjectFactory.create<BlockNumber>(isBlockNumber)\nexport const asOptionalBlockNumber = AsObjectFactory.createOptional<BlockNumber>(isBlockNumber)\n\n/**\n * Identity function for determining if an object is a BlockNumber with sources\n */\nexport const isBlockNumberWithSources = isPayloadOfSchemaTypeWithSources<BlockNumber>(BlockNumberSchema)\nexport const asBlockNumberWithSources = AsObjectFactory.create<WithSources<BlockNumber>>(isBlockNumberWithSources)\nexport const asOptionalBlockNumberWithSources = AsObjectFactory.createOptional<WithSources<BlockNumber>>(isBlockNumberWithSources)\n","import type { Address } from '@xylabs/hex'\n\n/**\n * Required info for a chain reference\n */\nexport interface ChainReference {\n /**\n * The contract address referenced by the chain\n */\n chain: Address\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 { AsObjectFactory } from '@xylabs/object'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nimport type { BlockDuration } from '#fields'\n\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 { 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 { Hex } from '@xylabs/hex'\n\nimport { MicroXL1 } from '../xl1/XL1.ts'\n\nexport interface TransactionFeesBigInt {\n base: MicroXL1\n gasLimit: MicroXL1\n gasPrice: MicroXL1\n priority: MicroXL1\n}\n\nexport type TransactionFeesHex = {\n [K in keyof TransactionFeesBigInt]: Hex;\n}\n\nexport interface TransactionFeesFields {\n fees: TransactionFeesHex\n}\n\nexport const minTransactionFees: TransactionFeesBigInt = {\n base: MicroXL1(1000n), gasPrice: MicroXL1(1n), gasLimit: MicroXL1(1000n), priority: MicroXL1(0n),\n} as const\n\nexport const defaultTransactionFees: TransactionFeesBigInt = {\n base: minTransactionFees.base, gasPrice: MicroXL1(10n), gasLimit: MicroXL1(1_000_000n), priority: MicroXL1(0n),\n} as const\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 { BlockDuration } from '#fields'\nimport type { FromFields, OptionalExecutable } from '#payload'\n\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 { Signed } from '@xyo-network/boundwitness-model'\nimport type {\n Payload, WithHashStorageMeta, WithStorageMeta,\n} from '@xyo-network/payload-model'\n\nimport type { TransactionBoundWitness } from './TransactionBoundWitness.ts'\n\nexport type HydratedTransaction<T extends TransactionBoundWitness = TransactionBoundWitness, P extends Payload = Payload> = [T, P[]]\n\nexport type HydratedTransactionWithStorageMeta<T extends HydratedTransaction = HydratedTransaction>\n = [WithStorageMeta<T[0]>, WithStorageMeta<T[1][number]>[]]\n\nexport type HydratedTransactionWithHashStorageMeta<T extends HydratedTransaction = HydratedTransaction>\n = [WithHashStorageMeta<T[0]>, WithHashStorageMeta<T[1][number]>[]]\n\nexport type SignedHydratedTransaction<T extends HydratedTransaction = HydratedTransaction> = [Signed<T[0]>, T[1][number][]] & HydratedTransaction\n\nexport type SignedHydratedTransactionWithStorageMeta<T extends HydratedTransaction = HydratedTransaction>\n = [WithStorageMeta<Signed<T[0]>>, WithStorageMeta<T[1][number]>[]] & SignedHydratedTransaction<T> & HydratedTransaction\n","import { BoundWitnessSchema } from '@xyo-network/boundwitness-model'\nimport type { Schema, WithStorageMeta } from '@xyo-network/payload-model'\nimport { isHashStorageMeta, isSchema } from '@xyo-network/payload-model'\nimport type { SchemaPayload } from '@xyo-network/schema-payload-plugin'\nimport { isSchemaPayload, SchemaSchema } from '@xyo-network/schema-payload-plugin'\n\nimport type {\n ChainStakeIntent, HashPayload, Transfer,\n} from '#payload'\nimport {\n ChainStakeIntentSchema, HashSchema, isChainStakeIntent, isHashPayload, isTransfer, TransferSchema,\n} from '#payload'\nimport { isTransactionBoundWitness, type TransactionBoundWitness } from '#transaction'\n\nexport type AllowedBlockPayload = Transfer | ChainStakeIntent | SchemaPayload | TransactionBoundWitness | HashPayload\nexport const AllowedBlockPayloadSchemas: Schema[] = [TransferSchema, ChainStakeIntentSchema, SchemaSchema, BoundWitnessSchema, HashSchema]\nexport type AllowedBlockPayloadSchema = typeof AllowedBlockPayloadSchemas[number]\n\nexport const isAllowedBlockPayloadSchema = (value: unknown): value is AllowedBlockPayloadSchema => {\n return isSchema(value) && AllowedBlockPayloadSchemas.includes(value)\n}\n\nexport const isAllowedBlockPayload = (value: unknown): value is AllowedBlockPayload => {\n return isTransfer(value) || isChainStakeIntent(value) || isSchemaPayload(value) || isTransactionBoundWitness(value) || isHashPayload(value)\n}\n\nexport const isAllowedBlockPayloadWithHashStorageMeta = (value: unknown): value is WithStorageMeta<AllowedBlockPayload> => {\n return isAllowedBlockPayload(value) && isHashStorageMeta(value)\n}\n","import 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 { Signed } from '@xyo-network/boundwitness-model'\nimport type { Payload, WithStorageMeta } from '@xyo-network/payload-model'\n\nimport type { BlockBoundWitness } from './BlockBoundWitness.ts'\n\nexport type HydratedBlock = [WithStorageMeta<BlockBoundWitness>, WithStorageMeta<Payload>[]]\n\nexport type SignedHydratedBlock = [WithStorageMeta<Signed<BlockBoundWitness>>, WithStorageMeta<Payload>[]] & HydratedBlock\n","import type { Promisable } from '@xylabs/promise'\nimport type { Payload } from '@xyo-network/payload-model'\n\nimport type { HydratedBlock } from '#block'\n\nexport interface ChainAnalyzer<T extends Payload = Payload> {\n onBlock(block: HydratedBlock): Promisable<boolean>\n result(): T\n shouldContinue(): boolean\n}\n","export const StepSizes = [10, 105, 1103, 11_576, 121_551, 1_276_282, 13_400_956] as const\n","import { MicroXL1 } from '../xl1/XL1.ts'\n\nexport const TransactionGasCosts = {\n /**\n * The cost of storing each character that is added to the chain\n * This includes the transaction JSON and all the elevated payloads' JSON\n */\n characterStorage: MicroXL1(10n),\n\n /** The cost of static validating every payload that will be included in the chain */\n payloadValidation: MicroXL1(1000n),\n\n /** The cost of validating each signature that will be included in the chain */\n signatureValidation: MicroXL1(1000n),\n\n /** The cost of validating each hash that will be included in the chain */\n hashValidation: MicroXL1(100n),\n\n /** The cost of validating a balance state, triggered by a Transfer payload or gas collection */\n balanceValidation: MicroXL1(100n),\n} as const\n\n/** Gas Calculation\n *\n * 1 Million microXL1 (mXL1) = 1 XL1\n *\n * Gas amount is calculated as follows:\n *\n * 1. Each byte in the transaction cost 10 gas\n * 2. Each payload validation in the transaction costs 1000 gas\n * 3. Each signature verification in the transaction costs 1000 gas\n * 4. Each hash validation in the transaction costs 100 gas\n * 5. Each balance validation in the transaction costs 100 gas\n * 6. Processing/Compute/Storage Cost?\n * 7. operation Costs?\n *\n * The total gas cost is calculated by multiplying the gas amount by the gas price.\n *\n * minGasPrice is initially set to 100 mXL1\n * minBase is initially set to 1000 mXL1\n * minPriority is always 0 mXL1, but can be set to increase the priority of the transaction\n *\n */\n","export interface ReadRepository<TId, TData> {\n get(id: TId): Promise<TData | undefined>\n}\n\nexport interface IterableRepository<TId, TData> {\n next(id: TId): Promise<TData | undefined>\n}\n\nexport interface WriteRepository<TData, TResp> {\n insert(data: TData): Promise<TResp>\n}\n","import type { HydratedTransaction, TransactionBoundWitness } from '#transaction'\n\nimport type { ReadRepository } from './Repository.ts'\n\nexport interface TransactionReadRepository extends ReadRepository<TransactionBoundWitness, HydratedTransaction> {}\n","import type { HydratedTransaction, TransactionBoundWitness } from '#transaction'\n\nimport type { IterableRepository } from './Repository.ts'\n\nexport interface TransactionRepositoryIterator extends IterableRepository<TransactionBoundWitness, HydratedTransaction> {}\n","import type { HydratedTransaction } from '#transaction'\n\nimport type { WriteRepository } from './Repository.ts'\n\nexport interface TransactionWriteRepository extends WriteRepository<HydratedTransaction, boolean> {}\n","import type { TransactionReadRepository } from './TransactionReadRepository.ts'\nimport type { TransactionRepositoryIterator } from './TransactionRepositoryIterator.ts'\nimport type { TransactionWriteRepository } from './TransactionWriteRepository.ts'\n\nexport interface TransactionRepository extends TransactionReadRepository, TransactionWriteRepository {}\n\nexport interface ReadonlyIterableTransactionRepository extends TransactionReadRepository, TransactionRepositoryIterator {}\n\nexport interface IterableTransactionRepository extends TransactionRepository, TransactionRepositoryIterator {}\n","import type {\n Address, Hash, Hex,\n} from '@xylabs/hex'\n\nexport interface AccountBalanceService {\n getBalanceValue?: (address: Address) => bigint\n getBalanceValues?: Record<Address, bigint>\n\n getBalance(address: Address): Hex\n getBalances(): Record<Address, Hex>\n sync(head: Hash): Promise<void>\n}\n","import type { BlockBoundWitness, HydratedBlock } from '#block'\nimport type { Addressable } from '#fields'\nimport type { IterableRepository } from '#repository'\n\nexport type NextBlockProducer = IterableRepository<BlockBoundWitness, HydratedBlock>\n\nexport interface BlockProducer extends Addressable, NextBlockProducer {}\n","import type { Meter, Tracer } from '@opentelemetry/api'\nimport type { Logger } from '@xylabs/logger'\n\nexport type ServiceName = Exclude<string, 'reserved-service-name-value'>\n\nexport interface Service {\n logger?: Logger\n meter?: Meter\n tracer?: Tracer\n}\n","import type { Promisable } from '@xylabs/promise'\n\nimport type { Service } from './Service.ts'\n\nexport interface BlockRewardService extends Service {\n getRewardForBlock(block: bigint): Promisable<bigint>\n}\n","import type { Address } from '@xylabs/hex'\n\nexport interface ChainContractViewer {\n active(): Promise<bigint>\n chainId(): Promise<Address>\n forkedAtBlockNumber(): Promise<bigint>\n forkedAtHash(): Promise<bigint>\n forkedChainId(): Promise<Address>\n minWithdrawalBlocks(): Promise<bigint>\n rewardsContract(): Promise<string>\n stakingTokenAddress(): Promise<string>\n}\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","export interface ChainStaker {\n addStake(staked: string, amount: bigint): Promise<boolean>\n removeStake(slot: bigint): Promise<boolean>\n withdrawStake(slot: bigint): Promise<boolean>\n}\n","import type { ChainContractViewer } from './ChainContractViewer.ts'\n\nexport interface ChainStakeViewer extends ChainContractViewer {\n activeByAddressStaked(address: string): Promise<bigint>\n activeByStaker(address: string): Promise<bigint>\n pending(): Promise<bigint>\n pendingByStaker(staker: string): Promise<bigint>\n withdrawn(): Promise<bigint>\n withdrawnByStaker(staker: string): Promise<bigint>\n}\n","import type { Service } from '../Service.ts'\nimport type { ChainContractViewer } from './ChainContractViewer.ts'\nimport type { ChainInformation } from './ChainInformation.ts'\nimport type { ChainStaker } from './ChainStaker.ts'\nimport type { ChainStakeViewer } from './ChainStakeViewer.ts'\n\nexport interface ChainService extends ChainInformation, ChainContractViewer, ChainStakeViewer, ChainStaker, Service {}\n","import type { Address } from '@xylabs/hex'\n\nimport type { BlockBoundWitness } from '#block'\n\nimport type { Service } from './Service.ts'\n\nexport interface ElectionService extends Service {\n\n /**\n * Given the current block, get the leader for the next block\n * @param current The previous block\n */\n getCreatorCommitteeForNextBlock(current: BlockBoundWitness): Promise<Address[]>\n\n}\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","import type { Address } from '@xylabs/hex'\n\nimport type { Intent } from '#payload'\n\nexport interface StakeIntentService {\n\n /**\n * Gets the declared ranges for an address based on historical on-chain data\n * @param address The address to get the declared ranges for\n * @param intent The declared intent to filter for\n */\n getDeclaredCandidateRanges(address: Address, intent: Intent): Promise<Readonly<Readonly<[number, number]>[]>>\n\n /**\n * Gets the declared candidates for a block based on historical on-chain data\n * @param block The block number to get the declared candidates for\n * @param intent The declared intent to filter for\n */\n getDeclaredCandidatesForBlock(block: number, intent: Intent): Promise<Address[]>\n\n /**\n * Checks if the address is staked for a block for a given intent\n * @param block The block number to check\n * @param intent The declared intent to filter for\n * @param address The address to check\n */\n isStakedForBlock(block: number, intent: Intent, address: Address): Promise<boolean>\n}\n","import type { ArchivistInstance, WriteArchivist } from '@xyo-network/archivist-model'\nimport type { WalletInstance } from '@xyo-network/wallet-model'\n\nimport type { EventingChainBlockNumberIterator } from '../iterator/index.ts'\nimport type { AccountBalanceService } from './AccountBalanceService.ts'\nimport type { BlockProducer } from './BlockProducer.ts'\nimport type { BlockRewardService } from './BlockReward.ts'\nimport type {\n ChainContractViewer, ChainInformation, ChainStaker, ChainStakeViewer,\n} from './Chain/index.ts'\nimport type { ElectionService } from './Election.ts'\nimport type { StakeIntentService } from './stakeIntent/index.ts'\n\nexport interface ChainServiceCollection {\n\n account: WalletInstance\n /**\n * Services for working with account balances\n */\n balanceService: AccountBalanceService\n /**\n * The archivist which the chain data is stored in\n */\n chainArchivist: ArchivistInstance\n chainContractViewer: ChainContractViewer\n /**\n * Hydrated information about the chain\n */\n chainInformation: ChainInformation\n /**\n * The chain iterator\n */\n chainIterator?: EventingChainBlockNumberIterator\n chainStakeViewer: ChainStakeViewer\n chainStaker: ChainStaker\n chainSubmissionsArchivistWrite: WriteArchivist\n electionService: ElectionService\n producer: BlockProducer\n rewardService: BlockRewardService\n /**\n * Services for working with staked intents\n */\n stakeIntentService: StakeIntentService\n}\n","import type { BaseParams } from '@xylabs/base'\nimport type { EmptyObject } from '@xylabs/object'\nimport type { AccountInstance } from '@xyo-network/account-model'\n\nimport type { OpenTelemetryProviders } from '../OpenTelemetryProviders.ts'\n\nexport type BaseServiceParams<TAdditionalParams extends EmptyObject = EmptyObject> = BaseParams<TAdditionalParams & OpenTelemetryProviders>\n\nexport type BaseAccountableServiceParams = BaseServiceParams<{\n account: AccountInstance\n}>\n","import type { Hash } from '@xylabs/hex'\n\nimport type { HydratedTransaction } from '#transaction'\n\nimport type { Service } from './Service.ts'\n\nexport interface PendingTransactionsService extends Service {\n getPendingTransactions(head: Hash, limit: number, timeout?: number): Promise<HydratedTransaction[]>\n}\n","import type { EventData } from '@xylabs/events'\n\nimport type { BlockBoundWitness } from '#block'\n\nexport type HeadEventArgs = { blocks: [BlockBoundWitness] }\n\nexport interface HeadEventData extends EventData {\n headUpdated: HeadEventArgs\n}\n\nexport interface ChainIteratorEventData extends HeadEventData { }\n","import type { BaseParams } from '@xylabs/base'\nimport type { BaseEmitter } from '@xylabs/events'\nimport type { Hash } from '@xylabs/hex'\nimport type { ArchivistInstance } from '@xyo-network/archivist-model'\n\nimport type { BlockBoundWitness } from '#block'\nimport type { IterableRepository, ReadRepository } from '#repository'\nimport type { BaseServiceParams, ChainIdentification } from '#services'\n\nimport type { ChainIteratorEventData } from './ChainIteratorEventData.ts'\n\nexport interface ChainIterator<TKey, THead> extends ReadRepository<TKey, BlockBoundWitness>, IterableRepository<TKey, BlockBoundWitness> {\n chainIdentification: ChainIdentification\n head(): Promise<THead>\n previous(cursor?: TKey | undefined, limit?: number): Promise<BlockBoundWitness[]>\n updateHead(head: THead): Promise<void>\n}\n\nexport interface EventingChainIterator<TKey, THead> extends ChainIterator<TKey, THead>, BaseEmitter<BaseParams, ChainIteratorEventData> { }\n\nexport interface ChainBlockNumberIterator extends ChainIterator<number, BlockBoundWitness> { }\nexport interface EventingChainBlockNumberIterator extends EventingChainIterator<number, BlockBoundWitness> { }\n\nexport interface ChainHashIterator extends ChainIterator<Hash, Hash> { }\nexport interface EventingChainHashIterator extends EventingChainIterator<Hash, Hash> { }\n\nexport interface XyoChainIteratorParams extends BaseServiceParams {\n chainArchivist: ArchivistInstance\n head: BlockBoundWitness\n}\n","export type DefaultNetworkIds = 'mainnet' | 'sequence' | 'local'\nexport type NetworkId<T extends string | void = void> = | T extends void ? DefaultNetworkIds : T | DefaultNetworkIds\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 { Hash } from '@xylabs/hex'\nimport type { Promisable } from '@xylabs/promise'\nimport type { Payload } from '@xyo-network/payload-model'\n\nexport interface XyoPayloadLakeViewer {\n getPayloads(hashes: Hash[]): Promisable<Payload[]>\n}\n\nexport interface XyoPayloadLakeProvider extends XyoPayloadLakeViewer {\n addPayloads(payloads: Payload[]): Promisable<Hash[]>\n}\n\nexport interface XyoDataLakeViewer extends XyoPayloadLakeViewer {\n // if resolves to hash payload, keep going until hitting a non-payload or maxDepth, or unable to find\n fetch(hashes: Hash[], maxDepth?: number): Promisable<(ArrayBuffer | Payload)[]>\n // same as fetch but never follows hash payloads\n get(hashes: Hash[]): Promisable<(ArrayBuffer | Payload)[]>\n // same as fetch, except returns each step\n trace(hashes: Hash[]): Promisable<[(ArrayBuffer | Payload), Payload[]][]>\n}\n\nexport interface XyoDataLakeProvider extends XyoDataLakeViewer, XyoPayloadLakeProvider {\n add(items: ArrayBuffer[]): Promisable<Hash[]>\n}\n","import type { Promisable } from '@xylabs/promise'\n\nimport type { NetworkStatus } from '#network'\n\nexport interface XyoNetwork {\n status(): Promisable<NetworkStatus>\n}\n","import type { Hash } from '@xylabs/hex'\nimport type { Promisable } from '@xylabs/promise'\n\nimport type { SignedHydratedTransaction } from '#transaction'\n\nexport interface XyoRunner {\n broadcastTransaction(transaction: SignedHydratedTransaction): Promisable<Hash>\n}\n","import type { Address } from '@xylabs/hex'\nimport type { Promisable } from '@xylabs/promise'\nimport type { Signed } from '@xyo-network/boundwitness-model'\nimport type { Payload } from '@xyo-network/payload-model'\n\nimport type { AllowedBlockPayload } from '#block'\nimport type { TransactionBoundWitness, TransactionFeesBigInt } from '#transaction'\n\nexport interface XyoSigner {\n address(): Promisable<Address>\n createSignedTransaction(\n chain: Address,\n elevatedPayloads: AllowedBlockPayload[],\n additionalPayloads: Payload[],\n nbf: number,\n exp: number,\n fees: TransactionFeesBigInt,\n from?: Address,\n ): Promisable<Signed<TransactionBoundWitness>>\n}\n","import type { Address, Hash } from '@xylabs/hex'\nimport type { Promisable } from '@xylabs/promise'\n\nimport type { SignedHydratedBlock } from '#block'\nimport type { Transfer } from '#payload'\nimport type { SignedHydratedTransaction, TransactionBoundWitness } from '#transaction'\n\nexport interface XyoViewer {\n accountBalance: (address: Address) => Promisable<bigint>\n accountHistory: (address: Address) => Promisable<[TransactionBoundWitness[], Transfer[]]>\n\n blockByHash(hash: Hash): Promisable<SignedHydratedBlock | null>\n blockByNumber(blockNumber: number): Promisable<SignedHydratedBlock | null>\n blocksByHash(hash: Hash, limit?: number): Promisable<SignedHydratedBlock[]>\n\n chainId(): Promisable<Address>\n\n currentBlock(): Promisable<SignedHydratedBlock>\n currentBlockHash(): Promisable<Hash>\n currentBlockNumber(): Promisable<number>\n\n transactionByBlockHashAndIndex(blockHash: Hash, transactionIndex: number): Promisable<SignedHydratedTransaction | null>\n transactionByBlockNumberAndIndex(blockNumber: number, transactionIndex: number): Promisable<SignedHydratedTransaction | null>\n transactionByHash(transactionHash: Hash): Promisable<SignedHydratedTransaction | null>\n}\n","import type { Address } from '@xylabs/hex'\nimport type { Promisable } from '@xylabs/promise'\n\n// TODO: define the permissions object and return object types\n\nexport interface XyoWallet {\n accounts(): Promisable<Address[]>\n addChain(chain: Address, name?: string): Promisable<object>\n chain(): Promisable<Address>\n chains(): Promisable<object>\n permissions(): Promisable<Record<string, object>>\n requestPermissions(permissions: object): Promisable<object>\n revokePermissions(permissions: object): Promisable<object>\n switchChain(chain: Address): Promisable<void>\n}\n","import type { Address } from '@xylabs/hex'\nimport type { Signed } from '@xyo-network/boundwitness-model'\nimport type { Payload } from '@xyo-network/payload-model'\n\nimport type { AllowedBlockPayload } from '#block'\nimport type { TransactionBoundWitness, TransactionFeesBigInt } from '#transaction'\n\nimport type { XyoDataLakeProvider } from './XyoDataLake.ts'\nimport type { XyoNetwork } from './XyoNetwork.ts'\nimport type { XyoRunner } from './XyoRunner.ts'\nimport type { XyoSigner } from './XyoSigner.ts'\nimport type { XyoViewer } from './XyoViewer.ts'\nimport type { XyoWallet } from './XyoWallet.ts'\n\nexport interface XyoProvider {\n network?: XyoNetwork\n runner?: XyoRunner\n send?: (\n elevatedPayloads: AllowedBlockPayload[],\n additionalPayloads: Payload[],\n chain?: Address,\n nbf?: number,\n exp?: number,\n from?: Address,\n fees?: TransactionFeesBigInt,\n ) => Promise<Signed<TransactionBoundWitness>>\n signer?: XyoSigner\n storage?: XyoDataLakeProvider\n viewer?: XyoViewer\n wallet?: XyoWallet\n}\n","import type { Address } from '@xylabs/hex'\nimport type { Promisable } from '@xylabs/promise'\n\nimport type { BlockBoundWitness } from '#block'\n\nexport type BlockValidatorFunction = (\n block: BlockBoundWitness,\n chainId?: Address,\n) => Promisable<Error[]>\n","import type { Address } from '@xylabs/hex'\nimport type { Promisable } from '@xylabs/promise'\nimport type { ReadArchivist } from '@xyo-network/archivist-model'\n\nimport type { HydratedBlock } from '#block'\n\n/**\n * A function that validates a hydrated block against chain state.\n * @param hydratedBlock The hydrated block to validate.\n * @param chainId The chain ID to use for validation.\n * @param archivist The archivist to use for validation.\n * @returns An array of errors if the block is invalid, or an empty array if it is valid.\n */\nexport type HydratedBlockStateValidationFunction = (\n hydratedBlock: HydratedBlock,\n chainId: Address,\n archivist: ReadArchivist,\n) => Promisable<Error[]>\n","import type { Address } from '@xylabs/hex'\nimport type { Promisable } from '@xylabs/promise'\n\nimport type { HydratedBlock } from '#block'\n\n/**\n * A function that validates a hydrated block.\n * @param hydratedBlock The hydrated block to validate.\n * @param chainId The chain ID to use for validation.\n * @returns An array of errors if the block is invalid, or an empty array if it is valid.\n */\nexport type HydratedBlockValidatorFunction = (\n hydratedBlock: HydratedBlock,\n chainId?: Address,\n) => Promisable<Error[]>\n","import type { Promisable } from '@xylabs/promise'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\n\nexport type BoundWitnessValidationFunction<T extends BoundWitness = BoundWitness> = (\n bw: T\n) => Promisable<Error[]>\n","import type { Promisable } from '@xylabs/promise'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport type { Payload, WithHashStorageMeta } from '@xyo-network/payload-model'\n\nexport type HydratedBoundWitnessWithHashStorageMeta<T extends BoundWitness = BoundWitness, P extends Payload = Payload>\n = [WithHashStorageMeta<T>, WithHashStorageMeta<P>[]]\n\nexport type HydratedBoundWitnessValidationFunction<T extends BoundWitness = BoundWitness> = (\n bw: HydratedBoundWitnessWithHashStorageMeta<T>\n) => Promisable<Error[]>\n","import type { Promisable } from '@xylabs/promise'\nimport type { Payload, WithHashStorageMeta } from '@xyo-network/payload-model'\n\nimport type { HydratedBlock } from '#block'\n\nexport type InBlockPayloadValidationFunction = (\n payload: WithHashStorageMeta<Payload>, block: HydratedBlock\n) => Promisable<Error[]>\n","import type { Address } from '@xylabs/hex'\nimport type { Promisable } from '@xylabs/promise'\nimport type { HydratedBoundWitnessWithStorageMeta, ReadArchivist } from '@xyo-network/archivist-model'\n\nimport type { TransactionBoundWitness } from '#transaction'\n\n/**\n * A function that validates a hydrated transaction against chain state.\n * @param hydratedTransaction The hydrated transaction to validate.\n * @param chainId The chain ID to use for validation.\n * @param archivist The archivist to use for validation.\n * @returns An array of errors if the transaction is invalid, or an empty array if it is valid.\n */\nexport type HydratedTransactionStateValidationFunction<T extends TransactionBoundWitness = TransactionBoundWitness> = (\n hydratedTransaction: HydratedBoundWitnessWithStorageMeta<T>,\n chainId: Address,\n archivist: ReadArchivist,\n) => Promisable<Error[]>\n","import type { Address } from '@xylabs/hex'\nimport type { Promisable } from '@xylabs/promise'\n\nimport type {\n HydratedTransaction, HydratedTransactionWithHashStorageMeta, TransactionBoundWitness,\n} from '#transaction'\n\n/**\n * A function that validates a hydrated transaction.\n * @param bw The hydrated transaction to validate.\n * @param chainId The chain ID to use for validation.\n * @returns An array of errors if the transaction is invalid, or an empty array if it is valid.\n */\nexport type HydratedTransactionValidatorFunction<T extends TransactionBoundWitness = TransactionBoundWitness> = (\n hydratedTransaction: HydratedTransactionWithHashStorageMeta<HydratedTransaction<T>>,\n chainId?: Address,\n) => Promisable<Error[]>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACO;;ACAA;AACP;AACA;AACA;;ACJO;AACP;AACA;AAmBO;AAlBA;AACP;AACA;AAiBO;AAhBA;AACP;AACA;AAeO;AAdA;AACP;AACA;AAaO;AAZA;AACP;AACA;AAWO;AAVA;AACP;AACA;AASO;AARA;AACP;AACA;AAOO;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC1CA;AACP;AACA;;ACHO;AACP;AACA;AACO;AACP;AACA;AACO;AACP;AACO;AACP;;ACPO;AACA;AACA;AACP;AACA;AACA;AACO;AACA;AACA;AACP;AACA;AACA;AACO;AACA;AACA;AACP;AACA;AACA;AACO;;ACnBA;AACP;AACA;;ACDO;AACP;AACA;AACO;AACA;AACP;AACA;AACO;AACA;AACA;AACA;;ACTA;AACA;AACA;AACA;AACP;AACA;AACO;AACA;AACA;AACP;AACA;AACA;AACO;;ACbA;AACA;AACA;AACP;AACA;AACO;AACA;AACA;AACP;AACA;AACA;AACO;AACP;AACA;AACA;AACO;;ACdA;AACA;AACA;AACP;AACA;AACA;AACO;AACA;AACA;AACP;AACA;AACA;AACO;;ACbA;AACP;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACO;AACP;AACA;AACO;AACA;;ACTA;AACP;AACA;AACO;AACA;AACA;AACA;AACA;AACA;AACA;AACP;AACA;AACA;AACO;AACA;AACP;AACA;AACA;AACO;;ACrBA;AACA;AACA;AACA;AACA;;ACHA;AACA;AACA;AACA;AACA;AACA;;ACNA;AACP;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACO;AACA;AACA;AACA;AACP;AACA;AACA;AACO;AACA;AACP;AACA;AACA;AACO;;ACtBA;AACA;;ACDA;AACP;AACA;AACA;AACA;;ACPO;;ACCA;AACP;AACA;AACA;AACA;AACA;AACA;;ACPO;AACP;AACA;AACO;AACP;AACA;AACO;AACP;AACA;;ACNO;AACP;;ACDO;AACP;;ACDO;AACP;;ACAO;AACP;AACO;AACP;AACO;AACP;;ACPO;AACP;AACA;AACA;AACA;AACA;AACA;;ACJO;AACA;AACP;;ACHO;AACA;AACP;AACA;AACA;AACA;;ACLO;AACP;AACA;;ACHO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACRO;AACA;AACA;AACP;AACA;AACO;AACA;;ACPA;AACA;;AAEA;AACP;AACO;AACA;;ACPA;AACP;AACA;AACA;AACA;;ACHO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;;ACHO;AACP;;ACHO;AACP;AACA;;ACFO;AACP;AACA;AACA;AACA;AACO;AACA;AACA;AACA;AACA;AACP;AACA;AACA;AACO;AACA;AACP;AACA;AACA;AACO;;ACnBA;AACP;AACA;AACA;AACA;;ACGO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACnBO;AACA;AACP;AACA;;ACJO;AACP;AACA;;ACHO;AACP;AACA;AACO;AACP;AACA;AACO;AACP;;ACDO;AACP;AACA;AACA;AACA;AACA;AACO;AACP;AACO;AACP;AACO;AACP;AACO;AACP;AACO;AACP;AACO;AACP;AACA;AACA;;AC3BO;AACA;;ACAA;AACA;AACA;AACA;AACP;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACO;AACA;;ACZA;AACP;AACA;AACO;AACP;AACA;AACO;AACP;AACA;AACA;AACA;AACO;AACP;AACA;;ACdO;AACP;AACA;;ACDO;AACP;AACA;;ACCO;AACP;AACA;AACA;;ACJO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AChBO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AChBO;;ACCA;;ACDA;;ACDA;;ACCA;AACA;;ACDA;;ACCA;;ACDA;;;"}
|
package/dist/neutral/index.mjs
CHANGED
|
@@ -1,11 +1,60 @@
|
|
|
1
|
-
// src/XL1.ts
|
|
1
|
+
// src/xl1/XL1.ts
|
|
2
2
|
var XL1 = (value) => value;
|
|
3
|
+
var MilliXL1 = (value) => value;
|
|
3
4
|
var MicroXL1 = (value) => value;
|
|
4
|
-
var
|
|
5
|
-
|
|
5
|
+
var NanoXL1 = (value) => value;
|
|
6
|
+
var PicoXL1 = (value) => value;
|
|
7
|
+
var FemtoXL1 = (value) => value;
|
|
8
|
+
var AttoXL1 = (value) => value;
|
|
9
|
+
var XL1ConvertDict = {
|
|
10
|
+
milli: 3,
|
|
11
|
+
micro: 6,
|
|
12
|
+
nano: 9,
|
|
13
|
+
pico: 12,
|
|
14
|
+
femto: 15,
|
|
15
|
+
atto: 18
|
|
6
16
|
};
|
|
7
|
-
|
|
8
|
-
return
|
|
17
|
+
function toXL1(value, factor) {
|
|
18
|
+
return XL1(value / 10n ** BigInt(factor));
|
|
19
|
+
}
|
|
20
|
+
function fromXL1(value, factor, typingFunc) {
|
|
21
|
+
return typingFunc(value * 10n ** BigInt(factor));
|
|
22
|
+
}
|
|
23
|
+
var milliXL1ToXL1 = (value) => {
|
|
24
|
+
return toXL1(value, XL1ConvertDict.milli);
|
|
25
|
+
};
|
|
26
|
+
var milliXL1FromXL1 = (value) => {
|
|
27
|
+
return fromXL1(value, XL1ConvertDict.micro, MilliXL1);
|
|
28
|
+
};
|
|
29
|
+
var microXL1ToXL1 = (value) => {
|
|
30
|
+
return toXL1(value, XL1ConvertDict.micro);
|
|
31
|
+
};
|
|
32
|
+
var microXL1FromXL1 = (value) => {
|
|
33
|
+
return fromXL1(value, XL1ConvertDict.micro, MicroXL1);
|
|
34
|
+
};
|
|
35
|
+
var nanoXL1ToXL1 = (value) => {
|
|
36
|
+
return toXL1(value, XL1ConvertDict.nano);
|
|
37
|
+
};
|
|
38
|
+
var nanoXL1FromXL1 = (value) => {
|
|
39
|
+
return fromXL1(value, XL1ConvertDict.nano, NanoXL1);
|
|
40
|
+
};
|
|
41
|
+
var picoXL1ToXL1 = (value) => {
|
|
42
|
+
return toXL1(value, XL1ConvertDict.pico);
|
|
43
|
+
};
|
|
44
|
+
var picoXL1FromXL1 = (value) => {
|
|
45
|
+
return fromXL1(value, XL1ConvertDict.pico, PicoXL1);
|
|
46
|
+
};
|
|
47
|
+
var femtoXL1ToXL1 = (value) => {
|
|
48
|
+
return toXL1(value, XL1ConvertDict.femto);
|
|
49
|
+
};
|
|
50
|
+
var femtoXL1FromXL1 = (value) => {
|
|
51
|
+
return fromXL1(value, XL1ConvertDict.femto, FemtoXL1);
|
|
52
|
+
};
|
|
53
|
+
var attoXL1ToXL1 = (value) => {
|
|
54
|
+
return toXL1(value, XL1ConvertDict.atto);
|
|
55
|
+
};
|
|
56
|
+
var attoXL1FromXL1 = (value) => {
|
|
57
|
+
return fromXL1(value, XL1ConvertDict.atto, AttoXL1);
|
|
9
58
|
};
|
|
10
59
|
|
|
11
60
|
// src/block/AllowedBlockPayload.ts
|
|
@@ -179,18 +228,24 @@ var asChainIndexingServiceStateWithStorageMeta = AsObjectFactory7.create(isChain
|
|
|
179
228
|
var asOptionalChainIndexingServiceStateWithStorageMeta = AsObjectFactory7.createOptional(isChainIndexingServiceStateWithStorageMeta);
|
|
180
229
|
export {
|
|
181
230
|
AllowedBlockPayloadSchemas,
|
|
231
|
+
AttoXL1,
|
|
182
232
|
BlockNumberSchema,
|
|
183
233
|
ChainIdentificationPayloadSchema,
|
|
184
234
|
ChainIndexingServiceStateSchema,
|
|
185
235
|
ChainInformationPayloadSchema,
|
|
186
236
|
ChainStakeIntentSchema,
|
|
237
|
+
FemtoXL1,
|
|
187
238
|
HashSchema,
|
|
188
239
|
MicroXL1,
|
|
240
|
+
MilliXL1,
|
|
241
|
+
NanoXL1,
|
|
189
242
|
NetworkStatusSchema,
|
|
243
|
+
PicoXL1,
|
|
190
244
|
StepSizes,
|
|
191
245
|
TransactionGasCosts,
|
|
192
246
|
TransferSchema,
|
|
193
247
|
XL1,
|
|
248
|
+
XL1ConvertDict,
|
|
194
249
|
asBlockBoundWitness,
|
|
195
250
|
asBlockBoundWitnessWithStorageMeta,
|
|
196
251
|
asBlockNumber,
|
|
@@ -214,7 +269,12 @@ export {
|
|
|
214
269
|
asTransactionBoundWitness,
|
|
215
270
|
asTransactionBoundWitnessWithStorageMeta,
|
|
216
271
|
asTransfer,
|
|
272
|
+
attoXL1FromXL1,
|
|
273
|
+
attoXL1ToXL1,
|
|
217
274
|
defaultTransactionFees,
|
|
275
|
+
femtoXL1FromXL1,
|
|
276
|
+
femtoXL1ToXL1,
|
|
277
|
+
fromXL1,
|
|
218
278
|
hasFrom,
|
|
219
279
|
isAllowedBlockPayload,
|
|
220
280
|
isAllowedBlockPayloadSchema,
|
|
@@ -237,8 +297,15 @@ export {
|
|
|
237
297
|
isTransactionBoundWitness,
|
|
238
298
|
isTransactionBoundWitnessWithStorageMeta,
|
|
239
299
|
isTransfer,
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
300
|
+
microXL1FromXL1,
|
|
301
|
+
microXL1ToXL1,
|
|
302
|
+
milliXL1FromXL1,
|
|
303
|
+
milliXL1ToXL1,
|
|
304
|
+
minTransactionFees,
|
|
305
|
+
nanoXL1FromXL1,
|
|
306
|
+
nanoXL1ToXL1,
|
|
307
|
+
picoXL1FromXL1,
|
|
308
|
+
picoXL1ToXL1,
|
|
309
|
+
toXL1
|
|
243
310
|
};
|
|
244
311
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/XL1.ts","../../src/block/AllowedBlockPayload.ts","../../src/payload/elevatable/ChainStakeIntent.ts","../../src/payload/elevatable/Executable.ts","../../src/payload/elevatable/Hash.ts","../../src/payload/elevatable/TransferPayload.ts","../../src/transaction/TransactionBoundWitness.ts","../../src/transaction/TransactionFeesFields.ts","../../src/block/BlockBoundWitness.ts","../../src/constants/StepSizes.ts","../../src/constants/TransactionGasCosts.ts","../../src/fields/BlockNumber.ts","../../src/network/Status.ts","../../src/services/Chain/ChainIdentification.ts","../../src/services/Chain/ChainInformation.ts","../../src/services/stakeIntent/ChainIndexingServiceStateSchema.ts"],"sourcesContent":["export type XL1 = bigint & { readonly _tag: 'XL1' } // 1e-18\nexport type MicroXL1 = bigint & { readonly _tag: 'MicroXL1' } // 1e-24\n\nexport const XL1 = (value: bigint): XL1 => value as XL1\nexport const MicroXL1 = (value: bigint): MicroXL1 => value as MicroXL1\n\nexport const mXL1ToXL1 = (value: MicroXL1): XL1 => {\n return XL1(BigInt(value) / BigInt(1_000_000))\n}\n\nexport const mXL1FromXL1 = (value: XL1): MicroXL1 => {\n return MicroXL1(BigInt(value) * BigInt(1_000_000))\n}\n","import { BoundWitnessSchema } from '@xyo-network/boundwitness-model'\nimport type { Schema, WithStorageMeta } from '@xyo-network/payload-model'\nimport { isHashStorageMeta, isSchema } from '@xyo-network/payload-model'\nimport type { SchemaPayload } from '@xyo-network/schema-payload-plugin'\nimport { isSchemaPayload, SchemaSchema } from '@xyo-network/schema-payload-plugin'\n\nimport type {\n ChainStakeIntent, HashPayload, Transfer,\n} from '#payload'\nimport {\n ChainStakeIntentSchema, HashSchema, isChainStakeIntent, isHashPayload, isTransfer, TransferSchema,\n} from '#payload'\nimport { isTransactionBoundWitness, type TransactionBoundWitness } from '#transaction'\n\nexport type AllowedBlockPayload = Transfer | ChainStakeIntent | SchemaPayload | TransactionBoundWitness | HashPayload\nexport const AllowedBlockPayloadSchemas: Schema[] = [TransferSchema, ChainStakeIntentSchema, SchemaSchema, BoundWitnessSchema, HashSchema]\nexport type AllowedBlockPayloadSchema = typeof AllowedBlockPayloadSchemas[number]\n\nexport const isAllowedBlockPayloadSchema = (value: unknown): value is AllowedBlockPayloadSchema => {\n return isSchema(value) && AllowedBlockPayloadSchemas.includes(value)\n}\n\nexport const isAllowedBlockPayload = (value: unknown): value is AllowedBlockPayload => {\n return isTransfer(value) || isChainStakeIntent(value) || isSchemaPayload(value) || isTransactionBoundWitness(value) || isHashPayload(value)\n}\n\nexport const isAllowedBlockPayloadWithHashStorageMeta = (value: unknown): value is WithStorageMeta<AllowedBlockPayload> => {\n return isAllowedBlockPayload(value) && isHashStorageMeta(value)\n}\n","import { AsObjectFactory } from '@xylabs/object'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nimport type { BlockDuration } from '#fields'\n\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 { BlockDuration } from '#fields'\nimport type { FromFields, OptionalExecutable } from '#payload'\n\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 { Hex } from '@xylabs/hex'\n\nimport { MicroXL1 } from '../XL1.ts'\n\nexport interface TransactionFeesBigInt {\n base: MicroXL1\n gasLimit: MicroXL1\n gasPrice: MicroXL1\n priority: MicroXL1\n}\n\nexport type TransactionFeesHex = {\n [K in keyof TransactionFeesBigInt]: Hex;\n}\n\nexport interface TransactionFeesFields {\n fees: TransactionFeesHex\n}\n\nexport const minTransactionFees: TransactionFeesBigInt = {\n base: MicroXL1(1000n), gasPrice: MicroXL1(1n), gasLimit: MicroXL1(1000n), priority: MicroXL1(0n),\n} as const\n\nexport const defaultTransactionFees: TransactionFeesBigInt = {\n base: minTransactionFees.base, gasPrice: MicroXL1(10n), gasLimit: MicroXL1(1_000_000n), priority: MicroXL1(0n),\n} as const\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","export const StepSizes = [10, 105, 1103, 11_576, 121_551, 1_276_282, 13_400_956] as const\n","import { MicroXL1 } from '../XL1.ts'\n\nexport const TransactionGasCosts = {\n /**\n * The cost of storing each character that is added to the chain\n * This includes the transaction JSON and all the elevated payloads' JSON\n */\n characterStorage: MicroXL1(10n),\n\n /** The cost of static validating every payload that will be included in the chain */\n payloadValidation: MicroXL1(1000n),\n\n /** The cost of validating each signature that will be included in the chain */\n signatureValidation: MicroXL1(1000n),\n\n /** The cost of validating each hash that will be included in the chain */\n hashValidation: MicroXL1(100n),\n\n /** The cost of validating a balance state, triggered by a Transfer payload or gas collection */\n balanceValidation: MicroXL1(100n),\n} as const\n\n/** Gas Calculation\n *\n * 1 Million microXL1 (mXL1) = 1 XL1\n *\n * Gas amount is calculated as follows:\n *\n * 1. Each byte in the transaction cost 10 gas\n * 2. Each payload validation in the transaction costs 1000 gas\n * 3. Each signature verification in the transaction costs 1000 gas\n * 4. Each hash validation in the transaction costs 100 gas\n * 5. Each balance validation in the transaction costs 100 gas\n * 6. Processing/Compute/Storage Cost?\n * 7. operation Costs?\n *\n * The total gas cost is calculated by multiplying the gas amount by the gas price.\n *\n * minGasPrice is initially set to 100 mXL1\n * minBase is initially set to 1000 mXL1\n * minPriority is always 0 mXL1, but can be set to increase the priority of the transaction\n *\n */\n","import type { Hex } from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { Payload, WithSources } from '@xyo-network/payload-model'\nimport {\n isPayloadOfSchemaType,\n isPayloadOfSchemaTypeWithSources,\n} from '@xyo-network/payload-model'\n\nexport const BlockNumberSchema = 'network.xyo.chain.block.number' as const\nexport type BlockNumberSchema = typeof BlockNumberSchema\n\nexport interface BlockNumberFields {\n /**\n * The block number\n */\n block: Hex\n /**\n * The chain id\n */\n chain?: Hex\n}\n/**\n * The number of a block\n */\nexport type BlockNumber = Payload<BlockNumberFields, BlockNumberSchema>\n\n/**\n * Identity function for determining if an object is a BlockNumber\n */\nexport const isBlockNumber = isPayloadOfSchemaType<BlockNumber>(BlockNumberSchema)\nexport const asBlockNumber = AsObjectFactory.create<BlockNumber>(isBlockNumber)\nexport const asOptionalBlockNumber = AsObjectFactory.createOptional<BlockNumber>(isBlockNumber)\n\n/**\n * Identity function for determining if an object is a BlockNumber with sources\n */\nexport const isBlockNumberWithSources = isPayloadOfSchemaTypeWithSources<BlockNumber>(BlockNumberSchema)\nexport const asBlockNumberWithSources = AsObjectFactory.create<WithSources<BlockNumber>>(isBlockNumberWithSources)\nexport const asOptionalBlockNumberWithSources = AsObjectFactory.createOptional<WithSources<BlockNumber>>(isBlockNumberWithSources)\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"],"mappings":";AAGO,IAAM,MAAM,CAAC,UAAuB;AACpC,IAAM,WAAW,CAAC,UAA4B;AAE9C,IAAM,YAAY,CAAC,UAAyB;AACjD,SAAO,IAAI,OAAO,KAAK,IAAI,OAAO,GAAS,CAAC;AAC9C;AAEO,IAAM,cAAc,CAAC,UAAyB;AACnD,SAAO,SAAS,OAAO,KAAK,IAAI,OAAO,GAAS,CAAC;AACnD;;;ACZA,SAAS,0BAA0B;AAEnC,SAAS,mBAAmB,gBAAgB;AAE5C,SAAS,iBAAiB,oBAAoB;;;ACJ9C,SAAS,uBAAuB;AAEhC,SAAS,6BAA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,SAAS,yBAAAE,8BAA6B;AAE/B,IAAM,sBAAsB;AAmB5B,IAAM,kBAAkBA,uBAAqC,mBAAmB;;;ACpBvF,SAAS,yBAAAC,8BAA6B;AAE/B,IAAM,mCAAmC;AAYzC,IAAM,+BAA+BA,uBAAkD,gCAAgC;;;ACf9H,SAAS,yBAAAC,8BAA6B;AAE/B,IAAM,gCAAgC;AAgBtC,IAAM,4BAA4BA,uBAA+C,6BAA6B;;;ACjBrH,SAAS,mBAAAC,wBAAuB;AAEhC,SAAS,yBAAAC,wBAAuB,iBAAAC,sBAAqB;AAiB9C,IAAM,kCAAkC;AAWxC,IAAM,8BAA8B,CAAkC,YAA+D;AAC1I,SAAOD,uBAAoD,+BAA+B,EAAE,OAAO;AACrG;AACO,IAAM,8BAA8BD,iBAAgB,OAA6C,2BAA2B;AAE5H,IAAM,6CACX,CAAkC,UAClC,4BAA+B,KAAK,KAAKE,eAAc,KAAK;AAEvD,IAAM,6CACXF,iBAAgB,OAAmD,0CAA0C;AAExG,IAAM,qDACXA,iBAAgB,eAA2D,0CAA0C;","names":["AsObjectFactory","isPayloadOfSchemaType","AsObjectFactory","isPayloadOfSchemaType","AsObjectFactory","AsObjectFactory","isBoundWitness","isStorageMeta","AsObjectFactory","isPayloadOfSchemaType","isPayloadOfSchemaType","isPayloadOfSchemaType","isPayloadOfSchemaType","AsObjectFactory","isPayloadOfSchemaType","isStorageMeta"]}
|
|
1
|
+
{"version":3,"sources":["../../src/xl1/XL1.ts","../../src/block/AllowedBlockPayload.ts","../../src/payload/elevatable/ChainStakeIntent.ts","../../src/payload/elevatable/Executable.ts","../../src/payload/elevatable/Hash.ts","../../src/payload/elevatable/TransferPayload.ts","../../src/transaction/TransactionBoundWitness.ts","../../src/transaction/TransactionFeesFields.ts","../../src/block/BlockBoundWitness.ts","../../src/constants/StepSizes.ts","../../src/constants/TransactionGasCosts.ts","../../src/fields/BlockNumber.ts","../../src/network/Status.ts","../../src/services/Chain/ChainIdentification.ts","../../src/services/Chain/ChainInformation.ts","../../src/services/stakeIntent/ChainIndexingServiceStateSchema.ts"],"sourcesContent":["export type XL1 = bigint & { readonly _tag: 'XL1' } // 1e-18\nexport type MilliXL1 = bigint & { readonly _tag: 'MilliXL1' } // 1e-15 [XL1 * 1e3 = milliXL1] [milliXL1 / 1e3 = XL1]\nexport type MicroXL1 = bigint & { readonly _tag: 'MicroXL1' } // 1e-12 [XL1 * 1e6 = microXL1] [microXL1 / 1e6 = XL1]\nexport type NanoXL1 = bigint & { readonly _tag: 'NanoXL1' } // 1e-9 [XL1 * 1e9 = nanoXL1] [nanoXL1 / 1e9 = XL1]\nexport type PicoXL1 = bigint & { readonly _tag: 'PicoXL1' } // 1e-6 [XL1 * 1e12 = picoXL1] [picoXL1 / 1e12 = XL1]\nexport type FemtoXL1 = bigint & { readonly _tag: 'FemtoXL1' } // 1e-3 [XL1 * 1e15 = femtoXL1] [femtoXL1 / 1e15 = XL1]\nexport type AttoXL1 = bigint & { readonly _tag: 'AttoXL1' } // 1e-0 [XL1 * 1e18 = attoXL1] [attoXL1 / 1e18 = XL1]\n\nexport const XL1: TypingFunc<XL1> = (value: bigint): XL1 => value as XL1\nexport const MilliXL1: TypingFunc<MilliXL1> = (value: bigint): MilliXL1 => value as MilliXL1\nexport const MicroXL1: TypingFunc<MicroXL1> = (value: bigint): MicroXL1 => value as MicroXL1\nexport const NanoXL1: TypingFunc<NanoXL1> = (value: bigint): NanoXL1 => value as NanoXL1\nexport const PicoXL1: TypingFunc<PicoXL1> = (value: bigint): PicoXL1 => value as PicoXL1\nexport const FemtoXL1: TypingFunc<FemtoXL1> = (value: bigint): FemtoXL1 => value as FemtoXL1\nexport const AttoXL1: TypingFunc<AttoXL1> = (value: bigint): AttoXL1 => value as AttoXL1\n\nexport const XL1ConvertDict: Record<string, number> = {\n milli: 3,\n micro: 6,\n nano: 9,\n pico: 12,\n femto: 15,\n atto: 18,\n}\n\nexport type TypingFunc<T extends bigint> = (value: bigint) => T\n\nexport function toXL1<T extends bigint>(value: T, factor: number): XL1 {\n return XL1(value / (10n ** BigInt(factor)))\n}\n\nexport function fromXL1<T extends bigint>(value: XL1, factor: number, typingFunc: TypingFunc<T>): T {\n return typingFunc(value * (10n ** BigInt(factor)))\n}\n\n// milli\nexport const milliXL1ToXL1 = (value: MilliXL1): XL1 => {\n return toXL1(value, XL1ConvertDict.milli)\n}\n\nexport const milliXL1FromXL1 = (value: XL1): MilliXL1 => {\n return fromXL1(value, XL1ConvertDict.micro, MilliXL1)\n}\n\n// micro\nexport const microXL1ToXL1 = (value: MicroXL1): XL1 => {\n return toXL1(value, XL1ConvertDict.micro)\n}\n\nexport const microXL1FromXL1 = (value: XL1): MicroXL1 => {\n return fromXL1(value, XL1ConvertDict.micro, MicroXL1)\n}\n\n// nano\nexport const nanoXL1ToXL1 = (value: NanoXL1): XL1 => {\n return toXL1(value, XL1ConvertDict.nano)\n}\n\nexport const nanoXL1FromXL1 = (value: XL1): NanoXL1 => {\n return fromXL1(value, XL1ConvertDict.nano, NanoXL1)\n}\n\n// pico\nexport const picoXL1ToXL1 = (value: PicoXL1): XL1 => {\n return toXL1(value, XL1ConvertDict.pico)\n}\n\nexport const picoXL1FromXL1 = (value: XL1): PicoXL1 => {\n return fromXL1(value, XL1ConvertDict.pico, PicoXL1)\n}\n\n// femto\nexport const femtoXL1ToXL1 = (value: FemtoXL1): XL1 => {\n return toXL1(value, XL1ConvertDict.femto)\n}\n\nexport const femtoXL1FromXL1 = (value: XL1): FemtoXL1 => {\n return fromXL1(value, XL1ConvertDict.femto, FemtoXL1)\n}\n\n// atto\nexport const attoXL1ToXL1 = (value: AttoXL1): XL1 => {\n return toXL1(value, XL1ConvertDict.atto)\n}\n\nexport const attoXL1FromXL1 = (value: XL1): AttoXL1 => {\n return fromXL1(value, XL1ConvertDict.atto, AttoXL1)\n}\n","import { BoundWitnessSchema } from '@xyo-network/boundwitness-model'\nimport type { Schema, WithStorageMeta } from '@xyo-network/payload-model'\nimport { isHashStorageMeta, isSchema } from '@xyo-network/payload-model'\nimport type { SchemaPayload } from '@xyo-network/schema-payload-plugin'\nimport { isSchemaPayload, SchemaSchema } from '@xyo-network/schema-payload-plugin'\n\nimport type {\n ChainStakeIntent, HashPayload, Transfer,\n} from '#payload'\nimport {\n ChainStakeIntentSchema, HashSchema, isChainStakeIntent, isHashPayload, isTransfer, TransferSchema,\n} from '#payload'\nimport { isTransactionBoundWitness, type TransactionBoundWitness } from '#transaction'\n\nexport type AllowedBlockPayload = Transfer | ChainStakeIntent | SchemaPayload | TransactionBoundWitness | HashPayload\nexport const AllowedBlockPayloadSchemas: Schema[] = [TransferSchema, ChainStakeIntentSchema, SchemaSchema, BoundWitnessSchema, HashSchema]\nexport type AllowedBlockPayloadSchema = typeof AllowedBlockPayloadSchemas[number]\n\nexport const isAllowedBlockPayloadSchema = (value: unknown): value is AllowedBlockPayloadSchema => {\n return isSchema(value) && AllowedBlockPayloadSchemas.includes(value)\n}\n\nexport const isAllowedBlockPayload = (value: unknown): value is AllowedBlockPayload => {\n return isTransfer(value) || isChainStakeIntent(value) || isSchemaPayload(value) || isTransactionBoundWitness(value) || isHashPayload(value)\n}\n\nexport const isAllowedBlockPayloadWithHashStorageMeta = (value: unknown): value is WithStorageMeta<AllowedBlockPayload> => {\n return isAllowedBlockPayload(value) && isHashStorageMeta(value)\n}\n","import { AsObjectFactory } from '@xylabs/object'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nimport type { BlockDuration } from '#fields'\n\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 { BlockDuration } from '#fields'\nimport type { FromFields, OptionalExecutable } from '#payload'\n\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 { Hex } from '@xylabs/hex'\n\nimport { MicroXL1 } from '../xl1/XL1.ts'\n\nexport interface TransactionFeesBigInt {\n base: MicroXL1\n gasLimit: MicroXL1\n gasPrice: MicroXL1\n priority: MicroXL1\n}\n\nexport type TransactionFeesHex = {\n [K in keyof TransactionFeesBigInt]: Hex;\n}\n\nexport interface TransactionFeesFields {\n fees: TransactionFeesHex\n}\n\nexport const minTransactionFees: TransactionFeesBigInt = {\n base: MicroXL1(1000n), gasPrice: MicroXL1(1n), gasLimit: MicroXL1(1000n), priority: MicroXL1(0n),\n} as const\n\nexport const defaultTransactionFees: TransactionFeesBigInt = {\n base: minTransactionFees.base, gasPrice: MicroXL1(10n), gasLimit: MicroXL1(1_000_000n), priority: MicroXL1(0n),\n} as const\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","export const StepSizes = [10, 105, 1103, 11_576, 121_551, 1_276_282, 13_400_956] as const\n","import { MicroXL1 } from '../xl1/XL1.ts'\n\nexport const TransactionGasCosts = {\n /**\n * The cost of storing each character that is added to the chain\n * This includes the transaction JSON and all the elevated payloads' JSON\n */\n characterStorage: MicroXL1(10n),\n\n /** The cost of static validating every payload that will be included in the chain */\n payloadValidation: MicroXL1(1000n),\n\n /** The cost of validating each signature that will be included in the chain */\n signatureValidation: MicroXL1(1000n),\n\n /** The cost of validating each hash that will be included in the chain */\n hashValidation: MicroXL1(100n),\n\n /** The cost of validating a balance state, triggered by a Transfer payload or gas collection */\n balanceValidation: MicroXL1(100n),\n} as const\n\n/** Gas Calculation\n *\n * 1 Million microXL1 (mXL1) = 1 XL1\n *\n * Gas amount is calculated as follows:\n *\n * 1. Each byte in the transaction cost 10 gas\n * 2. Each payload validation in the transaction costs 1000 gas\n * 3. Each signature verification in the transaction costs 1000 gas\n * 4. Each hash validation in the transaction costs 100 gas\n * 5. Each balance validation in the transaction costs 100 gas\n * 6. Processing/Compute/Storage Cost?\n * 7. operation Costs?\n *\n * The total gas cost is calculated by multiplying the gas amount by the gas price.\n *\n * minGasPrice is initially set to 100 mXL1\n * minBase is initially set to 1000 mXL1\n * minPriority is always 0 mXL1, but can be set to increase the priority of the transaction\n *\n */\n","import type { Hex } from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { Payload, WithSources } from '@xyo-network/payload-model'\nimport {\n isPayloadOfSchemaType,\n isPayloadOfSchemaTypeWithSources,\n} from '@xyo-network/payload-model'\n\nexport const BlockNumberSchema = 'network.xyo.chain.block.number' as const\nexport type BlockNumberSchema = typeof BlockNumberSchema\n\nexport interface BlockNumberFields {\n /**\n * The block number\n */\n block: Hex\n /**\n * The chain id\n */\n chain?: Hex\n}\n/**\n * The number of a block\n */\nexport type BlockNumber = Payload<BlockNumberFields, BlockNumberSchema>\n\n/**\n * Identity function for determining if an object is a BlockNumber\n */\nexport const isBlockNumber = isPayloadOfSchemaType<BlockNumber>(BlockNumberSchema)\nexport const asBlockNumber = AsObjectFactory.create<BlockNumber>(isBlockNumber)\nexport const asOptionalBlockNumber = AsObjectFactory.createOptional<BlockNumber>(isBlockNumber)\n\n/**\n * Identity function for determining if an object is a BlockNumber with sources\n */\nexport const isBlockNumberWithSources = isPayloadOfSchemaTypeWithSources<BlockNumber>(BlockNumberSchema)\nexport const asBlockNumberWithSources = AsObjectFactory.create<WithSources<BlockNumber>>(isBlockNumberWithSources)\nexport const asOptionalBlockNumberWithSources = AsObjectFactory.createOptional<WithSources<BlockNumber>>(isBlockNumberWithSources)\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"],"mappings":";AAQO,IAAM,MAAuB,CAAC,UAAuB;AACrD,IAAM,WAAiC,CAAC,UAA4B;AACpE,IAAM,WAAiC,CAAC,U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OACK;AAEA,IAAM,oBAAoB;AAqB1B,IAAM,gBAAgBA,uBAAmC,iBAAiB;AAC1E,IAAM,gBAAgBD,iBAAgB,OAAoB,aAAa;AACvE,IAAM,wBAAwBA,iBAAgB,eAA4B,aAAa;AAKvF,IAAM,2BAA2B,iCAA8C,iBAAiB;AAChG,IAAM,2BAA2BA,iBAAgB,OAAiC,wBAAwB;AAC1G,IAAM,mCAAmCA,iBAAgB,eAAyC,wBAAwB;;;ACrCjI,SAAS,yBAAAE,8BAA6B;AAE/B,IAAM,sBAAsB;AAmB5B,IAAM,kBAAkBA,uBAAqC,mBAAmB;;;ACpBvF,SAAS,yBAAAC,8BAA6B;AAE/B,IAAM,mCAAmC;AAYzC,IAAM,+BAA+BA,uBAAkD,gCAAgC;;;ACf9H,SAAS,yBAAAC,8BAA6B;AAE/B,IAAM,gCAAgC;AAgBtC,IAAM,4BAA4BA,uBAA+C,6BAA6B;;;ACjBrH,SAAS,mBAAAC,wBAAuB;AAEhC,SAAS,yBAAAC,wBAAuB,iBAAAC,sBAAqB;AAiB9C,IAAM,kCAAkC;AAWxC,IAAM,8BAA8B,CAAkC,YAA+D;AAC1I,SAAOD,uBAAoD,+BAA+B,EAAE,OAAO;AACrG;AACO,IAAM,8BAA8BD,iBAAgB,OAA6C,2BAA2B;AAE5H,IAAM,6CACX,CAAkC,UAClC,4BAA+B,KAAK,KAAKE,eAAc,KAAK;AAEvD,IAAM,6CACXF,iBAAgB,OAAmD,0CAA0C;AAExG,IAAM,qDACXA,iBAAgB,eAA2D,0CAA0C;","names":["AsObjectFactory","isPayloadOfSchemaType","AsObjectFactory","isPayloadOfSchemaType","AsObjectFactory","AsObjectFactory","isBoundWitness","isStorageMeta","AsObjectFactory","isPayloadOfSchemaType","isPayloadOfSchemaType","isPayloadOfSchemaType","isPayloadOfSchemaType","AsObjectFactory","isPayloadOfSchemaType","isStorageMeta"]}
|
package/dist/node/index.mjs
CHANGED
|
@@ -1,11 +1,60 @@
|
|
|
1
|
-
// src/XL1.ts
|
|
1
|
+
// src/xl1/XL1.ts
|
|
2
2
|
var XL1 = (value) => value;
|
|
3
|
+
var MilliXL1 = (value) => value;
|
|
3
4
|
var MicroXL1 = (value) => value;
|
|
4
|
-
var
|
|
5
|
-
|
|
5
|
+
var NanoXL1 = (value) => value;
|
|
6
|
+
var PicoXL1 = (value) => value;
|
|
7
|
+
var FemtoXL1 = (value) => value;
|
|
8
|
+
var AttoXL1 = (value) => value;
|
|
9
|
+
var XL1ConvertDict = {
|
|
10
|
+
milli: 3,
|
|
11
|
+
micro: 6,
|
|
12
|
+
nano: 9,
|
|
13
|
+
pico: 12,
|
|
14
|
+
femto: 15,
|
|
15
|
+
atto: 18
|
|
6
16
|
};
|
|
7
|
-
|
|
8
|
-
return
|
|
17
|
+
function toXL1(value, factor) {
|
|
18
|
+
return XL1(value / 10n ** BigInt(factor));
|
|
19
|
+
}
|
|
20
|
+
function fromXL1(value, factor, typingFunc) {
|
|
21
|
+
return typingFunc(value * 10n ** BigInt(factor));
|
|
22
|
+
}
|
|
23
|
+
var milliXL1ToXL1 = (value) => {
|
|
24
|
+
return toXL1(value, XL1ConvertDict.milli);
|
|
25
|
+
};
|
|
26
|
+
var milliXL1FromXL1 = (value) => {
|
|
27
|
+
return fromXL1(value, XL1ConvertDict.micro, MilliXL1);
|
|
28
|
+
};
|
|
29
|
+
var microXL1ToXL1 = (value) => {
|
|
30
|
+
return toXL1(value, XL1ConvertDict.micro);
|
|
31
|
+
};
|
|
32
|
+
var microXL1FromXL1 = (value) => {
|
|
33
|
+
return fromXL1(value, XL1ConvertDict.micro, MicroXL1);
|
|
34
|
+
};
|
|
35
|
+
var nanoXL1ToXL1 = (value) => {
|
|
36
|
+
return toXL1(value, XL1ConvertDict.nano);
|
|
37
|
+
};
|
|
38
|
+
var nanoXL1FromXL1 = (value) => {
|
|
39
|
+
return fromXL1(value, XL1ConvertDict.nano, NanoXL1);
|
|
40
|
+
};
|
|
41
|
+
var picoXL1ToXL1 = (value) => {
|
|
42
|
+
return toXL1(value, XL1ConvertDict.pico);
|
|
43
|
+
};
|
|
44
|
+
var picoXL1FromXL1 = (value) => {
|
|
45
|
+
return fromXL1(value, XL1ConvertDict.pico, PicoXL1);
|
|
46
|
+
};
|
|
47
|
+
var femtoXL1ToXL1 = (value) => {
|
|
48
|
+
return toXL1(value, XL1ConvertDict.femto);
|
|
49
|
+
};
|
|
50
|
+
var femtoXL1FromXL1 = (value) => {
|
|
51
|
+
return fromXL1(value, XL1ConvertDict.femto, FemtoXL1);
|
|
52
|
+
};
|
|
53
|
+
var attoXL1ToXL1 = (value) => {
|
|
54
|
+
return toXL1(value, XL1ConvertDict.atto);
|
|
55
|
+
};
|
|
56
|
+
var attoXL1FromXL1 = (value) => {
|
|
57
|
+
return fromXL1(value, XL1ConvertDict.atto, AttoXL1);
|
|
9
58
|
};
|
|
10
59
|
|
|
11
60
|
// src/block/AllowedBlockPayload.ts
|
|
@@ -179,18 +228,24 @@ var asChainIndexingServiceStateWithStorageMeta = AsObjectFactory7.create(isChain
|
|
|
179
228
|
var asOptionalChainIndexingServiceStateWithStorageMeta = AsObjectFactory7.createOptional(isChainIndexingServiceStateWithStorageMeta);
|
|
180
229
|
export {
|
|
181
230
|
AllowedBlockPayloadSchemas,
|
|
231
|
+
AttoXL1,
|
|
182
232
|
BlockNumberSchema,
|
|
183
233
|
ChainIdentificationPayloadSchema,
|
|
184
234
|
ChainIndexingServiceStateSchema,
|
|
185
235
|
ChainInformationPayloadSchema,
|
|
186
236
|
ChainStakeIntentSchema,
|
|
237
|
+
FemtoXL1,
|
|
187
238
|
HashSchema,
|
|
188
239
|
MicroXL1,
|
|
240
|
+
MilliXL1,
|
|
241
|
+
NanoXL1,
|
|
189
242
|
NetworkStatusSchema,
|
|
243
|
+
PicoXL1,
|
|
190
244
|
StepSizes,
|
|
191
245
|
TransactionGasCosts,
|
|
192
246
|
TransferSchema,
|
|
193
247
|
XL1,
|
|
248
|
+
XL1ConvertDict,
|
|
194
249
|
asBlockBoundWitness,
|
|
195
250
|
asBlockBoundWitnessWithStorageMeta,
|
|
196
251
|
asBlockNumber,
|
|
@@ -214,7 +269,12 @@ export {
|
|
|
214
269
|
asTransactionBoundWitness,
|
|
215
270
|
asTransactionBoundWitnessWithStorageMeta,
|
|
216
271
|
asTransfer,
|
|
272
|
+
attoXL1FromXL1,
|
|
273
|
+
attoXL1ToXL1,
|
|
217
274
|
defaultTransactionFees,
|
|
275
|
+
femtoXL1FromXL1,
|
|
276
|
+
femtoXL1ToXL1,
|
|
277
|
+
fromXL1,
|
|
218
278
|
hasFrom,
|
|
219
279
|
isAllowedBlockPayload,
|
|
220
280
|
isAllowedBlockPayloadSchema,
|
|
@@ -237,8 +297,15 @@ export {
|
|
|
237
297
|
isTransactionBoundWitness,
|
|
238
298
|
isTransactionBoundWitnessWithStorageMeta,
|
|
239
299
|
isTransfer,
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
300
|
+
microXL1FromXL1,
|
|
301
|
+
microXL1ToXL1,
|
|
302
|
+
milliXL1FromXL1,
|
|
303
|
+
milliXL1ToXL1,
|
|
304
|
+
minTransactionFees,
|
|
305
|
+
nanoXL1FromXL1,
|
|
306
|
+
nanoXL1ToXL1,
|
|
307
|
+
picoXL1FromXL1,
|
|
308
|
+
picoXL1ToXL1,
|
|
309
|
+
toXL1
|
|
243
310
|
};
|
|
244
311
|
//# sourceMappingURL=index.mjs.map
|
package/dist/node/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/XL1.ts","../../src/block/AllowedBlockPayload.ts","../../src/payload/elevatable/ChainStakeIntent.ts","../../src/payload/elevatable/Executable.ts","../../src/payload/elevatable/Hash.ts","../../src/payload/elevatable/TransferPayload.ts","../../src/transaction/TransactionBoundWitness.ts","../../src/transaction/TransactionFeesFields.ts","../../src/block/BlockBoundWitness.ts","../../src/constants/StepSizes.ts","../../src/constants/TransactionGasCosts.ts","../../src/fields/BlockNumber.ts","../../src/network/Status.ts","../../src/services/Chain/ChainIdentification.ts","../../src/services/Chain/ChainInformation.ts","../../src/services/stakeIntent/ChainIndexingServiceStateSchema.ts"],"sourcesContent":["export type XL1 = bigint & { readonly _tag: 'XL1' } // 1e-18\nexport type MicroXL1 = bigint & { readonly _tag: 'MicroXL1' } // 1e-24\n\nexport const XL1 = (value: bigint): XL1 => value as XL1\nexport const MicroXL1 = (value: bigint): MicroXL1 => value as MicroXL1\n\nexport const mXL1ToXL1 = (value: MicroXL1): XL1 => {\n return XL1(BigInt(value) / BigInt(1_000_000))\n}\n\nexport const mXL1FromXL1 = (value: XL1): MicroXL1 => {\n return MicroXL1(BigInt(value) * BigInt(1_000_000))\n}\n","import { BoundWitnessSchema } from '@xyo-network/boundwitness-model'\nimport type { Schema, WithStorageMeta } from '@xyo-network/payload-model'\nimport { isHashStorageMeta, isSchema } from '@xyo-network/payload-model'\nimport type { SchemaPayload } from '@xyo-network/schema-payload-plugin'\nimport { isSchemaPayload, SchemaSchema } from '@xyo-network/schema-payload-plugin'\n\nimport type {\n ChainStakeIntent, HashPayload, Transfer,\n} from '#payload'\nimport {\n ChainStakeIntentSchema, HashSchema, isChainStakeIntent, isHashPayload, isTransfer, TransferSchema,\n} from '#payload'\nimport { isTransactionBoundWitness, type TransactionBoundWitness } from '#transaction'\n\nexport type AllowedBlockPayload = Transfer | ChainStakeIntent | SchemaPayload | TransactionBoundWitness | HashPayload\nexport const AllowedBlockPayloadSchemas: Schema[] = [TransferSchema, ChainStakeIntentSchema, SchemaSchema, BoundWitnessSchema, HashSchema]\nexport type AllowedBlockPayloadSchema = typeof AllowedBlockPayloadSchemas[number]\n\nexport const isAllowedBlockPayloadSchema = (value: unknown): value is AllowedBlockPayloadSchema => {\n return isSchema(value) && AllowedBlockPayloadSchemas.includes(value)\n}\n\nexport const isAllowedBlockPayload = (value: unknown): value is AllowedBlockPayload => {\n return isTransfer(value) || isChainStakeIntent(value) || isSchemaPayload(value) || isTransactionBoundWitness(value) || isHashPayload(value)\n}\n\nexport const isAllowedBlockPayloadWithHashStorageMeta = (value: unknown): value is WithStorageMeta<AllowedBlockPayload> => {\n return isAllowedBlockPayload(value) && isHashStorageMeta(value)\n}\n","import { AsObjectFactory } from '@xylabs/object'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nimport type { BlockDuration } from '#fields'\n\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 { BlockDuration } from '#fields'\nimport type { FromFields, OptionalExecutable } from '#payload'\n\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 { Hex } from '@xylabs/hex'\n\nimport { MicroXL1 } from '../XL1.ts'\n\nexport interface TransactionFeesBigInt {\n base: MicroXL1\n gasLimit: MicroXL1\n gasPrice: MicroXL1\n priority: MicroXL1\n}\n\nexport type TransactionFeesHex = {\n [K in keyof TransactionFeesBigInt]: Hex;\n}\n\nexport interface TransactionFeesFields {\n fees: TransactionFeesHex\n}\n\nexport const minTransactionFees: TransactionFeesBigInt = {\n base: MicroXL1(1000n), gasPrice: MicroXL1(1n), gasLimit: MicroXL1(1000n), priority: MicroXL1(0n),\n} as const\n\nexport const defaultTransactionFees: TransactionFeesBigInt = {\n base: minTransactionFees.base, gasPrice: MicroXL1(10n), gasLimit: MicroXL1(1_000_000n), priority: MicroXL1(0n),\n} as const\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","export const StepSizes = [10, 105, 1103, 11_576, 121_551, 1_276_282, 13_400_956] as const\n","import { MicroXL1 } from '../XL1.ts'\n\nexport const TransactionGasCosts = {\n /**\n * The cost of storing each character that is added to the chain\n * This includes the transaction JSON and all the elevated payloads' JSON\n */\n characterStorage: MicroXL1(10n),\n\n /** The cost of static validating every payload that will be included in the chain */\n payloadValidation: MicroXL1(1000n),\n\n /** The cost of validating each signature that will be included in the chain */\n signatureValidation: MicroXL1(1000n),\n\n /** The cost of validating each hash that will be included in the chain */\n hashValidation: MicroXL1(100n),\n\n /** The cost of validating a balance state, triggered by a Transfer payload or gas collection */\n balanceValidation: MicroXL1(100n),\n} as const\n\n/** Gas Calculation\n *\n * 1 Million microXL1 (mXL1) = 1 XL1\n *\n * Gas amount is calculated as follows:\n *\n * 1. Each byte in the transaction cost 10 gas\n * 2. Each payload validation in the transaction costs 1000 gas\n * 3. Each signature verification in the transaction costs 1000 gas\n * 4. Each hash validation in the transaction costs 100 gas\n * 5. Each balance validation in the transaction costs 100 gas\n * 6. Processing/Compute/Storage Cost?\n * 7. operation Costs?\n *\n * The total gas cost is calculated by multiplying the gas amount by the gas price.\n *\n * minGasPrice is initially set to 100 mXL1\n * minBase is initially set to 1000 mXL1\n * minPriority is always 0 mXL1, but can be set to increase the priority of the transaction\n *\n */\n","import type { Hex } from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { Payload, WithSources } from '@xyo-network/payload-model'\nimport {\n isPayloadOfSchemaType,\n isPayloadOfSchemaTypeWithSources,\n} from '@xyo-network/payload-model'\n\nexport const BlockNumberSchema = 'network.xyo.chain.block.number' as const\nexport type BlockNumberSchema = typeof BlockNumberSchema\n\nexport interface BlockNumberFields {\n /**\n * The block number\n */\n block: Hex\n /**\n * The chain id\n */\n chain?: Hex\n}\n/**\n * The number of a block\n */\nexport type BlockNumber = Payload<BlockNumberFields, BlockNumberSchema>\n\n/**\n * Identity function for determining if an object is a BlockNumber\n */\nexport const isBlockNumber = isPayloadOfSchemaType<BlockNumber>(BlockNumberSchema)\nexport const asBlockNumber = AsObjectFactory.create<BlockNumber>(isBlockNumber)\nexport const asOptionalBlockNumber = AsObjectFactory.createOptional<BlockNumber>(isBlockNumber)\n\n/**\n * Identity function for determining if an object is a BlockNumber with sources\n */\nexport const isBlockNumberWithSources = isPayloadOfSchemaTypeWithSources<BlockNumber>(BlockNumberSchema)\nexport const asBlockNumberWithSources = AsObjectFactory.create<WithSources<BlockNumber>>(isBlockNumberWithSources)\nexport const asOptionalBlockNumberWithSources = AsObjectFactory.createOptional<WithSources<BlockNumber>>(isBlockNumberWithSources)\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"],"mappings":";AAGO,IAAM,MAAM,CAAC,UAAuB;AACpC,IAAM,WAAW,CAAC,UAA4B;AAE9C,IAAM,YAAY,CAAC,UAAyB;AACjD,SAAO,IAAI,OAAO,KAAK,IAAI,OAAO,GAAS,CAAC;AAC9C;AAEO,IAAM,cAAc,CAAC,UAAyB;AACnD,SAAO,SAAS,OAAO,KAAK,IAAI,OAAO,GAAS,CAAC;AACnD;;;ACZA,SAAS,0BAA0B;AAEnC,SAAS,mBAAmB,gBAAgB;AAE5C,SAAS,iBAAiB,oBAAoB;;;ACJ9C,SAAS,uBAAuB;AAEhC,SAAS,6BAA6B;AAM/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;;;AC9BA,SAAS,oBAAoB;AAOtB,IAAM,UAAU,CAAC,UAAwC;AAC9D,SAA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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;","names":["AsObjectFactory","isPayloadOfSchemaType","AsObjectFactory","isPayloadOfSchemaType","AsObjectFactory","AsObjectFactory","isBoundWitness","isStorageMeta","AsObjectFactory","isPayloadOfSchemaType","isPayloadOfSchemaType","isPayloadOfSchemaType","isPayloadOfSchemaType","AsObjectFactory","isPayloadOfSchemaType","isStorageMeta"]}
|
|
1
|
+
{"version":3,"sources":["../../src/xl1/XL1.ts","../../src/block/AllowedBlockPayload.ts","../../src/payload/elevatable/ChainStakeIntent.ts","../../src/payload/elevatable/Executable.ts","../../src/payload/elevatable/Hash.ts","../../src/payload/elevatable/TransferPayload.ts","../../src/transaction/TransactionBoundWitness.ts","../../src/transaction/TransactionFeesFields.ts","../../src/block/BlockBoundWitness.ts","../../src/constants/StepSizes.ts","../../src/constants/TransactionGasCosts.ts","../../src/fields/BlockNumber.ts","../../src/network/Status.ts","../../src/services/Chain/ChainIdentification.ts","../../src/services/Chain/ChainInformation.ts","../../src/services/stakeIntent/ChainIndexingServiceStateSchema.ts"],"sourcesContent":["export type XL1 = bigint & { readonly _tag: 'XL1' } // 1e-18\nexport type MilliXL1 = bigint & { readonly _tag: 'MilliXL1' } // 1e-15 [XL1 * 1e3 = milliXL1] [milliXL1 / 1e3 = XL1]\nexport type MicroXL1 = bigint & { readonly _tag: 'MicroXL1' } // 1e-12 [XL1 * 1e6 = microXL1] [microXL1 / 1e6 = XL1]\nexport type NanoXL1 = bigint & { readonly _tag: 'NanoXL1' } // 1e-9 [XL1 * 1e9 = nanoXL1] [nanoXL1 / 1e9 = XL1]\nexport type PicoXL1 = bigint & { readonly _tag: 'PicoXL1' } // 1e-6 [XL1 * 1e12 = picoXL1] [picoXL1 / 1e12 = XL1]\nexport type FemtoXL1 = bigint & { readonly _tag: 'FemtoXL1' } // 1e-3 [XL1 * 1e15 = femtoXL1] [femtoXL1 / 1e15 = XL1]\nexport type AttoXL1 = bigint & { readonly _tag: 'AttoXL1' } // 1e-0 [XL1 * 1e18 = attoXL1] [attoXL1 / 1e18 = XL1]\n\nexport const XL1: TypingFunc<XL1> = (value: bigint): XL1 => value as XL1\nexport const MilliXL1: TypingFunc<MilliXL1> = (value: bigint): MilliXL1 => value as MilliXL1\nexport const MicroXL1: TypingFunc<MicroXL1> = (value: bigint): MicroXL1 => value as MicroXL1\nexport const NanoXL1: TypingFunc<NanoXL1> = (value: bigint): NanoXL1 => value as NanoXL1\nexport const PicoXL1: TypingFunc<PicoXL1> = (value: bigint): PicoXL1 => value as PicoXL1\nexport const FemtoXL1: TypingFunc<FemtoXL1> = (value: bigint): FemtoXL1 => value as FemtoXL1\nexport const AttoXL1: TypingFunc<AttoXL1> = (value: bigint): AttoXL1 => value as AttoXL1\n\nexport const XL1ConvertDict: Record<string, number> = {\n milli: 3,\n micro: 6,\n nano: 9,\n pico: 12,\n femto: 15,\n atto: 18,\n}\n\nexport type TypingFunc<T extends bigint> = (value: bigint) => T\n\nexport function toXL1<T extends bigint>(value: T, factor: number): XL1 {\n return XL1(value / (10n ** BigInt(factor)))\n}\n\nexport function fromXL1<T extends bigint>(value: XL1, factor: number, typingFunc: TypingFunc<T>): T {\n return typingFunc(value * (10n ** BigInt(factor)))\n}\n\n// milli\nexport const milliXL1ToXL1 = (value: MilliXL1): XL1 => {\n return toXL1(value, XL1ConvertDict.milli)\n}\n\nexport const milliXL1FromXL1 = (value: XL1): MilliXL1 => {\n return fromXL1(value, XL1ConvertDict.micro, MilliXL1)\n}\n\n// micro\nexport const microXL1ToXL1 = (value: MicroXL1): XL1 => {\n return toXL1(value, XL1ConvertDict.micro)\n}\n\nexport const microXL1FromXL1 = (value: XL1): MicroXL1 => {\n return fromXL1(value, XL1ConvertDict.micro, MicroXL1)\n}\n\n// nano\nexport const nanoXL1ToXL1 = (value: NanoXL1): XL1 => {\n return toXL1(value, XL1ConvertDict.nano)\n}\n\nexport const nanoXL1FromXL1 = (value: XL1): NanoXL1 => {\n return fromXL1(value, XL1ConvertDict.nano, NanoXL1)\n}\n\n// pico\nexport const picoXL1ToXL1 = (value: PicoXL1): XL1 => {\n return toXL1(value, XL1ConvertDict.pico)\n}\n\nexport const picoXL1FromXL1 = (value: XL1): PicoXL1 => {\n return fromXL1(value, XL1ConvertDict.pico, PicoXL1)\n}\n\n// femto\nexport const femtoXL1ToXL1 = (value: FemtoXL1): XL1 => {\n return toXL1(value, XL1ConvertDict.femto)\n}\n\nexport const femtoXL1FromXL1 = (value: XL1): FemtoXL1 => {\n return fromXL1(value, XL1ConvertDict.femto, FemtoXL1)\n}\n\n// atto\nexport const attoXL1ToXL1 = (value: AttoXL1): XL1 => {\n return toXL1(value, XL1ConvertDict.atto)\n}\n\nexport const attoXL1FromXL1 = (value: XL1): AttoXL1 => {\n return fromXL1(value, XL1ConvertDict.atto, AttoXL1)\n}\n","import { BoundWitnessSchema } from '@xyo-network/boundwitness-model'\nimport type { Schema, WithStorageMeta } from '@xyo-network/payload-model'\nimport { isHashStorageMeta, isSchema } from '@xyo-network/payload-model'\nimport type { SchemaPayload } from '@xyo-network/schema-payload-plugin'\nimport { isSchemaPayload, SchemaSchema } from '@xyo-network/schema-payload-plugin'\n\nimport type {\n ChainStakeIntent, HashPayload, Transfer,\n} from '#payload'\nimport {\n ChainStakeIntentSchema, HashSchema, isChainStakeIntent, isHashPayload, isTransfer, TransferSchema,\n} from '#payload'\nimport { isTransactionBoundWitness, type TransactionBoundWitness } from '#transaction'\n\nexport type AllowedBlockPayload = Transfer | ChainStakeIntent | SchemaPayload | TransactionBoundWitness | HashPayload\nexport const AllowedBlockPayloadSchemas: Schema[] = [TransferSchema, ChainStakeIntentSchema, SchemaSchema, BoundWitnessSchema, HashSchema]\nexport type AllowedBlockPayloadSchema = typeof AllowedBlockPayloadSchemas[number]\n\nexport const isAllowedBlockPayloadSchema = (value: unknown): value is AllowedBlockPayloadSchema => {\n return isSchema(value) && AllowedBlockPayloadSchemas.includes(value)\n}\n\nexport const isAllowedBlockPayload = (value: unknown): value is AllowedBlockPayload => {\n return isTransfer(value) || isChainStakeIntent(value) || isSchemaPayload(value) || isTransactionBoundWitness(value) || isHashPayload(value)\n}\n\nexport const isAllowedBlockPayloadWithHashStorageMeta = (value: unknown): value is WithStorageMeta<AllowedBlockPayload> => {\n return isAllowedBlockPayload(value) && isHashStorageMeta(value)\n}\n","import { AsObjectFactory } from '@xylabs/object'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nimport type { BlockDuration } from '#fields'\n\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 { BlockDuration } from '#fields'\nimport type { FromFields, OptionalExecutable } from '#payload'\n\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 { Hex } from '@xylabs/hex'\n\nimport { MicroXL1 } from '../xl1/XL1.ts'\n\nexport interface TransactionFeesBigInt {\n base: MicroXL1\n gasLimit: MicroXL1\n gasPrice: MicroXL1\n priority: MicroXL1\n}\n\nexport type TransactionFeesHex = {\n [K in keyof TransactionFeesBigInt]: Hex;\n}\n\nexport interface TransactionFeesFields {\n fees: TransactionFeesHex\n}\n\nexport const minTransactionFees: TransactionFeesBigInt = {\n base: MicroXL1(1000n), gasPrice: MicroXL1(1n), gasLimit: MicroXL1(1000n), priority: MicroXL1(0n),\n} as const\n\nexport const defaultTransactionFees: TransactionFeesBigInt = {\n base: minTransactionFees.base, gasPrice: MicroXL1(10n), gasLimit: MicroXL1(1_000_000n), priority: MicroXL1(0n),\n} as const\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","export const StepSizes = [10, 105, 1103, 11_576, 121_551, 1_276_282, 13_400_956] as const\n","import { MicroXL1 } from '../xl1/XL1.ts'\n\nexport const TransactionGasCosts = {\n /**\n * The cost of storing each character that is added to the chain\n * This includes the transaction JSON and all the elevated payloads' JSON\n */\n characterStorage: MicroXL1(10n),\n\n /** The cost of static validating every payload that will be included in the chain */\n payloadValidation: MicroXL1(1000n),\n\n /** The cost of validating each signature that will be included in the chain */\n signatureValidation: MicroXL1(1000n),\n\n /** The cost of validating each hash that will be included in the chain */\n hashValidation: MicroXL1(100n),\n\n /** The cost of validating a balance state, triggered by a Transfer payload or gas collection */\n balanceValidation: MicroXL1(100n),\n} as const\n\n/** Gas Calculation\n *\n * 1 Million microXL1 (mXL1) = 1 XL1\n *\n * Gas amount is calculated as follows:\n *\n * 1. Each byte in the transaction cost 10 gas\n * 2. Each payload validation in the transaction costs 1000 gas\n * 3. Each signature verification in the transaction costs 1000 gas\n * 4. Each hash validation in the transaction costs 100 gas\n * 5. Each balance validation in the transaction costs 100 gas\n * 6. Processing/Compute/Storage Cost?\n * 7. operation Costs?\n *\n * The total gas cost is calculated by multiplying the gas amount by the gas price.\n *\n * minGasPrice is initially set to 100 mXL1\n * minBase is initially set to 1000 mXL1\n * minPriority is always 0 mXL1, but can be set to increase the priority of the transaction\n *\n */\n","import type { Hex } from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { Payload, WithSources } from '@xyo-network/payload-model'\nimport {\n isPayloadOfSchemaType,\n isPayloadOfSchemaTypeWithSources,\n} from '@xyo-network/payload-model'\n\nexport const BlockNumberSchema = 'network.xyo.chain.block.number' as const\nexport type BlockNumberSchema = typeof BlockNumberSchema\n\nexport interface BlockNumberFields {\n /**\n * The block number\n */\n block: Hex\n /**\n * The chain id\n */\n chain?: Hex\n}\n/**\n * The number of a block\n */\nexport type BlockNumber = Payload<BlockNumberFields, BlockNumberSchema>\n\n/**\n * Identity function for determining if an object is a BlockNumber\n */\nexport const isBlockNumber = isPayloadOfSchemaType<BlockNumber>(BlockNumberSchema)\nexport const asBlockNumber = AsObjectFactory.create<BlockNumber>(isBlockNumber)\nexport const asOptionalBlockNumber = AsObjectFactory.createOptional<BlockNumber>(isBlockNumber)\n\n/**\n * Identity function for determining if an object is a BlockNumber with sources\n */\nexport const isBlockNumberWithSources = isPayloadOfSchemaTypeWithSources<BlockNumber>(BlockNumberSchema)\nexport const asBlockNumberWithSources = AsObjectFactory.create<WithSources<BlockNumber>>(isBlockNumberWithSources)\nexport const asOptionalBlockNumberWithSources = AsObjectFactory.createOptional<WithSources<BlockNumber>>(isBlockNumberWithSources)\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"],"mappings":";AAQO,IAAM,MAAuB,CAAC,UAAuB;AACrD,IAAM,WAAiC,CAAC,UAA4B;AACpE,IAAM,WAAiC,CAAC,UAA4B;AACpE,IAAM,UAA+B,CAAC,UAA2B;AACjE,IAAM,UAA+B,CAAC,UAA2B;AACjE,IAAM,WAAiC,CAAC,UAA4B;AACpE,IAAM,UAA+B,CAAC,UAA2B;AAEjE,IAAM,iBAAyC;AAAA,EACpD,OAAO;AAAA,EACP,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AACR;AAIO,SAAS,MAAwB,OAAU,QAAqB;AACrE,SAAO,IAAI,QAAS,OAAO,OAAO,MAAM,CAAE;AAC5C;AAEO,SAAS,QAA0B,OAAY,QAAgB,YAA8B;AAClG,SAAO,WAAW,QAAS,OAAO,O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AAM,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;","names":["AsObjectFactory","isPayloadOfSchemaType","AsObjectFactory","isPayloadOfSchemaType","AsObjectFactory","AsObjectFactory","isBoundWitness","isStorageMeta","AsObjectFactory","isPayloadOfSchemaType","isPayloadOfSchemaType","isPayloadOfSchemaType","isPayloadOfSchemaType","AsObjectFactory","isPayloadOfSchemaType","isStorageMeta"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionGasCosts.d.ts","sourceRoot":"","sources":["../../../src/constants/TransactionGasCosts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"TransactionGasCosts.d.ts","sourceRoot":"","sources":["../../../src/constants/TransactionGasCosts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,eAAO,MAAM,mBAAmB;IAC9B;;;MAGE;;IAGF,qFAAqF;;IAGrF,+EAA+E;;IAG/E,0EAA0E;;IAG1E,gGAAgG;;CAExF,CAAA;AAEV;;;;;;;;;;;;;;;;;;;;GAoBG"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,gBAAgB,CAAA;AAC9B,cAAc,QAAQ,CAAA;AACtB,cAAc,QAAQ,CAAA;AACtB,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionFeesFields.d.ts","sourceRoot":"","sources":["../../../src/transaction/TransactionFeesFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAEtC,OAAO,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"TransactionFeesFields.d.ts","sourceRoot":"","sources":["../../../src/transaction/TransactionFeesFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAEtC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,QAAQ,CAAA;IACd,QAAQ,EAAE,QAAQ,CAAA;IAClB,QAAQ,EAAE,QAAQ,CAAA;IAClB,QAAQ,EAAE,QAAQ,CAAA;CACnB;AAED,MAAM,MAAM,kBAAkB,GAAG;KAC9B,CAAC,IAAI,MAAM,qBAAqB,GAAG,GAAG;CACxC,CAAA;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,kBAAkB,CAAA;CACzB;AAED,eAAO,MAAM,kBAAkB,EAAE,qBAEvB,CAAA;AAEV,eAAO,MAAM,sBAAsB,EAAE,qBAE3B,CAAA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export type XL1 = bigint & {
|
|
2
|
+
readonly _tag: 'XL1';
|
|
3
|
+
};
|
|
4
|
+
export type MilliXL1 = bigint & {
|
|
5
|
+
readonly _tag: 'MilliXL1';
|
|
6
|
+
};
|
|
7
|
+
export type MicroXL1 = bigint & {
|
|
8
|
+
readonly _tag: 'MicroXL1';
|
|
9
|
+
};
|
|
10
|
+
export type NanoXL1 = bigint & {
|
|
11
|
+
readonly _tag: 'NanoXL1';
|
|
12
|
+
};
|
|
13
|
+
export type PicoXL1 = bigint & {
|
|
14
|
+
readonly _tag: 'PicoXL1';
|
|
15
|
+
};
|
|
16
|
+
export type FemtoXL1 = bigint & {
|
|
17
|
+
readonly _tag: 'FemtoXL1';
|
|
18
|
+
};
|
|
19
|
+
export type AttoXL1 = bigint & {
|
|
20
|
+
readonly _tag: 'AttoXL1';
|
|
21
|
+
};
|
|
22
|
+
export declare const XL1: TypingFunc<XL1>;
|
|
23
|
+
export declare const MilliXL1: TypingFunc<MilliXL1>;
|
|
24
|
+
export declare const MicroXL1: TypingFunc<MicroXL1>;
|
|
25
|
+
export declare const NanoXL1: TypingFunc<NanoXL1>;
|
|
26
|
+
export declare const PicoXL1: TypingFunc<PicoXL1>;
|
|
27
|
+
export declare const FemtoXL1: TypingFunc<FemtoXL1>;
|
|
28
|
+
export declare const AttoXL1: TypingFunc<AttoXL1>;
|
|
29
|
+
export declare const XL1ConvertDict: Record<string, number>;
|
|
30
|
+
export type TypingFunc<T extends bigint> = (value: bigint) => T;
|
|
31
|
+
export declare function toXL1<T extends bigint>(value: T, factor: number): XL1;
|
|
32
|
+
export declare function fromXL1<T extends bigint>(value: XL1, factor: number, typingFunc: TypingFunc<T>): T;
|
|
33
|
+
export declare const milliXL1ToXL1: (value: MilliXL1) => XL1;
|
|
34
|
+
export declare const milliXL1FromXL1: (value: XL1) => MilliXL1;
|
|
35
|
+
export declare const microXL1ToXL1: (value: MicroXL1) => XL1;
|
|
36
|
+
export declare const microXL1FromXL1: (value: XL1) => MicroXL1;
|
|
37
|
+
export declare const nanoXL1ToXL1: (value: NanoXL1) => XL1;
|
|
38
|
+
export declare const nanoXL1FromXL1: (value: XL1) => NanoXL1;
|
|
39
|
+
export declare const picoXL1ToXL1: (value: PicoXL1) => XL1;
|
|
40
|
+
export declare const picoXL1FromXL1: (value: XL1) => PicoXL1;
|
|
41
|
+
export declare const femtoXL1ToXL1: (value: FemtoXL1) => XL1;
|
|
42
|
+
export declare const femtoXL1FromXL1: (value: XL1) => FemtoXL1;
|
|
43
|
+
export declare const attoXL1ToXL1: (value: AttoXL1) => XL1;
|
|
44
|
+
export declare const attoXL1FromXL1: (value: XL1) => AttoXL1;
|
|
45
|
+
//# sourceMappingURL=XL1.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"XL1.d.ts","sourceRoot":"","sources":["../../../src/xl1/XL1.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAA;CAAE,CAAA;AACnD,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;CAAE,CAAA;AAC7D,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;CAAE,CAAA;AAC7D,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;CAAE,CAAA;AAC3D,MAAM,MAAM,OAAO,GAAG,MA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O,GAAG,KAAG,QAE5C,CAAA;AAGD,eAAO,MAAM,aAAa,GAAI,OAAO,QAAQ,KAAG,GAE/C,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,OAAO,GAAG,KAAG,QAE5C,CAAA;AAGD,eAAO,MAAM,YAAY,GAAI,OAAO,OAAO,KAAG,GAE7C,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,OAAO,GAAG,KAAG,OAE3C,CAAA;AAGD,eAAO,MAAM,YAAY,GAAI,OAAO,OAAO,KAAG,GAE7C,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,OAAO,GAAG,KAAG,OAE3C,CAAA;AAGD,eAAO,MAAM,aAAa,GAAI,OAAO,QAAQ,KAAG,GAE/C,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,OAAO,GAAG,KAAG,QAE5C,CAAA;AAGD,eAAO,MAAM,YAAY,GAAI,OAAO,OAAO,KAAG,GAE7C,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,OAAO,GAAG,KAAG,OAE3C,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/xl1/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
package/src/xl1/XL1.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
export type XL1 = bigint & { readonly _tag: 'XL1' } // 1e-18
|
|
2
|
+
export type MilliXL1 = bigint & { readonly _tag: 'MilliXL1' } // 1e-15 [XL1 * 1e3 = milliXL1] [milliXL1 / 1e3 = XL1]
|
|
3
|
+
export type MicroXL1 = bigint & { readonly _tag: 'MicroXL1' } // 1e-12 [XL1 * 1e6 = microXL1] [microXL1 / 1e6 = XL1]
|
|
4
|
+
export type NanoXL1 = bigint & { readonly _tag: 'NanoXL1' } // 1e-9 [XL1 * 1e9 = nanoXL1] [nanoXL1 / 1e9 = XL1]
|
|
5
|
+
export type PicoXL1 = bigint & { readonly _tag: 'PicoXL1' } // 1e-6 [XL1 * 1e12 = picoXL1] [picoXL1 / 1e12 = XL1]
|
|
6
|
+
export type FemtoXL1 = bigint & { readonly _tag: 'FemtoXL1' } // 1e-3 [XL1 * 1e15 = femtoXL1] [femtoXL1 / 1e15 = XL1]
|
|
7
|
+
export type AttoXL1 = bigint & { readonly _tag: 'AttoXL1' } // 1e-0 [XL1 * 1e18 = attoXL1] [attoXL1 / 1e18 = XL1]
|
|
8
|
+
|
|
9
|
+
export const XL1: TypingFunc<XL1> = (value: bigint): XL1 => value as XL1
|
|
10
|
+
export const MilliXL1: TypingFunc<MilliXL1> = (value: bigint): MilliXL1 => value as MilliXL1
|
|
11
|
+
export const MicroXL1: TypingFunc<MicroXL1> = (value: bigint): MicroXL1 => value as MicroXL1
|
|
12
|
+
export const NanoXL1: TypingFunc<NanoXL1> = (value: bigint): NanoXL1 => value as NanoXL1
|
|
13
|
+
export const PicoXL1: TypingFunc<PicoXL1> = (value: bigint): PicoXL1 => value as PicoXL1
|
|
14
|
+
export const FemtoXL1: TypingFunc<FemtoXL1> = (value: bigint): FemtoXL1 => value as FemtoXL1
|
|
15
|
+
export const AttoXL1: TypingFunc<AttoXL1> = (value: bigint): AttoXL1 => value as AttoXL1
|
|
16
|
+
|
|
17
|
+
export const XL1ConvertDict: Record<string, number> = {
|
|
18
|
+
milli: 3,
|
|
19
|
+
micro: 6,
|
|
20
|
+
nano: 9,
|
|
21
|
+
pico: 12,
|
|
22
|
+
femto: 15,
|
|
23
|
+
atto: 18,
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type TypingFunc<T extends bigint> = (value: bigint) => T
|
|
27
|
+
|
|
28
|
+
export function toXL1<T extends bigint>(value: T, factor: number): XL1 {
|
|
29
|
+
return XL1(value / (10n ** BigInt(factor)))
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function fromXL1<T extends bigint>(value: XL1, factor: number, typingFunc: TypingFunc<T>): T {
|
|
33
|
+
return typingFunc(value * (10n ** BigInt(factor)))
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// milli
|
|
37
|
+
export const milliXL1ToXL1 = (value: MilliXL1): XL1 => {
|
|
38
|
+
return toXL1(value, XL1ConvertDict.milli)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const milliXL1FromXL1 = (value: XL1): MilliXL1 => {
|
|
42
|
+
return fromXL1(value, XL1ConvertDict.micro, MilliXL1)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// micro
|
|
46
|
+
export const microXL1ToXL1 = (value: MicroXL1): XL1 => {
|
|
47
|
+
return toXL1(value, XL1ConvertDict.micro)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const microXL1FromXL1 = (value: XL1): MicroXL1 => {
|
|
51
|
+
return fromXL1(value, XL1ConvertDict.micro, MicroXL1)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// nano
|
|
55
|
+
export const nanoXL1ToXL1 = (value: NanoXL1): XL1 => {
|
|
56
|
+
return toXL1(value, XL1ConvertDict.nano)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const nanoXL1FromXL1 = (value: XL1): NanoXL1 => {
|
|
60
|
+
return fromXL1(value, XL1ConvertDict.nano, NanoXL1)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// pico
|
|
64
|
+
export const picoXL1ToXL1 = (value: PicoXL1): XL1 => {
|
|
65
|
+
return toXL1(value, XL1ConvertDict.pico)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export const picoXL1FromXL1 = (value: XL1): PicoXL1 => {
|
|
69
|
+
return fromXL1(value, XL1ConvertDict.pico, PicoXL1)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// femto
|
|
73
|
+
export const femtoXL1ToXL1 = (value: FemtoXL1): XL1 => {
|
|
74
|
+
return toXL1(value, XL1ConvertDict.femto)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export const femtoXL1FromXL1 = (value: XL1): FemtoXL1 => {
|
|
78
|
+
return fromXL1(value, XL1ConvertDict.femto, FemtoXL1)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// atto
|
|
82
|
+
export const attoXL1ToXL1 = (value: AttoXL1): XL1 => {
|
|
83
|
+
return toXL1(value, XL1ConvertDict.atto)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export const attoXL1FromXL1 = (value: XL1): AttoXL1 => {
|
|
87
|
+
return fromXL1(value, XL1ConvertDict.atto, AttoXL1)
|
|
88
|
+
}
|
package/src/xl1/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './XL1.ts'
|
package/dist/types/XL1.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export type XL1 = bigint & {
|
|
2
|
-
readonly _tag: 'XL1';
|
|
3
|
-
};
|
|
4
|
-
export type MicroXL1 = bigint & {
|
|
5
|
-
readonly _tag: 'MicroXL1';
|
|
6
|
-
};
|
|
7
|
-
export declare const XL1: (value: bigint) => XL1;
|
|
8
|
-
export declare const MicroXL1: (value: bigint) => MicroXL1;
|
|
9
|
-
export declare const mXL1ToXL1: (value: MicroXL1) => XL1;
|
|
10
|
-
export declare const mXL1FromXL1: (value: XL1) => MicroXL1;
|
|
11
|
-
//# sourceMappingURL=XL1.d.ts.map
|
package/dist/types/XL1.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"XL1.d.ts","sourceRoot":"","sources":["../../src/XL1.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAA;CAAE,CAAA;AACnD,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;CAAE,CAAA;AAE7D,eAAO,MAAM,GAAG,GAAI,OAAO,MAAM,KAAG,GAAmB,CAAA;AACvD,eAAO,MAAM,QAAQ,GAAI,OAAO,MAAM,KAAG,QAA6B,CAAA;AAEtE,eAAO,MAAM,SAAS,GAAI,OAAO,QAAQ,KAAG,GAE3C,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,OAAO,GAAG,KAAG,QAExC,CAAA"}
|
package/src/XL1.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export type XL1 = bigint & { readonly _tag: 'XL1' } // 1e-18
|
|
2
|
-
export type MicroXL1 = bigint & { readonly _tag: 'MicroXL1' } // 1e-24
|
|
3
|
-
|
|
4
|
-
export const XL1 = (value: bigint): XL1 => value as XL1
|
|
5
|
-
export const MicroXL1 = (value: bigint): MicroXL1 => value as MicroXL1
|
|
6
|
-
|
|
7
|
-
export const mXL1ToXL1 = (value: MicroXL1): XL1 => {
|
|
8
|
-
return XL1(BigInt(value) / BigInt(1_000_000))
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const mXL1FromXL1 = (value: XL1): MicroXL1 => {
|
|
12
|
-
return MicroXL1(BigInt(value) * BigInt(1_000_000))
|
|
13
|
-
}
|