@ocap/indexdb 1.21.3 → 1.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/util.js +29 -0
- package/package.json +3 -3
package/lib/util.js
CHANGED
@@ -101,11 +101,33 @@ const createIndexedToken = (x) => ({
|
|
101
101
|
totalSupply: x.totalSupply,
|
102
102
|
initialSupply: x.initialSupply,
|
103
103
|
foreignToken: x.foreignToken,
|
104
|
+
tokenFactoryAddress: x.tokenFactoryAddress,
|
104
105
|
data: x.data,
|
105
106
|
genesisTime: x.context.genesisTime,
|
106
107
|
renaissanceTime: x.context.renaissanceTime,
|
107
108
|
});
|
108
109
|
|
110
|
+
const createIndexedTokenFactory = (tokenFactory, context) => {
|
111
|
+
return {
|
112
|
+
...pick(tokenFactory, [
|
113
|
+
'address',
|
114
|
+
'owner',
|
115
|
+
'tokenAddress',
|
116
|
+
'reserveAddress',
|
117
|
+
'curve',
|
118
|
+
'feeRate',
|
119
|
+
'currentSupply',
|
120
|
+
'reserveBalance',
|
121
|
+
'status',
|
122
|
+
'data',
|
123
|
+
]),
|
124
|
+
token: formatTokenMeta({ address: tokenFactory.tokenAddress }, [context.itx.token]),
|
125
|
+
reserveToken: formatTokenMeta({ address: tokenFactory.reserveAddress }, [context.config.token]),
|
126
|
+
genesisTime: tokenFactory.context.genesisTime,
|
127
|
+
renaissanceTime: tokenFactory.context.renaissanceTime,
|
128
|
+
};
|
129
|
+
};
|
130
|
+
|
109
131
|
const createIndexedFactory = (factory, context) => {
|
110
132
|
if (context.factoryTokens && context.factoryTokens.length > 0) {
|
111
133
|
factory.input.tokens = factory.input.tokens.map((token) => formatTokenMeta(token, context.tokenStates));
|
@@ -145,6 +167,7 @@ const createIndexedTransaction = async (tx, ctx, indexdb) => {
|
|
145
167
|
tx.stakes = [];
|
146
168
|
tx.rollups = [];
|
147
169
|
tx.delegations = [];
|
170
|
+
tx.tokenFactories = [];
|
148
171
|
|
149
172
|
tx.valid = tx.code === 'OK';
|
150
173
|
|
@@ -233,6 +256,11 @@ const createIndexedTransaction = async (tx, ctx, indexdb) => {
|
|
233
256
|
tx.rollups.push(ctx.rollupState.address);
|
234
257
|
}
|
235
258
|
|
259
|
+
// token factories
|
260
|
+
if (ctx.tokenFactoryState) {
|
261
|
+
tx.tokenFactories.push(ctx.tokenFactoryState.address);
|
262
|
+
}
|
263
|
+
|
236
264
|
const pickedFields = ['address', 'symbol', 'decimal', 'unit'];
|
237
265
|
if (Array.isArray(ctx.tokenStates)) {
|
238
266
|
tx.tokenSymbols = ctx.tokenStates.map((t) => pick(t, pickedFields));
|
@@ -581,6 +609,7 @@ module.exports = {
|
|
581
609
|
createIndexedAccount,
|
582
610
|
createIndexedAsset,
|
583
611
|
createIndexedFactory,
|
612
|
+
createIndexedTokenFactory,
|
584
613
|
createIndexedDelegation,
|
585
614
|
createIndexedToken,
|
586
615
|
createIndexedTransaction,
|
package/package.json
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
"publishConfig": {
|
4
4
|
"access": "public"
|
5
5
|
},
|
6
|
-
"version": "1.
|
6
|
+
"version": "1.22.0",
|
7
7
|
"description": "Defines the basic interface for OCAP IndexDB",
|
8
8
|
"main": "lib/main.js",
|
9
9
|
"files": [
|
@@ -21,8 +21,8 @@
|
|
21
21
|
"dependencies": {
|
22
22
|
"kareem": "^2.4.1",
|
23
23
|
"lodash": "^4.17.21",
|
24
|
-
"@ocap/state": "1.
|
25
|
-
"@ocap/util": "1.
|
24
|
+
"@ocap/state": "1.22.0",
|
25
|
+
"@ocap/util": "1.22.0"
|
26
26
|
},
|
27
27
|
"scripts": {
|
28
28
|
"lint": "eslint tests lib",
|