Skip to content

Commit

Permalink
Merge pull request #96 from Akord-com/fix-state-content-type-tag
Browse files Browse the repository at this point in the history
fix: add missing content type tag in state tx
  • Loading branch information
wkolod authored Mar 27, 2023
2 parents 2acd7b5 + e1a328a commit 0b62717
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/core/membership.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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),
Expand Down
5 changes: 4 additions & 1 deletion src/core/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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
Expand Down Expand Up @@ -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),
Expand Down
6 changes: 4 additions & 2 deletions src/core/vault.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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),
Expand All @@ -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),
Expand Down

0 comments on commit 0b62717

Please sign in to comment.