@xyo-network/xl1-rpc 1.24.28 → 1.24.30
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 +189 -35
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/provider/runner/JsonRpcRunner.d.ts.map +1 -1
- package/dist/neutral/provider/viewer/JsonRpcTransactionViewer/JsonRpcTransactionViewer.d.ts +116 -26
- package/dist/neutral/provider/viewer/JsonRpcTransactionViewer/JsonRpcTransactionViewer.d.ts.map +1 -1
- package/dist/neutral/provider/viewer/JsonRpcViewer.d.ts.map +1 -1
- package/dist/neutral/transport/PostMessage/PostMessageRpcTransport.d.ts +18 -0
- package/dist/neutral/transport/PostMessage/PostMessageRpcTransport.d.ts.map +1 -0
- package/dist/neutral/transport/PostMessage/SessionEnvelope.d.ts +7 -0
- package/dist/neutral/transport/PostMessage/SessionEnvelope.d.ts.map +1 -0
- package/dist/neutral/transport/PostMessage/bus/Abstract.d.ts +14 -0
- package/dist/neutral/transport/PostMessage/bus/Abstract.d.ts.map +1 -0
- package/dist/neutral/transport/PostMessage/bus/MessageBus.d.ts +12 -0
- package/dist/neutral/transport/PostMessage/bus/MessageBus.d.ts.map +1 -0
- package/dist/neutral/transport/PostMessage/bus/implementations/PostMessage.d.ts +9 -0
- package/dist/neutral/transport/PostMessage/bus/implementations/PostMessage.d.ts.map +1 -0
- package/dist/neutral/transport/PostMessage/bus/implementations/index.d.ts +2 -0
- package/dist/neutral/transport/PostMessage/bus/implementations/index.d.ts.map +1 -0
- package/dist/neutral/transport/PostMessage/bus/index.d.ts +5 -0
- package/dist/neutral/transport/PostMessage/bus/index.d.ts.map +1 -0
- package/dist/neutral/transport/PostMessage/bus/validators/hasSessionId.d.ts +5 -0
- package/dist/neutral/transport/PostMessage/bus/validators/hasSessionId.d.ts.map +1 -0
- package/dist/neutral/transport/PostMessage/bus/validators/index.d.ts +4 -0
- package/dist/neutral/transport/PostMessage/bus/validators/index.d.ts.map +1 -0
- package/dist/neutral/transport/PostMessage/bus/validators/isEventWithId.d.ts +9 -0
- package/dist/neutral/transport/PostMessage/bus/validators/isEventWithId.d.ts.map +1 -0
- package/dist/neutral/transport/PostMessage/bus/validators/isMessageWithId.d.ts +7 -0
- package/dist/neutral/transport/PostMessage/bus/validators/isMessageWithId.d.ts.map +1 -0
- package/dist/neutral/transport/PostMessage/helpers.d.ts +10 -0
- package/dist/neutral/transport/PostMessage/helpers.d.ts.map +1 -0
- package/dist/neutral/transport/PostMessage/index.d.ts +3 -0
- package/dist/neutral/transport/PostMessage/index.d.ts.map +1 -0
- package/dist/neutral/transport/index.d.ts +1 -0
- package/dist/neutral/transport/index.d.ts.map +1 -1
- package/dist/neutral/types/schema/AllRpcSchemas.d.ts +72 -24
- package/dist/neutral/types/schema/AllRpcSchemas.d.ts.map +1 -1
- package/dist/neutral/types/schema/TransactionViewerRpcSchema.d.ts +75 -24
- package/dist/neutral/types/schema/TransactionViewerRpcSchema.d.ts.map +1 -1
- package/dist/node/index-node.mjs +189 -35
- package/dist/node/index-node.mjs.map +1 -1
- package/dist/node/provider/runner/JsonRpcRunner.d.ts.map +1 -1
- package/dist/node/provider/viewer/JsonRpcTransactionViewer/JsonRpcTransactionViewer.d.ts +116 -26
- package/dist/node/provider/viewer/JsonRpcTransactionViewer/JsonRpcTransactionViewer.d.ts.map +1 -1
- package/dist/node/provider/viewer/JsonRpcViewer.d.ts.map +1 -1
- package/dist/node/transport/PostMessage/PostMessageRpcTransport.d.ts +18 -0
- package/dist/node/transport/PostMessage/PostMessageRpcTransport.d.ts.map +1 -0
- package/dist/node/transport/PostMessage/SessionEnvelope.d.ts +7 -0
- package/dist/node/transport/PostMessage/SessionEnvelope.d.ts.map +1 -0
- package/dist/node/transport/PostMessage/bus/Abstract.d.ts +14 -0
- package/dist/node/transport/PostMessage/bus/Abstract.d.ts.map +1 -0
- package/dist/node/transport/PostMessage/bus/MessageBus.d.ts +12 -0
- package/dist/node/transport/PostMessage/bus/MessageBus.d.ts.map +1 -0
- package/dist/node/transport/PostMessage/bus/implementations/PostMessage.d.ts +9 -0
- package/dist/node/transport/PostMessage/bus/implementations/PostMessage.d.ts.map +1 -0
- package/dist/node/transport/PostMessage/bus/implementations/index.d.ts +2 -0
- package/dist/node/transport/PostMessage/bus/implementations/index.d.ts.map +1 -0
- package/dist/node/transport/PostMessage/bus/index.d.ts +5 -0
- package/dist/node/transport/PostMessage/bus/index.d.ts.map +1 -0
- package/dist/node/transport/PostMessage/bus/validators/hasSessionId.d.ts +5 -0
- package/dist/node/transport/PostMessage/bus/validators/hasSessionId.d.ts.map +1 -0
- package/dist/node/transport/PostMessage/bus/validators/index.d.ts +4 -0
- package/dist/node/transport/PostMessage/bus/validators/index.d.ts.map +1 -0
- package/dist/node/transport/PostMessage/bus/validators/isEventWithId.d.ts +9 -0
- package/dist/node/transport/PostMessage/bus/validators/isEventWithId.d.ts.map +1 -0
- package/dist/node/transport/PostMessage/bus/validators/isMessageWithId.d.ts +7 -0
- package/dist/node/transport/PostMessage/bus/validators/isMessageWithId.d.ts.map +1 -0
- package/dist/node/transport/PostMessage/helpers.d.ts +10 -0
- package/dist/node/transport/PostMessage/helpers.d.ts.map +1 -0
- package/dist/node/transport/PostMessage/index.d.ts +3 -0
- package/dist/node/transport/PostMessage/index.d.ts.map +1 -0
- package/dist/node/transport/index.d.ts +1 -0
- package/dist/node/transport/index.d.ts.map +1 -1
- package/dist/node/types/schema/AllRpcSchemas.d.ts +72 -24
- package/dist/node/types/schema/AllRpcSchemas.d.ts.map +1 -1
- package/dist/node/types/schema/TransactionViewerRpcSchema.d.ts +75 -24
- package/dist/node/types/schema/TransactionViewerRpcSchema.d.ts.map +1 -1
- package/package.json +4 -3
- package/src/provider/runner/JsonRpcRunner.ts +6 -5
- package/src/provider/viewer/JsonRpcTransactionViewer/JsonRpcTransactionViewer.ts +4 -4
- package/src/provider/viewer/JsonRpcViewer.ts +5 -5
- package/src/transport/PostMessage/PostMessageRpcTransport.ts +112 -0
- package/src/transport/PostMessage/SessionEnvelope.ts +7 -0
- package/src/transport/PostMessage/bus/Abstract.ts +33 -0
- package/src/transport/PostMessage/bus/MessageBus.ts +12 -0
- package/src/transport/PostMessage/bus/implementations/PostMessage.ts +39 -0
- package/src/transport/PostMessage/bus/implementations/index.ts +1 -0
- package/src/transport/PostMessage/bus/index.ts +4 -0
- package/src/transport/PostMessage/bus/validators/hasSessionId.ts +9 -0
- package/src/transport/PostMessage/bus/validators/index.ts +3 -0
- package/src/transport/PostMessage/bus/validators/isEventWithId.ts +15 -0
- package/src/transport/PostMessage/bus/validators/isMessageWithId.ts +12 -0
- package/src/transport/PostMessage/helpers.ts +11 -0
- package/src/transport/PostMessage/index.ts +2 -0
- package/src/transport/index.ts +1 -0
- package/src/types/schema/TransactionViewerRpcSchema.ts +12 -9
package/dist/neutral/index.mjs
CHANGED
|
@@ -950,27 +950,29 @@ var TimeSyncViewerRpcSchemas = {
|
|
|
950
950
|
|
|
951
951
|
// src/types/schema/TransactionViewerRpcSchema.ts
|
|
952
952
|
import { HashZod as HashZod4 } from "@xylabs/sdk-js";
|
|
953
|
-
import {
|
|
953
|
+
import { SignedHydratedTransactionWithHashMetaZod as SignedHydratedTransactionWithHashMetaZod2 } from "@xyo-network/xl1-protocol";
|
|
954
954
|
import { z as z16 } from "zod";
|
|
955
955
|
var TransactionViewerRpcSchemas = {
|
|
956
|
+
/** @deprecated use byBlockHashAndIndex instead */
|
|
956
957
|
transactionViewer_transactionByBlockHashAndIndex: {
|
|
957
958
|
params: {
|
|
958
959
|
to: z16.tuple([HashZod4, z16.number()]),
|
|
959
960
|
from: z16.tuple([HashZod4, z16.number()])
|
|
960
961
|
},
|
|
961
962
|
result: {
|
|
962
|
-
to:
|
|
963
|
-
from:
|
|
963
|
+
to: SignedHydratedTransactionWithHashMetaZod2.nullable(),
|
|
964
|
+
from: SignedHydratedTransactionWithHashMetaZod2.nullable()
|
|
964
965
|
}
|
|
965
966
|
},
|
|
967
|
+
/** @deprecated use byBlockNumberAndIndex instead */
|
|
966
968
|
transactionViewer_transactionByBlockNumberAndIndex: {
|
|
967
969
|
params: {
|
|
968
970
|
to: z16.tuple([z16.number(), z16.number()]),
|
|
969
971
|
from: z16.tuple([z16.number(), z16.number()])
|
|
970
972
|
},
|
|
971
973
|
result: {
|
|
972
|
-
to:
|
|
973
|
-
from:
|
|
974
|
+
to: SignedHydratedTransactionWithHashMetaZod2.nullable(),
|
|
975
|
+
from: SignedHydratedTransactionWithHashMetaZod2.nullable()
|
|
974
976
|
}
|
|
975
977
|
},
|
|
976
978
|
transactionViewer_byHash: {
|
|
@@ -979,18 +981,19 @@ var TransactionViewerRpcSchemas = {
|
|
|
979
981
|
from: z16.tuple([HashZod4])
|
|
980
982
|
},
|
|
981
983
|
result: {
|
|
982
|
-
to:
|
|
983
|
-
from:
|
|
984
|
+
to: SignedHydratedTransactionWithHashMetaZod2.nullable(),
|
|
985
|
+
from: SignedHydratedTransactionWithHashMetaZod2.nullable()
|
|
984
986
|
}
|
|
985
987
|
},
|
|
988
|
+
/** @deprecated use byHash instead */
|
|
986
989
|
transactionViewer_transactionByHash: {
|
|
987
990
|
params: {
|
|
988
991
|
to: z16.tuple([HashZod4]),
|
|
989
992
|
from: z16.tuple([HashZod4])
|
|
990
993
|
},
|
|
991
994
|
result: {
|
|
992
|
-
to:
|
|
993
|
-
from:
|
|
995
|
+
to: SignedHydratedTransactionWithHashMetaZod2.nullable(),
|
|
996
|
+
from: SignedHydratedTransactionWithHashMetaZod2.nullable()
|
|
994
997
|
}
|
|
995
998
|
}
|
|
996
999
|
};
|
|
@@ -1037,13 +1040,13 @@ var XyoPermissionsRpcSchemas = {
|
|
|
1037
1040
|
|
|
1038
1041
|
// src/types/schema/XyoRunnerRpcSchemas.ts
|
|
1039
1042
|
import { HashToJsonZod, JsonToHashZod } from "@xylabs/sdk-js";
|
|
1040
|
-
import { SignedHydratedTransactionZod as
|
|
1043
|
+
import { SignedHydratedTransactionZod as SignedHydratedTransactionZod2 } from "@xyo-network/xl1-protocol";
|
|
1041
1044
|
import { z as z18 } from "zod";
|
|
1042
1045
|
var XyoRunnerRpcSchemas = {
|
|
1043
1046
|
xyoRunner_broadcastTransaction: {
|
|
1044
1047
|
params: {
|
|
1045
|
-
to: z18.tuple([
|
|
1046
|
-
from: z18.tuple([
|
|
1048
|
+
to: z18.tuple([SignedHydratedTransactionZod2]),
|
|
1049
|
+
from: z18.tuple([SignedHydratedTransactionZod2])
|
|
1047
1050
|
},
|
|
1048
1051
|
result: {
|
|
1049
1052
|
to: HashToJsonZod,
|
|
@@ -1054,7 +1057,7 @@ var XyoRunnerRpcSchemas = {
|
|
|
1054
1057
|
|
|
1055
1058
|
// src/types/schema/XyoSignerRpcSchemas.ts
|
|
1056
1059
|
import { AddressZod as AddressZod6 } from "@xylabs/sdk-js";
|
|
1057
|
-
import { SignedHydratedTransactionWithHashMetaZod as
|
|
1060
|
+
import { SignedHydratedTransactionWithHashMetaZod as SignedHydratedTransactionWithHashMetaZod3, UnsignedHydratedTransactionZod } from "@xyo-network/xl1-protocol";
|
|
1058
1061
|
import { z as z19 } from "zod";
|
|
1059
1062
|
var XyoSignerRpcSchemas = {
|
|
1060
1063
|
xyoSigner_address: {
|
|
@@ -1073,8 +1076,8 @@ var XyoSignerRpcSchemas = {
|
|
|
1073
1076
|
from: z19.tuple([UnsignedHydratedTransactionZod])
|
|
1074
1077
|
},
|
|
1075
1078
|
result: {
|
|
1076
|
-
to:
|
|
1077
|
-
from:
|
|
1079
|
+
to: SignedHydratedTransactionWithHashMetaZod3,
|
|
1080
|
+
from: SignedHydratedTransactionWithHashMetaZod3
|
|
1078
1081
|
}
|
|
1079
1082
|
}
|
|
1080
1083
|
};
|
|
@@ -1093,7 +1096,7 @@ import {
|
|
|
1093
1096
|
asAttoXL1 as asAttoXL16,
|
|
1094
1097
|
JsonToStakeZod as JsonToStakeZod3,
|
|
1095
1098
|
SignedHydratedBlockWithHashMetaZod as SignedHydratedBlockWithHashMetaZod3,
|
|
1096
|
-
SignedHydratedTransactionZod as
|
|
1099
|
+
SignedHydratedTransactionZod as SignedHydratedTransactionZod3,
|
|
1097
1100
|
StakeToJsonZod as StakeToJsonZod3,
|
|
1098
1101
|
StepIdentityZod as StepIdentityZod2,
|
|
1099
1102
|
XL1BlockNumberZod as XL1BlockNumberZod2,
|
|
@@ -1387,8 +1390,8 @@ var XyoViewerRpcSchemas = {
|
|
|
1387
1390
|
from: z20.tuple([HashZod5, z20.number()])
|
|
1388
1391
|
},
|
|
1389
1392
|
result: {
|
|
1390
|
-
to:
|
|
1391
|
-
from:
|
|
1393
|
+
to: SignedHydratedTransactionZod3.nullable(),
|
|
1394
|
+
from: SignedHydratedTransactionZod3.nullable()
|
|
1392
1395
|
}
|
|
1393
1396
|
},
|
|
1394
1397
|
xyoViewer_transactionByBlockNumberAndIndex: {
|
|
@@ -1397,8 +1400,8 @@ var XyoViewerRpcSchemas = {
|
|
|
1397
1400
|
from: z20.tuple([z20.number(), z20.number()])
|
|
1398
1401
|
},
|
|
1399
1402
|
result: {
|
|
1400
|
-
to:
|
|
1401
|
-
from:
|
|
1403
|
+
to: SignedHydratedTransactionZod3.nullable(),
|
|
1404
|
+
from: SignedHydratedTransactionZod3.nullable()
|
|
1402
1405
|
}
|
|
1403
1406
|
},
|
|
1404
1407
|
xyoViewer_transactionByHash: {
|
|
@@ -1407,8 +1410,8 @@ var XyoViewerRpcSchemas = {
|
|
|
1407
1410
|
from: z20.tuple([HashZod5])
|
|
1408
1411
|
},
|
|
1409
1412
|
result: {
|
|
1410
|
-
to:
|
|
1411
|
-
from:
|
|
1413
|
+
to: SignedHydratedTransactionZod3.nullable(),
|
|
1414
|
+
from: SignedHydratedTransactionZod3.nullable()
|
|
1412
1415
|
}
|
|
1413
1416
|
},
|
|
1414
1417
|
xyoViewer_payloadsByHash: {
|
|
@@ -1490,8 +1493,7 @@ import { creatableProvider } from "@xyo-network/xl1-protocol-sdk";
|
|
|
1490
1493
|
import { AccountBalanceViewerMoniker } from "@xyo-network/xl1-protocol";
|
|
1491
1494
|
|
|
1492
1495
|
// src/provider/viewer/JsonRpcViewer.ts
|
|
1493
|
-
import {
|
|
1494
|
-
import { AbstractCreatableProvider } from "@xyo-network/xl1-protocol-sdk";
|
|
1496
|
+
import { AbstractCreatableProvider, HttpRpcRemoteConfigZod } from "@xyo-network/xl1-protocol-sdk";
|
|
1495
1497
|
|
|
1496
1498
|
// src/transport/HttpRpcTransport.ts
|
|
1497
1499
|
import {
|
|
@@ -1588,6 +1590,151 @@ var MemoryRpcTransport = class {
|
|
|
1588
1590
|
}
|
|
1589
1591
|
};
|
|
1590
1592
|
|
|
1593
|
+
// src/transport/PostMessage/bus/Abstract.ts
|
|
1594
|
+
import { isDefined as isDefined2 } from "@xylabs/sdk-js";
|
|
1595
|
+
var AbstractMessageBus = class {
|
|
1596
|
+
connections = [];
|
|
1597
|
+
name;
|
|
1598
|
+
sessionId;
|
|
1599
|
+
constructor(sessionId, name = "default") {
|
|
1600
|
+
this.name = name;
|
|
1601
|
+
this.sessionId = sessionId;
|
|
1602
|
+
this.start();
|
|
1603
|
+
}
|
|
1604
|
+
addConnection(connection) {
|
|
1605
|
+
this.connections.push(connection);
|
|
1606
|
+
}
|
|
1607
|
+
removeConnection(connection) {
|
|
1608
|
+
this.connections = this.connections.filter((c) => c !== connection);
|
|
1609
|
+
}
|
|
1610
|
+
validateSessionId(sessionId) {
|
|
1611
|
+
return isDefined2(this.sessionId) && sessionId === this.sessionId;
|
|
1612
|
+
}
|
|
1613
|
+
};
|
|
1614
|
+
|
|
1615
|
+
// src/transport/PostMessage/bus/implementations/PostMessage.ts
|
|
1616
|
+
import { isDefined as isDefined3 } from "@xylabs/sdk-js";
|
|
1617
|
+
|
|
1618
|
+
// src/transport/PostMessage/bus/validators/hasSessionId.ts
|
|
1619
|
+
var hasSessionId = (message) => {
|
|
1620
|
+
return typeof message === "object" && message !== null && "sessionId" in message && typeof message.sessionId === "string";
|
|
1621
|
+
};
|
|
1622
|
+
|
|
1623
|
+
// src/transport/PostMessage/bus/validators/isEventWithId.ts
|
|
1624
|
+
var isEventWithId = (event) => {
|
|
1625
|
+
return typeof event === "object" && event !== null && "data" in event && typeof event.data === "object" && event.data !== null && "data" in event.data && typeof event.data.data === "object" && event.data.data !== null && "id" in event.data.data && typeof event.data.data.id === "string";
|
|
1626
|
+
};
|
|
1627
|
+
|
|
1628
|
+
// src/transport/PostMessage/bus/validators/isMessageWithId.ts
|
|
1629
|
+
var isMessageWithId = (message) => {
|
|
1630
|
+
return typeof message === "object" && message !== null && "data" in message && typeof message.data === "object" && message.data !== null && "id" in message.data && typeof message.data.id === "string";
|
|
1631
|
+
};
|
|
1632
|
+
|
|
1633
|
+
// src/transport/PostMessage/bus/implementations/PostMessage.ts
|
|
1634
|
+
var PostMessageBus = class extends AbstractMessageBus {
|
|
1635
|
+
constructor(sessionId, name = "default") {
|
|
1636
|
+
super(sessionId, name);
|
|
1637
|
+
}
|
|
1638
|
+
postMessage(message, origin = globalThis.location.origin) {
|
|
1639
|
+
globalThis.postMessage(message, origin);
|
|
1640
|
+
}
|
|
1641
|
+
start() {
|
|
1642
|
+
globalThis.addEventListener("message", (event) => this.handleMessage(event));
|
|
1643
|
+
}
|
|
1644
|
+
stop() {
|
|
1645
|
+
globalThis.removeEventListener("message", this.handleMessage);
|
|
1646
|
+
this.connections.length = 0;
|
|
1647
|
+
}
|
|
1648
|
+
handleMessage = (event) => {
|
|
1649
|
+
if (event.origin !== globalThis.location.origin) return;
|
|
1650
|
+
if (!this.validateSessionId(event.data?.sessionId)) return;
|
|
1651
|
+
for (const connection of this.connections) {
|
|
1652
|
+
const { id, listener } = connection;
|
|
1653
|
+
if (isDefined3(id) && isEventWithId(event)) {
|
|
1654
|
+
const eventWithId = event;
|
|
1655
|
+
if (eventWithId.data.data.id === id) listener(event);
|
|
1656
|
+
} else {
|
|
1657
|
+
listener(event);
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
};
|
|
1661
|
+
};
|
|
1662
|
+
|
|
1663
|
+
// src/transport/PostMessage/PostMessageRpcTransport.ts
|
|
1664
|
+
import {
|
|
1665
|
+
isJsonRpcFailure,
|
|
1666
|
+
isJsonRpcResponse,
|
|
1667
|
+
isJsonRpcSuccess
|
|
1668
|
+
} from "@metamask/utils";
|
|
1669
|
+
import { isDefined as isDefined4 } from "@xylabs/sdk-js";
|
|
1670
|
+
import { v4 as v43 } from "uuid";
|
|
1671
|
+
var PostMessageRpcTransport = class {
|
|
1672
|
+
_destination;
|
|
1673
|
+
_logger;
|
|
1674
|
+
_schemas;
|
|
1675
|
+
_sessionId;
|
|
1676
|
+
constructor(defaultDestination, schemas, sessionId, logger) {
|
|
1677
|
+
this._schemas = schemas;
|
|
1678
|
+
this._destination = defaultDestination;
|
|
1679
|
+
this._logger = logger;
|
|
1680
|
+
this._sessionId = sessionId;
|
|
1681
|
+
}
|
|
1682
|
+
get destination() {
|
|
1683
|
+
return this._destination;
|
|
1684
|
+
}
|
|
1685
|
+
get logger() {
|
|
1686
|
+
return this._logger;
|
|
1687
|
+
}
|
|
1688
|
+
get schemas() {
|
|
1689
|
+
return this._schemas;
|
|
1690
|
+
}
|
|
1691
|
+
get sessionId() {
|
|
1692
|
+
return this._sessionId;
|
|
1693
|
+
}
|
|
1694
|
+
async sendRequest(method, params) {
|
|
1695
|
+
const id = v43();
|
|
1696
|
+
return await this.callRpc(this.schemas, method, id, params);
|
|
1697
|
+
}
|
|
1698
|
+
async callRpc(schemas, method, id, params) {
|
|
1699
|
+
this.logger?.log(`PostMessageRpcTransport: callRpc method=${String(method)} id=${id}`);
|
|
1700
|
+
const body = {
|
|
1701
|
+
jsonrpc,
|
|
1702
|
+
id,
|
|
1703
|
+
method,
|
|
1704
|
+
params: isDefined4(params) && isDefined4(schemas[method]) ? schemas[method].params.to.parse(params) : params
|
|
1705
|
+
};
|
|
1706
|
+
return await new Promise((resolve, reject) => {
|
|
1707
|
+
const postMessageBus = new PostMessageBus(this.sessionId);
|
|
1708
|
+
const postMessageConnection = {
|
|
1709
|
+
listener: (event) => {
|
|
1710
|
+
if ("data" in event.data && isJsonRpcResponse(event.data.data)) {
|
|
1711
|
+
const response = event.data.data;
|
|
1712
|
+
if (isJsonRpcSuccess(response) && Array.isArray(response.result)) {
|
|
1713
|
+
const ret = schemas[method].result.from.parse(response.result[0]);
|
|
1714
|
+
resolve(ret);
|
|
1715
|
+
return;
|
|
1716
|
+
}
|
|
1717
|
+
if (isJsonRpcFailure(response)) {
|
|
1718
|
+
console.error("Error in PostMessageRpcTransport:", response);
|
|
1719
|
+
reject(new Error(response.error.message));
|
|
1720
|
+
return;
|
|
1721
|
+
}
|
|
1722
|
+
throw new Error(`Invalid response from wallet extension, ${JSON.stringify(event.data)}`);
|
|
1723
|
+
}
|
|
1724
|
+
},
|
|
1725
|
+
id
|
|
1726
|
+
};
|
|
1727
|
+
postMessageBus.addConnection(postMessageConnection);
|
|
1728
|
+
const message = {
|
|
1729
|
+
data: body,
|
|
1730
|
+
destination: this.destination,
|
|
1731
|
+
sessionId: this.sessionId ?? ""
|
|
1732
|
+
};
|
|
1733
|
+
postMessageBus.postMessage(message);
|
|
1734
|
+
});
|
|
1735
|
+
}
|
|
1736
|
+
};
|
|
1737
|
+
|
|
1591
1738
|
// src/provider/viewer/JsonRpcViewer.ts
|
|
1592
1739
|
var AbstractJsonRpcViewer = class extends AbstractCreatableProvider {
|
|
1593
1740
|
_transport;
|
|
@@ -1599,9 +1746,10 @@ var AbstractJsonRpcViewer = class extends AbstractCreatableProvider {
|
|
|
1599
1746
|
await super.createHandler();
|
|
1600
1747
|
}
|
|
1601
1748
|
createTransport() {
|
|
1602
|
-
const
|
|
1603
|
-
if (
|
|
1604
|
-
|
|
1749
|
+
const httpRemoteConfig = HttpRpcRemoteConfigZod.safeParse(this.config.remote);
|
|
1750
|
+
if (httpRemoteConfig.success) {
|
|
1751
|
+
const { url } = httpRemoteConfig.data.rpc;
|
|
1752
|
+
return new HttpRpcTransport(url, this.schemas());
|
|
1605
1753
|
}
|
|
1606
1754
|
throw new Error("Unable to create transport");
|
|
1607
1755
|
}
|
|
@@ -1665,7 +1813,7 @@ import {
|
|
|
1665
1813
|
} from "@xyo-network/xl1-protocol-sdk";
|
|
1666
1814
|
|
|
1667
1815
|
// src/provider/viewer/JsonRpcBlockViewer/JsonRpcBlockViewerMethods.ts
|
|
1668
|
-
import { isDefined as
|
|
1816
|
+
import { isDefined as isDefined5 } from "@xylabs/sdk-js";
|
|
1669
1817
|
import { BlockViewerMoniker, DataLakeViewerMoniker } from "@xyo-network/xl1-protocol";
|
|
1670
1818
|
import { addDataLakePayloads, addDataLakePayloadsToPayloads } from "@xyo-network/xl1-protocol-sdk";
|
|
1671
1819
|
var JsonRpcBlockViewerMethods = class extends AbstractJsonRpcViewer {
|
|
@@ -1674,14 +1822,14 @@ var JsonRpcBlockViewerMethods = class extends AbstractJsonRpcViewer {
|
|
|
1674
1822
|
async blocksByHash(hash, limit) {
|
|
1675
1823
|
const result = await this.transport.sendRequest(
|
|
1676
1824
|
"blockViewer_blocksByHash",
|
|
1677
|
-
|
|
1825
|
+
isDefined5(limit) ? [hash, limit] : [hash]
|
|
1678
1826
|
);
|
|
1679
1827
|
return await Promise.all(result.map(async (block) => (await addDataLakePayloads(block, this.dataLakeViewer))[0]));
|
|
1680
1828
|
}
|
|
1681
1829
|
async blocksByNumber(block, limit) {
|
|
1682
1830
|
const result = await this.transport.sendRequest(
|
|
1683
1831
|
"blockViewer_blocksByNumber",
|
|
1684
|
-
|
|
1832
|
+
isDefined5(limit) ? [block, limit] : [block]
|
|
1685
1833
|
);
|
|
1686
1834
|
return await Promise.all(result.map(async (block2) => (await addDataLakePayloads(block2, this.dataLakeViewer))[0]));
|
|
1687
1835
|
}
|
|
@@ -2407,8 +2555,7 @@ import { creatableProvider as creatableProvider13 } from "@xyo-network/xl1-proto
|
|
|
2407
2555
|
import { MempoolRunnerMoniker } from "@xyo-network/xl1-protocol";
|
|
2408
2556
|
|
|
2409
2557
|
// src/provider/runner/JsonRpcRunner.ts
|
|
2410
|
-
import {
|
|
2411
|
-
import { AbstractCreatableProvider as AbstractCreatableProvider2 } from "@xyo-network/xl1-protocol-sdk";
|
|
2558
|
+
import { AbstractCreatableProvider as AbstractCreatableProvider2, HttpRpcRemoteConfigZod as HttpRpcRemoteConfigZod2 } from "@xyo-network/xl1-protocol-sdk";
|
|
2412
2559
|
var AbstractJsonRpcRunner = class extends AbstractCreatableProvider2 {
|
|
2413
2560
|
get transport() {
|
|
2414
2561
|
return this.params.transport;
|
|
@@ -2418,9 +2565,10 @@ var AbstractJsonRpcRunner = class extends AbstractCreatableProvider2 {
|
|
|
2418
2565
|
await super.createHandler();
|
|
2419
2566
|
}
|
|
2420
2567
|
createTransport() {
|
|
2421
|
-
const
|
|
2422
|
-
if (
|
|
2423
|
-
|
|
2568
|
+
const httpRemoteConfig = HttpRpcRemoteConfigZod2.safeParse(this.config.remote);
|
|
2569
|
+
if (httpRemoteConfig.success) {
|
|
2570
|
+
const { url } = httpRemoteConfig.data.rpc;
|
|
2571
|
+
return new HttpRpcTransport(url, this.schemas());
|
|
2424
2572
|
}
|
|
2425
2573
|
throw new Error("Unable to create transport");
|
|
2426
2574
|
}
|
|
@@ -2584,6 +2732,7 @@ var JsonRpcXyoSigner = class extends JsonRpcXyoSignerMethods {
|
|
|
2584
2732
|
export {
|
|
2585
2733
|
AbstractJsonRpcRunner,
|
|
2586
2734
|
AbstractJsonRpcViewer,
|
|
2735
|
+
AbstractMessageBus,
|
|
2587
2736
|
AccountBalanceViewerRpcSchemas,
|
|
2588
2737
|
AllRpcSchemas,
|
|
2589
2738
|
BlockViewerRpcSchemas,
|
|
@@ -2635,6 +2784,8 @@ export {
|
|
|
2635
2784
|
NetworkStakingStepRewardsViewerRpcSchemas,
|
|
2636
2785
|
NoArgsZod,
|
|
2637
2786
|
NodeXyoRunner,
|
|
2787
|
+
PostMessageBus,
|
|
2788
|
+
PostMessageRpcTransport,
|
|
2638
2789
|
RpcXyoPermissions,
|
|
2639
2790
|
StakeTotalsViewerRpcSchemas,
|
|
2640
2791
|
StakeViewerRpcSchemas,
|
|
@@ -2646,6 +2797,9 @@ export {
|
|
|
2646
2797
|
XyoViewerRpcSchemas,
|
|
2647
2798
|
createRequestSchema,
|
|
2648
2799
|
createResponseSchema,
|
|
2800
|
+
hasSessionId,
|
|
2801
|
+
isEventWithId,
|
|
2802
|
+
isMessageWithId,
|
|
2649
2803
|
jsonrpc,
|
|
2650
2804
|
requestSchemas,
|
|
2651
2805
|
rpcMethodHandlersFromAccountBalanceViewer,
|