fireblocks / fireblocks-web3-provider Goto Github PK
View Code? Open in Web Editor NEWFireblocks EIP-1193 Compatible Ethereum JavaScript Provider
License: MIT License
Fireblocks EIP-1193 Compatible Ethereum JavaScript Provider
License: MIT License
Hey team,
I was recently trying to use the provider with Web3js v1.9.0 but it keeps giving an error- Provider does not have a request or send method to use
.
While it works perfectly with Web3js v4, wanted to understand if it is possible to use the provider with v1.9.0 as well.
Dependencies
node version: v16.20.0
npm version: 8.19.4
web3: ^1.9.0
@fireblocks/fireblocks-web3-provider: ^1.2.3
Hey team fireblocks,
Our team recently integrated the gasless
branch within our project and ran into some issues when resolving the @fireblocks-web3-provider
dependency in our project. Running npm i
for our project, causes build errors when trying to resolve your package. I understand there is a demo that comes with instructions, however following the instructions in an isolated environment still produces the below error.
package.json
node version v16.20.0
npm version 8.19.4
typescript version 4.0.0
"@fireblocks/fireblocks-web3-provider": "github:fireblocks/fireblocks-web3-provider#gasless",
as a dependency in projects package.json
The workaround for this was to npm uninstall @types/mocha
in the node_modules
of the web3-provider, via the package.json
of the root project, while also following the demo instructions like so - having a postinstall command run:
"postinstall": "(cd node_modules/@fireblocks/fireblocks-web3-provider && npm install && npm uninstall @types/mocha && npm run build && cp -rf src/abi dist/)",
Any way to resolve this without having to uninstall dependencies of this package?
It depends on tslib
for runtime, which throws an error for projects that import @fireblocks/fireblocks-web3-provider
and don't use tslib
.
Removing the dependency will require replacing the imported type and two functions:
import {
RequestArguments,
formatJsonRpcRequest,
formatJsonRpcResult,
} from "@json-rpc-tools/utils";
Hi there, I'm trying to use FireblocksWeb3Provider
and create error handling logic around transaction sending.
Apparently, if FireblocksWeb3Provider
is used - then try catch
section does not work as expected.
Code snipped below is a slightly modified version of example in ethereum development official documentation.
import {
FireblocksWeb3Provider,
ChainId,
} from "@fireblocks/fireblocks-web3-provider";
import * as ethers from "ethers";
// A Human-Readable ABI; for interacting with the contract, we
// must include any fragment we wish to use
const abi = [
"function transferFrom(address from, address to, uint256 tokenId)",
];
// NFT Contract Address
const CONTRACT_ADDRESS = process.env.NFT_CONTRACT_ADDRESS;
const eip1193Provider = new FireblocksWeb3Provider({
// apiBaseUrl: ApiBaseUrl.Sandbox, // If using a sandbox workspace
privateKey: process.env.FIREBLOCKS_API_PRIVATE_KEY,
apiKey: process.env.FIREBLOCKS_API_KEY,
vaultAccountIds: process.env.FIREBLOCKS_VAULT_ACCOUNT_IDS,
chainId: ChainId.MAINNET,
});
async function main() {
const provider = new ethers.providers.Web3Provider(eip1193Provider);
const signerAddress = process.env.FIREBLOCKS_VAULT_ADDRESS;
const signer = provider.getSigner(signerAddress);
const myContract = new ethers.Contract(CONTRACT_ADDRESS, abi, signer);
const from = signerAddress;
const to = "0x0000000000000000000000000000000000000000"; // random address
// Invoke `transferFrom` method
const tokenId = 2;
let txnHash = "";
try {
txnHash = await myContract.transferFrom(from, to, tokenId);
} catch (error) {
console.log("error catch");
}
console.log("normal code execution");
}
main().catch((error) => {
console.log(error);
});
I expect that error catch
and the following normal code execution
messages are printed in console. Instead I get the following:
$ dotenv -- node --no-warnings src/main.js
/home/eduard/fireblocks-nft-transfer/node_modules/@fireblocks/fireblocks-web3-provider/dist/src/provider.js:166
throw this.createError({ message: `No ${this.assetId} asset wallet found for vault account with id ${vaultAccountId}` });
^
Error: No ETH asset wallet found for vault account with id 123456
at FireblocksWeb3Provider.populateAccounts (/home/eduard/fireblocks-nft-transfer/node_modules/@fireblocks/fireblocks-web3-provider/dist/src/provider.js:166:28)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: -32603,
data: undefined,
payload: undefined
}
Node.js v18.12.0
There's a misconfiguration, but the try catch
section should still work!
I suspect this there's a floating promise somewhere in library code. Probably in FireblocksWeb3Provider
constructor.
@fireblocks/fireblocks-web3-provider
1.2.2
ethers
: 5.7.2
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.