@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
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Factory
|
|
3
|
+
var __extends = (this && this.__extends) || (function () {
|
|
4
|
+
var extendStatics = function (d, b) {
|
|
5
|
+
extendStatics = Object.setPrototypeOf ||
|
|
6
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
7
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
8
|
+
return extendStatics(d, b);
|
|
9
|
+
};
|
|
10
|
+
return function (d, b) {
|
|
11
|
+
if (typeof b !== "function" && b !== null)
|
|
12
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
13
|
+
extendStatics(d, b);
|
|
14
|
+
function __() { this.constructor = d; }
|
|
15
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
16
|
+
};
|
|
17
|
+
})();
|
|
18
|
+
var __assign = (this && this.__assign) || function () {
|
|
19
|
+
__assign = Object.assign || function(t) {
|
|
20
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
21
|
+
s = arguments[i];
|
|
22
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
23
|
+
t[p] = s[p];
|
|
24
|
+
}
|
|
25
|
+
return t;
|
|
26
|
+
};
|
|
27
|
+
return __assign.apply(this, arguments);
|
|
28
|
+
};
|
|
29
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
30
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
31
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
32
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
33
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
34
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
35
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
39
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
40
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
41
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
42
|
+
function step(op) {
|
|
43
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
44
|
+
while (_) try {
|
|
45
|
+
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;
|
|
46
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
47
|
+
switch (op[0]) {
|
|
48
|
+
case 0: case 1: t = op; break;
|
|
49
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
50
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
51
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
52
|
+
default:
|
|
53
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
54
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
55
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
56
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
57
|
+
if (t[2]) _.ops.pop();
|
|
58
|
+
_.trys.pop(); continue;
|
|
59
|
+
}
|
|
60
|
+
op = body.call(thisArg, _);
|
|
61
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
62
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
66
|
+
exports.isSerializedERC20Token = exports.deserializeERC20Token = exports.serializeERC20Token = exports.createERC20TokenOptions = exports.BNB_ERC20_MAINNET_PROTOCOL_NETWORK = exports.createERC20Token = void 0;
|
|
67
|
+
var coinlib_core_1 = require("@airgap/coinlib-core");
|
|
68
|
+
var v1_1 = require("@airgap/ethereum/v1");
|
|
69
|
+
var module_kit_1 = require("@airgap/module-kit");
|
|
70
|
+
var HttpBnbNodeClient_1 = require("../../client/node/HttpBnbNodeClient");
|
|
71
|
+
var BnbBaseProtocol_1 = require("../BnbBaseProtocol");
|
|
72
|
+
var BnbProtocol_1 = require("../BnbProtocol");
|
|
73
|
+
// Implementation
|
|
74
|
+
var ERC20TokenImpl = /** @class */ (function (_super) {
|
|
75
|
+
__extends(ERC20TokenImpl, _super);
|
|
76
|
+
function ERC20TokenImpl(options) {
|
|
77
|
+
var nodeClient = new HttpBnbNodeClient_1.HttpBnbNodeClient(options.network.rpcUrl);
|
|
78
|
+
var infoClient = new v1_1.EtherscanInfoClient(options.network.blockExplorerApi);
|
|
79
|
+
var ethereumProtocol = new v1_1.ERC20TokenImpl(nodeClient, infoClient, options);
|
|
80
|
+
return _super.call(this, ethereumProtocol, nodeClient, infoClient, options) || this;
|
|
81
|
+
}
|
|
82
|
+
// SubProtocol
|
|
83
|
+
ERC20TokenImpl.prototype.getType = function () {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
85
|
+
return __generator(this, function (_a) {
|
|
86
|
+
return [2 /*return*/, this.ethereumProtocol.getType()];
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
ERC20TokenImpl.prototype.mainProtocol = function () {
|
|
91
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
92
|
+
return __generator(this, function (_a) {
|
|
93
|
+
return [2 /*return*/, this.ethereumProtocol.mainProtocol()];
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
ERC20TokenImpl.prototype.getContractAddress = function () {
|
|
98
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
99
|
+
return __generator(this, function (_a) {
|
|
100
|
+
return [2 /*return*/, this.ethereumProtocol.getContractAddress()];
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
// Custom
|
|
105
|
+
ERC20TokenImpl.prototype.name = function () {
|
|
106
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
107
|
+
return __generator(this, function (_a) {
|
|
108
|
+
return [2 /*return*/, this.ethereumProtocol.name()];
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
ERC20TokenImpl.prototype.symbol = function () {
|
|
113
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
114
|
+
return __generator(this, function (_a) {
|
|
115
|
+
return [2 /*return*/, this.ethereumProtocol.symbol()];
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
ERC20TokenImpl.prototype.decimals = function () {
|
|
120
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
121
|
+
return __generator(this, function (_a) {
|
|
122
|
+
return [2 /*return*/, this.ethereumProtocol.decimals()];
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
ERC20TokenImpl.prototype.tokenMetadata = function () {
|
|
127
|
+
var _a;
|
|
128
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
129
|
+
var mainUnit;
|
|
130
|
+
return __generator(this, function (_b) {
|
|
131
|
+
mainUnit = this.options.units[this.options.mainUnit];
|
|
132
|
+
return [2 /*return*/, {
|
|
133
|
+
name: this.options.name,
|
|
134
|
+
identifier: this.options.identifier,
|
|
135
|
+
symbol: mainUnit.symbol.value,
|
|
136
|
+
marketSymbol: (_a = mainUnit.symbol.market) !== null && _a !== void 0 ? _a : mainUnit.symbol.value,
|
|
137
|
+
contractAddress: this.options.contractAddress,
|
|
138
|
+
decimals: mainUnit.decimals
|
|
139
|
+
}];
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
return ERC20TokenImpl;
|
|
144
|
+
}(BnbBaseProtocol_1.BnbBaseProtocolImpl));
|
|
145
|
+
// Factory
|
|
146
|
+
function createERC20Token(metadata, options) {
|
|
147
|
+
if (options === void 0) { options = {}; }
|
|
148
|
+
var completeOptions = createERC20TokenOptions(metadata, options.network);
|
|
149
|
+
return new ERC20TokenImpl(completeOptions);
|
|
150
|
+
}
|
|
151
|
+
exports.createERC20Token = createERC20Token;
|
|
152
|
+
exports.BNB_ERC20_MAINNET_PROTOCOL_NETWORK = BnbProtocol_1.BNB_MAINNET_PROTOCOL_NETWORK;
|
|
153
|
+
var DEFAULT_ERC20_PROTOCOL_NETWORK = exports.BNB_ERC20_MAINNET_PROTOCOL_NETWORK;
|
|
154
|
+
function createERC20TokenOptions(metadata, network) {
|
|
155
|
+
var _a;
|
|
156
|
+
if (network === void 0) { network = {}; }
|
|
157
|
+
return {
|
|
158
|
+
network: __assign(__assign({}, DEFAULT_ERC20_PROTOCOL_NETWORK), network),
|
|
159
|
+
name: metadata.name,
|
|
160
|
+
identifier: metadata.identifier,
|
|
161
|
+
mainIdentifier: coinlib_core_1.MainProtocolSymbols.BNB,
|
|
162
|
+
contractAddress: metadata.contractAddress,
|
|
163
|
+
units: (_a = {},
|
|
164
|
+
_a[metadata.symbol] = {
|
|
165
|
+
symbol: { value: metadata.symbol, market: metadata.marketSymbol },
|
|
166
|
+
decimals: metadata.decimals
|
|
167
|
+
},
|
|
168
|
+
_a),
|
|
169
|
+
mainUnit: metadata.symbol
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
exports.createERC20TokenOptions = createERC20TokenOptions;
|
|
173
|
+
function serializeERC20Token(erc20Token) {
|
|
174
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
175
|
+
var _a, tokenMetadata, network;
|
|
176
|
+
return __generator(this, function (_b) {
|
|
177
|
+
switch (_b.label) {
|
|
178
|
+
case 0: return [4 /*yield*/, Promise.all([
|
|
179
|
+
erc20Token.tokenMetadata(),
|
|
180
|
+
erc20Token.getNetwork()
|
|
181
|
+
])];
|
|
182
|
+
case 1:
|
|
183
|
+
_a = _b.sent(), tokenMetadata = _a[0], network = _a[1];
|
|
184
|
+
return [2 /*return*/, { metadata: tokenMetadata, network: network }];
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
exports.serializeERC20Token = serializeERC20Token;
|
|
190
|
+
function deserializeERC20Token(serialized) {
|
|
191
|
+
return createERC20Token(serialized.metadata, { network: serialized.network });
|
|
192
|
+
}
|
|
193
|
+
exports.deserializeERC20Token = deserializeERC20Token;
|
|
194
|
+
function isSerializedERC20Token(serialized) {
|
|
195
|
+
return (0, module_kit_1.implementsInterface)(serialized, { metadata: 'required', network: 'required' });
|
|
196
|
+
}
|
|
197
|
+
exports.isSerializedERC20Token = isSerializedERC20Token;
|
|
198
|
+
//# sourceMappingURL=ERC20Token.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ERC20Token.js","sourceRoot":"","sources":["../../../../src/v1/protocol/erc20/ERC20Token.ts"],"names":[],"mappings":";AAAA,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEV,qDAA0D;AAC1D,0CAM4B;AAC5B,iDAA2F;AAE3F,yEAAuE;AAEvE,sDAAyE;AACzE,8CAA6D;AAY7D,iBAAiB;AAEjB;IACU,kCAA8G;IAGtH,wBAAY,OAA8C;QACxD,IAAM,UAAU,GAAG,IAAI,qCAAiB,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QAChE,IAAM,UAAU,GAAG,IAAI,wBAAmB,CAAC,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAA;QAE5E,IAAM,gBAAgB,GAAG,IAAI,mBAAsB,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,CAA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CAAC,UAAU,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,CAAA;AAC/E,CAAC;AAFD,sDAEC;AAED,SAAgB,sBAAsB,CAAC,UAAmB;IACxD,OAAO,IAAA,gCAAmB,EAAuB,UAAU,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAA;AAC7G,CAAC;AAFD,wDAEC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BnbSignedTransaction, BnbUnsignedTransaction } from '../../../../types/transaction';
|
|
2
|
+
import { BnbTransactionSignRequest } from '../definitions/transaction-sign-request-bnb';
|
|
3
|
+
import { BnbTypedTransactionSignRequest } from '../definitions/transaction-sign-request-bnb-typed';
|
|
4
|
+
import { BnbTransactionSignResponse } from '../definitions/transaction-sign-response-bnb';
|
|
5
|
+
export declare function bnbUnsignedTransactionToRequest(unsigned: BnbUnsignedTransaction, publicKey: string, callbackUrl?: string): BnbTransactionSignRequest | BnbTypedTransactionSignRequest;
|
|
6
|
+
export declare function bnbSignedTransactionToResponse(signed: BnbSignedTransaction, accountIdentifier: string): BnbTransactionSignResponse;
|
|
7
|
+
export declare function bnbTransactionSignRequestToUnsigned(request: BnbTransactionSignRequest | BnbTypedTransactionSignRequest): BnbUnsignedTransaction;
|
|
8
|
+
export declare function bnbTransactionSignResponseToSigned(response: BnbTransactionSignResponse): BnbSignedTransaction;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bnbTransactionSignResponseToSigned = exports.bnbTransactionSignRequestToUnsigned = exports.bnbSignedTransactionToResponse = exports.bnbUnsignedTransactionToRequest = void 0;
|
|
4
|
+
var v1_1 = require("@airgap/ethereum/v1");
|
|
5
|
+
function bnbUnsignedTransactionToRequest(unsigned, publicKey, callbackUrl) {
|
|
6
|
+
return (0, v1_1.ethereumUnsignedTransactionToRequest)(unsigned, publicKey, callbackUrl);
|
|
7
|
+
}
|
|
8
|
+
exports.bnbUnsignedTransactionToRequest = bnbUnsignedTransactionToRequest;
|
|
9
|
+
function bnbSignedTransactionToResponse(signed, accountIdentifier) {
|
|
10
|
+
return (0, v1_1.ethereumSignedTransactionToResponse)(signed, accountIdentifier);
|
|
11
|
+
}
|
|
12
|
+
exports.bnbSignedTransactionToResponse = bnbSignedTransactionToResponse;
|
|
13
|
+
function bnbTransactionSignRequestToUnsigned(request) {
|
|
14
|
+
return (0, v1_1.ethereumTransactionSignRequestToUnsigned)(request);
|
|
15
|
+
}
|
|
16
|
+
exports.bnbTransactionSignRequestToUnsigned = bnbTransactionSignRequestToUnsigned;
|
|
17
|
+
function bnbTransactionSignResponseToSigned(response) {
|
|
18
|
+
return (0, v1_1.ethereumTransactionSignResponseToSigned)(response);
|
|
19
|
+
}
|
|
20
|
+
exports.bnbTransactionSignResponseToSigned = bnbTransactionSignResponseToSigned;
|
|
21
|
+
//# sourceMappingURL=transaction-converter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction-converter.js","sourceRoot":"","sources":["../../../../../../src/v1/serializer/v3/schemas/converter/transaction-converter.ts"],"names":[],"mappings":";;;AAAA,0CAK4B;AAO5B,SAAgB,+BAA+B,CAC7C,QAAgC,EAChC,SAAiB,EACjB,WAAoB;IAEpB,OAAO,IAAA,yCAAoC,EAAC,QAAQ,EAAE,SAAS,EAAE,WAAW,CAAC,CAAA;AAC/E,CAAC;AAND,0EAMC;AAED,SAAgB,8BAA8B,CAAC,MAA4B,EAAE,iBAAyB;IACpG,OAAO,IAAA,wCAAmC,EAAC,MAAM,EAAE,iBAAiB,CAAC,CAAA;AACvE,CAAC;AAFD,wEAEC;AAED,SAAgB,mCAAmC,CACjD,OAAmE;IAEnE,OAAO,IAAA,6CAAwC,EAAC,OAAO,CAAC,CAAA;AAC1D,CAAC;AAJD,kFAIC;AAED,SAAgB,kCAAkC,CAAC,QAAoC;IACrF,OAAO,IAAA,4CAAuC,EAAC,QAAQ,CAAC,CAAA;AAC1D,CAAC;AAFD,gFAEC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction-sign-request-bnb-typed.js","sourceRoot":"","sources":["../../../../../../src/v1/serializer/v3/schemas/definitions/transaction-sign-request-bnb-typed.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction-sign-request-bnb.js","sourceRoot":"","sources":["../../../../../../src/v1/serializer/v3/schemas/definitions/transaction-sign-request-bnb.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction-sign-response-bnb.js","sourceRoot":"","sources":["../../../../../../src/v1/serializer/v3/schemas/definitions/transaction-sign-response-bnb.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$ref": "#/definitions/BnbTypedTransactionSignRequest",
|
|
3
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
|
+
"definitions": {
|
|
5
|
+
"HexString": {
|
|
6
|
+
"type": "string"
|
|
7
|
+
},
|
|
8
|
+
"BnbTypedTransactionSignRequest": {
|
|
9
|
+
"additionalProperties": false,
|
|
10
|
+
"properties": {
|
|
11
|
+
"callbackURL": {
|
|
12
|
+
"type": "string"
|
|
13
|
+
},
|
|
14
|
+
"publicKey": {
|
|
15
|
+
"type": "string"
|
|
16
|
+
},
|
|
17
|
+
"transaction": {
|
|
18
|
+
"additionalProperties": false,
|
|
19
|
+
"properties": {
|
|
20
|
+
"derivationPath": {
|
|
21
|
+
"type": "string"
|
|
22
|
+
},
|
|
23
|
+
"masterFingerprint": {
|
|
24
|
+
"type": "string"
|
|
25
|
+
},
|
|
26
|
+
"serialized": {
|
|
27
|
+
"$ref": "#/definitions/HexString",
|
|
28
|
+
"type": "string"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"required": ["derivationPath", "masterFingerprint", "serialized"],
|
|
32
|
+
"type": "object"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"required": ["publicKey", "transaction"],
|
|
36
|
+
"type": "object"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$ref": "#/definitions/BnbTransactionSignRequest",
|
|
3
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
|
+
"definitions": {
|
|
5
|
+
"HexString": {
|
|
6
|
+
"type": "string"
|
|
7
|
+
},
|
|
8
|
+
"BnbTransactionSignRequest": {
|
|
9
|
+
"additionalProperties": false,
|
|
10
|
+
"properties": {
|
|
11
|
+
"callbackURL": {
|
|
12
|
+
"type": "string"
|
|
13
|
+
},
|
|
14
|
+
"publicKey": {
|
|
15
|
+
"type": "string"
|
|
16
|
+
},
|
|
17
|
+
"transaction": {
|
|
18
|
+
"additionalProperties": false,
|
|
19
|
+
"properties": {
|
|
20
|
+
"chainId": {
|
|
21
|
+
"type": "number"
|
|
22
|
+
},
|
|
23
|
+
"data": {
|
|
24
|
+
"$ref": "#/definitions/HexString",
|
|
25
|
+
"type": "string"
|
|
26
|
+
},
|
|
27
|
+
"gasLimit": {
|
|
28
|
+
"$ref": "#/definitions/HexString",
|
|
29
|
+
"type": "string"
|
|
30
|
+
},
|
|
31
|
+
"gasPrice": {
|
|
32
|
+
"$ref": "#/definitions/HexString",
|
|
33
|
+
"type": "string"
|
|
34
|
+
},
|
|
35
|
+
"nonce": {
|
|
36
|
+
"$ref": "#/definitions/HexString",
|
|
37
|
+
"type": "string"
|
|
38
|
+
},
|
|
39
|
+
"to": {
|
|
40
|
+
"$ref": "#/definitions/HexString",
|
|
41
|
+
"type": "string"
|
|
42
|
+
},
|
|
43
|
+
"value": {
|
|
44
|
+
"$ref": "#/definitions/HexString",
|
|
45
|
+
"type": "string"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"required": ["chainId", "data", "gasLimit", "gasPrice", "nonce", "to", "value"],
|
|
49
|
+
"type": "object"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"required": ["publicKey", "transaction"],
|
|
53
|
+
"type": "object"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$ref": "#/definitions/BnbTransactionSignResponse",
|
|
3
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
|
+
"definitions": {
|
|
5
|
+
"BnbTransactionSignResponse": {
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"properties": {
|
|
8
|
+
"accountIdentifier": {
|
|
9
|
+
"type": "string"
|
|
10
|
+
},
|
|
11
|
+
"transaction": {
|
|
12
|
+
"type": "string"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"required": ["accountIdentifier", "transaction"],
|
|
16
|
+
"type": "object"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AirGapV3SerializerCompanion, SignedTransaction, UnsignedTransaction } from '@airgap/module-kit';
|
|
2
|
+
import { V3SchemaConfiguration } from '@airgap/module-kit/types/serializer';
|
|
3
|
+
import { TransactionSignRequest, TransactionSignResponse } from '@airgap/serializer';
|
|
4
|
+
export declare class BnbV3SerializerCompanion implements AirGapV3SerializerCompanion {
|
|
5
|
+
readonly schemas: V3SchemaConfiguration[];
|
|
6
|
+
private readonly ethereumTransactionValidator;
|
|
7
|
+
toTransactionSignRequest(identifier: string, unsignedTransaction: UnsignedTransaction, publicKey: string, callbackUrl?: string): Promise<TransactionSignRequest>;
|
|
8
|
+
fromTransactionSignRequest(identifier: string, transactionSignRequest: TransactionSignRequest): Promise<UnsignedTransaction>;
|
|
9
|
+
validateTransactionSignRequest(identifier: string, transactionSignRequest: TransactionSignRequest): Promise<boolean>;
|
|
10
|
+
toTransactionSignResponse(identifier: string, signedTransaction: SignedTransaction, accountIdentifier: string): Promise<TransactionSignResponse>;
|
|
11
|
+
fromTransactionSignResponse(identifier: string, transactionSignResponse: TransactionSignResponse): Promise<SignedTransaction>;
|
|
12
|
+
validateTransactionSignResponse(identifier: string, transactionSignResponse: TransactionSignResponse): Promise<boolean>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,190 @@
|
|
|
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.BnbV3SerializerCompanion = void 0;
|
|
40
|
+
var coinlib_core_1 = require("@airgap/coinlib-core");
|
|
41
|
+
var errors_1 = require("@airgap/coinlib-core/errors");
|
|
42
|
+
var serializer_1 = require("@airgap/serializer");
|
|
43
|
+
var transaction_converter_1 = require("./schemas/converter/transaction-converter");
|
|
44
|
+
var transaction_validator_1 = require("./validators/transaction-validator");
|
|
45
|
+
var ethereumTransactionSignRequest = require('./schemas/generated/transaction-sign-request-bnb.json');
|
|
46
|
+
var ethereumTypedTransactionSignRequest = require('./schemas/generated/transaction-sign-request-bnb-typed.json');
|
|
47
|
+
var ethereumTransactionSignResponse = require('./schemas/generated/transaction-sign-response-bnb.json');
|
|
48
|
+
var BnbV3SerializerCompanion = /** @class */ (function () {
|
|
49
|
+
function BnbV3SerializerCompanion() {
|
|
50
|
+
this.schemas = [
|
|
51
|
+
{
|
|
52
|
+
type: serializer_1.IACMessageType.TransactionSignRequest,
|
|
53
|
+
schema: { schema: ethereumTransactionSignRequest },
|
|
54
|
+
protocolIdentifier: coinlib_core_1.MainProtocolSymbols.BNB
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
type: serializer_1.IACMessageType.TransactionSignRequest,
|
|
58
|
+
schema: { schema: ethereumTypedTransactionSignRequest },
|
|
59
|
+
protocolIdentifier: coinlib_core_1.MainProtocolSymbols.BNB
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
type: serializer_1.IACMessageType.TransactionSignResponse,
|
|
63
|
+
schema: { schema: ethereumTransactionSignResponse },
|
|
64
|
+
protocolIdentifier: coinlib_core_1.MainProtocolSymbols.BNB
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
type: serializer_1.IACMessageType.TransactionSignRequest,
|
|
68
|
+
schema: { schema: ethereumTransactionSignRequest },
|
|
69
|
+
protocolIdentifier: coinlib_core_1.SubProtocolSymbols.BNB_ERC20
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
type: serializer_1.IACMessageType.TransactionSignResponse,
|
|
73
|
+
schema: { schema: ethereumTransactionSignResponse },
|
|
74
|
+
protocolIdentifier: coinlib_core_1.SubProtocolSymbols.BNB_ERC20
|
|
75
|
+
}
|
|
76
|
+
];
|
|
77
|
+
this.ethereumTransactionValidator = new transaction_validator_1.BnbTransactionValidator();
|
|
78
|
+
}
|
|
79
|
+
BnbV3SerializerCompanion.prototype.toTransactionSignRequest = function (identifier, unsignedTransaction, publicKey, callbackUrl) {
|
|
80
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
81
|
+
return __generator(this, function (_a) {
|
|
82
|
+
switch (identifier) {
|
|
83
|
+
case coinlib_core_1.MainProtocolSymbols.BNB:
|
|
84
|
+
case coinlib_core_1.SubProtocolSymbols.BNB_ERC20:
|
|
85
|
+
return [2 /*return*/, (0, transaction_converter_1.bnbUnsignedTransactionToRequest)(unsignedTransaction, publicKey, callbackUrl)];
|
|
86
|
+
default:
|
|
87
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BNB, "Protocol ".concat(identifier, " not supported"));
|
|
88
|
+
}
|
|
89
|
+
return [2 /*return*/];
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
BnbV3SerializerCompanion.prototype.fromTransactionSignRequest = function (identifier, transactionSignRequest) {
|
|
94
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
95
|
+
return __generator(this, function (_a) {
|
|
96
|
+
switch (identifier) {
|
|
97
|
+
case coinlib_core_1.MainProtocolSymbols.BNB:
|
|
98
|
+
case coinlib_core_1.SubProtocolSymbols.BNB_ERC20:
|
|
99
|
+
return [2 /*return*/, (0, transaction_converter_1.bnbTransactionSignRequestToUnsigned)(transactionSignRequest)];
|
|
100
|
+
default:
|
|
101
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BNB, "Protocol ".concat(identifier, " not supported"));
|
|
102
|
+
}
|
|
103
|
+
return [2 /*return*/];
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
BnbV3SerializerCompanion.prototype.validateTransactionSignRequest = function (identifier, transactionSignRequest) {
|
|
108
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
109
|
+
var _a, _b;
|
|
110
|
+
return __generator(this, function (_c) {
|
|
111
|
+
switch (_c.label) {
|
|
112
|
+
case 0:
|
|
113
|
+
_a = identifier;
|
|
114
|
+
switch (_a) {
|
|
115
|
+
case coinlib_core_1.MainProtocolSymbols.BNB: return [3 /*break*/, 1];
|
|
116
|
+
case coinlib_core_1.SubProtocolSymbols.BNB_ERC20: return [3 /*break*/, 1];
|
|
117
|
+
}
|
|
118
|
+
return [3 /*break*/, 4];
|
|
119
|
+
case 1:
|
|
120
|
+
_c.trys.push([1, 3, , 4]);
|
|
121
|
+
return [4 /*yield*/, this.ethereumTransactionValidator.validateUnsignedTransaction(transactionSignRequest)];
|
|
122
|
+
case 2:
|
|
123
|
+
_c.sent();
|
|
124
|
+
return [2 /*return*/, true];
|
|
125
|
+
case 3:
|
|
126
|
+
_b = _c.sent();
|
|
127
|
+
return [2 /*return*/, false];
|
|
128
|
+
case 4: throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BNB, "Protocol ".concat(identifier, " not supported"));
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
BnbV3SerializerCompanion.prototype.toTransactionSignResponse = function (identifier, signedTransaction, accountIdentifier) {
|
|
134
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
135
|
+
return __generator(this, function (_a) {
|
|
136
|
+
switch (identifier) {
|
|
137
|
+
case coinlib_core_1.MainProtocolSymbols.BNB:
|
|
138
|
+
case coinlib_core_1.SubProtocolSymbols.BNB_ERC20:
|
|
139
|
+
return [2 /*return*/, (0, transaction_converter_1.bnbSignedTransactionToResponse)(signedTransaction, accountIdentifier)];
|
|
140
|
+
default:
|
|
141
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BNB, "Protocol ".concat(identifier, " not supported"));
|
|
142
|
+
}
|
|
143
|
+
return [2 /*return*/];
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
BnbV3SerializerCompanion.prototype.fromTransactionSignResponse = function (identifier, transactionSignResponse) {
|
|
148
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
149
|
+
return __generator(this, function (_a) {
|
|
150
|
+
switch (identifier) {
|
|
151
|
+
case coinlib_core_1.MainProtocolSymbols.BNB:
|
|
152
|
+
case coinlib_core_1.SubProtocolSymbols.BNB_ERC20:
|
|
153
|
+
return [2 /*return*/, (0, transaction_converter_1.bnbTransactionSignResponseToSigned)(transactionSignResponse)];
|
|
154
|
+
default:
|
|
155
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BNB, "Protocol ".concat(identifier, " not supported"));
|
|
156
|
+
}
|
|
157
|
+
return [2 /*return*/];
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
BnbV3SerializerCompanion.prototype.validateTransactionSignResponse = function (identifier, transactionSignResponse) {
|
|
162
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
163
|
+
var _a, _b;
|
|
164
|
+
return __generator(this, function (_c) {
|
|
165
|
+
switch (_c.label) {
|
|
166
|
+
case 0:
|
|
167
|
+
_a = identifier;
|
|
168
|
+
switch (_a) {
|
|
169
|
+
case coinlib_core_1.MainProtocolSymbols.BNB: return [3 /*break*/, 1];
|
|
170
|
+
case coinlib_core_1.SubProtocolSymbols.BNB_ERC20: return [3 /*break*/, 1];
|
|
171
|
+
}
|
|
172
|
+
return [3 /*break*/, 4];
|
|
173
|
+
case 1:
|
|
174
|
+
_c.trys.push([1, 3, , 4]);
|
|
175
|
+
return [4 /*yield*/, this.ethereumTransactionValidator.validateSignedTransaction(transactionSignResponse)];
|
|
176
|
+
case 2:
|
|
177
|
+
_c.sent();
|
|
178
|
+
return [2 /*return*/, true];
|
|
179
|
+
case 3:
|
|
180
|
+
_b = _c.sent();
|
|
181
|
+
return [2 /*return*/, false];
|
|
182
|
+
case 4: throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BNB, "Protocol ".concat(identifier, " not supported"));
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
};
|
|
187
|
+
return BnbV3SerializerCompanion;
|
|
188
|
+
}());
|
|
189
|
+
exports.BnbV3SerializerCompanion = BnbV3SerializerCompanion;
|
|
190
|
+
//# sourceMappingURL=serializer-companion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializer-companion.js","sourceRoot":"","sources":["../../../../src/v1/serializer/v3/serializer-companion.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAsF;AACtF,sDAA8D;AAG9D,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