Skip to content

Commit

Permalink
add i/o addresses to cardano mint and burn (#333)
Browse files Browse the repository at this point in the history
* add input and output address to cardano mint burn

* use tmp-carp-client dep

* add columns to paima-tables

* bump carp-client

---------

Co-authored-by: Sebastien Guillemot <[email protected]>
  • Loading branch information
ecioppettini and SebastienGllmt authored Mar 30, 2024
1 parent 85d83fa commit 940a857
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 32 deletions.
28 changes: 6 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/batcher/address-validator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"pg": "^8.11.3",
"web3": "1.10.0",
"assert-never": "^1.2.1",
"@dcspark/carp-client": "^3.0.1"
"@dcspark/carp-client": "^3.1.0"
},
"devDependencies": {
"@types/pg": "^8.10.9"
Expand Down
2 changes: 1 addition & 1 deletion packages/engine/paima-funnel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"dependencies": {
"assert-never": "^1.2.1",
"@dcspark/carp-client": "^3.0.1",
"@dcspark/carp-client": "^3.1.0",
"@dcspark/cardano-multiplatform-lib-nodejs": "5.2.0"
}
}
2 changes: 2 additions & 0 deletions packages/engine/paima-funnel/src/cde/cardanoMintBurn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ function eventToCdeDatum(
txId: event.txId,
metadata: event.metadata,
assets: event.assets,
inputAddresses: event.inputAddresses,
outputAddresses: event.outputAddresses,
},
scheduledPrefix: extension.scheduledPrefix,
paginationCursor: { cursor: JSON.stringify(cursor), finished: false },
Expand Down
3 changes: 2 additions & 1 deletion packages/engine/paima-sm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"author": "Paima Studios",
"dependencies": {
"@sinclair/typebox": "^0.31.28",
"assert-never": "^1.2.1"
"assert-never": "^1.2.1",
"@dcspark/carp-client": "^3.1.0"
}
}
6 changes: 5 additions & 1 deletion packages/engine/paima-sm/src/cde-cardano-mint-burn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ export default async function processDatum(
const txId = cdeDatum.payload.txId;
const assets = JSON.stringify(cdeDatum.payload.assets);
const metadata = cdeDatum.payload.metadata || undefined;
const inputAddresses = cdeDatum.payload.inputAddresses;
const outputAddresses = cdeDatum.payload.outputAddresses;

const scheduledBlockHeight = Math.max(cdeDatum.blockNumber, ENV.SM_START_BLOCKHEIGHT + 1);
const scheduledInputData = `${prefix}|${txId}|${metadata}|${assets}`;
const scheduledInputData = `${prefix}|${txId}|${metadata}|${assets}|${JSON.stringify(inputAddresses)}|${JSON.stringify(outputAddresses)}`;

const updateList: SQLUpdate[] = [
createScheduledData(scheduledInputData, scheduledBlockHeight),
Expand All @@ -24,6 +26,8 @@ export default async function processDatum(
tx_id: txId,
metadata: metadata,
assets: cdeDatum.payload.assets,
input_addresses: inputAddresses,
output_addresses: outputAddresses,
},
],
];
Expand Down
2 changes: 2 additions & 0 deletions packages/engine/paima-sm/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ interface CdeDatumCardanoMintBurnPayload {
txId: string;
metadata: string | null;
assets: { [policyId: string]: { [assetName: string]: string } };
inputAddresses: { [address: string]: { policyId: string; assetName: string; amount: string }[] };
outputAddresses: { [address: string]: { policyId: string; assetName: string; amount: string }[] };
}

type ChainDataExtensionPayload =
Expand Down
4 changes: 3 additions & 1 deletion packages/node-sdk/paima-db/migrations/up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -214,5 +214,7 @@ CREATE TABLE cde_cardano_mint_burn(
tx_id TEXT NOT NULL,
metadata TEXT NOT NULL,
assets JSONB NOT NULL,
inputAddresses JSONB NOT NULL,
outputAddresses JSONB NOT NULL,
PRIMARY KEY (cde_id, tx_id)
);
);
4 changes: 4 additions & 0 deletions packages/node-sdk/paima-db/src/paima-tables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,8 @@ CREATE TABLE cde_cardano_mint_burn(
tx_id TEXT NOT NULL,
metadata TEXT NOT NULL,
assets JSONB NOT NULL,
inputAddresses JSONB NOT NULL,
outputAddresses JSONB NOT NULL,
PRIMARY KEY (cde_id, tx_id)
)
`;
Expand All @@ -443,6 +445,8 @@ const TABLE_DATA_CDE_CARDANO_MINT_BURN: TableData = {
['tx_id', 'text', 'NO', ''],
['metadata', 'text', 'NO', ''],
['assets', 'jsonb', 'NO', ''],
['inputAddresses', 'jsonb', 'NO', ''],
['outputAddresses', 'jsonb', 'NO', ''],
]),
serialColumns: [],
creationQuery: QUERY_CREATE_TABLE_CDE_CARDANO_MINT_BURN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ export type Json = null | boolean | number | string | Json[] | { [key: string]:
export interface ICdeCardanoMintBurnInsertParams {
assets: Json;
cde_id: number;
input_addresses: Json;
metadata: string;
output_addresses: Json;
tx_id: string;
}

Expand All @@ -20,7 +22,7 @@ export interface ICdeCardanoMintBurnInsertQuery {
result: ICdeCardanoMintBurnInsertResult;
}

const cdeCardanoMintBurnInsertIR: any = {"usedParamSet":{"cde_id":true,"tx_id":true,"metadata":true,"assets":true},"params":[{"name":"cde_id","required":true,"transform":{"type":"scalar"},"locs":[{"a":89,"b":96}]},{"name":"tx_id","required":true,"transform":{"type":"scalar"},"locs":[{"a":101,"b":107}]},{"name":"metadata","required":true,"transform":{"type":"scalar"},"locs":[{"a":112,"b":121}]},{"name":"assets","required":true,"transform":{"type":"scalar"},"locs":[{"a":126,"b":133}]}],"statement":"INSERT INTO cde_cardano_mint_burn (\n cde_id,\n tx_id,\n metadata,\n assets\n) VALUES (\n :cde_id!,\n :tx_id!,\n :metadata!,\n :assets!\n)"};
const cdeCardanoMintBurnInsertIR: any = {"usedParamSet":{"cde_id":true,"tx_id":true,"metadata":true,"assets":true,"input_addresses":true,"output_addresses":true},"params":[{"name":"cde_id","required":true,"transform":{"type":"scalar"},"locs":[{"a":126,"b":133}]},{"name":"tx_id","required":true,"transform":{"type":"scalar"},"locs":[{"a":138,"b":144}]},{"name":"metadata","required":true,"transform":{"type":"scalar"},"locs":[{"a":149,"b":158}]},{"name":"assets","required":true,"transform":{"type":"scalar"},"locs":[{"a":163,"b":170}]},{"name":"input_addresses","required":true,"transform":{"type":"scalar"},"locs":[{"a":175,"b":191}]},{"name":"output_addresses","required":true,"transform":{"type":"scalar"},"locs":[{"a":196,"b":213}]}],"statement":"INSERT INTO cde_cardano_mint_burn (\n cde_id,\n tx_id,\n metadata,\n assets,\n inputAddresses,\n outputAddresses\n) VALUES (\n :cde_id!,\n :tx_id!,\n :metadata!,\n :assets!,\n :input_addresses!,\n :output_addresses!\n)"};

/**
* Query generated from SQL:
Expand All @@ -29,12 +31,16 @@ const cdeCardanoMintBurnInsertIR: any = {"usedParamSet":{"cde_id":true,"tx_id":t
* cde_id,
* tx_id,
* metadata,
* assets
* assets,
* inputAddresses,
* outputAddresses
* ) VALUES (
* :cde_id!,
* :tx_id!,
* :metadata!,
* :assets!
* :assets!,
* :input_addresses!,
* :output_addresses!
* )
* ```
*/
Expand Down
8 changes: 6 additions & 2 deletions packages/node-sdk/paima-db/src/sql/cde-cardano-mint-burn.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ INSERT INTO cde_cardano_mint_burn (
cde_id,
tx_id,
metadata,
assets
assets,
inputAddresses,
outputAddresses
) VALUES (
:cde_id!,
:tx_id!,
:metadata!,
:assets!
:assets!,
:input_addresses!,
:output_addresses!
);

0 comments on commit 940a857

Please sign in to comment.