@airgap/ethereum 0.13.8 → 0.13.9-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/package.json +4 -4
- package/v1/index.d.ts +2 -6
- package/v1/index.js +1 -11
- package/v1/index.js.map +1 -1
- package/v1/module/ERC20Tokens.d.ts +3 -0
- package/v1/module/ERC20Tokens.js +815 -0
- package/v1/module/ERC20Tokens.js.map +1 -0
- package/v1/module/EthereumModule.d.ts +11 -5
- package/v1/module/EthereumModule.js +114 -21
- package/v1/module/EthereumModule.js.map +1 -1
- package/v1/protocol/EthereumBaseProtocol.d.ts +28 -16
- package/v1/protocol/EthereumBaseProtocol.js +137 -17
- package/v1/protocol/EthereumBaseProtocol.js.map +1 -1
- package/v1/protocol/EthereumProtocol.d.ts +2 -2
- package/v1/protocol/EthereumProtocol.js +1 -250
- package/v1/protocol/EthereumProtocol.js.map +1 -1
- package/v1/protocol/erc20/ERC20Token.d.ts +3 -1
- package/v1/protocol/erc20/ERC20Token.js +22 -6
- package/v1/protocol/erc20/ERC20Token.js.map +1 -1
- package/v1/serializer/v3/schemas/converter/transaction-converter.d.ts +3 -1
- package/v1/serializer/v3/schemas/converter/transaction-converter.js +56 -5
- package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -1
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum-typed.d.ts +1 -1
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum.d.ts +1 -1
- package/v1/serializer/v3/schemas/generated/transaction-sign-request-ethereum-typed.json +1 -5
- package/v1/serializer/v3/schemas/generated/transaction-sign-request-ethereum.json +1 -5
- 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 +1 -4
- package/v1/serializer/v3/validators/transaction-validator.js +1 -10
- package/v1/serializer/v3/validators/transaction-validator.js.map +1 -1
- package/v1/types/transaction.d.ts +2 -0
- package/v1/module/ERC20Module.d.ts +0 -9
- package/v1/module/ERC20Module.js +0 -69
- package/v1/module/ERC20Module.js.map +0 -1
- package/v1/module/EthereumBaseModule.d.ts +0 -13
- package/v1/module/EthereumBaseModule.js +0 -83
- package/v1/module/EthereumBaseModule.js.map +0 -1
- package/v1/module/EthereumClassicModule.d.ts +0 -7
- package/v1/module/EthereumClassicModule.js +0 -32
- package/v1/module/EthereumClassicModule.js.map +0 -1
- package/v1/module/EthereumRopstenModule.d.ts +0 -7
- package/v1/module/EthereumRopstenModule.js +0 -32
- package/v1/module/EthereumRopstenModule.js.map +0 -1
- package/v1/protocol/EthereumClassicProtocol.d.ts +0 -8
- package/v1/protocol/EthereumClassicProtocol.js +0 -87
- package/v1/protocol/EthereumClassicProtocol.js.map +0 -1
- package/v1/protocol/EthereumRopstenProtocol.d.ts +0 -8
- package/v1/protocol/EthereumRopstenProtocol.js +0 -64
- package/v1/protocol/EthereumRopstenProtocol.js.map +0 -1
- package/v1/utils/transaction.d.ts +0 -3
- package/v1/utils/transaction.js +0 -29
- package/v1/utils/transaction.js.map +0 -1
|
@@ -1,25 +1,76 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
+
var t = {};
|
|
15
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
+
t[p] = s[p];
|
|
17
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
+
t[p[i]] = s[p[i]];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
2
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ethereumTransactionSignResponseToSigned = exports.ethereumTransactionSignRequestToTypedUnsigned = exports.ethereumTransactionSignRequestToRawUnsigned = exports.ethereumSignedTransactionToResponse = exports.ethereumTypedUnsignedTransactionToRequest = exports.ethereumRawUnsignedTransactionToRequest = void 0;
|
|
25
|
+
exports.ethereumTransactionSignResponseToSigned = exports.ethereumTransactionSignRequestToTypedUnsigned = exports.ethereumTransactionSignRequestToRawUnsigned = exports.ethereumTransactionSignRequestToUnsigned = exports.ethereumSignedTransactionToResponse = exports.ethereumTypedUnsignedTransactionToRequest = exports.ethereumRawUnsignedTransactionToRequest = exports.ethereumUnsignedTransactionToRequest = void 0;
|
|
4
26
|
var module_kit_1 = require("@airgap/module-kit");
|
|
27
|
+
function isEthereumTypedTransactionSignRequest(request) {
|
|
28
|
+
return (0, module_kit_1.implementsInterface)(request.transaction, {
|
|
29
|
+
derivationPath: 'required',
|
|
30
|
+
masterFingerprint: 'required',
|
|
31
|
+
serialized: 'required'
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function ethereumUnsignedTransactionToRequest(unsigned, publicKey, callbackUrl) {
|
|
35
|
+
return unsigned.ethereumType === 'raw'
|
|
36
|
+
? ethereumRawUnsignedTransactionToRequest(unsigned, publicKey, callbackUrl)
|
|
37
|
+
: ethereumTypedUnsignedTransactionToRequest(unsigned, publicKey, callbackUrl);
|
|
38
|
+
}
|
|
39
|
+
exports.ethereumUnsignedTransactionToRequest = ethereumUnsignedTransactionToRequest;
|
|
5
40
|
function ethereumRawUnsignedTransactionToRequest(unsigned, publicKey, callbackUrl) {
|
|
6
|
-
|
|
41
|
+
var _ = unsigned.type, rest = __rest(unsigned, ["type"]);
|
|
42
|
+
return {
|
|
43
|
+
transaction: rest,
|
|
44
|
+
publicKey: publicKey,
|
|
45
|
+
callbackURL: callbackUrl
|
|
46
|
+
};
|
|
7
47
|
}
|
|
8
48
|
exports.ethereumRawUnsignedTransactionToRequest = ethereumRawUnsignedTransactionToRequest;
|
|
9
49
|
function ethereumTypedUnsignedTransactionToRequest(unsigned, publicKey, callbackUrl) {
|
|
10
|
-
|
|
50
|
+
var _ = unsigned.type, rest = __rest(unsigned, ["type"]);
|
|
51
|
+
return {
|
|
52
|
+
transaction: rest,
|
|
53
|
+
publicKey: publicKey,
|
|
54
|
+
callbackURL: callbackUrl
|
|
55
|
+
};
|
|
11
56
|
}
|
|
12
57
|
exports.ethereumTypedUnsignedTransactionToRequest = ethereumTypedUnsignedTransactionToRequest;
|
|
13
58
|
function ethereumSignedTransactionToResponse(signed, accountIdentifier) {
|
|
14
59
|
return { transaction: signed.serialized, accountIdentifier: accountIdentifier };
|
|
15
60
|
}
|
|
16
61
|
exports.ethereumSignedTransactionToResponse = ethereumSignedTransactionToResponse;
|
|
62
|
+
function ethereumTransactionSignRequestToUnsigned(request) {
|
|
63
|
+
return isEthereumTypedTransactionSignRequest(request)
|
|
64
|
+
? ethereumTransactionSignRequestToTypedUnsigned(request)
|
|
65
|
+
: ethereumTransactionSignRequestToRawUnsigned(request);
|
|
66
|
+
}
|
|
67
|
+
exports.ethereumTransactionSignRequestToUnsigned = ethereumTransactionSignRequestToUnsigned;
|
|
17
68
|
function ethereumTransactionSignRequestToRawUnsigned(request) {
|
|
18
|
-
return request.transaction;
|
|
69
|
+
return (0, module_kit_1.newUnsignedTransaction)(__assign({ ethereumType: 'raw' }, request.transaction));
|
|
19
70
|
}
|
|
20
71
|
exports.ethereumTransactionSignRequestToRawUnsigned = ethereumTransactionSignRequestToRawUnsigned;
|
|
21
72
|
function ethereumTransactionSignRequestToTypedUnsigned(request) {
|
|
22
|
-
return request.transaction;
|
|
73
|
+
return (0, module_kit_1.newUnsignedTransaction)(__assign({ ethereumType: 'typed' }, request.transaction));
|
|
23
74
|
}
|
|
24
75
|
exports.ethereumTransactionSignRequestToTypedUnsigned = ethereumTransactionSignRequestToTypedUnsigned;
|
|
25
76
|
function ethereumTransactionSignResponseToSigned(response) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction-converter.js","sourceRoot":"","sources":["../../../../../../src/v1/serializer/v3/schemas/converter/transaction-converter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transaction-converter.js","sourceRoot":"","sources":["../../../../../../src/v1/serializer/v3/schemas/converter/transaction-converter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAsG;AAetG,SAAS,qCAAqC,CAC5C,OAA6E;IAE7E,OAAO,IAAA,gCAAmB,EAA+C,OAAO,CAAC,WAAW,EAAE;QAC5F,cAAc,EAAE,UAAU;QAC1B,iBAAiB,EAAE,UAAU;QAC7B,UAAU,EAAE,UAAU;KACvB,CAAC,CAAA;AACJ,CAAC;AAED,SAAgB,oCAAoC,CAClD,QAAqC,EACrC,SAAiB,EACjB,WAAoB;IAEpB,OAAO,QAAQ,CAAC,YAAY,KAAK,KAAK;QACpC,CAAC,CAAC,uCAAuC,CAAC,QAAQ,EAAE,SAAS,EAAE,WAAW,CAAC;QAC3E,CAAC,CAAC,yCAAyC,CAAC,QAAQ,EAAE,SAAS,EAAE,WAAW,CAAC,CAAA;AACjF,CAAC;AARD,oFAQC;AAED,SAAgB,uCAAuC,CACrD,QAAwC,EACxC,SAAiB,EACjB,WAAoB;IAEZ,IAAM,CAAC,GAAc,QAAQ,KAAtB,EAAK,IAAI,UAAK,QAAQ,EAA/B,QAAoB,CAAF,CAAa;IAErC,OAAO;QACL,WAAW,EAAE,IAAI;QACjB,SAAS,WAAA;QACT,WAAW,EAAE,WAAW;KACzB,CAAA;AACH,CAAC;AAZD,0FAYC;AAED,SAAgB,yCAAyC,CACvD,QAA0C,EAC1C,SAAiB,EACjB,WAAoB;IAEZ,IAAM,CAAC,GAAc,QAAQ,KAAtB,EAAK,IAAI,UAAK,QAAQ,EAA/B,QAAoB,CAAF,CAAa;IAErC,OAAO;QACL,WAAW,EAAE,IAAI;QACjB,SAAS,WAAA;QACT,WAAW,EAAE,WAAW;KACzB,CAAA;AACH,CAAC;AAZD,8FAYC;AAED,SAAgB,mCAAmC,CACjD,MAAiC,EACjC,iBAAyB;IAEzB,OAAO,EAAE,WAAW,EAAE,MAAM,CAAC,UAAU,EAAE,iBAAiB,mBAAA,EAAE,CAAA;AAC9D,CAAC;AALD,kFAKC;AAED,SAAgB,wCAAwC,CACtD,OAA6E;IAE7E,OAAO,qCAAqC,CAAC,OAAO,CAAC;QACnD,CAAC,CAAC,6CAA6C,CAAC,OAAO,CAAC;QACxD,CAAC,CAAC,2CAA2C,CAAC,OAAO,CAAC,CAAA;AAC1D,CAAC;AAND,4FAMC;AAED,SAAgB,2CAA2C,CAAC,OAAuC;IACjG,OAAO,IAAA,mCAAsB,aAAmC,YAAY,EAAE,KAAK,IAAK,OAAO,CAAC,WAAW,EAAG,CAAA;AAChH,CAAC;AAFD,kGAEC;AAED,SAAgB,6CAA6C,CAC3D,OAA4C;IAE5C,OAAO,IAAA,mCAAsB,aAAqC,YAAY,EAAE,OAAO,IAAK,OAAO,CAAC,WAAW,EAAG,CAAA;AACpH,CAAC;AAJD,sGAIC;AAED,SAAgB,uCAAuC,CAAC,QAAyC;IAC/F,OAAO,IAAA,iCAAoB,EAA4B,EAAE,UAAU,EAAE,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAA;AAC9F,CAAC;AAFD,0FAEC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TransactionSignRequest } from '@airgap/serializer';
|
|
2
2
|
import { HexString } from '@airgap/serializer/v3/schemas/definitions/hex-string';
|
|
3
3
|
import { EthereumTypedUnsignedTransaction } from '../../../../types/transaction';
|
|
4
|
-
export interface SerializableEthereumTypedUnsignedTransaction extends EthereumTypedUnsignedTransaction {
|
|
4
|
+
export interface SerializableEthereumTypedUnsignedTransaction extends Omit<EthereumTypedUnsignedTransaction, 'type' | 'ethereumType'> {
|
|
5
5
|
serialized: HexString;
|
|
6
6
|
derivationPath: string;
|
|
7
7
|
masterFingerprint: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TransactionSignRequest } from '@airgap/serializer';
|
|
2
2
|
import { HexString } from '@airgap/serializer/v3/schemas/definitions/hex-string';
|
|
3
3
|
import { EthereumRawUnsignedTransaction } from '../../../../types/transaction';
|
|
4
|
-
export interface SerializableEthereumRawUnsignedTransaction extends EthereumRawUnsignedTransaction {
|
|
4
|
+
export interface SerializableEthereumRawUnsignedTransaction extends Omit<EthereumRawUnsignedTransaction, 'type' | 'ethereumType'> {
|
|
5
5
|
nonce: HexString;
|
|
6
6
|
gasPrice: HexString;
|
|
7
7
|
gasLimit: HexString;
|
|
@@ -32,13 +32,9 @@
|
|
|
32
32
|
"serialized": {
|
|
33
33
|
"$ref": "#/definitions/HexString",
|
|
34
34
|
"type": "string"
|
|
35
|
-
},
|
|
36
|
-
"type": {
|
|
37
|
-
"enum": ["unsigned"],
|
|
38
|
-
"type": "string"
|
|
39
35
|
}
|
|
40
36
|
},
|
|
41
|
-
"required": ["derivationPath", "masterFingerprint", "serialized"
|
|
37
|
+
"required": ["derivationPath", "masterFingerprint", "serialized"],
|
|
42
38
|
"type": "object"
|
|
43
39
|
}
|
|
44
40
|
}
|
|
@@ -46,16 +46,12 @@
|
|
|
46
46
|
"$ref": "#/definitions/HexString",
|
|
47
47
|
"type": "string"
|
|
48
48
|
},
|
|
49
|
-
"type": {
|
|
50
|
-
"enum": ["unsigned"],
|
|
51
|
-
"type": "string"
|
|
52
|
-
},
|
|
53
49
|
"value": {
|
|
54
50
|
"$ref": "#/definitions/HexString",
|
|
55
51
|
"type": "string"
|
|
56
52
|
}
|
|
57
53
|
},
|
|
58
|
-
"required": ["chainId", "data", "gasLimit", "gasPrice", "nonce", "to", "
|
|
54
|
+
"required": ["chainId", "data", "gasLimit", "gasPrice", "nonce", "to", "value"],
|
|
59
55
|
"type": "object"
|
|
60
56
|
}
|
|
61
57
|
}
|
|
@@ -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 EthereumV3SerializerCompanion 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.EthereumV3SerializerCompanion = 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-ethereum.json');
|
|
46
|
+
var ethereumTypedTransactionSignRequest = require('./schemas/generated/transaction-sign-request-ethereum-typed.json');
|
|
47
|
+
var ethereumTransactionSignResponse = require('./schemas/generated/transaction-sign-response-ethereum.json');
|
|
48
|
+
var EthereumV3SerializerCompanion = /** @class */ (function () {
|
|
49
|
+
function EthereumV3SerializerCompanion() {
|
|
50
|
+
this.schemas = [
|
|
51
|
+
{
|
|
52
|
+
type: serializer_1.IACMessageType.TransactionSignRequest,
|
|
53
|
+
schema: { schema: ethereumTransactionSignRequest },
|
|
54
|
+
protocolIdentifier: coinlib_core_1.MainProtocolSymbols.ETH
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
type: serializer_1.IACMessageType.TransactionSignRequest,
|
|
58
|
+
schema: { schema: ethereumTypedTransactionSignRequest },
|
|
59
|
+
protocolIdentifier: coinlib_core_1.MainProtocolSymbols.ETH
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
type: serializer_1.IACMessageType.TransactionSignResponse,
|
|
63
|
+
schema: { schema: ethereumTransactionSignResponse },
|
|
64
|
+
protocolIdentifier: coinlib_core_1.MainProtocolSymbols.ETH
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
type: serializer_1.IACMessageType.TransactionSignRequest,
|
|
68
|
+
schema: { schema: ethereumTransactionSignRequest },
|
|
69
|
+
protocolIdentifier: coinlib_core_1.SubProtocolSymbols.ETH_ERC20
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
type: serializer_1.IACMessageType.TransactionSignResponse,
|
|
73
|
+
schema: { schema: ethereumTransactionSignResponse },
|
|
74
|
+
protocolIdentifier: coinlib_core_1.SubProtocolSymbols.ETH_ERC20
|
|
75
|
+
}
|
|
76
|
+
];
|
|
77
|
+
this.ethereumTransactionValidator = new transaction_validator_1.EthereumTransactionValidator();
|
|
78
|
+
}
|
|
79
|
+
EthereumV3SerializerCompanion.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.ETH:
|
|
84
|
+
case coinlib_core_1.SubProtocolSymbols.ETH_ERC20:
|
|
85
|
+
return [2 /*return*/, (0, transaction_converter_1.ethereumUnsignedTransactionToRequest)(unsignedTransaction, publicKey, callbackUrl)];
|
|
86
|
+
default:
|
|
87
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, "Protocol ".concat(identifier, " not supported"));
|
|
88
|
+
}
|
|
89
|
+
return [2 /*return*/];
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
EthereumV3SerializerCompanion.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.ETH:
|
|
98
|
+
case coinlib_core_1.SubProtocolSymbols.ETH_ERC20:
|
|
99
|
+
return [2 /*return*/, (0, transaction_converter_1.ethereumTransactionSignRequestToUnsigned)(transactionSignRequest)];
|
|
100
|
+
default:
|
|
101
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, "Protocol ".concat(identifier, " not supported"));
|
|
102
|
+
}
|
|
103
|
+
return [2 /*return*/];
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
EthereumV3SerializerCompanion.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.ETH: return [3 /*break*/, 1];
|
|
116
|
+
case coinlib_core_1.SubProtocolSymbols.ETH_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.ETHEREUM, "Protocol ".concat(identifier, " not supported"));
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
EthereumV3SerializerCompanion.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.ETH:
|
|
138
|
+
case coinlib_core_1.SubProtocolSymbols.ETH_ERC20:
|
|
139
|
+
return [2 /*return*/, (0, transaction_converter_1.ethereumSignedTransactionToResponse)(signedTransaction, accountIdentifier)];
|
|
140
|
+
default:
|
|
141
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, "Protocol ".concat(identifier, " not supported"));
|
|
142
|
+
}
|
|
143
|
+
return [2 /*return*/];
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
EthereumV3SerializerCompanion.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.ETH:
|
|
152
|
+
case coinlib_core_1.SubProtocolSymbols.ETH_ERC20:
|
|
153
|
+
return [2 /*return*/, (0, transaction_converter_1.ethereumTransactionSignResponseToSigned)(transactionSignResponse)];
|
|
154
|
+
default:
|
|
155
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, "Protocol ".concat(identifier, " not supported"));
|
|
156
|
+
}
|
|
157
|
+
return [2 /*return*/];
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
EthereumV3SerializerCompanion.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.ETH: return [3 /*break*/, 1];
|
|
170
|
+
case coinlib_core_1.SubProtocolSymbols.ETH_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.ETHEREUM, "Protocol ".concat(identifier, " not supported"));
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
};
|
|
187
|
+
return EthereumV3SerializerCompanion;
|
|
188
|
+
}());
|
|
189
|
+
exports.EthereumV3SerializerCompanion = EthereumV3SerializerCompanion;
|
|
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,iDAAgH;AAIhH,mFAKkD;AAClD,4EAAiF;AAEjF,IAAM,8BAA8B,GAAe,OAAO,CAAC,4DAA4D,CAAC,CAAA;AACxH,IAAM,mCAAmC,GAAe,OAAO,CAAC,kEAAkE,CAAC,CAAA;AACnI,IAAM,+BAA+B,GAAe,OAAO,CAAC,6DAA6D,CAAC,CAAA;AAE1H;IAAA;QACkB,YAAO,GAA4B;YACjD;gBACE,IAAI,EAAE,2BAAc,CAAC,sBAAsB;gBAC3C,MAAM,EAAE,EAAE,MAAM,EAAE,8BAA8B,EAAE;gBAClD,kBAAkB,EAAE,kCAAmB,CAAC,GAAG;aAC5C;YACD;gBACE,I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;;;KACF;IAEY,uEAA+B,GAA5C,UAA6C,UAAkB,EAAE,uBAAgD;;;;;;wBACvG,KAAA,UAAU,CAAA;;iCACX,kCAAmB,CAAC,GAAG,CAAC,CAAxB,wBAAuB;iCACvB,iCAAkB,CAAC,SAAS,CAAC,CAA7B,wBAA4B;;;;;wBAE7B,qBAAM,IAAI,CAAC,4BAA4B,CAAC,yBAAyB,CAAC,uBAAuB,CAAC,EAAA;;wBAA1F,SAA0F,CAAA;wBAE1F,sBAAO,IAAI,EAAA;;;wBAEX,sBAAO,KAAK,EAAA;4BAGd,MAAM,IAAI,yBAAgB,CAAC,qBAAM,CAAC,QAAQ,EAAE,mBAAY,UAAU,mBAAgB,CAAC,CAAA;;;;KAExF;IACH,oCAAC;AAAD,CAAC,AArHD,IAqHC;AArHY,sEAA6B"}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import { TransactionValidator,
|
|
1
|
+
import { TransactionValidator, TransactionValidatorV2 } from '@airgap/serializer';
|
|
2
2
|
import { EthereumTransactionSignRequest } from '../schemas/definitions/transaction-sign-request-ethereum';
|
|
3
3
|
import { EthereumTransactionSignResponse } from '../schemas/definitions/transaction-sign-response-ethereum';
|
|
4
4
|
export declare class EthereumTransactionValidator implements TransactionValidator, TransactionValidatorV2 {
|
|
5
5
|
validateUnsignedTransaction(request: EthereumTransactionSignRequest): Promise<any>;
|
|
6
6
|
validateSignedTransaction(signedTx: EthereumTransactionSignResponse): any;
|
|
7
7
|
}
|
|
8
|
-
export declare class EthereumTransactionValidatorFactory implements TransactionValidatorFactory<EthereumTransactionValidator> {
|
|
9
|
-
create(): EthereumTransactionValidator;
|
|
10
|
-
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.EthereumTransactionValidator = void 0;
|
|
4
4
|
// tslint:disable: max-classes-per-file
|
|
5
5
|
var validate_1 = require("@airgap/coinlib-core/dependencies/src/validate.js-0.13.1/validate");
|
|
6
6
|
var serializer_1 = require("@airgap/serializer");
|
|
@@ -68,13 +68,4 @@ var EthereumTransactionValidator = /** @class */ (function () {
|
|
|
68
68
|
return EthereumTransactionValidator;
|
|
69
69
|
}());
|
|
70
70
|
exports.EthereumTransactionValidator = EthereumTransactionValidator;
|
|
71
|
-
var EthereumTransactionValidatorFactory = /** @class */ (function () {
|
|
72
|
-
function EthereumTransactionValidatorFactory() {
|
|
73
|
-
}
|
|
74
|
-
EthereumTransactionValidatorFactory.prototype.create = function () {
|
|
75
|
-
return new EthereumTransactionValidator();
|
|
76
|
-
};
|
|
77
|
-
return EthereumTransactionValidatorFactory;
|
|
78
|
-
}());
|
|
79
|
-
exports.EthereumTransactionValidatorFactory = EthereumTransactionValidatorFactory;
|
|
80
71
|
//# sourceMappingURL=transaction-validator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction-validator.js","sourceRoot":"","sources":["../../../../../src/v1/serializer/v3/validators/transaction-validator.ts"],"names":[],"mappings":";;;AAAA,uCAAuC;AACvC,8FAAyF;AACzF,
|
|
1
|
+
{"version":3,"file":"transaction-validator.js","sourceRoot":"","sources":["../../../../../src/v1/serializer/v3/validators/transaction-validator.ts"],"names":[],"mappings":";;;AAAA,uCAAuC;AACvC,8FAAyF;AACzF,iDAAqG;AAKrG,IAAM,8BAA8B,GAAG;IACrC,KAAK,EAAE;QACL,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;QAC/B,IAAI,EAAE,QAAQ;QACd,qBAAqB,EAAE,IAAI;KAC5B;IACD,QAAQ,EAAE;QACR,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;QAC/B,IAAI,EAAE,QAAQ;QACd,qBAAqB,EAAE,IAAI;KAC5B;IACD,QAAQ,EAAE;QACR,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;QAC/B,IAAI,EAAE,QAAQ;QACd,qBAAqB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F,CAAC;IACM,gEAAyB,GAAhC,UAAiC,QAAyC;QACxE,OAAO,IAAA,gBAAK,EAAC,QAAQ,EAAE,4BAA4B,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IAC3E,CAAC;IACH,mCAAC;AAAD,CAAC,AAVD,IAUC;AAVY,oEAA4B"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SignedTransaction, TransactionCursor, UnsignedTransaction } from '@airgap/module-kit';
|
|
2
2
|
export interface EthereumRawUnsignedTransaction extends UnsignedTransaction {
|
|
3
|
+
ethereumType: 'raw';
|
|
3
4
|
nonce: string;
|
|
4
5
|
gasPrice: string;
|
|
5
6
|
gasLimit: string;
|
|
@@ -9,6 +10,7 @@ export interface EthereumRawUnsignedTransaction extends UnsignedTransaction {
|
|
|
9
10
|
data: string;
|
|
10
11
|
}
|
|
11
12
|
export interface EthereumTypedUnsignedTransaction extends UnsignedTransaction {
|
|
13
|
+
ethereumType: 'typed';
|
|
12
14
|
serialized: string;
|
|
13
15
|
derivationPath: string;
|
|
14
16
|
masterFingerprint: string;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { AirGapModule, ProtocolNetwork } from '@airgap/module-kit';
|
|
2
|
-
import { BlockExplorer } from '@airgap/module-kit/block-explorer/block-explorer';
|
|
3
|
-
import { OfflineProtocol, OnlineProtocol } from '@airgap/module-kit/protocol/protocol';
|
|
4
|
-
export declare class ERC20Module implements AirGapModule {
|
|
5
|
-
readonly supportedNetworks: Record<string, ProtocolNetwork>;
|
|
6
|
-
createOfflineProtocol(): Promise<OfflineProtocol | undefined>;
|
|
7
|
-
createOnlineProtocol(networkId?: string | undefined): Promise<OnlineProtocol | undefined>;
|
|
8
|
-
createBlockExplorer(networkId?: string | undefined): Promise<BlockExplorer | undefined>;
|
|
9
|
-
}
|
package/v1/module/ERC20Module.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
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.ERC20Module = void 0;
|
|
40
|
-
var ERC20Module = /** @class */ (function () {
|
|
41
|
-
function ERC20Module() {
|
|
42
|
-
// TODO: figure out what to do with modules that should create generic protocols instances
|
|
43
|
-
this.supportedNetworks = {};
|
|
44
|
-
}
|
|
45
|
-
ERC20Module.prototype.createOfflineProtocol = function () {
|
|
46
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
47
|
-
return __generator(this, function (_a) {
|
|
48
|
-
throw new Error('Method not implemented.');
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
ERC20Module.prototype.createOnlineProtocol = function (networkId) {
|
|
53
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
54
|
-
return __generator(this, function (_a) {
|
|
55
|
-
throw new Error('Method not implemented.');
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
ERC20Module.prototype.createBlockExplorer = function (networkId) {
|
|
60
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
61
|
-
return __generator(this, function (_a) {
|
|
62
|
-
throw new Error('Method not implemented.');
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
};
|
|
66
|
-
return ERC20Module;
|
|
67
|
-
}());
|
|
68
|
-
exports.ERC20Module = ERC20Module;
|
|
69
|
-
//# sourceMappingURL=ERC20Module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ERC20Module.js","sourceRoot":"","sources":["../../../src/v1/module/ERC20Module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;IAAA;QACE,0FAA0F;QAE1E,sBAAiB,GAAoC,EAAE,CAAA;IAazE,CAAC;IAXc,2CAAqB,GAAlC;;;gBACE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;;;KAC3C;IAEY,0CAAoB,GAAjC,UAAkC,SAA8B;;;gBAC9D,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;;;KAC3C;IAEY,yCAAmB,GAAhC,UAAiC,SAA8B;;;gBAC7D,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;;;KAC3C;IACH,kBAAC;AAAD,CAAC,AAhBD,IAgBC;AAhBY,kCAAW"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { AirGapModule, ProtocolNetwork } from '@airgap/module-kit';
|
|
2
|
-
import { BlockExplorer } from '@airgap/module-kit/block-explorer/block-explorer';
|
|
3
|
-
import { OfflineProtocol, OnlineProtocol } from '@airgap/module-kit/protocol/protocol';
|
|
4
|
-
import { EthereumBaseProtocol } from '../protocol/EthereumBaseProtocol';
|
|
5
|
-
export declare abstract class EthereumBaseModule implements AirGapModule {
|
|
6
|
-
readonly supportedNetworks: Record<string, ProtocolNetwork>;
|
|
7
|
-
private readonly networkRegistry;
|
|
8
|
-
protected constructor(supportedNetworks: ProtocolNetwork[], defaultNetwork?: ProtocolNetwork);
|
|
9
|
-
abstract createEthereumProtocol(network?: ProtocolNetwork): EthereumBaseProtocol;
|
|
10
|
-
createOfflineProtocol(): Promise<OfflineProtocol | undefined>;
|
|
11
|
-
createOnlineProtocol(networkId?: string | undefined): Promise<OnlineProtocol | undefined>;
|
|
12
|
-
createBlockExplorer(networkId?: string | undefined): Promise<BlockExplorer | undefined>;
|
|
13
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
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.EthereumBaseModule = void 0;
|
|
40
|
-
var coinlib_core_1 = require("@airgap/coinlib-core");
|
|
41
|
-
var errors_1 = require("@airgap/coinlib-core/errors");
|
|
42
|
-
var module_kit_1 = require("@airgap/module-kit");
|
|
43
|
-
var EtherscanBlockExplorer_1 = require("../block-explorer/EtherscanBlockExplorer");
|
|
44
|
-
var EthereumBaseModule = /** @class */ (function () {
|
|
45
|
-
function EthereumBaseModule(supportedNetworks, defaultNetwork) {
|
|
46
|
-
this.networkRegistry = new module_kit_1.ModuleNetworkRegistry({ supportedNetworks: supportedNetworks, defaultNetwork: defaultNetwork });
|
|
47
|
-
this.supportedNetworks = this.networkRegistry.supportedNetworks;
|
|
48
|
-
}
|
|
49
|
-
EthereumBaseModule.prototype.createOfflineProtocol = function () {
|
|
50
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
51
|
-
return __generator(this, function (_a) {
|
|
52
|
-
return [2 /*return*/, this.createEthereumProtocol()];
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
EthereumBaseModule.prototype.createOnlineProtocol = function (networkId) {
|
|
57
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
58
|
-
var network;
|
|
59
|
-
return __generator(this, function (_a) {
|
|
60
|
-
network = this.networkRegistry.findNetwork(networkId);
|
|
61
|
-
if (network === undefined) {
|
|
62
|
-
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.ETHEREUM, 'Protocol network type not supported.');
|
|
63
|
-
}
|
|
64
|
-
return [2 /*return*/, this.createEthereumProtocol(network)];
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
};
|
|
68
|
-
EthereumBaseModule.prototype.createBlockExplorer = function (networkId) {
|
|
69
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
70
|
-
var network;
|
|
71
|
-
return __generator(this, function (_a) {
|
|
72
|
-
network = this.networkRegistry.findNetwork(networkId);
|
|
73
|
-
if (network === undefined) {
|
|
74
|
-
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.ETHEREUM, 'Block Explorer network type not supported.');
|
|
75
|
-
}
|
|
76
|
-
return [2 /*return*/, new EtherscanBlockExplorer_1.EtherscanBlockExplorer()];
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
};
|
|
80
|
-
return EthereumBaseModule;
|
|
81
|
-
}());
|
|
82
|
-
exports.EthereumBaseModule = EthereumBaseModule;
|
|
83
|
-
//# sourceMappingURL=EthereumBaseModule.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumBaseModule.js","sourceRoot":"","sources":["../../../src/v1/module/EthereumBaseModule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAA6C;AAC7C,sDAAqE;AACrE,iDAAyF;AAIzF,mFAAiF;AAGjF;IAKE,4BAAsB,iBAAoC,EAAE,cAAgC;QAC1F,IAAI,CAAC,eAAe,GAAG,IAAI,kCAAqB,CAAC,EAAE,iBAAiB,mBAAA,EAAE,cAAc,gBAAA,EAAE,CAAC,CAAA;QACvF,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,eAAe,CAAC,iBAAiB,CAAA;IACjE,CAAC;IAIY,kDAAqB,GAAlC;;;gBACE,sBAAO,IAAI,CAAC,sBAAsB,EAAE,EAAA;;;KACrC;IAEY,iDAAoB,GAAjC,UAAkC,SAA8B;;;;gBACxD,OAAO,GAAgC,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA;gBACxF,IAAI,OAAO,KAAK,SAAS,EAAE;oBACzB,MAAM,IAAI,gCAAuB,CAAC,qBAAM,CAAC,QAAQ,EAAE,sCAAsC,CAAC,CAAA;iBAC3F;gBAED,sBAAO,IAAI,CAAC,sBAAsB,CAAC,OAAO,CAAC,EAAA;;;KAC5C;IAEY,gDAAmB,GAAhC,UAAiC,SAA8B;;;;gBACvD,OAAO,GAAgC,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA;gBACxF,IAAI,OAAO,KAAK,SAAS,EAAE;oBACzB,MAAM,IAAI,gCAAuB,CAAC,qBAAM,CAAC,QAAQ,EAAE,4CAA4C,CAAC,CAAA;iBACjG;gBAED,sBAAO,IAAI,+CAAsB,EAAE,EAAA;;;KACpC;IACH,yBAAC;AAAD,CAAC,AAjCD,IAiCC;AAjCqB,gDAAkB"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ProtocolNetwork } from '@airgap/module-kit';
|
|
2
|
-
import { EthereumBaseProtocol } from '../protocol/EthereumBaseProtocol';
|
|
3
|
-
import { EthereumBaseModule } from './EthereumBaseModule';
|
|
4
|
-
export declare class EthereumClassicModule extends EthereumBaseModule {
|
|
5
|
-
constructor();
|
|
6
|
-
createEthereumProtocol(network?: ProtocolNetwork | undefined): EthereumBaseProtocol;
|
|
7
|
-
}
|