@airgap/cosmos 0.13.45-beta.2 → 0.13.45-beta.3
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/package.json +6 -6
- package/v0/index.js +8 -8
- package/v0/index.js.map +1 -1
- package/v0/protocol/CosmosAddress.js +15 -16
- package/v0/protocol/CosmosAddress.js.map +1 -1
- package/v0/protocol/CosmosCoin.js +23 -24
- package/v0/protocol/CosmosCoin.js.map +1 -1
- package/v0/protocol/CosmosCryptoClient.js +19 -82
- package/v0/protocol/CosmosCryptoClient.js.map +1 -1
- package/v0/protocol/CosmosFee.js +16 -17
- package/v0/protocol/CosmosFee.js.map +1 -1
- package/v0/protocol/CosmosNodeClient.js +173 -365
- package/v0/protocol/CosmosNodeClient.js.map +1 -1
- package/v0/protocol/CosmosProtocol.d.ts +0 -1
- package/v0/protocol/CosmosProtocol.js +577 -1094
- package/v0/protocol/CosmosProtocol.js.map +1 -1
- package/v0/protocol/CosmosProtocolOptions.js +25 -98
- package/v0/protocol/CosmosProtocolOptions.js.map +1 -1
- package/v0/protocol/CosmosTransaction.js +37 -39
- package/v0/protocol/CosmosTransaction.js.map +1 -1
- package/v0/protocol/CosmosTypes.js +1 -1
- package/v0/protocol/CosmosTypes.js.map +1 -1
- package/v0/protocol/cosmos-message/CosmosDelegateMessage.js +24 -27
- package/v0/protocol/cosmos-message/CosmosDelegateMessage.js.map +1 -1
- package/v0/protocol/cosmos-message/CosmosMessage.js +11 -12
- package/v0/protocol/cosmos-message/CosmosMessage.js.map +1 -1
- package/v0/protocol/cosmos-message/CosmosSendMessage.js +31 -41
- package/v0/protocol/cosmos-message/CosmosSendMessage.js.map +1 -1
- package/v0/protocol/cosmos-message/CosmosWithdrawDelegationRewardMessage.js +20 -21
- package/v0/protocol/cosmos-message/CosmosWithdrawDelegationRewardMessage.js.map +1 -1
- package/v0/serializer/validators/transaction-validator.js +25 -77
- package/v0/serializer/validators/transaction-validator.js.map +1 -1
- package/v1/block-explorer/MintscanBlockExplorer.js +12 -61
- package/v1/block-explorer/MintscanBlockExplorer.js.map +1 -1
- package/v1/index.js +3 -3
- package/v1/index.js.map +1 -1
- package/v1/module/CosmosModule.d.ts +1 -1
- package/v1/module/CosmosModule.js +37 -95
- package/v1/module/CosmosModule.js.map +1 -1
- package/v1/module.js +2 -3
- package/v1/module.js.map +1 -1
- package/v1/protocol/CosmosProtocol.d.ts +1 -1
- package/v1/protocol/CosmosProtocol.js +35 -113
- package/v1/protocol/CosmosProtocol.js.map +1 -1
- package/v1/serializer/v3/serializer-companion.js +57 -124
- package/v1/serializer/v3/serializer-companion.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@airgap/cosmos",
|
|
3
|
-
"version": "0.13.45-beta.
|
|
3
|
+
"version": "0.13.45-beta.3",
|
|
4
4
|
"description": "The @airgap/cosmos is a Cosmos implementation of the ICoinProtocol interface from @airgap/coinlib-core.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"airgap",
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
},
|
|
31
31
|
"author": "Papers AG <contact@papers.ch> (https://papers.ch)",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@airgap/coinlib-core": "^0.13.45-beta.
|
|
34
|
-
"@airgap/cosmos-core": "^0.13.45-beta.
|
|
35
|
-
"@airgap/crypto": "^0.13.45-beta.
|
|
36
|
-
"@airgap/module-kit": "^0.13.45-beta.
|
|
37
|
-
"@airgap/serializer": "^0.13.45-beta.
|
|
33
|
+
"@airgap/coinlib-core": "^0.13.45-beta.3",
|
|
34
|
+
"@airgap/cosmos-core": "^0.13.45-beta.3",
|
|
35
|
+
"@airgap/crypto": "^0.13.45-beta.3",
|
|
36
|
+
"@airgap/module-kit": "^0.13.45-beta.3",
|
|
37
|
+
"@airgap/serializer": "^0.13.45-beta.3"
|
|
38
38
|
},
|
|
39
39
|
"localDependencies": {},
|
|
40
40
|
"nyc": {
|
package/v0/index.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CosmosTransaction = exports.CosmosAddress = exports.CosmosDelegationActionType = exports.CosmosProtocolOptions = exports.CosmosProtocolConfig = exports.CosmosProtocolNetwork = exports.MintscanBlockExplorer = exports.CosmosCryptoClient = exports.CosmosProtocol = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const coinlib_core_1 = require("@airgap/coinlib-core");
|
|
5
|
+
const serializer_1 = require("@airgap/serializer");
|
|
6
|
+
const CosmosAddress_1 = require("./protocol/CosmosAddress");
|
|
7
7
|
Object.defineProperty(exports, "CosmosAddress", { enumerable: true, get: function () { return CosmosAddress_1.CosmosAddress; } });
|
|
8
|
-
|
|
8
|
+
const CosmosCryptoClient_1 = require("./protocol/CosmosCryptoClient");
|
|
9
9
|
Object.defineProperty(exports, "CosmosCryptoClient", { enumerable: true, get: function () { return CosmosCryptoClient_1.CosmosCryptoClient; } });
|
|
10
|
-
|
|
10
|
+
const CosmosProtocol_1 = require("./protocol/CosmosProtocol");
|
|
11
11
|
Object.defineProperty(exports, "CosmosDelegationActionType", { enumerable: true, get: function () { return CosmosProtocol_1.CosmosDelegationActionType; } });
|
|
12
12
|
Object.defineProperty(exports, "CosmosProtocol", { enumerable: true, get: function () { return CosmosProtocol_1.CosmosProtocol; } });
|
|
13
|
-
|
|
13
|
+
const CosmosProtocolOptions_1 = require("./protocol/CosmosProtocolOptions");
|
|
14
14
|
Object.defineProperty(exports, "CosmosProtocolConfig", { enumerable: true, get: function () { return CosmosProtocolOptions_1.CosmosProtocolConfig; } });
|
|
15
15
|
Object.defineProperty(exports, "CosmosProtocolNetwork", { enumerable: true, get: function () { return CosmosProtocolOptions_1.CosmosProtocolNetwork; } });
|
|
16
16
|
Object.defineProperty(exports, "CosmosProtocolOptions", { enumerable: true, get: function () { return CosmosProtocolOptions_1.CosmosProtocolOptions; } });
|
|
17
17
|
Object.defineProperty(exports, "MintscanBlockExplorer", { enumerable: true, get: function () { return CosmosProtocolOptions_1.MintscanBlockExplorer; } });
|
|
18
|
-
|
|
18
|
+
const CosmosTransaction_1 = require("./protocol/CosmosTransaction");
|
|
19
19
|
Object.defineProperty(exports, "CosmosTransaction", { enumerable: true, get: function () { return CosmosTransaction_1.CosmosTransaction; } });
|
|
20
|
-
|
|
20
|
+
const transaction_validator_1 = require("./serializer/validators/transaction-validator");
|
|
21
21
|
// Serializer
|
|
22
22
|
function unsignedTransactionTransformer(value) {
|
|
23
23
|
value.transaction = CosmosTransaction_1.CosmosTransaction.fromJSON(value);
|
package/v0/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/v0/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/v0/index.ts"],"names":[],"mappings":";;;AAAA,uDAA0D;AAC1D,mDAA6E;AAE7E,4DAAwD;AAqBtD,8FArBO,6BAAa,OAqBP;AApBf,sEAAkE;AAYhE,mGAZO,uCAAkB,OAYP;AAXpB,8DAAsF;AAkBpF,2GAlBO,2CAA0B,OAkBP;AAR1B,+FAVmC,+BAAc,OAUnC;AAThB,4EAA4I;AAa1I,qGAbO,4CAAoB,OAaP;AADpB,sGAZ6B,6CAAqB,OAY7B;AAErB,sGAdoD,6CAAqB,OAcpD;AAHrB,sGAX2E,6CAAqB,OAW3E;AAVvB,oEAAgE;AAkB9D,kGAlBO,qCAAiB,OAkBP;AAhBnB,yFAAsI;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"}
|
|
@@ -2,27 +2,26 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CosmosAddress = void 0;
|
|
4
4
|
// @ts-ignore
|
|
5
|
-
|
|
5
|
+
const BECH32 = require("@airgap/coinlib-core/dependencies/src/bech32-1.1.3/index");
|
|
6
6
|
// @ts-ignore
|
|
7
|
-
|
|
7
|
+
const RIPEMD160 = require("@airgap/coinlib-core/dependencies/src/ripemd160-2.0.2/index");
|
|
8
8
|
// @ts-ignore
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
const sha = require("@airgap/coinlib-core/dependencies/src/sha.js-2.4.11/index");
|
|
10
|
+
class CosmosAddress {
|
|
11
|
+
static { this.addressPrefix = 'cosmos'; }
|
|
12
|
+
constructor(value) {
|
|
12
13
|
this.value = value;
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
static from(publicKey) {
|
|
16
|
+
const pubkey = Buffer.from(publicKey, 'hex');
|
|
17
|
+
const sha256Hash = sha('sha256').update(pubkey).digest();
|
|
18
|
+
const hash = new RIPEMD160().update(Buffer.from(sha256Hash)).digest();
|
|
19
|
+
const address = BECH32.encode(CosmosAddress.addressPrefix, BECH32.toWords(hash));
|
|
19
20
|
return new CosmosAddress(address);
|
|
20
|
-
}
|
|
21
|
-
|
|
21
|
+
}
|
|
22
|
+
asString() {
|
|
22
23
|
return this.value;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return CosmosAddress;
|
|
26
|
-
}());
|
|
24
|
+
}
|
|
25
|
+
}
|
|
27
26
|
exports.CosmosAddress = CosmosAddress;
|
|
28
27
|
//# sourceMappingURL=CosmosAddress.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CosmosAddress.js","sourceRoot":"","sources":["../../../src/v0/protocol/CosmosAddress.ts"],"names":[],"mappings":";;;AAAA,aAAa;AACb,
|
|
1
|
+
{"version":3,"file":"CosmosAddress.js","sourceRoot":"","sources":["../../../src/v0/protocol/CosmosAddress.ts"],"names":[],"mappings":";;;AAAA,aAAa;AACb,mFAAmF;AACnF,aAAa;AACb,yFAAyF;AACzF,aAAa;AACb,iFAAiF;AAGjF,MAAa,aAAa;aACA,kBAAa,GAAW,QAAQ,CAAA;IAExD,YAAqC,KAAa;QAAb,UAAK,GAAL,KAAK,CAAQ;IAAG,CAAC;IAE/C,MAAM,CAAC,IAAI,CAAC,SAAiB;QAClC,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAA;QAE5C,MAAM,UAAU,GAAW,GAAG,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAA;QAChE,MAAM,IAAI,GAAG,IAAI,SAAS,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,EAAE,CAAA;QACrE,MAAM,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,QAAQ;QACb,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;;AAjBH,sCAkBC"}
|
|
@@ -4,52 +4,51 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.CosmosCoin = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
const bignumber_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber"));
|
|
8
|
+
const errors_1 = require("@airgap/coinlib-core/errors");
|
|
9
|
+
const coinlib_error_1 = require("@airgap/coinlib-core/errors/coinlib-error");
|
|
10
|
+
class CosmosCoin {
|
|
11
|
+
static { this.supportedDenominations = ['uatom']; }
|
|
12
|
+
constructor(denom, amount) {
|
|
12
13
|
this.denom = denom;
|
|
13
14
|
this.amount = amount;
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
+
toJSON() {
|
|
16
17
|
return {
|
|
17
18
|
amount: this.amount,
|
|
18
19
|
denom: this.denom
|
|
19
20
|
};
|
|
20
|
-
}
|
|
21
|
-
|
|
21
|
+
}
|
|
22
|
+
static fromJSON(json) {
|
|
22
23
|
if (!CosmosCoin.supportedDenominations.includes(json.denom)) {
|
|
23
24
|
throw new errors_1.UnsupportedError(coinlib_error_1.Domain.COSMOS, 'Unsupported cosmos denomination');
|
|
24
25
|
}
|
|
25
26
|
return new CosmosCoin(json.denom, json.amount);
|
|
26
|
-
}
|
|
27
|
-
|
|
27
|
+
}
|
|
28
|
+
static fromCoins(json) {
|
|
28
29
|
return json
|
|
29
|
-
.map(
|
|
30
|
+
.map((coinJSON) => {
|
|
30
31
|
try {
|
|
31
32
|
return CosmosCoin.fromJSON(coinJSON);
|
|
32
33
|
}
|
|
33
|
-
catch
|
|
34
|
+
catch {
|
|
34
35
|
return undefined;
|
|
35
36
|
}
|
|
36
37
|
})
|
|
37
|
-
.filter(
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return coins.reduce(
|
|
41
|
-
}
|
|
42
|
-
|
|
38
|
+
.filter((value) => value !== undefined);
|
|
39
|
+
}
|
|
40
|
+
static sum(coins) {
|
|
41
|
+
return coins.reduce((current, next) => current.plus(new bignumber_1.default(next.amount)), new bignumber_1.default(0));
|
|
42
|
+
}
|
|
43
|
+
toRPCBody() {
|
|
43
44
|
return {
|
|
44
45
|
amount: this.amount,
|
|
45
46
|
denom: this.denom
|
|
46
47
|
};
|
|
47
|
-
}
|
|
48
|
-
|
|
48
|
+
}
|
|
49
|
+
static fromRPCBody(json) {
|
|
49
50
|
return new CosmosCoin(json.denom, json.amount);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return CosmosCoin;
|
|
53
|
-
}());
|
|
51
|
+
}
|
|
52
|
+
}
|
|
54
53
|
exports.CosmosCoin = CosmosCoin;
|
|
55
54
|
//# sourceMappingURL=CosmosCoin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CosmosCoin.js","sourceRoot":"","sources":["../../../src/v0/protocol/CosmosCoin.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"CosmosCoin.js","sourceRoot":"","sources":["../../../src/v0/protocol/CosmosCoin.ts"],"names":[],"mappings":";;;;;;AAAA,mHAA0F;AAC1F,wDAA8D;AAC9D,6EAAkE;AASlE,MAAa,UAAU;aACG,2BAAsB,GAAG,CAAC,OAAO,CAAC,CAAA;IAI1D,YAAY,KAAa,EAAE,MAAc;QACvC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAEM,MAAM;QACX,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB,CAAA;IACH,CAAC;IAEM,MAAM,CAAC,QAAQ,CAAC,IAAoB;QACzC,IAAI,CAAC,UAAU,CAAC,sBAAsB,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAC5D,MAAM,IAAI,yBAAgB,CAAC,sBAAM,CAAC,MAAM,EAAE,iCAAiC,CAAC,CAAA;QAC9E,CAAC;QAED,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;IAChD,CAAC;IAEM,MAAM,CAAC,SAAS,CAAC,IAAsB;QAC5C,OAAO,IAAI;aACR,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;YAChB,IAAI,CAAC;gBACH,OAAO,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;YACtC,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,SAAS,CAAA;YAClB,CAAC;QACH,CAAC,CAAC;aACD,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAiB,CAAA;IAC3D,CAAC;IAEM,MAAM,CAAC,GAAG,CAAC,KAAmB;QACnC,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,mBAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,mBAAS,CAAC,CAAC,CAAC,CAAC,CAAA;IACpG,CAAC;IAEM,SAAS;QACd,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB,CAAA;IACH,CAAC;IAEM,MAAM,CAAC,WAAW,CAAC,IAAS;QACjC,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;IAChD,CAAC;;AAlDH,gCAmDC"}
|
|
@@ -1,90 +1,27 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
3
|
exports.CosmosCryptoClient = void 0;
|
|
55
4
|
// @ts-ignore
|
|
56
|
-
|
|
5
|
+
const SECP256K1 = require("@airgap/coinlib-core/dependencies/src/secp256k1-3.7.1/elliptic");
|
|
57
6
|
// @ts-ignore
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
7
|
+
const sha = require("@airgap/coinlib-core/dependencies/src/sha.js-2.4.11/index");
|
|
8
|
+
const Secp256k1CryptoClient_1 = require("@airgap/coinlib-core/protocols/Secp256k1CryptoClient");
|
|
9
|
+
class CosmosCryptoClient extends Secp256k1CryptoClient_1.Secp256k1CryptoClient {
|
|
10
|
+
constructor() {
|
|
11
|
+
super();
|
|
12
|
+
}
|
|
13
|
+
async signMessage(message, keypair) {
|
|
14
|
+
const sha256Hash = sha('sha256').update(Buffer.from(message)).digest();
|
|
15
|
+
const hash = Buffer.from(sha256Hash);
|
|
16
|
+
const signed = SECP256K1.sign(hash, Buffer.from(keypair.privateKey, 'hex'));
|
|
17
|
+
return `0x${Buffer.from(signed.signature).toString('hex')}`;
|
|
18
|
+
}
|
|
19
|
+
async verifyMessage(message, signature, publicKey) {
|
|
20
|
+
const rawSignature = Buffer.from(signature.slice(2), 'hex');
|
|
21
|
+
const sha256Hash = sha('sha256').update(Buffer.from(message)).digest();
|
|
22
|
+
const messageHash = Buffer.from(sha256Hash);
|
|
23
|
+
return SECP256K1.verify(messageHash, rawSignature, Buffer.from(publicKey, 'hex'));
|
|
64
24
|
}
|
|
65
|
-
|
|
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));
|
|
25
|
+
}
|
|
89
26
|
exports.CosmosCryptoClient = CosmosCryptoClient;
|
|
90
27
|
//# sourceMappingURL=CosmosCryptoClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CosmosCryptoClient.js","sourceRoot":"","sources":["../../../src/v0/protocol/CosmosCryptoClient.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CosmosCryptoClient.js","sourceRoot":"","sources":["../../../src/v0/protocol/CosmosCryptoClient.ts"],"names":[],"mappings":";;;AAAA,aAAa;AACb,4FAA4F;AAC5F,aAAa;AACb,iFAAiF;AACjF,gGAA4F;AAE5F,MAAa,kBAAmB,SAAQ,6CAAqB;IAC3D;QACE,KAAK,EAAE,CAAA;IACT,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,OAAe,EAAE,OAA+B;QACvE,MAAM,UAAU,GAAW,GAAG,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,CAAA;QAC9E,MAAM,IAAI,GAAW,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;QAC5C,MAAM,MAAM,GAA0B,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAA;QAElG,OAAO,KAAK,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAA;IAC7D,CAAC;IAEM,KAAK,CAAC,aAAa,CAAC,OAAe,EAAE,SAAiB,EAAE,SAAiB;QAC9E,MAAM,YAAY,GAAW,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;QAEnE,MAAM,UAAU,GAAW,GAAG,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,CAAA;QAC9E,MAAM,WAAW,GAAW,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;QAEnD,OAAO,SAAS,CAAC,MAAM,CAAC,WAAW,EAAE,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAA;IACnF,CAAC;CACF;AArBD,gDAqBC"}
|
package/v0/protocol/CosmosFee.js
CHANGED
|
@@ -1,31 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CosmosFee = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const CosmosCoin_1 = require("./CosmosCoin");
|
|
5
|
+
class CosmosFee {
|
|
6
|
+
constructor(amount, gas) {
|
|
7
7
|
this.amount = amount;
|
|
8
8
|
this.gas = gas;
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
toJSON() {
|
|
11
11
|
return {
|
|
12
|
-
amount: this.amount.map(
|
|
12
|
+
amount: this.amount.map((value) => value.toJSON()),
|
|
13
13
|
gas: this.gas
|
|
14
14
|
};
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return new CosmosFee(json.amount.map(
|
|
18
|
-
}
|
|
19
|
-
|
|
15
|
+
}
|
|
16
|
+
static fromJSON(json) {
|
|
17
|
+
return new CosmosFee(json.amount.map((value) => CosmosCoin_1.CosmosCoin.fromJSON(value)), json.gas);
|
|
18
|
+
}
|
|
19
|
+
toRPCBody() {
|
|
20
20
|
return {
|
|
21
|
-
amount: this.amount.map(
|
|
21
|
+
amount: this.amount.map((value) => value.toRPCBody()),
|
|
22
22
|
gas: this.gas
|
|
23
23
|
};
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return new CosmosFee(json.amount.map(
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
}());
|
|
24
|
+
}
|
|
25
|
+
static fromRPCBody(json) {
|
|
26
|
+
return new CosmosFee(json.amount.map((value) => CosmosCoin_1.CosmosCoin.fromRPCBody(value)), json.gas);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
30
29
|
exports.CosmosFee = CosmosFee;
|
|
31
30
|
//# sourceMappingURL=CosmosFee.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CosmosFee.js","sourceRoot":"","sources":["../../../src/v0/protocol/CosmosFee.ts"],"names":[],"mappings":";;;AAEA,
|
|
1
|
+
{"version":3,"file":"CosmosFee.js","sourceRoot":"","sources":["../../../src/v0/protocol/CosmosFee.ts"],"names":[],"mappings":";;;AAEA,6CAAyC;AAEzC,MAAa,SAAS;IAIpB,YAAY,MAAoB,EAAE,GAAW;QAC3C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;IAChB,CAAC;IAEM,MAAM;QACX,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;YAClD,GAAG,EAAE,IAAI,CAAC,GAAG;SACd,CAAA;IACH,CAAC;IAEM,MAAM,CAAC,QAAQ,CAAC,IAAS;QAC9B,OAAO,IAAI,SAAS,CAClB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAU,EAAE,EAAE,CAAC,uBAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAC3D,IAAI,CAAC,GAAG,CACT,CAAA;IACH,CAAC;IAEM,SAAS;QACd,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;YACrD,GAAG,EAAE,IAAI,CAAC,GAAG;SACd,CAAA;IACH,CAAC;IAEM,MAAM,CAAC,WAAW,CAAC,IAAS;QACjC,OAAO,IAAI,SAAS,CAClB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAU,EAAE,EAAE,CAAC,uBAAU,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAC9D,IAAI,CAAC,GAAG,CACT,CAAA;IACH,CAAC;CACF;AApCD,8BAoCC"}
|