sway
January 19, 2023, 2:41pm
1
I have token that has mint functionality, and when I call mint function I keep getting this error
mint = async (assetId?: string) => {
if (assetId == null || this.alreadyMintedTokens.includes(assetId)) return;
this._setLoading(true);
const { accountStore, notificationStore } = this.rootStore;
const { address } = accountStore;
if (address == null || window?.fuel == null) return;
const wallet = Wallet.fromAddress(address, window.fuel?.getProvider());
console.log(assetId);
const tokenContract = TokenAbi__factory.connect(assetId, wallet);
try {
const v = await tokenContract.functions
.mint()
.txParams({ gasPrice: 1 })
.call();
console.log(v);
this.setAlreadyMintedTokens([...this.alreadyMintedTokens, assetId]);
await this.rootStore.accountStore.updateAccountBalances();
} catch (e) {
console.log(e);
notificationStore.notify(
`You have already minted ${TOKENS_BY_ASSET_ID[assetId].symbol}`,
{ type: "error" }
);
} finally {
this._setLoading(false);
}
};
this is the error
TypeError: this.provider.getResourcesToSpend is not a function
at P.getResourcesToSpend (base-locked-wallet.ts:81:1)
at S.fundWithRequiredCoins (base-invocation-scope.ts:165:1)
at S.prepareTransaction (base-invocation-scope.ts:114:1)
at S.getTransactionRequest (base-invocation-scope.ts:199:1)
at S.call (base-invocation-scope.ts:213:1)
at FaucetVM.mint (FaucetVm.tsx:128:1)
at executeAction (action.ts:68:1)
at FaucetVM@11.mint (action.ts:49:1)
at onClick (TokensFaucetTable.tsx:92:1)
at HTMLUnknownElement.callCallback (react-dom.development.js:4164:1
It used to work fine before, I have updated fuels and fuels-wallet packages to 0.29.1 version and
2 Likes
sarah
January 19, 2023, 4:47pm
3
Can you share the repo and branch to reproduce this?
1 Like
sway
January 19, 2023, 8:52pm
4
sure,
here is link to func declaration
...balance,
formatBalance,
price,
balanceDollar,
mintAmount,
mintAmountDollar,
};
});
}
mint = async (assetId?: string) => {
if (assetId == null || this.alreadyMintedTokens.includes(assetId)) return;
this._setLoading(true);
const { accountStore, notificationStore } = this.rootStore;
const { address } = accountStore;
if (address == null || window?.fuel == null) return;
//todo add signing from account store
const wallet = Wallet.fromAddress(address, window.fuel?.getProvider());
const tokenContract = TokenAbi__factory.connect(assetId, wallet);
try {
1 Like
sarah
January 20, 2023, 3:26pm
6
Do the other functions work and this is the only one where you get this error?
sway
January 20, 2023, 3:39pm
7
every call or simulate function fails with this error
1 Like
sarah
January 20, 2023, 4:23pm
8
Can you try deleting node_modules
and try re-installing? It seems to be working on our end.
sway
January 20, 2023, 7:05pm
9
I did this yesterday before crated topic and now also did it now to be sure all is same. It still keeps giving error
TypeError: this.provider.getResourcesToSpend is not a function
at P.getResourcesToSpend (base-locked-wallet.ts:81:1)
at S.fundWithRequiredCoins (base-invocation-scope.ts:165:1)
at S.prepareTransaction (base-invocation-scope.ts:114:1)
at S.getTransactionRequest (base-invocation-scope.ts:199:1)
at S.call (base-invocation-scope.ts:213:1)
at FaucetVM.mint (FaucetVm.tsx:124:1)
at executeAction (action.ts:68:1)
at FaucetVM@13.mint (action.ts:49:1)
at onClick (TokensFaucetTable.tsx:92:1)
at HTMLUnknownElement.callCallback (react-dom.development.js:4164:1)
sway
January 20, 2023, 7:22pm
10
I have found another of creating token contract instance and changed it to this one, but error is still same
import token_abi from "./token_abi.json"
mint = async (assetId?: string) => {
if (assetId == null || this.alreadyMintedTokens.includes(assetId)) return;
this._setLoading(true);
const { accountStore, notificationStore } = this.rootStore;
const { address } = accountStore;
if (address == null || window?.fuel == null) return;
const wallet = Wallet.fromAddress(address, window.fuel?.getProvider());
const tokenContract = new Contract(assetId, token_abi, wallet);
try {
//i have changed here !
const { transactionId, value } = await tokenContract.functions
.mint()
.txParams({ gasPrice: 1 })
.call();
console.log(value, transactionId);
this.setAlreadyMintedTokens([...this.alreadyMintedTokens, assetId]);
} catch (e) {
console.log(e);
} finally {
this._setLoading(false);
}
};
Here is list of token addresses that I want to mint
{
"name": "Bitcoin",
"symbol": "BTC",
"decimals": 8,
"assetId": "0xdd17dda6eeee55f6d327020e6d61b9fa7b3c2ab205c46cdca690a46966f4e1c7"
},
{
"name": "USDC",
"symbol": "USDC",
"decimals": 6,
"assetId": "0xd7d5e5c1220872e6f42b38f85ae80c6072b1b4723e7a7218bbf6717aca962536"
},
{
"name": "Uniswap",
"symbol": "UNI",
"decimals": 9,
"assetId": "0x76c4fda9074c4509eaf2652f82bace86e2c7a21bf9faff7bf6228034ebc0f8a2"
},
{
"name": "Chainlink",
"symbol": "LINK",
"decimals": 9,
"assetId": "0x71be783354a9bccfa9de0e7edf291797775e4a730d0922a9675258dbb47f557b"
},
{
"name": "Sway",
"symbol": "SWAY",
"decimals": 9,
"assetId": "0x99075448d291a8f8f69e5f3d25a309c38ad38def9f709a69ae4a2aeaed1701fe"
}
rpc link I use this - https://node-beta-2.fuel.network/graphql
sway
January 20, 2023, 7:29pm
11
also funny note!
every time when I mint tokes for just created address my Fuel wallet extension is breaking down and showing only black screen
@stacio please have a look, might be something wrong with token standard
link to token standard -
GitHub - sway-gang/fuel-token-standard: Fuel network Fungible token standard
stacio
January 25, 2023, 3:20pm
12
We have updated our API to get the provider, and it now returns a promise. it would require you to change the code;
from;
const wallet = Wallet.fromAddress(address, window.fuel?.getProvider());
to;
const provider = await window.fuel?.getProvider();
const wallet = Wallet.fromAddress(address, provider);
// or better now
const wallet = await window.fuel?.getWallet(address);
4 Likes
sway
January 30, 2023, 5:14pm
13
thanks fo help! it worked, but I have faced another problem with this error
Error: Window closed by inactivity after 5 minutes!
But my window was opened only for 10 seconds
1 Like
stacio
January 30, 2023, 5:28pm
14
Do you have an example for testing this? I think the issue is related to the custom token as mint will return a token we don’t have on the assets list.
sway
January 30, 2023, 10:58pm
15
I don’t have deployed version of code that I am trying to create yet, but I have tested with account that doesn’t have any other tokens except testEth, and yes, problem is exactly in this
sway
January 30, 2023, 11:11pm
16
Looking forward for this feature implementation
opened 12:26AM - 24 Jan 23 UTC
feature
The nature of the UTXO enables the wallet to list all assets from a given accoun… t, but now the Wallet only lists the known assets from a hardcoded list, making it impossible to see other assets.
To improve this, we should create a way for adding custom assets metadata;
Where;
- Users add custom tokens to the wallet, making their UTXOs with unknown assets ids been shown on the Wallet, the metadata required is;
- Name
- Symbol
- Image
- Asset Id
- DApp developer to request adding assets to the user's Wallet.
Is there any estimation when it will be done?)
stacio
February 1, 2023, 1:33pm
17
@sway This is one of our priorities. We should have it in a couple of days.
2 Likes
sway
February 6, 2023, 10:36am
18
Hello @stacio
I have noticed that team has updated @fuel-wallet /sdk package to 0.5.1 version and tried to run same code above with changed api way, so it look like this now
const wallet = window.fuel?.getWallet(this.address);
const marketContract = MarketAbi__factory.connect(
CONTRACT_ADDRESSES.market,
wallet
);
const tx = await market.functions
.supply_base()
.callParams({
forward: {
amount: this.tokenAmount.toString(),
assetId: this.baseToken.assetId,
},
})
.txParams({ gasPrice: 1 })
.call();
but it still fails with same “5 minutes not interaction” error
system
Closed
February 27, 2023, 6:36am
19
This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.