seismic-viem 1.1.1 → 2.0.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/_cjs/index.js +489 -169
- package/dist/_esm/index.js +417 -102
- package/dist/_types/actions/wallet.d.ts +20 -10
- package/dist/_types/chain.d.ts +50 -3
- package/dist/_types/client.d.ts +24 -5
- package/dist/_types/contract/abi.d.ts +7 -1
- package/dist/_types/contract/calldata.d.ts +16 -0
- package/dist/_types/contract/contract.d.ts +36 -19
- package/dist/_types/contract/read.d.ts +25 -1
- package/dist/_types/contract/write.d.ts +43 -42
- package/dist/_types/index.d.ts +6 -5
- package/dist/_types/tx/sendShielded.d.ts +49 -0
- package/dist/_types/tx/sendTransparent.d.ts +16 -0
- package/dist/_types/{signedCall.d.ts → tx/signedCall.d.ts} +17 -11
- package/dist/_types/tx/types.d.ts +15 -0
- package/package.json +1 -1
- package/dist/_types/request.d.ts +0 -4
- package/dist/_types/sendTransaction.d.ts +0 -56
package/dist/_cjs/index.js
CHANGED
|
@@ -32,6 +32,8 @@ __export(exports_src, {
|
|
|
32
32
|
watchSRC20EventsWithKey: () => watchSRC20EventsWithKey,
|
|
33
33
|
watchSRC20Events: () => watchSRC20Events,
|
|
34
34
|
txExplorerUrl: () => txExplorerUrl,
|
|
35
|
+
transparentWriteContract: () => transparentWriteContract,
|
|
36
|
+
transparentReadContract: () => transparentReadContract,
|
|
35
37
|
tokenExplorerUrl: () => tokenExplorerUrl,
|
|
36
38
|
stringifyBigInt: () => stringifyBigInt,
|
|
37
39
|
src20WalletActions: () => src20WalletActions,
|
|
@@ -61,6 +63,7 @@ __export(exports_src, {
|
|
|
61
63
|
localSeismicDevnet: () => localSeismicDevnet,
|
|
62
64
|
hdfkPrecompile: () => hdfkPrecompile,
|
|
63
65
|
hdfk: () => hdfk,
|
|
66
|
+
hasShieldedParams: () => hasShieldedParams,
|
|
64
67
|
getShieldedContract: () => getShieldedContract,
|
|
65
68
|
getPlaintextCalldata: () => getPlaintextCalldata,
|
|
66
69
|
getKeyHash: () => getKeyHash,
|
|
@@ -219,12 +222,14 @@ var seismicTxTypedData = (tx) => {
|
|
|
219
222
|
if (tx.signedRead === undefined) {
|
|
220
223
|
throw new Error("Seismic transactions require signedRead");
|
|
221
224
|
}
|
|
225
|
+
const isCreate = tx.to === undefined || tx.to === null;
|
|
222
226
|
const message = {
|
|
223
227
|
chainId: tx.chainId,
|
|
224
228
|
nonce: tx.nonce !== undefined ? BigInt(tx.nonce) : undefined,
|
|
225
229
|
gasPrice: tx.gasPrice && BigInt(tx.gasPrice),
|
|
226
230
|
gasLimit: tx.gas && BigInt(tx.gas),
|
|
227
|
-
to: tx.to,
|
|
231
|
+
to: isCreate ? "0x0000000000000000000000000000000000000000" : tx.to,
|
|
232
|
+
isCreate,
|
|
228
233
|
value: tx.value ? BigInt(tx.value) : 0n,
|
|
229
234
|
input: tx.data ?? "0x",
|
|
230
235
|
encryptionPubkey: tx.encryptionPubkey,
|
|
@@ -248,6 +253,7 @@ var seismicTxTypedData = (tx) => {
|
|
|
248
253
|
{ name: "gasPrice", type: "uint128" },
|
|
249
254
|
{ name: "gasLimit", type: "uint64" },
|
|
250
255
|
{ name: "to", type: "address" },
|
|
256
|
+
{ name: "isCreate", type: "bool" },
|
|
251
257
|
{ name: "value", type: "uint256" },
|
|
252
258
|
{ name: "input", type: "bytes" },
|
|
253
259
|
{ name: "encryptionPubkey", type: "bytes" },
|
|
@@ -283,13 +289,14 @@ var signSeismicTxTypedData = async (client, tx) => {
|
|
|
283
289
|
};
|
|
284
290
|
|
|
285
291
|
// src/metadata.ts
|
|
292
|
+
var DEFAULT_SEISMIC_BLOCKS_WINDOW = 100n;
|
|
286
293
|
var fillNonce = async (client, parameters) => {
|
|
287
294
|
let account = import_accounts.parseAccount(parameters.account || client.account);
|
|
288
295
|
const { nonce: nonce_ } = parameters;
|
|
289
296
|
if (nonce_ !== undefined) {
|
|
290
297
|
return nonce_;
|
|
291
298
|
}
|
|
292
|
-
const { blockNumber, blockTag = "
|
|
299
|
+
const { blockNumber, blockTag = "pending" } = parameters;
|
|
293
300
|
let args = {
|
|
294
301
|
address: account.address,
|
|
295
302
|
blockTag
|
|
@@ -303,7 +310,7 @@ var inferTypedDataTx = (typedDataTx, account) => {
|
|
|
303
310
|
if (typedDataTx !== undefined) {
|
|
304
311
|
return typedDataTx;
|
|
305
312
|
}
|
|
306
|
-
return account.type === "json-rpc";
|
|
313
|
+
return account.type === "json-rpc" || account.type === "local";
|
|
307
314
|
};
|
|
308
315
|
var buildTxSeismicMetadata = async (client, {
|
|
309
316
|
account: paramsAcct,
|
|
@@ -311,7 +318,7 @@ var buildTxSeismicMetadata = async (client, {
|
|
|
311
318
|
to,
|
|
312
319
|
value = 0n,
|
|
313
320
|
encryptionNonce,
|
|
314
|
-
blocksWindow =
|
|
321
|
+
blocksWindow = DEFAULT_SEISMIC_BLOCKS_WINDOW,
|
|
315
322
|
recentBlockHash,
|
|
316
323
|
expiresAtBlock,
|
|
317
324
|
typedDataTx,
|
|
@@ -420,7 +427,8 @@ var serializeSeismicTransaction = (tx, signature) => {
|
|
|
420
427
|
messageVersion = 0,
|
|
421
428
|
recentBlockHash,
|
|
422
429
|
expiresAtBlock,
|
|
423
|
-
signedRead = false
|
|
430
|
+
signedRead = false,
|
|
431
|
+
authorizationList
|
|
424
432
|
} = tx;
|
|
425
433
|
if (chainId === undefined) {
|
|
426
434
|
throw new Error("Seismic transactions require chainId");
|
|
@@ -466,6 +474,14 @@ var serializeSeismicTransaction = (tx, signature) => {
|
|
|
466
474
|
import_viem4.toHex(expiresAtBlock),
|
|
467
475
|
signedRead ? "0x01" : "0x",
|
|
468
476
|
data ?? "0x",
|
|
477
|
+
(authorizationList ?? []).map((auth) => [
|
|
478
|
+
auth.chainId ? import_viem4.toHex(auth.chainId) : "0x",
|
|
479
|
+
auth.contractAddress,
|
|
480
|
+
auth.nonce ? import_viem4.toHex(auth.nonce) : "0x",
|
|
481
|
+
auth.yParity ? import_viem4.toHex(auth.yParity) : "0x",
|
|
482
|
+
auth.r,
|
|
483
|
+
auth.s
|
|
484
|
+
]),
|
|
469
485
|
...toYParitySignatureArray(tx, signature)
|
|
470
486
|
];
|
|
471
487
|
const rlpEncoded = import_viem4.toRlp(rlpArray);
|
|
@@ -485,13 +501,27 @@ var seismicRpcSchema = [estimateGasRpcSchema, callRpcSchema];
|
|
|
485
501
|
var hasSeismicFields = (request) => {
|
|
486
502
|
return request.encryptionPubkey !== undefined && request.encryptionNonce !== undefined && request.messageVersion !== undefined && request.recentBlockHash !== undefined && request.expiresAtBlock !== undefined && request.signedRead !== undefined;
|
|
487
503
|
};
|
|
504
|
+
var formatAuthorizationList = (authorizationList) => authorizationList.map((authorization) => ({
|
|
505
|
+
address: authorization.contractAddress,
|
|
506
|
+
r: authorization.r,
|
|
507
|
+
s: authorization.s,
|
|
508
|
+
chainId: import_viem4.toHex(authorization.chainId),
|
|
509
|
+
nonce: import_viem4.toHex(authorization.nonce),
|
|
510
|
+
...typeof authorization.yParity !== "undefined" ? { yParity: import_viem4.toHex(authorization.yParity) } : {},
|
|
511
|
+
...typeof authorization.v !== "undefined" && typeof authorization.yParity === "undefined" ? { v: import_viem4.toHex(authorization.v) } : {}
|
|
512
|
+
}));
|
|
488
513
|
var fmtRpcRequest = (request) => {
|
|
489
514
|
if (request.type === "seismic") {
|
|
515
|
+
const { authorizationList, ...legacyCompatibleRequest } = request;
|
|
490
516
|
const seismicFmt = import_viem4.formatTransactionRequest({
|
|
491
|
-
...
|
|
517
|
+
...legacyCompatibleRequest,
|
|
492
518
|
type: "legacy"
|
|
493
519
|
});
|
|
494
|
-
return {
|
|
520
|
+
return {
|
|
521
|
+
...seismicFmt,
|
|
522
|
+
type: SEISMIC_TX_TYPE,
|
|
523
|
+
...authorizationList ? { authorizationList: formatAuthorizationList(authorizationList) } : {}
|
|
524
|
+
};
|
|
495
525
|
}
|
|
496
526
|
const { type, ...fmt } = import_viem4.formatTransactionRequest(request);
|
|
497
527
|
if (hasSeismicFields(request)) {
|
|
@@ -606,11 +636,11 @@ var sanvil = /* @__PURE__ */ import_viem4.defineChain({
|
|
|
606
636
|
testnet: true
|
|
607
637
|
});
|
|
608
638
|
// src/contract/contract.ts
|
|
609
|
-
var
|
|
610
|
-
var import_actions4 = require("viem/actions");
|
|
639
|
+
var import_viem13 = require("viem");
|
|
611
640
|
|
|
612
641
|
// src/contract/read.ts
|
|
613
642
|
var import_viem9 = require("viem");
|
|
643
|
+
var import_actions3 = require("viem/actions");
|
|
614
644
|
var import_utils2 = require("viem/utils");
|
|
615
645
|
|
|
616
646
|
// src/contract/abi.ts
|
|
@@ -653,8 +683,17 @@ var remapSeismicParam = (param) => {
|
|
|
653
683
|
if (ty === "saddress[]") {
|
|
654
684
|
return { shielded: true, type: "address[]" };
|
|
655
685
|
}
|
|
686
|
+
if (ty.startsWith("sbytes")) {
|
|
687
|
+
return { shielded: true, type: ty.slice(1) };
|
|
688
|
+
}
|
|
656
689
|
return { shielded: false, type: ty };
|
|
657
690
|
};
|
|
691
|
+
function hasShieldedParams(abi, functionName) {
|
|
692
|
+
const abiItem = import_viem5.getAbiItem({ abi, name: functionName });
|
|
693
|
+
if (!abiItem?.inputs)
|
|
694
|
+
return false;
|
|
695
|
+
return abiItem.inputs.some((param) => remapSeismicParam(param).shielded);
|
|
696
|
+
}
|
|
658
697
|
var remapSeismicAbiInputs = (abiFunction) => {
|
|
659
698
|
return {
|
|
660
699
|
type: abiFunction.type,
|
|
@@ -667,7 +706,7 @@ var remapSeismicAbiInputs = (abiFunction) => {
|
|
|
667
706
|
};
|
|
668
707
|
};
|
|
669
708
|
|
|
670
|
-
// src/signedCall.ts
|
|
709
|
+
// src/tx/signedCall.ts
|
|
671
710
|
var import_viem8 = require("viem");
|
|
672
711
|
var import_actions2 = require("viem/actions");
|
|
673
712
|
var import_utils = require("viem/utils");
|
|
@@ -698,9 +737,9 @@ function getRevertErrorData(err) {
|
|
|
698
737
|
return typeof error?.data === "object" ? error.data?.data : error.data;
|
|
699
738
|
}
|
|
700
739
|
|
|
701
|
-
// src/signedCall.ts
|
|
740
|
+
// src/tx/signedCall.ts
|
|
702
741
|
var doSignedCall = async (client, seismicTx, { block }) => {
|
|
703
|
-
if (client.account?.type === "json-rpc") {
|
|
742
|
+
if (client.account?.type === "json-rpc" || client.account?.type === "local") {
|
|
704
743
|
const { typedData, signature } = await signSeismicTxTypedData(client, seismicTx);
|
|
705
744
|
const response2 = await client.publicRequest({
|
|
706
745
|
method: "eth_call",
|
|
@@ -724,18 +763,19 @@ var prepareAccount = (paramsAccount, clientAccount) => {
|
|
|
724
763
|
}
|
|
725
764
|
return account;
|
|
726
765
|
};
|
|
727
|
-
async function signedCall(client, args, {
|
|
766
|
+
async function signedCall(client, args, {
|
|
767
|
+
blocksWindow,
|
|
768
|
+
encryptionNonce,
|
|
769
|
+
recentBlockHash,
|
|
770
|
+
expiresAtBlock
|
|
771
|
+
} = {}) {
|
|
728
772
|
const {
|
|
729
773
|
account: account_ = client.account,
|
|
730
|
-
batch = Boolean(client.batch?.multicall),
|
|
731
774
|
blockNumber,
|
|
732
775
|
blockTag = "latest",
|
|
733
776
|
accessList,
|
|
734
777
|
blobs,
|
|
735
|
-
code,
|
|
736
778
|
data: plaintextCalldata,
|
|
737
|
-
factory,
|
|
738
|
-
factoryData,
|
|
739
779
|
gas = 30000000,
|
|
740
780
|
gasPrice,
|
|
741
781
|
maxFeePerBlobGas,
|
|
@@ -779,6 +819,8 @@ async function signedCall(client, args, { blocksWindow = 100n, encryptionNonce }
|
|
|
779
819
|
to,
|
|
780
820
|
blocksWindow,
|
|
781
821
|
encryptionNonce,
|
|
822
|
+
recentBlockHash,
|
|
823
|
+
expiresAtBlock,
|
|
782
824
|
signedRead: true
|
|
783
825
|
});
|
|
784
826
|
const encryptedCalldata = await client.encrypt(plaintextCalldata, metadata);
|
|
@@ -828,6 +870,20 @@ async function signedCall(client, args, { blocksWindow = 100n, encryptionNonce }
|
|
|
828
870
|
}
|
|
829
871
|
|
|
830
872
|
// src/contract/read.ts
|
|
873
|
+
async function smartReadContract(walletClient, readClient, parameters, securityParams, forcedAccount) {
|
|
874
|
+
const readArgs = parameters;
|
|
875
|
+
if (hasShieldedParams(readArgs.abi, readArgs.functionName)) {
|
|
876
|
+
const account = forcedAccount ?? walletClient?.account;
|
|
877
|
+
if (!walletClient || !account) {
|
|
878
|
+
throw new Error("Wallet must have an account to perform signed reads");
|
|
879
|
+
}
|
|
880
|
+
return signedReadContract(walletClient, {
|
|
881
|
+
...parameters,
|
|
882
|
+
account
|
|
883
|
+
}, securityParams);
|
|
884
|
+
}
|
|
885
|
+
return import_actions3.readContract(readClient, parameters);
|
|
886
|
+
}
|
|
831
887
|
async function signedReadContract(client, parameters, securityParams) {
|
|
832
888
|
const {
|
|
833
889
|
abi,
|
|
@@ -854,20 +910,58 @@ async function signedReadContract(client, parameters, securityParams) {
|
|
|
854
910
|
data: data || "0x"
|
|
855
911
|
});
|
|
856
912
|
}
|
|
913
|
+
async function transparentReadContract(client, parameters) {
|
|
914
|
+
const {
|
|
915
|
+
abi,
|
|
916
|
+
functionName,
|
|
917
|
+
args = [],
|
|
918
|
+
address,
|
|
919
|
+
...rest
|
|
920
|
+
} = parameters;
|
|
921
|
+
const seismicAbi = import_viem9.getAbiItem({ abi, name: functionName });
|
|
922
|
+
const selector = import_viem9.toFunctionSelector(import_utils2.formatAbiItem(seismicAbi));
|
|
923
|
+
const ethAbi = remapSeismicAbiInputs(seismicAbi);
|
|
924
|
+
const encodedParams = import_viem9.encodeAbiParameters(ethAbi.inputs, args).slice(2);
|
|
925
|
+
const data = `${selector}${encodedParams}`;
|
|
926
|
+
const callOptions = rest;
|
|
927
|
+
const { data: result } = await client.call({
|
|
928
|
+
to: address,
|
|
929
|
+
data,
|
|
930
|
+
...callOptions
|
|
931
|
+
});
|
|
932
|
+
return import_viem9.decodeFunctionResult({
|
|
933
|
+
abi,
|
|
934
|
+
args,
|
|
935
|
+
functionName,
|
|
936
|
+
data: result || "0x"
|
|
937
|
+
});
|
|
938
|
+
}
|
|
857
939
|
|
|
858
940
|
// src/contract/write.ts
|
|
859
|
-
var
|
|
860
|
-
var
|
|
941
|
+
var import_viem12 = require("viem");
|
|
942
|
+
var import_actions5 = require("viem/actions");
|
|
861
943
|
|
|
862
|
-
// src/
|
|
863
|
-
var
|
|
864
|
-
var import_actions3 = require("viem/actions");
|
|
944
|
+
// src/contract/calldata.ts
|
|
945
|
+
var import_viem10 = require("viem");
|
|
865
946
|
var import_utils3 = require("viem/utils");
|
|
947
|
+
var getPlaintextCalldata = (parameters) => {
|
|
948
|
+
const { abi, functionName, args = [] } = parameters;
|
|
949
|
+
const seismicAbi = import_viem10.getAbiItem({ abi, name: functionName });
|
|
950
|
+
const selector = import_viem10.toFunctionSelector(import_utils3.formatAbiItem(seismicAbi));
|
|
951
|
+
const ethAbi = remapSeismicAbiInputs(seismicAbi);
|
|
952
|
+
const encodedParams = import_viem10.encodeAbiParameters(ethAbi.inputs, args).slice(2);
|
|
953
|
+
return `${selector}${encodedParams}`;
|
|
954
|
+
};
|
|
955
|
+
|
|
956
|
+
// src/tx/sendShielded.ts
|
|
957
|
+
var import_accounts2 = require("viem/accounts");
|
|
958
|
+
var import_actions4 = require("viem/actions");
|
|
959
|
+
var import_utils4 = require("viem/utils");
|
|
866
960
|
|
|
867
961
|
// src/error/account.ts
|
|
868
|
-
var
|
|
962
|
+
var import_viem11 = require("viem");
|
|
869
963
|
|
|
870
|
-
class AccountNotFoundError extends
|
|
964
|
+
class AccountNotFoundError extends import_viem11.BaseError {
|
|
871
965
|
constructor({ docsPath } = {}) {
|
|
872
966
|
super([
|
|
873
967
|
"Could not find an Account to execute with this Action.",
|
|
@@ -881,7 +975,7 @@ class AccountNotFoundError extends import_viem10.BaseError {
|
|
|
881
975
|
}
|
|
882
976
|
}
|
|
883
977
|
|
|
884
|
-
class AccountTypeNotSupportedError extends
|
|
978
|
+
class AccountTypeNotSupportedError extends import_viem11.BaseError {
|
|
885
979
|
constructor({
|
|
886
980
|
docsPath,
|
|
887
981
|
metaMessages,
|
|
@@ -895,8 +989,13 @@ class AccountTypeNotSupportedError extends import_viem10.BaseError {
|
|
|
895
989
|
}
|
|
896
990
|
}
|
|
897
991
|
|
|
898
|
-
// src/
|
|
899
|
-
async function sendShieldedTransaction(client, parameters, {
|
|
992
|
+
// src/tx/sendShielded.ts
|
|
993
|
+
async function sendShieldedTransaction(client, parameters, {
|
|
994
|
+
blocksWindow,
|
|
995
|
+
encryptionNonce,
|
|
996
|
+
recentBlockHash,
|
|
997
|
+
expiresAtBlock
|
|
998
|
+
} = {}) {
|
|
900
999
|
const {
|
|
901
1000
|
account: account_ = client.account,
|
|
902
1001
|
chain = client.chain,
|
|
@@ -927,7 +1026,7 @@ async function sendShieldedTransaction(client, parameters, { blocksWindow = 100n
|
|
|
927
1026
|
maxPriorityFeePerGas,
|
|
928
1027
|
to: parameters.to
|
|
929
1028
|
};
|
|
930
|
-
|
|
1029
|
+
import_utils4.assertRequest(assertRequestParams);
|
|
931
1030
|
const to = await (async () => {
|
|
932
1031
|
if (parameters.to)
|
|
933
1032
|
return parameters.to;
|
|
@@ -941,19 +1040,25 @@ async function sendShieldedTransaction(client, parameters, { blocksWindow = 100n
|
|
|
941
1040
|
value,
|
|
942
1041
|
blocksWindow,
|
|
943
1042
|
signedRead: false,
|
|
944
|
-
encryptionNonce
|
|
1043
|
+
encryptionNonce,
|
|
1044
|
+
recentBlockHash,
|
|
1045
|
+
expiresAtBlock
|
|
945
1046
|
});
|
|
946
1047
|
const encryptedCalldata = await client.encrypt(plaintextCalldata, metadata);
|
|
947
|
-
const
|
|
948
|
-
const
|
|
949
|
-
|
|
1048
|
+
const resolvedGasPrice = gasPrice ?? maxFeePerGas ?? await client.getGasPrice();
|
|
1049
|
+
const resolvedGas = gas ?? await estimateShieldedGas(client, {
|
|
1050
|
+
encryptedData: encryptedCalldata,
|
|
1051
|
+
metadata,
|
|
1052
|
+
gasPrice: resolvedGasPrice
|
|
1053
|
+
});
|
|
1054
|
+
const prepRequest = {
|
|
950
1055
|
accessList,
|
|
951
1056
|
authorizationList,
|
|
952
1057
|
blobs,
|
|
953
1058
|
chainId: metadata.legacyFields.chainId,
|
|
954
|
-
data:
|
|
1059
|
+
data: plaintextCalldata,
|
|
955
1060
|
from: account.address,
|
|
956
|
-
gas,
|
|
1061
|
+
gas: resolvedGas,
|
|
957
1062
|
gasPrice,
|
|
958
1063
|
maxFeePerBlobGas,
|
|
959
1064
|
maxFeePerGas,
|
|
@@ -961,24 +1066,27 @@ async function sendShieldedTransaction(client, parameters, { blocksWindow = 100n
|
|
|
961
1066
|
nonce: metadata.legacyFields.nonce,
|
|
962
1067
|
to,
|
|
963
1068
|
value,
|
|
964
|
-
type: "legacy",
|
|
965
1069
|
...rest
|
|
966
1070
|
};
|
|
967
|
-
const
|
|
1071
|
+
const viemPreparedTx = await import_actions4.prepareTransactionRequest(client, prepRequest);
|
|
968
1072
|
const preparedTx = {
|
|
969
1073
|
...viemPreparedTx,
|
|
1074
|
+
...metadata.seismicElements,
|
|
1075
|
+
data: encryptedCalldata,
|
|
1076
|
+
gasPrice: resolvedGasPrice,
|
|
970
1077
|
type: "seismic"
|
|
971
1078
|
};
|
|
972
1079
|
if (metadata.seismicElements.messageVersion === TYPED_DATA_MESSAGE_VERSION) {
|
|
973
1080
|
const { typedData, signature } = await signSeismicTxTypedData(client, preparedTx);
|
|
974
|
-
const action =
|
|
1081
|
+
const action = import_utils4.getAction(client, import_actions4.sendRawTransaction, "sendRawTransaction");
|
|
975
1082
|
return await action({
|
|
976
1083
|
serializedTransaction: { data: typedData, signature }
|
|
977
1084
|
});
|
|
978
|
-
} else {
|
|
979
|
-
const serializedTransaction = await account.signTransaction(preparedTx, { serializer: serializeSeismicTransaction });
|
|
980
|
-
return await import_actions3.sendRawTransaction(client, { serializedTransaction });
|
|
981
1085
|
}
|
|
1086
|
+
const serializedTransaction = await account.signTransaction(preparedTx, {
|
|
1087
|
+
serializer: serializeSeismicTransaction
|
|
1088
|
+
});
|
|
1089
|
+
return await import_actions4.sendRawTransaction(client, { serializedTransaction });
|
|
982
1090
|
}
|
|
983
1091
|
if (account?.type === "smart")
|
|
984
1092
|
throw new AccountTypeNotSupportedError({
|
|
@@ -993,7 +1101,7 @@ async function sendShieldedTransaction(client, parameters, { blocksWindow = 100n
|
|
|
993
1101
|
} catch (err) {
|
|
994
1102
|
if (err instanceof AccountTypeNotSupportedError)
|
|
995
1103
|
throw err;
|
|
996
|
-
throw
|
|
1104
|
+
throw import_utils4.getTransactionError(err, {
|
|
997
1105
|
...parameters,
|
|
998
1106
|
account,
|
|
999
1107
|
chain: chain || undefined,
|
|
@@ -1001,39 +1109,78 @@ async function sendShieldedTransaction(client, parameters, { blocksWindow = 100n
|
|
|
1001
1109
|
});
|
|
1002
1110
|
}
|
|
1003
1111
|
}
|
|
1112
|
+
async function estimateShieldedGas(client, {
|
|
1113
|
+
encryptedData,
|
|
1114
|
+
metadata,
|
|
1115
|
+
gasPrice
|
|
1116
|
+
}) {
|
|
1117
|
+
const block = await client.getBlock({ blockTag: "latest" });
|
|
1118
|
+
const blockGasLimit = block.gasLimit;
|
|
1119
|
+
const tempTx = {
|
|
1120
|
+
type: "seismic",
|
|
1121
|
+
chainId: metadata.legacyFields.chainId,
|
|
1122
|
+
nonce: metadata.legacyFields.nonce,
|
|
1123
|
+
gasPrice,
|
|
1124
|
+
gas: blockGasLimit,
|
|
1125
|
+
to: metadata.legacyFields.to ?? undefined,
|
|
1126
|
+
value: metadata.legacyFields.value,
|
|
1127
|
+
data: encryptedData,
|
|
1128
|
+
...metadata.seismicElements
|
|
1129
|
+
};
|
|
1130
|
+
const isEip712 = metadata.seismicElements.messageVersion === TYPED_DATA_MESSAGE_VERSION;
|
|
1131
|
+
if (isEip712) {
|
|
1132
|
+
const { typedData, signature } = await signSeismicTxTypedData(client, tempTx);
|
|
1133
|
+
const response2 = await client.request({
|
|
1134
|
+
method: "eth_estimateGas",
|
|
1135
|
+
params: [{ data: typedData, signature }]
|
|
1136
|
+
});
|
|
1137
|
+
return BigInt(response2);
|
|
1138
|
+
}
|
|
1139
|
+
const serializedTransaction = await client.account.signTransaction(tempTx, {
|
|
1140
|
+
serializer: serializeSeismicTransaction
|
|
1141
|
+
});
|
|
1142
|
+
const response = await client.request({
|
|
1143
|
+
method: "eth_estimateGas",
|
|
1144
|
+
params: [serializedTransaction]
|
|
1145
|
+
});
|
|
1146
|
+
return BigInt(response);
|
|
1147
|
+
}
|
|
1004
1148
|
|
|
1005
1149
|
// src/contract/write.ts
|
|
1006
|
-
|
|
1007
|
-
const
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1150
|
+
async function smartWriteContract(client, parameters) {
|
|
1151
|
+
const writeArgs = parameters;
|
|
1152
|
+
if (hasShieldedParams(writeArgs.abi, writeArgs.functionName)) {
|
|
1153
|
+
return shieldedWriteContract(client, parameters);
|
|
1154
|
+
}
|
|
1155
|
+
return import_actions5.writeContract(client, parameters);
|
|
1156
|
+
}
|
|
1157
|
+
async function transparentWriteContract(client, parameters) {
|
|
1158
|
+
const {
|
|
1159
|
+
abi: _abi,
|
|
1160
|
+
functionName: _fn,
|
|
1161
|
+
args: _args,
|
|
1162
|
+
address,
|
|
1163
|
+
...txOptions
|
|
1164
|
+
} = parameters;
|
|
1165
|
+
const data = getPlaintextCalldata(parameters);
|
|
1166
|
+
return client.sendTransaction({
|
|
1020
1167
|
to: address,
|
|
1021
|
-
data
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
gas,
|
|
1025
|
-
gasPrice
|
|
1026
|
-
};
|
|
1168
|
+
data,
|
|
1169
|
+
...txOptions
|
|
1170
|
+
});
|
|
1027
1171
|
}
|
|
1028
|
-
async function shieldedWriteContract(client, parameters) {
|
|
1172
|
+
async function shieldedWriteContract(client, parameters, securityParams) {
|
|
1029
1173
|
const plaintextCalldata = getPlaintextCalldata(parameters);
|
|
1030
|
-
const request =
|
|
1031
|
-
return sendShieldedTransaction(client, request);
|
|
1174
|
+
const request = buildShieldedWriteRequest(client, parameters, plaintextCalldata);
|
|
1175
|
+
return sendShieldedTransaction(client, request, securityParams);
|
|
1032
1176
|
}
|
|
1033
|
-
async function shieldedWriteContractDebug(client, parameters, checkContractDeployed, {
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1177
|
+
async function shieldedWriteContractDebug(client, parameters, checkContractDeployed, securityParams = {}) {
|
|
1178
|
+
const {
|
|
1179
|
+
blocksWindow,
|
|
1180
|
+
encryptionNonce: userEncNonce,
|
|
1181
|
+
recentBlockHash,
|
|
1182
|
+
expiresAtBlock
|
|
1183
|
+
} = securityParams;
|
|
1037
1184
|
if (checkContractDeployed) {
|
|
1038
1185
|
const code = await client.getCode({ address: parameters.address });
|
|
1039
1186
|
if (code === undefined) {
|
|
@@ -1041,7 +1188,7 @@ async function shieldedWriteContractDebug(client, parameters, checkContractDeplo
|
|
|
1041
1188
|
}
|
|
1042
1189
|
}
|
|
1043
1190
|
const plaintextCalldata = getPlaintextCalldata(parameters);
|
|
1044
|
-
const request =
|
|
1191
|
+
const request = buildShieldedWriteRequest(client, parameters, plaintextCalldata);
|
|
1045
1192
|
const encryptionNonce = userEncNonce ?? randomEncryptionNonce();
|
|
1046
1193
|
const metadata = await buildTxSeismicMetadata(client, {
|
|
1047
1194
|
account: parameters.account || client.account,
|
|
@@ -1050,30 +1197,46 @@ async function shieldedWriteContractDebug(client, parameters, checkContractDeplo
|
|
|
1050
1197
|
value: request.value,
|
|
1051
1198
|
encryptionNonce,
|
|
1052
1199
|
blocksWindow,
|
|
1200
|
+
recentBlockHash,
|
|
1201
|
+
expiresAtBlock,
|
|
1053
1202
|
signedRead: false
|
|
1054
1203
|
});
|
|
1055
1204
|
const txHash = await sendShieldedTransaction(client, request, {
|
|
1056
|
-
|
|
1057
|
-
|
|
1205
|
+
encryptionNonce,
|
|
1206
|
+
recentBlockHash: metadata.seismicElements.recentBlockHash,
|
|
1207
|
+
expiresAtBlock: metadata.seismicElements.expiresAtBlock
|
|
1058
1208
|
});
|
|
1059
1209
|
return {
|
|
1060
1210
|
plaintextTx: {
|
|
1061
1211
|
to: request.to || null,
|
|
1062
1212
|
data: plaintextCalldata,
|
|
1063
|
-
type:
|
|
1213
|
+
type: import_viem12.numberToHex(SEISMIC_TX_TYPE),
|
|
1064
1214
|
nonce: request.nonce,
|
|
1065
1215
|
gas: request.gas,
|
|
1066
1216
|
gasPrice: request.gasPrice,
|
|
1067
1217
|
value: request.value
|
|
1068
1218
|
},
|
|
1069
1219
|
shieldedTx: {
|
|
1070
|
-
type:
|
|
1220
|
+
type: import_viem12.numberToHex(SEISMIC_TX_TYPE),
|
|
1071
1221
|
...request,
|
|
1072
1222
|
...metadata.seismicElements
|
|
1073
1223
|
},
|
|
1074
1224
|
txHash
|
|
1075
1225
|
};
|
|
1076
1226
|
}
|
|
1227
|
+
function buildShieldedWriteRequest(client, parameters, plaintextCalldata) {
|
|
1228
|
+
const { address, gas, gasPrice, value, nonce } = parameters;
|
|
1229
|
+
return {
|
|
1230
|
+
account: client.account,
|
|
1231
|
+
chain: undefined,
|
|
1232
|
+
to: address,
|
|
1233
|
+
data: plaintextCalldata,
|
|
1234
|
+
nonce,
|
|
1235
|
+
value,
|
|
1236
|
+
gas,
|
|
1237
|
+
gasPrice
|
|
1238
|
+
};
|
|
1239
|
+
}
|
|
1077
1240
|
|
|
1078
1241
|
// src/viem-internal/function.ts
|
|
1079
1242
|
function getFunctionParameters(values) {
|
|
@@ -1089,7 +1252,7 @@ function getShieldedContract({
|
|
|
1089
1252
|
address,
|
|
1090
1253
|
client
|
|
1091
1254
|
}) {
|
|
1092
|
-
const viemContract =
|
|
1255
|
+
const viemContract = import_viem13.getContract({ abi, address, client });
|
|
1093
1256
|
const walletClient = (() => {
|
|
1094
1257
|
if (!client)
|
|
1095
1258
|
return;
|
|
@@ -1097,6 +1260,17 @@ function getShieldedContract({
|
|
|
1097
1260
|
return client.wallet;
|
|
1098
1261
|
return client;
|
|
1099
1262
|
})();
|
|
1263
|
+
const readClient = (() => {
|
|
1264
|
+
if (!client)
|
|
1265
|
+
return;
|
|
1266
|
+
if ("public" in client) {
|
|
1267
|
+
return client.public;
|
|
1268
|
+
}
|
|
1269
|
+
if ("wallet" in client) {
|
|
1270
|
+
return client.wallet;
|
|
1271
|
+
}
|
|
1272
|
+
return client;
|
|
1273
|
+
})();
|
|
1100
1274
|
const transparentWriteAction = new Proxy({}, {
|
|
1101
1275
|
get(_, functionName) {
|
|
1102
1276
|
return (...parameters) => {
|
|
@@ -1104,7 +1278,7 @@ function getShieldedContract({
|
|
|
1104
1278
|
throw new Error("Must provide wallet client to call Contract.write");
|
|
1105
1279
|
}
|
|
1106
1280
|
const { args, options } = getFunctionParameters(parameters);
|
|
1107
|
-
return
|
|
1281
|
+
return transparentWriteContract(walletClient, {
|
|
1108
1282
|
abi,
|
|
1109
1283
|
address,
|
|
1110
1284
|
functionName,
|
|
@@ -1146,6 +1320,22 @@ function getShieldedContract({
|
|
|
1146
1320
|
...options
|
|
1147
1321
|
});
|
|
1148
1322
|
}
|
|
1323
|
+
function smartWrite({
|
|
1324
|
+
functionName,
|
|
1325
|
+
args,
|
|
1326
|
+
...options
|
|
1327
|
+
}) {
|
|
1328
|
+
if (walletClient === undefined) {
|
|
1329
|
+
throw new Error("Must provide wallet client to call Contract.write");
|
|
1330
|
+
}
|
|
1331
|
+
return smartWriteContract(walletClient, {
|
|
1332
|
+
abi,
|
|
1333
|
+
address,
|
|
1334
|
+
functionName,
|
|
1335
|
+
args,
|
|
1336
|
+
...options
|
|
1337
|
+
});
|
|
1338
|
+
}
|
|
1149
1339
|
const shieldedWriteAction = new Proxy({}, {
|
|
1150
1340
|
get(_, functionName) {
|
|
1151
1341
|
return (...parameters) => {
|
|
@@ -1180,25 +1370,29 @@ function getShieldedContract({
|
|
|
1180
1370
|
}
|
|
1181
1371
|
return signedReadContract(walletClient, params);
|
|
1182
1372
|
}
|
|
1183
|
-
|
|
1373
|
+
function smartRead(params) {
|
|
1374
|
+
if (readClient === undefined) {
|
|
1375
|
+
throw new Error("Must provide a client to call Contract.read");
|
|
1376
|
+
}
|
|
1377
|
+
return smartReadContract(walletClient, readClient, params, undefined, walletClient?.account);
|
|
1378
|
+
}
|
|
1379
|
+
const transparentReadAction = new Proxy({}, {
|
|
1184
1380
|
get(_, functionName) {
|
|
1185
1381
|
return (...parameters) => {
|
|
1186
1382
|
const { args, options } = getFunctionParameters(parameters);
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
address,
|
|
1191
|
-
functionName,
|
|
1192
|
-
args,
|
|
1193
|
-
...options
|
|
1194
|
-
});
|
|
1383
|
+
const opts = options;
|
|
1384
|
+
if (opts?.account !== undefined) {
|
|
1385
|
+
throw new Error("Contract.tread 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 `contract.sread`.");
|
|
1195
1386
|
}
|
|
1196
|
-
|
|
1387
|
+
if (readClient === undefined) {
|
|
1388
|
+
throw new Error("Must provide a client to call Contract.tread");
|
|
1389
|
+
}
|
|
1390
|
+
return transparentReadContract(readClient, {
|
|
1197
1391
|
abi,
|
|
1198
1392
|
address,
|
|
1199
1393
|
functionName,
|
|
1200
1394
|
args,
|
|
1201
|
-
...
|
|
1395
|
+
...opts
|
|
1202
1396
|
});
|
|
1203
1397
|
};
|
|
1204
1398
|
}
|
|
@@ -1213,7 +1407,7 @@ function getShieldedContract({
|
|
|
1213
1407
|
const params = getFunctionParameters(parameters);
|
|
1214
1408
|
const { args } = params;
|
|
1215
1409
|
const {
|
|
1216
|
-
options: { account, ...options }
|
|
1410
|
+
options: { account: _account, ...options }
|
|
1217
1411
|
} = params;
|
|
1218
1412
|
return signedRead({
|
|
1219
1413
|
abi,
|
|
@@ -1226,20 +1420,50 @@ function getShieldedContract({
|
|
|
1226
1420
|
};
|
|
1227
1421
|
}
|
|
1228
1422
|
});
|
|
1423
|
+
const smartReadAction = new Proxy({}, {
|
|
1424
|
+
get(_, functionName) {
|
|
1425
|
+
return (...parameters) => {
|
|
1426
|
+
const { args, options } = getFunctionParameters(parameters);
|
|
1427
|
+
return smartRead({
|
|
1428
|
+
abi,
|
|
1429
|
+
address,
|
|
1430
|
+
functionName,
|
|
1431
|
+
args,
|
|
1432
|
+
...options
|
|
1433
|
+
});
|
|
1434
|
+
};
|
|
1435
|
+
}
|
|
1436
|
+
});
|
|
1437
|
+
const smartWriteAction = new Proxy({}, {
|
|
1438
|
+
get(_, functionName) {
|
|
1439
|
+
return (...parameters) => {
|
|
1440
|
+
const { args, options } = getFunctionParameters(parameters);
|
|
1441
|
+
return smartWrite({
|
|
1442
|
+
abi,
|
|
1443
|
+
address,
|
|
1444
|
+
functionName,
|
|
1445
|
+
args,
|
|
1446
|
+
...options
|
|
1447
|
+
});
|
|
1448
|
+
};
|
|
1449
|
+
}
|
|
1450
|
+
});
|
|
1229
1451
|
const contract = viemContract;
|
|
1230
1452
|
contract.twrite = transparentWriteAction;
|
|
1231
|
-
contract.tread =
|
|
1232
|
-
contract.
|
|
1453
|
+
contract.tread = transparentReadAction;
|
|
1454
|
+
contract.swrite = shieldedWriteAction;
|
|
1455
|
+
contract.sread = signedReadAction;
|
|
1456
|
+
contract.write = smartWriteAction;
|
|
1457
|
+
contract.read = smartReadAction;
|
|
1233
1458
|
contract.dwrite = shieldedWriteDebugAction;
|
|
1234
|
-
contract.read = signedReadAction;
|
|
1235
1459
|
return contract;
|
|
1236
1460
|
}
|
|
1237
1461
|
// src/client.ts
|
|
1238
|
-
var
|
|
1239
|
-
var
|
|
1462
|
+
var import_viem24 = require("viem");
|
|
1463
|
+
var import_accounts4 = require("viem/accounts");
|
|
1240
1464
|
|
|
1241
1465
|
// src/actions/depositContract.ts
|
|
1242
|
-
var
|
|
1466
|
+
var import_actions6 = require("viem/actions");
|
|
1243
1467
|
|
|
1244
1468
|
// src/abis/depositContract.ts
|
|
1245
1469
|
var depositContractAbi = [
|
|
@@ -1327,19 +1551,19 @@ var depositContractAbi = [
|
|
|
1327
1551
|
// src/actions/depositContract.ts
|
|
1328
1552
|
var DEPOSIT_CONTRACT_ADDRESS = "0x00000000219ab540356cBB839Cbe05303d7705Fa";
|
|
1329
1553
|
var depositContractPublicActions = (client) => ({
|
|
1330
|
-
getDepositRoot: async (args) =>
|
|
1554
|
+
getDepositRoot: async (args) => import_actions6.readContract(client, {
|
|
1331
1555
|
abi: depositContractAbi,
|
|
1332
1556
|
address: args.address || DEPOSIT_CONTRACT_ADDRESS,
|
|
1333
1557
|
functionName: "get_deposit_root"
|
|
1334
1558
|
}),
|
|
1335
|
-
getDepositCount: async (args) =>
|
|
1559
|
+
getDepositCount: async (args) => import_actions6.readContract(client, {
|
|
1336
1560
|
abi: depositContractAbi,
|
|
1337
1561
|
address: args.address || DEPOSIT_CONTRACT_ADDRESS,
|
|
1338
1562
|
functionName: "get_deposit_count"
|
|
1339
1563
|
})
|
|
1340
1564
|
});
|
|
1341
1565
|
var depositContractWalletActions = (client) => ({
|
|
1342
|
-
deposit: async (args) =>
|
|
1566
|
+
deposit: async (args) => import_actions6.writeContract(client, {
|
|
1343
1567
|
abi: depositContractAbi,
|
|
1344
1568
|
address: args.address || DEPOSIT_CONTRACT_ADDRESS,
|
|
1345
1569
|
functionName: "deposit",
|
|
@@ -1356,7 +1580,7 @@ var depositContractWalletActions = (client) => ({
|
|
|
1356
1580
|
});
|
|
1357
1581
|
|
|
1358
1582
|
// src/crypto/aead.ts
|
|
1359
|
-
var
|
|
1583
|
+
var import_viem14 = require("viem");
|
|
1360
1584
|
var encodeSeismicMetadataAsAAD = ({
|
|
1361
1585
|
sender,
|
|
1362
1586
|
legacyFields: { chainId, nonce, to, value },
|
|
@@ -1371,22 +1595,22 @@ var encodeSeismicMetadataAsAAD = ({
|
|
|
1371
1595
|
}) => {
|
|
1372
1596
|
const fields = [
|
|
1373
1597
|
sender,
|
|
1374
|
-
|
|
1375
|
-
nonce === 0 ? "0x" :
|
|
1598
|
+
import_viem14.toHex(chainId),
|
|
1599
|
+
nonce === 0 ? "0x" : import_viem14.toHex(nonce),
|
|
1376
1600
|
to ?? "0x",
|
|
1377
|
-
value === 0n ? "0x" :
|
|
1601
|
+
value === 0n ? "0x" : import_viem14.toHex(value),
|
|
1378
1602
|
encryptionPubkey,
|
|
1379
1603
|
encryptionNonce === "0x00" || encryptionNonce === "0x0" ? "0x" : encryptionNonce,
|
|
1380
|
-
messageVersion === 0 ? "0x" :
|
|
1604
|
+
messageVersion === 0 ? "0x" : import_viem14.toHex(messageVersion),
|
|
1381
1605
|
recentBlockHash,
|
|
1382
|
-
|
|
1606
|
+
import_viem14.toHex(expiresAtBlock),
|
|
1383
1607
|
signedRead ? "0x01" : "0x"
|
|
1384
1608
|
];
|
|
1385
|
-
return
|
|
1609
|
+
return import_viem14.toRlp(fields, "bytes");
|
|
1386
1610
|
};
|
|
1387
1611
|
|
|
1388
1612
|
// src/crypto/aes.ts
|
|
1389
|
-
var
|
|
1613
|
+
var import_viem15 = require("viem");
|
|
1390
1614
|
|
|
1391
1615
|
// ../../node_modules/@noble/hashes/esm/_assert.js
|
|
1392
1616
|
function anumber2(n) {
|
|
@@ -3422,7 +3646,7 @@ var _0n5 = BigInt(0);
|
|
|
3422
3646
|
var Point = secp256k1.ProjectivePoint;
|
|
3423
3647
|
|
|
3424
3648
|
// ../../node_modules/@noble/hashes/esm/hkdf.js
|
|
3425
|
-
function
|
|
3649
|
+
function extract2(hash, ikm, salt) {
|
|
3426
3650
|
ahash(hash);
|
|
3427
3651
|
if (salt === undefined)
|
|
3428
3652
|
salt = new Uint8Array(hash.outputLen);
|
|
@@ -3454,7 +3678,7 @@ function expand(hash, prk, info, length = 32) {
|
|
|
3454
3678
|
HKDF_COUNTER.fill(0);
|
|
3455
3679
|
return okm.slice(0, length);
|
|
3456
3680
|
}
|
|
3457
|
-
var hkdf = (hash, ikm, salt, info, length) => expand(hash,
|
|
3681
|
+
var hkdf = (hash, ikm, salt, info, length) => expand(hash, extract2(hash, ikm, salt), info, length);
|
|
3458
3682
|
|
|
3459
3683
|
// src/crypto/aes.ts
|
|
3460
3684
|
class AesGcmCrypto {
|
|
@@ -3463,7 +3687,7 @@ class AesGcmCrypto {
|
|
|
3463
3687
|
U64_SIZE = 8;
|
|
3464
3688
|
constructor(key) {
|
|
3465
3689
|
this.key = key;
|
|
3466
|
-
const keyBuffer =
|
|
3690
|
+
const keyBuffer = import_viem15.hexToBytes(key);
|
|
3467
3691
|
if (keyBuffer.length !== 32) {
|
|
3468
3692
|
throw new Error("Key must be 32 bytes (256 bits)");
|
|
3469
3693
|
}
|
|
@@ -3478,34 +3702,34 @@ class AesGcmCrypto {
|
|
|
3478
3702
|
return nonceBuffer;
|
|
3479
3703
|
}
|
|
3480
3704
|
validateAndConvertNonce(nonce) {
|
|
3481
|
-
const nonceBuffer =
|
|
3705
|
+
const nonceBuffer = import_viem15.hexToBytes(nonce);
|
|
3482
3706
|
if (nonceBuffer.length !== this.NONCE_LENGTH) {
|
|
3483
3707
|
throw new Error("Nonce must be 12 bytes");
|
|
3484
3708
|
}
|
|
3485
3709
|
return nonceBuffer;
|
|
3486
3710
|
}
|
|
3487
3711
|
createNonce(num) {
|
|
3488
|
-
return
|
|
3712
|
+
return import_viem15.bytesToHex(this.numberToNonce(num));
|
|
3489
3713
|
}
|
|
3490
3714
|
async encrypt(plaintext, nonce, aad) {
|
|
3491
3715
|
if (!plaintext || plaintext === "0x") {
|
|
3492
3716
|
return "0x";
|
|
3493
3717
|
}
|
|
3494
3718
|
const nonceBuffer = new Uint8Array(typeof nonce === "string" ? this.validateAndConvertNonce(nonce) : this.numberToNonce(nonce));
|
|
3495
|
-
const key =
|
|
3496
|
-
const plaintextBytes =
|
|
3719
|
+
const key = import_viem15.hexToBytes(this.key);
|
|
3720
|
+
const plaintextBytes = import_viem15.hexToBytes(plaintext);
|
|
3497
3721
|
const ciphertextBytes = await gcm(key, nonceBuffer, aad).encrypt(plaintextBytes);
|
|
3498
|
-
return
|
|
3722
|
+
return import_viem15.bytesToHex(ciphertextBytes);
|
|
3499
3723
|
}
|
|
3500
3724
|
async decrypt(ciphertext, nonce, aad) {
|
|
3501
3725
|
if (!ciphertext || ciphertext === "0x") {
|
|
3502
3726
|
return "0x";
|
|
3503
3727
|
}
|
|
3504
3728
|
const nonceBuffer = new Uint8Array(typeof nonce === "string" ? this.validateAndConvertNonce(nonce) : this.numberToNonce(nonce));
|
|
3505
|
-
const key =
|
|
3506
|
-
const ciphertextBytes =
|
|
3729
|
+
const key = import_viem15.hexToBytes(this.key);
|
|
3730
|
+
const ciphertextBytes = import_viem15.hexToBytes(ciphertext);
|
|
3507
3731
|
const plaintextBytes = await gcm(key, nonceBuffer, aad).decrypt(ciphertextBytes);
|
|
3508
|
-
return
|
|
3732
|
+
return import_viem15.bytesToHex(plaintextBytes);
|
|
3509
3733
|
}
|
|
3510
3734
|
}
|
|
3511
3735
|
var sharedSecretPoint = ({
|
|
@@ -3518,15 +3742,15 @@ var sharedSecretPoint = ({
|
|
|
3518
3742
|
var sharedKeyFromPoint = (sharedSecret) => {
|
|
3519
3743
|
const version = sharedSecret[63] & 1 | 2;
|
|
3520
3744
|
const finalSecret = sha2562.create().update(new Uint8Array([version])).update(sharedSecret.slice(0, 32)).digest();
|
|
3521
|
-
return
|
|
3745
|
+
return import_viem15.bytesToHex(finalSecret).slice(2);
|
|
3522
3746
|
};
|
|
3523
3747
|
var generateSharedKey = (inputs) => {
|
|
3524
3748
|
const sharedSecret = sharedSecretPoint(inputs);
|
|
3525
3749
|
return sharedKeyFromPoint(sharedSecret);
|
|
3526
3750
|
};
|
|
3527
3751
|
var deriveAesKey = (sharedSecret) => {
|
|
3528
|
-
const derivedKey = hkdf(sha2562,
|
|
3529
|
-
return
|
|
3752
|
+
const derivedKey = hkdf(sha2562, import_viem15.hexToBytes(`0x${sharedSecret}`), new Uint8Array(0), new TextEncoder().encode("aes-gcm key"), 32);
|
|
3753
|
+
return import_viem15.bytesToHex(derivedKey);
|
|
3530
3754
|
};
|
|
3531
3755
|
var generateAesKey = (aesKeys) => {
|
|
3532
3756
|
const sharedSecret = generateSharedKey(aesKeys);
|
|
@@ -3616,13 +3840,13 @@ var tokenExplorerUrl = ({
|
|
|
3616
3840
|
};
|
|
3617
3841
|
|
|
3618
3842
|
// src/precompiles/aes.ts
|
|
3619
|
-
var
|
|
3843
|
+
var import_viem17 = require("viem");
|
|
3620
3844
|
|
|
3621
3845
|
// src/precompiles/precompile.ts
|
|
3622
|
-
var
|
|
3846
|
+
var import_viem16 = require("viem");
|
|
3623
3847
|
var BASE_TX_GAS_COST = 21000n;
|
|
3624
3848
|
var calldataGasCost = (data) => {
|
|
3625
|
-
const dataBytes =
|
|
3849
|
+
const dataBytes = import_viem16.hexToBytes(data);
|
|
3626
3850
|
const nonZeroBytes = dataBytes.filter((b) => b !== 0).length;
|
|
3627
3851
|
return 4n * BigInt(dataBytes.length) + 12n * BigInt(nonZeroBytes);
|
|
3628
3852
|
};
|
|
@@ -3669,7 +3893,7 @@ var AES_GCM_PER_BLOCK = 30n;
|
|
|
3669
3893
|
var MIN_AES_PLAINTEXT_LENGTH = 0;
|
|
3670
3894
|
var MIN_AES_CIPHERTEXT_LENGTH = 16;
|
|
3671
3895
|
var aesGcmGasCost = (value) => {
|
|
3672
|
-
const valueBytes =
|
|
3896
|
+
const valueBytes = import_viem17.isHex(value) ? import_viem17.hexToBytes(value) : import_viem17.stringToBytes(value);
|
|
3673
3897
|
return calcLinearGasCost({
|
|
3674
3898
|
bus: 16,
|
|
3675
3899
|
len: valueBytes.length,
|
|
@@ -3679,21 +3903,21 @@ var aesGcmGasCost = (value) => {
|
|
|
3679
3903
|
};
|
|
3680
3904
|
var validateParams = (args, encryption) => {
|
|
3681
3905
|
const [aesKey, nonce, input] = args;
|
|
3682
|
-
const aesKeyBytes =
|
|
3906
|
+
const aesKeyBytes = import_viem17.hexToBytes(aesKey);
|
|
3683
3907
|
if (aesKeyBytes.length !== 32) {
|
|
3684
3908
|
throw new Error(`Invalid AES key: expected 32 bytes but found ${aesKeyBytes.length}`);
|
|
3685
3909
|
}
|
|
3686
|
-
const nonceBytes =
|
|
3910
|
+
const nonceBytes = import_viem17.numberToBytes(nonce, { size: 12 });
|
|
3687
3911
|
if (nonceBytes.length !== 12) {
|
|
3688
3912
|
throw new Error(`Invalid nonce: expected 12 bytes but found ${nonceBytes.length}`);
|
|
3689
3913
|
}
|
|
3690
3914
|
if (encryption) {
|
|
3691
|
-
const plaintextBytes =
|
|
3915
|
+
const plaintextBytes = import_viem17.stringToBytes(input);
|
|
3692
3916
|
if (plaintextBytes.length < MIN_AES_PLAINTEXT_LENGTH) {
|
|
3693
3917
|
throw new Error(`Invalid plaintext: expected at least ${MIN_AES_PLAINTEXT_LENGTH} bytes but found ${plaintextBytes.length}`);
|
|
3694
3918
|
}
|
|
3695
3919
|
} else {
|
|
3696
|
-
const ciphertextBytes =
|
|
3920
|
+
const ciphertextBytes = import_viem17.hexToBytes(input);
|
|
3697
3921
|
if (ciphertextBytes.length < MIN_AES_CIPHERTEXT_LENGTH) {
|
|
3698
3922
|
throw new Error(`Invalid ciphertext: expected at least ${MIN_AES_CIPHERTEXT_LENGTH} bytes but found ${ciphertextBytes.length}`);
|
|
3699
3923
|
}
|
|
@@ -3705,21 +3929,21 @@ var aesGcmEncryptPrecompile = {
|
|
|
3705
3929
|
gasCost: (args) => aesGcmGasCost(args.plaintext),
|
|
3706
3930
|
encodeParams: (args) => {
|
|
3707
3931
|
const [aesKey, nonce, plaintext] = validateParams([args.aesKey, args.nonce, args.plaintext], true);
|
|
3708
|
-
const nonceHex =
|
|
3709
|
-
const plaintextHex =
|
|
3932
|
+
const nonceHex = import_viem17.numberToHex(nonce, { size: 12 });
|
|
3933
|
+
const plaintextHex = import_viem17.stringToHex(plaintext);
|
|
3710
3934
|
return `${aesKey}${nonceHex.slice(2)}${plaintextHex.slice(2)}`;
|
|
3711
3935
|
},
|
|
3712
|
-
decodeResult: (result) =>
|
|
3936
|
+
decodeResult: (result) => import_viem17.trim(result)
|
|
3713
3937
|
};
|
|
3714
3938
|
var aesGcmDecryptPrecompile = {
|
|
3715
3939
|
address: AES_GCM_DECRYPT_ADDRESS,
|
|
3716
3940
|
gasCost: (args) => aesGcmGasCost(args.ciphertext),
|
|
3717
3941
|
encodeParams: (args) => {
|
|
3718
3942
|
const [aesKey, nonce, cipherText] = validateParams([args.aesKey, args.nonce, args.ciphertext], false);
|
|
3719
|
-
const nonceHex =
|
|
3943
|
+
const nonceHex = import_viem17.numberToHex(nonce, { size: 12 });
|
|
3720
3944
|
return `${aesKey}${nonceHex.slice(2)}${cipherText.slice(2)}`;
|
|
3721
3945
|
},
|
|
3722
|
-
decodeResult: (result) =>
|
|
3946
|
+
decodeResult: (result) => import_viem17.hexToString(import_viem17.trim(result))
|
|
3723
3947
|
};
|
|
3724
3948
|
var aesGcmEncrypt = async (client, args) => {
|
|
3725
3949
|
return callPrecompile({
|
|
@@ -3737,10 +3961,10 @@ var aesGcmDecrypt = async (client, args) => {
|
|
|
3737
3961
|
};
|
|
3738
3962
|
|
|
3739
3963
|
// src/precompiles/ecdh.ts
|
|
3740
|
-
var
|
|
3964
|
+
var import_viem19 = require("viem");
|
|
3741
3965
|
|
|
3742
3966
|
// src/precompiles/hkdf.ts
|
|
3743
|
-
var
|
|
3967
|
+
var import_viem18 = require("viem");
|
|
3744
3968
|
var HKDF_ADDRESS = "0x0000000000000000000000000000000000000068";
|
|
3745
3969
|
var SHA256_BASE_GAS = 60n;
|
|
3746
3970
|
var SHA256_PER_WORD = 12n;
|
|
@@ -3749,7 +3973,7 @@ var SHARED_SECRET_GAS = 3000n;
|
|
|
3749
3973
|
var hdfkPrecompile = {
|
|
3750
3974
|
address: HKDF_ADDRESS,
|
|
3751
3975
|
gasCost: (ikmHex) => {
|
|
3752
|
-
const ikmBytes =
|
|
3976
|
+
const ikmBytes = import_viem18.isHex(ikmHex) ? import_viem18.hexToBytes(ikmHex) : import_viem18.stringToBytes(ikmHex);
|
|
3753
3977
|
const linearGasCost = calcLinearGasCost({
|
|
3754
3978
|
bus: 32,
|
|
3755
3979
|
len: ikmBytes.length,
|
|
@@ -3759,13 +3983,13 @@ var hdfkPrecompile = {
|
|
|
3759
3983
|
return 2n * linearGasCost + HKDF_EXPAND_COST_GAS;
|
|
3760
3984
|
},
|
|
3761
3985
|
encodeParams: (input) => {
|
|
3762
|
-
if (
|
|
3986
|
+
if (import_viem18.isHex(input)) {
|
|
3763
3987
|
return input;
|
|
3764
3988
|
}
|
|
3765
|
-
return
|
|
3989
|
+
return import_viem18.stringToHex(input);
|
|
3766
3990
|
},
|
|
3767
3991
|
decodeResult: (result) => {
|
|
3768
|
-
const [output] =
|
|
3992
|
+
const [output] = import_viem18.decodeAbiParameters([{ type: "bytes32" }], result);
|
|
3769
3993
|
return output;
|
|
3770
3994
|
}
|
|
3771
3995
|
};
|
|
@@ -3782,7 +4006,7 @@ var ECDH_ADDRESS = "0x0000000000000000000000000000000000000065";
|
|
|
3782
4006
|
var SECRET_KEY_LENGTH = 32;
|
|
3783
4007
|
var PUBLIC_KEY_LENGTH = 33;
|
|
3784
4008
|
var validateKey = (key, sk) => {
|
|
3785
|
-
const bytes =
|
|
4009
|
+
const bytes = import_viem19.hexToBytes(key);
|
|
3786
4010
|
const expectedLength = sk ? SECRET_KEY_LENGTH : PUBLIC_KEY_LENGTH;
|
|
3787
4011
|
if (bytes.length !== expectedLength) {
|
|
3788
4012
|
throw new Error(`Invalid ${sk ? "secret" : "public"} key: must be ${expectedLength} bytes (received ${bytes.length})`);
|
|
@@ -3797,7 +4021,7 @@ var ecdhPrecompile = {
|
|
|
3797
4021
|
return `${sk}${pk.slice(2)}`;
|
|
3798
4022
|
},
|
|
3799
4023
|
decodeResult: (result) => {
|
|
3800
|
-
const [output] =
|
|
4024
|
+
const [output] = import_viem19.decodeAbiParameters([{ type: "bytes32" }], result);
|
|
3801
4025
|
return output;
|
|
3802
4026
|
}
|
|
3803
4027
|
};
|
|
@@ -3810,7 +4034,7 @@ var ecdh = async (client, args) => {
|
|
|
3810
4034
|
};
|
|
3811
4035
|
|
|
3812
4036
|
// src/precompiles/rng.ts
|
|
3813
|
-
var
|
|
4037
|
+
var import_viem20 = require("viem");
|
|
3814
4038
|
var RNG_ADDRESS = "0x0000000000000000000000000000000000000064";
|
|
3815
4039
|
var RNG_INIT_BASE_GAS = 3500n;
|
|
3816
4040
|
var STROBE_128_WORD_GAS = 5n;
|
|
@@ -3818,9 +4042,9 @@ var persToBytes = (pers) => {
|
|
|
3818
4042
|
if (!pers) {
|
|
3819
4043
|
return new Uint8Array;
|
|
3820
4044
|
}
|
|
3821
|
-
if (
|
|
3822
|
-
return
|
|
3823
|
-
} else if (
|
|
4045
|
+
if (import_viem20.isHex(pers)) {
|
|
4046
|
+
return import_viem20.hexToBytes(pers);
|
|
4047
|
+
} else if (import_viem20.isBytes(pers)) {
|
|
3824
4048
|
return pers;
|
|
3825
4049
|
}
|
|
3826
4050
|
throw new Error("Invalid pers: must be a hex or bytes array");
|
|
@@ -3847,15 +4071,15 @@ var rngPrecompile = {
|
|
|
3847
4071
|
if (BigInt(numBytes) > 32n) {
|
|
3848
4072
|
throw new Error("Invalid length: must be less than or equal to 32");
|
|
3849
4073
|
}
|
|
3850
|
-
const encodedBytes =
|
|
4074
|
+
const encodedBytes = import_viem20.numberToHex(numBytes, { size: 4 });
|
|
3851
4075
|
if (!pers) {
|
|
3852
4076
|
return encodedBytes;
|
|
3853
4077
|
}
|
|
3854
|
-
const encodedPers =
|
|
4078
|
+
const encodedPers = import_viem20.bytesToHex(persToBytes(pers));
|
|
3855
4079
|
return `${encodedBytes}${encodedPers.slice(2)}`;
|
|
3856
4080
|
},
|
|
3857
4081
|
decodeResult: (result) => {
|
|
3858
|
-
const [output] =
|
|
4082
|
+
const [output] = import_viem20.decodeAbiParameters([{ type: "uint256" }], import_viem20.pad(result));
|
|
3859
4083
|
return output;
|
|
3860
4084
|
}
|
|
3861
4085
|
};
|
|
@@ -3868,7 +4092,7 @@ var rng = async (client, args) => {
|
|
|
3868
4092
|
};
|
|
3869
4093
|
|
|
3870
4094
|
// src/precompiles/secp256k1.ts
|
|
3871
|
-
var
|
|
4095
|
+
var import_viem21 = require("viem");
|
|
3872
4096
|
var SECP256K1_SIG_ADDRESS = "0x0000000000000000000000000000000000000069";
|
|
3873
4097
|
var SECP256K1_SIG_BASE_GAS = 3000n;
|
|
3874
4098
|
var secp256k1SigPrecompile = {
|
|
@@ -3880,9 +4104,9 @@ var secp256k1SigPrecompile = {
|
|
|
3880
4104
|
{ name: "messageHash", type: "bytes32" }
|
|
3881
4105
|
];
|
|
3882
4106
|
const skHex = sk;
|
|
3883
|
-
return
|
|
4107
|
+
return import_viem21.encodeAbiParameters(params, [skHex, import_viem21.hashMessage(message)]);
|
|
3884
4108
|
},
|
|
3885
|
-
decodeResult:
|
|
4109
|
+
decodeResult: import_viem21.parseSignature
|
|
3886
4110
|
};
|
|
3887
4111
|
var secp256k1Sig = async (client, args) => {
|
|
3888
4112
|
return callPrecompile({
|
|
@@ -4130,7 +4354,7 @@ function parseEncryptedData(encryptedData) {
|
|
|
4130
4354
|
}
|
|
4131
4355
|
|
|
4132
4356
|
// src/actions/src20/directory.ts
|
|
4133
|
-
var
|
|
4357
|
+
var import_viem22 = require("viem");
|
|
4134
4358
|
|
|
4135
4359
|
// src/abis/directory.ts
|
|
4136
4360
|
var DIRECTORY_ADDRESS = "0x1000000000000000000000000000000000000004";
|
|
@@ -4208,7 +4432,7 @@ async function registerKey(client, aesKey) {
|
|
|
4208
4432
|
return withTimeout(txPromise, TX_TIMEOUT_MS);
|
|
4209
4433
|
}
|
|
4210
4434
|
function computeKeyHash(aesKey) {
|
|
4211
|
-
return
|
|
4435
|
+
return import_viem22.keccak256(aesKey);
|
|
4212
4436
|
}
|
|
4213
4437
|
|
|
4214
4438
|
// src/actions/src20/watchSRC20Events.ts
|
|
@@ -4345,47 +4569,143 @@ var src20WalletActions = (client) => ({
|
|
|
4345
4569
|
watchSRC20Events: (params) => watchSRC20Events(client, params)
|
|
4346
4570
|
});
|
|
4347
4571
|
|
|
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
|
+
|
|
4348
4660
|
// src/actions/wallet.ts
|
|
4349
|
-
var import_actions6 = require("viem/actions");
|
|
4350
4661
|
var shieldedWalletActions = (client) => {
|
|
4351
4662
|
return {
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
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);
|
|
4356
4669
|
return debugResult;
|
|
4357
4670
|
},
|
|
4358
|
-
readContract: (args
|
|
4359
|
-
|
|
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
|
+
},
|
|
4360
4680
|
signedCall: (args, securityParams) => signedCall(client, args, securityParams),
|
|
4361
4681
|
sendShieldedTransaction: (args, securityParams) => sendShieldedTransaction(client, args, securityParams)
|
|
4362
4682
|
};
|
|
4363
4683
|
};
|
|
4364
4684
|
|
|
4365
4685
|
// src/crypto/secp.ts
|
|
4366
|
-
var
|
|
4686
|
+
var import_viem23 = require("viem");
|
|
4367
4687
|
var compressPublicKey = (uncompressedKey) => {
|
|
4368
4688
|
const cleanKey = uncompressedKey.replace("0x", "");
|
|
4369
4689
|
if (cleanKey.length !== 130) {
|
|
4370
4690
|
throw new Error("Invalid uncompressed public key length");
|
|
4371
4691
|
}
|
|
4372
4692
|
const pt = secp256k1.ProjectivePoint.fromHex(cleanKey);
|
|
4373
|
-
return
|
|
4693
|
+
return import_viem23.bytesToHex(pt.toRawBytes(true));
|
|
4374
4694
|
};
|
|
4375
4695
|
|
|
4376
4696
|
// src/client.ts
|
|
4377
4697
|
var getEncryption = (networkPk, clientSk) => {
|
|
4378
|
-
const encryptionPrivateKey = clientSk ??
|
|
4698
|
+
const encryptionPrivateKey = clientSk ?? import_accounts4.generatePrivateKey();
|
|
4379
4699
|
const aesKey = generateAesKey({
|
|
4380
4700
|
privateKey: encryptionPrivateKey,
|
|
4381
4701
|
networkPublicKey: networkPk
|
|
4382
4702
|
});
|
|
4383
|
-
const uncompressedPk =
|
|
4703
|
+
const uncompressedPk = import_accounts4.privateKeyToAccount(encryptionPrivateKey).publicKey;
|
|
4384
4704
|
const encryptionPublicKey = compressPublicKey(uncompressedPk);
|
|
4385
4705
|
return { encryptionPrivateKey, encryptionPublicKey, aesKey };
|
|
4386
4706
|
};
|
|
4387
4707
|
var createShieldedPublicClient = (parameters) => {
|
|
4388
|
-
const viemPublicClient =
|
|
4708
|
+
const viemPublicClient = import_viem24.createPublicClient(parameters);
|
|
4389
4709
|
return viemPublicClient.extend(shieldedPublicActions).extend(depositContractPublicActions).extend(src20PublicActions);
|
|
4390
4710
|
};
|
|
4391
4711
|
var getSeismicClients = async ({
|
|
@@ -4401,12 +4721,12 @@ var getSeismicClients = async ({
|
|
|
4401
4721
|
});
|
|
4402
4722
|
const networkPublicKey = await pubClient.getTeePublicKey();
|
|
4403
4723
|
const { aesKey, encryptionPublicKey } = getEncryption(networkPublicKey, encryptionSk);
|
|
4404
|
-
const wallet =
|
|
4724
|
+
const wallet = import_viem24.createClient({
|
|
4405
4725
|
account,
|
|
4406
4726
|
chain,
|
|
4407
4727
|
transport,
|
|
4408
4728
|
rpcSchema: seismicRpcSchema
|
|
4409
|
-
}).extend(
|
|
4729
|
+
}).extend(import_viem24.walletActions).extend(() => import_viem24.publicActions(pubClient)).extend(() => encryptionActions(aesKey, encryptionPublicKey)).extend(() => shieldedPublicActions(pubClient)).extend(shieldedWalletActions).extend(depositContractWalletActions).extend(src20WalletActions);
|
|
4410
4730
|
return {
|
|
4411
4731
|
public: pubClient,
|
|
4412
4732
|
wallet
|
|
@@ -4429,11 +4749,11 @@ var createShieldedWalletClient = async ({
|
|
|
4429
4749
|
return clients.wallet;
|
|
4430
4750
|
};
|
|
4431
4751
|
// src/faucet.ts
|
|
4432
|
-
var
|
|
4433
|
-
var DEFAULT_MIN_BALANCE_WEI =
|
|
4752
|
+
var import_utils14 = require("viem/utils");
|
|
4753
|
+
var DEFAULT_MIN_BALANCE_WEI = import_utils14.parseEther("0.5");
|
|
4434
4754
|
var parseMinBalance = (minBalanceWei, minBalanceEther) => {
|
|
4435
4755
|
if (minBalanceWei && minBalanceEther) {
|
|
4436
|
-
if (BigInt(minBalanceWei) !==
|
|
4756
|
+
if (BigInt(minBalanceWei) !== import_utils14.parseEther(minBalanceEther.toString())) {
|
|
4437
4757
|
console.warn("Both minBalanceWei and minBalanceEther provided, using minBalanceWei");
|
|
4438
4758
|
}
|
|
4439
4759
|
}
|
|
@@ -4441,7 +4761,7 @@ var parseMinBalance = (minBalanceWei, minBalanceEther) => {
|
|
|
4441
4761
|
return BigInt(minBalanceWei);
|
|
4442
4762
|
}
|
|
4443
4763
|
if (minBalanceEther) {
|
|
4444
|
-
return
|
|
4764
|
+
return import_utils14.parseEther(minBalanceEther.toString());
|
|
4445
4765
|
}
|
|
4446
4766
|
return DEFAULT_MIN_BALANCE_WEI;
|
|
4447
4767
|
};
|