@airgap/ethereum 0.13.45-beta.3 → 0.13.45-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -5
- package/v0/index.js +10 -10
- package/v0/index.js.map +1 -1
- package/v0/protocol/BaseEthereumProtocol.d.ts +1 -0
- package/v0/protocol/BaseEthereumProtocol.js +872 -460
- package/v0/protocol/BaseEthereumProtocol.js.map +1 -1
- package/v0/protocol/EthereumAddress.d.ts +1 -0
- package/v0/protocol/EthereumAddress.js +17 -26
- package/v0/protocol/EthereumAddress.js.map +1 -1
- package/v0/protocol/EthereumClassicProtocol.js +23 -6
- package/v0/protocol/EthereumClassicProtocol.js.map +1 -1
- package/v0/protocol/EthereumCryptoClient.js +125 -66
- package/v0/protocol/EthereumCryptoClient.js.map +1 -1
- package/v0/protocol/EthereumProtocol.js +28 -9
- package/v0/protocol/EthereumProtocol.js.map +1 -1
- package/v0/protocol/EthereumProtocolOptions.d.ts +1 -1
- package/v0/protocol/EthereumProtocolOptions.js +117 -36
- package/v0/protocol/EthereumProtocolOptions.js.map +1 -1
- package/v0/protocol/EthereumRopstenProtocol.js +23 -6
- package/v0/protocol/EthereumRopstenProtocol.js.map +1 -1
- package/v0/protocol/clients/info-clients/EtherscanInfoClient.js +186 -86
- package/v0/protocol/clients/info-clients/EtherscanInfoClient.js.map +1 -1
- package/v0/protocol/clients/info-clients/InfoClient.js +4 -3
- package/v0/protocol/clients/info-clients/InfoClient.js.map +1 -1
- package/v0/protocol/clients/node-clients/AirGapNodeClient.js +298 -126
- package/v0/protocol/clients/node-clients/AirGapNodeClient.js.map +1 -1
- package/v0/protocol/clients/node-clients/NodeClient.js +4 -3
- package/v0/protocol/clients/node-clients/NodeClient.js.map +1 -1
- package/v0/protocol/erc20/ERC20.js +4 -4
- package/v0/protocol/erc20/ERC20.js.map +1 -1
- package/v0/protocol/erc20/GenericERC20.js +300 -161
- package/v0/protocol/erc20/GenericERC20.js.map +1 -1
- package/v0/protocol/utils/utils.js +55 -52
- package/v0/protocol/utils/utils.js.map +1 -1
- package/v0/serializer/validators/transaction-validator.js +31 -23
- package/v0/serializer/validators/transaction-validator.js.map +1 -1
- package/v0/serializer/validators/validators.js +73 -25
- package/v0/serializer/validators/validators.js.map +1 -1
- package/v1/block-explorer/EtherscanBlockExplorer.js +61 -12
- package/v1/block-explorer/EtherscanBlockExplorer.js.map +1 -1
- package/v1/clients/crypto/EthereumCryptoClient.js +124 -69
- package/v1/clients/crypto/EthereumCryptoClient.js.map +1 -1
- package/v1/clients/info/EthereumInfoClient.d.ts +1 -1
- package/v1/clients/info/EthereumInfoClient.js +4 -3
- package/v1/clients/info/EthereumInfoClient.js.map +1 -1
- package/v1/clients/info/EtherscanInfoClient.js +162 -84
- package/v1/clients/info/EtherscanInfoClient.js.map +1 -1
- package/v1/clients/node/HttpEthereumNodeClient.d.ts +2 -2
- package/v1/clients/node/HttpEthereumNodeClient.js +375 -164
- package/v1/clients/node/HttpEthereumNodeClient.js.map +1 -1
- package/v1/data/EthereumAddress.js +20 -29
- package/v1/data/EthereumAddress.js.map +1 -1
- package/v1/index.js +14 -14
- package/v1/index.js.map +1 -1
- package/v1/module/EthereumModule.js +112 -43
- package/v1/module/EthereumModule.js.map +1 -1
- package/v1/module.js +3 -2
- package/v1/module.js.map +1 -1
- package/v1/protocol/EthereumBaseProtocol.js +788 -467
- package/v1/protocol/EthereumBaseProtocol.js.map +1 -1
- package/v1/protocol/EthereumProtocol.js +46 -15
- package/v1/protocol/EthereumProtocol.js.map +1 -1
- package/v1/protocol/erc20/ERC20Protocol.js +360 -213
- package/v1/protocol/erc20/ERC20Protocol.js.map +1 -1
- package/v1/protocol/erc20/ERC20Token.d.ts +1 -1
- package/v1/protocol/erc20/ERC20Token.js +113 -35
- package/v1/protocol/erc20/ERC20Token.js.map +1 -1
- package/v1/serializer/v3/schemas/converter/transaction-converter.js +42 -25
- package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -1
- package/v1/serializer/v3/serializer-companion.js +148 -71
- package/v1/serializer/v3/serializer-companion.js.map +1 -1
- package/v1/serializer/v3/validators/transaction-validator.js +17 -14
- package/v1/serializer/v3/validators/transaction-validator.js.map +1 -1
- package/v1/types/crypto.d.ts +1 -1
- package/v1/types/protocol.d.ts +1 -1
- package/v1/types/transaction.d.ts +1 -1
- package/v1/utils/EthereumUtils.js +60 -57
- package/v1/utils/EthereumUtils.js.map +1 -1
- package/v1/utils/key.js +19 -28
- package/v1/utils/key.js.map +1 -1
- package/v1/utils/protocol.js +21 -33
- package/v1/utils/protocol.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ERC20Protocol.js","sourceRoot":"","sources":["../../../../src/v1/protocol/erc20/ERC20Protocol.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ERC20Protocol.js","sourceRoot":"","sources":["../../../../src/v1/protocol/erc20/ERC20Protocol.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAA0D;AAC1D,iHAA0F;AAC1F,aAAa;AACb,mGAAsF;AACtF,sDAAqG;AACrG,sDAAsD;AACtD,iDAc2B;AAC3B,qCAAgF;AAGhF,oFAAmF;AASnF,2DAAyD;AACzD,gEAAwF;AAExF,IAAM,mBAAmB,GAAG,OAAO,CAAC,iEAAiE,CAAC,CAAA;AAWtG,iBAAiB;AAEjB;IACU,qCAAkD;IAK1D,2BACE,UAA8B,EAC9B,UAA8B,EAC9B,OAAuD;QAHzD,YAKE,kBAAM,UAAU,EAAE,UAAU,EAAE;YAC5B,OAAO,EAAE,OAAO,CAAC,OAAO;YAExB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,UAAU,EAAE,OAAO,CAAC,UAAU;YAE9B,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,QAAQ,EAAE,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GAArB;;;gBACE,sBAAO,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,IAAI,CAAC,eAAe,CAAC,EAAA;;;KACjE;IAEe,uCAAW,GAA3B,UACE,WAAmB,EACnB,SAAiB,EACjB,MAA4C,EAC5C,KAAc;;;;gBAGd,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,IAAA,WAAK,EAAC,MAAM,CAAC,EAAE;oBAC/C,SAAS,GAAG,MAAM,CAAA;iBACnB;qBAAM;oBACC,gBAAgB,GAAW,IAAA,qBAAQ,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAA,sBAAS,EAAC,MAAM,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAA,sBAAS,EAAC,MAAM,EAAE,YAAY,CAAC,CAAA;oBAE9H,SAAS,GAAG,6BAAa,CAAC,KAAK,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAA;iBACxD;gBAED,sBAAO,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,IAAI,CAAC,eAAe,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,CAAC,EAAA;;;KACpG;IACH,wBAAC;AAAD,CAAC,AAnSD,CACU,+CAAwB,GAkSjC;AAnSqB,8CAAiB"}
|
|
@@ -12,7 +12,7 @@ export declare class ERC20TokenImpl<_ProtocolNetwork extends EthereumProtocolNet
|
|
|
12
12
|
mainProtocol(): Promise<string>;
|
|
13
13
|
getContractAddress(): Promise<string>;
|
|
14
14
|
}
|
|
15
|
-
type ERC20TokenOptionsWithoutMetadata = Omit<ERC20TokenOptions, 'name' | 'identifier' | 'contractAddress' | 'symbol' | 'marketSymbol' | 'decimals'>;
|
|
15
|
+
declare type ERC20TokenOptionsWithoutMetadata = Omit<ERC20TokenOptions, 'name' | 'identifier' | 'contractAddress' | 'symbol' | 'marketSymbol' | 'decimals'>;
|
|
16
16
|
export declare function createERC20Token(metadata: ERC20TokenMetadata, options?: RecursivePartial<ERC20TokenOptionsWithoutMetadata>): ERC20Token;
|
|
17
17
|
export declare const ETHEREUM_ERC20_MAINNET_PROTOCOL_NETWORK: EthereumProtocolNetwork;
|
|
18
18
|
export declare function createERC20TokenOptions(metadata: ERC20TokenMetadata, network?: Partial<EthereumProtocolNetwork>, mainIdentifier?: string): ERC20TokenOptions;
|
|
@@ -1,53 +1,131 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
29
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
30
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
31
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
32
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
33
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
34
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
38
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
39
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
40
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
41
|
+
function step(op) {
|
|
42
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
43
|
+
while (_) try {
|
|
44
|
+
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;
|
|
45
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
46
|
+
switch (op[0]) {
|
|
47
|
+
case 0: case 1: t = op; break;
|
|
48
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
49
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
50
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
51
|
+
default:
|
|
52
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
53
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
54
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
55
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
56
|
+
if (t[2]) _.ops.pop();
|
|
57
|
+
_.trys.pop(); continue;
|
|
58
|
+
}
|
|
59
|
+
op = body.call(thisArg, _);
|
|
60
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
61
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
62
|
+
}
|
|
63
|
+
};
|
|
2
64
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ETHEREUM_ERC20_MAINNET_PROTOCOL_NETWORK = exports.ERC20TokenImpl = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const EthereumProtocol_1 = require("../EthereumProtocol");
|
|
10
|
-
const ERC20Protocol_1 = require("./ERC20Protocol");
|
|
65
|
+
exports.createERC20TokenOptions = exports.ETHEREUM_ERC20_MAINNET_PROTOCOL_NETWORK = exports.createERC20Token = exports.ERC20TokenImpl = void 0;
|
|
66
|
+
var coinlib_core_1 = require("@airgap/coinlib-core");
|
|
67
|
+
var EtherscanInfoClient_1 = require("../../clients/info/EtherscanInfoClient");
|
|
68
|
+
var HttpEthereumNodeClient_1 = require("../../clients/node/HttpEthereumNodeClient");
|
|
69
|
+
var EthereumProtocol_1 = require("../EthereumProtocol");
|
|
70
|
+
var ERC20Protocol_1 = require("./ERC20Protocol");
|
|
11
71
|
// Implementation
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
72
|
+
var ERC20TokenImpl = /** @class */ (function (_super) {
|
|
73
|
+
__extends(ERC20TokenImpl, _super);
|
|
74
|
+
function ERC20TokenImpl(nodeClient, infoClient, options) {
|
|
75
|
+
var _this = _super.call(this, nodeClient, infoClient, options) || this;
|
|
76
|
+
_this._mainProtocol = options.mainIdentifier;
|
|
77
|
+
return _this;
|
|
16
78
|
}
|
|
17
79
|
// SubProtocol
|
|
18
|
-
|
|
19
|
-
return
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
80
|
+
ERC20TokenImpl.prototype.getType = function () {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
82
|
+
return __generator(this, function (_a) {
|
|
83
|
+
return [2 /*return*/, 'token'];
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
ERC20TokenImpl.prototype.mainProtocol = function () {
|
|
88
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
89
|
+
return __generator(this, function (_a) {
|
|
90
|
+
return [2 /*return*/, this._mainProtocol];
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
ERC20TokenImpl.prototype.getContractAddress = function () {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
96
|
+
return __generator(this, function (_a) {
|
|
97
|
+
return [2 /*return*/, this.contractAddress];
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
return ERC20TokenImpl;
|
|
102
|
+
}(ERC20Protocol_1.ERC20ProtocolImpl));
|
|
28
103
|
exports.ERC20TokenImpl = ERC20TokenImpl;
|
|
29
|
-
function createERC20Token(metadata, options
|
|
30
|
-
|
|
104
|
+
function createERC20Token(metadata, options) {
|
|
105
|
+
if (options === void 0) { options = {}; }
|
|
106
|
+
var completeOptions = createERC20TokenOptions(metadata, options.network, options.mainIdentifier);
|
|
31
107
|
return new ERC20TokenImpl(new HttpEthereumNodeClient_1.HttpEthereumNodeClient(completeOptions.network.rpcUrl), new EtherscanInfoClient_1.EtherscanInfoClient(completeOptions.network.blockExplorerApi), completeOptions);
|
|
32
108
|
}
|
|
33
|
-
exports.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
109
|
+
exports.createERC20Token = createERC20Token;
|
|
110
|
+
exports.ETHEREUM_ERC20_MAINNET_PROTOCOL_NETWORK = __assign({}, EthereumProtocol_1.ETHEREUM_MAINNET_PROTOCOL_NETWORK);
|
|
111
|
+
var DEFAULT_ERC20_PROTOCOL_NETWORK = exports.ETHEREUM_ERC20_MAINNET_PROTOCOL_NETWORK;
|
|
112
|
+
function createERC20TokenOptions(metadata, network, mainIdentifier) {
|
|
113
|
+
var _a;
|
|
114
|
+
if (network === void 0) { network = {}; }
|
|
38
115
|
return {
|
|
39
|
-
network: {
|
|
116
|
+
network: __assign(__assign({}, DEFAULT_ERC20_PROTOCOL_NETWORK), network),
|
|
40
117
|
name: metadata.name,
|
|
41
118
|
identifier: metadata.identifier,
|
|
42
|
-
mainIdentifier: mainIdentifier
|
|
119
|
+
mainIdentifier: mainIdentifier !== null && mainIdentifier !== void 0 ? mainIdentifier : coinlib_core_1.MainProtocolSymbols.ETH,
|
|
43
120
|
contractAddress: metadata.contractAddress,
|
|
44
|
-
units: {
|
|
45
|
-
[metadata.symbol]
|
|
121
|
+
units: (_a = {},
|
|
122
|
+
_a[metadata.symbol] = {
|
|
46
123
|
symbol: { value: metadata.symbol, market: metadata.marketSymbol },
|
|
47
124
|
decimals: metadata.decimals
|
|
48
|
-
}
|
|
49
|
-
|
|
125
|
+
},
|
|
126
|
+
_a),
|
|
50
127
|
mainUnit: metadata.symbol
|
|
51
128
|
};
|
|
52
129
|
}
|
|
130
|
+
exports.createERC20TokenOptions = createERC20TokenOptions;
|
|
53
131
|
//# sourceMappingURL=ERC20Token.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ERC20Token.js","sourceRoot":"","sources":["../../../../src/v1/protocol/erc20/ERC20Token.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ERC20Token.js","sourceRoot":"","sources":["../../../../src/v1/protocol/erc20/ERC20Token.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAA0D;AAM1D,8EAA4E;AAC5E,oFAAkF;AAGlF,w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Ac,aAAd,cAAc,cAAd,cAAc,GAAI,kCAAmB,CAAC,GAAG;QAEzD,eAAe,EAAE,QAAQ,CAAC,eAAe;QAEzC,KAAK;YACH,GAAC,QAAQ,CAAC,MAAM,IAAG;gBACjB,MAAM,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,YAAY,EAAE;gBACjE,QAAQ,EAAE,QAAQ,CAAC,QAAQ;aAC5B;eACF;QACD,QAAQ,EAAE,QAAQ,CAAC,MAAM;KAC1B,CAAA;AACH,CAAC;AArBD,0DAqBC"}
|
|
@@ -1,10 +1,29 @@
|
|
|
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.ethereumUnsignedTransactionToRequest =
|
|
4
|
-
|
|
5
|
-
exports.ethereumTransactionSignRequestToUnsigned = ethereumTransactionSignRequestToUnsigned;
|
|
6
|
-
exports.ethereumTransactionSignResponseToSigned = ethereumTransactionSignResponseToSigned;
|
|
7
|
-
const module_kit_1 = require("@airgap/module-kit");
|
|
25
|
+
exports.ethereumTransactionSignResponseToSigned = exports.ethereumTransactionSignRequestToUnsigned = exports.ethereumSignedTransactionToResponse = exports.ethereumUnsignedTransactionToRequest = void 0;
|
|
26
|
+
var module_kit_1 = require("@airgap/module-kit");
|
|
8
27
|
function isEthereumTypedTransactionSignRequest(request) {
|
|
9
28
|
return (0, module_kit_1.implementsInterface)(request.transaction, {
|
|
10
29
|
derivationPath: 'required',
|
|
@@ -17,49 +36,47 @@ function ethereumUnsignedTransactionToRequest(unsigned, publicKey, callbackUrl)
|
|
|
17
36
|
? ethereumRawUnsignedTransactionToRequest(unsigned, publicKey, callbackUrl)
|
|
18
37
|
: ethereumTypedUnsignedTransactionToRequest(unsigned, publicKey, callbackUrl);
|
|
19
38
|
}
|
|
39
|
+
exports.ethereumUnsignedTransactionToRequest = ethereumUnsignedTransactionToRequest;
|
|
20
40
|
function ethereumRawUnsignedTransactionToRequest(unsigned, publicKey, callbackUrl) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
...rest,
|
|
25
|
-
to: toHEX
|
|
26
|
-
};
|
|
41
|
+
var _ = unsigned.type, to = unsigned.to, rest = __rest(unsigned, ["type", "to"]);
|
|
42
|
+
var toHEX = Buffer.from(to, 'utf-8').toString('hex');
|
|
43
|
+
var transaction = __assign(__assign({}, rest), { to: toHEX });
|
|
27
44
|
return {
|
|
28
|
-
transaction,
|
|
29
|
-
publicKey,
|
|
45
|
+
transaction: transaction,
|
|
46
|
+
publicKey: publicKey,
|
|
30
47
|
callbackURL: callbackUrl
|
|
31
48
|
};
|
|
32
49
|
}
|
|
33
50
|
function ethereumTypedUnsignedTransactionToRequest(unsigned, publicKey, callbackUrl) {
|
|
34
|
-
|
|
51
|
+
var _ = unsigned.type, rest = __rest(unsigned, ["type"]);
|
|
35
52
|
return {
|
|
36
53
|
transaction: rest,
|
|
37
|
-
publicKey,
|
|
54
|
+
publicKey: publicKey,
|
|
38
55
|
callbackURL: callbackUrl
|
|
39
56
|
};
|
|
40
57
|
}
|
|
41
58
|
function ethereumSignedTransactionToResponse(signed, accountIdentifier) {
|
|
42
|
-
return { transaction: signed.serialized, accountIdentifier };
|
|
59
|
+
return { transaction: signed.serialized, accountIdentifier: accountIdentifier };
|
|
43
60
|
}
|
|
61
|
+
exports.ethereumSignedTransactionToResponse = ethereumSignedTransactionToResponse;
|
|
44
62
|
function ethereumTransactionSignRequestToUnsigned(request) {
|
|
45
63
|
return isEthereumTypedTransactionSignRequest(request)
|
|
46
64
|
? ethereumTransactionSignRequestToTypedUnsigned(request)
|
|
47
65
|
: ethereumTransactionSignRequestToRawUnsigned(request);
|
|
48
66
|
}
|
|
67
|
+
exports.ethereumTransactionSignRequestToUnsigned = ethereumTransactionSignRequestToUnsigned;
|
|
49
68
|
function ethereumTransactionSignRequestToRawUnsigned(request) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
to: isStringAddress ? to : toUTF8
|
|
56
|
-
};
|
|
57
|
-
return (0, module_kit_1.newUnsignedTransaction)({ ethereumType: 'raw', ...transaction });
|
|
69
|
+
var _a = request.transaction, to = _a.to, rest = __rest(_a, ["to"]);
|
|
70
|
+
var isStringAddress = /^0x[0-9a-fA-F]{40}$/.test(to);
|
|
71
|
+
var toUTF8 = Buffer.from(to, 'hex').toString('utf-8');
|
|
72
|
+
var transaction = __assign(__assign({}, rest), { to: isStringAddress ? to : toUTF8 });
|
|
73
|
+
return (0, module_kit_1.newUnsignedTransaction)(__assign({ ethereumType: 'raw' }, transaction));
|
|
58
74
|
}
|
|
59
75
|
function ethereumTransactionSignRequestToTypedUnsigned(request) {
|
|
60
|
-
return (0, module_kit_1.newUnsignedTransaction)({ ethereumType: 'typed',
|
|
76
|
+
return (0, module_kit_1.newUnsignedTransaction)(__assign({ ethereumType: 'typed' }, request.transaction));
|
|
61
77
|
}
|
|
62
78
|
function ethereumTransactionSignResponseToSigned(response) {
|
|
63
79
|
return (0, module_kit_1.newSignedTransaction)({ serialized: response.transaction });
|
|
64
80
|
}
|
|
81
|
+
exports.ethereumTransactionSignResponseToSigned = ethereumTransactionSignResponseToSigned;
|
|
65
82
|
//# sourceMappingURL=transaction-converter.js.map
|
|
@@ -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,SAAS,uCAAuC,CAC9C,QAAwC,EACxC,SAAiB,EACjB,WAAoB;IAEZ,IAAM,CAAC,GAAkB,QAAQ,KAA1B,EAAE,EAAE,GAAc,QAAQ,GAAtB,EAAK,IAAI,UAAK,QAAQ,EAAnC,cAAwB,CAAF,CAAa;IAEzC,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AC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,GAClC,CAAA;IAED,OAAO,IAAA,mCAAsB,aAAmC,YAAY,EAAE,KAAK,IAAK,WAAW,EAAG,CAAA;AACxG,CAAC;AAED,SAAS,6CAA6C,CAAC,OAA4C;IACjG,OAAO,IAAA,mCAAsB,aAAqC,YAAY,EAAE,OAAO,IAAK,OAAO,CAAC,WAAW,EAAG,CAAA;AACpH,CAAC;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,16 +1,52 @@
|
|
|
1
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
|
+
};
|
|
2
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
39
|
exports.EthereumV3SerializerCompanion = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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() {
|
|
14
50
|
this.schemas = [
|
|
15
51
|
{
|
|
16
52
|
type: serializer_1.IACMessageType.TransactionSignRequest,
|
|
@@ -40,66 +76,107 @@ class EthereumV3SerializerCompanion {
|
|
|
40
76
|
];
|
|
41
77
|
this.ethereumTransactionValidator = new transaction_validator_1.EthereumTransactionValidator();
|
|
42
78
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
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
|
+
if (identifier === coinlib_core_1.MainProtocolSymbols.ETH || identifier.startsWith(coinlib_core_1.SubProtocolSymbols.ETH_ERC20)) {
|
|
83
|
+
return [2 /*return*/, (0, transaction_converter_1.ethereumUnsignedTransactionToRequest)(unsignedTransaction, publicKey, callbackUrl)];
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, "Protocol ".concat(identifier, " not supported"));
|
|
87
|
+
}
|
|
88
|
+
return [2 /*return*/];
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
EthereumV3SerializerCompanion.prototype.fromTransactionSignRequest = function (identifier, transactionSignRequest) {
|
|
93
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
94
|
+
return __generator(this, function (_a) {
|
|
95
|
+
if (identifier === coinlib_core_1.MainProtocolSymbols.ETH || identifier.startsWith(coinlib_core_1.SubProtocolSymbols.ETH_ERC20)) {
|
|
96
|
+
return [2 /*return*/, (0, transaction_converter_1.ethereumTransactionSignRequestToUnsigned)(transactionSignRequest)];
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, "Protocol ".concat(identifier, " not supported"));
|
|
100
|
+
}
|
|
101
|
+
return [2 /*return*/];
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
EthereumV3SerializerCompanion.prototype.validateTransactionSignRequest = function (identifier, transactionSignRequest) {
|
|
106
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
107
|
+
var _a;
|
|
108
|
+
return __generator(this, function (_b) {
|
|
109
|
+
switch (_b.label) {
|
|
110
|
+
case 0:
|
|
111
|
+
if (!(identifier === coinlib_core_1.MainProtocolSymbols.ETH || identifier.startsWith(coinlib_core_1.SubProtocolSymbols.ETH_ERC20))) return [3 /*break*/, 5];
|
|
112
|
+
_b.label = 1;
|
|
113
|
+
case 1:
|
|
114
|
+
_b.trys.push([1, 3, , 4]);
|
|
115
|
+
return [4 /*yield*/, this.ethereumTransactionValidator.validateUnsignedTransaction(transactionSignRequest)];
|
|
116
|
+
case 2:
|
|
117
|
+
_b.sent();
|
|
118
|
+
return [2 /*return*/, true];
|
|
119
|
+
case 3:
|
|
120
|
+
_a = _b.sent();
|
|
121
|
+
return [2 /*return*/, false];
|
|
122
|
+
case 4: return [3 /*break*/, 6];
|
|
123
|
+
case 5: throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, "Protocol ".concat(identifier, " not supported"));
|
|
124
|
+
case 6: return [2 /*return*/];
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
EthereumV3SerializerCompanion.prototype.toTransactionSignResponse = function (identifier, signedTransaction, accountIdentifier) {
|
|
130
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
131
|
+
return __generator(this, function (_a) {
|
|
132
|
+
if (identifier === coinlib_core_1.MainProtocolSymbols.ETH || identifier.startsWith(coinlib_core_1.SubProtocolSymbols.ETH_ERC20)) {
|
|
133
|
+
return [2 /*return*/, (0, transaction_converter_1.ethereumSignedTransactionToResponse)(signedTransaction, accountIdentifier)];
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, "Protocol ".concat(identifier, " not supported"));
|
|
137
|
+
}
|
|
138
|
+
return [2 /*return*/];
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
EthereumV3SerializerCompanion.prototype.fromTransactionSignResponse = function (identifier, transactionSignResponse) {
|
|
143
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
144
|
+
return __generator(this, function (_a) {
|
|
145
|
+
if (identifier === coinlib_core_1.MainProtocolSymbols.ETH || identifier.startsWith(coinlib_core_1.SubProtocolSymbols.ETH_ERC20)) {
|
|
146
|
+
return [2 /*return*/, (0, transaction_converter_1.ethereumTransactionSignResponseToSigned)(transactionSignResponse)];
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, "Protocol ".concat(identifier, " not supported"));
|
|
150
|
+
}
|
|
151
|
+
return [2 /*return*/];
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
};
|
|
155
|
+
EthereumV3SerializerCompanion.prototype.validateTransactionSignResponse = function (identifier, transactionSignResponse) {
|
|
156
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
157
|
+
var _a;
|
|
158
|
+
return __generator(this, function (_b) {
|
|
159
|
+
switch (_b.label) {
|
|
160
|
+
case 0:
|
|
161
|
+
if (!(identifier === coinlib_core_1.MainProtocolSymbols.ETH || identifier.startsWith(coinlib_core_1.SubProtocolSymbols.ETH_ERC20))) return [3 /*break*/, 5];
|
|
162
|
+
_b.label = 1;
|
|
163
|
+
case 1:
|
|
164
|
+
_b.trys.push([1, 3, , 4]);
|
|
165
|
+
return [4 /*yield*/, this.ethereumTransactionValidator.validateSignedTransaction(transactionSignResponse)];
|
|
166
|
+
case 2:
|
|
167
|
+
_b.sent();
|
|
168
|
+
return [2 /*return*/, true];
|
|
169
|
+
case 3:
|
|
170
|
+
_a = _b.sent();
|
|
171
|
+
return [2 /*return*/, false];
|
|
172
|
+
case 4: return [3 /*break*/, 6];
|
|
173
|
+
case 5: throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, "Protocol ".concat(identifier, " not supported"));
|
|
174
|
+
case 6: return [2 /*return*/];
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
};
|
|
179
|
+
return EthereumV3SerializerCompanion;
|
|
180
|
+
}());
|
|
104
181
|
exports.EthereumV3SerializerCompanion = EthereumV3SerializerCompanion;
|
|
105
182
|
//# sourceMappingURL=serializer-companion.js.map
|