@arken/node 1.5.3 → 1.5.5
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/.rush/temp/shrinkwrap-deps.json +2 -223
- package/build/db.js +3 -21
- package/build/db.js.map +1 -1
- package/build/index.d.ts +0 -3
- package/build/index.js +0 -3
- package/build/index.js.map +1 -1
- package/build/package.json +2 -22
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/web3.d.ts +7 -10
- package/build/web3.js +9 -11
- package/build/web3.js.map +1 -1
- package/db.ts +22 -22
- package/index.ts +4 -4
- package/package.json +2 -22
- package/web3.ts +16 -15
package/build/web3.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import _Web3 from 'web3';
|
|
2
|
-
import HDWalletProvider from '@truffle/hdwallet-provider';
|
|
3
|
-
import { Contract } from '@ethersproject/contracts';
|
|
4
|
-
import { Web3Provider } from '@ethersproject/providers';
|
|
5
2
|
export declare const Web3: typeof _Web3;
|
|
6
|
-
export declare const getRandomProvider: (secret: any) =>
|
|
3
|
+
export declare const getRandomProvider: (HDWalletProvider: any, secret: any) => any;
|
|
7
4
|
export declare function iterateBlocks(app: any, name: any, address: any, fromBlock: any, toBlock: any, event: any, processLog: any, updateConfig: any): Promise<void>;
|
|
8
5
|
export declare const getAddress: (address: any) => any;
|
|
9
6
|
export declare function isValidRequest(web3: any, req: any): boolean;
|
|
@@ -12,13 +9,13 @@ export declare function getSignedRequest(web3: any, secret: any, data: any): Pro
|
|
|
12
9
|
hash: any;
|
|
13
10
|
data: any;
|
|
14
11
|
}>;
|
|
15
|
-
export declare function getTopicSignatureHex(topicSignature: any):
|
|
16
|
-
export declare function isAddress(value: any):
|
|
17
|
-
export declare function shortenAddress(address: any, chars?: number): string;
|
|
18
|
-
export declare function getContract(address: any, ABI: any, library: any, account: any):
|
|
12
|
+
export declare function getTopicSignatureHex(ethers: any, topicSignature: any): any;
|
|
13
|
+
export declare function isAddress(ethers: any, value: any): any;
|
|
14
|
+
export declare function shortenAddress(ethers: any, address: any, chars?: number): string;
|
|
15
|
+
export declare function getContract(ethers: any, address: any, ABI: any, library: any, account: any): any;
|
|
19
16
|
export declare function getSigner(library: any, account: any): any;
|
|
20
17
|
export declare function getProviderOrSigner(library: any, account: any): any;
|
|
21
18
|
export declare function encrypt(data: any, key: any): any;
|
|
22
19
|
export declare function decrypt(data: any, key: any): any;
|
|
23
|
-
export declare function toBytes32(text: any):
|
|
24
|
-
export default function getLibrary(provider: any):
|
|
20
|
+
export declare function toBytes32(ethers: any, text: any): any;
|
|
21
|
+
export default function getLibrary(ethers: any, provider: any): any;
|
package/build/web3.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import _Web3 from 'web3';
|
|
2
|
-
import HDWalletProvider from '@truffle/hdwallet-provider';
|
|
3
2
|
import CryptoJS from 'crypto-js';
|
|
4
|
-
import { ethers } from 'ethers';
|
|
5
3
|
import { log, logError } from './log';
|
|
6
4
|
export const Web3 = _Web3;
|
|
7
|
-
export const getRandomProvider = (secret) => {
|
|
5
|
+
export const getRandomProvider = (HDWalletProvider, secret) => {
|
|
8
6
|
return new HDWalletProvider(secret.mnemonic, process.env.PROVIDER_URI);
|
|
9
7
|
};
|
|
10
8
|
export async function iterateBlocks(app, name, address, fromBlock, toBlock, event, processLog, updateConfig) {
|
|
@@ -67,10 +65,10 @@ export async function getSignedRequest(web3, secret, data) {
|
|
|
67
65
|
return null;
|
|
68
66
|
}
|
|
69
67
|
}
|
|
70
|
-
export function getTopicSignatureHex(topicSignature) {
|
|
68
|
+
export function getTopicSignatureHex(ethers, topicSignature) {
|
|
71
69
|
return ethers.utils.id(topicSignature);
|
|
72
70
|
}
|
|
73
|
-
export function isAddress(value) {
|
|
71
|
+
export function isAddress(ethers, value) {
|
|
74
72
|
try {
|
|
75
73
|
return ethers.utils.getAddress(value);
|
|
76
74
|
}
|
|
@@ -78,15 +76,15 @@ export function isAddress(value) {
|
|
|
78
76
|
return false;
|
|
79
77
|
}
|
|
80
78
|
}
|
|
81
|
-
export function shortenAddress(address, chars = 4) {
|
|
82
|
-
const parsed = isAddress(address);
|
|
79
|
+
export function shortenAddress(ethers, address, chars = 4) {
|
|
80
|
+
const parsed = isAddress(ethers, address);
|
|
83
81
|
if (!parsed) {
|
|
84
82
|
throw Error(`Invalid 'address' parameter '${address}'.`);
|
|
85
83
|
}
|
|
86
84
|
return `${parsed.substring(0, chars + 2)}...${parsed.substring(42 - chars)}`;
|
|
87
85
|
}
|
|
88
|
-
export function getContract(address, ABI, library, account) {
|
|
89
|
-
if (!isAddress(address) || address === ethers.constants.AddressZero) {
|
|
86
|
+
export function getContract(ethers, address, ABI, library, account) {
|
|
87
|
+
if (!isAddress(ethers, address) || address === ethers.constants.AddressZero) {
|
|
90
88
|
throw Error(`Invalid 'address' parameter '${address}'.`);
|
|
91
89
|
}
|
|
92
90
|
return new ethers.Contract(address, ABI, getProviderOrSigner(library, account));
|
|
@@ -103,7 +101,7 @@ export function encrypt(data, key) {
|
|
|
103
101
|
export function decrypt(data, key) {
|
|
104
102
|
return CryptoJS.AES.decrypt(data, key).toString(CryptoJS.enc.Utf8);
|
|
105
103
|
}
|
|
106
|
-
export function toBytes32(text) {
|
|
104
|
+
export function toBytes32(ethers, text) {
|
|
107
105
|
let data = ethers.utils.toUtf8Bytes(text);
|
|
108
106
|
if (data.length > 32) {
|
|
109
107
|
throw new Error('too long');
|
|
@@ -111,7 +109,7 @@ export function toBytes32(text) {
|
|
|
111
109
|
data = ethers.utils.zeroPad(data, 32);
|
|
112
110
|
return ethers.utils.hexlify(data);
|
|
113
111
|
}
|
|
114
|
-
export default function getLibrary(provider) {
|
|
112
|
+
export default function getLibrary(ethers, provider) {
|
|
115
113
|
const library = new ethers.providers.Web3Provider(provider);
|
|
116
114
|
library.pollingInterval = 15000;
|
|
117
115
|
return library;
|
package/build/web3.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web3.js","s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AC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACrE,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,MAAM,EAAE,IAAI;IACpC,IAAI,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAC1C,IAAI,IAAI,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC;IAC9B,CAAC;IACD,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACtC,OAAO,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AACpC,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,MAAM,EAAE,QAAQ;IACjD,MAAM,OAAO,GAAG,IAAI,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAC5D,OAAO,CAAC,eAAe,GAAG,KAAK,CAAC;IAChC,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/db.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReplaySubject } from 'rxjs';
|
|
2
2
|
import Loki from 'lokijs';
|
|
3
|
-
import * as jetpack from 'fs-jetpack';
|
|
3
|
+
// import * as jetpack from 'fs-jetpack';
|
|
4
4
|
import mongoose, {
|
|
5
5
|
ConnectOptions,
|
|
6
6
|
Model as MongooseModel,
|
|
@@ -18,16 +18,17 @@ import fsPath from 'path';
|
|
|
18
18
|
import { v4 as uuidv4 } from 'uuid';
|
|
19
19
|
import _ from 'lodash';
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
export function isPostgresError (error: unknown): boolean {
|
|
21
|
+
export function isPostgresError(error: unknown): boolean {
|
|
23
22
|
if (!error) {
|
|
24
23
|
return false;
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
return _.every(['severity', 'code', 'detail', 'internalQuery', 'routine'], (attr) => _.has(error as object, attr));
|
|
28
|
-
}
|
|
27
|
+
}
|
|
29
28
|
|
|
30
|
-
export function isUniqueConstraintViolation
|
|
29
|
+
export function isUniqueConstraintViolation(error) {
|
|
30
|
+
return isPostgresError(error) && error.code === '23505';
|
|
31
|
+
}
|
|
31
32
|
|
|
32
33
|
export function generateLongId(): string {
|
|
33
34
|
return uuidv4().toUpperCase();
|
|
@@ -89,7 +90,6 @@ export function escapeStringRegexp(string: string): string {
|
|
|
89
90
|
return string.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d');
|
|
90
91
|
}
|
|
91
92
|
|
|
92
|
-
|
|
93
93
|
let app: any;
|
|
94
94
|
let log: (...msgs: any[]) => void;
|
|
95
95
|
|
|
@@ -463,27 +463,27 @@ class Database {
|
|
|
463
463
|
restoreData() {
|
|
464
464
|
log('Restoring data', ['p1']);
|
|
465
465
|
|
|
466
|
-
const files = jetpack.find(fsPath.join(__dirname, 'data/db'), { matching: '**/*.json' });
|
|
466
|
+
// const files = jetpack.find(fsPath.join(__dirname, 'data/db'), { matching: '**/*.json' });
|
|
467
467
|
|
|
468
|
-
for (const file of files) {
|
|
469
|
-
|
|
468
|
+
// for (const file of files) {
|
|
469
|
+
// log(`Found file: ${file}`);
|
|
470
470
|
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
471
|
+
// try {
|
|
472
|
+
// const data = jetpack.read(file, 'json');
|
|
473
|
+
// const [name, key] = file.replace('data/db/', '').replace('.json', '').split('/');
|
|
474
474
|
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
475
|
+
// this.initCollection(name, key, data as Record<string, any>);
|
|
476
|
+
// } catch (e) {
|
|
477
|
+
// if (e.toString().indexOf('JSON parsing failed') !== -1) {
|
|
478
|
+
// log(`File corrupt, loading backup: ${file}`);
|
|
479
479
|
|
|
480
|
-
|
|
481
|
-
|
|
480
|
+
// const data = jetpack.read(`${file}.backup`, 'json');
|
|
481
|
+
// const [name, key] = file.replace('data/db/', '').replace('.json', '').split('/');
|
|
482
482
|
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
}
|
|
483
|
+
// this.initCollection(name, key, data as Record<string, any>);
|
|
484
|
+
// }
|
|
485
|
+
// }
|
|
486
|
+
// }
|
|
487
487
|
}
|
|
488
488
|
|
|
489
489
|
beautify(data: any) {
|
package/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import crypto from 'crypto';
|
|
2
2
|
import { exec } from 'child_process';
|
|
3
3
|
// import jetpack from 'fs-jetpack';
|
|
4
|
-
import * as ethers from 'ethers';
|
|
4
|
+
// import * as ethers from 'ethers';
|
|
5
5
|
import _ from 'lodash';
|
|
6
6
|
import config from './config';
|
|
7
7
|
import * as time from './time';
|
|
@@ -52,9 +52,9 @@ export function removeDupes(list) {
|
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
export const toLong = (x, decimals = 16) =>
|
|
56
|
-
|
|
57
|
-
export const toShort = (x) => round(parseFloat(ethers.utils.formatEther(x)), 4);
|
|
55
|
+
// export const toLong = (x, decimals = 16) =>
|
|
56
|
+
// decimals === 16 ? ethers.utils.parseEther(x + '') : ethers.utils.parseUnits(x + '', decimals);
|
|
57
|
+
// export const toShort = (x) => round(parseFloat(ethers.utils.formatEther(x)), 4);
|
|
58
58
|
|
|
59
59
|
let updatingGit = false;
|
|
60
60
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arken/node",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/types.d.ts",
|
|
@@ -15,35 +15,16 @@
|
|
|
15
15
|
"zk:regen-updateLeaf": "ts-node scripts/zk-regen-updateLeaf.ts"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@ethersproject/address": "^5",
|
|
19
|
-
"@ethersproject/constants": "^5",
|
|
20
|
-
"@ethersproject/contracts": "^5",
|
|
21
|
-
"@ethersproject/networks": "^5",
|
|
22
|
-
"@ethersproject/providers": "^5",
|
|
23
|
-
"@ethersproject/solidity": "^5",
|
|
24
18
|
"@trpc/server": "11.0.0-rc.660",
|
|
25
19
|
"@trpc/client": "11.0.0-rc.660",
|
|
26
|
-
"@truffle/hdwallet-provider": "^1",
|
|
27
|
-
"@typechain/ethers-v4": "^1",
|
|
28
20
|
"axios": "^1",
|
|
29
|
-
"compromise": "^14",
|
|
30
|
-
"cross-fetch": "^4",
|
|
31
21
|
"crypto-js": "^4",
|
|
32
22
|
"dayjs": "^1",
|
|
33
|
-
"es6-promise": "^4",
|
|
34
|
-
"ethers": "^5",
|
|
35
|
-
"franc": "^6",
|
|
36
|
-
"fs-jetpack": "^4",
|
|
37
23
|
"js-md5": "^0",
|
|
38
|
-
"knex": "^0",
|
|
39
|
-
"langdetect": "^0",
|
|
40
24
|
"lodash": "^4",
|
|
41
25
|
"lokijs": "^1",
|
|
42
26
|
"moment": "^2",
|
|
43
27
|
"mongoose": "^8",
|
|
44
|
-
"natural": "^7",
|
|
45
|
-
"node-fetch": "^3",
|
|
46
|
-
"objection": "^2",
|
|
47
28
|
"openai": "^4",
|
|
48
29
|
"pluralize": "^8",
|
|
49
30
|
"puppeteer": "^22",
|
|
@@ -55,6 +36,7 @@
|
|
|
55
36
|
"web3": "^1",
|
|
56
37
|
"zod": "^3",
|
|
57
38
|
"rxjs": "^7",
|
|
39
|
+
"natural": "^7",
|
|
58
40
|
"fast-safe-stringify": "^2",
|
|
59
41
|
"@types/socket.io-client": "~3.0.0",
|
|
60
42
|
"otplib": "~12.0.1",
|
|
@@ -66,14 +48,12 @@
|
|
|
66
48
|
},
|
|
67
49
|
"devDependencies": {
|
|
68
50
|
"@types/common-tags": "^1",
|
|
69
|
-
"@types/ethereum-protocol": "^1",
|
|
70
51
|
"@types/jest": "^29",
|
|
71
52
|
"@types/lodash": "^4",
|
|
72
53
|
"@types/mongoose": "^5",
|
|
73
54
|
"@types/node": "^20",
|
|
74
55
|
"@types/react": "^18",
|
|
75
56
|
"@types/react-dom": "^18",
|
|
76
|
-
"@types/web3": "^1",
|
|
77
57
|
"@typescript-eslint/eslint-plugin": "^8",
|
|
78
58
|
"@typescript-eslint/parser": "^8",
|
|
79
59
|
"del-cli": "^5",
|
package/web3.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import md5 from 'js-md5';
|
|
2
2
|
import _Web3 from 'web3';
|
|
3
|
-
import HDWalletProvider from '@truffle/hdwallet-provider';
|
|
3
|
+
// import HDWalletProvider from '@truffle/hdwallet-provider';
|
|
4
4
|
import CryptoJS from 'crypto-js';
|
|
5
|
-
import ethersAddress from '@ethersproject/address';
|
|
6
|
-
import { Contract } from '@ethersproject/contracts';
|
|
7
|
-
import { Web3Provider } from '@ethersproject/providers';
|
|
8
|
-
import { ethers } from 'ethers';
|
|
5
|
+
// import ethersAddress from '@ethersproject/address';
|
|
6
|
+
// import { Contract } from '@ethersproject/contracts';
|
|
7
|
+
// import { Web3Provider } from '@ethersproject/providers';
|
|
8
|
+
// import { ethers } from 'ethers';
|
|
9
9
|
import { log, logError } from './log';
|
|
10
10
|
|
|
11
11
|
// const fetchPrice = async (id, vs = 'usd') => {
|
|
@@ -20,7 +20,7 @@ import { log, logError } from './log';
|
|
|
20
20
|
|
|
21
21
|
export const Web3 = _Web3;
|
|
22
22
|
|
|
23
|
-
export const getRandomProvider = (secret) => {
|
|
23
|
+
export const getRandomProvider = (HDWalletProvider, secret) => {
|
|
24
24
|
return new HDWalletProvider(
|
|
25
25
|
secret.mnemonic,
|
|
26
26
|
process.env.PROVIDER_URI //networks[Math.floor(Math.random() * networks.length)]
|
|
@@ -110,12 +110,12 @@ export async function getSignedRequest(web3, secret, data) {
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
// Get the topic signature hex
|
|
113
|
-
export function getTopicSignatureHex(topicSignature) {
|
|
113
|
+
export function getTopicSignatureHex(ethers, topicSignature) {
|
|
114
114
|
return ethers.utils.id(topicSignature);
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
// Returns the checksummed address if the address is valid, otherwise returns false
|
|
118
|
-
export function isAddress(value) {
|
|
118
|
+
export function isAddress(ethers, value) {
|
|
119
119
|
try {
|
|
120
120
|
return ethers.utils.getAddress(value);
|
|
121
121
|
} catch {
|
|
@@ -124,8 +124,8 @@ export function isAddress(value) {
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
// Shorten the checksummed version of the input address to have 0x + 4 characters at start and end
|
|
127
|
-
export function shortenAddress(address, chars = 4) {
|
|
128
|
-
const parsed = isAddress(address);
|
|
127
|
+
export function shortenAddress(ethers, address, chars = 4) {
|
|
128
|
+
const parsed = isAddress(ethers, address);
|
|
129
129
|
if (!parsed) {
|
|
130
130
|
throw Error(`Invalid 'address' parameter '${address}'.`);
|
|
131
131
|
}
|
|
@@ -133,8 +133,9 @@ export function shortenAddress(address, chars = 4) {
|
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
// account is optional
|
|
136
|
-
export function getContract(address, ABI, library, account) {
|
|
137
|
-
|
|
136
|
+
export function getContract(ethers, address, ABI, library, account) {
|
|
137
|
+
// pass in ethers
|
|
138
|
+
if (!isAddress(ethers, address) || address === ethers.constants.AddressZero) {
|
|
138
139
|
throw Error(`Invalid 'address' parameter '${address}'.`);
|
|
139
140
|
}
|
|
140
141
|
|
|
@@ -159,7 +160,7 @@ export function decrypt(data, key) {
|
|
|
159
160
|
return CryptoJS.AES.decrypt(data, key).toString(CryptoJS.enc.Utf8);
|
|
160
161
|
}
|
|
161
162
|
|
|
162
|
-
export function toBytes32(text) {
|
|
163
|
+
export function toBytes32(ethers, text) {
|
|
163
164
|
let data = ethers.utils.toUtf8Bytes(text);
|
|
164
165
|
if (data.length > 32) {
|
|
165
166
|
throw new Error('too long');
|
|
@@ -168,8 +169,8 @@ export function toBytes32(text) {
|
|
|
168
169
|
return ethers.utils.hexlify(data);
|
|
169
170
|
}
|
|
170
171
|
|
|
171
|
-
export default function getLibrary(provider) {
|
|
172
|
-
const library = new ethers.providers.Web3Provider(provider);
|
|
172
|
+
export default function getLibrary(ethers, provider) {
|
|
173
|
+
const library = new ethers.providers.Web3Provider(provider); // pass in ethers.providers.Web3Provider
|
|
173
174
|
library.pollingInterval = 15000;
|
|
174
175
|
return library;
|
|
175
176
|
}
|