@reyaxyz/common 0.98.1 → 0.98.2

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 CHANGED
@@ -6,5 +6,5 @@
6
6
 
7
7
  | Statements | Branches | Functions | Lines |
8
8
  | --------------------------- | ----------------------- | ------------------------- | ----------------- |
9
- | ![Statements](https://img.shields.io/badge/statements-13.74%25-red.svg?style=flat) | ![Branches](https://img.shields.io/badge/branches-14.96%25-red.svg?style=flat) | ![Functions](https://img.shields.io/badge/functions-9.75%25-red.svg?style=flat) | ![Lines](https://img.shields.io/badge/lines-14.11%25-red.svg?style=flat) |
9
+ | ![Statements](https://img.shields.io/badge/statements-13.67%25-red.svg?style=flat) | ![Branches](https://img.shields.io/badge/branches-14.66%25-red.svg?style=flat) | ![Functions](https://img.shields.io/badge/functions-9.75%25-red.svg?style=flat) | ![Lines](https://img.shields.io/badge/lines-14.03%25-red.svg?style=flat) |
10
10
 
@@ -87,14 +87,23 @@ var getSocketVault = function (params) {
87
87
  };
88
88
  exports.getSocketVault = getSocketVault;
89
89
  var getMoneyInOutChainIdFromReyaConnector = function (params) {
90
- var _a, _b, _c, _d;
90
+ var _a, _b, _c, _d, _e, _f, _g, _h;
91
91
  var deploymentJSON = getSocketDeploymentJSON(params.reyaChainId);
92
- for (var _i = 0, _e = (0, network_1.getMoneyInOutNetworksFromReyaChainId)(params.reyaChainId); _i < _e.length; _i++) {
93
- var moneyInOutChainId = _e[_i];
94
- var withdrawConnector = (_d = (_c = (_b = (_a = deploymentJSON === null || deploymentJSON === void 0 ? void 0 : deploymentJSON[params.reyaChainId]) === null || _a === void 0 ? void 0 : _a[params.tokenName]) === null || _b === void 0 ? void 0 : _b.connectors) === null || _c === void 0 ? void 0 : _c[moneyInOutChainId]) === null || _d === void 0 ? void 0 : _d.FAST;
95
- if (withdrawConnector &&
96
- withdrawConnector.toLowerCase() === params.socketConnector.toLowerCase()) {
97
- return moneyInOutChainId;
92
+ for (var _i = 0, _j = (0, network_1.getMoneyInOutNetworksFromReyaChainId)(params.reyaChainId); _i < _j.length; _i++) {
93
+ var moneyInOutChainId = _j[_i];
94
+ {
95
+ var withdrawConnector = (_d = (_c = (_b = (_a = deploymentJSON === null || deploymentJSON === void 0 ? void 0 : deploymentJSON[params.reyaChainId]) === null || _a === void 0 ? void 0 : _a[params.tokenName]) === null || _b === void 0 ? void 0 : _b.connectors) === null || _c === void 0 ? void 0 : _c[moneyInOutChainId]) === null || _d === void 0 ? void 0 : _d.FAST;
96
+ if (withdrawConnector &&
97
+ withdrawConnector.toLowerCase() === params.socketConnector.toLowerCase()) {
98
+ return moneyInOutChainId;
99
+ }
100
+ }
101
+ {
102
+ var withdrawConnector = (_h = (_g = (_f = (_e = deploymentJSON === null || deploymentJSON === void 0 ? void 0 : deploymentJSON[params.reyaChainId]) === null || _e === void 0 ? void 0 : _e[params.tokenName.concat('.E')]) === null || _f === void 0 ? void 0 : _f.connectors) === null || _g === void 0 ? void 0 : _g[moneyInOutChainId]) === null || _h === void 0 ? void 0 : _h.FAST;
103
+ if (withdrawConnector &&
104
+ withdrawConnector.toLowerCase() === params.socketConnector.toLowerCase()) {
105
+ return moneyInOutChainId;
106
+ }
98
107
  }
99
108
  }
100
109
  throw new Error('getMoneyInOutChainIdFromReyaConnector: money in out chain id not found');
@@ -1 +1 @@
1
- {"version":3,"file":"getSocketAddresses.js","sourceRoot":"/","sources":["services/getSocketAddresses.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kCAUkB;AAClB,4CAG0B;AAC1B,wCAAkD;AAElD,2EAA+D;AAC/D,6EAAiE;AA4BjE,IAAK,0BAQJ;AARD,WAAK,0BAA0B;IAC7B,6DAA+B,CAAA;IAC/B,mEAAqC,CAAA;IACrC,6CAAe,CAAA;IACf,uDAAyB,CAAA;IACzB,mFAAqD,CAAA;IACrD,2DAA6B,CAAA;IAC7B,6DAA+B,CAAA;AACjC,CAAC,EARI,0BAA0B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,WAAW,CAAC,CAAC;IACnE,KAAgC,UAE/B,EAF+B,SAAA,8CAAoC,EAClE,MAAM,CAAC,WAAW,CACnB,EAF+B,cAE/B,EAF+B,IAE/B,EAAE,CAAC;QAFC,IAAM,iBAAiB,SAAA;QAG1B,IAAM,iBAAiB,GACrB,MAAA,MAAA,MAAA,MAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAG,MAAM,CAAC,WAAW,CAAC,0CAAG,MAAM,CAAC,SAAS,CAAC,0CAAE,UAAU,0CAClE,iBAAiB,CAClB,0CAAE,IAAI,CAAC;QAEV,IACE,iBAAiB;YACjB,iBAAiB,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,EACxE,CAAC;YACD,OAAO,iBAAiB,CAAC;QAC3B,CAAC;IACH,CAAC;IAED,MAAM,IAAI,KAAK,CACb,wEAAwE,CACzE,CAAC;AACJ,CAAC,CAAC;AAvBW,QAAA,qCAAqC,yCAuBhD","sourcesContent":["import {\n ReyaChainId,\n GetSocketConnectorsParams,\n Address,\n GetSocketControllerParams,\n MoneyInOutChainId,\n GetSocketVaultParams,\n SocketTokenConnectors,\n TokenName,\n GetMoneyInOutChainIdFromReyaConnectorParams,\n} from '../types';\nimport {\n getMoneyInOutNetworksFromReyaChainId,\n getReyaNetworkFromMoneyInOutChainId,\n} from '../utils/network';\nimport { convertToAddress } from '../utils/token';\n\nimport * as REYA_CRONOS from '../utils/socket/reyaCronos.json';\nimport * as REYA_NETWORK from '../utils/socket/reyaNetwork.json';\n\ntype SocketDeploymentAddresses = {\n [chain in ReyaChainId | MoneyInOutChainId]?: SocketChainAddresses;\n};\n\ntype SocketChainAddresses = {\n [token in TokenName]?: SocketTokenAddresses;\n};\n\ntype SocketTokenAddresses =\n | SocketAppChainAddresses\n | SocketNonAppChainAddresses;\n\ninterface SocketAppChainAddresses {\n isAppChain: true;\n [SocketSuperBridgeContracts.MintableToken]?: string;\n [SocketSuperBridgeContracts.Controller]?: string;\n [SocketSuperBridgeContracts.ExchangeRate]?: string;\n connectors?: SocketConnectors;\n}\ninterface SocketNonAppChainAddresses {\n isAppChain: false;\n [SocketSuperBridgeContracts.NonMintableToken]?: string;\n [SocketSuperBridgeContracts.Vault]?: string;\n connectors?: SocketConnectors;\n}\n\nenum SocketSuperBridgeContracts {\n MintableToken = 'MintableToken',\n NonMintableToken = 'NonMintableToken',\n Vault = 'Vault',\n Controller = 'Controller',\n FiatTokenV2_1_Controller = 'FiatTokenV2_1_Controller',\n ExchangeRate = 'ExchangeRate',\n ConnectorPlug = 'ConnectorPlug',\n}\n\nexport type SocketConnectors = {\n [chainSlug in ReyaChainId | MoneyInOutChainId]?: SocketConnectorAddresses;\n};\n\nexport type SocketConnectorAddresses = {\n ['FAST']?: string;\n};\n\nconst getSocketDeploymentJSON = (\n reyaChainId: ReyaChainId,\n): SocketDeploymentAddresses => {\n switch (reyaChainId) {\n case ReyaChainId.reyaNetwork:\n return REYA_NETWORK;\n case ReyaChainId.reyaCronos:\n return REYA_CRONOS;\n }\n};\n\nexport const getSocketConnectors = (\n params: GetSocketConnectorsParams,\n): SocketTokenConnectors => {\n const reyaChainId = getReyaNetworkFromMoneyInOutChainId(\n params.moneyInOutChainId,\n );\n const deploymentJSON = getSocketDeploymentJSON(reyaChainId);\n const depositConnector =\n deploymentJSON?.[params.moneyInOutChainId]?.[params.tokenName]\n ?.connectors?.[reyaChainId]?.FAST;\n\n if (!depositConnector) {\n throw new Error(\n `getSocketConnectors: deposit connector not found ${JSON.stringify(\n params,\n )}`,\n );\n }\n\n const withdrawConnector =\n deploymentJSON?.[reyaChainId]?.[params.tokenName]?.connectors?.[\n params.moneyInOutChainId\n ]?.FAST;\n\n if (!withdrawConnector) {\n throw new Error(\n `getSocketConnectors: withdraw connector not found ${JSON.stringify(\n params,\n )}`,\n );\n }\n\n return {\n deposit: convertToAddress(depositConnector),\n withdraw: convertToAddress(withdrawConnector),\n };\n};\n\nexport const getSocketController = (\n params: GetSocketControllerParams,\n): Address => {\n const deploymentJSON = getSocketDeploymentJSON(params.reyaChainId);\n const controller = (\n deploymentJSON?.[params.reyaChainId]?.[\n params.tokenName\n ] as SocketAppChainAddresses\n )?.[SocketSuperBridgeContracts.Controller];\n\n if (!controller) {\n throw new Error(\n `getSocketController: controller not found ${JSON.stringify(params)}`,\n );\n }\n\n return convertToAddress(controller);\n};\n\nexport const getSocketVault = (params: GetSocketVaultParams): Address => {\n const reyaChainId = getReyaNetworkFromMoneyInOutChainId(\n params.moneyInOutChainId,\n );\n const deploymentJSON = getSocketDeploymentJSON(reyaChainId);\n\n const vault = (\n deploymentJSON?.[params.moneyInOutChainId]?.[\n params.tokenName\n ] as SocketNonAppChainAddresses\n )?.[SocketSuperBridgeContracts.Vault];\n\n if (!vault) {\n throw new Error(\n `getSocketVault: vault not found ${JSON.stringify(params)}`,\n );\n }\n\n return convertToAddress(vault);\n};\n\nexport const getMoneyInOutChainIdFromReyaConnector = (\n params: GetMoneyInOutChainIdFromReyaConnectorParams,\n): MoneyInOutChainId => {\n const deploymentJSON = getSocketDeploymentJSON(params.reyaChainId);\n for (const moneyInOutChainId of getMoneyInOutNetworksFromReyaChainId(\n params.reyaChainId,\n )) {\n const withdrawConnector =\n deploymentJSON?.[params.reyaChainId]?.[params.tokenName]?.connectors?.[\n moneyInOutChainId\n ]?.FAST;\n\n if (\n withdrawConnector &&\n withdrawConnector.toLowerCase() === params.socketConnector.toLowerCase()\n ) {\n return moneyInOutChainId;\n }\n }\n\n throw new Error(\n 'getMoneyInOutChainIdFromReyaConnector: money in out chain id not found',\n );\n};\n"]}
1
+ {"version":3,"file":"getSocketAddresses.js","sourceRoot":"/","sources":["services/getSocketAddresses.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kCAUkB;AAClB,4CAG0B;AAC1B,wCAAkD;AAElD,2EAA+D;AAC/D,6EAAiE;AA4BjE,IAAK,0BAQJ;AARD,WAAK,0BAA0B;IAC7B,6DAA+B,CAAA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ocketControllerParams,\n MoneyInOutChainId,\n GetSocketVaultParams,\n SocketTokenConnectors,\n TokenName,\n GetMoneyInOutChainIdFromReyaConnectorParams,\n} from '../types';\nimport {\n getMoneyInOutNetworksFromReyaChainId,\n getReyaNetworkFromMoneyInOutChainId,\n} from '../utils/network';\nimport { convertToAddress } from '../utils/token';\n\nimport * as REYA_CRONOS from '../utils/socket/reyaCronos.json';\nimport * as REYA_NETWORK from '../utils/socket/reyaNetwork.json';\n\ntype SocketDeploymentAddresses = {\n [chain in ReyaChainId | MoneyInOutChainId]?: SocketChainAddresses;\n};\n\ntype SocketChainAddresses = {\n [token in TokenName]?: SocketTokenAddresses;\n};\n\ntype SocketTokenAddresses =\n | SocketAppChainAddresses\n | SocketNonAppChainAddresses;\n\ninterface SocketAppChainAddresses {\n isAppChain: true;\n [SocketSuperBridgeContracts.MintableToken]?: string;\n [SocketSuperBridgeContracts.Controller]?: string;\n [SocketSuperBridgeContracts.ExchangeRate]?: string;\n connectors?: SocketConnectors;\n}\ninterface SocketNonAppChainAddresses {\n isAppChain: false;\n [SocketSuperBridgeContracts.NonMintableToken]?: string;\n [SocketSuperBridgeContracts.Vault]?: string;\n connectors?: SocketConnectors;\n}\n\nenum SocketSuperBridgeContracts {\n MintableToken = 'MintableToken',\n NonMintableToken = 'NonMintableToken',\n Vault = 'Vault',\n Controller = 'Controller',\n FiatTokenV2_1_Controller = 'FiatTokenV2_1_Controller',\n ExchangeRate = 'ExchangeRate',\n ConnectorPlug = 'ConnectorPlug',\n}\n\nexport type SocketConnectors = {\n [chainSlug in ReyaChainId | MoneyInOutChainId]?: SocketConnectorAddresses;\n};\n\nexport type SocketConnectorAddresses = {\n ['FAST']?: string;\n};\n\nconst getSocketDeploymentJSON = (\n reyaChainId: ReyaChainId,\n): SocketDeploymentAddresses => {\n switch (reyaChainId) {\n case ReyaChainId.reyaNetwork:\n return REYA_NETWORK;\n case ReyaChainId.reyaCronos:\n return REYA_CRONOS;\n }\n};\n\nexport const getSocketConnectors = (\n params: GetSocketConnectorsParams,\n): SocketTokenConnectors => {\n const reyaChainId = getReyaNetworkFromMoneyInOutChainId(\n params.moneyInOutChainId,\n );\n const deploymentJSON = getSocketDeploymentJSON(reyaChainId);\n const depositConnector =\n deploymentJSON?.[params.moneyInOutChainId]?.[params.tokenName]\n ?.connectors?.[reyaChainId]?.FAST;\n\n if (!depositConnector) {\n throw new Error(\n `getSocketConnectors: deposit connector not found ${JSON.stringify(\n params,\n )}`,\n );\n }\n\n const withdrawConnector =\n deploymentJSON?.[reyaChainId]?.[params.tokenName]?.connectors?.[\n params.moneyInOutChainId\n ]?.FAST;\n\n if (!withdrawConnector) {\n throw new Error(\n `getSocketConnectors: withdraw connector not found ${JSON.stringify(\n params,\n )}`,\n );\n }\n\n return {\n deposit: convertToAddress(depositConnector),\n withdraw: convertToAddress(withdrawConnector),\n };\n};\n\nexport const getSocketController = (\n params: GetSocketControllerParams,\n): Address => {\n const deploymentJSON = getSocketDeploymentJSON(params.reyaChainId);\n const controller = (\n deploymentJSON?.[params.reyaChainId]?.[\n params.tokenName\n ] as SocketAppChainAddresses\n )?.[SocketSuperBridgeContracts.Controller];\n\n if (!controller) {\n throw new Error(\n `getSocketController: controller not found ${JSON.stringify(params)}`,\n );\n }\n\n return convertToAddress(controller);\n};\n\nexport const getSocketVault = (params: GetSocketVaultParams): Address => {\n const reyaChainId = getReyaNetworkFromMoneyInOutChainId(\n params.moneyInOutChainId,\n );\n const deploymentJSON = getSocketDeploymentJSON(reyaChainId);\n\n const vault = (\n deploymentJSON?.[params.moneyInOutChainId]?.[\n params.tokenName\n ] as SocketNonAppChainAddresses\n )?.[SocketSuperBridgeContracts.Vault];\n\n if (!vault) {\n throw new Error(\n `getSocketVault: vault not found ${JSON.stringify(params)}`,\n );\n }\n\n return convertToAddress(vault);\n};\n\nexport const getMoneyInOutChainIdFromReyaConnector = (\n params: GetMoneyInOutChainIdFromReyaConnectorParams,\n): MoneyInOutChainId => {\n const deploymentJSON = getSocketDeploymentJSON(params.reyaChainId);\n for (const moneyInOutChainId of getMoneyInOutNetworksFromReyaChainId(\n params.reyaChainId,\n )) {\n {\n const withdrawConnector =\n deploymentJSON?.[params.reyaChainId]?.[params.tokenName]?.connectors?.[\n moneyInOutChainId\n ]?.FAST;\n\n if (\n withdrawConnector &&\n withdrawConnector.toLowerCase() === params.socketConnector.toLowerCase()\n ) {\n return moneyInOutChainId;\n }\n }\n\n {\n const withdrawConnector =\n deploymentJSON?.[params.reyaChainId]?.[\n params.tokenName.concat('.E') as TokenName\n ]?.connectors?.[moneyInOutChainId]?.FAST;\n\n if (\n withdrawConnector &&\n withdrawConnector.toLowerCase() === params.socketConnector.toLowerCase()\n ) {\n return moneyInOutChainId;\n }\n }\n }\n\n throw new Error(\n 'getMoneyInOutChainIdFromReyaConnector: money in out chain id not found',\n );\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"getSocketAddresses.d.ts","sourceRoot":"/","sources":["services/getSocketAddresses.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,yBAAyB,EACzB,OAAO,EACP,yBAAyB,EACzB,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EAErB,2CAA2C,EAC5C,MAAM,UAAU,CAAC;AA8ClB,MAAM,MAAM,gBAAgB,GAAG;KAC5B,SAAS,IAAI,WAAW,GAAG,iBAAiB,CAAC,CAAC,EAAE,wBAAwB;CAC1E,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAaF,eAAO,MAAM,mBAAmB,WACtB,yBAAyB,KAChC,qBAkCF,CAAC;AAEF,eAAO,MAAM,mBAAmB,WACtB,yBAAyB,KAChC,OAeF,CAAC;AAEF,eAAO,MAAM,cAAc,WAAY,oBAAoB,KAAG,OAmB7D,CAAC;AAEF,eAAO,MAAM,qCAAqC,WACxC,2CAA2C,KAClD,iBAqBF,CAAC"}
1
+ {"version":3,"file":"getSocketAddresses.d.ts","sourceRoot":"/","sources":["services/getSocketAddresses.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,yBAAyB,EACzB,OAAO,EACP,yBAAyB,EACzB,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EAErB,2CAA2C,EAC5C,MAAM,UAAU,CAAC;AA8ClB,MAAM,MAAM,gBAAgB,GAAG;KAC5B,SAAS,IAAI,WAAW,GAAG,iBAAiB,CAAC,CAAC,EAAE,wBAAwB;CAC1E,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAaF,eAAO,MAAM,mBAAmB,WACtB,yBAAyB,KAChC,qBAkCF,CAAC;AAEF,eAAO,MAAM,mBAAmB,WACtB,yBAAyB,KAChC,OAeF,CAAC;AAEF,eAAO,MAAM,cAAc,WAAY,oBAAoB,KAAG,OAmB7D,CAAC;AAEF,eAAO,MAAM,qCAAqC,WACxC,2CAA2C,KAClD,iBAqCF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reyaxyz/common",
3
- "version": "0.98.1",
3
+ "version": "0.98.2",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -42,5 +42,5 @@
42
42
  "generate:coverage-badges": "npx istanbul-badges-readme --silent"
43
43
  },
44
44
  "packageManager": "pnpm@8.3.1",
45
- "gitHead": "97c1070b09e50ca0fdf2fbd451aebab41787dfbd"
45
+ "gitHead": "37afd1166860d2840ae25d0007a332f7e86566f4"
46
46
  }
@@ -158,16 +158,32 @@ export const getMoneyInOutChainIdFromReyaConnector = (
158
158
  for (const moneyInOutChainId of getMoneyInOutNetworksFromReyaChainId(
159
159
  params.reyaChainId,
160
160
  )) {
161
- const withdrawConnector =
162
- deploymentJSON?.[params.reyaChainId]?.[params.tokenName]?.connectors?.[
163
- moneyInOutChainId
164
- ]?.FAST;
165
-
166
- if (
167
- withdrawConnector &&
168
- withdrawConnector.toLowerCase() === params.socketConnector.toLowerCase()
169
- ) {
170
- return moneyInOutChainId;
161
+ {
162
+ const withdrawConnector =
163
+ deploymentJSON?.[params.reyaChainId]?.[params.tokenName]?.connectors?.[
164
+ moneyInOutChainId
165
+ ]?.FAST;
166
+
167
+ if (
168
+ withdrawConnector &&
169
+ withdrawConnector.toLowerCase() === params.socketConnector.toLowerCase()
170
+ ) {
171
+ return moneyInOutChainId;
172
+ }
173
+ }
174
+
175
+ {
176
+ const withdrawConnector =
177
+ deploymentJSON?.[params.reyaChainId]?.[
178
+ params.tokenName.concat('.E') as TokenName
179
+ ]?.connectors?.[moneyInOutChainId]?.FAST;
180
+
181
+ if (
182
+ withdrawConnector &&
183
+ withdrawConnector.toLowerCase() === params.socketConnector.toLowerCase()
184
+ ) {
185
+ return moneyInOutChainId;
186
+ }
171
187
  }
172
188
  }
173
189