@wallfree-dev/cosmos 0.13.42
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.
- package/LICENSE.md +7 -0
- package/index.d.ts +1 -0
- package/index.js +18 -0
- package/index.js.map +1 -0
- package/package.json +62 -0
- package/readme.md +121 -0
- package/v0/index.d.ts +10 -0
- package/v0/index.js +32 -0
- package/v0/index.js.map +1 -0
- package/v0/protocol/CosmosAddress.d.ts +8 -0
- package/v0/protocol/CosmosAddress.js +28 -0
- package/v0/protocol/CosmosAddress.js.map +1 -0
- package/v0/protocol/CosmosCoin.d.ts +19 -0
- package/v0/protocol/CosmosCoin.js +55 -0
- package/v0/protocol/CosmosCoin.js.map +1 -0
- package/v0/protocol/CosmosCryptoClient.d.ts +8 -0
- package/v0/protocol/CosmosCryptoClient.js +90 -0
- package/v0/protocol/CosmosCryptoClient.js.map +1 -0
- package/v0/protocol/CosmosFee.d.ts +15 -0
- package/v0/protocol/CosmosFee.js +31 -0
- package/v0/protocol/CosmosFee.js.map +1 -0
- package/v0/protocol/CosmosNodeClient.d.ts +25 -0
- package/v0/protocol/CosmosNodeClient.js +382 -0
- package/v0/protocol/CosmosNodeClient.js.map +1 -0
- package/v0/protocol/CosmosProtocol.d.ts +125 -0
- package/v0/protocol/CosmosProtocol.js +1162 -0
- package/v0/protocol/CosmosProtocol.js.map +1 -0
- package/v0/protocol/CosmosProtocolOptions.d.ts +22 -0
- package/v0/protocol/CosmosProtocolOptions.js +116 -0
- package/v0/protocol/CosmosProtocolOptions.js.map +1 -0
- package/v0/protocol/CosmosTransaction.d.ts +37 -0
- package/v0/protocol/CosmosTransaction.js +106 -0
- package/v0/protocol/CosmosTransaction.js.map +1 -0
- package/v0/protocol/CosmosTypes.d.ts +310 -0
- package/v0/protocol/CosmosTypes.js +8 -0
- package/v0/protocol/CosmosTypes.js.map +1 -0
- package/v0/protocol/cosmos-message/CosmosDelegateMessage.d.ts +20 -0
- package/v0/protocol/cosmos-message/CosmosDelegateMessage.js +72 -0
- package/v0/protocol/cosmos-message/CosmosDelegateMessage.js.map +1 -0
- package/v0/protocol/cosmos-message/CosmosMessage.d.ts +39 -0
- package/v0/protocol/cosmos-message/CosmosMessage.js +47 -0
- package/v0/protocol/cosmos-message/CosmosMessage.js.map +1 -0
- package/v0/protocol/cosmos-message/CosmosSendMessage.d.ts +20 -0
- package/v0/protocol/cosmos-message/CosmosSendMessage.js +85 -0
- package/v0/protocol/cosmos-message/CosmosSendMessage.js.map +1 -0
- package/v0/protocol/cosmos-message/CosmosWithdrawDelegationRewardMessage.d.ts +24 -0
- package/v0/protocol/cosmos-message/CosmosWithdrawDelegationRewardMessage.js +61 -0
- package/v0/protocol/cosmos-message/CosmosWithdrawDelegationRewardMessage.js.map +1 -0
- package/v0/serializer/schemas/v2/transaction-sign-request-cosmos.json +100 -0
- package/v0/serializer/schemas/v2/transaction-sign-response-cosmos.json +22 -0
- package/v0/serializer/schemas/v3/transaction-sign-request-cosmos.json +100 -0
- package/v0/serializer/schemas/v3/transaction-sign-response-cosmos.json +23 -0
- package/v0/serializer/validators/transaction-validator.d.ts +15 -0
- package/v0/serializer/validators/transaction-validator.js +112 -0
- package/v0/serializer/validators/transaction-validator.js.map +1 -0
- package/v0/types/signed-transaction-cosmos.d.ts +5 -0
- package/v0/types/signed-transaction-cosmos.js +3 -0
- package/v0/types/signed-transaction-cosmos.js.map +1 -0
- package/v0/types/transaction-cosmos.d.ts +5 -0
- package/v0/types/transaction-cosmos.js +3 -0
- package/v0/types/transaction-cosmos.js.map +1 -0
- package/v0/types/unsigned-transaction-cosmos.d.ts +33 -0
- package/v0/types/unsigned-transaction-cosmos.js +10 -0
- package/v0/types/unsigned-transaction-cosmos.js.map +1 -0
- package/v1/block-explorer/MintscanBlockExplorer.d.ts +9 -0
- package/v1/block-explorer/MintscanBlockExplorer.js +72 -0
- package/v1/block-explorer/MintscanBlockExplorer.js.map +1 -0
- package/v1/index.d.ts +6 -0
- package/v1/index.js +11 -0
- package/v1/index.js.map +1 -0
- package/v1/module/CosmosModule.d.ts +17 -0
- package/v1/module/CosmosModule.js +107 -0
- package/v1/module/CosmosModule.js.map +1 -0
- package/v1/module.d.ts +3 -0
- package/v1/module.js +24 -0
- package/v1/module.js.map +1 -0
- package/v1/protocol/CosmosProtocol.d.ts +16 -0
- package/v1/protocol/CosmosProtocol.js +162 -0
- package/v1/protocol/CosmosProtocol.js.map +1 -0
- package/v1/serializer/v3/serializer-companion.d.ts +12 -0
- package/v1/serializer/v3/serializer-companion.js +142 -0
- package/v1/serializer/v3/serializer-companion.js.map +1 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2019 Papers AG
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './v1';
|
package/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./v1"), exports);
|
|
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,uCAAoB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wallfree-dev/cosmos",
|
|
3
|
+
"version": "0.13.42",
|
|
4
|
+
"description": "The @wallfree-dev/cosmos is a Cosmos implementation of the ICoinProtocol interface from @wallfree-dev/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/copy-files-after-build.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": "TS_NODE_PROJECT='./test/tsconfig.json' nyc mocha --bail --require ts-node/register --require tsconfig-paths/register --require source-map-support/register --full-trace --delay --timeout 40000 ./test/**/**.spec.ts",
|
|
28
|
+
"test-ci": "nyc --reporter=lcov npm test",
|
|
29
|
+
"browserify": "browserify ./dist/index.js -s airgapCoinLibCosmos > ./dist/airgap-coinlib-cosmos.min.js"
|
|
30
|
+
},
|
|
31
|
+
"author": "Papers AG <contact@papers.ch> (https://papers.ch)",
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@wallfree-dev/coinlib-core": "^0.13.42",
|
|
34
|
+
"@wallfree-dev/cosmos-core": "^0.13.42",
|
|
35
|
+
"@wallfree-dev/crypto": "^0.13.42",
|
|
36
|
+
"@wallfree-dev/module-kit": "^0.13.42",
|
|
37
|
+
"@wallfree-dev/serializer": "^0.13.42"
|
|
38
|
+
},
|
|
39
|
+
"localDependencies": {},
|
|
40
|
+
"nyc": {
|
|
41
|
+
"include": [
|
|
42
|
+
"src/**/*.ts"
|
|
43
|
+
],
|
|
44
|
+
"exclude": [
|
|
45
|
+
"test/**/*.spec.ts"
|
|
46
|
+
],
|
|
47
|
+
"extension": [
|
|
48
|
+
".ts"
|
|
49
|
+
],
|
|
50
|
+
"require": [
|
|
51
|
+
"ts-node/register"
|
|
52
|
+
],
|
|
53
|
+
"reporter": [
|
|
54
|
+
"text",
|
|
55
|
+
"text-summary"
|
|
56
|
+
],
|
|
57
|
+
"report-dir": "../../coverage/cosmos",
|
|
58
|
+
"sourceMap": true,
|
|
59
|
+
"instrument": true
|
|
60
|
+
},
|
|
61
|
+
"gitHead": "8e8feb6788204501b7173aa825f5456c2a5f185b"
|
|
62
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# AirGap Coin Library
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/airgap-coin-lib)
|
|
4
|
+
[](https://airgap-it.github.io/airgap-coin-lib/)
|
|
5
|
+
[](https://travis-ci.org/airgap-it/airgap-coin-lib/)
|
|
6
|
+
[](https://codecov.io/gh/airgap-it/airgap-coin-lib/)
|
|
7
|
+
|
|
8
|
+
The `airgap-coin-lib` is a protocol-agnostic library that allows easy handling of the most important tasks relating cryptocurrencies and blockchains.
|
|
9
|
+
|
|
10
|
+
It implements operations such as preparing, signing and broadcasting transactions for a range of protocols.
|
|
11
|
+
|
|
12
|
+
The library consists of a shared interface for all implemented protocols. This is especially useful in the context of AirGap because methods are designed to support offline key management and signing. The following core operations are specified:
|
|
13
|
+
|
|
14
|
+
- `prepareTransaction` - This is done on AirGap Wallet (online) side. Either a public key or extended public key is used and will fetch the required information from the network.
|
|
15
|
+
- `signTransaction` - This is done in AirGap Vault (offline) side. The output of "prepareTransaction" is the input for this method (hence the output of "prepareTransaction" is transferred via URL scheme (same-device) or QR code (2-device-setup)).
|
|
16
|
+
- `broadcastTransaction` - This is done in AirGap Wallet (online) side. The output of "signTransaction" is the input for this method (hence the output of "signTransaction" is transferred via URL scheme (same-device) or QR code (2-device-setup)).
|
|
17
|
+
|
|
18
|
+
## Supported Protocols
|
|
19
|
+
|
|
20
|
+
The modular design used in this library allows you to simply add new protocols with special logic. Adding a new Bitcoin-like protocol basically means:
|
|
21
|
+
|
|
22
|
+
1. select the correct network parameters (see `src/networks.ts`)
|
|
23
|
+
2. set the Insight API URL to communicate with the blockchain
|
|
24
|
+
|
|
25
|
+
Adding a new Ethereum-like protocol means:
|
|
26
|
+
|
|
27
|
+
1. set the correct chain id
|
|
28
|
+
2. set the JSON RPC URL
|
|
29
|
+
|
|
30
|
+
Currently supported are:
|
|
31
|
+
|
|
32
|
+
- Bitcoin
|
|
33
|
+
- Ethereum
|
|
34
|
+
- Generic ERC20 Tokens
|
|
35
|
+
- Aeternity
|
|
36
|
+
- Tezos
|
|
37
|
+
- FA1.2 tokens
|
|
38
|
+
- tzBTC
|
|
39
|
+
- USDtz
|
|
40
|
+
- FA2 tokens
|
|
41
|
+
- Groestlcoin
|
|
42
|
+
- Cosmos
|
|
43
|
+
- Polkadot
|
|
44
|
+
- Kusama
|
|
45
|
+
|
|
46
|
+
## Features
|
|
47
|
+
|
|
48
|
+
### Protocols
|
|
49
|
+
|
|
50
|
+
The way the interface was designed is to allow stateless calls. This means the class stores very little state itself.
|
|
51
|
+
All required input comes from the method params (public key, extended public key, etc...)
|
|
52
|
+
|
|
53
|
+
Currently we support for Bitcoin-like (UTXO) protocols:
|
|
54
|
+
|
|
55
|
+
- Single Address Wallets (deprecated)
|
|
56
|
+
- HD Wallets
|
|
57
|
+
|
|
58
|
+
Currently we support for Ethereum-like (Account-based) protocols:
|
|
59
|
+
|
|
60
|
+
- Single Address Wallets
|
|
61
|
+
|
|
62
|
+
### Delegation
|
|
63
|
+
|
|
64
|
+
There is a different interface that can be implemented if the protocol supports delegation. The delegation flow usually requires some changes in the user interface of the AirGap Wallet as well.
|
|
65
|
+
|
|
66
|
+
### Inter App Communication
|
|
67
|
+
|
|
68
|
+
A serializer is included that encodes JSON structures with RLP and base58check. Those strings can then be sent to the other app, either through QR codes or a URL. The serializer can only serialize messages in predefined formats, so new message types have to be added when new protocols are added.
|
|
69
|
+
|
|
70
|
+
### Tezos FA1.2 and FA2 tokens
|
|
71
|
+
|
|
72
|
+
It is possible to interact (fetch balances, create transfers, etc.) with an FA1.2 and FA2 smart contracts using the `TezosFA12Protocol` and `TezosFA2Protocol` classes. An example on how to use them can be found in `examples/custom/protocols/tezos/fa2-smart-contract.ts`.
|
|
73
|
+
|
|
74
|
+
## Synchronising information between wallet and vault
|
|
75
|
+
|
|
76
|
+
Such that the system works we need to be able to synchronise wallets. A wallet can be:
|
|
77
|
+
|
|
78
|
+
- Single Address Wallet
|
|
79
|
+
- HD Wallet
|
|
80
|
+
|
|
81
|
+
For the single address wallet we only need to share the public key. For HD Wallet we need to share the extended public key.
|
|
82
|
+
|
|
83
|
+
## Getting started
|
|
84
|
+
|
|
85
|
+
### Requirements
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
npm >= 6
|
|
89
|
+
NodeJS >= 12
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Build dependencies get installed using `npm install`.
|
|
93
|
+
|
|
94
|
+
### Clone and Run
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
$ git clone https://github.com/airgap-it/airgap-coin-lib.git
|
|
98
|
+
$ cd airgap-coin-lib
|
|
99
|
+
$ npm install
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
To run the tests, you will have to install the test dependencies
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
$ npm run install-test-dependencies
|
|
106
|
+
$ npm test
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
To remove the test dependencies and clean up the `package.json` and `package-lock.json`, execute this command
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
$ npm run install-build-dependencies
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Contributing
|
|
116
|
+
|
|
117
|
+
We welcome contributions from the community. Simple readme updates or bugfixes can be addressed with a PR directly.
|
|
118
|
+
|
|
119
|
+
For larger changes like new protocols, new features or larger refactorings, please contact us first by opening an issue. This project is under constant development and until version `1.x.x` has been reached, there will be frequent breaking changes. So make sure to take a look at the `develop` branch.
|
|
120
|
+
|
|
121
|
+
Regarding new protocols / currencies, we cannot guarantee that they will be merged, but we're more than happy to discuss the details of a specific integration in a github issue.
|
package/v0/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/v0/index.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
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 coinlib_core_1 = require("@wallfree-dev/coinlib-core");
|
|
5
|
+
var serializer_1 = require("@wallfree-dev/serializer");
|
|
6
|
+
var CosmosAddress_1 = require("./protocol/CosmosAddress");
|
|
7
|
+
Object.defineProperty(exports, "CosmosAddress", { enumerable: true, get: function () { return CosmosAddress_1.CosmosAddress; } });
|
|
8
|
+
var CosmosCryptoClient_1 = require("./protocol/CosmosCryptoClient");
|
|
9
|
+
Object.defineProperty(exports, "CosmosCryptoClient", { enumerable: true, get: function () { return CosmosCryptoClient_1.CosmosCryptoClient; } });
|
|
10
|
+
var CosmosProtocol_1 = require("./protocol/CosmosProtocol");
|
|
11
|
+
Object.defineProperty(exports, "CosmosDelegationActionType", { enumerable: true, get: function () { return CosmosProtocol_1.CosmosDelegationActionType; } });
|
|
12
|
+
Object.defineProperty(exports, "CosmosProtocol", { enumerable: true, get: function () { return CosmosProtocol_1.CosmosProtocol; } });
|
|
13
|
+
var CosmosProtocolOptions_1 = require("./protocol/CosmosProtocolOptions");
|
|
14
|
+
Object.defineProperty(exports, "CosmosProtocolConfig", { enumerable: true, get: function () { return CosmosProtocolOptions_1.CosmosProtocolConfig; } });
|
|
15
|
+
Object.defineProperty(exports, "CosmosProtocolNetwork", { enumerable: true, get: function () { return CosmosProtocolOptions_1.CosmosProtocolNetwork; } });
|
|
16
|
+
Object.defineProperty(exports, "CosmosProtocolOptions", { enumerable: true, get: function () { return CosmosProtocolOptions_1.CosmosProtocolOptions; } });
|
|
17
|
+
Object.defineProperty(exports, "MintscanBlockExplorer", { enumerable: true, get: function () { return CosmosProtocolOptions_1.MintscanBlockExplorer; } });
|
|
18
|
+
var CosmosTransaction_1 = require("./protocol/CosmosTransaction");
|
|
19
|
+
Object.defineProperty(exports, "CosmosTransaction", { enumerable: true, get: function () { return CosmosTransaction_1.CosmosTransaction; } });
|
|
20
|
+
var transaction_validator_1 = require("./serializer/validators/transaction-validator");
|
|
21
|
+
// Serializer
|
|
22
|
+
function unsignedTransactionTransformer(value) {
|
|
23
|
+
value.transaction = CosmosTransaction_1.CosmosTransaction.fromJSON(value);
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
serializer_1.Serializer.addSchema(serializer_1.IACMessageType.TransactionSignRequest, { schema: require('./serializer/schemas/v2/transaction-sign-request-cosmos.json'), transformer: unsignedTransactionTransformer }, coinlib_core_1.MainProtocolSymbols.COSMOS);
|
|
27
|
+
serializer_1.Serializer.addSchema(serializer_1.IACMessageType.TransactionSignResponse, { schema: require('./serializer/schemas/v2/transaction-sign-response-cosmos.json') }, coinlib_core_1.MainProtocolSymbols.COSMOS);
|
|
28
|
+
serializer_1.SerializerV3.addSchema(serializer_1.IACMessageType.TransactionSignRequest, { schema: require('./serializer/schemas/v3/transaction-sign-request-cosmos.json'), transformer: unsignedTransactionTransformer }, coinlib_core_1.MainProtocolSymbols.COSMOS);
|
|
29
|
+
serializer_1.SerializerV3.addSchema(serializer_1.IACMessageType.TransactionSignResponse, { schema: require('./serializer/schemas/v3/transaction-sign-response-cosmos.json') }, coinlib_core_1.MainProtocolSymbols.COSMOS);
|
|
30
|
+
serializer_1.Serializer.addValidator(coinlib_core_1.MainProtocolSymbols.COSMOS, new transaction_validator_1.CosmosTransactionValidatorFactoryV2());
|
|
31
|
+
serializer_1.SerializerV3.addValidator(coinlib_core_1.MainProtocolSymbols.COSMOS, new transaction_validator_1.CosmosTransactionValidatorFactory());
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
package/v0/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/v0/index.ts"],"names":[],"mappings":";;;AAAA,2DAAgE;AAChE,uDAAmF;AAEnF,0DAAwD;AAqBtD,8FArBO,6BAAa,OAqBP;AApBf,oEAAkE;AAYhE,mGAZO,uCAAkB,OAYP;AAXpB,4DAAsF;AAkBpF,2GAlBO,2CAA0B,OAkBP;AAR1B,+FAVmC,+BAAc,OAUnC;AAThB,0EAA4I;AAa1I,qGAbO,4CAAoB,OAaP;AADpB,sGAZ6B,6CAAqB,OAY7B;AAErB,sGAdoD,6CAAqB,OAcpD;AAHrB,sGAX2E,6CAAqB,OAW3E;AAVvB,kEAAgE;AAkB9D,kGAlBO,qCAAiB,OAkBP;AAhBnB,uFAAsI;AAsBtI,aAAa;AAEb,SAAS,8BAA8B,CAAC,KAA4C;IAClF,KAAK,CAAC,WAAW,GAAG,qCAAiB,CAAC,QAAQ,CAAC,KAAK,CAAQ,CAAA;IAE5D,OAAO,KAAK,CAAA;AACd,CAAC;AAED,uBAAU,CAAC,SAAS,CAClB,2BAAc,CAAC,sBAAsB,EACrC,EAAE,MAAM,EAAE,OAAO,CAAC,8DAA8D,CAAC,EAAE,WAAW,EAAE,8BAA8B,EAAE,EAChI,kCAAmB,CAAC,MAAM,CAC3B,CAAA;AACD,uBAAU,CAAC,SAAS,CAClB,2BAAc,CAAC,uBAAuB,EACtC,EAAE,MAAM,EAAE,OAAO,CAAC,+DAA+D,CAAC,EAAE,EACpF,kCAAmB,CAAC,MAAM,CAC3B,CAAA;AAED,yBAAY,CAAC,SAAS,CACpB,2BAAc,CAAC,sBAAsB,EACrC,EAAE,MAAM,EAAE,OAAO,CAAC,8DAA8D,CAAC,EAAE,WAAW,EAAE,8BAA8B,EAAE,EAChI,kCAAmB,CAAC,MAAM,CAC3B,CAAA;AACD,yBAAY,CAAC,SAAS,CACpB,2BAAc,CAAC,uBAAuB,EACtC,EAAE,MAAM,EAAE,OAAO,CAAC,+DAA+D,CAAC,EAAE,EACpF,kCAAmB,CAAC,MAAM,CAC3B,CAAA;AAED,uBAAU,CAAC,YAAY,CAAC,kCAAmB,CAAC,MAAM,EAAE,IAAI,2DAAmC,EAAE,CAAC,CAAA;AAC9F,yBAAY,CAAC,YAAY,CAAC,kCAAmB,CAAC,MAAM,EAAE,IAAI,yDAAiC,EAAE,CAAC,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IAirGapAddress } from '@wallfree-dev/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,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CosmosAddress = void 0;
|
|
4
|
+
// @ts-ignore
|
|
5
|
+
var BECH32 = require("@wallfree-dev/coinlib-core/dependencies/src/bech32-1.1.3/index");
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
var RIPEMD160 = require("@wallfree-dev/coinlib-core/dependencies/src/ripemd160-2.0.2/index");
|
|
8
|
+
// @ts-ignore
|
|
9
|
+
var sha = require("@wallfree-dev/coinlib-core/dependencies/src/sha.js-2.4.11/index");
|
|
10
|
+
var CosmosAddress = /** @class */ (function () {
|
|
11
|
+
function CosmosAddress(value) {
|
|
12
|
+
this.value = value;
|
|
13
|
+
}
|
|
14
|
+
CosmosAddress.from = function (publicKey) {
|
|
15
|
+
var pubkey = Buffer.from(publicKey, 'hex');
|
|
16
|
+
var sha256Hash = sha('sha256').update(pubkey).digest();
|
|
17
|
+
var hash = new RIPEMD160().update(Buffer.from(sha256Hash)).digest();
|
|
18
|
+
var address = BECH32.encode(CosmosAddress.addressPrefix, BECH32.toWords(hash));
|
|
19
|
+
return new CosmosAddress(address);
|
|
20
|
+
};
|
|
21
|
+
CosmosAddress.prototype.asString = function () {
|
|
22
|
+
return this.value;
|
|
23
|
+
};
|
|
24
|
+
CosmosAddress.addressPrefix = 'cosmos';
|
|
25
|
+
return CosmosAddress;
|
|
26
|
+
}());
|
|
27
|
+
exports.CosmosAddress = CosmosAddress;
|
|
28
|
+
//# sourceMappingURL=CosmosAddress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CosmosAddress.js","sourceRoot":"","sources":["../../../src/v0/protocol/CosmosAddress.ts"],"names":[],"mappings":";;;AAAA,aAAa;AACb,uFAAyF;AACzF,aAAa;AACb,6FAA+F;AAC/F,aAAa;AACb,qFAAuF;AAGvF;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 '@wallfree-dev/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber';
|
|
2
|
+
import { JSONConvertible } from '@wallfree-dev/coinlib-core/interfaces/JSONConvertible';
|
|
3
|
+
import { RPCConvertible } from '@wallfree-dev/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("@wallfree-dev/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber"));
|
|
8
|
+
var errors_1 = require("@wallfree-dev/coinlib-core/errors");
|
|
9
|
+
var coinlib_error_1 = require("@wallfree-dev/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/v0/protocol/CosmosCoin.ts"],"names":[],"mappings":";;;;;;AAAA,uHAAgG;AAChG,4DAAoE;AACpE,iFAAwE;AASxE;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 '@wallfree-dev/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,90 @@
|
|
|
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
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
+
function step(op) {
|
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
+
while (_) try {
|
|
33
|
+
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;
|
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
+
switch (op[0]) {
|
|
36
|
+
case 0: case 1: t = op; break;
|
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
+
default:
|
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
+
if (t[2]) _.ops.pop();
|
|
46
|
+
_.trys.pop(); continue;
|
|
47
|
+
}
|
|
48
|
+
op = body.call(thisArg, _);
|
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
+
exports.CosmosCryptoClient = void 0;
|
|
55
|
+
// @ts-ignore
|
|
56
|
+
var SECP256K1 = require("@wallfree-dev/coinlib-core/dependencies/src/secp256k1-3.7.1/elliptic");
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
var sha = require("@wallfree-dev/coinlib-core/dependencies/src/sha.js-2.4.11/index");
|
|
59
|
+
var Secp256k1CryptoClient_1 = require("@wallfree-dev/coinlib-core/protocols/Secp256k1CryptoClient");
|
|
60
|
+
var CosmosCryptoClient = /** @class */ (function (_super) {
|
|
61
|
+
__extends(CosmosCryptoClient, _super);
|
|
62
|
+
function CosmosCryptoClient() {
|
|
63
|
+
return _super.call(this) || this;
|
|
64
|
+
}
|
|
65
|
+
CosmosCryptoClient.prototype.signMessage = function (message, keypair) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
67
|
+
var sha256Hash, hash, signed;
|
|
68
|
+
return __generator(this, function (_a) {
|
|
69
|
+
sha256Hash = sha('sha256').update(Buffer.from(message)).digest();
|
|
70
|
+
hash = Buffer.from(sha256Hash);
|
|
71
|
+
signed = SECP256K1.sign(hash, Buffer.from(keypair.privateKey, 'hex'));
|
|
72
|
+
return [2 /*return*/, "0x".concat(Buffer.from(signed.signature).toString('hex'))];
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
CosmosCryptoClient.prototype.verifyMessage = function (message, signature, publicKey) {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
78
|
+
var rawSignature, sha256Hash, messageHash;
|
|
79
|
+
return __generator(this, function (_a) {
|
|
80
|
+
rawSignature = Buffer.from(signature.slice(2), 'hex');
|
|
81
|
+
sha256Hash = sha('sha256').update(Buffer.from(message)).digest();
|
|
82
|
+
messageHash = Buffer.from(sha256Hash);
|
|
83
|
+
return [2 /*return*/, SECP256K1.verify(messageHash, rawSignature, Buffer.from(publicKey, 'hex'))];
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
return CosmosCryptoClient;
|
|
88
|
+
}(Secp256k1CryptoClient_1.Secp256k1CryptoClient));
|
|
89
|
+
exports.CosmosCryptoClient = CosmosCryptoClient;
|
|
90
|
+
//# sourceMappingURL=CosmosCryptoClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CosmosCryptoClient.js","sourceRoot":"","sources":["../../../src/v0/protocol/CosmosCryptoClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,aAAa;AACb,gGAAkG;AAClG,aAAa;AACb,qFAAuF;AACvF,oGAAkG;AAElG;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,YAAK,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAE,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 '@wallfree-dev/coinlib-core/interfaces/JSONConvertible';
|
|
2
|
+
import { RPCConvertible } from '@wallfree-dev/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/v0/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 '@wallfree-dev/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
|
+
}
|