@reyaxyz/common 0.262.0 → 0.263.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/rest/helpers/constants.js +16 -10
- package/dist/rest/helpers/constants.js.map +1 -1
- package/dist/types/rest/helpers/constants.d.ts +1 -1
- package/dist/types/rest/helpers/constants.d.ts.map +1 -1
- package/dist/types/utils/sbt-helpers.d.ts +9 -1
- package/dist/types/utils/sbt-helpers.d.ts.map +1 -1
- package/dist/utils/sbt-helpers.js +23 -5
- package/dist/utils/sbt-helpers.js.map +1 -1
- package/package.json +2 -2
- package/src/rest/helpers/constants.ts +30 -11
- package/src/utils/sbt-helpers.ts +24 -5
package/README.md
CHANGED
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
|
|
7
7
|
| Statements | Branches | Functions | Lines |
|
|
8
8
|
| --------------------------- | ----------------------- | ------------------------- | ----------------- |
|
|
9
|
-
|  |  |  |  |
|
|
10
10
|
|
|
@@ -3,6 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.API_CLIENT_CONFIGS = void 0;
|
|
4
4
|
var utils_1 = require("../../utils");
|
|
5
5
|
var types_1 = require("../../types");
|
|
6
|
+
var getEnvVar = function (name, fallback) {
|
|
7
|
+
if (typeof process !== 'undefined' && process.env && process.env[name]) {
|
|
8
|
+
return process.env[name];
|
|
9
|
+
}
|
|
10
|
+
return fallback;
|
|
11
|
+
};
|
|
6
12
|
exports.API_CLIENT_CONFIGS = {
|
|
7
13
|
local: {
|
|
8
14
|
chain: types_1.ReyaChainId.reyaCronos,
|
|
@@ -14,25 +20,25 @@ exports.API_CLIENT_CONFIGS = {
|
|
|
14
20
|
},
|
|
15
21
|
production: {
|
|
16
22
|
chain: types_1.ReyaChainId.reyaNetwork,
|
|
17
|
-
apiEndpoint: 'https://api.reya.xyz',
|
|
18
|
-
webSocketEndpoint: 'wss://websocket.reya.xyz',
|
|
19
|
-
environment: 'production',
|
|
23
|
+
apiEndpoint: getEnvVar('REYA_API_ENDPOINT', 'https://api.reya.xyz'),
|
|
24
|
+
webSocketEndpoint: getEnvVar('REYA_WEBSOCKET_ENDPOINT', 'wss://websocket.reya.xyz'),
|
|
25
|
+
environment: getEnvVar('REYA_ENVIRONMENT', 'production'),
|
|
20
26
|
timeout: utils_1.API_TIMEOUT,
|
|
21
27
|
logging: false,
|
|
22
28
|
},
|
|
23
|
-
|
|
29
|
+
staging: {
|
|
24
30
|
chain: types_1.ReyaChainId.reyaNetwork,
|
|
25
|
-
apiEndpoint: 'https://api-
|
|
26
|
-
webSocketEndpoint: 'wss://websocket.reya.xyz',
|
|
27
|
-
environment: '
|
|
31
|
+
apiEndpoint: getEnvVar('REYA_API_ENDPOINT', 'https://api-staging.reya.xyz'),
|
|
32
|
+
webSocketEndpoint: getEnvVar('REYA_WEBSOCKET_ENDPOINT', 'wss://websocket-staging.reya.xyz'),
|
|
33
|
+
environment: getEnvVar('REYA_ENVIRONMENT', 'staging'),
|
|
28
34
|
timeout: utils_1.API_TIMEOUT,
|
|
29
35
|
logging: false,
|
|
30
36
|
},
|
|
31
37
|
test: {
|
|
32
38
|
chain: types_1.ReyaChainId.reyaCronos,
|
|
33
|
-
apiEndpoint: 'https://api-cronos.reya.xyz',
|
|
34
|
-
webSocketEndpoint: 'wss://websocket-testnet.reya.xyz',
|
|
35
|
-
environment: 'test',
|
|
39
|
+
apiEndpoint: getEnvVar('REYA_API_ENDPOINT', 'https://api-cronos.reya.xyz'),
|
|
40
|
+
webSocketEndpoint: getEnvVar('REYA_WEBSOCKET_ENDPOINT', 'wss://websocket-testnet.reya.xyz'),
|
|
41
|
+
environment: getEnvVar('REYA_ENVIRONMENT', 'test'),
|
|
36
42
|
timeout: utils_1.API_TIMEOUT,
|
|
37
43
|
logging: true,
|
|
38
44
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"/","sources":["rest/helpers/constants.ts"],"names":[],"mappings":";;;AAAA,qCAA0C;AAC1C,qCAA0C;
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"/","sources":["rest/helpers/constants.ts"],"names":[],"mappings":";;;AAAA,qCAA0C;AAC1C,qCAA0C;AAY1C,IAAM,SAAS,GAAG,UAAC,IAAY,EAAE,QAAgB;IAC/C,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QACvE,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAW,CAAC;IACrC,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAEW,QAAA,kBAAkB,GAA8C;IAC3E,KAAK,EAAE;QACL,KAAK,EAAE,mBAAW,CAAC,UAAU;QAC7B,WAAW,EAAE,uBAAuB;QACpC,iBAAiB,EAAE,qBAAqB;QACxC,WAAW,EAAE,OAAO;QACpB,OAAO,EAAE,mBAAW;QACpB,OAAO,EAAE,IAAI;KACd;IACD,UAAU,EAAE;QACV,KAAK,EAAE,mBAAW,CAAC,WAAW;QAC9B,WAAW,EAAE,SAAS,CAAC,mBAAmB,EAAE,sBAAsB,CAAC;QACnE,iBAAiB,EAAE,SAAS,CAC1B,yBAAyB,EACzB,0BAA0B,CAC3B;QACD,WAAW,EAAE,SAAS,CACpB,kBAAkB,EAClB,YAAY,CACS;QACvB,OAAO,EAAE,mBAAW;QACpB,OAAO,EAAE,KAAK;KACf;IACD,OAAO,EAAE;QACP,KAAK,EAAE,mBAAW,CAAC,WAAW;QAC9B,WAAW,EAAE,SAAS,CAAC,mBAAmB,EAAE,8BAA8B,CAAC;QAC3E,iBAAiB,EAAE,SAAS,CAC1B,yBAAyB,EACzB,kCAAkC,CACnC;QACD,WAAW,EAAE,SAAS,CAAC,kBAAkB,EAAE,SAAS,CAAuB;QAC3E,OAAO,EAAE,mBAAW;QACpB,OAAO,EAAE,KAAK;KACf;IACD,IAAI,EAAE;QACJ,KAAK,EAAE,mBAAW,CAAC,UAAU;QAC7B,WAAW,EAAE,SAAS,CAAC,mBAAmB,EAAE,6BAA6B,CAAC;QAC1E,iBAAiB,EAAE,SAAS,CAC1B,yBAAyB,EACzB,kCAAkC,CACnC;QACD,WAAW,EAAE,SAAS,CAAC,kBAAkB,EAAE,MAAM,CAAuB;QACxE,OAAO,EAAE,mBAAW;QACpB,OAAO,EAAE,IAAI;KACd;CACF,CAAC","sourcesContent":["import { API_TIMEOUT } from '../../utils';\nimport { ReyaChainId } from '../../types';\n\nexport type ServiceEnvironment = 'production' | 'staging' | 'test' | 'local';\nexport interface ServiceConfig {\n chain: ReyaChainId;\n apiEndpoint: string;\n webSocketEndpoint: string;\n environment: ServiceEnvironment; // Configuration for SDK, such as base URL for the REST API\n timeout: number; // Optional timeout for API requests\n logging: boolean;\n}\n\nconst getEnvVar = (name: string, fallback: string): string => {\n if (typeof process !== 'undefined' && process.env && process.env[name]) {\n return process.env[name] as string;\n }\n return fallback;\n};\n\nexport const API_CLIENT_CONFIGS: Record<ServiceEnvironment, ServiceConfig> = {\n local: {\n chain: ReyaChainId.reyaCronos,\n apiEndpoint: 'http://localhost:8000',\n webSocketEndpoint: 'ws://localhost:8080',\n environment: 'local',\n timeout: API_TIMEOUT,\n logging: true,\n },\n production: {\n chain: ReyaChainId.reyaNetwork,\n apiEndpoint: getEnvVar('REYA_API_ENDPOINT', 'https://api.reya.xyz'),\n webSocketEndpoint: getEnvVar(\n 'REYA_WEBSOCKET_ENDPOINT',\n 'wss://websocket.reya.xyz',\n ),\n environment: getEnvVar(\n 'REYA_ENVIRONMENT',\n 'production',\n ) as ServiceEnvironment,\n timeout: API_TIMEOUT,\n logging: false,\n },\n staging: {\n chain: ReyaChainId.reyaNetwork,\n apiEndpoint: getEnvVar('REYA_API_ENDPOINT', 'https://api-staging.reya.xyz'),\n webSocketEndpoint: getEnvVar(\n 'REYA_WEBSOCKET_ENDPOINT',\n 'wss://websocket-staging.reya.xyz',\n ),\n environment: getEnvVar('REYA_ENVIRONMENT', 'staging') as ServiceEnvironment,\n timeout: API_TIMEOUT,\n logging: false,\n },\n test: {\n chain: ReyaChainId.reyaCronos,\n apiEndpoint: getEnvVar('REYA_API_ENDPOINT', 'https://api-cronos.reya.xyz'),\n webSocketEndpoint: getEnvVar(\n 'REYA_WEBSOCKET_ENDPOINT',\n 'wss://websocket-testnet.reya.xyz',\n ),\n environment: getEnvVar('REYA_ENVIRONMENT', 'test') as ServiceEnvironment,\n timeout: API_TIMEOUT,\n logging: true,\n },\n};\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReyaChainId } from '../../types';
|
|
2
|
-
export type ServiceEnvironment = 'production' | '
|
|
2
|
+
export type ServiceEnvironment = 'production' | 'staging' | 'test' | 'local';
|
|
3
3
|
export interface ServiceConfig {
|
|
4
4
|
chain: ReyaChainId;
|
|
5
5
|
apiEndpoint: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"/","sources":["rest/helpers/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"/","sources":["rest/helpers/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;AAC7E,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,WAAW,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,kBAAkB,CAAC;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CAClB;AASD,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,kBAAkB,EAAE,aAAa,CA6CxE,CAAC"}
|
|
@@ -3,7 +3,15 @@ import { BigNumberish } from 'ethers';
|
|
|
3
3
|
import { ReyaChainId } from '../types';
|
|
4
4
|
export declare const SBT_ROOT: Record<ReyaChainId, string>;
|
|
5
5
|
export declare const SBT_ROOT_EXTRA_OGS: Record<ReyaChainId, string>;
|
|
6
|
-
export declare
|
|
6
|
+
export declare enum SBT_ROOT_TYPE {
|
|
7
|
+
SPECIAL_ROOT = "special_root",
|
|
8
|
+
OG_ROOT = "all_ogs_root",
|
|
9
|
+
EXTRA_ROOT = "extra_root"
|
|
10
|
+
}
|
|
11
|
+
export declare const getSbtRoot: (reyaChainId: ReyaChainId, ownerAddress: string, isAddressEligibleForSpecialSbt: boolean, isAddressEligibleForOgSbt: boolean, sbtEligibleExtraWallets: {
|
|
12
|
+
account: string;
|
|
13
|
+
root: string;
|
|
14
|
+
}[]) => string;
|
|
7
15
|
export declare const SBT_MINT_DEADLINE = 1743508800;
|
|
8
16
|
export type SbtLeafInfo = {
|
|
9
17
|
account: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sbt-helpers.d.ts","sourceRoot":"/","sources":["utils/sbt-helpers.ts"],"names":[],"mappings":";AAAA,OAAO,EAAU,YAAY,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAKhD,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAK1D,CAAC;AAEF,eAAO,MAAM,UAAU,gBACR,WAAW,
|
|
1
|
+
{"version":3,"file":"sbt-helpers.d.ts","sourceRoot":"/","sources":["utils/sbt-helpers.ts"],"names":[],"mappings":";AAAA,OAAO,EAAU,YAAY,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAKhD,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAK1D,CAAC;AAEF,oBAAY,aAAa;IACvB,YAAY,iBAAiB;IAC7B,OAAO,iBAAiB;IACxB,UAAU,eAAe;CAC1B;AAED,eAAO,MAAM,UAAU,gBACR,WAAW,gBACV,MAAM,kCACY,OAAO,6BACZ,OAAO,2BACT;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,KAC3D,MAcF,CAAC;AAEF,eAAO,MAAM,iBAAiB,aAAa,CAAC;AAE5C,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,OAAO,YAAa,MAAM,oBAAoB,MAAM,KAAG,MAQnE,CAAC;AAEF,eAAO,MAAM,aAAa,YACf,MAAM,cACH,MAAM,oBACA,MAAM,KACvB,YASF,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a, _b;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.getSbtTokenId = exports.getLeaf = exports.SBT_MINT_DEADLINE = exports.getSbtRoot = exports.SBT_ROOT_EXTRA_OGS = exports.SBT_ROOT = void 0;
|
|
4
|
+
exports.getSbtTokenId = exports.getLeaf = exports.SBT_MINT_DEADLINE = exports.getSbtRoot = exports.SBT_ROOT_TYPE = exports.SBT_ROOT_EXTRA_OGS = exports.SBT_ROOT = void 0;
|
|
5
5
|
var ethers_1 = require("ethers");
|
|
6
6
|
var types_1 = require("../types");
|
|
7
7
|
exports.SBT_ROOT = (_a = {},
|
|
@@ -12,10 +12,28 @@ exports.SBT_ROOT_EXTRA_OGS = (_b = {},
|
|
|
12
12
|
_b[types_1.ReyaChainId.reyaNetwork] = '0xbc6264e25255e1b3d456ec287615879c2525828345a3d4d4c09eb11baa2d201f',
|
|
13
13
|
_b[types_1.ReyaChainId.reyaCronos] = '0xdb3908dd08c4ccc9a39a3699999ff7043780ce76b245fffc4d551dc903594b61',
|
|
14
14
|
_b);
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
var SBT_ROOT_TYPE;
|
|
16
|
+
(function (SBT_ROOT_TYPE) {
|
|
17
|
+
SBT_ROOT_TYPE["SPECIAL_ROOT"] = "special_root";
|
|
18
|
+
SBT_ROOT_TYPE["OG_ROOT"] = "all_ogs_root";
|
|
19
|
+
SBT_ROOT_TYPE["EXTRA_ROOT"] = "extra_root";
|
|
20
|
+
})(SBT_ROOT_TYPE || (exports.SBT_ROOT_TYPE = SBT_ROOT_TYPE = {}));
|
|
21
|
+
var getSbtRoot = function (reyaChainId, ownerAddress, isAddressEligibleForSpecialSbt, isAddressEligibleForOgSbt, sbtEligibleExtraWallets) {
|
|
22
|
+
var merkleRoot = '';
|
|
23
|
+
if (isAddressEligibleForSpecialSbt) {
|
|
24
|
+
return exports.SBT_ROOT[reyaChainId];
|
|
25
|
+
}
|
|
26
|
+
else if (isAddressEligibleForOgSbt) {
|
|
27
|
+
return exports.SBT_ROOT_EXTRA_OGS[reyaChainId];
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
sbtEligibleExtraWallets.forEach(function (e) {
|
|
31
|
+
if (e.account.toLowerCase() == ownerAddress.toLowerCase()) {
|
|
32
|
+
merkleRoot = e.root;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return merkleRoot;
|
|
19
37
|
};
|
|
20
38
|
exports.getSbtRoot = getSbtRoot;
|
|
21
39
|
exports.SBT_MINT_DEADLINE = 1743508800; // Tue Apr 01 2025 12:00:00 GMT+0000
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sbt-helpers.js","sourceRoot":"/","sources":["utils/sbt-helpers.ts"],"names":[],"mappings":";;;;AAAA,iCAA8C;AAC9C,kCAAuC;AAE1B,QAAA,QAAQ;IACnB,GAAC,mBAAW,CAAC,WAAW,IACtB,oEAAoE;IACtE,GAAC,mBAAW,CAAC,UAAU,IACrB,oEAAoE;QACtE;AAEW,QAAA,kBAAkB;IAC7B,GAAC,mBAAW,CAAC,WAAW,IACtB,oEAAoE;IACtE,GAAC,mBAAW,CAAC,UAAU,IACrB,oEAAoE;QACtE;
|
|
1
|
+
{"version":3,"file":"sbt-helpers.js","sourceRoot":"/","sources":["utils/sbt-helpers.ts"],"names":[],"mappings":";;;;AAAA,iCAA8C;AAC9C,kCAAuC;AAE1B,QAAA,QAAQ;IACnB,GAAC,mBAAW,CAAC,WAAW,IACtB,oEAAoE;IACtE,GAAC,mBAAW,CAAC,UAAU,IACrB,oEAAoE;QACtE;AAEW,QAAA,kBAAkB;IAC7B,GAAC,mBAAW,CAAC,WAAW,IACtB,oEAAoE;IACtE,GAAC,mBAAW,CAAC,UAAU,IACrB,oEAAoE;QACtE;AAEF,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,8CAA6B,CAAA;IAC7B,yCAAwB,CAAA;IACxB,0CAAyB,CAAA;AAC3B,CAAC,EAJW,aAAa,6BAAb,aAAa,QAIxB;AAEM,IAAM,UAAU,GAAG,UACxB,WAAwB,EACxB,YAAoB,EACpB,8BAAuC,EACvC,yBAAkC,EAClC,uBAA4D;IAE5D,IAAI,UAAU,GAAG,EAAE,CAAC;IACpB,IAAI,8BAA8B,EAAE,CAAC;QACnC,OAAO,gBAAQ,CAAC,WAAW,CAAC,CAAC;IAC/B,CAAC;SAAM,IAAI,yBAAyB,EAAE,CAAC;QACrC,OAAO,0BAAkB,CAAC,WAAW,CAAC,CAAC;IACzC,CAAC;SAAM,CAAC;QACN,uBAAuB,CAAC,OAAO,CAAC,UAAC,CAAC;YAChC,IAAI,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,YAAY,CAAC,WAAW,EAAE,EAAE,CAAC;gBAC1D,UAAU,GAAG,CAAC,CAAC,IAAI,CAAC;YACtB,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AApBW,QAAA,UAAU,cAoBrB;AAEW,QAAA,iBAAiB,GAAG,UAAU,CAAC,CAAC,oCAAoC;AAO1E,IAAM,OAAO,GAAG,UAAC,OAAe,EAAE,gBAAwB;IAC/D,IAAM,WAAW,GAAG,eAAM,CAAC,SAAS,CAClC,eAAM,CAAC,cAAc,CACnB,CAAC,SAAS,EAAE,SAAS,CAAC,EACtB,CAAC,OAAO,EAAE,gBAAgB,CAAC,QAAQ,EAAE,CAAC,CACvC,CACF,CAAC;IACF,OAAO,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;AAClD,CAAC,CAAC;AARW,QAAA,OAAO,WAQlB;AAEK,IAAM,aAAa,GAAG,UAC3B,OAAe,EACf,UAAkB,EAClB,gBAAwB;IAExB,OAAO,eAAM,CAAC,QAAQ,CACpB,eAAM,CAAC,SAAS,CACd,eAAM,CAAC,cAAc,CACnB,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,EACjC,CAAC,OAAO,EAAE,UAAU,EAAE,gBAAgB,CAAC,QAAQ,EAAE,CAAC,CACnD,CACF,CACF,CAAC;AACJ,CAAC,CAAC;AAbW,QAAA,aAAa,iBAaxB","sourcesContent":["import { ethers, BigNumberish } from 'ethers';\nimport { ReyaChainId } from '../types';\n\nexport const SBT_ROOT: Record<ReyaChainId, string> = {\n [ReyaChainId.reyaNetwork]:\n '0x7d8254a884c4e1e8040d592fdbe3ce8986fb6c5c4f7dee3ce7b7f823fa127c52',\n [ReyaChainId.reyaCronos]:\n '0x01f4d29a3aca5cb40663851d2d40d605636dd6448f251d77765dd0e40c422136',\n};\n\nexport const SBT_ROOT_EXTRA_OGS: Record<ReyaChainId, string> = {\n [ReyaChainId.reyaNetwork]:\n '0xbc6264e25255e1b3d456ec287615879c2525828345a3d4d4c09eb11baa2d201f',\n [ReyaChainId.reyaCronos]:\n '0xdb3908dd08c4ccc9a39a3699999ff7043780ce76b245fffc4d551dc903594b61',\n};\n\nexport enum SBT_ROOT_TYPE {\n SPECIAL_ROOT = 'special_root',\n OG_ROOT = 'all_ogs_root',\n EXTRA_ROOT = 'extra_root',\n}\n\nexport const getSbtRoot = (\n reyaChainId: ReyaChainId,\n ownerAddress: string,\n isAddressEligibleForSpecialSbt: boolean,\n isAddressEligibleForOgSbt: boolean,\n sbtEligibleExtraWallets: { account: string; root: string }[],\n): string => {\n let merkleRoot = '';\n if (isAddressEligibleForSpecialSbt) {\n return SBT_ROOT[reyaChainId];\n } else if (isAddressEligibleForOgSbt) {\n return SBT_ROOT_EXTRA_OGS[reyaChainId];\n } else {\n sbtEligibleExtraWallets.forEach((e) => {\n if (e.account.toLowerCase() == ownerAddress.toLowerCase()) {\n merkleRoot = e.root;\n }\n });\n }\n return merkleRoot;\n};\n\nexport const SBT_MINT_DEADLINE = 1743508800; // Tue Apr 01 2025 12:00:00 GMT+0000\n\nexport type SbtLeafInfo = {\n account: string;\n tokenRootCounter: number;\n};\n\nexport const getLeaf = (address: string, tokenRootCounter: number): Buffer => {\n const messageHash = ethers.keccak256(\n ethers.solidityPacked(\n ['address', 'uint256'],\n [address, tokenRootCounter.toString()],\n ),\n );\n return Buffer.from(messageHash.slice(2), 'hex');\n};\n\nexport const getSbtTokenId = (\n account: string,\n merkleRoot: string,\n tokenRootCounter: number,\n): BigNumberish => {\n return ethers.toBigInt(\n ethers.keccak256(\n ethers.solidityPacked(\n ['address', 'bytes32', 'uint256'],\n [account, merkleRoot, tokenRootCounter.toString()],\n ),\n ),\n );\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reyaxyz/common",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.263.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"generate:coverage-badges": "npx istanbul-badges-readme --silent"
|
|
45
45
|
},
|
|
46
46
|
"packageManager": "pnpm@8.3.1",
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "ee6bfb985404ff7881b9e06801a1e1ff40b61295"
|
|
48
48
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { API_TIMEOUT } from '../../utils';
|
|
2
2
|
import { ReyaChainId } from '../../types';
|
|
3
3
|
|
|
4
|
-
export type ServiceEnvironment = 'production' | '
|
|
4
|
+
export type ServiceEnvironment = 'production' | 'staging' | 'test' | 'local';
|
|
5
5
|
export interface ServiceConfig {
|
|
6
6
|
chain: ReyaChainId;
|
|
7
7
|
apiEndpoint: string;
|
|
@@ -11,6 +11,13 @@ export interface ServiceConfig {
|
|
|
11
11
|
logging: boolean;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
const getEnvVar = (name: string, fallback: string): string => {
|
|
15
|
+
if (typeof process !== 'undefined' && process.env && process.env[name]) {
|
|
16
|
+
return process.env[name] as string;
|
|
17
|
+
}
|
|
18
|
+
return fallback;
|
|
19
|
+
};
|
|
20
|
+
|
|
14
21
|
export const API_CLIENT_CONFIGS: Record<ServiceEnvironment, ServiceConfig> = {
|
|
15
22
|
local: {
|
|
16
23
|
chain: ReyaChainId.reyaCronos,
|
|
@@ -22,25 +29,37 @@ export const API_CLIENT_CONFIGS: Record<ServiceEnvironment, ServiceConfig> = {
|
|
|
22
29
|
},
|
|
23
30
|
production: {
|
|
24
31
|
chain: ReyaChainId.reyaNetwork,
|
|
25
|
-
apiEndpoint: 'https://api.reya.xyz',
|
|
26
|
-
webSocketEndpoint:
|
|
27
|
-
|
|
32
|
+
apiEndpoint: getEnvVar('REYA_API_ENDPOINT', 'https://api.reya.xyz'),
|
|
33
|
+
webSocketEndpoint: getEnvVar(
|
|
34
|
+
'REYA_WEBSOCKET_ENDPOINT',
|
|
35
|
+
'wss://websocket.reya.xyz',
|
|
36
|
+
),
|
|
37
|
+
environment: getEnvVar(
|
|
38
|
+
'REYA_ENVIRONMENT',
|
|
39
|
+
'production',
|
|
40
|
+
) as ServiceEnvironment,
|
|
28
41
|
timeout: API_TIMEOUT,
|
|
29
42
|
logging: false,
|
|
30
43
|
},
|
|
31
|
-
|
|
44
|
+
staging: {
|
|
32
45
|
chain: ReyaChainId.reyaNetwork,
|
|
33
|
-
apiEndpoint: 'https://api-
|
|
34
|
-
webSocketEndpoint:
|
|
35
|
-
|
|
46
|
+
apiEndpoint: getEnvVar('REYA_API_ENDPOINT', 'https://api-staging.reya.xyz'),
|
|
47
|
+
webSocketEndpoint: getEnvVar(
|
|
48
|
+
'REYA_WEBSOCKET_ENDPOINT',
|
|
49
|
+
'wss://websocket-staging.reya.xyz',
|
|
50
|
+
),
|
|
51
|
+
environment: getEnvVar('REYA_ENVIRONMENT', 'staging') as ServiceEnvironment,
|
|
36
52
|
timeout: API_TIMEOUT,
|
|
37
53
|
logging: false,
|
|
38
54
|
},
|
|
39
55
|
test: {
|
|
40
56
|
chain: ReyaChainId.reyaCronos,
|
|
41
|
-
apiEndpoint: 'https://api-cronos.reya.xyz',
|
|
42
|
-
webSocketEndpoint:
|
|
43
|
-
|
|
57
|
+
apiEndpoint: getEnvVar('REYA_API_ENDPOINT', 'https://api-cronos.reya.xyz'),
|
|
58
|
+
webSocketEndpoint: getEnvVar(
|
|
59
|
+
'REYA_WEBSOCKET_ENDPOINT',
|
|
60
|
+
'wss://websocket-testnet.reya.xyz',
|
|
61
|
+
),
|
|
62
|
+
environment: getEnvVar('REYA_ENVIRONMENT', 'test') as ServiceEnvironment,
|
|
44
63
|
timeout: API_TIMEOUT,
|
|
45
64
|
logging: true,
|
|
46
65
|
},
|
package/src/utils/sbt-helpers.ts
CHANGED
|
@@ -15,13 +15,32 @@ export const SBT_ROOT_EXTRA_OGS: Record<ReyaChainId, string> = {
|
|
|
15
15
|
'0xdb3908dd08c4ccc9a39a3699999ff7043780ce76b245fffc4d551dc903594b61',
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
+
export enum SBT_ROOT_TYPE {
|
|
19
|
+
SPECIAL_ROOT = 'special_root',
|
|
20
|
+
OG_ROOT = 'all_ogs_root',
|
|
21
|
+
EXTRA_ROOT = 'extra_root',
|
|
22
|
+
}
|
|
23
|
+
|
|
18
24
|
export const getSbtRoot = (
|
|
19
25
|
reyaChainId: ReyaChainId,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
ownerAddress: string,
|
|
27
|
+
isAddressEligibleForSpecialSbt: boolean,
|
|
28
|
+
isAddressEligibleForOgSbt: boolean,
|
|
29
|
+
sbtEligibleExtraWallets: { account: string; root: string }[],
|
|
30
|
+
): string => {
|
|
31
|
+
let merkleRoot = '';
|
|
32
|
+
if (isAddressEligibleForSpecialSbt) {
|
|
33
|
+
return SBT_ROOT[reyaChainId];
|
|
34
|
+
} else if (isAddressEligibleForOgSbt) {
|
|
35
|
+
return SBT_ROOT_EXTRA_OGS[reyaChainId];
|
|
36
|
+
} else {
|
|
37
|
+
sbtEligibleExtraWallets.forEach((e) => {
|
|
38
|
+
if (e.account.toLowerCase() == ownerAddress.toLowerCase()) {
|
|
39
|
+
merkleRoot = e.root;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return merkleRoot;
|
|
25
44
|
};
|
|
26
45
|
|
|
27
46
|
export const SBT_MINT_DEADLINE = 1743508800; // Tue Apr 01 2025 12:00:00 GMT+0000
|