@xyo-network/xl1-rpc 1.12.0 → 1.12.1
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 +464 -235
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/transport/MemoryRpcTransport.d.ts +2 -3
- package/dist/neutral/transport/MemoryRpcTransport.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/common/Address.d.ts.map +1 -1
- package/dist/neutral/types/schema/common/Chain.d.ts.map +1 -1
- package/dist/neutral/types/schema/common/Sequence.d.ts.map +1 -1
- package/dist/node/index-node.mjs +493 -266
- package/dist/node/index-node.mjs.map +1 -1
- package/dist/node/transport/MemoryRpcTransport.d.ts +2 -3
- package/dist/node/transport/MemoryRpcTransport.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/common/Address.d.ts.map +1 -1
- package/dist/node/types/schema/common/Chain.d.ts.map +1 -1
- package/dist/node/types/schema/common/Sequence.d.ts.map +1 -1
- package/package.json +28 -31
- 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/MemoryRpcTransport.ts +3 -3
- package/src/types/schema/AllRpcSchemas.ts +2 -2
- package/src/types/schema/common/Address.ts +2 -5
- package/src/types/schema/common/Chain.ts +2 -5
- package/src/types/schema/common/Sequence.ts +1 -2
package/dist/neutral/index.mjs
CHANGED
|
@@ -1,54 +1,69 @@
|
|
|
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/provider/client/MemoryXyoClient.ts
|
|
51
63
|
var MemoryXyoClient = class {
|
|
64
|
+
static {
|
|
65
|
+
__name(this, "MemoryXyoClient");
|
|
66
|
+
}
|
|
52
67
|
gateways;
|
|
53
68
|
permissions;
|
|
54
69
|
constructor(gateways, permissions) {
|
|
@@ -58,21 +73,29 @@ var MemoryXyoClient = class {
|
|
|
58
73
|
};
|
|
59
74
|
|
|
60
75
|
// src/provider/client/PermissionsStore/getPermissionsStoreFromTransport.ts
|
|
61
|
-
var getPermissionsStoreFromTransport = (_transport) => {
|
|
76
|
+
var getPermissionsStoreFromTransport = /* @__PURE__ */ __name((_transport) => {
|
|
62
77
|
throw new Error("Not implemented");
|
|
63
|
-
};
|
|
78
|
+
}, "getPermissionsStoreFromTransport");
|
|
64
79
|
|
|
65
80
|
// src/provider/client/PermissionsStore/MemoryPermissionsStore.ts
|
|
66
81
|
var MemoryPermissionsStore = class {
|
|
82
|
+
static {
|
|
83
|
+
__name(this, "MemoryPermissionsStore");
|
|
84
|
+
}
|
|
67
85
|
_store = /* @__PURE__ */ new Map();
|
|
68
86
|
getPermissions() {
|
|
69
|
-
return [
|
|
87
|
+
return [
|
|
88
|
+
...this._store.values()
|
|
89
|
+
];
|
|
70
90
|
}
|
|
71
91
|
requestPermissions(permissions) {
|
|
72
92
|
const now = Date.now();
|
|
73
93
|
for (const perm of permissions) {
|
|
74
94
|
const key = this.getKey(perm);
|
|
75
|
-
this._store.set(key, {
|
|
95
|
+
this._store.set(key, {
|
|
96
|
+
...perm,
|
|
97
|
+
date: now
|
|
98
|
+
});
|
|
76
99
|
}
|
|
77
100
|
return true;
|
|
78
101
|
}
|
|
@@ -100,10 +123,22 @@ import { v4 } from "uuid";
|
|
|
100
123
|
|
|
101
124
|
// src/types/ErrorCodes.ts
|
|
102
125
|
var JsonRpcErrorCodes = {
|
|
103
|
-
InternalError: {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
126
|
+
InternalError: {
|
|
127
|
+
code: -32603,
|
|
128
|
+
message: "Internal JSON-RPC error (unexpected exception)."
|
|
129
|
+
},
|
|
130
|
+
InvalidParams: {
|
|
131
|
+
code: -32602,
|
|
132
|
+
message: "Invalid method parameter(s)."
|
|
133
|
+
},
|
|
134
|
+
InvalidRequest: {
|
|
135
|
+
code: -32600,
|
|
136
|
+
message: "The JSON sent is not a valid Request object."
|
|
137
|
+
},
|
|
138
|
+
MethodNotFound: {
|
|
139
|
+
code: -32601,
|
|
140
|
+
message: "The method does not exist or is not available."
|
|
141
|
+
}
|
|
107
142
|
};
|
|
108
143
|
|
|
109
144
|
// src/types/JsonRpc.ts
|
|
@@ -113,20 +148,14 @@ var jsonrpc = "2.0";
|
|
|
113
148
|
import { z as z13 } from "zod";
|
|
114
149
|
|
|
115
150
|
// src/types/schema/common/Address.ts
|
|
116
|
-
import { toAddress } from "@xylabs/hex";
|
|
117
|
-
import { AddressRegEx } from "@xyo-network/payload-wrapper";
|
|
151
|
+
import { AddressRegEx, toAddress } from "@xylabs/hex";
|
|
118
152
|
import { z } from "zod";
|
|
119
|
-
var
|
|
120
|
-
var AddressZod = z.string().toLowerCase().regex(CompiledAddressRegEx).transform((v) => toAddress(v));
|
|
153
|
+
var AddressZod = z.string().toLowerCase().regex(AddressRegEx).transform((v) => toAddress(v));
|
|
121
154
|
|
|
122
155
|
// src/types/schema/common/AllowedBlockPayload.ts
|
|
123
156
|
import { BoundWitnessSchema } from "@xyo-network/boundwitness-model";
|
|
124
157
|
import { SchemaSchema } from "@xyo-network/core-payload-plugins";
|
|
125
|
-
import {
|
|
126
|
-
ChainStakeIntentSchema,
|
|
127
|
-
HashSchema,
|
|
128
|
-
TransferSchema
|
|
129
|
-
} from "@xyo-network/xl1-protocol";
|
|
158
|
+
import { ChainStakeIntentSchema, HashSchema, TransferSchema } from "@xyo-network/xl1-protocol";
|
|
130
159
|
import z2 from "zod";
|
|
131
160
|
var AllowedBlockPayloadSchemas = [
|
|
132
161
|
BoundWitnessSchema,
|
|
@@ -135,7 +164,9 @@ var AllowedBlockPayloadSchemas = [
|
|
|
135
164
|
SchemaSchema,
|
|
136
165
|
TransferSchema
|
|
137
166
|
];
|
|
138
|
-
var AllowedBlockPayloadZod = z2.object({
|
|
167
|
+
var AllowedBlockPayloadZod = z2.object({
|
|
168
|
+
schema: z2.enum(AllowedBlockPayloadSchemas)
|
|
169
|
+
});
|
|
139
170
|
|
|
140
171
|
// src/types/schema/common/BlockBoundWitness.ts
|
|
141
172
|
import { HexZod as HexZod2 } from "@xylabs/hex";
|
|
@@ -151,9 +182,8 @@ import { HashToJsonZod } from "@xylabs/hex";
|
|
|
151
182
|
import { z as z4 } from "zod";
|
|
152
183
|
|
|
153
184
|
// src/types/schema/common/Sequence.ts
|
|
154
|
-
import { toHex } from "@xylabs/hex";
|
|
185
|
+
import { HexRegExMinMax, toHex } from "@xylabs/hex";
|
|
155
186
|
import { SequenceConstants } from "@xyo-network/payload-model";
|
|
156
|
-
import { HexRegExMinMax } from "@xyo-network/payload-wrapper";
|
|
157
187
|
import { z as z3 } from "zod";
|
|
158
188
|
var LocalSequenceRegex = new RegExp(HexRegExMinMax(SequenceConstants.localSequenceBytes, SequenceConstants.localSequenceBytes));
|
|
159
189
|
var LocalSequenceToStringZod = z3.string().regex(LocalSequenceRegex);
|
|
@@ -161,8 +191,14 @@ var LocalSequenceFromStringZod = z3.string().regex(LocalSequenceRegex).transform
|
|
|
161
191
|
var QualifiedSequenceRegex = new RegExp(HexRegExMinMax(SequenceConstants.qualifiedSequenceBytes, SequenceConstants.qualifiedSequenceBytes));
|
|
162
192
|
var QualifiedSequenceToStringZod = z3.string().regex(QualifiedSequenceRegex);
|
|
163
193
|
var QualifiedSequenceFromStringZod = z3.string().regex(QualifiedSequenceRegex).transform((v) => toHex(v));
|
|
164
|
-
var SequenceToStringZod = z3.union([
|
|
165
|
-
|
|
194
|
+
var SequenceToStringZod = z3.union([
|
|
195
|
+
LocalSequenceToStringZod,
|
|
196
|
+
QualifiedSequenceToStringZod
|
|
197
|
+
]);
|
|
198
|
+
var SequenceFromStringZod = z3.union([
|
|
199
|
+
LocalSequenceFromStringZod,
|
|
200
|
+
QualifiedSequenceFromStringZod
|
|
201
|
+
]);
|
|
166
202
|
|
|
167
203
|
// src/types/schema/common/Payload.ts
|
|
168
204
|
var StorageMetaZod = z4.object({
|
|
@@ -171,13 +207,16 @@ var StorageMetaZod = z4.object({
|
|
|
171
207
|
_sequence: SequenceToStringZod
|
|
172
208
|
});
|
|
173
209
|
var SchemaZod = z4.string();
|
|
174
|
-
var PayloadZod = z4.object({
|
|
210
|
+
var PayloadZod = z4.object({
|
|
211
|
+
schema: SchemaZod
|
|
212
|
+
}).catchall(z4.any());
|
|
175
213
|
var PayloadWithStorageMetaZod = PayloadZod.extend(StorageMetaZod.shape);
|
|
176
214
|
var AnyPayloadZod = PayloadZod.catchall(z4.json());
|
|
177
215
|
var AnyPayloadWithStorageMetaZod = AnyPayloadZod.extend(StorageMetaZod.shape);
|
|
178
216
|
function WithStorageMetaZod(valueZod) {
|
|
179
217
|
return StorageMetaZod.extend(valueZod.shape);
|
|
180
218
|
}
|
|
219
|
+
__name(WithStorageMetaZod, "WithStorageMetaZod");
|
|
181
220
|
|
|
182
221
|
// src/types/schema/common/BoundWitness.ts
|
|
183
222
|
var BoundWitnessRequiredFieldsZod = z5.object({
|
|
@@ -189,24 +228,33 @@ var BoundWitnessRequiredFieldsZod = z5.object({
|
|
|
189
228
|
var BoundWitnessMetaZod = z5.object({
|
|
190
229
|
$destination: AddressZod.optional(),
|
|
191
230
|
$sourceQuery: HashZod.optional(),
|
|
192
|
-
$signatures: z5.array(z5.union([
|
|
231
|
+
$signatures: z5.array(z5.union([
|
|
232
|
+
HexZod,
|
|
233
|
+
z5.null()
|
|
234
|
+
]))
|
|
235
|
+
});
|
|
236
|
+
var BoundWitnessZod = PayloadZod.extend({
|
|
237
|
+
schema: z5.literal(BoundWitnessSchema2)
|
|
238
|
+
}).extend(BoundWitnessRequiredFieldsZod.shape).extend(BoundWitnessMetaZod.shape).refine((data) => data.$signatures.length === data.addresses.length, {
|
|
239
|
+
message: "$signatures length must equal addresses length"
|
|
193
240
|
});
|
|
194
|
-
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" });
|
|
195
241
|
var AnyBoundWitnessZod = BoundWitnessZod.catchall(z5.any());
|
|
196
|
-
var UnsignedBoundWitnessZod = BoundWitnessZod.refine((data) => data.$signatures.includes(null), {
|
|
242
|
+
var UnsignedBoundWitnessZod = BoundWitnessZod.refine((data) => data.$signatures.includes(null), {
|
|
243
|
+
message: "all $signatures must be null"
|
|
244
|
+
});
|
|
197
245
|
var AnyUnsignedBoundWitnessZod = UnsignedBoundWitnessZod.catchall(z5.any());
|
|
198
246
|
var UnsignedBoundWitnessWithStorageMetaZod = UnsignedBoundWitnessZod.extend(BoundWitnessRequiredFieldsZod.shape).extend(BoundWitnessMetaZod.shape);
|
|
199
|
-
var SignedBoundWitnessZod = BoundWitnessZod.refine((data) => !data.$signatures.includes(null), {
|
|
247
|
+
var SignedBoundWitnessZod = BoundWitnessZod.refine((data) => !data.$signatures.includes(null), {
|
|
248
|
+
message: "all $signatures must not be null"
|
|
249
|
+
});
|
|
200
250
|
var SignedBoundWitnessWithStorageMetaZod = UnsignedBoundWitnessWithStorageMetaZod;
|
|
201
251
|
var AnySignedBoundWitnessZod = UnsignedBoundWitnessZod.catchall(z5.any());
|
|
202
252
|
var AnySignedBoundWitnessWithStorageMetaZod = UnsignedBoundWitnessWithStorageMetaZod.catchall(z5.any());
|
|
203
253
|
|
|
204
254
|
// src/types/schema/common/Chain.ts
|
|
205
|
-
import { toAddress as toAddress2 } from "@xylabs/hex";
|
|
206
|
-
import { AddressRegEx as AddressRegEx2 } from "@xyo-network/payload-wrapper";
|
|
255
|
+
import { AddressRegEx as AddressRegEx2, toAddress as toAddress2 } from "@xylabs/hex";
|
|
207
256
|
import { z as z6 } from "zod";
|
|
208
|
-
var
|
|
209
|
-
var ChainZod = z6.string().toLowerCase().regex(CompiledAddressRegEx2).transform((v) => toAddress2(v));
|
|
257
|
+
var ChainZod = z6.string().toLowerCase().regex(AddressRegEx2).transform((v) => toAddress2(v));
|
|
210
258
|
|
|
211
259
|
// src/types/schema/common/BlockBoundWitness.ts
|
|
212
260
|
var BlockNumberZod = z7.number().int().nonnegative();
|
|
@@ -217,7 +265,9 @@ var BlockBoundWitnessFieldsZod = z7.object({
|
|
|
217
265
|
protocol: z7.number().optional(),
|
|
218
266
|
step_hashes: z7.array(HexZod2).optional()
|
|
219
267
|
});
|
|
220
|
-
var BlockBoundWitnessMetaZod = z7.object({
|
|
268
|
+
var BlockBoundWitnessMetaZod = z7.object({
|
|
269
|
+
$epoch: z7.number()
|
|
270
|
+
});
|
|
221
271
|
var BlockBoundWitnessZod = UnsignedBoundWitnessZod.merge(StorageMetaZod.partial()).merge(BlockBoundWitnessFieldsZod).merge(BlockBoundWitnessMetaZod);
|
|
222
272
|
var BlockBoundWitnessWithStorageMetaZod = UnsignedBoundWitnessWithStorageMetaZod.merge(BlockBoundWitnessFieldsZod).merge(BlockBoundWitnessMetaZod);
|
|
223
273
|
var SignedBlockBoundWitnessZod = SignedBoundWitnessZod.merge(StorageMetaZod.partial()).merge(BlockBoundWitnessFieldsZod).merge(BlockBoundWitnessMetaZod);
|
|
@@ -255,11 +305,7 @@ import { z as z11 } from "zod";
|
|
|
255
305
|
import { z as z10 } from "zod";
|
|
256
306
|
|
|
257
307
|
// src/types/schema/common/TransactionFees.ts
|
|
258
|
-
import {
|
|
259
|
-
BigIntToJsonZod,
|
|
260
|
-
HexZod as HexZod3,
|
|
261
|
-
JsonToBigIntZod
|
|
262
|
-
} from "@xylabs/hex";
|
|
308
|
+
import { BigIntToJsonZod, HexZod as HexZod3, JsonToBigIntZod } from "@xylabs/hex";
|
|
263
309
|
import { asAttoXL1 } from "@xyo-network/xl1-protocol";
|
|
264
310
|
import { z as z9 } from "zod";
|
|
265
311
|
var AttoZod = z9.bigint();
|
|
@@ -290,12 +336,26 @@ var TransactionFeesBigIntToJsonZod = TransactionFeesBigIntZod.transform((val) =>
|
|
|
290
336
|
}));
|
|
291
337
|
|
|
292
338
|
// src/types/schema/common/TransactionBoundWitness.ts
|
|
293
|
-
var BlockStartZod = z10.object({
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
var
|
|
297
|
-
|
|
298
|
-
|
|
339
|
+
var BlockStartZod = z10.object({
|
|
340
|
+
nbf: BlockNumberZod
|
|
341
|
+
});
|
|
342
|
+
var BlockEndZod = z10.object({
|
|
343
|
+
exp: BlockNumberZod
|
|
344
|
+
});
|
|
345
|
+
var BlockDurationZod = z10.object({
|
|
346
|
+
nbf: BlockNumberZod,
|
|
347
|
+
exp: BlockNumberZod
|
|
348
|
+
});
|
|
349
|
+
var BlockScriptsZod = z10.object({
|
|
350
|
+
script: z10.array(z10.string()).optional()
|
|
351
|
+
});
|
|
352
|
+
var WithTransactionFeesZod = z10.object({
|
|
353
|
+
fees: TransactionFeesHexZod
|
|
354
|
+
});
|
|
355
|
+
var TransactionBoundWitnessFields = z10.object({
|
|
356
|
+
chain: ChainZod,
|
|
357
|
+
from: ChainZod
|
|
358
|
+
});
|
|
299
359
|
var TransactionBoundWitnessZod = UnsignedBoundWitnessZod.merge(StorageMetaZod.partial()).merge(BlockDurationZod).merge(WithTransactionFeesZod).merge(TransactionBoundWitnessFields).merge(BlockScriptsZod);
|
|
300
360
|
var SignedTransactionBoundWitnessZod = SignedBoundWitnessZod.merge(StorageMetaZod.partial()).merge(BlockDurationZod).merge(WithTransactionFeesZod).merge(TransactionBoundWitnessFields).merge(BlockScriptsZod.partial());
|
|
301
361
|
|
|
@@ -312,17 +372,11 @@ var SignedHydratedTransactionZod = z11.tuple([
|
|
|
312
372
|
SignedTransactionBoundWitnessZod,
|
|
313
373
|
z11.array(PayloadZod)
|
|
314
374
|
]);
|
|
315
|
-
var SignedHydratedTransactionToJsonZod = SignedHydratedTransactionZod.transform(([
|
|
316
|
-
tx,
|
|
317
|
-
payloads
|
|
318
|
-
]) => asSignedHydratedTransaction([
|
|
375
|
+
var SignedHydratedTransactionToJsonZod = SignedHydratedTransactionZod.transform(([tx, payloads]) => asSignedHydratedTransaction([
|
|
319
376
|
tx,
|
|
320
377
|
payloads.map((payload) => payload)
|
|
321
378
|
]));
|
|
322
|
-
var JsonToSignedHydratedTransactionZod = SignedHydratedTransactionZod.transform(([
|
|
323
|
-
tx,
|
|
324
|
-
payloads
|
|
325
|
-
]) => [
|
|
379
|
+
var JsonToSignedHydratedTransactionZod = SignedHydratedTransactionZod.transform(([tx, payloads]) => [
|
|
326
380
|
asSignedHydratedTransaction(tx),
|
|
327
381
|
payloads.map((p) => asAnyPayload(p))
|
|
328
382
|
]);
|
|
@@ -336,7 +390,6 @@ var JsonValueZod = z12.lazy(() => z12.union([
|
|
|
336
390
|
z12.null(),
|
|
337
391
|
z12.array(JsonValueZod),
|
|
338
392
|
z12.record(z12.string(), JsonValueZod)
|
|
339
|
-
// object with string keys and JSON values
|
|
340
393
|
]));
|
|
341
394
|
var JsonObjectZod = z12.record(z12.string(), JsonValueZod);
|
|
342
395
|
|
|
@@ -376,8 +429,12 @@ import { z as z14 } from "zod";
|
|
|
376
429
|
var XyoRunnerRpcSchemas = {
|
|
377
430
|
xyoRunner_broadcastTransaction: {
|
|
378
431
|
params: {
|
|
379
|
-
to: z14.tuple([
|
|
380
|
-
|
|
432
|
+
to: z14.tuple([
|
|
433
|
+
SignedHydratedTransactionZod
|
|
434
|
+
]),
|
|
435
|
+
from: z14.tuple([
|
|
436
|
+
SignedHydratedTransactionZod
|
|
437
|
+
])
|
|
381
438
|
},
|
|
382
439
|
result: {
|
|
383
440
|
to: HashToJsonZod2,
|
|
@@ -428,8 +485,12 @@ var XyoSignerRpcSchemas = {
|
|
|
428
485
|
},
|
|
429
486
|
xyoSigner_signTransaction: {
|
|
430
487
|
params: {
|
|
431
|
-
to: z15.tuple([
|
|
432
|
-
|
|
488
|
+
to: z15.tuple([
|
|
489
|
+
UnsignedHydratedTransactionZod
|
|
490
|
+
]),
|
|
491
|
+
from: z15.tuple([
|
|
492
|
+
UnsignedHydratedTransactionZod
|
|
493
|
+
])
|
|
433
494
|
},
|
|
434
495
|
result: {
|
|
435
496
|
to: SignedHydratedTransactionZod,
|
|
@@ -439,26 +500,38 @@ var XyoSignerRpcSchemas = {
|
|
|
439
500
|
};
|
|
440
501
|
|
|
441
502
|
// src/types/schema/XyoViewerRpcSchemas.ts
|
|
442
|
-
import {
|
|
443
|
-
BigIntToJsonZod as BigIntToJsonZod2,
|
|
444
|
-
HashToJsonZod as HashToJsonZod3,
|
|
445
|
-
HashZod as HashZod2,
|
|
446
|
-
JsonToBigIntZod as JsonToBigIntZod2,
|
|
447
|
-
JsonToHashZod as JsonToHashZod2
|
|
448
|
-
} from "@xylabs/hex";
|
|
503
|
+
import { BigIntToJsonZod as BigIntToJsonZod2, HashToJsonZod as HashToJsonZod3, HashZod as HashZod2, JsonToBigIntZod as JsonToBigIntZod2, JsonToHashZod as JsonToHashZod2 } from "@xylabs/hex";
|
|
449
504
|
import { z as z16 } from "zod";
|
|
450
505
|
var XyoViewerRpcSchemas = {
|
|
451
506
|
xyoViewer_accountBalance: {
|
|
452
507
|
params: {
|
|
453
508
|
to: z16.union([
|
|
454
|
-
z16.tuple([
|
|
455
|
-
|
|
456
|
-
|
|
509
|
+
z16.tuple([
|
|
510
|
+
AddressZod
|
|
511
|
+
]),
|
|
512
|
+
z16.tuple([
|
|
513
|
+
AddressZod,
|
|
514
|
+
z16.number()
|
|
515
|
+
]),
|
|
516
|
+
z16.tuple([
|
|
517
|
+
AddressZod,
|
|
518
|
+
z16.number(),
|
|
519
|
+
z16.boolean()
|
|
520
|
+
])
|
|
457
521
|
]),
|
|
458
522
|
from: z16.union([
|
|
459
|
-
z16.tuple([
|
|
460
|
-
|
|
461
|
-
|
|
523
|
+
z16.tuple([
|
|
524
|
+
AddressZod
|
|
525
|
+
]),
|
|
526
|
+
z16.tuple([
|
|
527
|
+
AddressZod,
|
|
528
|
+
z16.number()
|
|
529
|
+
]),
|
|
530
|
+
z16.tuple([
|
|
531
|
+
AddressZod,
|
|
532
|
+
z16.number(),
|
|
533
|
+
z16.boolean()
|
|
534
|
+
])
|
|
462
535
|
])
|
|
463
536
|
},
|
|
464
537
|
result: {
|
|
@@ -469,25 +542,55 @@ var XyoViewerRpcSchemas = {
|
|
|
469
542
|
xyoViewer_accountHistory: {
|
|
470
543
|
params: {
|
|
471
544
|
to: z16.union([
|
|
472
|
-
z16.tuple([
|
|
473
|
-
|
|
474
|
-
|
|
545
|
+
z16.tuple([
|
|
546
|
+
AddressZod
|
|
547
|
+
]),
|
|
548
|
+
z16.tuple([
|
|
549
|
+
AddressZod,
|
|
550
|
+
z16.number()
|
|
551
|
+
]),
|
|
552
|
+
z16.tuple([
|
|
553
|
+
AddressZod,
|
|
554
|
+
z16.number(),
|
|
555
|
+
z16.boolean()
|
|
556
|
+
])
|
|
475
557
|
]),
|
|
476
558
|
from: z16.union([
|
|
477
|
-
z16.tuple([
|
|
478
|
-
|
|
479
|
-
|
|
559
|
+
z16.tuple([
|
|
560
|
+
AddressZod
|
|
561
|
+
]),
|
|
562
|
+
z16.tuple([
|
|
563
|
+
AddressZod,
|
|
564
|
+
z16.number()
|
|
565
|
+
]),
|
|
566
|
+
z16.tuple([
|
|
567
|
+
AddressZod,
|
|
568
|
+
z16.number(),
|
|
569
|
+
z16.boolean()
|
|
570
|
+
])
|
|
480
571
|
])
|
|
481
572
|
},
|
|
482
573
|
result: {
|
|
483
|
-
to: z16.array(z16.tuple([
|
|
484
|
-
|
|
574
|
+
to: z16.array(z16.tuple([
|
|
575
|
+
HashZod2,
|
|
576
|
+
HashZod2,
|
|
577
|
+
PayloadZod
|
|
578
|
+
])),
|
|
579
|
+
from: z16.array(z16.tuple([
|
|
580
|
+
HashZod2,
|
|
581
|
+
HashZod2,
|
|
582
|
+
PayloadZod
|
|
583
|
+
]))
|
|
485
584
|
}
|
|
486
585
|
},
|
|
487
586
|
xyoViewer_blockByHash: {
|
|
488
587
|
params: {
|
|
489
|
-
to: z16.tuple([
|
|
490
|
-
|
|
588
|
+
to: z16.tuple([
|
|
589
|
+
HashToJsonZod3
|
|
590
|
+
]),
|
|
591
|
+
from: z16.tuple([
|
|
592
|
+
JsonToHashZod2
|
|
593
|
+
])
|
|
491
594
|
},
|
|
492
595
|
result: {
|
|
493
596
|
to: SignedHydratedBlockZod,
|
|
@@ -496,8 +599,12 @@ var XyoViewerRpcSchemas = {
|
|
|
496
599
|
},
|
|
497
600
|
xyoViewer_blockByNumber: {
|
|
498
601
|
params: {
|
|
499
|
-
to: z16.tuple([
|
|
500
|
-
|
|
602
|
+
to: z16.tuple([
|
|
603
|
+
z16.number()
|
|
604
|
+
]),
|
|
605
|
+
from: z16.tuple([
|
|
606
|
+
z16.number()
|
|
607
|
+
])
|
|
501
608
|
},
|
|
502
609
|
result: {
|
|
503
610
|
to: SignedHydratedBlockZod,
|
|
@@ -506,8 +613,14 @@ var XyoViewerRpcSchemas = {
|
|
|
506
613
|
},
|
|
507
614
|
xyoViewer_blocksByHash: {
|
|
508
615
|
params: {
|
|
509
|
-
to: z16.tuple([
|
|
510
|
-
|
|
616
|
+
to: z16.tuple([
|
|
617
|
+
HashZod2,
|
|
618
|
+
z16.number().optional()
|
|
619
|
+
]),
|
|
620
|
+
from: z16.tuple([
|
|
621
|
+
HashZod2,
|
|
622
|
+
z16.number().optional()
|
|
623
|
+
])
|
|
511
624
|
},
|
|
512
625
|
result: {
|
|
513
626
|
to: z16.array(SignedHydratedBlockZod),
|
|
@@ -556,8 +669,14 @@ var XyoViewerRpcSchemas = {
|
|
|
556
669
|
},
|
|
557
670
|
xyoViewer_transactionByBlockHashAndIndex: {
|
|
558
671
|
params: {
|
|
559
|
-
to: z16.tuple([
|
|
560
|
-
|
|
672
|
+
to: z16.tuple([
|
|
673
|
+
HashZod2,
|
|
674
|
+
z16.number()
|
|
675
|
+
]),
|
|
676
|
+
from: z16.tuple([
|
|
677
|
+
HashZod2,
|
|
678
|
+
z16.number()
|
|
679
|
+
])
|
|
561
680
|
},
|
|
562
681
|
result: {
|
|
563
682
|
to: SignedHydratedTransactionZod.nullable(),
|
|
@@ -566,8 +685,14 @@ var XyoViewerRpcSchemas = {
|
|
|
566
685
|
},
|
|
567
686
|
xyoViewer_transactionByBlockNumberAndIndex: {
|
|
568
687
|
params: {
|
|
569
|
-
to: z16.tuple([
|
|
570
|
-
|
|
688
|
+
to: z16.tuple([
|
|
689
|
+
z16.number(),
|
|
690
|
+
z16.number()
|
|
691
|
+
]),
|
|
692
|
+
from: z16.tuple([
|
|
693
|
+
z16.number(),
|
|
694
|
+
z16.number()
|
|
695
|
+
])
|
|
571
696
|
},
|
|
572
697
|
result: {
|
|
573
698
|
to: SignedHydratedTransactionZod.nullable(),
|
|
@@ -576,8 +701,12 @@ var XyoViewerRpcSchemas = {
|
|
|
576
701
|
},
|
|
577
702
|
xyoViewer_transactionByHash: {
|
|
578
703
|
params: {
|
|
579
|
-
to: z16.tuple([
|
|
580
|
-
|
|
704
|
+
to: z16.tuple([
|
|
705
|
+
HashZod2
|
|
706
|
+
]),
|
|
707
|
+
from: z16.tuple([
|
|
708
|
+
HashZod2
|
|
709
|
+
])
|
|
581
710
|
},
|
|
582
711
|
result: {
|
|
583
712
|
to: SignedHydratedTransactionZod.nullable(),
|
|
@@ -596,40 +725,55 @@ var AllRpcSchemas = {
|
|
|
596
725
|
|
|
597
726
|
// src/types/schema/createRequestSchema.ts
|
|
598
727
|
import { z as z17 } from "zod";
|
|
599
|
-
var createRequestSchema = (methodName, paramsSchema = z17.undefined()) => z17.object({
|
|
600
|
-
id: z17.union([
|
|
728
|
+
var createRequestSchema = /* @__PURE__ */ __name((methodName, paramsSchema = z17.undefined()) => z17.object({
|
|
729
|
+
id: z17.union([
|
|
730
|
+
z17.string(),
|
|
731
|
+
z17.number()
|
|
732
|
+
]),
|
|
601
733
|
jsonrpc: z17.literal(jsonrpc),
|
|
602
734
|
method: z17.literal(methodName),
|
|
603
735
|
params: paramsSchema
|
|
604
|
-
});
|
|
736
|
+
}), "createRequestSchema");
|
|
605
737
|
|
|
606
738
|
// src/types/schema/createResponseSchema.ts
|
|
607
739
|
import { z as z18 } from "zod";
|
|
608
|
-
var createResponseSchema = (resultSchema = z18.undefined()) => z18.object({
|
|
609
|
-
id: z18.union([
|
|
740
|
+
var createResponseSchema = /* @__PURE__ */ __name((resultSchema = z18.undefined()) => z18.object({
|
|
741
|
+
id: z18.union([
|
|
742
|
+
z18.string(),
|
|
743
|
+
z18.number()
|
|
744
|
+
]),
|
|
610
745
|
jsonrpc: z18.literal(jsonrpc),
|
|
611
746
|
result: resultSchema
|
|
612
|
-
});
|
|
747
|
+
}), "createResponseSchema");
|
|
613
748
|
|
|
614
749
|
// src/types/schema/XyoGatewayRpcSchemas.ts
|
|
615
750
|
import { z as z19 } from "zod";
|
|
616
751
|
var ChainConnectionZod = z19.object({
|
|
617
|
-
chainId: z19.union([
|
|
752
|
+
chainId: z19.union([
|
|
753
|
+
z19.string(),
|
|
754
|
+
z19.custom()
|
|
755
|
+
]).optional(),
|
|
618
756
|
name: z19.string(),
|
|
619
757
|
url: z19.string()
|
|
620
758
|
});
|
|
621
|
-
var CaveatTypesZod = z19.enum([
|
|
759
|
+
var CaveatTypesZod = z19.enum([
|
|
760
|
+
"chain",
|
|
761
|
+
"expiration",
|
|
762
|
+
"filteredResponse",
|
|
763
|
+
"rateLimit"
|
|
764
|
+
]);
|
|
622
765
|
var CaveatsZod = z19.object({
|
|
623
766
|
type: CaveatTypesZod,
|
|
624
767
|
value: z19.unknown()
|
|
625
|
-
// JsonValue is usually unknown, adjust if you have a stricter type
|
|
626
768
|
});
|
|
627
769
|
var PermissionZod = z19.object({
|
|
628
770
|
capability: z19.string(),
|
|
629
771
|
caveats: CaveatsZod.array().optional(),
|
|
630
772
|
invoker: z19.string()
|
|
631
773
|
});
|
|
632
|
-
var InvokerPermissionZod = PermissionZod.extend({
|
|
774
|
+
var InvokerPermissionZod = PermissionZod.extend({
|
|
775
|
+
date: z19.number().optional()
|
|
776
|
+
});
|
|
633
777
|
var XyoGatewayRpcSchemas = {
|
|
634
778
|
/*
|
|
635
779
|
xyoGateway_addConnection: {
|
|
@@ -695,12 +839,8 @@ var XyoGatewayRpcSchemas = {
|
|
|
695
839
|
*/
|
|
696
840
|
xyoGateway_submitTransaction: {
|
|
697
841
|
params: {
|
|
698
|
-
from: z19.array(
|
|
699
|
-
|
|
700
|
-
),
|
|
701
|
-
to: z19.array(
|
|
702
|
-
HydratedTransactionZod
|
|
703
|
-
)
|
|
842
|
+
from: z19.array(HydratedTransactionZod),
|
|
843
|
+
to: z19.array(HydratedTransactionZod)
|
|
704
844
|
},
|
|
705
845
|
result: {
|
|
706
846
|
from: BlockBoundWitnessZod,
|
|
@@ -711,6 +851,9 @@ var XyoGatewayRpcSchemas = {
|
|
|
711
851
|
|
|
712
852
|
// src/transport/HttpRpcTransport.ts
|
|
713
853
|
var HttpRpcTransport = class {
|
|
854
|
+
static {
|
|
855
|
+
__name(this, "HttpRpcTransport");
|
|
856
|
+
}
|
|
714
857
|
_rpcUrl;
|
|
715
858
|
_schemas;
|
|
716
859
|
constructor(rpcUrl, schemas) {
|
|
@@ -752,11 +895,14 @@ import { assertEx } from "@xylabs/assert";
|
|
|
752
895
|
import { isObject, isString } from "@xylabs/typeof";
|
|
753
896
|
import { v4 as v42 } from "uuid";
|
|
754
897
|
var MemoryRpcTransport = class {
|
|
898
|
+
static {
|
|
899
|
+
__name(this, "MemoryRpcTransport");
|
|
900
|
+
}
|
|
755
901
|
_rpcEngine;
|
|
756
902
|
_schemas;
|
|
757
903
|
requestSchemas = {};
|
|
758
904
|
responseSchemas = {};
|
|
759
|
-
constructor(rpcEngine, schemas
|
|
905
|
+
constructor(rpcEngine, schemas) {
|
|
760
906
|
this._rpcEngine = rpcEngine;
|
|
761
907
|
this._schemas = schemas;
|
|
762
908
|
}
|
|
@@ -786,37 +932,41 @@ var MemoryRpcTransport = class {
|
|
|
786
932
|
};
|
|
787
933
|
|
|
788
934
|
// src/transport/post-message/LegacyPostMessageRpcTransport.ts
|
|
789
|
-
import {
|
|
790
|
-
isJsonRpcError,
|
|
791
|
-
isJsonRpcSuccess
|
|
792
|
-
} from "@metamask/utils";
|
|
935
|
+
import { isJsonRpcError, isJsonRpcSuccess } from "@metamask/utils";
|
|
793
936
|
import { isDefined } from "@xylabs/typeof";
|
|
794
937
|
import { v4 as v43 } from "uuid";
|
|
795
938
|
|
|
796
939
|
// src/transport/post-message/helpers.ts
|
|
797
|
-
var isRpcError = (data) => {
|
|
940
|
+
var isRpcError = /* @__PURE__ */ __name((data) => {
|
|
798
941
|
return data && typeof data === "object" && "error" in data && data.error;
|
|
799
|
-
};
|
|
942
|
+
}, "isRpcError");
|
|
800
943
|
|
|
801
944
|
// src/transport/post-message/resolveData.ts
|
|
802
|
-
var hasMatchingId = (eventData, targetId) => {
|
|
803
|
-
return eventData?.id === targetId ? {
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
945
|
+
var hasMatchingId = /* @__PURE__ */ __name((eventData, targetId) => {
|
|
946
|
+
return eventData?.id === targetId ? {
|
|
947
|
+
legacyEventData: eventData
|
|
948
|
+
} : false;
|
|
949
|
+
}, "hasMatchingId");
|
|
950
|
+
var hasMatchingNestedId = /* @__PURE__ */ __name((eventData, targetId) => {
|
|
951
|
+
return eventData?.data?.id === targetId ? {
|
|
952
|
+
eventData: eventData.data
|
|
953
|
+
} : false;
|
|
954
|
+
}, "hasMatchingNestedId");
|
|
955
|
+
var resolvedEvent = /* @__PURE__ */ __name((event, targetId) => {
|
|
809
956
|
return hasMatchingId(event.data, targetId) || hasMatchingNestedId(event.data, targetId);
|
|
810
|
-
};
|
|
957
|
+
}, "resolvedEvent");
|
|
811
958
|
|
|
812
959
|
// src/transport/post-message/LegacyPostMessageRpcTransport.ts
|
|
813
|
-
var isValidBaseRpcEvent = (data) => {
|
|
960
|
+
var isValidBaseRpcEvent = /* @__PURE__ */ __name((data) => {
|
|
814
961
|
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");
|
|
815
|
-
};
|
|
816
|
-
var isRpcResponse = (data, targetId) => {
|
|
962
|
+
}, "isValidBaseRpcEvent");
|
|
963
|
+
var isRpcResponse = /* @__PURE__ */ __name((data, targetId) => {
|
|
817
964
|
return isValidBaseRpcEvent(data) && (isDefined(targetId) ? data.id === targetId : true) && "result" in data && Array.isArray(data.result);
|
|
818
|
-
};
|
|
965
|
+
}, "isRpcResponse");
|
|
819
966
|
var LegacyPostMessageRpcTransport = class {
|
|
967
|
+
static {
|
|
968
|
+
__name(this, "LegacyPostMessageRpcTransport");
|
|
969
|
+
}
|
|
820
970
|
destination;
|
|
821
971
|
schemas;
|
|
822
972
|
sessionId;
|
|
@@ -838,7 +988,7 @@ var LegacyPostMessageRpcTransport = class {
|
|
|
838
988
|
body.params = isDefined(params) && isDefined(schemas[method]) ? schemas[method].params.to.parse(params) : params;
|
|
839
989
|
return await new Promise((resolve, reject) => {
|
|
840
990
|
const id2 = body.id;
|
|
841
|
-
const handler = (event) => {
|
|
991
|
+
const handler = /* @__PURE__ */ __name((event) => {
|
|
842
992
|
if (event.origin !== globalThis.window.origin) return;
|
|
843
993
|
if (!isRpcResponse(event.data, id2)) return;
|
|
844
994
|
const data = resolvedEvent(event, id2);
|
|
@@ -863,39 +1013,37 @@ var LegacyPostMessageRpcTransport = class {
|
|
|
863
1013
|
}
|
|
864
1014
|
reject(new Error("Unexpected response format"));
|
|
865
1015
|
}
|
|
866
|
-
};
|
|
1016
|
+
}, "handler");
|
|
867
1017
|
globalThis.addEventListener("message", handler);
|
|
868
|
-
globalThis.postMessage(
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
},
|
|
874
|
-
globalThis.location.origin
|
|
875
|
-
);
|
|
1018
|
+
globalThis.postMessage({
|
|
1019
|
+
data: body,
|
|
1020
|
+
destination: this.destination,
|
|
1021
|
+
sessionId: this.sessionId
|
|
1022
|
+
}, globalThis.location.origin);
|
|
876
1023
|
});
|
|
877
1024
|
}
|
|
878
1025
|
};
|
|
879
1026
|
var PostMessageRpcTransport = LegacyPostMessageRpcTransport;
|
|
880
1027
|
|
|
881
1028
|
// src/transport/post-message/SessionEnvelope.ts
|
|
882
|
-
var buildSessionMessageRequest = (data, destination) => {
|
|
1029
|
+
var buildSessionMessageRequest = /* @__PURE__ */ __name((data, destination) => {
|
|
883
1030
|
const request = {
|
|
884
1031
|
data,
|
|
885
1032
|
destination,
|
|
886
1033
|
sessionId: globalThis.xyo.walletExtensionId() ?? ""
|
|
887
1034
|
};
|
|
888
1035
|
return request;
|
|
889
|
-
};
|
|
1036
|
+
}, "buildSessionMessageRequest");
|
|
890
1037
|
|
|
891
1038
|
// src/provider/datalake/AbstractXyoDataLake.ts
|
|
892
1039
|
import { ObjectHasher } from "@xyo-network/hash";
|
|
893
1040
|
import { PayloadBuilder } from "@xyo-network/payload-builder";
|
|
894
1041
|
import { isAnyPayload } from "@xyo-network/payload-model";
|
|
895
|
-
import {
|
|
896
|
-
isHashPayload
|
|
897
|
-
} from "@xyo-network/xl1-protocol";
|
|
1042
|
+
import { isHashPayload } from "@xyo-network/xl1-protocol";
|
|
898
1043
|
var AbstractXyoDataLake = class {
|
|
1044
|
+
static {
|
|
1045
|
+
__name(this, "AbstractXyoDataLake");
|
|
1046
|
+
}
|
|
899
1047
|
async fetch(hashes, maxDepth = 10) {
|
|
900
1048
|
const results = await this.get(hashes);
|
|
901
1049
|
if (maxDepth > 0) {
|
|
@@ -904,17 +1052,32 @@ var AbstractXyoDataLake = class {
|
|
|
904
1052
|
const found = await this.fetch(hashPayloads.map((item) => item.hash), maxDepth - 1);
|
|
905
1053
|
const foundHashes = await Promise.all(found.map(async (item) => isAnyPayload(item) ? await PayloadBuilder.hash(item) : ObjectHasher.hashBytes(item)));
|
|
906
1054
|
const notFound = hashPayloads.filter((item) => !foundHashes.includes(item.hash));
|
|
907
|
-
return [
|
|
1055
|
+
return [
|
|
1056
|
+
...otherPayloads,
|
|
1057
|
+
...found,
|
|
1058
|
+
...notFound
|
|
1059
|
+
];
|
|
908
1060
|
}
|
|
909
1061
|
return results;
|
|
910
1062
|
}
|
|
911
1063
|
async trace(hash) {
|
|
912
|
-
const [result] = await this.get([
|
|
1064
|
+
const [result] = await this.get([
|
|
1065
|
+
hash
|
|
1066
|
+
]);
|
|
913
1067
|
if (isHashPayload(result)) {
|
|
914
1068
|
const [payload, route] = await this.trace(result.hash);
|
|
915
|
-
return [
|
|
1069
|
+
return [
|
|
1070
|
+
payload,
|
|
1071
|
+
[
|
|
1072
|
+
result,
|
|
1073
|
+
...route
|
|
1074
|
+
]
|
|
1075
|
+
];
|
|
916
1076
|
}
|
|
917
|
-
return [
|
|
1077
|
+
return [
|
|
1078
|
+
result,
|
|
1079
|
+
[]
|
|
1080
|
+
];
|
|
918
1081
|
}
|
|
919
1082
|
};
|
|
920
1083
|
|
|
@@ -922,6 +1085,9 @@ var AbstractXyoDataLake = class {
|
|
|
922
1085
|
import { assertEx as assertEx2 } from "@xylabs/assert";
|
|
923
1086
|
import { isAnyPayload as isAnyPayload2 } from "@xyo-network/payload-model";
|
|
924
1087
|
var ArchivistXyoDataLake = class extends AbstractXyoDataLake {
|
|
1088
|
+
static {
|
|
1089
|
+
__name(this, "ArchivistXyoDataLake");
|
|
1090
|
+
}
|
|
925
1091
|
_archivist;
|
|
926
1092
|
constructor(archivist) {
|
|
927
1093
|
super();
|
|
@@ -946,6 +1112,9 @@ import { isAnyPayload as isAnyPayload3 } from "@xyo-network/payload-model";
|
|
|
946
1112
|
import { isHashPayload as isHashPayload2 } from "@xyo-network/xl1-protocol";
|
|
947
1113
|
import { Axios } from "axios";
|
|
948
1114
|
var HttpXyoDataLake = class extends AbstractXyoDataLake {
|
|
1115
|
+
static {
|
|
1116
|
+
__name(this, "HttpXyoDataLake");
|
|
1117
|
+
}
|
|
949
1118
|
_axiosGet;
|
|
950
1119
|
_axiosInsertBlob;
|
|
951
1120
|
_axiosInsertJson;
|
|
@@ -953,9 +1122,23 @@ var HttpXyoDataLake = class extends AbstractXyoDataLake {
|
|
|
953
1122
|
constructor(endpoint) {
|
|
954
1123
|
super();
|
|
955
1124
|
this._endpoint = endpoint;
|
|
956
|
-
this._axiosInsertJson = new AxiosJson2({
|
|
957
|
-
|
|
958
|
-
|
|
1125
|
+
this._axiosInsertJson = new AxiosJson2({
|
|
1126
|
+
baseURL: endpoint
|
|
1127
|
+
});
|
|
1128
|
+
this._axiosInsertBlob = new Axios({
|
|
1129
|
+
baseURL: endpoint,
|
|
1130
|
+
headers: {
|
|
1131
|
+
"Content-Type": "application/octet-stream",
|
|
1132
|
+
"Accept": "application/octet-stream"
|
|
1133
|
+
}
|
|
1134
|
+
});
|
|
1135
|
+
this._axiosGet = new Axios({
|
|
1136
|
+
baseURL: endpoint,
|
|
1137
|
+
headers: {
|
|
1138
|
+
"Content-Type": "application/json",
|
|
1139
|
+
"Accept": "application/octet-stream, application/json"
|
|
1140
|
+
}
|
|
1141
|
+
});
|
|
959
1142
|
}
|
|
960
1143
|
get endpoint() {
|
|
961
1144
|
return this._endpoint;
|
|
@@ -1031,12 +1214,17 @@ var HttpXyoDataLake = class extends AbstractXyoDataLake {
|
|
|
1031
1214
|
|
|
1032
1215
|
// src/provider/runner/JsonRpcXyoRunner.ts
|
|
1033
1216
|
var JsonRpcXyoRunner = class {
|
|
1217
|
+
static {
|
|
1218
|
+
__name(this, "JsonRpcXyoRunner");
|
|
1219
|
+
}
|
|
1034
1220
|
transport;
|
|
1035
1221
|
constructor(transport) {
|
|
1036
1222
|
this.transport = transport;
|
|
1037
1223
|
}
|
|
1038
1224
|
async broadcastTransaction(transaction) {
|
|
1039
|
-
return await this.transport.sendRequest("xyoRunner_broadcastTransaction", [
|
|
1225
|
+
return await this.transport.sendRequest("xyoRunner_broadcastTransaction", [
|
|
1226
|
+
transaction
|
|
1227
|
+
]);
|
|
1040
1228
|
}
|
|
1041
1229
|
};
|
|
1042
1230
|
|
|
@@ -1045,6 +1233,9 @@ import { MemoryArchivist } from "@xyo-network/archivist-memory";
|
|
|
1045
1233
|
import { PayloadBuilder as PayloadBuilder2 } from "@xyo-network/payload-builder";
|
|
1046
1234
|
import { flattenHydratedTransaction } from "@xyo-network/xl1-protocol-sdk";
|
|
1047
1235
|
var MemoryXyoRunner = class {
|
|
1236
|
+
static {
|
|
1237
|
+
__name(this, "MemoryXyoRunner");
|
|
1238
|
+
}
|
|
1048
1239
|
_archivist;
|
|
1049
1240
|
async broadcastTransaction(transaction) {
|
|
1050
1241
|
const archivist = await this.getArchivist();
|
|
@@ -1053,7 +1244,9 @@ var MemoryXyoRunner = class {
|
|
|
1053
1244
|
}
|
|
1054
1245
|
async getArchivist() {
|
|
1055
1246
|
if (!this._archivist) {
|
|
1056
|
-
this._archivist = await MemoryArchivist.create({
|
|
1247
|
+
this._archivist = await MemoryArchivist.create({
|
|
1248
|
+
account: "random"
|
|
1249
|
+
});
|
|
1057
1250
|
}
|
|
1058
1251
|
return this._archivist;
|
|
1059
1252
|
}
|
|
@@ -1066,6 +1259,9 @@ import { PayloadBuilder as PayloadBuilder3 } from "@xyo-network/payload-builder"
|
|
|
1066
1259
|
import { PayloadBundleSchema } from "@xyo-network/payload-model";
|
|
1067
1260
|
import { flattenHydratedTransaction as flattenHydratedTransaction2 } from "@xyo-network/xl1-protocol-sdk";
|
|
1068
1261
|
var NodeXyoRunner = class {
|
|
1262
|
+
static {
|
|
1263
|
+
__name(this, "NodeXyoRunner");
|
|
1264
|
+
}
|
|
1069
1265
|
// TODO: Make configurable with defaults
|
|
1070
1266
|
node;
|
|
1071
1267
|
pendingArchivistPath = "XYOChain:Pending:PendingTransactions";
|
|
@@ -1082,22 +1278,27 @@ var NodeXyoRunner = class {
|
|
|
1082
1278
|
payloads: flattened,
|
|
1083
1279
|
root: txHash
|
|
1084
1280
|
};
|
|
1085
|
-
await pendingArchivist.insert([
|
|
1281
|
+
await pendingArchivist.insert([
|
|
1282
|
+
payloadBundle
|
|
1283
|
+
]);
|
|
1086
1284
|
return txHash;
|
|
1087
1285
|
}
|
|
1088
|
-
getArchivist = async (identifier) => {
|
|
1286
|
+
getArchivist = /* @__PURE__ */ __name(async (identifier) => {
|
|
1089
1287
|
const archivist = await this.node.resolve(identifier);
|
|
1090
1288
|
return assertEx4(asArchivistInstance(archivist), () => `Error: Could not resolve ${identifier} to an archivist instance`);
|
|
1091
|
-
};
|
|
1092
|
-
getPendingArchivist = async () => {
|
|
1289
|
+
}, "getArchivist");
|
|
1290
|
+
getPendingArchivist = /* @__PURE__ */ __name(async () => {
|
|
1093
1291
|
if (this._pendingArchivist) return this._pendingArchivist;
|
|
1094
1292
|
this._pendingArchivist = await this.getArchivist(this.pendingArchivistPath);
|
|
1095
1293
|
return assertEx4(this._pendingArchivist, () => `Error: Could not resolve pending archivist at ${this.pendingArchivistPath}`);
|
|
1096
|
-
};
|
|
1294
|
+
}, "getPendingArchivist");
|
|
1097
1295
|
};
|
|
1098
1296
|
|
|
1099
1297
|
// src/provider/signer/JsonRpcXyoSigner.ts
|
|
1100
1298
|
var RpcXyoSigner = class {
|
|
1299
|
+
static {
|
|
1300
|
+
__name(this, "RpcXyoSigner");
|
|
1301
|
+
}
|
|
1101
1302
|
transport;
|
|
1102
1303
|
constructor(transport) {
|
|
1103
1304
|
this.transport = transport;
|
|
@@ -1118,16 +1319,24 @@ var RpcXyoSigner = class {
|
|
|
1118
1319
|
return ret;
|
|
1119
1320
|
}
|
|
1120
1321
|
async signTransaction(tx) {
|
|
1121
|
-
const ret = await this.transport.sendRequest("xyoSigner_signTransaction", [
|
|
1322
|
+
const ret = await this.transport.sendRequest("xyoSigner_signTransaction", [
|
|
1323
|
+
tx
|
|
1324
|
+
]);
|
|
1122
1325
|
return ret;
|
|
1123
1326
|
}
|
|
1124
1327
|
};
|
|
1125
1328
|
var JsonRpcXyoSigner = class extends RpcXyoSigner {
|
|
1329
|
+
static {
|
|
1330
|
+
__name(this, "JsonRpcXyoSigner");
|
|
1331
|
+
}
|
|
1126
1332
|
};
|
|
1127
1333
|
|
|
1128
1334
|
// src/provider/signer/MemoryXyoSigner.ts
|
|
1129
1335
|
import { buildTransaction, signTransaction } from "@xyo-network/xl1-protocol-sdk";
|
|
1130
1336
|
var MemoryXyoSigner = class {
|
|
1337
|
+
static {
|
|
1338
|
+
__name(this, "MemoryXyoSigner");
|
|
1339
|
+
}
|
|
1131
1340
|
_account;
|
|
1132
1341
|
constructor(account) {
|
|
1133
1342
|
this._account = account;
|
|
@@ -1137,44 +1346,52 @@ var MemoryXyoSigner = class {
|
|
|
1137
1346
|
}
|
|
1138
1347
|
async createSignedTransaction(chain, elevatedPayloads, additionalPayloads, nbf, exp, fees, from) {
|
|
1139
1348
|
const fromAddress = from ?? this._account.address;
|
|
1140
|
-
const transaction = await buildTransaction(
|
|
1141
|
-
chain,
|
|
1142
|
-
elevatedPayloads,
|
|
1143
|
-
additionalPayloads,
|
|
1144
|
-
this._account,
|
|
1145
|
-
nbf,
|
|
1146
|
-
exp,
|
|
1147
|
-
fromAddress,
|
|
1148
|
-
fees
|
|
1149
|
-
);
|
|
1349
|
+
const transaction = await buildTransaction(chain, elevatedPayloads, additionalPayloads, this._account, nbf, exp, fromAddress, fees);
|
|
1150
1350
|
return transaction[0];
|
|
1151
1351
|
}
|
|
1152
1352
|
async signTransaction(tx) {
|
|
1153
1353
|
const txBW = await signTransaction(tx[0], this._account);
|
|
1154
|
-
return [
|
|
1354
|
+
return [
|
|
1355
|
+
txBW,
|
|
1356
|
+
tx[1]
|
|
1357
|
+
];
|
|
1155
1358
|
}
|
|
1156
1359
|
};
|
|
1157
1360
|
|
|
1158
1361
|
// src/provider/viewer/JsonRpcXyoViewer.ts
|
|
1159
1362
|
var JsonRpcXyoViewer = class {
|
|
1363
|
+
static {
|
|
1364
|
+
__name(this, "JsonRpcXyoViewer");
|
|
1365
|
+
}
|
|
1160
1366
|
transport;
|
|
1161
1367
|
constructor(transport) {
|
|
1162
1368
|
this.transport = transport;
|
|
1163
1369
|
}
|
|
1164
1370
|
async accountBalance(address) {
|
|
1165
|
-
return await this.transport.sendRequest("xyoViewer_accountBalance", [
|
|
1371
|
+
return await this.transport.sendRequest("xyoViewer_accountBalance", [
|
|
1372
|
+
address
|
|
1373
|
+
]);
|
|
1166
1374
|
}
|
|
1167
1375
|
async accountHistory(address) {
|
|
1168
|
-
return await this.transport.sendRequest("xyoViewer_accountHistory", [
|
|
1376
|
+
return await this.transport.sendRequest("xyoViewer_accountHistory", [
|
|
1377
|
+
address
|
|
1378
|
+
]);
|
|
1169
1379
|
}
|
|
1170
1380
|
async blockByHash(hash) {
|
|
1171
|
-
return await this.transport.sendRequest("xyoViewer_blockByHash", [
|
|
1381
|
+
return await this.transport.sendRequest("xyoViewer_blockByHash", [
|
|
1382
|
+
hash
|
|
1383
|
+
]);
|
|
1172
1384
|
}
|
|
1173
1385
|
async blockByNumber(blockNumber) {
|
|
1174
|
-
return await this.transport.sendRequest("xyoViewer_blockByNumber", [
|
|
1386
|
+
return await this.transport.sendRequest("xyoViewer_blockByNumber", [
|
|
1387
|
+
blockNumber
|
|
1388
|
+
]);
|
|
1175
1389
|
}
|
|
1176
1390
|
async blocksByHash(hash, limit) {
|
|
1177
|
-
return await this.transport.sendRequest("xyoViewer_blocksByHash", [
|
|
1391
|
+
return await this.transport.sendRequest("xyoViewer_blocksByHash", [
|
|
1392
|
+
hash,
|
|
1393
|
+
limit
|
|
1394
|
+
]);
|
|
1178
1395
|
}
|
|
1179
1396
|
async chainId() {
|
|
1180
1397
|
return await this.transport.sendRequest("xyoViewer_chainId");
|
|
@@ -1189,13 +1406,21 @@ var JsonRpcXyoViewer = class {
|
|
|
1189
1406
|
return await this.transport.sendRequest("xyoViewer_currentBlockNumber");
|
|
1190
1407
|
}
|
|
1191
1408
|
async transactionByBlockHashAndIndex(blockHash, transactionIndex) {
|
|
1192
|
-
return await this.transport.sendRequest("xyoViewer_transactionByBlockHashAndIndex", [
|
|
1409
|
+
return await this.transport.sendRequest("xyoViewer_transactionByBlockHashAndIndex", [
|
|
1410
|
+
blockHash,
|
|
1411
|
+
transactionIndex
|
|
1412
|
+
]);
|
|
1193
1413
|
}
|
|
1194
1414
|
async transactionByBlockNumberAndIndex(blockNumber, transactionIndex) {
|
|
1195
|
-
return await this.transport.sendRequest("xyoViewer_transactionByBlockNumberAndIndex", [
|
|
1415
|
+
return await this.transport.sendRequest("xyoViewer_transactionByBlockNumberAndIndex", [
|
|
1416
|
+
blockNumber,
|
|
1417
|
+
transactionIndex
|
|
1418
|
+
]);
|
|
1196
1419
|
}
|
|
1197
1420
|
async transactionByHash(transactionHash) {
|
|
1198
|
-
return await this.transport.sendRequest("xyoViewer_transactionByHash", [
|
|
1421
|
+
return await this.transport.sendRequest("xyoViewer_transactionByHash", [
|
|
1422
|
+
transactionHash
|
|
1423
|
+
]);
|
|
1199
1424
|
}
|
|
1200
1425
|
};
|
|
1201
1426
|
|
|
@@ -1206,6 +1431,9 @@ import { isAnyPayload as isAnyPayload4 } from "@xyo-network/payload-model";
|
|
|
1206
1431
|
import { defaultTransactionFees, isDataLakeProvider } from "@xyo-network/xl1-protocol";
|
|
1207
1432
|
import { HydratedTransactionWrapper } from "@xyo-network/xl1-wrappers";
|
|
1208
1433
|
var XyoConnection = class {
|
|
1434
|
+
static {
|
|
1435
|
+
__name(this, "XyoConnection");
|
|
1436
|
+
}
|
|
1209
1437
|
_network;
|
|
1210
1438
|
_runner;
|
|
1211
1439
|
_signer;
|
|
@@ -1245,13 +1473,7 @@ var XyoConnection = class {
|
|
|
1245
1473
|
}))[0];
|
|
1246
1474
|
}
|
|
1247
1475
|
/** @deprecated use addPayloadsToChain from gateway instead */
|
|
1248
|
-
async submitTransaction(elevatedPayloads, additionalPayloads, {
|
|
1249
|
-
chain,
|
|
1250
|
-
exp,
|
|
1251
|
-
fees,
|
|
1252
|
-
from,
|
|
1253
|
-
nbf
|
|
1254
|
-
} = {}) {
|
|
1476
|
+
async submitTransaction(elevatedPayloads, additionalPayloads, { chain, exp, fees, from, nbf } = {}) {
|
|
1255
1477
|
const viewer = assertEx5(this.viewer, () => "No viewer available");
|
|
1256
1478
|
const signer = assertEx5(this.signer, () => "No signer available");
|
|
1257
1479
|
const runner = assertEx5(this.runner, () => "No runner available");
|
|
@@ -1263,15 +1485,7 @@ var XyoConnection = class {
|
|
|
1263
1485
|
const feesResolved = fees ?? defaultTransactionFees;
|
|
1264
1486
|
const fromResolved = from ?? await signer.address();
|
|
1265
1487
|
if (fromResolved === void 0) throw new Error("Failed to determine from address");
|
|
1266
|
-
const signedTransaction = assertEx5(await signer.createSignedTransaction(
|
|
1267
|
-
chainResolved,
|
|
1268
|
-
elevatedPayloads,
|
|
1269
|
-
additionalPayloads,
|
|
1270
|
-
nbfResolved,
|
|
1271
|
-
expResolved,
|
|
1272
|
-
feesResolved,
|
|
1273
|
-
fromResolved
|
|
1274
|
-
), () => "Failed to create transaction");
|
|
1488
|
+
const signedTransaction = assertEx5(await signer.createSignedTransaction(chainResolved, elevatedPayloads, additionalPayloads, nbfResolved, expResolved, feesResolved, fromResolved), () => "Failed to create transaction");
|
|
1275
1489
|
const hydratedTransaction = [
|
|
1276
1490
|
await PayloadBuilder4.addStorageMeta(signedTransaction),
|
|
1277
1491
|
await PayloadBuilder4.addStorageMeta(elevatedPayloads)
|
|
@@ -1287,14 +1501,16 @@ var XyoConnection = class {
|
|
|
1287
1501
|
|
|
1288
1502
|
// src/provider/connection/HttpRpcXyoConnection.ts
|
|
1289
1503
|
var HttpRpcXyoConnection = class extends XyoConnection {
|
|
1504
|
+
static {
|
|
1505
|
+
__name(this, "HttpRpcXyoConnection");
|
|
1506
|
+
}
|
|
1290
1507
|
constructor(params) {
|
|
1291
|
-
const {
|
|
1292
|
-
account,
|
|
1293
|
-
endpoint,
|
|
1294
|
-
storage: storageParam
|
|
1295
|
-
} = params;
|
|
1508
|
+
const { account, endpoint, storage: storageParam } = params;
|
|
1296
1509
|
const signer = isDefined3(account) ? new MemoryXyoSigner(account) : void 0;
|
|
1297
|
-
const transport = new HttpRpcTransport(endpoint, {
|
|
1510
|
+
const transport = new HttpRpcTransport(endpoint, {
|
|
1511
|
+
...XyoRunnerRpcSchemas,
|
|
1512
|
+
...XyoViewerRpcSchemas
|
|
1513
|
+
});
|
|
1298
1514
|
const runner = new JsonRpcXyoRunner(transport);
|
|
1299
1515
|
const viewer = new JsonRpcXyoViewer(transport);
|
|
1300
1516
|
const storage = isDataLakeProvider2(storageParam) ? storageParam : isString2(storageParam) ? new HttpXyoDataLake(storageParam) : void 0;
|
|
@@ -1307,6 +1523,9 @@ var HttpRpcXyoConnection = class extends XyoConnection {
|
|
|
1307
1523
|
}
|
|
1308
1524
|
};
|
|
1309
1525
|
var RpcXyoConnection = class extends HttpRpcXyoConnection {
|
|
1526
|
+
static {
|
|
1527
|
+
__name(this, "RpcXyoConnection");
|
|
1528
|
+
}
|
|
1310
1529
|
};
|
|
1311
1530
|
|
|
1312
1531
|
// src/provider/gateway/Abstract.ts
|
|
@@ -1314,6 +1533,9 @@ import { assertEx as assertEx6 } from "@xylabs/assert";
|
|
|
1314
1533
|
import { PayloadBuilder as PayloadBuilder5 } from "@xyo-network/payload-builder";
|
|
1315
1534
|
import { buildUnsignedTransaction } from "@xyo-network/xl1-protocol-sdk";
|
|
1316
1535
|
var AbstractXyoGateway = class {
|
|
1536
|
+
static {
|
|
1537
|
+
__name(this, "AbstractXyoGateway");
|
|
1538
|
+
}
|
|
1317
1539
|
async addPayloadsToChain(onChain, offChain) {
|
|
1318
1540
|
const connection = await this.connection();
|
|
1319
1541
|
const viewer = assertEx6(connection.viewer, () => "No viewer available on connection");
|
|
@@ -1322,19 +1544,20 @@ var AbstractXyoGateway = class {
|
|
|
1322
1544
|
const nbf = await viewer.currentBlockNumber();
|
|
1323
1545
|
const tx = await buildUnsignedTransaction(chainId, onChain, offChain, nbf, nbf + 1e3, await signer.address());
|
|
1324
1546
|
const hash = await this.addTransactionToChain(tx);
|
|
1325
|
-
return [
|
|
1547
|
+
return [
|
|
1548
|
+
hash,
|
|
1549
|
+
tx
|
|
1550
|
+
];
|
|
1326
1551
|
}
|
|
1327
1552
|
async addTransactionToChain(tx) {
|
|
1328
1553
|
const connection = await this.connection();
|
|
1329
1554
|
const signer = await this.signer();
|
|
1330
1555
|
const runner = assertEx6(connection.runner, () => "No runner available on connection");
|
|
1331
1556
|
const signedTx = await signer.signTransaction(tx);
|
|
1332
|
-
return await runner.broadcastTransaction(
|
|
1333
|
-
[
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
]
|
|
1337
|
-
);
|
|
1557
|
+
return await runner.broadcastTransaction([
|
|
1558
|
+
await PayloadBuilder5.addStorageMeta(signedTx[0]),
|
|
1559
|
+
await PayloadBuilder5.addStorageMeta(signedTx[1])
|
|
1560
|
+
]);
|
|
1338
1561
|
}
|
|
1339
1562
|
/** @deprecated use addPayloadsToChain instead */
|
|
1340
1563
|
async submitTransaction(elevatedPayloads, additionalPayloads) {
|
|
@@ -1347,6 +1570,9 @@ var AbstractXyoGateway = class {
|
|
|
1347
1570
|
|
|
1348
1571
|
// src/provider/gateway/MemoryXyoGateway.ts
|
|
1349
1572
|
var MemoryXyoGateway = class extends AbstractXyoGateway {
|
|
1573
|
+
static {
|
|
1574
|
+
__name(this, "MemoryXyoGateway");
|
|
1575
|
+
}
|
|
1350
1576
|
_connection;
|
|
1351
1577
|
_signer;
|
|
1352
1578
|
constructor(signer, connection) {
|
|
@@ -1401,6 +1627,9 @@ var StatusNetworks = {
|
|
|
1401
1627
|
|
|
1402
1628
|
// src/provider/network/MemoryXyoNetwork.ts
|
|
1403
1629
|
var MemoryXyoNetwork = class {
|
|
1630
|
+
static {
|
|
1631
|
+
__name(this, "MemoryXyoNetwork");
|
|
1632
|
+
}
|
|
1404
1633
|
_networkId;
|
|
1405
1634
|
constructor(networkId) {
|
|
1406
1635
|
this._networkId = networkId;
|