seismic-viem 2.0.0 → 2.0.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/README.md +5 -1
- package/dist/_cjs/index.js +498 -473
- package/dist/_esm/index.js +317 -299
- package/dist/_types/actions/encryption.d.ts +1 -1
- package/dist/_types/actions/wallet.d.ts +1 -1
- package/dist/_types/chain.d.ts +8 -158
- package/dist/_types/client.d.ts +2 -2
- package/dist/_types/contract/read.d.ts +1 -1
- package/dist/_types/contract/write.d.ts +1 -1
- package/dist/_types/crypto/aead.d.ts +1 -1
- package/dist/_types/extensions/depositContract.d.ts +38 -0
- package/dist/_types/extensions/faucet.d.ts +24 -0
- package/dist/_types/extensions/src20/crypto.d.ts +7 -0
- package/dist/_types/extensions/src20/directory.d.ts +8 -0
- package/dist/_types/extensions/src20/src20Actions.d.ts +42 -0
- package/dist/_types/extensions/src20/types.d.ts +34 -0
- package/dist/_types/extensions/src20/watchSRC20Events.d.ts +19 -0
- package/dist/_types/extensions/src20/watchSRC20EventsWithKey.d.ts +20 -0
- package/dist/_types/index.d.ts +18 -15
- package/dist/_types/tx/metadata.d.ts +81 -0
- package/dist/_types/tx/seismicRpc.d.ts +34 -0
- package/dist/_types/tx/seismicTx.d.ts +130 -0
- package/dist/_types/tx/sendShielded.d.ts +1 -1
- package/dist/_types/tx/signSeismicTypedData.d.ts +50 -0
- package/dist/_types/tx/signedCall.d.ts +1 -1
- package/dist/_types/tx/types.d.ts +1 -1
- package/package.json +1 -1
package/dist/_cjs/index.js
CHANGED
|
@@ -35,7 +35,6 @@ __export(exports_src, {
|
|
|
35
35
|
transparentWriteContract: () => transparentWriteContract,
|
|
36
36
|
transparentReadContract: () => transparentReadContract,
|
|
37
37
|
tokenExplorerUrl: () => tokenExplorerUrl,
|
|
38
|
-
stringifyBigInt: () => stringifyBigInt,
|
|
39
38
|
src20WalletActions: () => src20WalletActions,
|
|
40
39
|
src20PublicActions: () => src20PublicActions,
|
|
41
40
|
signedReadContract: () => signedReadContract,
|
|
@@ -51,6 +50,7 @@ __export(exports_src, {
|
|
|
51
50
|
seismicTestnet2: () => seismicTestnet2,
|
|
52
51
|
seismicTestnet1: () => seismicTestnet1,
|
|
53
52
|
seismicTestnet: () => seismicTestnet,
|
|
53
|
+
seismicRpcSchema: () => seismicRpcSchema,
|
|
54
54
|
seismicChainFormatters: () => seismicChainFormatters,
|
|
55
55
|
secp256k1SigPrecompile: () => secp256k1SigPrecompile,
|
|
56
56
|
secp256k1Sig: () => secp256k1Sig,
|
|
@@ -60,6 +60,9 @@ __export(exports_src, {
|
|
|
60
60
|
remapSeismicAbiInputs: () => remapSeismicAbiInputs,
|
|
61
61
|
registerKey: () => registerKey,
|
|
62
62
|
randomEncryptionNonce: () => randomEncryptionNonce,
|
|
63
|
+
parseMinBalance: () => parseMinBalance,
|
|
64
|
+
parseFaucetResponseHash: () => parseFaucetResponseHash,
|
|
65
|
+
parseEncryptedData: () => parseEncryptedData,
|
|
63
66
|
localSeismicDevnet: () => localSeismicDevnet,
|
|
64
67
|
hdfkPrecompile: () => hdfkPrecompile,
|
|
65
68
|
hdfk: () => hdfk,
|
|
@@ -71,12 +74,14 @@ __export(exports_src, {
|
|
|
71
74
|
getExplorerUrl: () => getExplorerUrl,
|
|
72
75
|
getEncryption: () => getEncryption,
|
|
73
76
|
generateAesKey: () => generateAesKey,
|
|
77
|
+
estimateGasRpcSchema: () => estimateGasRpcSchema,
|
|
74
78
|
encodeSeismicMetadataAsAAD: () => encodeSeismicMetadataAsAAD,
|
|
75
79
|
ecdhPrecompile: () => ecdhPrecompile,
|
|
76
80
|
ecdh: () => ecdh,
|
|
77
81
|
deriveAesKey: () => deriveAesKey,
|
|
78
82
|
createShieldedWalletClient: () => createShieldedWalletClient,
|
|
79
83
|
createShieldedPublicClient: () => createShieldedPublicClient,
|
|
84
|
+
createSeismicTestnet: () => createSeismicTestnet,
|
|
80
85
|
createSeismicGcpTestnet: () => createSeismicGcpTestnet,
|
|
81
86
|
createSeismicDevnet: () => createSeismicDevnet,
|
|
82
87
|
createSeismicAzTestnet: () => createSeismicAzTestnet,
|
|
@@ -84,6 +89,7 @@ __export(exports_src, {
|
|
|
84
89
|
compressPublicKey: () => compressPublicKey,
|
|
85
90
|
checkRegistration: () => checkRegistration,
|
|
86
91
|
checkFaucet: () => checkFaucet,
|
|
92
|
+
callRpcSchema: () => callRpcSchema,
|
|
87
93
|
buildTxSeismicMetadata: () => buildTxSeismicMetadata,
|
|
88
94
|
blockExplorerUrl: () => blockExplorerUrl,
|
|
89
95
|
aesGcmEncryptPrecompile: () => aesGcmEncryptPrecompile,
|
|
@@ -99,7 +105,7 @@ __export(exports_src, {
|
|
|
99
105
|
});
|
|
100
106
|
module.exports = __toCommonJS(exports_src);
|
|
101
107
|
|
|
102
|
-
// src/metadata.ts
|
|
108
|
+
// src/tx/metadata.ts
|
|
103
109
|
var import_accounts = require("viem/accounts");
|
|
104
110
|
|
|
105
111
|
// src/crypto/nonce.ts
|
|
@@ -199,7 +205,7 @@ var randomEncryptionNonce = () => {
|
|
|
199
205
|
return nonce;
|
|
200
206
|
};
|
|
201
207
|
|
|
202
|
-
// src/signSeismicTypedData.ts
|
|
208
|
+
// src/tx/signSeismicTypedData.ts
|
|
203
209
|
var import_viem2 = require("viem");
|
|
204
210
|
var import_actions = require("viem/actions");
|
|
205
211
|
var TYPED_DATA_MESSAGE_VERSION = 2;
|
|
@@ -288,7 +294,7 @@ var signSeismicTxTypedData = async (client, tx) => {
|
|
|
288
294
|
};
|
|
289
295
|
};
|
|
290
296
|
|
|
291
|
-
// src/metadata.ts
|
|
297
|
+
// src/tx/metadata.ts
|
|
292
298
|
var DEFAULT_SEISMIC_BLOCKS_WINDOW = 100n;
|
|
293
299
|
var fillNonce = async (client, parameters) => {
|
|
294
300
|
let account = import_accounts.parseAccount(parameters.account || client.account);
|
|
@@ -384,6 +390,12 @@ var buildTxSeismicMetadata = async (client, {
|
|
|
384
390
|
};
|
|
385
391
|
};
|
|
386
392
|
// src/chain.ts
|
|
393
|
+
var import_viem6 = require("viem");
|
|
394
|
+
|
|
395
|
+
// src/tx/seismicRpc.ts
|
|
396
|
+
var import_viem5 = require("viem");
|
|
397
|
+
|
|
398
|
+
// src/tx/seismicTx.ts
|
|
387
399
|
var import_viem4 = require("viem");
|
|
388
400
|
|
|
389
401
|
// src/viem-internal/signature.ts
|
|
@@ -411,7 +423,7 @@ function toYParitySignatureArray(transaction, signature_) {
|
|
|
411
423
|
return [yParity_, r === "0x00" ? "0x" : r, s === "0x00" ? "0x" : s];
|
|
412
424
|
}
|
|
413
425
|
|
|
414
|
-
// src/
|
|
426
|
+
// src/tx/seismicTx.ts
|
|
415
427
|
var SEISMIC_TX_TYPE = 74;
|
|
416
428
|
var serializeSeismicTransaction = (tx, signature) => {
|
|
417
429
|
const {
|
|
@@ -487,6 +499,8 @@ var serializeSeismicTransaction = (tx, signature) => {
|
|
|
487
499
|
const rlpEncoded = import_viem4.toRlp(rlpArray);
|
|
488
500
|
return import_viem4.concatHex([import_viem4.toHex(SEISMIC_TX_TYPE), rlpEncoded]);
|
|
489
501
|
};
|
|
502
|
+
|
|
503
|
+
// src/tx/seismicRpc.ts
|
|
490
504
|
var estimateGasRpcSchema = {
|
|
491
505
|
Method: "eth_estimateGas",
|
|
492
506
|
Parameters: ["SeismicTransactionRequest"],
|
|
@@ -505,15 +519,15 @@ var formatAuthorizationList = (authorizationList) => authorizationList.map((auth
|
|
|
505
519
|
address: authorization.contractAddress,
|
|
506
520
|
r: authorization.r,
|
|
507
521
|
s: authorization.s,
|
|
508
|
-
chainId:
|
|
509
|
-
nonce:
|
|
510
|
-
...typeof authorization.yParity !== "undefined" ? { yParity:
|
|
511
|
-
...typeof authorization.v !== "undefined" && typeof authorization.yParity === "undefined" ? { v:
|
|
522
|
+
chainId: import_viem5.toHex(authorization.chainId),
|
|
523
|
+
nonce: import_viem5.toHex(authorization.nonce),
|
|
524
|
+
...typeof authorization.yParity !== "undefined" ? { yParity: import_viem5.toHex(authorization.yParity) } : {},
|
|
525
|
+
...typeof authorization.v !== "undefined" && typeof authorization.yParity === "undefined" ? { v: import_viem5.toHex(authorization.v) } : {}
|
|
512
526
|
}));
|
|
513
|
-
var
|
|
527
|
+
var formatSeismicRpcRequest = (request) => {
|
|
514
528
|
if (request.type === "seismic") {
|
|
515
529
|
const { authorizationList, ...legacyCompatibleRequest } = request;
|
|
516
|
-
const seismicFmt =
|
|
530
|
+
const seismicFmt = import_viem5.formatTransactionRequest({
|
|
517
531
|
...legacyCompatibleRequest,
|
|
518
532
|
type: "legacy"
|
|
519
533
|
});
|
|
@@ -523,7 +537,7 @@ var fmtRpcRequest = (request) => {
|
|
|
523
537
|
...authorizationList ? { authorizationList: formatAuthorizationList(authorizationList) } : {}
|
|
524
538
|
};
|
|
525
539
|
}
|
|
526
|
-
const { type, ...fmt } =
|
|
540
|
+
const { type, ...fmt } = import_viem5.formatTransactionRequest(request);
|
|
527
541
|
if (hasSeismicFields(request)) {
|
|
528
542
|
return { ...fmt, type: SEISMIC_TX_TYPE };
|
|
529
543
|
}
|
|
@@ -532,8 +546,8 @@ var fmtRpcRequest = (request) => {
|
|
|
532
546
|
var seismicChainFormatters = {
|
|
533
547
|
transactionRequest: {
|
|
534
548
|
format: (request) => {
|
|
535
|
-
|
|
536
|
-
const formattedRpcRequest =
|
|
549
|
+
const chainId = request.chainId;
|
|
550
|
+
const formattedRpcRequest = formatSeismicRpcRequest(request);
|
|
537
551
|
if (request.type === "seismic") {
|
|
538
552
|
if (!request.encryptionNonce) {
|
|
539
553
|
throw new Error("Encryption nonce is required for seismic transactions");
|
|
@@ -554,7 +568,7 @@ var seismicChainFormatters = {
|
|
|
554
568
|
throw new Error("signedRead is required for seismic transaction requests");
|
|
555
569
|
}
|
|
556
570
|
}
|
|
557
|
-
|
|
571
|
+
return {
|
|
558
572
|
...formattedRpcRequest,
|
|
559
573
|
chainId,
|
|
560
574
|
encryptionPubkey: request.encryptionPubkey,
|
|
@@ -564,19 +578,20 @@ var seismicChainFormatters = {
|
|
|
564
578
|
expiresAtBlock: request.expiresAtBlock,
|
|
565
579
|
signedRead: request.signedRead
|
|
566
580
|
};
|
|
567
|
-
return fmtSeismicReq;
|
|
568
581
|
},
|
|
569
582
|
type: "transactionRequest"
|
|
570
583
|
}
|
|
571
584
|
};
|
|
585
|
+
|
|
586
|
+
// src/chain.ts
|
|
572
587
|
var createSeismicDevnet = ({
|
|
573
588
|
nodeHost,
|
|
574
589
|
explorerUrl
|
|
575
590
|
}) => {
|
|
576
591
|
if (!nodeHost) {
|
|
577
|
-
throw new Error("Must set `nodeHost` argument, e.g.
|
|
592
|
+
throw new Error("Must set `nodeHost` argument, e.g. testnet-1.seismictest.net");
|
|
578
593
|
}
|
|
579
|
-
return
|
|
594
|
+
return import_viem6.defineChain({
|
|
580
595
|
id: 5124,
|
|
581
596
|
name: "Seismic",
|
|
582
597
|
nativeCurrency: { decimals: 18, name: "Ether", symbol: "ETH" },
|
|
@@ -604,12 +619,16 @@ var createSeismicGcpTestnet = (n) => createSeismicDevnet({
|
|
|
604
619
|
nodeHost: `gcp-${n}.seismictest.net`,
|
|
605
620
|
explorerUrl: "https://seismic-testnet.socialscan.io"
|
|
606
621
|
});
|
|
622
|
+
var createSeismicTestnet = (n) => createSeismicDevnet({
|
|
623
|
+
nodeHost: `testnet-${n}.seismictest.net`,
|
|
624
|
+
explorerUrl: "https://seismic-testnet.socialscan.io"
|
|
625
|
+
});
|
|
607
626
|
var seismicTestnetGcp1 = createSeismicGcpTestnet(1);
|
|
608
627
|
var seismicTestnetGcp2 = createSeismicGcpTestnet(2);
|
|
609
|
-
var seismicTestnet1 =
|
|
610
|
-
var seismicTestnet2 =
|
|
628
|
+
var seismicTestnet1 = createSeismicTestnet(1);
|
|
629
|
+
var seismicTestnet2 = createSeismicTestnet(2);
|
|
611
630
|
var seismicTestnet = seismicTestnet1;
|
|
612
|
-
var localSeismicDevnet = /* @__PURE__ */
|
|
631
|
+
var localSeismicDevnet = /* @__PURE__ */ import_viem6.defineChain({
|
|
613
632
|
id: 5124,
|
|
614
633
|
name: "Seismic",
|
|
615
634
|
nativeCurrency: { decimals: 18, name: "Ether", symbol: "ETH" },
|
|
@@ -622,7 +641,7 @@ var localSeismicDevnet = /* @__PURE__ */ import_viem4.defineChain({
|
|
|
622
641
|
formatters: seismicChainFormatters,
|
|
623
642
|
testnet: true
|
|
624
643
|
});
|
|
625
|
-
var sanvil = /* @__PURE__ */
|
|
644
|
+
var sanvil = /* @__PURE__ */ import_viem6.defineChain({
|
|
626
645
|
id: 31337,
|
|
627
646
|
name: "Anvil",
|
|
628
647
|
nativeCurrency: { decimals: 18, name: "Ether", symbol: "ETH" },
|
|
@@ -636,15 +655,15 @@ var sanvil = /* @__PURE__ */ import_viem4.defineChain({
|
|
|
636
655
|
testnet: true
|
|
637
656
|
});
|
|
638
657
|
// src/contract/contract.ts
|
|
639
|
-
var
|
|
658
|
+
var import_viem15 = require("viem");
|
|
640
659
|
|
|
641
660
|
// src/contract/read.ts
|
|
642
|
-
var
|
|
661
|
+
var import_viem11 = require("viem");
|
|
643
662
|
var import_actions3 = require("viem/actions");
|
|
644
663
|
var import_utils2 = require("viem/utils");
|
|
645
664
|
|
|
646
665
|
// src/contract/abi.ts
|
|
647
|
-
var
|
|
666
|
+
var import_viem7 = require("viem");
|
|
648
667
|
var isAnyTrue = (bools) => bools.reduce((acc, val) => acc || val, false);
|
|
649
668
|
var remapSeismicParam = (param) => {
|
|
650
669
|
const ty = param.type;
|
|
@@ -689,7 +708,7 @@ var remapSeismicParam = (param) => {
|
|
|
689
708
|
return { shielded: false, type: ty };
|
|
690
709
|
};
|
|
691
710
|
function hasShieldedParams(abi, functionName) {
|
|
692
|
-
const abiItem =
|
|
711
|
+
const abiItem = import_viem7.getAbiItem({ abi, name: functionName });
|
|
693
712
|
if (!abiItem?.inputs)
|
|
694
713
|
return false;
|
|
695
714
|
return abiItem.inputs.some((param) => remapSeismicParam(param).shielded);
|
|
@@ -707,14 +726,14 @@ var remapSeismicAbiInputs = (abiFunction) => {
|
|
|
707
726
|
};
|
|
708
727
|
|
|
709
728
|
// src/tx/signedCall.ts
|
|
710
|
-
var
|
|
729
|
+
var import_viem10 = require("viem");
|
|
711
730
|
var import_actions2 = require("viem/actions");
|
|
712
731
|
var import_utils = require("viem/utils");
|
|
713
732
|
|
|
714
733
|
// src/error/signedCall.ts
|
|
715
|
-
var
|
|
734
|
+
var import_viem8 = require("viem");
|
|
716
735
|
|
|
717
|
-
class SignedCallError extends
|
|
736
|
+
class SignedCallError extends import_viem8.BaseError {
|
|
718
737
|
constructor({
|
|
719
738
|
docsPath,
|
|
720
739
|
metaMessages,
|
|
@@ -729,9 +748,9 @@ class SignedCallError extends import_viem6.BaseError {
|
|
|
729
748
|
}
|
|
730
749
|
|
|
731
750
|
// src/viem-internal/call.ts
|
|
732
|
-
var
|
|
751
|
+
var import_viem9 = require("viem");
|
|
733
752
|
function getRevertErrorData(err) {
|
|
734
|
-
if (!(err instanceof
|
|
753
|
+
if (!(err instanceof import_viem9.BaseError))
|
|
735
754
|
return;
|
|
736
755
|
const error = err.walk();
|
|
737
756
|
return typeof error?.data === "object" ? error.data?.data : error.data;
|
|
@@ -789,7 +808,7 @@ async function signedCall(client, args, {
|
|
|
789
808
|
} = args;
|
|
790
809
|
const account = prepareAccount(account_, client.account);
|
|
791
810
|
if (!to) {
|
|
792
|
-
throw new
|
|
811
|
+
throw new import_viem10.BaseError("Signed calls must set 'to' address");
|
|
793
812
|
}
|
|
794
813
|
try {
|
|
795
814
|
const assertRequestParams = {
|
|
@@ -799,8 +818,8 @@ async function signedCall(client, args, {
|
|
|
799
818
|
maxPriorityFeePerGas,
|
|
800
819
|
to: args.to
|
|
801
820
|
};
|
|
802
|
-
|
|
803
|
-
const blockNumberHex = blockNumber ?
|
|
821
|
+
import_viem10.assertRequest(assertRequestParams);
|
|
822
|
+
const blockNumberHex = blockNumber ? import_viem10.numberToHex(blockNumber) : undefined;
|
|
804
823
|
const block = blockNumberHex || blockTag;
|
|
805
824
|
const chainFormat = client.chain?.formatters?.transactionRequest?.format;
|
|
806
825
|
const fromAddress = account?.address;
|
|
@@ -852,8 +871,8 @@ async function signedCall(client, args, {
|
|
|
852
871
|
return { data: decryptedResponse };
|
|
853
872
|
} catch (err) {
|
|
854
873
|
const data = getRevertErrorData(err);
|
|
855
|
-
if (client.ccipRead !== false && data?.slice(0, 10) ===
|
|
856
|
-
return { data: await
|
|
874
|
+
if (client.ccipRead !== false && data?.slice(0, 10) === import_viem10.offchainLookupSignature && to)
|
|
875
|
+
return { data: await import_viem10.offchainLookup(client, { data, to }) };
|
|
857
876
|
throw import_utils.getCallError(err, {
|
|
858
877
|
account,
|
|
859
878
|
chain: client.chain,
|
|
@@ -892,10 +911,10 @@ async function signedReadContract(client, parameters, securityParams) {
|
|
|
892
911
|
address,
|
|
893
912
|
...rest
|
|
894
913
|
} = parameters;
|
|
895
|
-
const seismicAbi =
|
|
896
|
-
const selector =
|
|
914
|
+
const seismicAbi = import_viem11.getAbiItem({ abi, name: functionName });
|
|
915
|
+
const selector = import_viem11.toFunctionSelector(import_utils2.formatAbiItem(seismicAbi));
|
|
897
916
|
const ethAbi = remapSeismicAbiInputs(seismicAbi);
|
|
898
|
-
const encodedParams =
|
|
917
|
+
const encodedParams = import_viem11.encodeAbiParameters(ethAbi.inputs, args).slice(2);
|
|
899
918
|
const plaintextCalldata = `${selector}${encodedParams}`;
|
|
900
919
|
const request = {
|
|
901
920
|
...rest,
|
|
@@ -903,7 +922,7 @@ async function signedReadContract(client, parameters, securityParams) {
|
|
|
903
922
|
data: plaintextCalldata
|
|
904
923
|
};
|
|
905
924
|
const { data } = await signedCall(client, request, securityParams);
|
|
906
|
-
return
|
|
925
|
+
return import_viem11.decodeFunctionResult({
|
|
907
926
|
abi,
|
|
908
927
|
args,
|
|
909
928
|
functionName,
|
|
@@ -918,10 +937,10 @@ async function transparentReadContract(client, parameters) {
|
|
|
918
937
|
address,
|
|
919
938
|
...rest
|
|
920
939
|
} = parameters;
|
|
921
|
-
const seismicAbi =
|
|
922
|
-
const selector =
|
|
940
|
+
const seismicAbi = import_viem11.getAbiItem({ abi, name: functionName });
|
|
941
|
+
const selector = import_viem11.toFunctionSelector(import_utils2.formatAbiItem(seismicAbi));
|
|
923
942
|
const ethAbi = remapSeismicAbiInputs(seismicAbi);
|
|
924
|
-
const encodedParams =
|
|
943
|
+
const encodedParams = import_viem11.encodeAbiParameters(ethAbi.inputs, args).slice(2);
|
|
925
944
|
const data = `${selector}${encodedParams}`;
|
|
926
945
|
const callOptions = rest;
|
|
927
946
|
const { data: result } = await client.call({
|
|
@@ -929,7 +948,7 @@ async function transparentReadContract(client, parameters) {
|
|
|
929
948
|
data,
|
|
930
949
|
...callOptions
|
|
931
950
|
});
|
|
932
|
-
return
|
|
951
|
+
return import_viem11.decodeFunctionResult({
|
|
933
952
|
abi,
|
|
934
953
|
args,
|
|
935
954
|
functionName,
|
|
@@ -938,18 +957,18 @@ async function transparentReadContract(client, parameters) {
|
|
|
938
957
|
}
|
|
939
958
|
|
|
940
959
|
// src/contract/write.ts
|
|
941
|
-
var
|
|
960
|
+
var import_viem14 = require("viem");
|
|
942
961
|
var import_actions5 = require("viem/actions");
|
|
943
962
|
|
|
944
963
|
// src/contract/calldata.ts
|
|
945
|
-
var
|
|
964
|
+
var import_viem12 = require("viem");
|
|
946
965
|
var import_utils3 = require("viem/utils");
|
|
947
966
|
var getPlaintextCalldata = (parameters) => {
|
|
948
967
|
const { abi, functionName, args = [] } = parameters;
|
|
949
|
-
const seismicAbi =
|
|
950
|
-
const selector =
|
|
968
|
+
const seismicAbi = import_viem12.getAbiItem({ abi, name: functionName });
|
|
969
|
+
const selector = import_viem12.toFunctionSelector(import_utils3.formatAbiItem(seismicAbi));
|
|
951
970
|
const ethAbi = remapSeismicAbiInputs(seismicAbi);
|
|
952
|
-
const encodedParams =
|
|
971
|
+
const encodedParams = import_viem12.encodeAbiParameters(ethAbi.inputs, args).slice(2);
|
|
953
972
|
return `${selector}${encodedParams}`;
|
|
954
973
|
};
|
|
955
974
|
|
|
@@ -959,9 +978,9 @@ var import_actions4 = require("viem/actions");
|
|
|
959
978
|
var import_utils4 = require("viem/utils");
|
|
960
979
|
|
|
961
980
|
// src/error/account.ts
|
|
962
|
-
var
|
|
981
|
+
var import_viem13 = require("viem");
|
|
963
982
|
|
|
964
|
-
class AccountNotFoundError extends
|
|
983
|
+
class AccountNotFoundError extends import_viem13.BaseError {
|
|
965
984
|
constructor({ docsPath } = {}) {
|
|
966
985
|
super([
|
|
967
986
|
"Could not find an Account to execute with this Action.",
|
|
@@ -975,7 +994,7 @@ class AccountNotFoundError extends import_viem11.BaseError {
|
|
|
975
994
|
}
|
|
976
995
|
}
|
|
977
996
|
|
|
978
|
-
class AccountTypeNotSupportedError extends
|
|
997
|
+
class AccountTypeNotSupportedError extends import_viem13.BaseError {
|
|
979
998
|
constructor({
|
|
980
999
|
docsPath,
|
|
981
1000
|
metaMessages,
|
|
@@ -1210,14 +1229,14 @@ async function shieldedWriteContractDebug(client, parameters, checkContractDeplo
|
|
|
1210
1229
|
plaintextTx: {
|
|
1211
1230
|
to: request.to || null,
|
|
1212
1231
|
data: plaintextCalldata,
|
|
1213
|
-
type:
|
|
1232
|
+
type: import_viem14.numberToHex(SEISMIC_TX_TYPE),
|
|
1214
1233
|
nonce: request.nonce,
|
|
1215
1234
|
gas: request.gas,
|
|
1216
1235
|
gasPrice: request.gasPrice,
|
|
1217
1236
|
value: request.value
|
|
1218
1237
|
},
|
|
1219
1238
|
shieldedTx: {
|
|
1220
|
-
type:
|
|
1239
|
+
type: import_viem14.numberToHex(SEISMIC_TX_TYPE),
|
|
1221
1240
|
...request,
|
|
1222
1241
|
...metadata.seismicElements
|
|
1223
1242
|
},
|
|
@@ -1252,7 +1271,7 @@ function getShieldedContract({
|
|
|
1252
1271
|
address,
|
|
1253
1272
|
client
|
|
1254
1273
|
}) {
|
|
1255
|
-
const viemContract =
|
|
1274
|
+
const viemContract = import_viem15.getContract({ abi, address, client });
|
|
1256
1275
|
const walletClient = (() => {
|
|
1257
1276
|
if (!client)
|
|
1258
1277
|
return;
|
|
@@ -1459,128 +1478,11 @@ function getShieldedContract({
|
|
|
1459
1478
|
return contract;
|
|
1460
1479
|
}
|
|
1461
1480
|
// src/client.ts
|
|
1462
|
-
var
|
|
1481
|
+
var import_viem26 = require("viem");
|
|
1463
1482
|
var import_accounts4 = require("viem/accounts");
|
|
1464
1483
|
|
|
1465
|
-
// src/actions/depositContract.ts
|
|
1466
|
-
var import_actions6 = require("viem/actions");
|
|
1467
|
-
|
|
1468
|
-
// src/abis/depositContract.ts
|
|
1469
|
-
var depositContractAbi = [
|
|
1470
|
-
{
|
|
1471
|
-
type: "constructor",
|
|
1472
|
-
inputs: [],
|
|
1473
|
-
stateMutability: "nonpayable"
|
|
1474
|
-
},
|
|
1475
|
-
{
|
|
1476
|
-
type: "function",
|
|
1477
|
-
name: "deposit",
|
|
1478
|
-
inputs: [
|
|
1479
|
-
{ name: "node_pubkey", type: "bytes", internalType: "bytes" },
|
|
1480
|
-
{ name: "consensus_pubkey", type: "bytes", internalType: "bytes" },
|
|
1481
|
-
{ name: "withdrawal_credentials", type: "bytes", internalType: "bytes" },
|
|
1482
|
-
{ name: "node_signature", type: "bytes", internalType: "bytes" },
|
|
1483
|
-
{ name: "consensus_signature", type: "bytes", internalType: "bytes" },
|
|
1484
|
-
{ name: "deposit_data_root", type: "bytes32", internalType: "bytes32" }
|
|
1485
|
-
],
|
|
1486
|
-
outputs: [],
|
|
1487
|
-
stateMutability: "payable"
|
|
1488
|
-
},
|
|
1489
|
-
{
|
|
1490
|
-
type: "function",
|
|
1491
|
-
name: "get_deposit_count",
|
|
1492
|
-
inputs: [],
|
|
1493
|
-
outputs: [{ name: "", type: "bytes", internalType: "bytes" }],
|
|
1494
|
-
stateMutability: "view"
|
|
1495
|
-
},
|
|
1496
|
-
{
|
|
1497
|
-
type: "function",
|
|
1498
|
-
name: "get_deposit_root",
|
|
1499
|
-
inputs: [],
|
|
1500
|
-
outputs: [{ name: "", type: "bytes32", internalType: "bytes32" }],
|
|
1501
|
-
stateMutability: "view"
|
|
1502
|
-
},
|
|
1503
|
-
{
|
|
1504
|
-
type: "function",
|
|
1505
|
-
name: "supportsInterface",
|
|
1506
|
-
inputs: [{ name: "interfaceId", type: "bytes4", internalType: "bytes4" }],
|
|
1507
|
-
outputs: [{ name: "", type: "bool", internalType: "bool" }],
|
|
1508
|
-
stateMutability: "pure"
|
|
1509
|
-
},
|
|
1510
|
-
{
|
|
1511
|
-
type: "event",
|
|
1512
|
-
name: "DepositEvent",
|
|
1513
|
-
inputs: [
|
|
1514
|
-
{
|
|
1515
|
-
name: "node_pubkey",
|
|
1516
|
-
type: "bytes",
|
|
1517
|
-
indexed: false,
|
|
1518
|
-
internalType: "bytes"
|
|
1519
|
-
},
|
|
1520
|
-
{
|
|
1521
|
-
name: "consensus_pubkey",
|
|
1522
|
-
type: "bytes",
|
|
1523
|
-
indexed: false,
|
|
1524
|
-
internalType: "bytes"
|
|
1525
|
-
},
|
|
1526
|
-
{
|
|
1527
|
-
name: "withdrawal_credentials",
|
|
1528
|
-
type: "bytes",
|
|
1529
|
-
indexed: false,
|
|
1530
|
-
internalType: "bytes"
|
|
1531
|
-
},
|
|
1532
|
-
{ name: "amount", type: "bytes", indexed: false, internalType: "bytes" },
|
|
1533
|
-
{
|
|
1534
|
-
name: "node_signature",
|
|
1535
|
-
type: "bytes",
|
|
1536
|
-
indexed: false,
|
|
1537
|
-
internalType: "bytes"
|
|
1538
|
-
},
|
|
1539
|
-
{
|
|
1540
|
-
name: "consensus_signature",
|
|
1541
|
-
type: "bytes",
|
|
1542
|
-
indexed: false,
|
|
1543
|
-
internalType: "bytes"
|
|
1544
|
-
},
|
|
1545
|
-
{ name: "index", type: "bytes", indexed: false, internalType: "bytes" }
|
|
1546
|
-
],
|
|
1547
|
-
anonymous: false
|
|
1548
|
-
}
|
|
1549
|
-
];
|
|
1550
|
-
|
|
1551
|
-
// src/actions/depositContract.ts
|
|
1552
|
-
var DEPOSIT_CONTRACT_ADDRESS = "0x00000000219ab540356cBB839Cbe05303d7705Fa";
|
|
1553
|
-
var depositContractPublicActions = (client) => ({
|
|
1554
|
-
getDepositRoot: async (args) => import_actions6.readContract(client, {
|
|
1555
|
-
abi: depositContractAbi,
|
|
1556
|
-
address: args.address || DEPOSIT_CONTRACT_ADDRESS,
|
|
1557
|
-
functionName: "get_deposit_root"
|
|
1558
|
-
}),
|
|
1559
|
-
getDepositCount: async (args) => import_actions6.readContract(client, {
|
|
1560
|
-
abi: depositContractAbi,
|
|
1561
|
-
address: args.address || DEPOSIT_CONTRACT_ADDRESS,
|
|
1562
|
-
functionName: "get_deposit_count"
|
|
1563
|
-
})
|
|
1564
|
-
});
|
|
1565
|
-
var depositContractWalletActions = (client) => ({
|
|
1566
|
-
deposit: async (args) => import_actions6.writeContract(client, {
|
|
1567
|
-
abi: depositContractAbi,
|
|
1568
|
-
address: args.address || DEPOSIT_CONTRACT_ADDRESS,
|
|
1569
|
-
functionName: "deposit",
|
|
1570
|
-
args: [
|
|
1571
|
-
args.nodePubkey,
|
|
1572
|
-
args.consensusPubkey,
|
|
1573
|
-
args.withdrawalCredentials,
|
|
1574
|
-
args.nodeSignature,
|
|
1575
|
-
args.consensusSignature,
|
|
1576
|
-
args.depositDataRoot
|
|
1577
|
-
],
|
|
1578
|
-
value: args.value
|
|
1579
|
-
})
|
|
1580
|
-
});
|
|
1581
|
-
|
|
1582
1484
|
// src/crypto/aead.ts
|
|
1583
|
-
var
|
|
1485
|
+
var import_viem16 = require("viem");
|
|
1584
1486
|
var encodeSeismicMetadataAsAAD = ({
|
|
1585
1487
|
sender,
|
|
1586
1488
|
legacyFields: { chainId, nonce, to, value },
|
|
@@ -1595,22 +1497,22 @@ var encodeSeismicMetadataAsAAD = ({
|
|
|
1595
1497
|
}) => {
|
|
1596
1498
|
const fields = [
|
|
1597
1499
|
sender,
|
|
1598
|
-
|
|
1599
|
-
nonce === 0 ? "0x" :
|
|
1500
|
+
import_viem16.toHex(chainId),
|
|
1501
|
+
nonce === 0 ? "0x" : import_viem16.toHex(nonce),
|
|
1600
1502
|
to ?? "0x",
|
|
1601
|
-
value === 0n ? "0x" :
|
|
1503
|
+
value === 0n ? "0x" : import_viem16.toHex(value),
|
|
1602
1504
|
encryptionPubkey,
|
|
1603
1505
|
encryptionNonce === "0x00" || encryptionNonce === "0x0" ? "0x" : encryptionNonce,
|
|
1604
|
-
messageVersion === 0 ? "0x" :
|
|
1506
|
+
messageVersion === 0 ? "0x" : import_viem16.toHex(messageVersion),
|
|
1605
1507
|
recentBlockHash,
|
|
1606
|
-
|
|
1508
|
+
import_viem16.toHex(expiresAtBlock),
|
|
1607
1509
|
signedRead ? "0x01" : "0x"
|
|
1608
1510
|
];
|
|
1609
|
-
return
|
|
1511
|
+
return import_viem16.toRlp(fields, "bytes");
|
|
1610
1512
|
};
|
|
1611
1513
|
|
|
1612
1514
|
// src/crypto/aes.ts
|
|
1613
|
-
var
|
|
1515
|
+
var import_viem17 = require("viem");
|
|
1614
1516
|
|
|
1615
1517
|
// ../../node_modules/@noble/hashes/esm/_assert.js
|
|
1616
1518
|
function anumber2(n) {
|
|
@@ -3687,7 +3589,7 @@ class AesGcmCrypto {
|
|
|
3687
3589
|
U64_SIZE = 8;
|
|
3688
3590
|
constructor(key) {
|
|
3689
3591
|
this.key = key;
|
|
3690
|
-
const keyBuffer =
|
|
3592
|
+
const keyBuffer = import_viem17.hexToBytes(key);
|
|
3691
3593
|
if (keyBuffer.length !== 32) {
|
|
3692
3594
|
throw new Error("Key must be 32 bytes (256 bits)");
|
|
3693
3595
|
}
|
|
@@ -3702,34 +3604,34 @@ class AesGcmCrypto {
|
|
|
3702
3604
|
return nonceBuffer;
|
|
3703
3605
|
}
|
|
3704
3606
|
validateAndConvertNonce(nonce) {
|
|
3705
|
-
const nonceBuffer =
|
|
3607
|
+
const nonceBuffer = import_viem17.hexToBytes(nonce);
|
|
3706
3608
|
if (nonceBuffer.length !== this.NONCE_LENGTH) {
|
|
3707
3609
|
throw new Error("Nonce must be 12 bytes");
|
|
3708
3610
|
}
|
|
3709
3611
|
return nonceBuffer;
|
|
3710
3612
|
}
|
|
3711
3613
|
createNonce(num) {
|
|
3712
|
-
return
|
|
3614
|
+
return import_viem17.bytesToHex(this.numberToNonce(num));
|
|
3713
3615
|
}
|
|
3714
3616
|
async encrypt(plaintext, nonce, aad) {
|
|
3715
3617
|
if (!plaintext || plaintext === "0x") {
|
|
3716
3618
|
return "0x";
|
|
3717
3619
|
}
|
|
3718
3620
|
const nonceBuffer = new Uint8Array(typeof nonce === "string" ? this.validateAndConvertNonce(nonce) : this.numberToNonce(nonce));
|
|
3719
|
-
const key =
|
|
3720
|
-
const plaintextBytes =
|
|
3621
|
+
const key = import_viem17.hexToBytes(this.key);
|
|
3622
|
+
const plaintextBytes = import_viem17.hexToBytes(plaintext);
|
|
3721
3623
|
const ciphertextBytes = await gcm(key, nonceBuffer, aad).encrypt(plaintextBytes);
|
|
3722
|
-
return
|
|
3624
|
+
return import_viem17.bytesToHex(ciphertextBytes);
|
|
3723
3625
|
}
|
|
3724
3626
|
async decrypt(ciphertext, nonce, aad) {
|
|
3725
3627
|
if (!ciphertext || ciphertext === "0x") {
|
|
3726
3628
|
return "0x";
|
|
3727
3629
|
}
|
|
3728
3630
|
const nonceBuffer = new Uint8Array(typeof nonce === "string" ? this.validateAndConvertNonce(nonce) : this.numberToNonce(nonce));
|
|
3729
|
-
const key =
|
|
3730
|
-
const ciphertextBytes =
|
|
3631
|
+
const key = import_viem17.hexToBytes(this.key);
|
|
3632
|
+
const ciphertextBytes = import_viem17.hexToBytes(ciphertext);
|
|
3731
3633
|
const plaintextBytes = await gcm(key, nonceBuffer, aad).decrypt(ciphertextBytes);
|
|
3732
|
-
return
|
|
3634
|
+
return import_viem17.bytesToHex(plaintextBytes);
|
|
3733
3635
|
}
|
|
3734
3636
|
}
|
|
3735
3637
|
var sharedSecretPoint = ({
|
|
@@ -3742,15 +3644,15 @@ var sharedSecretPoint = ({
|
|
|
3742
3644
|
var sharedKeyFromPoint = (sharedSecret) => {
|
|
3743
3645
|
const version = sharedSecret[63] & 1 | 2;
|
|
3744
3646
|
const finalSecret = sha2562.create().update(new Uint8Array([version])).update(sharedSecret.slice(0, 32)).digest();
|
|
3745
|
-
return
|
|
3647
|
+
return import_viem17.bytesToHex(finalSecret).slice(2);
|
|
3746
3648
|
};
|
|
3747
3649
|
var generateSharedKey = (inputs) => {
|
|
3748
3650
|
const sharedSecret = sharedSecretPoint(inputs);
|
|
3749
3651
|
return sharedKeyFromPoint(sharedSecret);
|
|
3750
3652
|
};
|
|
3751
3653
|
var deriveAesKey = (sharedSecret) => {
|
|
3752
|
-
const derivedKey = hkdf(sha2562,
|
|
3753
|
-
return
|
|
3654
|
+
const derivedKey = hkdf(sha2562, import_viem17.hexToBytes(`0x${sharedSecret}`), new Uint8Array(0), new TextEncoder().encode("aes-gcm key"), 32);
|
|
3655
|
+
return import_viem17.bytesToHex(derivedKey);
|
|
3754
3656
|
};
|
|
3755
3657
|
var generateAesKey = (aesKeys) => {
|
|
3756
3658
|
const sharedSecret = generateSharedKey(aesKeys);
|
|
@@ -3840,13 +3742,13 @@ var tokenExplorerUrl = ({
|
|
|
3840
3742
|
};
|
|
3841
3743
|
|
|
3842
3744
|
// src/precompiles/aes.ts
|
|
3843
|
-
var
|
|
3745
|
+
var import_viem19 = require("viem");
|
|
3844
3746
|
|
|
3845
3747
|
// src/precompiles/precompile.ts
|
|
3846
|
-
var
|
|
3748
|
+
var import_viem18 = require("viem");
|
|
3847
3749
|
var BASE_TX_GAS_COST = 21000n;
|
|
3848
3750
|
var calldataGasCost = (data) => {
|
|
3849
|
-
const dataBytes =
|
|
3751
|
+
const dataBytes = import_viem18.hexToBytes(data);
|
|
3850
3752
|
const nonZeroBytes = dataBytes.filter((b) => b !== 0).length;
|
|
3851
3753
|
return 4n * BigInt(dataBytes.length) + 12n * BigInt(nonZeroBytes);
|
|
3852
3754
|
};
|
|
@@ -3893,7 +3795,7 @@ var AES_GCM_PER_BLOCK = 30n;
|
|
|
3893
3795
|
var MIN_AES_PLAINTEXT_LENGTH = 0;
|
|
3894
3796
|
var MIN_AES_CIPHERTEXT_LENGTH = 16;
|
|
3895
3797
|
var aesGcmGasCost = (value) => {
|
|
3896
|
-
const valueBytes =
|
|
3798
|
+
const valueBytes = import_viem19.isHex(value) ? import_viem19.hexToBytes(value) : import_viem19.stringToBytes(value);
|
|
3897
3799
|
return calcLinearGasCost({
|
|
3898
3800
|
bus: 16,
|
|
3899
3801
|
len: valueBytes.length,
|
|
@@ -3903,21 +3805,21 @@ var aesGcmGasCost = (value) => {
|
|
|
3903
3805
|
};
|
|
3904
3806
|
var validateParams = (args, encryption) => {
|
|
3905
3807
|
const [aesKey, nonce, input] = args;
|
|
3906
|
-
const aesKeyBytes =
|
|
3808
|
+
const aesKeyBytes = import_viem19.hexToBytes(aesKey);
|
|
3907
3809
|
if (aesKeyBytes.length !== 32) {
|
|
3908
3810
|
throw new Error(`Invalid AES key: expected 32 bytes but found ${aesKeyBytes.length}`);
|
|
3909
3811
|
}
|
|
3910
|
-
const nonceBytes =
|
|
3812
|
+
const nonceBytes = import_viem19.numberToBytes(nonce, { size: 12 });
|
|
3911
3813
|
if (nonceBytes.length !== 12) {
|
|
3912
3814
|
throw new Error(`Invalid nonce: expected 12 bytes but found ${nonceBytes.length}`);
|
|
3913
3815
|
}
|
|
3914
3816
|
if (encryption) {
|
|
3915
|
-
const plaintextBytes =
|
|
3817
|
+
const plaintextBytes = import_viem19.stringToBytes(input);
|
|
3916
3818
|
if (plaintextBytes.length < MIN_AES_PLAINTEXT_LENGTH) {
|
|
3917
3819
|
throw new Error(`Invalid plaintext: expected at least ${MIN_AES_PLAINTEXT_LENGTH} bytes but found ${plaintextBytes.length}`);
|
|
3918
3820
|
}
|
|
3919
3821
|
} else {
|
|
3920
|
-
const ciphertextBytes =
|
|
3822
|
+
const ciphertextBytes = import_viem19.hexToBytes(input);
|
|
3921
3823
|
if (ciphertextBytes.length < MIN_AES_CIPHERTEXT_LENGTH) {
|
|
3922
3824
|
throw new Error(`Invalid ciphertext: expected at least ${MIN_AES_CIPHERTEXT_LENGTH} bytes but found ${ciphertextBytes.length}`);
|
|
3923
3825
|
}
|
|
@@ -3929,21 +3831,21 @@ var aesGcmEncryptPrecompile = {
|
|
|
3929
3831
|
gasCost: (args) => aesGcmGasCost(args.plaintext),
|
|
3930
3832
|
encodeParams: (args) => {
|
|
3931
3833
|
const [aesKey, nonce, plaintext] = validateParams([args.aesKey, args.nonce, args.plaintext], true);
|
|
3932
|
-
const nonceHex =
|
|
3933
|
-
const plaintextHex =
|
|
3834
|
+
const nonceHex = import_viem19.numberToHex(nonce, { size: 12 });
|
|
3835
|
+
const plaintextHex = import_viem19.stringToHex(plaintext);
|
|
3934
3836
|
return `${aesKey}${nonceHex.slice(2)}${plaintextHex.slice(2)}`;
|
|
3935
3837
|
},
|
|
3936
|
-
decodeResult: (result) =>
|
|
3838
|
+
decodeResult: (result) => import_viem19.trim(result)
|
|
3937
3839
|
};
|
|
3938
3840
|
var aesGcmDecryptPrecompile = {
|
|
3939
3841
|
address: AES_GCM_DECRYPT_ADDRESS,
|
|
3940
3842
|
gasCost: (args) => aesGcmGasCost(args.ciphertext),
|
|
3941
3843
|
encodeParams: (args) => {
|
|
3942
3844
|
const [aesKey, nonce, cipherText] = validateParams([args.aesKey, args.nonce, args.ciphertext], false);
|
|
3943
|
-
const nonceHex =
|
|
3845
|
+
const nonceHex = import_viem19.numberToHex(nonce, { size: 12 });
|
|
3944
3846
|
return `${aesKey}${nonceHex.slice(2)}${cipherText.slice(2)}`;
|
|
3945
3847
|
},
|
|
3946
|
-
decodeResult: (result) =>
|
|
3848
|
+
decodeResult: (result) => import_viem19.hexToString(import_viem19.trim(result))
|
|
3947
3849
|
};
|
|
3948
3850
|
var aesGcmEncrypt = async (client, args) => {
|
|
3949
3851
|
return callPrecompile({
|
|
@@ -3961,10 +3863,10 @@ var aesGcmDecrypt = async (client, args) => {
|
|
|
3961
3863
|
};
|
|
3962
3864
|
|
|
3963
3865
|
// src/precompiles/ecdh.ts
|
|
3964
|
-
var
|
|
3866
|
+
var import_viem21 = require("viem");
|
|
3965
3867
|
|
|
3966
3868
|
// src/precompiles/hkdf.ts
|
|
3967
|
-
var
|
|
3869
|
+
var import_viem20 = require("viem");
|
|
3968
3870
|
var HKDF_ADDRESS = "0x0000000000000000000000000000000000000068";
|
|
3969
3871
|
var SHA256_BASE_GAS = 60n;
|
|
3970
3872
|
var SHA256_PER_WORD = 12n;
|
|
@@ -3973,7 +3875,7 @@ var SHARED_SECRET_GAS = 3000n;
|
|
|
3973
3875
|
var hdfkPrecompile = {
|
|
3974
3876
|
address: HKDF_ADDRESS,
|
|
3975
3877
|
gasCost: (ikmHex) => {
|
|
3976
|
-
const ikmBytes =
|
|
3878
|
+
const ikmBytes = import_viem20.isHex(ikmHex) ? import_viem20.hexToBytes(ikmHex) : import_viem20.stringToBytes(ikmHex);
|
|
3977
3879
|
const linearGasCost = calcLinearGasCost({
|
|
3978
3880
|
bus: 32,
|
|
3979
3881
|
len: ikmBytes.length,
|
|
@@ -3983,13 +3885,13 @@ var hdfkPrecompile = {
|
|
|
3983
3885
|
return 2n * linearGasCost + HKDF_EXPAND_COST_GAS;
|
|
3984
3886
|
},
|
|
3985
3887
|
encodeParams: (input) => {
|
|
3986
|
-
if (
|
|
3888
|
+
if (import_viem20.isHex(input)) {
|
|
3987
3889
|
return input;
|
|
3988
3890
|
}
|
|
3989
|
-
return
|
|
3891
|
+
return import_viem20.stringToHex(input);
|
|
3990
3892
|
},
|
|
3991
3893
|
decodeResult: (result) => {
|
|
3992
|
-
const [output] =
|
|
3894
|
+
const [output] = import_viem20.decodeAbiParameters([{ type: "bytes32" }], result);
|
|
3993
3895
|
return output;
|
|
3994
3896
|
}
|
|
3995
3897
|
};
|
|
@@ -4006,7 +3908,7 @@ var ECDH_ADDRESS = "0x0000000000000000000000000000000000000065";
|
|
|
4006
3908
|
var SECRET_KEY_LENGTH = 32;
|
|
4007
3909
|
var PUBLIC_KEY_LENGTH = 33;
|
|
4008
3910
|
var validateKey = (key, sk) => {
|
|
4009
|
-
const bytes =
|
|
3911
|
+
const bytes = import_viem21.hexToBytes(key);
|
|
4010
3912
|
const expectedLength = sk ? SECRET_KEY_LENGTH : PUBLIC_KEY_LENGTH;
|
|
4011
3913
|
if (bytes.length !== expectedLength) {
|
|
4012
3914
|
throw new Error(`Invalid ${sk ? "secret" : "public"} key: must be ${expectedLength} bytes (received ${bytes.length})`);
|
|
@@ -4021,7 +3923,7 @@ var ecdhPrecompile = {
|
|
|
4021
3923
|
return `${sk}${pk.slice(2)}`;
|
|
4022
3924
|
},
|
|
4023
3925
|
decodeResult: (result) => {
|
|
4024
|
-
const [output] =
|
|
3926
|
+
const [output] = import_viem21.decodeAbiParameters([{ type: "bytes32" }], result);
|
|
4025
3927
|
return output;
|
|
4026
3928
|
}
|
|
4027
3929
|
};
|
|
@@ -4034,7 +3936,7 @@ var ecdh = async (client, args) => {
|
|
|
4034
3936
|
};
|
|
4035
3937
|
|
|
4036
3938
|
// src/precompiles/rng.ts
|
|
4037
|
-
var
|
|
3939
|
+
var import_viem22 = require("viem");
|
|
4038
3940
|
var RNG_ADDRESS = "0x0000000000000000000000000000000000000064";
|
|
4039
3941
|
var RNG_INIT_BASE_GAS = 3500n;
|
|
4040
3942
|
var STROBE_128_WORD_GAS = 5n;
|
|
@@ -4042,9 +3944,9 @@ var persToBytes = (pers) => {
|
|
|
4042
3944
|
if (!pers) {
|
|
4043
3945
|
return new Uint8Array;
|
|
4044
3946
|
}
|
|
4045
|
-
if (
|
|
4046
|
-
return
|
|
4047
|
-
} else if (
|
|
3947
|
+
if (import_viem22.isHex(pers)) {
|
|
3948
|
+
return import_viem22.hexToBytes(pers);
|
|
3949
|
+
} else if (import_viem22.isBytes(pers)) {
|
|
4048
3950
|
return pers;
|
|
4049
3951
|
}
|
|
4050
3952
|
throw new Error("Invalid pers: must be a hex or bytes array");
|
|
@@ -4071,15 +3973,15 @@ var rngPrecompile = {
|
|
|
4071
3973
|
if (BigInt(numBytes) > 32n) {
|
|
4072
3974
|
throw new Error("Invalid length: must be less than or equal to 32");
|
|
4073
3975
|
}
|
|
4074
|
-
const encodedBytes =
|
|
3976
|
+
const encodedBytes = import_viem22.numberToHex(numBytes, { size: 4 });
|
|
4075
3977
|
if (!pers) {
|
|
4076
3978
|
return encodedBytes;
|
|
4077
3979
|
}
|
|
4078
|
-
const encodedPers =
|
|
3980
|
+
const encodedPers = import_viem22.bytesToHex(persToBytes(pers));
|
|
4079
3981
|
return `${encodedBytes}${encodedPers.slice(2)}`;
|
|
4080
3982
|
},
|
|
4081
3983
|
decodeResult: (result) => {
|
|
4082
|
-
const [output] =
|
|
3984
|
+
const [output] = import_viem22.decodeAbiParameters([{ type: "uint256" }], import_viem22.pad(result));
|
|
4083
3985
|
return output;
|
|
4084
3986
|
}
|
|
4085
3987
|
};
|
|
@@ -4092,7 +3994,7 @@ var rng = async (client, args) => {
|
|
|
4092
3994
|
};
|
|
4093
3995
|
|
|
4094
3996
|
// src/precompiles/secp256k1.ts
|
|
4095
|
-
var
|
|
3997
|
+
var import_viem23 = require("viem");
|
|
4096
3998
|
var SECP256K1_SIG_ADDRESS = "0x0000000000000000000000000000000000000069";
|
|
4097
3999
|
var SECP256K1_SIG_BASE_GAS = 3000n;
|
|
4098
4000
|
var secp256k1SigPrecompile = {
|
|
@@ -4104,9 +4006,9 @@ var secp256k1SigPrecompile = {
|
|
|
4104
4006
|
{ name: "messageHash", type: "bytes32" }
|
|
4105
4007
|
];
|
|
4106
4008
|
const skHex = sk;
|
|
4107
|
-
return
|
|
4009
|
+
return import_viem23.encodeAbiParameters(params, [skHex, import_viem23.hashMessage(message)]);
|
|
4108
4010
|
},
|
|
4109
|
-
decodeResult:
|
|
4011
|
+
decodeResult: import_viem23.parseSignature
|
|
4110
4012
|
};
|
|
4111
4013
|
var secp256k1Sig = async (client, args) => {
|
|
4112
4014
|
return callPrecompile({
|
|
@@ -4157,104 +4059,345 @@ var shieldedPublicActions = (client) => ({
|
|
|
4157
4059
|
aesGcmDecryption: (args) => aesGcmDecrypt(client, args)
|
|
4158
4060
|
});
|
|
4159
4061
|
|
|
4160
|
-
// src/
|
|
4161
|
-
var
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4062
|
+
// src/tx/sendTransparent.ts
|
|
4063
|
+
var import_accounts3 = require("viem/accounts");
|
|
4064
|
+
var import_actions6 = require("viem/actions");
|
|
4065
|
+
var import_utils13 = require("viem/utils");
|
|
4066
|
+
var DEFAULT_SIGNED_ESTIMATE_GAS_LIMIT = 30000000n;
|
|
4067
|
+
async function sendTransparentTransaction(client, parameters) {
|
|
4068
|
+
const {
|
|
4069
|
+
account: account_ = client.account,
|
|
4070
|
+
chain = client.chain,
|
|
4071
|
+
accessList,
|
|
4072
|
+
authorizationList,
|
|
4073
|
+
blobs,
|
|
4074
|
+
data,
|
|
4075
|
+
gas,
|
|
4076
|
+
gasPrice,
|
|
4077
|
+
maxFeePerBlobGas,
|
|
4078
|
+
maxFeePerGas,
|
|
4079
|
+
maxPriorityFeePerGas,
|
|
4080
|
+
nonce,
|
|
4081
|
+
value,
|
|
4082
|
+
...rest
|
|
4083
|
+
} = parameters;
|
|
4084
|
+
if (typeof account_ === "undefined")
|
|
4085
|
+
throw new AccountNotFoundError({
|
|
4086
|
+
docsPath: "/docs/actions/wallet/sendTransaction"
|
|
4087
|
+
});
|
|
4088
|
+
const account = account_ ? import_accounts3.parseAccount(account_) : null;
|
|
4089
|
+
try {
|
|
4090
|
+
import_utils13.assertRequest(parameters);
|
|
4091
|
+
const to = await (async () => {
|
|
4092
|
+
if (parameters.to)
|
|
4093
|
+
return parameters.to;
|
|
4094
|
+
return;
|
|
4095
|
+
})();
|
|
4096
|
+
if (account?.type !== "local") {
|
|
4097
|
+
return await import_actions6.sendTransaction(client, parameters);
|
|
4098
|
+
}
|
|
4099
|
+
const request = await import_actions6.prepareTransactionRequest(client, {
|
|
4100
|
+
account,
|
|
4101
|
+
accessList,
|
|
4102
|
+
authorizationList,
|
|
4103
|
+
blobs,
|
|
4104
|
+
chain,
|
|
4105
|
+
data,
|
|
4106
|
+
gasPrice,
|
|
4107
|
+
maxFeePerBlobGas,
|
|
4108
|
+
maxFeePerGas,
|
|
4109
|
+
maxPriorityFeePerGas,
|
|
4110
|
+
nonce,
|
|
4111
|
+
nonceManager: account.nonceManager,
|
|
4112
|
+
parameters: [
|
|
4113
|
+
"blobVersionedHashes",
|
|
4114
|
+
"chainId",
|
|
4115
|
+
"fees",
|
|
4116
|
+
"nonce",
|
|
4117
|
+
"type",
|
|
4118
|
+
"sidecars"
|
|
4119
|
+
],
|
|
4120
|
+
value,
|
|
4121
|
+
...rest,
|
|
4122
|
+
to
|
|
4123
|
+
});
|
|
4124
|
+
const serializer = chain?.serializers?.transaction;
|
|
4125
|
+
const gasEstimate = gas ?? BigInt(await client.request({
|
|
4126
|
+
method: "eth_estimateGas",
|
|
4127
|
+
params: [
|
|
4128
|
+
await account.signTransaction({
|
|
4129
|
+
...request,
|
|
4130
|
+
gas: DEFAULT_SIGNED_ESTIMATE_GAS_LIMIT
|
|
4131
|
+
}, { serializer })
|
|
4132
|
+
]
|
|
4133
|
+
}, { retryCount: 0 }));
|
|
4134
|
+
const serializedTransaction = await account.signTransaction({
|
|
4135
|
+
...request,
|
|
4136
|
+
gas: gasEstimate
|
|
4137
|
+
}, { serializer });
|
|
4138
|
+
return await import_utils13.getAction(client, import_actions6.sendRawTransaction, "sendRawTransaction")({
|
|
4139
|
+
serializedTransaction
|
|
4140
|
+
});
|
|
4141
|
+
} catch (err) {
|
|
4142
|
+
throw import_utils13.getTransactionError(err, {
|
|
4143
|
+
...parameters,
|
|
4144
|
+
account,
|
|
4145
|
+
chain: parameters.chain || undefined
|
|
4146
|
+
});
|
|
4147
|
+
}
|
|
4148
|
+
}
|
|
4149
|
+
|
|
4150
|
+
// src/actions/wallet.ts
|
|
4151
|
+
var shieldedWalletActions = (client) => {
|
|
4152
|
+
return {
|
|
4153
|
+
sendTransaction: (args) => sendTransparentTransaction(client, args),
|
|
4154
|
+
writeContract: (args) => smartWriteContract(client, args),
|
|
4155
|
+
swriteContract: (args, securityParams) => shieldedWriteContract(client, args, securityParams),
|
|
4156
|
+
twriteContract: (args) => transparentWriteContract(client, args),
|
|
4157
|
+
dwriteContract: (args, securityParams) => {
|
|
4158
|
+
const debugResult = shieldedWriteContractDebug(client, args, undefined, securityParams);
|
|
4159
|
+
return debugResult;
|
|
4160
|
+
},
|
|
4161
|
+
readContract: (args) => smartReadContract(client, client, args),
|
|
4162
|
+
sreadContract: (args, securityParams) => signedReadContract(client, args, securityParams),
|
|
4163
|
+
treadContract: (args) => {
|
|
4164
|
+
const readArgs = args;
|
|
4165
|
+
if (readArgs.account !== undefined) {
|
|
4166
|
+
throw new Error("walletClient.treadContract is always transparent. Seismic zeroes out `from` on transparent `eth_call`, so `account` would be ignored on the node and cause silent bugs. Remove `account` or use `walletClient.sreadContract`.");
|
|
4167
|
+
}
|
|
4168
|
+
return transparentReadContract(client, args);
|
|
4169
|
+
},
|
|
4170
|
+
signedCall: (args, securityParams) => signedCall(client, args, securityParams),
|
|
4171
|
+
sendShieldedTransaction: (args, securityParams) => sendShieldedTransaction(client, args, securityParams)
|
|
4172
|
+
};
|
|
4173
|
+
};
|
|
4174
|
+
|
|
4175
|
+
// src/crypto/secp.ts
|
|
4176
|
+
var import_viem24 = require("viem");
|
|
4177
|
+
var compressPublicKey = (uncompressedKey) => {
|
|
4178
|
+
const cleanKey = uncompressedKey.replace("0x", "");
|
|
4179
|
+
if (cleanKey.length !== 130) {
|
|
4180
|
+
throw new Error("Invalid uncompressed public key length");
|
|
4181
|
+
}
|
|
4182
|
+
const pt = secp256k1.ProjectivePoint.fromHex(cleanKey);
|
|
4183
|
+
return import_viem24.bytesToHex(pt.toRawBytes(true));
|
|
4184
|
+
};
|
|
4185
|
+
|
|
4186
|
+
// src/extensions/depositContract.ts
|
|
4187
|
+
var import_actions7 = require("viem/actions");
|
|
4188
|
+
|
|
4189
|
+
// src/abis/depositContract.ts
|
|
4190
|
+
var depositContractAbi = [
|
|
4191
|
+
{
|
|
4192
|
+
type: "constructor",
|
|
4193
|
+
inputs: [],
|
|
4194
|
+
stateMutability: "nonpayable"
|
|
4195
|
+
},
|
|
4196
|
+
{
|
|
4197
|
+
type: "function",
|
|
4198
|
+
name: "deposit",
|
|
4199
|
+
inputs: [
|
|
4200
|
+
{ name: "node_pubkey", type: "bytes", internalType: "bytes" },
|
|
4201
|
+
{ name: "consensus_pubkey", type: "bytes", internalType: "bytes" },
|
|
4202
|
+
{ name: "withdrawal_credentials", type: "bytes", internalType: "bytes" },
|
|
4203
|
+
{ name: "node_signature", type: "bytes", internalType: "bytes" },
|
|
4204
|
+
{ name: "consensus_signature", type: "bytes", internalType: "bytes" },
|
|
4205
|
+
{ name: "deposit_data_root", type: "bytes32", internalType: "bytes32" }
|
|
4206
|
+
],
|
|
4207
|
+
outputs: [],
|
|
4208
|
+
stateMutability: "payable"
|
|
4209
|
+
},
|
|
4210
|
+
{
|
|
4211
|
+
type: "function",
|
|
4212
|
+
name: "get_deposit_count",
|
|
4213
|
+
inputs: [],
|
|
4214
|
+
outputs: [{ name: "", type: "bytes", internalType: "bytes" }],
|
|
4215
|
+
stateMutability: "view"
|
|
4216
|
+
},
|
|
4217
|
+
{
|
|
4218
|
+
type: "function",
|
|
4219
|
+
name: "get_deposit_root",
|
|
4220
|
+
inputs: [],
|
|
4221
|
+
outputs: [{ name: "", type: "bytes32", internalType: "bytes32" }],
|
|
4222
|
+
stateMutability: "view"
|
|
4223
|
+
},
|
|
4224
|
+
{
|
|
4225
|
+
type: "function",
|
|
4226
|
+
name: "supportsInterface",
|
|
4227
|
+
inputs: [{ name: "interfaceId", type: "bytes4", internalType: "bytes4" }],
|
|
4228
|
+
outputs: [{ name: "", type: "bool", internalType: "bool" }],
|
|
4229
|
+
stateMutability: "pure"
|
|
4230
|
+
},
|
|
4231
|
+
{
|
|
4232
|
+
type: "event",
|
|
4233
|
+
name: "DepositEvent",
|
|
4234
|
+
inputs: [
|
|
4235
|
+
{
|
|
4236
|
+
name: "node_pubkey",
|
|
4237
|
+
type: "bytes",
|
|
4238
|
+
indexed: false,
|
|
4239
|
+
internalType: "bytes"
|
|
4240
|
+
},
|
|
4241
|
+
{
|
|
4242
|
+
name: "consensus_pubkey",
|
|
4243
|
+
type: "bytes",
|
|
4244
|
+
indexed: false,
|
|
4245
|
+
internalType: "bytes"
|
|
4246
|
+
},
|
|
4247
|
+
{
|
|
4248
|
+
name: "withdrawal_credentials",
|
|
4249
|
+
type: "bytes",
|
|
4250
|
+
indexed: false,
|
|
4251
|
+
internalType: "bytes"
|
|
4252
|
+
},
|
|
4253
|
+
{ name: "amount", type: "bytes", indexed: false, internalType: "bytes" },
|
|
4254
|
+
{
|
|
4255
|
+
name: "node_signature",
|
|
4256
|
+
type: "bytes",
|
|
4257
|
+
indexed: false,
|
|
4258
|
+
internalType: "bytes"
|
|
4259
|
+
},
|
|
4260
|
+
{
|
|
4261
|
+
name: "consensus_signature",
|
|
4262
|
+
type: "bytes",
|
|
4263
|
+
indexed: false,
|
|
4264
|
+
internalType: "bytes"
|
|
4265
|
+
},
|
|
4266
|
+
{ name: "index", type: "bytes", indexed: false, internalType: "bytes" }
|
|
4267
|
+
],
|
|
4268
|
+
anonymous: false
|
|
4269
|
+
}
|
|
4270
|
+
];
|
|
4271
|
+
|
|
4272
|
+
// src/extensions/depositContract.ts
|
|
4273
|
+
var DEPOSIT_CONTRACT_ADDRESS = "0x00000000219ab540356cBB839Cbe05303d7705Fa";
|
|
4274
|
+
var depositContractPublicActions = (client) => ({
|
|
4275
|
+
getDepositRoot: async (args) => import_actions7.readContract(client, {
|
|
4276
|
+
abi: depositContractAbi,
|
|
4277
|
+
address: args.address || DEPOSIT_CONTRACT_ADDRESS,
|
|
4278
|
+
functionName: "get_deposit_root"
|
|
4279
|
+
}),
|
|
4280
|
+
getDepositCount: async (args) => import_actions7.readContract(client, {
|
|
4281
|
+
abi: depositContractAbi,
|
|
4282
|
+
address: args.address || DEPOSIT_CONTRACT_ADDRESS,
|
|
4283
|
+
functionName: "get_deposit_count"
|
|
4284
|
+
})
|
|
4285
|
+
});
|
|
4286
|
+
var depositContractWalletActions = (client) => ({
|
|
4287
|
+
deposit: async (args) => import_actions7.writeContract(client, {
|
|
4288
|
+
abi: depositContractAbi,
|
|
4289
|
+
address: args.address || DEPOSIT_CONTRACT_ADDRESS,
|
|
4290
|
+
functionName: "deposit",
|
|
4291
|
+
args: [
|
|
4292
|
+
args.nodePubkey,
|
|
4293
|
+
args.consensusPubkey,
|
|
4294
|
+
args.withdrawalCredentials,
|
|
4295
|
+
args.nodeSignature,
|
|
4296
|
+
args.consensusSignature,
|
|
4297
|
+
args.depositDataRoot
|
|
4298
|
+
],
|
|
4299
|
+
value: args.value
|
|
4300
|
+
})
|
|
4301
|
+
});
|
|
4302
|
+
|
|
4303
|
+
// src/abis/src20.ts
|
|
4304
|
+
var SRC20Abi = [
|
|
4305
|
+
{
|
|
4306
|
+
inputs: [
|
|
4307
|
+
{
|
|
4308
|
+
internalType: "address",
|
|
4309
|
+
name: "owner",
|
|
4310
|
+
type: "address",
|
|
4311
|
+
indexed: true
|
|
4312
|
+
},
|
|
4313
|
+
{
|
|
4314
|
+
internalType: "address",
|
|
4315
|
+
name: "spender",
|
|
4316
|
+
type: "address",
|
|
4317
|
+
indexed: true
|
|
4318
|
+
},
|
|
4319
|
+
{
|
|
4320
|
+
internalType: "bytes32",
|
|
4321
|
+
name: "encryptKeyHash",
|
|
4322
|
+
type: "bytes32",
|
|
4323
|
+
indexed: true
|
|
4324
|
+
},
|
|
4325
|
+
{
|
|
4326
|
+
internalType: "bytes",
|
|
4327
|
+
name: "encryptedAmount",
|
|
4328
|
+
type: "bytes",
|
|
4329
|
+
indexed: false
|
|
4330
|
+
}
|
|
4331
|
+
],
|
|
4332
|
+
type: "event",
|
|
4333
|
+
name: "Approval",
|
|
4334
|
+
anonymous: false
|
|
4335
|
+
},
|
|
4336
|
+
{
|
|
4337
|
+
inputs: [
|
|
4338
|
+
{
|
|
4339
|
+
internalType: "address",
|
|
4340
|
+
name: "from",
|
|
4341
|
+
type: "address",
|
|
4342
|
+
indexed: true
|
|
4343
|
+
},
|
|
4344
|
+
{
|
|
4345
|
+
internalType: "address",
|
|
4346
|
+
name: "to",
|
|
4347
|
+
type: "address",
|
|
4348
|
+
indexed: true
|
|
4349
|
+
},
|
|
4350
|
+
{
|
|
4351
|
+
internalType: "bytes32",
|
|
4352
|
+
name: "encryptKeyHash",
|
|
4353
|
+
type: "bytes32",
|
|
4354
|
+
indexed: true
|
|
4355
|
+
},
|
|
4356
|
+
{
|
|
4357
|
+
internalType: "bytes",
|
|
4358
|
+
name: "encryptedAmount",
|
|
4359
|
+
type: "bytes",
|
|
4360
|
+
indexed: false
|
|
4361
|
+
}
|
|
4362
|
+
],
|
|
4363
|
+
type: "event",
|
|
4364
|
+
name: "Transfer",
|
|
4365
|
+
anonymous: false
|
|
4366
|
+
},
|
|
4367
|
+
{
|
|
4368
|
+
inputs: [],
|
|
4369
|
+
stateMutability: "view",
|
|
4370
|
+
type: "function",
|
|
4371
|
+
name: "DOMAIN_SEPARATOR",
|
|
4372
|
+
outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }]
|
|
4373
|
+
},
|
|
4374
|
+
{
|
|
4375
|
+
inputs: [],
|
|
4376
|
+
stateMutability: "view",
|
|
4377
|
+
type: "function",
|
|
4378
|
+
name: "INTELLIGENCE_ADDRESS",
|
|
4379
|
+
outputs: [{ internalType: "address", name: "", type: "address" }]
|
|
4380
|
+
},
|
|
4381
|
+
{
|
|
4382
|
+
inputs: [{ internalType: "address", name: "spender", type: "address" }],
|
|
4383
|
+
stateMutability: "view",
|
|
4384
|
+
type: "function",
|
|
4385
|
+
name: "allowance",
|
|
4386
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }]
|
|
4387
|
+
},
|
|
4388
|
+
{
|
|
4389
|
+
inputs: [
|
|
4390
|
+
{ internalType: "address", name: "spender", type: "address" },
|
|
4391
|
+
{ internalType: "suint256", name: "amount", type: "suint256" }
|
|
4392
|
+
],
|
|
4393
|
+
stateMutability: "nonpayable",
|
|
4394
|
+
type: "function",
|
|
4395
|
+
name: "approve",
|
|
4396
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }]
|
|
4397
|
+
},
|
|
4398
|
+
{
|
|
4399
|
+
inputs: [],
|
|
4400
|
+
stateMutability: "view",
|
|
4258
4401
|
type: "function",
|
|
4259
4402
|
name: "balance",
|
|
4260
4403
|
outputs: [{ internalType: "uint256", name: "", type: "uint256" }]
|
|
@@ -4342,7 +4485,7 @@ var SRC20Abi = [
|
|
|
4342
4485
|
}
|
|
4343
4486
|
];
|
|
4344
4487
|
|
|
4345
|
-
// src/
|
|
4488
|
+
// src/extensions/src20/crypto.ts
|
|
4346
4489
|
var NONCE_LENGTH = 24;
|
|
4347
4490
|
function parseEncryptedData(encryptedData) {
|
|
4348
4491
|
if (!encryptedData || encryptedData === "0x" || encryptedData.length <= 2) {
|
|
@@ -4353,8 +4496,8 @@ function parseEncryptedData(encryptedData) {
|
|
|
4353
4496
|
return { ciphertext, nonce };
|
|
4354
4497
|
}
|
|
4355
4498
|
|
|
4356
|
-
// src/
|
|
4357
|
-
var
|
|
4499
|
+
// src/extensions/src20/directory.ts
|
|
4500
|
+
var import_viem25 = require("viem");
|
|
4358
4501
|
|
|
4359
4502
|
// src/abis/directory.ts
|
|
4360
4503
|
var DIRECTORY_ADDRESS = "0x1000000000000000000000000000000000000004";
|
|
@@ -4389,7 +4532,7 @@ var DirectoryAbi = [
|
|
|
4389
4532
|
}
|
|
4390
4533
|
];
|
|
4391
4534
|
|
|
4392
|
-
// src/
|
|
4535
|
+
// src/extensions/src20/directory.ts
|
|
4393
4536
|
var TX_TIMEOUT_MS = 30000;
|
|
4394
4537
|
function withTimeout(promise, ms) {
|
|
4395
4538
|
const timeout = new Promise((_, reject) => setTimeout(() => reject(new Error(`Transaction timed out after ${ms}ms`)), ms));
|
|
@@ -4432,10 +4575,10 @@ async function registerKey(client, aesKey) {
|
|
|
4432
4575
|
return withTimeout(txPromise, TX_TIMEOUT_MS);
|
|
4433
4576
|
}
|
|
4434
4577
|
function computeKeyHash(aesKey) {
|
|
4435
|
-
return
|
|
4578
|
+
return import_viem25.keccak256(aesKey);
|
|
4436
4579
|
}
|
|
4437
4580
|
|
|
4438
|
-
// src/
|
|
4581
|
+
// src/extensions/src20/watchSRC20Events.ts
|
|
4439
4582
|
async function watchSRC20Events(client, params) {
|
|
4440
4583
|
const { address, onTransfer, onApproval, onError } = params;
|
|
4441
4584
|
const aesKey = await getKey(client);
|
|
@@ -4500,7 +4643,7 @@ async function watchSRC20Events(client, params) {
|
|
|
4500
4643
|
};
|
|
4501
4644
|
}
|
|
4502
4645
|
|
|
4503
|
-
// src/
|
|
4646
|
+
// src/extensions/src20/watchSRC20EventsWithKey.ts
|
|
4504
4647
|
async function watchSRC20EventsWithKey(client, viewingKey, params) {
|
|
4505
4648
|
const { address, onTransfer, onApproval, onError } = params;
|
|
4506
4649
|
const aesCipher = new AesGcmCrypto(viewingKey);
|
|
@@ -4561,7 +4704,7 @@ async function watchSRC20EventsWithKey(client, viewingKey, params) {
|
|
|
4561
4704
|
};
|
|
4562
4705
|
}
|
|
4563
4706
|
|
|
4564
|
-
// src/
|
|
4707
|
+
// src/extensions/src20/src20Actions.ts
|
|
4565
4708
|
var src20PublicActions = (client) => ({
|
|
4566
4709
|
watchSRC20EventsWithKey: (viewingKey, params) => watchSRC20EventsWithKey(client, viewingKey, params)
|
|
4567
4710
|
});
|
|
@@ -4569,130 +4712,6 @@ var src20WalletActions = (client) => ({
|
|
|
4569
4712
|
watchSRC20Events: (params) => watchSRC20Events(client, params)
|
|
4570
4713
|
});
|
|
4571
4714
|
|
|
4572
|
-
// src/tx/sendTransparent.ts
|
|
4573
|
-
var import_accounts3 = require("viem/accounts");
|
|
4574
|
-
var import_actions7 = require("viem/actions");
|
|
4575
|
-
var import_utils13 = require("viem/utils");
|
|
4576
|
-
var DEFAULT_SIGNED_ESTIMATE_GAS_LIMIT = 30000000n;
|
|
4577
|
-
async function sendTransparentTransaction(client, parameters) {
|
|
4578
|
-
const {
|
|
4579
|
-
account: account_ = client.account,
|
|
4580
|
-
chain = client.chain,
|
|
4581
|
-
accessList,
|
|
4582
|
-
authorizationList,
|
|
4583
|
-
blobs,
|
|
4584
|
-
data,
|
|
4585
|
-
gas,
|
|
4586
|
-
gasPrice,
|
|
4587
|
-
maxFeePerBlobGas,
|
|
4588
|
-
maxFeePerGas,
|
|
4589
|
-
maxPriorityFeePerGas,
|
|
4590
|
-
nonce,
|
|
4591
|
-
value,
|
|
4592
|
-
...rest
|
|
4593
|
-
} = parameters;
|
|
4594
|
-
if (typeof account_ === "undefined")
|
|
4595
|
-
throw new AccountNotFoundError({
|
|
4596
|
-
docsPath: "/docs/actions/wallet/sendTransaction"
|
|
4597
|
-
});
|
|
4598
|
-
const account = account_ ? import_accounts3.parseAccount(account_) : null;
|
|
4599
|
-
try {
|
|
4600
|
-
import_utils13.assertRequest(parameters);
|
|
4601
|
-
const to = await (async () => {
|
|
4602
|
-
if (parameters.to)
|
|
4603
|
-
return parameters.to;
|
|
4604
|
-
return;
|
|
4605
|
-
})();
|
|
4606
|
-
if (account?.type !== "local") {
|
|
4607
|
-
return await import_actions7.sendTransaction(client, parameters);
|
|
4608
|
-
}
|
|
4609
|
-
const request = await import_actions7.prepareTransactionRequest(client, {
|
|
4610
|
-
account,
|
|
4611
|
-
accessList,
|
|
4612
|
-
authorizationList,
|
|
4613
|
-
blobs,
|
|
4614
|
-
chain,
|
|
4615
|
-
data,
|
|
4616
|
-
gasPrice,
|
|
4617
|
-
maxFeePerBlobGas,
|
|
4618
|
-
maxFeePerGas,
|
|
4619
|
-
maxPriorityFeePerGas,
|
|
4620
|
-
nonce,
|
|
4621
|
-
nonceManager: account.nonceManager,
|
|
4622
|
-
parameters: [
|
|
4623
|
-
"blobVersionedHashes",
|
|
4624
|
-
"chainId",
|
|
4625
|
-
"fees",
|
|
4626
|
-
"nonce",
|
|
4627
|
-
"type",
|
|
4628
|
-
"sidecars"
|
|
4629
|
-
],
|
|
4630
|
-
value,
|
|
4631
|
-
...rest,
|
|
4632
|
-
to
|
|
4633
|
-
});
|
|
4634
|
-
const serializer = chain?.serializers?.transaction;
|
|
4635
|
-
const gasEstimate = gas ?? BigInt(await client.request({
|
|
4636
|
-
method: "eth_estimateGas",
|
|
4637
|
-
params: [
|
|
4638
|
-
await account.signTransaction({
|
|
4639
|
-
...request,
|
|
4640
|
-
gas: DEFAULT_SIGNED_ESTIMATE_GAS_LIMIT
|
|
4641
|
-
}, { serializer })
|
|
4642
|
-
]
|
|
4643
|
-
}, { retryCount: 0 }));
|
|
4644
|
-
const serializedTransaction = await account.signTransaction({
|
|
4645
|
-
...request,
|
|
4646
|
-
gas: gasEstimate
|
|
4647
|
-
}, { serializer });
|
|
4648
|
-
return await import_utils13.getAction(client, import_actions7.sendRawTransaction, "sendRawTransaction")({
|
|
4649
|
-
serializedTransaction
|
|
4650
|
-
});
|
|
4651
|
-
} catch (err) {
|
|
4652
|
-
throw import_utils13.getTransactionError(err, {
|
|
4653
|
-
...parameters,
|
|
4654
|
-
account,
|
|
4655
|
-
chain: parameters.chain || undefined
|
|
4656
|
-
});
|
|
4657
|
-
}
|
|
4658
|
-
}
|
|
4659
|
-
|
|
4660
|
-
// src/actions/wallet.ts
|
|
4661
|
-
var shieldedWalletActions = (client) => {
|
|
4662
|
-
return {
|
|
4663
|
-
sendTransaction: (args) => sendTransparentTransaction(client, args),
|
|
4664
|
-
writeContract: (args) => smartWriteContract(client, args),
|
|
4665
|
-
swriteContract: (args, securityParams) => shieldedWriteContract(client, args, securityParams),
|
|
4666
|
-
twriteContract: (args) => transparentWriteContract(client, args),
|
|
4667
|
-
dwriteContract: (args, securityParams) => {
|
|
4668
|
-
const debugResult = shieldedWriteContractDebug(client, args, undefined, securityParams);
|
|
4669
|
-
return debugResult;
|
|
4670
|
-
},
|
|
4671
|
-
readContract: (args) => smartReadContract(client, client, args),
|
|
4672
|
-
sreadContract: (args, securityParams) => signedReadContract(client, args, securityParams),
|
|
4673
|
-
treadContract: (args) => {
|
|
4674
|
-
const readArgs = args;
|
|
4675
|
-
if (readArgs.account !== undefined) {
|
|
4676
|
-
throw new Error("walletClient.treadContract is always transparent. Seismic zeroes out `from` on transparent `eth_call`, so `account` would be ignored on the node and cause silent bugs. Remove `account` or use `walletClient.sreadContract`.");
|
|
4677
|
-
}
|
|
4678
|
-
return transparentReadContract(client, args);
|
|
4679
|
-
},
|
|
4680
|
-
signedCall: (args, securityParams) => signedCall(client, args, securityParams),
|
|
4681
|
-
sendShieldedTransaction: (args, securityParams) => sendShieldedTransaction(client, args, securityParams)
|
|
4682
|
-
};
|
|
4683
|
-
};
|
|
4684
|
-
|
|
4685
|
-
// src/crypto/secp.ts
|
|
4686
|
-
var import_viem23 = require("viem");
|
|
4687
|
-
var compressPublicKey = (uncompressedKey) => {
|
|
4688
|
-
const cleanKey = uncompressedKey.replace("0x", "");
|
|
4689
|
-
if (cleanKey.length !== 130) {
|
|
4690
|
-
throw new Error("Invalid uncompressed public key length");
|
|
4691
|
-
}
|
|
4692
|
-
const pt = secp256k1.ProjectivePoint.fromHex(cleanKey);
|
|
4693
|
-
return import_viem23.bytesToHex(pt.toRawBytes(true));
|
|
4694
|
-
};
|
|
4695
|
-
|
|
4696
4715
|
// src/client.ts
|
|
4697
4716
|
var getEncryption = (networkPk, clientSk) => {
|
|
4698
4717
|
const encryptionPrivateKey = clientSk ?? import_accounts4.generatePrivateKey();
|
|
@@ -4705,7 +4724,7 @@ var getEncryption = (networkPk, clientSk) => {
|
|
|
4705
4724
|
return { encryptionPrivateKey, encryptionPublicKey, aesKey };
|
|
4706
4725
|
};
|
|
4707
4726
|
var createShieldedPublicClient = (parameters) => {
|
|
4708
|
-
const viemPublicClient =
|
|
4727
|
+
const viemPublicClient = import_viem26.createPublicClient(parameters);
|
|
4709
4728
|
return viemPublicClient.extend(shieldedPublicActions).extend(depositContractPublicActions).extend(src20PublicActions);
|
|
4710
4729
|
};
|
|
4711
4730
|
var getSeismicClients = async ({
|
|
@@ -4721,12 +4740,12 @@ var getSeismicClients = async ({
|
|
|
4721
4740
|
});
|
|
4722
4741
|
const networkPublicKey = await pubClient.getTeePublicKey();
|
|
4723
4742
|
const { aesKey, encryptionPublicKey } = getEncryption(networkPublicKey, encryptionSk);
|
|
4724
|
-
const wallet =
|
|
4743
|
+
const wallet = import_viem26.createClient({
|
|
4725
4744
|
account,
|
|
4726
4745
|
chain,
|
|
4727
4746
|
transport,
|
|
4728
4747
|
rpcSchema: seismicRpcSchema
|
|
4729
|
-
}).extend(
|
|
4748
|
+
}).extend(import_viem26.walletActions).extend(() => import_viem26.publicActions(pubClient)).extend(() => encryptionActions(aesKey, encryptionPublicKey)).extend(() => shieldedPublicActions(pubClient)).extend(shieldedWalletActions).extend(depositContractWalletActions).extend(src20WalletActions);
|
|
4730
4749
|
return {
|
|
4731
4750
|
public: pubClient,
|
|
4732
4751
|
wallet
|
|
@@ -4748,9 +4767,11 @@ var createShieldedWalletClient = async ({
|
|
|
4748
4767
|
});
|
|
4749
4768
|
return clients.wallet;
|
|
4750
4769
|
};
|
|
4751
|
-
// src/faucet.ts
|
|
4770
|
+
// src/extensions/faucet.ts
|
|
4752
4771
|
var import_utils14 = require("viem/utils");
|
|
4753
4772
|
var DEFAULT_MIN_BALANCE_WEI = import_utils14.parseEther("0.5");
|
|
4773
|
+
var TXHASH_PREFIX = "Txhash: ";
|
|
4774
|
+
var HASH_HEX_LENGTH = 66;
|
|
4754
4775
|
var parseMinBalance = (minBalanceWei, minBalanceEther) => {
|
|
4755
4776
|
if (minBalanceWei && minBalanceEther) {
|
|
4756
4777
|
if (BigInt(minBalanceWei) !== import_utils14.parseEther(minBalanceEther.toString())) {
|
|
@@ -4765,6 +4786,16 @@ var parseMinBalance = (minBalanceWei, minBalanceEther) => {
|
|
|
4765
4786
|
}
|
|
4766
4787
|
return DEFAULT_MIN_BALANCE_WEI;
|
|
4767
4788
|
};
|
|
4789
|
+
var parseFaucetResponseHash = (msg) => {
|
|
4790
|
+
if (!msg.startsWith(TXHASH_PREFIX)) {
|
|
4791
|
+
return null;
|
|
4792
|
+
}
|
|
4793
|
+
const hash = msg.slice(TXHASH_PREFIX.length);
|
|
4794
|
+
if (!hash.startsWith("0x") || hash.length !== HASH_HEX_LENGTH) {
|
|
4795
|
+
throw new Error(`Invalid hash from faucet claim: ${hash}`);
|
|
4796
|
+
}
|
|
4797
|
+
return hash;
|
|
4798
|
+
};
|
|
4768
4799
|
var checkFaucet = async ({
|
|
4769
4800
|
address,
|
|
4770
4801
|
publicClient,
|
|
@@ -4785,20 +4816,14 @@ var checkFaucet = async ({
|
|
|
4785
4816
|
throw new Error(`Faucet request failed with status ${response.status}: ${await response.text()}`);
|
|
4786
4817
|
}
|
|
4787
4818
|
const { msg } = await response.json();
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
await publicClient.waitForTransactionReceipt({ hash });
|
|
4796
|
-
return { sent: true, hash, txUrl: txUrl ?? undefined };
|
|
4797
|
-
} else {
|
|
4798
|
-
throw new Error(`Invalid hash from faucet claim: ${hash}`);
|
|
4799
|
-
}
|
|
4819
|
+
const hash = parseFaucetResponseHash(msg);
|
|
4820
|
+
if (!hash) {
|
|
4821
|
+
throw new Error(`Faucet claim failed: ${msg}`);
|
|
4822
|
+
}
|
|
4823
|
+
const txUrl = txExplorerUrl({ chain: publicClient.chain, txHash: hash });
|
|
4824
|
+
if (txUrl) {
|
|
4825
|
+
console.debug(`Faucet sent eth to ${address}: ${txUrl}`);
|
|
4800
4826
|
}
|
|
4801
|
-
|
|
4827
|
+
await publicClient.waitForTransactionReceipt({ hash });
|
|
4828
|
+
return { sent: true, hash, txUrl: txUrl ?? undefined };
|
|
4802
4829
|
};
|
|
4803
|
-
// src/utils.ts
|
|
4804
|
-
var stringifyBigInt = (_, v) => typeof v === "bigint" ? v.toString() : v;
|