Skip to content
Merged
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
2 changes: 1 addition & 1 deletion examples/create-account-with-secret.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ var secret = SDK.util.generatePrivateKey();
console.log("Your secret:", secret);

var account = SDK.util.getAccountIdFromPrivate(secret);
var address = SDK.Key.classes.PlatformAddress.fromAccountId(account);
var address = SDK.Core.classes.PlatformAddress.fromAccountId(account);
console.log("Your CodeChain address:", address.toString());
2 changes: 1 addition & 1 deletion examples/set-regular-key.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var ACCOUNT_SECRET =

const masterSecret = ACCOUNT_SECRET;
const masterAccountId = SDK.util.getAccountIdFromPrivate(masterSecret);
const masterAddress = sdk.key.classes.PlatformAddress.fromAccountId(
const masterAddress = sdk.core.classes.PlatformAddress.fromAccountId(
masterAccountId
);

Expand Down
7 changes: 4 additions & 3 deletions integration_tests/Rpc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {
H256,
Invoice,
Parcel,
PlatformAddress,
SignedParcel
} from "../lib/core/classes";
import { PlatformAddress } from "../lib/key/classes";
import {
generatePrivateKey,
getAccountIdFromPrivate,
Expand Down Expand Up @@ -110,7 +110,7 @@ describe("rpc", () => {

test("PlatformAddress", () => {
expect(
sdk.key.classes.PlatformAddress.fromAccountId(signerAccount).value
sdk.core.classes.PlatformAddress.fromAccountId(signerAccount).value
).toEqual(signerAddress);
});

Expand Down Expand Up @@ -162,7 +162,8 @@ describe("rpc", () => {

test("PlatformAddress", () => {
expect(
sdk.key.classes.PlatformAddress.fromAccountId(account).value
sdk.core.classes.PlatformAddress.fromAccountId(account)
.value
).toEqual(address);
});

Expand Down
4 changes: 2 additions & 2 deletions integration_tests/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const ACCOUNT_ID =
sdk.util.getAccountIdFromPrivate(ACCOUNT_SECRET).toString(); // "0xa6594b7196808d161b6fb137e781abbc251385d9"
export const ACCOUNT_ADDRESS =
process.env.ACCOUNT_ADDRESS ||
sdk.key.classes.PlatformAddress.fromAccountId(ACCOUNT_ID).toString(); // "tccqzn9jjm3j6qg69smd7cn0eup4w7z2yu9my9a2k78"
sdk.core.classes.PlatformAddress.fromAccountId(ACCOUNT_ID).toString(); // "tccqzn9jjm3j6qg69smd7cn0eup4w7z2yu9my9a2k78"
export const ACCOUNT_PASSPHRASE = process.env.ACCOUNT_PASSPHRASE || "satoshi";

export const sendTransactions = async ({ transactions }: any) => {
Expand Down Expand Up @@ -48,7 +48,7 @@ export const mintAsset = async ({
amount,
registrar
});
const assetAddress = sdk.key.classes.AssetTransferAddress.fromTypeAndPayload(
const assetAddress = sdk.core.classes.AssetTransferAddress.fromTypeAndPayload(
0,
lockScriptHash
);
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/useRegistrar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const masterAddress = ACCOUNT_ADDRESS;
const otherSecret =
"0000000000000000000000000000000000000000000000000000000000000001";
const otherAccountId = SDK.util.getAccountIdFromPrivate(otherSecret);
const otherAddress = sdk.key.classes.PlatformAddress.fromAccountId(
const otherAddress = sdk.core.classes.PlatformAddress.fromAccountId(
otherAccountId
);

Expand Down
3 changes: 1 addition & 2 deletions src/core/Asset.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Buffer } from "buffer";

import { AssetTransferAddress } from "../key/AssetTransferAddress";
import { AssetTransferAddress } from "codechain-primitives";

import { H256 } from "./H256";
import { AssetOutPoint } from "./transaction/AssetOutPoint";
Expand Down
4 changes: 1 addition & 3 deletions src/core/AssetScheme.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// FIXME: Use interface instead of importing key class.
import { AssetTransferAddress } from "../key/AssetTransferAddress";
import { PlatformAddress } from "../key/classes";
import { AssetTransferAddress, PlatformAddress } from "codechain-primitives";

import { AssetMintTransaction } from "./transaction/AssetMintTransaction";
import { NetworkId } from "./types";
Expand Down
3 changes: 2 additions & 1 deletion src/core/Block.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { PlatformAddress } from "../key/PlatformAddress";
import { PlatformAddress } from "codechain-primitives";

import { H256 } from "./H256";
import { SignedParcel } from "./SignedParcel";
import { U256 } from "./U256";
Expand Down
3 changes: 2 additions & 1 deletion src/core/Parcel.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { PlatformAddress } from "../key/PlatformAddress";
import { PlatformAddress } from "codechain-primitives";

import { blake256, signEcdsa } from "../utils";
import { Action, getActionFromJSON } from "./action/Action";
import { AssetTransactionGroup } from "./action/AssetTransactionGroup";
Expand Down
2 changes: 1 addition & 1 deletion src/core/SignedParcel.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PlatformAddress } from "codechain-primitives";
import * as _ from "lodash";

import { PlatformAddress } from "../key/classes";
import { blake256, recoverEcdsa, ripemd160 } from "../utils";

import { H160 } from "./H160";
Expand Down
3 changes: 2 additions & 1 deletion src/core/__test__/Block.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { PlatformAddress } from "codechain-primitives";

import { Block } from "../Block";
import { H256 } from "../H256";
import { U256 } from "../U256";
import { Parcel } from "../Parcel";
import { PlatformAddress } from "../../key/PlatformAddress";
import { getAccountIdFromPrivate } from "../../utils";

test("toJSON", () => {
Expand Down
3 changes: 2 additions & 1 deletion src/core/__test__/Parcel.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { PlatformAddress } from "codechain-primitives";

import { H256 } from "../H256";
import { U256 } from "../U256";
import { Parcel } from "../Parcel";
import { PlatformAddress } from "../../key/PlatformAddress";

test("rlp", () => {
const t = Parcel.transactions("tc");
Expand Down
2 changes: 1 addition & 1 deletion src/core/__test__/SignedParcel.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PlatformAddress } from "../../key/classes";
import { PlatformAddress } from "codechain-primitives";

import { H256 } from "../H256";
import { U256 } from "../U256";
Expand Down
3 changes: 2 additions & 1 deletion src/core/action/Action.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { PlatformAddress } from "../../key/PlatformAddress";
import { PlatformAddress } from "codechain-primitives";

import { H512 } from "../H512";
import { getTransactionFromJSON } from "../transaction/Transaction";
import { U256 } from "../U256";
Expand Down
3 changes: 2 additions & 1 deletion src/core/action/Payment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { PlatformAddress } from "../../key/PlatformAddress";
import { PlatformAddress } from "codechain-primitives";

import { U256 } from "../U256";

export class Payment {
Expand Down
2 changes: 1 addition & 1 deletion src/core/action/SetShardOwners.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PlatformAddress } from "../../key/PlatformAddress";
import { PlatformAddress } from "codechain-primitives";

export class SetShardOwners {
public readonly shardId: number;
Expand Down
2 changes: 1 addition & 1 deletion src/core/action/SetShardUsers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PlatformAddress } from "../../key/PlatformAddress";
import { PlatformAddress } from "codechain-primitives";

export class SetShardUsers {
public readonly shardId: number;
Expand Down
3 changes: 2 additions & 1 deletion src/core/action/__test__/SetShardOwners.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { PlatformAddress } from "codechain-primitives";

import { SetShardOwners } from "../SetShardOwners";
import { PlatformAddress } from "../../../key/PlatformAddress";
import { getActionFromJSON } from "../Action";

describe("SetShardOwners", () => {
Expand Down
3 changes: 2 additions & 1 deletion src/core/action/__test__/SetShardUsers.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { PlatformAddress } from "codechain-primitives";

import { SetShardUsers } from "../SetShardUsers";
import { PlatformAddress } from "../../../key/PlatformAddress";
import { getActionFromJSON } from "../Action";

describe("SetShardUsers", () => {
Expand Down
2 changes: 2 additions & 0 deletions src/core/classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ export { Asset } from "./Asset";
export { AssetScheme } from "./AssetScheme";

export { Script } from "./Script";

export { PlatformAddress, AssetTransferAddress } from "codechain-primitives";
8 changes: 5 additions & 3 deletions src/core/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// FIXME: Use interface instead of importing key class.
import { AssetTransferAddress, PlatformAddress } from "../key/classes";
import { AssetTransferAddress, PlatformAddress } from "codechain-primitives";

import { AssetTransactionGroup } from "./action/AssetTransactionGroup";
import { CreateShard } from "./action/CreateShard";
Expand Down Expand Up @@ -64,7 +63,10 @@ export class Core {
Asset,
AssetScheme,
// Script
Script
Script,
// Addresses
PlatformAddress,
AssetTransferAddress
};

public classes = Core.classes;
Expand Down
2 changes: 1 addition & 1 deletion src/core/transaction/AssetMintTransaction.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Buffer } from "buffer";
import { AssetTransferAddress, PlatformAddress } from "codechain-primitives";

import { AssetTransferAddress, PlatformAddress } from "../../key/classes";
import { P2PKH } from "../../key/P2PKH";
import { P2PKHBurn } from "../../key/P2PKHBurn";

Expand Down
2 changes: 1 addition & 1 deletion src/core/transaction/AssetTransferOutput.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Buffer } from "buffer";
import { AssetTransferAddress } from "codechain-primitives";

import { AssetTransferAddress } from "../../key/classes";
import { P2PKH } from "../../key/P2PKH";
import { P2PKHBurn } from "../../key/P2PKHBurn";

Expand Down
3 changes: 1 addition & 2 deletions src/core/transaction/AssetTransferTransaction.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { AssetTransferAddress } from "codechain-primitives";
import * as _ from "lodash";

import { AssetTransferAddress } from "../../key/classes";

import { blake256, blake256WithKey } from "../../utils";
import { Asset } from "../Asset";
import { H256 } from "../H256";
Expand Down
3 changes: 2 additions & 1 deletion src/core/transaction/CreateWorldTransaction.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { PlatformAddress } from "../../key/PlatformAddress";
import { PlatformAddress } from "codechain-primitives";

import { blake256 } from "../../utils";
import { H256 } from "../H256";
import { NetworkId } from "../types";
Expand Down
3 changes: 2 additions & 1 deletion src/core/transaction/SetWorldOwnersTransaction.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { PlatformAddress } from "../../key/PlatformAddress";
import { PlatformAddress } from "codechain-primitives";

import { blake256 } from "../../utils";
import { H256 } from "../H256";
import { NetworkId } from "../types";
Expand Down
3 changes: 2 additions & 1 deletion src/core/transaction/SetWorldUsersTransaction.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { PlatformAddress } from "../../key/PlatformAddress";
import { PlatformAddress } from "codechain-primitives";

import { blake256 } from "../../utils";
import { H256 } from "../H256";
import { NetworkId } from "../types";
Expand Down
3 changes: 2 additions & 1 deletion src/core/transaction/__test__/CreateWorldTransaction.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { PlatformAddress } from "codechain-primitives";

import { CreateWorldTransaction } from "../CreateWorldTransaction";
import { getTransactionFromJSON } from "../Transaction";
import { PlatformAddress } from "../../../key/classes";

describe("CreateWorldTransaction", () => {
test("toJSON", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { PlatformAddress } from "codechain-primitives";

import { SetWorldOwnersTransaction } from "../SetWorldOwnersTransaction";
import { getTransactionFromJSON } from "../Transaction";
import { PlatformAddress } from "../../../key/classes";

describe("SetWorldOwnersTransaction", () => {
test("toJSON", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { PlatformAddress } from "codechain-primitives";

import { SetWorldUsersTransaction } from "../SetWorldUsersTransaction";
import { getTransactionFromJSON } from "../Transaction";
import { PlatformAddress } from "../../../key/classes";

describe("SetWorldUsersTransaction", () => {
test("toJSON", () => {
Expand Down
1 change: 0 additions & 1 deletion src/key/AssetTransferAddress.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/key/P2PKH.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Buffer } from "buffer";
import { AssetTransferAddress } from "codechain-primitives";

import { H256 } from "../core/H256";
import { Script } from "../core/Script";
Expand All @@ -8,7 +9,6 @@ import {
} from "../core/transaction/AssetTransferTransaction";
import { NetworkId } from "../core/types";

import { AssetTransferAddress } from "./AssetTransferAddress";
import { KeyStore } from "./KeyStore";

/**
Expand Down
2 changes: 1 addition & 1 deletion src/key/P2PKHBurn.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Buffer } from "buffer";
import { AssetTransferAddress } from "codechain-primitives";

import { H256 } from "../core/H256";
import { Script } from "../core/Script";
Expand All @@ -8,7 +9,6 @@ import {
} from "../core/transaction/AssetTransferTransaction";
import { NetworkId } from "../core/types";

import { AssetTransferAddress } from "./AssetTransferAddress";
import { KeyStore } from "./KeyStore";

export class P2PKHBurn implements TransactionBurnSigner {
Expand Down
1 change: 0 additions & 1 deletion src/key/PlatformAddress.ts

This file was deleted.

33 changes: 0 additions & 33 deletions src/key/__test__/AssetTransferAddress.spec.ts

This file was deleted.

Loading