@airgap/bnb 0.13.45-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +7 -0
- package/index.d.ts +1 -0
- package/index.js +18 -0
- package/index.js.map +1 -0
- package/package.json +63 -0
- package/readme.md +121 -0
- package/v1/client/info/BnbinfoClient.d.ts +2 -0
- package/v1/client/info/BnbinfoClient.js +3 -0
- package/v1/client/info/BnbinfoClient.js.map +1 -0
- package/v1/client/node/BnbNodeClient.d.ts +3 -0
- package/v1/client/node/BnbNodeClient.js +3 -0
- package/v1/client/node/BnbNodeClient.js.map +1 -0
- package/v1/client/node/HttpBnbNodeClient.d.ts +5 -0
- package/v1/client/node/HttpBnbNodeClient.js +28 -0
- package/v1/client/node/HttpBnbNodeClient.js.map +1 -0
- package/v1/index.d.ts +11 -0
- package/v1/index.js +14 -0
- package/v1/index.js.map +1 -0
- package/v1/module/BnbModule.d.ts +18 -0
- package/v1/module/BnbModule.js +182 -0
- package/v1/module/BnbModule.js.map +1 -0
- package/v1/module/ERC20Tokens.d.ts +3 -0
- package/v1/module/ERC20Tokens.js +95 -0
- package/v1/module/ERC20Tokens.js.map +1 -0
- package/v1/module.d.ts +3 -0
- package/v1/module.js +24 -0
- package/v1/module.js.map +1 -0
- package/v1/protocol/BnbBaseProtocol.d.ts +58 -0
- package/v1/protocol/BnbBaseProtocol.js +265 -0
- package/v1/protocol/BnbBaseProtocol.js.map +1 -0
- package/v1/protocol/BnbProtocol.d.ts +8 -0
- package/v1/protocol/BnbProtocol.js +84 -0
- package/v1/protocol/BnbProtocol.js.map +1 -0
- package/v1/protocol/erc20/ERC20Token.d.ts +20 -0
- package/v1/protocol/erc20/ERC20Token.js +198 -0
- package/v1/protocol/erc20/ERC20Token.js.map +1 -0
- package/v1/serializer/v3/schemas/converter/transaction-converter.d.ts +8 -0
- package/v1/serializer/v3/schemas/converter/transaction-converter.js +21 -0
- package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-bnb-typed.d.ts +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-bnb-typed.js +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-bnb-typed.js.map +1 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-bnb.d.ts +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-bnb.js +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-bnb.js.map +1 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-bnb.d.ts +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-bnb.js +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-bnb.js.map +1 -0
- package/v1/serializer/v3/schemas/generated/transaction-sign-request-bnb-typed.json +39 -0
- package/v1/serializer/v3/schemas/generated/transaction-sign-request-bnb.json +56 -0
- package/v1/serializer/v3/schemas/generated/transaction-sign-response-bnb.json +19 -0
- package/v1/serializer/v3/serializer-companion.d.ts +13 -0
- package/v1/serializer/v3/serializer-companion.js +190 -0
- package/v1/serializer/v3/serializer-companion.js.map +1 -0
- package/v1/serializer/v3/validators/transaction-validator.d.ts +4 -0
- package/v1/serializer/v3/validators/transaction-validator.js +29 -0
- package/v1/serializer/v3/validators/transaction-validator.js.map +1 -0
- package/v1/types/crypto.d.ts +2 -0
- package/v1/types/crypto.js +3 -0
- package/v1/types/crypto.js.map +1 -0
- package/v1/types/protocol.d.ts +5 -0
- package/v1/types/protocol.js +3 -0
- package/v1/types/protocol.js.map +1 -0
- package/v1/types/transaction.d.ts +6 -0
- package/v1/types/transaction.js +3 -0
- package/v1/types/transaction.js.map +1 -0
- package/v1/utils/protocol.d.ts +10 -0
- package/v1/utils/protocol.js +33 -0
- package/v1/utils/protocol.js.map +1 -0
package/v1/module.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.create = void 0;
|
|
18
|
+
var BnbModule_1 = require("./module/BnbModule");
|
|
19
|
+
__exportStar(require("./index"), exports);
|
|
20
|
+
function create() {
|
|
21
|
+
return new BnbModule_1.BnbModule();
|
|
22
|
+
}
|
|
23
|
+
exports.create = create;
|
|
24
|
+
//# sourceMappingURL=module.js.map
|
package/v1/module.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/v1/module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,gDAA8C;AAE9C,0CAAuB;AAEvB,SAAgB,MAAM;IACpB,OAAO,IAAI,qBAAS,EAAE,CAAA;AACxB,CAAC;AAFD,wBAEC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { EthereumBaseProtocolImpl, EthereumUnits } from '@airgap/ethereum/v1';
|
|
2
|
+
import { Address, AirGapProtocol, AirGapTransaction, AirGapTransactionStatus, AirGapTransactionsWithCursor, Amount, Balance, CryptoDerivative, ExtendedKeyPair, ExtendedPublicKey, ExtendedSecretKey, FeeDefaults, KeyPair, ProtocolMetadata, ProtocolUnitsMetadata, PublicKey, SecretKey, Signature, TransactionFullConfiguration, TransactionDetails, WalletConnectRequest, TokenDetails } from '@airgap/module-kit';
|
|
3
|
+
import { BnbInfoClient } from '../client/info/BnbinfoClient';
|
|
4
|
+
import { BnbNodeClient } from '../client/node/BnbNodeClient';
|
|
5
|
+
import { BnbCryptoConfiguration } from '../types/crypto';
|
|
6
|
+
import { BnbProtocolNetwork, BnbProtocolOptions } from '../types/protocol';
|
|
7
|
+
import { BnbSignedTransaction, BnbTransactionCursor, BnbUnsignedTransaction } from '../types/transaction';
|
|
8
|
+
export interface BnbBaseProtocol<_Units extends string = EthereumUnits> extends AirGapProtocol<{
|
|
9
|
+
AddressResult: Address;
|
|
10
|
+
ProtocolNetwork: BnbProtocolNetwork;
|
|
11
|
+
CryptoConfiguration: BnbCryptoConfiguration;
|
|
12
|
+
Units: _Units;
|
|
13
|
+
FeeUnits: EthereumUnits;
|
|
14
|
+
FeeEstimation: FeeDefaults<EthereumUnits>;
|
|
15
|
+
SignedTransaction: BnbSignedTransaction;
|
|
16
|
+
UnsignedTransaction: BnbUnsignedTransaction;
|
|
17
|
+
TransactionCursor: BnbTransactionCursor;
|
|
18
|
+
}, 'Bip32', 'Crypto', 'FetchDataForAddress', 'FetchDataForMultipleAddresses', 'GetTokenBalances', 'TransactionStatusChecker', 'WalletConnect'> {
|
|
19
|
+
}
|
|
20
|
+
export declare abstract class BnbBaseProtocolImpl<_Units extends string = EthereumUnits, _EthereumProtocol extends EthereumBaseProtocolImpl<_Units, BnbProtocolNetwork> = EthereumBaseProtocolImpl<_Units, BnbProtocolNetwork>, _Options extends BnbProtocolOptions = BnbProtocolOptions> implements BnbBaseProtocol<_Units> {
|
|
21
|
+
protected readonly ethereumProtocol: _EthereumProtocol;
|
|
22
|
+
protected readonly nodeClient: BnbNodeClient;
|
|
23
|
+
protected readonly infoClient: BnbInfoClient;
|
|
24
|
+
protected readonly options: _Options;
|
|
25
|
+
protected constructor(ethereumProtocol: _EthereumProtocol, nodeClient: BnbNodeClient, infoClient: BnbInfoClient, options: _Options);
|
|
26
|
+
protected readonly units: ProtocolUnitsMetadata<_Units>;
|
|
27
|
+
protected readonly feeUnits: ProtocolUnitsMetadata<EthereumUnits>;
|
|
28
|
+
getMetadata(): Promise<ProtocolMetadata<_Units, EthereumUnits>>;
|
|
29
|
+
getAddressFromPublicKey(publicKey: PublicKey | ExtendedPublicKey): Promise<string>;
|
|
30
|
+
deriveFromExtendedPublicKey(extendedPublicKey: ExtendedPublicKey, visibilityIndex: number, addressIndex: number): Promise<PublicKey>;
|
|
31
|
+
getDetailsFromTransaction(transaction: BnbUnsignedTransaction | BnbSignedTransaction, publicKey: PublicKey | ExtendedPublicKey): Promise<AirGapTransaction<_Units, EthereumUnits>[]>;
|
|
32
|
+
verifyMessageWithPublicKey(message: string, signature: Signature, publicKey: PublicKey | ExtendedPublicKey): Promise<boolean>;
|
|
33
|
+
encryptAsymmetricWithPublicKey(payload: string, publicKey: PublicKey | ExtendedPublicKey): Promise<string>;
|
|
34
|
+
getCryptoConfiguration(): Promise<BnbCryptoConfiguration>;
|
|
35
|
+
getKeyPairFromDerivative(derivative: CryptoDerivative): Promise<KeyPair>;
|
|
36
|
+
getExtendedKeyPairFromDerivative(derivative: CryptoDerivative): Promise<ExtendedKeyPair>;
|
|
37
|
+
deriveFromExtendedSecretKey(extendedSecretKey: ExtendedSecretKey, visibilityIndex: number, addressIndex: number): Promise<SecretKey>;
|
|
38
|
+
signTransactionWithSecretKey(transaction: BnbUnsignedTransaction, secretKey: SecretKey | ExtendedSecretKey): Promise<BnbSignedTransaction>;
|
|
39
|
+
signMessageWithKeyPair(message: string, keyPair: KeyPair | ExtendedKeyPair): Promise<Signature>;
|
|
40
|
+
decryptAsymmetricWithKeyPair(payload: string, keyPair: KeyPair | ExtendedKeyPair): Promise<string>;
|
|
41
|
+
encryptAESWithSecretKey(payload: string, secretKey: SecretKey | ExtendedSecretKey): Promise<string>;
|
|
42
|
+
decryptAESWithSecretKey(payload: string, secretKey: SecretKey | ExtendedSecretKey): Promise<string>;
|
|
43
|
+
getNetwork(): Promise<BnbProtocolNetwork>;
|
|
44
|
+
getTransactionsForPublicKey(publicKey: PublicKey | ExtendedPublicKey, limit: number, cursor?: BnbTransactionCursor): Promise<AirGapTransactionsWithCursor<BnbTransactionCursor, _Units, EthereumUnits>>;
|
|
45
|
+
getTransactionsForAddress(address: string, limit: number, cursor?: BnbTransactionCursor): Promise<AirGapTransactionsWithCursor<BnbTransactionCursor, _Units, EthereumUnits>>;
|
|
46
|
+
getTransactionsForAddresses(addresses: string[], limit: number, cursor?: BnbTransactionCursor): Promise<AirGapTransactionsWithCursor<BnbTransactionCursor, _Units, EthereumUnits>>;
|
|
47
|
+
getTransactionStatus(transactionIds: string[]): Promise<Record<string, AirGapTransactionStatus>>;
|
|
48
|
+
getBalanceOfPublicKey(publicKey: PublicKey | ExtendedPublicKey): Promise<Balance<_Units>>;
|
|
49
|
+
getBalanceOfAddress(address: string): Promise<Balance<_Units>>;
|
|
50
|
+
getBalanceOfAddresses(addresses: string[]): Promise<Balance<_Units>>;
|
|
51
|
+
getTokenBalancesOfPublicKey(publicKey: PublicKey | ExtendedPublicKey, tokens: TokenDetails[]): Promise<Record<string, Amount>>;
|
|
52
|
+
getTransactionMaxAmountWithPublicKey(publicKey: PublicKey | ExtendedPublicKey, to: string[], configuration?: TransactionFullConfiguration<EthereumUnits>): Promise<Amount<_Units>>;
|
|
53
|
+
getTransactionFeeWithPublicKey(publicKey: PublicKey | ExtendedPublicKey, details: TransactionDetails<_Units>[]): Promise<FeeDefaults<EthereumUnits>>;
|
|
54
|
+
prepareTransactionWithPublicKey(publicKey: PublicKey | ExtendedPublicKey, details: TransactionDetails<_Units>[], configuration?: TransactionFullConfiguration<EthereumUnits>): Promise<BnbUnsignedTransaction>;
|
|
55
|
+
getWalletConnectChain(): Promise<string>;
|
|
56
|
+
prepareWalletConnectTransactionWithPublicKey(publicKey: PublicKey | ExtendedPublicKey, request: WalletConnectRequest): Promise<BnbUnsignedTransaction>;
|
|
57
|
+
broadcastTransaction(transaction: BnbSignedTransaction): Promise<string>;
|
|
58
|
+
}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.BnbBaseProtocolImpl = void 0;
|
|
40
|
+
// Implementation
|
|
41
|
+
var BnbBaseProtocolImpl = /** @class */ (function () {
|
|
42
|
+
function BnbBaseProtocolImpl(ethereumProtocol, nodeClient, infoClient, options) {
|
|
43
|
+
this.ethereumProtocol = ethereumProtocol;
|
|
44
|
+
this.nodeClient = nodeClient;
|
|
45
|
+
this.infoClient = infoClient;
|
|
46
|
+
this.options = options;
|
|
47
|
+
this.units = this.ethereumProtocol.units;
|
|
48
|
+
this.feeUnits = this.ethereumProtocol.feeUnits;
|
|
49
|
+
}
|
|
50
|
+
BnbBaseProtocolImpl.prototype.getMetadata = function () {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
52
|
+
return __generator(this, function (_a) {
|
|
53
|
+
return [2 /*return*/, this.ethereumProtocol.getMetadata()];
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
BnbBaseProtocolImpl.prototype.getAddressFromPublicKey = function (publicKey) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
59
|
+
return __generator(this, function (_a) {
|
|
60
|
+
return [2 /*return*/, this.ethereumProtocol.getAddressFromPublicKey(publicKey)];
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
BnbBaseProtocolImpl.prototype.deriveFromExtendedPublicKey = function (extendedPublicKey, visibilityIndex, addressIndex) {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
66
|
+
return __generator(this, function (_a) {
|
|
67
|
+
return [2 /*return*/, this.ethereumProtocol.deriveFromExtendedPublicKey(extendedPublicKey, visibilityIndex, addressIndex)];
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
BnbBaseProtocolImpl.prototype.getDetailsFromTransaction = function (transaction, publicKey) {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
73
|
+
return __generator(this, function (_a) {
|
|
74
|
+
return [2 /*return*/, this.ethereumProtocol.getDetailsFromTransaction(transaction, publicKey)];
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
BnbBaseProtocolImpl.prototype.verifyMessageWithPublicKey = function (message, signature, publicKey) {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
80
|
+
return __generator(this, function (_a) {
|
|
81
|
+
return [2 /*return*/, this.ethereumProtocol.verifyMessageWithPublicKey(message, signature, publicKey)];
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
BnbBaseProtocolImpl.prototype.encryptAsymmetricWithPublicKey = function (payload, publicKey) {
|
|
86
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
87
|
+
return __generator(this, function (_a) {
|
|
88
|
+
return [2 /*return*/, this.ethereumProtocol.encryptAsymmetricWithPublicKey(payload, publicKey)];
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
// Offline
|
|
93
|
+
BnbBaseProtocolImpl.prototype.getCryptoConfiguration = function () {
|
|
94
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
95
|
+
return __generator(this, function (_a) {
|
|
96
|
+
return [2 /*return*/, this.ethereumProtocol.getCryptoConfiguration()];
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
BnbBaseProtocolImpl.prototype.getKeyPairFromDerivative = function (derivative) {
|
|
101
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
102
|
+
return __generator(this, function (_a) {
|
|
103
|
+
return [2 /*return*/, this.ethereumProtocol.getKeyPairFromDerivative(derivative)];
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
BnbBaseProtocolImpl.prototype.getExtendedKeyPairFromDerivative = function (derivative) {
|
|
108
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
109
|
+
return __generator(this, function (_a) {
|
|
110
|
+
return [2 /*return*/, this.ethereumProtocol.getExtendedKeyPairFromDerivative(derivative)];
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
BnbBaseProtocolImpl.prototype.deriveFromExtendedSecretKey = function (extendedSecretKey, visibilityIndex, addressIndex) {
|
|
115
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
116
|
+
return __generator(this, function (_a) {
|
|
117
|
+
return [2 /*return*/, this.ethereumProtocol.deriveFromExtendedSecretKey(extendedSecretKey, visibilityIndex, addressIndex)];
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
BnbBaseProtocolImpl.prototype.signTransactionWithSecretKey = function (transaction, secretKey) {
|
|
122
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
123
|
+
return __generator(this, function (_a) {
|
|
124
|
+
return [2 /*return*/, this.ethereumProtocol.signTransactionWithSecretKey(transaction, secretKey)];
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
BnbBaseProtocolImpl.prototype.signMessageWithKeyPair = function (message, keyPair) {
|
|
129
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
130
|
+
return __generator(this, function (_a) {
|
|
131
|
+
return [2 /*return*/, this.ethereumProtocol.signMessageWithKeyPair(message, keyPair)];
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
BnbBaseProtocolImpl.prototype.decryptAsymmetricWithKeyPair = function (payload, keyPair) {
|
|
136
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
137
|
+
return __generator(this, function (_a) {
|
|
138
|
+
return [2 /*return*/, this.ethereumProtocol.decryptAsymmetricWithKeyPair(payload, keyPair)];
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
BnbBaseProtocolImpl.prototype.encryptAESWithSecretKey = function (payload, secretKey) {
|
|
143
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
144
|
+
return __generator(this, function (_a) {
|
|
145
|
+
return [2 /*return*/, this.ethereumProtocol.encryptAESWithSecretKey(payload, secretKey)];
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
BnbBaseProtocolImpl.prototype.decryptAESWithSecretKey = function (payload, secretKey) {
|
|
150
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
151
|
+
return __generator(this, function (_a) {
|
|
152
|
+
return [2 /*return*/, this.ethereumProtocol.decryptAESWithSecretKey(payload, secretKey)];
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
// Online
|
|
157
|
+
BnbBaseProtocolImpl.prototype.getNetwork = function () {
|
|
158
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
159
|
+
return __generator(this, function (_a) {
|
|
160
|
+
return [2 /*return*/, this.ethereumProtocol.getNetwork()];
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
BnbBaseProtocolImpl.prototype.getTransactionsForPublicKey = function (publicKey, limit, cursor) {
|
|
165
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
166
|
+
return __generator(this, function (_a) {
|
|
167
|
+
return [2 /*return*/, this.ethereumProtocol.getTransactionsForPublicKey(publicKey, limit, cursor)];
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
};
|
|
171
|
+
BnbBaseProtocolImpl.prototype.getTransactionsForAddress = function (address, limit, cursor) {
|
|
172
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
173
|
+
return __generator(this, function (_a) {
|
|
174
|
+
return [2 /*return*/, this.ethereumProtocol.getTransactionsForAddress(address, limit, cursor)];
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
BnbBaseProtocolImpl.prototype.getTransactionsForAddresses = function (addresses, limit, cursor) {
|
|
179
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
180
|
+
return __generator(this, function (_a) {
|
|
181
|
+
return [2 /*return*/, this.ethereumProtocol.getTransactionsForAddresses(addresses, limit, cursor)];
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
};
|
|
185
|
+
BnbBaseProtocolImpl.prototype.getTransactionStatus = function (transactionIds) {
|
|
186
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
187
|
+
return __generator(this, function (_a) {
|
|
188
|
+
return [2 /*return*/, this.ethereumProtocol.getTransactionStatus(transactionIds)];
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
};
|
|
192
|
+
BnbBaseProtocolImpl.prototype.getBalanceOfPublicKey = function (publicKey) {
|
|
193
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
194
|
+
return __generator(this, function (_a) {
|
|
195
|
+
return [2 /*return*/, this.ethereumProtocol.getBalanceOfPublicKey(publicKey)];
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
};
|
|
199
|
+
BnbBaseProtocolImpl.prototype.getBalanceOfAddress = function (address) {
|
|
200
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
201
|
+
return __generator(this, function (_a) {
|
|
202
|
+
return [2 /*return*/, this.ethereumProtocol.getBalanceOfAddress(address)];
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
};
|
|
206
|
+
BnbBaseProtocolImpl.prototype.getBalanceOfAddresses = function (addresses) {
|
|
207
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
208
|
+
return __generator(this, function (_a) {
|
|
209
|
+
return [2 /*return*/, this.ethereumProtocol.getBalanceOfAddresses(addresses)];
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
};
|
|
213
|
+
BnbBaseProtocolImpl.prototype.getTokenBalancesOfPublicKey = function (publicKey, tokens) {
|
|
214
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
215
|
+
return __generator(this, function (_a) {
|
|
216
|
+
return [2 /*return*/, this.ethereumProtocol.getTokenBalancesOfPublicKey(publicKey, tokens)];
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
};
|
|
220
|
+
BnbBaseProtocolImpl.prototype.getTransactionMaxAmountWithPublicKey = function (publicKey, to, configuration) {
|
|
221
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
222
|
+
return __generator(this, function (_a) {
|
|
223
|
+
return [2 /*return*/, this.ethereumProtocol.getTransactionMaxAmountWithPublicKey(publicKey, to, configuration)];
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
};
|
|
227
|
+
BnbBaseProtocolImpl.prototype.getTransactionFeeWithPublicKey = function (publicKey, details) {
|
|
228
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
229
|
+
return __generator(this, function (_a) {
|
|
230
|
+
return [2 /*return*/, this.ethereumProtocol.getTransactionFeeWithPublicKey(publicKey, details)];
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
};
|
|
234
|
+
BnbBaseProtocolImpl.prototype.prepareTransactionWithPublicKey = function (publicKey, details, configuration) {
|
|
235
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
236
|
+
return __generator(this, function (_a) {
|
|
237
|
+
return [2 /*return*/, this.ethereumProtocol.prepareTransactionWithPublicKey(publicKey, details, configuration)];
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
};
|
|
241
|
+
BnbBaseProtocolImpl.prototype.getWalletConnectChain = function () {
|
|
242
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
243
|
+
return __generator(this, function (_a) {
|
|
244
|
+
return [2 /*return*/, this.ethereumProtocol.getWalletConnectChain()];
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
};
|
|
248
|
+
BnbBaseProtocolImpl.prototype.prepareWalletConnectTransactionWithPublicKey = function (publicKey, request) {
|
|
249
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
250
|
+
return __generator(this, function (_a) {
|
|
251
|
+
return [2 /*return*/, this.ethereumProtocol.prepareWalletConnectTransactionWithPublicKey(publicKey, request)];
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
};
|
|
255
|
+
BnbBaseProtocolImpl.prototype.broadcastTransaction = function (transaction) {
|
|
256
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
257
|
+
return __generator(this, function (_a) {
|
|
258
|
+
return [2 /*return*/, this.ethereumProtocol.broadcastTransaction(transaction)];
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
};
|
|
262
|
+
return BnbBaseProtocolImpl;
|
|
263
|
+
}());
|
|
264
|
+
exports.BnbBaseProtocolImpl = BnbBaseProtocolImpl;
|
|
265
|
+
//# sourceMappingURL=BnbBaseProtocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BnbBaseProtocol.js","sourceRoot":"","sources":["../../../src/v1/protocol/BnbBaseProtocol.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDA,iBAAiB;AAEjB;IAKE,6BACqB,gBAAmC,EACnC,UAAyB,EACzB,UAAyB,EACzB,OAAiB;QAHjB,qBAAgB,GAAhB,gBAAgB,CAAmB;QACnC,eAAU,GAAV,UAAU,CAAe;QACzB,eAAU,GAAV,UAAU,CA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SAAwC,EACxC,OAAqC;;;gBAErC,sBAAO,IAAI,CAAC,gBAAgB,CAAC,8BAA8B,CAAC,SAAS,EAAE,OAAO,CAAC,EAAA;;;KAChF;IAEY,6DAA+B,GAA5C,UACE,SAAwC,EACxC,OAAqC,EACrC,aAA2D;;;gBAE3D,sBAAO,IAAI,CAAC,gBAAgB,CAAC,+BAA+B,CAAC,SAAS,EAAE,OAAO,EAAE,aAAa,CAAC,EAAA;;;KAChG;IAEY,mDAAqB,GAAlC;;;gBACE,sBAAO,IAAI,CAAC,gBAAgB,CAAC,qBAAqB,EAAE,EAAA;;;KACrD;IAEY,0EAA4C,GAAzD,UACE,SAAwC,EACxC,OAA6B;;;gBAE7B,sBAAO,IAAI,CAAC,gBAAgB,CAAC,4CAA4C,CAAC,SAAS,EAAE,OAAO,CAAC,EAAA;;;KAC9F;IAEY,kDAAoB,GAAjC,UAAkC,WAAiC;;;gBACjE,sBAAO,IAAI,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,WAAW,CAAC,EAAA;;;KAC/D;IACH,0BAAC;AAAD,CAAC,AA9LD,IA8LC;AA9LqB,kDAAmB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RecursivePartial } from '@airgap/module-kit';
|
|
2
|
+
import { BnbProtocolNetwork, BnbProtocolOptions } from '../types/protocol';
|
|
3
|
+
import { BnbBaseProtocol } from './BnbBaseProtocol';
|
|
4
|
+
export interface BnbProtocol extends BnbBaseProtocol {
|
|
5
|
+
}
|
|
6
|
+
export declare function createBnbProtocol(options?: RecursivePartial<BnbProtocolOptions>): BnbProtocol;
|
|
7
|
+
export declare const BNB_MAINNET_PROTOCOL_NETWORK: BnbProtocolNetwork;
|
|
8
|
+
export declare function createBnbProtocolOptions(network?: Partial<BnbProtocolNetwork>): BnbProtocolOptions;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.createBnbProtocolOptions = exports.BNB_MAINNET_PROTOCOL_NETWORK = exports.createBnbProtocol = void 0;
|
|
30
|
+
var coinlib_core_1 = require("@airgap/coinlib-core");
|
|
31
|
+
var v1_1 = require("@airgap/ethereum/v1");
|
|
32
|
+
var module_kit_1 = require("@airgap/module-kit");
|
|
33
|
+
var HttpBnbNodeClient_1 = require("../client/node/HttpBnbNodeClient");
|
|
34
|
+
var BnbBaseProtocol_1 = require("./BnbBaseProtocol");
|
|
35
|
+
// Implementation
|
|
36
|
+
var BnbProtocolImpl = /** @class */ (function (_super) {
|
|
37
|
+
__extends(BnbProtocolImpl, _super);
|
|
38
|
+
function BnbProtocolImpl(options) {
|
|
39
|
+
var completeOptions = createBnbProtocolOptions(options.network);
|
|
40
|
+
var nodeClient = new HttpBnbNodeClient_1.HttpBnbNodeClient(completeOptions.network.rpcUrl);
|
|
41
|
+
var infoClient = new v1_1.EtherscanInfoClient(completeOptions.network.blockExplorerApi);
|
|
42
|
+
var baseProtocolOptions = {
|
|
43
|
+
network: completeOptions.network,
|
|
44
|
+
identifier: coinlib_core_1.MainProtocolSymbols.BNB,
|
|
45
|
+
name: 'BNB Smart Chain',
|
|
46
|
+
units: __assign(__assign({}, v1_1.DEFAULT_ETHEREUM_UNITS_METADATA), { ETH: {
|
|
47
|
+
symbol: __assign(__assign({}, v1_1.DEFAULT_ETHEREUM_UNITS_METADATA.ETH.symbol), { asset: 'BNB' }),
|
|
48
|
+
decimals: v1_1.DEFAULT_ETHEREUM_UNITS_METADATA.ETH.decimals
|
|
49
|
+
} }),
|
|
50
|
+
mainUnit: 'ETH',
|
|
51
|
+
feeDefaults: {
|
|
52
|
+
low: (0, module_kit_1.newAmount)(63000 /* 21000 GAS * 3 GWEI */, 'GWEI').blockchain(v1_1.DEFAULT_ETHEREUM_UNITS_METADATA),
|
|
53
|
+
medium: (0, module_kit_1.newAmount)(105000 /* 21000 GAS * 5 GWEI */, 'GWEI').blockchain(v1_1.DEFAULT_ETHEREUM_UNITS_METADATA),
|
|
54
|
+
high: (0, module_kit_1.newAmount)(210000 /* 21000 GAS * 10 GWEI */, 'GWEI').blockchain(v1_1.DEFAULT_ETHEREUM_UNITS_METADATA)
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
var ethereumProtocol = new v1_1.EthereumBaseProtocolImpl(nodeClient, infoClient, baseProtocolOptions);
|
|
58
|
+
return _super.call(this, ethereumProtocol, nodeClient, infoClient, completeOptions) || this;
|
|
59
|
+
}
|
|
60
|
+
return BnbProtocolImpl;
|
|
61
|
+
}(BnbBaseProtocol_1.BnbBaseProtocolImpl));
|
|
62
|
+
// Factory
|
|
63
|
+
function createBnbProtocol(options) {
|
|
64
|
+
if (options === void 0) { options = {}; }
|
|
65
|
+
return new BnbProtocolImpl(options);
|
|
66
|
+
}
|
|
67
|
+
exports.createBnbProtocol = createBnbProtocol;
|
|
68
|
+
exports.BNB_MAINNET_PROTOCOL_NETWORK = {
|
|
69
|
+
name: 'Mainnet',
|
|
70
|
+
type: 'mainnet',
|
|
71
|
+
rpcUrl: 'https://bsc-dataseed.binance.org',
|
|
72
|
+
chainId: 56,
|
|
73
|
+
blockExplorerUrl: 'https://bscscan.com',
|
|
74
|
+
blockExplorerApi: 'https://api.bscscan.com/api'
|
|
75
|
+
};
|
|
76
|
+
var DEFAULT_BNB_PROTOCOL_NETWORK = exports.BNB_MAINNET_PROTOCOL_NETWORK;
|
|
77
|
+
function createBnbProtocolOptions(network) {
|
|
78
|
+
if (network === void 0) { network = {}; }
|
|
79
|
+
return {
|
|
80
|
+
network: __assign(__assign({}, DEFAULT_BNB_PROTOCOL_NETWORK), network)
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
exports.createBnbProtocolOptions = createBnbProtocolOptions;
|
|
84
|
+
//# sourceMappingURL=BnbProtocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BnbProtocol.js","sourceRoot":"","sources":["../../../src/v1/protocol/BnbProtocol.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAA0D;AAC1D,0CAM4B;AAC5B,iDAAgE;AAEhE,sEAAoE;AAGpE,qDAAwE;AAMxE,iBAAiB;AAEjB;IAA8B,mCAAmB;IAC/C,yBAAY,OAA6C;QACvD,IAAM,eAAe,GAAG,wBAAwB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAEjE,IAAM,UAAU,GAAG,IAAI,qCAAiB,CAAC,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QACxE,IAAM,UAAU,GAAG,IAAI,wBAAmB,CAAC,eAAe,CAAC,OAAO,CAAC,gBAAgB,CAAC,C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AAqB;IACvC,gBAAgB,EAAE,6BAA6B;CAChD,CAAA;AAED,IAAM,4BAA4B,GAAuB,oCAA4B,CAAA;AAErF,SAAgB,wBAAwB,CAAC,OAAyC;IAAzC,wBAAA,EAAA,YAAyC;IAChF,OAAO;QACL,OAAO,wBAAO,4BAA4B,GAAK,OAAO,CAAE;KACzD,CAAA;AACH,CAAC;AAJD,4DAIC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ERC20TokenMetadata, ERC20TokenOptions, EthereumProtocolNetwork } from '@airgap/ethereum/v1';
|
|
2
|
+
import { AirGapInterface, RecursivePartial } from '@airgap/module-kit';
|
|
3
|
+
import { BnbProtocolNetwork, BnbProtocolOptions } from '../../types/protocol';
|
|
4
|
+
import { BnbBaseProtocol } from '../BnbBaseProtocol';
|
|
5
|
+
export interface ERC20Token extends AirGapInterface<BnbBaseProtocol<string>, 'SingleTokenSubProtocol'> {
|
|
6
|
+
name(): Promise<string | undefined>;
|
|
7
|
+
symbol(): Promise<string | undefined>;
|
|
8
|
+
decimals(): Promise<number | undefined>;
|
|
9
|
+
tokenMetadata(): Promise<ERC20TokenMetadata>;
|
|
10
|
+
}
|
|
11
|
+
export declare function createERC20Token(metadata: ERC20TokenMetadata, options?: RecursivePartial<BnbProtocolOptions>): ERC20Token;
|
|
12
|
+
export declare const BNB_ERC20_MAINNET_PROTOCOL_NETWORK: BnbProtocolNetwork;
|
|
13
|
+
export declare function createERC20TokenOptions(metadata: ERC20TokenMetadata, network?: Partial<EthereumProtocolNetwork>): ERC20TokenOptions<BnbProtocolNetwork>;
|
|
14
|
+
export interface SerializedERC20Token {
|
|
15
|
+
metadata: ERC20TokenMetadata;
|
|
16
|
+
network: BnbProtocolNetwork;
|
|
17
|
+
}
|
|
18
|
+
export declare function serializeERC20Token(erc20Token: ERC20Token): Promise<SerializedERC20Token>;
|
|
19
|
+
export declare function deserializeERC20Token(serialized: SerializedERC20Token): ERC20Token;
|
|
20
|
+
export declare function isSerializedERC20Token(serialized: unknown): serialized is SerializedERC20Token;
|