@xyo-network/xl1-protocol-sdk 1.10.2 → 1.12.0
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/config/Api.d.ts +5 -13
- package/dist/neutral/config/Api.d.ts.map +1 -1
- package/dist/neutral/config/App.d.ts +4 -7
- package/dist/neutral/config/App.d.ts.map +1 -1
- package/dist/neutral/config/Chain.d.ts +3 -6
- package/dist/neutral/config/Chain.d.ts.map +1 -1
- package/dist/neutral/config/Config.d.ts +39 -225
- package/dist/neutral/config/Config.d.ts.map +1 -1
- package/dist/neutral/config/Evm.d.ts +11 -49
- package/dist/neutral/config/Evm.d.ts.map +1 -1
- package/dist/neutral/config/Log.d.ts +12 -7
- package/dist/neutral/config/Log.d.ts.map +1 -1
- package/dist/neutral/config/Producer.d.ts +7 -20
- package/dist/neutral/config/Producer.d.ts.map +1 -1
- package/dist/neutral/config/Telemetry.d.ts +8 -24
- package/dist/neutral/config/Telemetry.d.ts.map +1 -1
- package/dist/neutral/config/UsageMeta.d.ts +27 -0
- package/dist/neutral/config/UsageMeta.d.ts.map +1 -0
- package/dist/neutral/config/index.d.ts +1 -0
- package/dist/neutral/config/index.d.ts.map +1 -1
- package/dist/neutral/config/storage/Storage.d.ts +4 -34
- package/dist/neutral/config/storage/Storage.d.ts.map +1 -1
- package/dist/neutral/config/storage/driver/Mongo.d.ts +3 -15
- package/dist/neutral/config/storage/driver/Mongo.d.ts.map +1 -1
- package/dist/neutral/index.mjs +215 -72
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/instances/transaction/HydratedTransaction.d.ts +2 -2
- package/dist/neutral/instances/transaction/HydratedTransaction.d.ts.map +1 -1
- package/dist/neutral/payload/netBalancesForPayloads.d.ts +5 -2
- package/dist/neutral/payload/netBalancesForPayloads.d.ts.map +1 -1
- package/dist/neutral/transaction/buildTransaction.d.ts +3 -3
- package/dist/neutral/transaction/buildTransaction.d.ts.map +1 -1
- package/dist/neutral/transaction/buildUnsignedTransaction.d.ts +3 -3
- package/dist/neutral/transaction/buildUnsignedTransaction.d.ts.map +1 -1
- package/dist/neutral/transaction/confirmSubmittedTransaction.d.ts +2 -2
- package/dist/neutral/transaction/confirmSubmittedTransaction.d.ts.map +1 -1
- package/dist/neutral/transaction/hydrateTransaction.d.ts +7 -7
- package/dist/neutral/transaction/hydrateTransaction.d.ts.map +1 -1
- package/dist/neutral/transaction/primitives/transactionBlockByteCount.d.ts +2 -2
- package/dist/neutral/transaction/primitives/transactionBlockByteCount.d.ts.map +1 -1
- package/dist/neutral/transaction/primitives/transactionElevatedPayloads.d.ts +2 -2
- package/dist/neutral/transaction/primitives/transactionElevatedPayloads.d.ts.map +1 -1
- package/dist/neutral/transaction/primitives/transactionRequiredGas.d.ts +3 -3
- package/dist/neutral/transaction/primitives/transactionRequiredGas.d.ts.map +1 -1
- package/dist/neutral/transaction/script.d.ts +3 -3
- package/dist/neutral/transaction/script.d.ts.map +1 -1
- package/dist/neutral/transaction/signTransaction.d.ts +1 -1
- package/dist/neutral/transaction/signTransaction.d.ts.map +1 -1
- package/dist/neutral/validation/schema/Mnemonic.d.ts +2 -2
- package/dist/neutral/validation/schema/Mnemonic.d.ts.map +1 -1
- package/package.json +21 -21
- package/src/config/Api.ts +21 -7
- package/src/config/App.ts +11 -2
- package/src/config/Chain.ts +10 -3
- package/src/config/Config.ts +19 -25
- package/src/config/Evm.ts +29 -12
- package/src/config/Log.ts +18 -2
- package/src/config/Producer.ts +36 -9
- package/src/config/Telemetry.ts +10 -6
- package/src/config/UsageMeta.ts +41 -0
- package/src/config/index.ts +1 -0
- package/src/config/storage/Storage.ts +10 -6
- package/src/config/storage/driver/Mongo.ts +28 -8
- package/src/instances/transaction/HydratedTransaction.ts +2 -2
- package/src/transaction/buildTransaction.ts +5 -4
- package/src/transaction/buildUnsignedTransaction.ts +5 -4
- package/src/transaction/confirmSubmittedTransaction.ts +2 -2
- package/src/transaction/hydrateTransaction.ts +12 -12
- package/src/transaction/primitives/spec/transactionBlockByteCount.spec.ts +7 -7
- package/src/transaction/primitives/transactionBlockByteCount.ts +2 -2
- package/src/transaction/primitives/transactionElevatedPayloads.ts +2 -2
- package/src/transaction/primitives/transactionRequiredGas.ts +3 -3
- package/src/transaction/script.ts +3 -3
- package/src/transaction/signTransaction.ts +5 -5
- package/src/validation/schema/Mnemonic.ts +2 -2
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-sdk",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.12.0",
|
|
5
5
|
"description": "XYO Layer One SDK Protocol",
|
|
6
6
|
"homepage": "https://xylabs.com",
|
|
7
7
|
"bugs": {
|
|
@@ -36,28 +36,28 @@
|
|
|
36
36
|
"src"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@xylabs/array": "~5.0.
|
|
40
|
-
"@xylabs/arraybuffer": "~5.0.
|
|
41
|
-
"@xylabs/assert": "~5.0.
|
|
42
|
-
"@xylabs/delay": "~5.0.
|
|
43
|
-
"@xylabs/hex": "~5.0.
|
|
44
|
-
"@xylabs/logger": "~5.0.
|
|
45
|
-
"@xylabs/object": "~5.0.
|
|
46
|
-
"@xylabs/promise": "~5.0.
|
|
47
|
-
"@xylabs/typeof": "~5.0.
|
|
48
|
-
"@xyo-network/account-model": "~5.0.
|
|
49
|
-
"@xyo-network/archivist-model": "~5.0.
|
|
50
|
-
"@xyo-network/boundwitness-builder": "~5.0.
|
|
51
|
-
"@xyo-network/boundwitness-model": "~5.0.
|
|
52
|
-
"@xyo-network/payload-builder": "~5.0.
|
|
53
|
-
"@xyo-network/payload-model": "~5.0.
|
|
54
|
-
"@xyo-network/wallet": "~5.0.
|
|
55
|
-
"@xyo-network/wallet-model": "~5.0.
|
|
56
|
-
"@xyo-network/xl1-protocol": "~1.
|
|
57
|
-
"zod": "~
|
|
39
|
+
"@xylabs/array": "~5.0.7",
|
|
40
|
+
"@xylabs/arraybuffer": "~5.0.7",
|
|
41
|
+
"@xylabs/assert": "~5.0.7",
|
|
42
|
+
"@xylabs/delay": "~5.0.7",
|
|
43
|
+
"@xylabs/hex": "~5.0.7",
|
|
44
|
+
"@xylabs/logger": "~5.0.7",
|
|
45
|
+
"@xylabs/object": "~5.0.7",
|
|
46
|
+
"@xylabs/promise": "~5.0.7",
|
|
47
|
+
"@xylabs/typeof": "~5.0.7",
|
|
48
|
+
"@xyo-network/account-model": "~5.0.2",
|
|
49
|
+
"@xyo-network/archivist-model": "~5.0.2",
|
|
50
|
+
"@xyo-network/boundwitness-builder": "~5.0.2",
|
|
51
|
+
"@xyo-network/boundwitness-model": "~5.0.2",
|
|
52
|
+
"@xyo-network/payload-builder": "~5.0.2",
|
|
53
|
+
"@xyo-network/payload-model": "~5.0.2",
|
|
54
|
+
"@xyo-network/wallet": "~5.0.2",
|
|
55
|
+
"@xyo-network/wallet-model": "~5.0.2",
|
|
56
|
+
"@xyo-network/xl1-protocol": "~1.10.12",
|
|
57
|
+
"zod": "~4.0.17"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@types/node": "~24.2.
|
|
60
|
+
"@types/node": "~24.2.1",
|
|
61
61
|
"@xylabs/ts-scripts-yarn3": "~7.1.0",
|
|
62
62
|
"@xylabs/tsconfig": "~7.1.0",
|
|
63
63
|
"typescript": "~5.9.2",
|
package/src/config/Api.ts
CHANGED
|
@@ -1,11 +1,25 @@
|
|
|
1
|
-
import z from 'zod'
|
|
1
|
+
import z, { globalRegistry } from 'zod'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { MnemonicStringZod } from '../validation/index.ts'
|
|
4
4
|
|
|
5
|
-
export const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
export const ApiConfigZod = z.object({
|
|
6
|
+
host: z.string().default('localhost').register(globalRegistry, {
|
|
7
|
+
default: 'localhost',
|
|
8
|
+
description: 'Host for the API',
|
|
9
|
+
title: 'api.host',
|
|
10
|
+
type: 'string',
|
|
11
|
+
}),
|
|
12
|
+
mnemonic: MnemonicStringZod.optional().register(globalRegistry, {
|
|
13
|
+
description: 'Mnemonic for the API wallet',
|
|
14
|
+
title: 'api.mnemonic',
|
|
15
|
+
type: 'string',
|
|
16
|
+
}),
|
|
17
|
+
port: z.coerce.number().default(8080).register(globalRegistry, {
|
|
18
|
+
default: 8080,
|
|
19
|
+
description: 'Port for the API',
|
|
20
|
+
title: 'api.port',
|
|
21
|
+
type: 'number',
|
|
22
|
+
}),
|
|
9
23
|
})
|
|
10
24
|
|
|
11
|
-
export type ApiConfig = z.infer<typeof
|
|
25
|
+
export type ApiConfig = z.infer<typeof ApiConfigZod>
|
package/src/config/App.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
-
import z from 'zod'
|
|
1
|
+
import z, { globalRegistry } from 'zod'
|
|
2
2
|
|
|
3
|
-
export const
|
|
3
|
+
export const AppConfigZod = z.object({
|
|
4
|
+
port: z.coerce.number().default(3000).register(globalRegistry, {
|
|
5
|
+
default: 3000,
|
|
6
|
+
description: 'Port for the application',
|
|
7
|
+
title: 'app.port',
|
|
8
|
+
type: 'number',
|
|
9
|
+
}),
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
export type AppConfig = z.infer<typeof AppConfigZod>
|
package/src/config/Chain.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import z from 'zod'
|
|
1
|
+
import z, { globalRegistry } from 'zod'
|
|
2
2
|
|
|
3
|
-
export const
|
|
3
|
+
export const ChainConfigZod = z.object({
|
|
4
4
|
id: z.string().optional()
|
|
5
|
-
.
|
|
5
|
+
.register(globalRegistry, {
|
|
6
|
+
description:
|
|
7
|
+
'The unique identifier for the chain. Should be the staking contract address for contract-backed chains.',
|
|
8
|
+
title: 'chain.id',
|
|
9
|
+
type: 'string',
|
|
10
|
+
}),
|
|
6
11
|
})
|
|
12
|
+
|
|
13
|
+
export type ChainConfig = z.infer<typeof ChainConfigZod>
|
package/src/config/Config.ts
CHANGED
|
@@ -1,33 +1,27 @@
|
|
|
1
|
-
import type { LogLevelKey } from '@xylabs/logger'
|
|
2
|
-
import { LogLevel } from '@xylabs/logger'
|
|
3
1
|
import z from 'zod'
|
|
4
2
|
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
3
|
+
import { ApiConfigZod } from './Api.ts'
|
|
4
|
+
import { AppConfigZod } from './App.ts'
|
|
5
|
+
import { ChainConfigZod } from './Chain.ts'
|
|
6
|
+
import { EvmConfigZod } from './Evm.ts'
|
|
7
|
+
import { LogConfigZod } from './Log.ts'
|
|
8
|
+
import { ProducerConfigZod } from './Producer.ts'
|
|
9
|
+
import { StorageConfigZod } from './storage/index.ts'
|
|
10
|
+
import { TelemetryConfigZod } from './Telemetry.ts'
|
|
12
11
|
|
|
13
|
-
const
|
|
12
|
+
export const Xl1CommonConfigSchema = z.object({ ...LogConfigZod.shape }).describe('XL1 common configuration options')
|
|
14
13
|
|
|
15
|
-
export const
|
|
16
|
-
silent: z.boolean().default(false).describe('Whether to run in silent mode'),
|
|
17
|
-
logLevel: z.enum(LogLevels).default('info').describe('Desired process verbosity'),
|
|
18
|
-
}).describe('XL1 common configuration options')
|
|
19
|
-
|
|
20
|
-
export const ConfigSchema = z.object({
|
|
14
|
+
export const ConfigZod = z.object({
|
|
21
15
|
...Xl1CommonConfigSchema.shape,
|
|
22
|
-
api:
|
|
23
|
-
app:
|
|
24
|
-
chain:
|
|
25
|
-
evm:
|
|
26
|
-
producer:
|
|
27
|
-
storage:
|
|
28
|
-
telemetry:
|
|
16
|
+
api: ApiConfigZod.default(ApiConfigZod.parse({})).describe('Configuration for the API node'),
|
|
17
|
+
app: AppConfigZod.default(AppConfigZod.parse({})).describe('Configuration for the application'),
|
|
18
|
+
chain: ChainConfigZod.default(ChainConfigZod.parse({})).describe('Configuration for the chain'),
|
|
19
|
+
evm: EvmConfigZod.default(EvmConfigZod.parse({})).describe('Configuration for EVM-backed services'),
|
|
20
|
+
producer: ProducerConfigZod.default(ProducerConfigZod.parse({})).describe('Configuration for the producer'),
|
|
21
|
+
storage: StorageConfigZod.default(StorageConfigZod.parse({})).describe('Configuration for the storage'),
|
|
22
|
+
telemetry: TelemetryConfigZod.default(TelemetryConfigZod.parse({})).describe('Configuration for telemetry'),
|
|
29
23
|
})
|
|
30
24
|
|
|
31
|
-
export type Config = z.infer<typeof
|
|
25
|
+
export type Config = z.infer<typeof ConfigZod>
|
|
32
26
|
|
|
33
|
-
export const getDefaultConfig = (): Config =>
|
|
27
|
+
export const getDefaultConfig = (): Config => ConfigZod.parse({})
|
package/src/config/Evm.ts
CHANGED
|
@@ -1,17 +1,34 @@
|
|
|
1
|
-
import z from 'zod'
|
|
1
|
+
import z, { globalRegistry } from 'zod'
|
|
2
2
|
|
|
3
|
-
export const
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export const EvmInfuraConfigZod = z.object({
|
|
4
|
+
projectId: z.string().optional().register(globalRegistry, {
|
|
5
|
+
description: 'Infura project ID',
|
|
6
|
+
title: 'evm.infura.projectId',
|
|
7
|
+
type: 'string',
|
|
8
|
+
}),
|
|
9
|
+
projectSecret: z.string().optional().register(globalRegistry, {
|
|
10
|
+
description: 'Infura project secret',
|
|
11
|
+
title: 'evm.infura.projectSecret',
|
|
12
|
+
type: 'string',
|
|
13
|
+
}),
|
|
6
14
|
})
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
15
|
+
|
|
16
|
+
export const EvmJsonRpcConfigZod = z.object({
|
|
17
|
+
url: z.url().optional().register(globalRegistry, {
|
|
18
|
+
description: 'JSON-RPC URL',
|
|
19
|
+
title: 'evm.jsonRpc.url',
|
|
20
|
+
type: 'string',
|
|
21
|
+
}),
|
|
10
22
|
})
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
23
|
+
|
|
24
|
+
export const EvmConfigZod = z.object({
|
|
25
|
+
chainId: z.string().optional().register(globalRegistry, {
|
|
26
|
+
description: 'EVM chain ID',
|
|
27
|
+
title: 'evm.chainId',
|
|
28
|
+
type: 'string',
|
|
29
|
+
}),
|
|
30
|
+
infura: EvmInfuraConfigZod.optional().describe('Infura Provider configuration'),
|
|
31
|
+
jsonRpc: EvmJsonRpcConfigZod.optional().describe('JSON-RPC Provider configuration'),
|
|
15
32
|
})
|
|
16
33
|
|
|
17
|
-
export type EvmConfig = z.infer<typeof
|
|
34
|
+
export type EvmConfig = z.infer<typeof EvmConfigZod>
|
package/src/config/Log.ts
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
import type { LogLevelKey } from '@xylabs/logger'
|
|
2
2
|
import { LogLevel } from '@xylabs/logger'
|
|
3
|
-
import z from 'zod'
|
|
3
|
+
import z, { globalRegistry } from 'zod'
|
|
4
4
|
const LogLevels = Object.keys(LogLevel) as [LogLevelKey, ...LogLevelKey[]]
|
|
5
5
|
|
|
6
|
-
export const
|
|
6
|
+
export const LogConfigZod = z.object({
|
|
7
|
+
logLevel: z.enum(LogLevels).default('info').register(globalRegistry, {
|
|
8
|
+
choices: LogLevels,
|
|
9
|
+
default: 'info',
|
|
10
|
+
description: 'Desired process verbosity',
|
|
11
|
+
title: 'logLevel',
|
|
12
|
+
type: 'string',
|
|
13
|
+
}),
|
|
14
|
+
silent: z.boolean().default(false).register(globalRegistry, {
|
|
15
|
+
default: false,
|
|
16
|
+
description: 'Whether to run in silent mode',
|
|
17
|
+
title: 'silent',
|
|
18
|
+
type: 'boolean',
|
|
19
|
+
}),
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
export type LogConfig = z.infer<typeof LogConfigZod>
|
package/src/config/Producer.ts
CHANGED
|
@@ -1,16 +1,43 @@
|
|
|
1
|
-
import z from 'zod'
|
|
1
|
+
import z, { globalRegistry } from 'zod'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { MnemonicStringZod } from '../validation/index.ts'
|
|
4
4
|
|
|
5
|
-
export const
|
|
5
|
+
export const ProducerConfigZod = z.object({
|
|
6
|
+
disableIntentRedeclaration: z.boolean().optional().register(globalRegistry, {
|
|
7
|
+
description: 'Should the producer skip redeclaring their intent to continue producing blocks',
|
|
8
|
+
title: 'producer.disableIntentRedeclaration',
|
|
9
|
+
type: 'boolean',
|
|
10
|
+
}),
|
|
6
11
|
// TODO: Port schema
|
|
7
|
-
healthCheckPort: z.coerce.number().optional().
|
|
12
|
+
healthCheckPort: z.coerce.number().optional().register(globalRegistry, {
|
|
13
|
+
description: 'Port for the Producer health checks',
|
|
14
|
+
title: 'producer.healthCheckPort',
|
|
15
|
+
type: 'number',
|
|
16
|
+
}),
|
|
8
17
|
// TODO: BigInt schema
|
|
9
|
-
minStake: z.coerce.number().default(1).
|
|
10
|
-
|
|
18
|
+
minStake: z.coerce.number().default(1).register(globalRegistry, {
|
|
19
|
+
description: 'Minimum stake required to be a Producer',
|
|
20
|
+
title: 'producer.minStake',
|
|
21
|
+
type: 'number',
|
|
22
|
+
}),
|
|
23
|
+
mnemonic: MnemonicStringZod.optional().register(globalRegistry, {
|
|
24
|
+
description: 'Mnemonic for the Producer wallet',
|
|
25
|
+
title: 'producer.mnemonic',
|
|
26
|
+
type: 'string',
|
|
27
|
+
}),
|
|
11
28
|
// TODO: Port schema
|
|
12
|
-
port: z.coerce.number().default(8081).
|
|
13
|
-
|
|
29
|
+
port: z.coerce.number().default(8081).register(globalRegistry, {
|
|
30
|
+
default: 8081,
|
|
31
|
+
description: 'Port for the Producer',
|
|
32
|
+
title: 'producer.port',
|
|
33
|
+
type: 'number',
|
|
34
|
+
}),
|
|
14
35
|
// TODO: Address schema
|
|
15
|
-
rewardAddress: z.string().optional().
|
|
36
|
+
rewardAddress: z.string().optional().register(globalRegistry, {
|
|
37
|
+
description: 'Address to receive block rewards',
|
|
38
|
+
title: 'producer.rewardAddress',
|
|
39
|
+
type: 'string',
|
|
40
|
+
}),
|
|
16
41
|
})
|
|
42
|
+
|
|
43
|
+
export type ProducerConfig = z.infer<typeof ProducerConfigZod>
|
package/src/config/Telemetry.ts
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import z from 'zod'
|
|
1
|
+
import z, { globalRegistry } from 'zod'
|
|
2
2
|
|
|
3
|
-
export const
|
|
3
|
+
export const OpenTelemetryConfigZod = z.object({
|
|
4
4
|
// OpenTelemetry options
|
|
5
|
-
otlpEndpoint: z.
|
|
5
|
+
otlpEndpoint: z.url().optional().register(globalRegistry, {
|
|
6
|
+
description: 'OTLP endpoint for exporting telemetry data',
|
|
7
|
+
title: 'telemetry.otel.otlpEndpoint',
|
|
8
|
+
type: 'string',
|
|
9
|
+
}),
|
|
6
10
|
})
|
|
7
11
|
|
|
8
|
-
export const
|
|
12
|
+
export const TelemetryConfigZod = z.object({
|
|
9
13
|
// OpenTelemetry configuration
|
|
10
|
-
otel:
|
|
14
|
+
otel: OpenTelemetryConfigZod.optional().describe('OpenTelemetry configuration'),
|
|
11
15
|
}).describe('Telemetry configuration options')
|
|
12
16
|
|
|
13
|
-
export type TelemetryConfig = z.infer<typeof
|
|
17
|
+
export type TelemetryConfig = z.infer<typeof TelemetryConfigZod>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import z from 'zod'
|
|
2
|
+
|
|
3
|
+
const DescriptionSchema = z.string()
|
|
4
|
+
const TitleSchema = z.string()
|
|
5
|
+
|
|
6
|
+
export const JSONSchemaMetaSchema = z
|
|
7
|
+
.object({
|
|
8
|
+
id: z.string().optional(),
|
|
9
|
+
title: TitleSchema.optional(),
|
|
10
|
+
description: DescriptionSchema.optional(),
|
|
11
|
+
deprecated: z.boolean().optional(),
|
|
12
|
+
})
|
|
13
|
+
.catchall(z.unknown()) // allow arbitrary extra keys
|
|
14
|
+
|
|
15
|
+
export const GlobalMetaSchema = JSONSchemaMetaSchema.extend({})
|
|
16
|
+
|
|
17
|
+
const ChoicesSchema = z
|
|
18
|
+
.array(z.union([z.string(), z.number(), z.literal(true), z.undefined()]))
|
|
19
|
+
.readonly()
|
|
20
|
+
|
|
21
|
+
export const UsageMetaSchema = GlobalMetaSchema.extend({
|
|
22
|
+
choices: ChoicesSchema.optional(),
|
|
23
|
+
default: z.unknown().optional(),
|
|
24
|
+
description: DescriptionSchema,
|
|
25
|
+
group: z.string().optional(),
|
|
26
|
+
hidden: z.boolean().optional(),
|
|
27
|
+
title: TitleSchema,
|
|
28
|
+
type: z.union([
|
|
29
|
+
z.literal('array'),
|
|
30
|
+
z.literal('count'),
|
|
31
|
+
z.literal('boolean'),
|
|
32
|
+
z.literal('number'),
|
|
33
|
+
z.literal('string'),
|
|
34
|
+
]),
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
export type UsageMeta = z.infer<typeof UsageMetaSchema>
|
|
38
|
+
|
|
39
|
+
export function isUsageMeta(v: unknown): v is UsageMeta {
|
|
40
|
+
return UsageMetaSchema.safeParse(v).success
|
|
41
|
+
}
|
package/src/config/index.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import z from 'zod'
|
|
1
|
+
import z, { globalRegistry } from 'zod'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { MongoConfigZod } from './driver/index.ts'
|
|
4
4
|
|
|
5
|
-
export const
|
|
6
|
-
mongo:
|
|
7
|
-
root: z.string().optional().
|
|
5
|
+
export const StorageConfigZod = z.object({
|
|
6
|
+
mongo: MongoConfigZod.optional().describe('Configuration for the MongoD storage driver'),
|
|
7
|
+
root: z.string().optional().register(globalRegistry, {
|
|
8
|
+
description: 'Root directory for local storage',
|
|
9
|
+
title: 'storage.root',
|
|
10
|
+
type: 'string',
|
|
11
|
+
}),
|
|
8
12
|
}).describe('Storage configuration options')
|
|
9
13
|
|
|
10
|
-
export type StorageConfig = z.infer<typeof
|
|
14
|
+
export type StorageConfig = z.infer<typeof StorageConfigZod>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isDefined, isUndefined } from '@xylabs/typeof'
|
|
2
|
-
import z from 'zod'
|
|
2
|
+
import z, { globalRegistry } from 'zod'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Checks if the provided MongoDB configuration contains all necessary fields
|
|
@@ -19,13 +19,33 @@ export const hasMongoConfig = (config?: MongoConfig): config is Required<MongoCo
|
|
|
19
19
|
)
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export const
|
|
22
|
+
export const MongoConfigZod = z.object({
|
|
23
23
|
// TODO: Create from other arguments
|
|
24
|
-
connectionString: z.string().min(1).optional().
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
connectionString: z.string().min(1).optional().register(globalRegistry, {
|
|
25
|
+
description: 'MongoDB connection string',
|
|
26
|
+
title: 'storage.mongo.connectionString',
|
|
27
|
+
type: 'string',
|
|
28
|
+
}),
|
|
29
|
+
database: z.string().min(1).optional().register(globalRegistry, {
|
|
30
|
+
description: 'MongoDB database name',
|
|
31
|
+
title: 'storage.mongo.database',
|
|
32
|
+
type: 'string',
|
|
33
|
+
}),
|
|
34
|
+
domain: z.string().min(1).optional().register(globalRegistry, {
|
|
35
|
+
description: 'MongoDB domain',
|
|
36
|
+
title: 'storage.mongo.domain',
|
|
37
|
+
type: 'string',
|
|
38
|
+
}),
|
|
39
|
+
password: z.string().min(1).optional().register(globalRegistry, {
|
|
40
|
+
description: 'MongoDB password',
|
|
41
|
+
title: 'storage.mongo.password',
|
|
42
|
+
type: 'string',
|
|
43
|
+
}),
|
|
44
|
+
username: z.string().min(1).optional().register(globalRegistry, {
|
|
45
|
+
description: 'MongoDB username',
|
|
46
|
+
title: 'storage.mongo.username',
|
|
47
|
+
type: 'string',
|
|
48
|
+
}),
|
|
29
49
|
})
|
|
30
50
|
|
|
31
|
-
export type MongoConfig = z.infer<typeof
|
|
51
|
+
export type MongoConfig = z.infer<typeof MongoConfigZod>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { AllowedBlockPayload,
|
|
1
|
+
import type { AllowedBlockPayload, HydratedTransactionWithStorageMeta } from '@xyo-network/xl1-protocol'
|
|
2
2
|
|
|
3
3
|
import type { HydratedBoundWitnessInstance } from '../HydratedBoundWitness.ts'
|
|
4
4
|
import type { SignedInstance } from '../modifiers/index.ts'
|
|
5
5
|
import type { TransactionFieldsInstance } from './TransactionFields.ts'
|
|
6
6
|
|
|
7
|
-
export interface HydratedTransactionInstance<T extends
|
|
7
|
+
export interface HydratedTransactionInstance<T extends HydratedTransactionWithStorageMeta = HydratedTransactionWithStorageMeta,
|
|
8
8
|
TElevatedPayload extends AllowedBlockPayload = AllowedBlockPayload>
|
|
9
9
|
extends TransactionFieldsInstance<T[1][number] & TElevatedPayload>, HydratedBoundWitnessInstance<T>, SignedInstance {
|
|
10
10
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { assertEx } from '@xylabs/assert'
|
|
2
|
-
import type { Address
|
|
2
|
+
import type { Address } from '@xylabs/hex'
|
|
3
3
|
import { toHex } from '@xylabs/hex'
|
|
4
4
|
import type { AccountInstance } from '@xyo-network/account-model'
|
|
5
5
|
import { BoundWitnessBuilder } from '@xyo-network/boundwitness-builder'
|
|
@@ -7,14 +7,15 @@ import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
|
7
7
|
import type { Payload } from '@xyo-network/payload-model'
|
|
8
8
|
import type {
|
|
9
9
|
AllowedBlockPayload,
|
|
10
|
+
Chain,
|
|
10
11
|
ExecutableFields,
|
|
11
12
|
FromFields,
|
|
12
|
-
|
|
13
|
+
SignedHydratedTransactionWithStorageMeta, TransactionBoundWitness, TransactionBoundWitnessFields, TransactionFeesBigInt,
|
|
13
14
|
} from '@xyo-network/xl1-protocol'
|
|
14
15
|
import { defaultTransactionFees } from '@xyo-network/xl1-protocol'
|
|
15
16
|
|
|
16
17
|
export async function buildTransaction(
|
|
17
|
-
chain:
|
|
18
|
+
chain: Chain,
|
|
18
19
|
onChainPayloads: AllowedBlockPayload[],
|
|
19
20
|
offChainPayloads: Payload[],
|
|
20
21
|
signer: AccountInstance | AccountInstance[],
|
|
@@ -22,7 +23,7 @@ export async function buildTransaction(
|
|
|
22
23
|
exp: number,
|
|
23
24
|
from?: Address,
|
|
24
25
|
fees: TransactionFeesBigInt = defaultTransactionFees,
|
|
25
|
-
): Promise<
|
|
26
|
+
): Promise<SignedHydratedTransactionWithStorageMeta> {
|
|
26
27
|
if (from === undefined && Array.isArray(signer)) {
|
|
27
28
|
throw new Error('from is required when signer is an array')
|
|
28
29
|
}
|
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
import type { Address
|
|
1
|
+
import type { Address } from '@xylabs/hex'
|
|
2
2
|
import { toHex } from '@xylabs/hex'
|
|
3
3
|
import { BoundWitnessBuilder } from '@xyo-network/boundwitness-builder'
|
|
4
4
|
import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
5
5
|
import type { Payload } from '@xyo-network/payload-model'
|
|
6
6
|
import type {
|
|
7
7
|
AllowedBlockPayload,
|
|
8
|
+
Chain,
|
|
8
9
|
ExecutableFields,
|
|
9
10
|
FromFields,
|
|
10
|
-
|
|
11
|
+
SignedHydratedTransactionWithStorageMeta, TransactionBoundWitness, TransactionBoundWitnessFields, TransactionFeesBigInt,
|
|
11
12
|
} from '@xyo-network/xl1-protocol'
|
|
12
13
|
import { defaultTransactionFees } from '@xyo-network/xl1-protocol'
|
|
13
14
|
|
|
14
15
|
export async function buildUnsignedTransaction(
|
|
15
|
-
chain:
|
|
16
|
+
chain: Chain,
|
|
16
17
|
onChainPayloads: AllowedBlockPayload[],
|
|
17
18
|
offChainPayloads: Payload[],
|
|
18
19
|
nbf: number,
|
|
19
20
|
exp: number,
|
|
20
21
|
from: Address,
|
|
21
22
|
fees: TransactionFeesBigInt = defaultTransactionFees,
|
|
22
|
-
): Promise<
|
|
23
|
+
): Promise<SignedHydratedTransactionWithStorageMeta> {
|
|
23
24
|
const txBoundWitnessFields: TransactionBoundWitnessFields = {
|
|
24
25
|
chain,
|
|
25
26
|
fees: {
|
|
@@ -4,7 +4,7 @@ import { isDefined } from '@xylabs/typeof'
|
|
|
4
4
|
import type { Signed } from '@xyo-network/boundwitness-model'
|
|
5
5
|
import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
6
6
|
import type {
|
|
7
|
-
|
|
7
|
+
SignedHydratedTransaction, TransactionBoundWitness, XyoViewer,
|
|
8
8
|
} from '@xyo-network/xl1-protocol'
|
|
9
9
|
|
|
10
10
|
const DEFAULT_CONFIRMATION_ATTEMPTS = 20
|
|
@@ -38,7 +38,7 @@ export const confirmSubmittedTransaction = async (
|
|
|
38
38
|
viewer: XyoViewer,
|
|
39
39
|
transaction: Signed<TransactionBoundWitness>,
|
|
40
40
|
options?: ConfirmSubmittedTransactionOptions,
|
|
41
|
-
): Promise<
|
|
41
|
+
): Promise<SignedHydratedTransaction> => {
|
|
42
42
|
const { attempts: maxAttempts = DEFAULT_CONFIRMATION_ATTEMPTS, delay: attemptDelay = DEFAULT_DELAY_BETWEEN_ATTEMPTS } = options || {}
|
|
43
43
|
const txBWHash = await PayloadBuilder.hash(transaction)
|
|
44
44
|
options?.logger?.log('🚀 confirming transaction:', txBWHash, '\n')
|
|
@@ -5,44 +5,44 @@ import { hydrateTypedBoundWitness, tryHydrateTypedBoundWitness } from '@xyo-netw
|
|
|
5
5
|
import type { Payload, WithStorageMeta } from '@xyo-network/payload-model'
|
|
6
6
|
import type {
|
|
7
7
|
AllowedBlockPayload,
|
|
8
|
-
|
|
8
|
+
SignedHydratedTransaction, SignedHydratedTransactionWithStorageMeta, TransactionBoundWitness,
|
|
9
9
|
} from '@xyo-network/xl1-protocol'
|
|
10
|
-
import { isAllowedBlockPayload,
|
|
10
|
+
import { isAllowedBlockPayload, isSignedTransactionBoundWitnessWithStorageMeta } from '@xyo-network/xl1-protocol'
|
|
11
11
|
|
|
12
12
|
export const tryHydrateTransaction = async (
|
|
13
13
|
archivist: ReadArchivist,
|
|
14
14
|
hash: Hash,
|
|
15
|
-
): Promise<
|
|
15
|
+
): Promise<SignedHydratedTransactionWithStorageMeta | undefined> => {
|
|
16
16
|
return (await tryHydrateTypedBoundWitness<TransactionBoundWitness>(
|
|
17
17
|
archivist,
|
|
18
18
|
hash,
|
|
19
|
-
|
|
20
|
-
)) as
|
|
19
|
+
isSignedTransactionBoundWitnessWithStorageMeta,
|
|
20
|
+
)) as SignedHydratedTransactionWithStorageMeta | undefined
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export const hydrateTransaction = async (
|
|
24
24
|
archivist: ReadArchivist,
|
|
25
25
|
hash: Hash,
|
|
26
|
-
): Promise<
|
|
26
|
+
): Promise<SignedHydratedTransaction> => {
|
|
27
27
|
return await hydrateTypedBoundWitness<TransactionBoundWitness>(
|
|
28
28
|
archivist,
|
|
29
29
|
hash,
|
|
30
|
-
|
|
31
|
-
) as
|
|
30
|
+
isSignedTransactionBoundWitnessWithStorageMeta,
|
|
31
|
+
) as SignedHydratedTransaction
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
export const flattenHydratedTransaction = (hydratedTransaction:
|
|
34
|
+
export const flattenHydratedTransaction = (hydratedTransaction: SignedHydratedTransaction): Payload[] => {
|
|
35
35
|
const [tx, txPayloads] = hydratedTransaction
|
|
36
36
|
return [...txPayloads, tx]
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
export const flattenHydratedTransactions = (hydratedTransactions:
|
|
39
|
+
export const flattenHydratedTransactions = (hydratedTransactions: SignedHydratedTransaction[]): Payload[] =>
|
|
40
40
|
hydratedTransactions.flatMap(tx => flattenHydratedTransaction(tx))
|
|
41
41
|
|
|
42
42
|
export const tryHydrateElevatedTransaction = async (
|
|
43
43
|
archivist: ReadArchivist,
|
|
44
44
|
hash: Hash,
|
|
45
|
-
): Promise<
|
|
45
|
+
): Promise<SignedHydratedTransactionWithStorageMeta | undefined> => {
|
|
46
46
|
const hydratedTransaction = await tryHydrateTransaction(archivist, hash)
|
|
47
47
|
if (!hydratedTransaction) {
|
|
48
48
|
return undefined
|
|
@@ -68,6 +68,6 @@ export const tryHydrateElevatedTransaction = async (
|
|
|
68
68
|
export const hydrateElevatedTransaction = async (
|
|
69
69
|
archivist: ReadArchivist,
|
|
70
70
|
hash: Hash,
|
|
71
|
-
): Promise<
|
|
71
|
+
): Promise<SignedHydratedTransaction> => {
|
|
72
72
|
return assertEx(await tryHydrateElevatedTransaction(archivist, hash), () => 'Hydration failed')
|
|
73
73
|
}
|