@gurge/sdk-react-native 0.3.69 → 0.3.74
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/_virtual/_rolldown/runtime.mjs +11 -2
- package/common/src/constants/vite.constants.cjs +1 -1
- package/common/src/constants/vite.constants.mjs +1 -1
- package/common/src/crypto/babyJub.cjs +1 -1
- package/common/src/crypto/babyJub.mjs +7 -6
- package/common/src/crypto/eddsa.cjs +1 -1
- package/common/src/crypto/eddsa.mjs +7 -6
- package/common/src/crypto/poseidon.cjs +1 -1
- package/common/src/crypto/poseidon.mjs +13 -13
- package/common/src/data-structures/IndexedDB/activity-db.cjs +1 -1
- package/common/src/data-structures/IndexedDB/activity-db.mjs +38 -38
- package/common/src/data-structures/IndexedDB/balances-db.cjs +1 -1
- package/common/src/data-structures/IndexedDB/balances-db.mjs +18 -16
- package/common/src/data-structures/IndexedDB/contact-db.cjs +1 -1
- package/common/src/data-structures/IndexedDB/contact-db.mjs +16 -14
- package/common/src/data-structures/IndexedDB/key-val-store.cjs +1 -1
- package/common/src/data-structures/IndexedDB/key-val-store.mjs +12 -12
- package/common/src/data-structures/IndexedDB/pay-activity-db.cjs +1 -1
- package/common/src/data-structures/IndexedDB/pay-activity-db.mjs +10 -8
- package/common/src/data-structures/IndexedDB/signatures-db.cjs +1 -1
- package/common/src/data-structures/IndexedDB/signatures-db.mjs +23 -21
- package/common/src/data-structures/TokenDBs/AlchemyPublicTokensDB.cjs +1 -1
- package/common/src/data-structures/TokenDBs/AlchemyPublicTokensDB.mjs +32 -31
- package/common/src/data-structures/TokenDBs/ArcPublicTokensDB.cjs +1 -1
- package/common/src/data-structures/TokenDBs/ArcPublicTokensDB.mjs +25 -25
- package/common/src/data-structures/TokenDBs/EventsPublicTokensDB.cjs +1 -1
- package/common/src/data-structures/TokenDBs/EventsPublicTokensDB.mjs +47 -46
- package/common/src/data-structures/TokenDBs/PrivateTokensDB.cjs +1 -1
- package/common/src/data-structures/TokenDBs/PrivateTokensDB.mjs +20 -20
- package/common/src/data-structures/TokenDBs/TempoPublicTokensDB.cjs +1 -1
- package/common/src/data-structures/TokenDBs/TempoPublicTokensDB.mjs +19 -19
- package/common/src/data-structures/TokenDBs/TronPublicTokensDB.cjs +1 -1
- package/common/src/data-structures/TokenDBs/TronPublicTokensDB.mjs +19 -19
- package/common/src/data-structures/TokenDBs/token-visibility-db.cjs +1 -1
- package/common/src/data-structures/TokenDBs/token-visibility-db.mjs +45 -44
- package/common/src/data-structures/cacheDevices/FileCacheDevice.cjs +1 -1
- package/common/src/data-structures/cacheDevices/FileCacheDevice.mjs +1 -1
- package/common/src/functions/snarkjs/verifyCommitmentValidationData.cjs +1 -1
- package/common/src/functions/snarkjs/verifyCommitmentValidationData.mjs +4 -1
- package/common/src/functions/utils/cacheDevice.utils.cjs +1 -1
- package/common/src/functions/utils/cacheDevice.utils.mjs +1 -1
- package/common/src/functions/utils/cacheFunctions.cjs +1 -1
- package/common/src/functions/utils/cacheFunctions.mjs +13 -13
- package/common/src/functions/utils/ipfs.cjs +1 -1
- package/common/src/functions/utils/ipfs.mjs +3 -1
- package/common/src/webworker/viteWorkerURL.constant.mjs +3 -3
- package/common/src/webworker/workerFactory.cjs +1 -1
- package/common/src/webworker/workerFactory.mjs +3 -3
- package/package.json +1 -1
- package/shims/circomlibjs-hinkal-fork.cjs +14 -0
- package/shims/circomlibjs-hinkal-fork.mjs +3 -0
- package/shims/circomlibjs.cjs +15 -0
- package/shims/circomlibjs.mjs +3 -0
- package/shims/constants.cjs +7 -0
- package/shims/constants.mjs +3 -0
- package/shims/crypto.cjs +102 -0
- package/shims/crypto.mjs +3 -0
- package/shims/dotenv.cjs +3 -0
- package/shims/dotenv.mjs +3 -0
- package/shims/ffjavascript.cjs +5 -0
- package/shims/ffjavascript.mjs +3 -0
- package/shims/fs.cjs +5 -0
- package/shims/fs.mjs +3 -0
- package/shims/globals.cjs +15 -0
- package/shims/globals.mjs +3 -0
- package/shims/idb-keyval.cjs +75 -0
- package/shims/idb-keyval.mjs +3 -0
- package/shims/multiformats.cjs +1 -0
- package/shims/multiformats.mjs +3 -0
- package/shims/os.cjs +7 -0
- package/shims/os.mjs +3 -0
- package/shims/path.cjs +11 -0
- package/shims/path.mjs +3 -0
- package/shims/readline.cjs +6 -0
- package/shims/readline.mjs +3 -0
- package/shims/snarkjs.cjs +21 -0
- package/shims/snarkjs.mjs +3 -0
- package/shims/url.cjs +5 -0
- package/shims/url.mjs +3 -0
- package/shims/web-worker.cjs +7 -0
- package/shims/web-worker.mjs +3 -0
- package/shims/worker_threads.cjs +6 -0
- package/shims/worker_threads.mjs +3 -0
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
//#region \0rolldown/runtime.js
|
|
2
|
-
var e = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports),
|
|
2
|
+
var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), s = (e, i, o, s) => {
|
|
3
|
+
if (i && typeof i == "object" || typeof i == "function") for (var c = r(i), l = 0, u = c.length, d; l < u; l++) d = c[l], !a.call(e, d) && d !== o && t(e, d, {
|
|
4
|
+
get: ((e) => i[e]).bind(null, d),
|
|
5
|
+
enumerable: !(s = n(i, d)) || s.enumerable
|
|
6
|
+
});
|
|
7
|
+
return e;
|
|
8
|
+
}, c = (n, r, a) => (a = n == null ? {} : e(i(n)), s(r || !n || !n.__esModule ? t(a, "default", {
|
|
9
|
+
value: n,
|
|
10
|
+
enumerable: !0
|
|
11
|
+
}) : a, n)), l = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) {
|
|
3
12
|
if (typeof require < "u") return require.apply(this, arguments);
|
|
4
13
|
throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
|
|
5
14
|
});
|
|
6
15
|
//#endregion
|
|
7
|
-
export {
|
|
16
|
+
export { o as __commonJSMin, l as __require, c as __toESM };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../functions/utils/enum.utils.cjs`),t=require(`../../../
|
|
1
|
+
const e=require(`../functions/utils/enum.utils.cjs`),t=require(`../../../shims/dotenv.cjs`);var n=function(e){return e.DEVELOPMENT=`development`,e.PLAYGROUND=`playground`,e.PRODUCTION=`production`,e.STAGING=`staging`,e}({}),r={[n.DEVELOPMENT]:[`localhost`,`192.`,`127.`],[n.PLAYGROUND]:[`playground`],[n.STAGING]:[`working`,`staging`]},i=typeof process<`u`&&process?.release?.name===`node`,a=typeof process<`u`&&process.versions!=null&&process.versions.node!=null,o=typeof window<`u`&&window?.location?.protocol===`chrome-extension:`;function s(e,t){return t.some(t=>e.includes(t))}var c=()=>(t.default.config({path:`DOTENV_OVERRIDE`in process.env?process.env.DOTENV_OVERRIDE:void 0}),process.env.DEPLOYMENT_MODE?.startsWith(`production`)?n.PRODUCTION:e.toEnumValue(n,process.env.DEPLOYMENT_MODE)||n.DEVELOPMENT),l=(()=>{if(!i&&typeof window>`u`)return;if(i)return c();if(window?.location?.protocol===`chrome-extension:`)return e.toEnumValue(n,WALLET_DEPLOYMENT_MODE)||n.STAGING;let t=window?.location?.host;return t?s(t,r[n.DEVELOPMENT])?n.DEVELOPMENT:s(t,r[n.PLAYGROUND])?n.PLAYGROUND:s(t,r[n.STAGING])?n.STAGING:n.PRODUCTION:n.PRODUCTION})(),u=l===n.DEVELOPMENT,d=l===n.PLAYGROUND,f=l===n.STAGING,p=f||u||d,m=typeof navigator<`u`&&navigator.product===`ReactNative`,h=p||i&&l===n.PRODUCTION;exports.DEPLOYMENT_MODE=n,exports.deploymentMode=l,exports.isDevelopment=u,exports.isExtension=o,exports.isNode=a,exports.isNotClientProduction=h,exports.isNotProduction=p,exports.isPlayground=d,exports.isReactNative=m,exports.isStaging=f;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { toEnumValue as e } from "../functions/utils/enum.utils.mjs";
|
|
2
|
-
import { require_dotenv as t } from "../../../
|
|
2
|
+
import { require_dotenv as t } from "../../../shims/dotenv.mjs";
|
|
3
3
|
//#region common/src/constants/vite.constants.ts
|
|
4
4
|
var n = /* @__PURE__ */ function(e) {
|
|
5
5
|
return e.DEVELOPMENT = "development", e.PLAYGROUND = "playground", e.PRODUCTION = "production", e.STAGING = "staging", e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require(`../constants/vite.constants.cjs`),t=require(`../../../shims/circomlibjs-hinkal-fork.cjs`),n=require(`./BabyJubRN.cjs`);var r=t.default,i=new class{babyjub=void 0;async init(){this.babyjub||=e.isReactNative?new n.BabyJubRN:await(0,r.buildBabyjub)()}getJub(){return this.babyjub}},a=()=>i.getJub();exports.babyJubInstance=a,exports.jubHolder=i;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { isReactNative as e } from "../constants/vite.constants.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
2
|
+
import { require_circomlibjs_hinkal_fork as t } from "../../../shims/circomlibjs-hinkal-fork.mjs";
|
|
3
|
+
import { BabyJubRN as n } from "./BabyJubRN.mjs";
|
|
4
|
+
//#region common/src/crypto/babyJub.ts
|
|
5
|
+
var r = t(), i = new class {
|
|
5
6
|
babyjub = void 0;
|
|
6
7
|
async init() {
|
|
7
|
-
this.babyjub ||= e ? new
|
|
8
|
+
this.babyjub ||= e ? new n() : await (0, r.buildBabyjub)();
|
|
8
9
|
}
|
|
9
10
|
getJub() {
|
|
10
11
|
return this.babyjub;
|
|
11
12
|
}
|
|
12
|
-
}(),
|
|
13
|
+
}(), a = () => i.getJub();
|
|
13
14
|
//#endregion
|
|
14
|
-
export {
|
|
15
|
+
export { a as babyJubInstance, i as jubHolder };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require(`../constants/vite.constants.cjs`),t=require(`../../../shims/circomlibjs-hinkal-fork.cjs`),n=require(`./EddsaRN.cjs`);var r=t.default,i=new class{eddsa=void 0;async init(){this.eddsa||=e.isReactNative?await n.buildEddsaRN():await(0,r.buildEddsa)()}getEddsa(){return this.eddsa}},a=()=>i.getEddsa();exports.eddsaHolder=i,exports.eddsaInstance=a;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { isReactNative as e } from "../constants/vite.constants.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
2
|
+
import { require_circomlibjs_hinkal_fork as t } from "../../../shims/circomlibjs-hinkal-fork.mjs";
|
|
3
|
+
import { buildEddsaRN as n } from "./EddsaRN.mjs";
|
|
4
|
+
//#region common/src/crypto/eddsa.ts
|
|
5
|
+
var r = t(), i = new class {
|
|
5
6
|
eddsa = void 0;
|
|
6
7
|
async init() {
|
|
7
|
-
this.eddsa ||= e ? await
|
|
8
|
+
this.eddsa ||= e ? await n() : await (0, r.buildEddsa)();
|
|
8
9
|
}
|
|
9
10
|
getEddsa() {
|
|
10
11
|
return this.eddsa;
|
|
11
12
|
}
|
|
12
|
-
}(),
|
|
13
|
+
}(), a = () => i.getEddsa();
|
|
13
14
|
//#endregion
|
|
14
|
-
export {
|
|
15
|
+
export { i as eddsaHolder, a as eddsaInstance };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../../../../_virtual/_rolldown/runtime.cjs`),t=require(`../constants/vite.constants.cjs`),n=require(`../functions/utils/amounts.utils.cjs`);let
|
|
1
|
+
const e=require(`../../../../../_virtual/_rolldown/runtime.cjs`),t=require(`../constants/vite.constants.cjs`),n=require(`../functions/utils/amounts.utils.cjs`),r=require(`../../../shims/circomlibjs-hinkal-fork.cjs`);let i=require(`ethers`),a=require(`poseidon-lite`);a=e.__toESM(a);var o=r.default,s=()=>{let e=e=>{let t=a[`poseidon${e.length}`];if(!t)throw Error(`Poseidon: arity ${e.length} not supported (1..16)`);return t(e.map(e=>BigInt(e)))};return e.F={toString:e=>BigInt(e).toString()},e},c=new class{poseidon=void 0;async init(){this.poseidon||=t.isReactNative?s():await(0,o.buildPoseidon)()}getPoseidon(){return this.poseidon}};function l(...e){let t=c.getPoseidon();return n.toBigInt(t.F.toString(t(e)))}var u=(...e)=>{let t=c.getPoseidon();return i.ethers.toBeHex(t.F.toString(t([...e])))};exports.poseidonFunction=l,exports.poseidonHash=u,exports.poseidonHolder=c;
|
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import { isReactNative as e } from "../constants/vite.constants.mjs";
|
|
2
2
|
import { toBigInt as t } from "../functions/utils/amounts.utils.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
3
|
+
import { require_circomlibjs_hinkal_fork as n } from "../../../shims/circomlibjs-hinkal-fork.mjs";
|
|
4
|
+
import { ethers as r } from "ethers";
|
|
5
|
+
import * as i from "poseidon-lite";
|
|
6
6
|
//#region common/src/crypto/poseidon.ts
|
|
7
|
-
var a = () => {
|
|
7
|
+
var a = n(), o = () => {
|
|
8
8
|
let e = (e) => {
|
|
9
|
-
let t =
|
|
9
|
+
let t = i[`poseidon${e.length}`];
|
|
10
10
|
if (!t) throw Error(`Poseidon: arity ${e.length} not supported (1..16)`);
|
|
11
11
|
return t(e.map((e) => BigInt(e)));
|
|
12
12
|
};
|
|
13
13
|
return e.F = { toString: (e) => BigInt(e).toString() }, e;
|
|
14
|
-
},
|
|
14
|
+
}, s = new class {
|
|
15
15
|
poseidon = void 0;
|
|
16
16
|
async init() {
|
|
17
|
-
this.poseidon ||= e ?
|
|
17
|
+
this.poseidon ||= e ? o() : await (0, a.buildPoseidon)();
|
|
18
18
|
}
|
|
19
19
|
getPoseidon() {
|
|
20
20
|
return this.poseidon;
|
|
21
21
|
}
|
|
22
22
|
}();
|
|
23
|
-
function
|
|
24
|
-
let n =
|
|
23
|
+
function c(...e) {
|
|
24
|
+
let n = s.getPoseidon();
|
|
25
25
|
return t(n.F.toString(n(e)));
|
|
26
26
|
}
|
|
27
|
-
var
|
|
28
|
-
let t =
|
|
29
|
-
return
|
|
27
|
+
var l = (...e) => {
|
|
28
|
+
let t = s.getPoseidon();
|
|
29
|
+
return r.toBeHex(t.F.toString(t([...e])));
|
|
30
30
|
};
|
|
31
31
|
//#endregion
|
|
32
|
-
export {
|
|
32
|
+
export { c as poseidonFunction, l as poseidonHash, s as poseidonHolder };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require(`../../error-handling/error-codes.constants.cjs`),t=require(`../../../../shims/idb-keyval.cjs`),n=require(`../../types/activities.types.cjs`),r=require(`../../types/cache.types.cjs`);require(`../../types/index.cjs`);const i=require(`../../error-handling/logger.cjs`);require(`../../error-handling/index.cjs`);const a=require(`../../constants/tx-confirmation.constants.cjs`),o=require(`../../functions/utils/tx-confirmation.utils.cjs`);require(`../../functions/index.cjs`);const s=require(`../../functions/utils/aggregateTokenAmounts.cjs`);var c=t.default,l=class{generateTxId(){return`tx_${new Date().getTime()}_${Math.random().toString(36).substring(2,15)}`}async getTransactionRecord(){return await(0,c.get)(r.StorageKeys.TX_ACTIVITY)||{}}async saveTxRequest(e){let{from:t,to:i,gasInDollar:a,extraNativeTokenFee:o,chainId:l,status:u,txHash:d,activityType:f,tokensReceive:p,tokensSpend:m,tokensApprove:h,activityIcon:g,dappUrl:_,dappName:v,integrationProvider:y,knownPartialSignature:b}=e,x=this.generateTxId(),S=m?.length?s.aggregateTokensBySymbol(m):[],C=p?.length?s.aggregateTokensBySymbol(p):[],w={id:x,from:t,to:i,gasInDollar:a?.toString(),extraNativeTokenFee:o?.toString(),chainId:l,txHash:d,activityType:f,status:u??n.ActivityStatus.PENDING,timestamp:new Date,tokensReceive:C,tokensSpend:S,tokensApprove:h,activityIcon:g,dappUrl:_,dappName:v,integrationProvider:y,knownPartialSignature:b};return await(0,c.update)(r.StorageKeys.TX_ACTIVITY,(e={})=>(e[x]=w,e)),x}async getTxRequest(e){return(await this.getTransactionRecord())[e]||null}async getAllTxRequests(e){let t=await this.getTransactionRecord();return Object.values(t).filter(t=>t.chainId===e).sort((e,t)=>new Date(t.timestamp).getTime()-new Date(e.timestamp).getTime())}async updateTxHash(e,t){let n=await this.getTxRequest(e);if(!n)throw Error(`Activity not found`);let i={...n,txHash:t};await(0,c.update)(r.StorageKeys.TX_ACTIVITY,(t={})=>(t[e]=i,t))}async updateTxStatusAndHash(e,t,n){let i=await this.getTxRequest(e);if(!i)throw Error(`Transaction not found`);let a={...i,status:t,txHash:n,timestamp:new Date};return await(0,c.update)(r.StorageKeys.TX_ACTIVITY,(t={})=>(t[e]=a,t)),a}async updateActivity(e,t,n){try{await this.updateTxStatusAndHash(e,t,n)}catch(e){i.Logger.error(`error in updating tx request`,e)}}async removePendingTransactions(e){try{await(0,c.update)(r.StorageKeys.TX_ACTIVITY,(t={})=>(delete t[e],t))}catch(e){i.Logger.error(`error in deleting tx requests`,e)}}async updatePendingTransactions(t,r,s,c){try{let i=await this.getTxRequest(r);if(!i)throw Error(`Transaction not found`);let{chainId:l}=i;if(!t.success){c?.(t.error),await this.updateActivity(r,n.ActivityStatus.FAILED,`erroredTx`in t?t.erroredTx:void 0);return}if(`txHash`in t){let{txHash:i}=t;try{await o.waitForTransactionConfirmation(l,i,{evmTimeoutMs:a.RELAYER_TX_CONFIRMATION_TIMEOUT})}catch(t){let a=t instanceof Error?t:Error(e.transactionErrorCodes.UNKNOWN);c?.(a),await this.updateActivity(r,n.ActivityStatus.FAILED,i);return}s?.(),await this.updateActivity(r,n.ActivityStatus.SUCCESSFUL,i)}}catch(e){i.Logger.error(`error in updating pending transactions`,e)}}},u=new l;exports.ActivityStorage=l,exports.activityStorage=u;
|
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
import { transactionErrorCodes as e } from "../../error-handling/error-codes.constants.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { require_idb_keyval as t } from "../../../../shims/idb-keyval.mjs";
|
|
3
|
+
import { ActivityStatus as n } from "../../types/activities.types.mjs";
|
|
4
|
+
import { StorageKeys as r } from "../../types/cache.types.mjs";
|
|
4
5
|
import "../../types/index.mjs";
|
|
5
|
-
import { Logger as
|
|
6
|
+
import { Logger as i } from "../../error-handling/logger.mjs";
|
|
6
7
|
import "../../error-handling/index.mjs";
|
|
7
|
-
import { RELAYER_TX_CONFIRMATION_TIMEOUT as
|
|
8
|
-
import { waitForTransactionConfirmation as
|
|
8
|
+
import { RELAYER_TX_CONFIRMATION_TIMEOUT as a } from "../../constants/tx-confirmation.constants.mjs";
|
|
9
|
+
import { waitForTransactionConfirmation as o } from "../../functions/utils/tx-confirmation.utils.mjs";
|
|
9
10
|
import "../../functions/index.mjs";
|
|
10
|
-
import { aggregateTokensBySymbol as
|
|
11
|
-
import { get as s, update as c } from "idb-keyval";
|
|
11
|
+
import { aggregateTokensBySymbol as s } from "../../functions/utils/aggregateTokenAmounts.mjs";
|
|
12
12
|
//#region common/src/data-structures/IndexedDB/activity-db.ts
|
|
13
|
-
var l = class {
|
|
13
|
+
var c = t(), l = class {
|
|
14
14
|
generateTxId() {
|
|
15
15
|
return `tx_${(/* @__PURE__ */ new Date()).getTime()}_${Math.random().toString(36).substring(2, 15)}`;
|
|
16
16
|
}
|
|
17
17
|
async getTransactionRecord() {
|
|
18
|
-
return await
|
|
18
|
+
return await (0, c.get)(r.TX_ACTIVITY) || {};
|
|
19
19
|
}
|
|
20
20
|
async saveTxRequest(e) {
|
|
21
|
-
let { from:
|
|
21
|
+
let { from: t, to: i, gasInDollar: a, extraNativeTokenFee: o, chainId: l, status: u, txHash: d, activityType: f, tokensReceive: p, tokensSpend: m, tokensApprove: h, activityIcon: g, dappUrl: _, dappName: v, integrationProvider: y, knownPartialSignature: b } = e, x = this.generateTxId(), S = m?.length ? s(m) : [], C = p?.length ? s(p) : [], w = {
|
|
22
22
|
id: x,
|
|
23
|
-
from:
|
|
23
|
+
from: t,
|
|
24
24
|
to: i,
|
|
25
25
|
gasInDollar: a?.toString(),
|
|
26
|
-
extraNativeTokenFee:
|
|
26
|
+
extraNativeTokenFee: o?.toString(),
|
|
27
27
|
chainId: l,
|
|
28
28
|
txHash: d,
|
|
29
29
|
activityType: f,
|
|
30
|
-
status: u ??
|
|
30
|
+
status: u ?? n.PENDING,
|
|
31
31
|
timestamp: /* @__PURE__ */ new Date(),
|
|
32
32
|
tokensReceive: C,
|
|
33
33
|
tokensSpend: S,
|
|
@@ -38,7 +38,7 @@ var l = class {
|
|
|
38
38
|
integrationProvider: y,
|
|
39
39
|
knownPartialSignature: b
|
|
40
40
|
};
|
|
41
|
-
return await c(
|
|
41
|
+
return await (0, c.update)(r.TX_ACTIVITY, (e = {}) => (e[x] = w, e)), x;
|
|
42
42
|
}
|
|
43
43
|
async getTxRequest(e) {
|
|
44
44
|
return (await this.getTransactionRecord())[e] || null;
|
|
@@ -48,61 +48,61 @@ var l = class {
|
|
|
48
48
|
return Object.values(t).filter((t) => t.chainId === e).sort((e, t) => new Date(t.timestamp).getTime() - new Date(e.timestamp).getTime());
|
|
49
49
|
}
|
|
50
50
|
async updateTxHash(e, t) {
|
|
51
|
-
let
|
|
52
|
-
if (!
|
|
51
|
+
let n = await this.getTxRequest(e);
|
|
52
|
+
if (!n) throw Error("Activity not found");
|
|
53
53
|
let i = {
|
|
54
|
-
...
|
|
54
|
+
...n,
|
|
55
55
|
txHash: t
|
|
56
56
|
};
|
|
57
|
-
await c(
|
|
57
|
+
await (0, c.update)(r.TX_ACTIVITY, (t = {}) => (t[e] = i, t));
|
|
58
58
|
}
|
|
59
|
-
async updateTxStatusAndHash(e, t,
|
|
59
|
+
async updateTxStatusAndHash(e, t, n) {
|
|
60
60
|
let i = await this.getTxRequest(e);
|
|
61
61
|
if (!i) throw Error("Transaction not found");
|
|
62
62
|
let a = {
|
|
63
63
|
...i,
|
|
64
64
|
status: t,
|
|
65
|
-
txHash:
|
|
65
|
+
txHash: n,
|
|
66
66
|
timestamp: /* @__PURE__ */ new Date()
|
|
67
67
|
};
|
|
68
|
-
return await c(
|
|
68
|
+
return await (0, c.update)(r.TX_ACTIVITY, (t = {}) => (t[e] = a, t)), a;
|
|
69
69
|
}
|
|
70
70
|
async updateActivity(e, t, n) {
|
|
71
71
|
try {
|
|
72
72
|
await this.updateTxStatusAndHash(e, t, n);
|
|
73
73
|
} catch (e) {
|
|
74
|
-
|
|
74
|
+
i.error("error in updating tx request", e);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
async removePendingTransactions(e) {
|
|
78
78
|
try {
|
|
79
|
-
await c(
|
|
79
|
+
await (0, c.update)(r.TX_ACTIVITY, (t = {}) => (delete t[e], t));
|
|
80
80
|
} catch (e) {
|
|
81
|
-
|
|
81
|
+
i.error("error in deleting tx requests", e);
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
async updatePendingTransactions(
|
|
84
|
+
async updatePendingTransactions(t, r, s, c) {
|
|
85
85
|
try {
|
|
86
|
-
let
|
|
87
|
-
if (!
|
|
88
|
-
let { chainId: l } =
|
|
89
|
-
if (!
|
|
90
|
-
c?.(
|
|
86
|
+
let i = await this.getTxRequest(r);
|
|
87
|
+
if (!i) throw Error("Transaction not found");
|
|
88
|
+
let { chainId: l } = i;
|
|
89
|
+
if (!t.success) {
|
|
90
|
+
c?.(t.error), await this.updateActivity(r, n.FAILED, "erroredTx" in t ? t.erroredTx : void 0);
|
|
91
91
|
return;
|
|
92
92
|
}
|
|
93
|
-
if ("txHash" in
|
|
94
|
-
let { txHash:
|
|
93
|
+
if ("txHash" in t) {
|
|
94
|
+
let { txHash: i } = t;
|
|
95
95
|
try {
|
|
96
|
-
await
|
|
97
|
-
} catch (
|
|
98
|
-
let
|
|
99
|
-
c?.(
|
|
96
|
+
await o(l, i, { evmTimeoutMs: a });
|
|
97
|
+
} catch (t) {
|
|
98
|
+
let a = t instanceof Error ? t : Error(e.UNKNOWN);
|
|
99
|
+
c?.(a), await this.updateActivity(r, n.FAILED, i);
|
|
100
100
|
return;
|
|
101
101
|
}
|
|
102
|
-
s?.(), await this.updateActivity(
|
|
102
|
+
s?.(), await this.updateActivity(r, n.SUCCESSFUL, i);
|
|
103
103
|
}
|
|
104
104
|
} catch (e) {
|
|
105
|
-
|
|
105
|
+
i.error("error in updating pending transactions", e);
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
}, u = new l();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(
|
|
1
|
+
const e=require(`../../../../shims/idb-keyval.cjs`),t=require(`../../error-handling/logger.cjs`),n=require(`../../functions/utils/string.utils.cjs`);require(`../../functions/utils/index.cjs`);var r=e.default;new class{balancesRecordLabel=`walletsBalances`;async getBalances(){return await(0,r.get)(this.balancesRecordLabel)}async getBalancesByWallet(e,t){let r=await this.getBalances();if(r)return r[n.getStateKey(e,t)]}async setBalances(e,i,a,o){let s=[];if(!o)return await(0,r.update)(this.balancesRecordLabel,(t={})=>{let r=n.getStateKey(i,e);return{...t,[r]:a}}),a;if(o.length===0)return await this.getBalancesByWallet(i,e)??[];try{await(0,r.update)(this.balancesRecordLabel,(t={})=>{let r=n.getStateKey(i,e),c=this.createBalanceLookup(t[r]),l=this.createBalanceLookup(a);return o.forEach(({erc20TokenAddress:e})=>{let t=e.toLowerCase();t in l?c[t]=l[t]:delete c[t]}),s=Object.values(c),{...t,[r]:s}})}catch(e){t.Logger.error(`Failed to update wallet balances:`,e)}return s}createBalanceLookup(e=[]){return e.reduce((e,t)=>({...e,[t.token.erc20TokenAddress.toLowerCase()]:t}),{})}};
|
|
@@ -1,39 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { require_idb_keyval as e } from "../../../../shims/idb-keyval.mjs";
|
|
2
|
+
import { Logger as t } from "../../error-handling/logger.mjs";
|
|
3
|
+
import { getStateKey as n } from "../../functions/utils/string.utils.mjs";
|
|
3
4
|
import "../../functions/utils/index.mjs";
|
|
4
|
-
|
|
5
|
+
//#region common/src/data-structures/IndexedDB/balances-db.ts
|
|
6
|
+
var r = e();
|
|
5
7
|
new class {
|
|
6
8
|
balancesRecordLabel = "walletsBalances";
|
|
7
9
|
async getBalances() {
|
|
8
|
-
return await
|
|
10
|
+
return await (0, r.get)(this.balancesRecordLabel);
|
|
9
11
|
}
|
|
10
|
-
async getBalancesByWallet(e,
|
|
12
|
+
async getBalancesByWallet(e, t) {
|
|
11
13
|
let r = await this.getBalances();
|
|
12
|
-
if (r) return r[
|
|
14
|
+
if (r) return r[n(e, t)];
|
|
13
15
|
}
|
|
14
|
-
async setBalances(
|
|
16
|
+
async setBalances(e, i, a, o) {
|
|
15
17
|
let s = [];
|
|
16
|
-
if (!o) return await r(this.balancesRecordLabel, (
|
|
17
|
-
let r =
|
|
18
|
+
if (!o) return await (0, r.update)(this.balancesRecordLabel, (t = {}) => {
|
|
19
|
+
let r = n(i, e);
|
|
18
20
|
return {
|
|
19
|
-
...
|
|
21
|
+
...t,
|
|
20
22
|
[r]: a
|
|
21
23
|
};
|
|
22
24
|
}), a;
|
|
23
|
-
if (o.length === 0) return await this.getBalancesByWallet(i,
|
|
25
|
+
if (o.length === 0) return await this.getBalancesByWallet(i, e) ?? [];
|
|
24
26
|
try {
|
|
25
|
-
await r(this.balancesRecordLabel, (
|
|
26
|
-
let r =
|
|
27
|
+
await (0, r.update)(this.balancesRecordLabel, (t = {}) => {
|
|
28
|
+
let r = n(i, e), c = this.createBalanceLookup(t[r]), l = this.createBalanceLookup(a);
|
|
27
29
|
return o.forEach(({ erc20TokenAddress: e }) => {
|
|
28
30
|
let t = e.toLowerCase();
|
|
29
31
|
t in l ? c[t] = l[t] : delete c[t];
|
|
30
32
|
}), s = Object.values(c), {
|
|
31
|
-
...
|
|
33
|
+
...t,
|
|
32
34
|
[r]: s
|
|
33
35
|
};
|
|
34
36
|
});
|
|
35
|
-
} catch (
|
|
36
|
-
|
|
37
|
+
} catch (e) {
|
|
38
|
+
t.error("Failed to update wallet balances:", e);
|
|
37
39
|
}
|
|
38
40
|
return s;
|
|
39
41
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require(`../../functions/utils/caseInsensitive.utils.cjs`),t=require(`../../../../shims/idb-keyval.cjs`),n=require(`../../functions/utils/addresses.cjs`),r=require(`../../error-handling/logger.cjs`);require(`../../functions/index.cjs`);var i=t.default;new class{STORAGE_KEY=`contacts`;checkForDuplicate(e,t,n){if(e.find(({ethereumAddress:e,nickname:r})=>(e===t.ethereumAddress||r===t.nickname)&&e!==n)!==void 0)throw Error(`Duplicate Contact attribute`)}async createContact(e,t){let n=e.toLowerCase();await(0,i.update)(this.STORAGE_KEY,e=>{let r=e??{},i=r[n]??[];return this.checkForDuplicate(i,t),i.push(t),r[n]=i,r})}async getContacts(e){try{await this.removeOldStylePrivateAddressContacts(e);let t=e.toLowerCase(),n=await(0,i.get)(this.STORAGE_KEY);return!n||!n[t]?[]:n[t]}catch(e){return r.Logger.error(`Error while getting contacts:`,e),[]}}async editContact(t,n,r){let a=t.toLowerCase();await(0,i.update)(this.STORAGE_KEY,t=>{let i=t??{},o=i[a];if(!i||!o)throw Error(`Contacts could not be fetched`);this.checkForDuplicate(o,r,n);let s=o.findIndex(({ethereumAddress:t})=>e.caseInsensitiveEqual(t,n));if(s===-1)throw Error(`Contact to be edited was not found`);return o[s]=r,i[a]=o,i})}async removeOldStylePrivateAddressContacts(e){let t=e.toLowerCase(),r=0;return await(0,i.update)(this.STORAGE_KEY,e=>{let i=e??{},a=i[t];if(!a?.length)return i;let o=a.filter(e=>{let t=e.ethereumAddress;return!n.isValidOldStylePrivateAddress(t)||n.isValidPrivateAddress(t)?!0:(r+=1,!1)});return r===0||(i[t]=o),i}),r}async deleteContact(e,t){let n=e.toLowerCase();await(0,i.update)(this.STORAGE_KEY,e=>{let r=e??{},i=r[n];if(!r||!i)throw Error(`Contacts could not be fetched`);return r[n]=i.filter(({ethereumAddress:e})=>e!==t),r})}};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { caseInsensitiveEqual as e } from "../../functions/utils/caseInsensitive.utils.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { require_idb_keyval as t } from "../../../../shims/idb-keyval.mjs";
|
|
3
|
+
import { isValidOldStylePrivateAddress as n, isValidPrivateAddress as r } from "../../functions/utils/addresses.mjs";
|
|
4
|
+
import { Logger as i } from "../../error-handling/logger.mjs";
|
|
4
5
|
import "../../functions/index.mjs";
|
|
5
|
-
|
|
6
|
+
//#region common/src/data-structures/IndexedDB/contact-db.ts
|
|
7
|
+
var a = t();
|
|
6
8
|
new class {
|
|
7
9
|
STORAGE_KEY = "contacts";
|
|
8
10
|
checkForDuplicate(e, t, n) {
|
|
@@ -10,7 +12,7 @@ new class {
|
|
|
10
12
|
}
|
|
11
13
|
async createContact(e, t) {
|
|
12
14
|
let n = e.toLowerCase();
|
|
13
|
-
await a(this.STORAGE_KEY, (e) => {
|
|
15
|
+
await (0, a.update)(this.STORAGE_KEY, (e) => {
|
|
14
16
|
let r = e ?? {}, i = r[n] ?? [];
|
|
15
17
|
return this.checkForDuplicate(i, t), i.push(t), r[n] = i, r;
|
|
16
18
|
});
|
|
@@ -18,15 +20,15 @@ new class {
|
|
|
18
20
|
async getContacts(e) {
|
|
19
21
|
try {
|
|
20
22
|
await this.removeOldStylePrivateAddressContacts(e);
|
|
21
|
-
let t = e.toLowerCase(), n = await
|
|
23
|
+
let t = e.toLowerCase(), n = await (0, a.get)(this.STORAGE_KEY);
|
|
22
24
|
return !n || !n[t] ? [] : n[t];
|
|
23
25
|
} catch (e) {
|
|
24
|
-
return
|
|
26
|
+
return i.error("Error while getting contacts:", e), [];
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
29
|
async editContact(t, n, r) {
|
|
28
30
|
let i = t.toLowerCase();
|
|
29
|
-
await a(this.STORAGE_KEY, (t) => {
|
|
31
|
+
await (0, a.update)(this.STORAGE_KEY, (t) => {
|
|
30
32
|
let a = t ?? {}, o = a[i];
|
|
31
33
|
if (!a || !o) throw Error("Contacts could not be fetched");
|
|
32
34
|
this.checkForDuplicate(o, r, n);
|
|
@@ -36,20 +38,20 @@ new class {
|
|
|
36
38
|
});
|
|
37
39
|
}
|
|
38
40
|
async removeOldStylePrivateAddressContacts(e) {
|
|
39
|
-
let
|
|
40
|
-
return await a(this.STORAGE_KEY, (e) => {
|
|
41
|
-
let a = e ?? {}, o = a[
|
|
41
|
+
let t = e.toLowerCase(), i = 0;
|
|
42
|
+
return await (0, a.update)(this.STORAGE_KEY, (e) => {
|
|
43
|
+
let a = e ?? {}, o = a[t];
|
|
42
44
|
if (!o?.length) return a;
|
|
43
45
|
let s = o.filter((e) => {
|
|
44
|
-
let
|
|
45
|
-
return !t
|
|
46
|
+
let t = e.ethereumAddress;
|
|
47
|
+
return !n(t) || r(t) ? !0 : (i += 1, !1);
|
|
46
48
|
});
|
|
47
|
-
return i === 0 || (a[
|
|
49
|
+
return i === 0 || (a[t] = s), a;
|
|
48
50
|
}), i;
|
|
49
51
|
}
|
|
50
52
|
async deleteContact(e, t) {
|
|
51
53
|
let n = e.toLowerCase();
|
|
52
|
-
await a(this.STORAGE_KEY, (e) => {
|
|
54
|
+
await (0, a.update)(this.STORAGE_KEY, (e) => {
|
|
53
55
|
let r = e ?? {}, i = r[n];
|
|
54
56
|
if (!r || !i) throw Error("Contacts could not be fetched");
|
|
55
57
|
return r[n] = i.filter(({ ethereumAddress: e }) => e !== t), r;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../functions/utils/serialize.utils.cjs`),t=require(`../../constants/vite.constants.cjs`),n=require(`../../../../
|
|
1
|
+
const e=require(`../../functions/utils/serialize.utils.cjs`),t=require(`../../constants/vite.constants.cjs`),n=require(`../../../../shims/path.cjs`),r=require(`../../../../shims/idb-keyval.cjs`);require(`../../constants/index.cjs`);const i=require(`../cacheDevices/FileCacheDevice.cjs`);var a=()=>typeof globalThis<`u`&&`indexedDB`in globalThis&&globalThis.indexedDB!=null||t.isReactNative,o=class{idbPromise=null;idb(){return this.idbPromise||=Promise.resolve(r.default),this.idbPromise}async get(e){let{get:t}=await this.idb();return t(e)}async set(e,t){let{set:n}=await this.idb();await n(e,t)}async update(e,t){let{update:n}=await this.idb(),r;return await n(e,e=>(r=t(e),r)),r}},s=class{device;constructor(){let e=n.default;this.device=new i.FileCacheDevice(!0,e.resolve(process.cwd(),`hinkalKeyValCache.json`))}async get(t){let n=this.device.get(t);if(n)return e.CustomJSONParse(n)}async set(t,n){this.device.set(t,e.CustomJSONStringify(n))}async update(e,t){let n=t(await this.get(e));return await this.set(e,n),n}},c=a()?new o:new s;exports.keyValStore=c;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { CustomJSONParse as e, CustomJSONStringify as t } from "../../functions/utils/serialize.utils.mjs";
|
|
2
|
+
import { isReactNative as n } from "../../constants/vite.constants.mjs";
|
|
3
|
+
import { require_path as r } from "../../../../shims/path.mjs";
|
|
4
|
+
import { require_idb_keyval as i } from "../../../../shims/idb-keyval.mjs";
|
|
5
5
|
import "../../constants/index.mjs";
|
|
6
6
|
import { FileCacheDevice as a } from "../cacheDevices/FileCacheDevice.mjs";
|
|
7
7
|
//#region common/src/data-structures/IndexedDB/key-val-store.ts
|
|
8
|
-
var o = () => typeof globalThis < "u" && "indexedDB" in globalThis && globalThis.indexedDB != null ||
|
|
8
|
+
var o = () => typeof globalThis < "u" && "indexedDB" in globalThis && globalThis.indexedDB != null || n, s = class {
|
|
9
9
|
idbPromise = null;
|
|
10
10
|
idb() {
|
|
11
|
-
return this.idbPromise ||= Promise.resolve(
|
|
11
|
+
return this.idbPromise ||= Promise.resolve(i()), this.idbPromise;
|
|
12
12
|
}
|
|
13
13
|
async get(e) {
|
|
14
14
|
let { get: t } = await this.idb();
|
|
@@ -25,15 +25,15 @@ var o = () => typeof globalThis < "u" && "indexedDB" in globalThis && globalThis
|
|
|
25
25
|
}, c = class {
|
|
26
26
|
device;
|
|
27
27
|
constructor() {
|
|
28
|
-
let e =
|
|
28
|
+
let e = r();
|
|
29
29
|
this.device = new a(!0, e.resolve(process.cwd(), "hinkalKeyValCache.json"));
|
|
30
30
|
}
|
|
31
|
-
async get(
|
|
32
|
-
let n = this.device.get(
|
|
33
|
-
if (n) return
|
|
31
|
+
async get(t) {
|
|
32
|
+
let n = this.device.get(t);
|
|
33
|
+
if (n) return e(n);
|
|
34
34
|
}
|
|
35
|
-
async set(e,
|
|
36
|
-
this.device.set(e, n
|
|
35
|
+
async set(e, n) {
|
|
36
|
+
this.device.set(e, t(n));
|
|
37
37
|
}
|
|
38
38
|
async update(e, t) {
|
|
39
39
|
let n = t(await this.get(e));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(
|
|
1
|
+
const e=require(`../../../../shims/idb-keyval.cjs`),t=require(`../../types/cache.types.cjs`);require(`../../types/index.cjs`);const n=require(`./activity-db.cjs`);var r=e.default;new class extends n.ActivityStorage{async savePrivateSendTx(e){let n=this.generateTxId(),i={timestamp:new Date,...e};return await(0,r.update)(t.StorageKeys.TX_ACTIVITY,(e={})=>(e[n]=i,e)),n}async saveMultiplePrivateSendTxs(e){let t=e.map(e=>this.savePrivateSendTx(e));return Promise.all(t)}async getTransactionRecords(){return await(0,r.get)(t.StorageKeys.TX_ACTIVITY)||[]}};
|
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { require_idb_keyval as e } from "../../../../shims/idb-keyval.mjs";
|
|
2
|
+
import { StorageKeys as t } from "../../types/cache.types.mjs";
|
|
2
3
|
import "../../types/index.mjs";
|
|
3
|
-
import { ActivityStorage as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { ActivityStorage as n } from "./activity-db.mjs";
|
|
5
|
+
//#region common/src/data-structures/IndexedDB/pay-activity-db.ts
|
|
6
|
+
var r = e();
|
|
7
|
+
new class extends n {
|
|
8
|
+
async savePrivateSendTx(e) {
|
|
7
9
|
let n = this.generateTxId(), i = {
|
|
8
10
|
timestamp: /* @__PURE__ */ new Date(),
|
|
9
|
-
...
|
|
11
|
+
...e
|
|
10
12
|
};
|
|
11
|
-
return await r(
|
|
13
|
+
return await (0, r.update)(t.TX_ACTIVITY, (e = {}) => (e[n] = i, e)), n;
|
|
12
14
|
}
|
|
13
15
|
async saveMultiplePrivateSendTxs(e) {
|
|
14
16
|
let t = e.map((e) => this.savePrivateSendTx(e));
|
|
15
17
|
return Promise.all(t);
|
|
16
18
|
}
|
|
17
19
|
async getTransactionRecords() {
|
|
18
|
-
return await
|
|
20
|
+
return await (0, r.get)(t.TX_ACTIVITY) || [];
|
|
19
21
|
}
|
|
20
22
|
}();
|
|
21
23
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(
|
|
1
|
+
const e=require(`../../../../shims/idb-keyval.cjs`),t=require(`../../types/cache.types.cjs`);require(`../../types/index.cjs`);const n=require(`../../error-handling/logger.cjs`);require(`../../error-handling/index.cjs`);var r=e.default;new class{generateMessageId(){return`msg_${new Date().getTime()}_${Math.random().toString(36).substring(2,15)}`}async saveSignedMessage(e,i,a,o,s,c){try{let n=this.generateMessageId(),l=await(0,r.get)(t.StorageKeys.SIGNED_MESSAGES)||{},u={chainId:e,messageText:i,messageType:a,subAccountAddress:o,signature:s,appMetaData:c};l[n]={timestamp:new Date().toISOString(),...u},await(0,r.set)(t.StorageKeys.SIGNED_MESSAGES,l)}catch(t){n.Logger.error(`Failed to save signed message:`,t,{chainId:e,messageType:a})}}async getAllSignedMessages(){try{let e=await(0,r.get)(t.StorageKeys.SIGNED_MESSAGES)||{};return Object.values(e).sort((e,t)=>new Date(t.timestamp).getTime()-new Date(e.timestamp).getTime())}catch(e){return n.Logger.error(`Failed to retrieve signed messages:`,e),[]}}};
|