@acala-network/chopsticks-core 0.8.0-2 → 0.8.0-4
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/lib/blockchain/index.d.ts +1 -0
- package/lib/blockchain/index.js +6 -0
- package/lib/db/browser.d.ts +1 -1
- package/lib/db/browser.js +4 -4
- package/lib/db/index.d.ts +1 -1
- package/lib/db/index.js +3 -3
- package/lib/db/sql-wasm.d.ts +1 -0
- package/lib/db/sql-wasm.js +9 -0
- package/lib/setup.d.ts +1 -1
- package/lib/setup.js +0 -5
- package/lib/utils/decoder.d.ts +24 -0
- package/lib/utils/decoder.js +113 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +1 -0
- package/package.json +9 -7
|
@@ -70,4 +70,5 @@ export declare class Blockchain {
|
|
|
70
70
|
dryRunDmp(dmp: DownwardMessage[], at?: HexString): Promise<[HexString, HexString | null][]>;
|
|
71
71
|
dryRunUmp(ump: Record<number, HexString[]>, at?: HexString): Promise<[HexString, HexString | null][]>;
|
|
72
72
|
getInherents(): Promise<HexString[]>;
|
|
73
|
+
close(): Promise<void>;
|
|
73
74
|
}
|
package/lib/blockchain/index.js
CHANGED
|
@@ -342,6 +342,12 @@ class Blockchain {
|
|
|
342
342
|
return inherents;
|
|
343
343
|
});
|
|
344
344
|
}
|
|
345
|
+
close() {
|
|
346
|
+
var _a;
|
|
347
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
348
|
+
yield ((_a = this.db) === null || _a === void 0 ? void 0 : _a.destroy());
|
|
349
|
+
});
|
|
350
|
+
}
|
|
345
351
|
}
|
|
346
352
|
exports.Blockchain = Blockchain;
|
|
347
353
|
_Blockchain_txpool = new WeakMap(), _Blockchain_inherentProvider = new WeakMap(), _Blockchain_head = new WeakMap(), _Blockchain_blocksByNumber = new WeakMap(), _Blockchain_blocksByHash = new WeakMap(), _Blockchain_loadingBlocks = new WeakMap(), _Blockchain_maxMemoryBlockCount = new WeakMap(), _Blockchain_instances = new WeakSet(), _Blockchain_registerBlock = function _Blockchain_registerBlock(block) {
|
package/lib/db/browser.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { DataSource } from 'typeorm';
|
|
2
|
-
export declare const openDb: (
|
|
2
|
+
export declare const openDb: (location: string) => Promise<DataSource>;
|
package/lib/db/browser.js
CHANGED
|
@@ -40,14 +40,14 @@ const typeorm_1 = require("typeorm");
|
|
|
40
40
|
const localforage_1 = require("localforage");
|
|
41
41
|
const sql_js_1 = __importDefault(require("sql.js"));
|
|
42
42
|
const entities = __importStar(require("./entities"));
|
|
43
|
-
const
|
|
43
|
+
const sql_wasm_1 = require("./sql-wasm");
|
|
44
|
+
const openDb = (location) => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
45
|
if (!globalThis.localforage) {
|
|
45
46
|
globalThis.localforage = (0, localforage_1.createInstance)({ name: 'chopsticks' });
|
|
46
47
|
}
|
|
47
|
-
const wasmBinary = yield fetch(sqlWasmUrl).then((response) => response.arrayBuffer());
|
|
48
48
|
const source = new typeorm_1.DataSource({
|
|
49
49
|
type: 'sqljs',
|
|
50
|
-
location
|
|
50
|
+
location,
|
|
51
51
|
entities: Object.values(entities),
|
|
52
52
|
synchronize: true,
|
|
53
53
|
autoSave: true,
|
|
@@ -55,7 +55,7 @@ const openDb = (sqlWasmUrl) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
55
55
|
useLocalForage: true,
|
|
56
56
|
driver: sql_js_1.default,
|
|
57
57
|
sqlJsConfig: {
|
|
58
|
-
wasmBinary,
|
|
58
|
+
wasmBinary: sql_wasm_1.SQL_WASM_BYTES,
|
|
59
59
|
},
|
|
60
60
|
});
|
|
61
61
|
yield source.initialize();
|
package/lib/db/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const openDb: (dbPath: string
|
|
1
|
+
export declare const openDb: (dbPath: string) => Promise<import("typeorm").DataSource>;
|
package/lib/db/index.js
CHANGED
|
@@ -34,11 +34,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
35
|
exports.openDb = void 0;
|
|
36
36
|
const openDb = (dbPath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
-
if (
|
|
38
|
-
return (yield Promise.resolve().then(() => __importStar(require('./
|
|
37
|
+
if (typeof window === 'undefined') {
|
|
38
|
+
return (yield Promise.resolve().then(() => __importStar(require('./node')))).openDb(dbPath);
|
|
39
39
|
}
|
|
40
40
|
else {
|
|
41
|
-
return (yield Promise.resolve().then(() => __importStar(require('./
|
|
41
|
+
return (yield Promise.resolve().then(() => __importStar(require('./browser')))).openDb(dbPath);
|
|
42
42
|
}
|
|
43
43
|
});
|
|
44
44
|
exports.openDb = openDb;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SQL_WASM_BYTES: Uint8Array;
|