From 965c6248634aeafc77234588fa1347d0245aba8e Mon Sep 17 00:00:00 2001 From: Eugene Gostkin Date: Mon, 18 Dec 2023 18:07:29 +0100 Subject: [PATCH 1/3] Asset -> policy id + asset name --- .../src/cde/cardanoProjectedNFT.ts | 3 ++- .../paima-sm/src/cde-cardano-projected-nft.ts | 11 ++++++---- packages/engine/paima-sm/src/types.ts | 3 ++- packages/node-sdk/paima-db/README.md | 2 +- packages/node-sdk/paima-db/migrations/up.sql | 3 ++- .../sql/cde-cardano-projected-nft.queries.ts | 22 ++++++++++++------- .../src/sql/cde-cardano-projected-nft.sql | 9 +++++--- 7 files changed, 34 insertions(+), 19 deletions(-) diff --git a/packages/engine/paima-funnel/src/cde/cardanoProjectedNFT.ts b/packages/engine/paima-funnel/src/cde/cardanoProjectedNFT.ts index dbdae689a..610d914e0 100644 --- a/packages/engine/paima-funnel/src/cde/cardanoProjectedNFT.ts +++ b/packages/engine/paima-funnel/src/cde/cardanoProjectedNFT.ts @@ -55,7 +55,8 @@ function eventToCdeDatum( previousTxOutputIndex: event.previousTxOutputIndex != null ? event.previousTxOutputIndex : undefined, - asset: event.asset, + policyId: event.policyId, + assetName: event.assetName, amount: event.amount, status: event.status, plutusDatum: event.plutusDatum != null ? event.plutusDatum : '', diff --git a/packages/engine/paima-sm/src/cde-cardano-projected-nft.ts b/packages/engine/paima-sm/src/cde-cardano-projected-nft.ts index 87332c9dc..76165da75 100644 --- a/packages/engine/paima-sm/src/cde-cardano-projected-nft.ts +++ b/packages/engine/paima-sm/src/cde-cardano-projected-nft.ts @@ -18,13 +18,14 @@ export default async function processDatum( const currentTxHash = cdeDatum.payload.actionTxId; const currentOutputIndex = cdeDatum.payload.actionOutputIndex; const amount = cdeDatum.payload.amount; - const asset = cdeDatum.payload.asset; + const policyId = cdeDatum.payload.policyId; + const assetName = cdeDatum.payload.assetName; const status = cdeDatum.payload.status; const datum = cdeDatum.payload.plutusDatum; const forHowLong = cdeDatum.payload.forHowLong; const scheduledBlockHeight = Math.max(cdeDatum.blockNumber, ENV.SM_START_BLOCKHEIGHT + 1); - const scheduledInputData = `${prefix}|${ownerAddress}|${previousTxHash}|${previousOutputIndex}|${currentTxHash}|${currentOutputIndex}|${asset}|${status}`; + const scheduledInputData = `${prefix}|${ownerAddress}|${previousTxHash}|${previousOutputIndex}|${currentTxHash}|${currentOutputIndex}|${policyId}|${assetName}|${status}`; if (previousTxHash === undefined || previousOutputIndex === undefined) { const updateList: SQLUpdate[] = [ @@ -36,7 +37,8 @@ export default async function processDatum( owner_address: ownerAddress, current_tx_hash: currentTxHash, current_tx_output_index: currentOutputIndex, - asset: asset, + policy_id: policyId, + asset_name: assetName, amount: amount, status: status, plutus_datum: datum, @@ -57,7 +59,8 @@ export default async function processDatum( new_tx_output_index: currentOutputIndex, previous_tx_hash: previousTxHash, previous_tx_output_index: previousOutputIndex, - asset: asset, + policy_id: policyId, + asset_name: assetName, amount: amount, status: status, plutus_datum: datum, diff --git a/packages/engine/paima-sm/src/types.ts b/packages/engine/paima-sm/src/types.ts index 3bbf2c6c6..5a90de939 100644 --- a/packages/engine/paima-sm/src/types.ts +++ b/packages/engine/paima-sm/src/types.ts @@ -80,7 +80,8 @@ interface CdeDatumCardanoProjectedNFTPayload { previousTxHash: string | undefined; previousTxOutputIndex: number | undefined; - asset: string; + policyId: string; + assetName: string; amount: string; status: string; plutusDatum: string; diff --git a/packages/node-sdk/paima-db/README.md b/packages/node-sdk/paima-db/README.md index 7a9c05fa9..5b5cddf9e 100644 --- a/packages/node-sdk/paima-db/README.md +++ b/packages/node-sdk/paima-db/README.md @@ -17,4 +17,4 @@ Specific game databases do not need to contain these tables, as they will be cre To re-generate the queries, you will need a database running with the same connection info as [the config](./pgtypedconfig.json) and then run `npm run compile`. -Before running `npm compile`, you will need to initialize the DB using `sudo -u postgres psql -d postgres -a -f migrations/up.sql` +Before running `npm run compile`, you will need to initialize the DB using `sudo -u postgres psql -d postgres -a -f migrations/up.sql` diff --git a/packages/node-sdk/paima-db/migrations/up.sql b/packages/node-sdk/paima-db/migrations/up.sql index 7ca28f822..37a16edc9 100644 --- a/packages/node-sdk/paima-db/migrations/up.sql +++ b/packages/node-sdk/paima-db/migrations/up.sql @@ -102,7 +102,8 @@ CREATE TABLE cde_cardano_projected_nft ( previous_tx_output_index INTEGER, current_tx_hash TEXT NOT NULL, current_tx_output_index INTEGER, - asset TEXT NOT NULL, + policy_id TEXT NOT NULL, + asset_name TEXT NOT NULL, amount BIGINT NOT NULL, status TEXT NOT NULL, plutus_datum TEXT NOT NULL, diff --git a/packages/node-sdk/paima-db/src/sql/cde-cardano-projected-nft.queries.ts b/packages/node-sdk/paima-db/src/sql/cde-cardano-projected-nft.queries.ts index f59bdf548..4d1ab7096 100644 --- a/packages/node-sdk/paima-db/src/sql/cde-cardano-projected-nft.queries.ts +++ b/packages/node-sdk/paima-db/src/sql/cde-cardano-projected-nft.queries.ts @@ -11,7 +11,7 @@ export interface ICdeCardanoGetProjectedNftParams { /** 'CdeCardanoGetProjectedNft' return type */ export interface ICdeCardanoGetProjectedNftResult { amount: string; - asset: string; + asset_name: string; cde_id: number; current_tx_hash: string; current_tx_output_index: number | null; @@ -19,6 +19,7 @@ export interface ICdeCardanoGetProjectedNftResult { id: number; owner_address: string; plutus_datum: string; + policy_id: string; previous_tx_hash: string | null; previous_tx_output_index: number | null; status: string; @@ -45,13 +46,14 @@ export const cdeCardanoGetProjectedNft = new PreparedQuery Date: Tue, 19 Dec 2023 01:32:58 +0100 Subject: [PATCH 2/3] Update carp client call --- packages/engine/paima-funnel/src/cde/cardanoProjectedNFT.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/engine/paima-funnel/src/cde/cardanoProjectedNFT.ts b/packages/engine/paima-funnel/src/cde/cardanoProjectedNFT.ts index 610d914e0..bb958fe41 100644 --- a/packages/engine/paima-funnel/src/cde/cardanoProjectedNFT.ts +++ b/packages/engine/paima-funnel/src/cde/cardanoProjectedNFT.ts @@ -17,6 +17,7 @@ export default async function getCdeProjectedNFTData( const events = await timeout( query(url, Routes.projectedNftEventsRange, { range: { minSlot: fromAbsoluteSlot, maxSlot: toAbsoluteSlot }, + address: undefined, }), DEFAULT_FUNNEL_TIMEOUT ); From 7197527fbe988f1777925cffc4a6642ed0626bb4 Mon Sep 17 00:00:00 2001 From: Eugene Gostkin Date: Tue, 19 Dec 2023 02:32:01 +0100 Subject: [PATCH 3/3] Fix paima tables --- packages/node-sdk/paima-db/src/paima-tables.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/node-sdk/paima-db/src/paima-tables.ts b/packages/node-sdk/paima-db/src/paima-tables.ts index e3a41659e..e6779616d 100644 --- a/packages/node-sdk/paima-db/src/paima-tables.ts +++ b/packages/node-sdk/paima-db/src/paima-tables.ts @@ -286,7 +286,8 @@ CREATE TABLE cde_cardano_projected_nft ( previous_tx_output_index INTEGER, current_tx_hash TEXT NOT NULL, current_tx_output_index INTEGER, - asset TEXT NOT NULL, + policy_id TEXT NOT NULL, + asset_name TEXT NOT NULL, amount BIGINT NOT NULL, status TEXT NOT NULL, plutus_datum TEXT NOT NULL, @@ -306,11 +307,12 @@ const TABLE_DATA_CDE_CARDANO_PROJECTED_NFT: TableData = { ['previous_tx_output_index', 'integer', 'YES', ''], ['current_tx_hash', 'text', 'NO', ''], ['current_tx_output_index', 'integer', 'YES', ''], - ['asset', 'text', 'NO', ''], + ['policy_id', 'text', 'NO', ''], + ['asset_name', 'text', 'NO', ''], ['amount', 'bigint', 'NO', ''], ['status', 'text', 'NO', ''], ['plutus_datum', 'text', 'NO', ''], - ['for_how_long', 'bigint', 'NO', ''], + ['for_how_long', 'bigint', 'YES', ''], ]), serialColumns: ['id'], creationQuery: QUERY_CREATE_TABLE_CDE_CARDANO_PROJECTED_NFT,