Skip to content

Commit

Permalink
More edits
Browse files Browse the repository at this point in the history
  • Loading branch information
TimDaub committed Jul 7, 2022
1 parent d0a20c8 commit 10d1a0a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/assetId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface AssetIdParams {
}

export class AssetId {
public static spec: IdentifierSpec = CAIP["19"].assetId;
public static spec: IdentifierSpec = CAIP["19"].blockNumberTag;

public static parse(id: string): AssetIdParams {
if (!isValidId(id, this.spec)) {
Expand Down
24 changes: 7 additions & 17 deletions src/spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,28 +87,17 @@ const CAIP19AssetId: IdentifierSpec = {
},
};

const BlockNumberTag: IdentifierSpec = {
name: "blockNumberTag",
regex: "[0-9]{1,78}|latest",
parameters: {
delimiter: "",
values: {
0: {
name: "blockNumberTag",
regex: "[0-9]{1,78}|latest",
},
},
},
};

const CAIP19BlockNumberTag: IdentifierSpec = {
name: "blockNumberTag",
regex: ".*",
regex: "[-:a-zA-Z0-9]{13,226}",
parameters: {
delimiter: "#",
values: {
0: CAIP19AssetId,
2: BlockNumberTag,
1: {
name: "blockNumberTag",
regex: "[0-9]{1,78}|latest",
},
},
},
};
Expand All @@ -119,6 +108,7 @@ export const CAIP = {
"19": {
assetName: AssetName,
assetType: CAIP19AssetType,
assetId: CAIP19BlockNumberTag,
assetId: CAIP19AssetId,
blockNumberTag: CAIP19BlockNumberTag,
},
};
1 change: 1 addition & 0 deletions test/assetId.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ function assertInterface(result: AssetId) {
expect(result.chainId.toString()).toEqual(data.CHAIN_ID_STRING);
expect(result.assetName.toString()).toEqual(data.ASSET_NAME_STRING);
expect(result.tokenId).toEqual(data.TOKEN_ID);
expect(result.blockNumberTag).toEqual(data.BLOCK_NUMBER_TAG);
expect(result.toString()).toEqual(data.ASSET_ID_STRING);
expect(result.toJSON()).toEqual(data.ASSET_ID_NESTED_PARAMS);
}
Expand Down

0 comments on commit 10d1a0a

Please sign in to comment.