@orb-labs/orby-core 0.0.22 → 0.0.24
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/CHANGELOG.md +10 -1
- package/dist/cjs/actions/account_cluster.js +6 -6
- package/dist/cjs/actions/blockchain.js +1 -2
- package/dist/cjs/actions/instance.js +2 -2
- package/dist/cjs/actions/operation.js +15 -16
- package/dist/cjs/actions/token.js +2 -3
- package/dist/cjs/constants.d.ts +1 -5
- package/dist/cjs/constants.js +1 -5
- package/dist/cjs/entities/library_request.d.ts +4 -1
- package/dist/cjs/entities/library_request.js +40 -0
- package/dist/cjs/enums.d.ts +0 -25
- package/dist/cjs/enums.js +1 -29
- package/dist/cjs/types.d.ts +5 -1
- package/dist/cjs/utils/utils.d.ts +2 -4
- package/dist/cjs/utils/utils.js +9 -77
- package/dist/esm/actions/account_cluster.js +7 -7
- package/dist/esm/actions/blockchain.js +1 -2
- package/dist/esm/actions/instance.js +3 -3
- package/dist/esm/actions/operation.js +15 -16
- package/dist/esm/actions/token.js +2 -3
- package/dist/esm/constants.d.ts +1 -5
- package/dist/esm/constants.js +0 -4
- package/dist/esm/entities/library_request.d.ts +4 -1
- package/dist/esm/entities/library_request.js +41 -1
- package/dist/esm/enums.d.ts +0 -25
- package/dist/esm/enums.js +0 -28
- package/dist/esm/types.d.ts +5 -1
- package/dist/esm/utils/utils.d.ts +2 -4
- package/dist/esm/utils/utils.js +8 -74
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -2,7 +2,16 @@
|
|
2
2
|
|
3
3
|
### Unreleased
|
4
4
|
|
5
|
-
### 0.0.
|
5
|
+
### 0.0.24
|
6
|
+
|
7
|
+
- fetching blockchain list earlier
|
8
|
+
- remove some util functions that are not needed anymore
|
9
|
+
|
10
|
+
### 0.0.23
|
11
|
+
|
12
|
+
- refactoring how we get the blockchain list
|
13
|
+
|
14
|
+
### 0.0.22
|
6
15
|
|
7
16
|
- refactor constants to fetch directly from backend
|
8
17
|
- fix request method for getOperationsToSignTypeData
|
@@ -72,7 +72,7 @@ class AccountClusterActions extends library_request_js_1.LibraryRequest {
|
|
72
72
|
async setCustomChainEndpointsForAccountCluster(accountClusterId, chainEndpoints) {
|
73
73
|
const promises = chainEndpoints.map(async (endpoint) => {
|
74
74
|
return {
|
75
|
-
chainId: await
|
75
|
+
chainId: await this.getOrbyChainId(endpoint.chainId),
|
76
76
|
customRpcUrls: endpoint.customRpcUrls,
|
77
77
|
customIndexerUrls: endpoint.customIndexerUrls,
|
78
78
|
};
|
@@ -91,7 +91,7 @@ class AccountClusterActions extends library_request_js_1.LibraryRequest {
|
|
91
91
|
return success;
|
92
92
|
}
|
93
93
|
async removeCustomChainEndpointsForAccountCluster(accountClusterId, chainIds) {
|
94
|
-
const promises = chainIds.map(async (chainId) => await
|
94
|
+
const promises = chainIds.map(async (chainId) => await this.getOrbyChainId(chainId));
|
95
95
|
const formattedChainIds = Promise.all(promises);
|
96
96
|
const { success, message, code } = await this.sendRequest("orby_removeCustomChainEndpointsForAccountCluster", [
|
97
97
|
{
|
@@ -125,7 +125,7 @@ class AccountClusterActions extends library_request_js_1.LibraryRequest {
|
|
125
125
|
});
|
126
126
|
}
|
127
127
|
async isChainSupportedOnAccountCluster(accountClusterId, chainId) {
|
128
|
-
const orbyChainId = await
|
128
|
+
const orbyChainId = await this.getOrbyChainId(chainId);
|
129
129
|
const { supportStatus, message, code } = await this.sendRequest("orby_isChainSupportedOnAccountCluster", [
|
130
130
|
{
|
131
131
|
accountClusterId,
|
@@ -139,7 +139,7 @@ class AccountClusterActions extends library_request_js_1.LibraryRequest {
|
|
139
139
|
return supportStatus;
|
140
140
|
}
|
141
141
|
async getNodeRpcUrl(accountClusterId, chainId) {
|
142
|
-
const orbyChainId = await
|
142
|
+
const orbyChainId = await this.getOrbyChainId(chainId);
|
143
143
|
const { nodeRpcUrl, code, message } = await this.sendRequest("orby_getNodeRpcUrl", [
|
144
144
|
{
|
145
145
|
accountClusterId,
|
@@ -153,7 +153,7 @@ class AccountClusterActions extends library_request_js_1.LibraryRequest {
|
|
153
153
|
return nodeRpcUrl;
|
154
154
|
}
|
155
155
|
async getVirtualNodeRpcUrl(accountClusterId, chainId, entrypointAccountAddress) {
|
156
|
-
const orbyChainId = await
|
156
|
+
const orbyChainId = await this.getOrbyChainId(chainId);
|
157
157
|
const { virtualNodeRpcUrl, message, code } = await this.sendRequest("orby_getVirtualNodeRpcUrl", [
|
158
158
|
{
|
159
159
|
accountClusterId,
|
@@ -198,7 +198,7 @@ class AccountClusterActions extends library_request_js_1.LibraryRequest {
|
|
198
198
|
return (0, action_helpers_js_1.extractStandardizedBalances)(fungibleTokenBalances);
|
199
199
|
}
|
200
200
|
async getFungibleTokenBalances(accountClusterId, offset, limit, chainId, tokensToOmit) {
|
201
|
-
const orbyChainId = await
|
201
|
+
const orbyChainId = await this.getOrbyChainId(chainId);
|
202
202
|
const { fungibleTokenBalances, code, message } = await this.sendRequest("orby_getFungibleTokenBalances", [
|
203
203
|
{
|
204
204
|
accountClusterId,
|
@@ -3,13 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BlockchainActions = void 0;
|
4
4
|
const action_helpers_js_1 = require("../utils/action_helpers.js");
|
5
5
|
const library_request_js_1 = require("../entities/library_request.js");
|
6
|
-
const utils_js_1 = require("../utils/utils.js");
|
7
6
|
class BlockchainActions extends library_request_js_1.LibraryRequest {
|
8
7
|
constructor(library, client, provider) {
|
9
8
|
super(library, client, provider);
|
10
9
|
}
|
11
10
|
async getBlockchainInformation(chainId) {
|
12
|
-
const orbyChainId = await
|
11
|
+
const orbyChainId = await this.getOrbyChainId(chainId);
|
13
12
|
const { blockchain, code, message } = await this.sendRequest("orby_getBlockchainInformation", [{ chainId: orbyChainId }]);
|
14
13
|
if (code && message) {
|
15
14
|
console.error("[getBlockchainInformation]", code, message);
|
@@ -11,7 +11,7 @@ class InstanceActions extends library_request_js_1.LibraryRequest {
|
|
11
11
|
async setCustomChainEndpointsForInstance(chainEndpoints) {
|
12
12
|
const promises = chainEndpoints.map(async (endpoint) => {
|
13
13
|
return {
|
14
|
-
chainId: await
|
14
|
+
chainId: await this.getOrbyChainId(endpoint.chainId),
|
15
15
|
customRpcUrls: endpoint.customRpcUrls,
|
16
16
|
customIndexerUrls: endpoint.customIndexerUrls,
|
17
17
|
};
|
@@ -25,7 +25,7 @@ class InstanceActions extends library_request_js_1.LibraryRequest {
|
|
25
25
|
return success;
|
26
26
|
}
|
27
27
|
async removeCustomChainEndpointForInstance(chainIds) {
|
28
|
-
const promises = chainIds.map(async (chainId) => await
|
28
|
+
const promises = chainIds.map(async (chainId) => await this.getOrbyChainId(chainId));
|
29
29
|
const formattedChainIds = await Promise.all(promises);
|
30
30
|
const { success, code, message } = await this.sendRequest("orby_removeCustomChainEndpointForInstance", [{ chainIds: formattedChainIds }]);
|
31
31
|
if (code && message) {
|
@@ -5,7 +5,6 @@ const action_helpers_js_1 = require("../utils/action_helpers.js");
|
|
5
5
|
const currency_amount_js_1 = require("../entities/financial/currency_amount.js");
|
6
6
|
const enums_js_1 = require("../enums.js");
|
7
7
|
const library_request_js_1 = require("../entities/library_request.js");
|
8
|
-
const utils_js_1 = require("../utils/utils.js");
|
9
8
|
const account_js_1 = require("../entities/account.js");
|
10
9
|
// from here: https://stackoverflow.com/questions/65152373/typescript-serialize-bigint-in-json
|
11
10
|
BigInt.prototype.toJSON = function () {
|
@@ -20,7 +19,7 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
20
19
|
? {
|
21
20
|
...gasToken,
|
22
21
|
tokenSources: await Promise.all(gasToken.tokenSources?.map(async ({ chainId, address }) => ({
|
23
|
-
chainId: await
|
22
|
+
chainId: await this.getOrbyChainId(chainId),
|
24
23
|
address,
|
25
24
|
})) ?? []),
|
26
25
|
}
|
@@ -41,7 +40,7 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
41
40
|
? {
|
42
41
|
...gasToken,
|
43
42
|
tokenSources: await Promise.all(gasToken.tokenSources?.map(async ({ chainId, address }) => ({
|
44
|
-
chainId: await
|
43
|
+
chainId: await this.getOrbyChainId(chainId),
|
45
44
|
address,
|
46
45
|
})) ?? []),
|
47
46
|
}
|
@@ -60,7 +59,7 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
60
59
|
? {
|
61
60
|
...gasToken,
|
62
61
|
tokenSources: await Promise.all(gasToken.tokenSources?.map(async ({ chainId, address }) => ({
|
63
|
-
chainId: await
|
62
|
+
chainId: await this.getOrbyChainId(chainId),
|
64
63
|
address,
|
65
64
|
})) ?? []),
|
66
65
|
}
|
@@ -156,13 +155,13 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
156
155
|
? {
|
157
156
|
...gasToken,
|
158
157
|
tokenSources: await Promise.all(gasToken.tokenSources?.map(async ({ chainId, address }) => ({
|
159
|
-
chainId: await
|
158
|
+
chainId: await this.getOrbyChainId(chainId),
|
160
159
|
address,
|
161
160
|
})) ?? []),
|
162
161
|
}
|
163
162
|
: undefined;
|
164
163
|
const formattedRecepient = {
|
165
|
-
chainId: await
|
164
|
+
chainId: await this.getOrbyChainId(recipient.chainId),
|
166
165
|
recipientAddress: recipient.recipientAddress,
|
167
166
|
};
|
168
167
|
const operationSet = await this.sendRequest("orby_getOperationsToTransferToken", [
|
@@ -181,7 +180,7 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
181
180
|
? {
|
182
181
|
...input,
|
183
182
|
tokenSources: await Promise.all(input.tokenSources?.map(async ({ chainId, address }) => ({
|
184
|
-
chainId: await
|
183
|
+
chainId: await this.getOrbyChainId(chainId),
|
185
184
|
address,
|
186
185
|
})) ?? []),
|
187
186
|
}
|
@@ -191,7 +190,7 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
191
190
|
...output,
|
192
191
|
tokenDestination: output.tokenDestination
|
193
192
|
? {
|
194
|
-
chainId: await
|
193
|
+
chainId: await this.getOrbyChainId(output.tokenDestination.chainId),
|
195
194
|
address: output.tokenDestination.address,
|
196
195
|
}
|
197
196
|
: undefined,
|
@@ -201,7 +200,7 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
201
200
|
? {
|
202
201
|
...gasToken,
|
203
202
|
tokenSources: await Promise.all(gasToken.tokenSources?.map(async ({ chainId, address }) => ({
|
204
|
-
chainId: await
|
203
|
+
chainId: await this.getOrbyChainId(chainId),
|
205
204
|
address,
|
206
205
|
})) ?? []),
|
207
206
|
}
|
@@ -222,7 +221,7 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
222
221
|
? {
|
223
222
|
...input,
|
224
223
|
tokenSources: await Promise.all(input.tokenSources?.map(async ({ chainId, address }) => ({
|
225
|
-
chainId: await
|
224
|
+
chainId: await this.getOrbyChainId(chainId),
|
226
225
|
address,
|
227
226
|
})) ?? []),
|
228
227
|
}
|
@@ -232,7 +231,7 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
232
231
|
...output,
|
233
232
|
tokenDestination: output.tokenDestination
|
234
233
|
? {
|
235
|
-
chainId: await
|
234
|
+
chainId: await this.getOrbyChainId(output.tokenDestination.chainId),
|
236
235
|
address: output.tokenDestination.address,
|
237
236
|
}
|
238
237
|
: undefined,
|
@@ -250,12 +249,12 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
250
249
|
}
|
251
250
|
async getOperationsToBridge(accountClusterId, standardizedTokenId, amount, tokenSources, tokenDestination, gasToken) {
|
252
251
|
const formattedTokenSources = await Promise.all(tokenSources.map(async ({ chainId, address }) => ({
|
253
|
-
chainId: await
|
252
|
+
chainId: await this.getOrbyChainId(chainId),
|
254
253
|
address,
|
255
254
|
})));
|
256
255
|
const formattedDestination = tokenDestination
|
257
256
|
? {
|
258
|
-
chainId: await
|
257
|
+
chainId: await this.getOrbyChainId(tokenDestination.chainId),
|
259
258
|
address: tokenDestination.address,
|
260
259
|
}
|
261
260
|
: undefined;
|
@@ -263,7 +262,7 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
263
262
|
? {
|
264
263
|
...gasToken,
|
265
264
|
tokenSources: await Promise.all(gasToken.tokenSources?.map(async ({ chainId, address }) => ({
|
266
|
-
chainId: await
|
265
|
+
chainId: await this.getOrbyChainId(chainId),
|
267
266
|
address,
|
268
267
|
})) ?? []),
|
269
268
|
}
|
@@ -394,7 +393,7 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
394
393
|
signature: signature,
|
395
394
|
data: operation.data,
|
396
395
|
from: operation.from,
|
397
|
-
chainId: await
|
396
|
+
chainId: await this.getOrbyChainId(operation.chainId),
|
398
397
|
});
|
399
398
|
}
|
400
399
|
// batch sign all the smart contract transactions
|
@@ -424,7 +423,7 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
424
423
|
signature: userOperation.signature,
|
425
424
|
data: JSON.stringify(userOperation),
|
426
425
|
from: transactions[0].from,
|
427
|
-
chainId: await
|
426
|
+
chainId: await this.getOrbyChainId(transactions[0].chainId),
|
428
427
|
});
|
429
428
|
}
|
430
429
|
const { operationSetId, operationResponses } = await this.sendSignedOperations(accountCluster.accountClusterId, signedOperations);
|
@@ -3,14 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TokenActions = void 0;
|
4
4
|
const action_helpers_js_1 = require("../utils/action_helpers.js");
|
5
5
|
const library_request_js_1 = require("../entities/library_request.js");
|
6
|
-
const utils_js_1 = require("../utils/utils.js");
|
7
6
|
class TokenActions extends library_request_js_1.LibraryRequest {
|
8
7
|
constructor(library, client, provider) {
|
9
8
|
super(library, client, provider);
|
10
9
|
}
|
11
10
|
async getStandardizedTokenIds(tokens) {
|
12
11
|
const promises = tokens.map(async ({ tokenAddress, chainId }) => {
|
13
|
-
return { chainId: await
|
12
|
+
return { chainId: await this.getOrbyChainId(chainId), tokenAddress };
|
14
13
|
});
|
15
14
|
const formattedTokensInfo = await Promise.all(promises);
|
16
15
|
const { standardizedTokenIds, message, code } = await this.sendRequest("orby_getStandardizedTokenIds", [
|
@@ -26,7 +25,7 @@ class TokenActions extends library_request_js_1.LibraryRequest {
|
|
26
25
|
}
|
27
26
|
async getStandardizedTokens(tokens) {
|
28
27
|
const promises = tokens.map(async ({ tokenAddress, chainId }) => {
|
29
|
-
return { chainId: await
|
28
|
+
return { chainId: await this.getOrbyChainId(chainId), tokenAddress };
|
30
29
|
});
|
31
30
|
const formattedTokensInfo = await Promise.all(promises);
|
32
31
|
const { standardizedTokens, message, code } = await this.sendRequest("orby_getStandardizedTokens", [
|
package/dist/cjs/constants.d.ts
CHANGED
@@ -1,9 +1,5 @@
|
|
1
|
-
import { Blockchain } from "./enums.js";
|
2
1
|
import { Currency } from "./entities/financial/currency.js";
|
3
2
|
import { ChainConfigs } from "./types.js";
|
4
3
|
export declare const Big: any;
|
5
|
-
export declare const
|
6
|
-
export declare const BLOCKCHAIN_ID: Record<Blockchain, number>;
|
7
|
-
export declare const CHAIN_CONFIGS: Record<Blockchain, ChainConfigs>;
|
8
|
-
export declare const BLOCKCHAIN_ID_TO_BLOCKCHAIN: Record<number, Blockchain>;
|
4
|
+
export declare const CHAIN_CONFIGS: Record<number, ChainConfigs>;
|
9
5
|
export declare const FIAT_CURRENCY: Currency;
|
package/dist/cjs/constants.js
CHANGED
@@ -3,14 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.FIAT_CURRENCY = exports.
|
6
|
+
exports.FIAT_CURRENCY = exports.CHAIN_CONFIGS = exports.Big = void 0;
|
7
7
|
const toformat_1 = __importDefault(require("toformat"));
|
8
8
|
const big_js_1 = __importDefault(require("big.js"));
|
9
9
|
const currency_js_1 = require("./entities/financial/currency.js");
|
10
10
|
exports.Big = (0, toformat_1.default)(big_js_1.default);
|
11
|
-
// TO-DO (Sofia): fix API to return full list instead of just mainnet
|
12
|
-
exports.ORBY_URL = "https://api-rpc-dev.orblabs.xyz/f1c1d996-8df4-4d23-b926-ca702173021d/mainnet";
|
13
|
-
exports.BLOCKCHAIN_ID = {};
|
14
11
|
exports.CHAIN_CONFIGS = {};
|
15
|
-
exports.BLOCKCHAIN_ID_TO_BLOCKCHAIN = {};
|
16
12
|
exports.FIAT_CURRENCY = new currency_js_1.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
|
}
|
@@ -6,8 +6,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.LibraryRequest = void 0;
|
7
7
|
const enums_js_1 = require("../enums.js");
|
8
8
|
const tiny_invariant_1 = __importDefault(require("tiny-invariant"));
|
9
|
+
const constants_js_1 = require("../constants.js");
|
10
|
+
const utils_js_1 = require("../utils/utils.js");
|
9
11
|
class LibraryRequest {
|
10
12
|
constructor(library, client, provider) {
|
13
|
+
this.getOrbyChainId = async (chainId) => {
|
14
|
+
if (!chainId) {
|
15
|
+
return undefined;
|
16
|
+
}
|
17
|
+
const environment = await this.getVirtualEnvironment(chainId);
|
18
|
+
switch (environment) {
|
19
|
+
case enums_js_1.VMType.SVM:
|
20
|
+
return `SVM-${chainId.toString()}`;
|
21
|
+
case enums_js_1.VMType.EVM:
|
22
|
+
return `EIP155-${chainId.toString()}`;
|
23
|
+
default:
|
24
|
+
return undefined;
|
25
|
+
}
|
26
|
+
};
|
27
|
+
this.getVirtualEnvironment = async (id) => {
|
28
|
+
if (Object.keys(constants_js_1.CHAIN_CONFIGS).length == 0) {
|
29
|
+
await (0, utils_js_1.initializeBlockchainInformation)(this.providerUrl());
|
30
|
+
}
|
31
|
+
return constants_js_1.CHAIN_CONFIGS[Number(id)]?.vmType;
|
32
|
+
};
|
11
33
|
if (library == enums_js_1.LIBRARY_TYPE.VIEM) {
|
12
34
|
(0, tiny_invariant_1.default)(client, "CLIENT");
|
13
35
|
(0, tiny_invariant_1.default)(!provider, "PROVIDER");
|
@@ -26,6 +48,9 @@ class LibraryRequest {
|
|
26
48
|
this.provider = provider;
|
27
49
|
}
|
28
50
|
sendRequest(method, params) {
|
51
|
+
if (Object.keys(constants_js_1.CHAIN_CONFIGS).length == 0) {
|
52
|
+
(0, utils_js_1.initializeBlockchainInformation)(this.providerUrl());
|
53
|
+
}
|
29
54
|
if (this.library == enums_js_1.LIBRARY_TYPE.VIEM) {
|
30
55
|
return this.client.request({ method, params });
|
31
56
|
}
|
@@ -33,5 +58,20 @@ class LibraryRequest {
|
|
33
58
|
return this.provider.send(method, params);
|
34
59
|
}
|
35
60
|
}
|
61
|
+
providerUrl() {
|
62
|
+
let url = "";
|
63
|
+
if (this.library == enums_js_1.LIBRARY_TYPE.VIEM) {
|
64
|
+
url = this.client?.transport?.url;
|
65
|
+
}
|
66
|
+
else if (this.library == enums_js_1.LIBRARY_TYPE.ETHERS) {
|
67
|
+
url = this.provider._getConnection().url;
|
68
|
+
}
|
69
|
+
const uuidRegex = /([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/i;
|
70
|
+
const match = url.match(uuidRegex);
|
71
|
+
if (!match)
|
72
|
+
return url;
|
73
|
+
const endIndex = url.indexOf(match[1]) + match[1].length;
|
74
|
+
return url.slice(0, endIndex);
|
75
|
+
}
|
36
76
|
}
|
37
77
|
exports.LibraryRequest = LibraryRequest;
|
package/dist/cjs/enums.d.ts
CHANGED
@@ -1,28 +1,3 @@
|
|
1
|
-
export declare enum Blockchain {
|
2
|
-
ETHEREUM = "ethereum",
|
3
|
-
POLYGON = "polygon",
|
4
|
-
BINANCE = "binance",
|
5
|
-
ARBITRUM = "arbitrum",
|
6
|
-
BASE = "base",
|
7
|
-
AVALANCHE = "avalanche",
|
8
|
-
ARBITRUM_NOVA = "arbitrum_nova",
|
9
|
-
OPTIMISM = "optimism",
|
10
|
-
EVMOS = "evmos",
|
11
|
-
MOONBEAM = "moonbeam",
|
12
|
-
SOLANA = "solana",
|
13
|
-
ETHEREUM_SEPOLIA = "ethereum_sepolia",
|
14
|
-
ETHEREUM_HOLESKY = "ethereum_holesky",
|
15
|
-
BASE_SEPOLIA = "base_sepolia",
|
16
|
-
ARBITRUM_SEPOLIA = "arbitrum_sepolia",
|
17
|
-
OPTIMISM_SEPOLIA = "optimism_sepolia",
|
18
|
-
POLYGON_AMOY = "polygon_amoy",
|
19
|
-
BINANCE_TESTNET = "binance_testnet",
|
20
|
-
OPBNB_TESTNET = "opbnb_testnet",
|
21
|
-
MOONBEAM_ALPHA = "moonbeam_alpha",
|
22
|
-
HARDHAT = "hardhat",
|
23
|
-
LOCAL_CHAIN_0 = "local_chain_0",
|
24
|
-
LOCAL_CHAIN_1 = "local_chain_1"
|
25
|
-
}
|
26
1
|
export declare enum TokenType {
|
27
2
|
FUNGIBLE_TOKEN = "FUNGIBLE_TOKEN",
|
28
3
|
NON_FUNGIBLE_TOKEN = "NON_FUNGIBLE_TOKEN",
|
package/dist/cjs/enums.js
CHANGED
@@ -1,34 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.LIBRARY_TYPE = exports.TimeIntervalUnits = exports.TokenAllowlistType = exports.BlockchainEnvironment = exports.ActivityStatus = exports.Order = exports.QuoteType = exports.OperationStatusType = exports.Category = exports.OperationType = exports.OperationDataFormat = exports.CreateOperationsStatus = exports.ChainSupportStatus = exports.VMType = exports.AccountType = exports.TokenType =
|
4
|
-
var Blockchain;
|
5
|
-
(function (Blockchain) {
|
6
|
-
Blockchain["ETHEREUM"] = "ethereum";
|
7
|
-
Blockchain["POLYGON"] = "polygon";
|
8
|
-
Blockchain["BINANCE"] = "binance";
|
9
|
-
Blockchain["ARBITRUM"] = "arbitrum";
|
10
|
-
Blockchain["BASE"] = "base";
|
11
|
-
Blockchain["AVALANCHE"] = "avalanche";
|
12
|
-
Blockchain["ARBITRUM_NOVA"] = "arbitrum_nova";
|
13
|
-
Blockchain["OPTIMISM"] = "optimism";
|
14
|
-
Blockchain["EVMOS"] = "evmos";
|
15
|
-
Blockchain["MOONBEAM"] = "moonbeam";
|
16
|
-
Blockchain["SOLANA"] = "solana";
|
17
|
-
// testnets
|
18
|
-
Blockchain["ETHEREUM_SEPOLIA"] = "ethereum_sepolia";
|
19
|
-
Blockchain["ETHEREUM_HOLESKY"] = "ethereum_holesky";
|
20
|
-
Blockchain["BASE_SEPOLIA"] = "base_sepolia";
|
21
|
-
Blockchain["ARBITRUM_SEPOLIA"] = "arbitrum_sepolia";
|
22
|
-
Blockchain["OPTIMISM_SEPOLIA"] = "optimism_sepolia";
|
23
|
-
Blockchain["POLYGON_AMOY"] = "polygon_amoy";
|
24
|
-
Blockchain["BINANCE_TESTNET"] = "binance_testnet";
|
25
|
-
Blockchain["OPBNB_TESTNET"] = "opbnb_testnet";
|
26
|
-
Blockchain["MOONBEAM_ALPHA"] = "moonbeam_alpha";
|
27
|
-
// local testing
|
28
|
-
Blockchain["HARDHAT"] = "hardhat";
|
29
|
-
Blockchain["LOCAL_CHAIN_0"] = "local_chain_0";
|
30
|
-
Blockchain["LOCAL_CHAIN_1"] = "local_chain_1";
|
31
|
-
})(Blockchain || (exports.Blockchain = Blockchain = {}));
|
3
|
+
exports.LIBRARY_TYPE = exports.TimeIntervalUnits = exports.TokenAllowlistType = exports.BlockchainEnvironment = exports.ActivityStatus = exports.Order = exports.QuoteType = exports.OperationStatusType = exports.Category = exports.OperationType = exports.OperationDataFormat = exports.CreateOperationsStatus = exports.ChainSupportStatus = exports.VMType = exports.AccountType = exports.TokenType = void 0;
|
32
4
|
var TokenType;
|
33
5
|
(function (TokenType) {
|
34
6
|
TokenType["FUNGIBLE_TOKEN"] = "FUNGIBLE_TOKEN";
|
package/dist/cjs/types.d.ts
CHANGED
@@ -4,7 +4,7 @@ import { CurrencyAmount } from "./entities/financial/currency_amount.js";
|
|
4
4
|
import { FungibleToken } from "./entities/financial/fungible_token.js";
|
5
5
|
import { FungibleTokenAmount } from "./entities/financial/fungible_token_amount.js";
|
6
6
|
import { State } from "./entities/state.js";
|
7
|
-
import { ActivityStatus, BlockchainEnvironment, Category, CreateOperationsStatus, OperationDataFormat, OperationStatusType, OperationType, TimeIntervalUnits, TokenAllowlistType } from "./enums.js";
|
7
|
+
import { ActivityStatus, BlockchainEnvironment, Category, CreateOperationsStatus, OperationDataFormat, OperationStatusType, OperationType, TimeIntervalUnits, TokenAllowlistType, VMType } from "./enums.js";
|
8
8
|
export type AccountCluster = {
|
9
9
|
accountClusterId: string;
|
10
10
|
accounts: Account[];
|
@@ -164,6 +164,10 @@ export type GasSponsorshipData = {
|
|
164
164
|
export type ChainConfigs = {
|
165
165
|
environment: BlockchainEnvironment;
|
166
166
|
chainId: bigint;
|
167
|
+
vmType: VMType;
|
168
|
+
logoUrl: string;
|
169
|
+
name: string;
|
170
|
+
genesisBlockHash?: string;
|
167
171
|
};
|
168
172
|
export type VirtualNodeRpcUrlForSupportedChain = {
|
169
173
|
chainId: string;
|
@@ -1,10 +1,8 @@
|
|
1
|
-
import {
|
2
|
-
export declare const
|
1
|
+
import { VMType } from "../enums.js";
|
2
|
+
export declare const initializeBlockchainInformation: (orbyUrl: string) => Promise<void>;
|
3
3
|
export declare const getChainIdFromOrbyChainId: (value: string) => bigint | undefined;
|
4
4
|
export declare const getVirtualEnvironment: (id: bigint) => Promise<VMType>;
|
5
|
-
export declare const getOrbyChainId: (chainId: bigint) => Promise<string>;
|
6
5
|
export declare const hasError: (data: any) => {
|
7
6
|
code: number;
|
8
7
|
message: string;
|
9
8
|
};
|
10
|
-
export declare const getBlockchainFromName: (chainName: string) => Blockchain;
|
package/dist/cjs/utils/utils.js
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
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");
|
7
|
-
const
|
8
|
-
const response = await fetch(
|
6
|
+
const initializeBlockchainInformation = async (orbyUrl) => {
|
7
|
+
const response = await fetch(orbyUrl, {
|
9
8
|
method: "POST",
|
10
9
|
headers: {
|
11
10
|
"Content-Type": "application/json",
|
@@ -24,18 +23,15 @@ const initializeBlockchainInfo = async () => {
|
|
24
23
|
}
|
25
24
|
result.edges?.map((blockchainInfo) => {
|
26
25
|
const chainId = (0, exports.getChainIdFromOrbyChainId)(blockchainInfo.chainId);
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
constants_js_1.CHAIN_CONFIGS[blockchainName] = {
|
32
|
-
environment: blockchainInfo.environment,
|
33
|
-
chainId: chainId
|
26
|
+
if (chainId && blockchainInfo?.name) {
|
27
|
+
constants_js_1.CHAIN_CONFIGS[Number(chainId)] = {
|
28
|
+
...blockchainInfo,
|
29
|
+
chainId: chainId,
|
34
30
|
};
|
35
31
|
}
|
36
32
|
});
|
37
33
|
};
|
38
|
-
exports.
|
34
|
+
exports.initializeBlockchainInformation = initializeBlockchainInformation;
|
39
35
|
const getChainIdFromOrbyChainId = (value) => {
|
40
36
|
let chainId = undefined;
|
41
37
|
const formattedValue = (0, validateAndParseAddress_js_1.validateAndLowerCase)(value);
|
@@ -53,46 +49,13 @@ const getChainIdFromOrbyChainId = (value) => {
|
|
53
49
|
? BigInt(potentialId)
|
54
50
|
: undefined;
|
55
51
|
}
|
56
|
-
else {
|
57
|
-
const blockchain = (0, exports.getBlockchainFromName)(formattedValue);
|
58
|
-
const potentialId = blockchain
|
59
|
-
? constants_js_1.BLOCKCHAIN_ID[blockchain]
|
60
|
-
: undefined;
|
61
|
-
chainId = potentialId ? BigInt(potentialId) : undefined;
|
62
|
-
}
|
63
52
|
return chainId;
|
64
53
|
};
|
65
54
|
exports.getChainIdFromOrbyChainId = getChainIdFromOrbyChainId;
|
66
55
|
const getVirtualEnvironment = async (id) => {
|
67
|
-
|
68
|
-
await (0, exports.initializeBlockchainInfo)();
|
69
|
-
}
|
70
|
-
const blockchain = id ? constants_js_1.BLOCKCHAIN_ID_TO_BLOCKCHAIN[Number(id)] : undefined;
|
71
|
-
switch (blockchain) {
|
72
|
-
case undefined:
|
73
|
-
return undefined;
|
74
|
-
case enums_js_1.Blockchain.SOLANA:
|
75
|
-
return enums_js_1.VMType.SVM;
|
76
|
-
default:
|
77
|
-
return enums_js_1.VMType.EVM;
|
78
|
-
}
|
56
|
+
return constants_js_1.CHAIN_CONFIGS[Number(id)]?.vmType;
|
79
57
|
};
|
80
58
|
exports.getVirtualEnvironment = getVirtualEnvironment;
|
81
|
-
const getOrbyChainId = async (chainId) => {
|
82
|
-
if (!chainId) {
|
83
|
-
return undefined;
|
84
|
-
}
|
85
|
-
const environment = await (0, exports.getVirtualEnvironment)(chainId);
|
86
|
-
switch (environment) {
|
87
|
-
case enums_js_1.VMType.SVM:
|
88
|
-
return `SVM-${chainId.toString()}`;
|
89
|
-
case enums_js_1.VMType.EVM:
|
90
|
-
return `EIP155-${chainId.toString()}`;
|
91
|
-
default:
|
92
|
-
return undefined;
|
93
|
-
}
|
94
|
-
};
|
95
|
-
exports.getOrbyChainId = getOrbyChainId;
|
96
59
|
const hasError = (data) => {
|
97
60
|
if (data?.code && data?.message) {
|
98
61
|
return { code: data.code, message: data.message };
|
@@ -100,34 +63,3 @@ const hasError = (data) => {
|
|
100
63
|
return undefined;
|
101
64
|
};
|
102
65
|
exports.hasError = hasError;
|
103
|
-
const getBlockchainFromName = (chainName) => {
|
104
|
-
const formattedChainName = (0, validateAndParseAddress_js_1.validateAndLowerCase)(chainName)?.replace("-", "_");
|
105
|
-
switch (formattedChainName) {
|
106
|
-
case "bnbt": {
|
107
|
-
return enums_js_1.Blockchain.BINANCE_TESTNET;
|
108
|
-
}
|
109
|
-
case "matic_amoy": {
|
110
|
-
return enums_js_1.Blockchain.POLYGON_AMOY;
|
111
|
-
}
|
112
|
-
case "matic": {
|
113
|
-
return enums_js_1.Blockchain.POLYGON;
|
114
|
-
}
|
115
|
-
case "mainnet": {
|
116
|
-
return enums_js_1.Blockchain.ETHEREUM;
|
117
|
-
}
|
118
|
-
case "holesky": {
|
119
|
-
return enums_js_1.Blockchain.ETHEREUM_HOLESKY;
|
120
|
-
}
|
121
|
-
case "sepolia": {
|
122
|
-
return enums_js_1.Blockchain.ETHEREUM_SEPOLIA;
|
123
|
-
}
|
124
|
-
case "unknown": {
|
125
|
-
return undefined;
|
126
|
-
}
|
127
|
-
default: {
|
128
|
-
//statements;
|
129
|
-
return formattedChainName;
|
130
|
-
}
|
131
|
-
}
|
132
|
-
};
|
133
|
-
exports.getBlockchainFromName = getBlockchainFromName;
|
@@ -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
|
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) {
|
@@ -69,7 +69,7 @@ export class AccountClusterActions extends LibraryRequest {
|
|
69
69
|
async setCustomChainEndpointsForAccountCluster(accountClusterId, chainEndpoints) {
|
70
70
|
const promises = chainEndpoints.map(async (endpoint) => {
|
71
71
|
return {
|
72
|
-
chainId: await getOrbyChainId(endpoint.chainId),
|
72
|
+
chainId: await this.getOrbyChainId(endpoint.chainId),
|
73
73
|
customRpcUrls: endpoint.customRpcUrls,
|
74
74
|
customIndexerUrls: endpoint.customIndexerUrls,
|
75
75
|
};
|
@@ -88,7 +88,7 @@ export class AccountClusterActions extends LibraryRequest {
|
|
88
88
|
return success;
|
89
89
|
}
|
90
90
|
async removeCustomChainEndpointsForAccountCluster(accountClusterId, chainIds) {
|
91
|
-
const promises = chainIds.map(async (chainId) => await getOrbyChainId(chainId));
|
91
|
+
const promises = chainIds.map(async (chainId) => await this.getOrbyChainId(chainId));
|
92
92
|
const formattedChainIds = Promise.all(promises);
|
93
93
|
const { success, message, code } = await this.sendRequest("orby_removeCustomChainEndpointsForAccountCluster", [
|
94
94
|
{
|
@@ -122,7 +122,7 @@ export class AccountClusterActions extends LibraryRequest {
|
|
122
122
|
});
|
123
123
|
}
|
124
124
|
async isChainSupportedOnAccountCluster(accountClusterId, chainId) {
|
125
|
-
const orbyChainId = await getOrbyChainId(chainId);
|
125
|
+
const orbyChainId = await this.getOrbyChainId(chainId);
|
126
126
|
const { supportStatus, message, code } = await this.sendRequest("orby_isChainSupportedOnAccountCluster", [
|
127
127
|
{
|
128
128
|
accountClusterId,
|
@@ -136,7 +136,7 @@ export class AccountClusterActions extends LibraryRequest {
|
|
136
136
|
return supportStatus;
|
137
137
|
}
|
138
138
|
async getNodeRpcUrl(accountClusterId, chainId) {
|
139
|
-
const orbyChainId = await getOrbyChainId(chainId);
|
139
|
+
const orbyChainId = await this.getOrbyChainId(chainId);
|
140
140
|
const { nodeRpcUrl, code, message } = await this.sendRequest("orby_getNodeRpcUrl", [
|
141
141
|
{
|
142
142
|
accountClusterId,
|
@@ -150,7 +150,7 @@ export class AccountClusterActions extends LibraryRequest {
|
|
150
150
|
return nodeRpcUrl;
|
151
151
|
}
|
152
152
|
async getVirtualNodeRpcUrl(accountClusterId, chainId, entrypointAccountAddress) {
|
153
|
-
const orbyChainId = await getOrbyChainId(chainId);
|
153
|
+
const orbyChainId = await this.getOrbyChainId(chainId);
|
154
154
|
const { virtualNodeRpcUrl, message, code } = await this.sendRequest("orby_getVirtualNodeRpcUrl", [
|
155
155
|
{
|
156
156
|
accountClusterId,
|
@@ -195,7 +195,7 @@ export class AccountClusterActions extends LibraryRequest {
|
|
195
195
|
return extractStandardizedBalances(fungibleTokenBalances);
|
196
196
|
}
|
197
197
|
async getFungibleTokenBalances(accountClusterId, offset, limit, chainId, tokensToOmit) {
|
198
|
-
const orbyChainId = await getOrbyChainId(chainId);
|
198
|
+
const orbyChainId = await this.getOrbyChainId(chainId);
|
199
199
|
const { fungibleTokenBalances, code, message } = await this.sendRequest("orby_getFungibleTokenBalances", [
|
200
200
|
{
|
201
201
|
accountClusterId,
|