@xyo-network/xl1-protocol-sdk 1.26.11 → 1.26.13
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/package.json +29 -16
- package/src/ChainContextHelpers.ts +0 -50
- package/src/CreatableProvider/AbstractCreatableProvider.ts +0 -97
- package/src/CreatableProvider/CreatableProvider.ts +0 -102
- package/src/CreatableProvider/CreatableProviderRegistry.ts +0 -94
- package/src/CreatableProvider/GetInstanceOptions.ts +0 -11
- package/src/CreatableProvider/LabeledCreatableProviderFactory.ts +0 -24
- package/src/CreatableProvider/ProviderFactory.ts +0 -138
- package/src/CreatableProvider/ProviderFactoryLocator.ts +0 -170
- package/src/CreatableProvider/ProviderFactoryLocatorInstance.ts +0 -70
- package/src/CreatableProvider/index.ts +0 -8
- package/src/SignedBigInt.ts +0 -59
- package/src/_internal/context/getTestProviderContext.ts +0 -13
- package/src/_internal/context/index.ts +0 -1
- package/src/_internal/index.ts +0 -2
- package/src/actor/ActorV3.ts +0 -177
- package/src/actor/index.ts +0 -1
- package/src/amount/ShiftedBigInt.ts +0 -73
- package/src/amount/XL1Amount.ts +0 -103
- package/src/amount/index.ts +0 -4
- package/src/amount/splitOnDecimal.ts +0 -6
- package/src/amount/splitOnDecimalToString.ts +0 -40
- package/src/block/hydrate/allHashesPresent.ts +0 -8
- package/src/block/hydrate/blockPayloadsFromHydratedBlock.ts +0 -12
- package/src/block/hydrate/flattenHydratedBlock.ts +0 -28
- package/src/block/hydrate/flattenHydratedBlocks.ts +0 -7
- package/src/block/hydrate/hydrateBlock.ts +0 -43
- package/src/block/hydrate/index.ts +0 -7
- package/src/block/hydrate/transactionsFromHydratedBlock.ts +0 -7
- package/src/block/hydrate/tryHydrateBlock.ts +0 -26
- package/src/block/index.ts +0 -2
- package/src/block/primitives/blockFromBlockNumber.ts +0 -69
- package/src/block/primitives/frames/calculateFramesFromRange.ts +0 -30
- package/src/block/primitives/frames/deepCalculateFramesFromRange.ts +0 -28
- package/src/block/primitives/frames/index.ts +0 -2
- package/src/block/primitives/hashFromBlockNumber.ts +0 -9
- package/src/block/primitives/index.ts +0 -7
- package/src/block/primitives/model.ts +0 -18
- package/src/block/primitives/payloads/ChainWindow.ts +0 -7
- package/src/block/primitives/payloads/index.ts +0 -1
- package/src/block/primitives/toStepIdentityString.ts +0 -6
- package/src/block/primitives/validateTransactionOpcodes.ts +0 -45
- package/src/config/Actor.ts +0 -32
- package/src/config/Actors.ts +0 -9
- package/src/config/Base.ts +0 -27
- package/src/config/Chain.ts +0 -23
- package/src/config/Config.ts +0 -24
- package/src/config/DataLake/DataLake.ts +0 -12
- package/src/config/DataLake/DataLakeRemoteConfig.ts +0 -11
- package/src/config/DataLake/RestDataLakeConfig.ts +0 -18
- package/src/config/DataLake/RouterDataLakeConfig.ts +0 -22
- package/src/config/DataLake/index.ts +0 -4
- package/src/config/DeepPartial.ts +0 -4
- package/src/config/Evm.ts +0 -38
- package/src/config/HostActor.ts +0 -32
- package/src/config/Log.ts +0 -25
- package/src/config/Provider.ts +0 -20
- package/src/config/Providers.ts +0 -9
- package/src/config/Remote.ts +0 -59
- package/src/config/Telemetry.ts +0 -49
- package/src/config/UsageMeta.ts +0 -46
- package/src/config/Validation.ts +0 -29
- package/src/config/index.ts +0 -12
- package/src/config/storage/Storage.ts +0 -16
- package/src/config/storage/driver/Mongo.ts +0 -53
- package/src/config/storage/driver/index.ts +0 -1
- package/src/config/storage/index.ts +0 -2
- package/src/constants.ts +0 -4
- package/src/context/Actor.ts +0 -20
- package/src/context/HostActor.ts +0 -20
- package/src/context/getEmptyProviderContext.ts +0 -19
- package/src/context/index.ts +0 -3
- package/src/createDeclarationPayload.ts +0 -15
- package/src/createTransferPayload.ts +0 -16
- package/src/driver/cache/LruCacheMap.ts +0 -48
- package/src/driver/cache/index.ts +0 -1
- package/src/driver/index.ts +0 -2
- package/src/driver/memory/MemoryMap.ts +0 -48
- package/src/driver/memory/index.ts +0 -1
- package/src/eip-712/Payloads/EIP712Data.ts +0 -35
- package/src/eip-712/Payloads/EIP712Signature.ts +0 -32
- package/src/eip-712/Payloads/index.ts +0 -2
- package/src/eip-712/Types.ts +0 -41
- package/src/eip-712/index.ts +0 -4
- package/src/eip-712/sign.ts +0 -19
- package/src/eip-712/spec/fixtures.ts +0 -27
- package/src/eip-712/verify.ts +0 -20
- package/src/getFileConfig.ts +0 -36
- package/src/index.ts +0 -27
- package/src/instances/Address.ts +0 -16
- package/src/instances/BoundWitness.ts +0 -13
- package/src/instances/Data.ts +0 -4
- package/src/instances/Fees.ts +0 -9
- package/src/instances/HydratedBoundWitness.ts +0 -16
- package/src/instances/Object.ts +0 -6
- package/src/instances/Payload.ts +0 -7
- package/src/instances/Signature.ts +0 -12
- package/src/instances/block/BlockFields.ts +0 -18
- package/src/instances/block/HydratedBlock.ts +0 -10
- package/src/instances/block/index.ts +0 -1
- package/src/instances/index.ts +0 -10
- package/src/instances/modifiers/BlockWindowInstance.ts +0 -8
- package/src/instances/modifiers/BlockWindowState.ts +0 -6
- package/src/instances/modifiers/Signed.ts +0 -9
- package/src/instances/modifiers/Validatable.ts +0 -6
- package/src/instances/modifiers/index.ts +0 -4
- package/src/instances/transaction/HydratedTransaction.ts +0 -9
- package/src/instances/transaction/TransactionFields.ts +0 -22
- package/src/instances/transaction/index.ts +0 -1
- package/src/isInternetAvailable.ts +0 -11
- package/src/model/ChainFork/ChainForkStatic.ts +0 -9
- package/src/model/ChainFork/index.ts +0 -1
- package/src/model/ChainIdentity.ts +0 -6
- package/src/model/ChainStore.ts +0 -16
- package/src/model/CreatableProviderContext.ts +0 -6
- package/src/model/CreatableProviderContext.zod.ts +0 -55
- package/src/model/PayloadBundle/bundledPayloadToHydratedBlock.ts +0 -15
- package/src/model/PayloadBundle/bundledPayloadToHydratedTransaction.ts +0 -15
- package/src/model/PayloadBundle/hydratedBlockToPayloadBundle.ts +0 -19
- package/src/model/PayloadBundle/hydratedTransactionToPayloadBundle.ts +0 -19
- package/src/model/PayloadBundle/index.ts +0 -4
- package/src/model/index.ts +0 -6
- package/src/multipliers.ts +0 -18
- package/src/payloads/AddressPairPayload.ts +0 -27
- package/src/payloads/index.ts +0 -4
- package/src/payloads/netBalancesForPayloads.ts +0 -24
- package/src/payloads/netSchemasForPayloads.ts +0 -24
- package/src/payloads/netTransfersForPayloads.ts +0 -27
- package/src/primitives/block/index.ts +0 -2
- package/src/primitives/block/range/blockRangeSteps.ts +0 -23
- package/src/primitives/block/range/index.ts +0 -1
- package/src/primitives/block/rate/blockRate.ts +0 -77
- package/src/primitives/block/rate/index.ts +0 -4
- package/src/primitives/block/rate/stepRate.ts +0 -37
- package/src/primitives/block/rate/timeHelpers.ts +0 -61
- package/src/primitives/block/rate/timeRate.ts +0 -121
- package/src/primitives/chain/getWindowedChain.ts +0 -50
- package/src/primitives/chain/index.ts +0 -3
- package/src/primitives/chain/step/chainStepRewardAddress.ts +0 -30
- package/src/primitives/chain/step/index.ts +0 -4
- package/src/primitives/chain/step/stepRewardBlock.ts +0 -13
- package/src/primitives/chain/step/stepRewardTotal.ts +0 -46
- package/src/primitives/chain/step/stepsRewardTotal.ts +0 -37
- package/src/primitives/chain/time/externalBlockNumberFromXL1BlockNumber.ts +0 -32
- package/src/primitives/chain/time/externalBlockRangeFromStep.ts +0 -21
- package/src/primitives/chain/time/externalBlockRangeFromXL1BlockRange.ts +0 -17
- package/src/primitives/chain/time/index.ts +0 -3
- package/src/primitives/datalake/addDataLakePayloads.ts +0 -18
- package/src/primitives/datalake/addDataLakePayloadsToPayloads.ts +0 -24
- package/src/primitives/datalake/index.ts +0 -2
- package/src/primitives/index.ts +0 -13
- package/src/primitives/mapToMapType.ts +0 -35
- package/src/primitives/payload/index.ts +0 -1
- package/src/primitives/payload/mergeTransfers.ts +0 -16
- package/src/primitives/readPayloadMapFromStore.ts +0 -58
- package/src/primitives/rewardFromBlockNumber.ts +0 -19
- package/src/primitives/rewards/index.ts +0 -1
- package/src/primitives/rewards/networkStakeStepRewardPositionWeight.ts +0 -26
- package/src/primitives/stake/activeStakeAtTimeByAddress.ts +0 -27
- package/src/primitives/stake/activeStakeAtTimeByPosition.ts +0 -25
- package/src/primitives/stake/allStakersForRange.ts +0 -32
- package/src/primitives/stake/allStakersForStep.ts +0 -24
- package/src/primitives/stake/index.ts +0 -6
- package/src/primitives/stake/mergedAddRemoveStakeEventsByPosition.ts +0 -15
- package/src/primitives/stake/mergedAddRemoveStakeEventsByStaker.ts +0 -17
- package/src/primitives/stake/weightedStakeForRangeByPosition.ts +0 -69
- package/src/primitives/state/findMostRecentBlock.ts +0 -44
- package/src/primitives/state/hydratedBlockByNumber.ts +0 -25
- package/src/primitives/state/index.ts +0 -2
- package/src/primitives/step/completedStepRewardAddress.ts +0 -10
- package/src/primitives/step/derivedReceiveAddress.ts +0 -9
- package/src/primitives/step/index.ts +0 -4
- package/src/primitives/step/stepBlockRange.ts +0 -9
- package/src/primitives/step/stepTransferIndex.ts +0 -19
- package/src/primitives/transaction/elevatedPayloads.ts +0 -24
- package/src/primitives/transaction/index.ts +0 -1
- package/src/primitives/uncle/findBestUncle.ts +0 -9
- package/src/primitives/uncle/findUncles.ts +0 -75
- package/src/primitives/uncle/index.ts +0 -3
- package/src/primitives/uncle/scoreUncle.ts +0 -7
- package/src/services/AccountTransfersService.ts +0 -13
- package/src/services/BlockProducerService.ts +0 -11
- package/src/services/Chain/BaseChainService.ts +0 -4
- package/src/services/Chain/ChainHeadService.ts +0 -8
- package/src/services/Chain/ChainService.ts +0 -6
- package/src/services/Chain/index.ts +0 -3
- package/src/services/Election.ts +0 -14
- package/src/services/NetworkStakeService.ts +0 -4
- package/src/services/Params.ts +0 -13
- package/src/services/PendingTransactionsService.ts +0 -7
- package/src/services/SchemasService.ts +0 -11
- package/src/services/StakeIntentService/ChainIndexingServiceStateSchema.ts +0 -50
- package/src/services/StakeIntentService/StakeIntentService.ts +0 -35
- package/src/services/StakeIntentService/index.ts +0 -2
- package/src/services/index.ts +0 -8
- package/src/simple/StakeEventsViewer/SimpleStakeEventsViewer.ts +0 -93
- package/src/simple/StakeEventsViewer/index.ts +0 -1
- package/src/simple/StakeTotalsViewer/SimpleStakeTotalsViewer.ts +0 -116
- package/src/simple/StakeTotalsViewer/index.ts +0 -1
- package/src/simple/StakeViewer/SimpleStakeViewer.ts +0 -164
- package/src/simple/StakeViewer/index.ts +0 -1
- package/src/simple/TransactionViewer/SimpleTransactionViewer.ts +0 -100
- package/src/simple/TransactionViewer/index.ts +0 -1
- package/src/simple/accountBalance/SimpleAccountBalanceViewer.ts +0 -271
- package/src/simple/accountBalance/index.ts +0 -1
- package/src/simple/block/SimpleBlockViewer.ts +0 -231
- package/src/simple/block/index.ts +0 -1
- package/src/simple/blockInvalidation/SimpleBlockInvalidationViewer.ts +0 -197
- package/src/simple/blockInvalidation/index.ts +0 -1
- package/src/simple/blockReward/SimpleBlockRewardViewer.ts +0 -27
- package/src/simple/blockReward/index.ts +0 -1
- package/src/simple/blockValidation/SimpleBlockValidationViewer.ts +0 -194
- package/src/simple/blockValidation/index.ts +0 -1
- package/src/simple/chainContractViewer/SimpleChainContractViewer.ts +0 -92
- package/src/simple/chainContractViewer/index.ts +0 -1
- package/src/simple/client/SimpleXyoClient.ts +0 -14
- package/src/simple/client/index.ts +0 -1
- package/src/simple/datalake/AbstractRestDataLake.ts +0 -70
- package/src/simple/datalake/AbstractSimpleDataLake.ts +0 -62
- package/src/simple/datalake/RestDataLakeRunner.ts +0 -54
- package/src/simple/datalake/RestDataLakeViewer.ts +0 -22
- package/src/simple/datalake/SimpleDataLakeRunner.ts +0 -44
- package/src/simple/datalake/SimpleDataLakeViewer.ts +0 -24
- package/src/simple/datalake/index.ts +0 -4
- package/src/simple/finalization/SimpleFinalizationRunner.ts +0 -45
- package/src/simple/finalization/SimpleFinalizationViewer.ts +0 -123
- package/src/simple/finalization/index.ts +0 -2
- package/src/simple/gateway/SimpleXyoGateway.ts +0 -30
- package/src/simple/gateway/SimpleXyoGatewayRunner.ts +0 -137
- package/src/simple/gateway/index.ts +0 -2
- package/src/simple/index.ts +0 -22
- package/src/simple/mempool/SimpleMempoolRunner.ts +0 -390
- package/src/simple/mempool/SimpleMempoolViewer.ts +0 -215
- package/src/simple/mempool/index.ts +0 -2
- package/src/simple/network/SimpleXyoNetwork.ts +0 -48
- package/src/simple/network/index.ts +0 -1
- package/src/simple/network/lib/FailedNetworkStatusPayloads.ts +0 -16
- package/src/simple/network/lib/StatusNetworks.ts +0 -32
- package/src/simple/network/lib/index.ts +0 -2
- package/src/simple/permissions/SimpleXyoPermissions.ts +0 -82
- package/src/simple/permissions/index.ts +0 -2
- package/src/simple/permissions/store/MemoryPermissions.ts +0 -32
- package/src/simple/permissions/store/PermissionsStore.ts +0 -17
- package/src/simple/permissions/store/index.ts +0 -2
- package/src/simple/runner/SimpleXyoRunner.ts +0 -41
- package/src/simple/runner/index.ts +0 -1
- package/src/simple/signer/SimpleXyoSigner.ts +0 -78
- package/src/simple/signer/index.ts +0 -1
- package/src/simple/timeSync2/SimpleTimeSyncViewer.ts +0 -132
- package/src/simple/timeSync2/index.ts +0 -1
- package/src/simple/transactionInvalidation/SimpleTransactionInvalidationViewer.ts +0 -197
- package/src/simple/transactionInvalidation/index.ts +0 -1
- package/src/simple/transactionValidation/SimpleTransactionValidationViewer.ts +0 -173
- package/src/simple/transactionValidation/index.ts +0 -1
- package/src/simple/windowedBlock/SimpleWindowedBlockViewer.ts +0 -207
- package/src/simple/windowedBlock/index.ts +0 -1
- package/src/status/RuntimeStatusMonitor.ts +0 -120
- package/src/status/ServiceStatus.ts +0 -21
- package/src/status/index.ts +0 -2
- package/src/summary/index.ts +0 -2
- package/src/summary/model/BalancesStepSummary.ts +0 -35
- package/src/summary/model/SchemasStepSummary.ts +0 -33
- package/src/summary/model/StepSummary.ts +0 -20
- package/src/summary/model/TransfersSummary.ts +0 -36
- package/src/summary/model/index.ts +0 -4
- package/src/summary/primitives/balances/balancesStepSummaryFromRange.ts +0 -94
- package/src/summary/primitives/balances/balancesSummary.ts +0 -48
- package/src/summary/primitives/balances/index.ts +0 -2
- package/src/summary/primitives/index.ts +0 -3
- package/src/summary/primitives/schemas/index.ts +0 -2
- package/src/summary/primitives/schemas/schemasStepSummaryFromRange.ts +0 -86
- package/src/summary/primitives/schemas/schemasSummary.ts +0 -44
- package/src/summary/primitives/transfers/index.ts +0 -2
- package/src/summary/primitives/transfers/transfersStepSummaryFromRange.ts +0 -109
- package/src/summary/primitives/transfers/transfersSummary.ts +0 -52
- package/src/test/BuildBlockOptions.ts +0 -81
- package/src/test/buildBlock.ts +0 -105
- package/src/test/buildGenesisBlock.ts +0 -29
- package/src/test/buildNextBlock.ts +0 -37
- package/src/test/buildRandomChain.ts +0 -92
- package/src/test/buildRandomGenesisBlock.ts +0 -47
- package/src/test/createGenesisBlock.ts +0 -41
- package/src/test/createProducerChainStakeIntentTransaction.ts +0 -48
- package/src/test/getSimpleBlockViewerLocator.ts +0 -41
- package/src/test/getTestProviderContext.ts +0 -8
- package/src/test/index.ts +0 -2
- package/src/time/index.ts +0 -1
- package/src/time/primitives/index.ts +0 -1
- package/src/time/primitives/xl1BlockNumberToEthBlockNumber.ts +0 -13
- package/src/transaction/TransactionBuilder.ts +0 -164
- package/src/transaction/buildRandomTransaction.ts +0 -38
- package/src/transaction/buildTransaction.ts +0 -68
- package/src/transaction/buildUnsignedTransaction.ts +0 -56
- package/src/transaction/confirmSubmittedTransaction.ts +0 -42
- package/src/transaction/hydrateTransaction.ts +0 -117
- package/src/transaction/index.ts +0 -9
- package/src/transaction/primitives/index.ts +0 -4
- package/src/transaction/primitives/transactionBlockByteCount.ts +0 -10
- package/src/transaction/primitives/transactionElevatedPayloads.ts +0 -18
- package/src/transaction/primitives/transactionOperations.ts +0 -13
- package/src/transaction/primitives/transactionRequiredGas.ts +0 -22
- package/src/transaction/script.ts +0 -48
- package/src/transaction/signTransaction.ts +0 -32
- package/src/utils/HydratedCache.ts +0 -39
- package/src/utils/index.ts +0 -2
- package/src/utils/isZodError.ts +0 -11
- package/src/validation/index.ts +0 -2
- package/src/validation/lib/getUrl.ts +0 -7
- package/src/validation/lib/index.ts +0 -2
- package/src/validation/lib/isLocalhost.ts +0 -9
- package/src/validation/schema/Address.ts +0 -2
- package/src/validation/schema/Mnemonic.ts +0 -21
- package/src/validation/schema/index.ts +0 -2
- package/src/wallet/generateXyoBaseWalletFromPhrase.ts +0 -13
- package/src/wallet/index.ts +0 -2
- package/src/wallet/paths.ts +0 -17
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import type { Hash } from '@xylabs/sdk-js'
|
|
2
|
-
import { assertEx } from '@xylabs/sdk-js'
|
|
3
|
-
import type { Payload, WithStorageMeta } from '@xyo-network/sdk-js'
|
|
4
|
-
import {
|
|
5
|
-
asAnyPayload, hydrateTypedBoundWitness, tryHydrateTypedBoundWitness,
|
|
6
|
-
} from '@xyo-network/sdk-js'
|
|
7
|
-
import type {
|
|
8
|
-
AllowedBlockPayload, HydratedTransaction, SignedHydratedTransaction,
|
|
9
|
-
SignedHydratedTransactionWithHashMeta,
|
|
10
|
-
SignedHydratedTransactionWithStorageMeta, TransactionBoundWitness,
|
|
11
|
-
} from '@xyo-network/xl1-protocol-lib'
|
|
12
|
-
import {
|
|
13
|
-
asSignedHydratedTransaction, isAllowedBlockPayload, isSignedTransactionBoundWitnessWithStorageMeta,
|
|
14
|
-
} from '@xyo-network/xl1-protocol-lib'
|
|
15
|
-
|
|
16
|
-
import type { ChainStoreRead } from '../model/index.ts'
|
|
17
|
-
|
|
18
|
-
/** tryHydrateTransaction constant. */
|
|
19
|
-
export const tryHydrateTransaction = async (
|
|
20
|
-
{ chainMap }: ChainStoreRead,
|
|
21
|
-
hash: Hash,
|
|
22
|
-
): Promise<SignedHydratedTransactionWithStorageMeta | undefined> => {
|
|
23
|
-
return (await tryHydrateTypedBoundWitness<TransactionBoundWitness>(
|
|
24
|
-
{
|
|
25
|
-
get(hashes: Hash[]) {
|
|
26
|
-
return chainMap.get(hashes)
|
|
27
|
-
},
|
|
28
|
-
next() {
|
|
29
|
-
throw new Error('Not implemented')
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
hash,
|
|
33
|
-
isSignedTransactionBoundWitnessWithStorageMeta,
|
|
34
|
-
)) as SignedHydratedTransactionWithStorageMeta | undefined
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/** hydrateTransaction constant. */
|
|
38
|
-
export const hydrateTransaction = async (
|
|
39
|
-
{ chainMap }: ChainStoreRead,
|
|
40
|
-
hash: Hash,
|
|
41
|
-
): Promise<SignedHydratedTransaction> => {
|
|
42
|
-
return await hydrateTypedBoundWitness<TransactionBoundWitness>(
|
|
43
|
-
{
|
|
44
|
-
get(hashes: Hash[]) {
|
|
45
|
-
return chainMap.get(hashes)
|
|
46
|
-
},
|
|
47
|
-
next() {
|
|
48
|
-
throw new Error('Not implemented')
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
hash,
|
|
52
|
-
isSignedTransactionBoundWitnessWithStorageMeta,
|
|
53
|
-
) as SignedHydratedTransaction
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/** FlattenHydratedTransaction helper function. */
|
|
57
|
-
export function flattenHydratedTransaction<T extends HydratedTransaction>(hydratedTransaction: T): (T[0] | T[1][number])[] {
|
|
58
|
-
const [tx, txPayloads] = hydratedTransaction
|
|
59
|
-
return [...txPayloads, tx]
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/** tryUnflattenHydratedTransaction constant. */
|
|
63
|
-
export const tryUnflattenHydratedTransaction = (
|
|
64
|
-
flattened: Payload[],
|
|
65
|
-
): SignedHydratedTransaction | undefined => {
|
|
66
|
-
// Last element is always the transaction bound witness
|
|
67
|
-
const tx = flattened.at(-1)
|
|
68
|
-
|
|
69
|
-
// Everything else is a payloads
|
|
70
|
-
const txPayloads = flattened.slice(0, -1)
|
|
71
|
-
|
|
72
|
-
return asSignedHydratedTransaction([tx, txPayloads])
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/** unflattenHydratedTransaction constant. */
|
|
76
|
-
export const unflattenHydratedTransaction = (flattened: Payload[]): SignedHydratedTransaction =>
|
|
77
|
-
asSignedHydratedTransaction(tryUnflattenHydratedTransaction(flattened), true)
|
|
78
|
-
|
|
79
|
-
/** FlattenHydratedTransactions helper function. */
|
|
80
|
-
export function flattenHydratedTransactions<T extends HydratedTransaction>(hydratedTransactions: T[]): (T[0] | T[1][number])[] {
|
|
81
|
-
return hydratedTransactions.flatMap(tx => flattenHydratedTransaction(tx))
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/** tryHydrateElevatedTransaction constant. */
|
|
85
|
-
export const tryHydrateElevatedTransaction = async (
|
|
86
|
-
{ chainMap }: ChainStoreRead,
|
|
87
|
-
hash: Hash,
|
|
88
|
-
): Promise<SignedHydratedTransactionWithHashMeta | undefined> => {
|
|
89
|
-
const hydratedTransaction = await tryHydrateTransaction({ chainMap }, hash)
|
|
90
|
-
if (!hydratedTransaction) {
|
|
91
|
-
return undefined
|
|
92
|
-
}
|
|
93
|
-
const [transaction, payloads] = hydratedTransaction
|
|
94
|
-
const opCodes = (transaction.script ?? []).filter(operation => operation.startsWith('elevate|'))
|
|
95
|
-
const elevatedPayloads: WithStorageMeta<AllowedBlockPayload>[] = []
|
|
96
|
-
for (const opCode of opCodes) {
|
|
97
|
-
const [code, hash] = opCode.split('|')
|
|
98
|
-
if (code === 'elevated') {
|
|
99
|
-
const elevatedPayload = payloads.find(payload => payload._hash === hash)
|
|
100
|
-
if (isAllowedBlockPayload(elevatedPayload)) {
|
|
101
|
-
elevatedPayloads.push(elevatedPayload)
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
if (opCodes.length === elevatedPayloads.length) {
|
|
106
|
-
return [transaction, elevatedPayloads.map(p => asAnyPayload(p, true))]
|
|
107
|
-
}
|
|
108
|
-
return undefined
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/** hydrateElevatedTransaction constant. */
|
|
112
|
-
export const hydrateElevatedTransaction = async (
|
|
113
|
-
context: ChainStoreRead,
|
|
114
|
-
hash: Hash,
|
|
115
|
-
): Promise<SignedHydratedTransactionWithHashMeta> => {
|
|
116
|
-
return assertEx(await tryHydrateElevatedTransaction(context, hash), () => 'Hydration failed')
|
|
117
|
-
}
|
package/src/transaction/index.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export * from './buildRandomTransaction.ts'
|
|
2
|
-
export * from './buildTransaction.ts'
|
|
3
|
-
export * from './buildUnsignedTransaction.ts'
|
|
4
|
-
export * from './confirmSubmittedTransaction.ts'
|
|
5
|
-
export * from './hydrateTransaction.ts'
|
|
6
|
-
export * from './primitives/index.ts'
|
|
7
|
-
export * from './script.ts'
|
|
8
|
-
export * from './signTransaction.ts'
|
|
9
|
-
export * from './TransactionBuilder.ts'
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { PayloadBuilder } from '@xyo-network/sdk-js'
|
|
2
|
-
import type { HydratedTransaction } from '@xyo-network/xl1-protocol-lib'
|
|
3
|
-
|
|
4
|
-
/** The number of bytes that a transaction and its payloads will take up in a block */
|
|
5
|
-
export function transactionBlockByteCount([transaction, payloads]: HydratedTransaction): number {
|
|
6
|
-
const cleanTransaction = PayloadBuilder.omitStorageMeta(transaction)
|
|
7
|
-
const transactionBytes = JSON.stringify(cleanTransaction).length
|
|
8
|
-
const cleanPayloads = PayloadBuilder.omitStorageMeta(payloads)
|
|
9
|
-
return cleanPayloads.reduce((acc: number, payload) => acc + JSON.stringify(payload).length, 0) + transactionBytes
|
|
10
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { asHash, type Hash } from '@xylabs/sdk-js'
|
|
2
|
-
import type { Payload, WithHashMeta } from '@xyo-network/sdk-js'
|
|
3
|
-
import type { HydratedTransactionWithHashMeta, TransactionBoundWitness } from '@xyo-network/xl1-protocol-lib'
|
|
4
|
-
|
|
5
|
-
import { crackOperations } from './transactionOperations.ts'
|
|
6
|
-
|
|
7
|
-
/** TransactionElevatedPayloadHashes helper function. */
|
|
8
|
-
export function transactionElevatedPayloadHashes(transaction: TransactionBoundWitness): Hash[] {
|
|
9
|
-
const elevateOperations = crackOperations(transaction.script ?? []).filter(op => op[0] === 'elevate')
|
|
10
|
-
return elevateOperations.map(op => asHash(op[1][0], true))
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/** TransactionElevatedPayloads helper function. */
|
|
14
|
-
export function transactionElevatedPayloads([transaction, payloads]: HydratedTransactionWithHashMeta): WithHashMeta<Payload>[] {
|
|
15
|
-
const hashes = transactionElevatedPayloadHashes(transaction)
|
|
16
|
-
const elevatedPayloads = payloads.filter(payload => hashes.includes(payload._hash))
|
|
17
|
-
return elevatedPayloads
|
|
18
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/** CrackOperation helper function. */
|
|
2
|
-
export function crackOperation(operation: string): [string, string[]] {
|
|
3
|
-
const parts = operation.split('|')
|
|
4
|
-
if (parts.length < 2) {
|
|
5
|
-
throw new Error(`Invalid operation format: ${operation}`)
|
|
6
|
-
}
|
|
7
|
-
return [parts[0], parts.slice(1)]
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/** CrackOperations helper function. */
|
|
11
|
-
export function crackOperations(operations: string[]): [string, string[]][] {
|
|
12
|
-
return operations.map(op => crackOperation(op))
|
|
13
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { HydratedTransactionWithHashMeta } from '@xyo-network/xl1-protocol-lib'
|
|
2
|
-
import { AttoXL1, TransactionGasCosts } from '@xyo-network/xl1-protocol-lib'
|
|
3
|
-
|
|
4
|
-
import { transactionBlockByteCount } from './transactionBlockByteCount.ts'
|
|
5
|
-
import { transactionElevatedPayloads } from './transactionElevatedPayloads.ts'
|
|
6
|
-
|
|
7
|
-
/** The required gas for the byte storage on the block chain for a transaction */
|
|
8
|
-
export function transactionBytesRequiredGas([transaction, payloads]: HydratedTransactionWithHashMeta): AttoXL1 {
|
|
9
|
-
const transactionBlockBytes = transactionBlockByteCount([transaction, payloads])
|
|
10
|
-
return AttoXL1(TransactionGasCosts.characterStorage * BigInt(transactionBlockBytes))
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/** TransactionRequiredGas helper function. */
|
|
14
|
-
export function transactionRequiredGas(hydratedTransaction: HydratedTransactionWithHashMeta): AttoXL1 {
|
|
15
|
-
const elevatedPayloads = transactionElevatedPayloads(hydratedTransaction)
|
|
16
|
-
const hashes = elevatedPayloads.length + 1 /* for transaction itself */
|
|
17
|
-
const signatures = hydratedTransaction[0].addresses.length
|
|
18
|
-
return AttoXL1(transactionBytesRequiredGas(hydratedTransaction)
|
|
19
|
-
+ TransactionGasCosts.hashValidation * BigInt(hashes)
|
|
20
|
-
+ TransactionGasCosts.signatureValidation * BigInt(signatures)
|
|
21
|
-
+ TransactionGasCosts.payloadValidation * BigInt(elevatedPayloads.length))
|
|
22
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { asHash, type Hash } from '@xylabs/sdk-js'
|
|
2
|
-
import { assertEx, filterAs } from '@xylabs/sdk-js'
|
|
3
|
-
import type { WithHashMeta } from '@xyo-network/sdk-js'
|
|
4
|
-
import { isHashMeta } from '@xyo-network/sdk-js'
|
|
5
|
-
import type { AllowedBlockPayload, HydratedTransactionWithHashMeta } from '@xyo-network/xl1-protocol-lib'
|
|
6
|
-
import { isAllowedBlockPayload } from '@xyo-network/xl1-protocol-lib'
|
|
7
|
-
|
|
8
|
-
/** tryExtractElevatedHashesFromScript constant. */
|
|
9
|
-
export const tryExtractElevatedHashesFromScript = (strings: string[]): Hash[] => {
|
|
10
|
-
const hashes = strings
|
|
11
|
-
.filter(str => str.startsWith('elevate|'))
|
|
12
|
-
.map(str => str.split('|')[1])
|
|
13
|
-
return filterAs(hashes, h => asHash(h))
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/** extractElevatedHashesFromScript constant. */
|
|
17
|
-
export const extractElevatedHashesFromScript = (strings: string[]): Hash[] => {
|
|
18
|
-
const hashes = strings
|
|
19
|
-
.filter(str => str.startsWith('elevate|'))
|
|
20
|
-
.map(str => str.split('|')[1])
|
|
21
|
-
const filtered = filterAs(hashes, h => asHash(h))
|
|
22
|
-
assertEx(filtered.length === hashes.length, () => 'Invalid elevated hashes')
|
|
23
|
-
return filtered
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/** tryExtractElevatedHashes constant. */
|
|
27
|
-
export const tryExtractElevatedHashes = (tx: HydratedTransactionWithHashMeta): WithHashMeta<AllowedBlockPayload>[] => {
|
|
28
|
-
const [bw, payloads] = tx
|
|
29
|
-
const { script } = bw
|
|
30
|
-
const hashes = script ? tryExtractElevatedHashesFromScript(script) : []
|
|
31
|
-
return payloads
|
|
32
|
-
.filter(p => hashes.includes(p._hash))
|
|
33
|
-
.filter(isAllowedBlockPayload)
|
|
34
|
-
.filter(isHashMeta)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/** extractElevatedHashes constant. */
|
|
38
|
-
export const extractElevatedHashes = (tx: HydratedTransactionWithHashMeta): WithHashMeta<AllowedBlockPayload>[] => {
|
|
39
|
-
const [bw, payloads] = tx
|
|
40
|
-
const { script } = bw
|
|
41
|
-
const hashes = script ? tryExtractElevatedHashesFromScript(script) : []
|
|
42
|
-
const filtered = payloads
|
|
43
|
-
.filter(p => hashes.includes(p._hash))
|
|
44
|
-
.filter(isAllowedBlockPayload)
|
|
45
|
-
.filter(isHashMeta)
|
|
46
|
-
assertEx(filtered.length === hashes.length, () => 'Invalid elevated hashes')
|
|
47
|
-
return filtered
|
|
48
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
assertEx, hexFromArrayBuffer, toArrayBuffer,
|
|
3
|
-
} from '@xylabs/sdk-js'
|
|
4
|
-
import type { AccountInstance, Signed } from '@xyo-network/sdk-js'
|
|
5
|
-
import { PayloadBuilder } from '@xyo-network/sdk-js'
|
|
6
|
-
import type { TransactionBoundWitness, UnsignedTransactionBoundWitness } from '@xyo-network/xl1-protocol-lib'
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Signs an unsigned transaction with the provided account.
|
|
10
|
-
* @param tx The transaction to sign
|
|
11
|
-
* @param account The account to sign the transaction with
|
|
12
|
-
* @returns The signed transaction
|
|
13
|
-
*/
|
|
14
|
-
export async function signTransaction(tx: UnsignedTransactionBoundWitness, account: AccountInstance) {
|
|
15
|
-
assertEx(tx.from === account.address, () => 'Signer address does not match transaction from address')
|
|
16
|
-
// Clone tx to prevent modifying original
|
|
17
|
-
const unsignedTx = structuredClone(tx)
|
|
18
|
-
// Update dynamic fields based on account
|
|
19
|
-
unsignedTx.addresses = [account.address]
|
|
20
|
-
unsignedTx.previous_hashes = [account.previousHash ?? null]
|
|
21
|
-
// Calculate tx hash and sign it
|
|
22
|
-
const hash = await PayloadBuilder.dataHash(unsignedTx)
|
|
23
|
-
const hashBytes = toArrayBuffer(hash)
|
|
24
|
-
const [signature] = await account.sign(hashBytes)
|
|
25
|
-
// Append the signatures to the transaction
|
|
26
|
-
const result: Signed<TransactionBoundWitness> = {
|
|
27
|
-
...unsignedTx,
|
|
28
|
-
$signatures: [hexFromArrayBuffer(signature)],
|
|
29
|
-
}
|
|
30
|
-
// Return the signed transaction
|
|
31
|
-
return result
|
|
32
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { Hash } from '@xylabs/sdk-js'
|
|
2
|
-
import type { BlockContextRead } from '@xyo-network/xl1-protocol-lib'
|
|
3
|
-
import { LRUCache } from 'lru-cache'
|
|
4
|
-
|
|
5
|
-
/** Function type for Hydrate operations. */
|
|
6
|
-
export type HydrateFunction<T> = (
|
|
7
|
-
context: BlockContextRead,
|
|
8
|
-
hash: Hash,
|
|
9
|
-
) => Promise<T | undefined>
|
|
10
|
-
|
|
11
|
-
/** HydratedCache implementation. */
|
|
12
|
-
export class HydratedCache<T extends {}> {
|
|
13
|
-
protected readonly cache: LRUCache<Hash, T>
|
|
14
|
-
protected context: BlockContextRead
|
|
15
|
-
protected readonly hydrateFunction: HydrateFunction<T>
|
|
16
|
-
|
|
17
|
-
constructor(
|
|
18
|
-
context: BlockContextRead,
|
|
19
|
-
hydrateFunction: HydrateFunction<T>,
|
|
20
|
-
maxCount: number = 2000,
|
|
21
|
-
ttl: number = Number.MAX_SAFE_INTEGER,
|
|
22
|
-
) {
|
|
23
|
-
this.context = context
|
|
24
|
-
this.hydrateFunction = hydrateFunction
|
|
25
|
-
this.cache = new LRUCache<Hash, T>({ max: maxCount, ttl })
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
async get(hash: Hash): Promise<T | null> {
|
|
29
|
-
const existing = this.cache.get(hash)
|
|
30
|
-
if (existing !== undefined) return existing
|
|
31
|
-
const block = (await this.hydrateFunction(this.context, hash)) ?? null
|
|
32
|
-
if (block !== null) this.cache.set(hash, block)
|
|
33
|
-
return block
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
has(hash: Hash): boolean {
|
|
37
|
-
return this.cache.has(hash)
|
|
38
|
-
}
|
|
39
|
-
}
|
package/src/utils/index.ts
DELETED
package/src/utils/isZodError.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod'
|
|
2
|
-
|
|
3
|
-
/** Type guard that checks if a value is a valid ZodError. */
|
|
4
|
-
export const isZodError = (error: unknown): error is z.ZodError => {
|
|
5
|
-
return error instanceof z.ZodError
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/** prettifyZodError constant. */
|
|
9
|
-
export const prettifyZodError = (error: z.ZodError): string => {
|
|
10
|
-
return z.prettifyError(error)
|
|
11
|
-
}
|
package/src/validation/index.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/** Type guard that checks if a value is a valid Localhost. */
|
|
2
|
-
export const isLocalhost = (hostname: string): boolean => {
|
|
3
|
-
return (
|
|
4
|
-
hostname === 'localhost'
|
|
5
|
-
|| hostname === '127.0.0.1'
|
|
6
|
-
|| hostname === '::1' // IPv6 localhost
|
|
7
|
-
|| hostname.endsWith('.localhost')
|
|
8
|
-
)
|
|
9
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Validates a single string containing a BIP-39 mnemonic.
|
|
5
|
-
*
|
|
6
|
-
* • Trims leading/trailing whitespace.
|
|
7
|
-
* • Collapses any run of whitespace (spaces, tabs, new-lines) to a single space.
|
|
8
|
-
* • Splits on spaces → array of words.
|
|
9
|
-
* • Checks that the word-count is 12, 15, 18, 21, or 24.
|
|
10
|
-
*
|
|
11
|
-
*/
|
|
12
|
-
export const MnemonicStringZod = z
|
|
13
|
-
.string()
|
|
14
|
-
.transform(s => s.trim().replaceAll(/\s+/g, ' ')) // normalize spacing
|
|
15
|
-
.refine(
|
|
16
|
-
s => [12, 15, 18, 21, 24].includes(s.split(' ').length),
|
|
17
|
-
{ message: 'Mnemonic must contain 12, 15, 18, 21, or 24 words.' },
|
|
18
|
-
).describe('BIP-39 mnemonic string')
|
|
19
|
-
|
|
20
|
-
/** MnemonicString type. */
|
|
21
|
-
export type MnemonicString = z.infer<typeof MnemonicStringZod>
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { HDWallet } from '@xyo-network/sdk-js'
|
|
2
|
-
|
|
3
|
-
import { DEFAULT_WALLET_PATH } from './paths.ts'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Initializes a wallet to the default XYO path from a mnemonic phrase
|
|
7
|
-
* @param walletPhrase The mnemonic phrase for the wallet
|
|
8
|
-
* @returns A wallet initialized to the default XYO path using the provided phrase
|
|
9
|
-
*/
|
|
10
|
-
export const generateXyoBaseWalletFromPhrase = (walletPhrase: string) => {
|
|
11
|
-
const wallet = HDWallet.fromPhrase(walletPhrase, DEFAULT_WALLET_PATH)
|
|
12
|
-
return wallet
|
|
13
|
-
}
|
package/src/wallet/index.ts
DELETED
package/src/wallet/paths.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/** WALLET_COMPLIANCE constant. */
|
|
2
|
-
export const WALLET_COMPLIANCE = '44\'' as const
|
|
3
|
-
|
|
4
|
-
/** COIN_TYPES constant. */
|
|
5
|
-
export const COIN_TYPES = { Ethereum: '60\'' } as const
|
|
6
|
-
|
|
7
|
-
/** ACCOUNT_TYPE constant. */
|
|
8
|
-
export const ACCOUNT_TYPE = { GANACHE: '0\'', XYO: '0\'' } as const
|
|
9
|
-
|
|
10
|
-
/** CHANGE_ADDRESS constant. */
|
|
11
|
-
export const CHANGE_ADDRESS = { META_MASK: '0', XYO: '0' } as const
|
|
12
|
-
|
|
13
|
-
/** ADDRESS_INDEX constant. */
|
|
14
|
-
export const ADDRESS_INDEX = { META_MASK: '0', XYO: '0' } as const
|
|
15
|
-
|
|
16
|
-
/** DEFAULT_WALLET_PATH constant. */
|
|
17
|
-
export const DEFAULT_WALLET_PATH = `m/${WALLET_COMPLIANCE}/${COIN_TYPES.Ethereum}/${ACCOUNT_TYPE.XYO}/${CHANGE_ADDRESS.XYO}`
|