@talismn/balances 0.1.19 → 0.2.1
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/CHANGELOG.md +10 -0
- package/dist/BalanceModule.js +14 -39
- package/dist/TalismanBalancesDatabase.js +4 -7
- package/dist/helpers.js +6 -21
- package/dist/index.js +4 -20
- package/dist/log.js +2 -7
- package/dist/plugins.js +1 -2
- package/dist/types/addresses.js +1 -2
- package/dist/types/balances.js +238 -296
- package/dist/types/balancetypes.js +5 -11
- package/dist/types/index.js +4 -20
- package/dist/types/subscriptions.js +1 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/dist/BalanceModule.js
CHANGED
@@ -1,50 +1,25 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
-
});
|
10
|
-
};
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
-
exports.DefaultBalanceModule = void 0;
|
13
1
|
// TODO: Document default balances module purpose/usage
|
14
|
-
const DefaultBalanceModule = (type) => ({
|
2
|
+
export const DefaultBalanceModule = (type) => ({
|
15
3
|
get type() {
|
16
4
|
return type;
|
17
5
|
},
|
18
|
-
fetchSubstrateChainMeta() {
|
19
|
-
return
|
20
|
-
return null;
|
21
|
-
});
|
6
|
+
async fetchSubstrateChainMeta() {
|
7
|
+
return null;
|
22
8
|
},
|
23
|
-
fetchEvmChainMeta() {
|
24
|
-
return
|
25
|
-
return null;
|
26
|
-
});
|
9
|
+
async fetchEvmChainMeta() {
|
10
|
+
return null;
|
27
11
|
},
|
28
|
-
fetchSubstrateChainTokens() {
|
29
|
-
return
|
30
|
-
return Promise.resolve({});
|
31
|
-
});
|
12
|
+
async fetchSubstrateChainTokens() {
|
13
|
+
return Promise.resolve({});
|
32
14
|
},
|
33
|
-
fetchEvmChainTokens() {
|
34
|
-
return
|
35
|
-
return Promise.resolve({});
|
36
|
-
});
|
15
|
+
async fetchEvmChainTokens() {
|
16
|
+
return Promise.resolve({});
|
37
17
|
},
|
38
|
-
subscribeBalances(_chainConnectors, _chaindataProvider, _addressesByToken, callback) {
|
39
|
-
|
40
|
-
|
41
|
-
return () => { };
|
42
|
-
});
|
18
|
+
async subscribeBalances(_chainConnectors, _chaindataProvider, _addressesByToken, callback) {
|
19
|
+
callback(new Error("Balance subscriptions are not implemented in this module."));
|
20
|
+
return () => { };
|
43
21
|
},
|
44
|
-
fetchBalances() {
|
45
|
-
|
46
|
-
throw new Error("Balance fetching is not implemented in this module.");
|
47
|
-
});
|
22
|
+
async fetchBalances() {
|
23
|
+
throw new Error("Balance fetching is not implemented in this module.");
|
48
24
|
},
|
49
25
|
});
|
50
|
-
exports.DefaultBalanceModule = DefaultBalanceModule;
|
@@ -1,8 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
const dexie_1 = require("dexie");
|
5
|
-
class TalismanBalancesDatabase extends dexie_1.Dexie {
|
1
|
+
import { Dexie } from "dexie";
|
2
|
+
export class TalismanBalancesDatabase extends Dexie {
|
3
|
+
balances;
|
6
4
|
constructor() {
|
7
5
|
super("TalismanBalances");
|
8
6
|
// https://dexie.org/docs/Tutorial/Design#database-versioning
|
@@ -18,5 +16,4 @@ class TalismanBalancesDatabase extends dexie_1.Dexie {
|
|
18
16
|
// this.on("ready", async () => {})
|
19
17
|
}
|
20
18
|
}
|
21
|
-
|
22
|
-
exports.db = new TalismanBalancesDatabase();
|
19
|
+
export const db = new TalismanBalancesDatabase();
|
package/dist/helpers.js
CHANGED
@@ -1,22 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
-
});
|
10
|
-
};
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
-
exports.balances = void 0;
|
13
|
-
function balances(balanceModule, chainConnectors, chaindataProvider, addressesByToken, callback) {
|
14
|
-
return __awaiter(this, void 0, void 0, function* () {
|
15
|
-
// subscription request
|
16
|
-
if (callback !== undefined)
|
17
|
-
return yield balanceModule.subscribeBalances(chainConnectors, chaindataProvider, addressesByToken, callback);
|
18
|
-
// one-off request
|
19
|
-
return yield balanceModule.fetchBalances(chainConnectors, chaindataProvider, addressesByToken);
|
20
|
-
});
|
1
|
+
export async function balances(balanceModule, chainConnectors, chaindataProvider, addressesByToken, callback) {
|
2
|
+
// subscription request
|
3
|
+
if (callback !== undefined)
|
4
|
+
return await balanceModule.subscribeBalances(chainConnectors, chaindataProvider, addressesByToken, callback);
|
5
|
+
// one-off request
|
6
|
+
return await balanceModule.fetchBalances(chainConnectors, chaindataProvider, addressesByToken);
|
21
7
|
}
|
22
|
-
exports.balances = balances;
|
package/dist/index.js
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
"use strict";
|
2
1
|
//
|
3
2
|
// NOTE: Do not export `./plugins` from here!
|
4
3
|
// Doing so will introduce a circular dependency!
|
@@ -10,22 +9,7 @@
|
|
10
9
|
//
|
11
10
|
// import { PluginBalanceTypes } from '@talismn/balances'
|
12
11
|
//
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
18
|
-
}
|
19
|
-
Object.defineProperty(o, k2, desc);
|
20
|
-
}) : (function(o, m, k, k2) {
|
21
|
-
if (k2 === undefined) k2 = k;
|
22
|
-
o[k2] = m[k];
|
23
|
-
}));
|
24
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
25
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
26
|
-
};
|
27
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
28
|
-
__exportStar(require("./BalanceModule"), exports);
|
29
|
-
__exportStar(require("./TalismanBalancesDatabase"), exports);
|
30
|
-
__exportStar(require("./helpers"), exports);
|
31
|
-
__exportStar(require("./types"), exports);
|
12
|
+
export * from "./BalanceModule";
|
13
|
+
export * from "./TalismanBalancesDatabase";
|
14
|
+
export * from "./helpers";
|
15
|
+
export * from "./types";
|
package/dist/log.js
CHANGED
@@ -1,10 +1,5 @@
|
|
1
|
-
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
const anylogger_1 = __importDefault(require("anylogger"));
|
1
|
+
import anylogger from "anylogger";
|
7
2
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
8
3
|
const { name } = require("../package.json");
|
9
4
|
// import { name } from "../package.json"
|
10
|
-
|
5
|
+
export default anylogger(name);
|
package/dist/plugins.js
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
1
|
+
export {};
|
package/dist/types/addresses.js
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
1
|
+
export {};
|
package/dist/types/balances.js
CHANGED
@@ -1,144 +1,26 @@
|
|
1
|
-
"use strict";
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7
6
|
};
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
};
|
14
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
15
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
16
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
17
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
18
|
-
};
|
19
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
20
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
21
|
-
};
|
22
|
-
var _Balances_balances, _a, _Balance_storage, _Balance_db, _Balance_format, _BalanceFormatter_planck, _BalanceFormatter_decimals, _BalanceFormatter_fiatRatios, _FiatSumBalancesFormatter_balances, _FiatSumBalancesFormatter_currency, _FiatSumBalancesFormatter_sum, _SumBalancesFormatter_balances;
|
23
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
24
|
-
exports.SumBalancesFormatter = exports.FiatSumBalancesFormatter = exports.BalanceFormatter = exports.Balance = exports.Balances = void 0;
|
25
|
-
const util_1 = require("@talismn/util");
|
26
|
-
const memoize_1 = __importDefault(require("lodash/memoize"));
|
27
|
-
const typescript_memoize_1 = require("typescript-memoize");
|
28
|
-
const log_1 = __importDefault(require("../log"));
|
29
|
-
const balancetypes_1 = require("./balancetypes");
|
7
|
+
import { BigMath, isArrayOf, planckToTokens } from "@talismn/util";
|
8
|
+
import memoize from "lodash/memoize";
|
9
|
+
import { Memoize } from "typescript-memoize";
|
10
|
+
import log from "../log";
|
11
|
+
import { excludeFromFeePayableLocks, excludeFromTransferableAmount, includeInTotalExtraAmount, } from "./balancetypes";
|
30
12
|
/**
|
31
13
|
* A collection of balances.
|
32
14
|
*/
|
33
|
-
class Balances {
|
15
|
+
export class Balances {
|
16
|
+
//
|
17
|
+
// Properties
|
18
|
+
//
|
19
|
+
#balances = {};
|
34
20
|
//
|
35
21
|
// Methods
|
36
22
|
//
|
37
23
|
constructor(balances, hydrate) {
|
38
|
-
//
|
39
|
-
// Properties
|
40
|
-
//
|
41
|
-
_Balances_balances.set(this, {}
|
42
|
-
//
|
43
|
-
// Methods
|
44
|
-
//
|
45
|
-
);
|
46
|
-
/**
|
47
|
-
* Calling toJSON on a collection of balances will return the underlying BalanceJsonList.
|
48
|
-
*/
|
49
|
-
this.toJSON = () => Object.fromEntries(Object.entries(__classPrivateFieldGet(this, _Balances_balances, "f"))
|
50
|
-
.map(([id, balance]) => {
|
51
|
-
try {
|
52
|
-
return [id, balance.toJSON()];
|
53
|
-
}
|
54
|
-
catch (error) {
|
55
|
-
log_1.default.error("Failed to convert balance to JSON", error, { id, balance });
|
56
|
-
return null;
|
57
|
-
}
|
58
|
-
})
|
59
|
-
.filter(Array.isArray));
|
60
|
-
/**
|
61
|
-
* Allows the collection to be iterated over.
|
62
|
-
*
|
63
|
-
* @example
|
64
|
-
* [...balances].forEach(balance => { // do something // })
|
65
|
-
*
|
66
|
-
* @example
|
67
|
-
* for (const balance of balances) {
|
68
|
-
* // do something
|
69
|
-
* }
|
70
|
-
*/
|
71
|
-
this[_a] = () =>
|
72
|
-
// Create an array of the balances in this collection and return the result of its iterator.
|
73
|
-
Object.values(__classPrivateFieldGet(this, _Balances_balances, "f"))[Symbol.iterator]();
|
74
|
-
/**
|
75
|
-
* Hydrates all balances in this collection.
|
76
|
-
*
|
77
|
-
* @param sources - The sources to hydrate from.
|
78
|
-
*/
|
79
|
-
this.hydrate = (sources) => {
|
80
|
-
Object.values(__classPrivateFieldGet(this, _Balances_balances, "f")).map((balance) => balance.hydrate(sources));
|
81
|
-
};
|
82
|
-
/**
|
83
|
-
* Retrieve a balance from this collection by id.
|
84
|
-
*
|
85
|
-
* @param id - The id of the balance to fetch.
|
86
|
-
* @returns The balance if one exists, or none.
|
87
|
-
*/
|
88
|
-
this.get = (id) => __classPrivateFieldGet(this, _Balances_balances, "f")[id] || null;
|
89
|
-
/**
|
90
|
-
* Retrieve balances from this collection by search query.
|
91
|
-
*
|
92
|
-
* @param query - The search query.
|
93
|
-
* @returns All balances which match the query.
|
94
|
-
*/
|
95
|
-
this.find = (query) => {
|
96
|
-
// construct filter
|
97
|
-
const orQueries = (Array.isArray(query) ? query : [query]).map((query) => typeof query === "function" ? query : Object.entries(query));
|
98
|
-
// filter balances
|
99
|
-
const filter = (balance) => orQueries.some((query) => typeof query === "function"
|
100
|
-
? query(balance)
|
101
|
-
: query.every(([key, value]) => balance[key] === value));
|
102
|
-
// return filter matches
|
103
|
-
return new Balances([...this].filter(filter));
|
104
|
-
};
|
105
|
-
/**
|
106
|
-
* Add some balances to this collection.
|
107
|
-
* Added balances take priority over existing balances.
|
108
|
-
* The aggregation of the two collections is returned.
|
109
|
-
* The original collection is not mutated.
|
110
|
-
*
|
111
|
-
* @param balances - Either a balance or collection of balances to add.
|
112
|
-
* @returns The new collection of balances.
|
113
|
-
*/
|
114
|
-
this.add = (balances) => {
|
115
|
-
// handle single balance
|
116
|
-
if (balances instanceof Balance)
|
117
|
-
return this.add(new Balances(balances));
|
118
|
-
// merge balances
|
119
|
-
const mergedBalances = Object.assign({}, __classPrivateFieldGet(this, _Balances_balances, "f"));
|
120
|
-
[...balances].forEach((balance) => (mergedBalances[balance.id] = balance));
|
121
|
-
// return new balances
|
122
|
-
return new Balances(Object.values(mergedBalances));
|
123
|
-
};
|
124
|
-
/**
|
125
|
-
* Remove balances from this collection by id.
|
126
|
-
* A new collection without these balances is returned.
|
127
|
-
* The original collection is not mutated.
|
128
|
-
*
|
129
|
-
* @param ids - The id(s) of the balances to remove.
|
130
|
-
* @returns The new collection of balances.
|
131
|
-
*/
|
132
|
-
this.remove = (ids) => {
|
133
|
-
// handle single id
|
134
|
-
if (!Array.isArray(ids))
|
135
|
-
return this.remove([ids]);
|
136
|
-
// merge balances
|
137
|
-
const removedBalances = Object.assign({}, __classPrivateFieldGet(this, _Balances_balances, "f"));
|
138
|
-
ids.forEach((id) => delete removedBalances[id]);
|
139
|
-
// return new balances
|
140
|
-
return new Balances(Object.values(removedBalances));
|
141
|
-
};
|
142
24
|
// handle Balances (convert to Balance[])
|
143
25
|
if (balances instanceof Balances)
|
144
26
|
return new Balances([...balances], hydrate);
|
@@ -152,13 +34,109 @@ class Balances {
|
|
152
34
|
if (balances.length === 0)
|
153
35
|
return this;
|
154
36
|
// handle BalanceJson[]
|
155
|
-
if (!
|
37
|
+
if (!isArrayOf(balances, Balance))
|
156
38
|
return new Balances(balances.map((storage) => new Balance(storage)), hydrate);
|
157
39
|
// handle Balance[]
|
158
|
-
|
40
|
+
this.#balances = Object.fromEntries(balances.map((balance) => [balance.id, balance]));
|
159
41
|
if (hydrate !== undefined)
|
160
42
|
this.hydrate(hydrate);
|
161
43
|
}
|
44
|
+
/**
|
45
|
+
* Calling toJSON on a collection of balances will return the underlying BalanceJsonList.
|
46
|
+
*/
|
47
|
+
toJSON = () => Object.fromEntries(Object.entries(this.#balances)
|
48
|
+
.map(([id, balance]) => {
|
49
|
+
try {
|
50
|
+
return [id, balance.toJSON()];
|
51
|
+
}
|
52
|
+
catch (error) {
|
53
|
+
log.error("Failed to convert balance to JSON", error, { id, balance });
|
54
|
+
return null;
|
55
|
+
}
|
56
|
+
})
|
57
|
+
.filter(Array.isArray));
|
58
|
+
/**
|
59
|
+
* Allows the collection to be iterated over.
|
60
|
+
*
|
61
|
+
* @example
|
62
|
+
* [...balances].forEach(balance => { // do something // })
|
63
|
+
*
|
64
|
+
* @example
|
65
|
+
* for (const balance of balances) {
|
66
|
+
* // do something
|
67
|
+
* }
|
68
|
+
*/
|
69
|
+
[Symbol.iterator] = () =>
|
70
|
+
// Create an array of the balances in this collection and return the result of its iterator.
|
71
|
+
Object.values(this.#balances)[Symbol.iterator]();
|
72
|
+
/**
|
73
|
+
* Hydrates all balances in this collection.
|
74
|
+
*
|
75
|
+
* @param sources - The sources to hydrate from.
|
76
|
+
*/
|
77
|
+
hydrate = (sources) => {
|
78
|
+
Object.values(this.#balances).map((balance) => balance.hydrate(sources));
|
79
|
+
};
|
80
|
+
/**
|
81
|
+
* Retrieve a balance from this collection by id.
|
82
|
+
*
|
83
|
+
* @param id - The id of the balance to fetch.
|
84
|
+
* @returns The balance if one exists, or none.
|
85
|
+
*/
|
86
|
+
get = (id) => this.#balances[id] || null;
|
87
|
+
/**
|
88
|
+
* Retrieve balances from this collection by search query.
|
89
|
+
*
|
90
|
+
* @param query - The search query.
|
91
|
+
* @returns All balances which match the query.
|
92
|
+
*/
|
93
|
+
find = (query) => {
|
94
|
+
// construct filter
|
95
|
+
const orQueries = (Array.isArray(query) ? query : [query]).map((query) => typeof query === "function" ? query : Object.entries(query));
|
96
|
+
// filter balances
|
97
|
+
const filter = (balance) => orQueries.some((query) => typeof query === "function"
|
98
|
+
? query(balance)
|
99
|
+
: query.every(([key, value]) => balance[key] === value));
|
100
|
+
// return filter matches
|
101
|
+
return new Balances([...this].filter(filter));
|
102
|
+
};
|
103
|
+
/**
|
104
|
+
* Add some balances to this collection.
|
105
|
+
* Added balances take priority over existing balances.
|
106
|
+
* The aggregation of the two collections is returned.
|
107
|
+
* The original collection is not mutated.
|
108
|
+
*
|
109
|
+
* @param balances - Either a balance or collection of balances to add.
|
110
|
+
* @returns The new collection of balances.
|
111
|
+
*/
|
112
|
+
add = (balances) => {
|
113
|
+
// handle single balance
|
114
|
+
if (balances instanceof Balance)
|
115
|
+
return this.add(new Balances(balances));
|
116
|
+
// merge balances
|
117
|
+
const mergedBalances = { ...this.#balances };
|
118
|
+
[...balances].forEach((balance) => (mergedBalances[balance.id] = balance));
|
119
|
+
// return new balances
|
120
|
+
return new Balances(Object.values(mergedBalances));
|
121
|
+
};
|
122
|
+
/**
|
123
|
+
* Remove balances from this collection by id.
|
124
|
+
* A new collection without these balances is returned.
|
125
|
+
* The original collection is not mutated.
|
126
|
+
*
|
127
|
+
* @param ids - The id(s) of the balances to remove.
|
128
|
+
* @returns The new collection of balances.
|
129
|
+
*/
|
130
|
+
remove = (ids) => {
|
131
|
+
// handle single id
|
132
|
+
if (!Array.isArray(ids))
|
133
|
+
return this.remove([ids]);
|
134
|
+
// merge balances
|
135
|
+
const removedBalances = { ...this.#balances };
|
136
|
+
ids.forEach((id) => delete removedBalances[id]);
|
137
|
+
// return new balances
|
138
|
+
return new Balances(Object.values(removedBalances));
|
139
|
+
};
|
162
140
|
// TODO: Add some more useful aggregator methods
|
163
141
|
/**
|
164
142
|
* Get an array of balances in this collection, sorted by chain sortIndex.
|
@@ -166,11 +144,8 @@ class Balances {
|
|
166
144
|
* @returns A sorted array of the balances in this collection.
|
167
145
|
*/
|
168
146
|
get sorted() {
|
169
|
-
return [...this].sort((a, b) =>
|
170
|
-
|
171
|
-
return (((_b = (a.chain || a.evmNetwork)) === null || _b === void 0 ? void 0 : _b.sortIndex) || Number.MAX_SAFE_INTEGER) -
|
172
|
-
(((_c = (b.chain || b.evmNetwork)) === null || _c === void 0 ? void 0 : _c.sortIndex) || Number.MAX_SAFE_INTEGER);
|
173
|
-
});
|
147
|
+
return [...this].sort((a, b) => ((a.chain || a.evmNetwork)?.sortIndex || Number.MAX_SAFE_INTEGER) -
|
148
|
+
((b.chain || b.evmNetwork)?.sortIndex || Number.MAX_SAFE_INTEGER));
|
174
149
|
}
|
175
150
|
/**
|
176
151
|
* Get the number of balances in this collection.
|
@@ -192,114 +167,96 @@ class Balances {
|
|
192
167
|
return new SumBalancesFormatter(this);
|
193
168
|
}
|
194
169
|
}
|
195
|
-
_Balances_balances = new WeakMap(), _a = Symbol.iterator;
|
196
170
|
__decorate([
|
197
|
-
|
171
|
+
Memoize()
|
198
172
|
], Balances.prototype, "sorted", null);
|
199
173
|
__decorate([
|
200
|
-
|
174
|
+
Memoize()
|
201
175
|
], Balances.prototype, "count", null);
|
202
176
|
__decorate([
|
203
|
-
|
177
|
+
Memoize()
|
204
178
|
], Balances.prototype, "sum", null);
|
205
|
-
exports.Balances = Balances;
|
206
179
|
/**
|
207
180
|
* An individual balance.
|
208
181
|
*/
|
209
|
-
class Balance {
|
182
|
+
export class Balance {
|
183
|
+
//
|
184
|
+
// Properties
|
185
|
+
//
|
186
|
+
/** The underlying data for this balance */
|
187
|
+
#storage;
|
188
|
+
#db = null;
|
210
189
|
//
|
211
190
|
// Methods
|
212
191
|
//
|
213
192
|
constructor(storage, hydrate) {
|
214
|
-
|
215
|
-
|
216
|
-
//
|
217
|
-
/** The underlying data for this balance */
|
218
|
-
_Balance_storage.set(this, void 0);
|
219
|
-
_Balance_db.set(this, null
|
220
|
-
//
|
221
|
-
// Methods
|
222
|
-
//
|
223
|
-
);
|
224
|
-
this.toJSON = () => __classPrivateFieldGet(this, _Balance_storage, "f");
|
225
|
-
this.isSource = (source) => __classPrivateFieldGet(this, _Balance_storage, "f").source === source;
|
226
|
-
// // TODO: Fix this method, the types don't work with our plugin architecture.
|
227
|
-
// // Specifically, the `BalanceJson` type is compiled down to `IBalance` in the following way:
|
228
|
-
// //
|
229
|
-
// // toJSON: () => BalanceJson // works
|
230
|
-
// // isSource: (source: BalanceSource) => boolean // works
|
231
|
-
// // asSource: <P extends string>(source: P) => NarrowBalanceType<IBalance, P> | null // Doesn't work! IBalance should just be BalanceJson!
|
232
|
-
// //
|
233
|
-
// // `IBalance` won't match the type of `BalanceSource` after `PluginBalanceTypes` has been extended by balance plugins.
|
234
|
-
// // As a result, typescript will think that the returned #storage is not a BalanceJson.
|
235
|
-
// asSource = <P extends BalanceSource>(source: P): NarrowBalanceType<BalanceJson, P> | null => {
|
236
|
-
// if (this.#storage.source === source) return this.#storage as NarrowBalanceType<BalanceJson, P>
|
237
|
-
// return null
|
238
|
-
// }
|
239
|
-
this.hydrate = (hydrate) => {
|
240
|
-
if (hydrate !== undefined)
|
241
|
-
__classPrivateFieldSet(this, _Balance_db, hydrate, "f");
|
242
|
-
};
|
243
|
-
_Balance_format.set(this, (balance) => {
|
244
|
-
var _b;
|
245
|
-
return new BalanceFormatter(typeof balance === "bigint" ? balance.toString() : balance, this.decimals || undefined, ((_b = __classPrivateFieldGet(this, _Balance_db, "f")) === null || _b === void 0 ? void 0 : _b.tokenRates) && __classPrivateFieldGet(this, _Balance_db, "f").tokenRates[this.tokenId]);
|
246
|
-
}
|
247
|
-
//
|
248
|
-
// Accessors
|
249
|
-
//
|
250
|
-
);
|
251
|
-
__classPrivateFieldSet(this, _Balance_format, (0, memoize_1.default)(__classPrivateFieldGet(this, _Balance_format, "f")), "f");
|
252
|
-
__classPrivateFieldSet(this, _Balance_storage, storage, "f");
|
193
|
+
this.#format = memoize(this.#format);
|
194
|
+
this.#storage = storage;
|
253
195
|
if (hydrate !== undefined)
|
254
196
|
this.hydrate(hydrate);
|
255
197
|
}
|
198
|
+
toJSON = () => this.#storage;
|
199
|
+
isSource = (source) => this.#storage.source === source;
|
200
|
+
// // TODO: Fix this method, the types don't work with our plugin architecture.
|
201
|
+
// // Specifically, the `BalanceJson` type is compiled down to `IBalance` in the following way:
|
202
|
+
// //
|
203
|
+
// // toJSON: () => BalanceJson // works
|
204
|
+
// // isSource: (source: BalanceSource) => boolean // works
|
205
|
+
// // asSource: <P extends string>(source: P) => NarrowBalanceType<IBalance, P> | null // Doesn't work! IBalance should just be BalanceJson!
|
206
|
+
// //
|
207
|
+
// // `IBalance` won't match the type of `BalanceSource` after `PluginBalanceTypes` has been extended by balance plugins.
|
208
|
+
// // As a result, typescript will think that the returned #storage is not a BalanceJson.
|
209
|
+
// asSource = <P extends BalanceSource>(source: P): NarrowBalanceType<BalanceJson, P> | null => {
|
210
|
+
// if (this.#storage.source === source) return this.#storage as NarrowBalanceType<BalanceJson, P>
|
211
|
+
// return null
|
212
|
+
// }
|
213
|
+
hydrate = (hydrate) => {
|
214
|
+
if (hydrate !== undefined)
|
215
|
+
this.#db = hydrate;
|
216
|
+
};
|
217
|
+
#format = (balance) => new BalanceFormatter(typeof balance === "bigint" ? balance.toString() : balance, this.decimals || undefined, this.#db?.tokenRates && this.#db.tokenRates[this.tokenId]);
|
256
218
|
//
|
257
219
|
// Accessors
|
258
220
|
//
|
259
221
|
get id() {
|
260
|
-
const { source, address, chainId, evmNetworkId, tokenId } =
|
222
|
+
const { source, address, chainId, evmNetworkId, tokenId } = this.#storage;
|
261
223
|
const locationId = chainId !== undefined ? chainId : evmNetworkId;
|
262
224
|
return `${source}-${address}-${locationId}-${tokenId}`;
|
263
225
|
}
|
264
226
|
get source() {
|
265
|
-
return
|
227
|
+
return this.#storage.source;
|
266
228
|
}
|
267
229
|
get status() {
|
268
|
-
return
|
230
|
+
return this.#storage.status;
|
269
231
|
}
|
270
232
|
get address() {
|
271
|
-
return
|
233
|
+
return this.#storage.address;
|
272
234
|
}
|
273
235
|
get chainId() {
|
274
|
-
return
|
236
|
+
return this.#storage.chainId;
|
275
237
|
}
|
276
238
|
get chain() {
|
277
|
-
|
278
|
-
return (((_b = __classPrivateFieldGet(this, _Balance_db, "f")) === null || _b === void 0 ? void 0 : _b.chains) && this.chainId && ((_c = __classPrivateFieldGet(this, _Balance_db, "f")) === null || _c === void 0 ? void 0 : _c.chains[this.chainId])) || null;
|
239
|
+
return (this.#db?.chains && this.chainId && this.#db?.chains[this.chainId]) || null;
|
279
240
|
}
|
280
241
|
get evmNetworkId() {
|
281
|
-
return
|
242
|
+
return this.#storage.evmNetworkId;
|
282
243
|
}
|
283
244
|
get evmNetwork() {
|
284
|
-
var _b, _c;
|
285
245
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
286
|
-
return (
|
246
|
+
return (this.#db?.evmNetworks && this.#db?.evmNetworks[this.evmNetworkId]) || null;
|
287
247
|
}
|
288
248
|
get tokenId() {
|
289
|
-
return
|
249
|
+
return this.#storage.tokenId;
|
290
250
|
}
|
291
251
|
get token() {
|
292
|
-
var _b, _c;
|
293
252
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
294
|
-
return (
|
253
|
+
return (this.#db?.tokens && this.#db?.tokens[this.tokenId]) || null;
|
295
254
|
}
|
296
255
|
get decimals() {
|
297
|
-
|
298
|
-
return ((_b = this.token) === null || _b === void 0 ? void 0 : _b.decimals) || null;
|
256
|
+
return this.token?.decimals || null;
|
299
257
|
}
|
300
258
|
get rates() {
|
301
|
-
|
302
|
-
return (((_b = __classPrivateFieldGet(this, _Balance_db, "f")) === null || _b === void 0 ? void 0 : _b.tokenRates) && __classPrivateFieldGet(this, _Balance_db, "f").tokenRates[this.tokenId]) || null;
|
259
|
+
return (this.#db?.tokenRates && this.#db.tokenRates[this.tokenId]) || null;
|
303
260
|
}
|
304
261
|
/**
|
305
262
|
* The total balance of this token.
|
@@ -307,41 +264,38 @@ class Balance {
|
|
307
264
|
* The balance will be reaped if this goes below the existential deposit.
|
308
265
|
*/
|
309
266
|
get total() {
|
310
|
-
const extra =
|
311
|
-
return
|
267
|
+
const extra = includeInTotalExtraAmount(this.#storage.extra);
|
268
|
+
return this.#format(this.free.planck + this.reserved.planck + extra);
|
312
269
|
}
|
313
270
|
/** The non-reserved balance of this token. Includes the frozen amount. Is included in the total. */
|
314
271
|
get free() {
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
? __classPrivateFieldGet(this, _Balance_storage, "f").free
|
272
|
+
return this.#format(typeof this.#storage.free === "string"
|
273
|
+
? BigInt(this.#storage.free)
|
274
|
+
: Array.isArray(this.#storage.free)
|
275
|
+
? this.#storage.free
|
320
276
|
.map((reserve) => BigInt(reserve.amount))
|
321
277
|
.reduce((a, b) => a + b, BigInt("0"))
|
322
|
-
: BigInt(
|
278
|
+
: BigInt(this.#storage.free?.amount || "0"));
|
323
279
|
}
|
324
280
|
/** The reserved balance of this token. Is included in the total. */
|
325
281
|
get reserved() {
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
? __classPrivateFieldGet(this, _Balance_storage, "f").reserves
|
282
|
+
return this.#format(typeof this.#storage.reserves === "string"
|
283
|
+
? BigInt(this.#storage.reserves)
|
284
|
+
: Array.isArray(this.#storage.reserves)
|
285
|
+
? this.#storage.reserves
|
331
286
|
.map((reserve) => BigInt(reserve.amount))
|
332
287
|
.reduce((a, b) => a + b, BigInt("0"))
|
333
|
-
: BigInt(
|
288
|
+
: BigInt(this.#storage.reserves?.amount || "0"));
|
334
289
|
}
|
335
290
|
/** The frozen balance of this token. Is included in the free amount. */
|
336
291
|
get locked() {
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
? __classPrivateFieldGet(this, _Balance_storage, "f").locks
|
292
|
+
return this.#format(typeof this.#storage.locks === "string"
|
293
|
+
? BigInt(this.#storage.locks)
|
294
|
+
: Array.isArray(this.#storage.locks)
|
295
|
+
? this.#storage.locks
|
342
296
|
.map((lock) => BigInt(lock.amount))
|
343
|
-
.reduce((a, b) =>
|
344
|
-
: BigInt(
|
297
|
+
.reduce((a, b) => BigMath.max(a, b), BigInt("0"))
|
298
|
+
: BigInt(this.#storage.locks?.amount || "0"));
|
345
299
|
}
|
346
300
|
/** @depreacted - use balance.locked */
|
347
301
|
get frozen() {
|
@@ -350,122 +304,114 @@ class Balance {
|
|
350
304
|
/** The transferable balance of this token. Is generally the free amount - the miscFrozen amount. */
|
351
305
|
get transferable() {
|
352
306
|
// if no locks exist, transferable is equal to the free amount
|
353
|
-
if (!
|
307
|
+
if (!this.#storage.locks)
|
354
308
|
return this.free;
|
355
309
|
// find the largest lock (but ignore any locks which are marked as `includeInTransferable`)
|
356
|
-
const excludeAmount =
|
310
|
+
const excludeAmount = excludeFromTransferableAmount(this.#storage.locks);
|
357
311
|
// subtract the lock from the free amount (but don't go below 0)
|
358
|
-
return
|
312
|
+
return this.#format(BigMath.max(this.free.planck - excludeAmount, BigInt("0")));
|
359
313
|
}
|
360
314
|
/** The feePayable balance of this token. Is generally the free amount - the feeFrozen amount. */
|
361
315
|
get feePayable() {
|
362
316
|
// if no locks exist, feePayable is equal to the free amount
|
363
|
-
if (!
|
317
|
+
if (!this.#storage.locks)
|
364
318
|
return this.free;
|
365
319
|
// find the largest lock which can't be used to pay tx fees
|
366
|
-
const excludeAmount =
|
320
|
+
const excludeAmount = excludeFromFeePayableLocks(this.#storage.locks)
|
367
321
|
.map((lock) => BigInt(lock.amount))
|
368
|
-
.reduce((max, lock) =>
|
322
|
+
.reduce((max, lock) => BigMath.max(max, lock), BigInt("0"));
|
369
323
|
// subtract the lock from the free amount (but don't go below 0)
|
370
|
-
return
|
324
|
+
return this.#format(BigMath.max(this.free.planck - excludeAmount, BigInt("0")));
|
371
325
|
}
|
372
326
|
}
|
373
|
-
_Balance_storage = new WeakMap(), _Balance_db = new WeakMap(), _Balance_format = new WeakMap();
|
374
327
|
__decorate([
|
375
|
-
|
328
|
+
Memoize()
|
376
329
|
], Balance.prototype, "total", null);
|
377
330
|
__decorate([
|
378
|
-
|
331
|
+
Memoize()
|
379
332
|
], Balance.prototype, "free", null);
|
380
333
|
__decorate([
|
381
|
-
|
334
|
+
Memoize()
|
382
335
|
], Balance.prototype, "reserved", null);
|
383
336
|
__decorate([
|
384
|
-
|
337
|
+
Memoize()
|
385
338
|
], Balance.prototype, "locked", null);
|
386
339
|
__decorate([
|
387
|
-
|
340
|
+
Memoize()
|
388
341
|
], Balance.prototype, "frozen", null);
|
389
342
|
__decorate([
|
390
|
-
|
343
|
+
Memoize()
|
391
344
|
], Balance.prototype, "transferable", null);
|
392
345
|
__decorate([
|
393
|
-
|
346
|
+
Memoize()
|
394
347
|
], Balance.prototype, "feePayable", null);
|
395
|
-
|
396
|
-
|
348
|
+
export class BalanceFormatter {
|
349
|
+
#planck;
|
350
|
+
#decimals;
|
351
|
+
#fiatRatios;
|
397
352
|
constructor(planck, decimals, fiatRatios) {
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
this.
|
402
|
-
__classPrivateFieldSet(this, _BalanceFormatter_planck, typeof planck === "bigint" ? planck.toString() : planck !== null && planck !== void 0 ? planck : "0", "f");
|
403
|
-
__classPrivateFieldSet(this, _BalanceFormatter_decimals, decimals || 0, "f");
|
404
|
-
__classPrivateFieldSet(this, _BalanceFormatter_fiatRatios, fiatRatios || null, "f");
|
405
|
-
this.fiat = (0, memoize_1.default)(this.fiat);
|
353
|
+
this.#planck = typeof planck === "bigint" ? planck.toString() : planck ?? "0";
|
354
|
+
this.#decimals = decimals || 0;
|
355
|
+
this.#fiatRatios = fiatRatios || null;
|
356
|
+
this.fiat = memoize(this.fiat);
|
406
357
|
}
|
358
|
+
toJSON = () => this.#planck;
|
407
359
|
get planck() {
|
408
|
-
return BigInt(
|
360
|
+
return BigInt(this.#planck);
|
409
361
|
}
|
410
362
|
get tokens() {
|
411
|
-
return
|
363
|
+
return planckToTokens(this.#planck, this.#decimals);
|
412
364
|
}
|
413
365
|
fiat(currency) {
|
414
|
-
if (!
|
366
|
+
if (!this.#fiatRatios)
|
415
367
|
return null;
|
416
|
-
const ratio =
|
368
|
+
const ratio = this.#fiatRatios[currency];
|
417
369
|
if (!ratio)
|
418
370
|
return null;
|
419
371
|
return parseFloat(this.tokens) * ratio;
|
420
372
|
}
|
421
373
|
}
|
422
|
-
_BalanceFormatter_planck = new WeakMap(), _BalanceFormatter_decimals = new WeakMap(), _BalanceFormatter_fiatRatios = new WeakMap();
|
423
374
|
__decorate([
|
424
|
-
|
375
|
+
Memoize()
|
425
376
|
], BalanceFormatter.prototype, "tokens", null);
|
426
|
-
|
427
|
-
|
377
|
+
export class FiatSumBalancesFormatter {
|
378
|
+
#balances;
|
379
|
+
#currency;
|
428
380
|
constructor(balances, currency) {
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
*/
|
447
|
-
);
|
448
|
-
__classPrivateFieldSet(this, _FiatSumBalancesFormatter_balances, balances, "f");
|
449
|
-
__classPrivateFieldSet(this, _FiatSumBalancesFormatter_currency, currency, "f");
|
450
|
-
__classPrivateFieldSet(this, _FiatSumBalancesFormatter_sum, (0, memoize_1.default)(__classPrivateFieldGet(this, _FiatSumBalancesFormatter_sum, "f")), "f");
|
451
|
-
}
|
381
|
+
this.#balances = balances;
|
382
|
+
this.#currency = currency;
|
383
|
+
this.#sum = memoize(this.#sum);
|
384
|
+
}
|
385
|
+
#sum = (balanceField) => {
|
386
|
+
// a function to get a fiat amount from a balance
|
387
|
+
const fiat = (balance) => balance[balanceField].fiat(this.#currency) || 0;
|
388
|
+
// a function to add two amounts
|
389
|
+
const sum = (a, b) => a + b;
|
390
|
+
return [...this.#balances].reduce((total, balance) => sum(
|
391
|
+
// add the total amount...
|
392
|
+
total,
|
393
|
+
// ...to the fiat amount of each balance
|
394
|
+
fiat(balance)),
|
395
|
+
// start with a total of 0
|
396
|
+
0);
|
397
|
+
};
|
452
398
|
/**
|
453
399
|
* The total balance of these tokens. Includes the free and the reserved amount.
|
454
400
|
*/
|
455
401
|
get total() {
|
456
|
-
return
|
402
|
+
return this.#sum("total");
|
457
403
|
}
|
458
404
|
/** The non-reserved balance of these tokens. Includes the frozen amount. Is included in the total. */
|
459
405
|
get free() {
|
460
|
-
return
|
406
|
+
return this.#sum("free");
|
461
407
|
}
|
462
408
|
/** The reserved balance of these tokens. Is included in the total. */
|
463
409
|
get reserved() {
|
464
|
-
return
|
410
|
+
return this.#sum("reserved");
|
465
411
|
}
|
466
412
|
/** The frozen balance of these tokens. Is included in the free amount. */
|
467
413
|
get locked() {
|
468
|
-
return
|
414
|
+
return this.#sum("locked");
|
469
415
|
}
|
470
416
|
/** @deprecated - use balances.locked */
|
471
417
|
get frozen() {
|
@@ -473,45 +419,41 @@ class FiatSumBalancesFormatter {
|
|
473
419
|
}
|
474
420
|
/** The transferable balance of these tokens. Is generally the free amount - the miscFrozen amount. */
|
475
421
|
get transferable() {
|
476
|
-
return
|
422
|
+
return this.#sum("transferable");
|
477
423
|
}
|
478
424
|
/** The feePayable balance of these tokens. Is generally the free amount - the feeFrozen amount. */
|
479
425
|
get feePayable() {
|
480
|
-
return
|
426
|
+
return this.#sum("feePayable");
|
481
427
|
}
|
482
428
|
}
|
483
|
-
_FiatSumBalancesFormatter_balances = new WeakMap(), _FiatSumBalancesFormatter_currency = new WeakMap(), _FiatSumBalancesFormatter_sum = new WeakMap();
|
484
429
|
__decorate([
|
485
|
-
|
430
|
+
Memoize()
|
486
431
|
], FiatSumBalancesFormatter.prototype, "total", null);
|
487
432
|
__decorate([
|
488
|
-
|
433
|
+
Memoize()
|
489
434
|
], FiatSumBalancesFormatter.prototype, "free", null);
|
490
435
|
__decorate([
|
491
|
-
|
436
|
+
Memoize()
|
492
437
|
], FiatSumBalancesFormatter.prototype, "reserved", null);
|
493
438
|
__decorate([
|
494
|
-
|
439
|
+
Memoize()
|
495
440
|
], FiatSumBalancesFormatter.prototype, "locked", null);
|
496
441
|
__decorate([
|
497
|
-
|
442
|
+
Memoize()
|
498
443
|
], FiatSumBalancesFormatter.prototype, "frozen", null);
|
499
444
|
__decorate([
|
500
|
-
|
445
|
+
Memoize()
|
501
446
|
], FiatSumBalancesFormatter.prototype, "transferable", null);
|
502
447
|
__decorate([
|
503
|
-
|
448
|
+
Memoize()
|
504
449
|
], FiatSumBalancesFormatter.prototype, "feePayable", null);
|
505
|
-
|
506
|
-
|
450
|
+
export class SumBalancesFormatter {
|
451
|
+
#balances;
|
507
452
|
constructor(balances) {
|
508
|
-
|
509
|
-
|
510
|
-
this.fiat = (0, memoize_1.default)(this.fiat);
|
453
|
+
this.#balances = balances;
|
454
|
+
this.fiat = memoize(this.fiat);
|
511
455
|
}
|
512
456
|
fiat(currency) {
|
513
|
-
return new FiatSumBalancesFormatter(
|
457
|
+
return new FiatSumBalancesFormatter(this.#balances, currency);
|
514
458
|
}
|
515
459
|
}
|
516
|
-
exports.SumBalancesFormatter = SumBalancesFormatter;
|
517
|
-
_SumBalancesFormatter_balances = new WeakMap();
|
@@ -1,8 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
exports.includeInTotalExtraAmount = exports.excludeFromFeePayableLocks = exports.excludeFromTransferableAmount = void 0;
|
4
|
-
const util_1 = require("@talismn/util");
|
5
|
-
function excludeFromTransferableAmount(locks) {
|
1
|
+
import { BigMath } from "@talismn/util";
|
2
|
+
export function excludeFromTransferableAmount(locks) {
|
6
3
|
if (typeof locks === "string")
|
7
4
|
return BigInt(locks);
|
8
5
|
if (!Array.isArray(locks))
|
@@ -10,18 +7,16 @@ function excludeFromTransferableAmount(locks) {
|
|
10
7
|
return locks
|
11
8
|
.filter((lock) => lock.includeInTransferable !== true)
|
12
9
|
.map((lock) => BigInt(lock.amount))
|
13
|
-
.reduce((max, lock) =>
|
10
|
+
.reduce((max, lock) => BigMath.max(max, lock), BigInt("0"));
|
14
11
|
}
|
15
|
-
|
16
|
-
function excludeFromFeePayableLocks(locks) {
|
12
|
+
export function excludeFromFeePayableLocks(locks) {
|
17
13
|
if (typeof locks === "string")
|
18
14
|
return [];
|
19
15
|
if (!Array.isArray(locks))
|
20
16
|
locks = [locks];
|
21
17
|
return locks.filter((lock) => lock.excludeFromFeePayable);
|
22
18
|
}
|
23
|
-
|
24
|
-
function includeInTotalExtraAmount(extra) {
|
19
|
+
export function includeInTotalExtraAmount(extra) {
|
25
20
|
if (!extra)
|
26
21
|
return BigInt("0");
|
27
22
|
if (!Array.isArray(extra))
|
@@ -31,4 +26,3 @@ function includeInTotalExtraAmount(extra) {
|
|
31
26
|
.map((extra) => BigInt(extra.amount))
|
32
27
|
.reduce((a, b) => a + b, BigInt("0"));
|
33
28
|
}
|
34
|
-
exports.includeInTotalExtraAmount = includeInTotalExtraAmount;
|
package/dist/types/index.js
CHANGED
@@ -1,20 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
-
}
|
8
|
-
Object.defineProperty(o, k2, desc);
|
9
|
-
}) : (function(o, m, k, k2) {
|
10
|
-
if (k2 === undefined) k2 = k;
|
11
|
-
o[k2] = m[k];
|
12
|
-
}));
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
-
};
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
-
__exportStar(require("./addresses"), exports);
|
18
|
-
__exportStar(require("./balances"), exports);
|
19
|
-
__exportStar(require("./balancetypes"), exports);
|
20
|
-
__exportStar(require("./subscriptions"), exports);
|
1
|
+
export * from "./addresses";
|
2
|
+
export * from "./balances";
|
3
|
+
export * from "./balancetypes";
|
4
|
+
export * from "./subscriptions";
|
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
1
|
+
export {};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@talismn/balances",
|
3
|
-
"version": "0.1
|
3
|
+
"version": "0.2.1",
|
4
4
|
"author": "Talisman",
|
5
5
|
"homepage": "https://talisman.xyz",
|
6
6
|
"license": "UNLICENSED",
|
@@ -32,7 +32,7 @@
|
|
32
32
|
},
|
33
33
|
"dependencies": {
|
34
34
|
"@talismn/chain-connector": "^0.1.10",
|
35
|
-
"@talismn/chain-connector-evm": "^0.
|
35
|
+
"@talismn/chain-connector-evm": "^0.2.0",
|
36
36
|
"@talismn/chaindata-provider": "^0.1.10",
|
37
37
|
"@talismn/token-rates": "^0.1.10",
|
38
38
|
"@talismn/util": "^0.1.4",
|