@airgap/coinlib-core 0.13.6 → 0.13.7-beta.1
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/actions/GetKtAccountsAction.js +1 -1
- package/actions/GetKtAccountsAction.js.map +1 -1
- package/airgap-coinlib-core.min.js +389 -298
- package/interfaces/IAirGapAddress.d.ts +19 -0
- package/interfaces/IAirGapAddress.js +3 -0
- package/interfaces/IAirGapAddress.js.map +1 -0
- package/package.json +1 -1
- package/protocols/CryptoClient.d.ts +4 -5
- package/protocols/Ed25519CryptoClient.d.ts +1 -2
- package/protocols/Ed25519CryptoClient.js +1 -1
- package/protocols/Ed25519CryptoClient.js.map +1 -1
- package/protocols/ICoinBaseProtocol.d.ts +47 -0
- package/protocols/ICoinBaseProtocol.js +3 -0
- package/protocols/ICoinBaseProtocol.js.map +1 -0
- package/protocols/ICoinOfflineProtocol.d.ts +22 -0
- package/protocols/ICoinOfflineProtocol.js +3 -0
- package/protocols/ICoinOfflineProtocol.js.map +1 -0
- package/protocols/ICoinOnlineProtocol.d.ts +46 -0
- package/protocols/ICoinOnlineProtocol.js +3 -0
- package/protocols/ICoinOnlineProtocol.js.map +1 -0
- package/protocols/ICoinProtocol.d.ts +4 -110
- package/protocols/NonExtendedProtocol.d.ts +4 -3
- package/protocols/NonExtendedProtocol.js +4 -1
- package/protocols/NonExtendedProtocol.js.map +1 -1
- package/protocols/Secp256k1CryptoClient.d.ts +1 -2
- package/protocols/Secp256k1CryptoClient.js +1 -1
- package/protocols/Secp256k1CryptoClient.js.map +1 -1
- package/protocols/Sr25519CryptoClient.d.ts +1 -2
- package/protocols/aeternity/AeternityAddress.d.ts +1 -1
- package/protocols/aeternity/AeternityAddress.js +1 -1
- package/protocols/aeternity/AeternityCryptoClient.d.ts +1 -2
- package/protocols/aeternity/AeternityCryptoClient.js +1 -1
- package/protocols/aeternity/AeternityCryptoClient.js.map +1 -1
- package/protocols/aeternity/AeternityProtocol.d.ts +10 -13
- package/protocols/aeternity/AeternityProtocol.js +16 -20
- package/protocols/aeternity/AeternityProtocol.js.map +1 -1
- package/protocols/aeternity/AeternityTypes.d.ts +6 -0
- package/protocols/bitcoin/BitcoinAddress.d.ts +1 -1
- package/protocols/bitcoin/BitcoinAddress.js +1 -1
- package/protocols/bitcoin/BitcoinCryptoClient.d.ts +1 -2
- package/protocols/bitcoin/BitcoinCryptoClient.js +2 -2
- package/protocols/bitcoin/BitcoinCryptoClient.js.map +1 -1
- package/protocols/bitcoin/BitcoinProtocol.d.ts +12 -15
- package/protocols/bitcoin/BitcoinProtocol.js +35 -30
- package/protocols/bitcoin/BitcoinProtocol.js.map +1 -1
- package/protocols/bitcoin/BitcoinSegwitAddress.d.ts +1 -1
- package/protocols/bitcoin/BitcoinSegwitAddress.js +1 -1
- package/protocols/bitcoin/BitcoinSegwitProtocol.d.ts +6 -7
- package/protocols/bitcoin/BitcoinSegwitProtocol.js +28 -15
- package/protocols/bitcoin/BitcoinSegwitProtocol.js.map +1 -1
- package/protocols/bitcoin/BitcoinTypes.d.ts +6 -0
- package/protocols/cosmos/CosmosAddress.d.ts +1 -1
- package/protocols/cosmos/CosmosAddress.js +1 -1
- package/protocols/cosmos/CosmosCryptoClient.d.ts +1 -2
- package/protocols/cosmos/CosmosCryptoClient.js +1 -1
- package/protocols/cosmos/CosmosCryptoClient.js.map +1 -1
- package/protocols/cosmos/CosmosProtocol.d.ts +10 -13
- package/protocols/cosmos/CosmosProtocol.js +26 -27
- package/protocols/cosmos/CosmosProtocol.js.map +1 -1
- package/protocols/cosmos/CosmosTypes.d.ts +6 -0
- package/protocols/cosmos/CosmosTypes.js.map +1 -1
- package/protocols/ethereum/BaseEthereumProtocol.d.ts +12 -14
- package/protocols/ethereum/BaseEthereumProtocol.js +20 -22
- package/protocols/ethereum/BaseEthereumProtocol.js.map +1 -1
- package/protocols/ethereum/EthereumAddress.d.ts +1 -1
- package/protocols/ethereum/EthereumAddress.js +1 -1
- package/protocols/ethereum/EthereumCryptoClient.d.ts +1 -2
- package/protocols/ethereum/EthereumCryptoClient.js +8 -7
- package/protocols/ethereum/EthereumCryptoClient.js.map +1 -1
- package/protocols/ethereum/EthereumTypes.d.ts +6 -0
- package/protocols/ethereum/erc20/GenericERC20.d.ts +1 -2
- package/protocols/ethereum/erc20/GenericERC20.js +5 -5
- package/protocols/ethereum/erc20/GenericERC20.js.map +1 -1
- package/protocols/substrate/SubstrateCryptoClient.d.ts +1 -2
- package/protocols/substrate/SubstrateCryptoClient.js +7 -7
- package/protocols/substrate/SubstrateCryptoClient.js.map +1 -1
- package/protocols/substrate/SubstrateDelegateProtocol.js +3 -3
- package/protocols/substrate/SubstrateDelegateProtocol.js.map +1 -1
- package/protocols/substrate/SubstrateProtocol.d.ts +12 -13
- package/protocols/substrate/SubstrateProtocol.js +22 -20
- package/protocols/substrate/SubstrateProtocol.js.map +1 -1
- package/protocols/substrate/SubstrateTypes.d.ts +6 -0
- package/protocols/substrate/common/SubstrateAccountController.js +4 -4
- package/protocols/substrate/common/data/account/SubstrateAddress.d.ts +1 -1
- package/protocols/substrate/common/data/account/SubstrateAddress.js +2 -2
- package/protocols/substrate/common/data/scale/type/SCALEAccountId.js +1 -1
- package/protocols/substrate/common/data/transaction/method/SubstrateTransactionMethodArgs.js +12 -12
- package/protocols/substrate/moonbeam/MoonbeamProtocol.js +4 -4
- package/protocols/substrate/moonbeam/MoonbeamProtocol.js.map +1 -1
- package/protocols/substrate/moonbeam/controllers/MoonbeamAccountController.js +3 -3
- package/protocols/substrate/moonbeam/data/account/MoonbeamAddress.d.ts +1 -1
- package/protocols/substrate/moonbeam/data/account/MoonbeamAddress.js +3 -3
- package/protocols/tezos/TezosAddress.d.ts +1 -1
- package/protocols/tezos/TezosAddress.js +1 -1
- package/protocols/tezos/TezosCryptoClient.d.ts +1 -1
- package/protocols/tezos/TezosCryptoClient.js +1 -1
- package/protocols/tezos/TezosCryptoClient.js.map +1 -1
- package/protocols/tezos/TezosProtocol.d.ts +11 -12
- package/protocols/tezos/TezosProtocol.js +24 -22
- package/protocols/tezos/TezosProtocol.js.map +1 -1
- package/protocols/tezos/fa/TezosFA1Protocol.js +4 -4
- package/protocols/tezos/fa/TezosFA1Protocol.js.map +1 -1
- package/protocols/tezos/fa/TezosFA2Protocol.js +2 -2
- package/protocols/tezos/fa/TezosFA2Protocol.js.map +1 -1
- package/protocols/tezos/fa/TezosFAProtocol.js +1 -1
- package/protocols/tezos/fa/TezosFAProtocol.js.map +1 -1
- package/protocols/tezos/kt/TezosKtProtocol.d.ts +4 -3
- package/protocols/tezos/kt/TezosKtProtocol.js +44 -16
- package/protocols/tezos/kt/TezosKtProtocol.js.map +1 -1
- package/protocols/tezos/sapling/TezosSaplingCryptoClient.d.ts +1 -1
- package/protocols/tezos/sapling/TezosSaplingProtocol.d.ts +12 -12
- package/protocols/tezos/sapling/TezosSaplingProtocol.js +74 -29
- package/protocols/tezos/sapling/TezosSaplingProtocol.js.map +1 -1
- package/protocols/tezos/sapling/utils/TezosSaplingBookkeeper.js +7 -7
- package/protocols/tezos/sapling/utils/TezosSaplingBookkeeper.js.map +1 -1
- package/protocols/tezos/types/TezosAddressCursor.d.ts +3 -0
- package/protocols/tezos/types/TezosAddressCursor.js +3 -0
- package/protocols/tezos/types/TezosAddressCursor.js.map +1 -0
- package/protocols/tezos/types/TezosAddressResult.d.ts +4 -0
- package/protocols/tezos/types/TezosAddressResult.js +3 -0
- package/protocols/tezos/types/TezosAddressResult.js.map +1 -0
- package/protocols/tezos/types/kt/TezosKtAddressCursor.d.ts +4 -0
- package/protocols/tezos/types/kt/TezosKtAddressCursor.js +3 -0
- package/protocols/tezos/types/kt/TezosKtAddressCursor.js.map +1 -0
- package/protocols/tezos/types/kt/TezosKtAddressResult.d.ts +5 -0
- package/protocols/tezos/types/kt/TezosKtAddressResult.js +3 -0
- package/protocols/tezos/types/kt/TezosKtAddressResult.js.map +1 -0
- package/protocols/tezos/types/sapling/TezosSaplingAddressCursor.d.ts +4 -0
- package/protocols/tezos/types/sapling/TezosSaplingAddressCursor.js +3 -0
- package/protocols/tezos/types/sapling/TezosSaplingAddressCursor.js.map +1 -0
- package/protocols/tezos/types/sapling/TezosSaplingAddressResult.d.ts +4 -0
- package/protocols/tezos/types/sapling/TezosSaplingAddressResult.js +3 -0
- package/protocols/tezos/types/sapling/TezosSaplingAddressResult.js.map +1 -0
- package/utils/AES.d.ts +2 -3
- package/utils/AES.js +3 -1
- package/utils/AES.js.map +1 -1
- package/utils/protocolsByIdentifier.js +1 -10
- package/utils/protocolsByIdentifier.js.map +1 -1
- package/wallet/AirGapWallet.js +1 -1
- package/wallet/AirGapWallet.js.map +1 -1
|
@@ -30668,7 +30668,7 @@ var ImportAccountAction = /** @class */ (function (_super) {
|
|
|
30668
30668
|
return [4 /*yield*/, protocol.getAddressesFromPublicKey(this.context.publicKey)];
|
|
30669
30669
|
case 1:
|
|
30670
30670
|
ktAddresses = _a.sent();
|
|
30671
|
-
return [2 /*return*/, ktAddresses.map(function (address) { return address.
|
|
30671
|
+
return [2 /*return*/, ktAddresses.map(function (address) { return address.address; })];
|
|
30672
30672
|
}
|
|
30673
30673
|
});
|
|
30674
30674
|
});
|
|
@@ -124200,7 +124200,7 @@ var Ed25519CryptoClient = /** @class */ (function (_super) {
|
|
|
124200
124200
|
return __awaiter(this, void 0, void 0, function () {
|
|
124201
124201
|
var kxSelfPrivateKey, kxSelfPublicKey, decryptedMessage;
|
|
124202
124202
|
return __generator(this, function (_a) {
|
|
124203
|
-
kxSelfPrivateKey = sodium.crypto_sign_ed25519_sk_to_curve25519(Buffer.from(keypair.privateKey)) // Secret bytes to scalar bytes
|
|
124203
|
+
kxSelfPrivateKey = sodium.crypto_sign_ed25519_sk_to_curve25519(Buffer.from(keypair.privateKey, 'hex')) // Secret bytes to scalar bytes
|
|
124204
124204
|
;
|
|
124205
124205
|
kxSelfPublicKey = sodium.crypto_sign_ed25519_pk_to_curve25519(Buffer.from(keypair.publicKey, 'hex')) // Secret bytes to scalar bytes
|
|
124206
124206
|
;
|
|
@@ -124244,7 +124244,10 @@ var NonExtendedProtocol = /** @class */ (function () {
|
|
|
124244
124244
|
return Promise.reject('extended private key signing for not implemented');
|
|
124245
124245
|
};
|
|
124246
124246
|
NonExtendedProtocol.prototype.getAddressFromExtendedPublicKey = function (extendedPublicKey, visibilityDerivationIndex, addressDerivationIndex) {
|
|
124247
|
-
return Promise.resolve({
|
|
124247
|
+
return Promise.resolve({
|
|
124248
|
+
address: '',
|
|
124249
|
+
cursor: { hasNext: false }
|
|
124250
|
+
});
|
|
124248
124251
|
};
|
|
124249
124252
|
NonExtendedProtocol.prototype.getAddressesFromExtendedPublicKey = function (extendedPublicKey, visibilityDerivationIndex, addressCount, offset) {
|
|
124250
124253
|
return Promise.resolve([]);
|
|
@@ -124336,7 +124339,7 @@ var Secp256k1CryptoClient = /** @class */ (function (_super) {
|
|
|
124336
124339
|
Secp256k1CryptoClient.prototype.decryptAsymmetric = function (encryptedPayload, keypair) {
|
|
124337
124340
|
return __awaiter(this, void 0, void 0, function () {
|
|
124338
124341
|
return __generator(this, function (_a) {
|
|
124339
|
-
return [2 /*return*/, index_1.decrypt(keypair.privateKey
|
|
124342
|
+
return [2 /*return*/, index_1.decrypt(keypair.privateKey, Buffer.from(encryptedPayload, 'hex')).toString()];
|
|
124340
124343
|
});
|
|
124341
124344
|
});
|
|
124342
124345
|
};
|
|
@@ -124459,7 +124462,7 @@ var AeternityAddress = /** @class */ (function () {
|
|
|
124459
124462
|
var base58 = bs58check.encode(Buffer.from(publicKey, 'hex'));
|
|
124460
124463
|
return new AeternityAddress("ak_" + base58);
|
|
124461
124464
|
};
|
|
124462
|
-
AeternityAddress.prototype.
|
|
124465
|
+
AeternityAddress.prototype.asString = function () {
|
|
124463
124466
|
return this.value;
|
|
124464
124467
|
};
|
|
124465
124468
|
return AeternityAddress;
|
|
@@ -124547,7 +124550,7 @@ var AeternityCryptoClient = /** @class */ (function (_super) {
|
|
|
124547
124550
|
case 1:
|
|
124548
124551
|
_a.sent();
|
|
124549
124552
|
messageBuffer = personalMessageToBinary(message);
|
|
124550
|
-
rawSignature = sodium.crypto_sign_detached(messageBuffer, keypair.privateKey);
|
|
124553
|
+
rawSignature = sodium.crypto_sign_detached(messageBuffer, Buffer.from(keypair.privateKey, 'hex'));
|
|
124551
124554
|
return [2 /*return*/, Buffer.from(rawSignature).toString('hex')];
|
|
124552
124555
|
}
|
|
124553
124556
|
});
|
|
@@ -124656,6 +124659,8 @@ var index_2 = require("../../dependencies/src/bip39-2.5.0/index");
|
|
|
124656
124659
|
var bs58check = __importStar(require("../../dependencies/src/bs58check-2.1.2/index"));
|
|
124657
124660
|
var index_3 = require("../../dependencies/src/hd-wallet-js-b216450e56954a6e82ace0aade9474673de5d9d5/src/index");
|
|
124658
124661
|
var rlp = __importStar(require("../../dependencies/src/rlp-2.2.3/index"));
|
|
124662
|
+
var errors_1 = require("../../errors");
|
|
124663
|
+
var coinlib_error_1 = require("../../errors/coinlib-error");
|
|
124659
124664
|
var base64Check_1 = __importDefault(require("../../utils/base64Check"));
|
|
124660
124665
|
var padStart_1 = require("../../utils/padStart");
|
|
124661
124666
|
var ProtocolSymbols_1 = require("../../utils/ProtocolSymbols");
|
|
@@ -124664,8 +124669,6 @@ var NonExtendedProtocol_1 = require("../NonExtendedProtocol");
|
|
|
124664
124669
|
var AeternityAddress_1 = require("./AeternityAddress");
|
|
124665
124670
|
var AeternityCryptoClient_1 = require("./AeternityCryptoClient");
|
|
124666
124671
|
var AeternityProtocolOptions_1 = require("./AeternityProtocolOptions");
|
|
124667
|
-
var errors_1 = require("../../errors");
|
|
124668
|
-
var coinlib_error_1 = require("../../errors/coinlib-error");
|
|
124669
124672
|
var AeternityProtocol = /** @class */ (function (_super) {
|
|
124670
124673
|
__extends(AeternityProtocol, _super);
|
|
124671
124674
|
function AeternityProtocol(options) {
|
|
@@ -124757,23 +124760,26 @@ var AeternityProtocol = /** @class */ (function (_super) {
|
|
|
124757
124760
|
var secretKey;
|
|
124758
124761
|
return __generator(this, function (_a) {
|
|
124759
124762
|
secretKey = index_3.generateWalletUsingDerivationPath(Buffer.from(secret, 'hex'), derivationPath).secretKey;
|
|
124760
|
-
return [2 /*return*/, Buffer.from(secretKey)];
|
|
124763
|
+
return [2 /*return*/, Buffer.from(secretKey).toString('hex')];
|
|
124761
124764
|
});
|
|
124762
124765
|
});
|
|
124763
124766
|
};
|
|
124764
|
-
AeternityProtocol.prototype.getAddressFromPublicKey = function (publicKey) {
|
|
124767
|
+
AeternityProtocol.prototype.getAddressFromPublicKey = function (publicKey, cursor) {
|
|
124765
124768
|
return __awaiter(this, void 0, void 0, function () {
|
|
124766
124769
|
return __generator(this, function (_a) {
|
|
124767
|
-
return [2 /*return*/,
|
|
124770
|
+
return [2 /*return*/, {
|
|
124771
|
+
address: AeternityAddress_1.AeternityAddress.from(publicKey).asString(),
|
|
124772
|
+
cursor: { hasNext: false }
|
|
124773
|
+
}];
|
|
124768
124774
|
});
|
|
124769
124775
|
});
|
|
124770
124776
|
};
|
|
124771
|
-
AeternityProtocol.prototype.getAddressesFromPublicKey = function (publicKey) {
|
|
124777
|
+
AeternityProtocol.prototype.getAddressesFromPublicKey = function (publicKey, cursor) {
|
|
124772
124778
|
return __awaiter(this, void 0, void 0, function () {
|
|
124773
124779
|
var address;
|
|
124774
124780
|
return __generator(this, function (_a) {
|
|
124775
124781
|
switch (_a.label) {
|
|
124776
|
-
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
124782
|
+
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey, cursor)];
|
|
124777
124783
|
case 1:
|
|
124778
124784
|
address = _a.sent();
|
|
124779
124785
|
return [2 /*return*/, [address]];
|
|
@@ -124781,13 +124787,6 @@ var AeternityProtocol = /** @class */ (function (_super) {
|
|
|
124781
124787
|
});
|
|
124782
124788
|
});
|
|
124783
124789
|
};
|
|
124784
|
-
AeternityProtocol.prototype.getNextAddressFromPublicKey = function (publicKey, current) {
|
|
124785
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
124786
|
-
return __generator(this, function (_a) {
|
|
124787
|
-
return [2 /*return*/, current];
|
|
124788
|
-
});
|
|
124789
|
-
});
|
|
124790
|
-
};
|
|
124791
124790
|
AeternityProtocol.prototype.getTransactionsFromPublicKey = function (publicKey, limit, cursor) {
|
|
124792
124791
|
return __awaiter(this, void 0, void 0, function () {
|
|
124793
124792
|
var address;
|
|
@@ -124796,7 +124795,7 @@ var AeternityProtocol = /** @class */ (function (_super) {
|
|
|
124796
124795
|
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
124797
124796
|
case 1:
|
|
124798
124797
|
address = _a.sent();
|
|
124799
|
-
return [2 /*return*/, this.getTransactionsFromAddresses([address.
|
|
124798
|
+
return [2 /*return*/, this.getTransactionsFromAddresses([address.address], limit, cursor)];
|
|
124800
124799
|
}
|
|
124801
124800
|
});
|
|
124802
124801
|
});
|
|
@@ -124860,7 +124859,7 @@ var AeternityProtocol = /** @class */ (function (_super) {
|
|
|
124860
124859
|
return [4 /*yield*/, sodium.ready];
|
|
124861
124860
|
case 1:
|
|
124862
124861
|
_a.sent();
|
|
124863
|
-
signature = sodium.crypto_sign_detached(Buffer.concat([Buffer.from(transaction.networkId), rawTx]), privateKey);
|
|
124862
|
+
signature = sodium.crypto_sign_detached(Buffer.concat([Buffer.from(transaction.networkId), rawTx]), Buffer.from(privateKey, 'hex'));
|
|
124864
124863
|
txObj = {
|
|
124865
124864
|
tag: this.toHexBuffer(11),
|
|
124866
124865
|
version: this.toHexBuffer(1),
|
|
@@ -124911,11 +124910,11 @@ var AeternityProtocol = /** @class */ (function (_super) {
|
|
|
124911
124910
|
airgapTx = {
|
|
124912
124911
|
amount: new bignumber_1.default(parseInt(rlpDecodedTx[4].toString('hex'), 16)).toString(10),
|
|
124913
124912
|
fee: new bignumber_1.default(parseInt(rlpDecodedTx[5].toString('hex'), 16)).toString(10),
|
|
124914
|
-
from: [fromAddress.
|
|
124913
|
+
from: [fromAddress.address],
|
|
124915
124914
|
isInbound: false,
|
|
124916
124915
|
protocolIdentifier: this.identifier,
|
|
124917
124916
|
network: this.options.network,
|
|
124918
|
-
to: [toAddress.
|
|
124917
|
+
to: [toAddress.address],
|
|
124919
124918
|
data: (rlpDecodedTx[8] || '').toString('utf8'),
|
|
124920
124919
|
transactionDetails: unsignedTx.transaction
|
|
124921
124920
|
};
|
|
@@ -124984,7 +124983,7 @@ var AeternityProtocol = /** @class */ (function (_super) {
|
|
|
124984
124983
|
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
124985
124984
|
case 1:
|
|
124986
124985
|
address = _a.sent();
|
|
124987
|
-
return [2 /*return*/, this.getBalanceOfAddresses([address.
|
|
124986
|
+
return [2 /*return*/, this.getBalanceOfAddresses([address.address])];
|
|
124988
124987
|
}
|
|
124989
124988
|
});
|
|
124990
124989
|
});
|
|
@@ -125056,7 +125055,7 @@ var AeternityProtocol = /** @class */ (function (_super) {
|
|
|
125056
125055
|
_b.label = 2;
|
|
125057
125056
|
case 2:
|
|
125058
125057
|
_b.trys.push([2, 4, , 5]);
|
|
125059
|
-
return [4 /*yield*/, index_1.default.get(this.options.network.rpcUrl + "/v2/accounts/" + address.
|
|
125058
|
+
return [4 /*yield*/, index_1.default.get(this.options.network.rpcUrl + "/v2/accounts/" + address.address)];
|
|
125060
125059
|
case 3:
|
|
125061
125060
|
accountResponse = (_b.sent()).data;
|
|
125062
125061
|
nonce = accountResponse.nonce + 1;
|
|
@@ -125308,7 +125307,7 @@ var BitcoinAddress = /** @class */ (function () {
|
|
|
125308
125307
|
: node;
|
|
125309
125308
|
return new BitcoinAddress(_node.getAddress(), visibilityDerivationIndex, addressDerivationIndex);
|
|
125310
125309
|
};
|
|
125311
|
-
BitcoinAddress.prototype.
|
|
125310
|
+
BitcoinAddress.prototype.asString = function () {
|
|
125312
125311
|
return this.value;
|
|
125313
125312
|
};
|
|
125314
125313
|
return BitcoinAddress;
|
|
@@ -125382,7 +125381,7 @@ var BitcoinCryptoClient = /** @class */ (function (_super) {
|
|
|
125382
125381
|
return __awaiter(this, void 0, void 0, function () {
|
|
125383
125382
|
var signature;
|
|
125384
125383
|
return __generator(this, function (_a) {
|
|
125385
|
-
signature = this.bitcoinJSMessage.sign(message, keypair.privateKey, true);
|
|
125384
|
+
signature = this.bitcoinJSMessage.sign(message, Buffer.from(keypair.privateKey, 'hex'), true);
|
|
125386
125385
|
return [2 /*return*/, signature.toString('base64')];
|
|
125387
125386
|
});
|
|
125388
125387
|
});
|
|
@@ -125397,7 +125396,7 @@ var BitcoinCryptoClient = /** @class */ (function (_super) {
|
|
|
125397
125396
|
return [4 /*yield*/, this.protocol.getAddressFromPublicKey(publicKey)];
|
|
125398
125397
|
case 1:
|
|
125399
125398
|
address = _a.sent();
|
|
125400
|
-
return [2 /*return*/, this.bitcoinJSMessage.verify(message, address.
|
|
125399
|
+
return [2 /*return*/, this.bitcoinJSMessage.verify(message, address.address, rawSignature)];
|
|
125401
125400
|
}
|
|
125402
125401
|
});
|
|
125403
125402
|
});
|
|
@@ -125408,6 +125407,7 @@ exports.BitcoinCryptoClient = BitcoinCryptoClient;
|
|
|
125408
125407
|
|
|
125409
125408
|
}).call(this)}).call(this,require("buffer").Buffer)
|
|
125410
125409
|
},{"../Secp256k1CryptoClient":498,"buffer":67}],506:[function(require,module,exports){
|
|
125410
|
+
(function (Buffer){(function (){
|
|
125411
125411
|
"use strict";
|
|
125412
125412
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
125413
125413
|
if (k2 === undefined) k2 = k;
|
|
@@ -125580,7 +125580,7 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
125580
125580
|
var bitcoinNode;
|
|
125581
125581
|
return __generator(this, function (_a) {
|
|
125582
125582
|
bitcoinNode = this.options.config.bitcoinJSLib.HDNode.fromSeedHex(secret, this.options.network.extras.network);
|
|
125583
|
-
return [2 /*return*/, bitcoinNode.derivePath(derivationPath).keyPair.d.toBuffer(32)];
|
|
125583
|
+
return [2 /*return*/, bitcoinNode.derivePath(derivationPath).keyPair.d.toBuffer(32).toString('hex')];
|
|
125584
125584
|
});
|
|
125585
125585
|
});
|
|
125586
125586
|
};
|
|
@@ -125593,20 +125593,24 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
125593
125593
|
});
|
|
125594
125594
|
});
|
|
125595
125595
|
};
|
|
125596
|
-
BitcoinProtocol.prototype.getAddressFromPublicKey = function (publicKey) {
|
|
125596
|
+
BitcoinProtocol.prototype.getAddressFromPublicKey = function (publicKey, cursor) {
|
|
125597
125597
|
return __awaiter(this, void 0, void 0, function () {
|
|
125598
|
-
var node;
|
|
125598
|
+
var node, address;
|
|
125599
125599
|
return __generator(this, function (_a) {
|
|
125600
125600
|
node = this.options.config.bitcoinJSLib.HDNode.fromBase58(publicKey, this.options.network.extras.network);
|
|
125601
|
-
|
|
125601
|
+
address = BitcoinAddress_1.BitcoinAddress.from(node);
|
|
125602
|
+
return [2 /*return*/, {
|
|
125603
|
+
address: address.asString(),
|
|
125604
|
+
cursor: { hasNext: false }
|
|
125605
|
+
}];
|
|
125602
125606
|
});
|
|
125603
125607
|
});
|
|
125604
125608
|
};
|
|
125605
|
-
BitcoinProtocol.prototype.getAddressesFromPublicKey = function (publicKey) {
|
|
125609
|
+
BitcoinProtocol.prototype.getAddressesFromPublicKey = function (publicKey, cursor) {
|
|
125606
125610
|
return __awaiter(this, void 0, void 0, function () {
|
|
125607
125611
|
return __generator(this, function (_a) {
|
|
125608
125612
|
switch (_a.label) {
|
|
125609
|
-
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
125613
|
+
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey, cursor)];
|
|
125610
125614
|
case 1: return [2 /*return*/, [_a.sent()]];
|
|
125611
125615
|
}
|
|
125612
125616
|
});
|
|
@@ -125614,10 +125618,14 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
125614
125618
|
};
|
|
125615
125619
|
BitcoinProtocol.prototype.getAddressFromExtendedPublicKey = function (extendedPublicKey, visibilityDerivationIndex, addressDerivationIndex) {
|
|
125616
125620
|
return __awaiter(this, void 0, void 0, function () {
|
|
125617
|
-
var node;
|
|
125621
|
+
var node, address;
|
|
125618
125622
|
return __generator(this, function (_a) {
|
|
125619
125623
|
node = this.options.config.bitcoinJSLib.HDNode.fromBase58(extendedPublicKey, this.options.network.extras.network);
|
|
125620
|
-
|
|
125624
|
+
address = BitcoinAddress_1.BitcoinAddress.from(node, visibilityDerivationIndex, addressDerivationIndex);
|
|
125625
|
+
return [2 /*return*/, {
|
|
125626
|
+
address: address.asString(),
|
|
125627
|
+
cursor: { hasNext: false }
|
|
125628
|
+
}];
|
|
125621
125629
|
});
|
|
125622
125630
|
});
|
|
125623
125631
|
};
|
|
@@ -125627,16 +125635,13 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
125627
125635
|
return __generator(this, function (_a) {
|
|
125628
125636
|
node = this.options.config.bitcoinJSLib.HDNode.fromBase58(extendedPublicKey, this.options.network.extras.network);
|
|
125629
125637
|
generatorArray = Array.from(new Array(addressCount), function (_, i) { return i + offset; });
|
|
125630
|
-
return [2 /*return*/, Promise.all(generatorArray.map(function (x) {
|
|
125631
|
-
|
|
125632
|
-
|
|
125633
|
-
|
|
125634
|
-
|
|
125635
|
-
|
|
125636
|
-
|
|
125637
|
-
return __generator(this, function (_a) {
|
|
125638
|
-
node = this.options.config.bitcoinJSLib.HDNode.fromBase58(publicKey, this.options.network.extras.network);
|
|
125639
|
-
return [2 /*return*/, BitcoinAddress_1.BitcoinAddress.from(node, current.visibilityDerivationIndex, current.addressDerivationIndex !== undefined ? current.addressDerivationIndex + 1 : undefined)];
|
|
125638
|
+
return [2 /*return*/, Promise.all(generatorArray.map(function (x) {
|
|
125639
|
+
var address = BitcoinAddress_1.BitcoinAddress.from(node, visibilityDerivationIndex, x);
|
|
125640
|
+
return {
|
|
125641
|
+
address: address.asString(),
|
|
125642
|
+
cursor: { hasNext: false }
|
|
125643
|
+
};
|
|
125644
|
+
}))];
|
|
125640
125645
|
});
|
|
125641
125646
|
});
|
|
125642
125647
|
};
|
|
@@ -125657,9 +125662,9 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
125657
125662
|
if (!(_b < _c.length)) return [3 /*break*/, 5];
|
|
125658
125663
|
output = _c[_b];
|
|
125659
125664
|
if (!output.isChange) return [3 /*break*/, 3];
|
|
125660
|
-
return [4 /*yield*/, this.getAddressFromPublicKey(privateKey
|
|
125665
|
+
return [4 /*yield*/, this.getAddressFromPublicKey(privateKey)];
|
|
125661
125666
|
case 2:
|
|
125662
|
-
generatedChangeAddress = (_d.sent()).
|
|
125667
|
+
generatedChangeAddress = (_d.sent()).address;
|
|
125663
125668
|
if (generatedChangeAddress !== output.recipient) {
|
|
125664
125669
|
throw new errors_1.ConditionViolationError(coinlib_error_1.Domain.BITCOIN, 'Change address could not be verified.');
|
|
125665
125670
|
}
|
|
@@ -125672,7 +125677,7 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
125672
125677
|
return [3 /*break*/, 1];
|
|
125673
125678
|
case 5:
|
|
125674
125679
|
for (i = 0; i < transaction.ins.length; i++) {
|
|
125675
|
-
transactionBuilder.sign(i, privateKey);
|
|
125680
|
+
transactionBuilder.sign(i, Buffer.from(privateKey, 'hex'));
|
|
125676
125681
|
}
|
|
125677
125682
|
return [2 /*return*/, transactionBuilder.build().toHex()];
|
|
125678
125683
|
}
|
|
@@ -125703,7 +125708,7 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
125703
125708
|
if (!output.derivationPath) return [3 /*break*/, 3];
|
|
125704
125709
|
return [4 /*yield*/, this.getAddressesFromExtendedPublicKey(extendedPrivateKey, 1, 1, parseInt(output.derivationPath, 10))];
|
|
125705
125710
|
case 2:
|
|
125706
|
-
generatedChangeAddress = (_d.sent()).map(function (address) { return address.
|
|
125711
|
+
generatedChangeAddress = (_d.sent()).map(function (address) { return address.address; });
|
|
125707
125712
|
changeAddressIsValid = generatedChangeAddress.includes(output.recipient);
|
|
125708
125713
|
return [3 /*break*/, 7];
|
|
125709
125714
|
case 3:
|
|
@@ -125713,7 +125718,7 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
125713
125718
|
if (!(x < changeAddressMaxAddresses)) return [3 /*break*/, 7];
|
|
125714
125719
|
return [4 /*yield*/, this.getAddressesFromExtendedPublicKey(extendedPrivateKey, 1, changeAddressBatchSize, x)];
|
|
125715
125720
|
case 5:
|
|
125716
|
-
addresses = (_d.sent()).map(function (address) { return address.
|
|
125721
|
+
addresses = (_d.sent()).map(function (address) { return address.address; });
|
|
125717
125722
|
if (addresses.indexOf(output.recipient) >= 0) {
|
|
125718
125723
|
changeAddressIsValid = true;
|
|
125719
125724
|
x = changeAddressMaxAddresses;
|
|
@@ -125839,7 +125844,7 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
125839
125844
|
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
125840
125845
|
case 1:
|
|
125841
125846
|
address = _a.sent();
|
|
125842
|
-
return [2 /*return*/, this.getBalanceOfAddresses([address.
|
|
125847
|
+
return [2 /*return*/, this.getBalanceOfAddresses([address.address])];
|
|
125843
125848
|
}
|
|
125844
125849
|
});
|
|
125845
125850
|
});
|
|
@@ -125972,7 +125977,7 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
125972
125977
|
return [4 /*yield*/, this.getAddressFromExtendedPublicKey(extendedPublicKey, indexes[0], indexes[1])];
|
|
125973
125978
|
case 3:
|
|
125974
125979
|
derivedAddress = _a.sent();
|
|
125975
|
-
if (derivedAddress.
|
|
125980
|
+
if (derivedAddress.address === utxo.address) {
|
|
125976
125981
|
transaction.ins.push({
|
|
125977
125982
|
txId: utxo.txid,
|
|
125978
125983
|
value: new bignumber_1.default(utxo.value).toString(10),
|
|
@@ -126015,7 +126020,7 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
126015
126020
|
case 6:
|
|
126016
126021
|
derivedAddress = _a.sent();
|
|
126017
126022
|
transaction.outs.push({
|
|
126018
|
-
recipient: derivedAddress.
|
|
126023
|
+
recipient: derivedAddress.address,
|
|
126019
126024
|
isChange: true,
|
|
126020
126025
|
value: changeValue.toString(10),
|
|
126021
126026
|
derivationPath: changeAddressIndex.toString()
|
|
@@ -126043,7 +126048,7 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
126043
126048
|
}
|
|
126044
126049
|
return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
126045
126050
|
case 1:
|
|
126046
|
-
address = (_a.sent()).
|
|
126051
|
+
address = (_a.sent()).address;
|
|
126047
126052
|
return [4 /*yield*/, index_1.default.get(this.options.network.extras.indexerApi + "/api/v2/utxo/" + address, {
|
|
126048
126053
|
responseType: 'json'
|
|
126049
126054
|
})];
|
|
@@ -126189,7 +126194,7 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
126189
126194
|
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
126190
126195
|
case 1:
|
|
126191
126196
|
address = _a.sent();
|
|
126192
|
-
return [2 /*return*/, this.getTransactionsFromAddresses([address.
|
|
126197
|
+
return [2 /*return*/, this.getTransactionsFromAddresses([address.address], limit, cursor)];
|
|
126193
126198
|
}
|
|
126194
126199
|
});
|
|
126195
126200
|
});
|
|
@@ -126305,11 +126310,11 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
126305
126310
|
return __awaiter(this, void 0, void 0, function () {
|
|
126306
126311
|
var childPrivateKey;
|
|
126307
126312
|
return __generator(this, function (_a) {
|
|
126308
|
-
childPrivateKey = this.options.config.bitcoinJSLib.HDNode.fromBase58(keypair.privateKey
|
|
126313
|
+
childPrivateKey = this.options.config.bitcoinJSLib.HDNode.fromBase58(keypair.privateKey, this.options.network.extras.network)
|
|
126309
126314
|
.derive(0)
|
|
126310
126315
|
.derive(0)
|
|
126311
126316
|
.keyPair.d.toBuffer(32);
|
|
126312
|
-
return [2 /*return*/, this.cryptoClient.decryptAsymmetric(message, { publicKey: '', privateKey: childPrivateKey })];
|
|
126317
|
+
return [2 /*return*/, this.cryptoClient.decryptAsymmetric(message, { publicKey: '', privateKey: childPrivateKey.toString('hex') })];
|
|
126313
126318
|
});
|
|
126314
126319
|
});
|
|
126315
126320
|
};
|
|
@@ -126338,7 +126343,8 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
126338
126343
|
}());
|
|
126339
126344
|
exports.BitcoinProtocol = BitcoinProtocol;
|
|
126340
126345
|
|
|
126341
|
-
}
|
|
126346
|
+
}).call(this)}).call(this,require("buffer").Buffer)
|
|
126347
|
+
},{"../../dependencies/src/axios-0.19.0/index":235,"../../dependencies/src/bignumber.js-9.0.0/bignumber":269,"../../dependencies/src/bip39-2.5.0/index":274,"../../dependencies/src/bitcoinjs-message-2.1.1/index":286,"../../errors":491,"../../errors/coinlib-error":490,"../../utils/ProtocolSymbols":799,"./BitcoinAddress":504,"./BitcoinCryptoClient":505,"./BitcoinProtocolOptions":507,"buffer":67}],507:[function(require,module,exports){
|
|
126342
126348
|
"use strict";
|
|
126343
126349
|
var __extends = (this && this.__extends) || (function () {
|
|
126344
126350
|
var extendStatics = function (d, b) {
|
|
@@ -126514,7 +126520,7 @@ var BitcoinSegwitAddress = /** @class */ (function (_super) {
|
|
|
126514
126520
|
BitcoinSegwitAddress.fromAddress = function (address) {
|
|
126515
126521
|
return new BitcoinSegwitAddress(address, 0, 0);
|
|
126516
126522
|
};
|
|
126517
|
-
BitcoinSegwitAddress.prototype.
|
|
126523
|
+
BitcoinSegwitAddress.prototype.asString = function () {
|
|
126518
126524
|
return this.value;
|
|
126519
126525
|
};
|
|
126520
126526
|
return BitcoinSegwitAddress;
|
|
@@ -126604,6 +126610,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
126604
126610
|
};
|
|
126605
126611
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
126606
126612
|
exports.BitcoinSegwitProtocol = void 0;
|
|
126613
|
+
// tslint:disable: max-classes-per-file
|
|
126607
126614
|
var __1 = require("../..");
|
|
126608
126615
|
var index_1 = require("../../dependencies/src/bip39-2.5.0/index");
|
|
126609
126616
|
var index_2 = __importDefault(require("../../dependencies/src/axios-0.19.0/index"));
|
|
@@ -126679,7 +126686,7 @@ var BitcoinSegwitProtocol = /** @class */ (function (_super) {
|
|
|
126679
126686
|
if (!privateKey) {
|
|
126680
126687
|
throw new Error('No privatekey!');
|
|
126681
126688
|
}
|
|
126682
|
-
return [2 /*return*/, privateKey];
|
|
126689
|
+
return [2 /*return*/, privateKey.toString('hex')];
|
|
126683
126690
|
});
|
|
126684
126691
|
});
|
|
126685
126692
|
};
|
|
@@ -126701,19 +126708,23 @@ var BitcoinSegwitProtocol = /** @class */ (function (_super) {
|
|
|
126701
126708
|
});
|
|
126702
126709
|
});
|
|
126703
126710
|
};
|
|
126704
|
-
BitcoinSegwitProtocol.prototype.getAddressFromPublicKey = function (publicKey) {
|
|
126711
|
+
BitcoinSegwitProtocol.prototype.getAddressFromPublicKey = function (publicKey, cursor) {
|
|
126705
126712
|
return __awaiter(this, void 0, void 0, function () {
|
|
126713
|
+
var address;
|
|
126706
126714
|
return __generator(this, function (_a) {
|
|
126707
|
-
|
|
126708
|
-
return [2 /*return*/,
|
|
126715
|
+
address = BitcoinSegwitAddress_1.BitcoinSegwitAddress.fromAddress(bitcoinJS.bip32.fromBase58(publicKey, this.options.network.extras.network).toBase58());
|
|
126716
|
+
return [2 /*return*/, {
|
|
126717
|
+
address: address.asString(),
|
|
126718
|
+
cursor: { hasNext: false }
|
|
126719
|
+
}];
|
|
126709
126720
|
});
|
|
126710
126721
|
});
|
|
126711
126722
|
};
|
|
126712
|
-
BitcoinSegwitProtocol.prototype.getAddressesFromPublicKey = function (publicKey) {
|
|
126723
|
+
BitcoinSegwitProtocol.prototype.getAddressesFromPublicKey = function (publicKey, cursor) {
|
|
126713
126724
|
return __awaiter(this, void 0, void 0, function () {
|
|
126714
126725
|
return __generator(this, function (_a) {
|
|
126715
126726
|
switch (_a.label) {
|
|
126716
|
-
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
126727
|
+
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey, cursor)];
|
|
126717
126728
|
case 1: return [2 /*return*/, [_a.sent()]];
|
|
126718
126729
|
}
|
|
126719
126730
|
});
|
|
@@ -126721,7 +126732,7 @@ var BitcoinSegwitProtocol = /** @class */ (function (_super) {
|
|
|
126721
126732
|
};
|
|
126722
126733
|
BitcoinSegwitProtocol.prototype.getAddressFromExtendedPublicKey = function (extendedPublicKey, visibilityDerivationIndex, addressDerivationIndex) {
|
|
126723
126734
|
return __awaiter(this, void 0, void 0, function () {
|
|
126724
|
-
var xpub, keyPair, obj, address;
|
|
126735
|
+
var xpub, keyPair, obj, addressRaw, address;
|
|
126725
126736
|
return __generator(this, function (_a) {
|
|
126726
126737
|
xpub = new ExtendedPublicKey(extendedPublicKey).toXpub();
|
|
126727
126738
|
keyPair = bitcoinJS.bip32
|
|
@@ -126729,11 +126740,15 @@ var BitcoinSegwitProtocol = /** @class */ (function (_super) {
|
|
|
126729
126740
|
.derive(visibilityDerivationIndex)
|
|
126730
126741
|
.derive(addressDerivationIndex);
|
|
126731
126742
|
obj = bitcoinJS.payments.p2wpkh({ pubkey: keyPair.publicKey });
|
|
126732
|
-
|
|
126733
|
-
if (!
|
|
126743
|
+
addressRaw = obj.address;
|
|
126744
|
+
if (!addressRaw) {
|
|
126734
126745
|
throw new Error('could not generate address');
|
|
126735
126746
|
}
|
|
126736
|
-
|
|
126747
|
+
address = BitcoinSegwitAddress_1.BitcoinSegwitAddress.fromAddress(addressRaw);
|
|
126748
|
+
return [2 /*return*/, {
|
|
126749
|
+
address: address.asString(),
|
|
126750
|
+
cursor: { hasNext: false }
|
|
126751
|
+
}];
|
|
126737
126752
|
});
|
|
126738
126753
|
});
|
|
126739
126754
|
};
|
|
@@ -126743,11 +126758,15 @@ var BitcoinSegwitProtocol = /** @class */ (function (_super) {
|
|
|
126743
126758
|
var generatorArray = Array.from(new Array(addressCount), function (x, i) { return i + offset; });
|
|
126744
126759
|
return Promise.all(generatorArray.map(function (x) {
|
|
126745
126760
|
var keyPair = node.derive(visibilityDerivationIndex).derive(x);
|
|
126746
|
-
var
|
|
126747
|
-
if (!
|
|
126761
|
+
var addressRaw = bitcoinJS.payments.p2wpkh({ pubkey: keyPair.publicKey }).address;
|
|
126762
|
+
if (!addressRaw) {
|
|
126748
126763
|
throw new Error('could not generate address');
|
|
126749
126764
|
}
|
|
126750
|
-
|
|
126765
|
+
var address = BitcoinSegwitAddress_1.BitcoinSegwitAddress.fromAddress(addressRaw);
|
|
126766
|
+
return {
|
|
126767
|
+
address: address.asString(),
|
|
126768
|
+
cursor: { hasNext: false }
|
|
126769
|
+
};
|
|
126751
126770
|
}));
|
|
126752
126771
|
};
|
|
126753
126772
|
BitcoinSegwitProtocol.prototype.getTransactionDetails = function (unsignedTx) {
|
|
@@ -126900,7 +126919,7 @@ var BitcoinSegwitProtocol = /** @class */ (function (_super) {
|
|
|
126900
126919
|
indexes = getPathIndexes(utxo.path);
|
|
126901
126920
|
return [4 /*yield*/, this.getAddressFromExtendedPublicKey(extendedPublicKey, indexes[0], indexes[1])];
|
|
126902
126921
|
case 3:
|
|
126903
|
-
derivedAddress = (_a.sent()).
|
|
126922
|
+
derivedAddress = (_a.sent()).address;
|
|
126904
126923
|
if (derivedAddress === utxo.address) {
|
|
126905
126924
|
transaction.ins.push({
|
|
126906
126925
|
txId: utxo.txid,
|
|
@@ -126941,7 +126960,7 @@ var BitcoinSegwitProtocol = /** @class */ (function (_super) {
|
|
|
126941
126960
|
changeAddressIndex = lastUsedInternalAddress + 1;
|
|
126942
126961
|
return [4 /*yield*/, this.getAddressFromExtendedPublicKey(extendedPublicKey, 1, changeAddressIndex)];
|
|
126943
126962
|
case 6:
|
|
126944
|
-
derivedAddress = (_a.sent()).
|
|
126963
|
+
derivedAddress = (_a.sent()).address;
|
|
126945
126964
|
transaction.outs.push({
|
|
126946
126965
|
recipient: derivedAddress,
|
|
126947
126966
|
isChange: true,
|
|
@@ -127113,7 +127132,7 @@ var CosmosAddress = /** @class */ (function () {
|
|
|
127113
127132
|
var address = BECH32.encode(CosmosAddress.addressPrefix, BECH32.toWords(hash));
|
|
127114
127133
|
return new CosmosAddress(address);
|
|
127115
127134
|
};
|
|
127116
|
-
CosmosAddress.prototype.
|
|
127135
|
+
CosmosAddress.prototype.asString = function () {
|
|
127117
127136
|
return this.value;
|
|
127118
127137
|
};
|
|
127119
127138
|
CosmosAddress.addressPrefix = 'cosmos';
|
|
@@ -127246,7 +127265,7 @@ var CosmosCryptoClient = /** @class */ (function (_super) {
|
|
|
127246
127265
|
return __generator(this, function (_a) {
|
|
127247
127266
|
sha256Hash = sha('sha256').update(Buffer.from(message)).digest();
|
|
127248
127267
|
hash = Buffer.from(sha256Hash);
|
|
127249
|
-
signed = SECP256K1.sign(hash, keypair.privateKey);
|
|
127268
|
+
signed = SECP256K1.sign(hash, Buffer.from(keypair.privateKey, 'hex'));
|
|
127250
127269
|
return [2 /*return*/, "0x" + Buffer.from(signed.signature).toString('hex')];
|
|
127251
127270
|
});
|
|
127252
127271
|
});
|
|
@@ -127865,7 +127884,7 @@ var CosmosProtocol = /** @class */ (function (_super) {
|
|
|
127865
127884
|
CosmosProtocol.prototype.getPrivateKeyFromMnemonic = function (mnemonic, derivationPath, password) {
|
|
127866
127885
|
return __awaiter(this, void 0, void 0, function () {
|
|
127867
127886
|
return __generator(this, function (_a) {
|
|
127868
|
-
return [2 /*return*/, this.generateKeyPair(mnemonic, derivationPath, password).privateKey];
|
|
127887
|
+
return [2 /*return*/, this.generateKeyPair(mnemonic, derivationPath, password).privateKey.toString('hex')];
|
|
127869
127888
|
});
|
|
127870
127889
|
});
|
|
127871
127890
|
};
|
|
@@ -127887,34 +127906,32 @@ var CosmosProtocol = /** @class */ (function (_super) {
|
|
|
127887
127906
|
var node;
|
|
127888
127907
|
return __generator(this, function (_a) {
|
|
127889
127908
|
node = index_1.fromSeed(Buffer.from(secret, 'hex'));
|
|
127890
|
-
return [2 /*return*/, this.generateKeyPairFromNode(node, derivationPath).privateKey];
|
|
127909
|
+
return [2 /*return*/, this.generateKeyPairFromNode(node, derivationPath).privateKey.toString('hex')];
|
|
127891
127910
|
});
|
|
127892
127911
|
});
|
|
127893
127912
|
};
|
|
127894
|
-
CosmosProtocol.prototype.getAddressFromPublicKey = function (publicKey) {
|
|
127913
|
+
CosmosProtocol.prototype.getAddressFromPublicKey = function (publicKey, cursor) {
|
|
127895
127914
|
return __awaiter(this, void 0, void 0, function () {
|
|
127915
|
+
var address;
|
|
127896
127916
|
return __generator(this, function (_a) {
|
|
127897
|
-
|
|
127917
|
+
address = CosmosAddress_1.CosmosAddress.from(publicKey);
|
|
127918
|
+
return [2 /*return*/, {
|
|
127919
|
+
address: address.asString(),
|
|
127920
|
+
cursor: { hasNext: false }
|
|
127921
|
+
}];
|
|
127898
127922
|
});
|
|
127899
127923
|
});
|
|
127900
127924
|
};
|
|
127901
|
-
CosmosProtocol.prototype.getAddressesFromPublicKey = function (publicKey) {
|
|
127925
|
+
CosmosProtocol.prototype.getAddressesFromPublicKey = function (publicKey, cursor) {
|
|
127902
127926
|
return __awaiter(this, void 0, void 0, function () {
|
|
127903
127927
|
return __generator(this, function (_a) {
|
|
127904
127928
|
switch (_a.label) {
|
|
127905
|
-
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
127929
|
+
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey, cursor)];
|
|
127906
127930
|
case 1: return [2 /*return*/, [_a.sent()]];
|
|
127907
127931
|
}
|
|
127908
127932
|
});
|
|
127909
127933
|
});
|
|
127910
127934
|
};
|
|
127911
|
-
CosmosProtocol.prototype.getNextAddressFromPublicKey = function (publicKey, current) {
|
|
127912
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
127913
|
-
return __generator(this, function (_a) {
|
|
127914
|
-
return [2 /*return*/, current];
|
|
127915
|
-
});
|
|
127916
|
-
});
|
|
127917
|
-
};
|
|
127918
127935
|
CosmosProtocol.prototype.getTransactionsFromPublicKey = function (publicKey, limit, cursor) {
|
|
127919
127936
|
return __awaiter(this, void 0, void 0, function () {
|
|
127920
127937
|
var address;
|
|
@@ -127923,7 +127940,7 @@ var CosmosProtocol = /** @class */ (function (_super) {
|
|
|
127923
127940
|
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
127924
127941
|
case 1:
|
|
127925
127942
|
address = _a.sent();
|
|
127926
|
-
return [2 /*return*/, this.getTransactionsFromAddresses([address.
|
|
127943
|
+
return [2 /*return*/, this.getTransactionsFromAddresses([address.address], limit, cursor)];
|
|
127927
127944
|
}
|
|
127928
127945
|
});
|
|
127929
127946
|
});
|
|
@@ -128045,18 +128062,19 @@ var CosmosProtocol = /** @class */ (function (_super) {
|
|
|
128045
128062
|
};
|
|
128046
128063
|
CosmosProtocol.prototype.signWithPrivateKey = function (privateKey, transaction) {
|
|
128047
128064
|
return __awaiter(this, void 0, void 0, function () {
|
|
128048
|
-
var publicKey, encodedObject, signBytes, sha256Hash, hash, signed, sigBase64, txBytes;
|
|
128065
|
+
var privateKeyBuffer, publicKey, encodedObject, signBytes, sha256Hash, hash, signed, sigBase64, txBytes;
|
|
128049
128066
|
return __generator(this, function (_a) {
|
|
128050
128067
|
switch (_a.label) {
|
|
128051
128068
|
case 0:
|
|
128052
|
-
|
|
128069
|
+
privateKeyBuffer = Buffer.from(privateKey, 'hex');
|
|
128070
|
+
publicKey = this.getPublicKeyFromPrivateKey(privateKeyBuffer);
|
|
128053
128071
|
encodedObject = transaction.toEncodeObject();
|
|
128054
128072
|
return [4 /*yield*/, cosmjs_1.prepareSignBytes(encodedObject, transaction.fee, Uint8Array.from(publicKey), new bignumber_1.default(transaction.sequence).toNumber(), transaction.chainID, new bignumber_1.default(transaction.accountNumber).toNumber())];
|
|
128055
128073
|
case 1:
|
|
128056
128074
|
signBytes = _a.sent();
|
|
128057
128075
|
sha256Hash = sha('sha256').update(signBytes).digest();
|
|
128058
128076
|
hash = Buffer.from(sha256Hash);
|
|
128059
|
-
signed = SECP256K1.sign(hash,
|
|
128077
|
+
signed = SECP256K1.sign(hash, privateKeyBuffer);
|
|
128060
128078
|
sigBase64 = Buffer.from(signed.signature, 'binary').toString('base64');
|
|
128061
128079
|
return [4 /*yield*/, cosmjs_1.encodeTxBytes(encodedObject, transaction.fee, Uint8Array.from(publicKey), new bignumber_1.default(transaction.sequence).toNumber(), {
|
|
128062
128080
|
signature: sigBase64,
|
|
@@ -128148,7 +128166,7 @@ var CosmosProtocol = /** @class */ (function (_super) {
|
|
|
128148
128166
|
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
128149
128167
|
case 1:
|
|
128150
128168
|
address = _a.sent();
|
|
128151
|
-
return [2 /*return*/, this.getBalanceOfAddresses([address.
|
|
128169
|
+
return [2 /*return*/, this.getBalanceOfAddresses([address.address])];
|
|
128152
128170
|
}
|
|
128153
128171
|
});
|
|
128154
128172
|
});
|
|
@@ -128196,7 +128214,7 @@ var CosmosProtocol = /** @class */ (function (_super) {
|
|
|
128196
128214
|
switch (_a.label) {
|
|
128197
128215
|
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
128198
128216
|
case 1:
|
|
128199
|
-
address = (_a.sent()).
|
|
128217
|
+
address = (_a.sent()).address;
|
|
128200
128218
|
return [4 /*yield*/, this.getAvailableBalanceOfAddresses([address])];
|
|
128201
128219
|
case 2:
|
|
128202
128220
|
balance = _a.sent();
|
|
@@ -128243,7 +128261,7 @@ var CosmosProtocol = /** @class */ (function (_super) {
|
|
|
128243
128261
|
}
|
|
128244
128262
|
return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
128245
128263
|
case 1:
|
|
128246
|
-
address = (_d.sent()).
|
|
128264
|
+
address = (_d.sent()).address;
|
|
128247
128265
|
return [4 /*yield*/, this.nodeClient.fetchNodeInfo()];
|
|
128248
128266
|
case 2:
|
|
128249
128267
|
nodeInfo = _d.sent();
|
|
@@ -128292,7 +128310,7 @@ var CosmosProtocol = /** @class */ (function (_super) {
|
|
|
128292
128310
|
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
128293
128311
|
case 1:
|
|
128294
128312
|
address = _a.sent();
|
|
128295
|
-
return [2 /*return*/, this.getCurrentDelegateesForAddress(address.
|
|
128313
|
+
return [2 /*return*/, this.getCurrentDelegateesForAddress(address.address)];
|
|
128296
128314
|
}
|
|
128297
128315
|
});
|
|
128298
128316
|
});
|
|
@@ -128336,7 +128354,7 @@ var CosmosProtocol = /** @class */ (function (_super) {
|
|
|
128336
128354
|
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
128337
128355
|
case 1:
|
|
128338
128356
|
address = _a.sent();
|
|
128339
|
-
return [2 /*return*/, this.isAddressDelegating(address.
|
|
128357
|
+
return [2 /*return*/, this.isAddressDelegating(address.address)];
|
|
128340
128358
|
}
|
|
128341
128359
|
});
|
|
128342
128360
|
});
|
|
@@ -128362,7 +128380,7 @@ var CosmosProtocol = /** @class */ (function (_super) {
|
|
|
128362
128380
|
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
128363
128381
|
case 1:
|
|
128364
128382
|
address = _a.sent();
|
|
128365
|
-
return [2 /*return*/, this.getDelegatorDetailsFromAddress(address.
|
|
128383
|
+
return [2 /*return*/, this.getDelegatorDetailsFromAddress(address.address)];
|
|
128366
128384
|
}
|
|
128367
128385
|
});
|
|
128368
128386
|
});
|
|
@@ -128382,7 +128400,7 @@ var CosmosProtocol = /** @class */ (function (_super) {
|
|
|
128382
128400
|
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
128383
128401
|
case 1:
|
|
128384
128402
|
address = _a.sent();
|
|
128385
|
-
return [2 /*return*/, this.getDelegationDetailsFromAddress(address.
|
|
128403
|
+
return [2 /*return*/, this.getDelegationDetailsFromAddress(address.address, delegatees)];
|
|
128386
128404
|
}
|
|
128387
128405
|
});
|
|
128388
128406
|
});
|
|
@@ -128459,7 +128477,7 @@ var CosmosProtocol = /** @class */ (function (_super) {
|
|
|
128459
128477
|
switch (_b.label) {
|
|
128460
128478
|
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
128461
128479
|
case 1:
|
|
128462
|
-
address = (_b.sent()).
|
|
128480
|
+
address = (_b.sent()).address;
|
|
128463
128481
|
return [4 /*yield*/, this.nodeClient.fetchNodeInfo()];
|
|
128464
128482
|
case 2:
|
|
128465
128483
|
nodeInfo = _b.sent();
|
|
@@ -128485,7 +128503,7 @@ var CosmosProtocol = /** @class */ (function (_super) {
|
|
|
128485
128503
|
return [3 /*break*/, 4];
|
|
128486
128504
|
case 1: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
128487
128505
|
case 2:
|
|
128488
|
-
address_1 = (_b.sent()).
|
|
128506
|
+
address_1 = (_b.sent()).address;
|
|
128489
128507
|
return [4 /*yield*/, this.nodeClient.fetchRewardDetails(address_1)];
|
|
128490
128508
|
case 3:
|
|
128491
128509
|
rewards = _b.sent();
|
|
@@ -128499,7 +128517,7 @@ var CosmosProtocol = /** @class */ (function (_super) {
|
|
|
128499
128517
|
_b.label = 4;
|
|
128500
128518
|
case 4: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
128501
128519
|
case 5:
|
|
128502
|
-
address = (_b.sent()).
|
|
128520
|
+
address = (_b.sent()).address;
|
|
128503
128521
|
return [4 /*yield*/, this.nodeClient.fetchNodeInfo()];
|
|
128504
128522
|
case 6:
|
|
128505
128523
|
nodeInfo = _b.sent();
|
|
@@ -129436,7 +129454,7 @@ var BaseEthereumProtocol = /** @class */ (function () {
|
|
|
129436
129454
|
var ethereumNode;
|
|
129437
129455
|
return __generator(this, function (_a) {
|
|
129438
129456
|
ethereumNode = bitcoinJS.HDNode.fromSeedHex(secret, this.network);
|
|
129439
|
-
return [2 /*return*/, ethereumNode.derivePath(derivationPath).keyPair.d.toBuffer(32)];
|
|
129457
|
+
return [2 /*return*/, ethereumNode.derivePath(derivationPath).keyPair.d.toBuffer(32).toString('hex')];
|
|
129440
129458
|
});
|
|
129441
129459
|
});
|
|
129442
129460
|
};
|
|
@@ -129449,19 +129467,24 @@ var BaseEthereumProtocol = /** @class */ (function () {
|
|
|
129449
129467
|
});
|
|
129450
129468
|
});
|
|
129451
129469
|
};
|
|
129452
|
-
BaseEthereumProtocol.prototype.getAddressFromPublicKey = function (publicKey) {
|
|
129470
|
+
BaseEthereumProtocol.prototype.getAddressFromPublicKey = function (publicKey, cursor) {
|
|
129453
129471
|
return __awaiter(this, void 0, void 0, function () {
|
|
129472
|
+
var address;
|
|
129454
129473
|
return __generator(this, function (_a) {
|
|
129455
|
-
|
|
129474
|
+
address = EthereumAddress_1.EthereumAddress.from(publicKey);
|
|
129475
|
+
return [2 /*return*/, {
|
|
129476
|
+
address: address.asString(),
|
|
129477
|
+
cursor: { hasNext: false }
|
|
129478
|
+
}];
|
|
129456
129479
|
});
|
|
129457
129480
|
});
|
|
129458
129481
|
};
|
|
129459
|
-
BaseEthereumProtocol.prototype.getAddressesFromPublicKey = function (publicKey) {
|
|
129482
|
+
BaseEthereumProtocol.prototype.getAddressesFromPublicKey = function (publicKey, cursor) {
|
|
129460
129483
|
return __awaiter(this, void 0, void 0, function () {
|
|
129461
129484
|
var address;
|
|
129462
129485
|
return __generator(this, function (_a) {
|
|
129463
129486
|
switch (_a.label) {
|
|
129464
|
-
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
129487
|
+
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey, cursor)];
|
|
129465
129488
|
case 1:
|
|
129466
129489
|
address = _a.sent();
|
|
129467
129490
|
return [2 /*return*/, [address]];
|
|
@@ -129501,13 +129524,6 @@ var BaseEthereumProtocol = /** @class */ (function () {
|
|
|
129501
129524
|
return _this.getAddressFromPublicKey(node.derive(visibilityDerivationIndex).derive(x).getPublicKeyBuffer().toString('hex'));
|
|
129502
129525
|
}));
|
|
129503
129526
|
};
|
|
129504
|
-
BaseEthereumProtocol.prototype.getNextAddressFromPublicKey = function (publicKey, current) {
|
|
129505
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
129506
|
-
return __generator(this, function (_a) {
|
|
129507
|
-
return [2 /*return*/, current];
|
|
129508
|
-
});
|
|
129509
|
-
});
|
|
129510
|
-
};
|
|
129511
129527
|
BaseEthereumProtocol.prototype.getPrivateKeyFromExtendedPrivateKey = function (extendedPrivateKey, childDerivationPath) {
|
|
129512
129528
|
return __awaiter(this, void 0, void 0, function () {
|
|
129513
129529
|
var dp;
|
|
@@ -129543,7 +129559,7 @@ var BaseEthereumProtocol = /** @class */ (function () {
|
|
|
129543
129559
|
return [2 /*return*/, tx.serialize().toString('hex')];
|
|
129544
129560
|
}
|
|
129545
129561
|
else {
|
|
129546
|
-
return [2 /*return*/, this.signWithPrivateKey(privateKey, untypedTransaction)];
|
|
129562
|
+
return [2 /*return*/, this.signWithPrivateKey(privateKey.toString('hex'), untypedTransaction)];
|
|
129547
129563
|
}
|
|
129548
129564
|
return [2 /*return*/];
|
|
129549
129565
|
}
|
|
@@ -129564,7 +129580,7 @@ var BaseEthereumProtocol = /** @class */ (function () {
|
|
|
129564
129580
|
common = common_1.default.custom({ chainId: transaction.chainId });
|
|
129565
129581
|
}
|
|
129566
129582
|
tx = tx_1.TransactionFactory.fromTxData(transaction, { common: common });
|
|
129567
|
-
tx = tx.sign(privateKey);
|
|
129583
|
+
tx = tx.sign(Buffer.from(privateKey, 'hex'));
|
|
129568
129584
|
return [2 /*return*/, tx.serialize().toString('hex')];
|
|
129569
129585
|
});
|
|
129570
129586
|
});
|
|
@@ -129593,7 +129609,7 @@ var BaseEthereumProtocol = /** @class */ (function () {
|
|
|
129593
129609
|
case 4:
|
|
129594
129610
|
ownAddress = _d;
|
|
129595
129611
|
airGapTransaction = {
|
|
129596
|
-
from: [ownAddress.
|
|
129612
|
+
from: [ownAddress.address],
|
|
129597
129613
|
to: [(_b = (_a = transaction.to) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : ''],
|
|
129598
129614
|
amount: new bignumber_1.BigNumber(transaction.value.toString(10)).toString(10),
|
|
129599
129615
|
fee: new bignumber_1.BigNumber(transaction.gasLimit.toString(10))
|
|
@@ -129634,7 +129650,7 @@ var BaseEthereumProtocol = /** @class */ (function () {
|
|
|
129634
129650
|
ownAddress = _e;
|
|
129635
129651
|
return [2 /*return*/, [
|
|
129636
129652
|
{
|
|
129637
|
-
from: [ownAddress.
|
|
129653
|
+
from: [ownAddress.address],
|
|
129638
129654
|
to: [transaction.to],
|
|
129639
129655
|
amount: new bignumber_1.BigNumber(transaction.value).toString(10),
|
|
129640
129656
|
fee: new bignumber_1.BigNumber(transaction.gasLimit).multipliedBy(new bignumber_1.BigNumber(transaction.gasPrice)).toString(10),
|
|
@@ -129720,7 +129736,7 @@ var BaseEthereumProtocol = /** @class */ (function () {
|
|
|
129720
129736
|
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
129721
129737
|
case 1:
|
|
129722
129738
|
address = _a.sent();
|
|
129723
|
-
return [2 /*return*/, this.getBalanceOfAddresses([address.
|
|
129739
|
+
return [2 /*return*/, this.getBalanceOfAddresses([address.address])];
|
|
129724
129740
|
}
|
|
129725
129741
|
});
|
|
129726
129742
|
});
|
|
@@ -129748,10 +129764,10 @@ var BaseEthereumProtocol = /** @class */ (function () {
|
|
|
129748
129764
|
return __generator(this, function (_a) {
|
|
129749
129765
|
switch (_a.label) {
|
|
129750
129766
|
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)
|
|
129751
|
-
.then(function (address) { return address.
|
|
129767
|
+
.then(function (address) { return address.address; })
|
|
129752
129768
|
.catch(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
129753
129769
|
switch (_a.label) {
|
|
129754
|
-
case 0: return [4 /*yield*/, this.getAddressFromExtendedPublicKey(publicKey, 0, 0).then(function (address) { return address.
|
|
129770
|
+
case 0: return [4 /*yield*/, this.getAddressFromExtendedPublicKey(publicKey, 0, 0).then(function (address) { return address.address; })];
|
|
129755
129771
|
case 1: return [2 /*return*/, _a.sent()];
|
|
129756
129772
|
}
|
|
129757
129773
|
}); }); })];
|
|
@@ -129875,7 +129891,7 @@ var BaseEthereumProtocol = /** @class */ (function () {
|
|
|
129875
129891
|
if (recipients.length !== 1) {
|
|
129876
129892
|
return [2 /*return*/, Promise.reject('you cannot have 0 recipients')];
|
|
129877
129893
|
}
|
|
129878
|
-
return [4 /*yield*/, this.getAddressFromPublicKey(publicKey).then(function (address) { return address.
|
|
129894
|
+
return [4 /*yield*/, this.getAddressFromPublicKey(publicKey).then(function (address) { return address.address; })];
|
|
129879
129895
|
case 1:
|
|
129880
129896
|
address = _a.sent();
|
|
129881
129897
|
return [4 /*yield*/, this.options.nodeClient.estimateTransactionGas(address, recipients[0], utils_1.EthereumUtils.toHex(values[0]), undefined, utils_1.EthereumUtils.toHex(this.MAX_GAS_ESTIMATE))];
|
|
@@ -129906,7 +129922,7 @@ var BaseEthereumProtocol = /** @class */ (function () {
|
|
|
129906
129922
|
case 0:
|
|
129907
129923
|
wrappedValues = values.map(function (value) { return new bignumber_1.BigNumber(value); });
|
|
129908
129924
|
wrappedFee = new bignumber_1.BigNumber(fee);
|
|
129909
|
-
return [4 /*yield*/, this.getAddressFromPublicKey(publicKey).then(function (address) { return address.
|
|
129925
|
+
return [4 /*yield*/, this.getAddressFromPublicKey(publicKey).then(function (address) { return address.address; })];
|
|
129910
129926
|
case 1:
|
|
129911
129927
|
address = _a.sent();
|
|
129912
129928
|
if (recipients.length !== values.length) {
|
|
@@ -129971,7 +129987,7 @@ var BaseEthereumProtocol = /** @class */ (function () {
|
|
|
129971
129987
|
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
129972
129988
|
case 1:
|
|
129973
129989
|
address = _a.sent();
|
|
129974
|
-
return [2 /*return*/, this.getTransactionsFromAddresses([address.
|
|
129990
|
+
return [2 /*return*/, this.getTransactionsFromAddresses([address.address], limit, cursor)];
|
|
129975
129991
|
}
|
|
129976
129992
|
});
|
|
129977
129993
|
});
|
|
@@ -130086,7 +130102,7 @@ var EthereumAddress = /** @class */ (function () {
|
|
|
130086
130102
|
var pubkey = typeof publicKey === 'string' ? Buffer.from(publicKey, 'hex') : publicKey;
|
|
130087
130103
|
return new EthereumAddress(ethUtil.toChecksumAddress(ethUtil.pubToAddress(pubkey, true).toString('hex')));
|
|
130088
130104
|
};
|
|
130089
|
-
EthereumAddress.prototype.
|
|
130105
|
+
EthereumAddress.prototype.asString = function () {
|
|
130090
130106
|
return this.value;
|
|
130091
130107
|
};
|
|
130092
130108
|
return EthereumAddress;
|
|
@@ -130465,6 +130481,7 @@ var EthereumClassicProtocol = /** @class */ (function (_super) {
|
|
|
130465
130481
|
exports.EthereumClassicProtocol = EthereumClassicProtocol;
|
|
130466
130482
|
|
|
130467
130483
|
},{"./BaseEthereumProtocol":524,"./EthereumProtocolOptions":530}],528:[function(require,module,exports){
|
|
130484
|
+
(function (Buffer){(function (){
|
|
130468
130485
|
"use strict";
|
|
130469
130486
|
var __extends = (this && this.__extends) || (function () {
|
|
130470
130487
|
var extendStatics = function (d, b) {
|
|
@@ -130536,11 +130553,11 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
130536
130553
|
};
|
|
130537
130554
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
130538
130555
|
exports.EthereumCryptoClient = void 0;
|
|
130556
|
+
var eth_sig_util_1 = require("@metamask/eth-sig-util");
|
|
130539
130557
|
var EthereumJSUtils = __importStar(require("../../dependencies/src/ethereumjs-util-5.2.0/index"));
|
|
130540
130558
|
var errors_1 = require("../../errors");
|
|
130541
130559
|
var coinlib_error_1 = require("../../errors/coinlib-error");
|
|
130542
130560
|
var Secp256k1CryptoClient_1 = require("../Secp256k1CryptoClient");
|
|
130543
|
-
var eth_sig_util_1 = require("@metamask/eth-sig-util");
|
|
130544
130561
|
var EthereumCryptoClient = /** @class */ (function (_super) {
|
|
130545
130562
|
__extends(EthereumCryptoClient, _super);
|
|
130546
130563
|
function EthereumCryptoClient(protocol) {
|
|
@@ -130550,30 +130567,31 @@ var EthereumCryptoClient = /** @class */ (function (_super) {
|
|
|
130550
130567
|
}
|
|
130551
130568
|
EthereumCryptoClient.prototype.signMessage = function (message, keypair) {
|
|
130552
130569
|
return __awaiter(this, void 0, void 0, function () {
|
|
130553
|
-
var msgParams_1, msgParams_2, msgParams, messageBuffer, signature;
|
|
130570
|
+
var privateKey, msgParams_1, msgParams_2, msgParams, messageBuffer, signature;
|
|
130554
130571
|
return __generator(this, function (_a) {
|
|
130555
130572
|
if (!keypair.privateKey) {
|
|
130556
130573
|
throw new errors_1.NotFoundError(coinlib_error_1.Domain.ETHEREUM, "Private key not provided");
|
|
130557
130574
|
}
|
|
130575
|
+
privateKey = Buffer.from(keypair.privateKey, 'hex');
|
|
130558
130576
|
try {
|
|
130559
130577
|
try {
|
|
130560
130578
|
msgParams_1 = JSON.parse(message) // TODO types
|
|
130561
130579
|
;
|
|
130562
|
-
return [2 /*return*/, eth_sig_util_1.signTypedData({ privateKey:
|
|
130580
|
+
return [2 /*return*/, eth_sig_util_1.signTypedData({ privateKey: privateKey, data: msgParams_1, version: eth_sig_util_1.SignTypedDataVersion.V4 })];
|
|
130563
130581
|
}
|
|
130564
130582
|
catch (e) { }
|
|
130565
130583
|
try {
|
|
130566
130584
|
msgParams_2 = JSON.parse(message) // TODO types
|
|
130567
130585
|
;
|
|
130568
|
-
return [2 /*return*/, eth_sig_util_1.signTypedData({ privateKey:
|
|
130586
|
+
return [2 /*return*/, eth_sig_util_1.signTypedData({ privateKey: privateKey, data: msgParams_2, version: eth_sig_util_1.SignTypedDataVersion.V3 })];
|
|
130569
130587
|
}
|
|
130570
130588
|
catch (e) { }
|
|
130571
130589
|
msgParams = JSON.parse(message);
|
|
130572
|
-
return [2 /*return*/, eth_sig_util_1.signTypedData({ privateKey:
|
|
130590
|
+
return [2 /*return*/, eth_sig_util_1.signTypedData({ privateKey: privateKey, data: msgParams, version: eth_sig_util_1.SignTypedDataVersion.V1 })];
|
|
130573
130591
|
}
|
|
130574
130592
|
catch (error) {
|
|
130575
130593
|
messageBuffer = EthereumJSUtils.hashPersonalMessage(EthereumJSUtils.toBuffer(message));
|
|
130576
|
-
signature = EthereumJSUtils.ecsign(messageBuffer,
|
|
130594
|
+
signature = EthereumJSUtils.ecsign(messageBuffer, privateKey);
|
|
130577
130595
|
return [2 /*return*/, EthereumJSUtils.toRpcSig(signature.v, signature.r, signature.s)];
|
|
130578
130596
|
}
|
|
130579
130597
|
return [2 /*return*/];
|
|
@@ -130596,7 +130614,7 @@ var EthereumCryptoClient = /** @class */ (function (_super) {
|
|
|
130596
130614
|
return [4 /*yield*/, this.protocol.getAddressFromPublicKey(publicKey)];
|
|
130597
130615
|
case 1:
|
|
130598
130616
|
address = _a.sent();
|
|
130599
|
-
return [2 /*return*/, recoveredAddress.toLowerCase() === address.
|
|
130617
|
+
return [2 /*return*/, recoveredAddress.toLowerCase() === address.address.toLowerCase()];
|
|
130600
130618
|
}
|
|
130601
130619
|
});
|
|
130602
130620
|
});
|
|
@@ -130605,7 +130623,8 @@ var EthereumCryptoClient = /** @class */ (function (_super) {
|
|
|
130605
130623
|
}(Secp256k1CryptoClient_1.Secp256k1CryptoClient));
|
|
130606
130624
|
exports.EthereumCryptoClient = EthereumCryptoClient;
|
|
130607
130625
|
|
|
130608
|
-
}
|
|
130626
|
+
}).call(this)}).call(this,require("buffer").Buffer)
|
|
130627
|
+
},{"../../dependencies/src/ethereumjs-util-5.2.0/index":385,"../../errors":491,"../../errors/coinlib-error":490,"../Secp256k1CryptoClient":498,"@metamask/eth-sig-util":883,"buffer":67}],529:[function(require,module,exports){
|
|
130609
130628
|
"use strict";
|
|
130610
130629
|
var __extends = (this && this.__extends) || (function () {
|
|
130611
130630
|
var extendStatics = function (d, b) {
|
|
@@ -131439,12 +131458,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
131439
131458
|
exports.GenericERC20 = void 0;
|
|
131440
131459
|
var bignumber_1 = __importDefault(require("../../../dependencies/src/bignumber.js-9.0.0/bignumber"));
|
|
131441
131460
|
var ethUtil = __importStar(require("../../../dependencies/src/ethereumjs-util-5.2.0/index"));
|
|
131461
|
+
var errors_1 = require("../../../errors");
|
|
131462
|
+
var coinlib_error_1 = require("../../../errors/coinlib-error");
|
|
131442
131463
|
var ICoinSubProtocol_1 = require("../../ICoinSubProtocol");
|
|
131443
131464
|
var BaseEthereumProtocol_1 = require("../BaseEthereumProtocol");
|
|
131444
131465
|
var AirGapNodeClient_1 = require("../clients/node-clients/AirGapNodeClient");
|
|
131445
131466
|
var utils_1 = require("../utils/utils");
|
|
131446
|
-
var errors_1 = require("../../../errors");
|
|
131447
|
-
var coinlib_error_1 = require("../../../errors/coinlib-error");
|
|
131448
131467
|
var EthereumTransaction = require('../../../dependencies/src/ethereumjs-tx-1.3.7/index');
|
|
131449
131468
|
var GenericERC20 = /** @class */ (function (_super) {
|
|
131450
131469
|
__extends(GenericERC20, _super);
|
|
@@ -131469,7 +131488,7 @@ var GenericERC20 = /** @class */ (function (_super) {
|
|
|
131469
131488
|
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
131470
131489
|
case 1:
|
|
131471
131490
|
address = _a.sent();
|
|
131472
|
-
return [2 /*return*/, this.getBalanceOfAddresses([address.
|
|
131491
|
+
return [2 /*return*/, this.getBalanceOfAddresses([address.address])];
|
|
131473
131492
|
}
|
|
131474
131493
|
});
|
|
131475
131494
|
});
|
|
@@ -131530,7 +131549,7 @@ var GenericERC20 = /** @class */ (function (_super) {
|
|
|
131530
131549
|
}
|
|
131531
131550
|
return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
131532
131551
|
case 1:
|
|
131533
|
-
address = (_a.sent()).
|
|
131552
|
+
address = (_a.sent()).address;
|
|
131534
131553
|
return [4 /*yield*/, this.estimateGas(address, recipients[0], utils_1.EthereumUtils.toHex(values[0]))];
|
|
131535
131554
|
case 2:
|
|
131536
131555
|
estimatedGas = _a.sent();
|
|
@@ -131570,7 +131589,7 @@ var GenericERC20 = /** @class */ (function (_super) {
|
|
|
131570
131589
|
case 1:
|
|
131571
131590
|
balance = new (_a.apply(bignumber_1.default, [void 0, _c.sent()]))();
|
|
131572
131591
|
if (!balance.isGreaterThanOrEqualTo(wrappedValues[0])) return [3 /*break*/, 8];
|
|
131573
|
-
return [4 /*yield*/, this.getAddressFromPublicKey(publicKey).then(function (address) { return address.
|
|
131592
|
+
return [4 /*yield*/, this.getAddressFromPublicKey(publicKey).then(function (address) { return address.address; })];
|
|
131574
131593
|
case 2:
|
|
131575
131594
|
address = _c.sent();
|
|
131576
131595
|
_b = bignumber_1.default.bind;
|
|
@@ -132151,19 +132170,19 @@ var SubstrateCryptoClient = /** @class */ (function (_super) {
|
|
|
132151
132170
|
return _super.call(this) || this;
|
|
132152
132171
|
}
|
|
132153
132172
|
SubstrateCryptoClient.prototype.signMessage = function (message, keypair) {
|
|
132154
|
-
var _a;
|
|
132155
132173
|
return __awaiter(this, void 0, void 0, function () {
|
|
132156
|
-
var publicKeyBuffer, messageU8a;
|
|
132157
|
-
return __generator(this, function (
|
|
132158
|
-
switch (
|
|
132174
|
+
var privateKeyBuffer, publicKeyBuffer, messageU8a;
|
|
132175
|
+
return __generator(this, function (_a) {
|
|
132176
|
+
switch (_a.label) {
|
|
132159
132177
|
case 0: return [4 /*yield*/, wasm_crypto_1.waitReady()];
|
|
132160
132178
|
case 1:
|
|
132161
|
-
|
|
132179
|
+
_a.sent();
|
|
132180
|
+
privateKeyBuffer = Buffer.from(keypair.privateKey, 'hex');
|
|
132162
132181
|
publicKeyBuffer = Buffer.from(keypair.publicKey, 'hex');
|
|
132163
132182
|
util_1.assert((publicKeyBuffer === null || publicKeyBuffer === void 0 ? void 0 : publicKeyBuffer.length) === 32, 'Expected a valid publicKey, 32-bytes');
|
|
132164
|
-
util_1.assert(
|
|
132183
|
+
util_1.assert(privateKeyBuffer.length === 64, 'Expected a valid secretKey, 64-bytes');
|
|
132165
132184
|
messageU8a = util_1.u8aToU8a(message);
|
|
132166
|
-
return [2 /*return*/, "0x" + Buffer.from(wasm_crypto_1.sr25519Sign(publicKeyBuffer,
|
|
132185
|
+
return [2 /*return*/, "0x" + Buffer.from(wasm_crypto_1.sr25519Sign(publicKeyBuffer, privateKeyBuffer, messageU8a)).toString('hex')];
|
|
132167
132186
|
}
|
|
132168
132187
|
});
|
|
132169
132188
|
});
|
|
@@ -132275,7 +132294,7 @@ var SubstrateDelegateProtocol = /** @class */ (function (_super) {
|
|
|
132275
132294
|
return [4 /*yield*/, this.options.nodeClient.getValidators()];
|
|
132276
132295
|
case 1:
|
|
132277
132296
|
validators = _a.sent();
|
|
132278
|
-
return [2 /*return*/, validators ? validators[0].
|
|
132297
|
+
return [2 /*return*/, validators ? validators[0].asString() : ''];
|
|
132279
132298
|
}
|
|
132280
132299
|
});
|
|
132281
132300
|
});
|
|
@@ -132333,7 +132352,7 @@ var SubstrateDelegateProtocol = /** @class */ (function (_super) {
|
|
|
132333
132352
|
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
132334
132353
|
case 1:
|
|
132335
132354
|
address = _a.sent();
|
|
132336
|
-
return [2 /*return*/, this.getDelegatorDetailsFromAddress(address.
|
|
132355
|
+
return [2 /*return*/, this.getDelegatorDetailsFromAddress(address.address)];
|
|
132337
132356
|
}
|
|
132338
132357
|
});
|
|
132339
132358
|
});
|
|
@@ -132353,7 +132372,7 @@ var SubstrateDelegateProtocol = /** @class */ (function (_super) {
|
|
|
132353
132372
|
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
132354
132373
|
case 1:
|
|
132355
132374
|
address = _a.sent();
|
|
132356
|
-
return [2 /*return*/, this.getDelegationDetailsFromAddress(address.
|
|
132375
|
+
return [2 /*return*/, this.getDelegationDetailsFromAddress(address.address, delegatees)];
|
|
132357
132376
|
}
|
|
132358
132377
|
});
|
|
132359
132378
|
});
|
|
@@ -132765,6 +132784,7 @@ var SubstrateNetwork;
|
|
|
132765
132784
|
})(SubstrateNetwork = exports.SubstrateNetwork || (exports.SubstrateNetwork = {}));
|
|
132766
132785
|
|
|
132767
132786
|
},{}],544:[function(require,module,exports){
|
|
132787
|
+
(function (Buffer){(function (){
|
|
132768
132788
|
"use strict";
|
|
132769
132789
|
var __extends = (this && this.__extends) || (function () {
|
|
132770
132790
|
var extendStatics = function (d, b) {
|
|
@@ -132884,7 +132904,7 @@ var SubstrateProtocol = /** @class */ (function (_super) {
|
|
|
132884
132904
|
case 0: return [4 /*yield*/, this.options.accountController.createKeyPairFromMnemonic(mnemonic, derivationPath, password)];
|
|
132885
132905
|
case 1:
|
|
132886
132906
|
keyPair = _a.sent();
|
|
132887
|
-
return [2 /*return*/, keyPair.privateKey];
|
|
132907
|
+
return [2 /*return*/, keyPair.privateKey.toString('hex')];
|
|
132888
132908
|
}
|
|
132889
132909
|
});
|
|
132890
132910
|
});
|
|
@@ -132910,42 +132930,44 @@ var SubstrateProtocol = /** @class */ (function (_super) {
|
|
|
132910
132930
|
case 0: return [4 /*yield*/, this.options.accountController.createKeyPairFromHexSecret(secret, derivationPath)];
|
|
132911
132931
|
case 1:
|
|
132912
132932
|
keyPair = _a.sent();
|
|
132913
|
-
return [2 /*return*/, keyPair.privateKey];
|
|
132933
|
+
return [2 /*return*/, keyPair.privateKey.toString('hex')];
|
|
132914
132934
|
}
|
|
132915
132935
|
});
|
|
132916
132936
|
});
|
|
132917
132937
|
};
|
|
132918
|
-
SubstrateProtocol.prototype.getAddressFromPublicKey = function (publicKey) {
|
|
132938
|
+
SubstrateProtocol.prototype.getAddressFromPublicKey = function (publicKey, cursor) {
|
|
132919
132939
|
return __awaiter(this, void 0, void 0, function () {
|
|
132940
|
+
var address;
|
|
132920
132941
|
return __generator(this, function (_a) {
|
|
132921
|
-
|
|
132942
|
+
switch (_a.label) {
|
|
132943
|
+
case 0: return [4 /*yield*/, this.options.accountController.createAddressFromPublicKey(publicKey)];
|
|
132944
|
+
case 1:
|
|
132945
|
+
address = _a.sent();
|
|
132946
|
+
return [2 /*return*/, {
|
|
132947
|
+
address: address.asString(),
|
|
132948
|
+
cursor: { hasNext: false }
|
|
132949
|
+
}];
|
|
132950
|
+
}
|
|
132922
132951
|
});
|
|
132923
132952
|
});
|
|
132924
132953
|
};
|
|
132925
|
-
SubstrateProtocol.prototype.getAddressesFromPublicKey = function (publicKey) {
|
|
132954
|
+
SubstrateProtocol.prototype.getAddressesFromPublicKey = function (publicKey, cursor) {
|
|
132926
132955
|
return __awaiter(this, void 0, void 0, function () {
|
|
132927
132956
|
return __generator(this, function (_a) {
|
|
132928
132957
|
switch (_a.label) {
|
|
132929
|
-
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
132958
|
+
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey, cursor)];
|
|
132930
132959
|
case 1: return [2 /*return*/, [_a.sent()]];
|
|
132931
132960
|
}
|
|
132932
132961
|
});
|
|
132933
132962
|
});
|
|
132934
132963
|
};
|
|
132935
|
-
SubstrateProtocol.prototype.getNextAddressFromPublicKey = function (publicKey, current) {
|
|
132936
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
132937
|
-
return __generator(this, function (_a) {
|
|
132938
|
-
return [2 /*return*/, current];
|
|
132939
|
-
});
|
|
132940
|
-
});
|
|
132941
|
-
};
|
|
132942
132964
|
SubstrateProtocol.prototype.getTransactionsFromPublicKey = function (publicKey, limit, cursor) {
|
|
132943
132965
|
return __awaiter(this, void 0, void 0, function () {
|
|
132944
132966
|
var addresses;
|
|
132945
132967
|
return __generator(this, function (_a) {
|
|
132946
132968
|
switch (_a.label) {
|
|
132947
132969
|
case 0: return [4 /*yield*/, this.getAddressesFromPublicKey(publicKey).then(function (addresses) {
|
|
132948
|
-
return addresses.map(function (address) { return address.
|
|
132970
|
+
return addresses.map(function (address) { return address.address; });
|
|
132949
132971
|
})];
|
|
132950
132972
|
case 1:
|
|
132951
132973
|
addresses = _a.sent();
|
|
@@ -132979,7 +133001,7 @@ var SubstrateProtocol = /** @class */ (function (_super) {
|
|
|
132979
133001
|
switch (_a.label) {
|
|
132980
133002
|
case 0:
|
|
132981
133003
|
txs = this.options.transactionController.decodeDetails(rawTransaction.encoded);
|
|
132982
|
-
return [4 /*yield*/, Promise.all(txs.map(function (tx) { return _this.options.transactionController.signTransaction(privateKey, tx.transaction, tx.payload); }))];
|
|
133004
|
+
return [4 /*yield*/, Promise.all(txs.map(function (tx) { return _this.options.transactionController.signTransaction(Buffer.from(privateKey, 'hex'), tx.transaction, tx.payload); }))];
|
|
132983
133005
|
case 1:
|
|
132984
133006
|
signed = _a.sent();
|
|
132985
133007
|
txs.forEach(function (tx, index) { return (tx.transaction = signed[index]); });
|
|
@@ -133040,7 +133062,7 @@ var SubstrateProtocol = /** @class */ (function (_super) {
|
|
|
133040
133062
|
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
133041
133063
|
case 1:
|
|
133042
133064
|
address = _a.sent();
|
|
133043
|
-
return [2 /*return*/, this.getBalanceOfAddresses([address.
|
|
133065
|
+
return [2 /*return*/, this.getBalanceOfAddresses([address.address])];
|
|
133044
133066
|
}
|
|
133045
133067
|
});
|
|
133046
133068
|
});
|
|
@@ -133312,9 +133334,9 @@ var SubstrateProtocol = /** @class */ (function (_super) {
|
|
|
133312
133334
|
return __awaiter(this, void 0, void 0, function () {
|
|
133313
133335
|
var key;
|
|
133314
133336
|
return __generator(this, function (_a) {
|
|
133315
|
-
key = privateKey.slice(0, 32) // Substrate key is 32 bytes key + 32 bytes nonce
|
|
133337
|
+
key = Buffer.from(privateKey, 'hex').slice(0, 32) // Substrate key is 32 bytes key + 32 bytes nonce
|
|
133316
133338
|
;
|
|
133317
|
-
return [2 /*return*/, this.cryptoClient.encryptAES(message, key)];
|
|
133339
|
+
return [2 /*return*/, this.cryptoClient.encryptAES(message, key.toString('hex'))];
|
|
133318
133340
|
});
|
|
133319
133341
|
});
|
|
133320
133342
|
};
|
|
@@ -133322,9 +133344,9 @@ var SubstrateProtocol = /** @class */ (function (_super) {
|
|
|
133322
133344
|
return __awaiter(this, void 0, void 0, function () {
|
|
133323
133345
|
var key;
|
|
133324
133346
|
return __generator(this, function (_a) {
|
|
133325
|
-
key = privateKey.slice(0, 32) // Substrate key is 32 bytes key + 32 bytes nonce
|
|
133347
|
+
key = Buffer.from(privateKey, 'hex').slice(0, 32) // Substrate key is 32 bytes key + 32 bytes nonce
|
|
133326
133348
|
;
|
|
133327
|
-
return [2 /*return*/, this.cryptoClient.decryptAES(message, key)];
|
|
133349
|
+
return [2 /*return*/, this.cryptoClient.decryptAES(message, key.toString('hex'))];
|
|
133328
133350
|
});
|
|
133329
133351
|
});
|
|
133330
133352
|
};
|
|
@@ -133339,7 +133361,8 @@ var SubstrateProtocol = /** @class */ (function (_super) {
|
|
|
133339
133361
|
}(NonExtendedProtocol_1.NonExtendedProtocol));
|
|
133340
133362
|
exports.SubstrateProtocol = SubstrateProtocol;
|
|
133341
133363
|
|
|
133342
|
-
}
|
|
133364
|
+
}).call(this)}).call(this,require("buffer").Buffer)
|
|
133365
|
+
},{"../../dependencies/src/bignumber.js-9.0.0/bignumber":269,"../../errors":491,"../../errors/coinlib-error":490,"../NonExtendedProtocol":497,"./SubstrateCryptoClient":541,"./common/data/account/SubstrateAddress":555,"./common/data/transaction/SubstrateTransaction":625,"buffer":67}],545:[function(require,module,exports){
|
|
133343
133366
|
"use strict";
|
|
133344
133367
|
var __extends = (this && this.__extends) || (function () {
|
|
133345
133368
|
var extendStatics = function (d, b) {
|
|
@@ -134025,7 +134048,7 @@ var SubstrateAccountController = /** @class */ (function () {
|
|
|
134025
134048
|
}
|
|
134026
134049
|
_b.label = 4;
|
|
134027
134050
|
case 4: return [2 /*return*/, {
|
|
134028
|
-
address: address.
|
|
134051
|
+
address: address.asString(),
|
|
134029
134052
|
name: identity ? identity.display.toString() : undefined,
|
|
134030
134053
|
status: status || undefined,
|
|
134031
134054
|
ownStash: exposure ? exposure.own.toString() : undefined,
|
|
@@ -134076,7 +134099,7 @@ var SubstrateAccountController = /** @class */ (function () {
|
|
|
134076
134099
|
case 3:
|
|
134077
134100
|
availableActions = _c.sent();
|
|
134078
134101
|
return [2 /*return*/, {
|
|
134079
|
-
address: address.
|
|
134102
|
+
address: address.asString(),
|
|
134080
134103
|
balance: balance.toString(),
|
|
134081
134104
|
delegatees: validators,
|
|
134082
134105
|
availableActions: availableActions,
|
|
@@ -134384,7 +134407,7 @@ var SubstrateAccountController = /** @class */ (function () {
|
|
|
134384
134407
|
exposures: exposuresWithValidators === null || exposuresWithValidators === void 0 ? void 0 : exposuresWithValidators.map(function (_a) {
|
|
134385
134408
|
var validator = _a[0], _ = _a[1], exposure = _a[2];
|
|
134386
134409
|
return [
|
|
134387
|
-
validator.
|
|
134410
|
+
validator.asString(),
|
|
134388
134411
|
exposure === null || exposure === void 0 ? void 0 : exposure.others.elements.findIndex(function (element) { return element.first.compare(accountId) === 0; })
|
|
134389
134412
|
];
|
|
134390
134413
|
}).filter(function (_a) {
|
|
@@ -134414,7 +134437,7 @@ var SubstrateAccountController = /** @class */ (function () {
|
|
|
134414
134437
|
case 0:
|
|
134415
134438
|
availableActions = [];
|
|
134416
134439
|
currentValidators = ((_b = (_a = nominations === null || nominations === void 0 ? void 0 : nominations.targets) === null || _a === void 0 ? void 0 : _a.elements) === null || _b === void 0 ? void 0 : _b.map(function (target) { return target.asAddress(); })) || [];
|
|
134417
|
-
validatorAddresses = validatorIds.map(function (id) { return _this.substrateAddressFrom(id).
|
|
134440
|
+
validatorAddresses = validatorIds.map(function (id) { return _this.substrateAddressFrom(id).asString(); });
|
|
134418
134441
|
isBonded = new bignumber_1.default((_c = stakingDetails === null || stakingDetails === void 0 ? void 0 : stakingDetails.active) !== null && _c !== void 0 ? _c : 0).gt(0);
|
|
134419
134442
|
isDelegating = nominations !== null;
|
|
134420
134443
|
isUnbonding = stakingDetails && stakingDetails.locked.length > 0;
|
|
@@ -135145,13 +135168,13 @@ var SubstrateAddress = /** @class */ (function () {
|
|
|
135145
135168
|
return this.payload.compare(Buffer.from(other, 'hex'));
|
|
135146
135169
|
}
|
|
135147
135170
|
else if (typeof other === 'string') {
|
|
135148
|
-
return this.
|
|
135171
|
+
return this.asString().localeCompare(other);
|
|
135149
135172
|
}
|
|
135150
135173
|
else {
|
|
135151
135174
|
return this.payload.compare(other.payload);
|
|
135152
135175
|
}
|
|
135153
135176
|
};
|
|
135154
|
-
SubstrateAddress.prototype.
|
|
135177
|
+
SubstrateAddress.prototype.asString = function () {
|
|
135155
135178
|
if (!this.encoded) {
|
|
135156
135179
|
this.encoded = bs58.encode(Buffer.concat([this.version, this.payload, this.checksum]));
|
|
135157
135180
|
}
|
|
@@ -138148,7 +138171,7 @@ var SCALEAccountId = /** @class */ (function (_super) {
|
|
|
138148
138171
|
}
|
|
138149
138172
|
};
|
|
138150
138173
|
SCALEAccountId.prototype.asAddress = function () {
|
|
138151
|
-
return this.address.
|
|
138174
|
+
return this.address.asString();
|
|
138152
138175
|
};
|
|
138153
138176
|
SCALEAccountId.prototype.asBytes = function () {
|
|
138154
138177
|
return this.address.getBufferBytes();
|
|
@@ -140098,7 +140121,7 @@ var TransferArgsFactory = /** @class */ (function (_super) {
|
|
|
140098
140121
|
var _this = this;
|
|
140099
140122
|
return function () { return [
|
|
140100
140123
|
{
|
|
140101
|
-
to: [SubstrateCompatAddress_1.substrateAddressFactory(_this.network).from(_this.args.to).
|
|
140124
|
+
to: [SubstrateCompatAddress_1.substrateAddressFactory(_this.network).from(_this.args.to).asString()],
|
|
140102
140125
|
amount: _this.args.value.toString()
|
|
140103
140126
|
}
|
|
140104
140127
|
]; };
|
|
@@ -140139,7 +140162,7 @@ var BondArgsFactory = /** @class */ (function (_super) {
|
|
|
140139
140162
|
var _this = this;
|
|
140140
140163
|
return function () { return [
|
|
140141
140164
|
{
|
|
140142
|
-
to: [SubstrateCompatAddress_1.substrateAddressFactory(_this.network).from(_this.args.controller).
|
|
140165
|
+
to: [SubstrateCompatAddress_1.substrateAddressFactory(_this.network).from(_this.args.controller).asString()],
|
|
140143
140166
|
amount: _this.args.value.toString()
|
|
140144
140167
|
}
|
|
140145
140168
|
]; };
|
|
@@ -140310,7 +140333,7 @@ var NominateArgsFactory = /** @class */ (function (_super) {
|
|
|
140310
140333
|
var _this = this;
|
|
140311
140334
|
return function () { return [
|
|
140312
140335
|
{
|
|
140313
|
-
to: _this.args.targets.map(function (target) { return SubstrateCompatAddress_1.substrateAddressFactory(_this.network).from(target).
|
|
140336
|
+
to: _this.args.targets.map(function (target) { return SubstrateCompatAddress_1.substrateAddressFactory(_this.network).from(target).asString(); })
|
|
140314
140337
|
}
|
|
140315
140338
|
]; };
|
|
140316
140339
|
};
|
|
@@ -140435,7 +140458,7 @@ var SetControllerArgsFactory = /** @class */ (function (_super) {
|
|
|
140435
140458
|
var _this = this;
|
|
140436
140459
|
return function () { return [
|
|
140437
140460
|
{
|
|
140438
|
-
to: [SubstrateCompatAddress_1.substrateAddressFactory(_this.network).from(_this.args.controller).
|
|
140461
|
+
to: [SubstrateCompatAddress_1.substrateAddressFactory(_this.network).from(_this.args.controller).asString()]
|
|
140439
140462
|
}
|
|
140440
140463
|
]; };
|
|
140441
140464
|
};
|
|
@@ -140509,7 +140532,7 @@ var MoonbeamDelegateArgsFactory = /** @class */ (function (_super) {
|
|
|
140509
140532
|
var _this = this;
|
|
140510
140533
|
return function () { return [
|
|
140511
140534
|
{
|
|
140512
|
-
to: [SubstrateCompatAddress_1.substrateAddressFactory(_this.network).from(_this.args.candidate).
|
|
140535
|
+
to: [SubstrateCompatAddress_1.substrateAddressFactory(_this.network).from(_this.args.candidate).asString()],
|
|
140513
140536
|
amount: new bignumber_1.default(_this.args.amount).toString()
|
|
140514
140537
|
}
|
|
140515
140538
|
]; };
|
|
@@ -140636,7 +140659,7 @@ var MoonbeamScheduleRevokeDelegationArgsFactory = /** @class */ (function (_supe
|
|
|
140636
140659
|
var _this = this;
|
|
140637
140660
|
return function () { return [
|
|
140638
140661
|
{
|
|
140639
|
-
to: [SubstrateCompatAddress_1.substrateAddressFactory(_this.network).from(_this.args.collator).
|
|
140662
|
+
to: [SubstrateCompatAddress_1.substrateAddressFactory(_this.network).from(_this.args.collator).asString()]
|
|
140640
140663
|
}
|
|
140641
140664
|
]; };
|
|
140642
140665
|
};
|
|
@@ -140673,8 +140696,8 @@ var MoonbeamExecuteDelegationRequestArgsFactory = /** @class */ (function (_supe
|
|
|
140673
140696
|
var _this = this;
|
|
140674
140697
|
return function () { return [
|
|
140675
140698
|
{
|
|
140676
|
-
from: [SubstrateCompatAddress_1.substrateAddressFactory(_this.network).from(_this.args.delegator).
|
|
140677
|
-
to: [SubstrateCompatAddress_1.substrateAddressFactory(_this.network).from(_this.args.candidate).
|
|
140699
|
+
from: [SubstrateCompatAddress_1.substrateAddressFactory(_this.network).from(_this.args.delegator).asString()],
|
|
140700
|
+
to: [SubstrateCompatAddress_1.substrateAddressFactory(_this.network).from(_this.args.candidate).asString()]
|
|
140678
140701
|
}
|
|
140679
140702
|
]; };
|
|
140680
140703
|
};
|
|
@@ -140710,7 +140733,7 @@ var MoonbeamCancelDelegationRequestArgsFactory = /** @class */ (function (_super
|
|
|
140710
140733
|
var _this = this;
|
|
140711
140734
|
return function () { return [
|
|
140712
140735
|
{
|
|
140713
|
-
to: [SubstrateCompatAddress_1.substrateAddressFactory(_this.network).from(_this.args.candidate).
|
|
140736
|
+
to: [SubstrateCompatAddress_1.substrateAddressFactory(_this.network).from(_this.args.candidate).asString()]
|
|
140714
140737
|
}
|
|
140715
140738
|
]; };
|
|
140716
140739
|
};
|
|
@@ -140747,7 +140770,7 @@ var MoonbeamDelegatorBondMoreArgsFactory = /** @class */ (function (_super) {
|
|
|
140747
140770
|
var _this = this;
|
|
140748
140771
|
return function () { return [
|
|
140749
140772
|
{
|
|
140750
|
-
to: [SubstrateCompatAddress_1.substrateAddressFactory(_this.network).from(_this.args.candidate).
|
|
140773
|
+
to: [SubstrateCompatAddress_1.substrateAddressFactory(_this.network).from(_this.args.candidate).asString()],
|
|
140751
140774
|
amount: new bignumber_1.default(_this.args.more).toString()
|
|
140752
140775
|
}
|
|
140753
140776
|
]; };
|
|
@@ -140787,7 +140810,7 @@ var MoonbeamScheduleDelegatorBondLessArgsFactory = /** @class */ (function (_sup
|
|
|
140787
140810
|
var _this = this;
|
|
140788
140811
|
return function () { return [
|
|
140789
140812
|
{
|
|
140790
|
-
to: [SubstrateCompatAddress_1.substrateAddressFactory(_this.network).from(_this.args.candidate).
|
|
140813
|
+
to: [SubstrateCompatAddress_1.substrateAddressFactory(_this.network).from(_this.args.candidate).asString()],
|
|
140791
140814
|
amount: new bignumber_1.default(_this.args.less).toString()
|
|
140792
140815
|
}
|
|
140793
140816
|
]; };
|
|
@@ -140824,7 +140847,7 @@ var MoonbeamExecuteCandidateBondLessArgsFactory = /** @class */ (function (_supe
|
|
|
140824
140847
|
var _this = this;
|
|
140825
140848
|
return function () { return [
|
|
140826
140849
|
{
|
|
140827
|
-
to: [SubstrateCompatAddress_1.substrateAddressFactory(_this.network).from(_this.args.candidate).
|
|
140850
|
+
to: [SubstrateCompatAddress_1.substrateAddressFactory(_this.network).from(_this.args.candidate).asString()]
|
|
140828
140851
|
}
|
|
140829
140852
|
]; };
|
|
140830
140853
|
};
|
|
@@ -141987,7 +142010,7 @@ var MoonbeamProtocol = /** @class */ (function (_super) {
|
|
|
141987
142010
|
return [4 /*yield*/, this.options.nodeClient.getCollators()];
|
|
141988
142011
|
case 1:
|
|
141989
142012
|
collators = _a.sent();
|
|
141990
|
-
return [2 /*return*/, collators ? collators[0].
|
|
142013
|
+
return [2 /*return*/, collators ? collators[0].asString() : ''];
|
|
141991
142014
|
}
|
|
141992
142015
|
});
|
|
141993
142016
|
});
|
|
@@ -142060,7 +142083,7 @@ var MoonbeamProtocol = /** @class */ (function (_super) {
|
|
|
142060
142083
|
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
142061
142084
|
case 1:
|
|
142062
142085
|
address = _a.sent();
|
|
142063
|
-
return [2 /*return*/, this.getDelegationDetailsFromAddress(address.
|
|
142086
|
+
return [2 /*return*/, this.getDelegationDetailsFromAddress(address.address, delegatees)];
|
|
142064
142087
|
}
|
|
142065
142088
|
});
|
|
142066
142089
|
});
|
|
@@ -142253,7 +142276,7 @@ var MoonbeamProtocol = /** @class */ (function (_super) {
|
|
|
142253
142276
|
results = _a.sent();
|
|
142254
142277
|
delegatorDetails = results[0];
|
|
142255
142278
|
balance = results[1];
|
|
142256
|
-
delegator = results[2].
|
|
142279
|
+
delegator = results[2].address;
|
|
142257
142280
|
return [4 /*yield*/, this.options.transactionController.prepareSubmittableTransactions(publicKey, balance, [
|
|
142258
142281
|
{
|
|
142259
142282
|
type: SubstrateTransaction_1.SubstrateTransactionType.M_EXECUTE_LEAVE_DELEGATORS,
|
|
@@ -142378,7 +142401,7 @@ var MoonbeamProtocol = /** @class */ (function (_super) {
|
|
|
142378
142401
|
case 1:
|
|
142379
142402
|
results = _a.sent();
|
|
142380
142403
|
balance = results[0];
|
|
142381
|
-
delegator = results[1].
|
|
142404
|
+
delegator = results[1].address;
|
|
142382
142405
|
return [4 /*yield*/, this.options.transactionController.prepareSubmittableTransactions(publicKey, balance, [
|
|
142383
142406
|
{
|
|
142384
142407
|
type: SubstrateTransaction_1.SubstrateTransactionType.M_EXECUTE_DELGATION_REQUEST,
|
|
@@ -142806,7 +142829,7 @@ var MoonbeamAccountController = /** @class */ (function (_super) {
|
|
|
142806
142829
|
break;
|
|
142807
142830
|
}
|
|
142808
142831
|
_c = {
|
|
142809
|
-
address: address.
|
|
142832
|
+
address: address.asString(),
|
|
142810
142833
|
balance: balance.toString(),
|
|
142811
142834
|
totalBond: totalBond.toString(),
|
|
142812
142835
|
delegatees: (_b = delegatorState === null || delegatorState === void 0 ? void 0 : delegatorState.delegations.elements.map(function (bond) { return bond.owner.asAddress(); })) !== null && _b !== void 0 ? _b : []
|
|
@@ -142845,7 +142868,7 @@ var MoonbeamAccountController = /** @class */ (function (_super) {
|
|
|
142845
142868
|
status = 'Leaving';
|
|
142846
142869
|
}
|
|
142847
142870
|
return [2 /*return*/, {
|
|
142848
|
-
address: address.
|
|
142871
|
+
address: address.asString(),
|
|
142849
142872
|
status: status,
|
|
142850
142873
|
minEligibleBalance: candidateInfo.lowestTopDelegationAmount.toString(),
|
|
142851
142874
|
ownStakingBalance: candidateInfo.bond.toString(),
|
|
@@ -142895,7 +142918,7 @@ var MoonbeamAccountController = /** @class */ (function (_super) {
|
|
|
142895
142918
|
break;
|
|
142896
142919
|
}
|
|
142897
142920
|
_f = {
|
|
142898
|
-
address: delegatorAddress.
|
|
142921
|
+
address: delegatorAddress.asString(),
|
|
142899
142922
|
balance: balance.toString(),
|
|
142900
142923
|
totalBond: totalBond.toString(),
|
|
142901
142924
|
delegatees: (_e = delegatorState === null || delegatorState === void 0 ? void 0 : delegatorState.delegations.elements.map(function (bond) { return bond.owner.asAddress(); })) !== null && _e !== void 0 ? _e : []
|
|
@@ -143282,10 +143305,10 @@ var MoonbeamAddress = /** @class */ (function () {
|
|
|
143282
143305
|
return new MoonbeamAddress(address);
|
|
143283
143306
|
};
|
|
143284
143307
|
MoonbeamAddress.prototype.compare = function (other) {
|
|
143285
|
-
var value = typeof other === 'string' ? other : other.
|
|
143286
|
-
return hex_1.stripHexPrefix(this.
|
|
143308
|
+
var value = typeof other === 'string' ? other : other.asString();
|
|
143309
|
+
return hex_1.stripHexPrefix(this.asString()).localeCompare(hex_1.stripHexPrefix(value));
|
|
143287
143310
|
};
|
|
143288
|
-
MoonbeamAddress.prototype.
|
|
143311
|
+
MoonbeamAddress.prototype.asString = function () {
|
|
143289
143312
|
return hex_1.addHexPrefix(this.value);
|
|
143290
143313
|
};
|
|
143291
143314
|
MoonbeamAddress.prototype.getBufferBytes = function () {
|
|
@@ -144611,7 +144634,7 @@ var TezosAddress = /** @class */ (function () {
|
|
|
144611
144634
|
TezosAddress.isTzAddress = function (address) {
|
|
144612
144635
|
return address.startsWith('tz1') || address.startsWith('tz2') || address.startsWith('tz3');
|
|
144613
144636
|
};
|
|
144614
|
-
TezosAddress.prototype.
|
|
144637
|
+
TezosAddress.prototype.asString = function () {
|
|
144615
144638
|
return this.value;
|
|
144616
144639
|
};
|
|
144617
144640
|
return TezosAddress;
|
|
@@ -144721,7 +144744,7 @@ var TezosCryptoClient = /** @class */ (function (_super) {
|
|
|
144721
144744
|
return [4 /*yield*/, this.hash(bufferMessage)];
|
|
144722
144745
|
case 3:
|
|
144723
144746
|
hash = _a.sent();
|
|
144724
|
-
rawSignature = sodium.crypto_sign_detached(hash, keypair.privateKey);
|
|
144747
|
+
rawSignature = sodium.crypto_sign_detached(hash, Buffer.from(keypair.privateKey, 'hex'));
|
|
144725
144748
|
signature = bs58check.encode(Buffer.concat([Buffer.from(this.edsigPrefix), Buffer.from(rawSignature)]));
|
|
144726
144749
|
return [2 /*return*/, signature];
|
|
144727
144750
|
}
|
|
@@ -145064,23 +145087,32 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
145064
145087
|
return __generator(this, function (_a) {
|
|
145065
145088
|
secretKey = index_3.generateWalletUsingDerivationPath(Buffer.from(secret, 'hex'), derivationPath) // TODO: Look into typings
|
|
145066
145089
|
.secretKey;
|
|
145067
|
-
return [2 /*return*/, Buffer.from(secretKey)];
|
|
145090
|
+
return [2 /*return*/, Buffer.from(secretKey).toString('hex')];
|
|
145068
145091
|
});
|
|
145069
145092
|
});
|
|
145070
145093
|
};
|
|
145071
|
-
TezosProtocol.prototype.getAddressFromPublicKey = function (publicKey) {
|
|
145094
|
+
TezosProtocol.prototype.getAddressFromPublicKey = function (publicKey, cursor) {
|
|
145072
145095
|
return __awaiter(this, void 0, void 0, function () {
|
|
145096
|
+
var address;
|
|
145073
145097
|
return __generator(this, function (_a) {
|
|
145074
|
-
|
|
145098
|
+
switch (_a.label) {
|
|
145099
|
+
case 0: return [4 /*yield*/, TezosAddress_1.TezosAddress.fromPublicKey(publicKey)];
|
|
145100
|
+
case 1:
|
|
145101
|
+
address = _a.sent();
|
|
145102
|
+
return [2 /*return*/, {
|
|
145103
|
+
address: address.asString(),
|
|
145104
|
+
cursor: { hasNext: false }
|
|
145105
|
+
}];
|
|
145106
|
+
}
|
|
145075
145107
|
});
|
|
145076
145108
|
});
|
|
145077
145109
|
};
|
|
145078
|
-
TezosProtocol.prototype.getAddressesFromPublicKey = function (publicKey) {
|
|
145110
|
+
TezosProtocol.prototype.getAddressesFromPublicKey = function (publicKey, cursor) {
|
|
145079
145111
|
return __awaiter(this, void 0, void 0, function () {
|
|
145080
145112
|
var address;
|
|
145081
145113
|
return __generator(this, function (_a) {
|
|
145082
145114
|
switch (_a.label) {
|
|
145083
|
-
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
145115
|
+
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey, cursor)];
|
|
145084
145116
|
case 1:
|
|
145085
145117
|
address = _a.sent();
|
|
145086
145118
|
return [2 /*return*/, [address]];
|
|
@@ -145088,20 +145120,13 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
145088
145120
|
});
|
|
145089
145121
|
});
|
|
145090
145122
|
};
|
|
145091
|
-
TezosProtocol.prototype.getNextAddressFromPublicKey = function (publicKey, current) {
|
|
145092
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
145093
|
-
return __generator(this, function (_a) {
|
|
145094
|
-
return [2 /*return*/, current];
|
|
145095
|
-
});
|
|
145096
|
-
});
|
|
145097
|
-
};
|
|
145098
145123
|
TezosProtocol.prototype.getTransactionsFromPublicKey = function (publicKey, limit, cursor) {
|
|
145099
145124
|
return __awaiter(this, void 0, void 0, function () {
|
|
145100
145125
|
var addresses;
|
|
145101
145126
|
return __generator(this, function (_a) {
|
|
145102
145127
|
switch (_a.label) {
|
|
145103
145128
|
case 0: return [4 /*yield*/, this.getAddressesFromPublicKey(publicKey).then(function (addresses) {
|
|
145104
|
-
return addresses.map(function (address) { return address.
|
|
145129
|
+
return addresses.map(function (address) { return address.address; });
|
|
145105
145130
|
})];
|
|
145106
145131
|
case 1:
|
|
145107
145132
|
addresses = _a.sent();
|
|
@@ -145135,7 +145160,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
145135
145160
|
var opSignature, signedOpBytes;
|
|
145136
145161
|
return __generator(this, function (_a) {
|
|
145137
145162
|
switch (_a.label) {
|
|
145138
|
-
case 0: return [4 /*yield*/, this.cryptoClient.operationSignature(privateKey, transaction)];
|
|
145163
|
+
case 0: return [4 /*yield*/, this.cryptoClient.operationSignature(Buffer.from(privateKey, 'hex'), transaction)];
|
|
145139
145164
|
case 1:
|
|
145140
145165
|
opSignature = _a.sent();
|
|
145141
145166
|
signedOpBytes = Buffer.concat([Buffer.from(transaction.binaryTransaction, 'hex'), Buffer.from(opSignature)]);
|
|
@@ -145302,7 +145327,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
145302
145327
|
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
145303
145328
|
case 1:
|
|
145304
145329
|
address = _a.sent();
|
|
145305
|
-
return [2 /*return*/, this.getBalanceOfAddresses([address.
|
|
145330
|
+
return [2 /*return*/, this.getBalanceOfAddresses([address.address], data)];
|
|
145306
145331
|
}
|
|
145307
145332
|
});
|
|
145308
145333
|
});
|
|
@@ -145477,7 +145502,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
145477
145502
|
operations = [];
|
|
145478
145503
|
addressIndex = data && data.addressIndex ? data.addressIndex : 0;
|
|
145479
145504
|
return [4 /*yield*/, this.getAddressesFromPublicKey(publicKey).then(function (addresses) {
|
|
145480
|
-
return addresses.map(function (address) { return address.
|
|
145505
|
+
return addresses.map(function (address) { return address.address; });
|
|
145481
145506
|
})];
|
|
145482
145507
|
case 1:
|
|
145483
145508
|
addresses = _f.sent();
|
|
@@ -145658,7 +145683,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
145658
145683
|
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
145659
145684
|
case 1:
|
|
145660
145685
|
address = _a.sent();
|
|
145661
|
-
return [2 /*return*/, this.getCurrentDelegateesForAddress(address.
|
|
145686
|
+
return [2 /*return*/, this.getCurrentDelegateesForAddress(address.address)];
|
|
145662
145687
|
}
|
|
145663
145688
|
});
|
|
145664
145689
|
});
|
|
@@ -145701,7 +145726,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
145701
145726
|
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
145702
145727
|
case 1:
|
|
145703
145728
|
address = _a.sent();
|
|
145704
|
-
return [2 /*return*/, this.isAddressDelegating(address.
|
|
145729
|
+
return [2 /*return*/, this.isAddressDelegating(address.address)];
|
|
145705
145730
|
}
|
|
145706
145731
|
});
|
|
145707
145732
|
});
|
|
@@ -145727,7 +145752,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
145727
145752
|
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
145728
145753
|
case 1:
|
|
145729
145754
|
address = _a.sent();
|
|
145730
|
-
return [2 /*return*/, this.getDelegatorDetailsFromAddress(address.
|
|
145755
|
+
return [2 /*return*/, this.getDelegatorDetailsFromAddress(address.address)];
|
|
145731
145756
|
}
|
|
145732
145757
|
});
|
|
145733
145758
|
});
|
|
@@ -145747,7 +145772,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
145747
145772
|
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
145748
145773
|
case 1:
|
|
145749
145774
|
address = _a.sent();
|
|
145750
|
-
return [2 /*return*/, this.getDelegationDetailsFromAddress(address.
|
|
145775
|
+
return [2 /*return*/, this.getDelegationDetailsFromAddress(address.address, delegatees)];
|
|
145751
145776
|
}
|
|
145752
145777
|
});
|
|
145753
145778
|
});
|
|
@@ -145862,7 +145887,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
145862
145887
|
case 0:
|
|
145863
145888
|
counter = new bignumber_1.default(1);
|
|
145864
145889
|
operations = [];
|
|
145865
|
-
return [4 /*yield*/, this.getAddressFromPublicKey(publicKey).then(function (address) { return address.
|
|
145890
|
+
return [4 /*yield*/, this.getAddressFromPublicKey(publicKey).then(function (address) { return address.address; })];
|
|
145866
145891
|
case 1:
|
|
145867
145892
|
address = _f.sent();
|
|
145868
145893
|
return [4 /*yield*/, Promise.all([
|
|
@@ -146261,7 +146286,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
146261
146286
|
counter = new bignumber_1.default(1);
|
|
146262
146287
|
branch = '';
|
|
146263
146288
|
operations = [];
|
|
146264
|
-
return [4 /*yield*/, this.getAddressFromPublicKey(publicKey).then(function (address) { return address.
|
|
146289
|
+
return [4 /*yield*/, this.getAddressFromPublicKey(publicKey).then(function (address) { return address.address; })];
|
|
146265
146290
|
case 1:
|
|
146266
146291
|
tzAddress = _d.sent();
|
|
146267
146292
|
return [4 /*yield*/, Promise.all([
|
|
@@ -148482,18 +148507,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
148482
148507
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
148483
148508
|
exports.TezosFA1Protocol = void 0;
|
|
148484
148509
|
var bignumber_1 = __importDefault(require("../../../dependencies/src/bignumber.js-9.0.0/bignumber"));
|
|
148510
|
+
var errors_1 = require("../../../errors");
|
|
148511
|
+
var coinlib_error_1 = require("../../../errors/coinlib-error");
|
|
148485
148512
|
var hex_1 = require("../../../utils/hex");
|
|
148486
148513
|
var TezosProtocol_1 = require("../TezosProtocol");
|
|
148487
148514
|
var TezosUtils_1 = require("../TezosUtils");
|
|
148488
148515
|
var MichelsonPair_1 = require("../types/michelson/generics/MichelsonPair");
|
|
148489
148516
|
var MichelsonAddress_1 = require("../types/michelson/primitives/MichelsonAddress");
|
|
148490
148517
|
var MichelsonInt_1 = require("../types/michelson/primitives/MichelsonInt");
|
|
148518
|
+
var MichelsonString_1 = require("../types/michelson/primitives/MichelsonString");
|
|
148491
148519
|
var TezosOperationType_1 = require("../types/TezosOperationType");
|
|
148492
148520
|
var utils_1 = require("../types/utils");
|
|
148493
148521
|
var TezosFAProtocol_1 = require("./TezosFAProtocol");
|
|
148494
|
-
var errors_1 = require("../../../errors");
|
|
148495
|
-
var coinlib_error_1 = require("../../../errors/coinlib-error");
|
|
148496
|
-
var MichelsonString_1 = require("../types/michelson/primitives/MichelsonString");
|
|
148497
148522
|
var TezosFA1ContractEntrypoint;
|
|
148498
148523
|
(function (TezosFA1ContractEntrypoint) {
|
|
148499
148524
|
TezosFA1ContractEntrypoint["BALANCE"] = "getBalance";
|
|
@@ -148686,7 +148711,7 @@ var TezosFA1Protocol = /** @class */ (function (_super) {
|
|
|
148686
148711
|
addressIndex = data && data.addressIndex !== undefined ? data.addressIndex : 0;
|
|
148687
148712
|
return [4 /*yield*/, this.getAddressesFromPublicKey(publicKey)];
|
|
148688
148713
|
case 1:
|
|
148689
|
-
addresses = (_a.sent()).map(function (address) { return address.
|
|
148714
|
+
addresses = (_a.sent()).map(function (address) { return address.address; });
|
|
148690
148715
|
if (!addresses[addressIndex]) {
|
|
148691
148716
|
throw new errors_1.NotFoundError(coinlib_error_1.Domain.TEZOSFA, "no kt-address with index " + addressIndex + " exists");
|
|
148692
148717
|
}
|
|
@@ -148955,7 +148980,7 @@ var TezosFA2Protocol = /** @class */ (function (_super) {
|
|
|
148955
148980
|
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
148956
148981
|
case 1:
|
|
148957
148982
|
address = _a.sent();
|
|
148958
|
-
return [2 /*return*/, this.getBalanceOfAddresses([address.
|
|
148983
|
+
return [2 /*return*/, this.getBalanceOfAddresses([address.address], data)];
|
|
148959
148984
|
}
|
|
148960
148985
|
});
|
|
148961
148986
|
});
|
|
@@ -149242,7 +149267,7 @@ var TezosFA2Protocol = /** @class */ (function (_super) {
|
|
|
149242
149267
|
tokenID = (_c = (_b = data === null || data === void 0 ? void 0 : data.assetID) !== null && _b !== void 0 ? _b : this.tokenID) !== null && _c !== void 0 ? _c : 0;
|
|
149243
149268
|
return [4 /*yield*/, this.getAddressesFromPublicKey(publicKey)];
|
|
149244
149269
|
case 1:
|
|
149245
|
-
addresses = (_d.sent()).map(function (address) { return address.
|
|
149270
|
+
addresses = (_d.sent()).map(function (address) { return address.address; });
|
|
149246
149271
|
if (!addresses[addressIndex]) {
|
|
149247
149272
|
throw new errors_1.NotFoundError(coinlib_error_1.Domain.TEZOSFA, "no kt-address with index " + addressIndex + " exists");
|
|
149248
149273
|
}
|
|
@@ -149437,7 +149462,7 @@ var TezosFAProtocol = /** @class */ (function (_super) {
|
|
|
149437
149462
|
switch (_a.label) {
|
|
149438
149463
|
case 0: return [4 /*yield*/, this.getAddressesFromPublicKey(publicKey)];
|
|
149439
149464
|
case 1:
|
|
149440
|
-
addresses = (_a.sent()).map(function (address) { return address.
|
|
149465
|
+
addresses = (_a.sent()).map(function (address) { return address.address; });
|
|
149441
149466
|
return [2 /*return*/, this.getTransactionsFromAddresses(addresses, limit, cursor)];
|
|
149442
149467
|
}
|
|
149443
149468
|
});
|
|
@@ -151129,6 +151154,7 @@ var TezosProtocol_1 = require("../TezosProtocol");
|
|
|
151129
151154
|
var TezosOperationType_1 = require("../types/TezosOperationType");
|
|
151130
151155
|
var TezosKtAddress_1 = require("./TezosKtAddress");
|
|
151131
151156
|
var TezosUtils_1 = require("../TezosUtils");
|
|
151157
|
+
var INDEX_LIMIT = 10000;
|
|
151132
151158
|
var TezosKtProtocol = /** @class */ (function (_super) {
|
|
151133
151159
|
__extends(TezosKtProtocol, _super);
|
|
151134
151160
|
function TezosKtProtocol() {
|
|
@@ -151140,15 +151166,16 @@ var TezosKtProtocol = /** @class */ (function (_super) {
|
|
|
151140
151166
|
_this.migrationFee = new bignumber_1.default(5000);
|
|
151141
151167
|
return _this;
|
|
151142
151168
|
}
|
|
151143
|
-
TezosKtProtocol.prototype.getAddressFromPublicKey = function (publicKey,
|
|
151169
|
+
TezosKtProtocol.prototype.getAddressFromPublicKey = function (publicKey, cursor) {
|
|
151170
|
+
var _a;
|
|
151144
151171
|
return __awaiter(this, void 0, void 0, function () {
|
|
151145
151172
|
var addresses, index;
|
|
151146
|
-
return __generator(this, function (
|
|
151147
|
-
switch (
|
|
151173
|
+
return __generator(this, function (_b) {
|
|
151174
|
+
switch (_b.label) {
|
|
151148
151175
|
case 0: return [4 /*yield*/, this.getAddressesFromPublicKey(publicKey)];
|
|
151149
151176
|
case 1:
|
|
151150
|
-
addresses =
|
|
151151
|
-
index =
|
|
151177
|
+
addresses = _b.sent();
|
|
151178
|
+
index = (_a = cursor === null || cursor === void 0 ? void 0 : cursor.index) !== null && _a !== void 0 ? _a : 0;
|
|
151152
151179
|
if (index >= addresses.length) {
|
|
151153
151180
|
throw new errors_1.NotFoundError(coinlib_error_1.Domain.TEZOS, 'No address for the specified index exists');
|
|
151154
151181
|
}
|
|
@@ -151157,18 +151184,40 @@ var TezosKtProtocol = /** @class */ (function (_super) {
|
|
|
151157
151184
|
});
|
|
151158
151185
|
});
|
|
151159
151186
|
};
|
|
151160
|
-
TezosKtProtocol.prototype.getAddressesFromPublicKey = function (publicKey) {
|
|
151187
|
+
TezosKtProtocol.prototype.getAddressesFromPublicKey = function (publicKey, cursor) {
|
|
151188
|
+
var _a;
|
|
151161
151189
|
return __awaiter(this, void 0, void 0, function () {
|
|
151162
|
-
var tz1address, ktAddresses;
|
|
151163
|
-
|
|
151164
|
-
|
|
151190
|
+
var tz1address, startIndex, ktAddresses, addresses;
|
|
151191
|
+
var _this = this;
|
|
151192
|
+
return __generator(this, function (_b) {
|
|
151193
|
+
switch (_b.label) {
|
|
151165
151194
|
case 0: return [4 /*yield*/, _super.prototype.getAddressFromPublicKey.call(this, publicKey)];
|
|
151166
151195
|
case 1:
|
|
151167
|
-
tz1address = (
|
|
151168
|
-
|
|
151196
|
+
tz1address = (_b.sent()).address;
|
|
151197
|
+
startIndex = (_a = cursor === null || cursor === void 0 ? void 0 : cursor.index) !== null && _a !== void 0 ? _a : 0;
|
|
151198
|
+
return [4 /*yield*/, this.options.network.extras.indexerClient.getDelegatorContracts(tz1address, INDEX_LIMIT)];
|
|
151169
151199
|
case 2:
|
|
151170
|
-
ktAddresses =
|
|
151171
|
-
return [
|
|
151200
|
+
ktAddresses = _b.sent();
|
|
151201
|
+
return [4 /*yield*/, Promise.all(ktAddresses.reverse().map(function (ktAddress, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
151202
|
+
var address;
|
|
151203
|
+
return __generator(this, function (_a) {
|
|
151204
|
+
switch (_a.label) {
|
|
151205
|
+
case 0: return [4 /*yield*/, TezosKtAddress_1.TezosKtAddress.from(ktAddress)];
|
|
151206
|
+
case 1:
|
|
151207
|
+
address = _a.sent();
|
|
151208
|
+
return [2 /*return*/, {
|
|
151209
|
+
address: address.asString(),
|
|
151210
|
+
cursor: {
|
|
151211
|
+
hasNext: index < INDEX_LIMIT - 1,
|
|
151212
|
+
index: index
|
|
151213
|
+
}
|
|
151214
|
+
}];
|
|
151215
|
+
}
|
|
151216
|
+
});
|
|
151217
|
+
}); }))];
|
|
151218
|
+
case 3:
|
|
151219
|
+
addresses = _b.sent();
|
|
151220
|
+
return [2 /*return*/, addresses.slice(startIndex)];
|
|
151172
151221
|
}
|
|
151173
151222
|
});
|
|
151174
151223
|
});
|
|
@@ -151178,10 +151227,14 @@ var TezosKtProtocol = /** @class */ (function (_super) {
|
|
|
151178
151227
|
var address;
|
|
151179
151228
|
return __generator(this, function (_a) {
|
|
151180
151229
|
switch (_a.label) {
|
|
151181
|
-
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey, data === null || data === void 0 ? void 0 : data.addressIndex)
|
|
151230
|
+
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey, (data === null || data === void 0 ? void 0 : data.addressIndex) ? {
|
|
151231
|
+
hasNext: data.addressIndex < INDEX_LIMIT - 1,
|
|
151232
|
+
index: data.addressIndex
|
|
151233
|
+
}
|
|
151234
|
+
: undefined)];
|
|
151182
151235
|
case 1:
|
|
151183
151236
|
address = _a.sent();
|
|
151184
|
-
return [2 /*return*/, this.getBalanceOfAddresses([address.
|
|
151237
|
+
return [2 /*return*/, this.getBalanceOfAddresses([address.address])];
|
|
151185
151238
|
}
|
|
151186
151239
|
});
|
|
151187
151240
|
});
|
|
@@ -151231,7 +151284,7 @@ var TezosKtProtocol = /** @class */ (function (_super) {
|
|
|
151231
151284
|
operations = [];
|
|
151232
151285
|
return [4 /*yield*/, _super.prototype.getAddressFromPublicKey.call(this, publicKey)];
|
|
151233
151286
|
case 1:
|
|
151234
|
-
address = (_e.sent()).
|
|
151287
|
+
address = (_e.sent()).address;
|
|
151235
151288
|
_a = bignumber_1.default.bind;
|
|
151236
151289
|
return [4 /*yield*/, _super.prototype.getBalanceOfAddresses.call(this, [address])];
|
|
151237
151290
|
case 2:
|
|
@@ -151809,16 +151862,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
151809
151862
|
exports.TezosSaplingProtocol = void 0;
|
|
151810
151863
|
var sapling = __importStar(require("@airgap/sapling-wasm"));
|
|
151811
151864
|
var sodium = require("libsodium-wrappers");
|
|
151812
|
-
var __1 = require("../../..");
|
|
151813
151865
|
var bignumber_1 = __importDefault(require("../../../dependencies/src/bignumber.js-9.0.0/bignumber"));
|
|
151814
151866
|
var bip39_2_5_0_1 = require("../../../dependencies/src/bip39-2.5.0");
|
|
151815
151867
|
var errors_1 = require("../../../errors");
|
|
151868
|
+
var coinlib_error_1 = require("../../../errors/coinlib-error");
|
|
151816
151869
|
var array_1 = require("../../../utils/array");
|
|
151817
151870
|
var NonExtendedProtocol_1 = require("../../NonExtendedProtocol");
|
|
151818
151871
|
var TezosContract_1 = require("../contract/TezosContract");
|
|
151819
151872
|
var TezosAddress_1 = require("../TezosAddress");
|
|
151820
151873
|
var TezosProtocol_1 = require("../TezosProtocol");
|
|
151821
151874
|
var TezosProtocolOptions_1 = require("../TezosProtocolOptions");
|
|
151875
|
+
var TezosUtils_1 = require("../TezosUtils");
|
|
151822
151876
|
var MichelsonAddress_1 = require("../types/michelson/primitives/MichelsonAddress");
|
|
151823
151877
|
var TezosOperationType_1 = require("../types/TezosOperationType");
|
|
151824
151878
|
var TezosSaplingNodeClient_1 = require("./node/TezosSaplingNodeClient");
|
|
@@ -151927,23 +151981,60 @@ var TezosSaplingProtocol = /** @class */ (function (_super) {
|
|
|
151927
151981
|
};
|
|
151928
151982
|
TezosSaplingProtocol.prototype.getPrivateKeyFromHexSecret = function (secret, derivationPath) {
|
|
151929
151983
|
return __awaiter(this, void 0, void 0, function () {
|
|
151984
|
+
var xsk;
|
|
151930
151985
|
return __generator(this, function (_a) {
|
|
151931
|
-
|
|
151986
|
+
switch (_a.label) {
|
|
151987
|
+
case 0: return [4 /*yield*/, sapling.getExtendedSpendingKey(secret, derivationPath)];
|
|
151988
|
+
case 1:
|
|
151989
|
+
xsk = _a.sent();
|
|
151990
|
+
return [2 /*return*/, xsk.toString('hex')];
|
|
151991
|
+
}
|
|
151932
151992
|
});
|
|
151933
151993
|
});
|
|
151934
151994
|
};
|
|
151935
|
-
TezosSaplingProtocol.prototype.getAddressFromPublicKey = function (viewingKey) {
|
|
151995
|
+
TezosSaplingProtocol.prototype.getAddressFromPublicKey = function (viewingKey, cursor) {
|
|
151936
151996
|
return __awaiter(this, void 0, void 0, function () {
|
|
151937
|
-
|
|
151938
|
-
|
|
151997
|
+
var current, _a, address, _b;
|
|
151998
|
+
return __generator(this, function (_c) {
|
|
151999
|
+
switch (_c.label) {
|
|
152000
|
+
case 0:
|
|
152001
|
+
if (!((cursor === null || cursor === void 0 ? void 0 : cursor.hasNext) && (cursor === null || cursor === void 0 ? void 0 : cursor.diversifierIndex))) return [3 /*break*/, 2];
|
|
152002
|
+
return [4 /*yield*/, TezosSaplingAddress_1.TezosSaplingAddress.fromViewingKey(viewingKey, cursor.diversifierIndex)];
|
|
152003
|
+
case 1:
|
|
152004
|
+
_a = _c.sent();
|
|
152005
|
+
return [3 /*break*/, 3];
|
|
152006
|
+
case 2:
|
|
152007
|
+
_a = undefined;
|
|
152008
|
+
_c.label = 3;
|
|
152009
|
+
case 3:
|
|
152010
|
+
current = _a;
|
|
152011
|
+
if (!current) return [3 /*break*/, 5];
|
|
152012
|
+
return [4 /*yield*/, TezosSaplingAddress_1.TezosSaplingAddress.next(viewingKey, current)];
|
|
152013
|
+
case 4:
|
|
152014
|
+
_b = _c.sent();
|
|
152015
|
+
return [3 /*break*/, 7];
|
|
152016
|
+
case 5: return [4 /*yield*/, TezosSaplingAddress_1.TezosSaplingAddress.fromViewingKey(viewingKey)];
|
|
152017
|
+
case 6:
|
|
152018
|
+
_b = _c.sent();
|
|
152019
|
+
_c.label = 7;
|
|
152020
|
+
case 7:
|
|
152021
|
+
address = _b;
|
|
152022
|
+
return [2 /*return*/, {
|
|
152023
|
+
address: address.asString(),
|
|
152024
|
+
cursor: {
|
|
152025
|
+
hasNext: address.diversifierIndex !== undefined,
|
|
152026
|
+
diversifierIndex: address.diversifierIndex
|
|
152027
|
+
}
|
|
152028
|
+
}];
|
|
152029
|
+
}
|
|
151939
152030
|
});
|
|
151940
152031
|
});
|
|
151941
152032
|
};
|
|
151942
|
-
TezosSaplingProtocol.prototype.getAddressesFromPublicKey = function (viewingKey) {
|
|
152033
|
+
TezosSaplingProtocol.prototype.getAddressesFromPublicKey = function (viewingKey, cursor) {
|
|
151943
152034
|
return __awaiter(this, void 0, void 0, function () {
|
|
151944
152035
|
return __generator(this, function (_a) {
|
|
151945
152036
|
switch (_a.label) {
|
|
151946
|
-
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(viewingKey)];
|
|
152037
|
+
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(viewingKey, cursor)];
|
|
151947
152038
|
case 1: return [2 /*return*/, [_a.sent()]];
|
|
151948
152039
|
}
|
|
151949
152040
|
});
|
|
@@ -151951,15 +152042,20 @@ var TezosSaplingProtocol = /** @class */ (function (_super) {
|
|
|
151951
152042
|
};
|
|
151952
152043
|
TezosSaplingProtocol.prototype.getAddressFromViewingKey = function (viewingKey, index) {
|
|
151953
152044
|
return __awaiter(this, void 0, void 0, function () {
|
|
152045
|
+
var address;
|
|
151954
152046
|
return __generator(this, function (_a) {
|
|
151955
|
-
|
|
151956
|
-
|
|
151957
|
-
|
|
151958
|
-
|
|
151959
|
-
|
|
151960
|
-
|
|
151961
|
-
|
|
151962
|
-
|
|
152047
|
+
switch (_a.label) {
|
|
152048
|
+
case 0: return [4 /*yield*/, TezosSaplingAddress_1.TezosSaplingAddress.fromViewingKey(viewingKey, index)];
|
|
152049
|
+
case 1:
|
|
152050
|
+
address = _a.sent();
|
|
152051
|
+
return [2 /*return*/, {
|
|
152052
|
+
address: address.asString(),
|
|
152053
|
+
cursor: {
|
|
152054
|
+
hasNext: address.diversifierIndex !== undefined,
|
|
152055
|
+
diversifierIndex: address.diversifierIndex
|
|
152056
|
+
}
|
|
152057
|
+
}];
|
|
152058
|
+
}
|
|
151963
152059
|
});
|
|
151964
152060
|
});
|
|
151965
152061
|
};
|
|
@@ -152022,7 +152118,7 @@ var TezosSaplingProtocol = /** @class */ (function (_super) {
|
|
|
152022
152118
|
case 0:
|
|
152023
152119
|
_a = {};
|
|
152024
152120
|
return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
152025
|
-
case 1: return [2 /*return*/, (_a.from = [(_b.sent()).
|
|
152121
|
+
case 1: return [2 /*return*/, (_a.from = [(_b.sent()).address],
|
|
152026
152122
|
_a.to = [input.address],
|
|
152027
152123
|
_a.isInbound = false,
|
|
152028
152124
|
_a.amount = input.value,
|
|
@@ -152054,7 +152150,7 @@ var TezosSaplingProtocol = /** @class */ (function (_super) {
|
|
|
152054
152150
|
boundData = transaction.unshieldTarget && transaction.unshieldTarget.length > 0
|
|
152055
152151
|
? this.createAddressBoundData(transaction.unshieldTarget)
|
|
152056
152152
|
: undefined;
|
|
152057
|
-
return [4 /*yield*/, this.forger.forgeSaplingTransaction(transaction.ins, transaction.outs, stateTree, this.getAntiReplay(transaction.chainId, transaction.contractAddress), boundData, privateKey)];
|
|
152153
|
+
return [4 /*yield*/, this.forger.forgeSaplingTransaction(transaction.ins, transaction.outs, stateTree, this.getAntiReplay(transaction.chainId, transaction.contractAddress), boundData, Buffer.from(privateKey, 'hex'))];
|
|
152058
152154
|
case 2:
|
|
152059
152155
|
forgedTransaction = _a.sent();
|
|
152060
152156
|
return [2 /*return*/, this.encoder.encodeTransaction(forgedTransaction).toString('hex')];
|
|
@@ -152072,7 +152168,7 @@ var TezosSaplingProtocol = /** @class */ (function (_super) {
|
|
|
152072
152168
|
airGapTxs = [];
|
|
152073
152169
|
if (!this.isRawTezosSaplingTransaction(tx)) return [3 /*break*/, 2];
|
|
152074
152170
|
unshieldTarget = tx.unshieldTarget.length > 0 ? tx.unshieldTarget : undefined;
|
|
152075
|
-
return [4 /*yield*/, this.getAddressFromPublicKey(transaction.publicKey)];
|
|
152171
|
+
return [4 /*yield*/, this.getAddressFromPublicKey(transaction.publicKey).then(function (address) { return TezosSaplingAddress_1.TezosSaplingAddress.fromValue(address.address, address.cursor.diversifierIndex); })];
|
|
152076
152172
|
case 1:
|
|
152077
152173
|
from = _d.sent();
|
|
152078
152174
|
details = this.bookkeeper
|
|
@@ -152285,11 +152381,11 @@ var TezosSaplingProtocol = /** @class */ (function (_super) {
|
|
|
152285
152381
|
rpcErrors = error_1.data;
|
|
152286
152382
|
cannotPayStorageFee = rpcErrors.find(function (error) { return error.id.endsWith('.contract.cannot_pay_storage_fee'); });
|
|
152287
152383
|
if (cannotPayStorageFee) {
|
|
152288
|
-
throw new errors_1.BalanceError(
|
|
152384
|
+
throw new errors_1.BalanceError(coinlib_error_1.Domain.TEZOS, 'Balance too low, cannot pay for storage fee');
|
|
152289
152385
|
}
|
|
152290
152386
|
balanceTooLowError = rpcErrors.find(function (error) { return error.id.endsWith('.contract.balance_too_low'); });
|
|
152291
152387
|
if (balanceTooLowError) {
|
|
152292
|
-
throw new errors_1.BalanceError(
|
|
152388
|
+
throw new errors_1.BalanceError(coinlib_error_1.Domain.TEZOS, 'Balance too low');
|
|
152293
152389
|
}
|
|
152294
152390
|
}
|
|
152295
152391
|
throw error_1;
|
|
@@ -152360,7 +152456,9 @@ var TezosSaplingProtocol = /** @class */ (function (_super) {
|
|
|
152360
152456
|
return [4 /*yield*/, this.chooseInputs(viewingKey, stateDiff.commitments_and_ciphertexts, stateDiff.nullifiers, value)];
|
|
152361
152457
|
case 2:
|
|
152362
152458
|
_d = _g.sent(), inputs = _d[0], toSpend = _d[1];
|
|
152363
|
-
return [4 /*yield*/, this.getAddressFromPublicKey(viewingKey)
|
|
152459
|
+
return [4 /*yield*/, this.getAddressFromPublicKey(viewingKey).then(function (address) {
|
|
152460
|
+
return TezosSaplingAddress_1.TezosSaplingAddress.fromValue(address.address, address.cursor.diversifierIndex);
|
|
152461
|
+
})];
|
|
152364
152462
|
case 3:
|
|
152365
152463
|
address = _g.sent();
|
|
152366
152464
|
_e = this.createPaymentOutput;
|
|
@@ -152405,7 +152503,7 @@ var TezosSaplingProtocol = /** @class */ (function (_super) {
|
|
|
152405
152503
|
_b = {};
|
|
152406
152504
|
return [4 /*yield*/, TezosSaplingAddress_1.TezosSaplingAddress.fromValue(recipient)];
|
|
152407
152505
|
case 2:
|
|
152408
|
-
output = (_b.address = (_c.sent()).
|
|
152506
|
+
output = (_b.address = (_c.sent()).asString(),
|
|
152409
152507
|
_b.value = value,
|
|
152410
152508
|
_b.memo = Buffer.alloc(this.options.config.memoSize).toString('hex'),
|
|
152411
152509
|
_b.browsable = true,
|
|
@@ -152439,7 +152537,7 @@ var TezosSaplingProtocol = /** @class */ (function (_super) {
|
|
|
152439
152537
|
_c = {};
|
|
152440
152538
|
return [4 /*yield*/, this.getAddressFromPublicKey(viewingKey)];
|
|
152441
152539
|
case 3:
|
|
152442
|
-
paybackOutput = (_c.address = (_d.sent()).
|
|
152540
|
+
paybackOutput = (_c.address = (_d.sent()).address,
|
|
152443
152541
|
_c.value = toSpend.minus(value).toString(),
|
|
152444
152542
|
_c.memo = Buffer.alloc(this.options.config.memoSize).toString('hex'),
|
|
152445
152543
|
_c.browsable = true,
|
|
@@ -152486,7 +152584,7 @@ var TezosSaplingProtocol = /** @class */ (function (_super) {
|
|
|
152486
152584
|
TezosSaplingProtocol.prototype.createPaymentOutput = function (address, value, memo) {
|
|
152487
152585
|
if (memo === void 0) { memo = Buffer.alloc(this.options.config.memoSize); }
|
|
152488
152586
|
return {
|
|
152489
|
-
address: address.
|
|
152587
|
+
address: address.asString(),
|
|
152490
152588
|
value: new bignumber_1.default(value).toString(),
|
|
152491
152589
|
memo: memo.toString('hex'),
|
|
152492
152590
|
browsable: true
|
|
@@ -152497,7 +152595,7 @@ var TezosSaplingProtocol = /** @class */ (function (_super) {
|
|
|
152497
152595
|
var paybackValue = toSpend.minus(value);
|
|
152498
152596
|
return paybackValue.gt(0)
|
|
152499
152597
|
? {
|
|
152500
|
-
address: address.
|
|
152598
|
+
address: address.asString(),
|
|
152501
152599
|
value: paybackValue.toString(),
|
|
152502
152600
|
memo: memo.toString('hex'),
|
|
152503
152601
|
browsable: true
|
|
@@ -152516,7 +152614,7 @@ var TezosSaplingProtocol = /** @class */ (function (_super) {
|
|
|
152516
152614
|
rcm: rcm.toString('hex'),
|
|
152517
152615
|
pos: '0',
|
|
152518
152616
|
value: '0',
|
|
152519
|
-
address: address.
|
|
152617
|
+
address: address.asString()
|
|
152520
152618
|
}];
|
|
152521
152619
|
}
|
|
152522
152620
|
});
|
|
@@ -152535,7 +152633,7 @@ var TezosSaplingProtocol = /** @class */ (function (_super) {
|
|
|
152535
152633
|
address = _a.sent();
|
|
152536
152634
|
memo = sodium.randombytes_buf(this.options.config.memoSize);
|
|
152537
152635
|
return [2 /*return*/, {
|
|
152538
|
-
address: address.
|
|
152636
|
+
address: address.address,
|
|
152539
152637
|
value: '0',
|
|
152540
152638
|
memo: Buffer.from(memo).toString('hex'),
|
|
152541
152639
|
browsable: false
|
|
@@ -152562,8 +152660,8 @@ var TezosSaplingProtocol = /** @class */ (function (_super) {
|
|
|
152562
152660
|
});
|
|
152563
152661
|
};
|
|
152564
152662
|
TezosSaplingProtocol.prototype.createAddressBoundData = function (address) {
|
|
152565
|
-
var michelson = MichelsonAddress_1.MichelsonAddress.from(
|
|
152566
|
-
return
|
|
152663
|
+
var michelson = MichelsonAddress_1.MichelsonAddress.from(TezosUtils_1.TezosUtils.encodeTzAddress(address));
|
|
152664
|
+
return TezosUtils_1.TezosUtils.packMichelsonType(michelson);
|
|
152567
152665
|
};
|
|
152568
152666
|
TezosSaplingProtocol.prototype.getAntiReplay = function (chainId, contractAddress) {
|
|
152569
152667
|
return (contractAddress !== null && contractAddress !== void 0 ? contractAddress : this.options.config.contractAddress) + chainId;
|
|
@@ -152672,7 +152770,7 @@ var TezosSaplingProtocol = /** @class */ (function (_super) {
|
|
|
152672
152770
|
exports.TezosSaplingProtocol = TezosSaplingProtocol;
|
|
152673
152771
|
|
|
152674
152772
|
}).call(this)}).call(this,require("buffer").Buffer)
|
|
152675
|
-
},{"
|
|
152773
|
+
},{"../../../dependencies/src/bignumber.js-9.0.0/bignumber":269,"../../../dependencies/src/bip39-2.5.0":274,"../../../errors":491,"../../../errors/coinlib-error":490,"../../../utils/array":800,"../../NonExtendedProtocol":497,"../TezosAddress":657,"../TezosProtocol":659,"../TezosProtocolOptions":660,"../TezosUtils":661,"../contract/TezosContract":662,"../types/TezosOperationType":705,"../types/michelson/primitives/MichelsonAddress":715,"./TezosSaplingAddress":695,"./TezosSaplingCryptoClient":696,"./node/TezosSaplingNodeClient":700,"./utils/TezosSaplingBookkeeper":701,"./utils/TezosSaplingEncoder":702,"./utils/TezosSaplingForger":703,"./utils/TezosSaplingState":704,"@airgap/sapling-wasm":829,"buffer":67,"libsodium-wrappers":1160}],698:[function(require,module,exports){
|
|
152676
152774
|
"use strict";
|
|
152677
152775
|
var __extends = (this && this.__extends) || (function () {
|
|
152678
152776
|
var extendStatics = function (d, b) {
|
|
@@ -153024,7 +153122,7 @@ var TezosSaplingBookkeeper = /** @class */ (function () {
|
|
|
153024
153122
|
var _this = this;
|
|
153025
153123
|
if (unshieldTarget === undefined) {
|
|
153026
153124
|
return outputs.map(function (out) { return ({
|
|
153027
|
-
from: [sender.
|
|
153125
|
+
from: [sender.asString()],
|
|
153028
153126
|
to: [out.address],
|
|
153029
153127
|
isInbound: false,
|
|
153030
153128
|
amount: out.value,
|
|
@@ -153037,7 +153135,7 @@ var TezosSaplingBookkeeper = /** @class */ (function () {
|
|
|
153037
153135
|
var amount = this.sumNotes(inputs).minus(this.sumNotes(outputs));
|
|
153038
153136
|
return [
|
|
153039
153137
|
{
|
|
153040
|
-
from: [sender.
|
|
153138
|
+
from: [sender.asString()],
|
|
153041
153139
|
to: [unshieldTarget],
|
|
153042
153140
|
isInbound: false,
|
|
153043
153141
|
amount: amount.toFixed(),
|
|
@@ -153086,7 +153184,7 @@ var TezosSaplingBookkeeper = /** @class */ (function () {
|
|
|
153086
153184
|
_e = {};
|
|
153087
153185
|
return [4 /*yield*/, TezosSaplingAddress_1.TezosSaplingAddress.fromViewingKey(from)];
|
|
153088
153186
|
case 2:
|
|
153089
|
-
unshieldDetails = _c.apply(_b, _d.concat([(_e.from = [(_f.sent()).
|
|
153187
|
+
unshieldDetails = _c.apply(_b, _d.concat([(_e.from = [(_f.sent()).asString()], _e)]));
|
|
153090
153188
|
_f.label = 3;
|
|
153091
153189
|
case 3:
|
|
153092
153190
|
details.push(unshieldDetails);
|
|
@@ -153140,10 +153238,10 @@ var TezosSaplingBookkeeper = /** @class */ (function () {
|
|
|
153140
153238
|
_b = _c.sent(), to = _b[0], amount = _b[1];
|
|
153141
153239
|
outputDetails = {};
|
|
153142
153240
|
if (from !== undefined) {
|
|
153143
|
-
outputDetails = Object.assign(outputDetails, { from: [from.
|
|
153241
|
+
outputDetails = Object.assign(outputDetails, { from: [from.asString()] });
|
|
153144
153242
|
}
|
|
153145
153243
|
if (to !== undefined) {
|
|
153146
|
-
outputDetails = Object.assign(outputDetails, { to: [to.
|
|
153244
|
+
outputDetails = Object.assign(outputDetails, { to: [to.asString()] });
|
|
153147
153245
|
}
|
|
153148
153246
|
if (amount !== undefined) {
|
|
153149
153247
|
outputDetails = Object.assign(outputDetails, { amount: amount.toFixed() });
|
|
@@ -153412,7 +153510,7 @@ var TezosSaplingBookkeeper = /** @class */ (function () {
|
|
|
153412
153510
|
};
|
|
153413
153511
|
return [4 /*yield*/, TezosSaplingAddress_1.TezosSaplingAddress.fromRaw(address)];
|
|
153414
153512
|
case 4:
|
|
153415
|
-
input = (_c.address = (_d.sent()).
|
|
153513
|
+
input = (_c.address = (_d.sent()).asString(),
|
|
153416
153514
|
_c);
|
|
153417
153515
|
return [2 /*return*/, [Buffer.from(memo), input]];
|
|
153418
153516
|
case 5:
|
|
@@ -153441,7 +153539,7 @@ var TezosSaplingBookkeeper = /** @class */ (function () {
|
|
|
153441
153539
|
};
|
|
153442
153540
|
return [4 /*yield*/, TezosSaplingAddress_1.TezosSaplingAddress.fromRaw(address)];
|
|
153443
153541
|
case 2:
|
|
153444
|
-
input = (_c.address = (_d.sent()).
|
|
153542
|
+
input = (_c.address = (_d.sent()).asString(),
|
|
153445
153543
|
_c);
|
|
153446
153544
|
return [2 /*return*/, [Buffer.from(memo), input]];
|
|
153447
153545
|
case 3:
|
|
@@ -161002,6 +161100,7 @@ exports.AES = void 0;
|
|
|
161002
161100
|
var crypto = __importStar(require("crypto"));
|
|
161003
161101
|
var errors_1 = require("../errors");
|
|
161004
161102
|
var coinlib_error_1 = require("../errors/coinlib-error");
|
|
161103
|
+
var hex_1 = require("./hex");
|
|
161005
161104
|
// https://github.com/microsoft/botbuilder-js/blob/master/libraries/botframework-config/src/encrypt.ts#L20
|
|
161006
161105
|
var AES = /** @class */ (function () {
|
|
161007
161106
|
function AES(AES_KEY_SIZE, KEY_DERIVATION_ITERATION_COUNT, ALGORITHM, encoding) {
|
|
@@ -161087,8 +161186,9 @@ var AES = /** @class */ (function () {
|
|
|
161087
161186
|
};
|
|
161088
161187
|
AES.prototype.deriveKeyFromPrivateKey = function (privateKey) {
|
|
161089
161188
|
var _this = this;
|
|
161189
|
+
var password = hex_1.isHex(privateKey) ? Buffer.from(privateKey, 'hex') : privateKey;
|
|
161090
161190
|
return new Promise(function (resolve, reject) {
|
|
161091
|
-
crypto.pbkdf2(
|
|
161191
|
+
crypto.pbkdf2(password, '', _this.KEY_DERIVATION_ITERATION_COUNT, 32, 'sha512', function (pbkdf2Error, key) {
|
|
161092
161192
|
if (pbkdf2Error) {
|
|
161093
161193
|
reject(pbkdf2Error);
|
|
161094
161194
|
}
|
|
@@ -161101,7 +161201,7 @@ var AES = /** @class */ (function () {
|
|
|
161101
161201
|
exports.AES = AES;
|
|
161102
161202
|
|
|
161103
161203
|
}).call(this)}).call(this,require("buffer").Buffer)
|
|
161104
|
-
},{"../errors":491,"../errors/coinlib-error":490,"buffer":67,"crypto":78}],796:[function(require,module,exports){
|
|
161204
|
+
},{"../errors":491,"../errors/coinlib-error":490,"./hex":808,"buffer":67,"crypto":78}],796:[function(require,module,exports){
|
|
161105
161205
|
"use strict";
|
|
161106
161206
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
161107
161207
|
exports.isNetworkEqual = void 0;
|
|
@@ -161749,16 +161849,7 @@ var getProtocolByIdentifier = function (identifier, network) {
|
|
|
161749
161849
|
throw new errors_1.InvalidValueError(coinlib_error_1.Domain.UTILS, 'No protocol identifier provided');
|
|
161750
161850
|
}
|
|
161751
161851
|
var targetNetwork = network ? network : protocolOptionsByIdentifier_1.getProtocolOptionsByIdentifier(identifier).network;
|
|
161752
|
-
|
|
161753
|
-
var candidates = supportedProtocols_1.supportedProtocols()
|
|
161754
|
-
.map(function (protocol) {
|
|
161755
|
-
var protocols = [protocol];
|
|
161756
|
-
if (protocol.subProtocols) {
|
|
161757
|
-
protocols.push.apply(protocols, protocol.subProtocols);
|
|
161758
|
-
}
|
|
161759
|
-
return protocols;
|
|
161760
|
-
})
|
|
161761
|
-
.reduce(function (current, next) { return current.concat(next); }, []);
|
|
161852
|
+
var candidates = supportedProtocols_1.supportedProtocols();
|
|
161762
161853
|
// filter out potential candidates, those where our identifier startsWith the identifier of the protocol
|
|
161763
161854
|
var filteredCandidates = candidates.filter(function (protocol) { return identifier === protocol.identifier && Network_1.isNetworkEqual(protocol.options.network, targetNetwork); });
|
|
161764
161855
|
if (filteredCandidates.length === 0) {
|
|
@@ -163147,7 +163238,7 @@ var AirGapWallet = /** @class */ (function () {
|
|
|
163147
163238
|
case 3:
|
|
163148
163239
|
addresses = _a.sent();
|
|
163149
163240
|
_a.label = 4;
|
|
163150
|
-
case 4: return [2 /*return*/, addresses.map(function (address) { return address.
|
|
163241
|
+
case 4: return [2 /*return*/, addresses.map(function (address) { return address.address; })];
|
|
163151
163242
|
}
|
|
163152
163243
|
});
|
|
163153
163244
|
});
|