@xyo-network/xl1-rpc 1.8.4 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/neutral/index.mjs +459 -486
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/provider/client/MemoryXyoClient.d.ts +2 -2
- package/dist/neutral/provider/client/MemoryXyoClient.d.ts.map +1 -1
- package/dist/neutral/provider/{provider → connection}/HttpRpcXyoConnection.d.ts +2 -0
- package/dist/neutral/provider/connection/HttpRpcXyoConnection.d.ts.map +1 -0
- package/dist/neutral/provider/{provider → connection}/XyoConnection.d.ts +2 -0
- package/dist/neutral/provider/connection/XyoConnection.d.ts.map +1 -0
- package/dist/neutral/provider/connection/index.d.ts.map +1 -0
- package/dist/neutral/provider/connection/spec/XyoConnection.d.ts.map +1 -0
- package/dist/neutral/provider/datalake/AbstractXyoDataLake.d.ts +10 -0
- package/dist/neutral/provider/datalake/AbstractXyoDataLake.d.ts.map +1 -0
- package/dist/neutral/provider/datalake/ArchivistXyoDataLake.d.ts +11 -0
- package/dist/neutral/provider/datalake/ArchivistXyoDataLake.d.ts.map +1 -0
- package/dist/neutral/provider/datalake/HttpXyoDataLake.d.ts +20 -0
- package/dist/neutral/provider/datalake/HttpXyoDataLake.d.ts.map +1 -0
- package/dist/neutral/provider/datalake/index.d.ts +4 -0
- package/dist/neutral/provider/datalake/index.d.ts.map +1 -0
- package/dist/neutral/provider/gateway/Abstract.d.ts +13 -0
- package/dist/neutral/provider/gateway/Abstract.d.ts.map +1 -0
- package/dist/neutral/provider/gateway/MemoryXyoGateway.d.ts.map +1 -0
- package/dist/neutral/provider/gateway/index.d.ts.map +1 -0
- package/dist/neutral/provider/gateway/spec/MemoryXyoGateway.spec.d.ts.map +1 -0
- package/dist/neutral/provider/index.d.ts +3 -2
- package/dist/neutral/provider/index.d.ts.map +1 -1
- package/dist/neutral/provider/network/MemoryXyoNetwork.d.ts +3 -3
- package/dist/neutral/provider/network/MemoryXyoNetwork.d.ts.map +1 -1
- package/dist/neutral/provider/network/lib/StatusNetworks.d.ts +3 -3
- package/dist/neutral/provider/network/lib/StatusNetworks.d.ts.map +1 -1
- package/dist/neutral/types/XyoGatewayRpc.d.ts +1 -1
- package/dist/neutral/types/XyoGatewayRpc.d.ts.map +1 -1
- package/dist/neutral/types/schema/common/SequenceSchema.d.ts.map +1 -1
- package/dist/node/index-node.mjs +490 -515
- package/dist/node/index-node.mjs.map +1 -1
- package/dist/node/provider/client/MemoryXyoClient.d.ts +2 -2
- package/dist/node/provider/client/MemoryXyoClient.d.ts.map +1 -1
- package/dist/node/provider/{provider → connection}/HttpRpcXyoConnection.d.ts +2 -0
- package/dist/node/provider/connection/HttpRpcXyoConnection.d.ts.map +1 -0
- package/dist/node/provider/{provider → connection}/XyoConnection.d.ts +2 -0
- package/dist/node/provider/connection/XyoConnection.d.ts.map +1 -0
- package/dist/node/provider/connection/index.d.ts.map +1 -0
- package/dist/node/provider/connection/spec/XyoConnection.d.ts.map +1 -0
- package/dist/node/provider/datalake/AbstractXyoDataLake.d.ts +10 -0
- package/dist/node/provider/datalake/AbstractXyoDataLake.d.ts.map +1 -0
- package/dist/node/provider/datalake/ArchivistXyoDataLake.d.ts +11 -0
- package/dist/node/provider/datalake/ArchivistXyoDataLake.d.ts.map +1 -0
- package/dist/node/provider/datalake/HttpXyoDataLake.d.ts +20 -0
- package/dist/node/provider/datalake/HttpXyoDataLake.d.ts.map +1 -0
- package/dist/node/provider/datalake/index.d.ts +4 -0
- package/dist/node/provider/datalake/index.d.ts.map +1 -0
- package/dist/node/provider/gateway/Abstract.d.ts +13 -0
- package/dist/node/provider/gateway/Abstract.d.ts.map +1 -0
- package/dist/node/provider/gateway/MemoryXyoGateway.d.ts.map +1 -0
- package/dist/node/provider/gateway/index.d.ts.map +1 -0
- package/dist/node/provider/gateway/spec/MemoryXyoGateway.spec.d.ts.map +1 -0
- package/dist/node/provider/index.d.ts +3 -2
- package/dist/node/provider/index.d.ts.map +1 -1
- package/dist/node/provider/network/MemoryXyoNetwork.d.ts +3 -3
- package/dist/node/provider/network/MemoryXyoNetwork.d.ts.map +1 -1
- package/dist/node/provider/network/lib/StatusNetworks.d.ts +3 -3
- package/dist/node/provider/network/lib/StatusNetworks.d.ts.map +1 -1
- package/dist/node/types/XyoGatewayRpc.d.ts +1 -1
- package/dist/node/types/XyoGatewayRpc.d.ts.map +1 -1
- package/dist/node/types/schema/common/SequenceSchema.d.ts.map +1 -1
- package/package.json +37 -36
- package/src/provider/client/MemoryXyoClient.ts +3 -3
- package/src/provider/client/spec/MemoryXyoClient.spec.ts +17 -10
- package/src/provider/{provider → connection}/HttpRpcXyoConnection.ts +10 -3
- package/src/provider/{provider → connection}/XyoConnection.ts +2 -0
- package/src/provider/datalake/AbstractXyoDataLake.ts +38 -0
- package/src/provider/datalake/ArchivistXyoDataLake.ts +26 -0
- package/src/provider/datalake/HttpXyoDataLake.ts +105 -0
- package/src/provider/datalake/index.ts +3 -0
- package/src/provider/gateway/Abstract.ts +47 -0
- package/src/provider/{host → gateway}/spec/MemoryXyoGateway.spec.ts +7 -3
- package/src/provider/index.ts +3 -2
- package/src/provider/network/MemoryXyoNetwork.ts +4 -3
- package/src/provider/network/lib/StatusNetworks.ts +9 -9
- package/src/provider/signer/spec/RpcEngineXyoSigner.spec.ts +1 -1
- package/src/transport/post-message/SessionEnvelope.ts +1 -1
- package/src/types/XyoGatewayRpc.ts +2 -2
- package/src/types/schema/common/SequenceSchema.ts +2 -2
- package/dist/neutral/provider/host/Abstract.d.ts +0 -15
- package/dist/neutral/provider/host/Abstract.d.ts.map +0 -1
- package/dist/neutral/provider/host/MemoryXyoGateway.d.ts.map +0 -1
- package/dist/neutral/provider/host/index.d.ts.map +0 -1
- package/dist/neutral/provider/host/spec/MemoryXyoGateway.spec.d.ts.map +0 -1
- package/dist/neutral/provider/provider/HttpRpcXyoConnection.d.ts.map +0 -1
- package/dist/neutral/provider/provider/XyoConnection.d.ts.map +0 -1
- package/dist/neutral/provider/provider/index.d.ts.map +0 -1
- package/dist/neutral/provider/provider/spec/XyoConnection.d.ts.map +0 -1
- package/dist/node/provider/host/Abstract.d.ts +0 -15
- package/dist/node/provider/host/Abstract.d.ts.map +0 -1
- package/dist/node/provider/host/MemoryXyoGateway.d.ts.map +0 -1
- package/dist/node/provider/host/index.d.ts.map +0 -1
- package/dist/node/provider/host/spec/MemoryXyoGateway.spec.d.ts.map +0 -1
- package/dist/node/provider/provider/HttpRpcXyoConnection.d.ts.map +0 -1
- package/dist/node/provider/provider/XyoConnection.d.ts.map +0 -1
- package/dist/node/provider/provider/index.d.ts.map +0 -1
- package/dist/node/provider/provider/spec/XyoConnection.d.ts.map +0 -1
- package/src/provider/host/Abstract.ts +0 -42
- /package/dist/neutral/provider/{provider → connection}/index.d.ts +0 -0
- /package/dist/neutral/provider/{provider → connection}/spec/XyoConnection.d.ts +0 -0
- /package/dist/neutral/provider/{host → gateway}/MemoryXyoGateway.d.ts +0 -0
- /package/dist/neutral/provider/{host → gateway}/index.d.ts +0 -0
- /package/dist/neutral/provider/{host → gateway}/spec/MemoryXyoGateway.spec.d.ts +0 -0
- /package/dist/node/provider/{provider → connection}/index.d.ts +0 -0
- /package/dist/node/provider/{provider → connection}/spec/XyoConnection.d.ts +0 -0
- /package/dist/node/provider/{host → gateway}/MemoryXyoGateway.d.ts +0 -0
- /package/dist/node/provider/{host → gateway}/index.d.ts +0 -0
- /package/dist/node/provider/{host → gateway}/spec/MemoryXyoGateway.spec.d.ts +0 -0
- /package/src/provider/{provider → connection}/index.ts +0 -0
- /package/src/provider/{provider → connection}/spec/XyoConnection.ts +0 -0
- /package/src/provider/{host → gateway}/MemoryXyoGateway.ts +0 -0
- /package/src/provider/{host → gateway}/index.ts +0 -0
package/dist/neutral/index.mjs
CHANGED
|
@@ -1,101 +1,78 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
1
|
// src/engine/requestSchemas.ts
|
|
5
2
|
var requestSchemas = {};
|
|
6
3
|
|
|
7
4
|
// src/engine/rpcMethodHandlersFromRunner.ts
|
|
8
|
-
var rpcMethodHandlersFromRunner =
|
|
9
|
-
return {
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
}, "rpcMethodHandlersFromRunner");
|
|
5
|
+
var rpcMethodHandlersFromRunner = (runner) => {
|
|
6
|
+
return { xyoRunner_broadcastTransaction: (params) => runner.broadcastTransaction(...params ?? []) };
|
|
7
|
+
};
|
|
13
8
|
|
|
14
9
|
// src/engine/rpcMethodHandlersFromSigner.ts
|
|
15
|
-
var rpcMethodHandlersFromSigner =
|
|
10
|
+
var rpcMethodHandlersFromSigner = (signer) => {
|
|
16
11
|
return {
|
|
17
|
-
xyoSigner_address:
|
|
18
|
-
xyoSigner_createSignedTransaction:
|
|
19
|
-
xyoSigner_signTransaction:
|
|
12
|
+
xyoSigner_address: (params) => signer.address(...params ?? []),
|
|
13
|
+
xyoSigner_createSignedTransaction: (params) => signer.createSignedTransaction(...params ?? []),
|
|
14
|
+
xyoSigner_signTransaction: (params) => signer.signTransaction(...params ?? [])
|
|
20
15
|
};
|
|
21
|
-
}
|
|
16
|
+
};
|
|
22
17
|
|
|
23
18
|
// src/engine/rpcMethodHandlersFromViewer.ts
|
|
24
|
-
var rpcMethodHandlersFromViewer =
|
|
19
|
+
var rpcMethodHandlersFromViewer = (viewer) => {
|
|
25
20
|
return {
|
|
26
|
-
xyoViewer_accountBalance:
|
|
27
|
-
xyoViewer_accountHistory:
|
|
28
|
-
xyoViewer_blockByHash:
|
|
29
|
-
xyoViewer_blockByNumber:
|
|
30
|
-
xyoViewer_blocksByHash:
|
|
31
|
-
xyoViewer_chainId:
|
|
32
|
-
xyoViewer_currentBlock:
|
|
33
|
-
xyoViewer_currentBlockHash:
|
|
34
|
-
xyoViewer_currentBlockNumber:
|
|
35
|
-
xyoViewer_transactionByBlockHashAndIndex:
|
|
36
|
-
xyoViewer_transactionByBlockNumberAndIndex:
|
|
37
|
-
xyoViewer_transactionByHash:
|
|
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 ?? [])
|
|
38
33
|
};
|
|
39
|
-
}
|
|
34
|
+
};
|
|
40
35
|
|
|
41
36
|
// src/engine/rpcMethodHandlersFromProvider.ts
|
|
42
|
-
var rpcMethodHandlersFromProvider =
|
|
43
|
-
const {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
};
|
|
51
|
-
if (
|
|
52
|
-
...result,
|
|
53
|
-
...rpcMethodHandlersFromSigner(signer)
|
|
54
|
-
};
|
|
55
|
-
if (viewer) result = {
|
|
56
|
-
...result,
|
|
57
|
-
...rpcMethodHandlersFromViewer(viewer)
|
|
58
|
-
};
|
|
37
|
+
var rpcMethodHandlersFromProvider = (provider) => {
|
|
38
|
+
const {
|
|
39
|
+
runner,
|
|
40
|
+
signer,
|
|
41
|
+
viewer
|
|
42
|
+
} = provider;
|
|
43
|
+
let result = { xyoProvider_send: (params) => provider.send(...params ?? []) };
|
|
44
|
+
if (runner) result = { ...result, ...rpcMethodHandlersFromRunner(runner) };
|
|
45
|
+
if (signer) result = { ...result, ...rpcMethodHandlersFromSigner(signer) };
|
|
46
|
+
if (viewer) result = { ...result, ...rpcMethodHandlersFromViewer(viewer) };
|
|
59
47
|
return result;
|
|
60
|
-
}
|
|
48
|
+
};
|
|
61
49
|
|
|
62
50
|
// src/provider/client/MemoryXyoClient.ts
|
|
63
51
|
var MemoryXyoClient = class {
|
|
64
|
-
static {
|
|
65
|
-
__name(this, "MemoryXyoClient");
|
|
66
|
-
}
|
|
67
52
|
gateways;
|
|
68
|
-
|
|
69
|
-
constructor(gateways,
|
|
53
|
+
permissions;
|
|
54
|
+
constructor(gateways, permissions) {
|
|
70
55
|
this.gateways = gateways;
|
|
71
|
-
this.
|
|
56
|
+
this.permissions = permissions;
|
|
72
57
|
}
|
|
73
58
|
};
|
|
74
59
|
|
|
75
60
|
// src/provider/client/PermissionsStore/getPermissionsStoreFromTransport.ts
|
|
76
|
-
var getPermissionsStoreFromTransport =
|
|
61
|
+
var getPermissionsStoreFromTransport = (transport) => {
|
|
77
62
|
throw new Error("Not implemented");
|
|
78
|
-
}
|
|
63
|
+
};
|
|
79
64
|
|
|
80
65
|
// src/provider/client/PermissionsStore/MemoryPermissionsStore.ts
|
|
81
66
|
var MemoryPermissionsStore = class {
|
|
82
|
-
static {
|
|
83
|
-
__name(this, "MemoryPermissionsStore");
|
|
84
|
-
}
|
|
85
67
|
_store = /* @__PURE__ */ new Map();
|
|
86
68
|
getPermissions() {
|
|
87
|
-
return [
|
|
88
|
-
...this._store.values()
|
|
89
|
-
];
|
|
69
|
+
return [...this._store.values()];
|
|
90
70
|
}
|
|
91
71
|
requestPermissions(permissions) {
|
|
92
72
|
const now = Date.now();
|
|
93
73
|
for (const perm of permissions) {
|
|
94
74
|
const key = this.getKey(perm);
|
|
95
|
-
this._store.set(key, {
|
|
96
|
-
...perm,
|
|
97
|
-
date: now
|
|
98
|
-
});
|
|
75
|
+
this._store.set(key, { ...perm, date: now });
|
|
99
76
|
}
|
|
100
77
|
return true;
|
|
101
78
|
}
|
|
@@ -111,132 +88,9 @@ var MemoryPermissionsStore = class {
|
|
|
111
88
|
}
|
|
112
89
|
};
|
|
113
90
|
|
|
114
|
-
// src/provider/
|
|
115
|
-
import {
|
|
116
|
-
|
|
117
|
-
static {
|
|
118
|
-
__name(this, "AbstractXyoGateway");
|
|
119
|
-
}
|
|
120
|
-
activeConnection() {
|
|
121
|
-
throw new Error("Deprecated method not implemented.");
|
|
122
|
-
}
|
|
123
|
-
addConnection(_config) {
|
|
124
|
-
throw new Error("Deprecated method not implemented.");
|
|
125
|
-
}
|
|
126
|
-
connections() {
|
|
127
|
-
throw new Error("Deprecated method not implemented.");
|
|
128
|
-
}
|
|
129
|
-
getPermissions() {
|
|
130
|
-
throw new Error("Deprecated method not implemented.");
|
|
131
|
-
}
|
|
132
|
-
requestPermissions(_permissions) {
|
|
133
|
-
throw new Error("Deprecated method not implemented.");
|
|
134
|
-
}
|
|
135
|
-
revokePermissions(_permissions) {
|
|
136
|
-
throw new Error("Deprecated method not implemented.");
|
|
137
|
-
}
|
|
138
|
-
async submitTransaction(elevatedPayloads, additionalPayloads) {
|
|
139
|
-
const connection = await this.connection();
|
|
140
|
-
assertEx(connection.submitTransaction, () => "Active connection does not support transaction submission");
|
|
141
|
-
const tx = await connection.submitTransaction?.(elevatedPayloads, additionalPayloads);
|
|
142
|
-
return assertEx(tx, () => "Transaction submission failed");
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
// src/provider/host/MemoryXyoGateway.ts
|
|
147
|
-
var MemoryXyoGateway = class extends AbstractXyoGateway {
|
|
148
|
-
static {
|
|
149
|
-
__name(this, "MemoryXyoGateway");
|
|
150
|
-
}
|
|
151
|
-
_connection;
|
|
152
|
-
_signer;
|
|
153
|
-
constructor(signer, connection) {
|
|
154
|
-
super();
|
|
155
|
-
this._signer = signer;
|
|
156
|
-
this._connection = connection;
|
|
157
|
-
}
|
|
158
|
-
connection() {
|
|
159
|
-
return this._connection;
|
|
160
|
-
}
|
|
161
|
-
signer() {
|
|
162
|
-
return this._signer;
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
// src/provider/network/MemoryXyoNetwork.ts
|
|
167
|
-
import { isUndefined } from "@xylabs/typeof";
|
|
168
|
-
import { isNetworkStatus } from "@xyo-network/xl1-protocol";
|
|
169
|
-
import axios from "axios";
|
|
170
|
-
|
|
171
|
-
// src/provider/network/lib/FailedNetworkStatusPayloads.ts
|
|
172
|
-
import { NetworkStatusSchema } from "@xyo-network/xl1-protocol";
|
|
173
|
-
var unknownStatus = {
|
|
174
|
-
description: "Unknown Network Status",
|
|
175
|
-
schema: NetworkStatusSchema,
|
|
176
|
-
state: "unknown"
|
|
177
|
-
};
|
|
178
|
-
var errorStatus = {
|
|
179
|
-
description: "Error Fetching Network Status",
|
|
180
|
-
schema: NetworkStatusSchema,
|
|
181
|
-
state: "unknown"
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
// src/provider/network/lib/StatusNetworks.ts
|
|
185
|
-
var MainNetworkStats = {
|
|
186
|
-
id: "mainnet",
|
|
187
|
-
statusUrl: "https://xyo.network/chain-network-status-mainnet.json"
|
|
188
|
-
};
|
|
189
|
-
var SequenceNetworkStats = {
|
|
190
|
-
id: "sequence",
|
|
191
|
-
statusUrl: "https://beta.xyo.network/chain-network-status-sequence.json"
|
|
192
|
-
};
|
|
193
|
-
var LocalNetworkStats = {
|
|
194
|
-
id: "local",
|
|
195
|
-
statusUrl: "http://localhost:3002/chain-network-status-local.json"
|
|
196
|
-
};
|
|
197
|
-
var StatusNetworks = {
|
|
198
|
-
mainnet: MainNetworkStats,
|
|
199
|
-
sequence: SequenceNetworkStats,
|
|
200
|
-
local: LocalNetworkStats
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
// src/provider/network/MemoryXyoNetwork.ts
|
|
204
|
-
var MemoryXyoNetwork = class {
|
|
205
|
-
static {
|
|
206
|
-
__name(this, "MemoryXyoNetwork");
|
|
207
|
-
}
|
|
208
|
-
_networkId;
|
|
209
|
-
constructor(networkId) {
|
|
210
|
-
this._networkId = networkId;
|
|
211
|
-
}
|
|
212
|
-
async status() {
|
|
213
|
-
const statusNetwork = StatusNetworks[this._networkId];
|
|
214
|
-
if (isUndefined(statusNetwork)) {
|
|
215
|
-
throw new Error(`Unknown status network ID: ${this._networkId}`);
|
|
216
|
-
}
|
|
217
|
-
return await this.makeRequest(statusNetwork.statusUrl);
|
|
218
|
-
}
|
|
219
|
-
async makeRequest(url) {
|
|
220
|
-
try {
|
|
221
|
-
const response = await axios.get(url);
|
|
222
|
-
if (isNetworkStatus(response.data)) {
|
|
223
|
-
return response.data;
|
|
224
|
-
} else {
|
|
225
|
-
if (response.status === 200) {
|
|
226
|
-
console.error("Unknown network status response:", response.data);
|
|
227
|
-
return unknownStatus;
|
|
228
|
-
}
|
|
229
|
-
return errorStatus;
|
|
230
|
-
}
|
|
231
|
-
} catch (error) {
|
|
232
|
-
console.error("Error fetching network status:", error);
|
|
233
|
-
return errorStatus;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
|
|
238
|
-
// src/provider/provider/HttpRpcXyoConnection.ts
|
|
239
|
-
import { isDefined as isDefined2 } from "@xylabs/typeof";
|
|
91
|
+
// src/provider/connection/HttpRpcXyoConnection.ts
|
|
92
|
+
import { isDefined as isDefined3, isString } from "@xylabs/typeof";
|
|
93
|
+
import { isDataLakeProvider as isDataLakeProvider2 } from "@xyo-network/xl1-protocol";
|
|
240
94
|
|
|
241
95
|
// src/transport/HttpRpcTransport.ts
|
|
242
96
|
import { AxiosJson } from "@xylabs/axios";
|
|
@@ -246,22 +100,10 @@ import { v4 } from "uuid";
|
|
|
246
100
|
|
|
247
101
|
// src/types/ErrorCodes.ts
|
|
248
102
|
var JsonRpcErrorCodes = {
|
|
249
|
-
InternalError: {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
}
|
|
253
|
-
InvalidParams: {
|
|
254
|
-
code: -32602,
|
|
255
|
-
message: "Invalid method parameter(s)."
|
|
256
|
-
},
|
|
257
|
-
InvalidRequest: {
|
|
258
|
-
code: -32600,
|
|
259
|
-
message: "The JSON sent is not a valid Request object."
|
|
260
|
-
},
|
|
261
|
-
MethodNotFound: {
|
|
262
|
-
code: -32601,
|
|
263
|
-
message: "The method does not exist or is not available."
|
|
264
|
-
}
|
|
103
|
+
InternalError: { code: -32603, message: "Internal JSON-RPC error (unexpected exception)." },
|
|
104
|
+
InvalidParams: { code: -32602, message: "Invalid method parameter(s)." },
|
|
105
|
+
InvalidRequest: { code: -32600, message: "The JSON sent is not a valid Request object." },
|
|
106
|
+
MethodNotFound: { code: -32601, message: "The method does not exist or is not available." }
|
|
265
107
|
};
|
|
266
108
|
|
|
267
109
|
// src/types/JsonRpc.ts
|
|
@@ -279,7 +121,11 @@ var AddressToStringSchema = z.string().toLowerCase().regex(CompiledAddressRegEx)
|
|
|
279
121
|
var AddressFromStringSchema = z.string().toLowerCase().regex(CompiledAddressRegEx).transform((v) => toAddress(v));
|
|
280
122
|
|
|
281
123
|
// src/types/schema/common/BigIntSchema.ts
|
|
282
|
-
import {
|
|
124
|
+
import {
|
|
125
|
+
asHex,
|
|
126
|
+
hexToBigInt,
|
|
127
|
+
toHex
|
|
128
|
+
} from "@xylabs/hex";
|
|
283
129
|
import { HexRegEx } from "@xyo-network/payload-wrapper";
|
|
284
130
|
import { z as z2 } from "zod";
|
|
285
131
|
var CompiledHexRegEx = new RegExp(HexRegEx);
|
|
@@ -324,14 +170,8 @@ var LocalSequenceFromStringSchema = z5.string().regex(LocalSequenceRegex).transf
|
|
|
324
170
|
var QualifiedSequenceRegex = new RegExp(HexRegExMinMax(SequenceConstants.qualifiedSequenceBytes, SequenceConstants.qualifiedSequenceBytes));
|
|
325
171
|
var QualifiedSequenceToStringSchema = z5.string().regex(QualifiedSequenceRegex);
|
|
326
172
|
var QualifiedSequenceFromStringSchema = z5.string().regex(QualifiedSequenceRegex).transform((v) => toHex3(v));
|
|
327
|
-
var SequenceToStringSchema = z5.union([
|
|
328
|
-
|
|
329
|
-
QualifiedSequenceToStringSchema
|
|
330
|
-
]);
|
|
331
|
-
var SequenceFromStringSchema = z5.union([
|
|
332
|
-
LocalSequenceFromStringSchema,
|
|
333
|
-
QualifiedSequenceFromStringSchema
|
|
334
|
-
]);
|
|
173
|
+
var SequenceToStringSchema = z5.union([LocalSequenceToStringSchema, QualifiedSequenceToStringSchema]);
|
|
174
|
+
var SequenceFromStringSchema = z5.union([LocalSequenceFromStringSchema, QualifiedSequenceFromStringSchema]);
|
|
335
175
|
|
|
336
176
|
// src/types/schema/common/StorageMetaSchema.ts
|
|
337
177
|
var StorageMetaSchema = z6.object({
|
|
@@ -341,9 +181,7 @@ var StorageMetaSchema = z6.object({
|
|
|
341
181
|
});
|
|
342
182
|
|
|
343
183
|
// src/types/schema/common/PayloadSchema.ts
|
|
344
|
-
var PayloadSchema = z7.object({
|
|
345
|
-
schema: z7.string()
|
|
346
|
-
}).passthrough();
|
|
184
|
+
var PayloadSchema = z7.object({ schema: z7.string() }).passthrough();
|
|
347
185
|
var PayloadWithStorageMetaSchema = PayloadSchema.extend(StorageMetaSchema.shape).passthrough();
|
|
348
186
|
|
|
349
187
|
// src/types/schema/common/BoundWitnessSchema.ts
|
|
@@ -358,18 +196,14 @@ var BoundWitnessMetaSchema = z8.object({
|
|
|
358
196
|
$destination: AddressToStringSchema.optional(),
|
|
359
197
|
$sourceQuery: HashToStringSchema.optional()
|
|
360
198
|
});
|
|
361
|
-
var UnsignedBoundWitnessSchema = PayloadSchema.extend({
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
}).passthrough();
|
|
370
|
-
var SignedBoundWitnessWithStorageMetaSchema = UnsignedBoundWitnessWithStorageMetaSchema.extend({
|
|
371
|
-
$signatures: z8.array(HexToStringSchema)
|
|
372
|
-
}).passthrough();
|
|
199
|
+
var UnsignedBoundWitnessSchema = PayloadSchema.extend({ schema: z8.literal(BoundWitnessSchema) }).merge(BoundWitnessRequiredFieldsSchema).merge(BoundWitnessMetaSchema).passthrough();
|
|
200
|
+
var UnsignedBoundWitnessWithStorageMetaSchema = PayloadWithStorageMetaSchema.extend({ schema: z8.literal(BoundWitnessSchema) }).merge(BoundWitnessRequiredFieldsSchema).merge(BoundWitnessMetaSchema).passthrough();
|
|
201
|
+
var SignedBoundWitnessSchema = UnsignedBoundWitnessSchema.extend(
|
|
202
|
+
{ $signatures: z8.array(HexToStringSchema) }
|
|
203
|
+
).passthrough();
|
|
204
|
+
var SignedBoundWitnessWithStorageMetaSchema = UnsignedBoundWitnessWithStorageMetaSchema.extend(
|
|
205
|
+
{ $signatures: z8.array(HexToStringSchema) }
|
|
206
|
+
).passthrough();
|
|
373
207
|
|
|
374
208
|
// src/types/schema/common/BlockBoundWitnessSchema.ts
|
|
375
209
|
var BlockNumberSchema = z9.number().int().nonnegative();
|
|
@@ -409,16 +243,9 @@ import { z as z12 } from "zod";
|
|
|
409
243
|
|
|
410
244
|
// src/types/schema/common/TransactionBoundWitnessSchema.ts
|
|
411
245
|
import z11 from "zod";
|
|
412
|
-
var BlockStartSchema = z11.object({
|
|
413
|
-
|
|
414
|
-
});
|
|
415
|
-
var BlockEndSchema = z11.object({
|
|
416
|
-
exp: BlockNumberSchema
|
|
417
|
-
});
|
|
418
|
-
var BlockDurationSchema = z11.object({
|
|
419
|
-
nbf: BlockNumberSchema,
|
|
420
|
-
exp: BlockNumberSchema
|
|
421
|
-
});
|
|
246
|
+
var BlockStartSchema = z11.object({ nbf: BlockNumberSchema });
|
|
247
|
+
var BlockEndSchema = z11.object({ exp: BlockNumberSchema });
|
|
248
|
+
var BlockDurationSchema = z11.object({ nbf: BlockNumberSchema, exp: BlockNumberSchema });
|
|
422
249
|
var TransactionFeesSchema = z11.object({
|
|
423
250
|
fees: z11.object({
|
|
424
251
|
base: HexToStringSchema,
|
|
@@ -427,9 +254,7 @@ var TransactionFeesSchema = z11.object({
|
|
|
427
254
|
priority: HexToStringSchema
|
|
428
255
|
})
|
|
429
256
|
});
|
|
430
|
-
var TransactionBoundWitnessFields = z11.object({
|
|
431
|
-
chain: AddressToStringSchema
|
|
432
|
-
});
|
|
257
|
+
var TransactionBoundWitnessFields = z11.object({ chain: AddressToStringSchema });
|
|
433
258
|
var TransactionBoundWitnessSchema = UnsignedBoundWitnessSchema.merge(BlockDurationSchema).merge(TransactionFeesSchema).merge(TransactionBoundWitnessFields).passthrough();
|
|
434
259
|
var SignedTransactionBoundWitnessSchema = SignedBoundWitnessSchema.merge(BlockDurationSchema).merge(TransactionFeesSchema).merge(TransactionBoundWitnessFields).passthrough();
|
|
435
260
|
|
|
@@ -493,12 +318,8 @@ import { z as z15 } from "zod";
|
|
|
493
318
|
var XyoRunnerRpcSchemas = {
|
|
494
319
|
xyoRunner_broadcastTransaction: {
|
|
495
320
|
params: {
|
|
496
|
-
to: z15.tuple([
|
|
497
|
-
|
|
498
|
-
]),
|
|
499
|
-
from: z15.tuple([
|
|
500
|
-
SignedHydratedTransactionSchema
|
|
501
|
-
])
|
|
321
|
+
to: z15.tuple([SignedHydratedTransactionSchema]),
|
|
322
|
+
from: z15.tuple([SignedHydratedTransactionSchema])
|
|
502
323
|
},
|
|
503
324
|
result: {
|
|
504
325
|
to: HashToStringSchema,
|
|
@@ -548,12 +369,8 @@ var XyoSignerRpcSchemas = {
|
|
|
548
369
|
},
|
|
549
370
|
xyoSigner_signTransaction: {
|
|
550
371
|
params: {
|
|
551
|
-
to: z16.tuple([
|
|
552
|
-
|
|
553
|
-
]),
|
|
554
|
-
from: z16.tuple([
|
|
555
|
-
HydratedTransactionSchema
|
|
556
|
-
])
|
|
372
|
+
to: z16.tuple([HydratedTransactionSchema]),
|
|
373
|
+
from: z16.tuple([HydratedTransactionSchema])
|
|
557
374
|
},
|
|
558
375
|
result: {
|
|
559
376
|
to: SignedHydratedTransactionSchema,
|
|
@@ -568,32 +385,14 @@ var XyoViewerRpcSchemas = {
|
|
|
568
385
|
xyoViewer_accountBalance: {
|
|
569
386
|
params: {
|
|
570
387
|
to: z17.union([
|
|
571
|
-
z17.tuple([
|
|
572
|
-
|
|
573
|
-
])
|
|
574
|
-
z17.tuple([
|
|
575
|
-
AddressToStringSchema,
|
|
576
|
-
z17.number()
|
|
577
|
-
]),
|
|
578
|
-
z17.tuple([
|
|
579
|
-
AddressToStringSchema,
|
|
580
|
-
z17.number(),
|
|
581
|
-
z17.boolean()
|
|
582
|
-
])
|
|
388
|
+
z17.tuple([AddressToStringSchema]),
|
|
389
|
+
z17.tuple([AddressToStringSchema, z17.number()]),
|
|
390
|
+
z17.tuple([AddressToStringSchema, z17.number(), z17.boolean()])
|
|
583
391
|
]),
|
|
584
392
|
from: z17.union([
|
|
585
|
-
z17.tuple([
|
|
586
|
-
|
|
587
|
-
])
|
|
588
|
-
z17.tuple([
|
|
589
|
-
AddressToStringSchema,
|
|
590
|
-
z17.number()
|
|
591
|
-
]),
|
|
592
|
-
z17.tuple([
|
|
593
|
-
AddressToStringSchema,
|
|
594
|
-
z17.number(),
|
|
595
|
-
z17.boolean()
|
|
596
|
-
])
|
|
393
|
+
z17.tuple([AddressToStringSchema]),
|
|
394
|
+
z17.tuple([AddressToStringSchema, z17.number()]),
|
|
395
|
+
z17.tuple([AddressToStringSchema, z17.number(), z17.boolean()])
|
|
597
396
|
])
|
|
598
397
|
},
|
|
599
398
|
result: {
|
|
@@ -604,32 +403,14 @@ var XyoViewerRpcSchemas = {
|
|
|
604
403
|
xyoViewer_accountHistory: {
|
|
605
404
|
params: {
|
|
606
405
|
to: z17.union([
|
|
607
|
-
z17.tuple([
|
|
608
|
-
|
|
609
|
-
])
|
|
610
|
-
z17.tuple([
|
|
611
|
-
AddressToStringSchema,
|
|
612
|
-
z17.number()
|
|
613
|
-
]),
|
|
614
|
-
z17.tuple([
|
|
615
|
-
AddressToStringSchema,
|
|
616
|
-
z17.number(),
|
|
617
|
-
z17.boolean()
|
|
618
|
-
])
|
|
406
|
+
z17.tuple([AddressToStringSchema]),
|
|
407
|
+
z17.tuple([AddressToStringSchema, z17.number()]),
|
|
408
|
+
z17.tuple([AddressToStringSchema, z17.number(), z17.boolean()])
|
|
619
409
|
]),
|
|
620
410
|
from: z17.union([
|
|
621
|
-
z17.tuple([
|
|
622
|
-
|
|
623
|
-
])
|
|
624
|
-
z17.tuple([
|
|
625
|
-
AddressToStringSchema,
|
|
626
|
-
z17.number()
|
|
627
|
-
]),
|
|
628
|
-
z17.tuple([
|
|
629
|
-
AddressToStringSchema,
|
|
630
|
-
z17.number(),
|
|
631
|
-
z17.boolean()
|
|
632
|
-
])
|
|
411
|
+
z17.tuple([AddressToStringSchema]),
|
|
412
|
+
z17.tuple([AddressToStringSchema, z17.number()]),
|
|
413
|
+
z17.tuple([AddressToStringSchema, z17.number(), z17.boolean()])
|
|
633
414
|
])
|
|
634
415
|
},
|
|
635
416
|
result: {
|
|
@@ -639,12 +420,8 @@ var XyoViewerRpcSchemas = {
|
|
|
639
420
|
},
|
|
640
421
|
xyoViewer_blockByHash: {
|
|
641
422
|
params: {
|
|
642
|
-
to: z17.tuple([
|
|
643
|
-
|
|
644
|
-
]),
|
|
645
|
-
from: z17.tuple([
|
|
646
|
-
HashFromStringSchema
|
|
647
|
-
])
|
|
423
|
+
to: z17.tuple([HashToStringSchema]),
|
|
424
|
+
from: z17.tuple([HashFromStringSchema])
|
|
648
425
|
},
|
|
649
426
|
result: {
|
|
650
427
|
to: SignedHydratedBlockSchema,
|
|
@@ -653,12 +430,8 @@ var XyoViewerRpcSchemas = {
|
|
|
653
430
|
},
|
|
654
431
|
xyoViewer_blockByNumber: {
|
|
655
432
|
params: {
|
|
656
|
-
to: z17.tuple([
|
|
657
|
-
|
|
658
|
-
]),
|
|
659
|
-
from: z17.tuple([
|
|
660
|
-
z17.number()
|
|
661
|
-
])
|
|
433
|
+
to: z17.tuple([z17.number()]),
|
|
434
|
+
from: z17.tuple([z17.number()])
|
|
662
435
|
},
|
|
663
436
|
result: {
|
|
664
437
|
to: SignedHydratedBlockSchema,
|
|
@@ -667,14 +440,8 @@ var XyoViewerRpcSchemas = {
|
|
|
667
440
|
},
|
|
668
441
|
xyoViewer_blocksByHash: {
|
|
669
442
|
params: {
|
|
670
|
-
to: z17.tuple([
|
|
671
|
-
|
|
672
|
-
z17.number().optional()
|
|
673
|
-
]),
|
|
674
|
-
from: z17.tuple([
|
|
675
|
-
HashFromStringSchema,
|
|
676
|
-
z17.number().optional()
|
|
677
|
-
])
|
|
443
|
+
to: z17.tuple([HashToStringSchema, z17.number().optional()]),
|
|
444
|
+
from: z17.tuple([HashFromStringSchema, z17.number().optional()])
|
|
678
445
|
},
|
|
679
446
|
result: {
|
|
680
447
|
to: z17.array(SignedHydratedBlockSchema),
|
|
@@ -723,14 +490,8 @@ var XyoViewerRpcSchemas = {
|
|
|
723
490
|
},
|
|
724
491
|
xyoViewer_transactionByBlockHashAndIndex: {
|
|
725
492
|
params: {
|
|
726
|
-
to: z17.tuple([
|
|
727
|
-
|
|
728
|
-
z17.number()
|
|
729
|
-
]),
|
|
730
|
-
from: z17.tuple([
|
|
731
|
-
HashFromStringSchema,
|
|
732
|
-
z17.number()
|
|
733
|
-
])
|
|
493
|
+
to: z17.tuple([HashToStringSchema, z17.number()]),
|
|
494
|
+
from: z17.tuple([HashFromStringSchema, z17.number()])
|
|
734
495
|
},
|
|
735
496
|
result: {
|
|
736
497
|
to: SignedHydratedTransactionSchema.nullable(),
|
|
@@ -739,14 +500,8 @@ var XyoViewerRpcSchemas = {
|
|
|
739
500
|
},
|
|
740
501
|
xyoViewer_transactionByBlockNumberAndIndex: {
|
|
741
502
|
params: {
|
|
742
|
-
to: z17.tuple([
|
|
743
|
-
|
|
744
|
-
z17.number()
|
|
745
|
-
]),
|
|
746
|
-
from: z17.tuple([
|
|
747
|
-
z17.number(),
|
|
748
|
-
z17.number()
|
|
749
|
-
])
|
|
503
|
+
to: z17.tuple([z17.number(), z17.number()]),
|
|
504
|
+
from: z17.tuple([z17.number(), z17.number()])
|
|
750
505
|
},
|
|
751
506
|
result: {
|
|
752
507
|
to: SignedHydratedTransactionSchema.nullable(),
|
|
@@ -755,12 +510,8 @@ var XyoViewerRpcSchemas = {
|
|
|
755
510
|
},
|
|
756
511
|
xyoViewer_transactionByHash: {
|
|
757
512
|
params: {
|
|
758
|
-
to: z17.tuple([
|
|
759
|
-
|
|
760
|
-
]),
|
|
761
|
-
from: z17.tuple([
|
|
762
|
-
HashFromStringSchema
|
|
763
|
-
])
|
|
513
|
+
to: z17.tuple([HashToStringSchema]),
|
|
514
|
+
from: z17.tuple([HashFromStringSchema])
|
|
764
515
|
},
|
|
765
516
|
result: {
|
|
766
517
|
to: SignedHydratedTransactionSchema.nullable(),
|
|
@@ -779,55 +530,40 @@ var AllRpcSchemas = {
|
|
|
779
530
|
|
|
780
531
|
// src/types/schema/createRequestSchema.ts
|
|
781
532
|
import { z as z18 } from "zod";
|
|
782
|
-
var createRequestSchema =
|
|
783
|
-
id: z18.union([
|
|
784
|
-
z18.string(),
|
|
785
|
-
z18.number()
|
|
786
|
-
]),
|
|
533
|
+
var createRequestSchema = (methodName, paramsSchema = z18.undefined()) => z18.object({
|
|
534
|
+
id: z18.union([z18.string(), z18.number()]),
|
|
787
535
|
jsonrpc: z18.literal(jsonrpc),
|
|
788
536
|
method: z18.literal(methodName),
|
|
789
537
|
params: paramsSchema
|
|
790
|
-
})
|
|
538
|
+
});
|
|
791
539
|
|
|
792
540
|
// src/types/schema/createResponseSchema.ts
|
|
793
541
|
import { z as z19 } from "zod";
|
|
794
|
-
var createResponseSchema =
|
|
795
|
-
id: z19.union([
|
|
796
|
-
z19.string(),
|
|
797
|
-
z19.number()
|
|
798
|
-
]),
|
|
542
|
+
var createResponseSchema = (resultSchema = z19.undefined()) => z19.object({
|
|
543
|
+
id: z19.union([z19.string(), z19.number()]),
|
|
799
544
|
jsonrpc: z19.literal(jsonrpc),
|
|
800
545
|
result: resultSchema
|
|
801
|
-
})
|
|
546
|
+
});
|
|
802
547
|
|
|
803
548
|
// src/types/schema/XyoGatewayRpcSchemas.ts
|
|
804
549
|
import { z as z20 } from "zod";
|
|
805
550
|
var ChainConnectionSchema = z20.object({
|
|
806
|
-
chainId: z20.union([
|
|
807
|
-
z20.string(),
|
|
808
|
-
z20.custom()
|
|
809
|
-
]).optional(),
|
|
551
|
+
chainId: z20.union([z20.string(), z20.custom()]).optional(),
|
|
810
552
|
name: z20.string(),
|
|
811
553
|
url: z20.string()
|
|
812
554
|
});
|
|
813
|
-
var CaveatTypesSchema = z20.enum([
|
|
814
|
-
"chain",
|
|
815
|
-
"expiration",
|
|
816
|
-
"filteredResponse",
|
|
817
|
-
"rateLimit"
|
|
818
|
-
]);
|
|
555
|
+
var CaveatTypesSchema = z20.enum(["chain", "expiration", "filteredResponse", "rateLimit"]);
|
|
819
556
|
var CaveatsSchema = z20.object({
|
|
820
557
|
type: CaveatTypesSchema,
|
|
821
558
|
value: z20.unknown()
|
|
559
|
+
// JsonValue is usually unknown, adjust if you have a stricter type
|
|
822
560
|
});
|
|
823
561
|
var PermissionSchema = z20.object({
|
|
824
562
|
capability: z20.string(),
|
|
825
563
|
caveats: CaveatsSchema.array().optional(),
|
|
826
564
|
invoker: z20.string()
|
|
827
565
|
});
|
|
828
|
-
var InvokerPermissionSchema = PermissionSchema.extend({
|
|
829
|
-
date: z20.number().optional()
|
|
830
|
-
});
|
|
566
|
+
var InvokerPermissionSchema = PermissionSchema.extend({ date: z20.number().optional() });
|
|
831
567
|
var XyoGatewayRpcSchemas = {
|
|
832
568
|
/*
|
|
833
569
|
xyoGateway_addConnection: {
|
|
@@ -893,8 +629,12 @@ var XyoGatewayRpcSchemas = {
|
|
|
893
629
|
*/
|
|
894
630
|
xyoGateway_submitTransaction: {
|
|
895
631
|
params: {
|
|
896
|
-
from: z20.array(
|
|
897
|
-
|
|
632
|
+
from: z20.array(
|
|
633
|
+
HydratedTransactionSchema
|
|
634
|
+
),
|
|
635
|
+
to: z20.array(
|
|
636
|
+
HydratedTransactionSchema
|
|
637
|
+
)
|
|
898
638
|
},
|
|
899
639
|
result: {
|
|
900
640
|
from: BlockBoundWitnessSchema,
|
|
@@ -905,9 +645,6 @@ var XyoGatewayRpcSchemas = {
|
|
|
905
645
|
|
|
906
646
|
// src/transport/HttpRpcTransport.ts
|
|
907
647
|
var HttpRpcTransport = class {
|
|
908
|
-
static {
|
|
909
|
-
__name(this, "HttpRpcTransport");
|
|
910
|
-
}
|
|
911
648
|
_rpcUrl;
|
|
912
649
|
_schemas;
|
|
913
650
|
constructor(rpcUrl, schemas) {
|
|
@@ -948,9 +685,6 @@ var HttpRpcTransport = class {
|
|
|
948
685
|
import { isObject } from "@xylabs/typeof";
|
|
949
686
|
import { v4 as v42 } from "uuid";
|
|
950
687
|
var MemoryRpcTransport = class {
|
|
951
|
-
static {
|
|
952
|
-
__name(this, "MemoryRpcTransport");
|
|
953
|
-
}
|
|
954
688
|
_rpcEngine;
|
|
955
689
|
_schemas;
|
|
956
690
|
requestSchemas = {};
|
|
@@ -988,25 +722,22 @@ import { isDefined } from "@xylabs/typeof";
|
|
|
988
722
|
import { v4 as v43 } from "uuid";
|
|
989
723
|
|
|
990
724
|
// src/transport/post-message/helpers.ts
|
|
991
|
-
var isRpcError =
|
|
725
|
+
var isRpcError = (data) => {
|
|
992
726
|
return data && typeof data === "object" && "error" in data && data.error;
|
|
993
|
-
}
|
|
727
|
+
};
|
|
994
728
|
|
|
995
729
|
// src/transport/post-message/SessionEnvelope.ts
|
|
996
|
-
var buildSessionMessageRequest =
|
|
730
|
+
var buildSessionMessageRequest = (data, destination) => {
|
|
997
731
|
const request = {
|
|
998
732
|
data,
|
|
999
733
|
destination,
|
|
1000
|
-
sessionId: globalThis.
|
|
734
|
+
sessionId: globalThis.xyoWalletExtensionId ?? ""
|
|
1001
735
|
};
|
|
1002
736
|
return request;
|
|
1003
|
-
}
|
|
737
|
+
};
|
|
1004
738
|
|
|
1005
739
|
// src/transport/post-message/PostMessageRpcTransport.ts
|
|
1006
740
|
var PostMessageRpcTransport = class {
|
|
1007
|
-
static {
|
|
1008
|
-
__name(this, "PostMessageRpcTransport");
|
|
1009
|
-
}
|
|
1010
741
|
destination;
|
|
1011
742
|
schemas;
|
|
1012
743
|
constructor(defaultDestination, schemas = XyoGatewayRpcSchemas) {
|
|
@@ -1026,7 +757,7 @@ var PostMessageRpcTransport = class {
|
|
|
1026
757
|
body.params = isDefined(params) && isDefined(schemas[method]) ? schemas[method].params.to.parse(params) : params;
|
|
1027
758
|
return await new Promise((resolve, reject) => {
|
|
1028
759
|
const id2 = body.id;
|
|
1029
|
-
const handler =
|
|
760
|
+
const handler = (event) => {
|
|
1030
761
|
if (event.origin !== globalThis.window.origin) return;
|
|
1031
762
|
if (event.data.id !== id2) return;
|
|
1032
763
|
globalThis.removeEventListener("message", handler);
|
|
@@ -1035,63 +766,194 @@ var PostMessageRpcTransport = class {
|
|
|
1035
766
|
} else {
|
|
1036
767
|
resolve(event.data.result[0]);
|
|
1037
768
|
}
|
|
1038
|
-
}
|
|
769
|
+
};
|
|
1039
770
|
globalThis.addEventListener("message", handler);
|
|
1040
|
-
globalThis.postMessage(
|
|
771
|
+
globalThis.postMessage(
|
|
772
|
+
buildSessionMessageRequest(body, this.destination),
|
|
773
|
+
globalThis.location.origin
|
|
774
|
+
);
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
};
|
|
778
|
+
|
|
779
|
+
// src/provider/datalake/AbstractXyoDataLake.ts
|
|
780
|
+
import { ObjectHasher } from "@xyo-network/hash";
|
|
781
|
+
import { PayloadBuilder } from "@xyo-network/payload-builder";
|
|
782
|
+
import { isAnyPayload } from "@xyo-network/payload-model";
|
|
783
|
+
import {
|
|
784
|
+
isHashPayload
|
|
785
|
+
} from "@xyo-network/xl1-protocol";
|
|
786
|
+
var AbstractXyoDataLake = class {
|
|
787
|
+
async fetch(hashes, maxDepth = 10) {
|
|
788
|
+
const results = await this.get(hashes);
|
|
789
|
+
if (maxDepth > 0) {
|
|
790
|
+
const hashPayloads = results.filter(isHashPayload);
|
|
791
|
+
const otherPayloads = results.filter((item) => !isHashPayload(item));
|
|
792
|
+
const found = await this.fetch(hashPayloads.map((item) => item.hash), maxDepth - 1);
|
|
793
|
+
const foundHashes = await Promise.all(found.map(async (item) => isAnyPayload(item) ? await PayloadBuilder.hash(item) : ObjectHasher.hashBytes(item)));
|
|
794
|
+
const notFound = hashPayloads.filter((item) => !foundHashes.includes(item.hash));
|
|
795
|
+
return [...otherPayloads, ...found, ...notFound];
|
|
796
|
+
}
|
|
797
|
+
return results;
|
|
798
|
+
}
|
|
799
|
+
async trace(hash) {
|
|
800
|
+
const [result] = await this.get([hash]);
|
|
801
|
+
if (isHashPayload(result)) {
|
|
802
|
+
const [payload, route] = await this.trace(result.hash);
|
|
803
|
+
return [payload, [result, ...route]];
|
|
804
|
+
}
|
|
805
|
+
return [result, []];
|
|
806
|
+
}
|
|
807
|
+
};
|
|
808
|
+
|
|
809
|
+
// src/provider/datalake/ArchivistXyoDataLake.ts
|
|
810
|
+
import { assertEx } from "@xylabs/assert";
|
|
811
|
+
import { isAnyPayload as isAnyPayload2 } from "@xyo-network/payload-model";
|
|
812
|
+
var ArchivistXyoDataLake = class extends AbstractXyoDataLake {
|
|
813
|
+
_archivist;
|
|
814
|
+
constructor(archivist) {
|
|
815
|
+
super();
|
|
816
|
+
this._archivist = archivist;
|
|
817
|
+
}
|
|
818
|
+
async add(items) {
|
|
819
|
+
const payloads = items.filter(isAnyPayload2);
|
|
820
|
+
assertEx(payloads.length === items.length, () => "Some items are not payloads");
|
|
821
|
+
return await this._archivist.insert(payloads);
|
|
822
|
+
}
|
|
823
|
+
async get(hashes) {
|
|
824
|
+
return await this._archivist.get(hashes);
|
|
825
|
+
}
|
|
826
|
+
};
|
|
827
|
+
|
|
828
|
+
// src/provider/datalake/HttpXyoDataLake.ts
|
|
829
|
+
import { assertEx as assertEx2 } from "@xylabs/assert";
|
|
830
|
+
import { AxiosJson as AxiosJson2 } from "@xylabs/axios";
|
|
831
|
+
import { exists } from "@xylabs/exists";
|
|
832
|
+
import { isArrayBuffer, isDefined as isDefined2 } from "@xylabs/typeof";
|
|
833
|
+
import { isAnyPayload as isAnyPayload3 } from "@xyo-network/payload-model";
|
|
834
|
+
import { isHashPayload as isHashPayload2 } from "@xyo-network/xl1-protocol";
|
|
835
|
+
import { Axios } from "axios";
|
|
836
|
+
var HttpXyoDataLake = class extends AbstractXyoDataLake {
|
|
837
|
+
_axiosGet;
|
|
838
|
+
_axiosInsertBlob;
|
|
839
|
+
_axiosInsertJson;
|
|
840
|
+
_endpoint;
|
|
841
|
+
constructor(endpoint) {
|
|
842
|
+
super();
|
|
843
|
+
this._endpoint = endpoint;
|
|
844
|
+
this._axiosInsertJson = new AxiosJson2({ baseURL: endpoint });
|
|
845
|
+
this._axiosInsertBlob = new Axios({ baseURL: endpoint, headers: { "Content-Type": "application/octet-stream", "Accept": "application/octet-stream" } });
|
|
846
|
+
this._axiosGet = new Axios({ baseURL: endpoint, headers: { "Content-Type": "application/json", "Accept": "application/octet-stream, application/json" } });
|
|
847
|
+
}
|
|
848
|
+
get endpoint() {
|
|
849
|
+
return this._endpoint;
|
|
850
|
+
}
|
|
851
|
+
async add(items) {
|
|
852
|
+
const results = [];
|
|
853
|
+
for (const item of items) {
|
|
854
|
+
if (isAnyPayload3(item)) {
|
|
855
|
+
const result = await this.addPayload(item);
|
|
856
|
+
if (isAnyPayload3(result)) {
|
|
857
|
+
results.push(result);
|
|
858
|
+
} else if (isDefined2(result)) {
|
|
859
|
+
assertEx2(false, () => "Expected result to be a Payload");
|
|
860
|
+
}
|
|
861
|
+
} else if (isArrayBuffer(item)) {
|
|
862
|
+
const result = await this.addArrayBuffer(item);
|
|
863
|
+
if (isAnyPayload3(result)) {
|
|
864
|
+
results.push(result);
|
|
865
|
+
} else if (isDefined2(result)) {
|
|
866
|
+
assertEx2(false, () => "Expected result to be a Payload");
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
return results;
|
|
871
|
+
}
|
|
872
|
+
async get(hashes) {
|
|
873
|
+
return (await Promise.all(hashes.map(async (hash) => {
|
|
874
|
+
return await this.getOne(hash);
|
|
875
|
+
}))).filter(exists);
|
|
876
|
+
}
|
|
877
|
+
async addArrayBuffer(item) {
|
|
878
|
+
const result = await this._axiosInsertBlob.post("/insert", item);
|
|
879
|
+
if (result.status < 200 || result.status >= 300) {
|
|
880
|
+
throw new Error(`Failed to add items [${result.status}]: ${result.statusText}`);
|
|
881
|
+
}
|
|
882
|
+
if (!isArrayBuffer(result.data)) {
|
|
883
|
+
throw new Error("Invalid response from server (expected a ArrayBuffer)");
|
|
884
|
+
}
|
|
885
|
+
return result.data;
|
|
886
|
+
}
|
|
887
|
+
async addPayload(item) {
|
|
888
|
+
const result = await this._axiosInsertJson.post("/insert", item);
|
|
889
|
+
if (result.status < 200 || result.status >= 300) {
|
|
890
|
+
throw new Error(`Failed to add items [${result.status}]: ${result.statusText}`);
|
|
891
|
+
}
|
|
892
|
+
if (!isAnyPayload3(result.data)) {
|
|
893
|
+
throw new Error("Invalid response from server (expected a Payload)");
|
|
894
|
+
}
|
|
895
|
+
return result.data;
|
|
896
|
+
}
|
|
897
|
+
async fetchOne(hash, maxDepth = Number.MAX_SAFE_INTEGER) {
|
|
898
|
+
if (maxDepth <= 0) {
|
|
899
|
+
return void 0;
|
|
900
|
+
}
|
|
901
|
+
const result = await this.getOne(hash);
|
|
902
|
+
if (isHashPayload2(result)) {
|
|
903
|
+
return await this.fetchOne(result.hash, maxDepth - 1);
|
|
904
|
+
}
|
|
905
|
+
return result;
|
|
906
|
+
}
|
|
907
|
+
getOne(hash) {
|
|
908
|
+
return this._axiosGet.get(`/get/${hash}`).then((response) => {
|
|
909
|
+
if (response.status < 200 || response.status >= 300) {
|
|
910
|
+
throw new Error(`Failed to get item [${response.status}]: ${response.statusText}`);
|
|
911
|
+
}
|
|
912
|
+
if (!isAnyPayload3(response.data)) {
|
|
913
|
+
throw new Error("Invalid response from server (expected a Payload)");
|
|
914
|
+
}
|
|
915
|
+
return response.data;
|
|
1041
916
|
});
|
|
1042
917
|
}
|
|
1043
918
|
};
|
|
1044
919
|
|
|
1045
920
|
// src/provider/runner/JsonRpcXyoRunner.ts
|
|
1046
921
|
var JsonRpcXyoRunner = class {
|
|
1047
|
-
static {
|
|
1048
|
-
__name(this, "JsonRpcXyoRunner");
|
|
1049
|
-
}
|
|
1050
922
|
transport;
|
|
1051
923
|
constructor(transport) {
|
|
1052
924
|
this.transport = transport;
|
|
1053
925
|
}
|
|
1054
926
|
async broadcastTransaction(transaction) {
|
|
1055
|
-
return await this.transport.sendRequest("xyoRunner_broadcastTransaction", [
|
|
1056
|
-
transaction
|
|
1057
|
-
]);
|
|
927
|
+
return await this.transport.sendRequest("xyoRunner_broadcastTransaction", [transaction]);
|
|
1058
928
|
}
|
|
1059
929
|
};
|
|
1060
930
|
|
|
1061
931
|
// src/provider/runner/MemoryXyoRunner.ts
|
|
1062
932
|
import { MemoryArchivist } from "@xyo-network/archivist-memory";
|
|
1063
|
-
import { PayloadBuilder } from "@xyo-network/payload-builder";
|
|
933
|
+
import { PayloadBuilder as PayloadBuilder2 } from "@xyo-network/payload-builder";
|
|
1064
934
|
import { flattenHydratedTransaction } from "@xyo-network/xl1-protocol-sdk";
|
|
1065
935
|
var MemoryXyoRunner = class {
|
|
1066
|
-
static {
|
|
1067
|
-
__name(this, "MemoryXyoRunner");
|
|
1068
|
-
}
|
|
1069
936
|
_archivist;
|
|
1070
937
|
async broadcastTransaction(transaction) {
|
|
1071
938
|
const archivist = await this.getArchivist();
|
|
1072
939
|
await archivist.insert(flattenHydratedTransaction(transaction));
|
|
1073
|
-
return await
|
|
940
|
+
return await PayloadBuilder2.hash(transaction[0]);
|
|
1074
941
|
}
|
|
1075
942
|
async getArchivist() {
|
|
1076
943
|
if (!this._archivist) {
|
|
1077
|
-
this._archivist = await MemoryArchivist.create({
|
|
1078
|
-
account: "random"
|
|
1079
|
-
});
|
|
944
|
+
this._archivist = await MemoryArchivist.create({ account: "random" });
|
|
1080
945
|
}
|
|
1081
946
|
return this._archivist;
|
|
1082
947
|
}
|
|
1083
948
|
};
|
|
1084
949
|
|
|
1085
950
|
// src/provider/runner/NodeXyoRunner.ts
|
|
1086
|
-
import { assertEx as
|
|
951
|
+
import { assertEx as assertEx3 } from "@xylabs/assert";
|
|
1087
952
|
import { asArchivistInstance } from "@xyo-network/archivist-model";
|
|
1088
|
-
import { PayloadBuilder as
|
|
953
|
+
import { PayloadBuilder as PayloadBuilder3 } from "@xyo-network/payload-builder";
|
|
1089
954
|
import { PayloadBundleSchema } from "@xyo-network/payload-model";
|
|
1090
955
|
import { flattenHydratedTransaction as flattenHydratedTransaction2 } from "@xyo-network/xl1-protocol-sdk";
|
|
1091
956
|
var NodeXyoRunner = class {
|
|
1092
|
-
static {
|
|
1093
|
-
__name(this, "NodeXyoRunner");
|
|
1094
|
-
}
|
|
1095
957
|
// TODO: Make configurable with defaults
|
|
1096
958
|
node;
|
|
1097
959
|
pendingArchivistPath = "XYOChain:Pending:PendingTransactions";
|
|
@@ -1102,33 +964,28 @@ var NodeXyoRunner = class {
|
|
|
1102
964
|
async broadcastTransaction(transaction) {
|
|
1103
965
|
const flattened = flattenHydratedTransaction2(transaction);
|
|
1104
966
|
const pendingArchivist = await this.getPendingArchivist();
|
|
1105
|
-
const txHash = await
|
|
967
|
+
const txHash = await PayloadBuilder3.hash(transaction[0]);
|
|
1106
968
|
const payloadBundle = {
|
|
1107
969
|
schema: PayloadBundleSchema,
|
|
1108
970
|
payloads: flattened,
|
|
1109
971
|
root: txHash
|
|
1110
972
|
};
|
|
1111
|
-
await pendingArchivist.insert([
|
|
1112
|
-
payloadBundle
|
|
1113
|
-
]);
|
|
973
|
+
await pendingArchivist.insert([payloadBundle]);
|
|
1114
974
|
return txHash;
|
|
1115
975
|
}
|
|
1116
|
-
getArchivist =
|
|
976
|
+
getArchivist = async (identifier) => {
|
|
1117
977
|
const archivist = await this.node.resolve(identifier);
|
|
1118
|
-
return
|
|
1119
|
-
}
|
|
1120
|
-
getPendingArchivist =
|
|
978
|
+
return assertEx3(asArchivistInstance(archivist), () => `Error: Could not resolve ${identifier} to an archivist instance`);
|
|
979
|
+
};
|
|
980
|
+
getPendingArchivist = async () => {
|
|
1121
981
|
if (this._pendingArchivist) return this._pendingArchivist;
|
|
1122
982
|
this._pendingArchivist = await this.getArchivist(this.pendingArchivistPath);
|
|
1123
|
-
return
|
|
1124
|
-
}
|
|
983
|
+
return assertEx3(this._pendingArchivist, () => `Error: Could not resolve pending archivist at ${this.pendingArchivistPath}`);
|
|
984
|
+
};
|
|
1125
985
|
};
|
|
1126
986
|
|
|
1127
987
|
// src/provider/signer/JsonRpcXyoSigner.ts
|
|
1128
988
|
var RpcXyoSigner = class {
|
|
1129
|
-
static {
|
|
1130
|
-
__name(this, "RpcXyoSigner");
|
|
1131
|
-
}
|
|
1132
989
|
transport;
|
|
1133
990
|
constructor(transport) {
|
|
1134
991
|
this.transport = transport;
|
|
@@ -1152,17 +1009,11 @@ var RpcXyoSigner = class {
|
|
|
1152
1009
|
}
|
|
1153
1010
|
};
|
|
1154
1011
|
var JsonRpcXyoSigner = class extends RpcXyoSigner {
|
|
1155
|
-
static {
|
|
1156
|
-
__name(this, "JsonRpcXyoSigner");
|
|
1157
|
-
}
|
|
1158
1012
|
};
|
|
1159
1013
|
|
|
1160
1014
|
// src/provider/signer/MemoryXyoSigner.ts
|
|
1161
1015
|
import { buildTransaction } from "@xyo-network/xl1-protocol-sdk";
|
|
1162
1016
|
var MemoryXyoSigner = class {
|
|
1163
|
-
static {
|
|
1164
|
-
__name(this, "MemoryXyoSigner");
|
|
1165
|
-
}
|
|
1166
1017
|
_account;
|
|
1167
1018
|
constructor(account) {
|
|
1168
1019
|
this._account = account;
|
|
@@ -1172,7 +1023,16 @@ var MemoryXyoSigner = class {
|
|
|
1172
1023
|
}
|
|
1173
1024
|
async createSignedTransaction(chain, elevatedPayloads, additionalPayloads, nbf, exp, fees, from) {
|
|
1174
1025
|
const fromAddress = from ?? this._account.address;
|
|
1175
|
-
const transaction = await buildTransaction(
|
|
1026
|
+
const transaction = await buildTransaction(
|
|
1027
|
+
chain,
|
|
1028
|
+
elevatedPayloads,
|
|
1029
|
+
additionalPayloads,
|
|
1030
|
+
this._account,
|
|
1031
|
+
nbf,
|
|
1032
|
+
exp,
|
|
1033
|
+
fromAddress,
|
|
1034
|
+
fees
|
|
1035
|
+
);
|
|
1176
1036
|
return transaction[0];
|
|
1177
1037
|
}
|
|
1178
1038
|
signTransaction(_tx) {
|
|
@@ -1182,38 +1042,24 @@ var MemoryXyoSigner = class {
|
|
|
1182
1042
|
|
|
1183
1043
|
// src/provider/viewer/JsonRpcXyoViewer.ts
|
|
1184
1044
|
var JsonRpcXyoViewer = class {
|
|
1185
|
-
static {
|
|
1186
|
-
__name(this, "JsonRpcXyoViewer");
|
|
1187
|
-
}
|
|
1188
1045
|
transport;
|
|
1189
1046
|
constructor(transport) {
|
|
1190
1047
|
this.transport = transport;
|
|
1191
1048
|
}
|
|
1192
1049
|
async accountBalance(address) {
|
|
1193
|
-
return await this.transport.sendRequest("xyoViewer_accountBalance", [
|
|
1194
|
-
address
|
|
1195
|
-
]);
|
|
1050
|
+
return await this.transport.sendRequest("xyoViewer_accountBalance", [address]);
|
|
1196
1051
|
}
|
|
1197
1052
|
async accountHistory(address) {
|
|
1198
|
-
return await this.transport.sendRequest("xyoViewer_accountBalance", [
|
|
1199
|
-
address
|
|
1200
|
-
]);
|
|
1053
|
+
return await this.transport.sendRequest("xyoViewer_accountBalance", [address]);
|
|
1201
1054
|
}
|
|
1202
1055
|
async blockByHash(hash) {
|
|
1203
|
-
return await this.transport.sendRequest("xyoViewer_blockByHash", [
|
|
1204
|
-
hash
|
|
1205
|
-
]);
|
|
1056
|
+
return await this.transport.sendRequest("xyoViewer_blockByHash", [hash]);
|
|
1206
1057
|
}
|
|
1207
1058
|
async blockByNumber(blockNumber) {
|
|
1208
|
-
return await this.transport.sendRequest("xyoViewer_blockByNumber", [
|
|
1209
|
-
blockNumber
|
|
1210
|
-
]);
|
|
1059
|
+
return await this.transport.sendRequest("xyoViewer_blockByNumber", [blockNumber]);
|
|
1211
1060
|
}
|
|
1212
1061
|
async blocksByHash(hash, limit) {
|
|
1213
|
-
return await this.transport.sendRequest("xyoViewer_blocksByHash", [
|
|
1214
|
-
hash,
|
|
1215
|
-
limit
|
|
1216
|
-
]);
|
|
1062
|
+
return await this.transport.sendRequest("xyoViewer_blocksByHash", [hash, limit]);
|
|
1217
1063
|
}
|
|
1218
1064
|
async chainId() {
|
|
1219
1065
|
return await this.transport.sendRequest("xyoViewer_chainId");
|
|
@@ -1228,34 +1074,23 @@ var JsonRpcXyoViewer = class {
|
|
|
1228
1074
|
return await this.transport.sendRequest("xyoViewer_currentBlockNumber");
|
|
1229
1075
|
}
|
|
1230
1076
|
async transactionByBlockHashAndIndex(blockHash, transactionIndex) {
|
|
1231
|
-
return await this.transport.sendRequest("xyoViewer_transactionByBlockHashAndIndex", [
|
|
1232
|
-
blockHash,
|
|
1233
|
-
transactionIndex
|
|
1234
|
-
]);
|
|
1077
|
+
return await this.transport.sendRequest("xyoViewer_transactionByBlockHashAndIndex", [blockHash, transactionIndex]);
|
|
1235
1078
|
}
|
|
1236
1079
|
async transactionByBlockNumberAndIndex(blockNumber, transactionIndex) {
|
|
1237
|
-
return await this.transport.sendRequest("xyoViewer_transactionByBlockNumberAndIndex", [
|
|
1238
|
-
blockNumber,
|
|
1239
|
-
transactionIndex
|
|
1240
|
-
]);
|
|
1080
|
+
return await this.transport.sendRequest("xyoViewer_transactionByBlockNumberAndIndex", [blockNumber, transactionIndex]);
|
|
1241
1081
|
}
|
|
1242
1082
|
async transactionByHash(transactionHash) {
|
|
1243
|
-
return await this.transport.sendRequest("xyoViewer_transactionByHash", [
|
|
1244
|
-
transactionHash
|
|
1245
|
-
]);
|
|
1083
|
+
return await this.transport.sendRequest("xyoViewer_transactionByHash", [transactionHash]);
|
|
1246
1084
|
}
|
|
1247
1085
|
};
|
|
1248
1086
|
|
|
1249
|
-
// src/provider/
|
|
1250
|
-
import { assertEx as
|
|
1251
|
-
import { PayloadBuilder as
|
|
1252
|
-
import { isAnyPayload } from "@xyo-network/payload-model";
|
|
1087
|
+
// src/provider/connection/XyoConnection.ts
|
|
1088
|
+
import { assertEx as assertEx4 } from "@xylabs/assert";
|
|
1089
|
+
import { PayloadBuilder as PayloadBuilder4 } from "@xyo-network/payload-builder";
|
|
1090
|
+
import { isAnyPayload as isAnyPayload4 } from "@xyo-network/payload-model";
|
|
1253
1091
|
import { defaultTransactionFees, isDataLakeProvider } from "@xyo-network/xl1-protocol";
|
|
1254
1092
|
import { HydratedTransactionWrapper } from "@xyo-network/xl1-wrappers";
|
|
1255
1093
|
var XyoConnection = class {
|
|
1256
|
-
static {
|
|
1257
|
-
__name(this, "XyoConnection");
|
|
1258
|
-
}
|
|
1259
1094
|
_network;
|
|
1260
1095
|
_runner;
|
|
1261
1096
|
_signer;
|
|
@@ -1274,6 +1109,7 @@ var XyoConnection = class {
|
|
|
1274
1109
|
get runner() {
|
|
1275
1110
|
return this._runner;
|
|
1276
1111
|
}
|
|
1112
|
+
/** @deprecated use signer from gateway instead */
|
|
1277
1113
|
get signer() {
|
|
1278
1114
|
return this._signer;
|
|
1279
1115
|
}
|
|
@@ -1293,10 +1129,17 @@ var XyoConnection = class {
|
|
|
1293
1129
|
fees
|
|
1294
1130
|
}))[0];
|
|
1295
1131
|
}
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1132
|
+
/** @deprecated use addPayloadsToChain from gateway instead */
|
|
1133
|
+
async submitTransaction(elevatedPayloads, additionalPayloads, {
|
|
1134
|
+
chain,
|
|
1135
|
+
exp,
|
|
1136
|
+
fees,
|
|
1137
|
+
from,
|
|
1138
|
+
nbf
|
|
1139
|
+
} = {}) {
|
|
1140
|
+
const viewer = assertEx4(this.viewer, () => "No viewer available");
|
|
1141
|
+
const signer = assertEx4(this.signer, () => "No signer available");
|
|
1142
|
+
const runner = assertEx4(this.runner, () => "No runner available");
|
|
1300
1143
|
const storage = this.storage;
|
|
1301
1144
|
const chainResolved = chain ?? await viewer.chainId();
|
|
1302
1145
|
if (chainResolved === void 0) throw new Error("Failed to determine chain");
|
|
@@ -1305,54 +1148,184 @@ var XyoConnection = class {
|
|
|
1305
1148
|
const feesResolved = fees ?? defaultTransactionFees;
|
|
1306
1149
|
const fromResolved = from ?? await signer.address();
|
|
1307
1150
|
if (fromResolved === void 0) throw new Error("Failed to determine from address");
|
|
1308
|
-
const signedTransaction =
|
|
1151
|
+
const signedTransaction = assertEx4(await signer.createSignedTransaction(
|
|
1152
|
+
chainResolved,
|
|
1153
|
+
elevatedPayloads,
|
|
1154
|
+
additionalPayloads,
|
|
1155
|
+
nbfResolved,
|
|
1156
|
+
expResolved,
|
|
1157
|
+
feesResolved,
|
|
1158
|
+
fromResolved
|
|
1159
|
+
), () => "Failed to create transaction");
|
|
1309
1160
|
const hydratedTransaction = [
|
|
1310
|
-
await
|
|
1311
|
-
await
|
|
1161
|
+
await PayloadBuilder4.addStorageMeta(signedTransaction),
|
|
1162
|
+
await PayloadBuilder4.addStorageMeta(elevatedPayloads)
|
|
1312
1163
|
];
|
|
1313
1164
|
if (isDataLakeProvider(storage)) {
|
|
1314
1165
|
const wrapper = await HydratedTransactionWrapper.parse(hydratedTransaction);
|
|
1315
|
-
await storage.add(Object.values(wrapper.externalPayloads).filter(
|
|
1166
|
+
await storage.add(Object.values(wrapper.externalPayloads).filter(isAnyPayload4));
|
|
1316
1167
|
}
|
|
1317
|
-
|
|
1168
|
+
assertEx4(await runner.broadcastTransaction(hydratedTransaction), () => "Failed to broadcast transaction");
|
|
1318
1169
|
return hydratedTransaction;
|
|
1319
1170
|
}
|
|
1320
1171
|
};
|
|
1321
1172
|
|
|
1322
|
-
// src/provider/
|
|
1173
|
+
// src/provider/connection/HttpRpcXyoConnection.ts
|
|
1323
1174
|
var HttpRpcXyoConnection = class extends XyoConnection {
|
|
1324
|
-
static {
|
|
1325
|
-
__name(this, "HttpRpcXyoConnection");
|
|
1326
|
-
}
|
|
1327
1175
|
constructor(params) {
|
|
1328
|
-
const {
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1176
|
+
const {
|
|
1177
|
+
account,
|
|
1178
|
+
endpoint,
|
|
1179
|
+
storage: storageParam
|
|
1180
|
+
} = params;
|
|
1181
|
+
const signer = isDefined3(account) ? new MemoryXyoSigner(account) : void 0;
|
|
1182
|
+
const transport = new HttpRpcTransport(endpoint, { ...XyoRunnerRpcSchemas, ...XyoViewerRpcSchemas });
|
|
1334
1183
|
const runner = new JsonRpcXyoRunner(transport);
|
|
1335
1184
|
const viewer = new JsonRpcXyoViewer(transport);
|
|
1185
|
+
const storage = isDataLakeProvider2(storageParam) ? storageParam : isString(storageParam) ? new HttpXyoDataLake(storageParam) : void 0;
|
|
1336
1186
|
super({
|
|
1337
1187
|
signer,
|
|
1338
1188
|
runner,
|
|
1339
|
-
viewer
|
|
1189
|
+
viewer,
|
|
1190
|
+
storage
|
|
1340
1191
|
});
|
|
1341
1192
|
}
|
|
1342
1193
|
};
|
|
1343
1194
|
var RpcXyoConnection = class extends HttpRpcXyoConnection {
|
|
1344
|
-
|
|
1345
|
-
|
|
1195
|
+
};
|
|
1196
|
+
|
|
1197
|
+
// src/provider/gateway/Abstract.ts
|
|
1198
|
+
import { assertEx as assertEx5 } from "@xylabs/assert";
|
|
1199
|
+
import { PayloadBuilder as PayloadBuilder5 } from "@xyo-network/payload-builder";
|
|
1200
|
+
import { buildUnsignedTransaction } from "@xyo-network/xl1-protocol-sdk";
|
|
1201
|
+
var AbstractXyoGateway = class {
|
|
1202
|
+
async addPayloadsToChain(onChain, offChain) {
|
|
1203
|
+
const connection = await this.connection();
|
|
1204
|
+
const viewer = assertEx5(connection.viewer, () => "No viewer available on connection");
|
|
1205
|
+
const signer = await this.signer();
|
|
1206
|
+
const chainId = await viewer.chainId();
|
|
1207
|
+
const nbf = await viewer.currentBlockNumber();
|
|
1208
|
+
const tx = await buildUnsignedTransaction(chainId, onChain, offChain, nbf, nbf + 1e3, await signer.address());
|
|
1209
|
+
const hash = await this.addTransactionToChain(tx);
|
|
1210
|
+
return [hash, tx];
|
|
1211
|
+
}
|
|
1212
|
+
async addTransactionToChain(tx) {
|
|
1213
|
+
const connection = await this.connection();
|
|
1214
|
+
const signer = await this.signer();
|
|
1215
|
+
const runner = assertEx5(connection.runner, () => "No runner available on connection");
|
|
1216
|
+
const signedTx = await signer.signTransaction(tx);
|
|
1217
|
+
return await runner.broadcastTransaction(
|
|
1218
|
+
[
|
|
1219
|
+
await PayloadBuilder5.addStorageMeta(signedTx[0]),
|
|
1220
|
+
await PayloadBuilder5.addStorageMeta(signedTx[1])
|
|
1221
|
+
]
|
|
1222
|
+
);
|
|
1223
|
+
}
|
|
1224
|
+
/** @deprecated use addPayloadsToChain instead */
|
|
1225
|
+
async submitTransaction(elevatedPayloads, additionalPayloads) {
|
|
1226
|
+
const connection = await this.connection();
|
|
1227
|
+
assertEx5(connection.submitTransaction, () => "Active connection does not support transaction submission");
|
|
1228
|
+
const tx = await connection.submitTransaction?.(elevatedPayloads, additionalPayloads);
|
|
1229
|
+
return assertEx5(tx, () => "Transaction submission failed");
|
|
1230
|
+
}
|
|
1231
|
+
};
|
|
1232
|
+
|
|
1233
|
+
// src/provider/gateway/MemoryXyoGateway.ts
|
|
1234
|
+
var MemoryXyoGateway = class extends AbstractXyoGateway {
|
|
1235
|
+
_connection;
|
|
1236
|
+
_signer;
|
|
1237
|
+
constructor(signer, connection) {
|
|
1238
|
+
super();
|
|
1239
|
+
this._signer = signer;
|
|
1240
|
+
this._connection = connection;
|
|
1241
|
+
}
|
|
1242
|
+
connection() {
|
|
1243
|
+
return this._connection;
|
|
1244
|
+
}
|
|
1245
|
+
signer() {
|
|
1246
|
+
return this._signer;
|
|
1247
|
+
}
|
|
1248
|
+
};
|
|
1249
|
+
|
|
1250
|
+
// src/provider/network/MemoryXyoNetwork.ts
|
|
1251
|
+
import { isUndefined } from "@xylabs/typeof";
|
|
1252
|
+
import { isNetworkStatus } from "@xyo-network/xl1-protocol";
|
|
1253
|
+
import axios from "axios";
|
|
1254
|
+
|
|
1255
|
+
// src/provider/network/lib/FailedNetworkStatusPayloads.ts
|
|
1256
|
+
import { NetworkStatusSchema } from "@xyo-network/xl1-protocol";
|
|
1257
|
+
var unknownStatus = {
|
|
1258
|
+
description: "Unknown Network Status",
|
|
1259
|
+
schema: NetworkStatusSchema,
|
|
1260
|
+
state: "unknown"
|
|
1261
|
+
};
|
|
1262
|
+
var errorStatus = {
|
|
1263
|
+
description: "Error Fetching Network Status",
|
|
1264
|
+
schema: NetworkStatusSchema,
|
|
1265
|
+
state: "unknown"
|
|
1266
|
+
};
|
|
1267
|
+
|
|
1268
|
+
// src/provider/network/lib/StatusNetworks.ts
|
|
1269
|
+
var MainNetworkStats = {
|
|
1270
|
+
id: "mainnet",
|
|
1271
|
+
statusUrl: "https://xyo.network/chain-network-status-mainnet.json"
|
|
1272
|
+
};
|
|
1273
|
+
var SequenceNetworkStats = {
|
|
1274
|
+
id: "sequence",
|
|
1275
|
+
statusUrl: "https://beta.xyo.network/chain-network-status-sequence.json"
|
|
1276
|
+
};
|
|
1277
|
+
var LocalNetworkStats = {
|
|
1278
|
+
id: "local",
|
|
1279
|
+
statusUrl: "http://localhost:3002/chain-network-status-local.json"
|
|
1280
|
+
};
|
|
1281
|
+
var StatusNetworks = {
|
|
1282
|
+
["mainnet"]: MainNetworkStats,
|
|
1283
|
+
["sequence"]: SequenceNetworkStats,
|
|
1284
|
+
["local"]: LocalNetworkStats
|
|
1285
|
+
};
|
|
1286
|
+
|
|
1287
|
+
// src/provider/network/MemoryXyoNetwork.ts
|
|
1288
|
+
var MemoryXyoNetwork = class {
|
|
1289
|
+
_networkId;
|
|
1290
|
+
constructor(networkId) {
|
|
1291
|
+
this._networkId = networkId;
|
|
1292
|
+
}
|
|
1293
|
+
async status() {
|
|
1294
|
+
const statusNetwork = StatusNetworks[this._networkId];
|
|
1295
|
+
if (isUndefined(statusNetwork)) {
|
|
1296
|
+
throw new Error(`Unknown status network ID: ${this._networkId}`);
|
|
1297
|
+
}
|
|
1298
|
+
return await this.makeRequest(statusNetwork.statusUrl);
|
|
1299
|
+
}
|
|
1300
|
+
async makeRequest(url) {
|
|
1301
|
+
try {
|
|
1302
|
+
const response = await axios.get(url);
|
|
1303
|
+
if (isNetworkStatus(response.data)) {
|
|
1304
|
+
return response.data;
|
|
1305
|
+
} else {
|
|
1306
|
+
if (response.status === 200) {
|
|
1307
|
+
console.error("Unknown network status response:", response.data);
|
|
1308
|
+
return unknownStatus;
|
|
1309
|
+
}
|
|
1310
|
+
return errorStatus;
|
|
1311
|
+
}
|
|
1312
|
+
} catch (error) {
|
|
1313
|
+
console.error("Error fetching network status:", error);
|
|
1314
|
+
return errorStatus;
|
|
1315
|
+
}
|
|
1346
1316
|
}
|
|
1347
1317
|
};
|
|
1348
1318
|
export {
|
|
1319
|
+
AbstractXyoDataLake,
|
|
1349
1320
|
AbstractXyoGateway,
|
|
1350
1321
|
AllRpcSchemas,
|
|
1322
|
+
ArchivistXyoDataLake,
|
|
1351
1323
|
CaveatTypesSchema,
|
|
1352
1324
|
CaveatsSchema,
|
|
1353
1325
|
ChainConnectionSchema,
|
|
1354
1326
|
HttpRpcTransport,
|
|
1355
1327
|
HttpRpcXyoConnection,
|
|
1328
|
+
HttpXyoDataLake,
|
|
1356
1329
|
InvokerPermissionSchema,
|
|
1357
1330
|
JsonRpcErrorCodes,
|
|
1358
1331
|
JsonRpcXyoRunner,
|