Skip to content

Commit

Permalink
Move @anoma/wasm -> @anoma/shared
Browse files Browse the repository at this point in the history
  • Loading branch information
jurevans committed Sep 6, 2022
1 parent 0da830d commit 1b5e9a5
Show file tree
Hide file tree
Showing 53 changed files with 39 additions and 23 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ namada-interface/
├── namada-interface/ # Main wallet React App
├── extension/ # Browser Extension React App
└── packages/
├── crypto/ # Crypto functions related to anoma extension and interface
├── integrations/ # Third-party wallet integrations
└── masp-web/ # utilities for performing MASP actions
└── rpc/ # Library for handling HTTP and WebSocket RPC calls
Expand All @@ -56,7 +57,7 @@ namada-interface/
├── tx/ # Library for interfacing with Anoma transactions
├── utils/ # Shared utilities
├── wallet/ # Library for deriving keys
├── wasm/ # Rust lib for generating WASM
├── shared/ # Package for interfacing with `namada/shared`
```

### Usage
Expand Down
6 changes: 6 additions & 0 deletions apps/extension/src/browsers/chrome/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
"default_popup": "../../static/popup.html"
},
"permissions": ["storage", "notifications", "identity"],
"sandbox": {
"pages": ["../../background/index.ts"]
},
"content_security_policy": {
"sandbox": "sandbox allow-scripts script-src 'self' 'wasm-eval"
},
"web_accessible_resources": [
{
"resources": ["scripts/inject.ts"],
Expand Down
2 changes: 1 addition & 1 deletion apps/namada-interface/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
"@anoma/rpc": "0.1.0",
"@anoma/seed-management": "0.1.0",
"@anoma/session": "0.1.0",
"@anoma/shared": "0.1.0",
"@anoma/tx": "0.1.0",
"@anoma/utils": "0.1.0",
"@anoma/wallet": "0.1.0",
"@anoma/wasm": "0.1.0",
"@reduxjs/toolkit": "^1.8.0",
"crypto-browserify": "^3.12.0",
"framer-motion": "^6.2.8",
Expand Down
2 changes: 1 addition & 1 deletion packages/crypto/lib/src/crypto/aead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use orion::{aead, kdf};
use thiserror::Error;
use wasm_bindgen::prelude::*;

use crate::crypto::utils::{encryption_key, encryption_salt};
use crate::utils::{encryption_key, encryption_salt};

#[allow(missing_docs)]
#[derive(Debug, Error)]
Expand Down
6 changes: 1 addition & 5 deletions packages/crypto/lib/src/crypto/bip44.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use wasm_bindgen::prelude::*;
pub struct Bip44 {
root_key: String,
seed: Vec<u8>,
password: String,
}

#[wasm_bindgen]
Expand All @@ -28,17 +27,14 @@ pub struct ExtendedKeys {

#[wasm_bindgen]
impl Bip44 {
pub fn new(
seed: Vec<u8>,
password: String) -> Result<Bip44, JsValue> {
pub fn new(seed: Vec<u8>) -> Result<Bip44, JsValue> {
let seed: &[u8] = &seed;

// BIP32 Root Key
let root_xprv = XPrv::new(&seed).expect("Could not create extended private key from seed");
let root_xprv_str = root_xprv.to_string(Prefix::XPRV).to_string();

Ok(Bip44 {
password,
root_key: root_xprv_str,
seed: seed.to_vec(),
})
Expand Down
1 change: 0 additions & 1 deletion packages/crypto/lib/src/crypto/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
pub mod aead;
pub mod utils;
pub mod mnemonic;
pub mod bip44;
1 change: 1 addition & 0 deletions packages/crypto/lib/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pub mod crypto;
pub mod utils;
File renamed without changes.
13 changes: 13 additions & 0 deletions packages/crypto/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
/* eslint-disable */
import wasm from "./crypto";
/* eslint-enable */

export const init = async (): Promise<WebAssembly.Memory | null> => {
// Support setting wasm-pack target to "nodejs" (for testing)
// A target of "nodejs" will not generate a callable init() function
const _init =
typeof wasm === "function" ? wasm : () => Promise.resolve({ memory: null });
const { memory } = await _init();
return memory;
};

export * from "./crypto";
2 changes: 1 addition & 1 deletion packages/seed-management/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"typescript": "^4.5.5"
},
"dependencies": {
"@anoma/wasm": "0.1.0",
"@anoma/shared": "0.1.0",
"@iarna/toml": "^2.2.5",
"buffer": "^6.0.3"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/seed-management/src/Mnemonic.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Mnemonic, MnemonicLength } from "./Mnemonic";
import { AnomaClient } from "@anoma/wasm";
import { AnomaClient } from "@anoma/shared";

test("mnemonic should have a correct length", async () => {
const mnemonic1 = await Mnemonic.fromMnemonic(MnemonicLength.Twelve);
Expand Down
2 changes: 1 addition & 1 deletion packages/seed-management/src/Mnemonic.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AnomaClient } from "@anoma/wasm";
import { AnomaClient } from "@anoma/shared";
import { toBase64, fromBase64 } from "@cosmjs/encoding";

export enum MnemonicLength {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@anoma/wasm",
"name": "@anoma/shared",
"version": "0.1.0",
"type": "module",
"license": "MIT",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/tx/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# tx

Anoma Wallet transaction library for interfacing with packages served from `@anoma/wasm`.
Anoma Wallet transaction library for interfacing with packages served from `@anoma/shared`.

_TBD_
2 changes: 1 addition & 1 deletion packages/tx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"typescript": "^4.7.4"
},
"dependencies": {
"@anoma/wasm": "0.1.0",
"@anoma/shared": "0.1.0",
"slip44": "^1.2.60"
}
}
2 changes: 1 addition & 1 deletion packages/tx/src/Account.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AnomaClient } from "@anoma/wasm";
import { AnomaClient } from "@anoma/shared";
import { Tokens } from "@anoma/tx";

class Account {
Expand Down
2 changes: 1 addition & 1 deletion packages/tx/src/IBCTransfer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AnomaClient } from "@anoma/wasm";
import { AnomaClient } from "@anoma/shared";

class IBCTransfer {
private _client: AnomaClient | undefined;
Expand Down
2 changes: 1 addition & 1 deletion packages/tx/src/Transfer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { amountToMicro } from "@anoma/utils";
import { AnomaClient } from "@anoma/wasm";
import { AnomaClient } from "@anoma/shared";

type TransactionData = {
source: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/wallet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"dependencies": {
"@anoma/tx": "0.1.0",
"@anoma/wasm": "0.1.0",
"@anoma/shared": "0.1.0",
"@cosmjs/encoding": "^0.27.1",
"typescript": "^4.7.4"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/wallet/src/Wallet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { fromHex, toHex } from "@cosmjs/encoding";
import fetchMock, { enableFetchMocks } from "jest-fetch-mock";
import { Tokens } from "@anoma/tx";
import Wallet from "./Wallet";
import { AnomaClient } from "@anoma/wasm";
import { AnomaClient } from "@anoma/shared";

enableFetchMocks();

Expand Down
2 changes: 1 addition & 1 deletion packages/wallet/src/Wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
Result,
ResultType,
Wallet as WalletType,
} from "@anoma/wasm";
} from "@anoma/shared";

type Encoding = "hex" | "base58" | null;

Expand Down
2 changes: 1 addition & 1 deletion scripts/build-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd -P)

cd $SCRIPT_DIR/../packages/wasm && yarn wasm:build:node
cd $SCRIPT_DIR/../packages/shared && yarn wasm:build:node
2 changes: 1 addition & 1 deletion scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd -P)

cd $SCRIPT_DIR/../packages/wasm && yarn wasm:build
cd $SCRIPT_DIR/../packages/shared && yarn wasm:build

0 comments on commit 1b5e9a5

Please sign in to comment.