@xyo-network/xl1-protocol 1.3.28 → 1.3.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/neutral/index.mjs +39 -1
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/node/index.mjs +39 -1
- package/dist/node/index.mjs.map +1 -1
- package/dist/types/Xl1.d.ts +11 -0
- package/dist/types/Xl1.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/transaction/TransactionFeesFields.d.ts +15 -5
- package/dist/types/transaction/TransactionFeesFields.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/Xl1.ts +13 -0
- package/src/index.ts +1 -0
- package/src/transaction/TransactionFeesFields.ts +23 -5
package/dist/neutral/index.mjs
CHANGED
|
@@ -64,6 +64,37 @@ var asOptionalTransactionBoundWitness = AsObjectFactory4.createOptional(isTransa
|
|
|
64
64
|
var asTransactionBoundWitnessWithStorageMeta = AsObjectFactory4.create(isTransactionBoundWitnessWithStorageMeta);
|
|
65
65
|
var asOptionalTransactionBoundWitnessWithStorageMeta = AsObjectFactory4.createOptional(isTransactionBoundWitnessWithStorageMeta);
|
|
66
66
|
|
|
67
|
+
// src/Xl1.ts
|
|
68
|
+
var XL1 = (value) => value;
|
|
69
|
+
var MicroXL1 = (value) => value;
|
|
70
|
+
var mXl1ToXl1 = (value) => {
|
|
71
|
+
return XL1(BigInt(value) / BigInt(1e6));
|
|
72
|
+
};
|
|
73
|
+
var xl1ToMxl1 = (value) => {
|
|
74
|
+
return MicroXL1(BigInt(value) * BigInt(1e6));
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// src/transaction/TransactionFeesFields.ts
|
|
78
|
+
var TransactionGasCosts = {
|
|
79
|
+
byte: MicroXL1(10n),
|
|
80
|
+
payloadValidation: MicroXL1(1000n),
|
|
81
|
+
signatureValidation: MicroXL1(1000n),
|
|
82
|
+
hashValidation: MicroXL1(100n),
|
|
83
|
+
balanceValidation: MicroXL1(100n)
|
|
84
|
+
};
|
|
85
|
+
var minTransactionFees = {
|
|
86
|
+
base: MicroXL1(1000n),
|
|
87
|
+
gasPrice: MicroXL1(1n),
|
|
88
|
+
gasLimit: MicroXL1(1000n),
|
|
89
|
+
priority: MicroXL1(0n)
|
|
90
|
+
};
|
|
91
|
+
var defaultTransactionFees = {
|
|
92
|
+
base: minTransactionFees.base,
|
|
93
|
+
gasPrice: MicroXL1(10n),
|
|
94
|
+
gasLimit: MicroXL1(1000000n),
|
|
95
|
+
priority: MicroXL1(0n)
|
|
96
|
+
};
|
|
97
|
+
|
|
67
98
|
// src/block/AllowedBlockPayload.ts
|
|
68
99
|
var AllowedBlockPayloadSchemas = [TransferSchema, ChainStakeIntentSchema, SchemaSchema, BoundWitnessSchema, HashSchema];
|
|
69
100
|
var isAllowedBlockPayloadSchema = (value) => {
|
|
@@ -162,9 +193,12 @@ export {
|
|
|
162
193
|
ChainStakeIntentSchema,
|
|
163
194
|
ETH_ZERO_ADDRESS,
|
|
164
195
|
HashSchema,
|
|
196
|
+
MicroXL1,
|
|
165
197
|
NetworkStatusSchema,
|
|
166
198
|
StepSizes,
|
|
199
|
+
TransactionGasCosts,
|
|
167
200
|
TransferSchema,
|
|
201
|
+
XL1,
|
|
168
202
|
asBlockBoundWitness,
|
|
169
203
|
asBlockBoundWitnessWithStorageMeta,
|
|
170
204
|
asBlockNumber,
|
|
@@ -188,6 +222,7 @@ export {
|
|
|
188
222
|
asTransactionBoundWitness,
|
|
189
223
|
asTransactionBoundWitnessWithStorageMeta,
|
|
190
224
|
asTransfer,
|
|
225
|
+
defaultTransactionFees,
|
|
191
226
|
getDefaultGasConfig,
|
|
192
227
|
hasFrom,
|
|
193
228
|
isAllowedBlockPayload,
|
|
@@ -211,6 +246,9 @@ export {
|
|
|
211
246
|
isTransactionBoundWitness,
|
|
212
247
|
isTransactionBoundWitnessWithStorageMeta,
|
|
213
248
|
isTransfer,
|
|
214
|
-
|
|
249
|
+
mXl1ToXl1,
|
|
250
|
+
minTransactionFees,
|
|
251
|
+
toEthAddress,
|
|
252
|
+
xl1ToMxl1
|
|
215
253
|
};
|
|
216
254
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/block/AllowedBlockPayload.ts","../../src/payload/elevatable/ChainStakeIntent.ts","../../src/payload/elevatable/Executable.ts","../../src/payload/elevatable/Hash.ts","../../src/payload/elevatable/TransferPayload.ts","../../src/transaction/TransactionBoundWitness.ts","../../src/block/BlockBoundWitness.ts","../../src/BlockNumber.ts","../../src/ethereum.ts","../../src/network/Status.ts","../../src/services/Chain/ChainIdentification.ts","../../src/services/Chain/ChainInformation.ts","../../src/services/stakeIntent/ChainIndexingServiceStateSchema.ts","../../src/Steps.ts"],"sourcesContent":["import { BoundWitnessSchema } from '@xyo-network/boundwitness-model'\nimport type { Schema, WithStorageMeta } from '@xyo-network/payload-model'\nimport { isHashStorageMeta, isSchema } from '@xyo-network/payload-model'\nimport type { SchemaPayload } from '@xyo-network/schema-payload-plugin'\nimport { isSchemaPayload, SchemaSchema } from '@xyo-network/schema-payload-plugin'\n\nimport type {\n ChainStakeIntent, HashPayload, Transfer,\n} from '../payload/index.ts'\nimport {\n ChainStakeIntentSchema, HashSchema, isChainStakeIntent, isHashPayload, isTransfer, TransferSchema,\n} from '../payload/index.ts'\nimport { isTransactionBoundWitness, type TransactionBoundWitness } from '../transaction/index.ts'\n\nexport type AllowedBlockPayload = Transfer | ChainStakeIntent | SchemaPayload | TransactionBoundWitness | HashPayload\nexport const AllowedBlockPayloadSchemas: Schema[] = [TransferSchema, ChainStakeIntentSchema, SchemaSchema, BoundWitnessSchema, HashSchema]\nexport type AllowedBlockPayloadSchema = typeof AllowedBlockPayloadSchemas[number]\n\nexport const isAllowedBlockPayloadSchema = (value: unknown): value is AllowedBlockPayloadSchema => {\n return isSchema(value) && AllowedBlockPayloadSchemas.includes(value)\n}\n\nexport const isAllowedBlockPayload = (value: unknown): value is AllowedBlockPayload => {\n return isTransfer(value) || isChainStakeIntent(value) || isSchemaPayload(value) || isTransactionBoundWitness(value) || isHashPayload(value)\n}\n\nexport const isAllowedBlockPayloadWithHashStorageMeta = (value: unknown): value is WithStorageMeta<AllowedBlockPayload> => {\n return isAllowedBlockPayload(value) && isHashStorageMeta(value)\n}\n","import { AsObjectFactory } from '@xylabs/object'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nimport type { BlockDuration } from '../../BlockDuration.ts'\nimport type { FromFields } from './Executable.ts'\n\nexport const ChainStakeIntentSchema = 'network.xyo.chain.stake.intent' as const\nexport type ChainStakeIntentSchema = typeof ChainStakeIntentSchema\n\nexport type Intent = 'producer' // | 'bank'\n\nexport interface ChainStakeIntentFields extends BlockDuration, FromFields {\n /*\n * The intent of the staking\n */\n intent: Intent\n}\n\nexport type ChainStakeIntent = Payload<ChainStakeIntentFields, ChainStakeIntentSchema>\n\nexport const isChainStakeIntent = (x?: unknown | null): x is ChainStakeIntent => {\n return isPayloadOfSchemaType<ChainStakeIntent>(ChainStakeIntentSchema)(x)\n && asNonNegativeInteger(x.nbf) !== undefined\n && asNonNegativeInteger(x.exp) !== undefined\n}\nexport const asChainStakeIntent = AsObjectFactory.create(isChainStakeIntent)\nexport const asOptionalChainStakeIntent = AsObjectFactory.createOptional(isChainStakeIntent)\n\nconst asNonNegativeInteger = (num: number) => {\n return (Number.isInteger(num) && num >= 0) ? num : undefined\n}\n","import type { Address } from '@xylabs/hex'\nimport type { EmptyObject } from '@xylabs/object'\nimport { isAnyPayload } from '@xyo-network/payload-model'\n\nexport interface FromFields {\n // the address that is treated as the source of this action\n from: Address\n}\n\nexport const hasFrom = (value: unknown): value is FromFields => {\n return (value as FromFields).from !== undefined\n}\n\nexport interface ExecutableFields {\n script: string[]\n}\n\nexport type Executable<T extends EmptyObject = EmptyObject> = T & ExecutableFields\nexport type OptionalExecutable<T extends EmptyObject = EmptyObject> = T & Partial<ExecutableFields>\n\nexport const isExecutable = <T extends EmptyObject>(value: T | undefined): value is Executable<T> => {\n return isAnyPayload(value) && Array.isArray((value as unknown as ExecutableFields).script)\n}\n\nexport const asExecutable = <T extends EmptyObject>(value: T | undefined): Executable<T> | undefined => {\n return isExecutable(value)\n ? value as unknown as Executable<T>\n : undefined\n}\n","import type { Hash } from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nexport const HashSchema = 'network.xyo.hash' as const\nexport type HashSchema = typeof HashSchema\n\nexport interface HashFields {\n hash: Hash\n}\n\nexport type HashPayload = Payload<HashFields, HashSchema>\n\nexport const isHashPayload = isPayloadOfSchemaType<HashPayload>(HashSchema)\n\nexport const asHashPayload = AsObjectFactory.create(isHashPayload)\nexport const asHashPayloadWithStorageMeta = AsObjectFactory.create(isHashPayload)\nexport const asOptionalHashPayload = AsObjectFactory.createOptional(isHashPayload)\n","import type {\n Address,\n Hex,\n} from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nimport type { FromFields } from './Executable.ts'\n\nexport const TransferSchema = 'network.xyo.transfer' as const\nexport type TransferSchema = typeof TransferSchema\n\nexport interface TransferFields extends FromFields {\n epoch: number\n // the amount that is being sent to another address\n transfers: Record<Address, Hex>\n}\n\n// if this payload is included in a boundwitness, it needs to be available for inspection to be included in block\nexport type Transfer = Payload<TransferFields, TransferSchema>\n\nexport const isTransfer = isPayloadOfSchemaType<Transfer>(TransferSchema)\n\nexport const asTransfer = AsObjectFactory.create(isTransfer)\nexport const asOptionalTransfer = AsObjectFactory.createOptional(isTransfer)\n","import type { Address } from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { BoundWitness, Signed } from '@xyo-network/boundwitness-model'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport { isStorageMeta } from '@xyo-network/payload-model'\n\nimport type { BlockDuration } from '../BlockDuration.ts'\nimport type { FromFields, OptionalExecutable } from '../payload/index.ts'\nimport type { TransactionFeesFields } from './TransactionFeesFields.ts'\n\nexport interface TransactionBoundWitnessFields extends BlockDuration, TransactionFeesFields {\n chain: Address\n}\n\nexport type TransactionBoundWitness = BoundWitness<TransactionBoundWitnessFields & OptionalExecutable & FromFields>\n\nexport const isTransactionBoundWitness = (value: unknown): value is TransactionBoundWitness => {\n const typedObj = value as TransactionBoundWitness\n return isBoundWitness(value)\n && typedObj.chain !== undefined\n && typedObj.fees !== undefined\n && typedObj.exp !== undefined\n && typedObj.nbf !== undefined\n}\n\nexport const isSignedTransactionBoundWitness = (value: unknown): value is Signed<TransactionBoundWitness> => {\n return isTransactionBoundWitness(value) && isSigned(value)\n}\n\nexport const isSigned = <T extends BoundWitness = BoundWitness>(value: unknown): value is Signed<T> =>\n isBoundWitness(value)\n && value.$signatures.length === value.addresses.length\n && value.addresses.length > 0\n\nexport const isTransactionBoundWitnessWithStorageMeta = (value: unknown): value is WithStorageMeta<TransactionBoundWitness> =>\n isTransactionBoundWitness(value)\n && isStorageMeta(value)\n\nexport const isSignedTransactionBoundWitnessWithStorageMeta = (value: unknown): value is WithStorageMeta<Signed<TransactionBoundWitness>> =>\n isSignedTransactionBoundWitness(value)\n && isStorageMeta(value)\n\nexport const asTransactionBoundWitness = AsObjectFactory.create(isTransactionBoundWitness)\nexport const asOptionalTransactionBoundWitness = AsObjectFactory.createOptional(isTransactionBoundWitness)\n\nexport const asTransactionBoundWitnessWithStorageMeta = AsObjectFactory.create(isTransactionBoundWitnessWithStorageMeta)\nexport const asOptionalTransactionBoundWitnessWithStorageMeta = AsObjectFactory.createOptional(isTransactionBoundWitnessWithStorageMeta)\n","import type { Hash, Hex } from '@xylabs/hex'\nimport { isHex } from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport { isStorageMeta } from '@xyo-network/payload-model'\n\nexport interface BlockBoundWitnessMeta {\n $epoch: number\n}\n\nexport interface BlockBoundWitnessFields {\n /** Block number */\n block: number\n /** Chain id - this should be \"0\" for the genesis block */\n chain: Hex\n /** Previous block hash if not block 0 */\n previous: Hash | null /* the previous block hash */\n /** Version of the protocol being used major * 1,000,000 + minor * 1,000 + patch */\n protocol: number\n /** Step hashes */\n step_hashes: Hex[]\n}\n\nexport type BlockBoundWitness = BoundWitness<BlockBoundWitnessFields & BlockBoundWitnessMeta>\n\nexport const isBlockBoundWitness = (value: unknown): value is BlockBoundWitness => {\n const typedObj = value as BlockBoundWitness\n return isBoundWitness(value)\n && Number.isInteger(typedObj.block)\n && isHex(typedObj.chain)\n}\n\nexport const isBlockBoundWitnessWithStorageMeta = (value: unknown): value is WithStorageMeta<BlockBoundWitness> => {\n return isBlockBoundWitness(value) && isStorageMeta(value)\n}\n\nexport const asBlockBoundWitness = AsObjectFactory.create(isBlockBoundWitness)\nexport const asOptionalBlockBoundWitness = AsObjectFactory.createOptional(isBlockBoundWitness)\n\nexport const asBlockBoundWitnessWithStorageMeta = AsObjectFactory.create(isBlockBoundWitnessWithStorageMeta)\nexport const asOptionalBlockBoundWitnessWithStorageMeta = AsObjectFactory.createOptional(isBlockBoundWitnessWithStorageMeta)\n","import type { Hex } from '@xylabs/hex'\nimport { 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 { Hex } from '@xylabs/hex'\nimport { toHex } from '@xylabs/hex'\nimport type { AccountInstance } from '@xyo-network/account-model'\nimport { getAddress } from 'ethers'\nimport { parseUnits } from 'ethers/utils'\n\nexport interface GasConfig {\n gasLimit?: number\n gasPrice?: bigint\n}\n\nexport const getDefaultGasConfig = (): GasConfig => {\n return {\n gasLimit: 2_000_000, // Set the gas limit\n gasPrice: parseUnits('100', 'gwei'),\n }\n}\n\nexport type EthAddress = Hex\n\nexport const ETH_ZERO_ADDRESS: EthAddress = '0x0000000000000000000000000000000000000000' as const\n\nexport const toEthAddress = (value: bigint | string | AccountInstance): EthAddress => {\n const address = (typeof value === 'object') ? value.address : value\n return getAddress(toHex(address, { prefix: true, bitLength: 160 })) as EthAddress\n}\n","import type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nexport const NetworkStatusSchema = 'network.xyo.chain.status' as const\nexport type NetworkStatusSchema = typeof NetworkStatusSchema\n\nexport type NetworkStatusState = 'online' | 'offline' | 'degraded' | 'unknown'\n\nexport type NetworkStatusUpdate = {\n end: number\n start: number\n update: string\n}\n\nexport interface NetworkStatusFields {\n description: string\n state: NetworkStatusState\n updates?: NetworkStatusUpdate[]\n}\n\nexport type NetworkStatus = Payload<NetworkStatusFields, NetworkStatusSchema>\n\nexport const isNetworkStatus = isPayloadOfSchemaType<NetworkStatus>(NetworkStatusSchema)\n","import type { Address } from '@xylabs/hex'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nexport const ChainIdentificationPayloadSchema = 'network.xyo.chain.identification' as const\nexport type ChainIdentificationPayloadSchema = typeof ChainIdentificationPayloadSchema\n\n/**\n * Identification required to uniquely identify a chain\n */\nexport interface ChainIdentification {\n /** @field the id of the chain */\n id: Address\n}\n\nexport type ChainIdentificationPayload = Payload<ChainIdentification, ChainIdentificationPayloadSchema>\nexport const isChainIdentificationPayload = isPayloadOfSchemaType<ChainIdentificationPayload>(ChainIdentificationPayloadSchema)\n","import type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nexport const ChainInformationPayloadSchema = 'network.xyo.chain.information' as const\nexport type ChainInformationPayloadSchema = typeof ChainInformationPayloadSchema\n\nimport type { ChainIdentification } from './ChainIdentification.ts'\n\n/**\n * Information required to produce a chain\n */\nexport interface ChainInformation extends ChainIdentification {\n // TODO: Add these fields which are currently promises on the smart contract\n // forkedAtBlockNumber: bigint\n // forkedAtHash: Hash\n // forkedChainId: Address\n}\n\nexport type ChainInformationPayload = Payload<ChainIdentification, ChainInformationPayloadSchema>\nexport const isChainInformationPayload = isPayloadOfSchemaType<ChainInformationPayload>(ChainInformationPayloadSchema)\n","import type { Hash } from '@xylabs/hex'\nimport type { JsonValue } from '@xylabs/object'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { Payload, WithStorageMeta } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType, isStorageMeta } from '@xyo-network/payload-model'\n\nexport interface ChainIndexingServiceStateFields<T extends JsonValue = JsonValue> {\n /**\n * The hash of the last block that this service has indexing\n */\n endBlockHash: Hash\n /**\n * The hash of the block that the service started indexing. If undefined, the service is\n * assumed to have started indexing from the genesis block\n */\n startBlockHash?: Hash\n /**\n * The indexed state for the range\n */\n state: T\n}\nexport const ChainIndexingServiceStateSchema = 'network.xyo.chain.indexing.service.state' as const\nexport type ChainIndexingServiceStateSchema = typeof ChainIndexingServiceStateSchema\n\n/**\n * The result of a ChainIndexingServiceState\n */\nexport type ChainIndexingServiceState<T extends JsonValue = JsonValue> = Payload<ChainIndexingServiceStateFields<T>, ChainIndexingServiceStateSchema>\n\n/**\n * Identity functions for determining if an object is an ChainIndexingServiceState\n */\nexport const isChainIndexingServiceState = <T extends JsonValue = JsonValue>(payload?: unknown): payload is ChainIndexingServiceState<T> => {\n return isPayloadOfSchemaType<ChainIndexingServiceState<T>>(ChainIndexingServiceStateSchema)(payload)\n}\nexport const asChainIndexingServiceState = AsObjectFactory.create<ChainIndexingServiceState<JsonValue>>(isChainIndexingServiceState)\n\nexport const isChainIndexingServiceStateWithStorageMeta\n= <T extends JsonValue = JsonValue>(value: unknown): value is WithStorageMeta<ChainIndexingServiceState<T>> =>\n isChainIndexingServiceState<T>(value) && isStorageMeta(value)\n\nexport const asChainIndexingServiceStateWithStorageMeta\n= AsObjectFactory.create<WithStorageMeta<ChainIndexingServiceState>>(isChainIndexingServiceStateWithStorageMeta)\n\nexport const asOptionalChainIndexingServiceStateWithStorageMeta\n= AsObjectFactory.createOptional<WithStorageMeta<ChainIndexingServiceState>>(isChainIndexingServiceStateWithStorageMeta)\n","export const StepSizes = [10, 105, 1103, 11_576, 121_551, 1_276_282, 13_400_956]\n"],"mappings":";AAAA,SAAS,0BAA0B;AAEnC,SAAS,mBAAmB,gBAAgB;AAE5C,SAAS,iBAAiB,oBAAoB;;;ACJ9C,SAAS,uBAAuB;AAEhC,SAAS,6BAA6B;AAK/B,IAAM,yBAAyB;AAc/B,IAAM,qBAAqB,CAAC,MAA8C;AAC/E,SAAO,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yBAAAC,wBAAuB,iBAAAC,sBAAqB;AAiB9C,IAAM,kCAAkC;AAWxC,IAAM,8BAA8B,CAAkC,YAA+D;AAC1I,SAAOD,uBAAoD,+BAA+B,EAAE,OAAO;AACrG;AACO,IAAM,8BAA8BD,iBAAgB,OAA6C,2BAA2B;AAE5H,IAAM,6CACX,CAAkC,UAClC,4BAA+B,KAAK,KAAKE,eAAc,KAAK;AAEvD,IAAM,6CACXF,iBAAgB,OAAmD,0CAA0C;AAExG,IAAM,qDACXA,iBAAgB,eAA2D,0CAA0C;;;AC7ChH,IAAM,YAAY,CAAC,IAAI,KAAK,MAAM,OAAQ,QAAS,SAAW,QAAU;","names":["AsObjectFactory","isPayloadOfSchemaType","AsObjectFactory","isPayloadOfSchemaType","AsObjectFactory","AsObjectFactory","isBoundWitness","isStorageMeta","AsObjectFactory","isPayloadOfSchemaType","isPayloadOfSchemaType","isPayloadOfSchemaType","isPayloadOfSchemaType","AsObjectFactory","isPayloadOfSchemaType","isStorageMeta"]}
|
|
1
|
+
{"version":3,"sources":["../../src/block/AllowedBlockPayload.ts","../../src/payload/elevatable/ChainStakeIntent.ts","../../src/payload/elevatable/Executable.ts","../../src/payload/elevatable/Hash.ts","../../src/payload/elevatable/TransferPayload.ts","../../src/transaction/TransactionBoundWitness.ts","../../src/Xl1.ts","../../src/transaction/TransactionFeesFields.ts","../../src/block/BlockBoundWitness.ts","../../src/BlockNumber.ts","../../src/ethereum.ts","../../src/network/Status.ts","../../src/services/Chain/ChainIdentification.ts","../../src/services/Chain/ChainInformation.ts","../../src/services/stakeIntent/ChainIndexingServiceStateSchema.ts","../../src/Steps.ts"],"sourcesContent":["import { BoundWitnessSchema } from '@xyo-network/boundwitness-model'\nimport type { Schema, WithStorageMeta } from '@xyo-network/payload-model'\nimport { isHashStorageMeta, isSchema } from '@xyo-network/payload-model'\nimport type { SchemaPayload } from '@xyo-network/schema-payload-plugin'\nimport { isSchemaPayload, SchemaSchema } from '@xyo-network/schema-payload-plugin'\n\nimport type {\n ChainStakeIntent, HashPayload, Transfer,\n} from '../payload/index.ts'\nimport {\n ChainStakeIntentSchema, HashSchema, isChainStakeIntent, isHashPayload, isTransfer, TransferSchema,\n} from '../payload/index.ts'\nimport { isTransactionBoundWitness, type TransactionBoundWitness } from '../transaction/index.ts'\n\nexport type AllowedBlockPayload = Transfer | ChainStakeIntent | SchemaPayload | TransactionBoundWitness | HashPayload\nexport const AllowedBlockPayloadSchemas: Schema[] = [TransferSchema, ChainStakeIntentSchema, SchemaSchema, BoundWitnessSchema, HashSchema]\nexport type AllowedBlockPayloadSchema = typeof AllowedBlockPayloadSchemas[number]\n\nexport const isAllowedBlockPayloadSchema = (value: unknown): value is AllowedBlockPayloadSchema => {\n return isSchema(value) && AllowedBlockPayloadSchemas.includes(value)\n}\n\nexport const isAllowedBlockPayload = (value: unknown): value is AllowedBlockPayload => {\n return isTransfer(value) || isChainStakeIntent(value) || isSchemaPayload(value) || isTransactionBoundWitness(value) || isHashPayload(value)\n}\n\nexport const isAllowedBlockPayloadWithHashStorageMeta = (value: unknown): value is WithStorageMeta<AllowedBlockPayload> => {\n return isAllowedBlockPayload(value) && isHashStorageMeta(value)\n}\n","import { AsObjectFactory } from '@xylabs/object'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nimport type { BlockDuration } from '../../BlockDuration.ts'\nimport type { FromFields } from './Executable.ts'\n\nexport const ChainStakeIntentSchema = 'network.xyo.chain.stake.intent' as const\nexport type ChainStakeIntentSchema = typeof ChainStakeIntentSchema\n\nexport type Intent = 'producer' // | 'bank'\n\nexport interface ChainStakeIntentFields extends BlockDuration, FromFields {\n /*\n * The intent of the staking\n */\n intent: Intent\n}\n\nexport type ChainStakeIntent = Payload<ChainStakeIntentFields, ChainStakeIntentSchema>\n\nexport const isChainStakeIntent = (x?: unknown | null): x is ChainStakeIntent => {\n return isPayloadOfSchemaType<ChainStakeIntent>(ChainStakeIntentSchema)(x)\n && asNonNegativeInteger(x.nbf) !== undefined\n && asNonNegativeInteger(x.exp) !== undefined\n}\nexport const asChainStakeIntent = AsObjectFactory.create(isChainStakeIntent)\nexport const asOptionalChainStakeIntent = AsObjectFactory.createOptional(isChainStakeIntent)\n\nconst asNonNegativeInteger = (num: number) => {\n return (Number.isInteger(num) && num >= 0) ? num : undefined\n}\n","import type { Address } from '@xylabs/hex'\nimport type { EmptyObject } from '@xylabs/object'\nimport { isAnyPayload } from '@xyo-network/payload-model'\n\nexport interface FromFields {\n // the address that is treated as the source of this action\n from: Address\n}\n\nexport const hasFrom = (value: unknown): value is FromFields => {\n return (value as FromFields).from !== undefined\n}\n\nexport interface ExecutableFields {\n script: string[]\n}\n\nexport type Executable<T extends EmptyObject = EmptyObject> = T & ExecutableFields\nexport type OptionalExecutable<T extends EmptyObject = EmptyObject> = T & Partial<ExecutableFields>\n\nexport const isExecutable = <T extends EmptyObject>(value: T | undefined): value is Executable<T> => {\n return isAnyPayload(value) && Array.isArray((value as unknown as ExecutableFields).script)\n}\n\nexport const asExecutable = <T extends EmptyObject>(value: T | undefined): Executable<T> | undefined => {\n return isExecutable(value)\n ? value as unknown as Executable<T>\n : undefined\n}\n","import type { Hash } from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nexport const HashSchema = 'network.xyo.hash' as const\nexport type HashSchema = typeof HashSchema\n\nexport interface HashFields {\n hash: Hash\n}\n\nexport type HashPayload = Payload<HashFields, HashSchema>\n\nexport const isHashPayload = isPayloadOfSchemaType<HashPayload>(HashSchema)\n\nexport const asHashPayload = AsObjectFactory.create(isHashPayload)\nexport const asHashPayloadWithStorageMeta = AsObjectFactory.create(isHashPayload)\nexport const asOptionalHashPayload = AsObjectFactory.createOptional(isHashPayload)\n","import type {\n Address,\n Hex,\n} from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nimport type { FromFields } from './Executable.ts'\n\nexport const TransferSchema = 'network.xyo.transfer' as const\nexport type TransferSchema = typeof TransferSchema\n\nexport interface TransferFields extends FromFields {\n epoch: number\n // the amount that is being sent to another address\n transfers: Record<Address, Hex>\n}\n\n// if this payload is included in a boundwitness, it needs to be available for inspection to be included in block\nexport type Transfer = Payload<TransferFields, TransferSchema>\n\nexport const isTransfer = isPayloadOfSchemaType<Transfer>(TransferSchema)\n\nexport const asTransfer = AsObjectFactory.create(isTransfer)\nexport const asOptionalTransfer = AsObjectFactory.createOptional(isTransfer)\n","import type { Address } from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { BoundWitness, Signed } from '@xyo-network/boundwitness-model'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport { isStorageMeta } from '@xyo-network/payload-model'\n\nimport type { BlockDuration } from '../BlockDuration.ts'\nimport type { FromFields, OptionalExecutable } from '../payload/index.ts'\nimport type { TransactionFeesFields } from './TransactionFeesFields.ts'\n\nexport interface TransactionBoundWitnessFields extends BlockDuration, TransactionFeesFields {\n chain: Address\n}\n\nexport type TransactionBoundWitness = BoundWitness<TransactionBoundWitnessFields & OptionalExecutable & FromFields>\n\nexport const isTransactionBoundWitness = (value: unknown): value is TransactionBoundWitness => {\n const typedObj = value as TransactionBoundWitness\n return isBoundWitness(value)\n && typedObj.chain !== undefined\n && typedObj.fees !== undefined\n && typedObj.exp !== undefined\n && typedObj.nbf !== undefined\n}\n\nexport const isSignedTransactionBoundWitness = (value: unknown): value is Signed<TransactionBoundWitness> => {\n return isTransactionBoundWitness(value) && isSigned(value)\n}\n\nexport const isSigned = <T extends BoundWitness = BoundWitness>(value: unknown): value is Signed<T> =>\n isBoundWitness(value)\n && value.$signatures.length === value.addresses.length\n && value.addresses.length > 0\n\nexport const isTransactionBoundWitnessWithStorageMeta = (value: unknown): value is WithStorageMeta<TransactionBoundWitness> =>\n isTransactionBoundWitness(value)\n && isStorageMeta(value)\n\nexport const isSignedTransactionBoundWitnessWithStorageMeta = (value: unknown): value is WithStorageMeta<Signed<TransactionBoundWitness>> =>\n isSignedTransactionBoundWitness(value)\n && isStorageMeta(value)\n\nexport const asTransactionBoundWitness = AsObjectFactory.create(isTransactionBoundWitness)\nexport const asOptionalTransactionBoundWitness = AsObjectFactory.createOptional(isTransactionBoundWitness)\n\nexport const asTransactionBoundWitnessWithStorageMeta = AsObjectFactory.create(isTransactionBoundWitnessWithStorageMeta)\nexport const asOptionalTransactionBoundWitnessWithStorageMeta = AsObjectFactory.createOptional(isTransactionBoundWitnessWithStorageMeta)\n","export type XL1 = bigint & { readonly _tag: 'XL1' } // 1e-18\nexport type MicroXL1 = bigint & { readonly _tag: 'MicroXL1' } // 1e-12\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 xl1ToMxl1 = (value: XL1): MicroXL1 => {\n return MicroXL1(BigInt(value) * BigInt(1_000_000))\n}\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 const TransactionGasCosts = {\n byte: MicroXL1(10n),\n payloadValidation: MicroXL1(1000n),\n signatureValidation: MicroXL1(1000n),\n hashValidation: MicroXL1(100n),\n balanceValidation: MicroXL1(100n),\n} as const\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\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 { Hash, Hex } from '@xylabs/hex'\nimport { isHex } from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport { isStorageMeta } from '@xyo-network/payload-model'\n\nexport interface BlockBoundWitnessMeta {\n $epoch: number\n}\n\nexport interface BlockBoundWitnessFields {\n /** Block number */\n block: number\n /** Chain id - this should be \"0\" for the genesis block */\n chain: Hex\n /** Previous block hash if not block 0 */\n previous: Hash | null /* the previous block hash */\n /** Version of the protocol being used major * 1,000,000 + minor * 1,000 + patch */\n protocol: number\n /** Step hashes */\n step_hashes: Hex[]\n}\n\nexport type BlockBoundWitness = BoundWitness<BlockBoundWitnessFields & BlockBoundWitnessMeta>\n\nexport const isBlockBoundWitness = (value: unknown): value is BlockBoundWitness => {\n const typedObj = value as BlockBoundWitness\n return isBoundWitness(value)\n && Number.isInteger(typedObj.block)\n && isHex(typedObj.chain)\n}\n\nexport const isBlockBoundWitnessWithStorageMeta = (value: unknown): value is WithStorageMeta<BlockBoundWitness> => {\n return isBlockBoundWitness(value) && isStorageMeta(value)\n}\n\nexport const asBlockBoundWitness = AsObjectFactory.create(isBlockBoundWitness)\nexport const asOptionalBlockBoundWitness = AsObjectFactory.createOptional(isBlockBoundWitness)\n\nexport const asBlockBoundWitnessWithStorageMeta = AsObjectFactory.create(isBlockBoundWitnessWithStorageMeta)\nexport const asOptionalBlockBoundWitnessWithStorageMeta = AsObjectFactory.createOptional(isBlockBoundWitnessWithStorageMeta)\n","import type { Hex } from '@xylabs/hex'\nimport { 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 { Hex } from '@xylabs/hex'\nimport { toHex } from '@xylabs/hex'\nimport type { AccountInstance } from '@xyo-network/account-model'\nimport { getAddress } from 'ethers'\nimport { parseUnits } from 'ethers/utils'\n\nexport interface GasConfig {\n gasLimit?: number\n gasPrice?: bigint\n}\n\nexport const getDefaultGasConfig = (): GasConfig => {\n return {\n gasLimit: 2_000_000, // Set the gas limit\n gasPrice: parseUnits('100', 'gwei'),\n }\n}\n\nexport type EthAddress = Hex\n\nexport const ETH_ZERO_ADDRESS: EthAddress = '0x0000000000000000000000000000000000000000' as const\n\nexport const toEthAddress = (value: bigint | string | AccountInstance): EthAddress => {\n const address = (typeof value === 'object') ? value.address : value\n return getAddress(toHex(address, { prefix: true, bitLength: 160 })) as EthAddress\n}\n","import type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nexport const NetworkStatusSchema = 'network.xyo.chain.status' as const\nexport type NetworkStatusSchema = typeof NetworkStatusSchema\n\nexport type NetworkStatusState = 'online' | 'offline' | 'degraded' | 'unknown'\n\nexport type NetworkStatusUpdate = {\n end: number\n start: number\n update: string\n}\n\nexport interface NetworkStatusFields {\n description: string\n state: NetworkStatusState\n updates?: NetworkStatusUpdate[]\n}\n\nexport type NetworkStatus = Payload<NetworkStatusFields, NetworkStatusSchema>\n\nexport const isNetworkStatus = isPayloadOfSchemaType<NetworkStatus>(NetworkStatusSchema)\n","import type { Address } from '@xylabs/hex'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nexport const ChainIdentificationPayloadSchema = 'network.xyo.chain.identification' as const\nexport type ChainIdentificationPayloadSchema = typeof ChainIdentificationPayloadSchema\n\n/**\n * Identification required to uniquely identify a chain\n */\nexport interface ChainIdentification {\n /** @field the id of the chain */\n id: Address\n}\n\nexport type ChainIdentificationPayload = Payload<ChainIdentification, ChainIdentificationPayloadSchema>\nexport const isChainIdentificationPayload = isPayloadOfSchemaType<ChainIdentificationPayload>(ChainIdentificationPayloadSchema)\n","import type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nexport const ChainInformationPayloadSchema = 'network.xyo.chain.information' as const\nexport type ChainInformationPayloadSchema = typeof ChainInformationPayloadSchema\n\nimport type { ChainIdentification } from './ChainIdentification.ts'\n\n/**\n * Information required to produce a chain\n */\nexport interface ChainInformation extends ChainIdentification {\n // TODO: Add these fields which are currently promises on the smart contract\n // forkedAtBlockNumber: bigint\n // forkedAtHash: Hash\n // forkedChainId: Address\n}\n\nexport type ChainInformationPayload = Payload<ChainIdentification, ChainInformationPayloadSchema>\nexport const isChainInformationPayload = isPayloadOfSchemaType<ChainInformationPayload>(ChainInformationPayloadSchema)\n","import type { Hash } from '@xylabs/hex'\nimport type { JsonValue } from '@xylabs/object'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { Payload, WithStorageMeta } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType, isStorageMeta } from '@xyo-network/payload-model'\n\nexport interface ChainIndexingServiceStateFields<T extends JsonValue = JsonValue> {\n /**\n * The hash of the last block that this service has indexing\n */\n endBlockHash: Hash\n /**\n * The hash of the block that the service started indexing. If undefined, the service is\n * assumed to have started indexing from the genesis block\n */\n startBlockHash?: Hash\n /**\n * The indexed state for the range\n */\n state: T\n}\nexport const ChainIndexingServiceStateSchema = 'network.xyo.chain.indexing.service.state' as const\nexport type ChainIndexingServiceStateSchema = typeof ChainIndexingServiceStateSchema\n\n/**\n * The result of a ChainIndexingServiceState\n */\nexport type ChainIndexingServiceState<T extends JsonValue = JsonValue> = Payload<ChainIndexingServiceStateFields<T>, ChainIndexingServiceStateSchema>\n\n/**\n * Identity functions for determining if an object is an ChainIndexingServiceState\n */\nexport const isChainIndexingServiceState = <T extends JsonValue = JsonValue>(payload?: unknown): payload is ChainIndexingServiceState<T> => {\n return isPayloadOfSchemaType<ChainIndexingServiceState<T>>(ChainIndexingServiceStateSchema)(payload)\n}\nexport const asChainIndexingServiceState = AsObjectFactory.create<ChainIndexingServiceState<JsonValue>>(isChainIndexingServiceState)\n\nexport const isChainIndexingServiceStateWithStorageMeta\n= <T extends JsonValue = JsonValue>(value: unknown): value is WithStorageMeta<ChainIndexingServiceState<T>> =>\n isChainIndexingServiceState<T>(value) && isStorageMeta(value)\n\nexport const asChainIndexingServiceStateWithStorageMeta\n= AsObjectFactory.create<WithStorageMeta<ChainIndexingServiceState>>(isChainIndexingServiceStateWithStorageMeta)\n\nexport const asOptionalChainIndexingServiceStateWithStorageMeta\n= AsObjectFactory.createOptional<WithStorageMeta<ChainIndexingServiceState>>(isChainIndexingServiceStateWithStorageMeta)\n","export const StepSizes = [10, 105, 1103, 11_576, 121_551, 1_276_282, 13_400_956]\n"],"mappings":";AAAA,SAAS,0BAA0B;AAEnC,SAAS,mBAAmB,gBAAgB;AAE5C,SAAS,iBAAiB,oBAAoB;;;ACJ9C,SAAS,uBAAuB;AAEhC,SAAS,6BAA6B;AAK/B,IAAM,yBAAyB;AAc/B,IAAM,qBAAqB,CAAC,MAA8C;AAC/E,SAAO,sBAAwC,sBAAsB,EAAE,CAAC,KACnE,qBAAqB,EAAE,GAAG,MAAM,UAChC,qBAAqB,EAAE,GAAG,MAAM;AACvC;AACO,IAAM,qBAAqB,gBAAgB,OAAO,kBAAkB;AACpE,IAAM,6BAA6B,gBAAgB,eAAe,kBAAkB;AAE3F,IAAM,uBAAuB,CAAC,QAAgB;AAC5C,SAAQ,OAAO,UAAU,GAAG,KAAK,OAAO,IAAK,MAAM;AACrD;;;AC7BA,SAAS,oBAAoB;AAOtB,IAAM,UAAU,CAAC,UAAwC;AAC9D,SAAQ,MAAqB,SAAS;AACxC;AASO,IAAM,eAAe,CAAwB,UAAiD;AACnG,SAAO,aAAa,KAAK,KAAK,MAAM,QAAS,MAAsC,MAAM;AAC3F;AAEO,IAAM,eAAe,CAAwB,UAAoD;AACtG,SAAO,aAAa,KAAK,IACrB,QACA;AACN;;;AC3BA,SAAS,mBAAAA,wBAAuB;AAEhC,SAAS,yBAAAC,8BAA6B;AAE/B,IAAM,aAAa;AASnB,IAAM,gBA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M,gCAAgC;AAgBtC,IAAM,4BAA4BA,uBAA+C,6BAA6B;;;ACjBrH,SAAS,mBAAAC,wBAAuB;AAEhC,SAAS,yBAAAC,wBAAuB,iBAAAC,sBAAqB;AAiB9C,IAAM,kCAAkC;AAWxC,IAAM,8BAA8B,CAAkC,YAA+D;AAC1I,SAAOD,uBAAoD,+BAA+B,EAAE,OAAO;AACrG;AACO,IAAM,8BAA8BD,iBAAgB,OAA6C,2BAA2B;AAE5H,IAAM,6CACX,CAAkC,UAClC,4BAA+B,KAAK,KAAKE,eAAc,KAAK;AAEvD,IAAM,6CACXF,iBAAgB,OAAmD,0CAA0C;AAExG,IAAM,qDACXA,iBAAgB,eAA2D,0CAA0C;;;AC7ChH,IAAM,YAAY,CAAC,IAAI,KAAK,MAAM,OAAQ,QAAS,SAAW,QAAU;","names":["AsObjectFactory","isPayloadOfSchemaType","AsObjectFactory","isPayloadOfSchemaType","AsObjectFactory","AsObjectFactory","isBoundWitness","isStorageMeta","AsObjectFactory","isPayloadOfSchemaType","isPayloadOfSchemaType","isPayloadOfSchemaType","isPayloadOfSchemaType","AsObjectFactory","isPayloadOfSchemaType","isStorageMeta"]}
|
package/dist/node/index.mjs
CHANGED
|
@@ -64,6 +64,37 @@ var asOptionalTransactionBoundWitness = AsObjectFactory4.createOptional(isTransa
|
|
|
64
64
|
var asTransactionBoundWitnessWithStorageMeta = AsObjectFactory4.create(isTransactionBoundWitnessWithStorageMeta);
|
|
65
65
|
var asOptionalTransactionBoundWitnessWithStorageMeta = AsObjectFactory4.createOptional(isTransactionBoundWitnessWithStorageMeta);
|
|
66
66
|
|
|
67
|
+
// src/Xl1.ts
|
|
68
|
+
var XL1 = (value) => value;
|
|
69
|
+
var MicroXL1 = (value) => value;
|
|
70
|
+
var mXl1ToXl1 = (value) => {
|
|
71
|
+
return XL1(BigInt(value) / BigInt(1e6));
|
|
72
|
+
};
|
|
73
|
+
var xl1ToMxl1 = (value) => {
|
|
74
|
+
return MicroXL1(BigInt(value) * BigInt(1e6));
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// src/transaction/TransactionFeesFields.ts
|
|
78
|
+
var TransactionGasCosts = {
|
|
79
|
+
byte: MicroXL1(10n),
|
|
80
|
+
payloadValidation: MicroXL1(1000n),
|
|
81
|
+
signatureValidation: MicroXL1(1000n),
|
|
82
|
+
hashValidation: MicroXL1(100n),
|
|
83
|
+
balanceValidation: MicroXL1(100n)
|
|
84
|
+
};
|
|
85
|
+
var minTransactionFees = {
|
|
86
|
+
base: MicroXL1(1000n),
|
|
87
|
+
gasPrice: MicroXL1(1n),
|
|
88
|
+
gasLimit: MicroXL1(1000n),
|
|
89
|
+
priority: MicroXL1(0n)
|
|
90
|
+
};
|
|
91
|
+
var defaultTransactionFees = {
|
|
92
|
+
base: minTransactionFees.base,
|
|
93
|
+
gasPrice: MicroXL1(10n),
|
|
94
|
+
gasLimit: MicroXL1(1000000n),
|
|
95
|
+
priority: MicroXL1(0n)
|
|
96
|
+
};
|
|
97
|
+
|
|
67
98
|
// src/block/AllowedBlockPayload.ts
|
|
68
99
|
var AllowedBlockPayloadSchemas = [TransferSchema, ChainStakeIntentSchema, SchemaSchema, BoundWitnessSchema, HashSchema];
|
|
69
100
|
var isAllowedBlockPayloadSchema = (value) => {
|
|
@@ -162,9 +193,12 @@ export {
|
|
|
162
193
|
ChainStakeIntentSchema,
|
|
163
194
|
ETH_ZERO_ADDRESS,
|
|
164
195
|
HashSchema,
|
|
196
|
+
MicroXL1,
|
|
165
197
|
NetworkStatusSchema,
|
|
166
198
|
StepSizes,
|
|
199
|
+
TransactionGasCosts,
|
|
167
200
|
TransferSchema,
|
|
201
|
+
XL1,
|
|
168
202
|
asBlockBoundWitness,
|
|
169
203
|
asBlockBoundWitnessWithStorageMeta,
|
|
170
204
|
asBlockNumber,
|
|
@@ -188,6 +222,7 @@ export {
|
|
|
188
222
|
asTransactionBoundWitness,
|
|
189
223
|
asTransactionBoundWitnessWithStorageMeta,
|
|
190
224
|
asTransfer,
|
|
225
|
+
defaultTransactionFees,
|
|
191
226
|
getDefaultGasConfig,
|
|
192
227
|
hasFrom,
|
|
193
228
|
isAllowedBlockPayload,
|
|
@@ -211,6 +246,9 @@ export {
|
|
|
211
246
|
isTransactionBoundWitness,
|
|
212
247
|
isTransactionBoundWitnessWithStorageMeta,
|
|
213
248
|
isTransfer,
|
|
214
|
-
|
|
249
|
+
mXl1ToXl1,
|
|
250
|
+
minTransactionFees,
|
|
251
|
+
toEthAddress,
|
|
252
|
+
xl1ToMxl1
|
|
215
253
|
};
|
|
216
254
|
//# sourceMappingURL=index.mjs.map
|
package/dist/node/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/block/AllowedBlockPayload.ts","../../src/payload/elevatable/ChainStakeIntent.ts","../../src/payload/elevatable/Executable.ts","../../src/payload/elevatable/Hash.ts","../../src/payload/elevatable/TransferPayload.ts","../../src/transaction/TransactionBoundWitness.ts","../../src/block/BlockBoundWitness.ts","../../src/BlockNumber.ts","../../src/ethereum.ts","../../src/network/Status.ts","../../src/services/Chain/ChainIdentification.ts","../../src/services/Chain/ChainInformation.ts","../../src/services/stakeIntent/ChainIndexingServiceStateSchema.ts","../../src/Steps.ts"],"sourcesContent":["import { BoundWitnessSchema } from '@xyo-network/boundwitness-model'\nimport type { Schema, WithStorageMeta } from '@xyo-network/payload-model'\nimport { isHashStorageMeta, isSchema } from '@xyo-network/payload-model'\nimport type { SchemaPayload } from '@xyo-network/schema-payload-plugin'\nimport { isSchemaPayload, SchemaSchema } from '@xyo-network/schema-payload-plugin'\n\nimport type {\n ChainStakeIntent, HashPayload, Transfer,\n} from '../payload/index.ts'\nimport {\n ChainStakeIntentSchema, HashSchema, isChainStakeIntent, isHashPayload, isTransfer, TransferSchema,\n} from '../payload/index.ts'\nimport { isTransactionBoundWitness, type TransactionBoundWitness } from '../transaction/index.ts'\n\nexport type AllowedBlockPayload = Transfer | ChainStakeIntent | SchemaPayload | TransactionBoundWitness | HashPayload\nexport const AllowedBlockPayloadSchemas: Schema[] = [TransferSchema, ChainStakeIntentSchema, SchemaSchema, BoundWitnessSchema, HashSchema]\nexport type AllowedBlockPayloadSchema = typeof AllowedBlockPayloadSchemas[number]\n\nexport const isAllowedBlockPayloadSchema = (value: unknown): value is AllowedBlockPayloadSchema => {\n return isSchema(value) && AllowedBlockPayloadSchemas.includes(value)\n}\n\nexport const isAllowedBlockPayload = (value: unknown): value is AllowedBlockPayload => {\n return isTransfer(value) || isChainStakeIntent(value) || isSchemaPayload(value) || isTransactionBoundWitness(value) || isHashPayload(value)\n}\n\nexport const isAllowedBlockPayloadWithHashStorageMeta = (value: unknown): value is WithStorageMeta<AllowedBlockPayload> => {\n return isAllowedBlockPayload(value) && isHashStorageMeta(value)\n}\n","import { AsObjectFactory } from '@xylabs/object'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nimport type { BlockDuration } from '../../BlockDuration.ts'\nimport type { FromFields } from './Executable.ts'\n\nexport const ChainStakeIntentSchema = 'network.xyo.chain.stake.intent' as const\nexport type ChainStakeIntentSchema = typeof ChainStakeIntentSchema\n\nexport type Intent = 'producer' // | 'bank'\n\nexport interface ChainStakeIntentFields extends BlockDuration, FromFields {\n /*\n * The intent of the staking\n */\n intent: Intent\n}\n\nexport type ChainStakeIntent = Payload<ChainStakeIntentFields, ChainStakeIntentSchema>\n\nexport const isChainStakeIntent = (x?: unknown | null): x is ChainStakeIntent => {\n return isPayloadOfSchemaType<ChainStakeIntent>(ChainStakeIntentSchema)(x)\n && asNonNegativeInteger(x.nbf) !== undefined\n && asNonNegativeInteger(x.exp) !== undefined\n}\nexport const asChainStakeIntent = AsObjectFactory.create(isChainStakeIntent)\nexport const asOptionalChainStakeIntent = AsObjectFactory.createOptional(isChainStakeIntent)\n\nconst asNonNegativeInteger = (num: number) => {\n return (Number.isInteger(num) && num >= 0) ? num : undefined\n}\n","import type { Address } from '@xylabs/hex'\nimport type { EmptyObject } from '@xylabs/object'\nimport { isAnyPayload } from '@xyo-network/payload-model'\n\nexport interface FromFields {\n // the address that is treated as the source of this action\n from: Address\n}\n\nexport const hasFrom = (value: unknown): value is FromFields => {\n return (value as FromFields).from !== undefined\n}\n\nexport interface ExecutableFields {\n script: string[]\n}\n\nexport type Executable<T extends EmptyObject = EmptyObject> = T & ExecutableFields\nexport type OptionalExecutable<T extends EmptyObject = EmptyObject> = T & Partial<ExecutableFields>\n\nexport const isExecutable = <T extends EmptyObject>(value: T | undefined): value is Executable<T> => {\n return isAnyPayload(value) && Array.isArray((value as unknown as ExecutableFields).script)\n}\n\nexport const asExecutable = <T extends EmptyObject>(value: T | undefined): Executable<T> | undefined => {\n return isExecutable(value)\n ? value as unknown as Executable<T>\n : undefined\n}\n","import type { Hash } from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nexport const HashSchema = 'network.xyo.hash' as const\nexport type HashSchema = typeof HashSchema\n\nexport interface HashFields {\n hash: Hash\n}\n\nexport type HashPayload = Payload<HashFields, HashSchema>\n\nexport const isHashPayload = isPayloadOfSchemaType<HashPayload>(HashSchema)\n\nexport const asHashPayload = AsObjectFactory.create(isHashPayload)\nexport const asHashPayloadWithStorageMeta = AsObjectFactory.create(isHashPayload)\nexport const asOptionalHashPayload = AsObjectFactory.createOptional(isHashPayload)\n","import type {\n Address,\n Hex,\n} from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nimport type { FromFields } from './Executable.ts'\n\nexport const TransferSchema = 'network.xyo.transfer' as const\nexport type TransferSchema = typeof TransferSchema\n\nexport interface TransferFields extends FromFields {\n epoch: number\n // the amount that is being sent to another address\n transfers: Record<Address, Hex>\n}\n\n// if this payload is included in a boundwitness, it needs to be available for inspection to be included in block\nexport type Transfer = Payload<TransferFields, TransferSchema>\n\nexport const isTransfer = isPayloadOfSchemaType<Transfer>(TransferSchema)\n\nexport const asTransfer = AsObjectFactory.create(isTransfer)\nexport const asOptionalTransfer = AsObjectFactory.createOptional(isTransfer)\n","import type { Address } from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { BoundWitness, Signed } from '@xyo-network/boundwitness-model'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport { isStorageMeta } from '@xyo-network/payload-model'\n\nimport type { BlockDuration } from '../BlockDuration.ts'\nimport type { FromFields, OptionalExecutable } from '../payload/index.ts'\nimport type { TransactionFeesFields } from './TransactionFeesFields.ts'\n\nexport interface TransactionBoundWitnessFields extends BlockDuration, TransactionFeesFields {\n chain: Address\n}\n\nexport type TransactionBoundWitness = BoundWitness<TransactionBoundWitnessFields & OptionalExecutable & FromFields>\n\nexport const isTransactionBoundWitness = (value: unknown): value is TransactionBoundWitness => {\n const typedObj = value as TransactionBoundWitness\n return isBoundWitness(value)\n && typedObj.chain !== undefined\n && typedObj.fees !== undefined\n && typedObj.exp !== undefined\n && typedObj.nbf !== undefined\n}\n\nexport const isSignedTransactionBoundWitness = (value: unknown): value is Signed<TransactionBoundWitness> => {\n return isTransactionBoundWitness(value) && isSigned(value)\n}\n\nexport const isSigned = <T extends BoundWitness = BoundWitness>(value: unknown): value is Signed<T> =>\n isBoundWitness(value)\n && value.$signatures.length === value.addresses.length\n && value.addresses.length > 0\n\nexport const isTransactionBoundWitnessWithStorageMeta = (value: unknown): value is WithStorageMeta<TransactionBoundWitness> =>\n isTransactionBoundWitness(value)\n && isStorageMeta(value)\n\nexport const isSignedTransactionBoundWitnessWithStorageMeta = (value: unknown): value is WithStorageMeta<Signed<TransactionBoundWitness>> =>\n isSignedTransactionBoundWitness(value)\n && isStorageMeta(value)\n\nexport const asTransactionBoundWitness = AsObjectFactory.create(isTransactionBoundWitness)\nexport const asOptionalTransactionBoundWitness = AsObjectFactory.createOptional(isTransactionBoundWitness)\n\nexport const asTransactionBoundWitnessWithStorageMeta = AsObjectFactory.create(isTransactionBoundWitnessWithStorageMeta)\nexport const asOptionalTransactionBoundWitnessWithStorageMeta = AsObjectFactory.createOptional(isTransactionBoundWitnessWithStorageMeta)\n","import type { Hash, Hex } from '@xylabs/hex'\nimport { isHex } from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport { isStorageMeta } from '@xyo-network/payload-model'\n\nexport interface BlockBoundWitnessMeta {\n $epoch: number\n}\n\nexport interface BlockBoundWitnessFields {\n /** Block number */\n block: number\n /** Chain id - this should be \"0\" for the genesis block */\n chain: Hex\n /** Previous block hash if not block 0 */\n previous: Hash | null /* the previous block hash */\n /** Version of the protocol being used major * 1,000,000 + minor * 1,000 + patch */\n protocol: number\n /** Step hashes */\n step_hashes: Hex[]\n}\n\nexport type BlockBoundWitness = BoundWitness<BlockBoundWitnessFields & BlockBoundWitnessMeta>\n\nexport const isBlockBoundWitness = (value: unknown): value is BlockBoundWitness => {\n const typedObj = value as BlockBoundWitness\n return isBoundWitness(value)\n && Number.isInteger(typedObj.block)\n && isHex(typedObj.chain)\n}\n\nexport const isBlockBoundWitnessWithStorageMeta = (value: unknown): value is WithStorageMeta<BlockBoundWitness> => {\n return isBlockBoundWitness(value) && isStorageMeta(value)\n}\n\nexport const asBlockBoundWitness = AsObjectFactory.create(isBlockBoundWitness)\nexport const asOptionalBlockBoundWitness = AsObjectFactory.createOptional(isBlockBoundWitness)\n\nexport const asBlockBoundWitnessWithStorageMeta = AsObjectFactory.create(isBlockBoundWitnessWithStorageMeta)\nexport const asOptionalBlockBoundWitnessWithStorageMeta = AsObjectFactory.createOptional(isBlockBoundWitnessWithStorageMeta)\n","import type { Hex } from '@xylabs/hex'\nimport { 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 { Hex } from '@xylabs/hex'\nimport { toHex } from '@xylabs/hex'\nimport type { AccountInstance } from '@xyo-network/account-model'\nimport { getAddress } from 'ethers'\nimport { parseUnits } from 'ethers/utils'\n\nexport interface GasConfig {\n gasLimit?: number\n gasPrice?: bigint\n}\n\nexport const getDefaultGasConfig = (): GasConfig => {\n return {\n gasLimit: 2_000_000, // Set the gas limit\n gasPrice: parseUnits('100', 'gwei'),\n }\n}\n\nexport type EthAddress = Hex\n\nexport const ETH_ZERO_ADDRESS: EthAddress = '0x0000000000000000000000000000000000000000' as const\n\nexport const toEthAddress = (value: bigint | string | AccountInstance): EthAddress => {\n const address = (typeof value === 'object') ? value.address : value\n return getAddress(toHex(address, { prefix: true, bitLength: 160 })) as EthAddress\n}\n","import type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nexport const NetworkStatusSchema = 'network.xyo.chain.status' as const\nexport type NetworkStatusSchema = typeof NetworkStatusSchema\n\nexport type NetworkStatusState = 'online' | 'offline' | 'degraded' | 'unknown'\n\nexport type NetworkStatusUpdate = {\n end: number\n start: number\n update: string\n}\n\nexport interface NetworkStatusFields {\n description: string\n state: NetworkStatusState\n updates?: NetworkStatusUpdate[]\n}\n\nexport type NetworkStatus = Payload<NetworkStatusFields, NetworkStatusSchema>\n\nexport const isNetworkStatus = isPayloadOfSchemaType<NetworkStatus>(NetworkStatusSchema)\n","import type { Address } from '@xylabs/hex'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nexport const ChainIdentificationPayloadSchema = 'network.xyo.chain.identification' as const\nexport type ChainIdentificationPayloadSchema = typeof ChainIdentificationPayloadSchema\n\n/**\n * Identification required to uniquely identify a chain\n */\nexport interface ChainIdentification {\n /** @field the id of the chain */\n id: Address\n}\n\nexport type ChainIdentificationPayload = Payload<ChainIdentification, ChainIdentificationPayloadSchema>\nexport const isChainIdentificationPayload = isPayloadOfSchemaType<ChainIdentificationPayload>(ChainIdentificationPayloadSchema)\n","import type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nexport const ChainInformationPayloadSchema = 'network.xyo.chain.information' as const\nexport type ChainInformationPayloadSchema = typeof ChainInformationPayloadSchema\n\nimport type { ChainIdentification } from './ChainIdentification.ts'\n\n/**\n * Information required to produce a chain\n */\nexport interface ChainInformation extends ChainIdentification {\n // TODO: Add these fields which are currently promises on the smart contract\n // forkedAtBlockNumber: bigint\n // forkedAtHash: Hash\n // forkedChainId: Address\n}\n\nexport type ChainInformationPayload = Payload<ChainIdentification, ChainInformationPayloadSchema>\nexport const isChainInformationPayload = isPayloadOfSchemaType<ChainInformationPayload>(ChainInformationPayloadSchema)\n","import type { Hash } from '@xylabs/hex'\nimport type { JsonValue } from '@xylabs/object'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { Payload, WithStorageMeta } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType, isStorageMeta } from '@xyo-network/payload-model'\n\nexport interface ChainIndexingServiceStateFields<T extends JsonValue = JsonValue> {\n /**\n * The hash of the last block that this service has indexing\n */\n endBlockHash: Hash\n /**\n * The hash of the block that the service started indexing. If undefined, the service is\n * assumed to have started indexing from the genesis block\n */\n startBlockHash?: Hash\n /**\n * The indexed state for the range\n */\n state: T\n}\nexport const ChainIndexingServiceStateSchema = 'network.xyo.chain.indexing.service.state' as const\nexport type ChainIndexingServiceStateSchema = typeof ChainIndexingServiceStateSchema\n\n/**\n * The result of a ChainIndexingServiceState\n */\nexport type ChainIndexingServiceState<T extends JsonValue = JsonValue> = Payload<ChainIndexingServiceStateFields<T>, ChainIndexingServiceStateSchema>\n\n/**\n * Identity functions for determining if an object is an ChainIndexingServiceState\n */\nexport const isChainIndexingServiceState = <T extends JsonValue = JsonValue>(payload?: unknown): payload is ChainIndexingServiceState<T> => {\n return isPayloadOfSchemaType<ChainIndexingServiceState<T>>(ChainIndexingServiceStateSchema)(payload)\n}\nexport const asChainIndexingServiceState = AsObjectFactory.create<ChainIndexingServiceState<JsonValue>>(isChainIndexingServiceState)\n\nexport const isChainIndexingServiceStateWithStorageMeta\n= <T extends JsonValue = JsonValue>(value: unknown): value is WithStorageMeta<ChainIndexingServiceState<T>> =>\n isChainIndexingServiceState<T>(value) && isStorageMeta(value)\n\nexport const asChainIndexingServiceStateWithStorageMeta\n= AsObjectFactory.create<WithStorageMeta<ChainIndexingServiceState>>(isChainIndexingServiceStateWithStorageMeta)\n\nexport const asOptionalChainIndexingServiceStateWithStorageMeta\n= AsObjectFactory.createOptional<WithStorageMeta<ChainIndexingServiceState>>(isChainIndexingServiceStateWithStorageMeta)\n","export const Step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,uBAAqC,mBAAmB;;;ACpBvF,SAAS,yBAAAC,8BAA6B;AAE/B,IAAM,mCAAmC;AAYzC,IAAM,+BAA+BA,uBAAkD,gCAAgC;;;ACf9H,SAAS,yBAAAC,8BAA6B;AAE/B,IAAM,gCAAgC;AAgBtC,IAAM,4BAA4BA,uBAA+C,6BAA6B;;;ACjBrH,SAAS,mBAAAC,wBAAuB;AAEhC,SAAS,yBAAAC,wBAAuB,iBAAAC,sBAAqB;AAiB9C,IAAM,kCAAkC;AAWxC,IAAM,8BAA8B,CAAkC,YAA+D;AAC1I,SAAOD,uBAAoD,+BAA+B,EAAE,OAAO;AACrG;AACO,IAAM,8BAA8BD,iBAAgB,OAA6C,2BAA2B;AAE5H,IAAM,6CACX,CAAkC,UAClC,4BAA+B,KAAK,KAAKE,eAAc,KAAK;AAEvD,IAAM,6CACXF,iBAAgB,OAAmD,0CAA0C;AAExG,IAAM,qDACXA,iBAAgB,eAA2D,0CAA0C;;;AC7ChH,IAAM,YAAY,CAAC,IAAI,KAAK,MAAM,OAAQ,QAAS,SAAW,QAAU;","names":["AsObjectFactory","isPayloadOfSchemaType","AsObjectFactory","isPayloadOfSchemaType","AsObjectFactory","AsObjectFactory","isBoundWitness","isStorageMeta","AsObjectFactory","isPayloadOfSchemaType","isPayloadOfSchemaType","isPayloadOfSchemaType","isPayloadOfSchemaType","AsObjectFactory","isPayloadOfSchemaType","isStorageMeta"]}
|
|
1
|
+
{"version":3,"sources":["../../src/block/AllowedBlockPayload.ts","../../src/payload/elevatable/ChainStakeIntent.ts","../../src/payload/elevatable/Executable.ts","../../src/payload/elevatable/Hash.ts","../../src/payload/elevatable/TransferPayload.ts","../../src/transaction/TransactionBoundWitness.ts","../../src/Xl1.ts","../../src/transaction/TransactionFeesFields.ts","../../src/block/BlockBoundWitness.ts","../../src/BlockNumber.ts","../../src/ethereum.ts","../../src/network/Status.ts","../../src/services/Chain/ChainIdentification.ts","../../src/services/Chain/ChainInformation.ts","../../src/services/stakeIntent/ChainIndexingServiceStateSchema.ts","../../src/Steps.ts"],"sourcesContent":["import { BoundWitnessSchema } from '@xyo-network/boundwitness-model'\nimport type { Schema, WithStorageMeta } from '@xyo-network/payload-model'\nimport { isHashStorageMeta, isSchema } from '@xyo-network/payload-model'\nimport type { SchemaPayload } from '@xyo-network/schema-payload-plugin'\nimport { isSchemaPayload, SchemaSchema } from '@xyo-network/schema-payload-plugin'\n\nimport type {\n ChainStakeIntent, HashPayload, Transfer,\n} from '../payload/index.ts'\nimport {\n ChainStakeIntentSchema, HashSchema, isChainStakeIntent, isHashPayload, isTransfer, TransferSchema,\n} from '../payload/index.ts'\nimport { isTransactionBoundWitness, type TransactionBoundWitness } from '../transaction/index.ts'\n\nexport type AllowedBlockPayload = Transfer | ChainStakeIntent | SchemaPayload | TransactionBoundWitness | HashPayload\nexport const AllowedBlockPayloadSchemas: Schema[] = [TransferSchema, ChainStakeIntentSchema, SchemaSchema, BoundWitnessSchema, HashSchema]\nexport type AllowedBlockPayloadSchema = typeof AllowedBlockPayloadSchemas[number]\n\nexport const isAllowedBlockPayloadSchema = (value: unknown): value is AllowedBlockPayloadSchema => {\n return isSchema(value) && AllowedBlockPayloadSchemas.includes(value)\n}\n\nexport const isAllowedBlockPayload = (value: unknown): value is AllowedBlockPayload => {\n return isTransfer(value) || isChainStakeIntent(value) || isSchemaPayload(value) || isTransactionBoundWitness(value) || isHashPayload(value)\n}\n\nexport const isAllowedBlockPayloadWithHashStorageMeta = (value: unknown): value is WithStorageMeta<AllowedBlockPayload> => {\n return isAllowedBlockPayload(value) && isHashStorageMeta(value)\n}\n","import { AsObjectFactory } from '@xylabs/object'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nimport type { BlockDuration } from '../../BlockDuration.ts'\nimport type { FromFields } from './Executable.ts'\n\nexport const ChainStakeIntentSchema = 'network.xyo.chain.stake.intent' as const\nexport type ChainStakeIntentSchema = typeof ChainStakeIntentSchema\n\nexport type Intent = 'producer' // | 'bank'\n\nexport interface ChainStakeIntentFields extends BlockDuration, FromFields {\n /*\n * The intent of the staking\n */\n intent: Intent\n}\n\nexport type ChainStakeIntent = Payload<ChainStakeIntentFields, ChainStakeIntentSchema>\n\nexport const isChainStakeIntent = (x?: unknown | null): x is ChainStakeIntent => {\n return isPayloadOfSchemaType<ChainStakeIntent>(ChainStakeIntentSchema)(x)\n && asNonNegativeInteger(x.nbf) !== undefined\n && asNonNegativeInteger(x.exp) !== undefined\n}\nexport const asChainStakeIntent = AsObjectFactory.create(isChainStakeIntent)\nexport const asOptionalChainStakeIntent = AsObjectFactory.createOptional(isChainStakeIntent)\n\nconst asNonNegativeInteger = (num: number) => {\n return (Number.isInteger(num) && num >= 0) ? num : undefined\n}\n","import type { Address } from '@xylabs/hex'\nimport type { EmptyObject } from '@xylabs/object'\nimport { isAnyPayload } from '@xyo-network/payload-model'\n\nexport interface FromFields {\n // the address that is treated as the source of this action\n from: Address\n}\n\nexport const hasFrom = (value: unknown): value is FromFields => {\n return (value as FromFields).from !== undefined\n}\n\nexport interface ExecutableFields {\n script: string[]\n}\n\nexport type Executable<T extends EmptyObject = EmptyObject> = T & ExecutableFields\nexport type OptionalExecutable<T extends EmptyObject = EmptyObject> = T & Partial<ExecutableFields>\n\nexport const isExecutable = <T extends EmptyObject>(value: T | undefined): value is Executable<T> => {\n return isAnyPayload(value) && Array.isArray((value as unknown as ExecutableFields).script)\n}\n\nexport const asExecutable = <T extends EmptyObject>(value: T | undefined): Executable<T> | undefined => {\n return isExecutable(value)\n ? value as unknown as Executable<T>\n : undefined\n}\n","import type { Hash } from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nexport const HashSchema = 'network.xyo.hash' as const\nexport type HashSchema = typeof HashSchema\n\nexport interface HashFields {\n hash: Hash\n}\n\nexport type HashPayload = Payload<HashFields, HashSchema>\n\nexport const isHashPayload = isPayloadOfSchemaType<HashPayload>(HashSchema)\n\nexport const asHashPayload = AsObjectFactory.create(isHashPayload)\nexport const asHashPayloadWithStorageMeta = AsObjectFactory.create(isHashPayload)\nexport const asOptionalHashPayload = AsObjectFactory.createOptional(isHashPayload)\n","import type {\n Address,\n Hex,\n} from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nimport type { FromFields } from './Executable.ts'\n\nexport const TransferSchema = 'network.xyo.transfer' as const\nexport type TransferSchema = typeof TransferSchema\n\nexport interface TransferFields extends FromFields {\n epoch: number\n // the amount that is being sent to another address\n transfers: Record<Address, Hex>\n}\n\n// if this payload is included in a boundwitness, it needs to be available for inspection to be included in block\nexport type Transfer = Payload<TransferFields, TransferSchema>\n\nexport const isTransfer = isPayloadOfSchemaType<Transfer>(TransferSchema)\n\nexport const asTransfer = AsObjectFactory.create(isTransfer)\nexport const asOptionalTransfer = AsObjectFactory.createOptional(isTransfer)\n","import type { Address } from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { BoundWitness, Signed } from '@xyo-network/boundwitness-model'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport { isStorageMeta } from '@xyo-network/payload-model'\n\nimport type { BlockDuration } from '../BlockDuration.ts'\nimport type { FromFields, OptionalExecutable } from '../payload/index.ts'\nimport type { TransactionFeesFields } from './TransactionFeesFields.ts'\n\nexport interface TransactionBoundWitnessFields extends BlockDuration, TransactionFeesFields {\n chain: Address\n}\n\nexport type TransactionBoundWitness = BoundWitness<TransactionBoundWitnessFields & OptionalExecutable & FromFields>\n\nexport const isTransactionBoundWitness = (value: unknown): value is TransactionBoundWitness => {\n const typedObj = value as TransactionBoundWitness\n return isBoundWitness(value)\n && typedObj.chain !== undefined\n && typedObj.fees !== undefined\n && typedObj.exp !== undefined\n && typedObj.nbf !== undefined\n}\n\nexport const isSignedTransactionBoundWitness = (value: unknown): value is Signed<TransactionBoundWitness> => {\n return isTransactionBoundWitness(value) && isSigned(value)\n}\n\nexport const isSigned = <T extends BoundWitness = BoundWitness>(value: unknown): value is Signed<T> =>\n isBoundWitness(value)\n && value.$signatures.length === value.addresses.length\n && value.addresses.length > 0\n\nexport const isTransactionBoundWitnessWithStorageMeta = (value: unknown): value is WithStorageMeta<TransactionBoundWitness> =>\n isTransactionBoundWitness(value)\n && isStorageMeta(value)\n\nexport const isSignedTransactionBoundWitnessWithStorageMeta = (value: unknown): value is WithStorageMeta<Signed<TransactionBoundWitness>> =>\n isSignedTransactionBoundWitness(value)\n && isStorageMeta(value)\n\nexport const asTransactionBoundWitness = AsObjectFactory.create(isTransactionBoundWitness)\nexport const asOptionalTransactionBoundWitness = AsObjectFactory.createOptional(isTransactionBoundWitness)\n\nexport const asTransactionBoundWitnessWithStorageMeta = AsObjectFactory.create(isTransactionBoundWitnessWithStorageMeta)\nexport const asOptionalTransactionBoundWitnessWithStorageMeta = AsObjectFactory.createOptional(isTransactionBoundWitnessWithStorageMeta)\n","export type XL1 = bigint & { readonly _tag: 'XL1' } // 1e-18\nexport type MicroXL1 = bigint & { readonly _tag: 'MicroXL1' } // 1e-12\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 xl1ToMxl1 = (value: XL1): MicroXL1 => {\n return MicroXL1(BigInt(value) * BigInt(1_000_000))\n}\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 const TransactionGasCosts = {\n byte: MicroXL1(10n),\n payloadValidation: MicroXL1(1000n),\n signatureValidation: MicroXL1(1000n),\n hashValidation: MicroXL1(100n),\n balanceValidation: MicroXL1(100n),\n} as const\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\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 { Hash, Hex } from '@xylabs/hex'\nimport { isHex } from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport { isStorageMeta } from '@xyo-network/payload-model'\n\nexport interface BlockBoundWitnessMeta {\n $epoch: number\n}\n\nexport interface BlockBoundWitnessFields {\n /** Block number */\n block: number\n /** Chain id - this should be \"0\" for the genesis block */\n chain: Hex\n /** Previous block hash if not block 0 */\n previous: Hash | null /* the previous block hash */\n /** Version of the protocol being used major * 1,000,000 + minor * 1,000 + patch */\n protocol: number\n /** Step hashes */\n step_hashes: Hex[]\n}\n\nexport type BlockBoundWitness = BoundWitness<BlockBoundWitnessFields & BlockBoundWitnessMeta>\n\nexport const isBlockBoundWitness = (value: unknown): value is BlockBoundWitness => {\n const typedObj = value as BlockBoundWitness\n return isBoundWitness(value)\n && Number.isInteger(typedObj.block)\n && isHex(typedObj.chain)\n}\n\nexport const isBlockBoundWitnessWithStorageMeta = (value: unknown): value is WithStorageMeta<BlockBoundWitness> => {\n return isBlockBoundWitness(value) && isStorageMeta(value)\n}\n\nexport const asBlockBoundWitness = AsObjectFactory.create(isBlockBoundWitness)\nexport const asOptionalBlockBoundWitness = AsObjectFactory.createOptional(isBlockBoundWitness)\n\nexport const asBlockBoundWitnessWithStorageMeta = AsObjectFactory.create(isBlockBoundWitnessWithStorageMeta)\nexport const asOptionalBlockBoundWitnessWithStorageMeta = AsObjectFactory.createOptional(isBlockBoundWitnessWithStorageMeta)\n","import type { Hex } from '@xylabs/hex'\nimport { 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 { Hex } from '@xylabs/hex'\nimport { toHex } from '@xylabs/hex'\nimport type { AccountInstance } from '@xyo-network/account-model'\nimport { getAddress } from 'ethers'\nimport { parseUnits } from 'ethers/utils'\n\nexport interface GasConfig {\n gasLimit?: number\n gasPrice?: bigint\n}\n\nexport const getDefaultGasConfig = (): GasConfig => {\n return {\n gasLimit: 2_000_000, // Set the gas limit\n gasPrice: parseUnits('100', 'gwei'),\n }\n}\n\nexport type EthAddress = Hex\n\nexport const ETH_ZERO_ADDRESS: EthAddress = '0x0000000000000000000000000000000000000000' as const\n\nexport const toEthAddress = (value: bigint | string | AccountInstance): EthAddress => {\n const address = (typeof value === 'object') ? value.address : value\n return getAddress(toHex(address, { prefix: true, bitLength: 160 })) as EthAddress\n}\n","import type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nexport const NetworkStatusSchema = 'network.xyo.chain.status' as const\nexport type NetworkStatusSchema = typeof NetworkStatusSchema\n\nexport type NetworkStatusState = 'online' | 'offline' | 'degraded' | 'unknown'\n\nexport type NetworkStatusUpdate = {\n end: number\n start: number\n update: string\n}\n\nexport interface NetworkStatusFields {\n description: string\n state: NetworkStatusState\n updates?: NetworkStatusUpdate[]\n}\n\nexport type NetworkStatus = Payload<NetworkStatusFields, NetworkStatusSchema>\n\nexport const isNetworkStatus = isPayloadOfSchemaType<NetworkStatus>(NetworkStatusSchema)\n","import type { Address } from '@xylabs/hex'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nexport const ChainIdentificationPayloadSchema = 'network.xyo.chain.identification' as const\nexport type ChainIdentificationPayloadSchema = typeof ChainIdentificationPayloadSchema\n\n/**\n * Identification required to uniquely identify a chain\n */\nexport interface ChainIdentification {\n /** @field the id of the chain */\n id: Address\n}\n\nexport type ChainIdentificationPayload = Payload<ChainIdentification, ChainIdentificationPayloadSchema>\nexport const isChainIdentificationPayload = isPayloadOfSchemaType<ChainIdentificationPayload>(ChainIdentificationPayloadSchema)\n","import type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nexport const ChainInformationPayloadSchema = 'network.xyo.chain.information' as const\nexport type ChainInformationPayloadSchema = typeof ChainInformationPayloadSchema\n\nimport type { ChainIdentification } from './ChainIdentification.ts'\n\n/**\n * Information required to produce a chain\n */\nexport interface ChainInformation extends ChainIdentification {\n // TODO: Add these fields which are currently promises on the smart contract\n // forkedAtBlockNumber: bigint\n // forkedAtHash: Hash\n // forkedChainId: Address\n}\n\nexport type ChainInformationPayload = Payload<ChainIdentification, ChainInformationPayloadSchema>\nexport const isChainInformationPayload = isPayloadOfSchemaType<ChainInformationPayload>(ChainInformationPayloadSchema)\n","import type { Hash } from '@xylabs/hex'\nimport type { JsonValue } from '@xylabs/object'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { Payload, WithStorageMeta } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType, isStorageMeta } from '@xyo-network/payload-model'\n\nexport interface ChainIndexingServiceStateFields<T extends JsonValue = JsonValue> {\n /**\n * The hash of the last block that this service has indexing\n */\n endBlockHash: Hash\n /**\n * The hash of the block that the service started indexing. If undefined, the service is\n * assumed to have started indexing from the genesis block\n */\n startBlockHash?: Hash\n /**\n * The indexed state for the range\n */\n state: T\n}\nexport const ChainIndexingServiceStateSchema = 'network.xyo.chain.indexing.service.state' as const\nexport type ChainIndexingServiceStateSchema = typeof ChainIndexingServiceStateSchema\n\n/**\n * The result of a ChainIndexingServiceState\n */\nexport type ChainIndexingServiceState<T extends JsonValue = JsonValue> = Payload<ChainIndexingServiceStateFields<T>, ChainIndexingServiceStateSchema>\n\n/**\n * Identity functions for determining if an object is an ChainIndexingServiceState\n */\nexport const isChainIndexingServiceState = <T extends JsonValue = JsonValue>(payload?: unknown): payload is ChainIndexingServiceState<T> => {\n return isPayloadOfSchemaType<ChainIndexingServiceState<T>>(ChainIndexingServiceStateSchema)(payload)\n}\nexport const asChainIndexingServiceState = AsObjectFactory.create<ChainIndexingServiceState<JsonValue>>(isChainIndexingServiceState)\n\nexport const isChainIndexingServiceStateWithStorageMeta\n= <T extends JsonValue = JsonValue>(value: unknown): value is WithStorageMeta<ChainIndexingServiceState<T>> =>\n isChainIndexingServiceState<T>(value) && isStorageMeta(value)\n\nexport const asChainIndexingServiceStateWithStorageMeta\n= AsObjectFactory.create<WithStorageMeta<ChainIndexingServiceState>>(isChainIndexingServiceStateWithStorageMeta)\n\nexport const asOptionalChainIndexingServiceStateWithStorageMeta\n= AsObjectFactory.createOptional<WithStorageMeta<ChainIndexingServiceState>>(isChainIndexingServiceStateWithStorageMeta)\n","export const StepSizes = [10, 105, 1103, 11_576, 121_551, 1_276_282, 13_400_956]\n"],"mappings":";AAAA,SAAS,0BAA0B;AAEnC,SAAS,mBAAmB,gBAAgB;AAE5C,SAAS,iBAAiB,oBAAoB;;;ACJ9C,SAAS,uBAAuB;AAEhC,SAAS,6BAA6B;AAK/B,IAAM,yBAAyB;AAc/B,IAAM,qBAAqB,CAAC,MAA8C;AAC/E,SAAO,sBAAwC,sBAAsB,EAAE,CAAC,KACnE,qBAAqB,EAAE,GAAG,MAAM,UAChC,qBAAqB,EAAE,GAAG,MAAM;AACvC;AACO,IAAM,qBAAqB,gBAAgB,OAAO,kBAAkB;AACpE,IAAM,6BAA6B,gBAAgB,eAAe,kBAAkB;AAE3F,IAAM,uBAAuB,CAAC,QAAgB;AAC5C,SAAQ,OAAO,UAAU,GAAG,KAAK,OAAO,IAAK,MAAM;AACrD;;;AC7BA,SAAS,oBAAoB;AAOtB,IAAM,UAAU,CAAC,UAAwC;AAC9D,SAAQ,MAAqB,SAAS;AACxC;AASO,IAA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AI,CAAC,CAAC;AACpE;;;ACxBA,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;;;AC7ChH,IAAM,YAAY,CAAC,IAAI,KAAK,MAAM,OAAQ,QAAS,SAAW,QAAU;","names":["AsObjectFactory","isPayloadOfSchemaType","AsObjectFactory","isPayloadOfSchemaType","AsObjectFactory","AsObjectFactory","isBoundWitness","isStorageMeta","AsObjectFactory","isPayloadOfSchemaType","isPayloadOfSchemaType","isPayloadOfSchemaType","isPayloadOfSchemaType","AsObjectFactory","isPayloadOfSchemaType","isStorageMeta"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
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 xl1ToMxl1: (value: XL1) => MicroXL1;
|
|
11
|
+
//# sourceMappingURL=Xl1.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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,SAAS,GAAI,OAAO,GAAG,KAAG,QAEtC,CAAA"}
|
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,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,eAAe,CAAA;AAC7B,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,uBAAuB,CAAA;AACrC,cAAc,qBAAqB,CAAA;AACnC,cAAc,YAAY,CAAA;AAC1B,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,eAAe,CAAA;AAC7B,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,uBAAuB,CAAA;AACrC,cAAc,qBAAqB,CAAA;AACnC,cAAc,YAAY,CAAA;AAC1B,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,UAAU,CAAA"}
|
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
import type { Hex } from '@xylabs/hex';
|
|
2
|
+
import { MicroXL1 } from '../Xl1.ts';
|
|
2
3
|
export interface TransactionFeesBigInt {
|
|
3
|
-
base:
|
|
4
|
-
gasLimit:
|
|
5
|
-
gasPrice:
|
|
6
|
-
priority:
|
|
4
|
+
base: MicroXL1;
|
|
5
|
+
gasLimit: MicroXL1;
|
|
6
|
+
gasPrice: MicroXL1;
|
|
7
|
+
priority: MicroXL1;
|
|
7
8
|
}
|
|
9
|
+
export declare const TransactionGasCosts: {
|
|
10
|
+
readonly byte: MicroXL1;
|
|
11
|
+
readonly payloadValidation: MicroXL1;
|
|
12
|
+
readonly signatureValidation: MicroXL1;
|
|
13
|
+
readonly hashValidation: MicroXL1;
|
|
14
|
+
readonly balanceValidation: MicroXL1;
|
|
15
|
+
};
|
|
8
16
|
export type TransactionFeesHex = {
|
|
9
17
|
[K in keyof TransactionFeesBigInt]: Hex;
|
|
10
18
|
};
|
|
11
19
|
export interface TransactionFeesFields {
|
|
12
20
|
fees: TransactionFeesHex;
|
|
13
21
|
}
|
|
22
|
+
export declare const minTransactionFees: TransactionFeesBigInt;
|
|
23
|
+
export declare const defaultTransactionFees: TransactionFeesBigInt;
|
|
14
24
|
/** Gas Calculation
|
|
15
25
|
*
|
|
16
26
|
* 1 Million microXL1 (mXL1) = 1 XL1
|
|
@@ -29,7 +39,7 @@ export interface TransactionFeesFields {
|
|
|
29
39
|
*
|
|
30
40
|
* minGasPrice is initially set to 100 mXL1
|
|
31
41
|
* minBase is initially set to 1000 mXL1
|
|
32
|
-
* minPriority is
|
|
42
|
+
* minPriority is always 0 mXL1, but can be set to increase the priority of the transaction
|
|
33
43
|
*
|
|
34
44
|
*/
|
|
35
45
|
//# sourceMappingURL=TransactionFeesFields.d.ts.map
|
|
@@ -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,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,
|
|
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,WAAW,CAAA;AAEpC,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,eAAO,MAAM,mBAAmB;;;;;;CAMtB,CAAA;AAEV,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;AAEV;;;;;;;;;;;;;;;;;;;;GAoBG"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@xyo-network/xl1-protocol",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.30",
|
|
5
5
|
"description": "XYO Layer One Protocol",
|
|
6
6
|
"homepage": "https://xylabs.com",
|
|
7
7
|
"bugs": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"ethers": "6.14.1"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@types/node": "^22.15.
|
|
49
|
+
"@types/node": "^22.15.20",
|
|
50
50
|
"@xylabs/eslint-config-flat": "^6.5.7",
|
|
51
51
|
"@xylabs/ts-scripts-yarn3": "^6.5.7",
|
|
52
52
|
"@xylabs/tsconfig": "^6.5.7",
|
package/src/Xl1.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type XL1 = bigint & { readonly _tag: 'XL1' } // 1e-18
|
|
2
|
+
export type MicroXL1 = bigint & { readonly _tag: 'MicroXL1' } // 1e-12
|
|
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 xl1ToMxl1 = (value: XL1): MicroXL1 => {
|
|
12
|
+
return MicroXL1(BigInt(value) * BigInt(1_000_000))
|
|
13
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import type { Hex } from '@xylabs/hex'
|
|
2
2
|
|
|
3
|
+
import { MicroXL1 } from '../Xl1.ts'
|
|
4
|
+
|
|
3
5
|
export interface TransactionFeesBigInt {
|
|
4
|
-
base:
|
|
5
|
-
gasLimit:
|
|
6
|
-
gasPrice:
|
|
7
|
-
priority:
|
|
6
|
+
base: MicroXL1
|
|
7
|
+
gasLimit: MicroXL1
|
|
8
|
+
gasPrice: MicroXL1
|
|
9
|
+
priority: MicroXL1
|
|
8
10
|
}
|
|
9
11
|
|
|
12
|
+
export const TransactionGasCosts = {
|
|
13
|
+
byte: MicroXL1(10n),
|
|
14
|
+
payloadValidation: MicroXL1(1000n),
|
|
15
|
+
signatureValidation: MicroXL1(1000n),
|
|
16
|
+
hashValidation: MicroXL1(100n),
|
|
17
|
+
balanceValidation: MicroXL1(100n),
|
|
18
|
+
} as const
|
|
19
|
+
|
|
10
20
|
export type TransactionFeesHex = {
|
|
11
21
|
[K in keyof TransactionFeesBigInt]: Hex;
|
|
12
22
|
}
|
|
@@ -15,6 +25,14 @@ export interface TransactionFeesFields {
|
|
|
15
25
|
fees: TransactionFeesHex
|
|
16
26
|
}
|
|
17
27
|
|
|
28
|
+
export const minTransactionFees: TransactionFeesBigInt = {
|
|
29
|
+
base: MicroXL1(1000n), gasPrice: MicroXL1(1n), gasLimit: MicroXL1(1000n), priority: MicroXL1(0n),
|
|
30
|
+
} as const
|
|
31
|
+
|
|
32
|
+
export const defaultTransactionFees: TransactionFeesBigInt = {
|
|
33
|
+
base: minTransactionFees.base, gasPrice: MicroXL1(10n), gasLimit: MicroXL1(1_000_000n), priority: MicroXL1(0n),
|
|
34
|
+
} as const
|
|
35
|
+
|
|
18
36
|
/** Gas Calculation
|
|
19
37
|
*
|
|
20
38
|
* 1 Million microXL1 (mXL1) = 1 XL1
|
|
@@ -33,6 +51,6 @@ export interface TransactionFeesFields {
|
|
|
33
51
|
*
|
|
34
52
|
* minGasPrice is initially set to 100 mXL1
|
|
35
53
|
* minBase is initially set to 1000 mXL1
|
|
36
|
-
* minPriority is
|
|
54
|
+
* minPriority is always 0 mXL1, but can be set to increase the priority of the transaction
|
|
37
55
|
*
|
|
38
56
|
*/
|