@reyaxyz/sdk 0.23.0 → 0.24.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/dist/services/token/getBalanceByChainId.js +63 -0
- package/dist/services/token/getBalanceByChainId.js.map +1 -0
- package/dist/services/token/{getBalance.js → getBalanceByTokenAddress.js} +6 -8
- package/dist/services/token/getBalanceByTokenAddress.js.map +1 -0
- package/dist/services/token/index.js +2 -1
- package/dist/services/token/index.js.map +1 -1
- package/dist/services/token/types.js.map +1 -1
- package/dist/types/services/token/getBalanceByChainId.d.ts +3 -0
- package/dist/types/services/token/getBalanceByChainId.d.ts.map +1 -0
- package/dist/types/services/token/getBalanceByTokenAddress.d.ts +3 -0
- package/dist/types/services/token/getBalanceByTokenAddress.d.ts.map +1 -0
- package/dist/types/services/token/index.d.ts +2 -1
- package/dist/types/services/token/index.d.ts.map +1 -1
- package/dist/types/services/token/types.d.ts +6 -1
- package/dist/types/services/token/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/services/token/getBalanceByChainId.ts +26 -0
- package/src/services/token/{getBalance.ts → getBalanceByTokenAddress.ts} +4 -6
- package/src/services/token/index.ts +2 -1
- package/src/services/token/types.ts +7 -1
- package/dist/services/token/getBalance.js.map +0 -1
- package/dist/types/services/token/getBalance.d.ts +0 -3
- package/dist/types/services/token/getBalance.d.ts.map +0 -1
|
@@ -0,0 +1,63 @@
|
|
|
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
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var _a;
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.getBalanceByChainId = void 0;
|
|
41
|
+
var getBalanceByTokenAddress_1 = require("./getBalanceByTokenAddress");
|
|
42
|
+
var common_1 = require("@reyaxyz/common");
|
|
43
|
+
// TODO: Milan hardcoded address atm fix!
|
|
44
|
+
var chainToTokenMap = (_a = {},
|
|
45
|
+
_a[common_1.ReyaChainId.reyaCronos] = '0x51b0b7f083e563d5cf9d0b5f3916b59fc49c7e5f',
|
|
46
|
+
_a[common_1.ReyaChainId.reyaNetwork] = '0x51b0b7f083e563d5cf9d0b5f3916b59fc49c7e5f',
|
|
47
|
+
_a[common_1.MoneyInOutChainId.ethereumSepolia] = '0x51b0b7f083e563d5cf9d0b5f3916b59fc49c7e5f',
|
|
48
|
+
_a[common_1.ReyaChainId.polygonMumbai] = '0x51b0b7f083e563d5cf9d0b5f3916b59fc49c7e5f',
|
|
49
|
+
_a);
|
|
50
|
+
// TODO: Milan hardcoded address atm fix!
|
|
51
|
+
var getBalanceByChainId = function (_a) {
|
|
52
|
+
var signer = _a.signer, chainId = _a.chainId;
|
|
53
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
54
|
+
return __generator(this, function (_b) {
|
|
55
|
+
return [2 /*return*/, (0, getBalanceByTokenAddress_1.getBalanceByTokenAddress)({
|
|
56
|
+
signer: signer,
|
|
57
|
+
tokenAddress: chainToTokenMap[chainId],
|
|
58
|
+
})];
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
exports.getBalanceByChainId = getBalanceByChainId;
|
|
63
|
+
//# sourceMappingURL=getBalanceByChainId.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getBalanceByChainId.js","sourceRoot":"/","sources":["services/token/getBalanceByChainId.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,uEAAsE;AACtE,0CAAiE;AAEjE,yCAAyC;AACzC,IAAM,eAAe;IAInB,GAAC,oBAAW,CAAC,UAAU,IAAG,4CAA4C;IACtE,GAAC,oBAAW,CAAC,WAAW,IAAG,4CAA4C;IACvE,GAAC,0BAAiB,CAAC,eAAe,IAChC,4CAA4C;IAC9C,GAAC,oBAAW,CAAC,aAAa,IAAG,4CAA4C;OAC1E,CAAC;AAEF,yCAAyC;AAClC,IAAM,mBAAmB,GAAG,UAAO,EAGd;QAF1B,MAAM,YAAA,EACN,OAAO,aAAA;;;YAEP,sBAAO,IAAA,mDAAwB,EAAC;oBAC9B,MAAM,QAAA;oBACN,YAAY,EAAE,eAAe,CAAC,OAAO,CAAC;iBACvC,CAAC,EAAC;;;CACJ,CAAC;AARW,QAAA,mBAAmB,uBAQ9B","sourcesContent":["import { GetBalanceByChainIdParams } from './types';\nimport { getBalanceByTokenAddress } from './getBalanceByTokenAddress';\nimport { MoneyInOutChainId, ReyaChainId } from '@reyaxyz/common';\n\n// TODO: Milan hardcoded address atm fix!\nconst chainToTokenMap: Record<\n ReyaChainId | MoneyInOutChainId,\n Lowercase<string>\n> = {\n [ReyaChainId.reyaCronos]: '0x51b0b7f083e563d5cf9d0b5f3916b59fc49c7e5f',\n [ReyaChainId.reyaNetwork]: '0x51b0b7f083e563d5cf9d0b5f3916b59fc49c7e5f',\n [MoneyInOutChainId.ethereumSepolia]:\n '0x51b0b7f083e563d5cf9d0b5f3916b59fc49c7e5f',\n [ReyaChainId.polygonMumbai]: '0x51b0b7f083e563d5cf9d0b5f3916b59fc49c7e5f',\n};\n\n// TODO: Milan hardcoded address atm fix!\nexport const getBalanceByChainId = async ({\n signer,\n chainId,\n}: GetBalanceByChainIdParams): Promise<number> => {\n return getBalanceByTokenAddress({\n signer,\n tokenAddress: chainToTokenMap[chainId],\n });\n};\n"]}
|
|
@@ -36,12 +36,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.
|
|
39
|
+
exports.getBalanceByTokenAddress = void 0;
|
|
40
40
|
var common_1 = require("./common");
|
|
41
|
-
var
|
|
41
|
+
var getBalanceByTokenAddress = function (_a) {
|
|
42
42
|
var signer = _a.signer, tokenAddress = _a.tokenAddress;
|
|
43
43
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
44
|
-
var walletAddress
|
|
44
|
+
var walletAddress;
|
|
45
45
|
return __generator(this, function (_b) {
|
|
46
46
|
switch (_b.label) {
|
|
47
47
|
case 0: return [4 /*yield*/, signer.getAddress()];
|
|
@@ -52,12 +52,10 @@ var getBalance = function (_a) {
|
|
|
52
52
|
subject: signer,
|
|
53
53
|
tokenAddress: tokenAddress,
|
|
54
54
|
})];
|
|
55
|
-
case 2:
|
|
56
|
-
currentBalance = _b.sent();
|
|
57
|
-
return [2 /*return*/, currentBalance];
|
|
55
|
+
case 2: return [2 /*return*/, _b.sent()];
|
|
58
56
|
}
|
|
59
57
|
});
|
|
60
58
|
});
|
|
61
59
|
};
|
|
62
|
-
exports.
|
|
63
|
-
//# sourceMappingURL=
|
|
60
|
+
exports.getBalanceByTokenAddress = getBalanceByTokenAddress;
|
|
61
|
+
//# sourceMappingURL=getBalanceByTokenAddress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getBalanceByTokenAddress.js","sourceRoot":"/","sources":["services/token/getBalanceByTokenAddress.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,mCAA2C;AAEpC,IAAM,wBAAwB,GAAG,UAAO,EAGd;QAF/B,MAAM,YAAA,EACN,YAAY,kBAAA;;;;;wBAEU,qBAAM,MAAM,CAAC,UAAU,EAAE,EAAA;;oBAAzC,aAAa,GAAG,SAAyB;oBACxC,qBAAM,IAAA,wBAAe,EAAC;4BAC3B,aAAa,eAAA;4BACb,OAAO,EAAE,MAAM;4BACf,YAAY,EAAE,YAAY;yBAC3B,CAAC,EAAA;wBAJF,sBAAO,SAIL,EAAC;;;;CACJ,CAAC;AAVW,QAAA,wBAAwB,4BAUnC","sourcesContent":["import { GetBalanceByTokenAddressParams } from './types';\nimport { getERC20Balance } from './common';\n\nexport const getBalanceByTokenAddress = async ({\n signer,\n tokenAddress,\n}: GetBalanceByTokenAddressParams): Promise<number> => {\n const walletAddress = await signer.getAddress();\n return await getERC20Balance({\n walletAddress,\n subject: signer,\n tokenAddress: tokenAddress,\n });\n};\n"]}
|
|
@@ -17,5 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./types"), exports);
|
|
18
18
|
__exportStar(require("./approve"), exports);
|
|
19
19
|
__exportStar(require("./getAllowance"), exports);
|
|
20
|
-
__exportStar(require("./
|
|
20
|
+
__exportStar(require("./getBalanceByChainId"), exports);
|
|
21
|
+
__exportStar(require("./getBalanceByTokenAddress"), exports);
|
|
21
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["services/token/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,4CAA0B;AAC1B,iDAA+B;AAC/B
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["services/token/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,4CAA0B;AAC1B,iDAA+B;AAC/B,wDAAsC;AACtC,6DAA2C","sourcesContent":["export * from './types';\nexport * from './approve';\nexport * from './getAllowance';\nexport * from './getBalanceByChainId';\nexport * from './getBalanceByTokenAddress';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"/","sources":["services/token/types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"/","sources":["services/token/types.ts"],"names":[],"mappings":";;;AAIA,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,2CAAE,CAAA;IACF,qDAAO,CAAA;AACT,CAAC,EAHW,YAAY,4BAAZ,YAAY,QAGvB","sourcesContent":["import { JsonRpcSigner, Signer } from 'ethers';\nimport { LpPoolEntity, TokenEntity } from '@reyaxyz/common';\nimport { MoneyInOutChainId, ReyaChainId } from '@reyaxyz/common';\n\nexport enum ApprovalType {\n LP,\n DEPOSIT,\n}\n\nexport type ApproveTokenParams = {\n signer: Signer | JsonRpcSigner;\n tokenAddress: TokenEntity['address'];\n type: ApprovalType;\n};\n\nexport type GetAllowanceParams = {\n signer: Signer | JsonRpcSigner;\n tokenAddress: TokenEntity['address'];\n type: ApprovalType;\n};\n\nexport type GetERC20AllowanceParams = {\n walletAddress: string;\n tokenAddress: LpPoolEntity['tokenAddress'];\n spenderAddress: string;\n subject: Signer;\n};\n\nexport type GetBalanceByTokenAddressParams = {\n signer: Signer | JsonRpcSigner;\n tokenAddress: TokenEntity['address'];\n};\n\nexport type GetBalanceByChainIdParams = {\n signer: Signer | JsonRpcSigner;\n chainId: ReyaChainId | MoneyInOutChainId;\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getBalanceByChainId.d.ts","sourceRoot":"/","sources":["services/token/getBalanceByChainId.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAiBpD,eAAO,MAAM,mBAAmB,yBAG7B,yBAAyB,KAAG,QAAQ,MAAM,CAK5C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getBalanceByTokenAddress.d.ts","sourceRoot":"/","sources":["services/token/getBalanceByTokenAddress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,SAAS,CAAC;AAGzD,eAAO,MAAM,wBAAwB,8BAGlC,8BAA8B,KAAG,QAAQ,MAAM,CAOjD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["services/token/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["services/token/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { JsonRpcSigner, Signer } from 'ethers';
|
|
2
2
|
import { LpPoolEntity, TokenEntity } from '@reyaxyz/common';
|
|
3
|
+
import { MoneyInOutChainId, ReyaChainId } from '@reyaxyz/common';
|
|
3
4
|
export declare enum ApprovalType {
|
|
4
5
|
LP = 0,
|
|
5
6
|
DEPOSIT = 1
|
|
@@ -20,8 +21,12 @@ export type GetERC20AllowanceParams = {
|
|
|
20
21
|
spenderAddress: string;
|
|
21
22
|
subject: Signer;
|
|
22
23
|
};
|
|
23
|
-
export type
|
|
24
|
+
export type GetBalanceByTokenAddressParams = {
|
|
24
25
|
signer: Signer | JsonRpcSigner;
|
|
25
26
|
tokenAddress: TokenEntity['address'];
|
|
26
27
|
};
|
|
28
|
+
export type GetBalanceByChainIdParams = {
|
|
29
|
+
signer: Signer | JsonRpcSigner;
|
|
30
|
+
chainId: ReyaChainId | MoneyInOutChainId;
|
|
31
|
+
};
|
|
27
32
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["services/token/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["services/token/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEjE,oBAAY,YAAY;IACtB,EAAE,IAAA;IACF,OAAO,IAAA;CACR;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC;IAC/B,YAAY,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IACrC,IAAI,EAAE,YAAY,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC;IAC/B,YAAY,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IACrC,IAAI,EAAE,YAAY,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,YAAY,CAAC,cAAc,CAAC,CAAC;IAC3C,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC;IAC/B,YAAY,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC;IAC/B,OAAO,EAAE,WAAW,GAAG,iBAAiB,CAAC;CAC1C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reyaxyz/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"ethers": "6.9.0"
|
|
35
35
|
},
|
|
36
36
|
"packageManager": "pnpm@8.10.4",
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "ffa2ae8a7128df856137961ebb703a53f3e0f22b"
|
|
38
38
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { GetBalanceByChainIdParams } from './types';
|
|
2
|
+
import { getBalanceByTokenAddress } from './getBalanceByTokenAddress';
|
|
3
|
+
import { MoneyInOutChainId, ReyaChainId } from '@reyaxyz/common';
|
|
4
|
+
|
|
5
|
+
// TODO: Milan hardcoded address atm fix!
|
|
6
|
+
const chainToTokenMap: Record<
|
|
7
|
+
ReyaChainId | MoneyInOutChainId,
|
|
8
|
+
Lowercase<string>
|
|
9
|
+
> = {
|
|
10
|
+
[ReyaChainId.reyaCronos]: '0x51b0b7f083e563d5cf9d0b5f3916b59fc49c7e5f',
|
|
11
|
+
[ReyaChainId.reyaNetwork]: '0x51b0b7f083e563d5cf9d0b5f3916b59fc49c7e5f',
|
|
12
|
+
[MoneyInOutChainId.ethereumSepolia]:
|
|
13
|
+
'0x51b0b7f083e563d5cf9d0b5f3916b59fc49c7e5f',
|
|
14
|
+
[ReyaChainId.polygonMumbai]: '0x51b0b7f083e563d5cf9d0b5f3916b59fc49c7e5f',
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// TODO: Milan hardcoded address atm fix!
|
|
18
|
+
export const getBalanceByChainId = async ({
|
|
19
|
+
signer,
|
|
20
|
+
chainId,
|
|
21
|
+
}: GetBalanceByChainIdParams): Promise<number> => {
|
|
22
|
+
return getBalanceByTokenAddress({
|
|
23
|
+
signer,
|
|
24
|
+
tokenAddress: chainToTokenMap[chainId],
|
|
25
|
+
});
|
|
26
|
+
};
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GetBalanceByTokenAddressParams } from './types';
|
|
2
2
|
import { getERC20Balance } from './common';
|
|
3
3
|
|
|
4
|
-
export const
|
|
4
|
+
export const getBalanceByTokenAddress = async ({
|
|
5
5
|
signer,
|
|
6
6
|
tokenAddress,
|
|
7
|
-
}:
|
|
7
|
+
}: GetBalanceByTokenAddressParams): Promise<number> => {
|
|
8
8
|
const walletAddress = await signer.getAddress();
|
|
9
|
-
|
|
9
|
+
return await getERC20Balance({
|
|
10
10
|
walletAddress,
|
|
11
11
|
subject: signer,
|
|
12
12
|
tokenAddress: tokenAddress,
|
|
13
13
|
});
|
|
14
|
-
|
|
15
|
-
return currentBalance;
|
|
16
14
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { JsonRpcSigner, Signer } from 'ethers';
|
|
2
2
|
import { LpPoolEntity, TokenEntity } from '@reyaxyz/common';
|
|
3
|
+
import { MoneyInOutChainId, ReyaChainId } from '@reyaxyz/common';
|
|
3
4
|
|
|
4
5
|
export enum ApprovalType {
|
|
5
6
|
LP,
|
|
@@ -25,7 +26,12 @@ export type GetERC20AllowanceParams = {
|
|
|
25
26
|
subject: Signer;
|
|
26
27
|
};
|
|
27
28
|
|
|
28
|
-
export type
|
|
29
|
+
export type GetBalanceByTokenAddressParams = {
|
|
29
30
|
signer: Signer | JsonRpcSigner;
|
|
30
31
|
tokenAddress: TokenEntity['address'];
|
|
31
32
|
};
|
|
33
|
+
|
|
34
|
+
export type GetBalanceByChainIdParams = {
|
|
35
|
+
signer: Signer | JsonRpcSigner;
|
|
36
|
+
chainId: ReyaChainId | MoneyInOutChainId;
|
|
37
|
+
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getBalance.js","sourceRoot":"/","sources":["services/token/getBalance.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,mCAA2C;AAEpC,IAAM,UAAU,GAAG,UAAO,EAGd;QAFjB,MAAM,YAAA,EACN,YAAY,kBAAA;;;;;wBAEU,qBAAM,MAAM,CAAC,UAAU,EAAE,EAAA;;oBAAzC,aAAa,GAAG,SAAyB;oBACxB,qBAAM,IAAA,wBAAe,EAAC;4BAC3C,aAAa,eAAA;4BACb,OAAO,EAAE,MAAM;4BACf,YAAY,EAAE,YAAY;yBAC3B,CAAC,EAAA;;oBAJI,cAAc,GAAG,SAIrB;oBAEF,sBAAO,cAAc,EAAC;;;;CACvB,CAAC;AAZW,QAAA,UAAU,cAYrB","sourcesContent":["import { GetBalanceParams } from './types';\nimport { getERC20Balance } from './common';\n\nexport const getBalance = async ({\n signer,\n tokenAddress,\n}: GetBalanceParams): Promise<number> => {\n const walletAddress = await signer.getAddress();\n const currentBalance = await getERC20Balance({\n walletAddress,\n subject: signer,\n tokenAddress: tokenAddress,\n });\n\n return currentBalance;\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getBalance.d.ts","sourceRoot":"/","sources":["services/token/getBalance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAG3C,eAAO,MAAM,UAAU,8BAGpB,gBAAgB,KAAG,QAAQ,MAAM,CASnC,CAAC"}
|