Skip to content

Commit

Permalink
Improve the main page
Browse files Browse the repository at this point in the history
  • Loading branch information
Thunnini committed May 16, 2020
1 parent a5810c2 commit aef5d9a
Show file tree
Hide file tree
Showing 30 changed files with 1,743 additions and 213 deletions.
177 changes: 174 additions & 3 deletions package-lock.json

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

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
"write-file-webpack-plugin": "^4.5.1"
},
"dependencies": {
"@everett-protocol/cosmosjs": "git+https://github.com/everett-protocol/cosmosjs-dist.git#5b212c7",
"big-integer": "^1.6.43",
"@node-a-team/ts-amino": "0.0.1-alpha.2",
"webextension-polyfill": "^0.6.0",
"@fortawesome/fontawesome-free": "^5.13.0",
"argon-dashboard-react": "^1.1.0",
"axios": "^0.19.2",
Expand Down
1 change: 1 addition & 0 deletions src/background/tx/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const ROUTE = "background-tx";
1 change: 1 addition & 0 deletions src/background/tx/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./messages";
78 changes: 78 additions & 0 deletions src/background/tx/messages.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { Message, MessageSender } from "../../common/message";
import { ROUTE } from "./constants";

export class RequestBackgroundTxMsg extends Message<{}> {
public static type() {
return "request-background-tx";
}

/**
* @param chainId Chain id
* @param txBytes Hex encoded bytes for tx
* @param mode Broadcast mode
*/
public static create(
chainId: string,
txBytes: string,
mode: "sync" | "async" | "commit" = "commit",
origin: string
): RequestBackgroundTxMsg {
const msg = new RequestBackgroundTxMsg();
msg.chainId = chainId;
msg.txBytes = txBytes;
msg.mode = mode;
msg.origin = origin;
return msg;
}

public chainId: string = "";
public txBytes: string = "";
public mode?: "sync" | "async" | "commit";
public origin: string = "";

validateBasic(): void {
if (!this.chainId) {
throw new Error("chain id is empty");
}

if (!this.txBytes) {
throw new Error("tx bytes is empty");
}

if (
!this.mode ||
(this.mode !== "sync" && this.mode !== "async" && this.mode !== "commit")
) {
throw new Error("invalid mode");
}
}

// Approve external approves sending message if they submit their origin correctly.
// Keeper or handler must check that this origin has right permission.
approveExternal(sender: MessageSender): boolean {
const isInternal = super.approveExternal(sender);
if (isInternal) {
return true;
}

// TODO: When is a url undefined?
if (!sender.url) {
throw new Error("url is empty");
}

if (!this.origin) {
throw new Error("origin is empty");
}

const url = new URL(sender.url);
return url.origin === this.origin;
}

route(): string {
return ROUTE;
}

type(): string {
return RequestBackgroundTxMsg.type();
}
}
14 changes: 14 additions & 0 deletions src/chain-info.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Bech32Config } from "@everett-protocol/cosmosjs/core/bech32Config";

export interface ChainInfo {
readonly rpc: string;
readonly rest: string;
readonly chainId: string;
readonly chainName: string;
readonly nativeCurrency: {
coinDenom: string;
coinMinimalDenom: string;
coinDecimals: number;
};
readonly bech32Config: Bech32Config;
}
Loading

0 comments on commit aef5d9a

Please sign in to comment.