@xyo-network/xl1-rpc 1.2.3
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/LICENSE +165 -0
- package/README.md +44 -0
- package/dist/browser/index.mjs +1247 -0
- package/dist/browser/index.mjs.map +1 -0
- package/dist/neutral/index.mjs +1247 -0
- package/dist/neutral/index.mjs.map +1 -0
- package/dist/node/index.mjs +1247 -0
- package/dist/node/index.mjs.map +1 -0
- package/dist/types/engine/index.d.ts +2 -0
- package/dist/types/engine/index.d.ts.map +1 -0
- package/dist/types/engine/rpcEngineFromProvider.d.ts +4 -0
- package/dist/types/engine/rpcEngineFromProvider.d.ts.map +1 -0
- package/dist/types/engine/rpcMethodHandlersFromProvider.d.ts +4 -0
- package/dist/types/engine/rpcMethodHandlersFromProvider.d.ts.map +1 -0
- package/dist/types/engine/rpcMethodHandlersFromRunner.d.ts +4 -0
- package/dist/types/engine/rpcMethodHandlersFromRunner.d.ts.map +1 -0
- package/dist/types/engine/rpcMethodHandlersFromSigner.d.ts +4 -0
- package/dist/types/engine/rpcMethodHandlersFromSigner.d.ts.map +1 -0
- package/dist/types/engine/rpcMethodHandlersFromViewer.d.ts +4 -0
- package/dist/types/engine/rpcMethodHandlersFromViewer.d.ts.map +1 -0
- package/dist/types/engine/rpcMethodHandlersFromWallet.d.ts +4 -0
- package/dist/types/engine/rpcMethodHandlersFromWallet.d.ts.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/provider/index.d.ts +6 -0
- package/dist/types/provider/index.d.ts.map +1 -0
- package/dist/types/provider/provider/MemoryXyoProvider.d.ts +22 -0
- package/dist/types/provider/provider/MemoryXyoProvider.d.ts.map +1 -0
- package/dist/types/provider/provider/index.d.ts +2 -0
- package/dist/types/provider/provider/index.d.ts.map +1 -0
- package/dist/types/provider/runner/JsonRpcXyoRunner.d.ts +10 -0
- package/dist/types/provider/runner/JsonRpcXyoRunner.d.ts.map +1 -0
- package/dist/types/provider/runner/MemoryXyoRunner.d.ts +9 -0
- package/dist/types/provider/runner/MemoryXyoRunner.d.ts.map +1 -0
- package/dist/types/provider/runner/NodeXyoRunner.d.ts +35 -0
- package/dist/types/provider/runner/NodeXyoRunner.d.ts.map +1 -0
- package/dist/types/provider/runner/index.d.ts +4 -0
- package/dist/types/provider/runner/index.d.ts.map +1 -0
- package/dist/types/provider/signer/JsonRpcXyoSigner.d.ts +13 -0
- package/dist/types/provider/signer/JsonRpcXyoSigner.d.ts.map +1 -0
- package/dist/types/provider/signer/MemoryXyoSigner.d.ts +12 -0
- package/dist/types/provider/signer/MemoryXyoSigner.d.ts.map +1 -0
- package/dist/types/provider/signer/index.d.ts +3 -0
- package/dist/types/provider/signer/index.d.ts.map +1 -0
- package/dist/types/provider/viewer/JsonRpcXyoViewer.d.ts +20 -0
- package/dist/types/provider/viewer/JsonRpcXyoViewer.d.ts.map +1 -0
- package/dist/types/provider/viewer/NodeXyoViewer.d.ts +97 -0
- package/dist/types/provider/viewer/NodeXyoViewer.d.ts.map +1 -0
- package/dist/types/provider/viewer/index.d.ts +3 -0
- package/dist/types/provider/viewer/index.d.ts.map +1 -0
- package/dist/types/provider/wallet/JsonRpcXyoWallet.d.ts +17 -0
- package/dist/types/provider/wallet/JsonRpcXyoWallet.d.ts.map +1 -0
- package/dist/types/provider/wallet/MemoryXyoWallet.d.ts +18 -0
- package/dist/types/provider/wallet/MemoryXyoWallet.d.ts.map +1 -0
- package/dist/types/provider/wallet/index.d.ts +3 -0
- package/dist/types/provider/wallet/index.d.ts.map +1 -0
- package/dist/types/transport/HttpRpcTransport.d.ts +11 -0
- package/dist/types/transport/HttpRpcTransport.d.ts.map +1 -0
- package/dist/types/transport/MemoryRpcTransport.d.ts +14 -0
- package/dist/types/transport/MemoryRpcTransport.d.ts.map +1 -0
- package/dist/types/transport/RpcTransport.d.ts +6 -0
- package/dist/types/transport/RpcTransport.d.ts.map +1 -0
- package/dist/types/transport/index.d.ts +4 -0
- package/dist/types/transport/index.d.ts.map +1 -0
- package/dist/types/types/ErrorCodes.d.ts +5 -0
- package/dist/types/types/ErrorCodes.d.ts.map +1 -0
- package/dist/types/types/JsonRpc.d.ts +2 -0
- package/dist/types/types/JsonRpc.d.ts.map +1 -0
- package/dist/types/types/XyoProviderRpc.d.ts +11 -0
- package/dist/types/types/XyoProviderRpc.d.ts.map +1 -0
- package/dist/types/types/XyoRunnerRpc.d.ts +7 -0
- package/dist/types/types/XyoRunnerRpc.d.ts.map +1 -0
- package/dist/types/types/XyoSignerRpc.d.ts +7 -0
- package/dist/types/types/XyoSignerRpc.d.ts.map +1 -0
- package/dist/types/types/XyoViewerRpc.d.ts +7 -0
- package/dist/types/types/XyoViewerRpc.d.ts.map +1 -0
- package/dist/types/types/XyoWalletRpc.d.ts +7 -0
- package/dist/types/types/XyoWalletRpc.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +9 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/types/schema/AllRpcSchemas.d.ts +3 -0
- package/dist/types/types/schema/AllRpcSchemas.d.ts.map +1 -0
- package/dist/types/types/schema/RpcSchemaMap.d.ts +18 -0
- package/dist/types/types/schema/RpcSchemaMap.d.ts.map +1 -0
- package/dist/types/types/schema/XyoProviderRpcSchemas.d.ts +4 -0
- package/dist/types/types/schema/XyoProviderRpcSchemas.d.ts.map +1 -0
- package/dist/types/types/schema/XyoRunnerRpcSchemas.d.ts +4 -0
- package/dist/types/types/schema/XyoRunnerRpcSchemas.d.ts.map +1 -0
- package/dist/types/types/schema/XyoSignerRpcSchemas.d.ts +4 -0
- package/dist/types/types/schema/XyoSignerRpcSchemas.d.ts.map +1 -0
- package/dist/types/types/schema/XyoViewerRpcSchemas.d.ts +4 -0
- package/dist/types/types/schema/XyoViewerRpcSchemas.d.ts.map +1 -0
- package/dist/types/types/schema/XyoWalletRpcSchemas.d.ts +4 -0
- package/dist/types/types/schema/XyoWalletRpcSchemas.d.ts.map +1 -0
- package/dist/types/types/schema/common/AddressSchema.d.ts +4 -0
- package/dist/types/types/schema/common/AddressSchema.d.ts.map +1 -0
- package/dist/types/types/schema/common/BigIntSchema.d.ts +4 -0
- package/dist/types/types/schema/common/BigIntSchema.d.ts.map +1 -0
- package/dist/types/types/schema/common/BlockBoundWitnessSchema.d.ts +235 -0
- package/dist/types/types/schema/common/BlockBoundWitnessSchema.d.ts.map +1 -0
- package/dist/types/types/schema/common/BoundWitnessSchema.d.ts +163 -0
- package/dist/types/types/schema/common/BoundWitnessSchema.d.ts.map +1 -0
- package/dist/types/types/schema/common/HashSchema.d.ts +4 -0
- package/dist/types/types/schema/common/HashSchema.d.ts.map +1 -0
- package/dist/types/types/schema/common/HexSchema.d.ts +4 -0
- package/dist/types/types/schema/common/HexSchema.d.ts.map +1 -0
- package/dist/types/types/schema/common/HydratedBlockSchema.d.ts +282 -0
- package/dist/types/types/schema/common/HydratedBlockSchema.d.ts.map +1 -0
- package/dist/types/types/schema/common/HydratedTransactionSchema.d.ts +214 -0
- package/dist/types/types/schema/common/HydratedTransactionSchema.d.ts.map +1 -0
- package/dist/types/types/schema/common/PayloadSchema.d.ts +28 -0
- package/dist/types/types/schema/common/PayloadSchema.d.ts.map +1 -0
- package/dist/types/types/schema/common/SequenceSchema.d.ts +8 -0
- package/dist/types/types/schema/common/SequenceSchema.d.ts.map +1 -0
- package/dist/types/types/schema/common/StorageMetaSchema.d.ts +46 -0
- package/dist/types/types/schema/common/StorageMetaSchema.d.ts.map +1 -0
- package/dist/types/types/schema/common/TransactionBoundWitnessSchema.d.ts +258 -0
- package/dist/types/types/schema/common/TransactionBoundWitnessSchema.d.ts.map +1 -0
- package/dist/types/types/schema/common/TransactionFees.d.ts +34 -0
- package/dist/types/types/schema/common/TransactionFees.d.ts.map +1 -0
- package/dist/types/types/schema/common/index.d.ts +14 -0
- package/dist/types/types/schema/common/index.d.ts.map +1 -0
- package/dist/types/types/schema/createRequestSchema.d.ts +29 -0
- package/dist/types/types/schema/createRequestSchema.d.ts.map +1 -0
- package/dist/types/types/schema/createResponseSchema.d.ts +24 -0
- package/dist/types/types/schema/createResponseSchema.d.ts.map +1 -0
- package/dist/types/types/schema/index.d.ts +10 -0
- package/dist/types/types/schema/index.d.ts.map +1 -0
- package/package.json +91 -0
- package/src/engine/index.ts +1 -0
- package/src/engine/rpcEngineFromProvider.ts +61 -0
- package/src/engine/rpcMethodHandlersFromProvider.ts +19 -0
- package/src/engine/rpcMethodHandlersFromRunner.ts +7 -0
- package/src/engine/rpcMethodHandlersFromSigner.ts +10 -0
- package/src/engine/rpcMethodHandlersFromViewer.ts +19 -0
- package/src/engine/rpcMethodHandlersFromWallet.ts +16 -0
- package/src/index.ts +4 -0
- package/src/provider/index.ts +5 -0
- package/src/provider/provider/MemoryXyoProvider.ts +73 -0
- package/src/provider/provider/index.ts +1 -0
- package/src/provider/runner/JsonRpcXyoRunner.ts +16 -0
- package/src/provider/runner/MemoryXyoRunner.ts +22 -0
- package/src/provider/runner/NodeXyoRunner.ts +41 -0
- package/src/provider/runner/index.ts +3 -0
- package/src/provider/signer/JsonRpcXyoSigner.ts +43 -0
- package/src/provider/signer/MemoryXyoSigner.ts +43 -0
- package/src/provider/signer/index.ts +2 -0
- package/src/provider/viewer/JsonRpcXyoViewer.ts +58 -0
- package/src/provider/viewer/NodeXyoViewer.ts +179 -0
- package/src/provider/viewer/index.ts +2 -0
- package/src/provider/wallet/JsonRpcXyoWallet.ts +45 -0
- package/src/provider/wallet/MemoryXyoWallet.ts +51 -0
- package/src/provider/wallet/index.ts +2 -0
- package/src/transport/HttpRpcTransport.ts +59 -0
- package/src/transport/MemoryRpcTransport.ts +49 -0
- package/src/transport/RpcTransport.ts +12 -0
- package/src/transport/index.ts +3 -0
- package/src/types/ErrorCodes.ts +9 -0
- package/src/types/JsonRpc.ts +1 -0
- package/src/types/XyoProviderRpc.ts +22 -0
- package/src/types/XyoRunnerRpc.ts +13 -0
- package/src/types/XyoSignerRpc.ts +13 -0
- package/src/types/XyoViewerRpc.ts +13 -0
- package/src/types/XyoWalletRpc.ts +13 -0
- package/src/types/index.ts +8 -0
- package/src/types/schema/AllRpcSchemas.ts +14 -0
- package/src/types/schema/RpcSchemaMap.ts +22 -0
- package/src/types/schema/XyoProviderRpcSchemas.ts +37 -0
- package/src/types/schema/XyoRunnerRpcSchemas.ts +22 -0
- package/src/types/schema/XyoSignerRpcSchemas.ts +47 -0
- package/src/types/schema/XyoViewerRpcSchemas.ts +124 -0
- package/src/types/schema/XyoWalletRpcSchemas.ts +91 -0
- package/src/types/schema/common/AddressSchema.ts +9 -0
- package/src/types/schema/common/BigIntSchema.ts +8 -0
- package/src/types/schema/common/BlockBoundWitnessSchema.ts +30 -0
- package/src/types/schema/common/BoundWitnessSchema.ts +45 -0
- package/src/types/schema/common/HashSchema.ts +7 -0
- package/src/types/schema/common/HexSchema.ts +7 -0
- package/src/types/schema/common/HydratedBlockSchema.ts +26 -0
- package/src/types/schema/common/HydratedTransactionSchema.ts +14 -0
- package/src/types/schema/common/PayloadSchema.ts +6 -0
- package/src/types/schema/common/SequenceSchema.ts +19 -0
- package/src/types/schema/common/StorageMetaSchema.ts +14 -0
- package/src/types/schema/common/TransactionBoundWitnessSchema.ts +33 -0
- package/src/types/schema/common/TransactionFees.ts +17 -0
- package/src/types/schema/common/index.ts +13 -0
- package/src/types/schema/createRequestSchema.ts +15 -0
- package/src/types/schema/createResponseSchema.ts +13 -0
- package/src/types/schema/index.ts +9 -0
- package/vitest.config.ts +11 -0
- package/xy.config.ts +10 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
export declare const BlockStartSchema: z.ZodObject<{
|
|
3
|
+
nbf: z.ZodNumber;
|
|
4
|
+
}, "strip", z.ZodTypeAny, {
|
|
5
|
+
nbf: number;
|
|
6
|
+
}, {
|
|
7
|
+
nbf: number;
|
|
8
|
+
}>;
|
|
9
|
+
export declare const BlockEndSchema: z.ZodObject<{
|
|
10
|
+
exp: z.ZodNumber;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
exp: number;
|
|
13
|
+
}, {
|
|
14
|
+
exp: number;
|
|
15
|
+
}>;
|
|
16
|
+
export declare const BlockDurationSchema: z.ZodObject<{
|
|
17
|
+
nbf: z.ZodNumber;
|
|
18
|
+
exp: z.ZodNumber;
|
|
19
|
+
}, "strip", z.ZodTypeAny, {
|
|
20
|
+
nbf: number;
|
|
21
|
+
exp: number;
|
|
22
|
+
}, {
|
|
23
|
+
nbf: number;
|
|
24
|
+
exp: number;
|
|
25
|
+
}>;
|
|
26
|
+
export declare const TransactionFeesSchema: z.ZodObject<{
|
|
27
|
+
fees: z.ZodObject<{
|
|
28
|
+
base: z.ZodString;
|
|
29
|
+
gasLimit: z.ZodString;
|
|
30
|
+
gasPrice: z.ZodString;
|
|
31
|
+
priority: z.ZodString;
|
|
32
|
+
}, "strip", z.ZodTypeAny, {
|
|
33
|
+
base: string;
|
|
34
|
+
gasLimit: string;
|
|
35
|
+
gasPrice: string;
|
|
36
|
+
priority: string;
|
|
37
|
+
}, {
|
|
38
|
+
base: string;
|
|
39
|
+
gasLimit: string;
|
|
40
|
+
gasPrice: string;
|
|
41
|
+
priority: string;
|
|
42
|
+
}>;
|
|
43
|
+
}, "strip", z.ZodTypeAny, {
|
|
44
|
+
fees: {
|
|
45
|
+
base: string;
|
|
46
|
+
gasLimit: string;
|
|
47
|
+
gasPrice: string;
|
|
48
|
+
priority: string;
|
|
49
|
+
};
|
|
50
|
+
}, {
|
|
51
|
+
fees: {
|
|
52
|
+
base: string;
|
|
53
|
+
gasLimit: string;
|
|
54
|
+
gasPrice: string;
|
|
55
|
+
priority: string;
|
|
56
|
+
};
|
|
57
|
+
}>;
|
|
58
|
+
export declare const TransactionBoundWitnessSchema: z.ZodObject<{} & {
|
|
59
|
+
schema: z.ZodLiteral<"network.xyo.boundwitness">;
|
|
60
|
+
} & {
|
|
61
|
+
addresses: z.ZodArray<z.ZodString, "many">;
|
|
62
|
+
payload_hashes: z.ZodArray<z.ZodString, "many">;
|
|
63
|
+
payload_schemas: z.ZodArray<z.ZodString, "many">;
|
|
64
|
+
previous_hashes: z.ZodArray<z.ZodNullable<z.ZodString>, "many">;
|
|
65
|
+
} & {
|
|
66
|
+
$destination: z.ZodOptional<z.ZodString>;
|
|
67
|
+
$sourceQuery: z.ZodOptional<z.ZodString>;
|
|
68
|
+
} & {
|
|
69
|
+
nbf: z.ZodNumber;
|
|
70
|
+
exp: z.ZodNumber;
|
|
71
|
+
} & {
|
|
72
|
+
fees: z.ZodObject<{
|
|
73
|
+
base: z.ZodString;
|
|
74
|
+
gasLimit: z.ZodString;
|
|
75
|
+
gasPrice: z.ZodString;
|
|
76
|
+
priority: z.ZodString;
|
|
77
|
+
}, "strip", z.ZodTypeAny, {
|
|
78
|
+
base: string;
|
|
79
|
+
gasLimit: string;
|
|
80
|
+
gasPrice: string;
|
|
81
|
+
priority: string;
|
|
82
|
+
}, {
|
|
83
|
+
base: string;
|
|
84
|
+
gasLimit: string;
|
|
85
|
+
gasPrice: string;
|
|
86
|
+
priority: string;
|
|
87
|
+
}>;
|
|
88
|
+
} & {
|
|
89
|
+
chain: z.ZodString;
|
|
90
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{} & {
|
|
91
|
+
schema: z.ZodLiteral<"network.xyo.boundwitness">;
|
|
92
|
+
} & {
|
|
93
|
+
addresses: z.ZodArray<z.ZodString, "many">;
|
|
94
|
+
payload_hashes: z.ZodArray<z.ZodString, "many">;
|
|
95
|
+
payload_schemas: z.ZodArray<z.ZodString, "many">;
|
|
96
|
+
previous_hashes: z.ZodArray<z.ZodNullable<z.ZodString>, "many">;
|
|
97
|
+
} & {
|
|
98
|
+
$destination: z.ZodOptional<z.ZodString>;
|
|
99
|
+
$sourceQuery: z.ZodOptional<z.ZodString>;
|
|
100
|
+
} & {
|
|
101
|
+
nbf: z.ZodNumber;
|
|
102
|
+
exp: z.ZodNumber;
|
|
103
|
+
} & {
|
|
104
|
+
fees: z.ZodObject<{
|
|
105
|
+
base: z.ZodString;
|
|
106
|
+
gasLimit: z.ZodString;
|
|
107
|
+
gasPrice: z.ZodString;
|
|
108
|
+
priority: z.ZodString;
|
|
109
|
+
}, "strip", z.ZodTypeAny, {
|
|
110
|
+
base: string;
|
|
111
|
+
gasLimit: string;
|
|
112
|
+
gasPrice: string;
|
|
113
|
+
priority: string;
|
|
114
|
+
}, {
|
|
115
|
+
base: string;
|
|
116
|
+
gasLimit: string;
|
|
117
|
+
gasPrice: string;
|
|
118
|
+
priority: string;
|
|
119
|
+
}>;
|
|
120
|
+
} & {
|
|
121
|
+
chain: z.ZodString;
|
|
122
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{} & {
|
|
123
|
+
schema: z.ZodLiteral<"network.xyo.boundwitness">;
|
|
124
|
+
} & {
|
|
125
|
+
addresses: z.ZodArray<z.ZodString, "many">;
|
|
126
|
+
payload_hashes: z.ZodArray<z.ZodString, "many">;
|
|
127
|
+
payload_schemas: z.ZodArray<z.ZodString, "many">;
|
|
128
|
+
previous_hashes: z.ZodArray<z.ZodNullable<z.ZodString>, "many">;
|
|
129
|
+
} & {
|
|
130
|
+
$destination: z.ZodOptional<z.ZodString>;
|
|
131
|
+
$sourceQuery: z.ZodOptional<z.ZodString>;
|
|
132
|
+
} & {
|
|
133
|
+
nbf: z.ZodNumber;
|
|
134
|
+
exp: z.ZodNumber;
|
|
135
|
+
} & {
|
|
136
|
+
fees: z.ZodObject<{
|
|
137
|
+
base: z.ZodString;
|
|
138
|
+
gasLimit: z.ZodString;
|
|
139
|
+
gasPrice: z.ZodString;
|
|
140
|
+
priority: z.ZodString;
|
|
141
|
+
}, "strip", z.ZodTypeAny, {
|
|
142
|
+
base: string;
|
|
143
|
+
gasLimit: string;
|
|
144
|
+
gasPrice: string;
|
|
145
|
+
priority: string;
|
|
146
|
+
}, {
|
|
147
|
+
base: string;
|
|
148
|
+
gasLimit: string;
|
|
149
|
+
gasPrice: string;
|
|
150
|
+
priority: string;
|
|
151
|
+
}>;
|
|
152
|
+
} & {
|
|
153
|
+
chain: z.ZodString;
|
|
154
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
155
|
+
export declare const SignedTransactionBoundWitnessSchema: z.ZodObject<{} & {
|
|
156
|
+
schema: z.ZodLiteral<"network.xyo.boundwitness">;
|
|
157
|
+
} & {
|
|
158
|
+
addresses: z.ZodArray<z.ZodString, "many">;
|
|
159
|
+
payload_hashes: z.ZodArray<z.ZodString, "many">;
|
|
160
|
+
payload_schemas: z.ZodArray<z.ZodString, "many">;
|
|
161
|
+
previous_hashes: z.ZodArray<z.ZodNullable<z.ZodString>, "many">;
|
|
162
|
+
} & {
|
|
163
|
+
$destination: z.ZodOptional<z.ZodString>;
|
|
164
|
+
$sourceQuery: z.ZodOptional<z.ZodString>;
|
|
165
|
+
} & {
|
|
166
|
+
$signatures: z.ZodArray<z.ZodString, "many">;
|
|
167
|
+
} & {
|
|
168
|
+
nbf: z.ZodNumber;
|
|
169
|
+
exp: z.ZodNumber;
|
|
170
|
+
} & {
|
|
171
|
+
fees: z.ZodObject<{
|
|
172
|
+
base: z.ZodString;
|
|
173
|
+
gasLimit: z.ZodString;
|
|
174
|
+
gasPrice: z.ZodString;
|
|
175
|
+
priority: z.ZodString;
|
|
176
|
+
}, "strip", z.ZodTypeAny, {
|
|
177
|
+
base: string;
|
|
178
|
+
gasLimit: string;
|
|
179
|
+
gasPrice: string;
|
|
180
|
+
priority: string;
|
|
181
|
+
}, {
|
|
182
|
+
base: string;
|
|
183
|
+
gasLimit: string;
|
|
184
|
+
gasPrice: string;
|
|
185
|
+
priority: string;
|
|
186
|
+
}>;
|
|
187
|
+
} & {
|
|
188
|
+
chain: z.ZodString;
|
|
189
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{} & {
|
|
190
|
+
schema: z.ZodLiteral<"network.xyo.boundwitness">;
|
|
191
|
+
} & {
|
|
192
|
+
addresses: z.ZodArray<z.ZodString, "many">;
|
|
193
|
+
payload_hashes: z.ZodArray<z.ZodString, "many">;
|
|
194
|
+
payload_schemas: z.ZodArray<z.ZodString, "many">;
|
|
195
|
+
previous_hashes: z.ZodArray<z.ZodNullable<z.ZodString>, "many">;
|
|
196
|
+
} & {
|
|
197
|
+
$destination: z.ZodOptional<z.ZodString>;
|
|
198
|
+
$sourceQuery: z.ZodOptional<z.ZodString>;
|
|
199
|
+
} & {
|
|
200
|
+
$signatures: z.ZodArray<z.ZodString, "many">;
|
|
201
|
+
} & {
|
|
202
|
+
nbf: z.ZodNumber;
|
|
203
|
+
exp: z.ZodNumber;
|
|
204
|
+
} & {
|
|
205
|
+
fees: z.ZodObject<{
|
|
206
|
+
base: z.ZodString;
|
|
207
|
+
gasLimit: z.ZodString;
|
|
208
|
+
gasPrice: z.ZodString;
|
|
209
|
+
priority: z.ZodString;
|
|
210
|
+
}, "strip", z.ZodTypeAny, {
|
|
211
|
+
base: string;
|
|
212
|
+
gasLimit: string;
|
|
213
|
+
gasPrice: string;
|
|
214
|
+
priority: string;
|
|
215
|
+
}, {
|
|
216
|
+
base: string;
|
|
217
|
+
gasLimit: string;
|
|
218
|
+
gasPrice: string;
|
|
219
|
+
priority: string;
|
|
220
|
+
}>;
|
|
221
|
+
} & {
|
|
222
|
+
chain: z.ZodString;
|
|
223
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{} & {
|
|
224
|
+
schema: z.ZodLiteral<"network.xyo.boundwitness">;
|
|
225
|
+
} & {
|
|
226
|
+
addresses: z.ZodArray<z.ZodString, "many">;
|
|
227
|
+
payload_hashes: z.ZodArray<z.ZodString, "many">;
|
|
228
|
+
payload_schemas: z.ZodArray<z.ZodString, "many">;
|
|
229
|
+
previous_hashes: z.ZodArray<z.ZodNullable<z.ZodString>, "many">;
|
|
230
|
+
} & {
|
|
231
|
+
$destination: z.ZodOptional<z.ZodString>;
|
|
232
|
+
$sourceQuery: z.ZodOptional<z.ZodString>;
|
|
233
|
+
} & {
|
|
234
|
+
$signatures: z.ZodArray<z.ZodString, "many">;
|
|
235
|
+
} & {
|
|
236
|
+
nbf: z.ZodNumber;
|
|
237
|
+
exp: z.ZodNumber;
|
|
238
|
+
} & {
|
|
239
|
+
fees: z.ZodObject<{
|
|
240
|
+
base: z.ZodString;
|
|
241
|
+
gasLimit: z.ZodString;
|
|
242
|
+
gasPrice: z.ZodString;
|
|
243
|
+
priority: z.ZodString;
|
|
244
|
+
}, "strip", z.ZodTypeAny, {
|
|
245
|
+
base: string;
|
|
246
|
+
gasLimit: string;
|
|
247
|
+
gasPrice: string;
|
|
248
|
+
priority: string;
|
|
249
|
+
}, {
|
|
250
|
+
base: string;
|
|
251
|
+
gasLimit: string;
|
|
252
|
+
gasPrice: string;
|
|
253
|
+
priority: string;
|
|
254
|
+
}>;
|
|
255
|
+
} & {
|
|
256
|
+
chain: z.ZodString;
|
|
257
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
258
|
+
//# sourceMappingURL=TransactionBoundWitnessSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransactionBoundWitnessSchema.d.ts","sourceRoot":"","sources":["../../../../../src/types/schema/common/TransactionBoundWitnessSchema.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAA;AAOnB,eAAO,MAAM,gBAAgB;;;;;;EAAuC,CAAA;AACpE,eAAO,MAAM,cAAc;;;;;;EAAuC,CAAA;AAClE,eAAO,MAAM,mBAAmB;;;;;;;;;EAA+D,CAAA;AAE/F,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOhC,CAAA;AAIF,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAI1B,CAAA;AAEhB,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAIhC,CAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const TransactionFeesToStingSchema: z.ZodObject<{
|
|
3
|
+
base: z.ZodEffects<z.ZodBigInt, Lowercase<string>, bigint>;
|
|
4
|
+
gasLimit: z.ZodEffects<z.ZodBigInt, Lowercase<string>, bigint>;
|
|
5
|
+
gasPrice: z.ZodEffects<z.ZodBigInt, Lowercase<string>, bigint>;
|
|
6
|
+
priority: z.ZodEffects<z.ZodBigInt, Lowercase<string>, bigint>;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
base: Lowercase<string>;
|
|
9
|
+
gasLimit: Lowercase<string>;
|
|
10
|
+
gasPrice: Lowercase<string>;
|
|
11
|
+
priority: Lowercase<string>;
|
|
12
|
+
}, {
|
|
13
|
+
base: bigint;
|
|
14
|
+
gasLimit: bigint;
|
|
15
|
+
gasPrice: bigint;
|
|
16
|
+
priority: bigint;
|
|
17
|
+
}>;
|
|
18
|
+
export declare const TransactionFeesFromStingSchema: z.ZodObject<{
|
|
19
|
+
base: z.ZodEffects<z.ZodString, bigint, string>;
|
|
20
|
+
gasLimit: z.ZodEffects<z.ZodString, bigint, string>;
|
|
21
|
+
gasPrice: z.ZodEffects<z.ZodString, bigint, string>;
|
|
22
|
+
priority: z.ZodEffects<z.ZodString, bigint, string>;
|
|
23
|
+
}, "strip", z.ZodTypeAny, {
|
|
24
|
+
base: bigint;
|
|
25
|
+
gasLimit: bigint;
|
|
26
|
+
gasPrice: bigint;
|
|
27
|
+
priority: bigint;
|
|
28
|
+
}, {
|
|
29
|
+
base: string;
|
|
30
|
+
gasLimit: string;
|
|
31
|
+
gasPrice: string;
|
|
32
|
+
priority: string;
|
|
33
|
+
}>;
|
|
34
|
+
//# sourceMappingURL=TransactionFees.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransactionFees.d.ts","sourceRoot":"","sources":["../../../../../src/types/schema/common/TransactionFees.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;EAKvC,CAAA;AAEF,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;EAKzC,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from './AddressSchema.ts';
|
|
2
|
+
export * from './BigIntSchema.ts';
|
|
3
|
+
export * from './BlockBoundWitnessSchema.ts';
|
|
4
|
+
export * from './BoundWitnessSchema.ts';
|
|
5
|
+
export * from './HashSchema.ts';
|
|
6
|
+
export * from './HexSchema.ts';
|
|
7
|
+
export * from './HydratedBlockSchema.ts';
|
|
8
|
+
export * from './HydratedTransactionSchema.ts';
|
|
9
|
+
export * from './PayloadSchema.ts';
|
|
10
|
+
export * from './SequenceSchema.ts';
|
|
11
|
+
export * from './StorageMetaSchema.ts';
|
|
12
|
+
export * from './TransactionBoundWitnessSchema.ts';
|
|
13
|
+
export * from './TransactionFees.ts';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/types/schema/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AACjC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,yBAAyB,CAAA;AACvC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,0BAA0B,CAAA;AACxC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,wBAAwB,CAAA;AACtC,cAAc,oCAAoC,CAAA;AAClD,cAAc,sBAAsB,CAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ZodUndefined } from 'zod';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare const createRequestSchema: <TParams extends z.ZodTypeAny, TMethodName extends string = string>(methodName: TMethodName, paramsSchema?: TParams | ZodUndefined) => z.ZodObject<{
|
|
4
|
+
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
5
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
6
|
+
method: z.ZodLiteral<TMethodName>;
|
|
7
|
+
params: TParams | ZodUndefined;
|
|
8
|
+
}, "strip", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{
|
|
9
|
+
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
10
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
11
|
+
method: z.ZodLiteral<TMethodName>;
|
|
12
|
+
params: TParams | ZodUndefined;
|
|
13
|
+
}>, any> extends infer T ? { [k in keyof T]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{
|
|
14
|
+
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
15
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
16
|
+
method: z.ZodLiteral<TMethodName>;
|
|
17
|
+
params: TParams | ZodUndefined;
|
|
18
|
+
}>, any>[k]; } : never, z.baseObjectInputType<{
|
|
19
|
+
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
20
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
21
|
+
method: z.ZodLiteral<TMethodName>;
|
|
22
|
+
params: TParams | ZodUndefined;
|
|
23
|
+
}> extends infer T_1 ? { [k_1 in keyof T_1]: z.baseObjectInputType<{
|
|
24
|
+
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
25
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
26
|
+
method: z.ZodLiteral<TMethodName>;
|
|
27
|
+
params: TParams | ZodUndefined;
|
|
28
|
+
}>[k_1]; } : never>;
|
|
29
|
+
//# sourceMappingURL=createRequestSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createRequestSchema.d.ts","sourceRoot":"","sources":["../../../../src/types/schema/createRequestSchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,KAAK,CAAA;AACvC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,eAAO,MAAM,mBAAmB,GAAI,OAAO,SAAS,CAAC,CAAC,UAAU,EAAE,WAAW,SAAS,MAAM,GAAG,MAAM,EACnG,YAAY,WAAW,EACvB,eAAc,OAAO,GAAG,YAA4B;;;;;;;;;;;;;;;;;;;;;;;;;mBAOlD,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ZodUndefined } from 'zod';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare const createResponseSchema: <TParams extends z.ZodTypeAny>(resultSchema?: TParams | ZodUndefined) => z.ZodObject<{
|
|
4
|
+
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
5
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
6
|
+
result: ZodUndefined | TParams;
|
|
7
|
+
}, "strip", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{
|
|
8
|
+
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
9
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
10
|
+
result: ZodUndefined | TParams;
|
|
11
|
+
}>, any> extends infer T ? { [k in keyof T]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{
|
|
12
|
+
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
13
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
14
|
+
result: ZodUndefined | TParams;
|
|
15
|
+
}>, any>[k]; } : never, z.baseObjectInputType<{
|
|
16
|
+
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
17
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
18
|
+
result: ZodUndefined | TParams;
|
|
19
|
+
}> extends infer T_1 ? { [k_1 in keyof T_1]: z.baseObjectInputType<{
|
|
20
|
+
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
21
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
22
|
+
result: ZodUndefined | TParams;
|
|
23
|
+
}>[k_1]; } : never>;
|
|
24
|
+
//# sourceMappingURL=createResponseSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createResponseSchema.d.ts","sourceRoot":"","sources":["../../../../src/types/schema/createResponseSchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,KAAK,CAAA;AACvC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,eAAO,MAAM,oBAAoB,GAAI,OAAO,SAAS,CAAC,CAAC,UAAU,EAC/D,eAAc,OAAO,GAAG,YAA4B;;;;;;;;;;;;;;;;;;;;mBAMlD,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './AllRpcSchemas.ts';
|
|
2
|
+
export * from './createRequestSchema.ts';
|
|
3
|
+
export * from './createResponseSchema.ts';
|
|
4
|
+
export * from './RpcSchemaMap.ts';
|
|
5
|
+
export * from './XyoProviderRpcSchemas.ts';
|
|
6
|
+
export * from './XyoRunnerRpcSchemas.ts';
|
|
7
|
+
export * from './XyoSignerRpcSchemas.ts';
|
|
8
|
+
export * from './XyoViewerRpcSchemas.ts';
|
|
9
|
+
export * from './XyoWalletRpcSchemas.ts';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/schema/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,0BAA0B,CAAA;AACxC,cAAc,2BAA2B,CAAA;AACzC,cAAc,mBAAmB,CAAA;AACjC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,0BAA0B,CAAA;AACxC,cAAc,0BAA0B,CAAA;AACxC,cAAc,0BAA0B,CAAA;AACxC,cAAc,0BAA0B,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json.schemastore.org/package.json",
|
|
3
|
+
"name": "@xyo-network/xl1-rpc",
|
|
4
|
+
"version": "1.2.3",
|
|
5
|
+
"description": "XYO Layer One API",
|
|
6
|
+
"homepage": "https://xylabs.com",
|
|
7
|
+
"bugs": {
|
|
8
|
+
"url": "git+https://github.com/xylabs/xyo-chain/issues",
|
|
9
|
+
"email": "support@xylabs.com"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/xylabs/xyo-chain.git"
|
|
14
|
+
},
|
|
15
|
+
"license": "LGPL-3.0-only",
|
|
16
|
+
"author": {
|
|
17
|
+
"name": "XY Labs Development Team",
|
|
18
|
+
"email": "support@xylabs.com",
|
|
19
|
+
"url": "https://xylabs.com"
|
|
20
|
+
},
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"type": "module",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"browser": {
|
|
26
|
+
"types": "./dist/types/index.d.ts",
|
|
27
|
+
"default": "./dist/browser/index.mjs"
|
|
28
|
+
},
|
|
29
|
+
"node": {
|
|
30
|
+
"types": "./dist/types/index.d.ts",
|
|
31
|
+
"default": "./dist/node/index.mjs"
|
|
32
|
+
},
|
|
33
|
+
"neutral": {
|
|
34
|
+
"types": "./dist/types/index.d.ts",
|
|
35
|
+
"default": "./dist/neutral/index.mjs"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"./package.json": "./package.json"
|
|
39
|
+
},
|
|
40
|
+
"module": "./dist/neutral/index.mjs",
|
|
41
|
+
"types": "./dist/types/index.d.ts",
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build-tests": "tsc --noEmit --lib dom,esnext",
|
|
44
|
+
"deploy": "echo Deploy not allowed!",
|
|
45
|
+
"deploy3": "echo Deploy3 not allowed!",
|
|
46
|
+
"start": "nodemon",
|
|
47
|
+
"start-esm": "node ./dist/node/index.mjs",
|
|
48
|
+
"test": "vitest run",
|
|
49
|
+
"test:ci": "vitest run",
|
|
50
|
+
"types": "tsc --noEmit -p tsconfig.test.json"
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"@metamask/json-rpc-engine": "^10.0.3",
|
|
54
|
+
"@metamask/utils": "^11.4.0",
|
|
55
|
+
"@xylabs/assert": "^4.8.7",
|
|
56
|
+
"@xylabs/axios": "^4.8.7",
|
|
57
|
+
"@xylabs/hex": "^4.8.7",
|
|
58
|
+
"@xyo-network/archivist-memory": "^3.13.0",
|
|
59
|
+
"@xyo-network/boundwitness-model": "^3.13.0",
|
|
60
|
+
"@xyo-network/chain-modules": "^1.3.3",
|
|
61
|
+
"@xyo-network/diviner-model": "^3.13.0",
|
|
62
|
+
"@xyo-network/module-model": "^3.13.0",
|
|
63
|
+
"@xyo-network/node-model": "^3.13.0",
|
|
64
|
+
"@xyo-network/payload-model": "^3.13.0",
|
|
65
|
+
"@xyo-network/payload-wrapper": "^3.13.0",
|
|
66
|
+
"@xyo-network/xl1-model": "^1.3.3",
|
|
67
|
+
"@xyo-network/xl1-protocol": "^1.3.3",
|
|
68
|
+
"uuid": "^11.1.0",
|
|
69
|
+
"zod": "^3.24.3"
|
|
70
|
+
},
|
|
71
|
+
"devDependencies": {
|
|
72
|
+
"@types/node": "^22.14.1",
|
|
73
|
+
"@xylabs/ts-scripts-yarn3": "^6.3.4",
|
|
74
|
+
"@xylabs/tsconfig": "^6.3.4",
|
|
75
|
+
"dotenv": "^16.5.0",
|
|
76
|
+
"nodemon": "^3.1.9",
|
|
77
|
+
"typescript": "^5.8.3",
|
|
78
|
+
"vitest": "^3.1.2"
|
|
79
|
+
},
|
|
80
|
+
"packageManager": "yarn@4.6.0",
|
|
81
|
+
"engines": {
|
|
82
|
+
"node": ">=22"
|
|
83
|
+
},
|
|
84
|
+
"volta": {
|
|
85
|
+
"node": "22.5.1",
|
|
86
|
+
"yarn": "4.6.0"
|
|
87
|
+
},
|
|
88
|
+
"publishConfig": {
|
|
89
|
+
"access": "public"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './rpcEngineFromProvider.ts'
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { createAsyncMiddleware, JsonRpcEngine } from '@metamask/json-rpc-engine'
|
|
2
|
+
import type { Json } from '@metamask/utils'
|
|
3
|
+
import type { XyoProvider } from '@xyo-network/xl1-model'
|
|
4
|
+
import type { z } from 'zod'
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
AllRpcSchemas,
|
|
8
|
+
createRequestSchema,
|
|
9
|
+
JsonRpcErrorCodes,
|
|
10
|
+
} from '../types/index.ts'
|
|
11
|
+
import { rpcMethodHandlersFromProvider } from './rpcMethodHandlersFromProvider.ts'
|
|
12
|
+
|
|
13
|
+
const requestSchemas: Record<string, z.AnyZodObject> = {}
|
|
14
|
+
|
|
15
|
+
export const rpcEngineFromProvider = (provider: XyoProvider) => {
|
|
16
|
+
const engine = new JsonRpcEngine()
|
|
17
|
+
const handlers = rpcMethodHandlersFromProvider(provider)
|
|
18
|
+
engine.push(
|
|
19
|
+
createAsyncMiddleware(async (req, res) => {
|
|
20
|
+
// Get method name
|
|
21
|
+
const method = req.method as keyof typeof handlers & keyof typeof requestSchemas
|
|
22
|
+
// Get schema for method
|
|
23
|
+
const handler = handlers[method]
|
|
24
|
+
// Get handler for method
|
|
25
|
+
const schema = AllRpcSchemas[method]
|
|
26
|
+
|
|
27
|
+
// If no schema or handler exists
|
|
28
|
+
if (!schema || !handler) {
|
|
29
|
+
// return method not found error
|
|
30
|
+
res.error = JsonRpcErrorCodes.MethodNotFound
|
|
31
|
+
return
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Validate request according to schema
|
|
35
|
+
let requestSchema = requestSchemas[method]
|
|
36
|
+
if (!requestSchema) {
|
|
37
|
+
requestSchema = createRequestSchema(method, schema.params.from)
|
|
38
|
+
requestSchemas[method] = requestSchema
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const parsed = requestSchema.safeParse(req)
|
|
42
|
+
// If validation fails
|
|
43
|
+
if (!parsed.success) {
|
|
44
|
+
res.error = {
|
|
45
|
+
// Return invalid params error
|
|
46
|
+
...JsonRpcErrorCodes.InvalidParams,
|
|
47
|
+
// with the specific validation error message
|
|
48
|
+
message: parsed.error.message,
|
|
49
|
+
}
|
|
50
|
+
return
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Call handler with validated params
|
|
54
|
+
const { params } = parsed.data
|
|
55
|
+
const result = await handler(params as never)
|
|
56
|
+
// Parse handler result according to schema
|
|
57
|
+
res.result = schema.result.to.parse(result) as Json
|
|
58
|
+
}),
|
|
59
|
+
)
|
|
60
|
+
return engine
|
|
61
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { XyoProvider } from '@xyo-network/xl1-model'
|
|
2
|
+
|
|
3
|
+
import type { XyoProviderRpcMethodHandlers } from '../types/index.ts'
|
|
4
|
+
import { rpcMethodHandlersFromRunner } from './rpcMethodHandlersFromRunner.ts'
|
|
5
|
+
import { rpcMethodHandlersFromSigner } from './rpcMethodHandlersFromSigner.ts'
|
|
6
|
+
import { rpcMethodHandlersFromViewer } from './rpcMethodHandlersFromViewer.ts'
|
|
7
|
+
import { rpcMethodHandlersFromWallet } from './rpcMethodHandlersFromWallet.ts'
|
|
8
|
+
|
|
9
|
+
export const rpcMethodHandlersFromProvider = (provider: XyoProvider): XyoProviderRpcMethodHandlers => {
|
|
10
|
+
const {
|
|
11
|
+
runner, signer, viewer, wallet,
|
|
12
|
+
} = provider
|
|
13
|
+
let result: XyoProviderRpcMethodHandlers = { xyoProvider_send: params => (provider as Required<XyoProvider>).send(...(params ?? [])) }
|
|
14
|
+
if (runner) result = { ...result, ...rpcMethodHandlersFromRunner(runner) }
|
|
15
|
+
if (signer) result = { ...result, ...rpcMethodHandlersFromSigner(signer) }
|
|
16
|
+
if (viewer) result = { ...result, ...rpcMethodHandlersFromViewer(viewer) }
|
|
17
|
+
if (wallet) result = { ...result, ...rpcMethodHandlersFromWallet(wallet) }
|
|
18
|
+
return result
|
|
19
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { XyoRunner } from '@xyo-network/xl1-model'
|
|
2
|
+
|
|
3
|
+
import type { XyoRunnerRpcMethodHandlers } from '../types/index.ts'
|
|
4
|
+
|
|
5
|
+
export const rpcMethodHandlersFromRunner = (runner: XyoRunner): XyoRunnerRpcMethodHandlers => {
|
|
6
|
+
return { xyoRunner_broadcastTransaction: params => runner.broadcastTransaction(...(params ?? [])) }
|
|
7
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { XyoSigner } from '@xyo-network/xl1-model'
|
|
2
|
+
|
|
3
|
+
import type { XyoSignerRpcMethodHandlers } from '../types/index.ts'
|
|
4
|
+
|
|
5
|
+
export const rpcMethodHandlersFromSigner = (signer: XyoSigner): XyoSignerRpcMethodHandlers => {
|
|
6
|
+
return {
|
|
7
|
+
xyoSigner_address: params => signer.address(...(params ?? [])),
|
|
8
|
+
xyoSigner_createSignedTransaction: params => signer.createSignedTransaction(...(params ?? [])),
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { XyoViewer } from '@xyo-network/xl1-model'
|
|
2
|
+
|
|
3
|
+
import type { XyoViewerRpcMethodHandlers } from '../types/index.ts'
|
|
4
|
+
|
|
5
|
+
export const rpcMethodHandlersFromViewer = (viewer: XyoViewer): XyoViewerRpcMethodHandlers => {
|
|
6
|
+
return {
|
|
7
|
+
xyoViewer_accountBalance: params => viewer.accountBalance(...(params ?? [])),
|
|
8
|
+
xyoViewer_blockByHash: params => viewer.blockByHash(...(params ?? [])),
|
|
9
|
+
xyoViewer_blockByNumber: params => viewer.blockByNumber(...(params ?? [])),
|
|
10
|
+
xyoViewer_blocksByHash: params => viewer.blocksByHash(...(params ?? [])),
|
|
11
|
+
xyoViewer_chainId: params => viewer.chainId(...(params ?? [])),
|
|
12
|
+
xyoViewer_currentBlock: params => viewer.currentBlock(...(params ?? [])),
|
|
13
|
+
xyoViewer_currentBlockHash: params => viewer.currentBlockHash(...(params ?? [])),
|
|
14
|
+
xyoViewer_currentBlockNumber: params => viewer.currentBlockNumber(...(params ?? [])),
|
|
15
|
+
xyoViewer_transactionByBlockHashAndIndex: params => viewer.transactionByBlockHashAndIndex(...(params ?? [])),
|
|
16
|
+
xyoViewer_transactionByBlockNumberAndIndex: params => viewer.transactionByBlockNumberAndIndex(...(params ?? [])),
|
|
17
|
+
xyoViewer_transactionByHash: params => viewer.transactionByHash(...(params ?? [])),
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { XyoWallet } from '@xyo-network/xl1-model'
|
|
2
|
+
|
|
3
|
+
import type { XyoWalletRpcMethodHandlers } from '../types/index.ts'
|
|
4
|
+
|
|
5
|
+
export const rpcMethodHandlersFromWallet = (wallet: XyoWallet): XyoWalletRpcMethodHandlers => {
|
|
6
|
+
return {
|
|
7
|
+
xyoWallet_accounts: params => wallet.accounts(...(params ?? [])),
|
|
8
|
+
xyoWallet_addChain: params => wallet.addChain(...(params ?? [])),
|
|
9
|
+
xyoWallet_chain: params => wallet.chain(...(params ?? [])),
|
|
10
|
+
xyoWallet_chains: params => wallet.chains(...(params ?? [])),
|
|
11
|
+
xyoWallet_permissions: params => wallet.permissions(...(params ?? [])),
|
|
12
|
+
xyoWallet_requestPermissions: params => wallet.requestPermissions(...(params ?? [])),
|
|
13
|
+
xyoWallet_revokePermissions: params => wallet.revokePermissions(...(params ?? [])),
|
|
14
|
+
xyoWallet_switchChain: params => wallet.switchChain(...(params ?? [])),
|
|
15
|
+
}
|
|
16
|
+
}
|
package/src/index.ts
ADDED