@hinkal/common 0.2.22 → 0.2.23
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/API/proxyAccountsCalls.cjs +1 -1
- package/API/proxyAccountsCalls.mjs +13 -13
- package/README.md +63 -267
- package/constants/activity.constants.cjs +1 -1
- package/constants/activity.constants.mjs +0 -1
- package/constants/addresses.constants.cjs +1 -1
- package/constants/addresses.constants.mjs +9 -10
- package/constants/contracts.constants.cjs +1 -1
- package/constants/contracts.constants.d.ts +3 -3
- package/constants/contracts.constants.mjs +29 -29
- package/constants/server.constants.cjs +1 -1
- package/constants/server.constants.mjs +28 -29
- package/constants/tasks.constants.cjs +1 -1
- package/constants/tasks.constants.mjs +4 -5
- package/crypto/poseidon.cjs +1 -1
- package/crypto/poseidon.mjs +10 -10
- package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.cjs +1 -1
- package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.mjs +24 -24
- package/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/data-structures/Hinkal/Hinkal.mjs +4 -5
- package/data-structures/Hinkal/IHinkal.d.ts +2 -2
- package/data-structures/Hinkal/hinkalApprove.cjs +1 -1
- package/data-structures/Hinkal/hinkalApprove.mjs +40 -40
- package/data-structures/Hinkal/hinkalCheckTokenRegistry.cjs +1 -1
- package/data-structures/Hinkal/hinkalCheckTokenRegistry.mjs +7 -8
- package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalDeposit.mjs +4 -5
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +2 -3
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.mjs +18 -19
- package/data-structures/Hinkal/hinkalDepostAndBridge.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepostAndBridge.mjs +3 -4
- package/data-structures/Hinkal/hinkalInsideTransact.cjs +1 -1
- package/data-structures/Hinkal/hinkalInsideTransact.mjs +14 -13
- package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
- package/data-structures/Hinkal/hinkalPrivateWallet.mjs +2 -3
- package/data-structures/Hinkal/hinkalProoflessDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalProoflessDeposit.mjs +27 -26
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.mjs +38 -39
- package/data-structures/Hinkal/hinkalSolanaSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaSwap.mjs +16 -17
- package/data-structures/Hinkal/hinkalSolanaTransfer.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaTransfer.mjs +24 -25
- package/data-structures/Hinkal/hinkalSolanaWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaWithdraw.mjs +15 -16
- package/data-structures/Hinkal/hinkalSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSwap.mjs +2 -3
- package/data-structures/Hinkal/hinkalTransfer.cjs +1 -1
- package/data-structures/Hinkal/hinkalTransfer.mjs +2 -3
- package/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdraw.mjs +9 -10
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.mjs +8 -9
- package/data-structures/Hinkal/resetMerkleTrees.cjs +1 -1
- package/data-structures/Hinkal/resetMerkleTrees.mjs +10 -10
- package/data-structures/IndexedDB/activity-db.cjs +1 -1
- package/data-structures/IndexedDB/activity-db.mjs +39 -41
- package/data-structures/IndexedDB/balances-db.cjs +1 -1
- package/data-structures/IndexedDB/balances-db.mjs +8 -9
- package/data-structures/IndexedDB/contact-db.cjs +1 -1
- package/data-structures/IndexedDB/contact-db.mjs +21 -23
- package/data-structures/IndexedDB/signatures-db.cjs +1 -1
- package/data-structures/IndexedDB/signatures-db.mjs +2 -3
- package/data-structures/TokenDBs/EventsPublicTokensDB.cjs +1 -1
- package/data-structures/TokenDBs/EventsPublicTokensDB.mjs +34 -36
- package/data-structures/crypto-keys/decodeUTXO.cjs +1 -1
- package/data-structures/crypto-keys/decodeUTXO.mjs +45 -45
- package/data-structures/crypto-keys/encryptDecryptUtxo.cjs +1 -1
- package/data-structures/crypto-keys/encryptDecryptUtxo.mjs +28 -27
- package/data-structures/crypto-keys/keys.cjs +1 -1
- package/data-structures/crypto-keys/keys.d.ts +2 -3
- package/data-structures/crypto-keys/keys.mjs +56 -57
- package/data-structures/event-service/evm/AbstractEventService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractEventService.mjs +14 -14
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.d.ts +2 -3
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.mjs +5 -4
- package/data-structures/event-service/evm/AbstractSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractSnapshotService.mjs +6 -3
- package/data-structures/event-service/evm/BlockchainEventEmitter.cjs +1 -1
- package/data-structures/event-service/evm/BlockchainEventEmitter.d.ts +1 -1
- package/data-structures/event-service/evm/BlockchainEventEmitter.mjs +22 -18
- package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.mjs +2 -2
- package/data-structures/presale/PresaleContractWrapper.cjs +1 -1
- package/data-structures/presale/PresaleContractWrapper.d.ts +3 -3
- package/data-structures/presale/PresaleContractWrapper.mjs +10 -10
- package/data-structures/provider-adapter/IProviderAdapter.d.ts +7 -7
- package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.mjs +16 -14
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.mjs +7 -5
- package/error-handling/get-error.message.cjs +1 -1
- package/error-handling/get-error.message.mjs +2 -3
- package/functions/kyc/zkMeHelper.cjs +1 -1
- package/functions/kyc/zkMeHelper.mjs +3 -3
- package/functions/pre-transaction/getFlatFees.cjs +1 -1
- package/functions/pre-transaction/getFlatFees.mjs +2 -3
- package/functions/pre-transaction/getSolanaCalldataHash.cjs +1 -1
- package/functions/pre-transaction/getSolanaCalldataHash.mjs +21 -21
- package/functions/pre-transaction/getVolatileTransferAmount.cjs +1 -1
- package/functions/pre-transaction/getVolatileTransferAmount.mjs +2 -3
- package/functions/pre-transaction/interaction-to-action.cjs +1 -1
- package/functions/pre-transaction/interaction-to-action.mjs +2 -3
- package/functions/private-wallet/emporium.helpers.cjs +1 -1
- package/functions/private-wallet/emporium.helpers.d.ts +6 -7
- package/functions/private-wallet/emporium.helpers.mjs +104 -105
- package/functions/private-wallet/emporium.swap.helpers.cjs +1 -1
- package/functions/private-wallet/emporium.swap.helpers.mjs +44 -43
- package/functions/private-wallet/opProducer.cjs +1 -1
- package/functions/private-wallet/opProducer.mjs +1 -1
- package/functions/snarkjs/common.snarkjs.cjs +1 -1
- package/functions/snarkjs/common.snarkjs.mjs +21 -18
- package/functions/snarkjs/constructSolanaZkProof.cjs +1 -1
- package/functions/snarkjs/constructSolanaZkProof.mjs +11 -12
- package/functions/utils/addresses.cjs +1 -1
- package/functions/utils/addresses.mjs +6 -6
- package/functions/utils/cacheFunctions.cjs +1 -1
- package/functions/utils/cacheFunctions.d.ts +1 -1
- package/functions/utils/cacheFunctions.mjs +55 -54
- package/functions/utils/convertEmporiumOpToCallInfo.cjs +1 -1
- package/functions/utils/convertEmporiumOpToCallInfo.mjs +5 -5
- package/functions/utils/create-provider.cjs +1 -1
- package/functions/utils/create-provider.d.ts +2 -2
- package/functions/utils/create-provider.mjs +5 -5
- package/functions/utils/encryptInputForEnclave.cjs +1 -1
- package/functions/utils/encryptInputForEnclave.mjs +9 -9
- package/functions/utils/ethers-formatter.utils.d.ts +1 -1
- package/functions/utils/external-action.utils.cjs +1 -1
- package/functions/utils/external-action.utils.mjs +2 -2
- package/functions/utils/getContractAddress.cjs +1 -0
- package/functions/utils/getContractAddress.d.ts +2 -0
- package/functions/utils/getContractAddress.mjs +9 -0
- package/functions/utils/getDataFromTransaction.cjs +1 -1
- package/functions/utils/getDataFromTransaction.d.ts +0 -11
- package/functions/utils/getDataFromTransaction.mjs +26 -50
- package/functions/utils/getRecipientInfoFromUserKeys.cjs +1 -1
- package/functions/utils/getRecipientInfoFromUserKeys.mjs +1 -1
- package/functions/utils/getSignerFromContract.cjs +1 -0
- package/functions/utils/getSignerFromContract.d.ts +3 -0
- package/functions/utils/getSignerFromContract.mjs +16 -0
- package/functions/utils/getUtxosFromReceipt.utils.cjs +1 -1
- package/functions/utils/getUtxosFromReceipt.utils.d.ts +1 -1
- package/functions/utils/getUtxosFromReceipt.utils.mjs +15 -16
- package/functions/utils/inLogicMetadata.cjs +1 -1
- package/functions/utils/inLogicMetadata.mjs +2 -2
- package/functions/utils/nftTokenFunctions.cjs +1 -1
- package/functions/utils/nftTokenFunctions.mjs +2 -3
- package/functions/utils/publicBalance.utils.cjs +1 -1
- package/functions/utils/publicBalance.utils.d.ts +1 -1
- package/functions/utils/publicBalance.utils.mjs +42 -42
- package/functions/utils/rpc-int-encode.cjs +1 -1
- package/functions/utils/rpc-int-encode.d.ts +1 -2
- package/functions/utils/rpc-int-encode.mjs +3 -6
- package/functions/utils/solanaMint.utils.cjs +1 -1
- package/functions/utils/solanaMint.utils.mjs +6 -6
- package/functions/web3/EIP-712.cjs +1 -1
- package/functions/web3/EIP-712.d.ts +4 -4
- package/functions/web3/EIP-712.mjs +1 -1
- package/functions/web3/etherFunctions.cjs +1 -1
- package/functions/web3/etherFunctions.mjs +32 -29
- package/functions/web3/events/balanceChangedCustomHandler.cjs +1 -1
- package/functions/web3/events/balanceChangedCustomHandler.mjs +4 -5
- package/functions/web3/events/balanceChangedHandler.cjs +1 -1
- package/functions/web3/events/balanceChangedHandler.mjs +2 -3
- package/functions/web3/events/getApprovedBalance.cjs +1 -1
- package/functions/web3/events/getApprovedBalance.mjs +1 -1
- package/functions/web3/events/getInputUtxosEnclave.cjs +1 -1
- package/functions/web3/events/getInputUtxosEnclave.mjs +20 -20
- package/functions/web3/events/getTransactionLogEvents.cjs +1 -1
- package/functions/web3/events/getTransactionLogEvents.d.ts +3 -3
- package/functions/web3/events/getTransactionLogEvents.mjs +6 -5
- package/functions/web3/events/index.d.ts +0 -1
- package/functions/web3/fetchSolanaMerkleTreeRootHash.cjs +1 -1
- package/functions/web3/fetchSolanaMerkleTreeRootHash.d.ts +1 -2
- package/functions/web3/fetchSolanaMerkleTreeRootHash.mjs +4 -5
- package/functions/web3/functionCalls/accessTokenCalls.cjs +1 -1
- package/functions/web3/functionCalls/accessTokenCalls.mjs +10 -11
- package/functions/web3/functionCalls/approveToken.cjs +1 -1
- package/functions/web3/functionCalls/approveToken.mjs +61 -58
- package/functions/web3/functionCalls/constructBatchCall.cjs +1 -1
- package/functions/web3/functionCalls/constructBatchCall.d.ts +2 -2
- package/functions/web3/functionCalls/constructBatchCall.mjs +10 -9
- package/functions/web3/functionCalls/estimateGasRelayer.cjs +1 -1
- package/functions/web3/functionCalls/estimateGasRelayer.mjs +1 -1
- package/functions/web3/functionCalls/inHinkalApprovalCalls.cjs +1 -1
- package/functions/web3/functionCalls/inHinkalApprovalCalls.mjs +18 -21
- package/functions/web3/functionCalls/recoverTransactionFromError.d.ts +1 -1
- package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
- package/functions/web3/functionCalls/transactCallDirect.mjs +38 -34
- package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
- package/functions/web3/functionCalls/transactCallRelayer.mjs +8 -10
- package/functions/web3/getContractMetadata.cjs +1 -1
- package/functions/web3/getContractMetadata.d.ts +1 -1
- package/functions/web3/getContractMetadata.mjs +25 -25
- package/functions/web3/getPublicAddressBalance.cjs +1 -1
- package/functions/web3/getPublicAddressBalance.mjs +7 -6
- package/functions/web3/getTokenHolder.cjs +1 -1
- package/functions/web3/getTokenHolder.mjs +16 -15
- package/functions/web3/odosAPI.cjs +1 -1
- package/functions/web3/odosAPI.mjs +6 -7
- package/functions/web3/oneInchAPI.cjs +1 -1
- package/functions/web3/oneInchAPI.mjs +2 -3
- package/functions/web3/runContractFunction.cjs +1 -1
- package/functions/web3/runContractFunction.d.ts +6 -5
- package/functions/web3/runContractFunction.mjs +41 -45
- package/functions/web3/uniswapAPI.cjs +1 -1
- package/functions/web3/uniswapAPI.d.ts +2 -2
- package/functions/web3/uniswapAPI.mjs +23 -24
- package/index.cjs +1 -1
- package/index.mjs +336 -340
- package/package.json +3 -4
- package/providers/CustomEthersProvider.d.ts +1 -1
- package/providers/EthersProviderAdapter.cjs +1 -1
- package/providers/EthersProviderAdapter.d.ts +7 -7
- package/providers/EthersProviderAdapter.mjs +46 -44
- package/providers/SolanaProviderAdapter.d.ts +1 -1
- package/providers/WagmiProviderAdapter.cjs +1 -1
- package/providers/WagmiProviderAdapter.d.ts +5 -5
- package/providers/WagmiProviderAdapter.mjs +37 -33
- package/providers/prepareEthersHinkal.cjs +1 -1
- package/providers/prepareEthersHinkal.d.ts +2 -2
- package/providers/prepareEthersHinkal.mjs +3 -5
- package/providers/prepareWagmiHinkal.cjs +1 -1
- package/providers/prepareWagmiHinkal.mjs +3 -5
- package/types/activities.types.d.ts +2 -3
- package/types/big-intable.types.d.ts +3 -2
- package/types/ethereum-network.types.d.ts +10 -10
- package/types/transactions.types.cjs +1 -1
- package/types/transactions.types.d.ts +2 -3
- package/types/transactions.types.mjs +6 -7
- package/webworker/utxoWorker/utxoWorkerLauncher.cjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLauncher.mjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLogic.cjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLogic.mjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
- package/functions/web3/events/web3RetrieveEvents.cjs +0 -1
- package/functions/web3/events/web3RetrieveEvents.d.ts +0 -14
- package/functions/web3/events/web3RetrieveEvents.mjs +0 -9
|
@@ -1,64 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
extraRandomization: r,
|
|
5
|
-
stealthAddress: d,
|
|
6
|
-
H0: o,
|
|
7
|
-
H1: u
|
|
8
|
-
} = t.stealthAddressStructure;
|
|
9
|
-
return {
|
|
10
|
-
erc20TokenAddresses: t.erc20TokenAddresses,
|
|
11
|
-
amountChanges: t.amountChanges,
|
|
12
|
-
flatFees: t.flatFees,
|
|
13
|
-
externalActionId: t.externalActionId,
|
|
14
|
-
externalActionMetadata: t.externalActionMetadata,
|
|
15
|
-
encryptedOutputs: t.encryptedOutputs.map((i) => i[0]),
|
|
16
|
-
hookData: t.hookData,
|
|
17
|
-
stealthAddressStructure: {
|
|
18
|
-
extraRandomization: r.toBigInt(),
|
|
19
|
-
stealthAddress: d.toBigInt(),
|
|
20
|
-
H0: o.toBigInt(),
|
|
21
|
-
H1: u.toBigInt()
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
}, p = (e) => ({
|
|
25
|
-
...e,
|
|
26
|
-
utxosArray: e.utxosArray?.map((a) => ({ ...a, amount: BigInt(a.amount) })),
|
|
1
|
+
const a = (t) => ({
|
|
2
|
+
...t,
|
|
3
|
+
utxosArray: t.utxosArray?.map((r) => ({ ...r, amount: BigInt(r.amount) })),
|
|
27
4
|
decodedInput: {
|
|
28
|
-
...
|
|
29
|
-
amountChanges:
|
|
30
|
-
flatFees:
|
|
31
|
-
externalActionId:
|
|
5
|
+
...t.decodedInput,
|
|
6
|
+
amountChanges: t.decodedInput.amountChanges.map(BigInt),
|
|
7
|
+
flatFees: t.decodedInput.flatFees.map(BigInt),
|
|
8
|
+
externalActionId: BigInt(t.decodedInput.externalActionId),
|
|
32
9
|
stealthAddressStructure: {
|
|
33
|
-
...
|
|
34
|
-
extraRandomization: BigInt(
|
|
35
|
-
stealthAddress: BigInt(
|
|
36
|
-
H0: BigInt(
|
|
37
|
-
H1: BigInt(
|
|
10
|
+
...t.decodedInput.stealthAddressStructure,
|
|
11
|
+
extraRandomization: BigInt(t.decodedInput.stealthAddressStructure.extraRandomization),
|
|
12
|
+
stealthAddress: BigInt(t.decodedInput.stealthAddressStructure.stealthAddress),
|
|
13
|
+
H0: BigInt(t.decodedInput.stealthAddressStructure.H0),
|
|
14
|
+
H1: BigInt(t.decodedInput.stealthAddressStructure.H1)
|
|
38
15
|
}
|
|
39
16
|
}
|
|
40
|
-
}),
|
|
41
|
-
const { decodedInput:
|
|
17
|
+
}), d = (t) => t.map((n) => {
|
|
18
|
+
const { decodedInput: e } = n;
|
|
42
19
|
return {
|
|
43
|
-
...
|
|
20
|
+
...n,
|
|
44
21
|
input: "",
|
|
45
22
|
decodedInput: {
|
|
46
|
-
...
|
|
47
|
-
amountChanges:
|
|
48
|
-
flatFees:
|
|
49
|
-
externalActionId:
|
|
23
|
+
...e,
|
|
24
|
+
amountChanges: e.amountChanges.map((s) => s.toString()),
|
|
25
|
+
flatFees: e.flatFees.map((s) => s.toString()),
|
|
26
|
+
externalActionId: e.externalActionId.toString(),
|
|
50
27
|
stealthAddressStructure: {
|
|
51
|
-
...
|
|
52
|
-
extraRandomization: String(
|
|
53
|
-
stealthAddress: String(
|
|
54
|
-
H0: String(
|
|
55
|
-
H1: String(
|
|
28
|
+
...e.stealthAddressStructure,
|
|
29
|
+
extraRandomization: String(e.stealthAddressStructure.extraRandomization),
|
|
30
|
+
stealthAddress: String(e.stealthAddressStructure.stealthAddress),
|
|
31
|
+
H0: String(e.stealthAddressStructure.H0),
|
|
32
|
+
H1: String(e.stealthAddressStructure.H1)
|
|
56
33
|
}
|
|
57
34
|
}
|
|
58
35
|
};
|
|
59
36
|
});
|
|
60
37
|
export {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
h as serializeDecodedTxs
|
|
38
|
+
a as deserializeDecodedTxs,
|
|
39
|
+
d as serializeDecodedTxs
|
|
64
40
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../../constants/protocol.constants.cjs");require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../../constants/protocol.constants.cjs");require("@solana/web3.js");require("ethers");require("circomlibjs-hinkal-fork");require("../../constants/chains.constants.cjs");const y=require("../../data-structures/utxo/Utxo.cjs"),s=require("../../data-structures/crypto-keys/keys.cjs");require("libsodium-wrappers");const a=o=>{const e=o.getShieldedPrivateKey(),n=s.UserKeys.getEncryptionKeyPair(e).publicKey,t=new y.Utxo({amount:0n,erc20TokenAddress:u.zeroAddress,shieldedPrivateKey:e}),{randomization:r}=t,i=t.getStealthAddress(),{h0:c,h1:d}=s.UserKeys.getStealthAddressCompressedPoints(r,e);return`${r},${i},${n},${c},${d}`};exports.getRecipientInfoFromUserKeys=a;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { zeroAddress as p } from "../../constants/protocol.constants.mjs";
|
|
2
|
-
import "ethers";
|
|
3
2
|
import "@solana/web3.js";
|
|
3
|
+
import "ethers";
|
|
4
4
|
import "circomlibjs-hinkal-fork";
|
|
5
5
|
import "../../constants/chains.constants.mjs";
|
|
6
6
|
import { Utxo as c } from "../../data-structures/utxo/Utxo.mjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("ethers"),o=e=>{const{runner:r}=e;if(!(r instanceof t.ethers.AbstractSigner))throw new Error("expected signer");return r},n=e=>{const{runner:r}=e;if(!r)throw new Error("expected provider");return r.provider??r};exports.getProviderFromContract=n;exports.getSignerFromContract=o;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ethers as t } from "ethers";
|
|
2
|
+
const o = (e) => {
|
|
3
|
+
const { runner: r } = e;
|
|
4
|
+
if (!(r instanceof t.AbstractSigner))
|
|
5
|
+
throw new Error("expected signer");
|
|
6
|
+
return r;
|
|
7
|
+
}, c = (e) => {
|
|
8
|
+
const { runner: r } = e;
|
|
9
|
+
if (!r)
|
|
10
|
+
throw new Error("expected provider");
|
|
11
|
+
return r.provider ?? r;
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
c as getProviderFromContract,
|
|
15
|
+
o as getSignerFromContract
|
|
16
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("../../data-structures/crypto-keys/decodeUTXO.cjs"),i=require("./caseInsensitive.utils.cjs");require("../../types/circom-data.types.cjs");const y=require("../../types/ethereum-network.types.cjs");require("../../types/activities.types.cjs");const h=require("./amounts.utils.cjs"),f=async(o,t,c)=>{const r=t.getContractWithFetcher(y.ContractType.HinkalContract),a=r.interface,u=t.userKeys.getShieldedPrivateKey(),d=t.getCurrentChainId(),l=await r.getAddress();return o.logs.filter(e=>i.caseInsensitiveEqual(e.address,l)).map(e=>{try{const n=a.parseLog(e);if(n?.name==="NewCommitment"){const{encryptedOutput:g,index:m}=n.args;if(h.toBigInt(m)<0n){const s=p.decodeUtxo(g,u,d);if(i.caseInsensitiveEqual(s.erc20TokenAddress,c))return s}}}catch{return null}return null}).filter(e=>e!==null)};exports.getUtxosFromReceipt=f;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
2
|
import { Utxo } from '../../data-structures/utxo/Utxo';
|
|
3
3
|
import { IHinkal } from '../../data-structures/Hinkal/IHinkal';
|
|
4
|
-
export declare const getUtxosFromReceipt: (receipt: ethers.
|
|
4
|
+
export declare const getUtxosFromReceipt: (receipt: ethers.TransactionReceipt, hinkal: IHinkal, tokenAddress: string) => Promise<Utxo[]>;
|
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
import { decodeUtxo as
|
|
2
|
-
import { caseInsensitiveEqual as
|
|
1
|
+
import { decodeUtxo as f } from "../../data-structures/crypto-keys/decodeUTXO.mjs";
|
|
2
|
+
import { caseInsensitiveEqual as s } from "./caseInsensitive.utils.mjs";
|
|
3
3
|
import "../../types/circom-data.types.mjs";
|
|
4
|
-
import { ContractType as
|
|
5
|
-
import "../../types/transactions.types.mjs";
|
|
4
|
+
import { ContractType as g } from "../../types/ethereum-network.types.mjs";
|
|
6
5
|
import "../../types/activities.types.mjs";
|
|
7
|
-
import { toBigInt as
|
|
8
|
-
const
|
|
9
|
-
const r = e.getContractWithFetcher(
|
|
10
|
-
return
|
|
6
|
+
import { toBigInt as h } from "./amounts.utils.mjs";
|
|
7
|
+
const A = async (i, e, c) => {
|
|
8
|
+
const r = e.getContractWithFetcher(g.HinkalContract), a = r.interface, d = e.userKeys.getShieldedPrivateKey(), m = e.getCurrentChainId(), l = await r.getAddress();
|
|
9
|
+
return i.logs.filter((t) => s(t.address, l)).map((t) => {
|
|
11
10
|
try {
|
|
12
|
-
const
|
|
13
|
-
if (
|
|
14
|
-
const { encryptedOutput: p, index:
|
|
15
|
-
if (
|
|
16
|
-
const
|
|
17
|
-
if (
|
|
18
|
-
return
|
|
11
|
+
const n = a.parseLog(t);
|
|
12
|
+
if (n?.name === "NewCommitment") {
|
|
13
|
+
const { encryptedOutput: p, index: u } = n.args;
|
|
14
|
+
if (h(u) < 0n) {
|
|
15
|
+
const o = f(p, d, m);
|
|
16
|
+
if (s(o.erc20TokenAddress, c))
|
|
17
|
+
return o;
|
|
19
18
|
}
|
|
20
19
|
}
|
|
21
20
|
} catch {
|
|
@@ -25,5 +24,5 @@ const k = (s, e, c) => {
|
|
|
25
24
|
}).filter((t) => t !== null);
|
|
26
25
|
};
|
|
27
26
|
export {
|
|
28
|
-
|
|
27
|
+
A as getUtxosFromReceipt
|
|
29
28
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("ethers"),s=e=>r.ethers.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("ethers"),s=e=>r.ethers.AbiCoder.defaultAbiCoder().encode(["bytes","uint256","address[]","bytes"],[e.signature,e.deadline,e.erc20TokenAddresses,e.externalCallData]);exports.encodeParsedInLogicMetadata=s;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ethers as r } from "ethers";
|
|
2
|
-
const
|
|
2
|
+
const d = (e) => r.AbiCoder.defaultAbiCoder().encode(
|
|
3
3
|
["bytes", "uint256", "address[]", "bytes"],
|
|
4
4
|
[e.signature, e.deadline, e.erc20TokenAddresses, e.externalCallData]
|
|
5
5
|
);
|
|
6
6
|
export {
|
|
7
|
-
|
|
7
|
+
d as encodeParsedInLogicMetadata
|
|
8
8
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../../constants/protocol.constants.cjs");require("../../error-handling/error-codes.constants.cjs");require("ethers");require("../../types/circom-data.types.cjs");require("../../types/activities.types.cjs");require("../../constants/server.constants.cjs");require("../../API/getServerURL.cjs");require("../../data-structures/http/HttpClient.cjs");require("axios");require("../../constants/chains.constants.cjs");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");require("../../constants/vite.constants.cjs");require("../../constants/save-depths.cjs");require("../../constants/reorg-depths.constants.cjs");require("./mutexes.utils.cjs");require("@coral-xyz/anchor");const s=require("../../error-handling/logger.cjs");require("@solana/web3.js");require("../../data-structures/crypto-keys/keys.cjs");const n=o=>{const e={};return o.forEach(({assetInfo:t,id:i})=>{if(u.NFT_TRANSACTION_TYPES.includes(t.standard)&&i)try{if(t?.contractAddress){const r=t.contractAddress.toLowerCase();e[r]||(e[r]=[]),e[r].push(BigInt(i).toString())}}catch(r){s.Logger.error(`Failed to parse tokenId: ${i}`,r)}}),e};exports.extractTokenIdsFromAssetChanges=n;
|
|
@@ -2,7 +2,6 @@ import { NFT_TRANSACTION_TYPES as p } from "../../constants/protocol.constants.m
|
|
|
2
2
|
import "../../error-handling/error-codes.constants.mjs";
|
|
3
3
|
import "ethers";
|
|
4
4
|
import "../../types/circom-data.types.mjs";
|
|
5
|
-
import "../../types/transactions.types.mjs";
|
|
6
5
|
import "../../types/activities.types.mjs";
|
|
7
6
|
import "../../constants/server.constants.mjs";
|
|
8
7
|
import "../../API/getServerURL.mjs";
|
|
@@ -21,7 +20,7 @@ import "@coral-xyz/anchor";
|
|
|
21
20
|
import { Logger as e } from "../../error-handling/logger.mjs";
|
|
22
21
|
import "@solana/web3.js";
|
|
23
22
|
import "../../data-structures/crypto-keys/keys.mjs";
|
|
24
|
-
const
|
|
23
|
+
const w = (m) => {
|
|
25
24
|
const t = {};
|
|
26
25
|
return m.forEach(({ assetInfo: o, id: i }) => {
|
|
27
26
|
if (p.includes(o.standard) && i)
|
|
@@ -36,5 +35,5 @@ const y = (m) => {
|
|
|
36
35
|
}), t;
|
|
37
36
|
};
|
|
38
37
|
export {
|
|
39
|
-
|
|
38
|
+
w as extractTokenIdsFromAssetChanges
|
|
40
39
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("ethers"),p=require("../../constants/chains.constants.cjs"),g=require("../../constants/protocol.constants.cjs"),d=require("./erc20tokenFunctions.cjs"),P=require("../../externalABIs/swapAbi.cjs"),m=require("../../error-handling/logger.cjs"),w=require("../../externalABIs/index.cjs"),y=require("./ipfs.cjs"),C=require("./create-provider.cjs"),k=require("../../data-structures/http/HttpClient.cjs");require("axios");const f=require("@solana/web3.js"),b=require("@solana/spl-token"),B=n=>{const{fetchRpcUrl:e}=p.networkRegistry[n];if(!e)throw new Error(`No RPC URL configured for chain ${n}`);return C.createCustomRpcProvider(e)},R=async(n,e,t)=>{try{const s=t.erc20TokenAddress;let c;const o=new T.ethers.Contract(t.erc20TokenAddress,P.ERC20ABI,n);s!==g.zeroAddress?c=await o?.balanceOf(e):c=await n.getBalance(e);const r=c;return r<=0n?null:{token:t,balance:r}}catch{return null}},q=async(n,e)=>{const t=e.nftTokenType===g.TokenType.ERC721,s=new T.ethers.Contract(e.erc20TokenAddress,t?w.ERC721ABI:w.ERC1155ABI,n),{tokenIds:c}=e;if(!c?.length)return null;const o=await Promise.all(c.map(async r=>{try{const a=await s[t?"tokenURI":"uri"](r),l=a.startsWith("ipfs://")?y.getFormattedIpfsUrl(a,!1):a,u=t?l:l.replace("{id}",r);if(u){const i=await k.httpClient.get(u);return i?.image?.startsWith("ipfs://")&&(i.image=y.getFormattedIpfsUrl(i.image,!1)),{image:i.image,tokenId:Number(r),name:i.name}}return{tokenId:Number(r)}}catch{return{tokenId:Number(r)}}}));return{token:e,balance:c?.length?BigInt(c.length):0n,nfts:o}},E=async(n,e,t)=>{const s=t??d.getErc20TokensForChain(n),c=B(n);return(await Promise.all(s.map(async r=>d.isNFTToken(r)?q(c,r):R(c,e,r)))).filter(r=>r!==null)},N=async(n,e,t)=>{try{const s=B(n),c=new T.ethers.Contract(t,P.ERC20ABI,s);let o;return t!==g.zeroAddress?o=await c?.balanceOf(e):o=await s.getBalance(e),o}catch{return m.Logger.error(`Failed to fetch public balance for address ${e}`),null}},U=async(n,e)=>{try{return await B(n).getTransactionCount(e)}catch(t){return m.Logger.error(`Failed to fetch transaction count for address ${e} on chain ${n}`,t),null}},v=async(n,e,t)=>{const c=p.networkRegistry[n].fetchRpcUrl??"",o=C.createCustomSolanaConnection(c);return(await Promise.all(t.map(async a=>{if(d.isNFTToken(a))return{token:a,balance:1n,nfts:[{image:a.logoURI,tokenId:0,name:a.symbol}]};if(a.erc20TokenAddress===g.solanaNativeAddress){const I=BigInt(await o.getBalance(new f.PublicKey(e)));return{token:a,balance:I}}const l=new f.PublicKey(a.erc20TokenAddress),u=new f.PublicKey(e),i=await b.getAssociatedTokenAddress(l,u,!0,a.is2022Program?b.TOKEN_2022_PROGRAM_ID:b.TOKEN_PROGRAM_ID);if(!await o.getAccountInfo(i))return{token:a,balance:0n};const h=await o.getTokenAccountBalance(i),A=BigInt(h.value.amount);return{token:a,balance:A}}))).filter(a=>a.balance>0n)};exports.getPublicBalance=R;exports.getPublicBalanceByTokenAddress=N;exports.getPublicBalancesOfTokens=E;exports.getPublicTransactionCount=U;exports.getSolanaPublicBalances=v;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
2
|
import { ERC20Token, TokenBalance } from '../../types/token.types';
|
|
3
|
-
export declare const getPublicBalance: (provider: ethers.
|
|
3
|
+
export declare const getPublicBalance: (provider: ethers.JsonRpcProvider, ethereumAddress: string, token: ERC20Token) => Promise<TokenBalance | null>;
|
|
4
4
|
export declare const getPublicBalancesOfTokens: (chainId: number, ethereumAddress: string, tokens?: ERC20Token[]) => Promise<TokenBalance[]>;
|
|
5
5
|
export declare const getPublicBalanceByTokenAddress: (chainId: number, ethereumAddress: string, tokenAddress: string) => Promise<bigint | null>;
|
|
6
6
|
export declare const getPublicTransactionCount: (chainId: number, ethereumAddress: string) => Promise<number | null>;
|
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
import { ethers as m } from "ethers";
|
|
2
2
|
import { networkRegistry as d } from "../../constants/chains.constants.mjs";
|
|
3
|
-
import { zeroAddress as b, solanaNativeAddress as P, TokenType as
|
|
4
|
-
import { getErc20TokensForChain as
|
|
3
|
+
import { zeroAddress as b, solanaNativeAddress as P, TokenType as h } from "../../constants/protocol.constants.mjs";
|
|
4
|
+
import { getErc20TokensForChain as A, isNFTToken as w } from "./erc20tokenFunctions.mjs";
|
|
5
5
|
import { ERC20ABI as B } from "../../externalABIs/swapAbi.mjs";
|
|
6
6
|
import { Logger as T } from "../../error-handling/logger.mjs";
|
|
7
|
-
import { ERC721ABI as
|
|
7
|
+
import { ERC721ABI as I, ERC1155ABI as E } from "../../externalABIs/index.mjs";
|
|
8
8
|
import { getFormattedIpfsUrl as p } from "./ipfs.mjs";
|
|
9
|
-
import { createCustomSolanaConnection as
|
|
10
|
-
import { httpClient as
|
|
9
|
+
import { createCustomSolanaConnection as N, createCustomRpcProvider as U } from "./create-provider.mjs";
|
|
10
|
+
import { httpClient as k } from "../../data-structures/http/HttpClient.mjs";
|
|
11
11
|
import "axios";
|
|
12
12
|
import { PublicKey as u } from "@solana/web3.js";
|
|
13
|
-
import { getAssociatedTokenAddress as
|
|
14
|
-
const g = (
|
|
15
|
-
const { fetchRpcUrl: t } = d[
|
|
13
|
+
import { getAssociatedTokenAddress as v, TOKEN_2022_PROGRAM_ID as O, TOKEN_PROGRAM_ID as F } from "@solana/spl-token";
|
|
14
|
+
const g = (n) => {
|
|
15
|
+
const { fetchRpcUrl: t } = d[n];
|
|
16
16
|
if (!t)
|
|
17
|
-
throw new Error(`No RPC URL configured for chain ${
|
|
18
|
-
return
|
|
19
|
-
}, _ = async (
|
|
17
|
+
throw new Error(`No RPC URL configured for chain ${n}`);
|
|
18
|
+
return U(t);
|
|
19
|
+
}, _ = async (n, t, a) => {
|
|
20
20
|
try {
|
|
21
|
-
const s =
|
|
21
|
+
const s = a.erc20TokenAddress;
|
|
22
22
|
let r;
|
|
23
|
-
const o = new m.Contract(
|
|
24
|
-
s !== b ? r = await o?.balanceOf(t) : r = await
|
|
25
|
-
const c = r
|
|
26
|
-
return c <= 0n ? null : { token:
|
|
23
|
+
const o = new m.Contract(a.erc20TokenAddress, B, n);
|
|
24
|
+
s !== b ? r = await o?.balanceOf(t) : r = await n.getBalance(t);
|
|
25
|
+
const c = r;
|
|
26
|
+
return c <= 0n ? null : { token: a, balance: c };
|
|
27
27
|
} catch {
|
|
28
28
|
return null;
|
|
29
29
|
}
|
|
30
|
-
}, $ = async (
|
|
31
|
-
const
|
|
30
|
+
}, $ = async (n, t) => {
|
|
31
|
+
const a = t.nftTokenType === h.ERC721, s = new m.Contract(t.erc20TokenAddress, a ? I : E, n), { tokenIds: r } = t;
|
|
32
32
|
if (!r?.length)
|
|
33
33
|
return null;
|
|
34
34
|
const o = await Promise.all(
|
|
35
35
|
r.map(async (c) => {
|
|
36
36
|
try {
|
|
37
|
-
const
|
|
37
|
+
const e = await s[a ? "tokenURI" : "uri"](c), l = e.startsWith("ipfs://") ? p(e, !1) : e, f = a ? l : l.replace("{id}", c);
|
|
38
38
|
if (f) {
|
|
39
|
-
const i = await
|
|
39
|
+
const i = await k.get(f);
|
|
40
40
|
return i?.image?.startsWith("ipfs://") && (i.image = p(i.image, !1)), { image: i.image, tokenId: Number(c), name: i.name };
|
|
41
41
|
}
|
|
42
42
|
return { tokenId: Number(c) };
|
|
@@ -50,51 +50,51 @@ const g = (e) => {
|
|
|
50
50
|
balance: r?.length ? BigInt(r.length) : 0n,
|
|
51
51
|
nfts: o
|
|
52
52
|
};
|
|
53
|
-
}, V = async (
|
|
54
|
-
const s =
|
|
53
|
+
}, V = async (n, t, a) => {
|
|
54
|
+
const s = a ?? A(n), r = g(n);
|
|
55
55
|
return (await Promise.all(
|
|
56
56
|
s.map(async (c) => w(c) ? $(r, c) : _(r, t, c))
|
|
57
57
|
)).filter((c) => c !== null);
|
|
58
|
-
}, X = async (
|
|
58
|
+
}, X = async (n, t, a) => {
|
|
59
59
|
try {
|
|
60
|
-
const s = g(
|
|
60
|
+
const s = g(n), r = new m.Contract(a, B, s);
|
|
61
61
|
let o;
|
|
62
|
-
return
|
|
62
|
+
return a !== b ? o = await r?.balanceOf(t) : o = await s.getBalance(t), o;
|
|
63
63
|
} catch {
|
|
64
64
|
return T.error(`Failed to fetch public balance for address ${t}`), null;
|
|
65
65
|
}
|
|
66
|
-
}, Y = async (
|
|
66
|
+
}, Y = async (n, t) => {
|
|
67
67
|
try {
|
|
68
|
-
return await g(
|
|
69
|
-
} catch (
|
|
70
|
-
return T.error(`Failed to fetch transaction count for address ${t} on chain ${
|
|
68
|
+
return await g(n).getTransactionCount(t);
|
|
69
|
+
} catch (a) {
|
|
70
|
+
return T.error(`Failed to fetch transaction count for address ${t} on chain ${n}`, a), null;
|
|
71
71
|
}
|
|
72
|
-
}, Z = async (
|
|
73
|
-
const r = d[
|
|
72
|
+
}, Z = async (n, t, a) => {
|
|
73
|
+
const r = d[n].fetchRpcUrl ?? "", o = N(r);
|
|
74
74
|
return (await Promise.all(
|
|
75
|
-
|
|
76
|
-
if (w(
|
|
75
|
+
a.map(async (e) => {
|
|
76
|
+
if (w(e))
|
|
77
77
|
return {
|
|
78
|
-
token:
|
|
78
|
+
token: e,
|
|
79
79
|
balance: 1n,
|
|
80
|
-
nfts: [{ image:
|
|
80
|
+
nfts: [{ image: e.logoURI, tokenId: 0, name: e.symbol }]
|
|
81
81
|
};
|
|
82
|
-
if (
|
|
82
|
+
if (e.erc20TokenAddress === P) {
|
|
83
83
|
const R = BigInt(await o.getBalance(new u(t)));
|
|
84
|
-
return { token:
|
|
84
|
+
return { token: e, balance: R };
|
|
85
85
|
}
|
|
86
|
-
const l = new u(
|
|
86
|
+
const l = new u(e.erc20TokenAddress), f = new u(t), i = await v(
|
|
87
87
|
l,
|
|
88
88
|
f,
|
|
89
89
|
!0,
|
|
90
|
-
|
|
90
|
+
e.is2022Program ? O : F
|
|
91
91
|
);
|
|
92
92
|
if (!await o.getAccountInfo(i))
|
|
93
|
-
return { token:
|
|
93
|
+
return { token: e, balance: 0n };
|
|
94
94
|
const y = await o.getTokenAccountBalance(i), C = BigInt(y.value.amount);
|
|
95
|
-
return { token:
|
|
95
|
+
return { token: e, balance: C };
|
|
96
96
|
})
|
|
97
|
-
)).filter((
|
|
97
|
+
)).filter((e) => e.balance > 0n);
|
|
98
98
|
};
|
|
99
99
|
export {
|
|
100
100
|
_ as getPublicBalance,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("ethers"),r=e=>t.ethers.toBeHex(e);exports.rpcIntEncode=r;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const rpcIntEncode: (value: ethers.BigNumberish) => string;
|
|
1
|
+
export declare const rpcIntEncode: (value: string | number | bigint) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@solana/web3.js"),u=require("../../crypto/poseidon.cjs"),d=require("ethers"),r=t=>{const e=t.toBytes();return d.ethers.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@solana/web3.js"),u=require("../../crypto/poseidon.cjs"),d=require("ethers"),r=t=>{const e=t.toBytes();return BigInt(d.ethers.hexlify(e))},y=t=>{const e=typeof t=="string"?new i.PublicKey(t):t,n=r(e),o=n/2n**128n,s=n%2n**128n,c=u.poseidonHash(o,s);return{mintAccountPart1:o,mintAccountPart2:s,compressedAddress:c,mintPublicKey:e}};exports.convertPublicKeyToBigint=r;exports.formatMintAddress=y;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { PublicKey as c } from "@solana/web3.js";
|
|
2
2
|
import { poseidonHash as i } from "../../crypto/poseidon.mjs";
|
|
3
3
|
import { ethers as m } from "ethers";
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
return m.
|
|
4
|
+
const y = (t) => {
|
|
5
|
+
const n = t.toBytes();
|
|
6
|
+
return BigInt(m.hexlify(n));
|
|
7
7
|
}, f = (t) => {
|
|
8
|
-
const
|
|
9
|
-
return { mintAccountPart1:
|
|
8
|
+
const n = typeof t == "string" ? new c(t) : t, o = y(n), e = o / 2n ** 128n, r = o % 2n ** 128n, s = i(e, r);
|
|
9
|
+
return { mintAccountPart1: e, mintAccountPart2: r, compressedAddress: s, mintPublicKey: n };
|
|
10
10
|
};
|
|
11
11
|
export {
|
|
12
|
-
|
|
12
|
+
y as convertPublicKeyToBigint,
|
|
13
13
|
f as formatMintAddress
|
|
14
14
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("ethers"),c=(i,s,e)=>s.reduce((n,{name:t,type:r})=>{const a=i[t];if(r.endsWith("[]")){const o=r.slice(0,-2);if(e[o]&&Array.isArray(a)){const m=a.reduce((u,f,d)=>({...u,[d]:{value:c(f,e[o],e),type:o}}),{});return{...n,[t]:{value:m,type:r}}}return{...n,[t]:{value:a,type:r}}}return e[r]?{...n,[t]:{value:c(a,e[r],e),type:r}}:{...n,[t]:{value:a,type:r}}},{}),l=(i,s,e)=>{const n=c(i,s[e],s);return{primaryType:{value:e,type:"string"},...n}},g=["Permit","PermitWithExpiry","PermitBatch","PermitBatchTransferFrom","PermitSingle","PermitTransferFrom","PermitWitnessTransferFrom"],T=(i,s)=>{let e;switch(s){case"PermitSingle":case"PermitBatch":e=i.details;break;case"PermitBatchTransferFrom":case"PermitTransferFrom":case"PermitWitnessTransferFrom":e=i.permitted;break}if(e)return Array.isArray(e)?e:[e]},h=(i,s,e)=>{if(!Object.keys(s).some(r=>g.includes(r)))return{isPermit:!1,tokenDetails:[]};const t=T(i,e);return t?{isPermit:!0,tokenDetails:t}:{isPermit:!0,tokenDetails:[]}},k=(i,s,e,n)=>{const{isPermit:t,tokenDetails:r}=h(i,s,n);if(!t)return{isPermit:!1};let a;if(r.length)a=e.verifyingContract;else{const o=e.verifyingContract;o&&r.push({token:o,amount:P.ethers.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("ethers"),c=(i,s,e)=>s.reduce((n,{name:t,type:r})=>{const a=i[t];if(r.endsWith("[]")){const o=r.slice(0,-2);if(e[o]&&Array.isArray(a)){const m=a.reduce((u,f,d)=>({...u,[d]:{value:c(f,e[o],e),type:o}}),{});return{...n,[t]:{value:m,type:r}}}return{...n,[t]:{value:a,type:r}}}return e[r]?{...n,[t]:{value:c(a,e[r],e),type:r}}:{...n,[t]:{value:a,type:r}}},{}),l=(i,s,e)=>{const n=c(i,s[e],s);return{primaryType:{value:e,type:"string"},...n}},g=["Permit","PermitWithExpiry","PermitBatch","PermitBatchTransferFrom","PermitSingle","PermitTransferFrom","PermitWitnessTransferFrom"],T=(i,s)=>{let e;switch(s){case"PermitSingle":case"PermitBatch":e=i.details;break;case"PermitBatchTransferFrom":case"PermitTransferFrom":case"PermitWitnessTransferFrom":e=i.permitted;break}if(e)return Array.isArray(e)?e:[e]},h=(i,s,e)=>{if(!Object.keys(s).some(r=>g.includes(r)))return{isPermit:!1,tokenDetails:[]};const t=T(i,e);return t?{isPermit:!0,tokenDetails:t}:{isPermit:!0,tokenDetails:[]}},k=(i,s,e,n)=>{const{isPermit:t,tokenDetails:r}=h(i,s,n);if(!t)return{isPermit:!1};let a;if(r.length)a=e.verifyingContract;else{const o=e.verifyingContract;o&&r.push({token:o,amount:P.ethers.MaxUint256.toString()})}return{isPermit:t,tokenDetails:r,spender:a}};exports.decodeMessage=c;exports.getDecodedMessage=l;exports.getPermitInfo=k;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
2
|
import { DecodedTypedMessageValue } from '../../types/message.types';
|
|
3
|
-
export declare const decodeMessage: (message: Record<string, any>, typeDefinition: TypedDataField[], types: Record<string, TypedDataField[]>) => Record<string, DecodedTypedMessageValue>;
|
|
4
|
-
export declare const getDecodedMessage: (message: Record<string, any>, types: Record<string, TypedDataField[]>, primaryType: string) => {
|
|
3
|
+
export declare const decodeMessage: (message: Record<string, any>, typeDefinition: ethers.TypedDataField[], types: Record<string, ethers.TypedDataField[]>) => Record<string, DecodedTypedMessageValue>;
|
|
4
|
+
export declare const getDecodedMessage: (message: Record<string, any>, types: Record<string, ethers.TypedDataField[]>, primaryType: string) => {
|
|
5
5
|
primaryType: {
|
|
6
6
|
value: string;
|
|
7
7
|
type: string;
|
|
@@ -11,7 +11,7 @@ type TokenDetail = {
|
|
|
11
11
|
token: string;
|
|
12
12
|
amount: string;
|
|
13
13
|
};
|
|
14
|
-
export declare const getPermitInfo: (message: Record<string, any>, types: Record<string, TypedDataField[]>, domain: Record<string, unknown>, primaryType: string) => {
|
|
14
|
+
export declare const getPermitInfo: (message: Record<string, any>, types: Record<string, ethers.TypedDataField[]>, domain: Record<string, unknown>, primaryType: string) => {
|
|
15
15
|
isPermit: boolean;
|
|
16
16
|
tokenDetails?: undefined;
|
|
17
17
|
spender?: undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("ethers"),c=require("../../error-handling/error-codes.constants.cjs"),m=t=>o.ethers.parseEther(t),I=t=>[...o.ethers.randomBytes(t)].reduce((e,n)=>e<<8n|BigInt(n),0n),h=(t,e)=>o.ethers.formatUnits(e,t.decimals),a=(t,e)=>{const n=10**(18-t.decimals);try{return o.ethers.parseUnits(e)/BigInt(n)}catch{throw new Error(c.transactionErrorCodes.DECIMALS_LIMIT)}},l=t=>{const e=t.toFixed(30),[n,r]=e.split("."),s=r?r.length:0,i=`${n}${r||""}`;return[BigInt(i),s]},d=(t,e)=>{try{return a(t,e)}catch{return BigInt(0)}},u=(t,e,n)=>{const r=o.ethers.formatUnits(t,e.decimals),s=BigInt(10**(18-n));try{const i=o.ethers.parseUnits(r)/s;return o.ethers.formatUnits(i,n)}catch{throw new Error(c.transactionErrorCodes.DECIMALS_LIMIT)}},B=(t,e,n,r)=>{const[s,i]=l(n);return{totalValueDollarsBigInt:e*s/BigInt(10**(t.decimals-r))/BigInt(10**i),precision:r}},P=(t,e)=>!t||!e?"0":u(e??0n,t,t.decimals).toString()??"0";exports.calculateDollarValue=B;exports.ethToWei=m;exports.getAmountInToken=h;exports.getAmountInWei=a;exports.getAmountInWeiOrZero=d;exports.getAmountWithPrecision=u;exports.getAmountWithPrecisionOrZero=P;exports.randomBigInt=I;exports.toBigIntWithDecimals=l;
|
|
@@ -1,41 +1,44 @@
|
|
|
1
|
-
import { ethers as
|
|
2
|
-
import { transactionErrorCodes as
|
|
3
|
-
const
|
|
4
|
-
|
|
1
|
+
import { ethers as o } from "ethers";
|
|
2
|
+
import { transactionErrorCodes as a } from "../../error-handling/error-codes.constants.mjs";
|
|
3
|
+
const B = (t) => o.parseEther(t), h = (t) => (
|
|
4
|
+
// eslint-disable-next-line no-bitwise
|
|
5
|
+
[...o.randomBytes(t)].reduce((n, e) => n << 8n | BigInt(e), 0n)
|
|
6
|
+
), P = (t, n) => o.formatUnits(n, t.decimals), l = (t, n) => {
|
|
7
|
+
const e = 10 ** (18 - t.decimals);
|
|
5
8
|
try {
|
|
6
|
-
return
|
|
9
|
+
return o.parseUnits(n) / BigInt(e);
|
|
7
10
|
} catch {
|
|
8
|
-
throw new Error(
|
|
11
|
+
throw new Error(a.DECIMALS_LIMIT);
|
|
9
12
|
}
|
|
10
|
-
},
|
|
11
|
-
const n = t.toFixed(30), [
|
|
12
|
-
return [BigInt(
|
|
13
|
-
},
|
|
13
|
+
}, m = (t) => {
|
|
14
|
+
const n = t.toFixed(30), [e, r] = n.split("."), c = r ? r.length : 0, i = `${e}${r || ""}`;
|
|
15
|
+
return [BigInt(i), c];
|
|
16
|
+
}, D = (t, n) => {
|
|
14
17
|
try {
|
|
15
|
-
return
|
|
18
|
+
return l(t, n);
|
|
16
19
|
} catch {
|
|
17
20
|
return BigInt(0);
|
|
18
21
|
}
|
|
19
|
-
},
|
|
20
|
-
const
|
|
22
|
+
}, g = (t, n, e) => {
|
|
23
|
+
const r = o.formatUnits(t, n.decimals), c = BigInt(10 ** (18 - e));
|
|
21
24
|
try {
|
|
22
|
-
const
|
|
23
|
-
return
|
|
25
|
+
const i = o.parseUnits(r) / c;
|
|
26
|
+
return o.formatUnits(i, e);
|
|
24
27
|
} catch {
|
|
25
|
-
throw new Error(
|
|
28
|
+
throw new Error(a.DECIMALS_LIMIT);
|
|
26
29
|
}
|
|
27
|
-
},
|
|
28
|
-
const [
|
|
29
|
-
return { totalValueDollarsBigInt: n *
|
|
30
|
-
},
|
|
30
|
+
}, E = (t, n, e, r) => {
|
|
31
|
+
const [c, i] = m(e);
|
|
32
|
+
return { totalValueDollarsBigInt: n * c / BigInt(10 ** (t.decimals - r)) / BigInt(10 ** i), precision: r };
|
|
33
|
+
}, v = (t, n) => !t || !n ? "0" : g(n ?? 0n, t, t.decimals).toString() ?? "0";
|
|
31
34
|
export {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
E as calculateDollarValue,
|
|
36
|
+
B as ethToWei,
|
|
37
|
+
P as getAmountInToken,
|
|
38
|
+
l as getAmountInWei,
|
|
39
|
+
D as getAmountInWeiOrZero,
|
|
40
|
+
g as getAmountWithPrecision,
|
|
41
|
+
v as getAmountWithPrecisionOrZero,
|
|
42
|
+
h as randomBigInt,
|
|
43
|
+
m as toBigIntWithDecimals
|
|
41
44
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../../types/circom-data.types.cjs");const a=require("../../../types/hinkal.types.cjs");require("../../../types/
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../../types/circom-data.types.cjs");const a=require("../../../types/hinkal.types.cjs");require("../../../types/activities.types.cjs");const o=n=>{const t=a.EventType.BalanceChange,e=new CustomEvent(t,{detail:n});typeof document<"u"?document.dispatchEvent(e):process?.emit("message",e,void 0)};exports.balanceChangedCustomHandler=o;
|