Socket
Socket
Sign inDemoInstall

@terra-money/terra.js

Package Overview
Dependencies
55
Maintainers
5
Versions
230
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.4.17 to 0.4.18-beta.0

6

dist/key/Key.d.ts
/// <reference types="node" />
import * as secp256k1 from 'secp256k1';
import { StdSignature } from '../core';

@@ -21,3 +22,6 @@ import { StdTx } from '../core';

*/
abstract sign(payload: Buffer): Promise<Buffer>;
abstract sign(payload: Buffer, options?: secp256k1.SignOptions): {
signature: Uint8Array;
recid: number;
};
/**

@@ -24,0 +28,0 @@ * Terra account address. `terra-` prefixed.

22

dist/key/Key.js

@@ -123,16 +123,12 @@ "use strict";

return __awaiter(this, void 0, void 0, function () {
var sigData;
var signature;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.sign(Buffer.from(tx.toJSON()))];
case 1:
sigData = _a.sent();
return [2 /*return*/, core_1.StdSignature.fromData({
signature: sigData.toString('base64'),
pub_key: {
type: 'tendermint/PubKeySecp256k1',
value: this.publicKey.toString('base64'),
},
})];
}
signature = this.sign(Buffer.from(tx.toJSON())).signature;
return [2 /*return*/, core_1.StdSignature.fromData({
signature: Buffer.from(signature).toString('base64'),
pub_key: {
type: 'tendermint/PubKeySecp256k1',
value: this.publicKey.toString('base64'),
},
})];
});

@@ -139,0 +135,0 @@ });

/// <reference types="node" />
import * as secp256k1 from 'secp256k1';
import { Key } from './Key';

@@ -59,4 +60,7 @@ export declare const LUNA_COIN_TYPE = 330;

constructor(options?: MnemonicKeyOptions);
sign(payload: Buffer): Promise<Buffer>;
sign(payload: Buffer, options?: secp256k1.SignOptions): {
signature: Uint8Array;
recid: number;
};
}
export {};

@@ -46,38 +46,2 @@ "use strict";

};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -150,11 +114,5 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

}
MnemonicKey.prototype.sign = function (payload) {
return __awaiter(this, void 0, void 0, function () {
var hash, signature;
return __generator(this, function (_a) {
hash = Buffer.from(sha256_1.default(payload.toString()).toString(), 'hex');
signature = secp256k1.ecdsaSign(Uint8Array.from(hash), Uint8Array.from(this.privateKey)).signature;
return [2 /*return*/, Buffer.from(signature)];
});
});
MnemonicKey.prototype.sign = function (payload, options) {
var hash = Buffer.from(sha256_1.default(payload.toString()).toString(), 'hex');
return secp256k1.ecdsaSign(Uint8Array.from(hash), Uint8Array.from(this.privateKey), options);
};

@@ -161,0 +119,0 @@ return MnemonicKey;

/// <reference types="node" />
import * as secp256k1 from 'secp256k1';
import { Key } from './Key';

@@ -12,3 +13,6 @@ /**

constructor(privateKey: Buffer);
sign(payload: Buffer): Promise<Buffer>;
sign(payload: Buffer, options?: secp256k1.SignOptions): {
signature: Uint8Array;
recid: number;
};
}

@@ -34,38 +34,2 @@ "use strict";

};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -91,11 +55,5 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

}
RawKey.prototype.sign = function (payload) {
return __awaiter(this, void 0, void 0, function () {
var hash, signature;
return __generator(this, function (_a) {
hash = Buffer.from(sha256_1.default(payload.toString()).toString(), 'hex');
signature = secp256k1.ecdsaSign(Uint8Array.from(hash), Uint8Array.from(this.privateKey)).signature;
return [2 /*return*/, Buffer.from(signature)];
});
});
RawKey.prototype.sign = function (payload, options) {
var hash = Buffer.from(sha256_1.default(payload.toString()).toString(), 'hex');
return secp256k1.ecdsaSign(Uint8Array.from(hash), Uint8Array.from(this.privateKey), options);
};

@@ -102,0 +60,0 @@ return RawKey;

{
"version": "0.4.17",
"version": "0.4.18-beta.0",
"license": "MIT",

@@ -4,0 +4,0 @@ "main": "dist/index.js",

@@ -32,3 +32,3 @@ <p>&nbsp;</p>

Terra.js a JavaScript SDK for writing applications that interact with the Terra blockchain from either a Node.js or browser environments and provides simple abstractions over core data structures, serialization, key management, and API request generation.
Terra.js a JavaScript SDK for writing applications that interact with the Terra blockchain from either Node.js, browser, or React Native environments and provides simple abstractions over core data structures, serialization, key management, and API request generation.

@@ -39,3 +39,3 @@ ## Features

- Versatile support for [key management](https://github.com/terra-project/terra.js/wiki/Keys) solutions
- Works in both Node.js and in the browser
- Works in Node.js, in the browser, and React Native
- Exposes the Terra API through [`LCDClient`](https://github.com/terra-project/terra.js/wiki/Querying)

@@ -144,10 +144,14 @@ - Parses responses into native JavaScript types

## Terra.js on React Native environment
Setup a React Native App and install ```node-libs-react-native``` package. Following instructions were extracted from https://github.com/parshap/node-libs-react-native
## Terra.js in React Native
You need to register Node.js native modules by:
Setup a React Native App and install ```node-libs-react-native``` package, following instructions from https://github.com/parshap/node-libs-react-native.
You will need to register Node.js native modules with:
```js
require('node-libs-react-native/globals')
```
Add resolver configuration to metro.config.js
Also, add resolvers to your `metro.config.js`
```js

@@ -154,0 +158,0 @@ resolver: {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc