From f981a7900d951f224dddf99177c851d92c3ae259 Mon Sep 17 00:00:00 2001 From: Sebastian Pape Date: Tue, 14 Mar 2023 11:07:25 +0100 Subject: [PATCH] v10.5.0: introduce solana platform specific package and start using jscc for platfom specific code --- dist/esm/index.evm.js | 102 +++- dist/esm/index.js | 567 ++++++++++------- dist/umd/index.evm.js | 101 +++- dist/umd/index.js | 571 +++++++++++------- package.evm.json | 3 +- package.json | 5 +- package.solana.json | 31 + rollup.module.evm.config.js | 4 +- src/blockchains.evm.js | 5 - src/blockchains.js | 16 + src/estimate.js | 4 +- src/index.evm.js | 13 - src/index.js | 15 +- src/provider.evm.js | 36 -- src/provider.js | 86 ++- src/request.evm.js | 23 - src/request.js | 39 +- tests/units/platforms/evm/balance.evm.spec.js | 4 +- tests/units/platforms/evm/blocks.evm.spec.js | 4 +- tests/units/platforms/evm/cache.evm.spec.js | 4 +- .../units/platforms/evm/estimate.evm.spec.js | 4 +- .../units/platforms/evm/provider.evm.spec.js | 4 +- .../evm/request/contract.evm.spec.js | 4 +- .../evm/request/forSpecificBlock.evm.spec.js | 4 +- .../evm/transactionCount.evm.spec.js | 4 +- yarn.lock | 69 ++- 26 files changed, 1097 insertions(+), 625 deletions(-) create mode 100644 package.solana.json delete mode 100644 src/blockchains.evm.js delete mode 100644 src/index.evm.js delete mode 100644 src/provider.evm.js delete mode 100644 src/request.evm.js diff --git a/dist/esm/index.evm.js b/dist/esm/index.evm.js index 62e4569..37da739 100644 --- a/dist/esm/index.evm.js +++ b/dist/esm/index.evm.js @@ -30,10 +30,6 @@ var estimateEVM = ({ provider, from, to, value, method, api, params }) => { } }; -let supported = ['ethereum', 'bsc', 'polygon', 'fantom', 'velas']; -supported.evm = ['ethereum', 'bsc', 'polygon', 'fantom', 'velas']; -supported.solana = []; - const BATCH_INTERVAL = 10; const CHUNK_SIZE = 99; @@ -222,10 +218,24 @@ var EVM = { setProvider: setProvider$1, }; +let supported = ['ethereum', 'bsc', 'polygon', 'fantom', 'velas']; +supported.evm = ['ethereum', 'bsc', 'polygon', 'fantom', 'velas']; +supported.solana = []; + const getProvider = async (blockchain)=>{ if(supported.evm.includes(blockchain)) { + + return await EVM.getProvider(blockchain) + + + } else if(supported.solana.includes(blockchain)) { + + + return await Solana.getProvider(blockchain) + + } else { throw 'Unknown blockchain: ' + blockchain } @@ -234,7 +244,17 @@ const getProvider = async (blockchain)=>{ const setProvider = (blockchain, provider)=>{ if(supported.evm.includes(blockchain)) { + + return EVM.setProvider(blockchain, provider) + + + } else if(supported.solana.includes(blockchain)) { + + + return Solana.setProvider(blockchain, provider) + + } else { throw 'Unknown blockchain: ' + blockchain } @@ -243,7 +263,17 @@ const setProvider = (blockchain, provider)=>{ const setProviderEndpoints = (blockchain, endpoints)=>{ if(supported.evm.includes(blockchain)) { + + return EVM.setProviderEndpoints(blockchain, endpoints) + + + } else if(supported.solana.includes(blockchain)) { + + + return Solana.setProviderEndpoints(blockchain, endpoints) + + } else { throw 'Unknown blockchain: ' + blockchain } @@ -366,33 +396,6 @@ let estimate = async function ({ blockchain, from, to, value, method, api, param }) }; -var parseUrl = (url) => { - if (typeof url == 'object') { - return url - } - let deconstructed = url.match(/(?\w+):\/\/(?[\w\d]+)(\/(?[\w\d]+)*)?/); - - if(deconstructed.groups.part2 == undefined) { - if(deconstructed.groups.part1.match(/\d/)) { - return { - blockchain: deconstructed.groups.blockchain, - address: deconstructed.groups.part1 - } - } else { - return { - blockchain: deconstructed.groups.blockchain, - method: deconstructed.groups.part1 - } - } - } else { - return { - blockchain: deconstructed.groups.blockchain, - address: deconstructed.groups.part1, - method: deconstructed.groups.part2 - } - } -}; - let paramsToContractArgs = ({ contract, method, params }) => { let fragment = contract.interface.fragments.find((fragment) => { return fragment.name == method @@ -435,6 +438,33 @@ var requestEVM = async ({ blockchain, address, api, method, params, block }) => } }; +var parseUrl = (url) => { + if (typeof url == 'object') { + return url + } + let deconstructed = url.match(/(?\w+):\/\/(?[\w\d]+)(\/(?[\w\d]+)*)?/); + + if(deconstructed.groups.part2 == undefined) { + if(deconstructed.groups.part1.match(/\d/)) { + return { + blockchain: deconstructed.groups.blockchain, + address: deconstructed.groups.part1 + } + } else { + return { + blockchain: deconstructed.groups.blockchain, + method: deconstructed.groups.part1 + } + } + } else { + return { + blockchain: deconstructed.groups.blockchain, + address: deconstructed.groups.part1, + method: deconstructed.groups.part2 + } + } +}; + let request = async function (url, options) { let { blockchain, address, method } = parseUrl(url); let { api, params, cache: cache$1, block } = (typeof(url) == 'object' ? url : options) || {}; @@ -444,12 +474,18 @@ let request = async function (url, options) { key: [blockchain, address, method, params, block], call: async()=>{ if(supported.evm.includes(blockchain)) { + + return requestEVM({ blockchain, address, api, method, params, block }) - } else { + + + } else if(supported.solana.includes(blockchain)) ; else { throw 'Unknown blockchain: ' + blockchain } } }) }; -export { estimate, getProvider, request, resetCache, setProvider, setProviderEndpoints }; +const simulate = undefined; + +export { estimate, getProvider, request, resetCache, setProvider, setProviderEndpoints, simulate }; diff --git a/dist/esm/index.js b/dist/esm/index.js index 0b9098f..b5905fe 100644 --- a/dist/esm/index.js +++ b/dist/esm/index.js @@ -1,39 +1,6 @@ -import { ethers } from 'ethers'; +import { Connection, Buffer, PublicKey, TransactionInstruction, Transaction, ACCOUNT_LAYOUT } from '@depay/solana-web3.js'; import { Blockchain } from '@depay/web3-blockchains'; -import { Connection, PublicKey, ACCOUNT_LAYOUT, Buffer, TransactionInstruction, Transaction } from '@depay/solana-web3.js'; - -const getContractArguments = ({ contract, method, params })=>{ - let fragment = contract.interface.fragments.find((fragment) => { - return fragment.name == method - }); - - if(params instanceof Array) { - return params - } else if (params instanceof Object) { - return fragment.inputs.map((input) => { - return params[input.name] - }) - } -}; - -var estimateEVM = ({ provider, from, to, value, method, api, params }) => { - if(typeof api == "undefined"){ - return provider.estimateGas({ from, to, value }) - } else { - let contract = new ethers.Contract(to, api, provider); - let contractMethod = contract.estimateGas[method]; - let contractArguments = getContractArguments({ contract, method, params }); - if(contractArguments) { - return contractMethod(...contractArguments, { from, value }) - } else { - return contractMethod({ from, value }) - } - } -}; - -let supported$1 = ['ethereum', 'bsc', 'polygon', 'fantom', 'velas']; -supported$1.evm = ['ethereum', 'bsc', 'polygon', 'fantom', 'velas']; -supported$1.solana = []; +import { ethers } from 'ethers'; const BATCH_INTERVAL = 10; const CHUNK_SIZE = 99; @@ -200,7 +167,7 @@ const setProviderEndpoints$2 = async (blockchain, endpoints)=> { ); }; -const getProvider$3 = async (blockchain)=> { +const getProvider$2 = async (blockchain)=> { let providers = getProviders$1(); if(providers && providers[blockchain]){ return providers[blockchain] } @@ -218,21 +185,300 @@ const getProvider$3 = async (blockchain)=> { }; var EVM = { - getProvider: getProvider$3, + getProvider: getProvider$2, setProviderEndpoints: setProviderEndpoints$2, setProvider: setProvider$2, }; -const getProvider$2 = async (blockchain)=>{ +class StaticJsonRpcSequentialProvider extends Connection { + + constructor(url, network, endpoints) { + super(url); + this._network = network; + this._endpoint = url; + this._endpoints = endpoints; + } +} + +const ENDPOINTS = { + solana: ['https://solana-mainnet.phantom.app/YBPpkkN4g91xDiAnTE9r0RcMkjg0sKUIWvAfoFVJ', 'https://mainnet-beta.solflare.network', 'https://solana-mainnet.rpc.extrnode.com'] +}; + +const getProviders = ()=> { + if(getWindow()._clientProviders == undefined) { + getWindow()._clientProviders = {}; + } + return getWindow()._clientProviders +}; + +const setProvider$1 = (blockchain, provider)=> { + getProviders()[blockchain] = provider; +}; + +const setProviderEndpoints$1 = async (blockchain, endpoints)=> { + + let endpoint; + let window = getWindow(); + + if( + window.fetch == undefined || + (typeof process != 'undefined' && process['env'] && process['env']['NODE_ENV'] == 'test') || + (typeof window.cy != 'undefined') + ) { + endpoint = endpoints[0]; + } else { + + let responseTimes = await Promise.all(endpoints.map((endpoint)=>{ + return new Promise(async (resolve)=>{ + let timeout = 900; + let before = new Date().getTime(); + setTimeout(()=>resolve(timeout), timeout); + const response = await fetch(endpoint, { + method: 'POST', + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ method: 'getIdentity', id: 1, jsonrpc: '2.0' }) + }); + if(!response.ok) { return resolve(999) } + let after = new Date().getTime(); + resolve(after-before); + }) + })); + + const fastestResponse = Math.min(...responseTimes); + const fastestIndex = responseTimes.indexOf(fastestResponse); + endpoint = endpoints[fastestIndex]; + } + + setProvider$1( + blockchain, + new StaticJsonRpcSequentialProvider(endpoint, blockchain, endpoints) + ); +}; + +const getProvider$1 = async (blockchain)=> { + + let providers = getProviders(); + if(providers && providers[blockchain]){ return providers[blockchain] } + + let window = getWindow(); + if(window._getProviderPromise && window._getProviderPromise[blockchain]) { return await window._getProviderPromise[blockchain] } + + if(!window._getProviderPromise){ window._getProviderPromise = {}; } + window._getProviderPromise[blockchain] = new Promise(async(resolve)=> { + await setProviderEndpoints$1(blockchain, ENDPOINTS[blockchain]); + resolve(getWindow()._clientProviders[blockchain]); + }); + + return await window._getProviderPromise[blockchain] +}; + +var Solana = { + getProvider: getProvider$1, + setProviderEndpoints: setProviderEndpoints$1, + setProvider: setProvider$1, +}; + +/*#if _EVM + +let supported = ['ethereum', 'bsc', 'polygon', 'fantom', 'velas'] +supported.evm = ['ethereum', 'bsc', 'polygon', 'fantom', 'velas'] +supported.solana = [] + +/*#elif _SOLANA + +let supported = ['solana'] +supported.evm = [] +supported.solana = ['solana'] + +//#else */ + +let supported = ['ethereum', 'bsc', 'polygon', 'solana', 'fantom', 'velas']; +supported.evm = ['ethereum', 'bsc', 'polygon', 'fantom', 'velas']; +supported.solana = ['solana']; + +/*#if _EVM + +import EVM from './platforms/evm/provider' + +/*#elif _SOLANA + +import Solana from './platforms/solana/provider' + +//#else */ + +const getProvider = async (blockchain)=>{ + + if(supported.evm.includes(blockchain)) { + + /*#if _EVM - if(supported$1.evm.includes(blockchain)) { return await EVM.getProvider(blockchain) + + /*#elif _SOLANA + + //#else */ + + return await EVM.getProvider(blockchain) + + //#endif + + } else if(supported.solana.includes(blockchain)) { + + /*#if _EVM + + return await Solana.getProvider(blockchain) + + /*#elif _SOLANA + + //#else */ + + return await Solana.getProvider(blockchain) + + //#endif + + } else { + throw 'Unknown blockchain: ' + blockchain + } +}; + +const setProvider = (blockchain, provider)=>{ + + if(supported.evm.includes(blockchain)) { + + /*#if _EVM + + return EVM.setProvider(blockchain, provider) + + /*#elif _SOLANA + + //#else */ + + return EVM.setProvider(blockchain, provider) + + //#endif + + } else if(supported.solana.includes(blockchain)) { + + /*#if _EVM + + return Solana.setProvider(blockchain, provider) + + /*#elif _SOLANA + + //#else */ + + return Solana.setProvider(blockchain, provider) + + //#endif + + } else { + throw 'Unknown blockchain: ' + blockchain + } +}; + +const setProviderEndpoints = (blockchain, endpoints)=>{ + + if(supported.evm.includes(blockchain)) { + + /*#if _EVM + + return EVM.setProviderEndpoints(blockchain, endpoints) + + /*#elif _SOLANA + + //#else */ + + return EVM.setProviderEndpoints(blockchain, endpoints) + + //#endif + + } else if(supported.solana.includes(blockchain)) { + + /*#if _EVM + + return Solana.setProviderEndpoints(blockchain, endpoints) + + /*#elif _SOLANA + + //#else */ + + return Solana.setProviderEndpoints(blockchain, endpoints) + + //#endif + } else { throw 'Unknown blockchain: ' + blockchain } }; function _optionalChain$1(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } +let simulate = async function ({ blockchain, from, to, keys, api, params }) { + if(!supported.solana.includes(blockchain)) { throw `${blockchain} not supported for simulation!` } + + const data = Buffer.alloc(api.span); + api.encode(params, data); + + keys = keys.map((key)=>{ + return({...key, + pubkey: new PublicKey(key.pubkey) + }) + }); + + const instruction = new TransactionInstruction({ + programId: new PublicKey(to), + keys, + data + }); + + let transaction = new Transaction({ feePayer: new PublicKey(from) }); + transaction.add(instruction); + + let result; + try{ + const provider = await getProvider('solana'); + result = await provider.simulateTransaction(transaction); + } catch (error) { + console.log(error); + } + + return({ + logs: _optionalChain$1([result, 'optionalAccess', _ => _.value, 'optionalAccess', _2 => _2.logs]) + }) +}; + +const getContractArguments = ({ contract, method, params })=>{ + let fragment = contract.interface.fragments.find((fragment) => { + return fragment.name == method + }); + + if(params instanceof Array) { + return params + } else if (params instanceof Object) { + return fragment.inputs.map((input) => { + return params[input.name] + }) + } +}; + +var estimateEVM = ({ provider, from, to, value, method, api, params }) => { + if(typeof api == "undefined"){ + return provider.estimateGas({ from, to, value }) + } else { + let contract = new ethers.Contract(to, api, provider); + let contractMethod = contract.estimateGas[method]; + let contractArguments = getContractArguments({ contract, method, params }); + if(contractArguments) { + return contractMethod(...contractArguments, { from, value }) + } else { + return contractMethod({ from, value }) + } + } +}; + +function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } let getCacheStore = () => { if (getWindow()._cacheStore == undefined) { resetCache(); @@ -262,7 +508,7 @@ let set = function ({ key, value, expires }) { let get = function ({ key, expires }) { let cachedEntry = getCacheStore()[key]; - if (_optionalChain$1([cachedEntry, 'optionalAccess', _ => _.expiresAt]) > Date.now()) { + if (_optionalChain([cachedEntry, 'optionalAccess', _ => _.expiresAt]) > Date.now()) { return cachedEntry.value } }; @@ -337,10 +583,10 @@ let cache = function ({ call, key, expires = 0 }) { }; let estimate = async function ({ blockchain, from, to, value, method, api, params, cache: cache$1 }) { - if(!supported$1.includes(blockchain)) { throw 'Unknown blockchain: ' + blockchain } + if(!supported.includes(blockchain)) { throw 'Unknown blockchain: ' + blockchain } if(typeof value == 'undefined') { value = '0'; } - const provider = await getProvider$2(blockchain); + const provider = await getProvider(blockchain); return await cache({ expires: cache$1 || 0, @@ -349,33 +595,6 @@ let estimate = async function ({ blockchain, from, to, value, method, api, param }) }; -var parseUrl = (url) => { - if (typeof url == 'object') { - return url - } - let deconstructed = url.match(/(?\w+):\/\/(?[\w\d]+)(\/(?[\w\d]+)*)?/); - - if(deconstructed.groups.part2 == undefined) { - if(deconstructed.groups.part1.match(/\d/)) { - return { - blockchain: deconstructed.groups.blockchain, - address: deconstructed.groups.part1 - } - } else { - return { - blockchain: deconstructed.groups.blockchain, - method: deconstructed.groups.part1 - } - } - } else { - return { - blockchain: deconstructed.groups.blockchain, - address: deconstructed.groups.part1, - method: deconstructed.groups.part2 - } - } -}; - let paramsToContractArgs = ({ contract, method, params }) => { let fragment = contract.interface.fragments.find((fragment) => { return fragment.name == method @@ -418,97 +637,6 @@ var requestEVM = async ({ blockchain, address, api, method, params, block }) => } }; -class StaticJsonRpcSequentialProvider extends Connection { - - constructor(url, network, endpoints) { - super(url); - this._network = network; - this._endpoint = url; - this._endpoints = endpoints; - } -} - -const ENDPOINTS = { - solana: ['https://solana-mainnet.phantom.app/YBPpkkN4g91xDiAnTE9r0RcMkjg0sKUIWvAfoFVJ', 'https://mainnet-beta.solflare.network', 'https://solana-mainnet.rpc.extrnode.com'] -}; - -const getProviders = ()=> { - if(getWindow()._clientProviders == undefined) { - getWindow()._clientProviders = {}; - } - return getWindow()._clientProviders -}; - -const setProvider$1 = (blockchain, provider)=> { - getProviders()[blockchain] = provider; -}; - -const setProviderEndpoints$1 = async (blockchain, endpoints)=> { - - let endpoint; - let window = getWindow(); - - if( - window.fetch == undefined || - (typeof process != 'undefined' && process['env'] && process['env']['NODE_ENV'] == 'test') || - (typeof window.cy != 'undefined') - ) { - endpoint = endpoints[0]; - } else { - - let responseTimes = await Promise.all(endpoints.map((endpoint)=>{ - return new Promise(async (resolve)=>{ - let timeout = 900; - let before = new Date().getTime(); - setTimeout(()=>resolve(timeout), timeout); - const response = await fetch(endpoint, { - method: 'POST', - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json' - }, - body: JSON.stringify({ method: 'getIdentity', id: 1, jsonrpc: '2.0' }) - }); - if(!response.ok) { return resolve(999) } - let after = new Date().getTime(); - resolve(after-before); - }) - })); - - const fastestResponse = Math.min(...responseTimes); - const fastestIndex = responseTimes.indexOf(fastestResponse); - endpoint = endpoints[fastestIndex]; - } - - setProvider$1( - blockchain, - new StaticJsonRpcSequentialProvider(endpoint, blockchain, endpoints) - ); -}; - -const getProvider$1 = async (blockchain)=> { - - let providers = getProviders(); - if(providers && providers[blockchain]){ return providers[blockchain] } - - let window = getWindow(); - if(window._getProviderPromise && window._getProviderPromise[blockchain]) { return await window._getProviderPromise[blockchain] } - - if(!window._getProviderPromise){ window._getProviderPromise = {}; } - window._getProviderPromise[blockchain] = new Promise(async(resolve)=> { - await setProviderEndpoints$1(blockchain, ENDPOINTS[blockchain]); - resolve(getWindow()._clientProviders[blockchain]); - }); - - return await window._getProviderPromise[blockchain] -}; - -var Solana = { - getProvider: getProvider$1, - setProviderEndpoints: setProviderEndpoints$1, - setProvider: setProvider$1, -}; - let accountInfo = async ({ address, api, method, params, provider, block }) => { const info = await provider.getAccountInfo(new PublicKey(address)); return api.decode(info.data) @@ -546,9 +674,42 @@ var requestSolana = async ({ blockchain, address, api, method, params, block }) } }; -let supported = ['ethereum', 'bsc', 'polygon', 'solana', 'fantom', 'velas']; -supported.evm = ['ethereum', 'bsc', 'polygon', 'fantom', 'velas']; -supported.solana = ['solana']; +var parseUrl = (url) => { + if (typeof url == 'object') { + return url + } + let deconstructed = url.match(/(?\w+):\/\/(?[\w\d]+)(\/(?[\w\d]+)*)?/); + + if(deconstructed.groups.part2 == undefined) { + if(deconstructed.groups.part1.match(/\d/)) { + return { + blockchain: deconstructed.groups.blockchain, + address: deconstructed.groups.part1 + } + } else { + return { + blockchain: deconstructed.groups.blockchain, + method: deconstructed.groups.part1 + } + } + } else { + return { + blockchain: deconstructed.groups.blockchain, + address: deconstructed.groups.part1, + method: deconstructed.groups.part2 + } + } +}; + +/*#if _EVM + +import requestEVM from './platforms/evm/request' + +/*#elif _SOLANA + +import requestSolana from './platforms/solana/request' + +//#else */ let request = async function (url, options) { let { blockchain, address, method } = parseUrl(url); @@ -559,81 +720,37 @@ let request = async function (url, options) { key: [blockchain, address, method, params, block], call: async()=>{ if(supported.evm.includes(blockchain)) { - return requestEVM({ blockchain, address, api, method, params, block }) - } else if(supported.solana.includes(blockchain)) { - return requestSolana({ blockchain, address, api, method, params, block }) - } else { - throw 'Unknown blockchain: ' + blockchain - } - } - }) -}; -const getProvider = async (blockchain)=>{ + /*#if _EVM - if(supported.evm.includes(blockchain)) { - return await EVM.getProvider(blockchain) - } else if(supported.solana.includes(blockchain)) { - return await Solana.getProvider(blockchain) - } else { - throw 'Unknown blockchain: ' + blockchain - } -}; + return requestEVM({ blockchain, address, api, method, params, block }) -const setProvider = (blockchain, provider)=>{ + /*#elif _SOLANA - if(supported.evm.includes(blockchain)) { - return EVM.setProvider(blockchain, provider) - } else if(supported.solana.includes(blockchain)) { - return Solana.setProvider(blockchain, provider) - } else { - throw 'Unknown blockchain: ' + blockchain - } -}; + //#else */ -const setProviderEndpoints = (blockchain, endpoints)=>{ + return requestEVM({ blockchain, address, api, method, params, block }) - if(supported.evm.includes(blockchain)) { - return EVM.setProviderEndpoints(blockchain, endpoints) - } else if(supported.solana.includes(blockchain)) { - return Solana.setProviderEndpoints(blockchain, endpoints) - } else { - throw 'Unknown blockchain: ' + blockchain - } -}; + //#endif -function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } -let simulate = async function ({ blockchain, from, to, keys, api, params }) { - if(!supported.solana.includes(blockchain)) { throw `${blockchain} not supported for simulation!` } + } else if(supported.solana.includes(blockchain)) { - const data = Buffer.alloc(api.span); - api.encode(params, data); + /*#if _EVM - keys = keys.map((key)=>{ - return({...key, - pubkey: new PublicKey(key.pubkey) - }) - }); + /*#elif _SOLANA - const instruction = new TransactionInstruction({ - programId: new PublicKey(to), - keys, - data - }); + return requestSolana({ blockchain, address, api, method, params, block }) - let transaction = new Transaction({ feePayer: new PublicKey(from) }); - transaction.add(instruction); + //#else */ - let result; - try{ - const provider = await getProvider('solana'); - result = await provider.simulateTransaction(transaction); - } catch (error) { - console.log(error); - } + return requestSolana({ blockchain, address, api, method, params, block }) - return({ - logs: _optionalChain([result, 'optionalAccess', _ => _.value, 'optionalAccess', _2 => _2.logs]) + //#endif + + } else { + throw 'Unknown blockchain: ' + blockchain + } + } }) }; diff --git a/dist/umd/index.evm.js b/dist/umd/index.evm.js index efaaea0..0f99423 100644 --- a/dist/umd/index.evm.js +++ b/dist/umd/index.evm.js @@ -33,10 +33,6 @@ } }; - let supported = ['ethereum', 'bsc', 'polygon', 'fantom', 'velas']; - supported.evm = ['ethereum', 'bsc', 'polygon', 'fantom', 'velas']; - supported.solana = []; - const BATCH_INTERVAL = 10; const CHUNK_SIZE = 99; @@ -225,10 +221,24 @@ setProvider: setProvider$1, }; + let supported = ['ethereum', 'bsc', 'polygon', 'fantom', 'velas']; + supported.evm = ['ethereum', 'bsc', 'polygon', 'fantom', 'velas']; + supported.solana = []; + const getProvider = async (blockchain)=>{ if(supported.evm.includes(blockchain)) { + + return await EVM.getProvider(blockchain) + + + } else if(supported.solana.includes(blockchain)) { + + + return await Solana.getProvider(blockchain) + + } else { throw 'Unknown blockchain: ' + blockchain } @@ -237,7 +247,17 @@ const setProvider = (blockchain, provider)=>{ if(supported.evm.includes(blockchain)) { + + return EVM.setProvider(blockchain, provider) + + + } else if(supported.solana.includes(blockchain)) { + + + return Solana.setProvider(blockchain, provider) + + } else { throw 'Unknown blockchain: ' + blockchain } @@ -246,7 +266,17 @@ const setProviderEndpoints = (blockchain, endpoints)=>{ if(supported.evm.includes(blockchain)) { + + return EVM.setProviderEndpoints(blockchain, endpoints) + + + } else if(supported.solana.includes(blockchain)) { + + + return Solana.setProviderEndpoints(blockchain, endpoints) + + } else { throw 'Unknown blockchain: ' + blockchain } @@ -369,33 +399,6 @@ }) }; - var parseUrl = (url) => { - if (typeof url == 'object') { - return url - } - let deconstructed = url.match(/(?\w+):\/\/(?[\w\d]+)(\/(?[\w\d]+)*)?/); - - if(deconstructed.groups.part2 == undefined) { - if(deconstructed.groups.part1.match(/\d/)) { - return { - blockchain: deconstructed.groups.blockchain, - address: deconstructed.groups.part1 - } - } else { - return { - blockchain: deconstructed.groups.blockchain, - method: deconstructed.groups.part1 - } - } - } else { - return { - blockchain: deconstructed.groups.blockchain, - address: deconstructed.groups.part1, - method: deconstructed.groups.part2 - } - } - }; - let paramsToContractArgs = ({ contract, method, params }) => { let fragment = contract.interface.fragments.find((fragment) => { return fragment.name == method @@ -438,6 +441,33 @@ } }; + var parseUrl = (url) => { + if (typeof url == 'object') { + return url + } + let deconstructed = url.match(/(?\w+):\/\/(?[\w\d]+)(\/(?[\w\d]+)*)?/); + + if(deconstructed.groups.part2 == undefined) { + if(deconstructed.groups.part1.match(/\d/)) { + return { + blockchain: deconstructed.groups.blockchain, + address: deconstructed.groups.part1 + } + } else { + return { + blockchain: deconstructed.groups.blockchain, + method: deconstructed.groups.part1 + } + } + } else { + return { + blockchain: deconstructed.groups.blockchain, + address: deconstructed.groups.part1, + method: deconstructed.groups.part2 + } + } + }; + let request = async function (url, options) { let { blockchain, address, method } = parseUrl(url); let { api, params, cache: cache$1, block } = (typeof(url) == 'object' ? url : options) || {}; @@ -447,20 +477,27 @@ key: [blockchain, address, method, params, block], call: async()=>{ if(supported.evm.includes(blockchain)) { + + return requestEVM({ blockchain, address, api, method, params, block }) - } else { + + + } else if(supported.solana.includes(blockchain)) ; else { throw 'Unknown blockchain: ' + blockchain } } }) }; + const simulate = undefined; + exports.estimate = estimate; exports.getProvider = getProvider; exports.request = request; exports.resetCache = resetCache; exports.setProvider = setProvider; exports.setProviderEndpoints = setProviderEndpoints; + exports.simulate = simulate; Object.defineProperty(exports, '__esModule', { value: true }); diff --git a/dist/umd/index.js b/dist/umd/index.js index f6562fd..26e9392 100644 --- a/dist/umd/index.js +++ b/dist/umd/index.js @@ -1,41 +1,8 @@ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('ethers'), require('@depay/web3-blockchains'), require('@depay/solana-web3.js')) : - typeof define === 'function' && define.amd ? define(['exports', 'ethers', '@depay/web3-blockchains', '@depay/solana-web3.js'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Web3Client = {}, global.ethers, global.Web3Blockchains, global.SolanaWeb3js)); -})(this, (function (exports, ethers, web3Blockchains, solanaWeb3_js) { 'use strict'; - - const getContractArguments = ({ contract, method, params })=>{ - let fragment = contract.interface.fragments.find((fragment) => { - return fragment.name == method - }); - - if(params instanceof Array) { - return params - } else if (params instanceof Object) { - return fragment.inputs.map((input) => { - return params[input.name] - }) - } - }; - - var estimateEVM = ({ provider, from, to, value, method, api, params }) => { - if(typeof api == "undefined"){ - return provider.estimateGas({ from, to, value }) - } else { - let contract = new ethers.ethers.Contract(to, api, provider); - let contractMethod = contract.estimateGas[method]; - let contractArguments = getContractArguments({ contract, method, params }); - if(contractArguments) { - return contractMethod(...contractArguments, { from, value }) - } else { - return contractMethod({ from, value }) - } - } - }; - - let supported$1 = ['ethereum', 'bsc', 'polygon', 'fantom', 'velas']; - supported$1.evm = ['ethereum', 'bsc', 'polygon', 'fantom', 'velas']; - supported$1.solana = []; + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@depay/solana-web3.js'), require('@depay/web3-blockchains'), require('ethers')) : + typeof define === 'function' && define.amd ? define(['exports', '@depay/solana-web3.js', '@depay/web3-blockchains', 'ethers'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Web3Client = {}, global.SolanaWeb3js, global.Web3Blockchains, global.ethers)); +})(this, (function (exports, solanaWeb3_js, web3Blockchains, ethers) { 'use strict'; const BATCH_INTERVAL = 10; const CHUNK_SIZE = 99; @@ -202,7 +169,7 @@ ); }; - const getProvider$3 = async (blockchain)=> { + const getProvider$2 = async (blockchain)=> { let providers = getProviders$1(); if(providers && providers[blockchain]){ return providers[blockchain] } @@ -220,21 +187,300 @@ }; var EVM = { - getProvider: getProvider$3, + getProvider: getProvider$2, setProviderEndpoints: setProviderEndpoints$2, setProvider: setProvider$2, }; - const getProvider$2 = async (blockchain)=>{ + class StaticJsonRpcSequentialProvider extends solanaWeb3_js.Connection { + + constructor(url, network, endpoints) { + super(url); + this._network = network; + this._endpoint = url; + this._endpoints = endpoints; + } + } + + const ENDPOINTS = { + solana: ['https://solana-mainnet.phantom.app/YBPpkkN4g91xDiAnTE9r0RcMkjg0sKUIWvAfoFVJ', 'https://mainnet-beta.solflare.network', 'https://solana-mainnet.rpc.extrnode.com'] + }; + + const getProviders = ()=> { + if(getWindow()._clientProviders == undefined) { + getWindow()._clientProviders = {}; + } + return getWindow()._clientProviders + }; + + const setProvider$1 = (blockchain, provider)=> { + getProviders()[blockchain] = provider; + }; + + const setProviderEndpoints$1 = async (blockchain, endpoints)=> { + + let endpoint; + let window = getWindow(); + + if( + window.fetch == undefined || + (typeof process != 'undefined' && process['env'] && process['env']['NODE_ENV'] == 'test') || + (typeof window.cy != 'undefined') + ) { + endpoint = endpoints[0]; + } else { + + let responseTimes = await Promise.all(endpoints.map((endpoint)=>{ + return new Promise(async (resolve)=>{ + let timeout = 900; + let before = new Date().getTime(); + setTimeout(()=>resolve(timeout), timeout); + const response = await fetch(endpoint, { + method: 'POST', + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ method: 'getIdentity', id: 1, jsonrpc: '2.0' }) + }); + if(!response.ok) { return resolve(999) } + let after = new Date().getTime(); + resolve(after-before); + }) + })); + + const fastestResponse = Math.min(...responseTimes); + const fastestIndex = responseTimes.indexOf(fastestResponse); + endpoint = endpoints[fastestIndex]; + } + + setProvider$1( + blockchain, + new StaticJsonRpcSequentialProvider(endpoint, blockchain, endpoints) + ); + }; + + const getProvider$1 = async (blockchain)=> { + + let providers = getProviders(); + if(providers && providers[blockchain]){ return providers[blockchain] } + + let window = getWindow(); + if(window._getProviderPromise && window._getProviderPromise[blockchain]) { return await window._getProviderPromise[blockchain] } + + if(!window._getProviderPromise){ window._getProviderPromise = {}; } + window._getProviderPromise[blockchain] = new Promise(async(resolve)=> { + await setProviderEndpoints$1(blockchain, ENDPOINTS[blockchain]); + resolve(getWindow()._clientProviders[blockchain]); + }); + + return await window._getProviderPromise[blockchain] + }; + + var Solana = { + getProvider: getProvider$1, + setProviderEndpoints: setProviderEndpoints$1, + setProvider: setProvider$1, + }; + + /*#if _EVM + + let supported = ['ethereum', 'bsc', 'polygon', 'fantom', 'velas'] + supported.evm = ['ethereum', 'bsc', 'polygon', 'fantom', 'velas'] + supported.solana = [] + + /*#elif _SOLANA + + let supported = ['solana'] + supported.evm = [] + supported.solana = ['solana'] + + //#else */ + + let supported = ['ethereum', 'bsc', 'polygon', 'solana', 'fantom', 'velas']; + supported.evm = ['ethereum', 'bsc', 'polygon', 'fantom', 'velas']; + supported.solana = ['solana']; + + /*#if _EVM + + import EVM from './platforms/evm/provider' + + /*#elif _SOLANA + + import Solana from './platforms/solana/provider' + + //#else */ + + const getProvider = async (blockchain)=>{ + + if(supported.evm.includes(blockchain)) { + + /*#if _EVM - if(supported$1.evm.includes(blockchain)) { return await EVM.getProvider(blockchain) + + /*#elif _SOLANA + + //#else */ + + return await EVM.getProvider(blockchain) + + //#endif + + } else if(supported.solana.includes(blockchain)) { + + /*#if _EVM + + return await Solana.getProvider(blockchain) + + /*#elif _SOLANA + + //#else */ + + return await Solana.getProvider(blockchain) + + //#endif + + } else { + throw 'Unknown blockchain: ' + blockchain + } + }; + + const setProvider = (blockchain, provider)=>{ + + if(supported.evm.includes(blockchain)) { + + /*#if _EVM + + return EVM.setProvider(blockchain, provider) + + /*#elif _SOLANA + + //#else */ + + return EVM.setProvider(blockchain, provider) + + //#endif + + } else if(supported.solana.includes(blockchain)) { + + /*#if _EVM + + return Solana.setProvider(blockchain, provider) + + /*#elif _SOLANA + + //#else */ + + return Solana.setProvider(blockchain, provider) + + //#endif + + } else { + throw 'Unknown blockchain: ' + blockchain + } + }; + + const setProviderEndpoints = (blockchain, endpoints)=>{ + + if(supported.evm.includes(blockchain)) { + + /*#if _EVM + + return EVM.setProviderEndpoints(blockchain, endpoints) + + /*#elif _SOLANA + + //#else */ + + return EVM.setProviderEndpoints(blockchain, endpoints) + + //#endif + + } else if(supported.solana.includes(blockchain)) { + + /*#if _EVM + + return Solana.setProviderEndpoints(blockchain, endpoints) + + /*#elif _SOLANA + + //#else */ + + return Solana.setProviderEndpoints(blockchain, endpoints) + + //#endif + } else { throw 'Unknown blockchain: ' + blockchain } }; function _optionalChain$1(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } + let simulate = async function ({ blockchain, from, to, keys, api, params }) { + if(!supported.solana.includes(blockchain)) { throw `${blockchain} not supported for simulation!` } + + const data = solanaWeb3_js.Buffer.alloc(api.span); + api.encode(params, data); + + keys = keys.map((key)=>{ + return({...key, + pubkey: new solanaWeb3_js.PublicKey(key.pubkey) + }) + }); + + const instruction = new solanaWeb3_js.TransactionInstruction({ + programId: new solanaWeb3_js.PublicKey(to), + keys, + data + }); + + let transaction = new solanaWeb3_js.Transaction({ feePayer: new solanaWeb3_js.PublicKey(from) }); + transaction.add(instruction); + + let result; + try{ + const provider = await getProvider('solana'); + result = await provider.simulateTransaction(transaction); + } catch (error) { + console.log(error); + } + + return({ + logs: _optionalChain$1([result, 'optionalAccess', _ => _.value, 'optionalAccess', _2 => _2.logs]) + }) + }; + + const getContractArguments = ({ contract, method, params })=>{ + let fragment = contract.interface.fragments.find((fragment) => { + return fragment.name == method + }); + + if(params instanceof Array) { + return params + } else if (params instanceof Object) { + return fragment.inputs.map((input) => { + return params[input.name] + }) + } + }; + + var estimateEVM = ({ provider, from, to, value, method, api, params }) => { + if(typeof api == "undefined"){ + return provider.estimateGas({ from, to, value }) + } else { + let contract = new ethers.ethers.Contract(to, api, provider); + let contractMethod = contract.estimateGas[method]; + let contractArguments = getContractArguments({ contract, method, params }); + if(contractArguments) { + return contractMethod(...contractArguments, { from, value }) + } else { + return contractMethod({ from, value }) + } + } + }; + + function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } let getCacheStore = () => { if (getWindow()._cacheStore == undefined) { resetCache(); @@ -264,7 +510,7 @@ let get = function ({ key, expires }) { let cachedEntry = getCacheStore()[key]; - if (_optionalChain$1([cachedEntry, 'optionalAccess', _ => _.expiresAt]) > Date.now()) { + if (_optionalChain([cachedEntry, 'optionalAccess', _ => _.expiresAt]) > Date.now()) { return cachedEntry.value } }; @@ -339,10 +585,10 @@ }; let estimate = async function ({ blockchain, from, to, value, method, api, params, cache: cache$1 }) { - if(!supported$1.includes(blockchain)) { throw 'Unknown blockchain: ' + blockchain } + if(!supported.includes(blockchain)) { throw 'Unknown blockchain: ' + blockchain } if(typeof value == 'undefined') { value = '0'; } - const provider = await getProvider$2(blockchain); + const provider = await getProvider(blockchain); return await cache({ expires: cache$1 || 0, @@ -351,33 +597,6 @@ }) }; - var parseUrl = (url) => { - if (typeof url == 'object') { - return url - } - let deconstructed = url.match(/(?\w+):\/\/(?[\w\d]+)(\/(?[\w\d]+)*)?/); - - if(deconstructed.groups.part2 == undefined) { - if(deconstructed.groups.part1.match(/\d/)) { - return { - blockchain: deconstructed.groups.blockchain, - address: deconstructed.groups.part1 - } - } else { - return { - blockchain: deconstructed.groups.blockchain, - method: deconstructed.groups.part1 - } - } - } else { - return { - blockchain: deconstructed.groups.blockchain, - address: deconstructed.groups.part1, - method: deconstructed.groups.part2 - } - } - }; - let paramsToContractArgs = ({ contract, method, params }) => { let fragment = contract.interface.fragments.find((fragment) => { return fragment.name == method @@ -420,97 +639,6 @@ } }; - class StaticJsonRpcSequentialProvider extends solanaWeb3_js.Connection { - - constructor(url, network, endpoints) { - super(url); - this._network = network; - this._endpoint = url; - this._endpoints = endpoints; - } - } - - const ENDPOINTS = { - solana: ['https://solana-mainnet.phantom.app/YBPpkkN4g91xDiAnTE9r0RcMkjg0sKUIWvAfoFVJ', 'https://mainnet-beta.solflare.network', 'https://solana-mainnet.rpc.extrnode.com'] - }; - - const getProviders = ()=> { - if(getWindow()._clientProviders == undefined) { - getWindow()._clientProviders = {}; - } - return getWindow()._clientProviders - }; - - const setProvider$1 = (blockchain, provider)=> { - getProviders()[blockchain] = provider; - }; - - const setProviderEndpoints$1 = async (blockchain, endpoints)=> { - - let endpoint; - let window = getWindow(); - - if( - window.fetch == undefined || - (typeof process != 'undefined' && process['env'] && process['env']['NODE_ENV'] == 'test') || - (typeof window.cy != 'undefined') - ) { - endpoint = endpoints[0]; - } else { - - let responseTimes = await Promise.all(endpoints.map((endpoint)=>{ - return new Promise(async (resolve)=>{ - let timeout = 900; - let before = new Date().getTime(); - setTimeout(()=>resolve(timeout), timeout); - const response = await fetch(endpoint, { - method: 'POST', - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json' - }, - body: JSON.stringify({ method: 'getIdentity', id: 1, jsonrpc: '2.0' }) - }); - if(!response.ok) { return resolve(999) } - let after = new Date().getTime(); - resolve(after-before); - }) - })); - - const fastestResponse = Math.min(...responseTimes); - const fastestIndex = responseTimes.indexOf(fastestResponse); - endpoint = endpoints[fastestIndex]; - } - - setProvider$1( - blockchain, - new StaticJsonRpcSequentialProvider(endpoint, blockchain, endpoints) - ); - }; - - const getProvider$1 = async (blockchain)=> { - - let providers = getProviders(); - if(providers && providers[blockchain]){ return providers[blockchain] } - - let window = getWindow(); - if(window._getProviderPromise && window._getProviderPromise[blockchain]) { return await window._getProviderPromise[blockchain] } - - if(!window._getProviderPromise){ window._getProviderPromise = {}; } - window._getProviderPromise[blockchain] = new Promise(async(resolve)=> { - await setProviderEndpoints$1(blockchain, ENDPOINTS[blockchain]); - resolve(getWindow()._clientProviders[blockchain]); - }); - - return await window._getProviderPromise[blockchain] - }; - - var Solana = { - getProvider: getProvider$1, - setProviderEndpoints: setProviderEndpoints$1, - setProvider: setProvider$1, - }; - let accountInfo = async ({ address, api, method, params, provider, block }) => { const info = await provider.getAccountInfo(new solanaWeb3_js.PublicKey(address)); return api.decode(info.data) @@ -548,9 +676,42 @@ } }; - let supported = ['ethereum', 'bsc', 'polygon', 'solana', 'fantom', 'velas']; - supported.evm = ['ethereum', 'bsc', 'polygon', 'fantom', 'velas']; - supported.solana = ['solana']; + var parseUrl = (url) => { + if (typeof url == 'object') { + return url + } + let deconstructed = url.match(/(?\w+):\/\/(?[\w\d]+)(\/(?[\w\d]+)*)?/); + + if(deconstructed.groups.part2 == undefined) { + if(deconstructed.groups.part1.match(/\d/)) { + return { + blockchain: deconstructed.groups.blockchain, + address: deconstructed.groups.part1 + } + } else { + return { + blockchain: deconstructed.groups.blockchain, + method: deconstructed.groups.part1 + } + } + } else { + return { + blockchain: deconstructed.groups.blockchain, + address: deconstructed.groups.part1, + method: deconstructed.groups.part2 + } + } + }; + + /*#if _EVM + + import requestEVM from './platforms/evm/request' + + /*#elif _SOLANA + + import requestSolana from './platforms/solana/request' + + //#else */ let request = async function (url, options) { let { blockchain, address, method } = parseUrl(url); @@ -561,81 +722,37 @@ key: [blockchain, address, method, params, block], call: async()=>{ if(supported.evm.includes(blockchain)) { - return requestEVM({ blockchain, address, api, method, params, block }) - } else if(supported.solana.includes(blockchain)) { - return requestSolana({ blockchain, address, api, method, params, block }) - } else { - throw 'Unknown blockchain: ' + blockchain - } - } - }) - }; - const getProvider = async (blockchain)=>{ + /*#if _EVM - if(supported.evm.includes(blockchain)) { - return await EVM.getProvider(blockchain) - } else if(supported.solana.includes(blockchain)) { - return await Solana.getProvider(blockchain) - } else { - throw 'Unknown blockchain: ' + blockchain - } - }; + return requestEVM({ blockchain, address, api, method, params, block }) - const setProvider = (blockchain, provider)=>{ + /*#elif _SOLANA - if(supported.evm.includes(blockchain)) { - return EVM.setProvider(blockchain, provider) - } else if(supported.solana.includes(blockchain)) { - return Solana.setProvider(blockchain, provider) - } else { - throw 'Unknown blockchain: ' + blockchain - } - }; + //#else */ - const setProviderEndpoints = (blockchain, endpoints)=>{ + return requestEVM({ blockchain, address, api, method, params, block }) - if(supported.evm.includes(blockchain)) { - return EVM.setProviderEndpoints(blockchain, endpoints) - } else if(supported.solana.includes(blockchain)) { - return Solana.setProviderEndpoints(blockchain, endpoints) - } else { - throw 'Unknown blockchain: ' + blockchain - } - }; + //#endif - function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } - let simulate = async function ({ blockchain, from, to, keys, api, params }) { - if(!supported.solana.includes(blockchain)) { throw `${blockchain} not supported for simulation!` } + } else if(supported.solana.includes(blockchain)) { - const data = solanaWeb3_js.Buffer.alloc(api.span); - api.encode(params, data); + /*#if _EVM - keys = keys.map((key)=>{ - return({...key, - pubkey: new solanaWeb3_js.PublicKey(key.pubkey) - }) - }); + /*#elif _SOLANA - const instruction = new solanaWeb3_js.TransactionInstruction({ - programId: new solanaWeb3_js.PublicKey(to), - keys, - data - }); + return requestSolana({ blockchain, address, api, method, params, block }) - let transaction = new solanaWeb3_js.Transaction({ feePayer: new solanaWeb3_js.PublicKey(from) }); - transaction.add(instruction); + //#else */ - let result; - try{ - const provider = await getProvider('solana'); - result = await provider.simulateTransaction(transaction); - } catch (error) { - console.log(error); - } + return requestSolana({ blockchain, address, api, method, params, block }) - return({ - logs: _optionalChain([result, 'optionalAccess', _ => _.value, 'optionalAccess', _2 => _2.logs]) + //#endif + + } else { + throw 'Unknown blockchain: ' + blockchain + } + } }) }; diff --git a/package.evm.json b/package.evm.json index 76e4980..de5c922 100644 --- a/package.evm.json +++ b/package.evm.json @@ -1,11 +1,10 @@ { "name": "@depay/web3-client-evm", "moduleName": "Web3Client", - "version": "10.4.1", + "version": "10.5.0", "description": "A web3 client to fetch blockchain data just like you are used to with HTTP clients.", "main": "dist/umd/index.evm.js", "module": "dist/esm/index.evm.js", - "source": "src/index.evm.js", "files": [ "dist" ], diff --git a/package.json b/package.json index d93d32c..333d59b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@depay/web3-client", "moduleName": "Web3Client", - "version": "10.4.1", + "version": "10.5.0", "description": "A web3 client to fetch blockchain data just like you are used to with HTTP clients.", "main": "dist/umd/index.js", "module": "dist/esm/index.js", @@ -46,7 +46,7 @@ "@depay/solana-web3.js": "^1.19.0", "@depay/web3-blockchains": "^6.5.1", "@depay/web3-constants": "^6.4.0", - "@depay/web3-mock": "^13.23.0", + "@depay/web3-mock": "^13.24.0", "@rollup/plugin-commonjs": "^22.0.1", "@rollup/plugin-json": "^4.1.0", "@rollup/plugin-node-resolve": "^13.3.0", @@ -62,6 +62,7 @@ "regenerator-runtime": "^0.13.7", "rollup": "^2.76.0", "rollup-plugin-delete": "^2.0.0", + "rollup-plugin-jscc": "^2.0.0", "rollup-plugin-livereload": "^2.0.5", "rollup-plugin-serve": "^2.0.0", "webpack": "^5.73.0" diff --git a/package.solana.json b/package.solana.json new file mode 100644 index 0000000..00c348c --- /dev/null +++ b/package.solana.json @@ -0,0 +1,31 @@ +{ + "name": "@depay/web3-client-solana", + "moduleName": "Web3Client", + "version": "10.5.0", + "description": "A web3 client to fetch blockchain data just like you are used to with HTTP clients.", + "main": "dist/umd/index.solana.js", + "module": "dist/esm/index.solana.js", + "files": [ + "dist" + ], + "repository": "git@github.com:DePayFi/web3-client.git", + "keywords": [ + "web3", + "client", + "request", + "estimate" + ], + "author": "depay.com", + "license": "MIT", + "bugs": { + "url": "https://github.com/DePayFi/web3-client/issues" + }, + "homepage": "https://depay.com", + "private": false, + "peerDependencies": { + "@depay/web3-blockchains": "^6.5.1", + }, + "engines": { + "node": ">=16" + } +} diff --git a/rollup.module.evm.config.js b/rollup.module.evm.config.js index f9f31d4..c807bf4 100644 --- a/rollup.module.evm.config.js +++ b/rollup.module.evm.config.js @@ -1,5 +1,6 @@ import commonjs from '@rollup/plugin-commonjs' import globals from './rollup.globals.js' +import jscc from 'rollup-plugin-jscc' import json from '@rollup/plugin-json' import pkg from './package.evm.json' import replace from '@rollup/plugin-replace' @@ -8,7 +9,7 @@ import sucrase from '@rollup/plugin-sucrase' import { nodeResolve } from '@rollup/plugin-node-resolve' export default { - input: 'src/index.evm.js', + input: 'src/index.js', output: [ { format: 'es', @@ -27,6 +28,7 @@ export default { ...Object.keys(pkg.peerDependencies || {}), ], plugins: [ + jscc({ values: { _EVM: 1 }}), json(), sucrase({ exclude: ['node_modules/**'], diff --git a/src/blockchains.evm.js b/src/blockchains.evm.js deleted file mode 100644 index 2118752..0000000 --- a/src/blockchains.evm.js +++ /dev/null @@ -1,5 +0,0 @@ -let supported = ['ethereum', 'bsc', 'polygon', 'fantom', 'velas'] -supported.evm = ['ethereum', 'bsc', 'polygon', 'fantom', 'velas'] -supported.solana = [] - -export { supported } diff --git a/src/blockchains.js b/src/blockchains.js index 834f2ff..5cd5cbf 100644 --- a/src/blockchains.js +++ b/src/blockchains.js @@ -1,5 +1,21 @@ +/*#if _EVM + +let supported = ['ethereum', 'bsc', 'polygon', 'fantom', 'velas'] +supported.evm = ['ethereum', 'bsc', 'polygon', 'fantom', 'velas'] +supported.solana = [] + +/*#elif _SOLANA + +let supported = ['solana'] +supported.evm = [] +supported.solana = ['solana'] + +//#else */ + let supported = ['ethereum', 'bsc', 'polygon', 'solana', 'fantom', 'velas'] supported.evm = ['ethereum', 'bsc', 'polygon', 'fantom', 'velas'] supported.solana = ['solana'] +//#endif + export { supported } diff --git a/src/estimate.js b/src/estimate.js index 27cfc84..06fec79 100644 --- a/src/estimate.js +++ b/src/estimate.js @@ -1,7 +1,7 @@ import estimateEVM from './platforms/evm/estimate' -import { getProvider } from './provider.evm' +import { getProvider } from './provider' import { cache as cacheRequest } from './cache' -import { supported } from './blockchains.evm' +import { supported } from './blockchains' let estimate = async function ({ blockchain, from, to, value, method, api, params, cache }) { if(!supported.includes(blockchain)) { throw 'Unknown blockchain: ' + blockchain } diff --git a/src/index.evm.js b/src/index.evm.js deleted file mode 100644 index bf67bfb..0000000 --- a/src/index.evm.js +++ /dev/null @@ -1,13 +0,0 @@ -import estimate from './estimate' -import request from './request.evm' -import { getProvider, setProviderEndpoints, setProvider } from './provider.evm' -import { resetCache } from './cache' - -export { - request, - estimate, - getProvider, - setProviderEndpoints, - setProvider, - resetCache -} diff --git a/src/index.js b/src/index.js index e6362fa..10517b9 100644 --- a/src/index.js +++ b/src/index.js @@ -1,6 +1,19 @@ +/*#if _EVM + +const simulate = undefined + +/*#elif _SOLANA + +import simulate from './simulate' + +//#else */ + +import simulate from './simulate' + +//#endif + import estimate from './estimate' import request from './request' -import simulate from './simulate' import { getProvider, setProviderEndpoints, setProvider } from './provider' import { resetCache } from './cache' diff --git a/src/provider.evm.js b/src/provider.evm.js deleted file mode 100644 index e60369b..0000000 --- a/src/provider.evm.js +++ /dev/null @@ -1,36 +0,0 @@ -import { supported } from './blockchains.evm' - -import EVM from './platforms/evm/provider' - -const getProvider = async (blockchain)=>{ - - if(supported.evm.includes(blockchain)) { - return await EVM.getProvider(blockchain) - } else { - throw 'Unknown blockchain: ' + blockchain - } -} - -const setProvider = (blockchain, provider)=>{ - - if(supported.evm.includes(blockchain)) { - return EVM.setProvider(blockchain, provider) - } else { - throw 'Unknown blockchain: ' + blockchain - } -} - -const setProviderEndpoints = (blockchain, endpoints)=>{ - - if(supported.evm.includes(blockchain)) { - return EVM.setProviderEndpoints(blockchain, endpoints) - } else { - throw 'Unknown blockchain: ' + blockchain - } -} - -export { - getProvider, - setProvider, - setProviderEndpoints, -} diff --git a/src/provider.js b/src/provider.js index 1ce5a36..b8a9db9 100644 --- a/src/provider.js +++ b/src/provider.js @@ -1,14 +1,50 @@ -import { supported } from './blockchains' +/*#if _EVM + +import EVM from './platforms/evm/provider' + +/*#elif _SOLANA + +import Solana from './platforms/solana/provider' + +//#else */ import EVM from './platforms/evm/provider' import Solana from './platforms/solana/provider' +//#endif + +import { supported } from './blockchains' + const getProvider = async (blockchain)=>{ if(supported.evm.includes(blockchain)) { + + /*#if _EVM + return await EVM.getProvider(blockchain) + + /*#elif _SOLANA + + //#else */ + + return await EVM.getProvider(blockchain) + + //#endif + } else if(supported.solana.includes(blockchain)) { + + /*#if _EVM + + return await Solana.getProvider(blockchain) + + /*#elif _SOLANA + + //#else */ + return await Solana.getProvider(blockchain) + + //#endif + } else { throw 'Unknown blockchain: ' + blockchain } @@ -17,9 +53,33 @@ const getProvider = async (blockchain)=>{ const setProvider = (blockchain, provider)=>{ if(supported.evm.includes(blockchain)) { + + /*#if _EVM + + return EVM.setProvider(blockchain, provider) + + /*#elif _SOLANA + + //#else */ + return EVM.setProvider(blockchain, provider) + + //#endif + } else if(supported.solana.includes(blockchain)) { + + /*#if _EVM + return Solana.setProvider(blockchain, provider) + + /*#elif _SOLANA + + //#else */ + + return Solana.setProvider(blockchain, provider) + + //#endif + } else { throw 'Unknown blockchain: ' + blockchain } @@ -28,9 +88,33 @@ const setProvider = (blockchain, provider)=>{ const setProviderEndpoints = (blockchain, endpoints)=>{ if(supported.evm.includes(blockchain)) { + + /*#if _EVM + return EVM.setProviderEndpoints(blockchain, endpoints) + + /*#elif _SOLANA + + //#else */ + + return EVM.setProviderEndpoints(blockchain, endpoints) + + //#endif + } else if(supported.solana.includes(blockchain)) { + + /*#if _EVM + return Solana.setProviderEndpoints(blockchain, endpoints) + + /*#elif _SOLANA + + //#else */ + + return Solana.setProviderEndpoints(blockchain, endpoints) + + //#endif + } else { throw 'Unknown blockchain: ' + blockchain } diff --git a/src/request.evm.js b/src/request.evm.js deleted file mode 100644 index f53795a..0000000 --- a/src/request.evm.js +++ /dev/null @@ -1,23 +0,0 @@ -import parseUrl from './parseUrl' -import requestEVM from './platforms/evm/request' -import { cache as cacheRequest } from './cache' -import { supported } from './blockchains.evm' - -let request = async function (url, options) { - let { blockchain, address, method } = parseUrl(url) - let { api, params, cache, block } = (typeof(url) == 'object' ? url : options) || {} - - return await cacheRequest({ - expires: cache || 0, - key: [blockchain, address, method, params, block], - call: async()=>{ - if(supported.evm.includes(blockchain)) { - return requestEVM({ blockchain, address, api, method, params, block }) - } else { - throw 'Unknown blockchain: ' + blockchain - } - } - }) -} - -export default request diff --git a/src/request.js b/src/request.js index 5f3f6dc..f2524c1 100644 --- a/src/request.js +++ b/src/request.js @@ -1,6 +1,19 @@ -import parseUrl from './parseUrl' +/*#if _EVM + +import requestEVM from './platforms/evm/request' + +/*#elif _SOLANA + +import requestSolana from './platforms/solana/request' + +//#else */ + import requestEVM from './platforms/evm/request' import requestSolana from './platforms/solana/request' + +//#endif + +import parseUrl from './parseUrl' import { cache as cacheRequest } from './cache' import { supported } from './blockchains' @@ -13,9 +26,33 @@ let request = async function (url, options) { key: [blockchain, address, method, params, block], call: async()=>{ if(supported.evm.includes(blockchain)) { + + /*#if _EVM + return requestEVM({ blockchain, address, api, method, params, block }) + + /*#elif _SOLANA + + //#else */ + + return requestEVM({ blockchain, address, api, method, params, block }) + + //#endif + } else if(supported.solana.includes(blockchain)) { + + /*#if _EVM + + /*#elif _SOLANA + + return requestSolana({ blockchain, address, api, method, params, block }) + + //#else */ + return requestSolana({ blockchain, address, api, method, params, block }) + + //#endif + } else { throw 'Unknown blockchain: ' + blockchain } diff --git a/tests/units/platforms/evm/balance.evm.spec.js b/tests/units/platforms/evm/balance.evm.spec.js index 147b27a..a7e40eb 100644 --- a/tests/units/platforms/evm/balance.evm.spec.js +++ b/tests/units/platforms/evm/balance.evm.spec.js @@ -1,7 +1,7 @@ import { ethers } from 'ethers' import { mock, resetMocks } from '@depay/web3-mock' -import { request, getProvider, resetCache } from 'src/index.evm' -import { supported } from 'src/blockchains.evm' +import { request, getProvider, resetCache } from 'dist/esm/index.evm' +import { supported } from 'src/blockchains' describe('balance (evm)', ()=>{ diff --git a/tests/units/platforms/evm/blocks.evm.spec.js b/tests/units/platforms/evm/blocks.evm.spec.js index f834c88..15a6acf 100644 --- a/tests/units/platforms/evm/blocks.evm.spec.js +++ b/tests/units/platforms/evm/blocks.evm.spec.js @@ -1,6 +1,6 @@ import { mock, resetMocks, increaseBlock } from '@depay/web3-mock' -import { request, getProvider, resetCache } from 'src/index.evm' -import { supported } from 'src/blockchains.evm' +import { request, getProvider, resetCache } from 'dist/esm/index.evm' +import { supported } from 'src/blockchains' describe('blocks (evm)', ()=>{ diff --git a/tests/units/platforms/evm/cache.evm.spec.js b/tests/units/platforms/evm/cache.evm.spec.js index 2559cff..3ece127 100644 --- a/tests/units/platforms/evm/cache.evm.spec.js +++ b/tests/units/platforms/evm/cache.evm.spec.js @@ -1,7 +1,7 @@ import { ethers } from 'ethers' import { mock, resetMocks } from '@depay/web3-mock' -import { request, resetCache, getProvider } from 'src/index.evm' -import { supported } from 'src/blockchains.evm' +import { request, resetCache, getProvider } from 'dist/esm/index.evm' +import { supported } from 'src/blockchains' describe('cache (evm)', ()=>{ diff --git a/tests/units/platforms/evm/estimate.evm.spec.js b/tests/units/platforms/evm/estimate.evm.spec.js index c1f4bf7..03efabf 100644 --- a/tests/units/platforms/evm/estimate.evm.spec.js +++ b/tests/units/platforms/evm/estimate.evm.spec.js @@ -1,6 +1,6 @@ -import { estimate, getProvider, resetCache } from 'src/index.evm' +import { estimate, getProvider, resetCache } from 'dist/esm/index.evm' import { mock, resetMocks } from '@depay/web3-mock' -import { supported } from 'src/blockchains.evm' +import { supported } from 'src/blockchains' describe('estimate (evm)', () => { diff --git a/tests/units/platforms/evm/provider.evm.spec.js b/tests/units/platforms/evm/provider.evm.spec.js index fa5c231..865a11a 100644 --- a/tests/units/platforms/evm/provider.evm.spec.js +++ b/tests/units/platforms/evm/provider.evm.spec.js @@ -1,7 +1,7 @@ import { ethers } from 'ethers' import { mock, resetMocks } from '@depay/web3-mock' -import { getProvider, setProvider, setProviderEndpoints, resetCache } from 'src/index.evm' -import { supported } from 'src/blockchains.evm' +import { getProvider, setProvider, setProviderEndpoints, resetCache } from 'dist/esm/index.evm' +import { supported } from 'src/blockchains' describe('provider (evm)', () => { diff --git a/tests/units/platforms/evm/request/contract.evm.spec.js b/tests/units/platforms/evm/request/contract.evm.spec.js index 4b880fe..46c0ea8 100644 --- a/tests/units/platforms/evm/request/contract.evm.spec.js +++ b/tests/units/platforms/evm/request/contract.evm.spec.js @@ -1,7 +1,7 @@ import { ethers } from 'ethers' import { mock, resetMocks, connect } from '@depay/web3-mock' -import { request, getProvider, resetCache } from 'src/index.evm' -import { supported } from 'src/blockchains.evm' +import { request, getProvider, resetCache } from 'dist/esm/index.evm' +import { supported } from 'src/blockchains' describe('request contract data (evm)', () => { diff --git a/tests/units/platforms/evm/request/forSpecificBlock.evm.spec.js b/tests/units/platforms/evm/request/forSpecificBlock.evm.spec.js index 1703aad..caa0753 100644 --- a/tests/units/platforms/evm/request/forSpecificBlock.evm.spec.js +++ b/tests/units/platforms/evm/request/forSpecificBlock.evm.spec.js @@ -1,7 +1,7 @@ import { ethers } from 'ethers' import { mock, resetMocks, connect } from '@depay/web3-mock' -import { request, getProvider, resetCache } from 'src/index.evm' -import { supported } from 'src/blockchains.evm' +import { request, getProvider, resetCache } from 'dist/esm/index.evm' +import { supported } from 'src/blockchains' describe('request data for specific block (evm)', () => { diff --git a/tests/units/platforms/evm/transactionCount.evm.spec.js b/tests/units/platforms/evm/transactionCount.evm.spec.js index eee3adc..8bb387b 100644 --- a/tests/units/platforms/evm/transactionCount.evm.spec.js +++ b/tests/units/platforms/evm/transactionCount.evm.spec.js @@ -1,7 +1,7 @@ import { ethers } from 'ethers' import { mock, resetMocks } from '@depay/web3-mock' -import { request, getProvider, resetCache } from 'src/index.evm' -import { supported } from 'src/blockchains.evm' +import { request, getProvider, resetCache } from 'dist/esm/index.evm' +import { supported } from 'src/blockchains' describe('transactionCount', ()=>{ diff --git a/yarn.lock b/yarn.lock index d64e96a..45dc902 100644 --- a/yarn.lock +++ b/yarn.lock @@ -911,10 +911,10 @@ resolved "https://registry.yarnpkg.com/@depay/web3-constants/-/web3-constants-6.4.0.tgz#58aae0c953ed5ebad3731ae8b791ba1f9e18585b" integrity sha512-asBMISqtjLZwyJlhppNZ/q46Fga2PzxRtjYNgcSkpSN6Qf0YJ3wpDt3nVPQel5ggRbleCNQOsrBI5Jzsu7xGYg== -"@depay/web3-mock@^13.23.0": - version "13.23.0" - resolved "https://registry.yarnpkg.com/@depay/web3-mock/-/web3-mock-13.23.0.tgz#d62516de33e26bd560b84fa08cf1e935b2da9e93" - integrity sha512-amkS/w403i8LE5/7EZdimqFJmR3wfSDZy+jjI+RM02Myvcg7v8v87w7b8K4J88bHWKVjc8kjs3SImwNtaQG19w== +"@depay/web3-mock@^13.24.0": + version "13.24.0" + resolved "https://registry.yarnpkg.com/@depay/web3-mock/-/web3-mock-13.24.0.tgz#64abd9d474ce4312495ba31d8afe74c22ab2ca6f" + integrity sha512-oiSWLUVoVodMYi9LYFr/nreD3X+XAhdMc16rJp8JiD0SSyq2NFoR65w0K0PQkb3oCcGNyA1uihJru9PgINjNpg== dependencies: "@depay/solana-web3.js" "^1.19.0" "@depay/web3-blockchains" "^6.5.1" @@ -1374,6 +1374,16 @@ "@jridgewell/resolve-uri" "^3.0.3" "@jridgewell/sourcemap-codec" "^1.4.10" +"@jsbits/escape-regex-str@^1.0.2": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@jsbits/escape-regex-str/-/escape-regex-str-1.0.3.tgz#d35a2d21dfdc81a0e5ebeb68b6a16e17ca36ad20" + integrity sha512-0800vYI2fg1nuUq/T9Tqv8DMOLLNiRAltxFbKIbR7szrvW6qTuI2+zGK51hV7NAAmUr4G83Kvpj2R6Yyg07iIw== + +"@jsbits/get-package-version@^1.0.2", "@jsbits/get-package-version@^1.0.3": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@jsbits/get-package-version/-/get-package-version-1.0.3.tgz#a47dfd077420beee435580c3bc197931fe3c694c" + integrity sha512-IJy1jRL01x7p6UEpgKa1lVLstMUx8EiIR8pPoS5sBfsHEoeLkzYiNpAfxPx8zLDUJyS1yBbChJjcWdPqyH285w== + "@nodelib/fs.scandir@2.1.5": version "2.1.5" resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" @@ -3084,6 +3094,11 @@ estraverse@^5.1.0, estraverse@^5.2.0: resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.2.0.tgz#307df42547e6cc7324d3cf03c155d5cdb8c53880" integrity sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ== +estree-walker@^0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-0.6.1.tgz#53049143f40c6eb918b23671d1fe3219f3a1b362" + integrity sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w== + estree-walker@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-1.0.1.tgz#31bc5d612c96b704106b477e6dd5d8aa138cb700" @@ -3726,6 +3741,17 @@ js-yaml@^3.13.1: argparse "^1.0.7" esprima "^4.0.0" +jscc@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/jscc/-/jscc-1.1.1.tgz#fb329325773a80bcf3e3db3acec6a3f21e61ed0e" + integrity sha512-anpZkTXwZbxfxLEBMciKxXMHx2xOLK2qhynIhTnoSyC+wGOEPrAoofxnADgblbarn0kijVMt1U71cQGmRF/1Og== + dependencies: + "@jsbits/escape-regex-str" "^1.0.2" + "@jsbits/get-package-version" "^1.0.2" + magic-string "^0.25.1" + perf-regexes "^1.0.1" + skip-regex "^1.0.2" + jsdom@^19.0.0: version "19.0.0" resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-19.0.0.tgz#93e67c149fe26816d38a849ea30ac93677e16b6a" @@ -3938,6 +3964,13 @@ lru-cache@^6.0.0: dependencies: yallist "^4.0.0" +magic-string@^0.25.1: + version "0.25.9" + resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.9.tgz#de7f9faf91ef8a1c91d02c2e5314c8277dbcdd1c" + integrity sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ== + dependencies: + sourcemap-codec "^1.4.8" + magic-string@^0.25.7: version "0.25.7" resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.7.tgz#3f497d6fd34c669c6798dcb821f2ef31f5445051" @@ -4260,6 +4293,11 @@ path-type@^4.0.0: resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b" integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw== +perf-regexes@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/perf-regexes/-/perf-regexes-1.0.1.tgz#6da1d62f5a94bf9353a0451bccacf69068b75d0b" + integrity sha512-L7MXxUDtqr4PUaLFCDCXBfGV/6KLIuSEccizDI7JxT+c9x1G1v04BQ4+4oag84SHaCdrBgQAIs/Cqn+flwFPng== + picocolors@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c" @@ -4509,6 +4547,15 @@ rollup-plugin-delete@^2.0.0: dependencies: del "^5.1.0" +rollup-plugin-jscc@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/rollup-plugin-jscc/-/rollup-plugin-jscc-2.0.0.tgz#1ad2f74ab3248dcaaa5ebff0b838418e22243ce6" + integrity sha512-5jG9q79K2u5uRBTKA+GA4gqt1zA7qHQRpcabZMoVs913gr75s428O7K3r58n2vADDzwIhiOKMo7rCMhOyks6dw== + dependencies: + "@jsbits/get-package-version" "^1.0.3" + jscc "^1.1.1" + rollup-pluginutils "^2.8.2" + rollup-plugin-livereload@^2.0.5: version "2.0.5" resolved "https://registry.yarnpkg.com/rollup-plugin-livereload/-/rollup-plugin-livereload-2.0.5.tgz#4747fa292a2cceb0c972c573d71b3d66b4252b37" @@ -4524,6 +4571,13 @@ rollup-plugin-serve@^2.0.0: mime ">=2.4.6" opener "1" +rollup-pluginutils@^2.8.2: + version "2.8.2" + resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz#72f2af0748b592364dbd3389e600e5a9444a351e" + integrity sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ== + dependencies: + estree-walker "^0.6.1" + rollup@^2.76.0: version "2.76.0" resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.76.0.tgz#c69fe03db530ac53fcb9523b3caa0d3c0b9491a1" @@ -4633,6 +4687,11 @@ side-channel@^1.0.4: get-intrinsic "^1.0.2" object-inspect "^1.9.0" +skip-regex@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/skip-regex/-/skip-regex-1.0.2.tgz#ac655d77e7c771ac2b9f37585fea37bff56ad65b" + integrity sha512-pEjMUbwJ5Pl/6Vn6FsamXHXItJXSRftcibixDmNCWbWhic0hzHrwkMZo0IZ7fMRH9KxcWDFSkzhccB4285PutA== + slash@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" @@ -4665,7 +4724,7 @@ source-map@^0.6.0, source-map@~0.6.1: resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== -sourcemap-codec@^1.4.4: +sourcemap-codec@^1.4.4, sourcemap-codec@^1.4.8: version "1.4.8" resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz#ea804bd94857402e6992d05a38ef1ae35a9ab4c4" integrity sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==