diff --git a/README.md b/README.md index d480b30..38277ba 100644 --- a/README.md +++ b/README.md @@ -133,6 +133,20 @@ stores. } ``` +## Create contract stores + +The function `makeContractStore` allows you to create a Svelte derived +store of a `web3.eth.Contract` object instance. It takes the same +parameters as a ̀new web3.eth.Contract` call: + +```js +makeContractStore(jsonInterface[, address][, options]) +``` + +This store is conveniently and automatically updated after connection +and when the account or chain change. + + ## Simultaneous multi chain usage You can also using the library to create several stores, each diff --git a/package-lock.json b/package-lock.json index ab40e68..ff60ce5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,12 +11,12 @@ "@babel/core": "^7.14.3", "@rollup/plugin-json": "^4.1.0", "eslint-plugin-svelte3": "^3.2.0", - "release-it": "^14.6.2", - "rollup": "^2.49.0", + "release-it": "^14.8.0", + "rollup": "^2.51.0", "rollup-plugin-babel": "^4.4.0", "rollup-plugin-livereload": "^2.0.0", "rollup-plugin-svelte": "^7.1.0", - "sirv-cli": "^1.0.11", + "sirv-cli": "^1.0.12", "svelte": "^3.38.2", "web3": "1.3.6" } @@ -882,9 +882,9 @@ } }, "node_modules/@polka/url": { - "version": "1.0.0-next.11", - "resolved": "https://registry.npmjs.org/@polka/url/-/url-1.0.0-next.11.tgz", - "integrity": "sha512-3NsZsJIA/22P3QUyrEDNA2D133H4j224twJrdipXN38dpnIOzAbUDtOwkcJ5pXmn75w7LSQDjA4tO9dm1XlqlA==", + "version": "1.0.0-next.15", + "resolved": "https://registry.npmjs.org/@polka/url/-/url-1.0.0-next.15.tgz", + "integrity": "sha512-15spi3V28QdevleWBNXE4pIls3nFZmBbUGrW9IVPwiQczuSb9n76TCB4bsk8TSel+I1OkHEdPhu5QKMfY6rQHA==", "dev": true }, "node_modules/@rollup/plugin-json": { @@ -4180,19 +4180,20 @@ } }, "node_modules/inquirer": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-8.0.0.tgz", - "integrity": "sha512-ON8pEJPPCdyjxj+cxsYRe6XfCJepTxANdNnTebsTuQgXpRyZRRT9t4dJwjRubgmvn20CLSEnozRUayXyM9VTXA==", + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-8.1.0.tgz", + "integrity": "sha512-1nKYPoalt1vMBfCMtpomsUc32wmOoWXAoq3kM/5iTfxyQ2f/BxjixQpC+mbZ7BI0JUXHED4/XPXekDVtJNpXYw==", "dev": true, "dependencies": { "ansi-escapes": "^4.2.1", - "chalk": "^4.1.0", + "chalk": "^4.1.1", "cli-cursor": "^3.1.0", "cli-width": "^3.0.0", "external-editor": "^3.0.3", "figures": "^3.0.0", "lodash": "^4.17.21", "mute-stream": "0.0.8", + "ora": "^5.3.0", "run-async": "^2.4.0", "rxjs": "^6.6.6", "string-width": "^4.1.0", @@ -6270,9 +6271,9 @@ } }, "node_modules/release-it": { - "version": "14.6.2", - "resolved": "https://registry.npmjs.org/release-it/-/release-it-14.6.2.tgz", - "integrity": "sha512-rjRe2cC59ueTUGS2rkwI5JEeN0DQlU2eeq4nrCQcwQXv5IzC+9uPd7EvoUT7VDwJ4ZNu1Oh8DZVQqrtDzVboUg==", + "version": "14.8.0", + "resolved": "https://registry.npmjs.org/release-it/-/release-it-14.8.0.tgz", + "integrity": "sha512-XCw4kzJqdKgtis97HcNZ45r5dx+tZhcG1Yu2IEBKym1SceXiLBbycLsfqJQ8z+VLimClKpDeBdJkU03Vo/yFqw==", "dev": true, "dependencies": { "@iarna/toml": "2.2.5", @@ -6289,7 +6290,7 @@ "globby": "11.0.3", "got": "11.8.2", "import-cwd": "3.0.0", - "inquirer": "8.0.0", + "inquirer": "8.1.0", "is-ci": "3.0.0", "lodash": "4.17.21", "mime-types": "2.1.30", @@ -6750,9 +6751,9 @@ } }, "node_modules/rollup": { - "version": "2.49.0", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.49.0.tgz", - "integrity": "sha512-UnrCjMXICx9q0jF8L7OYs7LPk95dW0U5UYp/VANnWqfuhyr66FWi/YVlI34Oy8Tp4ZGLcaUDt4APJm80b9oPWQ==", + "version": "2.51.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.51.0.tgz", + "integrity": "sha512-ITLt9sScNCBVspSHauw/W49lEZ0vjN8LyCzSNsNaqT67vTss2lYEfOyxltX8hjrhr1l/rQwmZ2wazzEqhZ/fUg==", "dev": true, "bin": { "rollup": "dist/bin/rollup" @@ -7135,12 +7136,12 @@ } }, "node_modules/sirv": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/sirv/-/sirv-1.0.11.tgz", - "integrity": "sha512-SR36i3/LSWja7AJNRBz4fF/Xjpn7lQFI30tZ434dIy+bitLYSP+ZEenHg36i23V2SGEz+kqjksg0uOGZ5LPiqg==", + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/sirv/-/sirv-1.0.12.tgz", + "integrity": "sha512-+jQoCxndz7L2tqQL4ZyzfDhky0W/4ZJip3XoOuxyQWnAwMxindLl3Xv1qT4x1YX/re0leShvTm8Uk0kQspGhBg==", "dev": true, "dependencies": { - "@polka/url": "^1.0.0-next.9", + "@polka/url": "^1.0.0-next.15", "mime": "^2.3.1", "totalist": "^1.0.0" }, @@ -7149,9 +7150,9 @@ } }, "node_modules/sirv-cli": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/sirv-cli/-/sirv-cli-1.0.11.tgz", - "integrity": "sha512-L8NILoRSBd38VcfFcERYCaVCnWPBLo9G6u/a37UJ8Ysv4DfjizMbFBcM+SswNnndJienhR6qy8KFuAEaeL4g8Q==", + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/sirv-cli/-/sirv-cli-1.0.12.tgz", + "integrity": "sha512-Rs5PvF3a48zuLmrl8vcqVv9xF/WWPES19QawVkpdzqx7vD5SMZS07+ece1gK4umbslXN43YeIksYtQM5csgIzQ==", "dev": true, "dependencies": { "console-clear": "^1.1.0", @@ -7160,7 +7161,7 @@ "local-access": "^1.0.1", "sade": "^1.6.0", "semiver": "^1.0.0", - "sirv": "^1.0.11", + "sirv": "^1.0.12", "tinydate": "^1.0.0" }, "bin": { @@ -8724,9 +8725,9 @@ } }, "node_modules/ws": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz", - "integrity": "sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA==", + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.2.tgz", + "integrity": "sha512-zmhltoSR8u1cnDsD43TX59mzoMZsLKqUweyYBAIvTngR3shc0W6aOZylZmq/7hqyVxPdi+5Ud2QInblgyE72fw==", "dev": true, "dependencies": { "async-limiter": "~1.0.0" @@ -9481,9 +9482,9 @@ } }, "@polka/url": { - "version": "1.0.0-next.11", - "resolved": "https://registry.npmjs.org/@polka/url/-/url-1.0.0-next.11.tgz", - "integrity": "sha512-3NsZsJIA/22P3QUyrEDNA2D133H4j224twJrdipXN38dpnIOzAbUDtOwkcJ5pXmn75w7LSQDjA4tO9dm1XlqlA==", + "version": "1.0.0-next.15", + "resolved": "https://registry.npmjs.org/@polka/url/-/url-1.0.0-next.15.tgz", + "integrity": "sha512-15spi3V28QdevleWBNXE4pIls3nFZmBbUGrW9IVPwiQczuSb9n76TCB4bsk8TSel+I1OkHEdPhu5QKMfY6rQHA==", "dev": true }, "@rollup/plugin-json": { @@ -12185,19 +12186,20 @@ "dev": true }, "inquirer": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-8.0.0.tgz", - "integrity": "sha512-ON8pEJPPCdyjxj+cxsYRe6XfCJepTxANdNnTebsTuQgXpRyZRRT9t4dJwjRubgmvn20CLSEnozRUayXyM9VTXA==", + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-8.1.0.tgz", + "integrity": "sha512-1nKYPoalt1vMBfCMtpomsUc32wmOoWXAoq3kM/5iTfxyQ2f/BxjixQpC+mbZ7BI0JUXHED4/XPXekDVtJNpXYw==", "dev": true, "requires": { "ansi-escapes": "^4.2.1", - "chalk": "^4.1.0", + "chalk": "^4.1.1", "cli-cursor": "^3.1.0", "cli-width": "^3.0.0", "external-editor": "^3.0.3", "figures": "^3.0.0", "lodash": "^4.17.21", "mute-stream": "0.0.8", + "ora": "^5.3.0", "run-async": "^2.4.0", "rxjs": "^6.6.6", "string-width": "^4.1.0", @@ -13781,9 +13783,9 @@ } }, "release-it": { - "version": "14.6.2", - "resolved": "https://registry.npmjs.org/release-it/-/release-it-14.6.2.tgz", - "integrity": "sha512-rjRe2cC59ueTUGS2rkwI5JEeN0DQlU2eeq4nrCQcwQXv5IzC+9uPd7EvoUT7VDwJ4ZNu1Oh8DZVQqrtDzVboUg==", + "version": "14.8.0", + "resolved": "https://registry.npmjs.org/release-it/-/release-it-14.8.0.tgz", + "integrity": "sha512-XCw4kzJqdKgtis97HcNZ45r5dx+tZhcG1Yu2IEBKym1SceXiLBbycLsfqJQ8z+VLimClKpDeBdJkU03Vo/yFqw==", "dev": true, "requires": { "@iarna/toml": "2.2.5", @@ -13800,7 +13802,7 @@ "globby": "11.0.3", "got": "11.8.2", "import-cwd": "3.0.0", - "inquirer": "8.0.0", + "inquirer": "8.1.0", "is-ci": "3.0.0", "lodash": "4.17.21", "mime-types": "2.1.30", @@ -14146,9 +14148,9 @@ } }, "rollup": { - "version": "2.49.0", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.49.0.tgz", - "integrity": "sha512-UnrCjMXICx9q0jF8L7OYs7LPk95dW0U5UYp/VANnWqfuhyr66FWi/YVlI34Oy8Tp4ZGLcaUDt4APJm80b9oPWQ==", + "version": "2.51.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.51.0.tgz", + "integrity": "sha512-ITLt9sScNCBVspSHauw/W49lEZ0vjN8LyCzSNsNaqT67vTss2lYEfOyxltX8hjrhr1l/rQwmZ2wazzEqhZ/fUg==", "dev": true, "requires": { "fsevents": "~2.3.1" @@ -14441,20 +14443,20 @@ } }, "sirv": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/sirv/-/sirv-1.0.11.tgz", - "integrity": "sha512-SR36i3/LSWja7AJNRBz4fF/Xjpn7lQFI30tZ434dIy+bitLYSP+ZEenHg36i23V2SGEz+kqjksg0uOGZ5LPiqg==", + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/sirv/-/sirv-1.0.12.tgz", + "integrity": "sha512-+jQoCxndz7L2tqQL4ZyzfDhky0W/4ZJip3XoOuxyQWnAwMxindLl3Xv1qT4x1YX/re0leShvTm8Uk0kQspGhBg==", "dev": true, "requires": { - "@polka/url": "^1.0.0-next.9", + "@polka/url": "^1.0.0-next.15", "mime": "^2.3.1", "totalist": "^1.0.0" } }, "sirv-cli": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/sirv-cli/-/sirv-cli-1.0.11.tgz", - "integrity": "sha512-L8NILoRSBd38VcfFcERYCaVCnWPBLo9G6u/a37UJ8Ysv4DfjizMbFBcM+SswNnndJienhR6qy8KFuAEaeL4g8Q==", + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/sirv-cli/-/sirv-cli-1.0.12.tgz", + "integrity": "sha512-Rs5PvF3a48zuLmrl8vcqVv9xF/WWPES19QawVkpdzqx7vD5SMZS07+ece1gK4umbslXN43YeIksYtQM5csgIzQ==", "dev": true, "requires": { "console-clear": "^1.1.0", @@ -14463,7 +14465,7 @@ "local-access": "^1.0.1", "sade": "^1.6.0", "semiver": "^1.0.0", - "sirv": "^1.0.11", + "sirv": "^1.0.12", "tinydate": "^1.0.0" } }, @@ -15724,9 +15726,9 @@ } }, "ws": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz", - "integrity": "sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA==", + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.2.tgz", + "integrity": "sha512-zmhltoSR8u1cnDsD43TX59mzoMZsLKqUweyYBAIvTngR3shc0W6aOZylZmq/7hqyVxPdi+5Ud2QInblgyE72fw==", "dev": true, "requires": { "async-limiter": "~1.0.0" diff --git a/package.json b/package.json index 760c80a..4cc6350 100644 --- a/package.json +++ b/package.json @@ -18,12 +18,12 @@ "@babel/core": "^7.14.3", "@rollup/plugin-json": "^4.1.0", "eslint-plugin-svelte3": "^3.2.0", - "release-it": "^14.6.2", - "rollup": "^2.49.0", + "release-it": "^14.8.0", + "rollup": "^2.51.0", "rollup-plugin-babel": "^4.4.0", "rollup-plugin-livereload": "^2.0.0", "rollup-plugin-svelte": "^7.1.0", - "sirv-cli": "^1.0.11", + "sirv-cli": "^1.0.12", "svelte": "^3.38.2", "web3": "1.3.6" }, diff --git a/src/chains.json b/src/chains.json index e0a7b19..ccee588 100644 --- a/src/chains.json +++ b/src/chains.json @@ -155,6 +155,19 @@ "explorers": [], "infoURL": "https://web3games.org/" }, + { + "name": "Sakura", + "chainId": 1022, + "shortName": "sku", + "chain": "Sakura", + "network": "sakura", + "networkId": 1022, + "nativeCurrency": {"name":"Sakura","symbol":"SKU","decimals":18}, + "rpc": [], + "faucets": [], + "explorers": [], + "infoURL": "https://clover.finance/sakura" + }, { "name": "Clover Testnet", "chainId": 1023, @@ -480,6 +493,19 @@ "explorers": [], "infoURL": "https://github.com/flare-eng/coston" }, + { + "name": "Catecoin Chain Mainnet", + "chainId": 1618, + "shortName": "cate", + "chain": "Catechain", + "network": "mainnet", + "networkId": 1618, + "nativeCurrency": {"name":"Catecoin","symbol":"CATE","decimals":18}, + "rpc": ["https://send.catechain.com"], + "faucets": [], + "explorers": [], + "infoURL": "https://catechain.com" + }, { "name": "Lightstreams Testnet", "chainId": 162, @@ -747,7 +773,7 @@ "chain": "QKI", "network": "mainnet", "networkId": 20181205, - "nativeCurrency": {"name":"quarkblockchain Native Token","symbol":"HT","decimals":18}, + "nativeCurrency": {"name":"quarkblockchain Native Token","symbol":"QKI","decimals":18}, "rpc": ["https://hz.rpc.qkiscan.cn","https://jp.rpc.qkiscan.io"], "faucets": [], "explorers": [], @@ -866,7 +892,7 @@ "networkId": 246, "nativeCurrency": {"name":"Energy Web Token","symbol":"EWT","decimals":18}, "rpc": ["https://rpc.energyweb.org","wss://rpc.energyweb.org/ws"], - "faucets": [], + "faucets": ["https://faucet.carbonswap.exchange"], "explorers": [], "infoURL": "https://energyweb.org" }, @@ -1390,6 +1416,19 @@ "explorers": [], "infoURL": "https://xinfin.org" }, + { + "name": "EraSwap Mainnet", + "chainId": 5197, + "shortName": "es", + "chain": "ESN", + "network": "mainnet", + "networkId": 5197, + "nativeCurrency": {"name":"EraSwap","symbol":"ES","decimals":18}, + "rpc": ["https://mainnet.eraswap.network","https://rpc-mumbai.mainnet.eraswap.network"], + "faucets": [], + "explorers": [], + "infoURL": "https://eraswap.info/" + }, { "name": "CoinEx Smart Chain Mainnet", "chainId": 52, @@ -1975,6 +2014,19 @@ "explorers": [], "infoURL": "https://ethersocial.org" }, + { + "name": "CryptoKylin Testnet", + "chainId": 95, + "shortName": "Kylin Testnet", + "chain": "EOS", + "network": "testnet", + "networkId": 95, + "nativeCurrency": {"name":"EOS","symbol":"EOS","decimals":18}, + "rpc": ["https://kylin.eosargentina.io"], + "faucets": [], + "explorers": [{"name":"eosq","url":"https://kylin.eosargentina.io","standard":"EIP3091"}], + "infoURL": "https://www.cryptokylin.io/" + }, { "name": "Binance Smart Chain Testnet", "chainId": 97, diff --git a/src/web3-store.js b/src/web3-store.js index 89965d4..94c5770 100644 --- a/src/web3-store.js +++ b/src/web3-store.js @@ -157,7 +157,7 @@ export const getChainStore = name => { return allStores[name] } -export const contractStore = (abi, address, defaults = {}) => derived( +export const makeContractStore = (abi, address, defaults = {}) => derived( [web3, connected], ([$web3, $connected]) => { if ($connected && $web3.eth) {