@airgap/cosmos 0.13.45-beta.3 → 0.13.45-beta.5
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 +16 -15
- package/v0/protocol/CosmosAddress.js.map +1 -1
- package/v0/protocol/CosmosCoin.js +24 -23
- package/v0/protocol/CosmosCoin.js.map +1 -1
- package/v0/protocol/CosmosCryptoClient.js +82 -19
- package/v0/protocol/CosmosCryptoClient.js.map +1 -1
- package/v0/protocol/CosmosFee.js +17 -16
- package/v0/protocol/CosmosFee.js.map +1 -1
- package/v0/protocol/CosmosNodeClient.js +365 -173
- package/v0/protocol/CosmosNodeClient.js.map +1 -1
- package/v0/protocol/CosmosProtocol.d.ts +1 -0
- package/v0/protocol/CosmosProtocol.js +1094 -577
- package/v0/protocol/CosmosProtocol.js.map +1 -1
- package/v0/protocol/CosmosProtocolOptions.js +98 -25
- package/v0/protocol/CosmosProtocolOptions.js.map +1 -1
- package/v0/protocol/CosmosTransaction.js +39 -37
- 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 +27 -24
- package/v0/protocol/cosmos-message/CosmosDelegateMessage.js.map +1 -1
- package/v0/protocol/cosmos-message/CosmosMessage.js +12 -11
- package/v0/protocol/cosmos-message/CosmosMessage.js.map +1 -1
- package/v0/protocol/cosmos-message/CosmosSendMessage.js +41 -31
- package/v0/protocol/cosmos-message/CosmosSendMessage.js.map +1 -1
- package/v0/protocol/cosmos-message/CosmosWithdrawDelegationRewardMessage.js +21 -20
- package/v0/protocol/cosmos-message/CosmosWithdrawDelegationRewardMessage.js.map +1 -1
- package/v0/serializer/validators/transaction-validator.js +77 -25
- package/v0/serializer/validators/transaction-validator.js.map +1 -1
- package/v1/block-explorer/MintscanBlockExplorer.js +61 -12
- 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 +95 -37
- package/v1/module/CosmosModule.js.map +1 -1
- package/v1/module.js +3 -2
- package/v1/module.js.map +1 -1
- package/v1/protocol/CosmosProtocol.d.ts +1 -1
- package/v1/protocol/CosmosProtocol.js +113 -35
- package/v1/protocol/CosmosProtocol.js.map +1 -1
- package/v1/serializer/v3/serializer-companion.js +124 -57
- 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.5",
|
|
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.5",
|
|
34
|
+
"@airgap/cosmos-core": "^0.13.45-beta.5",
|
|
35
|
+
"@airgap/crypto": "^0.13.45-beta.5",
|
|
36
|
+
"@airgap/module-kit": "^0.13.45-beta.5",
|
|
37
|
+
"@airgap/serializer": "^0.13.45-beta.5"
|
|
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
|
+
var coinlib_core_1 = require("@airgap/coinlib-core");
|
|
5
|
+
var serializer_1 = require("@airgap/serializer");
|
|
6
|
+
var CosmosAddress_1 = require("./protocol/CosmosAddress");
|
|
7
7
|
Object.defineProperty(exports, "CosmosAddress", { enumerable: true, get: function () { return CosmosAddress_1.CosmosAddress; } });
|
|
8
|
-
|
|
8
|
+
var CosmosCryptoClient_1 = require("./protocol/CosmosCryptoClient");
|
|
9
9
|
Object.defineProperty(exports, "CosmosCryptoClient", { enumerable: true, get: function () { return CosmosCryptoClient_1.CosmosCryptoClient; } });
|
|
10
|
-
|
|
10
|
+
var 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
|
+
var 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
|
+
var CosmosTransaction_1 = require("./protocol/CosmosTransaction");
|
|
19
19
|
Object.defineProperty(exports, "CosmosTransaction", { enumerable: true, get: function () { return CosmosTransaction_1.CosmosTransaction; } });
|
|
20
|
-
|
|
20
|
+
var 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,qDAA0D;AAC1D,iDAA6E;AAE7E,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"}
|
|
@@ -2,26 +2,27 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CosmosAddress = void 0;
|
|
4
4
|
// @ts-ignore
|
|
5
|
-
|
|
5
|
+
var BECH32 = require("@airgap/coinlib-core/dependencies/src/bech32-1.1.3/index");
|
|
6
6
|
// @ts-ignore
|
|
7
|
-
|
|
7
|
+
var RIPEMD160 = require("@airgap/coinlib-core/dependencies/src/ripemd160-2.0.2/index");
|
|
8
8
|
// @ts-ignore
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
constructor(value) {
|
|
9
|
+
var sha = require("@airgap/coinlib-core/dependencies/src/sha.js-2.4.11/index");
|
|
10
|
+
var CosmosAddress = /** @class */ (function () {
|
|
11
|
+
function CosmosAddress(value) {
|
|
13
12
|
this.value = value;
|
|
14
13
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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));
|
|
20
19
|
return new CosmosAddress(address);
|
|
21
|
-
}
|
|
22
|
-
asString() {
|
|
20
|
+
};
|
|
21
|
+
CosmosAddress.prototype.asString = function () {
|
|
23
22
|
return this.value;
|
|
24
|
-
}
|
|
25
|
-
|
|
23
|
+
};
|
|
24
|
+
CosmosAddress.addressPrefix = 'cosmos';
|
|
25
|
+
return CosmosAddress;
|
|
26
|
+
}());
|
|
26
27
|
exports.CosmosAddress = CosmosAddress;
|
|
27
28
|
//# 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,iFAAmF;AACnF,aAAa;AACb,uFAAyF;AACzF,aAAa;AACb,+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"}
|
|
@@ -4,51 +4,52 @@ 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
|
-
|
|
12
|
-
constructor(denom, amount) {
|
|
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) {
|
|
13
12
|
this.denom = denom;
|
|
14
13
|
this.amount = amount;
|
|
15
14
|
}
|
|
16
|
-
toJSON() {
|
|
15
|
+
CosmosCoin.prototype.toJSON = function () {
|
|
17
16
|
return {
|
|
18
17
|
amount: this.amount,
|
|
19
18
|
denom: this.denom
|
|
20
19
|
};
|
|
21
|
-
}
|
|
22
|
-
|
|
20
|
+
};
|
|
21
|
+
CosmosCoin.fromJSON = function (json) {
|
|
23
22
|
if (!CosmosCoin.supportedDenominations.includes(json.denom)) {
|
|
24
23
|
throw new errors_1.UnsupportedError(coinlib_error_1.Domain.COSMOS, 'Unsupported cosmos denomination');
|
|
25
24
|
}
|
|
26
25
|
return new CosmosCoin(json.denom, json.amount);
|
|
27
|
-
}
|
|
28
|
-
|
|
26
|
+
};
|
|
27
|
+
CosmosCoin.fromCoins = function (json) {
|
|
29
28
|
return json
|
|
30
|
-
.map((coinJSON)
|
|
29
|
+
.map(function (coinJSON) {
|
|
31
30
|
try {
|
|
32
31
|
return CosmosCoin.fromJSON(coinJSON);
|
|
33
32
|
}
|
|
34
|
-
catch {
|
|
33
|
+
catch (_a) {
|
|
35
34
|
return undefined;
|
|
36
35
|
}
|
|
37
36
|
})
|
|
38
|
-
.filter((value)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return coins.reduce((current, next)
|
|
42
|
-
}
|
|
43
|
-
toRPCBody() {
|
|
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 () {
|
|
44
43
|
return {
|
|
45
44
|
amount: this.amount,
|
|
46
45
|
denom: this.denom
|
|
47
46
|
};
|
|
48
|
-
}
|
|
49
|
-
|
|
47
|
+
};
|
|
48
|
+
CosmosCoin.fromRPCBody = function (json) {
|
|
50
49
|
return new CosmosCoin(json.denom, json.amount);
|
|
51
|
-
}
|
|
52
|
-
|
|
50
|
+
};
|
|
51
|
+
CosmosCoin.supportedDenominations = ['uatom'];
|
|
52
|
+
return CosmosCoin;
|
|
53
|
+
}());
|
|
53
54
|
exports.CosmosCoin = CosmosCoin;
|
|
54
55
|
//# 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,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"}
|
|
@@ -1,27 +1,90 @@
|
|
|
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
|
+
};
|
|
2
53
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
54
|
exports.CosmosCryptoClient = void 0;
|
|
4
55
|
// @ts-ignore
|
|
5
|
-
|
|
56
|
+
var SECP256K1 = require("@airgap/coinlib-core/dependencies/src/secp256k1-3.7.1/elliptic");
|
|
6
57
|
// @ts-ignore
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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'));
|
|
58
|
+
var sha = require("@airgap/coinlib-core/dependencies/src/sha.js-2.4.11/index");
|
|
59
|
+
var Secp256k1CryptoClient_1 = require("@airgap/coinlib-core/protocols/Secp256k1CryptoClient");
|
|
60
|
+
var CosmosCryptoClient = /** @class */ (function (_super) {
|
|
61
|
+
__extends(CosmosCryptoClient, _super);
|
|
62
|
+
function CosmosCryptoClient() {
|
|
63
|
+
return _super.call(this) || this;
|
|
24
64
|
}
|
|
25
|
-
|
|
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));
|
|
26
89
|
exports.CosmosCryptoClient = CosmosCryptoClient;
|
|
27
90
|
//# 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,0FAA4F;AAC5F,aAAa;AACb,+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,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"}
|
package/v0/protocol/CosmosFee.js
CHANGED
|
@@ -1,30 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CosmosFee = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
var CosmosCoin_1 = require("./CosmosCoin");
|
|
5
|
+
var CosmosFee = /** @class */ (function () {
|
|
6
|
+
function CosmosFee(amount, gas) {
|
|
7
7
|
this.amount = amount;
|
|
8
8
|
this.gas = gas;
|
|
9
9
|
}
|
|
10
|
-
toJSON() {
|
|
10
|
+
CosmosFee.prototype.toJSON = function () {
|
|
11
11
|
return {
|
|
12
|
-
amount: this.amount.map((value)
|
|
12
|
+
amount: this.amount.map(function (value) { return value.toJSON(); }),
|
|
13
13
|
gas: this.gas
|
|
14
14
|
};
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return new CosmosFee(json.amount.map((value)
|
|
18
|
-
}
|
|
19
|
-
toRPCBody() {
|
|
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
20
|
return {
|
|
21
|
-
amount: this.amount.map((value)
|
|
21
|
+
amount: this.amount.map(function (value) { return value.toRPCBody(); }),
|
|
22
22
|
gas: this.gas
|
|
23
23
|
};
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return new CosmosFee(json.amount.map((value)
|
|
27
|
-
}
|
|
28
|
-
|
|
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
|
+
}());
|
|
29
30
|
exports.CosmosFee = CosmosFee;
|
|
30
31
|
//# 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,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"}
|