@iota-big3/sdk-blockchain
Version:
Comprehensive blockchain integration platform with multi-chain support, smart contracts, DeFi protocols, NFT infrastructure, Bitcoin support, and seamless SDK ecosystem integration for IOTA Big3
157 lines • 6.78 kB
JavaScript
/**
* @iota-big3/sdk-blockchain - Clean Index
* Blockchain integration and Web3 functionality
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.SDK_NAME = exports.VERSION = exports.COMMON_TOKENS = exports.SUPPORTED_WALLETS = exports.parseTokenAmount = exports.formatTokenAmount = exports.isTestnet = exports.getChainName = exports.createBlockchainManager = exports.DEFAULT_BLOCKCHAIN_CONFIG = exports.NFTManager = exports.DeFiProtocolsManager = exports.SmartContractManager = exports.MultiChainConnector = exports.BitcoinConnector = exports.Web3AuthManager = void 0;
const tslib_1 = require("tslib");
// Import manager classes
const web3_auth_1 = require("./auth/web3-auth");
const bitcoin_connector_1 = require("./bitcoin/bitcoin-connector");
const multi_chain_connector_1 = require("./chains/multi-chain-connector");
const smart_contract_manager_1 = require("./contracts/smart-contract-manager");
const defi_protocols_1 = require("./defi/defi-protocols");
const nft_manager_1 = require("./nft/nft-manager");
// Export manager classes
var web3_auth_2 = require("./auth/web3-auth");
Object.defineProperty(exports, "Web3AuthManager", { enumerable: true, get: function () { return web3_auth_2.Web3AuthManager; } });
var bitcoin_connector_2 = require("./bitcoin/bitcoin-connector");
Object.defineProperty(exports, "BitcoinConnector", { enumerable: true, get: function () { return bitcoin_connector_2.BitcoinConnector; } });
var multi_chain_connector_2 = require("./chains/multi-chain-connector");
Object.defineProperty(exports, "MultiChainConnector", { enumerable: true, get: function () { return multi_chain_connector_2.MultiChainConnector; } });
var smart_contract_manager_2 = require("./contracts/smart-contract-manager");
Object.defineProperty(exports, "SmartContractManager", { enumerable: true, get: function () { return smart_contract_manager_2.SmartContractManager; } });
var defi_protocols_2 = require("./defi/defi-protocols");
Object.defineProperty(exports, "DeFiProtocolsManager", { enumerable: true, get: function () { return defi_protocols_2.DeFiProtocolsManager; } });
var nft_manager_2 = require("./nft/nft-manager");
Object.defineProperty(exports, "NFTManager", { enumerable: true, get: function () { return nft_manager_2.NFTManager; } });
// Default configurations
exports.DEFAULT_BLOCKCHAIN_CONFIG = {
defaultChain: 1, // Ethereum mainnet
supportedChains: [1, 137, 56], // Ethereum, Polygon, BSC
rpcEndpoints: {
1: 'https://mainnet.infura.io/v3/YOUR_PROJECT_ID',
3: 'https://ropsten.infura.io/v3/YOUR_PROJECT_ID',
4: 'https://rinkeby.infura.io/v3/YOUR_PROJECT_ID',
5: 'https://goerli.infura.io/v3/YOUR_PROJECT_ID',
56: 'https://bsc-dataseed1.binance.org',
97: 'https://data-seed-prebsc-1-s1.binance.org:8545',
137: 'https://polygon-rpc.com',
80001: 'https://rpc-mumbai.maticvigil.com',
43114: 'https://api.avax.network/ext/bc/C/rpc',
43113: 'https://api.avax-test.network/ext/bc/C/rpc',
250: 'https://rpc.ftm.tools',
4002: 'https://rpc.testnet.fantom.network'
},
web3Auth: {
enabled: true,
clientId: 'YOUR_WEB3AUTH_CLIENT_ID',
chainConfig: {
chainId: 1,
chainName: 'Ethereum Mainnet',
nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
rpcUrls: ['https://mainnet.infura.io/v3/YOUR_PROJECT_ID'],
blockExplorerUrls: ['https://etherscan.io']
}
}
};
// Utility functions
const createBlockchainManager = (config) => {
// Pass integration options to multi-chain connector
const multiChain = new multi_chain_connector_1.MultiChainConnector(config);
const web3Auth = new web3_auth_1.Web3AuthManager(config.web3Auth || { enabled: false });
const contracts = new smart_contract_manager_1.SmartContractManager();
const defi = new defi_protocols_1.DeFiProtocolsManager();
const nft = new nft_manager_1.NFTManager();
// Add Bitcoin support if configured
const bitcoin = config.bitcoin?.enabled
? new bitcoin_connector_1.BitcoinConnector(config.bitcoin)
: undefined;
return {
web3Auth,
multiChain,
contracts,
defi,
nft,
bitcoin,
features: config.features // For testing
};
};
exports.createBlockchainManager = createBlockchainManager;
const getChainName = (chainId) => {
const chainNames = {
1: 'Ethereum Mainnet',
3: 'Ropsten Testnet',
4: 'Rinkeby Testnet',
5: 'Goerli Testnet',
56: 'Binance Smart Chain',
97: 'BSC Testnet',
137: 'Polygon Mainnet',
80001: 'Polygon Mumbai',
43114: 'Avalanche C-Chain',
43113: 'Avalanche Fuji Testnet',
250: 'Fantom Opera',
4002: 'Fantom Testnet'
};
return chainNames[chainId] || `Chain ${chainId}`;
};
exports.getChainName = getChainName;
const isTestnet = (chainId) => {
const testnets = [3, 4, 5, 97, 80001, 43113, 4002];
return testnets.includes(chainId);
};
exports.isTestnet = isTestnet;
const formatTokenAmount = (amount, decimals = 18, precision = 4) => {
const divisor = Math.pow(10, decimals);
const formatted = (parseInt(amount) / divisor).toFixed(precision);
return parseFloat(formatted).toString();
};
exports.formatTokenAmount = formatTokenAmount;
const parseTokenAmount = (amount, decimals = 18) => {
const multiplier = Math.pow(10, decimals);
const parsed = (parseFloat(amount) * multiplier).toString();
return Math.floor(parseFloat(parsed)).toString();
};
exports.parseTokenAmount = parseTokenAmount;
// Constants
exports.SUPPORTED_WALLETS = [
'metamask',
'walletconnect',
'coinbase',
'web3auth'
];
exports.COMMON_TOKENS = {
ETH: {
symbol: 'ETH',
name: 'Ethereum',
decimals: 18,
addresses: {
1: '0x0000000000000000000000000000000000000000' // Native ETH
}
},
USDC: {
symbol: 'USDC',
name: 'USD Coin',
decimals: 6,
addresses: {
1: '0xA0b86a33E6441b8e8c0A0f8b6b8b8e8c0A0f8b6b', // Example address
137: '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174' // USDC on Polygon
}
},
USDT: {
symbol: 'USDT',
name: 'Tether USD',
decimals: 6,
addresses: {
1: '0xdAC17F958D2ee523a2206206994597C13D831ec7',
137: '0xc2132D05D31c914a87C6611C10748AEb04B58e8F' // USDT on Polygon
}
}
};
// Version info
exports.VERSION = '1.0.0';
exports.SDK_NAME = '@iota-big3/sdk-blockchain';
// Re-export everything from types for convenience
tslib_1.__exportStar(require("./types"), exports);
//# sourceMappingURL=index.js.map
;