@rarible/sdk-common
Advanced tools
Comparing version 0.13.69-beta.4 to 0.13.69-beta.5
@@ -38,3 +38,3 @@ "use strict"; | ||
"transaction would cause overdraft", | ||
].map((msg) => msg.toLowerCase()); | ||
].map(msg => msg.toLowerCase()); | ||
exports.CANCEL_MESSAGES = [ | ||
@@ -108,3 +108,5 @@ "Transaction canceled", | ||
"user closed popup", | ||
].map((msg) => msg.toLowerCase()); | ||
"User has rejected the request", | ||
"The user rejected the request", | ||
].map(msg => msg.toLowerCase()); | ||
exports.COMMON_INFO_MESSAGES = [ | ||
@@ -145,3 +147,3 @@ "The gas fee has been updated and you need", | ||
"User Reject", | ||
].map((msg) => msg.toLowerCase()); | ||
].map(msg => msg.toLowerCase()); | ||
exports.OUT_OF_GAS_ERROR = "returned values aren't valid, did it run out of gas"; | ||
@@ -161,3 +163,3 @@ const shortCancelMessages = ["cancel", "canceled", "cancelled", "rejected"]; | ||
} | ||
return exports.CANCEL_MESSAGES.some((msg) => msgLowerCase === null || msgLowerCase === void 0 ? void 0 : msgLowerCase.includes(msg)); | ||
return exports.CANCEL_MESSAGES.some(msg => msgLowerCase === null || msgLowerCase === void 0 ? void 0 : msgLowerCase.includes(msg)); | ||
} | ||
@@ -174,11 +176,10 @@ exports.isCancelMessage = isCancelMessage; | ||
} | ||
return exports.COMMON_INFO_MESSAGES.some((msg) => msgLowerCase === null || msgLowerCase === void 0 ? void 0 : msgLowerCase.includes(msg)); | ||
return exports.COMMON_INFO_MESSAGES.some(msg => msgLowerCase === null || msgLowerCase === void 0 ? void 0 : msgLowerCase.includes(msg)); | ||
} | ||
exports.isInfoLevel = isInfoLevel; | ||
function isEVMWarning(error) { | ||
if ((error === null || error === void 0 ? void 0 : error.name) && | ||
["WrongNetworkWarning", "InsufficientFundsError"].includes(error === null || error === void 0 ? void 0 : error.name)) | ||
if ((error === null || error === void 0 ? void 0 : error.name) && ["WrongNetworkWarning", "InsufficientFundsError"].includes(error === null || error === void 0 ? void 0 : error.name)) | ||
return true; | ||
const msgLowerCase = error === null || error === void 0 ? void 0 : error.message.toLowerCase(); | ||
return EVM_WARN_MESSAGES.some((msg) => msgLowerCase === null || msgLowerCase === void 0 ? void 0 : msgLowerCase.includes(msg)); | ||
return EVM_WARN_MESSAGES.some(msg => msgLowerCase === null || msgLowerCase === void 0 ? void 0 : msgLowerCase.includes(msg)); | ||
} | ||
@@ -190,4 +191,3 @@ exports.isEVMWarning = isEVMWarning; | ||
const originalError = isWrappedError ? err.error : err; | ||
return (((originalError === null || originalError === void 0 ? void 0 : originalError.name) === "UnknownBeaconError" && | ||
(originalError === null || originalError === void 0 ? void 0 : originalError.title) === "Aborted") || | ||
return (((originalError === null || originalError === void 0 ? void 0 : originalError.name) === "UnknownBeaconError" && (originalError === null || originalError === void 0 ? void 0 : originalError.title) === "Aborted") || | ||
(originalError === null || originalError === void 0 ? void 0 : originalError.name) === "NotGrantedTempleWalletError" || | ||
@@ -204,11 +204,8 @@ (originalError === null || originalError === void 0 ? void 0 : originalError.name) === "NoAddressBeaconError" || | ||
var _a; | ||
return ((error === null || error === void 0 ? void 0 : error.name) === "User rejected the request." || ((_a = error === null || error === void 0 ? void 0 : error.error) === null || _a === void 0 ? void 0 : _a.code) === 4001); | ||
return (error === null || error === void 0 ? void 0 : error.name) === "User rejected the request." || ((_a = error === null || error === void 0 ? void 0 : error.error) === null || _a === void 0 ? void 0 : _a.code) === 4001; | ||
} | ||
exports.isSolanaWarning = isSolanaWarning; | ||
exports.FLOW_WARN_MESSAGES = [ | ||
"[Error Code: 1007] invalid proposal key", | ||
"User rejected signature", | ||
]; | ||
exports.FLOW_WARN_MESSAGES = ["[Error Code: 1007] invalid proposal key", "User rejected signature"]; | ||
function isFlowWarning(error) { | ||
return exports.FLOW_WARN_MESSAGES.some((msg) => { var _a; return (_a = error === null || error === void 0 ? void 0 : error.message) === null || _a === void 0 ? void 0 : _a.includes(msg); }); | ||
return exports.FLOW_WARN_MESSAGES.some(msg => { var _a; return (_a = error === null || error === void 0 ? void 0 : error.message) === null || _a === void 0 ? void 0 : _a.includes(msg); }); | ||
} | ||
@@ -215,0 +212,0 @@ exports.isFlowWarning = isFlowWarning; |
@@ -5,6 +5,6 @@ import type { AssetType, CollectionId, CurrencyId, ItemId, OrderId, OwnershipId } from "@rarible/api-client"; | ||
export declare function extractBlockchainFromAssetType(assetType: AssetType): SupportedBlockchain | undefined; | ||
export declare type BlockchainIsh = UnionAddress | ContractAddress | ItemId | OrderId | OwnershipId | CollectionId | CurrencyId; | ||
export type BlockchainIsh = UnionAddress | ContractAddress | ItemId | OrderId | OwnershipId | CollectionId | CurrencyId; | ||
export declare function extractBlockchain(value: BlockchainIsh): SupportedBlockchain; | ||
export declare function extractId(value: BlockchainIsh): string; | ||
export declare function getEntityData(entity: UnionAddress | ContractAddress | string): { | ||
export declare function getEntityData(entity: UnionAddress | ContractAddress | string | undefined): { | ||
blockchain: SupportedBlockchain; | ||
@@ -19,1 +19,2 @@ address: string; | ||
export declare function isSupportedBlockchain(blockchain: string): blockchain is SupportedBlockchain; | ||
export declare function normalizeAptosAddress(address: string): string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isSupportedBlockchain = exports.FLOW_TOKEN_MAP = exports.validateBlockchain = exports.getEntityData = exports.extractId = exports.extractBlockchain = exports.extractBlockchainFromAssetType = void 0; | ||
exports.normalizeAptosAddress = exports.isSupportedBlockchain = exports.FLOW_TOKEN_MAP = exports.validateBlockchain = exports.getEntityData = exports.extractId = exports.extractBlockchain = exports.extractBlockchainFromAssetType = void 0; | ||
const blockchain_1 = require("./blockchain"); | ||
@@ -64,1 +64,7 @@ function extractBlockchainFromAssetType(assetType) { | ||
exports.isSupportedBlockchain = isSupportedBlockchain; | ||
function normalizeAptosAddress(address) { | ||
if (address.length === 66 && address.startsWith("0x")) | ||
return address; | ||
return `0x${address.replace("0x", "").padStart(64, "0")}`; | ||
} | ||
exports.normalizeAptosAddress = normalizeAptosAddress; |
import { Blockchain } from "@rarible/api-client"; | ||
export declare const EVMBlockchains: readonly [Blockchain.ETHEREUM, Blockchain.POLYGON, Blockchain.MANTLE, Blockchain.ARBITRUM, Blockchain.ZKSYNC, Blockchain.CHILIZ, Blockchain.LIGHTLINK, Blockchain.RARI, Blockchain.ASTARZKEVM, Blockchain.BASE, Blockchain.FIEF, Blockchain.XAI, Blockchain.KROMA, Blockchain.CELO]; | ||
export declare type EVMBlockchain = typeof EVMBlockchains[number]; | ||
export declare const EVMBlockchains: readonly [Blockchain.ETHEREUM, Blockchain.POLYGON, Blockchain.MANTLE, Blockchain.ARBITRUM, Blockchain.ZKSYNC, Blockchain.CHILIZ, Blockchain.LIGHTLINK, Blockchain.RARI, Blockchain.ASTARZKEVM, Blockchain.BASE, Blockchain.FIEF, Blockchain.XAI, Blockchain.KROMA, Blockchain.CELO, Blockchain.SAAKURU, Blockchain.OASYS, Blockchain.SEI, Blockchain.MOONBEAM, Blockchain.PALM, Blockchain.ETHERLINK, Blockchain.LISK, Blockchain.ALEPHZERO, Blockchain.MATCH, Blockchain.FIVIRE]; | ||
export type EVMBlockchain = (typeof EVMBlockchains)[number]; | ||
export declare function isEVMBlockchain(blockchain: string): blockchain is EVMBlockchain; | ||
export declare const NonEVMBlockchains: readonly [Blockchain.FLOW, Blockchain.TEZOS, Blockchain.SOLANA, Blockchain.ECLIPSE, Blockchain.IMMUTABLEX, Blockchain.APTOS]; | ||
export declare const SupportedBlockchains: readonly [Blockchain.ETHEREUM, Blockchain.POLYGON, Blockchain.MANTLE, Blockchain.ARBITRUM, Blockchain.ZKSYNC, Blockchain.CHILIZ, Blockchain.LIGHTLINK, Blockchain.RARI, Blockchain.ASTARZKEVM, Blockchain.BASE, Blockchain.FIEF, Blockchain.XAI, Blockchain.KROMA, Blockchain.CELO, Blockchain.FLOW, Blockchain.TEZOS, Blockchain.SOLANA, Blockchain.ECLIPSE, Blockchain.IMMUTABLEX, Blockchain.APTOS]; | ||
export declare type SupportedBlockchain = Extract<Blockchain, typeof SupportedBlockchains[number]>; | ||
export declare const SupportedBlockchains: readonly [Blockchain.ETHEREUM, Blockchain.POLYGON, Blockchain.MANTLE, Blockchain.ARBITRUM, Blockchain.ZKSYNC, Blockchain.CHILIZ, Blockchain.LIGHTLINK, Blockchain.RARI, Blockchain.ASTARZKEVM, Blockchain.BASE, Blockchain.FIEF, Blockchain.XAI, Blockchain.KROMA, Blockchain.CELO, Blockchain.SAAKURU, Blockchain.OASYS, Blockchain.SEI, Blockchain.MOONBEAM, Blockchain.PALM, Blockchain.ETHERLINK, Blockchain.LISK, Blockchain.ALEPHZERO, Blockchain.MATCH, Blockchain.FIVIRE, Blockchain.FLOW, Blockchain.TEZOS, Blockchain.SOLANA, Blockchain.ECLIPSE, Blockchain.IMMUTABLEX, Blockchain.APTOS]; | ||
export type SupportedBlockchain = Extract<Blockchain, (typeof SupportedBlockchains)[number]>; |
@@ -20,2 +20,12 @@ "use strict"; | ||
api_client_1.Blockchain.CELO, | ||
api_client_1.Blockchain.SAAKURU, | ||
api_client_1.Blockchain.OASYS, | ||
api_client_1.Blockchain.SEI, | ||
api_client_1.Blockchain.MOONBEAM, | ||
api_client_1.Blockchain.PALM, | ||
api_client_1.Blockchain.ETHERLINK, | ||
api_client_1.Blockchain.LISK, | ||
api_client_1.Blockchain.ALEPHZERO, | ||
api_client_1.Blockchain.MATCH, | ||
api_client_1.Blockchain.FIVIRE, | ||
]; | ||
@@ -34,5 +44,2 @@ function isEVMBlockchain(blockchain) { | ||
]; | ||
exports.SupportedBlockchains = [ | ||
...exports.EVMBlockchains, | ||
...exports.NonEVMBlockchains, | ||
]; | ||
exports.SupportedBlockchains = [...exports.EVMBlockchains, ...exports.NonEVMBlockchains]; |
@@ -5,5 +5,51 @@ export * from "./promise-settled"; | ||
export * from "./retry"; | ||
export declare function getStringifiedData(data: any): string | undefined; | ||
export * from "./get-stringified-data"; | ||
export * from "./methods"; | ||
export declare enum DappType { | ||
AlphaWallet = "AlphaWallet", | ||
AToken = "AToken", | ||
Binance = "Binance Smart Wallet", | ||
Bitpie = "Bitpie", | ||
BlockWallet = "BlockWallet", | ||
Brave = "Brave", | ||
Coinbase = "Coinbase Wallet", | ||
CoinbaseBrowser = "Coinbase Browser", | ||
Dcent = "D'CENT", | ||
Frame = "Frame", | ||
HuobiWallet = "Huobi Wallet", | ||
LedgerConnect = "Ledger Connect", | ||
HyperPay = "HyperPay", | ||
ImToken = "imToken", | ||
Liquality = "Liquality", | ||
MeetOne = "MeetOne", | ||
Metamask = "Metamask", | ||
MyKey = "MyKey", | ||
Opera = "Opera Wallet", | ||
OwnBit = "OwnBit", | ||
Status = "Status Wallet", | ||
Trust = "Trust Wallet", | ||
TokenPocket = "TokenPocket", | ||
TP = "TP Wallet", | ||
WalletIo = "Wallet.io", | ||
XDEFI = "XDEFI Wallet", | ||
OneInch = "1inch Wallet", | ||
Tokenary = "Tokenary Wallet", | ||
Tally = "Tally Wallet", | ||
GameStop = "Game Stop", | ||
Dapper = "Dapper", | ||
Cipher = "Cipher", | ||
Mist = "Mist", | ||
Parity = "Parity", | ||
Mock = "Mock", | ||
Generic = "Web3", | ||
Unknown = "Unknown" | ||
} | ||
export declare function getDappType(provider: any): DappType | undefined; | ||
export declare function isObjectLike(x: unknown): x is object; | ||
export declare function hasName(x: unknown): x is Error; | ||
export declare function hasCode(error: unknown): error is { | ||
code: number; | ||
}; | ||
export declare function deepReplaceBigInt(o: unknown): any; | ||
export * from "./types"; | ||
export * from "./web3"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.deepReplaceBigInt = exports.getStringifiedData = void 0; | ||
exports.deepReplaceBigInt = exports.hasCode = exports.hasName = exports.isObjectLike = exports.getDappType = exports.DappType = void 0; | ||
const tslib_1 = require("tslib"); | ||
@@ -9,33 +9,129 @@ tslib_1.__exportStar(require("./promise-settled"), exports); | ||
tslib_1.__exportStar(require("./retry"), exports); | ||
function getStringifiedData(data) { | ||
try { | ||
if (typeof data === "string") { | ||
return data; | ||
} | ||
const errorObject = Object.getOwnPropertyNames(data) | ||
.reduce((acc, key) => { | ||
acc[key] = data[key]; | ||
return acc; | ||
}, {}); | ||
return JSON.stringify(errorObject, replaceErrors, " "); | ||
} | ||
catch (e) { | ||
tslib_1.__exportStar(require("./get-stringified-data"), exports); | ||
tslib_1.__exportStar(require("./methods"), exports); | ||
var DappType; | ||
(function (DappType) { | ||
DappType["AlphaWallet"] = "AlphaWallet"; | ||
DappType["AToken"] = "AToken"; | ||
DappType["Binance"] = "Binance Smart Wallet"; | ||
DappType["Bitpie"] = "Bitpie"; | ||
DappType["BlockWallet"] = "BlockWallet"; | ||
DappType["Brave"] = "Brave"; | ||
DappType["Coinbase"] = "Coinbase Wallet"; | ||
DappType["CoinbaseBrowser"] = "Coinbase Browser"; | ||
DappType["Dcent"] = "D'CENT"; | ||
DappType["Frame"] = "Frame"; | ||
DappType["HuobiWallet"] = "Huobi Wallet"; | ||
DappType["LedgerConnect"] = "Ledger Connect"; | ||
DappType["HyperPay"] = "HyperPay"; | ||
DappType["ImToken"] = "imToken"; | ||
DappType["Liquality"] = "Liquality"; | ||
DappType["MeetOne"] = "MeetOne"; | ||
DappType["Metamask"] = "Metamask"; | ||
DappType["MyKey"] = "MyKey"; | ||
DappType["Opera"] = "Opera Wallet"; | ||
DappType["OwnBit"] = "OwnBit"; | ||
DappType["Status"] = "Status Wallet"; | ||
DappType["Trust"] = "Trust Wallet"; | ||
DappType["TokenPocket"] = "TokenPocket"; | ||
DappType["TP"] = "TP Wallet"; | ||
DappType["WalletIo"] = "Wallet.io"; | ||
DappType["XDEFI"] = "XDEFI Wallet"; | ||
DappType["OneInch"] = "1inch Wallet"; | ||
DappType["Tokenary"] = "Tokenary Wallet"; | ||
DappType["Tally"] = "Tally Wallet"; | ||
DappType["GameStop"] = "Game Stop"; | ||
DappType["Dapper"] = "Dapper"; | ||
DappType["Cipher"] = "Cipher"; | ||
DappType["Mist"] = "Mist"; | ||
DappType["Parity"] = "Parity"; | ||
DappType["Mock"] = "Mock"; | ||
DappType["Generic"] = "Web3"; | ||
DappType["Unknown"] = "Unknown"; | ||
})(DappType || (exports.DappType = DappType = {})); | ||
function getDappType(provider) { | ||
var _a, _b, _c; | ||
if (!provider) | ||
return undefined; | ||
} | ||
if (provider.isAlphaWallet) | ||
return DappType.AlphaWallet; | ||
if (provider.isAToken) | ||
return DappType.AToken; | ||
if (provider.bbcSignTx) | ||
return DappType.Binance; | ||
if (provider.isBitpie) | ||
return DappType.Bitpie; | ||
if (provider.isBlockWallet) | ||
return DappType.BlockWallet; | ||
if (provider.isCoinbaseBrowser) | ||
return DappType.CoinbaseBrowser; | ||
if (provider.isCoinbaseWallet) | ||
return DappType.Coinbase; | ||
if (provider.isDcentWallet) | ||
return DappType.Dcent; | ||
if (provider.isFrame) | ||
return DappType.Frame; | ||
if (provider.isHbWallet) | ||
return DappType.HuobiWallet; | ||
if (provider.isHyperPay) | ||
return DappType.HyperPay; | ||
if (provider.isImToken) | ||
return DappType.ImToken; | ||
if (provider.isLiquality) | ||
return DappType.Liquality; | ||
if (provider.wallet) | ||
return DappType.MeetOne; | ||
if (provider.isMYKEY) | ||
return DappType.MyKey; | ||
if (provider.isOwnbit) | ||
return DappType.OwnBit; | ||
if (provider.isStatus) | ||
return DappType.Status; | ||
if (provider.isTrust) | ||
return DappType.Trust; | ||
if (provider.isTokenPocket) | ||
return DappType.TokenPocket; | ||
if (provider.isTp) | ||
return DappType.TP; | ||
if (provider.isWalletIO) | ||
return DappType.WalletIo; | ||
if (provider.isXDEFI) | ||
return DappType.XDEFI; | ||
if (provider.isOneInchIOSWallet) | ||
return DappType.OneInch; | ||
if (provider.isTokenary) | ||
return DappType.Tokenary; | ||
if (provider.isTally) | ||
return DappType.Tally; | ||
if (provider.isBraveWallet) | ||
return DappType.Brave; | ||
if (provider.isOpera) | ||
return DappType.Opera; | ||
if (provider.isLedgerConnect) | ||
return DappType.LedgerConnect; | ||
if (provider.isMetaMask) | ||
return DappType.Metamask; | ||
if (provider.isGamestop) | ||
return DappType.GameStop; | ||
if (((_a = provider === null || provider === void 0 ? void 0 : provider.constructor) === null || _a === void 0 ? void 0 : _a.name) === "Web3ProviderEngine") | ||
return DappType.Mock; | ||
if (((_b = provider === null || provider === void 0 ? void 0 : provider.constructor) === null || _b === void 0 ? void 0 : _b.name) === "EthereumProvider") | ||
return DappType.Mist; | ||
if (((_c = provider === null || provider === void 0 ? void 0 : provider.constructor) === null || _c === void 0 ? void 0 : _c.name) === "Web3FrameProvider") | ||
return DappType.Parity; | ||
return DappType.Unknown; | ||
} | ||
exports.getStringifiedData = getStringifiedData; | ||
function replaceErrors(key, value) { | ||
try { | ||
if (value instanceof Error) { | ||
const error = {}; | ||
Object.getOwnPropertyNames(value).forEach(function (propName) { | ||
// @ts-ignore | ||
error[propName] = value[propName]; | ||
}); | ||
return error; | ||
} | ||
} | ||
catch (_) { } | ||
return value; | ||
exports.getDappType = getDappType; | ||
function isObjectLike(x) { | ||
return typeof x === "object" && x !== null; | ||
} | ||
exports.isObjectLike = isObjectLike; | ||
function hasName(x) { | ||
return isObjectLike(x) && "name" in x; | ||
} | ||
exports.hasName = hasName; | ||
function hasCode(error) { | ||
return isObjectLike(error) && "code" in error; | ||
} | ||
exports.hasCode = hasCode; | ||
function deepReplaceBigInt(o) { | ||
@@ -42,0 +138,0 @@ if (Array.isArray(o)) { |
@@ -9,5 +9,5 @@ "use strict"; | ||
// @ts-ignore | ||
return response.map(v => v.status === "fulfilled" ? v.value : undefined); | ||
return response.map(v => (v.status === "fulfilled" ? v.value : undefined)); | ||
}); | ||
} | ||
exports.promiseSettledRequest = promiseSettledRequest; |
@@ -5,3 +5,3 @@ "use strict"; | ||
function retry(num, del, thunk) { | ||
return thunk().catch((error) => { | ||
return thunk().catch(error => { | ||
if (num === 0) { | ||
@@ -15,3 +15,3 @@ throw error; | ||
function delay(num) { | ||
return new Promise((r) => setTimeout(r, num)); | ||
return new Promise(r => setTimeout(r, num)); | ||
} | ||
@@ -27,3 +27,3 @@ exports.delay = delay; | ||
function conditionalRetry(num, del, thunk, conditionCallback) { | ||
return thunk().catch((error) => { | ||
return thunk().catch(error => { | ||
if (num === 0 || !conditionCallback(error)) { | ||
@@ -30,0 +30,0 @@ throw error; |
@@ -43,3 +43,3 @@ "use strict"; | ||
DappType["Unknown"] = "Unknown"; | ||
})(DappType = exports.DappType || (exports.DappType = {})); | ||
})(DappType || (exports.DappType = DappType = {})); | ||
function getDappType(provider) { | ||
@@ -46,0 +46,0 @@ var _a, _b, _c; |
{ | ||
"name": "@rarible/sdk-common", | ||
"version": "0.13.69-beta.4", | ||
"version": "0.13.69-beta.5", | ||
"homepage": "", | ||
@@ -14,3 +14,5 @@ "license": "ISC", | ||
"build": "tsc --project tsconfig-build.json", | ||
"clean": "rimraf ./build", | ||
"clean": "run-s clean:*", | ||
"clean:build": "rimraf ./build", | ||
"clean:tsbuildinfo": "rimraf ./tsconfig.tsbuildinfo", | ||
"test": "jest --runInBand --passWithNoTests", | ||
@@ -20,11 +22,4 @@ "verify": "tsc --noEmit --project tsconfig-build.json" | ||
"dependencies": { | ||
"@rarible/api-client": "0.16.5-alpha.10" | ||
"@rarible/api-client": "0.18.0-alpha.3" | ||
}, | ||
"devDependencies": { | ||
"dotenv": "16.0.0", | ||
"jest": "^27.2.7", | ||
"jest-junit": "^15.0.0", | ||
"node-fetch": "2.6.7", | ||
"ts-jest": "^27.0.3" | ||
}, | ||
"peerDependencies": { | ||
@@ -36,3 +31,3 @@ "tslib": "^2.3.1" | ||
}, | ||
"gitHead": "8a8273a5ca7de6b4bb6cc349bf8fc6dc8f4837fe" | ||
"gitHead": "b258e81a4553f9e927bd8ccea7beee212394b6a4" | ||
} |
45461
0
31
1064
+ Added@rarible/api-client@0.18.0-alpha.3(transitive)
- Removed@rarible/api-client@0.16.5-alpha.10(transitive)