pineappleworkshop / ntc-services

0 stars 0 forks source link

Build GET /addresses/:addr/inscriptions endpoint to return wallet inscriptions #3

Open hathbanger opened 1 year ago

hathbanger commented 1 year ago

Updates

This will more than likely take the form of: GET?address/:id/inscriptions?page={int}&limit={int}


info

build out endpoint to return wallet inscriptions.

down to change the route path here as well.

current request / response below

request:

curl --location 'http://localhost:3000/api/inscriptions?walletAddress=bc1p5pvvfjtnhl32llttswchrtyd9mdzd3p7yps98tlydh2dm6zj6gqsfkmcnd'

response:

[
    {
        "inscription_name": "Bitcoin Monke #1519",
        "inscription_id": "65d9a42e48b97e9a77d200bd10b944c0d6f37651bf00a981e352382c0d4cdf76i0",
        "inscription_number": 309914,
        "metadata": {
            "name": "Bitcoin Monke #1519"
        },
        "owner_wallet_addr": "bc1p5pvvfjtnhl32llttswchrtyd9mdzd3p7yps98tlydh2dm6zj6gqsfkmcnd",
        "mime_type": "image/png",
        "last_sale_price": null,
        "slug": "bitcoin-monkes",
        "collection_name": "Bitcoin Monkes",
        "satpoint": "507d326907da044441e9d6928442e9594d3e451eb6693ede5def0ab6e42b70c2:3:0",
        "last_transfer_block_height": 799246,
        "content_url": "https://bis-ord-content.fra1.cdn.digitaloceanspaces.com/ordinals/65d9a42e48b97e9a77d200bd10b944c0d6f37651bf00a981e352382c0d4cdf76i0",
        "bis_url": "https://bestinslot.xyz/ordinals/inscription/65d9a42e48b97e9a77d200bd10b944c0d6f37651bf00a981e352382c0d4cdf76i0"
    },
    {
        "inscription_name": "4ll.unisat",
        "inscription_id": "4177f2896a9398de53c6a58272b7d37cdd08b9546ad933d8c6ed10e7ec26dfe0i0",
        "inscription_number": 10300088,
        "metadata": {
            "name": "4ll.unisat",
            "attributes": [
                {
                    "value": "3",
                    "trait_type": "Letters"
                }
            ]
        },
        "owner_wallet_addr": "bc1p5pvvfjtnhl32llttswchrtyd9mdzd3p7yps98tlydh2dm6zj6gqsfkmcnd",
        "mime_type": "text/plain;charset=utf-8",
        "last_sale_price": 50000,
        "slug": "unisat-names",
        "collection_name": "Unisat Names",
        "satpoint": "9c1cf515e73021bb2670af964fc21ea08684013933a71a91b99f7448ce43facf:2:0",
        "last_transfer_block_height": 799252,
        "content_url": "https://bis-ord-content.fra1.cdn.digitaloceanspaces.com/ordinals/4177f2896a9398de53c6a58272b7d37cdd08b9546ad933d8c6ed10e7ec26dfe0i0",
        "bis_url": "https://bestinslot.xyz/ordinals/inscription/4177f2896a9398de53c6a58272b7d37cdd08b9546ad933d8c6ed10e7ec26dfe0i0"
    },
    {
        "inscription_name": null,
        "inscription_id": "7f11104f64c99be928805b6eebb0e17c7746cddc523344c193ef7769908fb3dei0",
        "inscription_number": 12714250,
        "metadata": null,
        "owner_wallet_addr": "bc1p5pvvfjtnhl32llttswchrtyd9mdzd3p7yps98tlydh2dm6zj6gqsfkmcnd",
        "mime_type": "application/json",
        "last_sale_price": null,
        "slug": null,
        "collection_name": null,
        "satpoint": "507d326907da044441e9d6928442e9594d3e451eb6693ede5def0ab6e42b70c2:4:0",
        "last_transfer_block_height": 799246,
        "content_url": "https://bis-ord-content.fra1.cdn.digitaloceanspaces.com/ordinals/7f11104f64c99be928805b6eebb0e17c7746cddc523344c193ef7769908fb3dei0",
        "bis_url": "https://bestinslot.xyz/ordinals/inscription/7f11104f64c99be928805b6eebb0e17c7746cddc523344c193ef7769908fb3dei0"
    },
...    
]

here's the current endpoint (in js)

https://github.com/pineappleworkshop/nakamoto-trading-co/blob/dev/apps/nakamoto/app/api/inscriptions/route.ts#L1-L28

and here's the supporting function: https://github.com/pineappleworkshop/nakamoto-trading-co/blob/dev/apps/nakamoto/lib/inscriptions.ts#L9-L21C3

berryhill commented 1 year ago

@hathbanger I'm a little confused that we're using snake case here.. didn't you want to use camel?

hathbanger commented 1 year ago

@berryhill looks to be a bug somewhere in the parsing for this mega wallet:

req:

http://localhost:3000/api/inscriptions?walletAddress=bc1pydf2px4mq8q2w85t2854fmjugkcja20849jde70n34l6k5thr08qqhx8v8

logs:

{"time":"2023-07-25T08:45:40.980197+02:00","id":"","remote_ip":"::1","host":"localhost:3444","method":"GET","uri":"/addresses/bc1pydf2px4mq8q2w85t2854fmjugkcja20849jde70n34l6k5thr08qqhx8v8/inscriptions?page=1&limit=100","user_agent":"axios/1.4.0","status":500,"error":"","latency":234537334,"latency_human":"234.537334ms","bytes_in":0,"bytes_out":13}
{"time":"2023-07-25T08:46:01.349826+02:00","level":"ERROR","prefix":"echo","file":"best_in_slot.go","line":"88","message":"invalid character 'T' looking for beginning of value"}
{"time":"2023-07-25T08:46:01.349868+02:00","level":"ERROR","prefix":"echo","file":"inscriptions.go","line":"26","message":"invalid character 'T' looking for beginning of value"}

here's the call to BIS for posterity:

curl --location 'https://api.bestinslot.xyz/v3/wallet/inscriptions?address=bc1pydf2px4mq8q2w85t2854fmjugkcja20849jde70n34l6k5thr08qqhx8v8&sort_by=inscr_num&order=asc&offset=0&count=100' \
--header 'x-api-key: xxx'
hathbanger commented 1 year ago

correction...

just started working.

hathbanger commented 1 year ago

update

tried running it again and it failed:

{"time":"2023-07-25T09:08:45.903422+02:00","id":"","remote_ip":"::1","host":"localhost:3444","method":"GET","uri":"/addresses/bc1pydf2px4mq8q2w85t2854fmjugkcja20849jde70n34l6k5thr08qqhx8v8/inscriptions?page=2&limit=100","user_agent":"axios/1.4.0","status":200,"error":"","latency":362969500,"latency_human":"362.9695ms","bytes_in":0,"bytes_out":102754}
{"time":"2023-07-25T09:08:46.176827+02:00","level":"ERROR","prefix":"echo","file":"best_in_slot.go","line":"88","message":"invalid character 'T' looking for beginning of value"}
{"time":"2023-07-25T09:08:46.176881+02:00","level":"ERROR","prefix":"echo","file":"inscriptions.go","line":"26","message":"invalid character 'T' looking for beginning of value"}
{"time":"2023-07-25T09:08:46.176923+02:00","id":"","remote_ip":"::1","host":"localhost:3444","method":"GET","uri":"/addresses/bc1pydf2px4mq8q2w85t2854fmjugkcja20849jde70n34l6k5thr08qqhx8v8/inscriptions?page=3&limit=100","user_agent":"axios/1.4.0","status":500,"error":"","latency":262402666,"latency_human":"262.402666ms","bytes_in":0,"bytes_out":13}
{"time":"2023-07-25T09:08:47.682732+02:00","level":"ERROR","prefix":"echo","file":"best_in_slot.go","line":"88","message":"invalid character 'T' looking for beginning of value"}
{"time":"2023-07-25T09:08:47.682768+02:00","level":"ERROR","prefix":"echo","file":"inscriptions.go","line":"26","message":"invalid character 'T' looking for beginning of value"}
{"time":"2023-07-25T09:08:47.682796+02:00","id":"","remote_ip":"::1","host":"localhost:3444","method":"GET","uri":"/addresses/bc1pydf2px4mq8q2w85t2854fmjugkcja20849jde70n34l6k5thr08qqhx8v8/inscriptions?page=1&limit=100","user_agent":"axios/1.4.0","status":500,"error":"","latency":270989125,"latency_human":"270.989125ms","bytes_in":0,"bytes_out":13}

ok just ran it AGAIN and it worked:

{"time":"2023-07-25T09:09:50.759425+02:00","id":"","remote_ip":"::1","host":"localhost:3444","method":"GET","uri":"/addresses/bc1pydf2px4mq8q2w85t2854fmjugkcja20849jde70n34l6k5thr08qqhx8v8/inscriptions?page=1&limit=100","user_agent":"axios/1.4.0","status":200,"error":"","latency":1193706292,"latency_human":"1.193706292s","bytes_in":0,"bytes_out":79140}
{"time":"2023-07-25T09:09:51.154536+02:00","id":"","remote_ip":"::1","host":"localhost:3444","method":"GET","uri":"/addresses/bc1pydf2px4mq8q2w85t2854fmjugkcja20849jde70n34l6k5thr08qqhx8v8/inscriptions?page=2&limit=100","user_agent":"axios/1.4.0","status":200,"error":"","latency":387311667,"latency_human":"387.311667ms","bytes_in":0,"bytes_out":102754}
{"time":"2023-07-25T09:09:51.477123+02:00","id":"","remote_ip":"::1","host":"localhost:3444","method":"GET","uri":"/addresses/bc1pydf2px4mq8q2w85t2854fmjugkcja20849jde70n34l6k5thr08qqhx8v8/inscriptions?page=3&limit=100","user_agent":"axios/1.4.0","status":200,"error":"","latency":316677334,"latency_human":"316.677334ms","bytes_in":0,"bytes_out":79364}
{"time":"2023-07-25T09:09:51.772998+02:00","id":"","remote_ip":"::1","host":"localhost:3444","method":"GET","uri":"/addresses/bc1pydf2px4mq8q2w85t2854fmjugkcja20849jde70n34l6k5thr08qqhx8v8/inscriptions?page=4&limit=100","user_agent":"axios/1.4.0","status":200,"error":"","latency":277585667,"latency_human":"277.585667ms","bytes_in":0,"bytes_out":73526}
{"time":"2023-07-25T09:09:52.083134+02:00","id":"","remote_ip":"::1","host":"localhost:3444","method":"GET","uri":"/addresses/bc1pydf2px4mq8q2w85t2854fmjugkcja20849jde70n34l6k5thr08qqhx8v8/inscriptions?page=5&limit=100","user_agent":"axios/1.4.0","status":200,"error":"","latency":300856208,"latency_human":"300.856208ms","bytes_in":0,"bytes_out":72998}
{"time":"2023-07-25T09:09:52.380219+02:00","id":"","remote_ip":"::1","host":"localhost:3444","method":"GET","uri":"/addresses/bc1pydf2px4mq8q2w85t2854fmjugkcja20849jde70n34l6k5thr08qqhx8v8/inscriptions?page=6&limit=100","user_agent":"axios/1.4.0","status":200,"error":"","latency":278742375,"latency_human":"278.742375ms","bytes_in":0,"bytes_out":72919}
{"time":"2023-07-25T09:09:52.678983+02:00","id":"","remote_ip":"::1","host":"localhost:3444","method":"GET","uri":"/addresses/bc1pydf2px4mq8q2w85t2854fmjugkcja20849jde70n34l6k5thr08qqhx8v8/inscriptions?page=7&limit=100","user_agent":"axios/1.4.0","status":200,"error":"","latency":292944917,"latency_human":"292.944917ms","bytes_in":0,"bytes_out":74625}
{"time":"2023-07-25T09:09:52.93343+02:00","id":"","remote_ip":"::1","host":"localhost:3444","method":"GET","uri":"/addresses/bc1pydf2px4mq8q2w85t2854fmjugkcja20849jde70n34l6k5thr08qqhx8v8/inscriptions?page=8&limit=100","user_agent":"axios/1.4.0","status":200,"error":"","latency":251156167,"latency_human":"251.156167ms","bytes_in":0,"bytes_out":30054}
berryhill commented 1 year ago

PR: https://github.com/pineappleworkshop/ntc-services/pull/29

zuwuko commented 1 year ago

Tested successfully

$ curl --location http://localhost:3444/addresses/bc1p5pvvfjtnhl32llttswchrtyd9mdzd3p7yps98tlydh2dm6zj6gqsfkmcnd/inscriptions

Screenshot from 2023-07-26 15-58-08