From e1a328ac80eb645afef4995db669a9575a2b8a87 Mon Sep 17 00:00:00 2001 From: Weronika K Date: Sun, 26 Mar 2023 13:26:23 +0200 Subject: [PATCH] fix: add missing content type tag in state tx --- src/core/membership.ts | 5 +++-- src/core/service.ts | 5 ++++- src/core/vault.ts | 6 ++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/core/membership.ts b/src/core/membership.ts index 1c6085fa..fc75e95e 100644 --- a/src/core/membership.ts +++ b/src/core/membership.ts @@ -1,7 +1,7 @@ -import { actionRefs, objectType, status, functions, protocolTags } from "../constants"; +import { actionRefs, objectType, status, functions, protocolTags, smartweaveTags } from "../constants"; import { v4 as uuidv4 } from "uuid"; import { Encrypter, generateKeyPair } from "@akord/crypto"; -import { Service } from "./service"; +import { Service, STATE_CONTENT_TYPE } from "./service"; import { Membership, RoleType } from "../types/membership"; import { ListOptions } from "../types/list-options"; import { Tag, Tags } from "../types/contract"; @@ -238,6 +238,7 @@ class MembershipService extends Service { newMembershipStates.push({ data: newState, tags: [ new Tag("Data-Type", "State"), + new Tag(smartweaveTags.CONTENT_TYPE, STATE_CONTENT_TYPE), new Tag(protocolTags.SIGNATURE, signature), new Tag(protocolTags.SIGNER_ADDRESS, await this.wallet.getAddress()), new Tag(protocolTags.VAULT_ID, this.vaultId), diff --git a/src/core/service.ts b/src/core/service.ts index 8fc2eaa5..91614b6f 100644 --- a/src/core/service.ts +++ b/src/core/service.ts @@ -14,7 +14,7 @@ import { AkordWallet, } from "@akord/crypto"; import { v4 as uuidv4 } from "uuid"; -import { objectType, protocolTags, functions, dataTags, encryptionTags } from '../constants'; +import { objectType, protocolTags, functions, dataTags, encryptionTags, smartweaveTags } from '../constants'; import lodash from "lodash"; import { Vault } from "../types/vault"; import { Tag, Tags } from "../types/contract"; @@ -25,6 +25,8 @@ import { EncryptedPayload } from "@akord/crypto/lib/types"; declare const Buffer; +export const STATE_CONTENT_TYPE = "application/json"; + class Service { api: Api wallet: Wallet @@ -339,6 +341,7 @@ class Service { const signature = await this.signData(state); const tags = [ new Tag(dataTags.DATA_TYPE, "State"), + new Tag(smartweaveTags.CONTENT_TYPE, STATE_CONTENT_TYPE), new Tag(protocolTags.SIGNATURE, signature), new Tag(protocolTags.SIGNER_ADDRESS, await this.wallet.getAddress()), new Tag(protocolTags.VAULT_ID, this.vaultId), diff --git a/src/core/vault.ts b/src/core/vault.ts index b2556c3e..45315bfd 100644 --- a/src/core/vault.ts +++ b/src/core/vault.ts @@ -1,8 +1,8 @@ -import { actionRefs, objectType, functions, protocolTags } from "../constants"; +import { actionRefs, objectType, functions, protocolTags, smartweaveTags } from "../constants"; import { v4 as uuidv4 } from "uuid"; import { generateKeyPair, arrayToBase64, Encrypter } from "@akord/crypto"; import { Vault } from "../types/vault"; -import { Service } from "./service"; +import { Service, STATE_CONTENT_TYPE } from "./service"; import { Tag } from "../types/contract"; class VaultService extends Service { @@ -64,6 +64,7 @@ class VaultService extends Service { { data: vaultData, tags: [ new Tag("Data-Type", "State"), + new Tag(smartweaveTags.CONTENT_TYPE, STATE_CONTENT_TYPE), new Tag(protocolTags.SIGNATURE, vaultSignature), new Tag(protocolTags.SIGNER_ADDRESS, await this.wallet.getAddress()), new Tag(protocolTags.VAULT_ID, this.vaultId), @@ -73,6 +74,7 @@ class VaultService extends Service { { data: membershipData, tags: [ new Tag("Data-Type", "State"), + new Tag(smartweaveTags.CONTENT_TYPE, STATE_CONTENT_TYPE), new Tag(protocolTags.SIGNATURE, membershipSignature), new Tag(protocolTags.SIGNER_ADDRESS, await this.wallet.getAddress()), new Tag(protocolTags.VAULT_ID, this.vaultId),