@reown/appkit-common-react-native 0.0.0-feat-smart-account-20241017180406 → 0.0.0-feat-swaps-20241203153101
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/commonjs/contracts/erc20.js +36 -0
- package/lib/commonjs/contracts/erc20.js.map +1 -1
- package/lib/commonjs/index.js +8 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils/ErrorUtil.js +41 -0
- package/lib/commonjs/utils/ErrorUtil.js.map +1 -0
- package/lib/commonjs/utils/NumberUtil.js +39 -2
- package/lib/commonjs/utils/NumberUtil.js.map +1 -1
- package/lib/module/contracts/erc20.js +36 -0
- package/lib/module/contracts/erc20.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/ErrorUtil.js +35 -0
- package/lib/module/utils/ErrorUtil.js.map +1 -0
- package/lib/module/utils/NumberUtil.js +39 -2
- package/lib/module/utils/NumberUtil.js.map +1 -1
- package/lib/typescript/__tests__/NamesUtil.test.d.ts +2 -0
- package/lib/typescript/__tests__/NamesUtil.test.d.ts.map +1 -0
- package/lib/typescript/__tests__/NumberUtil.test.d.ts +2 -0
- package/lib/typescript/__tests__/NumberUtil.test.d.ts.map +1 -0
- package/lib/typescript/contracts/erc20.d.ts +18 -2
- package/lib/typescript/contracts/erc20.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/utils/ErrorUtil.d.ts +35 -0
- package/lib/typescript/utils/ErrorUtil.d.ts.map +1 -0
- package/lib/typescript/utils/NumberUtil.d.ts +13 -0
- package/lib/typescript/utils/NumberUtil.d.ts.map +1 -1
- package/lib/typescript/utils/TypeUtil.d.ts +1 -1
- package/lib/typescript/utils/TypeUtil.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/NamesUtil.test.ts +24 -0
- package/src/__tests__/NumberUtil.test.ts +46 -0
- package/src/contracts/erc20.ts +47 -0
- package/src/index.ts +1 -0
- package/src/utils/ErrorUtil.ts +35 -0
- package/src/utils/NumberUtil.ts +43 -2
- package/src/utils/TypeUtil.ts +1 -4
|
@@ -37,5 +37,41 @@ const erc20ABI = exports.erc20ABI = [{
|
|
|
37
37
|
name: '',
|
|
38
38
|
type: 'bool'
|
|
39
39
|
}]
|
|
40
|
+
}, {
|
|
41
|
+
constant: true,
|
|
42
|
+
inputs: [],
|
|
43
|
+
name: 'symbol',
|
|
44
|
+
outputs: [{
|
|
45
|
+
name: '',
|
|
46
|
+
type: 'string'
|
|
47
|
+
}],
|
|
48
|
+
payable: false,
|
|
49
|
+
stateMutability: 'view',
|
|
50
|
+
type: 'function'
|
|
51
|
+
}, {
|
|
52
|
+
constant: true,
|
|
53
|
+
inputs: [],
|
|
54
|
+
name: 'decimals',
|
|
55
|
+
outputs: [{
|
|
56
|
+
name: '',
|
|
57
|
+
type: 'uint8'
|
|
58
|
+
}],
|
|
59
|
+
payable: false,
|
|
60
|
+
stateMutability: 'view',
|
|
61
|
+
type: 'function'
|
|
62
|
+
}, {
|
|
63
|
+
constant: true,
|
|
64
|
+
inputs: [{
|
|
65
|
+
name: '_owner',
|
|
66
|
+
type: 'address'
|
|
67
|
+
}],
|
|
68
|
+
name: 'balanceOf',
|
|
69
|
+
outputs: [{
|
|
70
|
+
name: 'balance',
|
|
71
|
+
type: 'uint256'
|
|
72
|
+
}],
|
|
73
|
+
payable: false,
|
|
74
|
+
stateMutability: 'view',
|
|
75
|
+
type: 'function'
|
|
40
76
|
}];
|
|
41
77
|
//# sourceMappingURL=erc20.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["erc20ABI","exports","type","name","stateMutability","inputs","outputs"],"sourceRoot":"../../../src","sources":["contracts/erc20.ts"],"mappings":";;;;;;AAAO,MAAMA,QAAQ,GAAAC,OAAA,CAAAD,QAAA,GAAG,CACtB;EACEE,IAAI,EAAE,UAAU;EAChBC,IAAI,EAAE,UAAU;EAChBC,eAAe,EAAE,YAAY;EAC7BC,MAAM,EAAE,CACN;IACEF,IAAI,EAAE,KAAK;IACXD,IAAI,EAAE;EACR,CAAC,EACD;IACEC,IAAI,EAAE,QAAQ;IACdD,IAAI,EAAE;EACR,CAAC,CACF;EACDI,OAAO,EAAE,CACP;IACEH,IAAI,EAAE,EAAE;IACRD,IAAI,EAAE;EACR,CAAC;AAEL,CAAC,EACD;EACEA,IAAI,EAAE,UAAU;EAChBC,IAAI,EAAE,cAAc;EACpBC,eAAe,EAAE,YAAY;EAC7BC,MAAM,EAAE,CACN;IACEF,IAAI,EAAE,OAAO;IACbD,IAAI,EAAE;EACR,CAAC,EACD;IACEC,IAAI,EAAE,KAAK;IACXD,IAAI,EAAE;EACR,CAAC,EACD;IACEC,IAAI,EAAE,QAAQ;IACdD,IAAI,EAAE;EACR,CAAC,CACF;EACDI,OAAO,EAAE,CACP;IACEH,IAAI,EAAE,EAAE;IACRD,IAAI,EAAE;EACR,CAAC;AAEL,CAAC,CACF"}
|
|
1
|
+
{"version":3,"names":["erc20ABI","exports","type","name","stateMutability","inputs","outputs","constant","payable"],"sourceRoot":"../../../src","sources":["contracts/erc20.ts"],"mappings":";;;;;;AAAO,MAAMA,QAAQ,GAAAC,OAAA,CAAAD,QAAA,GAAG,CACtB;EACEE,IAAI,EAAE,UAAU;EAChBC,IAAI,EAAE,UAAU;EAChBC,eAAe,EAAE,YAAY;EAC7BC,MAAM,EAAE,CACN;IACEF,IAAI,EAAE,KAAK;IACXD,IAAI,EAAE;EACR,CAAC,EACD;IACEC,IAAI,EAAE,QAAQ;IACdD,IAAI,EAAE;EACR,CAAC,CACF;EACDI,OAAO,EAAE,CACP;IACEH,IAAI,EAAE,EAAE;IACRD,IAAI,EAAE;EACR,CAAC;AAEL,CAAC,EACD;EACEA,IAAI,EAAE,UAAU;EAChBC,IAAI,EAAE,cAAc;EACpBC,eAAe,EAAE,YAAY;EAC7BC,MAAM,EAAE,CACN;IACEF,IAAI,EAAE,OAAO;IACbD,IAAI,EAAE;EACR,CAAC,EACD;IACEC,IAAI,EAAE,KAAK;IACXD,IAAI,EAAE;EACR,CAAC,EACD;IACEC,IAAI,EAAE,QAAQ;IACdD,IAAI,EAAE;EACR,CAAC,CACF;EACDI,OAAO,EAAE,CACP;IACEH,IAAI,EAAE,EAAE;IACRD,IAAI,EAAE;EACR,CAAC;AAEL,CAAC,EACD;EACEK,QAAQ,EAAE,IAAI;EACdF,MAAM,EAAE,EAAE;EACVF,IAAI,EAAE,QAAQ;EACdG,OAAO,EAAE,CACP;IACEH,IAAI,EAAE,EAAE;IACRD,IAAI,EAAE;EACR,CAAC,CACF;EACDM,OAAO,EAAE,KAAK;EACdJ,eAAe,EAAE,MAAM;EACvBF,IAAI,EAAE;AACR,CAAC,EACD;EACEK,QAAQ,EAAE,IAAI;EACdF,MAAM,EAAE,EAAE;EACVF,IAAI,EAAE,UAAU;EAChBG,OAAO,EAAE,CACP;IACEH,IAAI,EAAE,EAAE;IACRD,IAAI,EAAE;EACR,CAAC,CACF;EACDM,OAAO,EAAE,KAAK;EACdJ,eAAe,EAAE,MAAM;EACvBF,IAAI,EAAE;AACR,CAAC,EACD;EACEK,QAAQ,EAAE,IAAI;EACdF,MAAM,EAAE,CACN;IACEF,IAAI,EAAE,QAAQ;IACdD,IAAI,EAAE;EACR,CAAC,CACF;EACDC,IAAI,EAAE,WAAW;EACjBG,OAAO,EAAE,CACP;IACEH,IAAI,EAAE,SAAS;IACfD,IAAI,EAAE;EACR,CAAC,CACF;EACDM,OAAO,EAAE,KAAK;EACdJ,eAAe,EAAE,MAAM;EACvBF,IAAI,EAAE;AACR,CAAC,CACF"}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -11,6 +11,7 @@ var _exportNames = {
|
|
|
11
11
|
NetworkUtil: true,
|
|
12
12
|
NumberUtil: true,
|
|
13
13
|
StringUtil: true,
|
|
14
|
+
ErrorUtil: true,
|
|
14
15
|
erc20ABI: true
|
|
15
16
|
};
|
|
16
17
|
Object.defineProperty(exports, "ConstantsUtil", {
|
|
@@ -31,6 +32,12 @@ Object.defineProperty(exports, "DateUtil", {
|
|
|
31
32
|
return _DateUtil.DateUtil;
|
|
32
33
|
}
|
|
33
34
|
});
|
|
35
|
+
Object.defineProperty(exports, "ErrorUtil", {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
get: function () {
|
|
38
|
+
return _ErrorUtil.ErrorUtil;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
34
41
|
Object.defineProperty(exports, "NamesUtil", {
|
|
35
42
|
enumerable: true,
|
|
36
43
|
get: function () {
|
|
@@ -68,6 +75,7 @@ var _NamesUtil = require("./utils/NamesUtil");
|
|
|
68
75
|
var _NetworkUtil = require("./utils/NetworkUtil");
|
|
69
76
|
var _NumberUtil = require("./utils/NumberUtil");
|
|
70
77
|
var _StringUtil = require("./utils/StringUtil");
|
|
78
|
+
var _ErrorUtil = require("./utils/ErrorUtil");
|
|
71
79
|
var _erc = require("./contracts/erc20");
|
|
72
80
|
var _TypeUtil = require("./utils/TypeUtil");
|
|
73
81
|
Object.keys(_TypeUtil).forEach(function (key) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_ConstantsUtil","require","_ContractUtil","_DateUtil","_NamesUtil","_NetworkUtil","_NumberUtil","_StringUtil","_erc","_TypeUtil","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_ConstantsUtil","require","_ContractUtil","_DateUtil","_NamesUtil","_NetworkUtil","_NumberUtil","_StringUtil","_ErrorUtil","_erc","_TypeUtil","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAP,OAAA;AACA,IAAAQ,IAAA,GAAAR,OAAA;AACA,IAAAS,SAAA,GAAAT,OAAA;AAAAU,MAAA,CAAAC,IAAA,CAAAF,SAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,SAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,SAAA,CAAAI,GAAA;IAAA;EAAA;AAAA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ErrorUtil = void 0;
|
|
7
|
+
const ErrorUtil = exports.ErrorUtil = {
|
|
8
|
+
UniversalProviderErrors: {
|
|
9
|
+
UNAUTHORIZED_DOMAIN_NOT_ALLOWED: {
|
|
10
|
+
message: 'Unauthorized: origin not allowed',
|
|
11
|
+
alertErrorKey: 'INVALID_APP_CONFIGURATION'
|
|
12
|
+
},
|
|
13
|
+
PROJECT_ID_NOT_CONFIGURED: {
|
|
14
|
+
message: 'Project ID is missing',
|
|
15
|
+
alertErrorKey: 'PROJECT_ID_NOT_CONFIGURED'
|
|
16
|
+
},
|
|
17
|
+
JWT_VALIDATION_ERROR: {
|
|
18
|
+
message: 'JWT validation error: JWT Token is not yet valid',
|
|
19
|
+
alertErrorKey: 'JWT_TOKEN_NOT_VALID'
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
ALERT_ERRORS: {
|
|
23
|
+
INVALID_APP_CONFIGURATION: {
|
|
24
|
+
shortMessage: 'Invalid App Configuration',
|
|
25
|
+
longMessage: `Bundle ID not found on Allowlist - Please verify that your bundle ID is allowed at https://cloud.reown.com`
|
|
26
|
+
},
|
|
27
|
+
SOCIALS_TIMEOUT: {
|
|
28
|
+
shortMessage: 'Invalid App Configuration',
|
|
29
|
+
longMessage: 'There was an issue loading the embedded wallet. Please verify that your bundle ID is allowed at https://cloud.reown.com'
|
|
30
|
+
},
|
|
31
|
+
JWT_TOKEN_NOT_VALID: {
|
|
32
|
+
shortMessage: 'Session Expired',
|
|
33
|
+
longMessage: 'Invalid session found - please check your time settings and connect again'
|
|
34
|
+
},
|
|
35
|
+
PROJECT_ID_NOT_CONFIGURED: {
|
|
36
|
+
shortMessage: 'Project ID Not Configured',
|
|
37
|
+
longMessage: 'Project ID Not Configured - update configuration'
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=ErrorUtil.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ErrorUtil","exports","UniversalProviderErrors","UNAUTHORIZED_DOMAIN_NOT_ALLOWED","message","alertErrorKey","PROJECT_ID_NOT_CONFIGURED","JWT_VALIDATION_ERROR","ALERT_ERRORS","INVALID_APP_CONFIGURATION","shortMessage","longMessage","SOCIALS_TIMEOUT","JWT_TOKEN_NOT_VALID"],"sourceRoot":"../../../src","sources":["utils/ErrorUtil.ts"],"mappings":";;;;;;AAAO,MAAMA,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG;EACvBE,uBAAuB,EAAE;IACvBC,+BAA+B,EAAE;MAC/BC,OAAO,EAAE,kCAAkC;MAC3CC,aAAa,EAAE;IACjB,CAAC;IACDC,yBAAyB,EAAE;MACzBF,OAAO,EAAE,uBAAuB;MAChCC,aAAa,EAAE;IACjB,CAAC;IACDE,oBAAoB,EAAE;MACpBH,OAAO,EAAE,kDAAkD;MAC3DC,aAAa,EAAE;IACjB;EACF,CAAC;EACDG,YAAY,EAAE;IACZC,yBAAyB,EAAE;MACzBC,YAAY,EAAE,2BAA2B;MACzCC,WAAW,EAAG;IAChB,CAAC;IACDC,eAAe,EAAE;MACfF,YAAY,EAAE,2BAA2B;MACzCC,WAAW,EACT;IACJ,CAAC;IACDE,mBAAmB,EAAE;MACnBH,YAAY,EAAE,iBAAiB;MAC/BC,WAAW,EAAE;IACf,CAAC;IACDL,yBAAyB,EAAE;MACzBI,YAAY,EAAE,2BAA2B;MACzCC,WAAW,EAAE;IACf;EACF;AACF,CAAC"}
|
|
@@ -9,6 +9,9 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
9
9
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
10
10
|
const NumberUtil = exports.NumberUtil = {
|
|
11
11
|
bigNumber(value) {
|
|
12
|
+
if (typeof value === 'string') {
|
|
13
|
+
return new BigNumber.BigNumber(value.replace(/,/g, ''));
|
|
14
|
+
}
|
|
12
15
|
return new BigNumber.BigNumber(value);
|
|
13
16
|
},
|
|
14
17
|
/**
|
|
@@ -21,13 +24,47 @@ const NumberUtil = exports.NumberUtil = {
|
|
|
21
24
|
if (a === undefined || b === undefined) {
|
|
22
25
|
return BigNumber.BigNumber(0);
|
|
23
26
|
}
|
|
24
|
-
const aBigNumber = new BigNumber.BigNumber(a);
|
|
25
|
-
const bBigNumber = new BigNumber.BigNumber(b);
|
|
27
|
+
const aBigNumber = new BigNumber.BigNumber(typeof a === 'string' ? a.replace(/,/gu, '') : a);
|
|
28
|
+
const bBigNumber = new BigNumber.BigNumber(typeof b === 'string' ? b.replace(/,/gu, '') : b);
|
|
26
29
|
return aBigNumber.multipliedBy(bBigNumber);
|
|
27
30
|
},
|
|
28
31
|
roundNumber(number, threshold, fixed) {
|
|
29
32
|
const roundedNumber = number.toString().length >= threshold ? Number(number).toFixed(fixed) : number;
|
|
30
33
|
return roundedNumber;
|
|
34
|
+
},
|
|
35
|
+
/**
|
|
36
|
+
* Format the given number or string to human readable numbers with the given number of decimals
|
|
37
|
+
* @param value - The value to format. It could be a number or string. If it's a string, it will be parsed to a float then formatted.
|
|
38
|
+
* @param decimals - number of decimals after dot
|
|
39
|
+
* @returns
|
|
40
|
+
*/
|
|
41
|
+
formatNumberToLocalString(value, decimals = 2) {
|
|
42
|
+
if (value === undefined) {
|
|
43
|
+
return '0.00';
|
|
44
|
+
}
|
|
45
|
+
if (typeof value === 'number') {
|
|
46
|
+
return value.toLocaleString('en-US', {
|
|
47
|
+
maximumFractionDigits: decimals,
|
|
48
|
+
minimumFractionDigits: decimals
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return parseFloat(value).toLocaleString('en-US', {
|
|
52
|
+
maximumFractionDigits: decimals,
|
|
53
|
+
minimumFractionDigits: decimals
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
/**
|
|
57
|
+
* Parse a formatted local string back to a number
|
|
58
|
+
* @param value - The formatted string to parse
|
|
59
|
+
* @returns
|
|
60
|
+
*/
|
|
61
|
+
parseLocalStringToNumber(value) {
|
|
62
|
+
if (value === undefined) {
|
|
63
|
+
return 0;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Remove any commas used as thousand separators and parse the float
|
|
67
|
+
return parseFloat(value.replace(/,/gu, ''));
|
|
31
68
|
}
|
|
32
69
|
};
|
|
33
70
|
//# sourceMappingURL=NumberUtil.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BigNumber","_interopRequireWildcard","require","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","NumberUtil","exports","bigNumber","value","multiply","b","undefined","aBigNumber","bBigNumber","multipliedBy","roundNumber","number","threshold","fixed","roundedNumber","toString","length","Number","toFixed"],"sourceRoot":"../../../src","sources":["utils/NumberUtil.ts"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,uBAAA,CAAAC,OAAA;AAA0C,SAAAC,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAH,wBAAAG,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAjB,CAAA,EAAAc,CAAA,SAAAI,CAAA,GAAAR,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAI,CAAA,KAAAA,CAAA,CAAAX,GAAA,IAAAW,CAAA,CAAAC,GAAA,IAAAR,MAAA,CAAAC,cAAA,CAAAJ,CAAA,EAAAM,CAAA,EAAAI,CAAA,IAAAV,CAAA,CAAAM,CAAA,IAAAd,CAAA,CAAAc,CAAA,YAAAN,CAAA,CAAAH,OAAA,GAAAL,CAAA,EAAAG,CAAA,IAAAA,CAAA,CAAAgB,GAAA,CAAAnB,CAAA,EAAAQ,CAAA,GAAAA,CAAA;AAEnC,MAAMY,UAAU,GAAAC,OAAA,CAAAD,UAAA,GAAG;EACxBE,SAASA,CAACC,KAAgC,EAAE;IAC1C,OAAO,IAAI3B,SAAS,CAACA,SAAS,CAAC2B,KAAK,CAAC;EACvC,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;
|
|
1
|
+
{"version":3,"names":["BigNumber","_interopRequireWildcard","require","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","NumberUtil","exports","bigNumber","value","replace","multiply","b","undefined","aBigNumber","bBigNumber","multipliedBy","roundNumber","number","threshold","fixed","roundedNumber","toString","length","Number","toFixed","formatNumberToLocalString","decimals","toLocaleString","maximumFractionDigits","minimumFractionDigits","parseFloat","parseLocalStringToNumber"],"sourceRoot":"../../../src","sources":["utils/NumberUtil.ts"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,uBAAA,CAAAC,OAAA;AAA0C,SAAAC,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAH,wBAAAG,CAAA,EAAAE,CAA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MAC/BG,qBAAqB,EAAEH;IACzB,CAAC,CAAC;EACJ,CAAC;EACD;AACF;AACA;AACA;AACA;EACEK,wBAAwBA,CAACvB,KAAyB,EAAE;IAClD,IAAIA,KAAK,KAAKI,SAAS,EAAE;MACvB,OAAO,CAAC;IACV;;IAEA;IACA,OAAOkB,UAAU,CAACtB,KAAK,CAACC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;EAC7C;AACF,CAAC"}
|
|
@@ -31,5 +31,41 @@ export const erc20ABI = [{
|
|
|
31
31
|
name: '',
|
|
32
32
|
type: 'bool'
|
|
33
33
|
}]
|
|
34
|
+
}, {
|
|
35
|
+
constant: true,
|
|
36
|
+
inputs: [],
|
|
37
|
+
name: 'symbol',
|
|
38
|
+
outputs: [{
|
|
39
|
+
name: '',
|
|
40
|
+
type: 'string'
|
|
41
|
+
}],
|
|
42
|
+
payable: false,
|
|
43
|
+
stateMutability: 'view',
|
|
44
|
+
type: 'function'
|
|
45
|
+
}, {
|
|
46
|
+
constant: true,
|
|
47
|
+
inputs: [],
|
|
48
|
+
name: 'decimals',
|
|
49
|
+
outputs: [{
|
|
50
|
+
name: '',
|
|
51
|
+
type: 'uint8'
|
|
52
|
+
}],
|
|
53
|
+
payable: false,
|
|
54
|
+
stateMutability: 'view',
|
|
55
|
+
type: 'function'
|
|
56
|
+
}, {
|
|
57
|
+
constant: true,
|
|
58
|
+
inputs: [{
|
|
59
|
+
name: '_owner',
|
|
60
|
+
type: 'address'
|
|
61
|
+
}],
|
|
62
|
+
name: 'balanceOf',
|
|
63
|
+
outputs: [{
|
|
64
|
+
name: 'balance',
|
|
65
|
+
type: 'uint256'
|
|
66
|
+
}],
|
|
67
|
+
payable: false,
|
|
68
|
+
stateMutability: 'view',
|
|
69
|
+
type: 'function'
|
|
34
70
|
}];
|
|
35
71
|
//# sourceMappingURL=erc20.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["erc20ABI","type","name","stateMutability","inputs","outputs"],"sourceRoot":"../../../src","sources":["contracts/erc20.ts"],"mappings":"AAAA,OAAO,MAAMA,QAAQ,GAAG,CACtB;EACEC,IAAI,EAAE,UAAU;EAChBC,IAAI,EAAE,UAAU;EAChBC,eAAe,EAAE,YAAY;EAC7BC,MAAM,EAAE,CACN;IACEF,IAAI,EAAE,KAAK;IACXD,IAAI,EAAE;EACR,CAAC,EACD;IACEC,IAAI,EAAE,QAAQ;IACdD,IAAI,EAAE;EACR,CAAC,CACF;EACDI,OAAO,EAAE,CACP;IACEH,IAAI,EAAE,EAAE;IACRD,IAAI,EAAE;EACR,CAAC;AAEL,CAAC,EACD;EACEA,IAAI,EAAE,UAAU;EAChBC,IAAI,EAAE,cAAc;EACpBC,eAAe,EAAE,YAAY;EAC7BC,MAAM,EAAE,CACN;IACEF,IAAI,EAAE,OAAO;IACbD,IAAI,EAAE;EACR,CAAC,EACD;IACEC,IAAI,EAAE,KAAK;IACXD,IAAI,EAAE;EACR,CAAC,EACD;IACEC,IAAI,EAAE,QAAQ;IACdD,IAAI,EAAE;EACR,CAAC,CACF;EACDI,OAAO,EAAE,CACP;IACEH,IAAI,EAAE,EAAE;IACRD,IAAI,EAAE;EACR,CAAC;AAEL,CAAC,CACF"}
|
|
1
|
+
{"version":3,"names":["erc20ABI","type","name","stateMutability","inputs","outputs","constant","payable"],"sourceRoot":"../../../src","sources":["contracts/erc20.ts"],"mappings":"AAAA,OAAO,MAAMA,QAAQ,GAAG,CACtB;EACEC,IAAI,EAAE,UAAU;EAChBC,IAAI,EAAE,UAAU;EAChBC,eAAe,EAAE,YAAY;EAC7BC,MAAM,EAAE,CACN;IACEF,IAAI,EAAE,KAAK;IACXD,IAAI,EAAE;EACR,CAAC,EACD;IACEC,IAAI,EAAE,QAAQ;IACdD,IAAI,EAAE;EACR,CAAC,CACF;EACDI,OAAO,EAAE,CACP;IACEH,IAAI,EAAE,EAAE;IACRD,IAAI,EAAE;EACR,CAAC;AAEL,CAAC,EACD;EACEA,IAAI,EAAE,UAAU;EAChBC,IAAI,EAAE,cAAc;EACpBC,eAAe,EAAE,YAAY;EAC7BC,MAAM,EAAE,CACN;IACEF,IAAI,EAAE,OAAO;IACbD,IAAI,EAAE;EACR,CAAC,EACD;IACEC,IAAI,EAAE,KAAK;IACXD,IAAI,EAAE;EACR,CAAC,EACD;IACEC,IAAI,EAAE,QAAQ;IACdD,IAAI,EAAE;EACR,CAAC,CACF;EACDI,OAAO,EAAE,CACP;IACEH,IAAI,EAAE,EAAE;IACRD,IAAI,EAAE;EACR,CAAC;AAEL,CAAC,EACD;EACEK,QAAQ,EAAE,IAAI;EACdF,MAAM,EAAE,EAAE;EACVF,IAAI,EAAE,QAAQ;EACdG,OAAO,EAAE,CACP;IACEH,IAAI,EAAE,EAAE;IACRD,IAAI,EAAE;EACR,CAAC,CACF;EACDM,OAAO,EAAE,KAAK;EACdJ,eAAe,EAAE,MAAM;EACvBF,IAAI,EAAE;AACR,CAAC,EACD;EACEK,QAAQ,EAAE,IAAI;EACdF,MAAM,EAAE,EAAE;EACVF,IAAI,EAAE,UAAU;EAChBG,OAAO,EAAE,CACP;IACEH,IAAI,EAAE,EAAE;IACRD,IAAI,EAAE;EACR,CAAC,CACF;EACDM,OAAO,EAAE,KAAK;EACdJ,eAAe,EAAE,MAAM;EACvBF,IAAI,EAAE;AACR,CAAC,EACD;EACEK,QAAQ,EAAE,IAAI;EACdF,MAAM,EAAE,CACN;IACEF,IAAI,EAAE,QAAQ;IACdD,IAAI,EAAE;EACR,CAAC,CACF;EACDC,IAAI,EAAE,WAAW;EACjBG,OAAO,EAAE,CACP;IACEH,IAAI,EAAE,SAAS;IACfD,IAAI,EAAE;EACR,CAAC,CACF;EACDM,OAAO,EAAE,KAAK;EACdJ,eAAe,EAAE,MAAM;EACvBF,IAAI,EAAE;AACR,CAAC,CACF"}
|
package/lib/module/index.js
CHANGED
|
@@ -5,6 +5,7 @@ export { NamesUtil } from './utils/NamesUtil';
|
|
|
5
5
|
export { NetworkUtil } from './utils/NetworkUtil';
|
|
6
6
|
export { NumberUtil } from './utils/NumberUtil';
|
|
7
7
|
export { StringUtil } from './utils/StringUtil';
|
|
8
|
+
export { ErrorUtil } from './utils/ErrorUtil';
|
|
8
9
|
export { erc20ABI } from './contracts/erc20';
|
|
9
10
|
export * from './utils/TypeUtil';
|
|
10
11
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ConstantsUtil","ContractUtil","DateUtil","NamesUtil","NetworkUtil","NumberUtil","StringUtil","erc20ABI"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,SAASA,aAAa,QAAQ,uBAAuB;AACrD,SAASC,YAAY,QAAQ,sBAAsB;AACnD,SAASC,QAAQ,QAAQ,kBAAkB;AAC3C,SAASC,SAAS,QAAQ,mBAAmB;AAC7C,SAASC,WAAW,QAAQ,qBAAqB;AACjD,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,QAAQ,QAAQ,mBAAmB;AAC5C,cAAc,kBAAkB"}
|
|
1
|
+
{"version":3,"names":["ConstantsUtil","ContractUtil","DateUtil","NamesUtil","NetworkUtil","NumberUtil","StringUtil","ErrorUtil","erc20ABI"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,SAASA,aAAa,QAAQ,uBAAuB;AACrD,SAASC,YAAY,QAAQ,sBAAsB;AACnD,SAASC,QAAQ,QAAQ,kBAAkB;AAC3C,SAASC,SAAS,QAAQ,mBAAmB;AAC7C,SAASC,WAAW,QAAQ,qBAAqB;AACjD,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,SAAS,QAAQ,mBAAmB;AAC7C,SAASC,QAAQ,QAAQ,mBAAmB;AAC5C,cAAc,kBAAkB"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export const ErrorUtil = {
|
|
2
|
+
UniversalProviderErrors: {
|
|
3
|
+
UNAUTHORIZED_DOMAIN_NOT_ALLOWED: {
|
|
4
|
+
message: 'Unauthorized: origin not allowed',
|
|
5
|
+
alertErrorKey: 'INVALID_APP_CONFIGURATION'
|
|
6
|
+
},
|
|
7
|
+
PROJECT_ID_NOT_CONFIGURED: {
|
|
8
|
+
message: 'Project ID is missing',
|
|
9
|
+
alertErrorKey: 'PROJECT_ID_NOT_CONFIGURED'
|
|
10
|
+
},
|
|
11
|
+
JWT_VALIDATION_ERROR: {
|
|
12
|
+
message: 'JWT validation error: JWT Token is not yet valid',
|
|
13
|
+
alertErrorKey: 'JWT_TOKEN_NOT_VALID'
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
ALERT_ERRORS: {
|
|
17
|
+
INVALID_APP_CONFIGURATION: {
|
|
18
|
+
shortMessage: 'Invalid App Configuration',
|
|
19
|
+
longMessage: `Bundle ID not found on Allowlist - Please verify that your bundle ID is allowed at https://cloud.reown.com`
|
|
20
|
+
},
|
|
21
|
+
SOCIALS_TIMEOUT: {
|
|
22
|
+
shortMessage: 'Invalid App Configuration',
|
|
23
|
+
longMessage: 'There was an issue loading the embedded wallet. Please verify that your bundle ID is allowed at https://cloud.reown.com'
|
|
24
|
+
},
|
|
25
|
+
JWT_TOKEN_NOT_VALID: {
|
|
26
|
+
shortMessage: 'Session Expired',
|
|
27
|
+
longMessage: 'Invalid session found - please check your time settings and connect again'
|
|
28
|
+
},
|
|
29
|
+
PROJECT_ID_NOT_CONFIGURED: {
|
|
30
|
+
shortMessage: 'Project ID Not Configured',
|
|
31
|
+
longMessage: 'Project ID Not Configured - update configuration'
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=ErrorUtil.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ErrorUtil","UniversalProviderErrors","UNAUTHORIZED_DOMAIN_NOT_ALLOWED","message","alertErrorKey","PROJECT_ID_NOT_CONFIGURED","JWT_VALIDATION_ERROR","ALERT_ERRORS","INVALID_APP_CONFIGURATION","shortMessage","longMessage","SOCIALS_TIMEOUT","JWT_TOKEN_NOT_VALID"],"sourceRoot":"../../../src","sources":["utils/ErrorUtil.ts"],"mappings":"AAAA,OAAO,MAAMA,SAAS,GAAG;EACvBC,uBAAuB,EAAE;IACvBC,+BAA+B,EAAE;MAC/BC,OAAO,EAAE,kCAAkC;MAC3CC,aAAa,EAAE;IACjB,CAAC;IACDC,yBAAyB,EAAE;MACzBF,OAAO,EAAE,uBAAuB;MAChCC,aAAa,EAAE;IACjB,CAAC;IACDE,oBAAoB,EAAE;MACpBH,OAAO,EAAE,kDAAkD;MAC3DC,aAAa,EAAE;IACjB;EACF,CAAC;EACDG,YAAY,EAAE;IACZC,yBAAyB,EAAE;MACzBC,YAAY,EAAE,2BAA2B;MACzCC,WAAW,EAAG;IAChB,CAAC;IACDC,eAAe,EAAE;MACfF,YAAY,EAAE,2BAA2B;MACzCC,WAAW,EACT;IACJ,CAAC;IACDE,mBAAmB,EAAE;MACnBH,YAAY,EAAE,iBAAiB;MAC/BC,WAAW,EAAE;IACf,CAAC;IACDL,yBAAyB,EAAE;MACzBI,YAAY,EAAE,2BAA2B;MACzCC,WAAW,EAAE;IACf;EACF;AACF,CAAC"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import * as BigNumber from 'bignumber.js';
|
|
2
2
|
export const NumberUtil = {
|
|
3
3
|
bigNumber(value) {
|
|
4
|
+
if (typeof value === 'string') {
|
|
5
|
+
return new BigNumber.BigNumber(value.replace(/,/g, ''));
|
|
6
|
+
}
|
|
4
7
|
return new BigNumber.BigNumber(value);
|
|
5
8
|
},
|
|
6
9
|
/**
|
|
@@ -13,13 +16,47 @@ export const NumberUtil = {
|
|
|
13
16
|
if (a === undefined || b === undefined) {
|
|
14
17
|
return BigNumber.BigNumber(0);
|
|
15
18
|
}
|
|
16
|
-
const aBigNumber = new BigNumber.BigNumber(a);
|
|
17
|
-
const bBigNumber = new BigNumber.BigNumber(b);
|
|
19
|
+
const aBigNumber = new BigNumber.BigNumber(typeof a === 'string' ? a.replace(/,/gu, '') : a);
|
|
20
|
+
const bBigNumber = new BigNumber.BigNumber(typeof b === 'string' ? b.replace(/,/gu, '') : b);
|
|
18
21
|
return aBigNumber.multipliedBy(bBigNumber);
|
|
19
22
|
},
|
|
20
23
|
roundNumber(number, threshold, fixed) {
|
|
21
24
|
const roundedNumber = number.toString().length >= threshold ? Number(number).toFixed(fixed) : number;
|
|
22
25
|
return roundedNumber;
|
|
26
|
+
},
|
|
27
|
+
/**
|
|
28
|
+
* Format the given number or string to human readable numbers with the given number of decimals
|
|
29
|
+
* @param value - The value to format. It could be a number or string. If it's a string, it will be parsed to a float then formatted.
|
|
30
|
+
* @param decimals - number of decimals after dot
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
formatNumberToLocalString(value, decimals = 2) {
|
|
34
|
+
if (value === undefined) {
|
|
35
|
+
return '0.00';
|
|
36
|
+
}
|
|
37
|
+
if (typeof value === 'number') {
|
|
38
|
+
return value.toLocaleString('en-US', {
|
|
39
|
+
maximumFractionDigits: decimals,
|
|
40
|
+
minimumFractionDigits: decimals
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return parseFloat(value).toLocaleString('en-US', {
|
|
44
|
+
maximumFractionDigits: decimals,
|
|
45
|
+
minimumFractionDigits: decimals
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
/**
|
|
49
|
+
* Parse a formatted local string back to a number
|
|
50
|
+
* @param value - The formatted string to parse
|
|
51
|
+
* @returns
|
|
52
|
+
*/
|
|
53
|
+
parseLocalStringToNumber(value) {
|
|
54
|
+
if (value === undefined) {
|
|
55
|
+
return 0;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Remove any commas used as thousand separators and parse the float
|
|
59
|
+
return parseFloat(value.replace(/,/gu, ''));
|
|
23
60
|
}
|
|
24
61
|
};
|
|
25
62
|
//# sourceMappingURL=NumberUtil.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BigNumber","NumberUtil","bigNumber","value","multiply","a","b","undefined","aBigNumber","bBigNumber","multipliedBy","roundNumber","number","threshold","fixed","roundedNumber","toString","length","Number","toFixed"],"sourceRoot":"../../../src","sources":["utils/NumberUtil.ts"],"mappings":"AAAA,OAAO,KAAKA,SAAS,MAAM,cAAc;AAEzC,OAAO,MAAMC,UAAU,GAAG;EACxBC,SAASA,CAACC,KAAgC,EAAE;IAC1C,OAAO,IAAIH,SAAS,CAACA,SAAS,CAACG,KAAK,CAAC;EACvC,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;
|
|
1
|
+
{"version":3,"names":["BigNumber","NumberUtil","bigNumber","value","replace","multiply","a","b","undefined","aBigNumber","bBigNumber","multipliedBy","roundNumber","number","threshold","fixed","roundedNumber","toString","length","Number","toFixed","formatNumberToLocalString","decimals","toLocaleString","maximumFractionDigits","minimumFractionDigits","parseFloat","parseLocalStringToNumber"],"sourceRoot":"../../../src","sources":["utils/NumberUtil.ts"],"mappings":"AAAA,OAAO,KAAKA,SAAS,MAAM,cAAc;AAEzC,OAAO,MAAMC,UAAU,GAAG;EACxBC,SAASA,CAACC,KAAgC,EAAE;IAC1C,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;MAC7B,OAAO,IAAIH,SAAS,CAACA,SAAS,CAACG,KAAK,CAACC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACzD;IAEA,OAAO,IAAIJ,SAAS,CAACA,SAAS,CAACG,KAAK,CAAC;EACvC,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;EACEE,QAAQA,CAACC,CAAwC,EAAEC,CAAwC,EAAE;IAC3F,IAAID,CAAC,KAAKE,SAAS,IAAID,CAAC,KAAKC,SAAS,EAAE;MACtC,OAAOR,SAAS,CAACA,SAAS,CAAC,CAAC,CAAC;IAC/B;IAEA,MAAMS,UAAU,G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AAOkB,UAAU,CAACvB,KAAK,CAACC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;EAC7C;AACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NamesUtil.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/NamesUtil.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NumberUtil.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/NumberUtil.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const erc20ABI: {
|
|
1
|
+
export declare const erc20ABI: ({
|
|
2
2
|
type: string;
|
|
3
3
|
name: string;
|
|
4
4
|
stateMutability: string;
|
|
@@ -10,5 +10,21 @@ export declare const erc20ABI: {
|
|
|
10
10
|
name: string;
|
|
11
11
|
type: string;
|
|
12
12
|
}[];
|
|
13
|
-
|
|
13
|
+
constant?: undefined;
|
|
14
|
+
payable?: undefined;
|
|
15
|
+
} | {
|
|
16
|
+
constant: boolean;
|
|
17
|
+
inputs: {
|
|
18
|
+
name: string;
|
|
19
|
+
type: string;
|
|
20
|
+
}[];
|
|
21
|
+
name: string;
|
|
22
|
+
outputs: {
|
|
23
|
+
name: string;
|
|
24
|
+
type: string;
|
|
25
|
+
}[];
|
|
26
|
+
payable: boolean;
|
|
27
|
+
stateMutability: string;
|
|
28
|
+
type: string;
|
|
29
|
+
})[];
|
|
14
30
|
//# sourceMappingURL=erc20.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"erc20.d.ts","sourceRoot":"","sources":["../../../src/contracts/erc20.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ
|
|
1
|
+
{"version":3,"file":"erc20.d.ts","sourceRoot":"","sources":["../../../src/contracts/erc20.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA8FpB,CAAC"}
|
|
@@ -5,6 +5,7 @@ export { NamesUtil } from './utils/NamesUtil';
|
|
|
5
5
|
export { NetworkUtil } from './utils/NetworkUtil';
|
|
6
6
|
export { NumberUtil } from './utils/NumberUtil';
|
|
7
7
|
export { StringUtil } from './utils/StringUtil';
|
|
8
|
+
export { ErrorUtil } from './utils/ErrorUtil';
|
|
8
9
|
export { erc20ABI } from './contracts/erc20';
|
|
9
10
|
export * from './utils/TypeUtil';
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export declare const ErrorUtil: {
|
|
2
|
+
UniversalProviderErrors: {
|
|
3
|
+
UNAUTHORIZED_DOMAIN_NOT_ALLOWED: {
|
|
4
|
+
message: string;
|
|
5
|
+
alertErrorKey: string;
|
|
6
|
+
};
|
|
7
|
+
PROJECT_ID_NOT_CONFIGURED: {
|
|
8
|
+
message: string;
|
|
9
|
+
alertErrorKey: string;
|
|
10
|
+
};
|
|
11
|
+
JWT_VALIDATION_ERROR: {
|
|
12
|
+
message: string;
|
|
13
|
+
alertErrorKey: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
ALERT_ERRORS: {
|
|
17
|
+
INVALID_APP_CONFIGURATION: {
|
|
18
|
+
shortMessage: string;
|
|
19
|
+
longMessage: string;
|
|
20
|
+
};
|
|
21
|
+
SOCIALS_TIMEOUT: {
|
|
22
|
+
shortMessage: string;
|
|
23
|
+
longMessage: string;
|
|
24
|
+
};
|
|
25
|
+
JWT_TOKEN_NOT_VALID: {
|
|
26
|
+
shortMessage: string;
|
|
27
|
+
longMessage: string;
|
|
28
|
+
};
|
|
29
|
+
PROJECT_ID_NOT_CONFIGURED: {
|
|
30
|
+
shortMessage: string;
|
|
31
|
+
longMessage: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=ErrorUtil.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorUtil.d.ts","sourceRoot":"","sources":["../../../src/utils/ErrorUtil.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkCrB,CAAC"}
|
|
@@ -9,5 +9,18 @@ export declare const NumberUtil: {
|
|
|
9
9
|
*/
|
|
10
10
|
multiply(a: BigNumber.BigNumber.Value | undefined, b: BigNumber.BigNumber.Value | undefined): BigNumber.BigNumber;
|
|
11
11
|
roundNumber(number: number, threshold: number, fixed: number): string | number;
|
|
12
|
+
/**
|
|
13
|
+
* Format the given number or string to human readable numbers with the given number of decimals
|
|
14
|
+
* @param value - The value to format. It could be a number or string. If it's a string, it will be parsed to a float then formatted.
|
|
15
|
+
* @param decimals - number of decimals after dot
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
formatNumberToLocalString(value: string | number | undefined, decimals?: number): string;
|
|
19
|
+
/**
|
|
20
|
+
* Parse a formatted local string back to a number
|
|
21
|
+
* @param value - The formatted string to parse
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
parseLocalStringToNumber(value: string | undefined): number;
|
|
12
25
|
};
|
|
13
26
|
//# sourceMappingURL=NumberUtil.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberUtil.d.ts","sourceRoot":"","sources":["../../../src/utils/NumberUtil.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,cAAc,CAAC;AAE1C,eAAO,MAAM,UAAU;qBACJ,mBAAmB,CAAC,KAAK;
|
|
1
|
+
{"version":3,"file":"NumberUtil.d.ts","sourceRoot":"","sources":["../../../src/utils/NumberUtil.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,cAAc,CAAC;AAE1C,eAAO,MAAM,UAAU;qBACJ,mBAAmB,CAAC,KAAK;IAQ1C;;;;;OAKG;gBACS,mBAAmB,CAAC,KAAK,GAAG,SAAS,KAAK,mBAAmB,CAAC,KAAK,GAAG,SAAS;wBAWvE,MAAM,aAAa,MAAM,SAAS,MAAM;IAO5D;;;;;OAKG;qCAC8B,MAAM,GAAG,MAAM,GAAG,SAAS;IAiB5D;;;;OAIG;oCAC6B,MAAM,GAAG,SAAS;CAQnD,CAAC"}
|
|
@@ -74,6 +74,6 @@ export interface TransactionDetail {
|
|
|
74
74
|
export interface TransactionQuantity {
|
|
75
75
|
numeric: string;
|
|
76
76
|
}
|
|
77
|
-
export type SocialProvider = 'apple' | '
|
|
77
|
+
export type SocialProvider = 'apple' | 'x' | 'discord' | 'farcaster';
|
|
78
78
|
export {};
|
|
79
79
|
//# sourceMappingURL=TypeUtil.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeUtil.d.ts","sourceRoot":"","sources":["../../../src/utils/TypeUtil.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,eAAe,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,KAAK,eAAe,GAAG;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG,QAAQ,GAAG,SAAS,CAAC;AACnE,MAAM,MAAM,oBAAoB,GAAG,IAAI,GAAG,KAAK,GAAG,MAAM,CAAC;AACzD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,UAAU,GAAG,KAAK,GAAG,SAAS,CAAC;IACrC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;CACzB,CAAC;AAEF,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,SAAS,EAAE,mBAAmB,EAAE,CAAC;CAClC;AAED,MAAM,WAAW,mBA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Util, NamesUtil } from '../index';
|
|
2
|
+
|
|
3
|
+
describe('NamesUtil', () => {
|
|
4
|
+
describe('isReownName', () => {
|
|
5
|
+
test('returns true for names ending with legacy suffix', () => {
|
|
6
|
+
const legacyName = `testname${ConstantsUtil.WC_NAME_SUFFIX_LEGACY}`;
|
|
7
|
+
expect(NamesUtil.isReownName(legacyName)).toBe(true);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
test('returns true for names ending with current suffix', () => {
|
|
11
|
+
const currentName = `testname${ConstantsUtil.WC_NAME_SUFFIX}`;
|
|
12
|
+
expect(NamesUtil.isReownName(currentName)).toBe(true);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test('returns false for names not ending with either suffix', () => {
|
|
16
|
+
expect(NamesUtil.isReownName('testname')).toBe(false);
|
|
17
|
+
expect(NamesUtil.isReownName('testname.com')).toBe(false);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test('returns false for empty string', () => {
|
|
21
|
+
expect(NamesUtil.isReownName('')).toBe(false);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { NumberUtil } from '../utils/NumberUtil';
|
|
2
|
+
|
|
3
|
+
// -- Tests --------------------------------------------------------------------
|
|
4
|
+
describe('NumberUtil', () => {
|
|
5
|
+
it('should return isGreaterThan as expected', () => {
|
|
6
|
+
const isGreaterThan = NumberUtil.bigNumber('6.348').isGreaterThan('0');
|
|
7
|
+
expect(isGreaterThan).toBe(true);
|
|
8
|
+
});
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
describe('NumberUtil.parseLocalStringToNumber', () => {
|
|
12
|
+
it('should return 0 when value is undefined', () => {
|
|
13
|
+
const result = NumberUtil.parseLocalStringToNumber(undefined);
|
|
14
|
+
expect(result).toBe(0);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('should return the number when value is a string', () => {
|
|
18
|
+
const result = NumberUtil.parseLocalStringToNumber('123.45');
|
|
19
|
+
expect(result).toBe(123.45);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should return the number when value is a string with a lot of decimals', () => {
|
|
23
|
+
const result = NumberUtil.parseLocalStringToNumber('123.4567890123456789');
|
|
24
|
+
expect(result).toBe(123.4567890123456789);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('should return the number when value is a string with zero and a lot of decimals', () => {
|
|
28
|
+
const result = NumberUtil.parseLocalStringToNumber('0.000000000000000001');
|
|
29
|
+
expect(result).toBe(0.000000000000000001);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('should return the number when value is a string with a negative sign', () => {
|
|
33
|
+
const result = NumberUtil.parseLocalStringToNumber('-123.45');
|
|
34
|
+
expect(result).toBe(-123.45);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should return the number when value is a string with commas', () => {
|
|
38
|
+
const result = NumberUtil.parseLocalStringToNumber('123,456.78');
|
|
39
|
+
expect(result).toBe(123456.78);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('should return the number when value is a string with a lot of commas', () => {
|
|
43
|
+
const result = NumberUtil.parseLocalStringToNumber('123,456,789.123,456,789');
|
|
44
|
+
expect(result).toBe(123456789.123456789);
|
|
45
|
+
});
|
|
46
|
+
});
|
package/src/contracts/erc20.ts
CHANGED
|
@@ -44,5 +44,52 @@ export const erc20ABI = [
|
|
|
44
44
|
type: 'bool'
|
|
45
45
|
}
|
|
46
46
|
]
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
constant: true,
|
|
50
|
+
inputs: [],
|
|
51
|
+
name: 'symbol',
|
|
52
|
+
outputs: [
|
|
53
|
+
{
|
|
54
|
+
name: '',
|
|
55
|
+
type: 'string'
|
|
56
|
+
}
|
|
57
|
+
],
|
|
58
|
+
payable: false,
|
|
59
|
+
stateMutability: 'view',
|
|
60
|
+
type: 'function'
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
constant: true,
|
|
64
|
+
inputs: [],
|
|
65
|
+
name: 'decimals',
|
|
66
|
+
outputs: [
|
|
67
|
+
{
|
|
68
|
+
name: '',
|
|
69
|
+
type: 'uint8'
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
payable: false,
|
|
73
|
+
stateMutability: 'view',
|
|
74
|
+
type: 'function'
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
constant: true,
|
|
78
|
+
inputs: [
|
|
79
|
+
{
|
|
80
|
+
name: '_owner',
|
|
81
|
+
type: 'address'
|
|
82
|
+
}
|
|
83
|
+
],
|
|
84
|
+
name: 'balanceOf',
|
|
85
|
+
outputs: [
|
|
86
|
+
{
|
|
87
|
+
name: 'balance',
|
|
88
|
+
type: 'uint256'
|
|
89
|
+
}
|
|
90
|
+
],
|
|
91
|
+
payable: false,
|
|
92
|
+
stateMutability: 'view',
|
|
93
|
+
type: 'function'
|
|
47
94
|
}
|
|
48
95
|
];
|
package/src/index.ts
CHANGED
|
@@ -5,5 +5,6 @@ export { NamesUtil } from './utils/NamesUtil';
|
|
|
5
5
|
export { NetworkUtil } from './utils/NetworkUtil';
|
|
6
6
|
export { NumberUtil } from './utils/NumberUtil';
|
|
7
7
|
export { StringUtil } from './utils/StringUtil';
|
|
8
|
+
export { ErrorUtil } from './utils/ErrorUtil';
|
|
8
9
|
export { erc20ABI } from './contracts/erc20';
|
|
9
10
|
export * from './utils/TypeUtil';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export const ErrorUtil = {
|
|
2
|
+
UniversalProviderErrors: {
|
|
3
|
+
UNAUTHORIZED_DOMAIN_NOT_ALLOWED: {
|
|
4
|
+
message: 'Unauthorized: origin not allowed',
|
|
5
|
+
alertErrorKey: 'INVALID_APP_CONFIGURATION'
|
|
6
|
+
},
|
|
7
|
+
PROJECT_ID_NOT_CONFIGURED: {
|
|
8
|
+
message: 'Project ID is missing',
|
|
9
|
+
alertErrorKey: 'PROJECT_ID_NOT_CONFIGURED'
|
|
10
|
+
},
|
|
11
|
+
JWT_VALIDATION_ERROR: {
|
|
12
|
+
message: 'JWT validation error: JWT Token is not yet valid',
|
|
13
|
+
alertErrorKey: 'JWT_TOKEN_NOT_VALID'
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
ALERT_ERRORS: {
|
|
17
|
+
INVALID_APP_CONFIGURATION: {
|
|
18
|
+
shortMessage: 'Invalid App Configuration',
|
|
19
|
+
longMessage: `Bundle ID not found on Allowlist - Please verify that your bundle ID is allowed at https://cloud.reown.com`
|
|
20
|
+
},
|
|
21
|
+
SOCIALS_TIMEOUT: {
|
|
22
|
+
shortMessage: 'Invalid App Configuration',
|
|
23
|
+
longMessage:
|
|
24
|
+
'There was an issue loading the embedded wallet. Please verify that your bundle ID is allowed at https://cloud.reown.com'
|
|
25
|
+
},
|
|
26
|
+
JWT_TOKEN_NOT_VALID: {
|
|
27
|
+
shortMessage: 'Session Expired',
|
|
28
|
+
longMessage: 'Invalid session found - please check your time settings and connect again'
|
|
29
|
+
},
|
|
30
|
+
PROJECT_ID_NOT_CONFIGURED: {
|
|
31
|
+
shortMessage: 'Project ID Not Configured',
|
|
32
|
+
longMessage: 'Project ID Not Configured - update configuration'
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
package/src/utils/NumberUtil.ts
CHANGED
|
@@ -2,6 +2,10 @@ import * as BigNumber from 'bignumber.js';
|
|
|
2
2
|
|
|
3
3
|
export const NumberUtil = {
|
|
4
4
|
bigNumber(value: BigNumber.BigNumber.Value) {
|
|
5
|
+
if (typeof value === 'string') {
|
|
6
|
+
return new BigNumber.BigNumber(value.replace(/,/g, ''));
|
|
7
|
+
}
|
|
8
|
+
|
|
5
9
|
return new BigNumber.BigNumber(value);
|
|
6
10
|
},
|
|
7
11
|
|
|
@@ -16,8 +20,8 @@ export const NumberUtil = {
|
|
|
16
20
|
return BigNumber.BigNumber(0);
|
|
17
21
|
}
|
|
18
22
|
|
|
19
|
-
const aBigNumber = new BigNumber.BigNumber(a);
|
|
20
|
-
const bBigNumber = new BigNumber.BigNumber(b);
|
|
23
|
+
const aBigNumber = new BigNumber.BigNumber(typeof a === 'string' ? a.replace(/,/gu, '') : a);
|
|
24
|
+
const bBigNumber = new BigNumber.BigNumber(typeof b === 'string' ? b.replace(/,/gu, '') : b);
|
|
21
25
|
|
|
22
26
|
return aBigNumber.multipliedBy(bBigNumber);
|
|
23
27
|
},
|
|
@@ -27,5 +31,42 @@ export const NumberUtil = {
|
|
|
27
31
|
number.toString().length >= threshold ? Number(number).toFixed(fixed) : number;
|
|
28
32
|
|
|
29
33
|
return roundedNumber;
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Format the given number or string to human readable numbers with the given number of decimals
|
|
38
|
+
* @param value - The value to format. It could be a number or string. If it's a string, it will be parsed to a float then formatted.
|
|
39
|
+
* @param decimals - number of decimals after dot
|
|
40
|
+
* @returns
|
|
41
|
+
*/
|
|
42
|
+
formatNumberToLocalString(value: string | number | undefined, decimals = 2) {
|
|
43
|
+
if (value === undefined) {
|
|
44
|
+
return '0.00';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (typeof value === 'number') {
|
|
48
|
+
return value.toLocaleString('en-US', {
|
|
49
|
+
maximumFractionDigits: decimals,
|
|
50
|
+
minimumFractionDigits: decimals
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return parseFloat(value).toLocaleString('en-US', {
|
|
55
|
+
maximumFractionDigits: decimals,
|
|
56
|
+
minimumFractionDigits: decimals
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
/**
|
|
60
|
+
* Parse a formatted local string back to a number
|
|
61
|
+
* @param value - The formatted string to parse
|
|
62
|
+
* @returns
|
|
63
|
+
*/
|
|
64
|
+
parseLocalStringToNumber(value: string | undefined) {
|
|
65
|
+
if (value === undefined) {
|
|
66
|
+
return 0;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Remove any commas used as thousand separators and parse the float
|
|
70
|
+
return parseFloat(value.replace(/,/gu, ''));
|
|
30
71
|
}
|
|
31
72
|
};
|
package/src/utils/TypeUtil.ts
CHANGED