Requests with simulate
or dryRun
fail when I provide a wallet instance without ETH on balance.
Error: not enough coins to fit the target: {"response":{"data":null,"errors":[{"message":"not enough coins to fit the target","locations":[{"line":2,"column":3}],"path":["coinsToSpend"]}],"status":200,"headers":{"map":{"content-type":"application/json"}}},"request":{"query":"query getCoinsToSpend($owner: Address!, $queryPerAsset: [SpendQueryElementInput!]!, $excludedIds: ExcludeInput) {\n coinsToSpend(\n owner: $owner\n queryPerAsset: $queryPerAsset\n excludedIds: $excludedIds\n ) {\n ...coinFragment\n ...messageCoinFragment\n }\n}\n\nfragment coinFragment on Coin {\n __typename\n utxoId\n owner\n amount\n assetId\n maturity\n blockCreated\n txCreatedIdx\n}\n\nfragment messageCoinFragment on MessageCoin {\n __typename\n sender\n recipient\n nonce\n amount\n assetId\n daHeight\n}","variables":{"owner":"0x689a861c0f215ebad8a51b1e0332b3967f47a8ae1e698805811683339673d137","queryPerAsset":[{"assetId":"0x0000000000000000000000000000000000000000000000000000000000000000","amount":"1"}],"excludedIds":{"messages":[],"utxos":[]}}}}
at makeRequest (index.ts:441:1)
at async Provider.getResourcesToSpend (provider.ts:632:1)
at async FunctionInvocationScope.fundWithRequiredCoins (base-invocation-scope.ts:227:1)
at async FunctionInvocationScope.prepareTransaction (base-invocation-scope.ts:183:1)
at async FunctionInvocationScope.getTransactionRequest (base-invocation-scope.ts:269:1)
at async FunctionInvocationScope.simulate (base-invocation-scope.ts:313:1)
at async Promise.all (:3000/index 6)
at async PricesStore.updateTokenPrices (PricesStore.ts:54:1)
Here is code that I use
let provider = new Provider(NODE_URL);
const wallet = Wallet.generate({ provider });
const oracleContract = OracleAbi__factory.connect(priceOracle, wallet);
const response = await Promise.all(
TOKENS_LIST.map((token) =>
oracleContract.functions.get_price(token.assetId).simulate()
)
);