Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No base issuer #114

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/rmrk2.0.0/classes/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { getRemarkData } from "../tools/utils";
import { OP_TYPES, PREFIX, VERSION } from "../tools/constants";
import { BaseType } from "../tools/types";
import { Change } from "../changelog";
import { encodeAddress } from "@polkadot/keyring";

export class Base {
readonly block: number;
Expand Down Expand Up @@ -41,7 +40,6 @@ export class Base {
JSON.stringify({
symbol: this.symbol,
type: this.type,
issuer: this.issuer,
parts: this.parts,
themes: this.themes,
metadata: this.metadata,
Expand Down Expand Up @@ -140,8 +138,8 @@ export class Base {

static fromRemark(
remark: string,
block?: number,
ss58Format?: number
issuer: string,
block?: number
): Base | string {
if (!block) {
block = 0;
Expand All @@ -153,7 +151,7 @@ export class Base {
return new this(
block,
obj.symbol,
encodeAddress(obj.issuer, ss58Format),
issuer,
obj.type,
obj.parts,
obj.themes,
Expand Down
4 changes: 3 additions & 1 deletion src/rmrk2.0.0/tools/consolidator/interactions/base.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { Remark } from "../remark";
import { OP_TYPES } from "../../constants";
import {Base} from "../../../classes/base";
import { encodeAddress } from "@polkadot/keyring";

export const getBaseFromRemark = (remark: Remark, ss58Format?: number) => {
const base = Base.fromRemark(remark.remark, remark.block, ss58Format);
const issuer = encodeAddress(remark.caller, ss58Format);
const base = Base.fromRemark(remark.remark, issuer, remark.block);
if (typeof base === "string") {
throw new Error(`[${OP_TYPES.BASE}] Dead before instantiation: ${base}`);
}
Expand Down
2 changes: 1 addition & 1 deletion src/rmrk2.0.0/tools/validate-remark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const EMOTEStruct = type({
});

const BaseStruct = type({
issuer: string(),
issuer: optional(string()),
type: optional(string()),
symbol: string(),
parts: array(PartStruct),
Expand Down
2 changes: 1 addition & 1 deletion test/2.0.0/classes/__snapshots__/base.test.ts.snap

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