@orb-labs/orby-core 0.0.3 → 0.0.5
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 +42 -1
- package/dist/actions/account_cluster.d.ts +1 -1
- package/dist/actions/account_cluster.js +308 -121
- package/dist/actions/admin.js +115 -28
- package/dist/actions/application.js +68 -14
- package/dist/actions/instance.js +237 -72
- package/dist/actions/operation.d.ts +12 -6
- package/dist/actions/operation.js +242 -90
- package/dist/actions/token.js +107 -31
- package/dist/constants.d.ts +8 -0
- package/dist/constants.js +132 -36
- package/dist/entities/account.js +26 -28
- package/dist/entities/financial/account_balance.js +22 -24
- package/dist/entities/financial/asset.js +15 -17
- package/dist/entities/financial/currency.js +37 -25
- package/dist/entities/financial/currency_amount.js +79 -64
- package/dist/entities/financial/fungible_token.js +49 -34
- package/dist/entities/financial/fungible_token_amount.js +85 -70
- package/dist/entities/financial/non_fungible_token.js +45 -30
- package/dist/entities/financial/semi_fungible_token.js +45 -30
- package/dist/entities/library_request.js +19 -24
- package/dist/entities/state.js +67 -60
- package/dist/enums.js +34 -37
- package/dist/index.d.ts +1 -3
- package/dist/index.js +27 -46
- package/dist/interfaces/account_cluster.d.ts +1 -1
- package/dist/interfaces/account_cluster.js +1 -2
- package/dist/interfaces/admin.js +1 -2
- package/dist/interfaces/application.js +1 -2
- package/dist/interfaces/instance.js +1 -2
- package/dist/interfaces/operation.d.ts +5 -5
- package/dist/interfaces/operation.js +1 -2
- package/dist/interfaces/orby.js +1 -2
- package/dist/interfaces/token.js +1 -2
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types.d.ts +4 -0
- package/dist/types.js +1 -2
- package/dist/utils/action_helpers.d.ts +22 -0
- package/dist/utils/action_helpers.js +270 -0
- package/dist/utils/utils.d.ts +5 -22
- package/dist/utils/utils.js +30 -279
- package/dist/utils/validateAndParseAddress.js +7 -11
- package/package.json +6 -1
package/dist/utils/utils.js
CHANGED
@@ -1,307 +1,55 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
const enums_1 = require("../enums");
|
5
|
-
const constants_1 = require("../constants");
|
6
|
-
const currency_amount_1 = require("../entities/financial/currency_amount");
|
7
|
-
const state_1 = require("../entities/state");
|
8
|
-
const currency_1 = require("../entities/financial/currency");
|
9
|
-
const fungible_token_amount_1 = require("../entities/financial/fungible_token_amount");
|
10
|
-
const fungible_token_1 = require("../entities/financial/fungible_token");
|
11
|
-
const account_1 = require("../entities/account");
|
12
|
-
const extractAccountCluster = (accountCluster) => {
|
1
|
+
import { Blockchain, BlockchainEnvironment } from "../enums";
|
2
|
+
import { BLOCKCHAIN_ID, BLOCKCHAIN_ID_TO_BLOCKCHAIN, CHAIN_CONFIGS, } from "../constants";
|
3
|
+
export var getChainIdFromOrbyChainId = function (value) {
|
13
4
|
var _a;
|
14
|
-
|
15
|
-
|
16
|
-
}
|
17
|
-
return {
|
18
|
-
accountClusterId: accountCluster.accountClusterId,
|
19
|
-
accounts: (_a = accountCluster === null || accountCluster === void 0 ? void 0 : accountCluster.accounts) === null || _a === void 0 ? void 0 : _a.map((account) => account_1.Account.toAccount(account)),
|
20
|
-
};
|
21
|
-
};
|
22
|
-
exports.extractAccountCluster = extractAccountCluster;
|
23
|
-
const extractOperationSet = (operationSet) => {
|
24
|
-
var _a;
|
25
|
-
if (!operationSet) {
|
26
|
-
return undefined;
|
27
|
-
}
|
28
|
-
return {
|
29
|
-
status: operationSet.status,
|
30
|
-
primaryOperation: (0, exports.extractOnchainOperation)(operationSet.primaryOperation),
|
31
|
-
primaryOperationPreconditions: state_1.State.toState(operationSet.primaryOperationPreconditions),
|
32
|
-
inputState: state_1.State.toState(operationSet.inputState),
|
33
|
-
outputState: state_1.State.toState(operationSet.outputState),
|
34
|
-
intents: (_a = operationSet.intents) === null || _a === void 0 ? void 0 : _a.map((intent) => (0, exports.extractIntent)(intent)),
|
35
|
-
aggregateNetworkFeeInFiatCurrency: currency_amount_1.CurrencyAmount.toCurrencyAmount(operationSet.aggregateNetworkFeeInFiatCurrency),
|
36
|
-
aggregateOperationFeeInFiatCurrency: currency_amount_1.CurrencyAmount.toCurrencyAmount(operationSet.aggregateOperationFeeInFiatCurrency),
|
37
|
-
aggregateEstimatedTimeInMs: operationSet.aggregateEstimatedTimeInMs,
|
38
|
-
};
|
39
|
-
};
|
40
|
-
exports.extractOperationSet = extractOperationSet;
|
41
|
-
const extractOnchainOperation = (onchainOperation) => {
|
42
|
-
if (!onchainOperation) {
|
43
|
-
return undefined;
|
44
|
-
}
|
45
|
-
return {
|
46
|
-
chainId: (0, exports.getChainIdFromOrbyChainId)(onchainOperation.chainId),
|
47
|
-
data: onchainOperation.data,
|
48
|
-
estimatedNetworkFees: currency_amount_1.CurrencyAmount.toCurrencyAmount(onchainOperation.estimatedNetworkFees),
|
49
|
-
estimatedNetworkFeesInFiatCurrency: currency_amount_1.CurrencyAmount.toCurrencyAmount(onchainOperation.estimatedNetworkFeesInFiatCurrency),
|
50
|
-
estimatedTimeInMs: onchainOperation.estimatedTimeInMs,
|
51
|
-
format: onchainOperation.format,
|
52
|
-
from: onchainOperation.from,
|
53
|
-
gasLimit: onchainOperation.gasLimit
|
54
|
-
? BigInt(onchainOperation.gasLimit)
|
55
|
-
: undefined,
|
56
|
-
gasPrice: onchainOperation.gasPrice
|
57
|
-
? BigInt(onchainOperation.gasPrice)
|
58
|
-
: undefined,
|
59
|
-
inputState: state_1.State.toState(onchainOperation.inputState),
|
60
|
-
maxFeePerGas: onchainOperation.maxFeePerGas
|
61
|
-
? BigInt(onchainOperation.maxFeePerGas)
|
62
|
-
: undefined,
|
63
|
-
maxPriorityFeePerGas: onchainOperation.maxPriorityFeePerGas
|
64
|
-
? BigInt(onchainOperation.maxPriorityFeePerGas)
|
65
|
-
: undefined,
|
66
|
-
nativeCurrency: currency_1.Currency.toCurrency(onchainOperation.nativeCurrency),
|
67
|
-
nonce: onchainOperation.nonce ? BigInt(onchainOperation.nonce) : undefined,
|
68
|
-
outputState: state_1.State.toState(onchainOperation.outputState),
|
69
|
-
to: onchainOperation.to,
|
70
|
-
txRpcUrl: onchainOperation.txRpcUrl,
|
71
|
-
type: onchainOperation.type,
|
72
|
-
value: onchainOperation.value ? BigInt(onchainOperation.value) : undefined,
|
73
|
-
};
|
74
|
-
};
|
75
|
-
exports.extractOnchainOperation = extractOnchainOperation;
|
76
|
-
const extractIntent = (intent) => {
|
77
|
-
if (!intent) {
|
78
|
-
return undefined;
|
79
|
-
}
|
80
|
-
return {
|
81
|
-
estimatedProtocolFees: fungible_token_amount_1.FungibleTokenAmount.toFungibleTokenAmount(intent.estimatedProtocolFees),
|
82
|
-
estimatedProtocolFeesInFiatCurrency: currency_amount_1.CurrencyAmount.toCurrencyAmount(intent.estimatedProtocolFeesInFiatCurrency),
|
83
|
-
inputState: state_1.State.toState(intent.inputState),
|
84
|
-
intentOperations: intent.intentOperations.map((operation) => (0, exports.extractOnchainOperation)(operation)),
|
85
|
-
outputState: state_1.State.toState(intent.outputState),
|
86
|
-
};
|
87
|
-
};
|
88
|
-
exports.extractIntent = extractIntent;
|
89
|
-
const extractOperationStatuses = (operationStatus) => {
|
90
|
-
return operationStatus === null || operationStatus === void 0 ? void 0 : operationStatus.map((status) => (0, exports.extractOperationStatus)(status));
|
91
|
-
};
|
92
|
-
exports.extractOperationStatuses = extractOperationStatuses;
|
93
|
-
const extractOperationStatus = (status) => {
|
94
|
-
if (!status) {
|
95
|
-
return undefined;
|
96
|
-
}
|
97
|
-
return {
|
98
|
-
blockHash: status.blockHash,
|
99
|
-
blockNumber: status.blockNumber ? BigInt(status.blockNumber) : undefined,
|
100
|
-
chainId: status.chainId
|
101
|
-
? (0, exports.getChainIdFromOrbyChainId)(status.chainId)
|
102
|
-
: undefined,
|
103
|
-
errorReason: status.errorReason,
|
104
|
-
hash: status.hash,
|
105
|
-
id: status.id,
|
106
|
-
status: status.status,
|
107
|
-
type: status.type,
|
108
|
-
};
|
109
|
-
};
|
110
|
-
exports.extractOperationStatus = extractOperationStatus;
|
111
|
-
const extractActivities = (activities) => {
|
112
|
-
if (!activities) {
|
113
|
-
return undefined;
|
114
|
-
}
|
115
|
-
return activities.map((activity) => {
|
116
|
-
return {
|
117
|
-
aggregateFiatValueOfInputState: currency_amount_1.CurrencyAmount.toCurrencyAmount(activity.aggregateFiatValueOfInputState),
|
118
|
-
aggregateFiatValueOfOutputState: currency_amount_1.CurrencyAmount.toCurrencyAmount(activity.aggregateFiatValueOfOutputState),
|
119
|
-
aggregateNetworkFeesInFiatCurrency: currency_amount_1.CurrencyAmount.toCurrencyAmount(activity.aggregateNetworkFeesInFiatCurrency),
|
120
|
-
aggregateProtocolFeesInFiatCurrency: currency_amount_1.CurrencyAmount.toCurrencyAmount(activity.aggregateProtocolFeesInFiatCurrency),
|
121
|
-
category: activity.category,
|
122
|
-
initiateAt: activity.initiateAt,
|
123
|
-
inputState: state_1.State.toState(activity.inputState),
|
124
|
-
operationStatuses: (0, exports.extractOperationStatus)(activity.operationStatuses),
|
125
|
-
outputState: state_1.State.toState(activity.outputState),
|
126
|
-
overallStatus: activity.overallStatus,
|
127
|
-
};
|
128
|
-
});
|
129
|
-
};
|
130
|
-
exports.extractActivities = extractActivities;
|
131
|
-
const extractFungibleTokenOverview = (overview) => {
|
132
|
-
if (!overview) {
|
133
|
-
return undefined;
|
134
|
-
}
|
135
|
-
return {
|
136
|
-
tokenCount: overview.tokenCount,
|
137
|
-
hiddenTokenCount: overview.hiddenTokenCount,
|
138
|
-
totalValueInFiat: currency_amount_1.CurrencyAmount.toCurrencyAmount(overview.totalValueInFiat),
|
139
|
-
};
|
140
|
-
};
|
141
|
-
exports.extractFungibleTokenOverview = extractFungibleTokenOverview;
|
142
|
-
const extractStandardizedBalances = (balances) => {
|
143
|
-
return balances === null || balances === void 0 ? void 0 : balances.map((balance) => (0, exports.extractStandardizedBalance)(balance));
|
144
|
-
};
|
145
|
-
exports.extractStandardizedBalances = extractStandardizedBalances;
|
146
|
-
const extractStandardizedBalance = (balance) => {
|
147
|
-
if (!balance) {
|
148
|
-
return undefined;
|
149
|
-
}
|
150
|
-
return {
|
151
|
-
standardizedTokenId: balance.standardizedTokenId,
|
152
|
-
tokenBalances: balance.tokenBalances.map((ft) => fungible_token_amount_1.FungibleTokenAmount.toFungibleTokenAmount(ft)),
|
153
|
-
tokenBalancesOnChains: balance.tokenBalancesOnChains.map((ft) => fungible_token_amount_1.FungibleTokenAmount.toFungibleTokenAmount(ft)),
|
154
|
-
total: currency_amount_1.CurrencyAmount.toCurrencyAmount(balance.total),
|
155
|
-
totalValueInFiat: currency_amount_1.CurrencyAmount.toCurrencyAmount(balance.totalValueInFiat),
|
156
|
-
};
|
157
|
-
};
|
158
|
-
exports.extractStandardizedBalance = extractStandardizedBalance;
|
159
|
-
const extractStandardizedTokens = (tokens) => {
|
160
|
-
return tokens === null || tokens === void 0 ? void 0 : tokens.map((token) => (0, exports.extractStandardizedToken)(token));
|
161
|
-
};
|
162
|
-
exports.extractStandardizedTokens = extractStandardizedTokens;
|
163
|
-
const extractStandardizedToken = (token) => {
|
164
|
-
if (!token) {
|
165
|
-
return undefined;
|
166
|
-
}
|
167
|
-
return {
|
168
|
-
stardardizedTokenId: token.stardardizedTokenId,
|
169
|
-
currency: currency_1.Currency.toCurrency(token.currency),
|
170
|
-
priceInFiat: currency_amount_1.CurrencyAmount.toCurrencyAmount(token.priceInFiat),
|
171
|
-
tokens: token.tokens.map((ft) => fungible_token_1.FungibleToken.toFungibleToken(ft)),
|
172
|
-
};
|
173
|
-
};
|
174
|
-
exports.extractStandardizedToken = extractStandardizedToken;
|
175
|
-
const extractBlockchainInformations = (blockchainInformation) => {
|
176
|
-
return blockchainInformation === null || blockchainInformation === void 0 ? void 0 : blockchainInformation.map((info) => (0, exports.extractBlockchainInformation)(info));
|
177
|
-
};
|
178
|
-
exports.extractBlockchainInformations = extractBlockchainInformations;
|
179
|
-
const extractBlockchainInformation = (blockchainInformation) => {
|
180
|
-
if (!blockchainInformation) {
|
181
|
-
return undefined;
|
182
|
-
}
|
183
|
-
return {
|
184
|
-
chainId: (0, exports.getChainIdFromOrbyChainId)(blockchainInformation.chainId),
|
185
|
-
environment: blockchainInformation.environment,
|
186
|
-
logoUrl: blockchainInformation.logoUrl,
|
187
|
-
name: blockchainInformation.name,
|
188
|
-
};
|
189
|
-
};
|
190
|
-
exports.extractBlockchainInformation = extractBlockchainInformation;
|
191
|
-
const extractMaxAmountPerInterval = (maxAmountPerInterval) => {
|
192
|
-
if (!maxAmountPerInterval) {
|
193
|
-
return undefined;
|
194
|
-
}
|
195
|
-
return {
|
196
|
-
amount: maxAmountPerInterval.amount,
|
197
|
-
interval: {
|
198
|
-
amount: maxAmountPerInterval.interval.amount,
|
199
|
-
unit: maxAmountPerInterval.interval.unit,
|
200
|
-
},
|
201
|
-
};
|
202
|
-
};
|
203
|
-
exports.extractMaxAmountPerInterval = extractMaxAmountPerInterval;
|
204
|
-
const extractAllowlistWithOpenFallback = (allowlist) => {
|
205
|
-
if (!allowlist) {
|
206
|
-
return undefined;
|
207
|
-
}
|
208
|
-
return {
|
209
|
-
tokenAllowlist: {
|
210
|
-
tokenAllowlistType: allowlist.tokenAllowlist.tokenAllowlistType,
|
211
|
-
sponsoredFunctions: allowlist.tokenAllowlist.sponsoredFunctions,
|
212
|
-
},
|
213
|
-
arbitraryContractAllowlist: allowlist.arbitraryContractAllowlist,
|
214
|
-
};
|
215
|
-
};
|
216
|
-
exports.extractAllowlistWithOpenFallback = extractAllowlistWithOpenFallback;
|
217
|
-
const extractGasSponsorshipPolicy = (gasSponsorshipPolicy) => {
|
218
|
-
if (!gasSponsorshipPolicy) {
|
219
|
-
return undefined;
|
220
|
-
}
|
221
|
-
return {
|
222
|
-
maxTotalGasSpendForInstance: (0, exports.extractMaxAmountPerInterval)(gasSponsorshipPolicy.maxTotalGasSpendForInstance),
|
223
|
-
maxGasSpendPerTransaction: gasSponsorshipPolicy.maxGasSpendPerTransaction,
|
224
|
-
allowlistWithOpenFallback: (0, exports.extractAllowlistWithOpenFallback)(gasSponsorshipPolicy.allowlistWithOpenFallback),
|
225
|
-
maxTotalTransactionCountForInstance: (0, exports.extractMaxAmountPerInterval)(gasSponsorshipPolicy.maxTotalTransactionCountForInstance),
|
226
|
-
maxTotalGasSpendPerUser: (0, exports.extractMaxAmountPerInterval)(gasSponsorshipPolicy.maxTotalGasSpendPerUser),
|
227
|
-
maxTotalTransactionCountPerUser: (0, exports.extractMaxAmountPerInterval)(gasSponsorshipPolicy.maxTotalTransactionCountPerUser),
|
228
|
-
};
|
229
|
-
};
|
230
|
-
exports.extractGasSponsorshipPolicy = extractGasSponsorshipPolicy;
|
231
|
-
const extractGasSpendForInstances = (gasSpendForInstances) => {
|
232
|
-
return gasSpendForInstances === null || gasSpendForInstances === void 0 ? void 0 : gasSpendForInstances.map((data) => (0, exports.extractGasSpendForInstance)(data));
|
233
|
-
};
|
234
|
-
exports.extractGasSpendForInstances = extractGasSpendForInstances;
|
235
|
-
const extractGasSpendForInstance = (gasSpendForInstance) => {
|
236
|
-
if (!gasSpendForInstance) {
|
237
|
-
return;
|
238
|
-
}
|
239
|
-
return {
|
240
|
-
instanceName: gasSpendForInstance.instanceName,
|
241
|
-
gasSpentForInstance: (0, exports.extractGasSponsorshipData)(gasSpendForInstance.gasSpentForInstance),
|
242
|
-
};
|
243
|
-
};
|
244
|
-
exports.extractGasSpendForInstance = extractGasSpendForInstance;
|
245
|
-
const extractGasSponsorshipInformation = (gasSponsorshipData) => {
|
246
|
-
return gasSponsorshipData === null || gasSponsorshipData === void 0 ? void 0 : gasSponsorshipData.map((data) => (0, exports.extractGasSponsorshipData)(data));
|
247
|
-
};
|
248
|
-
exports.extractGasSponsorshipInformation = extractGasSponsorshipInformation;
|
249
|
-
const extractGasSponsorshipData = (gasSponsorshipData) => {
|
250
|
-
if (!gasSponsorshipData) {
|
251
|
-
return undefined;
|
252
|
-
}
|
253
|
-
return {
|
254
|
-
totalGasSpent: currency_amount_1.CurrencyAmount.toCurrencyAmount(gasSponsorshipData.totalGasSpent),
|
255
|
-
totalTransactionCount: gasSponsorshipData.totalTransactionCount,
|
256
|
-
};
|
257
|
-
};
|
258
|
-
exports.extractGasSponsorshipData = extractGasSponsorshipData;
|
259
|
-
const getChainIdFromOrbyChainId = (value) => {
|
260
|
-
var _a;
|
261
|
-
let chainId = undefined;
|
262
|
-
const formattedValue = (_a = value === null || value === void 0 ? void 0 : value.trim()) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
5
|
+
var chainId = undefined;
|
6
|
+
var formattedValue = (_a = value === null || value === void 0 ? void 0 : value.trim()) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
263
7
|
if (formattedValue === null || formattedValue === void 0 ? void 0 : formattedValue.includes("eip155")) {
|
264
|
-
|
265
|
-
|
8
|
+
var publicIdElements = formattedValue.split("eip155-");
|
9
|
+
var potentialId = (publicIdElements === null || publicIdElements === void 0 ? void 0 : publicIdElements.length) > 1 ? publicIdElements[1] : undefined;
|
266
10
|
chainId = !Number.isNaN(Number(potentialId))
|
267
11
|
? BigInt(potentialId)
|
268
12
|
: undefined;
|
269
13
|
}
|
270
14
|
else {
|
271
|
-
|
272
|
-
|
273
|
-
?
|
15
|
+
var blockchain = getBlockchainFromName(formattedValue);
|
16
|
+
var potentialId = blockchain
|
17
|
+
? getBlockchainIdFromBlockchain(blockchain)
|
274
18
|
: undefined;
|
275
19
|
chainId = potentialId ? BigInt(potentialId) : undefined;
|
276
20
|
}
|
277
21
|
return chainId;
|
278
22
|
};
|
279
|
-
|
280
|
-
|
281
|
-
return constants_1.BLOCKCHAIN_ID[blockchain];
|
23
|
+
export var getBlockchainIdFromBlockchain = function (blockchain) {
|
24
|
+
return BLOCKCHAIN_ID[blockchain];
|
282
25
|
};
|
283
|
-
|
284
|
-
|
26
|
+
export var hasError = function (data) {
|
27
|
+
if ((data === null || data === void 0 ? void 0 : data.code) && (data === null || data === void 0 ? void 0 : data.message)) {
|
28
|
+
return { code: data.code, message: data.message };
|
29
|
+
}
|
30
|
+
return undefined;
|
31
|
+
};
|
32
|
+
export var getBlockchainFromName = function (chainName) {
|
285
33
|
var _a;
|
286
|
-
|
34
|
+
var formattedChainName = (_a = chainName === null || chainName === void 0 ? void 0 : chainName.toLowerCase()) === null || _a === void 0 ? void 0 : _a.replace("-", "_");
|
287
35
|
switch (formattedChainName) {
|
288
36
|
case "bnbt": {
|
289
|
-
return
|
37
|
+
return Blockchain.BINANCE_TESTNET;
|
290
38
|
}
|
291
39
|
case "matic_amoy": {
|
292
|
-
return
|
40
|
+
return Blockchain.POLYGON_AMOY;
|
293
41
|
}
|
294
42
|
case "matic": {
|
295
|
-
return
|
43
|
+
return Blockchain.POLYGON;
|
296
44
|
}
|
297
45
|
case "mainnet": {
|
298
|
-
return
|
46
|
+
return Blockchain.ETHEREUM;
|
299
47
|
}
|
300
48
|
case "holesky": {
|
301
|
-
return
|
49
|
+
return Blockchain.ETHEREUM_HOLESKY;
|
302
50
|
}
|
303
51
|
case "sepolia": {
|
304
|
-
return
|
52
|
+
return Blockchain.ETHEREUM_SEPOLIA;
|
305
53
|
}
|
306
54
|
case "unknown": {
|
307
55
|
return undefined;
|
@@ -312,4 +60,7 @@ const getBlockchainFromName = (chainName) => {
|
|
312
60
|
}
|
313
61
|
}
|
314
62
|
};
|
315
|
-
|
63
|
+
export var isMainnet = function (chainId) {
|
64
|
+
var blockchain = BLOCKCHAIN_ID_TO_BLOCKCHAIN[Number(chainId)];
|
65
|
+
return CHAIN_CONFIGS[blockchain].environment == BlockchainEnvironment.MAINNET;
|
66
|
+
};
|
@@ -1,29 +1,25 @@
|
|
1
|
-
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.validateAndParseAddress = validateAndParseAddress;
|
4
|
-
exports.checkValidAddress = checkValidAddress;
|
5
|
-
const address_1 = require("@ethersproject/address");
|
1
|
+
import { getAddress } from "@ethersproject/address";
|
6
2
|
/**
|
7
3
|
* Validates an address and returns the parsed (checksummed) version of that address
|
8
4
|
* @param address the unchecksummed hex address
|
9
5
|
*/
|
10
|
-
function validateAndParseAddress(address) {
|
6
|
+
export function validateAndParseAddress(address) {
|
11
7
|
try {
|
12
|
-
return
|
8
|
+
return getAddress(address);
|
13
9
|
}
|
14
10
|
catch (error) {
|
15
|
-
throw new Error(
|
11
|
+
throw new Error("".concat(address, " is not a valid address."));
|
16
12
|
}
|
17
13
|
}
|
18
14
|
// Checks a string starts with 0x, is 42 characters long and contains only hex characters after 0x
|
19
|
-
|
15
|
+
var startsWith0xLen42HexRegex = /^0x[0-9a-fA-F]{40}$/;
|
20
16
|
/**
|
21
17
|
* Checks if an address is valid by checking 0x prefix, length === 42 and hex encoding.
|
22
18
|
* @param address the unchecksummed hex address
|
23
19
|
*/
|
24
|
-
function checkValidAddress(address) {
|
20
|
+
export function checkValidAddress(address) {
|
25
21
|
if (startsWith0xLen42HexRegex.test(address)) {
|
26
22
|
return address;
|
27
23
|
}
|
28
|
-
throw new Error(
|
24
|
+
throw new Error("".concat(address, " is not a valid address."));
|
29
25
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@orb-labs/orby-core",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.5",
|
4
4
|
"exports": {
|
5
5
|
".": "./dist/index.js"
|
6
6
|
},
|
@@ -15,11 +15,16 @@
|
|
15
15
|
"watch:alias": "nodemon --watch dist --exec \"tsc-alias -p tsconfig.json\""
|
16
16
|
},
|
17
17
|
"devDependencies": {
|
18
|
+
"@types/big.js": "^6.2.2",
|
18
19
|
"@types/lodash": "^4.17.13",
|
20
|
+
"concurrently": "^9.1.0",
|
19
21
|
"eslint": "^8",
|
20
22
|
"javascript-obfuscator": "^4.1.1",
|
21
23
|
"nodemon": "^3.0.3",
|
22
24
|
"tsc-alias": "^1.8.10",
|
23
25
|
"typescript": "^5.6.3"
|
26
|
+
},
|
27
|
+
"dependencies": {
|
28
|
+
"@uniswap/sdk-core": "^5.9.0"
|
24
29
|
}
|
25
30
|
}
|