@airgap/ethereum 0.13.45-beta.2 → 0.13.45-beta.3
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 +0 -1
- package/v0/protocol/BaseEthereumProtocol.js +460 -872
- package/v0/protocol/BaseEthereumProtocol.js.map +1 -1
- package/v0/protocol/EthereumAddress.d.ts +0 -1
- package/v0/protocol/EthereumAddress.js +26 -17
- package/v0/protocol/EthereumAddress.js.map +1 -1
- package/v0/protocol/EthereumClassicProtocol.js +6 -23
- package/v0/protocol/EthereumClassicProtocol.js.map +1 -1
- package/v0/protocol/EthereumCryptoClient.js +66 -125
- package/v0/protocol/EthereumCryptoClient.js.map +1 -1
- package/v0/protocol/EthereumProtocol.js +9 -28
- package/v0/protocol/EthereumProtocol.js.map +1 -1
- package/v0/protocol/EthereumProtocolOptions.d.ts +1 -1
- package/v0/protocol/EthereumProtocolOptions.js +36 -117
- package/v0/protocol/EthereumProtocolOptions.js.map +1 -1
- package/v0/protocol/EthereumRopstenProtocol.js +6 -23
- package/v0/protocol/EthereumRopstenProtocol.js.map +1 -1
- package/v0/protocol/clients/info-clients/EtherscanInfoClient.js +86 -186
- package/v0/protocol/clients/info-clients/EtherscanInfoClient.js.map +1 -1
- package/v0/protocol/clients/info-clients/InfoClient.js +3 -4
- package/v0/protocol/clients/info-clients/InfoClient.js.map +1 -1
- package/v0/protocol/clients/node-clients/AirGapNodeClient.js +126 -298
- package/v0/protocol/clients/node-clients/AirGapNodeClient.js.map +1 -1
- package/v0/protocol/clients/node-clients/NodeClient.js +3 -4
- 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 +161 -300
- package/v0/protocol/erc20/GenericERC20.js.map +1 -1
- package/v0/protocol/utils/utils.js +52 -55
- package/v0/protocol/utils/utils.js.map +1 -1
- package/v0/serializer/validators/transaction-validator.js +23 -31
- package/v0/serializer/validators/transaction-validator.js.map +1 -1
- package/v0/serializer/validators/validators.js +25 -73
- package/v0/serializer/validators/validators.js.map +1 -1
- package/v1/block-explorer/EtherscanBlockExplorer.js +12 -61
- package/v1/block-explorer/EtherscanBlockExplorer.js.map +1 -1
- package/v1/clients/crypto/EthereumCryptoClient.js +69 -124
- package/v1/clients/crypto/EthereumCryptoClient.js.map +1 -1
- package/v1/clients/info/EthereumInfoClient.d.ts +1 -1
- package/v1/clients/info/EthereumInfoClient.js +3 -4
- package/v1/clients/info/EthereumInfoClient.js.map +1 -1
- package/v1/clients/info/EtherscanInfoClient.js +84 -162
- package/v1/clients/info/EtherscanInfoClient.js.map +1 -1
- package/v1/clients/node/HttpEthereumNodeClient.d.ts +2 -2
- package/v1/clients/node/HttpEthereumNodeClient.js +164 -375
- package/v1/clients/node/HttpEthereumNodeClient.js.map +1 -1
- package/v1/data/EthereumAddress.js +29 -20
- 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 +43 -112
- package/v1/module/EthereumModule.js.map +1 -1
- package/v1/module.js +2 -3
- package/v1/module.js.map +1 -1
- package/v1/protocol/EthereumBaseProtocol.js +467 -788
- package/v1/protocol/EthereumBaseProtocol.js.map +1 -1
- package/v1/protocol/EthereumProtocol.js +15 -46
- package/v1/protocol/EthereumProtocol.js.map +1 -1
- package/v1/protocol/erc20/ERC20Protocol.js +213 -360
- package/v1/protocol/erc20/ERC20Protocol.js.map +1 -1
- package/v1/protocol/erc20/ERC20Token.d.ts +1 -1
- package/v1/protocol/erc20/ERC20Token.js +35 -113
- package/v1/protocol/erc20/ERC20Token.js.map +1 -1
- package/v1/serializer/v3/schemas/converter/transaction-converter.js +25 -42
- package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -1
- package/v1/serializer/v3/serializer-companion.js +71 -148
- package/v1/serializer/v3/serializer-companion.js.map +1 -1
- package/v1/serializer/v3/validators/transaction-validator.js +14 -17
- 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 +57 -60
- package/v1/utils/EthereumUtils.js.map +1 -1
- package/v1/utils/key.js +28 -19
- package/v1/utils/key.js.map +1 -1
- package/v1/utils/protocol.js +33 -21
- 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,uDAA0D;AAC1D,mHAA0F;AAC1F,aAAa;AACb,qGAAsF;AACtF,wDAAqG;AACrG,wDAAsD;AACtD,mDAc2B;AAC3B,uCAAgF;AAGhF,sFAAmF;AASnF,6DAAyD;AACzD,kEAAwF;AAExF,MAAM,mBAAmB,GAAG,OAAO,CAAC,iEAAiE,CAAC,CAAA;AAWtG,iBAAiB;AAEjB,MAAsB,iBACpB,SAAQ,+CAAkD;IAK1D,YACE,UAA8B,EAC9B,UAA8B,EAC9B,OAAuD;QAEvD,KAAK,CAAC,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,OAAO,CAAC,QAAQ;SAC3B,CAAC,CAAA;QACF,IAAI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iB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;IAChE,CAAC;IAEM,KAAK,CAAC,QAAQ;QACnB,OAAO,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;IAClE,CAAC;IAES,KAAK,CAAC,WAAW,CACzB,WAAmB,EACnB,SAAiB,EACjB,MAA4C,EAC5C,KAAc;QAEd,IAAI,SAAiB,CAAA;QACrB,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,IAAA,WAAK,EAAC,MAAM,CAAC,EAAE,CAAC;YAChD,SAAS,GAAG,MAAM,CAAA;QACpB,CAAC;aAAM,CAAC;YACN,MAAM,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;YAE9H,SAAS,GAAG,6BAAa,CAAC,KAAK,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAA;QACzD,CAAC;QAED,OAAO,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,IAAI,CAAC,eAAe,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,CAAC,CAAA;IACrG,CAAC;CACF;AAnSD,8CAmSC"}
|
|
@@ -12,7 +12,7 @@ export declare class ERC20TokenImpl<_ProtocolNetwork extends EthereumProtocolNet
|
|
|
12
12
|
mainProtocol(): Promise<string>;
|
|
13
13
|
getContractAddress(): Promise<string>;
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
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,131 +1,53 @@
|
|
|
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
|
-
};
|
|
64
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
65
|
-
exports.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
3
|
+
exports.ETHEREUM_ERC20_MAINNET_PROTOCOL_NETWORK = exports.ERC20TokenImpl = void 0;
|
|
4
|
+
exports.createERC20Token = createERC20Token;
|
|
5
|
+
exports.createERC20TokenOptions = createERC20TokenOptions;
|
|
6
|
+
const coinlib_core_1 = require("@airgap/coinlib-core");
|
|
7
|
+
const EtherscanInfoClient_1 = require("../../clients/info/EtherscanInfoClient");
|
|
8
|
+
const HttpEthereumNodeClient_1 = require("../../clients/node/HttpEthereumNodeClient");
|
|
9
|
+
const EthereumProtocol_1 = require("../EthereumProtocol");
|
|
10
|
+
const ERC20Protocol_1 = require("./ERC20Protocol");
|
|
71
11
|
// Implementation
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
_this._mainProtocol = options.mainIdentifier;
|
|
77
|
-
return _this;
|
|
12
|
+
class ERC20TokenImpl extends ERC20Protocol_1.ERC20ProtocolImpl {
|
|
13
|
+
constructor(nodeClient, infoClient, options) {
|
|
14
|
+
super(nodeClient, infoClient, options);
|
|
15
|
+
this._mainProtocol = options.mainIdentifier;
|
|
78
16
|
}
|
|
79
17
|
// SubProtocol
|
|
80
|
-
|
|
81
|
-
return
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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));
|
|
18
|
+
async getType() {
|
|
19
|
+
return 'token';
|
|
20
|
+
}
|
|
21
|
+
async mainProtocol() {
|
|
22
|
+
return this._mainProtocol;
|
|
23
|
+
}
|
|
24
|
+
async getContractAddress() {
|
|
25
|
+
return this.contractAddress;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
103
28
|
exports.ERC20TokenImpl = ERC20TokenImpl;
|
|
104
|
-
function createERC20Token(metadata, options) {
|
|
105
|
-
|
|
106
|
-
var completeOptions = createERC20TokenOptions(metadata, options.network, options.mainIdentifier);
|
|
29
|
+
function createERC20Token(metadata, options = {}) {
|
|
30
|
+
const completeOptions = createERC20TokenOptions(metadata, options.network, options.mainIdentifier);
|
|
107
31
|
return new ERC20TokenImpl(new HttpEthereumNodeClient_1.HttpEthereumNodeClient(completeOptions.network.rpcUrl), new EtherscanInfoClient_1.EtherscanInfoClient(completeOptions.network.blockExplorerApi), completeOptions);
|
|
108
32
|
}
|
|
109
|
-
exports.
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
if (network === void 0) { network = {}; }
|
|
33
|
+
exports.ETHEREUM_ERC20_MAINNET_PROTOCOL_NETWORK = {
|
|
34
|
+
...EthereumProtocol_1.ETHEREUM_MAINNET_PROTOCOL_NETWORK
|
|
35
|
+
};
|
|
36
|
+
const DEFAULT_ERC20_PROTOCOL_NETWORK = exports.ETHEREUM_ERC20_MAINNET_PROTOCOL_NETWORK;
|
|
37
|
+
function createERC20TokenOptions(metadata, network = {}, mainIdentifier) {
|
|
115
38
|
return {
|
|
116
|
-
network:
|
|
39
|
+
network: { ...DEFAULT_ERC20_PROTOCOL_NETWORK, ...network },
|
|
117
40
|
name: metadata.name,
|
|
118
41
|
identifier: metadata.identifier,
|
|
119
|
-
mainIdentifier: mainIdentifier
|
|
42
|
+
mainIdentifier: mainIdentifier ?? coinlib_core_1.MainProtocolSymbols.ETH,
|
|
120
43
|
contractAddress: metadata.contractAddress,
|
|
121
|
-
units:
|
|
122
|
-
|
|
44
|
+
units: {
|
|
45
|
+
[metadata.symbol]: {
|
|
123
46
|
symbol: { value: metadata.symbol, market: metadata.marketSymbol },
|
|
124
47
|
decimals: metadata.decimals
|
|
125
|
-
}
|
|
126
|
-
|
|
48
|
+
}
|
|
49
|
+
},
|
|
127
50
|
mainUnit: metadata.symbol
|
|
128
51
|
};
|
|
129
52
|
}
|
|
130
|
-
exports.createERC20TokenOptions = createERC20TokenOptions;
|
|
131
53
|
//# 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":";;;AAsDA,4CAWC;AAQD,0DAqBC;AA9FD,uDAA0D;AAM1D,gFAA4E;AAC5E,sFAAkF;AAGlF,0DAAuE;AAEvE,mDAAkE;AAOlE,iBAAiB;AAEjB,MAAa,cACX,SAAQ,iCAA2C;IAGnD,YAAmB,UAA8B,EAAE,UAA8B,EAAE,OAA4C;QAC7H,KAAK,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;QAEtC,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,cAAc,CAAA;IAC7C,CAAC;IAED,cAAc;IAEP,KAAK,CAAC,OAAO;QAClB,OAAO,OAAO,CAAA;IAChB,CAAC;IAGM,KAAK,CAA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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
|
-
};
|
|
24
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.
|
|
26
|
-
|
|
3
|
+
exports.ethereumUnsignedTransactionToRequest = ethereumUnsignedTransactionToRequest;
|
|
4
|
+
exports.ethereumSignedTransactionToResponse = ethereumSignedTransactionToResponse;
|
|
5
|
+
exports.ethereumTransactionSignRequestToUnsigned = ethereumTransactionSignRequestToUnsigned;
|
|
6
|
+
exports.ethereumTransactionSignResponseToSigned = ethereumTransactionSignResponseToSigned;
|
|
7
|
+
const module_kit_1 = require("@airgap/module-kit");
|
|
27
8
|
function isEthereumTypedTransactionSignRequest(request) {
|
|
28
9
|
return (0, module_kit_1.implementsInterface)(request.transaction, {
|
|
29
10
|
derivationPath: 'required',
|
|
@@ -36,47 +17,49 @@ function ethereumUnsignedTransactionToRequest(unsigned, publicKey, callbackUrl)
|
|
|
36
17
|
? ethereumRawUnsignedTransactionToRequest(unsigned, publicKey, callbackUrl)
|
|
37
18
|
: ethereumTypedUnsignedTransactionToRequest(unsigned, publicKey, callbackUrl);
|
|
38
19
|
}
|
|
39
|
-
exports.ethereumUnsignedTransactionToRequest = ethereumUnsignedTransactionToRequest;
|
|
40
20
|
function ethereumRawUnsignedTransactionToRequest(unsigned, publicKey, callbackUrl) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
21
|
+
const { type: _, to, ...rest } = unsigned;
|
|
22
|
+
const toHEX = Buffer.from(to, 'utf-8').toString('hex');
|
|
23
|
+
const transaction = {
|
|
24
|
+
...rest,
|
|
25
|
+
to: toHEX
|
|
26
|
+
};
|
|
44
27
|
return {
|
|
45
|
-
transaction
|
|
46
|
-
publicKey
|
|
28
|
+
transaction,
|
|
29
|
+
publicKey,
|
|
47
30
|
callbackURL: callbackUrl
|
|
48
31
|
};
|
|
49
32
|
}
|
|
50
33
|
function ethereumTypedUnsignedTransactionToRequest(unsigned, publicKey, callbackUrl) {
|
|
51
|
-
|
|
34
|
+
const { type: _, ...rest } = unsigned;
|
|
52
35
|
return {
|
|
53
36
|
transaction: rest,
|
|
54
|
-
publicKey
|
|
37
|
+
publicKey,
|
|
55
38
|
callbackURL: callbackUrl
|
|
56
39
|
};
|
|
57
40
|
}
|
|
58
41
|
function ethereumSignedTransactionToResponse(signed, accountIdentifier) {
|
|
59
|
-
return { transaction: signed.serialized, accountIdentifier
|
|
42
|
+
return { transaction: signed.serialized, accountIdentifier };
|
|
60
43
|
}
|
|
61
|
-
exports.ethereumSignedTransactionToResponse = ethereumSignedTransactionToResponse;
|
|
62
44
|
function ethereumTransactionSignRequestToUnsigned(request) {
|
|
63
45
|
return isEthereumTypedTransactionSignRequest(request)
|
|
64
46
|
? ethereumTransactionSignRequestToTypedUnsigned(request)
|
|
65
47
|
: ethereumTransactionSignRequestToRawUnsigned(request);
|
|
66
48
|
}
|
|
67
|
-
exports.ethereumTransactionSignRequestToUnsigned = ethereumTransactionSignRequestToUnsigned;
|
|
68
49
|
function ethereumTransactionSignRequestToRawUnsigned(request) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
50
|
+
const { to, ...rest } = request.transaction;
|
|
51
|
+
const isStringAddress = /^0x[0-9a-fA-F]{40}$/.test(to);
|
|
52
|
+
const toUTF8 = Buffer.from(to, 'hex').toString('utf-8');
|
|
53
|
+
const transaction = {
|
|
54
|
+
...rest,
|
|
55
|
+
to: isStringAddress ? to : toUTF8
|
|
56
|
+
};
|
|
57
|
+
return (0, module_kit_1.newUnsignedTransaction)({ ethereumType: 'raw', ...transaction });
|
|
74
58
|
}
|
|
75
59
|
function ethereumTransactionSignRequestToTypedUnsigned(request) {
|
|
76
|
-
return (0, module_kit_1.newUnsignedTransaction)(
|
|
60
|
+
return (0, module_kit_1.newUnsignedTransaction)({ ethereumType: 'typed', ...request.transaction });
|
|
77
61
|
}
|
|
78
62
|
function ethereumTransactionSignResponseToSigned(response) {
|
|
79
63
|
return (0, module_kit_1.newSignedTransaction)({ serialized: response.transaction });
|
|
80
64
|
}
|
|
81
|
-
exports.ethereumTransactionSignResponseToSigned = ethereumTransactionSignResponseToSigned;
|
|
82
65
|
//# 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":";;AAyBA,oFAQC;AAqCD,kFAKC;AAED,4FAMC;AAqBD,0FAEC;AA1GD,mDAAsG;AAetG,SAAS,qCAAqC,CAC5C,OAA6E;IAE7E,OAAO,IAAA,gCAAmB,EAA+C,OAAO,CAAC,WAAW,EAAE;QAC5F,cA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AAC,CAAC,6CAA6C,CAAC,OAAO,CAAC;QACxD,CAAC,CAAC,2CAA2C,CAAC,OAAO,CAAC,CAAA;AAC1D,CAAC;AAED,SAAS,2CAA2C,CAAC,OAAuC;IAC1F,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC,WAAW,CAAA;IAE3C,MAAM,eAAe,GAAG,qBAAqB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAEtD,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;IAEvD,MAAM,WAAW,GAAG;QAClB,GAAG,IAAI;QACP,EAAE,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM;KAClC,CAAA;IAED,OAAO,IAAA,mCAAsB,EAAiC,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,WAAW,EAAE,CAAC,CAAA;AACxG,CAAC;AAED,SAAS,6CAA6C,CAAC,OAA4C;IACjG,OAAO,IAAA,mCAAsB,EAAmC,EAAE,YAAY,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,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"}
|
|
@@ -1,52 +1,16 @@
|
|
|
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
|
-
};
|
|
38
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
3
|
exports.EthereumV3SerializerCompanion = void 0;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
4
|
+
const coinlib_core_1 = require("@airgap/coinlib-core");
|
|
5
|
+
const errors_1 = require("@airgap/coinlib-core/errors");
|
|
6
|
+
const serializer_1 = require("@airgap/serializer");
|
|
7
|
+
const transaction_converter_1 = require("./schemas/converter/transaction-converter");
|
|
8
|
+
const transaction_validator_1 = require("./validators/transaction-validator");
|
|
9
|
+
const ethereumTransactionSignRequest = require('./schemas/generated/transaction-sign-request-ethereum.json');
|
|
10
|
+
const ethereumTypedTransactionSignRequest = require('./schemas/generated/transaction-sign-request-ethereum-typed.json');
|
|
11
|
+
const ethereumTransactionSignResponse = require('./schemas/generated/transaction-sign-response-ethereum.json');
|
|
12
|
+
class EthereumV3SerializerCompanion {
|
|
13
|
+
constructor() {
|
|
50
14
|
this.schemas = [
|
|
51
15
|
{
|
|
52
16
|
type: serializer_1.IACMessageType.TransactionSignRequest,
|
|
@@ -76,107 +40,66 @@ var EthereumV3SerializerCompanion = /** @class */ (function () {
|
|
|
76
40
|
];
|
|
77
41
|
this.ethereumTransactionValidator = new transaction_validator_1.EthereumTransactionValidator();
|
|
78
42
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
return
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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
|
-
}());
|
|
43
|
+
async toTransactionSignRequest(identifier, unsignedTransaction, publicKey, callbackUrl) {
|
|
44
|
+
if (identifier === coinlib_core_1.MainProtocolSymbols.ETH || identifier.startsWith(coinlib_core_1.SubProtocolSymbols.ETH_ERC20)) {
|
|
45
|
+
return (0, transaction_converter_1.ethereumUnsignedTransactionToRequest)(unsignedTransaction, publicKey, callbackUrl);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, `Protocol ${identifier} not supported`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async fromTransactionSignRequest(identifier, transactionSignRequest) {
|
|
52
|
+
if (identifier === coinlib_core_1.MainProtocolSymbols.ETH || identifier.startsWith(coinlib_core_1.SubProtocolSymbols.ETH_ERC20)) {
|
|
53
|
+
return (0, transaction_converter_1.ethereumTransactionSignRequestToUnsigned)(transactionSignRequest);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, `Protocol ${identifier} not supported`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async validateTransactionSignRequest(identifier, transactionSignRequest) {
|
|
60
|
+
if (identifier === coinlib_core_1.MainProtocolSymbols.ETH || identifier.startsWith(coinlib_core_1.SubProtocolSymbols.ETH_ERC20)) {
|
|
61
|
+
try {
|
|
62
|
+
await this.ethereumTransactionValidator.validateUnsignedTransaction(transactionSignRequest);
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, `Protocol ${identifier} not supported`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
async toTransactionSignResponse(identifier, signedTransaction, accountIdentifier) {
|
|
74
|
+
if (identifier === coinlib_core_1.MainProtocolSymbols.ETH || identifier.startsWith(coinlib_core_1.SubProtocolSymbols.ETH_ERC20)) {
|
|
75
|
+
return (0, transaction_converter_1.ethereumSignedTransactionToResponse)(signedTransaction, accountIdentifier);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, `Protocol ${identifier} not supported`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
async fromTransactionSignResponse(identifier, transactionSignResponse) {
|
|
82
|
+
if (identifier === coinlib_core_1.MainProtocolSymbols.ETH || identifier.startsWith(coinlib_core_1.SubProtocolSymbols.ETH_ERC20)) {
|
|
83
|
+
return (0, transaction_converter_1.ethereumTransactionSignResponseToSigned)(transactionSignResponse);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, `Protocol ${identifier} not supported`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async validateTransactionSignResponse(identifier, transactionSignResponse) {
|
|
90
|
+
if (identifier === coinlib_core_1.MainProtocolSymbols.ETH || identifier.startsWith(coinlib_core_1.SubProtocolSymbols.ETH_ERC20)) {
|
|
91
|
+
try {
|
|
92
|
+
await this.ethereumTransactionValidator.validateSignedTransaction(transactionSignResponse);
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, `Protocol ${identifier} not supported`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
181
104
|
exports.EthereumV3SerializerCompanion = EthereumV3SerializerCompanion;
|
|
182
105
|
//# sourceMappingURL=serializer-companion.js.map
|