@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.
- package/CHANGELOG.md +9 -0
- package/dist/cjs/actions/account_cluster.js +13 -7
- package/dist/cjs/actions/blockchain.js +2 -2
- package/dist/cjs/actions/instance.js +5 -3
- package/dist/cjs/actions/operation.js +36 -37
- package/dist/cjs/actions/token.js +6 -5
- package/dist/cjs/constants.d.ts +3 -9
- package/dist/cjs/constants.js +3 -134
- package/dist/cjs/entities/library_request.d.ts +4 -1
- package/dist/cjs/entities/library_request.js +37 -0
- package/dist/cjs/types.d.ts +2 -1
- package/dist/cjs/utils/utils.d.ts +3 -6
- package/dist/cjs/utils/utils.js +38 -68
- package/dist/esm/actions/account_cluster.js +14 -8
- package/dist/esm/actions/blockchain.js +2 -2
- package/dist/esm/actions/instance.js +6 -4
- package/dist/esm/actions/operation.js +36 -37
- package/dist/esm/actions/token.js +6 -5
- package/dist/esm/constants.d.ts +3 -9
- package/dist/esm/constants.js +3 -134
- package/dist/esm/entities/library_request.d.ts +4 -1
- package/dist/esm/entities/library_request.js +38 -1
- package/dist/esm/types.d.ts +2 -1
- package/dist/esm/utils/utils.d.ts +3 -6
- package/dist/esm/utils/utils.js +36 -63
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,15 @@
|
|
2
2
|
|
3
3
|
### Unreleased
|
4
4
|
|
5
|
+
### 0.0.23
|
6
|
+
|
7
|
+
- refactoring how we get the blockchain list
|
8
|
+
|
9
|
+
### 0.0.22
|
10
|
+
|
11
|
+
- refactor constants to fetch directly from backend
|
12
|
+
- fix request method for getOperationsToSignTypeData
|
13
|
+
|
5
14
|
### 0.0.21
|
6
15
|
|
7
16
|
- make signing functions to sendOperationSet optional
|
@@ -70,13 +70,14 @@ class AccountClusterActions extends library_request_js_1.LibraryRequest {
|
|
70
70
|
return success;
|
71
71
|
}
|
72
72
|
async setCustomChainEndpointsForAccountCluster(accountClusterId, chainEndpoints) {
|
73
|
-
const
|
73
|
+
const promises = chainEndpoints.map(async (endpoint) => {
|
74
74
|
return {
|
75
|
-
chainId:
|
75
|
+
chainId: await this.getOrbyChainId(endpoint.chainId),
|
76
76
|
customRpcUrls: endpoint.customRpcUrls,
|
77
77
|
customIndexerUrls: endpoint.customIndexerUrls,
|
78
78
|
};
|
79
79
|
});
|
80
|
+
const formattedEndpoints = await Promise.all(promises);
|
80
81
|
const { success, message, code } = await this.sendRequest("orby_setCustomChainEndpointsForAccountCluster", [
|
81
82
|
{
|
82
83
|
accountClusterId,
|
@@ -90,7 +91,8 @@ class AccountClusterActions extends library_request_js_1.LibraryRequest {
|
|
90
91
|
return success;
|
91
92
|
}
|
92
93
|
async removeCustomChainEndpointsForAccountCluster(accountClusterId, chainIds) {
|
93
|
-
const
|
94
|
+
const promises = chainIds.map(async (chainId) => await this.getOrbyChainId(chainId));
|
95
|
+
const formattedChainIds = Promise.all(promises);
|
94
96
|
const { success, message, code } = await this.sendRequest("orby_removeCustomChainEndpointsForAccountCluster", [
|
95
97
|
{
|
96
98
|
accountClusterId,
|
@@ -123,10 +125,11 @@ class AccountClusterActions extends library_request_js_1.LibraryRequest {
|
|
123
125
|
});
|
124
126
|
}
|
125
127
|
async isChainSupportedOnAccountCluster(accountClusterId, chainId) {
|
128
|
+
const orbyChainId = await this.getOrbyChainId(chainId);
|
126
129
|
const { supportStatus, message, code } = await this.sendRequest("orby_isChainSupportedOnAccountCluster", [
|
127
130
|
{
|
128
131
|
accountClusterId,
|
129
|
-
chainId:
|
132
|
+
chainId: orbyChainId,
|
130
133
|
},
|
131
134
|
]);
|
132
135
|
if (code && message) {
|
@@ -136,10 +139,11 @@ class AccountClusterActions extends library_request_js_1.LibraryRequest {
|
|
136
139
|
return supportStatus;
|
137
140
|
}
|
138
141
|
async getNodeRpcUrl(accountClusterId, chainId) {
|
142
|
+
const orbyChainId = await this.getOrbyChainId(chainId);
|
139
143
|
const { nodeRpcUrl, code, message } = await this.sendRequest("orby_getNodeRpcUrl", [
|
140
144
|
{
|
141
145
|
accountClusterId,
|
142
|
-
chainId:
|
146
|
+
chainId: orbyChainId,
|
143
147
|
},
|
144
148
|
]);
|
145
149
|
if (code && message) {
|
@@ -149,10 +153,11 @@ class AccountClusterActions extends library_request_js_1.LibraryRequest {
|
|
149
153
|
return nodeRpcUrl;
|
150
154
|
}
|
151
155
|
async getVirtualNodeRpcUrl(accountClusterId, chainId, entrypointAccountAddress) {
|
156
|
+
const orbyChainId = await this.getOrbyChainId(chainId);
|
152
157
|
const { virtualNodeRpcUrl, message, code } = await this.sendRequest("orby_getVirtualNodeRpcUrl", [
|
153
158
|
{
|
154
159
|
accountClusterId,
|
155
|
-
chainId:
|
160
|
+
chainId: orbyChainId,
|
156
161
|
entrypointAccountAddress,
|
157
162
|
},
|
158
163
|
]);
|
@@ -193,12 +198,13 @@ class AccountClusterActions extends library_request_js_1.LibraryRequest {
|
|
193
198
|
return (0, action_helpers_js_1.extractStandardizedBalances)(fungibleTokenBalances);
|
194
199
|
}
|
195
200
|
async getFungibleTokenBalances(accountClusterId, offset, limit, chainId, tokensToOmit) {
|
201
|
+
const orbyChainId = await this.getOrbyChainId(chainId);
|
196
202
|
const { fungibleTokenBalances, code, message } = await this.sendRequest("orby_getFungibleTokenBalances", [
|
197
203
|
{
|
198
204
|
accountClusterId,
|
199
205
|
offset,
|
200
206
|
limit,
|
201
|
-
chainId:
|
207
|
+
chainId: orbyChainId,
|
202
208
|
tokensToOmit,
|
203
209
|
},
|
204
210
|
]);
|
@@ -3,13 +3,13 @@ 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
|
11
|
+
const orbyChainId = await this.getOrbyChainId(chainId);
|
12
|
+
const { blockchain, code, message } = await this.sendRequest("orby_getBlockchainInformation", [{ chainId: orbyChainId }]);
|
13
13
|
if (code && message) {
|
14
14
|
console.error("[getBlockchainInformation]", code, message);
|
15
15
|
return undefined;
|
@@ -9,13 +9,14 @@ class InstanceActions extends library_request_js_1.LibraryRequest {
|
|
9
9
|
super(library, client, provider);
|
10
10
|
}
|
11
11
|
async setCustomChainEndpointsForInstance(chainEndpoints) {
|
12
|
-
const
|
12
|
+
const promises = chainEndpoints.map(async (endpoint) => {
|
13
13
|
return {
|
14
|
-
chainId:
|
14
|
+
chainId: await this.getOrbyChainId(endpoint.chainId),
|
15
15
|
customRpcUrls: endpoint.customRpcUrls,
|
16
16
|
customIndexerUrls: endpoint.customIndexerUrls,
|
17
17
|
};
|
18
18
|
});
|
19
|
+
const formattedEndpoints = await Promise.all(promises);
|
19
20
|
const { success, code, message } = await this.sendRequest("orby_setCustomChainEndpointsForInstance", [{ chainEndpoints: formattedEndpoints }]);
|
20
21
|
if (code && message) {
|
21
22
|
console.error("[setCustomChainEndpointsForInstance]", code, message);
|
@@ -24,7 +25,8 @@ class InstanceActions extends library_request_js_1.LibraryRequest {
|
|
24
25
|
return success;
|
25
26
|
}
|
26
27
|
async removeCustomChainEndpointForInstance(chainIds) {
|
27
|
-
const
|
28
|
+
const promises = chainIds.map(async (chainId) => await this.getOrbyChainId(chainId));
|
29
|
+
const formattedChainIds = await Promise.all(promises);
|
28
30
|
const { success, code, message } = await this.sendRequest("orby_removeCustomChainEndpointForInstance", [{ chainIds: formattedChainIds }]);
|
29
31
|
if (code && message) {
|
30
32
|
console.error("[removeCustomChainEndpointForInstance]", 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 () {
|
@@ -19,10 +18,10 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
19
18
|
const formattedGasToken = gasToken
|
20
19
|
? {
|
21
20
|
...gasToken,
|
22
|
-
tokenSources: gasToken.tokenSources?.map(({ chainId, address }) => ({
|
23
|
-
chainId:
|
21
|
+
tokenSources: await Promise.all(gasToken.tokenSources?.map(async ({ chainId, address }) => ({
|
22
|
+
chainId: await this.getOrbyChainId(chainId),
|
24
23
|
address,
|
25
|
-
})),
|
24
|
+
})) ?? []),
|
26
25
|
}
|
27
26
|
: undefined;
|
28
27
|
const operationSet = await this.sendRequest("orby_getOperationsToExecuteTransaction", [
|
@@ -40,13 +39,13 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
40
39
|
const formattedGasToken = gasToken
|
41
40
|
? {
|
42
41
|
...gasToken,
|
43
|
-
tokenSources: gasToken.tokenSources?.map(({ chainId, address }) => ({
|
44
|
-
chainId:
|
42
|
+
tokenSources: await Promise.all(gasToken.tokenSources?.map(async ({ chainId, address }) => ({
|
43
|
+
chainId: await this.getOrbyChainId(chainId),
|
45
44
|
address,
|
46
|
-
})),
|
45
|
+
})) ?? []),
|
47
46
|
}
|
48
47
|
: undefined;
|
49
|
-
const operationSet = await this.sendRequest("
|
48
|
+
const operationSet = await this.sendRequest("orby_getOperationsToSignTypedData", [
|
50
49
|
{
|
51
50
|
accountClusterId,
|
52
51
|
data,
|
@@ -59,10 +58,10 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
59
58
|
const formattedGasToken = gasToken
|
60
59
|
? {
|
61
60
|
...gasToken,
|
62
|
-
tokenSources: gasToken.tokenSources?.map(({ chainId, address }) => ({
|
63
|
-
chainId:
|
61
|
+
tokenSources: await Promise.all(gasToken.tokenSources?.map(async ({ chainId, address }) => ({
|
62
|
+
chainId: await this.getOrbyChainId(chainId),
|
64
63
|
address,
|
65
|
-
})),
|
64
|
+
})) ?? []),
|
66
65
|
}
|
67
66
|
: undefined;
|
68
67
|
const operationSet = await this.sendRequest("orby_getOperationsToSignTransactionOrSignTypedData", [
|
@@ -155,14 +154,14 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
155
154
|
const formattedGasToken = gasToken
|
156
155
|
? {
|
157
156
|
...gasToken,
|
158
|
-
tokenSources: gasToken.tokenSources?.map(({ chainId, address }) => ({
|
159
|
-
chainId:
|
157
|
+
tokenSources: await Promise.all(gasToken.tokenSources?.map(async ({ chainId, address }) => ({
|
158
|
+
chainId: await this.getOrbyChainId(chainId),
|
160
159
|
address,
|
161
|
-
})),
|
160
|
+
})) ?? []),
|
162
161
|
}
|
163
162
|
: undefined;
|
164
163
|
const formattedRecepient = {
|
165
|
-
chainId:
|
164
|
+
chainId: await this.getOrbyChainId(recipient.chainId),
|
166
165
|
recipientAddress: recipient.recipientAddress,
|
167
166
|
};
|
168
167
|
const operationSet = await this.sendRequest("orby_getOperationsToTransferToken", [
|
@@ -180,18 +179,18 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
180
179
|
const formattedInput = input
|
181
180
|
? {
|
182
181
|
...input,
|
183
|
-
tokenSources: input?.
|
184
|
-
chainId:
|
182
|
+
tokenSources: await Promise.all(input.tokenSources?.map(async ({ chainId, address }) => ({
|
183
|
+
chainId: await this.getOrbyChainId(chainId),
|
185
184
|
address,
|
186
|
-
})),
|
185
|
+
})) ?? []),
|
187
186
|
}
|
188
187
|
: undefined;
|
189
188
|
const formattedOutput = output
|
190
189
|
? {
|
191
190
|
...output,
|
192
|
-
tokenDestination: output
|
191
|
+
tokenDestination: output.tokenDestination
|
193
192
|
? {
|
194
|
-
chainId:
|
193
|
+
chainId: await this.getOrbyChainId(output.tokenDestination.chainId),
|
195
194
|
address: output.tokenDestination.address,
|
196
195
|
}
|
197
196
|
: undefined,
|
@@ -200,10 +199,10 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
200
199
|
const formattedGasToken = gasToken
|
201
200
|
? {
|
202
201
|
...gasToken,
|
203
|
-
tokenSources: gasToken.tokenSources?.map(({ chainId, address }) => ({
|
204
|
-
chainId:
|
202
|
+
tokenSources: await Promise.all(gasToken.tokenSources?.map(async ({ chainId, address }) => ({
|
203
|
+
chainId: await this.getOrbyChainId(chainId),
|
205
204
|
address,
|
206
|
-
})),
|
205
|
+
})) ?? []),
|
207
206
|
}
|
208
207
|
: undefined;
|
209
208
|
const operationSet = await this.sendRequest("orby_getOperationsToSwap", [
|
@@ -221,18 +220,18 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
221
220
|
const formattedInput = input
|
222
221
|
? {
|
223
222
|
...input,
|
224
|
-
tokenSources: input?.
|
225
|
-
chainId:
|
223
|
+
tokenSources: await Promise.all(input.tokenSources?.map(async ({ chainId, address }) => ({
|
224
|
+
chainId: await this.getOrbyChainId(chainId),
|
226
225
|
address,
|
227
|
-
})),
|
226
|
+
})) ?? []),
|
228
227
|
}
|
229
228
|
: undefined;
|
230
229
|
const formattedOutput = output
|
231
230
|
? {
|
232
231
|
...output,
|
233
|
-
tokenDestination: output
|
232
|
+
tokenDestination: output.tokenDestination
|
234
233
|
? {
|
235
|
-
chainId:
|
234
|
+
chainId: await this.getOrbyChainId(output.tokenDestination.chainId),
|
236
235
|
address: output.tokenDestination.address,
|
237
236
|
}
|
238
237
|
: undefined,
|
@@ -249,23 +248,23 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
249
248
|
return (0, action_helpers_js_1.extractOperationSet)(operationSet);
|
250
249
|
}
|
251
250
|
async getOperationsToBridge(accountClusterId, standardizedTokenId, amount, tokenSources, tokenDestination, gasToken) {
|
252
|
-
const formattedTokenSources = tokenSources.map(({ chainId, address }) => ({
|
253
|
-
chainId:
|
251
|
+
const formattedTokenSources = await Promise.all(tokenSources.map(async ({ chainId, address }) => ({
|
252
|
+
chainId: await this.getOrbyChainId(chainId),
|
254
253
|
address,
|
255
|
-
}));
|
254
|
+
})));
|
256
255
|
const formattedDestination = tokenDestination
|
257
256
|
? {
|
258
|
-
chainId:
|
257
|
+
chainId: await this.getOrbyChainId(tokenDestination.chainId),
|
259
258
|
address: tokenDestination.address,
|
260
259
|
}
|
261
260
|
: undefined;
|
262
261
|
const formattedGasToken = gasToken
|
263
262
|
? {
|
264
263
|
...gasToken,
|
265
|
-
tokenSources: gasToken.tokenSources?.map(({ chainId, address }) => ({
|
266
|
-
chainId:
|
264
|
+
tokenSources: await Promise.all(gasToken.tokenSources?.map(async ({ chainId, address }) => ({
|
265
|
+
chainId: await this.getOrbyChainId(chainId),
|
267
266
|
address,
|
268
|
-
})),
|
267
|
+
})) ?? []),
|
269
268
|
}
|
270
269
|
: undefined;
|
271
270
|
const operationSet = await this.sendRequest("orby_getOperationsToBridge", [
|
@@ -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:
|
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:
|
426
|
+
chainId: await this.getOrbyChainId(transactions[0].chainId),
|
428
427
|
});
|
429
428
|
}
|
430
429
|
const { operationSetId, operationResponses } = await this.sendSignedOperations(accountCluster.accountClusterId, signedOperations);
|
@@ -3,15 +3,15 @@ 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
|
-
const
|
13
|
-
return { chainId:
|
11
|
+
const promises = tokens.map(async ({ tokenAddress, chainId }) => {
|
12
|
+
return { chainId: await this.getOrbyChainId(chainId), tokenAddress };
|
14
13
|
});
|
14
|
+
const formattedTokensInfo = await Promise.all(promises);
|
15
15
|
const { standardizedTokenIds, message, code } = await this.sendRequest("orby_getStandardizedTokenIds", [
|
16
16
|
{
|
17
17
|
tokens: formattedTokensInfo,
|
@@ -24,9 +24,10 @@ class TokenActions extends library_request_js_1.LibraryRequest {
|
|
24
24
|
return standardizedTokenIds;
|
25
25
|
}
|
26
26
|
async getStandardizedTokens(tokens) {
|
27
|
-
const
|
28
|
-
return { chainId:
|
27
|
+
const promises = tokens.map(async ({ tokenAddress, chainId }) => {
|
28
|
+
return { chainId: await this.getOrbyChainId(chainId), tokenAddress };
|
29
29
|
});
|
30
|
+
const formattedTokensInfo = await Promise.all(promises);
|
30
31
|
const { standardizedTokens, message, code } = await this.sendRequest("orby_getStandardizedTokens", [
|
31
32
|
{
|
32
33
|
tokens: formattedTokensInfo,
|
package/dist/cjs/constants.d.ts
CHANGED
@@ -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
|
-
|
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;
|
package/dist/cjs/constants.js
CHANGED
@@ -6,140 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.FIAT_CURRENCY = exports.BLOCKCHAIN_ID_TO_BLOCKCHAIN = exports.CHAIN_CONFIGS = exports.BLOCKCHAIN_ID = exports.Big = void 0;
|
7
7
|
const toformat_1 = __importDefault(require("toformat"));
|
8
8
|
const big_js_1 = __importDefault(require("big.js"));
|
9
|
-
const enums_js_1 = require("./enums.js");
|
10
9
|
const currency_js_1 = require("./entities/financial/currency.js");
|
11
10
|
exports.Big = (0, toformat_1.default)(big_js_1.default);
|
12
|
-
exports.BLOCKCHAIN_ID = {
|
13
|
-
|
14
|
-
|
15
|
-
[enums_js_1.Blockchain.BINANCE]: 56,
|
16
|
-
[enums_js_1.Blockchain.ARBITRUM]: 42161,
|
17
|
-
[enums_js_1.Blockchain.ARBITRUM_NOVA]: 42170,
|
18
|
-
[enums_js_1.Blockchain.OPTIMISM]: 10,
|
19
|
-
[enums_js_1.Blockchain.EVMOS]: 9001,
|
20
|
-
[enums_js_1.Blockchain.MOONBEAM]: 1284,
|
21
|
-
[enums_js_1.Blockchain.BASE]: 8453,
|
22
|
-
[enums_js_1.Blockchain.AVALANCHE]: 43114,
|
23
|
-
[enums_js_1.Blockchain.SOLANA]: 101,
|
24
|
-
// testnets
|
25
|
-
[enums_js_1.Blockchain.ETHEREUM_SEPOLIA]: 11155111,
|
26
|
-
[enums_js_1.Blockchain.ETHEREUM_HOLESKY]: 17000,
|
27
|
-
[enums_js_1.Blockchain.ARBITRUM_SEPOLIA]: 421614,
|
28
|
-
[enums_js_1.Blockchain.OPTIMISM_SEPOLIA]: 11155420,
|
29
|
-
[enums_js_1.Blockchain.POLYGON_AMOY]: 80002,
|
30
|
-
[enums_js_1.Blockchain.BINANCE_TESTNET]: 97,
|
31
|
-
[enums_js_1.Blockchain.OPBNB_TESTNET]: 5611,
|
32
|
-
[enums_js_1.Blockchain.MOONBEAM_ALPHA]: 1287,
|
33
|
-
[enums_js_1.Blockchain.BASE_SEPOLIA]: 84532,
|
34
|
-
// local testing
|
35
|
-
[enums_js_1.Blockchain.HARDHAT]: 31337,
|
36
|
-
[enums_js_1.Blockchain.LOCAL_CHAIN_0]: 1_000_000_000_001,
|
37
|
-
[enums_js_1.Blockchain.LOCAL_CHAIN_1]: 1_000_000_000_002,
|
38
|
-
};
|
39
|
-
exports.CHAIN_CONFIGS = {
|
40
|
-
[enums_js_1.Blockchain.ETHEREUM]: {
|
41
|
-
environment: enums_js_1.BlockchainEnvironment.MAINNET,
|
42
|
-
chainId: BigInt(1),
|
43
|
-
},
|
44
|
-
[enums_js_1.Blockchain.POLYGON]: {
|
45
|
-
environment: enums_js_1.BlockchainEnvironment.MAINNET,
|
46
|
-
chainId: BigInt(137),
|
47
|
-
},
|
48
|
-
[enums_js_1.Blockchain.BINANCE]: {
|
49
|
-
environment: enums_js_1.BlockchainEnvironment.MAINNET,
|
50
|
-
chainId: BigInt(56),
|
51
|
-
},
|
52
|
-
[enums_js_1.Blockchain.ARBITRUM]: {
|
53
|
-
environment: enums_js_1.BlockchainEnvironment.MAINNET,
|
54
|
-
chainId: BigInt(42161),
|
55
|
-
},
|
56
|
-
[enums_js_1.Blockchain.ARBITRUM_NOVA]: {
|
57
|
-
environment: enums_js_1.BlockchainEnvironment.MAINNET,
|
58
|
-
chainId: BigInt(42170),
|
59
|
-
},
|
60
|
-
[enums_js_1.Blockchain.OPTIMISM]: {
|
61
|
-
environment: enums_js_1.BlockchainEnvironment.MAINNET,
|
62
|
-
chainId: BigInt(10),
|
63
|
-
},
|
64
|
-
[enums_js_1.Blockchain.EVMOS]: {
|
65
|
-
environment: enums_js_1.BlockchainEnvironment.MAINNET,
|
66
|
-
chainId: BigInt(9001),
|
67
|
-
},
|
68
|
-
[enums_js_1.Blockchain.MOONBEAM]: {
|
69
|
-
environment: enums_js_1.BlockchainEnvironment.MAINNET,
|
70
|
-
chainId: BigInt(1284),
|
71
|
-
},
|
72
|
-
[enums_js_1.Blockchain.BASE]: {
|
73
|
-
environment: enums_js_1.BlockchainEnvironment.MAINNET,
|
74
|
-
chainId: BigInt(8453),
|
75
|
-
},
|
76
|
-
[enums_js_1.Blockchain.AVALANCHE]: {
|
77
|
-
environment: enums_js_1.BlockchainEnvironment.MAINNET,
|
78
|
-
chainId: BigInt(43114),
|
79
|
-
},
|
80
|
-
[enums_js_1.Blockchain.SOLANA]: {
|
81
|
-
environment: enums_js_1.BlockchainEnvironment.MAINNET,
|
82
|
-
chainId: BigInt(101),
|
83
|
-
},
|
84
|
-
// testnets
|
85
|
-
[enums_js_1.Blockchain.ETHEREUM_SEPOLIA]: {
|
86
|
-
environment: enums_js_1.BlockchainEnvironment.TESTNET,
|
87
|
-
chainId: BigInt(11155111),
|
88
|
-
},
|
89
|
-
[enums_js_1.Blockchain.ETHEREUM_HOLESKY]: {
|
90
|
-
environment: enums_js_1.BlockchainEnvironment.TESTNET,
|
91
|
-
chainId: BigInt(17000),
|
92
|
-
},
|
93
|
-
[enums_js_1.Blockchain.ARBITRUM_SEPOLIA]: {
|
94
|
-
environment: enums_js_1.BlockchainEnvironment.TESTNET,
|
95
|
-
chainId: BigInt(421614),
|
96
|
-
},
|
97
|
-
[enums_js_1.Blockchain.BASE_SEPOLIA]: {
|
98
|
-
environment: enums_js_1.BlockchainEnvironment.TESTNET,
|
99
|
-
chainId: BigInt(84532),
|
100
|
-
},
|
101
|
-
[enums_js_1.Blockchain.OPTIMISM_SEPOLIA]: {
|
102
|
-
environment: enums_js_1.BlockchainEnvironment.TESTNET,
|
103
|
-
chainId: BigInt(11155420),
|
104
|
-
},
|
105
|
-
[enums_js_1.Blockchain.BINANCE_TESTNET]: {
|
106
|
-
environment: enums_js_1.BlockchainEnvironment.TESTNET,
|
107
|
-
chainId: BigInt(97),
|
108
|
-
},
|
109
|
-
[enums_js_1.Blockchain.OPBNB_TESTNET]: {
|
110
|
-
environment: enums_js_1.BlockchainEnvironment.TESTNET,
|
111
|
-
chainId: BigInt(5611),
|
112
|
-
},
|
113
|
-
[enums_js_1.Blockchain.MOONBEAM_ALPHA]: {
|
114
|
-
environment: enums_js_1.BlockchainEnvironment.TESTNET,
|
115
|
-
chainId: BigInt(1287),
|
116
|
-
},
|
117
|
-
[enums_js_1.Blockchain.POLYGON_AMOY]: {
|
118
|
-
environment: enums_js_1.BlockchainEnvironment.TESTNET,
|
119
|
-
chainId: BigInt(80002),
|
120
|
-
},
|
121
|
-
};
|
122
|
-
exports.BLOCKCHAIN_ID_TO_BLOCKCHAIN = {
|
123
|
-
[1]: enums_js_1.Blockchain.ETHEREUM,
|
124
|
-
[137]: enums_js_1.Blockchain.POLYGON,
|
125
|
-
[56]: enums_js_1.Blockchain.BINANCE,
|
126
|
-
[42161]: enums_js_1.Blockchain.ARBITRUM,
|
127
|
-
[42170]: enums_js_1.Blockchain.ARBITRUM_NOVA,
|
128
|
-
[10]: enums_js_1.Blockchain.OPTIMISM,
|
129
|
-
[9001]: enums_js_1.Blockchain.EVMOS,
|
130
|
-
[1284]: enums_js_1.Blockchain.MOONBEAM,
|
131
|
-
[8453]: enums_js_1.Blockchain.BASE,
|
132
|
-
[43114]: enums_js_1.Blockchain.AVALANCHE,
|
133
|
-
[101]: enums_js_1.Blockchain.SOLANA,
|
134
|
-
// testnets
|
135
|
-
[11155111]: enums_js_1.Blockchain.ETHEREUM_SEPOLIA,
|
136
|
-
[84532]: enums_js_1.Blockchain.BASE_SEPOLIA,
|
137
|
-
[17000]: enums_js_1.Blockchain.ETHEREUM_HOLESKY,
|
138
|
-
[421614]: enums_js_1.Blockchain.ARBITRUM_SEPOLIA,
|
139
|
-
[11155420]: enums_js_1.Blockchain.OPTIMISM_SEPOLIA,
|
140
|
-
[80002]: enums_js_1.Blockchain.POLYGON_AMOY,
|
141
|
-
[97]: enums_js_1.Blockchain.BINANCE_TESTNET,
|
142
|
-
[5611]: enums_js_1.Blockchain.OPBNB_TESTNET,
|
143
|
-
[1287]: enums_js_1.Blockchain.MOONBEAM_ALPHA,
|
144
|
-
};
|
11
|
+
exports.BLOCKCHAIN_ID = {};
|
12
|
+
exports.CHAIN_CONFIGS = {};
|
13
|
+
exports.BLOCKCHAIN_ID_TO_BLOCKCHAIN = {};
|
145
14
|
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,37 @@ 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
|
+
console.log("ENVIRONMENT", environment);
|
19
|
+
switch (environment) {
|
20
|
+
case enums_js_1.VMType.SVM:
|
21
|
+
return `SVM-${chainId.toString()}`;
|
22
|
+
case enums_js_1.VMType.EVM:
|
23
|
+
return `EIP155-${chainId.toString()}`;
|
24
|
+
default:
|
25
|
+
return undefined;
|
26
|
+
}
|
27
|
+
};
|
28
|
+
this.getVirtualEnvironment = async (id) => {
|
29
|
+
if (Object.keys(constants_js_1.BLOCKCHAIN_ID_TO_BLOCKCHAIN).length == 0) {
|
30
|
+
await (0, utils_js_1.initializeBlockchainInformation)(this.providerUrl());
|
31
|
+
}
|
32
|
+
console.log("CHAIN_CONFIGS", constants_js_1.CHAIN_CONFIGS);
|
33
|
+
const blockchain = id ? constants_js_1.BLOCKCHAIN_ID_TO_BLOCKCHAIN[Number(id)] : undefined;
|
34
|
+
if (!blockchain) {
|
35
|
+
console.error("No blockchain found for chainId", id);
|
36
|
+
return undefined;
|
37
|
+
}
|
38
|
+
return constants_js_1.CHAIN_CONFIGS[blockchain]?.vmType;
|
39
|
+
};
|
11
40
|
if (library == enums_js_1.LIBRARY_TYPE.VIEM) {
|
12
41
|
(0, tiny_invariant_1.default)(client, "CLIENT");
|
13
42
|
(0, tiny_invariant_1.default)(!provider, "PROVIDER");
|
@@ -33,5 +62,13 @@ class LibraryRequest {
|
|
33
62
|
return this.provider.send(method, params);
|
34
63
|
}
|
35
64
|
}
|
65
|
+
providerUrl() {
|
66
|
+
if (this.library == enums_js_1.LIBRARY_TYPE.VIEM) {
|
67
|
+
return this.client?.transport?.url;
|
68
|
+
}
|
69
|
+
else if (this.library == enums_js_1.LIBRARY_TYPE.ETHERS) {
|
70
|
+
return this.provider._getConnection().url;
|
71
|
+
}
|
72
|
+
}
|
36
73
|
}
|
37
74
|
exports.LibraryRequest = LibraryRequest;
|
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,7 @@ export type GasSponsorshipData = {
|
|
164
164
|
export type ChainConfigs = {
|
165
165
|
environment: BlockchainEnvironment;
|
166
166
|
chainId: bigint;
|
167
|
+
vmType: VMType;
|
167
168
|
};
|
168
169
|
export type VirtualNodeRpcUrlForSupportedChain = {
|
169
170
|
chainId: string;
|
@@ -1,11 +1,8 @@
|
|
1
|
-
import {
|
1
|
+
import { VMType } from "../enums.js";
|
2
|
+
export declare const initializeBlockchainInformation: (orbyUrl: string) => Promise<void>;
|
2
3
|
export declare const getChainIdFromOrbyChainId: (value: string) => bigint | undefined;
|
3
|
-
export declare const getVirtualEnvironment: (id: bigint) => VMType
|
4
|
-
export declare const getOrbyChainId: (chainId: bigint) => string;
|
5
|
-
export declare const getBlockchainIdFromBlockchain: (blockchain: Blockchain) => number;
|
4
|
+
export declare const getVirtualEnvironment: (id: bigint) => Promise<VMType>;
|
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;
|
11
|
-
export declare const isMainnet: (chainId: bigint) => boolean;
|