@airgap/cosmos 0.13.7-beta.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/LICENSE.md +7 -0
  2. package/airgap-coinlib-cosmos.min.js +72632 -0
  3. package/index.d.ts +10 -0
  4. package/index.js +18 -0
  5. package/index.js.map +1 -0
  6. package/package.json +59 -0
  7. package/protocol/CosmosAddress.d.ts +8 -0
  8. package/protocol/CosmosAddress.js +25 -0
  9. package/protocol/CosmosAddress.js.map +1 -0
  10. package/protocol/CosmosCoin.d.ts +19 -0
  11. package/protocol/CosmosCoin.js +55 -0
  12. package/protocol/CosmosCoin.js.map +1 -0
  13. package/protocol/CosmosCryptoClient.d.ts +8 -0
  14. package/protocol/CosmosCryptoClient.js +86 -0
  15. package/protocol/CosmosCryptoClient.js.map +1 -0
  16. package/protocol/CosmosFee.d.ts +15 -0
  17. package/protocol/CosmosFee.js +31 -0
  18. package/protocol/CosmosFee.js.map +1 -0
  19. package/protocol/CosmosNodeClient.d.ts +25 -0
  20. package/protocol/CosmosNodeClient.js +382 -0
  21. package/protocol/CosmosNodeClient.js.map +1 -0
  22. package/protocol/CosmosProtocol.d.ts +124 -0
  23. package/protocol/CosmosProtocol.js +1147 -0
  24. package/protocol/CosmosProtocol.js.map +1 -0
  25. package/protocol/CosmosProtocolOptions.d.ts +22 -0
  26. package/protocol/CosmosProtocolOptions.js +114 -0
  27. package/protocol/CosmosProtocolOptions.js.map +1 -0
  28. package/protocol/CosmosTransaction.d.ts +37 -0
  29. package/protocol/CosmosTransaction.js +106 -0
  30. package/protocol/CosmosTransaction.js.map +1 -0
  31. package/protocol/CosmosTypes.d.ts +310 -0
  32. package/protocol/CosmosTypes.js +8 -0
  33. package/protocol/CosmosTypes.js.map +1 -0
  34. package/protocol/cosmos-message/CosmosDelegateMessage.d.ts +20 -0
  35. package/protocol/cosmos-message/CosmosDelegateMessage.js +72 -0
  36. package/protocol/cosmos-message/CosmosDelegateMessage.js.map +1 -0
  37. package/protocol/cosmos-message/CosmosMessage.d.ts +39 -0
  38. package/protocol/cosmos-message/CosmosMessage.js +47 -0
  39. package/protocol/cosmos-message/CosmosMessage.js.map +1 -0
  40. package/protocol/cosmos-message/CosmosSendMessage.d.ts +20 -0
  41. package/protocol/cosmos-message/CosmosSendMessage.js +83 -0
  42. package/protocol/cosmos-message/CosmosSendMessage.js.map +1 -0
  43. package/protocol/cosmos-message/CosmosWithdrawDelegationRewardMessage.d.ts +24 -0
  44. package/protocol/cosmos-message/CosmosWithdrawDelegationRewardMessage.js +61 -0
  45. package/protocol/cosmos-message/CosmosWithdrawDelegationRewardMessage.js.map +1 -0
  46. package/readme.md +121 -0
  47. package/types/signed-transaction-cosmos.d.ts +6 -0
  48. package/types/signed-transaction-cosmos.js +3 -0
  49. package/types/signed-transaction-cosmos.js.map +1 -0
  50. package/types/transaction-cosmos.d.ts +5 -0
  51. package/types/transaction-cosmos.js +3 -0
  52. package/types/transaction-cosmos.js.map +1 -0
  53. package/types/unsigned-transaction-cosmos.d.ts +33 -0
  54. package/types/unsigned-transaction-cosmos.js +10 -0
  55. package/types/unsigned-transaction-cosmos.js.map +1 -0
package/index.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { CosmosAddress } from './protocol/CosmosAddress';
2
+ import { CosmosCryptoClient } from './protocol/CosmosCryptoClient';
3
+ import { CosmosDelegationActionType, CosmosProtocol } from './protocol/CosmosProtocol';
4
+ import { CosmosProtocolConfig, CosmosProtocolNetwork, CosmosProtocolOptions, MintscanBlockExplorer } from './protocol/CosmosProtocolOptions';
5
+ import { CosmosTransaction } from './protocol/CosmosTransaction';
6
+ import { CosmosUnbondingDelegation, CosmosValidator } from './protocol/CosmosTypes';
7
+ import { SignedCosmosTransaction } from './types/signed-transaction-cosmos';
8
+ import { UnsignedCosmosTransaction } from './types/transaction-cosmos';
9
+ import { SerializableUnsignedCosmosTransaction } from './types/unsigned-transaction-cosmos';
10
+ export { CosmosProtocol, CosmosCryptoClient, MintscanBlockExplorer, CosmosProtocolNetwork, CosmosProtocolConfig, CosmosProtocolOptions, CosmosUnbondingDelegation, CosmosValidator, CosmosDelegationActionType, CosmosAddress, CosmosTransaction, UnsignedCosmosTransaction, SignedCosmosTransaction, SerializableUnsignedCosmosTransaction };
package/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CosmosTransaction = exports.CosmosAddress = exports.CosmosDelegationActionType = exports.CosmosProtocolOptions = exports.CosmosProtocolConfig = exports.CosmosProtocolNetwork = exports.MintscanBlockExplorer = exports.CosmosCryptoClient = exports.CosmosProtocol = void 0;
4
+ var CosmosAddress_1 = require("./protocol/CosmosAddress");
5
+ Object.defineProperty(exports, "CosmosAddress", { enumerable: true, get: function () { return CosmosAddress_1.CosmosAddress; } });
6
+ var CosmosCryptoClient_1 = require("./protocol/CosmosCryptoClient");
7
+ Object.defineProperty(exports, "CosmosCryptoClient", { enumerable: true, get: function () { return CosmosCryptoClient_1.CosmosCryptoClient; } });
8
+ var CosmosProtocol_1 = require("./protocol/CosmosProtocol");
9
+ Object.defineProperty(exports, "CosmosDelegationActionType", { enumerable: true, get: function () { return CosmosProtocol_1.CosmosDelegationActionType; } });
10
+ Object.defineProperty(exports, "CosmosProtocol", { enumerable: true, get: function () { return CosmosProtocol_1.CosmosProtocol; } });
11
+ var CosmosProtocolOptions_1 = require("./protocol/CosmosProtocolOptions");
12
+ Object.defineProperty(exports, "CosmosProtocolConfig", { enumerable: true, get: function () { return CosmosProtocolOptions_1.CosmosProtocolConfig; } });
13
+ Object.defineProperty(exports, "CosmosProtocolNetwork", { enumerable: true, get: function () { return CosmosProtocolOptions_1.CosmosProtocolNetwork; } });
14
+ Object.defineProperty(exports, "CosmosProtocolOptions", { enumerable: true, get: function () { return CosmosProtocolOptions_1.CosmosProtocolOptions; } });
15
+ Object.defineProperty(exports, "MintscanBlockExplorer", { enumerable: true, get: function () { return CosmosProtocolOptions_1.MintscanBlockExplorer; } });
16
+ var CosmosTransaction_1 = require("./protocol/CosmosTransaction");
17
+ Object.defineProperty(exports, "CosmosTransaction", { enumerable: true, get: function () { return CosmosTransaction_1.CosmosTransaction; } });
18
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,0DAAwD;AAoBtD,8FApBO,6BAAa,OAoBP;AAnBf,oEAAkE;AAWhE,mGAXO,uCAAkB,OAWP;AAVpB,4DAAsF;AAiBpF,2GAjBO,2CAA0B,OAiBP;AAR1B,+FATmC,+BAAc,OASnC;AARhB,0EAA4I;AAY1I,qGAZO,4CAAoB,OAYP;AADpB,sGAX6B,6CAAqB,OAW7B;AAErB,sGAboD,6CAAqB,OAapD;AAHrB,sGAV2E,6CAAqB,OAU3E;AATvB,kEAAgE;AAiB9D,kGAjBO,qCAAiB,OAiBP"}
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@airgap/cosmos",
3
+ "version": "0.13.7-beta.11",
4
+ "description": "The @airgap/cosmos is a Cosmos implementation of the ICoinProtocol interface from @airgap/coinlib-core.",
5
+ "keywords": [
6
+ "airgap",
7
+ "blockchain",
8
+ "crypto",
9
+ "cosmos"
10
+ ],
11
+ "license": "MIT",
12
+ "homepage": "https://www.airgap.it",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/airgap-it/airgap-coin-lib"
16
+ },
17
+ "publishConfig": {
18
+ "access": "public"
19
+ },
20
+ "scripts": {
21
+ "build": "rm -rf ./dist && tsc && node scripts/copy-files-after-build.js",
22
+ "build-scripts": "tsc scripts/*.ts",
23
+ "lint": "tslint -c ./tslint.json --project ./tsconfig.json --format stylish --fix",
24
+ "lint:prettier": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
25
+ "lint-ci": "tslint -t json -o ../../lint-reports/cosmos.json --project . || true",
26
+ "lint-ci:prettier": "prettier \"src/**/*.ts\" \"test/**/*.ts\" --list-different",
27
+ "test": "nyc mocha --bail --require ts-node/register --require source-map-support/register --full-trace --delay --timeout 40000 ./test/**/**.spec.ts",
28
+ "test-ci": "nyc --reporter=lcov npm test",
29
+ "test-legacy": "",
30
+ "browserify": "browserify ./dist/index.js -p realpathify -s airgapCoinLibCosmos > ./dist/airgap-coinlib-cosmos.min.js"
31
+ },
32
+ "author": "Papers GmbH <contact@papers.ch> (https://papers.ch)",
33
+ "peerDependencies": {
34
+ "@airgap/coinlib-core": "^0.13.7-beta.0"
35
+ },
36
+ "localDependencies": {},
37
+ "nyc": {
38
+ "include": [
39
+ "src/**/*.ts"
40
+ ],
41
+ "exclude": [
42
+ "test/**/*.spec.ts"
43
+ ],
44
+ "extension": [
45
+ ".ts"
46
+ ],
47
+ "require": [
48
+ "ts-node/register"
49
+ ],
50
+ "reporter": [
51
+ "text",
52
+ "text-summary"
53
+ ],
54
+ "report-dir": "../../coverage/cosmos",
55
+ "sourceMap": true,
56
+ "instrument": true
57
+ },
58
+ "gitHead": "8e8feb6788204501b7173aa825f5456c2a5f185b"
59
+ }
@@ -0,0 +1,8 @@
1
+ import { IAirGapAddress } from '@airgap/coinlib-core/interfaces/IAirGapAddress';
2
+ export declare class CosmosAddress implements IAirGapAddress {
3
+ private readonly value;
4
+ private static readonly addressPrefix;
5
+ private constructor();
6
+ static from(publicKey: string): CosmosAddress;
7
+ asString(): string;
8
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CosmosAddress = void 0;
4
+ var BECH32 = require("@airgap/coinlib-core/dependencies/src/bech32-1.1.3/index");
5
+ var RIPEMD160 = require("@airgap/coinlib-core/dependencies/src/ripemd160-2.0.2/index");
6
+ var sha = require("@airgap/coinlib-core/dependencies/src/sha.js-2.4.11/index");
7
+ var CosmosAddress = /** @class */ (function () {
8
+ function CosmosAddress(value) {
9
+ this.value = value;
10
+ }
11
+ CosmosAddress.from = function (publicKey) {
12
+ var pubkey = Buffer.from(publicKey, 'hex');
13
+ var sha256Hash = sha('sha256').update(pubkey).digest();
14
+ var hash = new RIPEMD160().update(Buffer.from(sha256Hash)).digest();
15
+ var address = BECH32.encode(CosmosAddress.addressPrefix, BECH32.toWords(hash));
16
+ return new CosmosAddress(address);
17
+ };
18
+ CosmosAddress.prototype.asString = function () {
19
+ return this.value;
20
+ };
21
+ CosmosAddress.addressPrefix = 'cosmos';
22
+ return CosmosAddress;
23
+ }());
24
+ exports.CosmosAddress = CosmosAddress;
25
+ //# sourceMappingURL=CosmosAddress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CosmosAddress.js","sourceRoot":"","sources":["../../src/protocol/CosmosAddress.ts"],"names":[],"mappings":";;;AAAA,iFAAmF;AACnF,uFAAyF;AACzF,+EAAiF;AAGjF;IAGE,uBAAqC,KAAa;QAAb,UAAK,GAAL,KAAK,CAAQ;IAAG,CAAC;IAExC,kBAAI,GAAlB,UAAmB,SAAiB;QAClC,IAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAA;QAE5C,IAAM,UAAU,GAAW,GAAG,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAA;QAChE,IAAM,IAAI,GAAG,IAAI,SAAS,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,EAAE,CAAA;QACrE,IAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,aAAa,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;QAEhF,OAAO,IAAI,aAAa,CAAC,OAAO,CAAC,CAAA;IACnC,CAAC;IAEM,gCAAQ,GAAf;QACE,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;IAhBuB,2BAAa,GAAW,QAAQ,CAAA;IAiB1D,oBAAC;CAAA,AAlBD,IAkBC;AAlBY,sCAAa"}
@@ -0,0 +1,19 @@
1
+ import BigNumber from '@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber';
2
+ import { JSONConvertible } from '@airgap/coinlib-core/interfaces/JSONConvertible';
3
+ import { RPCConvertible } from '@airgap/coinlib-core/interfaces/RPCConvertible';
4
+ export interface CosmosCoinJSON {
5
+ denom: string;
6
+ amount: string;
7
+ }
8
+ export declare class CosmosCoin implements JSONConvertible, RPCConvertible {
9
+ private static readonly supportedDenominations;
10
+ readonly denom: string;
11
+ readonly amount: string;
12
+ constructor(denom: string, amount: string);
13
+ toJSON(): CosmosCoinJSON;
14
+ static fromJSON(json: CosmosCoinJSON): CosmosCoin;
15
+ static fromCoins(json: CosmosCoinJSON[]): CosmosCoin[];
16
+ static sum(coins: CosmosCoin[]): BigNumber;
17
+ toRPCBody(): any;
18
+ static fromRPCBody(json: any): CosmosCoin;
19
+ }
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.CosmosCoin = void 0;
7
+ var bignumber_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber"));
8
+ var errors_1 = require("@airgap/coinlib-core/errors");
9
+ var coinlib_error_1 = require("@airgap/coinlib-core/errors/coinlib-error");
10
+ var CosmosCoin = /** @class */ (function () {
11
+ function CosmosCoin(denom, amount) {
12
+ this.denom = denom;
13
+ this.amount = amount;
14
+ }
15
+ CosmosCoin.prototype.toJSON = function () {
16
+ return {
17
+ amount: this.amount,
18
+ denom: this.denom
19
+ };
20
+ };
21
+ CosmosCoin.fromJSON = function (json) {
22
+ if (!CosmosCoin.supportedDenominations.includes(json.denom)) {
23
+ throw new errors_1.UnsupportedError(coinlib_error_1.Domain.COSMOS, 'Unsupported cosmos denomination');
24
+ }
25
+ return new CosmosCoin(json.denom, json.amount);
26
+ };
27
+ CosmosCoin.fromCoins = function (json) {
28
+ return json
29
+ .map(function (coinJSON) {
30
+ try {
31
+ return CosmosCoin.fromJSON(coinJSON);
32
+ }
33
+ catch (_a) {
34
+ return undefined;
35
+ }
36
+ })
37
+ .filter(function (value) { return value !== undefined; });
38
+ };
39
+ CosmosCoin.sum = function (coins) {
40
+ return coins.reduce(function (current, next) { return current.plus(new bignumber_1.default(next.amount)); }, new bignumber_1.default(0));
41
+ };
42
+ CosmosCoin.prototype.toRPCBody = function () {
43
+ return {
44
+ amount: this.amount,
45
+ denom: this.denom
46
+ };
47
+ };
48
+ CosmosCoin.fromRPCBody = function (json) {
49
+ return new CosmosCoin(json.denom, json.amount);
50
+ };
51
+ CosmosCoin.supportedDenominations = ['uatom'];
52
+ return CosmosCoin;
53
+ }());
54
+ exports.CosmosCoin = CosmosCoin;
55
+ //# sourceMappingURL=CosmosCoin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CosmosCoin.js","sourceRoot":"","sources":["../../src/protocol/CosmosCoin.ts"],"names":[],"mappings":";;;;;;AAAA,iHAA0F;AAC1F,sDAA8D;AAC9D,2EAAkE;AASlE;IAKE,oBAAY,KAAa,EAAE,MAAc;QACvC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAEM,2BAAM,GAAb;QACE,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB,CAAA;IACH,CAAC;IAEa,mBAAQ,GAAtB,UAAuB,IAAoB;QACzC,IAAI,CAAC,UAAU,CAAC,sBAAsB,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;YAC3D,MAAM,IAAI,yBAAgB,CAAC,sBAAM,CAAC,MAAM,EAAE,iCAAiC,CAAC,CAAA;SAC7E;QAED,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;IAChD,CAAC;IAEa,oBAAS,GAAvB,UAAwB,IAAsB;QAC5C,OAAO,IAAI;aACR,GAAG,CAAC,UAAC,QAAQ;YACZ,IAAI;gBACF,OAAO,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;aACrC;YAAC,WAAM;gBACN,OAAO,SAAS,CAAA;aACjB;QACH,CAAC,CAAC;aACD,MAAM,CAAC,UAAC,KAAK,IAAK,OAAA,KAAK,KAAK,SAAS,EAAnB,CAAmB,CAAiB,CAAA;IAC3D,CAAC;IAEa,cAAG,GAAjB,UAAkB,KAAmB;QACnC,OAAO,KAAK,CAAC,MAAM,CAAC,UAAC,OAAO,EAAE,IAAI,IAAK,OAAA,OAAO,CAAC,IAAI,CAAC,IAAI,mBAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAxC,CAAwC,EAAE,IAAI,mBAAS,CAAC,CAAC,CAAC,CAAC,CAAA;IACpG,CAAC;IAEM,8BAAS,GAAhB;QACE,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB,CAAA;IACH,CAAC;IAEa,sBAAW,GAAzB,UAA0B,IAAS;QACjC,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;IAChD,CAAC;IAjDuB,iCAAsB,GAAG,CAAC,OAAO,CAAC,CAAA;IAkD5D,iBAAC;CAAA,AAnDD,IAmDC;AAnDY,gCAAU"}
@@ -0,0 +1,8 @@
1
+ import { Secp256k1CryptoClient } from '@airgap/coinlib-core/protocols/Secp256k1CryptoClient';
2
+ export declare class CosmosCryptoClient extends Secp256k1CryptoClient {
3
+ constructor();
4
+ signMessage(message: string, keypair: {
5
+ privateKey: string;
6
+ }): Promise<string>;
7
+ verifyMessage(message: string, signature: string, publicKey: string): Promise<boolean>;
8
+ }
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ extendStatics(d, b);
11
+ function __() { this.constructor = d; }
12
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
+ };
14
+ })();
15
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
16
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
17
+ return new (P || (P = Promise))(function (resolve, reject) {
18
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
19
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
20
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
21
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
22
+ });
23
+ };
24
+ var __generator = (this && this.__generator) || function (thisArg, body) {
25
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
26
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
27
+ function verb(n) { return function (v) { return step([n, v]); }; }
28
+ function step(op) {
29
+ if (f) throw new TypeError("Generator is already executing.");
30
+ while (_) try {
31
+ 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;
32
+ if (y = 0, t) op = [op[0] & 2, t.value];
33
+ switch (op[0]) {
34
+ case 0: case 1: t = op; break;
35
+ case 4: _.label++; return { value: op[1], done: false };
36
+ case 5: _.label++; y = op[1]; op = [0]; continue;
37
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
38
+ default:
39
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
40
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
41
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
42
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
43
+ if (t[2]) _.ops.pop();
44
+ _.trys.pop(); continue;
45
+ }
46
+ op = body.call(thisArg, _);
47
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
48
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
49
+ }
50
+ };
51
+ Object.defineProperty(exports, "__esModule", { value: true });
52
+ exports.CosmosCryptoClient = void 0;
53
+ var SECP256K1 = require("@airgap/coinlib-core/dependencies/src/secp256k1-3.7.1/elliptic");
54
+ var sha = require("@airgap/coinlib-core/dependencies/src/sha.js-2.4.11/index");
55
+ var Secp256k1CryptoClient_1 = require("@airgap/coinlib-core/protocols/Secp256k1CryptoClient");
56
+ var CosmosCryptoClient = /** @class */ (function (_super) {
57
+ __extends(CosmosCryptoClient, _super);
58
+ function CosmosCryptoClient() {
59
+ return _super.call(this) || this;
60
+ }
61
+ CosmosCryptoClient.prototype.signMessage = function (message, keypair) {
62
+ return __awaiter(this, void 0, void 0, function () {
63
+ var sha256Hash, hash, signed;
64
+ return __generator(this, function (_a) {
65
+ sha256Hash = sha('sha256').update(Buffer.from(message)).digest();
66
+ hash = Buffer.from(sha256Hash);
67
+ signed = SECP256K1.sign(hash, Buffer.from(keypair.privateKey, 'hex'));
68
+ return [2 /*return*/, "0x" + Buffer.from(signed.signature).toString('hex')];
69
+ });
70
+ });
71
+ };
72
+ CosmosCryptoClient.prototype.verifyMessage = function (message, signature, publicKey) {
73
+ return __awaiter(this, void 0, void 0, function () {
74
+ var rawSignature, sha256Hash, messageHash;
75
+ return __generator(this, function (_a) {
76
+ rawSignature = Buffer.from(signature.slice(2), 'hex');
77
+ sha256Hash = sha('sha256').update(Buffer.from(message)).digest();
78
+ messageHash = Buffer.from(sha256Hash);
79
+ return [2 /*return*/, SECP256K1.verify(messageHash, rawSignature, Buffer.from(publicKey, 'hex'))];
80
+ });
81
+ });
82
+ };
83
+ return CosmosCryptoClient;
84
+ }(Secp256k1CryptoClient_1.Secp256k1CryptoClient));
85
+ exports.CosmosCryptoClient = CosmosCryptoClient;
86
+ //# sourceMappingURL=CosmosCryptoClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CosmosCryptoClient.js","sourceRoot":"","sources":["../../src/protocol/CosmosCryptoClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0FAA4F;AAC5F,+EAAiF;AACjF,8FAA4F;AAE5F;IAAwC,sCAAqB;IAC3D;eACE,iBAAO;IACT,CAAC;IAEY,wCAAW,GAAxB,UAAyB,OAAe,EAAE,OAA+B;;;;gBACjE,UAAU,GAAW,GAAG,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,CAAA;gBACxE,IAAI,GAAW,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;gBACtC,MAAM,GAA0B,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAA;gBAElG,sBAAO,OAAK,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAG,EAAA;;;KAC5D;IAEY,0CAAa,GAA1B,UAA2B,OAAe,EAAE,SAAiB,EAAE,SAAiB;;;;gBACxE,YAAY,GAAW,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;gBAE7D,UAAU,GAAW,GAAG,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,CAAA;gBACxE,WAAW,GAAW,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;gBAEnD,sBAAO,SAAS,CAAC,MAAM,CAAC,WAAW,EAAE,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,EAAA;;;KAClF;IACH,yBAAC;AAAD,CAAC,AArBD,CAAwC,6CAAqB,GAqB5D;AArBY,gDAAkB"}
@@ -0,0 +1,15 @@
1
+ import { JSONConvertible } from '@airgap/coinlib-core/interfaces/JSONConvertible';
2
+ import { RPCConvertible } from '@airgap/coinlib-core/interfaces/RPCConvertible';
3
+ import { CosmosCoin } from './CosmosCoin';
4
+ export declare class CosmosFee implements JSONConvertible, RPCConvertible {
5
+ readonly amount: CosmosCoin[];
6
+ readonly gas: string;
7
+ constructor(amount: CosmosCoin[], gas: string);
8
+ toJSON(): {
9
+ amount: import("./CosmosCoin").CosmosCoinJSON[];
10
+ gas: string;
11
+ };
12
+ static fromJSON(json: any): CosmosFee;
13
+ toRPCBody(): any;
14
+ static fromRPCBody(json: any): CosmosFee;
15
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CosmosFee = void 0;
4
+ var CosmosCoin_1 = require("./CosmosCoin");
5
+ var CosmosFee = /** @class */ (function () {
6
+ function CosmosFee(amount, gas) {
7
+ this.amount = amount;
8
+ this.gas = gas;
9
+ }
10
+ CosmosFee.prototype.toJSON = function () {
11
+ return {
12
+ amount: this.amount.map(function (value) { return value.toJSON(); }),
13
+ gas: this.gas
14
+ };
15
+ };
16
+ CosmosFee.fromJSON = function (json) {
17
+ return new CosmosFee(json.amount.map(function (value) { return CosmosCoin_1.CosmosCoin.fromJSON(value); }), json.gas);
18
+ };
19
+ CosmosFee.prototype.toRPCBody = function () {
20
+ return {
21
+ amount: this.amount.map(function (value) { return value.toRPCBody(); }),
22
+ gas: this.gas
23
+ };
24
+ };
25
+ CosmosFee.fromRPCBody = function (json) {
26
+ return new CosmosFee(json.amount.map(function (value) { return CosmosCoin_1.CosmosCoin.fromRPCBody(value); }), json.gas);
27
+ };
28
+ return CosmosFee;
29
+ }());
30
+ exports.CosmosFee = CosmosFee;
31
+ //# sourceMappingURL=CosmosFee.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CosmosFee.js","sourceRoot":"","sources":["../../src/protocol/CosmosFee.ts"],"names":[],"mappings":";;;AAEA,2CAAyC;AAEzC;IAIE,mBAAY,MAAoB,EAAE,GAAW;QAC3C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;IAChB,CAAC;IAEM,0BAAM,GAAb;QACE,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAC,KAAK,IAAK,OAAA,KAAK,CAAC,MAAM,EAAE,EAAd,CAAc,CAAC;YAClD,GAAG,EAAE,IAAI,CAAC,GAAG;SACd,CAAA;IACH,CAAC;IAEa,kBAAQ,GAAtB,UAAuB,IAAS;QAC9B,OAAO,IAAI,SAAS,CAClB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAC,KAAU,IAAK,OAAA,uBAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,EAA1B,CAA0B,CAAC,EAC3D,IAAI,CAAC,GAAG,CACT,CAAA;IACH,CAAC;IAEM,6BAAS,GAAhB;QACE,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAC,KAAK,IAAK,OAAA,KAAK,CAAC,SAAS,EAAE,EAAjB,CAAiB,CAAC;YACrD,GAAG,EAAE,IAAI,CAAC,GAAG;SACd,CAAA;IACH,CAAC;IAEa,qBAAW,GAAzB,UAA0B,IAAS;QACjC,OAAO,IAAI,SAAS,CAClB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAC,KAAU,IAAK,OAAA,uBAAU,CAAC,WAAW,CAAC,KAAK,CAAC,EAA7B,CAA6B,CAAC,EAC9D,IAAI,CAAC,GAAG,CACT,CAAA;IACH,CAAC;IACH,gBAAC;AAAD,CAAC,AApCD,IAoCC;AApCY,8BAAS"}
@@ -0,0 +1,25 @@
1
+ import BigNumber from '@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber';
2
+ import { CosmosAccount, CosmosDelegation, CosmosNodeInfo, CosmosPagedSendTxsResponse, CosmosRewardDetails, CosmosUnbondingDelegation, CosmosValidator } from './CosmosTypes';
3
+ export declare class CosmosNodeClient {
4
+ readonly baseURL: string;
5
+ useCORSProxy: boolean;
6
+ constructor(baseURL: string, useCORSProxy?: boolean);
7
+ fetchBalance(address: string, totalBalance?: boolean): Promise<BigNumber>;
8
+ fetchSendTransactionsFor(address: string, limit: number, offset: number, isSender?: boolean): Promise<CosmosPagedSendTxsResponse>;
9
+ fetchNodeInfo(): Promise<CosmosNodeInfo>;
10
+ broadcastSignedTransaction(tx_bytes: string): Promise<string>;
11
+ fetchAccount(address: string): Promise<CosmosAccount>;
12
+ fetchDelegations(address: string, filterEmpty?: boolean): Promise<CosmosDelegation[]>;
13
+ fetchTotalDelegatedAmount(address: string): Promise<BigNumber>;
14
+ fetchValidator(address: string): Promise<CosmosValidator>;
15
+ fetchValidators(): Promise<CosmosValidator[]>;
16
+ fetchSelfDelegation(validatorAddress: string): Promise<CosmosDelegation>;
17
+ fetchUnbondingDelegations(delegatorAddress: string): Promise<CosmosUnbondingDelegation[]>;
18
+ fetchTotalUnbondingAmount(address: string): Promise<BigNumber>;
19
+ fetchRewardDetails(delegatorAddress: string): Promise<CosmosRewardDetails[]>;
20
+ fetchTotalReward(delegatorAddress: string): Promise<BigNumber>;
21
+ fetchRewardForDelegation(delegatorAddress: string, validatorAddress: string): Promise<BigNumber>;
22
+ withdrawAllDelegationRewards(delegatorAddress: string, chainID: string, accountNumber: string, sequence: string, gas: BigNumber, fee: BigNumber, memo: string, simulate?: boolean): Promise<string>;
23
+ withdrawDelegationRewards(delegatorAddress: string, validatorAdress: string, chainID: string, accountNumber: string, sequence: string, gas: BigNumber, fee: BigNumber, memo: string, simulate?: boolean): Promise<string>;
24
+ private url;
25
+ }