You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a Cloudflare Worker setup as an API with Hono.js, code is here
I wanted to use callReadOnlyFunction() to fetch some contract data and verify something before returning a resource, but ran into an error: "The 'referrerPolicy' field on 'RequestInitializerDict' is not implemented." (full error below)
[wrangler:inf] GET /bitcoin-face 500 Internal Server Error (16ms)
✘ [ERROR] Error: The 'referrerPolicy' field on 'RequestInitializerDict' is not implemented.
at checkURL
(file:///home/whoabuddy/Dev/stacks-m2m/gated-api/.wrangler/tmp/bundle-yFShja/checked-fetch.js:9:9)
at Object.apply
(file:///home/whoabuddy/Dev/stacks-m2m/gated-api/.wrangler/tmp/bundle-yFShja/checked-fetch.js:27:3)
at fetchWrapper
(file:///home/whoabuddy/Dev/stacks-m2m/gated-api/node_modules/@stacks/network/src/fetch.ts:47:29)
at StacksMainnet.fetchFn
(file:///home/whoabuddy/Dev/stacks-m2m/gated-api/node_modules/@stacks/network/src/fetch.ts:160:26)
at callReadOnlyFunction
(file:///home/whoabuddy/Dev/stacks-m2m/gated-api/node_modules/@stacks/transactions/src/builders.ts:1438:34)
at getRecentPaymentData (file:///home/whoabuddy/Dev/stacks-m2m/gated-api/src/index.ts:46:28)
at Array.<anonymous> (file:///home/whoabuddy/Dev/stacks-m2m/gated-api/src/index.ts:32:28)
at Hono2.dispatch
(file:///home/whoabuddy/Dev/stacks-m2m/gated-api/node_modules/hono/dist/hono-base.js:228:37)
at Object.fetch
(file:///home/whoabuddy/Dev/stacks-m2m/gated-api/node_modules/hono/dist/hono-base.js:68:19)
at __facade_modules_fetch__
(file:///home/whoabuddy/Dev/stacks-m2m/gated-api/.wrangler/tmp/bundle-yFShja/middleware-loader.entry.ts:45:16)
The quick fix was to switch to micro-stacks and use fetchReadOnlyFunction(), but I wanted to report it anyway in case others have run into it.
How to reproduce
This was the original code that caused an error, if more details are needed to reproduce I can push an example.
Setup new project with wrangler
Setup dependencies
Run code below
import{Hono}from'hono';import{serveStatic}from'hono/cloudflare-workers';import{Cl,callReadOnlyFunction,cvToValue}from'@stacks/transactions';constapp=newHono();exportinterfaceEnv{}app.get('/',(c)=>{returnc.text('Welcome to the Gated API example using machine-payable transactions on Stacks.');});app.get('/favicon.ico',serveStatic({path: 'favicon.ico'}));app.get('/bitcoin-face',async(c)=>{// check resource is registered / payment data existsconstpaymentData=awaitgetRecentPaymentData();if(!paymentData.status){// if not, return invoicereturnc.text(`Please pay first: ${paymentData}`);}// if so, return resourcereturnc.text('Bitcoin Face');});asyncfunctiongetRecentPaymentData(){// testing with hardcoded address at firstconstaddress='ST2TY3WNDVY1ZSXCPCFYK9KDJJC2TFWYVWNBXNHD4';constpaymentData=awaitcallReadOnlyFunction({contractName: 'stacks-m2m-v1',contractAddress: 'ST17EAYFJ9JDJAQ7RGSE6CTGH90MQH68B3FPR7EKP',functionName: 'get-recent-payment-data-by-address',functionArgs: [Cl.stringUtf8('Bitcoin Face'),Cl.principal(address)],network: 'testnet',senderAddress: address,});console.log(JSON.stringify(paymentData));if(paymentData===Cl.none()){return{status: false,statusText: `No payment data found for ${address}.`,data: null,};}return{status: true,statusText: `Payment data found for ${address}.`,data: cvToValue(paymentData),};}exportdefaultapp;
Expected behavior
I expected the fetch call to succeed and return data.
Additional context
None, please let me know if more info is needed!
The text was updated successfully, but these errors were encountered:
I bet that'll work and will give it a test - have to finish up a few things first but will report back. That's awesome it's an option I didn't think it'd be so simple to fix!
What version of Stacks.js are you using?
latest, fresh install from npm
Describe the bug
I have a Cloudflare Worker setup as an API with Hono.js, code is here
I wanted to use
callReadOnlyFunction()
to fetch some contract data and verify something before returning a resource, but ran into an error: "The 'referrerPolicy' field on 'RequestInitializerDict' is not implemented." (full error below)The quick fix was to switch to micro-stacks and use
fetchReadOnlyFunction()
, but I wanted to report it anyway in case others have run into it.How to reproduce
This was the original code that caused an error, if more details are needed to reproduce I can push an example.
Expected behavior
I expected the fetch call to succeed and return data.
Additional context
None, please let me know if more info is needed!
The text was updated successfully, but these errors were encountered: