@xyo-network/xl1-rpc 1.12.0 → 1.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/neutral/index.mjs +487 -258
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/transport/HttpRpcTransport.d.ts +1 -1
- package/dist/neutral/transport/HttpRpcTransport.d.ts.map +1 -1
- package/dist/neutral/transport/MemoryRpcTransport.d.ts +4 -4
- package/dist/neutral/transport/MemoryRpcTransport.d.ts.map +1 -1
- package/dist/neutral/transport/RpcTransport.d.ts +1 -1
- package/dist/neutral/transport/RpcTransport.d.ts.map +1 -1
- package/dist/neutral/transport/post-message/LegacyPostMessageRpcTransport.d.ts +1 -1
- package/dist/neutral/transport/post-message/LegacyPostMessageRpcTransport.d.ts.map +1 -1
- package/dist/neutral/types/schema/AllRpcSchemas.d.ts +2965 -2
- package/dist/neutral/types/schema/AllRpcSchemas.d.ts.map +1 -1
- package/dist/neutral/types/schema/XyoGatewayRpcSchemas.d.ts +1 -1
- package/dist/neutral/types/schema/XyoGatewayRpcSchemas.d.ts.map +1 -1
- package/dist/neutral/types/schema/XyoProviderRpcSchemas.d.ts +1 -1
- package/dist/neutral/types/schema/XyoProviderRpcSchemas.d.ts.map +1 -1
- package/dist/neutral/types/schema/XyoRunnerRpcSchemas.d.ts +1 -1
- package/dist/neutral/types/schema/XyoRunnerRpcSchemas.d.ts.map +1 -1
- package/dist/neutral/types/schema/XyoSignerRpcSchemas.d.ts +1 -1
- package/dist/neutral/types/schema/XyoSignerRpcSchemas.d.ts.map +1 -1
- package/dist/neutral/types/schema/XyoViewerRpcSchemas.d.ts +1 -1
- package/dist/neutral/types/schema/XyoViewerRpcSchemas.d.ts.map +1 -1
- package/dist/neutral/types/schema/common/Address.d.ts +1 -1
- package/dist/neutral/types/schema/common/Address.d.ts.map +1 -1
- package/dist/neutral/types/schema/common/AllowedBlockPayload.d.ts +2 -2
- package/dist/neutral/types/schema/common/AllowedBlockPayload.d.ts.map +1 -1
- package/dist/neutral/types/schema/common/BlockBoundWitness.d.ts +1 -1
- package/dist/neutral/types/schema/common/BlockBoundWitness.d.ts.map +1 -1
- package/dist/neutral/types/schema/common/BoundWitness.d.ts +1 -1
- package/dist/neutral/types/schema/common/BoundWitness.d.ts.map +1 -1
- package/dist/neutral/types/schema/common/Chain.d.ts +1 -1
- package/dist/neutral/types/schema/common/Chain.d.ts.map +1 -1
- package/dist/neutral/types/schema/common/HydratedBlock.d.ts +1 -1
- package/dist/neutral/types/schema/common/HydratedBlock.d.ts.map +1 -1
- package/dist/neutral/types/schema/common/HydratedTransaction.d.ts +1 -1
- package/dist/neutral/types/schema/common/HydratedTransaction.d.ts.map +1 -1
- package/dist/neutral/types/schema/common/Json.d.ts +1 -1
- package/dist/neutral/types/schema/common/Json.d.ts.map +1 -1
- package/dist/neutral/types/schema/common/Payload.d.ts +1 -1
- package/dist/neutral/types/schema/common/Payload.d.ts.map +1 -1
- package/dist/neutral/types/schema/common/Sequence.d.ts +1 -1
- package/dist/neutral/types/schema/common/Sequence.d.ts.map +1 -1
- package/dist/neutral/types/schema/common/TransactionBoundWitness.d.ts +1 -1
- package/dist/neutral/types/schema/common/TransactionBoundWitness.d.ts.map +1 -1
- package/dist/neutral/types/schema/common/TransactionFees.d.ts +1 -1
- package/dist/neutral/types/schema/common/TransactionFees.d.ts.map +1 -1
- package/dist/neutral/types/schema/createRequestSchema.d.ts +2 -2
- package/dist/neutral/types/schema/createRequestSchema.d.ts.map +1 -1
- package/dist/neutral/types/schema/createResponseSchema.d.ts +1 -1
- package/dist/neutral/types/schema/createResponseSchema.d.ts.map +1 -1
- package/dist/node/index-node.mjs +516 -289
- package/dist/node/index-node.mjs.map +1 -1
- package/dist/node/transport/HttpRpcTransport.d.ts +1 -1
- package/dist/node/transport/HttpRpcTransport.d.ts.map +1 -1
- package/dist/node/transport/MemoryRpcTransport.d.ts +4 -4
- package/dist/node/transport/MemoryRpcTransport.d.ts.map +1 -1
- package/dist/node/transport/RpcTransport.d.ts +1 -1
- package/dist/node/transport/RpcTransport.d.ts.map +1 -1
- package/dist/node/transport/post-message/LegacyPostMessageRpcTransport.d.ts +1 -1
- package/dist/node/transport/post-message/LegacyPostMessageRpcTransport.d.ts.map +1 -1
- package/dist/node/types/schema/AllRpcSchemas.d.ts +2965 -2
- package/dist/node/types/schema/AllRpcSchemas.d.ts.map +1 -1
- package/dist/node/types/schema/XyoGatewayRpcSchemas.d.ts +1 -1
- package/dist/node/types/schema/XyoGatewayRpcSchemas.d.ts.map +1 -1
- package/dist/node/types/schema/XyoProviderRpcSchemas.d.ts +1 -1
- package/dist/node/types/schema/XyoProviderRpcSchemas.d.ts.map +1 -1
- package/dist/node/types/schema/XyoRunnerRpcSchemas.d.ts +1 -1
- package/dist/node/types/schema/XyoRunnerRpcSchemas.d.ts.map +1 -1
- package/dist/node/types/schema/XyoSignerRpcSchemas.d.ts +1 -1
- package/dist/node/types/schema/XyoSignerRpcSchemas.d.ts.map +1 -1
- package/dist/node/types/schema/XyoViewerRpcSchemas.d.ts +1 -1
- package/dist/node/types/schema/XyoViewerRpcSchemas.d.ts.map +1 -1
- package/dist/node/types/schema/common/Address.d.ts +1 -1
- package/dist/node/types/schema/common/Address.d.ts.map +1 -1
- package/dist/node/types/schema/common/AllowedBlockPayload.d.ts +2 -2
- package/dist/node/types/schema/common/AllowedBlockPayload.d.ts.map +1 -1
- package/dist/node/types/schema/common/BlockBoundWitness.d.ts +1 -1
- package/dist/node/types/schema/common/BlockBoundWitness.d.ts.map +1 -1
- package/dist/node/types/schema/common/BoundWitness.d.ts +1 -1
- package/dist/node/types/schema/common/BoundWitness.d.ts.map +1 -1
- package/dist/node/types/schema/common/Chain.d.ts +1 -1
- package/dist/node/types/schema/common/Chain.d.ts.map +1 -1
- package/dist/node/types/schema/common/HydratedBlock.d.ts +1 -1
- package/dist/node/types/schema/common/HydratedBlock.d.ts.map +1 -1
- package/dist/node/types/schema/common/HydratedTransaction.d.ts +1 -1
- package/dist/node/types/schema/common/HydratedTransaction.d.ts.map +1 -1
- package/dist/node/types/schema/common/Json.d.ts +1 -1
- package/dist/node/types/schema/common/Json.d.ts.map +1 -1
- package/dist/node/types/schema/common/Payload.d.ts +1 -1
- package/dist/node/types/schema/common/Payload.d.ts.map +1 -1
- package/dist/node/types/schema/common/Sequence.d.ts +1 -1
- package/dist/node/types/schema/common/Sequence.d.ts.map +1 -1
- package/dist/node/types/schema/common/TransactionBoundWitness.d.ts +1 -1
- package/dist/node/types/schema/common/TransactionBoundWitness.d.ts.map +1 -1
- package/dist/node/types/schema/common/TransactionFees.d.ts +1 -1
- package/dist/node/types/schema/common/TransactionFees.d.ts.map +1 -1
- package/dist/node/types/schema/createRequestSchema.d.ts +2 -2
- package/dist/node/types/schema/createRequestSchema.d.ts.map +1 -1
- package/dist/node/types/schema/createResponseSchema.d.ts +1 -1
- package/dist/node/types/schema/createResponseSchema.d.ts.map +1 -1
- package/package.json +29 -32
- package/src/provider/client/spec/MemoryXyoClient.spec.ts +2 -2
- package/src/provider/gateway/spec/MemoryXyoGateway.spec.ts +2 -2
- package/src/provider/viewer/spec/JsonRpcXyoViewer.spec.ts +3 -2
- package/src/transport/HttpRpcTransport.ts +1 -1
- package/src/transport/MemoryRpcTransport.ts +5 -4
- package/src/transport/RpcTransport.ts +1 -1
- package/src/transport/post-message/LegacyPostMessageRpcTransport.ts +1 -1
- package/src/types/schema/AllRpcSchemas.ts +2 -2
- package/src/types/schema/XyoGatewayRpcSchemas.ts +1 -1
- package/src/types/schema/XyoProviderRpcSchemas.ts +1 -1
- package/src/types/schema/XyoRunnerRpcSchemas.ts +1 -1
- package/src/types/schema/XyoSignerRpcSchemas.ts +1 -1
- package/src/types/schema/XyoViewerRpcSchemas.ts +1 -1
- package/src/types/schema/common/Address.ts +3 -6
- package/src/types/schema/common/AllowedBlockPayload.ts +1 -1
- package/src/types/schema/common/BlockBoundWitness.ts +1 -1
- package/src/types/schema/common/BoundWitness.ts +1 -1
- package/src/types/schema/common/Chain.ts +3 -6
- package/src/types/schema/common/HydratedBlock.ts +1 -1
- package/src/types/schema/common/HydratedTransaction.ts +1 -1
- package/src/types/schema/common/Json.ts +1 -1
- package/src/types/schema/common/Payload.ts +1 -1
- package/src/types/schema/common/Sequence.ts +2 -3
- package/src/types/schema/common/TransactionBoundWitness.ts +1 -1
- package/src/types/schema/common/TransactionFees.ts +1 -1
- package/src/types/schema/common/spec/HydratedBlockSchema.spec.ts +1 -2
- package/src/types/schema/createRequestSchema.ts +1 -1
- package/src/types/schema/createResponseSchema.ts +1 -1
package/dist/node/index-node.mjs
CHANGED
|
@@ -1,85 +1,103 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
1
4
|
// src/engine/requestSchemas.ts
|
|
2
5
|
var requestSchemas = {};
|
|
3
6
|
|
|
4
7
|
// src/engine/rpcMethodHandlersFromRunner.ts
|
|
5
|
-
var rpcMethodHandlersFromRunner = (runner) => {
|
|
6
|
-
return {
|
|
7
|
-
|
|
8
|
+
var rpcMethodHandlersFromRunner = /* @__PURE__ */ __name((runner) => {
|
|
9
|
+
return {
|
|
10
|
+
xyoRunner_broadcastTransaction: /* @__PURE__ */ __name((params) => runner.broadcastTransaction(...params ?? []), "xyoRunner_broadcastTransaction")
|
|
11
|
+
};
|
|
12
|
+
}, "rpcMethodHandlersFromRunner");
|
|
8
13
|
|
|
9
14
|
// src/engine/rpcMethodHandlersFromSigner.ts
|
|
10
|
-
var rpcMethodHandlersFromSigner = (signer) => {
|
|
15
|
+
var rpcMethodHandlersFromSigner = /* @__PURE__ */ __name((signer) => {
|
|
11
16
|
return {
|
|
12
|
-
xyoSigner_address: (params) => signer.address(...params ?? []),
|
|
13
|
-
xyoSigner_createSignedTransaction: (params) => signer.createSignedTransaction(...params ?? []),
|
|
14
|
-
xyoSigner_signTransaction: (params) => signer.signTransaction(...params ?? [])
|
|
17
|
+
xyoSigner_address: /* @__PURE__ */ __name((params) => signer.address(...params ?? []), "xyoSigner_address"),
|
|
18
|
+
xyoSigner_createSignedTransaction: /* @__PURE__ */ __name((params) => signer.createSignedTransaction(...params ?? []), "xyoSigner_createSignedTransaction"),
|
|
19
|
+
xyoSigner_signTransaction: /* @__PURE__ */ __name((params) => signer.signTransaction(...params ?? []), "xyoSigner_signTransaction")
|
|
15
20
|
};
|
|
16
|
-
};
|
|
21
|
+
}, "rpcMethodHandlersFromSigner");
|
|
17
22
|
|
|
18
23
|
// src/engine/rpcMethodHandlersFromViewer.ts
|
|
19
|
-
var rpcMethodHandlersFromViewer = (viewer) => {
|
|
24
|
+
var rpcMethodHandlersFromViewer = /* @__PURE__ */ __name((viewer) => {
|
|
20
25
|
return {
|
|
21
|
-
xyoViewer_accountBalance: (params) => viewer.accountBalance(...params ?? []),
|
|
22
|
-
xyoViewer_accountHistory: (params) => viewer.accountHistory(...params ?? []),
|
|
23
|
-
xyoViewer_blockByHash: (params) => viewer.blockByHash(...params ?? []),
|
|
24
|
-
xyoViewer_blockByNumber: (params) => viewer.blockByNumber(...params ?? []),
|
|
25
|
-
xyoViewer_blocksByHash: (params) => viewer.blocksByHash(...params ?? []),
|
|
26
|
-
xyoViewer_chainId: (params) => viewer.chainId(...params ?? []),
|
|
27
|
-
xyoViewer_currentBlock: (params) => viewer.currentBlock(...params ?? []),
|
|
28
|
-
xyoViewer_currentBlockHash: (params) => viewer.currentBlockHash(...params ?? []),
|
|
29
|
-
xyoViewer_currentBlockNumber: (params) => viewer.currentBlockNumber(...params ?? []),
|
|
30
|
-
xyoViewer_transactionByBlockHashAndIndex: (params) => viewer.transactionByBlockHashAndIndex(...params ?? []),
|
|
31
|
-
xyoViewer_transactionByBlockNumberAndIndex: (params) => viewer.transactionByBlockNumberAndIndex(...params ?? []),
|
|
32
|
-
xyoViewer_transactionByHash: (params) => viewer.transactionByHash(...params ?? [])
|
|
26
|
+
xyoViewer_accountBalance: /* @__PURE__ */ __name((params) => viewer.accountBalance(...params ?? []), "xyoViewer_accountBalance"),
|
|
27
|
+
xyoViewer_accountHistory: /* @__PURE__ */ __name((params) => viewer.accountHistory(...params ?? []), "xyoViewer_accountHistory"),
|
|
28
|
+
xyoViewer_blockByHash: /* @__PURE__ */ __name((params) => viewer.blockByHash(...params ?? []), "xyoViewer_blockByHash"),
|
|
29
|
+
xyoViewer_blockByNumber: /* @__PURE__ */ __name((params) => viewer.blockByNumber(...params ?? []), "xyoViewer_blockByNumber"),
|
|
30
|
+
xyoViewer_blocksByHash: /* @__PURE__ */ __name((params) => viewer.blocksByHash(...params ?? []), "xyoViewer_blocksByHash"),
|
|
31
|
+
xyoViewer_chainId: /* @__PURE__ */ __name((params) => viewer.chainId(...params ?? []), "xyoViewer_chainId"),
|
|
32
|
+
xyoViewer_currentBlock: /* @__PURE__ */ __name((params) => viewer.currentBlock(...params ?? []), "xyoViewer_currentBlock"),
|
|
33
|
+
xyoViewer_currentBlockHash: /* @__PURE__ */ __name((params) => viewer.currentBlockHash(...params ?? []), "xyoViewer_currentBlockHash"),
|
|
34
|
+
xyoViewer_currentBlockNumber: /* @__PURE__ */ __name((params) => viewer.currentBlockNumber(...params ?? []), "xyoViewer_currentBlockNumber"),
|
|
35
|
+
xyoViewer_transactionByBlockHashAndIndex: /* @__PURE__ */ __name((params) => viewer.transactionByBlockHashAndIndex(...params ?? []), "xyoViewer_transactionByBlockHashAndIndex"),
|
|
36
|
+
xyoViewer_transactionByBlockNumberAndIndex: /* @__PURE__ */ __name((params) => viewer.transactionByBlockNumberAndIndex(...params ?? []), "xyoViewer_transactionByBlockNumberAndIndex"),
|
|
37
|
+
xyoViewer_transactionByHash: /* @__PURE__ */ __name((params) => viewer.transactionByHash(...params ?? []), "xyoViewer_transactionByHash")
|
|
33
38
|
};
|
|
34
|
-
};
|
|
39
|
+
}, "rpcMethodHandlersFromViewer");
|
|
35
40
|
|
|
36
41
|
// src/engine/rpcMethodHandlersFromProvider.ts
|
|
37
|
-
var rpcMethodHandlersFromProvider = (provider) => {
|
|
38
|
-
const {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (
|
|
42
|
+
var rpcMethodHandlersFromProvider = /* @__PURE__ */ __name((provider) => {
|
|
43
|
+
const { runner, signer, viewer } = provider;
|
|
44
|
+
let result = {
|
|
45
|
+
xyoProvider_send: /* @__PURE__ */ __name((params) => provider.send(...params ?? []), "xyoProvider_send")
|
|
46
|
+
};
|
|
47
|
+
if (runner) result = {
|
|
48
|
+
...result,
|
|
49
|
+
...rpcMethodHandlersFromRunner(runner)
|
|
50
|
+
};
|
|
51
|
+
if (signer) result = {
|
|
52
|
+
...result,
|
|
53
|
+
...rpcMethodHandlersFromSigner(signer)
|
|
54
|
+
};
|
|
55
|
+
if (viewer) result = {
|
|
56
|
+
...result,
|
|
57
|
+
...rpcMethodHandlersFromViewer(viewer)
|
|
58
|
+
};
|
|
47
59
|
return result;
|
|
48
|
-
};
|
|
60
|
+
}, "rpcMethodHandlersFromProvider");
|
|
49
61
|
|
|
50
62
|
// src/engine/rpcEngineFromProvider.ts
|
|
51
63
|
import { createAsyncMiddleware, JsonRpcEngine } from "@metamask/json-rpc-engine";
|
|
52
64
|
|
|
53
65
|
// src/types/ErrorCodes.ts
|
|
54
66
|
var JsonRpcErrorCodes = {
|
|
55
|
-
InternalError: {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
67
|
+
InternalError: {
|
|
68
|
+
code: -32603,
|
|
69
|
+
message: "Internal JSON-RPC error (unexpected exception)."
|
|
70
|
+
},
|
|
71
|
+
InvalidParams: {
|
|
72
|
+
code: -32602,
|
|
73
|
+
message: "Invalid method parameter(s)."
|
|
74
|
+
},
|
|
75
|
+
InvalidRequest: {
|
|
76
|
+
code: -32600,
|
|
77
|
+
message: "The JSON sent is not a valid Request object."
|
|
78
|
+
},
|
|
79
|
+
MethodNotFound: {
|
|
80
|
+
code: -32601,
|
|
81
|
+
message: "The method does not exist or is not available."
|
|
82
|
+
}
|
|
59
83
|
};
|
|
60
84
|
|
|
61
85
|
// src/types/JsonRpc.ts
|
|
62
86
|
var jsonrpc = "2.0";
|
|
63
87
|
|
|
64
88
|
// src/types/schema/XyoProviderRpcSchemas.ts
|
|
65
|
-
import
|
|
89
|
+
import * as z13 from "zod";
|
|
66
90
|
|
|
67
91
|
// src/types/schema/common/Address.ts
|
|
68
|
-
import { toAddress } from "@xylabs/hex";
|
|
69
|
-
import
|
|
70
|
-
|
|
71
|
-
var CompiledAddressRegEx = new RegExp(AddressRegEx);
|
|
72
|
-
var AddressZod = z.string().toLowerCase().regex(CompiledAddressRegEx).transform((v) => toAddress(v));
|
|
92
|
+
import { AddressRegEx, toAddress } from "@xylabs/hex";
|
|
93
|
+
import * as z from "zod";
|
|
94
|
+
var AddressZod = z.string().toLowerCase().regex(AddressRegEx).transform((v) => toAddress(v));
|
|
73
95
|
|
|
74
96
|
// src/types/schema/common/AllowedBlockPayload.ts
|
|
75
97
|
import { BoundWitnessSchema } from "@xyo-network/boundwitness-model";
|
|
76
98
|
import { SchemaSchema } from "@xyo-network/core-payload-plugins";
|
|
77
|
-
import {
|
|
78
|
-
|
|
79
|
-
HashSchema,
|
|
80
|
-
TransferSchema
|
|
81
|
-
} from "@xyo-network/xl1-protocol";
|
|
82
|
-
import z2 from "zod";
|
|
99
|
+
import { ChainStakeIntentSchema, HashSchema, TransferSchema } from "@xyo-network/xl1-protocol";
|
|
100
|
+
import * as z2 from "zod";
|
|
83
101
|
var AllowedBlockPayloadSchemas = [
|
|
84
102
|
BoundWitnessSchema,
|
|
85
103
|
ChainStakeIntentSchema,
|
|
@@ -87,34 +105,41 @@ var AllowedBlockPayloadSchemas = [
|
|
|
87
105
|
SchemaSchema,
|
|
88
106
|
TransferSchema
|
|
89
107
|
];
|
|
90
|
-
var AllowedBlockPayloadZod = z2.object({
|
|
108
|
+
var AllowedBlockPayloadZod = z2.object({
|
|
109
|
+
schema: z2.enum(AllowedBlockPayloadSchemas)
|
|
110
|
+
});
|
|
91
111
|
|
|
92
112
|
// src/types/schema/common/BlockBoundWitness.ts
|
|
93
113
|
import { HexZod as HexZod2 } from "@xylabs/hex";
|
|
94
|
-
import
|
|
114
|
+
import * as z7 from "zod";
|
|
95
115
|
|
|
96
116
|
// src/types/schema/common/BoundWitness.ts
|
|
97
117
|
import { HashZod, HexZod } from "@xylabs/hex";
|
|
98
118
|
import { BoundWitnessSchema as BoundWitnessSchema2 } from "@xyo-network/boundwitness-model";
|
|
99
|
-
import
|
|
119
|
+
import * as z5 from "zod";
|
|
100
120
|
|
|
101
121
|
// src/types/schema/common/Payload.ts
|
|
102
122
|
import { HashToJsonZod } from "@xylabs/hex";
|
|
103
|
-
import
|
|
123
|
+
import * as z4 from "zod";
|
|
104
124
|
|
|
105
125
|
// src/types/schema/common/Sequence.ts
|
|
106
|
-
import { toHex } from "@xylabs/hex";
|
|
126
|
+
import { HexRegExMinMax, toHex } from "@xylabs/hex";
|
|
107
127
|
import { SequenceConstants } from "@xyo-network/payload-model";
|
|
108
|
-
import
|
|
109
|
-
import { z as z3 } from "zod";
|
|
128
|
+
import * as z3 from "zod";
|
|
110
129
|
var LocalSequenceRegex = new RegExp(HexRegExMinMax(SequenceConstants.localSequenceBytes, SequenceConstants.localSequenceBytes));
|
|
111
130
|
var LocalSequenceToStringZod = z3.string().regex(LocalSequenceRegex);
|
|
112
131
|
var LocalSequenceFromStringZod = z3.string().regex(LocalSequenceRegex).transform((v) => toHex(v));
|
|
113
132
|
var QualifiedSequenceRegex = new RegExp(HexRegExMinMax(SequenceConstants.qualifiedSequenceBytes, SequenceConstants.qualifiedSequenceBytes));
|
|
114
133
|
var QualifiedSequenceToStringZod = z3.string().regex(QualifiedSequenceRegex);
|
|
115
134
|
var QualifiedSequenceFromStringZod = z3.string().regex(QualifiedSequenceRegex).transform((v) => toHex(v));
|
|
116
|
-
var SequenceToStringZod = z3.union([
|
|
117
|
-
|
|
135
|
+
var SequenceToStringZod = z3.union([
|
|
136
|
+
LocalSequenceToStringZod,
|
|
137
|
+
QualifiedSequenceToStringZod
|
|
138
|
+
]);
|
|
139
|
+
var SequenceFromStringZod = z3.union([
|
|
140
|
+
LocalSequenceFromStringZod,
|
|
141
|
+
QualifiedSequenceFromStringZod
|
|
142
|
+
]);
|
|
118
143
|
|
|
119
144
|
// src/types/schema/common/Payload.ts
|
|
120
145
|
var StorageMetaZod = z4.object({
|
|
@@ -123,13 +148,16 @@ var StorageMetaZod = z4.object({
|
|
|
123
148
|
_sequence: SequenceToStringZod
|
|
124
149
|
});
|
|
125
150
|
var SchemaZod = z4.string();
|
|
126
|
-
var PayloadZod = z4.object({
|
|
151
|
+
var PayloadZod = z4.object({
|
|
152
|
+
schema: SchemaZod
|
|
153
|
+
}).catchall(z4.any());
|
|
127
154
|
var PayloadWithStorageMetaZod = PayloadZod.extend(StorageMetaZod.shape);
|
|
128
155
|
var AnyPayloadZod = PayloadZod.catchall(z4.json());
|
|
129
156
|
var AnyPayloadWithStorageMetaZod = AnyPayloadZod.extend(StorageMetaZod.shape);
|
|
130
157
|
function WithStorageMetaZod(valueZod) {
|
|
131
158
|
return StorageMetaZod.extend(valueZod.shape);
|
|
132
159
|
}
|
|
160
|
+
__name(WithStorageMetaZod, "WithStorageMetaZod");
|
|
133
161
|
|
|
134
162
|
// src/types/schema/common/BoundWitness.ts
|
|
135
163
|
var BoundWitnessRequiredFieldsZod = z5.object({
|
|
@@ -141,24 +169,33 @@ var BoundWitnessRequiredFieldsZod = z5.object({
|
|
|
141
169
|
var BoundWitnessMetaZod = z5.object({
|
|
142
170
|
$destination: AddressZod.optional(),
|
|
143
171
|
$sourceQuery: HashZod.optional(),
|
|
144
|
-
$signatures: z5.array(z5.union([
|
|
172
|
+
$signatures: z5.array(z5.union([
|
|
173
|
+
HexZod,
|
|
174
|
+
z5.null()
|
|
175
|
+
]))
|
|
176
|
+
});
|
|
177
|
+
var BoundWitnessZod = PayloadZod.extend({
|
|
178
|
+
schema: z5.literal(BoundWitnessSchema2)
|
|
179
|
+
}).extend(BoundWitnessRequiredFieldsZod.shape).extend(BoundWitnessMetaZod.shape).refine((data) => data.$signatures.length === data.addresses.length, {
|
|
180
|
+
message: "$signatures length must equal addresses length"
|
|
145
181
|
});
|
|
146
|
-
var BoundWitnessZod = PayloadZod.extend({ schema: z5.literal(BoundWitnessSchema2) }).extend(BoundWitnessRequiredFieldsZod.shape).extend(BoundWitnessMetaZod.shape).refine((data) => data.$signatures.length === data.addresses.length, { message: "$signatures length must equal addresses length" });
|
|
147
182
|
var AnyBoundWitnessZod = BoundWitnessZod.catchall(z5.any());
|
|
148
|
-
var UnsignedBoundWitnessZod = BoundWitnessZod.refine((data) => data.$signatures.includes(null), {
|
|
183
|
+
var UnsignedBoundWitnessZod = BoundWitnessZod.refine((data) => data.$signatures.includes(null), {
|
|
184
|
+
message: "all $signatures must be null"
|
|
185
|
+
});
|
|
149
186
|
var AnyUnsignedBoundWitnessZod = UnsignedBoundWitnessZod.catchall(z5.any());
|
|
150
187
|
var UnsignedBoundWitnessWithStorageMetaZod = UnsignedBoundWitnessZod.extend(BoundWitnessRequiredFieldsZod.shape).extend(BoundWitnessMetaZod.shape);
|
|
151
|
-
var SignedBoundWitnessZod = BoundWitnessZod.refine((data) => !data.$signatures.includes(null), {
|
|
188
|
+
var SignedBoundWitnessZod = BoundWitnessZod.refine((data) => !data.$signatures.includes(null), {
|
|
189
|
+
message: "all $signatures must not be null"
|
|
190
|
+
});
|
|
152
191
|
var SignedBoundWitnessWithStorageMetaZod = UnsignedBoundWitnessWithStorageMetaZod;
|
|
153
192
|
var AnySignedBoundWitnessZod = UnsignedBoundWitnessZod.catchall(z5.any());
|
|
154
193
|
var AnySignedBoundWitnessWithStorageMetaZod = UnsignedBoundWitnessWithStorageMetaZod.catchall(z5.any());
|
|
155
194
|
|
|
156
195
|
// src/types/schema/common/Chain.ts
|
|
157
|
-
import { toAddress as toAddress2 } from "@xylabs/hex";
|
|
158
|
-
import
|
|
159
|
-
|
|
160
|
-
var CompiledAddressRegEx2 = new RegExp(AddressRegEx2);
|
|
161
|
-
var ChainZod = z6.string().toLowerCase().regex(CompiledAddressRegEx2).transform((v) => toAddress2(v));
|
|
196
|
+
import { AddressRegEx as AddressRegEx2, toAddress as toAddress2 } from "@xylabs/hex";
|
|
197
|
+
import * as z6 from "zod";
|
|
198
|
+
var ChainZod = z6.string().toLowerCase().regex(AddressRegEx2).transform((v) => toAddress2(v));
|
|
162
199
|
|
|
163
200
|
// src/types/schema/common/BlockBoundWitness.ts
|
|
164
201
|
var BlockNumberZod = z7.number().int().nonnegative();
|
|
@@ -169,14 +206,16 @@ var BlockBoundWitnessFieldsZod = z7.object({
|
|
|
169
206
|
protocol: z7.number().optional(),
|
|
170
207
|
step_hashes: z7.array(HexZod2).optional()
|
|
171
208
|
});
|
|
172
|
-
var BlockBoundWitnessMetaZod = z7.object({
|
|
209
|
+
var BlockBoundWitnessMetaZod = z7.object({
|
|
210
|
+
$epoch: z7.number()
|
|
211
|
+
});
|
|
173
212
|
var BlockBoundWitnessZod = UnsignedBoundWitnessZod.merge(StorageMetaZod.partial()).merge(BlockBoundWitnessFieldsZod).merge(BlockBoundWitnessMetaZod);
|
|
174
213
|
var BlockBoundWitnessWithStorageMetaZod = UnsignedBoundWitnessWithStorageMetaZod.merge(BlockBoundWitnessFieldsZod).merge(BlockBoundWitnessMetaZod);
|
|
175
214
|
var SignedBlockBoundWitnessZod = SignedBoundWitnessZod.merge(StorageMetaZod.partial()).merge(BlockBoundWitnessFieldsZod).merge(BlockBoundWitnessMetaZod);
|
|
176
215
|
var SignedBlockBoundWitnessWithStorageMetaZod = SignedBoundWitnessWithStorageMetaZod.merge(StorageMetaZod.partial()).merge(BlockBoundWitnessFieldsZod).merge(BlockBoundWitnessMetaZod);
|
|
177
216
|
|
|
178
217
|
// src/types/schema/common/HydratedBlock.ts
|
|
179
|
-
import
|
|
218
|
+
import * as z8 from "zod";
|
|
180
219
|
var HydratedBlockZod = z8.tuple([
|
|
181
220
|
BlockBoundWitnessZod,
|
|
182
221
|
z8.array(PayloadZod)
|
|
@@ -201,19 +240,15 @@ var SignedHydratedBlockWithStorageMetaZod = z8.tuple([
|
|
|
201
240
|
// src/types/schema/common/HydratedTransaction.ts
|
|
202
241
|
import { asAnyPayload } from "@xyo-network/payload-model";
|
|
203
242
|
import { asSignedHydratedTransaction } from "@xyo-network/xl1-protocol";
|
|
204
|
-
import
|
|
243
|
+
import * as z11 from "zod";
|
|
205
244
|
|
|
206
245
|
// src/types/schema/common/TransactionBoundWitness.ts
|
|
207
|
-
import
|
|
246
|
+
import * as z10 from "zod";
|
|
208
247
|
|
|
209
248
|
// src/types/schema/common/TransactionFees.ts
|
|
210
|
-
import {
|
|
211
|
-
BigIntToJsonZod,
|
|
212
|
-
HexZod as HexZod3,
|
|
213
|
-
JsonToBigIntZod
|
|
214
|
-
} from "@xylabs/hex";
|
|
249
|
+
import { BigIntToJsonZod, HexZod as HexZod3, JsonToBigIntZod } from "@xylabs/hex";
|
|
215
250
|
import { asAttoXL1 } from "@xyo-network/xl1-protocol";
|
|
216
|
-
import
|
|
251
|
+
import * as z9 from "zod";
|
|
217
252
|
var AttoZod = z9.bigint();
|
|
218
253
|
var AttoFromStringZod = JsonToBigIntZod.transform((v) => asAttoXL1(v));
|
|
219
254
|
var TransactionFeesHexZod = z9.object({
|
|
@@ -242,12 +277,26 @@ var TransactionFeesBigIntToJsonZod = TransactionFeesBigIntZod.transform((val) =>
|
|
|
242
277
|
}));
|
|
243
278
|
|
|
244
279
|
// src/types/schema/common/TransactionBoundWitness.ts
|
|
245
|
-
var BlockStartZod = z10.object({
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
var
|
|
249
|
-
|
|
250
|
-
|
|
280
|
+
var BlockStartZod = z10.object({
|
|
281
|
+
nbf: BlockNumberZod
|
|
282
|
+
});
|
|
283
|
+
var BlockEndZod = z10.object({
|
|
284
|
+
exp: BlockNumberZod
|
|
285
|
+
});
|
|
286
|
+
var BlockDurationZod = z10.object({
|
|
287
|
+
nbf: BlockNumberZod,
|
|
288
|
+
exp: BlockNumberZod
|
|
289
|
+
});
|
|
290
|
+
var BlockScriptsZod = z10.object({
|
|
291
|
+
script: z10.array(z10.string()).optional()
|
|
292
|
+
});
|
|
293
|
+
var WithTransactionFeesZod = z10.object({
|
|
294
|
+
fees: TransactionFeesHexZod
|
|
295
|
+
});
|
|
296
|
+
var TransactionBoundWitnessFields = z10.object({
|
|
297
|
+
chain: ChainZod,
|
|
298
|
+
from: ChainZod
|
|
299
|
+
});
|
|
251
300
|
var TransactionBoundWitnessZod = UnsignedBoundWitnessZod.merge(StorageMetaZod.partial()).merge(BlockDurationZod).merge(WithTransactionFeesZod).merge(TransactionBoundWitnessFields).merge(BlockScriptsZod);
|
|
252
301
|
var SignedTransactionBoundWitnessZod = SignedBoundWitnessZod.merge(StorageMetaZod.partial()).merge(BlockDurationZod).merge(WithTransactionFeesZod).merge(TransactionBoundWitnessFields).merge(BlockScriptsZod.partial());
|
|
253
302
|
|
|
@@ -264,23 +313,17 @@ var SignedHydratedTransactionZod = z11.tuple([
|
|
|
264
313
|
SignedTransactionBoundWitnessZod,
|
|
265
314
|
z11.array(PayloadZod)
|
|
266
315
|
]);
|
|
267
|
-
var SignedHydratedTransactionToJsonZod = SignedHydratedTransactionZod.transform(([
|
|
268
|
-
tx,
|
|
269
|
-
payloads
|
|
270
|
-
]) => asSignedHydratedTransaction([
|
|
316
|
+
var SignedHydratedTransactionToJsonZod = SignedHydratedTransactionZod.transform(([tx, payloads]) => asSignedHydratedTransaction([
|
|
271
317
|
tx,
|
|
272
318
|
payloads.map((payload) => payload)
|
|
273
319
|
]));
|
|
274
|
-
var JsonToSignedHydratedTransactionZod = SignedHydratedTransactionZod.transform(([
|
|
275
|
-
tx,
|
|
276
|
-
payloads
|
|
277
|
-
]) => [
|
|
320
|
+
var JsonToSignedHydratedTransactionZod = SignedHydratedTransactionZod.transform(([tx, payloads]) => [
|
|
278
321
|
asSignedHydratedTransaction(tx),
|
|
279
322
|
payloads.map((p) => asAnyPayload(p))
|
|
280
323
|
]);
|
|
281
324
|
|
|
282
325
|
// src/types/schema/common/Json.ts
|
|
283
|
-
import
|
|
326
|
+
import * as z12 from "zod";
|
|
284
327
|
var JsonValueZod = z12.lazy(() => z12.union([
|
|
285
328
|
z12.string(),
|
|
286
329
|
z12.number(),
|
|
@@ -288,7 +331,6 @@ var JsonValueZod = z12.lazy(() => z12.union([
|
|
|
288
331
|
z12.null(),
|
|
289
332
|
z12.array(JsonValueZod),
|
|
290
333
|
z12.record(z12.string(), JsonValueZod)
|
|
291
|
-
// object with string keys and JSON values
|
|
292
334
|
]));
|
|
293
335
|
var JsonObjectZod = z12.record(z12.string(), JsonValueZod);
|
|
294
336
|
|
|
@@ -324,12 +366,16 @@ var XyoProviderRpcSchemas = {
|
|
|
324
366
|
|
|
325
367
|
// src/types/schema/XyoRunnerRpcSchemas.ts
|
|
326
368
|
import { HashToJsonZod as HashToJsonZod2, JsonToHashZod } from "@xylabs/hex";
|
|
327
|
-
import
|
|
369
|
+
import * as z14 from "zod";
|
|
328
370
|
var XyoRunnerRpcSchemas = {
|
|
329
371
|
xyoRunner_broadcastTransaction: {
|
|
330
372
|
params: {
|
|
331
|
-
to: z14.tuple([
|
|
332
|
-
|
|
373
|
+
to: z14.tuple([
|
|
374
|
+
SignedHydratedTransactionZod
|
|
375
|
+
]),
|
|
376
|
+
from: z14.tuple([
|
|
377
|
+
SignedHydratedTransactionZod
|
|
378
|
+
])
|
|
333
379
|
},
|
|
334
380
|
result: {
|
|
335
381
|
to: HashToJsonZod2,
|
|
@@ -339,7 +385,7 @@ var XyoRunnerRpcSchemas = {
|
|
|
339
385
|
};
|
|
340
386
|
|
|
341
387
|
// src/types/schema/XyoSignerRpcSchemas.ts
|
|
342
|
-
import
|
|
388
|
+
import * as z15 from "zod";
|
|
343
389
|
var XyoSignerRpcSchemas = {
|
|
344
390
|
xyoSigner_address: {
|
|
345
391
|
params: {
|
|
@@ -380,8 +426,12 @@ var XyoSignerRpcSchemas = {
|
|
|
380
426
|
},
|
|
381
427
|
xyoSigner_signTransaction: {
|
|
382
428
|
params: {
|
|
383
|
-
to: z15.tuple([
|
|
384
|
-
|
|
429
|
+
to: z15.tuple([
|
|
430
|
+
UnsignedHydratedTransactionZod
|
|
431
|
+
]),
|
|
432
|
+
from: z15.tuple([
|
|
433
|
+
UnsignedHydratedTransactionZod
|
|
434
|
+
])
|
|
385
435
|
},
|
|
386
436
|
result: {
|
|
387
437
|
to: SignedHydratedTransactionZod,
|
|
@@ -391,26 +441,38 @@ var XyoSignerRpcSchemas = {
|
|
|
391
441
|
};
|
|
392
442
|
|
|
393
443
|
// src/types/schema/XyoViewerRpcSchemas.ts
|
|
394
|
-
import {
|
|
395
|
-
|
|
396
|
-
HashToJsonZod as HashToJsonZod3,
|
|
397
|
-
HashZod as HashZod2,
|
|
398
|
-
JsonToBigIntZod as JsonToBigIntZod2,
|
|
399
|
-
JsonToHashZod as JsonToHashZod2
|
|
400
|
-
} from "@xylabs/hex";
|
|
401
|
-
import { z as z16 } from "zod";
|
|
444
|
+
import { BigIntToJsonZod as BigIntToJsonZod2, HashToJsonZod as HashToJsonZod3, HashZod as HashZod2, JsonToBigIntZod as JsonToBigIntZod2, JsonToHashZod as JsonToHashZod2 } from "@xylabs/hex";
|
|
445
|
+
import * as z16 from "zod";
|
|
402
446
|
var XyoViewerRpcSchemas = {
|
|
403
447
|
xyoViewer_accountBalance: {
|
|
404
448
|
params: {
|
|
405
449
|
to: z16.union([
|
|
406
|
-
z16.tuple([
|
|
407
|
-
|
|
408
|
-
|
|
450
|
+
z16.tuple([
|
|
451
|
+
AddressZod
|
|
452
|
+
]),
|
|
453
|
+
z16.tuple([
|
|
454
|
+
AddressZod,
|
|
455
|
+
z16.number()
|
|
456
|
+
]),
|
|
457
|
+
z16.tuple([
|
|
458
|
+
AddressZod,
|
|
459
|
+
z16.number(),
|
|
460
|
+
z16.boolean()
|
|
461
|
+
])
|
|
409
462
|
]),
|
|
410
463
|
from: z16.union([
|
|
411
|
-
z16.tuple([
|
|
412
|
-
|
|
413
|
-
|
|
464
|
+
z16.tuple([
|
|
465
|
+
AddressZod
|
|
466
|
+
]),
|
|
467
|
+
z16.tuple([
|
|
468
|
+
AddressZod,
|
|
469
|
+
z16.number()
|
|
470
|
+
]),
|
|
471
|
+
z16.tuple([
|
|
472
|
+
AddressZod,
|
|
473
|
+
z16.number(),
|
|
474
|
+
z16.boolean()
|
|
475
|
+
])
|
|
414
476
|
])
|
|
415
477
|
},
|
|
416
478
|
result: {
|
|
@@ -421,25 +483,55 @@ var XyoViewerRpcSchemas = {
|
|
|
421
483
|
xyoViewer_accountHistory: {
|
|
422
484
|
params: {
|
|
423
485
|
to: z16.union([
|
|
424
|
-
z16.tuple([
|
|
425
|
-
|
|
426
|
-
|
|
486
|
+
z16.tuple([
|
|
487
|
+
AddressZod
|
|
488
|
+
]),
|
|
489
|
+
z16.tuple([
|
|
490
|
+
AddressZod,
|
|
491
|
+
z16.number()
|
|
492
|
+
]),
|
|
493
|
+
z16.tuple([
|
|
494
|
+
AddressZod,
|
|
495
|
+
z16.number(),
|
|
496
|
+
z16.boolean()
|
|
497
|
+
])
|
|
427
498
|
]),
|
|
428
499
|
from: z16.union([
|
|
429
|
-
z16.tuple([
|
|
430
|
-
|
|
431
|
-
|
|
500
|
+
z16.tuple([
|
|
501
|
+
AddressZod
|
|
502
|
+
]),
|
|
503
|
+
z16.tuple([
|
|
504
|
+
AddressZod,
|
|
505
|
+
z16.number()
|
|
506
|
+
]),
|
|
507
|
+
z16.tuple([
|
|
508
|
+
AddressZod,
|
|
509
|
+
z16.number(),
|
|
510
|
+
z16.boolean()
|
|
511
|
+
])
|
|
432
512
|
])
|
|
433
513
|
},
|
|
434
514
|
result: {
|
|
435
|
-
to: z16.array(z16.tuple([
|
|
436
|
-
|
|
515
|
+
to: z16.array(z16.tuple([
|
|
516
|
+
HashZod2,
|
|
517
|
+
HashZod2,
|
|
518
|
+
PayloadZod
|
|
519
|
+
])),
|
|
520
|
+
from: z16.array(z16.tuple([
|
|
521
|
+
HashZod2,
|
|
522
|
+
HashZod2,
|
|
523
|
+
PayloadZod
|
|
524
|
+
]))
|
|
437
525
|
}
|
|
438
526
|
},
|
|
439
527
|
xyoViewer_blockByHash: {
|
|
440
528
|
params: {
|
|
441
|
-
to: z16.tuple([
|
|
442
|
-
|
|
529
|
+
to: z16.tuple([
|
|
530
|
+
HashToJsonZod3
|
|
531
|
+
]),
|
|
532
|
+
from: z16.tuple([
|
|
533
|
+
JsonToHashZod2
|
|
534
|
+
])
|
|
443
535
|
},
|
|
444
536
|
result: {
|
|
445
537
|
to: SignedHydratedBlockZod,
|
|
@@ -448,8 +540,12 @@ var XyoViewerRpcSchemas = {
|
|
|
448
540
|
},
|
|
449
541
|
xyoViewer_blockByNumber: {
|
|
450
542
|
params: {
|
|
451
|
-
to: z16.tuple([
|
|
452
|
-
|
|
543
|
+
to: z16.tuple([
|
|
544
|
+
z16.number()
|
|
545
|
+
]),
|
|
546
|
+
from: z16.tuple([
|
|
547
|
+
z16.number()
|
|
548
|
+
])
|
|
453
549
|
},
|
|
454
550
|
result: {
|
|
455
551
|
to: SignedHydratedBlockZod,
|
|
@@ -458,8 +554,14 @@ var XyoViewerRpcSchemas = {
|
|
|
458
554
|
},
|
|
459
555
|
xyoViewer_blocksByHash: {
|
|
460
556
|
params: {
|
|
461
|
-
to: z16.tuple([
|
|
462
|
-
|
|
557
|
+
to: z16.tuple([
|
|
558
|
+
HashZod2,
|
|
559
|
+
z16.number().optional()
|
|
560
|
+
]),
|
|
561
|
+
from: z16.tuple([
|
|
562
|
+
HashZod2,
|
|
563
|
+
z16.number().optional()
|
|
564
|
+
])
|
|
463
565
|
},
|
|
464
566
|
result: {
|
|
465
567
|
to: z16.array(SignedHydratedBlockZod),
|
|
@@ -508,8 +610,14 @@ var XyoViewerRpcSchemas = {
|
|
|
508
610
|
},
|
|
509
611
|
xyoViewer_transactionByBlockHashAndIndex: {
|
|
510
612
|
params: {
|
|
511
|
-
to: z16.tuple([
|
|
512
|
-
|
|
613
|
+
to: z16.tuple([
|
|
614
|
+
HashZod2,
|
|
615
|
+
z16.number()
|
|
616
|
+
]),
|
|
617
|
+
from: z16.tuple([
|
|
618
|
+
HashZod2,
|
|
619
|
+
z16.number()
|
|
620
|
+
])
|
|
513
621
|
},
|
|
514
622
|
result: {
|
|
515
623
|
to: SignedHydratedTransactionZod.nullable(),
|
|
@@ -518,8 +626,14 @@ var XyoViewerRpcSchemas = {
|
|
|
518
626
|
},
|
|
519
627
|
xyoViewer_transactionByBlockNumberAndIndex: {
|
|
520
628
|
params: {
|
|
521
|
-
to: z16.tuple([
|
|
522
|
-
|
|
629
|
+
to: z16.tuple([
|
|
630
|
+
z16.number(),
|
|
631
|
+
z16.number()
|
|
632
|
+
]),
|
|
633
|
+
from: z16.tuple([
|
|
634
|
+
z16.number(),
|
|
635
|
+
z16.number()
|
|
636
|
+
])
|
|
523
637
|
},
|
|
524
638
|
result: {
|
|
525
639
|
to: SignedHydratedTransactionZod.nullable(),
|
|
@@ -528,8 +642,12 @@ var XyoViewerRpcSchemas = {
|
|
|
528
642
|
},
|
|
529
643
|
xyoViewer_transactionByHash: {
|
|
530
644
|
params: {
|
|
531
|
-
to: z16.tuple([
|
|
532
|
-
|
|
645
|
+
to: z16.tuple([
|
|
646
|
+
HashZod2
|
|
647
|
+
]),
|
|
648
|
+
from: z16.tuple([
|
|
649
|
+
HashZod2
|
|
650
|
+
])
|
|
533
651
|
},
|
|
534
652
|
result: {
|
|
535
653
|
to: SignedHydratedTransactionZod.nullable(),
|
|
@@ -547,41 +665,56 @@ var AllRpcSchemas = {
|
|
|
547
665
|
};
|
|
548
666
|
|
|
549
667
|
// src/types/schema/createRequestSchema.ts
|
|
550
|
-
import
|
|
551
|
-
var createRequestSchema = (methodName, paramsSchema = z17.undefined()) => z17.object({
|
|
552
|
-
id: z17.union([
|
|
668
|
+
import * as z17 from "zod";
|
|
669
|
+
var createRequestSchema = /* @__PURE__ */ __name((methodName, paramsSchema = z17.undefined()) => z17.object({
|
|
670
|
+
id: z17.union([
|
|
671
|
+
z17.string(),
|
|
672
|
+
z17.number()
|
|
673
|
+
]),
|
|
553
674
|
jsonrpc: z17.literal(jsonrpc),
|
|
554
675
|
method: z17.literal(methodName),
|
|
555
676
|
params: paramsSchema
|
|
556
|
-
});
|
|
677
|
+
}), "createRequestSchema");
|
|
557
678
|
|
|
558
679
|
// src/types/schema/createResponseSchema.ts
|
|
559
|
-
import
|
|
560
|
-
var createResponseSchema = (resultSchema = z18.undefined()) => z18.object({
|
|
561
|
-
id: z18.union([
|
|
680
|
+
import * as z18 from "zod";
|
|
681
|
+
var createResponseSchema = /* @__PURE__ */ __name((resultSchema = z18.undefined()) => z18.object({
|
|
682
|
+
id: z18.union([
|
|
683
|
+
z18.string(),
|
|
684
|
+
z18.number()
|
|
685
|
+
]),
|
|
562
686
|
jsonrpc: z18.literal(jsonrpc),
|
|
563
687
|
result: resultSchema
|
|
564
|
-
});
|
|
688
|
+
}), "createResponseSchema");
|
|
565
689
|
|
|
566
690
|
// src/types/schema/XyoGatewayRpcSchemas.ts
|
|
567
|
-
import
|
|
691
|
+
import * as z19 from "zod";
|
|
568
692
|
var ChainConnectionZod = z19.object({
|
|
569
|
-
chainId: z19.union([
|
|
693
|
+
chainId: z19.union([
|
|
694
|
+
z19.string(),
|
|
695
|
+
z19.custom()
|
|
696
|
+
]).optional(),
|
|
570
697
|
name: z19.string(),
|
|
571
698
|
url: z19.string()
|
|
572
699
|
});
|
|
573
|
-
var CaveatTypesZod = z19.enum([
|
|
700
|
+
var CaveatTypesZod = z19.enum([
|
|
701
|
+
"chain",
|
|
702
|
+
"expiration",
|
|
703
|
+
"filteredResponse",
|
|
704
|
+
"rateLimit"
|
|
705
|
+
]);
|
|
574
706
|
var CaveatsZod = z19.object({
|
|
575
707
|
type: CaveatTypesZod,
|
|
576
708
|
value: z19.unknown()
|
|
577
|
-
// JsonValue is usually unknown, adjust if you have a stricter type
|
|
578
709
|
});
|
|
579
710
|
var PermissionZod = z19.object({
|
|
580
711
|
capability: z19.string(),
|
|
581
712
|
caveats: CaveatsZod.array().optional(),
|
|
582
713
|
invoker: z19.string()
|
|
583
714
|
});
|
|
584
|
-
var InvokerPermissionZod = PermissionZod.extend({
|
|
715
|
+
var InvokerPermissionZod = PermissionZod.extend({
|
|
716
|
+
date: z19.number().optional()
|
|
717
|
+
});
|
|
585
718
|
var XyoGatewayRpcSchemas = {
|
|
586
719
|
/*
|
|
587
720
|
xyoGateway_addConnection: {
|
|
@@ -647,12 +780,8 @@ var XyoGatewayRpcSchemas = {
|
|
|
647
780
|
*/
|
|
648
781
|
xyoGateway_submitTransaction: {
|
|
649
782
|
params: {
|
|
650
|
-
from: z19.array(
|
|
651
|
-
|
|
652
|
-
),
|
|
653
|
-
to: z19.array(
|
|
654
|
-
HydratedTransactionZod
|
|
655
|
-
)
|
|
783
|
+
from: z19.array(HydratedTransactionZod),
|
|
784
|
+
to: z19.array(HydratedTransactionZod)
|
|
656
785
|
},
|
|
657
786
|
result: {
|
|
658
787
|
from: BlockBoundWitnessZod,
|
|
@@ -662,43 +791,44 @@ var XyoGatewayRpcSchemas = {
|
|
|
662
791
|
};
|
|
663
792
|
|
|
664
793
|
// src/engine/rpcEngineFromProvider.ts
|
|
665
|
-
var rpcEngineFromProvider = (provider) => {
|
|
794
|
+
var rpcEngineFromProvider = /* @__PURE__ */ __name((provider) => {
|
|
666
795
|
const engine = new JsonRpcEngine();
|
|
667
796
|
const handlers = rpcMethodHandlersFromProvider(provider);
|
|
668
|
-
engine.push(
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
})
|
|
696
|
-
);
|
|
797
|
+
engine.push(createAsyncMiddleware(async (req, res) => {
|
|
798
|
+
const method = req.method;
|
|
799
|
+
const handler = handlers[method];
|
|
800
|
+
const schema = AllRpcSchemas[method];
|
|
801
|
+
if (schema === void 0 || handler === void 0) {
|
|
802
|
+
res.error = JsonRpcErrorCodes.MethodNotFound;
|
|
803
|
+
return;
|
|
804
|
+
}
|
|
805
|
+
let requestSchema = requestSchemas[method];
|
|
806
|
+
if (requestSchema == void 0) {
|
|
807
|
+
requestSchema = createRequestSchema(method, schema.params.from);
|
|
808
|
+
requestSchemas[method] = requestSchema;
|
|
809
|
+
}
|
|
810
|
+
const parsed = requestSchema.safeParse(req);
|
|
811
|
+
if (!parsed.success) {
|
|
812
|
+
res.error = {
|
|
813
|
+
// Return invalid params error
|
|
814
|
+
...JsonRpcErrorCodes.InvalidParams,
|
|
815
|
+
// with the specific validation error message
|
|
816
|
+
message: parsed.error.message
|
|
817
|
+
};
|
|
818
|
+
return;
|
|
819
|
+
}
|
|
820
|
+
const { params } = parsed.data;
|
|
821
|
+
const result = await handler(params);
|
|
822
|
+
res.result = schema.result.to.parse(result);
|
|
823
|
+
}));
|
|
697
824
|
return engine;
|
|
698
|
-
};
|
|
825
|
+
}, "rpcEngineFromProvider");
|
|
699
826
|
|
|
700
827
|
// src/provider/client/MemoryXyoClient.ts
|
|
701
828
|
var MemoryXyoClient = class {
|
|
829
|
+
static {
|
|
830
|
+
__name(this, "MemoryXyoClient");
|
|
831
|
+
}
|
|
702
832
|
gateways;
|
|
703
833
|
permissions;
|
|
704
834
|
constructor(gateways, permissions) {
|
|
@@ -708,21 +838,29 @@ var MemoryXyoClient = class {
|
|
|
708
838
|
};
|
|
709
839
|
|
|
710
840
|
// src/provider/client/PermissionsStore/getPermissionsStoreFromTransport.ts
|
|
711
|
-
var getPermissionsStoreFromTransport = (_transport) => {
|
|
841
|
+
var getPermissionsStoreFromTransport = /* @__PURE__ */ __name((_transport) => {
|
|
712
842
|
throw new Error("Not implemented");
|
|
713
|
-
};
|
|
843
|
+
}, "getPermissionsStoreFromTransport");
|
|
714
844
|
|
|
715
845
|
// src/provider/client/PermissionsStore/MemoryPermissionsStore.ts
|
|
716
846
|
var MemoryPermissionsStore = class {
|
|
847
|
+
static {
|
|
848
|
+
__name(this, "MemoryPermissionsStore");
|
|
849
|
+
}
|
|
717
850
|
_store = /* @__PURE__ */ new Map();
|
|
718
851
|
getPermissions() {
|
|
719
|
-
return [
|
|
852
|
+
return [
|
|
853
|
+
...this._store.values()
|
|
854
|
+
];
|
|
720
855
|
}
|
|
721
856
|
requestPermissions(permissions) {
|
|
722
857
|
const now = Date.now();
|
|
723
858
|
for (const perm of permissions) {
|
|
724
859
|
const key = this.getKey(perm);
|
|
725
|
-
this._store.set(key, {
|
|
860
|
+
this._store.set(key, {
|
|
861
|
+
...perm,
|
|
862
|
+
date: now
|
|
863
|
+
});
|
|
726
864
|
}
|
|
727
865
|
return true;
|
|
728
866
|
}
|
|
@@ -748,6 +886,9 @@ import { isError, isUndefinedOrNull } from "@xylabs/typeof";
|
|
|
748
886
|
import { isAxiosError } from "axios";
|
|
749
887
|
import { v4 } from "uuid";
|
|
750
888
|
var HttpRpcTransport = class {
|
|
889
|
+
static {
|
|
890
|
+
__name(this, "HttpRpcTransport");
|
|
891
|
+
}
|
|
751
892
|
_rpcUrl;
|
|
752
893
|
_schemas;
|
|
753
894
|
constructor(rpcUrl, schemas) {
|
|
@@ -769,11 +910,11 @@ var HttpRpcTransport = class {
|
|
|
769
910
|
body.params = schemas[method].params.to.parse(params);
|
|
770
911
|
}
|
|
771
912
|
const res = await new AxiosJson().post(url, body);
|
|
772
|
-
const
|
|
773
|
-
if (isUndefinedOrNull(
|
|
774
|
-
throw new Error(
|
|
913
|
+
const json2 = res.data;
|
|
914
|
+
if (isUndefinedOrNull(json2) || json2.error) {
|
|
915
|
+
throw new Error(json2.error.message);
|
|
775
916
|
}
|
|
776
|
-
return schemas[method].result.from.parse(
|
|
917
|
+
return schemas[method].result.from.parse(json2.result);
|
|
777
918
|
} catch (ex) {
|
|
778
919
|
let message = isError(ex) ? ex.message : String(ex);
|
|
779
920
|
if (isAxiosError(ex)) {
|
|
@@ -789,11 +930,14 @@ import { assertEx } from "@xylabs/assert";
|
|
|
789
930
|
import { isObject, isString } from "@xylabs/typeof";
|
|
790
931
|
import { v4 as v42 } from "uuid";
|
|
791
932
|
var MemoryRpcTransport = class {
|
|
933
|
+
static {
|
|
934
|
+
__name(this, "MemoryRpcTransport");
|
|
935
|
+
}
|
|
792
936
|
_rpcEngine;
|
|
793
937
|
_schemas;
|
|
794
938
|
requestSchemas = {};
|
|
795
939
|
responseSchemas = {};
|
|
796
|
-
constructor(rpcEngine, schemas
|
|
940
|
+
constructor(rpcEngine, schemas) {
|
|
797
941
|
this._rpcEngine = rpcEngine;
|
|
798
942
|
this._schemas = schemas;
|
|
799
943
|
}
|
|
@@ -823,37 +967,41 @@ var MemoryRpcTransport = class {
|
|
|
823
967
|
};
|
|
824
968
|
|
|
825
969
|
// src/transport/post-message/LegacyPostMessageRpcTransport.ts
|
|
826
|
-
import {
|
|
827
|
-
isJsonRpcError,
|
|
828
|
-
isJsonRpcSuccess
|
|
829
|
-
} from "@metamask/utils";
|
|
970
|
+
import { isJsonRpcError, isJsonRpcSuccess } from "@metamask/utils";
|
|
830
971
|
import { isDefined } from "@xylabs/typeof";
|
|
831
972
|
import { v4 as v43 } from "uuid";
|
|
832
973
|
|
|
833
974
|
// src/transport/post-message/helpers.ts
|
|
834
|
-
var isRpcError = (data) => {
|
|
975
|
+
var isRpcError = /* @__PURE__ */ __name((data) => {
|
|
835
976
|
return data && typeof data === "object" && "error" in data && data.error;
|
|
836
|
-
};
|
|
977
|
+
}, "isRpcError");
|
|
837
978
|
|
|
838
979
|
// src/transport/post-message/resolveData.ts
|
|
839
|
-
var hasMatchingId = (eventData, targetId) => {
|
|
840
|
-
return eventData?.id === targetId ? {
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
980
|
+
var hasMatchingId = /* @__PURE__ */ __name((eventData, targetId) => {
|
|
981
|
+
return eventData?.id === targetId ? {
|
|
982
|
+
legacyEventData: eventData
|
|
983
|
+
} : false;
|
|
984
|
+
}, "hasMatchingId");
|
|
985
|
+
var hasMatchingNestedId = /* @__PURE__ */ __name((eventData, targetId) => {
|
|
986
|
+
return eventData?.data?.id === targetId ? {
|
|
987
|
+
eventData: eventData.data
|
|
988
|
+
} : false;
|
|
989
|
+
}, "hasMatchingNestedId");
|
|
990
|
+
var resolvedEvent = /* @__PURE__ */ __name((event, targetId) => {
|
|
846
991
|
return hasMatchingId(event.data, targetId) || hasMatchingNestedId(event.data, targetId);
|
|
847
|
-
};
|
|
992
|
+
}, "resolvedEvent");
|
|
848
993
|
|
|
849
994
|
// src/transport/post-message/LegacyPostMessageRpcTransport.ts
|
|
850
|
-
var isValidBaseRpcEvent = (data) => {
|
|
995
|
+
var isValidBaseRpcEvent = /* @__PURE__ */ __name((data) => {
|
|
851
996
|
return !!(data && typeof data === "object" && "jsonrpc" in data && data.jsonrpc === "2.0" && "method" in data && typeof data.method === "string" && "id" in data && typeof data.id === "string");
|
|
852
|
-
};
|
|
853
|
-
var isRpcResponse = (data, targetId) => {
|
|
997
|
+
}, "isValidBaseRpcEvent");
|
|
998
|
+
var isRpcResponse = /* @__PURE__ */ __name((data, targetId) => {
|
|
854
999
|
return isValidBaseRpcEvent(data) && (isDefined(targetId) ? data.id === targetId : true) && "result" in data && Array.isArray(data.result);
|
|
855
|
-
};
|
|
1000
|
+
}, "isRpcResponse");
|
|
856
1001
|
var LegacyPostMessageRpcTransport = class {
|
|
1002
|
+
static {
|
|
1003
|
+
__name(this, "LegacyPostMessageRpcTransport");
|
|
1004
|
+
}
|
|
857
1005
|
destination;
|
|
858
1006
|
schemas;
|
|
859
1007
|
sessionId;
|
|
@@ -875,7 +1023,7 @@ var LegacyPostMessageRpcTransport = class {
|
|
|
875
1023
|
body.params = isDefined(params) && isDefined(schemas[method]) ? schemas[method].params.to.parse(params) : params;
|
|
876
1024
|
return await new Promise((resolve, reject) => {
|
|
877
1025
|
const id2 = body.id;
|
|
878
|
-
const handler = (event) => {
|
|
1026
|
+
const handler = /* @__PURE__ */ __name((event) => {
|
|
879
1027
|
if (event.origin !== globalThis.window.origin) return;
|
|
880
1028
|
if (!isRpcResponse(event.data, id2)) return;
|
|
881
1029
|
const data = resolvedEvent(event, id2);
|
|
@@ -900,39 +1048,37 @@ var LegacyPostMessageRpcTransport = class {
|
|
|
900
1048
|
}
|
|
901
1049
|
reject(new Error("Unexpected response format"));
|
|
902
1050
|
}
|
|
903
|
-
};
|
|
1051
|
+
}, "handler");
|
|
904
1052
|
globalThis.addEventListener("message", handler);
|
|
905
|
-
globalThis.postMessage(
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
},
|
|
911
|
-
globalThis.location.origin
|
|
912
|
-
);
|
|
1053
|
+
globalThis.postMessage({
|
|
1054
|
+
data: body,
|
|
1055
|
+
destination: this.destination,
|
|
1056
|
+
sessionId: this.sessionId
|
|
1057
|
+
}, globalThis.location.origin);
|
|
913
1058
|
});
|
|
914
1059
|
}
|
|
915
1060
|
};
|
|
916
1061
|
var PostMessageRpcTransport = LegacyPostMessageRpcTransport;
|
|
917
1062
|
|
|
918
1063
|
// src/transport/post-message/SessionEnvelope.ts
|
|
919
|
-
var buildSessionMessageRequest = (data, destination) => {
|
|
1064
|
+
var buildSessionMessageRequest = /* @__PURE__ */ __name((data, destination) => {
|
|
920
1065
|
const request = {
|
|
921
1066
|
data,
|
|
922
1067
|
destination,
|
|
923
1068
|
sessionId: globalThis.xyo.walletExtensionId() ?? ""
|
|
924
1069
|
};
|
|
925
1070
|
return request;
|
|
926
|
-
};
|
|
1071
|
+
}, "buildSessionMessageRequest");
|
|
927
1072
|
|
|
928
1073
|
// src/provider/datalake/AbstractXyoDataLake.ts
|
|
929
1074
|
import { ObjectHasher } from "@xyo-network/hash";
|
|
930
1075
|
import { PayloadBuilder } from "@xyo-network/payload-builder";
|
|
931
1076
|
import { isAnyPayload } from "@xyo-network/payload-model";
|
|
932
|
-
import {
|
|
933
|
-
isHashPayload
|
|
934
|
-
} from "@xyo-network/xl1-protocol";
|
|
1077
|
+
import { isHashPayload } from "@xyo-network/xl1-protocol";
|
|
935
1078
|
var AbstractXyoDataLake = class {
|
|
1079
|
+
static {
|
|
1080
|
+
__name(this, "AbstractXyoDataLake");
|
|
1081
|
+
}
|
|
936
1082
|
async fetch(hashes, maxDepth = 10) {
|
|
937
1083
|
const results = await this.get(hashes);
|
|
938
1084
|
if (maxDepth > 0) {
|
|
@@ -941,17 +1087,32 @@ var AbstractXyoDataLake = class {
|
|
|
941
1087
|
const found = await this.fetch(hashPayloads.map((item) => item.hash), maxDepth - 1);
|
|
942
1088
|
const foundHashes = await Promise.all(found.map(async (item) => isAnyPayload(item) ? await PayloadBuilder.hash(item) : ObjectHasher.hashBytes(item)));
|
|
943
1089
|
const notFound = hashPayloads.filter((item) => !foundHashes.includes(item.hash));
|
|
944
|
-
return [
|
|
1090
|
+
return [
|
|
1091
|
+
...otherPayloads,
|
|
1092
|
+
...found,
|
|
1093
|
+
...notFound
|
|
1094
|
+
];
|
|
945
1095
|
}
|
|
946
1096
|
return results;
|
|
947
1097
|
}
|
|
948
1098
|
async trace(hash) {
|
|
949
|
-
const [result] = await this.get([
|
|
1099
|
+
const [result] = await this.get([
|
|
1100
|
+
hash
|
|
1101
|
+
]);
|
|
950
1102
|
if (isHashPayload(result)) {
|
|
951
1103
|
const [payload, route] = await this.trace(result.hash);
|
|
952
|
-
return [
|
|
1104
|
+
return [
|
|
1105
|
+
payload,
|
|
1106
|
+
[
|
|
1107
|
+
result,
|
|
1108
|
+
...route
|
|
1109
|
+
]
|
|
1110
|
+
];
|
|
953
1111
|
}
|
|
954
|
-
return [
|
|
1112
|
+
return [
|
|
1113
|
+
result,
|
|
1114
|
+
[]
|
|
1115
|
+
];
|
|
955
1116
|
}
|
|
956
1117
|
};
|
|
957
1118
|
|
|
@@ -959,6 +1120,9 @@ var AbstractXyoDataLake = class {
|
|
|
959
1120
|
import { assertEx as assertEx2 } from "@xylabs/assert";
|
|
960
1121
|
import { isAnyPayload as isAnyPayload2 } from "@xyo-network/payload-model";
|
|
961
1122
|
var ArchivistXyoDataLake = class extends AbstractXyoDataLake {
|
|
1123
|
+
static {
|
|
1124
|
+
__name(this, "ArchivistXyoDataLake");
|
|
1125
|
+
}
|
|
962
1126
|
_archivist;
|
|
963
1127
|
constructor(archivist) {
|
|
964
1128
|
super();
|
|
@@ -983,6 +1147,9 @@ import { isAnyPayload as isAnyPayload3 } from "@xyo-network/payload-model";
|
|
|
983
1147
|
import { isHashPayload as isHashPayload2 } from "@xyo-network/xl1-protocol";
|
|
984
1148
|
import { Axios } from "axios";
|
|
985
1149
|
var HttpXyoDataLake = class extends AbstractXyoDataLake {
|
|
1150
|
+
static {
|
|
1151
|
+
__name(this, "HttpXyoDataLake");
|
|
1152
|
+
}
|
|
986
1153
|
_axiosGet;
|
|
987
1154
|
_axiosInsertBlob;
|
|
988
1155
|
_axiosInsertJson;
|
|
@@ -990,9 +1157,23 @@ var HttpXyoDataLake = class extends AbstractXyoDataLake {
|
|
|
990
1157
|
constructor(endpoint) {
|
|
991
1158
|
super();
|
|
992
1159
|
this._endpoint = endpoint;
|
|
993
|
-
this._axiosInsertJson = new AxiosJson2({
|
|
994
|
-
|
|
995
|
-
|
|
1160
|
+
this._axiosInsertJson = new AxiosJson2({
|
|
1161
|
+
baseURL: endpoint
|
|
1162
|
+
});
|
|
1163
|
+
this._axiosInsertBlob = new Axios({
|
|
1164
|
+
baseURL: endpoint,
|
|
1165
|
+
headers: {
|
|
1166
|
+
"Content-Type": "application/octet-stream",
|
|
1167
|
+
"Accept": "application/octet-stream"
|
|
1168
|
+
}
|
|
1169
|
+
});
|
|
1170
|
+
this._axiosGet = new Axios({
|
|
1171
|
+
baseURL: endpoint,
|
|
1172
|
+
headers: {
|
|
1173
|
+
"Content-Type": "application/json",
|
|
1174
|
+
"Accept": "application/octet-stream, application/json"
|
|
1175
|
+
}
|
|
1176
|
+
});
|
|
996
1177
|
}
|
|
997
1178
|
get endpoint() {
|
|
998
1179
|
return this._endpoint;
|
|
@@ -1068,12 +1249,17 @@ var HttpXyoDataLake = class extends AbstractXyoDataLake {
|
|
|
1068
1249
|
|
|
1069
1250
|
// src/provider/runner/JsonRpcXyoRunner.ts
|
|
1070
1251
|
var JsonRpcXyoRunner = class {
|
|
1252
|
+
static {
|
|
1253
|
+
__name(this, "JsonRpcXyoRunner");
|
|
1254
|
+
}
|
|
1071
1255
|
transport;
|
|
1072
1256
|
constructor(transport) {
|
|
1073
1257
|
this.transport = transport;
|
|
1074
1258
|
}
|
|
1075
1259
|
async broadcastTransaction(transaction) {
|
|
1076
|
-
return await this.transport.sendRequest("xyoRunner_broadcastTransaction", [
|
|
1260
|
+
return await this.transport.sendRequest("xyoRunner_broadcastTransaction", [
|
|
1261
|
+
transaction
|
|
1262
|
+
]);
|
|
1077
1263
|
}
|
|
1078
1264
|
};
|
|
1079
1265
|
|
|
@@ -1082,6 +1268,9 @@ import { MemoryArchivist } from "@xyo-network/archivist-memory";
|
|
|
1082
1268
|
import { PayloadBuilder as PayloadBuilder2 } from "@xyo-network/payload-builder";
|
|
1083
1269
|
import { flattenHydratedTransaction } from "@xyo-network/xl1-protocol-sdk";
|
|
1084
1270
|
var MemoryXyoRunner = class {
|
|
1271
|
+
static {
|
|
1272
|
+
__name(this, "MemoryXyoRunner");
|
|
1273
|
+
}
|
|
1085
1274
|
_archivist;
|
|
1086
1275
|
async broadcastTransaction(transaction) {
|
|
1087
1276
|
const archivist = await this.getArchivist();
|
|
@@ -1090,7 +1279,9 @@ var MemoryXyoRunner = class {
|
|
|
1090
1279
|
}
|
|
1091
1280
|
async getArchivist() {
|
|
1092
1281
|
if (!this._archivist) {
|
|
1093
|
-
this._archivist = await MemoryArchivist.create({
|
|
1282
|
+
this._archivist = await MemoryArchivist.create({
|
|
1283
|
+
account: "random"
|
|
1284
|
+
});
|
|
1094
1285
|
}
|
|
1095
1286
|
return this._archivist;
|
|
1096
1287
|
}
|
|
@@ -1103,6 +1294,9 @@ import { PayloadBuilder as PayloadBuilder3 } from "@xyo-network/payload-builder"
|
|
|
1103
1294
|
import { PayloadBundleSchema } from "@xyo-network/payload-model";
|
|
1104
1295
|
import { flattenHydratedTransaction as flattenHydratedTransaction2 } from "@xyo-network/xl1-protocol-sdk";
|
|
1105
1296
|
var NodeXyoRunner = class {
|
|
1297
|
+
static {
|
|
1298
|
+
__name(this, "NodeXyoRunner");
|
|
1299
|
+
}
|
|
1106
1300
|
// TODO: Make configurable with defaults
|
|
1107
1301
|
node;
|
|
1108
1302
|
pendingArchivistPath = "XYOChain:Pending:PendingTransactions";
|
|
@@ -1119,22 +1313,27 @@ var NodeXyoRunner = class {
|
|
|
1119
1313
|
payloads: flattened,
|
|
1120
1314
|
root: txHash
|
|
1121
1315
|
};
|
|
1122
|
-
await pendingArchivist.insert([
|
|
1316
|
+
await pendingArchivist.insert([
|
|
1317
|
+
payloadBundle
|
|
1318
|
+
]);
|
|
1123
1319
|
return txHash;
|
|
1124
1320
|
}
|
|
1125
|
-
getArchivist = async (identifier) => {
|
|
1321
|
+
getArchivist = /* @__PURE__ */ __name(async (identifier) => {
|
|
1126
1322
|
const archivist = await this.node.resolve(identifier);
|
|
1127
1323
|
return assertEx4(asArchivistInstance(archivist), () => `Error: Could not resolve ${identifier} to an archivist instance`);
|
|
1128
|
-
};
|
|
1129
|
-
getPendingArchivist = async () => {
|
|
1324
|
+
}, "getArchivist");
|
|
1325
|
+
getPendingArchivist = /* @__PURE__ */ __name(async () => {
|
|
1130
1326
|
if (this._pendingArchivist) return this._pendingArchivist;
|
|
1131
1327
|
this._pendingArchivist = await this.getArchivist(this.pendingArchivistPath);
|
|
1132
1328
|
return assertEx4(this._pendingArchivist, () => `Error: Could not resolve pending archivist at ${this.pendingArchivistPath}`);
|
|
1133
|
-
};
|
|
1329
|
+
}, "getPendingArchivist");
|
|
1134
1330
|
};
|
|
1135
1331
|
|
|
1136
1332
|
// src/provider/signer/JsonRpcXyoSigner.ts
|
|
1137
1333
|
var RpcXyoSigner = class {
|
|
1334
|
+
static {
|
|
1335
|
+
__name(this, "RpcXyoSigner");
|
|
1336
|
+
}
|
|
1138
1337
|
transport;
|
|
1139
1338
|
constructor(transport) {
|
|
1140
1339
|
this.transport = transport;
|
|
@@ -1155,16 +1354,24 @@ var RpcXyoSigner = class {
|
|
|
1155
1354
|
return ret;
|
|
1156
1355
|
}
|
|
1157
1356
|
async signTransaction(tx) {
|
|
1158
|
-
const ret = await this.transport.sendRequest("xyoSigner_signTransaction", [
|
|
1357
|
+
const ret = await this.transport.sendRequest("xyoSigner_signTransaction", [
|
|
1358
|
+
tx
|
|
1359
|
+
]);
|
|
1159
1360
|
return ret;
|
|
1160
1361
|
}
|
|
1161
1362
|
};
|
|
1162
1363
|
var JsonRpcXyoSigner = class extends RpcXyoSigner {
|
|
1364
|
+
static {
|
|
1365
|
+
__name(this, "JsonRpcXyoSigner");
|
|
1366
|
+
}
|
|
1163
1367
|
};
|
|
1164
1368
|
|
|
1165
1369
|
// src/provider/signer/MemoryXyoSigner.ts
|
|
1166
1370
|
import { buildTransaction, signTransaction } from "@xyo-network/xl1-protocol-sdk";
|
|
1167
1371
|
var MemoryXyoSigner = class {
|
|
1372
|
+
static {
|
|
1373
|
+
__name(this, "MemoryXyoSigner");
|
|
1374
|
+
}
|
|
1168
1375
|
_account;
|
|
1169
1376
|
constructor(account) {
|
|
1170
1377
|
this._account = account;
|
|
@@ -1174,44 +1381,52 @@ var MemoryXyoSigner = class {
|
|
|
1174
1381
|
}
|
|
1175
1382
|
async createSignedTransaction(chain, elevatedPayloads, additionalPayloads, nbf, exp, fees, from) {
|
|
1176
1383
|
const fromAddress = from ?? this._account.address;
|
|
1177
|
-
const transaction = await buildTransaction(
|
|
1178
|
-
chain,
|
|
1179
|
-
elevatedPayloads,
|
|
1180
|
-
additionalPayloads,
|
|
1181
|
-
this._account,
|
|
1182
|
-
nbf,
|
|
1183
|
-
exp,
|
|
1184
|
-
fromAddress,
|
|
1185
|
-
fees
|
|
1186
|
-
);
|
|
1384
|
+
const transaction = await buildTransaction(chain, elevatedPayloads, additionalPayloads, this._account, nbf, exp, fromAddress, fees);
|
|
1187
1385
|
return transaction[0];
|
|
1188
1386
|
}
|
|
1189
1387
|
async signTransaction(tx) {
|
|
1190
1388
|
const txBW = await signTransaction(tx[0], this._account);
|
|
1191
|
-
return [
|
|
1389
|
+
return [
|
|
1390
|
+
txBW,
|
|
1391
|
+
tx[1]
|
|
1392
|
+
];
|
|
1192
1393
|
}
|
|
1193
1394
|
};
|
|
1194
1395
|
|
|
1195
1396
|
// src/provider/viewer/JsonRpcXyoViewer.ts
|
|
1196
1397
|
var JsonRpcXyoViewer = class {
|
|
1398
|
+
static {
|
|
1399
|
+
__name(this, "JsonRpcXyoViewer");
|
|
1400
|
+
}
|
|
1197
1401
|
transport;
|
|
1198
1402
|
constructor(transport) {
|
|
1199
1403
|
this.transport = transport;
|
|
1200
1404
|
}
|
|
1201
1405
|
async accountBalance(address) {
|
|
1202
|
-
return await this.transport.sendRequest("xyoViewer_accountBalance", [
|
|
1406
|
+
return await this.transport.sendRequest("xyoViewer_accountBalance", [
|
|
1407
|
+
address
|
|
1408
|
+
]);
|
|
1203
1409
|
}
|
|
1204
1410
|
async accountHistory(address) {
|
|
1205
|
-
return await this.transport.sendRequest("xyoViewer_accountHistory", [
|
|
1411
|
+
return await this.transport.sendRequest("xyoViewer_accountHistory", [
|
|
1412
|
+
address
|
|
1413
|
+
]);
|
|
1206
1414
|
}
|
|
1207
1415
|
async blockByHash(hash) {
|
|
1208
|
-
return await this.transport.sendRequest("xyoViewer_blockByHash", [
|
|
1416
|
+
return await this.transport.sendRequest("xyoViewer_blockByHash", [
|
|
1417
|
+
hash
|
|
1418
|
+
]);
|
|
1209
1419
|
}
|
|
1210
1420
|
async blockByNumber(blockNumber) {
|
|
1211
|
-
return await this.transport.sendRequest("xyoViewer_blockByNumber", [
|
|
1421
|
+
return await this.transport.sendRequest("xyoViewer_blockByNumber", [
|
|
1422
|
+
blockNumber
|
|
1423
|
+
]);
|
|
1212
1424
|
}
|
|
1213
1425
|
async blocksByHash(hash, limit) {
|
|
1214
|
-
return await this.transport.sendRequest("xyoViewer_blocksByHash", [
|
|
1426
|
+
return await this.transport.sendRequest("xyoViewer_blocksByHash", [
|
|
1427
|
+
hash,
|
|
1428
|
+
limit
|
|
1429
|
+
]);
|
|
1215
1430
|
}
|
|
1216
1431
|
async chainId() {
|
|
1217
1432
|
return await this.transport.sendRequest("xyoViewer_chainId");
|
|
@@ -1226,13 +1441,21 @@ var JsonRpcXyoViewer = class {
|
|
|
1226
1441
|
return await this.transport.sendRequest("xyoViewer_currentBlockNumber");
|
|
1227
1442
|
}
|
|
1228
1443
|
async transactionByBlockHashAndIndex(blockHash, transactionIndex) {
|
|
1229
|
-
return await this.transport.sendRequest("xyoViewer_transactionByBlockHashAndIndex", [
|
|
1444
|
+
return await this.transport.sendRequest("xyoViewer_transactionByBlockHashAndIndex", [
|
|
1445
|
+
blockHash,
|
|
1446
|
+
transactionIndex
|
|
1447
|
+
]);
|
|
1230
1448
|
}
|
|
1231
1449
|
async transactionByBlockNumberAndIndex(blockNumber, transactionIndex) {
|
|
1232
|
-
return await this.transport.sendRequest("xyoViewer_transactionByBlockNumberAndIndex", [
|
|
1450
|
+
return await this.transport.sendRequest("xyoViewer_transactionByBlockNumberAndIndex", [
|
|
1451
|
+
blockNumber,
|
|
1452
|
+
transactionIndex
|
|
1453
|
+
]);
|
|
1233
1454
|
}
|
|
1234
1455
|
async transactionByHash(transactionHash) {
|
|
1235
|
-
return await this.transport.sendRequest("xyoViewer_transactionByHash", [
|
|
1456
|
+
return await this.transport.sendRequest("xyoViewer_transactionByHash", [
|
|
1457
|
+
transactionHash
|
|
1458
|
+
]);
|
|
1236
1459
|
}
|
|
1237
1460
|
};
|
|
1238
1461
|
|
|
@@ -1243,6 +1466,9 @@ import { isAnyPayload as isAnyPayload4 } from "@xyo-network/payload-model";
|
|
|
1243
1466
|
import { defaultTransactionFees, isDataLakeProvider } from "@xyo-network/xl1-protocol";
|
|
1244
1467
|
import { HydratedTransactionWrapper } from "@xyo-network/xl1-wrappers";
|
|
1245
1468
|
var XyoConnection = class {
|
|
1469
|
+
static {
|
|
1470
|
+
__name(this, "XyoConnection");
|
|
1471
|
+
}
|
|
1246
1472
|
_network;
|
|
1247
1473
|
_runner;
|
|
1248
1474
|
_signer;
|
|
@@ -1282,13 +1508,7 @@ var XyoConnection = class {
|
|
|
1282
1508
|
}))[0];
|
|
1283
1509
|
}
|
|
1284
1510
|
/** @deprecated use addPayloadsToChain from gateway instead */
|
|
1285
|
-
async submitTransaction(elevatedPayloads, additionalPayloads, {
|
|
1286
|
-
chain,
|
|
1287
|
-
exp,
|
|
1288
|
-
fees,
|
|
1289
|
-
from,
|
|
1290
|
-
nbf
|
|
1291
|
-
} = {}) {
|
|
1511
|
+
async submitTransaction(elevatedPayloads, additionalPayloads, { chain, exp, fees, from, nbf } = {}) {
|
|
1292
1512
|
const viewer = assertEx5(this.viewer, () => "No viewer available");
|
|
1293
1513
|
const signer = assertEx5(this.signer, () => "No signer available");
|
|
1294
1514
|
const runner = assertEx5(this.runner, () => "No runner available");
|
|
@@ -1300,15 +1520,7 @@ var XyoConnection = class {
|
|
|
1300
1520
|
const feesResolved = fees ?? defaultTransactionFees;
|
|
1301
1521
|
const fromResolved = from ?? await signer.address();
|
|
1302
1522
|
if (fromResolved === void 0) throw new Error("Failed to determine from address");
|
|
1303
|
-
const signedTransaction = assertEx5(await signer.createSignedTransaction(
|
|
1304
|
-
chainResolved,
|
|
1305
|
-
elevatedPayloads,
|
|
1306
|
-
additionalPayloads,
|
|
1307
|
-
nbfResolved,
|
|
1308
|
-
expResolved,
|
|
1309
|
-
feesResolved,
|
|
1310
|
-
fromResolved
|
|
1311
|
-
), () => "Failed to create transaction");
|
|
1523
|
+
const signedTransaction = assertEx5(await signer.createSignedTransaction(chainResolved, elevatedPayloads, additionalPayloads, nbfResolved, expResolved, feesResolved, fromResolved), () => "Failed to create transaction");
|
|
1312
1524
|
const hydratedTransaction = [
|
|
1313
1525
|
await PayloadBuilder4.addStorageMeta(signedTransaction),
|
|
1314
1526
|
await PayloadBuilder4.addStorageMeta(elevatedPayloads)
|
|
@@ -1324,14 +1536,16 @@ var XyoConnection = class {
|
|
|
1324
1536
|
|
|
1325
1537
|
// src/provider/connection/HttpRpcXyoConnection.ts
|
|
1326
1538
|
var HttpRpcXyoConnection = class extends XyoConnection {
|
|
1539
|
+
static {
|
|
1540
|
+
__name(this, "HttpRpcXyoConnection");
|
|
1541
|
+
}
|
|
1327
1542
|
constructor(params) {
|
|
1328
|
-
const {
|
|
1329
|
-
account,
|
|
1330
|
-
endpoint,
|
|
1331
|
-
storage: storageParam
|
|
1332
|
-
} = params;
|
|
1543
|
+
const { account, endpoint, storage: storageParam } = params;
|
|
1333
1544
|
const signer = isDefined3(account) ? new MemoryXyoSigner(account) : void 0;
|
|
1334
|
-
const transport = new HttpRpcTransport(endpoint, {
|
|
1545
|
+
const transport = new HttpRpcTransport(endpoint, {
|
|
1546
|
+
...XyoRunnerRpcSchemas,
|
|
1547
|
+
...XyoViewerRpcSchemas
|
|
1548
|
+
});
|
|
1335
1549
|
const runner = new JsonRpcXyoRunner(transport);
|
|
1336
1550
|
const viewer = new JsonRpcXyoViewer(transport);
|
|
1337
1551
|
const storage = isDataLakeProvider2(storageParam) ? storageParam : isString2(storageParam) ? new HttpXyoDataLake(storageParam) : void 0;
|
|
@@ -1344,6 +1558,9 @@ var HttpRpcXyoConnection = class extends XyoConnection {
|
|
|
1344
1558
|
}
|
|
1345
1559
|
};
|
|
1346
1560
|
var RpcXyoConnection = class extends HttpRpcXyoConnection {
|
|
1561
|
+
static {
|
|
1562
|
+
__name(this, "RpcXyoConnection");
|
|
1563
|
+
}
|
|
1347
1564
|
};
|
|
1348
1565
|
|
|
1349
1566
|
// src/provider/gateway/Abstract.ts
|
|
@@ -1351,6 +1568,9 @@ import { assertEx as assertEx6 } from "@xylabs/assert";
|
|
|
1351
1568
|
import { PayloadBuilder as PayloadBuilder5 } from "@xyo-network/payload-builder";
|
|
1352
1569
|
import { buildUnsignedTransaction } from "@xyo-network/xl1-protocol-sdk";
|
|
1353
1570
|
var AbstractXyoGateway = class {
|
|
1571
|
+
static {
|
|
1572
|
+
__name(this, "AbstractXyoGateway");
|
|
1573
|
+
}
|
|
1354
1574
|
async addPayloadsToChain(onChain, offChain) {
|
|
1355
1575
|
const connection = await this.connection();
|
|
1356
1576
|
const viewer = assertEx6(connection.viewer, () => "No viewer available on connection");
|
|
@@ -1359,19 +1579,20 @@ var AbstractXyoGateway = class {
|
|
|
1359
1579
|
const nbf = await viewer.currentBlockNumber();
|
|
1360
1580
|
const tx = await buildUnsignedTransaction(chainId, onChain, offChain, nbf, nbf + 1e3, await signer.address());
|
|
1361
1581
|
const hash = await this.addTransactionToChain(tx);
|
|
1362
|
-
return [
|
|
1582
|
+
return [
|
|
1583
|
+
hash,
|
|
1584
|
+
tx
|
|
1585
|
+
];
|
|
1363
1586
|
}
|
|
1364
1587
|
async addTransactionToChain(tx) {
|
|
1365
1588
|
const connection = await this.connection();
|
|
1366
1589
|
const signer = await this.signer();
|
|
1367
1590
|
const runner = assertEx6(connection.runner, () => "No runner available on connection");
|
|
1368
1591
|
const signedTx = await signer.signTransaction(tx);
|
|
1369
|
-
return await runner.broadcastTransaction(
|
|
1370
|
-
[
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
]
|
|
1374
|
-
);
|
|
1592
|
+
return await runner.broadcastTransaction([
|
|
1593
|
+
await PayloadBuilder5.addStorageMeta(signedTx[0]),
|
|
1594
|
+
await PayloadBuilder5.addStorageMeta(signedTx[1])
|
|
1595
|
+
]);
|
|
1375
1596
|
}
|
|
1376
1597
|
/** @deprecated use addPayloadsToChain instead */
|
|
1377
1598
|
async submitTransaction(elevatedPayloads, additionalPayloads) {
|
|
@@ -1384,6 +1605,9 @@ var AbstractXyoGateway = class {
|
|
|
1384
1605
|
|
|
1385
1606
|
// src/provider/gateway/MemoryXyoGateway.ts
|
|
1386
1607
|
var MemoryXyoGateway = class extends AbstractXyoGateway {
|
|
1608
|
+
static {
|
|
1609
|
+
__name(this, "MemoryXyoGateway");
|
|
1610
|
+
}
|
|
1387
1611
|
_connection;
|
|
1388
1612
|
_signer;
|
|
1389
1613
|
constructor(signer, connection) {
|
|
@@ -1438,6 +1662,9 @@ var StatusNetworks = {
|
|
|
1438
1662
|
|
|
1439
1663
|
// src/provider/network/MemoryXyoNetwork.ts
|
|
1440
1664
|
var MemoryXyoNetwork = class {
|
|
1665
|
+
static {
|
|
1666
|
+
__name(this, "MemoryXyoNetwork");
|
|
1667
|
+
}
|
|
1441
1668
|
_networkId;
|
|
1442
1669
|
constructor(networkId) {
|
|
1443
1670
|
this._networkId = networkId;
|