ava-labs / avalanche-wallet-sdk Goto Github PK
View Code? Open in Web Editor NEWA Typescript library to create and manage wallets on the Avalanche network.
License: BSD 3-Clause "New" or "Revised" License
A Typescript library to create and manage wallets on the Avalanche network.
License: BSD 3-Clause "New" or "Revised" License
Current dev version at least.
Wayt to reproduce bug:
`
... you will get "Insufficient Funds error"
How I fixed it
async exportX(amountAvax: string, destination:ExportChainsX): Promise<string> {
// const fee: BN = xChain.getDefaultTxFee();
const amount:BN = new BN(amountAvax);
// FIX make SingleWallet to update it's uxtos
const uxtos = await this.swallet.updateUtxosX()
console.log("destination fro X to ", destination2);//, uxtos);
return this.swallet.exportXChain(amount, destination2);
}
I think there should be way to refresh Wallet state after constructing it / I understand the need separate routines which makes network calls and which are not
Hi the following code was not properly clearing EventEmitter events causing MaxListenersExceededWarning.
wallet.ts line 150
public destroy() {
networkEvents.off('network_change', this.onNetworkChange);
}
I was able to resolve the waring using
networkEvents.removeAllListeners('network_change');
or
networkEvents.removeAllListeners();
I am not familiar with EventEmitter so I just wanted to mainly report the issue.
ReferenceError: fetch is not defined
Ive installed the fetch package and my IDE allows me to scope definition
also event listeners arent working aswell
Putting avalanche in devDependancies is not installing this lib with yarn and as a result, the app fails to build. The workaround will be to add avalanche to the app package. Was this intended?
Version 0.10.1 typescript in npm seems to still have importC without parameters
but the code has already importC(chained) version...
Wallet.d.ts ....
`/**
* Imports atomic X chain utxos to the current actie X chain address
* @param chainID The chain ID to import from, either `P` or `C`
*/
importX(chainID: AvmImportChainType): Promise<string>;
importP(toAddress?: string): Promise<string>;
importC(): Promise<string>;`
I would like to update the X-chain balance of a wallet so that I can access the wallet's balance of various ANT tokens. Since updateBalanceX() is private, the only way to do this seems to be calling updateUtxosX(). However, this function calls updateBalanceX() without awaiting its promise, so I'm not sure how I can tell when it has finished updating the X-chain balance. For my use case, I would prefer if the function did the following:
await this.updateUnknownAssetsX();
await this.updateBalanceX();
I understand that the function is probably written as it currently is because updateBalanceX() is a costly function. Maybe a solution could be to have a boolean parameter waitForBalance for the function updateBalanceX() with the following code:
if (waitForBalance) {
await this.updateBalanceX();
else {
this.updateBalanceX();
}
Apologies in advance if there is another solution to this issue that I'm missing.
When attempting to run a terminal based app using version 0.17.2, I get this error:
/@avalabs/avalanche-wallet-sdk/dist/index.js:1596
const response = yield fetch(input, Object.assign(Object.assign({}, options), { signal: controller.signal }));
^
ReferenceError: fetch is not defined
at HttpClient.<anonymous> (/@avalabs/avalanche-wallet-sdk/dist/index.js:1596:30)
at Generator.next (<anonymous>)
at /@avalabs/avalanche-wallet-sdk/dist/index.js:186:71
at new Promise (<anonymous>)
at __awaiter (/@avalabs/avalanche-wallet-sdk/dist/index.js:182:12)
at HttpClient.fetchWithTimeout (/@avalabs/avalanche-wallet-sdk/dist/index.js:1592:16)
at HttpClient.post (/@avalabs/avalanche-wallet-sdk/dist/index.js:1576:41)
at /@avalabs/avalanche-wallet-sdk/dist/index.js:5450:46
at Generator.next (<anonymous>)
at /@avalabs/avalanche-wallet-sdk/dist/index.js:186:71
at new Promise (<anonymous>)
at __awaiter (/@avalabs/avalanche-wallet-sdk/dist/index.js:182:12)
at getAddressChains (/@avalabs/avalanche-wallet-sdk/dist/index.js:5441:12)
at HdScanner.<anonymous> (/@avalabs/avalanche-wallet-sdk/dist/index.js:7347:36)
at Generator.next (<anonymous>)
at fulfilled (/@avalabs/avalanche-wallet-sdk/dist/index.js:183:58)
A working solution is to install the CJS module via:
npm install node-fetch@2
Then edit @avalabs/avalanche-wallet-sdk/dist/index.js
and add
const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
at the top of the file.
Perhaps node-fetch should be included in the node only version?
I am trying to use both "avalanche": "3.15.5"
and "@avalabs/avalanche-wallet-sdk": "0.18.4"
for my project.
However, when I try npm ci, it shows this error.
I checked the package.json of avalanche-wallet-sdk and it uses 3.15.2. Since the most recent version of "avalanche" is 3.15.5 I think it should be updated to 3.15.5 . Or, is there anything else I can do to solve this issue?
When doing importP etc... it throws Error, but it's merely normal situation not Error condition.
If you want to check that nothing is left accidentally not imported you cannot call Promise.all([multiple imports because it throws Error])
:"Nothing to import.","stack":"Error: Nothing to import.\n at SingletonWallet.<anon...
I am getting an error when I run yarn install. It says that package.json is not defined by "exports". The error I am getting is below, when I click the link it takes me to the package.json file.
[!] Error: Package subpath './package.json' is not defined by "exports" in /Users/eddyalvarado_1/Documents/GitHub/plasma-wallet-web3/js/avalanche-wallet-sdk/node_modules/rollup-plugin-typescript2/node_modules/tslib/package.json
Currently it's only possible to instantiate a MnemonicWallet
with a seed phrase. For users that have a bip39 passphrase associated with the mnemonic, the constructor should support an optional passphrase field.
BurnerWallet.on('balanceChangedC', (newBalance)=>{
console.log("done")
})
everything else is fine
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.