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
4,737 changes: 812 additions & 3,925 deletions package-lock.json

Large diffs are not rendered by default.

11 changes: 0 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@
"license": "GPL-3.0-or-later",
"dependencies": {
"@babel/runtime": "7.11.2",
"@elrondnetwork/bls-wasm": "0.3.3",
"@elrondnetwork/hw-app-elrond": "0.3.2",
"@ledgerhq/hw-transport-u2f": "^5.36.0-deprecated",
"@ledgerhq/hw-transport-webhid": "^6.11.2",
"@ledgerhq/hw-transport-webusb": "6.11.2",
"@walletconnect/client": "1.6.5",
"abort-controller": "3.0.0",
"axios": "0.24.0",
Expand All @@ -43,7 +38,6 @@
"json-bigint": "1.0.0",
"json-duplicate-key-handle": "1.0.0",
"keccak": "^3.0.1",
"platform": "1.3.6",
"protobufjs": "6.10.2",
"qs": "6.10.1"
},
Expand All @@ -53,15 +47,10 @@
"@elrondnetwork/erdjs-walletcore": "1.0.0",
"@types/assert": "1.4.6",
"@types/chai": "4.2.11",
"@types/ledgerhq__hw-transport-u2f": "4.21.2",
"@types/ledgerhq__hw-transport-webusb": "4.70.1",
"@types/mocha": "7.0.2",
"@types/node": "13.13.2",
"@types/platform": "1.3.3",
"@types/protobufjs": "6.0.0",
"@types/qs": "6.9.7",
"@types/scryptsy": "2.0.0",
"@types/uuid": "8.3.0",
"assert": "2.0.0",
"babelify": "^10.0.0",
"browserify": "17.0.0",
Expand Down
5 changes: 3 additions & 2 deletions src/boundaryAdapters.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Address } from "./address";
import { ErrInvariantFailed } from "./errors";
import { IAddressOfExternalSigner, ISignatureOfExternalSigner } from "./interface";
import { Signature } from "./signature";

/**
* Adapts a signature created by other components (e.g. erdjs-walletcore, erdjs-hw-provider) to one understood by erdjs.
*/
export function adaptToSignature(obj: any): Signature {
export function adaptToSignature(obj: ISignatureOfExternalSigner): Signature {
if (!obj.hex || typeof obj.hex() !== "string") {
throw new ErrInvariantFailed("adaptToSignature: bad or missing hex()")
}
Expand All @@ -16,7 +17,7 @@ export function adaptToSignature(obj: any): Signature {
/**
* Adapts an address created by other components (e.g. erdjs-walletcore, erdjs-hw-provider) to one understood by erdjs.
*/
export function adaptToAddress(obj: any): Address {
export function adaptToAddress(obj: IAddressOfExternalSigner): Address {
if (!obj.bech32 || typeof obj.bech32() !== "string") {
throw new ErrInvariantFailed("adaptToSignature: bad or missing bech32()")
}
Expand Down
4 changes: 0 additions & 4 deletions src/dapp/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,5 @@ export const WALLET_PROVIDER_SIGN_TRANSACTION_URL = "/hook/sign";
export const WALLET_PROVIDER_CALLBACK_PARAM = "walletProviderStatus";
export const WALLET_PROVIDER_CALLBACK_PARAM_TX_SIGNED = "transactionsSigned";

// This constant represents the minimum version in which the Elrond Ledger App doesn't support anymore regular
// transactions' signing, and uses transaction's hash signing instead
export const LEDGER_TX_HASH_SIGN_MIN_VERSION = "1.0.11";

// Wallet Connect ChainId for Elrond blockchain
export const WALLETCONNECT_ELROND_CHAIN_ID = 508;
214 changes: 0 additions & 214 deletions src/dapp/hwProvider.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/dapp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

export * from "./constants";
export * from "./interface";
export * from "./hwProvider";
export * from "./walletProvider";
export * from "./walletConnectProvider";
export * from "./extensionProvider";
39 changes: 0 additions & 39 deletions src/dapp/interface.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Transaction } from "../transaction";
import {SignableMessage} from "../signableMessage";
import {Signature} from "../signature";

export interface IDappProvider {
init(): Promise<boolean>;
Expand All @@ -15,48 +14,10 @@ export interface IDappProvider {
signMessage(transaction: SignableMessage, options?: {callbackUrl?: string}): Promise<SignableMessage>;
}

export interface IHWProvider extends IDappProvider {
getAccounts(startIndex: number, length: number): Promise<string[]>;
tokenLogin(options: { token: Buffer, addressIndex?: number }): Promise<{signature: Signature; address: string}>;
}

export interface IDappMessageEvent extends MessageEvent {
data: {
type: string;
data: any;
error: string;
};
}

export interface IHWElrondApp {
getAddress(
account: number,
index: number,
display?: boolean
): Promise<{
publicKey: string;
address: string;
chainCode?: string;
}>;
setAddress(
account: number,
index: number,
display?: boolean,
): Promise<any>;
signTransaction(rawTx: Buffer, usingHash: boolean): Promise<string>;
signMessage(rawMessage: Buffer): Promise<string>;
getAppConfiguration(): Promise<{
version: string;
contractData: number;
accountIndex: number;
addressIndex: number;
}>;
getAddressAndSignAuthToken(
account: number,
index: number,
token: Buffer,
): Promise<{
address: string,
signature: string,
}>;
}
20 changes: 18 additions & 2 deletions src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ export interface ISignable {
/**
* Returns the signable object in its raw form - a sequence of bytes to be signed.
*/
serializeForSigning(signedBy: Address): Buffer;
serializeForSigning(signedBy: IAddressOfExternalSigner): Buffer;

/**
* Applies the computed signature on the object itself.
*
* @param signature The computed signature
* @param signedBy The address of the signer
*/
applySignature(signature: any, signedBy: any): void;
applySignature(signature: ISignatureOfExternalSigner, signedBy: IAddressOfExternalSigner): void;
}

/**
Expand All @@ -146,3 +146,19 @@ export interface IVerifiable {
export interface Disposable {
dispose(): void;
}

/**
* An interface that defines the signature, as computed by an external (to erdjs) signer.
* Implementations are outside of erdjs.
*/
export interface ISignatureOfExternalSigner {
hex(): string;
}

/**
* An interface that defines the address of an external (to erdjs) signer.
* Implementations are outside of erdjs.
*/
export interface IAddressOfExternalSigner {
bech32(): string;
}
Loading