@orb-labs/orby-core 0.0.21 → 0.0.23

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.
@@ -1,9 +1,41 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isMainnet = exports.getBlockchainFromName = exports.hasError = exports.getBlockchainIdFromBlockchain = exports.getOrbyChainId = exports.getVirtualEnvironment = exports.getChainIdFromOrbyChainId = void 0;
4
- const enums_js_1 = require("../enums.js");
3
+ exports.hasError = exports.getVirtualEnvironment = exports.getChainIdFromOrbyChainId = exports.initializeBlockchainInformation = void 0;
5
4
  const constants_js_1 = require("../constants.js");
6
5
  const validateAndParseAddress_js_1 = require("./validateAndParseAddress.js");
6
+ const initializeBlockchainInformation = async (orbyUrl) => {
7
+ const response = await fetch(orbyUrl, {
8
+ method: "POST",
9
+ headers: {
10
+ "Content-Type": "application/json",
11
+ },
12
+ body: JSON.stringify({
13
+ jsonrpc: "2.0",
14
+ method: "orby_listBlockchainsInformation",
15
+ params: [],
16
+ id: 1,
17
+ }),
18
+ });
19
+ const { result, error } = await response.json();
20
+ if (error?.code && error?.message) {
21
+ console.error("[initializeBlockchainInfo]", error.code, error.message);
22
+ return;
23
+ }
24
+ result.edges?.map((blockchainInfo) => {
25
+ const chainId = (0, exports.getChainIdFromOrbyChainId)(blockchainInfo.chainId);
26
+ const blockchainName = blockchainInfo.name;
27
+ if (chainId && blockchainName) {
28
+ constants_js_1.BLOCKCHAIN_ID[blockchainName] = Number(chainId);
29
+ constants_js_1.BLOCKCHAIN_ID_TO_BLOCKCHAIN[Number(chainId)] = blockchainName;
30
+ constants_js_1.CHAIN_CONFIGS[blockchainName] = {
31
+ environment: blockchainInfo.environment,
32
+ chainId: chainId,
33
+ vmType: blockchainInfo.vmType,
34
+ };
35
+ }
36
+ });
37
+ };
38
+ exports.initializeBlockchainInformation = initializeBlockchainInformation;
7
39
  const getChainIdFromOrbyChainId = (value) => {
8
40
  let chainId = undefined;
9
41
  const formattedValue = (0, validateAndParseAddress_js_1.validateAndLowerCase)(value);
@@ -21,43 +53,17 @@ const getChainIdFromOrbyChainId = (value) => {
21
53
  ? BigInt(potentialId)
22
54
  : undefined;
23
55
  }
24
- else {
25
- const blockchain = (0, exports.getBlockchainFromName)(formattedValue);
26
- const potentialId = blockchain
27
- ? (0, exports.getBlockchainIdFromBlockchain)(blockchain)
28
- : undefined;
29
- chainId = potentialId ? BigInt(potentialId) : undefined;
30
- }
31
56
  return chainId;
32
57
  };
33
58
  exports.getChainIdFromOrbyChainId = getChainIdFromOrbyChainId;
34
- const getVirtualEnvironment = (id) => {
59
+ const getVirtualEnvironment = async (id) => {
35
60
  const blockchain = id ? constants_js_1.BLOCKCHAIN_ID_TO_BLOCKCHAIN[Number(id)] : undefined;
36
- switch (blockchain) {
37
- case undefined:
38
- return undefined;
39
- case enums_js_1.Blockchain.SOLANA:
40
- return enums_js_1.VMType.SVM;
41
- default:
42
- return enums_js_1.VMType.EVM;
61
+ if (!blockchain) {
62
+ return undefined;
43
63
  }
64
+ return constants_js_1.CHAIN_CONFIGS[blockchain]?.vmType;
44
65
  };
45
66
  exports.getVirtualEnvironment = getVirtualEnvironment;
46
- const getOrbyChainId = (chainId) => {
47
- switch ((0, exports.getVirtualEnvironment)(chainId)) {
48
- case enums_js_1.VMType.SVM:
49
- return `SVM-${chainId.toString()}`;
50
- case enums_js_1.VMType.EVM:
51
- return `EIP155-${chainId.toString()}`;
52
- default:
53
- return undefined;
54
- }
55
- };
56
- exports.getOrbyChainId = getOrbyChainId;
57
- const getBlockchainIdFromBlockchain = (blockchain) => {
58
- return constants_js_1.BLOCKCHAIN_ID[blockchain];
59
- };
60
- exports.getBlockchainIdFromBlockchain = getBlockchainIdFromBlockchain;
61
67
  const hasError = (data) => {
62
68
  if (data?.code && data?.message) {
63
69
  return { code: data.code, message: data.message };
@@ -65,39 +71,3 @@ const hasError = (data) => {
65
71
  return undefined;
66
72
  };
67
73
  exports.hasError = hasError;
68
- const getBlockchainFromName = (chainName) => {
69
- const formattedChainName = (0, validateAndParseAddress_js_1.validateAndLowerCase)(chainName)?.replace("-", "_");
70
- switch (formattedChainName) {
71
- case "bnbt": {
72
- return enums_js_1.Blockchain.BINANCE_TESTNET;
73
- }
74
- case "matic_amoy": {
75
- return enums_js_1.Blockchain.POLYGON_AMOY;
76
- }
77
- case "matic": {
78
- return enums_js_1.Blockchain.POLYGON;
79
- }
80
- case "mainnet": {
81
- return enums_js_1.Blockchain.ETHEREUM;
82
- }
83
- case "holesky": {
84
- return enums_js_1.Blockchain.ETHEREUM_HOLESKY;
85
- }
86
- case "sepolia": {
87
- return enums_js_1.Blockchain.ETHEREUM_SEPOLIA;
88
- }
89
- case "unknown": {
90
- return undefined;
91
- }
92
- default: {
93
- //statements;
94
- return formattedChainName;
95
- }
96
- }
97
- };
98
- exports.getBlockchainFromName = getBlockchainFromName;
99
- const isMainnet = (chainId) => {
100
- const blockchain = constants_js_1.BLOCKCHAIN_ID_TO_BLOCKCHAIN[Number(chainId)];
101
- return constants_js_1.CHAIN_CONFIGS[blockchain].environment == enums_js_1.BlockchainEnvironment.MAINNET;
102
- };
103
- exports.isMainnet = isMainnet;
@@ -1,6 +1,6 @@
1
1
  import { extractAccountCluster, extractActivities, extractFungibleTokenOverview, extractStandardizedBalances, } from "../utils/action_helpers.js";
2
2
  import { LibraryRequest } from "../entities/library_request.js";
3
- import { getChainIdFromOrbyChainId, getOrbyChainId } from "../utils/utils.js";
3
+ import { getChainIdFromOrbyChainId } from "../utils/utils.js";
4
4
  import { validateAndFormatAddress } from "../utils/validateAndParseAddress.js";
5
5
  export class AccountClusterActions extends LibraryRequest {
6
6
  constructor(library, client, provider) {
@@ -67,13 +67,14 @@ export class AccountClusterActions extends LibraryRequest {
67
67
  return success;
68
68
  }
69
69
  async setCustomChainEndpointsForAccountCluster(accountClusterId, chainEndpoints) {
70
- const formattedEndpoints = chainEndpoints.map((endpoint) => {
70
+ const promises = chainEndpoints.map(async (endpoint) => {
71
71
  return {
72
- chainId: getOrbyChainId(endpoint.chainId),
72
+ chainId: await this.getOrbyChainId(endpoint.chainId),
73
73
  customRpcUrls: endpoint.customRpcUrls,
74
74
  customIndexerUrls: endpoint.customIndexerUrls,
75
75
  };
76
76
  });
77
+ const formattedEndpoints = await Promise.all(promises);
77
78
  const { success, message, code } = await this.sendRequest("orby_setCustomChainEndpointsForAccountCluster", [
78
79
  {
79
80
  accountClusterId,
@@ -87,7 +88,8 @@ export class AccountClusterActions extends LibraryRequest {
87
88
  return success;
88
89
  }
89
90
  async removeCustomChainEndpointsForAccountCluster(accountClusterId, chainIds) {
90
- const formattedChainIds = chainIds.map((chainId) => getOrbyChainId(chainId));
91
+ const promises = chainIds.map(async (chainId) => await this.getOrbyChainId(chainId));
92
+ const formattedChainIds = Promise.all(promises);
91
93
  const { success, message, code } = await this.sendRequest("orby_removeCustomChainEndpointsForAccountCluster", [
92
94
  {
93
95
  accountClusterId,
@@ -120,10 +122,11 @@ export class AccountClusterActions extends LibraryRequest {
120
122
  });
121
123
  }
122
124
  async isChainSupportedOnAccountCluster(accountClusterId, chainId) {
125
+ const orbyChainId = await this.getOrbyChainId(chainId);
123
126
  const { supportStatus, message, code } = await this.sendRequest("orby_isChainSupportedOnAccountCluster", [
124
127
  {
125
128
  accountClusterId,
126
- chainId: getOrbyChainId(chainId),
129
+ chainId: orbyChainId,
127
130
  },
128
131
  ]);
129
132
  if (code && message) {
@@ -133,10 +136,11 @@ export class AccountClusterActions extends LibraryRequest {
133
136
  return supportStatus;
134
137
  }
135
138
  async getNodeRpcUrl(accountClusterId, chainId) {
139
+ const orbyChainId = await this.getOrbyChainId(chainId);
136
140
  const { nodeRpcUrl, code, message } = await this.sendRequest("orby_getNodeRpcUrl", [
137
141
  {
138
142
  accountClusterId,
139
- chainId: getOrbyChainId(chainId),
143
+ chainId: orbyChainId,
140
144
  },
141
145
  ]);
142
146
  if (code && message) {
@@ -146,10 +150,11 @@ export class AccountClusterActions extends LibraryRequest {
146
150
  return nodeRpcUrl;
147
151
  }
148
152
  async getVirtualNodeRpcUrl(accountClusterId, chainId, entrypointAccountAddress) {
153
+ const orbyChainId = await this.getOrbyChainId(chainId);
149
154
  const { virtualNodeRpcUrl, message, code } = await this.sendRequest("orby_getVirtualNodeRpcUrl", [
150
155
  {
151
156
  accountClusterId,
152
- chainId: getOrbyChainId(chainId),
157
+ chainId: orbyChainId,
153
158
  entrypointAccountAddress,
154
159
  },
155
160
  ]);
@@ -190,12 +195,13 @@ export class AccountClusterActions extends LibraryRequest {
190
195
  return extractStandardizedBalances(fungibleTokenBalances);
191
196
  }
192
197
  async getFungibleTokenBalances(accountClusterId, offset, limit, chainId, tokensToOmit) {
198
+ const orbyChainId = await this.getOrbyChainId(chainId);
193
199
  const { fungibleTokenBalances, code, message } = await this.sendRequest("orby_getFungibleTokenBalances", [
194
200
  {
195
201
  accountClusterId,
196
202
  offset,
197
203
  limit,
198
- chainId: chainId ? getOrbyChainId(chainId) : undefined,
204
+ chainId: orbyChainId,
199
205
  tokensToOmit,
200
206
  },
201
207
  ]);
@@ -1,12 +1,12 @@
1
1
  import { extractBlockchainInformation, extractBlockchainInformations, } from "../utils/action_helpers.js";
2
2
  import { LibraryRequest } from "../entities/library_request.js";
3
- import { getOrbyChainId } from "../utils/utils.js";
4
3
  export class BlockchainActions extends LibraryRequest {
5
4
  constructor(library, client, provider) {
6
5
  super(library, client, provider);
7
6
  }
8
7
  async getBlockchainInformation(chainId) {
9
- const { blockchain, code, message } = await this.sendRequest("orby_getBlockchainInformation", [{ chainId: getOrbyChainId(chainId) }]);
8
+ const orbyChainId = await this.getOrbyChainId(chainId);
9
+ const { blockchain, code, message } = await this.sendRequest("orby_getBlockchainInformation", [{ chainId: orbyChainId }]);
10
10
  if (code && message) {
11
11
  console.error("[getBlockchainInformation]", code, message);
12
12
  return undefined;
@@ -1,18 +1,19 @@
1
1
  import { extractGasSponsorshipPolicy } from "../utils/action_helpers.js";
2
2
  import { LibraryRequest } from "../entities/library_request.js";
3
- import { getChainIdFromOrbyChainId, getOrbyChainId } from "../utils/utils.js";
3
+ import { getChainIdFromOrbyChainId } from "../utils/utils.js";
4
4
  export class InstanceActions extends LibraryRequest {
5
5
  constructor(library, client, provider) {
6
6
  super(library, client, provider);
7
7
  }
8
8
  async setCustomChainEndpointsForInstance(chainEndpoints) {
9
- const formattedEndpoints = chainEndpoints.map((endpoint) => {
9
+ const promises = chainEndpoints.map(async (endpoint) => {
10
10
  return {
11
- chainId: getOrbyChainId(endpoint.chainId),
11
+ chainId: await this.getOrbyChainId(endpoint.chainId),
12
12
  customRpcUrls: endpoint.customRpcUrls,
13
13
  customIndexerUrls: endpoint.customIndexerUrls,
14
14
  };
15
15
  });
16
+ const formattedEndpoints = await Promise.all(promises);
16
17
  const { success, code, message } = await this.sendRequest("orby_setCustomChainEndpointsForInstance", [{ chainEndpoints: formattedEndpoints }]);
17
18
  if (code && message) {
18
19
  console.error("[setCustomChainEndpointsForInstance]", code, message);
@@ -21,7 +22,8 @@ export class InstanceActions extends LibraryRequest {
21
22
  return success;
22
23
  }
23
24
  async removeCustomChainEndpointForInstance(chainIds) {
24
- const formattedChainIds = chainIds.map((chainId) => getOrbyChainId(chainId));
25
+ const promises = chainIds.map(async (chainId) => await this.getOrbyChainId(chainId));
26
+ const formattedChainIds = await Promise.all(promises);
25
27
  const { success, code, message } = await this.sendRequest("orby_removeCustomChainEndpointForInstance", [{ chainIds: formattedChainIds }]);
26
28
  if (code && message) {
27
29
  console.error("[removeCustomChainEndpointForInstance]", code, message);
@@ -2,7 +2,6 @@ import { extractOperationSet, extractOperationStatuses, } from "../utils/action_
2
2
  import { CurrencyAmount } from "../entities/financial/currency_amount.js";
3
3
  import { AccountType, OperationDataFormat, OperationStatusType, OperationType, } from "../enums.js";
4
4
  import { LibraryRequest } from "../entities/library_request.js";
5
- import { getOrbyChainId } from "../utils/utils.js";
6
5
  import { Account } from "../entities/account.js";
7
6
  // from here: https://stackoverflow.com/questions/65152373/typescript-serialize-bigint-in-json
8
7
  BigInt.prototype.toJSON = function () {
@@ -16,10 +15,10 @@ export class OperationActions extends LibraryRequest {
16
15
  const formattedGasToken = gasToken
17
16
  ? {
18
17
  ...gasToken,
19
- tokenSources: gasToken.tokenSources?.map(({ chainId, address }) => ({
20
- chainId: getOrbyChainId(chainId),
18
+ tokenSources: await Promise.all(gasToken.tokenSources?.map(async ({ chainId, address }) => ({
19
+ chainId: await this.getOrbyChainId(chainId),
21
20
  address,
22
- })),
21
+ })) ?? []),
23
22
  }
24
23
  : undefined;
25
24
  const operationSet = await this.sendRequest("orby_getOperationsToExecuteTransaction", [
@@ -37,13 +36,13 @@ export class OperationActions extends LibraryRequest {
37
36
  const formattedGasToken = gasToken
38
37
  ? {
39
38
  ...gasToken,
40
- tokenSources: gasToken.tokenSources?.map(({ chainId, address }) => ({
41
- chainId: getOrbyChainId(chainId),
39
+ tokenSources: await Promise.all(gasToken.tokenSources?.map(async ({ chainId, address }) => ({
40
+ chainId: await this.getOrbyChainId(chainId),
42
41
  address,
43
- })),
42
+ })) ?? []),
44
43
  }
45
44
  : undefined;
46
- const operationSet = await this.sendRequest("orby_getOperationsForSignTransactionOrSignTypedData", [
45
+ const operationSet = await this.sendRequest("orby_getOperationsToSignTypedData", [
47
46
  {
48
47
  accountClusterId,
49
48
  data,
@@ -56,10 +55,10 @@ export class OperationActions extends LibraryRequest {
56
55
  const formattedGasToken = gasToken
57
56
  ? {
58
57
  ...gasToken,
59
- tokenSources: gasToken.tokenSources?.map(({ chainId, address }) => ({
60
- chainId: getOrbyChainId(chainId),
58
+ tokenSources: await Promise.all(gasToken.tokenSources?.map(async ({ chainId, address }) => ({
59
+ chainId: await this.getOrbyChainId(chainId),
61
60
  address,
62
- })),
61
+ })) ?? []),
63
62
  }
64
63
  : undefined;
65
64
  const operationSet = await this.sendRequest("orby_getOperationsToSignTransactionOrSignTypedData", [
@@ -152,14 +151,14 @@ export class OperationActions extends LibraryRequest {
152
151
  const formattedGasToken = gasToken
153
152
  ? {
154
153
  ...gasToken,
155
- tokenSources: gasToken.tokenSources?.map(({ chainId, address }) => ({
156
- chainId: getOrbyChainId(chainId),
154
+ tokenSources: await Promise.all(gasToken.tokenSources?.map(async ({ chainId, address }) => ({
155
+ chainId: await this.getOrbyChainId(chainId),
157
156
  address,
158
- })),
157
+ })) ?? []),
159
158
  }
160
159
  : undefined;
161
160
  const formattedRecepient = {
162
- chainId: getOrbyChainId(recipient.chainId),
161
+ chainId: await this.getOrbyChainId(recipient.chainId),
163
162
  recipientAddress: recipient.recipientAddress,
164
163
  };
165
164
  const operationSet = await this.sendRequest("orby_getOperationsToTransferToken", [
@@ -177,18 +176,18 @@ export class OperationActions extends LibraryRequest {
177
176
  const formattedInput = input
178
177
  ? {
179
178
  ...input,
180
- tokenSources: input?.tokenSources.map(({ chainId, address }) => ({
181
- chainId: getOrbyChainId(chainId),
179
+ tokenSources: await Promise.all(input.tokenSources?.map(async ({ chainId, address }) => ({
180
+ chainId: await this.getOrbyChainId(chainId),
182
181
  address,
183
- })),
182
+ })) ?? []),
184
183
  }
185
184
  : undefined;
186
185
  const formattedOutput = output
187
186
  ? {
188
187
  ...output,
189
- tokenDestination: output?.tokenDestination
188
+ tokenDestination: output.tokenDestination
190
189
  ? {
191
- chainId: getOrbyChainId(output.tokenDestination.chainId),
190
+ chainId: await this.getOrbyChainId(output.tokenDestination.chainId),
192
191
  address: output.tokenDestination.address,
193
192
  }
194
193
  : undefined,
@@ -197,10 +196,10 @@ export class OperationActions extends LibraryRequest {
197
196
  const formattedGasToken = gasToken
198
197
  ? {
199
198
  ...gasToken,
200
- tokenSources: gasToken.tokenSources?.map(({ chainId, address }) => ({
201
- chainId: getOrbyChainId(chainId),
199
+ tokenSources: await Promise.all(gasToken.tokenSources?.map(async ({ chainId, address }) => ({
200
+ chainId: await this.getOrbyChainId(chainId),
202
201
  address,
203
- })),
202
+ })) ?? []),
204
203
  }
205
204
  : undefined;
206
205
  const operationSet = await this.sendRequest("orby_getOperationsToSwap", [
@@ -218,18 +217,18 @@ export class OperationActions extends LibraryRequest {
218
217
  const formattedInput = input
219
218
  ? {
220
219
  ...input,
221
- tokenSources: input?.tokenSources.map(({ chainId, address }) => ({
222
- chainId: getOrbyChainId(chainId),
220
+ tokenSources: await Promise.all(input.tokenSources?.map(async ({ chainId, address }) => ({
221
+ chainId: await this.getOrbyChainId(chainId),
223
222
  address,
224
- })),
223
+ })) ?? []),
225
224
  }
226
225
  : undefined;
227
226
  const formattedOutput = output
228
227
  ? {
229
228
  ...output,
230
- tokenDestination: output?.tokenDestination
229
+ tokenDestination: output.tokenDestination
231
230
  ? {
232
- chainId: getOrbyChainId(output.tokenDestination.chainId),
231
+ chainId: await this.getOrbyChainId(output.tokenDestination.chainId),
233
232
  address: output.tokenDestination.address,
234
233
  }
235
234
  : undefined,
@@ -246,23 +245,23 @@ export class OperationActions extends LibraryRequest {
246
245
  return extractOperationSet(operationSet);
247
246
  }
248
247
  async getOperationsToBridge(accountClusterId, standardizedTokenId, amount, tokenSources, tokenDestination, gasToken) {
249
- const formattedTokenSources = tokenSources.map(({ chainId, address }) => ({
250
- chainId: getOrbyChainId(chainId),
248
+ const formattedTokenSources = await Promise.all(tokenSources.map(async ({ chainId, address }) => ({
249
+ chainId: await this.getOrbyChainId(chainId),
251
250
  address,
252
- }));
251
+ })));
253
252
  const formattedDestination = tokenDestination
254
253
  ? {
255
- chainId: getOrbyChainId(tokenDestination.chainId),
254
+ chainId: await this.getOrbyChainId(tokenDestination.chainId),
256
255
  address: tokenDestination.address,
257
256
  }
258
257
  : undefined;
259
258
  const formattedGasToken = gasToken
260
259
  ? {
261
260
  ...gasToken,
262
- tokenSources: gasToken.tokenSources?.map(({ chainId, address }) => ({
263
- chainId: getOrbyChainId(chainId),
261
+ tokenSources: await Promise.all(gasToken.tokenSources?.map(async ({ chainId, address }) => ({
262
+ chainId: await this.getOrbyChainId(chainId),
264
263
  address,
265
- })),
264
+ })) ?? []),
266
265
  }
267
266
  : undefined;
268
267
  const operationSet = await this.sendRequest("orby_getOperationsToBridge", [
@@ -391,7 +390,7 @@ export class OperationActions extends LibraryRequest {
391
390
  signature: signature,
392
391
  data: operation.data,
393
392
  from: operation.from,
394
- chainId: getOrbyChainId(operation.chainId),
393
+ chainId: await this.getOrbyChainId(operation.chainId),
395
394
  });
396
395
  }
397
396
  // batch sign all the smart contract transactions
@@ -421,7 +420,7 @@ export class OperationActions extends LibraryRequest {
421
420
  signature: userOperation.signature,
422
421
  data: JSON.stringify(userOperation),
423
422
  from: transactions[0].from,
424
- chainId: getOrbyChainId(transactions[0].chainId),
423
+ chainId: await this.getOrbyChainId(transactions[0].chainId),
425
424
  });
426
425
  }
427
426
  const { operationSetId, operationResponses } = await this.sendSignedOperations(accountCluster.accountClusterId, signedOperations);
@@ -1,14 +1,14 @@
1
1
  import { extractStandardizedTokens } from "../utils/action_helpers.js";
2
2
  import { LibraryRequest } from "../entities/library_request.js";
3
- import { getOrbyChainId } from "../utils/utils.js";
4
3
  export class TokenActions extends LibraryRequest {
5
4
  constructor(library, client, provider) {
6
5
  super(library, client, provider);
7
6
  }
8
7
  async getStandardizedTokenIds(tokens) {
9
- const formattedTokensInfo = tokens.map(({ tokenAddress, chainId }) => {
10
- return { chainId: getOrbyChainId(chainId), tokenAddress };
8
+ const promises = tokens.map(async ({ tokenAddress, chainId }) => {
9
+ return { chainId: await this.getOrbyChainId(chainId), tokenAddress };
11
10
  });
11
+ const formattedTokensInfo = await Promise.all(promises);
12
12
  const { standardizedTokenIds, message, code } = await this.sendRequest("orby_getStandardizedTokenIds", [
13
13
  {
14
14
  tokens: formattedTokensInfo,
@@ -21,9 +21,10 @@ export class TokenActions extends LibraryRequest {
21
21
  return standardizedTokenIds;
22
22
  }
23
23
  async getStandardizedTokens(tokens) {
24
- const formattedTokensInfo = tokens.map(({ tokenAddress, chainId }) => {
25
- return { chainId: getOrbyChainId(chainId), tokenAddress };
24
+ const promises = tokens.map(async ({ tokenAddress, chainId }) => {
25
+ return { chainId: await this.getOrbyChainId(chainId), tokenAddress };
26
26
  });
27
+ const formattedTokensInfo = await Promise.all(promises);
27
28
  const { standardizedTokens, message, code } = await this.sendRequest("orby_getStandardizedTokens", [
28
29
  {
29
30
  tokens: formattedTokensInfo,
@@ -2,13 +2,7 @@ import { Blockchain } from "./enums.js";
2
2
  import { Currency } from "./entities/financial/currency.js";
3
3
  import { ChainConfigs } from "./types.js";
4
4
  export declare const Big: any;
5
- export declare const BLOCKCHAIN_ID: {
6
- [s: string]: number;
7
- };
8
- export declare const CHAIN_CONFIGS: {
9
- [s: string]: ChainConfigs;
10
- };
11
- export declare const BLOCKCHAIN_ID_TO_BLOCKCHAIN: {
12
- [s: number]: Blockchain;
13
- };
5
+ export declare const BLOCKCHAIN_ID: Record<Blockchain, number>;
6
+ export declare const CHAIN_CONFIGS: Record<Blockchain, ChainConfigs>;
7
+ export declare const BLOCKCHAIN_ID_TO_BLOCKCHAIN: Record<number, Blockchain>;
14
8
  export declare const FIAT_CURRENCY: Currency;
@@ -1,139 +1,8 @@
1
1
  import toFormat from "toformat";
2
2
  import _Big from "big.js";
3
- import { Blockchain, BlockchainEnvironment } from "./enums.js";
4
3
  import { Currency } from "./entities/financial/currency.js";
5
4
  export const Big = toFormat(_Big);
6
- export const BLOCKCHAIN_ID = {
7
- [Blockchain.ETHEREUM]: 1,
8
- [Blockchain.POLYGON]: 137,
9
- [Blockchain.BINANCE]: 56,
10
- [Blockchain.ARBITRUM]: 42161,
11
- [Blockchain.ARBITRUM_NOVA]: 42170,
12
- [Blockchain.OPTIMISM]: 10,
13
- [Blockchain.EVMOS]: 9001,
14
- [Blockchain.MOONBEAM]: 1284,
15
- [Blockchain.BASE]: 8453,
16
- [Blockchain.AVALANCHE]: 43114,
17
- [Blockchain.SOLANA]: 101,
18
- // testnets
19
- [Blockchain.ETHEREUM_SEPOLIA]: 11155111,
20
- [Blockchain.ETHEREUM_HOLESKY]: 17000,
21
- [Blockchain.ARBITRUM_SEPOLIA]: 421614,
22
- [Blockchain.OPTIMISM_SEPOLIA]: 11155420,
23
- [Blockchain.POLYGON_AMOY]: 80002,
24
- [Blockchain.BINANCE_TESTNET]: 97,
25
- [Blockchain.OPBNB_TESTNET]: 5611,
26
- [Blockchain.MOONBEAM_ALPHA]: 1287,
27
- [Blockchain.BASE_SEPOLIA]: 84532,
28
- // local testing
29
- [Blockchain.HARDHAT]: 31337,
30
- [Blockchain.LOCAL_CHAIN_0]: 1_000_000_000_001,
31
- [Blockchain.LOCAL_CHAIN_1]: 1_000_000_000_002,
32
- };
33
- export const CHAIN_CONFIGS = {
34
- [Blockchain.ETHEREUM]: {
35
- environment: BlockchainEnvironment.MAINNET,
36
- chainId: BigInt(1),
37
- },
38
- [Blockchain.POLYGON]: {
39
- environment: BlockchainEnvironment.MAINNET,
40
- chainId: BigInt(137),
41
- },
42
- [Blockchain.BINANCE]: {
43
- environment: BlockchainEnvironment.MAINNET,
44
- chainId: BigInt(56),
45
- },
46
- [Blockchain.ARBITRUM]: {
47
- environment: BlockchainEnvironment.MAINNET,
48
- chainId: BigInt(42161),
49
- },
50
- [Blockchain.ARBITRUM_NOVA]: {
51
- environment: BlockchainEnvironment.MAINNET,
52
- chainId: BigInt(42170),
53
- },
54
- [Blockchain.OPTIMISM]: {
55
- environment: BlockchainEnvironment.MAINNET,
56
- chainId: BigInt(10),
57
- },
58
- [Blockchain.EVMOS]: {
59
- environment: BlockchainEnvironment.MAINNET,
60
- chainId: BigInt(9001),
61
- },
62
- [Blockchain.MOONBEAM]: {
63
- environment: BlockchainEnvironment.MAINNET,
64
- chainId: BigInt(1284),
65
- },
66
- [Blockchain.BASE]: {
67
- environment: BlockchainEnvironment.MAINNET,
68
- chainId: BigInt(8453),
69
- },
70
- [Blockchain.AVALANCHE]: {
71
- environment: BlockchainEnvironment.MAINNET,
72
- chainId: BigInt(43114),
73
- },
74
- [Blockchain.SOLANA]: {
75
- environment: BlockchainEnvironment.MAINNET,
76
- chainId: BigInt(101),
77
- },
78
- // testnets
79
- [Blockchain.ETHEREUM_SEPOLIA]: {
80
- environment: BlockchainEnvironment.TESTNET,
81
- chainId: BigInt(11155111),
82
- },
83
- [Blockchain.ETHEREUM_HOLESKY]: {
84
- environment: BlockchainEnvironment.TESTNET,
85
- chainId: BigInt(17000),
86
- },
87
- [Blockchain.ARBITRUM_SEPOLIA]: {
88
- environment: BlockchainEnvironment.TESTNET,
89
- chainId: BigInt(421614),
90
- },
91
- [Blockchain.BASE_SEPOLIA]: {
92
- environment: BlockchainEnvironment.TESTNET,
93
- chainId: BigInt(84532),
94
- },
95
- [Blockchain.OPTIMISM_SEPOLIA]: {
96
- environment: BlockchainEnvironment.TESTNET,
97
- chainId: BigInt(11155420),
98
- },
99
- [Blockchain.BINANCE_TESTNET]: {
100
- environment: BlockchainEnvironment.TESTNET,
101
- chainId: BigInt(97),
102
- },
103
- [Blockchain.OPBNB_TESTNET]: {
104
- environment: BlockchainEnvironment.TESTNET,
105
- chainId: BigInt(5611),
106
- },
107
- [Blockchain.MOONBEAM_ALPHA]: {
108
- environment: BlockchainEnvironment.TESTNET,
109
- chainId: BigInt(1287),
110
- },
111
- [Blockchain.POLYGON_AMOY]: {
112
- environment: BlockchainEnvironment.TESTNET,
113
- chainId: BigInt(80002),
114
- },
115
- };
116
- export const BLOCKCHAIN_ID_TO_BLOCKCHAIN = {
117
- [1]: Blockchain.ETHEREUM,
118
- [137]: Blockchain.POLYGON,
119
- [56]: Blockchain.BINANCE,
120
- [42161]: Blockchain.ARBITRUM,
121
- [42170]: Blockchain.ARBITRUM_NOVA,
122
- [10]: Blockchain.OPTIMISM,
123
- [9001]: Blockchain.EVMOS,
124
- [1284]: Blockchain.MOONBEAM,
125
- [8453]: Blockchain.BASE,
126
- [43114]: Blockchain.AVALANCHE,
127
- [101]: Blockchain.SOLANA,
128
- // testnets
129
- [11155111]: Blockchain.ETHEREUM_SEPOLIA,
130
- [84532]: Blockchain.BASE_SEPOLIA,
131
- [17000]: Blockchain.ETHEREUM_HOLESKY,
132
- [421614]: Blockchain.ARBITRUM_SEPOLIA,
133
- [11155420]: Blockchain.OPTIMISM_SEPOLIA,
134
- [80002]: Blockchain.POLYGON_AMOY,
135
- [97]: Blockchain.BINANCE_TESTNET,
136
- [5611]: Blockchain.OPBNB_TESTNET,
137
- [1287]: Blockchain.MOONBEAM_ALPHA,
138
- };
5
+ export const BLOCKCHAIN_ID = {};
6
+ export const CHAIN_CONFIGS = {};
7
+ export const BLOCKCHAIN_ID_TO_BLOCKCHAIN = {};
139
8
  export const FIAT_CURRENCY = new Currency(6, "USD", "US Dollar", undefined, false, false);
@@ -1,8 +1,11 @@
1
- import { LIBRARY_TYPE } from "../enums.js";
1
+ import { LIBRARY_TYPE, VMType } from "../enums.js";
2
2
  export declare class LibraryRequest {
3
3
  readonly library: LIBRARY_TYPE;
4
4
  readonly client?: any;
5
5
  readonly provider?: any;
6
6
  constructor(library: LIBRARY_TYPE, client?: any, provider?: any);
7
7
  sendRequest(method: string, params: any[]): Promise<any>;
8
+ protected getOrbyChainId: (chainId: bigint) => Promise<string>;
9
+ protected getVirtualEnvironment: (id: bigint) => Promise<VMType>;
10
+ protected providerUrl(): string;
8
11
  }