-
Notifications
You must be signed in to change notification settings - Fork 2
feat: add type_hash to rgbpp assets routes #184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,5 +91,6 @@ export const XUDTBalance = z.object({ | |
available_amount: z.string(), | ||
pending_amount: z.string(), | ||
type_hash: z.string(), | ||
type_script: Script, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another case issue is the Script is in camelCase where this type is in snake_case: https://github.com/ckb-cell/btc-assets-api/blob/f686bc1ab05719fc9942ecd01f1c1e645138cf9d/src/routes/rgbpp/types.ts#L3-L7 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
}); | ||
export type XUDTBalance = z.infer<typeof XUDTBalance>; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`Get RGB++ assets by BTC txid 1`] = ` | ||
[ | ||
{ | ||
"blockNumber": "0xc6067f", | ||
"cellOutput": { | ||
"capacity": "0x5e9f52520", | ||
"lock": { | ||
"args": "0x010000001770f9dc84b1e05d507bcdd46884b5e267c731071c0d2f01cb257c76049e15ca", | ||
"codeHash": "0x61ca7a4796a4eb19ca4f0d065cb9b10ddcf002f10f7cbb810c706cb6bb5c3248", | ||
"hashType": "type", | ||
}, | ||
"type": { | ||
"args": "0x7e96affc517fe2b286e309e88d6b331911fc319baa3f8a830dcf59a9756f2c25", | ||
"codeHash": "0x25c29dc317811a6f6f3985a7a9ebc4838bd388d19d0feeecf0bcd60f6c0975bb", | ||
"hashType": "type", | ||
}, | ||
}, | ||
"data": "0x0040075af07507000000000000000000", | ||
"outPoint": { | ||
"index": "0x0", | ||
"txHash": "0xb799ae6896875f2a1a1e765d614cf864c444242babc4bfd7808b37fdea66c4cc", | ||
}, | ||
"txIndex": "0x2", | ||
"typeHash": "0x27b36bd74aec3ffccb1c1351c3e3db64cba33ee1b5651059fe468fbcbb8c81bd", | ||
}, | ||
] | ||
`; | ||
|
||
exports[`Get RGB++ assets by BTC txid and vout 1`] = ` | ||
[ | ||
{ | ||
"blockNumber": "0xc6067f", | ||
"cellOutput": { | ||
"capacity": "0x5e9f52520", | ||
"lock": { | ||
"args": "0x010000001770f9dc84b1e05d507bcdd46884b5e267c731071c0d2f01cb257c76049e15ca", | ||
"codeHash": "0x61ca7a4796a4eb19ca4f0d065cb9b10ddcf002f10f7cbb810c706cb6bb5c3248", | ||
"hashType": "type", | ||
}, | ||
"type": { | ||
"args": "0x7e96affc517fe2b286e309e88d6b331911fc319baa3f8a830dcf59a9756f2c25", | ||
"codeHash": "0x25c29dc317811a6f6f3985a7a9ebc4838bd388d19d0feeecf0bcd60f6c0975bb", | ||
"hashType": "type", | ||
}, | ||
}, | ||
"data": "0x0040075af07507000000000000000000", | ||
"outPoint": { | ||
"index": "0x0", | ||
"txHash": "0xb799ae6896875f2a1a1e765d614cf864c444242babc4bfd7808b37fdea66c4cc", | ||
}, | ||
"txIndex": "0x2", | ||
"typeHash": "0x27b36bd74aec3ffccb1c1351c3e3db64cba33ee1b5651059fe468fbcbb8c81bd", | ||
}, | ||
] | ||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { beforeEach, expect, test } from 'vitest'; | ||
import { buildFastify } from '../../../src/app'; | ||
import { describe } from 'node:test'; | ||
|
||
let token: string; | ||
|
||
describe('/rgbpp/v1/assets', () => { | ||
beforeEach(async () => { | ||
const fastify = buildFastify(); | ||
await fastify.ready(); | ||
|
||
const response = await fastify.inject({ | ||
method: 'POST', | ||
url: '/token/generate', | ||
payload: { | ||
app: 'test', | ||
domain: 'test.com', | ||
}, | ||
}); | ||
const data = response.json(); | ||
token = data.token; | ||
|
||
await fastify.close(); | ||
}); | ||
|
||
test('Get RGB++ assets by BTC txid', async () => { | ||
const fastify = buildFastify(); | ||
await fastify.ready(); | ||
|
||
const response = await fastify.inject({ | ||
method: 'GET', | ||
url: '/rgbpp/v1/assets/ca159e04767c25cb012f0d1c0731c767e2b58468d4cd7b505de0b184dcf97017', | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
Origin: 'https://test.com', | ||
}, | ||
}); | ||
const data = response.json(); | ||
|
||
expect(response.statusCode).toBe(200); | ||
expect(data).toMatchSnapshot(); | ||
|
||
await fastify.close(); | ||
}); | ||
|
||
test('Get RGB++ assets by BTC txid and vout', async () => { | ||
const fastify = buildFastify(); | ||
await fastify.ready(); | ||
|
||
const response = await fastify.inject({ | ||
method: 'GET', | ||
url: '/rgbpp/v1/assets/ca159e04767c25cb012f0d1c0731c767e2b58468d4cd7b505de0b184dcf97017/1', | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
Origin: 'https://test.com', | ||
}, | ||
}); | ||
const data = response.json(); | ||
|
||
expect(response.statusCode).toBe(200); | ||
expect(data).toMatchSnapshot(); | ||
|
||
await fastify.close(); | ||
}); | ||
}); |
Uh oh!
There was an error while loading. Please reload this page.