@railgun-community/shared-models 1.0.3

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.
Files changed (47) hide show
  1. package/README.md +5 -0
  2. package/dist/models/artifact.d.ts +36 -0
  3. package/dist/models/artifact.js +53 -0
  4. package/dist/models/artifact.js.map +1 -0
  5. package/dist/models/blocked-address.d.ts +1 -0
  6. package/dist/models/blocked-address.js +46 -0
  7. package/dist/models/blocked-address.js.map +1 -0
  8. package/dist/models/fallback-provider.d.ts +11 -0
  9. package/dist/models/fallback-provider.js +38 -0
  10. package/dist/models/fallback-provider.js.map +1 -0
  11. package/dist/models/fee-token.d.ts +4 -0
  12. package/dist/models/fee-token.js +3 -0
  13. package/dist/models/fee-token.js.map +1 -0
  14. package/dist/models/function-types.d.ts +2 -0
  15. package/dist/models/function-types.js +3 -0
  16. package/dist/models/function-types.js.map +1 -0
  17. package/dist/models/merkletree-scan.d.ts +6 -0
  18. package/dist/models/merkletree-scan.js +11 -0
  19. package/dist/models/merkletree-scan.js.map +1 -0
  20. package/dist/models/network-config.d.ts +76 -0
  21. package/dist/models/network-config.js +208 -0
  22. package/dist/models/network-config.js.map +1 -0
  23. package/dist/models/proof.d.ts +6 -0
  24. package/dist/models/proof.js +11 -0
  25. package/dist/models/proof.js.map +1 -0
  26. package/dist/models/response-types.d.ts +130 -0
  27. package/dist/models/response-types.js +8 -0
  28. package/dist/models/response-types.js.map +1 -0
  29. package/dist/models/transaction.d.ts +4 -0
  30. package/dist/models/transaction.js +3 -0
  31. package/dist/models/transaction.js.map +1 -0
  32. package/dist/models/wallet.d.ts +5 -0
  33. package/dist/models/wallet.js +10 -0
  34. package/dist/models/wallet.js.map +1 -0
  35. package/dist/utils/compare.d.ts +2 -0
  36. package/dist/utils/compare.js +8 -0
  37. package/dist/utils/compare.js.map +1 -0
  38. package/dist/utils/error.d.ts +1 -0
  39. package/dist/utils/error.js +49 -0
  40. package/dist/utils/error.js.map +1 -0
  41. package/dist/utils/gas.d.ts +5 -0
  42. package/dist/utils/gas.js +33 -0
  43. package/dist/utils/gas.js.map +1 -0
  44. package/dist/utils/serializer.d.ts +4 -0
  45. package/dist/utils/serializer.js +39 -0
  46. package/dist/utils/serializer.js.map +1 -0
  47. package/package.json +36 -0
package/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # Shared TypeScript models, types and various utils for RAILGUN SDKs
2
+
3
+ Compatible with browser, node and React environments.
4
+
5
+ `yarn add @railgun-community/shared-models`
@@ -0,0 +1,36 @@
1
+ /// <reference types="node" />
2
+ export declare enum ArtifactName {
3
+ ZKEY = "zkey",
4
+ WASM = "wasm",
5
+ VKEY = "vkey",
6
+ DAT = "dat"
7
+ }
8
+ export declare enum ArtifactVariant {
9
+ Variant_8_by_2 = "8x2",
10
+ Variant_2_by_3 = "2x3",
11
+ Variant_2_by_2 = "2x2",
12
+ Variant_1_by_3 = "1x3",
13
+ Variant_1_by_2 = "1x2"
14
+ }
15
+ export declare type ArtifactGroup = {
16
+ [ArtifactName.ZKEY]: Buffer;
17
+ [ArtifactName.VKEY]: object;
18
+ [ArtifactName.WASM]: Optional<Buffer>;
19
+ [ArtifactName.DAT]: Optional<Buffer>;
20
+ };
21
+ export declare type ArtifactMapping = {
22
+ [ArtifactName.ZKEY]: string;
23
+ [ArtifactName.WASM]: string;
24
+ [ArtifactName.VKEY]: string;
25
+ [ArtifactName.DAT]: string;
26
+ };
27
+ export declare type ArtifactDownloadedGroup = {
28
+ [ArtifactName.ZKEY]: boolean;
29
+ [ArtifactName.WASM]: boolean;
30
+ [ArtifactName.VKEY]: boolean;
31
+ [ArtifactName.DAT]: boolean;
32
+ };
33
+ export declare type ArtifactVariantMapping = {
34
+ [artifactVariant in ArtifactVariant]: ArtifactMapping;
35
+ };
36
+ export declare const ARTIFACT_URL_PATHS_VARIANTS_V1: ArtifactVariantMapping;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var _a, _b, _c, _d, _e, _f;
3
+ exports.__esModule = true;
4
+ exports.ARTIFACT_URL_PATHS_VARIANTS_V1 = exports.ArtifactVariant = exports.ArtifactName = void 0;
5
+ var ArtifactName;
6
+ (function (ArtifactName) {
7
+ ArtifactName["ZKEY"] = "zkey";
8
+ ArtifactName["WASM"] = "wasm";
9
+ ArtifactName["VKEY"] = "vkey";
10
+ ArtifactName["DAT"] = "dat";
11
+ })(ArtifactName = exports.ArtifactName || (exports.ArtifactName = {}));
12
+ var ArtifactVariant;
13
+ (function (ArtifactVariant) {
14
+ ArtifactVariant["Variant_8_by_2"] = "8x2";
15
+ ArtifactVariant["Variant_2_by_3"] = "2x3";
16
+ ArtifactVariant["Variant_2_by_2"] = "2x2";
17
+ ArtifactVariant["Variant_1_by_3"] = "1x3";
18
+ ArtifactVariant["Variant_1_by_2"] = "1x2";
19
+ })(ArtifactVariant = exports.ArtifactVariant || (exports.ArtifactVariant = {}));
20
+ // Files hosted at https://beacon.railgun.ch/<URL_PATH>
21
+ exports.ARTIFACT_URL_PATHS_VARIANTS_V1 = (_a = {},
22
+ _a[ArtifactVariant.Variant_1_by_2] = (_b = {},
23
+ _b[ArtifactName.VKEY] = 'artifacts_v1/1-2/vkey.json',
24
+ _b[ArtifactName.ZKEY] = 'artifacts_v1/1-2/zkey.br',
25
+ _b[ArtifactName.WASM] = 'artifacts_v1/1-2/wasm.br',
26
+ _b[ArtifactName.DAT] = 'artifacts_v1/1-2/native.br',
27
+ _b),
28
+ _a[ArtifactVariant.Variant_1_by_3] = (_c = {},
29
+ _c[ArtifactName.VKEY] = 'artifacts_v1/1-3/vkey.json',
30
+ _c[ArtifactName.ZKEY] = 'artifacts_v1/1-3/zkey.br',
31
+ _c[ArtifactName.WASM] = 'artifacts_v1/1-3/wasm.br',
32
+ _c[ArtifactName.DAT] = 'artifacts_v1/1-3/native.br',
33
+ _c),
34
+ _a[ArtifactVariant.Variant_2_by_2] = (_d = {},
35
+ _d[ArtifactName.VKEY] = 'artifacts_v1/2-2/vkey.json',
36
+ _d[ArtifactName.ZKEY] = 'artifacts_v1/2-2/zkey.br',
37
+ _d[ArtifactName.WASM] = 'artifacts_v1/2-2/wasm.br',
38
+ _d[ArtifactName.DAT] = 'artifacts_v1/2-2/native.br',
39
+ _d),
40
+ _a[ArtifactVariant.Variant_2_by_3] = (_e = {},
41
+ _e[ArtifactName.VKEY] = 'artifacts_v1/2-3/vkey.json',
42
+ _e[ArtifactName.ZKEY] = 'artifacts_v1/2-3/zkey.br',
43
+ _e[ArtifactName.WASM] = 'artifacts_v1/2-3/wasm.br',
44
+ _e[ArtifactName.DAT] = 'artifacts_v1/2-3/native.br',
45
+ _e),
46
+ _a[ArtifactVariant.Variant_8_by_2] = (_f = {},
47
+ _f[ArtifactName.VKEY] = 'artifacts_v1/8-2/vkey.json',
48
+ _f[ArtifactName.ZKEY] = 'artifacts_v1/8-2/zkey.br',
49
+ _f[ArtifactName.WASM] = 'artifacts_v1/8-2/wasm.br',
50
+ _f[ArtifactName.DAT] = 'artifacts_v1/8-2/native.br',
51
+ _f),
52
+ _a);
53
+ //# sourceMappingURL=artifact.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"artifact.js","sourceRoot":"","sources":["../../src/models/artifact.ts"],"names":[],"mappings":";;;;AAAA,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,6BAAa,CAAA;IACb,6BAAa,CAAA;IACb,6BAAa,CAAA;IACb,2BAAW,CAAA;AACb,CAAC,EALW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAKvB;AAED,IAAY,eAMX;AAND,WAAY,eAAe;IACzB,yCAAsB,CAAA;IACtB,yCAAsB,CAAA;IACtB,yCAAsB,CAAA;IACtB,yCAAsB,CAAA;IACtB,yCAAsB,CAAA;AACxB,CAAC,EANW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAM1B;AA2BD,uDAAuD;AAC1C,QAAA,8BAA8B;IACzC,GAAC,eAAe,CAAC,cAAc;QAC7B,GAAC,YAAY,CAAC,IAAI,IAAG,4BAA4B;QACjD,GAAC,YAAY,CAAC,IAAI,IAAG,0BAA0B;QAC/C,GAAC,YAAY,CAAC,IAAI,IAAG,0BAA0B;QAC/C,GAAC,YAAY,CAAC,GAAG,IAAG,4BAA4B;WACjD;IACD,GAAC,eAAe,CAAC,cAAc;QAC7B,GAAC,YAAY,CAAC,IAAI,IAAG,4BAA4B;QACjD,GAAC,YAAY,CAAC,IAAI,IAAG,0BAA0B;QAC/C,GAAC,YAAY,CAAC,IAAI,IAAG,0BAA0B;QAC/C,GAAC,YAAY,CAAC,GAAG,IAAG,4BAA4B;WACjD;IACD,GAAC,eAAe,CAAC,cAAc;QAC7B,GAAC,YAAY,CAAC,IAAI,IAAG,4BAA4B;QACjD,GAAC,YAAY,CAAC,IAAI,IAAG,0BAA0B;QAC/C,GAAC,YAAY,CAAC,IAAI,IAAG,0BAA0B;QAC/C,GAAC,YAAY,CAAC,GAAG,IAAG,4BAA4B;WACjD;IACD,GAAC,eAAe,CAAC,cAAc;QAC7B,GAAC,YAAY,CAAC,IAAI,IAAG,4BAA4B;QACjD,GAAC,YAAY,CAAC,IAAI,IAAG,0BAA0B;QAC/C,GAAC,YAAY,CAAC,IAAI,IAAG,0BAA0B;QAC/C,GAAC,YAAY,CAAC,GAAG,IAAG,4BAA4B;WACjD;IACD,GAAC,eAAe,CAAC,cAAc;QAC7B,GAAC,YAAY,CAAC,IAAI,IAAG,4BAA4B;QACjD,GAAC,YAAY,CAAC,IAAI,IAAG,0BAA0B;QAC/C,GAAC,YAAY,CAAC,IAAI,IAAG,0BAA0B;QAC/C,GAAC,YAAY,CAAC,GAAG,IAAG,4BAA4B;WACjD;QACD","sourcesContent":["export enum ArtifactName {\n ZKEY = 'zkey',\n WASM = 'wasm',\n VKEY = 'vkey',\n DAT = 'dat',\n}\n\nexport enum ArtifactVariant {\n Variant_8_by_2 = '8x2',\n Variant_2_by_3 = '2x3',\n Variant_2_by_2 = '2x2',\n Variant_1_by_3 = '1x3',\n Variant_1_by_2 = '1x2',\n}\n\nexport type ArtifactGroup = {\n [ArtifactName.ZKEY]: Buffer;\n [ArtifactName.VKEY]: object;\n [ArtifactName.WASM]: Optional<Buffer>;\n [ArtifactName.DAT]: Optional<Buffer>;\n};\n\nexport type ArtifactMapping = {\n [ArtifactName.ZKEY]: string;\n [ArtifactName.WASM]: string;\n [ArtifactName.VKEY]: string;\n [ArtifactName.DAT]: string;\n};\n\nexport type ArtifactDownloadedGroup = {\n [ArtifactName.ZKEY]: boolean;\n [ArtifactName.WASM]: boolean;\n [ArtifactName.VKEY]: boolean;\n [ArtifactName.DAT]: boolean;\n};\n\nexport type ArtifactVariantMapping = {\n [artifactVariant in ArtifactVariant]: ArtifactMapping;\n};\n\n// Files hosted at https://beacon.railgun.ch/<URL_PATH>\nexport const ARTIFACT_URL_PATHS_VARIANTS_V1: ArtifactVariantMapping = {\n [ArtifactVariant.Variant_1_by_2]: {\n [ArtifactName.VKEY]: 'artifacts_v1/1-2/vkey.json',\n [ArtifactName.ZKEY]: 'artifacts_v1/1-2/zkey.br',\n [ArtifactName.WASM]: 'artifacts_v1/1-2/wasm.br',\n [ArtifactName.DAT]: 'artifacts_v1/1-2/native.br',\n },\n [ArtifactVariant.Variant_1_by_3]: {\n [ArtifactName.VKEY]: 'artifacts_v1/1-3/vkey.json',\n [ArtifactName.ZKEY]: 'artifacts_v1/1-3/zkey.br',\n [ArtifactName.WASM]: 'artifacts_v1/1-3/wasm.br',\n [ArtifactName.DAT]: 'artifacts_v1/1-3/native.br',\n },\n [ArtifactVariant.Variant_2_by_2]: {\n [ArtifactName.VKEY]: 'artifacts_v1/2-2/vkey.json',\n [ArtifactName.ZKEY]: 'artifacts_v1/2-2/zkey.br',\n [ArtifactName.WASM]: 'artifacts_v1/2-2/wasm.br',\n [ArtifactName.DAT]: 'artifacts_v1/2-2/native.br',\n },\n [ArtifactVariant.Variant_2_by_3]: {\n [ArtifactName.VKEY]: 'artifacts_v1/2-3/vkey.json',\n [ArtifactName.ZKEY]: 'artifacts_v1/2-3/zkey.br',\n [ArtifactName.WASM]: 'artifacts_v1/2-3/wasm.br',\n [ArtifactName.DAT]: 'artifacts_v1/2-3/native.br',\n },\n [ArtifactVariant.Variant_8_by_2]: {\n [ArtifactName.VKEY]: 'artifacts_v1/8-2/vkey.json',\n [ArtifactName.ZKEY]: 'artifacts_v1/8-2/zkey.br',\n [ArtifactName.WASM]: 'artifacts_v1/8-2/wasm.br',\n [ArtifactName.DAT]: 'artifacts_v1/8-2/native.br',\n },\n};\n"]}
@@ -0,0 +1 @@
1
+ export declare const OFAC_TORNADO_CASH_SANCTIONS_LIST_ETH_ADDRESS: string[];
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ // NOTE: ENSURE ALL BLOCKED ADDRESSES ARE ENTIRELY LOWERCASE.
3
+ exports.__esModule = true;
4
+ exports.OFAC_TORNADO_CASH_SANCTIONS_LIST_ETH_ADDRESS = void 0;
5
+ exports.OFAC_TORNADO_CASH_SANCTIONS_LIST_ETH_ADDRESS = [
6
+ '0x8589427373d6d84e98730d7795d8f6f8731fda16',
7
+ '0x722122df12d4e14e13ac3b6895a86e84145b6967',
8
+ '0xdd4c48c0b24039969fc16d1cdf626eab821d3384',
9
+ '0xd90e2f925da726b50c4ed8d0fb90ad053324f31b',
10
+ '0xd96f2b1c14db8458374d9aca76e26c3d18364307',
11
+ '0x4736dcf1b7a3d580672cce6e7c65cd5cc9cfba9d',
12
+ '0xd4b88df4d29f5cedd6857912842cff3b20c8cfa3',
13
+ '0x910cbd523d972eb0a6f4cae4618ad62622b39dbf',
14
+ '0xa160cdab225685da1d56aa342ad8841c3b53f291',
15
+ '0xfd8610d20aa15b7b2e3be39b396a1bc3516c7144',
16
+ '0xf60dd140cff0706bae9cd734ac3ae76ad9ebc32a',
17
+ '0x22aaa7720ddd5388a3c0a3333430953c68f1849b',
18
+ '0xba214c1c1928a32bffe790263e38b4af9bfcd659',
19
+ '0xb1c8094b234dce6e03f10a5b673c1d8c69739a00',
20
+ '0x527653ea119f3e6a1f5bd18fbf4714081d7b31ce',
21
+ '0x58e8dcc13be9780fc42e8723d8ead4cf46943df2',
22
+ '0xd691f27f38b395864ea86cfc7253969b409c362d',
23
+ '0xaeaac358560e11f52454d997aaff2c5731b6f8a6',
24
+ '0x1356c899d8c9467c7f71c195612f8a395abf2f0a',
25
+ '0xa60c772958a3ed56c1f15dd055ba37ac8e523a0d',
26
+ '0x169ad27a470d064dede56a2d3ff727986b15d52b',
27
+ '0x0836222f2b2b24a3f36f98668ed8f0b38d1a872f',
28
+ '0xf67721a2d8f736e75a49fdd7fad2e31d8676542a',
29
+ '0x9ad122c22b14202b4490edaf288fdb3c7cb3ff5e',
30
+ '0x905b63fff465b9ffbf41dea908ceb12478ec7601',
31
+ '0x07687e702b410fa43f4cb4af7fa097918ffd2730',
32
+ '0x94a1b5cdb22c43faab4abeb5c74999895464ddaf',
33
+ '0xb541fc07bc7619fd4062a54d96268525cbc6ffef',
34
+ '0xd21be7248e0197ee08e0c20d4a96debdac3d20af',
35
+ '0x12d66f87a04a9e220743712ce6d9bb1b5616b8fc',
36
+ '0x47ce0c6ed5b0ce3d3a51fdb1c52dc66a7c3c2936',
37
+ '0x23773e65ed146a459791799d01336db287f25334',
38
+ '0x610b717796ad172b316836ac95a2ffad065ceab4',
39
+ '0x178169b423a011fff22b9e3f3abea13414ddd0f1',
40
+ '0xbb93e510bbcd0b7beb5a853875f9ec60275cf498',
41
+ '0x2717c5e28cf931547b621a5dddb772ab6a35b701',
42
+ '0x03893a7c7463ae47d46bc7f091665f1893656003',
43
+ '0xca0840578f57fe71599d29375e16783424023357',
44
+ '0x58e8dcc13be9780fc42e8723d8ead4cf46943df2',
45
+ ];
46
+ //# sourceMappingURL=blocked-address.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blocked-address.js","sourceRoot":"","sources":["../../src/models/blocked-address.ts"],"names":[],"mappings":";AAAA,6DAA6D;;;AAEhD,QAAA,4CAA4C,GAAG;IAC1D,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;CAC7C,CAAC","sourcesContent":["// NOTE: ENSURE ALL BLOCKED ADDRESSES ARE ENTIRELY LOWERCASE.\n\nexport const OFAC_TORNADO_CASH_SANCTIONS_LIST_ETH_ADDRESS = [\n '0x8589427373d6d84e98730d7795d8f6f8731fda16',\n '0x722122df12d4e14e13ac3b6895a86e84145b6967',\n '0xdd4c48c0b24039969fc16d1cdf626eab821d3384',\n '0xd90e2f925da726b50c4ed8d0fb90ad053324f31b',\n '0xd96f2b1c14db8458374d9aca76e26c3d18364307',\n '0x4736dcf1b7a3d580672cce6e7c65cd5cc9cfba9d',\n '0xd4b88df4d29f5cedd6857912842cff3b20c8cfa3',\n '0x910cbd523d972eb0a6f4cae4618ad62622b39dbf',\n '0xa160cdab225685da1d56aa342ad8841c3b53f291',\n '0xfd8610d20aa15b7b2e3be39b396a1bc3516c7144',\n '0xf60dd140cff0706bae9cd734ac3ae76ad9ebc32a',\n '0x22aaa7720ddd5388a3c0a3333430953c68f1849b',\n '0xba214c1c1928a32bffe790263e38b4af9bfcd659',\n '0xb1c8094b234dce6e03f10a5b673c1d8c69739a00',\n '0x527653ea119f3e6a1f5bd18fbf4714081d7b31ce',\n '0x58e8dcc13be9780fc42e8723d8ead4cf46943df2',\n '0xd691f27f38b395864ea86cfc7253969b409c362d',\n '0xaeaac358560e11f52454d997aaff2c5731b6f8a6',\n '0x1356c899d8c9467c7f71c195612f8a395abf2f0a',\n '0xa60c772958a3ed56c1f15dd055ba37ac8e523a0d',\n '0x169ad27a470d064dede56a2d3ff727986b15d52b',\n '0x0836222f2b2b24a3f36f98668ed8f0b38d1a872f',\n '0xf67721a2d8f736e75a49fdd7fad2e31d8676542a',\n '0x9ad122c22b14202b4490edaf288fdb3c7cb3ff5e',\n '0x905b63fff465b9ffbf41dea908ceb12478ec7601',\n '0x07687e702b410fa43f4cb4af7fa097918ffd2730',\n '0x94a1b5cdb22c43faab4abeb5c74999895464ddaf',\n '0xb541fc07bc7619fd4062a54d96268525cbc6ffef',\n '0xd21be7248e0197ee08e0c20d4a96debdac3d20af',\n '0x12d66f87a04a9e220743712ce6d9bb1b5616b8fc',\n '0x47ce0c6ed5b0ce3d3a51fdb1c52dc66a7c3c2936',\n '0x23773e65ed146a459791799d01336db287f25334',\n '0x610b717796ad172b316836ac95a2ffad065ceab4',\n '0x178169b423a011fff22b9e3f3abea13414ddd0f1',\n '0xbb93e510bbcd0b7beb5a853875f9ec60275cf498',\n '0x2717c5e28cf931547b621a5dddb772ab6a35b701',\n '0x03893a7c7463ae47d46bc7f091665f1893656003',\n '0xca0840578f57fe71599d29375e16783424023357',\n '0x58e8dcc13be9780fc42e8723d8ead4cf46943df2',\n];\n"]}
@@ -0,0 +1,11 @@
1
+ import { FallbackProvider } from '@ethersproject/providers';
2
+ export declare type FallbackProviderJsonConfig = {
3
+ chainId: number;
4
+ providers: ProviderJson[];
5
+ };
6
+ export declare type ProviderJson = {
7
+ priority: number;
8
+ weight: number;
9
+ provider: string;
10
+ };
11
+ export declare const createFallbackProviderFromJsonConfig: (config: FallbackProviderJsonConfig, debugMessage?: ((msg: string) => void) | undefined) => FallbackProvider;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ exports.__esModule = true;
14
+ exports.createFallbackProviderFromJsonConfig = void 0;
15
+ var providers_1 = require("@ethersproject/providers");
16
+ var createFallbackProviderFromJsonConfig = function (config, debugMessage) {
17
+ var providers = config.providers.map(function (json) {
18
+ var isWebsocket = json.provider.startsWith('wss');
19
+ var provider = isWebsocket
20
+ ? new providers_1.WebSocketProvider(json.provider, Number(config.chainId))
21
+ : new providers_1.StaticJsonRpcProvider(json.provider, Number(config.chainId));
22
+ if (debugMessage) {
23
+ provider.on('debug', function (debug) {
24
+ if (debug.backend && debug.backend.error) {
25
+ debugMessage("Provider error: ".concat(debug.backend.error));
26
+ debugMessage("Provider connection: ".concat(debug.backend.provider
27
+ ? debug.backend.provider.connection
28
+ : undefined));
29
+ }
30
+ });
31
+ }
32
+ return __assign(__assign({}, json), { provider: provider });
33
+ });
34
+ var quorum = 1;
35
+ return new providers_1.FallbackProvider(providers, quorum);
36
+ };
37
+ exports.createFallbackProviderFromJsonConfig = createFallbackProviderFromJsonConfig;
38
+ //# sourceMappingURL=fallback-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fallback-provider.js","sourceRoot":"","sources":["../../src/models/fallback-provider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,sDAIkC;AA4B3B,IAAM,oCAAoC,GAAG,UAClD,MAAkC,EAClC,YAAoC;IAEpC,IAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,UAAA,IAAI;QACzC,IAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QACpD,IAAM,QAAQ,GAAG,WAAW;YAC1B,CAAC,CAAC,IAAI,6BAAiB,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAC9D,CAAC,CAAC,IAAI,iCAAqB,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;QAErE,IAAI,YAAY,EAAE;YAChB,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,UAAC,KAAoB;gBACxC,IAAI,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE;oBACxC,YAAY,CAAC,0BAAmB,KAAK,CAAC,OAAO,CAAC,KAAK,CAAE,CAAC,CAAC;oBACvD,YAAY,CACV,+BACE,KAAK,CAAC,OAAO,CAAC,QAAQ;wBACpB,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU;wBACnC,CAAC,CAAC,SAAS,CACb,CACH,CAAC;iBACH;YACH,CAAC,CAAC,CAAC;SACJ;QAED,6BACK,IAAI,KACP,QAAQ,UAAA,IACR;IACJ,CAAC,CAAC,CAAC;IAEH,IAAM,MAAM,GAAG,CAAC,CAAC;IACjB,OAAO,IAAI,4BAAgB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;AACjD,CAAC,CAAC;AAjCW,QAAA,oCAAoC,wCAiC/C","sourcesContent":["import {\n FallbackProvider,\n StaticJsonRpcProvider,\n WebSocketProvider,\n} from '@ethersproject/providers';\n\nexport type FallbackProviderJsonConfig = {\n chainId: number;\n providers: ProviderJson[];\n};\n\nexport type ProviderJson = {\n priority: number;\n weight: number;\n provider: string;\n};\n\ntype ProviderDebug = {\n action: string;\n rid: number;\n backend: {\n weight: number;\n start: number;\n duration: number;\n result?: string[];\n error?: typeof Error;\n provider?: StaticJsonRpcProvider;\n };\n request: { method: string; params: { filter?: object } };\n provider: FallbackProvider;\n};\n\nexport const createFallbackProviderFromJsonConfig = (\n config: FallbackProviderJsonConfig,\n debugMessage?: (msg: string) => void,\n): FallbackProvider => {\n const providers = config.providers.map(json => {\n const isWebsocket = json.provider.startsWith('wss');\n const provider = isWebsocket\n ? new WebSocketProvider(json.provider, Number(config.chainId))\n : new StaticJsonRpcProvider(json.provider, Number(config.chainId));\n\n if (debugMessage) {\n provider.on('debug', (debug: ProviderDebug) => {\n if (debug.backend && debug.backend.error) {\n debugMessage(`Provider error: ${debug.backend.error}`);\n debugMessage(\n `Provider connection: ${\n debug.backend.provider\n ? debug.backend.provider.connection\n : undefined\n }`,\n );\n }\n });\n }\n\n return {\n ...json,\n provider,\n };\n });\n\n const quorum = 1;\n return new FallbackProvider(providers, quorum);\n};\n"]}
@@ -0,0 +1,4 @@
1
+ export declare type FeeTokenDetails = {
2
+ tokenAddress: string;
3
+ feePerUnitGas: string;
4
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ //# sourceMappingURL=fee-token.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fee-token.js","sourceRoot":"","sources":["../../src/models/fee-token.ts"],"names":[],"mappings":"","sourcesContent":["export type FeeTokenDetails = {\n tokenAddress: string;\n feePerUnitGas: string;\n};\n"]}
@@ -0,0 +1,2 @@
1
+ import { Chain, RailgunBalanceResponse } from './response-types';
2
+ export declare type RailgunBalanceRefreshTrigger = (chain: Chain, railgunWalletID: string, fullRescan: boolean) => Promise<RailgunBalanceResponse>;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ //# sourceMappingURL=function-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"function-types.js","sourceRoot":"","sources":["../../src/models/function-types.ts"],"names":[],"mappings":"","sourcesContent":["import { Chain, RailgunBalanceResponse } from './response-types';\n\nexport type RailgunBalanceRefreshTrigger = (\n chain: Chain,\n railgunWalletID: string,\n fullRescan: boolean,\n) => Promise<RailgunBalanceResponse>;\n"]}
@@ -0,0 +1,6 @@
1
+ export declare enum MerkletreeScanStatus {
2
+ Started = "Started",
3
+ Updated = "Updated",
4
+ Complete = "Complete",
5
+ Incomplete = "Incomplete"
6
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.MerkletreeScanStatus = void 0;
4
+ var MerkletreeScanStatus;
5
+ (function (MerkletreeScanStatus) {
6
+ MerkletreeScanStatus["Started"] = "Started";
7
+ MerkletreeScanStatus["Updated"] = "Updated";
8
+ MerkletreeScanStatus["Complete"] = "Complete";
9
+ MerkletreeScanStatus["Incomplete"] = "Incomplete";
10
+ })(MerkletreeScanStatus = exports.MerkletreeScanStatus || (exports.MerkletreeScanStatus = {}));
11
+ //# sourceMappingURL=merkletree-scan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merkletree-scan.js","sourceRoot":"","sources":["../../src/models/merkletree-scan.ts"],"names":[],"mappings":";;;AAAA,IAAY,oBAKX;AALD,WAAY,oBAAoB;IAC9B,2CAAmB,CAAA;IACnB,2CAAmB,CAAA;IACnB,6CAAqB,CAAA;IACrB,iDAAyB,CAAA;AAC3B,CAAC,EALW,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QAK/B","sourcesContent":["export enum MerkletreeScanStatus {\n Started = 'Started',\n Updated = 'Updated',\n Complete = 'Complete',\n Incomplete = 'Incomplete',\n}\n"]}
@@ -0,0 +1,76 @@
1
+ import { Chain } from './response-types';
2
+ export declare enum NetworkName {
3
+ Railgun = "Railgun",
4
+ Ethereum = "Ethereum",
5
+ BNBSmartChain = "BNB_Chain",
6
+ Polygon = "Polygon",
7
+ EthereumRopsten = "Ethereum_Ropsten",
8
+ EthereumGoerli = "Ethereum_Goerli",
9
+ HardHat = "HardHat"
10
+ }
11
+ export declare enum BaseTokenWrappedAddress {
12
+ EthereumWETH = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
13
+ BinanceWBNB = "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c",
14
+ PolygonWMATIC = "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
15
+ RopstenWETH = "0xc778417e063141139fce010982780140aa0cd5ab",
16
+ HardhatWETH = "0x322813Fd9A801c5507c9de605d63CEA4f2CE6c44"
17
+ }
18
+ export declare type FeesSerialized = {
19
+ deposit: string;
20
+ withdraw: string;
21
+ nft: string;
22
+ };
23
+ declare type BaseToken = {
24
+ symbol: string;
25
+ wrappedSymbol: string;
26
+ wrappedAddress: BaseTokenWrappedAddress;
27
+ decimals: number;
28
+ };
29
+ export declare type Network = {
30
+ chain: Chain;
31
+ name: NetworkName;
32
+ publicName: string;
33
+ shortPublicName: string;
34
+ coingeckoId: string;
35
+ baseToken: BaseToken;
36
+ proxyContract?: RailgunProxyContract;
37
+ relayAdaptContract?: RelayAdaptContract;
38
+ deploymentBlock?: RailgunProxyDeploymentBlock;
39
+ isTestNetwork?: boolean;
40
+ feesSerialized?: FeesSerialized;
41
+ isEVM?: boolean;
42
+ evmGasType: EVMGasType;
43
+ shouldQuickSync: boolean;
44
+ };
45
+ declare enum RailgunProxyContract {
46
+ Ethereum = "0xfa7093cdd9ee6932b4eb2c9e1cde7ce00b1fa4b9",
47
+ Ropsten = "0x1c2A4092e2a436d78FcdF3a178a4E1ed87f0bB8F",
48
+ BNBSmartChain = "0x590162bf4b50f6576a459b75309ee21d92178a10",
49
+ PolygonPOS = "0x19b620929f97b7b990801496c3b361ca5def8c71",
50
+ HardHat = "0x0165878A594ca255338adfa4d48449f69242Eb8F"
51
+ }
52
+ declare enum RelayAdaptContract {
53
+ Ethereum = "0x22af4EDBeA3De885dDa8f0a0653E6209e44e5B84",
54
+ Ropsten = "0x95abeff80554b23cefe1d3f8dcff3b7d90e28045",
55
+ BNBSmartChain = "0x20d868C7F1Eb706C46641ADD2f849c5DBf4dB158",
56
+ PolygonPOS = "0x30D8AD0339e2CF160620589f2DBa1765126A5fDC",
57
+ HardHat = "0xa85233C63b9Ee964Add6F2cffe00Fd84eb32338f"
58
+ }
59
+ export declare enum RailgunProxyDeploymentBlock {
60
+ Ethereum = 14737691,
61
+ Ropsten = 12226000,
62
+ BNBSmartChain = 17633701,
63
+ PolygonPOS = 28083766,
64
+ HardHat = 0
65
+ }
66
+ /**
67
+ * Type0 = non-EIP-1559 (gasPrice).
68
+ * Type1 = EIP-1559 (maxFeePerGas and maxPriorityFeePerGas).
69
+ */
70
+ export declare enum EVMGasType {
71
+ Type0 = "Type0",
72
+ Type2 = "Type2"
73
+ }
74
+ export declare const NETWORK_CONFIG: MapType<Network>;
75
+ export declare const networkForChain: (chain: Chain) => Optional<Network>;
76
+ export {};
@@ -0,0 +1,208 @@
1
+ "use strict";
2
+ var _a;
3
+ exports.__esModule = true;
4
+ exports.networkForChain = exports.NETWORK_CONFIG = exports.EVMGasType = exports.RailgunProxyDeploymentBlock = exports.BaseTokenWrappedAddress = exports.NetworkName = void 0;
5
+ var response_types_1 = require("./response-types");
6
+ var NetworkName;
7
+ (function (NetworkName) {
8
+ NetworkName["Railgun"] = "Railgun";
9
+ NetworkName["Ethereum"] = "Ethereum";
10
+ NetworkName["BNBSmartChain"] = "BNB_Chain";
11
+ NetworkName["Polygon"] = "Polygon";
12
+ NetworkName["EthereumRopsten"] = "Ethereum_Ropsten";
13
+ NetworkName["EthereumGoerli"] = "Ethereum_Goerli";
14
+ // Test only
15
+ NetworkName["HardHat"] = "HardHat";
16
+ })(NetworkName = exports.NetworkName || (exports.NetworkName = {}));
17
+ var BaseTokenWrappedAddress;
18
+ (function (BaseTokenWrappedAddress) {
19
+ BaseTokenWrappedAddress["EthereumWETH"] = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2";
20
+ BaseTokenWrappedAddress["BinanceWBNB"] = "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c";
21
+ BaseTokenWrappedAddress["PolygonWMATIC"] = "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270";
22
+ BaseTokenWrappedAddress["RopstenWETH"] = "0xc778417e063141139fce010982780140aa0cd5ab";
23
+ BaseTokenWrappedAddress["HardhatWETH"] = "0x322813Fd9A801c5507c9de605d63CEA4f2CE6c44";
24
+ })(BaseTokenWrappedAddress = exports.BaseTokenWrappedAddress || (exports.BaseTokenWrappedAddress = {}));
25
+ var RailgunProxyContract;
26
+ (function (RailgunProxyContract) {
27
+ RailgunProxyContract["Ethereum"] = "0xfa7093cdd9ee6932b4eb2c9e1cde7ce00b1fa4b9";
28
+ RailgunProxyContract["Ropsten"] = "0x1c2A4092e2a436d78FcdF3a178a4E1ed87f0bB8F";
29
+ RailgunProxyContract["BNBSmartChain"] = "0x590162bf4b50f6576a459b75309ee21d92178a10";
30
+ RailgunProxyContract["PolygonPOS"] = "0x19b620929f97b7b990801496c3b361ca5def8c71";
31
+ RailgunProxyContract["HardHat"] = "0x0165878A594ca255338adfa4d48449f69242Eb8F";
32
+ })(RailgunProxyContract || (RailgunProxyContract = {}));
33
+ var RelayAdaptContract;
34
+ (function (RelayAdaptContract) {
35
+ RelayAdaptContract["Ethereum"] = "0x22af4EDBeA3De885dDa8f0a0653E6209e44e5B84";
36
+ RelayAdaptContract["Ropsten"] = "0x95abeff80554b23cefe1d3f8dcff3b7d90e28045";
37
+ RelayAdaptContract["BNBSmartChain"] = "0x20d868C7F1Eb706C46641ADD2f849c5DBf4dB158";
38
+ RelayAdaptContract["PolygonPOS"] = "0x30D8AD0339e2CF160620589f2DBa1765126A5fDC";
39
+ RelayAdaptContract["HardHat"] = "0xa85233C63b9Ee964Add6F2cffe00Fd84eb32338f";
40
+ })(RelayAdaptContract || (RelayAdaptContract = {}));
41
+ var RailgunProxyDeploymentBlock;
42
+ (function (RailgunProxyDeploymentBlock) {
43
+ RailgunProxyDeploymentBlock[RailgunProxyDeploymentBlock["Ethereum"] = 14737691] = "Ethereum";
44
+ RailgunProxyDeploymentBlock[RailgunProxyDeploymentBlock["Ropsten"] = 12226000] = "Ropsten";
45
+ RailgunProxyDeploymentBlock[RailgunProxyDeploymentBlock["BNBSmartChain"] = 17633701] = "BNBSmartChain";
46
+ RailgunProxyDeploymentBlock[RailgunProxyDeploymentBlock["PolygonPOS"] = 28083766] = "PolygonPOS";
47
+ RailgunProxyDeploymentBlock[RailgunProxyDeploymentBlock["HardHat"] = 0] = "HardHat";
48
+ })(RailgunProxyDeploymentBlock = exports.RailgunProxyDeploymentBlock || (exports.RailgunProxyDeploymentBlock = {}));
49
+ /**
50
+ * Type0 = non-EIP-1559 (gasPrice).
51
+ * Type1 = EIP-1559 (maxFeePerGas and maxPriorityFeePerGas).
52
+ */
53
+ var EVMGasType;
54
+ (function (EVMGasType) {
55
+ EVMGasType["Type0"] = "Type0";
56
+ EVMGasType["Type2"] = "Type2";
57
+ })(EVMGasType = exports.EVMGasType || (exports.EVMGasType = {}));
58
+ exports.NETWORK_CONFIG = (_a = {},
59
+ _a[NetworkName.Railgun] = {
60
+ chain: {
61
+ type: -1,
62
+ id: -1
63
+ },
64
+ name: NetworkName.Railgun,
65
+ publicName: 'RAILGUN',
66
+ shortPublicName: '',
67
+ coingeckoId: '',
68
+ baseToken: {},
69
+ evmGasType: EVMGasType.Type2,
70
+ shouldQuickSync: false
71
+ },
72
+ _a[NetworkName.Ethereum] = {
73
+ chain: {
74
+ type: response_types_1.ChainType.EVM,
75
+ id: 1
76
+ },
77
+ name: NetworkName.Ethereum,
78
+ publicName: 'Ethereum',
79
+ shortPublicName: 'Ethereum',
80
+ coingeckoId: 'ethereum',
81
+ baseToken: {
82
+ symbol: 'ETH',
83
+ wrappedSymbol: 'WETH',
84
+ wrappedAddress: BaseTokenWrappedAddress.EthereumWETH,
85
+ decimals: 18
86
+ },
87
+ proxyContract: RailgunProxyContract.Ethereum,
88
+ relayAdaptContract: RelayAdaptContract.Ethereum,
89
+ deploymentBlock: RailgunProxyDeploymentBlock.Ethereum,
90
+ isEVM: true,
91
+ evmGasType: EVMGasType.Type2,
92
+ shouldQuickSync: true
93
+ },
94
+ _a[NetworkName.BNBSmartChain] = {
95
+ chain: {
96
+ type: response_types_1.ChainType.EVM,
97
+ id: 56
98
+ },
99
+ name: NetworkName.BNBSmartChain,
100
+ publicName: 'BNB Chain',
101
+ shortPublicName: 'BSC',
102
+ coingeckoId: 'binance-smart-chain',
103
+ baseToken: {
104
+ symbol: 'BNB',
105
+ wrappedSymbol: 'WBNB',
106
+ wrappedAddress: BaseTokenWrappedAddress.BinanceWBNB,
107
+ decimals: 18
108
+ },
109
+ proxyContract: RailgunProxyContract.BNBSmartChain,
110
+ relayAdaptContract: RelayAdaptContract.BNBSmartChain,
111
+ deploymentBlock: RailgunProxyDeploymentBlock.BNBSmartChain,
112
+ isEVM: true,
113
+ evmGasType: EVMGasType.Type0,
114
+ shouldQuickSync: true
115
+ },
116
+ _a[NetworkName.Polygon] = {
117
+ chain: {
118
+ type: response_types_1.ChainType.EVM,
119
+ id: 137
120
+ },
121
+ name: NetworkName.Polygon,
122
+ publicName: 'Polygon PoS',
123
+ shortPublicName: 'Polygon',
124
+ coingeckoId: 'polygon-pos',
125
+ baseToken: {
126
+ symbol: 'MATIC',
127
+ wrappedSymbol: 'WMATIC',
128
+ wrappedAddress: BaseTokenWrappedAddress.PolygonWMATIC,
129
+ decimals: 18
130
+ },
131
+ proxyContract: RailgunProxyContract.PolygonPOS,
132
+ relayAdaptContract: RelayAdaptContract.PolygonPOS,
133
+ deploymentBlock: RailgunProxyDeploymentBlock.PolygonPOS,
134
+ isEVM: true,
135
+ evmGasType: EVMGasType.Type2,
136
+ shouldQuickSync: true
137
+ },
138
+ _a[NetworkName.EthereumRopsten] = {
139
+ chain: {
140
+ type: response_types_1.ChainType.EVM,
141
+ id: 3
142
+ },
143
+ name: NetworkName.EthereumRopsten,
144
+ publicName: 'Ropsten Test Network',
145
+ shortPublicName: 'Ropsten',
146
+ coingeckoId: 'ethereum',
147
+ baseToken: {
148
+ symbol: 'ETH',
149
+ wrappedSymbol: 'WETH',
150
+ wrappedAddress: BaseTokenWrappedAddress.RopstenWETH,
151
+ decimals: 18
152
+ },
153
+ proxyContract: RailgunProxyContract.Ropsten,
154
+ relayAdaptContract: RelayAdaptContract.Ropsten,
155
+ deploymentBlock: RailgunProxyDeploymentBlock.Ropsten,
156
+ isTestNetwork: true,
157
+ isEVM: true,
158
+ evmGasType: EVMGasType.Type2,
159
+ shouldQuickSync: false
160
+ },
161
+ // [NetworkName.EthereumGoerli]: {
162
+ // chainId: 420,
163
+ // name: NetworkName.EthereumGoerli,
164
+ // publicName: 'Goerli Test Network',
165
+ // shortPublicName: 'Goerli',
166
+ // coingeckoId: 'ethereum',
167
+ // baseToken: {
168
+ // symbol: 'ETH',
169
+ // wrappedSymbol: 'WETH',
170
+ // wrappedAddress: BaseTokenWrappedAddress.EthereumWETH, // TODO: Fix this address.
171
+ // decimals: 18,
172
+ // },
173
+ // proxyContract: '', // TODO: Add Goerli rail contract address.
174
+ // isTestNetwork: true,
175
+ // deploymentBlock: 0,
176
+ // isEVM: true,
177
+ // },
178
+ _a[NetworkName.HardHat] = {
179
+ chain: {
180
+ type: response_types_1.ChainType.EVM,
181
+ id: 31337
182
+ },
183
+ name: NetworkName.HardHat,
184
+ publicName: 'HardHat Test Network',
185
+ shortPublicName: 'HardHat',
186
+ coingeckoId: '',
187
+ baseToken: {
188
+ symbol: 'ETH',
189
+ wrappedSymbol: 'WETH',
190
+ wrappedAddress: BaseTokenWrappedAddress.HardhatWETH,
191
+ decimals: 18
192
+ },
193
+ proxyContract: RailgunProxyContract.HardHat,
194
+ relayAdaptContract: RelayAdaptContract.HardHat,
195
+ deploymentBlock: RailgunProxyDeploymentBlock.HardHat,
196
+ isTestNetwork: true,
197
+ isEVM: true,
198
+ evmGasType: EVMGasType.Type2,
199
+ shouldQuickSync: false
200
+ },
201
+ _a);
202
+ var networkForChain = function (chain) {
203
+ return Object.values(exports.NETWORK_CONFIG).find(function (network) {
204
+ return network.chain.type === chain.type && network.chain.id === chain.id;
205
+ });
206
+ };
207
+ exports.networkForChain = networkForChain;
208
+ //# sourceMappingURL=network-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"network-config.js","sourceRoot":"","sources":["../../src/models/network-config.ts"],"names":[],"mappings":"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","sourcesContent":["import { Chain, ChainType } from './response-types';\n\nexport enum NetworkName {\n Railgun = 'Railgun',\n Ethereum = 'Ethereum',\n BNBSmartChain = 'BNB_Chain',\n Polygon = 'Polygon',\n EthereumRopsten = 'Ethereum_Ropsten',\n EthereumGoerli = 'Ethereum_Goerli',\n\n // Test only\n HardHat = 'HardHat',\n}\n\nexport enum BaseTokenWrappedAddress {\n EthereumWETH = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', // WETH\n BinanceWBNB = '0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c', // WBNB\n PolygonWMATIC = '0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270', // WMATIC\n RopstenWETH = '0xc778417e063141139fce010982780140aa0cd5ab', // (Ropsten) WETH\n HardhatWETH = '0x322813Fd9A801c5507c9de605d63CEA4f2CE6c44', // (Hardhat) WETH\n}\n\nexport type FeesSerialized = {\n deposit: string;\n withdraw: string;\n nft: string;\n};\n\ntype BaseToken = {\n symbol: string;\n wrappedSymbol: string;\n wrappedAddress: BaseTokenWrappedAddress;\n decimals: number;\n};\n\nexport type Network = {\n chain: Chain;\n name: NetworkName;\n publicName: string;\n shortPublicName: string;\n coingeckoId: string;\n baseToken: BaseToken;\n proxyContract?: RailgunProxyContract;\n relayAdaptContract?: RelayAdaptContract;\n deploymentBlock?: RailgunProxyDeploymentBlock;\n isTestNetwork?: boolean;\n feesSerialized?: FeesSerialized;\n isEVM?: boolean;\n evmGasType: EVMGasType;\n shouldQuickSync: boolean;\n};\n\nenum RailgunProxyContract {\n Ethereum = '0xfa7093cdd9ee6932b4eb2c9e1cde7ce00b1fa4b9',\n Ropsten = '0x1c2A4092e2a436d78FcdF3a178a4E1ed87f0bB8F',\n BNBSmartChain = '0x590162bf4b50f6576a459b75309ee21d92178a10',\n PolygonPOS = '0x19b620929f97b7b990801496c3b361ca5def8c71',\n HardHat = '0x0165878A594ca255338adfa4d48449f69242Eb8F',\n}\n\nenum RelayAdaptContract {\n Ethereum = '0x22af4EDBeA3De885dDa8f0a0653E6209e44e5B84',\n Ropsten = '0x95abeff80554b23cefe1d3f8dcff3b7d90e28045',\n BNBSmartChain = '0x20d868C7F1Eb706C46641ADD2f849c5DBf4dB158',\n PolygonPOS = '0x30D8AD0339e2CF160620589f2DBa1765126A5fDC',\n HardHat = '0xa85233C63b9Ee964Add6F2cffe00Fd84eb32338f',\n}\n\nexport enum RailgunProxyDeploymentBlock {\n Ethereum = 14737691,\n Ropsten = 12226000,\n BNBSmartChain = 17633701,\n PolygonPOS = 28083766,\n HardHat = 0,\n}\n\n/**\n * Type0 = non-EIP-1559 (gasPrice).\n * Type1 = EIP-1559 (maxFeePerGas and maxPriorityFeePerGas).\n */\nexport enum EVMGasType {\n Type0 = 'Type0',\n Type2 = 'Type2',\n}\n\nexport const NETWORK_CONFIG: MapType<Network> = {\n [NetworkName.Railgun]: {\n chain: {\n type: -1,\n id: -1,\n },\n name: NetworkName.Railgun,\n publicName: 'RAILGUN',\n shortPublicName: '',\n coingeckoId: '',\n baseToken: {} as BaseToken,\n evmGasType: EVMGasType.Type2,\n shouldQuickSync: false,\n },\n [NetworkName.Ethereum]: {\n chain: {\n type: ChainType.EVM,\n id: 1,\n },\n name: NetworkName.Ethereum,\n publicName: 'Ethereum',\n shortPublicName: 'Ethereum',\n coingeckoId: 'ethereum',\n baseToken: {\n symbol: 'ETH',\n wrappedSymbol: 'WETH',\n wrappedAddress: BaseTokenWrappedAddress.EthereumWETH,\n decimals: 18,\n },\n proxyContract: RailgunProxyContract.Ethereum,\n relayAdaptContract: RelayAdaptContract.Ethereum,\n deploymentBlock: RailgunProxyDeploymentBlock.Ethereum,\n isEVM: true,\n evmGasType: EVMGasType.Type2,\n shouldQuickSync: true,\n },\n [NetworkName.BNBSmartChain]: {\n chain: {\n type: ChainType.EVM,\n id: 56,\n },\n name: NetworkName.BNBSmartChain,\n publicName: 'BNB Chain',\n shortPublicName: 'BSC',\n coingeckoId: 'binance-smart-chain',\n baseToken: {\n symbol: 'BNB',\n wrappedSymbol: 'WBNB',\n wrappedAddress: BaseTokenWrappedAddress.BinanceWBNB,\n decimals: 18,\n },\n proxyContract: RailgunProxyContract.BNBSmartChain,\n relayAdaptContract: RelayAdaptContract.BNBSmartChain,\n deploymentBlock: RailgunProxyDeploymentBlock.BNBSmartChain,\n isEVM: true,\n evmGasType: EVMGasType.Type0,\n shouldQuickSync: true,\n },\n [NetworkName.Polygon]: {\n chain: {\n type: ChainType.EVM,\n id: 137,\n },\n name: NetworkName.Polygon,\n publicName: 'Polygon PoS',\n shortPublicName: 'Polygon',\n coingeckoId: 'polygon-pos',\n baseToken: {\n symbol: 'MATIC',\n wrappedSymbol: 'WMATIC',\n wrappedAddress: BaseTokenWrappedAddress.PolygonWMATIC,\n decimals: 18,\n },\n proxyContract: RailgunProxyContract.PolygonPOS,\n relayAdaptContract: RelayAdaptContract.PolygonPOS,\n deploymentBlock: RailgunProxyDeploymentBlock.PolygonPOS,\n isEVM: true,\n evmGasType: EVMGasType.Type2,\n shouldQuickSync: true,\n },\n [NetworkName.EthereumRopsten]: {\n chain: {\n type: ChainType.EVM,\n id: 3,\n },\n name: NetworkName.EthereumRopsten,\n publicName: 'Ropsten Test Network',\n shortPublicName: 'Ropsten',\n coingeckoId: 'ethereum',\n baseToken: {\n symbol: 'ETH',\n wrappedSymbol: 'WETH',\n wrappedAddress: BaseTokenWrappedAddress.RopstenWETH,\n decimals: 18,\n },\n proxyContract: RailgunProxyContract.Ropsten,\n relayAdaptContract: RelayAdaptContract.Ropsten,\n deploymentBlock: RailgunProxyDeploymentBlock.Ropsten,\n isTestNetwork: true,\n isEVM: true,\n evmGasType: EVMGasType.Type2,\n shouldQuickSync: false,\n },\n // [NetworkName.EthereumGoerli]: {\n // chainId: 420,\n // name: NetworkName.EthereumGoerli,\n // publicName: 'Goerli Test Network',\n // shortPublicName: 'Goerli',\n // coingeckoId: 'ethereum',\n // baseToken: {\n // symbol: 'ETH',\n // wrappedSymbol: 'WETH',\n // wrappedAddress: BaseTokenWrappedAddress.EthereumWETH, // TODO: Fix this address.\n // decimals: 18,\n // },\n // proxyContract: '', // TODO: Add Goerli rail contract address.\n // isTestNetwork: true,\n // deploymentBlock: 0,\n // isEVM: true,\n // },\n [NetworkName.HardHat]: {\n chain: {\n type: ChainType.EVM,\n id: 31337,\n },\n name: NetworkName.HardHat,\n publicName: 'HardHat Test Network',\n shortPublicName: 'HardHat',\n coingeckoId: '',\n baseToken: {\n symbol: 'ETH',\n wrappedSymbol: 'WETH',\n wrappedAddress: BaseTokenWrappedAddress.HardhatWETH,\n decimals: 18,\n },\n proxyContract: RailgunProxyContract.HardHat,\n relayAdaptContract: RelayAdaptContract.HardHat,\n deploymentBlock: RailgunProxyDeploymentBlock.HardHat,\n isTestNetwork: true,\n isEVM: true,\n evmGasType: EVMGasType.Type2,\n shouldQuickSync: false,\n },\n};\n\nexport const networkForChain = (chain: Chain): Optional<Network> => {\n return Object.values(NETWORK_CONFIG).find(\n network =>\n network.chain.type === chain.type && network.chain.id === chain.id,\n );\n};\n"]}
@@ -0,0 +1,6 @@
1
+ export declare enum ProofType {
2
+ Transfer = "Transfer",
3
+ Withdraw = "Withdraw",
4
+ WithdrawBaseToken = "WithdrawBaseToken",
5
+ CrossContractCalls = "CrossContractCalls"
6
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.ProofType = void 0;
4
+ var ProofType;
5
+ (function (ProofType) {
6
+ ProofType["Transfer"] = "Transfer";
7
+ ProofType["Withdraw"] = "Withdraw";
8
+ ProofType["WithdrawBaseToken"] = "WithdrawBaseToken";
9
+ ProofType["CrossContractCalls"] = "CrossContractCalls";
10
+ })(ProofType = exports.ProofType || (exports.ProofType = {}));
11
+ //# sourceMappingURL=proof.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proof.js","sourceRoot":"","sources":["../../src/models/proof.ts"],"names":[],"mappings":";;;AAAA,IAAY,SAKX;AALD,WAAY,SAAS;IACnB,kCAAqB,CAAA;IACrB,kCAAqB,CAAA;IACrB,oDAAuC,CAAA;IACvC,sDAAyC,CAAA;AAC3C,CAAC,EALW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAKpB","sourcesContent":["export enum ProofType {\n Transfer = 'Transfer',\n Withdraw = 'Withdraw',\n WithdrawBaseToken = 'WithdrawBaseToken',\n CrossContractCalls = 'CrossContractCalls',\n}\n"]}
@@ -0,0 +1,130 @@
1
+ import { BigNumber } from '@ethersproject/bignumber';
2
+ import { MerkletreeScanStatus } from './merkletree-scan';
3
+ import { EVMGasType, FeesSerialized } from './network-config';
4
+ export declare type RailgunAPICiphertext = {
5
+ iv: string;
6
+ data: string[];
7
+ };
8
+ export declare type TransactionGasDetails = TransactionGasDetailsType0 | TransactionGasDetailsType2;
9
+ export declare type TransactionGasDetailsType0 = {
10
+ evmGasType: EVMGasType.Type0;
11
+ gasEstimate: BigNumber;
12
+ gasPrice: BigNumber;
13
+ };
14
+ export declare type TransactionGasDetailsType2 = {
15
+ evmGasType: EVMGasType.Type2;
16
+ gasEstimate: BigNumber;
17
+ maxFeePerGas: BigNumber;
18
+ maxPriorityFeePerGas: BigNumber;
19
+ };
20
+ export declare type TransactionGasDetailsSerialized = TransactionGasDetailsSerializedType0 | TransactionGasDetailsSerializedType2;
21
+ export declare type TransactionGasDetailsSerializedType0 = {
22
+ evmGasType: EVMGasType.Type0;
23
+ gasEstimateString: string;
24
+ gasPriceString: string;
25
+ };
26
+ export declare type TransactionGasDetailsSerializedType2 = {
27
+ evmGasType: EVMGasType.Type2;
28
+ gasEstimateString: string;
29
+ maxFeePerGasString: string;
30
+ maxPriorityFeePerGasString: string;
31
+ };
32
+ export declare type StartRailgunEngineResponse = {
33
+ error?: string;
34
+ };
35
+ export declare type DownloadInitialArtifactsResponse = {
36
+ error?: string;
37
+ };
38
+ export declare enum ChainType {
39
+ EVM = 0
40
+ }
41
+ export declare type Chain = {
42
+ type: ChainType;
43
+ id: number;
44
+ };
45
+ export declare type RailgunBalancesEvent = {
46
+ chain: Chain;
47
+ tokenBalancesSerialized: RailgunShieldedTokenBalanceSerialized[];
48
+ railgunWalletID: string;
49
+ };
50
+ export declare type MerkletreeScanUpdateEvent = {
51
+ chain: Chain;
52
+ scanStatus: MerkletreeScanStatus;
53
+ progress: number;
54
+ };
55
+ export declare type LoadProviderResponse = {
56
+ feesSerialized?: FeesSerialized;
57
+ error?: string;
58
+ };
59
+ export declare type RailgunWalletInfo = {
60
+ id: string;
61
+ railgunAddress: string;
62
+ };
63
+ export declare type LoadRailgunWalletResponse = {
64
+ railgunWalletInfo?: RailgunWalletInfo;
65
+ error?: string;
66
+ };
67
+ export declare type UnloadRailgunWalletResponse = {
68
+ error?: string;
69
+ };
70
+ export declare type RailgunWalletAddressDataSerialized = {
71
+ masterPublicKey: string;
72
+ viewingPublicKey: string;
73
+ };
74
+ export declare type RailgunBalanceResponse = {
75
+ error?: string;
76
+ };
77
+ export declare type RailgunShieldedTokenBalanceSerialized = {
78
+ tokenAddress: string;
79
+ balanceString: string;
80
+ };
81
+ export declare type RailgunProveTransactionResponse = {
82
+ error?: string;
83
+ };
84
+ export declare type RailgunPopulateTransactionResponse = {
85
+ serializedTransaction?: string;
86
+ error?: string;
87
+ };
88
+ export declare type RailgunTransactionGasEstimateResponse = {
89
+ gasEstimateString?: string;
90
+ error?: string;
91
+ };
92
+ export declare type RailgunWalletTokenAmount = {
93
+ tokenAddress: string;
94
+ amountString: string;
95
+ };
96
+ export declare type EncryptDataWithSharedKeyResponse = {
97
+ encryptedData: [string, string];
98
+ randomPubKey: string;
99
+ sharedKey: Uint8Array;
100
+ };
101
+ export declare type EncryptDataWithSharedKeySerialized = {
102
+ encryptedData: [string, string];
103
+ randomPubKey: string;
104
+ sharedKey: string;
105
+ };
106
+ export declare type ValidateCachedProvedTransactionResponse = {
107
+ isValid: boolean;
108
+ error?: string;
109
+ };
110
+ export declare type Pbkdf2Response = string;
111
+ export declare type RailgunWalletSendTokenAmount = RailgunWalletTokenAmount & {
112
+ recipientAddress?: string;
113
+ walletSource?: string;
114
+ memoText?: string;
115
+ };
116
+ export declare type RailgunWalletReceiveTokenAmount = RailgunWalletTokenAmount & {
117
+ memoText?: string;
118
+ };
119
+ export declare type TransactionHistoryItem = {
120
+ txid: string;
121
+ receiveTokenAmounts: RailgunWalletReceiveTokenAmount[];
122
+ transferTokenAmounts: RailgunWalletSendTokenAmount[];
123
+ changeTokenAmounts: RailgunWalletTokenAmount[];
124
+ relayerFeeTokenAmount?: RailgunWalletTokenAmount;
125
+ version: number;
126
+ };
127
+ export declare type TransactionHistorySerializedResponse = {
128
+ items?: TransactionHistoryItem[];
129
+ error?: string;
130
+ };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.ChainType = void 0;
4
+ var ChainType;
5
+ (function (ChainType) {
6
+ ChainType[ChainType["EVM"] = 0] = "EVM";
7
+ })(ChainType = exports.ChainType || (exports.ChainType = {}));
8
+ //# sourceMappingURL=response-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response-types.js","sourceRoot":"","sources":["../../src/models/response-types.ts"],"names":[],"mappings":";;;AAmDA,IAAY,SAEX;AAFD,WAAY,SAAS;IACnB,uCAAO,CAAA;AACT,CAAC,EAFW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAEpB","sourcesContent":["import { BigNumber } from '@ethersproject/bignumber';\nimport { MerkletreeScanStatus } from './merkletree-scan';\nimport { EVMGasType, FeesSerialized } from './network-config';\n\nexport type RailgunAPICiphertext = {\n iv: string;\n data: string[];\n};\n\nexport type TransactionGasDetails =\n | TransactionGasDetailsType0\n | TransactionGasDetailsType2;\n\nexport type TransactionGasDetailsType0 = {\n evmGasType: EVMGasType.Type0;\n gasEstimate: BigNumber;\n gasPrice: BigNumber;\n};\n\nexport type TransactionGasDetailsType2 = {\n evmGasType: EVMGasType.Type2;\n gasEstimate: BigNumber;\n maxFeePerGas: BigNumber;\n maxPriorityFeePerGas: BigNumber;\n};\n\nexport type TransactionGasDetailsSerialized =\n | TransactionGasDetailsSerializedType0\n | TransactionGasDetailsSerializedType2;\n\nexport type TransactionGasDetailsSerializedType0 = {\n evmGasType: EVMGasType.Type0;\n gasEstimateString: string;\n gasPriceString: string;\n};\n\nexport type TransactionGasDetailsSerializedType2 = {\n evmGasType: EVMGasType.Type2;\n gasEstimateString: string;\n maxFeePerGasString: string;\n maxPriorityFeePerGasString: string;\n};\n\nexport type StartRailgunEngineResponse = {\n error?: string;\n};\n\nexport type DownloadInitialArtifactsResponse = {\n error?: string;\n};\n\nexport enum ChainType {\n EVM = 0,\n}\n\nexport type Chain = {\n type: ChainType;\n id: number;\n};\n\nexport type RailgunBalancesEvent = {\n chain: Chain;\n tokenBalancesSerialized: RailgunShieldedTokenBalanceSerialized[];\n railgunWalletID: string;\n};\n\nexport type MerkletreeScanUpdateEvent = {\n chain: Chain;\n scanStatus: MerkletreeScanStatus;\n progress: number;\n};\n\nexport type LoadProviderResponse = {\n feesSerialized?: FeesSerialized;\n error?: string;\n};\n\nexport type RailgunWalletInfo = {\n id: string;\n railgunAddress: string;\n};\n\nexport type LoadRailgunWalletResponse = {\n railgunWalletInfo?: RailgunWalletInfo;\n error?: string;\n};\n\nexport type UnloadRailgunWalletResponse = {\n error?: string;\n};\n\nexport type RailgunWalletAddressDataSerialized = {\n masterPublicKey: string;\n viewingPublicKey: string;\n};\n\nexport type RailgunBalanceResponse = {\n error?: string;\n};\n\nexport type RailgunShieldedTokenBalanceSerialized = {\n tokenAddress: string;\n balanceString: string;\n};\n\nexport type RailgunProveTransactionResponse = {\n error?: string;\n};\n\nexport type RailgunPopulateTransactionResponse = {\n serializedTransaction?: string;\n error?: string;\n};\n\nexport type RailgunTransactionGasEstimateResponse = {\n gasEstimateString?: string;\n error?: string;\n};\n\nexport type RailgunWalletTokenAmount = {\n tokenAddress: string;\n amountString: string;\n};\n\nexport type EncryptDataWithSharedKeyResponse = {\n encryptedData: [string, string];\n randomPubKey: string;\n sharedKey: Uint8Array;\n};\n\nexport type EncryptDataWithSharedKeySerialized = {\n encryptedData: [string, string];\n randomPubKey: string;\n sharedKey: string;\n};\n\nexport type ValidateCachedProvedTransactionResponse = {\n isValid: boolean;\n error?: string;\n};\n\nexport type Pbkdf2Response = string;\n\nexport declare type RailgunWalletSendTokenAmount = RailgunWalletTokenAmount & {\n recipientAddress?: string;\n walletSource?: string;\n memoText?: string;\n};\n\nexport declare type RailgunWalletReceiveTokenAmount =\n RailgunWalletTokenAmount & {\n memoText?: string;\n };\n\nexport type TransactionHistoryItem = {\n txid: string;\n receiveTokenAmounts: RailgunWalletReceiveTokenAmount[];\n transferTokenAmounts: RailgunWalletSendTokenAmount[];\n changeTokenAmounts: RailgunWalletTokenAmount[];\n relayerFeeTokenAmount?: RailgunWalletTokenAmount;\n version: number;\n};\n\nexport type TransactionHistorySerializedResponse = {\n items?: TransactionHistoryItem[];\n error?: string;\n};\n"]}
@@ -0,0 +1,4 @@
1
+ export declare type TransactionReceiptLog = {
2
+ topics: string[];
3
+ data: string;
4
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ //# sourceMappingURL=transaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../src/models/transaction.ts"],"names":[],"mappings":"","sourcesContent":["export type TransactionReceiptLog = {\n topics: string[];\n data: string;\n};\n"]}
@@ -0,0 +1,5 @@
1
+ export declare enum WalletCreationType {
2
+ Import = "Import",
3
+ Create = "Create",
4
+ AddViewOnly = "AddViewOnly"
5
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.WalletCreationType = void 0;
4
+ var WalletCreationType;
5
+ (function (WalletCreationType) {
6
+ WalletCreationType["Import"] = "Import";
7
+ WalletCreationType["Create"] = "Create";
8
+ WalletCreationType["AddViewOnly"] = "AddViewOnly";
9
+ })(WalletCreationType = exports.WalletCreationType || (exports.WalletCreationType = {}));
10
+ //# sourceMappingURL=wallet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../src/models/wallet.ts"],"names":[],"mappings":";;;AAAA,IAAY,kBAIX;AAJD,WAAY,kBAAkB;IAC5B,uCAAiB,CAAA;IACjB,uCAAiB,CAAA;IACjB,iDAA2B,CAAA;AAC7B,CAAC,EAJW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAI7B","sourcesContent":["export enum WalletCreationType {\n Import = 'Import',\n Create = 'Create',\n AddViewOnly = 'AddViewOnly',\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import { Chain } from '../models/response-types';
2
+ export declare const compareChains: (chainA: Chain, chainB: Chain) => boolean;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.compareChains = void 0;
4
+ var compareChains = function (chainA, chainB) {
5
+ return chainA.type === chainB.type && chainA.id === chainB.id;
6
+ };
7
+ exports.compareChains = compareChains;
8
+ //# sourceMappingURL=compare.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compare.js","sourceRoot":"","sources":["../../src/utils/compare.ts"],"names":[],"mappings":";;;AAEO,IAAM,aAAa,GAAG,UAAC,MAAa,EAAE,MAAa;IACxD,OAAO,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,EAAE,KAAK,MAAM,CAAC,EAAE,CAAC;AAChE,CAAC,CAAC;AAFW,QAAA,aAAa,iBAExB","sourcesContent":["import { Chain } from '../models/response-types';\n\nexport const compareChains = (chainA: Chain, chainB: Chain) => {\n return chainA.type === chainB.type && chainA.id === chainB.id;\n};\n"]}
@@ -0,0 +1 @@
1
+ export declare const sanitizeError: (err: Error) => Error;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.sanitizeError = void 0;
4
+ var STRING_PREFIX_AFTER_UNICODE_REPLACEMENT = 'y %';
5
+ var validAscii = function (str) {
6
+ return str.replace(
7
+ // eslint-disable-next-line no-useless-escape
8
+ /[^A-Za-z 0-9 \.,\?""!@#\$%\^&\*\(\)-_=\+;:<>\/\\\|\}\{\[\]`~]*/g, '');
9
+ };
10
+ var sanitizeError = function (err) {
11
+ if (err && err.message) {
12
+ var lowercaseMsg = err.message.toLowerCase();
13
+ if (lowercaseMsg.includes('quorum') ||
14
+ lowercaseMsg.includes('could not connect to')) {
15
+ return new Error('Could not connect.');
16
+ }
17
+ if (lowercaseMsg.includes('call revert exception')) {
18
+ return new Error('Possible bad token address.');
19
+ }
20
+ if (lowercaseMsg.includes('missing revert data')) {
21
+ return new Error('Possible bad address.');
22
+ }
23
+ if (lowercaseMsg.includes('transaction may fail or may require manual gas limit')) {
24
+ return new Error('Something went wrong. Please make sure you have a valid balance for this transaction.');
25
+ }
26
+ if (lowercaseMsg.includes('replacement fee too low')) {
27
+ return new Error('Cancellation fee too low. Please increase your network fee to replace the current pending transaction.');
28
+ }
29
+ if (lowercaseMsg.includes('intrinsic gas too low')) {
30
+ return new Error('Gas price rejected. Please select a higher gas price or resubmit.');
31
+ }
32
+ if (lowercaseMsg.includes('insufficient funds for intrinsic')) {
33
+ return new Error('Insufficient gas in signing wallet.');
34
+ }
35
+ if (lowercaseMsg.includes('nonce has already been used')) {
36
+ return new Error('Nonce previously used: this transaction is already completed.');
37
+ }
38
+ if (lowercaseMsg.includes('Error while dialing dial tcp')) {
39
+ return new Error('Error while dialing provider. Please try again.');
40
+ }
41
+ if (lowercaseMsg.includes('RailgunLogic: Invalid Merkle Root')) {
42
+ return new Error('RailgunLogic: Invalid Merkle Root. Please try re-scanning your balances through Settings.');
43
+ }
44
+ return new Error(validAscii(err.message).replace(":".concat(STRING_PREFIX_AFTER_UNICODE_REPLACEMENT), ': '));
45
+ }
46
+ return new Error('Unknown error. Please try again.');
47
+ };
48
+ exports.sanitizeError = sanitizeError;
49
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/utils/error.ts"],"names":[],"mappings":";;;AAAA,IAAM,uCAAuC,GAAG,KAAK,CAAC;AAEtD,IAAM,UAAU,GAAG,UAAC,GAAW;IAC7B,OAAO,GAAG,CAAC,OAAO;IAChB,6CAA6C;IAC7C,iEAAiE,EACjE,EAAE,CACH,CAAC;AACJ,CAAC,CAAC;AAEK,IAAM,aAAa,GAAG,UAAC,GAAU;IACtC,IAAI,GAAG,IAAI,GAAG,CAAC,OAAO,EAAE;QACtB,IAAM,YAAY,GAAG,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;QAC/C,IACE,YAAY,CAAC,QAAQ,CAAC,QAAQ,CAAC;YAC/B,YAAY,CAAC,QAAQ,CAAC,sBAAsB,CAAC,EAC7C;YACA,OAAO,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;SACxC;QACD,IAAI,YAAY,CAAC,QAAQ,CAAC,uBAAuB,CAAC,EAAE;YAClD,OAAO,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;SACjD;QACD,IAAI,YAAY,CAAC,QAAQ,CAAC,qBAAqB,CAAC,EAAE;YAChD,OAAO,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;SAC3C;QACD,IACE,YAAY,CAAC,QAAQ,CACnB,sDAAsD,CACvD,EACD;YACA,OAAO,IAAI,KAAK,CACd,uFAAuF,CACxF,CAAC;SACH;QACD,IAAI,YAAY,CAAC,QAAQ,CAAC,yBAAyB,CAAC,EAAE;YACpD,OAAO,IAAI,KAAK,CACd,wGAAwG,CACzG,CAAC;SACH;QACD,IAAI,YAAY,CAAC,QAAQ,CAAC,uBAAuB,CAAC,EAAE;YAClD,OAAO,IAAI,KAAK,CACd,mEAAmE,CACpE,CAAC;SACH;QACD,IAAI,YAAY,CAAC,QAAQ,CAAC,kCAAkC,CAAC,EAAE;YAC7D,OAAO,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;SACzD;QACD,IAAI,YAAY,CAAC,QAAQ,CAAC,6BAA6B,CAAC,EAAE;YACxD,OAAO,IAAI,KAAK,CACd,+DAA+D,CAChE,CAAC;SACH;QACD,IAAI,YAAY,CAAC,QAAQ,CAAC,8BAA8B,CAAC,EAAE;YACzD,OAAO,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;SACrE;QACD,IAAI,YAAY,CAAC,QAAQ,CAAC,mCAAmC,CAAC,EAAE;YAC9D,OAAO,IAAI,KAAK,CACd,2FAA2F,CAC5F,CAAC;SACH;QACD,OAAO,IAAI,KAAK,CACd,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,OAAO,CAC7B,WAAI,uCAAuC,CAAE,EAC7C,IAAI,CACL,CACF,CAAC;KACH;IAED,OAAO,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;AACvD,CAAC,CAAC;AA3DW,QAAA,aAAa,iBA2DxB","sourcesContent":["const STRING_PREFIX_AFTER_UNICODE_REPLACEMENT = 'y %';\n\nconst validAscii = (str: string) => {\n return str.replace(\n // eslint-disable-next-line no-useless-escape\n /[^A-Za-z 0-9 \\.,\\?\"\"!@#\\$%\\^&\\*\\(\\)-_=\\+;:<>\\/\\\\\\|\\}\\{\\[\\]`~]*/g,\n '',\n );\n};\n\nexport const sanitizeError = (err: Error): Error => {\n if (err && err.message) {\n const lowercaseMsg = err.message.toLowerCase();\n if (\n lowercaseMsg.includes('quorum') ||\n lowercaseMsg.includes('could not connect to')\n ) {\n return new Error('Could not connect.');\n }\n if (lowercaseMsg.includes('call revert exception')) {\n return new Error('Possible bad token address.');\n }\n if (lowercaseMsg.includes('missing revert data')) {\n return new Error('Possible bad address.');\n }\n if (\n lowercaseMsg.includes(\n 'transaction may fail or may require manual gas limit',\n )\n ) {\n return new Error(\n 'Something went wrong. Please make sure you have a valid balance for this transaction.',\n );\n }\n if (lowercaseMsg.includes('replacement fee too low')) {\n return new Error(\n 'Cancellation fee too low. Please increase your network fee to replace the current pending transaction.',\n );\n }\n if (lowercaseMsg.includes('intrinsic gas too low')) {\n return new Error(\n 'Gas price rejected. Please select a higher gas price or resubmit.',\n );\n }\n if (lowercaseMsg.includes('insufficient funds for intrinsic')) {\n return new Error('Insufficient gas in signing wallet.');\n }\n if (lowercaseMsg.includes('nonce has already been used')) {\n return new Error(\n 'Nonce previously used: this transaction is already completed.',\n );\n }\n if (lowercaseMsg.includes('Error while dialing dial tcp')) {\n return new Error('Error while dialing provider. Please try again.');\n }\n if (lowercaseMsg.includes('RailgunLogic: Invalid Merkle Root')) {\n return new Error(\n 'RailgunLogic: Invalid Merkle Root. Please try re-scanning your balances through Settings.',\n );\n }\n return new Error(\n validAscii(err.message).replace(\n `:${STRING_PREFIX_AFTER_UNICODE_REPLACEMENT}`,\n ': ',\n ),\n );\n }\n\n return new Error('Unknown error. Please try again.');\n};\n"]}
@@ -0,0 +1,5 @@
1
+ import { BigNumber } from '@ethersproject/bignumber';
2
+ import { TransactionGasDetails } from '../models/response-types';
3
+ export declare const calculateGasLimit: (gasEstimate: BigNumber) => BigNumber;
4
+ export declare const calculateTotalGas: (transactionGasDetails: TransactionGasDetails) => BigNumber;
5
+ export declare const calculateMaximumGas: (transactionGasDetails: TransactionGasDetails) => BigNumber;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.calculateMaximumGas = exports.calculateTotalGas = exports.calculateGasLimit = void 0;
4
+ var network_config_1 = require("../models/network-config");
5
+ var calculateGasLimit = function (gasEstimate) {
6
+ // Gas Limit: Add 20% to gas estimate.
7
+ return gasEstimate.mul(12000).div(10000);
8
+ };
9
+ exports.calculateGasLimit = calculateGasLimit;
10
+ var calculateGasPrice = function (gasDetails) {
11
+ switch (gasDetails.evmGasType) {
12
+ case network_config_1.EVMGasType.Type0: {
13
+ return gasDetails.gasPrice;
14
+ }
15
+ case network_config_1.EVMGasType.Type2: {
16
+ var maxFeePerGas = gasDetails.maxFeePerGas, maxPriorityFeePerGas = gasDetails.maxPriorityFeePerGas;
17
+ return maxFeePerGas.add(maxPriorityFeePerGas);
18
+ }
19
+ }
20
+ };
21
+ var calculateTotalGas = function (transactionGasDetails) {
22
+ var gasPrice = calculateGasPrice(transactionGasDetails);
23
+ var gasEstimate = transactionGasDetails.gasEstimate;
24
+ return gasEstimate.mul(gasPrice);
25
+ };
26
+ exports.calculateTotalGas = calculateTotalGas;
27
+ var calculateMaximumGas = function (transactionGasDetails) {
28
+ var gasPrice = calculateGasPrice(transactionGasDetails);
29
+ var gasEstimate = transactionGasDetails.gasEstimate;
30
+ return (0, exports.calculateGasLimit)(gasEstimate).mul(gasPrice);
31
+ };
32
+ exports.calculateMaximumGas = calculateMaximumGas;
33
+ //# sourceMappingURL=gas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gas.js","sourceRoot":"","sources":["../../src/utils/gas.ts"],"names":[],"mappings":";;;AACA,2DAAsD;AAG/C,IAAM,iBAAiB,GAAG,UAAC,WAAsB;IACtD,sCAAsC;IACtC,OAAO,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAC3C,CAAC,CAAC;AAHW,QAAA,iBAAiB,qBAG5B;AAEF,IAAM,iBAAiB,GAAG,UAAC,UAAiC;IAC1D,QAAQ,UAAU,CAAC,UAAU,EAAE;QAC7B,KAAK,2BAAU,CAAC,KAAK,CAAC,CAAC;YACrB,OAAO,UAAU,CAAC,QAAQ,CAAC;SAC5B;QACD,KAAK,2BAAU,CAAC,KAAK,CAAC,CAAC;YACb,IAAA,YAAY,GAA2B,UAAU,aAArC,EAAE,oBAAoB,GAAK,UAAU,qBAAf,CAAgB;YAC1D,OAAO,YAAY,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;SAC/C;KACF;AACH,CAAC,CAAC;AAEK,IAAM,iBAAiB,GAAG,UAC/B,qBAA4C;IAE5C,IAAM,QAAQ,GAAG,iBAAiB,CAAC,qBAAqB,CAAC,CAAC;IAClD,IAAA,WAAW,GAAK,qBAAqB,YAA1B,CAA2B;IAC9C,OAAO,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AACnC,CAAC,CAAC;AANW,QAAA,iBAAiB,qBAM5B;AAEK,IAAM,mBAAmB,GAAG,UACjC,qBAA4C;IAE5C,IAAM,QAAQ,GAAG,iBAAiB,CAAC,qBAAqB,CAAC,CAAC;IAClD,IAAA,WAAW,GAAK,qBAAqB,YAA1B,CAA2B;IAC9C,OAAO,IAAA,yBAAiB,EAAC,WAAW,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AACtD,CAAC,CAAC;AANW,QAAA,mBAAmB,uBAM9B","sourcesContent":["import { BigNumber } from '@ethersproject/bignumber';\nimport { EVMGasType } from '../models/network-config';\nimport { TransactionGasDetails } from '../models/response-types';\n\nexport const calculateGasLimit = (gasEstimate: BigNumber): BigNumber => {\n // Gas Limit: Add 20% to gas estimate.\n return gasEstimate.mul(12000).div(10000);\n};\n\nconst calculateGasPrice = (gasDetails: TransactionGasDetails) => {\n switch (gasDetails.evmGasType) {\n case EVMGasType.Type0: {\n return gasDetails.gasPrice;\n }\n case EVMGasType.Type2: {\n const { maxFeePerGas, maxPriorityFeePerGas } = gasDetails;\n return maxFeePerGas.add(maxPriorityFeePerGas);\n }\n }\n};\n\nexport const calculateTotalGas = (\n transactionGasDetails: TransactionGasDetails,\n) => {\n const gasPrice = calculateGasPrice(transactionGasDetails);\n const { gasEstimate } = transactionGasDetails;\n return gasEstimate.mul(gasPrice);\n};\n\nexport const calculateMaximumGas = (\n transactionGasDetails: TransactionGasDetails,\n): BigNumber => {\n const gasPrice = calculateGasPrice(transactionGasDetails);\n const { gasEstimate } = transactionGasDetails;\n return calculateGasLimit(gasEstimate).mul(gasPrice);\n};\n"]}
@@ -0,0 +1,4 @@
1
+ import { PopulatedTransaction } from '@ethersproject/contracts';
2
+ import { TransactionRequest } from '@ethersproject/providers';
3
+ export declare const serializeUnsignedTransaction: (transaction: PopulatedTransaction) => string;
4
+ export declare const deserializeTransaction: (rawTransaction: string, nonce: Optional<number>, chainId: number) => TransactionRequest;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ exports.__esModule = true;
14
+ exports.deserializeTransaction = exports.serializeUnsignedTransaction = void 0;
15
+ var transactions_1 = require("@ethersproject/transactions");
16
+ var validatePreserialize = function (transaction) {
17
+ if (transaction.from) {
18
+ throw new Error("Cannot serialize 'from' field on transaction.");
19
+ }
20
+ };
21
+ var serializeUnsignedTransaction = function (transaction) {
22
+ validatePreserialize(transaction);
23
+ return (0, transactions_1.serialize)(transaction);
24
+ };
25
+ exports.serializeUnsignedTransaction = serializeUnsignedTransaction;
26
+ // export const serializeSignedTransaction = (
27
+ // transaction: PopulatedTransaction,
28
+ // signature: SignatureLike,
29
+ // ): string => {
30
+ // validatePreserialize(transaction);
31
+ // return serialize(transaction, signature);
32
+ // };
33
+ var deserializeTransaction = function (rawTransaction, nonce, chainId) {
34
+ var _a;
35
+ var transaction = (0, transactions_1.parse)(rawTransaction);
36
+ return __assign(__assign({}, transaction), { type: (_a = transaction.type) !== null && _a !== void 0 ? _a : undefined, nonce: nonce, chainId: chainId });
37
+ };
38
+ exports.deserializeTransaction = deserializeTransaction;
39
+ //# sourceMappingURL=serializer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serializer.js","sourceRoot":"","sources":["../../src/utils/serializer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,4DAA4E;AAG5E,IAAM,oBAAoB,GAAG,UAAC,WAAiC;IAC7D,IAAI,WAAW,CAAC,IAAI,EAAE;QACpB,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;KAClE;AACH,CAAC,CAAC;AAEK,IAAM,4BAA4B,GAAG,UAC1C,WAAiC;IAEjC,oBAAoB,CAAC,WAAW,CAAC,CAAC;IAClC,OAAO,IAAA,wBAAS,EAAC,WAAW,CAAC,CAAC;AAChC,CAAC,CAAC;AALW,QAAA,4BAA4B,gCAKvC;AAEF,8CAA8C;AAC9C,uCAAuC;AACvC,8BAA8B;AAC9B,iBAAiB;AACjB,uCAAuC;AACvC,8CAA8C;AAC9C,KAAK;AAEE,IAAM,sBAAsB,GAAG,UACpC,cAAsB,EACtB,KAAuB,EACvB,OAAe;;IAEf,IAAM,WAAW,GAAgB,IAAA,oBAAK,EAAC,cAAc,CAAC,CAAC;IACvD,6BACK,WAAW,KACd,IAAI,EAAE,MAAA,WAAW,CAAC,IAAI,mCAAI,SAAS,EACnC,KAAK,OAAA,EACL,OAAO,SAAA,IACP;AACJ,CAAC,CAAC;AAZW,QAAA,sBAAsB,0BAYjC","sourcesContent":["import { PopulatedTransaction } from '@ethersproject/contracts';\nimport { parse, serialize, Transaction } from '@ethersproject/transactions';\nimport { TransactionRequest } from '@ethersproject/providers';\n\nconst validatePreserialize = (transaction: PopulatedTransaction) => {\n if (transaction.from) {\n throw new Error(`Cannot serialize 'from' field on transaction.`);\n }\n};\n\nexport const serializeUnsignedTransaction = (\n transaction: PopulatedTransaction,\n): string => {\n validatePreserialize(transaction);\n return serialize(transaction);\n};\n\n// export const serializeSignedTransaction = (\n// transaction: PopulatedTransaction,\n// signature: SignatureLike,\n// ): string => {\n// validatePreserialize(transaction);\n// return serialize(transaction, signature);\n// };\n\nexport const deserializeTransaction = (\n rawTransaction: string,\n nonce: Optional<number>,\n chainId: number,\n): TransactionRequest => {\n const transaction: Transaction = parse(rawTransaction);\n return {\n ...transaction,\n type: transaction.type ?? undefined,\n nonce,\n chainId,\n };\n};\n"]}
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@railgun-community/shared-models",
3
+ "version": "1.0.3",
4
+ "files": [
5
+ "dist/**/*"
6
+ ],
7
+ "peerDependencies": {
8
+ "@ethersproject/bignumber": "^5.7.0",
9
+ "@ethersproject/providers": "^5.7.1"
10
+ },
11
+ "devDependencies": {
12
+ "@ethersproject/bignumber": "^5.7.0",
13
+ "@ethersproject/providers": "^5.7.1",
14
+ "@types/node": "^18.7.23",
15
+ "@typescript-eslint/eslint-plugin": "^5.38.1",
16
+ "@typescript-eslint/parser": "^5.38.1",
17
+ "eslint": "^8.24.0",
18
+ "eslint-config-prettier": "^8.5.0",
19
+ "eslint-plugin-flowtype": "^8.0.3",
20
+ "eslint-plugin-import": "^2.26.0",
21
+ "madge": "^5.0.1",
22
+ "typescript": "^4.8.3"
23
+ },
24
+ "scripts": {
25
+ "clean": "rm -rf dist",
26
+ "build": "npm run clean && tsc",
27
+ "prepare": "npm run build",
28
+ "check-circular-deps": "madge --circular --extensions tsx .",
29
+ "eslint": "eslint src --ext .ts,.tsx --fix",
30
+ "lint": "npm run check-circular-deps && npm run eslint"
31
+ },
32
+ "dependencies": {
33
+ "@ethersproject/contracts": "^5.7.0",
34
+ "@ethersproject/transactions": "^5.7.0"
35
+ }
36
+ }