Skip to content

Commit

Permalink
fix: ignore json content for current build (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelcr committed Jul 9, 2023
1 parent 8a3f8ad commit 909f79f
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 93 deletions.
32 changes: 16 additions & 16 deletions src/pg/pg-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -686,22 +686,22 @@ export class PgStore extends BasePgStore {
location_id: locationRes[0].id,
block_height: args.location.block_height,
});
const json = inscriptionContentToJson(args.inscription);
if (json) {
const values = {
inscription_id,
p: json.p,
op: json.op,
content: json,
};
await sql`
INSERT INTO json_contents ${sql(values)}
ON CONFLICT ON CONSTRAINT json_contents_inscription_id_unique DO UPDATE SET
p = EXCLUDED.p,
op = EXCLUDED.op,
content = EXCLUDED.content
`;
}
// const json = inscriptionContentToJson(args.inscription);
// if (json) {
// const values = {
// inscription_id,
// p: json.p,
// op: json.op,
// content: json,
// };
// await sql`
// INSERT INTO json_contents ${sql(values)}
// ON CONFLICT ON CONSTRAINT json_contents_inscription_id_unique DO UPDATE SET
// p = EXCLUDED.p,
// op = EXCLUDED.op,
// content = EXCLUDED.content
// `;
// }
});
return inscription_id;
}
Expand Down
154 changes: 77 additions & 77 deletions tests/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,84 +391,84 @@ describe('EventServer', () => {
expect(c2[0].count).toBe(1);
});

test('saves p/op json content', async () => {
const reveal = {
block_identifier: {
index: 107,
hash: '0x163de66dc9c0949905bfe8e148bde04600223cf88d19f26fdbeba1d6e6fa0f88',
},
parent_block_identifier: {
index: 106,
hash: '0x117374e7078440835a744b6b1b13dd2c48c4eff8c58dde07162241a8f15d1e03',
},
timestamp: 1677803510,
transactions: [
{
transaction_identifier: {
hash: '0x0268dd9743c862d80ab02cb1d0228036cfe172522850eb96be60cfee14b31fb8',
},
operations: [],
metadata: {
ordinal_operations: [
{
inscription_revealed: {
// { "p": "sns", "op": "reg", "name": "treysongz.sats" }
content_bytes:
'0x7b202270223a2022736e73222c20226f70223a2022726567222c20226e616d65223a202274726579736f6e677a2e7361747322207d',
content_type: 'text/plain;charset=utf-8',
content_length: 12,
inscription_number: 100,
inscription_fee: 3425,
inscription_id:
'0268dd9743c862d80ab02cb1d0228036cfe172522850eb96be60cfee14b31fb8i0',
inscriber_address:
'bc1p3cyx5e2hgh53w7kpxcvm8s4kkega9gv5wfw7c4qxsvxl0u8x834qf0u2td',
ordinal_number: 125348773618236,
ordinal_block_height: 566462,
ordinal_offset: 0,
satpoint_post_inscription:
'0268dd9743c862d80ab02cb1d0228036cfe172522850eb96be60cfee14b31fb8:0:0',
inscription_output_value: 10000,
},
},
],
proof: '0x12341234',
},
},
],
metadata: {},
};
// test('saves p/op json content', async () => {
// const reveal = {
// block_identifier: {
// index: 107,
// hash: '0x163de66dc9c0949905bfe8e148bde04600223cf88d19f26fdbeba1d6e6fa0f88',
// },
// parent_block_identifier: {
// index: 106,
// hash: '0x117374e7078440835a744b6b1b13dd2c48c4eff8c58dde07162241a8f15d1e03',
// },
// timestamp: 1677803510,
// transactions: [
// {
// transaction_identifier: {
// hash: '0x0268dd9743c862d80ab02cb1d0228036cfe172522850eb96be60cfee14b31fb8',
// },
// operations: [],
// metadata: {
// ordinal_operations: [
// {
// inscription_revealed: {
// // { "p": "sns", "op": "reg", "name": "treysongz.sats" }
// content_bytes:
// '0x7b202270223a2022736e73222c20226f70223a2022726567222c20226e616d65223a202274726579736f6e677a2e7361747322207d',
// content_type: 'text/plain;charset=utf-8',
// content_length: 12,
// inscription_number: 100,
// inscription_fee: 3425,
// inscription_id:
// '0268dd9743c862d80ab02cb1d0228036cfe172522850eb96be60cfee14b31fb8i0',
// inscriber_address:
// 'bc1p3cyx5e2hgh53w7kpxcvm8s4kkega9gv5wfw7c4qxsvxl0u8x834qf0u2td',
// ordinal_number: 125348773618236,
// ordinal_block_height: 566462,
// ordinal_offset: 0,
// satpoint_post_inscription:
// '0268dd9743c862d80ab02cb1d0228036cfe172522850eb96be60cfee14b31fb8:0:0',
// inscription_output_value: 10000,
// },
// },
// ],
// proof: '0x12341234',
// },
// },
// ],
// metadata: {},
// };

// Apply
const payload1: ChainhookPayload = {
apply: [reveal],
rollback: [],
chainhook: {
uuid: '1',
predicate: {
scope: 'ordinals_protocol',
operation: 'inscription_feed',
},
is_streaming_blocks: true,
},
};
const response = await fastify.inject({
method: 'POST',
url: '/chainhook/inscription_feed',
headers: { authorization: `Bearer ${ENV.CHAINHOOK_NODE_AUTH_TOKEN}` },
payload: payload1,
});
expect(response.statusCode).toBe(200);
// // Apply
// const payload1: ChainhookPayload = {
// apply: [reveal],
// rollback: [],
// chainhook: {
// uuid: '1',
// predicate: {
// scope: 'ordinals_protocol',
// operation: 'inscription_feed',
// },
// is_streaming_blocks: true,
// },
// };
// const response = await fastify.inject({
// method: 'POST',
// url: '/chainhook/inscription_feed',
// headers: { authorization: `Bearer ${ENV.CHAINHOOK_NODE_AUTH_TOKEN}` },
// payload: payload1,
// });
// expect(response.statusCode).toBe(200);

const json = await db.getJsonContent({ number: 100 });
expect(json).not.toBeUndefined();
expect(json?.p).toBe('sns');
expect(json?.op).toBe('reg');
expect(json?.content).toStrictEqual({
name: 'treysongz.sats',
op: 'reg',
p: 'sns',
});
});
// const json = await db.getJsonContent({ number: 100 });
// expect(json).not.toBeUndefined();
// expect(json?.p).toBe('sns');
// expect(json?.op).toBe('reg');
// expect(json?.content).toStrictEqual({
// name: 'treysongz.sats',
// op: 'reg',
// p: 'sns',
// });
// });
});
});

0 comments on commit 909f79f

Please sign in to comment.